Mercurial > pidgin.yaz
comparison src/oscar.c @ 302:61894ab8c47e
[gaim-migrate @ 312]
I think logging in for oscar works a bit better now.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 01 Jun 2000 10:06:37 +0000 |
parents | 6e609d42f767 |
children | 3069be4c291e |
comparison
equal
deleted
inserted
replaced
301:f905caee43ca | 302:61894ab8c47e |
---|---|
88 struct aim_conn_t *conn; | 88 struct aim_conn_t *conn; |
89 struct client_info_s info = {"Gaim/Faim", 3, 5, 1670, "us", "en"}; | 89 struct client_info_s info = {"Gaim/Faim", 3, 5, 1670, "us", "en"}; |
90 struct aim_user *u; | 90 struct aim_user *u; |
91 char buf[256]; | 91 char buf[256]; |
92 | 92 |
93 sprintf(debug_buff, "Logging in %s\n", username); | |
94 debug_print(debug_buff); | |
95 | |
93 sess = g_new0(struct aim_session_t, 1); | 96 sess = g_new0(struct aim_session_t, 1); |
94 aim_session_init(sess); | 97 aim_session_init(sess); |
95 /* we need an immediate queue because we don't use a while-loop to | 98 /* we need an immediate queue because we don't use a while-loop to |
96 * see if things need to be sent. */ | 99 * see if things need to be sent. */ |
97 sess->tx_enqueue = &aim_tx_enqueue__immediate; | 100 sess->tx_enqueue = &aim_tx_enqueue__immediate; |
151 "%s", username); | 154 "%s", username); |
152 g_snprintf(current_user->password, sizeof(current_user->password), | 155 g_snprintf(current_user->password, sizeof(current_user->password), |
153 "%s", password); | 156 "%s", password); |
154 save_prefs(); | 157 save_prefs(); |
155 | 158 |
159 debug_print("Password sent, waiting for response\n"); | |
160 | |
156 return 0; | 161 return 0; |
157 } | |
158 | |
159 int oscar_send_im(char *name, char *msg, int away) { | |
160 if (away) | |
161 return aim_send_im(gaim_sess, gaim_conn, name, AIM_IMFLAGS_AWAY, msg); | |
162 else | |
163 return aim_send_im(gaim_sess, gaim_conn, name, 0, msg); | |
164 } | 162 } |
165 | 163 |
166 void oscar_close() { | 164 void oscar_close() { |
167 #ifdef USE_APPLET | 165 #ifdef USE_APPLET |
168 setUserState(offline); | 166 setUserState(offline); |
170 set_state(STATE_OFFLINE); | 168 set_state(STATE_OFFLINE); |
171 if (inpa > 0) | 169 if (inpa > 0) |
172 gdk_input_remove(inpa); | 170 gdk_input_remove(inpa); |
173 inpa = -1; | 171 inpa = -1; |
174 aim_logoff(gaim_sess); | 172 aim_logoff(gaim_sess); |
173 debug_print("Signed off.\n"); | |
175 } | 174 } |
176 | 175 |
177 extern void auth_failed(); | 176 extern void auth_failed(); |
178 | 177 |
179 int gaim_parse_auth_resp(struct aim_session_t *sess, | 178 int gaim_parse_auth_resp(struct aim_session_t *sess, |
182 sprintf(debug_buff, "inside auth_resp (Screen name: %s)\n", | 181 sprintf(debug_buff, "inside auth_resp (Screen name: %s)\n", |
183 sess->logininfo.screen_name); | 182 sess->logininfo.screen_name); |
184 debug_print(debug_buff); | 183 debug_print(debug_buff); |
185 | 184 |
186 if (sess->logininfo.errorcode) { | 185 if (sess->logininfo.errorcode) { |
186 switch (sess->logininfo.errorcode) { | |
187 case 0x18: | |
188 do_error_dialog("You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer.", "Gaim - Error"); | |
189 break; | |
190 case 0x05: | |
191 do_error_dialog("Incorrect nickname or password.", "Gaim - Error"); | |
192 break; | |
193 case 0x1c: | |
194 do_error_dialog("AOL has decided your client is too old. Please download a newer version from http://www.marko.net/gaim/", "Gaim - Error"); | |
195 break; | |
196 } | |
187 sprintf(debug_buff, "Login Error Code 0x%04x\n", | 197 sprintf(debug_buff, "Login Error Code 0x%04x\n", |
188 sess->logininfo.errorcode); | 198 sess->logininfo.errorcode); |
189 debug_print(debug_buff); | 199 debug_print(debug_buff); |
190 sprintf(debug_buff, "Error URL: %s\n", | 200 sprintf(debug_buff, "Error URL: %s\n", |
191 sess->logininfo.errorurl); | 201 sess->logininfo.errorurl); |
264 case AIM_CONN_TYPE_BOS: | 274 case AIM_CONN_TYPE_BOS: |
265 aim_bos_reqrate(sess, command->conn); | 275 aim_bos_reqrate(sess, command->conn); |
266 aim_bos_ackrateresp(sess, command->conn); | 276 aim_bos_ackrateresp(sess, command->conn); |
267 aim_bos_setprivacyflags(sess, command->conn, 0x00000003); | 277 aim_bos_setprivacyflags(sess, command->conn, 0x00000003); |
268 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_ADS); | 278 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_ADS); |
269 aim_setversions(sess, command->conn); | |
270 aim_bos_setgroupperm(sess, command->conn, 0x1f); | 279 aim_bos_setgroupperm(sess, command->conn, 0x1f); |
271 debug_print("done with BOS ServerReady\n"); | 280 debug_print("done with BOS ServerReady\n"); |
272 break; | 281 break; |
273 case AIM_CONN_TYPE_CHATNAV: | 282 case AIM_CONN_TYPE_CHATNAV: |
283 debug_print("chatnav: got server ready\n"); | |
274 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); | 284 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0); |
275 aim_bos_reqrate(sess, command->conn); | 285 aim_bos_reqrate(sess, command->conn); |
276 aim_bos_ackrateresp(sess, command->conn); | 286 aim_bos_ackrateresp(sess, command->conn); |
277 aim_chatnav_clientready(sess, command->conn); | 287 aim_chatnav_clientready(sess, command->conn); |
278 aim_chatnav_reqrights(sess, command->conn); | 288 aim_chatnav_reqrights(sess, command->conn); |
279 break; | 289 break; |
280 case AIM_CONN_TYPE_CHAT: | 290 case AIM_CONN_TYPE_CHAT: |
291 debug_print("chat: got server ready\n"); | |
281 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); | 292 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0); |
282 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); | 293 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0); |
283 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); | 294 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0); |
284 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); | 295 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0); |
285 aim_bos_reqrate(sess, command->conn); | 296 aim_bos_reqrate(sess, command->conn); |
286 aim_bos_ackrateresp(sess, command->conn); | 297 aim_bos_ackrateresp(sess, command->conn); |
287 aim_chat_clientready(sess, command->conn); | 298 aim_chat_clientready(sess, command->conn); |
288 serv_got_joined_chat(id++, aim_chat_getname(command->conn)); | 299 serv_got_joined_chat(id++, aim_chat_getname(command->conn)); |
289 break; | 300 break; |
290 default: /* huh? */ | 301 default: /* huh? */ |
302 sprintf(debug_buff, "server ready: got unexpected connection type %04x\n", command->conn->type); | |
303 debug_print(debug_buff); | |
291 break; | 304 break; |
292 } | 305 } |
293 return 1; | 306 return 1; |
294 } | 307 } |
295 | 308 |
311 ip = va_arg(ap, char *); | 324 ip = va_arg(ap, char *); |
312 cookie = va_arg(ap, char *); | 325 cookie = va_arg(ap, char *); |
313 | 326 |
314 switch(serviceid) { | 327 switch(serviceid) { |
315 case 0x0005: /* Ads */ | 328 case 0x0005: /* Ads */ |
329 debug_print("Received Ads, finishing login\n"); | |
316 sprintf(buddies, "%s&", current_user->username); | 330 sprintf(buddies, "%s&", current_user->username); |
317 aim_bos_setbuddylist(sess, command->conn, buddies); | 331 aim_bos_setbuddylist(sess, command->conn, buddies); |
318 aim_bos_setprofile(sess, command->conn, current_user->user_info, | 332 aim_bos_setprofile(sess, command->conn, current_user->user_info, |
319 NULL, gaim_caps); | 333 NULL, gaim_caps); |
320 | |
321 aim_seticbmparam(sess, command->conn); | 334 aim_seticbmparam(sess, command->conn); |
322 | |
323 aim_bos_clientready(sess, command->conn); | |
324 | |
325 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV); | |
326 aim_conn_setlatency(command->conn, 1); | 335 aim_conn_setlatency(command->conn, 1); |
327 | 336 |
328 debug_print("Roger that, all systems go\n"); | |
329 #ifdef USE_APPLET | 337 #ifdef USE_APPLET |
330 make_buddy(); | 338 make_buddy(); |
331 if (general_options & OPT_GEN_APP_BUDDY_SHOW) { | 339 if (general_options & OPT_GEN_APP_BUDDY_SHOW) { |
332 gnome_buddy_show(); | 340 gnome_buddy_show(); |
333 createOnlinePopup(); | 341 createOnlinePopup(); |
346 serv_finish_login(); | 354 serv_finish_login(); |
347 gaim_setup(); | 355 gaim_setup(); |
348 if (bud_list_cache_exists()) | 356 if (bud_list_cache_exists()) |
349 do_import(NULL, 0); | 357 do_import(NULL, 0); |
350 | 358 |
359 aim_bos_clientready(sess, command->conn); | |
360 debug_print("Roger that, all systems go\n"); | |
361 aim_bos_reqservice(sess, command->conn, AIM_CONN_TYPE_CHATNAV); | |
362 | |
351 break; | 363 break; |
352 case 0x7: /* Authorizer */ | 364 case 0x7: /* Authorizer */ |
365 debug_print("Reconnecting with authorizor...\n"); | |
353 { | 366 { |
354 struct aim_conn_t *tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip); | 367 struct aim_conn_t *tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip); |
355 if (tstconn == NULL || tstconn->status >= AIM_CONN_STATUS_RESOLVERR) | 368 if (tstconn == NULL || tstconn->status >= AIM_CONN_STATUS_RESOLVERR) |
356 debug_print("unable to reconnect with authorizer\n"); | 369 debug_print("unable to reconnect with authorizer\n"); |
357 else | 370 else |
376 char *roomname = va_arg(ap, char *); | 389 char *roomname = va_arg(ap, char *); |
377 if (tstconn == NULL || tstconn->status >= AIM_CONN_STATUS_RESOLVERR) { | 390 if (tstconn == NULL || tstconn->status >= AIM_CONN_STATUS_RESOLVERR) { |
378 debug_print("unable to connect to chat server\n"); | 391 debug_print("unable to connect to chat server\n"); |
379 return 1; | 392 return 1; |
380 } | 393 } |
394 sprintf(debug_buff, "Connected to chat room %s\n", roomname); | |
395 debug_print(debug_buff); | |
396 | |
381 aim_chat_attachname(tstconn, roomname); | 397 aim_chat_attachname(tstconn, roomname); |
382 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); | 398 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0); |
383 aim_auth_sendcookie(sess, tstconn, cookie); | 399 aim_auth_sendcookie(sess, tstconn, cookie); |
384 } | 400 } |
385 break; | 401 break; |
481 serv_got_chat_invite(roominfo->name, | 497 serv_got_chat_invite(roominfo->name, |
482 roominfo->instance, | 498 roominfo->instance, |
483 userinfo->sn, | 499 userinfo->sn, |
484 msg); | 500 msg); |
485 } else if (rendtype == 1) { | 501 } else if (rendtype == 1) { |
486 /* FIXME : voice chat */ | 502 /* voice chat */ |
487 } else { | 503 } else { |
488 sprintf(debug_buff, "Unknown rendtype %d\n", rendtype); | 504 sprintf(debug_buff, "Unknown rendtype %d\n", rendtype); |
489 debug_print(debug_buff); | 505 debug_print(debug_buff); |
490 } | 506 } |
491 /* libfaim doesn't do file transfer yet, from what i can tell */ | 507 /* libfaim doesn't do file transfer yet, from what i can tell */ |
505 | 521 |
506 family = aimutil_get16(command->data+0); | 522 family = aimutil_get16(command->data+0); |
507 subtype = aimutil_get16(command->data+2); | 523 subtype = aimutil_get16(command->data+2); |
508 | 524 |
509 switch (family) { | 525 switch (family) { |
510 /* case 0x0001: | 526 case 0x0001: |
511 if (subtype == 0x000a) | 527 if (subtype == 0x000a) |
512 sprintf(buf, "You are sending messages too fast."); | 528 sprintf(buf, "You are sending messages too fast."); |
513 break; | 529 break; |
514 */ case 0x0002: | 530 case 0x0002: |
515 if (subtype == 0x0001) | 531 if (subtype == 0x0001) |
516 sprintf(buf, "Unknown SNAC error (I'm hungry)"); | 532 sprintf(buf, "Unknown SNAC error (I'm hungry)"); |
517 break; | 533 break; |
518 case 0x0004: | 534 case 0x0004: |
519 if (subtype == 0x0001) | 535 if (subtype == 0x0001) |
585 return 1; | 601 return 1; |
586 } | 602 } |
587 | 603 |
588 int gaim_chatnav_info(struct aim_session_t *sess, | 604 int gaim_chatnav_info(struct aim_session_t *sess, |
589 struct command_rx_struct *command, ...) { | 605 struct command_rx_struct *command, ...) { |
590 /* FIXME */ | 606 va_list ap = va_start(ap, command); |
591 debug_print("inside chatnav_info\n"); | 607 u_short type = va_arg(ap, u_short); |
592 aim_conn_close(command->conn); | 608 |
609 switch(type) { | |
610 case 0x0002: { | |
611 int maxrooms; | |
612 struct aim_chat_exchangeinfo *exchanges; | |
613 int exchangecount, i = 0; | |
614 | |
615 maxrooms = va_arg(ap, u_char); | |
616 exchangecount = va_arg(ap, int); | |
617 exchanges = va_arg(ap, struct aim_chat_exchangeinfo *); | |
618 va_end(ap); | |
619 | |
620 debug_print("chat info: Chat Rights:\n"); | |
621 sprintf(debug_buff, "chat info: \tMax Concurrent Rooms: %d\n", maxrooms); | |
622 debug_print(debug_buff); | |
623 sprintf(debug_buff, "chat info: \tExchange List: (%d total)\n", exchangecount); | |
624 debug_print(debug_buff); | |
625 while (i < exchangecount) { | |
626 sprintf(debug_buff, "chat info: \t\t%x: %s (%s/%s)\n", | |
627 exchanges[i].number, | |
628 exchanges[i].name, | |
629 exchanges[i].charset1, | |
630 exchanges[i].lang1); | |
631 debug_print(debug_buff); | |
632 i++; | |
633 } | |
634 } | |
635 break; | |
636 default: | |
637 va_end(ap); | |
638 sprintf(debug_buff, "chatnav info: unknown type (%04x)\n", type); | |
639 debug_print(debug_buff); | |
640 break; | |
641 } | |
593 return 1; | 642 return 1; |
594 } | 643 } |
595 | 644 |
596 int gaim_chat_join(struct aim_session_t *sess, | 645 int gaim_chat_join(struct aim_session_t *sess, |
597 struct command_rx_struct *command, ...) { | 646 struct command_rx_struct *command, ...) { |