61650c361f29c818969ff2dd796eeb396d8051cb
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-2006 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()
76 { return name; }
78 /**
79 *
80 */
81 virtual void setName(const DOMString &val)
82 { name = val; }
84 /**
85 *
86 */
87 virtual DOMString getHost()
88 { return host; }
90 /**
91 *
92 */
93 virtual void setHost(const DOMString &val)
94 { host = val; }
96 /**
97 *
98 */
99 virtual int getPort()
100 { return port; }
102 /**
103 *
104 */
105 virtual void setPort(int val)
106 { port = val; }
108 /**
109 *
110 */
111 virtual DOMString getUsername()
112 { return username; }
114 /**
115 *
116 */
117 virtual void setUsername(const DOMString &val)
118 { username = val; }
120 /**
121 *
122 */
123 virtual DOMString getPassword()
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()
221 { return accounts; }
225 private:
227 void init()
228 {
229 }
231 void assign(const XmppConfig &other)
232 {
233 accounts = other.accounts;
234 }
236 std::vector<XmppAccount> accounts;
238 };
243 } //namespace Pedro
245 #endif /* __PEDROCONFIG_H__ */
247 //########################################################################
248 //# E N D O F F I L E
249 //########################################################################