mirror of
https://github.com/profanity-im/profanity.git
synced 2024-09-01 19:24:15 -04:00
Merge /invite, /invites and /decline commands
`/invite <contact>` became `/invite send <contact>. `/invites` became `/invite list`. `/decline` became `/invite decline`. Accept is still done via `/join`. Regards https://github.com/profanity-im/profanity/issues/1116
This commit is contained in:
parent
40dc5932f7
commit
c1a9736232
@ -108,6 +108,7 @@ static char* _presence_autocomplete(ProfWin *window, const char *const input, gb
|
||||
static char* _rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _statusbar_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _clear_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _invite_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
|
||||
static char* _script_autocomplete_func(const char *const prefix, gboolean previous);
|
||||
|
||||
@ -222,6 +223,7 @@ static Autocomplete statusbar_chat_ac;
|
||||
static Autocomplete statusbar_room_ac;
|
||||
static Autocomplete statusbar_show_ac;
|
||||
static Autocomplete clear_ac;
|
||||
static Autocomplete invite_ac;
|
||||
|
||||
void
|
||||
cmd_ac_init(void)
|
||||
@ -858,6 +860,11 @@ cmd_ac_init(void)
|
||||
autocomplete_add(statusbar_ac, "chat");
|
||||
autocomplete_add(statusbar_ac, "room");
|
||||
|
||||
invite_ac = autocomplete_new();
|
||||
autocomplete_add(invite_ac, "send");
|
||||
autocomplete_add(invite_ac, "list");
|
||||
autocomplete_add(invite_ac, "decline");
|
||||
|
||||
statusbar_self_ac = autocomplete_new();
|
||||
autocomplete_add(statusbar_self_ac, "user");
|
||||
autocomplete_add(statusbar_self_ac, "barejid");
|
||||
@ -1173,6 +1180,7 @@ cmd_ac_reset(ProfWin *window)
|
||||
autocomplete_reset(statusbar_room_ac);
|
||||
autocomplete_reset(statusbar_show_ac);
|
||||
autocomplete_reset(clear_ac);
|
||||
autocomplete_reset(invite_ac);
|
||||
|
||||
autocomplete_reset(script_ac);
|
||||
if (script_show_ac) {
|
||||
@ -1313,6 +1321,7 @@ cmd_ac_uninit(void)
|
||||
autocomplete_free(statusbar_room_ac);
|
||||
autocomplete_free(statusbar_show_ac);
|
||||
autocomplete_free(clear_ac);
|
||||
autocomplete_free(invite_ac);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1495,14 +1504,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ
|
||||
}
|
||||
}
|
||||
|
||||
if (conn_status == JABBER_CONNECTED) {
|
||||
result = autocomplete_param_with_func(input, "/invite", roster_contact_autocomplete, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
gchar *invite_choices[] = { "/decline", "/join" };
|
||||
gchar *invite_choices[] = { "/join" };
|
||||
for (i = 0; i < ARRAY_SIZE(invite_choices); i++) {
|
||||
result = autocomplete_param_with_func(input, invite_choices[i], muc_invites_find, previous);
|
||||
if (result) {
|
||||
@ -1566,6 +1568,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ
|
||||
g_hash_table_insert(ac_funcs, "/rooms", _rooms_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/statusbar", _statusbar_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/clear", _clear_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/invite", _invite_autocomplete);
|
||||
|
||||
int len = strlen(input);
|
||||
char parsed[len+1];
|
||||
@ -3477,3 +3480,30 @@ _clear_autocomplete(ProfWin *window, const char *const input, gboolean previous)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char*
|
||||
_invite_autocomplete(ProfWin *window, const char *const input, gboolean previous)
|
||||
{
|
||||
char *result = NULL;
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/invite", invite_ac, TRUE, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
jabber_conn_status_t conn_status = connection_get_status();
|
||||
|
||||
if (conn_status == JABBER_CONNECTED) {
|
||||
result = autocomplete_param_with_func(input, "/invite send", roster_contact_autocomplete, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_func(input, "/invite decline", muc_invites_find, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -577,48 +577,28 @@ static struct cmd_t command_defs[] =
|
||||
},
|
||||
|
||||
{ "/invite",
|
||||
parse_args_with_freetext, 1, 2, NULL,
|
||||
parse_args_with_freetext, 1, 3, NULL,
|
||||
CMD_NOSUBFUNCS
|
||||
CMD_MAINFUNC(cmd_invite)
|
||||
CMD_TAGS(
|
||||
CMD_TAG_GROUPCHAT)
|
||||
CMD_SYN(
|
||||
"/invite <contact> [<message>]")
|
||||
"/invite send <contact> [<message>]",
|
||||
"/invite list",
|
||||
"/invite decline")
|
||||
CMD_DESC(
|
||||
"Send an invite to a contact for the current chat room.")
|
||||
"Manage room invites. "
|
||||
"Send an invite to a contact for the current chat room. "
|
||||
"List received invites. "
|
||||
"Decline them using /invite decline and accept them using /join.")
|
||||
CMD_ARGS(
|
||||
{ "<contact>", "The contact you wish to invite." },
|
||||
{ "<message>", "An optional message to send with the invite." })
|
||||
CMD_NOEXAMPLES
|
||||
},
|
||||
|
||||
{ "/invites",
|
||||
parse_args_with_freetext, 0, 0, NULL,
|
||||
CMD_NOSUBFUNCS
|
||||
CMD_MAINFUNC(cmd_invites)
|
||||
CMD_TAGS(
|
||||
CMD_TAG_GROUPCHAT)
|
||||
CMD_SYN(
|
||||
"/invites")
|
||||
CMD_DESC(
|
||||
"Show all rooms that you have been invited to, and not accepted or declined.")
|
||||
CMD_NOARGS
|
||||
CMD_NOEXAMPLES
|
||||
},
|
||||
|
||||
{ "/decline",
|
||||
parse_args_with_freetext, 1, 1, NULL,
|
||||
CMD_NOSUBFUNCS
|
||||
CMD_MAINFUNC(cmd_decline)
|
||||
CMD_TAGS(
|
||||
CMD_TAG_GROUPCHAT)
|
||||
CMD_SYN(
|
||||
"/decline <room>")
|
||||
CMD_DESC(
|
||||
"Decline a chat room invitation.")
|
||||
CMD_ARGS(
|
||||
{ "<room>", "The room for the invite you wish to decline." })
|
||||
CMD_NOEXAMPLES
|
||||
{ "send <contact> [<message>]", "The contact you wish to invite. And an optional message." },
|
||||
{ "list", "Show all rooms that you have been invited to, and not accepted or declined."},
|
||||
{ "decline <room>", "Decline a chat room invitation."})
|
||||
CMD_EXAMPLES(
|
||||
"/invite send gustavo@pollos.tx",
|
||||
"/invite decline profanity@rooms.dismail.de"
|
||||
"/invite list")
|
||||
},
|
||||
|
||||
{ "/room",
|
||||
|
@ -3660,8 +3660,6 @@ cmd_join(ProfWin *window, const char *const command, gchar **args)
|
||||
gboolean
|
||||
cmd_invite(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
char *contact = args[0];
|
||||
char *reason = args[1];
|
||||
jabber_conn_status_t conn_status = connection_get_status();
|
||||
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
@ -3669,6 +3667,10 @@ cmd_invite(ProfWin *window, const char *const command, gchar **args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (g_strcmp0(args[0], "send") == 0) {
|
||||
char *contact = args[1];
|
||||
char *reason = args[2];
|
||||
|
||||
if (window->type != WIN_MUC) {
|
||||
cons_show("You must be in a chat room to send an invite.");
|
||||
return TRUE;
|
||||
@ -3689,27 +3691,17 @@ cmd_invite(ProfWin *window, const char *const command, gchar **args)
|
||||
cons_show("Room invite sent, contact: %s, room: %s.",
|
||||
contact, mucwin->roomjid);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_invites(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
} else if (g_strcmp0(args[0], "list") == 0) {
|
||||
GList *invites = muc_invites();
|
||||
cons_show_room_invites(invites);
|
||||
g_list_free_full(invites, g_free);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_decline(ProfWin *window, const char *const command, gchar **args)
|
||||
{
|
||||
if (!muc_invites_contain(args[0])) {
|
||||
} else if (g_strcmp0(args[0], "decline") == 0) {
|
||||
if (!muc_invites_contain(args[1])) {
|
||||
cons_show("No such invite exists.");
|
||||
} else {
|
||||
muc_invites_remove(args[0]);
|
||||
cons_show("Declined invite to %s.", args[0]);
|
||||
muc_invites_remove(args[1]);
|
||||
cons_show("Declined invite to %s.", args[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -86,7 +86,6 @@ gboolean cmd_chlog(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_clear(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_close(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_connect(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_decline(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_disco(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_sendfile(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_lastactivity(ProfWin *window, const char *const command, gchar **args);
|
||||
@ -104,7 +103,6 @@ gboolean cmd_receipts(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_info(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_intype(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_invite(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_invites(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_join(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_leave(ProfWin *window, const char *const command, gchar **args);
|
||||
gboolean cmd_log(ProfWin *window, const char *const command, gchar **args);
|
||||
|
@ -830,7 +830,7 @@ cons_show_room_invite(const char *const invitor, const char * const room, const
|
||||
}
|
||||
|
||||
cons_show("Use '/join %s' to accept the invitation", room);
|
||||
cons_show("Use '/decline %s' to decline the invitation", room);
|
||||
cons_show("Use '/invite decline %s' to decline the invitation", room);
|
||||
|
||||
if (prefs_get_boolean(PREF_NOTIFY_INVITE)) {
|
||||
notify_invite(display_from, room, reason);
|
||||
|
Loading…
Reference in New Issue
Block a user