1 /*
2  * Copyright (C) 2003  Justin Karneges
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  */
19 
20 #ifndef XMPP_ROSTERITEM_H
21 #define XMPP_ROSTERITEM_H
22 
23 #include <QString>
24 #include <QStringList>
25 
26 #include "xmpp/jid/jid.h"
27 
28 namespace XMPP
29 {
30 	class Subscription
31 	{
32 	public:
33 		enum SubType { None, To, From, Both, Remove };
34 
35 		Subscription(SubType type=None);
36 
37 		int type() const;
38 
39 		QString toString() const;
40 		bool fromString(const QString &);
41 
42 	private:
43 		SubType value;
44 	};
45 
46 	class RosterItem
47 	{
48 	public:
49 		RosterItem(const Jid &jid="");
50 		virtual ~RosterItem();
51 
52 		const Jid & jid() const;
53 		const QString & name() const;
54 		const QStringList & groups() const;
55 		const Subscription & subscription() const;
56 		const QString & ask() const;
57 		bool isPush() const;
58 		bool inGroup(const QString &) const;
59 
60 		virtual void setJid(const Jid &);
61 		void setName(const QString &);
62 		void setGroups(const QStringList &);
63 		void setSubscription(const Subscription &);
64 		void setAsk(const QString &);
65 		void setIsPush(bool);
66 		bool addGroup(const QString &);
67 		bool removeGroup(const QString &);
68 
69 		QDomElement toXml(QDomDocument *) const;
70 		bool fromXml(const QDomElement &);
71 
72 	private:
73 		Jid v_jid;
74 		QString v_name;
75 		QStringList v_groups;
76 		Subscription v_subscription;
77 		QString v_ask;
78 		bool v_push;
79 	};
80 }
81 
82 #endif
83