diff options
Diffstat (limited to 'skypeweb/skypeweb_login.c')
-rw-r--r-- | skypeweb/skypeweb_login.c | 70 |
1 files changed, 8 insertions, 62 deletions
diff --git a/skypeweb/skypeweb_login.c b/skypeweb/skypeweb_login.c index 2540ee2..2aa24f8 100644 --- a/skypeweb/skypeweb_login.c +++ b/skypeweb/skypeweb_login.c @@ -3,54 +3,9 @@ static void
-skypeweb_got_login_scope(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message)
-{
- SkypeWebAccount *sa = user_data;
-
- purple_connection_set_state(sa->pc, PURPLE_CONNECTED);
-
- skypeweb_do_all_the_things(sa);
-}
-
-static void
-skypeweb_get_login_scope(SkypeWebAccount *sa, const gchar *session_token)
-{
- const gchar *main_url = "https://web.skype.com/";
- gchar *request;
- GString *postdata;
-
- postdata = g_string_new("");
- g_string_append_printf(postdata, "skypetoken=%s&", purple_url_encode(sa->skype_token));
- g_string_append_printf(postdata, "session_token=%s&", purple_url_encode(session_token));
-
- request = g_strdup_printf("POST / HTTP/1.0\r\n"
- "Connection: close\r\n"
- "Accept: */*\r\n"
- "BehaviorOverride: redirectAs404\r\n"
- "Host: web.skype.com\r\n"
- "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n"
- "Content-Length: %" G_GSIZE_FORMAT "\r\n\r\n%s",
- strlen(postdata->str), postdata->str);
-
-#if PURPLE_VERSION_CHECK(3, 0, 0)
- purple_util_fetch_url_request(sa->account, main_url, TRUE, NULL, FALSE, request, FALSE, -1, skypeweb_got_login_scope, sa);
-#else
- purple_util_fetch_url_request(main_url, TRUE, NULL, FALSE, request, FALSE, skypeweb_got_login_scope, sa);
-#endif
-
- g_string_free(postdata, TRUE);
- g_free(request);
-
-
-
- purple_connection_update_progress(sa->pc, _("Getting scoped"), 3, 4);
-}
-
-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;
- gchar *session_token;
SkypeWebAccount *sa = user_data;
if (url_text == NULL) {
@@ -58,7 +13,7 @@ skypeweb_login_did_auth(PurpleUtilFetchUrlData *url_data, gpointer user_data, co len = url_data->data_len;
}
- refresh_token = skypeweb_string_get_chunk(url_text, len, "Set-Cookie: refresh-token=", ";");
+ refresh_token = skypeweb_string_get_chunk(url_text, len, "=\"skypetoken\" value=\"", "\"");
if (refresh_token == NULL) {
purple_debug_info("skypeweb", "login response was %s\r\n", url_text);
purple_connection_error (sa->pc,
@@ -69,12 +24,11 @@ skypeweb_login_did_auth(PurpleUtilFetchUrlData *url_data, gpointer user_data, co sa->skype_token = refresh_token;
- session_token = skypeweb_string_get_chunk(url_text, len, "Set-Cookie: skype-session-token=", ";");
- skypeweb_get_login_scope(sa, session_token);
- g_free(session_token);
+ skypeweb_update_cookies(sa, url_text);
+
+ purple_connection_set_state(sa->pc, PURPLE_CONNECTED);
- //skypeweb_update_cookies(sa, url_text);
- //skypeweb_post_or_get(sa, SKYPEWEB_METHOD_GET | SKYPEWEB_METHOD_SSL, "a.config.skype.com", "/config/v1/SkypeLyncWebExperience/905_1.1.0.0?apikey=skype.com&fingerprint=bff8bf91-1c49-4de0-8059-0ea206317fdb&callback=Skype.onConfigurationLoaded", NULL, NULL, NULL, FALSE);
+ skypeweb_do_all_the_things(sa);
}
static void
@@ -84,7 +38,7 @@ skypeweb_login_got_pie(PurpleUtilFetchUrlData *url_data, gpointer user_data, con PurpleAccount *account = sa->account;
gchar *pie;
gchar *etm;
- const gchar *login_url = "https://" SKYPEWEB_LOGIN_HOST "/login?client_id=578134&redirect_uri=https%3A%2F%2Fweb.skype.com";
+ const gchar *login_url = "https://" SKYPEWEB_LOGIN_HOST;// "/login?client_id=578134&redirect_uri=https%3A%2F%2Fweb.skype.com";
GString *postdata;
gchar *request;
struct timezone tz;
@@ -126,11 +80,7 @@ skypeweb_login_got_pie(PurpleUtilFetchUrlData *url_data, gpointer user_data, con "Content-Length: %" G_GSIZE_FORMAT "\r\n\r\n%s",
strlen(postdata->str), postdata->str);
-#if PURPLE_VERSION_CHECK(3, 0, 0)
- purple_util_fetch_url_request(sa->account, login_url, TRUE, NULL, FALSE, request, TRUE, -1, skypeweb_login_did_auth, sa);
-#else
- purple_util_fetch_url_request(login_url, TRUE, NULL, FALSE, request, TRUE, skypeweb_login_did_auth, sa);
-#endif
+ purple_util_fetch_url_request(sa->account, login_url, TRUE, NULL, FALSE, request, TRUE, 524288, skypeweb_login_did_auth, sa);
g_string_free(postdata, TRUE);
g_free(request);
@@ -143,11 +93,7 @@ skypeweb_begin_web_login(SkypeWebAccount *sa) {
const gchar *login_url = "https://" SKYPEWEB_LOGIN_HOST "/login";
-#if PURPLE_VERSION_CHECK(3, 0, 0)
- purple_util_fetch_url_request(sa->account, login_url, TRUE, NULL, FALSE, NULL, FALSE, -1, skypeweb_login_got_pie, sa);
-#else
- purple_util_fetch_url_request(login_url, TRUE, NULL, FALSE, NULL, FALSE, skypeweb_login_got_pie, sa);
-#endif
+ purple_util_fetch_url_request(sa->account, login_url, TRUE, NULL, FALSE, NULL, FALSE, 524288, skypeweb_login_got_pie, sa);
purple_connection_set_state(sa->pc, PURPLE_CONNECTING);
purple_connection_update_progress(sa->pc, _("Connecting"), 1, 4);
|