3 * centerim IM contacts group class
4 * $Id: icqgroup.cc,v 1.9 2005/01/30 22:21:34 konst Exp $
6 * Copyright (C) 2001 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
26 #include "icqgroups.h"
27 #include "abstracthook.h"
29 icqgroup::icqgroup(int aid
, const string
&aname
) {
35 icqgroup::~icqgroup() {
38 int icqgroup::getcount(bool countonline
, bool countoffline
) {
41 for(i
= counter
= 0; i
< clist
.count
; i
++) {
42 icqcontact
*c
= (icqcontact
*) clist
.at(i
);
44 if(c
->getgroupid() == id
) {
45 if(countoffline
&& c
->getstatus() == offline
) counter
++;
46 if(countonline
&& c
->getstatus() != offline
) counter
++;
53 void icqgroup::moveup() {
57 if(find(groups
.begin(), groups
.end(), nid
) != groups
.end()) break;
61 if(nid
> 0) exchange(nid
);
64 void icqgroup::movedown() {
66 int fid
= (groups
.end()-1)->id
;
69 if(find(groups
.begin(), groups
.end(), nid
) != groups
.end()) break;
73 if(nid
<= fid
) exchange(nid
);
76 void icqgroup::exchange(int nid
) {
79 vector
<icqgroup
>::iterator ig
;
81 ig
= find(groups
.begin(), groups
.end(), nid
);
83 if(ig
!= groups
.end()) {
84 for(i
= 0; i
< clist
.count
; i
++) {
85 c
= (icqcontact
*) clist
.at(i
);
87 if(c
->getgroupid() == id
) c
->setgroupid(nid
, false); else
88 if(c
->getgroupid() == nid
) c
->setgroupid(id
, false);
96 void icqgroup::rename(const string
&aname
) {
97 string oldname
= name
;
100 for(protocolname pname
= icq
; pname
!= protocolname_size
; pname
++)
101 gethook(pname
).renamegroup(oldname
, name
);