From kopete-devel Sat Aug 23 16:35:50 2008 From: =?utf-8?q?Dennis=20Nienh=C3=BCser?= Date: Sat, 23 Aug 2008 16:35:50 +0000 To: kopete-devel Subject: [kopete-devel] KDE/kdenetwork/kopete Message-Id: <1219509350.283306.16080.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kopete-devel&m=121950936425255 SVN commit 851433 by nienhueser: Extend the auto connect at startup option to a global initial account status setting. Patch by Cyrill Helg, thanks! CCMAIL: kopete-devel@kde.org M +51 -26 kopete/config/behavior/behaviorconfig_general.ui M +15 -3 kopete/kopeteapplication.cpp M +9 -2 libkopete/kopeteaccountmanager.cpp M +10 -3 libkopete/kopetebehaviorsettings.kcfg M +26 -0 libkopete/kopeteonlinestatusmanager.cpp M +7 -0 libkopete/kopeteonlinestatusmanager.h --- trunk/KDE/kdenetwork/kopete/kopete/config/behavior/behaviorconfig_general.ui #851432:851433 @@ -134,33 +134,57 @@ - - - Miscellaneous - - - - 6 - - - 9 - - - - - Connect on startup and when a network is available - - - When starting Kopete, and whenever your computer is online, all your accounts will be connected automatically. You can exclude accounts individually in their properties. - - - Connect automatically - - - - - + + + Initial status + + + + 6 + + + 9 + + + + + Set the initial status + + + When starting Kopete, and whenever your computer is online, all your accounts will go into the status selected here. You can exclude accounts individually in their properties. + + + + Offline + + + + + Online + + + + + Away + + + + + Busy + + + + + Invisible + + + + + + + + @@ -186,6 +210,7 @@ kcfg_startDocked kcfg_useMessageQueue kcfg_autoConnect + kcfg_initialStatus --- trunk/KDE/kdenetwork/kopete/kopete/kopeteapplication.cpp #851432:851433 @@ -210,17 +210,26 @@ } } + void KopeteApplication::slotAllPluginsLoaded() { KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); //FIXME: this should probably ask for the identities to connect instead of all accounts // --noconnect not specified? - if ( args->isSet( "connect" ) && Kopete::BehaviorSettings::self()->autoConnect() && + + Kopete::OnlineStatusManager::Category initStatus = Kopete::OnlineStatusManager::self()->initialStatus(); + + if ( args->isSet( "connect" ) && initStatus != Kopete::OnlineStatusManager::Offline && ( Solid::Networking::status() == Solid::Networking::Unknown || - Solid::Networking::status() == Solid::Networking::Connected ) ) - Kopete::AccountManager::self()->setOnlineStatus( Kopete::OnlineStatusManager::Online, QString(), Kopete::AccountManager::ConnectIfOffline ); + Solid::Networking::status() == Solid::Networking::Connected ) ){ + Kopete::AccountManager::self()->setOnlineStatus( initStatus, QString(), Kopete::AccountManager::ConnectIfOffline ); + + } + + kDebug(14000)<< "initial status set in config: " << initStatus; + QStringList connectArgs = args->getOptionList( "autoconnect" ); // toConnect will contain all the protocols to connect to @@ -267,6 +276,8 @@ handleURLArgs(); } + + int KopeteApplication::newInstance() { // kDebug(14000) ; @@ -293,6 +304,7 @@ } // END args->count() > 0 } + void KopeteApplication::quitKopete() { kDebug( 14000 ) ; --- trunk/KDE/kdenetwork/kopete/libkopete/kopeteaccountmanager.cpp #851432:851433 @@ -43,6 +43,7 @@ #include "kopetegroup.h" #include "kopetestatusmanager.h" + namespace Kopete { static int compareAccountsByPriority( Account *a, Account *b ) @@ -420,10 +421,16 @@ void AccountManager::networkConnected() { - if ( Kopete::BehaviorSettings::self()->autoConnect() ) - setOnlineStatus( Kopete::OnlineStatusManager::Online, QString(), ConnectIfOffline ); + Kopete::OnlineStatusManager::Category initStatus = Kopete::OnlineStatusManager::self()->initialStatus(); + //we check for network availability here too + if ( Solid::Networking::status() == Solid::Networking::Unknown || + Solid::Networking::status() == Solid::Networking::Connected ){ + + Kopete::AccountManager::self()->setOnlineStatus( initStatus, QString(), Kopete::AccountManager::ConnectIfOffline ); + } } + void AccountManager::networkDisconnected() { setOnlineStatus( Kopete::OnlineStatusManager::Offline ); --- trunk/KDE/kdenetwork/kopete/libkopete/kopetebehaviorsettings.kcfg #851432:851433 @@ -36,9 +36,16 @@ true - - - false + + + + + + + + + + Offline --- trunk/KDE/kdenetwork/kopete/libkopete/kopeteonlinestatusmanager.cpp #851432:851433 @@ -19,6 +19,7 @@ #include "kopeteonlinestatusmanager.h" #include "kopeteprotocol.h" +#include "kopetebehaviorsettings.h" #include #include @@ -126,6 +127,31 @@ return OnlineStatus(); } +OnlineStatusManager::Category OnlineStatusManager::initialStatus() const +{ + Kopete::OnlineStatusManager::Category statusValue; + switch( Kopete::BehaviorSettings::self()->initialStatus() ) + { + case Kopete::BehaviorSettings::EnumInitialStatus::Offline: + statusValue = Kopete::OnlineStatusManager::Offline; + break; + case Kopete::BehaviorSettings::EnumInitialStatus::Online: + statusValue = Kopete::OnlineStatusManager::Online; + break; + case Kopete::BehaviorSettings::EnumInitialStatus::Away: + statusValue = Kopete::OnlineStatusManager::Away; + break; + case Kopete::BehaviorSettings::EnumInitialStatus::Busy: + statusValue = Kopete::OnlineStatusManager::Busy; + break; + case Kopete::BehaviorSettings::EnumInitialStatus::Invisible: + statusValue = Kopete::OnlineStatusManager::Invisible; + break; + } + + return statusValue; +} + QString OnlineStatusManager::fingerprint( const OnlineStatus &statusFor, const QString& icon, int size, QColor color, bool idle) { // create a 'fingerprint' to use as a hash key --- trunk/KDE/kdenetwork/kopete/libkopete/kopeteonlinestatusmanager.h #851432:851433 @@ -120,6 +120,13 @@ */ static KIcon pixmapForCategory( Categories category ); + /** + * This returns status from config as Kopete::OnlineStatusManager::Category + * + * @return the desired initial status + */ + Kopete::OnlineStatusManager::Category initialStatus() const; + private: friend class OnlineStatus; friend class OnlineStatusIconEngine; _______________________________________________ kopete-devel mailing list kopete-devel@kde.org https://mail.kde.org/mailman/listinfo/kopete-devel