Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.2:PowerPC
kdepim3
kdepim_networkstatus_branch.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File kdepim_networkstatus_branch.diff of Package kdepim3
Index: kmail/kmmainwin.cpp ================================================================================ --- kmail/Makefile.am +++ kmail/Makefile.am @@ -32,6 +32,7 @@ ../libksieve/libksieve.la ../libemailfunctions/libemailfunctions.la \ ../certmanager/lib/libkleopatra.la $(INDEXLIB) \ ../libkcal/libkcal.la \ + -lconnectionmanager \ $(LIB_KHTML) $(LIB_KSPELL) $(LIB_KABC) kde_module_LTLIBRARIES = kcm_kmail.la libkmailpart.la libkmail_bodypartformatter_application_octetstream.la --- kmail/accountmanager.cpp +++ kmail/accountmanager.cpp @@ -22,6 +22,7 @@ #include <kdebug.h> #include <kconfig.h> #include <kapplication.h> +#include <connectionmanager.h> #include <qregexp.h> #include <qvaluelist.h> @@ -183,6 +184,15 @@ return; } + if ( curAccount->type() == "imap" || curAccount->type() == "cachedimap" || curAccount->type() == "pop" ) + { + // Check with the network status daemon whether the network is available + if ( !( ConnectionManager::self()->status() == NetworkStatus::Online || ConnectionManager::self()->status() == NetworkStatus::NoNetworks ) ) { + emit checkedMail( false, mInteractive, mTotalNewInFolder ); + return; + } + + } connect( curAccount, SIGNAL( finishedCheck( bool, CheckStatus ) ), this, SLOT( processNextCheck( bool ) ) ); --- kmail/imapaccountbase.cpp +++ kmail/imapaccountbase.cpp @@ -947,7 +947,10 @@ QString caption = i18n("Error"); if ( jobsKilled || errorCode == KIO::ERR_COULD_NOT_LOGIN ) { - if ( errorCode == KIO::ERR_SERVER_TIMEOUT || errorCode == KIO::ERR_CONNECTION_BROKEN ) { + if ( ( errorCode == KIO::ERR_SERVER_TIMEOUT || errorCode == KIO::ERR_CONNECTION_BROKEN ) && + /* suppress error messages about loss of connectivity whilst in offline mode */ + GlobalSettings::self()->networkState() != GlobalSettings::EnumNetworkState::Offline ) + { msg = i18n("The connection to the server %1 was unexpectedly closed or timed out. It will be re-established automatically if possible."). arg( name() ); KMessageBox::information( kapp->activeWindow(), msg, caption, "kmailConnectionBrokenErrorDialog" ); @@ -959,11 +962,13 @@ KPIM::BroadcastStatus::instance()->setStatusMsg( i18n( "The connection to account %1 timed out." ).arg( name() ) ); } else { - if ( !errors.isEmpty() ) + if ( !( errorCode == KIO::ERR_UNKNOWN_HOST && GlobalSettings::self()->networkState() == GlobalSettings::EnumNetworkState::Offline ) ) { + if ( !errors.isEmpty() ) KMessageBox::detailedError( kapp->activeWindow(), msg, errors.join("\n").prepend("<qt>"), caption ); - else + else KMessageBox::error( kapp->activeWindow(), msg, caption ); } + } } else { // i.e. we have a chance to continue, ask the user about it if ( errors.count() >= 3 ) { // there is no detailedWarningContinueCancel... (#86517) QString error = prettifyQuotaError( errors[1], job ); --- kmail/kmkernel.cpp +++ kmail/kmkernel.cpp @@ -28,6 +28,7 @@ #undef REALLY_WANT_KMSENDER #include "undostack.h" #include "accountmanager.h" +#include "networkaccount.h" using KMail::AccountManager; #include <libkdepim/kfileio.h> #include "kmversion.h" @@ -89,6 +90,7 @@ #include <fixx11h.h> #include <kcmdlineargs.h> #include <kstartupinfo.h> +#include <connectionmanager.h> KMKernel *KMKernel::mySelf = 0; @@ -1205,7 +1207,13 @@ return; GlobalSettings::setNetworkState( GlobalSettings::EnumNetworkState::Offline ); - BroadcastStatus::instance()->setStatusMsg( i18n("KMail is set to be offline; all network jobs are suspended")); + for ( KMAccount * cur = the_acctMgr->first(); cur; cur = the_acctMgr->next() ) { + KMail::NetworkAccount * netAccount = dynamic_cast<KMail::NetworkAccount *>( cur ); + if ( netAccount ) { + netAccount->killAllJobs( true ); + } + } + BroadcastStatus::instance()->setStatusMsg( i18n("KMail is now offline; all network operations cancelled")); emit onlineStatusChanged( (GlobalSettings::EnumNetworkState::type)GlobalSettings::networkState() ); } @@ -1215,7 +1223,7 @@ return; GlobalSettings::setNetworkState( GlobalSettings::EnumNetworkState::Online ); - BroadcastStatus::instance()->setStatusMsg( i18n("KMail is set to be online; all network jobs resumed")); + BroadcastStatus::instance()->setStatusMsg( i18n("KMail is now online; network operations resumed")); emit onlineStatusChanged( (GlobalSettings::EnumNetworkState::type)GlobalSettings::networkState() ); if ( kmkernel->msgSender()->sendImmediate() ) { @@ -1225,10 +1233,7 @@ bool KMKernel::isOffline() { - if ( GlobalSettings::self()->networkState() == GlobalSettings::EnumNetworkState::Offline ) - return true; - else - return false; + return ( GlobalSettings::self()->networkState() == GlobalSettings::EnumNetworkState::Offline ); } bool KMKernel::askToGoOnline() @@ -1479,6 +1484,8 @@ if (lsf) the_searchFolderMgr->remove( lsf ); + ConnectionManager::self()->registerConnectSlot( this, SLOT( resumeNetworkJobs() ) ); + ConnectionManager::self()->registerDisconnectSlot( this, SLOT( stopNetworkJobs() ) ); the_acctMgr = new AccountManager(); the_filterMgr = new KMFilterMgr(); the_popFilterMgr = new KMFilterMgr(true); @@ -1531,6 +1538,12 @@ #else mBackgroundTasksTimer->start( 5 * 60000, true ); // 5 minutes, singleshot #endif + + if ( ( ConnectionManager::self()->status() == NetworkStatus::Online || ConnectionManager::self()->status() == NetworkStatus::NoNetworks ) ) { + resumeNetworkJobs(); + } else { + stopNetworkJobs(); + } } void KMKernel::readConfig() --- kmail/kmkernel.h +++ kmail/kmkernel.h @@ -202,18 +202,6 @@ */ virtual void resumeBackgroundJobs(); - /** - * Stops all network related jobs and enter offline mode - * New network jobs cannot be started. - */ - void stopNetworkJobs(); - - /** - * Resumes all network related jobs and enter online mode - * New network jobs can be started. - */ - void resumeNetworkJobs(); - /** A static helper function that asks the user * if they want to go online. * @return true if the user wants to go online @@ -409,6 +397,18 @@ void slotConfigChanged(); + /** + * Stops all network related jobs and enter offline mode + * New network jobs cannot be started. + */ + void stopNetworkJobs(); + + /** + * Resumes all network related jobs and enter online mode + * New network jobs can be started. + */ + void resumeNetworkJobs(); + protected slots: void slotDataReq(KIO::Job*,QByteArray&); void slotResult(KIO::Job*); --- kmail/kmmainwin.cpp +++ kmail/kmmainwin.cpp @@ -1,4 +1,5 @@ + #ifdef HAVE_CONFIG_H #include <config.h> #endif @@ -22,7 +23,7 @@ #include <kstringhandler.h> #include <kdebug.h> #include <ktip.h> - +#include <networkstatusindicator.h> #include "kmmainwin.moc" KMMainWin::KMMainWin(QWidget *) @@ -73,7 +74,7 @@ this, SLOT(slotConfigChanged())); connect(mKMMainWidget, SIGNAL(captionChangeRequest(const QString&)), - SLOT(setCaption(const QString&)) ); + SLOT(setCaption(const QString&)) ); // Enable mail checks again (see destructor) kmkernel->enableMailCheck(); @@ -179,6 +180,11 @@ statusBar()->setItemAlignment( 1, AlignLeft | AlignVCenter ); statusBar()->addWidget( mKMMainWidget->vacationScriptIndicator(), 1 ); mLittleProgress->show(); + + /* Indicator for desktop offline mode */ + StatusBarNetworkStatusIndicator * indicator = new StatusBarNetworkStatusIndicator( this, "netstatusindicator" ); + statusBar()->addWidget( indicator, 0, false ); + indicator->init(); } /** Read configuration options after widgets are created. */ @@ -219,4 +225,3 @@ KTipDialog::showTip( this ); } - --- kmail/kmmainwin.h +++ kmail/kmmainwin.h @@ -29,6 +29,7 @@ class StatusbarProgressWidget; class ProgressDialog; } + using KPIM::StatusbarProgressWidget; using KPIM::ProgressDialog; --- kmail/popaccount.cpp +++ kmail/popaccount.cpp @@ -1016,7 +1016,9 @@ } if (interactive && kmkernel) { - KMessageBox::error(kmkernel->mainWin(), KIO::buildErrorString(error, errorMsg)); + if ( ! ( ( error == KIO::ERR_CONNECTION_BROKEN || error == KIO::ERR_SERVER_TIMEOUT ) && + GlobalSettings::self()->networkState() != GlobalSettings::EnumNetworkState::Offline ) ) + KMessageBox::error(kmkernel->mainWin(), KIO::buildErrorString(error, errorMsg)); }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor