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
25 #include "imcontact.h"
26 #include "icqcontact.h"
29 imcontact
contactroot(0, icq
);
31 imcontact::imcontact() {
34 imcontact::imcontact(unsigned long auin
, protocolname apname
) {
39 imcontact::imcontact(const string
&anick
, protocolname apname
) {
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
);
55 r
= r
& (up(stripspaces(ainfo
.nickname
)) == up(stripspaces(nickname
)));
61 r
= r
& (up(ainfo
.nickname
) == up(nickname
));
65 r
= r
& (ainfo
.nickname
== nickname
);
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 {
99 if(!uin
&& nickname
.empty()) r
= "...";
100 else if(uin
) r
= "[" + conf
->getprotocolname(pname
) + "] " + i2str(uin
);
101 else r
= "[" + conf
->getprotocolname(pname
) + "] " + nickname
;
106 string
imstatus2str(imstatus st
) {
107 static map
<imstatus
, string
> mst
;
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
] = "";