xml_manager.h

00001 /* 00002 $Id: xml__manager_8h-source.html,v 1.1 2004/10/05 21:12:03 mentat Exp $ 00003 00004 GNU Messenger - The secure instant messenger 00005 00006 Copyright (C) 2003 Jesse Lovelace <jllovela@eos.ncsu.edu> 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 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 // the password has used to encrypt/decrypt to disk 00181 VBuffer m_diskPass; 00182 00183 bool m_isOnline; 00184 }; 00185 00186 } // !GNUMessenger 00187 00188 #endif // !GM_XML_MANAGER_H

Generated on Tue Oct 5 14:41:47 2004 for GNU Messenger by doxygen 1.3.8