[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:20:44 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=ec32f25
The following commit has been merged in the master branch:
commit ec32f257314382062de5890595a6ad7607020bc1
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Sun Jan 29 17:06:36 2012 +0000
Tidy up the log loader, and fix all associated crashes
REVIEW: 103824
BUG:292274
CCBUG:292716
---
lib/chat-widget.cpp | 9 +++------
lib/logmanager.cpp | 38 +++++++++++++++++++++-----------------
lib/logmanager.h | 5 ++---
3 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index 872de02..5494b7a 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -86,6 +86,8 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, const Tp::AccountPtr
{
d->channel = channel;
d->account = account;
+ d->logManager = new LogManager(this);
+
//load translations for this library. keep this before any i18n() calls in library code
KGlobal::locale()->insertCatalog(QLatin1String("ktpchat"));
@@ -188,16 +190,14 @@ ChatWidget::ChatWidget(const Tp::TextChannelPtr & channel, const Tp::AccountPtr
// initialize LogManager
if (!d->isGroupChat) {
- d->logManager = new LogManager(account, channel->targetContact(), this);
d->logManager->setFetchAmount(3);
- d->logManager->setTextChannel(channel);
+ d->logManager->setTextChannel(d->account, d->channel);
}
}
ChatWidget::~ChatWidget()
{
d->channel->requestClose(); // ensure closing; does nothing, if already closed
- delete d->logManager;
delete d;
}
@@ -407,9 +407,6 @@ void ChatWidget::onHistoryFetched(const QList<AdiumThemeContentInfo> &messages)
Q_FOREACH(const Tp::ReceivedMessage &message, d->channel->messageQueue()) {
handleIncomingMessage(message);
}
-
- delete d->logManager;
- d->logManager = 0;
}
int ChatWidget::unreadMessageCount() const
diff --git a/lib/logmanager.cpp b/lib/logmanager.cpp
index 61484af..ee89809 100644
--- a/lib/logmanager.cpp
+++ b/lib/logmanager.cpp
@@ -43,13 +43,10 @@
#include <TelepathyQt/TextChannel>
#include <TelepathyQt/ReceivedMessage>
-LogManager::LogManager(const Tp::AccountPtr &account, const Tp::ContactPtr &contact, QObject *parent)
+LogManager::LogManager(QObject *parent)
: QObject(parent),
- m_account(account),
- m_contact(contact),
m_fetchAmount(10)
{
-
#ifdef TELEPATHY_LOGGER_QT4_FOUND
g_type_init();
QGlib::init();
@@ -61,10 +58,6 @@ LogManager::LogManager(const Tp::AccountPtr &account, const Tp::ContactPtr &cont
Q_ASSERT(false);
}
- m_contactEntity = Tpl::Entity::create(m_contact->id().toLatin1().data(),
- Tpl::EntityTypeContact,
- NULL,
- NULL);
#else
kWarning() << "text-ui was built without log support";
#endif
@@ -84,9 +77,10 @@ bool LogManager::exists() const
#endif
}
-void LogManager::setTextChannel(const Tp::TextChannelPtr& textChannel)
+void LogManager::setTextChannel(const Tp::AccountPtr &account, const Tp::TextChannelPtr &textChannel)
{
m_textChannel = textChannel;
+ m_account = account;
}
void LogManager::setFetchAmount(int n)
@@ -98,8 +92,17 @@ void LogManager::fetchLast()
{
kDebug();
#ifdef TELEPATHY_LOGGER_QT4_FOUND
- Tpl::PendingDates* dates = m_logManager->queryDates( m_account, m_contactEntity, Tpl::EventTypeMaskText);
- connect(dates, SIGNAL(finished(Tpl::PendingOperation*)), SLOT(onDatesFinished(Tpl::PendingOperation*)));
+ if (!m_account.isNull() && !m_textChannel.isNull() && m_textChannel->targetHandleType() == Tp::HandleTypeContact) {
+ Tpl::EntityPtr contactEntity = Tpl::Entity::create(m_textChannel->targetContact()->id().toLatin1().data(),
+ Tpl::EntityTypeContact,
+ NULL,
+ NULL);
+
+ Tpl::PendingDates* dates = m_logManager->queryDates( m_account, contactEntity, Tpl::EventTypeMaskText);
+ connect(dates, SIGNAL(finished(Tpl::PendingOperation*)), SLOT(onDatesFinished(Tpl::PendingOperation*)));
+ return;
+ }
+ //in all other cases finish immediately.
#else
QList<AdiumThemeContentInfo> messages;
Q_EMIT fetched(messages);
@@ -143,8 +146,7 @@ void LogManager::onEventsFinished(Tpl::PendingOperation* po)
QStringList queuedMessageTokens;
if(!m_textChannel.isNull()) {
- Q_FOREACH(const Tp::ReceivedMessage &message, m_textChannel->messageQueue())
- {
+ Q_FOREACH(const Tp::ReceivedMessage &message, m_textChannel->messageQueue()) {
queuedMessageTokens.append(message.messageToken());
}
}
@@ -169,15 +171,17 @@ void LogManager::onEventsFinished(Tpl::PendingOperation* po)
Q_FOREACH(const Tpl::TextEventPtr& event, events) {
AdiumThemeMessageInfo::MessageType type;
QString iconPath;
- Tp::ContactPtr targetContact;
+ Tp::ContactPtr contact;
if(event->sender()->identifier() == m_account->normalizedName()) {
type = AdiumThemeMessageInfo::HistoryLocalToRemote;
- targetContact = m_account->connection()->selfContact();
+ if (m_account->connection()) {
+ contact = m_account->connection()->selfContact();
+ }
} else {
type = AdiumThemeMessageInfo::HistoryRemoteToLocal;
- targetContact = m_contact;
+ contact = m_textChannel->targetContact();
}
- iconPath = targetContact->avatarData().fileName;
+ iconPath = contact->avatarData().fileName;
AdiumThemeContentInfo message(type);
message.setMessage(event->message());
diff --git a/lib/logmanager.h b/lib/logmanager.h
index 4e11086..5d44f6c 100644
--- a/lib/logmanager.h
+++ b/lib/logmanager.h
@@ -42,12 +42,12 @@ class LogManager : public QObject
Q_OBJECT
public:
- explicit LogManager(const Tp::AccountPtr &account, const Tp::ContactPtr &contact, QObject *parent = 0);
+ explicit LogManager(QObject *parent = 0);
virtual ~LogManager();
bool exists() const;
- void setTextChannel(const Tp::TextChannelPtr &textChannel);
+ void setTextChannel(const Tp::AccountPtr &account, const Tp::TextChannelPtr &textChannel);
void setFetchAmount(int n);
void fetchLast();
@@ -62,7 +62,6 @@ private Q_SLOTS:
private:
Tp::AccountPtr m_account;
- Tp::ContactPtr m_contact;
Tp::TextChannelPtr m_textChannel;
#ifdef TELEPATHY_LOGGER_QT4_FOUND
Tpl::EntityPtr m_contactEntity;
--
ktp-text-ui packaging
More information about the pkg-kde-commits
mailing list