/* this should be called upon signin, even when we did not open group chat window */ void qq_group_init(GaimConnection *gc) { gint i; GaimAccount *account; GaimChat *chat; GaimGroup *gaim_group; GaimBlistNode *node; qq_group *group; account = gaim_connection_get_account(gc); gaim_group = gaim_find_group(GAIM_GROUP_QQ_QUN); if (gaim_group == NULL) { gaim_debug(GAIM_DEBUG_INFO, "QQ", "We have no QQ Qun\n"); return; } i = 0; for (node = ((GaimBlistNode *) gaim_group)->child; node != NULL; node = node->next) if (GAIM_BLIST_NODE_IS_CHAT(node)) { /* got one */ chat = (GaimChat *) node; if (account != chat->account) continue; /* very important here ! */ group = qq_group_from_hashtable(gc, chat->components); if (group != NULL) { i++; qq_send_cmd_group_get_group_info(gc, group); /* get group info and members */ } } gaim_debug(GAIM_DEBUG_INFO, "QQ", "Load %d QQ Qun configurations\n", i); }
/* Remove the buddy referenced by the MsnAddRemData before the serverside list is changed. * If the buddy will be added, he'll be added back; if he will be removed, he won't be. */ static void msn_complete_sync_issue(MsnAddRemData *data) { GaimBuddy *buddy; GaimGroup *group = NULL; if (data->group != NULL) group = gaim_find_group(data->group); if (group != NULL) buddy = gaim_find_buddy_in_group(gaim_connection_get_account(data->gc), data->who, group); else buddy = gaim_find_buddy(gaim_connection_get_account(data->gc), data->who); if (buddy != NULL) gaim_blist_remove_buddy(buddy); }
void msn_user_add_group_id(MsnUser *user, int id) { MsnUserList *userlist; GaimAccount *account; GaimBuddy *b; GaimGroup *g; const char *passport; const char *group_name; g_return_if_fail(user != NULL); g_return_if_fail(id >= 0); user->group_ids = g_list_append(user->group_ids, GINT_TO_POINTER(id)); userlist = user->userlist; account = userlist->session->account; passport = msn_user_get_passport(user); group_name = msn_userlist_find_group_name(userlist, id); g = gaim_find_group(group_name); if ((id == 0) && (g == NULL)) { g = gaim_group_new(group_name); gaim_blist_add_group(g, NULL); } b = gaim_find_buddy_in_group(account, passport, g); if (b == NULL) { b = gaim_buddy_new(account, passport, NULL); gaim_blist_add_buddy(b, NULL, g, NULL); } b->proto_data = user; }
static void lsg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) { MsnSession *session = cmdproc->session; const char *name; int group_id; group_id = atoi(cmd->params[0]); name = gaim_url_decode(cmd->params[1]); msn_group_new(session->userlist, group_id, name); /* HACK */ if (group_id == 0) /* Group of ungroupped buddies */ return; if ((gaim_find_group(name)) == NULL) { GaimGroup *g = gaim_group_new(name); gaim_blist_add_group(g, NULL); } }
static gboolean _parse_data(TrepiaSession *session, char *buf) { GHashTable *info; GaimAccount *account; TrepiaMessageType type = 0; TrepiaProfile *profile = NULL; int ret; char *buffer; GaimBuddy *b; int id = 0; const char *value; char *username; int *int_p; GMainContext *ctx; account = gaim_connection_get_account(session->gc); ret = __parse_message(buf, &type, &info); if (ret == 1) return TRUE; if (info != NULL) { switch (type) { case TREPIA_USER_LIST: gaim_connection_update_progress(session->gc, _("Retrieving buddy list"), 2, TREPIA_CONNECT_STEPS); gaim_connection_set_state(session->gc, GAIM_CONNECTED); serv_finish_login(session->gc); break; case TREPIA_MSG_INCOMING: /* Incoming Message */ id = atoi(g_hash_table_lookup(info, "a")); profile = g_hash_table_lookup(session->user_profiles, &id); serv_got_im(session->gc, trepia_profile_get_login(profile), (char *)g_hash_table_lookup(info, "b"), 0, time(NULL)); break; case TREPIA_MEMBER_UPDATE: profile = trepia_profile_new(); if ((value = g_hash_table_lookup(info, "a")) != NULL) { id = atoi(value); trepia_profile_set_id(profile, id); } if ((value = g_hash_table_lookup(info, "b")) != NULL) trepia_profile_set_login_time(profile, atoi(value)); if ((value = g_hash_table_lookup(info, "c")) != NULL) trepia_profile_set_type(profile, atoi(value)); else trepia_profile_set_type(profile, 2); session->pending_users = g_list_append(session->pending_users, profile); #if 0 if (trepia_profile_get_type(profile) == 1) { buffer = g_strdup_printf( "<D>" "<a>%d</a>" "<b>1</b>" "</D>", id); } else { #endif buffer = g_strdup_printf( "<D>" "<a>%d</a>" "<b>1</b>" "</D>" "<D>" "<a>%d</a>" "<b>2</b>" "</D>", id, id); #if 0 } #endif if (trepia_write(session->fd, buffer, strlen(buffer)) < 0) { gaim_connection_error(session->gc, _("Write error")); g_free(buffer); return 1; } g_free(buffer); break; case TREPIA_MEMBER_PROFILE: if ((value = g_hash_table_lookup(info, "a")) != NULL) { GList *l; id = atoi(value); for (l = session->pending_users; l != NULL; l = l->next) { profile = l->data; if (trepia_profile_get_id(profile) == id) break; profile = NULL; } } else break; if (profile == NULL) { profile = g_hash_table_lookup(session->user_profiles, &id); if (profile == NULL) break; } /* Age */ if ((value = g_hash_table_lookup(info, "m")) != NULL) trepia_profile_set_age(profile, atoi(value)); /* ICQ */ if ((value = g_hash_table_lookup(info, "i")) != NULL) trepia_profile_set_icq(profile, atoi(value)); /* Sex */ if ((value = g_hash_table_lookup(info, "n")) != NULL) trepia_profile_set_sex(profile, *value); /* Location */ if ((value = g_hash_table_lookup(info, "p")) != NULL) trepia_profile_set_location(profile, value); /* First Name */ if ((value = g_hash_table_lookup(info, "g")) != NULL) trepia_profile_set_first_name(profile, value); /* Last Name */ if ((value = g_hash_table_lookup(info, "h")) != NULL) trepia_profile_set_last_name(profile, value); /* Profile */ if ((value = g_hash_table_lookup(info, "o")) != NULL) trepia_profile_set_profile(profile, value); /* E-mail */ if ((value = g_hash_table_lookup(info, "e")) != NULL) trepia_profile_set_email(profile, value); /* AIM */ if ((value = g_hash_table_lookup(info, "j")) != NULL) trepia_profile_set_aim(profile, value); /* MSN */ if ((value = g_hash_table_lookup(info, "k")) != NULL) trepia_profile_set_msn(profile, value); /* Yahoo */ if ((value = g_hash_table_lookup(info, "l")) != NULL) trepia_profile_set_yahoo(profile, value); /* Homepage */ if ((value = g_hash_table_lookup(info, "f")) != NULL) trepia_profile_set_homepage(profile, value); /* Country */ if ((value = g_hash_table_lookup(info, "r")) != NULL) trepia_profile_set_country(profile, value); /* State */ if ((value = g_hash_table_lookup(info, "s")) != NULL) trepia_profile_set_state(profile, value); /* City */ if ((value = g_hash_table_lookup(info, "t")) != NULL) trepia_profile_set_city(profile, value); /* Languages */ if ((value = g_hash_table_lookup(info, "u")) != NULL) trepia_profile_set_languages(profile, value); /* School */ if ((value = g_hash_table_lookup(info, "v")) != NULL) trepia_profile_set_school(profile, value); /* Company */ if ((value = g_hash_table_lookup(info, "w")) != NULL) trepia_profile_set_company(profile, value); /* Login Name */ if ((value = g_hash_table_lookup(info, "d")) != NULL) { trepia_profile_set_login(profile, value); username = g_strdup(value); } else if ((value = trepia_profile_get_login(profile)) != NULL) { username = g_strdup(value); } else { username = g_strdup_printf("%d", id); trepia_profile_set_login(profile, username); } b = gaim_find_buddy(account, username); if (b == NULL) { GaimGroup *g; g = gaim_find_group(_("Local Users")); if (g == NULL) { g = gaim_group_new(_("Local Users")); gaim_blist_add_group(g, NULL); } b = gaim_buddy_new(account, username, NULL); gaim_blist_add_buddy(b, NULL, g, NULL); } profile->buddy = b; b->proto_data = profile; session->pending_users = g_list_remove(session->pending_users, profile); int_p = g_new0(int, 1); *int_p = id; g_hash_table_insert(session->user_profiles, int_p, profile); serv_got_update(session->gc, username, TRUE, 0, trepia_profile_get_login_time(profile), 0, 0); /* Buddy Icon */ if ((value = g_hash_table_lookup(info, "q")) != NULL) { char *icon; int icon_len; gaim_base64_decode(value, &icon, &icon_len); gaim_buddy_icons_set_for_user(session->gc->account, username, icon, icon_len); g_free(icon); serv_got_update(session->gc, username, TRUE, 0, 0, 0, 0); } /* * XXX * This does nothing when using a non-gtk event loop. * What is it supposed to accomplish anyway? */ ctx = g_main_context_default(); while (g_main_context_pending(ctx)) g_main_context_iteration(ctx, FALSE); g_free(username); break; case TREPIA_MEMBER_OFFLINE: if ((value = g_hash_table_lookup(info, "a")) != NULL) id = atoi(value); else break; profile = g_hash_table_lookup(session->user_profiles, &id); if (profile == NULL) break; g_hash_table_remove(session->user_profiles, &id); b = profile->buddy; if (b != NULL) serv_got_update(session->gc, trepia_profile_get_login(profile), FALSE, 0, 0, 0, 0); gaim_blist_remove_buddy(b); break; default: break; } g_hash_table_destroy(info); } else {