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 TELEPATHY_QT4_EXPORT 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 TELEPATHY_QT4_EXPORT 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     static const Feature FeatureChatState;
00073 
00074     static TextChannelPtr create(const ConnectionPtr &connection,
00075             const QString &objectPath, const QVariantMap &immutableProperties);
00076 
00077     virtual ~TextChannel();
00078 
00079     bool hasMessagesInterface() const;
00080     bool hasChatStateInterface() const;
00081     bool canInviteContacts() const;
00082 
00083     // requires FeatureMessageCapabilities
00084     QStringList supportedContentTypes() const;
00085     MessagePartSupportFlags messagePartSupport() const;
00086     DeliveryReportingSupportFlags deliveryReportingSupport() const;
00087 
00088     // requires FeatureMessageQueue
00089     QList<ReceivedMessage> messageQueue() const;
00090 
00091     // requires FeatureChatState
00092     ChannelChatState chatState(const ContactPtr &contact) const;
00093 
00094 public Q_SLOTS:
00095     void acknowledge(const QList<ReceivedMessage> &messages);
00096 
00097     void forget(const QList<ReceivedMessage> &messages);
00098 
00099     PendingSendMessage *send(const QString &text,
00100             ChannelTextMessageType type = ChannelTextMessageTypeNormal,
00101             MessageSendingFlags flags = 0);
00102 
00103     PendingSendMessage *send(const MessagePartList &parts,
00104             MessageSendingFlags flags = 0);
00105 
00106     inline PendingOperation *inviteContacts(
00107             const QList<ContactPtr> &contacts,
00108             const QString &message = QString())
00109     {
00110         return groupAddContacts(contacts, message);
00111     }
00112 
00113     PendingOperation *requestChatState(ChannelChatState state);
00114 
00115 Q_SIGNALS:
00116     // FeatureMessageSentSignal
00117     void messageSent(const Tp::Message &message,
00118             Tp::MessageSendingFlags flags,
00119             const QString &sentMessageToken);
00120 
00121     // FeatureMessageQueue
00122     void messageReceived(const Tp::ReceivedMessage &message);
00123     void pendingMessageRemoved(
00124             const Tp::ReceivedMessage &message);
00125 
00126     // FeatureChatState
00127     // FIXME: (API/ABI break) Use full-qualified namespace for state param.
00128     void chatStateChanged(const Tp::ContactPtr &contact,
00129             ChannelChatState state);
00130 
00131 protected:
00132     TextChannel(const ConnectionPtr &connection, const QString &objectPath,
00133             const QVariantMap &immutableProperties);
00134 
00135 private Q_SLOTS:
00136     void onContactsFinished(Tp::PendingOperation *);
00137     void onAcknowledgePendingMessagesReply(QDBusPendingCallWatcher *);
00138 
00139     void onMessageSent(const Tp::MessagePartList &, uint,
00140             const QString &);
00141     void onMessageReceived(const Tp::MessagePartList &);
00142     void onPendingMessagesRemoved(const Tp::UIntList &);
00143 
00144     void onTextSent(uint, uint, const QString &);
00145     void onTextReceived(uint, uint, uint, uint, uint, const QString &);
00146     void onTextSendError(uint, uint, uint, const QString &);
00147 
00148     void gotProperties(QDBusPendingCallWatcher *);
00149     void gotPendingMessages(QDBusPendingCallWatcher *);
00150 
00151     void onChatStateChanged(uint, uint);
00152 
00153 private:
00154     struct Private;
00155     friend struct Private;
00156     Private *mPriv;
00157 };
00158 
00159 } // Tp
00160 
00161 #endif


Copyright © 2008-2010 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.4.4