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_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
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