diff options
-rw-r--r-- | skypeweb/libskypeweb.c | 29 | ||||
-rw-r--r-- | skypeweb/libskypeweb.h | 1 | ||||
-rw-r--r-- | skypeweb/skypeweb_connection.c | 10 | ||||
-rw-r--r-- | skypeweb/skypeweb_contacts.c | 112 | ||||
-rw-r--r-- | skypeweb/skypeweb_contacts.h | 1 | ||||
-rw-r--r-- | skypeweb/skypeweb_login.c | 70 | ||||
-rw-r--r-- | skypeweb/skypeweb_messages.c | 31 |
7 files changed, 142 insertions, 112 deletions
diff --git a/skypeweb/libskypeweb.c b/skypeweb/libskypeweb.c index a40ab6b..25c2688 100644 --- a/skypeweb/libskypeweb.c +++ b/skypeweb/libskypeweb.c @@ -27,12 +27,14 @@ skypeweb_do_all_the_things(SkypeWebAccount *sa) /* PRPL functions */
/******************************************************************************/
-static const char *skypeweb_list_icon(PurpleAccount *account, PurpleBuddy *buddy)
+static const char *
+skypeweb_list_icon(PurpleAccount *account, PurpleBuddy *buddy)
{
return "skype";
}
-static gchar *skypeweb_status_text(PurpleBuddy *buddy)
+static gchar *
+skypeweb_status_text(PurpleBuddy *buddy)
{
SkypeWebBuddy *sbuddy = buddy->proto_data;
@@ -76,8 +78,8 @@ skypeweb_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gbool const gchar *
skypeweb_list_emblem(PurpleBuddy *buddy)
{
- SkypeWebBuddy *sbuddy = buddy->proto_data;
-
+ //SkypeWebBuddy *sbuddy = buddy->proto_data;
+
return NULL;
}
@@ -86,8 +88,6 @@ skypeweb_status_types(PurpleAccount *account) {
GList *types = NULL;
PurpleStatusType *status;
-
- purple_debug_info("skypeweb", "status_types\n");
status = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE, "Online", NULL, TRUE, TRUE, FALSE, "message", "Mood", purple_value_new(PURPLE_TYPE_STRING), NULL);
types = g_list_append(types, status);
@@ -104,7 +104,8 @@ skypeweb_status_types(PurpleAccount *account) }
-static void skypeweb_buddy_free(PurpleBuddy *buddy)
+static void
+skypeweb_buddy_free(PurpleBuddy *buddy)
{
SkypeWebBuddy *sbuddy = buddy->proto_data;
if (sbuddy != NULL)
@@ -166,18 +167,17 @@ skypeweb_login(PurpleAccount *account) static void skypeweb_close(PurpleConnection *pc)
{
SkypeWebAccount *sa;
- GString *post;
g_return_if_fail(pc != NULL);
g_return_if_fail(pc->proto_data != NULL);
sa = pc->proto_data;
- skypeweb_logout(sa);
-
purple_timeout_remove(sa->authcheck_timeout);
purple_timeout_remove(sa->poll_timeout);
purple_timeout_remove(sa->watchdog_timeout);
+
+ skypeweb_logout(sa);
purple_debug_info("skypeweb", "destroying %d waiting connections\n",
g_queue_get_length(sa->waiting_conns));
@@ -191,7 +191,7 @@ static void skypeweb_close(PurpleConnection *pc) while (sa->conns != NULL)
skypeweb_connection_destroy(sa->conns->data);
-
+
while (sa->dns_queries != NULL) {
PurpleDnsQueryData *dns_query = sa->dns_queries->data;
purple_debug_info("skypeweb", "canceling dns query for %s\n",
@@ -237,12 +237,11 @@ static GList *skypeweb_actions(PurplePlugin *plugin, gpointer context) static void plugin_init(PurplePlugin *plugin)
{
- PurpleAccountOption *option;
+ /*PurpleAccountOption *option;
PurplePluginInfo *info = plugin->info;
PurplePluginProtocolInfo *prpl_info = info->extra_info;
-
- /*option = purple_account_option_bool_new(
+ option = purple_account_option_bool_new(
_("Always use HTTPS"),
"always_use_https", FALSE);
prpl_info->protocol_options = g_list_append(
@@ -275,7 +274,7 @@ static PurplePluginProtocolInfo prpl_info = { skypeweb_send_im, /* send_im */
NULL, /* set_info */
skypeweb_send_typing, /* send_typing */
- NULL,//skypeweb_get_info, /* get_info */
+ skypeweb_get_info, /* get_info */
skypeweb_set_status, /* set_status */
skypeweb_set_idle, /* set_idle */
NULL, /* change_passwd */
diff --git a/skypeweb/libskypeweb.h b/skypeweb/libskypeweb.h index 4676be8..a2fbf25 100644 --- a/skypeweb/libskypeweb.h +++ b/skypeweb/libskypeweb.h @@ -64,6 +64,7 @@ #if !PURPLE_VERSION_CHECK(3, 0, 0) #define purple_connection_error purple_connection_error_reason #define purple_notify_user_info_add_pair_html purple_notify_user_info_add_pair + #define purple_util_fetch_url_request purple_util_fetch_url_request_len_with_account #endif #define SKYPEWEB_MAX_MSG_RETRY 2 diff --git a/skypeweb/skypeweb_connection.c b/skypeweb/skypeweb_connection.c index c6c26ab..933cceb 100644 --- a/skypeweb/skypeweb_connection.c +++ b/skypeweb/skypeweb_connection.c @@ -206,7 +206,7 @@ static void skypeweb_connection_process_data(SkypeWebConnection *skypewebcon) if (skypewebcon->callback != NULL) { if (!len) { - //purple_debug_error("skypeweb", "No data in response\n"); + purple_debug_info("skypeweb", "No data in response\n"); skypewebcon->callback(skypewebcon->sa, NULL, skypewebcon->user_data); } else { JsonParser *parser = json_parser_new(); @@ -221,7 +221,7 @@ static void skypeweb_connection_process_data(SkypeWebConnection *skypewebcon) JsonNode *root = json_parser_get_root(parser); //TODO - //purple_debug_info("skypeweb", "Got response: %s\n", tmp); + purple_debug_info("skypeweb", "Got response: %s\n", tmp); purple_debug_info("skypeweb", "executing callback for %s\n", skypewebcon->url); skypewebcon->callback(skypewebcon->sa, root, skypewebcon->user_data); } @@ -505,7 +505,7 @@ skypeweb_post_or_get(SkypeWebAccount *sa, SkypeWebMethod method, SkypeWebConnection *skypewebcon; gchar *real_url; gboolean is_proxy = FALSE; - const gchar *user_agent; + //const gchar *user_agent; const gchar* const *languages; gchar *language_names; PurpleProxyInfo *proxy_info = NULL; @@ -542,7 +542,7 @@ skypeweb_post_or_get(SkypeWebAccount *sa, SkypeWebMethod method, } cookies = skypeweb_cookies_to_string(sa); - //user_agent = purple_account_get_string(sa->account, "user-agent", "SkypeWeb 1.2.0 / iPhone"); + //user_agent = purple_account_get_string(sa->account, "user-agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36"); if (method & SKYPEWEB_METHOD_POST && !postdata) postdata = ""; @@ -559,7 +559,7 @@ skypeweb_post_or_get(SkypeWebAccount *sa, SkypeWebMethod method, //g_string_append_printf(request, "User-Agent: %s\r\n", user_agent); if (method & SKYPEWEB_METHOD_POST) { - if (postdata && postdata[0] == '[' || postdata[0] == '{') { + if (postdata && (postdata[0] == '[' || postdata[0] == '{')) { g_string_append(request, "Content-Type: application/json\r\n"); // hax } else { g_string_append_printf(request, "Content-Type: application/x-www-form-urlencoded\r\n"); diff --git a/skypeweb/skypeweb_contacts.c b/skypeweb/skypeweb_contacts.c index e4be388..134757b 100644 --- a/skypeweb/skypeweb_contacts.c +++ b/skypeweb/skypeweb_contacts.c @@ -31,17 +31,13 @@ skypeweb_get_icon_now(PurpleBuddy *buddy) purple_debug_info("skypeweb", "getting new buddy icon for %s\n", buddy->name);
sbuddy = buddy->proto_data;
- if (sbuddy->avatar_url) {
+ if (sbuddy->avatar_url && sbuddy->avatar_url[0]) {
url = g_strdup(sbuddy->avatar_url);
} else {
url = g_strdup_printf("https://api.skype.com/users/%s/profile/avatar", purple_url_encode(buddy->name));
}
-#if PURPLE_VERSION_CHECK(3, 0, 0)
- purple_util_fetch_url_request(buddy->account, url, TRUE, NULL, FALSE, NULL, FALSE, -1, skypeweb_get_icon_cb, buddy);
-#else
- purple_util_fetch_url_request(url, TRUE, NULL, FALSE, NULL, FALSE, skypeweb_get_icon_cb, buddy);
-#endif
+ purple_util_fetch_url_request(buddy->account, url, TRUE, NULL, FALSE, NULL, FALSE, 524288, skypeweb_get_icon_cb, buddy);
g_free(url);
@@ -229,8 +225,7 @@ skypeweb_got_friend_profiles(SkypeWebAccount *sa, JsonNode *node, gpointer user_ if (!buddy)
continue;
sbuddy = buddy->proto_data;
- if (sbuddy == NULL)
- {
+ if (sbuddy == NULL) {
sbuddy = g_new0(SkypeWebBuddy, 1);
buddy->proto_data = sbuddy;
sbuddy->skypename = g_strdup(username);
@@ -256,21 +251,100 @@ skypeweb_got_friend_profiles(SkypeWebAccount *sa, JsonNode *node, gpointer user_ void
skypeweb_get_friend_profiles(SkypeWebAccount *sa, GSList *contacts)
{
- const gchar *profiles_url = "/users/SELF/contacts/profiles"; //TODO: Might need to be username instead of SELF
+ const gchar *profiles_url = "/users/self/contacts/profiles";
GString *postdata;
GSList *cur = contacts;
+ if (contacts == NULL)
+ return;
+
postdata = g_string_new("");
do {
- g_string_append_printf(postdata, "&contacts[]=", purple_url_encode(cur->data));
+ g_string_append_printf(postdata, "&contacts[]=%s", purple_url_encode(cur->data));
} while((cur = g_slist_next(cur)));
- skypeweb_post_or_get(sa, SKYPEWEB_METHOD_GET | SKYPEWEB_METHOD_SSL, SKYPEWEB_CONTACTS_HOST, profiles_url, NULL, skypeweb_got_friend_profiles, NULL, TRUE);
+ skypeweb_post_or_get(sa, SKYPEWEB_METHOD_POST | SKYPEWEB_METHOD_SSL, SKYPEWEB_CONTACTS_HOST, profiles_url, postdata->str, skypeweb_got_friend_profiles, NULL, TRUE);
g_string_free(postdata, TRUE);
}
+
+static void
+skypeweb_got_info(SkypeWebAccount *sa, JsonNode *node, gpointer user_data)
+{
+ gchar *username = user_data;
+ PurpleNotifyUserInfo *user_info;
+ JsonObject *userobj;
+ PurpleBuddy *buddy;
+ SkypeWebBuddy *sbuddy;
+ const gchar *new_avatar;
+
+ userobj = json_node_get_object(node);
+
+ user_info = purple_notify_user_info_new();
+
+#define _SKYPE_USER_INFO(prop, key) if (prop && !json_object_get_null_member(userobj, (prop))) \
+ purple_notify_user_info_add_pair_html(user_info, _(key), json_object_get_string_member(userobj, (prop)));
+
+ _SKYPE_USER_INFO("firstname", "First name");
+ _SKYPE_USER_INFO("lastname", "Last name");
+ _SKYPE_USER_INFO("birthday", "Birthday");
+ _SKYPE_USER_INFO("gender", "Gender");
+ _SKYPE_USER_INFO("language", "Language");
+ _SKYPE_USER_INFO("country", "Country");
+ _SKYPE_USER_INFO("province", "Province");
+ _SKYPE_USER_INFO("city", "City");
+ _SKYPE_USER_INFO("homepage", "Homepage");
+ _SKYPE_USER_INFO("about", "About");
+ _SKYPE_USER_INFO("jobtitle", "Job Title");
+ _SKYPE_USER_INFO("phoneMobile", "Phone - Mobile");
+ _SKYPE_USER_INFO("phoneHome", "Phone - Home");
+ _SKYPE_USER_INFO("phoneOffice", "Phone - Office");
+ //_SKYPE_USER_INFO("mood", "Mood");
+ //_SKYPE_USER_INFO("richMood", "Mood");
+ //_SKYPE_USER_INFO("avatarUrl", "Avatar");
+
+ buddy = purple_find_buddy(sa->account, username);
+ if (buddy) {
+ sbuddy = buddy->proto_data;
+ if (sbuddy == NULL) {
+ sbuddy = g_new0(SkypeWebBuddy, 1);
+ buddy->proto_data = sbuddy;
+ sbuddy->skypename = g_strdup(username);
+ }
+
+ new_avatar = json_object_get_string_member(userobj, "avatarUrl");
+ if (new_avatar && (!sbuddy->avatar_url || !g_str_equal(sbuddy->avatar_url, new_avatar))) {
+ g_free(sbuddy->avatar_url);
+ sbuddy->avatar_url = g_strdup(new_avatar);
+ skypeweb_get_icon(buddy);
+ }
+
+ g_free(sbuddy->mood); sbuddy->mood = g_strdup(json_object_get_string_member(userobj, "mood"));
+ g_free(sbuddy->rich_mood); sbuddy->rich_mood = g_strdup(json_object_get_string_member(userobj, "richMood"));
+ g_free(sbuddy->country); sbuddy->country = g_strdup(json_object_get_string_member(userobj, "country"));
+ g_free(sbuddy->city); sbuddy->city = g_strdup(json_object_get_string_member(userobj, "city"));
+ }
+
+ purple_notify_userinfo(sa->pc, username, user_info, NULL, NULL);
+
+ g_free(username);
+}
+
+void
+skypeweb_get_info(PurpleConnection *pc, const gchar *username)
+{
+ SkypeWebAccount *sa = pc->proto_data;
+ gchar *url;
+
+ url = g_strdup_printf("/users/%s/profile", purple_url_encode(username));
+
+ skypeweb_post_or_get(sa, SKYPEWEB_METHOD_GET | SKYPEWEB_METHOD_SSL, SKYPEWEB_CONTACTS_HOST, url, NULL, skypeweb_got_info, g_strdup(username), TRUE);
+
+ g_free(url);
+}
+
void
skypeweb_get_friend_profile(SkypeWebAccount *sa, const gchar *who)
{
@@ -322,8 +396,12 @@ skypeweb_get_friend_list_cb(SkypeWebAccount *sa, JsonNode *node, gpointer user_d 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;
- if (!purple_find_buddy(sa->account, skypename))
+ purple_debug_info("skypeweb", "Found user %s\n", skypename);
+
+ buddy = purple_find_buddy(sa->account, skypename);
+ if (!buddy)
{
if (!group)
{
@@ -334,7 +412,8 @@ skypeweb_get_friend_list_cb(SkypeWebAccount *sa, JsonNode *node, gpointer user_d purple_blist_add_group(group, NULL);
}
}
- purple_blist_add_buddy(purple_buddy_new(sa->account, skypename, NULL), NULL, 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);
@@ -344,6 +423,9 @@ skypeweb_get_friend_list_cb(SkypeWebAccount *sa, JsonNode *node, gpointer user_d sbuddy->authorized = authorized;
sbuddy->blocked = blocked;
+ sbuddy->buddy = buddy;
+ buddy->proto_data = sbuddy;
+
serv_got_alias(sa->pc, skypename, sbuddy->display_name); //purple_blist_server_alias_buddy(buddy, string_parts[3]);
users_to_fetch = g_slist_prepend(users_to_fetch, (gpointer) skypename);
@@ -413,7 +495,7 @@ skypeweb_got_authrequests(SkypeWebAccount *sa, JsonNode *node, gpointer user_dat for(index = 0; index < length; index++)
{
JsonObject *request = json_array_get_object_element(requests, index);
- const gchar *event_time = json_object_get_string_member(request, "event_time");
+ //const gchar *event_time = json_object_get_string_member(request, "event_time");
const gchar *sender = json_object_get_string_member(request, "sender");
const gchar *greeting = json_object_get_string_member(request, "greeting");
@@ -457,6 +539,6 @@ skypeweb_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) void
skypeweb_buddy_remove(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group)
{
- SkypeWebAccount *sa = pc->proto_data;
+ //SkypeWebAccount *sa = pc->proto_data;
}
\ No newline at end of file diff --git a/skypeweb/skypeweb_contacts.h b/skypeweb/skypeweb_contacts.h index c2e8095..3e3691a 100644 --- a/skypeweb/skypeweb_contacts.h +++ b/skypeweb/skypeweb_contacts.h @@ -11,6 +11,7 @@ void skypeweb_get_friend_profiles(SkypeWebAccount *sa, GSList *contacts); void skypeweb_get_friend_profile(SkypeWebAccount *sa, const gchar *who); void skypeweb_get_friend_list(SkypeWebAccount *sa); +void skypeweb_get_info(PurpleConnection *pc, const gchar *username); void skypeweb_buddy_remove(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group); void skypeweb_add_buddy_with_invite(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group, const char* message); 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);
diff --git a/skypeweb/skypeweb_messages.c b/skypeweb/skypeweb_messages.c index c355418..3e19294 100644 --- a/skypeweb/skypeweb_messages.c +++ b/skypeweb/skypeweb_messages.c @@ -146,7 +146,7 @@ skypeweb_subscribe_cb(SkypeWebAccount *sa, JsonNode *node, gpointer user_data) {
//{"id":"messagingService","type":"EndpointPresenceDoc","selfLink":"uri","privateInfo":{"epname":"skype"},"publicInfo":{"capabilities":"video|audio","type":1,"skypeNameVersion":"908/1.0.20/swx-skype.com","nodeInfo":"xx","version":"908/1.0.20"}}
// /v1/users/ME/endpoints/%7B60da4fa8-79f0-445b-846f-1f1e0116ecb5%7D/presenceDocs/messagingService
-
+
skypeweb_do_all_the_things(sa);
}
@@ -233,11 +233,7 @@ skypeweb_get_registration_token(SkypeWebAccount *sa) purple_debug_info("skypeweb", "reg token request is %s\n", request);
-#if PURPLE_VERSION_CHECK(3, 0, 0)
- requestdata = purple_util_fetch_url_request(sa->account, messages_url, TRUE, NULL, FALSE, request, TRUE, -1, skypeweb_got_registration_token, sa);
-#else
- requestdata = purple_util_fetch_url_request(messages_url, TRUE, NULL, FALSE, request, TRUE, skypeweb_got_registration_token, sa);
-#endif
+ requestdata = purple_util_fetch_url_request(sa->account, messages_url, TRUE, NULL, FALSE, request, TRUE, 524288, skypeweb_got_registration_token, sa);
requestdata->num_times_redirected = 10; /* Prevent following redirects */
g_free(request);
@@ -276,16 +272,12 @@ skypeweb_send_typing(PurpleConnection *pc, const gchar *name, PurpleTypingState }
-
-
-void
-skypeweb_set_status(PurpleAccount *account, PurpleStatus *status)
+static void
+skypeweb_set_statusid(SkypeWebAccount *sa, const gchar *status)
{
- PurpleConnection *pc = purple_account_get_connection(account);
- SkypeWebAccount *sa = pc->proto_data;
gchar *post;
- post = g_strdup_printf("{\"status\":\"%s\"}", purple_status_get_id(status));
+ post = g_strdup_printf("{\"status\":\"%s\"}", status);
skypeweb_post_or_get(sa, SKYPEWEB_METHOD_PUT | SKYPEWEB_METHOD_SSL, SKYPEWEB_MESSAGES_HOST, "/v1/users/ME/presenceDocs/messagingService", post, NULL, NULL, TRUE);
@@ -293,14 +285,23 @@ skypeweb_set_status(PurpleAccount *account, PurpleStatus *status) }
void
+skypeweb_set_status(PurpleAccount *account, PurpleStatus *status)
+{
+ PurpleConnection *pc = purple_account_get_connection(account);
+ SkypeWebAccount *sa = pc->proto_data;
+
+ skypeweb_set_statusid(sa, purple_status_get_id(status));
+}
+
+void
skypeweb_set_idle(PurpleConnection *pc, int time)
{
SkypeWebAccount *sa = pc->proto_data;
if (time < 30) {
- //skypeweb_set_status(pc->account, active status);
+ skypeweb_set_statusid(sa, "Online");
} else {
- //skypeweb_set_status(pc->account, idle status);
+ skypeweb_set_statusid(sa, "Idle");
}
}
|