Sun, 30 Apr 2000 21:47:04 +0000
[gaim-migrate @ 210]
Made the receive non-blocking, added a cancel button, and a few other updates.
No, sending a file to someone does not work yet. Be patient.
| 2 | 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 | ||
| 14 | #include "aim.h" | |
| 15 | ||
| 16 | /* | |
| 17 | * aim_bos_setidle() | |
| 18 | * | |
| 19 | * Should set your current idle time in seconds. Idealy, OSCAR should | |
| 20 | * do this for us. But, it doesn't. The client must call this to set idle | |
| 21 | * time. | |
| 22 | * | |
| 23 | */ | |
| 24 | u_long aim_bos_setidle(struct aim_conn_t *conn, u_long idletime) | |
| 25 | { | |
| 26 | return aim_genericreq_l(conn, 0x0001, 0x0011, &idletime); | |
| 27 | } | |
| 28 | ||
| 29 | ||
| 30 | /* | |
| 31 | * aim_bos_changevisibility(conn, changtype, namelist) | |
| 32 | * | |
| 33 | * Changes your visibility depending on changetype: | |
| 34 | * | |
| 35 | * AIM_VISIBILITYCHANGE_PERMITADD: Lets provided list of names see you | |
| 36 | * AIM_VISIBILITYCHANGE_PERMIDREMOVE: Removes listed names from permit list | |
| 37 | * AIM_VISIBILITYCHANGE_DENYADD: Hides you from provided list of names | |
| 38 | * AIM_VISIBILITYCHANGE_DENYREMOVE: Lets list see you again | |
| 39 | * | |
| 40 | * list should be a list of | |
| 41 | * screen names in the form "Screen Name One&ScreenNameTwo&" etc. | |
| 42 | * | |
| 43 | * Equivelents to options in WinAIM: | |
| 44 | * - Allow all users to contact me: Send an AIM_VISIBILITYCHANGE_DENYADD | |
| 45 | * with only your name on it. | |
| 46 | * - Allow only users on my Buddy List: Send an | |
| 47 | * AIM_VISIBILITYCHANGE_PERMITADD with the list the same as your | |
| 48 | * buddy list | |
| 49 | * - Allow only the uesrs below: Send an AIM_VISIBILITYCHANGE_PERMITADD | |
| 50 | * with everyone listed that you want to see you. | |
| 51 | * - Block all users: Send an AIM_VISIBILITYCHANGE_PERMITADD with only | |
| 52 | * yourself in the list | |
| 53 | * - Block the users below: Send an AIM_VISIBILITYCHANGE_DENYADD with | |
| 54 | * the list of users to be blocked | |
| 55 | * | |
| 56 | * | |
| 57 | */ | |
| 58 | u_long aim_bos_changevisibility(struct aim_conn_t *conn, int changetype, char *denylist) | |
| 59 | { | |
| 60 | struct command_tx_struct newpacket; | |
| 61 | ||
| 62 | char *localcpy = NULL; | |
| 63 | char *tmpptr = NULL; | |
| 64 | char *tmpptr2 = NULL; | |
| 65 | int i,j; | |
| 66 | ||
| 67 | if (!denylist) | |
| 68 | return 0; | |
| 69 | ||
| 70 | newpacket.lock = 1; | |
| 71 | ||
| 72 | if (conn) | |
| 73 | newpacket.conn = conn; | |
| 74 | else | |
| 75 | newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_BOS); | |
| 76 | ||
| 77 | newpacket.type = 0x02; | |
| 78 | newpacket.commandlen = 10; | |
| 79 | ||
| 80 | localcpy = (char *) malloc(strlen(denylist)+1); | |
| 81 | memcpy(localcpy, denylist, strlen(denylist)+1); | |
| 82 | tmpptr2 = localcpy; /* save this for the free() */ | |
| 83 | ||
| 84 | i = 0; | |
| 85 | tmpptr = strsep(&localcpy, "&"); | |
| 86 | while (strlen(tmpptr) && (i < 100)) | |
| 87 | { | |
| 88 | newpacket.commandlen += strlen(tmpptr)+1; | |
| 89 | i++; | |
| 90 | tmpptr = strsep(&localcpy, "&"); | |
| 91 | } | |
| 92 | free(tmpptr2); | |
| 93 | tmpptr2 = NULL; | |
| 94 | ||
| 95 | newpacket.data = (char *) malloc(newpacket.commandlen); | |
| 96 | memset(newpacket.data, 0x00, newpacket.commandlen); | |
| 97 | ||
| 98 | newpacket.data[0] = 0x00; | |
| 99 | newpacket.data[1] = 0x09; | |
| 100 | newpacket.data[2] = 0x00; | |
| 101 | switch(changetype) | |
| 102 | { | |
| 103 | case AIM_VISIBILITYCHANGE_PERMITADD: | |
| 104 | newpacket.data[3] = 0x05; break; | |
| 105 | case AIM_VISIBILITYCHANGE_PERMITREMOVE: | |
| 106 | newpacket.data[3] = 0x06; break; | |
| 107 | case AIM_VISIBILITYCHANGE_DENYADD: | |
| 108 | newpacket.data[3] = 0x07; break; | |
| 109 | case AIM_VISIBILITYCHANGE_DENYREMOVE: | |
| 110 | newpacket.data[4] = 0x08; break; | |
| 111 | default: | |
| 112 | return 0; | |
| 113 | } | |
| 114 | /* SNAC reqid -- we actually DO NOT send a SNAC ID with this one! */ | |
| 115 | newpacket.data[6] = 0; | |
| 116 | newpacket.data[7] = 0; | |
| 117 | newpacket.data[8] = 0; | |
| 118 | newpacket.data[9] = 0; | |
| 119 | ||
| 120 | j = 10; /* the next byte */ | |
| 121 | ||
| 122 | localcpy = (char *) malloc(strlen(denylist)+1); | |
| 123 | memcpy(localcpy, denylist, strlen(denylist)+1); | |
| 124 | tmpptr2 = localcpy; /* save this for the free() */ | |
| 125 | ||
| 126 | i = 0; | |
| 127 | tmpptr = strsep(&localcpy, "&"); | |
| 128 | while (strlen(tmpptr) && (i < 100)) | |
| 129 | { | |
| 130 | newpacket.data[j] = strlen(tmpptr); | |
| 131 | memcpy(&(newpacket.data[j+1]), tmpptr, strlen(tmpptr)); | |
| 132 | j += strlen(tmpptr)+1; | |
| 133 | i++; | |
| 134 | tmpptr = strsep(&localcpy, "&"); | |
| 135 | } | |
| 136 | free(tmpptr2); | |
| 137 | ||
| 138 | newpacket.lock = 0; | |
| 139 | ||
| 140 | aim_tx_enqueue(&newpacket); | |
| 141 | ||
| 142 | return (aim_snac_nextid); /* dont increment */ | |
| 143 | ||
| 144 | } | |
| 145 | ||
| 146 | ||
| 147 | ||
| 148 | /* | |
| 149 | * aim_bos_setbuddylist(buddylist) | |
| 150 | * | |
| 151 | * This just builds the "set buddy list" command then queues it. | |
| 152 | * | |
| 153 | * buddy_list = "Screen Name One&ScreenNameTwo&"; | |
| 154 | * | |
| 155 | * TODO: Clean this up. | |
| 156 | * | |
| 157 | */ | |
| 158 | u_long aim_bos_setbuddylist(struct aim_conn_t *conn, char *buddy_list) | |
| 159 | { | |
| 160 | int i, j; | |
| 161 | ||
| 162 | struct command_tx_struct newpacket; | |
| 163 | ||
| 164 | int packet_login_phase3c_hi_b_len = 0; | |
| 165 | ||
| 166 | char *localcpy = NULL; | |
| 167 | char *tmpptr = NULL; | |
| 168 | ||
| 169 | packet_login_phase3c_hi_b_len = 16; /* 16b for FLAP and SNAC headers */ | |
| 170 | ||
| 171 | /* bail out if we can't make the packet */ | |
| 172 | if (buddy_list == NULL) | |
| 173 | { | |
| 174 | printf("\nNO BUDDIES! ARE YOU THAT LONELY???\n"); | |
| 175 | return 0; | |
| 176 | } | |
| 177 | #if debug > 0 | |
| 178 | printf("****buddy list: %s\n", buddy_list); | |
| 179 | printf("****buddy list len: %d (%x)\n", strlen(buddy_list), strlen(buddy_list)); | |
| 180 | #endif | |
| 181 | ||
| 182 | localcpy = (char *) malloc(strlen(buddy_list)+1); | |
| 183 | memcpy(localcpy, buddy_list, strlen(buddy_list)+1); | |
| 184 | ||
| 185 | i = 0; | |
| 186 | tmpptr = strtok(localcpy, "&"); | |
| 187 | while ((tmpptr != NULL) && (i < 100)) | |
| 188 | { | |
| 189 | #if debug > 0 | |
| 190 | printf("---adding %s (%d)\n", tmpptr, strlen(tmpptr)); | |
| 191 | #endif | |
| 192 | packet_login_phase3c_hi_b_len += strlen(tmpptr)+1; | |
| 193 | i++; | |
| 194 | tmpptr = strtok(NULL, "&"); | |
| 195 | } | |
| 196 | #if debug > 0 | |
| 197 | printf("*** send buddy list len: %d (%x)\n", packet_login_phase3c_hi_b_len, packet_login_phase3c_hi_b_len); | |
| 198 | #endif | |
| 199 | free(localcpy); | |
| 200 | ||
| 201 | newpacket.type = 0x02; | |
| 202 | if (conn) | |
| 203 | newpacket.conn = conn; | |
| 204 | else | |
| 205 | newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_BOS); | |
| 206 | newpacket.commandlen = packet_login_phase3c_hi_b_len - 6; | |
| 207 | newpacket.lock = 1; | |
| 208 | ||
| 209 | newpacket.data = (char *) malloc(newpacket.commandlen); | |
| 210 | ||
| 211 | newpacket.data[0] = 0x00; | |
| 212 | newpacket.data[1] = 0x03; | |
| 213 | newpacket.data[2] = 0x00; | |
| 214 | newpacket.data[3] = 0x04; | |
| 215 | newpacket.data[4] = 0x00; | |
| 216 | newpacket.data[5] = 0x00; | |
| 217 | /* SNAC reqid */ | |
| 218 | newpacket.data[6] = (aim_snac_nextid >> 24) & 0xFF; | |
| 219 | newpacket.data[7] = (aim_snac_nextid >> 16) & 0xFF; | |
| 220 | newpacket.data[8] = (aim_snac_nextid >> 8) & 0xFF; | |
| 221 | newpacket.data[9] = (aim_snac_nextid) & 0xFF; | |
| 222 | ||
| 223 | j = 10; /* the next byte */ | |
| 224 | ||
| 225 | i = 0; | |
| 226 | tmpptr = strtok(buddy_list, "&"); | |
| 227 | while ((tmpptr != NULL) & (i < 100)) | |
| 228 | { | |
| 229 | #if debug > 0 | |
| 230 | printf("---adding %s (%d)\n", tmpptr, strlen(tmpptr)); | |
| 231 | #endif | |
| 232 | newpacket.data[j] = strlen(tmpptr); | |
| 233 | memcpy(&(newpacket.data[j+1]), tmpptr, strlen(tmpptr)); | |
| 234 | j += strlen(tmpptr)+1; | |
| 235 | i++; | |
| 236 | tmpptr = strtok(NULL, "&"); | |
| 237 | } | |
| 238 | ||
| 239 | newpacket.lock = 0; | |
| 240 | ||
| 241 | aim_tx_enqueue(&newpacket); | |
| 242 | ||
| 243 | return (aim_snac_nextid++); | |
| 244 | } | |
| 245 | ||
| 246 | /* | |
| 247 | * aim_bos_setprofile(profile) | |
| 248 | * | |
| 249 | * Gives BOS your profile. | |
| 250 | * | |
| 251 | */ | |
| 252 | u_long aim_bos_setprofile(struct aim_conn_t *conn, char *profile) | |
| 253 | { | |
| 254 | int packet_profile_len = 0; | |
| 255 | struct command_tx_struct newpacket; | |
| 256 | int i = 0; | |
| 257 | ||
| 258 | /* len: SNAC */ | |
| 259 | packet_profile_len = 10; | |
| 260 | /* len: T+L (where t(0001)) */ | |
| 261 | packet_profile_len += 2 + 2; | |
| 262 | /* len: V (where t(0001)) */ | |
| 263 | packet_profile_len += strlen("text/x-aolrtf"); | |
| 264 | /* len: T+L (where t(0002)) */ | |
| 265 | packet_profile_len += 2 + 2; | |
| 266 | /* len: V (where t(0002)) */ | |
| 267 | packet_profile_len += strlen(profile); | |
| 268 | ||
| 269 | newpacket.type = 0x02; | |
| 270 | if (conn) | |
| 271 | newpacket.conn = conn; | |
| 272 | else | |
| 273 | newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_BOS); | |
| 274 | newpacket.commandlen = packet_profile_len; | |
| 275 | newpacket.data = (char *) malloc(packet_profile_len); | |
| 276 | ||
| 277 | i = 0; | |
| 278 | /* SNAC: family */ | |
| 279 | newpacket.data[i++] = 0x00; | |
| 280 | newpacket.data[i++] = 0x02; | |
| 281 | /* SNAC: subtype */ | |
| 282 | newpacket.data[i++] = 0x00; | |
| 283 | newpacket.data[i++] = 0x04; | |
| 284 | /* SNAC: flags */ | |
| 285 | newpacket.data[i++] = 0x00; | |
| 286 | newpacket.data[i++] = 0x00; | |
| 287 | /* SNAC: id */ | |
| 288 | /* SNAC reqid */ | |
| 289 | newpacket.data[i++] = (aim_snac_nextid >> 24) & 0xFF; | |
| 290 | newpacket.data[i++] = (aim_snac_nextid >> 16) & 0xFF; | |
| 291 | newpacket.data[i++] = (aim_snac_nextid >> 8) & 0xFF; | |
| 292 | newpacket.data[i++] = (aim_snac_nextid) & 0xFF; | |
| 293 | /* TLV t(0001) */ | |
| 294 | newpacket.data[i++] = 0x00; | |
| 295 | newpacket.data[i++] = 0x01; | |
| 296 | /* TLV l(000d) */ | |
| 297 | newpacket.data[i++] = 0x00; | |
| 298 | newpacket.data[i++] = 0x0d; | |
| 299 | /* TLV v(text/x-aolrtf) */ | |
| 300 | memcpy(&(newpacket.data[i]), "text/x-aolrtf", 0x000d); | |
| 301 | i += 0x000d; | |
| 302 | ||
| 303 | /* TLV t(0002) */ | |
| 304 | newpacket.data[i++] = 0x00; | |
| 305 | newpacket.data[i++] = 0x02; | |
| 306 | /* TLV l() */ | |
| 307 | newpacket.data[i++] = (strlen(profile) >> 8) & 0xFF; | |
| 308 | newpacket.data[i++] = (strlen(profile) & 0xFF); | |
| 309 | /* TLV v(profile) */ | |
| 310 | memcpy(&(newpacket.data[i]), profile, strlen(profile)); | |
| 311 | ||
| 312 | aim_tx_enqueue(&newpacket); | |
| 313 | ||
| 314 | return (aim_snac_nextid++); | |
| 315 | } | |
| 316 | ||
| 317 | /* | |
| 318 | * aim_bos_setgroupperm(mask) | |
| 319 | * | |
| 320 | * Set group permisson mask. Normally 0x1f. | |
| 321 | * | |
| 322 | */ | |
| 323 | u_long aim_bos_setgroupperm(struct aim_conn_t *conn, u_long mask) | |
| 324 | { | |
| 325 | return aim_genericreq_l(conn, 0x0009, 0x0004, &mask); | |
| 326 | } | |
| 327 | ||
| 328 | /* | |
| 329 | * aim_bos_clientready() | |
| 330 | * | |
| 331 | * Send Client Ready. | |
| 332 | * | |
| 333 | * TODO: Dynamisize. | |
| 334 | * | |
| 335 | */ | |
| 336 | u_long aim_bos_clientready(struct aim_conn_t *conn) | |
| 337 | { | |
| 338 | char command_2[] = { | |
| 339 | 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x7a, 0x8c, | |
| 340 | 0x11, 0xab, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, | |
| 341 | 0x00, 0x13, 0x00, 0x09, 0x00, 0x01, 0x00, 0x01, | |
| 342 | 0x00, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x01, | |
| 343 | 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x01, | |
| 344 | 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, | |
| 345 | 0x00, 0x01, 0x00, 0x08, 0x00, 0x01, 0x00, 0x01, | |
| 346 | 0x00, 0x01, 0x00, 0x06, 0x00, 0x01, 0x00, 0x01, | |
| 347 | 0x00, 0x01, 0x00, 0x0a, 0x00, 0x01, 0x00, 0x01, | |
| 348 | 0x00, 0x01, 0x00, 0x0b, 0x00, 0x01, 0x00, 0x01, | |
| 349 | 0x00, 0x01 | |
| 350 | }; | |
| 351 | int command_2_len = 0x52; | |
| 352 | struct command_tx_struct newpacket; | |
| 353 | ||
| 354 | newpacket.lock = 1; | |
| 355 | if (conn) | |
| 356 | newpacket.conn = conn; | |
| 357 | else | |
| 358 | newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_BOS); | |
| 359 | newpacket.type = 0x02; | |
| 360 | newpacket.commandlen = command_2_len; | |
| 361 | newpacket.data = (char *) malloc (newpacket.commandlen); | |
| 362 | memcpy(newpacket.data, command_2, newpacket.commandlen); | |
| 363 | ||
| 364 | /* SNAC reqid */ | |
| 365 | newpacket.data[6] = (aim_snac_nextid >> 24) & 0xFF; | |
| 366 | newpacket.data[7] = (aim_snac_nextid >> 16) & 0xFF; | |
| 367 | newpacket.data[8] = (aim_snac_nextid >> 8) & 0xFF; | |
| 368 | newpacket.data[9] = (aim_snac_nextid) & 0xFF; | |
| 369 | ||
| 370 | aim_tx_enqueue(&newpacket); | |
| 371 | ||
| 372 | return (aim_snac_nextid++); | |
| 373 | } | |
| 374 | ||
| 375 | /* | |
| 376 | * send_login_phase3(int socket) | |
| 377 | * | |
| 378 | * Request Rate Information. | |
| 379 | * | |
| 380 | * TODO: Move to aim_conn. | |
| 381 | * TODO: Move to SNAC interface. | |
| 382 | */ | |
| 383 | u_long aim_bos_reqrate(struct aim_conn_t *conn) | |
| 384 | { | |
| 385 | return aim_genericreq_n(conn, 0x0001, 0x0006); | |
| 386 | } | |
| 387 | ||
| 388 | /* | |
| 389 | * send_login_phase3b(int socket) | |
| 390 | * | |
| 391 | * Rate Information Response Acknowledge. | |
| 392 | * | |
| 393 | */ | |
| 394 | u_long aim_bos_ackrateresp(struct aim_conn_t *conn) | |
| 395 | { | |
| 396 | struct command_tx_struct newpacket; | |
| 397 | ||
| 398 | newpacket.lock = 1; | |
| 399 | if (conn) | |
| 400 | newpacket.conn = conn; | |
| 401 | else | |
| 402 | newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_BOS); | |
| 403 | newpacket.type = 0x02; | |
| 404 | newpacket.commandlen = 18; | |
| 405 | ||
| 406 | newpacket.data = (char *) malloc(newpacket.commandlen); | |
| 407 | newpacket.data[0] = 0x00; | |
| 408 | newpacket.data[1] = 0x01; | |
| 409 | newpacket.data[2] = 0x00; | |
| 410 | newpacket.data[3] = 0x08; | |
| 411 | newpacket.data[4] = 0x00; | |
| 412 | newpacket.data[5] = 0x00; | |
| 413 | /* SNAC reqid */ | |
| 414 | newpacket.data[6] = (aim_snac_nextid >> 24) & 0xFF; | |
| 415 | newpacket.data[7] = (aim_snac_nextid >> 16) & 0xFF; | |
| 416 | newpacket.data[8] = (aim_snac_nextid >> 8) & 0xFF; | |
| 417 | newpacket.data[9] = (aim_snac_nextid) & 0xFF; | |
| 418 | ||
| 419 | newpacket.data[10] = 0x00; | |
| 420 | newpacket.data[11] = 0x01; | |
| 421 | newpacket.data[12] = 0x00; | |
| 422 | newpacket.data[13] = 0x02; | |
| 423 | newpacket.data[14] = 0x00; | |
| 424 | newpacket.data[15] = 0x03; | |
| 425 | newpacket.data[16] = 0x00; | |
| 426 | newpacket.data[17] = 0x04; | |
| 427 | ||
| 428 | aim_tx_enqueue(&newpacket); | |
| 429 | ||
| 430 | return (aim_snac_nextid++); | |
| 431 | } | |
| 432 | ||
| 433 | /* | |
| 434 | * aim_bos_setprivacyflags() | |
| 435 | * | |
| 436 | * Sets privacy flags. Normally 0x03. | |
| 437 | * | |
| 438 | * Bit 1: Allows other AIM users to see how long you've been idle. | |
| 439 | * | |
| 440 | * | |
| 441 | */ | |
| 442 | u_long aim_bos_setprivacyflags(struct aim_conn_t *conn, u_long flags) | |
| 443 | { | |
| 444 | return aim_genericreq_l(conn, 0x0001, 0x0014, &flags); | |
| 445 | } | |
| 446 | ||
| 447 | /* | |
| 448 | * aim_bos_reqpersonalinfo() | |
| 449 | * | |
| 450 | * Requests the current user's information. Can't go generic on this one | |
| 451 | * because aparently it uses SNAC flags. | |
| 452 | * | |
| 453 | */ | |
| 454 | u_long aim_bos_reqpersonalinfo(struct aim_conn_t *conn) | |
| 455 | { | |
| 456 | struct command_tx_struct newpacket; | |
| 457 | ||
| 458 | newpacket.lock = 1; | |
| 459 | if (conn) | |
| 460 | newpacket.conn = conn; | |
| 461 | else | |
| 462 | newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_BOS); | |
| 463 | newpacket.type = 0x02; | |
| 464 | newpacket.commandlen = 12; | |
| 465 | ||
| 466 | newpacket.data = (char *) malloc(newpacket.commandlen); | |
| 467 | ||
| 468 | newpacket.data[0] = 0x00; | |
| 469 | newpacket.data[1] = 0x0a; | |
| 470 | newpacket.data[2] = 0x00; | |
| 471 | newpacket.data[3] = 0x01; | |
| 472 | newpacket.data[4] = 0x00; | |
| 473 | newpacket.data[5] = 0x0e; /* huh? */ | |
| 474 | ||
| 475 | /* SNAC reqid */ | |
| 476 | newpacket.data[6] = (aim_snac_nextid >> 24) & 0xFF; | |
| 477 | newpacket.data[7] = (aim_snac_nextid >> 16) & 0xFF; | |
| 478 | newpacket.data[8] = (aim_snac_nextid >> 8) & 0xFF; | |
| 479 | newpacket.data[9] = (aim_snac_nextid) & 0xFF; | |
| 480 | ||
| 481 | newpacket.data[10] = 0x0d; | |
| 482 | newpacket.data[11] = 0xda; | |
| 483 | ||
| 484 | aim_tx_enqueue(&newpacket); | |
| 485 | ||
| 486 | return (aim_snac_nextid++); | |
| 487 | } | |
| 488 | ||
| 489 | /* | |
| 490 | * aim_bos_reqservice(serviceid) | |
| 491 | * | |
| 492 | * Service request. | |
| 493 | * | |
| 494 | */ | |
| 495 | u_long aim_bos_reqservice(struct aim_conn_t *conn, u_short serviceid) | |
| 496 | { | |
| 497 | return aim_genericreq_s(conn, 0x0001, 0x0004, &serviceid); | |
| 498 | } | |
| 499 | ||
| 500 | /* | |
| 501 | * aim_bos_reqrights() | |
| 502 | * | |
| 503 | * Request BOS rights. | |
| 504 | * | |
| 505 | */ | |
| 506 | u_long aim_bos_reqrights(struct aim_conn_t *conn) | |
| 507 | { | |
| 508 | return aim_genericreq_n(conn, 0x0009, 0x0002); | |
| 509 | } | |
| 510 | ||
| 511 | /* | |
| 512 | * aim_bos_reqbuddyrights() | |
| 513 | * | |
| 514 | * Request Buddy List rights. | |
| 515 | * | |
| 516 | */ | |
| 517 | u_long aim_bos_reqbuddyrights(struct aim_conn_t *conn) | |
| 518 | { | |
| 519 | return aim_genericreq_n(conn, 0x0003, 0x0002); | |
| 520 | } | |
| 521 | ||
| 522 | /* | |
| 523 | * Generic routine for sending commands. | |
| 524 | * | |
| 525 | * | |
| 526 | * I know I can do this in a smarter way...but I'm not thinking straight | |
| 527 | * right now... | |
| 528 | * | |
| 529 | * I had one big function that handled all three cases, but then it broke | |
| 530 | * and I split it up into three. But then I fixed it. I just never went | |
| 531 | * back to the single. I don't see any advantage to doing it either way. | |
| 532 | * | |
| 533 | */ | |
| 534 | u_long aim_genericreq_n(struct aim_conn_t *conn, u_short family, u_short subtype) | |
| 535 | { | |
| 536 | struct command_tx_struct newpacket; | |
| 537 | ||
| 538 | newpacket.lock = 1; | |
| 539 | ||
| 540 | if (conn) | |
| 541 | newpacket.conn = conn; | |
| 542 | else | |
| 543 | newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_BOS); | |
| 544 | newpacket.type = 0x02; | |
| 545 | ||
| 546 | newpacket.commandlen = 10; | |
| 547 | ||
| 548 | newpacket.data = (char *) malloc(newpacket.commandlen); | |
| 549 | memset(newpacket.data, 0x00, newpacket.commandlen); | |
| 550 | newpacket.data[0] = (family & 0xff00)>>8; | |
| 551 | newpacket.data[1] = family & 0xff; | |
| 552 | newpacket.data[2] = (subtype & 0xff00)>>8; | |
| 553 | newpacket.data[3] = subtype & 0xff; | |
| 554 | newpacket.data[4] = 0x00; | |
| 555 | newpacket.data[5] = 0x00; | |
| 556 | /* SNAC reqid */ | |
| 557 | newpacket.data[6] = (aim_snac_nextid >> 24) & 0xFF; | |
| 558 | newpacket.data[7] = (aim_snac_nextid >> 16) & 0xFF; | |
| 559 | newpacket.data[8] = (aim_snac_nextid >> 8) & 0xFF; | |
| 560 | newpacket.data[9] = (aim_snac_nextid) & 0xFF; | |
| 561 | ||
| 562 | aim_tx_enqueue(&newpacket); | |
| 563 | return (aim_snac_nextid++); | |
| 564 | } | |
| 565 | ||
| 566 | /* | |
| 567 | * | |
| 568 | * | |
| 569 | */ | |
| 570 | u_long aim_genericreq_l(struct aim_conn_t *conn, u_short family, u_short subtype, u_long *longdata) | |
| 571 | { | |
| 572 | struct command_tx_struct newpacket; | |
| 573 | u_long newlong; | |
| 574 | ||
| 575 | /* If we don't have data, there's no reason to use this function */ | |
| 576 | if (!longdata) | |
| 577 | return aim_genericreq_n(conn, family, subtype); | |
| 578 | ||
| 579 | newpacket.lock = 1; | |
| 580 | ||
| 581 | if (conn) | |
| 582 | newpacket.conn = conn; | |
| 583 | else | |
| 584 | newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_BOS); | |
| 585 | newpacket.type = 0x02; | |
| 586 | ||
| 587 | newpacket.commandlen = 10+sizeof(u_long); | |
| 588 | ||
| 589 | newpacket.data = (char *) malloc(newpacket.commandlen); | |
| 590 | memset(newpacket.data, 0x00, newpacket.commandlen); | |
| 591 | ||
| 592 | newpacket.data[0] = (family & 0xff00)>>8; | |
| 593 | newpacket.data[1] = family & 0xff; | |
| 594 | newpacket.data[2] = (subtype & 0xff00)>>8; | |
| 595 | newpacket.data[3] = subtype & 0xff; | |
| 596 | newpacket.data[4] = 0x00; | |
| 597 | newpacket.data[5] = 0x00; | |
| 598 | /* SNAC reqid */ | |
| 599 | newpacket.data[6] = (aim_snac_nextid >> 24) & 0xFF; | |
| 600 | newpacket.data[7] = (aim_snac_nextid >> 16) & 0xFF; | |
| 601 | newpacket.data[8] = (aim_snac_nextid >> 8) & 0xFF; | |
| 602 | newpacket.data[9] = (aim_snac_nextid) & 0xFF; | |
| 603 | ||
| 604 | /* copy in data */ | |
| 605 | newlong = htonl(*longdata); | |
| 606 | memcpy(&(newpacket.data[10]), &newlong, sizeof(u_long)); | |
| 607 | ||
| 608 | aim_tx_enqueue(&newpacket); | |
| 609 | return (aim_snac_nextid++); | |
| 610 | } | |
| 611 | ||
| 612 | u_long aim_genericreq_s(struct aim_conn_t *conn, u_short family, u_short subtype, u_short *shortdata) | |
| 613 | { | |
| 614 | struct command_tx_struct newpacket; | |
| 615 | u_short newshort; | |
| 616 | ||
| 617 | /* If we don't have data, there's no reason to use this function */ | |
| 618 | if (!shortdata) | |
| 619 | return aim_genericreq_n(conn, family, subtype); | |
| 620 | ||
| 621 | newpacket.lock = 1; | |
| 622 | ||
| 623 | if (conn) | |
| 624 | newpacket.conn = conn; | |
| 625 | else | |
| 626 | newpacket.conn = aim_getconn_type(AIM_CONN_TYPE_BOS); | |
| 627 | newpacket.type = 0x02; | |
| 628 | ||
| 629 | newpacket.commandlen = 10+sizeof(u_short); | |
| 630 | ||
| 631 | newpacket.data = (char *) malloc(newpacket.commandlen); | |
| 632 | memset(newpacket.data, 0x00, newpacket.commandlen); | |
| 633 | ||
| 634 | newpacket.data[0] = (family & 0xff00)>>8; | |
| 635 | newpacket.data[1] = family & 0xff; | |
| 636 | newpacket.data[2] = (subtype & 0xff00)>>8; | |
| 637 | newpacket.data[3] = subtype & 0xff; | |
| 638 | newpacket.data[4] = 0x00; | |
| 639 | newpacket.data[5] = 0x00; | |
| 640 | /* SNAC reqid */ | |
| 641 | newpacket.data[6] = (aim_snac_nextid >> 24) & 0xFF; | |
| 642 | newpacket.data[7] = (aim_snac_nextid >> 16) & 0xFF; | |
| 643 | newpacket.data[8] = (aim_snac_nextid >> 8) & 0xFF; | |
| 644 | newpacket.data[9] = (aim_snac_nextid) & 0xFF; | |
| 645 | ||
| 646 | /* copy in data */ | |
| 647 | newshort = htons(*shortdata); | |
| 648 | memcpy(&(newpacket.data[10]), &newshort, sizeof(u_short)); | |
| 649 | ||
| 650 | aim_tx_enqueue(&newpacket); | |
| 651 | return (aim_snac_nextid++); | |
| 652 | } | |
| 653 | ||
| 654 | /* | |
| 655 | * aim_bos_reqlocaterights() | |
| 656 | * | |
| 657 | * Request Location services rights. | |
| 658 | * | |
| 659 | */ | |
| 660 | u_long aim_bos_reqlocaterights(struct aim_conn_t *conn) | |
| 661 | { | |
| 662 | return aim_genericreq_n(conn, 0x0002, 0x0002); | |
| 663 | } | |
| 664 | ||
| 665 | /* | |
| 666 | * aim_bos_reqicbmparaminfo() | |
| 667 | * | |
| 668 | * Request ICBM parameter information. | |
| 669 | * | |
| 670 | */ | |
| 671 | u_long aim_bos_reqicbmparaminfo(struct aim_conn_t *conn) | |
| 672 | { | |
| 673 | return aim_genericreq_n(conn, 0x0004, 0x0004); | |
| 674 | } |