[SCM] ktp-contact-applet packaging branch, master, updated. debian/15.12.1-1-966-gde83ac5

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:12:06 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-desktop-applets.git;a=commitdiff;h=e3e7dd4

The following commit has been merged in the master branch:
commit e3e7dd444e309e80d051356c978ca43e8c004e32
Author: Francesco Nwokeka <francesco.nwokeka at gmail.com>
Date:   Mon Dec 12 13:17:54 2011 +0100

    Made the plasmoid as simple as can be
    
    eliminated the QML part. The presence plasmoid now shows what it should be showing, that is
    PRESENCE. The plasmoid shows current pressence via an icon. It can sit on the desktop or in the
    systray. Right click shows available functions
---
 presence/CMakeLists.txt          |   4 +-
 presence/src/presence-applet.cpp | 168 ++++++++++++++++++++++++++++-----------
 presence/src/presence-applet.h   |  38 ++++++---
 3 files changed, 146 insertions(+), 64 deletions(-)

diff --git a/presence/CMakeLists.txt b/presence/CMakeLists.txt
index f290a08..e750b74 100644
--- a/presence/CMakeLists.txt
+++ b/presence/CMakeLists.txt
@@ -30,7 +30,6 @@ include_directories(${CMAKE_SOURCE_DIR}
 
 
 set(telepathy-kde-presence-applet_SRCS
-    src/globalpresencewrapper.cpp
     src/presenceapplet.cpp
 )
 #
@@ -45,8 +44,7 @@ target_link_libraries(telepathy-kde-presence-applet
                         ${TELEPATHY_QT4_LIBRARIES}
                         ${KTELEPATHY_LIBRARIES}
                         ${KTELEPATHY_MODELS_LIBRARIES}
-                        ${QT_QTDECLARATIVE_LIBRARY})
+                     )
 
-install(DIRECTORY src/declarative/ DESTINATION ${DATA_INSTALL_DIR}/plasma/plasmoids/org.kde.telepathy-kde-presence-applet)
 install(TARGETS telepathy-kde-presence-applet DESTINATION ${PLUGIN_INSTALL_DIR})
 install(FILES telepathy-kde-presence-applet.desktop DESTINATION ${SERVICES_INSTALL_DIR})
diff --git a/presence/src/presence-applet.cpp b/presence/src/presence-applet.cpp
index 96aef1d..c1e0c13 100644
--- a/presence/src/presence-applet.cpp
+++ b/presence/src/presence-applet.cpp
@@ -17,7 +17,6 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
-#include "globalpresencewrapper.h"
 #include "presenceapplet.h"
 
 #include <KAction>
@@ -28,36 +27,30 @@
 #include <KTelepathy/global-presence.h>
 #include <KTelepathy/presence.h>
 
-#include <QtDeclarative/QDeclarativeEngine>
-#include <QtDeclarative/QDeclarativeContext>
+#include <TelepathyQt4/PendingOperation>
+#include <TelepathyQt4/PendingReady>
+
 
 TelepathyPresenceApplet::TelepathyPresenceApplet(QObject* parent, const QVariantList& args)
-    : Plasma::Applet(parent, args)
-    , m_declarative(new Plasma::DeclarativeWidget(this))
-    , m_qmlObject(0)
-    , m_globalPresenceWrapper(new GlobalPresenceWrapper(this))
-{
-    // setup plasmoid size
-    resize(250, 250);
-    setAspectRatioMode(Plasma::FixedSize);
+    : Plasma::PopupApplet(parent, args)
+    , m_globalPresence(new KTp::GlobalPresence(this))
+{
     setupContextMenuActions();
-}
+    setupAccountManager();
 
-TelepathyPresenceApplet::~TelepathyPresenceApplet()
-{
-    m_declarative->deleteLater();   // do i need to do this?
-    m_contextActions.clear();
-//     m_qmlObject ??
-}
+    resize(128, 128);
+    setAspectRatioMode(Plasma::KeepAspectRatio);
+    setBackgroundHints(NoBackground);
 
-int TelepathyPresenceApplet::appletHeight() const
-{
-    return geometry().height();
+    int iconSize = IconSize(KIconLoader::Small);
+    setMinimumSize(QSize(iconSize, iconSize));
+
+    connect(m_globalPresence, SIGNAL(currentPresenceChanged(Tp::Presence)), this, SLOT(onPresenceChanged(Tp::Presence)));
 }
 
-int TelepathyPresenceApplet::appletWidth() const
+TelepathyPresenceApplet::~TelepathyPresenceApplet()
 {
-    return geometry().width();
+    m_contextActions.clear();
 }
 
 QList< QAction* > TelepathyPresenceApplet::contextualActions()
@@ -68,24 +61,6 @@ QList< QAction* > TelepathyPresenceApplet::contextualActions()
 void TelepathyPresenceApplet::init()
 {
     Plasma::Applet::init();
-
-    if (m_declarative) {
-        /// TODO sort this path out with correct one
-        QString qmlFile = KGlobal::dirs()->findResource("data", "plasma/plasmoids/org.kde.telepathy-kde-presence-applet/contents/ui/main.qml");
-        qDebug() << "LOADING: " << qmlFile;
-        m_declarative->setQmlPath(qmlFile);
-        m_declarative->engine()->rootContext()->setContextProperty("TelepathyPresenceApplet", m_globalPresenceWrapper);
-
-        // setup qml object so that we can talk to the declarative part
-        m_qmlObject = dynamic_cast<QObject*>(m_declarative->rootObject());
-
-        // connect the qml object to recieve signals from the globalpresencewrapper
-//         connect(m_globalPresenceWrapper, SIGNAL(presenceChanged()), m_qmlObject, SLOT(/*updatePresence*/));
-
-        // these two signals are for the plasmoid resize. QML can't determine the Plasma::DeclarativeWidget's boundaries
-        connect(this, SIGNAL(widthChanged()), m_qmlObject, SLOT(onWidthChanged()));
-        connect(this, SIGNAL(heightChanged()), m_qmlObject, SLOT(onHeightChanged()));
-    }
 }
 
 void TelepathyPresenceApplet::paintInterface(QPainter* p, const QStyleOptionGraphicsItem* option, const QRect& contentsRect)
@@ -93,6 +68,42 @@ void TelepathyPresenceApplet::paintInterface(QPainter* p, const QStyleOptionGrap
     Plasma::Applet::paintInterface(p, option, contentsRect);
 }
 
+void TelepathyPresenceApplet::setupAccountManager()
+{
+    Tp::registerTypes();
+
+    // setup the telepathy account manager from where I'll retrieve info on accounts and contacts
+    Tp::AccountFactoryPtr  accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus(),
+                                                                       Tp::Features() << Tp::Account::FeatureCore
+                                                                       << Tp::Account::FeatureAvatar
+                                                                       << Tp::Account::FeatureCapabilities
+                                                                       << Tp::Account::FeatureProtocolInfo
+                                                                       << Tp::Account::FeatureProfile);
+
+    Tp::ConnectionFactoryPtr connectionFactory = Tp::ConnectionFactory::create(QDBusConnection::sessionBus(),
+                                                                               Tp::Features() << Tp::Connection::FeatureCore
+                                                                               << Tp::Connection::FeatureRosterGroups
+                                                                               << Tp::Connection::FeatureRoster
+                                                                               << Tp::Connection::FeatureSelfContact);
+
+    Tp::ContactFactoryPtr contactFactory = Tp::ContactFactory::create(Tp::Features()
+    << Tp::Contact::FeatureAlias
+    << Tp::Contact::FeatureAvatarData
+    << Tp::Contact::FeatureSimplePresence
+    << Tp::Contact::FeatureCapabilities);
+
+    Tp::ChannelFactoryPtr channelFactory = Tp::ChannelFactory::create(QDBusConnection::sessionBus());
+
+    m_accountManager = Tp::AccountManager::create(QDBusConnection::sessionBus(),
+                                                  accountFactory,
+                                                  connectionFactory,
+                                                  channelFactory,
+                                                  contactFactory);
+
+    connect(m_accountManager->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)), this, SLOT(onAccountManagerReady(Tp::PendingOperation*)));
+}
+
+
 void TelepathyPresenceApplet::setupContextMenuActions()
 {
     // presence actions
@@ -110,12 +121,12 @@ void TelepathyPresenceApplet::setupContextMenuActions()
     KAction *showContactListAction = new KAction(KIcon("meeting-attending"), i18n("Contact List"), this);
 
     // connect actions
-    connect(goOnlineAction, SIGNAL(triggered()), m_globalPresenceWrapper, SLOT(setPresenceOnline()));
-    connect(goBusyAction, SIGNAL(triggered()), m_globalPresenceWrapper, SLOT(setPresenceBusy()));
-    connect(goAwayAction, SIGNAL(triggered()), m_globalPresenceWrapper, SLOT(setPresenceAway()));
-    connect(goExtendedAwayAction, SIGNAL(triggered()), m_globalPresenceWrapper, SLOT(setPresenceXa()));
-    connect(goHiddenAction, SIGNAL(triggered()), m_globalPresenceWrapper, SLOT(setPresenceHidden()));
-    connect(goOfflineAction, SIGNAL(triggered()), m_globalPresenceWrapper, SLOT(setPresenceOffline()));
+    connect(goOnlineAction, SIGNAL(triggered()), this, SLOT(setPresenceOnline()));
+    connect(goBusyAction, SIGNAL(triggered()), this, SLOT(setPresenceBusy()));
+    connect(goAwayAction, SIGNAL(triggered()), this, SLOT(setPresenceAway()));
+    connect(goExtendedAwayAction, SIGNAL(triggered()), this, SLOT(setPresenceXa()));
+    connect(goHiddenAction, SIGNAL(triggered()), this, SLOT(setPresenceHidden()));
+    connect(goOfflineAction, SIGNAL(triggered()), this, SLOT(setPresenceOffline()));
 
     connect(showAccountManagerAction, SIGNAL(triggered()), this, SLOT(startAccountManager()));
     connect(showContactListAction, SIGNAL(triggered()), this, SLOT(startContactList()));
@@ -135,6 +146,68 @@ void TelepathyPresenceApplet::setupContextMenuActions()
     m_contextActions.append(presenceMenu->addSeparator());
 }
 
+void TelepathyPresenceApplet::onAccountManagerReady(Tp::PendingOperation* op)
+{
+    if (op->isError()) {
+        kDebug() << op->errorName();
+        kDebug() << op->errorMessage();
+    }
+
+    // set the manager to the globalpresence
+    m_globalPresence->setAccountManager(m_accountManager);
+}
+
+void TelepathyPresenceApplet::onPresenceChanged(Tp::Presence presence)
+{
+    QString presenceStr = presence.status();
+
+    if (presenceStr == "available") {
+        setPopupIcon("user-online");
+    } else if (presenceStr == "busy" || presenceStr == "dnd") {
+        setPopupIcon("user-busy");
+    } else if (presenceStr == "away" || presenceStr == "brb") {
+        setPopupIcon("user-away");
+    } else if (presenceStr == "xa") {
+        setPopupIcon("user-away-extended");
+    } else if (presenceStr == "hidden") {
+        setPopupIcon("user-invisible");
+    } else if (presenceStr == "offline") {
+        setPopupIcon("user-offline");
+    } else {
+        setPopupIcon("user-offline");
+    }
+}
+
+void TelepathyPresenceApplet::setPresenceAway()
+{
+    m_globalPresence->setPresence(Tp::Presence::away(m_globalPresence->currentPresence().statusMessage()));
+}
+
+void TelepathyPresenceApplet::setPresenceBusy()
+{
+    m_globalPresence->setPresence(Tp::Presence::busy(m_globalPresence->currentPresence().statusMessage()));
+}
+
+void TelepathyPresenceApplet::setPresenceHidden()
+{
+    m_globalPresence->setPresence(Tp::Presence::hidden(m_globalPresence->currentPresence().statusMessage()));
+}
+
+void TelepathyPresenceApplet::setPresenceOffline()
+{
+    m_globalPresence->setPresence(Tp::Presence::offline(m_globalPresence->currentPresence().statusMessage()));
+}
+
+void TelepathyPresenceApplet::setPresenceOnline()
+{
+    m_globalPresence->setPresence(Tp::Presence::available(m_globalPresence->currentPresence().statusMessage()));
+}
+
+void TelepathyPresenceApplet::setPresenceXa()
+{
+    m_globalPresence->setPresence(Tp::Presence::xa(m_globalPresence->currentPresence().statusMessage()));
+}
+
 void TelepathyPresenceApplet::startAccountManager() const
 {
     KToolInvocation::startServiceByDesktopName("kcm_telepathy_accounts");
@@ -146,7 +219,6 @@ void TelepathyPresenceApplet::startContactList() const
 }
 
 
-
 // This is the command that links your applet to the .desktop file
 K_EXPORT_PLASMA_APPLET(telepathy-kde-presence-applet, TelepathyPresenceApplet)
 
diff --git a/presence/src/presence-applet.h b/presence/src/presence-applet.h
index 36b3900..01b6c61 100644
--- a/presence/src/presence-applet.h
+++ b/presence/src/presence-applet.h
@@ -20,26 +20,31 @@
 #ifndef TELEPATHY_KDE_PRESENCE_APPLET_H
 #define TELEPATHY_KDE_PRESENCE_APPLET_H
 
-#include <Plasma/Applet>
+#include <Plasma/PopupApplet>
 #include <Plasma/DeclarativeWidget>
 
+#include <TelepathyQt4/AccountManager>
+#include <TelepathyQt4/Presence>
+
+namespace KTp {
+    class GlobalPresence;
+}
+
+namespace Tp {
+    class PendingOperation;
+}
+
 class GlobalPresenceWrapper;
 class QAction;
 
-class TelepathyPresenceApplet: public Plasma::Applet
+class TelepathyPresenceApplet: public Plasma::PopupApplet
 {
     Q_OBJECT
 
-    Q_PROPERTY(int height READ appletHeight)
-    Q_PROPERTY(int width READ appletWidth)
-
 public:
     TelepathyPresenceApplet(QObject *parent, const QVariantList &args);
     ~TelepathyPresenceApplet();
 
-    int appletHeight() const;
-    int appletWidth() const;
-
     QList<QAction*>contextualActions();
     void init();
     void paintInterface(QPainter *p, const QStyleOptionGraphicsItem *option, const QRect& contentsRect);
@@ -49,20 +54,27 @@ public:
 //     void showConfigurationInterface();
 
 private Q_SLOTS:
+    void onAccountManagerReady(Tp::PendingOperation *op);
+    void onPresenceChanged(Tp::Presence presence);
+    void setPresenceAway();
+    void setPresenceBusy();
+    void setPresenceHidden();
+    void setPresenceOffline();
+    void setPresenceOnline();
+    void setPresenceXa();
     void startAccountManager() const;
     void startContactList() const;
 
 private:
-    /// TODO
-    void saveConfig();
+    void setupAccountManager();
+
     /** used only upon creation to setup a list of actions for the context menu */
     void setupContextMenuActions();
 
     QList<QAction*>m_contextActions;
 
-    Plasma::DeclarativeWidget *m_declarative;
-    QObject *m_qmlObject;
-    GlobalPresenceWrapper *m_globalPresenceWrapper;
+    Tp::AccountManagerPtr m_accountManager;
+    KTp::GlobalPresence *m_globalPresence;
 };
 
 #endif  // TELEPATHY_KDE_PRESENCE_APPLET_H

-- 
ktp-contact-applet packaging



More information about the pkg-kde-commits mailing list