Home · All Classes · All Namespaces · Modules · Functions · Files

text-channel.h

00001 /* Text channel client-side proxy
00002  *
00003  * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
00004  * Copyright (C) 2009 Nokia Corporation
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #ifndef _TelepathyQt4_text_channel_h_HEADER_GUARD_
00022 #define _TelepathyQt4_text_channel_h_HEADER_GUARD_
00023 
00024 #ifndef IN_TELEPATHY_QT4_HEADER
00025 #error IN_TELEPATHY_QT4_HEADER
00026 #endif
00027 
00028 #include <TelepathyQt4/Channel>
00029 #include <TelepathyQt4/PendingOperation>
00030 
00031 namespace Tp
00032 {
00033 
00034 class PendingReadyChannel;
00035 class Message;
00036 class ReceivedMessage;
00037 class TextChannel;
00038 
00039 class PendingSendMessage : public PendingOperation
00040 {
00041     Q_OBJECT
00042     Q_DISABLE_COPY(PendingSendMessage)
00043 
00044 public:
00045     PendingSendMessage(const Message &message, QObject *parent = 0);
00046     ~PendingSendMessage();
00047 
00048     QString sentMessageToken() const;
00049     Message message() const;
00050 
00051 private Q_SLOTS:
00052     void onTextSent(QDBusPendingCallWatcher *);
00053     void onMessageSent(QDBusPendingCallWatcher *);
00054 
00055 private:
00056     friend class TextChannel;
00057 
00058     struct Private;
00059     friend struct Private;
00060     Private *mPriv;
00061 };
00062 
00063 class TextChannel : public Channel
00064 {
00065     Q_OBJECT
00066     Q_DISABLE_COPY(TextChannel)
00067 
00068 public:
00069     static const Feature FeatureMessageQueue;
00070     static const Feature FeatureMessageCapabilities;
00071     static const Feature FeatureMessageSentSignal;
00072 
00073     static TextChannelPtr create(const ConnectionPtr &connection,
00074             const QString &objectPath, const QVariantMap &immutableProperties);
00075 
00076     virtual ~TextChannel();
00077 
00078     bool hasMessagesInterface() const;
00079     bool canInviteContacts() const;
00080 
00081     // requires FeatureMessageCapabilities
00082     QStringList supportedContentTypes() const;
00083     MessagePartSupportFlags messagePartSupport() const;
00084     DeliveryReportingSupportFlags deliveryReportingSupport() const;
00085 
00086     // requires FeatureMessageQueue
00087     QList<ReceivedMessage> messageQueue() const;
00088 
00089 public Q_SLOTS:
00090     void acknowledge(const QList<ReceivedMessage> &messages);
00091 
00092     void forget(const QList<ReceivedMessage> &messages);
00093 
00094     PendingSendMessage *send(const QString &text,
00095             ChannelTextMessageType type = ChannelTextMessageTypeNormal);
00096 
00097     PendingSendMessage *send(const MessagePartList &parts);
00098 
00099     inline PendingOperation *inviteContacts(
00100             const QList<ContactPtr> &contacts,
00101             const QString &message = QString())
00102     {
00103         return groupAddContacts(contacts, message);
00104     }
00105 
00106 Q_SIGNALS:
00107     // FeatureMessageSentSignal
00108     void messageSent(const Tp::Message &message,
00109             Tp::MessageSendingFlags flags,
00110             const QString &sentMessageToken);
00111 
00112     // FeatureMessageQueue
00113     void messageReceived(const Tp::ReceivedMessage &message);
00114     void pendingMessageRemoved(
00115             const Tp::ReceivedMessage &message);
00116 
00117 protected:
00118     TextChannel(const ConnectionPtr &connection, const QString &objectPath,
00119             const QVariantMap &immutableProperties);
00120 
00121 private Q_SLOTS:
00122     void onContactsFinished(Tp::PendingOperation *);
00123     void onAcknowledgePendingMessagesReply(QDBusPendingCallWatcher *);
00124 
00125     void onMessageSent(const Tp::MessagePartList &, uint,
00126             const QString &);
00127     void onMessageReceived(const Tp::MessagePartList &);
00128     void onPendingMessagesRemoved(const Tp::UIntList &);
00129 
00130     void onTextSent(uint, uint, const QString &);
00131     void onTextReceived(uint, uint, uint, uint, uint, const QString &);
00132     void onTextSendError(uint, uint, uint, const QString &);
00133 
00134     void gotProperties(QDBusPendingCallWatcher *);
00135     void gotPendingMessages(QDBusPendingCallWatcher *);
00136 
00137 private:
00138     void processQueue();
00139 
00140     struct Private;
00141     friend struct Private;
00142     Private *mPriv;
00143 };
00144 
00145 } // Tp
00146 
00147 #endif


Copyright © 2009 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.1.10