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

Many changes in IRC plugin

This commit is contained in:
Sebastien Helleu
2007-12-10 17:18:40 +01:00
parent 8b3980f508
commit 256557f900
27 changed files with 1374 additions and 1252 deletions
+51 -48
View File
File diff suppressed because it is too large Load Diff
+7 -1
View File
@@ -89,6 +89,7 @@ struct t_config_option *config_look_day_change_time_format;
struct t_config_option *config_look_read_marker;
struct t_config_option *config_look_input_format;
struct t_config_option *config_look_paste_max_lines;
struct t_config_option *config_look_default_msg_quit;
/* config, colors section */
@@ -600,7 +601,12 @@ config_weechat_init ()
N_("max number of lines for paste without asking user "
"(0 = disable this feature)"),
NULL, 0, INT_MAX, "3", NULL);
config_look_default_msg_quit = config_file_new_option (
ptr_section, "look_default_msg_quit", "string",
N_("default quit message ('%v' will be replaced by WeeChat version in "
"string)"),
NULL, 0, 0, "WeeChat %v", NULL);
/* colors */
ptr_section = config_file_new_section (weechat_config_file, "colors",
NULL, NULL, NULL);
+1
View File
@@ -83,6 +83,7 @@ extern struct t_config_option *config_look_day_change_time_format;
extern struct t_config_option *config_look_read_marker;
extern struct t_config_option *config_look_input_format;
extern struct t_config_option *config_look_paste_max_lines;
extern struct t_config_option *config_look_default_msg_quit;
extern struct t_config_option *config_color_separator;
extern struct t_config_option *config_color_title;
+14
View File
@@ -29,6 +29,7 @@
#include "../../core/weechat.h"
#include "../../core/wee-config.h"
#include "../../core/wee-utf8.h"
#include "../../plugins/plugin.h"
#include "../gui-status.h"
#include "../gui-color.h"
#include "../gui-main.h"
@@ -77,6 +78,19 @@ gui_status_draw (struct t_gui_buffer *buffer, int erase)
GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
/* display buffer plugin */
if (ptr_win->buffer->plugin)
{
wprintw (GUI_CURSES(ptr_win)->win_status, "[");
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS);
wprintw (GUI_CURSES(ptr_win)->win_status, "%s",
ptr_win->buffer->plugin->name);
gui_window_set_weechat_color (GUI_CURSES(ptr_win)->win_status,
GUI_COLOR_STATUS_DELIMITERS);
wprintw (GUI_CURSES(ptr_win)->win_status, "] ");
}
/* display buffer category */
if (ptr_win->buffer->category)
{
+8 -7
View File
@@ -38,6 +38,7 @@
#include "../core/wee-log.h"
#include "../core/wee-string.h"
#include "../core/wee-utf8.h"
#include "../plugins/plugin.h"
#include "gui-buffer.h"
#include "gui-chat.h"
#include "gui-color.h"
@@ -49,7 +50,6 @@
#include "gui-nicklist.h"
#include "gui-status.h"
#include "gui-window.h"
#include "../plugins/plugin.h"
struct t_gui_buffer *gui_buffers = NULL; /* first buffer */
@@ -92,7 +92,7 @@ gui_buffer_new (void *plugin, char *category, char *name,
if ((new_buffer = (struct t_gui_buffer *)(malloc (sizeof (struct t_gui_buffer)))))
{
/* init buffer */
new_buffer->plugin = (struct t_weechat_plugin *)plugin;
new_buffer->plugin = plugin;
new_buffer->number = (last_gui_buffer) ? last_gui_buffer->number + 1 : 1;
new_buffer->category = (category) ? strdup (category) : NULL;
new_buffer->name = strdup (name);
@@ -212,12 +212,11 @@ gui_buffer_valid (struct t_gui_buffer *buffer)
* gui_buffer_get: get a buffer property
*/
char *
void *
gui_buffer_get (struct t_gui_buffer *buffer, char *property)
{
long number;
char *error;
if (string_strcasecmp (property, "plugin") == 0)
return buffer->plugin;
if (string_strcasecmp (property, "category") == 0)
return buffer->category;
else if (string_strcasecmp (property, "name") == 0)
@@ -225,7 +224,9 @@ gui_buffer_get (struct t_gui_buffer *buffer, char *property)
else if (string_strcasecmp (property, "title") == 0)
return buffer->title;
else if (string_strcasecmp (property, "nick") == 0)
return buffer->nick;
return buffer->input_nick;
return NULL;
}
/*
+2 -2
View File
@@ -63,7 +63,7 @@ struct t_gui_nick
struct t_gui_buffer
{
void *plugin; /* plugin which created this buffer */
struct t_weechat_plugin *plugin; /* plugin which created this buffer */
/* (NULL for a WeeChat buffer) */
int number; /* buffer number (for jump/switch) */
char *category; /* category name */
@@ -142,7 +142,7 @@ extern struct t_gui_buffer *gui_buffer_before_raw_data;
extern struct t_gui_buffer *gui_buffer_new (void *, char *, char *,
void (*)(struct t_gui_buffer *, char *));
extern int gui_buffer_valid (struct t_gui_buffer *);
extern char *gui_buffer_get (struct t_gui_buffer *, char *);
extern void *gui_buffer_get (struct t_gui_buffer *, char *);
extern void gui_buffer_set_category (struct t_gui_buffer *, char *);
extern void gui_buffer_set_name (struct t_gui_buffer *, char *);
extern void gui_buffer_set_log (struct t_gui_buffer *, char *);
+1
View File
@@ -43,6 +43,7 @@
char *gui_chat_prefix[GUI_CHAT_PREFIX_NUMBER]; /* prefixes */
char gui_chat_prefix_empty[] = ""; /* empty prefix */
int gui_chat_time_length = 0; /* length of time for each line (in chars) */
+1
View File
@@ -38,6 +38,7 @@ enum t_gui_prefix
};
extern char *gui_chat_prefix[GUI_CHAT_PREFIX_NUMBER];
extern char gui_chat_prefix_empty[];
extern int gui_chat_time_length;
/* chat functions */
+1 -1
View File
@@ -552,7 +552,7 @@ alias_config_reload_event_cb (void *data, char *event, void *pointer)
if (weechat_config_reload (alias_config_file) == 0)
{
weechat_printf (NULL,
_("%sAlias configuration file reloaded"),
_("%sAlias: configuration file reloaded"),
weechat_prefix ("info"));
return PLUGIN_RC_SUCCESS;
}
+3 -3
View File
@@ -34,6 +34,8 @@ irc_la_SOURCES = irc.c \
irc-display.h \
irc-nick.c \
irc-nick.h \
irc-protocol.c \
irc-protocol.h \
irc-server.c \
irc-server.h
@@ -43,9 +45,7 @@ irc_la_SOURCES = irc.c \
# irc-dcc.h \
# irc-input.c \
# irc-log.c \
# irc-mode.c \
# irc-protocol.c \
# irc-protocol.h
# irc-mode.c
irc_la_LDFLAGS = -module
irc_la_LIBADD = $(GNUTLS_LFLAGS)
+1 -1
View File
@@ -51,7 +51,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
if ((new_channel = (struct t_irc_channel *) malloc (sizeof (struct t_irc_channel))) == NULL)
{
weechat_printf (NULL,
_("%sIrc: cannot allocate new channel"),
_("%sirc: cannot allocate new channel"),
weechat_prefix ("error"));
return NULL;
}
File diff suppressed because it is too large Load Diff
+28 -9
View File
@@ -20,18 +20,37 @@
#ifndef __WEECHAT_IRC_COMMAND_H
#define __WEECHAT_IRC_COMMAND_H 1
#define IRC_COMMAND_GET_SERVER(buffer) \
struct t_irc_server *ptr_server = irc_server_search ( \
weechat_buffer_get (buffer, "category"))
#include "irc-server.h"
#define IRC_COMMAND_GET_SERVER_CHANNEL(buffer) \
struct t_irc_server *ptr_server = irc_server_search ( \
weechat_buffer_get (buffer, "category")); \
struct t_irc_channel *ptr_channel = irc_channel_search ( \
ptr_server, \
weechat_buffer_get (buffer, "name"))
#define IRC_COMMAND_GET_SERVER(__buffer) \
struct t_weechat_plugin *buffer_plugin = NULL; \
struct t_irc_server *ptr_server = NULL; \
buffer_plugin = weechat_buffer_get (__buffer, "plugin"); \
if (buffer_plugin == weechat_irc_plugin) \
ptr_server = irc_server_search ( \
weechat_buffer_get (__buffer, "category"));
#define IRC_COMMAND_GET_SERVER_CHANNEL(__buffer) \
struct t_weechat_plugin *buffer_plugin = NULL; \
struct t_irc_server *ptr_server = NULL; \
struct t_irc_channel *ptr_channel = NULL; \
buffer_plugin = weechat_buffer_get (__buffer, "plugin"); \
if (buffer_plugin == weechat_irc_plugin) \
{ \
ptr_server = irc_server_search ( \
weechat_buffer_get (__buffer, "category")); \
ptr_channel = irc_channel_search ( \
ptr_server, weechat_buffer_get (__buffer, "name")); \
}
#define IRC_COMMAND_TOO_FEW_ARGUMENTS(__buffer, __command) \
weechat_printf (__buffer, \
_("%sirc: too few arguments for \"%s\" command"), \
weechat_prefix ("error"), __command); \
return PLUGIN_RC_FAILED;
extern void irc_command_quit_server (struct t_irc_server *, char *);
extern void irc_command_init ();
#endif /* irc-command.h */
+14 -15
View File
@@ -47,7 +47,6 @@ struct t_config_option *irc_config_irc_nick_suffix;
struct t_config_option *irc_config_irc_display_away;
struct t_config_option *irc_config_irc_show_away_once;
struct t_config_option *irc_config_irc_default_msg_part;
struct t_config_option *irc_config_irc_default_msg_quit;
struct t_config_option *irc_config_irc_notice_as_pv;
struct t_config_option *irc_config_irc_away_check;
struct t_config_option *irc_config_irc_away_check_max_nicks;
@@ -237,7 +236,7 @@ irc_config_read_server_line (void *config_file, char *option_name, char *value)
break;
case 0:
weechat_printf (NULL,
_("%sIrc: warning, failed to set option "
_("%sirc: warning, failed to set option "
"\"%s\" with value \"%s\""),
weechat_prefix ("error"),
option_name, value);
@@ -247,7 +246,7 @@ irc_config_read_server_line (void *config_file, char *option_name, char *value)
else
{
weechat_printf (NULL,
_("%sIrc: warning, option not found in config "
_("%sirc: warning, option not found in config "
"file: \"%s\""),
weechat_prefix ("error"),
option_name);
@@ -268,7 +267,7 @@ irc_config_read_server_line (void *config_file, char *option_name, char *value)
if (!irc_config_server)
{
weechat_printf (NULL,
_("%sIrc: error creating server for reading "
_("%sirc: error creating server for reading "
"config file"),
weechat_prefix ("error"));
}
@@ -448,11 +447,6 @@ irc_config_init ()
N_("default part message (leaving channel) ('%v' will be replaced by "
"WeeChat version in string)"),
NULL, 0, 0, "WeeChat %v", NULL);
irc_config_irc_default_msg_quit = weechat_config_new_option (
ptr_section, "irc_default_msg_quit", "string",
N_("default quit message ('%v' will be replaced by WeeChat version in "
"string)"),
NULL, 0, 0, "WeeChat %v", NULL);
irc_config_irc_notice_as_pv = weechat_config_new_option (
ptr_section, "irc_notice_as_pv", "boolean",
N_("display notices as private messages"),
@@ -725,15 +719,20 @@ irc_config_read ()
}
/*
* irc_config_reload: read IRC configuration file
* irc_config_reload_cb: read IRC configuration file
*/
int
irc_config_reload ()
irc_config_reload_cb (void *data, char *event, void *pointer)
{
struct t_irc_server *ptr_server, *next_server;
int rc;
/* make C compiler happy */
(void) data;
(void) event;
(void) pointer;
irc_config_server = NULL;
irc_config_reload_flag = 1;
for (ptr_server = irc_servers; ptr_server;
@@ -762,7 +761,7 @@ irc_config_reload ()
if (ptr_server->is_connected)
{
weechat_printf (NULL,
_("%sIrc: warning: server \"%s\" not found in "
_("%sirc: warning: server \"%s\" not found in "
"configuration file, but was not deleted "
"(currently used)"),
weechat_prefix ("info"),
@@ -776,13 +775,13 @@ irc_config_reload ()
}
weechat_printf (NULL,
_("%sIrc configuration file reloaded"),
_("%sirc: configuration file reloaded"),
weechat_prefix ("info"));
return PLUGIN_RC_SUCCESS;
}
weechat_printf (NULL,
_("%sIrc: failed to reload alias configuration "
_("%sirc: failed to reload alias configuration "
"file"),
weechat_prefix ("error"));
return PLUGIN_RC_FAILED;
+1 -1
View File
@@ -73,7 +73,7 @@ void irc_config_change_log ();
void irc_config_change_notify_levels ();
int irc_config_init ();
int irc_config_read ();
int irc_config_reload ();
int irc_config_reload_cb ();
int irc_config_write ();
#endif /* irc-config.h */
+1 -1
View File
@@ -380,7 +380,7 @@ irc_dcc_free (struct t_irc_dcc *ptr_dcc)
{
/* check if channel is used for another active DCC CHAT */
if (!ptr_dcc->channel->dcc_chat
|| (IRC_DCC_ENDED(((struct t_irc_dcc *)(ptr_dcc->channel->dcc_chat))->status)))
|| (IRC_DCC_ENDED(ptr_dcc->channel->dcc_chat->status)))
{
gui_buffer_free (ptr_dcc->channel->buffer, 1);
if (ptr_dcc->channel)
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -166,7 +166,7 @@ irc_input_data (t_gui_window *window, char *data)
if (ptr_channel->dcc_chat)
{
if (((t_irc_dcc *)(ptr_channel->dcc_chat))->sock < 0)
if (ptr_channel->dcc_chat->sock < 0)
{
gui_chat_printf_error_nolog (window->buffer,
"%s DCC CHAT is closed\n",
@@ -174,7 +174,7 @@ irc_input_data (t_gui_window *window, char *data)
}
else
{
irc_dcc_chat_sendf ((t_irc_dcc *)(ptr_channel->dcc_chat),
irc_dcc_chat_sendf (ptr_channel->dcc_chat,
"%s\r\n",
(data_with_colors) ? data_with_colors : data);
irc_input_user_message_display (window,
File diff suppressed because it is too large Load Diff
+3 -6
View File
@@ -30,13 +30,10 @@
#include <wctype.h>
#include <sys/utsname.h>
#include "../../core/weechat.h"
#include "irc.h"
#include "../../core/alias.h"
#include "../../core/command.h"
#include "../../core/utf8.h"
#include "../../core/util.h"
#include "../../core/weechat-config.h"
#include "irc-protocol.h"
#include "irc-server.h"
#include "irc-channel.h"
struct t_irc_protocol_msg irc_protocol_messages[] =
File diff suppressed because it is too large Load Diff
+37 -6
View File
@@ -30,6 +30,7 @@
#endif
#include "irc.h"
#include "irc-command.h"
#include "irc-config.h"
#include "irc-server.h"
@@ -112,6 +113,30 @@ irc_create_directories ()
}
}
/*
* irc_quit_cb: callback for event "quit"
*/
int
irc_quit_cb (void *data, char *event, void *pointer)
{
struct t_irc_server *ptr_server;
/* make C compiler happy */
(void) data;
(void) event;
(void) pointer;
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
irc_command_quit_server (ptr_server, (char *)pointer);
}
return PLUGIN_RC_SUCCESS;
}
/*
* weechat_plugin_init: initialize IRC plugin
*/
@@ -136,18 +161,24 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
irc_create_directories ();
weechat_hook_event ("config_reload", irc_config_reload, NULL);
irc_command_init ();
weechat_hook_event ("config_reload", &irc_config_reload_cb, NULL);
weechat_hook_event ("quit", &irc_quit_cb, NULL);
//irc_server_auto_connect (1, 0);
/*irc_timer = weechat_hook_timer (1 * 1000, 0,
irc_server_timer,
/*
irc_timer = weechat_hook_timer (1 * 1000, 0,
&irc_server_timer,
NULL);
if (irc_cfg_irc_away_check != 0)
irc_timer_check_away = weechat_hook_timer (irc_cfg_irc_away_check * 60 * 1000,
0,
irc_server_timer_check_away,
NULL);*/
&irc_server_timer_check_away,
NULL);
*/
return PLUGIN_RC_SUCCESS;
}
+1 -2
View File
@@ -34,8 +34,7 @@
#define IRC_COLOR_CHAT_NICK weechat_color("color_chat_nick")
#define IRC_COLOR_CHAT_SERVER weechat_color("color_chat_server")
extern struct t_weechat_plugin *weechat_plugin;
extern struct t_weechat_plugin *weechat_plugin;
extern struct t_weechat_plugin *weechat_irc_plugin;
extern struct t_hook *irc_timer_check_away;
extern gnutls_certificate_credentials gnutls_xcred;
+17 -5
View File
@@ -161,6 +161,20 @@ plugin_api_strncasecmp (struct t_weechat_plugin *plugin,
return string_strncasecmp (string1, string2, max);
}
/*
* plugin_api_strcasestr: locale and case independent string search
*/
char *
plugin_api_strcasestr (struct t_weechat_plugin *plugin,
char *string1, char *string2)
{
/* make C compiler happy */
(void) plugin;
return string_strcasestr (string1, string2);
}
/*
* plugin_api_string_replace: replace a string by new one in a string
*/
@@ -919,10 +933,8 @@ plugin_api_plugin_config_set (struct t_weechat_plugin *plugin,
char *
plugin_api_prefix (struct t_weechat_plugin *plugin, char *prefix)
{
static char empty_prefix[] = "";
if (!plugin || !prefix)
return empty_prefix;
return gui_chat_prefix_empty;
if (string_strcasecmp (prefix, "info") == 0)
return gui_chat_prefix[GUI_CHAT_PREFIX_INFO];
@@ -937,7 +949,7 @@ plugin_api_prefix (struct t_weechat_plugin *plugin, char *prefix)
if (string_strcasecmp (prefix, "quit") == 0)
return gui_chat_prefix[GUI_CHAT_PREFIX_QUIT];
return empty_prefix;
return gui_chat_prefix_empty;
}
/*
@@ -1275,7 +1287,7 @@ plugin_api_buffer_close (struct t_weechat_plugin *plugin, void *buffer)
* plugin_api_buffer_get: get a buffer property
*/
char *
void *
plugin_api_buffer_get (struct t_weechat_plugin *plugin, void *buffer,
char *property)
{
+2 -1
View File
@@ -32,6 +32,7 @@ extern char *plugin_api_ngettext (struct t_weechat_plugin *, char *, char *,
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_strcasestr (struct t_weechat_plugin *,char *, char *);
extern char *plugin_api_string_replace (struct t_weechat_plugin *,char *,
char *, char *);
extern char **plugin_api_string_explode (struct t_weechat_plugin *, char *,
@@ -160,7 +161,7 @@ extern struct t_gui_buffer *plugin_api_buffer_new (struct t_weechat_plugin *,
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 char *plugin_api_buffer_get (struct t_weechat_plugin *, void *, char *);
extern void *plugin_api_buffer_get (struct t_weechat_plugin *, void *, char *);
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 *,
+2
View File
@@ -230,6 +230,7 @@ plugin_load (char *filename)
new_plugin->ngettext = &plugin_api_ngettext;
new_plugin->strcasecmp = &plugin_api_strcasecmp;
new_plugin->strncasecmp = &plugin_api_strncasecmp;
new_plugin->strcasestr = &plugin_api_strcasestr;
new_plugin->string_replace = &plugin_api_string_replace;
new_plugin->string_explode = &plugin_api_string_explode;
new_plugin->string_free_exploded = &plugin_api_string_free_exploded;
@@ -296,6 +297,7 @@ plugin_load (char *filename)
new_plugin->buffer_new = &plugin_api_buffer_new;
new_plugin->buffer_search = &plugin_api_buffer_search;
new_plugin->buffer_close = &plugin_api_buffer_close;
new_plugin->buffer_get = &plugin_api_buffer_get;
new_plugin->buffer_set = &plugin_api_buffer_set;
new_plugin->buffer_nick_add = &plugin_api_buffer_nick_add;
new_plugin->buffer_nick_remove = &plugin_api_buffer_nick_remove;
+4 -1
View File
@@ -63,6 +63,7 @@ struct t_weechat_plugin
char *(*ngettext) (struct t_weechat_plugin *, char *, char *, int);
int (*strcasecmp) (struct t_weechat_plugin *, char *, char *);
int (*strncasecmp) (struct t_weechat_plugin *, char *, char *, int);
char *(*strcasestr) (struct t_weechat_plugin *, char *, char *);
char *(*string_replace) (struct t_weechat_plugin *, char *, char *, char *);
char **(*string_explode) (struct t_weechat_plugin *, char *, char *, int,
int, int *);
@@ -168,7 +169,7 @@ struct t_weechat_plugin
struct t_gui_buffer *(*buffer_search) (struct t_weechat_plugin *,
char *, char *);
void (*buffer_close) (struct t_weechat_plugin *, void *);
char *(*buffer_get) (struct t_weechat_plugin *, void *, char *);
void *(*buffer_get) (struct t_weechat_plugin *, void *, char *);
void (*buffer_set) (struct t_weechat_plugin *, void *, char *, char *);
void (*buffer_nick_add) (struct t_weechat_plugin *, void *, char *, int,
char *, char, char *);
@@ -220,6 +221,8 @@ struct t_weechat_plugin
#define weechat_strncasecmp(__string1, __string2, __max) \
weechat_plugin->strncasecmp(weechat_plugin, __string1, \
__string2, __max)
#define weechat_strcasestr(__string1, __string2) \
weechat_plugin->strcasestr(weechat_plugin, __string1, __string2)
#define weechat_string_replace(__string1, __search1, __replace1) \
weechat_plugin->string_replace(weechat_plugin, __string1, \
__search1, __replace1)