Skip to content

Commit

Permalink
skype: create groupchat as soon as a message is received
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dequis committed Oct 13, 2015
1 parent fdc6d84 commit 64bed24
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 34 deletions.
34 changes: 21 additions & 13 deletions protocols/skype/skype.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion protocols/skype/t/groupchat-invite-bitlbee.mock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<< PRIVMSG &bitlbee :account skype on
>> :bob!bob@skype.com JOIN :&bitlbee
<< PRIVMSG &bitlbee :chat with bob
>> 353 alice = ##alice/$bob;a7ab206ec78 :@alice bob @root
>> 353 alice = ##alice/$bob;a7ab206ec78 :@alice @root
<< INVITE cecil ##alice/$bob;a7ab206ec78
>> cecil@skype.com JOIN :##alice/$bob;a7ab206ec78
2 changes: 2 additions & 0 deletions protocols/skype/t/groupchat-invite-skyped.mock
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<< CHAT #alice/$bob;a7ab206ec78060f1 NAME #alice/$bob;a7ab206ec78060f1
>> GET CHAT #alice/$bob;a7ab206ec78060f1 TOPIC
<< CHAT #alice/$bob;a7ab206ec78060f1 TOPIC
>> GET CHAT #alice/$bob;a7ab206ec78060f1 ACTIVEMEMBERS
<< CHAT #alice/$bob;a7ab206ec78060f1 ACTIVEMEMBERS
<< CHATMESSAGE 206 STATUS SENDING
<< CHAT #alice/$bob;a7ab206ec78060f1 STATUS DIALOG
<< CHATMEMBER 204 ROLE USER
Expand Down
2 changes: 1 addition & 1 deletion protocols/skype/t/groupchat-invited-bitlbee.mock
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
<< PRIVMSG &bitlbee :account add skype alice foo
<< PRIVMSG &bitlbee :account skype on
>> JOIN :##cecil/$bob;4d8cc996579
>> 353 alice = ##cecil/$bob;4d8cc996579 :@alice bob cecil @root
>> 353 alice = ##cecil/$bob;4d8cc996579 :@alice @root
2 changes: 1 addition & 1 deletion protocols/skype/t/groupchat-leave-bitlbee.mock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<< PRIVMSG &bitlbee :account skype set skypeconsole_receive true
<< PRIVMSG &bitlbee :account skype on
>> JOIN :##cecil/$bob;4d8cc996579
>> 353 alice = ##cecil/$bob;4d8cc996579 :@alice bob cecil @root
>> 353 alice = ##cecil/$bob;4d8cc996579 :@alice @root
<< PART ##cecil/$bob;4d8cc996579
>> PRIVMSG &bitlbee :alice: CHAT #cecil/$bob;4d8cc9965791c6b9 STATUS UNSUBSCRIBED
10 changes: 2 additions & 8 deletions protocols/skype/t/groupchat-leave-skyped.mock
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,8 @@
<< CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER bob
>> GET CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
>> GET CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER
<< CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER bob
>> GET CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
>> GET CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER
<< CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER bob
>> GET CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
>> GET CHAT #cecil/$bob;4d8cc9965791c6b9 ACTIVEMEMBERS
<< CHAT #cecil/$bob;4d8cc9965791c6b9 ACTIVEMEMBERS
>> GET CHATMESSAGE 188 FROM_HANDLE
<< CHATMESSAGE 188 FROM_HANDLE bob
>> GET CHATMESSAGE 188 BODY
Expand Down
2 changes: 1 addition & 1 deletion protocols/skype/t/groupchat-msg-bitlbee.mock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<< PRIVMSG &bitlbee :account skype set skypeconsole_receive true
<< PRIVMSG &bitlbee :account skype on
>> JOIN :##cecil/$bob;4d8cc996579
>> 353 alice = ##cecil/$bob;4d8cc996579 :@alice bob cecil @root
>> 353 alice = ##cecil/$bob;4d8cc996579 :@alice @root
<< PRIVMSG ##cecil/$bob;4d8cc996579 :hello
>> PRIVMSG &bitlbee :alice: CHAT #cecil/$bob;4d8cc9965791c6b9 ACTIVITY_TIMESTAMP
10 changes: 2 additions & 8 deletions protocols/skype/t/groupchat-msg-skyped.mock
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,8 @@
<< CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER bob
>> GET CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
>> GET CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER
<< CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER bob
>> GET CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
>> GET CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER
<< CHAT #cecil/$bob;4d8cc9965791c6b9 ADDER bob
>> GET CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
<< CHAT #cecil/$bob;4d8cc9965791c6b9 TOPIC
>> GET CHAT #cecil/$bob;4d8cc9965791c6b9 ACTIVEMEMBERS
<< CHAT #cecil/$bob;4d8cc9965791c6b9 ACTIVEMEMBERS bob cecil alice
>> GET CHATMESSAGE 188 FROM_HANDLE
<< CHATMESSAGE 188 FROM_HANDLE bob
>> GET CHATMESSAGE 188 BODY
Expand Down
2 changes: 1 addition & 1 deletion protocols/skype/t/groupchat-topic-bitlbee.mock
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<< PRIVMSG &bitlbee :account add skype alice foo
<< PRIVMSG &bitlbee :account skype on
>> JOIN :##cecil/$bob;4d8cc996579
>> 353 alice = ##cecil/$bob;4d8cc996579 :@alice bob cecil @root
>> 353 alice = ##cecil/$bob;4d8cc996579 :@alice @root
<< TOPIC ##cecil/$bob;4d8cc996579 :topic
>> TOPIC ##cecil/$bob;4d8cc996579 :topic

0 comments on commit 64bed24

Please sign in to comment.