All pastes #1430050 Raw Edit

Untitled

public text v1 · immutable
#1430050 ·published 2009-05-21 16:43 UTC
rendered paste body
Index: imapresource.cpp
===================================================================
--- imapresource.cpp	(revision 970318)
+++ imapresource.cpp	(working copy)
@@ -30,6 +30,7 @@
 #include <QtCore/QDebug>
 #include <QtDBus/QDBusConnection>
 #include <QtNetwork/QSslSocket>
+#include <QTimer>
 
 #include <kdebug.h>
 #include <klocale.h>
@@ -107,6 +108,9 @@
   new SettingsAdaptor( Settings::self() );
   QDBusConnection::sessionBus().registerObject( QLatin1String( "/Settings" ),
                                                 Settings::self(), QDBusConnection::ExportAdaptors );
+  //wait 30 secs until timeout
+  mTimer.setInterval( 30000 );
+  connect( &mTimer, SIGNAL(timeout()), SLOT(connectionTimeout()) );
 
   startConnect();
 }
@@ -290,8 +294,14 @@
   connect( loginJob, SIGNAL( result(KJob*) ),
            this, SLOT( onLoginDone(KJob*) ) );
   loginJob->start();
+  mTimer.start();
 }
 
+void ImapResource::connectionTimeout()
+{
+  qDebug()<<"timeout";
+}
+
 void ImapResource::itemAdded( const Item &item, const Collection &collection )
 {
   const QString mailBox = mailBoxForRemoteId( collection.remoteId() );
@@ -672,6 +682,8 @@
     capJob->start();
     return;
   }
+  
+  mTimer.stop();
 
   // the credentials where not ok....
   int i = KMessageBox::questionYesNoCancelWId( winIdForDialogs(),
@@ -1024,5 +1036,3 @@
 AKONADI_RESOURCE_MAIN( ImapResource )
 
 #include "imapresource.moc"
-
-
Index: imapresource.h
===================================================================
--- imapresource.h	(revision 970318)
+++ imapresource.h	(working copy)
@@ -28,6 +28,7 @@
 #include <akonadi/resourcebase.h>
 #include <boost/shared_ptr.hpp>
 #include <QtCore/QStringList>
+#include <QtCore/QTimer>
 
 #include <kimap/fetchjob.h>
 #include <kimap/listjob.h>
@@ -87,6 +88,7 @@
   void onDeleteMailBoxDone( KJob *job );
   void onAppendMessageDone( KJob *job );
   void onStoreFlagsDone( KJob *job );
+  void connectionTimeout();
 
 private:
   QString rootRemoteId() const;
@@ -104,6 +106,7 @@
   QStringList m_capabilities;
   QString m_server;
   QString m_userName;
+  QTimer mTimer;
 };
 
 #endif