1 #ifndef __PEDROCONFIG_H__
2 #define __PEDROCONFIG_H__
3 /*
4 * Implementation the Pedro mini-XMPP client
5 *
6 * Authors:
7 * Bob Jamison
8 *
9 * Copyright (C) 2005-2007 Bob Jamison
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
28 #include "pedrodom.h"
29 #include "pedroxmpp.h"
31 #include <vector>
35 namespace Pedro
36 {
39 /**
40 * Individual account record
41 */
42 class XmppAccount
43 {
45 public:
47 /**
48 *
49 */
50 XmppAccount()
51 { init(); }
53 /**
54 *
55 */
56 XmppAccount(const XmppAccount &other)
57 { assign(other); }
59 /**
60 *
61 */
62 XmppAccount operator=(const XmppAccount &other)
63 { assign(other); return *this; }
65 /**
66 *
67 */
68 virtual ~XmppAccount()
69 {}
72 /**
73 *
74 */
75 virtual DOMString getName() const
76 { return name; }
78 /**
79 *
80 */
81 virtual void setName(const DOMString &val)
82 { name = val; }
84 /**
85 *
86 */
87 virtual DOMString getHost() const
88 { return host; }
90 /**
91 *
92 */
93 virtual void setHost(const DOMString &val)
94 { host = val; }
96 /**
97 *
98 */
99 virtual int getPort() const
100 { return port; }
102 /**
103 *
104 */
105 virtual void setPort(int val)
106 { port = val; }
108 /**
109 *
110 */
111 virtual DOMString getUsername() const
112 { return username; }
114 /**
115 *
116 */
117 virtual void setUsername(const DOMString &val)
118 { username = val; }
120 /**
121 *
122 */
123 virtual DOMString getPassword() const
124 { return password; }
126 /**
127 *
128 */
129 virtual void setPassword(const DOMString &val)
130 { password = val; }
134 private:
136 void init()
137 {
138 name = "noname";
139 host = "jabber.org";
140 port = 5222;
141 username = "nobody";
142 password = "nopass";
143 }
145 void assign(const XmppAccount &other)
146 {
147 name = other.name;
148 host = other.host;
149 port = other.port;
150 username = other.username;
151 password = other.password;
152 }
154 DOMString name;
155 DOMString host;
156 int port;
157 DOMString username;
158 DOMString password;
160 };
164 /**
165 * Configuration record
166 */
167 class XmppConfig : XmppEventTarget
168 {
170 public:
172 /**
173 *
174 */
175 XmppConfig()
176 { init(); }
178 /**
179 *
180 */
181 XmppConfig(const XmppConfig &other)
182 { assign(other); }
184 /**
185 *
186 */
187 virtual XmppConfig &operator=(const XmppConfig &other)
188 { assign(other); return *this; }
190 /**
191 *
192 */
193 virtual ~XmppConfig()
194 {}
197 /**
198 * Parse a configuration xml chunk from a memory buffer
199 */
200 virtual bool read(const DOMString &buffer);
202 /**
203 * Parse a configuration file
204 */
205 virtual bool readFile(const DOMString &fileName);
207 /**
208 * Ouputs this object as a string formatted in XML
209 */
210 virtual DOMString toXmlBuffer();
212 /**
213 * Write a configuration file
214 */
215 virtual bool writeFile(const DOMString &fileName);
217 /**
218 *
219 */
220 virtual std::vector<XmppAccount> &getAccounts();
222 /**
223 *
224 */
225 virtual DOMString getMucGroup();
227 /**
228 *
229 */
230 virtual void setMucGroup(const DOMString &val);
232 /**
233 *
234 */
235 virtual DOMString getMucHost();
237 /**
238 *
239 */
240 virtual void setMucHost(const DOMString &val);
242 /**
243 *
244 */
245 virtual DOMString getMucNick();
247 /**
248 *
249 */
250 virtual void setMucNick(const DOMString &val);
252 /**
253 *
254 */
255 virtual DOMString getMucPassword();
257 /**
258 *
259 */
260 virtual void setMucPassword(const DOMString &val);
262 /**
263 *
264 */
265 virtual bool accountAdd(const XmppAccount &account);
267 /**
268 *
269 */
270 virtual bool accountExists(const DOMString &accountName);
272 /**
273 *
274 */
275 virtual void accountRemove(const DOMString &accountName);
277 /**
278 *
279 */
280 bool accountFind(const DOMString &accountName,
281 XmppAccount &retVal);
284 private:
286 void init()
287 {
288 }
290 void assign(const XmppConfig &other)
291 {
292 accounts = other.accounts;
293 }
295 //# Group stuff
296 DOMString mucGroup;
298 DOMString mucHost;
300 DOMString mucNick;
302 DOMString mucPassword;
304 std::vector<XmppAccount> accounts;
306 };
311 } //namespace Pedro
313 #endif /* __PEDROCONFIG_H__ */
315 //########################################################################
316 //# E N D O F F I L E
317 //########################################################################