LeechCraft Azoth  0.6.70-11552-gf61ee51c3d
Modular multiprotocol IM plugin for LeechCraft
iclentry.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 <QFlags>
33 #include <QMetaType>
34 #include "imessage.h"
35 #include "azothcommon.h"
36 
37 class QAction;
38 class QImage;
39 
40 namespace LeechCraft
41 {
42 namespace Azoth
43 {
44  class IAccount;
45  class IMessage;
46 
55  struct EntryStatus
56  {
60 
63  QString StatusString_;
64 
68  : State_ (SOffline)
69  {
70  }
71 
78  EntryStatus (State state, const QString& string)
79  : State_ (state)
80  , StatusString_ (string)
81  {
82  }
83  };
84 
92  inline bool operator== (const EntryStatus& es1, const EntryStatus& es2)
93  {
94  return es1.State_ == es2.State_ &&
95  es1.StatusString_ == es2.StatusString_;
96  }
97 
105  inline bool operator!= (const EntryStatus& es1, const EntryStatus& es2)
106  {
107  return !(es1 == es2);
108  }
109 
141  class ICLEntry
142  {
143  public:
144  virtual ~ICLEntry () {}
145 
149  enum Feature
150  {
158  FPermanentEntry = 0x0000,
159 
163  FSessionEntry = 0x0001,
164 
168 
173 
177 
182  FSupportsAuth = 0x0080,
183 
187 
190  FSelfContact = 0x0200
191  };
192 
193  Q_DECLARE_FLAGS (Features, Feature)
194 
195  enum class EntryType
196  {
199  Chat,
200 
203  MUC,
204 
208  PrivateChat,
209 
213  UnauthEntry
214  };
215 
220  virtual QObject* GetQObject () = 0;
221 
227  virtual IAccount* GetParentAccount () const = 0;
228 
243  virtual ICLEntry* GetParentCLEntry () const
244  {
245  return nullptr;
246  }
247 
248  QObject* GetParentCLEntryObject () const
249  {
250  if (const auto entry = GetParentCLEntry ())
251  return entry->GetQObject ();
252  return nullptr;
253  }
254 
260  virtual Features GetEntryFeatures () const = 0;
261 
266  virtual EntryType GetEntryType () const = 0;
267 
274  virtual QString GetEntryName () const = 0;
275 
284  virtual void SetEntryName (const QString& name) = 0;
285 
304  virtual QString GetEntryID () const = 0;
305 
329  virtual QString GetHumanReadableID () const
330  {
331  return GetEntryID ();
332  }
333 
339  virtual QStringList Groups () const = 0;
340 
348  virtual void SetGroups (const QStringList& groups) = 0;
349 
366  virtual QStringList Variants () const = 0;
367 
387  virtual IMessage* CreateMessage (IMessage::Type type,
388  const QString& variant,
389  const QString& body) = 0;
390 
401  virtual QList<IMessage*> GetAllMessages () const = 0;
402 
417  virtual void PurgeMessages (const QDateTime& before) = 0;
418 
427  virtual void SetChatPartState (ChatPartState state,
428  const QString& variant) = 0;
429 
441  virtual EntryStatus GetStatus (const QString& variant = QString ()) const = 0;
442 
445  virtual void ShowInfo () = 0;
446 
455  virtual QList<QAction*> GetActions () const = 0;
456 
480  virtual QMap<QString, QVariant> GetClientInfo (const QString& variant) const = 0;
481 
492  virtual void MarkMsgsRead () = 0;
493 
496  virtual void ChatTabClosed () = 0;
497 
505  virtual void gotMessage (QObject *msg) = 0;
506 
515  virtual void statusChanged (const EntryStatus& st,
516  const QString& variant) = 0;
517 
526  virtual void availableVariantsChanged (const QStringList& newVars) = 0;
527 
540  virtual void nameChanged (const QString& name) = 0;
541 
554  virtual void groupsChanged (const QStringList& groups) = 0;
555 
564  virtual void chatPartStateChanged (const ChatPartState& state,
565  const QString& variant) = 0;
566 
572  virtual void permsChanged () = 0;
573 
582  virtual void entryGenerallyChanged () = 0;
583  };
584 }
585 }
586 
587 Q_DECLARE_METATYPE (LeechCraft::Azoth::EntryStatus)
588 Q_DECLARE_OPERATORS_FOR_FLAGS (LeechCraft::Azoth::ICLEntry::Features)
589 Q_DECLARE_INTERFACE (LeechCraft::Azoth::ICLEntry,
590  "org.Deviant.LeechCraft.Azoth.ICLEntry/1.0")
Definition: iclentry.h:172
virtual void groupsChanged(const QStringList &groups)=0
This signal should be emitted whenever the entry&#39;s groups are changed.
Definition: iclentry.h:158
virtual void PurgeMessages(const QDateTime &before)=0
Purges messages before the given date.
Definition: iclentry.h:182
virtual QObject * GetQObject()=0
virtual void ShowInfo()=0
Requests the entry to show dialog with info about it.
virtual void statusChanged(const EntryStatus &st, const QString &variant)=0
This signal should be emitted whenever the status of a variant in this entry changes.
virtual IAccount * GetParentAccount() const =0
virtual QMap< QString, QVariant > GetClientInfo(const QString &variant) const =0
Returns the client information for the given variant.
State
Describes possible presence states of an account or a contact.
Definition: azothcommon.h:43
virtual QString GetEntryID() const =0
Returns the ID of this entry.
virtual void gotMessage(QObject *msg)=0
This signal should be emitted whenever a new message is received.
virtual EntryType GetEntryType() const =0
Describes an entry&#39;s status.
Definition: iclentry.h:55
virtual void SetGroups(const QStringList &groups)=0
Sets the list of groups this item belongs to.
virtual void availableVariantsChanged(const QStringList &newVars)=0
This signal should be emitted whenever the list of available variants changes.
Represents a single entry in contact list.
Definition: iclentry.h:141
virtual void MarkMsgsRead()=0
Called whenever new messages are read.
Definition: iclentry.h:176
Definition: iclentry.h:190
virtual void entryGenerallyChanged()=0
This signal should be emitted when the entry changes.
QObject * GetParentCLEntryObject() const
Definition: iclentry.h:248
virtual void SetChatPartState(ChatPartState state, const QString &variant)=0
Notifies about our chat participation state change.
Feature
Definition: iclentry.h:149
virtual EntryStatus GetStatus(const QString &variant=QString()) const =0
Returns the current status of a variant of the item.
virtual QString GetHumanReadableID() const
Returns the human-readable ID of this entry.
Definition: iclentry.h:329
virtual Features GetEntryFeatures() const =0
virtual QStringList Groups() const =0
Returns the list of human-readable names of the groups that this entry belongs to.
EntryStatus(State state, const QString &string)
Constructs a status with a given state and status string.
Definition: iclentry.h:78
bool operator==(const ActivityInfo &i1, const ActivityInfo &i2)
Checks whether the activity info structures are equal.
Definition: activityinfo.h:70
Definition: iclentry.h:163
Interface representing a single account.
Definition: iaccount.h:65
virtual IMessage * CreateMessage(IMessage::Type type, const QString &variant, const QString &body)=0
Creates the message of the given type to the given variant.
virtual void nameChanged(const QString &name)=0
This signal should be emitted whenever the entry changes name.
Type
Represents possible message types.
Definition: imessage.h:83
State State_
The general state of the entry.
Definition: iclentry.h:59
virtual void SetEntryName(const QString &name)=0
Sets the human-readable name of this entry.
virtual QStringList Variants() const =0
Returns the list of destination variants.
QString StatusString_
The string of the entry accompanying its state.
Definition: iclentry.h:63
virtual QString GetEntryName() const =0
virtual QList< IMessage * > GetAllMessages() const =0
Returns all already sent or received messages.
virtual void permsChanged()=0
This signal should be emitted if it&#39;s a MUC participant and his role/affiliation changes.
bool operator!=(const ActivityInfo &i1, const ActivityInfo &i2)
Checks whether the activity info structures are not equal.
Definition: activityinfo.h:87
Definition: iclentry.h:186
Definition: iclentry.h:167
virtual void chatPartStateChanged(const ChatPartState &state, const QString &variant)=0
This signal should be emitted whenever the chat participation state of this entry changes...
virtual void ChatTabClosed()=0
Called by Azoth when the chat with the entry is closed.
EntryType
Definition: iclentry.h:195
EntryStatus()
Default-constructs an (offline) status.
Definition: iclentry.h:67
virtual ICLEntry * GetParentCLEntry() const
Definition: iclentry.h:243
This interface is used to represent a message.
Definition: imessage.h:63
virtual ~ICLEntry()
Definition: iclentry.h:144
virtual QList< QAction * > GetActions() const =0
Returns the list of actions for the item.