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

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

SVN commit 614637 by lunakl:

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



 M  +7 -0      kio/job.cpp  
 M  +20 -0     kio/jobuidelegate.cpp  
 M  +11 -0     kio/jobuidelegate.h  
 M  +5 -3      kio/slavebase.cpp  
 M  +6 -2      kpasswdserver/kpasswdserver.cpp  
 M  +2 -2      kpasswdserver/kpasswdserver.h  


--- trunk/KDE/kdelibs/kio/kio/job.cpp #614636:614637
@@ -129,6 +129,7 @@
        job->mergeMetaData(m_outgoingMetaData);
 
     job->ui()->setWindow( ui()->window());
+    job->ui()->updateUserTimestamp( ui()->userTimestamp());
 }
 
 void Job::removeSubjob( KJob *jobBase, bool mergeMetaData )
@@ -419,6 +420,12 @@
        addMetaData("window-id", id.setNum((ulong)ui()->window()->winId()));
     }
 
+    if (ui() && ui()->userTimestamp())
+    {
+       QString id;
+       addMetaData("user-timestamp", id.setNum((ulong)ui()->userTimestamp()));
+    }
+
     QString sslSession = KSSLCSessionCache::getSessionForUrl(m_url);
     if ( !sslSession.isNull() )
     {
--- trunk/KDE/kdelibs/kio/kio/jobuidelegate.cpp #614636:614637
@@ -27,11 +27,17 @@
 #include "kio/observer.h"
 #include "kio/scheduler.h"
 
+#if defined Q_WS_X11
+#include <QX11Info>
+#include <netwm.h>
+#endif
+
 class KIO::JobUiDelegate::Private
 {
 public:
     bool showProgressInfo;
     QPointer<QWidget> errorParentWidget;
+    unsigned long userTimestamp;
 };
 
 KIO::JobUiDelegate::JobUiDelegate( bool showProgressInfo )
@@ -39,6 +45,7 @@
 {
     d->showProgressInfo = showProgressInfo;
     d->errorParentWidget = 0L;
+    d->userTimestamp = QX11Info::appUserTime();
 }
 
 KIO::JobUiDelegate::~JobUiDelegate()
@@ -62,6 +69,19 @@
     return d->errorParentWidget;
 }
 
+void KIO::JobUiDelegate::updateUserTimestamp( unsigned long time )
+{
+#if defined Q_WS_X11
+  if( d->userTimestamp == 0 || NET::timestampCompare( time, d->userTimestamp ) > 0 )
+      d->userTimestamp = time;
+#endif
+}
+
+unsigned long KIO::JobUiDelegate::userTimestamp() const
+{
+    return d->userTimestamp;
+}
+
 void KIO::JobUiDelegate::connectJob( KJob *job )
 {
     // Notify the UI Server and get a progress id
--- trunk/KDE/kdelibs/kio/kio/jobuidelegate.h #614636:614637
@@ -68,6 +68,17 @@
      */
     QWidget *window() const;
 
+    /**
+     * Updates the last user action timestamp to the given time.
+     * See KApplication::updateUserTimestamp() .
+     */
+    void updateUserTimestamp( unsigned long time );
+
+    /**
+     * @internal
+     */
+    unsigned long userTimestamp() const;
+
     virtual void showErrorMessage();
 
 protected:
--- trunk/KDE/kdelibs/kio/kio/slavebase.cpp #614636:614637
@@ -821,6 +821,7 @@
     AuthInfo authResult;
     const long windowId = metaData("window-id").toLong();
     const long progressId = metaData("progress-id").toLong();
+    const unsigned long userTimestamp = metaData("user-timestamp").toULong();
 
     org::kde::KIO::UIServer uiserver("org.kde.kio_uiserver", "/UIServer", \
QDBusConnection::sessionBus());  if (progressId)
@@ -839,9 +840,9 @@
 
     if (metaData("no-auth-prompt").toLower() == "true")
        reply = kps.call("queryAuthInfo", data, \
                QString(QLatin1String("<NoAuthPrompt>")),
-                         qlonglong(windowId), s_seqNr);
+                         qlonglong(windowId), s_seqNr, qlonglong(userTimestamp));
     else
-       reply = kps.call("queryAuthInfo", data, errorMsg, qlonglong(windowId), \
s_seqNr); +       reply = kps.call("queryAuthInfo", data, errorMsg, \
qlonglong(windowId), s_seqNr, qlonglong(userTimestamp));  
     bool callOK = reply.type() == QDBusMessage::ReplyMessage;
     if (progressId)
@@ -1125,6 +1126,7 @@
 {
     AuthInfo authResult;
     long windowId = metaData("window-id").toLong();
+    unsigned long userTimestamp = metaData("user-timestamp").toULong();
 
     kDebug(7019) << "SlaveBase::checkCachedAuthInfo window = " << windowId << " url \
= " << info.url.url() << endl;  
@@ -1135,7 +1137,7 @@
        QDataStream stream(&data, QIODevice::WriteOnly);
        stream << info;
     }
-    QDBusReply<QByteArray> reply = kps.call("checkAuthInfo", data, \
qlonglong(windowId)); +    QDBusReply<QByteArray> reply = kps.call("checkAuthInfo", \
data, qlonglong(windowId), qlonglong(userTimestamp));  
     if ( !reply.isValid() )
     {
--- trunk/KDE/kdelibs/kio/kpasswdserver/kpasswdserver.cpp #614636:614637
@@ -176,7 +176,7 @@
 }
 
 QByteArray
-KPasswdServer::checkAuthInfo(const QByteArray &data, qlonglong windowId, const \
QDBusMessage &msg) +KPasswdServer::checkAuthInfo(const QByteArray &data, qlonglong \
windowId, qlonglong usertime, const QDBusMessage &msg)  {
     KIO::AuthInfo info;
     {
@@ -186,6 +186,8 @@
     }
     kDebug(130) << "KPasswdServer::checkAuthInfo: User= " << info.username
               << ", WindowId = " << windowId << endl;
+    if( usertime != 0 )
+        kapp->updateUserTimestamp( usertime );
 
     QString key = createCacheKey(info);
 
@@ -250,7 +252,7 @@
 
 QByteArray
 KPasswdServer::queryAuthInfo(const QByteArray &data, const QString &errorMsg, \
                qlonglong windowId,
-                             qlonglong seqNr, const QDBusMessage &msg)
+                             qlonglong seqNr, qlonglong usertime, const QDBusMessage \
&msg)  {
     KIO::AuthInfo info;
     {
@@ -262,6 +264,8 @@
               << ", Message= " << info.prompt << ", WindowId = " << windowId << \
                endl;
     if ( !info.password.isEmpty() ) // should we really allow the caller to pre-fill \
the password?  kDebug(130) <<  "password was set by caller" << endl;
+    if( usertime != 0 )
+        kapp->updateUserTimestamp( usertime );
 
     QString key = createCacheKey(info);
     Request *request = new Request;
--- trunk/KDE/kdelibs/kio/kpasswdserver/kpasswdserver.h #614636:614637
@@ -44,8 +44,8 @@
   ~KPasswdServer();
 
 public Q_SLOTS:
-  Q_SCRIPTABLE QByteArray checkAuthInfo(const QByteArray &, qlonglong, const \
                QDBusMessage &);
-  Q_SCRIPTABLE QByteArray queryAuthInfo(const QByteArray &, const QString &, \
qlonglong, qlonglong, const QDBusMessage &); +  Q_SCRIPTABLE QByteArray \
checkAuthInfo(const QByteArray &, qlonglong, qlonglong, const QDBusMessage &); +  \
Q_SCRIPTABLE QByteArray queryAuthInfo(const QByteArray &, const QString &, qlonglong, \
qlonglong, qlonglong, const QDBusMessage &);  Q_SCRIPTABLE void addAuthInfo(const \
QByteArray &, qlonglong);  
   void processRequest();


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

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