[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:11:45 UTC 2016


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

The following commit has been merged in the master branch:
commit 72ee1a85bbdaee780ad97255a8d0da38e1697681
Author: Francesco Nwokeka <francesco.nwokeka at gmail.com>
Date:   Mon Oct 3 19:35:03 2011 +0200

    Move accountManagerPtr from config to main applet class
    
    there was no need to keep full track of the model's changes when not using them
---
 src/config.cpp            | 78 ++++++---------------------------------------
 src/config.h              | 12 +------
 src/telepathy-contact.cpp | 81 +++++++++++++++++++++++++++++++++++++++++++----
 src/telepathy-contact.h   |  8 ++++-
 4 files changed, 92 insertions(+), 87 deletions(-)

diff --git a/src/config.cpp b/src/config.cpp
index 9734a83..dbf8373 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -27,73 +27,28 @@
 #include <KDebug>
 #include <KPushButton>
 
-#include <TelepathyQt4/PendingOperation>
-#include <TelepathyQt4/PendingReady>
-#include <TelepathyQt4/Types>
-
-Config::Config(QWidget* parent)
+Config::Config(const Tp::AccountManagerPtr &accountManager, QWidget* parent)
     : KDialog(parent)
     , m_model(0)
     , m_modelFilter(0)
     , m_groupsModel(0)
+    , m_accountManager(accountManager)
 {
     QWidget *widget = new QWidget(this);
 
     ui.setupUi(widget);
     setMainWidget(widget);
     setCaption(i18n("Select a contact"));
+    setupContactsList();
 
-    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*)));
     connect(this, SIGNAL(buttonClicked(KDialog::ButtonCode)), this, SLOT(slotButtonClicked(int)));
 }
 
 Config::~Config()
 {
-}
-
-Tp::AccountPtr Config::accountFromUniqueId(const QString& id) const
-{
-    Tp::AccountPtr account;
-
-    if (m_accountManager) {
-        foreach (account, m_accountManager->allAccounts()) {
-            if (account->uniqueIdentifier() == id) {
-                return account;
-            }
-        }
-    }
-
-    return account;
+    m_groupsModel->deleteLater();
+    m_model->deleteLater();
+    m_modelFilter->deleteLater();
 }
 
 void Config::activateOkButton()
@@ -115,13 +70,9 @@ void Config::enableOfflineContacts(bool enable)
     m_modelFilter->showOfflineUsers(enable);
 }
 
-void Config::onAccountManagerReady(Tp::PendingOperation* op)
+void Config::setupContactsList()
 {
-    if (op->isError()) {
-        kDebug() << op->errorName();
-        kDebug() << op->errorMessage();
-    }
-
+    // prepare models
     m_model = new AccountsModel(m_accountManager, this);
     m_groupsModel = new GroupsModel(m_model, this);
     m_modelFilter = new AccountsFilterModel(this);
@@ -138,17 +89,6 @@ void Config::onAccountManagerReady(Tp::PendingOperation* op)
     m_modelFilter->setSortRole(Qt::DisplayRole);
     m_modelFilter->setSortByPresence(true);
 
-//     // search input
-//     m_modelFilter->clearFilterString();
-//     m_modelFilter->setFilterCaseSensitivity(Qt::CaseInsensitive);
-
-    setupContactsList();
-
-    emit(loadConfig());
-}
-
-void Config::setupContactsList()
-{
     // set model for the contacts tree view
     ui.contactsList->setModel(m_modelFilter);
 
@@ -182,6 +122,8 @@ void Config::slotButtonClicked(int button)
             setNewContact(item->contact(), account);
             accept();
         }
+    } else if (button == KDialog::Cancel) {
+        delayedDestruct();
     }
 
     KDialog::slotButtonClicked(button);
diff --git a/src/config.h b/src/config.h
index 6d3e27d..36e8266 100644
--- a/src/config.h
+++ b/src/config.h
@@ -38,19 +38,10 @@ class Config : public KDialog
     Q_OBJECT
 
 public:
-    Config(QWidget *parent = 0);
+    Config(const Tp::AccountManagerPtr &accountManager, QWidget *parent = 0);
     ~Config();
 
-    /** retrieve accountPtr by given unique identifier */
-    Tp::AccountPtr accountFromUniqueId(const QString &id) const;
-
-//     /** retrieve contactPtr from given id */
-//     Tp::ContactPtr contactFromUniqueId(const Tp::AccountPtr &account, const QString &id) const;
-
 signals:
-    /** emitted when accountManager is ready so that the plasmoid can retrieve Account and Contact pointers */
-    void loadConfig();
-
     void setNewContact(const Tp::ContactPtr &newContact, const Tp::AccountPtr &relatedAccount);
 
 protected slots:
@@ -60,7 +51,6 @@ private slots:
     void activateOkButton();
     void enableGroupsView(bool enable);                     /** enable/disable groups view */
     void enableOfflineContacts(bool enable);                /** enable/disable offline contacts */
-    void onAccountManagerReady(Tp::PendingOperation* op);
 
 private:
     void setupContactsList();                               /** prepare the contacts to be show in the list */
diff --git a/src/telepathy-contact.cpp b/src/telepathy-contact.cpp
index 34ce6db..883ecd7 100644
--- a/src/telepathy-contact.cpp
+++ b/src/telepathy-contact.cpp
@@ -30,12 +30,15 @@
 
 #include <QtGui/QPainter>
 
+#include <TelepathyQt4/AccountManager>
 #include <TelepathyQt4/ContactManager>
+#include <TelepathyQt4/PendingOperation>
+#include <TelepathyQt4/PendingReady>
+#include <TelepathyQt4/Types>
 
 
 TelepathyContact::TelepathyContact(QObject* parent, const QVariantList& args)
     : Plasma::Applet(parent, args)
-    , m_config(new Config())
     , m_declarative(new Plasma::DeclarativeWidget(this))
     , m_contact(new ContactWrapper(parent))
     , m_qmlObject(0)
@@ -47,8 +50,8 @@ TelepathyContact::TelepathyContact(QObject* parent, const QVariantList& args)
     // user shouldn't be able to resize the plasmoid
     setAspectRatioMode(Plasma::FixedSize);
 
-    connect(m_config, SIGNAL(setNewContact(Tp::ContactPtr, Tp::AccountPtr)), this, SLOT(setContact(Tp::ContactPtr, Tp::AccountPtr)));
-    connect(m_config, SIGNAL(loadConfig()), this, SLOT(loadConfig()));
+    // prepare account manager
+    setupAccountManager();
 
     if (args.length() == 1) {
         m_fileToLoad = args.first().toString();
@@ -58,12 +61,26 @@ TelepathyContact::TelepathyContact(QObject* parent, const QVariantList& args)
 
 TelepathyContact::~TelepathyContact()
 {
-    delete m_config;
-    delete m_declarative;
+    m_declarative->deleteLater();
 //     delete m_contact;
 //     delete m_qmlObject;
 }
 
+Tp::AccountPtr TelepathyContact::accountFromUniqueId(const QString &id) const
+{
+    Tp::AccountPtr account;
+
+    if (m_accountManager) {
+        foreach (account, m_accountManager->allAccounts()) {
+            if (account->uniqueIdentifier() == id) {
+                return account;
+            }
+        }
+    }
+
+    return account;
+}
+
 void TelepathyContact::init()
 {
     Plasma::Applet::init();
@@ -112,7 +129,7 @@ void TelepathyContact::loadConfig()
     }
 
     if (!contactId.isEmpty() && !relatedAcc.isEmpty()) {
-        Tp::AccountPtr account = m_config->accountFromUniqueId(relatedAcc);
+        Tp::AccountPtr account = accountFromUniqueId(relatedAcc);
         Tp::ContactPtr contact;
 
         // check on account. Shouldn't ever be invalid
@@ -145,6 +162,17 @@ void TelepathyContact::loadConfig()
     }
 }
 
+void TelepathyContact::onAccountManagerReady(Tp::PendingOperation* op)
+{
+    if (op->isError()) {
+        kDebug() << op->errorName();
+        kDebug() << op->errorMessage();
+    }
+
+    // now I can load config
+    loadConfig();
+}
+
 void TelepathyContact::paintInterface(QPainter* p, const QStyleOptionGraphicsItem* option, const QRect& contentsRect)
 {
     Plasma::Applet::paintInterface(p, option, contentsRect);
@@ -165,6 +193,41 @@ void TelepathyContact::saveConfig()
     configNeedsSaving();
 }
 
+void TelepathyContact::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 TelepathyContact::setContact(const Tp::ContactPtr& newContact, const Tp::AccountPtr &relatedAccount)
 {
     Q_ASSERT(newContact);
@@ -180,7 +243,11 @@ void TelepathyContact::setContact(const Tp::ContactPtr& newContact, const Tp::Ac
 
 void TelepathyContact::showConfigurationInterface()
 {
-    m_config->show();
+    if (!isUserConfiguring()) {
+        Config *config = new Config(m_accountManager, 0);
+        connect(config, SIGNAL(setNewContact(Tp::ContactPtr, Tp::AccountPtr)), this, SLOT(setContact(Tp::ContactPtr, Tp::AccountPtr)));
+        config->show();
+    }
 }
 
 // This is the command that links your applet to the .desktop file
diff --git a/src/telepathy-contact.h b/src/telepathy-contact.h
index ce7632f..5f39d19 100644
--- a/src/telepathy-contact.h
+++ b/src/telepathy-contact.h
@@ -25,6 +25,7 @@
 #include <Plasma/Applet>
 #include <Plasma/DeclarativeWidget>
 
+#include <TelepathyQt4/AccountManager>
 #include <TelepathyQt4/Contact>
 
 class Config;
@@ -52,15 +53,20 @@ public slots:
 
 private slots:
     void loadConfig();
+    void onAccountManagerReady(Tp::PendingOperation *op);
 
 private:
+    /** retrieve accountPtr by given unique identifier */
+    Tp::AccountPtr accountFromUniqueId(const QString &id) const;
+
     void saveConfig();
+    void setupAccountManager();
 
     QString m_fileToLoad;
-    Config *m_config;
     Plasma::DeclarativeWidget *m_declarative;
     ContactWrapper *m_contact;
     QObject *m_qmlObject;
+    Tp::AccountManagerPtr m_accountManager;
 };
 
 #endif  // TELEPATHY_CONTACT_H

-- 
ktp-contact-applet packaging



More information about the pkg-kde-commits mailing list