LeechCraft Azoth  0.6.70-6645-gcd10d7e
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 
167  FMaskLongetivity = 0x0003,
168 
172  FSupportsRenames = 0x0020,
173 
176  FHasCustomChatWidget = 0x0040,
177 
182  FSupportsAuth = 0x0080,
183 
186  FSupportsGrouping = 0x0100,
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  protected:
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 
588 Q_DECLARE_OPERATORS_FOR_FLAGS (LeechCraft::Azoth::ICLEntry::Features);
590  "org.Deviant.LeechCraft.Azoth.ICLEntry/1.0");
bool operator==(const EntryStatus &es1, const EntryStatus &es2)
Compares two entry statuses for equality.
Definition: iclentry.h:92
bool operator!=(const EntryStatus &es1, const EntryStatus &es2)
Compares two entry statuses for inequality.
Definition: iclentry.h:105
State
Describes possible presence states of an account or a contact.
Definition: azothcommon.h:43
virtual QString GetHumanReadableID() const
Returns the human-readable ID of this entry.
Definition: iclentry.h:329
Q_DECLARE_OPERATORS_FOR_FLAGS(LeechCraft::Azoth::ICLEntry::Features)
Describes an entry&#39;s status.
Definition: iclentry.h:55
Q_DECLARE_METATYPE(LeechCraft::Azoth::EntryStatus)
Represents a single entry in contact list.
Definition: iclentry.h:141
Feature
Definition: iclentry.h:149
EntryStatus(State state, const QString &string)
Constructs a status with a given state and status string.
Definition: iclentry.h:78
QObject * GetParentCLEntryObject() const
Definition: iclentry.h:248
Interface representing a single account.
Definition: iaccount.h:65
virtual ICLEntry * GetParentCLEntry() const
Definition: iclentry.h:243
Type
Represents possible message types.
Definition: imessage.h:83
State State_
The general state of the entry.
Definition: iclentry.h:59
QString StatusString_
The string of the entry accompanying its state.
Definition: iclentry.h:63
EntryType
Definition: iclentry.h:195
EntryStatus()
Default-constructs an (offline) status.
Definition: iclentry.h:67
This interface is used to represent a message.
Definition: imessage.h:63
Q_DECLARE_INTERFACE(LeechCraft::Azoth::ICLEntry,"org.Deviant.LeechCraft.Azoth.ICLEntry/1.0")
virtual ~ICLEntry()
Definition: iclentry.h:144