]> andersk Git - libfaim.git/blame - aim_misc.c
- Sun Feb 11 01:07:36 UTC 2001
[libfaim.git] / aim_misc.c
CommitLineData
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 25faim_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 61faim_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 139faim_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 211faim_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 258faim_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 265faim_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 306faim_export unsigned long aim_bos_clientready(struct aim_session_t *sess,
307 struct aim_conn_t *conn)
9de3ca7e 308{
64c78745 309 struct aim_tool_version tools[] = {
d6c9fcf0 310 {0x0001, 0x0003, AIM_TOOL_WIN32, 0x0686},
311 {0x0002, 0x0001, AIM_TOOL_WIN32, 0x0001},
312 {0x0003, 0x0001, AIM_TOOL_WIN32, 0x0001},
313 {0x0004, 0x0001, AIM_TOOL_WIN32, 0x0001},
314 {0x0006, 0x0001, AIM_TOOL_WIN32, 0x0001},
315 {0x0008, 0x0001, AIM_TOOL_WIN32, 0x0001},
316 {0x0009, 0x0001, AIM_TOOL_WIN32, 0x0001},
317 {0x000a, 0x0001, AIM_TOOL_WIN32, 0x0001},
318 {0x000b, 0x0001, AIM_TOOL_WIN32, 0x0001}
9de3ca7e 319 };
d6c9fcf0 320 int i,j;
5b79dc93 321 struct command_tx_struct *newpacket;
d6c9fcf0 322 int toolcount = sizeof(tools)/sizeof(struct aim_tool_version);
323
324 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152)))
5b79dc93 325 return -1;
326
327 newpacket->lock = 1;
328
d6c9fcf0 329 i = aim_putsnac(newpacket->data, 0x0001, 0x0002, 0x0000, sess->snac_nextid);
330 aim_cachesnac(sess, 0x0001, 0x0002, 0x0000, NULL, 0);
331
332 for (j = 0; j < toolcount; j++) {
333 i += aimutil_put16(newpacket->data+i, tools[j].group);
334 i += aimutil_put16(newpacket->data+i, tools[j].version);
335 i += aimutil_put16(newpacket->data+i, tools[j].tool);
336 i += aimutil_put16(newpacket->data+i, tools[j].toolversion);
337 }
338
339 newpacket->commandlen = i;
340 newpacket->lock = 0;
9de3ca7e 341
5b79dc93 342 aim_tx_enqueue(sess, newpacket);
9de3ca7e 343
d6c9fcf0 344 return sess->snac_nextid;
9de3ca7e 345}
346
347/*
9de3ca7e 348 * Request Rate Information.
349 *
9de3ca7e 350 */
5ac21963 351faim_export unsigned long aim_bos_reqrate(struct aim_session_t *sess,
352 struct aim_conn_t *conn)
9de3ca7e 353{
a25832e6 354 return aim_genericreq_n(sess, conn, 0x0001, 0x0006);
9de3ca7e 355}
356
357/*
9de3ca7e 358 * Rate Information Response Acknowledge.
359 *
360 */
5ac21963 361faim_export unsigned long aim_bos_ackrateresp(struct aim_session_t *sess,
362 struct aim_conn_t *conn)
9de3ca7e 363{
5b79dc93 364 struct command_tx_struct *newpacket;
c78446b5 365 int packlen = 20, i=0;
9de3ca7e 366
c78446b5 367 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen)))
368 return (sess->snac_nextid);
5b79dc93 369
370 newpacket->lock = 1;
9de3ca7e 371
c78446b5 372 i = aim_putsnac(newpacket->data, 0x0001, 0x0008, 0x0000, 0);
5b79dc93 373 i += aimutil_put16(newpacket->data+i, 0x0001);
374 i += aimutil_put16(newpacket->data+i, 0x0002);
375 i += aimutil_put16(newpacket->data+i, 0x0003);
376 i += aimutil_put16(newpacket->data+i, 0x0004);
c78446b5 377 i += aimutil_put16(newpacket->data+i, 0x0005);
5925849b 378
379 newpacket->commandlen = i;
380 newpacket->lock = 0;
381
5b79dc93 382 aim_tx_enqueue(sess, newpacket);
9de3ca7e 383
c78446b5 384 return (sess->snac_nextid);
9de3ca7e 385}
386
387/*
388 * aim_bos_setprivacyflags()
389 *
390 * Sets privacy flags. Normally 0x03.
391 *
392 * Bit 1: Allows other AIM users to see how long you've been idle.
98c88242 393 * Bit 2: Allows other AIM users to see how long you've been a member.
9de3ca7e 394 *
395 */
5ac21963 396faim_export unsigned long aim_bos_setprivacyflags(struct aim_session_t *sess,
397 struct aim_conn_t *conn,
398 u_long flags)
9de3ca7e 399{
a25832e6 400 return aim_genericreq_l(sess, conn, 0x0001, 0x0014, &flags);
9de3ca7e 401}
402
403/*
404 * aim_bos_reqpersonalinfo()
405 *
406 * Requests the current user's information. Can't go generic on this one
407 * because aparently it uses SNAC flags.
408 *
409 */
5ac21963 410faim_export unsigned long aim_bos_reqpersonalinfo(struct aim_session_t *sess,
411 struct aim_conn_t *conn)
9de3ca7e 412{
c78446b5 413 return aim_genericreq_n(sess, conn, 0x0001, 0x000e);
9de3ca7e 414}
415
5ac21963 416faim_export unsigned long aim_setversions(struct aim_session_t *sess,
417 struct aim_conn_t *conn)
01b59e1e 418{
5b79dc93 419 struct command_tx_struct *newpacket;
0c20631f 420 int i;
01b59e1e 421
c78446b5 422 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10 + (4*12))))
5b79dc93 423 return -1;
424
425 newpacket->lock = 1;
01b59e1e 426
5b79dc93 427 i = aim_putsnac(newpacket->data, 0x0001, 0x0017, 0x0000, sess->snac_nextid);
ee49b735 428 aim_cachesnac(sess, 0x0001, 0x0017, 0x0000, NULL, 0);
01b59e1e 429
5b79dc93 430 i += aimutil_put16(newpacket->data+i, 0x0001);
431 i += aimutil_put16(newpacket->data+i, 0x0003);
26af6789 432
ee49b735 433 i += aimutil_put16(newpacket->data+i, 0x0013);
434 i += aimutil_put16(newpacket->data+i, 0x0001);
435
5b79dc93 436 i += aimutil_put16(newpacket->data+i, 0x0002);
437 i += aimutil_put16(newpacket->data+i, 0x0001);
26af6789 438
5b79dc93 439 i += aimutil_put16(newpacket->data+i, 0x0003);
440 i += aimutil_put16(newpacket->data+i, 0x0001);
26af6789 441
5b79dc93 442 i += aimutil_put16(newpacket->data+i, 0x0004);
443 i += aimutil_put16(newpacket->data+i, 0x0001);
26af6789 444
5b79dc93 445 i += aimutil_put16(newpacket->data+i, 0x0006);
446 i += aimutil_put16(newpacket->data+i, 0x0001);
26af6789 447
5b79dc93 448 i += aimutil_put16(newpacket->data+i, 0x0008);
449 i += aimutil_put16(newpacket->data+i, 0x0001);
26af6789 450
5b79dc93 451 i += aimutil_put16(newpacket->data+i, 0x0009);
452 i += aimutil_put16(newpacket->data+i, 0x0001);
26af6789 453
5b79dc93 454 i += aimutil_put16(newpacket->data+i, 0x000a);
455 i += aimutil_put16(newpacket->data+i, 0x0001);
26af6789 456
5b79dc93 457 i += aimutil_put16(newpacket->data+i, 0x000b);
5b79dc93 458 i += aimutil_put16(newpacket->data+i, 0x0001);
26af6789 459
ee49b735 460 i += aimutil_put16(newpacket->data+i, 0x000c);
5b79dc93 461 i += aimutil_put16(newpacket->data+i, 0x0001);
01b59e1e 462
5925849b 463 newpacket->commandlen = i;
5b79dc93 464 newpacket->lock = 0;
465 aim_tx_enqueue(sess, newpacket);
01b59e1e 466
ee49b735 467 return sess->snac_nextid;
01b59e1e 468}
469
470
9de3ca7e 471/*
472 * aim_bos_reqservice(serviceid)
473 *
474 * Service request.
475 *
476 */
5ac21963 477faim_export unsigned long aim_bos_reqservice(struct aim_session_t *sess,
a25832e6 478 struct aim_conn_t *conn,
479 u_short serviceid)
9de3ca7e 480{
a25832e6 481 return aim_genericreq_s(sess, conn, 0x0001, 0x0004, &serviceid);
9de3ca7e 482}
483
f0a7908e 484/*
485 * aim_bos_nop()
486 *
487 * No-op. WinAIM sends these every 4min or so to keep
98c88242 488 * the connection alive. Its not real necessary.
f0a7908e 489 *
490 */
5ac21963 491faim_export unsigned long aim_bos_nop(struct aim_session_t *sess,
492 struct aim_conn_t *conn)
f0a7908e 493{
494 return aim_genericreq_n(sess, conn, 0x0001, 0x0016);
495}
496
44d6f2dc 497/*
498 * aim_flap_nop()
499 *
500 * No-op. WinAIM 4.x sends these _every minute_ to keep
501 * the connection alive.
502 */
503faim_export unsigned long aim_flap_nop(struct aim_session_t *sess,
504 struct aim_conn_t *conn)
505{
506 struct command_tx_struct *newpacket;
507
508 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0005, conn, 0)))
509 return sess->snac_nextid;
510
511 newpacket->lock = 1;
512 newpacket->commandlen = 0;
513 newpacket->lock = 0;
514
515 aim_tx_enqueue(sess, newpacket);
516
517 return (sess->snac_nextid);
518}
519
9de3ca7e 520/*
521 * aim_bos_reqrights()
522 *
523 * Request BOS rights.
524 *
525 */
5ac21963 526faim_export unsigned long aim_bos_reqrights(struct aim_session_t *sess,
527 struct aim_conn_t *conn)
9de3ca7e 528{
a25832e6 529 return aim_genericreq_n(sess, conn, 0x0009, 0x0002);
9de3ca7e 530}
531
532/*
533 * aim_bos_reqbuddyrights()
534 *
535 * Request Buddy List rights.
536 *
537 */
5ac21963 538faim_export unsigned long aim_bos_reqbuddyrights(struct aim_session_t *sess,
539 struct aim_conn_t *conn)
9de3ca7e 540{
a25832e6 541 return aim_genericreq_n(sess, conn, 0x0003, 0x0002);
9de3ca7e 542}
543
98c88242 544/*
545 * aim_send_warning(struct aim_session_t *sess,
546 * struct aim_conn_t *conn, char *destsn, int anon)
547 * send a warning to destsn.
548 * anon is anonymous or not;
549 * AIM_WARN_ANON anonymous
550 *
551 * returns -1 on error (couldn't alloc packet), next snacid on success.
552 *
553 */
5ac21963 554faim_export int aim_send_warning(struct aim_session_t *sess, struct aim_conn_t *conn, char *destsn, int anon)
98c88242 555{
556 struct command_tx_struct *newpacket;
557 int curbyte;
558
559 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, strlen(destsn)+13)))
560 return -1;
561
562 newpacket->lock = 1;
563
564 curbyte = 0;
565 curbyte += aim_putsnac(newpacket->data+curbyte,
566 0x0004, 0x0008, 0x0000, sess->snac_nextid);
567
568 curbyte += aimutil_put16(newpacket->data+curbyte, (anon & AIM_WARN_ANON)?1:0);
569
570 curbyte += aimutil_put8(newpacket->data+curbyte, strlen(destsn));
571
572 curbyte += aimutil_putstr(newpacket->data+curbyte, destsn, strlen(destsn));
573
574 newpacket->commandlen = curbyte;
575 newpacket->lock = 0;
576
577 aim_tx_enqueue(sess, newpacket);
578
579 return (sess->snac_nextid++);
580}
581
e5012450 582/*
583 * aim_debugconn_sendconnect()
584 *
585 * For aimdebugd. If you don't know what it is, you don't want to.
586 */
5ac21963 587faim_export unsigned long aim_debugconn_sendconnect(struct aim_session_t *sess,
588 struct aim_conn_t *conn)
e5012450 589{
590 return aim_genericreq_n(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DEBUGCONN_CONNECT);
591}
592
9de3ca7e 593/*
594 * Generic routine for sending commands.
595 *
596 *
597 * I know I can do this in a smarter way...but I'm not thinking straight
598 * right now...
599 *
600 * I had one big function that handled all three cases, but then it broke
601 * and I split it up into three. But then I fixed it. I just never went
602 * back to the single. I don't see any advantage to doing it either way.
603 *
604 */
5ac21963 605faim_internal unsigned long aim_genericreq_n(struct aim_session_t *sess,
606 struct aim_conn_t *conn,
607 u_short family, u_short subtype)
9de3ca7e 608{
5b79dc93 609 struct command_tx_struct *newpacket;
9de3ca7e 610
b69540e3 611 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10)))
5b79dc93 612 return 0;
9de3ca7e 613
5b79dc93 614 newpacket->lock = 1;
9de3ca7e 615
5b79dc93 616 aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid);
ee49b735 617
618 aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0);
619
5b79dc93 620 aim_tx_enqueue(sess, newpacket);
ee49b735 621 return sess->snac_nextid;
9de3ca7e 622}
623
624/*
625 *
626 *
627 */
5ac21963 628faim_internal unsigned long aim_genericreq_l(struct aim_session_t *sess,
629 struct aim_conn_t *conn,
630 u_short family, u_short subtype,
631 u_long *longdata)
9de3ca7e 632{
5b79dc93 633 struct command_tx_struct *newpacket;
9de3ca7e 634 u_long newlong;
635
636 /* If we don't have data, there's no reason to use this function */
637 if (!longdata)
a25832e6 638 return aim_genericreq_n(sess, conn, family, subtype);
9de3ca7e 639
b69540e3 640 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+sizeof(u_long))))
5b79dc93 641 return -1;
9de3ca7e 642
5b79dc93 643 newpacket->lock = 1;
9de3ca7e 644
5b79dc93 645 aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid);
ee49b735 646 aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0);
9de3ca7e 647
648 /* copy in data */
649 newlong = htonl(*longdata);
5b79dc93 650 memcpy(&(newpacket->data[10]), &newlong, sizeof(u_long));
9de3ca7e 651
5b79dc93 652 aim_tx_enqueue(sess, newpacket);
ee49b735 653 return sess->snac_nextid;
9de3ca7e 654}
655
5ac21963 656faim_internal unsigned long aim_genericreq_s(struct aim_session_t *sess,
657 struct aim_conn_t *conn,
658 u_short family, u_short subtype,
659 u_short *shortdata)
9de3ca7e 660{
5b79dc93 661 struct command_tx_struct *newpacket;
9de3ca7e 662 u_short newshort;
663
664 /* If we don't have data, there's no reason to use this function */
665 if (!shortdata)
a25832e6 666 return aim_genericreq_n(sess, conn, family, subtype);
9de3ca7e 667
b69540e3 668 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+sizeof(u_short))))
5b79dc93 669 return -1;
9de3ca7e 670
5b79dc93 671 newpacket->lock = 1;
9de3ca7e 672
5b79dc93 673 aim_putsnac(newpacket->data, family, subtype, 0x0000, sess->snac_nextid);
ee49b735 674 aim_cachesnac(sess, family, subtype, 0x0000, NULL, 0);
9de3ca7e 675
676 /* copy in data */
677 newshort = htons(*shortdata);
5b79dc93 678 memcpy(&(newpacket->data[10]), &newshort, sizeof(u_short));
9de3ca7e 679
5b79dc93 680 aim_tx_enqueue(sess, newpacket);
ee49b735 681 return sess->snac_nextid;
9de3ca7e 682}
683
684/*
685 * aim_bos_reqlocaterights()
686 *
687 * Request Location services rights.
688 *
689 */
5ac21963 690faim_export unsigned long aim_bos_reqlocaterights(struct aim_session_t *sess,
691 struct aim_conn_t *conn)
9de3ca7e 692{
a25832e6 693 return aim_genericreq_n(sess, conn, 0x0002, 0x0002);
9de3ca7e 694}
695
696/*
e88ba395 697* aim_bos_reqicbmparaminfo()
9de3ca7e 698 *
699 * Request ICBM parameter information.
700 *
701 */
5ac21963 702faim_export unsigned long aim_bos_reqicbmparaminfo(struct aim_session_t *sess,
703 struct aim_conn_t *conn)
9de3ca7e 704{
a25832e6 705 return aim_genericreq_n(sess, conn, 0x0004, 0x0004);
9de3ca7e 706}
e88ba395 707
c78446b5 708/*
709 * Add ICBM parameter? Huh?
710 */
5ac21963 711faim_export unsigned long aim_addicbmparam(struct aim_session_t *sess,
712 struct aim_conn_t *conn)
c78446b5 713{
714 struct command_tx_struct *newpacket;
715 int packlen = 10+16, i=0;
716
717 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen)))
718 return (sess->snac_nextid);
719
720 newpacket->lock = 1;
721
722 i = aim_putsnac(newpacket->data, 0x0004, 0x0002, 0x0000, sess->snac_nextid);
ee49b735 723 aim_cachesnac(sess, 0x0004, 0x0002, 0x0000, NULL, 0);
724
c78446b5 725 i += aimutil_put16(newpacket->data+i, 0x0000);
726 i += aimutil_put16(newpacket->data+i, 0x0000);
727 i += aimutil_put16(newpacket->data+i, 0x0003);
728 i += aimutil_put16(newpacket->data+i, 0x1f40);
729 i += aimutil_put16(newpacket->data+i, 0x03e7);
730 i += aimutil_put16(newpacket->data+i, 0x03e7);
731 i += aimutil_put16(newpacket->data+i, 0x0000);
732 i += aimutil_put16(newpacket->data+i, 0x0000);
733
734 aim_tx_enqueue(sess, newpacket);
735
ee49b735 736 return sess->snac_nextid;
c78446b5 737}
f2d214f9 738
739/*
740 * Set directory profile data (not the same as aim_bos_setprofile!)
741 */
742faim_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)
743{
744 struct command_tx_struct *newpacket;
745 int packlen = 0, i = 0;
746
747 packlen += 2+2+2;
748
749 if(first) /* TLV 0001 */
750 packlen += (strlen(first) + 4);
751 if(middle)
752 packlen += (strlen(middle) + 4);
753 if(last)
754 packlen += (strlen(last) + 4);
755 if(maiden)
756 packlen += (strlen(maiden) + 4);
757 if(nickname)
758 packlen += (strlen(nickname) + 4);
759 if(street)
760 packlen += (strlen(street) + 4);
761 if(state)
762 packlen += (strlen(state) + 4);
763 if(city)
764 packlen += (strlen(city) + 4);
765 if(zip)
766 packlen += (strlen(zip) + 4);
767
768 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen+10)))
769 return -1;
770
771 newpacket->lock = 1;
772
773 i = aim_putsnac(newpacket->data, 0x0002, 0x0009, 0x0000, 0);
774
775 /* 000a/0002: privacy: 1 to allow search/disp, 0 to disallow */
776 i += aim_puttlv_16(newpacket->data+i, 0x000a, privacy);
777
778
779 if (first)
780 i += aim_puttlv_str(newpacket->data+i, 0x0001, strlen(first), first);
781 if (middle)
782 i += aim_puttlv_str(newpacket->data+i, 0x0003, strlen(middle), middle);
783 if (last)
784 i += aim_puttlv_str(newpacket->data+i, 0x0002, strlen(last), last);
785 if (maiden)
786 i += aim_puttlv_str(newpacket->data+i, 0x0004, strlen(maiden), maiden);
787 if (nickname)
788 i += aim_puttlv_str(newpacket->data+i, 0x000c, strlen(nickname), nickname);
789 if (street)
790 i += aim_puttlv_str(newpacket->data+i, 0x0021, strlen(street), street);
791 if (city)
792 i += aim_puttlv_str(newpacket->data+i, 0x0008, strlen(city), city);
793 if (state)
794 i += aim_puttlv_str(newpacket->data+i, 0x0007, strlen(state), state);
795 if (zip)
796 i += aim_puttlv_str(newpacket->data+i, 0x000d, strlen(zip), zip);
797
798 newpacket->commandlen = i;
799 newpacket->lock = 0;
800
801 aim_tx_enqueue(sess, newpacket);
802
803 return(sess->snac_nextid);
804}
805
806faim_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)
807{
808 struct command_tx_struct *newpacket;
809 int packlen = 0, i = 0;
810
811 packlen += 2+2+2;
812
813 if(interest1)
814 packlen += (strlen(interest1) + 4);
815 if(interest2)
816 packlen += (strlen(interest2) + 4);
817 if(interest3)
818 packlen += (strlen(interest3) + 4);
819 if(interest4)
820 packlen += (strlen(interest4) + 4);
821 if(interest5)
822 packlen += (strlen(interest5) + 4) ;
823
824
825 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, packlen+10)))
826 return -1;
827
828 newpacket->lock = 1;
829
830 i = aim_putsnac(newpacket->data, 0x0002, 0x000f, 0x0000, 0);
831
832 /* 000a/0002: 0000 ?? ?privacy? */
833 i += aim_puttlv_16(newpacket->data+i, 0x000a, privacy);
834
835 if(interest1)
836 i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest1), interest1);
837 if(interest2)
838 i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest2), interest2);
839 if(interest3)
840 i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest3), interest3);
841 if(interest4)
842 i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest4), interest4);
843 if(interest5)
844 i += aim_puttlv_str(newpacket->data+i, 0x000b, strlen(interest1), interest5);
845
846 newpacket->commandlen = i;
847 newpacket->lock = 0;
848
849 aim_tx_enqueue(sess, newpacket);
850
851 return(sess->snac_nextid);
852}
ec6b8da8 853
854faim_export unsigned long aim_icq_setstatus(struct aim_session_t *sess,
855 struct aim_conn_t *conn,
856 unsigned long status)
857{
858 struct command_tx_struct *newpacket;
859 int i;
860 unsigned long data;
861
862 data = 0x00030000 | status; /* yay for error checking ;^) */
863
864 if(!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10 + 4)))
865 return -1;
866
867 newpacket->lock = 1;
868
869 i = aim_putsnac(newpacket->data, 0x0001, 0x001e, 0x0000, 0x0000001e);
870 i += aim_puttlv_32(newpacket->data+i, 0x0006, data);
871
872 newpacket->commandlen = i;
873 newpacket->lock = 0;
874
875 aim_tx_enqueue(sess, newpacket);
876
877 return(sess->snac_nextid);
878}
This page took 0.814979 seconds and 5 git commands to generate.