[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [ktp-kded-module] /: Stop using mission-control for autoconnect
From: Dominik Cermak <d.cermak () arcor ! de>
Date: 2013-03-31 18:02:25
Message-ID: 20130331180225.5E622A604F () git ! kde ! org
[Download RAW message or body]
Git commit 9b8f17433a7b14b256c1eb9272186c0f00ab416f by Dominik Cermak.
Committed on 31/03/2013 at 19:53.
Pushed by cermak into branch 'master'.
Stop using mission-control for autoconnect
Instead use our kded-module.
BUG: 307175
FIXED-IN: 0.7.0
REVIEW: 109807
M +14 -26 autoconnect.cpp
M +6 -4 autoconnect.h
M +3 -14 telepathy-module.cpp
http://commits.kde.org/telepathy-kded-module/9b8f17433a7b14b256c1eb9272186c0f00ab416f
diff --git a/autoconnect.cpp b/autoconnect.cpp
index 526b060..b779426 100644
--- a/autoconnect.cpp
+++ b/autoconnect.cpp
@@ -21,11 +21,14 @@
#include <KConfig>
+#include <KTp/presence.h>
+
AutoConnect::AutoConnect(QObject *parent)
: QObject(parent)
{
KSharedConfigPtr config = \
KSharedConfig::openConfig(QLatin1String("ktelepathyrc")); m_kdedConfig = \
config->group("KDED"); + m_presenceConfig = config->group("LastPresence");
}
AutoConnect::~AutoConnect()
@@ -35,41 +38,26 @@ AutoConnect::~AutoConnect()
void AutoConnect::setAccountManager(const Tp::AccountManagerPtr &accountManager)
{
m_accountManager = accountManager;
- onSettingsChanged();
-}
-void AutoConnect::setAutomaticPresence(const Tp::Presence &presence)
-{
+ uint presenceType = \
m_presenceConfig.readEntry<uint>(QLatin1String("PresenceType"), \
(uint)Tp::ConnectionPresenceTypeOffline); + QString presenceStatus = \
m_presenceConfig.readEntry(QLatin1String("PresenceStatus"), QString()); + QString \
presenceMessage = m_presenceConfig.readEntry(QLatin1String("PresenceMessage"), \
QString()); +
QString autoConnectString = m_kdedConfig.readEntry(QLatin1String("autoConnect"), \
modeToString(AutoConnect::Manual)); Mode autoConnectMode = \
stringToMode(autoConnectString);
- // Don't interfere if the user set it to manual.
- if (autoConnectMode != AutoConnect::Manual) {
+ if (autoConnectMode == AutoConnect::Enabled) {
Q_FOREACH(Tp::AccountPtr account, m_accountManager->allAccounts()) {
- if ((autoConnectMode == AutoConnect::Enabled) && \
(account->automaticPresence() != presence)) {
- account->setAutomaticPresence(presence);
- } else if ((autoConnectMode == AutoConnect::Disabled) && \
(account->automaticPresence() != Tp::Presence::available())) {
- // The user disabled it, so reset the automatic presence to its \
default value (available).
- account->setAutomaticPresence(Tp::Presence::available());
- }
+ account->setRequestedPresence(Tp::Presence((Tp::ConnectionPresenceType)presenceType, \
presenceStatus, presenceMessage)); }
}
}
-void AutoConnect::onSettingsChanged()
+void AutoConnect::savePresence(const KTp::Presence &presence)
{
- if (m_accountManager) {
- QString autoConnect = m_kdedConfig.readEntry(QLatin1String("autoConnect"), \
modeToString(AutoConnect::Manual)); + \
m_presenceConfig.writeEntry(QLatin1String("PresenceType"), (uint)presence.type()); + \
m_presenceConfig.writeEntry(QLatin1String("PresenceStatus"), presence.status()); + \
m_presenceConfig.writeEntry(QLatin1String("PresenceMessage"), \
presence.statusMessage());
- // Don't interfere if the user set it to manual.
- if (autoConnect != modeToString(AutoConnect::Manual)) {
- Q_FOREACH(Tp::AccountPtr account, m_accountManager->allAccounts()) {
- if ((autoConnect == modeToString(AutoConnect::Enabled)) && \
(!account->connectsAutomatically())) {
- account->setConnectsAutomatically(true);
- } else if ((autoConnect == modeToString(AutoConnect::Disabled)) && \
(account->connectsAutomatically())) {
- account->setConnectsAutomatically(false);
- }
- }
- }
- }
+ m_presenceConfig.sync();
}
diff --git a/autoconnect.h b/autoconnect.h
index e296012..aeb4b54 100644
--- a/autoconnect.h
+++ b/autoconnect.h
@@ -25,6 +25,10 @@
#include <KConfigGroup>
#include <KDebug>
+namespace KTp {
+ class Presence;
+}
+
class AutoConnect : public QObject
{
Q_OBJECT
@@ -40,6 +44,7 @@ public:
~AutoConnect();
void setAccountManager(const Tp::AccountManagerPtr &accountManager);
+ void savePresence(const KTp::Presence &presence);
/**
* \brief Returns a string for the given enum value.
@@ -85,14 +90,11 @@ public:
}
};
-public Q_SLOTS:
- void onSettingsChanged();
- void setAutomaticPresence(const Tp::Presence &presence);
-
private:
Tp::AccountManagerPtr m_accountManager;
Tp::Presence m_presence;
KConfigGroup m_kdedConfig;
+ KConfigGroup m_presenceConfig;
};
#endif // AUTOCONNECT_H
diff --git a/telepathy-module.cpp b/telepathy-module.cpp
index a28bca8..c7a01b5 100644
--- a/telepathy-module.cpp
+++ b/telepathy-module.cpp
@@ -115,16 +115,13 @@ void \
TelepathyModule::onAccountManagerReady(Tp::PendingOperation* op) m_autoConnect = new \
AutoConnect(this); m_autoConnect->setAccountManager(m_accountManager);
- connect(this, SIGNAL(settingsChanged()),
- m_autoConnect, SLOT(onSettingsChanged()));
-
//earlier in list = higher priority
m_pluginStack << m_autoAway << m_mpris;
m_errorHandler = new ErrorHandler(m_accountManager, this);
m_contactHandler = new ContactRequestHandler(m_accountManager, this);
m_contactNotify = new ContactNotify(m_accountManager, this);
-
+
m_lastUserPresence = m_globalPresence->requestedPresence();
}
@@ -138,16 +135,8 @@ void TelepathyModule::onRequestedPresenceChanged(const \
KTp::Presence &presence) //user is manually setting the presnece.
m_lastUserPresence = presence;
- KSharedConfigPtr config = \
KSharedConfig::openConfig(QLatin1String("ktelepathyrc"));
- KConfigGroup presenceConfig = config->group("LastPresence");
-
- presenceConfig.writeEntry(QLatin1String("PresenceType"), (uint)presence.type());
- presenceConfig.writeEntry(QLatin1String("PresenceStatus"), presence.status());
- presenceConfig.writeEntry(QLatin1String("PresenceMessage"), \
presence.statusMessage());
-
- presenceConfig.sync();
-
- m_autoConnect->setAutomaticPresence(presence);
+ //save presence (needed for autoconnect)
+ m_autoConnect->savePresence(presence);
}
void TelepathyModule::onPluginActivated(bool active)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic