Mercurial > pidgin
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 |
rev | line source |
---|---|
1152 | 1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
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 | 24 |
25 #include <stdlib.h> | |
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 | 29 #include "contacts.h" |
30 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
31 icq_ContactItem *icq_ContactNew(icq_Link *icqlink) |
1152 | 32 { |
33 icq_ContactItem *pcontact= | |
34 (icq_ContactItem *)malloc(sizeof(icq_ContactItem)); | |
35 | |
36 if(pcontact) | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
37 pcontact->icqlink=icqlink; |
1152 | 38 |
39 return pcontact; | |
40 } | |
41 | |
42 void icq_ContactDelete(void *p) | |
43 { | |
44 free(p); | |
45 } | |
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 | 48 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
49 icq_ContactItem *p = icq_ContactNew(icqlink); |
1152 | 50 p->uin = cuin; |
51 p->vis_list = FALSE; | |
52 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
53 icq_ListEnqueue(icqlink->d->icq_ContactList, p); |
1152 | 54 } |
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 | 57 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
58 icq_ContactItem *pcontact=icq_ContactFind(icqlink, cuin); |
1152 | 59 |
60 if (pcontact) | |
61 { | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
62 icq_ListRemove(icqlink->d->icq_ContactList, pcontact); |
1152 | 63 icq_ContactDelete(pcontact); |
64 } | |
65 } | |
66 | |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
67 void icq_ContactClear(icq_Link *icqlink) |
1152 | 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 | 71 } |
72 | |
73 int _icq_ContactFind(void *p, va_list data) | |
74 { | |
75 DWORD uin=va_arg(data, DWORD); | |
76 | |
77 return (((icq_ContactItem *)p)->uin == uin); | |
78 } | |
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 | 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 | 83 } |
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 | 86 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
87 icq_ContactItem *p = icq_ContactFind(icqlink, cuin); |
1152 | 88 if(p) |
1977
7b3f1eb1ef7d
[gaim-migrate @ 1987]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1912
diff
changeset
|
89 p->vis_list = on; |
1152 | 90 } |
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 | 100 { |
1912
8ed70631ed15
[gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1432
diff
changeset
|
101 return icq_ListFirst(icqlink->d->icq_ContactList); |
1152 | 102 } |
103 | |
104 icq_ContactItem *icq_ContactGetNext(icq_ContactItem *pcontact) | |
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 | 107 |
108 if (p && p->next) | |
109 return p->next->item; | |
110 else | |
111 return 0L; | |
112 } |