comparison src/protocols/sametime/sametime.c @ 11638:3a05b53a589e

[gaim-migrate @ 13914] Some bits'n'pieces: A bunch of memory leak fixes Fix newly created accounts to connect in the currently active global status Fix the modify account dialog to only show relevant user options etc. Update sametime to use some more of the new status stuff, it still needs more love though. Some s/online/available/ for consistency across prpls Fix a racyness in disconnecting connections that want to die (fixes the Yahoo crash when signing on somewhere else) Sorry if I caused any conflicts! committer: Tailor Script <tailor@pidgin.im>
author Stu Tomlinson <stu@nosnilmot.com>
date Mon, 10 Oct 2005 17:59:48 +0000
parents 726264a8f48f
children 925c1960af34
comparison
equal deleted inserted replaced
11637:cedd48571c90 11638:3a05b53a589e
405 405
406 static void mw_aware_list_on_aware(struct mwAwareList *list, 406 static void mw_aware_list_on_aware(struct mwAwareList *list,
407 struct mwAwareSnapshot *aware) { 407 struct mwAwareSnapshot *aware) {
408 408
409 GaimConnection *gc; 409 GaimConnection *gc;
410 GaimAccount *acct;
410 struct mwGaimPluginData *pd; 411 struct mwGaimPluginData *pd;
411 412 const char *status_id = MW_STATE_ACTIVE;
412 time_t idle = 0; 413 gboolean idle = FALSE;
414
413 guint stat = aware->status.status; 415 guint stat = aware->status.status;
414 416
415 const char *id = aware->id.user; 417 const char *id = aware->id.user;
416 418
417 gc = mwAwareList_getClientData(list); 419 gc = mwAwareList_getClientData(list);
418 pd = gc->proto_data; 420 pd = gc->proto_data;
421 acct = gaim_connection_get_account(gc);
419 422
420 switch(stat) { 423 switch(stat) {
421 case mwStatus_IDLE: 424 case mwStatus_IDLE:
422 idle = -1; 425 idle = TRUE;
423 break; 426 break;
424 427
425 case mwStatus_AWAY: 428 case mwStatus_AWAY:
429 status_id = MW_STATE_AWAY;
430 break;
426 case mwStatus_BUSY: 431 case mwStatus_BUSY:
427 /* need to let gaim know that these are 'unavailable' states */ 432 status_id = MW_STATE_BUSY;
428
429 /* XXX */
430 /* stat |= UC_UNAVAILABLE; */
431
432 break; 433 break;
433 } 434 }
434 435
435 if(aware->group) { 436 if(aware->group) {
436 GaimAccount *acct;
437 GaimGroup *group; 437 GaimGroup *group;
438 GaimBuddy *buddy; 438 GaimBuddy *buddy;
439 GaimBlistNode *bnode; 439 GaimBlistNode *bnode;
440 440
441 acct = gaim_connection_get_account(gc);
442 group = g_hash_table_lookup(pd->group_list_map, list); 441 group = g_hash_table_lookup(pd->group_list_map, list);
443 buddy = gaim_find_buddy_in_group(acct, id, group); 442 buddy = gaim_find_buddy_in_group(acct, id, group);
444 bnode = (GaimBlistNode *) buddy; 443 bnode = (GaimBlistNode *) buddy;
445 444
446 if(! buddy) { 445 if(! buddy) {
465 } 464 }
466 465
467 gaim_blist_node_set_int(bnode, BUDDY_KEY_TYPE, mwSametimeUser_NORMAL); 466 gaim_blist_node_set_int(bnode, BUDDY_KEY_TYPE, mwSametimeUser_NORMAL);
468 } 467 }
469 468
470 /* XXX */ 469 gaim_prpl_got_user_status(acct, id, status_id, NULL);
471 /* serv_got_update(gc, id, aware->online, 0, 0, idle, stat); */ 470 gaim_prpl_got_user_login_time(acct, id, aware->online - time(NULL));
471
472 if (idle)
473 gaim_prpl_got_user_idle(acct, id, TRUE, -1);
474 else
475 gaim_prpl_got_user_idle(acct, id, FALSE, 0);
472 } 476 }
473 477
474 478
475 static void mw_aware_list_on_attrib(struct mwAwareList *list, 479 static void mw_aware_list_on_attrib(struct mwAwareList *list,
476 struct mwAwareIdBlock *id, 480 struct mwAwareIdBlock *id,
3472 3476
3473 g_string_free(str, TRUE); 3477 g_string_free(str, TRUE);
3474 } 3478 }
3475 3479
3476 3480
3477 #if 0 3481 static void mw_prpl_set_status(GaimAccount *acct, GaimStatus *status) {
3478 static void mw_prpl_set_away(GaimConnection *gc, 3482 GaimConnection *gc;
3479 const char *state, 3483 const char *state;
3480 const char *message) { 3484 char *message;
3481 GaimAccount *acct;
3482 struct mwSession *session; 3485 struct mwSession *session;
3483 struct mwUserStatus stat; 3486 struct mwUserStatus stat;
3484 3487
3485 acct = gaim_connection_get_account(gc);
3486 g_return_if_fail(acct != NULL); 3488 g_return_if_fail(acct != NULL);
3487 3489 gc = gaim_account_get_connection(acct);
3490
3491 state = gaim_status_get_id(status);
3492
3493 gaim_debug_info("meanwhile", "Set status to %s\n", gaim_status_get_name(status));
3494
3495 if (!strcmp(state, "offline") && (gc != NULL)) {
3496 gaim_account_disconnect(acct);
3497 return;
3498 }
3499 else if (strcmp(state, "offline") && (gc == NULL)) {
3500 gaim_account_connect(acct);
3501 return;
3502 }
3503
3504 g_return_if_fail(gc != NULL);
3505
3488 session = gc_to_session(gc); 3506 session = gc_to_session(gc);
3489 g_return_if_fail(session != NULL); 3507 g_return_if_fail(session != NULL);
3490 3508
3491 /* get a working copy of the current status */ 3509 /* get a working copy of the current status */
3492 mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); 3510 mwUserStatus_clone(&stat, mwSession_getUserStatus(session));
3493 3511
3494 /* determine the state */ 3512 /* determine the state */
3495 if(state) { 3513 if(! strcmp(state, MW_STATE_ACTIVE)) {
3496 if(! strcmp(state, GAIM_AWAY_CUSTOM)) {
3497 if(message) {
3498 stat.status = mwStatus_AWAY;
3499 } else {
3500 stat.status = mwStatus_ACTIVE;
3501 }
3502
3503 } else if(! strcmp(state, MW_STATE_AWAY)) {
3504 stat.status = mwStatus_AWAY;
3505
3506 } else if(! strcmp(state, MW_STATE_BUSY)) {
3507 stat.status = mwStatus_BUSY;
3508
3509 } else if(! strcmp(state, MW_STATE_ACTIVE)) {
3510 stat.status = mwStatus_ACTIVE;
3511 }
3512
3513 } else {
3514 stat.status = mwStatus_ACTIVE; 3514 stat.status = mwStatus_ACTIVE;
3515
3516 } else if(! strcmp(state, MW_STATE_AWAY)) {
3517 stat.status = mwStatus_AWAY;
3518
3519 } else if(! strcmp(state, MW_STATE_BUSY)) {
3520 stat.status = mwStatus_BUSY;
3515 } 3521 }
3516 3522
3517 /* determine the message */ 3523 /* determine the message */
3518 if(! message) { 3524 switch(stat.status) {
3519 switch(stat.status) { 3525 case mwStatus_ACTIVE:
3520 case mwStatus_AWAY: 3526 stat.time = 0;
3521 message = gaim_account_get_string(acct, MW_KEY_AWAY_MSG, 3527 case mwStatus_AWAY:
3522 MW_PLUGIN_DEFAULT_AWAY_MSG); 3528 case mwStatus_BUSY:
3523 break; 3529 message = (char *)gaim_status_get_attr_string(status, MW_STATE_MESSAGE);
3524 3530 break;
3525 case mwStatus_BUSY:
3526 message = gaim_account_get_string(acct, MW_KEY_BUSY_MSG,
3527 MW_PLUGIN_DEFAULT_BUSY_MSG);
3528 break;
3529
3530 case mwStatus_ACTIVE:
3531 message = gaim_account_get_string(acct, MW_KEY_ACTIVE_MSG,
3532 MW_PLUGIN_DEFAULT_ACTIVE_MSG);
3533 stat.time = 0;
3534 break;
3535 }
3536 } 3531 }
3537 3532
3538 if(message) { 3533 if(message) {
3539 /* all the possible non-NULL values of message up to this point 3534 /* all the possible non-NULL values of message up to this point
3540 are const, so we don't need to free them */ 3535 are const, so we don't need to free them */
3541 message = gaim_markup_strip_html(message); 3536 message = gaim_markup_strip_html(message);
3542 } 3537 }
3543 3538
3544 /* out with the old */ 3539 /* out with the old */
3545 g_free(stat.desc); 3540 g_free(stat.desc);
3546 g_free(gc->away);
3547 3541
3548 /* in with the new */ 3542 /* in with the new */
3549 stat.desc = (char *) message; 3543 stat.desc = (char *) message;
3550 gc->away = g_strdup(message);
3551 3544
3552 mwSession_setUserStatus(session, &stat); 3545 mwSession_setUserStatus(session, &stat);
3553 mwUserStatus_clear(&stat); 3546 mwUserStatus_clear(&stat);
3554 } 3547 }
3555 #endif
3556 3548
3557 3549
3558 static void mw_prpl_set_idle(GaimConnection *gc, int time) { 3550 static void mw_prpl_set_idle(GaimConnection *gc, int time) {
3559 struct mwSession *session; 3551 struct mwSession *session;
3560 struct mwUserStatus stat; 3552 struct mwUserStatus stat;
4384 .close = mw_prpl_close, 4376 .close = mw_prpl_close,
4385 .send_im = mw_prpl_send_im, 4377 .send_im = mw_prpl_send_im,
4386 .set_info = NULL, 4378 .set_info = NULL,
4387 .send_typing = mw_prpl_send_typing, 4379 .send_typing = mw_prpl_send_typing,
4388 .get_info = mw_prpl_get_info, 4380 .get_info = mw_prpl_get_info,
4381 .set_status = mw_prpl_set_status,
4389 .set_idle = mw_prpl_set_idle, 4382 .set_idle = mw_prpl_set_idle,
4390 .change_passwd = NULL, 4383 .change_passwd = NULL,
4391 .add_buddy = mw_prpl_add_buddy, 4384 .add_buddy = mw_prpl_add_buddy,
4392 .add_buddies = mw_prpl_add_buddies, 4385 .add_buddies = mw_prpl_add_buddies,
4393 .remove_buddy = mw_prpl_remove_buddy, 4386 .remove_buddy = mw_prpl_remove_buddy,