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