/cpw/tomkiewicz/gg11: fd4379677b3b: Gadu-Gadu: fix edisc authent...
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Sat Nov 3 08:25:30 EDT 2012
Changeset: fd4379677b3b558745565dc6e099b57dac6f0f4f
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2012-11-03 13:25 +0100
Branch: default
URL: http://hg.pidgin.im/cpw/tomkiewicz/gg11/rev/fd4379677b3b
Description:
Gadu-Gadu: fix edisc authentication
diffstat:
libpurple/protocols/gg/edisc.c | 30 +++++++++++++++++++++++++++---
1 files changed, 27 insertions(+), 3 deletions(-)
diffs (50 lines):
diff --git a/libpurple/protocols/gg/edisc.c b/libpurple/protocols/gg/edisc.c
--- a/libpurple/protocols/gg/edisc.c
+++ b/libpurple/protocols/gg/edisc.c
@@ -660,12 +660,34 @@ static void ggp_ggdrive_auth_done(Purple
{
PurpleConnection *gc = purple_http_conn_get_purple_connection(hc);
ggp_edisc_session_data *sdata = ggp_edisc_get_sdata(gc);
+ JsonParser *parser;
+ JsonObject *result;
+ int status = -1;
sdata->auth_request = NULL;
- if (!purple_http_response_is_successfull(response) ||
- 0 != strcmp(purple_http_response_get_data(response),
- "{\"result\":{\"status\":0}}")) {
+ if (!purple_http_response_is_successfull(response)) {
+ purple_debug_misc("gg", "ggp_ggdrive_auth_done: authentication "
+ "failed due to unsuccessful request (code = %d)\n",
+ purple_http_response_get_code(response));
+ ggp_ggdrive_auth_results(gc, FALSE);
+ return;
+ }
+
+ parser = ggp_json_parse(purple_http_response_get_data(response));
+ result = json_node_get_object(json_parser_get_root(parser));
+ result = json_object_get_object_member(result, "result");
+ if (json_object_has_member(result, "status"))
+ status = json_object_get_int_member(result, "status");
+ g_object_unref(parser);
+
+ if (status != 0 ) {
+ purple_debug_misc("gg", "ggp_ggdrive_auth_done: authentication "
+ "failed due to bad result (status=%d)\n", status);
+ if (purple_debug_is_verbose())
+ purple_debug_misc("gg", "ggp_ggdrive_auth_done: "
+ "result = %s\n",
+ purple_http_response_get_data(response));
ggp_ggdrive_auth_results(gc, FALSE);
return;
}
@@ -673,6 +695,8 @@ static void ggp_ggdrive_auth_done(Purple
sdata->security_token = g_strdup(purple_http_response_get_header(
response, "X-gged-security-token"));
if (!sdata->security_token) {
+ purple_debug_misc("gg", "ggp_ggdrive_auth_done: authentication "
+ "failed due to missing security token header\n");
ggp_ggdrive_auth_results(gc, FALSE);
return;
}
More information about the Commits
mailing list