~ubuntu-branches/ubuntu/hoary/psi/hoary

« back to all changes in this revision

Viewing changes to src/userlist.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2004-06-15 00:10:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040615001041-enywb6pcpe4sjsw6
Tags: 0.9.2-1
* New upstream release
* Set KDEDIR for ./configure so kde specific files get installed
* Don't install libpsiwidgets.so. It got installed in /usr/share
  where it doesn't belong. May be included (at a better location)
  later.

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 UserResource : public XMPP::Resource
 
30
{
 
31
public:
 
32
        UserResource();
 
33
        UserResource(const XMPP::Resource &);
 
34
        ~UserResource();
 
35
 
 
36
        void setResource(const XMPP::Resource &);
 
37
 
 
38
        const QString & versionString() const;
 
39
        void setVersionString(const QString &);
 
40
 
 
41
        const QString & publicKeyID() const;
 
42
        int pgpVerifyStatus() const;
 
43
        QDateTime sigTimestamp() const;
 
44
        void setPublicKeyID(const QString &);
 
45
        void setPGPVerifyStatus(int);
 
46
        void setSigTimestamp(const QDateTime &);
 
47
 
 
48
private:
 
49
        QString v_ver, v_keyID;
 
50
        int v_pgpVerifyStatus;
 
51
        QDateTime sigts;
 
52
};
 
53
 
 
54
bool operator<(const UserResource &r1, const UserResource &r2);
 
55
bool operator<=(const UserResource &r1, const UserResource &r2);
 
56
bool operator==(const UserResource &r1, const UserResource &r2);
 
57
bool operator>(const UserResource &r1, const UserResource &r2);
 
58
bool operator>=(const UserResource &r1, const UserResource &r2);
 
59
 
 
60
class UserResourceList : public QValueList<UserResource>
 
61
{
 
62
public:
 
63
        UserResourceList();
 
64
        ~UserResourceList();
 
65
 
 
66
        void sort();
 
67
 
 
68
        UserResourceList::Iterator find(const QString &);
 
69
        UserResourceList::Iterator priority();
 
70
 
 
71
        UserResourceList::ConstIterator find(const QString &) const;
 
72
        UserResourceList::ConstIterator priority() const;
 
73
};
 
74
 
 
75
class UserListItem : public XMPP::LiveRosterItem
 
76
{
 
77
public:
 
78
        UserListItem(bool self=false);
41
79
        ~UserListItem();
42
80
 
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();
 
81
        bool inList() const;
 
82
        bool isTransport() const;
 
83
        bool isAvailable() const;
 
84
        bool isHidden() const;
 
85
        bool isAway() const;
 
86
        QDateTime lastAvailable() const;
 
87
        int lastMessageType() const;
 
88
        void setLastMessageType(const int mtype);
 
89
        const QString & presenceError() const;
 
90
        bool isSelf() const;
 
91
        QString makeTip(bool trim = true, bool doLinkify = true) const;
 
92
        QString makeDesc() const;
 
93
        bool isPrivate() const;
 
94
 
 
95
        void setJid(const XMPP::Jid &);
 
96
        void setInList(bool);
 
97
        void setLastAvailable(const QDateTime &);
 
98
        void setPresenceError(const QString &);
 
99
        void setPrivate(bool);
 
100
 
 
101
        UserResourceList & userResourceList();
 
102
        UserResourceList::Iterator priority();
 
103
        const UserResourceList & userResourceList() const;
 
104
        UserResourceList::ConstIterator priority() const;
 
105
 
 
106
        bool isSecure(const QString &rname) const;
 
107
        void setSecure(const QString &rname, bool);
 
108
 
 
109
        const QString & publicKeyID() const;
 
110
        void setPublicKeyID(const QString &);
74
111
 
75
112
private:
76
 
        void advanceTo();
77
 
 
78
 
        int num;
79
 
        QPtrList<UserListItem> list;
80
 
        QPtrListIterator<UserListItem> *it;
81
 
        int searchtype;
 
113
        int lastmsgtype;
 
114
        bool v_inList;
 
115
        QDateTime v_t;
 
116
        UserResourceList v_url;
 
117
        QString v_perr;
 
118
        bool v_self, v_isTransport;
 
119
        bool v_private;
 
120
        QStringList secList;
 
121
        QString v_keyID;
82
122
};
83
123
 
84
 
class Account
 
124
typedef QPtrListIterator<UserListItem> UserListIt;
 
125
 
 
126
class UserList : public QPtrList<UserListItem>
85
127
{
86
128
public:
87
 
        Account();
88
 
 
89
 
        QString jid() const;
90
 
 
91
 
        QString user, pass, host, resource;
92
 
        int port, priority;
 
129
        UserList();
 
130
        ~UserList();
 
131
 
 
132
        UserListItem *find(const XMPP::Jid &);
93
133
};
94
134
 
95
135
#endif
 
136