mirror of
https://github.com/weechat/weechat.git
synced 2026-06-15 07:34:46 +02:00
Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 627e0a24eb | |||
| ab6ca9a0b4 | |||
| 7e069ec3e2 | |||
| ddd798a65a | |||
| 4fde90e418 | |||
| 65c146e9c6 | |||
| d6454184e4 | |||
| 53efa7d6af | |||
| 073b1d0bd4 | |||
| 2968e61d97 | |||
| ede76f7b44 | |||
| db5ee98418 | |||
| a148073391 | |||
| 2db87e36b8 | |||
| e0fb9723a7 | |||
| 3782ef828a | |||
| cec899898a | |||
| 106bdb1d4a | |||
| ef4e6b93e0 | |||
| d0bb1e0c2a | |||
| 77e0d01d7a | |||
| b4ff775f03 | |||
| 9f1fd921f7 | |||
| 13c7cb9dd4 | |||
| a5ae266ee4 | |||
| a353a6d228 | |||
| 4ad98ebc52 | |||
| c32bc12d8e | |||
| 70cd53af86 | |||
| ac42b65177 | |||
| c3bb49501c | |||
| 625480e448 | |||
| ab6921ff85 | |||
| a7091f895d |
@@ -1,17 +1,16 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
WeeChat known bugs, 2003-09-27
|
||||
WeeChat known bugs, 2003-10-05
|
||||
|
||||
- too much nicks in the channel (> height of window) => display bug
|
||||
- some IRC commands are marked as 'unknown' when received
|
||||
(irc protocol is under dev!)
|
||||
- bug in nicklist resize (sometimes resize doesn't work and there is display
|
||||
problem)
|
||||
- alias/unalias commands doesn't work
|
||||
- config is not saved (to ~/.weechat/weechatrc)
|
||||
(IRC protocol is under dev!)
|
||||
- intercept Ctrl-C (do not quit immediately if Ctrl-C pressed!)
|
||||
- program is stopped when bad option in config file (it should not, only display
|
||||
warning)
|
||||
- too much opened channel => display bug
|
||||
- too much opened channels => display bug
|
||||
- when kicked, channel is not prefixed by '(' and sufixed by ')'
|
||||
- when function key (non used by WeeChat) is pressed, prompt is deleted
|
||||
- when quitting WeeChat term title is not restored (if look_set_title is ON)
|
||||
- command name for /server can not contain spaces
|
||||
|
||||
@@ -1,88 +1,31 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2003-09-27
|
||||
ChangeLog - 2003-10-05
|
||||
|
||||
* 2003-09-27:
|
||||
- WeeChat 0.0.1 released!
|
||||
|
||||
* 2003-09-26:
|
||||
- added completor prefix (in config: look_nick_completor)
|
||||
- fixef log_printf command (bug with year & month)
|
||||
- added "/kill" command
|
||||
- fixed /version and /ctcp commands (missing ":" before message)
|
||||
Version 0.0.2 (2003-10-05):
|
||||
* added commands /rehash and /restart
|
||||
* command & auto-join channels when connected to server
|
||||
* new commands for alias: /alias, /unalias (new section in config file)
|
||||
* config is now saved automatically when quitting WeeChat, /save command added
|
||||
* new commands for servers: /server, /connect, /disconnect
|
||||
* added autoconnect flag for each server in config file
|
||||
* added "look_set_title" option in config file
|
||||
* term window title is modified with WeeChat name and version
|
||||
* fixed nicklist display bug
|
||||
* fixed crash when sending command which can only be received
|
||||
* CTCP version returns more info (about OS)
|
||||
|
||||
* 2003-09-25:
|
||||
- added "/kick" command
|
||||
- added IRC errors 402 to 407
|
||||
- added "/invite" command
|
||||
|
||||
* 2003-09-24:
|
||||
- "ctcp version" received is now correctly displayed
|
||||
- "/version" command is ok
|
||||
|
||||
* 2003-09-23:
|
||||
- log file (~/.weechat/weechat.log)
|
||||
- renamed config file (~/.weechat/weechatrc to ~/.weechat/weechat.rc)
|
||||
|
||||
* 2003-09-21:
|
||||
- "demi-highlight": 2 types of windows highlight: lightred for windows with
|
||||
unread messages (from other users), lightmagenta for windows with other
|
||||
unread data (join, part, quit, away, ...)
|
||||
- "320" IRC message management
|
||||
- "/clear" command
|
||||
|
||||
* 2003-09-19:
|
||||
- préparation des sources pour l'internationalisation avec gettext
|
||||
- "301" IRC command (away message)
|
||||
- functions renamed in rc-commands.c, irc-server.c,
|
||||
command.c and config.c (all functions are beginning with a prefix:
|
||||
irc_cmd_recv_xxx, irc_cmd_send_xxx, server_xxx, weechat_cmd_xxx and
|
||||
config_xxx). Moreover, all commands (sent and received) return a value
|
||||
(success or not)
|
||||
- "/quote" command
|
||||
- "/whois" command (and colored display of /whois result in server window)
|
||||
|
||||
* 2003-09-18:
|
||||
- use of alternate nickname (and 2nd alternate) if nick is already used
|
||||
on server (changed/added in config file: options "nick1", "nick2", "nick3"
|
||||
for a server, all are mandatory)
|
||||
- "433" IRC error management (nickname already in use)
|
||||
- "mode" command received correctly for "channel flags" and
|
||||
op/deop/voice/devoice actions for a nick
|
||||
- "401" IRC error management (no such nick/channel)
|
||||
- private windows management (when received and opened, with /privmsg),
|
||||
"/privmsg" completed consequently
|
||||
|
||||
* 2003-09-17:
|
||||
- nickmode display ((half)op/voice) before nicks (as option, look at config
|
||||
options beginning with "look_nickmode")
|
||||
- windows history is now ok (pgup/pgdn on any window type)
|
||||
- "/me" command (and OK when received)
|
||||
- display nicks count when joining channel or with "/names" command
|
||||
(total, ops, halfops, voices et normaux)
|
||||
|
||||
* 2003-09-16:
|
||||
- added and normalized chat window colors
|
||||
(new colors in config file)
|
||||
- "/topic" command
|
||||
- nicklist can be moved on top, bottom, left or right of window
|
||||
|
||||
* 2003-09-15:
|
||||
- auto-resize of nicklist, according to nick max length
|
||||
- IRC multi-servers is OK
|
||||
|
||||
* 2003-09-14:
|
||||
- no hangup if "/part" command is executed on server window
|
||||
- continue if no server is declared in config file
|
||||
(empty window will be opened for executing WeeChat commands)
|
||||
- string array for strings in config file
|
||||
example: cfg_look_nicklist_position can take values "left", "right",
|
||||
"top", "bottom", which are converted to int (from 0 for "left" to 3 for
|
||||
"bottom")
|
||||
- messages are aligned under time (server window) or under time + nick
|
||||
(channel window)
|
||||
|
||||
* 2003-09-13:
|
||||
- sources exploded in many directories: ./irc, ./gui/curses, ./gui/gtk,
|
||||
./gui/qt and ./gui/text
|
||||
Version 0.0.1 (2003-09-27):
|
||||
* ncurses GUI with color output
|
||||
* multi-servers
|
||||
* channel windows, with nicklist (position: top, bottom, left or right)
|
||||
* private windows
|
||||
* IRC commands: away, ctcp, deop, devoice, invite, join, kick, kill, list,
|
||||
me, mode, msg, names, nick, notice, op, oper, part, ping, pong, quit,
|
||||
quote, topic, version, voice, whois
|
||||
* WeeChat commands: clear, help, set (partial)
|
||||
* many config options
|
||||
* log file (~/.weechat/weechat.log)
|
||||
* nicklist can be moved on top, bottom, left or right of window
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
FlashCode, 2003-09-27
|
||||
* FlashCode, 2003-10-05
|
||||
|
||||
WeeChat 0.0.1 released.
|
||||
WeeChat 0.0.2 released.
|
||||
|
||||
* FlashCode, 2003-09-27
|
||||
|
||||
WeeChat 0.0.1 released.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
TODO - 2003-09-27
|
||||
TODO - 2003-10-05
|
||||
|
||||
Legend:
|
||||
# done
|
||||
@@ -10,70 +10,40 @@ Legend:
|
||||
? is this really necessary?
|
||||
|
||||
|
||||
v0.0.1:
|
||||
v0.0.2:
|
||||
------
|
||||
|
||||
* IRC protocol:
|
||||
# "/quote" command: send a raw string to the server without parsing it
|
||||
# "/me" command (for user actions description)
|
||||
# "/away" command (to toggle the away status)
|
||||
# "/op", "/deop", "/voice", "/devoice" commands
|
||||
# "/invite" command
|
||||
# "/kick", "/ban", "/unban" commands
|
||||
# "/kill" command
|
||||
# "/list" command: list of channels
|
||||
# "/names" command: view who is on a given channel without being
|
||||
on it (for example /names #weechat gives all the nicks present on
|
||||
#weechat, except those who have the +i flag (server side))
|
||||
# "/oper" command: become operator on the irc network
|
||||
# "/topic" command: change the topic of a channel
|
||||
# "/version" command: give the irc client version (CTCP VERSION)
|
||||
of a given nick/channel (without parameter: gives WeeChat version)
|
||||
# "/whois" command
|
||||
# "/rehash" command: tell the server to reload its config file
|
||||
# "/restart" command: tell the server to restart itself
|
||||
|
||||
* WeeChat commands:
|
||||
# "/clear": to clear window content
|
||||
|
||||
* Interface:
|
||||
# "demi-highlight" when joins/quits etc
|
||||
# log messages/warning/errors to ~/.weechat/log file
|
||||
# improve editing zone (left arrow <> backspace)
|
||||
# sort nick list
|
||||
# choose nick list position (top, left, right (default), bottom)
|
||||
# auto-resize nicklist (when nick too long)
|
||||
# do pretty cutting of long lines (align on the nick or after hour for server)
|
||||
# keep history of commands and call them again with up/down arrow
|
||||
# text GUI
|
||||
# ncurses GUI:
|
||||
# one window for each channel
|
||||
# color display
|
||||
# private windows
|
||||
# redraw window when term size is modified
|
||||
# chat history (pgup/pgdn for displaying history)
|
||||
# switch to other channel window
|
||||
|
||||
* TCP/IP communication:
|
||||
# IPv4 protocol implementation
|
||||
# "/connect" and "/disconnect" commands (for multiservers use)
|
||||
# "/server" command to add, remove or list servers
|
||||
# "/save" command: save configuration to disk
|
||||
# "/alias" and "/unalias" commands
|
||||
|
||||
* Configuration:
|
||||
# write default config file
|
||||
# write config file
|
||||
# add alias definition
|
||||
# add an option for each server in order to run commands on join
|
||||
(example: /msg nickserv identify password)
|
||||
# channel list for auto-join (for each server)
|
||||
|
||||
|
||||
Future versions:
|
||||
---------------
|
||||
|
||||
* IRC protocol:
|
||||
- implement RFC 2812
|
||||
+ "/mode" command: change the user/channels modes
|
||||
- "/dcc" command (for chat and sending/receiving files)
|
||||
- manage "halfop" status
|
||||
- complete "/list" command: add regexp search, display only channels that
|
||||
match regexp
|
||||
- "/connect" and "/disconnect" commands (for multiservers use)
|
||||
- "/ignore" and "/unignore" commands: hide all that is write by a given
|
||||
nick/host
|
||||
- when we're away, WeeChat should log all the lines begenning by our nick.
|
||||
When we come back from our away it should print it to the current window
|
||||
- "/rehash" command: tell the server to reload its config file
|
||||
- "/restart" command: tell the server to restart itself
|
||||
- "/notify" and "/unnotify" command to be warn by WeeChat when a given
|
||||
nick/host connect to the given irc network
|
||||
- "/wallops" command: write the same string to all the
|
||||
@@ -87,15 +57,15 @@ Future versions:
|
||||
like -o could send the output to the server, on the current
|
||||
channel/private
|
||||
- "/reload" command: reload the WeeChat's config file
|
||||
- "/set" command: allow the user to set the WeeChat variables
|
||||
under WeeChat without editing the config file (colours, time
|
||||
format, etc)
|
||||
- "/highlight" command: highlight a given word when it appears on
|
||||
channels/privates
|
||||
+ "/set" command: allow the user to set the WeeChat variables
|
||||
under WeeChat without editing the config file (colours, time
|
||||
format, etc)
|
||||
|
||||
* Interface:
|
||||
- display current channel modes (example : #weechat(+nt))
|
||||
- interpret ^B in messages (this means bold text)
|
||||
- interpret special chars in messages (color & bold for example)
|
||||
- internationalization (traduce WeeChat in many languages)
|
||||
- many channel windows in one window/term (window split)
|
||||
- add lag indicator
|
||||
@@ -109,15 +79,14 @@ Future versions:
|
||||
? Qt GUI
|
||||
|
||||
* TCP/IP communication:
|
||||
- connect to server with child process (background)
|
||||
- SSL support
|
||||
- IPv6 protocol implementation
|
||||
|
||||
|
||||
* Configuration:
|
||||
- add key bindings to config file
|
||||
- add missing options for config file
|
||||
- write config file
|
||||
- add an option for each server in order to run commands on join
|
||||
(example: /msg nickserv identify password)
|
||||
- channel list for auto-join (for each server)
|
||||
- wrong alias is not created and not saved when quitting WeeChat
|
||||
- do not stop program if problem with options in config file
|
||||
- load config file after GUI (so init values by default (colors, ...) before
|
||||
loading config)
|
||||
|
||||
Vendored
+7
-1
@@ -1,5 +1,11 @@
|
||||
weechat (0.0.2-1) unstable; urgency=low
|
||||
|
||||
* WeeChat version 0.0.2, see ChangeLog for detail.
|
||||
|
||||
-- FlashCode <flashcode@flashtux.org> Sun, 05 Oct 2003 12:00:00 +0200
|
||||
|
||||
weechat (0.0.1-1) unstable; urgency=low
|
||||
|
||||
* First version.
|
||||
|
||||
-- FlashCode <flashcode@flashtux.org> Sat, 27 Jun 2003 12:00:00 +0200
|
||||
-- FlashCode <flashcode@flashtux.org> Sat, 27 Sep 2003 12:00:00 +0200
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
This package was debianized by FlashCode <flashcode@flashtux.org> on
|
||||
Sat, 27 Sep 2003 10:00:00 +0200.
|
||||
Sun, 05 Oct 2003 12:00:00 +0200.
|
||||
|
||||
It was downloaded from http://weechat.flashtux.org/download
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
weechat_0.0.1-1_i386.deb net optional
|
||||
weechat_0.0.2-1_i386.deb net optional
|
||||
|
||||
+2
-2
@@ -84,8 +84,8 @@ command.o: command.c weechat.h command.h irc/irc.h gui/gui.h completion.h \
|
||||
history.h config.h
|
||||
completion.o: completion.c weechat.h completion.h irc/irc.h gui/gui.h \
|
||||
history.h command.h
|
||||
config.o: config.c weechat.h config.h irc/irc.h gui/gui.h completion.h \
|
||||
history.h
|
||||
config.o: config.c weechat.h config.h command.h irc/irc.h gui/gui.h \
|
||||
completion.h history.h
|
||||
history.o: history.c weechat.h history.h gui/gui.h completion.h
|
||||
weechat.o: weechat.c weechat.h config.h command.h irc/irc.h gui/gui.h \
|
||||
completion.h history.h
|
||||
|
||||
+774
-58
File diff suppressed because it is too large
Load Diff
+20
-3
@@ -40,6 +40,16 @@ struct t_weechat_command
|
||||
int (*cmd_function_1arg)(char *);
|
||||
};
|
||||
|
||||
typedef struct t_weechat_alias t_weechat_alias;
|
||||
|
||||
struct t_weechat_alias
|
||||
{
|
||||
char *alias_name;
|
||||
char *alias_command;
|
||||
t_weechat_alias *prev_alias;
|
||||
t_weechat_alias *next_alias;
|
||||
};
|
||||
|
||||
typedef struct t_index_command t_index_command;
|
||||
|
||||
struct t_index_command
|
||||
@@ -49,15 +59,22 @@ struct t_index_command
|
||||
t_index_command *next_index;
|
||||
};
|
||||
|
||||
extern t_weechat_alias *weechat_alias;
|
||||
extern t_index_command *index_commands;
|
||||
|
||||
extern t_index_command *index_command_new (char *);
|
||||
extern void index_command_build ();
|
||||
extern t_weechat_alias *alias_new (char *, char *);
|
||||
extern int exec_weechat_command (t_irc_server *, char *);
|
||||
extern void user_command (t_irc_server *, char *);
|
||||
extern int weechat_cmd_alias(int, char **);
|
||||
extern int weechat_cmd_clear(int, char **);
|
||||
extern int weechat_cmd_alias (char *);
|
||||
extern int weechat_cmd_clear (int, char **);
|
||||
extern int weechat_cmd_connect (int, char **);
|
||||
extern int weechat_cmd_disconnect (int, char **);
|
||||
extern int weechat_cmd_help (int, char **);
|
||||
extern int weechat_cmd_server (int, char **);
|
||||
extern int weechat_cmd_save (int, char **);
|
||||
extern int weechat_cmd_set (int, char **);
|
||||
extern int weechat_cmd_unalias (int, char **);
|
||||
extern int weechat_cmd_unalias (char *);
|
||||
|
||||
#endif /* command.h */
|
||||
|
||||
+265
-97
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "weechat.h"
|
||||
#include "config.h"
|
||||
#include "command.h"
|
||||
#include "irc/irc.h"
|
||||
#include "gui/gui.h"
|
||||
|
||||
@@ -44,11 +45,13 @@ t_config_section config_sections[CONFIG_NUMBER_SECTIONS] =
|
||||
{ CONFIG_SECTION_LOG, "log" },
|
||||
{ CONFIG_SECTION_DCC, "dcc" },
|
||||
{ CONFIG_SECTION_PROXY, "proxy" },
|
||||
{ CONFIG_SECTION_ALIAS, "alias" },
|
||||
{ CONFIG_SECTION_SERVER, "server" }
|
||||
};
|
||||
|
||||
/* config, look & feel section */
|
||||
|
||||
int cfg_look_set_title;
|
||||
int cfg_look_startup_logo;
|
||||
int cfg_look_startup_version;
|
||||
char *cfg_look_weechat_slogan;
|
||||
@@ -67,16 +70,20 @@ char *cfg_look_no_nickname;
|
||||
char *cfg_look_completor;
|
||||
|
||||
t_config_option weechat_options_look[] =
|
||||
{ { "look_startup_logo", N_("display " WEECHAT_NAME " logo at startup"),
|
||||
N_("display " WEECHAT_NAME " logo at startup"),
|
||||
{ { "look_set_title", N_("set title for terminal window (curses GUI) with name & version"),
|
||||
N_("set title for terminal window (curses GUI) with name & version"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
NULL, NULL, &cfg_look_set_title, NULL, NULL },
|
||||
{ "look_startup_logo", N_("display WeeChat logo at startup"),
|
||||
N_("display WeeChat logo at startup"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
NULL, NULL, &cfg_look_startup_logo, NULL, NULL },
|
||||
{ "look_startup_version", N_("display " WEECHAT_NAME " version at startup"),
|
||||
N_("display " WEECHAT_NAME " version at startup"),
|
||||
{ "look_startup_version", N_("display WeeChat version at startup"),
|
||||
N_("display WeeChat version at startup"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
NULL, NULL, &cfg_look_startup_version, NULL, NULL },
|
||||
{ "look_weechat_slogan", N_(WEECHAT_NAME "slogan"),
|
||||
N_(WEECHAT_NAME "slogan (if empty, slogan is not used)"),
|
||||
{ "look_weechat_slogan", N_("WeeChat slogan"),
|
||||
N_("WeeChat slogan (if empty, slogan is not used)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"the geekest IRC client!", NULL, NULL, &cfg_look_weechat_slogan, NULL },
|
||||
{ "look_color_nicks", N_("display nick names with different colors"),
|
||||
@@ -333,7 +340,7 @@ t_config_option weechat_options_log[] =
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
NULL, NULL, &cfg_log_auto_private, NULL, NULL },
|
||||
{ "log_path", N_("path for log files"),
|
||||
N_("path for " WEECHAT_NAME " log files"),
|
||||
N_("path for WeeChat log files"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"~/.weechat/logs/", NULL, NULL, &cfg_log_path, NULL },
|
||||
{ "log_name", N_("name for log files"),
|
||||
@@ -441,6 +448,10 @@ t_config_option weechat_options_server[] =
|
||||
N_("name associated to IRC server (for display only)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"", NULL, NULL, &(cfg_server.name), NULL },
|
||||
{ "server_autoconnect", N_("automatically connect to server"),
|
||||
N_("automatically connect to server when WeeChat is starting"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
NULL, NULL, &(cfg_server.autoconnect), NULL, NULL },
|
||||
{ "server_address", N_("server address or hostname"),
|
||||
N_("IP address or hostname of IRC server"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
@@ -473,6 +484,14 @@ t_config_option weechat_options_server[] =
|
||||
N_("real name to use on IRC server"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"", NULL, NULL, &(cfg_server.realname), NULL },
|
||||
{ "server_command", N_("first command to run when connected to server"),
|
||||
N_("first command to run when connected to server"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"", NULL, NULL, &(cfg_server.command), NULL },
|
||||
{ "server_autojoin", N_("list of channels to join when connected to server"),
|
||||
N_("comma separated list of channels to join when connected to server"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"", NULL, NULL, &(cfg_server.autojoin), NULL },
|
||||
{ NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
@@ -481,7 +500,7 @@ t_config_option weechat_options_server[] =
|
||||
t_config_option *weechat_options[CONFIG_NUMBER_SECTIONS] =
|
||||
{ weechat_options_look, weechat_options_colors, weechat_options_history,
|
||||
weechat_options_log, weechat_options_dcc, weechat_options_proxy,
|
||||
weechat_options_server
|
||||
NULL, weechat_options_server
|
||||
};
|
||||
|
||||
|
||||
@@ -506,24 +525,6 @@ get_pos_array_values (char **array, char *string)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* config_init_server: init server struct
|
||||
*/
|
||||
|
||||
void
|
||||
config_init_server ()
|
||||
{
|
||||
cfg_server.name = NULL;
|
||||
cfg_server.address = NULL;
|
||||
cfg_server.port = -1;
|
||||
cfg_server.password = NULL;
|
||||
cfg_server.nick1 = NULL;
|
||||
cfg_server.nick2 = NULL;
|
||||
cfg_server.nick3 = NULL;
|
||||
cfg_server.username = NULL;
|
||||
cfg_server.realname = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* config_allocate_server: allocate a new server
|
||||
*/
|
||||
@@ -556,9 +557,10 @@ config_allocate_server (char *filename, int line_number)
|
||||
return 0;
|
||||
}
|
||||
if (!server_new (cfg_server.name,
|
||||
cfg_server.address, cfg_server.port, cfg_server.password,
|
||||
cfg_server.nick1, cfg_server.nick2, cfg_server.nick3,
|
||||
cfg_server.username, cfg_server.realname))
|
||||
cfg_server.autoconnect, cfg_server.address, cfg_server.port,
|
||||
cfg_server.password, cfg_server.nick1, cfg_server.nick2,
|
||||
cfg_server.nick3, cfg_server.username, cfg_server.realname,
|
||||
cfg_server.command, cfg_server.autojoin))
|
||||
{
|
||||
server_free_all ();
|
||||
gui_printf (NULL,
|
||||
@@ -566,26 +568,9 @@ config_allocate_server (char *filename, int line_number)
|
||||
WEECHAT_WARNING, filename, line_number);
|
||||
return 0;
|
||||
}
|
||||
if (cfg_server.name)
|
||||
free (cfg_server.name);
|
||||
if (cfg_server.address)
|
||||
free (cfg_server.address);
|
||||
if (cfg_server.password)
|
||||
free (cfg_server.password);
|
||||
if (cfg_server.nick1)
|
||||
free (cfg_server.nick1);
|
||||
if (cfg_server.nick2)
|
||||
free (cfg_server.nick2);
|
||||
if (cfg_server.nick3)
|
||||
free (cfg_server.nick3);
|
||||
if (cfg_server.username)
|
||||
free (cfg_server.username);
|
||||
if (cfg_server.realname)
|
||||
free (cfg_server.realname);
|
||||
if (cfg_server.nick)
|
||||
free (cfg_server.nick);
|
||||
|
||||
config_init_server ();
|
||||
server_destroy (&cfg_server);
|
||||
server_init (&cfg_server);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -601,7 +586,7 @@ config_default_values ()
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if (i != CONFIG_SECTION_SERVER)
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
@@ -670,7 +655,7 @@ config_read ()
|
||||
}
|
||||
|
||||
config_default_values ();
|
||||
config_init_server ();
|
||||
server_init (&cfg_server);
|
||||
|
||||
/* read config file */
|
||||
section = CONFIG_SECTION_NONE;
|
||||
@@ -756,29 +741,35 @@ config_read ()
|
||||
pos2 = strchr (pos, '\n');
|
||||
if (pos2 != NULL)
|
||||
pos2[0] = '\0';
|
||||
option_number = -1;
|
||||
for (i = 0;
|
||||
weechat_options[section][i].option_name; i++)
|
||||
|
||||
if (section == CONFIG_SECTION_ALIAS)
|
||||
{
|
||||
if (strcmp
|
||||
(weechat_options[section][i].option_name,
|
||||
ptr_line) == 0)
|
||||
{
|
||||
option_number = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (option_number < 0)
|
||||
{
|
||||
gui_printf (NULL,
|
||||
_("%s %s, line %d: invalid option \"%s\"\n"),
|
||||
WEECHAT_WARNING, filename, line_number, ptr_line);
|
||||
fclose (file);
|
||||
free (filename);
|
||||
return -2;
|
||||
if (alias_new (line, pos))
|
||||
index_command_new (pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
option_number = -1;
|
||||
for (i = 0;
|
||||
weechat_options[section][i].option_name; i++)
|
||||
{
|
||||
if (strcmp
|
||||
(weechat_options[section][i].option_name,
|
||||
ptr_line) == 0)
|
||||
{
|
||||
option_number = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (option_number < 0)
|
||||
{
|
||||
gui_printf (NULL,
|
||||
_("%s %s, line %d: invalid option \"%s\"\n"),
|
||||
WEECHAT_WARNING, filename, line_number, ptr_line);
|
||||
fclose (file);
|
||||
free (filename);
|
||||
return -2;
|
||||
}
|
||||
switch (weechat_options[section]
|
||||
[option_number].option_type)
|
||||
{
|
||||
@@ -920,6 +911,8 @@ config_read ()
|
||||
|
||||
/*
|
||||
* config_create_default: create default WeeChat config
|
||||
* return: 0 if ok
|
||||
* < 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
@@ -936,24 +929,25 @@ config_create_default ()
|
||||
sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME"));
|
||||
if ((file = fopen (filename, "wt")) == NULL)
|
||||
{
|
||||
free (filename);
|
||||
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
|
||||
WEECHAT_ERROR, filename);
|
||||
free (filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf (_(WEECHAT_NAME ": creating default config file...\n"));
|
||||
printf (_("%s: creating default config file...\n"), WEECHAT_NAME);
|
||||
log_printf (_("creating default config file\n"));
|
||||
|
||||
current_time = time (NULL);
|
||||
sprintf (line, _("#\n# " WEECHAT_NAME " configuration file, generated by "
|
||||
WEECHAT_NAME " " WEECHAT_VERSION " on %s"), ctime (¤t_time));
|
||||
sprintf (line, _("#\n# %s configuration file, created by "
|
||||
"%s v%s on %s#\n"),
|
||||
WEECHAT_NAME, WEECHAT_NAME, WEECHAT_VERSION,
|
||||
ctime (¤t_time));
|
||||
fputs (line, file);
|
||||
fputs (_("# This file may be edited by user. Invalid syntax will prevent "
|
||||
WEECHAT_NAME " from running!\n#\n"), file);
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if (i != CONFIG_SECTION_SERVER)
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
sprintf (line, "\n[%s]\n", config_sections[i].section_name);
|
||||
fputs (line, file);
|
||||
@@ -969,33 +963,62 @@ config_create_default ()
|
||||
{
|
||||
switch (weechat_options[i][j].option_type)
|
||||
{
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].
|
||||
default_int) ? "on" : "off");
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
sprintf (line, "%s=%d\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_int);
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
case OPTION_TYPE_COLOR:
|
||||
case OPTION_TYPE_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].default_int) ?
|
||||
"on" : "off");
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
sprintf (line, "%s=%d\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_int);
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
case OPTION_TYPE_COLOR:
|
||||
case OPTION_TYPE_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
}
|
||||
fputs (line, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* default aliases */
|
||||
/* TODO: remove comments when missing commands will be ok */
|
||||
fputs ("\n[alias]\n", file);
|
||||
fputs ("SAY=msg *\n", file);
|
||||
fputs ("BYE=quit\n", file);
|
||||
fputs ("EXIT=quit\n", file);
|
||||
fputs ("SIGNOFF=quit\n", file);
|
||||
fputs ("C=clear\n", file);
|
||||
fputs ("CL=clear\n", file);
|
||||
fputs ("# CHAT=dcc chat\n", file);
|
||||
fputs ("# GET=dcc get\n", file);
|
||||
fputs ("# IG=ignore\n", file);
|
||||
fputs ("J=join\n", file);
|
||||
fputs ("K=kick\n", file);
|
||||
fputs ("# KB=kickban\n", file);
|
||||
fputs ("# KN=knockout\n", file);
|
||||
fputs ("LEAVE=part\n", file);
|
||||
fputs ("M=msg\n", file);
|
||||
fputs ("# MUB=unban *\n", file);
|
||||
fputs ("N=names\n", file);
|
||||
fputs ("T=topic\n", file);
|
||||
fputs ("# UB=unban\n", file);
|
||||
fputs ("# UNIG=unignore\n", file);
|
||||
fputs ("# W=who\n", file);
|
||||
fputs ("WC=part\n", file);
|
||||
fputs ("WI=whois\n", file);
|
||||
fputs ("# WW=whowas\n", file);
|
||||
|
||||
/* default server is freenode */
|
||||
fputs ("\n[server]\n", file);
|
||||
fputs ("server_name=freenode\n", file);
|
||||
fputs ("server_autoconnect=on\n", file);
|
||||
fputs ("server_address=irc.freenode.net\n", file);
|
||||
fputs ("server_port=6667\n", file);
|
||||
fputs ("server_password=\n", file);
|
||||
@@ -1004,6 +1027,8 @@ config_create_default ()
|
||||
fputs ("server_nick3=weechat3\n", file);
|
||||
fputs ("server_username=weechat\n", file);
|
||||
fputs ("server_realname=WeeChat default realname\n", file);
|
||||
fputs ("server_command=\n", file);
|
||||
fputs ("server_autojoin=\n", file);
|
||||
|
||||
fclose (file);
|
||||
free (filename);
|
||||
@@ -1012,10 +1037,153 @@ config_create_default ()
|
||||
|
||||
/*
|
||||
* config_write: write WeeChat configurtion
|
||||
* return: 0 if ok
|
||||
* < 0 if error
|
||||
*/
|
||||
|
||||
void
|
||||
config_write ()
|
||||
int
|
||||
config_write (char *config_name)
|
||||
{
|
||||
/* TODO: write "config_write" function! */
|
||||
char *filename;
|
||||
char line[1024];
|
||||
FILE *file;
|
||||
int i, j;
|
||||
time_t current_time;
|
||||
t_irc_server *ptr_server;
|
||||
t_weechat_alias *ptr_alias;
|
||||
|
||||
if (config_name)
|
||||
filename = strdup (config_name);
|
||||
else
|
||||
{
|
||||
filename =
|
||||
(char *) malloc ((strlen (getenv ("HOME")) + 64) * sizeof (char));
|
||||
sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME"));
|
||||
}
|
||||
|
||||
if ((file = fopen (filename, "wt")) == NULL)
|
||||
{
|
||||
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
|
||||
WEECHAT_ERROR, filename);
|
||||
free (filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
log_printf (_("saving config to disk\n"));
|
||||
|
||||
current_time = time (NULL);
|
||||
sprintf (line, _("#\n# %s configuration file, created by "
|
||||
"%s v%s on %s#\n"),
|
||||
WEECHAT_NAME, WEECHAT_NAME, WEECHAT_VERSION,
|
||||
ctime (¤t_time));
|
||||
fputs (line, file);
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
sprintf (line, "\n[%s]\n", config_sections[i].section_name);
|
||||
fputs (line, file);
|
||||
if ((i == CONFIG_SECTION_HISTORY) || (i == CONFIG_SECTION_LOG) ||
|
||||
(i == CONFIG_SECTION_DCC) || (i == CONFIG_SECTION_PROXY))
|
||||
{
|
||||
sprintf (line,
|
||||
"# WARNING!!! Options for section \"%s\" are not developed!\n",
|
||||
config_sections[i].section_name);
|
||||
fputs (line, file);
|
||||
}
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
switch (weechat_options[i][j].option_type)
|
||||
{
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int &&
|
||||
*weechat_options[i][j].ptr_int) ?
|
||||
"on" : "off");
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
sprintf (line, "%s=%d\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
*weechat_options[i][j].ptr_int :
|
||||
weechat_options[i][j].default_int);
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
weechat_options[i][j].array_values[*weechat_options[i][j].ptr_int] :
|
||||
weechat_options[i][j].array_values[weechat_options[i][j].default_int]);
|
||||
break;
|
||||
case OPTION_TYPE_COLOR:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
gui_get_color_by_value (*weechat_options[i][j].ptr_int) :
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_string) ?
|
||||
*weechat_options[i][j].ptr_string :
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
}
|
||||
fputs (line, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* alias section */
|
||||
fputs ("\n[alias]\n", file);
|
||||
for (ptr_alias = weechat_alias; ptr_alias;
|
||||
ptr_alias = ptr_alias->next_alias)
|
||||
{
|
||||
sprintf (line, "%s=%s\n",
|
||||
ptr_alias->alias_name, ptr_alias->alias_command + 1);
|
||||
fputs (line, file);
|
||||
}
|
||||
|
||||
/* server section */
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
/* default server is freenode */
|
||||
fputs ("\n[server]\n", file);
|
||||
sprintf (line, "server_name=%s\n", ptr_server->name);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_autoconnect=%s\n",
|
||||
(ptr_server->autoconnect) ? "on" : "off");
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_address=%s\n", ptr_server->address);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_port=%d\n", ptr_server->port);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_password=%s\n",
|
||||
(ptr_server->password) ? ptr_server->password : "");
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_nick1=%s\n", ptr_server->nick1);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_nick2=%s\n", ptr_server->nick2);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_nick3=%s\n", ptr_server->nick3);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_username=%s\n", ptr_server->username);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_realname=%s\n", ptr_server->realname);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_command=%s\n",
|
||||
(ptr_server->command) ? ptr_server->command : "");
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_autojoin=%s\n",
|
||||
(ptr_server->autojoin) ? ptr_server->autojoin : "");
|
||||
fputs (line, file);
|
||||
}
|
||||
|
||||
fclose (file);
|
||||
free (filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+5
-3
@@ -32,8 +32,9 @@
|
||||
#define CONFIG_SECTION_LOG 3
|
||||
#define CONFIG_SECTION_DCC 4
|
||||
#define CONFIG_SECTION_PROXY 5
|
||||
#define CONFIG_SECTION_SERVER 6
|
||||
#define CONFIG_NUMBER_SECTIONS 7
|
||||
#define CONFIG_SECTION_ALIAS 6
|
||||
#define CONFIG_SECTION_SERVER 7
|
||||
#define CONFIG_NUMBER_SECTIONS 8
|
||||
|
||||
#define OPTION_TYPE_BOOLEAN 1 /* values: on/off */
|
||||
#define OPTION_TYPE_INT 2 /* values: from min to max */
|
||||
@@ -74,6 +75,7 @@ struct t_config_option
|
||||
int (*handler_change)(int *, char **);
|
||||
};
|
||||
|
||||
extern int cfg_look_set_title;
|
||||
extern int cfg_look_startup_logo;
|
||||
extern int cfg_look_startup_version;
|
||||
extern char *cfg_look_weechat_slogan;
|
||||
@@ -150,6 +152,6 @@ extern t_config_option * weechat_options [CONFIG_NUMBER_SECTIONS];
|
||||
|
||||
extern int config_read ();
|
||||
extern int config_create_default ();
|
||||
extern void config_write ();
|
||||
extern int config_write ();
|
||||
|
||||
#endif /* config.h */
|
||||
|
||||
@@ -611,7 +611,8 @@ gui_draw_window_nick (t_gui_window *window)
|
||||
if (CHANNEL(window) && CHANNEL(window)->nicks)
|
||||
{
|
||||
max_length = nick_get_max_length (CHANNEL(window));
|
||||
if ((max_length + 2) != window->win_nick_width)
|
||||
if ((window == gui_current_window) &&
|
||||
((max_length + 2) != window->win_nick_width))
|
||||
{
|
||||
gui_calculate_pos_size (window);
|
||||
delwin (window->win_chat);
|
||||
@@ -624,7 +625,6 @@ gui_draw_window_nick (t_gui_window *window)
|
||||
window->win_nick_width,
|
||||
window->win_nick_y,
|
||||
window->win_nick_x);
|
||||
//scrollok (window->win_chat, TRUE);
|
||||
gui_redraw_window_chat (window);
|
||||
}
|
||||
sprintf (format, "%%-%ds", max_length);
|
||||
@@ -752,6 +752,7 @@ void
|
||||
gui_draw_window_status (t_gui_window *window)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
char format_more[32];
|
||||
|
||||
/* TODO: manage splitted windows! */
|
||||
if (window != gui_current_window)
|
||||
@@ -853,9 +854,12 @@ gui_draw_window_status (t_gui_window *window)
|
||||
/* display "*MORE*" if last line is not displayed */
|
||||
gui_window_set_color (window->win_status, COLOR_WIN_STATUS_MORE);
|
||||
if (window->sub_lines > 0)
|
||||
mvwprintw (window->win_status, 0, COLS - 7, "-MORE-");
|
||||
mvwprintw (window->win_status, 0, COLS - 7, _("-MORE-"));
|
||||
else
|
||||
mvwprintw (window->win_status, 0, COLS - 7, " ");
|
||||
{
|
||||
sprintf (format_more, "%%-%ds", strlen (_("-MORE")));
|
||||
mvwprintw (window->win_status, 0, COLS - 7, format_more, " ");
|
||||
}
|
||||
|
||||
wrefresh (window->win_status);
|
||||
refresh ();
|
||||
@@ -958,17 +962,34 @@ gui_draw_window_input (t_gui_window *window)
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (format, "%%s> %%-%ds", input_width);
|
||||
if (SERVER(window) && (SERVER(window)->is_connected))
|
||||
ptr_nickname = SERVER(window)->nick;
|
||||
if (SERVER(window))
|
||||
{
|
||||
sprintf (format, "%%s> %%-%ds", input_width);
|
||||
if (SERVER(window) && (SERVER(window)->is_connected))
|
||||
ptr_nickname = SERVER(window)->nick;
|
||||
else
|
||||
ptr_nickname = cfg_look_no_nickname;
|
||||
mvwprintw (window->win_input, 0, 0, format,
|
||||
ptr_nickname,
|
||||
window->input_buffer + window->input_buffer_1st_display);
|
||||
wclrtoeol (window->win_input);
|
||||
move (LINES - 1, strlen (ptr_nickname) + 2 +
|
||||
(window->input_buffer_pos - window->input_buffer_1st_display));
|
||||
}
|
||||
else
|
||||
ptr_nickname = cfg_look_no_nickname;
|
||||
mvwprintw (window->win_input, 0, 0, format,
|
||||
ptr_nickname,
|
||||
window->input_buffer + window->input_buffer_1st_display);
|
||||
wclrtoeol (window->win_input);
|
||||
move (LINES - 1, strlen (ptr_nickname) + 2 +
|
||||
(window->input_buffer_pos - window->input_buffer_1st_display));
|
||||
{
|
||||
sprintf (format, "%%s> %%-%ds", input_width);
|
||||
if (SERVER(window) && (SERVER(window)->is_connected))
|
||||
ptr_nickname = SERVER(window)->nick;
|
||||
else
|
||||
ptr_nickname = cfg_look_no_nickname;
|
||||
mvwprintw (window->win_input, 0, 0, format,
|
||||
ptr_nickname,
|
||||
window->input_buffer + window->input_buffer_1st_display);
|
||||
wclrtoeol (window->win_input);
|
||||
move (LINES - 1, strlen (ptr_nickname) + 2 +
|
||||
(window->input_buffer_pos - window->input_buffer_1st_display));
|
||||
}
|
||||
}
|
||||
|
||||
wrefresh (window->win_input);
|
||||
@@ -1089,17 +1110,17 @@ gui_switch_to_window (t_gui_window *window)
|
||||
}
|
||||
}
|
||||
|
||||
gui_calculate_pos_size (window);
|
||||
|
||||
/* first time creation for windows */
|
||||
if (!another_window)
|
||||
{
|
||||
/* create new windows */
|
||||
gui_calculate_pos_size (window);
|
||||
window->win_title = newwin (1, COLS, 0, 0);
|
||||
window->win_chat = newwin (window->win_chat_height,
|
||||
window->win_chat_width,
|
||||
window->win_chat_y,
|
||||
window->win_chat_x);
|
||||
//scrollok (window->win_chat, TRUE);
|
||||
if (CHANNEL(window))
|
||||
window->win_nick = newwin (window->win_nick_height,
|
||||
window->win_nick_width,
|
||||
@@ -1112,34 +1133,33 @@ gui_switch_to_window (t_gui_window *window)
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_calculate_pos_size (window);
|
||||
|
||||
/* create chat & nick windows */
|
||||
if (WIN_IS_CHANNEL(window) && !(window->win_nick))
|
||||
if (WIN_IS_CHANNEL(window))
|
||||
{
|
||||
/* add nick list window */
|
||||
/* (re)create nicklist window */
|
||||
if (window->win_nick)
|
||||
delwin (window->win_nick);
|
||||
delwin (window->win_chat);
|
||||
window->win_chat = newwin (window->win_chat_height,
|
||||
window->win_chat_width,
|
||||
window->win_chat_y,
|
||||
window->win_chat_x);
|
||||
//scrollok (window->win_chat, TRUE);
|
||||
window->win_nick = newwin (window->win_nick_height,
|
||||
window->win_nick_width,
|
||||
window->win_nick_y,
|
||||
window->win_nick_x);
|
||||
}
|
||||
if (!(WIN_IS_CHANNEL(window)) && window->win_nick)
|
||||
if (!(WIN_IS_CHANNEL(window)))
|
||||
{
|
||||
/* remove nick list window */
|
||||
delwin (window->win_nick);
|
||||
if (window->win_nick)
|
||||
delwin (window->win_nick);
|
||||
window->win_nick = NULL;
|
||||
delwin (window->win_chat);
|
||||
window->win_chat = newwin (window->win_chat_height,
|
||||
window->win_chat_width,
|
||||
window->win_chat_y,
|
||||
window->win_chat_x);
|
||||
//scrollok (window->win_chat, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1229,7 +1249,21 @@ gui_window_new (void *server, void *channel
|
||||
/*int x, int y, int width, int height*/)
|
||||
{
|
||||
t_gui_window *new_window;
|
||||
|
||||
|
||||
if (gui_windows)
|
||||
{
|
||||
if (!SERVER(gui_windows))
|
||||
{
|
||||
if (server)
|
||||
((t_irc_server *)(server))->window = gui_windows;
|
||||
if (channel)
|
||||
((t_irc_channel *)(channel))->window = gui_windows;
|
||||
SERVER(gui_windows) = server;
|
||||
CHANNEL(gui_windows) = channel;
|
||||
return gui_windows;
|
||||
}
|
||||
}
|
||||
|
||||
if ((new_window = (t_gui_window *)(malloc (sizeof (t_gui_window)))))
|
||||
{
|
||||
/* assign server and channel to window */
|
||||
@@ -1290,6 +1324,7 @@ gui_window_new (void *server, void *channel
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
|
||||
return new_window;
|
||||
}
|
||||
|
||||
@@ -1302,9 +1337,13 @@ gui_window_free (t_gui_window *window)
|
||||
{
|
||||
t_gui_line *ptr_line;
|
||||
t_gui_message *ptr_message;
|
||||
int create_new;
|
||||
|
||||
create_new = (window->server || window->channel);
|
||||
|
||||
/* TODO: manage splitted windows! */
|
||||
if (window == gui_current_window)
|
||||
if ((window == gui_current_window) &&
|
||||
((window->next_window) || (window->prev_window)))
|
||||
gui_switch_to_previous_window ();
|
||||
|
||||
/* free lines and messages */
|
||||
@@ -1339,6 +1378,10 @@ gui_window_free (t_gui_window *window)
|
||||
last_gui_window = window->prev_window;
|
||||
|
||||
free (window);
|
||||
|
||||
/* always at least one window */
|
||||
if (!gui_windows && create_new)
|
||||
gui_window_new (NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1506,6 +1549,12 @@ gui_init ()
|
||||
|
||||
signal (SIGWINCH, gui_resize_term_handler);
|
||||
|
||||
#ifdef __linux__
|
||||
/* set title for term window, not for console */
|
||||
if (cfg_look_set_title && (strcmp (getenv ("TERM"), "linux") != 0))
|
||||
printf ("\e]2;" WEECHAT_NAME " " WEECHAT_VERSION "\a\e]1;" WEECHAT_NAME " " WEECHAT_VERSION "\a");
|
||||
#endif
|
||||
|
||||
gui_ready = 1;
|
||||
}
|
||||
|
||||
@@ -1534,7 +1583,7 @@ gui_end ()
|
||||
/* TODO: free input buffer, lines, messages, completion */
|
||||
}
|
||||
|
||||
/* end of ncurses output */
|
||||
/* end of curses output */
|
||||
refresh ();
|
||||
endwin ();
|
||||
}
|
||||
@@ -1594,7 +1643,7 @@ gui_new_message (t_gui_window *window)
|
||||
}
|
||||
else
|
||||
{
|
||||
log_printf ("not enough memory!\n");
|
||||
log_printf (_("not enough memory!\n"));
|
||||
return NULL;
|
||||
}
|
||||
return new_message;
|
||||
|
||||
+227
-141
@@ -29,6 +29,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include "../weechat.h"
|
||||
#include "irc.h"
|
||||
@@ -102,7 +103,8 @@ t_irc_command irc_commands[] =
|
||||
" o: operator flag\n"),
|
||||
1, MAX_ARGS, 1, NULL, irc_cmd_send_mode, irc_cmd_recv_mode },
|
||||
{ "msg", N_("send message to a nick or channel"),
|
||||
N_("receiver[,receiver] text"), N_("receiver: nick or channel (may be mask)"
|
||||
N_("receiver[,receiver] text"),
|
||||
N_("receiver: nick or channel (may be mask, '*' = current channel)"
|
||||
"\ntext: text to send"),
|
||||
1, MAX_ARGS, 1, NULL, irc_cmd_send_msg, NULL },
|
||||
{ "names", N_("list nicknames on channels"),
|
||||
@@ -122,7 +124,7 @@ t_irc_command irc_commands[] =
|
||||
N_("user/password: used to get privileges on current IRC server"),
|
||||
2, 2, 1, irc_cmd_send_oper, NULL, NULL },
|
||||
{ "part", N_("leave a channel"),
|
||||
N_("[channel[,channel]]"), N_("channel: channel name to join"),
|
||||
N_("[channel[,channel]]"), N_("channel: channel name to leave"),
|
||||
0, MAX_ARGS, 1, NULL, irc_cmd_send_part, irc_cmd_recv_part },
|
||||
{ "ping", N_("ping server"),
|
||||
N_("server1 [server2]"),
|
||||
@@ -134,7 +136,7 @@ t_irc_command irc_commands[] =
|
||||
1, 2, 1, irc_cmd_send_pong, NULL, NULL },
|
||||
{ "privmsg", N_("message received"),
|
||||
"", "",
|
||||
0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_privmsg },
|
||||
0, 0, 1, NULL, NULL, irc_cmd_recv_privmsg },
|
||||
{ "quit", N_("close all connections & quit " WEECHAT_NAME),
|
||||
N_("[quit_message]"),
|
||||
N_("quit_message: quit message (displayed to other users)"),
|
||||
@@ -143,6 +145,12 @@ t_irc_command irc_commands[] =
|
||||
N_("data"),
|
||||
N_("data: raw data to send"),
|
||||
1, MAX_ARGS, 1, NULL, irc_cmd_send_quote, NULL },
|
||||
{ "rehash", N_("tell the server to reload its config file"),
|
||||
"", "",
|
||||
0, 0, 1, NULL, irc_cmd_send_rehash, NULL },
|
||||
{ "restart", N_("tell the server to restart itself"),
|
||||
"", "",
|
||||
0, 0, 1, NULL, irc_cmd_send_restart, NULL },
|
||||
{ "topic", N_("get/set channel topic"),
|
||||
N_("[channel] [topic]"), N_("channel: channel name\ntopic: new topic for channel "
|
||||
"(if topic is \"-delete\" then topic is deleted)"),
|
||||
@@ -323,11 +331,6 @@ irc_recv_command (t_irc_server *server,
|
||||
{
|
||||
int i, cmd_found;
|
||||
|
||||
#if DEBUG >= 2
|
||||
gui_printf (server->window, "recv_irc_command: cmd=%s args=%s\n",
|
||||
command, arguments);
|
||||
#endif
|
||||
|
||||
if (command == NULL)
|
||||
return -2;
|
||||
|
||||
@@ -367,8 +370,8 @@ irc_login (t_irc_server *server)
|
||||
if (!hostname[0])
|
||||
strcpy (hostname, _("unknown"));
|
||||
gui_printf (server->window,
|
||||
_(WEECHAT_NAME ": using local hostname \"%s\"\n"),
|
||||
hostname);
|
||||
_("%s: using local hostname \"%s\"\n"),
|
||||
WEECHAT_NAME, hostname);
|
||||
server_sendf (server,
|
||||
"NICK %s\r\n"
|
||||
"USER %s %s %s :%s\r\n",
|
||||
@@ -484,8 +487,8 @@ irc_cmd_send_deop (t_irc_server *server, int argc, char **argv)
|
||||
}
|
||||
else
|
||||
gui_printf (server->window,
|
||||
_("%s \"deop\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR, "deop");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -508,8 +511,8 @@ irc_cmd_send_devoice (t_irc_server *server, int argc, char **argv)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"devoice\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR, "devoice");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -557,8 +560,8 @@ irc_cmd_send_kick (t_irc_server *server, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"kick\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR, "kick");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -600,8 +603,8 @@ irc_cmd_send_me (t_irc_server *server, char *arguments)
|
||||
if (WIN_IS_SERVER(gui_current_window))
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"me\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR, "me");
|
||||
return -1;
|
||||
}
|
||||
server_sendf (server, "PRIVMSG %s :\01ACTION %s\01\r\n",
|
||||
@@ -652,66 +655,97 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments)
|
||||
pos_comma[0] = '\0';
|
||||
pos_comma++;
|
||||
}
|
||||
if (string_is_channel (arguments))
|
||||
if (strcmp (arguments, "*") == 0)
|
||||
{
|
||||
ptr_channel = channel_search (server, arguments);
|
||||
if (ptr_channel)
|
||||
if (WIN_IS_SERVER(gui_current_window))
|
||||
{
|
||||
ptr_nick = nick_search (ptr_channel, server->nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
irc_display_nick (ptr_channel->window, ptr_nick,
|
||||
MSG_TYPE_NICK, 1, 1, 0);
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_MSG,
|
||||
COLOR_WIN_CHAT, "%s\n", pos);
|
||||
}
|
||||
else
|
||||
gui_printf (server->window,
|
||||
_("%s nick not found for \"privmsg\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_printf (server->window,
|
||||
_("%s \"%s\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR, "msg *");
|
||||
return -1;
|
||||
}
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
|
||||
ptr_channel = CHANNEL(gui_current_window);
|
||||
ptr_nick = nick_search (ptr_channel, server->nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
irc_display_nick (ptr_channel->window, ptr_nick,
|
||||
MSG_TYPE_NICK, 1, 1, 0);
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_MSG,
|
||||
COLOR_WIN_CHAT, "%s\n", pos);
|
||||
}
|
||||
else
|
||||
gui_printf (server->window,
|
||||
_("%s nick not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "msg");
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n", ptr_channel->name, pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_channel = channel_search (server, arguments);
|
||||
if (!ptr_channel)
|
||||
if (string_is_channel (arguments))
|
||||
{
|
||||
ptr_channel = channel_new (server, CHAT_PRIVATE, arguments);
|
||||
ptr_channel = channel_search (server, arguments);
|
||||
if (ptr_channel)
|
||||
{
|
||||
ptr_nick = nick_search (ptr_channel, server->nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
irc_display_nick (ptr_channel->window, ptr_nick,
|
||||
MSG_TYPE_NICK, 1, 1, 0);
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_MSG,
|
||||
COLOR_WIN_CHAT, "%s\n", pos);
|
||||
}
|
||||
else
|
||||
gui_printf (server->window,
|
||||
_("%s nick not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "msg");
|
||||
}
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_channel = channel_search (server, arguments);
|
||||
if (!ptr_channel)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot create new private window \"%s\"\n"),
|
||||
WEECHAT_ERROR,
|
||||
arguments);
|
||||
return -1;
|
||||
ptr_channel = channel_new (server, CHAT_PRIVATE, arguments);
|
||||
if (!ptr_channel)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot create new private window \"%s\"\n"),
|
||||
WEECHAT_ERROR,
|
||||
arguments);
|
||||
return -1;
|
||||
}
|
||||
gui_redraw_window_title (ptr_channel->window);
|
||||
}
|
||||
gui_redraw_window_title (ptr_channel->window);
|
||||
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_CHAT_DARK, "<");
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_NICK_SELF,
|
||||
"%s", server->nick);
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_CHAT_DARK, "> ");
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_MSG,
|
||||
COLOR_WIN_CHAT, "%s\n", pos);
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
|
||||
}
|
||||
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_CHAT_DARK, "<");
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_NICK_SELF,
|
||||
"%s", server->nick);
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_CHAT_DARK, "> ");
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_MSG,
|
||||
COLOR_WIN_CHAT, "%s\n", pos);
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
|
||||
}
|
||||
arguments = pos_comma;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s wrong number of args for \"privmsg\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "msg");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -729,8 +763,8 @@ irc_cmd_send_names (t_irc_server *server, char *arguments)
|
||||
if (!WIN_IS_CHANNEL(gui_current_window))
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"names\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR, "names");
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
@@ -783,8 +817,8 @@ irc_cmd_send_op (t_irc_server *server, int argc, char **argv)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"op\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR, "op");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -832,8 +866,8 @@ irc_cmd_send_part (t_irc_server *server, char *arguments)
|
||||
if (WIN_IS_SERVER(gui_current_window))
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"part\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR, "part");
|
||||
return -1;
|
||||
}
|
||||
channel_name = CHANNEL(gui_current_window)->name;
|
||||
@@ -845,8 +879,8 @@ irc_cmd_send_part (t_irc_server *server, char *arguments)
|
||||
if (WIN_IS_SERVER(gui_current_window))
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"part\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR, "part");
|
||||
return -1;
|
||||
}
|
||||
if (WIN_IS_PRIVATE(gui_current_window))
|
||||
@@ -928,6 +962,34 @@ irc_cmd_send_quote (t_irc_server *server, char *arguments)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_cmd_send_rehash: tell the server to reload its config file
|
||||
*/
|
||||
|
||||
int
|
||||
irc_cmd_send_rehash (t_irc_server *server, char *arguments)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) arguments;
|
||||
|
||||
server_sendf (server, "REHASH\r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_cmd_send_restart: tell the server to restart itself
|
||||
*/
|
||||
|
||||
int
|
||||
irc_cmd_send_restart (t_irc_server *server, char *arguments)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) arguments;
|
||||
|
||||
server_sendf (server, "RESTART\r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_cmd_send_topic: get/set topic for a channel
|
||||
*/
|
||||
@@ -965,8 +1027,8 @@ irc_cmd_send_topic (t_irc_server *server, char *arguments)
|
||||
if (WIN_IS_SERVER(gui_current_window))
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"topic\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR, "topic");
|
||||
return -1;
|
||||
}
|
||||
channel_name = CHANNEL(gui_current_window)->name;
|
||||
@@ -1004,7 +1066,7 @@ irc_cmd_send_version (t_irc_server *server, char *arguments)
|
||||
else
|
||||
{
|
||||
irc_display_prefix (server->window, PREFIX_INFO);
|
||||
gui_printf (server->window, "%s, compiled on %s %s\n",
|
||||
gui_printf (server->window, _("%s, compiled on %s %s\n"),
|
||||
WEECHAT_NAME_AND_VERSION,
|
||||
__DATE__, __TIME__);
|
||||
server_sendf (server, "VERSION\r\n");
|
||||
@@ -1031,8 +1093,8 @@ irc_cmd_send_voice (t_irc_server *server, int argc, char **argv)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"voice\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR, "voice");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -1192,8 +1254,8 @@ irc_cmd_recv_kick (t_irc_server *server, char *host, char *arguments)
|
||||
if (!ptr_channel)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s channel not found for \"kick\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s channel not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "kick");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1224,8 +1286,8 @@ irc_cmd_recv_kick (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s nick not found for \"kick\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s nick not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "kick");
|
||||
return -1;
|
||||
}
|
||||
ptr_nick = nick_search (ptr_channel, pos_nick);
|
||||
@@ -1253,8 +1315,8 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *arguments)
|
||||
if (host == NULL)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"mode\" command received without host\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command received without host\n"),
|
||||
WEECHAT_ERROR, "mode");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1267,8 +1329,8 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *arguments)
|
||||
if (!pos)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"mode\" command received without channel or nickname\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command received without channel or nickname\n"),
|
||||
WEECHAT_ERROR, "mode");
|
||||
return -1;
|
||||
}
|
||||
pos[0] = '\0';
|
||||
@@ -1408,8 +1470,8 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s channel not found for \"mode\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s channel not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "mode");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1437,8 +1499,8 @@ irc_cmd_recv_nick (t_irc_server *server, char *host, char *arguments)
|
||||
if (host == NULL)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"nick\" command received without host\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command received without host\n"),
|
||||
WEECHAT_ERROR, "nick");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1519,8 +1581,8 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s nickname not found for \"notice\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s nickname not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "notice");
|
||||
return -1;
|
||||
}
|
||||
irc_display_prefix (server->window, PREFIX_SERVER);
|
||||
@@ -1531,9 +1593,9 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *arguments)
|
||||
if (pos2)
|
||||
pos2[0] = '\0';
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT, "CTCP ");
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT_CHANNEL, "VERSION");
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT, " reply from ");
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT_NICK, "%s", host);
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT_CHANNEL, "VERSION ");
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT, _("reply from"));
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT_NICK, " %s", host);
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT, ": %s\n", pos);
|
||||
}
|
||||
else
|
||||
@@ -1556,8 +1618,8 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *arguments)
|
||||
if (!host || !arguments)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"part\" command received without host or channel\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command received without host or channel\n"),
|
||||
WEECHAT_ERROR, "part");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1630,8 +1692,8 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s channel not found for \"part\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s channel not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "part");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1665,13 +1727,14 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
|
||||
char *pos, *pos2, *host2;
|
||||
t_irc_channel *ptr_channel;
|
||||
t_irc_nick *ptr_nick;
|
||||
struct utsname *buf;
|
||||
|
||||
/* no host => we can't identify sender of message! */
|
||||
if (host == NULL)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"privmsg\" command received without host\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command received without host\n"),
|
||||
WEECHAT_ERROR, "privmsg");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1727,8 +1790,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s nick not found for \"privmsg\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s nick not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "privmsg");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1736,8 +1799,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s channel not found for \"privmsg\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s channel not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "privmsg");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1759,11 +1822,27 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
|
||||
pos++;
|
||||
|
||||
if (strcmp (pos, "\01VERSION\01") == 0)
|
||||
{
|
||||
buf = (struct utsname *) malloc (sizeof (struct utsname));
|
||||
uname (buf);
|
||||
server_sendf (server,
|
||||
"NOTICE %s :\01VERSION "
|
||||
WEECHAT_NAME " v"
|
||||
WEECHAT_VERSION ", compiled on " __DATE__ "\01\r\n",
|
||||
host);
|
||||
_("NOTICE %s :%sVERSION %s v%s"
|
||||
" compiled on %s, host \"%s\" is running "
|
||||
"%s %s / %s%s"),
|
||||
host, "\01", WEECHAT_NAME, WEECHAT_VERSION, __DATE__,
|
||||
&buf->nodename, &buf->sysname,
|
||||
&buf->release, &buf->machine, "\01\r\n");
|
||||
free (buf);
|
||||
irc_display_prefix (server->window, PREFIX_INFO);
|
||||
gui_printf_color (server->window,
|
||||
COLOR_WIN_CHAT, _("Received a "));
|
||||
gui_printf_color (server->window,
|
||||
COLOR_WIN_CHAT_CHANNEL, _("CTCP VERSION "));
|
||||
gui_printf_color (server->window,
|
||||
COLOR_WIN_CHAT, _("from"));
|
||||
gui_printf_color (server->window,
|
||||
COLOR_WIN_CHAT_NICK, " %s\n", host);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* private message received */
|
||||
@@ -1803,8 +1882,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot parse \"privmsg\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s cannot parse \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "privmsg");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1826,8 +1905,8 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *arguments)
|
||||
if (host == NULL)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"quit\" command received without host\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command received without host\n"),
|
||||
WEECHAT_ERROR, "quit");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1856,11 +1935,11 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *arguments)
|
||||
gui_printf_color (ptr_channel->window,
|
||||
COLOR_WIN_CHAT_HOST, "%s", pos + 1);
|
||||
gui_printf_color (ptr_channel->window,
|
||||
COLOR_WIN_CHAT_DARK, ")");
|
||||
COLOR_WIN_CHAT_DARK, ") ");
|
||||
gui_printf_color (ptr_channel->window,
|
||||
COLOR_WIN_CHAT, _(" has quit "));
|
||||
COLOR_WIN_CHAT, _("has quit"));
|
||||
gui_printf_color (ptr_channel->window,
|
||||
COLOR_WIN_CHAT_DARK, "(");
|
||||
COLOR_WIN_CHAT_DARK, " (");
|
||||
gui_printf_color (ptr_channel->window,
|
||||
COLOR_WIN_CHAT, "%s",
|
||||
arguments);
|
||||
@@ -1975,11 +2054,11 @@ irc_cmd_recv_topic (t_irc_server *server, char *host, char *arguments)
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
|
||||
if (string_is_channel (arguments))
|
||||
if (!string_is_channel (arguments))
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"topic\" command received without channel\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command received without channel\n"),
|
||||
WEECHAT_ERROR, "topic");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2038,7 +2117,7 @@ irc_cmd_recv_topic (t_irc_server *server, char *host, char *arguments)
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_cmd_recv_004: '004' command (connected to irc server ?????)
|
||||
* irc_cmd_recv_004: '004' command (connected to irc server)
|
||||
*/
|
||||
|
||||
int
|
||||
@@ -2054,6 +2133,15 @@ irc_cmd_recv_004 (t_irc_server *server, char *host, char *arguments)
|
||||
server->is_connected = 1;
|
||||
gui_redraw_window_status (server->window);
|
||||
gui_redraw_window_input (server->window);
|
||||
|
||||
/* execute command once connected */
|
||||
if (server->command && server->command[0])
|
||||
user_command(server, server->command);
|
||||
|
||||
/* autojoin */
|
||||
if (server->autojoin && server->autojoin[0])
|
||||
return irc_cmd_send_join (server, server->autojoin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2673,8 +2761,8 @@ irc_cmd_recv_332 (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s channel not found for \"332\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s channel not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "332");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -2682,8 +2770,8 @@ irc_cmd_recv_332 (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot identify channel for \"332\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s cannot identify channel for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "332");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -2738,32 +2826,32 @@ irc_cmd_recv_333 (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s channel not found for \"333\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s channel not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "333");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot identify date/time for \"333\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s cannot identify date/time for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "333");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot identify nickname for \"333\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s cannot identify nickname for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "333");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot identify channel for \"333\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s cannot identify channel for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "333");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -2838,8 +2926,8 @@ irc_cmd_recv_353 (t_irc_server *server, char *host, char *arguments)
|
||||
if (pos[0] != ':')
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot parse \"353\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s cannot parse \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "353");
|
||||
return -1;
|
||||
}
|
||||
pos++;
|
||||
@@ -2878,8 +2966,8 @@ irc_cmd_recv_353 (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot parse \"353\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s cannot parse \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "353");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -3020,10 +3108,9 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments)
|
||||
if (strcmp (server->nick, server->nick1) == 0)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_(WEECHAT_NAME
|
||||
": nickname \"%s\" is already in use, "
|
||||
_("%s: nickname \"%s\" is already in use, "
|
||||
"trying 2nd nickname \"%s\"\n"),
|
||||
server->nick, server->nick2);
|
||||
WEECHAT_NAME, server->nick, server->nick2);
|
||||
free (server->nick);
|
||||
server->nick = strdup (server->nick2);
|
||||
}
|
||||
@@ -3032,19 +3119,18 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments)
|
||||
if (strcmp (server->nick, server->nick2) == 0)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_(WEECHAT_NAME
|
||||
": nickname \"%s\" is already in use, "
|
||||
_("%s: nickname \"%s\" is already in use, "
|
||||
"trying 3rd nickname \"%s\"\n"),
|
||||
server->nick, server->nick3);
|
||||
WEECHAT_NAME, server->nick, server->nick3);
|
||||
free (server->nick);
|
||||
server->nick = strdup (server->nick3);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_(WEECHAT_NAME
|
||||
": all declared nicknames are already in use, "
|
||||
"closing connection with server!\n"));
|
||||
_("%s: all declared nicknames are already in use, "
|
||||
"closing connection with server!\n"),
|
||||
WEECHAT_NAME);
|
||||
server_disconnect (server);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+116
-65
@@ -49,6 +49,36 @@ t_irc_message *recv_msgq, *msgq_last_msg;
|
||||
char *unterminated_message = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* server_init: init server struct with default values
|
||||
*/
|
||||
|
||||
void
|
||||
server_init (t_irc_server *server)
|
||||
{
|
||||
server->name = NULL;
|
||||
server->autoconnect = 0;
|
||||
server->address = NULL;
|
||||
server->port = -1;
|
||||
server->password = NULL;
|
||||
server->nick1 = NULL;
|
||||
server->nick2 = NULL;
|
||||
server->nick3 = NULL;
|
||||
server->username = NULL;
|
||||
server->realname = NULL;
|
||||
server->command = NULL;
|
||||
server->autojoin = NULL;
|
||||
server->nick = NULL;
|
||||
server->is_connected = 0;
|
||||
server->sock4 = -1;
|
||||
server->is_away = 0;
|
||||
server->server_read = -1;
|
||||
server->server_write = -1;
|
||||
server->window = NULL;
|
||||
server->channels = NULL;
|
||||
server->last_channel = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* server_alloc: allocate a new server and add it to the servers queue
|
||||
*/
|
||||
@@ -65,28 +95,12 @@ server_alloc ()
|
||||
/* alloc memory for new server */
|
||||
if ((new_server = (t_irc_server *) malloc (sizeof (t_irc_server))) == NULL)
|
||||
{
|
||||
fprintf (stderr, _("%s cannot allocate new server"), WEECHAT_ERROR);
|
||||
fprintf (stderr, _("%s cannot allocate new server\n"), WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* initialize new server */
|
||||
new_server->name = NULL;
|
||||
new_server->address = NULL;
|
||||
new_server->password = NULL;
|
||||
new_server->nick1 = NULL;
|
||||
new_server->nick2 = NULL;
|
||||
new_server->nick3 = NULL;
|
||||
new_server->username = NULL;
|
||||
new_server->realname = NULL;
|
||||
new_server->nick = NULL;
|
||||
new_server->is_connected = 0;
|
||||
new_server->sock4 = -1;
|
||||
new_server->is_away = 0;
|
||||
new_server->server_read = -1;
|
||||
new_server->server_write = -1;
|
||||
new_server->window = NULL;
|
||||
new_server->channels = NULL;
|
||||
new_server->last_channel = NULL;
|
||||
server_init (new_server);
|
||||
|
||||
/* add new server to queue */
|
||||
new_server->prev_server = last_irc_server;
|
||||
@@ -102,42 +116,12 @@ server_alloc ()
|
||||
}
|
||||
|
||||
/*
|
||||
* server_create_window: create windows for a server
|
||||
* server_destroy: free server data (not struct himself)
|
||||
*/
|
||||
|
||||
void
|
||||
server_create_window (t_irc_server *server)
|
||||
server_destroy (t_irc_server *server)
|
||||
{
|
||||
if (!SERVER(gui_windows))
|
||||
{
|
||||
server->window = gui_windows;
|
||||
SERVER(gui_windows) = server;
|
||||
}
|
||||
else
|
||||
gui_window_new (server, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* server_free: free a server and remove it from servers queue
|
||||
*/
|
||||
|
||||
void
|
||||
server_free (t_irc_server *server)
|
||||
{
|
||||
t_irc_server *new_irc_servers;
|
||||
|
||||
/* remove server from queue */
|
||||
if (server->prev_server)
|
||||
{
|
||||
(server->prev_server)->next_server = server->next_server;
|
||||
new_irc_servers = irc_servers;
|
||||
}
|
||||
else
|
||||
new_irc_servers = server->next_server;
|
||||
|
||||
if (server->next_server)
|
||||
(server->next_server)->prev_server = server->prev_server;
|
||||
|
||||
/* free data */
|
||||
if (server->name)
|
||||
free (server->name);
|
||||
@@ -155,12 +139,42 @@ server_free (t_irc_server *server)
|
||||
free (server->username);
|
||||
if (server->realname)
|
||||
free (server->realname);
|
||||
if (server->command)
|
||||
free (server->command);
|
||||
if (server->autojoin)
|
||||
free (server->autojoin);
|
||||
if (server->nick)
|
||||
free (server->nick);
|
||||
if (server->channels)
|
||||
channel_free_all (server);
|
||||
/* TODO: free weechat window (???) */
|
||||
/* (...) */
|
||||
}
|
||||
|
||||
/*
|
||||
* server_free: free a server and remove it from servers queue
|
||||
*/
|
||||
|
||||
void
|
||||
server_free (t_irc_server *server)
|
||||
{
|
||||
t_irc_server *new_irc_servers;
|
||||
|
||||
/* remove server from queue */
|
||||
if (last_irc_server == server)
|
||||
last_irc_server = server->prev_server;
|
||||
if (server->prev_server)
|
||||
{
|
||||
(server->prev_server)->next_server = server->next_server;
|
||||
new_irc_servers = irc_servers;
|
||||
}
|
||||
else
|
||||
new_irc_servers = server->next_server;
|
||||
|
||||
if (server->next_server)
|
||||
(server->next_server)->prev_server = server->prev_server;
|
||||
|
||||
server_destroy (server);
|
||||
if (server->window)
|
||||
gui_window_free (server->window);
|
||||
free (server);
|
||||
irc_servers = new_irc_servers;
|
||||
}
|
||||
@@ -182,26 +196,29 @@ server_free_all ()
|
||||
*/
|
||||
|
||||
t_irc_server *
|
||||
server_new (char *name, char *address, int port, char *password,
|
||||
char *nick1, char *nick2, char *nick3,
|
||||
char *username, char *realname)
|
||||
server_new (char *name, int autoconnect, char *address, int port,
|
||||
char *password, char *nick1, char *nick2, char *nick3,
|
||||
char *username, char *realname, char *command, char *autojoin)
|
||||
{
|
||||
t_irc_server *new_server;
|
||||
|
||||
if (!name || !address || (port < 0) || !nick1 || !nick2 || !nick3
|
||||
|| !username || !realname)
|
||||
if (!name || !address || (port < 0))
|
||||
return NULL;
|
||||
|
||||
#if DEBUG >= 1
|
||||
log_printf ("creating new server (name:%s, address:%s, port:%d, pwd:%s, "
|
||||
"nick1:%s, nick2:%s, nick3:%s, username:%s, realname:%s)\n",
|
||||
name, address, port, password, nick1, nick2, nick3,
|
||||
username, realname);
|
||||
"nick1:%s, nick2:%s, nick3:%s, username:%s, realname:%s, "
|
||||
"command:%s, autojoin:%s)\n",
|
||||
name, address, port, (password) ? password : "",
|
||||
(nick1) ? nick1 : "", (nick2) ? nick2 : "", (nick3) ? nick3 : "",
|
||||
(username) ? username : "", (realname) ? realname : "",
|
||||
(command) ? command : "", (autojoin) ? autojoin : "");
|
||||
#endif
|
||||
|
||||
if ((new_server = server_alloc ()))
|
||||
{
|
||||
new_server->name = strdup (name);
|
||||
new_server->autoconnect = autoconnect;
|
||||
new_server->address = strdup (address);
|
||||
new_server->port = port;
|
||||
new_server->password = (password) ? strdup (password) : strdup ("");
|
||||
@@ -212,6 +229,10 @@ server_new (char *name, char *address, int port, char *password,
|
||||
(username) ? strdup (username) : strdup ("weechat");
|
||||
new_server->realname =
|
||||
(realname) ? strdup (realname) : strdup ("realname");
|
||||
new_server->command =
|
||||
(command) ? strdup (command) : NULL;
|
||||
new_server->autojoin =
|
||||
(autojoin) ? strdup (autojoin) : NULL;
|
||||
new_server->nick = strdup (new_server->nick1);
|
||||
}
|
||||
else
|
||||
@@ -458,9 +479,9 @@ server_connect (t_irc_server *server)
|
||||
int server_pipe[2];
|
||||
|
||||
gui_printf (server->window,
|
||||
_(WEECHAT_NAME ": connecting to %s:%d...\n"),
|
||||
server->address, server->port);
|
||||
log_printf ("connecting to server %s:%d...\n",
|
||||
_("%s: connecting to %s:%d...\n"),
|
||||
WEECHAT_NAME, server->address, server->port);
|
||||
log_printf (_("connecting to server %s:%d...\n"),
|
||||
server->address, server->port);
|
||||
server->is_connected = 0;
|
||||
|
||||
@@ -482,7 +503,7 @@ server_connect (t_irc_server *server)
|
||||
(server->sock4, SOL_SOCKET, SO_REUSEADDR, (char *) &set,
|
||||
sizeof (set)) == -1)
|
||||
gui_printf (server->window,
|
||||
_("%s cannot set socket option 'SO_REUSEADDR'\n"),
|
||||
_("%s cannot set socket option \"SO_REUSEADDR\"\n"),
|
||||
WEECHAT_ERROR);
|
||||
set = 1;
|
||||
if (setsockopt
|
||||
@@ -530,7 +551,7 @@ server_connect (t_irc_server *server)
|
||||
|
||||
/* connection to server */
|
||||
gui_printf (server->window,
|
||||
_(WEECHAT_NAME ": server IP is: %s\n"), ip_address);
|
||||
_("%s: server IP is: %s\n"), WEECHAT_NAME, ip_address);
|
||||
|
||||
error = connect (server->sock4, (struct sockaddr *) &addr, sizeof (addr));
|
||||
if (error != 0)
|
||||
@@ -555,12 +576,24 @@ server_connect (t_irc_server *server)
|
||||
void
|
||||
server_disconnect (t_irc_server *server)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
if (server->is_connected)
|
||||
{
|
||||
/* write disconnection message on each channel/private window */
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
irc_display_prefix (ptr_channel->window, PREFIX_INFO);
|
||||
gui_printf (ptr_channel->window, _("Disconnected from server!\n"));
|
||||
}
|
||||
|
||||
/* close communication with server */
|
||||
close (server->server_read);
|
||||
close (server->server_write);
|
||||
close (server->sock4);
|
||||
server->is_connected = 0;
|
||||
server->sock4 = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,6 +610,24 @@ server_disconnect_all ()
|
||||
server_disconnect (ptr_server);
|
||||
}
|
||||
|
||||
/*
|
||||
* server_search: return pointer on a server with a name
|
||||
*/
|
||||
|
||||
t_irc_server *
|
||||
server_search (char *servername)
|
||||
{
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
if (strcmp (ptr_server->name, servername) == 0)
|
||||
return ptr_server;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* server_get_number_connected: returns number of connected server
|
||||
*/
|
||||
|
||||
+10
-3
@@ -78,6 +78,7 @@ struct t_irc_server
|
||||
{
|
||||
/* user choices */
|
||||
char *name; /* name of server (only for display) */
|
||||
int autoconnect; /* = 1 if auto connect at startup */
|
||||
char *address; /* address of server (IP or name) */
|
||||
int port; /* port for server (6667 by default) */
|
||||
char *password; /* password for server */
|
||||
@@ -86,6 +87,8 @@ struct t_irc_server
|
||||
char *nick3; /* 2nd alternate nickname */
|
||||
char *username; /* user name */
|
||||
char *realname; /* real name */
|
||||
char *command; /* command to run once connected */
|
||||
char *autojoin; /* channels to automatically join */
|
||||
|
||||
/* internal vars */
|
||||
char *nick; /* current nickname */
|
||||
@@ -137,18 +140,20 @@ extern t_irc_channel *current_channel;
|
||||
|
||||
/* server functions (irc-server.c) */
|
||||
|
||||
extern void server_init (t_irc_server *);
|
||||
extern t_irc_server *server_alloc ();
|
||||
extern void server_create_window (t_irc_server *);
|
||||
extern void server_destroy (t_irc_server *);
|
||||
extern void server_free (t_irc_server *);
|
||||
extern void server_free_all ();
|
||||
extern t_irc_server *server_new (char *, char *, int, char *, char *, char *,
|
||||
char *, char *, char *);
|
||||
extern t_irc_server *server_new (char *, int, char *, int, char *, char *,
|
||||
char *, char *, char *, char *, char *, char *);
|
||||
extern int server_send (t_irc_server *, char *, int);
|
||||
extern int server_sendf (t_irc_server *, char *, ...);
|
||||
extern void server_recv (t_irc_server *);
|
||||
extern int server_connect ();
|
||||
extern void server_disconnect (t_irc_server *);
|
||||
extern void server_disconnect_all ();
|
||||
extern t_irc_server *server_search (char *);
|
||||
extern int server_get_number_connected ();
|
||||
extern int server_name_already_exists (char *);
|
||||
|
||||
@@ -205,6 +210,8 @@ extern int irc_cmd_send_ping (t_irc_server *, int, char **);
|
||||
extern int irc_cmd_send_pong (t_irc_server *, int, char **);
|
||||
extern int irc_cmd_send_quit (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_quote (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_rehash (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_restart (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_topic (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_version (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_voice (t_irc_server *, int, char **);
|
||||
|
||||
+18
-8
@@ -211,8 +211,8 @@ wee_init_log ()
|
||||
void
|
||||
wee_shutdown ()
|
||||
{
|
||||
gui_end ();
|
||||
server_free_all ();
|
||||
gui_end ();
|
||||
if (log_file)
|
||||
fclose (log_file);
|
||||
exit (0);
|
||||
@@ -227,6 +227,10 @@ main (int argc, char *argv[])
|
||||
{
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, "/usr/share/locale");
|
||||
textdomain (PACKAGE);
|
||||
|
||||
/* initialize variables */
|
||||
wee_init_vars ();
|
||||
|
||||
@@ -239,6 +243,9 @@ main (int argc, char *argv[])
|
||||
/* init log file */
|
||||
wee_init_log ();
|
||||
|
||||
/* build commands index (sorted), for completion */
|
||||
index_command_build ();
|
||||
|
||||
/* read configuration */
|
||||
switch (config_read ())
|
||||
{
|
||||
@@ -256,9 +263,6 @@ main (int argc, char *argv[])
|
||||
/* init gui */
|
||||
gui_init ();
|
||||
|
||||
/* build commands index (sorted), for completion */
|
||||
index_command_build ();
|
||||
|
||||
/* Welcome message - yeah! */
|
||||
if (cfg_look_startup_logo)
|
||||
{
|
||||
@@ -292,17 +296,23 @@ main (int argc, char *argv[])
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX1,
|
||||
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
|
||||
|
||||
/* connect to all servers */
|
||||
/* connect to all servers (with autoconnect flag) */
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
server_create_window (ptr_server);
|
||||
if (server_connect (ptr_server))
|
||||
irc_login (ptr_server);
|
||||
if (ptr_server->autoconnect)
|
||||
{
|
||||
gui_window_new (ptr_server, NULL);
|
||||
if (server_connect (ptr_server))
|
||||
irc_login (ptr_server);
|
||||
}
|
||||
}
|
||||
gui_main_loop ();
|
||||
server_disconnect_all ();
|
||||
|
||||
/* save config file */
|
||||
config_write (NULL);
|
||||
|
||||
/* program ending */
|
||||
wee_shutdown ();
|
||||
|
||||
|
||||
+3
-1
@@ -24,13 +24,15 @@
|
||||
#define __WEECHAT_H 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
|
||||
#define PACKAGE "weechat"
|
||||
#define _(string) gettext(string)
|
||||
#define N_(string) (string)
|
||||
|
||||
#define WEECHAT_NAME "WeeChat"
|
||||
#define WEECHAT_VERSION "0.0.1"
|
||||
#define WEECHAT_VERSION "0.0.2"
|
||||
|
||||
#define WEECHAT_NAME_AND_VERSION WEECHAT_NAME " " WEECHAT_VERSION
|
||||
#define WEECHAT_COPYRIGHT WEECHAT_NAME " (c) 2003 by Wee Team"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.TH WEECHAT 1 "September 2003" "FlashCode"
|
||||
.TH WEECHAT 1 "October 2003" "FlashCode"
|
||||
|
||||
.SH NAME
|
||||
weechat \- wee enhanced environment for chat
|
||||
weechat \- Wee Enhanced Environment for Chat
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B weechat
|
||||
@@ -9,8 +9,11 @@ weechat \- wee enhanced environment for chat
|
||||
.br
|
||||
|
||||
.SH DESCRIPTION
|
||||
Fast, light and extensible IRC client for many operating systems. Everything can be
|
||||
done with a keyboard. It is customizable and extensible with scripts.
|
||||
Fast, light and extensible IRC client for many operating systems.
|
||||
.br
|
||||
Everything can be done with a keyboard. It is customizable and extensible with scripts.
|
||||
Many GUIs are available (Curses, Gtk, Qt, and text).
|
||||
It is compliant with RFCs 1459, 2810, 2811, 2812, and 2813.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
@@ -30,6 +33,9 @@ display WeeChat version
|
||||
.TP
|
||||
.B $HOME/.weechat/weechat.rc
|
||||
configuration file for WeeChat
|
||||
.TP
|
||||
.B $HOME/.weechat/weechat.log
|
||||
WeeChat log file
|
||||
|
||||
.SH AUTHOR
|
||||
WeeChat is written by:
|
||||
@@ -41,4 +47,8 @@ WeeChat is written by:
|
||||
WeeChat on the web:
|
||||
.UR
|
||||
http://weechat.flashtux.org
|
||||
.br
|
||||
Get support there:
|
||||
.UR
|
||||
http://weechat.flashtux.org/support.php
|
||||
.UE
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
%define name weechat
|
||||
%define version 0.0.1
|
||||
%define version 0.0.2
|
||||
%define release 1
|
||||
|
||||
Name: %{name}
|
||||
@@ -37,5 +37,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
/usr/local/bin/weechat
|
||||
|
||||
%changelog
|
||||
* Thu Sep 27 2003 FlashCode <flashcode@flashtux.org> 0.0.1-1
|
||||
* Sun Oct 05 2003 FlashCode <flashcode@flashtux.org> 0.0.2-1
|
||||
- Released version 0.0.2
|
||||
* Sat Sep 27 2003 FlashCode <flashcode@flashtux.org> 0.0.1-1
|
||||
- Released version 0.0.1
|
||||
|
||||
+6
-7
@@ -1,17 +1,16 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
WeeChat known bugs, 2003-09-27
|
||||
WeeChat known bugs, 2003-10-05
|
||||
|
||||
- too much nicks in the channel (> height of window) => display bug
|
||||
- some IRC commands are marked as 'unknown' when received
|
||||
(irc protocol is under dev!)
|
||||
- bug in nicklist resize (sometimes resize doesn't work and there is display
|
||||
problem)
|
||||
- alias/unalias commands doesn't work
|
||||
- config is not saved (to ~/.weechat/weechatrc)
|
||||
(IRC protocol is under dev!)
|
||||
- intercept Ctrl-C (do not quit immediately if Ctrl-C pressed!)
|
||||
- program is stopped when bad option in config file (it should not, only display
|
||||
warning)
|
||||
- too much opened channel => display bug
|
||||
- too much opened channels => display bug
|
||||
- when kicked, channel is not prefixed by '(' and sufixed by ')'
|
||||
- when function key (non used by WeeChat) is pressed, prompt is deleted
|
||||
- when quitting WeeChat term title is not restored (if look_set_title is ON)
|
||||
- command name for /server can not contain spaces
|
||||
|
||||
+25
-82
@@ -1,88 +1,31 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
ChangeLog - 2003-09-27
|
||||
ChangeLog - 2003-10-05
|
||||
|
||||
* 2003-09-27:
|
||||
- WeeChat 0.0.1 released!
|
||||
|
||||
* 2003-09-26:
|
||||
- added completor prefix (in config: look_nick_completor)
|
||||
- fixef log_printf command (bug with year & month)
|
||||
- added "/kill" command
|
||||
- fixed /version and /ctcp commands (missing ":" before message)
|
||||
Version 0.0.2 (2003-10-05):
|
||||
* added commands /rehash and /restart
|
||||
* command & auto-join channels when connected to server
|
||||
* new commands for alias: /alias, /unalias (new section in config file)
|
||||
* config is now saved automatically when quitting WeeChat, /save command added
|
||||
* new commands for servers: /server, /connect, /disconnect
|
||||
* added autoconnect flag for each server in config file
|
||||
* added "look_set_title" option in config file
|
||||
* term window title is modified with WeeChat name and version
|
||||
* fixed nicklist display bug
|
||||
* fixed crash when sending command which can only be received
|
||||
* CTCP version returns more info (about OS)
|
||||
|
||||
* 2003-09-25:
|
||||
- added "/kick" command
|
||||
- added IRC errors 402 to 407
|
||||
- added "/invite" command
|
||||
|
||||
* 2003-09-24:
|
||||
- "ctcp version" received is now correctly displayed
|
||||
- "/version" command is ok
|
||||
|
||||
* 2003-09-23:
|
||||
- log file (~/.weechat/weechat.log)
|
||||
- renamed config file (~/.weechat/weechatrc to ~/.weechat/weechat.rc)
|
||||
|
||||
* 2003-09-21:
|
||||
- "demi-highlight": 2 types of windows highlight: lightred for windows with
|
||||
unread messages (from other users), lightmagenta for windows with other
|
||||
unread data (join, part, quit, away, ...)
|
||||
- "320" IRC message management
|
||||
- "/clear" command
|
||||
|
||||
* 2003-09-19:
|
||||
- préparation des sources pour l'internationalisation avec gettext
|
||||
- "301" IRC command (away message)
|
||||
- functions renamed in rc-commands.c, irc-server.c,
|
||||
command.c and config.c (all functions are beginning with a prefix:
|
||||
irc_cmd_recv_xxx, irc_cmd_send_xxx, server_xxx, weechat_cmd_xxx and
|
||||
config_xxx). Moreover, all commands (sent and received) return a value
|
||||
(success or not)
|
||||
- "/quote" command
|
||||
- "/whois" command (and colored display of /whois result in server window)
|
||||
|
||||
* 2003-09-18:
|
||||
- use of alternate nickname (and 2nd alternate) if nick is already used
|
||||
on server (changed/added in config file: options "nick1", "nick2", "nick3"
|
||||
for a server, all are mandatory)
|
||||
- "433" IRC error management (nickname already in use)
|
||||
- "mode" command received correctly for "channel flags" and
|
||||
op/deop/voice/devoice actions for a nick
|
||||
- "401" IRC error management (no such nick/channel)
|
||||
- private windows management (when received and opened, with /privmsg),
|
||||
"/privmsg" completed consequently
|
||||
|
||||
* 2003-09-17:
|
||||
- nickmode display ((half)op/voice) before nicks (as option, look at config
|
||||
options beginning with "look_nickmode")
|
||||
- windows history is now ok (pgup/pgdn on any window type)
|
||||
- "/me" command (and OK when received)
|
||||
- display nicks count when joining channel or with "/names" command
|
||||
(total, ops, halfops, voices et normaux)
|
||||
|
||||
* 2003-09-16:
|
||||
- added and normalized chat window colors
|
||||
(new colors in config file)
|
||||
- "/topic" command
|
||||
- nicklist can be moved on top, bottom, left or right of window
|
||||
|
||||
* 2003-09-15:
|
||||
- auto-resize of nicklist, according to nick max length
|
||||
- IRC multi-servers is OK
|
||||
|
||||
* 2003-09-14:
|
||||
- no hangup if "/part" command is executed on server window
|
||||
- continue if no server is declared in config file
|
||||
(empty window will be opened for executing WeeChat commands)
|
||||
- string array for strings in config file
|
||||
example: cfg_look_nicklist_position can take values "left", "right",
|
||||
"top", "bottom", which are converted to int (from 0 for "left" to 3 for
|
||||
"bottom")
|
||||
- messages are aligned under time (server window) or under time + nick
|
||||
(channel window)
|
||||
|
||||
* 2003-09-13:
|
||||
- sources exploded in many directories: ./irc, ./gui/curses, ./gui/gtk,
|
||||
./gui/qt and ./gui/text
|
||||
Version 0.0.1 (2003-09-27):
|
||||
* ncurses GUI with color output
|
||||
* multi-servers
|
||||
* channel windows, with nicklist (position: top, bottom, left or right)
|
||||
* private windows
|
||||
* IRC commands: away, ctcp, deop, devoice, invite, join, kick, kill, list,
|
||||
me, mode, msg, names, nick, notice, op, oper, part, ping, pong, quit,
|
||||
quote, topic, version, voice, whois
|
||||
* WeeChat commands: clear, help, set (partial)
|
||||
* many config options
|
||||
* log file (~/.weechat/weechat.log)
|
||||
* nicklist can be moved on top, bottom, left or right of window
|
||||
|
||||
+6
-2
@@ -1,6 +1,10 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
FlashCode, 2003-09-27
|
||||
* FlashCode, 2003-10-05
|
||||
|
||||
WeeChat 0.0.1 released.
|
||||
WeeChat 0.0.2 released.
|
||||
|
||||
* FlashCode, 2003-09-27
|
||||
|
||||
WeeChat 0.0.1 released.
|
||||
|
||||
+23
-54
@@ -1,7 +1,7 @@
|
||||
WeeChat - Wee Enhanced Environment for Chat
|
||||
===========================================
|
||||
|
||||
TODO - 2003-09-27
|
||||
TODO - 2003-10-05
|
||||
|
||||
Legend:
|
||||
# done
|
||||
@@ -10,70 +10,40 @@ Legend:
|
||||
? is this really necessary?
|
||||
|
||||
|
||||
v0.0.1:
|
||||
v0.0.2:
|
||||
------
|
||||
|
||||
* IRC protocol:
|
||||
# "/quote" command: send a raw string to the server without parsing it
|
||||
# "/me" command (for user actions description)
|
||||
# "/away" command (to toggle the away status)
|
||||
# "/op", "/deop", "/voice", "/devoice" commands
|
||||
# "/invite" command
|
||||
# "/kick", "/ban", "/unban" commands
|
||||
# "/kill" command
|
||||
# "/list" command: list of channels
|
||||
# "/names" command: view who is on a given channel without being
|
||||
on it (for example /names #weechat gives all the nicks present on
|
||||
#weechat, except those who have the +i flag (server side))
|
||||
# "/oper" command: become operator on the irc network
|
||||
# "/topic" command: change the topic of a channel
|
||||
# "/version" command: give the irc client version (CTCP VERSION)
|
||||
of a given nick/channel (without parameter: gives WeeChat version)
|
||||
# "/whois" command
|
||||
# "/rehash" command: tell the server to reload its config file
|
||||
# "/restart" command: tell the server to restart itself
|
||||
|
||||
* WeeChat commands:
|
||||
# "/clear": to clear window content
|
||||
|
||||
* Interface:
|
||||
# "demi-highlight" when joins/quits etc
|
||||
# log messages/warning/errors to ~/.weechat/log file
|
||||
# improve editing zone (left arrow <> backspace)
|
||||
# sort nick list
|
||||
# choose nick list position (top, left, right (default), bottom)
|
||||
# auto-resize nicklist (when nick too long)
|
||||
# do pretty cutting of long lines (align on the nick or after hour for server)
|
||||
# keep history of commands and call them again with up/down arrow
|
||||
# text GUI
|
||||
# ncurses GUI:
|
||||
# one window for each channel
|
||||
# color display
|
||||
# private windows
|
||||
# redraw window when term size is modified
|
||||
# chat history (pgup/pgdn for displaying history)
|
||||
# switch to other channel window
|
||||
|
||||
* TCP/IP communication:
|
||||
# IPv4 protocol implementation
|
||||
# "/connect" and "/disconnect" commands (for multiservers use)
|
||||
# "/server" command to add, remove or list servers
|
||||
# "/save" command: save configuration to disk
|
||||
# "/alias" and "/unalias" commands
|
||||
|
||||
* Configuration:
|
||||
# write default config file
|
||||
# write config file
|
||||
# add alias definition
|
||||
# add an option for each server in order to run commands on join
|
||||
(example: /msg nickserv identify password)
|
||||
# channel list for auto-join (for each server)
|
||||
|
||||
|
||||
Future versions:
|
||||
---------------
|
||||
|
||||
* IRC protocol:
|
||||
- implement RFC 2812
|
||||
+ "/mode" command: change the user/channels modes
|
||||
- "/dcc" command (for chat and sending/receiving files)
|
||||
- manage "halfop" status
|
||||
- complete "/list" command: add regexp search, display only channels that
|
||||
match regexp
|
||||
- "/connect" and "/disconnect" commands (for multiservers use)
|
||||
- "/ignore" and "/unignore" commands: hide all that is write by a given
|
||||
nick/host
|
||||
- when we're away, WeeChat should log all the lines begenning by our nick.
|
||||
When we come back from our away it should print it to the current window
|
||||
- "/rehash" command: tell the server to reload its config file
|
||||
- "/restart" command: tell the server to restart itself
|
||||
- "/notify" and "/unnotify" command to be warn by WeeChat when a given
|
||||
nick/host connect to the given irc network
|
||||
- "/wallops" command: write the same string to all the
|
||||
@@ -87,15 +57,15 @@ Future versions:
|
||||
like -o could send the output to the server, on the current
|
||||
channel/private
|
||||
- "/reload" command: reload the WeeChat's config file
|
||||
- "/set" command: allow the user to set the WeeChat variables
|
||||
under WeeChat without editing the config file (colours, time
|
||||
format, etc)
|
||||
- "/highlight" command: highlight a given word when it appears on
|
||||
channels/privates
|
||||
+ "/set" command: allow the user to set the WeeChat variables
|
||||
under WeeChat without editing the config file (colours, time
|
||||
format, etc)
|
||||
|
||||
* Interface:
|
||||
- display current channel modes (example : #weechat(+nt))
|
||||
- interpret ^B in messages (this means bold text)
|
||||
- interpret special chars in messages (color & bold for example)
|
||||
- internationalization (traduce WeeChat in many languages)
|
||||
- many channel windows in one window/term (window split)
|
||||
- add lag indicator
|
||||
@@ -109,15 +79,14 @@ Future versions:
|
||||
? Qt GUI
|
||||
|
||||
* TCP/IP communication:
|
||||
- connect to server with child process (background)
|
||||
- SSL support
|
||||
- IPv6 protocol implementation
|
||||
|
||||
|
||||
* Configuration:
|
||||
- add key bindings to config file
|
||||
- add missing options for config file
|
||||
- write config file
|
||||
- add an option for each server in order to run commands on join
|
||||
(example: /msg nickserv identify password)
|
||||
- channel list for auto-join (for each server)
|
||||
- wrong alias is not created and not saved when quitting WeeChat
|
||||
- do not stop program if problem with options in config file
|
||||
- load config file after GUI (so init values by default (colors, ...) before
|
||||
loading config)
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
weechat (0.0.2-1) unstable; urgency=low
|
||||
|
||||
* WeeChat version 0.0.2, see ChangeLog for detail.
|
||||
|
||||
-- FlashCode <flashcode@flashtux.org> Sun, 05 Oct 2003 12:00:00 +0200
|
||||
|
||||
weechat (0.0.1-1) unstable; urgency=low
|
||||
|
||||
* First version.
|
||||
|
||||
-- FlashCode <flashcode@flashtux.org> Sat, 27 Jun 2003 12:00:00 +0200
|
||||
-- FlashCode <flashcode@flashtux.org> Sat, 27 Sep 2003 12:00:00 +0200
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
This package was debianized by FlashCode <flashcode@flashtux.org> on
|
||||
Sat, 27 Sep 2003 10:00:00 +0200.
|
||||
Sun, 05 Oct 2003 12:00:00 +0200.
|
||||
|
||||
It was downloaded from http://weechat.flashtux.org/download
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
weechat_0.0.1-1_i386.deb net optional
|
||||
weechat_0.0.2-1_i386.deb net optional
|
||||
|
||||
@@ -84,8 +84,8 @@ command.o: command.c weechat.h command.h irc/irc.h gui/gui.h completion.h \
|
||||
history.h config.h
|
||||
completion.o: completion.c weechat.h completion.h irc/irc.h gui/gui.h \
|
||||
history.h command.h
|
||||
config.o: config.c weechat.h config.h irc/irc.h gui/gui.h completion.h \
|
||||
history.h
|
||||
config.o: config.c weechat.h config.h command.h irc/irc.h gui/gui.h \
|
||||
completion.h history.h
|
||||
history.o: history.c weechat.h history.h gui/gui.h completion.h
|
||||
weechat.o: weechat.c weechat.h config.h command.h irc/irc.h gui/gui.h \
|
||||
completion.h history.h
|
||||
|
||||
+774
-58
File diff suppressed because it is too large
Load Diff
+20
-3
@@ -40,6 +40,16 @@ struct t_weechat_command
|
||||
int (*cmd_function_1arg)(char *);
|
||||
};
|
||||
|
||||
typedef struct t_weechat_alias t_weechat_alias;
|
||||
|
||||
struct t_weechat_alias
|
||||
{
|
||||
char *alias_name;
|
||||
char *alias_command;
|
||||
t_weechat_alias *prev_alias;
|
||||
t_weechat_alias *next_alias;
|
||||
};
|
||||
|
||||
typedef struct t_index_command t_index_command;
|
||||
|
||||
struct t_index_command
|
||||
@@ -49,15 +59,22 @@ struct t_index_command
|
||||
t_index_command *next_index;
|
||||
};
|
||||
|
||||
extern t_weechat_alias *weechat_alias;
|
||||
extern t_index_command *index_commands;
|
||||
|
||||
extern t_index_command *index_command_new (char *);
|
||||
extern void index_command_build ();
|
||||
extern t_weechat_alias *alias_new (char *, char *);
|
||||
extern int exec_weechat_command (t_irc_server *, char *);
|
||||
extern void user_command (t_irc_server *, char *);
|
||||
extern int weechat_cmd_alias(int, char **);
|
||||
extern int weechat_cmd_clear(int, char **);
|
||||
extern int weechat_cmd_alias (char *);
|
||||
extern int weechat_cmd_clear (int, char **);
|
||||
extern int weechat_cmd_connect (int, char **);
|
||||
extern int weechat_cmd_disconnect (int, char **);
|
||||
extern int weechat_cmd_help (int, char **);
|
||||
extern int weechat_cmd_server (int, char **);
|
||||
extern int weechat_cmd_save (int, char **);
|
||||
extern int weechat_cmd_set (int, char **);
|
||||
extern int weechat_cmd_unalias (int, char **);
|
||||
extern int weechat_cmd_unalias (char *);
|
||||
|
||||
#endif /* command.h */
|
||||
|
||||
+265
-97
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "weechat.h"
|
||||
#include "config.h"
|
||||
#include "command.h"
|
||||
#include "irc/irc.h"
|
||||
#include "gui/gui.h"
|
||||
|
||||
@@ -44,11 +45,13 @@ t_config_section config_sections[CONFIG_NUMBER_SECTIONS] =
|
||||
{ CONFIG_SECTION_LOG, "log" },
|
||||
{ CONFIG_SECTION_DCC, "dcc" },
|
||||
{ CONFIG_SECTION_PROXY, "proxy" },
|
||||
{ CONFIG_SECTION_ALIAS, "alias" },
|
||||
{ CONFIG_SECTION_SERVER, "server" }
|
||||
};
|
||||
|
||||
/* config, look & feel section */
|
||||
|
||||
int cfg_look_set_title;
|
||||
int cfg_look_startup_logo;
|
||||
int cfg_look_startup_version;
|
||||
char *cfg_look_weechat_slogan;
|
||||
@@ -67,16 +70,20 @@ char *cfg_look_no_nickname;
|
||||
char *cfg_look_completor;
|
||||
|
||||
t_config_option weechat_options_look[] =
|
||||
{ { "look_startup_logo", N_("display " WEECHAT_NAME " logo at startup"),
|
||||
N_("display " WEECHAT_NAME " logo at startup"),
|
||||
{ { "look_set_title", N_("set title for terminal window (curses GUI) with name & version"),
|
||||
N_("set title for terminal window (curses GUI) with name & version"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
NULL, NULL, &cfg_look_set_title, NULL, NULL },
|
||||
{ "look_startup_logo", N_("display WeeChat logo at startup"),
|
||||
N_("display WeeChat logo at startup"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
NULL, NULL, &cfg_look_startup_logo, NULL, NULL },
|
||||
{ "look_startup_version", N_("display " WEECHAT_NAME " version at startup"),
|
||||
N_("display " WEECHAT_NAME " version at startup"),
|
||||
{ "look_startup_version", N_("display WeeChat version at startup"),
|
||||
N_("display WeeChat version at startup"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
NULL, NULL, &cfg_look_startup_version, NULL, NULL },
|
||||
{ "look_weechat_slogan", N_(WEECHAT_NAME "slogan"),
|
||||
N_(WEECHAT_NAME "slogan (if empty, slogan is not used)"),
|
||||
{ "look_weechat_slogan", N_("WeeChat slogan"),
|
||||
N_("WeeChat slogan (if empty, slogan is not used)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"the geekest IRC client!", NULL, NULL, &cfg_look_weechat_slogan, NULL },
|
||||
{ "look_color_nicks", N_("display nick names with different colors"),
|
||||
@@ -333,7 +340,7 @@ t_config_option weechat_options_log[] =
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
NULL, NULL, &cfg_log_auto_private, NULL, NULL },
|
||||
{ "log_path", N_("path for log files"),
|
||||
N_("path for " WEECHAT_NAME " log files"),
|
||||
N_("path for WeeChat log files"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"~/.weechat/logs/", NULL, NULL, &cfg_log_path, NULL },
|
||||
{ "log_name", N_("name for log files"),
|
||||
@@ -441,6 +448,10 @@ t_config_option weechat_options_server[] =
|
||||
N_("name associated to IRC server (for display only)"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"", NULL, NULL, &(cfg_server.name), NULL },
|
||||
{ "server_autoconnect", N_("automatically connect to server"),
|
||||
N_("automatically connect to server when WeeChat is starting"),
|
||||
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE,
|
||||
NULL, NULL, &(cfg_server.autoconnect), NULL, NULL },
|
||||
{ "server_address", N_("server address or hostname"),
|
||||
N_("IP address or hostname of IRC server"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
@@ -473,6 +484,14 @@ t_config_option weechat_options_server[] =
|
||||
N_("real name to use on IRC server"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"", NULL, NULL, &(cfg_server.realname), NULL },
|
||||
{ "server_command", N_("first command to run when connected to server"),
|
||||
N_("first command to run when connected to server"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"", NULL, NULL, &(cfg_server.command), NULL },
|
||||
{ "server_autojoin", N_("list of channels to join when connected to server"),
|
||||
N_("comma separated list of channels to join when connected to server"),
|
||||
OPTION_TYPE_STRING, 0, 0, 0,
|
||||
"", NULL, NULL, &(cfg_server.autojoin), NULL },
|
||||
{ NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
@@ -481,7 +500,7 @@ t_config_option weechat_options_server[] =
|
||||
t_config_option *weechat_options[CONFIG_NUMBER_SECTIONS] =
|
||||
{ weechat_options_look, weechat_options_colors, weechat_options_history,
|
||||
weechat_options_log, weechat_options_dcc, weechat_options_proxy,
|
||||
weechat_options_server
|
||||
NULL, weechat_options_server
|
||||
};
|
||||
|
||||
|
||||
@@ -506,24 +525,6 @@ get_pos_array_values (char **array, char *string)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* config_init_server: init server struct
|
||||
*/
|
||||
|
||||
void
|
||||
config_init_server ()
|
||||
{
|
||||
cfg_server.name = NULL;
|
||||
cfg_server.address = NULL;
|
||||
cfg_server.port = -1;
|
||||
cfg_server.password = NULL;
|
||||
cfg_server.nick1 = NULL;
|
||||
cfg_server.nick2 = NULL;
|
||||
cfg_server.nick3 = NULL;
|
||||
cfg_server.username = NULL;
|
||||
cfg_server.realname = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* config_allocate_server: allocate a new server
|
||||
*/
|
||||
@@ -556,9 +557,10 @@ config_allocate_server (char *filename, int line_number)
|
||||
return 0;
|
||||
}
|
||||
if (!server_new (cfg_server.name,
|
||||
cfg_server.address, cfg_server.port, cfg_server.password,
|
||||
cfg_server.nick1, cfg_server.nick2, cfg_server.nick3,
|
||||
cfg_server.username, cfg_server.realname))
|
||||
cfg_server.autoconnect, cfg_server.address, cfg_server.port,
|
||||
cfg_server.password, cfg_server.nick1, cfg_server.nick2,
|
||||
cfg_server.nick3, cfg_server.username, cfg_server.realname,
|
||||
cfg_server.command, cfg_server.autojoin))
|
||||
{
|
||||
server_free_all ();
|
||||
gui_printf (NULL,
|
||||
@@ -566,26 +568,9 @@ config_allocate_server (char *filename, int line_number)
|
||||
WEECHAT_WARNING, filename, line_number);
|
||||
return 0;
|
||||
}
|
||||
if (cfg_server.name)
|
||||
free (cfg_server.name);
|
||||
if (cfg_server.address)
|
||||
free (cfg_server.address);
|
||||
if (cfg_server.password)
|
||||
free (cfg_server.password);
|
||||
if (cfg_server.nick1)
|
||||
free (cfg_server.nick1);
|
||||
if (cfg_server.nick2)
|
||||
free (cfg_server.nick2);
|
||||
if (cfg_server.nick3)
|
||||
free (cfg_server.nick3);
|
||||
if (cfg_server.username)
|
||||
free (cfg_server.username);
|
||||
if (cfg_server.realname)
|
||||
free (cfg_server.realname);
|
||||
if (cfg_server.nick)
|
||||
free (cfg_server.nick);
|
||||
|
||||
config_init_server ();
|
||||
server_destroy (&cfg_server);
|
||||
server_init (&cfg_server);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -601,7 +586,7 @@ config_default_values ()
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if (i != CONFIG_SECTION_SERVER)
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
@@ -670,7 +655,7 @@ config_read ()
|
||||
}
|
||||
|
||||
config_default_values ();
|
||||
config_init_server ();
|
||||
server_init (&cfg_server);
|
||||
|
||||
/* read config file */
|
||||
section = CONFIG_SECTION_NONE;
|
||||
@@ -756,29 +741,35 @@ config_read ()
|
||||
pos2 = strchr (pos, '\n');
|
||||
if (pos2 != NULL)
|
||||
pos2[0] = '\0';
|
||||
option_number = -1;
|
||||
for (i = 0;
|
||||
weechat_options[section][i].option_name; i++)
|
||||
|
||||
if (section == CONFIG_SECTION_ALIAS)
|
||||
{
|
||||
if (strcmp
|
||||
(weechat_options[section][i].option_name,
|
||||
ptr_line) == 0)
|
||||
{
|
||||
option_number = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (option_number < 0)
|
||||
{
|
||||
gui_printf (NULL,
|
||||
_("%s %s, line %d: invalid option \"%s\"\n"),
|
||||
WEECHAT_WARNING, filename, line_number, ptr_line);
|
||||
fclose (file);
|
||||
free (filename);
|
||||
return -2;
|
||||
if (alias_new (line, pos))
|
||||
index_command_new (pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
option_number = -1;
|
||||
for (i = 0;
|
||||
weechat_options[section][i].option_name; i++)
|
||||
{
|
||||
if (strcmp
|
||||
(weechat_options[section][i].option_name,
|
||||
ptr_line) == 0)
|
||||
{
|
||||
option_number = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (option_number < 0)
|
||||
{
|
||||
gui_printf (NULL,
|
||||
_("%s %s, line %d: invalid option \"%s\"\n"),
|
||||
WEECHAT_WARNING, filename, line_number, ptr_line);
|
||||
fclose (file);
|
||||
free (filename);
|
||||
return -2;
|
||||
}
|
||||
switch (weechat_options[section]
|
||||
[option_number].option_type)
|
||||
{
|
||||
@@ -920,6 +911,8 @@ config_read ()
|
||||
|
||||
/*
|
||||
* config_create_default: create default WeeChat config
|
||||
* return: 0 if ok
|
||||
* < 0 if error
|
||||
*/
|
||||
|
||||
int
|
||||
@@ -936,24 +929,25 @@ config_create_default ()
|
||||
sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME"));
|
||||
if ((file = fopen (filename, "wt")) == NULL)
|
||||
{
|
||||
free (filename);
|
||||
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
|
||||
WEECHAT_ERROR, filename);
|
||||
free (filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf (_(WEECHAT_NAME ": creating default config file...\n"));
|
||||
printf (_("%s: creating default config file...\n"), WEECHAT_NAME);
|
||||
log_printf (_("creating default config file\n"));
|
||||
|
||||
current_time = time (NULL);
|
||||
sprintf (line, _("#\n# " WEECHAT_NAME " configuration file, generated by "
|
||||
WEECHAT_NAME " " WEECHAT_VERSION " on %s"), ctime (¤t_time));
|
||||
sprintf (line, _("#\n# %s configuration file, created by "
|
||||
"%s v%s on %s#\n"),
|
||||
WEECHAT_NAME, WEECHAT_NAME, WEECHAT_VERSION,
|
||||
ctime (¤t_time));
|
||||
fputs (line, file);
|
||||
fputs (_("# This file may be edited by user. Invalid syntax will prevent "
|
||||
WEECHAT_NAME " from running!\n#\n"), file);
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if (i != CONFIG_SECTION_SERVER)
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
sprintf (line, "\n[%s]\n", config_sections[i].section_name);
|
||||
fputs (line, file);
|
||||
@@ -969,33 +963,62 @@ config_create_default ()
|
||||
{
|
||||
switch (weechat_options[i][j].option_type)
|
||||
{
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].
|
||||
default_int) ? "on" : "off");
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
sprintf (line, "%s=%d\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_int);
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
case OPTION_TYPE_COLOR:
|
||||
case OPTION_TYPE_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].default_int) ?
|
||||
"on" : "off");
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
sprintf (line, "%s=%d\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_int);
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
case OPTION_TYPE_COLOR:
|
||||
case OPTION_TYPE_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
}
|
||||
fputs (line, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* default aliases */
|
||||
/* TODO: remove comments when missing commands will be ok */
|
||||
fputs ("\n[alias]\n", file);
|
||||
fputs ("SAY=msg *\n", file);
|
||||
fputs ("BYE=quit\n", file);
|
||||
fputs ("EXIT=quit\n", file);
|
||||
fputs ("SIGNOFF=quit\n", file);
|
||||
fputs ("C=clear\n", file);
|
||||
fputs ("CL=clear\n", file);
|
||||
fputs ("# CHAT=dcc chat\n", file);
|
||||
fputs ("# GET=dcc get\n", file);
|
||||
fputs ("# IG=ignore\n", file);
|
||||
fputs ("J=join\n", file);
|
||||
fputs ("K=kick\n", file);
|
||||
fputs ("# KB=kickban\n", file);
|
||||
fputs ("# KN=knockout\n", file);
|
||||
fputs ("LEAVE=part\n", file);
|
||||
fputs ("M=msg\n", file);
|
||||
fputs ("# MUB=unban *\n", file);
|
||||
fputs ("N=names\n", file);
|
||||
fputs ("T=topic\n", file);
|
||||
fputs ("# UB=unban\n", file);
|
||||
fputs ("# UNIG=unignore\n", file);
|
||||
fputs ("# W=who\n", file);
|
||||
fputs ("WC=part\n", file);
|
||||
fputs ("WI=whois\n", file);
|
||||
fputs ("# WW=whowas\n", file);
|
||||
|
||||
/* default server is freenode */
|
||||
fputs ("\n[server]\n", file);
|
||||
fputs ("server_name=freenode\n", file);
|
||||
fputs ("server_autoconnect=on\n", file);
|
||||
fputs ("server_address=irc.freenode.net\n", file);
|
||||
fputs ("server_port=6667\n", file);
|
||||
fputs ("server_password=\n", file);
|
||||
@@ -1004,6 +1027,8 @@ config_create_default ()
|
||||
fputs ("server_nick3=weechat3\n", file);
|
||||
fputs ("server_username=weechat\n", file);
|
||||
fputs ("server_realname=WeeChat default realname\n", file);
|
||||
fputs ("server_command=\n", file);
|
||||
fputs ("server_autojoin=\n", file);
|
||||
|
||||
fclose (file);
|
||||
free (filename);
|
||||
@@ -1012,10 +1037,153 @@ config_create_default ()
|
||||
|
||||
/*
|
||||
* config_write: write WeeChat configurtion
|
||||
* return: 0 if ok
|
||||
* < 0 if error
|
||||
*/
|
||||
|
||||
void
|
||||
config_write ()
|
||||
int
|
||||
config_write (char *config_name)
|
||||
{
|
||||
/* TODO: write "config_write" function! */
|
||||
char *filename;
|
||||
char line[1024];
|
||||
FILE *file;
|
||||
int i, j;
|
||||
time_t current_time;
|
||||
t_irc_server *ptr_server;
|
||||
t_weechat_alias *ptr_alias;
|
||||
|
||||
if (config_name)
|
||||
filename = strdup (config_name);
|
||||
else
|
||||
{
|
||||
filename =
|
||||
(char *) malloc ((strlen (getenv ("HOME")) + 64) * sizeof (char));
|
||||
sprintf (filename, "%s/.weechat/" WEECHAT_CONFIG_NAME, getenv ("HOME"));
|
||||
}
|
||||
|
||||
if ((file = fopen (filename, "wt")) == NULL)
|
||||
{
|
||||
gui_printf (NULL, _("%s cannot create file \"%s\"\n"),
|
||||
WEECHAT_ERROR, filename);
|
||||
free (filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
log_printf (_("saving config to disk\n"));
|
||||
|
||||
current_time = time (NULL);
|
||||
sprintf (line, _("#\n# %s configuration file, created by "
|
||||
"%s v%s on %s#\n"),
|
||||
WEECHAT_NAME, WEECHAT_NAME, WEECHAT_VERSION,
|
||||
ctime (¤t_time));
|
||||
fputs (line, file);
|
||||
|
||||
for (i = 0; i < CONFIG_NUMBER_SECTIONS; i++)
|
||||
{
|
||||
if ((i != CONFIG_SECTION_ALIAS) && (i != CONFIG_SECTION_SERVER))
|
||||
{
|
||||
sprintf (line, "\n[%s]\n", config_sections[i].section_name);
|
||||
fputs (line, file);
|
||||
if ((i == CONFIG_SECTION_HISTORY) || (i == CONFIG_SECTION_LOG) ||
|
||||
(i == CONFIG_SECTION_DCC) || (i == CONFIG_SECTION_PROXY))
|
||||
{
|
||||
sprintf (line,
|
||||
"# WARNING!!! Options for section \"%s\" are not developed!\n",
|
||||
config_sections[i].section_name);
|
||||
fputs (line, file);
|
||||
}
|
||||
for (j = 0; weechat_options[i][j].option_name; j++)
|
||||
{
|
||||
switch (weechat_options[i][j].option_type)
|
||||
{
|
||||
case OPTION_TYPE_BOOLEAN:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int &&
|
||||
*weechat_options[i][j].ptr_int) ?
|
||||
"on" : "off");
|
||||
break;
|
||||
case OPTION_TYPE_INT:
|
||||
sprintf (line, "%s=%d\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
*weechat_options[i][j].ptr_int :
|
||||
weechat_options[i][j].default_int);
|
||||
break;
|
||||
case OPTION_TYPE_INT_WITH_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
weechat_options[i][j].array_values[*weechat_options[i][j].ptr_int] :
|
||||
weechat_options[i][j].array_values[weechat_options[i][j].default_int]);
|
||||
break;
|
||||
case OPTION_TYPE_COLOR:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_int) ?
|
||||
gui_get_color_by_value (*weechat_options[i][j].ptr_int) :
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
case OPTION_TYPE_STRING:
|
||||
sprintf (line, "%s=%s\n",
|
||||
weechat_options[i][j].option_name,
|
||||
(weechat_options[i][j].ptr_string) ?
|
||||
*weechat_options[i][j].ptr_string :
|
||||
weechat_options[i][j].default_string);
|
||||
break;
|
||||
}
|
||||
fputs (line, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* alias section */
|
||||
fputs ("\n[alias]\n", file);
|
||||
for (ptr_alias = weechat_alias; ptr_alias;
|
||||
ptr_alias = ptr_alias->next_alias)
|
||||
{
|
||||
sprintf (line, "%s=%s\n",
|
||||
ptr_alias->alias_name, ptr_alias->alias_command + 1);
|
||||
fputs (line, file);
|
||||
}
|
||||
|
||||
/* server section */
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
/* default server is freenode */
|
||||
fputs ("\n[server]\n", file);
|
||||
sprintf (line, "server_name=%s\n", ptr_server->name);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_autoconnect=%s\n",
|
||||
(ptr_server->autoconnect) ? "on" : "off");
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_address=%s\n", ptr_server->address);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_port=%d\n", ptr_server->port);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_password=%s\n",
|
||||
(ptr_server->password) ? ptr_server->password : "");
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_nick1=%s\n", ptr_server->nick1);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_nick2=%s\n", ptr_server->nick2);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_nick3=%s\n", ptr_server->nick3);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_username=%s\n", ptr_server->username);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_realname=%s\n", ptr_server->realname);
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_command=%s\n",
|
||||
(ptr_server->command) ? ptr_server->command : "");
|
||||
fputs (line, file);
|
||||
sprintf (line, "server_autojoin=%s\n",
|
||||
(ptr_server->autojoin) ? ptr_server->autojoin : "");
|
||||
fputs (line, file);
|
||||
}
|
||||
|
||||
fclose (file);
|
||||
free (filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -32,8 +32,9 @@
|
||||
#define CONFIG_SECTION_LOG 3
|
||||
#define CONFIG_SECTION_DCC 4
|
||||
#define CONFIG_SECTION_PROXY 5
|
||||
#define CONFIG_SECTION_SERVER 6
|
||||
#define CONFIG_NUMBER_SECTIONS 7
|
||||
#define CONFIG_SECTION_ALIAS 6
|
||||
#define CONFIG_SECTION_SERVER 7
|
||||
#define CONFIG_NUMBER_SECTIONS 8
|
||||
|
||||
#define OPTION_TYPE_BOOLEAN 1 /* values: on/off */
|
||||
#define OPTION_TYPE_INT 2 /* values: from min to max */
|
||||
@@ -74,6 +75,7 @@ struct t_config_option
|
||||
int (*handler_change)(int *, char **);
|
||||
};
|
||||
|
||||
extern int cfg_look_set_title;
|
||||
extern int cfg_look_startup_logo;
|
||||
extern int cfg_look_startup_version;
|
||||
extern char *cfg_look_weechat_slogan;
|
||||
@@ -150,6 +152,6 @@ extern t_config_option * weechat_options [CONFIG_NUMBER_SECTIONS];
|
||||
|
||||
extern int config_read ();
|
||||
extern int config_create_default ();
|
||||
extern void config_write ();
|
||||
extern int config_write ();
|
||||
|
||||
#endif /* config.h */
|
||||
|
||||
@@ -611,7 +611,8 @@ gui_draw_window_nick (t_gui_window *window)
|
||||
if (CHANNEL(window) && CHANNEL(window)->nicks)
|
||||
{
|
||||
max_length = nick_get_max_length (CHANNEL(window));
|
||||
if ((max_length + 2) != window->win_nick_width)
|
||||
if ((window == gui_current_window) &&
|
||||
((max_length + 2) != window->win_nick_width))
|
||||
{
|
||||
gui_calculate_pos_size (window);
|
||||
delwin (window->win_chat);
|
||||
@@ -624,7 +625,6 @@ gui_draw_window_nick (t_gui_window *window)
|
||||
window->win_nick_width,
|
||||
window->win_nick_y,
|
||||
window->win_nick_x);
|
||||
//scrollok (window->win_chat, TRUE);
|
||||
gui_redraw_window_chat (window);
|
||||
}
|
||||
sprintf (format, "%%-%ds", max_length);
|
||||
@@ -752,6 +752,7 @@ void
|
||||
gui_draw_window_status (t_gui_window *window)
|
||||
{
|
||||
t_gui_window *ptr_win;
|
||||
char format_more[32];
|
||||
|
||||
/* TODO: manage splitted windows! */
|
||||
if (window != gui_current_window)
|
||||
@@ -853,9 +854,12 @@ gui_draw_window_status (t_gui_window *window)
|
||||
/* display "*MORE*" if last line is not displayed */
|
||||
gui_window_set_color (window->win_status, COLOR_WIN_STATUS_MORE);
|
||||
if (window->sub_lines > 0)
|
||||
mvwprintw (window->win_status, 0, COLS - 7, "-MORE-");
|
||||
mvwprintw (window->win_status, 0, COLS - 7, _("-MORE-"));
|
||||
else
|
||||
mvwprintw (window->win_status, 0, COLS - 7, " ");
|
||||
{
|
||||
sprintf (format_more, "%%-%ds", strlen (_("-MORE")));
|
||||
mvwprintw (window->win_status, 0, COLS - 7, format_more, " ");
|
||||
}
|
||||
|
||||
wrefresh (window->win_status);
|
||||
refresh ();
|
||||
@@ -958,17 +962,34 @@ gui_draw_window_input (t_gui_window *window)
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (format, "%%s> %%-%ds", input_width);
|
||||
if (SERVER(window) && (SERVER(window)->is_connected))
|
||||
ptr_nickname = SERVER(window)->nick;
|
||||
if (SERVER(window))
|
||||
{
|
||||
sprintf (format, "%%s> %%-%ds", input_width);
|
||||
if (SERVER(window) && (SERVER(window)->is_connected))
|
||||
ptr_nickname = SERVER(window)->nick;
|
||||
else
|
||||
ptr_nickname = cfg_look_no_nickname;
|
||||
mvwprintw (window->win_input, 0, 0, format,
|
||||
ptr_nickname,
|
||||
window->input_buffer + window->input_buffer_1st_display);
|
||||
wclrtoeol (window->win_input);
|
||||
move (LINES - 1, strlen (ptr_nickname) + 2 +
|
||||
(window->input_buffer_pos - window->input_buffer_1st_display));
|
||||
}
|
||||
else
|
||||
ptr_nickname = cfg_look_no_nickname;
|
||||
mvwprintw (window->win_input, 0, 0, format,
|
||||
ptr_nickname,
|
||||
window->input_buffer + window->input_buffer_1st_display);
|
||||
wclrtoeol (window->win_input);
|
||||
move (LINES - 1, strlen (ptr_nickname) + 2 +
|
||||
(window->input_buffer_pos - window->input_buffer_1st_display));
|
||||
{
|
||||
sprintf (format, "%%s> %%-%ds", input_width);
|
||||
if (SERVER(window) && (SERVER(window)->is_connected))
|
||||
ptr_nickname = SERVER(window)->nick;
|
||||
else
|
||||
ptr_nickname = cfg_look_no_nickname;
|
||||
mvwprintw (window->win_input, 0, 0, format,
|
||||
ptr_nickname,
|
||||
window->input_buffer + window->input_buffer_1st_display);
|
||||
wclrtoeol (window->win_input);
|
||||
move (LINES - 1, strlen (ptr_nickname) + 2 +
|
||||
(window->input_buffer_pos - window->input_buffer_1st_display));
|
||||
}
|
||||
}
|
||||
|
||||
wrefresh (window->win_input);
|
||||
@@ -1089,17 +1110,17 @@ gui_switch_to_window (t_gui_window *window)
|
||||
}
|
||||
}
|
||||
|
||||
gui_calculate_pos_size (window);
|
||||
|
||||
/* first time creation for windows */
|
||||
if (!another_window)
|
||||
{
|
||||
/* create new windows */
|
||||
gui_calculate_pos_size (window);
|
||||
window->win_title = newwin (1, COLS, 0, 0);
|
||||
window->win_chat = newwin (window->win_chat_height,
|
||||
window->win_chat_width,
|
||||
window->win_chat_y,
|
||||
window->win_chat_x);
|
||||
//scrollok (window->win_chat, TRUE);
|
||||
if (CHANNEL(window))
|
||||
window->win_nick = newwin (window->win_nick_height,
|
||||
window->win_nick_width,
|
||||
@@ -1112,34 +1133,33 @@ gui_switch_to_window (t_gui_window *window)
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_calculate_pos_size (window);
|
||||
|
||||
/* create chat & nick windows */
|
||||
if (WIN_IS_CHANNEL(window) && !(window->win_nick))
|
||||
if (WIN_IS_CHANNEL(window))
|
||||
{
|
||||
/* add nick list window */
|
||||
/* (re)create nicklist window */
|
||||
if (window->win_nick)
|
||||
delwin (window->win_nick);
|
||||
delwin (window->win_chat);
|
||||
window->win_chat = newwin (window->win_chat_height,
|
||||
window->win_chat_width,
|
||||
window->win_chat_y,
|
||||
window->win_chat_x);
|
||||
//scrollok (window->win_chat, TRUE);
|
||||
window->win_nick = newwin (window->win_nick_height,
|
||||
window->win_nick_width,
|
||||
window->win_nick_y,
|
||||
window->win_nick_x);
|
||||
}
|
||||
if (!(WIN_IS_CHANNEL(window)) && window->win_nick)
|
||||
if (!(WIN_IS_CHANNEL(window)))
|
||||
{
|
||||
/* remove nick list window */
|
||||
delwin (window->win_nick);
|
||||
if (window->win_nick)
|
||||
delwin (window->win_nick);
|
||||
window->win_nick = NULL;
|
||||
delwin (window->win_chat);
|
||||
window->win_chat = newwin (window->win_chat_height,
|
||||
window->win_chat_width,
|
||||
window->win_chat_y,
|
||||
window->win_chat_x);
|
||||
//scrollok (window->win_chat, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1229,7 +1249,21 @@ gui_window_new (void *server, void *channel
|
||||
/*int x, int y, int width, int height*/)
|
||||
{
|
||||
t_gui_window *new_window;
|
||||
|
||||
|
||||
if (gui_windows)
|
||||
{
|
||||
if (!SERVER(gui_windows))
|
||||
{
|
||||
if (server)
|
||||
((t_irc_server *)(server))->window = gui_windows;
|
||||
if (channel)
|
||||
((t_irc_channel *)(channel))->window = gui_windows;
|
||||
SERVER(gui_windows) = server;
|
||||
CHANNEL(gui_windows) = channel;
|
||||
return gui_windows;
|
||||
}
|
||||
}
|
||||
|
||||
if ((new_window = (t_gui_window *)(malloc (sizeof (t_gui_window)))))
|
||||
{
|
||||
/* assign server and channel to window */
|
||||
@@ -1290,6 +1324,7 @@ gui_window_new (void *server, void *channel
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
|
||||
return new_window;
|
||||
}
|
||||
|
||||
@@ -1302,9 +1337,13 @@ gui_window_free (t_gui_window *window)
|
||||
{
|
||||
t_gui_line *ptr_line;
|
||||
t_gui_message *ptr_message;
|
||||
int create_new;
|
||||
|
||||
create_new = (window->server || window->channel);
|
||||
|
||||
/* TODO: manage splitted windows! */
|
||||
if (window == gui_current_window)
|
||||
if ((window == gui_current_window) &&
|
||||
((window->next_window) || (window->prev_window)))
|
||||
gui_switch_to_previous_window ();
|
||||
|
||||
/* free lines and messages */
|
||||
@@ -1339,6 +1378,10 @@ gui_window_free (t_gui_window *window)
|
||||
last_gui_window = window->prev_window;
|
||||
|
||||
free (window);
|
||||
|
||||
/* always at least one window */
|
||||
if (!gui_windows && create_new)
|
||||
gui_window_new (NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1506,6 +1549,12 @@ gui_init ()
|
||||
|
||||
signal (SIGWINCH, gui_resize_term_handler);
|
||||
|
||||
#ifdef __linux__
|
||||
/* set title for term window, not for console */
|
||||
if (cfg_look_set_title && (strcmp (getenv ("TERM"), "linux") != 0))
|
||||
printf ("\e]2;" WEECHAT_NAME " " WEECHAT_VERSION "\a\e]1;" WEECHAT_NAME " " WEECHAT_VERSION "\a");
|
||||
#endif
|
||||
|
||||
gui_ready = 1;
|
||||
}
|
||||
|
||||
@@ -1534,7 +1583,7 @@ gui_end ()
|
||||
/* TODO: free input buffer, lines, messages, completion */
|
||||
}
|
||||
|
||||
/* end of ncurses output */
|
||||
/* end of curses output */
|
||||
refresh ();
|
||||
endwin ();
|
||||
}
|
||||
@@ -1594,7 +1643,7 @@ gui_new_message (t_gui_window *window)
|
||||
}
|
||||
else
|
||||
{
|
||||
log_printf ("not enough memory!\n");
|
||||
log_printf (_("not enough memory!\n"));
|
||||
return NULL;
|
||||
}
|
||||
return new_message;
|
||||
|
||||
+227
-141
@@ -29,6 +29,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include "../weechat.h"
|
||||
#include "irc.h"
|
||||
@@ -102,7 +103,8 @@ t_irc_command irc_commands[] =
|
||||
" o: operator flag\n"),
|
||||
1, MAX_ARGS, 1, NULL, irc_cmd_send_mode, irc_cmd_recv_mode },
|
||||
{ "msg", N_("send message to a nick or channel"),
|
||||
N_("receiver[,receiver] text"), N_("receiver: nick or channel (may be mask)"
|
||||
N_("receiver[,receiver] text"),
|
||||
N_("receiver: nick or channel (may be mask, '*' = current channel)"
|
||||
"\ntext: text to send"),
|
||||
1, MAX_ARGS, 1, NULL, irc_cmd_send_msg, NULL },
|
||||
{ "names", N_("list nicknames on channels"),
|
||||
@@ -122,7 +124,7 @@ t_irc_command irc_commands[] =
|
||||
N_("user/password: used to get privileges on current IRC server"),
|
||||
2, 2, 1, irc_cmd_send_oper, NULL, NULL },
|
||||
{ "part", N_("leave a channel"),
|
||||
N_("[channel[,channel]]"), N_("channel: channel name to join"),
|
||||
N_("[channel[,channel]]"), N_("channel: channel name to leave"),
|
||||
0, MAX_ARGS, 1, NULL, irc_cmd_send_part, irc_cmd_recv_part },
|
||||
{ "ping", N_("ping server"),
|
||||
N_("server1 [server2]"),
|
||||
@@ -134,7 +136,7 @@ t_irc_command irc_commands[] =
|
||||
1, 2, 1, irc_cmd_send_pong, NULL, NULL },
|
||||
{ "privmsg", N_("message received"),
|
||||
"", "",
|
||||
0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_privmsg },
|
||||
0, 0, 1, NULL, NULL, irc_cmd_recv_privmsg },
|
||||
{ "quit", N_("close all connections & quit " WEECHAT_NAME),
|
||||
N_("[quit_message]"),
|
||||
N_("quit_message: quit message (displayed to other users)"),
|
||||
@@ -143,6 +145,12 @@ t_irc_command irc_commands[] =
|
||||
N_("data"),
|
||||
N_("data: raw data to send"),
|
||||
1, MAX_ARGS, 1, NULL, irc_cmd_send_quote, NULL },
|
||||
{ "rehash", N_("tell the server to reload its config file"),
|
||||
"", "",
|
||||
0, 0, 1, NULL, irc_cmd_send_rehash, NULL },
|
||||
{ "restart", N_("tell the server to restart itself"),
|
||||
"", "",
|
||||
0, 0, 1, NULL, irc_cmd_send_restart, NULL },
|
||||
{ "topic", N_("get/set channel topic"),
|
||||
N_("[channel] [topic]"), N_("channel: channel name\ntopic: new topic for channel "
|
||||
"(if topic is \"-delete\" then topic is deleted)"),
|
||||
@@ -323,11 +331,6 @@ irc_recv_command (t_irc_server *server,
|
||||
{
|
||||
int i, cmd_found;
|
||||
|
||||
#if DEBUG >= 2
|
||||
gui_printf (server->window, "recv_irc_command: cmd=%s args=%s\n",
|
||||
command, arguments);
|
||||
#endif
|
||||
|
||||
if (command == NULL)
|
||||
return -2;
|
||||
|
||||
@@ -367,8 +370,8 @@ irc_login (t_irc_server *server)
|
||||
if (!hostname[0])
|
||||
strcpy (hostname, _("unknown"));
|
||||
gui_printf (server->window,
|
||||
_(WEECHAT_NAME ": using local hostname \"%s\"\n"),
|
||||
hostname);
|
||||
_("%s: using local hostname \"%s\"\n"),
|
||||
WEECHAT_NAME, hostname);
|
||||
server_sendf (server,
|
||||
"NICK %s\r\n"
|
||||
"USER %s %s %s :%s\r\n",
|
||||
@@ -484,8 +487,8 @@ irc_cmd_send_deop (t_irc_server *server, int argc, char **argv)
|
||||
}
|
||||
else
|
||||
gui_printf (server->window,
|
||||
_("%s \"deop\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR, "deop");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -508,8 +511,8 @@ irc_cmd_send_devoice (t_irc_server *server, int argc, char **argv)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"devoice\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR, "devoice");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -557,8 +560,8 @@ irc_cmd_send_kick (t_irc_server *server, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"kick\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR, "kick");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -600,8 +603,8 @@ irc_cmd_send_me (t_irc_server *server, char *arguments)
|
||||
if (WIN_IS_SERVER(gui_current_window))
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"me\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR, "me");
|
||||
return -1;
|
||||
}
|
||||
server_sendf (server, "PRIVMSG %s :\01ACTION %s\01\r\n",
|
||||
@@ -652,66 +655,97 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments)
|
||||
pos_comma[0] = '\0';
|
||||
pos_comma++;
|
||||
}
|
||||
if (string_is_channel (arguments))
|
||||
if (strcmp (arguments, "*") == 0)
|
||||
{
|
||||
ptr_channel = channel_search (server, arguments);
|
||||
if (ptr_channel)
|
||||
if (WIN_IS_SERVER(gui_current_window))
|
||||
{
|
||||
ptr_nick = nick_search (ptr_channel, server->nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
irc_display_nick (ptr_channel->window, ptr_nick,
|
||||
MSG_TYPE_NICK, 1, 1, 0);
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_MSG,
|
||||
COLOR_WIN_CHAT, "%s\n", pos);
|
||||
}
|
||||
else
|
||||
gui_printf (server->window,
|
||||
_("%s nick not found for \"privmsg\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
gui_printf (server->window,
|
||||
_("%s \"%s\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR, "msg *");
|
||||
return -1;
|
||||
}
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
|
||||
ptr_channel = CHANNEL(gui_current_window);
|
||||
ptr_nick = nick_search (ptr_channel, server->nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
irc_display_nick (ptr_channel->window, ptr_nick,
|
||||
MSG_TYPE_NICK, 1, 1, 0);
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_MSG,
|
||||
COLOR_WIN_CHAT, "%s\n", pos);
|
||||
}
|
||||
else
|
||||
gui_printf (server->window,
|
||||
_("%s nick not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "msg");
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n", ptr_channel->name, pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_channel = channel_search (server, arguments);
|
||||
if (!ptr_channel)
|
||||
if (string_is_channel (arguments))
|
||||
{
|
||||
ptr_channel = channel_new (server, CHAT_PRIVATE, arguments);
|
||||
ptr_channel = channel_search (server, arguments);
|
||||
if (ptr_channel)
|
||||
{
|
||||
ptr_nick = nick_search (ptr_channel, server->nick);
|
||||
if (ptr_nick)
|
||||
{
|
||||
irc_display_nick (ptr_channel->window, ptr_nick,
|
||||
MSG_TYPE_NICK, 1, 1, 0);
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_MSG,
|
||||
COLOR_WIN_CHAT, "%s\n", pos);
|
||||
}
|
||||
else
|
||||
gui_printf (server->window,
|
||||
_("%s nick not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "msg");
|
||||
}
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_channel = channel_search (server, arguments);
|
||||
if (!ptr_channel)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot create new private window \"%s\"\n"),
|
||||
WEECHAT_ERROR,
|
||||
arguments);
|
||||
return -1;
|
||||
ptr_channel = channel_new (server, CHAT_PRIVATE, arguments);
|
||||
if (!ptr_channel)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot create new private window \"%s\"\n"),
|
||||
WEECHAT_ERROR,
|
||||
arguments);
|
||||
return -1;
|
||||
}
|
||||
gui_redraw_window_title (ptr_channel->window);
|
||||
}
|
||||
gui_redraw_window_title (ptr_channel->window);
|
||||
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_CHAT_DARK, "<");
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_NICK_SELF,
|
||||
"%s", server->nick);
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_CHAT_DARK, "> ");
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_MSG,
|
||||
COLOR_WIN_CHAT, "%s\n", pos);
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
|
||||
}
|
||||
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_CHAT_DARK, "<");
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_NICK_SELF,
|
||||
"%s", server->nick);
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_NICK,
|
||||
COLOR_WIN_CHAT_DARK, "> ");
|
||||
gui_printf_color_type (ptr_channel->window,
|
||||
MSG_TYPE_MSG,
|
||||
COLOR_WIN_CHAT, "%s\n", pos);
|
||||
server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos);
|
||||
}
|
||||
arguments = pos_comma;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s wrong number of args for \"privmsg\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s wrong argument count for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "msg");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -729,8 +763,8 @@ irc_cmd_send_names (t_irc_server *server, char *arguments)
|
||||
if (!WIN_IS_CHANNEL(gui_current_window))
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"names\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR, "names");
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
@@ -783,8 +817,8 @@ irc_cmd_send_op (t_irc_server *server, int argc, char **argv)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"op\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR, "op");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -832,8 +866,8 @@ irc_cmd_send_part (t_irc_server *server, char *arguments)
|
||||
if (WIN_IS_SERVER(gui_current_window))
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"part\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR, "part");
|
||||
return -1;
|
||||
}
|
||||
channel_name = CHANNEL(gui_current_window)->name;
|
||||
@@ -845,8 +879,8 @@ irc_cmd_send_part (t_irc_server *server, char *arguments)
|
||||
if (WIN_IS_SERVER(gui_current_window))
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"part\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR, "part");
|
||||
return -1;
|
||||
}
|
||||
if (WIN_IS_PRIVATE(gui_current_window))
|
||||
@@ -928,6 +962,34 @@ irc_cmd_send_quote (t_irc_server *server, char *arguments)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_cmd_send_rehash: tell the server to reload its config file
|
||||
*/
|
||||
|
||||
int
|
||||
irc_cmd_send_rehash (t_irc_server *server, char *arguments)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) arguments;
|
||||
|
||||
server_sendf (server, "REHASH\r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_cmd_send_restart: tell the server to restart itself
|
||||
*/
|
||||
|
||||
int
|
||||
irc_cmd_send_restart (t_irc_server *server, char *arguments)
|
||||
{
|
||||
/* make gcc happy */
|
||||
(void) arguments;
|
||||
|
||||
server_sendf (server, "RESTART\r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_cmd_send_topic: get/set topic for a channel
|
||||
*/
|
||||
@@ -965,8 +1027,8 @@ irc_cmd_send_topic (t_irc_server *server, char *arguments)
|
||||
if (WIN_IS_SERVER(gui_current_window))
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"topic\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can not be executed on a server window\n"),
|
||||
WEECHAT_ERROR, "topic");
|
||||
return -1;
|
||||
}
|
||||
channel_name = CHANNEL(gui_current_window)->name;
|
||||
@@ -1004,7 +1066,7 @@ irc_cmd_send_version (t_irc_server *server, char *arguments)
|
||||
else
|
||||
{
|
||||
irc_display_prefix (server->window, PREFIX_INFO);
|
||||
gui_printf (server->window, "%s, compiled on %s %s\n",
|
||||
gui_printf (server->window, _("%s, compiled on %s %s\n"),
|
||||
WEECHAT_NAME_AND_VERSION,
|
||||
__DATE__, __TIME__);
|
||||
server_sendf (server, "VERSION\r\n");
|
||||
@@ -1031,8 +1093,8 @@ irc_cmd_send_voice (t_irc_server *server, int argc, char **argv)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"voice\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command can only be executed in a channel window\n"),
|
||||
WEECHAT_ERROR, "voice");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -1192,8 +1254,8 @@ irc_cmd_recv_kick (t_irc_server *server, char *host, char *arguments)
|
||||
if (!ptr_channel)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s channel not found for \"kick\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s channel not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "kick");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1224,8 +1286,8 @@ irc_cmd_recv_kick (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s nick not found for \"kick\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s nick not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "kick");
|
||||
return -1;
|
||||
}
|
||||
ptr_nick = nick_search (ptr_channel, pos_nick);
|
||||
@@ -1253,8 +1315,8 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *arguments)
|
||||
if (host == NULL)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"mode\" command received without host\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command received without host\n"),
|
||||
WEECHAT_ERROR, "mode");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1267,8 +1329,8 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *arguments)
|
||||
if (!pos)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"mode\" command received without channel or nickname\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command received without channel or nickname\n"),
|
||||
WEECHAT_ERROR, "mode");
|
||||
return -1;
|
||||
}
|
||||
pos[0] = '\0';
|
||||
@@ -1408,8 +1470,8 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s channel not found for \"mode\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s channel not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "mode");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1437,8 +1499,8 @@ irc_cmd_recv_nick (t_irc_server *server, char *host, char *arguments)
|
||||
if (host == NULL)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"nick\" command received without host\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command received without host\n"),
|
||||
WEECHAT_ERROR, "nick");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1519,8 +1581,8 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s nickname not found for \"notice\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s nickname not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "notice");
|
||||
return -1;
|
||||
}
|
||||
irc_display_prefix (server->window, PREFIX_SERVER);
|
||||
@@ -1531,9 +1593,9 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *arguments)
|
||||
if (pos2)
|
||||
pos2[0] = '\0';
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT, "CTCP ");
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT_CHANNEL, "VERSION");
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT, " reply from ");
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT_NICK, "%s", host);
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT_CHANNEL, "VERSION ");
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT, _("reply from"));
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT_NICK, " %s", host);
|
||||
gui_printf_color (server->window, COLOR_WIN_CHAT, ": %s\n", pos);
|
||||
}
|
||||
else
|
||||
@@ -1556,8 +1618,8 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *arguments)
|
||||
if (!host || !arguments)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"part\" command received without host or channel\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command received without host or channel\n"),
|
||||
WEECHAT_ERROR, "part");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1630,8 +1692,8 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s channel not found for \"part\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s channel not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "part");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1665,13 +1727,14 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
|
||||
char *pos, *pos2, *host2;
|
||||
t_irc_channel *ptr_channel;
|
||||
t_irc_nick *ptr_nick;
|
||||
struct utsname *buf;
|
||||
|
||||
/* no host => we can't identify sender of message! */
|
||||
if (host == NULL)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"privmsg\" command received without host\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command received without host\n"),
|
||||
WEECHAT_ERROR, "privmsg");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1727,8 +1790,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s nick not found for \"privmsg\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s nick not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "privmsg");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1736,8 +1799,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s channel not found for \"privmsg\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s channel not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "privmsg");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1759,11 +1822,27 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
|
||||
pos++;
|
||||
|
||||
if (strcmp (pos, "\01VERSION\01") == 0)
|
||||
{
|
||||
buf = (struct utsname *) malloc (sizeof (struct utsname));
|
||||
uname (buf);
|
||||
server_sendf (server,
|
||||
"NOTICE %s :\01VERSION "
|
||||
WEECHAT_NAME " v"
|
||||
WEECHAT_VERSION ", compiled on " __DATE__ "\01\r\n",
|
||||
host);
|
||||
_("NOTICE %s :%sVERSION %s v%s"
|
||||
" compiled on %s, host \"%s\" is running "
|
||||
"%s %s / %s%s"),
|
||||
host, "\01", WEECHAT_NAME, WEECHAT_VERSION, __DATE__,
|
||||
&buf->nodename, &buf->sysname,
|
||||
&buf->release, &buf->machine, "\01\r\n");
|
||||
free (buf);
|
||||
irc_display_prefix (server->window, PREFIX_INFO);
|
||||
gui_printf_color (server->window,
|
||||
COLOR_WIN_CHAT, _("Received a "));
|
||||
gui_printf_color (server->window,
|
||||
COLOR_WIN_CHAT_CHANNEL, _("CTCP VERSION "));
|
||||
gui_printf_color (server->window,
|
||||
COLOR_WIN_CHAT, _("from"));
|
||||
gui_printf_color (server->window,
|
||||
COLOR_WIN_CHAT_NICK, " %s\n", host);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* private message received */
|
||||
@@ -1803,8 +1882,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot parse \"privmsg\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s cannot parse \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "privmsg");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1826,8 +1905,8 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *arguments)
|
||||
if (host == NULL)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"quit\" command received without host\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command received without host\n"),
|
||||
WEECHAT_ERROR, "quit");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1856,11 +1935,11 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *arguments)
|
||||
gui_printf_color (ptr_channel->window,
|
||||
COLOR_WIN_CHAT_HOST, "%s", pos + 1);
|
||||
gui_printf_color (ptr_channel->window,
|
||||
COLOR_WIN_CHAT_DARK, ")");
|
||||
COLOR_WIN_CHAT_DARK, ") ");
|
||||
gui_printf_color (ptr_channel->window,
|
||||
COLOR_WIN_CHAT, _(" has quit "));
|
||||
COLOR_WIN_CHAT, _("has quit"));
|
||||
gui_printf_color (ptr_channel->window,
|
||||
COLOR_WIN_CHAT_DARK, "(");
|
||||
COLOR_WIN_CHAT_DARK, " (");
|
||||
gui_printf_color (ptr_channel->window,
|
||||
COLOR_WIN_CHAT, "%s",
|
||||
arguments);
|
||||
@@ -1975,11 +2054,11 @@ irc_cmd_recv_topic (t_irc_server *server, char *host, char *arguments)
|
||||
if (pos)
|
||||
pos[0] = '\0';
|
||||
|
||||
if (string_is_channel (arguments))
|
||||
if (!string_is_channel (arguments))
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s \"topic\" command received without channel\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s \"%s\" command received without channel\n"),
|
||||
WEECHAT_ERROR, "topic");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2038,7 +2117,7 @@ irc_cmd_recv_topic (t_irc_server *server, char *host, char *arguments)
|
||||
}
|
||||
|
||||
/*
|
||||
* irc_cmd_recv_004: '004' command (connected to irc server ?????)
|
||||
* irc_cmd_recv_004: '004' command (connected to irc server)
|
||||
*/
|
||||
|
||||
int
|
||||
@@ -2054,6 +2133,15 @@ irc_cmd_recv_004 (t_irc_server *server, char *host, char *arguments)
|
||||
server->is_connected = 1;
|
||||
gui_redraw_window_status (server->window);
|
||||
gui_redraw_window_input (server->window);
|
||||
|
||||
/* execute command once connected */
|
||||
if (server->command && server->command[0])
|
||||
user_command(server, server->command);
|
||||
|
||||
/* autojoin */
|
||||
if (server->autojoin && server->autojoin[0])
|
||||
return irc_cmd_send_join (server, server->autojoin);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2673,8 +2761,8 @@ irc_cmd_recv_332 (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s channel not found for \"332\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s channel not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "332");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -2682,8 +2770,8 @@ irc_cmd_recv_332 (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot identify channel for \"332\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s cannot identify channel for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "332");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -2738,32 +2826,32 @@ irc_cmd_recv_333 (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s channel not found for \"333\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s channel not found for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "333");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot identify date/time for \"333\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s cannot identify date/time for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "333");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot identify nickname for \"333\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s cannot identify nickname for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "333");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot identify channel for \"333\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s cannot identify channel for \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "333");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -2838,8 +2926,8 @@ irc_cmd_recv_353 (t_irc_server *server, char *host, char *arguments)
|
||||
if (pos[0] != ':')
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot parse \"353\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s cannot parse \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "353");
|
||||
return -1;
|
||||
}
|
||||
pos++;
|
||||
@@ -2878,8 +2966,8 @@ irc_cmd_recv_353 (t_irc_server *server, char *host, char *arguments)
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_("%s cannot parse \"353\" command\n"),
|
||||
WEECHAT_ERROR);
|
||||
_("%s cannot parse \"%s\" command\n"),
|
||||
WEECHAT_ERROR, "353");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -3020,10 +3108,9 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments)
|
||||
if (strcmp (server->nick, server->nick1) == 0)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_(WEECHAT_NAME
|
||||
": nickname \"%s\" is already in use, "
|
||||
_("%s: nickname \"%s\" is already in use, "
|
||||
"trying 2nd nickname \"%s\"\n"),
|
||||
server->nick, server->nick2);
|
||||
WEECHAT_NAME, server->nick, server->nick2);
|
||||
free (server->nick);
|
||||
server->nick = strdup (server->nick2);
|
||||
}
|
||||
@@ -3032,19 +3119,18 @@ irc_cmd_recv_433 (t_irc_server *server, char *host, char *arguments)
|
||||
if (strcmp (server->nick, server->nick2) == 0)
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_(WEECHAT_NAME
|
||||
": nickname \"%s\" is already in use, "
|
||||
_("%s: nickname \"%s\" is already in use, "
|
||||
"trying 3rd nickname \"%s\"\n"),
|
||||
server->nick, server->nick3);
|
||||
WEECHAT_NAME, server->nick, server->nick3);
|
||||
free (server->nick);
|
||||
server->nick = strdup (server->nick3);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_printf (server->window,
|
||||
_(WEECHAT_NAME
|
||||
": all declared nicknames are already in use, "
|
||||
"closing connection with server!\n"));
|
||||
_("%s: all declared nicknames are already in use, "
|
||||
"closing connection with server!\n"),
|
||||
WEECHAT_NAME);
|
||||
server_disconnect (server);
|
||||
return 0;
|
||||
}
|
||||
|
||||
+116
-65
@@ -49,6 +49,36 @@ t_irc_message *recv_msgq, *msgq_last_msg;
|
||||
char *unterminated_message = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* server_init: init server struct with default values
|
||||
*/
|
||||
|
||||
void
|
||||
server_init (t_irc_server *server)
|
||||
{
|
||||
server->name = NULL;
|
||||
server->autoconnect = 0;
|
||||
server->address = NULL;
|
||||
server->port = -1;
|
||||
server->password = NULL;
|
||||
server->nick1 = NULL;
|
||||
server->nick2 = NULL;
|
||||
server->nick3 = NULL;
|
||||
server->username = NULL;
|
||||
server->realname = NULL;
|
||||
server->command = NULL;
|
||||
server->autojoin = NULL;
|
||||
server->nick = NULL;
|
||||
server->is_connected = 0;
|
||||
server->sock4 = -1;
|
||||
server->is_away = 0;
|
||||
server->server_read = -1;
|
||||
server->server_write = -1;
|
||||
server->window = NULL;
|
||||
server->channels = NULL;
|
||||
server->last_channel = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* server_alloc: allocate a new server and add it to the servers queue
|
||||
*/
|
||||
@@ -65,28 +95,12 @@ server_alloc ()
|
||||
/* alloc memory for new server */
|
||||
if ((new_server = (t_irc_server *) malloc (sizeof (t_irc_server))) == NULL)
|
||||
{
|
||||
fprintf (stderr, _("%s cannot allocate new server"), WEECHAT_ERROR);
|
||||
fprintf (stderr, _("%s cannot allocate new server\n"), WEECHAT_ERROR);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* initialize new server */
|
||||
new_server->name = NULL;
|
||||
new_server->address = NULL;
|
||||
new_server->password = NULL;
|
||||
new_server->nick1 = NULL;
|
||||
new_server->nick2 = NULL;
|
||||
new_server->nick3 = NULL;
|
||||
new_server->username = NULL;
|
||||
new_server->realname = NULL;
|
||||
new_server->nick = NULL;
|
||||
new_server->is_connected = 0;
|
||||
new_server->sock4 = -1;
|
||||
new_server->is_away = 0;
|
||||
new_server->server_read = -1;
|
||||
new_server->server_write = -1;
|
||||
new_server->window = NULL;
|
||||
new_server->channels = NULL;
|
||||
new_server->last_channel = NULL;
|
||||
server_init (new_server);
|
||||
|
||||
/* add new server to queue */
|
||||
new_server->prev_server = last_irc_server;
|
||||
@@ -102,42 +116,12 @@ server_alloc ()
|
||||
}
|
||||
|
||||
/*
|
||||
* server_create_window: create windows for a server
|
||||
* server_destroy: free server data (not struct himself)
|
||||
*/
|
||||
|
||||
void
|
||||
server_create_window (t_irc_server *server)
|
||||
server_destroy (t_irc_server *server)
|
||||
{
|
||||
if (!SERVER(gui_windows))
|
||||
{
|
||||
server->window = gui_windows;
|
||||
SERVER(gui_windows) = server;
|
||||
}
|
||||
else
|
||||
gui_window_new (server, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* server_free: free a server and remove it from servers queue
|
||||
*/
|
||||
|
||||
void
|
||||
server_free (t_irc_server *server)
|
||||
{
|
||||
t_irc_server *new_irc_servers;
|
||||
|
||||
/* remove server from queue */
|
||||
if (server->prev_server)
|
||||
{
|
||||
(server->prev_server)->next_server = server->next_server;
|
||||
new_irc_servers = irc_servers;
|
||||
}
|
||||
else
|
||||
new_irc_servers = server->next_server;
|
||||
|
||||
if (server->next_server)
|
||||
(server->next_server)->prev_server = server->prev_server;
|
||||
|
||||
/* free data */
|
||||
if (server->name)
|
||||
free (server->name);
|
||||
@@ -155,12 +139,42 @@ server_free (t_irc_server *server)
|
||||
free (server->username);
|
||||
if (server->realname)
|
||||
free (server->realname);
|
||||
if (server->command)
|
||||
free (server->command);
|
||||
if (server->autojoin)
|
||||
free (server->autojoin);
|
||||
if (server->nick)
|
||||
free (server->nick);
|
||||
if (server->channels)
|
||||
channel_free_all (server);
|
||||
/* TODO: free weechat window (???) */
|
||||
/* (...) */
|
||||
}
|
||||
|
||||
/*
|
||||
* server_free: free a server and remove it from servers queue
|
||||
*/
|
||||
|
||||
void
|
||||
server_free (t_irc_server *server)
|
||||
{
|
||||
t_irc_server *new_irc_servers;
|
||||
|
||||
/* remove server from queue */
|
||||
if (last_irc_server == server)
|
||||
last_irc_server = server->prev_server;
|
||||
if (server->prev_server)
|
||||
{
|
||||
(server->prev_server)->next_server = server->next_server;
|
||||
new_irc_servers = irc_servers;
|
||||
}
|
||||
else
|
||||
new_irc_servers = server->next_server;
|
||||
|
||||
if (server->next_server)
|
||||
(server->next_server)->prev_server = server->prev_server;
|
||||
|
||||
server_destroy (server);
|
||||
if (server->window)
|
||||
gui_window_free (server->window);
|
||||
free (server);
|
||||
irc_servers = new_irc_servers;
|
||||
}
|
||||
@@ -182,26 +196,29 @@ server_free_all ()
|
||||
*/
|
||||
|
||||
t_irc_server *
|
||||
server_new (char *name, char *address, int port, char *password,
|
||||
char *nick1, char *nick2, char *nick3,
|
||||
char *username, char *realname)
|
||||
server_new (char *name, int autoconnect, char *address, int port,
|
||||
char *password, char *nick1, char *nick2, char *nick3,
|
||||
char *username, char *realname, char *command, char *autojoin)
|
||||
{
|
||||
t_irc_server *new_server;
|
||||
|
||||
if (!name || !address || (port < 0) || !nick1 || !nick2 || !nick3
|
||||
|| !username || !realname)
|
||||
if (!name || !address || (port < 0))
|
||||
return NULL;
|
||||
|
||||
#if DEBUG >= 1
|
||||
log_printf ("creating new server (name:%s, address:%s, port:%d, pwd:%s, "
|
||||
"nick1:%s, nick2:%s, nick3:%s, username:%s, realname:%s)\n",
|
||||
name, address, port, password, nick1, nick2, nick3,
|
||||
username, realname);
|
||||
"nick1:%s, nick2:%s, nick3:%s, username:%s, realname:%s, "
|
||||
"command:%s, autojoin:%s)\n",
|
||||
name, address, port, (password) ? password : "",
|
||||
(nick1) ? nick1 : "", (nick2) ? nick2 : "", (nick3) ? nick3 : "",
|
||||
(username) ? username : "", (realname) ? realname : "",
|
||||
(command) ? command : "", (autojoin) ? autojoin : "");
|
||||
#endif
|
||||
|
||||
if ((new_server = server_alloc ()))
|
||||
{
|
||||
new_server->name = strdup (name);
|
||||
new_server->autoconnect = autoconnect;
|
||||
new_server->address = strdup (address);
|
||||
new_server->port = port;
|
||||
new_server->password = (password) ? strdup (password) : strdup ("");
|
||||
@@ -212,6 +229,10 @@ server_new (char *name, char *address, int port, char *password,
|
||||
(username) ? strdup (username) : strdup ("weechat");
|
||||
new_server->realname =
|
||||
(realname) ? strdup (realname) : strdup ("realname");
|
||||
new_server->command =
|
||||
(command) ? strdup (command) : NULL;
|
||||
new_server->autojoin =
|
||||
(autojoin) ? strdup (autojoin) : NULL;
|
||||
new_server->nick = strdup (new_server->nick1);
|
||||
}
|
||||
else
|
||||
@@ -458,9 +479,9 @@ server_connect (t_irc_server *server)
|
||||
int server_pipe[2];
|
||||
|
||||
gui_printf (server->window,
|
||||
_(WEECHAT_NAME ": connecting to %s:%d...\n"),
|
||||
server->address, server->port);
|
||||
log_printf ("connecting to server %s:%d...\n",
|
||||
_("%s: connecting to %s:%d...\n"),
|
||||
WEECHAT_NAME, server->address, server->port);
|
||||
log_printf (_("connecting to server %s:%d...\n"),
|
||||
server->address, server->port);
|
||||
server->is_connected = 0;
|
||||
|
||||
@@ -482,7 +503,7 @@ server_connect (t_irc_server *server)
|
||||
(server->sock4, SOL_SOCKET, SO_REUSEADDR, (char *) &set,
|
||||
sizeof (set)) == -1)
|
||||
gui_printf (server->window,
|
||||
_("%s cannot set socket option 'SO_REUSEADDR'\n"),
|
||||
_("%s cannot set socket option \"SO_REUSEADDR\"\n"),
|
||||
WEECHAT_ERROR);
|
||||
set = 1;
|
||||
if (setsockopt
|
||||
@@ -530,7 +551,7 @@ server_connect (t_irc_server *server)
|
||||
|
||||
/* connection to server */
|
||||
gui_printf (server->window,
|
||||
_(WEECHAT_NAME ": server IP is: %s\n"), ip_address);
|
||||
_("%s: server IP is: %s\n"), WEECHAT_NAME, ip_address);
|
||||
|
||||
error = connect (server->sock4, (struct sockaddr *) &addr, sizeof (addr));
|
||||
if (error != 0)
|
||||
@@ -555,12 +576,24 @@ server_connect (t_irc_server *server)
|
||||
void
|
||||
server_disconnect (t_irc_server *server)
|
||||
{
|
||||
t_irc_channel *ptr_channel;
|
||||
|
||||
if (server->is_connected)
|
||||
{
|
||||
/* write disconnection message on each channel/private window */
|
||||
for (ptr_channel = server->channels; ptr_channel;
|
||||
ptr_channel = ptr_channel->next_channel)
|
||||
{
|
||||
irc_display_prefix (ptr_channel->window, PREFIX_INFO);
|
||||
gui_printf (ptr_channel->window, _("Disconnected from server!\n"));
|
||||
}
|
||||
|
||||
/* close communication with server */
|
||||
close (server->server_read);
|
||||
close (server->server_write);
|
||||
close (server->sock4);
|
||||
server->is_connected = 0;
|
||||
server->sock4 = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,6 +610,24 @@ server_disconnect_all ()
|
||||
server_disconnect (ptr_server);
|
||||
}
|
||||
|
||||
/*
|
||||
* server_search: return pointer on a server with a name
|
||||
*/
|
||||
|
||||
t_irc_server *
|
||||
server_search (char *servername)
|
||||
{
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
if (strcmp (ptr_server->name, servername) == 0)
|
||||
return ptr_server;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* server_get_number_connected: returns number of connected server
|
||||
*/
|
||||
|
||||
+10
-3
@@ -78,6 +78,7 @@ struct t_irc_server
|
||||
{
|
||||
/* user choices */
|
||||
char *name; /* name of server (only for display) */
|
||||
int autoconnect; /* = 1 if auto connect at startup */
|
||||
char *address; /* address of server (IP or name) */
|
||||
int port; /* port for server (6667 by default) */
|
||||
char *password; /* password for server */
|
||||
@@ -86,6 +87,8 @@ struct t_irc_server
|
||||
char *nick3; /* 2nd alternate nickname */
|
||||
char *username; /* user name */
|
||||
char *realname; /* real name */
|
||||
char *command; /* command to run once connected */
|
||||
char *autojoin; /* channels to automatically join */
|
||||
|
||||
/* internal vars */
|
||||
char *nick; /* current nickname */
|
||||
@@ -137,18 +140,20 @@ extern t_irc_channel *current_channel;
|
||||
|
||||
/* server functions (irc-server.c) */
|
||||
|
||||
extern void server_init (t_irc_server *);
|
||||
extern t_irc_server *server_alloc ();
|
||||
extern void server_create_window (t_irc_server *);
|
||||
extern void server_destroy (t_irc_server *);
|
||||
extern void server_free (t_irc_server *);
|
||||
extern void server_free_all ();
|
||||
extern t_irc_server *server_new (char *, char *, int, char *, char *, char *,
|
||||
char *, char *, char *);
|
||||
extern t_irc_server *server_new (char *, int, char *, int, char *, char *,
|
||||
char *, char *, char *, char *, char *, char *);
|
||||
extern int server_send (t_irc_server *, char *, int);
|
||||
extern int server_sendf (t_irc_server *, char *, ...);
|
||||
extern void server_recv (t_irc_server *);
|
||||
extern int server_connect ();
|
||||
extern void server_disconnect (t_irc_server *);
|
||||
extern void server_disconnect_all ();
|
||||
extern t_irc_server *server_search (char *);
|
||||
extern int server_get_number_connected ();
|
||||
extern int server_name_already_exists (char *);
|
||||
|
||||
@@ -205,6 +210,8 @@ extern int irc_cmd_send_ping (t_irc_server *, int, char **);
|
||||
extern int irc_cmd_send_pong (t_irc_server *, int, char **);
|
||||
extern int irc_cmd_send_quit (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_quote (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_rehash (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_restart (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_topic (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_version (t_irc_server *, char *);
|
||||
extern int irc_cmd_send_voice (t_irc_server *, int, char **);
|
||||
|
||||
+18
-8
@@ -211,8 +211,8 @@ wee_init_log ()
|
||||
void
|
||||
wee_shutdown ()
|
||||
{
|
||||
gui_end ();
|
||||
server_free_all ();
|
||||
gui_end ();
|
||||
if (log_file)
|
||||
fclose (log_file);
|
||||
exit (0);
|
||||
@@ -227,6 +227,10 @@ main (int argc, char *argv[])
|
||||
{
|
||||
t_irc_server *ptr_server;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, "/usr/share/locale");
|
||||
textdomain (PACKAGE);
|
||||
|
||||
/* initialize variables */
|
||||
wee_init_vars ();
|
||||
|
||||
@@ -239,6 +243,9 @@ main (int argc, char *argv[])
|
||||
/* init log file */
|
||||
wee_init_log ();
|
||||
|
||||
/* build commands index (sorted), for completion */
|
||||
index_command_build ();
|
||||
|
||||
/* read configuration */
|
||||
switch (config_read ())
|
||||
{
|
||||
@@ -256,9 +263,6 @@ main (int argc, char *argv[])
|
||||
/* init gui */
|
||||
gui_init ();
|
||||
|
||||
/* build commands index (sorted), for completion */
|
||||
index_command_build ();
|
||||
|
||||
/* Welcome message - yeah! */
|
||||
if (cfg_look_startup_logo)
|
||||
{
|
||||
@@ -292,17 +296,23 @@ main (int argc, char *argv[])
|
||||
gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX1,
|
||||
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
|
||||
|
||||
/* connect to all servers */
|
||||
/* connect to all servers (with autoconnect flag) */
|
||||
for (ptr_server = irc_servers; ptr_server;
|
||||
ptr_server = ptr_server->next_server)
|
||||
{
|
||||
server_create_window (ptr_server);
|
||||
if (server_connect (ptr_server))
|
||||
irc_login (ptr_server);
|
||||
if (ptr_server->autoconnect)
|
||||
{
|
||||
gui_window_new (ptr_server, NULL);
|
||||
if (server_connect (ptr_server))
|
||||
irc_login (ptr_server);
|
||||
}
|
||||
}
|
||||
gui_main_loop ();
|
||||
server_disconnect_all ();
|
||||
|
||||
/* save config file */
|
||||
config_write (NULL);
|
||||
|
||||
/* program ending */
|
||||
wee_shutdown ();
|
||||
|
||||
|
||||
@@ -24,13 +24,15 @@
|
||||
#define __WEECHAT_H 1
|
||||
|
||||
#include <stdio.h>
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
|
||||
#define PACKAGE "weechat"
|
||||
#define _(string) gettext(string)
|
||||
#define N_(string) (string)
|
||||
|
||||
#define WEECHAT_NAME "WeeChat"
|
||||
#define WEECHAT_VERSION "0.0.1"
|
||||
#define WEECHAT_VERSION "0.0.2"
|
||||
|
||||
#define WEECHAT_NAME_AND_VERSION WEECHAT_NAME " " WEECHAT_VERSION
|
||||
#define WEECHAT_COPYRIGHT WEECHAT_NAME " (c) 2003 by Wee Team"
|
||||
|
||||
+14
-4
@@ -1,7 +1,7 @@
|
||||
.TH WEECHAT 1 "September 2003" "FlashCode"
|
||||
.TH WEECHAT 1 "October 2003" "FlashCode"
|
||||
|
||||
.SH NAME
|
||||
weechat \- wee enhanced environment for chat
|
||||
weechat \- Wee Enhanced Environment for Chat
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B weechat
|
||||
@@ -9,8 +9,11 @@ weechat \- wee enhanced environment for chat
|
||||
.br
|
||||
|
||||
.SH DESCRIPTION
|
||||
Fast, light and extensible IRC client for many operating systems. Everything can be
|
||||
done with a keyboard. It is customizable and extensible with scripts.
|
||||
Fast, light and extensible IRC client for many operating systems.
|
||||
.br
|
||||
Everything can be done with a keyboard. It is customizable and extensible with scripts.
|
||||
Many GUIs are available (Curses, Gtk, Qt, and text).
|
||||
It is compliant with RFCs 1459, 2810, 2811, 2812, and 2813.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
@@ -30,6 +33,9 @@ display WeeChat version
|
||||
.TP
|
||||
.B $HOME/.weechat/weechat.rc
|
||||
configuration file for WeeChat
|
||||
.TP
|
||||
.B $HOME/.weechat/weechat.log
|
||||
WeeChat log file
|
||||
|
||||
.SH AUTHOR
|
||||
WeeChat is written by:
|
||||
@@ -41,4 +47,8 @@ WeeChat is written by:
|
||||
WeeChat on the web:
|
||||
.UR
|
||||
http://weechat.flashtux.org
|
||||
.br
|
||||
Get support there:
|
||||
.UR
|
||||
http://weechat.flashtux.org/support.php
|
||||
.UE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
%define name weechat
|
||||
%define version 0.0.1
|
||||
%define version 0.0.2
|
||||
%define release 1
|
||||
|
||||
Name: %{name}
|
||||
@@ -37,5 +37,7 @@ rm -rf $RPM_BUILD_ROOT
|
||||
/usr/local/bin/weechat
|
||||
|
||||
%changelog
|
||||
* Thu Sep 27 2003 FlashCode <flashcode@flashtux.org> 0.0.1-1
|
||||
* Sun Oct 05 2003 FlashCode <flashcode@flashtux.org> 0.0.2-1
|
||||
- Released version 0.0.2
|
||||
* Sat Sep 27 2003 FlashCode <flashcode@flashtux.org> 0.0.1-1
|
||||
- Released version 0.0.1
|
||||
|
||||
Reference in New Issue
Block a user