annotate src/protocols/oscar/newsearch.c @ 5125:74139d2562f5

[gaim-migrate @ 5488] properly handle NULL settings, and hopefully fix a potential buddy icon segfault. I'm sure KingAnt will come up with a better fix for this later committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Mon, 14 Apr 2003 00:53:44 +0000
parents 0b64f386a7b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1 /*
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
2 * Family 0x000f - Newer Search Method
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
3 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
4 * Used for searching for other AIM users by email address, name,
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
5 * location, commmon interests, and a few other similar things.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
6 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
7 */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
8
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
9 #define FAIM_INTERNAL
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
10 #include <aim.h>
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
11
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
12 /**
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
13 * Subtype 0x0002 - Submit a User Search Request
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
14 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
15 * Search for an AIM screen name based on their email address.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
16 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
17 * @param sess The oscar session.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
18 * @param region Should be "us-ascii" unless you know what you're doing.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
19 * @param email The email address you want to search for.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
20 * @return Return 0 if no errors, otherwise return the error number.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
21 */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
22 faim_export int aim_usersearch_email(aim_session_t *sess, const char *region, const char *email)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
23 {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
24 aim_conn_t *conn;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
25 aim_frame_t *fr;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
26 aim_snacid_t snacid;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
27 aim_tlvlist_t *tl = NULL;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
28
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
29 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x000f)) || !region || !email)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
30 return -EINVAL;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
31
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
32 /* Create a TLV chain, write it to the outgoing frame, then free the chain */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
33 aim_addtlvtochain_raw(&tl, 0x001c, strlen(region), region);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
34 aim_addtlvtochain16(&tl, 0x000a, 0x0001); /* Type of search */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
35 aim_addtlvtochain_raw(&tl, 0x0005, strlen(email), email);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
36
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
37 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl))))
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
38 return -ENOMEM;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
39 snacid = aim_cachesnac(sess, 0x000f, 0x0002, 0x0000, NULL, 0);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
40 aim_putsnac(&fr->data, 0x000f, 0x0002, 0x0000, snacid);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
41
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
42 aim_writetlvchain(&fr->data, &tl);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
43 aim_freetlvchain(&tl);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
44
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
45 aim_tx_enqueue(sess, fr);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
46
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
47 return 0;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
48 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
49
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
50
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
51 /**
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
52 * Subtype 0x0002 - Submit a User Search Request
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
53 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
54 * Search for an AIM screen name based on various info
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
55 * about the person.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
56 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
57 * @param sess The oscar session.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
58 * @param region Should be "us-ascii" unless you know what you're doing.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
59 * @param first The first name of the person you want to search for.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
60 * @param middle The middle name of the person you want to search for.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
61 * @param last The last name of the person you want to search for.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
62 * @param maiden The maiden name of the person you want to search for.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
63 * @param nick The nick name of the person you want to search for.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
64 * @param city The city where the person you want to search for resides.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
65 * @param state The state where the person you want to search for resides.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
66 * @param country The country where the person you want to search for resides.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
67 * @param zip The zip code where the person you want to search for resides.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
68 * @param address The street address where the person you want to seach for resides.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
69 * @return Return 0 if no errors, otherwise return the error number.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
70 */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
71 faim_export int aim_usersearch_name(aim_session_t *sess, const char *region, const char *first, const char *middle, const char *last, const char *maiden, const char *nick, const char *city, const char *state, const char *country, const char *zip, const char *address)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
72 {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
73 aim_conn_t *conn;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
74 aim_frame_t *fr;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
75 aim_snacid_t snacid;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
76 aim_tlvlist_t *tl = NULL;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
77
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
78 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x000f)) || !region)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
79 return -EINVAL;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
80
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
81 /* Create a TLV chain, write it to the outgoing frame, then free the chain */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
82 aim_addtlvtochain_raw(&tl, 0x001c, strlen(region), region);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
83 aim_addtlvtochain16(&tl, 0x000a, 0x0000); /* Type of search */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
84 if (first)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
85 aim_addtlvtochain_raw(&tl, 0x0001, strlen(first), first);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
86 if (last)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
87 aim_addtlvtochain_raw(&tl, 0x0002, strlen(last), last);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
88 if (middle)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
89 aim_addtlvtochain_raw(&tl, 0x0003, strlen(middle), middle);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
90 if (maiden)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
91 aim_addtlvtochain_raw(&tl, 0x0004, strlen(maiden), maiden);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
92 if (country)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
93 aim_addtlvtochain_raw(&tl, 0x0006, strlen(country), country);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
94 if (state)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
95 aim_addtlvtochain_raw(&tl, 0x0007, strlen(state), state);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
96 if (city)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
97 aim_addtlvtochain_raw(&tl, 0x0008, strlen(city), city);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
98 if (nick)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
99 aim_addtlvtochain_raw(&tl, 0x000c, strlen(nick), nick);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
100 if (zip)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
101 aim_addtlvtochain_raw(&tl, 0x000d, strlen(zip), zip);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
102 if (address)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
103 aim_addtlvtochain_raw(&tl, 0x0021, strlen(address), address);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
104
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
105 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl))))
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
106 return -ENOMEM;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
107 snacid = aim_cachesnac(sess, 0x000f, 0x0002, 0x0000, NULL, 0);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
108 aim_putsnac(&fr->data, 0x000f, 0x0002, 0x0000, snacid);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
109
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
110 aim_writetlvchain(&fr->data, &tl);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
111 aim_freetlvchain(&tl);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
112
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
113 aim_tx_enqueue(sess, fr);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
114
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
115 return 0;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
116 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
117
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
118
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
119 /**
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
120 * Subtype 0x0002 - Submit a User Search Request
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
121 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
122 * @param sess The oscar session.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
123 * @param interest1 An interest you want to search for.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
124 * @return Return 0 if no errors, otherwise return the error number.
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
125 */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
126 faim_export int aim_usersearch_interest(aim_session_t *sess, const char *region, const char *interest)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
127 {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
128 aim_conn_t *conn;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
129 aim_frame_t *fr;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
130 aim_snacid_t snacid;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
131 aim_tlvlist_t *tl = NULL;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
132
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
133 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x000f)) || !region)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
134 return -EINVAL;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
135
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
136 /* Create a TLV chain, write it to the outgoing frame, then free the chain */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
137 aim_addtlvtochain_raw(&tl, 0x001c, strlen(region), region);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
138 aim_addtlvtochain16(&tl, 0x000a, 0x0001); /* Type of search */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
139 if (interest)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
140 aim_addtlvtochain_raw(&tl, 0x0001, strlen(interest), interest);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
141
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
142 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_sizetlvchain(&tl))))
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
143 return -ENOMEM;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
144 snacid = aim_cachesnac(sess, 0x000f, 0x0002, 0x0000, NULL, 0);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
145 aim_putsnac(&fr->data, 0x000f, 0x0002, 0x0000, snacid);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
146
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
147 aim_writetlvchain(&fr->data, &tl);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
148 aim_freetlvchain(&tl);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
149
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
150 aim_tx_enqueue(sess, fr);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
151
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
152 return 0;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
153 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
154
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
155
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
156 /**
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
157 * Subtype 0x0003 - Receive Reply From a User Search
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
158 *
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
159 */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
160 static int parseresults(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
161 {
4871
0b64f386a7b8 [gaim-migrate @ 5201]
Mark Doliner <mark@kingant.net>
parents: 3952
diff changeset
162 int ret = 0;
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
163 aim_rxcallback_t userfunc;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
164 fu16_t tmp, numresults;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
165 struct aim_usersearch *results = NULL;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
166
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
167 tmp = aimbs_get16(bs); /* Unknown */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
168 tmp = aimbs_get16(bs); /* Unknown */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
169 aim_bstream_advance(bs, tmp);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
170
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
171 numresults = aimbs_get16(bs); /* Number of results to follow */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
172
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
173 /* Allocate a linked list, 1 node per result */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
174 while (numresults) {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
175 struct aim_usersearch *new;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
176 aim_tlvlist_t *tl = aim_readtlvchain_num(bs, aimbs_get16(bs));
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
177 new = (struct aim_usersearch *)malloc(sizeof(struct aim_usersearch));
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
178 new->first = aim_gettlv_str(tl, 0x0001, 1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
179 new->last = aim_gettlv_str(tl, 0x0002, 1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
180 new->middle = aim_gettlv_str(tl, 0x0003, 1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
181 new->maiden = aim_gettlv_str(tl, 0x0004, 1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
182 new->email = aim_gettlv_str(tl, 0x0005, 1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
183 new->country = aim_gettlv_str(tl, 0x0006, 1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
184 new->state = aim_gettlv_str(tl, 0x0007, 1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
185 new->city = aim_gettlv_str(tl, 0x0008, 1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
186 new->sn = aim_gettlv_str(tl, 0x0009, 1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
187 new->interest = aim_gettlv_str(tl, 0x000b, 1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
188 new->nick = aim_gettlv_str(tl, 0x000c, 1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
189 new->zip = aim_gettlv_str(tl, 0x000d, 1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
190 new->region = aim_gettlv_str(tl, 0x001c, 1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
191 new->address = aim_gettlv_str(tl, 0x0021, 1);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
192 new->next = results;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
193 results = new;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
194 numresults--;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
195 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
196
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
197 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
4871
0b64f386a7b8 [gaim-migrate @ 5201]
Mark Doliner <mark@kingant.net>
parents: 3952
diff changeset
198 ret = userfunc(sess, rx, results);
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
199
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
200 /* Now free everything from above */
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
201 while (results) {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
202 struct aim_usersearch *del = results;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
203 results = results->next;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
204 free(del->first);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
205 free(del->last);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
206 free(del->middle);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
207 free(del->maiden);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
208 free(del->email);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
209 free(del->country);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
210 free(del->state);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
211 free(del->city);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
212 free(del->sn);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
213 free(del->interest);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
214 free(del->nick);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
215 free(del->zip);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
216 free(del->region);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
217 free(del->address);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
218 free(del);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
219 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
220
4871
0b64f386a7b8 [gaim-migrate @ 5201]
Mark Doliner <mark@kingant.net>
parents: 3952
diff changeset
221 return ret;
3952
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
222 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
223
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
224 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
225 {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
226
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
227 if (snac->subtype == 0x0003)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
228 return parseresults(sess, mod, rx, snac, bs);
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
229
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
230 return 0;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
231 }
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
232
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
233 faim_internal int newsearch_modfirst(aim_session_t *sess, aim_module_t *mod)
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
234 {
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
235
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
236 mod->family = 0x000f;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
237 mod->version = 0x0001;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
238 mod->toolid = 0x0010;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
239 mod->toolversion = 0x0629;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
240 mod->flags = 0;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
241 strncpy(mod->name, "newsearch", sizeof(mod->name));
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
242 mod->snachandler = snachandler;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
243
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
244 return 0;
07283934dedd [gaim-migrate @ 4133]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
245 }