comparison src/oscar.c @ 242:14fc16f579c8

[gaim-migrate @ 252] More updates to oscar.c (et al.) to use libfaim. Lots of good stuff now. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sat, 20 May 2000 07:58:50 +0000
parents 6ced2f1c8b24
children 3414ff74cb0f
comparison
equal deleted inserted replaced
241:452993e3cdd2 242:14fc16f579c8
37 #include "gaim.h" 37 #include "gaim.h"
38 #include "aim.h" 38 #include "aim.h"
39 #include "gnome_applet_mgr.h" 39 #include "gnome_applet_mgr.h"
40 40
41 static int inpa = -1; 41 static int inpa = -1;
42 static struct aim_session_t *gaim_sess; 42 struct aim_session_t *gaim_sess;
43 static struct aim_conn_t *gaim_conn; 43 struct aim_conn_t *gaim_conn;
44 44
45 static int gaim_parse_auth_resp (struct aim_session_t *, struct command_rx_struct *, ...); 45 static int gaim_parse_auth_resp (struct aim_session_t *, struct command_rx_struct *, ...);
46 static int gaim_auth_server_ready(struct aim_session_t *, struct command_rx_struct *, ...); 46 static int gaim_auth_server_ready(struct aim_session_t *, struct command_rx_struct *, ...);
47 static int gaim_server_ready (struct aim_session_t *, struct command_rx_struct *, ...); 47 static int gaim_server_ready (struct aim_session_t *, struct command_rx_struct *, ...);
48 static int gaim_handle_redirect (struct aim_session_t *, struct command_rx_struct *, ...); 48 static int gaim_handle_redirect (struct aim_session_t *, struct command_rx_struct *, ...);
51 static int gaim_parse_incoming_im(struct aim_session_t *, struct command_rx_struct *, ...); 51 static int gaim_parse_incoming_im(struct aim_session_t *, struct command_rx_struct *, ...);
52 static int gaim_parse_misses (struct aim_session_t *, struct command_rx_struct *, ...); 52 static int gaim_parse_misses (struct aim_session_t *, struct command_rx_struct *, ...);
53 static int gaim_parse_user_info (struct aim_session_t *, struct command_rx_struct *, ...); 53 static int gaim_parse_user_info (struct aim_session_t *, struct command_rx_struct *, ...);
54 static int gaim_parse_unknown (struct aim_session_t *, struct command_rx_struct *, ...); 54 static int gaim_parse_unknown (struct aim_session_t *, struct command_rx_struct *, ...);
55 static int gaim_parse_motd (struct aim_session_t *, struct command_rx_struct *, ...); 55 static int gaim_parse_motd (struct aim_session_t *, struct command_rx_struct *, ...);
56 static int gaim_chatnav_info (struct aim_session_t *, struct command_rx_struct *, ...);
56 57
57 static void oscar_callback(gpointer data, gint source, 58 static void oscar_callback(gpointer data, gint source,
58 GdkInputCondition condition) { 59 GdkInputCondition condition) {
59 struct aim_session_t *sess = (struct aim_session_t *)data; 60 struct aim_session_t *sess = (struct aim_session_t *)data;
60 struct aim_conn_t *conn = NULL; 61 struct aim_conn_t *conn = NULL;
73 signoff(); 74 signoff();
74 hide_login_progress("Disconnected."); 75 hide_login_progress("Disconnected.");
75 aim_logoff(sess); 76 aim_logoff(sess);
76 gdk_input_remove(inpa); 77 gdk_input_remove(inpa);
77 break; 78 break;
78 case 0: /* this should never happen because of the gdk_input */ 79 case 0:
79 gdk_input_remove(inpa); 80 gdk_input_remove(inpa);
80 while (gtk_events_pending()) 81 while (gtk_events_pending())
81 gtk_main_iteration(); 82 gtk_main_iteration();
82 inpa = gdk_input_add(gaim_conn->fd, 83 inpa = gdk_input_add(gaim_conn->fd,
83 GDK_INPUT_READ | GDK_INPUT_WRITE | 84 GDK_INPUT_READ | GDK_INPUT_WRITE |
168 aim_send_im(gaim_sess, gaim_conn, name, AIM_IMFLAGS_AWAY, msg); 169 aim_send_im(gaim_sess, gaim_conn, name, AIM_IMFLAGS_AWAY, msg);
169 else 170 else
170 aim_send_im(gaim_sess, gaim_conn, name, 0, msg); 171 aim_send_im(gaim_sess, gaim_conn, name, 0, msg);
171 } 172 }
172 173
174 void oscar_close() {
175 #ifdef USE_APPLET
176 setUserState(offline);
177 #endif
178 set_state(STATE_OFFLINE);
179 if (inpa > 0)
180 gdk_input_remove(inpa);
181 inpa = -1;
182 aim_logoff(gaim_sess);
183 }
184
173 int gaim_parse_auth_resp(struct aim_session_t *sess, 185 int gaim_parse_auth_resp(struct aim_session_t *sess,
174 struct command_rx_struct *command, ...) { 186 struct command_rx_struct *command, ...) {
175 struct aim_conn_t *bosconn = NULL; 187 struct aim_conn_t *bosconn = NULL;
176 sprintf(debug_buff, "inside auth_resp (Screen name: %s)\n", 188 sprintf(debug_buff, "inside auth_resp (Screen name: %s)\n",
177 sess->logininfo.screen_name); 189 sess->logininfo.screen_name);
261 aim_setversions(sess, command->conn); 273 aim_setversions(sess, command->conn);
262 aim_bos_setgroupperm(sess, command->conn, 0x1f); 274 aim_bos_setgroupperm(sess, command->conn, 0x1f);
263 debug_print("done with BOS ServerReady\n"); 275 debug_print("done with BOS ServerReady\n");
264 break; 276 break;
265 case AIM_CONN_TYPE_CHATNAV: 277 case AIM_CONN_TYPE_CHATNAV:
278 aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CTN, AIM_CB_CTN_INFO, gaim_chatnav_info, 0);
279 aim_bos_reqrate(sess, command->conn);
280 aim_bos_ackrateresp(sess, command->conn);
281 aim_chatnav_clientready(sess, command->conn);
282 aim_chatnav_reqrights(sess, command->conn);
266 break; 283 break;
267 case AIM_CONN_TYPE_CHAT: 284 case AIM_CONN_TYPE_CHAT:
285 /* FIXME */
268 break; 286 break;
269 default: /* huh? */ 287 default: /* huh? */
270 break; 288 break;
271 } 289 }
272 return 1; 290 return 1;
277 va_list ap; 295 va_list ap;
278 int serviceid; 296 int serviceid;
279 char *ip; 297 char *ip;
280 char *cookie; 298 char *cookie;
281 299
282 /* FIXME */ 300 char buddies[] = "EWarmenhoven&";
283 char buddies[] = "EWarmenhoven&RobFlynn&Zilding&FlynOrange&";
284 char profile[] = "Hello"; 301 char profile[] = "Hello";
285 302
286 va_start(ap, command); 303 va_start(ap, command);
287 serviceid = va_arg(ap, int); 304 serviceid = va_arg(ap, int);
288 ip = va_arg(ap, char *); 305 ip = va_arg(ap, char *);
289 cookie = va_arg(ap, char *); 306 cookie = va_arg(ap, char *);
290 307
291 switch(serviceid) { 308 switch(serviceid) {
292 case 0x0005: /* Ads */ 309 case 0x0005: /* Ads */
293 aim_bos_setbuddylist(sess, command->conn, buddies); 310 aim_bos_setbuddylist(sess, command->conn, buddies);
294 aim_bos_setprofile(sess, command->conn, profile, NULL, AIM_CAPS_CHAT); 311 aim_bos_setprofile(sess, command->conn, profile,
312 NULL, AIM_CAPS_CHAT);
295 313
296 aim_bos_clientready(sess, command->conn); 314 aim_bos_clientready(sess, command->conn);
297 315
298 gaim_sess = sess; 316 gaim_sess = sess;
299 gaim_conn = command->conn; 317 gaim_conn = command->conn;
314 #else 332 #else
315 gtk_widget_hide(mainwindow); 333 gtk_widget_hide(mainwindow);
316 show_buddy_list(); 334 show_buddy_list();
317 refresh_buddy_window(); 335 refresh_buddy_window();
318 #endif 336 #endif
337 serv_finish_login();
338 if (bud_list_cache_exists())
339 do_import(NULL, 0);
340
319 break; 341 break;
320 case 0x7: /* Authorizer */ 342 case 0x7: /* Authorizer */
321 { 343 {
322 struct aim_conn_t *tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip); 344 struct aim_conn_t *tstconn = aim_newconn(sess, AIM_CONN_TYPE_AUTH, ip);
323 if (tstconn == NULL || tstconn->status >= AIM_CONN_STATUS_RESOLVERR) 345 if (tstconn == NULL || tstconn->status >= AIM_CONN_STATUS_RESOLVERR)
325 else 347 else
326 aim_auth_sendcookie(sess, tstconn, cookie); 348 aim_auth_sendcookie(sess, tstconn, cookie);
327 } 349 }
328 break; 350 break;
329 case 0xd: /* ChatNav */ 351 case 0xd: /* ChatNav */
352 {
353 struct aim_conn_t *tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHATNAV, ip);
354 if (tstconn == NULL || tstconn->status >= AIM_CONN_STATUS_RESOLVERR) {
355 debug_print("unable to connect to chatnav server\n");
356 return 1;
357 }
358 aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0);
359 aim_auth_sendcookie(sess, tstconn, cookie);
360 }
361 debug_print("chatnav: connected\n");
330 break; 362 break;
331 case 0xe: /* Chat */ 363 case 0xe: /* Chat */
364 /* FIXME */
332 break; 365 break;
333 default: /* huh? */ 366 default: /* huh? */
334 sprintf(debug_buff, "got redirect for unknown service 0x%04x\n", 367 sprintf(debug_buff, "got redirect for unknown service 0x%04x\n",
335 serviceid); 368 serviceid);
336 debug_print(debug_buff); 369 debug_print(debug_buff);
342 return 1; 375 return 1;
343 } 376 }
344 377
345 int gaim_parse_oncoming(struct aim_session_t *sess, 378 int gaim_parse_oncoming(struct aim_session_t *sess,
346 struct command_rx_struct *command, ...) { 379 struct command_rx_struct *command, ...) {
380 struct aim_userinfo_s *info;
381 int type = 0;
382
383 va_list ap;
384 va_start(ap, command);
385 info = va_arg(ap, struct aim_userinfo_s *);
386 va_end(ap);
387
388 if (info->class & AIM_CLASS_TRIAL)
389 type |= UC_UNCONFIRMED;
390 if (info->class & AIM_CLASS_AOL)
391 type |= UC_AOL;
392 if (info->class & AIM_CLASS_FREE)
393 type |= UC_NORMAL;
394 if (info->class & AIM_CLASS_AWAY)
395 type |= UC_UNAVAILABLE;
396
397 serv_got_update(info->sn, 1, info->warnlevel, info->onlinesince,
398 info->idletime, type);
399
347 return 1; 400 return 1;
348 } 401 }
349 402
350 int gaim_parse_offgoing(struct aim_session_t *sess, 403 int gaim_parse_offgoing(struct aim_session_t *sess,
351 struct command_rx_struct *command, ...) { 404 struct command_rx_struct *command, ...) {
405 char *sn;
406 va_list ap;
407
408 va_start(ap, command);
409 sn = va_arg(ap, char *);
410 va_end(ap);
411
412 serv_got_update(sn, 0, 0, 0, 0, 0);
413
352 return 1; 414 return 1;
353 } 415 }
354 416
355 int gaim_parse_incoming_im(struct aim_session_t *sess, 417 int gaim_parse_incoming_im(struct aim_session_t *sess,
356 struct command_rx_struct *command, ...) { 418 struct command_rx_struct *command, ...) {
381 return 1; 443 return 1;
382 } 444 }
383 445
384 int gaim_parse_misses(struct aim_session_t *sess, 446 int gaim_parse_misses(struct aim_session_t *sess,
385 struct command_rx_struct *command, ...) { 447 struct command_rx_struct *command, ...) {
448 /* FIXME */
386 return 1; 449 return 1;
387 } 450 }
388 451
389 int gaim_parse_user_info(struct aim_session_t *sess, 452 int gaim_parse_user_info(struct aim_session_t *sess,
390 struct command_rx_struct *command, ...) { 453 struct command_rx_struct *command, ...) {
454 /* FIXME */
391 return 1; 455 return 1;
392 } 456 }
393 457
394 int gaim_parse_unknown(struct aim_session_t *sess, 458 int gaim_parse_unknown(struct aim_session_t *sess,
395 struct command_rx_struct *command, ...) { 459 struct command_rx_struct *command, ...) {
460 /* FIXME */
396 return 1; 461 return 1;
397 } 462 }
398 463
399 int gaim_parse_motd(struct aim_session_t *sess, 464 int gaim_parse_motd(struct aim_session_t *sess,
400 struct command_rx_struct *command, ...) { 465 struct command_rx_struct *command, ...) {
411 debug_print(debug_buff); 476 debug_print(debug_buff);
412 477
413 return 1; 478 return 1;
414 } 479 }
415 480
481 int gaim_chatnav_info(struct aim_session_t *sess,
482 struct command_rx_struct *command, ...) {
483 /* FIXME */
484 return 1;
485 }
416 #endif /* USE_OSCAR */ 486 #endif /* USE_OSCAR */