mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Autocomplete "/sub allow" parameter from subscription requests
This commit is contained in:
parent
53eeb0ef45
commit
3d8d5214bb
@ -74,6 +74,7 @@ static gboolean _cmd_set_boolean_preference(gchar *arg, struct cmd_help_t help,
|
|||||||
const char * const display, preference_t pref);
|
const char * const display, preference_t pref);
|
||||||
|
|
||||||
static void _cmd_complete_parameters(char *input, int *size);
|
static void _cmd_complete_parameters(char *input, int *size);
|
||||||
|
static void _sub_autocomplete(char *input, int *size);
|
||||||
static void _notify_autocomplete(char *input, int *size);
|
static void _notify_autocomplete(char *input, int *size);
|
||||||
static void _titlebar_autocomplete(char *input, int *size);
|
static void _titlebar_autocomplete(char *input, int *size);
|
||||||
static void _theme_autocomplete(char *input, int *size);
|
static void _theme_autocomplete(char *input, int *size);
|
||||||
@ -965,6 +966,7 @@ cmd_reset_autocomplete()
|
|||||||
accounts_reset_all_search();
|
accounts_reset_all_search();
|
||||||
accounts_reset_enabled_search();
|
accounts_reset_enabled_search();
|
||||||
prefs_reset_boolean_choice();
|
prefs_reset_boolean_choice();
|
||||||
|
presence_reset_sub_request_search();
|
||||||
autocomplete_reset(help_ac);
|
autocomplete_reset(help_ac);
|
||||||
autocomplete_reset(notify_ac);
|
autocomplete_reset(notify_ac);
|
||||||
autocomplete_reset(sub_ac);
|
autocomplete_reset(sub_ac);
|
||||||
@ -1181,13 +1183,13 @@ _cmd_complete_parameters(char *input, int *size)
|
|||||||
|
|
||||||
_parameter_autocomplete(input, size, "/connect",
|
_parameter_autocomplete(input, size, "/connect",
|
||||||
accounts_find_enabled);
|
accounts_find_enabled);
|
||||||
_parameter_autocomplete_with_ac(input, size, "/sub", sub_ac);
|
|
||||||
_parameter_autocomplete_with_ac(input, size, "/help", help_ac);
|
_parameter_autocomplete_with_ac(input, size, "/help", help_ac);
|
||||||
_parameter_autocomplete_with_ac(input, size, "/who", who_ac);
|
_parameter_autocomplete_with_ac(input, size, "/who", who_ac);
|
||||||
_parameter_autocomplete_with_ac(input, size, "/prefs", prefs_ac);
|
_parameter_autocomplete_with_ac(input, size, "/prefs", prefs_ac);
|
||||||
_parameter_autocomplete_with_ac(input, size, "/log", log_ac);
|
_parameter_autocomplete_with_ac(input, size, "/log", log_ac);
|
||||||
_parameter_autocomplete_with_ac(input, size, "/disco", disco_ac);
|
_parameter_autocomplete_with_ac(input, size, "/disco", disco_ac);
|
||||||
|
|
||||||
|
_sub_autocomplete(input, size);
|
||||||
_notify_autocomplete(input, size);
|
_notify_autocomplete(input, size);
|
||||||
_autoaway_autocomplete(input, size);
|
_autoaway_autocomplete(input, size);
|
||||||
_titlebar_autocomplete(input, size);
|
_titlebar_autocomplete(input, size);
|
||||||
@ -3073,6 +3075,33 @@ _parameter_autocomplete_with_ac(char *input, int *size, char *command,
|
|||||||
free(command_cpy);
|
free(command_cpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_sub_autocomplete(char *input, int *size)
|
||||||
|
{
|
||||||
|
char *found = NULL;
|
||||||
|
char *auto_msg = NULL;
|
||||||
|
char inp_cpy[*size];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if ((strncmp(input, "/sub allow ", 11) == 0) && (*size > 11)) {
|
||||||
|
for (i = 11; i < *size; i++) {
|
||||||
|
inp_cpy[i-11] = input[i];
|
||||||
|
}
|
||||||
|
inp_cpy[(*size) - 11] = '\0';
|
||||||
|
found = presence_sub_request_find(inp_cpy);
|
||||||
|
if (found != NULL) {
|
||||||
|
auto_msg = (char *) malloc((11 + (strlen(found) + 1)) * sizeof(char));
|
||||||
|
strcpy(auto_msg, "/sub allow ");
|
||||||
|
strcat(auto_msg, found);
|
||||||
|
inp_replace_input(input, auto_msg, size);
|
||||||
|
free(auto_msg);
|
||||||
|
free(found);
|
||||||
|
}
|
||||||
|
} else if ((strncmp(input, "/sub ", 5) == 0) && (*size > 5)) {
|
||||||
|
_parameter_autocomplete_with_ac(input, size, "/sub", sub_ac);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_notify_autocomplete(char *input, int *size)
|
_notify_autocomplete(char *input, int *size)
|
||||||
{
|
{
|
||||||
|
@ -141,6 +141,18 @@ presence_free_sub_requests(void)
|
|||||||
autocomplete_free(sub_requests_ac);
|
autocomplete_free(sub_requests_ac);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
presence_sub_request_find(char * search_str)
|
||||||
|
{
|
||||||
|
return autocomplete_complete(sub_requests_ac, search_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
presence_reset_sub_request_search(void)
|
||||||
|
{
|
||||||
|
autocomplete_reset(sub_requests_ac);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
presence_update(const resource_presence_t presence_type, const char * const msg,
|
presence_update(const resource_presence_t presence_type, const char * const msg,
|
||||||
const int idle)
|
const int idle)
|
||||||
|
@ -105,6 +105,8 @@ void message_send_duck(const char * const query);
|
|||||||
void presence_subscription(const char * const jid, const jabber_subscr_t action);
|
void presence_subscription(const char * const jid, const jabber_subscr_t action);
|
||||||
GSList* presence_get_subscription_requests(void);
|
GSList* presence_get_subscription_requests(void);
|
||||||
gint presence_sub_request_count(void);
|
gint presence_sub_request_count(void);
|
||||||
|
void presence_reset_sub_request_search(void);
|
||||||
|
char * presence_sub_request_find(char * search_str);
|
||||||
void presence_join_room(Jid *jid);
|
void presence_join_room(Jid *jid);
|
||||||
void presence_change_room_nick(const char * const room, const char * const nick);
|
void presence_change_room_nick(const char * const room, const char * const nick);
|
||||||
void presence_leave_chat_room(const char * const room_jid);
|
void presence_leave_chat_room(const char * const room_jid);
|
||||||
|
Loading…
Reference in New Issue
Block a user