-
Notifications
You must be signed in to change notification settings - Fork 1
/
roster.h
119 lines (109 loc) · 3.87 KB
/
roster.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/****************************************************************************
**
** Ireen — cross-platform OSCAR protocol library
**
** Copyright © 2012 Ruslan Nigmatullin <[email protected]>
** Alexey Prokhin <[email protected]>
**
*****************************************************************************
**
** $IREEN_BEGIN_LICENSE$
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as
** published by the Free Software Foundation, either version 3
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with this program. If not, see http://www.gnu.org/licenses/.
** $IREEN_END_LICENSE$
**
****************************************************************************/
#ifndef IREEN_ROSTER_H
#define IREEN_ROSTER_H
#include "core/capability.h"
#include <QExplicitlySharedDataPointer>
#include <QDateTime>
#include "core/snachandler.h"
#include "core/sessiondataitem.h"
#include "feedbag.h"
namespace Ireen {
class ContactItemPrivate;
class StatusItemPrivate;
class Client;
class IREEN_EXPORT ContactItem
{
public:
ContactItem();
ContactItem(const FeedbagItem &item);
~ContactItem();
ContactItem(const ContactItem &other);
void operator=(const ContactItem &other);
QString uin() const;
QString name() const;
void setName(const QString &name);
quint16 groupId() const;
QString group() const;
QString protocol() const;
QString comment() const;
void setComment(const QString &comment);
bool isAuthorizedBy() const;
FeedbagItem &feedbagItem() const;
private:
friend class Roster;
QExplicitlySharedDataPointer<ContactItemPrivate> d;
};
class IREEN_EXPORT StatusItem
{
public:
StatusItem();
~StatusItem();
StatusItem(const StatusItem &other);
void operator=(const StatusItem &other);
quint16 statusId() const;
quint16 statusFlags() const;
QString statusText() const;
QDateTime statusTextUpdateTime() const;
Capabilities capabilities() const;
QDateTime onlineSince() const;
QDateTime awaySince() const;
QDateTime registrationTime() const;
// Returns parsed tlv 0x1D that, for some reason only oscar devs know about,
// contains a lot of data:
// 1. status text
// 2. status text update time
// 3. new-style extended statuses
// 4. avatar hash
SessionDataItemMap statusData() const;
private:
friend class Roster;
QExplicitlySharedDataPointer<StatusItemPrivate> d;
};
class IREEN_EXPORT Roster : public QObject, public SNACHandler, public FeedbagItemHandler
{
Q_OBJECT
Q_INTERFACES(Ireen::SNACHandler Ireen::FeedbagItemHandler)
public:
Roster(Client *client, Feedbag *feedbag);
signals:
void contactItemReceived(const Ireen::ContactItem &item);
void contactStatusUpdated(const QString &uin, const Ireen::StatusItem &item);
void contactItemRemoved(const QString &uin);
void groupItemAdded(const QString &groupName);
void groupItemRenamed(const QString &newGroupName, const QString &oldGroupName);
void groupItemRemoved(const QString &groupName);
void authorizationRequestReceived(const QString &uin, const QString &reason);
void authorizationRequestReply(const QString &uin, bool isAccepted, const QString &reason);
protected:
bool handleFeedbagItem(Feedbag *feedbag, const FeedbagItem &item, Feedbag::ModifyType type, FeedbagError error);
void handleAddModifyCLItem(const FeedbagItem &item, Feedbag::ModifyType type);
void handleRemoveCLItem(const FeedbagItem &item);
virtual void handleSNAC(AbstractConnection *conn, const SNAC &snac);
void handleNewStatus(const SNAC &snac, bool online);
};
} // namespace Ireen
#endif // IREEN_ROSTER_H