Exemplo n.º 1
0
static void
skypeweb_login_did_auth(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message)
{
    gchar *refresh_token;
    SkypeWebAccount *sa = user_data;

    if (url_text == NULL) {
        url_text = url_data->webdata;
        len = url_data->data_len;
    }

    refresh_token = skypeweb_string_get_chunk(url_text, len, "=\"skypetoken\" value=\"", "\"");
    if (refresh_token == NULL) {
        if (g_strstr_len(url_text, len, "recaptcha_response_field")) {
            purple_connection_error(sa->pc,
                                    PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED,
                                    _("Captcha required.\nTry logging into web.skype.com and try again."));
            return;
        } else {
            purple_debug_info("skypeweb", "login response was %s\r\n", url_text);
            purple_connection_error(sa->pc,
                                    PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED,
                                    _("Failed getting Skype Token"));
            return;
        }
    }

    sa->skype_token = refresh_token;

    skypeweb_update_cookies(sa, url_text);

    skypeweb_do_all_the_things(sa);
}
Exemplo n.º 2
0
static void
skypeweb_got_self_details(SkypeWebAccount *sa, JsonNode *node, gpointer user_data)
{
	JsonObject *userobj;
	const gchar *old_alias;
	const gchar *displayname = NULL;
	const gchar *username;
	
	if (node == NULL || json_node_get_node_type(node) != JSON_NODE_OBJECT)
		return;
	userobj = json_node_get_object(node);
	
	username = json_object_get_string_member(userobj, "username");
	g_free(sa->username); sa->username = g_strdup(username);
	
	old_alias = purple_account_get_private_alias(sa->account);
	if (!old_alias || !*old_alias) {
		if (json_object_has_member(userobj, "displayname"))
			displayname = json_object_get_string_member(userobj, "displayname");
		if (!displayname || g_str_equal(displayname, username))
			displayname = json_object_get_string_member(userobj, "firstname");
	
		if (displayname)
			purple_account_set_private_alias(sa->account, displayname);
	}
	
	if (!PURPLE_CONNECTION_IS_CONNECTED(sa->pc)) {
		skypeweb_do_all_the_things(sa);
	}
}