Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/EionRobb/skype4pidgin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEion Robb <eion@robbmob.com>2016-03-30 11:01:35 +0300
committerEion Robb <eion@robbmob.com>2016-03-30 11:01:35 +0300
commit922ca9580ead376b3c451458f914fa27b772a1a3 (patch)
tree85197fcfb647973eb6617b79ce89f36448149c52
parent80368db8f881ed005d9632a48602b35aba9864b4 (diff)
SkypeWeb : Make it easier to support more user-prefixes (like for phone numbers) in the future
-rw-r--r--skypeweb/libskypeweb.h1
-rw-r--r--skypeweb/skypeweb_contacts.c6
-rw-r--r--skypeweb/skypeweb_messages.c57
-rw-r--r--skypeweb/skypeweb_util.c13
-rw-r--r--skypeweb/skypeweb_util.h2
5 files changed, 29 insertions, 50 deletions
diff --git a/skypeweb/libskypeweb.h b/skypeweb/libskypeweb.h
index 5d4d148..bfcc31d 100644
--- a/skypeweb/libskypeweb.h
+++ b/skypeweb/libskypeweb.h
@@ -255,6 +255,7 @@ G_MODULE_EXPORT GType skypeweb_protocol_get_type(void);
#define SKYPEWEB_CLIENTINFO_VERSION "908/1.22.117"
#define SKYPEWEB_BUDDY_IS_MSN(a) G_UNLIKELY((a) != NULL && strchr((a), '@') != NULL)
+#define SKYPEWEB_BUDDY_IS_PHONE(a) G_UNLIKELY((a) != NULL && *(a) == '+')
typedef struct _SkypeWebAccount SkypeWebAccount;
typedef struct _SkypeWebBuddy SkypeWebBuddy;
diff --git a/skypeweb/skypeweb_contacts.c b/skypeweb/skypeweb_contacts.c
index 2ba86f2..3aeae26 100644
--- a/skypeweb/skypeweb_contacts.c
+++ b/skypeweb/skypeweb_contacts.c
@@ -742,11 +742,7 @@ skypeweb_xfer_send_init(PurpleXfer *xfer)
json_object_set_string_member(obj, "type", "sharing/file");
json_object_set_string_member(obj, "filename", basename);
- if (SKYPEWEB_BUDDY_IS_MSN(swft->from)) {
- id = g_strconcat("1:", swft->from, NULL);
- } else {
- id = g_strconcat("8:", swft->from, NULL);
- }
+ id = g_strconcat(skypeweb_user_url_prefix(swft->from), swft->from, NULL);
json_array_add_string_element(userpermissions, "read");
json_object_set_array_member(permissions, id, userpermissions);
json_object_set_object_member(obj, "permissions", permissions);
diff --git a/skypeweb/skypeweb_messages.c b/skypeweb/skypeweb_messages.c
index 34058f6..667dd59 100644
--- a/skypeweb/skypeweb_messages.c
+++ b/skypeweb/skypeweb_messages.c
@@ -320,11 +320,7 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource)
// This is a One-to-one/IM message
convbuddyname = g_strdup(skypeweb_contact_url_to_name(conversationLink));
- if (SKYPEWEB_BUDDY_IS_MSN(convbuddyname)) {
- convname = g_strconcat("1:", convbuddyname, NULL);
- } else {
- convname = g_strconcat("8:", convbuddyname, NULL);
- }
+ convname = g_strconcat(skypeweb_user_url_prefix(convbuddyname), convbuddyname, NULL);
from = skypeweb_contact_url_to_name(from);
g_return_if_fail(from);
@@ -638,6 +634,9 @@ skypeweb_poll_cb(SkypeWebAccount *sa, JsonNode *node, gpointer user_data)
// Dammit, Jim; I'm a programmer, not a surgeon!
skypeweb_get_registration_token(sa);
return;
+ } else if (errorCode == 450) {
+ // "Subscription requested could not be found."
+ // No more Womens Weekly? :O
}
}
@@ -670,11 +669,7 @@ skypeweb_mark_conv_seen(PurpleConversation *conv, PurpleConversationUpdateType t
if (PURPLE_IS_IM_CONVERSATION(conv)) {
const gchar *buddyname = purple_conversation_get_name(conv);
- if (SKYPEWEB_BUDDY_IS_MSN(buddyname)) {
- convname = g_strconcat("1:", buddyname, NULL);
- } else {
- convname = g_strconcat("8:", buddyname, NULL);
- }
+ convname = g_strconcat(skypeweb_user_url_prefix(buddyname), buddyname, NULL);
} else {
convname = g_strdup(purple_conversation_get_data(conv, "chatname"));
}
@@ -907,11 +902,7 @@ skypeweb_unsubscribe_from_contact_status(SkypeWebAccount *sa, const gchar *who)
const gchar *contacts_url = "/v1/users/ME/contacts";
gchar *url;
- if (SKYPEWEB_BUDDY_IS_MSN(who)) {
- url = g_strconcat(contacts_url, "/1:", purple_url_encode(who), NULL);
- } else {
- url = g_strconcat(contacts_url, "/8:", purple_url_encode(who), NULL);
- }
+ url = g_strconcat(contacts_url, "/", skypeweb_user_url_prefix(who), purple_url_encode(who), NULL);
skypeweb_post_or_get(sa, SKYPEWEB_METHOD_DELETE | SKYPEWEB_METHOD_SSL, sa->messages_host, url, NULL, NULL, NULL, TRUE);
@@ -938,11 +929,7 @@ skypeweb_subscribe_to_contact_status(SkypeWebAccount *sa, GSList *contacts)
JsonObject *contact = json_object_new();
gchar *id;
- if (SKYPEWEB_BUDDY_IS_MSN(cur->data)) {
- id = g_strconcat("1:", cur->data, NULL);
- } else {
- id = g_strconcat("8:", cur->data, NULL);
- }
+ id = g_strconcat(skypeweb_user_url_prefix(cur->data), cur->data, NULL);
json_object_set_string_member(contact, "id", id);
json_array_add_object_element(contacts_array, contact);
@@ -1122,11 +1109,7 @@ skypeweb_send_typing(PurpleConnection *pc, const gchar *name, PurpleIMTypingStat
gchar *post, *url;
JsonObject *obj;
- if (SKYPEWEB_BUDDY_IS_MSN(name)) {
- url = g_strdup_printf("/v1/users/ME/conversations/1:%s/messages", purple_url_encode(name));
- } else {
- url = g_strdup_printf("/v1/users/ME/conversations/8:%s/messages", purple_url_encode(name));
- }
+ url = g_strdup_printf("/v1/users/ME/conversations/%s%s/messages", skypeweb_user_url_prefix(name), purple_url_encode(name));
obj = json_object_new();
json_object_set_int_member(obj, "clientmessageid", time(NULL));
@@ -1261,11 +1244,7 @@ skypeweb_send_im(PurpleConnection *pc, const gchar *who, const gchar *message, P
SkypeWebAccount *sa = purple_connection_get_protocol_data(pc);
gchar *convname;
- if (SKYPEWEB_BUDDY_IS_MSN(who)) {
- convname = g_strconcat("1:", who, NULL);
- } else {
- convname = g_strconcat("8:", who, NULL);
- }
+ convname = g_strconcat(skypeweb_user_url_prefix(who), who, NULL);
skypeweb_send_message(sa, convname, message);
g_free(convname);
@@ -1288,11 +1267,7 @@ skypeweb_chat_invite(PurpleConnection *pc, int id, const char *message, const ch
url = g_string_new("/v1/threads/");
g_string_append_printf(url, "%s", purple_url_encode(chatname));
g_string_append(url, "/members/");
- if (SKYPEWEB_BUDDY_IS_MSN(who)) {
- g_string_append_printf(url, "1:%s", purple_url_encode(who));
- } else {
- g_string_append_printf(url, "8:%s", purple_url_encode(who));
- }
+ g_string_append_printf(url, "%s%s", skypeweb_user_url_prefix(who), purple_url_encode(who));
post = "{\"role\":\"User\"}";
@@ -1316,11 +1291,7 @@ skypeweb_chat_kick(PurpleConnection *pc, int id, const char *who)
url = g_string_new("/v1/threads/");
g_string_append_printf(url, "%s", purple_url_encode(chatname));
g_string_append(url, "/members/");
- if (SKYPEWEB_BUDDY_IS_MSN(who)) {
- g_string_append_printf(url, "1:%s", purple_url_encode(who));
- } else {
- g_string_append_printf(url, "8:%s", purple_url_encode(who));
- }
+ g_string_append_printf(url, "%s%s", skypeweb_user_url_prefix(who), purple_url_encode(who));
post = "";
@@ -1340,11 +1311,7 @@ skypeweb_initiate_chat(SkypeWebAccount *sa, const gchar *who)
members = json_array_new();
contact = json_object_new();
- if (SKYPEWEB_BUDDY_IS_MSN(who)) {
- id = g_strconcat("1:", who, NULL);
- } else {
- id = g_strconcat("8:", who, NULL);
- }
+ id = g_strconcat(skypeweb_user_url_prefix(who), who, NULL);
json_object_set_string_member(contact, "id", id);
json_object_set_string_member(contact, "role", "User");
json_array_add_object_element(members, contact);
diff --git a/skypeweb/skypeweb_util.c b/skypeweb/skypeweb_util.c
index f6bfb73..9ed3cf6 100644
--- a/skypeweb/skypeweb_util.c
+++ b/skypeweb/skypeweb_util.c
@@ -81,6 +81,7 @@ skypeweb_contact_url_to_name(const gchar *url)
start = g_strrstr(url, "/8:");
if (!start) start = g_strrstr(url, "/1:");
+ if (!start) start = g_strrstr(url, "/4:");
if (!start) return NULL;
start = start + 3;
@@ -268,3 +269,15 @@ skypeweb_fetch_url_request(SkypeWebAccount *sa,
return url_data;
}
+
+const gchar *
+skypeweb_user_url_prefix(const gchar *who)
+{
+ if (SKYPEWEB_BUDDY_IS_MSN(who)) {
+ return "1:";
+ } else if(SKYPEWEB_BUDDY_IS_PHONE(who)) {
+ return "4:";
+ } else {
+ return "8:";
+ }
+}
diff --git a/skypeweb/skypeweb_util.h b/skypeweb/skypeweb_util.h
index f73a32f..d8ecff2 100644
--- a/skypeweb/skypeweb_util.h
+++ b/skypeweb/skypeweb_util.h
@@ -36,3 +36,5 @@ skypeweb_fetch_url_request(SkypeWebAccount *sa,
const char *url, gboolean full, const char *user_agent, gboolean http11,
const char *request, gboolean include_headers, gssize max_len,
PurpleUtilFetchUrlCallback callback, void *user_data);
+
+const gchar *skypeweb_user_url_prefix(const gchar *who);