contact_manager.h

00001 /* 00002 $Id: contact__manager_8h-source.html,v 1.1 2004/10/05 21:12:01 mentat Exp $ 00003 00004 GNU Messenger - The secure instant messenger 00005 00006 Copyright (C) 2003-2004 Jesse Lovelace <jesse at aslogicsys dot com> 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_CONTACT_MANAGER_H 00024 #define GM_CONTACT_MANAGER_H 00025 00026 #include <map> 00027 #include "gm/xmlnode.h" 00028 #include "gm/exception.h" 00029 #include "gm/tree.h" 00030 00031 namespace GNUMessenger 00032 { 00033 using namespace std; 00034 00035 class Contact; 00036 00043 class ContactManager 00044 { 00045 public: 00046 ContactManager(XMLNode& xml): m_xml(xml) {} 00047 00049 class InvalidUserName: public Exception 00050 { 00051 public: 00052 InvalidUserName(const string& error): Exception(error) {} 00053 }; 00054 00056 class InvalidFolder: public Exception 00057 { 00058 public: 00059 InvalidFolder(const string& msg): Exception(msg) {} 00060 }; 00061 00063 class InvalidNode: public Exception 00064 { 00065 public: 00066 InvalidNode(const string& msg): Exception(msg) {} 00067 }; 00068 00070 enum Type { FOLDER, BASEFOLDER, CONTACT, CONTACTBASE, PROTOCOL }; 00071 00077 bool addContact(const string& contactname, const string& folder = ""); 00078 00084 bool addContact(const Contact& contact, const string& folder = ""); 00085 00089 bool deleteContact(const string& contactname); 00090 00095 bool moveContact(const string& name, const string& newbase); 00096 00102 bool renameContact(const string& oldname, const string& newname); 00103 00108 Contact getContact(const string& contactname); 00109 00112 vector<Contact> getAllContacts(); 00113 00120 bool setInfo(const string& username, const string& infoname, const string& data, const string& childof = ""); 00121 00126 bool deleteInfo(const string& username, const string& infoname); 00127 00128 string getAvailableName() const; 00129 00130 string getInfo(const string& username, const string& infoname); 00131 map<string, string> getAllInfo(const string& username); 00132 00133 bool addNet(const string& username, const string& netname, const string& login); 00134 bool deleteNet(const string& username, const string& netname); 00135 00136 00137 /* ------- Folder Manipulation --------- */ 00138 bool renameFolder(const string& oldname, const string& newname); 00139 bool addFolder(const string& folder_name, const string& base = ""); 00140 bool deleteFolder(const string& folder_name); 00141 bool moveFolder(const string& name, const string& newbase); 00142 00143 bool folderExists(const string& name) const; 00144 bool contactExists(const string& name) const; 00145 00147 Folder getFolder(const string& name = ""); 00148 00149 void getContactsOfProtocol(const string& protocol, vector<Contact>& contacts); 00150 00152 void deleteAllNets(const string& contactname); 00153 00155 void deleteAllInfo(const string& contactname); 00156 00158 unsigned long getCount(); 00159 00161 string getPublicKey(const string& contactname); 00162 00163 bool getInfoXML(const string& username, XMLNode& xml); 00164 bool setInfoXML(const string& username, const XMLNode& xml); 00165 00166 00168 XMLNode getXML(const string& name); 00169 XMLNode getFolderXML(const string & name); 00170 00171 private: 00172 00173 00174 XMLNode& m_xml; 00175 }; 00176 00177 } 00178 00179 #endif //GM_CONTACT_MANAGER_H

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