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>2014-12-09 09:04:24 +0300
committerEion Robb <eion@robbmob.com>2014-12-09 09:04:24 +0300
commit1a90351c2c8ad1c704da1d673fbed13e4ca6bbf3 (patch)
tree9f14b55e6d405068cd534510d290c61862bc7d28
parentb4fd0d7269f6b76485bb269183f984d7acf45941 (diff)
SkypeWeb : Add in a uri-handler for skype: uri's
-rw-r--r--skypeweb/libskypeweb.c105
-rw-r--r--skypeweb/skypeweb_util.c30
-rw-r--r--skypeweb/skypeweb_util.h4
3 files changed, 136 insertions, 3 deletions
diff --git a/skypeweb/libskypeweb.c b/skypeweb/libskypeweb.c
index 11d36f7..4fbe9f6 100644
--- a/skypeweb/libskypeweb.c
+++ b/skypeweb/libskypeweb.c
@@ -324,6 +324,80 @@ skypeweb_close(PurpleConnection *pc)
/******************************************************************************/
static gboolean
+skypeweb_uri_handler(const char *proto, const char *cmd, GHashTable *params)
+{
+ PurpleAccount *account;
+ PurpleConnection *pc;
+
+ if (!g_str_equal(proto, "skype"))
+ return FALSE;
+
+ /*skype uri's:
+
+ skype: //does nothing
+ skype:{buddyname} //open im with {buddyname}
+ skype:{buddynames}?chat //open multi-user chat with {buddynames}
+ skype:?chat&blob={blob id} //open public multi-user chat with the blob id of {blob id}
+ skype:?chat&id={chat id} //open multi-user chat with the id of {chat id}
+ skype:{buddyname}?add //add user to buddy list
+ skype:{buddyname}?userinfo //get buddy's info
+
+ skype:{buddynames}?call //call {buddynames}
+ skype:{buddyname}?voicemail //send a voice mail message
+ skype:{buddyname}?sendfile //send a file
+ */
+
+ account = find_acct(SKYPEWEB_PLUGIN_ID, g_hash_table_lookup(params, "account"));
+ pc = purple_account_get_connection(account);
+
+ if (g_hash_table_lookup(params, "chat")) {
+ if (cmd && *cmd) {
+ //there'll be a bunch of usernames, seperated by semi-colon
+ if (strchr(cmd, ';')) {
+ gchar **users = g_strsplit_set(cmd, ";", -1);
+ skypeweb_initiate_chat(pc->proto_data, users[0]);
+ //TODO the other users
+ g_strfreev(users);
+ } else {
+ PurpleConversation *conv;
+ conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, cmd, account);
+ if (!conv) {
+ conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, cmd);
+ }
+ purple_conversation_present(conv);
+ }
+ } else {
+ //probably a public multi-user chat?
+ GHashTable *chatinfo;
+ if (g_hash_table_lookup(params, "id"))
+ chatinfo = skypeweb_chat_info_defaults(pc, g_hash_table_lookup(params, "id"));
+ else if (g_hash_table_lookup(params, "blob"))
+ chatinfo = skypeweb_chat_info_defaults(pc, g_hash_table_lookup(params, "blob"));
+
+ skypeweb_join_chat(pc, chatinfo);
+ g_hash_table_destroy(chatinfo);
+ }
+ } else if (g_hash_table_lookup(params, "add")) {
+ purple_blist_request_add_buddy(account, cmd, "Skype", g_hash_table_lookup(params, "displayname"));
+ return TRUE;
+ } else if (g_hash_table_lookup(params, "call")) {
+
+ } else if (g_hash_table_lookup(params, "userinfo")) {
+ skypeweb_get_info(pc, cmd);
+ return TRUE;
+ } else if (g_hash_table_lookup(params, "voicemail")) {
+
+ } else if (g_hash_table_lookup(params, "sendfile")) {
+
+ } else if (strlen(cmd)) {
+ //supposed to be the same as call?
+ }
+
+ //we don't know how to handle this
+ return FALSE;
+}
+
+static gboolean
plugin_load(PurplePlugin *plugin)
{
return TRUE;
@@ -360,7 +434,36 @@ plugin_init(PurplePlugin *plugin)
"always_use_https", FALSE);
prpl_info->protocol_options = g_list_append(
prpl_info->protocol_options, option);*/
-
+
+
+ /*
+ //leave
+ purple_cmd_register("leave", "", PURPLE_CMD_P_PRPL, PURPLE_CMD_FLAG_CHAT |
+ PURPLE_CMD_FLAG_PRPL_ONLY | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS,
+ plugin->info->id, skypeweb_cmd_leave,
+ _("leave [room]: Leave the chat"), NULL);
+ //topic
+ purple_cmd_register("topic", "s", PURPLE_CMD_P_PRPL, PURPLE_CMD_FLAG_CHAT |
+ PURPLE_CMD_FLAG_PRPL_ONLY | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS,
+ plugin->info->id, skypeweb_cmd_topic,
+ _("topic [&lt;new topic&gt;]: View or change the topic"),
+ NULL);
+ //call, as in call person
+ //kick
+ purple_cmd_register("kick", "s", PURPLE_CMD_P_PRPL, PURPLE_CMD_FLAG_CHAT |
+ PURPLE_CMD_FLAG_PRPL_ONLY,
+ plugin->info->id, skypeweb_cmd_kick,
+ _("kick &lt;user&gt; [room]: Kick a user from the room."),
+ NULL);
+ //kickban
+ purple_cmd_register("kickban", "s", PURPLE_CMD_P_PRPL, PURPLE_CMD_FLAG_CHAT |
+ PURPLE_CMD_FLAG_PRPL_ONLY,
+ plugin->info->id, skypeweb_cmd_kickban,
+ _("kickban &lt;user&gt; [room]: Kick and ban a user from the room."),
+ NULL);
+ */
+
+ purple_signal_connect(purple_get_core(), "uri-handler", plugin, PURPLE_CALLBACK(skypeweb_uri_handler), NULL);
}
static PurplePluginProtocolInfo prpl_info = {
diff --git a/skypeweb/skypeweb_util.c b/skypeweb/skypeweb_util.c
index b635471..0cff64f 100644
--- a/skypeweb/skypeweb_util.c
+++ b/skypeweb/skypeweb_util.c
@@ -67,7 +67,9 @@ skypeweb_contact_url_to_name(const gchar *url)
return tempname;
}
- return start;
+ g_free(tempname);
+ tempname = g_strdup(start);
+ return tempname;
}
/** turn https://bay-client-s.gateway.messenger.live.com/v1/users/ME/conversations/19:blah@thread.skype
@@ -200,3 +202,29 @@ skypeweb_get_js_time()
return (val.tv_sec * 1000) + (val.tv_usec / 1000);
}
+
+/* copied from oscar.c to be libpurple 2.1 compatible */
+PurpleAccount *
+find_acct(const char *prpl, const char *acct_id)
+{
+ PurpleAccount *acct = NULL;
+
+ /* If we have a specific acct, use it */
+ if (acct_id && *acct_id) {
+ acct = purple_accounts_find(acct_id, prpl);
+ if (acct && !purple_account_is_connected(acct))
+ acct = NULL;
+ } else { /* Otherwise find an active account for the protocol */
+ GList *l = purple_accounts_get_all();
+ while (l) {
+ if (!strcmp(prpl, purple_account_get_protocol_id(l->data))
+ && purple_account_is_connected(l->data)) {
+ acct = l->data;
+ break;
+ }
+ l = l->next;
+ }
+ }
+
+ return acct;
+}
diff --git a/skypeweb/skypeweb_util.h b/skypeweb/skypeweb_util.h
index 2c36d35..0d97bb7 100644
--- a/skypeweb/skypeweb_util.h
+++ b/skypeweb/skypeweb_util.h
@@ -9,4 +9,6 @@ const gchar *skypeweb_thread_url_to_name(const gchar *url);
gchar *skypeweb_hmac_sha256(gchar *input);
-gint64 skypeweb_get_js_time(); \ No newline at end of file
+gint64 skypeweb_get_js_time();
+
+PurpleAccount *find_acct(const char *prpl, const char *acct_id); \ No newline at end of file