LeechCraft Azoth 0.6.70-14794-g33744ae6ce
Modular multiprotocol IM plugin for LeechCraft
Loading...
Searching...
No Matches
imessage.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <QString>
12#include <QDateTime>
13#include <QtPlugin>
14#include "messagebase.h"
15
16class QObject;
17
18namespace LC
19{
20namespace Azoth
21{
22 class ICLEntry;
23
42 class IMessage : public MessageBase
43 {
44 public:
45 virtual ~IMessage () {};
46
49 enum class Direction : uint8_t
50 {
53 In,
54
57 Out
58 };
59
62 enum class Type : uint8_t
63 {
67
76
83
92
96 };
97
105 enum class SubType : uint8_t
106 {
110 Other,
111
115
119
137
142
146
150
155
159
163 };
164
165 enum class EscapePolicy : uint8_t
166 {
167 Escape,
169 };
170
173 virtual QObject* GetQObject () = 0;
174
183 virtual void Send () = 0;
184
193 virtual void Store () = 0;
194
199 virtual Direction GetDirection () const = 0;
200
205 virtual Type GetMessageType () const = 0;
206
214 virtual SubType GetMessageSubType () const = 0;
215
230 virtual QObject* OtherPart () const = 0;
231
246 virtual QObject* ParentCLEntry () const
247 {
248 return OtherPart ();
249 }
250
257 virtual QString GetOtherVariant () const = 0;
258
266 virtual QString GetBody () const = 0;
267
274 virtual void SetBody (const QString& body) = 0;
275
286 {
288 }
289
301 QString GetEscapedBody () const
302 {
303 auto body = GetBody ();
304 switch (GetEscapePolicy ())
305 {
307 break;
309 body.replace ('&', "&amp;");
310 body.replace ('"', "&quot;");
311 body.replace ('<', "&lt;");
312 body.replace ('>', "&gt;");
313 break;
314 }
315 return body;
316 }
317
322 virtual QDateTime GetDateTime () const = 0;
323
328 virtual void SetDateTime (const QDateTime& timestamp) = 0;
329 };
330}
331}
332
333Q_DECLARE_INTERFACE (LC::Azoth::IMessage,
334 "org.LeechCraft.Azoth.IMessage/1.0")
This interface is used to represent a message.
Definition: imessage.h:43
virtual Direction GetDirection() const =0
Returns the direction of this message.
virtual EscapePolicy GetEscapePolicy() const
Returns the escape policy of the body.
Definition: imessage.h:285
virtual QDateTime GetDateTime() const =0
Returns the timestamp of the message.
Type
Represents possible message types.
Definition: imessage.h:63
@ StatusMessage
Status changes in a chat.
@ EventMessage
Various events in a chat.
@ ChatMessage
Standard one-to-one message.
@ MUCMessage
Message in a multiuser conference.
virtual Type GetMessageType() const =0
Returns the type of this message.
virtual QString GetBody() const =0
Returns the body of the message.
virtual ~IMessage()
Definition: imessage.h:45
virtual QString GetOtherVariant() const =0
The variant of the other part.
virtual void SetBody(const QString &body)=0
Updates the body of the message.
virtual void Store()=0
Stores the message.
virtual SubType GetMessageSubType() const =0
Returns the subtype of this message.
virtual void SetDateTime(const QDateTime &timestamp)=0
Updates the timestamp of the message.
virtual QObject * OtherPart() const =0
Returns the CL entry from which this message is.
SubType
This enum is used for more precise classification of chat types messages.
Definition: imessage.h:106
@ ParticipantLeave
Notifies about participant leaving a MUC room.
@ ParticipantNickChange
Notifies about participant in a MUC changing the nick.
@ ParticipantJoin
Notifies about participant joining to a MUC room.
@ RoomSubjectChange
Notifies about changing subject in a MUC room.
@ ParticipantRoleAffiliationChange
Represents permission changes of a participant in a chat or MUC room.
@ ParticipantStatusChange
Represents status change of a participant in a chat or MUC room.
@ ParticipantEndedConversation
The participant has ended the conversation.
Direction
Represents the direction of the message.
Definition: imessage.h:50
@ Out
The message is from us to the remote party.
@ In
The message is from the remote party to us.
QString GetEscapedBody() const
Returns the body according to the escape policy.
Definition: imessage.h:301
virtual QObject * ParentCLEntry() const
Returns the parent CL entry of this message.
Definition: imessage.h:246
virtual void Send()=0
Sends the message.
virtual QObject * GetQObject()=0
Returns this message as a QObject.