00001
#ifndef GM_CONTACT_H
00002
#define GM_CONTACT_H
00003
00004
#include <string>
00005
#include <map>
00006
#include "gm/xmlnode.h"
00007
#include "gm/exception.h"
00008
00009
namespace GNUMessenger
00010 {
00011
using namespace std;
00012
00021 class Contact:
public XMLNode
00022 {
00023
public:
00024
class ContactError:
public Exception
00025 {
00026
public:
00027 ContactError(
const string& error):
Exception(error) {}
00028 };
00029
00031
Contact();
00032
00037
Contact(
const Contact& contact);
00038
00044
Contact(
const XMLNode &config);
00045
00047 virtual ~Contact() {}
00048
00051 enum Status {
00052
Offline,
00053
Online,
00054
Away,
00055
Occupied,
00056
DND,
00057
NA,
00058
FFC,
00059
Error,
00060 Custom
00061 };
00062
00065
bool isOK() const;
00066
00067
void Destroy();
00068
00071
bool isOnline() const;
00072
00075
void addProtocol(const string& proto);
00076
00079
void removeProtocol(const string& proto);
00080
00083 virtual
XMLNode& setName(const string &name) {
setProperty(
"name",name);
return *
this; }
00084
00087 virtual const string&
name()
const { m_name =
property(
"name");
return m_name; }
00088
00090 virtual const string
type()
const {
return "contact"; }
00091
00098 string
getProtocol() const;
00099
00101
bool hasProtocol(const string& str) const;
00102
00108
void setServerId(const string& proto, const string&
id);
00109
00113 string getServerId( const string& proto ) const;
00114
00119
void setStatus(const string& proto, Status state);
00120
00124 Status getStatus(const string& proto) const;
00125
00126 Status getOverallStatus() const;
00127
00130
Contact& operator=(const
Contact &other);
00131
00133 friend
bool operator !=(const
Contact& lhs, const
Contact& rhs);
00135 friend
bool operator ==(const
Contact& lhs, const
Contact& rhs);
00137 friend
bool operator < (const
Contact& lhs, const
Contact& c2);
00138
00140 friend class
ContactManager;
00141
00142 private:
00143 mutable string m_name;
00145 map<string, Status> m_session;
00146 };
00147 }
00148
00149 #endif