From: Pekka Riikonen Date: Tue, 7 May 2002 17:53:31 +0000 (+0000) Subject: Merges from Irssi CVS. X-Git-Tag: 1.2.beta1~1373 X-Git-Url: http://git.silcnet.org/gitweb/?p=crypto.git;a=commitdiff_plain;h=9601176a506c8a545a954891e5e25552e9609159 Merges from Irssi CVS. --- diff --git a/CHANGES b/CHANGES index 11aede39..1d0a8464 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +Tue May 7 20:41:58 EEST 2002 Pekka Riikonen + + * Merged with Irssi CVS for Irssi SILC client. + Tue May 7 11:07:16 EEST 2002 Pekka Riikonen * Added the founder's public key delivery to the diff --git a/apps/irssi/autogen.sh b/apps/irssi/autogen.sh index 5ad69a27..79156309 100755 --- a/apps/irssi/autogen.sh +++ b/apps/irssi/autogen.sh @@ -88,14 +88,34 @@ xlc ) am_opt=--include-deps;; esac -rm -f aclocal.m4 +rm -f aclocal.m4 glib.m4 glib-2.0.m4 if grep "^AM_PROG_LIBTOOL" configure.in >/dev/null; then echo "Running libtoolize..." libtoolize --force --copy fi aclocalinclude="$ACLOCAL_FLAGS -I ." echo "Running aclocal $aclocalinclude ..." + +# see if we don't have glib.m4 or glib-2.0.m4 there yet +error=`aclocal $aclocalinclude 2>&1` +if test "x`echo $error|grep 'AM_PATH_GLIB[^_]'`" != "x"; then + cp glib.m4_ glib.m4 + error=`aclocal $aclocalinclude 2>&1` +fi +if test "x`echo $error|grep AM_PATH_GLIB_2_0`" != "x"; then + cp glib-2.0.m4_ glib-2.0.m4 +fi + aclocal $aclocalinclude + +# aclocal for some reason doesn't complain about glib2, so we still need +# to check it later again.. +if grep "^AC_DEFUN.AM_PATH_GLIB_2_0" aclocal.m4 >/dev/null; then :; +else + cp glib-2.0.m4_ glib-2.0.m4 + aclocal $aclocalinclude +fi + if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then echo "Running autoheader..." autoheader diff --git a/apps/irssi/configure.in b/apps/irssi/configure.in index 2031de73..c039ddbe 100644 --- a/apps/irssi/configure.in +++ b/apps/irssi/configure.in @@ -110,6 +110,19 @@ if test "x$prefix" != "xNONE"; then perl_prefix_note=yes fi +AC_ARG_WITH(tests, +[ --with-glib2 Use GLIB 2.0 instead of 1.2], + if test x$withval = xyes; then + want_glib2=yes + else + if test "x$withval" = xno; then + want_glib2=no + else + want_glib2=yes + fi + fi, + want_glib2=yes) + AC_ARG_WITH(perl-staticlib, [ --with-perl-staticlib Specify that we want to link perl libraries statically in irssi, default is no], @@ -311,16 +324,36 @@ AC_DEFUN(AC_CHECK_GLIBDIR,[ AC_CHECK_GLIBDIR if test -z "$GLIB_DIR"; then - AM_PATH_GLIB(1.2.0,,, gmodule) - if test -z "$GLIB_LIBS"; then - echo "*** trying without -lgmodule" - glib_config_args= - AM_PATH_GLIB(1.2.0) + if test "x$with_glib2" = "xyes"; then + dnl * check only for glib2 + checks="3 4" else - AC_DEFINE(HAVE_GMODULE) - have_gmodule=yes + dnl * check glib1 then glib2 + checks="1 2 3 4" fi + for try in $checks; do + glib_config_args= + if test $try = 1 -o $try = 3; then + glib_modules=gmodule + else + echo "*** trying without -lgmodule" + glib_modules= + fi + if test $try = 1 -o $try = 2; then + AM_PATH_GLIB(1.2.0,,, $glib_modules) + else + AM_PATH_GLIB_2_0(2.0.0,,, $glib_modules) + fi + if test "$GLIB_LIBS"; then + if test $glib_modules = gmodule; then + AC_DEFINE(HAVE_GMODULE) + have_gmodule=yes + fi + break + fi + done + if test -z "$GLIB_LIBS"; then echo echo "*** If you don't have GLIB, you can get it from ftp://ftp.gtk.org" @@ -448,9 +481,8 @@ if test "x$want_textui" = "xyes"; then LIBS="$LIBS -ltermcap" want_termcap=yes ], [ - AC_MSG_WARN(Terminfo/termcap not found) + AC_ERROR(Terminfo/termcap not found - install ncurses-devel package) want_textui=no - curses_error=yes ]))) fi if test "x$want_termcap" = "xyes"; then @@ -535,21 +567,14 @@ if test "$want_perl" != "no"; then esac dnl * check that perl's ldflags actually work - AC_CACHE_VAL(irssi_cv_lib_perl_works, [ - echo "main(){perl_alloc(); return 0;}" > conftest.c - $CC $CFLAGS conftest.c -o conftest $LDFLAGS $PERL_LDFLAGS 2> perl.error.tmp > /dev/null - if test -s conftest; then - irssi_cv_lib_perl_works=yes - else - irssi_cv_lib_perl_works=no - fi - ]) - - if test "x$irssi_cv_lib_perl_works" = "xno"; then + echo "main(){perl_alloc(); return 0;}" > conftest.c + $CC $CFLAGS conftest.c -o conftest $LDFLAGS $PERL_LDFLAGS 2> perl.error.tmp > /dev/null + if test ! -s conftest; then perl_check_error="Error linking with perl libraries: $PERL_LDFLAGS: `cat perl.error.tmp`" AC_MSG_RESULT([error linking with perl libraries, building without Perl]) want_perl=no fi + rm -f perl.error.tmp fi @@ -798,23 +823,16 @@ fi echo -if test "x$curses_error" != "xyes"; then - if test "x$want_textui" = "xno"; then - text=no - elif test "x$want_termcap" = "xyes"; then - text="yes, using termcap" - elif test "x$want_terminfo" = "xyes"; then - text="yes, using terminfo" - else - text="yes, using curses" - fi - echo "Building text frontend ..... : $text" +if test "x$want_textui" = "xno"; then + text=no +elif test "x$want_termcap" = "xyes"; then + text="yes, using termcap" +elif test "x$want_terminfo" = "xyes"; then + text="yes, using terminfo" else - echo "Building text frontend ..... : NO!!" - echo " - Because curses was not found, specify the path to it with" - echo " --with-curses=/dir and make sure you have the curses headers" - echo " installed (usually in ncurses-devel package)" + text="yes, using curses" fi +echo "Building text frontend ..... : $text" echo "Building irssi bot ......... : $want_irssibot" echo "Building irssi proxy ....... : $want_irssiproxy" echo "Building with IPv6 support . : $want_ipv6" @@ -843,6 +861,10 @@ if test "x$want_perl" != "xno" -a "x$perl_mod_error" != "x"; then echo " - NOTE: Perl support will be compiled statically to irssi, not as" echo " a module as requested. Reason:" echo " $perl_mod_error" + + if test -f /etc/debian_version; then + echo " - Try: apt-get install libperl-dev" + fi fi if test "x$want_perl" != "xno"; then @@ -863,3 +885,5 @@ fi echo "Install prefix ............. : $prefix" +echo +echo "If there was any problems, read the INSTALL file." diff --git a/apps/irssi/default.theme b/apps/irssi/default.theme index 584856c8..121ca945 100644 --- a/apps/irssi/default.theme +++ b/apps/irssi/default.theme @@ -48,15 +48,15 @@ ############################################################################# # default foreground color (%N) - 0 is the "default terminal color" -default_color = 0; +default_color = "-1"; -# default foreground color when "0" can't be used, -# such as with bolds and reverses. white is default. -default_real_color = 7; +# print timestamp/servertag at the end of line, not at beginning +info_eol = "false"; # these characters are automatically replaced with specified color # (dark grey by default) -replaces = {}; +replaces = { "()=" = "%K$*%n"; }; +#replaces = {}; abstracts = { ## diff --git a/apps/irssi/docs/crash.txt b/apps/irssi/docs/crash.txt index d3100f57..5461b9bf 100644 --- a/apps/irssi/docs/crash.txt +++ b/apps/irssi/docs/crash.txt @@ -1,5 +1,7 @@ How to submit a good bug report? +Send them to bugs@irssi.org. + First you should give the following information: - irssi version, if CVS (or devel. tarball) then which day? - operating system / distribution and it's version diff --git a/apps/irssi/docs/formats.txt b/apps/irssi/docs/formats.txt index e98f2719..d918a268 100644 --- a/apps/irssi/docs/formats.txt +++ b/apps/irssi/docs/formats.txt @@ -3,7 +3,7 @@ text text background --------------------------------------------------------------------- - %k %K %0 black bold black black + %k %K %0 black dark grey black %r %R %1 red bold red red %g %G %2 green bold green green %y %Y %3 yellow bold yellow yellow @@ -19,6 +19,7 @@ %9 %_ Bold on/off %: Insert newline %| Marks the indentation position + %# Monospace font on/off (useful with lists and GUI) %% A single % In .theme files %n works a bit differently. See default.theme diff --git a/apps/irssi/docs/help/in/hilight.in b/apps/irssi/docs/help/in/hilight.in index a38d10c9..58d1d118 100644 --- a/apps/irssi/docs/help/in/hilight.in +++ b/apps/irssi/docs/help/in/hilight.in @@ -7,8 +7,9 @@ -nick: Hilight only the nick, not the whole line (default) -word: Hilight only the word (default with non-public messages) -line: Hilight the whole line with the hilight color. - -color: Print the message with . color is in %code format + -color: Print the message with . color is in %%code format (see docs/formats.txt) + -actcolor: Color to show in statusbar activity, or don't change if %%n. -level: Match only for messages, default is publics,msgs,notices,actions -channels: Match only in @@ -19,7 +20,7 @@ Hilight lines that have "mynick" word: /HILIGHT mynick Hilight lines that were written by nicks from *.fi with bold green - /HILIGHT -color %G -mask *!*@*.fi + /HILIGHT -color %%G -mask *!*@*.fi For regular expressions, see `man 7 regex`. diff --git a/apps/irssi/docs/help/in/levels.in b/apps/irssi/docs/help/in/levels.in index e48a79fd..b6ebed7e 100644 --- a/apps/irssi/docs/help/in/levels.in +++ b/apps/irssi/docs/help/in/levels.in @@ -11,7 +11,7 @@ list of them all: ACTIONS - Actions (/me) - usually ORed with PUBLIC or MSGS JOINS - Someone joins a channel PARTS - Someone parts a channel - QUITS - Someone quits network + QUITS - Someone quits IRC KICKS - Someone gets kicked from channel MODES - Channel mode is changed TOPICS - Channel topic is changed @@ -20,8 +20,8 @@ list of them all: NICKS - Someone changes nick DCC - DCC related messages DCCMSGS - DCC chat messages - CLIENTNOTICES - Irssi's notices - CLIENTERRORS - Irssi's error messages + CLIENTNOTICE - Irssi's notices + CLIENTERROR - Irssi's error messages CLIENTCRAP - Some other messages from Irssi And a few special ones that could be included with the diff --git a/apps/irssi/docs/manual.txt b/apps/irssi/docs/manual.txt index 2954deff..2956e18e 100644 --- a/apps/irssi/docs/manual.txt +++ b/apps/irssi/docs/manual.txt @@ -1,7 +1,7 @@ Irssi 0.8 documentation - http://irssi.org/ - Copyright(c) 2000 Timo Sirainen + Copyright(c) 2000 Timo Sirainen Index diff --git a/apps/irssi/docs/perl.txt b/apps/irssi/docs/perl.txt index 23ecfbed..59c7e57a 100644 --- a/apps/irssi/docs/perl.txt +++ b/apps/irssi/docs/perl.txt @@ -958,12 +958,6 @@ Server::channel_create(name, automatic) Channel::bans() Return a list of bans in channel. -Channel::ebans() - Return a list of ban exceptions in channel. - -Channel::invites() - Return invite list (+I) of channel. - Channel::ban_get_mask(nick) Get ban mask for `nick'. @@ -973,22 +967,6 @@ Channel::banlist_add(ban, nick, time) Channel::banlist_remove(ban) Remove a ban from channel. -Channel::banlist_exception_add(ban, nick, time) - Add a new ban exception to channel. - -Channel::banlist_exception_remove(ban) - Remove a ban exception from channel. - -Channel::invitelist_add(mask) - Add a new invite mask to channel. - -Channel::invitelist_remove(mask) - Remove invite mask from channel. - -modes_join(old, mode, channel) - Add `mode' to `old' - return newly allocated mode. If `channel' is 1, - we're parsing channel mode and we should try to join mode arguments too. - *** DCC diff --git a/apps/irssi/docs/signals.txt b/apps/irssi/docs/signals.txt index f009a4de..2bf0d921 100644 --- a/apps/irssi/docs/signals.txt +++ b/apps/irssi/docs/signals.txt @@ -70,6 +70,7 @@ queries.c: "query created", QUERY_REC, int automatic "query destroyed", QUERY_REC "query nick changed", QUERY_REC, char *orignick + "window item name changed", WI_ITEM_REC "query address changed", QUERY_REC "query server changed", QUERY_REC, SERVER_REC @@ -151,8 +152,8 @@ mode-lists.c: "ban remove", CHANNEL_REC, BAN_REC modes.c: - "channel mode changed", CHANNEL_REC - "nick mode changed", CHANNEL_REC, NICK_REC + "channel mode changed", CHANNEL_REC, char *setby + "nick mode changed", CHANNEL_REC, NICK_REC, char *setby "user mode changed", SERVER_REC, char *old "away mode changed", SERVER_REC @@ -225,7 +226,7 @@ FE common * Requires to work properly: - "gui print text", WINDOW_REC, int fg, int bg, int flags, char *text, int level + "gui print text", WINDOW_REC, int fg, int bg, int flags, char *text, TEXT_DEST_REC (Can be used to determine when all "gui print text"s are sent (not required)) "gui print text finished", WINDOW_REC @@ -304,6 +305,9 @@ fe-irc-messages.c: "message irc own_ctcp", SERVER_REC, char *cmd, char *data, char *target "message irc ctcp", SERVER_REC, char *cmd, char *data, char *nick, char *address, char *target +fe-modes.c: + "message irc mode", SERVER_REC, char *channel, char *nick, char *addr, char *mode + dcc/fe-dcc-chat-messages.c: "message dcc own", DCC_REC *dcc, char *msg "message dcc own_action", DCC_REC *dcc, char *msg diff --git a/apps/irssi/docs/startup-HOWTO.html b/apps/irssi/docs/startup-HOWTO.html index cb323cda..5700d9f0 100644 --- a/apps/irssi/docs/startup-HOWTO.html +++ b/apps/irssi/docs/startup-HOWTO.html @@ -8,18 +8,21 @@

Index with some FAQ questions that are answered in the chapter:

    -
  1. For all the lazy people
  2. +
  3. For all the lazy people
    • This window management is just weird, I want it exactly like ircII
    • -
    +
  4. Basic user interface usage
    • Split windows work in weird way
    • +
    • How can I easily switch between windows?
    • +
    • But alt-1 etc. don't work!
  5. Server and channel automation
    • How do I automatically connect to servers at startup?
    • How do I automatically join to channels at startup?
    • +
    • How do I automatically send commands to server at connect?
  6. Setting up windows and automatically restoring them at startup
  7. @@ -77,8 +80,8 @@ like msgs window where all messages go:

    /SET use_msgs_window ON -

    Disable automatic window closing when /PARTing channel or /UNQUERYing -query:

    +

    Disable automatic window closing when /PARTing channel or +/UNQUERYing query:

          /SET autoclose_windows OFF
    @@ -139,11 +142,11 @@ If you want lines containing your nick to hilight:
     
     

    Windows can be scrolled up/down with PgUp and PgDown keys. If they don't work for you, use Meta-p and Meta-n keys. For jumping to beginning or end of -the buffer, use /SB HOME and /SB END commands.

    +the buffer, use /SB HOME and /SB END commands.

    -

    By default, irssi uses "hidden windows" for everything. Hidden -window is created every time you /JOIN a channel or /QUERY someone. -There's several ways you can change between these windows:

    +

    By default, irssi uses "hidden windows" for everything. Hidden window is +created every time you /JOIN a channel or /QUERY +someone. There's several ways you can change between these windows:

          Meta-1, Meta-2, .. Meta-0 - Jump directly between windows 1-10
    @@ -176,11 +179,12 @@ want to use ALT instead of Windows key for it, use:

    And how exactly do you set these X resources? For Debian, there's -/etc/X11/Xresources/xterm file where you can put them and it's read -automatically when X starts. ~/.Xresources and ~/.Xdefaults files might also -work. If you can't get anything else to work, just copy&paste those lines to -~/.Xresources and directly call "xrdb -merge ~/.Xresources" in some xterm. -The resources affect only the new xterms you start, not existing ones.

    +/etc/X11/Xresources/xterm file where you can put them and it's +read automatically when X starts. ~/.Xresources and +~/.Xdefaults files might also work. If you can't get anything +else to work, just copy and paste those lines to ~/.Xresources +and directly call xrdb -merge ~/.Xresources in some xterm. +The resources affect only the new xterms you start, not existing ones.

    Many windows SSH clients also don't allow usage of ALT. One excellent client that does allow is putty, you can download it from @@ -260,11 +264,16 @@ helps with reconnecting if your primary server breaks and is probably useful in some other ways too :) For information how to actually use irssi correctly with multiple servers see the chapter 6.

    -

    First you need to have your IRC network set, use /IRCNET command to -see if it's already there. If it isn't, use /IRCNET ADD yourircnet. To -make Irssi work properly with different IRC networks, you might need to -give some special settings to /IRCNET ADD, see manual.txt for more -information about them. Irssi defaults to IRCNet's behaviour.

    +

    First you need to have your IRC network set, use /IRCNET +command to see if it's already there. If it isn't, use /IRCNET ADD +yourircnet. If you want to execute some commands automatically when +you're connected to some network, use -autosendcmd option. +Here's some examples:

    + +
    +     /IRCNET ADD -autosendcmd '^msg bot invite' ircnet
    +     /IRCNET ADD -autosendcmd "/^msg nickserv ident pass;wait -opn 2000" opn
    +

    After that you need to add your servers. For example:

    @@ -273,10 +282,11 @@ information about them. Irssi defaults to IRCNet's behaviour.

    /SERVER ADD -auto -ircnet worknet irc.mycompany.com 6667 password
    -

    The -auto option specifies that this server is automatically connected -at startup. You don't need to make more than one server with -auto -option to one IRC network, other servers are automatically connected in -same network if the -auto server fails.

    +

    The -auto option specifies that this server is +automatically connected at startup. You don't need to make more than one +server with -auto option to one IRC network, other servers are +automatically connected in same network if the -auto server +fails.

    And finally channels:

    @@ -286,15 +296,15 @@ same network if the -auto server fails.

    /CHANNEL ADD -auto #secret ircnet password -

    -bots and -botcmd should be the only ones needing a bit of -explaining. They're used to send commands automatically to bot when -channel is joined, usually to get ops automatically. You can specify -multiple bot masks with -bots option separated with spaces (and -remember to quote the string then). The $0 in -botcmd specifies the -first found bot in the list. If you don't need the bot masks (ie. the -bot is always with the same nick, like chanserv) you can give only the --botcmd option and the command is always sent.

    - +

    -bots and -botcmd should be the only ones +needing a bit of explaining. They're used to send commands automatically to +bot when channel is joined, usually to get ops automatically. You can +specify multiple bot masks with -bots option separated with +spaces (and remember to quote the string then). The $0 in +-botcmd specifies the first found bot in the list. If you +don't need the bot masks (ie. the bot is always with the same nick, like +chanserv) you can give only the -botcmd option and the command +is always sent.

    4. Setting up windows and automatically restoring them at startup

    @@ -307,17 +317,18 @@ use commands:

    /WINDOW ITEM MOVE <number>|<name> - move channel/query to another window -

    When everything looks the way you like, use /LAYOUT SAVE command -(and /SAVE, if you don't have autosaving enabled) and when you start -irssi next time, irssi remembers the positions of the channels, queries -and everything. This "remembering" doesn't mean that simply using -/LAYOUT SAVE would automatically make irssi reconnect to all servers -and join all channels, you'll need the /SERVER ADD -auto and /CHANNEL -ADD -auto commands to do that.

    +

    When everything looks the way you like, use /LAYOUT SAVE +command (and /SAVE, if you don't have autosaving enabled) and +when you start irssi next time, irssi remembers the positions of the +channels, queries and everything. This "remembering" doesn't mean that +simply using /LAYOUT SAVE would automatically make irssi +reconnect to all servers and join all channels, you'll need the +/SERVER ADD -auto and /CHANNEL ADD -auto commands +to do that.

    If you want to change the layout, you just rearrange the layout like -you want it and use /LAYOUT SAVE again. If you want to remove the -layout for some reason, use /LAYOUT RESET.

    +you want it and use /LAYOUT SAVE again. If you want to remove +the layout for some reason, use /LAYOUT RESET.

    5. Status and msgs windows & message levels

    @@ -331,7 +342,7 @@ query. Some people like it, some don't. If you want to remove it, use

    This doesn't have any effect until you restart irssi. If you want to -remove it immediately, just /WINDOW CLOSE it.

    +remove it immediately, just /WINDOW CLOSE it.

    Another common window is "messages window", where all private messages go. By default it's disabled and query windows are created @@ -354,7 +365,7 @@ irssi. To create it immediately say:

    Note that neither use_msgs_window nor use_status_window have any -effect at all if /LAYOUT SAVE has been used.

    +effect at all if /LAYOUT SAVE has been used.

    This brings us to message levels.. What are they? All messages that irssi prints have one or more "message levels". Most common are PUBLIC @@ -366,10 +377,10 @@ list of levels with

    /HELP levels -

    Status window has message level "ALL -MSGS", meaning that all messages, -except private messages, without more specific place go to status -window. The -MSGS is there so it doesn't conflict with messages -window.

    +

    Status window has message level ALL -MSGS, meaning that all +messages, except private messages, without more specific place go to status +window. The -MSGS is there so it doesn't conflict with +messages window.

    6. How support for multiple servers works in irssi

    @@ -385,9 +396,9 @@ how you do connect to new server without closing the old connection:

    /CONNECT irc.server.org -

    Instead of the /SERVER which disconnects the existing connection. To -see list of all active connections, use /SERVER without any parameters. -You should see a list of something like:

    +

    Instead of the /SERVER which disconnects the existing +connection. To see list of all active connections, use /SERVER +without any parameters. You should see a list of something like:

          -!- IRCNet: irc.song.fi:6667 (IRCNet)
    @@ -404,9 +415,9 @@ When there's multiple connections to same IRC network or server, irssi
     adds a number after the tag so there could be ircnet, ircnet2, ircnet3
     etc.

    -

    Server tags beginning with RECON- mean server reconnections. Above we -see that connection to server at 192.168.0.1 wasn't successful and -irssi will try to connect it again in 3 minutes.

    +

    Server tags beginning with RECON- mean server +reconnections. Above we see that connection to server at 192.168.0.1 wasn't +successful and irssi will try to connect it again in 3 minutes.

    To disconnect one of the servers, or to stop irssi from reconnecting, use

    @@ -436,8 +447,8 @@ multiple connected servers, irssi adds [servertag] prefix to all messages in non-channel/query messages so you'll know where it came from.

    -

    Several commands also accept -servertag option to specify which server -it should use:

    +

    Several commands also accept -servertag option to specify +which server it should use:

          /MSG -tag nick message
    @@ -445,8 +456,8 @@ it should use:

    /QUERY -tag nick
    -

    /MSG tab completion also automatically adds the -tag option when -nick isn't in active server.

    +

    /MSG tab completion also automatically adds the +-tag option when nick isn't in active server.

    Window's server can be made sticky. When sticky, it will never automatically change to anything else, and if server gets disconnected, the @@ -475,8 +486,8 @@ for each server. Here's how to do them (repeat for each server)

    7. /LASTLOG and jumping around in scrollback

    -

    /LASTLOG command can be used for searching texts in scrollback -buffer. Simplest usages are

    +

    /LASTLOG command can be used for searching texts in +scrollback buffer. Simplest usages are

          /LASTLOG word     - print all lines with "word" in them
    @@ -485,30 +496,32 @@ buffer. Simplest usages are

    If there's more than 1000 lines to be printed, irssi thinks that you -probably made some mistake and won't print them without -force option. -If you want to save the full lastlog to file, use

    +probably made some mistake and won't print them without -force +option. If you want to save the full lastlog to file, use

          /LASTLOG -file ~/irc.log
     
    -

    With -file option you don't need -force even if there's more than 1000 -lines. /LASTLOG has a lot of other options too, see /HELP lastlog for -details.

    +

    With -file option you don't need -force even +if there's more than 1000 lines. /LASTLOG has a lot of other +options too, see /HELP lastlog for details.

    Once you've found the lines you were interested in, you might want -to check the discussion around them. Irssi has /SCROLLBACK (or alias -/SB) command for jumping around in scrollback buffer. Since /LASTLOG -prints the timestamp when the message was originally printed, you can -use /SB GOTO hh:mm to jump directly there. To get back to the bottom of -scrollback, use /SB END command.

    +to check the discussion around them. Irssi has /SCROLLBACK (or +alias /SB) command for jumping around in scrollback buffer. +Since /LASTLOG prints the timestamp when the message was +originally printed, you can use /SB GOTO hh:mm to jump +directly there. To get back to the bottom of scrollback, use /SB +END command.

    8. Logging

    Irssi can automatically log important messages when you're set away -(/AWAY reason). When you set yourself unaway (/AWAY), the new messages -in away log are printed to screen. You can configure it with:

    +(/AWAY reason). When you set yourself unaway +(/AWAY), the new messages in away log are printed to screen. +You can configure it with:

          /SET awaylog_level MSGS HILIGHT     - Specifies what messages to log
    @@ -524,7 +537,8 @@ You can turn it on with

    By default it logs pretty much everything execept CTCPS or CRAP -(/WHOIS requests, etc). You can specify the logging level yourself with

    +(/WHOIS requests, etc). You can specify the logging level +yourself with

          /SET autolog_level ALL -CRAP -CLIENTCRAP -CTCPS (this is the default)
    @@ -546,7 +560,8 @@ logs by adding date/time formats to the file name. The formats are in
          /SET autolog_path ~/irclogs/%Y/$tag/$0.%m-%d.log
     
    -

    For logging only some specific channels or nicks, see /HELP log

    +

    For logging only some specific channels or nicks, see /HELP +log

    9. Changing keyboard bindings

    @@ -556,33 +571,34 @@ about. It doesn't let irssi know everything, so for example shift-backspace can't be bound unless you modify xterm resources somehow.

    -

    /HELP bind tells pretty much everything there is to know about -keyboard bindings. However, there's the problem of how to bind some -non-standard keys. They might differ a bit with each terminal, so -you'll need to find out what exactly the keypress produces. Easiest -way to check that would be to see what it prints in "cat". Here's -an example for pressing F1 key:

    +

    /HELP bind tells pretty much everything there is to know +about keyboard bindings. However, there's the problem of how to bind some +non-standard keys. They might differ a bit with each terminal, so you'll +need to find out what exactly the keypress produces. Easiest way to check +that would be to see what it prints in cat. Here's an example +for pressing F1 key:

    -[cras@hurina] ~% cat
    -^[OP
    +     [cras@hurina] ~% cat
    +     ^[OP
     
    -

    So in irssi you would use /BIND ^[OP /ECHO F1 pressed. If you use -multiple terminals which have different bindings for the key, it would -be better to use eg.:

    +

    So in irssi you would use /BIND ^[OP /ECHO F1 pressed. If +you use multiple terminals which have different bindings for the key, it +would be better to use eg.:

    -/BIND ^[OP key F1
    -/BIND ^[11~ key F1
    -/BIND F1 /ECHO F1 pressed.
    +     /BIND ^[OP key F1
    +     /BIND ^[11~ key F1
    +     /BIND F1 /ECHO F1 pressed.
     

    10. Proxies and IRC bouncers

    Irssi supports connecting to IRC servers via a proxy. All server connections are then made through it, and if you've set up everything -properly, you don't need to do any /QUOTE SERVER commands manually.

    +properly, you don't need to do any /QUOTE SERVER commands +manually.

    Here's an example: You have your bouncer (lets say, BNC or BNC-like) listening in irc.bouncer.org port 5000. You want to use it to connect @@ -608,12 +624,13 @@ about them:

    /SERVER ADD -auto -ircnet efnet irc.efnet.org
    -

    With the proxy /SETs however, irssi now connects to those servers -through your BNC. All server connections are made through them so you -can just forget that your bouncer even exists.

    +

    With the proxy /SETs however, irssi now connects to those +servers through your BNC. All server connections are made through them so +you can just forget that your bouncer even exists.

    -

    If you don't want to use the proxy for some reason, there's -noproxy -option which you can give to /SERVER and /SERVER ADD commands.

    +

    If you don't want to use the proxy for some reason, there's +-noproxy option which you can give to /SERVER and +/SERVER ADD commands.

    Proxy specific settings:

    @@ -677,19 +694,22 @@ as with dircproxy, by creating fake connections:

    /SERVER ADD -auto -ircnet opn fake.opn 6667 opnpass -

    So, you'll specify the usernames with /IRCNET ADD command, and the -user's password with /SERVER ADD.

    +

    So, you'll specify the usernames with /IRCNET ADD command, +and the user's password with /SERVER ADD.

    Irssi proxy

    Irssi contains it's own proxy which you can build giving ---with-proxy option to configure. You'll still need to run +--with-proxy option to configure. You'll still need to run irssi in a screen to use it though.

    Irssi proxy is a bit different than most proxies, normally proxies create a new connection to IRC server when you connect to it, but irssi proxy shares your existing IRC connection(s) to multiple -clients.

    +clients. And even more clearly: You can use only one IRC +server connection to IRC with as many clients as you want. Can +anyone figure out even more easier ways to say this, so I wouldn't need to +try to explain this thing for minutes every time? :)

    Irssi proxy supports sharing multiple server connections in different ports, like you can share ircnet in port 2777 and efnet in port 2778.

    @@ -703,9 +723,9 @@ ports, like you can share ircnet in port 2777 and efnet in port 2778.

    NOTE: you MUST add all the servers you -are using to server and ircnet lists with /SERVER ADD and /IRCNET ADD. -..Except if you really don't want to for some reason, and you only use -one server connection, you may simply set:

    +are using to server and ircnet lists with /SERVER ADD and +/IRCNET ADD. ..Except if you really don't want to for some +reason, and you only use one server connection, you may simply set:

          /SET irssiproxy_ports *=2777
    @@ -714,7 +734,7 @@ one server connection, you may simply set:

    Usage in client side:

    Just connect to the irssi proxy like it is a normal server with password -specified in /SET irssiproxy_password. For example:

    +specified in /SET irssiproxy_password. For example:

          /SERVER ADD -ircnet ircnet my.irssi-proxy.org 2777 secret
    @@ -725,9 +745,9 @@ specified in /SET irssiproxy_password. For example:

    SOCKS

    -Irssi can be compiled with socks support (--with-socks -option to configure), but I don't really know how it works, if at all. /SET -proxy settings don't have anything to do with socks however. +Irssi can be compiled with socks support (--with-socks option +to configure), but I don't really know how it works, if at all. /SET +proxy settings don't have anything to do with socks however.

    Others

    @@ -760,12 +780,12 @@ of them you might want to change (the default value is shown):

    /SET autocreate_own_query ON
    Should new query window be created when you send message to someone - (with /msg).
    + (with /MSG).
    /SET autocreate_query_level MSGS
    New query window should be created when receiving messages with this level. MSGS, DCCMSGS and NOTICES levels work currently. You can - disable this with /SET -clear autocrate_query_level.
    + disable this with /SET -clear autocrate_query_level.
    /SET autoclose_query 0
    Query windows can be automatically closed after certain time of @@ -785,8 +805,8 @@ of them you might want to change (the default value is shown):

    /SET use_status_window ON
    Create status window at startup. All messages that don't really have better place go here, like all /WHOIS replies etc. Status window - can also be created manually with /WINDOW LEVEL ALL -MSGS, /WINDOW NAME - (status).
    + can also be created manually with /WINDOW LEVEL ALL -MSGS, + /WINDOW NAME (status).
    /SET autocreate_windows ON
    Should we create new windows for new window items or just place @@ -794,7 +814,7 @@ of them you might want to change (the default value is shown):

    /SET autoclose_windows ON
    Should window be automatically closed when the last item in them is - removed (ie. /PART, /UNQUERY).
    + removed (ie. /PART, /UNQUERY).
    /SET reuse_unused_windows OFF
    When finding where to place new window item (channel, query) Irssi @@ -803,16 +823,16 @@ of them you might want to change (the default value is shown):

    ignored if autoclose_windows is set ON.
    /SET window_auto_change OFF
    -
    Should Irssi automatically change to automatically created windows - - usually queries when someone sends you a message. To prevent +
    Should Irssi automatically change to automatically created windows - + usually queries when someone sends you a message. To prevent accidentally sending text meant to some other channel/nick, Irssi clears the input buffer when changing the window. The text is still in scrollback buffer, you can get it back with pressing arrow up key.
    /SET print_active_channel OFF
    When you keep more than one channel in same window, Irssi prints - the messages coming to active channel as "<nick> text" - and other channels as "<nick:channel> text". If this + the messages coming to active channel as <nick> text + and other channels as <nick:channel> text. If this setting is set ON, the messages to active channels are also printed in the latter way.
    @@ -868,11 +888,12 @@ of them you might want to change (the default value is shown):

    /SET show_nickmode ON
    Show the nick's mode before nick in channels, ie. ops have - <@nick>, voices <+nick> and others < nick>
    + <@nick>, voices <+nick> and others + < nick>
    /SET show_nickmode_empty ON
    If the nick doesn't have a mode, use one space. ie. ON: - < nick>, OFF: <nick>
    + < nick>, OFF: <nick>
    /SET show_quit_once OFF
    Show quit message only once in some of the channel windows the @@ -886,13 +907,13 @@ of them you might want to change (the default value is shown):

    When lines are longer than screen width they have to be split to multiple lines. This specifies how much space to put at the beginning of the line before the text begins. This can be overridden in text - formats with %| format.
    + formats with %| format.
    /SET activity_hide_targets
    If you don't want to see window activity in some certain channels - or queries, list them here. For example "#boringchannel =bot1 =bot2". - If any highlighted text or message for you appears in that window, this - setting is ignored and the activity is shown.
    + or queries, list them here. For example #boringchannel =bot1 + =bot2. If any highlighted text or message for you appears in that + window, this setting is ignored and the activity is shown.

    Nick completion

    @@ -909,22 +930,21 @@ of them you might want to change (the default value is shown):

    12. Statusbar

    -

    /STATUSBAR displays a list of statusbars:

    +

    /STATUSBAR displays a list of statusbars:

    -Name                           Type   Placement Position Visible
    -window                         window bottom    0        always
    -window_inact                   window bottom    1        inactive
    -prompt                         root   bottom    100      always
    -topic                          root   top       1        always
    +     Name                           Type   Placement Position Visible
    +     window                         window bottom    0        always
    +     window_inact                   window bottom    1        inactive
    +     prompt                         root   bottom    100      always
    +     topic                          root   top       1        always
     
    -

    /STATUSBAR <name> prints the statusbar -settings and it's items. /STATUSBAR <name> -ENABLE|DISABLE enables/disables the statusbar. -/STATUSBAR <name> RESET resets the statusbar to -it's default settings, or if the statusbar was created by you, it will be -removed.

    +

    /STATUSBAR <name> prints the statusbar settings and +it's items. /STATUSBAR <name> ENABLE|DISABLE +enables/disables the statusbar. /STATUSBAR <name> RESET +resets the statusbar to it's default settings, or if the statusbar was +created by you, it will be removed.

    Type can be window or root, meaning if the statusbar should be created for each split window, or just once. Placement can be top or @@ -933,23 +953,23 @@ it is. Visible can be always, active or inactive. Active/inactive is useful only with split windows, one split window is active and the rest are inactive. These settings can be changed with:

    -
      -
    • STATUSBAR <name> TYPE window|root
    • -
    • STATUSBAR <name> PLACEMENT top|bottom
    • -
    • STATUSBAR <name> POSITION <num>
    • -
    • STATUSBAR <name> VISIBLE always|active|inactive
    • -
    +
    +     STATUSBAR <name> TYPE window|root
    +     STATUSBAR <name> PLACEMENT top|bottom
    +     STATUSBAR <name> POSITION <num>
    +     STATUSBAR <name> VISIBLE always|active|inactive
    +

    When loading a new statusbar scripts, you'll need to also specify where you want to show it. Statusbar items can be modified with:

    -
      -
    • 10:52 STATUSBAR <name> ADD [-before | -after <item>] [-priority #] [-alignment left|right] <item>
    • -
    • 10:52 STATUSBAR <name> REMOVE <item>
    • -
    +
    +     STATUSBAR <name> ADD [-before | -after <item>] [-priority #] [-alignment left|right] <item>
    +     STATUSBAR <name> REMOVE <item>
    +

    The item name with statusbar scripts is usually same as the script's name. Script's documentation should tell if this isn't the case. So, to add mail.pl before the window activity item (see the list with -/STATUSBAR window), use: /STATUSBAR window ADD -before act -mail.

    +/STATUSBAR window), use: /STATUSBAR window ADD -before +act mail.

    diff --git a/apps/irssi/silc.conf b/apps/irssi/silc.conf index e8741573..40a07856 100644 --- a/apps/irssi/silc.conf +++ b/apps/irssi/silc.conf @@ -70,6 +70,7 @@ aliases = { UPTIME = "eval exec - expr `date +%s` - \\$F | awk '{print \"Irssi uptime: \"int(\\\\\\$1/3600/24)\"d \"int(\\\\\\$1/3600%24)\"h \"int(\\\\\\$1/60%60)\"m \"int(\\\\\\$1%60)\"s\" }'"; CALC = "exec - if which bc &>/dev/null\\; then echo '$*' | bc | awk '{print \"$*=\"$$1}'\\; else echo bc was not found\\; fi"; SBAR = "STATUSBAR"; + Q = "QUERY"; }; # @@ -91,6 +92,7 @@ statusbar = { user = "{sb $cumode$N{sbaway $A}}"; usermode = " {sbusermode $usermode}"; topic = " $topic"; + topic_empty = " Irssi v$J - http://irssi.org/help/"; # treated specially .. window is printed with non-empty windows, # window_empty is printed with empty windows @@ -179,6 +181,7 @@ statusbar = { items = { barstart = { priority = "100"; }; topic = { }; + topic_empty = { }; barend = { priority = "100"; alignment = "right"; }; }; }; diff --git a/apps/irssi/src/common.h b/apps/irssi/src/common.h index d6cc0421..bdfec4ec 100644 --- a/apps/irssi/src/common.h +++ b/apps/irssi/src/common.h @@ -1,7 +1,7 @@ #ifndef __COMMON_H #define __COMMON_H -#define IRSSI_AUTHOR "Timo Sirainen " +#define IRSSI_AUTHOR "Timo Sirainen " #define IRSSI_WEBSITE "http://irssi.org/" #define IRSSI_DIR_SHORT "~/.silc" diff --git a/apps/irssi/src/core/channels.c b/apps/irssi/src/core/channels.c index 06bf0c41..1884c402 100644 --- a/apps/irssi/src/core/channels.c +++ b/apps/irssi/src/core/channels.c @@ -64,7 +64,7 @@ void channel_destroy(CHANNEL_REC *channel) channel->destroying = TRUE; channels = g_slist_remove(channels, channel); - if (channel->server != NULL) + if (!channel->server->disconnected) channel->server->channels = g_slist_remove(channel->server->channels, channel); signal_emit("channel destroyed", 1, channel); diff --git a/apps/irssi/src/core/commands.c b/apps/irssi/src/core/commands.c index 0899c9fa..96a74008 100644 --- a/apps/irssi/src/core/commands.c +++ b/apps/irssi/src/core/commands.c @@ -72,10 +72,10 @@ static COMMAND_MODULE_REC *command_module_find(COMMAND_REC *rec, return NULL; } -static COMMAND_MODULE_REC *command_module_find_func(COMMAND_REC *rec, - SIGNAL_FUNC func) +static COMMAND_MODULE_REC * +command_module_find_and_remove(COMMAND_REC *rec, SIGNAL_FUNC func) { - GSList *tmp; + GSList *tmp, *tmp2; g_return_val_if_fail(rec != NULL, NULL); g_return_val_if_fail(func != NULL, NULL); @@ -83,8 +83,15 @@ static COMMAND_MODULE_REC *command_module_find_func(COMMAND_REC *rec, for (tmp = rec->modules; tmp != NULL; tmp = tmp->next) { COMMAND_MODULE_REC *rec = tmp->data; - if (g_slist_find(rec->signals, (void *) func) != NULL) - return rec; + for (tmp2 = rec->callbacks; tmp2 != NULL; tmp2 = tmp2->next) { + COMMAND_CALLBACK_REC *cb = tmp2->data; + + if (cb->func == func) { + rec->callbacks = + g_slist_remove(rec->callbacks, cb); + return rec; + } + } } return NULL; @@ -131,11 +138,13 @@ command_module_get(COMMAND_REC *rec, const char *module, int protocol) return modrec; } -void command_bind_to(const char *module, int pos, const char *cmd, - int protocol, const char *category, SIGNAL_FUNC func) +void command_bind_full(const char *module, int priority, const char *cmd, + int protocol, const char *category, SIGNAL_FUNC func, + void *user_data) { COMMAND_REC *rec; - COMMAND_MODULE_REC *modrec; + COMMAND_MODULE_REC *modrec; + COMMAND_CALLBACK_REC *cb; char *str; g_return_if_fail(module != NULL); @@ -150,11 +159,14 @@ void command_bind_to(const char *module, int pos, const char *cmd, } modrec = command_module_get(rec, module, protocol); - modrec->signals = g_slist_append(modrec->signals, (void *) func); + cb = g_new0(COMMAND_CALLBACK_REC, 1); + cb->func = func; + cb->user_data = user_data; + modrec->callbacks = g_slist_append(modrec->callbacks, cb); if (func != NULL) { str = g_strconcat("command ", cmd, NULL); - signal_add_to(module, pos, str, func); + signal_add_full(module, priority, str, func, user_data); g_free(str); } @@ -176,7 +188,8 @@ static void command_module_free(COMMAND_MODULE_REC *modrec, COMMAND_REC *rec) { rec->modules = g_slist_remove(rec->modules, modrec); - g_slist_free(modrec->signals); + g_slist_foreach(modrec->callbacks, (GFunc) g_free, NULL); + g_slist_free(modrec->callbacks); g_free(modrec->name); g_free_not_null(modrec->options); g_free(modrec); @@ -196,7 +209,7 @@ static void command_module_destroy(COMMAND_REC *rec, for (tmp = rec->modules; tmp != NULL; tmp = tmp->next) { COMMAND_MODULE_REC *rec = tmp->data; - if (rec->signals == NULL) + if (rec->callbacks == NULL) freelist = g_slist_append(freelist, rec); else { g_slist_free(freelist); @@ -212,10 +225,10 @@ static void command_module_destroy(COMMAND_REC *rec, command_free(rec); } -void command_unbind(const char *cmd, SIGNAL_FUNC func) +void command_unbind_full(const char *cmd, SIGNAL_FUNC func, void *user_data) { COMMAND_REC *rec; - COMMAND_MODULE_REC *modrec; + COMMAND_MODULE_REC *modrec; char *str; g_return_if_fail(cmd != NULL); @@ -223,17 +236,15 @@ void command_unbind(const char *cmd, SIGNAL_FUNC func) rec = command_find(cmd); if (rec != NULL) { - modrec = command_module_find_func(rec, func); + modrec = command_module_find_and_remove(rec, func); g_return_if_fail(modrec != NULL); - modrec->signals = - g_slist_remove(modrec->signals, (void *) func); - if (modrec->signals == NULL) + if (modrec->callbacks == NULL) command_module_destroy(rec, modrec); } str = g_strconcat("command ", cmd, NULL); - signal_remove(str, func); + signal_remove_data(str, func, user_data); g_free(str); } @@ -767,10 +778,11 @@ static void command_module_unbind_all(COMMAND_REC *rec, { GSList *tmp, *next; - for (tmp = modrec->signals; tmp != NULL; tmp = next) { + for (tmp = modrec->callbacks; tmp != NULL; tmp = next) { + COMMAND_CALLBACK_REC *cb = tmp->data; next = tmp->next; - command_unbind(rec->cmd, (SIGNAL_FUNC) tmp->data); + command_unbind_full(rec->cmd, cb->func, cb->user_data); } if (g_slist_find(commands, rec) != NULL) { diff --git a/apps/irssi/src/core/commands.h b/apps/irssi/src/core/commands.h index e3bf4374..1733c589 100644 --- a/apps/irssi/src/core/commands.h +++ b/apps/irssi/src/core/commands.h @@ -3,11 +3,16 @@ #include "signals.h" +typedef struct { + SIGNAL_FUNC func; + void *user_data; +} COMMAND_CALLBACK_REC; + typedef struct { char *name; char *options; int protocol; /* chat protocol required for this command */ - GSList *signals; + GSList *callbacks; } COMMAND_MODULE_REC; typedef struct { @@ -57,17 +62,23 @@ extern GSList *commands; extern char *current_command; /* the command we're right now. */ /* Bind command to specified function. */ -void command_bind_to(const char *module, int pos, const char *cmd, - int protocol, const char *category, SIGNAL_FUNC func); -#define command_bind(a, b, c) command_bind_to(MODULE_NAME, 1, a, -1, b, c) -#define command_bind_first(a, b, c) command_bind_to(MODULE_NAME, 0, a, -1, b, c) -#define command_bind_last(a, b, c) command_bind_to(MODULE_NAME, 2, a, -1, b, c) - -#define command_bind_proto(a, b, c, d) command_bind_to(MODULE_NAME, 1, a, b, c, d) -#define command_bind_proto_first(a, b, c, d) command_bind_to(MODULE_NAME, 0, a, b, c, d) -#define command_bind_proto_last(a, b, c, d) command_bind_to(MODULE_NAME, 2, a, b, c, d) - -void command_unbind(const char *cmd, SIGNAL_FUNC func); +void command_bind_full(const char *module, int priority, const char *cmd, + int protocol, const char *category, SIGNAL_FUNC func, + void *user_data); +#define command_bind(a, b, c) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT, a, -1, b, c, NULL) +#define command_bind_first(a, b, c) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_HIGH, a, -1, b, c, NULL) +#define command_bind_last(a, b, c) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_LOW, a, -1, b, c, NULL) + +#define command_bind_data(a, b, c, d) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT, a, -1, b, c, d) +#define command_bind_data_first(a, b, c, d) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_HIGH, a, -1, b, c, d) +#define command_bind_data_last(a, b, c, d) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_LOW, a, -1, b, c, d) + +#define command_bind_proto(a, b, c, d) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT, a, b, c, d, NULL) +#define command_bind_proto_first(a, b, c, d) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_HIGH, a, b, c, d, NULL) +#define command_bind_proto_last(a, b, c, d) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_LOW, a, b, c, d, NULL) + +void command_unbind_full(const char *cmd, SIGNAL_FUNC func, void *user_data); +#define command_unbind(cmd, func) command_unbind_full(cmd, func, NULL) /* Run subcommand, `cmd' contains the base command, first word in `data' contains the subcommand */ diff --git a/apps/irssi/src/core/expandos.c b/apps/irssi/src/core/expandos.c index 130d6025..5cec5561 100644 --- a/apps/irssi/src/core/expandos.c +++ b/apps/irssi/src/core/expandos.c @@ -179,7 +179,8 @@ void expando_bind(const char *key, int funccount, SIGNAL_FUNC *funcs) func = arg < funccount ? funcs[arg] : NULL; if (func == NULL) func = funcs[EXPANDO_ARG_NONE]; - signal_add_to_id(MODULE_NAME, 1, rec->signal_ids[n], func); + signal_add_full_id(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT, + rec->signal_ids[n], func, NULL); } } @@ -208,7 +209,7 @@ void expando_unbind(const char *key, int funccount, SIGNAL_FUNC *funcs) func = arg < funccount ? funcs[arg] : NULL; if (func == NULL) func = funcs[EXPANDO_ARG_NONE]; - signal_remove_id(rec->signal_ids[n], func); + signal_remove_id(rec->signal_ids[n], func, NULL); } } diff --git a/apps/irssi/src/core/masks.c b/apps/irssi/src/core/masks.c index 7014e431..02c7655c 100644 --- a/apps/irssi/src/core/masks.c +++ b/apps/irssi/src/core/masks.c @@ -30,6 +30,7 @@ static int check_address(const char *mask, int *wildcards) { int ret; + *wildcards = FALSE; ret = FALSE; while (*mask != '\0') { if (*mask == '!') { diff --git a/apps/irssi/src/core/queries.c b/apps/irssi/src/core/queries.c index f4aae6e7..8ae994a2 100644 --- a/apps/irssi/src/core/queries.c +++ b/apps/irssi/src/core/queries.c @@ -37,6 +37,7 @@ void query_init(QUERY_REC *query, int automatic) MODULE_DATA_INIT(query); query->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "QUERY"); query->destroy = (void (*) (WI_ITEM_REC *)) query_destroy; + query->createtime = time(NULL); query->last_unread_msg = time(NULL); if (query->server_tag != NULL) { @@ -124,6 +125,7 @@ void query_change_nick(QUERY_REC *query, const char *nick) oldnick = query->name; query->name = g_strdup(nick); signal_emit("query nick changed", 2, query, oldnick); + signal_emit("window item name changed", 1, query); g_free(oldnick); } diff --git a/apps/irssi/src/core/servers-reconnect.c b/apps/irssi/src/core/servers-reconnect.c index e51a3fa2..1b17c921 100644 --- a/apps/irssi/src/core/servers-reconnect.c +++ b/apps/irssi/src/core/servers-reconnect.c @@ -162,6 +162,7 @@ server_connect_copy_skeleton(SERVER_CONNECT_REC *src, int connect_info) dest->channels = g_strdup(src->channels); dest->away_reason = g_strdup(src->away_reason); + dest->no_autojoin_channels = src->no_autojoin_channels; return dest; } diff --git a/apps/irssi/src/core/servers.c b/apps/irssi/src/core/servers.c index a5a8c701..1e5c0b84 100644 --- a/apps/irssi/src/core/servers.c +++ b/apps/irssi/src/core/servers.c @@ -257,6 +257,8 @@ static void server_connect_callback_readpipe(SERVER_REC *server) /* initializes server record but doesn't start connecting */ void server_connect_init(SERVER_REC *server) { + const char *str; + g_return_if_fail(server != NULL); MODULE_DATA_INIT(server); @@ -267,16 +269,16 @@ void server_connect_init(SERVER_REC *server) if (server->connrec->username == NULL || *server->connrec->username == '\0') { g_free_not_null(server->connrec->username); - server->connrec->username = g_get_user_name(); - if (*server->connrec->username == '\0') server->connrec->username = "-"; - server->connrec->username = g_strdup(server->connrec->username); + str = g_get_user_name(); + if (*str == '\0') str = "-"; + server->connrec->username = g_strdup(str); } if (server->connrec->realname == NULL || *server->connrec->realname == '\0') { g_free_not_null(server->connrec->realname); - server->connrec->realname = g_get_real_name(); - if (*server->connrec->realname == '\0') server->connrec->realname = "-"; - server->connrec->realname = g_strdup(server->connrec->realname); + str = g_get_real_name(); + if (*str == '\0') str = "-"; + server->connrec->realname = g_strdup(str); } server->tag = server_create_tag(server->connrec); @@ -331,7 +333,6 @@ static int server_remove_channels(SERVER_REC *server) for (tmp = server->channels; tmp != NULL; tmp = tmp->next) { CHANNEL_REC *channel = tmp->data; - channel->server = NULL; channel_destroy(channel); found = TRUE; } diff --git a/apps/irssi/src/core/session.c b/apps/irssi/src/core/session.c index 7e7b0afa..b5419134 100644 --- a/apps/irssi/src/core/session.c +++ b/apps/irssi/src/core/session.c @@ -39,6 +39,7 @@ static char **session_args; void session_set_binary(const char *path) { + const char *envpath; char **paths, **tmp; char *str; @@ -59,10 +60,10 @@ void session_set_binary(const char *path) } /* we'll need to find it from path. */ - str = g_getenv("PATH"); - if (str == NULL) return; + envpath = g_getenv("PATH"); + if (envpath == NULL) return; - paths = g_strsplit(str, ":", -1); + paths = g_strsplit(envpath, ":", -1); for (tmp = paths; *tmp != NULL; tmp++) { str = g_strconcat(*tmp, G_DIR_SEPARATOR_S, path, NULL); if (access(str, X_OK) == 0) { diff --git a/apps/irssi/src/core/signals.c b/apps/irssi/src/core/signals.c index 92064e8d..31642452 100644 --- a/apps/irssi/src/core/signals.c +++ b/apps/irssi/src/core/signals.c @@ -1,7 +1,7 @@ /* signals.c : irssi - Copyright (C) 1999 Timo Sirainen + Copyright (C) 1999-2002 Timo Sirainen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,11 +18,18 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "../common.h" +#include "module.h" #include "signals.h" #include "modules.h" -#define SIGNAL_LISTS 3 +typedef struct _SignalHook { + struct _SignalHook *next; + + int priority; + const char *module; + SIGNAL_FUNC func; + void *user_data; +} SignalHook; typedef struct { int id; /* signal id */ @@ -30,207 +37,233 @@ typedef struct { int emitting; /* signal is being emitted */ int stop_emit; /* this signal was stopped */ + int continue_emit; /* this signal emit was continued elsewhere */ + int remove_count; /* hooks were removed from signal */ - GPtrArray *modulelist[SIGNAL_LISTS]; /* list of what signals belong - to which module */ - GPtrArray *siglist[SIGNAL_LISTS]; /* signal lists */ -} SIGNAL_REC; + SignalHook *hooks; +} Signal; -#define signal_is_emitlist_empty(a) \ - (!(a)->siglist[0] && !(a)->siglist[1] && !(a)->siglist[2]) +void *signal_user_data; -static GMemChunk *signals_chunk; static GHashTable *signals; -static SIGNAL_REC *current_emitted_signal; +static Signal *current_emitted_signal; +static SignalHook *current_emitted_hook; #define signal_ref(signal) ++(signal)->refcount -#define signal_unref(rec) (signal_unref_full(rec, TRUE)) +#define signal_unref(signal) (signal_unref_full(signal, TRUE)) -static int signal_unref_full(SIGNAL_REC *rec, int remove_hash) +static int signal_unref_full(Signal *rec, int remove) { - if (rec->refcount == 0) { - g_error("signal_unref(%s) : BUG - reference counter == 0", - signal_get_id_str(rec->id)); - } + g_assert(rec->refcount > 0); if (--rec->refcount != 0) - return FALSE; + return TRUE; /* remove whole signal from memory */ - if (!signal_is_emitlist_empty(rec)) { - g_error("signal_unref(%s) : BUG - emitlist wasn't empty", + if (rec->hooks != NULL) { + g_error("signal_unref(%s) : BUG - hook list wasn't empty", signal_get_id_str(rec->id)); } - if (remove_hash) + if (remove) g_hash_table_remove(signals, GINT_TO_POINTER(rec->id)); - g_mem_chunk_free(signals_chunk, rec); - return TRUE; + g_free(rec); + + return FALSE; } -static void signal_unref_count(SIGNAL_REC *rec, int count) +static void signal_hash_ref(void *key, Signal *rec) { - while (count-- > 0) - signal_unref(rec); + signal_ref(rec); } -void signal_add_to(const char *module, int pos, - const char *signal, SIGNAL_FUNC func) +static int signal_hash_unref(void *key, Signal *rec) { - g_return_if_fail(signal != NULL); + return !signal_unref_full(rec, FALSE); +} - signal_add_to_id(module, pos, signal_get_uniq_id(signal), func); +void signal_add_full(const char *module, int priority, + const char *signal, SIGNAL_FUNC func, void *user_data) +{ + signal_add_full_id(module, priority, signal_get_uniq_id(signal), + func, user_data); } /* bind a signal */ -void signal_add_to_id(const char *module, int pos, - int signal_id, SIGNAL_FUNC func) +void signal_add_full_id(const char *module, int priority, + int signal_id, SIGNAL_FUNC func, void *user_data) { - SIGNAL_REC *rec; + Signal *signal; + SignalHook *hook, **tmp; g_return_if_fail(signal_id >= 0); g_return_if_fail(func != NULL); - g_return_if_fail(pos >= 0 && pos < SIGNAL_LISTS); - - rec = g_hash_table_lookup(signals, GINT_TO_POINTER(signal_id)); - if (rec == NULL) { - rec = g_mem_chunk_alloc0(signals_chunk); - rec->id = signal_id; - g_hash_table_insert(signals, GINT_TO_POINTER(signal_id), rec); - } - if (rec->siglist[pos] == NULL) { - rec->siglist[pos] = g_ptr_array_new(); - rec->modulelist[pos] = g_ptr_array_new(); + signal = g_hash_table_lookup(signals, GINT_TO_POINTER(signal_id)); + if (signal == NULL) { + /* new signal */ + signal = g_new0(Signal, 1); + signal->id = signal_id; + g_hash_table_insert(signals, GINT_TO_POINTER(signal_id), signal); } - g_ptr_array_add(rec->siglist[pos], (void *) func); - g_ptr_array_add(rec->modulelist[pos], (void *) module); - - signal_ref(rec); -} - -static int signal_list_find(GPtrArray *array, void *data) -{ - unsigned int n; - - for (n = 0; n < array->len; n++) { - if (g_ptr_array_index(array, n) == data) - return n; + hook = g_new0(SignalHook, 1); + hook->priority = priority; + hook->module = module; + hook->func = func; + hook->user_data = user_data; + + /* insert signal to proper position in list */ + for (tmp = &signal->hooks; ; tmp = &(*tmp)->next) { + if (*tmp == NULL) { + /* last in list */ + *tmp = hook; + break; + } else if (priority <= (*tmp)->priority) { + /* insert before others with same priority */ + hook->next = *tmp; + *tmp = hook; + break; + } } - return -1; + signal_ref(signal); } -static void signal_list_free(SIGNAL_REC *rec, int list) +static void signal_remove_hook(Signal *rec, SignalHook **hook_pos) { - g_ptr_array_free(rec->siglist[list], TRUE); - g_ptr_array_free(rec->modulelist[list], TRUE); - rec->siglist[list] = NULL; - rec->modulelist[list] = NULL; -} + SignalHook *hook; -/* Returns TRUE if the whole signal is removed after this remove */ -static void signal_remove_from_list(SIGNAL_REC *rec, int list, int index) -{ - g_ptr_array_remove_index(rec->siglist[list], index); - g_ptr_array_remove_index(rec->modulelist[list], index); + hook = *hook_pos; + *hook_pos = hook->next; - if (rec->siglist[list]->len == 0) - signal_list_free(rec, list); + g_free(hook); signal_unref(rec); } -/* Remove signal from emit lists */ -static int signal_remove_from_lists(SIGNAL_REC *rec, SIGNAL_FUNC func) +/* Remove function from signal's emit list */ +static int signal_remove_func(Signal *rec, SIGNAL_FUNC func, void *user_data) { - int n, index; - - for (n = 0; n < SIGNAL_LISTS; n++) { - if (rec->siglist[n] == NULL) - continue; - - index = signal_list_find(rec->siglist[n], (void *) func); - if (index != -1) { - /* remove the function from emit list */ - signal_remove_from_list(rec, n, index); - return 1; + SignalHook **hook; + + for (hook = &rec->hooks; *hook != NULL; hook = &(*hook)->next) { + if ((*hook)->func == func && (*hook)->user_data == user_data) { + if (rec->emitting) { + /* mark it removed after emitting is done */ + (*hook)->func = NULL; + rec->remove_count++; + } else { + /* remove the function from emit list */ + signal_remove_hook(rec, hook); + } + return TRUE; } } - return 0; + return FALSE; } -void signal_remove_id(int signal_id, SIGNAL_FUNC func) +void signal_remove_id(int signal_id, SIGNAL_FUNC func, void *user_data) { - SIGNAL_REC *rec; + Signal *rec; g_return_if_fail(signal_id >= 0); g_return_if_fail(func != NULL); rec = g_hash_table_lookup(signals, GINT_TO_POINTER(signal_id)); if (rec != NULL) - signal_remove_from_lists(rec, func); + signal_remove_func(rec, func, user_data); } /* unbind signal */ -void signal_remove(const char *signal, SIGNAL_FUNC func) +void signal_remove_full(const char *signal, SIGNAL_FUNC func, void *user_data) { g_return_if_fail(signal != NULL); - signal_remove_id(signal_get_uniq_id(signal), func); + signal_remove_id(signal_get_uniq_id(signal), func, user_data); +} + +static void signal_hooks_clean(Signal *rec) +{ + SignalHook **hook, **next; + int count; + + count = rec->remove_count; + rec->remove_count = 0; + + for (hook = &rec->hooks; *hook != NULL; hook = next) { + next = &(*hook)->next; + + if ((*hook)->func == NULL) { + next = hook; + signal_remove_hook(rec, hook); + + if (--count == 0) + break; + } + } } -static int signal_emit_real(SIGNAL_REC *rec, int params, va_list va) +static int signal_emit_real(Signal *rec, int params, va_list va, + SignalHook *first_hook) { - gconstpointer arglist[SIGNAL_MAX_ARGUMENTS]; - SIGNAL_REC *prev_emitted_signal; - SIGNAL_FUNC func; - int n, index, stopped, stop_emit_count; + const void *arglist[SIGNAL_MAX_ARGUMENTS]; + Signal *prev_emitted_signal; + SignalHook *hook, *prev_emitted_hook; + int i, stopped, stop_emit_count, continue_emit_count; - for (n = 0; n < SIGNAL_MAX_ARGUMENTS; n++) - arglist[n] = n >= params ? NULL : va_arg(va, gconstpointer); + for (i = 0; i < SIGNAL_MAX_ARGUMENTS; i++) + arglist[i] = i >= params ? NULL : va_arg(va, const void *); /* signal_stop_by_name("signal"); signal_emit("signal", ...); fails if we compare rec->stop_emit against 0. */ stop_emit_count = rec->stop_emit; + continue_emit_count = rec->continue_emit; signal_ref(rec); stopped = FALSE; rec->emitting++; - for (n = 0; n < SIGNAL_LISTS; n++) { - /* run signals in emit lists */ - if (rec->siglist[n] == NULL) - continue; - for (index = rec->siglist[n]->len-1; index >= 0; index--) { - func = (SIGNAL_FUNC) g_ptr_array_index(rec->siglist[n], index); + prev_emitted_signal = current_emitted_signal; + prev_emitted_hook = current_emitted_hook; + current_emitted_signal = rec; - prev_emitted_signal = current_emitted_signal; - current_emitted_signal = rec; + for (hook = first_hook; hook != NULL; hook = hook->next) { + if (hook->func == NULL) + continue; /* removed */ + + current_emitted_hook = hook; #if SIGNAL_MAX_ARGUMENTS != 6 # error SIGNAL_MAX_ARGUMENTS changed - update code #endif - func(arglist[0], arglist[1], arglist[2], arglist[3], arglist[4], arglist[5]); - current_emitted_signal = prev_emitted_signal; - - if (rec->stop_emit != stop_emit_count) { - stopped = TRUE; - rec->stop_emit--; - n = SIGNAL_LISTS; - break; - } + signal_user_data = hook->user_data; + hook->func(arglist[0], arglist[1], arglist[2], arglist[3], + arglist[4], arglist[5]); + + if (rec->continue_emit != continue_emit_count) + rec->continue_emit--; + + if (rec->stop_emit != stop_emit_count) { + stopped = TRUE; + rec->stop_emit--; + break; } } + + current_emitted_signal = prev_emitted_signal; + current_emitted_hook = prev_emitted_hook; + rec->emitting--; + signal_user_data = NULL; if (!rec->emitting) { - if (rec->stop_emit != 0) { - /* signal_stop() used too many times */ - rec->stop_emit = 0; - } + g_assert(rec->stop_emit == 0); + g_assert(rec->continue_emit == 0); + + if (rec->remove_count > 0) + signal_hooks_clean(rec); } signal_unref(rec); @@ -239,7 +272,7 @@ static int signal_emit_real(SIGNAL_REC *rec, int params, va_list va) int signal_emit(const char *signal, int params, ...) { - SIGNAL_REC *rec; + Signal *rec; va_list va; int signal_id; @@ -250,7 +283,7 @@ int signal_emit(const char *signal, int params, ...) rec = g_hash_table_lookup(signals, GINT_TO_POINTER(signal_id)); if (rec != NULL) { va_start(va, params); - signal_emit_real(rec, params, va); + signal_emit_real(rec, params, va, rec->hooks); va_end(va); } @@ -259,7 +292,7 @@ int signal_emit(const char *signal, int params, ...) int signal_emit_id(int signal_id, int params, ...) { - SIGNAL_REC *rec; + Signal *rec; va_list va; g_return_val_if_fail(signal_id >= 0, FALSE); @@ -268,17 +301,39 @@ int signal_emit_id(int signal_id, int params, ...) rec = g_hash_table_lookup(signals, GINT_TO_POINTER(signal_id)); if (rec != NULL) { va_start(va, params); - signal_emit_real(rec, params, va); + signal_emit_real(rec, params, va, rec->hooks); va_end(va); } return rec != NULL; } +void signal_continue(int params, ...) +{ + Signal *rec; + va_list va; + + rec = current_emitted_signal; + if (rec == NULL || rec->emitting <= rec->continue_emit) + g_warning("signal_continue() : no signals are being emitted currently"); + else { + va_start(va, params); + + /* stop the signal */ + if (rec->emitting > rec->stop_emit) + rec->stop_emit++; + + /* re-emit */ + rec->continue_emit++; + signal_emit_real(rec, params, va, current_emitted_hook->next); + va_end(va); + } +} + /* stop the current ongoing signal emission */ void signal_stop(void) { - SIGNAL_REC *rec; + Signal *rec; rec = current_emitted_signal; if (rec == NULL) @@ -290,7 +345,7 @@ void signal_stop(void) /* stop ongoing signal emission by signal name */ void signal_stop_by_name(const char *signal) { - SIGNAL_REC *rec; + Signal *rec; int signal_id; signal_id = signal_get_uniq_id(signal); @@ -310,7 +365,7 @@ const char *signal_get_emitted(void) /* return the ID of the signal that is currently being emitted */ int signal_get_emitted_id(void) { - SIGNAL_REC *rec; + Signal *rec; rec = current_emitted_signal; g_return_val_if_fail(rec != NULL, -1); @@ -320,7 +375,7 @@ int signal_get_emitted_id(void) /* return TRUE if specified signal was stopped */ int signal_is_stopped(int signal_id) { - SIGNAL_REC *rec; + Signal *rec; rec = g_hash_table_lookup(signals, GINT_TO_POINTER(signal_id)); g_return_val_if_fail(rec != NULL, FALSE); @@ -328,73 +383,57 @@ int signal_is_stopped(int signal_id) return rec->emitting <= rec->stop_emit; } -static void signal_remove_module(void *signal, SIGNAL_REC *rec, +static void signal_remove_module(void *signal, Signal *rec, const char *module) { - unsigned int index; - int list; + SignalHook **hook, **next; - for (list = 0; list < SIGNAL_LISTS; list++) { - if (rec->modulelist[list] == NULL) - continue; + for (hook = &rec->hooks; *hook != NULL; hook = next) { + next = &(*hook)->next; - for (index = rec->modulelist[list]->len; index > 0; index--) - if (g_strcasecmp(g_ptr_array_index(rec->modulelist[list], index-1), module) == 0) - signal_remove_from_list(rec, list, index-1); + if (strcasecmp((*hook)->module, module) == 0) { + next = hook; + signal_remove_hook(rec, hook); + } } } -static void signal_foreach_ref(void *signal, SIGNAL_REC *rec) -{ - signal_ref(rec); -} - -static int signal_foreach_unref(void *signal, SIGNAL_REC *rec) -{ - return signal_unref_full(rec, FALSE); -} - /* remove all signals that belong to `module' */ void signals_remove_module(const char *module) { g_return_if_fail(module != NULL); - g_hash_table_foreach(signals, (GHFunc) signal_foreach_ref, NULL); - g_hash_table_foreach(signals, (GHFunc) signal_remove_module, (void *) module); - g_hash_table_foreach_remove(signals, (GHRFunc) signal_foreach_unref, NULL); + g_hash_table_foreach(signals, (GHFunc) signal_hash_ref, NULL); + g_hash_table_foreach(signals, (GHFunc) signal_remove_module, + (void *) module); + g_hash_table_foreach_remove(signals, (GHRFunc) signal_hash_unref, NULL); } void signals_init(void) { - signals_chunk = g_mem_chunk_new("signals", sizeof(SIGNAL_REC), - sizeof(SIGNAL_REC)*200, G_ALLOC_AND_FREE); - signals = g_hash_table_new((GHashFunc) g_direct_hash, (GCompareFunc) g_direct_equal); + signals = g_hash_table_new(NULL, NULL); } -static void signal_free(void *key, SIGNAL_REC *rec) +static void signal_free(void *key, Signal *rec) { - int n; + /* refcount-1 because we just referenced it ourself */ + g_warning("signal_free(%s) : signal still has %d references:", + signal_get_id_str(rec->id), rec->refcount-1); - signal_ref(rec); - - for (n = 0; n < SIGNAL_LISTS; n++) { - if (rec->siglist[n] != NULL) { - signal_unref_count(rec, rec->siglist[n]->len); - signal_list_free(rec, n); - } - } + while (rec->hooks != NULL) { + g_warning(" - module '%s' function %p", + rec->hooks->module, rec->hooks->func); - if (!signal_unref_full(rec, FALSE)) { - g_error("signal_free(%s) : BUG - signal still has %d references", - signal_get_id_str(rec->id), rec->refcount); + signal_remove_hook(rec, &rec->hooks); } } void signals_deinit(void) { - g_hash_table_foreach(signals, (GHFunc) signal_free, NULL); + g_hash_table_foreach(signals, (GHFunc) signal_hash_ref, NULL); + g_hash_table_foreach(signals, (GHFunc) signal_free, NULL); + g_hash_table_foreach_remove(signals, (GHRFunc) signal_hash_unref, NULL); g_hash_table_destroy(signals); module_uniq_destroy("signals"); - g_mem_chunk_destroy(signals_chunk); } diff --git a/apps/irssi/src/core/signals.h b/apps/irssi/src/core/signals.h index 795f7327..384af66f 100644 --- a/apps/irssi/src/core/signals.h +++ b/apps/irssi/src/core/signals.h @@ -1,38 +1,51 @@ #ifndef __SIGNAL_H #define __SIGNAL_H +#define SIGNAL_PRIORITY_LOW 100 +#define SIGNAL_PRIORITY_DEFAULT 0 +#define SIGNAL_PRIORITY_HIGH -100 + #define SIGNAL_MAX_ARGUMENTS 6 -typedef void (*SIGNAL_FUNC) (gconstpointer, gconstpointer, - gconstpointer, gconstpointer, - gconstpointer, gconstpointer); +typedef void (*SIGNAL_FUNC) (const void *, const void *, + const void *, const void *, + const void *, const void *); -void signals_init(void); -void signals_deinit(void); - -/* signal name -> ID */ -#define signal_get_uniq_id(signal) \ - module_get_uniq_id_str("signals", signal) -/* signal ID -> name */ -#define signal_get_id_str(signal_id) \ - module_find_id_str("signals", signal_id) +extern void *signal_user_data; /* use signal_get_user_data() macro to access */ /* bind a signal */ -void signal_add_to(const char *module, int pos, - const char *signal, SIGNAL_FUNC func); -void signal_add_to_id(const char *module, int pos, - int signal, SIGNAL_FUNC func); -#define signal_add(a, b) signal_add_to(MODULE_NAME, 1, a, b) -#define signal_add_first(a, b) signal_add_to(MODULE_NAME, 0, a, b) -#define signal_add_last(a, b) signal_add_to(MODULE_NAME, 2, a, b) +void signal_add_full(const char *module, int priority, + const char *signal, SIGNAL_FUNC func, void *user_data); +void signal_add_full_id(const char *module, int priority, + int signal, SIGNAL_FUNC func, void *user_data); +#define signal_add(signal, func) \ + signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT, (signal), (SIGNAL_FUNC) (func), NULL) +#define signal_add_first(signal, func) \ + signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_HIGH, (signal), (SIGNAL_FUNC) (func), NULL) +#define signal_add_last(signal, func) \ + signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_LOW, (signal), (SIGNAL_FUNC) (func), NULL) + +#define signal_add_data(signal, func, data) \ + signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT, (signal), (SIGNAL_FUNC) (func), data) +#define signal_add_first_data(signal, func, data) \ + signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_HIGH, (signal), (SIGNAL_FUNC) (func), data) +#define signal_add_last_data(signal, func, data) \ + signal_add_full(MODULE_NAME, SIGNAL_PRIORITY_LOW, (signal), (SIGNAL_FUNC) (func), data) /* unbind signal */ -void signal_remove(const char *signal, SIGNAL_FUNC func); -void signal_remove_id(int signal_id, SIGNAL_FUNC func); +void signal_remove_full(const char *signal, SIGNAL_FUNC func, void *user_data); +#define signal_remove(signal, func) \ + signal_remove_full((signal), (SIGNAL_FUNC) (func), NULL) +#define signal_remove_data(signal, func, data) \ + signal_remove_full((signal), (SIGNAL_FUNC) (func), data) +void signal_remove_id(int signal_id, SIGNAL_FUNC func, void *user_data); /* emit signal */ int signal_emit(const char *signal, int params, ...); int signal_emit_id(int signal_id, int params, ...); +/* continue currently emitted signal with different parameters */ +void signal_continue(int params, ...); + /* stop the current ongoing signal emission */ void signal_stop(void); /* stop ongoing signal emission by signal name */ @@ -44,8 +57,20 @@ const char *signal_get_emitted(void); int signal_get_emitted_id(void); /* return TRUE if specified signal was stopped */ int signal_is_stopped(int signal_id); +/* return the user data of the signal function currently being emitted */ +#define signal_get_user_data() signal_user_data /* remove all signals that belong to `module' */ void signals_remove_module(const char *module); +/* signal name -> ID */ +#define signal_get_uniq_id(signal) \ + module_get_uniq_id_str("signals", signal) +/* signal ID -> name */ +#define signal_get_id_str(signal_id) \ + module_find_id_str("signals", signal_id) + +void signals_init(void); +void signals_deinit(void); + #endif diff --git a/apps/irssi/src/core/special-vars.c b/apps/irssi/src/core/special-vars.c index 2556cd63..7291f469 100644 --- a/apps/irssi/src/core/special-vars.c +++ b/apps/irssi/src/core/special-vars.c @@ -106,7 +106,7 @@ static char *get_long_variable_value(const char *key, SERVER_REC *server, void *item, int *free_ret) { EXPANDO_FUNC func; - char *ret; + const char *ret; int type; *free_ret = FALSE; @@ -124,7 +124,7 @@ static char *get_long_variable_value(const char *key, SERVER_REC *server, /* environment variable? */ ret = g_getenv(key); if (ret != NULL) - return ret; + return (char *) ret; return NULL; } diff --git a/apps/irssi/src/fe-common/core/chat-completion.c b/apps/irssi/src/fe-common/core/chat-completion.c index 2c23a6ab..df5525eb 100644 --- a/apps/irssi/src/fe-common/core/chat-completion.c +++ b/apps/irssi/src/fe-common/core/chat-completion.c @@ -757,6 +757,17 @@ static void sig_complete_topic(GList **list, WINDOW_REC *window, } } +static void sig_complete_channel(GList **list, WINDOW_REC *window, + const char *word, const char *line, + int *want_space) +{ + g_return_if_fail(list != NULL); + g_return_if_fail(word != NULL); + + *list = completion_get_channels(NULL, word); + if (*list != NULL) signal_stop(); +} + /* expand \n, \t and \\ */ static char *expand_escapes(const char *line, SERVER_REC *server, WI_ITEM_REC *item) @@ -921,6 +932,7 @@ void chat_completion_init(void) signal_add("complete command connect", (SIGNAL_FUNC) sig_complete_connect); signal_add("complete command server", (SIGNAL_FUNC) sig_complete_connect); signal_add("complete command topic", (SIGNAL_FUNC) sig_complete_topic); + signal_add("complete command window item move", (SIGNAL_FUNC) sig_complete_channel); signal_add("message public", (SIGNAL_FUNC) sig_message_public); signal_add("message join", (SIGNAL_FUNC) sig_message_join); signal_add("message private", (SIGNAL_FUNC) sig_message_private); @@ -949,6 +961,7 @@ void chat_completion_deinit(void) signal_remove("complete command connect", (SIGNAL_FUNC) sig_complete_connect); signal_remove("complete command server", (SIGNAL_FUNC) sig_complete_connect); signal_remove("complete command topic", (SIGNAL_FUNC) sig_complete_topic); + signal_remove("complete command window item move", (SIGNAL_FUNC) sig_complete_channel); signal_remove("message public", (SIGNAL_FUNC) sig_message_public); signal_remove("message join", (SIGNAL_FUNC) sig_message_join); signal_remove("message private", (SIGNAL_FUNC) sig_message_private); diff --git a/apps/irssi/src/fe-common/core/completion.c b/apps/irssi/src/fe-common/core/completion.c index f10fbb6d..99046b9f 100644 --- a/apps/irssi/src/fe-common/core/completion.c +++ b/apps/irssi/src/fe-common/core/completion.c @@ -267,7 +267,8 @@ GList *filename_complete(const char *path, const char *default_path) GList *list; DIR *dirp; struct dirent *dp; - char *realpath, *dir, *basename, *name; + const char *basename; + char *realpath, *dir, *name; int len; g_return_val_if_fail(path != NULL, NULL); @@ -744,6 +745,7 @@ void completion_init(void) signal_add_first("complete erase", (SIGNAL_FUNC) sig_complete_erase); signal_add("complete command set", (SIGNAL_FUNC) sig_complete_set); signal_add("complete command toggle", (SIGNAL_FUNC) sig_complete_toggle); + signal_add("complete command load", (SIGNAL_FUNC) sig_complete_filename); signal_add("complete command cat", (SIGNAL_FUNC) sig_complete_filename); signal_add("complete command save", (SIGNAL_FUNC) sig_complete_filename); signal_add("complete command reload", (SIGNAL_FUNC) sig_complete_filename); @@ -762,6 +764,7 @@ void completion_deinit(void) signal_remove("complete erase", (SIGNAL_FUNC) sig_complete_erase); signal_remove("complete command set", (SIGNAL_FUNC) sig_complete_set); signal_remove("complete command toggle", (SIGNAL_FUNC) sig_complete_toggle); + signal_remove("complete command load", (SIGNAL_FUNC) sig_complete_filename); signal_remove("complete command cat", (SIGNAL_FUNC) sig_complete_filename); signal_remove("complete command save", (SIGNAL_FUNC) sig_complete_filename); signal_remove("complete command reload", (SIGNAL_FUNC) sig_complete_filename); diff --git a/apps/irssi/src/fe-common/core/fe-channels.c b/apps/irssi/src/fe-common/core/fe-channels.c index ec5d395b..27ad4365 100644 --- a/apps/irssi/src/fe-common/core/fe-channels.c +++ b/apps/irssi/src/fe-common/core/fe-channels.c @@ -67,7 +67,7 @@ static void signal_channel_destroyed(CHANNEL_REC *channel) window_item_destroy((WI_ITEM_REC *) channel); if (channel->joined && !channel->left && - channel->server != NULL) { + !channel->server->disconnected) { /* kicked out from channel */ window_bind_add(window, channel->server->tag, channel->name); @@ -132,21 +132,12 @@ static void cmd_join(const char *data, SERVER_REC *server) if (channel == NULL) return; + /* already joined to channel, set it active */ window = window_item_window(channel); + if (window != active_win) + window_set_active(window); - if (window == active_win) { - /* channel is in active window, set it active */ - window_item_set_active(active_win, - (WI_ITEM_REC *) channel); - } else { - /* notify user how to move the channel to active - window. this was used to be done automatically - but it just confused everyone who did it - accidentally */ - printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, - TXT_CHANNEL_MOVE_NOTIFY, channel->name, - window->refnum); - } + window_item_set_active(active_win, (WI_ITEM_REC *) channel); } static void cmd_wjoin_post(const char *data) diff --git a/apps/irssi/src/fe-common/core/fe-common-core.c b/apps/irssi/src/fe-common/core/fe-common-core.c index 89c17c7f..f356aa28 100644 --- a/apps/irssi/src/fe-common/core/fe-common-core.c +++ b/apps/irssi/src/fe-common/core/fe-common-core.c @@ -240,7 +240,7 @@ void fe_common_core_deinit(void) fe_queries_deinit(); fe_messages_deinit(); - fe_ignore_messages_init(); + fe_ignore_messages_deinit(); theme_unregister(); themes_deinit(); @@ -269,7 +269,7 @@ void glog_func(const char *log_domain, GLogLevelFlags log_level, } if (windows == NULL) - fprintf(stderr, "GLib %s: %s", reason, message); + fprintf(stderr, "GLib %s: %s\n", reason, message); else { printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_GLIB_ERROR, reason, message); diff --git a/apps/irssi/src/fe-common/core/fe-exec.c b/apps/irssi/src/fe-common/core/fe-exec.c index 033e6be6..4b7c9ae0 100644 --- a/apps/irssi/src/fe-common/core/fe-exec.c +++ b/apps/irssi/src/fe-common/core/fe-exec.c @@ -67,8 +67,7 @@ static EXEC_WI_REC *exec_wi_create(WINDOW_REC *window, PROCESS_REC *rec) item = g_new0(EXEC_WI_REC, 1); item->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "EXEC"); item->destroy = (void (*) (WI_ITEM_REC *)) exec_wi_destroy; - item->name = rec->name != NULL ? - g_strdup_printf("%%%s", rec->name) : + item->name = rec->name != NULL ? g_strdup(rec->name) : g_strdup_printf("%%%d", rec->id); item->createtime = time(NULL); @@ -406,7 +405,7 @@ static void handle_exec(const char *args, GHashTable *optlist, return; /* common options */ - target_channel = target_nick = FALSE; + target_channel = target_nick = FALSE; if (g_hash_table_lookup(optlist, "out") != NULL) { /* redirect output to active channel/query */ if (item == NULL) @@ -498,6 +497,7 @@ static void handle_exec(const char *args, GHashTable *optlist, rec->args = g_strdup(args); rec->notice = notice; rec->silent = g_hash_table_lookup(optlist, "-") != NULL; + rec->quiet = g_hash_table_lookup(optlist, "quiet") != NULL; rec->name = g_strdup(g_hash_table_lookup(optlist, "name")); level = g_hash_table_lookup(optlist, "level"); @@ -572,6 +572,9 @@ static void sig_exec_input(PROCESS_REC *rec, const char *text) SERVER_REC *server; char *str; + if (rec->quiet) + return; + item = NULL; server = NULL; @@ -620,7 +623,7 @@ static void event_text(const char *data, SERVER_REC *server, EXEC_WI_REC *item) void fe_exec_init(void) { command_bind("exec", NULL, (SIGNAL_FUNC) cmd_exec); - command_set_options("exec", "!- interactive nosh +name out +msg +notice +in window close +level"); + command_set_options("exec", "!- interactive nosh +name out +msg +notice +in window close +level quiet"); signal_exec_input = signal_get_uniq_id("exec input"); signal_add("pidwait", (SIGNAL_FUNC) sig_pidwait); diff --git a/apps/irssi/src/fe-common/core/fe-exec.h b/apps/irssi/src/fe-common/core/fe-exec.h index a3b7edee..606b2302 100644 --- a/apps/irssi/src/fe-common/core/fe-exec.h +++ b/apps/irssi/src/fe-common/core/fe-exec.h @@ -38,6 +38,7 @@ struct PROCESS_REC { unsigned int shell:1; /* start the program via /bin/sh */ unsigned int notice:1; /* send text with /notice, not /msg if target is set */ unsigned int silent:1; /* don't print "process exited with level xx" */ + unsigned int quiet:1; /* don't print process output at all */ unsigned int target_channel:1; /* target is a channel */ unsigned int target_nick:1; /* target is a nick */ }; diff --git a/apps/irssi/src/fe-common/core/fe-messages.c b/apps/irssi/src/fe-common/core/fe-messages.c index 4b4e4db4..48130103 100644 --- a/apps/irssi/src/fe-common/core/fe-messages.c +++ b/apps/irssi/src/fe-common/core/fe-messages.c @@ -396,7 +396,7 @@ static void sig_message_kick(SERVER_REC *server, const char *channel, const char *address, const char *reason) { printformat(server, channel, MSGLEVEL_KICKS, - TXT_KICK, nick, channel, kicker, reason); + TXT_KICK, nick, channel, kicker, reason, address); } static void print_nick_change_channel(SERVER_REC *server, const char *channel, @@ -415,7 +415,7 @@ static void print_nick_change_channel(SERVER_REC *server, const char *channel, printformat(server, channel, level, ownnick ? TXT_YOUR_NICK_CHANGED : TXT_NICK_CHANGED, - oldnick, newnick, channel); + oldnick, newnick, channel, address); } static void print_nick_change(SERVER_REC *server, const char *newnick, @@ -449,7 +449,8 @@ static void print_nick_change(SERVER_REC *server, const char *newnick, if (!msgprint && ownnick) { printformat(server, NULL, MSGLEVEL_NICKS, - TXT_YOUR_NICK_CHANGED, oldnick, newnick, ""); + TXT_YOUR_NICK_CHANGED, oldnick, newnick, "", + address); } } @@ -466,7 +467,8 @@ static void sig_message_own_nick(SERVER_REC *server, const char *newnick, print_nick_change(server, newnick, oldnick, address, TRUE); else { printformat(server, NULL, MSGLEVEL_NICKS, - TXT_YOUR_NICK_CHANGED, oldnick, newnick, ""); + TXT_YOUR_NICK_CHANGED, oldnick, newnick, "", + address); } } @@ -477,7 +479,7 @@ static void sig_message_invite(SERVER_REC *server, const char *channel, str = show_lowascii(channel); printformat(server, NULL, MSGLEVEL_INVITES, - TXT_INVITE, nick, str); + TXT_INVITE, nick, str, address); g_free(str); } @@ -487,7 +489,7 @@ static void sig_message_topic(SERVER_REC *server, const char *channel, { printformat(server, channel, MSGLEVEL_TOPICS, *topic != '\0' ? TXT_NEW_TOPIC : TXT_TOPIC_UNSET, - nick, channel, topic); + nick, channel, topic, address); } static int printnick_exists(NICK_REC *first, NICK_REC *ignore, diff --git a/apps/irssi/src/fe-common/core/fe-queries.c b/apps/irssi/src/fe-common/core/fe-queries.c index 1ea056e9..c6bfaef2 100644 --- a/apps/irssi/src/fe-common/core/fe-queries.c +++ b/apps/irssi/src/fe-common/core/fe-queries.c @@ -98,6 +98,10 @@ static void signal_query_destroyed(QUERY_REC *query) if (!query->unwanted) window_auto_destroy(window); + else { + /* eg. connection lost to dcc chat */ + window_bind_add(window, query->server->tag, query->name); + } } static void signal_query_server_changed(QUERY_REC *query) @@ -123,7 +127,8 @@ static void signal_query_nick_changed(QUERY_REC *query, const char *oldnick) /* don't print the nick change message if only the case was changed */ if (g_strcasecmp(query->name, oldnick) != 0) { printformat_dest(&dest, TXT_NICK_CHANGED, oldnick, - query->name, query->name); + query->name, query->name, + query->address == NULL ? "" : query->address); } signal_emit("window item changed", 2, @@ -247,22 +252,12 @@ static void cmd_query(const char *data, SERVER_REC *server, WI_ITEM_REC *item) query = CHAT_PROTOCOL(server)-> query_create(server->tag, nick, FALSE); else { - /* query already exists */ + /* query already exists, set it active */ WINDOW_REC *window = window_item_window(query); - if (window == active_win) { - /* query is in active window, set it active */ - window_item_set_active(active_win, - (WI_ITEM_REC *) query); - } else { - /* notify user how to move the query to active - window. this was used to be done automatically - but it just confused everyone who did it - accidentally */ - printformat_window(active_win, MSGLEVEL_CLIENTNOTICE, - TXT_QUERY_MOVE_NOTIFY, query->name, - window->refnum); - } + if (window != active_win) + window_set_active(window); + window_item_set_active(active_win, (WI_ITEM_REC *) query); } if (g_hash_table_lookup(optlist, "window") != NULL) { diff --git a/apps/irssi/src/fe-common/core/fe-windows.c b/apps/irssi/src/fe-common/core/fe-windows.c index 2370facb..af8e4297 100644 --- a/apps/irssi/src/fe-common/core/fe-windows.c +++ b/apps/irssi/src/fe-common/core/fe-windows.c @@ -109,9 +109,10 @@ void window_destroy(WINDOW_REC *window) window->destroying = TRUE; windows = g_slist_remove(windows, window); - if (active_win == window && windows != NULL) { - active_win = NULL; /* it's corrupted */ - window_set_active(windows->data); + if (active_win == window) { + active_win = NULL; /* it's corrupted */ + if (windows != NULL) + window_set_active(windows->data); } while (window->items != NULL) @@ -160,8 +161,8 @@ void window_set_active(WINDOW_REC *window) void window_change_server(WINDOW_REC *window, void *server) { - if (server != NULL && SERVER(server)->disconnected) - return; + if (server != NULL && SERVER(server)->disconnected) + return; window->active_server = server; signal_emit("window server changed", 2, window, server); @@ -194,7 +195,7 @@ void window_set_refnum(WINDOW_REC *window, int refnum) void window_set_name(WINDOW_REC *window, const char *name) { g_free_not_null(window->name); - window->name = g_strdup(name); + window->name = name == NULL || *name == '\0' ? NULL : g_strdup(name); signal_emit("window name changed", 1, window); } @@ -338,23 +339,11 @@ WINDOW_REC *window_find_item(SERVER_REC *server, const char *name) item = server == NULL ? NULL : window_item_find(server, name); - if (item == NULL && server == NULL) { + if (item == NULL) { /* not found from the active server - any server? */ item = window_item_find(NULL, name); } - if (item == NULL) { - char *chan; - - /* still nothing? maybe user just left the # in front of - channel, try again with it.. */ - chan = g_strdup_printf("#%s", name); - item = server == NULL ? NULL : - window_item_find(server, chan); - if (item == NULL) item = window_item_find(NULL, chan); - g_free(chan); - } - if (item == NULL) return 0; diff --git a/apps/irssi/src/fe-common/core/formats.c b/apps/irssi/src/fe-common/core/formats.c index e014583c..6941391e 100644 --- a/apps/irssi/src/fe-common/core/formats.c +++ b/apps/irssi/src/fe-common/core/formats.c @@ -169,6 +169,10 @@ int format_expand_styles(GString *out, const char **format, int *flags) g_string_append_c(out, 4); g_string_append_c(out, FORMAT_STYLE_CLRTOEOL); break; + case '#': + g_string_append_c(out, 4); + g_string_append_c(out, FORMAT_STYLE_MONOSPACE); + break; case '[': /* code */ format_expand_code(format, out, flags); @@ -224,7 +228,7 @@ void format_read_arglist(va_list va, FORMAT_REC *format, case FORMAT_STRING: arglist[num] = (char *) va_arg(va, char *); if (arglist[num] == NULL) { - g_warning("format_read_arglist() : parameter %d is NULL", num); + g_warning("format_read_arglist(%s) : parameter %d is NULL", format->tag, num); arglist[num] = ""; } break; @@ -703,7 +707,7 @@ void format_newline(WINDOW_REC *window) signal_emit_id(signal_gui_print_text, 6, window, GINT_TO_POINTER(-1), GINT_TO_POINTER(-1), GINT_TO_POINTER(GUI_PRINT_FLAG_NEWLINE), - "", GINT_TO_POINTER(-1)); + "", NULL); } /* parse ANSI color string */ @@ -956,7 +960,7 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text) GINT_TO_POINTER(fgcolor), GINT_TO_POINTER(bgcolor), GINT_TO_POINTER(flags), str, - dest->level); + dest); flags &= ~(GUI_PRINT_FLAG_INDENT|GUI_PRINT_FLAG_CLRTOEOL); } @@ -997,6 +1001,9 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text) case FORMAT_STYLE_REVERSE: flags ^= GUI_PRINT_FLAG_REVERSE; break; + case FORMAT_STYLE_MONOSPACE: + flags ^= GUI_PRINT_FLAG_MONOSPACE; + break; case FORMAT_STYLE_INDENT: flags |= GUI_PRINT_FLAG_INDENT; break; @@ -1009,13 +1016,13 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text) signal_emit_id(signal_gui_print_text, 6, dest->window, NULL, NULL, GINT_TO_POINTER(GUI_PRINT_FLAG_INDENT_FUNC), - str, start, dest->level); + str, start, dest); break; } case FORMAT_STYLE_DEFAULTS: fgcolor = theme->default_color; bgcolor = -1; - flags &= GUI_PRINT_FLAG_INDENT; + flags &= GUI_PRINT_FLAG_INDENT|GUI_PRINT_FLAG_MONOSPACE; break; case FORMAT_STYLE_CLRTOEOL: break; @@ -1056,7 +1063,7 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text) /* remove all styling */ fgcolor = theme->default_color; bgcolor = -1; - flags &= GUI_PRINT_FLAG_INDENT; + flags &= GUI_PRINT_FLAG_INDENT|GUI_PRINT_FLAG_MONOSPACE; break; case 22: /* reverse */ diff --git a/apps/irssi/src/fe-common/core/formats.h b/apps/irssi/src/fe-common/core/formats.h index 4d459c1c..7dbdd904 100644 --- a/apps/irssi/src/fe-common/core/formats.h +++ b/apps/irssi/src/fe-common/core/formats.h @@ -13,6 +13,7 @@ #define GUI_PRINT_FLAG_INDENT_FUNC 0x0040 #define GUI_PRINT_FLAG_NEWLINE 0x0080 #define GUI_PRINT_FLAG_CLRTOEOL 0x0100 +#define GUI_PRINT_FLAG_MONOSPACE 0x0200 #define MAX_FORMAT_PARAMS 10 #define DEFAULT_FORMAT_ARGLIST_SIZE 200 @@ -42,7 +43,7 @@ struct _FORMAT_REC { #define PRINT_FLAG_SET_SERVERTAG 0x0010 #define PRINT_FLAG_UNSET_SERVERTAG 0x0020 -typedef struct { +typedef struct _TEXT_DEST_REC { WINDOW_REC *window; SERVER_REC *server; const char *server_tag; /* if server is non-NULL, must be server->tag */ @@ -131,6 +132,7 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text); #define FORMAT_STYLE_INDENT_FUNC (0x06 + FORMAT_STYLE_SPECIAL) #define FORMAT_STYLE_DEFAULTS (0x07 + FORMAT_STYLE_SPECIAL) #define FORMAT_STYLE_CLRTOEOL (0x08 + FORMAT_STYLE_SPECIAL) +#define FORMAT_STYLE_MONOSPACE (0x09 + FORMAT_STYLE_SPECIAL) int format_expand_styles(GString *out, const char **format, int *flags); void formats_init(void); diff --git a/apps/irssi/src/fe-common/core/keyboard.c b/apps/irssi/src/fe-common/core/keyboard.c index 3c0efade..fb1d89fe 100644 --- a/apps/irssi/src/fe-common/core/keyboard.c +++ b/apps/irssi/src/fe-common/core/keyboard.c @@ -44,7 +44,7 @@ static char used_keys[256]; static GTree *key_states; static int key_config_frozen; -struct KEYBOARD_REC { +struct _KEYBOARD_REC { char *key_state; /* the ongoing key combo */ void *gui_data; /* GUI specific data sent in "key pressed" signal */ }; @@ -193,7 +193,7 @@ static int expand_combo(const char *start, const char *end, GSList **out) KEY_REC *rec; KEYINFO_REC *info; GSList *tmp, *tmp2, *list, *copy, *newout; - char *str; + char *str, *p; if (start == end) { /* single key */ @@ -214,10 +214,16 @@ static int expand_combo(const char *start, const char *end, GSList **out) if (strcmp(rec->data, str) == 0) list = g_slist_append(list, rec); } - g_free(str); - if (list == NULL) - return FALSE; + if (list == NULL) { + /* unknown keycombo - add it as-is, maybe the GUI will + feed it to us as such */ + for (p = str; *p != '\0'; p++) + expand_out_char(*out, *p); + g_free(str); + return TRUE; + } + g_free(str); if (list->next == NULL) { /* only one way to generate the combo, good */ @@ -563,6 +569,9 @@ int key_pressed(KEYBOARD_REC *keyboard, const char *key) g_strconcat(keyboard->key_state, "-", key, NULL); g_free_and_null(keyboard->key_state); +#if GLIB_MAJOR_VERSION == 2 +# define GSearchFunc GCompareFunc +#endif rec = g_tree_search(key_states, (GSearchFunc) key_states_search, combo); @@ -642,6 +651,8 @@ static void cmd_show_keys(const char *searchkey, int full) GSList *info, *key; int len; + printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_BIND_HEADER); + len = searchkey == NULL ? 0 : strlen(searchkey); for (info = keyinfos; info != NULL; info = info->next) { KEYINFO_REC *rec = info->data; @@ -651,11 +662,13 @@ static void cmd_show_keys(const char *searchkey, int full) if ((len == 0 || g_strncasecmp(rec->key, searchkey, len) == 0) && (!full || rec->key[len] == '\0')) { - printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_BIND_KEY, + printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_BIND_LIST, rec->key, rec->info->id, rec->data == NULL ? "" : rec->data); } } } + + printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_BIND_FOOTER); } /* SYNTAX: BIND [-delete] [ [ []]] */ @@ -833,6 +846,11 @@ void keyboard_init(void) void keyboard_deinit(void) { + key_unbind("command", (SIGNAL_FUNC) sig_command); + key_unbind("key", (SIGNAL_FUNC) sig_key); + key_unbind("multi", (SIGNAL_FUNC) sig_multi); + key_unbind("nothing", (SIGNAL_FUNC) sig_nothing); + while (keyinfos != NULL) keyinfo_remove(keyinfos->data); g_hash_table_destroy(keys); diff --git a/apps/irssi/src/fe-common/core/keyboard.h b/apps/irssi/src/fe-common/core/keyboard.h index 9f2652e0..c508d53b 100644 --- a/apps/irssi/src/fe-common/core/keyboard.h +++ b/apps/irssi/src/fe-common/core/keyboard.h @@ -3,7 +3,7 @@ #include "signals.h" -typedef struct KEYBOARD_REC KEYBOARD_REC; +typedef struct _KEYBOARD_REC KEYBOARD_REC; typedef struct { char *id; diff --git a/apps/irssi/src/fe-common/core/module-formats.c b/apps/irssi/src/fe-common/core/module-formats.c index 690ae737..223eb3ac 100644 --- a/apps/irssi/src/fe-common/core/module-formats.c +++ b/apps/irssi/src/fe-common/core/module-formats.c @@ -42,28 +42,28 @@ FORMAT_REC fecommon_core_formats[] = { { "window_set_immortal", "Window is now immortal", 0 }, { "window_unset_immortal", "Window isn't immortal anymore", 0 }, { "window_immortal_error", "Window is immortal, if you really want to close it, say /WINDOW IMMORTAL OFF", 0 }, - { "windowlist_header", "Ref Name Active item Server Level", 0 }, - { "windowlist_line", "$[3]0 %|$[20]1 $[15]2 $[15]3 $4", 5, { 1, 0, 0, 0, 0 } }, + { "windowlist_header", "%#Ref Name Active item Server Level", 0 }, + { "windowlist_line", "%#$[3]0 %|$[20]1 $[15]2 $[15]3 $4", 5, { 1, 0, 0, 0, 0 } }, { "windowlist_footer", "", 0 }, { "windows_layout_saved", "Layout of windows is now remembered next time you start irssi", 0 }, { "windows_layout_reset", "Layout of windows reset to defaults", 0 }, { "window_info_header", "", 0 }, { "window_info_footer", "", 0 }, - { "window_info_refnum", "Window : {hilight #$0}", 1, { 1 } }, - { "window_info_refnum_sticky", "Window : {hilight #$0 (sticky)}", 1, { 1 } }, - { "window_info_name", "Name : $0", 1, { 0 } }, - { "window_info_history", "History : $0", 1, { 0 } }, - { "window_info_immortal", "Immortal: yes", 0 }, - { "window_info_size", "Size : $0x$1", 2, { 1, 1 } }, - { "window_info_level", "Level : $0", 1, { 0 } }, - { "window_info_server", "Server : $0", 1, { 0 } }, - { "window_info_server_sticky", "Server : $0 (sticky)", 1, { 0 } }, - { "window_info_theme", "Theme : $0$1", 2, { 0, 0 } }, - { "window_info_bound_items_header", "Bounds : {hilight Name Server tag}", 0 }, - { "window_info_bound_item", " : $[!30]0 $[!15]1 $2", 3, { 0, 0, 0 } }, + { "window_info_refnum", "%#Window : {hilight #$0}", 1, { 1 } }, + { "window_info_refnum_sticky", "%#Window : {hilight #$0 (sticky)}", 1, { 1 } }, + { "window_info_name", "%#Name : $0", 1, { 0 } }, + { "window_info_history", "%#History : $0", 1, { 0 } }, + { "window_info_immortal", "%#Immortal: yes", 0 }, + { "window_info_size", "%#Size : $0x$1", 2, { 1, 1 } }, + { "window_info_level", "%#Level : $0", 1, { 0 } }, + { "window_info_server", "%#Server : $0", 1, { 0 } }, + { "window_info_server_sticky", "%#Server : $0 (sticky)", 1, { 0 } }, + { "window_info_theme", "%#Theme : $0$1", 2, { 0, 0 } }, + { "window_info_bound_items_header", "%#Bounds : {hilight Name Server tag}", 0 }, + { "window_info_bound_item", "%# : $[!30]0 $[!15]1 $2", 3, { 0, 0, 0 } }, { "window_info_bound_items_footer", "", 0 }, - { "window_info_items_header", "Items : {hilight Name Server tag}", 0 }, - { "window_info_item", " $[7]0: $[!30]1 $2", 3, { 0, 0, 0 } }, + { "window_info_items_header", "%#Items : {hilight Name Server tag}", 0 }, + { "window_info_item", "%# $[7]0: $[!30]1 $2", 3, { 0, 0, 0 } }, { "window_info_items_footer", "", 0 }, /* ---- */ @@ -95,34 +95,33 @@ FORMAT_REC fecommon_core_formats[] = { { "join", "{channick_hilight $0} {chanhost_hilight $1} has joined {channel $2}", 3, { 0, 0, 0 } }, { "part", "{channick $0} {chanhost $1} has left {channel $2} {reason $3}", 4, { 0, 0, 0, 0 } }, - { "kick", "{channick $0} was kicked from {channel $1} by {nick $2} {reason $3}", 4, { 0, 0, 0, 0 } }, + { "kick", "{channick $0} was kicked from {channel $1} by {nick $2} {reason $3}", 5, { 0, 0, 0, 0, 0 } }, { "quit", "{channick $0} {chanhost $1} has quit {reason $2}", 4, { 0, 0, 0, 0 } }, { "quit_once", "{channel $3} {channick $0} {chanhost $1} has quit {reason $2}", 4, { 0, 0, 0, 0 } }, - { "invite", "{nick $0} invites you to {channel $1}", 2, { 0, 0 } }, + { "invite", "{nick $0} invites you to {channel $1}", 3, { 0, 0, 0 } }, { "not_invited", "You have not been invited to a channel!", 0 }, - { "new_topic", "{nick $0} changed the topic of {channel $1} to: $2", 3, { 0, 0, 0 } }, - { "topic_unset", "Topic unset by {nick $0} on {channel $1}", 2, { 0, 0 } }, - { "your_nick_changed", "You're now known as {nick $1}", 3, { 0, 0, 0 } }, - { "nick_changed", "{channick $0} is now known as {channick_hilight $1}", 3, { 0, 0, 0 } }, + { "new_topic", "{nick $0} changed the topic of {channel $1} to: $2", 4, { 0, 0, 0, 0 } }, + { "topic_unset", "Topic unset by {nick $0} on {channel $1}", 4, { 0, 0, 0, 0 } }, + { "your_nick_changed", "You're now known as {nick $1}", 4, { 0, 0, 0, 0 } }, + { "nick_changed", "{channick $0} is now known as {channick_hilight $1}", 4, { 0, 0, 0, 0 } }, { "talking_in", "You are now talking in {channel $0}", 1, { 0 } }, { "not_in_channels", "You are not on any channels", 0 }, { "current_channel", "Current channel {channel $0}", 1, { 0 } }, { "names", "{names_users Users {names_channel $0}}", 6, { 0, 1, 1, 1, 1, 1 } }, - { "names_prefix", "{names_prefix $0}", 1, { 0 } }, + { "names_prefix", "%#{names_prefix $0}", 1, { 0 } }, { "names_nick_op", "{names_nick_op $0 $1}", 2, { 0, 0 } }, { "names_nick_halfop", "{names_nick_halfop $0 $1}", 2, { 0, 0 } }, { "names_nick_voice", "{names_nick_voice $0 $1}", 2, { 0, 0 } }, { "names_nick", "{names_nick $0 $1}", 2, { 0, 0 } }, { "endofnames", "{channel $0}: Total of {hilight $1} nicks {comment {hilight $2} ops, {hilight $3} halfops, {hilight $4} voices, {hilight $5} normal}", 6, { 0, 1, 1, 1, 1, 1 } }, - { "chanlist_header", "You are on the following channels:", 0 }, - { "chanlist_line", "{channel $[-10]0} %|+$1 ($2): $3", 4, { 0, 0, 0, 0 } }, + { "chanlist_header", "%#You are on the following channels:", 0 }, + { "chanlist_line", "%#{channel $[-10]0} %|+$1 ($2): $3", 4, { 0, 0, 0, 0 } }, { "chansetup_not_found", "Channel {channel $0} not found", 2, { 0, 0 } }, { "chansetup_added", "Channel {channel $0} saved", 2, { 0, 0 } }, { "chansetup_removed", "Channel {channel $0} removed", 2, { 0, 0 } }, - { "chansetup_header", "Channel Network Password Settings", 0 }, - { "chansetup_line", "{channel $[15]0} %|$[10]1 $[10]2 $3", 4, { 0, 0, 0, 0 } }, + { "chansetup_header", "%#Channel Network Password Settings", 0 }, + { "chansetup_line", "%#{channel $[15]0} %|$[10]1 $[10]2 $3", 4, { 0, 0, 0, 0 } }, { "chansetup_footer", "", 0 }, - { "channel_move_notify", "{channel $0} is already joined in window $1, use \"/WINDOW ITEM MOVE $0\" to move it to this window", 2, { 0, 1 } }, /* ---- */ { NULL, "Messages", 0 }, @@ -149,13 +148,12 @@ FORMAT_REC fecommon_core_formats[] = { { "query_stop", "Closing query with {nick $0}", 1, { 0 } }, { "no_query", "No query with {nick $0}", 1, { 0 } }, { "query_server_changed", "Query with {nick $0} changed to server {server $1}", 2, { 0, 0 } }, - { "query_move_notify", "Query with {nick $0} is already created to window $1, use \"/WINDOW ITEM MOVE $0\" to move it to this window", 2, { 0, 1 } }, /* ---- */ { NULL, "Highlighting", 0 }, - { "hilight_header", "Highlights:", 0 }, - { "hilight_line", "$[-4]0 $1 $2 $3$4$5", 7, { 1, 0, 0, 0, 0, 0, 0 } }, + { "hilight_header", "%#Highlights:", 0 }, + { "hilight_line", "%#$[-4]0 $1 $2 $3$4$5", 7, { 1, 0, 0, 0, 0, 0, 0 } }, { "hilight_footer", "", 0 }, { "hilight_not_found", "Highlight not found: $0", 1, { 0 } }, { "hilight_removed", "Highlight removed: $0", 1, { 0 } }, @@ -166,8 +164,8 @@ FORMAT_REC fecommon_core_formats[] = { { "alias_added", "Alias $0 added", 1, { 0 } }, { "alias_removed", "Alias $0 removed", 1, { 0 } }, { "alias_not_found", "No such alias: $0", 1, { 0 } }, - { "aliaslist_header", "Aliases:", 0 }, - { "aliaslist_line", "$[10]0 $1", 2, { 0, 0 } }, + { "aliaslist_header", "%#Aliases:", 0 }, + { "aliaslist_line", "%#$[10]0 $1", 2, { 0, 0 } }, { "aliaslist_footer", "", 0 }, /* ---- */ @@ -180,8 +178,8 @@ FORMAT_REC fecommon_core_formats[] = { { "log_not_open", "Log file {hilight $0} not open", 1, { 0 } }, { "log_started", "Started logging to file {hilight $0}", 1, { 0 } }, { "log_stopped", "Stopped logging to file {hilight $0}", 1, { 0 } }, - { "log_list_header", "Logs:", 0 }, - { "log_list", "$0 $1: $2 $3$4", 5, { 1, 0, 0, 0, 0, 0 } }, + { "log_list_header", "%#Logs:", 0 }, + { "log_list", "%#$0 $1: $2 $3$4", 5, { 1, 0, 0, 0, 0, 0 } }, { "log_list_footer", "", 0 }, { "windowlog_file", "Window LOGFILE set to $0", 1, { 0 } }, { "windowlog_file_logging", "Can't change window's logfile while log is on", 0 }, @@ -191,8 +189,8 @@ FORMAT_REC fecommon_core_formats[] = { /* ---- */ { NULL, "Modules", 0 }, - { "module_header", "Module Type Submodules", 0, }, - { "module_line", "$[!20]0 $[7]1 $2", 3, { 0, 0, 0 } }, + { "module_header", "%#Module Type Submodules", 0, }, + { "module_line", "%#$[!20]0 $[7]1 $2", 3, { 0, 0, 0 } }, { "module_footer", "", 0, }, { "module_already_loaded", "Module {hilight $0/$1} already loaded", 2, { 0, 0 } }, { "module_not_loaded", "Module {hilight $0/$1} is not loaded", 2, { 0, 0 } }, @@ -239,8 +237,8 @@ FORMAT_REC fecommon_core_formats[] = { { "unignored", "Unignored {nick $0}", 1, { 0 } }, { "ignore_not_found", "{nick $0} is not being ignored", 1, { 0 } }, { "ignore_no_ignores", "There are no ignores", 0 }, - { "ignore_header", "Ignorance List:", 0 }, - { "ignore_line", "$[-4]0 $1: $2 $3 $4", 4, { 1, 0, 0, 0 } }, + { "ignore_header", "%#Ignorance List:", 0 }, + { "ignore_line", "%#$[-4]0 $1: $2 $3 $4", 4, { 1, 0, 0, 0 } }, { "ignore_footer", "", 0 }, /* ---- */ @@ -250,12 +248,14 @@ FORMAT_REC fecommon_core_formats[] = { { "unknown_chatnet", "Unknown chat network: $0 (create it with /IRCNET ADD)", 1, { 0 } }, { "not_toggle", "Value must be either ON, OFF or TOGGLE", 0 }, { "perl_error", "Perl error: $0", 1, { 0 } }, - { "bind_key", "$[!20]0 $1 $2", 3, { 0, 0, 0 } }, + { "bind_header", "%#Key Action", 0 }, + { "bind_list", "%#$[!20]0 $1 $2", 3, { 0, 0, 0 } }, + { "bind_footer", "", 0 }, { "bind_unknown_id", "Unknown bind action: $0", 1, { 0 } }, { "config_saved", "Saved configuration to file $0", 1, { 0 } }, { "config_reloaded", "Reloaded configuration", 1, { 0 } }, { "config_modified", "Configuration file was modified since irssi was last started - do you want to overwrite the possible changes?", 1, { 0 } }, - { "glib_error", "{error GLib $0} $1", 2, { 0, 0 } }, + { "glib_error", "{error $0} $1", 2, { 0, 0 } }, { "overwrite_config", "Overwrite config (y/N)?", 0 }, { "set_title", "[{hilight $0}]", 1, { 0 } }, { "set_item", "$0 = $1", 2, { 0, 0 } }, diff --git a/apps/irssi/src/fe-common/core/module-formats.h b/apps/irssi/src/fe-common/core/module-formats.h index 6ef7043c..e4d74461 100644 --- a/apps/irssi/src/fe-common/core/module-formats.h +++ b/apps/irssi/src/fe-common/core/module-formats.h @@ -98,7 +98,6 @@ enum { TXT_CHANSETUP_HEADER, TXT_CHANSETUP_LINE, TXT_CHANSETUP_FOOTER, - TXT_CHANNEL_MOVE_NOTIFY, TXT_FILL_4, @@ -123,7 +122,6 @@ enum { TXT_QUERY_STOP, TXT_NO_QUERY, TXT_QUERY_SERVER_CHANGED, - TXT_QUERY_MOVE_NOTIFY, TXT_FILL_6, @@ -216,7 +214,9 @@ enum { TXT_UNKNOWN_CHATNET, TXT_NOT_TOGGLE, TXT_PERL_ERROR, - TXT_BIND_KEY, + TXT_BIND_HEADER, + TXT_BIND_LIST, + TXT_BIND_FOOTER, TXT_BIND_UNKNOWN_ID, TXT_CONFIG_SAVED, TXT_CONFIG_RELOADED, diff --git a/apps/irssi/src/fe-common/core/window-commands.c b/apps/irssi/src/fe-common/core/window-commands.c index 2accad9d..bbe495aa 100644 --- a/apps/irssi/src/fe-common/core/window-commands.c +++ b/apps/irssi/src/fe-common/core/window-commands.c @@ -427,7 +427,12 @@ static void cmd_window_server(const char *data) static void cmd_window_item(const char *data, void *server, WI_ITEM_REC *item) { - command_runsub("window item", data, server, item); + while (*data == ' ') data++; + + if (is_numeric(data, '\0')) + signal_emit("command window item goto", 3, data, server, item); + else + command_runsub("window item", data, server, item); } /* SYNTAX: WINDOW ITEM PREV */ @@ -442,12 +447,20 @@ static void cmd_window_item_next(void) window_item_next(active_win); } -/* SYNTAX: WINDOW ITEM GOTO */ +/* SYNTAX: WINDOW ITEM GOTO | */ static void cmd_window_item_goto(const char *data, SERVER_REC *server) { - WI_ITEM_REC *item; + WI_ITEM_REC *item; + GSList *tmp; + + if (is_numeric(data, '\0')) { + /* change to specified number */ + tmp = g_slist_nth(active_win->items, atoi(data)-1); + item = tmp == NULL ? NULL : tmp->data; + } else { + item = window_item_find_window(active_win, server, data); + } - item = window_item_find_window(active_win, server, data); if (item != NULL) window_item_set_active(active_win, item); } @@ -510,7 +523,8 @@ static void cmd_window_name(const char *data) { if (window_find_name(data) == NULL) window_set_name(active_win, data); - else { + else if (active_win->name == NULL || + strcmp(active_win->name, data) != 0) { printformat_window(active_win, MSGLEVEL_CLIENTERROR, TXT_WINDOW_NAME_NOT_UNIQUE, data); } diff --git a/apps/irssi/src/fe-common/core/windows-layout.c b/apps/irssi/src/fe-common/core/windows-layout.c index 5d53f1ae..a19b2942 100644 --- a/apps/irssi/src/fe-common/core/windows-layout.c +++ b/apps/irssi/src/fe-common/core/windows-layout.c @@ -132,36 +132,39 @@ static void sig_layout_restore(void) } } -static void window_save_items(WINDOW_REC *window, CONFIG_NODE *node) +static void sig_layout_save_item(WINDOW_REC *window, WI_ITEM_REC *item, + CONFIG_NODE *node) { CONFIG_NODE *subnode; - GSList *tmp; const char *type; - node = config_node_section(node, "items", NODE_TYPE_LIST); - for (tmp = window->items; tmp != NULL; tmp = tmp->next) { - WI_ITEM_REC *rec = tmp->data; - SERVER_REC *server = rec->server; - - type = module_find_id_str("WINDOW ITEM TYPE", rec->type); - if (type == NULL) continue; + type = module_find_id_str("WINDOW ITEM TYPE", item->type); + if (type == NULL) + return; - subnode = config_node_section(node, NULL, NODE_TYPE_BLOCK); + subnode = config_node_section(node, NULL, NODE_TYPE_BLOCK); - iconfig_node_set_str(subnode, "type", type); - type = chat_protocol_find_id(rec->chat_type)->name; - iconfig_node_set_str(subnode, "chat_type", type); - iconfig_node_set_str(subnode, "name", rec->name); + iconfig_node_set_str(subnode, "type", type); + type = chat_protocol_find_id(item->chat_type)->name; + iconfig_node_set_str(subnode, "chat_type", type); + iconfig_node_set_str(subnode, "name", item->name); - if (server != NULL) - iconfig_node_set_str(subnode, "tag", server->tag); - else if (IS_QUERY(rec)) { - iconfig_node_set_str(subnode, "tag", - QUERY(rec)->server_tag); - } + if (item->server != NULL) + iconfig_node_set_str(subnode, "tag", item->server->tag); + else if (IS_QUERY(item)) { + iconfig_node_set_str(subnode, "tag", QUERY(item)->server_tag); } } +static void window_save_items(WINDOW_REC *window, CONFIG_NODE *node) +{ + GSList *tmp; + + node = config_node_section(node, "items", NODE_TYPE_LIST); + for (tmp = window->items; tmp != NULL; tmp = tmp->next) + signal_emit("layout save item", 3, window, tmp->data, node); +} + static void window_save(WINDOW_REC *window, CONFIG_NODE *node) { char refnum[MAX_INT_STRLEN]; @@ -224,10 +227,12 @@ void windows_layout_init(void) { signal_add("layout restore item", (SIGNAL_FUNC) sig_layout_restore_item); signal_add("layout restore", (SIGNAL_FUNC) sig_layout_restore); + signal_add("layout save item", (SIGNAL_FUNC) sig_layout_save_item); } void windows_layout_deinit(void) { signal_remove("layout restore item", (SIGNAL_FUNC) sig_layout_restore_item); signal_remove("layout restore", (SIGNAL_FUNC) sig_layout_restore); + signal_remove("layout save item", (SIGNAL_FUNC) sig_layout_save_item); } diff --git a/apps/irssi/src/fe-text/gui-printtext.c b/apps/irssi/src/fe-text/gui-printtext.c index 429937a5..2d8a8cde 100644 --- a/apps/irssi/src/fe-text/gui-printtext.c +++ b/apps/irssi/src/fe-text/gui-printtext.c @@ -231,7 +231,7 @@ static void view_add_eol(TEXT_BUFFER_VIEW_REC *view, LINE_REC **line) static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor, void *bgcolor, void *pflags, - char *str, void *level) + char *str, TEXT_DEST_REC *dest) { GUI_WINDOW_REC *gui; TEXT_BUFFER_VIEW_REC *view; @@ -259,7 +259,7 @@ static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor, return; } - lineinfo.level = GPOINTER_TO_INT(level); + lineinfo.level = dest == NULL ? 0 : dest->level; lineinfo.time = time(NULL); gui = WINDOW_GUI(window); diff --git a/apps/irssi/src/fe-text/gui-readline.c b/apps/irssi/src/fe-text/gui-readline.c index 145273b7..c23b42c7 100644 --- a/apps/irssi/src/fe-text/gui-readline.c +++ b/apps/irssi/src/fe-text/gui-readline.c @@ -665,11 +665,11 @@ void gui_readline_init(void) /* window managing */ key_bind("previous_window", "Previous window", "^P", NULL, (SIGNAL_FUNC) key_previous_window); - key_bind("left_window", "Window in left", "meta-left", NULL, (SIGNAL_FUNC) key_left_window); key_bind("next_window", "Next window", "^N", NULL, (SIGNAL_FUNC) key_next_window); - key_bind("right_window", "Window in right", "meta-right", NULL, (SIGNAL_FUNC) key_right_window); key_bind("upper_window", "Upper window", "meta-up", NULL, (SIGNAL_FUNC) key_upper_window); key_bind("lower_window", "Lower window", "meta-down", NULL, (SIGNAL_FUNC) key_lower_window); + key_bind("left_window", "Window in left", "meta-left", NULL, (SIGNAL_FUNC) key_left_window); + key_bind("right_window", "Window in right", "meta-right", NULL, (SIGNAL_FUNC) key_right_window); key_bind("active_window", "Go to next window with the highest activity", "meta-a", NULL, (SIGNAL_FUNC) key_active_window); key_bind("next_window_item", "Next channel/query", "^X", NULL, (SIGNAL_FUNC) key_next_window_item); key_bind("previous_window_item", "Previous channel/query", NULL, NULL, (SIGNAL_FUNC) key_previous_window_item); @@ -737,13 +737,17 @@ void gui_readline_deinit(void) key_unbind("yank_from_cutbuffer", (SIGNAL_FUNC) key_yank_from_cutbuffer); key_unbind("transpose_characters", (SIGNAL_FUNC) key_transpose_characters); + key_unbind("send_line", (SIGNAL_FUNC) key_send_line); key_unbind("word_completion", (SIGNAL_FUNC) key_word_completion); + key_unbind("erase_completion", (SIGNAL_FUNC) key_erase_completion); key_unbind("check_replaces", (SIGNAL_FUNC) key_check_replaces); key_unbind("previous_window", (SIGNAL_FUNC) key_previous_window); key_unbind("next_window", (SIGNAL_FUNC) key_next_window); key_unbind("upper_window", (SIGNAL_FUNC) key_upper_window); key_unbind("lower_window", (SIGNAL_FUNC) key_lower_window); + key_unbind("left_window", (SIGNAL_FUNC) key_left_window); + key_unbind("right_window", (SIGNAL_FUNC) key_right_window); key_unbind("active_window", (SIGNAL_FUNC) key_active_window); key_unbind("next_window_item", (SIGNAL_FUNC) key_next_window_item); key_unbind("previous_window_item", (SIGNAL_FUNC) key_previous_window_item); diff --git a/apps/irssi/src/fe-text/module-formats.c b/apps/irssi/src/fe-text/module-formats.c index f236d900..79e9dc2b 100644 --- a/apps/irssi/src/fe-text/module-formats.c +++ b/apps/irssi/src/fe-text/module-formats.c @@ -45,25 +45,25 @@ FORMAT_REC gui_text_formats[] = { "window_not_sticky", "Window is not sticky", 0 }, { "window_set_sticky", "Window set sticky", 0 }, { "window_unset_sticky", "Window is not sticky anymore", 0 }, - { "window_info_sticky", "Sticky : $0", 1, { 0 } }, - { "window_info_scroll", "Scroll : $0", 1, { 0 } }, + { "window_info_sticky", "%#Sticky : $0", 1, { 0 } }, + { "window_info_scroll", "%#Scroll : $0", 1, { 0 } }, { "window_scroll", "Window scroll mode is now $0", 1, { 0 } }, { "window_scroll_unknown", "Unknown scroll mode $0, must be ON, OFF or DEFAULT", 1, { 0 } }, /* ---- */ { NULL, "Statusbars", 0 }, - { "statusbar_list_header", "Name Type Placement Position Visible", 0 }, + { "statusbar_list_header", "%#Name Type Placement Position Visible", 0 }, { "statusbar_list_footer", "", 0 }, - { "statusbar_list", "$[30]0 $[6]1 $[9]2 $[8]3 $4", 5, { 0, 0, 0, 1, 0 } }, - { "statusbar_info_name", "Statusbar: {hilight $0}", 1, { 0 } }, - { "statusbar_info_type", "Type : $0", 1, { 0 } }, - { "statusbar_info_placement", "Placement: $0", 1, { 0 } }, - { "statusbar_info_position", "Position : $0", 1, { 1 } }, - { "statusbar_info_visible", "Visible : $0", 1, { 0 } }, - { "statusbar_info_item_header", "Items : Name Priority Alignment", 0 }, + { "statusbar_list", "%#$[30]0 $[6]1 $[9]2 $[8]3 $4", 5, { 0, 0, 0, 1, 0 } }, + { "statusbar_info_name", "%#Statusbar: {hilight $0}", 1, { 0 } }, + { "statusbar_info_type", "%#Type : $0", 1, { 0 } }, + { "statusbar_info_placement", "%#Placement: $0", 1, { 0 } }, + { "statusbar_info_position", "%#Position : $0", 1, { 1 } }, + { "statusbar_info_visible", "%#Visible : $0", 1, { 0 } }, + { "statusbar_info_item_header", "%#Items : Name Priority Alignment", 0 }, { "statusbar_info_item_footer", "", 0 }, - { "statusbar_info_item_name", " : $[35]0 $[9]1 $2", 3, { 0, 1, 0 } }, + { "statusbar_info_item_name", "%# : $[35]0 $[9]1 $2", 3, { 0, 1, 0 } }, { "statusbar_not_found", "Statusbar doesn't exist: $0", 1, { 0 } }, { "statusbar_not_found", "Statusbar doesn't exist: $0", 1, { 0 } }, { "statusbar_item_not_found", "Statusbar item doesn't exist: $0", 1, { 0 } }, diff --git a/apps/irssi/src/fe-text/statusbar.c b/apps/irssi/src/fe-text/statusbar.c index 9d39ede7..5ad86998 100644 --- a/apps/irssi/src/fe-text/statusbar.c +++ b/apps/irssi/src/fe-text/statusbar.c @@ -859,8 +859,11 @@ static void statusbar_item_default_signals(SBAR_ITEM_REC *item) func = NULL; break; } - if (func != NULL) - signal_add_to_id(MODULE_NAME, 1, *pos, func); + if (func != NULL) { + signal_add_full_id(MODULE_NAME, + SIGNAL_PRIORITY_DEFAULT, + *pos, func, NULL); + } } if (g_slist_find(list, item) == NULL) @@ -911,10 +914,10 @@ SBAR_ITEM_REC *statusbar_item_create(STATUSBAR_REC *bar, static void statusbar_signal_remove(int signal_id) { - signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_item); - signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_server); - signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_window); - signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_window_item); + signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_item, NULL); + signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_server, NULL); + signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_window, NULL); + signal_remove_id(signal_id, (SIGNAL_FUNC) statusbar_update_window_item, NULL); } static void statusbar_item_remove_signal(SBAR_ITEM_REC *item, int signal_id) diff --git a/apps/irssi/src/fe-text/term-terminfo.c b/apps/irssi/src/fe-text/term-terminfo.c index 54a02a6b..ddb00441 100644 --- a/apps/irssi/src/fe-text/term-terminfo.c +++ b/apps/irssi/src/fe-text/term-terminfo.c @@ -376,7 +376,7 @@ static void term_printed_text(int count) vcx += count; while (vcx >= term_width) { vcx -= term_width; - if (vcy < term_height) vcy++; + if (vcy < term_height-1) vcy++; if (vcx > 0) term_lines_empty[vcy] = FALSE; } } diff --git a/apps/irssi/src/fe-text/textbuffer-reformat.c b/apps/irssi/src/fe-text/textbuffer-reformat.c index da75a5a8..62f17f0d 100644 --- a/apps/irssi/src/fe-text/textbuffer-reformat.c +++ b/apps/irssi/src/fe-text/textbuffer-reformat.c @@ -275,6 +275,6 @@ void textbuffer_reformat_deinit(void) g_string_free(format, TRUE); signal_remove("print format", (SIGNAL_FUNC) sig_print_format); - signal_remove("print text finished", (SIGNAL_FUNC) sig_gui_printtext_finished); + signal_remove("gui print text finished", (SIGNAL_FUNC) sig_gui_printtext_finished); signal_remove("setup changed", (SIGNAL_FUNC) read_settings); } diff --git a/apps/irssi/src/perl/common/Core.xs b/apps/irssi/src/perl/common/Core.xs index 4db742c0..0fb93efb 100644 --- a/apps/irssi/src/perl/common/Core.xs +++ b/apps/irssi/src/perl/common/Core.xs @@ -15,7 +15,7 @@ void perl_signal_add_hash(int priority, SV *sv) hv = hvref(sv); hv_iterinit(hv); while ((he = hv_iternext(hv)) != NULL) - perl_signal_add_to(hv_iterkey(he, &len), HeVAL(he), priority); + perl_signal_add_full(hv_iterkey(he, &len), HeVAL(he), priority); } static void perl_command_bind_add_hash(int priority, SV *sv, char *category) @@ -76,15 +76,35 @@ CODE: } signal_emit(signal, items-1, p[0], p[1], p[2], p[3], p[4], p[5]); +void +signal_continue(...) +CODE: + void *p[SIGNAL_MAX_ARGUMENTS]; + int n; + + memset(p, 0, sizeof(p)); + for (n = 0; n < items && n < SIGNAL_MAX_ARGUMENTS; n++) { + if (SvPOKp(ST(n))) + p[n] = SvPV(ST(n), PL_na); + else if (irssi_is_ref_object(ST(n))) + p[n] = irssi_ref_object(ST(n)); + else if (SvROK(ST(n))) + p[n] = (void *) SvIV((SV*)SvRV(ST(n))); + else + p[n] = NULL; + } + signal_continue(items, p[0], p[1], p[2], p[3], p[4], p[5]); + void signal_add(...) CODE: if (items != 1 && items != 2) croak("Usage: Irssi::signal_add(signal, func)"); if (items == 2) - perl_signal_add((char *)SvPV(ST(0),PL_na), ST(1)); + perl_signal_add_full((char *)SvPV(ST(0),PL_na), ST(1), + SIGNAL_PRIORITY_DEFAULT); else - perl_signal_add_hash(1, ST(0)); + perl_signal_add_hash(SIGNAL_PRIORITY_DEFAULT, ST(0)); void signal_add_first(...) @@ -92,9 +112,10 @@ CODE: if (items != 1 && items != 2) croak("Usage: Irssi::signal_add_first(signal, func)"); if (items == 2) - perl_signal_add_first((char *)SvPV(ST(0),PL_na), ST(1)); + perl_signal_add_full((char *)SvPV(ST(0),PL_na), ST(1), + SIGNAL_PRIORITY_HIGH); else - perl_signal_add_hash(0, ST(0)); + perl_signal_add_hash(SIGNAL_PRIORITY_HIGH, ST(0)); void signal_add_last(...) @@ -102,9 +123,41 @@ CODE: if (items != 1 && items != 2) croak("Usage: Irssi::signal_add_last(signal, func)"); if (items == 2) - perl_signal_add_last((char *)SvPV(ST(0),PL_na), ST(1)); + perl_signal_add_full((char *)SvPV(ST(0),PL_na), ST(1), + SIGNAL_PRIORITY_LOW); else - perl_signal_add_hash(2, ST(0)); + perl_signal_add_hash(SIGNAL_PRIORITY_LOW, ST(0)); + +void +signal_add_priority(...) +CODE: + if (items != 2 && items != 3) + croak("Usage: Irssi::signal_add_priority(signal, func, priority)"); + if (items == 3) + perl_signal_add_full((char *)SvPV(ST(0),PL_na), ST(1), SvIV(ST(2))); + else + perl_signal_add_hash(SvIV(ST(0)), ST(1)); + +int +SIGNAL_PRIORITY_LOW() +CODE: + RETVAL = SIGNAL_PRIORITY_LOW; +OUTPUT: + RETVAL + +int +SIGNAL_PRIORITY_DEFAULT() +CODE: + RETVAL = SIGNAL_PRIORITY_DEFAULT; +OUTPUT: + RETVAL + +int +SIGNAL_PRIORITY_HIGH() +CODE: + RETVAL = SIGNAL_PRIORITY_HIGH; +OUTPUT: + RETVAL void signal_remove(signal, func) @@ -136,7 +189,12 @@ timeout_add(msecs, func, data) SV *func SV *data CODE: - RETVAL = perl_timeout_add(msecs, func, data); + if (msecs < 10) { + croak("Irssi::timeout() : msecs must be >= 10"); + RETVAL = -1; + } else { + RETVAL = perl_timeout_add(msecs, func, data); + } OUTPUT: RETVAL @@ -399,17 +457,17 @@ PPCODE: void command_bind_first(...) CODE: - handle_command_bind(0, items, ST(0), ST(1), ST(2)); + handle_command_bind(SIGNAL_PRIORITY_HIGH, items, ST(0), ST(1), ST(2)); void command_bind(...) CODE: - handle_command_bind(1, items, ST(0), ST(1), ST(2)); + handle_command_bind(SIGNAL_PRIORITY_DEFAULT, items, ST(0), ST(1), ST(2)); void command_bind_last(...) CODE: - handle_command_bind(2, items, ST(0), ST(1), ST(2)); + handle_command_bind(SIGNAL_PRIORITY_LOW, items, ST(0), ST(1), ST(2)); void command_runsub(cmd, data, server, item) diff --git a/apps/irssi/src/perl/common/Irssi.pm b/apps/irssi/src/perl/common/Irssi.pm index eb1d367b..a9f93bf0 100644 --- a/apps/irssi/src/perl/common/Irssi.pm +++ b/apps/irssi/src/perl/common/Irssi.pm @@ -120,7 +120,9 @@ sub EXPORT_ALL () { push @EXPORT_OK, $_ if /[a-z]/ && defined *{$_}{CODE}; } } - select CLIENTCRAP; + + tie *DEFAULT, __PACKAGE__, MSGLEVEL_CLIENTCRAP(); + select DEFAULT; } sub in_irssi { diff --git a/apps/irssi/src/perl/module-formats.c b/apps/irssi/src/perl/module-formats.c index 5c2e1c66..8840e437 100644 --- a/apps/irssi/src/perl/module-formats.c +++ b/apps/irssi/src/perl/module-formats.c @@ -32,8 +32,8 @@ FORMAT_REC feperl_formats[] = { { "script_loaded", "Loaded script {hilight $0}", 2, { 0, 0 } }, { "script_unloaded", "Unloaded script {hilight $0}", 1, { 0 } }, { "no_scripts_loaded", "No scripts are loaded", 0 }, - { "script_list_header", "Loaded scripts:", 0 }, - { "script_list_line", "$[!15]0 $1", 2, { 0, 0 } }, + { "script_list_header", "%#Loaded scripts:", 0 }, + { "script_list_line", "%#$[!15]0 $1", 2, { 0, 0 } }, { "script_list_footer", "", 0 }, { "script_error", "{error Error in script {hilight $0}:}", 1, { 0 } }, diff --git a/apps/irssi/src/perl/perl-common.c b/apps/irssi/src/perl/perl-common.c index cb5f0987..72fc557c 100644 --- a/apps/irssi/src/perl/perl-common.c +++ b/apps/irssi/src/perl/perl-common.c @@ -329,8 +329,8 @@ void perl_window_item_fill_hash(HV *hv, WI_ITEM_REC *item) hv_store(hv, "name", 4, new_pv(item->name), 0); hv_store(hv, "createtime", 10, newSViv(item->createtime), 0); - hv_store(hv, "data_level", 8, newSViv(item->data_level), 0); - hv_store(hv, "hilight_color", 10, new_pv(item->hilight_color), 0); + hv_store(hv, "data_level", 10, newSViv(item->data_level), 0); + hv_store(hv, "hilight_color", 13, new_pv(item->hilight_color), 0); } void perl_channel_fill_hash(HV *hv, CHANNEL_REC *channel) @@ -369,6 +369,7 @@ void perl_query_fill_hash(HV *hv, QUERY_REC *query) perl_window_item_fill_hash(hv, (WI_ITEM_REC *) query); + hv_store(hv, "last_unread_msg", 15, newSViv(query->last_unread_msg), 0); hv_store(hv, "address", 7, new_pv(query->address), 0); hv_store(hv, "server_tag", 10, new_pv(query->server_tag), 0); hv_store(hv, "unwanted", 8, newSViv(query->unwanted), 0); @@ -425,7 +426,7 @@ static void perl_ignore_fill_hash(HV *hv, IGNORE_REC *ignore) hv_store(hv, "level", 5, newSViv(ignore->level), 0); - hv_store(hv, "exception", 6, newSViv(ignore->exception), 0); + hv_store(hv, "exception", 9, newSViv(ignore->exception), 0); hv_store(hv, "regexp", 6, newSViv(ignore->regexp), 0); hv_store(hv, "fullword", 8, newSViv(ignore->fullword), 0); } diff --git a/apps/irssi/src/perl/perl-signals-list.h b/apps/irssi/src/perl/perl-signals-list.h index fc888cf2..05003c0f 100644 --- a/apps/irssi/src/perl/perl-signals-list.h +++ b/apps/irssi/src/perl/perl-signals-list.h @@ -40,6 +40,7 @@ static PERL_SIGNAL_ARGS_REC perl_signal_args[] = { "query created", { "iobject", "int", NULL } }, { "query destroyed", { "iobject", NULL } }, { "query nick changed", { "iobject", "string", NULL } }, + { "window item name changed", { "iobject", NULL } }, { "query address changed", { "iobject", NULL } }, { "query server changed", { "iobject", "iobject", NULL } }, { "rawlog", { "RAWIrssi::Log", "string", NULL } }, @@ -76,8 +77,8 @@ static PERL_SIGNAL_ARGS_REC perl_signal_args[] = { "massjoin", { "iobject", "gslist_iobject", NULL } }, { "ban new", { "iobject", "Irssi::Irc::Ban", NULL } }, { "ban remove", { "iobject", "Irssi::Irc::Ban", NULL } }, - { "channel mode changed", { "iobject", NULL } }, - { "nick mode changed", { "iobject", "iobject", NULL } }, + { "channel mode changed", { "iobject", "string", NULL } }, + { "nick mode changed", { "iobject", "iobject", "string", NULL } }, { "user mode changed", { "iobject", "string", NULL } }, { "away mode changed", { "iobject", NULL } }, { "netsplit server new", { "iobject", "NETSPLIT_iobject", NULL } }, @@ -119,7 +120,7 @@ static PERL_SIGNAL_ARGS_REC perl_signal_args[] = { "notifylist left", { "iobject", "string", "string", "string", "string", "string", NULL } }, { "proxy client connected", { "CLIENT_REC", NULL } }, { "proxy client disconnected", { "CLIENT_REC", NULL } }, - { "gui print text", { "Irssi::UI::Window", "int", "int", "int", "string", "int", NULL } }, + { "gui print text", { "Irssi::UI::Window", "int", "int", "int", "string", "Irssi::UI::TextDest", NULL } }, { "gui print text finished", { "Irssi::UI::Window", NULL } }, { "complete word", { "glistptr_char*", "Irssi::UI::Window", "string", "string", "intptr", NULL } }, { "exec new", { "Irssi::UI::Process", NULL } }, @@ -167,6 +168,7 @@ static PERL_SIGNAL_ARGS_REC perl_signal_args[] = { "message irc notice", { "iobject", "string", "string", "string", "string", NULL } }, { "message irc own_ctcp", { "iobject", "string", "string", "string", NULL } }, { "message irc ctcp", { "iobject", "string", "string", "string", "string", "string", NULL } }, + { "message irc mode", { "iobject", "string", "string", "string", "string", NULL } }, { "message dcc own", { "siobject", "string", NULL } }, { "message dcc own_action", { "siobject", "string", NULL } }, { "message dcc own_ctcp", { "siobject", "string", "string", NULL } }, diff --git a/apps/irssi/src/perl/perl-signals.c b/apps/irssi/src/perl/perl-signals.c index eb3a8b48..3c423a64 100644 --- a/apps/irssi/src/perl/perl-signals.c +++ b/apps/irssi/src/perl/perl-signals.c @@ -33,9 +33,7 @@ typedef struct { PERL_SCRIPT_REC *script; int signal_id; char *signal; - SV *func; - int priority; } PERL_SIGNAL_REC; typedef struct { @@ -45,7 +43,7 @@ typedef struct { #include "perl-signals-list.h" -static GHashTable *signals[3]; +static GHashTable *signals; static GHashTable *perl_signal_args_hash; static GSList *perl_signal_args_partial; @@ -208,103 +206,72 @@ static void perl_call_signal(PERL_SCRIPT_REC *script, SV *func, LEAVE; } -static void sig_func(int priority, gconstpointer *args) +static void sig_func(const void *p1, const void *p2, + const void *p3, const void *p4, + const void *p5, const void *p6) { - GSList **list, *tmp, *next; - int signal_id; - - signal_id = signal_get_emitted_id(); - list = g_hash_table_lookup(signals[priority], - GINT_TO_POINTER(signal_id)); - for (tmp = list == NULL ? NULL : *list; tmp != NULL; tmp = next) { - PERL_SIGNAL_REC *rec = tmp->data; + PERL_SIGNAL_REC *rec; + const void *args[6]; - next = tmp->next; - perl_call_signal(rec->script, rec->func, signal_id, args); - if (signal_is_stopped(signal_id)) - break; - } -} + args[0] = p1; args[1] = p2; args[2] = p3; + args[3] = p4; args[4] = p5; args[5] = p6; -#define SIG_FUNC_DECL(priority, priority_name) \ -static void sig_func_##priority_name(gconstpointer p1, gconstpointer p2, \ - gconstpointer p3, gconstpointer p4, \ - gconstpointer p5, gconstpointer p6) \ -{ \ - gconstpointer args[6]; \ - args[0] = p1; args[1] = p2; args[2] = p3; \ - args[3] = p4; args[4] = p5; args[5] = p6; \ - sig_func(priority, args); \ + rec = signal_get_user_data(); + perl_call_signal(rec->script, rec->func, signal_get_emitted_id(), args); } -SIG_FUNC_DECL(0, first); -SIG_FUNC_DECL(1, default); -SIG_FUNC_DECL(2, last); - -#define priority_get_func(priority) \ - (priority == 0 ? sig_func_first : \ - priority == 1 ? sig_func_default : sig_func_last) - -#define perl_signal_get_func(rec) \ - (priority_get_func((rec)->priority)) - -static void perl_signal_add_to_int(const char *signal, SV *func, - int priority, int command) +static void perl_signal_add_full_int(const char *signal, SV *func, + int priority, int command, + const char *category) { PERL_SCRIPT_REC *script; PERL_SIGNAL_REC *rec; - GHashTable *table; GSList **siglist; void *signal_idp; g_return_if_fail(signal != NULL); g_return_if_fail(func != NULL); - g_return_if_fail(priority >= 0 && priority <= 2); script = perl_script_find_package(perl_get_package()); g_return_if_fail(script != NULL); - if (!command && strncmp(signal, "command ", 8) == 0) { - /* we used Irssi::signal_add() instead of - Irssi::command_bind() - oh well, allow this.. */ - command_bind_to(MODULE_NAME, priority, signal+8, -1, - NULL, priority_get_func(priority)); - command = TRUE; - } - rec = g_new(PERL_SIGNAL_REC, 1); rec->script = script; rec->signal_id = signal_get_uniq_id(signal); rec->signal = g_strdup(signal); rec->func = perl_func_sv_inc(func, perl_get_package()); - rec->priority = priority; - table = signals[priority]; - signal_idp = GINT_TO_POINTER(rec->signal_id); + if (command || strncmp(signal, "command ", 8) == 0) { + /* we used Irssi::signal_add() instead of + Irssi::command_bind() - oh well, allow this.. */ + command_bind_full(MODULE_NAME, priority, signal+8, -1, + category, sig_func, rec); + } else { + signal_add_full_id(MODULE_NAME, priority, rec->signal_id, + sig_func, rec); + } - siglist = g_hash_table_lookup(table, signal_idp); + signal_idp = GINT_TO_POINTER(rec->signal_id); + siglist = g_hash_table_lookup(signals, signal_idp); if (siglist == NULL) { siglist = g_new0(GSList *, 1); - g_hash_table_insert(table, signal_idp, siglist); - - if (!command) { - signal_add_to_id(MODULE_NAME, priority, rec->signal_id, - perl_signal_get_func(rec)); - } + g_hash_table_insert(signals, signal_idp, siglist); } *siglist = g_slist_append(*siglist, rec); } -void perl_signal_add_to(const char *signal, SV *func, int priority) +void perl_signal_add_full(const char *signal, SV *func, int priority) { - perl_signal_add_to_int(signal, func, priority, FALSE); + perl_signal_add_full_int(signal, func, priority, FALSE, NULL); } static void perl_signal_destroy(PERL_SIGNAL_REC *rec) { if (strncmp(rec->signal, "command ", 8) == 0) - command_unbind(rec->signal+8, perl_signal_get_func(rec)); + command_unbind_full(rec->signal+8, sig_func, rec); + else + signal_remove_id(rec->signal_id, sig_func, rec); SvREFCNT_dec(rec->func); g_free(rec->signal); @@ -313,17 +280,10 @@ static void perl_signal_destroy(PERL_SIGNAL_REC *rec) static void perl_signal_remove_list_one(GSList **siglist, PERL_SIGNAL_REC *rec) { - void *signal_idp; - - g_return_if_fail(rec != NULL); - - signal_idp = GINT_TO_POINTER(rec->signal_id); - *siglist = g_slist_remove(*siglist, rec); if (*siglist == NULL) { - signal_remove_id(rec->signal_id, perl_signal_get_func(rec)); g_free(siglist); - g_hash_table_remove(signals[rec->priority], signal_idp); + g_hash_table_remove(signals, GINT_TO_POINTER(rec->signal_id)); } perl_signal_destroy(rec); @@ -337,8 +297,6 @@ static void perl_signal_remove_list(GSList **list, SV *func) { GSList *tmp; - g_return_if_fail(list != NULL); - for (tmp = *list; tmp != NULL; tmp = tmp->next) { PERL_SIGNAL_REC *rec = tmp->data; @@ -353,17 +311,15 @@ void perl_signal_remove(const char *signal, SV *func) { GSList **list; void *signal_idp; - int n; signal_idp = GINT_TO_POINTER(signal_get_uniq_id(signal)); + list = g_hash_table_lookup(signals, signal_idp); - func = perl_func_sv_inc(func, perl_get_package()); - for (n = 0; n < sizeof(signals)/sizeof(signals[0]); n++) { - list = g_hash_table_lookup(signals[n], signal_idp); - if (list != NULL) - perl_signal_remove_list(list, func); + if (list != NULL) { + func = perl_func_sv_inc(func, perl_get_package()); + perl_signal_remove_list(list, func); + SvREFCNT_dec(func); } - SvREFCNT_dec(func); } void perl_command_bind_to(const char *cmd, const char *category, @@ -371,11 +327,8 @@ void perl_command_bind_to(const char *cmd, const char *category, { char *signal; - command_bind_to(MODULE_NAME, priority, cmd, -1, - category, priority_get_func(priority)); - signal = g_strconcat("command ", cmd, NULL); - perl_signal_add_to_int(signal, func, priority, TRUE); + perl_signal_add_full_int(signal, func, priority, TRUE, category); g_free(signal); } @@ -405,10 +358,6 @@ static int signal_destroy_hash(void *key, GSList **list, PERL_SCRIPT_REC *script next = tmp->next; if (script == NULL || rec->script == script) { *list = g_slist_remove(*list, rec); - if (*list == NULL) { - signal_remove_id(rec->signal_id, - perl_signal_get_func(rec)); - } perl_signal_destroy(rec); } } @@ -423,35 +372,20 @@ static int signal_destroy_hash(void *key, GSList **list, PERL_SCRIPT_REC *script /* destroy all signals used by script */ void perl_signal_remove_script(PERL_SCRIPT_REC *script) { - int n; - - for (n = 0; n < sizeof(signals)/sizeof(signals[0]); n++) { - g_hash_table_foreach_remove(signals[n], - (GHRFunc) signal_destroy_hash, - script); - } + g_hash_table_foreach_remove(signals, (GHRFunc) signal_destroy_hash, + script); } void perl_signals_start(void) { - int n; - - for (n = 0; n < sizeof(signals)/sizeof(signals[0]); n++) { - signals[n] = g_hash_table_new((GHashFunc) g_direct_hash, - (GCompareFunc) g_direct_equal); - } + signals = g_hash_table_new(NULL, NULL); } void perl_signals_stop(void) { - int n; - - for (n = 0; n < sizeof(signals)/sizeof(signals[0]); n++) { - g_hash_table_foreach(signals[n], - (GHFunc) signal_destroy_hash, NULL); - g_hash_table_destroy(signals[n]); - signals[n] = NULL; - } + g_hash_table_foreach(signals, (GHFunc) signal_destroy_hash, NULL); + g_hash_table_destroy(signals); + signals = NULL; } void perl_signals_init(void) diff --git a/apps/irssi/src/perl/perl-signals.h b/apps/irssi/src/perl/perl-signals.h index 33e0c1b8..92196d04 100644 --- a/apps/irssi/src/perl/perl-signals.h +++ b/apps/irssi/src/perl/perl-signals.h @@ -1,13 +1,7 @@ #ifndef __PERL_SIGNALS_H #define __PERL_SIGNALS_H -void perl_signal_add_to(const char *signal, SV *func, int priority); -#define perl_signal_add_first(signal, func) \ - perl_signal_add_to(signal, func, 0) -#define perl_signal_add(signal, func) \ - perl_signal_add_to(signal, func, 1) -#define perl_signal_add_last(signal, func) \ - perl_signal_add_to(signal, func, 2) +void perl_signal_add_full(const char *signal, SV *func, int priority); void perl_signal_remove(const char *signal, SV *func); /* remove all signals used by script */ diff --git a/apps/irssi/src/perl/ui/Formats.xs b/apps/irssi/src/perl/ui/Formats.xs index 0ad8c86a..f9cc0200 100644 --- a/apps/irssi/src/perl/ui/Formats.xs +++ b/apps/irssi/src/perl/ui/Formats.xs @@ -11,16 +11,21 @@ format_get_text(window, module, server, target, formatnum, ...) char *target int formatnum PREINIT: + TEXT_DEST_REC dest; + THEME_REC *theme; char **charargs; char *ret; int n; PPCODE: charargs = g_new0(char *, items-5+1); - charargs[items-5] = NULL; for (n = 5; n < items; n++) { charargs[n-5] = (char *)SvPV(ST(n), PL_na); } - ret = format_get_text(module, window, server, target, formatnum, charargs); + + format_create_dest(&dest, server, target, 0, window); + theme = window_get_theme(dest.window); + + ret = format_get_text_theme_charargs(theme, module, &dest, formatnum, charargs); g_free(charargs); XPUSHs(sv_2mortal(new_pv(ret))); diff --git a/apps/irssi/src/perl/ui/Themes.xs b/apps/irssi/src/perl/ui/Themes.xs index fc3165e9..f4528083 100644 --- a/apps/irssi/src/perl/ui/Themes.xs +++ b/apps/irssi/src/perl/ui/Themes.xs @@ -223,3 +223,34 @@ PPCODE: } XPUSHs(sv_2mortal(new_pv(ret))); g_free_not_null(ret); + +char * +theme_get_format(theme, module, tag) + Irssi::UI::Theme theme + char *module + char *tag +PREINIT: + MODULE_THEME_REC *modtheme; + FORMAT_REC *formats; + char *ret; + int i; +CODE: + formats = g_hash_table_lookup(default_formats, module); + if (formats == NULL) + croak("Unknown module: %s", module); + + for (i = 0; formats[i].def != NULL; i++) { + if (formats[i].tag != NULL && + g_strcasecmp(formats[i].tag, tag) == 0) + break; + } + + if (formats[i].def == NULL) + croak("Unknown format tag: %s", tag); + + modtheme = g_hash_table_lookup(theme->modules, module); + RETVAL = modtheme == NULL ? NULL : modtheme->formats[i]; + if (RETVAL == NULL) + RETVAL = formats[i].def; +OUTPUT: + RETVAL diff --git a/apps/irssi/src/silc/core/silc-channels.c b/apps/irssi/src/silc/core/silc-channels.c index 6235e6f0..108f6dbe 100644 --- a/apps/irssi/src/silc/core/silc-channels.c +++ b/apps/irssi/src/silc/core/silc-channels.c @@ -66,6 +66,8 @@ static void sig_channel_destroyed(SILC_CHANNEL_REC *channel) { if (!IS_SILC_CHANNEL(channel)) return; + if (channel->server && channel->server->disconnected) + return; if (channel->server != NULL && !channel->left && !channel->kicked) { /* destroying channel record without actually diff --git a/apps/irssi/src/silc/core/silc-core.c b/apps/irssi/src/silc/core/silc-core.c index 114f03af..9578ce9b 100644 --- a/apps/irssi/src/silc/core/silc-core.c +++ b/apps/irssi/src/silc/core/silc-core.c @@ -429,6 +429,8 @@ void silc_core_deinit(void) if (idletag != -1) { signal_emit("chat protocol deinit", 1, chat_protocol_find("SILC")); + signal_remove("irssi init read settings", + (SIGNAL_FUNC) sig_init_read_settings); silc_server_deinit(); silc_channels_deinit(); diff --git a/doc/Makefile.am.pre b/doc/Makefile.am.pre index 8aac88cd..e7a3e3e3 100644 --- a/doc/Makefile.am.pre +++ b/doc/Makefile.am.pre @@ -29,6 +29,7 @@ all: touch draft-riikonen-silc-ke-auth-05.txt touch draft-riikonen-silc-commands-03.txt touch draft-riikonen-silc-flags-payloads-00.txt + touch draft-riikonen-presence-attrs-00.txt if SILC_DIST_CLIENT dist-hook: @@ -38,6 +39,7 @@ dist-hook: touch draft-riikonen-silc-ke-auth-05.txt touch draft-riikonen-silc-commands-03.txt touch draft-riikonen-silc-flags-payloads-00.txt + touch draft-riikonen-presence-attrs-00.txt else if SILC_DIST_TOOLKIT dist-hook: @@ -54,6 +56,7 @@ dist-hook: touch draft-riikonen-silc-ke-auth-05.txt touch draft-riikonen-silc-commands-03.txt touch draft-riikonen-silc-flags-payloads-00.txt + touch draft-riikonen-presence-attrs-00.txt $(makerfc) draft-riikonen-silc-spec-05.nroff \ draft-riikonen-silc-spec-05.txt $(makerfc) draft-riikonen-silc-pp-05.nroff \ @@ -64,6 +67,8 @@ dist-hook: draft-riikonen-silc-commands-03.txt $(makerfc) draft-riikonen-silc-flags-payloads-00.nroff \ draft-riikonen-silc-flags-payloads-00.txt + $(makerfc) draft-riikonen-presence-attrs-00.nroff \ + draft-riikonen-presence-attrs-00.txt else dist-hook: touch draft-riikonen-silc-spec-05.txt @@ -71,6 +76,7 @@ dist-hook: touch draft-riikonen-silc-ke-auth-05.txt touch draft-riikonen-silc-commands-03.txt touch draft-riikonen-silc-flags-payloads-00.txt + touch draft-riikonen-presence-attrs-00.txt $(makerfc) draft-riikonen-silc-spec-05.nroff \ draft-riikonen-silc-spec-05.txt $(makerfc) draft-riikonen-silc-pp-05.nroff \ @@ -79,8 +85,8 @@ dist-hook: draft-riikonen-silc-ke-auth-05.txt $(makerfc) draft-riikonen-silc-commands-03.nroff \ draft-riikonen-silc-commands-03.txt - $(makerfc) draft-riikonen-silc-flags-payloads-00.nroff \ - draft-riikonen-silc-flags-payloads-00.txt + $(makerfc) draft-riikonen-presence-attrs-00.nroff \ + draft-riikonen-presence-attrs-00.txt endif endif diff --git a/doc/draft-riikonen-silc-commands-03.nroff b/doc/draft-riikonen-silc-commands-03.nroff index 1db9bc3d..89ec6b11 100644 --- a/doc/draft-riikonen-silc-commands-03.nroff +++ b/doc/draft-riikonen-silc-commands-03.nroff @@ -2300,13 +2300,13 @@ security of this protocol. 4 References [SILC1] Riikonen, P., "Secure Internet Live Conferencing (SILC), - Protocol Specification", Internet Draft, April 2001. + Protocol Specification", Internet Draft, May 2002. [SILC2] Riikonen, P., "SILC Packet Protocol", Internet Draft, - April 2001. + May 2002. [SILC3] Riikonen, P., "SILC Key Exchange and Authentication - Protocols", Internet Draft, April 2001. + Protocols", Internet Draft, May 2002. [IRC] Oikarinen, J., and Reed D., "Internet Relay Chat Protocol", RFC 1459, May 1993. @@ -2364,8 +2364,8 @@ security of this protocol. [RFC2279] Yergeau, F., "UTF-8, a transformation format of ISO 10646", RFC 2279, January 1998. - - +[ATTRS] Riikonen, P., "User Online Presence and Information + Attributes", Internet Draft, May 2002. .ti 0 diff --git a/doc/draft-riikonen-silc-flags-payloads-00.nroff b/doc/draft-riikonen-silc-flags-payloads-00.nroff index 38d1cd23..a827ccfc 100644 --- a/doc/draft-riikonen-silc-flags-payloads-00.nroff +++ b/doc/draft-riikonen-silc-flags-payloads-00.nroff @@ -261,10 +261,10 @@ support S/MIME may be desired in some implementations. 5 References [SILC1] Riikonen, P., "Secure Internet Live Conferencing (SILC), - Protocol Specification", Internet Draft, April 2001. + Protocol Specification", Internet Draft, May 2002. [SILC2] Riikonen, P., "SILC Packet Protocol", Internet Draft, - April 2001. + May 2002. [RFC2045] Freed, N., et al., "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", diff --git a/doc/draft-riikonen-silc-ke-auth-05.nroff b/doc/draft-riikonen-silc-ke-auth-05.nroff index 7089aa48..247e99d5 100644 --- a/doc/draft-riikonen-silc-ke-auth-05.nroff +++ b/doc/draft-riikonen-silc-ke-auth-05.nroff @@ -1052,12 +1052,12 @@ security of this protocol. 5 References [SILC1] Riikonen, P., "Secure Internet Live Conferencing (SILC), - Protocol Specification", Internet Draft, April 2001. + Protocol Specification", Internet Draft, May 2002. [SILC2] Riikonen, P., "SILC Packet Protocol", Internet Draft, - April 2001. + May 2002. -[SILC4] Riikonen, P., "SILC Commands", Internet Draft, April 2001. +[SILC4] Riikonen, P., "SILC Commands", Internet Draft, May 2002. [IRC] Oikarinen, J., and Reed D., "Internet Relay Chat Protocol", RFC 1459, May 1993. diff --git a/doc/draft-riikonen-silc-pp-05.nroff b/doc/draft-riikonen-silc-pp-05.nroff index 597b9586..f3445fd0 100644 --- a/doc/draft-riikonen-silc-pp-05.nroff +++ b/doc/draft-riikonen-silc-pp-05.nroff @@ -2925,12 +2925,12 @@ security of this protocol. 4 References [SILC1] Riikonen, P., "Secure Internet Live Conferencing (SILC), - Protocol Specification", Internet Draft, April 2001. + Protocol Specification", Internet Draft, May 2002. [SILC3] Riikonen, P., "SILC Key Exchange and Authentication - Protocols", Internet Draft, April 2001. + Protocols", Internet Draft, May 2002. -[SILC4] Riikonen, P., "SILC Commands", Internet Draft, April 2001. +[SILC4] Riikonen, P., "SILC Commands", Internet Draft, May 2002. [IRC] Oikarinen, J., and Reed D., "Internet Relay Chat Protocol", RFC 1459, May 1993. diff --git a/doc/draft-riikonen-silc-spec-05.nroff b/doc/draft-riikonen-silc-spec-05.nroff index 0e8a5ee5..417a73ae 100644 --- a/doc/draft-riikonen-silc-spec-05.nroff +++ b/doc/draft-riikonen-silc-spec-05.nroff @@ -2305,12 +2305,12 @@ should have a forum to discuss the cell management issues. 6 References [SILC2] Riikonen, P., "SILC Packet Protocol", Internet Draft, - April 2001. + May 2002. [SILC3] Riikonen, P., "SILC Key Exchange and Authentication - Protocols", Internet Draft, April 2001. + Protocols", Internet Draft, May 2002. -[SILC4] Riikonen, P., "SILC Commands", Internet Draft, April 2001. +[SILC4] Riikonen, P., "SILC Commands", Internet Draft, May 2002. [IRC] Oikarinen, J., and Reed D., "Internet Relay Chat Protocol", RFC 1459, May 1993. diff --git a/prepare b/prepare index f5cfff57..09da0308 100755 --- a/prepare +++ b/prepare @@ -37,7 +37,7 @@ # SILC Distribution versions. Set here or give the version on the command # line as argument. # -SILC_VERSION=0.8.2 # Base version +SILC_VERSION=0.9 # Base version #############################################################################