1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 04:16:38 +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
@@ -103,7 +103,7 @@ command_buffer (void *data, void *buffer,
"command"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
"buffer");
return -1;
return PLUGIN_RC_FAILED;
}
error = NULL;
@@ -127,7 +127,7 @@ command_buffer (void *data, void *buffer,
gui_chat_printf (NULL,
_("%sError: incorrect buffer number"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
return -1;
return PLUGIN_RC_FAILED;
}
}
else if (string_strcasecmp (argv[1], "close") == 0)
@@ -138,7 +138,7 @@ command_buffer (void *data, void *buffer,
_("%sError: WeeChat main buffer can't be "
"closed"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
return -1;
return PLUGIN_RC_FAILED;
}
gui_buffer_free (buffer, 1);
gui_status_draw (gui_current_window->buffer, 1);
@@ -179,7 +179,7 @@ command_buffer (void *data, void *buffer,
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
GUI_BUFFER_NOTIFY_LEVEL_MIN,
GUI_BUFFER_NOTIFY_LEVEL_MAX);
return -1;
return PLUGIN_RC_FAILED;
}
gui_chat_printf (NULL,
_("%sNew notify level for %s%s%s: "
@@ -225,7 +225,7 @@ command_buffer (void *data, void *buffer,
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
GUI_BUFFER_NOTIFY_LEVEL_MIN,
GUI_BUFFER_NOTIFY_LEVEL_MAX);
return -1;
return PLUGIN_RC_FAILED;
}
}
}
@@ -240,7 +240,7 @@ command_buffer (void *data, void *buffer,
"command"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
"buffer");
return -1;
return PLUGIN_RC_FAILED;
}
value = string_remove_quotes (argv_eol[3], "'\"");
gui_buffer_set (buffer, argv[2], (value) ? value : argv_eol[3]);
@@ -313,7 +313,7 @@ command_buffer (void *data, void *buffer,
}
}
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
@@ -346,7 +346,7 @@ command_builtin (void *data, void *buffer,
}
}
}
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
@@ -388,7 +388,7 @@ command_clear (void *data, void *buffer,
else
gui_buffer_clear (buffer);
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
@@ -467,11 +467,11 @@ command_debug (void *data, void *buffer,
_("%sError: unknown option for \"%s\" command"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
"debug");
return -1;
return PLUGIN_RC_FAILED;
}
}
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
@@ -587,7 +587,7 @@ command_help (void *data, void *buffer,
gui_chat_printf (NULL, "%s",
HOOK_COMMAND(ptr_hook, args_description));
}
return 0;
return PLUGIN_RC_SUCCESS;
}
}
gui_chat_printf (NULL,
@@ -597,7 +597,7 @@ command_help (void *data, void *buffer,
argv[1]);
break;
}
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
@@ -622,7 +622,7 @@ command_history (void *data, void *buffer,
if (string_strcasecmp (argv[1], "clear") == 0)
{
gui_history_buffer_free (buffer);
return 0;
return PLUGIN_RC_SUCCESS;
}
else
n_user = atoi (argv[1]);
@@ -652,7 +652,7 @@ command_history (void *data, void *buffer,
}
}
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
@@ -716,7 +716,7 @@ command_key (void *data, void *buffer,
{
command_key_display (ptr_key, 0);
}
return 0;
return PLUGIN_RC_SUCCESS;
}
if (string_strcasecmp (argv[1], "functions") == 0)
@@ -732,7 +732,7 @@ command_key (void *data, void *buffer,
_(gui_key_functions[i].description));
i++;
}
return 0;
return PLUGIN_RC_SUCCESS;
}
if (string_strcasecmp (argv[1], "reset") == 0)
@@ -751,9 +751,9 @@ command_key (void *data, void *buffer,
_("%sError: \"-yes\" argument is required for "
"keys reset (security reason)"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
return -1;
return PLUGIN_RC_FAILED;
}
return 0;
return PLUGIN_RC_SUCCESS;
}
if (string_strcasecmp (argv[1], "unbind") == 0)
@@ -773,10 +773,10 @@ command_key (void *data, void *buffer,
_("%sError: unable to unbind key \"%s\""),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
argv[2]);
return -1;
return PLUGIN_RC_FAILED;
}
}
return 0;
return PLUGIN_RC_SUCCESS;
}
if (string_strcasecmp (argv[1], "call") == 0)
@@ -802,10 +802,10 @@ command_key (void *data, void *buffer,
_("%sError: unknown key function \"%s\""),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
argv[2]);
return -1;
return PLUGIN_RC_FAILED;
}
}
return 0;
return PLUGIN_RC_SUCCESS;
}
/* display a key */
@@ -828,7 +828,7 @@ command_key (void *data, void *buffer,
}
if (internal_code)
free (internal_code);
return 0;
return PLUGIN_RC_SUCCESS;
}
/* bind new key */
@@ -841,9 +841,9 @@ command_key (void *data, void *buffer,
_("%sError: unable to bind key \"%s\""),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
argv[1]);
return -1;
return PLUGIN_RC_FAILED;
}
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
@@ -1122,7 +1122,7 @@ command_plugin (void *data, void *buffer,
"plugin");
}
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
@@ -1138,11 +1138,14 @@ command_quit (void *data, void *buffer,
(void) buffer;
(void) argc;
(void) argv;
(void) argv_eol;
hook_event_exec ("quit",
(argc > 1) ?
argv_eol[1] : CONFIG_STRING(config_look_default_msg_quit));
quit_weechat = 1;
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
@@ -1183,7 +1186,7 @@ command_reload (void *data, void *buffer,
/* tell to plugins to reload their configuration */
(void) hook_event_exec ("config_reload", NULL);
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
@@ -1221,7 +1224,7 @@ command_save (void *data, void *buffer,
_("%sError: failed to save plugins options"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
@@ -1393,7 +1396,7 @@ command_set (void *data, void *buffer,
number_found,
GUI_COLOR(GUI_COLOR_CHAT));
}
return 0;
return PLUGIN_RC_SUCCESS;
}
/* set option value */
@@ -1407,7 +1410,7 @@ command_set (void *data, void *buffer,
"found"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
argv[1]);
return -1;
return PLUGIN_RC_FAILED;
}
value = string_remove_quotes (argv_eol[3], "'\"");
rc = config_file_option_set (ptr_option,
@@ -1429,11 +1432,11 @@ command_set (void *data, void *buffer,
"option \"%s\""),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
argv[1]);
return -1;
return PLUGIN_RC_FAILED;
}
}
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
@@ -1519,7 +1522,7 @@ command_setp (void *data, void *buffer,
argv[1]);
if (pos)
pos[0] = '.';
return -1;
return PLUGIN_RC_FAILED;
}
else
ptr_name = argv[1];
@@ -1546,14 +1549,14 @@ command_setp (void *data, void *buffer,
ptr_name);
if (value)
free (value);
return -1;
return PLUGIN_RC_FAILED;
}
if (value)
free (value);
}
}
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
@@ -1585,7 +1588,7 @@ command_upgrade (void *data, void *buffer,
gui_chat_printf_error (NULL,
_("Error: can't upgrade: connection to at least "
"one server is pending"));
return -1;
return PLUGIN_RC_FAILED;
}*/
/* TODO: remove this test, and fix gnutls save/load in session */
/*if (ptr_server->is_connected && ptr_server->ssl_connected)
@@ -1594,14 +1597,14 @@ command_upgrade (void *data, void *buffer,
_("Error: can't upgrade: connection to at least "
"one SSL server is active "
"(should be fixed in a future version)"));
return -1;
return PLUGIN_RC_FAILED;
}
if (ptr_server->outqueue)
{
gui_chat_printf_error_nolog (NULL,
_("Error: can't upgrade: anti-flood is active on "
"at least one server (sending many lines)"));
return -1;
return PLUGIN_RC_FAILED;
}
}
@@ -1620,7 +1623,7 @@ command_upgrade (void *data, void *buffer,
free (filename);
gui_chat_printf_error_nolog (NULL,
_("Error: unable to save session in file"));
return -1;
return PLUGIN_RC_FAILED;
}
exec_args[0] = strdup (ptr_binary);
@@ -1651,7 +1654,7 @@ command_upgrade (void *data, void *buffer,
exit (EXIT_FAILURE);*/
/* never executed */
return -1;
return PLUGIN_RC_FAILED;
}
/*
@@ -1712,7 +1715,7 @@ command_uptime (void *data, void *buffer,
ctime (&weechat_start_time));
}
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
@@ -1815,7 +1818,7 @@ command_window (void *data, void *buffer,
"command"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
"window merge");
return -1;
return PLUGIN_RC_FAILED;
}
}
else
@@ -1827,7 +1830,7 @@ command_window (void *data, void *buffer,
"there's no other window with same "
"size near current one."),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
return -1;
return PLUGIN_RC_FAILED;
}
}
}
@@ -1862,10 +1865,10 @@ command_window (void *data, void *buffer,
_("%sError: unknown option for \"%s\" command"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
"window");
return -1;
return PLUGIN_RC_FAILED;
}
}
return 0;
return PLUGIN_RC_SUCCESS;
}
/*
+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)
+141 -140
View File
@@ -28,11 +28,11 @@
#include <stdio.h>
#include <string.h>
#include "../../core/weechat.h"
#include "irc.h"
#include "../../core/utf8.h"
#include "../../core/weechat-config.h"
#include "../../gui/gui.h"
#include "irc-command.h"
#include "irc-config.h"
#include "irc-server.h"
#include "irc-nick.h"
/*
@@ -92,9 +92,19 @@ irc_display_hide_password (char *string, int look_for_nickserv)
*/
void
irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
int type, int display_around, char *force_color, int no_nickmode)
irc_display_nick (struct t_gui_buffer *buffer, struct t_irc_nick *nick,
char *nickname, int type, int display_around,
char *force_color, int no_nickmode)
{
(void) buffer;
(void) nick;
(void) nickname;
(void) type;
(void) display_around;
(void) force_color;
(void) no_nickmode;
/*
char format[32], *ptr_nickname;
t_irc_server *ptr_server;
t_irc_channel *ptr_channel;
@@ -117,7 +127,7 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
&& ((int)strlen (cfg_look_nick_prefix) +
(int)strlen (cfg_look_nick_suffix) > max_align - 4));
/* calculate length to display, to truncate it if too long */
// calculate length to display, to truncate it if too long
length = nickname_length;
if (!disable_prefix_suffix && cfg_look_nick_prefix)
length += strlen (cfg_look_nick_prefix);
@@ -135,7 +145,7 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
if (!disable_prefix_suffix && cfg_look_nick_suffix)
length += strlen (cfg_look_nick_suffix);
/* calculate number of spaces to insert before or after nick */
// calculate number of spaces to insert before or after nick
spaces = 0;
if (cfg_look_align_nick != CFG_LOOK_ALIGN_NICK_NONE)
{
@@ -147,7 +157,7 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
spaces = cfg_look_align_size - length;
}
/* display prefix */
// display prefix
if (display_around && !disable_prefix_suffix
&& cfg_look_nick_prefix && cfg_look_nick_prefix[0])
gui_chat_printf_type (buffer, type, NULL, -1,
@@ -155,7 +165,7 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
cfg_look_nick_prefix);
/* display spaces before nick, if needed */
// display spaces before nick, if needed
if (display_around
&& (cfg_look_align_nick == CFG_LOOK_ALIGN_NICK_RIGHT)
&& (spaces > 0))
@@ -164,7 +174,7 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
gui_chat_printf_type (buffer, type, NULL, -1, format, " ");
}
/* display nick mode */
// display nick mode
if (nick && cfg_look_nickmode)
{
if (nick->flags & IRC_NICK_CHANOWNER)
@@ -193,7 +203,7 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
GUI_COLOR(GUI_COLOR_CHAT));
}
/* display nick */
// display nick
if (external_nick)
gui_chat_printf_type (buffer, type, NULL, -1, "%s%s",
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
@@ -233,7 +243,7 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
")");
/* display spaces after nick, if needed */
// display spaces after nick, if needed
if (display_around
&& (cfg_look_align_nick == CFG_LOOK_ALIGN_NICK_LEFT)
&& (spaces > 0))
@@ -242,7 +252,7 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
gui_chat_printf_type (buffer, type, NULL, -1, format, " ");
}
/* display suffix */
// display suffix
if (display_around && !disable_prefix_suffix
&& cfg_look_nick_suffix && cfg_look_nick_suffix[0])
gui_chat_printf_type (buffer, type, NULL, -1, "%s%s",
@@ -253,6 +263,7 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
GUI_NO_COLOR,
(display_around) ? " " : "");
free (ptr_nickname);
*/
}
/*
@@ -260,33 +271,24 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname,
*/
void
irc_display_away (t_irc_server *server, char *string1, char *string2)
irc_display_away (struct t_irc_server *server, char *string1, char *string2)
{
t_irc_channel *ptr_channel;
char format[32];
struct t_irc_channel *ptr_channel;
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
{
if (cfg_look_align_other)
{
snprintf (format, 32, "%%-%ds", cfg_look_align_size + 1);
gui_chat_printf_type (ptr_channel->buffer, GUI_MSG_TYPE_NICK,
NULL, -1,
format, " ");
}
gui_chat_printf_nolog (ptr_channel->buffer,
NULL, -1,
"%s[%s%s%s %s: %s%s]\n",
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_NICK),
server->nick,
GUI_COLOR(GUI_COLOR_CHAT),
string1,
string2,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
weechat_printf (ptr_channel->buffer,
"%s[%s%s%s %s: %s%s]",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
server->nick,
IRC_COLOR_CHAT,
string1,
string2,
IRC_COLOR_CHAT_DELIMITERS);
}
}
}
@@ -296,34 +298,29 @@ irc_display_away (t_irc_server *server, char *string1, char *string2)
*/
void
irc_display_mode (t_gui_buffer *buffer,
irc_display_mode (struct t_gui_buffer *buffer,
char *channel_name, char *nick_name, char set_flag,
char *symbol, char *nick_host, char *message, char *param)
{
gui_chat_printf_info (buffer,
"%s[%s%s%s/%s%c%s%s] %s%s",
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
(channel_name) ?
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL) :
GUI_COLOR(GUI_COLOR_CHAT_NICK),
(channel_name) ? channel_name : nick_name,
GUI_COLOR(GUI_COLOR_CHAT),
GUI_COLOR(GUI_COLOR_CHAT_CHANNEL),
set_flag,
symbol,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT_NICK),
nick_host);
if (param)
gui_chat_printf (buffer, " %s%s %s%s\n",
GUI_COLOR(GUI_COLOR_CHAT),
message,
GUI_COLOR(GUI_COLOR_CHAT_NICK),
param);
else
gui_chat_printf (buffer, " %s%s\n",
GUI_COLOR(GUI_COLOR_CHAT),
message);
weechat_printf (buffer,
"%s[%s%s%s/%s%c%s%s] %s%s %s%s%s%s%s",
IRC_COLOR_CHAT_DELIMITERS,
(channel_name) ?
IRC_COLOR_CHAT_CHANNEL :
IRC_COLOR_CHAT_NICK,
(channel_name) ? channel_name : nick_name,
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_CHANNEL,
set_flag,
symbol,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
nick_host,
IRC_COLOR_CHAT,
message,
(param) ? " " : "",
(param) ? IRC_COLOR_CHAT_NICK : "",
(param) ? param : "");
}
/*
@@ -331,111 +328,115 @@ irc_display_mode (t_gui_buffer *buffer,
*/
void
irc_display_server (t_irc_server *server, int with_detail)
irc_display_server (struct t_irc_server *server, int with_detail)
{
char *string;
int num_channels, num_pv;
if (with_detail)
{
gui_chat_printf (NULL, "\n");
gui_chat_printf (NULL, _("%sServer: %s%s %s[%s%s%s]\n"),
GUI_COLOR(GUI_COLOR_CHAT),
GUI_COLOR(GUI_COLOR_CHAT_SERVER),
server->name,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT),
(server->is_connected) ?
_("connected") : _("not connected"),
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
weechat_printf (NULL, "");
weechat_printf (NULL, _("%sServer: %s%s %s[%s%s%s]"),
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_SERVER,
server->name,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
(server->is_connected) ?
_("connected") : _("not connected"),
IRC_COLOR_CHAT_DELIMITERS);
gui_chat_printf (NULL, " server_autoconnect . . . . : %s%s\n",
(server->autoconnect) ? _("on") : _("off"),
(server->temp_server) ?
_(" (temporary server, will not be saved)") : "");
gui_chat_printf (NULL, " server_autoreconnect . . . : %s\n",
(server->autoreconnect) ? _("on") : _("off"));
gui_chat_printf (NULL, " server_autoreconnect_delay : %d %s\n",
server->autoreconnect_delay,
_("seconds"));
gui_chat_printf (NULL, " server_address . . . . . . : %s\n",
server->address);
gui_chat_printf (NULL, " server_port . . . . . . . : %d\n",
server->port);
gui_chat_printf (NULL, " server_ipv6 . . . . . . . : %s\n",
(server->ipv6) ? _("on") : _("off"));
gui_chat_printf (NULL, " server_ssl . . . . . . . . : %s\n",
(server->ssl) ? _("on") : _("off"));
gui_chat_printf (NULL, " server_password . . . . . : %s\n",
(server->password && server->password[0]) ?
_("(hidden)") : "");
gui_chat_printf (NULL, " server_nick1/2/3 . . . . . : "
"%s %s/ %s%s %s/ %s%s\n",
server->nick1,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT),
server->nick2,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT),
server->nick3);
gui_chat_printf (NULL, " server_username . . . . . : %s\n",
server->username);
gui_chat_printf (NULL, " server_realname . . . . . : %s\n",
server->realname);
gui_chat_printf (NULL, " server_hostname . . . . . : %s\n",
(server->hostname) ? server->hostname : "");
weechat_printf (NULL, " server_autoconnect . . . . : %s%s",
(server->autoconnect) ? _("on") : _("off"),
(server->temp_server) ?
_(" (temporary server, will not be saved)") : "");
weechat_printf (NULL, " server_autoreconnect . . . : %s",
(server->autoreconnect) ? _("on") : _("off"));
weechat_printf (NULL, " server_autoreconnect_delay : %d %s",
server->autoreconnect_delay,
_("seconds"));
weechat_printf (NULL, " server_address . . . . . . : %s",
server->address);
weechat_printf (NULL, " server_port . . . . . . . : %d",
server->port);
weechat_printf (NULL, " server_ipv6 . . . . . . . : %s",
(server->ipv6) ? _("on") : _("off"));
weechat_printf (NULL, " server_ssl . . . . . . . . : %s",
(server->ssl) ? _("on") : _("off"));
weechat_printf (NULL, " server_password . . . . . : %s",
(server->password && server->password[0]) ?
_("(hidden)") : "");
weechat_printf (NULL,
" server_nick1/2/3 . . . . . : %s %s/ %s%s %s/ %s%s",
server->nick1,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
server->nick2,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
server->nick3);
weechat_printf (NULL, " server_username . . . . . : %s",
server->username);
weechat_printf (NULL, " server_realname . . . . . : %s",
server->realname);
weechat_printf (NULL, " server_hostname . . . . . : %s",
(server->hostname) ? server->hostname : "");
if (server->command && server->command[0])
string = strdup (server->command);
else
string = NULL;
if (string)
{
if (irc_cfg_log_hide_nickserv_pwd)
if (weechat_config_boolean (irc_config_log_hide_nickserv_pwd))
irc_display_hide_password (string, 1);
gui_chat_printf (NULL, " server_command . . . . . . : %s\n",
string);
weechat_printf (NULL, " server_command . . . . . . : %s",
string);
free (string);
}
else
gui_chat_printf (NULL, " server_command . . . . . . : %s\n",
(server->command && server->command[0]) ?
server->command : "");
gui_chat_printf (NULL, " server_command_delay . . . : %d %s\n",
server->command_delay,
_("seconds"));
gui_chat_printf (NULL, " server_autojoin . . . . . : %s\n",
(server->autojoin && server->autojoin[0]) ?
server->autojoin : "");
gui_chat_printf (NULL, " server_notify_levels . . . : %s\n",
(server->notify_levels && server->notify_levels[0]) ?
server->notify_levels : "");
weechat_printf (NULL, " server_command . . . . . . : %s",
(server->command && server->command[0]) ?
server->command : "");
weechat_printf (NULL, " server_command_delay . . . : %d %s",
server->command_delay,
_("seconds"));
weechat_printf (NULL, " server_autojoin . . . . . : %s",
(server->autojoin && server->autojoin[0]) ?
server->autojoin : "");
weechat_printf (NULL, " server_notify_levels . . . : %s",
(server->notify_levels && server->notify_levels[0]) ?
server->notify_levels : "");
}
else
{
gui_chat_printf (NULL, " %s %s%s ",
(server->is_connected) ? "*" : " ",
GUI_COLOR(GUI_COLOR_CHAT_SERVER),
server->name);
gui_chat_printf (NULL, "%s[%s%s",
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT),
(server->is_connected) ?
_("connected") : _("not connected"));
if (server->is_connected)
{
num_channels = irc_server_get_channel_count (server);
num_pv = irc_server_get_pv_count (server);
gui_chat_printf (NULL, ", ");
gui_chat_printf (NULL,
NG_("%d channel", "%d channels",
num_channels),
num_channels);
gui_chat_printf (NULL, ", ");
gui_chat_printf (NULL, _("%d pv"), num_pv);
weechat_printf (NULL, " %s %s%s %s[%s%s%s]%s%s, %d %s, %d pv",
(server->is_connected) ? "*" : " ",
IRC_COLOR_CHAT_SERVER,
server->name,
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
(server->is_connected) ?
_("connected") : _("not connected"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
(server->temp_server) ? _(" (temporary)") : "",
num_channels,
NG_("channel", "channels",
num_channels),
num_pv);
}
else
{
weechat_printf (NULL, " %s %s%s%s%s",
(server->is_connected) ? "*" : " ",
IRC_COLOR_CHAT_SERVER,
server->name,
IRC_COLOR_CHAT,
(server->temp_server) ? _(" (temporary)") : "");
}
gui_chat_printf (NULL, "%s]%s%s\n",
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT),
(server->temp_server) ? _(" (temporary)") : "");
}
}
+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,
+49 -16
View File
@@ -121,15 +121,27 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
int is_chanadmin2, int is_op, int is_halfop, int has_voice,
int is_chanuser)
{
(void) server;
(void) channel;
(void) nick_name;
(void) is_chanowner;
(void) is_chanadmin;
(void) is_chanadmin2;
(void) is_op;
(void) is_halfop;
(void) has_voice;
(void) is_chanuser;
/*
struct t_irc_nick *new_nick;
struct t_gui_nick *ptr_gui_nick;
int sort_index, color_prefix;
char prefix;
/* nick already exists on this channel? */
// nick already exists on this channel?
if ((new_nick = irc_nick_search (channel, nick_name)))
{
/* update nick */
// update nick
IRC_NICK_SET_FLAG(new_nick, is_chanowner, IRC_NICK_CHANOWNER);
IRC_NICK_SET_FLAG(new_nick, is_chanadmin, IRC_NICK_CHANADMIN);
IRC_NICK_SET_FLAG(new_nick, is_chanadmin2, IRC_NICK_CHANADMIN2);
@@ -149,11 +161,11 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
return new_nick;
}
/* alloc memory for new nick */
// alloc memory for new nick
if ((new_nick = (struct t_irc_nick *) malloc (sizeof (struct t_irc_nick))) == NULL)
return NULL;
/* initialize new nick */
// initialize new nick
new_nick->nick = strdup (nick_name);
new_nick->host = NULL;
new_nick->flags = 0;
@@ -169,7 +181,7 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
else
new_nick->color = irc_nick_find_color (new_nick);
/* add nick to end of list */
// add nick to end of list
new_nick->prev_nick = channel->last_nick;
if (channel->nicks)
channel->last_nick->next_nick = new_nick;
@@ -182,13 +194,15 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
channel->nick_completion_reset = 1;
/* add nick to buffer nicklist */
// add nick to buffer nicklist
irc_nick_get_gui_infos (new_nick, &sort_index, &prefix, &color_prefix);
gui_nicklist_add (channel->buffer, new_nick->nick, sort_index,
GUI_COLOR_NICKLIST, prefix, color_prefix);
/* all is ok, return address of new nick */
// all is ok, return address of new nick
return new_nick;
*/
return NULL;
}
/*
@@ -199,11 +213,17 @@ void
irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
struct t_irc_nick *nick, char *new_nick)
{
int nick_is_me;
t_weelist *ptr_weelist;
t_gui_nick *ptr_nick;
(void) server;
(void) channel;
(void) nick;
(void) new_nick;
/* update buffer nick */
/*
int nick_is_me;
struct t_weelist *ptr_weelist;
struct t_gui_nick *ptr_nick;
// update buffer nick
ptr_nick = gui_nicklist_search (channel->buffer, nick->nick);
if (ptr_nick)
gui_nicklist_update (channel->buffer, ptr_nick, new_nick,
@@ -224,7 +244,7 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
}
}
/* change nickname */
// change nickname
if (nick->nick)
free (nick->nick);
nick->nick = strdup (new_nick);
@@ -232,6 +252,7 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
nick->color = GUI_COLOR_CHAT_NICK_SELF;
else
nick->color = irc_nick_find_color (nick);
*/
}
/*
@@ -241,15 +262,19 @@ irc_nick_change (struct t_irc_server *server, struct t_irc_channel *channel,
void
irc_nick_free (struct t_irc_channel *channel, struct t_irc_nick *nick)
{
(void) channel;
(void) nick;
/*
struct t_irc_nick *new_nicks;
if (!channel || !nick)
return;
/* remove nick from buffer nicklist */
// remove nick from buffer nicklist
(void) gui_nicklist_remove (channel->buffer, nick->nick);
/* remove nick from nicks list */
// remove nick from nicks list
if (channel->last_nick == nick)
channel->last_nick = nick->prev_nick;
if (nick->prev_nick)
@@ -265,7 +290,7 @@ irc_nick_free (struct t_irc_channel *channel, struct t_irc_nick *nick)
channel->nicks_count--;
/* free data */
// free data
if (nick->nick)
free (nick->nick);
if (nick->host)
@@ -274,6 +299,7 @@ irc_nick_free (struct t_irc_channel *channel, struct t_irc_nick *nick)
channel->nicks = new_nicks;
channel->nick_completion_reset = 1;
*/
}
/*
@@ -359,8 +385,14 @@ irc_nick_count (struct t_irc_channel *channel, int *total, int *count_op,
*/
void
irc_nick_set_away (struct t_irc_channel *channel, struct t_irc_nick *nick, int is_away)
irc_nick_set_away (struct t_irc_channel *channel, struct t_irc_nick *nick,
int is_away)
{
(void) channel;
(void) nick;
(void) is_away;
/*
t_gui_nick *ptr_nick;
if ((irc_cfg_irc_away_check > 0)
@@ -382,6 +414,7 @@ irc_nick_set_away (struct t_irc_channel *channel, struct t_irc_nick *nick, int i
gui_nicklist_draw (channel->buffer, 0, 0);
}
}
*/
}
/*
+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[] =
+45 -42
View File
@@ -201,7 +201,7 @@ irc_server_init_with_url (struct t_irc_server *server, char *irc_url)
else
{
weechat_printf (NULL,
_("%sIrc: error retrieving user's name: %s"),
_("%sirc: error retrieving user's name: %s"),
weechat_prefix ("error"),
strerror (errno));
free (url);
@@ -425,7 +425,7 @@ irc_server_alloc ()
if ((new_server = (struct t_irc_server *) malloc (sizeof (struct t_irc_server))) == NULL)
{
weechat_printf (NULL,
_("%sIrc: error when allocating new server"),
_("%sirc: error when allocating new server"),
weechat_prefix ("error"));
return NULL;
}
@@ -758,7 +758,7 @@ irc_server_send (struct t_irc_server *server, char *buffer, int size_buf)
if (!server)
{
weechat_printf (NULL,
_("%sIrc: error sending data to IRC server: null "
_("%sirc: error sending data to IRC server: null "
"pointer (please report problem to developers)"),
weechat_prefix ("error"));
return 0;
@@ -767,7 +767,7 @@ irc_server_send (struct t_irc_server *server, char *buffer, int size_buf)
if (size_buf <= 0)
{
weechat_printf (server->buffer,
_("%sIrc: error sending data to IRC server: empty "
_("%sirc: error sending data to IRC server: empty "
"buffer (please report problem to "
"developers)"),
weechat_prefix ("error"));
@@ -784,7 +784,7 @@ irc_server_send (struct t_irc_server *server, char *buffer, int size_buf)
if (rc < 0)
{
weechat_printf (server->buffer,
_("%sIrc: error sending data to IRC server (%s)"),
_("%sirc: error sending data to IRC server (%s)"),
weechat_prefix ("error"),
strerror (errno));
}
@@ -832,7 +832,7 @@ irc_server_outqueue_send (struct t_irc_server *server)
strlen (server->outqueue->message_after_mod)) < 0)
{
weechat_printf (server->buffer,
_("%sIrc: error sending data to IRC "
_("%sirc: error sending data to IRC "
"server"),
weechat_prefix ("error"));
}
@@ -863,7 +863,9 @@ irc_server_send_one_msg (struct t_irc_server *server, char *message)
#endif
/*new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_OUT,
server->name,
message);*/
message)
*/
new_msg = NULL;
/* no changes in new message */
if (new_msg && (strcmp (buffer, new_msg) == 0))
@@ -913,7 +915,7 @@ irc_server_send_one_msg (struct t_irc_server *server, char *message)
if (irc_server_send (server, buffer, strlen (buffer)) <= 0)
{
weechat_printf (server->buffer,
_("%sIrc: error sending data to IRC "
_("%sirc: error sending data to IRC "
"server"),
weechat_prefix ("error"));
rc = 0;
@@ -1045,7 +1047,7 @@ irc_server_msgq_add_msg (struct t_irc_server *server, char *msg)
if (!message)
{
weechat_printf (server->buffer,
_("%sIrc: not enough memory for received IRC "
_("%sirc: not enough memory for received IRC "
"message"),
weechat_prefix ("error"));
return;
@@ -1058,7 +1060,7 @@ irc_server_msgq_add_msg (struct t_irc_server *server, char *msg)
if (!message->data)
{
weechat_printf (server->buffer,
_("%sIrc: not enough memory for received IRC "
_("%sirc: not enough memory for received IRC "
"message"),
weechat_prefix ("error"));
}
@@ -1105,7 +1107,7 @@ irc_server_msgq_add_unterminated (struct t_irc_server *server, char *string)
if (!server->unterminated_message)
{
weechat_printf (server->buffer,
_("%sIrc: not enough memory for received IRC "
_("%sirc: not enough memory for received IRC "
"message"),
weechat_prefix ("error"));
}
@@ -1118,7 +1120,7 @@ irc_server_msgq_add_unterminated (struct t_irc_server *server, char *string)
if (!server->unterminated_message)
{
weechat_printf (server->buffer,
_("%sIrc: not enough memory for received IRC "
_("%sirc: not enough memory for received IRC "
"message"),
weechat_prefix ("error"));
}
@@ -1179,7 +1181,7 @@ irc_server_msgq_flush ()
if (irc_recv_msgq->data)
{
#ifdef DEBUG
weechat_printf (weechat_current_buffer,
weechat_printf (irc_recv_msgq->server->buffer,
"[DEBUG] %s",
irc_recv_msgq->data);
#endif
@@ -1192,7 +1194,7 @@ irc_server_msgq_flush ()
//gui_chat_printf_raw_data (irc_recv_msgq->server, 0, 0,
// ptr_data);
#ifdef DEBUG
weechat_printf (NULL,
weechat_printf (irc_recv_msgq->server->buffer,
"[DEBUG] data received from server: %s",
ptr_data);
#endif
@@ -1231,20 +1233,20 @@ irc_server_msgq_flush ()
{
case -1:
weechat_printf (irc_recv_msgq->server->buffer,
_("%sIrc: command \"%s\" "
_("%sirc: command \"%s\" "
"failed!"),
weechat_prefix ("error"),
command);
break;
case -2:
weechat_printf (irc_recv_msgq->server->buffer,
_("%sIrc: no command to "
_("%sirc: no command to "
"execute!"),
weechat_prefix ("error"));
break;
case -3:
weechat_printf (irc_recv_msgq->server->buffer,
_("%sIrc: unknown command: "
_("%sirc: unknown command: "
"cmd=\"%s\", "
"host=\"%s\", "
"args=\"%s\""),
@@ -1320,7 +1322,7 @@ irc_server_recv (void *arg_server)
else
{
weechat_printf (server->buffer,
_("%sIrc: cannot read data from socket, "
_("%sirc: cannot read data from socket, "
"disconnecting from server..."),
weechat_prefix ("error"));
irc_server_disconnect (server, 1);
@@ -1387,7 +1389,7 @@ irc_server_timer (void *empty)
if (diff / 1000 > weechat_config_integer (irc_config_irc_lag_disconnect) * 60)
{
weechat_printf (ptr_server->buffer,
_("%sIrc: lag is high, "
_("%sirc: lag is high, "
"disconnecting from "
"server..."),
weechat_prefix ("info"));
@@ -1490,7 +1492,7 @@ irc_server_reconnect_schedule (struct t_irc_server *server)
{
server->reconnect_start = time (NULL);
weechat_printf (server->buffer,
_("%sIrc: reconnecting to server in %d seconds"),
_("%sirc: reconnecting to server in %d seconds"),
weechat_prefix ("info"),
server->autoreconnect_delay);
}
@@ -1549,7 +1551,7 @@ irc_server_child_read (void *arg_server)
if (gnutls_handshake (server->gnutls_sess) < 0)
{
weechat_printf (server->buffer,
_("%sIrc: GnuTLS handshake failed"),
_("%sirc: GnuTLS handshake failed"),
weechat_prefix ("error"));
irc_server_close_connection (server);
irc_server_reconnect_schedule (server);
@@ -1570,8 +1572,8 @@ irc_server_child_read (void *arg_server)
case '1':
weechat_printf (server->buffer,
(config_proxy_use) ?
_("%sIrc: proxy address \"%s\" not found") :
_("%sIrc: address \"%s\" not found"),
_("%sirc: proxy address \"%s\" not found") :
_("%sirc: address \"%s\" not found"),
weechat_prefix ("error"),
server->address);
irc_server_close_connection (server);
@@ -1581,8 +1583,8 @@ irc_server_child_read (void *arg_server)
case '2':
weechat_printf (server->buffer,
(config_proxy_use) ?
_("%sIrc: proxy IP address not found") :
_("%sIrc: IP address not found"),
_("%sirc: proxy IP address not found") :
_("%sirc: IP address not found"),
weechat_prefix ("error"));
irc_server_close_connection (server);
irc_server_reconnect_schedule (server);
@@ -1591,8 +1593,8 @@ irc_server_child_read (void *arg_server)
case '3':
weechat_printf (server->buffer,
(config_proxy_use) ?
_("%sIrc: proxy connection refused") :
_("%sIrc: connection refused"),
_("%sirc: proxy connection refused") :
_("%sirc: connection refused"),
weechat_prefix ("error"));
irc_server_close_connection (server);
irc_server_reconnect_schedule (server);
@@ -1600,7 +1602,7 @@ irc_server_child_read (void *arg_server)
/* proxy fails to connect to server */
case '4':
weechat_printf (server->buffer,
_("%sIrc: proxy fails to establish "
_("%sirc: proxy fails to establish "
"connection to server "
"(check username/password if used)"),
weechat_prefix ("error"));
@@ -1610,7 +1612,7 @@ irc_server_child_read (void *arg_server)
/* fails to set local hostname/IP */
case '5':
weechat_printf (server->buffer,
_("%sIrc: unable to set local hostname/IP"),
_("%sirc: unable to set local hostname/IP"),
weechat_prefix ("error"));
irc_server_close_connection (server);
irc_server_reconnect_schedule (server);
@@ -2158,16 +2160,17 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
if (!server->buffer)
{
server->buffer = weechat_buffer_new ("irc", server->name, NULL);
server->buffer = weechat_buffer_new (server->name, server->name, NULL);
if (!server->buffer)
return 0;
weechat_buffer_set (server->buffer, "display", "1");
}
#ifndef HAVE_GNUTLS
if (server->ssl)
{
weechat_printf (server->buffer,
_("%sIrc: cannot connect with SSL since WeeChat "
_("%sirc: cannot connect with SSL since WeeChat "
"was not built with GnuTLS support"),
weechat_prefix ("error"));
return 0;
@@ -2176,7 +2179,7 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
if (config_proxy_use)
{
weechat_printf (server->buffer,
_("%sIrc: connecting to server %s:%d%s%s via %s "
_("%sirc: connecting to server %s:%d%s%s via %s "
"proxy %s:%d%s..."),
weechat_prefix ("info"),
server->address, server->port,
@@ -2197,12 +2200,12 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
else
{
weechat_printf (server->buffer,
_("%sIrc: connecting to server %s:%d%s%s..."),
_("%sirc: connecting to server %s:%d%s%s..."),
weechat_prefix ("info"),
server->address, server->port,
(server->ipv6) ? " (IPv6)" : "",
(server->ssl) ? " (SSL)" : "");
weechat_log_printf (_("Irc: caonnecting to server %s:%d%s%s..."),
weechat_log_printf (_("irc: connecting to server %s:%d%s%s..."),
server->address, server->port,
(server->ipv6) ? " (IPv6)" : "",
(server->ssl) ? " (SSL)" : "");
@@ -2219,7 +2222,7 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
if (gnutls_init (&server->gnutls_sess, GNUTLS_CLIENT) != 0)
{
weechat_printf (server->buffer,
_("%sIrc: GnuTLS init error"),
_("%sirc: GnuTLS init error"),
weechat_prefix ("error"));
return 0;
}
@@ -2237,7 +2240,7 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
if (pipe (child_pipe) < 0)
{
weechat_printf (server->buffer,
_("%sIrc: cannot create pipe"),
_("%sirc: cannot create pipe"),
weechat_prefix ("error"));
return 0;
}
@@ -2252,7 +2255,7 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
if (server->sock == -1)
{
weechat_printf (server->buffer,
_("%sIrc: cannot create socket"),
_("%sirc: cannot create socket"),
weechat_prefix ("error"));
return 0;
}
@@ -2263,7 +2266,7 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
(void *) &set, sizeof (set)) == -1)
{
weechat_printf (server->buffer,
_("%sIrc: cannot set socket option "
_("%sirc: cannot set socket option "
"\"SO_REUSEADDR\""),
weechat_prefix ("error"));
}
@@ -2274,7 +2277,7 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
(void *) &set, sizeof (set)) == -1)
{
weechat_printf (server->buffer,
_("%sIrc: cannot set socket option "
_("%sirc: cannot set socket option "
"\"SO_KEEPALIVE\""),
weechat_prefix ("error"));
}
@@ -2321,7 +2324,7 @@ void
irc_server_reconnect (struct t_irc_server *server)
{
weechat_printf (server->buffer,
_("%sIrc: reconnecting to server..."),
_("%sirc: reconnecting to server..."),
weechat_prefix ("info"));
server->reconnect_start = 0;
@@ -2369,7 +2372,7 @@ irc_server_disconnect (struct t_irc_server *server, int reconnect)
{
//irc_nick_free_all (ptr_channel);
weechat_printf (ptr_channel->buffer,
_("%sIrc: disconnected from server!"),
_("%sirc: disconnected from server!"),
weechat_prefix ("info"));
//gui_nicklist_draw (ptr_channel->buffer, 1, 1);
//gui_status_draw (ptr_channel->buffer, 1);
@@ -2380,7 +2383,7 @@ irc_server_disconnect (struct t_irc_server *server, int reconnect)
if (server->buffer)
weechat_printf (server->buffer,
_("%sIrc: disconnected from server!"),
_("%sirc: disconnected from server!"),
weechat_prefix ("info"));
if (server->nick_modes)
+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)