Add function to get plugin name (return "core" for WeeChat core)
This commit is contained in:
parent
0e053e072b
commit
5d07aa14ed
@ -502,8 +502,7 @@ command_buffer (void *data, struct t_gui_buffer *buffer,
|
|||||||
ptr_buffer->number,
|
ptr_buffer->number,
|
||||||
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
|
||||||
GUI_COLOR(GUI_COLOR_CHAT),
|
GUI_COLOR(GUI_COLOR_CHAT),
|
||||||
(ptr_buffer->plugin) ?
|
plugin_get_name (ptr_buffer->plugin),
|
||||||
ptr_buffer->plugin->name : "core",
|
|
||||||
ptr_buffer->name);
|
ptr_buffer->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,8 +81,7 @@ gui_status_draw (int erase)
|
|||||||
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
|
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
|
||||||
GUI_COLOR_STATUS);
|
GUI_COLOR_STATUS);
|
||||||
wprintw (GUI_CURSES(ptr_win)->win_status, "%s",
|
wprintw (GUI_CURSES(ptr_win)->win_status, "%s",
|
||||||
(ptr_win->buffer->plugin) ?
|
plugin_get_name (ptr_win->buffer->plugin));
|
||||||
ptr_win->buffer->plugin->name : "core");
|
|
||||||
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
|
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
|
||||||
GUI_COLOR_STATUS_DELIMITERS);
|
GUI_COLOR_STATUS_DELIMITERS);
|
||||||
wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
|
wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
|
||||||
|
@ -742,6 +742,8 @@ gui_bar_item_default_buffer_plugin (void *data, struct t_gui_bar_item *item,
|
|||||||
struct t_gui_window *window,
|
struct t_gui_window *window,
|
||||||
int max_width, int max_height)
|
int max_width, int max_height)
|
||||||
{
|
{
|
||||||
|
char *plugin_name;
|
||||||
|
|
||||||
/* make C compiler happy */
|
/* make C compiler happy */
|
||||||
(void) data;
|
(void) data;
|
||||||
(void) item;
|
(void) item;
|
||||||
@ -750,9 +752,9 @@ gui_bar_item_default_buffer_plugin (void *data, struct t_gui_bar_item *item,
|
|||||||
|
|
||||||
if (!window)
|
if (!window)
|
||||||
window = gui_current_window;
|
window = gui_current_window;
|
||||||
|
|
||||||
return (window->buffer->plugin) ?
|
plugin_name = plugin_get_name (window->buffer->plugin);
|
||||||
strdup (window->buffer->plugin->name) : strdup ("core");
|
return (plugin_name) ? strdup (plugin_name) : strdup ("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -149,7 +149,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
|
|||||||
if (!name)
|
if (!name)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (gui_buffer_search_by_name ((plugin) ? plugin->name : "core", name))
|
if (gui_buffer_search_by_name (plugin_get_name (plugin), name))
|
||||||
{
|
{
|
||||||
gui_chat_printf (NULL,
|
gui_chat_printf (NULL,
|
||||||
_("%sError: a buffer with same name (%s) already "
|
_("%sError: a buffer with same name (%s) already "
|
||||||
@ -167,7 +167,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
|
|||||||
new_buffer->plugin = plugin;
|
new_buffer->plugin = plugin;
|
||||||
new_buffer->plugin_name_for_upgrade = NULL;
|
new_buffer->plugin_name_for_upgrade = NULL;
|
||||||
/* number will be set later (when inserting buffer in list) */
|
/* number will be set later (when inserting buffer in list) */
|
||||||
new_buffer->layout_number = gui_layout_buffer_get_number ((plugin) ? plugin->name : "core",
|
new_buffer->layout_number = gui_layout_buffer_get_number (plugin_get_name (plugin),
|
||||||
name);
|
name);
|
||||||
new_buffer->name = strdup (name);
|
new_buffer->name = strdup (name);
|
||||||
new_buffer->type = GUI_BUFFER_TYPE_FORMATED;
|
new_buffer->type = GUI_BUFFER_TYPE_FORMATED;
|
||||||
@ -354,7 +354,7 @@ gui_buffer_get_string (struct t_gui_buffer *buffer, const char *property)
|
|||||||
if (buffer && property)
|
if (buffer && property)
|
||||||
{
|
{
|
||||||
if (string_strcasecmp (property, "plugin") == 0)
|
if (string_strcasecmp (property, "plugin") == 0)
|
||||||
return (buffer->plugin) ? buffer->plugin->name : NULL;
|
return plugin_get_name (buffer->plugin);
|
||||||
else if (string_strcasecmp (property, "name") == 0)
|
else if (string_strcasecmp (property, "name") == 0)
|
||||||
return buffer->name;
|
return buffer->name;
|
||||||
else if (string_strcasecmp (property, "title") == 0)
|
else if (string_strcasecmp (property, "title") == 0)
|
||||||
@ -773,7 +773,7 @@ gui_buffer_search_by_name (const char *plugin, const char *name)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (strcmp (plugin, "core") != 0)
|
if (strcmp (plugin, PLUGIN_CORE) != 0)
|
||||||
plugin_match = 0;
|
plugin_match = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -818,7 +818,7 @@ gui_buffer_search_by_partial_name (const char *plugin, const char *name)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (strcmp (plugin, "core") != 0)
|
if (strcmp (plugin, PLUGIN_CORE) != 0)
|
||||||
plugin_match = 0;
|
plugin_match = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1256,8 +1256,7 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
|
|||||||
if (!infolist_new_var_pointer (ptr_item, "plugin", buffer->plugin))
|
if (!infolist_new_var_pointer (ptr_item, "plugin", buffer->plugin))
|
||||||
return 0;
|
return 0;
|
||||||
if (!infolist_new_var_string (ptr_item, "plugin_name",
|
if (!infolist_new_var_string (ptr_item, "plugin_name",
|
||||||
(buffer->plugin) ?
|
plugin_get_name (buffer->plugin)))
|
||||||
buffer->plugin->name : NULL))
|
|
||||||
return 0;
|
return 0;
|
||||||
if (!infolist_new_var_integer (ptr_item, "number", buffer->number))
|
if (!infolist_new_var_integer (ptr_item, "number", buffer->number))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -148,8 +148,7 @@ gui_layout_buffer_save ()
|
|||||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||||
ptr_buffer = ptr_buffer->next_buffer)
|
ptr_buffer = ptr_buffer->next_buffer)
|
||||||
{
|
{
|
||||||
gui_layout_buffer_add ((ptr_buffer->plugin) ?
|
gui_layout_buffer_add (plugin_get_name (ptr_buffer->plugin),
|
||||||
ptr_buffer->plugin->name : "core",
|
|
||||||
ptr_buffer->name,
|
ptr_buffer->name,
|
||||||
ptr_buffer->number);
|
ptr_buffer->number);
|
||||||
}
|
}
|
||||||
@ -187,14 +186,14 @@ void
|
|||||||
gui_layout_buffer_apply ()
|
gui_layout_buffer_apply ()
|
||||||
{
|
{
|
||||||
struct t_gui_buffer *ptr_buffer;
|
struct t_gui_buffer *ptr_buffer;
|
||||||
char *plugin_core = "core", *plugin_name;
|
char *plugin_name;
|
||||||
|
|
||||||
if (gui_layout_buffers)
|
if (gui_layout_buffers)
|
||||||
{
|
{
|
||||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||||
ptr_buffer = ptr_buffer->next_buffer)
|
ptr_buffer = ptr_buffer->next_buffer)
|
||||||
{
|
{
|
||||||
plugin_name = (ptr_buffer->plugin) ? ptr_buffer->plugin->name : plugin_core;
|
plugin_name = plugin_get_name (ptr_buffer->plugin);
|
||||||
ptr_buffer->layout_number = gui_layout_buffer_get_number (plugin_name,
|
ptr_buffer->layout_number = gui_layout_buffer_get_number (plugin_name,
|
||||||
ptr_buffer->name);
|
ptr_buffer->name);
|
||||||
if ((ptr_buffer->layout_number > 0)
|
if ((ptr_buffer->layout_number > 0)
|
||||||
@ -370,8 +369,7 @@ gui_layout_window_save_tree (struct t_gui_layout_window *parent_layout,
|
|||||||
layout_window = gui_layout_window_add (internal_id++,
|
layout_window = gui_layout_window_add (internal_id++,
|
||||||
parent_layout,
|
parent_layout,
|
||||||
0, 0,
|
0, 0,
|
||||||
(tree->window->buffer->plugin) ?
|
plugin_get_name (tree->window->buffer->plugin),
|
||||||
tree->window->buffer->plugin->name : "core",
|
|
||||||
tree->window->buffer->name);
|
tree->window->buffer->name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -412,9 +410,9 @@ void
|
|||||||
gui_layout_window_check_buffer (struct t_gui_buffer *buffer)
|
gui_layout_window_check_buffer (struct t_gui_buffer *buffer)
|
||||||
{
|
{
|
||||||
struct t_gui_window *ptr_win;
|
struct t_gui_window *ptr_win;
|
||||||
char *plugin_core = "core", *plugin_name;
|
char *plugin_name;
|
||||||
|
|
||||||
plugin_name = (buffer->plugin) ? buffer->plugin->name : plugin_core;
|
plugin_name = plugin_get_name (buffer->plugin);
|
||||||
|
|
||||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||||
{
|
{
|
||||||
@ -440,7 +438,7 @@ gui_layout_window_check_all_buffers ()
|
|||||||
{
|
{
|
||||||
struct t_gui_window *ptr_win;
|
struct t_gui_window *ptr_win;
|
||||||
struct t_gui_buffer *ptr_buffer;
|
struct t_gui_buffer *ptr_buffer;
|
||||||
char *plugin_core = "core", *plugin_name;
|
char *plugin_name;
|
||||||
|
|
||||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||||
{
|
{
|
||||||
@ -449,7 +447,7 @@ gui_layout_window_check_all_buffers ()
|
|||||||
for (ptr_buffer = gui_buffers; ptr_buffer;
|
for (ptr_buffer = gui_buffers; ptr_buffer;
|
||||||
ptr_buffer = ptr_buffer->next_buffer)
|
ptr_buffer = ptr_buffer->next_buffer)
|
||||||
{
|
{
|
||||||
plugin_name = (ptr_buffer->plugin) ? ptr_buffer->plugin->name : plugin_core;
|
plugin_name = plugin_get_name (ptr_buffer->plugin);
|
||||||
|
|
||||||
if ((strcmp (ptr_win->layout_plugin_name, plugin_name) == 0)
|
if ((strcmp (ptr_win->layout_plugin_name, plugin_name) == 0)
|
||||||
&& (strcmp (ptr_win->layout_buffer_name, ptr_buffer->name) == 0))
|
&& (strcmp (ptr_win->layout_buffer_name, ptr_buffer->name) == 0))
|
||||||
|
@ -443,15 +443,12 @@ charset_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
|
|||||||
plugin_name = weechat_buffer_get_string (buffer, "plugin");
|
plugin_name = weechat_buffer_get_string (buffer, "plugin");
|
||||||
name = weechat_buffer_get_string (buffer, "name");
|
name = weechat_buffer_get_string (buffer, "name");
|
||||||
|
|
||||||
length = ((plugin_name) ? strlen (plugin_name) : strlen ("core")) + 1 +
|
length = strlen (plugin_name) + 1 + strlen (name) + 1;
|
||||||
strlen (name) + 1;
|
|
||||||
option_name = malloc (length);
|
option_name = malloc (length);
|
||||||
if (!option_name)
|
if (!option_name)
|
||||||
return WEECHAT_RC_ERROR;
|
return WEECHAT_RC_ERROR;
|
||||||
|
|
||||||
snprintf (option_name, length, "%s.%s",
|
snprintf (option_name, length, "%s.%s", plugin_name, name);
|
||||||
(plugin_name) ? plugin_name : "core",
|
|
||||||
name);
|
|
||||||
|
|
||||||
if ((argc > 1) && (weechat_strcasecmp (argv[1], "reset") == 0))
|
if ((argc > 1) && (weechat_strcasecmp (argv[1], "reset") == 0))
|
||||||
{
|
{
|
||||||
|
@ -131,7 +131,7 @@ logger_get_filename (struct t_gui_buffer *buffer)
|
|||||||
{
|
{
|
||||||
plugin_name = weechat_infolist_string (ptr_infolist, "plugin_name");
|
plugin_name = weechat_infolist_string (ptr_infolist, "plugin_name");
|
||||||
plugin_name2 = (plugin_name) ?
|
plugin_name2 = (plugin_name) ?
|
||||||
weechat_string_replace (plugin_name, dir_separator, "_") : strdup ("core");
|
weechat_string_replace (plugin_name, dir_separator, "_") : NULL;
|
||||||
name = weechat_infolist_string (ptr_infolist, "name");
|
name = weechat_infolist_string (ptr_infolist, "name");
|
||||||
name2 = (name) ?
|
name2 = (name) ?
|
||||||
weechat_string_replace (name, dir_separator, "_") : NULL;
|
weechat_string_replace (name, dir_separator, "_") : NULL;
|
||||||
|
@ -84,15 +84,12 @@ notify_build_option_name (struct t_gui_buffer *buffer)
|
|||||||
plugin_name = weechat_buffer_get_string (buffer, "plugin");
|
plugin_name = weechat_buffer_get_string (buffer, "plugin");
|
||||||
name = weechat_buffer_get_string (buffer, "name");
|
name = weechat_buffer_get_string (buffer, "name");
|
||||||
|
|
||||||
length = ((plugin_name) ? strlen (plugin_name) : strlen ("core")) + 1 +
|
length = strlen (plugin_name) + 1 + strlen (name) + 1;
|
||||||
strlen (name) + 1;
|
|
||||||
option_name = malloc (length);
|
option_name = malloc (length);
|
||||||
if (!option_name)
|
if (!option_name)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
snprintf (option_name, length, "%s.%s",
|
snprintf (option_name, length, "%s.%s", plugin_name, name);
|
||||||
(plugin_name) ? plugin_name : "core",
|
|
||||||
name);
|
|
||||||
|
|
||||||
return option_name;
|
return option_name;
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,18 @@ plugin_search (const char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* plugin_get_name: get name of plugin with a pointer
|
||||||
|
*/
|
||||||
|
|
||||||
|
char *
|
||||||
|
plugin_get_name (struct t_weechat_plugin *plugin)
|
||||||
|
{
|
||||||
|
static char *plugin_core = PLUGIN_CORE;
|
||||||
|
|
||||||
|
return (plugin) ? plugin->name : plugin_core;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* plugin_load: load a WeeChat plugin (a dynamic library)
|
* plugin_load: load a WeeChat plugin (a dynamic library)
|
||||||
* return: pointer to new WeeChat plugin, NULL if error
|
* return: pointer to new WeeChat plugin, NULL if error
|
||||||
@ -281,6 +293,8 @@ plugin_load (const char *filename)
|
|||||||
new_plugin->charset = (charset) ? strdup (charset) : NULL;
|
new_plugin->charset = (charset) ? strdup (charset) : NULL;
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
new_plugin->plugin_get_name = &plugin_get_name;
|
||||||
|
|
||||||
new_plugin->charset_set = &plugin_api_charset_set;
|
new_plugin->charset_set = &plugin_api_charset_set;
|
||||||
new_plugin->iconv_to_internal = &string_iconv_to_internal;
|
new_plugin->iconv_to_internal = &string_iconv_to_internal;
|
||||||
new_plugin->iconv_from_internal = &string_iconv_from_internal;
|
new_plugin->iconv_from_internal = &string_iconv_from_internal;
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include "weechat-plugin.h"
|
#include "weechat-plugin.h"
|
||||||
|
|
||||||
|
#define PLUGIN_CORE "core"
|
||||||
|
|
||||||
typedef int (t_weechat_init_func) (struct t_weechat_plugin *plugin,
|
typedef int (t_weechat_init_func) (struct t_weechat_plugin *plugin,
|
||||||
int argc, char *argv[]);
|
int argc, char *argv[]);
|
||||||
typedef int (t_weechat_end_func) (struct t_weechat_plugin *plugin);
|
typedef int (t_weechat_end_func) (struct t_weechat_plugin *plugin);
|
||||||
@ -32,6 +34,7 @@ extern struct t_weechat_plugin *last_weechat_plugin;
|
|||||||
//extern t_plugin_irc_color plugins_irc_colors[GUI_NUM_IRC_COLORS];
|
//extern t_plugin_irc_color plugins_irc_colors[GUI_NUM_IRC_COLORS];
|
||||||
|
|
||||||
extern struct t_weechat_plugin *plugin_search (const char *name);
|
extern struct t_weechat_plugin *plugin_search (const char *name);
|
||||||
|
extern char *plugin_get_name (struct t_weechat_plugin *plugin);
|
||||||
extern struct t_weechat_plugin *plugin_load (const char *filename);
|
extern struct t_weechat_plugin *plugin_load (const char *filename);
|
||||||
extern void plugin_auto_load ();
|
extern void plugin_auto_load ();
|
||||||
extern void plugin_remove (struct t_weechat_plugin *plugin);
|
extern void plugin_remove (struct t_weechat_plugin *plugin);
|
||||||
|
@ -132,6 +132,44 @@ weechat_lua_api_register (lua_State *L)
|
|||||||
LUA_RETURN_OK;
|
LUA_RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* weechat_lua_api_plugin_get_name: get name of plugin (return "core" for
|
||||||
|
* WeeChat core)
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
weechat_lua_api_plugin_get_name (lua_State *L)
|
||||||
|
{
|
||||||
|
const char *plugin;
|
||||||
|
char *result;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
/* make C compiler happy */
|
||||||
|
(void) L;
|
||||||
|
|
||||||
|
if (!lua_current_script)
|
||||||
|
{
|
||||||
|
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("plugin_get_name");
|
||||||
|
LUA_RETURN_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin = NULL;
|
||||||
|
|
||||||
|
n = lua_gettop (lua_current_interpreter);
|
||||||
|
|
||||||
|
if (n < 1)
|
||||||
|
{
|
||||||
|
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("plugin_get_name");
|
||||||
|
LUA_RETURN_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin = lua_tostring (lua_current_interpreter, -1);
|
||||||
|
|
||||||
|
result = weechat_plugin_get_name (script_str2ptr (plugin));
|
||||||
|
|
||||||
|
LUA_RETURN_STRING(result);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* weechat_lua_api_charset_set: set script charset
|
* weechat_lua_api_charset_set: set script charset
|
||||||
*/
|
*/
|
||||||
@ -5554,6 +5592,7 @@ weechat_lua_api_constant_weechat_hook_signal_pointer (lua_State *L)
|
|||||||
|
|
||||||
const struct luaL_reg weechat_lua_api_funcs[] = {
|
const struct luaL_reg weechat_lua_api_funcs[] = {
|
||||||
{ "register", &weechat_lua_api_register },
|
{ "register", &weechat_lua_api_register },
|
||||||
|
{ "plugin_get_name", &weechat_lua_api_plugin_get_name },
|
||||||
{ "charset_set", &weechat_lua_api_charset_set },
|
{ "charset_set", &weechat_lua_api_charset_set },
|
||||||
{ "iconv_to_internal", &weechat_lua_api_iconv_to_internal },
|
{ "iconv_to_internal", &weechat_lua_api_iconv_to_internal },
|
||||||
{ "iconv_from_internal", &weechat_lua_api_iconv_from_internal },
|
{ "iconv_from_internal", &weechat_lua_api_iconv_from_internal },
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -115,6 +115,38 @@ weechat_python_api_register (PyObject *self, PyObject *args)
|
|||||||
PYTHON_RETURN_OK;
|
PYTHON_RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* weechat_python_api_plugin_get_name: get name of plugin (return "core" for
|
||||||
|
* WeeChat core)
|
||||||
|
*/
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
weechat_python_api_plugin_get_name (PyObject *self, PyObject *args)
|
||||||
|
{
|
||||||
|
char *plugin, *result;
|
||||||
|
|
||||||
|
/* make C compiler happy */
|
||||||
|
(void) self;
|
||||||
|
|
||||||
|
if (!python_current_script)
|
||||||
|
{
|
||||||
|
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("plugin_get_name");
|
||||||
|
PYTHON_RETURN_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin = NULL;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple (args, "s", &plugin))
|
||||||
|
{
|
||||||
|
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("plugin_get_name");
|
||||||
|
PYTHON_RETURN_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = weechat_plugin_get_name (script_str2ptr (plugin));
|
||||||
|
|
||||||
|
PYTHON_RETURN_STRING(result);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* weechat_python_api_charset_set: set script charset
|
* weechat_python_api_charset_set: set script charset
|
||||||
*/
|
*/
|
||||||
@ -4588,6 +4620,7 @@ weechat_python_api_infolist_free (PyObject *self, PyObject *args)
|
|||||||
PyMethodDef weechat_python_funcs[] =
|
PyMethodDef weechat_python_funcs[] =
|
||||||
{
|
{
|
||||||
{ "register", &weechat_python_api_register, METH_VARARGS, "" },
|
{ "register", &weechat_python_api_register, METH_VARARGS, "" },
|
||||||
|
{ "plugin_get_name", &weechat_python_api_plugin_get_name, METH_VARARGS, "" },
|
||||||
{ "charset_set", &weechat_python_api_charset_set, METH_VARARGS, "" },
|
{ "charset_set", &weechat_python_api_charset_set, METH_VARARGS, "" },
|
||||||
{ "iconv_to_internal", &weechat_python_api_iconv_to_internal, METH_VARARGS, "" },
|
{ "iconv_to_internal", &weechat_python_api_iconv_to_internal, METH_VARARGS, "" },
|
||||||
{ "iconv_from_internal", &weechat_python_api_iconv_from_internal, METH_VARARGS, "" },
|
{ "iconv_from_internal", &weechat_python_api_iconv_from_internal, METH_VARARGS, "" },
|
||||||
|
@ -133,6 +133,42 @@ weechat_ruby_api_register (VALUE class, VALUE name, VALUE author,
|
|||||||
RUBY_RETURN_OK;
|
RUBY_RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* weechat_ruby_api_plugin_get_name: get name of plugin (return "core" for
|
||||||
|
* WeeChat core)
|
||||||
|
*/
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
weechat_ruby_api_plugin_get_name (VALUE class, VALUE plugin)
|
||||||
|
{
|
||||||
|
char *c_plugin, *result;
|
||||||
|
|
||||||
|
/* make C compiler happy */
|
||||||
|
(void) class;
|
||||||
|
|
||||||
|
if (!ruby_current_script)
|
||||||
|
{
|
||||||
|
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("plugin_get_name");
|
||||||
|
RUBY_RETURN_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
c_plugin = NULL;
|
||||||
|
|
||||||
|
if (NIL_P (plugin))
|
||||||
|
{
|
||||||
|
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("plugin_get_name");
|
||||||
|
RUBY_RETURN_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
Check_Type (plugin, T_STRING);
|
||||||
|
|
||||||
|
c_plugin = STR2CSTR (plugin);
|
||||||
|
|
||||||
|
result = weechat_plugin_get_name (script_str2ptr (c_plugin));
|
||||||
|
|
||||||
|
RUBY_RETURN_STRING(result);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* weechat_ruby_api_charset_set: set script charset
|
* weechat_ruby_api_charset_set: set script charset
|
||||||
*/
|
*/
|
||||||
@ -5294,6 +5330,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
|||||||
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_SIGNAL_POINTER", rb_str_new2(WEECHAT_HOOK_SIGNAL_POINTER));
|
rb_define_const(ruby_mWeechat, "WEECHAT_HOOK_SIGNAL_POINTER", rb_str_new2(WEECHAT_HOOK_SIGNAL_POINTER));
|
||||||
|
|
||||||
rb_define_module_function (ruby_mWeechat, "register", &weechat_ruby_api_register, 7);
|
rb_define_module_function (ruby_mWeechat, "register", &weechat_ruby_api_register, 7);
|
||||||
|
rb_define_module_function (ruby_mWeechat, "plugin_get_name", &weechat_ruby_api_plugin_get_name, 1);
|
||||||
rb_define_module_function (ruby_mWeechat, "charset_set", &weechat_ruby_api_charset_set, 1);
|
rb_define_module_function (ruby_mWeechat, "charset_set", &weechat_ruby_api_charset_set, 1);
|
||||||
rb_define_module_function (ruby_mWeechat, "iconv_to_internal", &weechat_ruby_api_iconv_to_internal, 2);
|
rb_define_module_function (ruby_mWeechat, "iconv_to_internal", &weechat_ruby_api_iconv_to_internal, 2);
|
||||||
rb_define_module_function (ruby_mWeechat, "iconv_from_internal", &weechat_ruby_api_iconv_from_internal, 2);
|
rb_define_module_function (ruby_mWeechat, "iconv_from_internal", &weechat_ruby_api_iconv_from_internal, 2);
|
||||||
|
@ -219,6 +219,40 @@ weechat_tcl_api_register (ClientData clientData, Tcl_Interp *interp, int objc,
|
|||||||
TCL_RETURN_OK;
|
TCL_RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* weechat::plugin_get_name: get name of plugin (return "core" for WeeChat core)
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
weechat_tcl_api_plugin_get_name (ClientData clientData, Tcl_Interp *interp,
|
||||||
|
int objc, Tcl_Obj *CONST objv[])
|
||||||
|
{
|
||||||
|
Tcl_Obj* objp;
|
||||||
|
char *result, *plugin;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* make C compiler happy */
|
||||||
|
(void) clientData;
|
||||||
|
|
||||||
|
if (!tcl_current_script)
|
||||||
|
{
|
||||||
|
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("plugin_get_name");
|
||||||
|
TCL_RETURN_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (objc < 2)
|
||||||
|
{
|
||||||
|
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("plugin_get_name");
|
||||||
|
TCL_RETURN_EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin = Tcl_GetStringFromObj (objv[1], &i);
|
||||||
|
|
||||||
|
result = weechat_plugin_get_name (script_str2ptr (plugin));
|
||||||
|
|
||||||
|
TCL_RETURN_STRING(result);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* weechat::charset_set: set script charset
|
* weechat::charset_set: set script charset
|
||||||
*/
|
*/
|
||||||
@ -4951,6 +4985,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp) {
|
|||||||
/* interface functions */
|
/* interface functions */
|
||||||
Tcl_CreateObjCommand (interp,"weechat::register",
|
Tcl_CreateObjCommand (interp,"weechat::register",
|
||||||
weechat_tcl_api_register, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
weechat_tcl_api_register, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||||
|
Tcl_CreateObjCommand (interp,"weechat::plugin_get_name",
|
||||||
|
weechat_tcl_api_plugin_get_name, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||||
Tcl_CreateObjCommand (interp,"weechat::charset_set",
|
Tcl_CreateObjCommand (interp,"weechat::charset_set",
|
||||||
weechat_tcl_api_charset_set, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
weechat_tcl_api_charset_set, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||||
Tcl_CreateObjCommand (interp,"weechat::iconv_to_internal",
|
Tcl_CreateObjCommand (interp,"weechat::iconv_to_internal",
|
||||||
|
@ -119,6 +119,9 @@ struct t_weechat_plugin
|
|||||||
at the END of functions, for keeping backward compatibility with
|
at the END of functions, for keeping backward compatibility with
|
||||||
existing plugins */
|
existing plugins */
|
||||||
|
|
||||||
|
/* plugins */
|
||||||
|
char *(*plugin_get_name) (struct t_weechat_plugin *plugin);
|
||||||
|
|
||||||
/* strings */
|
/* strings */
|
||||||
void (*charset_set) (struct t_weechat_plugin *plugin, const char *charset);
|
void (*charset_set) (struct t_weechat_plugin *plugin, const char *charset);
|
||||||
char *(*iconv_to_internal) (const char *charset, const char *string);
|
char *(*iconv_to_internal) (const char *charset, const char *string);
|
||||||
@ -552,6 +555,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
|||||||
|
|
||||||
/* macros for easy call to plugin API */
|
/* macros for easy call to plugin API */
|
||||||
|
|
||||||
|
/* plugins */
|
||||||
|
#define weechat_plugin_get_name(__plugin) \
|
||||||
|
weechat_plugin->plugin_get_name(__plugin)
|
||||||
|
|
||||||
/* strings */
|
/* strings */
|
||||||
#define weechat_charset_set(__charset) \
|
#define weechat_charset_set(__charset) \
|
||||||
weechat_plugin->charset_set(weechat_plugin, __charset)
|
weechat_plugin->charset_set(weechat_plugin, __charset)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user