Mercurial > pidgin
comparison src/protocols/oscar/family_odir.c @ 13592:6519aeb66b31
[gaim-migrate @ 15978]
Holy cow this is crazy.
34 files changed, 5760 insertions(+), 8517 deletions(-)
* Non-blocking I/O for all of oscar. That includes normal FLAP
connections as well as file transfers and direct IM.
* Kick-ass file transfer and direct IM. Either party can request
the connection. Gaim will try both the "public" IP and the
"client" IP. It'll fall back to transferring through a proxy
if that fails. Should be relatively few memleaks (I didn't
have a lot of confidence in the non-memleakiness of the old
code). And the code is reasonably generic, so it shouldn't
be too much work to add voice chat. This might still be a
LITTLE buggy, but it shouldn't be too bad. If anything, file
transfer will be more buggy than direct IM. And sending a
file will be more buggy than receiving a file. Bug reports
with a series of steps to reproduce are welcome.
* I merged OscarData and aim_session_t
* Somewhere between 50 and 100 hours of work.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 07 Apr 2006 05:10:56 +0000 |
parents | 87a7c3077c19 |
children |
comparison
equal
deleted
inserted
replaced
13591:dcfda39ad547 | 13592:6519aeb66b31 |
---|---|
31 /** | 31 /** |
32 * Subtype 0x0002 - Submit a User Search Request | 32 * Subtype 0x0002 - Submit a User Search Request |
33 * | 33 * |
34 * Search for an AIM screen name based on their email address. | 34 * Search for an AIM screen name based on their email address. |
35 * | 35 * |
36 * @param sess The oscar session. | 36 * @param od The oscar session. |
37 * @param region Should be "us-ascii" unless you know what you're doing. | 37 * @param region Should be "us-ascii" unless you know what you're doing. |
38 * @param email The email address you want to search for. | 38 * @param email The email address you want to search for. |
39 * @return Return 0 if no errors, otherwise return the error number. | 39 * @return Return 0 if no errors, otherwise return the error number. |
40 */ | 40 */ |
41 faim_export int aim_odir_email(OscarSession *sess, const char *region, const char *email) | 41 int aim_odir_email(OscarData *od, const char *region, const char *email) |
42 { | 42 { |
43 OscarConnection *conn; | 43 FlapConnection *conn; |
44 FlapFrame *fr; | 44 FlapFrame *frame; |
45 aim_snacid_t snacid; | 45 aim_snacid_t snacid; |
46 aim_tlvlist_t *tl = NULL; | 46 aim_tlvlist_t *tl = NULL; |
47 | 47 |
48 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x000f)) || !region || !email) | 48 if (!od || !(conn = flap_connection_findbygroup(od, 0x000f)) || !region || !email) |
49 return -EINVAL; | 49 return -EINVAL; |
50 | 50 |
51 /* Create a TLV chain, write it to the outgoing frame, then free the chain */ | 51 /* Create a TLV chain, write it to the outgoing frame, then free the chain */ |
52 aim_tlvlist_add_str(&tl, 0x001c, region); | 52 aim_tlvlist_add_str(&tl, 0x001c, region); |
53 aim_tlvlist_add_16(&tl, 0x000a, 0x0001); /* Type of search */ | 53 aim_tlvlist_add_16(&tl, 0x000a, 0x0001); /* Type of search */ |
54 aim_tlvlist_add_str(&tl, 0x0005, email); | 54 aim_tlvlist_add_str(&tl, 0x0005, email); |
55 | 55 |
56 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_tlvlist_size(&tl)))) | 56 frame = flap_frame_new(od, 0x02, 10+aim_tlvlist_size(&tl)); |
57 return -ENOMEM; | 57 snacid = aim_cachesnac(od, 0x000f, 0x0002, 0x0000, NULL, 0); |
58 snacid = aim_cachesnac(sess, 0x000f, 0x0002, 0x0000, NULL, 0); | 58 aim_putsnac(&frame->data, 0x000f, 0x0002, 0x0000, snacid); |
59 aim_putsnac(&fr->data, 0x000f, 0x0002, 0x0000, snacid); | 59 |
60 | 60 aim_tlvlist_write(&frame->data, &tl); |
61 aim_tlvlist_write(&fr->data, &tl); | |
62 aim_tlvlist_free(&tl); | 61 aim_tlvlist_free(&tl); |
63 | 62 |
64 aim_tx_enqueue(sess, fr); | 63 flap_connection_send(conn, frame); |
65 | 64 |
66 return 0; | 65 return 0; |
67 } | 66 } |
68 | 67 |
69 | 68 |
71 * Subtype 0x0002 - Submit a User Search Request | 70 * Subtype 0x0002 - Submit a User Search Request |
72 * | 71 * |
73 * Search for an AIM screen name based on various info | 72 * Search for an AIM screen name based on various info |
74 * about the person. | 73 * about the person. |
75 * | 74 * |
76 * @param sess The oscar session. | 75 * @param od The oscar session. |
77 * @param region Should be "us-ascii" unless you know what you're doing. | 76 * @param region Should be "us-ascii" unless you know what you're doing. |
78 * @param first The first name of the person you want to search for. | 77 * @param first The first name of the person you want to search for. |
79 * @param middle The middle name of the person you want to search for. | 78 * @param middle The middle name of the person you want to search for. |
80 * @param last The last name of the person you want to search for. | 79 * @param last The last name of the person you want to search for. |
81 * @param maiden The maiden name of the person you want to search for. | 80 * @param maiden The maiden name of the person you want to search for. |
85 * @param country The country where the person you want to search for resides. | 84 * @param country The country where the person you want to search for resides. |
86 * @param zip The zip code where the person you want to search for resides. | 85 * @param zip The zip code where the person you want to search for resides. |
87 * @param address The street address where the person you want to seach for resides. | 86 * @param address The street address where the person you want to seach for resides. |
88 * @return Return 0 if no errors, otherwise return the error number. | 87 * @return Return 0 if no errors, otherwise return the error number. |
89 */ | 88 */ |
90 faim_export int aim_odir_name(OscarSession *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) | 89 int aim_odir_name(OscarData *od, 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) |
91 { | 90 { |
92 OscarConnection *conn; | 91 FlapConnection *conn; |
93 FlapFrame *fr; | 92 FlapFrame *frame; |
94 aim_snacid_t snacid; | 93 aim_snacid_t snacid; |
95 aim_tlvlist_t *tl = NULL; | 94 aim_tlvlist_t *tl = NULL; |
96 | 95 |
97 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x000f)) || !region) | 96 if (!od || !(conn = flap_connection_findbygroup(od, 0x000f)) || !region) |
98 return -EINVAL; | 97 return -EINVAL; |
99 | 98 |
100 /* Create a TLV chain, write it to the outgoing frame, then free the chain */ | 99 /* Create a TLV chain, write it to the outgoing frame, then free the chain */ |
101 aim_tlvlist_add_str(&tl, 0x001c, region); | 100 aim_tlvlist_add_str(&tl, 0x001c, region); |
102 aim_tlvlist_add_16(&tl, 0x000a, 0x0000); /* Type of search */ | 101 aim_tlvlist_add_16(&tl, 0x000a, 0x0000); /* Type of search */ |
119 if (zip) | 118 if (zip) |
120 aim_tlvlist_add_str(&tl, 0x000d, zip); | 119 aim_tlvlist_add_str(&tl, 0x000d, zip); |
121 if (address) | 120 if (address) |
122 aim_tlvlist_add_str(&tl, 0x0021, address); | 121 aim_tlvlist_add_str(&tl, 0x0021, address); |
123 | 122 |
124 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_tlvlist_size(&tl)))) | 123 frame = flap_frame_new(od, 0x02, 10+aim_tlvlist_size(&tl)); |
125 return -ENOMEM; | 124 snacid = aim_cachesnac(od, 0x000f, 0x0002, 0x0000, NULL, 0); |
126 snacid = aim_cachesnac(sess, 0x000f, 0x0002, 0x0000, NULL, 0); | 125 aim_putsnac(&frame->data, 0x000f, 0x0002, 0x0000, snacid); |
127 aim_putsnac(&fr->data, 0x000f, 0x0002, 0x0000, snacid); | 126 |
128 | 127 aim_tlvlist_write(&frame->data, &tl); |
129 aim_tlvlist_write(&fr->data, &tl); | |
130 aim_tlvlist_free(&tl); | 128 aim_tlvlist_free(&tl); |
131 | 129 |
132 aim_tx_enqueue(sess, fr); | 130 flap_connection_send(conn, frame); |
133 | 131 |
134 return 0; | 132 return 0; |
135 } | 133 } |
136 | 134 |
137 | 135 |
138 /** | 136 /** |
139 * Subtype 0x0002 - Submit a User Search Request | 137 * Subtype 0x0002 - Submit a User Search Request |
140 * | 138 * |
141 * @param sess The oscar session. | 139 * @param od The oscar session. |
142 * @param interest1 An interest you want to search for. | 140 * @param interest1 An interest you want to search for. |
143 * @return Return 0 if no errors, otherwise return the error number. | 141 * @return Return 0 if no errors, otherwise return the error number. |
144 */ | 142 */ |
145 faim_export int aim_odir_interest(OscarSession *sess, const char *region, const char *interest) | 143 int aim_odir_interest(OscarData *od, const char *region, const char *interest) |
146 { | 144 { |
147 OscarConnection *conn; | 145 FlapConnection *conn; |
148 FlapFrame *fr; | 146 FlapFrame *frame; |
149 aim_snacid_t snacid; | 147 aim_snacid_t snacid; |
150 aim_tlvlist_t *tl = NULL; | 148 aim_tlvlist_t *tl = NULL; |
151 | 149 |
152 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x000f)) || !region) | 150 if (!od || !(conn = flap_connection_findbygroup(od, 0x000f)) || !region) |
153 return -EINVAL; | 151 return -EINVAL; |
154 | 152 |
155 /* Create a TLV chain, write it to the outgoing frame, then free the chain */ | 153 /* Create a TLV chain, write it to the outgoing frame, then free the chain */ |
156 aim_tlvlist_add_str(&tl, 0x001c, region); | 154 aim_tlvlist_add_str(&tl, 0x001c, region); |
157 aim_tlvlist_add_16(&tl, 0x000a, 0x0001); /* Type of search */ | 155 aim_tlvlist_add_16(&tl, 0x000a, 0x0001); /* Type of search */ |
158 if (interest) | 156 if (interest) |
159 aim_tlvlist_add_str(&tl, 0x0001, interest); | 157 aim_tlvlist_add_str(&tl, 0x0001, interest); |
160 | 158 |
161 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10+aim_tlvlist_size(&tl)))) | 159 frame = flap_frame_new(od, 0x02, 10+aim_tlvlist_size(&tl)); |
162 return -ENOMEM; | 160 snacid = aim_cachesnac(od, 0x000f, 0x0002, 0x0000, NULL, 0); |
163 snacid = aim_cachesnac(sess, 0x000f, 0x0002, 0x0000, NULL, 0); | 161 aim_putsnac(&frame->data, 0x000f, 0x0002, 0x0000, snacid); |
164 aim_putsnac(&fr->data, 0x000f, 0x0002, 0x0000, snacid); | 162 |
165 | 163 aim_tlvlist_write(&frame->data, &tl); |
166 aim_tlvlist_write(&fr->data, &tl); | |
167 aim_tlvlist_free(&tl); | 164 aim_tlvlist_free(&tl); |
168 | 165 |
169 aim_tx_enqueue(sess, fr); | 166 flap_connection_send(conn, frame); |
170 | 167 |
171 return 0; | 168 return 0; |
172 } | 169 } |
173 | 170 |
174 | 171 |
175 /** | 172 /** |
176 * Subtype 0x0003 - Receive Reply From a User Search | 173 * Subtype 0x0003 - Receive Reply From a User Search |
177 * | 174 * |
178 */ | 175 */ |
179 static int parseresults(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 176 static int parseresults(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
180 { | 177 { |
181 int ret = 0; | 178 int ret = 0; |
182 aim_rxcallback_t userfunc; | 179 aim_rxcallback_t userfunc; |
183 guint16 tmp, numresults; | 180 guint16 tmp, numresults; |
184 struct aim_odir *results = NULL; | 181 struct aim_odir *results = NULL; |
185 | 182 |
186 tmp = aimbs_get16(bs); /* Unknown */ | 183 tmp = byte_stream_get16(bs); /* Unknown */ |
187 tmp = aimbs_get16(bs); /* Unknown */ | 184 tmp = byte_stream_get16(bs); /* Unknown */ |
188 aim_bstream_advance(bs, tmp); | 185 byte_stream_advance(bs, tmp); |
189 | 186 |
190 numresults = aimbs_get16(bs); /* Number of results to follow */ | 187 numresults = byte_stream_get16(bs); /* Number of results to follow */ |
191 | 188 |
192 /* Allocate a linked list, 1 node per result */ | 189 /* Allocate a linked list, 1 node per result */ |
193 while (numresults) { | 190 while (numresults) { |
194 struct aim_odir *new; | 191 struct aim_odir *new; |
195 aim_tlvlist_t *tl = aim_tlvlist_readnum(bs, aimbs_get16(bs)); | 192 aim_tlvlist_t *tl = aim_tlvlist_readnum(bs, byte_stream_get16(bs)); |
196 new = (struct aim_odir *)malloc(sizeof(struct aim_odir)); | 193 new = (struct aim_odir *)malloc(sizeof(struct aim_odir)); |
197 new->first = aim_tlv_getstr(tl, 0x0001, 1); | 194 new->first = aim_tlv_getstr(tl, 0x0001, 1); |
198 new->last = aim_tlv_getstr(tl, 0x0002, 1); | 195 new->last = aim_tlv_getstr(tl, 0x0002, 1); |
199 new->middle = aim_tlv_getstr(tl, 0x0003, 1); | 196 new->middle = aim_tlv_getstr(tl, 0x0003, 1); |
200 new->maiden = aim_tlv_getstr(tl, 0x0004, 1); | 197 new->maiden = aim_tlv_getstr(tl, 0x0004, 1); |
211 new->next = results; | 208 new->next = results; |
212 results = new; | 209 results = new; |
213 numresults--; | 210 numresults--; |
214 } | 211 } |
215 | 212 |
216 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | 213 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
217 ret = userfunc(sess, rx, results); | 214 ret = userfunc(od, conn, frame, results); |
218 | 215 |
219 /* Now free everything from above */ | 216 /* Now free everything from above */ |
220 while (results) { | 217 while (results) { |
221 struct aim_odir *del = results; | 218 struct aim_odir *del = results; |
222 results = results->next; | 219 results = results->next; |
238 } | 235 } |
239 | 236 |
240 return ret; | 237 return ret; |
241 } | 238 } |
242 | 239 |
243 static int snachandler(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 240 static int |
244 { | 241 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
245 | 242 { |
246 if (snac->subtype == 0x0003) | 243 if (snac->subtype == 0x0003) |
247 return parseresults(sess, mod, rx, snac, bs); | 244 return parseresults(od, conn, mod, frame, snac, bs); |
248 | 245 |
249 return 0; | 246 return 0; |
250 } | 247 } |
251 | 248 |
252 faim_internal int odir_modfirst(OscarSession *sess, aim_module_t *mod) | 249 int |
253 { | 250 odir_modfirst(OscarData *od, aim_module_t *mod) |
254 | 251 { |
255 mod->family = 0x000f; | 252 mod->family = 0x000f; |
256 mod->version = 0x0001; | 253 mod->version = 0x0001; |
257 mod->toolid = 0x0010; | 254 mod->toolid = 0x0010; |
258 mod->toolversion = 0x0629; | 255 mod->toolversion = 0x0629; |
259 mod->flags = 0; | 256 mod->flags = 0; |