File indexing completed on 2024-06-23 04:03:41

0001 /*
0002  * Copyright (C) 2003  Justin Karneges
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * either version 2
0008    of the License, or (at your option) any later version.1 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Lesser General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Lesser General Public
0016  * License along with this library; if not, write to the Free Software
0017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0018  *
0019  */
0020 
0021 #ifndef XMPP_MESSAGE_H
0022 #define XMPP_MESSAGE_H
0023 
0024 #include "iris_export.h"
0025 #include "xmpp_stanza.h"
0026 #include "xmpp_url.h"
0027 #include "xmpp_chatstate.h"
0028 #include "xmpp_receipts.h"
0029 #include "xmpp_address.h"
0030 #include "xmpp_rosterx.h"
0031 #include "xmpp_muc.h"
0032 
0033 class QString;
0034 class QDateTime;
0035 
0036 namespace XMPP {
0037     class Jid;
0038     class PubSubItem;
0039     class PubSubRetraction;
0040     class HTMLElement;
0041     class HttpAuthRequest;
0042     class XData;
0043 
0044     typedef enum { OfflineEvent, DeliveredEvent, DisplayedEvent,
0045             ComposingEvent, CancelEvent } MsgEvent;
0046 
0047   class IRIS_EXPORT Message
0048     {
0049     public:
0050         Message(const Jid &to="");
0051         Message(const Message &from);
0052         Message & operator=(const Message &from);
0053         ~Message();
0054 
0055         Jid to() const;
0056         Jid from() const;
0057         QString id() const;
0058         QString type() const;
0059         QString lang() const;
0060         QString subject(const QString &lang="") const;
0061         QString body(const QString &lang="") const;
0062         QString xHTMLBody(const QString &lang="") const;
0063         QString thread() const;
0064         Stanza::Error error() const;
0065 
0066         void setTo(const Jid &j);
0067         void setFrom(const Jid &j);
0068         void setId(const QString &s);
0069         void setType(const QString &s);
0070         void setLang(const QString &s);
0071         void setSubject(const QString &s, const QString &lang="");
0072         void setBody(const QString &s, const QString &lang="");
0073         void setXHTMLBody(const QString &s, const QString &lang="", const QString &attr="");
0074         void setThread(const QString &s, bool send = false);
0075         void setError(const Stanza::Error &err);
0076 
0077         // JEP-0060
0078         const QString& pubsubNode() const;
0079         const QList<PubSubItem>& pubsubItems() const;
0080         const QList<PubSubRetraction>& pubsubRetractions() const;
0081 
0082         // JEP-0091
0083         QDateTime timeStamp() const;
0084         void setTimeStamp(const QDateTime &ts, bool send = false);
0085 
0086         // JEP-0071
0087         HTMLElement html(const QString &lang="") const;
0088         void setHTML(const HTMLElement &s, const QString &lang="");
0089         bool containsHTML() const;
0090 
0091         // JEP-0066
0092         UrlList urlList() const;
0093         void urlAdd(const Url &u);
0094         void urlsClear();
0095         void setUrlList(const UrlList &list);
0096 
0097         // JEP-0022
0098         QString eventId() const;
0099         void setEventId(const QString& id);
0100         bool containsEvents() const;
0101         bool containsEvent(MsgEvent e) const;
0102         void addEvent(MsgEvent e);
0103 
0104         // JEP-0085
0105         ChatState chatState() const;
0106         void setChatState(ChatState);
0107  
0108         // XEP-0184
0109         MessageReceipt messageReceipt() const;
0110         void setMessageReceipt(MessageReceipt);
0111 
0112         // JEP-0027
0113         QString xencrypted() const;
0114         void setXEncrypted(const QString &s);
0115         
0116         // JEP-0033
0117         AddressList addresses() const;
0118         AddressList findAddresses(Address::Type t) const;
0119         void addAddress(const Address &a);
0120         void clearAddresses();
0121         void setAddresses(const AddressList &list);
0122 
0123         // JEP-144
0124         const RosterExchangeItems& rosterExchangeItems() const;
0125         void setRosterExchangeItems(const RosterExchangeItems&);
0126 
0127         // JEP-172
0128         void setNick(const QString&);
0129         const QString& nick() const;
0130 
0131         // JEP-0070
0132         void setHttpAuthRequest(const HttpAuthRequest&);
0133         HttpAuthRequest httpAuthRequest() const;
0134 
0135         // JEP-0004
0136         void setForm(const XData&);
0137         const XData& getForm() const;
0138 
0139         // JEP-xxxx SXE
0140         void setSxe(const QDomElement&);
0141         const QDomElement& sxe() const;
0142 
0143         // MUC
0144         void addMUCStatus(int);
0145         const QList<int>& getMUCStatuses() const;
0146         void addMUCInvite(const MUCInvite&);
0147         const QList<MUCInvite>& mucInvites() const;
0148         void setMUCDecline(const MUCDecline&);
0149         const MUCDecline& mucDecline() const;
0150         const QString& mucPassword() const;
0151         void setMUCPassword(const QString&);
0152 
0153         // Obsolete invitation
0154         QString invite() const;
0155         void setInvite(const QString &s);
0156 
0157         // for compatibility.  delete me later
0158         bool spooled() const;
0159         void setSpooled(bool);
0160         bool wasEncrypted() const;
0161         void setWasEncrypted(bool);
0162 
0163         Stanza toStanza(Stream *stream) const;
0164         bool fromStanza(const Stanza &s, int tzoffset);
0165 
0166     private:
0167         class Private;
0168         Private *d;
0169     };
0170 }
0171 
0172 #endif