1 | /*
|
---|
2 | * userlist.h - high-level roster
|
---|
3 | * Copyright (C) 2001, 2002 Justin Karneges
|
---|
4 | *
|
---|
5 | * This program is free software; you can redistribute it and/or
|
---|
6 | * modify it under the terms of the GNU General Public License
|
---|
7 | * as published by the Free Software Foundation; either version 2
|
---|
8 | * of the License, or (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this library; if not, write to the Free Software
|
---|
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
18 | *
|
---|
19 | */
|
---|
20 |
|
---|
21 | #ifndef USERLIST_H
|
---|
22 | #define USERLIST_H
|
---|
23 |
|
---|
24 | #include<qstring.h>
|
---|
25 | #include<qdatetime.h>
|
---|
26 | #include<qvaluelist.h>
|
---|
27 | #include"im.h"
|
---|
28 |
|
---|
29 | class AvatarFactory;
|
---|
30 |
|
---|
31 | class UserResource : public XMPP::Resource
|
---|
32 | {
|
---|
33 | public:
|
---|
34 | UserResource();
|
---|
35 | UserResource(const XMPP::Resource &);
|
---|
36 | ~UserResource();
|
---|
37 |
|
---|
38 | void setResource(const XMPP::Resource &);
|
---|
39 |
|
---|
40 | const QString& versionString() const;
|
---|
41 | const QString& clientVersion() const;
|
---|
42 | const QString& clientName() const;
|
---|
43 | const QString& clientOS() const;
|
---|
44 | void setClient(const QString& name, const QString& version, const QString& os);
|
---|
45 |
|
---|
46 | const QString & publicKeyID() const;
|
---|
47 | int pgpVerifyStatus() const;
|
---|
48 | QDateTime sigTimestamp() const;
|
---|
49 | void setPublicKeyID(const QString &);
|
---|
50 | void setPGPVerifyStatus(int);
|
---|
51 | void setSigTimestamp(const QDateTime &);
|
---|
52 |
|
---|
53 | private:
|
---|
54 | QString v_ver, v_clientName, v_clientVersion, v_clientOS, v_keyID;
|
---|
55 | int v_pgpVerifyStatus;
|
---|
56 | QDateTime sigts;
|
---|
57 | };
|
---|
58 |
|
---|
59 | bool operator<(const UserResource &r1, const UserResource &r2);
|
---|
60 | bool operator<=(const UserResource &r1, const UserResource &r2);
|
---|
61 | bool operator==(const UserResource &r1, const UserResource &r2);
|
---|
62 | bool operator>(const UserResource &r1, const UserResource &r2);
|
---|
63 | bool operator>=(const UserResource &r1, const UserResource &r2);
|
---|
64 |
|
---|
65 | class UserResourceList : public QValueList<UserResource>
|
---|
66 | {
|
---|
67 | public:
|
---|
68 | UserResourceList();
|
---|
69 | ~UserResourceList();
|
---|
70 |
|
---|
71 | void sort();
|
---|
72 |
|
---|
73 | UserResourceList::Iterator find(const QString &);
|
---|
74 | UserResourceList::Iterator priority();
|
---|
75 |
|
---|
76 | UserResourceList::ConstIterator find(const QString &) const;
|
---|
77 | UserResourceList::ConstIterator priority() const;
|
---|
78 | };
|
---|
79 |
|
---|
80 | class UserListItem : public XMPP::LiveRosterItem
|
---|
81 | {
|
---|
82 | public:
|
---|
83 | UserListItem(bool self=false);
|
---|
84 | ~UserListItem();
|
---|
85 |
|
---|
86 | bool inList() const;
|
---|
87 | bool isTransport() const;
|
---|
88 | bool isAvailable() const;
|
---|
89 | bool isHidden() const;
|
---|
90 | bool isAway() const;
|
---|
91 | QDateTime lastAvailable() const;
|
---|
92 | int lastMessageType() const;
|
---|
93 | void setLastMessageType(const int mtype);
|
---|
94 | const QString & presenceError() const;
|
---|
95 | bool isSelf() const;
|
---|
96 | QString makeTip(bool trim = true, bool doLinkify = true) const;
|
---|
97 | QString makeBareTip(bool trim, bool doLinkify) const;
|
---|
98 | QString makeDesc() const;
|
---|
99 | bool isPrivate() const;
|
---|
100 |
|
---|
101 | void setJid(const XMPP::Jid &);
|
---|
102 | void setInList(bool);
|
---|
103 | void setLastAvailable(const QDateTime &);
|
---|
104 | void setPresenceError(const QString &);
|
---|
105 | void setPrivate(bool);
|
---|
106 |
|
---|
107 | UserResourceList & userResourceList();
|
---|
108 | UserResourceList::Iterator priority();
|
---|
109 | const UserResourceList & userResourceList() const;
|
---|
110 | UserResourceList::ConstIterator priority() const;
|
---|
111 |
|
---|
112 | bool isSecure(const QString &rname) const;
|
---|
113 | void setSecure(const QString &rname, bool);
|
---|
114 |
|
---|
115 | const QString & publicKeyID() const;
|
---|
116 | void setPublicKeyID(const QString &);
|
---|
117 |
|
---|
118 | AvatarFactory* avatarFactory() const;
|
---|
119 | void setAvatarFactory(AvatarFactory* av);
|
---|
120 |
|
---|
121 | private:
|
---|
122 | int lastmsgtype;
|
---|
123 | bool v_inList;
|
---|
124 | QDateTime v_t;
|
---|
125 | UserResourceList v_url;
|
---|
126 | QString v_perr;
|
---|
127 | bool v_self, v_isTransport;
|
---|
128 | bool v_private;
|
---|
129 | QStringList secList;
|
---|
130 | QString v_keyID;
|
---|
131 | AvatarFactory* v_avatarFactory;
|
---|
132 |
|
---|
133 | };
|
---|
134 |
|
---|
135 | typedef QPtrListIterator<UserListItem> UserListIt;
|
---|
136 |
|
---|
137 | class UserList : public QPtrList<UserListItem>
|
---|
138 | {
|
---|
139 | public:
|
---|
140 | UserList();
|
---|
141 | ~UserList();
|
---|
142 |
|
---|
143 | UserListItem *find(const XMPP::Jid &);
|
---|
144 | };
|
---|
145 |
|
---|
146 | #endif
|
---|
147 |
|
---|