LeechCraft Azoth  0.6.70-3565-g2d86529
Modular multiprotocol IM plugin for LeechCraft
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
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 
47  struct EntryStatus
48  {
50  QString StatusString_;
51 
53  : State_ (SOffline)
54  {
55  }
56 
57  EntryStatus (State state, const QString& str)
58  : State_ (state)
59  , StatusString_ (str)
60  {
61  }
62  };
63 
64  inline bool operator== (const EntryStatus& es1, const EntryStatus& es2)
65  {
66  return es1.State_ == es2.State_ &&
67  es1.StatusString_ == es2.StatusString_;
68  }
69 
70  inline bool operator!= (const EntryStatus& es1, const EntryStatus& es2)
71  {
72  return !(es1 == es2);
73  }
74 
102  class ICLEntry
103  {
104  public:
105  virtual ~ICLEntry () {}
106 
110  enum Feature
111  {
119  FPermanentEntry = 0x0000,
120 
124  FSessionEntry = 0x0001,
125 
129 
134 
138 
143  FSupportsAuth = 0x0080,
144 
148 
151  FSelfContact = 0x0200
152  };
153 
154  Q_DECLARE_FLAGS (Features, Feature)
155 
156  enum class EntryType
157  {
160  Chat,
161 
164  MUC,
165 
169  PrivateChat,
170 
174  UnauthEntry
175  };
176 
181  virtual QObject* GetQObject () = 0;
182 
188  virtual IAccount* GetParentAccount () const = 0;
189 
204  virtual ICLEntry* GetParentCLEntry () const
205  {
206  return nullptr;
207  }
208 
209  QObject* GetParentCLEntryObject () const
210  {
211  if (const auto entry = GetParentCLEntry ())
212  return entry->GetQObject ();
213  return nullptr;
214  }
215 
221  virtual Features GetEntryFeatures () const = 0;
222 
227  virtual EntryType GetEntryType () const = 0;
228 
235  virtual QString GetEntryName () const = 0;
236 
245  virtual void SetEntryName (const QString& name) = 0;
246 
265  virtual QString GetEntryID () const = 0;
266 
290  virtual QString GetHumanReadableID () const
291  {
292  return GetEntryID ();
293  }
294 
300  virtual QStringList Groups () const = 0;
301 
309  virtual void SetGroups (const QStringList& groups) = 0;
310 
327  virtual QStringList Variants () const = 0;
328 
348  virtual IMessage* CreateMessage (IMessage::Type type,
349  const QString& variant,
350  const QString& body) = 0;
351 
362  virtual QList<IMessage*> GetAllMessages () const = 0;
363 
378  virtual void PurgeMessages (const QDateTime& before) = 0;
379 
388  virtual void SetChatPartState (ChatPartState state,
389  const QString& variant) = 0;
390 
402  virtual EntryStatus GetStatus (const QString& variant = QString ()) const = 0;
403 
408  virtual QImage GetAvatar () const = 0;
409 
412  virtual void ShowInfo () = 0;
413 
422  virtual QList<QAction*> GetActions () const = 0;
423 
447  virtual QMap<QString, QVariant> GetClientInfo (const QString& variant) const = 0;
448 
459  virtual void MarkMsgsRead () = 0;
460 
463  virtual void ChatTabClosed () = 0;
464 
472  virtual void gotMessage (QObject *msg) = 0;
473 
482  virtual void statusChanged (const EntryStatus& st,
483  const QString& variant) = 0;
484 
493  virtual void availableVariantsChanged (const QStringList& newVars) = 0;
494 
500  virtual void avatarChanged (const QImage&) = 0;
501 
514  virtual void nameChanged (const QString& name) = 0;
515 
528  virtual void groupsChanged (const QStringList& groups) = 0;
529 
538  virtual void chatPartStateChanged (const ChatPartState& state,
539  const QString& variant) = 0;
540 
546  virtual void permsChanged () = 0;
547 
556  virtual void entryGenerallyChanged () = 0;
557  };
558 }
559 }
560 
562 Q_DECLARE_OPERATORS_FOR_FLAGS (LeechCraft::Azoth::ICLEntry::Features);
564  "org.Deviant.LeechCraft.Azoth.ICLEntry/1.0");
Definition: iclentry.h:133
EntryStatus(State state, const QString &str)
Definition: iclentry.h:57
virtual void groupsChanged(const QStringList &groups)=0
This signal should be emitted whenever the entry's groups are changed.
Definition: iclentry.h:119
virtual void PurgeMessages(const QDateTime &before)=0
Purges messages before the given date.
Definition: iclentry.h:143
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.
bool operator==(const EntryStatus &es1, const EntryStatus &es2)
Definition: iclentry.h:64
virtual IAccount * GetParentAccount() const =0
virtual QMap< QString, QVariant > GetClientInfo(const QString &variant) const =0
Returns the client information for the given variant.
bool operator!=(const EntryStatus &es1, const EntryStatus &es2)
Definition: iclentry.h:70
virtual QString GetEntryID() const =0
Returns the ID of this entry.
virtual QString GetHumanReadableID() const
Returns the human-readable ID of this entry.
Definition: iclentry.h:290
virtual void gotMessage(QObject *msg)=0
This signal should be emitted whenever a new message is received.
virtual EntryType GetEntryType() const =0
Q_DECLARE_OPERATORS_FOR_FLAGS(LeechCraft::Azoth::ICLEntry::Features)
Definition: iclentry.h:47
Q_DECLARE_METATYPE(LeechCraft::Azoth::EntryStatus)
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:102
virtual void MarkMsgsRead()=0
Called whenever new messages are read.
Definition: iclentry.h:137
Definition: iclentry.h:151
virtual void entryGenerallyChanged()=0
This signal should be emitted when the entry changes.
virtual void SetChatPartState(ChatPartState state, const QString &variant)=0
Notifies about our chat participation state change.
Feature
Definition: iclentry.h:110
virtual EntryStatus GetStatus(const QString &variant=QString()) const =0
Returns the current status of a variant of the item.
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.
Definition: iclentry.h:124
virtual void avatarChanged(const QImage &)=0
This signal should be emitted whenever the avatar of this item is changed.
QObject * GetParentCLEntryObject() const
Definition: iclentry.h:209
Interface representing a single account.
Definition: iaccount.h:65
virtual ICLEntry * GetParentCLEntry() const
Definition: iclentry.h:204
virtual IMessage * CreateMessage(IMessage::Type type, const QString &variant, const QString &body)=0
Creates the message of the given type to the given variant.
Type
Represents possible message types.
Definition: imessage.h:83
virtual void nameChanged(const QString &name)=0
This signal should be emitted whenever the entry changes name.
State State_
Definition: iclentry.h:49
virtual void SetEntryName(const QString &name)=0
Sets the human-readable name of this entry.
virtual QImage GetAvatar() const =0
Returns the avatar of this item.
virtual QStringList Variants() const =0
Returns the list of destination variants.
QString StatusString_
Definition: iclentry.h:50
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's a MUC participant and his role/affiliation changes.
Definition: iclentry.h:147
Definition: iclentry.h:128
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:156
EntryStatus()
Definition: iclentry.h:52
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:105
virtual QList< QAction * > GetActions() const =0
Returns the list of actions for the item.