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