]>
Commit | Line | Data |
---|---|---|
9de3ca7e | 1 | |
2 | /* | |
3 | * aim_misc.c | |
4 | * | |
5 | * TODO: Seperate a lot of this into an aim_bos.c. | |
6 | * | |
7 | * Other things... | |
8 | * | |
9 | * - Idle setting | |
10 | * | |
11 | * | |
12 | */ | |
13 | ||
37ee990e | 14 | #define FAIM_INTERNAL |
dd60ff8b | 15 | #include <aim.h> |
9de3ca7e | 16 | |
17 | /* | |
18 | * aim_bos_setidle() | |
19 | * | |
20 | * Should set your current idle time in seconds. Idealy, OSCAR should | |
21 | * do this for us. But, it doesn't. The client must call this to set idle | |
22 | * time. | |
23 | * | |
24 | */ | |
5ac21963 | 25 | faim_export unsigned long aim_bos_setidle(struct aim_session_t *sess, |
26 | struct aim_conn_t *conn, | |
27 | u_long idletime) | |
9de3ca7e | 28 | { |
a25832e6 | 29 | return aim_genericreq_l(sess, conn, 0x0001, 0x0011, &idletime); |
9de3ca7e | 30 | } |
31 | ||
32 | ||
33 | /* | |
34 | * aim_bos_changevisibility(conn, changtype, namelist) | |
35 | * | |
36 | * Changes your visibility depending on changetype: | |
37 | * | |
38 | * AIM_VISIBILITYCHANGE_PERMITADD: Lets provided list of names see you | |
39 | * AIM_VISIBILITYCHANGE_PERMIDREMOVE: Removes listed names from permit list | |
40 | * AIM_VISIBILITYCHANGE_DENYADD: Hides you from provided list of names | |
41 | * AIM_VISIBILITYCHANGE_DENYREMOVE: Lets list see you again | |
42 | * | |
43 | * list should be a list of | |
44 | * screen names in the form "Screen Name One&ScreenNameTwo&" etc. | |
45 | * | |
46 | * Equivelents to options in WinAIM: | |
47 | * - Allow all users to contact me: Send an AIM_VISIBILITYCHANGE_DENYADD | |
48 | * with only your name on it. | |
49 | * - Allow only users on my Buddy List: Send an | |
50 | * AIM_VISIBILITYCHANGE_PERMITADD with the list the same as your | |
51 | * buddy list | |
52 | * - Allow only the uesrs below: Send an AIM_VISIBILITYCHANGE_PERMITADD | |
53 | * with everyone listed that you want to see you. | |
54 | * - Block all users: Send an AIM_VISIBILITYCHANGE_PERMITADD with only | |
55 | * yourself in the list | |
56 | * - Block the users below: Send an AIM_VISIBILITYCHANGE_DENYADD with | |
57 | * the list of users to be blocked | |
58 | * | |
59 | * | |
60 | */ | |
5ac21963 | 61 | faim_export unsigned long aim_bos_changevisibility(struct aim_session_t *sess, |
62 | struct aim_conn_t *conn, | |
63 | int changetype, | |
64 | char *denylist) | |
9de3ca7e | 65 | { |
5b79dc93 | 66 | struct command_tx_struct *newpacket; |
67 | int packlen = 0; | |
9de3ca7e | 68 | u_short subtype; |
69 | ||
70 | char *localcpy = NULL; | |
71 | char *tmpptr = NULL; | |
72 | int i,j; | |
73 | int listcount; | |
74 | ||
75 | if (!denylist) | |
76 | return 0; | |
77 | ||
9de3ca7e | 78 | localcpy = (char *) malloc(strlen(denylist)+1); |
79 | memcpy(localcpy, denylist, strlen(denylist)+1); | |
80 | ||
81 | listcount = aimutil_itemcnt(localcpy, '&'); | |
5b79dc93 | 82 | packlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9; |
9de3ca7e | 83 | |
646c6b52 | 84 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen))) |
5b79dc93 | 85 | return -1; |
9de3ca7e | 86 | |
5b79dc93 | 87 | newpacket->lock = 1; |
9de3ca7e | 88 | |
89 | switch(changetype) | |
90 | { | |
91 | case AIM_VISIBILITYCHANGE_PERMITADD: subtype = 0x05; break; | |
92 | case AIM_VISIBILITYCHANGE_PERMITREMOVE: subtype = 0x06; break; | |
93 | case AIM_VISIBILITYCHANGE_DENYADD: subtype = 0x07; break; | |
94 | case AIM_VISIBILITYCHANGE_DENYREMOVE: subtype = 0x08; break; | |
95 | default: | |
5b79dc93 | 96 | free(newpacket->data); |
97 | free(newpacket); | |
9de3ca7e | 98 | return 0; |
99 | } | |
100 | ||
101 | /* We actually DO NOT send a SNAC ID with this one! */ | |
5b79dc93 | 102 | aim_putsnac(newpacket->data, 0x0009, subtype, 0x00, 0); |
9de3ca7e | 103 | |
104 | j = 10; /* the next byte */ | |
105 | ||
106 | for (i=0; (i < (listcount - 1)) && (i < 99); i++) | |
107 | { | |
108 | tmpptr = aimutil_itemidx(localcpy, i, '&'); | |
109 | ||
5b79dc93 | 110 | newpacket->data[j] = strlen(tmpptr); |
111 | memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr)); | |
9de3ca7e | 112 | j += strlen(tmpptr)+1; |
113 | free(tmpptr); | |
114 | } | |
115 | free(localcpy); | |
116 | ||
5b79dc93 | 117 | newpacket->lock = 0; |
9de3ca7e | 118 | |
5b79dc93 | 119 | aim_tx_enqueue(sess, newpacket); |
9de3ca7e | 120 | |
a25832e6 | 121 | return (sess->snac_nextid); /* dont increment */ |
9de3ca7e | 122 | |
123 | } | |
124 | ||
125 | ||
126 | ||
127 | /* | |
128 | * aim_bos_setbuddylist(buddylist) | |
129 | * | |
130 | * This just builds the "set buddy list" command then queues it. | |
131 | * | |
132 | * buddy_list = "Screen Name One&ScreenNameTwo&"; | |
133 | * | |
5b79dc93 | 134 | * TODO: Clean this up. |
135 | * | |
136 | * XXX: I can't stress the TODO enough. | |
9de3ca7e | 137 | * |
138 | */ | |
5ac21963 | 139 | faim_export unsigned long aim_bos_setbuddylist(struct aim_session_t *sess, |
140 | struct aim_conn_t *conn, | |
141 | char *buddy_list) | |
9de3ca7e | 142 | { |
143 | int i, j; | |
144 | ||
5b79dc93 | 145 | struct command_tx_struct *newpacket; |
9de3ca7e | 146 | |
c78446b5 | 147 | int len = 0; |
9de3ca7e | 148 | |
149 | char *localcpy = NULL; | |
150 | char *tmpptr = NULL; | |
151 | ||
c78446b5 | 152 | len = 10; /* 10B SNAC headers */ |
9de3ca7e | 153 | |
c78446b5 | 154 | if (!buddy_list || !(localcpy = (char *) malloc(strlen(buddy_list)+1))) |
5b79dc93 | 155 | return -1; |
c78446b5 | 156 | strncpy(localcpy, buddy_list, strlen(buddy_list)+1); |
9de3ca7e | 157 | |
158 | i = 0; | |
159 | tmpptr = strtok(localcpy, "&"); | |
c78446b5 | 160 | while ((tmpptr != NULL) && (i < 150)) { |
646c6b52 | 161 | faimdprintf(sess, 2, "---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr)); |
c78446b5 | 162 | len += 1+strlen(tmpptr); |
163 | i++; | |
164 | tmpptr = strtok(NULL, "&"); | |
165 | } | |
646c6b52 | 166 | faimdprintf(sess, 2, "*** send buddy list len: %d (%x)\n", len, len); |
9de3ca7e | 167 | |
646c6b52 | 168 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, len))) |
5b79dc93 | 169 | return -1; |
9de3ca7e | 170 | |
5b79dc93 | 171 | newpacket->lock = 1; |
172 | ||
c78446b5 | 173 | aim_putsnac(newpacket->data, 0x0003, 0x0004, 0x0000, 0); |
9de3ca7e | 174 | |
175 | j = 10; /* the next byte */ | |
176 | ||
c78446b5 | 177 | strncpy(localcpy, buddy_list, strlen(buddy_list)+1); |
9de3ca7e | 178 | i = 0; |
c78446b5 | 179 | tmpptr = strtok(localcpy, "&"); |
180 | while ((tmpptr != NULL) & (i < 150)) { | |
646c6b52 | 181 | faimdprintf(sess, 2, "---adding %d: %s (%d)\n", i, tmpptr, strlen(tmpptr)); |
c78446b5 | 182 | newpacket->data[j] = strlen(tmpptr); |
183 | memcpy(&(newpacket->data[j+1]), tmpptr, strlen(tmpptr)); | |
184 | j += 1+strlen(tmpptr); | |
185 | i++; | |
186 | tmpptr = strtok(NULL, "&"); | |
187 | } | |
9de3ca7e | 188 | |
5b79dc93 | 189 | newpacket->lock = 0; |
9de3ca7e | 190 | |
5b79dc93 | 191 | aim_tx_enqueue(sess, newpacket); |
9de3ca7e | 192 | |
c78446b5 | 193 | free(localcpy); |
194 | ||
195 | return (sess->snac_nextid); | |
9de3ca7e | 196 | } |
197 | ||
198 | /* | |
199 | * aim_bos_setprofile(profile) | |
200 | * | |
201 | * Gives BOS your profile. | |
202 | * | |
26af6789 | 203 | * |
9de3ca7e | 204 | */ |
5ac21963 | 205 | faim_export unsigned long aim_bos_setprofile(struct aim_session_t *sess, |
206 | struct aim_conn_t *conn, | |
207 | char *profile, | |
208 | char *awaymsg, | |
209 | unsigned short caps) | |
9de3ca7e | 210 | { |
5b79dc93 | 211 | struct command_tx_struct *newpacket; |
b69540e3 | 212 | int i = 0, tmp, caplen; |
0c20631f | 213 | |
646c6b52 | 214 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152+strlen(profile)+1+(awaymsg?strlen(awaymsg):0)))) |
5b79dc93 | 215 | return -1; |
9de3ca7e | 216 | |
5b79dc93 | 217 | i += aim_putsnac(newpacket->data, 0x0002, 0x004, 0x0000, sess->snac_nextid); |
218 | i += aim_puttlv_str(newpacket->data+i, 0x0001, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\""); | |
219 | i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(profile), profile); | |
26af6789 | 220 | /* why do we send this twice? */ |
5b79dc93 | 221 | i += aim_puttlv_str(newpacket->data+i, 0x0003, strlen("text/x-aolrtf; charset=\"us-ascii\""), "text/x-aolrtf; charset=\"us-ascii\""); |
9de3ca7e | 222 | |
0c20631f | 223 | /* Away message -- we send this no matter what, even if its blank */ |
224 | if (awaymsg) | |
5b79dc93 | 225 | i += aim_puttlv_str(newpacket->data+i, 0x0004, strlen(awaymsg), awaymsg); |
0c20631f | 226 | else |
5b79dc93 | 227 | i += aim_puttlv_str(newpacket->data+i, 0x0004, 0x0000, NULL); |
26af6789 | 228 | |
229 | /* Capability information. */ | |
b69540e3 | 230 | |
231 | tmp = (i += aimutil_put16(newpacket->data+i, 0x0005)); | |
232 | i += aimutil_put16(newpacket->data+i, 0x0000); /* rewritten later */ | |
233 | i += (caplen = aim_putcap(newpacket->data+i, 512, caps)); | |
234 | aimutil_put16(newpacket->data+tmp, caplen); /* rewrite TLV size */ | |
235 | ||
5b79dc93 | 236 | newpacket->commandlen = i; |
237 | aim_tx_enqueue(sess, newpacket); | |
9de3ca7e | 238 | |
a25832e6 | 239 | return (sess->snac_nextid++); |
9de3ca7e | 240 | } |
241 | ||
242 | /* | |
243 | * aim_bos_setgroupperm(mask) | |
244 | * | |
98c88242 | 245 | * Set group permisson mask. Normally 0x1f (all classes). |
246 | * | |
247 | * The group permission mask allows you to keep users of a certain | |
248 | * class or classes from talking to you. The mask should be | |
249 | * a bitwise OR of all the user classes you want to see you. | |
9de3ca7e | 250 | * |
251 | */ | |
5ac21963 | 252 | faim_export unsigned long aim_bos_setgroupperm(struct aim_session_t *sess, |
253 | struct aim_conn_t *conn, | |
254 | u_long mask) | |
9de3ca7e | 255 | { |
a25832e6 | 256 | return aim_genericreq_l(sess, conn, 0x0009, 0x0004, &mask); |
9de3ca7e | 257 | } |
258 | ||
5ac21963 | 259 | faim_internal int aim_parse_bosrights(struct aim_session_t *sess, |
260 | struct command_rx_struct *command, ...) | |
96f8b1ed | 261 | { |
262 | rxcallback_t userfunc = NULL; | |
263 | int ret=1; | |
264 | struct aim_tlvlist_t *tlvlist; | |
96f8b1ed | 265 | unsigned short maxpermits = 0, maxdenies = 0; |
266 | ||
267 | /* | |
268 | * TLVs follow | |
269 | */ | |
270 | if (!(tlvlist = aim_readtlvchain(command->data+10, command->commandlen-10))) | |
271 | return ret; | |
272 | ||
273 | /* | |
274 | * TLV type 0x0001: Maximum number of buddies on permit list. | |
275 | */ | |
1ea867e3 | 276 | if (aim_gettlv(tlvlist, 0x0001, 1)) |
277 | maxpermits = aim_gettlv16(tlvlist, 0x0001, 1); | |
96f8b1ed | 278 | |
279 | /* | |
280 | * TLV type 0x0002: Maximum number of buddies on deny list. | |
281 | * | |
282 | */ | |
1ea867e3 | 283 | if (aim_gettlv(tlvlist, 0x0002, 1)) |
284 | maxdenies = aim_gettlv16(tlvlist, 0x0002, 1); | |
96f8b1ed | 285 | |
646c6b52 | 286 | if ((userfunc = aim_callhandler(sess, command->conn, 0x0009, 0x0003))) |
1ea867e3 | 287 | ret = userfunc(sess, command, maxpermits, maxdenies); |
96f8b1ed | 288 | |
289 | aim_freetlvchain(&tlvlist); | |
290 | ||
291 | return ret; | |
292 | } | |
293 | ||
9de3ca7e | 294 | /* |
295 | * aim_bos_clientready() | |
296 | * | |
297 | * Send Client Ready. | |
298 | * | |
9de3ca7e | 299 | */ |
5ac21963 | 300 | faim_export unsigned long aim_bos_clientready(struct aim_session_t *sess, |
301 | struct aim_conn_t *conn) | |
9de3ca7e | 302 | { |
64c78745 | 303 | struct aim_tool_version tools[] = { |
d6c9fcf0 | 304 | {0x0001, 0x0003, AIM_TOOL_WIN32, 0x0686}, |
305 | {0x0002, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
306 | {0x0003, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
307 | {0x0004, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
308 | {0x0006, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
309 | {0x0008, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
310 | {0x0009, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
311 | {0x000a, 0x0001, AIM_TOOL_WIN32, 0x0001}, | |
312 | {0x000b, 0x0001, AIM_TOOL_WIN32, 0x0001} | |
9de3ca7e | 313 | }; |
d6c9fcf0 | 314 | int i,j; |
5b79dc93 | 315 | struct command_tx_struct *newpacket; |
d6c9fcf0 | 316 | int toolcount = sizeof(tools)/sizeof(struct aim_tool_version); |
317 | ||
646c6b52 | 318 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 1152))) |
5b79dc93 | 319 | return -1; |
320 | ||
321 | newpacket->lock = 1; | |
322 | ||
d6c9fcf0 | 323 | i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid); |
324 | aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0); | |
325 | ||
326 | for (j = 0; j < toolcount; j++) { | |
327 | i += aimutil_put16(newpacket->data+i, tools[j].group); | |
328 | i += aimutil_put16(newpacket->data+i, tools[j].version); | |
329 | i += aimutil_put16(newpacket->data+i, tools[j].tool); | |
330 | i += aimutil_put16(newpacket->data+i, tools[j].toolversion); | |
331 | } | |
332 | ||
333 | newpacket->commandlen = i; | |
334 | newpacket->lock = 0; | |
9de3ca7e | 335 | |
5b79dc93 | 336 | aim_tx_enqueue(sess, newpacket); |
9de3ca7e | 337 | |
d6c9fcf0 | 338 | return sess->snac_nextid; |
9de3ca7e | 339 | } |
340 | ||
341 | /* | |
9de3ca7e | 342 | * Request Rate Information. |
343 | * | |
9de3ca7e | 344 | */ |
5ac21963 | 345 | faim_export unsigned long aim_bos_reqrate(struct aim_session_t *sess, |
346 | struct aim_conn_t *conn) | |
9de3ca7e | 347 | { |
a25832e6 | 348 | return aim_genericreq_n(sess, conn, 0x0001, 0x0006); |
9de3ca7e | 349 | } |
350 | ||
351 | /* | |
9de3ca7e | 352 | * Rate Information Response Acknowledge. |
353 | * | |
354 | */ | |
5ac21963 | 355 | faim_export unsigned long aim_bos_ackrateresp(struct aim_session_t *sess, |
356 | struct aim_conn_t *conn) | |
9de3ca7e | 357 | { |
5b79dc93 | 358 | struct command_tx_struct *newpacket; |
c78446b5 | 359 | int packlen = 20, i=0; |
9de3ca7e | 360 | |
646c6b52 | 361 | if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen))) |
c78446b5 | 362 | return (sess->snac_nextid); |
5b79dc93 | 363 | |
364 | newpacket->lock = 1; | |
9de3ca7e | 365 | |
c78446b5 | 366 | i = aim_putsnac(newpacket->data, 0x0001, 0x0008, 0x0000, 0); |
5b79dc93 | 367 | i += aimutil_put16(newpacket->data+i, 0x0001); |
368 | i += aimutil_put16(newpacket->data+i, 0x0002); | |
369 | i += aimutil_put16(newpacket->data+i, 0x0003); | |
370 | i += aimutil_put16(newpacket->data+i, 0x0004); | |
c78446b5 | 371 | i += aimutil_put16(newpacket->data+i, 0x0005); |
5925849b | 372 | |
373 | newpacket->commandlen = i; | |
374 | newpacket->lock = 0; | |
375 | ||
5b79dc93 | 376 | aim_tx_enqueue(sess, newpacket); |
9de3ca7e | 377 | |
c78446b5 | 378 | return (sess->snac_nextid); |
9de3ca7e | 379 | } |
380 | ||
381 | /* | |
382 | * aim_bos_setprivacyflags() | |
383 | * | |
384 | * Sets privacy flags. Normally 0x03. | |
385 | * | |
386 | * Bit 1: Allows other AIM users to see how long you've been idle. | |
98c88242 | 387 | * Bit 2: Allows other AIM users to see how long you've been a member. |
9de3ca7e | 388 | * |
389 | */ | |
5ac21963 | 390 | faim_export unsigned long aim_bos_setprivacyflags(struct aim_session_t *sess, |
391 | struct aim_conn_t *conn, | |
392 | u_long flags) | |
9de3ca7e | 393 | { |
a25832e6 | 394 | return aim_genericreq_l(sess, conn, 0x0001, 0x0014, &flags); |
9de3ca7e | 395 | } |
396 | ||
397 | /* | |
398 | * aim_bos_reqpersonalinfo() | |
399 | * | |
400 | * Requests the current user's information. Can't go generic on this one | |
401 | * because aparently it uses SNAC flags. | |
402 | * | |
403 | */ | |
5ac21963 | 404 | faim_export unsigned long aim_bos_reqpersonalinfo(struct aim_session_t *sess, |
405 | struct aim_conn_t *conn) | |
9de3ca7e | 406 | { |
c78446b5 | 407 | return aim_genericreq_n(sess, conn, 0x0001, 0x000e); |
9de3ca7e | 408 | } |
409 | ||
5ac21963 | 410 | faim_export unsigned long aim_setversions(struct aim_session_t *sess, |
411 | struct aim_conn_t *conn) | |
01b59e1e | 412 | { |
5b79dc93 | 413 | struct command_tx_struct *newpacket; |
0c20631f | 414 | int i; |
01b59e1e | 415 | |
646c6b52 | 416 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10 + (4*12)))) |
5b79dc93 | 417 | return -1; |
418 | ||
419 | newpacket->lock = 1; | |
01b59e1e | 420 | |
5b79dc93 | 421 | i = aim_putsnac(newpacket->data, 0x0001, 0x0017, 0x0000, sess->snac_nextid); |
ee49b735 | 422 | aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0); |
01b59e1e | 423 | |
5b79dc93 | 424 | i += aimutil_put16(newpacket->data+i, 0x0001); |
425 | i += aimutil_put16(newpacket->data+i, 0x0003); | |
26af6789 | 426 | |
ee49b735 | 427 | i += aimutil_put16(newpacket->data+i, 0x0013); |
428 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
429 | ||
5b79dc93 | 430 | i += aimutil_put16(newpacket->data+i, 0x0002); |
431 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 432 | |
5b79dc93 | 433 | i += aimutil_put16(newpacket->data+i, 0x0003); |
434 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 435 | |
5b79dc93 | 436 | i += aimutil_put16(newpacket->data+i, 0x0004); |
437 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 438 | |
5b79dc93 | 439 | i += aimutil_put16(newpacket->data+i, 0x0006); |
440 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 441 | |
5b79dc93 | 442 | i += aimutil_put16(newpacket->data+i, 0x0008); |
443 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 444 | |
5b79dc93 | 445 | i += aimutil_put16(newpacket->data+i, 0x0009); |
446 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 447 | |
5b79dc93 | 448 | i += aimutil_put16(newpacket->data+i, 0x000a); |
449 | i += aimutil_put16(newpacket->data+i, 0x0001); | |
26af6789 | 450 | |
5b79dc93 | 451 | i += aimutil_put16(newpacket->data+i, 0x000b); |
5b79dc93 | 452 | i += aimutil_put16(newpacket->data+i, 0x0001); |
26af6789 | 453 | |
ee49b735 | 454 | i += aimutil_put16(newpacket->data+i, 0x000c); |
5b79dc93 | 455 | i += aimutil_put16(newpacket->data+i, 0x0001); |
01b59e1e | 456 | |
5925849b | 457 | newpacket->commandlen = i; |
5b79dc93 | 458 | newpacket->lock = 0; |
459 | aim_tx_enqueue(sess, newpacket); | |
01b59e1e | 460 | |
ee49b735 | 461 | return sess->snac_nextid; |
01b59e1e | 462 | } |
463 | ||
464 | ||
9de3ca7e | 465 | /* |
466 | * aim_bos_reqservice(serviceid) | |
467 | * | |
468 | * Service request. | |
469 | * | |
470 | */ | |
5ac21963 | 471 | faim_export unsigned long aim_bos_reqservice(struct aim_session_t *sess, |
a25832e6 | 472 | struct aim_conn_t *conn, |
473 | u_short serviceid) | |
9de3ca7e | 474 | { |
a25832e6 | 475 | return aim_genericreq_s(sess, conn, 0x0001, 0x0004, &serviceid); |
9de3ca7e | 476 | } |
477 | ||
f0a7908e | 478 | /* |
479 | * aim_bos_nop() | |
480 | * | |
481 | * No-op. WinAIM sends these every 4min or so to keep | |
98c88242 | 482 | * the connection alive. Its not real necessary. |
f0a7908e | 483 | * |
484 | */ | |
5ac21963 | 485 | faim_export unsigned long aim_bos_nop(struct aim_session_t *sess, |
486 | struct aim_conn_t *conn) | |
f0a7908e | 487 | { |
488 | return aim_genericreq_n(sess, conn, 0x0001, 0x0016); | |
489 | } | |
490 | ||
44d6f2dc | 491 | /* |
492 | * aim_flap_nop() | |
493 | * | |
494 | * No-op. WinAIM 4.x sends these _every minute_ to keep | |
495 | * the connection alive. | |
496 | */ | |
497 | faim_export unsigned long aim_flap_nop(struct aim_session_t *sess, | |
498 | struct aim_conn_t *conn) | |
499 | { | |
500 | struct command_tx_struct *newpacket; | |
501 | ||
646c6b52 | 502 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0005, 0))) |
44d6f2dc | 503 | return sess->snac_nextid; |
504 | ||
505 | newpacket->lock = 1; | |
506 | newpacket->commandlen = 0; | |
507 | newpacket->lock = 0; | |
508 | ||
509 | aim_tx_enqueue(sess, newpacket); | |
510 | ||
511 | return (sess->snac_nextid); | |
512 | } | |
513 | ||
9de3ca7e | 514 | /* |
515 | * aim_bos_reqrights() | |
516 | * | |
517 | * Request BOS rights. | |
518 | * | |
519 | */ | |
5ac21963 | 520 | faim_export unsigned long aim_bos_reqrights(struct aim_session_t *sess, |
521 | struct aim_conn_t *conn) | |
9de3ca7e | 522 | { |
a25832e6 | 523 | return aim_genericreq_n(sess, conn, 0x0009, 0x0002); |
9de3ca7e | 524 | } |
525 | ||
526 | /* | |
527 | * aim_bos_reqbuddyrights() | |
528 | * | |
529 | * Request Buddy List rights. | |
530 | * | |
531 | */ | |
5ac21963 | 532 | faim_export unsigned long aim_bos_reqbuddyrights(struct aim_session_t *sess, |
533 | struct aim_conn_t *conn) | |
9de3ca7e | 534 | { |
a25832e6 | 535 | return aim_genericreq_n(sess, conn, 0x0003, 0x0002); |
9de3ca7e | 536 | } |
537 | ||
98c88242 | 538 | /* |
539 | * aim_send_warning(struct aim_session_t *sess, | |
540 | * struct aim_conn_t *conn, char *destsn, int anon) | |
541 | * send a warning to destsn. | |
542 | * anon is anonymous or not; | |
543 | * AIM_WARN_ANON anonymous | |
544 | * | |
545 | * returns -1 on error (couldn't alloc packet), next snacid on success. | |
546 | * | |
547 | */ | |
5ac21963 | 548 | faim_export int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn, int anon) |
98c88242 | 549 | { |
550 | struct command_tx_struct *newpacket; | |
551 | int curbyte; | |
552 | ||
646c6b52 | 553 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, strlen(destsn)+13))) |
98c88242 | 554 | return -1; |
555 | ||
556 | newpacket->lock = 1; | |
557 | ||
558 | curbyte = 0; | |
559 | curbyte += aim_putsnac(newpacket->data+curbyte, | |
560 | 0x0004, 0x0008, 0x0000, sess->snac_nextid); | |
561 | ||
562 | curbyte += aimutil_put16(newpacket->data+curbyte, (anon & AIM_WARN_ANON)?1:0); | |
563 | ||
564 | curbyte += aimutil_put8(newpacket->data+curbyte, strlen(destsn)); | |
565 | ||
566 | curbyte += aimutil_putstr(newpacket->data+curbyte, destsn, strlen(destsn)); | |
567 | ||
568 | newpacket->commandlen = curbyte; | |
569 | newpacket->lock = 0; | |
570 | ||
571 | aim_tx_enqueue(sess, newpacket); | |
572 | ||
573 | return (sess->snac_nextid++); | |
574 | } | |
575 | ||
e5012450 | 576 | /* |
577 | * aim_debugconn_sendconnect() | |
578 | * | |
579 | * For aimdebugd. If you don't know what it is, you don't want to. | |
580 | */ | |
5ac21963 | 581 | faim_export unsigned long aim_debugconn_sendconnect(struct aim_session_t *sess, |
582 | struct aim_conn_t *conn) | |
e5012450 | 583 | { |
584 | return aim_genericreq_n(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT); | |
585 | } | |
586 | ||
9de3ca7e | 587 | /* |
588 | * Generic routine for sending commands. | |
589 | * | |
590 | * | |
591 | * I know I can do this in a smarter way...but I'm not thinking straight | |
592 | * right now... | |
593 | * | |
594 | * I had one big function that handled all three cases, but then it broke | |
595 | * and I split it up into three. But then I fixed it. I just never went | |
596 | * back to the single. I don't see any advantage to doing it either way. | |
597 | * | |
598 | */ | |
5ac21963 | 599 | faim_internal unsigned long aim_genericreq_n(struct aim_session_t *sess, |
600 | struct aim_conn_t *conn, | |
601 | u_short family, u_short subtype) | |
9de3ca7e | 602 | { |
5b79dc93 | 603 | struct command_tx_struct *newpacket; |
9de3ca7e | 604 | |
646c6b52 | 605 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10))) |
5b79dc93 | 606 | return 0; |
9de3ca7e | 607 | |
5b79dc93 | 608 | newpacket->lock = 1; |
9de3ca7e | 609 | |
5b79dc93 | 610 | aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid); |
ee49b735 | 611 | |
612 | aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0); | |
613 | ||
5b79dc93 | 614 | aim_tx_enqueue(sess, newpacket); |
ee49b735 | 615 | return sess->snac_nextid; |
9de3ca7e | 616 | } |
617 | ||
618 | /* | |
619 | * | |
620 | * | |
621 | */ | |
5ac21963 | 622 | faim_internal unsigned long aim_genericreq_l(struct aim_session_t *sess, |
623 | struct aim_conn_t *conn, | |
624 | u_short family, u_short subtype, | |
625 | u_long *longdata) | |
9de3ca7e | 626 | { |
5b79dc93 | 627 | struct command_tx_struct *newpacket; |
9de3ca7e | 628 | u_long newlong; |
629 | ||
630 | /* If we don't have data, there's no reason to use this function */ | |
631 | if (!longdata) | |
a25832e6 | 632 | return aim_genericreq_n(sess, conn, family, subtype); |
9de3ca7e | 633 | |
646c6b52 | 634 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+sizeof(u_long)))) |
5b79dc93 | 635 | return -1; |
9de3ca7e | 636 | |
5b79dc93 | 637 | newpacket->lock = 1; |
9de3ca7e | 638 | |
5b79dc93 | 639 | aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid); |
ee49b735 | 640 | aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0); |
9de3ca7e | 641 | |
642 | /* copy in data */ | |
643 | newlong = htonl(*longdata); | |
5b79dc93 | 644 | memcpy(&(newpacket->data[10]), &newlong, sizeof(u_long)); |
9de3ca7e | 645 | |
5b79dc93 | 646 | aim_tx_enqueue(sess, newpacket); |
ee49b735 | 647 | return sess->snac_nextid; |
9de3ca7e | 648 | } |
649 | ||
5ac21963 | 650 | faim_internal unsigned long aim_genericreq_s(struct aim_session_t *sess, |
651 | struct aim_conn_t *conn, | |
652 | u_short family, u_short subtype, | |
653 | u_short *shortdata) | |
9de3ca7e | 654 | { |
5b79dc93 | 655 | struct command_tx_struct *newpacket; |
9de3ca7e | 656 | u_short newshort; |
657 | ||
658 | /* If we don't have data, there's no reason to use this function */ | |
659 | if (!shortdata) | |
a25832e6 | 660 | return aim_genericreq_n(sess, conn, family, subtype); |
9de3ca7e | 661 | |
646c6b52 | 662 | if (!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10+sizeof(u_short)))) |
5b79dc93 | 663 | return -1; |
9de3ca7e | 664 | |
5b79dc93 | 665 | newpacket->lock = 1; |
9de3ca7e | 666 | |
5b79dc93 | 667 | aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid); |
ee49b735 | 668 | aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0); |
9de3ca7e | 669 | |
670 | /* copy in data */ | |
671 | newshort = htons(*shortdata); | |
5b79dc93 | 672 | memcpy(&(newpacket->data[10]), &newshort, sizeof(u_short)); |
9de3ca7e | 673 | |
5b79dc93 | 674 | aim_tx_enqueue(sess, newpacket); |
ee49b735 | 675 | return sess->snac_nextid; |
9de3ca7e | 676 | } |
677 | ||
678 | /* | |
679 | * aim_bos_reqlocaterights() | |
680 | * | |
681 | * Request Location services rights. | |
682 | * | |
683 | */ | |
5ac21963 | 684 | faim_export unsigned long aim_bos_reqlocaterights(struct aim_session_t *sess, |
685 | struct aim_conn_t *conn) | |
9de3ca7e | 686 | { |
a25832e6 | 687 | return aim_genericreq_n(sess, conn, 0x0002, 0x0002); |
9de3ca7e | 688 | } |
689 | ||
690 | /* | |
e88ba395 | 691 | * aim_bos_reqicbmparaminfo() |
9de3ca7e | 692 | * |
693 | * Request ICBM parameter information. | |
694 | * | |
695 | */ | |
5ac21963 | 696 | faim_export unsigned long aim_bos_reqicbmparaminfo(struct aim_session_t *sess, |
697 | struct aim_conn_t *conn) | |
9de3ca7e | 698 | { |
a25832e6 | 699 | return aim_genericreq_n(sess, conn, 0x0004, 0x0004); |
9de3ca7e | 700 | } |
e88ba395 | 701 | |
c78446b5 | 702 | /* |
703 | * Add ICBM parameter? Huh? | |
704 | */ | |
5ac21963 | 705 | faim_export unsigned long aim_addicbmparam(struct aim_session_t *sess, |
706 | struct aim_conn_t *conn) | |
c78446b5 | 707 | { |
708 | struct command_tx_struct *newpacket; | |
709 | int packlen = 10+16, i=0; | |
710 | ||
646c6b52 | 711 | if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen))) |
c78446b5 | 712 | return (sess->snac_nextid); |
713 | ||
714 | newpacket->lock = 1; | |
715 | ||
716 | i = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid); | |
ee49b735 | 717 | aim_cachesnac(sess, 0x0004, 0x0002, 0x0000, NULL, 0); |
718 | ||
c78446b5 | 719 | i += aimutil_put16(newpacket->data+i, 0x0000); |
720 | i += aimutil_put16(newpacket->data+i, 0x0000); | |
721 | i += aimutil_put16(newpacket->data+i, 0x0003); | |
722 | i += aimutil_put16(newpacket->data+i, 0x1f40); | |
723 | i += aimutil_put16(newpacket->data+i, 0x03e7); | |
724 | i += aimutil_put16(newpacket->data+i, 0x03e7); | |
725 | i += aimutil_put16(newpacket->data+i, 0x0000); | |
726 | i += aimutil_put16(newpacket->data+i, 0x0000); | |
727 | ||
728 | aim_tx_enqueue(sess, newpacket); | |
729 | ||
ee49b735 | 730 | return sess->snac_nextid; |
c78446b5 | 731 | } |
f2d214f9 | 732 | |
733 | /* | |
734 | * Set directory profile data (not the same as aim_bos_setprofile!) | |
735 | */ | |
736 | faim_export unsigned long aim_setdirectoryinfo(struct aim_session_t *sess, struct aim_conn_t *conn, char *first, char *middle, char *last, char *maiden, char *nickname, char *street, char *city, char *state, char *zip, int country, unsigned short privacy) | |
737 | { | |
738 | struct command_tx_struct *newpacket; | |
739 | int packlen = 0, i = 0; | |
740 | ||
741 | packlen += 2+2+2; | |
742 | ||
743 | if(first) /* TLV 0001 */ | |
744 | packlen += (strlen(first) + 4); | |
745 | if(middle) | |
746 | packlen += (strlen(middle) + 4); | |
747 | if(last) | |
748 | packlen += (strlen(last) + 4); | |
749 | if(maiden) | |
750 | packlen += (strlen(maiden) + 4); | |
751 | if(nickname) | |
752 | packlen += (strlen(nickname) + 4); | |
753 | if(street) | |
754 | packlen += (strlen(street) + 4); | |
755 | if(state) | |
756 | packlen += (strlen(state) + 4); | |
757 | if(city) | |
758 | packlen += (strlen(city) + 4); | |
759 | if(zip) | |
760 | packlen += (strlen(zip) + 4); | |
761 | ||
646c6b52 | 762 | if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen+10))) |
f2d214f9 | 763 | return -1; |
764 | ||
765 | newpacket->lock = 1; | |
766 | ||
767 | i = aim_putsnac(newpacket->data, 0x0002, 0x0009, 0x0000, 0); | |
768 | ||
769 | /* 000a/0002: privacy: 1 to allow search/disp, 0 to disallow */ | |
770 | i += aim_puttlv_16(newpacket->data+i, 0x000a, privacy); | |
771 | ||
772 | ||
773 | if (first) | |
774 | i += aim_puttlv_str(newpacket->data+i, 0x0001, strlen(first), first); | |
775 | if (middle) | |
776 | i += aim_puttlv_str(newpacket->data+i, 0x0003, strlen(middle), middle); | |
777 | if (last) | |
778 | i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(last), last); | |
779 | if (maiden) | |
780 | i += aim_puttlv_str(newpacket->data+i, 0x0004, strlen(maiden), maiden); | |
781 | if (nickname) | |
782 | i += aim_puttlv_str(newpacket->data+i, 0x000c, strlen(nickname), nickname); | |
783 | if (street) | |
784 | i += aim_puttlv_str(newpacket->data+i, 0x0021, strlen(street), street); | |
785 | if (city) | |
786 | i += aim_puttlv_str(newpacket->data+i, 0x0008, strlen(city), city); | |
787 | if (state) | |
788 | i += aim_puttlv_str(newpacket->data+i, 0x0007, strlen(state), state); | |
789 | if (zip) | |
790 | i += aim_puttlv_str(newpacket->data+i, 0x000d, strlen(zip), zip); | |
791 | ||
792 | newpacket->commandlen = i; | |
793 | newpacket->lock = 0; | |
794 | ||
795 | aim_tx_enqueue(sess, newpacket); | |
796 | ||
797 | return(sess->snac_nextid); | |
798 | } | |
799 | ||
800 | faim_export unsigned long aim_setuserinterests(struct aim_session_t *sess, struct aim_conn_t *conn, char *interest1, char *interest2, char *interest3, char *interest4, char *interest5, unsigned short privacy) | |
801 | { | |
802 | struct command_tx_struct *newpacket; | |
803 | int packlen = 0, i = 0; | |
804 | ||
805 | packlen += 2+2+2; | |
806 | ||
807 | if(interest1) | |
808 | packlen += (strlen(interest1) + 4); | |
809 | if(interest2) | |
810 | packlen += (strlen(interest2) + 4); | |
811 | if(interest3) | |
812 | packlen += (strlen(interest3) + 4); | |
813 | if(interest4) | |
814 | packlen += (strlen(interest4) + 4); | |
815 | if(interest5) | |
816 | packlen += (strlen(interest5) + 4) ; | |
817 | ||
818 | ||
646c6b52 | 819 | if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, packlen+10))) |
f2d214f9 | 820 | return -1; |
821 | ||
822 | newpacket->lock = 1; | |
823 | ||
824 | i = aim_putsnac(newpacket->data, 0x0002, 0x000f, 0x0000, 0); | |
825 | ||
826 | /* 000a/0002: 0000 ?? ?privacy? */ | |
827 | i += aim_puttlv_16(newpacket->data+i, 0x000a, privacy); | |
828 | ||
829 | if(interest1) | |
830 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest1), interest1); | |
831 | if(interest2) | |
832 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest2), interest2); | |
833 | if(interest3) | |
834 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest3), interest3); | |
835 | if(interest4) | |
836 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest4), interest4); | |
837 | if(interest5) | |
838 | i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest1), interest5); | |
839 | ||
840 | newpacket->commandlen = i; | |
841 | newpacket->lock = 0; | |
842 | ||
843 | aim_tx_enqueue(sess, newpacket); | |
844 | ||
845 | return(sess->snac_nextid); | |
846 | } | |
ec6b8da8 | 847 | |
848 | faim_export unsigned long aim_icq_setstatus(struct aim_session_t *sess, | |
849 | struct aim_conn_t *conn, | |
850 | unsigned long status) | |
851 | { | |
852 | struct command_tx_struct *newpacket; | |
853 | int i; | |
854 | unsigned long data; | |
855 | ||
856 | data = 0x00030000 | status; /* yay for error checking ;^) */ | |
857 | ||
646c6b52 | 858 | if(!(newpacket = aim_tx_new(sess, conn, AIM_FRAMETYPE_OSCAR, 0x0002, 10 + 4))) |
ec6b8da8 | 859 | return -1; |
860 | ||
861 | newpacket->lock = 1; | |
862 | ||
863 | i = aim_putsnac(newpacket->data, 0x0001, 0x001e, 0x0000, 0x0000001e); | |
864 | i += aim_puttlv_32(newpacket->data+i, 0x0006, data); | |
865 | ||
866 | newpacket->commandlen = i; | |
867 | newpacket->lock = 0; | |
868 | ||
869 | aim_tx_enqueue(sess, newpacket); | |
870 | ||
871 | return(sess->snac_nextid); | |
872 | } |