LeechCraft Azoth  0.6.70-15082-g543737046d
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  * 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 <QFlags>
12 #include <QMetaType>
13 #include "imessage.h"
14 #include "azothcommon.h"
15 
16 class QAction;
17 class QImage;
18 
19 namespace LC
20 {
21 namespace Azoth
22 {
23  class IAccount;
24  class IMessage;
25 
34  struct EntryStatus
35  {
39 
42  QString StatusString_;
43 
47  : State_ (SOffline)
48  {
49  }
50 
57  EntryStatus (State state, const QString& string)
58  : State_ (state)
59  , StatusString_ (string)
60  {
61  }
62  };
63 
71  inline bool operator== (const EntryStatus& es1, const EntryStatus& es2)
72  {
73  return es1.State_ == es2.State_ &&
74  es1.StatusString_ == es2.StatusString_;
75  }
76 
84  inline bool operator!= (const EntryStatus& es1, const EntryStatus& es2)
85  {
86  return !(es1 == es2);
87  }
88 
120  class ICLEntry
121  {
122  public:
123  virtual ~ICLEntry () {}
124 
128  enum Feature
129  {
137  FPermanentEntry = 0x0000,
138 
142  FSessionEntry = 0x0001,
143 
147 
152 
156 
161  FSupportsAuth = 0x0080,
162 
166 
169  FSelfContact = 0x0200
170  };
171 
172  Q_DECLARE_FLAGS (Features, Feature)
173 
174  enum class EntryType
175  {
178  Chat,
179 
182  MUC,
183 
187  PrivateChat,
188 
192  UnauthEntry
193  };
194 
199  virtual QObject* GetQObject () = 0;
200 
206  virtual IAccount* GetParentAccount () const = 0;
207 
222  virtual ICLEntry* GetParentCLEntry () const
223  {
224  return nullptr;
225  }
226 
227  QObject* GetParentCLEntryObject () const
228  {
229  if (const auto entry = GetParentCLEntry ())
230  return entry->GetQObject ();
231  return nullptr;
232  }
233 
239  virtual Features GetEntryFeatures () const = 0;
240 
245  virtual EntryType GetEntryType () const = 0;
246 
253  virtual QString GetEntryName () const = 0;
254 
263  virtual void SetEntryName (const QString& name) = 0;
264 
283  virtual QString GetEntryID () const = 0;
284 
308  virtual QString GetHumanReadableID () const
309  {
310  return GetEntryID ();
311  }
312 
318  virtual QStringList Groups () const = 0;
319 
327  virtual void SetGroups (const QStringList& groups) = 0;
328 
345  virtual QStringList Variants () const = 0;
346 
366  virtual IMessage* CreateMessage (IMessage::Type type,
367  const QString& variant,
368  const QString& body) = 0;
369 
380  virtual QList<IMessage*> GetAllMessages () const = 0;
381 
396  virtual void PurgeMessages (const QDateTime& before) = 0;
397 
406  virtual void SetChatPartState (ChatPartState state,
407  const QString& variant) = 0;
408 
420  virtual EntryStatus GetStatus (const QString& variant = QString ()) const = 0;
421 
424  virtual void ShowInfo () = 0;
425 
434  virtual QList<QAction*> GetActions () const = 0;
435 
459  virtual QMap<QString, QVariant> GetClientInfo (const QString& variant) const = 0;
460 
471  virtual void MarkMsgsRead () = 0;
472 
475  virtual void ChatTabClosed () = 0;
476 
484  virtual void gotMessage (QObject *msg) = 0;
485 
494  virtual void statusChanged (const EntryStatus& st,
495  const QString& variant) = 0;
496 
505  virtual void availableVariantsChanged (const QStringList& newVars) = 0;
506 
519  virtual void nameChanged (const QString& name) = 0;
520 
533  virtual void groupsChanged (const QStringList& groups) = 0;
534 
543  virtual void chatPartStateChanged (const ChatPartState& state,
544  const QString& variant) = 0;
545 
551  virtual void permsChanged () = 0;
552 
561  virtual void entryGenerallyChanged () = 0;
562  };
563 }
564 }
565 
566 Q_DECLARE_METATYPE (LC::Azoth::EntryStatus)
567 Q_DECLARE_OPERATORS_FOR_FLAGS (LC::Azoth::ICLEntry::Features)
568 Q_DECLARE_INTERFACE (LC::Azoth::ICLEntry,
569  "org.Deviant.LeechCraft.Azoth.ICLEntry/1.0")
LC::Azoth::ICLEntry::Variants
virtual QStringList Variants() const =0
Returns the list of destination variants.
LC::Azoth::ICLEntry::nameChanged
virtual void nameChanged(const QString &name)=0
This signal should be emitted whenever the entry changes name.
LC::Azoth::ICLEntry::permsChanged
virtual void permsChanged()=0
This signal should be emitted if it's a MUC participant and his role/affiliation changes.
LC::Azoth::ICLEntry::CreateMessage
virtual IMessage * CreateMessage(IMessage::Type type, const QString &variant, const QString &body)=0
Creates the message of the given type to the given variant.
LC::Azoth::ICLEntry::GetAllMessages
virtual QList< IMessage * > GetAllMessages() const =0
Returns all already sent or received messages.
LC::Azoth::ICLEntry::groupsChanged
virtual void groupsChanged(const QStringList &groups)=0
This signal should be emitted whenever the entry's groups are changed.
LC::Azoth::ICLEntry::chatPartStateChanged
virtual void chatPartStateChanged(const ChatPartState &state, const QString &variant)=0
This signal should be emitted whenever the chat participation state of this entry changes.
LC::Azoth::ICLEntry::GetStatus
virtual EntryStatus GetStatus(const QString &variant=QString()) const =0
Returns the current status of a variant of the item.
LC::Azoth::ICLEntry::GetParentAccount
virtual IAccount * GetParentAccount() const =0
LC::Azoth::ICLEntry::gotMessage
virtual void gotMessage(QObject *msg)=0
This signal should be emitted whenever a new message is received.
QList
Definition: iaccountactionsprovider.h:16
LC::Azoth::ICLEntry::SetChatPartState
virtual void SetChatPartState(ChatPartState state, const QString &variant)=0
Notifies about our chat participation state change.
LC::Azoth::ICLEntry::GetEntryID
virtual QString GetEntryID() const =0
Returns the ID of this entry.
LC::Azoth::IMessage
This interface is used to represent a message.
Definition: imessage.h:42
LC::Azoth::ICLEntry::FSupportsAuth
@ FSupportsAuth
Definition: iclentry.h:161
LC::Azoth::ICLEntry::FSelfContact
@ FSelfContact
Definition: iclentry.h:169
LC::Azoth::SOffline
@ SOffline
Definition: azothcommon.h:42
LC::Azoth::EntryStatus::State_
State State_
The general state of the entry.
Definition: iclentry.h:38
LC::Azoth::ICLEntry
Represents a single entry in contact list.
Definition: iclentry.h:120
LC::Azoth::ICLEntry::GetEntryType
virtual EntryType GetEntryType() const =0
LC::Azoth::ICLEntry::statusChanged
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.
LC::Azoth::ICLEntry::FMaskLongetivity
@ FMaskLongetivity
Definition: iclentry.h:146
LC::Azoth::ICLEntry::~ICLEntry
virtual ~ICLEntry()
Definition: iclentry.h:123
LC::Azoth::ICLEntry::GetEntryName
virtual QString GetEntryName() const =0
LC::Azoth::ICLEntry::SetEntryName
virtual void SetEntryName(const QString &name)=0
Sets the human-readable name of this entry.
LC::Azoth::ICLEntry::entryGenerallyChanged
virtual void entryGenerallyChanged()=0
This signal should be emitted when the entry changes.
LC::Azoth::ChatPartState
ChatPartState
Definition: azothcommon.h:109
LC::Azoth::ICLEntry::EntryType
EntryType
Definition: iclentry.h:174
LC::Azoth::ICLEntry::Groups
virtual QStringList Groups() const =0
Returns the list of human-readable names of the groups that this entry belongs to.
LC::Azoth::ICLEntry::ChatTabClosed
virtual void ChatTabClosed()=0
Called by Azoth when the chat with the entry is closed.
LC::Azoth::ICLEntry::GetParentCLEntry
virtual ICLEntry * GetParentCLEntry() const
Definition: iclentry.h:222
LC::Azoth::ICLEntry::GetEntryFeatures
virtual Features GetEntryFeatures() const =0
LC::Azoth::operator==
bool operator==(const ActivityInfo &i1, const ActivityInfo &i2)
Checks whether the activity info structures are equal.
Definition: activityinfo.h:61
LC::Azoth::ICLEntry::MarkMsgsRead
virtual void MarkMsgsRead()=0
Called whenever new messages are read.
LC::Azoth::EntryStatus::EntryStatus
EntryStatus()
Default-constructs an (offline) status.
Definition: iclentry.h:46
LC
Definition: activityinfo.h:13
LC::Azoth::ICLEntry::GetClientInfo
virtual QMap< QString, QVariant > GetClientInfo(const QString &variant) const =0
Returns the client information for the given variant.
LC::Azoth::ICLEntry::FSupportsRenames
@ FSupportsRenames
Definition: iclentry.h:151
LC::Azoth::ICLEntry::GetParentCLEntryObject
QObject * GetParentCLEntryObject() const
Definition: iclentry.h:227
LC::Azoth::ICLEntry::GetActions
virtual QList< QAction * > GetActions() const =0
Returns the list of actions for the item.
LC::Azoth::State
State
Describes possible presence states of an account or a contact.
Definition: azothcommon.h:34
LC::Azoth::ICLEntry::PurgeMessages
virtual void PurgeMessages(const QDateTime &before)=0
Purges messages before the given date.
LC::Azoth::ICLEntry::ShowInfo
virtual void ShowInfo()=0
Requests the entry to show dialog with info about it.
LC::Azoth::EntryStatus::EntryStatus
EntryStatus(State state, const QString &string)
Constructs a status with a given state and status string.
Definition: iclentry.h:57
LC::Azoth::operator!=
bool operator!=(const ActivityInfo &i1, const ActivityInfo &i2)
Checks whether the activity info structures are not equal.
Definition: activityinfo.h:78
azothcommon.h
LC::Azoth::ICLEntry::FPermanentEntry
@ FPermanentEntry
Definition: iclentry.h:137
LC::Azoth::ICLEntry::FSupportsGrouping
@ FSupportsGrouping
Definition: iclentry.h:165
imessage.h
LC::Azoth::ICLEntry::Feature
Feature
Definition: iclentry.h:128
LC::Azoth::ICLEntry::GetQObject
virtual QObject * GetQObject()=0
LC::Azoth::ICLEntry::availableVariantsChanged
virtual void availableVariantsChanged(const QStringList &newVars)=0
This signal should be emitted whenever the list of available variants changes.
LC::Azoth::ICLEntry::SetGroups
virtual void SetGroups(const QStringList &groups)=0
Sets the list of groups this item belongs to.
LC::Azoth::IMessage::Type
Type
Represents possible message types.
Definition: imessage.h:62
LC::Azoth::IAccount
Interface representing a single account.
Definition: iaccount.h:56
LC::Azoth::ICLEntry::FSessionEntry
@ FSessionEntry
Definition: iclentry.h:142
LC::Azoth::ICLEntry::FHasCustomChatWidget
@ FHasCustomChatWidget
Definition: iclentry.h:155
LC::Azoth::EntryStatus
Describes an entry's status.
Definition: iclentry.h:34
LC::Azoth::EntryStatus::StatusString_
QString StatusString_
The string of the entry accompanying its state.
Definition: iclentry.h:42
LC::Azoth::ICLEntry::GetHumanReadableID
virtual QString GetHumanReadableID() const
Returns the human-readable ID of this entry.
Definition: iclentry.h:308