Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show system message when call received #525

Merged
merged 2 commits into from
Feb 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 51 additions & 31 deletions skypeweb/skypeweb_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,45 +437,65 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource)
(void) incoming;
from = convbuddyname;
}
if (partlisttype && from != NULL) {
imconv = purple_conversations_find_im_with_account(from, sa->account);
if (imconv == NULL)
{
imconv = purple_im_conversation_new(sa->account, from);
}

conv = PURPLE_CONVERSATION(imconv);
if (g_str_equal(partlisttype, "started")) {
message = _("Call started");
} else if (g_str_equal(partlisttype, "ended")) {
PurpleXmlNode *part;
gint duration_int = -1;

for(part = purple_xmlnode_get_child(partlist, "part");
part;
part = purple_xmlnode_get_next_twin(part))

if (from != NULL) {
if (partlisttype) {
imconv = purple_conversations_find_im_with_account(from, sa->account);
if (imconv == NULL)
{
const gchar *identity = purple_xmlnode_get_attrib(part, "identity");
if (identity && skypeweb_is_user_self(sa, identity)) {
PurpleXmlNode *duration = purple_xmlnode_get_child(part, "duration");
if (duration != NULL) {
gchar *duration_str;
duration_str = purple_xmlnode_get_data(duration);
duration_int = atoi(duration_str);
break;
imconv = purple_im_conversation_new(sa->account, from);
}

conv = PURPLE_CONVERSATION(imconv);
if (g_str_equal(partlisttype, "started")) {
message = _("Call started");
} else if (g_str_equal(partlisttype, "ended")) {
PurpleXmlNode *part;
gint duration_int = -1;

for(part = purple_xmlnode_get_child(partlist, "part");
part;
part = purple_xmlnode_get_next_twin(part))
{
const gchar *identity = purple_xmlnode_get_attrib(part, "identity");
if (identity && skypeweb_is_user_self(sa, identity)) {
PurpleXmlNode *duration = purple_xmlnode_get_child(part, "duration");
if (duration != NULL) {
gchar *duration_str;
duration_str = purple_xmlnode_get_data(duration);
duration_int = atoi(duration_str);
break;
}
}
}
}
if (duration_int < 0) {
message = _("Call missed");
} else {
//TODO report how long the call was
message = _("Call ended");
if (duration_int < 0) {
message = _("Call missed");
} else {
//TODO report how long the call was
message = _("Call ended");
}
}
}
else {
message = _("Unsupported call received");
}

purple_serv_got_im(sa->pc, from, message, PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM, composetimestamp);
}

purple_xmlnode_free(partlist);
} else if (g_str_equal(messagetype, "Signal/Flamingo")) {
const gchar *message = NULL;

if (skypeweb_is_user_self(sa, from)) {
from = convbuddyname;
}

if (from != NULL) {
message = _("Unsupported call received");

purple_serv_got_im(sa->pc, from, message, PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM, composetimestamp);
}
} else if (g_str_equal(messagetype, "RichText/Files")) {
purple_serv_got_im(sa->pc, convbuddyname, _("The user sent files in an unsupported way"), PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_ERROR, composetimestamp);
} else {
Expand Down