LeechCraft Azoth
0.6.70-18808-g3467692359
Modular multiprotocol IM plugin for LeechCraft
Toggle main menu visibility
Loading...
Searching...
No Matches
azothcommon.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 <variant>
12
#include <QHashFunctions>
13
#include <QMetaType>
14
#include <
interfaces/azoth/imessage.h
>
15
16
namespace
LC
17
{
18
namespace
Azoth
19
{
20
enum class
IdKind
: std::uint8_t
21
{
22
Persistent
,
23
Conventional
,
24
};
25
26
template
<IdKind>
27
struct
EntryId
28
{
29
QString
Id_
;
30
31
EntryId
() =
default
;
32
33
static
EntryId
FromString
(
const
QString&
id
) {
return
EntryId
{
id
}; }
34
35
bool
operator==
(
const
EntryId
&)
const
=
default
;
36
37
friend
size_t
qHash
(
const
EntryId
&
id
,
size_t
seed = 0) {
return
qHash
(
id
.
Id_
, seed); }
38
39
[[nodiscard]] QString
ToString
()
const
{
return
Id_
; }
40
private
:
41
explicit
EntryId
(
const
QString&
id
) :
Id_
{ id } {}
42
};
43
44
using
EntryPersistentId
=
EntryId<IdKind::Persistent>
;
45
using
EntryConventionalId
=
EntryId<IdKind::Conventional>
;
46
47
template
<IdKind K>
48
struct
GlobalId
49
{
50
QString
AccountId_
;
51
EntryId<K>
EntryId_
;
52
53
bool
operator==
(
const
GlobalId
&)
const
=
default
;
54
55
friend
size_t
qHash
(
const
GlobalId
&
id
,
size_t
seed = 0) {
return
qHashMulti (seed,
id
.
AccountId_
,
id
.
EntryId_
); }
56
57
[[nodiscard]] QString
ToString
()
const
{
return
AccountId_
+
':'
+
EntryId_
.ToString (); }
58
};
59
60
using
GlobalPersistentId
=
GlobalId<IdKind::Persistent>
;
61
using
GlobalConventionalId
=
GlobalId<IdKind::Conventional>
;
62
63
template
<
template
<IdKind>
typename
Id>
64
struct
StrongestId
: std::variant<Id<IdKind::Persistent>, Id<IdKind::Conventional>>
65
{
66
using
Base
= std::variant<Id<IdKind::Persistent>, Id<IdKind::Conventional>>;
67
using
Base::Base;
68
69
bool
operator==
(
const
StrongestId
&)
const
=
default
;
70
71
friend
size_t
qHash
(
const
StrongestId
& strongestId,
size_t
seed = 0)
72
{
73
const
auto
index = strongestId.index ();
74
return
std::visit ([&] (
const
auto
&
id
) {
return
qHashMulti (seed, index,
id
); }, strongestId.
ToVariant
());
75
}
76
77
[[nodiscard]] QString
ToString
()
const
78
{
79
return
std::visit ([] (
const
auto
&
id
) {
return
id
.ToString (); }, *
this
);
80
}
81
82
[[nodiscard]]
const
Base
&
ToVariant
()
const
83
{
84
return
*
this
;
85
}
86
};
87
88
using
EntryStrongestId
=
StrongestId<EntryId>
;
89
using
GlobalStrongestId
=
StrongestId<GlobalId>
;
90
91
inline
QString
GetAccountId
(
const
GlobalStrongestId
& strongestId)
92
{
93
return
std::visit ([] (
const
auto
&
id
) {
return
id
.AccountId_; }, strongestId.
ToVariant
());
94
}
95
99
enum
State
: std::uint8_t
100
{
101
SOffline
,
102
SOnline
,
103
SAway
,
104
SXA
,
105
SDND
,
106
SChat
,
107
SInvisible
,
108
SProbe
,
109
SError
,
110
SInvalid
,
111
116
SConnecting
117
};
118
135
inline
bool
IsLess
(
State
s1,
State
s2)
136
{
137
constexpr
int
order [] = { 7, 3, 4, 5, 6, 1, 2, 8, 9, 10 };
138
return
order [s1] < order [s2];
139
}
140
146
enum
AuthStatus
147
{
151
ASNone
= 0x00,
152
155
ASFrom
= 0x01,
156
159
ASTo
= 0x02,
160
163
ASBoth
= 0x03,
164
167
ASContactRequested
= 0x08
168
};
169
174
enum
ChatPartState
: std::uint8_t
175
{
178
CPSNone
,
179
182
CPSActive
,
183
187
CPSInactive
,
188
192
CPSGone
,
193
196
CPSComposing
,
197
200
CPSPaused
201
};
202
205
struct
CustomStatus
206
{
209
QString
Name_
;
210
213
State
State_
;
214
217
QString
Text_
;
218
};
219
228
struct
EntryStatus
229
{
232
State
State_
=
SOffline
;
233
236
QString
StatusString_
{};
237
238
bool
operator==
(
const
EntryStatus
& es2)
const
=
default
;
239
};
240
}
241
}
242
243
Q_DECLARE_METATYPE (
LC::Azoth::ChatPartState
)
244
Q_DECLARE_METATYPE (
LC::Azoth::EntryStatus
)
245
Q_DECLARE_METATYPE (
LC::Azoth::State
)
imessage.h
LC::Azoth
Definition
activityinfo.h:16
LC::Azoth::IdKind
IdKind
Definition
azothcommon.h:21
LC::Azoth::IdKind::Persistent
@ Persistent
Definition
azothcommon.h:22
LC::Azoth::IdKind::Conventional
@ Conventional
Definition
azothcommon.h:23
LC::Azoth::State
State
Describes possible presence states of an account or a contact.
Definition
azothcommon.h:100
LC::Azoth::SInvalid
@ SInvalid
Definition
azothcommon.h:110
LC::Azoth::SXA
@ SXA
Definition
azothcommon.h:104
LC::Azoth::SOnline
@ SOnline
Definition
azothcommon.h:102
LC::Azoth::SError
@ SError
Definition
azothcommon.h:109
LC::Azoth::SOffline
@ SOffline
Definition
azothcommon.h:101
LC::Azoth::SConnecting
@ SConnecting
Definition
azothcommon.h:116
LC::Azoth::SChat
@ SChat
Definition
azothcommon.h:106
LC::Azoth::SProbe
@ SProbe
Definition
azothcommon.h:108
LC::Azoth::SAway
@ SAway
Definition
azothcommon.h:103
LC::Azoth::SDND
@ SDND
Definition
azothcommon.h:105
LC::Azoth::SInvisible
@ SInvisible
Definition
azothcommon.h:107
LC::Azoth::GlobalConventionalId
GlobalId< IdKind::Conventional > GlobalConventionalId
Definition
azothcommon.h:61
LC::Azoth::EntryConventionalId
EntryId< IdKind::Conventional > EntryConventionalId
Definition
azothcommon.h:45
LC::Azoth::IsLess
bool IsLess(State s1, State s2)
Compares two states according to the implied desire to have a conversation.
Definition
azothcommon.h:135
LC::Azoth::AuthStatus
AuthStatus
Definition
azothcommon.h:147
LC::Azoth::ASBoth
@ ASBoth
Definition
azothcommon.h:163
LC::Azoth::ASTo
@ ASTo
Definition
azothcommon.h:159
LC::Azoth::ASFrom
@ ASFrom
Definition
azothcommon.h:155
LC::Azoth::ASContactRequested
@ ASContactRequested
Definition
azothcommon.h:167
LC::Azoth::ASNone
@ ASNone
Definition
azothcommon.h:151
LC::Azoth::EntryStrongestId
StrongestId< EntryId > EntryStrongestId
Definition
azothcommon.h:88
LC::Azoth::GlobalStrongestId
StrongestId< GlobalId > GlobalStrongestId
Definition
azothcommon.h:89
LC::Azoth::EntryPersistentId
EntryId< IdKind::Persistent > EntryPersistentId
Definition
azothcommon.h:44
LC::Azoth::ChatPartState
ChatPartState
Definition
azothcommon.h:175
LC::Azoth::CPSActive
@ CPSActive
Definition
azothcommon.h:182
LC::Azoth::CPSInactive
@ CPSInactive
Definition
azothcommon.h:187
LC::Azoth::CPSComposing
@ CPSComposing
Definition
azothcommon.h:196
LC::Azoth::CPSPaused
@ CPSPaused
Definition
azothcommon.h:200
LC::Azoth::CPSNone
@ CPSNone
Definition
azothcommon.h:178
LC::Azoth::CPSGone
@ CPSGone
Definition
azothcommon.h:192
LC::Azoth::GlobalPersistentId
GlobalId< IdKind::Persistent > GlobalPersistentId
Definition
azothcommon.h:60
LC::Azoth::GetAccountId
QString GetAccountId(const GlobalStrongestId &strongestId)
Definition
azothcommon.h:91
LC
Definition
activityinfo.h:14
LC::Azoth::CustomStatus
A custom saved named status.
Definition
azothcommon.h:206
LC::Azoth::CustomStatus::Name_
QString Name_
The name of this status.
Definition
azothcommon.h:209
LC::Azoth::CustomStatus::State_
State State_
The state associated with this status.
Definition
azothcommon.h:213
LC::Azoth::CustomStatus::Text_
QString Text_
The status text associated with this status.
Definition
azothcommon.h:217
LC::Azoth::EntryId
Definition
azothcommon.h:28
LC::Azoth::EntryId::ToString
QString ToString() const
Definition
azothcommon.h:39
LC::Azoth::EntryId::EntryId
EntryId()=default
LC::Azoth::EntryId< IdKind::Persistent >::Id_
QString Id_
Definition
azothcommon.h:29
LC::Azoth::EntryId::FromString
static EntryId FromString(const QString &id)
Definition
azothcommon.h:33
LC::Azoth::EntryId::operator==
bool operator==(const EntryId &) const =default
LC::Azoth::EntryId::qHash
friend size_t qHash(const EntryId &id, size_t seed=0)
Definition
azothcommon.h:37
LC::Azoth::EntryStatus
Describes an entry's status.
Definition
azothcommon.h:229
LC::Azoth::EntryStatus::State_
State State_
The general state of the entry.
Definition
azothcommon.h:232
LC::Azoth::EntryStatus::StatusString_
QString StatusString_
The string of the entry accompanying its state.
Definition
azothcommon.h:236
LC::Azoth::EntryStatus::operator==
bool operator==(const EntryStatus &es2) const =default
LC::Azoth::GlobalId
Definition
azothcommon.h:49
LC::Azoth::GlobalId::qHash
friend size_t qHash(const GlobalId &id, size_t seed=0)
Definition
azothcommon.h:55
LC::Azoth::GlobalId< IdKind::Persistent >::AccountId_
QString AccountId_
Definition
azothcommon.h:50
LC::Azoth::GlobalId::operator==
bool operator==(const GlobalId &) const =default
LC::Azoth::GlobalId::ToString
QString ToString() const
Definition
azothcommon.h:57
LC::Azoth::GlobalId< IdKind::Persistent >::EntryId_
EntryId< K > EntryId_
Definition
azothcommon.h:51
LC::Azoth::StrongestId
Definition
azothcommon.h:65
LC::Azoth::StrongestId::ToString
QString ToString() const
Definition
azothcommon.h:77
LC::Azoth::StrongestId::qHash
friend size_t qHash(const StrongestId &strongestId, size_t seed=0)
Definition
azothcommon.h:71
LC::Azoth::StrongestId::Base
std::variant< Id< IdKind::Persistent >, Id< IdKind::Conventional > > Base
Definition
azothcommon.h:66
LC::Azoth::StrongestId::ToVariant
const Base & ToVariant() const
Definition
azothcommon.h:82
LC::Azoth::StrongestId::operator==
bool operator==(const StrongestId &) const =default
src
plugins
azoth
interfaces
azoth
azothcommon.h
Generated by
1.17.0