1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-02 07:25:43 +02:00

Improved plugin API, most functions rewritten from scratch

This commit is contained in:
Sebastien Helleu
2007-10-31 18:04:44 +01:00
parent 02c0dec9cb
commit bf40cfbdfd
16 changed files with 2861 additions and 4010 deletions
+18 -4
View File
@@ -14,8 +14,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
SET(LIB_PLUGINS_SRC weechat-plugin.h plugins.h plugins.c plugins-interface.c
plugins-config.h plugins-config.c)
SET(LIB_PLUGINS_SRC weechat-plugin.h plugin.c plugin.h plugin-api.c
plugin-api.h plugin-config.h plugin-config.c plugin-list.c plugin-list.h)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
ADD_LIBRARY(weechat_plugins STATIC ${LIB_PLUGINS_SRC})
@@ -24,6 +24,14 @@ INCLUDE(CheckIncludeFiles)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckLibraryExists)
IF(NOT DISABLE_IRC)
ADD_SUBDIRECTORY( irc )
ENDIF(NOT DISABLE_IRC)
IF(NOT DISABLE_PERL AND NOT DISABLE_PYTHON AND NOT DISABLE_RUBY AND NOT DISABLE_LUA)
ADD_SUBDIRECTORY( scripts )
ENDIF(NOT DISABLE_PERL AND NOT DISABLE_PYTHON AND NOT DISABLE_RUBY AND NOT DISABLE_LUA)
IF(NOT DISABLE_ASPELL)
# Check for aspell libraries
FIND_PACKAGE(Aspell)
@@ -32,11 +40,17 @@ IF(NOT DISABLE_ASPELL)
ENDIF(ASPELL_FOUND)
ENDIF(NOT DISABLE_ASPELL)
IF (NOT DISABLE_CHARSET)
IF(NOT DISABLE_CHARSET)
# Check for iconv support.
IF(ICONV_FOUND)
ADD_SUBDIRECTORY( charset )
ENDIF(ICONV_FOUND)
ENDIF(NOT DISABLE_CHARSET)
ADD_SUBDIRECTORY( scripts )
IF(NOT DISABLE_FIFO)
ADD_SUBDIRECTORY( fifo )
ENDIF(NOT DISABLE_FIFO)
IF(NOT DISABLE_TRIGGER)
ADD_SUBDIRECTORY( trigger )
ENDIF(NOT DISABLE_TRIGGER)
+23 -8
View File
@@ -16,6 +16,22 @@
INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\"
noinst_LIBRARIES = lib_weechat_plugins.a
lib_weechat_plugins_a_SOURCES = weechat-plugin.h \
plugin.c \
plugin.h \
plugin-api.c \
plugin-api.h \
plugin-config.c \
plugin-config.h \
plugin-list.c \
plugin-list.h
if PLUGIN_IRC
irc_dir = irc
endif
if PLUGIN_PERL
script_dir = scripts
endif
@@ -40,13 +56,12 @@ if PLUGIN_CHARSET
charset_dir = charset
endif
SUBDIRS = $(script_dir) $(aspell_dir) $(charset_dir)
if PLUGIN_FIFO
fifo_dir = fifo
endif
noinst_LIBRARIES = lib_weechat_plugins.a
if PLUGIN_TRIGGER
trigger_dir = trigger
endif
lib_weechat_plugins_a_SOURCES = weechat-plugin.h \
plugins.h \
plugins.c \
plugins-interface.c \
plugins-config.h \
plugins-config.c
SUBDIRS = . $(irc_dir) $(script_dir) $(aspell_dir) $(charset_dir) $(fifo_dir) $(trigger_dir)
File diff suppressed because it is too large Load Diff
+96
View File
@@ -0,0 +1,96 @@
/*
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_PLUGIN_API_H
#define __WEECHAT_PLUGIN_API_H 1
/* strings */
extern void plugin_api_charset_set (struct t_weechat_plugin *, char *);
extern char *plugin_api_iconv_to_internal (struct t_weechat_plugin *, char *, char *);
extern char *plugin_api_iconv_from_internal (struct t_weechat_plugin *, char *, char *);
extern char *plugin_api_gettext (struct t_weechat_plugin *, char *);
extern char *plugin_api_ngettext (struct t_weechat_plugin *, char *, char *, int);
extern int plugin_api_strcasecmp (struct t_weechat_plugin *,char *, char *);
extern int plugin_api_strncasecmp (struct t_weechat_plugin *,char *, char *, int);
extern char **plugin_api_explode_string (struct t_weechat_plugin *, char *, char *, int, int *);
extern void plugin_api_free_exploded_string (struct t_weechat_plugin *, char **);
/* directories */
extern int plugin_api_mkdir_home (struct t_weechat_plugin *, char *);
extern void plugin_api_exec_on_files (struct t_weechat_plugin *, char *,
int (*)(char *));
/* display */
extern void plugin_api_printf (struct t_weechat_plugin *, void *,
char *, ...);
extern char *plugin_api_prefix (struct t_weechat_plugin *, char *);
extern char *plugin_api_color (struct t_weechat_plugin *, char *);
extern void plugin_api_print_infobar (struct t_weechat_plugin *, int,
char *, ...);
extern void plugin_api_infobar_remove (struct t_weechat_plugin *, int);
/* hooks */
extern struct t_hook *plugin_api_hook_command (struct t_weechat_plugin *,
char *, char *, char *, char *,
char *, int (*)(void *, char *),
void *);
extern struct t_hook *plugin_api_hook_message (struct t_weechat_plugin *,
char *, int (*)(void *, char *),
void *);
extern struct t_hook *plugin_api_hook_config (struct t_weechat_plugin *,
char *, char *,
int (*)(void *, char *, char *, char *),
void *);
extern struct t_hook *plugin_api_hook_timer (struct t_weechat_plugin *,
long, int,
int (*)(void *), void *);
extern struct t_hook *plugin_api_hook_fd (struct t_weechat_plugin *,
int, int, int, int,
int (*)(void *), void *);
extern void plugin_api_unhook (struct t_weechat_plugin *, void *);
extern void plugin_api_unhook_all (struct t_weechat_plugin *);
/* buffers */
extern struct t_gui_buffer *plugin_api_buffer_new (struct t_weechat_plugin *,
char *, char *);
extern struct t_gui_buffer *plugin_api_buffer_search (struct t_weechat_plugin *,
char *, char *);
extern void plugin_api_buffer_close (struct t_weechat_plugin *, void *);
extern void plugin_api_buffer_set (struct t_weechat_plugin *, void *, char *,
char *);
extern void plugin_api_buffer_nick_add (struct t_weechat_plugin *, void *,
char *, int, char *, char, char *);
extern void plugin_api_buffer_nick_remove (struct t_weechat_plugin *, char *);
/* command */
extern void plugin_api_command (struct t_weechat_plugin *, void *, char *);
/* infos */
extern char *plugin_api_info_get (struct t_weechat_plugin *, char *);
/* config */
extern char *plugin_api_config_get (struct t_weechat_plugin *, char *);
extern int plugin_api_config_set (struct t_weechat_plugin *, char *, char *);
extern char *plugin_api_plugin_config_get (struct t_weechat_plugin *, char *);
extern int plugin_api_plugin_config_set (struct t_weechat_plugin *, char *, char *);
/* log */
extern void plugin_api_log (struct t_weechat_plugin *, char *, char *, char *, ...);
#endif /* plugin-api.h */
File diff suppressed because it is too large Load Diff
+47
View File
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_PLUGIN_CONFIG_H
#define __WEECHAT_PLUGIN_CONFIG_H 1
#include "../core/wee-config-option.h"
#define WEECHAT_PLUGIN_CONFIG_NAME "plugins.rc"
struct t_plugin_option
{
char *name; /* option name in config file */
char *value; /* value of option */
struct t_plugin_option *prev_option; /* link to previous option */
struct t_plugin_option *next_option; /* link to next option */
};
extern struct t_plugin_option *plugin_options;
extern struct t_plugin_option *plugin_config_search_internal (char *);
extern struct t_plugin_option *plugin_config_search (char *, char *);
extern int plugin_config_set_internal (char *, char *);
extern int plugin_config_set (char *, char *, char *);
extern int plugin_config_read_option (struct t_config_option *, char *, char *);
extern int plugin_config_read ();
extern int plugin_config_write_options (FILE *, char *,
struct t_config_option *);
extern int plugin_config_write ();
#endif /* plugin-config.h */
File diff suppressed because it is too large Load Diff
+82
View File
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_PLUGIN_LIST_H
#define __WEECHAT_PLUGIN_LIST_H 1
/* list structures */
enum t_plugin_var_type
{
PLUGIN_LIST_VAR_INTEGER = 0,
PLUGIN_LIST_VAR_STRING,
PLUGIN_LIST_VAR_POINTER,
PLUGIN_LIST_VAR_TIME,
};
struct t_plugin_list_var
{
char *name; /* variable name */
enum t_plugin_var_type type; /* type: integer, string, time */
int value_int; /* integer value */
char *value_string; /* string value */
void *value_pointer; /* pointer value */
time_t value_time; /* time value */
struct t_plugin_list_var *prev_var; /* link to previous variable */
struct t_plugin_list_var *next_var; /* link to next variable */
};
struct t_plugin_list_item
{
struct t_plugin_list_var *vars; /* item variables */
struct t_plugin_list_var *last_var; /* last variable */
struct t_plugin_list_item *prev_item; /* link to previous item */
struct t_plugin_list_item *next_item; /* link to next item */
};
struct t_plugin_list
{
struct t_plugin_list_item *items; /* link to items */
struct t_plugin_list_item *last_item; /* last variable */
struct t_plugin_list_item *ptr_item; /* pointer to current item */
struct t_plugin_list *prev_list; /* link to previous list */
struct t_plugin_list *next_list; /* link to next list */
};
/* list variables */
extern struct t_plugin_list *plugin_lists;
extern struct t_plugin_list *last_plugin_list;
/* list functions */
extern struct t_plugin_list *plugin_list_new ();
extern struct t_plugin_list_item *plugin_list_new_item (struct t_plugin_list *);
extern struct t_plugin_list_var *plugin_list_new_var_int (struct t_plugin_list_item *,
char *, int);
extern struct t_plugin_list_var *plugin_list_new_var_string (struct t_plugin_list_item *,
char *, char *);
extern struct t_plugin_list_var *plugin_list_new_var_pointer (struct t_plugin_list_item *,
char *, void *);
extern struct t_plugin_list_var *plugin_list_new_var_time (struct t_plugin_list_item *,
char *, time_t);
extern void plugin_list_free (struct t_plugin_list *);
extern void plugin_list_print_log ();
#endif /* plugin-list.h */
File diff suppressed because it is too large Load Diff
+47
View File
@@ -0,0 +1,47 @@
/*
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_PLUGIN_H
#define __WEECHAT_PLUGIN_H 1
#include "weechat-plugin.h"
typedef int (t_weechat_init_func) (struct t_weechat_plugin *);
typedef void (t_weechat_end_func) (struct t_weechat_plugin *);
extern struct t_weechat_plugin *weechat_plugins;
extern struct t_weechat_plugin *last_weechat_plugin;
//extern t_plugin_irc_color plugins_irc_colors[GUI_NUM_IRC_COLORS];
extern void plugin_exec_on_files (struct t_weechat_plugin *, char *,
int (*)(struct t_weechat_plugin *, char *));
extern struct t_weechat_plugin *plugin_search (char *);
extern struct t_weechat_plugin *plugin_load (char *);
extern void plugin_auto_load ();
extern void plugin_remove (struct t_weechat_plugin *);
extern void plugin_unload (struct t_weechat_plugin *);
extern void plugin_unload_name (char *);
extern void plugin_unload_all ();
extern void plugin_reload_name (char *);
extern void plugin_init (int);
extern void plugin_end ();
extern void plugin_print_log ();
#endif /* plugin.h */
File diff suppressed because it is too large Load Diff
-44
View File
@@ -1,44 +0,0 @@
/*
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_PLUGINS_CONFIG_H
#define __WEECHAT_PLUGINS_CONFIG_H 1
#define WEECHAT_PLUGINS_CONFIG_NAME "plugins.rc"
typedef struct t_plugin_option t_plugin_option;
struct t_plugin_option
{
char *name; /* option name in config file */
char *value; /* value of option */
t_plugin_option *prev_option; /* link to previous option */
t_plugin_option *next_option; /* link to next option */
};
extern t_plugin_option *plugin_options;
extern t_plugin_option *plugin_config_search_internal (char *);
extern t_plugin_option *plugin_config_search (t_weechat_plugin *, char *);
extern int plugin_config_set_internal (char *, char *);
extern int plugin_config_set (t_weechat_plugin *, char *, char *);
extern void plugin_config_read ();
extern int plugin_config_write ();
#endif /* plugins-config.h */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-93
View File
@@ -1,93 +0,0 @@
/*
* Copyright (c) 2003-2007 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_PLUGINS_H
#define __WEECHAT_PLUGINS_H 1
#include "weechat-plugin.h"
#include "plugins-config.h"
#include "../protocols/irc/irc.h"
#include "../gui/gui.h"
typedef struct t_plugin_irc_color t_plugin_irc_color;
struct t_plugin_irc_color
{
int number;
char *name;
};
typedef int (t_weechat_init_func) (t_weechat_plugin *);
typedef void (t_weechat_end_func) (t_weechat_plugin *);
extern t_weechat_plugin *weechat_plugins;
extern t_weechat_plugin *last_weechat_plugin;
extern t_plugin_irc_color plugins_irc_colors[GUI_NUM_IRC_COLORS];
extern int plugin_find_server_channel (char *, char *,
t_irc_server **, t_irc_channel **);
extern void plugin_exec_on_files (t_weechat_plugin *, char *,
int (*)(t_weechat_plugin *, char *));
extern t_weechat_plugin *plugin_search (char *);
extern t_plugin_handler *plugin_msg_handler_add (t_weechat_plugin *, char *,
t_plugin_handler_func *,
char *, void *);
extern t_plugin_handler *plugin_cmd_handler_add (t_weechat_plugin *, char *,
char *, char *, char *,
char *,
t_plugin_handler_func *,
char *, void *);
extern t_plugin_handler *plugin_timer_handler_add (t_weechat_plugin *, int,
t_plugin_handler_func *,
char *, void *);
extern t_plugin_handler *plugin_keyboard_handler_add (t_weechat_plugin *,
t_plugin_handler_func *,
char *, void *);
extern t_plugin_handler *plugin_event_handler_add (t_weechat_plugin *, char *,
t_plugin_handler_func *,
char *, void *);
extern int plugin_msg_handler_exec (char *, char *, char *);
extern int plugin_cmd_handler_exec (char *, char *, char *);
extern int plugin_timer_handler_exec ();
extern int plugin_keyboard_handler_exec (char *, char *, char *);
extern int plugin_event_handler_exec (char *, int, char **);
extern void plugin_handler_remove (t_weechat_plugin *,
t_plugin_handler *);
extern void plugin_handler_remove_all (t_weechat_plugin *);
extern t_plugin_modifier *plugin_modifier_add (t_weechat_plugin *,
char *, char *,
t_plugin_modifier_func *,
char *, void *);
extern char *plugin_modifier_exec (t_plugin_modifier_type, char *, char *);
extern void plugin_modifier_remove (t_weechat_plugin *,
t_plugin_modifier *);
extern void plugin_modifier_remove_all (t_weechat_plugin *);
extern t_weechat_plugin *plugin_load (char *);
extern void plugin_auto_load ();
extern void plugin_remove (t_weechat_plugin *);
extern void plugin_unload (t_weechat_plugin *);
extern void plugin_unload_name (char *);
extern void plugin_unload_all ();
extern void plugin_reload_name (char *);
extern void plugin_init (int);
extern void plugin_end ();
extern void plugin_print_log (t_weechat_plugin *);
#endif /* plugins.h */
File diff suppressed because it is too large Load Diff