summaryrefslogtreecommitdiff
path: root/src/plugins/irc
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-01-01 18:22:26 +0100
committerSebastien Helleu <flashcode@flashtux.org>2008-01-01 18:22:26 +0100
commit9222a7b109bf5c20ac60466cfc293dc462989bdf (patch)
treee9ddc3fb3cdc238083e1252deafb7f928b837192 /src/plugins/irc
parentcdbffe40da5f4fb23494b0464eea74ad1619a82b (diff)
downloadweechat-9222a7b109bf5c20ac60466cfc293dc462989bdf.zip
Added group support for nicklist, fixed some bugs in plugins API and IRC plugin
Added group support for nicklist (with subgroups). Partial changes in IRC protocol functions (new arguments with argv and argv_eol). Fixed some bugs: - nicklist in plugins API - problem in main loop with select() when SIGWINCH is received (terminal resize) - bug in string explode function - bug in infobar countdown.
Diffstat (limited to 'src/plugins/irc')
-rw-r--r--src/plugins/irc/irc-buffer.h3
-rw-r--r--src/plugins/irc/irc-channel.c60
-rw-r--r--src/plugins/irc/irc-channel.h4
-rw-r--r--src/plugins/irc/irc-command.c6
-rw-r--r--src/plugins/irc/irc-completion.c12
-rw-r--r--src/plugins/irc/irc-dcc.c23
-rw-r--r--src/plugins/irc/irc-dcc.h3
-rw-r--r--src/plugins/irc/irc-display.c1
-rw-r--r--src/plugins/irc/irc-mode.h3
-rw-r--r--src/plugins/irc/irc-nick.c246
-rw-r--r--src/plugins/irc/irc-nick.h17
-rw-r--r--src/plugins/irc/irc-protocol.c555
-rw-r--r--src/plugins/irc/irc-protocol.h14
-rw-r--r--src/plugins/irc/irc-server.c93
-rw-r--r--src/plugins/irc/irc.c48
-rw-r--r--src/plugins/irc/irc.h3
16 files changed, 598 insertions, 493 deletions
diff --git a/src/plugins/irc/irc-buffer.h b/src/plugins/irc/irc-buffer.h
index 600493bf5..4286a21fb 100644
--- a/src/plugins/irc/irc-buffer.h
+++ b/src/plugins/irc/irc-buffer.h
@@ -20,9 +20,6 @@
#ifndef __WEECHAT_IRC_BUFFER_H
#define __WEECHAT_IRC_BUFFER_H 1
-#include "irc-server.h"
-#include "irc-channel.h"
-
#define IRC_BUFFER_SERVER(buffer) (((t_irc_buffer_data *)(buffer->protocol_data))->server)
#define IRC_BUFFER_CHANNEL(buffer) (((t_irc_buffer_data *)(buffer->protocol_data))->channel)
#define IRC_BUFFER_ALL_SERVERS(buffer) (((t_irc_buffer_data *)(buffer->protocol_data))->all_servers)
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index 635fc0df4..40f55e354 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -64,7 +64,20 @@ irc_channel_new (struct t_irc_server *server, int channel_type,
return NULL;
}
if (channel_type == IRC_CHANNEL_TYPE_CHANNEL)
+ {
weechat_buffer_set (new_buffer, "nicklist", "1");
+ weechat_buffer_set (new_buffer, "nicklist_display_groups", "0");
+ weechat_nicklist_add_group (new_buffer, NULL, IRC_NICK_GROUP_OP,
+ "color_nicklist_group", 1);
+ weechat_nicklist_add_group (new_buffer, NULL, IRC_NICK_GROUP_HALFOP,
+ "color_nicklist_group", 1);
+ weechat_nicklist_add_group (new_buffer, NULL, IRC_NICK_GROUP_VOICE,
+ "color_nicklist_group", 1);
+ weechat_nicklist_add_group (new_buffer, NULL, IRC_NICK_GROUP_CHANUSER,
+ "color_nicklist_group", 1);
+ weechat_nicklist_add_group (new_buffer, NULL, IRC_NICK_GROUP_NORMAL,
+ "color_nicklist_group", 1);
+ }
/* initialize new channel */
new_channel->type = channel_type;
@@ -450,6 +463,9 @@ void
irc_channel_add_nick_speaking (struct t_irc_channel *channel, char *nick)
{
int size, to_remove, i;
+
+ if (!channel->nicks_speaking)
+ channel->nicks_speaking = weechat_list_new ();
weechat_list_add (channel->nicks_speaking, nick, "end");
@@ -474,25 +490,27 @@ irc_channel_print_log (struct t_irc_channel *channel)
{
struct t_weelist_item *ptr_item;
int i;
+ struct t_irc_nick *ptr_nick;
- weechat_log_printf ("=> channel %s (addr:0x%X)]", channel->name, channel);
- weechat_log_printf (" type . . . . . . . . : %d", channel->type);
- weechat_log_printf (" dcc_chat . . . . . . : 0x%X", channel->dcc_chat);
- weechat_log_printf (" topic. . . . . . . . : '%s'", channel->topic);
- weechat_log_printf (" modes. . . . . . . . : '%s'", channel->modes);
- weechat_log_printf (" limit. . . . . . . . : %d", channel->limit);
- weechat_log_printf (" key. . . . . . . . . : '%s'", channel->key);
- weechat_log_printf (" checking_away. . . . : %d", channel->checking_away);
- weechat_log_printf (" away_message . . . . : '%s'", channel->away_message);
- weechat_log_printf (" cycle. . . . . . . . : %d", channel->cycle);
- weechat_log_printf (" close. . . . . . . . : %d", channel->close);
- weechat_log_printf (" display_creation_date: %d", channel->display_creation_date);
- weechat_log_printf (" nicks. . . . . . . . : 0x%X", channel->nicks);
- weechat_log_printf (" last_nick. . . . . . : 0x%X", channel->last_nick);
- weechat_log_printf (" buffer . . . . . . . : 0x%X", channel->buffer);
- weechat_log_printf (" nicks_speaking . . . : 0x%X", channel->nicks_speaking);
- weechat_log_printf (" prev_channel . . . . : 0x%X", channel->prev_channel);
- weechat_log_printf (" next_channel . . . . : 0x%X", channel->next_channel);
+ weechat_log_printf ("");
+ weechat_log_printf (" => channel %s (addr:0x%X)]", channel->name, channel);
+ weechat_log_printf (" type . . . . . . . . : %d", channel->type);
+ weechat_log_printf (" dcc_chat . . . . . . : 0x%X", channel->dcc_chat);
+ weechat_log_printf (" topic. . . . . . . . : '%s'", channel->topic);
+ weechat_log_printf (" modes. . . . . . . . : '%s'", channel->modes);
+ weechat_log_printf (" limit. . . . . . . . : %d", channel->limit);
+ weechat_log_printf (" key. . . . . . . . . : '%s'", channel->key);
+ weechat_log_printf (" checking_away. . . . : %d", channel->checking_away);
+ weechat_log_printf (" away_message . . . . : '%s'", channel->away_message);
+ weechat_log_printf (" cycle. . . . . . . . : %d", channel->cycle);
+ weechat_log_printf (" close. . . . . . . . : %d", channel->close);
+ weechat_log_printf (" display_creation_date: %d", channel->display_creation_date);
+ weechat_log_printf (" nicks. . . . . . . . : 0x%X", channel->nicks);
+ weechat_log_printf (" last_nick. . . . . . : 0x%X", channel->last_nick);
+ weechat_log_printf (" buffer . . . . . . . : 0x%X", channel->buffer);
+ weechat_log_printf (" nicks_speaking . . . : 0x%X", channel->nicks_speaking);
+ weechat_log_printf (" prev_channel . . . . : 0x%X", channel->prev_channel);
+ weechat_log_printf (" next_channel . . . . : 0x%X", channel->next_channel);
if (channel->nicks_speaking)
{
weechat_log_printf ("");
@@ -500,9 +518,13 @@ irc_channel_print_log (struct t_irc_channel *channel)
for (ptr_item = weechat_list_get (channel->nicks_speaking, 0);
ptr_item; ptr_item = weechat_list_next (ptr_item))
{
- weechat_log_printf (" nick speaking %d: '%s'",
+ weechat_log_printf (" nick speaking %d: '%s'",
i, weechat_list_string (ptr_item));
i++;
}
}
+ for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
+ {
+ irc_nick_print_log (ptr_nick);
+ }
}
diff --git a/src/plugins/irc/irc-channel.h b/src/plugins/irc/irc-channel.h
index cd3c453e7..d7a30073d 100644
--- a/src/plugins/irc/irc-channel.h
+++ b/src/plugins/irc/irc-channel.h
@@ -20,8 +20,6 @@
#ifndef __WEECHAT_IRC_CHANNEL_H
#define __WEECHAT_IRC_CHANNEL_H 1
-#include "irc-server.h"
-
#define IRC_CHANNEL_PREFIX "#&+!"
/* channel types */
@@ -32,6 +30,8 @@
#define IRC_CHANNEL_NICKS_SPEAKING_LIMIT 32
+struct t_irc_server;
+
struct t_irc_channel
{
int type; /* channel type */
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c
index aac4448c2..435290693 100644
--- a/src/plugins/irc/irc-command.c
+++ b/src/plugins/irc/irc-command.c
@@ -849,8 +849,6 @@ irc_command_cycle (void *data, struct t_gui_buffer *buffer, int argc,
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
- if (version)
- free (version);
}
else
irc_server_sendf (ptr_server, "PART %s", channel_name);
@@ -1085,8 +1083,6 @@ irc_command_quit_server (struct t_irc_server *server, char *arguments)
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
- if (version)
- free (version);
}
else
irc_server_sendf (server, "QUIT");
@@ -2182,8 +2178,6 @@ irc_command_part (void *data, struct t_gui_buffer *buffer, int argc,
(buf) ? buf : ptr_arg);
if (buf)
free (buf);
- if (version)
- free (version);
}
else
irc_server_sendf (ptr_server, "PART %s", channel_name);
diff --git a/src/plugins/irc/irc-completion.c b/src/plugins/irc/irc-completion.c
index 82eb4e46f..f9c1f5f7b 100644
--- a/src/plugins/irc/irc-completion.c
+++ b/src/plugins/irc/irc-completion.c
@@ -90,7 +90,7 @@ irc_completion_server_nicks_cb (void *data, char *completion,
for (ptr_nick = ptr_channel2->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
- weechat_list_add (list, ptr_nick->nick, "sort");
+ weechat_list_add (list, ptr_nick->name, "sort");
}
}
}
@@ -102,7 +102,7 @@ irc_completion_server_nicks_cb (void *data, char *completion,
for (ptr_nick = ptr_channel->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
- weechat_list_add (list, ptr_nick->nick, "beginning");
+ weechat_list_add (list, ptr_nick->name, "beginning");
}
}
@@ -184,7 +184,7 @@ irc_completion_channel_nicks_cb (void *data, char *completion,
for (ptr_nick = ptr_channel->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
- weechat_list_add (list, ptr_nick->nick, "sort");
+ weechat_list_add (list, ptr_nick->name, "sort");
}
/* add nicks speaking recently on this channel */
@@ -241,16 +241,16 @@ irc_completion_channel_nicks_hosts_cb (void *data, char *completion,
for (ptr_nick = ptr_channel->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
- weechat_list_add (list, ptr_nick->nick, "sort");
+ weechat_list_add (list, ptr_nick->name, "sort");
if (ptr_nick->host)
{
- length = strlen (ptr_nick->nick) + 1 +
+ length = strlen (ptr_nick->name) + 1 +
strlen (ptr_nick->host) + 1;
buf = (char *)malloc (length);
if (buf)
{
snprintf (buf, length, "%s!%s",
- ptr_nick->nick, ptr_nick->host);
+ ptr_nick->name, ptr_nick->host);
weechat_list_add (list, buf, "sort");
free (buf);
}
diff --git a/src/plugins/irc/irc-dcc.c b/src/plugins/irc/irc-dcc.c
index 4c84000aa..cc7f7b928 100644
--- a/src/plugins/irc/irc-dcc.c
+++ b/src/plugins/irc/irc-dcc.c
@@ -124,7 +124,7 @@ irc_dcc_file_is_resumable (struct t_irc_dcc *ptr_dcc, char *filename)
{
struct stat st;
- if (!irc_cfg_dcc_auto_resume)
+ if (!weechat_config_boolean (irc_config_dcc_auto_resume))
return 0;
if (access (filename, W_OK) == 0)
@@ -154,15 +154,24 @@ irc_dcc_file_is_resumable (struct t_irc_dcc *ptr_dcc, char *filename)
void
irc_dcc_find_filename (struct t_irc_dcc *ptr_dcc)
{
- char *dir1, *dir2, *filename2;
+ char *weechat_home, *dir1, *dir2, *filename2, *dir_separator;
if (!IRC_DCC_IS_FILE(ptr_dcc->type))
return;
- dir1 = weechat_strreplace (irc_cfg_dcc_download_path, "~", getenv ("HOME"));
+ dir1 = weechat_string_replace (weechat_config_string (irc_config_dcc_download_path),
+ "~",
+ getenv ("HOME"));
if (!dir1)
return;
- dir2 = weechat_strreplace (dir1, "%h", weechat_home);
+
+ weechat_home = weechat_info_get ("weechat_dir");
+ if (!weechat_home)
+ {
+ free (dir1);
+ return;
+ }
+ dir2 = weechat_string_replace (dir1, "%h", weechat_home);
if (!dir2)
{
free (dir1);
@@ -176,8 +185,10 @@ irc_dcc_find_filename (struct t_irc_dcc *ptr_dcc)
return;
strcpy (ptr_dcc->local_filename, dir2);
- if (ptr_dcc->local_filename[strlen (ptr_dcc->local_filename) - 1] != DIR_SEPARATOR_CHAR)
- strcat (ptr_dcc->local_filename, DIR_SEPARATOR);
+ dir_separator = weechat_info_get("dir_separator");
+ if (dir_separator
+ && (ptr_dcc->local_filename[strlen (ptr_dcc->local_filename) - 1] != dir_separator[0]))
+ strcat (ptr_dcc->local_filename, dir_separator);
strcat (ptr_dcc->local_filename, ptr_dcc->nick);
strcat (ptr_dcc->local_filename, ".");
strcat (ptr_dcc->local_filename, ptr_dcc->filename);
diff --git a/src/plugins/irc/irc-dcc.h b/src/plugins/irc/irc-dcc.h
index f36bb0c51..00ebcc9cc 100644
--- a/src/plugins/irc/irc-dcc.h
+++ b/src/plugins/irc/irc-dcc.h
@@ -20,9 +20,6 @@
#ifndef __WEECHAT_IRC_DCC_H
#define __WEECHAT_IRC_DCC_H 1
-#include "irc-server.h"
-#include "irc-channel.h"
-
/* DCC types */
#define IRC_DCC_CHAT_RECV 0 /* receiving DCC chat */
diff --git a/src/plugins/irc/irc-display.c b/src/plugins/irc/irc-display.c
index 6d48de902..a7ea8cb61 100644
--- a/src/plugins/irc/irc-display.c
+++ b/src/plugins/irc/irc-display.c
@@ -29,6 +29,7 @@
#include <string.h>
#include "irc.h"
+#include "irc-channel.h"
#include "irc-command.h"
#include "irc-config.h"
#include "irc-server.h"
diff --git a/src/plugins/irc/irc-mode.h b/src/plugins/irc/irc-mode.h
index c53612f55..1d32ca806 100644
--- a/src/plugins/irc/irc-mode.h
+++ b/src/plugins/irc/irc-mode.h
@@ -20,7 +20,8 @@
#ifndef __WEECHAT_IRC_MODE_H
#define __WEECHAT_IRC_MODE_H 1
-#include "irc-server.h"
+struct t_irc_server;
+struct t_irc_channel;
extern void irc_mode_channel_set (struct t_irc_server *server,
struct t_irc_channel *channel, char *modes);
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index d51fde31f..cdd3757fa 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -39,20 +39,24 @@
* irc_nick_find_color: find a color for a nick (according to nick letters)
*/
-int
+char *
irc_nick_find_color (struct t_irc_nick *nick)
{
int i, color;
+ char color_name[64];
color = 0;
- for (i = strlen (nick->nick) - 1; i >= 0; i--)
+ for (i = strlen (nick->name) - 1; i >= 0; i--)
{
- color += (int)(nick->nick[i]);
+ color += (int)(nick->name[i]);
}
color = (color %
weechat_config_integer (weechat_config_get_weechat ("look_color_nicks_number")));
+
+ snprintf (color_name, sizeof (color_name),
+ "color_chat_nick_color%d", color);
- return color;
+ return weechat_color (color_name);
}
/*
@@ -61,56 +65,66 @@ irc_nick_find_color (struct t_irc_nick *nick)
*/
void
-irc_nick_get_gui_infos (struct t_irc_nick *nick,
- int *sort_index, char *prefix, int *color_prefix)
+irc_nick_get_gui_infos (struct t_gui_buffer *buffer,
+ struct t_irc_nick *nick,
+ char *prefix, int *color_prefix,
+ struct t_gui_nick_group **group)
{
if (nick->flags & IRC_NICK_CHANOWNER)
{
- *sort_index = 1;
*prefix = '~';
*color_prefix = 1;
+ *group = weechat_nicklist_search_group (buffer, NULL,
+ IRC_NICK_GROUP_OP);
}
else if (nick->flags & IRC_NICK_CHANADMIN)
{
- *sort_index = 2;
*prefix = '&';
*color_prefix = 1;
+ *group = weechat_nicklist_search_group (buffer, NULL,
+ IRC_NICK_GROUP_OP);
}
else if (nick->flags & IRC_NICK_CHANADMIN2)
{
- *sort_index = 3;
*prefix = '!';
*color_prefix = 1;
+ *group = weechat_nicklist_search_group (buffer, NULL,
+ IRC_NICK_GROUP_OP);
}
else if (nick->flags & IRC_NICK_OP)
{
- *sort_index = 4;
*prefix = '@';
*color_prefix = 1;
+ *group = weechat_nicklist_search_group (buffer, NULL,
+ IRC_NICK_GROUP_OP);
}
else if (nick->flags & IRC_NICK_HALFOP)
{
- *sort_index = 5;
*prefix = '%';
*color_prefix = 2;
+ *group = weechat_nicklist_search_group (buffer, NULL,
+ IRC_NICK_GROUP_HALFOP);
}
else if (nick->flags & IRC_NICK_VOICE)
{
- *sort_index = 6;
*prefix = '+';
*color_prefix = 3;
+ *group = weechat_nicklist_search_group (buffer, NULL,
+ IRC_NICK_GROUP_VOICE);
}
else if (nick->flags & IRC_NICK_CHANUSER)
{
- *sort_index = 7;
*prefix = '-';
*color_prefix = 4;
+ *group = weechat_nicklist_search_group (buffer, NULL,
+ IRC_NICK_GROUP_CHANUSER);
}
else
{
- *sort_index = 8;
*prefix = ' ';
*color_prefix = 0;
+ *group = weechat_nicklist_search_group (buffer, NULL,
+ IRC_NICK_GROUP_NORMAL);
}
}
@@ -124,52 +138,46 @@ 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, *ptr_nick;
+ char prefix, str_prefix_color[64];
+ int prefix_color;
+ struct t_gui_nick_group *ptr_group;
- /*
- 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?
- if ((new_nick = irc_nick_search (channel, nick_name)))
+ /* nick already exists on this channel? */
+ ptr_nick = irc_nick_search (channel, nick_name);
+ if (ptr_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);
- IRC_NICK_SET_FLAG(new_nick, is_op, IRC_NICK_OP);
- IRC_NICK_SET_FLAG(new_nick, is_halfop, IRC_NICK_HALFOP);
- IRC_NICK_SET_FLAG(new_nick, has_voice, IRC_NICK_VOICE);
- IRC_NICK_SET_FLAG(new_nick, is_chanuser, IRC_NICK_CHANUSER);
- irc_nick_get_gui_infos (new_nick, &sort_index, &prefix, &color_prefix);
- ptr_gui_nick = gui_nicklist_search (channel->buffer, new_nick->nick);
- if (ptr_gui_nick)
- gui_nicklist_update (channel->buffer, ptr_gui_nick, NULL,
- sort_index,
- ptr_gui_nick->color_nick,
- prefix,
- color_prefix);
-
- return new_nick;
+ /* update nick */
+ IRC_NICK_SET_FLAG(ptr_nick, is_chanowner, IRC_NICK_CHANOWNER);
+ IRC_NICK_SET_FLAG(ptr_nick, is_chanadmin, IRC_NICK_CHANADMIN);
+ IRC_NICK_SET_FLAG(ptr_nick, is_chanadmin2, IRC_NICK_CHANADMIN2);
+ IRC_NICK_SET_FLAG(ptr_nick, is_op, IRC_NICK_OP);
+ IRC_NICK_SET_FLAG(ptr_nick, is_halfop, IRC_NICK_HALFOP);
+ IRC_NICK_SET_FLAG(ptr_nick, has_voice, IRC_NICK_VOICE);
+ IRC_NICK_SET_FLAG(ptr_nick, is_chanuser, IRC_NICK_CHANUSER);
+
+ irc_nick_get_gui_infos (channel->buffer, ptr_nick, &prefix,
+ &prefix_color, &ptr_group);
+ weechat_nicklist_remove_nick (channel->buffer,
+ weechat_nicklist_search_nick (channel->buffer,
+ ptr_group,
+ ptr_nick->name));
+ snprintf (str_prefix_color, sizeof (str_prefix_color),
+ "color_nicklist_prefix%d",
+ prefix_color);
+ weechat_nicklist_add_nick (channel->buffer, ptr_group,
+ ptr_nick->name, ptr_nick->color,
+ prefix, str_prefix_color, 1);
+
+ return ptr_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
- new_nick->nick = strdup (nick_name);
+ /* initialize new nick */
+ new_nick->name = strdup (nick_name);
new_nick->host = NULL;
new_nick->flags = 0;
IRC_NICK_SET_FLAG(new_nick, is_chanowner, IRC_NICK_CHANOWNER);
@@ -179,12 +187,12 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
IRC_NICK_SET_FLAG(new_nick, is_halfop, IRC_NICK_HALFOP);
IRC_NICK_SET_FLAG(new_nick, has_voice, IRC_NICK_VOICE);
IRC_NICK_SET_FLAG(new_nick, is_chanuser, IRC_NICK_CHANUSER);
- if (weechat_strcasecmp (new_nick->nick, server->nick) == 0)
- new_nick->color = GUI_COLOR_CHAT_NICK_SELF;
+ if (weechat_strcasecmp (new_nick->name, server->nick) == 0)
+ new_nick->color = IRC_COLOR_CHAT_NICK_SELF;
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;
@@ -197,15 +205,18 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel,
channel->nick_completion_reset = 1;
- // 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
+ /* add nick to buffer nicklist */
+ irc_nick_get_gui_infos (channel->buffer, new_nick, &prefix, &prefix_color,
+ &ptr_group);
+ snprintf (str_prefix_color, sizeof (str_prefix_color),
+ "color_nicklist_prefix%d",
+ prefix_color);
+ weechat_nicklist_add_nick (channel->buffer, ptr_group,
+ new_nick->name, new_nick->color,
+ prefix, str_prefix_color, 1);
+
+ /* all is ok, return address of new nick */
return new_nick;
- */
- return NULL;
}
/*
@@ -216,46 +227,45 @@ 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;
- struct t_weelist *ptr_weelist;
- struct t_gui_nick *ptr_nick;
-
- // update buffer nick
- ptr_nick = gui_nicklist_search (channel->buffer, nick->nick);
- if (ptr_nick)
- gui_nicklist_update (channel->buffer, ptr_nick, new_nick,
- ptr_nick->sort_index,
- ptr_nick->color_nick,
- ptr_nick->prefix,
- ptr_nick->color_prefix);
-
- nick_is_me = (strcmp (nick->nick, server->nick) == 0) ? 1 : 0;
-
+ int nick_is_me, prefix_color;
+ struct t_gui_nick_group *ptr_group;
+ char prefix, str_prefix_color[64];
+
+ /* remove nick from nicklist */
+ irc_nick_get_gui_infos (channel->buffer, nick, &prefix, &prefix_color,
+ &ptr_group);
+ weechat_nicklist_remove_nick (channel->buffer,
+ weechat_nicklist_search_nick (channel->buffer,
+ ptr_group,
+ nick->name));
+
+ /* update nicks speaking */
+ nick_is_me = (strcmp (nick->name, server->nick) == 0) ? 1 : 0;
if (!nick_is_me && channel->nicks_speaking)
{
- ptr_weelist = weelist_search (channel->nicks_speaking, nick->nick);
- if (ptr_weelist && ptr_weelist->data)
- {
- free (ptr_weelist->data);
- ptr_weelist->data = strdup (new_nick);
- }
+ weechat_list_set (weechat_list_search (channel->nicks_speaking,
+ nick->name),
+ new_nick);
}
- // change nickname
- if (nick->nick)
- free (nick->nick);
- nick->nick = strdup (new_nick);
+ /* change nickname */
+ if (nick->name)
+ free (nick->name);
+ nick->name = strdup (new_nick);
if (nick_is_me)
- nick->color = GUI_COLOR_CHAT_NICK_SELF;
+ nick->color = IRC_COLOR_CHAT_NICK_SELF;
else
nick->color = irc_nick_find_color (nick);
- */
+
+ /* add nick in nicklist */
+ irc_nick_get_gui_infos (channel->buffer, nick, &prefix, &prefix_color,
+ &ptr_group);
+ snprintf (str_prefix_color, sizeof (str_prefix_color),
+ "color_nicklist_prefix%d",
+ prefix_color);
+ weechat_nicklist_add_nick (channel->buffer, ptr_group,
+ nick->name, nick->color,
+ prefix, str_prefix_color, 1);
}
/*
@@ -265,19 +275,23 @@ 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;
+ char prefix;
+ int prefix_color;
+ struct t_gui_nick_group *ptr_group;
if (!channel || !nick)
return;
- // remove nick from buffer nicklist
- (void) gui_nicklist_remove (channel->buffer, nick->nick);
+ /* remove nick from nicklist */
+ irc_nick_get_gui_infos (channel->buffer, nick, &prefix, &prefix_color,
+ &ptr_group);
+ weechat_nicklist_remove_nick (channel->buffer,
+ weechat_nicklist_search_nick (channel->buffer,
+ ptr_group,
+ nick->name));
- // remove nick from nicks list
+ /* remove nick */
if (channel->last_nick == nick)
channel->last_nick = nick->prev_nick;
if (nick->prev_nick)
@@ -293,16 +307,15 @@ irc_nick_free (struct t_irc_channel *channel, struct t_irc_nick *nick)
channel->nicks_count--;
- // free data
- if (nick->nick)
- free (nick->nick);
+ /* free data */
+ if (nick->name)
+ free (nick->name);
if (nick->host)
free (nick->host);
free (nick);
channel->nicks = new_nicks;
channel->nick_completion_reset = 1;
- */
}
/*
@@ -338,7 +351,7 @@ irc_nick_search (struct t_irc_channel *channel, char *nickname)
for (ptr_nick = channel->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
- if (weechat_strcasecmp (ptr_nick->nick, nickname) == 0)
+ if (weechat_strcasecmp (ptr_nick->name, nickname) == 0)
return ptr_nick;
}
return NULL;
@@ -438,7 +451,7 @@ irc_nick_as_prefix (struct t_irc_nick *nick, char *nickname, char *force_color)
&& weechat_config_string (irc_config_irc_nick_prefix)[0]) ?
weechat_config_string (irc_config_irc_nick_prefix) : "",
(force_color) ? force_color : ((nick) ? nick->color : IRC_COLOR_CHAT_NICK),
- (nick) ? nick->nick : nickname,
+ (nick) ? nick->name : nickname,
(weechat_config_string (irc_config_irc_nick_suffix)
&& weechat_config_string (irc_config_irc_nick_suffix)[0]) ?
IRC_COLOR_CHAT_DELIMITERS : "",
@@ -456,10 +469,11 @@ irc_nick_as_prefix (struct t_irc_nick *nick, char *nickname, char *force_color)
void
irc_nick_print_log (struct t_irc_nick *nick)
{
- weechat_log_printf ("=> nick %s (addr:0x%X):", nick->nick, nick);
- weechat_log_printf (" host . . . . . : %s", nick->host);
- weechat_log_printf (" flags. . . . . : %d", nick->flags);
- weechat_log_printf (" color. . . . . : %d", nick->color);
- weechat_log_printf (" prev_nick. . . : 0x%X", nick->prev_nick);
- weechat_log_printf (" next_nick. . . : 0x%X", nick->next_nick);
+ weechat_log_printf ("");
+ weechat_log_printf (" => nick %s (addr:0x%X):", nick->name, nick);
+ weechat_log_printf (" host . . . . . : %s", nick->host);
+ weechat_log_printf (" flags. . . . . : %d", nick->flags);
+ weechat_log_printf (" color. . . . . : '%s'", nick->color);
+ weechat_log_printf (" prev_nick. . . : 0x%X", nick->prev_nick);
+ weechat_log_printf (" next_nick. . . : 0x%X", nick->next_nick);
}
diff --git a/src/plugins/irc/irc-nick.h b/src/plugins/irc/irc-nick.h
index f0bc5ecd5..f26561370 100644
--- a/src/plugins/irc/irc-nick.h
+++ b/src/plugins/irc/irc-nick.h
@@ -20,9 +20,6 @@
#ifndef __WEECHAT_IRC_NICK_H
#define __WEECHAT_IRC_NICK_H 1
-#include "irc-server.h"
-#include "irc-channel.h"
-
#define IRC_NICK_DEFAULT_PREFIXES_LIST "@%+~&!-"
#define IRC_NICK_CHANOWNER 1
@@ -39,9 +36,18 @@
else \
nick->flags &= 0xFFFF - flag;
+#define IRC_NICK_GROUP_OP "1|op"
+#define IRC_NICK_GROUP_HALFOP "2|halfop"
+#define IRC_NICK_GROUP_VOICE "3|voice"
+#define IRC_NICK_GROUP_CHANUSER "4|chanuser"
+#define IRC_NICK_GROUP_NORMAL "5|normal"
+
+struct t_irc_server;
+struct t_irc_channel;
+
struct t_irc_nick
{
- char *nick; /* nickname */
+ char *name; /* nickname */
char *host; /* full hostname */
int flags; /* chanowner/chanadmin (unrealircd), */
/* op, halfop, voice, away */
@@ -50,9 +56,6 @@ struct t_irc_nick
struct t_irc_nick *next_nick; /* link to next nick on channel */
};
-extern int irc_nick_find_color (struct t_irc_nick *nick);
-extern void irc_nick_get_gui_infos (struct t_irc_nick *nick, int *sort_index,
- char *prefix, int *color_prefix);
extern struct t_irc_nick *irc_nick_new (struct t_irc_server *server,
struct t_irc_channel *channel,
char *nick_name, int is_chanowner,
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 87d7415e3..1494a123c 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* irc-protocol.c: description of IRC commands, according to
- RFC 1459,2810,2811,2812 */
+/* irc-protocol.c: description of IRC commands, according to RFC 1459, 2810,
+ 2811 2812 */
#ifdef HAVE_CONFIG_H
@@ -54,129 +54,126 @@
struct t_irc_protocol_msg irc_protocol_messages[] =
-{ { "error", N_("error received from IRC server"), irc_protocol_cmd_error },
- { "invite", N_("invite a nick on a channel"), irc_protocol_cmd_invite },
- { "join", N_("join a channel"), irc_protocol_cmd_join },
- { "kick", N_("forcibly remove a user from a channel"), irc_protocol_cmd_kick },
- { "kill", N_("close client-server connection"), irc_protocol_cmd_kill },
- { "mode", N_("change channel or user mode"), irc_protocol_cmd_mode },
- { "nick", N_("change current nickname"), irc_protocol_cmd_nick },
- { "notice", N_("send notice message to user"), irc_protocol_cmd_notice },
- { "part", N_("leave a channel"), irc_protocol_cmd_part },
- { "ping", N_("ping server"), irc_protocol_cmd_ping },
- { "pong", N_("answer to a ping message"), irc_protocol_cmd_pong },
- { "privmsg", N_("message received"), irc_protocol_cmd_privmsg },
- { "quit", N_("close all connections and quit"), irc_protocol_cmd_quit },
- { "topic", N_("get/set channel topic"), irc_protocol_cmd_topic },
+{ { "error", N_("error received from IRC server"), NULL, irc_protocol_cmd_error },
+ { "invite", N_("invite a nick on a channel"), NULL, irc_protocol_cmd_invite },
+ { "join", N_("join a channel"), NULL, irc_protocol_cmd_join },
+ { "kick", N_("forcibly remove a user from a channel"), irc_protocol_cmd_kick, NULL },
+ { "kill", N_("close client-server connection"), irc_protocol_cmd_kill, NULL },
+ { "mode", N_("change channel or user mode"), irc_protocol_cmd_mode, NULL },
+ { "nick", N_("change current nickname"), irc_protocol_cmd_nick, NULL },
+ { "notice", N_("send notice message to user"), irc_protocol_cmd_notice, NULL },
+ { "part", N_("leave a channel"), irc_protocol_cmd_part, NULL },
+ { "ping", N_("ping server"), irc_protocol_cmd_ping, NULL },
+ { "pong", N_("answer to a ping message"), irc_protocol_cmd_pong, NULL },
+ { "privmsg", N_("message received"), irc_protocol_cmd_privmsg, NULL },
+ { "quit", N_("close all connections and quit"), irc_protocol_cmd_quit, NULL },
+ { "topic", N_("get/set channel topic"), irc_protocol_cmd_topic, NULL },
{ "wallops", N_("send a message to all currently connected users who have "
- "set the 'w' user mode for themselves"), irc_protocol_cmd_wallops },
- { "001", N_("a server message"), irc_protocol_cmd_001 },
- { "005", N_("a server message"), irc_protocol_cmd_005 },
- { "221", N_("user mode string"), irc_protocol_cmd_221 },
- { "301", N_("away message"), irc_protocol_cmd_301 },
- { "302", N_("userhost"), irc_protocol_cmd_302 },
- { "303", N_("ison"), irc_protocol_cmd_303 },
- { "305", N_("unaway"), irc_protocol_cmd_305 },
- { "306", N_("now away"), irc_protocol_cmd_306 },
- { "307", N_("whois (registered nick)"), irc_protocol_cmd_whois_nick_msg },
- { "310", N_("whois (help mode)"), irc_protocol_cmd_310 },
- { "311", N_("whois (user)"), irc_protocol_cmd_311 },
- { "312", N_("whois (server)"), irc_protocol_cmd_312 },
- { "313", N_("whois (operator)"), irc_protocol_cmd_whois_nick_msg },
- { "314", N_("whowas"), irc_protocol_cmd_314 },
- { "315", N_("end of /who list"), irc_protocol_cmd_315 },
- { "317", N_("whois (idle)"), irc_protocol_cmd_317 },
- { "318", N_("whois (end)"), irc_protocol_cmd_whois_nick_msg },
- { "319", N_("whois (channels)"), irc_protocol_cmd_319 },
- { "320", N_("whois (identified user)"), irc_protocol_cmd_whois_nick_msg },
- { "321", N_("/list start"), irc_protocol_cmd_321 },
- { "322", N_("channel (for /list)"), irc_protocol_cmd_322 },
- { "323", N_("/list end"), irc_protocol_cmd_323 },
- { "324", N_("channel mode"), irc_protocol_cmd_324 },
- { "326", N_("whois (has oper privs)"), irc_protocol_cmd_whois_nick_msg },
- { "327", N_("whois (host)"), irc_protocol_cmd_327 },
- { "329", N_("channel creation date"), irc_protocol_cmd_329 },
- { "331", N_("no topic for channel"), irc_protocol_cmd_331 },
- { "332", N_("topic of channel"), irc_protocol_cmd_332 },
- { "333", N_("infos about topic (nick and date changed)"), irc_protocol_cmd_333 },
- { "338", N_("whois (host)"), irc_protocol_cmd_338 },
- { "341", N_("inviting"), irc_protocol_cmd_341 },
- { "344", N_("channel reop"), irc_protocol_cmd_344 },
- { "345", N_("end of channel reop list"), irc_protocol_cmd_345 },
- { "348", N_("channel exception list"), irc_protocol_cmd_348 },
- { "349", N_("end of channel exception list"), irc_protocol_cmd_349 },
- { "351", N_("server version"), irc_protocol_cmd_351 },
- { "352", N_("who"), irc_protocol_cmd_352 },
- { "353", N_("list of nicks on channel"), irc_protocol_cmd_353 },
- { "366", N_("end of /names list"), irc_protocol_cmd_366 },
- { "367", N_("banlist"), irc_protocol_cmd_367 },
- { "368", N_("end of banlist"), irc_protocol_cmd_368 },
- { "378", N_("whois (connecting from)"), irc_protocol_cmd_whois_nick_msg },
- { "379", N_("whois (using modes)"), irc_protocol_cmd_whois_nick_msg },
- { "401", N_("no such nick/channel"), irc_protocol_cmd_error },
- { "402", N_("no such server"), irc_protocol_cmd_error },
- { "403", N_("no such channel"), irc_protocol_cmd_error },
- { "404", N_("cannot send to channel"), irc_protocol_cmd_error },
- { "405", N_("too many channels"), irc_protocol_cmd_error },
- { "406", N_("was no such nick"), irc_protocol_cmd_error },
- { "407", N_("was no such nick"), irc_protocol_cmd_error },
- { "409", N_("no origin"), irc_protocol_cmd_error },
- { "410", N_("no services"), irc_protocol_cmd_error },
- { "411", N_("no recipient"), irc_protocol_cmd_error },
- { "412", N_("no text to send"), irc_protocol_cmd_error },
- { "413", N_("no toplevel"), irc_protocol_cmd_error },
- { "414", N_("wilcard in toplevel domain"), irc_protocol_cmd_error },
- { "421", N_("unknown command"), irc_protocol_cmd_error },
- { "422", N_("MOTD is missing"), irc_protocol_cmd_error },
- { "423", N_("no administrative info"), irc_protocol_cmd_error },
- { "424", N_("file error"), irc_protocol_cmd_error },
- { "431", N_("no nickname given"), irc_protocol_cmd_error },
- { "432", N_("erroneous nickname"), irc_protocol_cmd_432 },
- { "433", N_("nickname already in use"), irc_protocol_cmd_433 },
- { "436", N_("nickname collision"), irc_protocol_cmd_error },
- { "437", N_("resource unavailable"), irc_protocol_cmd_error },
- { "438", N_("not authorized to change nickname"), irc_protocol_cmd_438 },
- { "441", N_("user not in channel"), irc_protocol_cmd_error },
- { "442", N_("not on channel"), irc_protocol_cmd_error },
- { "443", N_("user already on channel"), irc_protocol_cmd_error },
- { "444", N_("user not logged in"), irc_protocol_cmd_error },
- { "445", N_("summon has been disabled"), irc_protocol_cmd_error },
- { "446", N_("users has been disabled"), irc_protocol_cmd_error },
- { "451", N_("you are not registered"), irc_protocol_cmd_error },
- { "461", N_("not enough parameters"), irc_protocol_cmd_error },
- { "462", N_("you may not register"), irc_protocol_cmd_error },
- { "463", N_("your host isn't among the privileged"), irc_protocol_cmd_error },
- { "464", N_("password incorrect"), irc_protocol_cmd_error },
- { "465", N_("you are banned from this server"), irc_protocol_cmd_error },
- { "467", N_("channel key already set"), irc_protocol_cmd_error },
- { "470", N_("forwarding to another channel"), irc_protocol_cmd_error },
- { "471", N_("channel is already full"), irc_protocol_cmd_error },
- { "472", N_("unknown mode char to me"), irc_protocol_cmd_error },
- { "473", N_("cannot join channel (invite only)"), irc_protocol_cmd_error },
- { "474", N_("cannot join channel (banned from channel)"), irc_protocol_cmd_error },
- { "475", N_("cannot join channel (bad channel key)"), irc_protocol_cmd_error },
- { "476", N_("bad channel mask"), irc_protocol_cmd_error },
- { "477", N_("channel doesn't support modes"), irc_protocol_cmd_error },
- { "481", N_("you're not an IRC operator"), irc_protocol_cmd_error },
- { "482", N_("you're not channel operator"), irc_protocol_cmd_error },
- { "483", N_("you can't kill a server!"), irc_protocol_cmd_error },
- { "484", N_("your connection is restricted!"), irc_protocol_cmd_error },
- { "485", N_("user is immune from kick/deop"), irc_protocol_cmd_error },
- { "487", N_("network split"), irc_protocol_cmd_error },
- { "491", N_("no O-lines for your host"), irc_protocol_cmd_error },
- { "501", N_("unknown mode flag"), irc_protocol_cmd_error },
- { "502", N_("can't change mode for other users"), irc_protocol_cmd_error },
- { "671", N_("whois (secure connection)"), irc_protocol_cmd_671 },
- { "973", N_("whois (secure connection)"), irc_protocol_cmd_server_mode_reason },
- { "974", N_("whois (secure connection)"), irc_protocol_cmd_server_mode_reason },
- { "975", N_("whois (secure connection)"), irc_protocol_cmd_server_mode_reason },
- { NULL, NULL, NULL }
+ "set the 'w' user mode for themselves"), irc_protocol_cmd_wallops, NULL },
+ { "001", N_("a server message"), irc_protocol_cmd_001, NULL },
+ { "005", N_("a server message"), irc_protocol_cmd_005, NULL },
+ { "221", N_("user mode string"), irc_protocol_cmd_221, NULL },
+ { "301", N_("away message"), irc_protocol_cmd_301, NULL },
+ { "302", N_("userhost"), irc_protocol_cmd_302, NULL },
+ { "303", N_("ison"), irc_protocol_cmd_303, NULL },
+ { "305", N_("unaway"), irc_protocol_cmd_305, NULL },
+ { "306", N_("now away"), irc_protocol_cmd_306, NULL },
+ { "307", N_("whois (registered nick)"), irc_protocol_cmd_whois_nick_msg, NULL },
+ { "310", N_("whois (help mode)"), irc_protocol_cmd_310, NULL },
+ { "311", N_("whois (user)"), irc_protocol_cmd_311, NULL },
+ { "312", N_("whois (server)"), irc_protocol_cmd_312, NULL },
+ { "313", N_("whois (operator)"), irc_protocol_cmd_whois_nick_msg, NULL },
+ { "314", N_("whowas"), irc_protocol_cmd_314, NULL },
+ { "315", N_("end of /who list"), irc_protocol_cmd_315, NULL },
+ { "317", N_("whois (idle)"), irc_protocol_cmd_317, NULL },
+ { "318", N_("whois (end)"), irc_protocol_cmd_whois_nick_msg, NULL },
+ { "319", N_("whois (channels)"), irc_protocol_cmd_319, NULL },
+ { "320", N_("whois (identified user)"), irc_protocol_cmd_whois_nick_msg, NULL },
+ { "321", N_("/list start"), irc_protocol_cmd_321, NULL },
+ { "322", N_("channel (for /list)"), irc_protocol_cmd_322, NULL },
+ { "323", N_("/list end"), irc_protocol_cmd_323, NULL },
+ { "324", N_("channel mode"), irc_protocol_cmd_324, NULL },
+ { "326", N_("whois (has oper privs)"), irc_protocol_cmd_whois_nick_msg, NULL },
+ { "327", N_("whois (host)"), irc_protocol_cmd_327, NULL },
+ { "329", N_("channel creation date"), irc_protocol_cmd_329, NULL },
+ { "331", N_("no topic for channel"), irc_protocol_cmd_331, NULL },
+ { "332", N_("topic of channel"), irc_protocol_cmd_332, NULL },
+ { "333", N_("infos about topic (nick and date changed)"), irc_protocol_cmd_333, NULL },
+ { "338", N_("whois (host)"), irc_protocol_cmd_338, NULL },
+ { "341", N_("inviting"), irc_protocol_cmd_341, NULL },
+ { "344", N_("channel reop"), irc_protocol_cmd_344, NULL },
+ { "345", N_("end of channel reop list"), irc_protocol_cmd_345, NULL },
+ { "348", N_("channel exception list"), irc_protocol_cmd_348, NULL },
+ { "349", N_("end of channel exception list"), irc_protocol_cmd_349, NULL },
+ { "351", N_("server version"), irc_protocol_cmd_351, NULL },
+ { "352", N_("who"), irc_protocol_cmd_352, NULL },
+ { "353", N_("list of nicks on channel"), irc_protocol_cmd_353, NULL },
+ { "366", N_("end of /names list"), irc_protocol_cmd_366, NULL },
+ { "367", N_("banlist"), irc_protocol_cmd_367, NULL },
+ { "368", N_("end of banlist"), irc_protocol_cmd_368, NULL },
+ { "378", N_("whois (connecting from)"), irc_protocol_cmd_whois_nick_msg, NULL },
+ { "379", N_("whois (using modes)"), irc_protocol_cmd_whois_nick_msg, NULL },
+ { "401", N_("no such nick/channel"), NULL, irc_protocol_cmd_error },
+ { "402", N_("no such server"), NULL, irc_protocol_cmd_error },
+ { "403", N_("no such channel"), NULL, irc_protocol_cmd_error },
+ { "404", N_("cannot send to channel"), NULL, irc_protocol_cmd_error },
+ { "405", N_("too many channels"), NULL, irc_protocol_cmd_error },
+ { "406", N_("was no such nick"), NULL, irc_protocol_cmd_error },
+ { "407", N_("was no such nick"), NULL, irc_protocol_cmd_error },
+ { "409", N_("no origin"), NULL, irc_protocol_cmd_error },
+ { "410", N_("no services"), NULL, irc_protocol_cmd_error },
+ { "411", N_("no recipient"), NULL, irc_protocol_cmd_error },
+ { "412", N_("no text to send"), NULL, irc_protocol_cmd_error },
+ { "413", N_("no toplevel"), NULL, irc_protocol_cmd_error },
+ { "414", N_("wilcard in toplevel domain"), NULL, irc_protocol_cmd_error },
+ { "421", N_("unknown command"), NULL, irc_protocol_cmd_error },
+ { "422", N_("MOTD is missing"), NULL, irc_protocol_cmd_error },
+ { "423", N_("no administrative info"), NULL, irc_protocol_cmd_error },
+ { "424", N_("file error"), NULL, irc_protocol_cmd_error },
+ { "431", N_("no nickname given"), NULL, irc_protocol_cmd_error },
+ { "432", N_("erroneous nickname"), NULL, irc_protocol_cmd_432 },
+ { "433", N_("nickname already in use"), NULL, irc_protocol_cmd_433 },
+ { "436", N_("nickname collision"), NULL, irc_protocol_cmd_error },
+ { "437", N_("resource unavailable"), NULL, irc_protocol_cmd_error },
+ { "438", N_("not authorized to change nickname"), irc_protocol_cmd_438, NULL },
+ { "441", N_("user not in channel"), NULL, irc_protocol_cmd_error },
+ { "442", N_("not on channel"), NULL, irc_protocol_cmd_error },
+ { "443", N_("user already on channel"), NULL, irc_protocol_cmd_error },
+ { "444", N_("user not logged in"), NULL, irc_protocol_cmd_error },
+ { "445", N_("summon has been disabled"), NULL, irc_protocol_cmd_error },
+ { "446", N_("users has been disabled"), NULL, irc_protocol_cmd_error },
+ { "451", N_("you are not registered"), NULL, irc_protocol_cmd_error },
+ { "461", N_("not enough parameters"), NULL, irc_protocol_cmd_error },
+ { "462", N_("you may not register"), NULL, irc_protocol_cmd_error },
+ { "463", N_("your host isn't among the privileged"), NULL, irc_protocol_cmd_error },
+ { "464", N_("password incorrect"), NULL, irc_protocol_cmd_error },
+ { "465", N_("you are banned from this server"), NULL, irc_protocol_cmd_error },
+ { "467", N_("channel key already set"), NULL, irc_protocol_cmd_error },
+ { "470", N_("forwarding to another channel"), NULL, irc_protocol_cmd_error },
+ { "471", N_("channel is already full"), NULL, irc_protocol_cmd_error },
+ { "472", N_("unknown mode char to me"), NULL, irc_protocol_cmd_error },
+ { "473", N_("cannot join channel (invite only)"), NULL, irc_protocol_cmd_error },
+ { "474", N_("cannot join channel (banned from channel)"), NULL, irc_protocol_cmd_error },
+ { "475", N_("cannot join channel (bad channel key)"), NULL, irc_protocol_cmd_error },
+ { "476", N_("bad channel mask"), NULL, irc_protocol_cmd_error },
+ { "477", N_("channel doesn't support modes"), NULL, irc_protocol_cmd_error },
+ { "481", N_("you're not an IRC operator"), NULL, irc_protocol_cmd_error },
+ { "482", N_("you're not channel operator"), NULL, irc_protocol_cmd_error },
+ { "483", N_("you can't kill a server!"), NULL, irc_protocol_cmd_error },
+ { "484", N_("your connection is restricted!"), NULL, irc_protocol_cmd_error },
+ { "485", N_("user is immune from kick/deop"), NULL, irc_protocol_cmd_error },
+ { "487", N_("network split"), NULL, irc_protocol_cmd_error },
+ { "491", N_("no O-lines for your host"), NULL, irc_protocol_cmd_error },
+ { "501", N_("unknown mode flag"), NULL, irc_protocol_cmd_error },
+ { "502", N_("can't change mode for other users"), NULL, irc_protocol_cmd_error },
+ { "671", N_("whois (secure connection)"), irc_protocol_cmd_671, NULL },
+ { "973", N_("whois (secure connection)"), irc_protocol_cmd_server_mode_reason, NULL },
+ { "974", N_("whois (secure connection)"), irc_protocol_cmd_server_mode_reason, NULL },
+ { "975", N_("whois (secure connection)"), irc_protocol_cmd_server_mode_reason, NULL },
+ { NULL, NULL, NULL, NULL }
};
-char *irc_message = NULL;
-
-
/*
* irc_protocol_get_wide_char: get wide char from string (first char)
*/
@@ -394,7 +391,8 @@ irc_protocol_is_highlight (char *message, char *nick)
*/
char *
-irc_protocol_replace_vars (struct t_irc_server *server, struct t_irc_channel *channel, char *string)
+irc_protocol_replace_vars (struct t_irc_server *server,
+ struct t_irc_channel *channel, char *string)
{
char *var_nick, *var_channel, *var_server;
char empty_string[1] = { '\0' };
@@ -429,6 +427,57 @@ irc_protocol_replace_vars (struct t_irc_server *server, struct t_irc_channel *ch
}
/*
+ * irc_protocol_get_nick_from_host: get nick from host in an IRC message
+ */
+
+char *
+irc_protocol_get_nick_from_host (char *host)
+{
+ static char nick[128];
+ char *pos;
+
+ nick[0] = '\0';
+ if (host)
+ {
+ if (host[0] == ':')
+ host++;
+ pos = strchr (host, '!');
+ if (pos && (pos - host < (int)sizeof (nick)))
+ {
+ strncpy (nick, host, pos - host);
+ nick[pos - host] = '\0';
+ }
+ else
+ snprintf (nick, sizeof (nick), "%s", host);
+ }
+ return nick;
+}
+
+/*
+ * irc_protocol_get_address_from_host: get address from host in an IRC message
+ */
+
+char *
+irc_protocol_get_address_from_host (char *host)
+{
+ static char address[256];
+ char *pos;
+
+ address[0] = '\0';
+ if (host)
+ {
+ if (host[0] == ':')
+ host++;
+ pos = strchr (host, '!');
+ if (pos)
+ snprintf (address, sizeof (address), "%s", pos + 1);
+ else
+ snprintf (address, sizeof (address), "%s", host);
+ }
+ return address;
+}
+
+/*
* irc_protocol_recv_command: executes action when receiving IRC command
* return: 0 = all ok, command executed
* -1 = command failed
@@ -440,11 +489,12 @@ int
irc_protocol_recv_command (struct t_irc_server *server, char *entire_line,
char *host, char *command, char *arguments)
{
- int i, cmd_found, return_code, ignore, highlight;
+ int i, cmd_found, return_code, ignore, highlight, argc;
char *pos, *nick;
char *dup_entire_line, *dup_host, *dup_arguments, *irc_message;
t_irc_recv_func *cmd_recv_func;
- char *cmd_name;
+ t_irc_recv_func2 *cmd_recv_func2;
+ char *cmd_name, **argv, **argv_eol;
if (!command)
return -2;
@@ -468,6 +518,7 @@ irc_protocol_recv_command (struct t_irc_server *server, char *entire_line,
{
cmd_name = command;
cmd_recv_func = irc_protocol_cmd_server_msg;
+ cmd_recv_func2 = NULL;
}
else
return -3;
@@ -476,10 +527,13 @@ irc_protocol_recv_command (struct t_irc_server *server, char *entire_line,
{
cmd_name = irc_protocol_messages[cmd_found].name;
cmd_recv_func = irc_protocol_messages[cmd_found].recv_function;
+ cmd_recv_func2 = irc_protocol_messages[cmd_found].recv_function2;
}
- if (cmd_recv_func != NULL)
+ if ((cmd_recv_func != NULL) || (cmd_recv_func2 != NULL))
{
+ argv = weechat_string_explode (entire_line, " ", 0, 0, &argc);
+ argv_eol = weechat_string_explode (entire_line, " ", 1, 0, NULL);
dup_entire_line = (entire_line) ? strdup (entire_line) : NULL;
dup_host = (host) ? strdup (host) : NULL;
dup_arguments = (arguments) ? strdup (arguments) : NULL;
@@ -505,10 +559,19 @@ irc_protocol_recv_command (struct t_irc_server *server, char *entire_line,
if (pos)
pos[0] = '!';
irc_message = strdup (dup_entire_line);
- return_code = (int) (cmd_recv_func) (server, irc_message,
- dup_host, nick,
- dup_arguments,
- ignore, highlight);
+
+ if (cmd_recv_func2 != NULL)
+ {
+ return_code = (int) (cmd_recv_func2) (server, argc, argv, argv_eol,
+ ignore, highlight);
+ }
+ else
+ {
+ return_code = (int) (cmd_recv_func) (server, irc_message,
+ dup_host, nick,
+ dup_arguments,
+ ignore, highlight);
+ }
if (irc_message)
free (irc_message);
if (nick)
@@ -519,6 +582,10 @@ irc_protocol_recv_command (struct t_irc_server *server, char *entire_line,
free (dup_host);
if (dup_arguments)
free (dup_arguments);
+ if (argv)
+ weechat_string_free_exploded (argv);
+ if (argv_eol)
+ weechat_string_free_exploded (argv_eol);
return return_code;
}
@@ -530,53 +597,41 @@ irc_protocol_recv_command (struct t_irc_server *server, char *entire_line,
*/
int
-irc_protocol_cmd_error (struct t_irc_server *server, char *irc_message, char *host,
- char *nick, char *arguments, int ignore, int highlight)
+irc_protocol_cmd_error (struct t_irc_server *server, int argc, char **argv,
+ char **argv_eol, int ignore, int highlight)
{
- char *pos_args, *pos;
- int first;
+ int first_arg;
+ char *chan_nick, *args;
/* make C compiler happy */
- (void) irc_message;
- (void) host;
- (void) nick;
+ (void) argc;
(void) ignore;
(void) highlight;
- first = 1;
+ first_arg = (strcmp (argv[2], server->nick) == 0) ? 3 : 2;
- pos_args = strstr (arguments, " :");
- if (pos_args)
+ if ((argv[first_arg][0] != ':') && argv[first_arg + 1])
{
- pos_args[0] = '\0';
- if (weechat_strncasecmp (arguments, server->nick,
- strlen (server->nick)) == 0)
- {
- pos = strchr (arguments, ' ');
- if (pos)
- {
- while (pos[0] == ' ')
- pos++;
- }
- else
- pos = arguments;
- }
- else
- {
- pos = arguments;
- }
- weechat_printf (server->buffer, "%s%s: %s",
- weechat_prefix ("error"),
- pos, pos_args + 2);
- if (strncmp (arguments, "Closing Link", 12) == 0)
- irc_server_disconnect (server, 1);
+ chan_nick = argv[first_arg];
+ args = argv_eol[first_arg + 1];
}
else
{
- weechat_printf (server->buffer, "%s%s",
- weechat_prefix ("error"),
- arguments);
+ chan_nick = NULL;
+ args = argv_eol[first_arg];
}
+ if (args[0] == ':')
+ args++;
+
+ weechat_printf (server->buffer,
+ "%s%s%s%s",
+ weechat_prefix ("error"),
+ (chan_nick) ? chan_nick : "",
+ (chan_nick) ? ": " : "",
+ args);
+
+ if (strncmp (args, "Closing Link", 12) == 0)
+ irc_server_disconnect (server, 1);
return WEECHAT_RC_OK;
}
@@ -586,47 +641,34 @@ irc_protocol_cmd_error (struct t_irc_server *server, char *irc_message, char *ho
*/
int
-irc_protocol_cmd_invite (struct t_irc_server *server, char *irc_message, char *host,
- char *nick, char *arguments, int ignore, int highlight)
+irc_protocol_cmd_invite (struct t_irc_server *server, int argc, char **argv,
+ char **argv_eol, int ignore, int highlight)
{
- char *pos_channel;
-
/* make C compiler happy */
- (void) irc_message;
- (void) host;
+ (void) argc;
+ (void) argv_eol;
(void) highlight;
- pos_channel = strchr (arguments, ' ');
- if (pos_channel)
+ if (!ignore && argv[3])
{
- pos_channel[0] = '\0';
- pos_channel++;
- while (pos_channel[0] == ' ')
- pos_channel++;
- if (pos_channel[0] == ':')
- pos_channel++;
-
- if (!ignore)
- {
- weechat_printf (server->buffer,
- _("You have been invited to %s%s%s by "
- "%s%s"),
- IRC_COLOR_CHAT_CHANNEL,
- pos_channel,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_NICK,
- nick);
- /*
- if (gui_add_hotlist
- && ((server->buffer->num_displayed == 0)
- || (gui_buffer_is_scrolled (server->buffer))))
- {
- gui_hotlist_add (GUI_HOTLIST_HIGHLIGHT, NULL,
- server->buffer, 0);
- gui_status_draw (gui_current_window->buffer, 1);
- }
- */
- }
+ weechat_printf (server->buffer,
+ _("You have been invited to %s%s%s by "
+ "%s%s"),
+ IRC_COLOR_CHAT_CHANNEL,
+ (argv[3][0] == ':') ? argv[3] + 1 : argv[3],
+ IRC_COLOR_CHAT,
+ IRC_COLOR_CHAT_NICK,
+ irc_protocol_get_nick_from_host (argv[0]));
+ /*
+ if (gui_add_hotlist
+ && ((server->buffer->num_displayed == 0)
+ || (gui_buffer_is_scrolled (server->buffer))))
+ {
+ gui_hotlist_add (GUI_HOTLIST_HIGHLIGHT, NULL,
+ server->buffer, 0);
+ gui_status_draw (gui_current_window->buffer, 1);
+ }
+ */
}
else
{
@@ -646,19 +688,20 @@ irc_protocol_cmd_invite (struct t_irc_server *server, char *irc_message, char *h
*/
int
-irc_protocol_cmd_join (struct t_irc_server *server, char *irc_message, char *host,
- char *nick, char *arguments, int ignore, int highlight)
+irc_protocol_cmd_join (struct t_irc_server *server, int argc, char **argv,
+ char **argv_eol, int ignore, int highlight)
{
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
- char *pos;
-
+ char *pos_channel;
+
/* make C compiler happy */
- (void) irc_message;
+ (void) argc;
+ (void) argv_eol;
(void) highlight;
/* no host => we can't identify sender of message! */
- if (!host)
+ if (argv[0][0] != ':')
{
weechat_printf (server->buffer,
_("%s%s: \"%s\" command received without host"),
@@ -666,38 +709,35 @@ irc_protocol_cmd_join (struct t_irc_server *server, char *irc_message, char *hos
return WEECHAT_RC_ERROR;
}
- if (arguments[0] == ':')
- arguments++;
-
- ptr_channel = irc_channel_search (server, arguments);
+ pos_channel = (argv[2][0] == ':') ? argv[2] + 1 : argv[2];
+ ptr_channel = irc_channel_search (server, pos_channel);
if (!ptr_channel)
{
ptr_channel = irc_channel_new (server, IRC_CHANNEL_TYPE_CHANNEL,
- arguments, 1);
+ pos_channel, 1);
if (!ptr_channel)
{
weechat_printf (server->buffer,
_("%s%s: cannot create new channel \"%s\""),
- weechat_prefix ("error"), "irc", arguments);
+ weechat_prefix ("error"), "irc", pos_channel);
return WEECHAT_RC_ERROR;
}
}
- pos = strchr (host, '!');
if (!ignore)
{
weechat_printf (ptr_channel->buffer,
_("%s%s%s %s(%s%s%s)%s has joined %s%s"),
weechat_prefix ("join"),
IRC_COLOR_CHAT_NICK,
- nick,
+ irc_protocol_get_nick_from_host (argv[0]),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
- (pos) ? pos + 1 : host,
+ irc_protocol_get_address_from_host (argv[0]),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_CHANNEL,
- arguments);
+ pos_channel);
}
/* remove topic and display channel creation date if joining new channel */
@@ -713,9 +753,11 @@ irc_protocol_cmd_join (struct t_irc_server *server, char *irc_message, char *hos
}
/* add nick in channel */
- ptr_nick = irc_nick_new (server, ptr_channel, nick, 0, 0, 0, 0, 0, 0, 0);
+ ptr_nick = irc_nick_new (server, ptr_channel,
+ irc_protocol_get_nick_from_host (argv[0]),
+ 0, 0, 0, 0, 0, 0, 0);
if (ptr_nick)
- ptr_nick->host = strdup ((pos) ? pos + 1 : host);
+ ptr_nick->host = strdup (irc_protocol_get_address_from_host (argv[0]));
/* redraw nicklist and status bar */
//gui_nicklist_draw (ptr_channel->buffer, 1, 1);
@@ -1082,7 +1124,7 @@ irc_protocol_cmd_nick (struct t_irc_server *server, char *irc_message, char *hos
ptr_nick = irc_nick_search (ptr_channel, nick);
if (ptr_nick)
{
- nick_is_me = (strcmp (ptr_nick->nick, server->nick) == 0) ? 1 : 0;
+ nick_is_me = (strcmp (ptr_nick->name, server->nick) == 0) ? 1 : 0;
//if (nick_is_me)
// gui_add_hotlist = 0;
irc_nick_change (server, ptr_channel, ptr_nick, arguments);
@@ -1403,7 +1445,8 @@ irc_protocol_cmd_part (struct t_irc_server *server, char *irc_message, char *hos
if (pos_args && pos_args[0])
{
weechat_printf (ptr_channel->buffer,
- _("%s%s %s(%s%s%s)%s has left %s%s %s(%s%s%s)"),
+ _("%s%s%s %s(%s%s%s)%s has left %s%s %s(%s%s%s)"),
+ weechat_prefix ("quit"),
IRC_COLOR_CHAT_NICK,
nick,
IRC_COLOR_CHAT_DELIMITERS,
@@ -1421,7 +1464,8 @@ irc_protocol_cmd_part (struct t_irc_server *server, char *irc_message, char *hos
else
{
weechat_printf (ptr_channel->buffer,
- _("%s%s %s(%s%s%s)%s has left %s%s"),
+ _("%s%s%s %s(%s%s%s)%s has left %s%s"),
+ weechat_prefix ("quit"),
IRC_COLOR_CHAT_NICK,
nick,
IRC_COLOR_CHAT_DELIMITERS,
@@ -1435,7 +1479,7 @@ irc_protocol_cmd_part (struct t_irc_server *server, char *irc_message, char *hos
}
/* part request was issued by local client ? */
- if (strcmp (ptr_nick->nick, server->nick) == 0)
+ if (strcmp (ptr_nick->name, server->nick) == 0)
{
irc_nick_free_all (ptr_channel);
@@ -1630,10 +1674,6 @@ irc_protocol_reply_version (struct t_irc_server *server, struct t_irc_channel *c
nick);
}
}
- if (version)
- free (version);
- if (date)
- free (date);
//(void) plugin_msg_handler_exec (server->name,
// "weechat_ctcp",
// irc_message);
@@ -2451,7 +2491,8 @@ irc_protocol_cmd_quit (struct t_irc_server *server, char *irc_message, char *hos
{
pos = strchr (host, '!');
weechat_printf (ptr_channel->buffer,
- _("%s%s %s(%s%s%s)%s has quit %s(%s%s%s)"),
+ _("%s%s%s %s(%s%s%s)%s has quit %s(%s%s%s)"),
+ weechat_prefix ("quit"),
IRC_COLOR_CHAT_NICK,
nick,
IRC_COLOR_CHAT_DELIMITERS,
@@ -4079,6 +4120,8 @@ irc_protocol_cmd_332 (struct t_irc_server *server, char *irc_message, char *host
if (ptr_channel->topic)
free (ptr_channel->topic);
ptr_channel->topic = strdup (pos2);
+ weechat_buffer_set (ptr_channel->buffer, "title",
+ ptr_channel->topic);
}
if (!ignore)
@@ -4092,9 +4135,6 @@ irc_protocol_cmd_332 (struct t_irc_server *server, char *irc_message, char *host
pos2,
IRC_COLOR_CHAT);
}
-
- //if (ptr_channel)
- // gui_chat_draw_title (ptr_buffer, 1);
}
}
else
@@ -4823,12 +4863,12 @@ irc_protocol_cmd_353 (struct t_irc_server *server, char *irc_message, char *host
if (!ignore && !ptr_channel)
{
/* display users on channel */
- weechat_printf (ptr_buffer,
- _("Nicks %s%s%s: %s["),
- IRC_COLOR_CHAT_CHANNEL,
- arguments,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_DELIMITERS);
+ //weechat_printf (ptr_buffer,
+ // _("Nicks %s%s%s: %s["),
+ // IRC_COLOR_CHAT_CHANNEL,
+ // arguments,
+ // IRC_COLOR_CHAT,
+ // IRC_COLOR_CHAT_DELIMITERS);
}
pos++;
@@ -4987,12 +5027,12 @@ irc_protocol_cmd_366 (struct t_irc_server *server, char *irc_message, char *host
if (!ignore)
{
/* display users on channel */
- weechat_printf (ptr_channel->buffer,
- _("Nicks %s%s%s: %s["),
- IRC_COLOR_CHAT_CHANNEL,
- ptr_channel->name,
- IRC_COLOR_CHAT,
- IRC_COLOR_CHAT_DELIMITERS);
+ //weechat_printf (ptr_channel->buffer,
+ // _("Nicks %s%s%s: %s["),
+ // IRC_COLOR_CHAT_CHANNEL,
+ // ptr_channel->name,
+ // IRC_COLOR_CHAT,
+ // IRC_COLOR_CHAT_DELIMITERS);
/*
for (ptr_nick = ptr_channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick)
@@ -5004,8 +5044,8 @@ irc_protocol_cmd_366 (struct t_irc_server *server, char *irc_message, char *host
gui_chat_printf (ptr_channel->buffer, " ");
}
*/
- weechat_printf (ptr_channel->buffer, "%s]",
- IRC_COLOR_CHAT_DELIMITERS);
+ //weechat_printf (ptr_channel->buffer, "%s]",
+ // IRC_COLOR_CHAT_DELIMITERS);
/* display number of nicks, ops, halfops & voices on the channel */
irc_nick_count (ptr_channel, &num_nicks, &num_op, &num_halfop, &num_voice,
@@ -5047,12 +5087,12 @@ irc_protocol_cmd_366 (struct t_irc_server *server, char *irc_message, char *host
{
if (!ignore)
{
- weechat_printf (server->buffer,
- "%s%s%s: %s",
- IRC_COLOR_CHAT_CHANNEL,
- pos,
- IRC_COLOR_CHAT,
- pos2);
+ //weechat_printf (server->buffer,
+ // "%s%s%s: %s",
+ // IRC_COLOR_CHAT_CHANNEL,
+ // pos,
+ // IRC_COLOR_CHAT,
+ // pos2);
}
return WEECHAT_RC_OK;
}
@@ -5259,13 +5299,12 @@ irc_protocol_cmd_368 (struct t_irc_server *server, char *irc_message, char *host
*/
int
-irc_protocol_cmd_432 (struct t_irc_server *server, char *irc_message, char *host,
- char *nick, char *arguments, int ignore, int highlight)
+irc_protocol_cmd_432 (struct t_irc_server *server, int argc, char **argv,
+ char **argv_eol, int ignore, int highlight)
{
/* Note: this IRC command can not be ignored */
- irc_protocol_cmd_error (server, irc_message, host, nick, arguments,
- ignore, highlight);
+ irc_protocol_cmd_error (server, argc, argv, argv_eol, ignore, highlight);
if (!server->is_connected)
{
@@ -5326,8 +5365,8 @@ irc_protocol_cmd_432 (struct t_irc_server *server, char *irc_message, char *host
*/
int
-irc_protocol_cmd_433 (struct t_irc_server *server, char *irc_message, char *host,
- char *nick, char *arguments, int ignore, int highlight)
+irc_protocol_cmd_433 (struct t_irc_server *server, int argc, char **argv,
+ char **argv_eol, int ignore, int highlight)
{
/* Note: this IRC command can not be ignored */
@@ -5382,8 +5421,8 @@ irc_protocol_cmd_433 (struct t_irc_server *server, char *irc_message, char *host
irc_server_sendf (server, "NICK %s", server->nick);
}
else
- return irc_protocol_cmd_error (server, irc_message, host, nick, arguments,
- ignore, highlight);
+ return irc_protocol_cmd_error (server, argc, argv, argv_eol, ignore,
+ highlight);
return WEECHAT_RC_OK;
}
diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h
index d76911657..788007e28 100644
--- a/src/plugins/irc/irc-protocol.h
+++ b/src/plugins/irc/irc-protocol.h
@@ -25,19 +25,23 @@
typedef int (t_irc_recv_func)(struct t_irc_server *server, char *irc_message,
char *host, char *nick, char *arguments,
int ignore, int highlight);
+typedef int (t_irc_recv_func2)(struct t_irc_server *server, int argc,
+ char **argv, char **argv_eol,
+ int ignore, int highlight);
struct t_irc_protocol_msg
{
char *name; /* IRC message name */
char *description; /* message description */
t_irc_recv_func *recv_function; /* function called when msg is received */
+ t_irc_recv_func2 *recv_function2; /* function called when msg is received */
};
extern int irc_protocol_is_highlight (char *, char *);
extern int irc_protocol_recv_command (struct t_irc_server *, char *, char *, char *, char *);
-extern int irc_protocol_cmd_error (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
-extern int irc_protocol_cmd_invite (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
-extern int irc_protocol_cmd_join (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_error (struct t_irc_server *server, int argc, char **argv, char **argv_eol, int ignore, int highlight);
+extern int irc_protocol_cmd_invite (struct t_irc_server *server, int argc, char **argv, char **argv_eol, int ignore, int highlight);
+extern int irc_protocol_cmd_join (struct t_irc_server *server, int argc, char **argv, char **argv_eol, int ignore, int highlight);
extern int irc_protocol_cmd_kick (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
extern int irc_protocol_cmd_kill (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
extern int irc_protocol_cmd_mode (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
@@ -91,8 +95,8 @@ extern int irc_protocol_cmd_365 (struct t_irc_server *server, char *irc_message,
extern int irc_protocol_cmd_366 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
extern int irc_protocol_cmd_367 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
extern int irc_protocol_cmd_368 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
-extern int irc_protocol_cmd_432 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
-extern int irc_protocol_cmd_433 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
+extern int irc_protocol_cmd_432 (struct t_irc_server *server, int argc, char **argv, char **argv_eol, int ignore, int highlight);
+extern int irc_protocol_cmd_433 (struct t_irc_server *server, int argc, char **argv, char **argv_eol, int ignore, int highlight);
extern int irc_protocol_cmd_438 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
extern int irc_protocol_cmd_671 (struct t_irc_server *server, char *irc_message, char *host, char *nick, char *arguments, int ignore, int highlight);
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 4257a1a11..3391fb130 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -47,6 +47,7 @@
#include "irc.h"
#include "irc-server.h"
#include "irc-channel.h"
+#include "irc-command.h"
#include "irc-config.h"
#include "irc-nick.h"
#include "irc-protocol.h"
@@ -632,18 +633,23 @@ irc_server_new (char *name, int autoconnect, int autoreconnect,
if (!name || !address || (port < 0))
return NULL;
-#ifdef DEBUG
- weechat_log_printf ("Creating new server (name:%s, address:%s, port:%d, pwd:%s, "
- "nick1:%s, nick2:%s, nick3:%s, username:%s, realname:%s, "
- "hostname: %s, command:%s, autojoin:%s, autorejoin:%s, "
- "notify_levels:%s)",
- name, address, port, (password) ? password : "",
- (nick1) ? nick1 : "", (nick2) ? nick2 : "", (nick3) ? nick3 : "",
- (username) ? username : "", (realname) ? realname : "",
- (hostname) ? hostname : "", (command) ? command : "",
- (autojoin) ? autojoin : "", (autorejoin) ? "on" : "off",
- (notify_levels) ? notify_levels : "");
-#endif
+ if (irc_debug)
+ {
+ weechat_log_printf ("Creating new server (name:%s, address:%s, "
+ "port:%d, pwd:%s, nick1:%s, nick2:%s, nick3:%s, "
+ "username:%s, realname:%s, hostname: %s, "
+ "command:%s, autojoin:%s, autorejoin:%s, "
+ "notify_levels:%s)",
+ name, address, port, (password) ? password : "",
+ (nick1) ? nick1 : "", (nick2) ? nick2 : "",
+ (nick3) ? nick3 : "", (username) ? username : "",
+ (realname) ? realname : "",
+ (hostname) ? hostname : "",
+ (command) ? command : "",
+ (autojoin) ? autojoin : "",
+ (autorejoin) ? "on" : "off",
+ (notify_levels) ? notify_levels : "");
+ }
if ((new_server = irc_server_alloc ()))
{
@@ -850,12 +856,13 @@ irc_server_send_one_msg (struct t_irc_server *server, char *message)
time_t time_now;
rc = 1;
-
-#ifdef DEBUG
- weechat_printf (server->buffer,
- "[DEBUG] Sending to server >>> %s",
- message);
-#endif
+
+ if (irc_debug)
+ {
+ weechat_printf (server->buffer,
+ "[DEBUG] Sending to server >>> %s",
+ message);
+ }
/*new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_OUT,
server->name,
message)
@@ -1169,11 +1176,12 @@ irc_server_msgq_flush ()
{
if (irc_recv_msgq->data)
{
-#ifdef DEBUG
- weechat_printf (irc_recv_msgq->server->buffer,
- "[DEBUG] %s",
- irc_recv_msgq->data);
-#endif
+ if (irc_debug)
+ {
+ weechat_printf (irc_recv_msgq->server->buffer,
+ "[DEBUG] %s",
+ irc_recv_msgq->data);
+ }
ptr_data = irc_recv_msgq->data;
while (ptr_data[0] == ' ')
ptr_data++;
@@ -1182,11 +1190,12 @@ irc_server_msgq_flush ()
{
//gui_chat_printf_raw_data (irc_recv_msgq->server, 0, 0,
// ptr_data);
-#ifdef DEBUG
- weechat_printf (irc_recv_msgq->server->buffer,
- "[DEBUG] data received from server: %s",
- ptr_data);
-#endif
+ if (irc_debug)
+ {
+ weechat_printf (irc_recv_msgq->server->buffer,
+ "[DEBUG] data received from server: %s",
+ ptr_data);
+ }
/*new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_IN,
irc_recv_msgq->server->name,
ptr_data);*/
@@ -1293,7 +1302,7 @@ irc_server_recv_cb (void *arg_server)
static char buffer[4096 + 2];
int num_read;
-
+
if (!server)
return WEECHAT_RC_ERROR;
@@ -1319,7 +1328,7 @@ irc_server_recv_cb (void *arg_server)
weechat_prefix ("error"), "irc");
irc_server_disconnect (server, 1);
}
-
+
return WEECHAT_RC_OK;
}
@@ -1443,6 +1452,11 @@ irc_server_child_kill (struct t_irc_server *server)
void
irc_server_close_connection (struct t_irc_server *server)
{
+ if (server->hook_fd)
+ {
+ weechat_unhook (server->hook_fd);
+ server->hook_fd = NULL;
+ }
irc_server_child_kill (server);
/* close network socket */
@@ -1555,9 +1569,9 @@ irc_server_child_read (void *arg_server)
}
#endif
/* kill child and login to server */
+ weechat_unhook (server->hook_fd);
irc_server_child_kill (server);
irc_server_login (server);
- weechat_unhook (server->hook_fd);
server->hook_fd = weechat_hook_fd (server->sock,
1, 0, 0,
irc_server_recv_cb,
@@ -2260,9 +2274,9 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin)
/* create socket and set options */
if (config_proxy_use)
- server->sock = socket ((config_proxy_ipv6) ? AF_INET6 : AF_INET, SOCK_STREAM, 0);
+ server->sock = socket ((config_proxy_ipv6) ? AF_INET6 : AF_INET, SOCK_STREAM, 0);
else
- server->sock = socket ((server->ipv6) ? AF_INET6 : AF_INET, SOCK_STREAM, 0);
+ server->sock = socket ((server->ipv6) ? AF_INET6 : AF_INET, SOCK_STREAM, 0);
if (server->sock == -1)
{
weechat_printf (server->buffer,
@@ -2473,8 +2487,8 @@ irc_server_autojoin_channels (struct t_irc_server *server)
else
{
/* auto-join when connecting to server for first time */
- //if (!server->disable_autojoin && server->autojoin && server->autojoin[0])
- // irc_cmd_join_server (server, server->autojoin);
+ if (!server->disable_autojoin && server->autojoin && server->autojoin[0])
+ irc_command_join_server (server, server->autojoin);
}
server->disable_autojoin = 0;
@@ -2713,7 +2727,8 @@ void
irc_server_print_log ()
{
struct t_irc_server *ptr_server;
-
+ struct t_irc_channel *ptr_channel;
+
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
@@ -2774,5 +2789,11 @@ irc_server_print_log ()
weechat_log_printf (" last_channel. . . . : 0x%X", ptr_server->last_channel);
weechat_log_printf (" prev_server . . . . : 0x%X", ptr_server->prev_server);
weechat_log_printf (" next_server . . . . : 0x%X", ptr_server->next_server);
+
+ for (ptr_channel = ptr_server->channels; ptr_channel;
+ ptr_channel = ptr_channel->next_channel)
+ {
+ irc_channel_print_log (ptr_channel);
+ }
}
}
diff --git a/src/plugins/irc/irc.c b/src/plugins/irc/irc.c
index cc808eb0f..b84a3f541 100644
--- a/src/plugins/irc/irc.c
+++ b/src/plugins/irc/irc.c
@@ -45,9 +45,11 @@ char plugin_description[] = "IRC (Internet Relay Chat)";
struct t_weechat_plugin *weechat_irc_plugin = NULL;
-struct t_hook *irc_hook_timer = NULL;
+ struct t_hook *irc_hook_timer = NULL;
struct t_hook *irc_hook_timer_check_away = NULL;
+int irc_debug = 0;
+
#ifdef HAVE_GNUTLS
gnutls_certificate_credentials gnutls_xcred; /* gnutls client credentials */
#endif
@@ -60,10 +62,6 @@ gnutls_certificate_credentials gnutls_xcred; /* gnutls client credentials */
int
irc_dump_data_cb (void *data, char *signal, void *pointer)
{
- struct t_irc_server *ptr_server;
- struct t_irc_channel *ptr_channel;
- struct t_irc_nick *ptr_nick;
-
/* make C compiler happy */
(void) data;
(void) signal;
@@ -72,23 +70,7 @@ irc_dump_data_cb (void *data, char *signal, void *pointer)
weechat_log_printf ("");
weechat_log_printf ("***** IRC plugin dump *****");
- for (ptr_server = irc_servers; ptr_server;
- ptr_server = ptr_server->next_server)
- {
- irc_server_print_log (ptr_server);
-
- for (ptr_channel = ptr_server->channels; ptr_channel;
- ptr_channel = ptr_channel->next_channel)
- {
- irc_channel_print_log (ptr_channel);
-
- for (ptr_nick = ptr_channel->nicks; ptr_nick;
- ptr_nick = ptr_nick->next_nick)
- {
- irc_nick_print_log (ptr_nick);
- }
- }
- }
+ irc_server_print_log ();
//irc_dcc_print_log ();
@@ -120,7 +102,6 @@ irc_create_directories ()
free (dir1);
if (dir2)
free (dir2);
- free (weechat_dir);
}
}
@@ -147,6 +128,22 @@ irc_quit_cb (void *data, char *signal, void *pointer)
return WEECHAT_RC_OK;
}
+/*
+ * irc_debug_cb: callback for "debug" signal
+ */
+
+int
+irc_debug_cb (void *data, char *signal, void *pointer)
+{
+ /* make C compiler happy */
+ (void) data;
+ (void) signal;
+
+ if (weechat_strcasecmp ((char *)pointer, "irc") == 0)
+ irc_debug ^= 1;
+
+ return WEECHAT_RC_OK;
+}
/*
* weechat_plugin_init: initialize IRC plugin
@@ -178,12 +175,13 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
weechat_hook_signal ("dump_data", &irc_dump_data_cb, NULL);
weechat_hook_signal ("config_reload", &irc_config_reload_cb, NULL);
weechat_hook_signal ("quit", &irc_quit_cb, NULL);
+ weechat_hook_signal ("debug", &irc_debug_cb, NULL);
/* hook completions */
irc_completion_init ();
- //irc_server_auto_connect (1, 0);
-
+ irc_server_auto_connect (1, 0);
+
/*
irc_timer = weechat_hook_timer (1 * 1000, 0,
&irc_server_timer,
diff --git a/src/plugins/irc/irc.h b/src/plugins/irc/irc.h
index c859c0760..cf627bce0 100644
--- a/src/plugins/irc/irc.h
+++ b/src/plugins/irc/irc.h
@@ -55,6 +55,7 @@
#define IRC_COLOR_CHAT_HIGHLIGHT weechat_color("color_chat_highlight")
#define IRC_COLOR_CHAT_HOST weechat_color("color_chat_host")
#define IRC_COLOR_CHAT_NICK weechat_color("color_chat_nick")
+#define IRC_COLOR_CHAT_NICK_SELF weechat_color("color_chat_nick_self")
#define IRC_COLOR_CHAT_NICK_OTHER weechat_color("color_chat_nick_other")
#define IRC_COLOR_CHAT_SERVER weechat_color("color_chat_server")
#define IRC_COLOR_INFOBAR_HIGHLIGHT weechat_color("color_infobar_highlight")
@@ -67,6 +68,8 @@
extern struct t_weechat_plugin *weechat_irc_plugin;
extern struct t_hook *irc_hook_timer_check_away;
+extern int irc_debug;
+
extern gnutls_certificate_credentials gnutls_xcred;
#endif /* irc.h */