summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-command.c99
-rw-r--r--src/core/wee-config.c8
-rw-r--r--src/core/wee-config.h1
-rw-r--r--src/gui/curses/gui-curses-status.c14
-rw-r--r--src/gui/gui-buffer.c15
-rw-r--r--src/gui/gui-buffer.h4
-rw-r--r--src/gui/gui-chat.c1
-rw-r--r--src/gui/gui-chat.h1
-rw-r--r--src/plugins/alias/alias.c2
-rw-r--r--src/plugins/irc/Makefile.am6
-rw-r--r--src/plugins/irc/irc-channel.c2
-rw-r--r--src/plugins/irc/irc-command.c1773
-rw-r--r--src/plugins/irc/irc-command.h37
-rw-r--r--src/plugins/irc/irc-config.c29
-rw-r--r--src/plugins/irc/irc-config.h2
-rw-r--r--src/plugins/irc/irc-dcc.c2
-rw-r--r--src/plugins/irc/irc-display.c281
-rw-r--r--src/plugins/irc/irc-input.c4
-rw-r--r--src/plugins/irc/irc-nick.c63
-rw-r--r--src/plugins/irc/irc-protocol.c9
-rw-r--r--src/plugins/irc/irc-server.c87
-rw-r--r--src/plugins/irc/irc.c43
-rw-r--r--src/plugins/irc/irc.h3
-rw-r--r--src/plugins/plugin-api.c22
-rw-r--r--src/plugins/plugin-api.h3
-rw-r--r--src/plugins/plugin.c2
-rw-r--r--src/plugins/weechat-plugin.h5
27 files changed, 1320 insertions, 1198 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 72405bc9a..5eb3ab458 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -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;
}
/*
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index b12597caa..191df3be5 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -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);
diff --git a/src/core/wee-config.h b/src/core/wee-config.h
index e30e5371e..f79135eac 100644
--- a/src/core/wee-config.h
+++ b/src/core/wee-config.h
@@ -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;
diff --git a/src/gui/curses/gui-curses-status.c b/src/gui/curses/gui-curses-status.c
index 9ced1e317..9422a7f44 100644
--- a/src/gui/curses/gui-curses-status.c
+++ b/src/gui/curses/gui-curses-status.c
@@ -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)
{
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index 5cc8a30da..390eca487 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -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;
}
/*
diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h
index dd80da6b1..975f28c92 100644
--- a/src/gui/gui-buffer.h
+++ b/src/gui/gui-buffer.h
@@ -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 *);
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
index f2d0b462e..94b25fc55 100644
--- a/src/gui/gui-chat.c
+++ b/src/gui/gui-chat.c
@@ -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) */
diff --git a/src/gui/gui-chat.h b/src/gui/gui-chat.h
index 7addeff1a..99b0c2ee0 100644
--- a/src/gui/gui-chat.h
+++ b/src/gui/gui-chat.h
@@ -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 */
diff --git a/src/plugins/alias/alias.c b/src/plugins/alias/alias.c
index 791090929..fe4ffaeb3 100644
--- a/src/plugins/alias/alias.c
+++ b/src/plugins/alias/alias.c
@@ -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;
}
diff --git a/src/plugins/irc/Makefile.am b/src/plugins/irc/Makefile.am
index d9e58cfd3..1cda2b8ad 100644
--- a/src/plugins/irc/Makefile.am
+++ b/src/plugins/irc/Makefile.am
@@ -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)
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index c57fac6d4..d3975bbb7 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -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;
}
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index 1b80e2ea3..516e58be2 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -50,7 +50,7 @@ irc_command_admin (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
(void) data;
@@ -119,16 +119,16 @@ irc_command_mode_nicks (struct t_irc_server *server, char *channel,
char *command;
length = 0;
- for (i = 0; i < argc; i++)
+ for (i = 1; i < argc; i++)
length += strlen (argv[i]) + 1;
length += strlen (channel) + (argc * strlen (mode)) + 32;
command = (char *)malloc (length);
if (command)
{
snprintf (command, length, "MODE %s %s", channel, set);
- for (i = 0; i < argc; i++)
+ for (i = 1; i < argc; i++)
strcat (command, mode);
- for (i = 0; i < argc; i++)
+ for (i = 1; i < argc; i++)
{
strcat (command, " ");
strcat (command, argv[i]);
@@ -227,7 +227,7 @@ irc_command_amsg (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: cannot find nick for "
+ _("%sirc: cannot find nick for "
"sending message"),
weechat_prefix ("error"));
}
@@ -303,7 +303,7 @@ irc_command_away_server (struct t_irc_server *server, char *arguments)
string = (char *)irc_color_decode ((unsigned char *)arguments,
1, 0);
weechat_printf (server->buffer,
- _("%sIrc: future away on %s%s%s: %s"),
+ _("%sirc: future away on %s%s%s: %s"),
weechat_prefix ("info"),
IRC_COLOR_CHAT_SERVER,
server->name,
@@ -361,7 +361,7 @@ irc_command_away_server (struct t_irc_server *server, char *arguments)
/* server not connected, remove away message but do not send
anything */
weechat_printf (server->buffer,
- _("%sIrc: future away on %s%s%s removed"),
+ _("%sirc: future away on %s%s%s removed"),
weechat_prefix ("info"),
IRC_COLOR_CHAT_SERVER,
server->name,
@@ -380,7 +380,7 @@ irc_command_away (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
(void) data;
@@ -401,7 +401,7 @@ irc_command_away (void *data, void *buffer, int argc, char **argv,
//gui_status_draw (window->buffer, 1);
//gui_add_hotlist = 1;
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -444,10 +444,10 @@ irc_command_ban (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
+ _("%sirc: \"%s\" command can only be "
"executed in a channel buffer"),
weechat_prefix ("error"), "ban");
- return -1;
+ return PLUGIN_RC_FAILED;
}
}
@@ -464,7 +464,7 @@ irc_command_ban (void *data, void *buffer, int argc, char **argv,
if (!ptr_channel)
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
+ _("%sirc: \"%s\" command can only be "
"executed in a channel buffer"),
weechat_prefix ("error"),
"ban");
@@ -490,7 +490,7 @@ irc_command_connect_one_server (struct t_irc_server *server, int no_join)
if (server->is_connected)
{
weechat_printf (NULL,
- _("%sIrc: already connected to server "
+ _("%sirc: already connected to server "
"\"%s\"!"),
weechat_prefix ("error"),
server->name);
@@ -499,7 +499,7 @@ irc_command_connect_one_server (struct t_irc_server *server, int no_join)
if (server->child_pid > 0)
{
weechat_printf (NULL,
- _("%sIrc: currently connecting to server "
+ _("%sirc: currently connecting to server "
"\"%s\"!"),
weechat_prefix ("error"),
server->name);
@@ -558,7 +558,7 @@ irc_command_connect (void *data, void *buffer, int argc, char **argv,
if (i == (argc - 1))
{
weechat_printf (NULL,
- _("%sIrc: missing argument for \"%s\" "
+ _("%sirc: missing argument for \"%s\" "
"option"),
weechat_prefix ("error"),
"-port");
@@ -629,7 +629,7 @@ irc_command_connect (void *data, void *buffer, int argc, char **argv,
if (ptr_server)
{
weechat_printf (NULL,
- _("%sIrc: server %s%s%s created "
+ _("%sirc: server %s%s%s created "
"(temporary server, "
"NOT SAVED!)"),
weechat_prefix ("info"),
@@ -642,7 +642,7 @@ irc_command_connect (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (NULL,
- _("%sIrc: unable to create server "
+ _("%sirc: unable to create server "
"\"%s\""),
weechat_prefix ("error"),
argv[i]);
@@ -762,32 +762,25 @@ int
irc_command_cycle (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
- char *channel_name, *pos_args, *ptr_arg, *buf;
+ char *channel_name, *pos_args, *ptr_arg, *buf, *version;
char **channels;
int i, num_channels;
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- if (arguments)
+ if (argc > 1)
{
- if (irc_channel_is_channel (arguments))
+ if (irc_channel_is_channel (argv[1]))
{
- channel_name = arguments;
- pos_args = strchr (arguments, ' ');
- if (pos_args)
- {
- pos_args[0] = '\0';
- pos_args++;
- while (pos_args[0] == ' ')
- pos_args++;
- }
- channels = weechat_explode_string (channel_name, ",", 0,
+ channel_name = argv[1];
+ pos_args = argv_eol[2];
+ channels = weechat_string_explode (channel_name, ",", 0, 0,
&num_channels);
if (channels)
{
@@ -799,7 +792,7 @@ irc_command_cycle (void *data, void *buffer, int argc, char **argv,
(ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
ptr_channel->cycle = 1;
}
- weechat_free_exploded_string (channels);
+ weechat_string_free_exploded (channels);
}
}
else
@@ -807,18 +800,18 @@ irc_command_cycle (void *data, void *buffer, int argc, char **argv,
if (!ptr_channel)
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can not be executed "
+ _("%sirc: \"%s\" command can not be executed "
"on a server buffer"),
weechat_prefix ("error"), "cycle");
- return -1;
+ return PLUGIN_RC_FAILED;
}
/* does nothing on private buffer (cycle has no sense!) */
if (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL)
- return 0;
+ return PLUGIN_RC_SUCCESS;
channel_name = ptr_channel->name;
- pos_args = arguments;
+ pos_args = argv_eol[1];
ptr_channel->cycle = 1;
}
}
@@ -827,15 +820,15 @@ irc_command_cycle (void *data, void *buffer, int argc, char **argv,
if (!ptr_channel)
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can not be executed on "
+ _("%sirc: \"%s\" command can not be executed on "
"a server buffer"),
weechat_prefix ("error"), "part");
- return -1;
+ return PLUGIN_RC_FAILED;
}
/* does nothing on private buffer (cycle has no sense!) */
if (ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL)
- return 0;
+ return PLUGIN_RC_SUCCESS;
channel_name = ptr_channel->name;
pos_args = NULL;
@@ -843,21 +836,25 @@ irc_command_cycle (void *data, void *buffer, int argc, char **argv,
}
ptr_arg = (pos_args) ? pos_args :
- (irc_cfg_irc_default_msg_part && irc_cfg_irc_default_msg_part[0]) ?
- irc_cfg_irc_default_msg_part : NULL;
+ (weechat_config_string (irc_config_irc_default_msg_part)
+ && weechat_config_string (irc_config_irc_default_msg_part)[0]) ?
+ weechat_config_string (irc_config_irc_default_msg_part) : NULL;
if (ptr_arg)
{
- buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
+ version = weechat_info_get ("version");
+ buf = weechat_string_replace (ptr_arg, "%v", (version) ? version : "");
irc_server_sendf (ptr_server, "PART %s :%s", channel_name,
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
+ if (version)
+ free (version);
}
else
irc_server_sendf (ptr_server, "PART %s", channel_name);
-
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -868,87 +865,61 @@ int
irc_command_dcc (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
- char *pos_nick, *pos_file;
-
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make compiler happy */
- (void) argc;
- (void) argv;
+ (void) data;
- /* DCC SEND file */
- if (strncasecmp (arguments, "send", 4) == 0)
+ if (argc > 1)
{
- pos_nick = strchr (arguments, ' ');
- if (!pos_nick)
+ /* DCC SEND file */
+ if (weechat_strcasecmp (argv[1], "send") == 0)
{
- weechat_printf (ptr_server->buffer,
- _("%sIrc: wrong argument count for \"%s\" "
- "command"),
- weechat_prefix ("error"), "dcc send");
- return -1;
+ if (argc < 4)
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "dcc send");
+ }
+ //irc_dcc_send_request (ptr_server, IRC_DCC_FILE_SEND,
+ // argv[2], argv_eol[3]);
}
- while (pos_nick[0] == ' ')
- pos_nick++;
-
- pos_file = strchr (pos_nick, ' ');
- if (!pos_file)
+ /* DCC CHAT */
+ else if (weechat_strcasecmp (argv[1], "chat") == 0)
{
- weechat_printf (ptr_server->buffer,
- _("%sIrc: wrong argument count for \"%s\" "
- "command"),
- weechat_prefix ("error"), "dcc send");
- return -1;
- }
- pos_file[0] = '\0';
- pos_file++;
- while (pos_file[0] == ' ')
- pos_file++;
-
- irc_dcc_send_request (ptr_server, IRC_DCC_FILE_SEND,
- pos_nick, pos_file);
- }
- /* DCC CHAT */
- else if (strncasecmp (arguments, "chat", 4) == 0)
- {
- pos_nick = strchr (arguments, ' ');
- if (!pos_nick)
+ if (argc < 3)
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "dcc chat");
+ }
+ //irc_dcc_send_request (ptr_server, IRC_DCC_CHAT_SEND,
+ // argv[2], NULL);
+ }
+ /* close DCC CHAT */
+ else if (weechat_strcasecmp (argv[1], "close") == 0)
{
- weechat_printf (ptr_server->buffer,
- _("%sIrc: wrong argument count for \"%s\" "
- "command"),
- weechat_prefix ("error"), "dcc chat");
- return -1;
+ if (ptr_channel && (ptr_channel != IRC_CHANNEL_TYPE_CHANNEL)
+ && (ptr_channel->dcc_chat))
+ {
+ //irc_dcc_close (ptr_channel->dcc_chat,
+ // IRC_DCC_ABORTED);
+ //irc_dcc_redraw (1);
+ }
}
- while (pos_nick[0] == ' ')
- pos_nick++;
-
- irc_dcc_send_request (ptr_server, IRC_DCC_CHAT_SEND,
- pos_nick, NULL);
- }
- /* close DCC CHAT */
- else if (weechat_strcasecmp (arguments, "close") == 0)
- {
- if (ptr_channel && (ptr_channel != IRC_CHANNEL_TYPE_CHANNEL)
- && (ptr_channel->dcc_chat))
+ /* unknown DCC action */
+ else
{
- irc_dcc_close ((t_irc_dcc *)(ptr_channel->dcc_chat),
- IRC_DCC_ABORTED);
- irc_dcc_redraw (1);
+ weechat_printf (ptr_server->buffer,
+ _("%sirc: wrong arguments for \"%s\" command"),
+ weechat_prefix ("error"), "dcc");
+ return PLUGIN_RC_FAILED;
}
}
- /* unknown DCC action */
else
{
- weechat_printf (ptr_server->buffer,
- _("%sIrc: wrong arguments for \"%s\" command"),
- weechat_prefix ("error"), "dcc");
- return -1;
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "dcc");
}
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -961,14 +932,15 @@ irc_command_dehalfop (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) arguments;
+ (void) data;
+ (void) argv_eol;
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
{
- if (argc == 0)
+ if (argc < 2)
irc_server_sendf (ptr_server, "MODE %s -h %s",
ptr_channel->name,
ptr_server->nick);
@@ -979,11 +951,12 @@ irc_command_dehalfop (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be executed in "
+ _("%sirc: \"%s\" command can only be executed in "
"a channel buffer"),
weechat_prefix ("error"), "dehalfop");
+ return PLUGIN_RC_FAILED;
}
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -996,14 +969,15 @@ irc_command_deop (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) arguments;
+ (void) data;
+ (void) argv_eol;
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
{
- if (argc == 0)
+ if (argc < 2)
irc_server_sendf (ptr_server, "MODE %s -o %s",
ptr_channel->name,
ptr_server->nick);
@@ -1014,12 +988,12 @@ irc_command_deop (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be executed in "
+ _("%sirc: \"%s\" command can only be executed in "
"a channel buffer"),
weechat_prefix ("error"), "deop");
- return -1;
+ return PLUGIN_RC_FAILED;
}
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1032,14 +1006,15 @@ irc_command_devoice (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) arguments;
+ (void) data;
+ (void) argv_eol;
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
{
- if (argc == 0)
+ if (argc < 2)
irc_server_sendf (ptr_server, "MODE %s -v %s",
ptr_channel->name,
ptr_server->nick);
@@ -1050,12 +1025,12 @@ irc_command_devoice (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
+ _("%sirc: \"%s\" command can only be "
"executed in a channel buffer"),
weechat_prefix ("error"), "devoice");
- return -1;
+ return PLUGIN_RC_FAILED;
}
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1068,15 +1043,16 @@ irc_command_die (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) arguments;
+ (void) data;
(void) argc;
(void) argv;
+ (void) argv_eol;
irc_server_sendf (ptr_server, "DIE");
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1086,7 +1062,7 @@ irc_command_die (void *data, void *buffer, int argc, char **argv,
void
irc_command_quit_server (struct t_irc_server *server, char *arguments)
{
- char *ptr_arg, *buf;
+ char *ptr_arg, *buf, *version;
if (!server)
return;
@@ -1094,16 +1070,21 @@ irc_command_quit_server (struct t_irc_server *server, char *arguments)
if (server->is_connected)
{
ptr_arg = (arguments) ? arguments :
- (irc_cfg_irc_default_msg_quit && irc_cfg_irc_default_msg_quit[0]) ?
- irc_cfg_irc_default_msg_quit : NULL;
+ (weechat_config_string (irc_config_irc_default_msg_quit)
+ && weechat_config_string (irc_config_irc_default_msg_quit)[0]) ?
+ weechat_config_string (irc_config_irc_default_msg_quit) : NULL;
if (ptr_arg)
{
- buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
+ version = weechat_info_get ("version");
+ buf = weechat_string_replace (ptr_arg, "%v",
+ (version) ? version : "");
irc_server_sendf (server, "QUIT :%s",
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
+ if (version)
+ free (version);
}
else
irc_server_sendf (server, "QUIT");
@@ -1125,18 +1106,18 @@ irc_command_disconnect_one_server (struct t_irc_server *server)
&& (server->reconnect_start == 0))
{
weechat_printf (server->buffer,
- _("%sIrc: not connected to server \"%s\"!"),
+ _("%sirc: not connected to server \"%s\"!"),
weechat_prefix ("error"), server->name);
return 0;
}
if (server->reconnect_start > 0)
{
weechat_printf (server->buffer,
- _("Irc: auto-reconnection is cancelled"));
+ _("irc: auto-reconnection is cancelled"));
}
irc_command_quit_server (server, NULL);
irc_server_disconnect (server, 0);
- gui_status_draw (server->buffer, 1);
+ //gui_status_draw (server->buffer, 1);
/* disconnect ok */
return 1;
@@ -1155,15 +1136,16 @@ irc_command_disconnect (void *data, void *buffer, int argc, char **argv,
IRC_COMMAND_GET_SERVER(buffer);
/* make C compiler happy */
- (void) arguments;
+ (void) data;
+ (void) argv_eol;
- if (argc == 0)
+ if (argc < 2)
disconnect_ok = irc_command_disconnect_one_server (ptr_server);
else
{
disconnect_ok = 1;
- if (weechat_strcasecmp (argv[0], "-all") == 0)
+ if (weechat_strcasecmp (argv[1], "-all") == 0)
{
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
@@ -1178,7 +1160,7 @@ irc_command_disconnect (void *data, void *buffer, int argc, char **argv,
}
else
{
- for (i = 0; i < argc; i++)
+ for (i = 1; i < argc; i++)
{
ptr_server = irc_server_search (argv[i]);
if (ptr_server)
@@ -1189,7 +1171,7 @@ irc_command_disconnect (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (NULL,
- _("%sIrc: server \"%s\" not found"),
+ _("%sirc: server \"%s\" not found"),
weechat_prefix ("error"), argv[i]);
disconnect_ok = 0;
}
@@ -1198,9 +1180,9 @@ irc_command_disconnect (void *data, void *buffer, int argc, char **argv,
}
if (!disconnect_ok)
- return -1;
+ return PLUGIN_RC_FAILED;
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1213,14 +1195,15 @@ irc_command_halfop (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) arguments;
+ (void) data;
+ (void) argv_eol;
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
{
- if (argc == 0)
+ if (argc < 2)
irc_server_sendf (ptr_server, "MODE %s +h %s",
ptr_channel->name,
ptr_server->nick);
@@ -1231,12 +1214,12 @@ irc_command_halfop (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
+ _("%sirc: \"%s\" command can only be "
"executed in a channel buffer"),
weechat_prefix ("error"), "halfop");
- return -1;
+ return PLUGIN_RC_FAILED;
}
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1249,17 +1232,17 @@ irc_command_info (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- if (arguments)
- irc_server_sendf (ptr_server, "INFO %s", arguments);
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "INFO %s", argv_eol[1]);
else
irc_server_sendf (ptr_server, "INFO");
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1272,12 +1255,13 @@ irc_command_invite (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) arguments;
+ (void) data;
+ (void) argv_eol;
- if (argc == 2)
+ if (argc > 2)
irc_server_sendf (ptr_server, "INVITE %s %s", argv[0], argv[1]);
else
{
@@ -1287,14 +1271,14 @@ irc_command_invite (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
+ _("%sirc: \"%s\" command can only be "
"executed in a channel buffer"),
weechat_prefix ("error"), "invite");
- return -1;
+ return PLUGIN_RC_FAILED;
}
}
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1307,14 +1291,20 @@ irc_command_ison (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- irc_server_sendf (ptr_server, "ISON %s", arguments);
- return 0;
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "ISON %s", argv_eol[1]);
+ else
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "ison");
+ }
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1340,15 +1330,20 @@ irc_command_join (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
+
+ if (argc > 1)
+ irc_command_join_server (ptr_server, argv_eol[1]);
+ else
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "join");
+ }
- irc_command_join_server (ptr_server, arguments);
-
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1360,66 +1355,61 @@ irc_command_kick (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
char *pos_channel, *pos_nick, *pos_comment;
-
+
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
- (void) argv;
+ (void) data;
- if (irc_channel_is_channel (arguments))
- {
- pos_channel = arguments;
- pos_nick = strchr (arguments, ' ');
- if (!pos_nick)
- {
- weechat_printf (ptr_server->buffer,
- _("%sIrc: wrong arguments for \"%s\" "
- "command"),
- weechat_prefix ("error"), "kick");
- return -1;
- }
- pos_nick[0] = '\0';
- pos_nick++;
- while (pos_nick[0] == ' ')
- pos_nick++;
- }
- else
+ if (argc > 1)
{
- if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
+ if (irc_channel_is_channel (argv[1]))
{
- pos_channel = ptr_channel->name;
- pos_nick = arguments;
+ if (argc < 3)
+ {
+ weechat_printf (ptr_server->buffer,
+ _("%sirc: wrong arguments for \"%s\" "
+ "command"),
+ weechat_prefix ("error"), "kick");
+ return PLUGIN_RC_FAILED;
+ }
+ pos_channel = argv[1];
+ pos_nick = argv[2];
+ pos_comment = argv_eol[3];
}
else
{
- weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
- "executed in a channel buffer"),
- weechat_prefix ("error"), "kick");
- return -1;
+ if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
+ {
+ pos_channel = ptr_channel->name;
+ pos_nick = argv[1];
+ pos_comment = argv_eol[2];
+ }
+ else
+ {
+ weechat_printf (ptr_server->buffer,
+ _("%sirc: \"%s\" command can only be "
+ "executed in a channel buffer"),
+ weechat_prefix ("error"), "kick");
+ return PLUGIN_RC_FAILED;
+ }
}
+
+ if (pos_comment)
+ irc_server_sendf (ptr_server, "KICK %s %s :%s",
+ pos_channel, pos_nick, pos_comment);
+ else
+ irc_server_sendf (ptr_server, "KICK %s %s",
+ pos_channel, pos_nick);
}
-
- pos_comment = strchr (pos_nick, ' ');
- if (pos_comment)
+ else
{
- pos_comment[0] = '\0';
- pos_comment++;
- while (pos_comment[0] == ' ')
- pos_comment++;
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "kick");
}
- if (pos_comment)
- irc_server_sendf (ptr_server, "KICK %s %s :%s",
- pos_channel, pos_nick, pos_comment);
- else
- irc_server_sendf (ptr_server, "KICK %s %s",
- pos_channel, pos_nick);
-
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1434,65 +1424,60 @@ irc_command_kickban (void *data, void *buffer, int argc, char **argv,
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
- (void) argv;
-
- if (irc_channel_is_channel (arguments))
- {
- pos_channel = arguments;
- pos_nick = strchr (arguments, ' ');
- if (!pos_nick)
- {
- weechat_printf (ptr_server->buffer,
- _("%sIrc: wrong arguments for \"%s\" "
- "command"),
- weechat_prefix ("error"), "kickban");
- return -1;
- }
- pos_nick[0] = '\0';
- pos_nick++;
- while (pos_nick[0] == ' ')
- pos_nick++;
- }
- else
+ (void) data;
+
+ if (argc > 1)
{
- if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
+ if (irc_channel_is_channel (argv[1]))
{
- pos_channel = ptr_channel->name;
- pos_nick = arguments;
+ if (argc < 3)
+ {
+ weechat_printf (ptr_server->buffer,
+ _("%sirc: wrong arguments for \"%s\" "
+ "command"),
+ weechat_prefix ("error"), "kickban");
+ return PLUGIN_RC_FAILED;
+ }
+ pos_channel = argv[1];
+ pos_nick = argv[2];
+ pos_comment = argv_eol[3];
}
else
{
- weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
- "executed in a channel buffer"),
- weechat_prefix ("error"), "kickban");
- return -1;
+ if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
+ {
+ pos_channel = ptr_channel->name;
+ pos_nick = argv[1];
+ pos_comment = argv_eol[2];
+ }
+ else
+ {
+ weechat_printf (ptr_server->buffer,
+ _("%sirc: \"%s\" command can only be "
+ "executed in a channel buffer"),
+ weechat_prefix ("error"), "kickban");
+ return PLUGIN_RC_FAILED;
+ }
}
+
+ irc_server_sendf (ptr_server, "MODE %s +b %s",
+ pos_channel, pos_nick);
+ if (pos_comment)
+ irc_server_sendf (ptr_server, "KICK %s %s :%s",
+ pos_channel, pos_nick, pos_comment);
+ else
+ irc_server_sendf (ptr_server, "KICK %s %s",
+ pos_channel, pos_nick);
}
-
- pos_comment = strchr (pos_nick, ' ');
- if (pos_comment)
+ else
{
- pos_comment[0] = '\0';
- pos_comment++;
- while (pos_comment[0] == ' ')
- pos_comment++;
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "kickban");
}
- irc_server_sendf (ptr_server, "MODE %s +b %s",
- pos_channel, pos_nick);
- if (pos_comment)
- irc_server_sendf (ptr_server, "KICK %s %s :%s",
- pos_channel, pos_nick, pos_comment);
- else
- irc_server_sendf (ptr_server, "KICK %s %s",
- pos_channel, pos_nick);
-
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1503,30 +1488,24 @@ int
irc_command_kill (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
- char *pos;
-
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
- (void) argv;
-
- pos = strchr (arguments, ' ');
- if (pos)
+ (void) data;
+
+ if (argc > 2)
{
- pos[0] = '\0';
- pos++;
- while (pos[0] == ' ')
- pos++;
irc_server_sendf (ptr_server, "KILL %s :%s",
- arguments, pos);
+ argv[1], argv_eol[2]);
}
else
- irc_server_sendf (ptr_server, "KILL %s",
- arguments);
- return 0;
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "kill");
+ }
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1540,17 +1519,18 @@ irc_command_links (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- if (arguments)
- irc_server_sendf (ptr_server, "LINKS %s", arguments);
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "LINKS %s", argv_eol[1]);
else
irc_server_sendf (ptr_server, "LINKS");
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1566,10 +1546,10 @@ irc_command_list (void *data, void *buffer, int argc, char **argv,
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
if (ptr_server->cmd_list_regexp)
@@ -1579,22 +1559,22 @@ irc_command_list (void *data, void *buffer, int argc, char **argv,
ptr_server->cmd_list_regexp = NULL;
}
- if (arguments)
+ if (argc > 1)
{
ptr_server->cmd_list_regexp = (regex_t *) malloc (sizeof (regex_t));
if (ptr_server->cmd_list_regexp)
{
if ((ret = regcomp (ptr_server->cmd_list_regexp,
- arguments,
+ argv_eol[1],
REG_NOSUB | REG_ICASE)) != 0)
{
regerror (ret, ptr_server->cmd_list_regexp,
buf, sizeof(buf));
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" is not a valid regular "
+ _("%sirc: \"%s\" is not a valid regular "
"expression (%s)"),
- weechat_prefix ("error"), arguments, buf);
- return -1;
+ weechat_prefix ("error"), argv_eol, buf);
+ return PLUGIN_RC_FAILED;
}
else
irc_server_sendf (ptr_server, "LIST");
@@ -1602,16 +1582,16 @@ irc_command_list (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: not enough memory for regular "
+ _("%sirc: not enough memory for regular "
"expression"),
weechat_prefix ("error"));
- return -1;
+ return PLUGIN_RC_FAILED;
}
}
else
irc_server_sendf (ptr_server, "LIST");
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1624,17 +1604,18 @@ irc_command_lusers (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- if (arguments)
- irc_server_sendf (ptr_server, "LUSERS %s", arguments);
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "LUSERS %s", argv_eol[1]);
else
irc_server_sendf (ptr_server, "LUSERS");
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1647,26 +1628,34 @@ irc_command_me (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
-
- if (!ptr_channel)
+
+ if (argc > 1)
{
- weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can not be executed "
- "on a server buffer"),
- weechat_prefix ("error"), "me");
- return -1;
+ if (!ptr_channel)
+ {
+ weechat_printf (ptr_server->buffer,
+ _("%sirc: \"%s\" command can not be executed "
+ "on a server buffer"),
+ weechat_prefix ("error"), "me");
+ return PLUGIN_RC_FAILED;
+ }
+ irc_command_me_channel (ptr_server, ptr_channel, argv_eol[1]);
+ }
+ else
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "me");
}
- irc_command_me_channel (ptr_server, ptr_channel, arguments);
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
- * irc_command_mode_server! send MODE command on a server
+ * irc_command_mode_server: send MODE command on a server
*/
void
@@ -1685,15 +1674,20 @@ irc_command_mode (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
+
+ if (argc > 1)
+ irc_command_mode_server (ptr_server, argv_eol[1]);
+ else
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "mode");
+ }
- irc_command_mode_server (ptr_server, arguments);
-
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1706,17 +1700,18 @@ irc_command_motd (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- if (arguments)
- irc_server_sendf (ptr_server, "MOTD %s", arguments);
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "MOTD %s", argv_eol[1]);
else
irc_server_sendf (ptr_server, "MOTD");
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1727,172 +1722,171 @@ int
irc_command_msg (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
- char *pos, *pos_comma;
+ char **targets;
+ int num_targets, i;
char *msg_pwd_hidden;
- t_irc_nick *ptr_nick;
+ struct t_irc_nick *ptr_nick;
char *string;
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
- (void) argv;
-
- pos = strchr (arguments, ' ');
- if (pos)
+ (void) data;
+ (void) argv_eol;
+
+ if (argc > 2)
{
- pos[0] = '\0';
- pos++;
- while (pos[0] == ' ')
- pos++;
-
- while (arguments && arguments[0])
+ targets = weechat_string_explode (argv[1], ",", 0, 0,
+ &num_targets);
+ if (targets)
{
- pos_comma = strchr (arguments, ',');
- if (pos_comma)
- {
- pos_comma[0] = '\0';
- pos_comma++;
- }
- if (strcmp (arguments, "*") == 0)
+ for (i = 0; i < num_targets; i++)
{
- if (!ptr_channel
- || ((ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL)
- && (ptr_channel->type != IRC_CHANNEL_TYPE_PRIVATE)))
+ if (strcmp (targets[i], "*") == 0)
{
- weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
- "executed in a channel or private "
- "buffer"),
- weechat_prefix ("error"), "msg *");
- return -1;
+ if (!ptr_channel
+ || ((ptr_channel->type != IRC_CHANNEL_TYPE_CHANNEL)
+ && (ptr_channel->type != IRC_CHANNEL_TYPE_PRIVATE)))
+ {
+ weechat_printf (ptr_server->buffer,
+ _("%sirc: \"%s\" command can only be "
+ "executed in a channel or private "
+ "buffer"),
+ weechat_prefix ("error"), "msg *");
+ }
+ if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
+ ptr_nick = irc_nick_search (ptr_channel, ptr_server->nick);
+ else
+ ptr_nick = NULL;
+ //irc_display_nick (ptr_channel->buffer, ptr_nick,
+ // (ptr_nick) ? NULL : ptr_server->nick,
+ // GUI_MSG_TYPE_NICK, 1, NULL, 0);
+ string = (char *)irc_color_decode ((unsigned char *)argv_eol[2],
+ 1, 0);
+ weechat_printf (ptr_channel->buffer,
+ "%s",
+ (string) ? string : argv_eol[2]);
+ if (string)
+ free (string);
+
+ irc_server_sendf (ptr_server, "PRIVMSG %s :%s",
+ ptr_channel->name, argv_eol[2]);
}
- if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
- ptr_nick = irc_nick_search (ptr_channel, ptr_server->nick);
else
- ptr_nick = NULL;
- irc_display_nick (ptr_channel->buffer, ptr_nick,
- (ptr_nick) ? NULL : ptr_server->nick,
- GUI_MSG_TYPE_NICK, 1, NULL, 0);
- string = (char *)irc_color_decode ((unsigned char *)pos, 1, 0);
- weechat_printf (ptr_channel->buffer,
- "%s",
- (string) ? string : "");
- if (string)
- free (string);
-
- irc_server_sendf (ptr_server, "PRIVMSG %s :%s",
- ptr_channel->name, pos);
- }
- else
- {
- if (irc_channel_is_channel (arguments))
{
- ptr_channel = irc_channel_search (ptr_server, arguments);
- if (ptr_channel)
+ if (irc_channel_is_channel (targets[i]))
{
- ptr_nick = irc_nick_search (ptr_channel,
- ptr_server->nick);
- if (ptr_nick)
+ ptr_channel = irc_channel_search (ptr_server,
+ targets[i]);
+ if (ptr_channel)
{
- irc_display_nick (ptr_channel->buffer, ptr_nick,
- NULL, GUI_MSG_TYPE_NICK, 1,
- NULL, 0);
+ ptr_nick = irc_nick_search (ptr_channel,
+ ptr_server->nick);
+ if (ptr_nick)
+ {
+ //irc_display_nick (ptr_channel->buffer, ptr_nick,
+ // NULL, GUI_MSG_TYPE_NICK, 1,
+ // NULL, 0);
+ string = (char *)irc_color_decode (
+ (unsigned char *)argv_eol[2], 1, 0);
+ weechat_printf (ptr_channel->buffer,
+ "%s",
+ (string) ?
+ string : argv_eol[2]);
+ if (string)
+ free (string);
+ }
+ else
+ {
+ weechat_printf (ptr_server->buffer,
+ _("%sirc: nick \"%s\" not "
+ "found for \"%s\" command"),
+ weechat_prefix ("error"),
+ ptr_server->nick,
+ "msg");
+ }
+ }
+ irc_server_sendf (ptr_server, "PRIVMSG %s :%s",
+ targets[i], argv_eol[2]);
+ }
+ else
+ {
+ /* message to nickserv with identify ? */
+ if (weechat_strcasecmp (targets[i], "nickserv") == 0)
+ {
+ msg_pwd_hidden = strdup (argv_eol[2]);
+ if (msg_pwd_hidden
+ && (weechat_config_boolean (irc_config_log_hide_nickserv_pwd)))
+ irc_display_hide_password (msg_pwd_hidden, 0);
string = (char *)irc_color_decode (
- (unsigned char *)pos, 1, 0);
- weechat_printf (ptr_channel->buffer,
- "%s",
- (string) ? string : "");
+ (unsigned char *)((msg_pwd_hidden) ?
+ msg_pwd_hidden : argv_eol[2]),
+ 1, 0);
+ weechat_printf (ptr_server->buffer,
+ "%s%s-%s%s%s- %s%s",
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT_NICK,
+ targets[i],
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ (string) ?
+ string : ((msg_pwd_hidden) ?
+ msg_pwd_hidden : argv_eol[2]));
if (string)
free (string);
+ if (msg_pwd_hidden)
+ free (msg_pwd_hidden);
+ irc_server_sendf (ptr_server, "PRIVMSG %s :%s",
+ targets[i], argv_eol[2]);
+ }
+
+ string = (char *)irc_color_decode (
+ (unsigned char *)argv_eol[2], 1, 0);
+ ptr_channel = irc_channel_search (ptr_server,
+ targets[i]);
+ if (ptr_channel)
+ {
+ //irc_display_nick (ptr_channel->buffer, NULL,
+ // ptr_server->nick,
+ // GUI_MSG_TYPE_NICK, 1,
+ // GUI_COLOR(GUI_CHAT_NICK_SELF),
+ // 0);
+ weechat_printf (ptr_channel->buffer,
+ "%s%s",
+ IRC_COLOR_CHAT,
+ (string) ? string : argv_eol[2]);
}
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: nick \"%s\" not found "
- "for \"%s\" command"),
- weechat_prefix ("error"),
- ptr_server->nick,
- "msg");
+ "%sMSG%s(%s%s%s)%s: %s",
+ weechat_prefix ("network"),
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT_NICK,
+ targets[i],
+ IRC_COLOR_CHAT_DELIMITERS,
+ IRC_COLOR_CHAT,
+ (string) ? string : argv_eol[2]);
}
- }
- irc_server_sendf (ptr_server, "PRIVMSG %s :%s",
- arguments, pos);
- }
- else
- {
- /* message to nickserv with identify ? */
- if (strcmp (arguments, "nickserv") == 0)
- {
- msg_pwd_hidden = strdup (pos);
- if (irc_cfg_log_hide_nickserv_pwd)
- irc_display_hide_password (msg_pwd_hidden, 0);
- string = (char *)irc_color_decode (
- (unsigned char *)msg_pwd_hidden, 1, 0);
- weechat_printf (ptr_server->buffer,
- "%s%s-%s%s%s- %s%s",
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT_NICK,
- arguments,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- (string) ? string : "");
if (string)
free (string);
irc_server_sendf (ptr_server, "PRIVMSG %s :%s",
- arguments, pos);
- free (msg_pwd_hidden);
- return 0;
- }
-
- string = (char *)irc_color_decode (
- (unsigned char *)pos, 1, 0);
- ptr_channel = irc_channel_search (ptr_server, arguments);
- if (ptr_channel)
- {
- irc_display_nick (ptr_channel->buffer, NULL,
- ptr_server->nick,
- GUI_MSG_TYPE_NICK, 1,
- GUI_COLOR(GUI_CHAT_NICK_SELF),
- 0);
- weechat_printf (ptr_channel->buffer,
- "%s%s",
- IRC_COLOR_CHAT,
- (string) ? string : "");
- }
- else
- {
- weechat_printf (ptr_server->buffer,
- "%sMSG%s(%s%s%s)%s: %s",
- weechat_prefix ("network"),
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT_NICK,
- arguments,
- IRC_COLOR_CHAT_DELIMITERS,
- IRC_COLOR_CHAT,
- (string) ? string : pos);
+ targets[i], argv_eol[2]);
}
- if (string)
- free (string);
- irc_server_sendf (ptr_server, "PRIVMSG %s :%s",
- arguments, pos);
}
}
- arguments = pos_comma;
+ weechat_string_free_exploded (targets);
}
}
else
{
- weechat_printf (ptr_server->buffer,
- _("%sIrc: wrong argument count for \"%s\" "
- "command"),
- weechat_prefix ("error"), "msg");
- return -1;
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "msg");
}
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1905,14 +1899,14 @@ irc_command_names (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- if (arguments)
- irc_server_sendf (ptr_server, "NAMES %s", arguments);
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "NAMES %s", argv_eol[1]);
else
{
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
@@ -1921,13 +1915,14 @@ irc_command_names (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
+ _("%sirc: \"%s\" command can only be "
"executed in a channel buffer"),
weechat_prefix ("error"), "names");
- return -1;
+ return PLUGIN_RC_FAILED;
}
}
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -1937,7 +1932,7 @@ irc_command_names (void *data, void *buffer, int argc, char **argv,
void
irc_send_nick_server (struct t_irc_server *server, char *nickname)
{
- t_irc_channel *ptr_channel;
+ struct t_irc_channel *ptr_channel;
if (!server)
return;
@@ -1949,11 +1944,11 @@ irc_send_nick_server (struct t_irc_server *server, char *nickname)
if (server->nick)
free (server->nick);
server->nick = strdup (nickname);
- gui_input_draw (server->buffer, 1);
+ //gui_input_draw (server->buffer, 1);
for (ptr_channel = server->channels; ptr_channel;
ptr_channel = ptr_channel->next_channel)
{
- gui_input_draw (ptr_channel->buffer, 1);
+ //gui_input_draw (ptr_channel->buffer, 1);
}
}
}
@@ -1968,31 +1963,38 @@ irc_command_nick (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) arguments;
+ (void) data;
+ (void) argv_eol;
- if (argc == 2)
+ if (argc > 2)
{
- if (strncmp (argv[0], "-all", 4) != 0)
- return -1;
-
+ if (weechat_strcasecmp (argv[1], "-all") != 0)
+ {
+ weechat_printf (ptr_server->buffer,
+ _("%sirc: wrong arguments for \"%s\" command"),
+ weechat_prefix ("error"), "nick");
+ return PLUGIN_RC_FAILED;
+ }
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
- irc_send_nick_server (ptr_server, argv[1]);
+ irc_send_nick_server (ptr_server, argv[2]);
}
}
else
{
- if (argc == 1)
- irc_send_nick_server (ptr_server, argv[0]);
+ if (argc > 1)
+ irc_send_nick_server (ptr_server, argv[1]);
else
- return -1;
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "nick");
+ }
}
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -2003,46 +2005,38 @@ int
irc_command_notice (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
- char *pos, *string;
-
+ char *string;
+
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
-
- pos = strchr (arguments, ' ');
- if (pos)
+
+ if (argc > 2)
{
- pos[0] = '\0';
- pos++;
- while (pos[0] == ' ')
- pos++;
- string = (char *)irc_color_decode ((unsigned char *)pos, 1, 0);
+ string = (char *)irc_color_decode ((unsigned char *)argv_eol[2], 1, 0);
weechat_printf (ptr_server->buffer,
"notice%s(%s%s%s)%s: %s",
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_NICK,
- arguments,
+ argv[1],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
- (string) ? string : "");
+ (string) ? string : argv_eol[2]);
if (string)
free (string);
irc_server_sendf (ptr_server, "NOTICE %s :%s",
- arguments, pos);
+ argv[1], argv_eol[2]);
}
else
{
- weechat_printf (ptr_server->buffer,
- _("%sIrc: wrong argument count for \"%s\" "
- "command"),
- weechat_prefix ("error"), "notice");
- return -1;
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "notice");
}
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -2050,19 +2044,20 @@ irc_command_notice (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_op (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_op (void *data, void *buffer, int argc, char **argv,
+ char **argv_eol)
{
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) arguments;
+ (void) data;
+ (void) argv_eol;
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
{
- if (argc == 0)
+ if (argc < 2)
irc_server_sendf (ptr_server, "MODE %s +o %s",
ptr_channel->name,
ptr_server->nick);
@@ -2073,12 +2068,12 @@ irc_command_op (t_gui_window *window,
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
+ _("%sirc: \"%s\" command can only be "
"executed in a channel buffer"),
weechat_prefix ("error"), "op");
- return -1;
+ return PLUGIN_RC_FAILED;
}
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -2091,14 +2086,20 @@ irc_command_oper (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
+
+ if (argc > 2)
+ irc_server_sendf (ptr_server, "OPER %s", argv_eol[1]);
+ else
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "oper");
+ }
- irc_server_sendf (ptr_server, "OPER %s", arguments);
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -2109,43 +2110,35 @@ int
irc_command_part (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
- char *channel_name, *pos_args, *ptr_arg, *buf;
+ char *channel_name, *pos_args, *ptr_arg, *buf, *version;
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
- (void) argv;
+ (void) data;
- if (arguments)
+ if (argc > 1)
{
- if (irc_channel_is_channel (arguments))
+ if (irc_channel_is_channel (argv[1]))
{
- channel_name = arguments;
- pos_args = strchr (arguments, ' ');
- if (pos_args)
- {
- pos_args[0] = '\0';
- pos_args++;
- while (pos_args[0] == ' ')
- pos_args++;
- }
+ channel_name = argv[1];
+ pos_args = argv_eol[2];
}
else
{
if (!ptr_channel)
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
+ _("%sirc: \"%s\" command can only be "
"executed in a channel or "
"private buffer"),
weechat_prefix ("error"), "part");
- return -1;
+ return PLUGIN_RC_FAILED;
}
channel_name = ptr_channel->name;
- pos_args = arguments;
+ pos_args = argv_eol[1];
}
}
else
@@ -2153,41 +2146,46 @@ irc_command_part (void *data, void *buffer, int argc, char **argv,
if (!ptr_channel)
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
+ _("%sirc: \"%s\" command can only be "
"executed in a channel or private "
"buffer"),
weechat_prefix ("error"), "part");
- return -1;
+ return PLUGIN_RC_FAILED;
}
if (!ptr_channel->nicks)
{
- gui_buffer_free (ptr_channel->buffer, 1);
+ weechat_buffer_close (ptr_channel->buffer);
+ ptr_channel->buffer = NULL;
irc_channel_free (ptr_server, ptr_channel);
- gui_status_draw (gui_current_window->buffer, 1);
- gui_input_draw (gui_current_window->buffer, 1);
- return 0;
+ //gui_status_draw (gui_current_window->buffer, 1);
+ //gui_input_draw (gui_current_window->buffer, 1);
+ return PLUGIN_RC_SUCCESS;
}
channel_name = ptr_channel->name;
pos_args = NULL;
}
ptr_arg = (pos_args) ? pos_args :
- (irc_cfg_irc_default_msg_part && irc_cfg_irc_default_msg_part[0]) ?
- irc_cfg_irc_default_msg_part : NULL;
+ (weechat_config_string (irc_config_irc_default_msg_part)
+ && weechat_config_string (irc_config_irc_default_msg_part)[0]) ?
+ weechat_config_string (irc_config_irc_default_msg_part) : NULL;
if (ptr_arg)
{
- buf = weechat_strreplace (ptr_arg, "%v", PACKAGE_VERSION);
+ version = weechat_info_get ("version");
+ buf = weechat_string_replace (ptr_arg, "%v", (version) ? version : "");
irc_server_sendf (ptr_server, "PART %s :%s",
channel_name,
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
+ if (version)
+ free (version);
}
else
irc_server_sendf (ptr_server, "PART %s", channel_name);
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -2200,14 +2198,20 @@ irc_command_ping (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
+
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "PING %s", argv_eol[1]);
+ else
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "ping");
+ }
- irc_server_sendf (ptr_server, "PING %s", arguments);
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -2220,14 +2224,20 @@ irc_command_pong (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- irc_server_sendf (ptr_server, "PONG %s", arguments);
- return 0;
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "PONG %s", argv_eol[1]);
+ else
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "pong");
+ }
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -2238,94 +2248,60 @@ int
irc_command_query (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
- char *pos, *string;
+ char *string;
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
-
- pos = strchr (arguments, ' ');
- if (pos)
- {
- pos[0] = '\0';
- pos++;
- while (pos[0] == ' ')
- pos++;
- if (!pos[0])
- pos = NULL;
- }
-
- /* create private window if not already opened */
- ptr_channel = irc_channel_search (ptr_server, arguments);
- if (!ptr_channel)
+
+ if (argc > 1)
{
- ptr_channel = irc_channel_new (ptr_server,
- IRC_CHANNEL_TYPE_PRIVATE,
- arguments, 1);
+ /* create private window if not already opened */
+ ptr_channel = irc_channel_search (ptr_server, argv[1]);
if (!ptr_channel)
{
- weechat_printf (ptr_server->buffer,
- _("%sIrc: cannot create new private "
- "buffer \"%s\""),
- weechat_prefix ("error"), arguments);
- return -1;
+ ptr_channel = irc_channel_new (ptr_server,
+ IRC_CHANNEL_TYPE_PRIVATE,
+ argv[1], 1);
+ if (!ptr_channel)
+ {
+ weechat_printf (ptr_server->buffer,
+ _("%sirc: cannot create new private "
+ "buffer \"%s\""),
+ weechat_prefix ("error"), argv[1]);
+ return PLUGIN_RC_FAILED;
+ }
}
- gui_chat_draw_title (ptr_channel->buffer, 1);
- }
- else
- {
- if (window->buffer != ptr_channel->buffer)
+ weechat_buffer_set (ptr_channel->buffer, "display", "1");
+
+ /* display text if given */
+ if (argv_eol[2])
{
- gui_window_switch_to_buffer (window, ptr_channel->buffer);
- gui_window_redraw_buffer (ptr_channel->buffer);
+ //irc_display_nick (ptr_channel->buffer, NULL, ptr_server->nick,
+ // GUI_MSG_TYPE_NICK, 1,
+ // GUI_COLOR(GIU_COLOR_CHAT_NICK_SELF), 0);
+ string = (char *)irc_color_decode ((unsigned char *)argv_eol[2],
+ 1, 0);
+ weechat_printf (ptr_channel->buffer,
+ "%s%s",
+ IRC_COLOR_CHAT,
+ (string) ? string : argv_eol[2]);
+ if (string)
+ free (string);
+ irc_server_sendf (ptr_server, "PRIVMSG %s :%s",
+ argv[1], argv_eol[2]);
}
}
-
- /* display text if given */
- if (pos)
+ else
{
- irc_display_nick (ptr_channel->buffer, NULL, ptr_server->nick,
- GUI_MSG_TYPE_NICK, 1,
- GUI_COLOR(GIU_COLOR_CHAT_NICK_SELF), 0);
- string = (char *)irc_color_decode ((unsigned char *)pos, 1, 0);
- weechat_printf (ptr_channel->buffer,
- "%s%s",
- IRC_COLOR_CHAT,
- (string) ? string : "");
- if (string)
- free (string);
- irc_server_sendf (ptr_server, "PRIVMSG %s :%s",
- arguments, pos);
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "query");
}
- return 0;
-}
-
-/*
- * irc_command_quit: disconnect from all servers and quit WeeChat
- */
-
-int
-irc_command_quit (void *data, void *buffer, int argc, char **argv,
- char **argv_eol)
-{
- t_irc_server *ptr_server;
- /* make C compiler happy */
- (void) window;
- (void) argc;
- (void) argv;
-
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- irc_command_quit_server (ptr_server, arguments);
- }
- quit_weechat = 1;
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -2337,23 +2313,21 @@ irc_command_quote (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
IRC_COMMAND_GET_SERVER(buffer);
- if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ if (!ptr_server)// || !ptr_server->is_connected)
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
-
- if (ptr_server->sock < 0)
+
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "%s", argv_eol[1]);
+ else
{
- weechat_printf (NULL,
- _("%sIrc: command \"%s\" needs a server "
- "connection!"),
- weechat_prefix ("error"), "quote");
- return -1;
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "quote");
}
- irc_server_sendf (ptr_server, "%s", arguments);
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -2370,7 +2344,7 @@ irc_command_reconnect_one_server (struct t_irc_server *server, int no_join)
if ((!server->is_connected) && (server->child_pid == 0))
{
weechat_printf (server->buffer,
- _("%sIrc: not connected to server \"%s\"!"),
+ _("%sirc: not connected to server \"%s\"!"),
weechat_prefix ("error"), server->name);
return 0;
}
@@ -2381,7 +2355,7 @@ irc_command_reconnect_one_server (struct t_irc_server *server, int no_join)
server->reconnect_start = 0;
server->reconnect_join = (server->channels) ? 1 : 0;
}
- gui_status_draw (server->buffer, 1);
+ //gui_status_draw (server->buffer, 1);
/* reconnect ok */
return 1;
@@ -2400,14 +2374,15 @@ irc_command_reconnect (void *data, void *buffer, int argc, char **argv,
IRC_COMMAND_GET_SERVER(buffer);
/* make C compiler happy */
- (void) arguments;
+ (void) data;
+ (void) argv_eol;
nb_reconnect = 0;
reconnect_ok = 1;
all_servers = 0;
no_join = 0;
- for (i = 0; i < argc; i++)
+ for (i = 1; i < argc; i++)
{
if (weechat_strcasecmp (argv[i], "-all") == 0)
all_servers = 1;
@@ -2430,7 +2405,7 @@ irc_command_reconnect (void *data, void *buffer, int argc, char **argv,
}
else
{
- for (i = 0; i < argc; i++)
+ for (i = 1; i < argc; i++)
{
if (argv[i][0] != '-')
{
@@ -2444,7 +2419,7 @@ irc_command_reconnect (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (NULL,
- _("%sIrc: server \"%s\" not found"),
+ _("%sirc: server \"%s\" not found"),
weechat_prefix ("error"), argv[i]);
reconnect_ok = 0;
}
@@ -2456,9 +2431,9 @@ irc_command_reconnect (void *data, void *buffer, int argc, char **argv,
reconnect_ok = irc_command_reconnect_one_server (ptr_server, no_join);
if (!reconnect_ok)
- return -1;
+ return PLUGIN_RC_FAILED;
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -2471,15 +2446,17 @@ irc_command_rehash (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) arguments;
+ (void) data;
(void) argc;
(void) argv;
+ (void) argv_eol;
irc_server_sendf (ptr_server, "REHASH");
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -2492,15 +2469,17 @@ irc_command_restart (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) arguments;
+ (void) data;
(void) argc;
(void) argv;
+ (void) argv_eol;
irc_server_sendf (ptr_server, "RESTART");
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -2512,22 +2491,23 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
int i, detailed_list, one_server_found;
- t_irc_server server_tmp, *ptr_server, *server_found, *new_server;
+ struct t_irc_server server_tmp, *ptr_server, *server_found, *new_server;
char *server_name, *error;
long number;
- t_gui_buffer *ptr_buffer;
/* make C compiler happy */
- (void) arguments;
+ (void) data;
+ (void) buffer;
+ (void) argv_eol;
- if ((argc == 0)
- || (weechat_strcasecmp (argv[0], "list") == 0)
- || (weechat_strcasecmp (argv[0], "listfull") == 0))
+ if ((argc == 1)
+ || (weechat_strcasecmp (argv[1], "list") == 0)
+ || (weechat_strcasecmp (argv[1], "listfull") == 0))
{
/* list servers */
server_name = NULL;
detailed_list = 0;
- for (i = 0; i < argc; i++)
+ for (i = 1; i < argc; i++)
{
if (weechat_strcasecmp (argv[i], "list") == 0)
continue;
@@ -2552,7 +2532,7 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
}
}
else
- weechat_printf (NULL, _("No server."));
+ weechat_printf (NULL, _("No server"));
}
else
{
@@ -2575,41 +2555,36 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
}
if (!one_server_found)
weechat_printf (NULL,
- _("No server with '%s' found."),
+ _("No server with '%s' found"),
server_name);
}
}
else
{
- if (weechat_strcasecmp (argv[0], "add") == 0)
+ if (weechat_strcasecmp (argv[1], "add") == 0)
{
- if (argc < 3)
+ if (argc < 4)
{
- weechat_printf (NULL,
- _("%sIrc: missing parameters for \"%s\" "
- "command"),
- weechat_prefix ("error"), "server");
- return -1;
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server add");
}
-
- if (irc_server_name_already_exists (argv[1]))
+ if (irc_server_name_already_exists (argv[2]))
{
weechat_printf (NULL,
- _("%sIrc: server \"%s\" already exists, "
+ _("%sirc: server \"%s\" already exists, "
"can't create it!"),
- weechat_prefix ("error"), argv[1]);
- return -1;
+ weechat_prefix ("error"), argv[2]);
+ return PLUGIN_RC_FAILED;
}
-
+
/* init server struct */
irc_server_init (&server_tmp);
- server_tmp.name = strdup (argv[1]);
- server_tmp.address = strdup (argv[2]);
+ server_tmp.name = strdup (argv[2]);
+ server_tmp.address = strdup (argv[3]);
server_tmp.port = IRC_SERVER_DEFAULT_PORT;
/* parse arguments */
- for (i = 3; i < argc; i++)
+ for (i = 4; i < argc; i++)
{
if (argv[i][0] == '-')
{
@@ -2628,11 +2603,11 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
if (i == (argc - 1))
{
weechat_printf (NULL,
- _("%sIrc: missing argument for "
+ _("%sirc: missing argument for "
"\"%s\" option"),
weechat_prefix ("error"), "-port");
irc_server_free_data (&server_tmp);
- return -1;
+ return PLUGIN_RC_FAILED;
}
error = NULL;
number = strtol (argv[++i], &error, 10);
@@ -2644,11 +2619,11 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
if (i == (argc - 1))
{
weechat_printf (NULL,
- _("%sIrc: missing argument for "
+ _("%sirc: missing argument for "
"\"%s\" option"),
weechat_prefix ("error"), "-pwd");
irc_server_free_data (&server_tmp);
- return -1;
+ return PLUGIN_RC_FAILED;
}
server_tmp.password = strdup (argv[++i]);
}
@@ -2657,12 +2632,12 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
if (i >= (argc - 3))
{
weechat_printf (NULL,
- _("%sIrc: missing argument for "
+ _("%sirc: missing argument for "
"\"%s\" option"),
weechat_prefix ("error"),
"-nicks");
irc_server_free_data (&server_tmp);
- return -1;
+ return PLUGIN_RC_FAILED;
}
server_tmp.nick1 = strdup (argv[++i]);
server_tmp.nick2 = strdup (argv[++i]);
@@ -2673,12 +2648,12 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
if (i == (argc - 1))
{
weechat_printf (NULL,
- _("%sIrc: missing argument for "
+ _("%sirc: missing argument for "
"\"%s\" option"),
weechat_prefix ("error"),
"-username");
irc_server_free_data (&server_tmp);
- return -1;
+ return PLUGIN_RC_FAILED;
}
server_tmp.username = strdup (argv[++i]);
}
@@ -2687,12 +2662,12 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
if (i == (argc - 1))
{
weechat_printf (NULL,
- _("%sIrc: missing argument for "
+ _("%sirc: missing argument for "
"\"%s\" option"),
weechat_prefix ("error"),
"-realname");
irc_server_free_data (&server_tmp);
- return -1;
+ return PLUGIN_RC_FAILED;
}
server_tmp.realname = strdup (argv[++i]);
}
@@ -2701,12 +2676,12 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
if (i == (argc - 1))
{
weechat_printf (NULL,
- _("%sIrc: missing argument for "
+ _("%sirc: missing argument for "
"\"%s\" option"),
weechat_prefix ("error"),
"-command");
irc_server_free_data (&server_tmp);
- return -1;
+ return PLUGIN_RC_FAILED;
}
server_tmp.command = strdup (argv[++i]);
}
@@ -2715,12 +2690,12 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
if (i == (argc - 1))
{
weechat_printf (NULL,
- _("%sIrc: missing argument for "
+ _("%sirc: missing argument for "
"\"%s\" option"),
weechat_prefix ("error"),
"-autojoin");
irc_server_free_data (&server_tmp);
- return -1;
+ return PLUGIN_RC_FAILED;
}
server_tmp.autojoin = strdup (argv[++i]);
}
@@ -2752,7 +2727,7 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
if (new_server)
{
weechat_printf (NULL,
- _("%sIrc: server %s%s%s created"),
+ _("%sirc: server %s%s%s created"),
weechat_prefix ("info"),
IRC_COLOR_CHAT_SERVER,
server_tmp.name,
@@ -2761,10 +2736,10 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (NULL,
- _("%sIrc: unable to create server"),
+ _("%sirc: unable to create server"),
weechat_prefix ("error"));
irc_server_free_data (&server_tmp);
- return -1;
+ return PLUGIN_RC_FAILED;
}
if (new_server->autoconnect)
@@ -2772,189 +2747,173 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
irc_server_free_data (&server_tmp);
}
- else if (weechat_strcasecmp (argv[0], "copy") == 0)
+ else if (weechat_strcasecmp (argv[1], "copy") == 0)
{
- if (argc < 3)
+ if (argc < 4)
{
- weechat_printf (NULL,
- _("%sIrc: missing server name for \"%s\" "
- "command"),
- weechat_prefix ("error"), "server copy");
- return -1;
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server copy");
}
/* look for server by name */
- server_found = irc_server_search (argv[1]);
+ server_found = irc_server_search (argv[2]);
if (!server_found)
{
weechat_printf (NULL,
- _("%sIrc: server \"%s\" not found for "
+ _("%sirc: server \"%s\" not found for "
"\"%s\" command"),
weechat_prefix ("error"),
- argv[1], "server copy");
- return -1;
+ argv[2], "server copy");
+ return PLUGIN_RC_FAILED;
}
/* check if target name already exists */
- if (irc_server_search (argv[2]))
+ if (irc_server_search (argv[3]))
{
weechat_printf (NULL,
- _("%sIrc: server \"%s\" already exists for "
+ _("%sirc: server \"%s\" already exists for "
"\"%s\" command"),
weechat_prefix ("error"),
- argv[2], "server copy");
- return -1;
+ argv[3], "server copy");
+ return PLUGIN_RC_FAILED;
}
/* duplicate server */
- new_server = irc_server_duplicate (server_found, argv[2]);
+ new_server = irc_server_duplicate (server_found, argv[3]);
if (new_server)
{
weechat_printf (NULL,
- _("%sIrc: Server %s%s%s has been copied to "
+ _("%sirc: Server %s%s%s has been copied to "
"%s%s"),
IRC_COLOR_CHAT_SERVER,
- argv[1],
+ argv[2],
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_SERVER,
- argv[2]);
- gui_window_redraw_all_buffers ();
- return 0;
+ argv[3]);
+ //gui_window_redraw_all_buffers ();
+ return PLUGIN_RC_SUCCESS;
}
- return -1;
+ return PLUGIN_RC_FAILED;
}
- else if (weechat_strcasecmp (argv[0], "rename") == 0)
+ else if (weechat_strcasecmp (argv[1], "rename") == 0)
{
- if (argc < 3)
+ if (argc < 4)
{
- weechat_printf (NULL,
- _("%s missing server name for \"%s\" "
- "command"),
- weechat_prefix ("error"),
- "server rename");
- return -1;
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server rename");
}
/* look for server by name */
- server_found = irc_server_search (argv[1]);
+ server_found = irc_server_search (argv[2]);
if (!server_found)
{
weechat_printf (NULL,
- _("%sIrc: server \"%s\" not found for "
+ _("%sirc: server \"%s\" not found for "
"\"%s\" command"),
weechat_prefix ("error"),
- argv[1], "server rename");
- return -1;
+ argv[2], "server rename");
+ return PLUGIN_RC_FAILED;
}
/* check if target name already exists */
- if (irc_server_search (argv[2]))
+ if (irc_server_search (argv[3]))
{
weechat_printf (NULL,
- _("%sIrc: server \"%s\" already exists for "
+ _("%sirc: server \"%s\" already exists for "
"\"%s\" command"),
weechat_prefix ("error"),
- argv[2], "server rename");
- return -1;
+ argv[3], "server rename");
+ return PLUGIN_RC_FAILED;
}
/* rename server */
- if (irc_server_rename (server_found, argv[2]))
+ if (irc_server_rename (server_found, argv[3]))
{
weechat_printf (NULL,
- _("%sIrc: server %s%s%s has been renamed to "
+ _("%sirc: server %s%s%s has been renamed to "
"%s%s"),
weechat_prefix ("info"),
IRC_COLOR_CHAT_SERVER,
- argv[1],
+ argv[2],
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_SERVER,
- argv[2]);
- gui_window_redraw_all_buffers ();
- return 0;
+ argv[3]);
+ //gui_window_redraw_all_buffers ();
+ return PLUGIN_RC_SUCCESS;
}
- return -1;
+ return PLUGIN_RC_FAILED;
}
- else if (weechat_strcasecmp (argv[0], "keep") == 0)
+ else if (weechat_strcasecmp (argv[1], "keep") == 0)
{
- if (argc < 2)
+ if (argc < 3)
{
- weechat_printf (NULL,
- _("%sIrc: missing server name for \"%s\" "
- "command"),
- weechat_prefix ("error"), "server keep");
- return -1;
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server rename");
}
/* look for server by name */
- server_found = irc_server_search (argv[1]);
+ server_found = irc_server_search (argv[2]);
if (!server_found)
{
weechat_printf (NULL,
- _("%sIrc: server \"%s\" not found for "
+ _("%sirc: server \"%s\" not found for "
"\"%s\" command"),
weechat_prefix ("error"),
- argv[1], "server keep");
- return -1;
+ argv[2], "server keep");
+ return PLUGIN_RC_FAILED;
}
/* check that it is temporary server */
if (!server_found->temp_server)
{
weechat_printf (NULL,
- _("%sIrc: server \"%s\" is not a temporary "
+ _("%sirc: server \"%s\" is not a temporary "
"server"),
- weechat_prefix ("error"), argv[1]);
- return -1;
+ weechat_prefix ("error"), argv[2]);
+ return PLUGIN_RC_FAILED;
}
/* remove temporary flag on server */
server_found->temp_server = 0;
weechat_printf (NULL,
- _("%sIrc: server %s%s%s is not temporary any "
+ _("%sirc: server %s%s%s is not temporary any "
"more"),
weechat_prefix ("info"),
IRC_COLOR_CHAT_SERVER,
- argv[1],
+ argv[2],
IRC_COLOR_CHAT);
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
- else if (weechat_strcasecmp (argv[0], "del") == 0)
+ else if (weechat_strcasecmp (argv[1], "del") == 0)
{
- if (argc < 2)
+ if (argc < 3)
{
- weechat_printf (NULL,
- _("%sIrc: missing server name for \"%s\" "
- "command"),
- weechat_prefix ("error"), "server del");
- return -1;
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server del");
}
/* look for server by name */
- server_found = irc_server_search (argv[1]);
+ server_found = irc_server_search (argv[2]);
if (!server_found)
{
weechat_printf (NULL,
- _("%sIrc: server \"%s\" not found for "
+ _("%sirc: server \"%s\" not found for "
"\"%s\" command"),
weechat_prefix ("error"),
- argv[1], "server del");
- return -1;
+ argv[2], "server del");
+ return PLUGIN_RC_FAILED;
}
if (server_found->is_connected)
{
weechat_printf (NULL,
- _("%sIrc: you can not delete server \"%s\" "
+ _("%sirc: you can not delete server \"%s\" "
"because you are connected to. "
"Try \"/disconnect %s\" before."),
- weechat_prefix ("error"), argv[1], argv[1]);
- return -1;
+ weechat_prefix ("error"), argv[2], argv[2]);
+ return PLUGIN_RC_FAILED;
}
-
+
+ /*
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
@@ -2965,25 +2924,26 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
IRC_BUFFER_CHANNEL(ptr_buffer) = NULL;
}
}
+ */
server_name = strdup (server_found->name);
irc_server_free (server_found);
weechat_printf (NULL,
- _("%sIrc: Server %s%s%s has been deleted"),
+ _("%sirc: Server %s%s%s has been deleted"),
weechat_prefix ("info"),
IRC_COLOR_CHAT_SERVER,
- server_name,
+ (server_name) ? server_name : "???",
IRC_COLOR_CHAT);
if (server_name)
free (server_name);
- gui_window_redraw_buffer (window->buffer);
+ //gui_window_redraw_buffer (window->buffer);
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
- else if (weechat_strcasecmp (argv[0], "deloutq") == 0)
+ else if (weechat_strcasecmp (argv[1], "deloutq") == 0)
{
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
@@ -2991,20 +2951,21 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
irc_server_outqueue_free_all (ptr_server);
}
weechat_printf (NULL,
- _("Irc: messages outqueue DELETED for all "
+ _("irc: messages outqueue DELETED for all "
"servers. Some messages from you or "
"WeeChat may have been lost!"));
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
else
{
weechat_printf (NULL,
- _("%sIrc: unknown option for \"%s\" command"),
+ _("%sirc: unknown option for \"%s\" command"),
weechat_prefix ("error"), "server");
- return -1;
+ return PLUGIN_RC_FAILED;
}
}
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3012,19 +2973,25 @@ irc_command_server (void *data, void *buffer, int argc, char **argv,
*/
int
-irc_command_service (t_gui_window *window,
- char *arguments, int argc, char **argv)
+irc_command_service (void *data, void *buffer, int argc, char **argv,
+ char **argv_eol)
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
+
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "SERVICE %s", argv_eol[1]);
+ else
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "service");
+ }
- irc_server_sendf (ptr_server, "SERVICE %s", arguments);
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3037,17 +3004,18 @@ irc_command_servlist (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- if (arguments)
- irc_server_sendf (ptr_server, "SERVLIST %s", arguments);
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "SERVLIST %s", argv_eol[1]);
else
irc_server_sendf (ptr_server, "SERVLIST");
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3058,31 +3026,27 @@ int
irc_command_squery (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
- char *pos;
-
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
- (void) argv;
+ (void) data;
- pos = strchr (arguments, ' ');
- if (pos)
+ if (argc > 1)
{
- pos[0] = '\0';
- pos++;
- while (pos[0] == ' ')
- {
- pos++;
- }
- irc_server_sendf (ptr_server, "SQUERY %s :%s", arguments, pos);
+ if (argc > 2)
+ irc_server_sendf (ptr_server, "SQUERY %s :%s",
+ argv[1], argv_eol[2]);
+ else
+ irc_server_sendf (ptr_server, "SQUERY %s", argv_eol[1]);
}
else
- irc_server_sendf (ptr_server, "SQUERY %s", arguments);
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "squery");
+ }
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3095,14 +3059,20 @@ irc_command_squit (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
+
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "SQUIT %s", argv_eol[1]);
+ else
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "squit");
+ }
- irc_server_sendf (ptr_server, "SQUIT %s", arguments);
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3115,17 +3085,18 @@ irc_command_stats (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- if (arguments)
- irc_server_sendf (ptr_server, "STATS %s", arguments);
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "STATS %s", argv_eol[1]);
else
irc_server_sendf (ptr_server, "STATS");
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3139,14 +3110,20 @@ irc_command_summon (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
+
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "SUMMON %s", argv_eol[1]);
+ else
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "summon");
+ }
- irc_server_sendf (ptr_server, "SUMMON %s", arguments);
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3159,17 +3136,18 @@ irc_command_time (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- if (arguments)
- irc_server_sendf (ptr_server, "TIME %s", arguments);
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "TIME %s", argv_eol[1]);
else
irc_server_sendf (ptr_server, "TIME");
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3180,36 +3158,28 @@ int
irc_command_topic (void *data, void *buffer, int argc, char **argv,
char **argv_eol)
{
- char *channel_name, *new_topic, *pos;
+ char *channel_name, *new_topic;
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
channel_name = NULL;
new_topic = NULL;
- if (arguments)
+ if (argc > 1)
{
- if (irc_channel_is_channel (arguments))
+ if (irc_channel_is_channel (argv[1]))
{
- channel_name = arguments;
- pos = strchr (arguments, ' ');
- if (pos)
- {
- pos[0] = '\0';
- pos++;
- while (pos[0] == ' ')
- pos++;
- new_topic = (pos[0]) ? pos : NULL;
- }
+ channel_name = argv[1];
+ new_topic = argv_eol[2];
}
else
- new_topic = arguments;
+ new_topic = argv_eol[1];
}
/* look for current channel if not specified */
@@ -3220,16 +3190,16 @@ irc_command_topic (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
+ _("%sirc: \"%s\" command can only be "
"executed in a channel buffer"),
weechat_prefix ("error"), "topic");
- return -1;
+ return PLUGIN_RC_FAILED;
}
}
if (new_topic)
{
- if (strcmp (new_topic, "-delete") == 0)
+ if (weechat_strcasecmp (new_topic, "-delete") == 0)
irc_server_sendf (ptr_server, "TOPIC %s :",
channel_name);
else
@@ -3240,7 +3210,7 @@ irc_command_topic (void *data, void *buffer, int argc, char **argv,
irc_server_sendf (ptr_server, "TOPIC %s",
channel_name);
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3253,17 +3223,18 @@ irc_command_trace (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- if (arguments)
- irc_server_sendf (ptr_server, "TRACE %s", arguments);
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "TRACE %s", argv_eol[1]);
else
irc_server_sendf (ptr_server, "TRACE");
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3306,7 +3277,7 @@ irc_command_unban (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
+ _("%sirc: \"%s\" command can only be "
"executed in a channel buffer"),
weechat_prefix ("error"), "unban");
return PLUGIN_RC_FAILED;
@@ -3324,7 +3295,7 @@ irc_command_unban (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: wrong argument count for \"%s\" command"),
+ _("%sirc: wrong argument count for \"%s\" command"),
weechat_prefix ("error"), "unban");
return PLUGIN_RC_FAILED;
}
@@ -3342,14 +3313,20 @@ irc_command_userhost (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- irc_server_sendf (ptr_server, "USERHOST %s", arguments);
- return 0;
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "USERHOST %s", argv_eol[1]);
+ else
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "userhost");
+ }
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3362,17 +3339,18 @@ irc_command_users (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- if (arguments)
- irc_server_sendf (ptr_server, "USERS %s", arguments);
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "USERS %s", argv_eol[1]);
else
irc_server_sendf (ptr_server, "USERS");
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3385,26 +3363,26 @@ irc_command_version (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
- (void) argv;
+ (void) data;
+ (void) argv_eol;
- if (arguments)
+ if (argc > 1)
{
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL)
- && irc_nick_search (ptr_channel, arguments))
+ && irc_nick_search (ptr_channel, argv[1]))
irc_server_sendf (ptr_server, "PRIVMSG %s :\01VERSION\01",
- arguments);
+ argv[1]);
else
irc_server_sendf (ptr_server, "VERSION %s",
- arguments);
+ argv[1]);
}
else
irc_server_sendf (ptr_server, "VERSION");
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3417,14 +3395,15 @@ irc_command_voice (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER_CHANNEL(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) arguments;
+ (void) data;
+ (void) argv_eol;
if (ptr_channel && (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL))
{
- if (argc == 0)
+ if (argc < 2)
irc_server_sendf (ptr_server, "MODE %s +v %s",
ptr_channel->name,
ptr_server->nick);
@@ -3435,12 +3414,12 @@ irc_command_voice (void *data, void *buffer, int argc, char **argv,
else
{
weechat_printf (ptr_server->buffer,
- _("%sIrc: \"%s\" command can only be "
+ _("%sirc: \"%s\" command can only be "
"executed in a channel buffer"),
weechat_prefix ("error"), "voice");
- return -1;
+ return PLUGIN_RC_FAILED;
}
- return 0;
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3454,14 +3433,20 @@ irc_command_wallops (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- irc_server_sendf (ptr_server, "WALLOPS :%s", arguments);
- return 0;
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "WALLOPS :%s", argv_eol[1]);
+ else
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "wallops");
+ }
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3474,17 +3459,18 @@ irc_command_who (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- if (arguments)
- irc_server_sendf (ptr_server, "WHO %s", arguments);
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "WHO %s", argv_eol[1]);
else
irc_server_sendf (ptr_server, "WHO");
- return 0;
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3497,14 +3483,20 @@ irc_command_whois (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- irc_server_sendf (ptr_server, "WHOIS %s", arguments);
- return 0;
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "WHOIS %s", argv_eol[1]);
+ else
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "whois");
+ }
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3517,14 +3509,20 @@ irc_command_whowas (void *data, void *buffer, int argc, char **argv,
{
IRC_COMMAND_GET_SERVER(buffer);
if (!ptr_server || !ptr_server->is_connected)
- return -1;
+ return PLUGIN_RC_FAILED;
/* make C compiler happy */
- (void) argc;
+ (void) data;
(void) argv;
- irc_server_sendf (ptr_server, "WHOWAS %s", arguments);
- return 0;
+ if (argc > 1)
+ irc_server_sendf (ptr_server, "WHOWAS %s", argv_eol[1]);
+ else
+ {
+ IRC_COMMAND_TOO_FEW_ARGUMENTS(ptr_server->buffer, "whowas");
+ }
+
+ return PLUGIN_RC_SUCCESS;
}
/*
@@ -3788,8 +3786,8 @@ irc_command_init ()
weechat_hook_command ("ping",
N_("ping server"),
N_("server1 [server2]"),
- N_("server1: server to ping\nserver2: forward ping "
- "to this server"),
+ N_("server1: server to ping\n"
+ "server2: forward ping to this server"),
NULL, &irc_command_ping, NULL);
weechat_hook_command ("pong",
N_("answer to a ping message"),
@@ -3804,12 +3802,6 @@ irc_command_init ()
N_("nickname: nickname for private conversation\n"
" text: text to send"),
"%n %-", &irc_command_query, NULL);
- weechat_hook_command ("quit",
- N_("close all connections and quit"),
- N_("[quit_message]"),
- N_("quit_message: quit message (displayed to other "
- "users)"),
- "%q", &irc_command_quit, NULL);
weechat_hook_command ("quote",
N_("send raw data to server without parsing"),
N_("data"),
@@ -3896,7 +3888,8 @@ irc_command_init ()
weechat_hook_command ("squery",
N_("deliver a message to a service"),
N_("service text"),
- N_("service: name of service\ntext: text to send"),
+ N_("service: name of service\n"
+ "text: text to send"),
NULL, &irc_command_squery, NULL);
weechat_hook_command ("squit",
N_("disconnect server links"),
@@ -3915,7 +3908,8 @@ irc_command_init ()
"server a message asking them to please join "
"IRC"),
N_("user [target [channel]]"),
- N_(" user: username\ntarget: server name\n"
+ N_(" user: username\n"
+ "target: server name\n"
"channel: channel name"),
NULL, &irc_command_summon, NULL);
weechat_hook_command ("time",
@@ -3926,7 +3920,8 @@ irc_command_init ()
weechat_hook_command ("topic",
N_("get/set channel topic"),
N_("[channel] [topic]"),
- N_("channel: channel name\ntopic: new topic for "
+ N_("channel: channel name\n"
+ "topic: new topic for "
"channel (if topic is \"-delete\" then topic "
"is deleted)"),
"%t|-delete %-", &irc_command_topic, NULL);
diff --git a/src/plugins/irc/irc-command.h b/src/plugins/irc/irc-command.h
index 66997bd9d..cec8fb8c4 100644
--- a/src/plugins/irc/irc-command.h
+++ b/src/plugins/irc/irc-command.h
@@ -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 */
diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c
index 2c3369223..afe0c22b3 100644
--- a/src/plugins/irc/irc-config.c
+++ b/src/plugins/irc/irc-config.c
@@ -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;
diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h
index 6dc336005..40aeb686b 100644
--- a/src/plugins/irc/irc-config.h
+++ b/src/plugins/irc/irc-config.h
@@ -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 */
diff --git a/src/plugins/irc/irc-dcc.c b/src/plugins/irc/irc-dcc.c
index 3c6b130e4..01da53991 100644
--- a/src/plugins/irc/irc-dcc.c
+++ b/src/plugins/irc/irc-dcc.c
@@ -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)
diff --git a/src/plugins/irc/irc-display.c b/src/plugins/irc/irc-display.c
index 0f3ebffe2..8dfead1f7 100644
--- a/src/plugins/irc/irc-display.c
+++ b/src/plugins/irc/irc-display.c
@@ -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)") : "");
}
}
diff --git a/src/plugins/irc/irc-input.c b/src/plugins/irc/irc-input.c
index dc8b71922..e9ef9419d 100644
--- a/src/plugins/irc/irc-input.c
+++ b/src/plugins/irc/irc-input.c
@@ -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,
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index db26345c6..d8dab8144 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -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)
{
+ (void) server;
+ (void) channel;
+ (void) nick;
+ (void) new_nick;
+
+ /*
int nick_is_me;
- t_weelist *ptr_weelist;
- t_gui_nick *ptr_nick;
+ struct t_weelist *ptr_weelist;
+ struct t_gui_nick *ptr_nick;
- /* update buffer 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);
}
}
+ */
}
/*
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 3a219768b..a9efb3245 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -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[] =
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index ffd893ac3..729f91a39 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -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)
diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c
index 279bf582c..5f652d580 100644
--- a/src/plugins/irc/irc.c
+++ b/src/plugins/irc/irc.c
@@ -30,6 +30,7 @@
#endif
#include "irc.h"
+#include "irc-command.h"
#include "irc-config.h"
#include "irc-server.h"
@@ -113,6 +114,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;
}
diff --git a/src/plugins/irc/irc.h b/src/plugins/irc/irc.h
index 96722b8ac..969ed0df3 100644
--- a/src/plugins/irc/irc.h
+++ b/src/plugins/irc/irc.h
@@ -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;
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c
index c9addab57..5b14f0efe 100644
--- a/src/plugins/plugin-api.c
+++ b/src/plugins/plugin-api.c
@@ -162,6 +162,20 @@ plugin_api_strncasecmp (struct t_weechat_plugin *plugin,
}
/*
+ * 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)
{
diff --git a/src/plugins/plugin-api.h b/src/plugins/plugin-api.h
index 141282ad3..2f7505e55 100644
--- a/src/plugins/plugin-api.h
+++ b/src/plugins/plugin-api.h
@@ -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 *,
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index f1057c3cf..034d18e78 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -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;
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index efb0cb3ec..bed73a4f6 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -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)