[Telepathy-commits] [telepathy-qt4/master] Implement sending of complex messages (use at own risk) and inviting others

Simon McVittie simon.mcvittie at collabora.co.uk
Fri Feb 20 11:49:39 PST 2009


Untested, but should work...
---
 TelepathyQt4/Client/text-channel.cpp |   21 +++++++++++++++++++++
 TelepathyQt4/Client/text-channel.h   |    7 +------
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/TelepathyQt4/Client/text-channel.cpp b/TelepathyQt4/Client/text-channel.cpp
index 913054e..f617401 100644
--- a/TelepathyQt4/Client/text-channel.cpp
+++ b/TelepathyQt4/Client/text-channel.cpp
@@ -480,6 +480,27 @@ PendingSendMessage *TextChannel::send(const QString &text,
     return op;
 }
 
+PendingSendMessage *TextChannel::send(const MessagePartList &parts)
+{
+    Message m(parts);
+    PendingSendMessage *op = new PendingSendMessage(m, this);
+
+    if (hasMessagesInterface()) {
+        connect(new QDBusPendingCallWatcher(
+                    messagesInterface()->SendMessage(m.parts(), 0)),
+                SIGNAL(finished(QDBusPendingCallWatcher *)),
+                op,
+                SLOT(onMessageSent(QDBusPendingCallWatcher *)));
+    } else {
+        connect(new QDBusPendingCallWatcher(textInterface()->Send(
+                        m.messageType(), m.text())),
+                SIGNAL(finished(QDBusPendingCallWatcher *)),
+                op,
+                SLOT(onTextSent(QDBusPendingCallWatcher *)));
+    }
+    return op;
+}
+
 /**
  * Return whether the desired features are ready for use.
  *
diff --git a/TelepathyQt4/Client/text-channel.h b/TelepathyQt4/Client/text-channel.h
index e836b48..c66de61 100644
--- a/TelepathyQt4/Client/text-channel.h
+++ b/TelepathyQt4/Client/text-channel.h
@@ -109,11 +109,7 @@ public Q_SLOTS:
     PendingSendMessage *send(const QString &text,
             ChannelTextMessageType type = ChannelTextMessageTypeNormal);
 
-#if 0
-    // For advanced users.
-    //
-    // Returns a sent-message token (as in messageSent), or "".
-    QString send(QList<QVariantMap> message);
+    PendingSendMessage *send(const MessagePartList &parts);
 
     inline PendingOperation *inviteContacts(
             const QList<QSharedPointer<Contact> > &contacts,
@@ -121,7 +117,6 @@ public Q_SLOTS:
     {
         return groupAddContacts(contacts, message);
     }
-#endif
 
 Q_SIGNALS:
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list