annotate plugins/icq/contacts.c @ 1990:7712a8c13b55

[gaim-migrate @ 2000] one more thing i forgot committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 11 Jun 2001 20:40:52 +0000
parents 7b3f1eb1ef7d
children 0be1e533036c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
3 /*
1977
7b3f1eb1ef7d [gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1912
diff changeset
4 * $Id: contacts.c 1987 2001-06-09 14:46:51Z warmenhoven $
7b3f1eb1ef7d [gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1912
diff changeset
5 *
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
6 * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
7 * Bill Soudan <soudan@kde.org>
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
8 *
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
9 * This program is free software; you can redistribute it and/or modify
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
10 * it under the terms of the GNU General Public License as published by
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
12 * (at your option) any later version.
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
13 *
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
14 * This program is distributed in the hope that it will be useful,
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
17 * GNU General Public License for more details.
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
18 *
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
19 * You should have received a copy of the GNU General Public License
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
20 * along with this program; if not, write to the Free Software
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
22 *
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
23 */
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 #include <stdlib.h>
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26
1309
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1152
diff changeset
27 #include "icqlib.h"
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
28
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include "contacts.h"
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
31 icq_ContactItem *icq_ContactNew(icq_Link *icqlink)
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 icq_ContactItem *pcontact=
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 (icq_ContactItem *)malloc(sizeof(icq_ContactItem));
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 if(pcontact)
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
37 pcontact->icqlink=icqlink;
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 return pcontact;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 void icq_ContactDelete(void *p)
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 free(p);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
47 void icq_ContactAdd(icq_Link *icqlink, DWORD cuin)
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 {
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
49 icq_ContactItem *p = icq_ContactNew(icqlink);
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 p->uin = cuin;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 p->vis_list = FALSE;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
53 icq_ListEnqueue(icqlink->d->icq_ContactList, p);
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
56 void icq_ContactRemove(icq_Link *icqlink, DWORD cuin)
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 {
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
58 icq_ContactItem *pcontact=icq_ContactFind(icqlink, cuin);
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 if (pcontact)
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 {
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
62 icq_ListRemove(icqlink->d->icq_ContactList, pcontact);
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 icq_ContactDelete(pcontact);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
67 void icq_ContactClear(icq_Link *icqlink)
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 {
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
69 icq_ListDelete(icqlink->d->icq_ContactList, icq_ContactDelete);
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
70 icqlink->d->icq_ContactList=icq_ListNew();
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 int _icq_ContactFind(void *p, va_list data)
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 {
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 DWORD uin=va_arg(data, DWORD);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 return (((icq_ContactItem *)p)->uin == uin);
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
80 icq_ContactItem *icq_ContactFind(icq_Link *icqlink, DWORD cuin)
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 {
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
82 return icq_ListTraverse(icqlink->d->icq_ContactList, _icq_ContactFind, cuin);
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84
1977
7b3f1eb1ef7d [gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1912
diff changeset
85 void icq_ContactSetVis(icq_Link *icqlink, DWORD cuin, BOOL on)
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 {
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
87 icq_ContactItem *p = icq_ContactFind(icqlink, cuin);
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 if(p)
1977
7b3f1eb1ef7d [gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1912
diff changeset
89 p->vis_list = on;
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91
1977
7b3f1eb1ef7d [gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1912
diff changeset
92 void icq_ContactSetInvis(icq_Link *icqlink, DWORD cuin, BOOL on)
1432
4c510ca3563f [gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1309
diff changeset
93 {
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
94 icq_ContactItem *p = icq_ContactFind(icqlink, cuin);
1432
4c510ca3563f [gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1309
diff changeset
95 if(p)
1977
7b3f1eb1ef7d [gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1912
diff changeset
96 p->invis_list = on;
1432
4c510ca3563f [gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1309
diff changeset
97 }
4c510ca3563f [gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1309
diff changeset
98
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
99 icq_ContactItem *icq_ContactGetFirst(icq_Link *icqlink)
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 {
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
101 return icq_ListFirst(icqlink->d->icq_ContactList);
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 }
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 icq_ContactItem *icq_ContactGetNext(icq_ContactItem *pcontact)
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 {
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
106 icq_ListNode *p=icq_ListFind(pcontact->icqlink->d->icq_ContactList, pcontact);
1152
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 if (p && p->next)
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 return p->next->item;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 else
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 return 0L;
201ec77f3a60 [gaim-migrate @ 1162]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 }