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_Client_message_h_HEADER_GUARD_
00022 #define _TelepathyQt4_Client_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 Message
00044 {
00045 public:
00046 
00047     Message(ChannelTextMessageType, const QString &);
00048     Message(const Message &other);
00049     ~Message();
00050 
00051     Message &operator=(const Message &other);
00052     bool operator==(const Message &other) const;
00053     inline bool operator!=(const Message &other) const
00054     {
00055         return !(*this == other);
00056     }
00057 
00058     // Convenient access to headers
00059 
00060     QDateTime sent() const;
00061 
00062     ChannelTextMessageType messageType() const;
00063 
00064     bool isTruncated() const;
00065 
00066     bool hasNonTextContent() const;
00067 
00068     QString messageToken() const;
00069 
00070     bool isSpecificToDBusInterface() const;
00071     QString dbusInterface() const;
00072 
00073     QString text() const;
00074 
00075     // Direct access to the whole message (header and body)
00076 
00077     MessagePart header() const;
00078 
00079     int size() const;
00080     MessagePart part(uint index) const;
00081     MessagePartList parts() const;
00082 
00083 private:
00084     friend class TextChannel;
00085     friend class ReceivedMessage;
00086 
00087     Message();
00088     Message(const MessagePartList &parts);
00089     Message(uint, uint, const QString &);
00090 
00091     class Private;
00092     QSharedDataPointer<Private> mPriv;
00093 };
00094 
00095 class 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     ReceivedMessage(const MessagePartList &parts,
00112             const TextChannelPtr &channel);
00113     ReceivedMessage();
00114     uint senderHandle() const;
00115     uint pendingId() const;
00116 
00117     void setForceNonText();
00118     void clearSenderHandle();
00119     void setSender(const ContactPtr &sender);
00120 };
00121 
00122 } // Tp
00123 
00124 #endif


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