1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-07 06:45:42 +02:00

Added some missing functions in Perl plugin API

This commit is contained in:
Sebastien Helleu
2008-01-10 18:37:31 +01:00
parent 938574feec
commit 8a67299912
20 changed files with 1700 additions and 900 deletions
+4 -2
View File
@@ -213,9 +213,11 @@ input_data (struct t_gui_buffer *buffer, char *data, int only_builtin)
hook_command_exec (buffer, ptr_data, 0);
if (buffer->input_data_cb)
if (buffer->input_callback)
{
(void)(buffer->input_data_cb) (buffer, ptr_data);
(void)(buffer->input_callback) (buffer->input_callback_data,
buffer,
ptr_data);
}
else
gui_chat_printf (buffer,
+1 -1
View File
@@ -101,7 +101,7 @@ gui_main_init ()
if (gui_window_new (NULL, 0, 0, COLS, LINES, 100, 100))
{
gui_current_window = gui_windows;
ptr_buffer = gui_buffer_new (NULL, "weechat", "weechat", NULL);
ptr_buffer = gui_buffer_new (NULL, "weechat", "weechat", NULL, NULL);
if (ptr_buffer)
{
gui_init_ok = 1;
+1 -1
View File
@@ -170,7 +170,7 @@ gui_main_init ()
if (gui_window_new (NULL, 0, 0, 0, 0, 100, 100))
{
gui_current_window = gui_windows;
ptr_buffer = gui_buffer_new (NULL, "weechat", "weechat", NULL);
ptr_buffer = gui_buffer_new (NULL, "weechat", "weechat", NULL, NULL);
if (ptr_buffer)
{
gui_init_ok = 1;
+8 -7
View File
@@ -66,15 +66,14 @@ struct t_gui_buffer *gui_buffer_before_raw_data = NULL; /* buf. before raw */
struct t_gui_buffer *
gui_buffer_new (struct t_weechat_plugin *plugin, char *category, char *name,
void (*callback_input_data)(struct t_gui_buffer *buffer, char *data))
int (*input_callback)(void *data,
struct t_gui_buffer *buffer,
char *input_data),
void *input_callback_data)
{
struct t_gui_buffer *new_buffer;
struct t_gui_completion *new_completion;
#ifdef DEBUG
log_printf ("Creating new buffer");
#endif
if (!category || !name)
return NULL;
@@ -124,7 +123,8 @@ gui_buffer_new (struct t_weechat_plugin *plugin, char *category, char *name,
/* input */
new_buffer->input = 1;
new_buffer->input_data_cb = callback_input_data;
new_buffer->input_callback = input_callback;
new_buffer->input_callback_data = input_callback_data;
new_buffer->input_nick = NULL;
new_buffer->input_buffer_alloc = GUI_BUFFER_INPUT_BLOCK_SIZE;
new_buffer->input_buffer = (char *)malloc (GUI_BUFFER_INPUT_BLOCK_SIZE);
@@ -1032,7 +1032,8 @@ gui_buffer_print_log ()
log_printf (" nicklist_visible_count.: %d", ptr_buffer->nicklist_visible_count);
log_printf (" nicklist_refresh_needed: %d", ptr_buffer->nicklist_refresh_needed);
log_printf (" input. . . . . . . . . : %d", ptr_buffer->input);
log_printf (" input_data_cb. . . . . : 0x%x", ptr_buffer->input_data_cb);
log_printf (" input_callback . . . . : 0x%x", ptr_buffer->input_callback);
log_printf (" input_callback_data. . : 0x%x", ptr_buffer->input_callback_data);
log_printf (" input_nick . . . . . . : '%s'", ptr_buffer->input_nick);
log_printf (" input_buffer . . . . . : '%s'", ptr_buffer->input_buffer);
log_printf (" input_buffer_color_mask: '%s'", ptr_buffer->input_buffer_color_mask);
+8 -3
View File
@@ -87,8 +87,11 @@ struct t_gui_buffer
/* inupt */
int input; /* = 1 if input is enabled */
void (*input_data_cb)(struct t_gui_buffer *buffer, char *data);
int (*input_callback)(void *data,
struct t_gui_buffer *buffer,
char *input_data);
/* called when user send data */
void *input_callback_data; /* data for callback */
/* to this buffer */
char *input_nick; /* self nick */
char *input_buffer; /* input buffer */
@@ -133,8 +136,10 @@ extern struct t_gui_buffer *gui_buffer_before_raw_data;
extern struct t_gui_buffer *gui_buffer_new (struct t_weechat_plugin *plugin,
char *category, char *name,
void (*input_data_cb)(struct t_gui_buffer *buffer,
char *data));
int (*input_callback)(void *data,
struct t_gui_buffer *buffer,
char *input_data),
void *input_callback_data);
extern int gui_buffer_valid (struct t_gui_buffer *buffer);
extern void *gui_buffer_get (struct t_gui_buffer *buffer, char *property);
extern void gui_buffer_set_category (struct t_gui_buffer *buffer,
+12 -4
View File
@@ -107,10 +107,17 @@ demo_infobar_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
* demo_buffer_input_data_cb: callback for input data on buffer
*/
void
demo_buffer_input_data_cb (struct t_gui_buffer *buffer, char *data)
int
demo_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer,
char *input_data)
{
weechat_printf (buffer, "buffer input_data_cb: data = '%s'", data);
/* make C compiler happy */
(void) data;
weechat_printf (buffer,
"buffer input_data_cb: input_data = '%s'", input_data);
return WEECHAT_RC_OK;
}
/*
@@ -131,7 +138,8 @@ demo_buffer_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
if (argc > 2)
{
new_buffer = weechat_buffer_new (argv[1], argv[2],
demo_buffer_input_data_cb);
&demo_buffer_input_data_cb,
NULL);
if (new_buffer)
weechat_buffer_set (new_buffer, "display", "1");
weechat_hook_signal_send ("logger_backlog",
+1 -1
View File
@@ -60,7 +60,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
/* create buffer for channel */
new_buffer = weechat_buffer_new (server->name, channel_name,
&irc_input_data);
&irc_input_data, NULL);
if (!new_buffer)
{
free (new_channel);
+11 -6
View File
@@ -151,16 +151,19 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, char *text)
* PROTOCOL_RC_KO if error
*/
void
irc_input_data (struct t_gui_buffer *buffer, char *data)
int
irc_input_data (void *data, struct t_gui_buffer *buffer, char *input_data)
{
char *data_with_colors;
/* make C compiler happy */
(void) data;
IRC_GET_SERVER_CHANNEL(buffer);
if (ptr_channel)
{
data_with_colors = (char *)irc_color_encode ((unsigned char *)data,
data_with_colors = (char *)irc_color_encode ((unsigned char *)input_data,
weechat_config_boolean (irc_config_irc_colors_send));
if (ptr_channel->dcc_chat)
@@ -175,15 +178,15 @@ irc_input_data (struct t_gui_buffer *buffer, char *data)
{
//irc_dcc_chat_sendf (ptr_channel->dcc_chat,
// "%s\r\n",
// (data_with_colors) ? data_with_colors : data);
// (data_with_colors) ? data_with_colors : input_data);
//irc_input_user_message_display (buffer,
// (data_with_colors) ?
// data_with_colors : data);
// data_with_colors : input_data);
}
}
else
irc_input_send_user_message (buffer,
(data_with_colors) ? data_with_colors : data);
(data_with_colors) ? data_with_colors : input_data);
if (data_with_colors)
free (data_with_colors);
@@ -194,4 +197,6 @@ irc_input_data (struct t_gui_buffer *buffer, char *data)
_("%s: this buffer is not a channel!"),
"irc");
}
return WEECHAT_RC_OK;
}
+2 -1
View File
@@ -20,6 +20,7 @@
#ifndef __WEECHAT_IRC_INPUT_H
#define __WEECHAT_IRC_INPUT_H 1
extern void irc_input_data (struct t_gui_buffer *buffer, char *data);
extern int irc_input_data (void *data, struct t_gui_buffer *buffer,
char *input_data);
#endif /* irc-input.h */
+2 -1
View File
@@ -2184,7 +2184,8 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
if (!server->buffer)
{
server->buffer = weechat_buffer_new (server->name, server->name, NULL);
server->buffer = weechat_buffer_new (server->name, server->name,
NULL, NULL);
if (!server->buffer)
return 0;
weechat_buffer_set (server->buffer, "display", "1");
+5 -1
View File
@@ -19,7 +19,11 @@ INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\"
noinst_LTLIBRARIES = lib_weechat_plugins_scripts.la
lib_weechat_plugins_scripts_la_SOURCES = script.c \
script.h
script.h \
script-callback.c \
script-callback.h \
script-api.c \
script-api.h
if PLUGIN_PERL
perl_dir = perl
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+41
View File
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2003-2008 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_SCRIPT_CALLBACK_H
#define __WEECHAT_SCRIPT_CALLBACK_H 1
struct t_script_callback
{
void *script; /* pointer to script */
char *function; /* script function called */
struct t_hook *hook; /* not NULL if hook */
struct t_gui_buffer *buffer; /* not NULL if buffer callback */
struct t_script_callback *prev_callback; /* link to next callback */
struct t_script_callback *next_callback; /* link to previous callback */
};
extern struct t_script_callback *script_callback_alloc ();
extern void script_callback_add (struct t_plugin_script *script,
struct t_script_callback *callback);
extern void script_callback_remove (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_script_callback *script_callback);
extern void script_callback_remove_all (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script);
#endif /* script-callback.h */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+7 -4
View File
@@ -261,8 +261,10 @@ struct t_weechat_plugin
/* buffers */
struct t_gui_buffer *(*buffer_new) (struct t_weechat_plugin *plugin,
char *category, char *name,
void (*callback_input_data)(struct t_gui_buffer *buffer,
char *data));
int (*input_callback)(void *data,
struct t_gui_buffer *buffer,
char *input_data),
void *input_callback_data);
struct t_gui_buffer *(*buffer_search) (char *category, char *name);
void (*buffer_close) (struct t_gui_buffer *buffer, int switch_to_another);
void *(*buffer_get) (struct t_gui_buffer *buffer, char *property);
@@ -532,9 +534,10 @@ struct t_weechat_plugin
weechat_plugin->unhook_all_plugin(weechat_plugin)
/* buffers */
#define weechat_buffer_new(__category, __name, __callback_input_data) \
#define weechat_buffer_new(__category, __name, __input_callback, \
__input_callback_data) \
weechat_plugin->buffer_new(weechat_plugin, __category, __name, \
__callback_input_data)
__input_callback, __input_callback_data)
#define weechat_buffer_search(__category, __name) \
weechat_plugin->buffer_search(__category, __name)
#define weechat_current_buffer \