1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

Pass plugin name to all autocompleter functions

This commit is contained in:
James Booth 2016-07-04 23:14:08 +01:00
parent 03c7ac73fd
commit fd218ac3e4
7 changed files with 39 additions and 16 deletions

View File

@ -167,13 +167,13 @@ api_completer_add(const char *const plugin_name, const char *key, char **items)
}
void
api_completer_remove(const char *key, char **items)
api_completer_remove(const char *const plugin_name, const char *key, char **items)
{
autocompleters_remove(key, items);
}
void
api_completer_clear(const char *key)
api_completer_clear(const char *const plugin_name, const char *key)
{
autocompleters_clear(key);
}

View File

@ -57,8 +57,8 @@ void api_register_timed(const char *const plugin_name, void *callback, int inter
void (*callback_func)(PluginTimedFunction *timed_function), void(*callback_destroy)(void *callback));
void api_completer_add(const char *const plugin_name, const char *key, char **items);
void api_completer_remove(const char *key, char **items);
void api_completer_clear(const char *key);
void api_completer_remove(const char *const plugin_name, const char *key, char **items);
void api_completer_clear(const char *const plugin_name, const char *key);
void api_log_debug(const char *message);
void api_log_info(const char *message);

View File

@ -120,15 +120,25 @@ c_api_completer_add(const char *filename, const char *key, char **items)
}
static void
c_api_completer_remove(const char *key, char **items)
c_api_completer_remove(const char *filename, const char *key, char **items)
{
api_completer_remove(key, items);
char *plugin_name = _c_plugin_name(filename);
log_debug("Autocomplete remove %s for %s", key, plugin_name);
api_completer_remove(plugin_name, key, items);
free(plugin_name);
}
static void
c_api_completer_clear(const char *key)
c_api_completer_clear(const char *filename, const char *key)
{
api_completer_clear(key);
char *plugin_name = _c_plugin_name(filename);
log_debug("Autocomplete clear %s for %s", key, plugin_name);
api_completer_clear(plugin_name, key);
free(plugin_name);
}
static void
@ -322,9 +332,9 @@ c_api_init(void)
_prof_register_command = c_api_register_command;
_prof_register_timed = c_api_register_timed;
_prof_completer_add = c_api_completer_add;
_prof_completer_remove = c_api_completer_remove;
_prof_completer_clear = c_api_completer_clear;
_prof_win_create = c_api_win_create;
prof_completer_remove = c_api_completer_remove;
prof_completer_clear = c_api_completer_clear;
prof_notify = c_api_notify;
prof_send_line = c_api_send_line;
prof_get_current_recipient = c_api_get_current_recipient;

View File

@ -141,6 +141,7 @@ callbacks_init(void)
void
callbacks_remove(const char *const plugin_name)
{
// TODO remove from cmd_ac and cmd_ac_help
g_hash_table_remove(p_commands, plugin_name);
g_hash_table_remove(p_timed_functions, plugin_name);
g_hash_table_remove(p_window_callbacks, plugin_name);

View File

@ -49,8 +49,8 @@ void (*_prof_register_command)(const char *filename, const char *command_name, i
void (*_prof_register_timed)(const char *filename, void(*callback)(void), int interval_seconds) = NULL;
void (*_prof_completer_add)(const char *filename, const char *key, char **items) = NULL;
void (*prof_completer_remove)(const char *key, char **items) = NULL;
void (*prof_completer_clear)(const char *key) = NULL;
void (*_prof_completer_remove)(const char *filename, const char *key, char **items) = NULL;
void (*_prof_completer_clear)(const char *filename, const char *key) = NULL;
void (*prof_notify)(const char *message, int timeout_ms, const char *category) = NULL;

View File

@ -38,6 +38,8 @@
#define prof_register_command(command_name, min_args, max_args, synopsis, description, arguments, examples, callback) _prof_register_command(__FILE__, command_name, min_args, max_args, synopsis, description, arguments, examples, callback)
#define prof_register_timed(callback, interval_seconds) _prof_register_timed(__FILE__, callback, interval_seconds)
#define prof_completer_add(key, items) _prof_completer_add(__FILE__, key, items)
#define prof_completer_remove(key, items) _prof_completer_remove(__FILE__, key, items)
#define prof_completer_clear(key) _prof_completer_clear(__FILE__, key)
#define prof_win_create(win, input_handler) _prof_win_create(__FILE__, win, input_handler)
typedef char* PROF_WIN_TAG;
@ -54,8 +56,8 @@ void (*_prof_register_command)(const char *filename, const char *command_name, i
void (*_prof_register_timed)(const char *filename, void(*callback)(void), int interval_seconds);
void (*_prof_completer_add)(const char *filename, const char *key, char **items);
void (*prof_completer_remove)(const char *key, char **items);
void (*prof_completer_clear)(const char *key);
void (*_prof_completer_remove)(const char *filename, const char *key, char **items);
void (*_prof_completer_clear)(const char *filename, const char *key);
void (*prof_notify)(const char *message, int timeout_ms, const char *category);

View File

@ -242,6 +242,9 @@ python_api_completer_remove(PyObject *self, PyObject *args)
return Py_BuildValue("");
}
char *plugin_name = _python_plugin_name();
log_debug("Autocomplete remove %s for %s", key, plugin_name);
Py_ssize_t len = PyList_Size(items);
char *c_items[len];
@ -254,9 +257,11 @@ python_api_completer_remove(PyObject *self, PyObject *args)
c_items[len] = NULL;
allow_python_threads();
api_completer_remove(key, c_items);
api_completer_remove(plugin_name, key, c_items);
disable_python_threads();
free(plugin_name);
return Py_BuildValue("");
}
@ -269,10 +274,15 @@ python_api_completer_clear(PyObject *self, PyObject *args)
return Py_BuildValue("");
}
char *plugin_name = _python_plugin_name();
log_debug("Autocomplete clear %s for %s", key, plugin_name);
allow_python_threads();
api_completer_clear(key);
api_completer_clear(plugin_name, key);
disable_python_threads();
free(plugin_name);
return Py_BuildValue("");
}