annotate src/protocols/oscar/search.c @ 7166:e6b01bd8d6cd

[gaim-migrate @ 7733] I fixed the notify_added function, Chip had two of the variables swapped :-) I changed the way tlvlists are done in ssi.c a little bit. You can alias ICQ buddies that you don't have authorization for yet, and when you alias a buddy you will no longer lose any Buddy Alerts that may be set. Why is this? Previously tlvlists (data associated with each server stored item) were just deleted and recreated when you set an alias, or changed your permit/deny setting. Now the lists are modified and TLVs that libfaim doesn't know about are just left in place. Why did I wait so long to do this? I'm lazy, it's not really all that fun, and I don't consider it all that important. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 05 Oct 2003 22:41:29 +0000
parents 594682101ba6
children 6d3d8f11e765
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
2 * Family 0x000a - User Search.
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * TODO: Add aim_usersearch_name()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 #define FAIM_INTERNAL
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 #include <aim.h>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
11 /*
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
12 * Subtype 0x0001
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
13 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
14 * XXX can this be integrated with the rest of the error handling?
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
15 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
16 static int error(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
18 int ret = 0;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
19 aim_rxcallback_t userfunc;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
20 aim_snac_t *snac2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
22 /* XXX the modules interface should have already retrieved this for us */
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
23 if (!(snac2 = aim_remsnac(sess, snac->id))) {
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
24 faimdprintf(sess, 2, "search error: couldn't get a snac for 0x%08lx\n", snac->id);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
25 return 0;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
26 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
28 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
29 ret = userfunc(sess, rx, snac2->data /* address */);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
31 /* XXX freesnac()? */
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
32 if (snac2)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
33 free(snac2->data);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
34 free(snac2);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
35
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
36 return ret;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
39 /*
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
40 * Subtype 0x0002
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
41 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
42 */
6879
594682101ba6 [gaim-migrate @ 7425]
Mark Doliner <mark@kingant.net>
parents: 4071
diff changeset
43 faim_export int aim_search_address(aim_session_t *sess, aim_conn_t *conn, const char *address)
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
44 {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
45 aim_frame_t *fr;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
46 aim_snacid_t snacid;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
47
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
48 if (!sess || !conn || !address)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
49 return -EINVAL;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
50
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
51 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+strlen(address))))
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
52 return -ENOMEM;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
53
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
54 snacid = aim_cachesnac(sess, 0x000a, 0x0002, 0x0000, strdup(address), strlen(address)+1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
55 aim_putsnac(&fr->data, 0x000a, 0x0002, 0x0000, snacid);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
56
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
57 aimbs_putraw(&fr->data, address, strlen(address));
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
58
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
59 aim_tx_enqueue(sess, fr);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
60
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
61 return 0;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
62 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
63
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
64 /*
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
65 * Subtype 0x0003
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
66 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents: 2672
diff changeset
67 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
68 static int reply(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 {
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
70 int j = 0, m, ret = 0;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
71 aim_tlvlist_t *tlvlist;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
72 char *cur = NULL, *buf = NULL;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
73 aim_rxcallback_t userfunc;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
74 aim_snac_t *snac2;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
75 char *searchaddr = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
77 if ((snac2 = aim_remsnac(sess, snac->id)))
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
78 searchaddr = (char *)snac2->data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
80 tlvlist = aim_readtlvchain(bs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
81 m = aim_counttlvchain(&tlvlist);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82
7166
e6b01bd8d6cd [gaim-migrate @ 7733]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
83 /* XXX uhm.
e6b01bd8d6cd [gaim-migrate @ 7733]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
84 * This is the only place that uses something other than 1 for the 3rd
e6b01bd8d6cd [gaim-migrate @ 7733]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
85 * parameter to aim_gettlv_whatever().
e6b01bd8d6cd [gaim-migrate @ 7733]
Mark Doliner <mark@kingant.net>
parents: 6879
diff changeset
86 */
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
87 while ((cur = aim_gettlv_str(tlvlist, 0x0001, j+1)) && j < m) {
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
88 buf = realloc(buf, (j+1) * (MAXSNLEN+1));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
90 strncpy(&buf[j * (MAXSNLEN+1)], cur, MAXSNLEN);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
91 free(cur);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
93 j++;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
94 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
96 aim_freetlvchain(&tlvlist);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
98 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
99 ret = userfunc(sess, rx, searchaddr, j, buf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
101 /* XXX freesnac()? */
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
102 if (snac2)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
103 free(snac2->data);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
104 free(snac2);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
106 free(buf);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
108 return ret;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
111 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
114 if (snac->subtype == 0x0001)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
115 return error(sess, mod, rx, snac, bs);
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
116 else if (snac->subtype == 0x0003)
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
117 return reply(sess, mod, rx, snac, bs);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
119 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
122 faim_internal int search_modfirst(aim_session_t *sess, aim_module_t *mod)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
125 mod->family = 0x000a;
2672
c41030cfed76 [gaim-migrate @ 2685]
Adam Fritzler <mid@auk.cx>
parents: 2246
diff changeset
126 mod->version = 0x0001;
c41030cfed76 [gaim-migrate @ 2685]
Adam Fritzler <mid@auk.cx>
parents: 2246
diff changeset
127 mod->toolid = 0x0110;
4071
2532f1192da3 [gaim-migrate @ 4283]
Mark Doliner <mark@kingant.net>
parents: 3952
diff changeset
128 mod->toolversion = 0x0629;
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
129 mod->flags = 0;
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
130 strncpy(mod->name, "search", sizeof(mod->name));
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
131 mod->snachandler = snachandler;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132
2246
933346315b9b [gaim-migrate @ 2256]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2086
diff changeset
133 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 }