LeechCraft Azoth 0.6.70-18808-g3467692359
Modular multiprotocol IM plugin for LeechCraft
Loading...
Searching...
No Matches
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 <QHashFunctions>
12#include <QFlags>
13#include <QMetaType>
14#include <util/azoth/emitters/clentry.h>
15#include "azothcommon.h"
16#include "iaccount.h"
17#include "message.h"
18
19class QAction;
20class QImage;
21
22namespace LC::Azoth
23{
24 class IAccount;
25 class IMessage;
26
49 {
50 protected:
51 Emitters::CLEntry Emitter_;
52
53 virtual ~ICLEntry () = default;
54 public:
55 Emitters::CLEntry& GetCLEntryEmitter () { return Emitter_; }
56
61 {
62 FPermanentEntry = 0b00000000,
63 FSessionEntry = 0b00000001,
64 FMaskLongetivity = 0b00000011,
65 FSupportsRenames = 0b00000100,
66 FSupportsAuth = 0b00001000,
67 FSupportsGrouping = 0b00010000,
68 FSelfContact = 0b00100000,
69 };
70
71 Q_DECLARE_FLAGS (Features, Feature)
72
73 enum class EntryType : std::uint8_t
74 {
79 };
80
85 virtual QObject* GetQObject () = 0;
86
92 virtual IAccount* GetParentAccount () const = 0;
93
108 virtual ICLEntry* GetParentCLEntry () const
109 {
110 return nullptr;
111 }
112
113 QObject* GetParentCLEntryObject () const
114 {
115 if (const auto entry = GetParentCLEntry ())
116 return entry->GetQObject ();
117 return nullptr;
118 }
119
125 virtual Features GetEntryFeatures () const = 0;
126
131 virtual EntryType GetEntryType () const = 0;
132
139 virtual QString GetEntryName () const = 0;
140
149 virtual void SetEntryName (const QString& name) = 0;
150
151 [[deprecated("Use GetGlobalPersistentID() or GetGlobalStrongestID()")]]
152 QString GetEntryID () const
153 {
154 return GetGlobalStrongestID ().ToString ();
155 }
156
157 [[deprecated("Use GetConventionalID()")]]
158 QString GetHumanReadableID () const
159 {
160 return GetConventionalID ().ToString ();
161 }
162
181 virtual std::optional<EntryPersistentId> GetPersistentID () const = 0;
182
183 std::optional<GlobalPersistentId> GetGlobalPersistentID () const
184 {
185 if (const auto persistentId = GetPersistentID ())
186 return GlobalId { GetParentAccount ()->GetAccountID (), *persistentId };
187 return {};
188 }
189
208
213
215 {
216 if (const auto persistentId = GetPersistentID ())
217 return *persistentId;
218 return GetConventionalID ();
219 }
220
222 {
223 if (const auto persistentId = GetGlobalPersistentID ())
224 return *persistentId;
225 return GetGlobalConventionalID ();
226 }
227
228 virtual QString GetHumanReadableAddress () const
229 {
230 return GetConventionalID ().ToString ();
231 }
232
238 virtual QStringList Groups () const = 0;
239
247 virtual void SetGroups (const QStringList& groups) = 0;
248
265 virtual QStringList Variants () const = 0;
266
269 virtual void SendMessage (const OutgoingMessage& message) = 0;
270
281 virtual QList<IMessage*> GetAllMessages () const = 0;
282
297 virtual void PurgeMessages (const QDateTime& before) = 0;
298
307 virtual void SetChatPartState (ChatPartState state,
308 const QString& variant) = 0;
309
321 virtual EntryStatus GetStatus (const QString& variant = QString ()) const = 0;
322
325 virtual void ShowInfo () = 0;
326
335 virtual QList<QAction*> GetActions () const = 0;
336
360 virtual QMap<QString, QVariant> GetClientInfo (const QString& variant) const = 0;
361
372 virtual void MarkMsgsRead () = 0;
373
376 virtual void ChatTabClosed () = 0;
377 };
378}
379
380Q_DECLARE_OPERATORS_FOR_FLAGS (LC::Azoth::ICLEntry::Features)
381Q_DECLARE_INTERFACE (LC::Azoth::ICLEntry, "org.Deviant.LeechCraft.Azoth.ICLEntry/1.0")
Interface representing a single account.
Definition iaccount.h:47
virtual QByteArray GetAccountID() const =0
Returns the ID of this account.
Represents a single entry in contact list.
Definition iclentry.h:49
virtual ~ICLEntry()=default
virtual QObject * GetQObject()=0
virtual QString GetHumanReadableAddress() const
Definition iclentry.h:228
QString GetEntryID() const
Definition iclentry.h:152
virtual Features GetEntryFeatures() const =0
virtual void SendMessage(const OutgoingMessage &message)=0
Sends the message described by message.
virtual void ChatTabClosed()=0
Called by Azoth when the chat with the entry is closed.
virtual void PurgeMessages(const QDateTime &before)=0
Purges messages before the given date.
virtual std::optional< EntryPersistentId > GetPersistentID() const =0
Returns the global persistent ID of this entry.
std::optional< GlobalPersistentId > GetGlobalPersistentID() const
Definition iclentry.h:183
virtual QStringList Groups() const =0
Returns the list of human-readable names of the groups that this entry belongs to.
Emitters::CLEntry Emitter_
Definition iclentry.h:51
virtual void SetChatPartState(ChatPartState state, const QString &variant)=0
Notifies about our chat participation state change.
virtual void MarkMsgsRead()=0
Called whenever new messages are read.
Feature
Definition iclentry.h:61
@ FSelfContact
The entry represents ourselves, like the self-contact in XMPP.
Definition iclentry.h:68
@ FMaskLongetivity
Mask for FPermanentEntry and FSessionEntry.
Definition iclentry.h:64
@ FSessionEntry
The entry is transient, like a chat room participant or a temporary contact.
Definition iclentry.h:63
@ FSupportsRenames
The entry supports renaming, so SetEntryName() makes sense.
Definition iclentry.h:65
@ FSupportsGrouping
The entry supports moving between different groups via SetGroups().
Definition iclentry.h:67
@ FPermanentEntry
The entry is permanent: it belongs to some kind of roster list.
Definition iclentry.h:62
@ FSupportsAuth
The entry supports auth manipulations and implements IAuthable.
Definition iclentry.h:66
virtual void SetGroups(const QStringList &groups)=0
Sets the list of groups this item belongs to.
EntryType
Definition iclentry.h:74
@ PrivateChat
A chat room member.
Definition iclentry.h:77
@ Chat
A standard one-to-one chat.
Definition iclentry.h:75
@ MUC
A multi-user chatroom.
Definition iclentry.h:76
@ UnauthEntry
An unauthorized user that has requested authorization.
Definition iclentry.h:78
virtual QList< IMessage * > GetAllMessages() const =0
Returns all already sent or received messages.
virtual EntryType GetEntryType() const =0
QString GetHumanReadableID() const
Definition iclentry.h:158
GlobalConventionalId GetGlobalConventionalID() const
Definition iclentry.h:209
virtual EntryStatus GetStatus(const QString &variant=QString()) const =0
Returns the current status of a variant of the item.
virtual QMap< QString, QVariant > GetClientInfo(const QString &variant) const =0
Returns the client information for the given variant.
virtual QString GetEntryName() const =0
GlobalStrongestId GetGlobalStrongestID() const
Definition iclentry.h:221
virtual EntryConventionalId GetConventionalID() const =0
Returns the conventional human-readable ID of this entry.
virtual IAccount * GetParentAccount() const =0
virtual QList< QAction * > GetActions() const =0
Returns the list of actions for the item.
QObject * GetParentCLEntryObject() const
Definition iclentry.h:113
virtual void ShowInfo()=0
Requests the entry to show dialog with info about it.
virtual ICLEntry * GetParentCLEntry() const
Definition iclentry.h:108
Emitters::CLEntry & GetCLEntryEmitter()
Definition iclentry.h:55
virtual QStringList Variants() const =0
Returns the list of destination variants.
EntryStrongestId GetStrongestID() const
Definition iclentry.h:214
virtual void SetEntryName(const QString &name)=0
Sets the human-readable name of this entry.
This interface is used to represent a message.
Definition imessage.h:40
GlobalId< IdKind::Conventional > GlobalConventionalId
Definition azothcommon.h:61
EntryId< IdKind::Conventional > EntryConventionalId
Definition azothcommon.h:45
StrongestId< EntryId > EntryStrongestId
Definition azothcommon.h:88
StrongestId< GlobalId > GlobalStrongestId
Definition azothcommon.h:89
QString ToString() const
Definition azothcommon.h:39
Describes an entry's status.
Describes a message to be sent, as formed by the user and before it has been sent to the wire.
Definition message.h:22
QString ToString() const
Definition azothcommon.h:77