[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kio
From:       Dawit Alemayehu <adawit () kde ! org>
Date:       2010-05-06 23:43:24
Message-ID: 20100506234324.58155AC8B0 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1123795 by adawit:

- Added support for internal metadata. For details, read the changes in the \
DESGIN.metadata file  and/or the link below:

  http://lists.kde.org/?t=127243134200002&r=1&w=2


 M  +15 -0     DESIGN.metadata  
 M  +9 -1      kio/job.cpp  
 M  +1 -0      kio/job_p.h  
 M  +36 -2     kio/scheduler.cpp  
 M  +1 -0      kio/scheduler_p.h  


--- trunk/KDE/kdelibs/kio/DESIGN.metadata #1123794:1123795
@@ -5,7 +5,22 @@
 the behavior of a slave and is usally protocol dependent. MetaData consists
 of two strings: a "key" and a "value".
 
+Any meta data whose "key" starts with the keywords {internal~currenthost} and
+"{internal~allhosts}" will be treated as internal metadata and will not be made
+available to client applications. Instead all such meta-data will be stored and
+will appropriately be sent back to all ioslaves along with the other regular
+metadata values.
 
+Use "{internal~currenthost}" to make the internal metadata available to all
+ioslaves of the same protocol and host as the ioslave that generated it. If
+you do not want to restrict the availability of the internal metadata to only
+the current host, then use {internal~allhosts}. In either case the internal
+metadata follows the rules of the regular metadata and therefore cannot be sent
+from one protocol such as "http" to a completely different one like "ftp".
+
+Please note that when internal meta-data values are sent back to ioslaves, the
+keyword used to mark them internal will be stripped from the key name.
+
 The following keys are currently in use:
 
 Key             Value(s)        Description
--- trunk/KDE/kdelibs/kio/kio/job.cpp #1123794:1123795
@@ -588,8 +588,16 @@
 void SimpleJob::slotMetaData( const KIO::MetaData &_metaData )
 {
     Q_D(SimpleJob);
-    d->m_incomingMetaData += _metaData;
+
+    QMapIterator<QString,QString> it (_metaData);
+    while (it.hasNext()) {
+        it.next();
+        if (it.key().startsWith(QLatin1String("{internal~"), Qt::CaseInsensitive))
+            d->m_internalMetaData.insert(it.key(), it.value());
+        else
+            d->m_incomingMetaData.insert(it.key(), it.value());
 }
+}
 
 void SimpleJob::storeSSLSessionFromJob(const KUrl &redirectionURL)
 {
--- trunk/KDE/kdelibs/kio/kio/job_p.h #1123794:1123795
@@ -55,6 +55,7 @@
         Job* m_parentJob;
         int m_extraFlags;
         MetaData m_incomingMetaData;
+        MetaData m_internalMetaData;
         MetaData m_outgoingMetaData;
 
         inline KIO::JobUiDelegate *ui() const
--- trunk/KDE/kdelibs/kio/kio/scheduler.cpp #1123794:1123795
@@ -133,7 +133,6 @@
     return m_idleSlaves.values();
 }
 
-
 void SlaveKeeper::scheduleGrimReaper()
 {
     if (!m_grimTimer.isActive()) {
@@ -570,7 +569,18 @@
     return ret;
 }
 
+void ProtoQueue::updateSlaveConfigFor(const QString& host)
+{
+    Q_FOREACH(Slave *slave, allSlaves()) {
+        if (slave->host() == host) {
+            slave->setConfig(SlaveConfig::self()->configData(slave->protocol(), \
host)); +            kDebug(7006) << "Updating configuration of" << slave->protocol()
+                         << "ioslave, pid=" << slave->slave_pid();
+        }
+    }
+}
 
+
 //private slot
 void ProtoQueue::startAJob()
 {
@@ -948,17 +958,42 @@
     }
 
     KIO::SimpleJobPrivate *const jobPriv = SimpleJobPrivate::get(job);
+
+    // Preserve all internal meta-data so they can be sent back to the
+    // ioslaves as needed...
+    const KUrl jobUrl = job->url();
+    QMapIterator<QString, QString> it (jobPriv->m_internalMetaData);
+    while (it.hasNext()) {
+        it.next();        
+        if (it.key().startsWith(QLatin1String("{internal~currenthost}"), \
Qt::CaseInsensitive)) { +            \
SlaveConfig::self()->setConfigData(jobUrl.protocol(), jobUrl.host(), \
it.key().mid(22), it.value()); +        } else if \
(it.key().startsWith(QLatin1String("{internal~allhosts}"), Qt::CaseInsensitive)) { +  \
SlaveConfig::self()->setConfigData(jobUrl.protocol(), QString(), it.key().mid(19), \
it.value()); +        }
+    }
+
     // make sure that we knew about the job!
     Q_ASSERT(jobPriv->m_schedSerial);
 
     ProtoQueue *pq = m_protocols.value(jobPriv->m_protocol);
     pq->removeJob(job);
     if (slave) {
+        // If we have internal meta-data, tell existing ioslaves to reload
+        // their configuration.
+        if (jobPriv->m_internalMetaData.count()) {
+            kDebug(7006) << "Updating ioslaves with new internal metadata \
information"; +            ProtoQueue * queue = m_protocols.value(slave->protocol());
+            if (queue)
+                queue->updateSlaveConfigFor(slave->host());
+        }
         slave->setJob(0);
         slave->disconnect(job);
     }
     jobPriv->m_schedSerial = 0; // this marks the job as unscheduled again
     jobPriv->m_slave = 0;
+    // Clear the values in the internal metadata container since they have
+    // already been taken care of above...
+    jobPriv->m_internalMetaData.clear();
 }
 
 // static
@@ -1117,7 +1152,6 @@
 
 Slave *SchedulerPrivate::getConnectedSlave(const KUrl &url, const KIO::MetaData \
&config)  {
-    kDebug(7006);
     QString proxy;
     QString protocol = KProtocolManager::slaveProtocol(url, proxy);
     ProtoQueue *pq = protoQ(protocol);
--- trunk/KDE/kdelibs/kio/kio/scheduler_p.h #1123794:1123795
@@ -146,6 +146,7 @@
     KIO::Slave *createSlave(const QString &protocol, KIO::SimpleJob *job, const KUrl \
&url);  bool removeSlave (KIO::Slave *slave);
     QList<KIO::Slave *> allSlaves() const;
+    void updateSlaveConfigFor(const QString&);
     ConnectedSlaveQueue m_connectedSlaveQueue;
 
 private slots:


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic