[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:24:06 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=2ab50b0
The following commit has been merged in the master branch:
commit 2ab50b0db4529095133f51a33811502cbe1e000e
Author: Dan Vrátil <dvratil at redhat.com>
Date: Mon Aug 26 15:15:37 2013 +0200
Port LogViewer and text-ui to KTp Logger
ktp-text-ui no longer depends on TelepathyLoggerQt now.
REVIEW: 112006
BUG: 323981
---
CMakeLists.txt | 12 +--
cmake/modules/FindKTp.cmake | 2 +
lib/CMakeLists.txt | 15 +---
lib/logmanager.cpp | 129 ++++++++++++++-------------------
lib/logmanager.h | 9 ++-
lib/logmanager_dummy.cpp | 84 ---------------------
logviewer/CMakeLists.txt | 2 +-
logviewer/conversation-date-picker.cpp | 30 ++++----
logviewer/conversation-date-picker.h | 20 ++---
logviewer/entity-model-item.cpp | 7 +-
logviewer/entity-model-item.h | 4 +-
logviewer/entity-model.cpp | 24 +++---
logviewer/entity-model.h | 11 +--
logviewer/entity-proxy-model.cpp | 21 +++---
logviewer/entity-proxy-model.h | 14 ++--
logviewer/entity-view.cpp | 9 ++-
logviewer/log-viewer.cpp | 77 +++++++++-----------
logviewer/log-viewer.h | 14 ++--
logviewer/logs-import-dialog.h | 1 +
logviewer/main.cpp | 2 -
logviewer/message-view.cpp | 45 ++++++------
logviewer/message-view.h | 14 ++--
22 files changed, 205 insertions(+), 341 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a062b5f..8083bc2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,11 +15,6 @@ set(KDE_MIN_VERSION "4.4.75")
find_package (KDE4 ${KDE_MIN_VERSION} REQUIRED)
find_package (TelepathyQt4 0.9.1 REQUIRED)
find_package (KTp REQUIRED)
-find_package (TelepathyLoggerQt4 0.7.95 QUIET)
-
-macro_log_feature(TELEPATHY_LOGGER_QT4_FOUND "TelepatyLoggerQt4" "Qt bindings for TelepathyLogger. This is needed to provide access to chat logs. HIGHLY recommended" "http://projects.kde.org/telepathy-logger-qt" FALSE "" "")
-macro_display_feature_log()
-
# FUTURE: When we can depend on KDE 4.10, use emoticoncontexteditaction from here
# find_package(KdepimLibs 4.10 REQUIRED)
@@ -42,15 +37,10 @@ add_definitions (${KDE4_DEFINITIONS}
configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
-if (TELEPATHY_LOGGER_QT4_FOUND)
- add_definitions(${TELEPATHY_LOGGER_QT4_DEFINITIONS} -DHAVE_TPLOGGERQT)
- include_directories(${TELEPATHY_LOGGER_QT4_INCLUDE_DIRS})
- add_subdirectory(logviewer)
-endif (TELEPATHY_LOGGER_QT4_FOUND)
-
add_subdirectory(lib)
add_subdirectory(app)
add_subdirectory(config)
add_subdirectory(data)
add_subdirectory(adiumxtra-protocol-handler)
add_subdirectory(filters)
+add_subdirectory(logviewer)
diff --git a/cmake/modules/FindKTp.cmake b/cmake/modules/FindKTp.cmake
index 8facd12..4c6f7a6 100644
--- a/cmake/modules/FindKTp.cmake
+++ b/cmake/modules/FindKTp.cmake
@@ -4,6 +4,7 @@
# KTP_LIBRARIES
# KTP_MODELS_LIBRARIES
# KTP_WIDGETS_LIBRARIES
+# KTP_LOGGER_LIBRARIES
# Copyright (c) 2011, Dario Freddi <drf at kde.org>
#
@@ -28,6 +29,7 @@ find_path(KTP_INCLUDE_DIR
find_library(KTP_LIBRARIES NAMES ktpcommoninternalsprivate )
find_library(KTP_MODELS_LIBRARIES NAMES ktpmodelsprivate )
find_library(KTP_WIDGETS_LIBRARIES NAMES ktpwidgetsprivate )
+find_library(KTP_LOGGER_LIBRARIES NAMES ktploggerprivate )
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(KTp DEFAULT_MSG
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index c73de90..547c560 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -15,6 +15,7 @@ set(ktpchat_SRCS
chat-search-bar.cpp
notify-filter.cpp
text-chat-config.cpp
+ logmanager.cpp
)
set(ktpchat_HDRS
@@ -47,18 +48,6 @@ set(ktpchat_UI
chat-widget.ui
)
-if (TELEPATHY_LOGGER_QT4_FOUND)
- set(ktpchat_SRCS
- ${ktpchat_SRCS}
- logmanager.cpp
- )
-else (TELEPATHY_LOGGER_QT4_FOUND)
- set(ktpchat_SRCS
- ${ktpchat_SRCS}
- logmanager_dummy.cpp
- )
-endif (TELEPATHY_LOGGER_QT4_FOUND)
-
kde4_add_ui_files(ktpchat_SRCS ${ktpchat_UI})
kde4_add_library(ktpchat SHARED ${ktpchat_SRCS})
@@ -71,7 +60,7 @@ target_link_libraries(ktpchat
${KDE4_KDEWEBKIT_LIBRARY}
${KDE4_KEMOTICONS_LIBS}
${KTP_LIBRARIES}
- ${TELEPATHY_LOGGER_QT4_LIBRARIES}
+ ${KTP_LOGGER_LIBRARIES}
)
install(TARGETS ktpchat ${INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/lib/logmanager.cpp b/lib/logmanager.cpp
index 946b083..e54e109 100644
--- a/lib/logmanager.cpp
+++ b/lib/logmanager.cpp
@@ -1,5 +1,6 @@
/*
Copyright (C) 2011 Dominik Schmidt <kde at dominik-schmidt.de>
+ Copyright (C) 2013 Daniel Vrátil <dvratil at redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -22,17 +23,13 @@
#include "adium-theme-content-info.h"
#include <KTp/message-processor.h>
+#include <KTp/Logger/log-entity.h>
+#include <KTp/Logger/log-manager.h>
+#include <KTp/Logger/pending-logger-dates.h>
+#include <KTp/Logger/pending-logger-logs.h>
#include <KDebug>
-#include <TelepathyLoggerQt4/Init>
-#include <TelepathyLoggerQt4/LogWalker>
-#include <TelepathyLoggerQt4/Entity>
-#include <TelepathyLoggerQt4/PendingEvents>
-#include <TelepathyLoggerQt4/Event>
-#include <TelepathyLoggerQt4/TextEvent>
-#include <TelepathyLoggerQt4/LogManager>
-
#include <TelepathyQt/Types>
#include <TelepathyQt/AvatarData>
#include <TelepathyQt/TextChannel>
@@ -47,8 +44,7 @@ class LogManager::Private
Tp::AccountPtr account;
Tp::TextChannelPtr textChannel;
- Tpl::EntityPtr contactEntity;
- Tpl::LogManagerPtr logManager;
+ KTp::LogEntity contactEntity;
int scrollbackLength;
};
@@ -56,13 +52,6 @@ LogManager::LogManager(QObject *parent)
: QObject(parent),
d(new Private)
{
- Tpl::init();
-
- d->logManager = Tpl::LogManager::instance();
- if (d->logManager.isNull()) {
- qWarning() << "LogManager not found";
- Q_ASSERT(false);
- }
}
LogManager::~LogManager()
@@ -76,24 +65,27 @@ bool LogManager::exists() const
return false;
}
- Tpl::EntityPtr contactEntity;
- if (d->textChannel->targetHandleType() == Tp::HandleTypeContact) {
- contactEntity = Tpl::Entity::create(d->textChannel->targetContact()->id().toLatin1().data(),
- Tpl::EntityTypeContact, NULL, NULL);
- } else if (d->textChannel->targetHandleType() == Tp::HandleTypeRoom) {
- contactEntity = Tpl::Entity::create(d->textChannel->targetId().toLatin1().data(),
- Tpl::EntityTypeRoom, NULL, NULL);
- } else {
- return false;
- }
-
- return d->logManager->exists(d->account, contactEntity, Tpl::EventTypeMaskText);
+ return KTp::LogManager::instance()->logsExist(d->account, d->contactEntity);
}
void LogManager::setTextChannel(const Tp::AccountPtr &account, const Tp::TextChannelPtr &textChannel)
{
d->textChannel = textChannel;
d->account = account;
+
+ if (d->account.isNull() || d->textChannel.isNull()) {
+ return;
+ }
+
+ KTp::LogEntity contactEntity;
+ if (d->textChannel->targetHandleType() == Tp::HandleTypeContact) {
+ d->contactEntity = KTp::LogEntity(d->textChannel->targetHandleType(),
+ d->textChannel->targetContact()->id(),
+ d->textChannel->targetContact()->alias());
+ } else if (d->textChannel->targetHandleType() == Tp::HandleTypeRoom) {
+ d->contactEntity = KTp::LogEntity(d->textChannel->targetHandleType(),
+ d->textChannel->targetId());
+ }
}
void LogManager::setScrollbackLength(int n)
@@ -114,21 +106,11 @@ void LogManager::fetchScrollback()
void LogManager::fetchHistory(int n)
{
if (n > 0 && !d->account.isNull() && !d->textChannel.isNull()) {
- Tpl::EntityPtr contactEntity;
- if (d->textChannel->targetHandleType() == Tp::HandleTypeContact) {
- contactEntity = Tpl::Entity::create(d->textChannel->targetContact()->id().toLatin1().data(),
- Tpl::EntityTypeContact, NULL, NULL);
- } else if (d->textChannel->targetHandleType() == Tp::HandleTypeRoom) {
- contactEntity = Tpl::Entity::create(d->textChannel->targetId().toLatin1().data(),
- Tpl::EntityTypeRoom, NULL, NULL);
- }
-
- if (!contactEntity.isNull()) {
- Tpl::LogWalkerPtr walker = d->logManager->queryWalkFilteredEvents(
- d->account, contactEntity, Tpl::EventTypeMaskText, 0, 0);
- Tpl::PendingEvents *events = walker->queryEvents(n);
- connect(events, SIGNAL(finished(Tpl::PendingOperation*)),
- this, SLOT(onEventsFinished(Tpl::PendingOperation*)));
+ if (d->contactEntity.isValid()) {
+ KTp::LogManager *manager = KTp::LogManager::instance();
+ KTp::PendingLoggerDates *dates = manager->queryDates(d->account, d->contactEntity);
+ connect(dates, SIGNAL(finished(KTp::PendingLoggerOperation*)),
+ this, SLOT(onDatesFinished(KTp::PendingLoggerOperation*)));
return;
}
}
@@ -138,45 +120,44 @@ void LogManager::fetchHistory(int n)
Q_EMIT fetched(messages);
}
-bool operator<(const Tpl::EventPtr &e1, const Tpl::EventPtr &e2)
-{
- return e1->timestamp() < e2->timestamp();
-}
-
-void LogManager::onEventsFinished(Tpl::PendingOperation *po)
+void LogManager::onDatesFinished(KTp::PendingLoggerOperation* po)
{
- Tpl::PendingEvents *pe = (Tpl::PendingEvents*) po;
-
- if (pe->isError()) {
- qWarning() << "error in PendingEvents" << pe->errorMessage();
+ KTp::PendingLoggerDates *datesOp = qobject_cast<KTp::PendingLoggerDates*>(po);
+ if (datesOp->hasError()) {
+ kWarning() << "Failed to fetch dates:" << datesOp->error();
+ Q_EMIT fetched(QList<KTp::Message>());
return;
}
- QStringList queuedMessageTokens;
- if (!d->textChannel.isNull()) {
- Q_FOREACH(const Tp::ReceivedMessage &message, d->textChannel->messageQueue()) {
- queuedMessageTokens.append(message.messageToken());
- }
+ const QList<QDate> dates = datesOp->dates();
+ if (dates.isEmpty()) {
+ Q_EMIT fetched(QList<KTp::Message>());
+ return;
}
- kDebug() << "queuedMessageTokens" << queuedMessageTokens;
-
- // get last n (d->fetchLast) messages that are not queued
- QList<Tpl::EventPtr> allEvents = pe->events();
+ KTp::LogManager *manager = KTp::LogManager::instance();
+ KTp::PendingLoggerLogs *logs = manager->queryLogs(datesOp->account(), datesOp->entity(),
+ dates.last());
+ connect(logs, SIGNAL(finished(KTp::PendingLoggerOperation*)),
+ this, SLOT(onEventsFinished(KTp::PendingLoggerOperation*)));
+}
- // See https://bugs.kde.org/show_bug.cgi?id=317866
- // Uses the operator< overload above
- qSort(allEvents);
+void LogManager::onEventsFinished(KTp::PendingLoggerOperation *op)
+{
+ KTp::PendingLoggerLogs *logsOp = qobject_cast<KTp::PendingLoggerLogs*>(op);
+ if (logsOp->hasError()) {
+ kWarning() << "Failed to fetch events:" << logsOp->error();
+ Q_EMIT fetched(QList<KTp::Message>());
+ return;
+ }
+ // get last n (d->fetchLast) messages that are not queued
+ const QList<KTp::LogMessage> allMessages = logsOp->logs();
QList<KTp::Message> messages;
- Q_FOREACH (const Tpl::EventPtr &event, allEvents) {
- const Tpl::TextEventPtr textEvent = event.dynamicCast<Tpl::TextEvent>();
- if (!textEvent.isNull()) {
- if (!queuedMessageTokens.contains(textEvent->messageToken())) {
- const KTp::Message message = KTp::MessageProcessor::instance()->processIncomingMessage(textEvent, d->account, d->textChannel);
- messages.append(message);
- }
- }
+ const KTp::MessageContext ctx(d->account, d->textChannel);
+ for (int i = 0; i < d->scrollbackLength && i < allMessages.count(); ++i) {
+ const KTp::LogMessage message = allMessages[i];
+ messages << KTp::MessageProcessor::instance()->processIncomingMessage(message, ctx);
}
kDebug() << "emit all messages" << messages.count();
diff --git a/lib/logmanager.h b/lib/logmanager.h
index 61a5b04..4ff540c 100644
--- a/lib/logmanager.h
+++ b/lib/logmanager.h
@@ -1,5 +1,6 @@
/*
Copyright (C) 2011 Dominik Schmidt <kde at dominik-schmidt.de>
+ Copyright (C) 2013 Daniel Vrátil <dvratil at redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -24,11 +25,10 @@
#include <KTp/message.h>
-namespace Tpl {
- class PendingOperation;
+namespace KTp {
+class PendingLoggerOperation;
}
-
class LogManager : public QObject
{
Q_OBJECT
@@ -62,7 +62,8 @@ Q_SIGNALS:
void fetched(const QList<KTp::Message> &messages);
private Q_SLOTS:
- void onEventsFinished(Tpl::PendingOperation *po);
+ void onDatesFinished(KTp::PendingLoggerOperation *po);
+ void onEventsFinished(KTp::PendingLoggerOperation *po);
private:
class Private;
diff --git a/lib/logmanager_dummy.cpp b/lib/logmanager_dummy.cpp
deleted file mode 100644
index bf11809..0000000
--- a/lib/logmanager_dummy.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- Copyright (C) 2013 Daniel Vrátil <dvratil at redhat.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 library 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-
-#include "logmanager.h"
-
-#include <TelepathyQt/Types>
-
-class LogManager::Private
-{
- public:
- Private(): scrollbackLength(10)
- {
- }
-
- int scrollbackLength;
-};
-
-LogManager::LogManager(QObject *parent)
- : QObject(parent),
- d(new Private)
-{
-}
-
-LogManager::~LogManager()
-{
- delete d;
-}
-
-bool LogManager::exists() const
-{
- return false;
-}
-
-void LogManager::setTextChannel(const Tp::AccountPtr &account, const Tp::TextChannelPtr &textChannel)
-{
- Q_UNUSED(account);
- Q_UNUSED(textChannel);
-}
-
-void LogManager::setScrollbackLength(int n)
-{
- d->scrollbackLength = n;
-}
-
-int LogManager::scrollbackLength() const
-{
- return d->scrollbackLength;
-}
-
-void LogManager::fetchScrollback()
-{
- QMetaObject::invokeMethod(this, "fetched", Qt::QueuedConnection,
- Q_ARG(QList<KTp::Message>, QList<KTp::Message>()));
-}
-
-void LogManager::fetchHistory(int n)
-{
- Q_UNUSED(n);
-
- fetchScrollback();
-}
-
-void LogManager::onEventsFinished(Tpl::PendingOperation *po)
-{
- Q_UNUSED(po);
-}
-
-#include "moc_logmanager.cpp"
diff --git a/logviewer/CMakeLists.txt b/logviewer/CMakeLists.txt
index d01d7e1..300ba8f 100644
--- a/logviewer/CMakeLists.txt
+++ b/logviewer/CMakeLists.txt
@@ -23,9 +23,9 @@ target_link_libraries(ktp-log-viewer
${TELEPATHY_QT4_LIBRARIES}
${KDE4_KEMOTICONS_LIBS}
${KDE4_KCMUTILS_LIBS}
- ${TELEPATHY_LOGGER_QT4_LIBRARIES}
${KDE4_KDEWEBKIT_LIBRARY}
${KTP_LIBRARIES}
+ ${KTP_LOGGER_LIBRARIES}
ktpchat)
install(TARGETS ktp-log-viewer DESTINATION ${BIN_INSTALL_DIR})
diff --git a/logviewer/conversation-date-picker.cpp b/logviewer/conversation-date-picker.cpp
index c3c31ec..b8db972 100644
--- a/logviewer/conversation-date-picker.cpp
+++ b/logviewer/conversation-date-picker.cpp
@@ -19,11 +19,8 @@
#include "conversation-date-picker.h"
-#include <TelepathyLoggerQt4/LogManager>
-#include <TelepathyLoggerQt4/PendingDates>
-#include <TelepathyLoggerQt4/PendingOperation>
-#include <TelepathyLoggerQt4/Entity>
-#include <TelepathyLoggerQt4/SearchHit>
+#include <KTp/Logger/log-manager.h>
+#include <KTp/Logger/pending-logger-dates.h>
#include <KDateTable>
#include <TelepathyQt/Account>
@@ -33,7 +30,7 @@ ConversationDatePicker::ConversationDatePicker(QWidget *parent) :
{
}
-void ConversationDatePicker::setEntity(const Tp::AccountPtr &account, const Tpl::EntityPtr &entity)
+void ConversationDatePicker::setEntity(const Tp::AccountPtr &account, const KTp::LogEntity &entity)
{
clear();
@@ -45,9 +42,9 @@ void ConversationDatePicker::setEntity(const Tp::AccountPtr &account, const Tpl:
updatePaintedDates();
Q_EMIT dateChanged(date());
} else {
- Tpl::LogManagerPtr logManager = Tpl::LogManager::instance();
- Tpl::PendingDates *pendingDates = logManager->queryDates(account, entity, Tpl::EventTypeMaskText);
- connect(pendingDates, SIGNAL(finished(Tpl::PendingOperation*)), SLOT(onDatesFinished(Tpl::PendingOperation*)));
+ KTp::LogManager *logManager = KTp::LogManager::instance();
+ KTp::PendingLoggerDates* pendingDates = logManager->queryDates(account, entity);
+ connect(pendingDates, SIGNAL(finished(KTp::PendingLoggerOperation*)), SLOT(onDatesFinished(KTp::PendingLoggerOperation*)));
}
}
@@ -62,7 +59,7 @@ void ConversationDatePicker::clear()
}
}
-void ConversationDatePicker::setSearchHits(const Tpl::SearchHitList &searchHits)
+void ConversationDatePicker::setSearchHits(const QList<KTp::LogSearchHit> &searchHits)
{
m_searchHits = searchHits;
@@ -77,7 +74,6 @@ void ConversationDatePicker::clearSearchHits()
updatePaintedDates();
}
-
QDate ConversationDatePicker::nextDate() const
{
QList<QDate>::ConstIterator iter = qUpperBound(m_setDates, date());
@@ -103,9 +99,9 @@ const QList<QDate>& ConversationDatePicker::validDates() const
return m_setDates;
}
-void ConversationDatePicker::onDatesFinished(Tpl::PendingOperation *op)
+void ConversationDatePicker::onDatesFinished(KTp::PendingLoggerOperation *op)
{
- Tpl::PendingDates *pendingDates = qobject_cast<Tpl::PendingDates*>(op);
+ KTp::PendingLoggerDates *pendingDates = qobject_cast<KTp::PendingLoggerDates*>(op);
m_setDates = pendingDates->dates();
qSort(m_setDates);
@@ -127,17 +123,17 @@ void ConversationDatePicker::setDatesFromSearchHits()
{
m_setDates.clear();
- if (m_account.isNull() || m_entity.isNull()) {
+ if (m_account.isNull() || !m_entity.isValid()) {
return;
}
- Q_FOREACH (const Tpl::SearchHit &searchHit, m_searchHits) {
- if (searchHit.account().isNull() || searchHit.target().isNull()) {
+ Q_FOREACH (const KTp::LogSearchHit &searchHit, m_searchHits) {
+ if (searchHit.account().isNull() || !searchHit.entity().isValid()) {
continue;
}
if ((searchHit.account()->uniqueIdentifier() == m_account->uniqueIdentifier()) &&
- (searchHit.target()->identifier() == m_entity->identifier())) {
+ (searchHit.entity().id() == m_entity.id())) {
m_setDates << searchHit.date();
}
}
diff --git a/logviewer/conversation-date-picker.h b/logviewer/conversation-date-picker.h
index d39e68d..6e1bd60 100644
--- a/logviewer/conversation-date-picker.h
+++ b/logviewer/conversation-date-picker.h
@@ -1,5 +1,6 @@
/***************************************************************************
* Copyright (C) 2012 by David Edmundson <kde at davidedmundson.co.uk> *
+ * Copyright (C) 2013 by Daniel Vrátil <dvratil at redhat.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -22,12 +23,13 @@
#include <KDatePicker>
-#include <TelepathyLoggerQt4/Entity>
-#include <TelepathyLoggerQt4/SearchHit>
+#include <KTp/Logger/log-entity.h>
+#include <KTp/Logger/log-search-hit.h>
+
#include <TelepathyQt/Types>
-namespace Tpl{
- class PendingOperation;
+namespace KTp {
+class PendingLoggerOperation;
}
class ConversationDatePicker : public KDatePicker
@@ -36,10 +38,10 @@ class ConversationDatePicker : public KDatePicker
public:
explicit ConversationDatePicker(QWidget *parent = 0);
- void setEntity(const Tp::AccountPtr &accout, const Tpl::EntityPtr &entity);
+ void setEntity(const Tp::AccountPtr &accout, const KTp::LogEntity &entity);
void clear();
- void setSearchHits(const Tpl::SearchHitList &searchHits);
+ void setSearchHits(const QList<KTp::LogSearchHit> &searchHits);
void clearSearchHits();
QDate previousDate() const;
@@ -47,15 +49,15 @@ public:
const QList<QDate>& validDates() const;
private Q_SLOTS:
- void onDatesFinished(Tpl::PendingOperation*);
+ void onDatesFinished(KTp::PendingLoggerOperation *op);
private:
void updatePaintedDates();
void setDatesFromSearchHits();
Tp::AccountPtr m_account;
- Tpl::EntityPtr m_entity;
- Tpl::SearchHitList m_searchHits;
+ KTp::LogEntity m_entity;
+ QList<KTp::LogSearchHit> m_searchHits;
QList< QDate > m_setDates;
};
diff --git a/logviewer/entity-model-item.cpp b/logviewer/entity-model-item.cpp
index b5ace64..4e2189d 100644
--- a/logviewer/entity-model-item.cpp
+++ b/logviewer/entity-model-item.cpp
@@ -21,7 +21,6 @@
#include "entity-model.h"
#include <TelepathyQt/Contact>
-#include <TelepathyLoggerQt4/Entity>
#include <QDebug>
@@ -95,7 +94,7 @@ QVariant EntityModelItem::data(int role) const
{
switch (role) {
case Qt::DisplayRole:
- return m_contact ? m_contact->alias() : (m_entity ? m_entity->alias() : m_account->displayName());
+ return m_contact ? m_contact->alias() : (m_entity.isValid() ? m_entity.alias() : m_account->displayName());
case EntityModel::AccountRole:
return QVariant::fromValue(m_account);
case EntityModel::ContactRole:
@@ -103,7 +102,7 @@ QVariant EntityModelItem::data(int role) const
case EntityModel::EntityRole:
return QVariant::fromValue(m_entity);
case EntityModel::IdRole:
- return m_entity->identifier();
+ return m_entity.id();
}
return QVariant();
@@ -119,7 +118,7 @@ void EntityModelItem::setData(const QVariant &data, int role)
m_contact = data.value< KTp::ContactPtr >();
break;
case EntityModel::EntityRole:
- m_entity = data.value< Tpl::EntityPtr >();
+ m_entity = data.value< KTp::LogEntity >();
break;
}
}
diff --git a/logviewer/entity-model-item.h b/logviewer/entity-model-item.h
index 8713956..d7cb8ed 100644
--- a/logviewer/entity-model-item.h
+++ b/logviewer/entity-model-item.h
@@ -25,9 +25,9 @@
#include <QList>
#include <TelepathyQt/Types>
-#include <TelepathyLoggerQt4/Entity>
#include <KTp/contact.h>
+#include <KTp/Logger/log-entity.h>
class EntityModelItem
{
@@ -54,7 +54,7 @@ private:
EntityModelItem *m_parent;
Tp::AccountPtr m_account;
- Tpl::EntityPtr m_entity;
+ KTp::LogEntity m_entity;
KTp::ContactPtr m_contact;
};
diff --git a/logviewer/entity-model.cpp b/logviewer/entity-model.cpp
index 4f0dc49..164f263 100644
--- a/logviewer/entity-model.cpp
+++ b/logviewer/entity-model.cpp
@@ -21,10 +21,9 @@
#include "entity-model.h"
#include "entity-model-item.h"
-#include <TelepathyLoggerQt4/LogManager>
-#include <TelepathyLoggerQt4/PendingEntities>
-#include <TelepathyLoggerQt4/PendingOperation>
-#include <TelepathyLoggerQt4/Entity>
+#include <KTp/Logger/log-manager.h>
+#include <KTp/Logger/log-entity.h>
+#include <KTp/Logger/pending-logger-entities.h>
#include <TelepathyQt/AccountManager>
#include <TelepathyQt/Account>
@@ -49,11 +48,11 @@ EntityModel::~EntityModel()
void EntityModel::setAccountManager(const Tp::AccountManagerPtr &accountManager)
{
- Tpl::LogManagerPtr logManager = Tpl::LogManager::instance();
+ KTp::LogManager *logManager = KTp::LogManager::instance();
Q_FOREACH(const Tp::AccountPtr &account, accountManager->allAccounts()) {
connect(logManager->queryEntities(account),
- SIGNAL(finished(Tpl::PendingOperation*)),
- SLOT(onEntitiesSearchFinished(Tpl::PendingOperation*)));
+ SIGNAL(finished(KTp::PendingLoggerOperation*)),
+ SLOT(onEntitiesSearchFinished(KTp::PendingLoggerOperation*)));
}
}
@@ -158,13 +157,12 @@ bool EntityModel::removeRows(int start, int count, const QModelIndex &parent)
return true;
}
-void EntityModel::onEntitiesSearchFinished(Tpl::PendingOperation *operation)
+void EntityModel::onEntitiesSearchFinished(KTp::PendingLoggerOperation *operation)
{
- Tpl::PendingEntities *pendingEntities = qobject_cast<Tpl::PendingEntities*>(operation);
+ KTp::PendingLoggerEntities *pendingEntities = qobject_cast<KTp::PendingLoggerEntities*>(operation);
+ const QList<KTp::LogEntity> newEntries = pendingEntities->entities();
- Tpl::EntityPtrList newEntries = pendingEntities->entities();
-
- Q_FOREACH(const Tpl::EntityPtr &entity, newEntries) {
+ Q_FOREACH(const KTp::LogEntity &entity, newEntries) {
EntityModelItem *parent = m_rootItem->item(pendingEntities->account());
if (!parent) {
beginInsertRows(QModelIndex(), m_rootItem->itemCount(), m_rootItem->itemCount());
@@ -184,7 +182,7 @@ void EntityModel::onEntitiesSearchFinished(Tpl::PendingOperation *operation)
if (pendingEntities->account()->connection()) {
Tp::PendingOperation *op =
pendingEntities->account()->connection()->contactManager()->contactsForIdentifiers(
- QStringList() << entity->identifier());
+ QStringList() << entity.id());
connect(op, SIGNAL(finished(Tp::PendingOperation*)),
this, SLOT(onEntityContactRetrieved(Tp::PendingOperation*)));
}
diff --git a/logviewer/entity-model.h b/logviewer/entity-model.h
index 37cdeae..f9bf293 100644
--- a/logviewer/entity-model.h
+++ b/logviewer/entity-model.h
@@ -25,7 +25,6 @@
#include <TelepathyQt/Types>
-#include <TelepathyLoggerQt4/Entity>
#include <TelepathyQt/Account>
#include <KTp/types.h>
@@ -37,11 +36,11 @@
- Qt::DecorationRole - avatar
- EntityModel::IdRole
- EntityModel::TypeRole - EntityType (EntityTypeContact/Room/Self/Unknown)
- - EntityModel::EntityRole - relevant Tpl::EntityPtr
+ - EntityModel::EntityRole - relevant KTp::LogEntity
*/
-namespace Tpl{
- class PendingOperation;
+namespace KTp {
+ class PendingLoggerOperation;
}
class EntityModelItem;
@@ -74,7 +73,7 @@ public:
bool removeRows(int start, int count, const QModelIndex &parent = QModelIndex());
private Q_SLOTS:
- void onEntitiesSearchFinished(Tpl::PendingOperation*);
+ void onEntitiesSearchFinished(KTp::PendingLoggerOperation*);
void onEntityContactRetrieved(Tp::PendingOperation*);
private:
@@ -82,6 +81,4 @@ private:
};
-Q_DECLARE_METATYPE(Tpl::EntityPtr);
-
#endif // ENTITYMODEL_H
diff --git a/logviewer/entity-proxy-model.cpp b/logviewer/entity-proxy-model.cpp
index e8c440e..b57296b 100644
--- a/logviewer/entity-proxy-model.cpp
+++ b/logviewer/entity-proxy-model.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2012 by Dan Vratil <dan at progdan.cz> *
+ * Copyright (C) 2012,2013 by Dan Vratil <dan at progdan.cz> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -22,7 +22,6 @@
#include "entity-model.h"
#include <TelepathyQt/Types>
-#include <TelepathyLoggerQt4/SearchHit>
EntityProxyModel::EntityProxyModel(QObject *parent):
QSortFilterProxyModel(parent)
@@ -42,22 +41,22 @@ bool EntityProxyModel::filterAcceptsRow(int source_row, const QModelIndex &sourc
QModelIndex index = source_parent.child(source_row, 0);
Tp::AccountPtr account = source_parent.data(EntityModel::AccountRole).value< Tp::AccountPtr >();
- Tpl::EntityPtr entity = index.data(EntityModel::EntityRole).value< Tpl::EntityPtr >();
+ KTp::LogEntity entity = index.data(EntityModel::EntityRole).value< KTp::LogEntity >();
bool matches_filter = false;
- if (!m_searchHits.isEmpty() && !account.isNull() && !entity.isNull()) {
- Q_FOREACH(const Tpl::SearchHit &searchHit, m_searchHits) {
+ if (!m_searchHits.isEmpty() && !account.isNull() && entity.isValid()) {
+ Q_FOREACH(const KTp::LogSearchHit &searchHit, m_searchHits) {
Tp::AccountPtr searchHitAccount = searchHit.account();
- Tpl::EntityPtr searchHitTarget = searchHit.target();
+ KTp::LogEntity searchHitTarget = searchHit.entity();
- /* Don't display search hits with empty account or target */
- if (searchHitAccount.isNull() || searchHitTarget.isNull()) {
+ // Don't display search hits with empty account or target
+ if (searchHitAccount.isNull() || !searchHitTarget.isValid()) {
continue;
}
if ((searchHitAccount->uniqueIdentifier() == account->uniqueIdentifier()) &&
- (searchHitTarget->identifier() == entity->identifier())) {
+ (searchHitTarget.id() == entity.id())) {
matches_filter = true;
}
}
@@ -73,7 +72,7 @@ bool EntityProxyModel::filterAcceptsRow(int source_row, const QModelIndex &sourc
KTp::ContactPtr contact = index.data(EntityModel::ContactRole).value< KTp::ContactPtr >();
/* Check if contact's account name matches */
- if (entity->alias().contains(term, Qt::CaseInsensitive) && matches_filter) {
+ if (entity.alias().contains(term, Qt::CaseInsensitive) && matches_filter) {
return true;
}
@@ -87,7 +86,7 @@ bool EntityProxyModel::filterAcceptsRow(int source_row, const QModelIndex &sourc
return false;
}
-void EntityProxyModel::setSearchHits(const Tpl::SearchHitList &searchHits)
+void EntityProxyModel::setSearchHits(const QList<KTp::LogSearchHit> &searchHits)
{
m_searchHits = searchHits;
diff --git a/logviewer/entity-proxy-model.h b/logviewer/entity-proxy-model.h
index 78dd071..837f4af 100644
--- a/logviewer/entity-proxy-model.h
+++ b/logviewer/entity-proxy-model.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2012 by Dan Vratil <dan at progdan.cz> *
+ * Copyright (C) 2012,2013 by Dan Vratil <dan at progdan.cz> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -22,9 +22,13 @@
#define ENTITY_PROXY_MODEL_H
#include <QSortFilterProxyModel>
-#include <TelepathyLoggerQt4/Types>
-typedef QPair< Tp::AccountPtr, Tpl::EntityPtr > AccountEntityPair;
+#include <TelepathyQt/Types>
+
+#include <KTp/Logger/log-entity.h>
+#include <KTp/Logger/log-search-hit.h>
+
+typedef QPair< Tp::AccountPtr, KTp::LogEntity > AccountEntityPair;
class EntityProxyModel : public QSortFilterProxyModel
{
@@ -34,14 +38,14 @@ public:
explicit EntityProxyModel(QObject *parent = 0);
virtual ~EntityProxyModel();
- void setSearchHits(const Tpl::SearchHitList &searchHits);
+ void setSearchHits(const QList<KTp::LogSearchHit> &searchHits);
void clearSearchHits();
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
private:
- Tpl::SearchHitList m_searchHits;
+ QList<KTp::LogSearchHit> m_searchHits;
};
diff --git a/logviewer/entity-view.cpp b/logviewer/entity-view.cpp
index 97e7087..77fefc0 100644
--- a/logviewer/entity-view.cpp
+++ b/logviewer/entity-view.cpp
@@ -21,8 +21,9 @@
#include <KCmdLineArgs>
+#include <KTp/Logger/log-entity.h>
+
#include <TelepathyQt/Account>
-#include <TelepathyLoggerQt4/Entity>
#include "entity-model.h"
@@ -48,13 +49,13 @@ void EntityView::rowsInserted(const QModelIndex &parent, int start, int end)
for (int i = start; i <= end; i++) {
QModelIndex index = model()->index(i, 0, parent);
Tp::AccountPtr account = index.data(EntityModel::AccountRole).value<Tp::AccountPtr>();
- Tpl::EntityPtr contact = index.data(EntityModel::EntityRole).value<Tpl::EntityPtr>();
+ KTp::LogEntity entity = index.data(EntityModel::EntityRole).value<KTp::LogEntity>();
- if (account.isNull() || contact.isNull()) {
+ if (account.isNull() || !entity.isValid()) {
continue;
}
- if (selectAccountId == account->uniqueIdentifier() && selectContactId == contact->identifier()) {
+ if (selectAccountId == account->uniqueIdentifier() && selectContactId == entity.id()) {
setCurrentIndex(index);
loadedCurrentContact = true;
break;
diff --git a/logviewer/log-viewer.cpp b/logviewer/log-viewer.cpp
index 6fca33d..909777d 100644
--- a/logviewer/log-viewer.cpp
+++ b/logviewer/log-viewer.cpp
@@ -1,5 +1,6 @@
/***************************************************************************
* Copyright (C) 2012 by David Edmundson <kde at davidedmundson.co.uk> *
+ * Copyright (C) 2012,2013 by Daniel Vrátil <dvratil at redhat.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -24,11 +25,9 @@
#include <TelepathyQt/PendingReady>
#include <TelepathyQt/ContactManager>
-#include <TelepathyLoggerQt4/Init>
-#include <TelepathyLoggerQt4/Entity>
-#include <TelepathyLoggerQt4/LogManager>
-#include <TelepathyLoggerQt4/SearchHit>
-#include <TelepathyLoggerQt4/PendingSearch>
+#include <KTp/Logger/log-manager.h>
+#include <KTp/Logger/log-entity.h>
+#include <KTp/Logger/pending-logger-search.h>
#include <KTp/logs-importer.h>
#include <KTp/contact.h>
@@ -141,8 +140,8 @@ void LogViewer::setupActions()
void LogViewer::onAccountManagerReady()
{
- Tpl::LogManagerPtr logManager = Tpl::LogManager::instance();
- logManager->setAccountManagerPtr(m_accountManager);
+ KTp::LogManager *logManger = KTp::LogManager::instance();
+ logManger->setAccountManager(m_accountManager);
m_entityModel->setAccountManager(m_accountManager);
/* Try to run log import */
@@ -159,10 +158,10 @@ void LogViewer::onEntitySelected(const QModelIndex ¤t, const QModelIndex &
return;
}
- Tpl::EntityPtr entity = current.data(EntityModel::EntityRole).value<Tpl::EntityPtr>();
+ KTp::LogEntity entity = current.data(EntityModel::EntityRole).value<KTp::LogEntity>();
Tp::AccountPtr account = current.data(EntityModel::AccountRole).value<Tp::AccountPtr>();
- if (!account.isNull() && !entity.isNull()) {
+ if (!account.isNull() && entity.isValid()) {
actionCollection()->action(QLatin1String("clear-contact-logs"))->setEnabled(true);
}
@@ -199,7 +198,7 @@ void LogViewer::slotUpdateMainWindow()
nearestDates.first = m_prevConversationDate;
nearestDates.second = m_nextConversationDate;
- Tpl::EntityPtr entity = currentIndex.data(EntityModel::EntityRole).value<Tpl::EntityPtr>();
+ KTp::LogEntity entity = currentIndex.data(EntityModel::EntityRole).value<KTp::LogEntity>();
KTp::ContactPtr contact = currentIndex.data(EntityModel::ContactRole).value<KTp::ContactPtr>();
Tp::AccountPtr account = currentIndex.data(EntityModel::AccountRole).value<Tp::AccountPtr>();
ui->messageView->loadLog(account, entity, contact, date, nearestDates);
@@ -225,19 +224,19 @@ void LogViewer::slotStartGlobalSearch(const QString &term)
ui->messageView->setHighlightText(term);
- Tpl::LogManagerPtr manager = Tpl::LogManager::instance();
- Tpl::PendingSearch *search = manager->search(term, Tpl::EventTypeMaskAny);
- connect (search, SIGNAL(finished(Tpl::PendingOperation*)),
- this, SLOT(onGlobalSearchFinished(Tpl::PendingOperation*)));
+ KTp::LogManager *manager = KTp::LogManager::instance();
+ KTp::PendingLoggerSearch *search = manager->search(term);
+ connect(search, SIGNAL(finished(KTp::PendingLoggerOperation*)),
+ this, SLOT(onGlobalSearchFinished(KTp::PendingLoggerOperation*)));
}
-void LogViewer::onGlobalSearchFinished(Tpl::PendingOperation *operation)
+void LogViewer::onGlobalSearchFinished(KTp::PendingLoggerOperation *operation)
{
- Tpl::PendingSearch *search = qobject_cast< Tpl::PendingSearch* >(operation);
+ KTp::PendingLoggerSearch *search = qobject_cast<KTp::PendingLoggerSearch*>(operation);
Q_ASSERT(search);
- m_filterModel->setSearchHits(search->hits());
- ui->datePicker->setSearchHits(search->hits());
+ m_filterModel->setSearchHits(search->searchHits());
+ ui->datePicker->setSearchHits(search->searchHits());
ui->globalSearch->setEnabled(true);
ui->busyAnimation->setSequence(KPixmapSequence());
@@ -270,7 +269,7 @@ void LogViewer::slotClearAccountHistory()
{
QModelIndex index = ui->entityList->currentIndex();
- /* Usually and account node is selected, so traverse up to it's parent
+ /* Usually a contact node is selected, so traverse up to it's parent
* account node */
if (index.parent().isValid()) {
index = index.parent();
@@ -292,9 +291,17 @@ void LogViewer::slotClearAccountHistory()
return;
}
- Tpl::LogManagerPtr logManager = Tpl::LogManager::instance();
- Tpl::PendingOperation *operation = logManager->clearAccountHistory(account);
- connect(operation, SIGNAL(finished(Tpl::PendingOperation*)), SLOT(onLogClearingFinished(Tpl::PendingOperation*)));
+ KTp::LogManager::instance()->clearAccountLogs(account);
+
+ QModelIndex parent = index.parent();
+ m_entityModel->removeRow(index.row(), parent);
+
+ // If last entity was removed then remove the account node as well
+ if (parent.isValid() && !m_entityModel->hasChildren(parent)) {
+ m_entityModel->removeRow(parent.row(), parent.parent());
+ }
+
+ m_entityListContextMenu->setProperty("index", QVariant());
}
void LogViewer::slotClearContactHistory()
@@ -305,8 +312,8 @@ void LogViewer::slotClearContactHistory()
}
Tp::AccountPtr account = index.data(EntityModel::AccountRole).value<Tp::AccountPtr>();
- Tpl::EntityPtr entity = index.data(EntityModel::EntityRole).value<Tpl::EntityPtr>();
- if (account.isNull() || entity.isNull()) {
+ KTp::LogEntity entity = index.data(EntityModel::EntityRole).value<KTp::LogEntity>();
+ if (account.isNull() || !entity.isValid()) {
return;
}
@@ -318,30 +325,12 @@ void LogViewer::slotClearContactHistory()
return;
}
- Tpl::LogManagerPtr logManager = Tpl::LogManager::instance();
- Tpl::PendingOperation *operation = logManager->clearEntityHistory(account, entity);
- connect(operation, SIGNAL(finished(Tpl::PendingOperation*)), SLOT(onLogClearingFinished(Tpl::PendingOperation*)));
-}
-
-void LogViewer::onLogClearingFinished(Tpl::PendingOperation *operation)
-{
- if (!operation->errorName().isEmpty() || !operation->errorMessage().isEmpty()) {
- /* Make sure we display at least some message */
- QString msg = (operation->errorMessage().isEmpty()) ? operation->errorName() : operation->errorMessage();
- KMessageBox::sorry(this, msg, operation->errorName(), 0);
- return;
- }
-
- QModelIndex index = m_entityListContextMenu->property("index").value<QModelIndex>();
- if (!index.isValid()) {
- m_entityListContextMenu->setProperty("index", QVariant());
- return;
- }
+ KTp::LogManager::instance()->clearContactLogs(account, entity);
QModelIndex parent = index.parent();
m_entityModel->removeRow(index.row(), parent);
- /* If last entity was removed then remove the account node as well */
+ // If last entity was removed then remove the account node as well
if (parent.isValid() && !m_entityModel->hasChildren(parent)) {
m_entityModel->removeRow(parent.row(), parent.parent());
}
diff --git a/logviewer/log-viewer.h b/logviewer/log-viewer.h
index f5f512f..5820a88 100644
--- a/logviewer/log-viewer.h
+++ b/logviewer/log-viewer.h
@@ -1,5 +1,6 @@
/***************************************************************************
* Copyright (C) 2012 by David Edmundson <kde at davidedmundson.co.uk> *
+ * Copyright (C) 2012,2013 by Daniel Vrátil <dvratil at redhat.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@@ -21,14 +22,14 @@
#define LOGVIEWER_H
#include <KXmlGuiWindow>
-#include <TelepathyLoggerQt4/Types>
+#include <TelepathyQt/Types>
-namespace Ui {
- class LogViewer;
+namespace KTp {
+class PendingLoggerOperation;
}
-namespace Tpl {
- class PendingOperation;
+namespace Ui {
+ class LogViewer;
}
class EntityModel;
@@ -56,11 +57,10 @@ private Q_SLOTS:
void slotShowEntityListContextMenu(const QPoint &coords);
void slotClearGlobalSearch();
void slotStartGlobalSearch(const QString &term);
- void onGlobalSearchFinished(Tpl::PendingOperation *);
+ void onGlobalSearchFinished(KTp::PendingLoggerOperation *);
void slotClearAccountHistory();
void slotClearContactHistory();
- void onLogClearingFinished(Tpl::PendingOperation *);
void slotImportKopeteLogs(bool force = true);
diff --git a/logviewer/logs-import-dialog.h b/logviewer/logs-import-dialog.h
index 05f813e..7d2ad4d 100644
--- a/logviewer/logs-import-dialog.h
+++ b/logviewer/logs-import-dialog.h
@@ -39,6 +39,7 @@ class LogsImportDialog : public KDialog
LogsImportDialog(QObject* parent);
virtual ~LogsImportDialog();
+
void importLogs(const QList<Tp::AccountPtr> &accounts);
protected Q_SLOTS:
diff --git a/logviewer/main.cpp b/logviewer/main.cpp
index be894c5..53b95cd 100644
--- a/logviewer/main.cpp
+++ b/logviewer/main.cpp
@@ -25,7 +25,6 @@
#include "version.h"
#include <TelepathyQt/AccountManager>
-#include <TelepathyLoggerQt4/Init>
#include <KTp/contact-factory.h>
@@ -53,7 +52,6 @@ int main(int argc, char *argv[])
KApplication app;
Tp::registerTypes();
- Tpl::init();
Tp::AccountFactoryPtr accountFactory = Tp::AccountFactory::create(
QDBusConnection::sessionBus(),
diff --git a/logviewer/message-view.cpp b/logviewer/message-view.cpp
index 13a67d9..b037900 100644
--- a/logviewer/message-view.cpp
+++ b/logviewer/message-view.cpp
@@ -28,9 +28,9 @@
#include <QLabel>
#include <QResizeEvent>
-#include <TelepathyLoggerQt4/LogManager>
-#include <TelepathyLoggerQt4/PendingEvents>
-#include <TelepathyLoggerQt4/TextEvent>
+#include <KTp/Logger/log-manager.h>
+#include <KTp/Logger/pending-logger-logs.h>
+
#include <TelepathyQt/Account>
MessageView::MessageView(QWidget *parent) :
@@ -45,11 +45,11 @@ MessageView::MessageView(QWidget *parent) :
connect(this, SIGNAL(loadFinished(bool)), SLOT(processStoredEvents()));
}
-void MessageView::loadLog(const Tp::AccountPtr &account, const Tpl::EntityPtr &entity,
+void MessageView::loadLog(const Tp::AccountPtr &account, const KTp::LogEntity &entity,
const Tp::ContactPtr &contact, const QDate &date,
const QPair< QDate, QDate > &nearestDates)
{
- if (account.isNull() || entity.isNull()) {
+ if (account.isNull() || !entity.isValid()) {
//note contact can be null
showInfoMessage(i18n("Unknown or invalid contact"));
return;
@@ -63,7 +63,7 @@ void MessageView::loadLog(const Tp::AccountPtr &account, const Tpl::EntityPtr &e
m_prev = nearestDates.first;
m_next = nearestDates.second;
- if (entity->entityType() == Tpl::EntityTypeRoom) {
+ if (entity.entityType() == Tp::HandleTypeRoom) {
load(AdiumThemeView::GroupChat);
} else {
load(AdiumThemeView::SingleUserChat);
@@ -76,9 +76,9 @@ void MessageView::loadLog(const Tp::AccountPtr &account, const Tpl::EntityPtr &e
arg(QString::fromLatin1(m_account->avatar().avatarData.toBase64().data()));
}
- Tpl::LogManagerPtr logManager = Tpl::LogManager::instance();
- Tpl::PendingEvents *pendingEvents = logManager->queryEvents(m_account, m_entity, Tpl::EventTypeMaskText, m_date);
- connect(pendingEvents, SIGNAL(finished(Tpl::PendingOperation*)), SLOT(onEventsLoaded(Tpl::PendingOperation*)));
+ KTp::LogManager *logManager = KTp::LogManager::instance();
+ KTp::PendingLoggerLogs *pendingLogs = logManager->queryLogs(m_account, m_entity, m_date);
+ connect(pendingLogs, SIGNAL(finished(KTp::PendingLoggerOperation*)), SLOT(onEventsLoaded(KTp::PendingLoggerOperation*)));
}
void MessageView::showInfoMessage(const QString& message)
@@ -106,29 +106,29 @@ void MessageView::clearHighlightText()
setHighlightText(QString());
}
-void MessageView::onEventsLoaded(Tpl::PendingOperation *po)
+void MessageView::onEventsLoaded(KTp::PendingLoggerOperation *po)
{
- Tpl::PendingEvents *pe = qobject_cast<Tpl::PendingEvents*>(po);
- m_events << pe->events();
+ KTp::PendingLoggerLogs *pl = qobject_cast<KTp::PendingLoggerLogs*>(po);
+ m_events << pl->logs();
/* Wait with initialization for the first event so that we can know when the chat session started */
AdiumThemeHeaderInfo headerInfo;
- headerInfo.setDestinationDisplayName(m_contact.isNull() ? m_entity->alias() : m_contact->alias());
- headerInfo.setChatName(m_contact.isNull() ? m_entity->alias() : m_contact->alias());
- headerInfo.setGroupChat(m_entity->entityType() == Tpl::EntityTypeRoom);
+ headerInfo.setDestinationDisplayName(m_contact.isNull() ? m_entity.alias() : m_contact->alias());
+ headerInfo.setChatName(m_contact.isNull() ? m_entity.alias() : m_contact->alias());
+ headerInfo.setGroupChat(m_entity.entityType() == Tp::HandleTypeRoom);
headerInfo.setSourceName(m_account->displayName());
headerInfo.setIncomingIconPath(m_contact.isNull() ? QString() : m_contact->avatarData().fileName);
- if (pe->events().count() > 0 && !pe->events().first().isNull()) {
- headerInfo.setTimeOpened(pe->events().first()->timestamp());
+ if (pl->logs().count() > 0) {
+ headerInfo.setTimeOpened(pl->logs().first().time());
}
initialise(headerInfo);
}
-bool operator<(const Tpl::EventPtr &e1, const Tpl::EventPtr &e2)
+bool logMessageOlderThan(const KTp::LogMessage &e1, const KTp::LogMessage &e2)
{
- return e1->timestamp() < e2->timestamp();
+ return e1.time() < e2.time();
}
void MessageView::processStoredEvents()
@@ -148,11 +148,12 @@ void MessageView::processStoredEvents()
// See https://bugs.kde.org/show_bug.cgi?id=317866
// Uses the operator< overload above
- qSort(m_events);
+ qSort(m_events.begin(), m_events.end(), logMessageOlderThan);
while (!m_events.isEmpty()) {
- const Tpl::TextEventPtr textEvent(m_events.takeFirst().staticCast<Tpl::TextEvent>());
- KTp::Message message = KTp::MessageProcessor::instance()->processIncomingMessage(textEvent, m_account, Tp::TextChannelPtr());
+ const KTp::LogMessage msg = m_events.takeFirst();
+ KTp::MessageContext ctx(m_account, Tp::TextChannelPtr());
+ KTp::Message message = KTp::MessageProcessor::instance()->processIncomingMessage(msg, ctx);
addMessage(message);
}
diff --git a/logviewer/message-view.h b/logviewer/message-view.h
index 4dcf49c..4e2e2bb 100644
--- a/logviewer/message-view.h
+++ b/logviewer/message-view.h
@@ -24,9 +24,9 @@
#include <QDate>
-#include <TelepathyLoggerQt4/Event>
-#include <TelepathyLoggerQt4/Entity>
-#include <TelepathyLoggerQt4/PendingOperation>
+#include <KTp/Logger/log-entity.h>
+#include <KTp/Logger/log-message.h>
+#include <KTp/Logger/pending-logger-operation.h>
class QLabel;
@@ -36,7 +36,7 @@ class MessageView : public AdiumThemeView
public:
explicit MessageView(QWidget *parent = 0);
- void loadLog(const Tp::AccountPtr &account, const Tpl::EntityPtr &entity,
+ void loadLog(const Tp::AccountPtr &account, const KTp::LogEntity &entity,
const Tp::ContactPtr &contact, const QDate &date,
const QPair< QDate, QDate > &nearestDates);
@@ -49,7 +49,7 @@ public Q_SLOTS:
void onLinkClicked(const QUrl &link);
private Q_SLOTS:
- void onEventsLoaded(Tpl::PendingOperation* po);
+ void onEventsLoaded(KTp::PendingLoggerOperation* po);
void doHighlightText();
void processStoredEvents();
@@ -60,7 +60,7 @@ protected:
virtual void resizeEvent(QResizeEvent *e);
private:
- Tpl::EntityPtr m_entity;
+ KTp::LogEntity m_entity;
Tp::AccountPtr m_account;
Tp::ContactPtr m_contact;
QDate m_date;
@@ -69,7 +69,7 @@ private:
QString m_highlightedText;
- Tpl::EventPtrList m_events;
+ QList<KTp::LogMessage> m_events;
QString m_accountAvatar;
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list