Ejemplo n.º 1
0
void
skypeweb_get_friend_profile(SkypeWebAccount *sa, const gchar *who)
{
	GSList *contacts = NULL;
	gchar *whodup;
	
	g_return_if_fail(sa && who && *who);
	
	whodup = g_strdup(who);
	contacts = g_slist_prepend(contacts, whodup);
	
	skypeweb_get_friend_profiles(sa, contacts);
	
	g_free(contacts);
	g_free(whodup);
}
Ejemplo n.º 2
0
static void
skypeweb_get_friend_list_cb(SkypeWebAccount *sa, JsonNode *node, gpointer user_data)
{
	JsonArray *friends;
	PurpleGroup *group = NULL;
	GSList *users_to_fetch = NULL;
	gint index, length;
	
	friends = json_node_get_array(node);
	length = json_array_get_length(friends);
	
	for(index = 0; index < length; index++)
	{
		JsonObject *friend = json_array_get_object_element(friends, index);
		const gchar *skypename = json_object_get_string_member(friend, "skypename");
		const gchar *fullname = json_object_get_string_member(friend, "fullname");
		const gchar *display_name = json_object_get_string_member(friend, "display_name");
		gboolean authorized = json_object_get_boolean_member(friend, "authorized");
		gboolean blocked = json_object_get_boolean_member(friend, "blocked");
		PurpleBuddy *buddy;
		
		buddy = purple_find_buddy(sa->account, skypename);
		if (!buddy)
		{
			if (!group)
			{
				group = purple_blist_find_group("Skype");
				if (!group)
				{
					group = purple_group_new("Skype");
					purple_blist_add_group(group, NULL);
				}
			}
			buddy = purple_buddy_new(sa->account, skypename, display_name);
			purple_blist_add_buddy(buddy, NULL, group, NULL);
		}
		
		SkypeWebBuddy *sbuddy = g_new0(SkypeWebBuddy, 1);
		sbuddy->skypename = g_strdup(skypename);
		sbuddy->sa = sa;
		sbuddy->fullname = g_strdup(fullname);
		sbuddy->display_name = g_strdup(display_name);
		sbuddy->authorized = authorized;
		sbuddy->blocked = blocked;
		
		sbuddy->buddy = buddy;
		purple_buddy_set_protocol_data(buddy, sbuddy);
		
		purple_serv_got_alias(sa->pc, skypename, sbuddy->display_name);
		purple_blist_server_alias_buddy(buddy, fullname);
		
		users_to_fetch = g_slist_prepend(users_to_fetch, sbuddy->skypename);
	}
	
	if (users_to_fetch)
	{
		skypeweb_get_friend_profiles(sa, users_to_fetch);
		skypeweb_subscribe_to_contact_status(sa, users_to_fetch);
		g_slist_free(users_to_fetch);
	}
}