static const char* get_friendly_name(MsnUser *user) { const char *friendly_name; g_return_val_if_fail(user != NULL, NULL); friendly_name = msn_user_get_friendly_name(user); if (friendly_name != NULL) friendly_name = purple_url_encode(friendly_name); else friendly_name = msn_user_get_passport(user); /* this might be a bit of a hack, but it should prevent notification server * disconnections for people who have buddies with insane friendly names * who added you to their buddy list from being disconnected. Stu. */ /* Shx: What? Isn't the store_name obtained from the server, and hence it's * below the BUDDY_ALIAS_MAXLEN ? */ /* Stu: yeah, that's why it's a bit of a hack, as you pointed out, we're * probably decoding the incoming store_name wrong, or something. bleh. */ if (strlen(friendly_name) > BUDDY_ALIAS_MAXLEN) friendly_name = msn_user_get_passport(user); return friendly_name; }
static void nln_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { MsnSession *session; GaimAccount *account; GaimConnection *gc; MsnUser *user; MsnObject *msnobj; int clientid; const char *state, *passport, *friendly, *old_friendly; session = cmdproc->session; account = session->account; gc = gaim_account_get_connection(account); state = cmd->params[0]; passport = cmd->params[1]; friendly = gaim_url_decode(cmd->params[2]); user = msn_userlist_find_user(session->userlist, passport); old_friendly = msn_user_get_friendly_name(user); if (!old_friendly || (old_friendly && strcmp(old_friendly, friendly))) { serv_got_alias(gc, passport, friendly); msn_user_set_friendly_name(user, friendly); } if (session->protocol_ver >= 9) { if (cmd->param_count == 5) { msnobj = msn_object_new_from_string(gaim_url_decode(cmd->params[4])); msn_user_set_object(user, msnobj); } else { msn_user_set_object(user, NULL); } } clientid = atoi(cmd->params[3]); user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE); msn_user_set_state(user, state); msn_user_update(user); }
void msn_got_lst_user(MsnSession *session, MsnUser *user, int list_op, GSList *group_ids) { PurpleConnection *gc; PurpleAccount *account; const char *passport; const char *store; account = session->account; gc = purple_account_get_connection(account); passport = msn_user_get_passport(user); store = msn_user_get_friendly_name(user); if (list_op & MSN_LIST_AL_OP) { /* These are users who are allowed to see our status. */ purple_privacy_deny_remove(account, passport, TRUE); purple_privacy_permit_add(account, passport, TRUE); } if (list_op & MSN_LIST_BL_OP) { /* These are users who are not allowed to see our status. */ purple_privacy_permit_remove(account, passport, TRUE); purple_privacy_deny_add(account, passport, TRUE); } if (list_op & MSN_LIST_FL_OP) { GSList *c; for (c = group_ids; c != NULL; c = g_slist_next(c)) { int group_id; group_id = GPOINTER_TO_INT(c->data); msn_user_add_group_id(user, group_id); } /* FIXME: It might be a real alias */ /* Umm, what? This might fix bug #1385130 */ serv_got_alias(gc, passport, store); } if (list_op & MSN_LIST_RL_OP) { /* These are users who have us on their buddy list. */ /* * TODO: What is store name set to when this happens? * For one of my accounts "*****@*****.**" * the store name was "something." Maybe we * should use the friendly name, instead? --KingAnt */ if (!(list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))) { got_new_entry(gc, passport, store); } } user->list_op = list_op; }
void msn_got_add_user(MsnSession *session, MsnUser *user, MsnListId list_id, int group_id) { PurpleAccount *account; const char *passport; const char *friendly; account = session->account; passport = msn_user_get_passport(user); friendly = msn_user_get_friendly_name(user); if (list_id == MSN_LIST_FL) { PurpleConnection *gc; gc = purple_account_get_connection(account); serv_got_alias(gc, passport, friendly); if (group_id >= 0) { msn_user_add_group_id(user, group_id); } else { /* session->sync->fl_users_count++; */ } } else if (list_id == MSN_LIST_AL) { purple_privacy_permit_add(account, passport, TRUE); } else if (list_id == MSN_LIST_BL) { purple_privacy_deny_add(account, passport, TRUE); } else if (list_id == MSN_LIST_RL) { PurpleConnection *gc; PurpleConversation *convo; gc = purple_account_get_connection(account); purple_debug_info("msn", "%s has added you to his or her buddy list.\n", passport); convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, passport, account); if (convo) { PurpleBuddy *buddy; char *msg; buddy = purple_find_buddy(account, passport); msg = g_strdup_printf( _("%s has added you to his or her buddy list."), buddy ? purple_buddy_get_contact_alias(buddy) : passport); purple_conv_im_write(PURPLE_CONV_IM(convo), passport, msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); g_free(msg); } if (!(user->list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))) { /* * TODO: The friendly name was NULL for me when I * looked at this. Maybe we should use the store * name instead? --KingAnt */ got_new_entry(gc, passport, friendly); } } user->list_op |= (1 << list_id); /* purple_user_add_list_id (user, list_id); */ }