[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:05:20 UTC 2016


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

The following commit has been merged in the master branch:
commit ddbfe452aaf4461fef0cbe13d976f92a76cf9f44
Author: George Kiagiadakis <kiagiadakis.george at gmail.com>
Date:   Sun Dec 11 19:50:04 2011 +0200

    Initial implementation of a debugging tool
---
 tools/debugger/CMakeLists.txt                      |  20 +++
 tools/debugger/debug-messages-model.cpp            | 188 +++++++++++++++++++++
 tools/debugger/debug-messages-model.h              |  59 +++++++
 tools/debugger/main-window.cpp                     |  40 +++++
 .../debugger/main-window.h                         |  36 ++--
 tools/debugger/main-window.ui                      |  55 ++++++
 tools/debugger/main.cpp                            |  49 ++++++
 7 files changed, 427 insertions(+), 20 deletions(-)

diff --git a/tools/debugger/CMakeLists.txt b/tools/debugger/CMakeLists.txt
new file mode 100644
index 0000000..599de1a
--- /dev/null
+++ b/tools/debugger/CMakeLists.txt
@@ -0,0 +1,20 @@
+project(telepathy-kde-debugger)
+
+find_package(TelepathyQt4 REQUIRED)
+find_package(KDE4 REQUIRED)
+
+include_directories(
+    ${CMAKE_CURRENT_BINARY_DIR}
+    ${TELEPATHY_QT4_INCLUDE_DIR}
+    ${KDE4_INCLUDES}
+)
+
+set(tp-kde-debugger_SRCS
+    main-window.cpp
+    debug-messages-model.cpp
+    main.cpp
+)
+
+kde4_add_ui_files(tp-kde-debugger_SRCS main-window.ui)
+kde4_add_executable(telepathy-kde-debugger ${tp-kde-debugger_SRCS})
+target_link_libraries(telepathy-kde-debugger ${TELEPATHY_QT4_LIBRARIES} ${KDE4_KDEUI_LIBS})
diff --git a/tools/debugger/debug-messages-model.cpp b/tools/debugger/debug-messages-model.cpp
new file mode 100644
index 0000000..a7ed444
--- /dev/null
+++ b/tools/debugger/debug-messages-model.cpp
@@ -0,0 +1,188 @@
+/*
+    Copyright (C) 2011 Collabora Ltd. <info at collabora.com>
+      @author George Kiagiadakis <george.kiagiadakis at collabora.com>
+
+    This library is free software; you can redistribute it and/or modify
+    it under the terms of the GNU Lesser General Public License as published
+    by the Free Software Foundation; either version 2.1 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "debug-messages-model.h"
+
+#include <TelepathyQt/PendingReady>
+#include <TelepathyQt/Constants>
+#include <KDebug>
+#include <ctime>
+
+DebugMessagesModel::DebugMessagesModel(const QString & service, QObject *parent)
+    : QAbstractListModel(parent),
+      m_serviceName(service),
+      m_ready(false)
+{
+    m_serviceWatcher = new QDBusServiceWatcher(service, QDBusConnection::sessionBus(),
+                                               QDBusServiceWatcher::WatchForOwnerChange, this);
+    connect(m_serviceWatcher, SIGNAL(serviceRegistered(QString)),
+            SLOT(onServiceRegistered(QString)));
+    connect(m_serviceWatcher, SIGNAL(serviceUnregistered(QString)),
+            SLOT(onServiceUnregistered(QString)));
+
+    if (QDBusConnection::sessionBus().interface()->isServiceRegistered(service)) {
+        onServiceRegistered(service);
+    }
+}
+
+DebugMessagesModel::~DebugMessagesModel()
+{
+}
+
+void DebugMessagesModel::onServiceRegistered(const QString & service)
+{
+    kDebug() << "Service" << service << "registered. Introspecting Debug interface...";
+
+    m_debugReceiver = Tp::DebugReceiver::create(service);
+
+    Tp::PendingReady *op = m_debugReceiver->becomeReady(Tp::DebugReceiver::FeatureMonitor);
+    connect(op, SIGNAL(finished(Tp::PendingOperation*)),
+            SLOT(onDebugReceiverReady(Tp::PendingOperation*)));
+}
+
+void DebugMessagesModel::onServiceUnregistered(const QString & service)
+{
+    kDebug() << "Service" << service << "unregistered";
+    m_ready = false;
+    m_debugReceiver.reset();
+}
+
+void DebugMessagesModel::onDebugReceiverReady(Tp::PendingOperation *op)
+{
+    if (op->isError()) {
+        kDebug() << "Failed to introspect Debug interface for" << m_serviceName
+                 << "Error was:" << op->errorName() << "-" << op->errorMessage();
+        m_debugReceiver.reset();
+    } else {
+        connect(m_debugReceiver.data(), SIGNAL(newDebugMessage(Tp::DebugMessage)),
+                SLOT(onNewDebugMessage(Tp::DebugMessage)));
+
+        connect(m_debugReceiver->fetchMessages(), SIGNAL(finished(Tp::PendingOperation*)),
+            SLOT(onFetchMessagesFinished(Tp::PendingOperation*)));
+    }
+}
+
+void DebugMessagesModel::onFetchMessagesFinished(Tp::PendingOperation* op)
+{
+    if (op->isError()) {
+        kError() << "Failed to fetch messages from" << m_serviceName
+                 << "Error was:" << op->errorName() << "-" << op->errorMessage();
+        m_tmpCache.clear();
+        m_debugReceiver.reset();
+    } else {
+        Tp::PendingDebugMessageList *pdml = qobject_cast<Tp::PendingDebugMessageList*>(op);
+        Tp::DebugMessageList messages = pdml->result();
+        messages.append(m_tmpCache); //append any messages that were received from onNewDebugMessage()
+        m_tmpCache.clear();
+
+        beginInsertRows(QModelIndex(), m_messages.size(), m_messages.size() + messages.size());
+        m_messages.append(messages);
+        endInsertRows();
+
+        //TODO limit m_messages size
+
+        m_ready = true;
+    }
+}
+
+void DebugMessagesModel::onNewDebugMessage(const Tp::DebugMessage & msg)
+{
+    if (m_ready) {
+        beginInsertRows(QModelIndex(), m_messages.size(), m_messages.size());
+        m_messages.append(msg);
+        endInsertRows();
+
+        //TODO limit m_messages size
+    } else {
+        //cache until we are ready
+        m_tmpCache.append(msg);
+    }
+}
+
+//taken from empathy
+static QString formatTimestamp(double timestamp)
+{
+    struct tm *tstruct;
+    char time_str[32];
+    int ms;
+    time_t sec;
+
+    ms = (int) ((timestamp - (int) timestamp)*1e6);
+    sec = (long) timestamp;
+    tstruct = std::localtime((time_t *) &sec);
+    if (!std::strftime(time_str, sizeof(time_str), "%x %T", tstruct)) {
+        kDebug() << "Failed to format timestamp" << timestamp;
+        time_str[0] = '

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list