connwrap - initialize gnutls session in cw_connect
[centerim.git] / src / imcontact.cc
blobfc694e3441f149e903cc357bd1eedc32f196da0f
1 /*
3 * centerim IM contact basic info class
4 * $Id: imcontact.cc,v 1.21 2005/01/23 13:21:46 konst Exp $
6 * Copyright (C) 2002 by Konstantin Klyagin <k@thekonst.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 * USA
25 #include "imcontact.h"
26 #include "icqcontact.h"
27 #include "icqconf.h"
29 imcontact contactroot(0, icq);
31 imcontact::imcontact() {
34 imcontact::imcontact(unsigned long auin, protocolname apname) {
35 uin = auin;
36 pname = apname;
39 imcontact::imcontact(const string &anick, protocolname apname) {
40 nickname = anick;
41 pname = apname;
42 uin = 0;
45 imcontact::imcontact(const icqcontact *c) {
46 if(c) *this = c->getdesc();
49 bool imcontact::operator == (const imcontact &ainfo) const {
50 bool r = (ainfo.uin == uin) && (ainfo.pname == pname);
52 if(r)
53 switch(pname) {
54 case aim:
55 r = r & (up(stripspaces(ainfo.nickname)) == up(stripspaces(nickname)));
56 break;
58 case irc:
59 case yahoo:
60 case jabber:
61 r = r & (up(ainfo.nickname) == up(nickname));
62 break;
64 default:
65 r = r & (ainfo.nickname == nickname);
66 break;
69 return r;
72 bool imcontact::operator != (const imcontact &ainfo) const {
73 return !(*this == ainfo);
76 bool imcontact::operator < (const imcontact &ainfo) const {
77 return false; /*TODO: fix this to something meaningfull! */
80 bool imcontact::operator == (protocolname apname) const {
81 return apname == pname;
84 bool imcontact::operator != (protocolname apname) const {
85 return !(*this == apname);
88 bool imcontact::operator < (protocolname apname) const {
89 return (*this < apname);
92 bool imcontact::empty() const {
93 return !uin && nickname.empty();
96 string imcontact::totext() const {
97 string r;
99 if(!uin && nickname.empty()) r = "...";
100 else if(uin) r = "[" + conf->getprotocolname(pname) + "] " + i2str(uin);
101 else r = "[" + conf->getprotocolname(pname) + "] " + nickname;
103 return r;
106 string imstatus2str(imstatus st) {
107 static map<imstatus, string> mst;
109 if(mst.empty()) {
110 mst[offline] = _("Offline");
111 mst[available] = _("Online");
112 mst[invisible] = _("Invisible");
113 mst[freeforchat] = _("Free for chat");
114 mst[dontdisturb] = _("Do not disturb");
115 mst[occupied] = _("Occupied");
116 mst[notavail] = _("Not available");
117 mst[away] = _("Away");
118 mst[outforlunch] = _("Out for Lunch");
119 mst[imstatus_size] = "";
122 return mst[st];