comparison src/protocols/oscar/family_icq.c @ 13592:6519aeb66b31

[gaim-migrate @ 15978] Holy cow this is crazy. 34 files changed, 5760 insertions(+), 8517 deletions(-) * Non-blocking I/O for all of oscar. That includes normal FLAP connections as well as file transfers and direct IM. * Kick-ass file transfer and direct IM. Either party can request the connection. Gaim will try both the "public" IP and the "client" IP. It'll fall back to transferring through a proxy if that fails. Should be relatively few memleaks (I didn't have a lot of confidence in the non-memleakiness of the old code). And the code is reasonably generic, so it shouldn't be too much work to add voice chat. This might still be a LITTLE buggy, but it shouldn't be too bad. If anything, file transfer will be more buggy than direct IM. And sending a file will be more buggy than receiving a file. Bug reports with a series of steps to reproduce are welcome. * I merged OscarData and aim_session_t * Somewhere between 50 and 100 hours of work. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 07 Apr 2006 05:10:56 +0000
parents 87a7c3077c19
children
comparison
equal deleted inserted replaced
13591:dcfda39ad547 13592:6519aeb66b31
23 * 23 *
24 */ 24 */
25 25
26 #include "oscar.h" 26 #include "oscar.h"
27 27
28 faim_export int aim_icq_reqofflinemsgs(OscarSession *sess) 28 int aim_icq_reqofflinemsgs(OscarData *od)
29 { 29 {
30 OscarConnection *conn; 30 FlapConnection *conn;
31 FlapFrame *fr; 31 FlapFrame *frame;
32 aim_snacid_t snacid; 32 aim_snacid_t snacid;
33 int bslen; 33 int bslen;
34 34
35 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) 35 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
36 return -EINVAL; 36 return -EINVAL;
37 37
38 bslen = 2 + 4 + 2 + 2; 38 bslen = 2 + 4 + 2 + 2;
39 39
40 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) 40 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
41 return -ENOMEM; 41
42 42 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
43 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); 43 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
44 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); 44
45 45 /* For simplicity, don't bother using a tlvlist */
46 /* For simplicity, don't bother using a tlvlist */ 46 byte_stream_put16(&frame->data, 0x0001);
47 aimbs_put16(&fr->data, 0x0001); 47 byte_stream_put16(&frame->data, bslen);
48 aimbs_put16(&fr->data, bslen); 48
49 49 byte_stream_putle16(&frame->data, bslen - 2);
50 aimbs_putle16(&fr->data, bslen - 2); 50 byte_stream_putle32(&frame->data, atoi(od->sn));
51 aimbs_putle32(&fr->data, atoi(sess->sn)); 51 byte_stream_putle16(&frame->data, 0x003c); /* I command thee. */
52 aimbs_putle16(&fr->data, 0x003c); /* I command thee. */ 52 byte_stream_putle16(&frame->data, snacid); /* eh. */
53 aimbs_putle16(&fr->data, snacid); /* eh. */ 53
54 54 flap_connection_send(conn, frame);
55 aim_tx_enqueue(sess, fr); 55
56 56 return 0;
57 return 0; 57 }
58 } 58
59 59 int aim_icq_ackofflinemsgs(OscarData *od)
60 faim_export int aim_icq_ackofflinemsgs(OscarSession *sess) 60 {
61 { 61 FlapConnection *conn;
62 OscarConnection *conn; 62 FlapFrame *frame;
63 FlapFrame *fr;
64 aim_snacid_t snacid; 63 aim_snacid_t snacid;
65 int bslen; 64 int bslen;
66 65
67 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) 66 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
68 return -EINVAL; 67 return -EINVAL;
69 68
70 bslen = 2 + 4 + 2 + 2; 69 bslen = 2 + 4 + 2 + 2;
71 70
72 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) 71 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
73 return -ENOMEM; 72
74 73 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
75 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); 74 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
76 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); 75
77 76 /* For simplicity, don't bother using a tlvlist */
78 /* For simplicity, don't bother using a tlvlist */ 77 byte_stream_put16(&frame->data, 0x0001);
79 aimbs_put16(&fr->data, 0x0001); 78 byte_stream_put16(&frame->data, bslen);
80 aimbs_put16(&fr->data, bslen); 79
81 80 byte_stream_putle16(&frame->data, bslen - 2);
82 aimbs_putle16(&fr->data, bslen - 2); 81 byte_stream_putle32(&frame->data, atoi(od->sn));
83 aimbs_putle32(&fr->data, atoi(sess->sn)); 82 byte_stream_putle16(&frame->data, 0x003e); /* I command thee. */
84 aimbs_putle16(&fr->data, 0x003e); /* I command thee. */ 83 byte_stream_putle16(&frame->data, snacid); /* eh. */
85 aimbs_putle16(&fr->data, snacid); /* eh. */ 84
86 85 flap_connection_send(conn, frame);
87 aim_tx_enqueue(sess, fr); 86
88 87 return 0;
89 return 0; 88 }
90 } 89
91 90 int
92 faim_export int 91 aim_icq_setsecurity(OscarData *od, gboolean auth_required, gboolean webaware)
93 aim_icq_setsecurity(OscarSession *sess, gboolean auth_required, gboolean webaware) 92 {
94 { 93 FlapConnection *conn;
95 OscarConnection *conn; 94 FlapFrame *frame;
96 FlapFrame *fr;
97 aim_snacid_t snacid; 95 aim_snacid_t snacid;
98 int bslen; 96 int bslen;
99 97
100 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) 98 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
101 return -EINVAL; 99 return -EINVAL;
102 100
103 bslen = 2+4+2+2+2+2+2+1+1+1+1+1+1; 101 bslen = 2+4+2+2+2+2+2+1+1+1+1+1+1;
104 102
105 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) 103 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
106 return -ENOMEM; 104
107 105 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
108 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); 106 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
109 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); 107
110 108 /* For simplicity, don't bother using a tlvlist */
111 /* For simplicity, don't bother using a tlvlist */ 109 byte_stream_put16(&frame->data, 0x0001);
112 aimbs_put16(&fr->data, 0x0001); 110 byte_stream_put16(&frame->data, bslen);
113 aimbs_put16(&fr->data, bslen); 111
114 112 byte_stream_putle16(&frame->data, bslen - 2);
115 aimbs_putle16(&fr->data, bslen - 2); 113 byte_stream_putle32(&frame->data, atoi(od->sn));
116 aimbs_putle32(&fr->data, atoi(sess->sn)); 114 byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */
117 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ 115 byte_stream_putle16(&frame->data, snacid); /* eh. */
118 aimbs_putle16(&fr->data, snacid); /* eh. */ 116 byte_stream_putle16(&frame->data, 0x0c3a); /* shrug. */
119 aimbs_putle16(&fr->data, 0x0c3a); /* shrug. */ 117 byte_stream_putle16(&frame->data, 0x030c);
120 aimbs_putle16(&fr->data, 0x030c); 118 byte_stream_putle16(&frame->data, 0x0001);
121 aimbs_putle16(&fr->data, 0x0001); 119 byte_stream_putle8(&frame->data, webaware);
122 aimbs_putle8(&fr->data, webaware); 120 byte_stream_putle8(&frame->data, 0xf8);
123 aimbs_putle8(&fr->data, 0xf8); 121 byte_stream_putle8(&frame->data, 0x02);
124 aimbs_putle8(&fr->data, 0x02); 122 byte_stream_putle8(&frame->data, 0x01);
125 aimbs_putle8(&fr->data, 0x01); 123 byte_stream_putle8(&frame->data, 0x00);
126 aimbs_putle8(&fr->data, 0x00); 124 byte_stream_putle8(&frame->data, !auth_required);
127 aimbs_putle8(&fr->data, !auth_required); 125
128 126 flap_connection_send(conn, frame);
129 aim_tx_enqueue(sess, fr);
130 127
131 return 0; 128 return 0;
132 } 129 }
133 130
134 /** 131 /**
135 * Change your ICQ password. 132 * Change your ICQ password.
136 * 133 *
137 * @param sess The oscar session 134 * @param od The oscar session
138 * @param passwd The new password. If this is longer than 8 characters it 135 * @param passwd The new password. If this is longer than 8 characters it
139 * will be truncated. 136 * will be truncated.
140 * @return Return 0 if no errors, otherwise return the error number. 137 * @return Return 0 if no errors, otherwise return the error number.
141 */ 138 */
142 faim_export int aim_icq_changepasswd(OscarSession *sess, const char *passwd) 139 int aim_icq_changepasswd(OscarData *od, const char *passwd)
143 { 140 {
144 OscarConnection *conn; 141 FlapConnection *conn;
145 FlapFrame *fr; 142 FlapFrame *frame;
146 aim_snacid_t snacid; 143 aim_snacid_t snacid;
147 int bslen, passwdlen; 144 int bslen, passwdlen;
148 145
149 if (!passwd) 146 if (!passwd)
150 return -EINVAL; 147 return -EINVAL;
151 148
152 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) 149 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
153 return -EINVAL; 150 return -EINVAL;
154 151
155 passwdlen = strlen(passwd); 152 passwdlen = strlen(passwd);
156 if (passwdlen > MAXICQPASSLEN) 153 if (passwdlen > MAXICQPASSLEN)
157 passwdlen = MAXICQPASSLEN; 154 passwdlen = MAXICQPASSLEN;
158 bslen = 2+4+2+2+2+2+passwdlen+1; 155 bslen = 2+4+2+2+2+2+passwdlen+1;
159 156
160 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) 157 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
161 return -ENOMEM; 158
162 159 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
163 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); 160 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
164 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); 161
165 162 /* For simplicity, don't bother using a tlvlist */
166 /* For simplicity, don't bother using a tlvlist */ 163 byte_stream_put16(&frame->data, 0x0001);
167 aimbs_put16(&fr->data, 0x0001); 164 byte_stream_put16(&frame->data, bslen);
168 aimbs_put16(&fr->data, bslen); 165
169 166 byte_stream_putle16(&frame->data, bslen - 2);
170 aimbs_putle16(&fr->data, bslen - 2); 167 byte_stream_putle32(&frame->data, atoi(od->sn));
171 aimbs_putle32(&fr->data, atoi(sess->sn)); 168 byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */
172 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ 169 byte_stream_putle16(&frame->data, snacid); /* eh. */
173 aimbs_putle16(&fr->data, snacid); /* eh. */ 170 byte_stream_putle16(&frame->data, 0x042e); /* shrug. */
174 aimbs_putle16(&fr->data, 0x042e); /* shrug. */ 171 byte_stream_putle16(&frame->data, passwdlen+1);
175 aimbs_putle16(&fr->data, passwdlen+1); 172 byte_stream_putstr(&frame->data, passwd);
176 aimbs_putstr(&fr->data, passwd); 173 byte_stream_putle8(&frame->data, '\0');
177 aimbs_putle8(&fr->data, '\0'); 174
178 175 flap_connection_send(conn, frame);
179 aim_tx_enqueue(sess, fr); 176
180 177 return 0;
181 return 0; 178 }
182 } 179
183 180 int aim_icq_getallinfo(OscarData *od, const char *uin)
184 faim_export int aim_icq_getallinfo(OscarSession *sess, const char *uin) 181 {
185 { 182 FlapConnection *conn;
186 OscarConnection *conn; 183 FlapFrame *frame;
187 FlapFrame *fr;
188 aim_snacid_t snacid; 184 aim_snacid_t snacid;
189 int bslen; 185 int bslen;
190 struct aim_icq_info *info; 186 struct aim_icq_info *info;
191 187
192 if (!uin || uin[0] < '0' || uin[0] > '9') 188 if (!uin || uin[0] < '0' || uin[0] > '9')
193 return -EINVAL; 189 return -EINVAL;
194 190
195 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) 191 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
196 return -EINVAL; 192 return -EINVAL;
197 193
198 bslen = 2 + 4 + 2 + 2 + 2 + 4; 194 bslen = 2 + 4 + 2 + 2 + 2 + 4;
199 195
200 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) 196 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
201 return -ENOMEM; 197
202 198 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
203 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); 199 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
204 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); 200
205 201 /* For simplicity, don't bother using a tlvlist */
206 /* For simplicity, don't bother using a tlvlist */ 202 byte_stream_put16(&frame->data, 0x0001);
207 aimbs_put16(&fr->data, 0x0001); 203 byte_stream_put16(&frame->data, bslen);
208 aimbs_put16(&fr->data, bslen); 204
209 205 byte_stream_putle16(&frame->data, bslen - 2);
210 aimbs_putle16(&fr->data, bslen - 2); 206 byte_stream_putle32(&frame->data, atoi(od->sn));
211 aimbs_putle32(&fr->data, atoi(sess->sn)); 207 byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */
212 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ 208 byte_stream_putle16(&frame->data, snacid); /* eh. */
213 aimbs_putle16(&fr->data, snacid); /* eh. */ 209 byte_stream_putle16(&frame->data, 0x04b2); /* shrug. */
214 aimbs_putle16(&fr->data, 0x04b2); /* shrug. */ 210 byte_stream_putle32(&frame->data, atoi(uin));
215 aimbs_putle32(&fr->data, atoi(uin)); 211
216 212 flap_connection_send(conn, frame);
217 aim_tx_enqueue(sess, fr);
218 213
219 /* Keep track of this request and the ICQ number and request ID */ 214 /* Keep track of this request and the ICQ number and request ID */
220 info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info)); 215 info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info));
221 info->reqid = snacid; 216 info->reqid = snacid;
222 info->uin = atoi(uin); 217 info->uin = atoi(uin);
223 info->next = sess->icq_info; 218 info->next = od->icq_info;
224 sess->icq_info = info; 219 od->icq_info = info;
225 220
226 return 0; 221 return 0;
227 } 222 }
228 223
229 faim_export int aim_icq_getalias(OscarSession *sess, const char *uin) 224 int aim_icq_getalias(OscarData *od, const char *uin)
230 { 225 {
231 OscarConnection *conn; 226 FlapConnection *conn;
232 FlapFrame *fr; 227 FlapFrame *frame;
233 aim_snacid_t snacid; 228 aim_snacid_t snacid;
234 int bslen; 229 int bslen;
235 struct aim_icq_info *info; 230 struct aim_icq_info *info;
236 231
237 if (!uin || uin[0] < '0' || uin[0] > '9') 232 if (!uin || uin[0] < '0' || uin[0] > '9')
238 return -EINVAL; 233 return -EINVAL;
239 234
240 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) 235 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
241 return -EINVAL; 236 return -EINVAL;
242 237
243 bslen = 2 + 4 + 2 + 2 + 2 + 4; 238 bslen = 2 + 4 + 2 + 2 + 2 + 4;
244 239
245 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) 240 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
246 return -ENOMEM; 241
247 242 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
248 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); 243 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
249 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); 244
250 245 /* For simplicity, don't bother using a tlvlist */
251 /* For simplicity, don't bother using a tlvlist */ 246 byte_stream_put16(&frame->data, 0x0001);
252 aimbs_put16(&fr->data, 0x0001); 247 byte_stream_put16(&frame->data, bslen);
253 aimbs_put16(&fr->data, bslen); 248
254 249 byte_stream_putle16(&frame->data, bslen - 2);
255 aimbs_putle16(&fr->data, bslen - 2); 250 byte_stream_putle32(&frame->data, atoi(od->sn));
256 aimbs_putle32(&fr->data, atoi(sess->sn)); 251 byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */
257 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ 252 byte_stream_putle16(&frame->data, snacid); /* eh. */
258 aimbs_putle16(&fr->data, snacid); /* eh. */ 253 byte_stream_putle16(&frame->data, 0x04ba); /* shrug. */
259 aimbs_putle16(&fr->data, 0x04ba); /* shrug. */ 254 byte_stream_putle32(&frame->data, atoi(uin));
260 aimbs_putle32(&fr->data, atoi(uin)); 255
261 256 flap_connection_send(conn, frame);
262 aim_tx_enqueue(sess, fr);
263 257
264 /* Keep track of this request and the ICQ number and request ID */ 258 /* Keep track of this request and the ICQ number and request ID */
265 info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info)); 259 info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info));
266 info->reqid = snacid; 260 info->reqid = snacid;
267 info->uin = atoi(uin); 261 info->uin = atoi(uin);
268 info->next = sess->icq_info; 262 info->next = od->icq_info;
269 sess->icq_info = info; 263 od->icq_info = info;
270 264
271 return 0; 265 return 0;
272 } 266 }
273 267
274 faim_export int aim_icq_getsimpleinfo(OscarSession *sess, const char *uin) 268 int aim_icq_getsimpleinfo(OscarData *od, const char *uin)
275 { 269 {
276 OscarConnection *conn; 270 FlapConnection *conn;
277 FlapFrame *fr; 271 FlapFrame *frame;
278 aim_snacid_t snacid; 272 aim_snacid_t snacid;
279 int bslen; 273 int bslen;
280 274
281 if (!uin || uin[0] < '0' || uin[0] > '9') 275 if (!uin || uin[0] < '0' || uin[0] > '9')
282 return -EINVAL; 276 return -EINVAL;
283 277
284 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) 278 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
285 return -EINVAL; 279 return -EINVAL;
286 280
287 bslen = 2 + 4 + 2 + 2 + 2 + 4; 281 bslen = 2 + 4 + 2 + 2 + 2 + 4;
288 282
289 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) 283 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
290 return -ENOMEM; 284
291 285 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
292 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); 286 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
293 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); 287
294 288 /* For simplicity, don't bother using a tlvlist */
295 /* For simplicity, don't bother using a tlvlist */ 289 byte_stream_put16(&frame->data, 0x0001);
296 aimbs_put16(&fr->data, 0x0001); 290 byte_stream_put16(&frame->data, bslen);
297 aimbs_put16(&fr->data, bslen); 291
298 292 byte_stream_putle16(&frame->data, bslen - 2);
299 aimbs_putle16(&fr->data, bslen - 2); 293 byte_stream_putle32(&frame->data, atoi(od->sn));
300 aimbs_putle32(&fr->data, atoi(sess->sn)); 294 byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */
301 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ 295 byte_stream_putle16(&frame->data, snacid); /* eh. */
302 aimbs_putle16(&fr->data, snacid); /* eh. */ 296 byte_stream_putle16(&frame->data, 0x051f); /* shrug. */
303 aimbs_putle16(&fr->data, 0x051f); /* shrug. */ 297 byte_stream_putle32(&frame->data, atoi(uin));
304 aimbs_putle32(&fr->data, atoi(uin)); 298
305 299 flap_connection_send(conn, frame);
306 aim_tx_enqueue(sess, fr);
307 300
308 return 0; 301 return 0;
309 } 302 }
310 303
311 #if 0 304 #if 0
312 faim_export int aim_icq_sendxmlreq(OscarSession *sess, const char *xml) 305 int aim_icq_sendxmlreq(OscarData *od, const char *xml)
313 { 306 {
314 OscarConnection *conn; 307 FlapConnection *conn;
315 FlapFrame *fr; 308 FlapFrame *frame;
316 aim_snacid_t snacid; 309 aim_snacid_t snacid;
317 int bslen; 310 int bslen;
318 311
319 if (!xml || !strlen(xml)) 312 if (!xml || !strlen(xml))
320 return -EINVAL; 313 return -EINVAL;
321 314
322 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) 315 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
323 return -EINVAL; 316 return -EINVAL;
324 317
325 bslen = 2 + 10 + 2 + strlen(xml) + 1; 318 bslen = 2 + 10 + 2 + strlen(xml) + 1;
326 319
327 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) 320 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
328 return -ENOMEM; 321
329 322 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
330 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); 323 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
331 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); 324
332 325 /* For simplicity, don't bother using a tlvlist */
333 /* For simplicity, don't bother using a tlvlist */ 326 byte_stream_put16(&frame->data, 0x0001);
334 aimbs_put16(&fr->data, 0x0001); 327 byte_stream_put16(&frame->data, bslen);
335 aimbs_put16(&fr->data, bslen); 328
336 329 byte_stream_putle16(&frame->data, bslen - 2);
337 aimbs_putle16(&fr->data, bslen - 2); 330 byte_stream_putle32(&frame->data, atoi(od->sn));
338 aimbs_putle32(&fr->data, atoi(sess->sn)); 331 byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */
339 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ 332 byte_stream_putle16(&frame->data, snacid); /* eh. */
340 aimbs_putle16(&fr->data, snacid); /* eh. */ 333 byte_stream_putle16(&frame->data, 0x0998); /* shrug. */
341 aimbs_putle16(&fr->data, 0x0998); /* shrug. */ 334 byte_stream_putle16(&frame->data, strlen(xml) + 1);
342 aimbs_putle16(&fr->data, strlen(xml) + 1); 335 byte_stream_putraw(&frame->data, (guint8 *)xml, strlen(xml) + 1);
343 aimbs_putraw(&fr->data, (guint8 *)xml, strlen(xml) + 1); 336
344 337 flap_connection_send(conn, frame);
345 aim_tx_enqueue(sess, fr);
346 338
347 return 0; 339 return 0;
348 } 340 }
349 #endif 341 #endif
350 342
365 * </icq_sms_message> 357 * </icq_sms_message>
366 * 358 *
367 * Yeah hi Peter, whaaaat's happening. If there's any way to use 359 * Yeah hi Peter, whaaaat's happening. If there's any way to use
368 * a codepage other than 1252 that would be great. Thaaaanks. 360 * a codepage other than 1252 that would be great. Thaaaanks.
369 */ 361 */
370 faim_export int aim_icq_sendsms(OscarSession *sess, const char *name, const char *msg, const char *alias) 362 int aim_icq_sendsms(OscarData *od, const char *name, const char *msg, const char *alias)
371 { 363 {
372 OscarConnection *conn; 364 FlapConnection *conn;
373 FlapFrame *fr; 365 FlapFrame *frame;
374 aim_snacid_t snacid; 366 aim_snacid_t snacid;
375 int bslen, xmllen; 367 int bslen, xmllen;
376 char *xml; 368 char *xml;
377 const char *timestr; 369 const char *timestr;
378 time_t t; 370 time_t t;
379 struct tm *tm; 371 struct tm *tm;
380 372
381 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) 373 if (!od || !(conn = flap_connection_findbygroup(od, 0x0015)))
382 return -EINVAL; 374 return -EINVAL;
383 375
384 if (!name || !msg || !alias) 376 if (!name || !msg || !alias)
385 return -EINVAL; 377 return -EINVAL;
386 378
387 time(&t); 379 time(&t);
388 tm = gmtime(&t); 380 tm = gmtime(&t);
389 timestr = gaim_utf8_strftime("%a, %d %b %Y %T %Z", tm); 381 timestr = gaim_utf8_strftime("%a, %d %b %Y %T %Z", tm);
390 382
391 /* The length of xml included the null terminating character */ 383 /* The length of xml included the null terminating character */
392 xmllen = 225 + strlen(name) + strlen(msg) + strlen(sess->sn) + strlen(alias) + strlen(timestr) + 1; 384 xmllen = 225 + strlen(name) + strlen(msg) + strlen(od->sn) + strlen(alias) + strlen(timestr) + 1;
393 385
394 if (!(xml = (char *)malloc(xmllen*sizeof(char)))) 386 xml = g_new(char, xmllen);
395 return -ENOMEM;
396 snprintf(xml, xmllen, "<icq_sms_message>\n" 387 snprintf(xml, xmllen, "<icq_sms_message>\n"
397 "\t<destination>%s</destination>\n" 388 "\t<destination>%s</destination>\n"
398 "\t<text>%s</text>\n" 389 "\t<text>%s</text>\n"
399 "\t<codepage>1252</codepage>\n" 390 "\t<codepage>1252</codepage>\n"
400 "\t<senders_UIN>%s</senders_UIN>\n" 391 "\t<senders_UIN>%s</senders_UIN>\n"
401 "\t<senders_name>%s</senders_name>\n" 392 "\t<senders_name>%s</senders_name>\n"
402 "\t<delivery_receipt>Yes</delivery_receipt>\n" 393 "\t<delivery_receipt>Yes</delivery_receipt>\n"
403 "\t<time>%s</time>\n" 394 "\t<time>%s</time>\n"
404 "</icq_sms_message>\n", 395 "</icq_sms_message>\n",
405 name, msg, sess->sn, alias, timestr); 396 name, msg, od->sn, alias, timestr);
406 397
407 bslen = 37 + xmllen; 398 bslen = 37 + xmllen;
408 399
409 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) { 400 frame = flap_frame_new(od, 0x02, 10 + 4 + bslen);
410 free(xml); 401
411 return -ENOMEM; 402 snacid = aim_cachesnac(od, 0x0015, 0x0002, 0x0000, NULL, 0);
412 } 403 aim_putsnac(&frame->data, 0x0015, 0x0002, 0x0000, snacid);
413 404
414 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); 405 /* For simplicity, don't bother using a tlvlist */
415 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); 406 byte_stream_put16(&frame->data, 0x0001);
416 407 byte_stream_put16(&frame->data, bslen);
417 /* For simplicity, don't bother using a tlvlist */ 408
418 aimbs_put16(&fr->data, 0x0001); 409 byte_stream_putle16(&frame->data, bslen - 2);
419 aimbs_put16(&fr->data, bslen); 410 byte_stream_putle32(&frame->data, atoi(od->sn));
420 411 byte_stream_putle16(&frame->data, 0x07d0); /* I command thee. */
421 aimbs_putle16(&fr->data, bslen - 2); 412 byte_stream_putle16(&frame->data, snacid); /* eh. */
422 aimbs_putle32(&fr->data, atoi(sess->sn));
423 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */
424 aimbs_putle16(&fr->data, snacid); /* eh. */
425 413
426 /* From libicq200-0.3.2/src/SNAC-SRV.cpp */ 414 /* From libicq200-0.3.2/src/SNAC-SRV.cpp */
427 aimbs_putle16(&fr->data, 0x8214); 415 byte_stream_putle16(&frame->data, 0x8214);
428 aimbs_put16(&fr->data, 0x0001); 416 byte_stream_put16(&frame->data, 0x0001);
429 aimbs_put16(&fr->data, 0x0016); 417 byte_stream_put16(&frame->data, 0x0016);
430 aimbs_put32(&fr->data, 0x00000000); 418 byte_stream_put32(&frame->data, 0x00000000);
431 aimbs_put32(&fr->data, 0x00000000); 419 byte_stream_put32(&frame->data, 0x00000000);
432 aimbs_put32(&fr->data, 0x00000000); 420 byte_stream_put32(&frame->data, 0x00000000);
433 aimbs_put32(&fr->data, 0x00000000); 421 byte_stream_put32(&frame->data, 0x00000000);
434 422
435 aimbs_put16(&fr->data, 0x0000); 423 byte_stream_put16(&frame->data, 0x0000);
436 aimbs_put16(&fr->data, xmllen); 424 byte_stream_put16(&frame->data, xmllen);
437 aimbs_putstr(&fr->data, xml); 425 byte_stream_putstr(&frame->data, xml);
438 426
439 aim_tx_enqueue(sess, fr); 427 flap_connection_send(conn, frame);
440 428
441 free(xml); 429 free(xml);
442 430
443 return 0; 431 return 0;
444 } 432 }
480 } 468 }
481 469
482 /** 470 /**
483 * Subtype 0x0003 - Response to 0x0015/0x002, contains an ICQesque packet. 471 * Subtype 0x0003 - Response to 0x0015/0x002, contains an ICQesque packet.
484 */ 472 */
485 static int icqresponse(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) 473 static int
474 icqresponse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
486 { 475 {
487 int ret = 0; 476 int ret = 0;
488 aim_tlvlist_t *tl; 477 aim_tlvlist_t *tl;
489 aim_tlv_t *datatlv; 478 aim_tlv_t *datatlv;
490 ByteStream qbs; 479 ByteStream qbs;
495 aim_tlvlist_free(&tl); 484 aim_tlvlist_free(&tl);
496 gaim_debug_misc("oscar", "corrupt ICQ response\n"); 485 gaim_debug_misc("oscar", "corrupt ICQ response\n");
497 return 0; 486 return 0;
498 } 487 }
499 488
500 aim_bstream_init(&qbs, datatlv->value, datatlv->length); 489 byte_stream_init(&qbs, datatlv->value, datatlv->length);
501 490
502 cmdlen = aimbs_getle16(&qbs); 491 cmdlen = byte_stream_getle16(&qbs);
503 ouruin = aimbs_getle32(&qbs); 492 ouruin = byte_stream_getle32(&qbs);
504 cmd = aimbs_getle16(&qbs); 493 cmd = byte_stream_getle16(&qbs);
505 reqid = aimbs_getle16(&qbs); 494 reqid = byte_stream_getle16(&qbs);
506 495
507 gaim_debug_misc("oscar", "icq response: %d bytes, %ld, 0x%04x, 0x%04x\n", cmdlen, ouruin, cmd, reqid); 496 gaim_debug_misc("oscar", "icq response: %d bytes, %ld, 0x%04x, 0x%04x\n", cmdlen, ouruin, cmd, reqid);
508 497
509 if (cmd == 0x0041) { /* offline message */ 498 if (cmd == 0x0041) { /* offline message */
510 struct aim_icq_offlinemsg msg; 499 struct aim_icq_offlinemsg msg;
511 aim_rxcallback_t userfunc; 500 aim_rxcallback_t userfunc;
512 501
513 memset(&msg, 0, sizeof(msg)); 502 memset(&msg, 0, sizeof(msg));
514 503
515 msg.sender = aimbs_getle32(&qbs); 504 msg.sender = byte_stream_getle32(&qbs);
516 msg.year = aimbs_getle16(&qbs); 505 msg.year = byte_stream_getle16(&qbs);
517 msg.month = aimbs_getle8(&qbs); 506 msg.month = byte_stream_getle8(&qbs);
518 msg.day = aimbs_getle8(&qbs); 507 msg.day = byte_stream_getle8(&qbs);
519 msg.hour = aimbs_getle8(&qbs); 508 msg.hour = byte_stream_getle8(&qbs);
520 msg.minute = aimbs_getle8(&qbs); 509 msg.minute = byte_stream_getle8(&qbs);
521 msg.type = aimbs_getle8(&qbs); 510 msg.type = byte_stream_getle8(&qbs);
522 msg.flags = aimbs_getle8(&qbs); 511 msg.flags = byte_stream_getle8(&qbs);
523 msg.msglen = aimbs_getle16(&qbs); 512 msg.msglen = byte_stream_getle16(&qbs);
524 msg.msg = aimbs_getstr(&qbs, msg.msglen); 513 msg.msg = byte_stream_getstr(&qbs, msg.msglen);
525 514
526 if ((userfunc = aim_callhandler(sess, rx->conn, OSCAR_FAMILY_ICQ, OSCAR_SUBTYPE_ICQ_OFFLINEMSG))) 515 if ((userfunc = aim_callhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_OFFLINEMSG)))
527 ret = userfunc(sess, rx, &msg); 516 ret = userfunc(od, conn, frame, &msg);
528 517
529 free(msg.msg); 518 free(msg.msg);
530 519
531 } else if (cmd == 0x0042) { 520 } else if (cmd == 0x0042) {
532 aim_rxcallback_t userfunc; 521 aim_rxcallback_t userfunc;
533 522
534 if ((userfunc = aim_callhandler(sess, rx->conn, OSCAR_FAMILY_ICQ, OSCAR_SUBTYPE_ICQ_OFFLINEMSGCOMPLETE))) 523 if ((userfunc = aim_callhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_OFFLINEMSGCOMPLETE)))
535 ret = userfunc(sess, rx); 524 ret = userfunc(od, conn, frame);
536 525
537 } else if (cmd == 0x07da) { /* information */ 526 } else if (cmd == 0x07da) { /* information */
538 guint16 subtype; 527 guint16 subtype;
539 struct aim_icq_info *info; 528 struct aim_icq_info *info;
540 aim_rxcallback_t userfunc; 529 aim_rxcallback_t userfunc;
541 530
542 subtype = aimbs_getle16(&qbs); 531 subtype = byte_stream_getle16(&qbs);
543 aim_bstream_advance(&qbs, 1); /* 0x0a */ 532 byte_stream_advance(&qbs, 1); /* 0x0a */
544 533
545 /* find other data from the same request */ 534 /* find other data from the same request */
546 for (info = sess->icq_info; info && (info->reqid != reqid); info = info->next); 535 for (info = od->icq_info; info && (info->reqid != reqid); info = info->next);
547 if (!info) { 536 if (!info) {
548 info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info)); 537 info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info));
549 info->reqid = reqid; 538 info->reqid = reqid;
550 info->next = sess->icq_info; 539 info->next = od->icq_info;
551 sess->icq_info = info; 540 od->icq_info = info;
552 } 541 }
553 542
554 switch (subtype) { 543 switch (subtype) {
555 case 0x00a0: { /* hide ip status */ 544 case 0x00a0: { /* hide ip status */
556 /* nothing */ 545 /* nothing */
559 case 0x00aa: { /* password change status */ 548 case 0x00aa: { /* password change status */
560 /* nothing */ 549 /* nothing */
561 } break; 550 } break;
562 551
563 case 0x00c8: { /* general and "home" information */ 552 case 0x00c8: { /* general and "home" information */
564 info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 553 info->nick = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
565 info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 554 info->first = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
566 info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 555 info->last = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
567 info->email = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 556 info->email = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
568 info->homecity = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 557 info->homecity = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
569 info->homestate = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 558 info->homestate = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
570 info->homephone = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 559 info->homephone = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
571 info->homefax = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 560 info->homefax = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
572 info->homeaddr = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 561 info->homeaddr = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
573 info->mobile = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 562 info->mobile = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
574 info->homezip = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 563 info->homezip = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
575 info->homecountry = aimbs_getle16(&qbs); 564 info->homecountry = byte_stream_getle16(&qbs);
576 /* 0x0a 00 02 00 */ 565 /* 0x0a 00 02 00 */
577 /* 1 byte timezone? */ 566 /* 1 byte timezone? */
578 /* 1 byte hide email flag? */ 567 /* 1 byte hide email flag? */
579 } break; 568 } break;
580 569
581 case 0x00dc: { /* personal information */ 570 case 0x00dc: { /* personal information */
582 info->age = aimbs_getle8(&qbs); 571 info->age = byte_stream_getle8(&qbs);
583 info->unknown = aimbs_getle8(&qbs); 572 info->unknown = byte_stream_getle8(&qbs);
584 info->gender = aimbs_getle8(&qbs); /* Not specified=0x00, Female=0x01, Male=0x02 */ 573 info->gender = byte_stream_getle8(&qbs); /* Not specified=0x00, Female=0x01, Male=0x02 */
585 info->personalwebpage = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 574 info->personalwebpage = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
586 info->birthyear = aimbs_getle16(&qbs); 575 info->birthyear = byte_stream_getle16(&qbs);
587 info->birthmonth = aimbs_getle8(&qbs); 576 info->birthmonth = byte_stream_getle8(&qbs);
588 info->birthday = aimbs_getle8(&qbs); 577 info->birthday = byte_stream_getle8(&qbs);
589 info->language1 = aimbs_getle8(&qbs); 578 info->language1 = byte_stream_getle8(&qbs);
590 info->language2 = aimbs_getle8(&qbs); 579 info->language2 = byte_stream_getle8(&qbs);
591 info->language3 = aimbs_getle8(&qbs); 580 info->language3 = byte_stream_getle8(&qbs);
592 /* 0x00 00 01 00 00 01 00 00 00 00 00 */ 581 /* 0x00 00 01 00 00 01 00 00 00 00 00 */
593 } break; 582 } break;
594 583
595 case 0x00d2: { /* work information */ 584 case 0x00d2: { /* work information */
596 info->workcity = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 585 info->workcity = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
597 info->workstate = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 586 info->workstate = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
598 info->workphone = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 587 info->workphone = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
599 info->workfax = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 588 info->workfax = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
600 info->workaddr = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 589 info->workaddr = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
601 info->workzip = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 590 info->workzip = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
602 info->workcountry = aimbs_getle16(&qbs); 591 info->workcountry = byte_stream_getle16(&qbs);
603 info->workcompany = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 592 info->workcompany = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
604 info->workdivision = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 593 info->workdivision = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
605 info->workposition = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 594 info->workposition = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
606 aim_bstream_advance(&qbs, 2); /* 0x01 00 */ 595 byte_stream_advance(&qbs, 2); /* 0x01 00 */
607 info->workwebpage = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 596 info->workwebpage = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
608 } break; 597 } break;
609 598
610 case 0x00e6: { /* additional personal information */ 599 case 0x00e6: { /* additional personal information */
611 info->info = aimbs_getstr(&qbs, aimbs_getle16(&qbs)-1); 600 info->info = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs)-1);
612 } break; 601 } break;
613 602
614 case 0x00eb: { /* email address(es) */ 603 case 0x00eb: { /* email address(es) */
615 int i; 604 int i;
616 info->numaddresses = aimbs_getle16(&qbs); 605 info->numaddresses = byte_stream_getle16(&qbs);
617 info->email2 = (char **)calloc(info->numaddresses, sizeof(char *)); 606 info->email2 = (char **)calloc(info->numaddresses, sizeof(char *));
618 for (i = 0; i < info->numaddresses; i++) { 607 for (i = 0; i < info->numaddresses; i++) {
619 info->email2[i] = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 608 info->email2[i] = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
620 if (i+1 != info->numaddresses) 609 if (i+1 != info->numaddresses)
621 aim_bstream_advance(&qbs, 1); /* 0x00 */ 610 byte_stream_advance(&qbs, 1); /* 0x00 */
622 } 611 }
623 } break; 612 } break;
624 613
625 case 0x00f0: { /* personal interests */ 614 case 0x00f0: { /* personal interests */
626 } break; 615 } break;
627 616
628 case 0x00fa: { /* past background and current organizations */ 617 case 0x00fa: { /* past background and current organizations */
629 } break; 618 } break;
630 619
631 case 0x0104: { /* alias info */ 620 case 0x0104: { /* alias info */
632 info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 621 info->nick = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
633 info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 622 info->first = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
634 info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 623 info->last = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
635 aim_bstream_advance(&qbs, aimbs_getle16(&qbs)); /* email address? */ 624 byte_stream_advance(&qbs, byte_stream_getle16(&qbs)); /* email address? */
636 /* Then 0x00 02 00 */ 625 /* Then 0x00 02 00 */
637 } break; 626 } break;
638 627
639 case 0x010e: { /* unknown */ 628 case 0x010e: { /* unknown */
640 /* 0x00 00 */ 629 /* 0x00 00 */
641 } break; 630 } break;
642 631
643 case 0x019a: { /* simple info */ 632 case 0x019a: { /* simple info */
644 aim_bstream_advance(&qbs, 2); 633 byte_stream_advance(&qbs, 2);
645 info->uin = aimbs_getle32(&qbs); 634 info->uin = byte_stream_getle32(&qbs);
646 info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 635 info->nick = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
647 info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 636 info->first = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
648 info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 637 info->last = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
649 info->email = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); 638 info->email = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
650 /* Then 0x00 02 00 00 00 00 00 */ 639 /* Then 0x00 02 00 00 00 00 00 */
651 } break; 640 } break;
652 } /* End switch statement */ 641 } /* End switch statement */
653 642
654 if (!(snac->flags & 0x0001)) { 643 if (!(snac->flags & 0x0001)) {
655 if (subtype != 0x0104) 644 if (subtype != 0x0104)
656 if ((userfunc = aim_callhandler(sess, rx->conn, OSCAR_FAMILY_ICQ, OSCAR_SUBTYPE_ICQ_INFO))) 645 if ((userfunc = aim_callhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_INFO)))
657 ret = userfunc(sess, rx, info); 646 ret = userfunc(od, conn, frame, info);
658 647
659 if (info->uin && info->nick) 648 if (info->uin && info->nick)
660 if ((userfunc = aim_callhandler(sess, rx->conn, OSCAR_FAMILY_ICQ, OSCAR_SUBTYPE_ICQ_ALIAS))) 649 if ((userfunc = aim_callhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_ALIAS)))
661 ret = userfunc(sess, rx, info); 650 ret = userfunc(od, conn, frame, info);
662 651
663 if (sess->icq_info == info) { 652 if (od->icq_info == info) {
664 sess->icq_info = info->next; 653 od->icq_info = info->next;
665 } else { 654 } else {
666 struct aim_icq_info *cur; 655 struct aim_icq_info *cur;
667 for (cur=sess->icq_info; (cur->next && (cur->next!=info)); cur=cur->next); 656 for (cur=od->icq_info; (cur->next && (cur->next!=info)); cur=cur->next);
668 if (cur->next) 657 if (cur->next)
669 cur->next = cur->next->next; 658 cur->next = cur->next->next;
670 } 659 }
671 aim_icq_freeinfo(info); 660 aim_icq_freeinfo(info);
672 } 661 }
675 aim_tlvlist_free(&tl); 664 aim_tlvlist_free(&tl);
676 665
677 return ret; 666 return ret;
678 } 667 }
679 668
680 static int snachandler(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) 669 static int
681 { 670 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs)
682 671 {
683 if (snac->subtype == 0x0003) 672 if (snac->subtype == 0x0003)
684 return icqresponse(sess, mod, rx, snac, bs); 673 return icqresponse(od, conn, mod, frame, snac, bs);
685 674
686 return 0; 675 return 0;
687 } 676 }
688 677
689 static void icq_shutdown(OscarSession *sess, aim_module_t *mod) 678 static void
679 icq_shutdown(OscarData *od, aim_module_t *mod)
690 { 680 {
691 struct aim_icq_info *del; 681 struct aim_icq_info *del;
692 682
693 while (sess->icq_info) { 683 while (od->icq_info) {
694 del = sess->icq_info; 684 del = od->icq_info;
695 sess->icq_info = sess->icq_info->next; 685 od->icq_info = od->icq_info->next;
696 aim_icq_freeinfo(del); 686 aim_icq_freeinfo(del);
697 } 687 }
698 688
699 return; 689 return;
700 } 690 }
701 691
702 faim_internal int icq_modfirst(OscarSession *sess, aim_module_t *mod) 692 int
703 { 693 icq_modfirst(OscarData *od, aim_module_t *mod)
704 694 {
705 mod->family = 0x0015; 695 mod->family = 0x0015;
706 mod->version = 0x0001; 696 mod->version = 0x0001;
707 mod->toolid = 0x0110; 697 mod->toolid = 0x0110;
708 mod->toolversion = 0x047c; 698 mod->toolversion = 0x047c;
709 mod->flags = 0; 699 mod->flags = 0;