[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdenetwork/kopete/libkopete
From: Lamarque Souza <lamarque () kde ! org>
Date: 2012-03-04 4:41:41
Message-ID: 20120304044141.E16ADAC896 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1283434 by lvsouza:
React on networking status changes. If networking is offline
Kopete will stop trying to connect until networking is online.
M +33 -0 kopeteaccount.cpp
M +8 -0 kopeteaccount.h
--- trunk/KDE/kdenetwork/kopete/libkopete/kopeteaccount.cpp #1283433:1283434
@@ -85,6 +85,7 @@
Contact *myself;
QTimer suppressStatusTimer;
QTimer reconnectTimer;
+ bool reconnectOnNetworkIsOnline;
bool suppressStatusNotification;
Kopete::BlackLister *blackList;
KConfigGroup *configGroup;
@@ -106,11 +107,14 @@
d->restoreStatus = Kopete::OnlineStatus::Online;
d->restoreMessage = Kopete::StatusMessage();
+ d->reconnectOnNetworkIsOnline = false;
d->reconnectTimer.setSingleShot( true );
QObject::connect( &d->reconnectTimer, SIGNAL(timeout()),
this, SLOT(reconnect()) );
+ QObject::connect(Solid::Networking::notifier(), \
SIGNAL(statusChanged(Solid::Networking::Status)), this, \
SLOT(networkingStatusChanged(Solid::Networking::Status))); +
QObject::connect( &d->suppressStatusTimer, SIGNAL(timeout()),
this, SLOT(slotStopSuppression()) );
}
@@ -141,6 +145,29 @@
setOnlineStatus( d->restoreStatus, d->restoreMessage );
}
+void Account::networkingStatusChanged( const Solid::Networking::Status status )
+{
+ switch(status) {
+ case Solid::Networking::Connected:
+ if (d->reconnectOnNetworkIsOnline) {
+ reconnect();
+ }
+ break;
+
+ case Solid::Networking::Unconnected:
+ case Solid::Networking::Disconnecting:
+ setOnlineStatus( OnlineStatus::Offline );
+ if (Kopete::BehaviorSettings::self()->reconnectOnDisconnect()) {
+ d->reconnectOnNetworkIsOnline = true;
+ }
+ break;
+
+ case Solid::Networking::Unknown:
+ case Solid::Networking::Connecting:
+ break;
+ }
+}
+
void Account::disconnected( DisconnectReason reason )
{
kDebug( 14010 ) << reason;
@@ -151,6 +178,10 @@
}
else if ( Kopete::BehaviorSettings::self()->reconnectOnDisconnect() == true && \
reason > Manual ) {
+ if (reason == ConnectionReset) {
+ d->reconnectOnNetworkIsOnline = true;
+ d->reconnectTimer.stop();
+ } else {
if ( d->reconnectTimer.isActive() )
return; // In case protocol calls disconnected more than one time on disconnect.
@@ -161,8 +192,10 @@
else if ( d->connectionTry <= 10 )
d->reconnectTimer.start( ((2 * (d->connectionTry - 2)) - 1) * 60000 ); // wait \
1,3,5...15 minutes => stops after 64 min }
+ }
else
{
+ d->reconnectOnNetworkIsOnline = false;
d->reconnectTimer.stop();
}
--- trunk/KDE/kdenetwork/kopete/libkopete/kopeteaccount.h #1283433:1283434
@@ -31,6 +31,7 @@
#include <kconfiggroup.h>
#include <kiconloader.h>
+#include <solid/networking.h>
class KActionMenu;
class KConfigGroup;
@@ -474,6 +475,13 @@
*/
void setAllContactsStatus( const Kopete::OnlineStatus &status );
+ /**
+ * @brief React to network status changes
+ *
+ * @param status the new network status.
+ */
+ void networkingStatusChanged( const Solid::Networking::Status status );
+
signals:
/**
* The color of the account has been changed
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic