[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9

Maximiliano Curia maxy at moszumanska.debian.org
Mon May 9 09:08:15 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=381f7a8

The following commit has been merged in the master branch:
commit 381f7a89414b1fe04af344fd0a6b21c8503f9eb3
Author: Ahmed I. Khalil <ahmedibrahimkhali at gmail.com>
Date:   Sat Apr 26 21:26:24 2014 +0200

    Don't hardcode Connection Managers (Haze, Gabble, etc..) in ktp-debugger
    REVIEW: 117793
    BUG: 303563
---
 tools/debugger/main-window.cpp | 63 +++++++++++++++++++++++++++++++++++-------
 tools/debugger/main-window.h   |  9 ++++++
 tools/debugger/main-window.ui  | 40 ---------------------------
 3 files changed, 62 insertions(+), 50 deletions(-)

diff --git a/tools/debugger/main-window.cpp b/tools/debugger/main-window.cpp
index eb607cc..52ba74d 100644
--- a/tools/debugger/main-window.cpp
+++ b/tools/debugger/main-window.cpp
@@ -17,12 +17,18 @@
 */
 #include "main-window.h"
 #include "debug-message-view.h"
+
+#include <TelepathyQt/AccountManager>
+#include <TelepathyQt/AccountSet>
+#include <TelepathyQt/PendingReady>
+
+#include <QtAlgorithms>
+
 #include <KAction>
 #include <KIcon>
 #include <KStatusBar>
 #include <KToolBar>
 
-
 MainWindow::MainWindow(QWidget *parent)
     : KXmlGuiWindow(parent)
 {
@@ -31,20 +37,16 @@ MainWindow::MainWindow(QWidget *parent)
     setupGUI();
 
     m_ui.mcLogsView->setService(QLatin1String("org.freedesktop.Telepathy.MissionControl5"));
-    m_ui.gabbleLogsView->setService(QLatin1String("org.freedesktop.Telepathy.ConnectionManager.gabble"));
-    m_ui.hazeLogsView->setService(QLatin1String("org.freedesktop.Telepathy.ConnectionManager.haze"));
-    m_ui.salutLogsView->setService(QLatin1String("org.freedesktop.Telepathy.ConnectionManager.salut"));
-    m_ui.rakiaLogsView->setService(QLatin1String("org.freedesktop.Telepathy.ConnectionManager.rakia"));
+
+    m_AccountManager = Tp::AccountManager::create();
+    Tp::PendingReady *pendingReady = m_AccountManager->becomeReady();
+    connect(pendingReady, SIGNAL(finished(Tp::PendingOperation*)), this, SLOT(onAccountManagerBecameReady(Tp::PendingOperation*)));
 
     KAction *saveLogAction = new KAction(KIcon(QLatin1String("document-save-as"), KIconLoader::global()), i18n("Save Log"), this);
     saveLogAction->setToolTip(i18nc("Toolbar icon tooltip", "Save log of the current tab"));
     toolBar()->addAction(saveLogAction);
 
     connect(m_ui.mcLogsView, SIGNAL(statusMessage(QString)), statusBar(), SLOT(showMessage(QString)));
-    connect(m_ui.gabbleLogsView, SIGNAL(statusMessage(QString)), statusBar(), SLOT(showMessage(QString)));
-    connect(m_ui.hazeLogsView, SIGNAL(statusMessage(QString)), statusBar(), SLOT(showMessage(QString)));
-    connect(m_ui.salutLogsView, SIGNAL(statusMessage(QString)), statusBar(), SLOT(showMessage(QString)));
-    connect(m_ui.rakiaLogsView, SIGNAL(statusMessage(QString)), statusBar(), SLOT(showMessage(QString)));
     connect(saveLogAction, SIGNAL(triggered(bool)), this, SLOT(saveLogFile()));
 }
 
@@ -56,4 +58,45 @@ MainWindow::~MainWindow()
 void MainWindow::saveLogFile()
 {
     m_ui.tabWidget->currentWidget()->findChild<DebugMessageView *>()->saveLogFile();
-}
\ No newline at end of file
+}
+
+void MainWindow::onAccountManagerBecameReady(Tp::PendingOperation* op)
+{
+    if (op->isError()) {
+        kError() << "Failed to initialize Tp::AccountManager"
+                 << "Error was:" << op->errorName() << "-" << op->errorMessage();
+    } else {
+        QSet<QString> connectionManagers;
+
+        Tp::AccountSetPtr accountSetPtr = m_AccountManager->onlineAccounts();
+        QList<Tp::AccountPtr> accountList = accountSetPtr->accounts();
+
+        Q_FOREACH(Tp::AccountPtr account, accountList) {
+            connectionManagers.insert(account->cmName());
+        }
+
+        initConnectionManagerTabs(connectionManagers);
+    }
+}
+
+void MainWindow::initConnectionManagerTabs(const QSet<QString>& connectionManagerSet)
+{
+    QStringList connectionManagerStringList = connectionManagerSet.toList();
+    qSort(connectionManagerStringList);
+
+    Q_FOREACH(QString connectionManager, connectionManagerStringList) {
+        QWidget *cmTab = new QWidget();
+        QHBoxLayout *horizontalLayout = new QHBoxLayout(cmTab);
+        DebugMessageView *cmDebugMessageView = new DebugMessageView(cmTab);
+        cmDebugMessageView->setService(QString(QLatin1String("org.freedesktop.Telepathy.ConnectionManager.%1")).arg(connectionManager));
+
+        horizontalLayout->addWidget(cmDebugMessageView);
+
+        // Convert the connectionManager to title case. eg. haze to Haze
+        QString tabText = connectionManager;
+        tabText[0] = tabText[0].toTitleCase();
+        m_ui.tabWidget->addTab(cmTab, tabText);
+
+        connect(cmDebugMessageView, SIGNAL(statusMessage(QString)), statusBar(), SLOT(showMessage(QString)));
+    }
+}
diff --git a/tools/debugger/main-window.h b/tools/debugger/main-window.h
index 67ea785..2e7c968 100644
--- a/tools/debugger/main-window.h
+++ b/tools/debugger/main-window.h
@@ -19,6 +19,9 @@
 #define MAIN_WINDOW_H
 
 #include "ui_main-window.h"
+
+#include <TelepathyQt/Types>
+
 #include <KXmlGuiWindow>
 
 class MainWindow : public KXmlGuiWindow
@@ -31,7 +34,13 @@ public:
 public Q_SLOTS:
     void saveLogFile();
 
+private Q_SLOTS:
+    void onAccountManagerBecameReady(Tp::PendingOperation *pendingReady);
+
 private:
+    void initConnectionManagerTabs(const QSet<QString> &connectionManagerSet);
+
+    Tp::AccountManagerPtr m_AccountManager;
     Ui::MainWindow m_ui;
 };
 
diff --git a/tools/debugger/main-window.ui b/tools/debugger/main-window.ui
index dd7dcc4..4df1e7b 100644
--- a/tools/debugger/main-window.ui
+++ b/tools/debugger/main-window.ui
@@ -26,46 +26,6 @@
        </item>
       </layout>
      </widget>
-     <widget class="QWidget" name="gabbleTab">
-      <attribute name="title">
-       <string notr="true">Gabble</string>
-      </attribute>
-      <layout class="QHBoxLayout" name="horizontalLayout_3">
-       <item>
-        <widget class="DebugMessageView" name="gabbleLogsView"/>
-       </item>
-      </layout>
-     </widget>
-     <widget class="QWidget" name="hazeTab">
-      <attribute name="title">
-       <string notr="true">Haze</string>
-      </attribute>
-      <layout class="QHBoxLayout" name="horizontalLayout_4">
-       <item>
-        <widget class="DebugMessageView" name="hazeLogsView"/>
-       </item>
-      </layout>
-     </widget>
-     <widget class="QWidget" name="salutTab">
-      <attribute name="title">
-       <string notr="true">Salut</string>
-      </attribute>
-      <layout class="QHBoxLayout" name="horizontalLayout_5">
-       <item>
-        <widget class="DebugMessageView" name="salutLogsView"/>
-       </item>
-      </layout>
-     </widget>
-     <widget class="QWidget" name="rakiaTab">
-      <attribute name="title">
-       <string notr="true">Rakia</string>
-      </attribute>
-      <layout class="QHBoxLayout" name="horizontalLayout_6">
-       <item>
-        <widget class="DebugMessageView" name="rakiaLogsView"/>
-       </item>
-      </layout>
-     </widget>
     </widget>
    </item>
   </layout>

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list