[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:22 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=f09156c
The following commit has been merged in the master branch:
commit f09156c0cc8ae0d00c9bc5228c6ec1a2b828f54e
Author: Marcin Ziemiński <zieminn at gmail.com>
Date: Sun Aug 3 01:37:25 2014 +0200
Added necessary headers to message in MessageSent signal. The proxy quits when no channels are being handled.
Signed-off-by: Marcin Ziemiński <zieminn at gmail.com>
---
otr-proxy/KTpProxy/otr-message.cpp | 60 ++++++++++++++++++++++++
otr-proxy/KTpProxy/otr-message.h | 12 +++++
otr-proxy/KTpProxy/otr-proxy-channel-adaptee.cpp | 18 ++++++-
otr-proxy/KTpProxy/otr-proxy-channel-adaptee.h | 1 +
otr-proxy/KTpProxy/proxy-service.cpp | 5 ++
5 files changed, 95 insertions(+), 1 deletion(-)
diff --git a/otr-proxy/KTpProxy/otr-message.cpp b/otr-proxy/KTpProxy/otr-message.cpp
index 306e870..ca5f980 100644
--- a/otr-proxy/KTpProxy/otr-message.cpp
+++ b/otr-proxy/KTpProxy/otr-message.cpp
@@ -118,4 +118,64 @@ namespace OTR
}
}
+ void Message::setTimestamp(qint64 timestamp)
+ {
+ message[0].insert(QLatin1String("message-sent"), QDBusVariant(timestamp));
+ }
+
+ qint64 Message::getTimestamp() const
+ {
+ auto it = message[0].find(QLatin1String("message-sent"));
+ if(it == message[0].end()) {
+ return 0;
+ } else {
+ return it->variant().toLongLong(NULL);
+ }
+ }
+
+ void Message::setSenderId(const QString &senderId)
+ {
+ message[0].insert(QLatin1String("message-sender-id"), QDBusVariant(senderId));
+ }
+
+ QString Message::getSenderId() const
+ {
+ auto it = message[0].find(QLatin1String("message-sender-id"));
+ if(it == message[0].end()) {
+ return QLatin1String("");
+ } else {
+ return it->variant().toString();
+ }
+ }
+
+ void Message::setSender(uint sender)
+ {
+ message[0].insert(QLatin1String("message-sender"), QDBusVariant(sender));
+ }
+
+ uint Message::getSender() const
+ {
+ auto it = message[0].find(QLatin1String("message-sender"));
+ if(it == message[0].end()) {
+ return 0;
+ } else {
+ return it->variant().toUInt(NULL);
+ }
+ }
+
+ void Message::setToken(const QString &token)
+ {
+ message[0].insert(QLatin1String("message-token"), QDBusVariant(token));
+ }
+
+ QString Message::getToken() const
+ {
+ auto it = message[0].find(QLatin1String("message-sender"));
+ if(it == message[0].end()) {
+ return QLatin1String("");
+ } else {
+ return it->variant().toString();
+ }
+ }
+
} /* namespace OTR */
diff --git a/otr-proxy/KTpProxy/otr-message.h b/otr-proxy/KTpProxy/otr-message.h
index 82ebcc2..ae363d4 100644
--- a/otr-proxy/KTpProxy/otr-message.h
+++ b/otr-proxy/KTpProxy/otr-message.h
@@ -61,6 +61,18 @@ namespace OTR
void setOTRheader(const QString &header, const QString &text);
QString getOTRheader(const QString &header);
+ void setTimestamp(qint64 timestamp);
+ qint64 getTimestamp() const;
+
+ void setSenderId(const QString &senderId);
+ QString getSenderId() const;
+
+ void setSender(uint sender);
+ uint getSender() const;
+
+ void setToken(const QString &token);
+ QString getToken() const;
+
private:
MessageDirection dir;
Tp::MessagePartList message;
diff --git a/otr-proxy/KTpProxy/otr-proxy-channel-adaptee.cpp b/otr-proxy/KTpProxy/otr-proxy-channel-adaptee.cpp
index 3cb685e..db1eb39 100644
--- a/otr-proxy/KTpProxy/otr-proxy-channel-adaptee.cpp
+++ b/otr-proxy/KTpProxy/otr-proxy-channel-adaptee.cpp
@@ -22,11 +22,15 @@
#include "proxy-service.h"
#include "otr-constants.h"
#include "otr-manager.h"
+#include "otr-utils.h"
#include "constants.h"
#include "pending-curry-operation.h"
#include <TelepathyQt/DBusObject>
#include <TelepathyQt/TextChannel>
+#include <TelepathyQt/Contact>
+
+#include <QDateTime>
#include <KDebug>
@@ -105,6 +109,8 @@ OtrProxyChannel::Adaptee::Adaptee(OtrProxyChannel *pc,
connect(chan.data(), SIGNAL(invalidated(Tp::DBusProxy*,const QString&,const QString&)), SIGNAL(closed()));
connect(&otrSes, SIGNAL(trustLevelChanged(TrustLevel)), SLOT(onTrustLevelChanged(TrustLevel)));
connect(&otrSes, SIGNAL(sessionRefreshed()), SIGNAL(sessionRefreshed()));
+
+ sender = channel->connection()->selfHandle();
}
QDBusObjectPath OtrProxyChannel::Adaptee::wrappedChannel() const
@@ -374,7 +380,17 @@ void OtrProxyChannel::Adaptee::onPendingSendFinished(Tp::PendingOperation *op)
ctx->setFinishedWithError(sendResult->errorName(), sendResult->errorMessage());
} else {
ctx->setFinished(sendResult->getToken());
- Q_EMIT messageSent(sendResult->getMessage(), sendResult->getFlags(), sendResult->getToken());
+
+ OTR::Message message = sendResult->getMessage();
+ message.setToken(sendResult->getToken());
+ message.setTimestamp(QDateTime::currentDateTime().toTime_t());
+ message.setSender(sender);
+ message.setSenderId(otrSes.context().accountName);
+ if(!otrSes.remoteFingerprint().isEmpty()) {
+ message.setOTRheader(QLatin1String("otr-remote-fingerprint"), otrSes.remoteFingerprint());
+ }
+
+ Q_EMIT messageSent(message.parts(), sendResult->getFlags(), sendResult->getToken());
}
}
}
diff --git a/otr-proxy/KTpProxy/otr-proxy-channel-adaptee.h b/otr-proxy/KTpProxy/otr-proxy-channel-adaptee.h
index c810dc6..908edf7 100644
--- a/otr-proxy/KTpProxy/otr-proxy-channel-adaptee.h
+++ b/otr-proxy/KTpProxy/otr-proxy-channel-adaptee.h
@@ -100,6 +100,7 @@ class OtrProxyChannel::Adaptee : public QObject
bool isConnected;
OTR::ProxySession otrSes;
ProxyService *ps;
+ uint sender;
QMap<uint, Tp::ReceivedMessage> messages; // queue
QList<Tp::ReceivedMessage> enqueuedMessages; // when there is now private key generated
diff --git a/otr-proxy/KTpProxy/proxy-service.cpp b/otr-proxy/KTpProxy/proxy-service.cpp
index d5c60b4..ca8ab86 100644
--- a/otr-proxy/KTpProxy/proxy-service.cpp
+++ b/otr-proxy/KTpProxy/proxy-service.cpp
@@ -130,6 +130,11 @@ void ProxyService::onChannelProxyClosed()
<< " for the channel: " << proxyChannel->wrappedChannel()->objectPath();
channels.remove(proxyChannel);
+
+ // stop the application when not needed anymore
+ if(channels.isEmpty()) {
+ KApplication::kApplication()->quit();
+ }
}
void ProxyService::onChannelReady(Tp::PendingOperation *pendingChanReady)
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list