* Copyright (C) 2005 Bartosz Oler <bartosz@bzimage.us> * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA /* void ggp_buddylist_send(PurpleConnection *gc) {{{ */ /* this is for for notify purposes, not synchronizing buddy list */ void ggp_buddylist_send(PurpleConnection *gc) GGPInfo *info = purple_connection_get_protocol_data(gc); PurpleAccount *account = purple_connection_get_account(gc); buddies = purple_blist_find_buddies(account, NULL); size = g_slist_length(buddies); userlist = g_new(uin_t, size); types = g_new(gchar, size); for (buddies = purple_blist_find_buddies(account, NULL); buddies; buddies = g_slist_delete_link(buddies, buddies), ++i) PurpleBuddy *buddy = buddies->data; const gchar *name = purple_buddy_get_name(buddy); userlist[i] = ggp_str_to_uin(name); types[i] = GG_USER_NORMAL; purple_debug_info("gg", "ggp_buddylist_send: adding %d\n", ret = gg_notify_ex(info->session, userlist, types, size); purple_debug_info("gg", "send: ret=%d; size=%d\n", ret, size); /* void ggp_buddylist_load(PurpleConnection *gc, char *buddylist) {{{ */ void ggp_buddylist_load(PurpleConnection *gc, char *buddylist) char *utf8buddylist = ggp_convert_from_cp1250(buddylist); /* Don't limit the number of records in a buddylist. */ users_tbl = g_strsplit(utf8buddylist, "\r\n", -1); for (i = 0; users_tbl[i] != NULL; i++) { data_tbl = g_strsplit(users_tbl[i], ";", 8); if (g_strv_length(data_tbl) < 8) { purple_debug_warning("gg", "Something is wrong on line %d of the buddylist. Skipping.\n", show = data_tbl[F_NICKNAME]; if ('\0' == *name || !atol(name)) { purple_debug_warning("gg", "Identifier on line %d of the buddylist is not a number. Skipping.\n", purple_debug_info("gg", "got buddy: name=%s; show=%s\n", name, show); if (purple_blist_find_buddy(purple_connection_get_account(gc), name)) { g = g_strdup("Gadu-Gadu"); if ('\0' != *(data_tbl[F_GROUP])) { /* XXX: Probably buddy should be added to all the groups. */ /* Hard limit to at most 50 groups */ gchar **group_tbl = g_strsplit(data_tbl[F_GROUP], ",", 50); if (g_strv_length(group_tbl) > 0) { g = g_strdup(group_tbl[0]); buddy = purple_buddy_new(purple_connection_get_account(gc), name, *show == '\0' ? NULL : show); if (!(group = purple_blist_find_group(g))) { group = purple_group_new(g); purple_blist_add_group(group, NULL); purple_blist_add_buddy(buddy, NULL, group, NULL); /* char *ggp_buddylist_dump(PurpleAccount *account) {{{ */ char *ggp_buddylist_dump(PurpleAccount *account) GString *buddylist = g_string_sized_new(1024); for (buddies = purple_blist_find_buddies(account, NULL); buddies; buddies = g_slist_delete_link(buddies, buddies)) PurpleBuddy *buddy = buddies->data; PurpleGroup *group = purple_buddy_get_group(buddy); const char *bname = purple_buddy_get_name(buddy); const char *gname = purple_group_get_name(group); const char *alias = purple_buddy_get_alias(buddy); g_string_append_printf(buddylist, "%s;%s;%s;%s;%s;%s;%s;%s%s\r\n", alias, alias, alias, alias, "", gname, bname, "", ""); ptr = ggp_convert_to_cp1250(buddylist->str); g_string_free(buddylist, TRUE); const char * ggp_buddylist_get_buddy_name(PurpleConnection *gc, const uin_t uin) const char *uin_s = ggp_uin_to_str(uin); PurpleBuddy *buddy = purple_blist_find_buddy( purple_connection_get_account(gc), uin_s); return purple_buddy_get_alias(buddy); /* vim: set ts=8 sts=0 sw=8 noet: */