00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#ifndef GM_XML_MANAGER_H
00024
#define GM_XML_MANAGER_H
00025
00026
#include "gm/xmlnode.h"
00027
#include "gm/buffer.h"
00028
00029
namespace GNUMessenger
00030 {
00031
class ContactManager;
00032
class SettingsManager;
00033
00041 class XMLManager
00042 {
00043
public:
00044
00048 class InvalidData:
public Exception
00049 {
00050
public:
00051
InvalidData(
const string& msg):
Exception(msg) {}
00052 };
00053
00056 class DiskError:
public Exception
00057 {
00058
public:
00059
DiskError(
const string& msg):
Exception(msg) {}
00060 };
00061
00065 class AuthError:
public Exception
00066 {
00067
public:
00068
AuthError(
const string& msg):
Exception(msg) {}
00069 };
00070
00074 class PasswordError:
public Exception
00075 {
00076
public:
00077
PasswordError(
const string& msg):
Exception(msg) {}
00078 };
00079
00080
XMLManager(
const string& directory =
"");
00081
00083
~XMLManager();
00084
00088
bool createNew(
const string& username,
const VBuffer& password);
00089
00093
static bool setDirectory(
const string& dir);
00094
00096 static const string&
getDirectory() {
return m_directory; }
00097
00104
bool login(
const string & username,
const VBuffer &password);
00105
00108
bool logout();
00109
00111 string
getFileName(
const string& username)
const;
00112
00114
static bool search(
const string& dataToFind,
00115
const string& tagName,
00116
XMLNode& parentNode,
00117
XMLNode& returnNode);
00118
00120
static bool baseSearch(
const string& dataToFind,
00121
const string& tagName,
00122
XMLNode& parentNode,
00123
XMLNode& realParent,
00124
unsigned int& num);
00125
00127
static unsigned int tagCount(
const string& findType,
const XMLNode& parentNode) ;
00128
00130
static void getAllTags(
const string& findType,
XMLNode& parentNode, vector<XMLNode> &result_vector);
00131
00133
static string
printTree(
const XMLNode& base);
00134
00138
bool commit();
00139
00143
static bool exists(
const string& username);
00144
00145
static bool isDirectory(
const string& dirname);
00146
00148
bool setPassword(
const VBuffer& password);
00149
00151 string
getLogin() const;
00152
00154 bool isOK() {
return m_isOnline; }
00155
00157 string
encode(
const string & inbound);
00158
00160 string
decode(
const string & inbound);
00161
00162
XMLNode& returnXML() {
return m_xml; }
00163
00164 ContactManager& contacts() {
return *m_contactManager; }
00165 SettingsManager& settings() {
return *m_settingsManager; }
00166
00167
private:
00168
00169 auto_ptr<SettingsManager> m_settingsManager;
00170 auto_ptr<ContactManager> m_contactManager;
00171
00173 XMLNode m_xml;
00174
00176
static string m_directory;
00178 string m_filename;
00179
00180
00181 VBuffer m_diskPass;
00182
00183
bool m_isOnline;
00184 };
00185
00186 }
00187
00188
#endif // !GM_XML_MANAGER_H