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

List:       kde-commits
Subject:    branches/KDE/3.5/kdelibs/kio
From:       Luboš Luňák <l.lunak () kde ! org>
Date:       2006-12-18 14:32:01
Message-ID: 1166452321.482144.12188.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 614636 by lunakl:

Include also the application's user timestamp in KIO job information.
Helps with focus when clicking an URL in KMail that pops up
the authentication dialog.



 M  +26 -1     kio/job.cpp  
 M  +12 -0     kio/jobclasses.h  
 M  +7 -5      kio/slavebase.cpp  
 M  +16 -0     kpasswdserver/kpasswdserver.cpp  
 M  +3 -0      kpasswdserver/kpasswdserver.h  


--- branches/KDE/3.5/kdelibs/kio/kio/job.cpp #614635:614636
@@ -73,6 +73,9 @@
 #ifdef Q_OS_UNIX
 #include <utime.h>
 #endif
+#if defined Q_WS_X11
+#include <netwm.h>
+#endif
 
 using namespace KIO;
 template class QPtrList<KIO::Job>;
@@ -87,7 +90,7 @@
 public:
     JobPrivate() : m_autoErrorHandling( false ), m_autoWarningHandling( true ),
                    m_interactive( true ), m_parentJob( 0L ), m_extraFlags(0),
-                   m_processedSize(0)
+                   m_processedSize(0), m_userTimestamp(0)
                    {}
 
     bool m_autoErrorHandling;
@@ -99,6 +102,7 @@
     Job* m_parentJob;
     int m_extraFlags;
     KIO::filesize_t m_processedSize;
+    unsigned long m_userTimestamp;
 };
 
 Job::Job(bool showProgressInfo) : QObject(0, "job"), m_error(0), m_percent(0)
@@ -127,6 +131,8 @@
     // Don't exit while this job is running
     if (kapp)
         kapp->ref();
+    if (kapp)
+        updateUserTimestamp( kapp->userTimestamp());
 }
 
 Job::~Job()
@@ -171,6 +177,7 @@
        job->mergeMetaData(m_outgoingMetaData);
 
     job->setWindow( m_window );
+    job->updateUserTimestamp( d->m_userTimestamp );
 }
 
 void Job::removeSubjob( Job *job )
@@ -352,6 +359,19 @@
   return m_window;
 }
 
+void Job::updateUserTimestamp( unsigned long time )
+{
+#if defined Q_WS_X11
+  if( d->m_userTimestamp == 0 || NET::timestampCompare( time, d->m_userTimestamp ) > \
0 ) +      d->m_userTimestamp = time;
+#endif
+}
+
+unsigned long Job::userTimestamp() const
+{
+    return d->m_userTimestamp;
+}
+
 void Job::setParentJob(Job* job)
 {
   Q_ASSERT(d->m_parentJob == 0L);
@@ -512,6 +532,11 @@
        QString id;
        addMetaData("window-id", id.setNum((ulong)m_window->winId()));
     }
+    if (userTimestamp())
+    {
+       QString id;
+       addMetaData("user-timestamp", id.setNum(userTimestamp()));
+    }
 
     QString sslSession = KSSLCSessionCache::getSessionForURL(m_url);
     if ( !sslSession.isNull() )
--- branches/KDE/3.5/kdelibs/kio/kio/jobclasses.h #614635:614636
@@ -227,6 +227,13 @@
 	 * @see setWindow()
          */
         QWidget *window() const;
+        
+        /**
+         * Updates the last user action timestamp to the given time.
+         * See KApplication::updateUserTimestamp() .
+         * @since 3.5.6
+         */
+        void updateUserTimestamp( unsigned long time );
 
         /**
          * Set the parent Job.
@@ -482,6 +489,11 @@
 
         /**
          * @internal
+         */
+        unsigned long userTimestamp() const;
+
+        /**
+         * @internal
          * Some extra storage space for jobs that don't have their own
          * private d pointer.
          */
--- branches/KDE/3.5/kdelibs/kio/kio/slavebase.cpp #614635:614636
@@ -824,6 +824,7 @@
     AuthInfo authResult;
     long windowId = metaData("window-id").toLong();
     long progressId = metaData("progress-id").toLong();
+    unsigned long userTimestamp = metaData("user-timestamp").toULong();
 
     kdDebug(7019) << "SlaveBase::openPassDlg window-id=" << windowId << " \
progress-id=" << progressId << endl;  
@@ -836,11 +837,11 @@
     QDataStream stream(params, IO_WriteOnly);
 
     if (metaData("no-auth-prompt").lower() == "true")
-       stream << info << QString("<NoAuthPrompt>") << windowId << s_seqNr;
+       stream << info << QString("<NoAuthPrompt>") << windowId << s_seqNr << \
userTimestamp;  else
-       stream << info << errorMsg << windowId << s_seqNr;
+       stream << info << errorMsg << windowId << s_seqNr << userTimestamp;
 
-    bool callOK = d->dcopClient->call( "kded", "kpasswdserver", \
"queryAuthInfo(KIO::AuthInfo, QString, long int, long int)", +    bool callOK = \
d->dcopClient->call( "kded", "kpasswdserver", "queryAuthInfo(KIO::AuthInfo, QString, \
long int, long int, unsigned long int)",  params, replyType, reply );
 
     if (progressId)
@@ -1170,15 +1171,16 @@
     QByteArray reply;
     AuthInfo authResult;
     long windowId = metaData("window-id").toLong();
+    unsigned long userTimestamp = metaData("user-timestamp").toULong();
 
     kdDebug(7019) << "SlaveBase::checkCachedAuthInfo window = " << windowId << " url \
= " << info.url.url() << endl;  
     (void) dcopClient(); // Make sure to have a dcop client.
 
     QDataStream stream(params, IO_WriteOnly);
-    stream << info << windowId;
+    stream << info << windowId << userTimestamp;
 
-    if ( !d->dcopClient->call( "kded", "kpasswdserver", \
"checkAuthInfo(KIO::AuthInfo, long int)", +    if ( !d->dcopClient->call( "kded", \
"kpasswdserver", "checkAuthInfo(KIO::AuthInfo, long int, unsigned long int)",  \
params, replyType, reply ) )  {
        kdWarning(7019) << "Can't communicate with kded_kpasswdserver!" << endl;
--- branches/KDE/3.5/kdelibs/kio/kpasswdserver/kpasswdserver.cpp #614635:614636
@@ -178,8 +178,16 @@
 KIO::AuthInfo
 KPasswdServer::checkAuthInfo(KIO::AuthInfo info, long windowId)
 {
+    return checkAuthInfo(info, windowId, 0);
+}
+
+KIO::AuthInfo
+KPasswdServer::checkAuthInfo(KIO::AuthInfo info, long windowId, unsigned long \
usertime) +{
     kdDebug(130) << "KPasswdServer::checkAuthInfo: User= " << info.username
               << ", WindowId = " << windowId << endl;
+    if( usertime != 0 )
+        kapp->updateUserTimestamp( usertime );
 
     QString key = createCacheKey(info);
 
@@ -237,10 +245,18 @@
 KIO::AuthInfo
 KPasswdServer::queryAuthInfo(KIO::AuthInfo info, QString errorMsg, long windowId, \
long seqNr)  {
+    return queryAuthInfo(info, errorMsg, windowId, seqNr, 0 );
+}
+
+KIO::AuthInfo
+KPasswdServer::queryAuthInfo(KIO::AuthInfo info, QString errorMsg, long windowId, \
long seqNr, unsigned long usertime) +{
     kdDebug(130) << "KPasswdServer::queryAuthInfo: User= " << info.username
               << ", Message= " << info.prompt << ", WindowId = " << windowId << \
                endl;
     if ( !info.password.isEmpty() ) // should we really allow the caller to pre-fill \
the password?  kdDebug(130) <<  "password was set by caller" << endl;
+    if( usertime != 0 )
+        kapp->updateUserTimestamp( usertime );
 
     QString key = createCacheKey(info);
     Request *request = new Request;
--- branches/KDE/3.5/kdelibs/kio/kpasswdserver/kpasswdserver.h #614635:614636
@@ -45,7 +45,10 @@
   ~KPasswdServer();
 
 k_dcop:
+  // KDE4 merge
+  KIO::AuthInfo checkAuthInfo(KIO::AuthInfo, long, unsigned long);
   KIO::AuthInfo checkAuthInfo(KIO::AuthInfo, long);
+  KIO::AuthInfo queryAuthInfo(KIO::AuthInfo, QString, long, long, unsigned long);
   KIO::AuthInfo queryAuthInfo(KIO::AuthInfo, QString, long, long);
   void addAuthInfo(KIO::AuthInfo, long);
 


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

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