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


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