mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge /group command into /roster
Fix https://github.com/profanity-im/profanity/issues/1229 Regards https://github.com/profanity-im/profanity/issues/1116
This commit is contained in:
parent
548b64f6c5
commit
f0a719d1e1
@ -71,7 +71,6 @@ static char* _autoconnect_autocomplete(ProfWin *window, const char *const input,
|
||||
static char* _account_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _who_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _roster_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _group_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _bookmark_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _otr_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
static char* _pgp_autocomplete(ProfWin *window, const char *const input, gboolean previous);
|
||||
@ -441,6 +440,7 @@ cmd_ac_init(void)
|
||||
autocomplete_add(roster_ac, "resource");
|
||||
autocomplete_add(roster_ac, "presence");
|
||||
autocomplete_add(roster_ac, "private");
|
||||
autocomplete_add(roster_ac, "group");
|
||||
|
||||
roster_private_ac = autocomplete_new();
|
||||
autocomplete_add(roster_private_ac, "room");
|
||||
@ -1559,7 +1559,6 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ
|
||||
g_hash_table_insert(ac_funcs, "/log", _log_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/account", _account_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/roster", _roster_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/group", _group_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/bookmark", _bookmark_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/autoconnect", _autoconnect_autocomplete);
|
||||
g_hash_table_insert(ac_funcs, "/otr", _otr_autocomplete);
|
||||
@ -1788,6 +1787,27 @@ _roster_autocomplete(ProfWin *window, const char *const input, gboolean previous
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_func(input, "/roster group show", roster_group_autocomplete, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = autocomplete_param_no_with_func(input, "/roster group add", 5, roster_contact_autocomplete, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = autocomplete_param_no_with_func(input, "/roster group remove", 5, roster_contact_autocomplete, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = autocomplete_param_with_func(input, "/roster group add", roster_group_autocomplete, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = autocomplete_param_with_func(input, "/roster group remove", roster_group_autocomplete, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/roster remove_all", roster_remove_all_ac, TRUE, previous);
|
||||
@ -1846,6 +1866,10 @@ _roster_autocomplete(ProfWin *window, const char *const input, gboolean previous
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = autocomplete_param_with_ac(input, "/roster group", group_ac, TRUE, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = autocomplete_param_with_ac(input, "/roster", roster_ac, TRUE, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
@ -1854,44 +1878,6 @@ _roster_autocomplete(ProfWin *window, const char *const input, gboolean previous
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char*
|
||||
_group_autocomplete(ProfWin *window, const char *const input, gboolean previous)
|
||||
{
|
||||
char *result = NULL;
|
||||
|
||||
jabber_conn_status_t conn_status = connection_get_status();
|
||||
|
||||
if (conn_status == JABBER_CONNECTED) {
|
||||
result = autocomplete_param_with_func(input, "/group show", roster_group_autocomplete, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = autocomplete_param_no_with_func(input, "/group add", 4, roster_contact_autocomplete, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = autocomplete_param_no_with_func(input, "/group remove", 4, roster_contact_autocomplete, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = autocomplete_param_with_func(input, "/group add", roster_group_autocomplete, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
result = autocomplete_param_with_func(input, "/group remove", roster_group_autocomplete, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
result = autocomplete_param_with_ac(input, "/group", group_ac, TRUE, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char*
|
||||
_blocked_autocomplete(ProfWin *window, const char *const input, gboolean previous)
|
||||
{
|
||||
|
@ -266,7 +266,8 @@ static struct cmd_t command_defs[] =
|
||||
|
||||
{ "/roster",
|
||||
parse_args_with_freetext, 0, 4, NULL,
|
||||
CMD_NOSUBFUNCS
|
||||
CMD_SUBFUNCS(
|
||||
{ "group", cmd_group })
|
||||
CMD_MAINFUNC(cmd_roster)
|
||||
CMD_TAGS(
|
||||
CMD_TAG_ROSTER,
|
||||
@ -304,7 +305,11 @@ static struct cmd_t command_defs[] =
|
||||
"/roster remove <jid>",
|
||||
"/roster remove_all contacts",
|
||||
"/roster nick <jid> <nick>",
|
||||
"/roster clearnick <jid>")
|
||||
"/roster clearnick <jid>",
|
||||
"/roster group",
|
||||
"/roster group show <group>",
|
||||
"/roster group add <group> <contat>",
|
||||
"/roster group remove <group> <contact>")
|
||||
CMD_DESC(
|
||||
"Manage your roster, and roster display settings. "
|
||||
"Passing no arguments lists all contacts in your roster.")
|
||||
@ -377,7 +382,10 @@ static struct cmd_t command_defs[] =
|
||||
{ "remove <jid>", "Removes an item from the roster." },
|
||||
{ "remove_all contacts", "Remove all items from roster." },
|
||||
{ "nick <jid> <nick>", "Change a contacts nickname." },
|
||||
{ "clearnick <jid>", "Removes the current nickname." })
|
||||
{ "clearnick <jid>", "Removes the current nickname." },
|
||||
{ "group show <group>", "List all roster items in a group." },
|
||||
{ "group add <group> <contact>", "Add a contact to a group." },
|
||||
{ "group remove <group> <contact>", "Remove a contact from a group." })
|
||||
CMD_EXAMPLES(
|
||||
"/roster",
|
||||
"/roster add someone@contacts.org",
|
||||
@ -385,7 +393,12 @@ static struct cmd_t command_defs[] =
|
||||
"/roster remove someone@contacts.org",
|
||||
"/roster nick myfriend@chat.org \"My Friend\"",
|
||||
"/roster clearnick kai@server.com",
|
||||
"/roster size 15")
|
||||
"/roster size 15",
|
||||
"/roster group",
|
||||
"/roster group show friends",
|
||||
"/roster group add friends newfriend@server.org",
|
||||
"/roster group add family Brother",
|
||||
"/roster group remove colleagues boss@work.com")
|
||||
},
|
||||
|
||||
{ "/blocked",
|
||||
@ -410,33 +423,6 @@ static struct cmd_t command_defs[] =
|
||||
"/blocked add profanity@rooms.dismail.de/spammy-user")
|
||||
},
|
||||
|
||||
{ "/group",
|
||||
parse_args_with_freetext, 0, 3, NULL,
|
||||
CMD_NOSUBFUNCS
|
||||
CMD_MAINFUNC(cmd_group)
|
||||
CMD_TAGS(
|
||||
CMD_TAG_ROSTER,
|
||||
CMD_TAG_UI)
|
||||
CMD_SYN(
|
||||
"/group",
|
||||
"/group show <group>",
|
||||
"/group add <group> <contat>",
|
||||
"/group remove <group> <contact>")
|
||||
CMD_DESC(
|
||||
"View, add to, and remove from roster groups. "
|
||||
"Passing no argument will list all roster groups.")
|
||||
CMD_ARGS(
|
||||
{ "show <group>", "List all roster items in a group." },
|
||||
{ "add <group> <contact>", "Add a contact to a group." },
|
||||
{ "remove <group> <contact>", "Remove a contact from a group." })
|
||||
CMD_EXAMPLES(
|
||||
"/group",
|
||||
"/group show friends",
|
||||
"/group add friends newfriend@server.org",
|
||||
"/group add family Brother",
|
||||
"/group remove colleagues boss@work.com")
|
||||
},
|
||||
|
||||
{ "/info",
|
||||
parse_args, 0, 1, NULL,
|
||||
CMD_NOSUBFUNCS
|
||||
|
@ -2230,7 +2230,7 @@ cmd_group(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
|
||||
// list all groups
|
||||
if (args[0] == NULL) {
|
||||
if (args[1] == NULL) {
|
||||
GList *groups = roster_get_groups();
|
||||
GList *curr = groups;
|
||||
if (curr) {
|
||||
@ -2248,8 +2248,8 @@ cmd_group(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
|
||||
// show contacts in group
|
||||
if (strcmp(args[0], "show") == 0) {
|
||||
char *group = args[1];
|
||||
if (strcmp(args[1], "show") == 0) {
|
||||
char *group = args[2];
|
||||
if (group == NULL) {
|
||||
cons_bad_cmd_usage(command);
|
||||
return TRUE;
|
||||
@ -2261,9 +2261,9 @@ cmd_group(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
|
||||
// add contact to group
|
||||
if (strcmp(args[0], "add") == 0) {
|
||||
char *group = args[1];
|
||||
char *contact = args[2];
|
||||
if (strcmp(args[1], "add") == 0) {
|
||||
char *group = args[2];
|
||||
char *contact = args[3];
|
||||
|
||||
if ((group == NULL) || (contact == NULL)) {
|
||||
cons_bad_cmd_usage(command);
|
||||
@ -2292,9 +2292,9 @@ cmd_group(ProfWin *window, const char *const command, gchar **args)
|
||||
}
|
||||
|
||||
// remove contact from group
|
||||
if (strcmp(args[0], "remove") == 0) {
|
||||
char *group = args[1];
|
||||
char *contact = args[2];
|
||||
if (strcmp(args[1], "remove") == 0) {
|
||||
char *group = args[2];
|
||||
char *contact = args[3];
|
||||
|
||||
if ((group == NULL) || (contact == NULL)) {
|
||||
cons_bad_cmd_usage(command);
|
||||
|
Loading…
Reference in New Issue
Block a user