LeechCraft Azoth  0.6.70-3565-g2d86529
Modular multiprotocol IM plugin for LeechCraft
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
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  * Boost Software License - Version 1.0 - August 17th, 2003
6  *
7  * Permission is hereby granted, free of charge, to any person or organization
8  * obtaining a copy of the software and accompanying documentation covered by
9  * this license (the "Software") to use, reproduce, display, distribute,
10  * execute, and transmit the Software, and to prepare derivative works of the
11  * Software, and to permit third-parties to whom the Software is furnished to
12  * do so, all subject to the following:
13  *
14  * The copyright notices in the Software and this entire statement, including
15  * the above license grant, this restriction and the following disclaimer,
16  * must be included in all copies of the Software, in whole or in part, and
17  * all derivative works of the Software, unless such copies or derivative
18  * works are solely in the form of machine-executable object code generated by
19  * a source language processor.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
24  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
25  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  **********************************************************************/
29 
30 #pragma once
31 
32 #include <QString>
33 #include <QDateTime>
34 #include <QtPlugin>
35 #include "messagebase.h"
36 
37 class QObject;
38 
39 namespace LeechCraft
40 {
41 namespace Azoth
42 {
43  class ICLEntry;
44 
63  class IMessage : public MessageBase
64  {
65  public:
66  virtual ~IMessage () {};
67 
70  enum class Direction
71  {
74  In,
75 
78  Out
79  };
80 
83  enum class Type
84  {
88 
96  MUCMessage,
97 
104 
112  EventMessage,
113 
117  };
118 
126  enum class SubType
127  {
131  Other,
132 
136 
140 
158 
163 
167 
171 
176 
180 
184  };
185 
186  enum class EscapePolicy
187  {
188  Escape,
189  NoEscape
190  };
191 
194  virtual QObject* GetQObject () = 0;
195 
204  virtual void Send () = 0;
205 
214  virtual void Store () = 0;
215 
220  virtual Direction GetDirection () const = 0;
221 
226  virtual Type GetMessageType () const = 0;
227 
235  virtual SubType GetMessageSubType () const = 0;
236 
251  virtual QObject* OtherPart () const = 0;
252 
267  virtual QObject* ParentCLEntry () const
268  {
269  return OtherPart ();
270  }
271 
278  virtual QString GetOtherVariant () const = 0;
279 
287  virtual QString GetBody () const = 0;
288 
295  virtual void SetBody (const QString& body) = 0;
296 
306  virtual EscapePolicy GetEscapePolicy () const
307  {
308  return EscapePolicy::Escape;
309  }
310 
322  QString GetEscapedBody () const
323  {
324  auto body = GetBody ();
325  switch (GetEscapePolicy ())
326  {
328  break;
330  body.replace ('&', "&amp;");
331  body.replace ('"', "&quot;");
332  body.replace ('<', "&lt;");
333  body.replace ('>', "&gt;");
334  break;
335  }
336  return body;
337  }
338 
343  virtual QDateTime GetDateTime () const = 0;
344 
349  virtual void SetDateTime (const QDateTime& timestamp) = 0;
350  };
351 }
352 }
353 
355  "org.LeechCraft.Azoth.IMessage/1.0");
Notifies about participant joining to a MUC room.
virtual SubType GetMessageSubType() const =0
Returns the subtype of this message.
virtual void SetDateTime(const QDateTime &timestamp)=0
Updates the timestamp of the message.
Represents status change of a participant in a chat or MUC room.
Q_DECLARE_INTERFACE(LeechCraft::Azoth::IMessage,"org.LeechCraft.Azoth.IMessage/1.0")
The message is from us to the remote party.
virtual Direction GetDirection() const =0
Returns the direction of this message.
Notifies about changing subject in a MUC room.
virtual void SetBody(const QString &body)=0
Updates the body of the message.
virtual Type GetMessageType() const =0
Returns the type of this message.
SubType
This enum is used for more precise classification of chat types messages.
Definition: imessage.h:126
Notifies about participant leaving a MUC room.
virtual QDateTime GetDateTime() const =0
Returns the timestamp of the message.
virtual QObject * GetQObject()=0
Returns this message as a QObject.
The participant has ended the conversation.
The message is from the remote party to us.
virtual QString GetOtherVariant() const =0
The variant of the other part.
virtual void Send()=0
Sends the message.
virtual EscapePolicy GetEscapePolicy() const
Returns the escape policy of the body.
Definition: imessage.h:306
Type
Represents possible message types.
Definition: imessage.h:83
Notifies about participant in a MUC changing the nick.
virtual QString GetBody() const =0
Returns the body of the message.
Message in a multiuser conference.
Direction
Represents the direction of the message.
Definition: imessage.h:70
virtual void Store()=0
Stores the message.
QString GetEscapedBody() const
Returns the body according to the escape policy.
Definition: imessage.h:322
Represents permission changes of a participant in a chat or MUC room.
virtual QObject * OtherPart() const =0
Returns the CL entry from which this message is.
This interface is used to represent a message.
Definition: imessage.h:63
virtual QObject * ParentCLEntry() const
Returns the parent CL entry of this message.
Definition: imessage.h:267