[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:21 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=35f9178
The following commit has been merged in the master branch:
commit 35f91787ffd35d314445eed430b266f4b288cd83
Author: Siddhartha Sahu <sh.siddhartha at gmail.com>
Date: Thu Nov 7 16:11:57 2013 +0530
Use ScrollBackManager from ktp-common-internals
REVIEW: 113848
---
lib/CMakeLists.txt | 1 -
lib/chat-widget.cpp | 6 +-
lib/logmanager.cpp | 177 ----------------------------------------------------
lib/logmanager.h | 73 ----------------------
4 files changed, 3 insertions(+), 254 deletions(-)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 5706522..d640536 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -15,7 +15,6 @@ set(ktpchat_SRCS
chat-search-bar.cpp
notify-filter.cpp
text-chat-config.cpp
- logmanager.cpp
)
set(ktpchat_UI
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index cf8b509..b8b7295 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -25,7 +25,6 @@
#include "adium-theme-message-info.h"
#include "adium-theme-status-info.h"
#include "channel-contact-model.h"
-#include "logmanager.h"
#include "notify-filter.h"
#include "text-chat-config.h"
@@ -55,6 +54,7 @@
#include <KTp/presence.h>
#include <KTp/actions.h>
#include <KTp/message-processor.h>
+#include <KTp/Logger/scrollback-manager.h>
#include <sonnet/speller.h>
@@ -79,7 +79,7 @@ public:
Tp::AccountPtr account;
Ui::ChatWidget ui;
ChannelContactModel *contactModel;
- LogManager *logManager;
+ ScrollbackManager *logManager;
QTimer *pausedStateTimer;
bool logsLoaded;
uint exchangedMessagesCount;
@@ -104,7 +104,7 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, const Tp::AccountPtr
{
d->channel = channel;
d->account = account;
- d->logManager = new LogManager(this);
+ d->logManager = new ScrollbackManager(this);
connect(d->logManager, SIGNAL(fetched(QList<KTp::Message>)), SLOT(onHistoryFetched(QList<KTp::Message>)));
connect(d->account.data(), SIGNAL(currentPresenceChanged(Tp::Presence)),
diff --git a/lib/logmanager.cpp b/lib/logmanager.cpp
deleted file mode 100644
index 30b0141..0000000
--- a/lib/logmanager.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- 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
- 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 "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 <TelepathyQt/Types>
-#include <TelepathyQt/AvatarData>
-#include <TelepathyQt/TextChannel>
-#include <TelepathyQt/ReceivedMessage>
-
-class LogManager::Private
-{
- public:
- Private(): scrollbackLength(10)
- {
- }
-
- Tp::AccountPtr account;
- Tp::TextChannelPtr textChannel;
- KTp::LogEntity contactEntity;
- int scrollbackLength;
-};
-
-LogManager::LogManager(QObject *parent)
- : QObject(parent),
- d(new Private)
-{
-}
-
-LogManager::~LogManager()
-{
- delete d;
-}
-
-bool LogManager::exists() const
-{
- if (d->account.isNull() || d->textChannel.isNull() ) {
- return false;
- }
-
- 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)
-{
- d->scrollbackLength = n;
-}
-
-int LogManager::scrollbackLength() const
-{
- return d->scrollbackLength;
-}
-
-void LogManager::fetchScrollback()
-{
- fetchHistory(d->scrollbackLength);
-}
-
-void LogManager::fetchHistory(int n)
-{
- if (n > 0 && !d->account.isNull() && !d->textChannel.isNull()) {
- 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;
- }
- }
-
- //in all other cases finish immediately.
- QList<KTp::Message> messages;
- Q_EMIT fetched(messages);
-}
-
-void LogManager::onDatesFinished(KTp::PendingLoggerOperation* po)
-{
- 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;
- }
-
- const QList<QDate> dates = datesOp->dates();
- if (dates.isEmpty()) {
- Q_EMIT fetched(QList<KTp::Message>());
- return;
- }
-
- 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*)));
-}
-
-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;
- }
-
- QStringList queuedMessageTokens;
- if (!d->textChannel.isNull()) {
- Q_FOREACH(const Tp::ReceivedMessage &message, d->textChannel->messageQueue()) {
- queuedMessageTokens.append(message.messageToken());
- }
- }
- kDebug() << "queuedMessageTokens" << queuedMessageTokens;
-
- // get last n (d->fetchLast) messages that are not queued
- const QList<KTp::LogMessage> allMessages = logsOp->logs();
- QList<KTp::Message> messages;
- const KTp::MessageContext ctx(d->account, d->textChannel);
- for (int i = qMax(allMessages.count() - d->scrollbackLength, 0) ; i < allMessages.count(); ++i) {
- const KTp::LogMessage message = allMessages[i];
- if (queuedMessageTokens.contains(message.token())) {
- continue;
- }
-
- messages << KTp::MessageProcessor::instance()->processIncomingMessage(message, ctx);
- }
-
- kDebug() << "emit all messages" << messages.count();
- Q_EMIT fetched(messages);
-}
diff --git a/lib/logmanager.h b/lib/logmanager.h
deleted file mode 100644
index 4ff540c..0000000
--- a/lib/logmanager.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- 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
- 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
-*/
-
-
-#ifndef LOGMANAGER_H
-#define LOGMANAGER_H
-
-#include "adium-theme-content-info.h"
-
-#include <KTp/message.h>
-
-namespace KTp {
-class PendingLoggerOperation;
-}
-
-class LogManager : public QObject
-{
- Q_OBJECT
-
-public:
- explicit LogManager(QObject *parent = 0);
- virtual ~LogManager();
-
- bool exists() const;
-
- void setTextChannel(const Tp::AccountPtr &account, const Tp::TextChannelPtr &textChannel);
-
- /**
- * Sets amount of messages to be fetched via @p fetchScrollback()
- */
- void setScrollbackLength(int n);
-
- int scrollbackLength() const;
-
- /**
- * Fetches last N message,s as set via setFetchAmount()
- */
- void fetchScrollback();
-
- /**
- * Fetches last @p n messages
- */
- void fetchHistory(int n);
-
-Q_SIGNALS:
- void fetched(const QList<KTp::Message> &messages);
-
-private Q_SLOTS:
- void onDatesFinished(KTp::PendingLoggerOperation *po);
- void onEventsFinished(KTp::PendingLoggerOperation *po);
-
-private:
- class Private;
- Private * const d;
-};
-
-#endif // LOGMANAGER_H
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list