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

message.h

00001 /* Message object used by 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_message_h_HEADER_GUARD_
00022 #define _TelepathyQt4_message_h_HEADER_GUARD_
00023 
00024 #ifndef IN_TELEPATHY_QT4_HEADER
00025 #error IN_TELEPATHY_QT4_HEADER
00026 #endif
00027 
00028 #include <QSharedDataPointer>
00029 
00030 #include <TelepathyQt4/Contact>
00031 #include <TelepathyQt4/Types>
00032 #include <TelepathyQt4/Constants>
00033 #include <TelepathyQt4/Types>
00034 
00035 class QDateTime;
00036 
00037 namespace Tp
00038 {
00039 
00040 class Contact;
00041 class TextChannel;
00042 
00043 class TELEPATHY_QT4_EXPORT Message
00044 {
00045 public:
00046     Message(ChannelTextMessageType, const QString &);
00047     Message(const Message &other);
00048     ~Message();
00049 
00050     Message &operator=(const Message &other);
00051     bool operator==(const Message &other) const;
00052     inline bool operator!=(const Message &other) const
00053     {
00054         return !(*this == other);
00055     }
00056 
00057     // Convenient access to headers
00058 
00059     QDateTime sent() const;
00060 
00061     ChannelTextMessageType messageType() const;
00062 
00063     bool isTruncated() const;
00064 
00065     bool hasNonTextContent() const;
00066 
00067     QString messageToken() const;
00068 
00069     bool isSpecificToDBusInterface() const;
00070     QString dbusInterface() const;
00071 
00072     QString text() const;
00073 
00074     // Direct access to the whole message (header and body)
00075 
00076     MessagePart header() const;
00077 
00078     int size() const;
00079     MessagePart part(uint index) const;
00080     MessagePartList parts() const;
00081 
00082 private:
00083     friend class TextChannel;
00084     friend class ReceivedMessage;
00085 
00086     Message();
00087     Message(const MessagePartList &parts);
00088     Message(uint, uint, const QString &);
00089 
00090     struct Private;
00091     friend struct Private;
00092     QSharedDataPointer<Private> mPriv;
00093 };
00094 
00095 class TELEPATHY_QT4_EXPORT ReceivedMessage : public Message
00096 {
00097 public:
00098     ReceivedMessage(const ReceivedMessage &other);
00099     ReceivedMessage &operator=(const ReceivedMessage &other);
00100     ~ReceivedMessage();
00101 
00102     QDateTime received() const;
00103     ContactPtr sender() const;
00104     bool isScrollback() const;
00105     bool isRescued() const;
00106 
00107     bool isFromChannel(const TextChannelPtr &channel) const;
00108 
00109 private:
00110     friend class TextChannel;
00111 
00112     ReceivedMessage(const MessagePartList &parts,
00113             const TextChannelPtr &channel);
00114     ReceivedMessage();
00115 
00116     uint senderHandle() const;
00117     uint pendingId() const;
00118 
00119     void setForceNonText();
00120     void clearSenderHandle();
00121     void setSender(const ContactPtr &sender);
00122 };
00123 
00124 } // Tp
00125 
00126 #endif


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