[SCM] ktp-kded-integration-module packaging branch, master, updated. debian/15.12.1-2-382-gbd961c2
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:15:41 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-kded-module.git;a=commitdiff;h=b29833c
The following commit has been merged in the master branch:
commit b29833c28dc5a805ca63382d478260660ff46ffd
Author: David Edmundson <davidedmundson at kde.org>
Date: Wed Apr 2 02:06:12 2014 +0200
Split presence handling into a new class
Code is a direct copy/paste from telepathy-module
---
CMakeLists.txt | 1 +
telepathy-module.cpp => status-handler.cpp | 106 ++++++-----------
telepathy-module.h => status-handler.h | 56 ++++-----
telepathy-module.cpp | 183 +----------------------------
telepathy-module.h | 28 +----
5 files changed, 66 insertions(+), 308 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d08606b..b069662 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,7 @@ set (kded_ktp_integration_module_SRCS
telepathy-module.cpp
autoaway.cpp
telepathy-mpris.cpp
+ status-handler.cpp
autoconnect.cpp
error-handler.cpp
contactnotify.cpp
diff --git a/telepathy-module.cpp b/status-handler.cpp
similarity index 69%
copy from telepathy-module.cpp
copy to status-handler.cpp
index 030a0d9..db7f977 100644
--- a/telepathy-module.cpp
+++ b/status-handler.cpp
@@ -1,6 +1,5 @@
/*
- KDE integration module for Telepathy
- Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
+ Copyright (C) 2014 David Edmundson <kde at davidedmundson.co.uk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -17,113 +16,79 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "telepathy-module.h"
+#include "status-handler.h"
-#include "autoaway.h"
#include "autoconnect.h"
-#include "contact-cache.h"
-#include "contact-request-handler.h"
-#include "contactnotify.h"
-#include "error-handler.h"
+#include "autoaway.h"
#include "screensaveraway.h"
-#include "telepathy-kded-module-plugin.h"
#include "telepathy-mpris.h"
-#include <KTp/contact-factory.h>
-#include <KTp/core.h>
#include <KTp/global-presence.h>
-#include <TelepathyQt/AccountFactory>
-#include <TelepathyQt/PendingOperation>
#include <TelepathyQt/PendingReady>
-#include <TelepathyQt/Debug>
-
-#include <KConfigGroup>
-#include <KDebug>
-#include <KPluginFactory>
-
-K_PLUGIN_FACTORY(TelepathyModuleFactory, registerPlugin<TelepathyModule>(); )
-K_EXPORT_PLUGIN(TelepathyModuleFactory("ktp_integration_module", "kded_ktp_integration_module"))
-
-TelepathyModule::TelepathyModule(QObject *parent, const QList<QVariant> &args)
- : KDEDModule(parent)
- , m_autoAway( 0 )
- , m_mpris( 0 )
- , m_autoConnect( 0 )
- , m_errorHandler( 0 )
- , m_globalPresence( 0 )
- , m_contactHandler( 0 )
- , m_contactNotify( 0 )
- , m_screenSaverAway( 0 )
-{
- Q_UNUSED(args)
-
- Tp::registerTypes();
- Tp::enableDebug(false);
- Tp::enableWarnings(false);
+#include <TelepathyQt/AccountManager>
+StatusHandler::StatusHandler(QObject* parent):
+ m_autoConnect(0),
+ m_globalPresence(0)
+{
connect(KTp::accountManager()->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)),
SLOT(onAccountManagerReady(Tp::PendingOperation*)));
QDBusConnection::sessionBus().connect(QString(), QLatin1String("/Telepathy"), QLatin1String("org.kde.Telepathy"),
QLatin1String("settingsChange"), this, SIGNAL(settingsChanged()));
-
}
-TelepathyModule::~TelepathyModule()
+StatusHandler::~StatusHandler()
{
+
}
-void TelepathyModule::onAccountManagerReady(Tp::PendingOperation *op)
+void StatusHandler::onAccountManagerReady(Tp::PendingOperation *op)
{
if (op->isError()) {
return;
}
m_globalPresence = new KTp::GlobalPresence(this);
+ m_autoConnect = new AutoConnect(this);
+
m_globalPresence->setAccountManager(KTp::accountManager());
connect(m_globalPresence, SIGNAL(requestedPresenceChanged(KTp::Presence)),
this, SLOT(onRequestedPresenceChanged(KTp::Presence)));
- m_autoAway = new AutoAway(m_globalPresence, this);
- connect(m_autoAway, SIGNAL(activate(bool)),
+ AutoAway *autoAway = new AutoAway(m_globalPresence, this);
+ connect(autoAway, SIGNAL(activate(bool)),
this, SLOT(onPluginActivated(bool)));
connect(this, SIGNAL(settingsChanged()),
- m_autoAway, SLOT(reloadConfig()));
+ autoAway, SLOT(reloadConfig()));
- m_screenSaverAway = new ScreenSaverAway(m_globalPresence, this);
- connect(m_screenSaverAway, SIGNAL(activate(bool)),
+ ScreenSaverAway *screenSaverAway = new ScreenSaverAway(m_globalPresence, this);
+ connect(screenSaverAway, SIGNAL(activate(bool)),
this, SLOT(onPluginActivated(bool)));
connect(this, SIGNAL(settingsChanged()),
- m_screenSaverAway, SLOT(reloadConfig()));
+ screenSaverAway, SLOT(reloadConfig()));
- m_mpris = new TelepathyMPRIS(m_globalPresence, this);
- connect(m_mpris, SIGNAL(activate(bool)),
+ TelepathyMPRIS *mpris = new TelepathyMPRIS(m_globalPresence, this);
+ connect(mpris, SIGNAL(activate(bool)),
this, SLOT(onPluginActivated(bool)));
connect(this, SIGNAL(settingsChanged()),
- m_mpris, SLOT(reloadConfig()));
-
- m_autoConnect = new AutoConnect(this);
+ mpris, SLOT(reloadConfig()));
//earlier in list = higher priority
- m_pluginStack << m_autoAway << m_screenSaverAway;
+ m_pluginStack << autoAway << screenSaverAway;
//status message plugins are second to user-set status messages and presences
- m_statusMessagePluginStack << m_mpris;
-
- m_errorHandler = new ErrorHandler(this);
- m_contactHandler = new ContactRequestHandler(this);
- m_contactNotify = new ContactNotify(this);
+ m_statusMessagePluginStack << mpris;
- new ContactCache(this);
m_lastUserPresence = m_globalPresence->requestedPresence();
}
-void TelepathyModule::onRequestedPresenceChanged(const KTp::Presence &presence)
+void StatusHandler::onRequestedPresenceChanged(const KTp::Presence &presence)
{
// the difference between user requested offline and network related offline is the connectionStatus is connected or not
// offline caused by network offline shold not be recorded as user requested.
@@ -155,17 +120,17 @@ void TelepathyModule::onRequestedPresenceChanged(const KTp::Presence &presence)
}
}
-void TelepathyModule::onPluginActivated(bool active)
+void StatusHandler::onPluginActivated(bool active)
{
Q_UNUSED(active);
- // cut down on unneccessary status updates by only updating when the current global presence isn't the same as the filtered
+ // cut down on unneccessary status updates by only updating when the current global presence isn't the same as the filtered
// presence. This also helps with misbehaving plugins, in particular the mpris2 plugin ticks and outputs every second.
if (m_globalPresence->currentPresence() != presenceThrottle()) {
setPresence(presenceThrottle());
}
}
-const QString TelepathyModule::statusMessageStack()
+const QString StatusHandler::statusMessageStack()
{
QString expectedStatusMessage = m_lastUserPresence.statusMessage();
if (activeStatusMessagePlugin() && m_lastUserPresence.statusMessage().isEmpty()) {
@@ -177,7 +142,7 @@ const QString TelepathyModule::statusMessageStack()
return expectedStatusMessage;
}
-KTp::Presence TelepathyModule::presenceThrottle()
+KTp::Presence StatusHandler::presenceThrottle()
{
KTp::Presence expectedPresence = m_lastUserPresence;
if (activePlugin()) {
@@ -187,7 +152,7 @@ KTp::Presence TelepathyModule::presenceThrottle()
return expectedPresence;
}
-void TelepathyModule::setPresence(const KTp::Presence &presence)
+void StatusHandler::setPresence(const KTp::Presence &presence)
{
Q_FOREACH(const Tp::AccountPtr &account, KTp::accountManager()->allAccounts()) {
if (account->requestedPresence() != Tp::Presence::offline()) {
@@ -196,7 +161,7 @@ void TelepathyModule::setPresence(const KTp::Presence &presence)
}
}
-KTp::Presence TelepathyModule::currentPluginPresence() const
+KTp::Presence StatusHandler::currentPluginPresence() const
{
KTp::Presence requestedPresence;
//search plugins in priority order. If a plugin is active, return the state it thinks it should be in.
@@ -208,7 +173,7 @@ KTp::Presence TelepathyModule::currentPluginPresence() const
return requestedPresence;
}
-QString TelepathyModule::currentPluginStatusMessage()
+QString StatusHandler::currentPluginStatusMessage()
{
QString requestedStatusMessage;
//search plugins in priority order. If a plugin is active, return the message it thinks it should.
@@ -220,8 +185,8 @@ QString TelepathyModule::currentPluginStatusMessage()
return requestedStatusMessage;
}
-bool TelepathyModule::activePlugin()
-{
+bool StatusHandler::activePlugin()
+{
bool activePlugin = false;
Q_FOREACH(TelepathyKDEDModulePlugin* plugin, m_pluginStack) {
if (plugin->isActive()) {
@@ -231,7 +196,7 @@ bool TelepathyModule::activePlugin()
return activePlugin;
}
-bool TelepathyModule::activeStatusMessagePlugin()
+bool StatusHandler::activeStatusMessagePlugin()
{
bool activeStatusMessagePlugin = false;
Q_FOREACH(TelepathyKDEDModulePlugin* plugin, m_statusMessagePluginStack) {
@@ -241,4 +206,3 @@ bool TelepathyModule::activeStatusMessagePlugin()
}
return activeStatusMessagePlugin;
}
-#include "telepathy-module.moc"
diff --git a/telepathy-module.h b/status-handler.h
similarity index 63%
copy from telepathy-module.h
copy to status-handler.h
index 2213cdf..06240ff 100644
--- a/telepathy-module.h
+++ b/status-handler.h
@@ -1,6 +1,5 @@
/*
- KDE integration module for Telepathy
- Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
+ Copyright (C) 2014 David Edmundson <kde at davidedmundson.co.uk>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -18,38 +17,32 @@
*/
-#ifndef TELEPATHY_MODULE_H
-#define TELEPATHY_MODULE_H
+#include <QObject>
-#include <KDEDModule>
+#include <KTp/types.h>
-#include <TelepathyQt/AccountManager>
-#include <KTp/presence.h>
-
-class ContactRequestHandler;
-namespace Tp {
- class PendingOperation;
-}
+class TelepathyKDEDModulePlugin;
+class AutoConnect;
namespace KTp {
class GlobalPresence;
}
-class TelepathyKDEDModulePlugin;
-class ErrorHandler;
-class TelepathyMPRIS;
-class AutoAway;
-class AutoConnect;
-class ContactNotify;
-class ScreenSaverAway;
+/**
+ * This class keeps track of all status modifying functions, such as now playing and autoaway and
+ * ensures they do not clash.
+ * It consists of a queue of plugins. If any of these plugins are active the presence is set to this
+ * this presence.
+ *
+ * Otherwise we fall back to the last user set presence.
+ */
-class TelepathyModule : public KDEDModule
+class StatusHandler : public QObject
{
Q_OBJECT
-
public:
- TelepathyModule(QObject *parent, const QList<QVariant> &args);
- ~TelepathyModule();
+ StatusHandler(QObject *parent);
+ ~StatusHandler();
Q_SIGNALS:
void settingsChanged();
@@ -60,28 +53,21 @@ private Q_SLOTS:
void onPluginActivated(bool);
private:
+ private:
/** Returns the presence we think we should be in. Either from the highest priority plugin, or if none are active, the last user set.*/
KTp::Presence currentPluginPresence() const;
QString currentPluginStatusMessage();
KTp::Presence presenceThrottle();
const QString statusMessageStack();
- bool activePlugin();
- bool activeStatusMessagePlugin();
+
+ bool activePlugin(); //FIXME should be isActivePlugin
+ bool activeStatusMessagePlugin(); //FIXME should be isActiveStatusMessagePlugin
void setPresence(const KTp::Presence &presence);
-private:
- AutoAway *m_autoAway;
- TelepathyMPRIS *m_mpris;
AutoConnect *m_autoConnect;
- ErrorHandler *m_errorHandler;
- KTp::GlobalPresence *m_globalPresence;
- ContactRequestHandler *m_contactHandler;
- ContactNotify *m_contactNotify;
- ScreenSaverAway *m_screenSaverAway;
QList<TelepathyKDEDModulePlugin*> m_pluginStack;
QList<TelepathyKDEDModulePlugin*> m_statusMessagePluginStack;
KTp::Presence m_lastUserPresence;
+ KTp::GlobalPresence *m_globalPresence;
};
-
-#endif // TELEPATHY_MODULE_H
diff --git a/telepathy-module.cpp b/telepathy-module.cpp
index 030a0d9..90471f9 100644
--- a/telepathy-module.cpp
+++ b/telepathy-module.cpp
@@ -19,22 +19,16 @@
#include "telepathy-module.h"
-#include "autoaway.h"
-#include "autoconnect.h"
#include "contact-cache.h"
#include "contact-request-handler.h"
#include "contactnotify.h"
#include "error-handler.h"
-#include "screensaveraway.h"
-#include "telepathy-kded-module-plugin.h"
-#include "telepathy-mpris.h"
+#include "status-handler.h"
#include <KTp/contact-factory.h>
#include <KTp/core.h>
-#include <KTp/global-presence.h>
#include <TelepathyQt/AccountFactory>
-#include <TelepathyQt/PendingOperation>
#include <TelepathyQt/PendingReady>
#include <TelepathyQt/Debug>
@@ -46,28 +40,17 @@ K_PLUGIN_FACTORY(TelepathyModuleFactory, registerPlugin<TelepathyModule>(); )
K_EXPORT_PLUGIN(TelepathyModuleFactory("ktp_integration_module", "kded_ktp_integration_module"))
TelepathyModule::TelepathyModule(QObject *parent, const QList<QVariant> &args)
- : KDEDModule(parent)
- , m_autoAway( 0 )
- , m_mpris( 0 )
- , m_autoConnect( 0 )
- , m_errorHandler( 0 )
- , m_globalPresence( 0 )
- , m_contactHandler( 0 )
- , m_contactNotify( 0 )
- , m_screenSaverAway( 0 )
+ : KDEDModule(parent),
+ m_statusHandler(new StatusHandler(this)),
+ m_contactHandler( 0 ),
+ m_contactNotify( 0 ),
+ m_errorHandler( 0 )
{
Q_UNUSED(args)
Tp::registerTypes();
Tp::enableDebug(false);
Tp::enableWarnings(false);
-
- connect(KTp::accountManager()->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(onAccountManagerReady(Tp::PendingOperation*)));
-
- QDBusConnection::sessionBus().connect(QString(), QLatin1String("/Telepathy"), QLatin1String("org.kde.Telepathy"),
- QLatin1String("settingsChange"), this, SIGNAL(settingsChanged()));
-
}
TelepathyModule::~TelepathyModule()
@@ -80,165 +63,11 @@ void TelepathyModule::onAccountManagerReady(Tp::PendingOperation *op)
return;
}
- m_globalPresence = new KTp::GlobalPresence(this);
- m_globalPresence->setAccountManager(KTp::accountManager());
- connect(m_globalPresence, SIGNAL(requestedPresenceChanged(KTp::Presence)),
- this, SLOT(onRequestedPresenceChanged(KTp::Presence)));
-
- m_autoAway = new AutoAway(m_globalPresence, this);
- connect(m_autoAway, SIGNAL(activate(bool)),
- this, SLOT(onPluginActivated(bool)));
-
- connect(this, SIGNAL(settingsChanged()),
- m_autoAway, SLOT(reloadConfig()));
-
- m_screenSaverAway = new ScreenSaverAway(m_globalPresence, this);
- connect(m_screenSaverAway, SIGNAL(activate(bool)),
- this, SLOT(onPluginActivated(bool)));
-
- connect(this, SIGNAL(settingsChanged()),
- m_screenSaverAway, SLOT(reloadConfig()));
-
- m_mpris = new TelepathyMPRIS(m_globalPresence, this);
- connect(m_mpris, SIGNAL(activate(bool)),
- this, SLOT(onPluginActivated(bool)));
-
- connect(this, SIGNAL(settingsChanged()),
- m_mpris, SLOT(reloadConfig()));
-
- m_autoConnect = new AutoConnect(this);
-
- //earlier in list = higher priority
- m_pluginStack << m_autoAway << m_screenSaverAway;
-
- //status message plugins are second to user-set status messages and presences
- m_statusMessagePluginStack << m_mpris;
-
m_errorHandler = new ErrorHandler(this);
m_contactHandler = new ContactRequestHandler(this);
m_contactNotify = new ContactNotify(this);
-
new ContactCache(this);
-
- m_lastUserPresence = m_globalPresence->requestedPresence();
-}
-
-void TelepathyModule::onRequestedPresenceChanged(const KTp::Presence &presence)
-{
- // the difference between user requested offline and network related offline is the connectionStatus is connected or not
- // offline caused by network offline shold not be recorded as user requested.
- if (presence.type() == Tp::ConnectionPresenceTypeOffline
- && m_globalPresence->connectionStatus() != Tp::ConnectionStatusConnected) {
- return;
- }
-
- //if it's changed to what we set it to. Ignore it.
- if (presence == presenceThrottle()) {
- return;
- }
-
- //user is manually setting the presence.
- m_lastUserPresence = presence;
-
- //save presence (needed for autoconnect)
- m_autoConnect->savePresence(presence);
-
- // keep status messages current. User-requested status message changes (or plugin-requested status and message) won't return
- // to automatic status message until the next status message plugin signals.
- if (activeStatusMessagePlugin()) {
- if (!presence.statusMessage().isEmpty()) {
- return;
- }
- if (presence != presenceThrottle()) {
- setPresence(presenceThrottle());
- }
- }
}
-void TelepathyModule::onPluginActivated(bool active)
-{
- Q_UNUSED(active);
- // cut down on unneccessary status updates by only updating when the current global presence isn't the same as the filtered
- // presence. This also helps with misbehaving plugins, in particular the mpris2 plugin ticks and outputs every second.
- if (m_globalPresence->currentPresence() != presenceThrottle()) {
- setPresence(presenceThrottle());
- }
-}
-const QString TelepathyModule::statusMessageStack()
-{
- QString expectedStatusMessage = m_lastUserPresence.statusMessage();
- if (activeStatusMessagePlugin() && m_lastUserPresence.statusMessage().isEmpty()) {
- expectedStatusMessage = currentPluginStatusMessage();
- }
- if (activePlugin() && !currentPluginPresence().statusMessage().isEmpty()) {
- expectedStatusMessage = currentPluginPresence().statusMessage();
- }
- return expectedStatusMessage;
-}
-
-KTp::Presence TelepathyModule::presenceThrottle()
-{
- KTp::Presence expectedPresence = m_lastUserPresence;
- if (activePlugin()) {
- expectedPresence = currentPluginPresence();
- }
- expectedPresence.setStatusMessage(statusMessageStack());
- return expectedPresence;
-}
-
-void TelepathyModule::setPresence(const KTp::Presence &presence)
-{
- Q_FOREACH(const Tp::AccountPtr &account, KTp::accountManager()->allAccounts()) {
- if (account->requestedPresence() != Tp::Presence::offline()) {
- account->setRequestedPresence(presence);
- }
- }
-}
-
-KTp::Presence TelepathyModule::currentPluginPresence() const
-{
- KTp::Presence requestedPresence;
- //search plugins in priority order. If a plugin is active, return the state it thinks it should be in.
- Q_FOREACH(TelepathyKDEDModulePlugin* plugin, m_pluginStack) {
- if (plugin->isActive() && plugin->isEnabled()) {
- requestedPresence = plugin->requestedPresence();
- }
- }
- return requestedPresence;
-}
-
-QString TelepathyModule::currentPluginStatusMessage()
-{
- QString requestedStatusMessage;
- //search plugins in priority order. If a plugin is active, return the message it thinks it should.
- Q_FOREACH(TelepathyKDEDModulePlugin* plugin, m_statusMessagePluginStack) {
- if (plugin->isActive() && plugin->isEnabled()) {
- requestedStatusMessage = plugin->requestedStatusMessage();
- }
- }
- return requestedStatusMessage;
-}
-
-bool TelepathyModule::activePlugin()
-{
- bool activePlugin = false;
- Q_FOREACH(TelepathyKDEDModulePlugin* plugin, m_pluginStack) {
- if (plugin->isActive()) {
- activePlugin = true;
- }
- }
- return activePlugin;
-}
-
-bool TelepathyModule::activeStatusMessagePlugin()
-{
- bool activeStatusMessagePlugin = false;
- Q_FOREACH(TelepathyKDEDModulePlugin* plugin, m_statusMessagePluginStack) {
- if (plugin->isActive()) {
- activeStatusMessagePlugin = true;
- }
- }
- return activeStatusMessagePlugin;
-}
#include "telepathy-module.moc"
diff --git a/telepathy-module.h b/telepathy-module.h
index 2213cdf..17ef4ce 100644
--- a/telepathy-module.h
+++ b/telepathy-module.h
@@ -35,13 +35,10 @@ namespace KTp {
class GlobalPresence;
}
-class TelepathyKDEDModulePlugin;
class ErrorHandler;
-class TelepathyMPRIS;
-class AutoAway;
class AutoConnect;
class ContactNotify;
-class ScreenSaverAway;
+class StatusHandler;
class TelepathyModule : public KDEDModule
{
@@ -56,32 +53,13 @@ Q_SIGNALS:
private Q_SLOTS:
void onAccountManagerReady(Tp::PendingOperation *op);
- void onRequestedPresenceChanged(const KTp::Presence &presence);
- void onPluginActivated(bool);
private:
- /** Returns the presence we think we should be in. Either from the highest priority plugin, or if none are active, the last user set.*/
- KTp::Presence currentPluginPresence() const;
- QString currentPluginStatusMessage();
- KTp::Presence presenceThrottle();
- const QString statusMessageStack();
- bool activePlugin();
- bool activeStatusMessagePlugin();
- void setPresence(const KTp::Presence &presence);
-
-private:
- AutoAway *m_autoAway;
- TelepathyMPRIS *m_mpris;
- AutoConnect *m_autoConnect;
- ErrorHandler *m_errorHandler;
- KTp::GlobalPresence *m_globalPresence;
+ StatusHandler *m_statusHandler;
ContactRequestHandler *m_contactHandler;
ContactNotify *m_contactNotify;
- ScreenSaverAway *m_screenSaverAway;
+ ErrorHandler *m_errorHandler;
- QList<TelepathyKDEDModulePlugin*> m_pluginStack;
- QList<TelepathyKDEDModulePlugin*> m_statusMessagePluginStack;
- KTp::Presence m_lastUserPresence;
};
#endif // TELEPATHY_MODULE_H
--
ktp-kded-integration-module packaging
More information about the pkg-kde-commits
mailing list