~ubuntu-branches/ubuntu/jaunty/psi/jaunty

« back to all changes in this revision

Viewing changes to src/userlist.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2005-01-10 17:41:43 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050110174143-ltocv5zapl6blf5d
Tags: 0.9.3-1
* New upstream release
* Cleaned up debian/rules (some things are done by upstream Makefiles now)
* Fixed some lintian warnings:
  - removed executable bit from some .png files
  - moved psi.desktop to /usr/share/applications
* Updated menu files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
** userlist.h - higher-level version of JabRoster
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 program; if not, write to the Free Software
17
 
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 
**
19
 
****************************************************************************/
 
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
20
 
21
21
#ifndef USERLIST_H
22
22
#define USERLIST_H
23
23
 
24
 
#include<qptrlist.h>
25
24
#include<qstring.h>
26
25
#include<qdatetime.h>
27
 
#include"jabcommon.h"
28
 
#include"common.h"
29
 
#include"message.h"
30
 
 
31
 
#define USERLIST_CONTACTS       1
32
 
#define USERLIST_SERVICES       2
33
 
 
34
 
#define USERLIST_ALL            3
35
 
 
36
 
 
37
 
class UserListItem
38
 
{
39
 
public:
40
 
        UserListItem();
 
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);
41
84
        ~UserListItem();
42
85
 
43
 
        QString jid;
44
 
        QString nick;
45
 
        QString group;
46
 
        QString sub;
47
 
        int state;
48
 
        QString statusString;
49
 
        bool inList;
50
 
        bool isTransport;
51
 
 
52
 
        JabResourceList res;
53
 
};
54
 
 
55
 
class UserList
56
 
{
57
 
public:
58
 
        UserList();
59
 
        ~UserList();
60
 
 
61
 
        int size();
62
 
        void add(UserListItem *);
63
 
        void remove(UserListItem *);
64
 
        void remove(QString &jid);
65
 
        UserListItem *findByJid(const QString &jid);
66
 
        UserListItem *findServiceByJid(const QString &jid);
67
 
        UserListItem *findAnyByJid(const QString &jid);
68
 
        void clear();
69
 
        //int allQueuesEmpty();
70
 
 
71
 
        UserListItem *start(int);
72
 
        UserListItem *next();
73
 
        void end();
 
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);
74
120
 
75
121
private:
76
 
        void advanceTo();
 
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;
77
132
 
78
 
        int num;
79
 
        QPtrList<UserListItem> list;
80
 
        QPtrListIterator<UserListItem> *it;
81
 
        int searchtype;
82
133
};
83
134
 
84
 
class Account
 
135
typedef QPtrListIterator<UserListItem> UserListIt;
 
136
 
 
137
class UserList : public QPtrList<UserListItem>
85
138
{
86
139
public:
87
 
        Account();
88
 
 
89
 
        QString jid() const;
90
 
 
91
 
        QString user, pass, host, resource;
92
 
        int port, priority;
 
140
        UserList();
 
141
        ~UserList();
 
142
 
 
143
        UserListItem *find(const XMPP::Jid &);
93
144
};
94
145
 
95
146
#endif
 
147