mirror of
https://github.com/profanity-im/profanity.git
synced 2024-10-27 20:30:13 -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* _rooms_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||||
static char* _statusbar_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* _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);
|
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_room_ac;
|
||||||
static Autocomplete statusbar_show_ac;
|
static Autocomplete statusbar_show_ac;
|
||||||
static Autocomplete clear_ac;
|
static Autocomplete clear_ac;
|
||||||
|
static Autocomplete invite_ac;
|
||||||
|
|
||||||
void
|
void
|
||||||
cmd_ac_init(void)
|
cmd_ac_init(void)
|
||||||
@ -858,6 +860,11 @@ cmd_ac_init(void)
|
|||||||
autocomplete_add(statusbar_ac, "chat");
|
autocomplete_add(statusbar_ac, "chat");
|
||||||
autocomplete_add(statusbar_ac, "room");
|
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();
|
statusbar_self_ac = autocomplete_new();
|
||||||
autocomplete_add(statusbar_self_ac, "user");
|
autocomplete_add(statusbar_self_ac, "user");
|
||||||
autocomplete_add(statusbar_self_ac, "barejid");
|
autocomplete_add(statusbar_self_ac, "barejid");
|
||||||
@ -1173,6 +1180,7 @@ cmd_ac_reset(ProfWin *window)
|
|||||||
autocomplete_reset(statusbar_room_ac);
|
autocomplete_reset(statusbar_room_ac);
|
||||||
autocomplete_reset(statusbar_show_ac);
|
autocomplete_reset(statusbar_show_ac);
|
||||||
autocomplete_reset(clear_ac);
|
autocomplete_reset(clear_ac);
|
||||||
|
autocomplete_reset(invite_ac);
|
||||||
|
|
||||||
autocomplete_reset(script_ac);
|
autocomplete_reset(script_ac);
|
||||||
if (script_show_ac) {
|
if (script_show_ac) {
|
||||||
@ -1313,6 +1321,7 @@ cmd_ac_uninit(void)
|
|||||||
autocomplete_free(statusbar_room_ac);
|
autocomplete_free(statusbar_room_ac);
|
||||||
autocomplete_free(statusbar_show_ac);
|
autocomplete_free(statusbar_show_ac);
|
||||||
autocomplete_free(clear_ac);
|
autocomplete_free(clear_ac);
|
||||||
|
autocomplete_free(invite_ac);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1495,14 +1504,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn_status == JABBER_CONNECTED) {
|
gchar *invite_choices[] = { "/join" };
|
||||||
result = autocomplete_param_with_func(input, "/invite", roster_contact_autocomplete, previous);
|
|
||||||
if (result) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *invite_choices[] = { "/decline", "/join" };
|
|
||||||
for (i = 0; i < ARRAY_SIZE(invite_choices); i++) {
|
for (i = 0; i < ARRAY_SIZE(invite_choices); i++) {
|
||||||
result = autocomplete_param_with_func(input, invite_choices[i], muc_invites_find, previous);
|
result = autocomplete_param_with_func(input, invite_choices[i], muc_invites_find, previous);
|
||||||
if (result) {
|
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, "/rooms", _rooms_autocomplete);
|
||||||
g_hash_table_insert(ac_funcs, "/statusbar", _statusbar_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, "/clear", _clear_autocomplete);
|
||||||
|
g_hash_table_insert(ac_funcs, "/invite", _invite_autocomplete);
|
||||||
|
|
||||||
int len = strlen(input);
|
int len = strlen(input);
|
||||||
char parsed[len+1];
|
char parsed[len+1];
|
||||||
@ -3477,3 +3480,30 @@ _clear_autocomplete(ProfWin *window, const char *const input, gboolean previous)
|
|||||||
|
|
||||||
return NULL;
|
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",
|
{ "/invite",
|
||||||
parse_args_with_freetext, 1, 2, NULL,
|
parse_args_with_freetext, 1, 3, NULL,
|
||||||
CMD_NOSUBFUNCS
|
CMD_NOSUBFUNCS
|
||||||
CMD_MAINFUNC(cmd_invite)
|
CMD_MAINFUNC(cmd_invite)
|
||||||
CMD_TAGS(
|
CMD_TAGS(
|
||||||
CMD_TAG_GROUPCHAT)
|
CMD_TAG_GROUPCHAT)
|
||||||
CMD_SYN(
|
CMD_SYN(
|
||||||
"/invite <contact> [<message>]")
|
"/invite send <contact> [<message>]",
|
||||||
|
"/invite list",
|
||||||
|
"/invite decline")
|
||||||
CMD_DESC(
|
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(
|
CMD_ARGS(
|
||||||
{ "<contact>", "The contact you wish to invite." },
|
{ "send <contact> [<message>]", "The contact you wish to invite. And an optional message." },
|
||||||
{ "<message>", "An optional message to send with the invite." })
|
{ "list", "Show all rooms that you have been invited to, and not accepted or declined."},
|
||||||
CMD_NOEXAMPLES
|
{ "decline <room>", "Decline a chat room invitation."})
|
||||||
},
|
CMD_EXAMPLES(
|
||||||
|
"/invite send gustavo@pollos.tx",
|
||||||
{ "/invites",
|
"/invite decline profanity@rooms.dismail.de"
|
||||||
parse_args_with_freetext, 0, 0, NULL,
|
"/invite list")
|
||||||
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
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{ "/room",
|
{ "/room",
|
||||||
|
@ -3660,8 +3660,6 @@ cmd_join(ProfWin *window, const char *const command, gchar **args)
|
|||||||
gboolean
|
gboolean
|
||||||
cmd_invite(ProfWin *window, const char *const command, gchar **args)
|
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();
|
jabber_conn_status_t conn_status = connection_get_status();
|
||||||
|
|
||||||
if (conn_status != JABBER_CONNECTED) {
|
if (conn_status != JABBER_CONNECTED) {
|
||||||
@ -3669,47 +3667,41 @@ cmd_invite(ProfWin *window, const char *const command, gchar **args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->type != WIN_MUC) {
|
if (g_strcmp0(args[0], "send") == 0) {
|
||||||
cons_show("You must be in a chat room to send an invite.");
|
char *contact = args[1];
|
||||||
return TRUE;
|
char *reason = args[2];
|
||||||
}
|
|
||||||
|
|
||||||
char *usr_jid = roster_barejid_from_name(contact);
|
if (window->type != WIN_MUC) {
|
||||||
if (usr_jid == NULL) {
|
cons_show("You must be in a chat room to send an invite.");
|
||||||
usr_jid = contact;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfMucWin *mucwin = (ProfMucWin*)window;
|
char *usr_jid = roster_barejid_from_name(contact);
|
||||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
if (usr_jid == NULL) {
|
||||||
message_send_invite(mucwin->roomjid, usr_jid, reason);
|
usr_jid = contact;
|
||||||
if (reason) {
|
}
|
||||||
cons_show("Room invite sent, contact: %s, room: %s, reason: \"%s\".",
|
|
||||||
contact, mucwin->roomjid, reason);
|
|
||||||
} else {
|
|
||||||
cons_show("Room invite sent, contact: %s, room: %s.",
|
|
||||||
contact, mucwin->roomjid);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
ProfMucWin *mucwin = (ProfMucWin*)window;
|
||||||
}
|
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||||
|
message_send_invite(mucwin->roomjid, usr_jid, reason);
|
||||||
gboolean
|
if (reason) {
|
||||||
cmd_invites(ProfWin *window, const char *const command, gchar **args)
|
cons_show("Room invite sent, contact: %s, room: %s, reason: \"%s\".",
|
||||||
{
|
contact, mucwin->roomjid, reason);
|
||||||
GList *invites = muc_invites();
|
} else {
|
||||||
cons_show_room_invites(invites);
|
cons_show("Room invite sent, contact: %s, room: %s.",
|
||||||
g_list_free_full(invites, g_free);
|
contact, mucwin->roomjid);
|
||||||
return TRUE;
|
}
|
||||||
}
|
} else if (g_strcmp0(args[0], "list") == 0) {
|
||||||
|
GList *invites = muc_invites();
|
||||||
gboolean
|
cons_show_room_invites(invites);
|
||||||
cmd_decline(ProfWin *window, const char *const command, gchar **args)
|
g_list_free_full(invites, g_free);
|
||||||
{
|
} else if (g_strcmp0(args[0], "decline") == 0) {
|
||||||
if (!muc_invites_contain(args[0])) {
|
if (!muc_invites_contain(args[1])) {
|
||||||
cons_show("No such invite exists.");
|
cons_show("No such invite exists.");
|
||||||
} else {
|
} else {
|
||||||
muc_invites_remove(args[0]);
|
muc_invites_remove(args[1]);
|
||||||
cons_show("Declined invite to %s.", args[0]);
|
cons_show("Declined invite to %s.", args[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
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_clear(ProfWin *window, const char *const command, gchar **args);
|
||||||
gboolean cmd_close(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_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_disco(ProfWin *window, const char *const command, gchar **args);
|
||||||
gboolean cmd_sendfile(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);
|
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_info(ProfWin *window, const char *const command, gchar **args);
|
||||||
gboolean cmd_intype(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_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_join(ProfWin *window, const char *const command, gchar **args);
|
||||||
gboolean cmd_leave(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);
|
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 '/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)) {
|
if (prefs_get_boolean(PREF_NOTIFY_INVITE)) {
|
||||||
notify_invite(display_from, room, reason);
|
notify_invite(display_from, room, reason);
|
||||||
|
Loading…
Reference in New Issue
Block a user