aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/skype/skype.c
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-10-13 02:05:22 -0300
committerdequis <dx@dxzone.com.ar>2015-10-13 02:05:22 -0300
commit64bed24b810fa3c44d23132b2aa8792fc78ffe77 (patch)
treeffc3b30753048432c754a672e6ef46333e86d0e9 /protocols/skype/skype.c
parentfdc6d84a32e87c3486ac99b7aee282153d65b23e (diff)
skype: create groupchat as soon as a message is received
Before this commit, the bee_chat_by_title() call just failed when receiving a message in a groupchat we didn't know about, which is probably something skype broke in their api at some point. I'm fixing this since apparently the only way to access p2p based chats is through the official skype desktop client (they won't be supported through msnp24 or skypeweb. It's broken in mobile clients already), so this plugin is probably the best way to access those. This breaks the 'msg' test - now all chats are groupchats and there's no way to tell them apart. However, in reality, private messages aren't delivered at all over the api, or at least I never managed to get them working. Probably if you talk with someone who has a very old patched skype client.
Diffstat (limited to 'protocols/skype/skype.c')
-rw-r--r--protocols/skype/skype.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/protocols/skype/skype.c b/protocols/skype/skype.c
index ade5b8c6..a21af8ef 100644
--- a/protocols/skype/skype.c
+++ b/protocols/skype/skype.c
@@ -322,6 +322,24 @@ static struct skype_group *skype_group_by_name(struct im_connection *ic, char *n
return NULL;
}
+static struct groupchat *skype_chat_get_or_create(struct im_connection *ic, char *id)
+{
+ struct skype_data *sd = ic->proto_data;
+ struct groupchat *gc = bee_chat_by_title(ic->bee, ic, id);
+
+ if (!gc) {
+ gc = imcb_chat_new(ic, id);
+ imcb_chat_name_hint(gc, id);
+ imcb_chat_add_buddy(gc, sd->username);
+
+ skype_printf(ic, "GET CHAT %s ADDER\n", id);
+ skype_printf(ic, "GET CHAT %s TOPIC\n", id);
+ skype_printf(ic, "GET CHAT %s ACTIVEMEMBERS\n", id);
+ }
+
+ return gc;
+}
+
static void skype_parse_users(struct im_connection *ic, char *line)
{
char **i, **nicks;
@@ -686,7 +704,7 @@ static void skype_parse_chatmessage(struct im_connection *ic, char *line)
} else if (!strncmp(info, "CHATNAME ", 9)) {
info += 9;
if (sd->handle && sd->body && sd->type) {
- struct groupchat *gc = bee_chat_by_title(ic->bee, ic, info);
+ struct groupchat *gc = skype_chat_get_or_create(ic, info);
int i;
for (i = 0; i < g_list_length(sd->body); i++) {
char *body = g_list_nth_data(sd->body, i);
@@ -1024,16 +1042,9 @@ static void skype_parse_chat(struct im_connection *ic, char *line)
imcb_chat_free(gc);
}
if (!strcmp(info, "STATUS MULTI_SUBSCRIBED")) {
- gc = bee_chat_by_title(ic->bee, ic, id);
- if (!gc) {
- gc = imcb_chat_new(ic, id);
- imcb_chat_name_hint(gc, id);
- }
- skype_printf(ic, "GET CHAT %s ADDER\n", id);
- skype_printf(ic, "GET CHAT %s TOPIC\n", id);
+ skype_chat_get_or_create(ic, id);
} else if (!strcmp(info, "STATUS DIALOG") && sd->groupchat_with) {
- gc = imcb_chat_new(ic, id);
- imcb_chat_name_hint(gc, id);
+ gc = skype_chat_get_or_create(ic, id);
/* According to the docs this
* is necessary. However it
* does not seem the situation
@@ -1044,11 +1055,8 @@ static void skype_parse_chat(struct im_connection *ic, char *line)
g_snprintf(buf, IRC_LINE_SIZE, "%s@skype.com",
sd->groupchat_with);
imcb_chat_add_buddy(gc, buf);
- imcb_chat_add_buddy(gc, sd->username);
g_free(sd->groupchat_with);
sd->groupchat_with = NULL;
- skype_printf(ic, "GET CHAT %s ADDER\n", id);
- skype_printf(ic, "GET CHAT %s TOPIC\n", id);
} else if (!strcmp(info, "STATUS UNSUBSCRIBED")) {
gc = bee_chat_by_title(ic->bee, ic, id);
if (gc) {