summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kmail/kmkernel.cpp44
-rw-r--r--kmail/kmkernel.h6
2 files changed, 50 insertions, 0 deletions
diff --git a/kmail/kmkernel.cpp b/kmail/kmkernel.cpp
index df0ab2d5b..162e179ba 100644
--- a/kmail/kmkernel.cpp
+++ b/kmail/kmkernel.cpp
@@ -169,6 +169,18 @@ KMKernel::KMKernel (TQObject *parent, const char *name) :
connectDCOPSignal( 0, 0, "kmailSelectFolder(TQString)",
"selectFolder(TQString)", false );
+
+ mNetworkManager = TDEGlobal::networkManager();
+ if (mNetworkManager) {
+ connect( mNetworkManager, TQT_SIGNAL( networkDeviceStateChanged( TDENetworkConnectionStatus::TDENetworkConnectionStatus, TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString ) ),
+ this, TQT_SLOT( slotNetworkStateChanged( TDENetworkConnectionStatus::TDENetworkConnectionStatus newState, TDENetworkConnectionStatus::TDENetworkConnectionStatus previousState, TQString hwAddress ) ) );
+ if (networkStateConnected()) {
+ resumeNetworkJobs();
+ }
+ else {
+ stopNetworkJobs();
+ }
+ }
}
KMKernel::~KMKernel ()
@@ -2456,6 +2468,38 @@ int KMKernel::timeOfLastMessageCountChange() const
return mTimeOfLastMessageCountChange;
}
+bool KMKernel::networkStateConnected()
+{
+ if (mNetworkManager) {
+ TDENetworkGlobalManagerFlags::TDENetworkGlobalManagerFlags networkStatus = mNetworkManager->backendStatus();
+ if ((networkStatus & TDENetworkGlobalManagerFlags::Connected)
+ || (networkStatus & TDENetworkGlobalManagerFlags::BackendUnavailable)
+ || (networkStatus == TDENetworkGlobalManagerFlags::Unknown)
+ ){
+ // Connected or no backend available
+ return true;
+ }
+ else {
+ // Not connected
+ return false;
+ }
+ }
+ else {
+ // Assume connected
+ return true;
+ }
+}
+
+void KMKernel::slotNetworkStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString)
+{
+ if (networkStateConnected()) {
+ resumeNetworkJobs();
+ }
+ else {
+ stopNetworkJobs();
+ }
+}
+
Wallet *KMKernel::wallet() {
static bool walletOpenFailed = false;
if ( mWallet && mWallet->isOpen() )
diff --git a/kmail/kmkernel.h b/kmail/kmkernel.h
index 993c8a0e9..0dc46441e 100644
--- a/kmail/kmkernel.h
+++ b/kmail/kmkernel.h
@@ -14,6 +14,8 @@
#include <tdeimproxy.h>
#include <tdepimmacros.h>
+#include <tdenetworkconnections.h>
+
#include "kmailIface.h"
#include "kmmsgbase.h"
#include "globalsettings.h"
@@ -434,6 +436,7 @@ public slots:
protected slots:
void slotDataReq(TDEIO::Job*,TQByteArray&);
void slotResult(TDEIO::Job*);
+ void slotNetworkStateChanged(TDENetworkConnectionStatus::TDENetworkConnectionStatus, TDENetworkConnectionStatus::TDENetworkConnectionStatus, TQString);
signals:
void configChanged();
@@ -443,6 +446,7 @@ signals:
private:
void openReader( bool onlyCheck );
KMMsgStatus strToStatus(const TQString &flags);
+ bool networkStateConnected();
KMFolder *currentFolder();
KMFolder *the_inboxFolder;
@@ -522,6 +526,8 @@ private:
TQStringList mAddMessageMsgIds;
TQString mAddMessageLastFolder;
KMFolder *mAddMsgCurrentFolder;
+
+ TDEGlobalNetworkManager *mNetworkManager;
};
#endif