put invite messages to profile buffer if there is no friend buffer opened

This commit is contained in:
Gordon Quad 2016-12-05 01:59:18 +00:00
parent 44c24bdd38
commit f91b117996

View File

@ -211,7 +211,7 @@ twc_friend_request_callback(Tox *tox, const uint8_t *public_key,
if (rc == -1) if (rc == -1)
{ {
weechat_printf_date_tags(profile->buffer, 0, "notify_private", weechat_printf_date_tags(profile->buffer, 0, "notify_highlight",
"%sReceived a friend request, but your friend request list is full!", "%sReceived a friend request, but your friend request list is full!",
weechat_prefix("warning")); weechat_prefix("warning"));
} }
@ -220,7 +220,7 @@ twc_friend_request_callback(Tox *tox, const uint8_t *public_key,
char hex_address[TOX_PUBLIC_KEY_SIZE * 2 + 1]; char hex_address[TOX_PUBLIC_KEY_SIZE * 2 + 1];
twc_bin2hex(public_key, TOX_PUBLIC_KEY_SIZE, hex_address); twc_bin2hex(public_key, TOX_PUBLIC_KEY_SIZE, hex_address);
weechat_printf_date_tags(profile->buffer, 0, "notify_private", weechat_printf_date_tags(profile->buffer, 0, "notify_highlight",
"%sReceived a friend request from %s with message \"%s\"; " "%sReceived a friend request from %s with message \"%s\"; "
"accept it with \"/friend accept %d\"", "accept it with \"/friend accept %d\"",
weechat_prefix("network"), weechat_prefix("network"),
@ -228,7 +228,7 @@ twc_friend_request_callback(Tox *tox, const uint8_t *public_key,
if (rc == -2) if (rc == -2)
{ {
weechat_printf_date_tags(profile->buffer, 0, "notify_private", weechat_printf_date_tags(profile->buffer, 0, "notify_highlight",
"%sFailed to save friend request, try manually " "%sFailed to save friend request, try manually "
"accepting with /friend add", "accepting with /friend add",
weechat_prefix("error")); weechat_prefix("error"));
@ -247,8 +247,9 @@ twc_group_invite_callback(Tox *tox,
struct t_twc_profile *profile = data; struct t_twc_profile *profile = data;
char *friend_name = twc_get_name_nt(profile->tox, friend_number); char *friend_name = twc_get_name_nt(profile->tox, friend_number);
struct t_twc_chat *friend_chat struct t_twc_chat *friend_chat
= twc_chat_search_friend(profile, friend_number, true); = twc_chat_search_friend(profile, friend_number, false);
int64_t rc; int64_t rc;
char *tags;
char *type_str; char *type_str;
switch (type) switch (type)
@ -283,20 +284,41 @@ twc_group_invite_callback(Tox *tox,
if (rc >= 0) if (rc >= 0)
{ {
weechat_printf(friend_chat->buffer, tags = "notify_private";
"%sWe joined the %s%s%s's invite to %s.", if (friend_chat)
weechat_prefix("network"), {
weechat_color("chat_nick_other"), friend_name, weechat_printf_date_tags(friend_chat->buffer, 0, tags,
weechat_color("reset"), type_str, rc); "%sWe joined the %s%s%s's invite to %s.",
weechat_prefix("network"),
weechat_color("chat_nick_other"), friend_name,
weechat_color("reset"), type_str);
tags = "";
}
weechat_printf_date_tags(profile->buffer, 0, tags,
"%sWe joined the %s%s%s's invite to %s.",
weechat_prefix("network"),
weechat_color("chat_nick_other"), friend_name,
weechat_color("reset"), type_str);
} }
else else
{ {
weechat_printf(friend_chat->buffer, tags = "notify_highlight";
"%s%s%s%s invites you to join %s, but we failed to " if (friend_chat)
"process the invite. Please try again.", {
weechat_prefix("network"), weechat_printf_date_tags(friend_chat->buffer, 0, tags,
weechat_color("chat_nick_other"), friend_name, "%s%s%s%s invites you to join %s, but we failed to "
weechat_color("reset"), rc); "process the invite. Please try again.",
weechat_prefix("network"),
weechat_color("chat_nick_other"), friend_name,
weechat_color("reset"));
tags = "";
}
weechat_printf_date_tags(profile->buffer, 0, tags,
"%s%s%s%s invites you to join %s, but we failed to "
"process the invite. Please try again.",
weechat_prefix("network"),
weechat_color("chat_nick_other"), friend_name,
weechat_color("reset"));
} }
} }
else else
@ -306,21 +328,43 @@ twc_group_invite_callback(Tox *tox,
if (rc >= 0) if (rc >= 0)
{ {
weechat_printf(friend_chat->buffer, tags = "notify_highlight";
"%s%s%s%s invites you to join %s. Type " if (friend_chat)
"\"/group join %d\" to accept.", {
weechat_prefix("network"), weechat_printf_date_tags(friend_chat->buffer, 0, tags,
weechat_color("chat_nick_other"), friend_name, "%s%s%s%s invites you to join %s. Type "
weechat_color("reset"), type_str, rc); "\"/group join %d\" to accept.",
weechat_prefix("network"),
weechat_color("chat_nick_other"), friend_name,
weechat_color("reset"), type_str, rc);
tags = "";
}
weechat_printf_date_tags(profile->buffer, 0, tags,
"%s%s%s%s invites you to join %s. Type "
"\"/group join %d\" to accept.",
weechat_prefix("network"),
weechat_color("chat_nick_other"), friend_name,
weechat_color("reset"), type_str, rc);
} }
else else
{ {
weechat_printf(friend_chat->buffer, tags = "notify_highlight";
"%s%s%s%s invites you to join %s, but we failed to " if (friend_chat)
"process the invite. Please try again.", {
weechat_prefix("network"), weechat_printf_date_tags(friend_chat->buffer, 0, tags,
weechat_color("chat_nick_other"), friend_name, "%s%s%s%s invites you to join %s, but we failed to "
weechat_color("reset"), rc); "process the invite. Please try again.",
weechat_prefix("network"),
weechat_color("chat_nick_other"), friend_name,
weechat_color("reset"), rc);
tags = "";
}
weechat_printf_date_tags(profile->buffer, 0, tags,
"%s%s%s%s invites you to join %s, but we failed to "
"process the invite. Please try again.",
weechat_prefix("network"),
weechat_color("chat_nick_other"), friend_name,
weechat_color("reset"), rc);
} }
} }
free(friend_name); free(friend_name);