diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2005-12-06 18:20:59 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2005-12-06 18:20:59 +0000 |
commit | 0ef010d21121365ca901881de40d5daf6bf4f07a (patch) | |
tree | 55dcbfebd572e165ed3cf16838015c2ce0519101 /src/irc | |
parent | 6c7a71976b61c6a703d09d1de9db1f4b2496e738 (diff) | |
download | weechat-0ef010d21121365ca901881de40d5daf6bf4f07a.zip |
added /upgrade command, added ETA for DCC files
Diffstat (limited to 'src/irc')
-rw-r--r-- | src/irc/irc-channel.c | 49 | ||||
-rw-r--r-- | src/irc/irc-dcc.c | 117 | ||||
-rw-r--r-- | src/irc/irc-display.c | 10 | ||||
-rw-r--r-- | src/irc/irc-ignore.c | 18 | ||||
-rw-r--r-- | src/irc/irc-nick.c | 72 | ||||
-rw-r--r-- | src/irc/irc-recv.c | 60 | ||||
-rw-r--r-- | src/irc/irc-send.c | 12 | ||||
-rw-r--r-- | src/irc/irc-server.c | 139 | ||||
-rw-r--r-- | src/irc/irc.h | 117 |
9 files changed, 346 insertions, 248 deletions
diff --git a/src/irc/irc-channel.c b/src/irc/irc-channel.c index 86028f952..761e64fc7 100644 --- a/src/irc/irc-channel.c +++ b/src/irc/irc-channel.c @@ -41,8 +41,7 @@ char *channel_modes = "iklmnst"; */ t_irc_channel * -channel_new (t_irc_server *server, int channel_type, char *channel_name, - int switch_to_buffer) +channel_new (t_irc_server *server, int channel_type, char *channel_name) { t_irc_channel *new_channel; @@ -58,8 +57,9 @@ channel_new (t_irc_server *server, int channel_type, char *channel_name, new_channel->dcc_chat = NULL; new_channel->name = strdup (channel_name); new_channel->topic = NULL; - memset (new_channel->modes, ' ', sizeof (new_channel->modes)); - new_channel->modes[sizeof (new_channel->modes) - 1] = '\0'; + new_channel->modes = (char *) malloc (NUM_CHANNEL_MODES + 1); + memset (new_channel->modes, ' ', NUM_CHANNEL_MODES); + new_channel->modes[NUM_CHANNEL_MODES] = '\0'; new_channel->limit = 0; new_channel->key = NULL; new_channel->nicks_count = 0; @@ -75,8 +75,6 @@ channel_new (t_irc_server *server, int channel_type, char *channel_name, else server->channels = new_channel; server->last_channel = new_channel; - - gui_buffer_new (gui_current_window, server, new_channel, 0, switch_to_buffer); /* all is ok, return address of new channel */ return new_channel; @@ -182,11 +180,11 @@ channel_remove_away (t_irc_channel *channel) { t_irc_nick *ptr_nick; - if (channel->type == CHAT_CHANNEL) + if (channel->type == CHANNEL_TYPE_CHANNEL) { for (ptr_nick = channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) { - ptr_nick->is_away = 0; + NICK_SET_FLAG(ptr_nick, 0, NICK_AWAY); } gui_draw_buffer_nick (channel->buffer, 0); } @@ -199,7 +197,7 @@ channel_remove_away (t_irc_channel *channel) void channel_check_away (t_irc_server *server, t_irc_channel *channel) { - if (channel->type == CHAT_CHANNEL) + if (channel->type == CHANNEL_TYPE_CHANNEL) { channel->checking_away++; server_sendf (server, "WHO %s\r\n", channel->name); @@ -215,7 +213,7 @@ channel_set_away (t_irc_channel *channel, char *nick, int is_away) { t_irc_nick *ptr_nick; - if (channel->type == CHAT_CHANNEL) + if (channel->type == CHANNEL_TYPE_CHANNEL) { ptr_nick = nick_search (channel, nick); if (ptr_nick) @@ -234,10 +232,11 @@ channel_create_dcc (t_irc_dcc *ptr_dcc) ptr_channel = channel_search (ptr_dcc->server, ptr_dcc->nick); if (!ptr_channel) - ptr_channel = channel_new (ptr_dcc->server, CHAT_PRIVATE, - ptr_dcc->nick, 0); + ptr_channel = channel_new (ptr_dcc->server, CHANNEL_TYPE_PRIVATE, + ptr_dcc->nick); if (!ptr_channel) return 0; + gui_buffer_new (gui_current_window, ptr_dcc->server, ptr_channel, 0, 0); if (ptr_channel->dcc_chat && (!DCC_ENDED(((t_irc_dcc *)(ptr_channel->dcc_chat))->status))) @@ -406,17 +405,17 @@ channel_set_notify_level (t_irc_server *server, t_irc_channel *channel, int noti void channel_print_log (t_irc_channel *channel) { - wee_log_printf ("=> channel %s (addr:0x%X)]\n", channel->name, channel); - wee_log_printf (" type . . . . : %d\n", channel->type); - wee_log_printf (" dcc_chat . . : 0x%X\n", channel->dcc_chat); - wee_log_printf (" topic. . . . : '%s'\n", channel->topic); - wee_log_printf (" modes. . . . : '%s'\n", channel->modes); - wee_log_printf (" limit. . . . : %d\n", channel->limit); - wee_log_printf (" key. . . . . : '%s'\n", channel->key); - wee_log_printf (" checking_away: %d\n", channel->checking_away); - wee_log_printf (" nicks. . . . : 0x%X\n", channel->nicks); - wee_log_printf (" last_nick. . : 0x%X\n", channel->last_nick); - wee_log_printf (" buffer . . . : 0x%X\n", channel->buffer); - wee_log_printf (" prev_channel : 0x%X\n", channel->prev_channel); - wee_log_printf (" next_channel : 0x%X\n", channel->next_channel); + weechat_log_printf ("=> channel %s (addr:0x%X)]\n", channel->name, channel); + weechat_log_printf (" type . . . . : %d\n", channel->type); + weechat_log_printf (" dcc_chat . . : 0x%X\n", channel->dcc_chat); + weechat_log_printf (" topic. . . . : '%s'\n", channel->topic); + weechat_log_printf (" modes. . . . : '%s'\n", channel->modes); + weechat_log_printf (" limit. . . . : %d\n", channel->limit); + weechat_log_printf (" key. . . . . : '%s'\n", channel->key); + weechat_log_printf (" checking_away: %d\n", channel->checking_away); + weechat_log_printf (" nicks. . . . : 0x%X\n", channel->nicks); + weechat_log_printf (" last_nick. . : 0x%X\n", channel->last_nick); + weechat_log_printf (" buffer . . . : 0x%X\n", channel->buffer); + weechat_log_printf (" prev_channel : 0x%X\n", channel->prev_channel); + weechat_log_printf (" next_channel : 0x%X\n", channel->next_channel); } diff --git a/src/irc/irc-dcc.c b/src/irc/irc-dcc.c index 83cb66450..cdf7d08b1 100644 --- a/src/irc/irc-dcc.c +++ b/src/irc/irc-dcc.c @@ -148,6 +148,9 @@ dcc_find_filename (t_irc_dcc *ptr_dcc) { char *ptr_home, *filename2; + if (!DCC_IS_FILE(ptr_dcc->type)) + return; + ptr_home = getenv ("HOME"); ptr_dcc->local_filename = (char *) malloc (strlen (cfg_dcc_download_path) + strlen (ptr_dcc->nick) + @@ -223,20 +226,32 @@ void dcc_calculate_speed (t_irc_dcc *ptr_dcc, int ended) { time_t local_time, elapsed; + unsigned long bytes_per_sec_total; local_time = time (NULL); if (ended || local_time > ptr_dcc->last_check_time) { - if (ended) { + /* calculate bytes per second (global) */ elapsed = local_time - ptr_dcc->start_transfer; if (elapsed == 0) elapsed = 1; ptr_dcc->bytes_per_sec = (ptr_dcc->pos - ptr_dcc->start_resume) / elapsed; + ptr_dcc->eta = 0; } else { + /* calculate ETA */ + elapsed = local_time - ptr_dcc->start_transfer; + if (elapsed == 0) + elapsed = 1; + bytes_per_sec_total = (ptr_dcc->pos - ptr_dcc->start_resume) / elapsed; + if (bytes_per_sec_total == 0) + bytes_per_sec_total = 1; + ptr_dcc->eta = (ptr_dcc->size - ptr_dcc->pos) / bytes_per_sec_total; + + /* calculate bytes per second (since last check time) */ elapsed = local_time - ptr_dcc->last_check_time; if (elapsed == 0) elapsed = 1; @@ -606,6 +621,54 @@ dcc_start_resume (t_irc_server *server, char *filename, int port, } /* + * dcc_alloc: allocate a new DCC file + */ + +t_irc_dcc * +dcc_alloc () +{ + t_irc_dcc *new_dcc; + + /* create new DCC struct */ + if ((new_dcc = (t_irc_dcc *) malloc (sizeof (t_irc_dcc))) == NULL) + return NULL; + + /* default values */ + new_dcc->server = NULL; + new_dcc->channel = NULL; + new_dcc->type = 0; + new_dcc->status = 0; + new_dcc->start_time = 0; + new_dcc->start_transfer = 0; + new_dcc->addr = 0; + new_dcc->port = 0; + new_dcc->nick = NULL; + new_dcc->sock = -1; + new_dcc->unterminated_message = NULL; + new_dcc->file = -1; + new_dcc->filename = NULL; + new_dcc->local_filename = NULL; + new_dcc->filename_suffix = -1; + new_dcc->size = 0; + new_dcc->pos = 0; + new_dcc->ack = 0; + new_dcc->start_resume = 0; + new_dcc->last_check_time = 0; + new_dcc->last_check_pos = 0; + new_dcc->last_activity = 0; + new_dcc->bytes_per_sec = 0; + new_dcc->eta = 0; + + new_dcc->prev_dcc = NULL; + new_dcc->next_dcc = dcc_list; + if (dcc_list) + dcc_list->prev_dcc = new_dcc; + dcc_list = new_dcc; + + return new_dcc; +} + +/* * dcc_add: add a DCC file to queue */ @@ -615,8 +678,8 @@ dcc_add (t_irc_server *server, int type, unsigned long addr, int port, char *nic { t_irc_dcc *new_dcc; - /* create new DCC struct */ - if ((new_dcc = (t_irc_dcc *) malloc (sizeof (t_irc_dcc))) == NULL) + new_dcc = dcc_alloc (); + if (!new_dcc) { irc_display_prefix (server, server->buffer, PREFIX_ERROR); gui_printf (server->buffer, @@ -650,17 +713,13 @@ dcc_add (t_irc_server *server, int type, unsigned long addr, int port, char *nic new_dcc->start_resume = 0; new_dcc->last_check_time = time (NULL); new_dcc->last_check_pos = 0; - new_dcc->bytes_per_sec = 0; new_dcc->last_activity = time (NULL); + new_dcc->bytes_per_sec = 0; + new_dcc->eta = 0; if (local_filename) new_dcc->local_filename = strdup (local_filename); else dcc_find_filename (new_dcc); - new_dcc->prev_dcc = NULL; - new_dcc->next_dcc = dcc_list; - if (dcc_list) - dcc_list->prev_dcc = new_dcc; - dcc_list = new_dcc; gui_current_window->dcc_first = NULL; gui_current_window->dcc_selected = NULL; @@ -1424,9 +1483,45 @@ dcc_end () if (ptr_dcc->sock != -1) { if (ptr_dcc->status == DCC_ACTIVE) - wee_log_printf (_("Aborting active DCC: \"%s\" from %s\n"), - ptr_dcc->filename, ptr_dcc->nick); + weechat_log_printf (_("Aborting active DCC: \"%s\" from %s\n"), + ptr_dcc->filename, ptr_dcc->nick); dcc_close (ptr_dcc, DCC_FAILED); } } } + +/* + * dcc_print_log: print DCC infos in log (usually for crash dump) + */ + +void +dcc_print_log (t_irc_dcc *dcc) +{ + weechat_log_printf ("[DCC (addr:0x%X)]\n", dcc); + weechat_log_printf (" server. . . . . . . : 0x%X\n", dcc->server); + weechat_log_printf (" channel . . . . . . : 0x%X\n", dcc->channel); + weechat_log_printf (" type. . . . . . . . : %d\n", dcc->type); + weechat_log_printf (" status. . . . . . . : %d\n", dcc->status); + weechat_log_printf (" start_time. . . . . : %ld\n", dcc->start_time); + weechat_log_printf (" start_transfer. . . : %ld\n", dcc->start_transfer); + weechat_log_printf (" addr. . . . . . . . : %lu\n", dcc->addr); + weechat_log_printf (" port. . . . . . . . : %d\n", dcc->port); + weechat_log_printf (" nick. . . . . . . . : '%s'\n", dcc->nick); + weechat_log_printf (" sock. . . . . . . . : %d\n", dcc->sock); + weechat_log_printf (" unterminated_message: '%s'\n", dcc->unterminated_message); + weechat_log_printf (" file. . . . . . . . : %d\n", dcc->file); + weechat_log_printf (" filename. . . . . . : '%s'\n", dcc->filename); + weechat_log_printf (" local_filename. . . : '%s'\n", dcc->local_filename); + weechat_log_printf (" filename_suffix . . : %d\n", dcc->filename_suffix); + weechat_log_printf (" size. . . . . . . . : %lu\n", dcc->size); + weechat_log_printf (" pos . . . . . . . . : %lu\n", dcc->pos); + weechat_log_printf (" ack . . . . . . . . : %lu\n", dcc->ack); + weechat_log_printf (" start_resume. . . . : %lu\n", dcc->start_resume); + weechat_log_printf (" last_check_time . . : %ld\n", dcc->last_check_time); + weechat_log_printf (" last_check_pos. . . : %lu\n", dcc->last_check_pos); + weechat_log_printf (" last_activity . . . : %ld\n", dcc->last_activity); + weechat_log_printf (" bytes_per_sec . . . : %lu\n", dcc->bytes_per_sec); + weechat_log_printf (" eta . . . . . . . . : %lu\n", dcc->eta); + weechat_log_printf (" prev_dcc. . . . . . : 0x%X\n", dcc->prev_dcc); + weechat_log_printf (" next_dcc. . . . . . : 0x%X\n", dcc->next_dcc); +} diff --git a/src/irc/irc-display.c b/src/irc/irc-display.c index 97272c09d..b8be20219 100644 --- a/src/irc/irc-display.c +++ b/src/irc/irc-display.c @@ -97,19 +97,19 @@ irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname, (nick) ? "<" : ">"); if (nick && cfg_look_nickmode) { - if (nick->is_chanowner) + if (nick->flags & NICK_CHANOWNER) gui_printf_type (buffer, type, "%s~", GUI_COLOR(COLOR_WIN_NICK_OP)); - else if (nick->is_chanadmin) + else if (nick->flags & NICK_CHANADMIN) gui_printf_type (buffer, type, "%s&", GUI_COLOR(COLOR_WIN_NICK_OP)); - else if (nick->is_op) + else if (nick->flags & NICK_OP) gui_printf_type (buffer, type, "%s@", GUI_COLOR(COLOR_WIN_NICK_OP)); - else if (nick->is_halfop) + else if (nick->flags & NICK_HALFOP) gui_printf_type (buffer, type, "%s%%", GUI_COLOR(COLOR_WIN_NICK_HALFOP)); - else if (nick->has_voice) + else if (nick->flags & NICK_VOICE) gui_printf_type (buffer, type, "%s+", GUI_COLOR(COLOR_WIN_NICK_VOICE)); else diff --git a/src/irc/irc-ignore.c b/src/irc/irc-ignore.c index a039bb846..d81453a8d 100644 --- a/src/irc/irc-ignore.c +++ b/src/irc/irc-ignore.c @@ -459,18 +459,18 @@ ignore_print_log () { t_irc_ignore *ptr_ignore; - wee_log_printf ("[ignore list]\n"); + weechat_log_printf ("[ignore list]\n"); for (ptr_ignore = irc_ignore; ptr_ignore; ptr_ignore = ptr_ignore->next_ignore) { - wee_log_printf ("\n"); - wee_log_printf (" -> ignore at 0x%X:\n", ptr_ignore); - wee_log_printf (" mask. . . . . . . : %s\n", ptr_ignore->mask); - wee_log_printf (" type. . . . . . . : %s\n", ptr_ignore->type); - wee_log_printf (" channel_name. . . : %s\n", ptr_ignore->channel_name); - wee_log_printf (" server_name . . . : %s\n", ptr_ignore->server_name); - wee_log_printf (" prev_ignore . . . : 0x%X\n", ptr_ignore->prev_ignore); - wee_log_printf (" next_ignore . . . : 0x%X\n", ptr_ignore->next_ignore); + weechat_log_printf ("\n"); + weechat_log_printf (" -> ignore at 0x%X:\n", ptr_ignore); + weechat_log_printf (" mask. . . . . . . : %s\n", ptr_ignore->mask); + weechat_log_printf (" type. . . . . . . : %s\n", ptr_ignore->type); + weechat_log_printf (" channel_name. . . : %s\n", ptr_ignore->channel_name); + weechat_log_printf (" server_name . . . : %s\n", ptr_ignore->server_name); + weechat_log_printf (" prev_ignore . . . : 0x%X\n", ptr_ignore->prev_ignore); + weechat_log_printf (" next_ignore . . . : 0x%X\n", ptr_ignore->next_ignore); } } diff --git a/src/irc/irc-nick.c b/src/irc/irc-nick.c index a91fcd7af..ae6dbc3bc 100644 --- a/src/irc/irc-nick.c +++ b/src/irc/irc-nick.c @@ -59,15 +59,15 @@ nick_find_color (t_irc_nick *nick) int nick_score_for_sort (t_irc_nick *nick) { - if (nick->is_chanowner) + if (nick->flags & NICK_CHANOWNER) return -32; - if (nick->is_chanadmin) + if (nick->flags & NICK_CHANADMIN) return -16; - if (nick->is_op) + if (nick->flags & NICK_OP) return -8; - if (nick->is_halfop) + if (nick->flags & NICK_HALFOP) return -4; - if (nick->has_voice) + if (nick->flags & NICK_VOICE) return -2; return 0; } @@ -168,7 +168,7 @@ nick_insert_sorted (t_irc_channel *channel, t_irc_nick *nick) */ t_irc_nick * -nick_new (t_irc_channel *channel, char *nick_name, +nick_new (t_irc_server *server, t_irc_channel *channel, char *nick_name, int is_chanowner, int is_chanadmin, int is_op, int is_halfop, int has_voice) { @@ -178,35 +178,31 @@ nick_new (t_irc_channel *channel, char *nick_name, if ((new_nick = nick_search (channel, nick_name))) { /* update nick */ - new_nick->is_chanowner = is_chanowner; - new_nick->is_chanadmin = is_chanadmin; - new_nick->is_op = is_op; - new_nick->is_halfop = is_halfop; - new_nick->has_voice = has_voice; + NICK_SET_FLAG(new_nick, is_chanowner, NICK_CHANOWNER); + NICK_SET_FLAG(new_nick, is_chanadmin, NICK_CHANADMIN); + NICK_SET_FLAG(new_nick, is_op, NICK_OP); + NICK_SET_FLAG(new_nick, is_halfop, NICK_HALFOP); + NICK_SET_FLAG(new_nick, has_voice, NICK_VOICE); return new_nick; } /* alloc memory for new nick */ if ((new_nick = (t_irc_nick *) malloc (sizeof (t_irc_nick))) == NULL) - { - gui_printf (channel->buffer, - _("%s cannot allocate new nick\n"), WEECHAT_ERROR); return NULL; - } - + /* initialize new nick */ new_nick->nick = strdup (nick_name); - new_nick->is_chanowner = is_chanowner; - new_nick->is_chanadmin = is_chanadmin; - new_nick->is_op = is_op; - new_nick->is_halfop = is_halfop; - new_nick->has_voice = has_voice; - new_nick->is_away = 0; - if (ascii_strcasecmp (new_nick->nick, SERVER(channel->buffer)->nick) == 0) + new_nick->flags = 0; + NICK_SET_FLAG(new_nick, is_chanowner, NICK_CHANOWNER); + NICK_SET_FLAG(new_nick, is_chanadmin, NICK_CHANADMIN); + NICK_SET_FLAG(new_nick, is_op, NICK_OP); + NICK_SET_FLAG(new_nick, is_halfop, NICK_HALFOP); + NICK_SET_FLAG(new_nick, has_voice, NICK_VOICE); + if (ascii_strcasecmp (new_nick->nick, server->nick) == 0) new_nick->color = COLOR_WIN_NICK_SELF; else new_nick->color = nick_find_color (new_nick); - + nick_insert_sorted (channel, new_nick); channel->nicks_count++; @@ -347,15 +343,17 @@ nick_count (t_irc_channel *channel, int *total, int *count_op, ptr_nick = ptr_nick->next_nick) { (*total)++; - if ((ptr_nick->is_chanowner) || (ptr_nick->is_chanadmin) || (ptr_nick->is_op)) + if ((ptr_nick->flags & NICK_CHANOWNER) || + (ptr_nick->flags & NICK_CHANADMIN) || + (ptr_nick->flags & NICK_OP)) (*count_op)++; else { - if (ptr_nick->is_halfop) + if (ptr_nick->flags & NICK_HALFOP) (*count_halfop)++; else { - if (ptr_nick->has_voice) + if (ptr_nick->flags & NICK_VOICE) (*count_voice)++; else (*count_normal)++; @@ -391,9 +389,10 @@ nick_get_max_length (t_irc_channel *channel) void nick_set_away (t_irc_channel *channel, t_irc_nick *nick, int is_away) { - if (nick->is_away != is_away) + if (((is_away) && (!(nick->flags & NICK_AWAY))) || + ((!is_away) && (nick->flags & NICK_AWAY))) { - nick->is_away = is_away; + NICK_SET_FLAG(nick, is_away, NICK_AWAY); gui_draw_buffer_nick (channel->buffer, 0); } } @@ -405,14 +404,9 @@ nick_set_away (t_irc_channel *channel, t_irc_nick *nick, int is_away) void nick_print_log (t_irc_nick *nick) { - wee_log_printf ("=> nick %s (addr:0x%X)]\n", nick->nick, nick); - wee_log_printf (" is_chanowner . : %d\n", nick->is_chanowner); - wee_log_printf (" is_chanadmin . : %d\n", nick->is_chanadmin); - wee_log_printf (" is_op. . . . . : %d\n", nick->is_op); - wee_log_printf (" is_halfop. . . : %d\n", nick->is_halfop); - wee_log_printf (" has_voice. . . : %d\n", nick->has_voice); - wee_log_printf (" is_away. . . . : %d\n", nick->is_away); - wee_log_printf (" color. . . . . : %d\n", nick->color); - wee_log_printf (" prev_nick. . . : 0x%X\n", nick->prev_nick); - wee_log_printf (" next_nick. . . : 0x%X\n", nick->next_nick); + weechat_log_printf ("=> nick %s (addr:0x%X)]\n", nick->nick, nick); + weechat_log_printf (" flags. . . . . : %d\n", nick->flags); + weechat_log_printf (" color. . . . . : %d\n", nick->color); + weechat_log_printf (" prev_nick. . . : 0x%X\n", nick->prev_nick); + weechat_log_printf (" next_nick. . . : 0x%X\n", nick->next_nick); } diff --git a/src/irc/irc-recv.c b/src/irc/irc-recv.c index 55c203194..a19196315 100644 --- a/src/irc/irc-recv.c +++ b/src/irc/irc-recv.c @@ -396,7 +396,7 @@ irc_cmd_recv_join (t_irc_server *server, char *host, char *nick, char *arguments ptr_channel = channel_search (server, arguments); if (!ptr_channel) { - ptr_channel = channel_new (server, CHAT_CHANNEL, arguments, 1); + ptr_channel = channel_new (server, CHANNEL_TYPE_CHANNEL, arguments); if (!ptr_channel) { irc_display_prefix (server, server->buffer, PREFIX_ERROR); @@ -405,6 +405,7 @@ irc_cmd_recv_join (t_irc_server *server, char *host, char *nick, char *arguments WEECHAT_ERROR, arguments); return -1; } + gui_buffer_new (gui_current_window, server, ptr_channel, 0, 1); } if (!command_ignored) @@ -423,7 +424,7 @@ irc_cmd_recv_join (t_irc_server *server, char *host, char *nick, char *arguments GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), arguments); } - (void) nick_new (ptr_channel, nick, 0, 0, 0, 0, 0); + (void) nick_new (server, ptr_channel, nick, 0, 0, 0, 0, 0); gui_draw_buffer_nick (ptr_channel->buffer, 1); gui_draw_buffer_status (ptr_channel->buffer, 1); return 0; @@ -705,7 +706,7 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel, ptr_nick = nick_search (ptr_channel, parm); if (ptr_nick) { - ptr_nick->is_halfop = (set_flag == '+') ? 1 : 0; + NICK_SET_FLAG(ptr_nick, (set_flag == '+'), NICK_HALFOP); nick_resort (ptr_channel, ptr_nick); gui_draw_buffer_nick (ptr_channel->buffer, 1); } @@ -728,8 +729,8 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel, _("sets invite-only channel flag") : _("removes invite-only channel flag"), NULL); - SET_CHANNEL_MODE(ptr_channel, (set_flag == '+'), - CHANNEL_MODE_INVITE); + CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'), + CHANNEL_MODE_INVITE); break; case 'k': pos = NULL; @@ -748,8 +749,8 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel, (set_flag == '+') ? ((parm) ? parm : NULL) : NULL); - SET_CHANNEL_MODE(ptr_channel, (set_flag == '+'), - CHANNEL_MODE_KEY); + CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'), + CHANNEL_MODE_KEY); if (ptr_channel->key) free (ptr_channel->key); ptr_channel->key = strdup (parm); @@ -780,8 +781,8 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel, (set_flag == '+') ? ((parm) ? parm : NULL) : NULL); - SET_CHANNEL_MODE(ptr_channel, (set_flag == '+'), - CHANNEL_MODE_LIMIT); + CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'), + CHANNEL_MODE_LIMIT); ptr_channel->limit = atoi (parm); /* look for next parameter */ @@ -801,8 +802,8 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel, _("sets moderated channel flag") : _("removes moderated channel flag"), NULL); - SET_CHANNEL_MODE(ptr_channel, (set_flag == '+'), - CHANNEL_MODE_MODERATED); + CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'), + CHANNEL_MODE_MODERATED); break; case 'n': if (nick_host) @@ -812,8 +813,8 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel, _("sets messages from channel only flag") : _("removes messages from channel only flag"), NULL); - SET_CHANNEL_MODE(ptr_channel, (set_flag == '+'), - CHANNEL_MODE_NO_MSG_OUT); + CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'), + CHANNEL_MODE_NO_MSG_OUT); break; case 'o': pos = NULL; @@ -835,7 +836,7 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel, ptr_nick = nick_search (ptr_channel, parm); if (ptr_nick) { - ptr_nick->is_op = (set_flag == '+') ? 1 : 0; + NICK_SET_FLAG(ptr_nick, (set_flag == '+'), NICK_OP); nick_resort (ptr_channel, ptr_nick); gui_draw_buffer_nick (ptr_channel->buffer, 1); } @@ -858,8 +859,8 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel, _("sets private channel flag") : _("removes private channel flag"), NULL); - SET_CHANNEL_MODE(ptr_channel, (set_flag == '+'), - CHANNEL_MODE_SECRET); + CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'), + CHANNEL_MODE_SECRET); break; case 'q': pos = NULL; @@ -894,8 +895,8 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel, _("sets secret channel flag") : _("removes secret channel flag"), NULL); - SET_CHANNEL_MODE(ptr_channel, (set_flag == '+'), - CHANNEL_MODE_SECRET); + CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'), + CHANNEL_MODE_SECRET); break; case 't': if (nick_host) @@ -905,8 +906,8 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel, _("sets topic protection") : _("removes topic protection"), NULL); - SET_CHANNEL_MODE(ptr_channel, (set_flag == '+'), - CHANNEL_MODE_TOPIC); + CHANNEL_SET_MODE(ptr_channel, (set_flag == '+'), + CHANNEL_MODE_TOPIC); break; case 'v': pos = NULL; @@ -929,7 +930,7 @@ void irc_get_channel_modes (t_irc_server *server, t_irc_channel *ptr_channel, ptr_nick = nick_search (ptr_channel, parm); if (ptr_nick) { - ptr_nick->has_voice = (set_flag == '+') ? 1 : 0; + NICK_SET_FLAG(ptr_nick, (set_flag == '+'), NICK_VOICE); nick_resort (ptr_channel, ptr_nick); gui_draw_buffer_nick (ptr_channel->buffer, 1); } @@ -1222,7 +1223,7 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen ptr_channel = channel_search (server, nick); if (!ptr_channel) { - ptr_channel = channel_new (server, CHAT_PRIVATE, nick, 0); + ptr_channel = channel_new (server, CHANNEL_TYPE_PRIVATE, nick); if (!ptr_channel) { irc_display_prefix (server, server->buffer, PREFIX_ERROR); @@ -1231,6 +1232,7 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen WEECHAT_ERROR, nick); return -1; } + gui_buffer_new (gui_current_window, server, ptr_channel, 0, 0); } if (!ptr_channel->topic) ptr_channel->topic = strdup ((host2) ? host2 : ""); @@ -2034,7 +2036,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume { if (!ptr_channel) { - ptr_channel = channel_new (server, CHAT_PRIVATE, nick, 0); + ptr_channel = channel_new (server, CHANNEL_TYPE_PRIVATE, nick); if (!ptr_channel) { irc_display_prefix (server, server->buffer, PREFIX_ERROR); @@ -2043,6 +2045,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume WEECHAT_ERROR, nick); return -1; } + gui_buffer_new (gui_current_window, server, ptr_channel, 0, 0); } if (!ptr_channel->topic) ptr_channel->topic = strdup (host2); @@ -2124,7 +2127,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume { if (!ptr_channel) { - ptr_channel = channel_new (server, CHAT_PRIVATE, nick, 0); + ptr_channel = channel_new (server, CHANNEL_TYPE_PRIVATE, nick); if (!ptr_channel) { irc_display_prefix (server, server->buffer, PREFIX_ERROR); @@ -2133,6 +2136,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume WEECHAT_ERROR, nick); return -1; } + gui_buffer_new (gui_current_window, server, ptr_channel, 0, 0); } if (!ptr_channel->topic) ptr_channel->topic = strdup (host2); @@ -2206,7 +2210,7 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *nick, char *arguments for (ptr_channel = server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { - if (ptr_channel->type == CHAT_PRIVATE) + if (ptr_channel->type == CHANNEL_TYPE_PRIVATE) ptr_nick = NULL; else ptr_nick = nick_search (ptr_channel, nick); @@ -2454,7 +2458,7 @@ irc_cmd_recv_004 (t_irc_server *server, char *host, char *nick, char *arguments) for (ptr_channel = server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { - if (ptr_channel->type == CHAT_CHANNEL) + if (ptr_channel->type == CHANNEL_TYPE_CHANNEL) { if (ptr_channel->key) server_sendf (server, "JOIN %s %s\r\n", @@ -4309,8 +4313,8 @@ irc_cmd_recv_353 (t_irc_server *server, char *host, char *nick, char *arguments) pos[0] = '\0'; pos++; } - if (!nick_new (ptr_channel, pos_nick, is_chanowner, is_chanadmin, - is_op, is_halfop, has_voice)) + if (!nick_new (server, ptr_channel, pos_nick, is_chanowner, + is_chanadmin, is_op, is_halfop, has_voice)) { irc_display_prefix (server, server->buffer, PREFIX_ERROR); gui_printf_nolog (server->buffer, diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c index a0bee886b..84da65271 100644 --- a/src/irc/irc-send.c +++ b/src/irc/irc-send.c @@ -107,7 +107,7 @@ irc_cmd_send_ame (t_irc_server *server, char *arguments) for (ptr_channel = ptr_server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { - if (ptr_channel->type == CHAT_CHANNEL) + if (ptr_channel->type == CHANNEL_TYPE_CHANNEL) { server_sendf (ptr_server, "PRIVMSG %s :\01ACTION %s\01\r\n", ptr_channel->name, @@ -156,7 +156,7 @@ irc_cmd_send_amsg (t_irc_server *server, char *arguments) for (ptr_channel = ptr_server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { - if (ptr_channel->type == CHAT_CHANNEL) + if (ptr_channel->type == CHANNEL_TYPE_CHANNEL) { server_sendf (ptr_server, "PRIVMSG %s :%s\r\n", ptr_channel->name, arguments); @@ -965,7 +965,7 @@ irc_send_me_all_channels (t_irc_server *server, char *arguments) for (ptr_channel = server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { - if (ptr_channel->type == CHAT_CHANNEL) + if (ptr_channel->type == CHANNEL_TYPE_CHANNEL) irc_send_me (server, ptr_channel, arguments); } return 0; @@ -1145,7 +1145,7 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments) ptr_channel = channel_search (server, arguments); if (!ptr_channel) { - ptr_channel = channel_new (server, CHAT_PRIVATE, arguments, 1); + ptr_channel = channel_new (server, CHANNEL_TYPE_PRIVATE, arguments); if (!ptr_channel) { irc_display_prefix (NULL, server->buffer, PREFIX_ERROR); @@ -1154,6 +1154,7 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments) WEECHAT_ERROR, arguments); return -1; } + gui_buffer_new (gui_current_window, server, ptr_channel, 0, 1); gui_draw_buffer_title (ptr_channel->buffer, 1); } @@ -1485,7 +1486,7 @@ irc_cmd_send_query (t_irc_server *server, char *arguments) ptr_channel = channel_search (server, arguments); if (!ptr_channel) { - ptr_channel = channel_new (server, CHAT_PRIVATE, arguments, 1); + ptr_channel = channel_new (server, CHANNEL_TYPE_PRIVATE, arguments); if (!ptr_channel) { irc_display_prefix (NULL, server->buffer, PREFIX_ERROR); @@ -1494,6 +1495,7 @@ irc_cmd_send_query (t_irc_server *server, char *arguments) WEECHAT_ERROR, arguments); return -1; } + gui_buffer_new (gui_current_window, server, ptr_channel, 0, 1); gui_draw_buffer_title (ptr_channel->buffer, 1); } else diff --git a/src/irc/irc-server.c b/src/irc/irc-server.c index d877bd15f..2a4b6107e 100644 --- a/src/irc/irc-server.c +++ b/src/irc/irc-server.c @@ -91,9 +91,7 @@ server_init (t_irc_server *server) server->child_write = -1; server->sock = -1; server->is_connected = 0; -#ifdef HAVE_GNUTLS server->ssl_connected = 0; -#endif server->unterminated_message = NULL; server->nick = NULL; server->reconnect_start = 0; @@ -365,14 +363,14 @@ server_new (char *name, int autoconnect, int autoreconnect, int autoreconnect_de return NULL; #ifdef DEBUG - wee_log_printf ("Creating new server (name:%s, address:%s, port:%d, pwd:%s, " - "nick1:%s, nick2:%s, nick3:%s, username:%s, realname:%s, " - "command:%s, autojoin:%s, autorejoin:%s, notify_levels:%s)\n", - name, address, port, (password) ? password : "", - (nick1) ? nick1 : "", (nick2) ? nick2 : "", (nick3) ? nick3 : "", - (username) ? username : "", (realname) ? realname : "", - (command) ? command : "", (autojoin) ? autojoin : "", - (autorejoin) ? "on" : "off", (notify_levels) ? notify_levels : ""); + weechat_log_printf ("Creating new server (name:%s, address:%s, port:%d, pwd:%s, " + "nick1:%s, nick2:%s, nick3:%s, username:%s, realname:%s, " + "command:%s, autojoin:%s, autorejoin:%s, notify_levels:%s)\n", + name, address, port, (password) ? password : "", + (nick1) ? nick1 : "", (nick2) ? nick2 : "", (nick3) ? nick3 : "", + (username) ? username : "", (realname) ? realname : "", + (command) ? command : "", (autojoin) ? autojoin : "", + (autorejoin) ? "on" : "off", (notify_levels) ? notify_levels : ""); #endif if ((new_server = server_alloc ())) @@ -801,9 +799,7 @@ server_close_connection (t_irc_server *server) /* server is now disconnected */ server->is_connected = 0; -#ifdef HAVE_GNUTLS server->ssl_connected = 0; -#endif } /* @@ -1399,12 +1395,12 @@ server_connect (t_irc_server *server) (server->ssl) ? " (SSL)" : "", cfg_proxy_type_values[cfg_proxy_type], cfg_proxy_address, cfg_proxy_port, (cfg_proxy_ipv6) ? " (IPv6)" : ""); - wee_log_printf (_("Connecting to server %s:%d%s%s via %s proxy %s:%d%s...\n"), - server->address, server->port, - (server->ipv6) ? " (IPv6)" : "", - (server->ssl) ? " (SSL)" : "", - cfg_proxy_type_values[cfg_proxy_type], cfg_proxy_address, cfg_proxy_port, - (cfg_proxy_ipv6) ? " (IPv6)" : ""); + weechat_log_printf (_("Connecting to server %s:%d%s%s via %s proxy %s:%d%s...\n"), + server->address, server->port, + (server->ipv6) ? " (IPv6)" : "", + (server->ssl) ? " (SSL)" : "", + cfg_proxy_type_values[cfg_proxy_type], cfg_proxy_address, cfg_proxy_port, + (cfg_proxy_ipv6) ? " (IPv6)" : ""); } else { @@ -1413,18 +1409,18 @@ server_connect (t_irc_server *server) PACKAGE_NAME, server->address, server->port, (server->ipv6) ? " (IPv6)" : "", (server->ssl) ? " (SSL)" : ""); - wee_log_printf (_("Connecting to server %s:%d%s%s...\n"), - server->address, server->port, - (server->ipv6) ? " (IPv6)" : "", - (server->ssl) ? " (SSL)" : ""); + weechat_log_printf (_("Connecting to server %s:%d%s%s...\n"), + server->address, server->port, + (server->ipv6) ? " (IPv6)" : "", + (server->ssl) ? " (SSL)" : ""); } /* close any opened connection and kill child process if running */ server_close_connection (server); /* init SSL if asked */ -#ifdef HAVE_GNUTLS server->ssl_connected = 0; +#ifdef HAVE_GNUTLS if (server->ssl) { if (gnutls_init (&server->gnutls_sess, GNUTLS_CLIENT) != 0) @@ -1706,7 +1702,7 @@ server_remove_away () { for (ptr_channel = ptr_server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { - if (ptr_channel->type == CHAT_CHANNEL) + if (ptr_channel->type == CHANNEL_TYPE_CHANNEL) channel_remove_away (ptr_channel); } } @@ -1729,7 +1725,7 @@ server_check_away () { for (ptr_channel = ptr_server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { - if (ptr_channel->type == CHAT_CHANNEL) + if (ptr_channel->type == CHANNEL_TYPE_CHANNEL) channel_check_away (ptr_server, ptr_channel); } } @@ -1749,7 +1745,7 @@ server_set_away (t_irc_server *server, char *nick, int is_away) { if (server->is_connected) { - if (ptr_channel->type == CHAT_CHANNEL) + if (ptr_channel->type == CHANNEL_TYPE_CHANNEL) channel_set_away (ptr_channel, nick, is_away); } } @@ -1762,49 +1758,50 @@ server_set_away (t_irc_server *server, char *nick, int is_away) void server_print_log (t_irc_server *server) { - wee_log_printf ("[server %s (addr:0x%X)]\n", server->name, server); - wee_log_printf (" autoconnect . . . . : %d\n", server->autoconnect); - wee_log_printf (" autoreconnect . . . : %d\n", server->autoreconnect); - wee_log_printf (" autoreconnect_delay : %d\n", server->autoreconnect_delay); - wee_log_printf (" command_line. . . . : %d\n", server->command_line); - wee_log_printf (" address . . . . . . : '%s'\n", server->address); - wee_log_printf (" port. . . . . . . . : %d\n", server->port); - wee_log_printf (" ipv6. . . . . . . . : %d\n", server->ipv6); - wee_log_printf (" ssl . . . . . . . . : %d\n", server->ssl); - wee_log_printf (" password. . . . . . : '%s'\n", - (server->password && server->password[0]) ? "(hidden)" : server->password); - wee_log_printf (" nick1 . . . . . . . : '%s'\n", server->nick1); - wee_log_printf (" nick2 . . . . . . . : '%s'\n", server->nick2); - wee_log_printf (" nick3 . . . . . . . : '%s'\n", server->nick3); - wee_log_printf (" username. . . . . . : '%s'\n", server->username); - wee_log_printf (" realname. . . . . . : '%s'\n", server->realname); - wee_log_printf (" command . . . . . . : '%s'\n", - (server->command && server->command[0]) ? "(hidden)" : server->command); - wee_log_printf (" command_delay . . . : %d\n", server->command_delay); - wee_log_printf (" autojoin. . . . . . : '%s'\n", server->autojoin); - wee_log_printf (" autorejoin. . . . . : %d\n", server->autorejoin); - wee_log_printf (" notify_levels . . . : %s\n", server->notify_levels); - wee_log_printf (" child_pid . . . . . : %d\n", server->child_pid); - wee_log_printf (" child_read . . . . : %d\n", server->child_read); - wee_log_printf (" child_write . . . . : %d\n", server->child_write); - wee_log_printf (" sock. . . . . . . . : %d\n", server->sock); - wee_log_printf (" is_connected. . . . : %d\n", server->is_connected); -#ifdef HAVE_GNUTLS - wee_log_printf(" ssl_connected . . . : %d\n", server->ssl_connected); -#endif - wee_log_printf (" unterminated_message: '%s'\n", server->unterminated_message); - wee_log_printf (" nick. . . . . . . . : '%s'\n", server->nick); - wee_log_printf (" reconnect_start . . : %ld\n", server->reconnect_start); - wee_log_printf (" reconnect_join. . . : %d\n", server->reconnect_join); - wee_log_printf (" is_away . . . . . . : %d\n", server->is_away); - wee_log_printf (" away_time . . . . . : %ld\n", server->away_time); - wee_log_printf (" lag . . . . . . . . : %d\n", server->lag); - wee_log_printf (" lag_check_time. . . : tv_sec:%d, tv_usec:%d\n", - server->lag_check_time.tv_sec, server->lag_check_time.tv_usec); - wee_log_printf (" lag_next_check. . . : %ld\n", server->lag_next_check); - wee_log_printf (" buffer. . . . . . . : 0x%X\n", server->buffer); - wee_log_printf (" channels. . . . . . : 0x%X\n", server->channels); - wee_log_printf (" last_channel. . . . : 0x%X\n", server->last_channel); - wee_log_printf (" prev_server . . . . : 0x%X\n", server->prev_server); - wee_log_printf (" next_server . . . . : 0x%X\n", server->next_server); + weechat_log_printf ("[server %s (addr:0x%X)]\n", server->name, server); + weechat_log_printf (" autoconnect . . . . : %d\n", server->autoconnect); + weechat_log_printf (" autoreconnect . . . : %d\n", server->autoreconnect); + weechat_log_printf (" autoreconnect_delay : %d\n", server->autoreconnect_delay); + weechat_log_printf (" command_line. . . . : %d\n", server->command_line); + weechat_log_printf (" address . . . . . . : '%s'\n", server->address); + weechat_log_printf (" port. . . . . . . . : %d\n", server->port); + weechat_log_printf (" ipv6. . . . . . . . : %d\n", server->ipv6); + weechat_log_printf (" ssl . . . . . . . . : %d\n", server->ssl); + weechat_log_printf (" password. . . . . . : '%s'\n", + (server->password && server->password[0]) ? + "(hidden)" : server->password); + weechat_log_printf (" nick1 . . . . . . . : '%s'\n", server->nick1); + weechat_log_printf (" nick2 . . . . . . . : '%s'\n", server->nick2); + weechat_log_printf (" nick3 . . . . . . . : '%s'\n", server->nick3); + weechat_log_printf (" username. . . . . . : '%s'\n", server->username); + weechat_log_printf (" realname. . . . . . : '%s'\n", server->realname); + weechat_log_printf (" command . . . . . . : '%s'\n", + (server->command && server->command[0]) ? + "(hidden)" : server->command); + weechat_log_printf (" command_delay . . . : %d\n", server->command_delay); + weechat_log_printf (" autojoin. . . . . . : '%s'\n", server->autojoin); + weechat_log_printf (" autorejoin. . . . . : %d\n", server->autorejoin); + weechat_log_printf (" notify_levels . . . : %s\n", server->notify_levels); + weechat_log_printf (" child_pid . . . . . : %d\n", server->child_pid); + weechat_log_printf (" child_read . . . . : %d\n", server->child_read); + weechat_log_printf (" child_write . . . . : %d\n", server->child_write); + weechat_log_printf (" sock. . . . . . . . : %d\n", server->sock); + weechat_log_printf (" is_connected. . . . : %d\n", server->is_connected); + weechat_log_printf (" ssl_connected . . . : %d\n", server->ssl_connected); + weechat_log_printf (" unterminated_message: '%s'\n", server->unterminated_message); + weechat_log_printf (" nick. . . . . . . . : '%s'\n", server->nick); + weechat_log_printf (" reconnect_start . . : %ld\n", server->reconnect_start); + weechat_log_printf (" reconnect_join. . . : %d\n", server->reconnect_join); + weechat_log_printf (" is_away . . . . . . : %d\n", server->is_away); + weechat_log_printf (" away_time . . . . . : %ld\n", server->away_time); + weechat_log_printf (" lag . . . . . . . . : %d\n", server->lag); + weechat_log_printf (" lag_check_time. . . : tv_sec:%d, tv_usec:%d\n", + server->lag_check_time.tv_sec, + server->lag_check_time.tv_usec); + weechat_log_printf (" lag_next_check. . . : %ld\n", server->lag_next_check); + weechat_log_printf (" buffer. . . . . . . : 0x%X\n", server->buffer); + weechat_log_printf (" channels. . . . . . : 0x%X\n", server->channels); + weechat_log_printf (" last_channel. . . . : 0x%X\n", server->last_channel); + weechat_log_printf (" prev_server . . . . : 0x%X\n", server->prev_server); + weechat_log_printf (" next_server . . . . : 0x%X\n", server->next_server); } diff --git a/src/irc/irc.h b/src/irc/irc.h index 236353b8f..e2fdc00fb 100644 --- a/src/irc/irc.h +++ b/src/irc/irc.h @@ -46,61 +46,29 @@ #define PREFIX_ERROR "=!=" #define PREFIX_PLUGIN "-P-" -#define CHANNEL_PREFIX "#&+!" +#define DEFAULT_IRC_PORT 6667 -/* channel modes */ +/* nick types */ -#define NUM_CHANNEL_MODES 7 -#define CHANNEL_MODE_INVITE 0 -#define CHANNEL_MODE_KEY 1 -#define CHANNEL_MODE_LIMIT 2 -#define CHANNEL_MODE_MODERATED 3 -#define CHANNEL_MODE_NO_MSG_OUT 4 -#define CHANNEL_MODE_SECRET 5 -#define CHANNEL_MODE_TOPIC 6 -#define SET_CHANNEL_MODE(channel, set, mode) \ +#define NICK_CHANOWNER 1 +#define NICK_CHANADMIN 2 +#define NICK_OP 4 +#define NICK_HALFOP 8 +#define NICK_VOICE 16 +#define NICK_AWAY 32 +#define NICK_SET_FLAG(nick, set, flag) \ if (set) \ - channel->modes[mode] = channel_modes[mode]; \ + nick->flags |= flag; \ else \ - channel->modes[mode] = ' '; - -#define DEFAULT_IRC_PORT 6667 - -/* DCC types & status */ - -#define DCC_CHAT_RECV 0 /* receiving DCC chat */ -#define DCC_CHAT_SEND 1 /* sending DCC chat */ -#define DCC_FILE_RECV 2 /* incoming DCC file */ -#define DCC_FILE_SEND 3 /* sending DCC file */ - -#define DCC_WAITING 0 /* waiting for host answer */ -#define DCC_CONNECTING 1 /* connecting to host */ -#define DCC_ACTIVE 2 /* sending/receiving data */ -#define DCC_DONE 3 /* transfer done */ -#define DCC_FAILED 4 /* DCC failed */ -#define DCC_ABORTED 5 /* DCC aborted by user */ - -#define DCC_IS_CHAT(type) ((type == DCC_CHAT_RECV) || (type == DCC_CHAT_SEND)) -#define DCC_IS_FILE(type) ((type == DCC_FILE_RECV) || (type == DCC_FILE_SEND)) -#define DCC_IS_RECV(type) ((type == DCC_CHAT_RECV) || (type == DCC_FILE_RECV)) -#define DCC_IS_SEND(type) ((type == DCC_CHAT_SEND) || (type == DCC_FILE_SEND)) - -#define DCC_ENDED(status) ((status == DCC_DONE) || (status == DCC_FAILED) || \ - (status == DCC_ABORTED)) - -/* nick types */ + nick->flags &= 0xFFFF - flag; typedef struct t_irc_nick t_irc_nick; struct t_irc_nick { char *nick; /* nickname */ - int is_chanowner; /* chan owner? (specific to unrealircd) */ - int is_chanadmin; /* chan admin? (specific to unrealircd) */ - int is_op; /* operator privileges? */ - int is_halfop; /* half operator privileges? */ - int has_voice; /* nick has voice? */ - int is_away; /* = 1 if nick is away, otherwise 0 */ + int flags; /* chanowner/chanadmin (unrealircd), */ + /* op, halfop, voice, away */ int color; /* color for nickname in chat window */ t_irc_nick *prev_nick; /* link to previous nick on the channel */ t_irc_nick *next_nick; /* link to next nick on the channel */ @@ -108,11 +76,27 @@ struct t_irc_nick /* channel types */ -typedef struct t_irc_channel t_irc_channel; +#define CHANNEL_PREFIX "#&+!" -#define CHAT_UNKNOWN -1 -#define CHAT_CHANNEL 0 -#define CHAT_PRIVATE 1 +#define CHANNEL_TYPE_UNKNOWN -1 +#define CHANNEL_TYPE_CHANNEL 0 +#define CHANNEL_TYPE_PRIVATE 1 + +#define NUM_CHANNEL_MODES 7 +#define CHANNEL_MODE_INVITE 0 +#define CHANNEL_MODE_KEY 1 +#define CHANNEL_MODE_LIMIT 2 +#define CHANNEL_MODE_MODERATED 3 +#define CHANNEL_MODE_NO_MSG_OUT 4 +#define CHANNEL_MODE_SECRET 5 +#define CHANNEL_MODE_TOPIC 6 +#define CHANNEL_SET_MODE(channel, set, mode) \ + if (set) \ + channel->modes[mode] = channel_modes[mode]; \ + else \ + channel->modes[mode] = ' '; + +typedef struct t_irc_channel t_irc_channel; struct t_irc_channel { @@ -120,7 +104,7 @@ struct t_irc_channel void *dcc_chat; /* DCC CHAT pointer (NULL if not DCC) */ char *name; /* name of channel (exemple: "#abc") */ char *topic; /* topic of channel (host for private) */ - char modes[NUM_CHANNEL_MODES+1];/* channel modes */ + char *modes; /* channel modes */ int limit; /* user limit (0 is limit not set) */ char *key; /* channel key (NULL if no key is set) */ int nicks_count; /* # nicks on channel (0 if dcc/pv) */ @@ -166,11 +150,10 @@ struct t_irc_server int child_write; /* to write into child pipe */ int sock; /* socket for server (IPv4 or IPv6) */ int is_connected; /* 1 if WeeChat is connected to server */ -#ifdef HAVE_GNUTLS int ssl_connected; /* = 1 if connected with SSL */ +#ifdef HAVE_GNUTLS gnutls_session gnutls_sess; /* gnutls session (only if SSL is used) */ #endif - char *unterminated_message; /* beginning of a message in input buf */ char *nick; /* current nickname */ time_t reconnect_start; /* this time + delay = reconnect time */ @@ -221,6 +204,26 @@ struct t_irc_message /* DCC types */ +#define DCC_CHAT_RECV 0 /* receiving DCC chat */ +#define DCC_CHAT_SEND 1 /* sending DCC chat */ +#define DCC_FILE_RECV 2 /* incoming DCC file */ +#define DCC_FILE_SEND 3 /* sending DCC file */ + +#define DCC_WAITING 0 /* waiting for host answer */ +#define DCC_CONNECTING 1 /* connecting to host */ +#define DCC_ACTIVE 2 /* sending/receiving data */ +#define DCC_DONE 3 /* transfer done */ +#define DCC_FAILED 4 /* DCC failed */ +#define DCC_ABORTED 5 /* DCC aborted by user */ + +#define DCC_IS_CHAT(type) ((type == DCC_CHAT_RECV) || (type == DCC_CHAT_SEND)) +#define DCC_IS_FILE(type) ((type == DCC_FILE_RECV) || (type == DCC_FILE_SEND)) +#define DCC_IS_RECV(type) ((type == DCC_CHAT_RECV) || (type == DCC_FILE_RECV)) +#define DCC_IS_SEND(type) ((type == DCC_CHAT_SEND) || (type == DCC_FILE_SEND)) + +#define DCC_ENDED(status) ((status == DCC_DONE) || (status == DCC_FAILED) || \ + (status == DCC_ABORTED)) + typedef struct t_irc_dcc t_irc_dcc; struct t_irc_dcc @@ -246,8 +249,9 @@ struct t_irc_dcc unsigned long start_resume; /* start of resume (in bytes) */ time_t last_check_time; /* last time we looked at bytes sent/rcv*/ unsigned long last_check_pos; /* bytes sent/recv at last check */ - unsigned long bytes_per_sec; /* bytes per second */ time_t last_activity; /* time of last byte received/sent */ + unsigned long bytes_per_sec; /* bytes per second */ + unsigned long eta; /* estimated time of arrival */ t_irc_dcc *prev_dcc; /* link to previous dcc file/chat */ t_irc_dcc *next_dcc; /* link to next dcc file/chat */ }; @@ -327,7 +331,7 @@ extern int pass_proxy(int, char*, int, char*); /* channel functions (irc-channel.c) */ -extern t_irc_channel *channel_new (t_irc_server *, int, char *, int); +extern t_irc_channel *channel_new (t_irc_server *, int, char *); extern void channel_free (t_irc_server *, t_irc_channel *); extern void channel_free_all (t_irc_server *); extern t_irc_channel *channel_search (t_irc_server *, char *); @@ -345,7 +349,8 @@ extern void channel_print_log (t_irc_channel *); /* nick functions (irc-nick.c) */ extern int nick_find_color (t_irc_nick *); -extern t_irc_nick *nick_new (t_irc_channel *, char *, int, int, int, int, int); +extern t_irc_nick *nick_new (t_irc_server *, t_irc_channel *, char *, + int, int, int, int, int); extern void nick_resort (t_irc_channel *, t_irc_nick *); extern void nick_change (t_irc_channel *, t_irc_nick *, char *); extern void nick_free (t_irc_channel *, t_irc_nick *); @@ -364,12 +369,14 @@ extern void dcc_close (t_irc_dcc *, int); extern void dcc_accept (t_irc_dcc *); extern void dcc_accept_resume (t_irc_server *, char *, int, unsigned long); extern void dcc_start_resume (t_irc_server *, char *, int, unsigned long); +extern t_irc_dcc *dcc_alloc (); extern t_irc_dcc *dcc_add (t_irc_server *, int, unsigned long, int, char *, int, char *, char *, unsigned long); extern void dcc_send_request (t_irc_server *, int, char *, char *); extern void dcc_chat_sendf (t_irc_dcc *, char *, ...); extern void dcc_handle (); extern void dcc_end (); +extern void dcc_print_log (t_irc_dcc *); /* IRC display (irc-diplay.c) */ |