diff options
73 files changed, 4779 insertions, 2558 deletions
@@ -1,10 +1,11 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -ChangeLog - 2008-03-05 +ChangeLog - 2008-03-22 Version 0.2.7 (under dev!): + * added tags for lines and custom filtering by tags or regex (task #7674) * added custom bars, with custom items * command /whois is now authorized in private without argument (task #7482) * removed kernel info in CTCP VERSION reply (IRC plugin) (task #7494) diff --git a/po/POTFILES.in b/po/POTFILES.in index a432640f4..4238047ab 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -62,6 +62,8 @@ ./src/gui/gui-color.h ./src/gui/gui-completion.c ./src/gui/gui-completion.h +./src/gui/gui-filter.c +./src/gui/gui-filter.h ./src/gui/gui-history.c ./src/gui/gui-history.h ./src/gui/gui-hotlist.c @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-03-15 09:33+0100\n" +"POT-Creation-Date: 2008-03-22 23:32+0100\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -206,6 +206,56 @@ msgstr "(hotlist: zvýraznění + zprávy)\n" msgid "(hotlist: highlights + messages + join/part (all))" msgstr "(hotlist: zvýrazění + zprávy + připojení/odpojení (vše))\n" +#, fuzzy +msgid "Filters are enabled" +msgstr "uživatel byl zablokován" + +#, fuzzy +msgid "Filters are disabled" +msgstr "uživatel byl zablokován" + +msgid "Message filters:" +msgstr "" + +#, fuzzy, c-format +msgid " %s[%s%d%s]%s buffer: %s%s%s / tags: %s / regex: %s" +msgstr " (není obsluhovač zprávy)\n" + +#, fuzzy +msgid "No message filter defined" +msgstr "Žádné aliasy nejsou definovány.\n" + +msgid "Filters enabled" +msgstr "" + +#, fuzzy +msgid "Filters disabled" +msgstr "uživatel byl zablokován" + +#, fuzzy, c-format +msgid "%sError: filter already exists" +msgstr "%s ignorování již existuje\n" + +#, c-format +msgid "%sError: you must specify at least tag(s) or regex for filter" +msgstr "" + +#, fuzzy +msgid "Filter added" +msgstr "uživatel byl zablokován" + +#, fuzzy +msgid "Filter deleted" +msgstr "uživatel byl zablokován" + +#, fuzzy, c-format +msgid "%sError: filter not found" +msgstr "%s plugin \"%s\" nenalezen\n" + +#, fuzzy, c-format +msgid "%sError: wrong filter number" +msgstr "%s nekorektní číslo bufferu\n" + #. TRANSLATORS: %s is "WeeChat" #, fuzzy, c-format msgid "%s internal commands:" @@ -595,6 +645,30 @@ msgstr "" "příkaz: příkaz, který spustit ('/' je automaticky dodáno, pokud není " "nalezeno na začátku příkazu)\n" +msgid "" +"filter messages in buffers, to hide/show them according to tags or regex" +msgstr "" + +msgid "" +"[list] | [enable|disable|toggle] | [add buffer tags regex] | [del number]" +msgstr "" + +msgid "" +" list: list all filters\n" +" enable: enable filters (filters are enabled by default)\n" +"disable: disable filters\n" +" toggle: toggle filters\n" +" add: add a filter\n" +" del: delete a filter\n" +" number: number of filter to delete (look at list to find it)\n" +" buffer: buffer where filter is active: it may be a name (category.name) or " +"\"*\" for all buffers\n" +" tags: comma separated list of tags, for example: \"irc_join,irc_part," +"irc_quit\"\n" +" regex: regular expression to search in line (use \t to separate prefix " +"from message)" +msgstr "" + msgid "display help about commands" msgstr "zobrazí nápovědu k příkazům" @@ -1483,10 +1557,6 @@ msgid " . description: %s\n" msgstr " . popis: %s\n" #, fuzzy, c-format -msgid "%sError: command \"%s\" failed" -msgstr "%s příkaz \"%s\" selhal\n" - -#, fuzzy, c-format msgid "%sError: unknown command \"%s\" (type /help for help)" msgstr "%s alias nebo příkaz \"%s\" nenalezen\n" @@ -1562,6 +1632,14 @@ msgstr "-VÍCE-" msgid "server" msgstr "server" +#, fuzzy, c-format +msgid "%s[%sF%s%s%s]" +msgstr "%s[%s%s%s]%s nečinný: " + +#, fuzzy +msgid "filtered" +msgstr "uživatel byl zablokován" + #, fuzzy msgid "(MORE)" msgstr "-VÍCE-" @@ -3546,7 +3624,7 @@ msgid "%sUser mode for %s%s%s is %s[%s%s%s]" msgstr "Uživatelský mód pro %s%s%s je %s[%s%s%s]\n" #, fuzzy, c-format -msgid "%s%s%s%s is away: %s" +msgid "%s%s[%s%s%s]%s is away: %s" msgstr "%s%s%s je pryč: %s\n" #, fuzzy, c-format @@ -3609,28 +3687,16 @@ msgid "%s%s%s%s has invited %s%s%s on %s%s" msgstr "%s%s%s pozval %s%s%s na %s%s\n" #, fuzzy, c-format -msgid "%s%s: cannot identify channel for \"%s\" command" -msgstr "%s nemohu identifikovat kanál pro příkaz \"%s\"\n" - -#, fuzzy, c-format -msgid "%s%s: cannot identify nickname for \"%s\" command" -msgstr "%s nemohu identifikovat přezdívku pro příkaz \"%s\"\n" - -#, fuzzy, c-format msgid "%sChannel reop %s%s%s: %s%s" msgstr "Reop kanálu %s%s%s: %s%s\n" #, fuzzy, c-format -msgid "%s%s[%s%s%s]%s exception %s%s%s" +msgid "%s%s[%s%s%s]%s exception %s%s%s by %s%s %s(%s%s%s)%s on %s" msgstr "%s[%s%s%s] %s%s%s takázaný\n" -#, c-format -msgid " by %s%s %s(%s%s%s)" -msgstr " od %s%s %s(%s%s%s)" - -#, c-format -msgid " by %s%s" -msgstr " od %s%s" +#, fuzzy, c-format +msgid "%s%s[%s%s%s]%s exception %s%s" +msgstr "%s[%s%s%s] %s%s%s takázaný\n" #, fuzzy, c-format msgid "%s%s: cannot create nick \"%s\" for channel \"%s\"" @@ -3674,12 +3740,12 @@ msgid "normal" msgstr "normální" #, fuzzy, c-format -msgid "%s%s[%s%s%s] %s%s%s banned by " +msgid "%s%s[%s%s%s] %s%s%s banned by %s%s %s(%s%s%s)%s on %s" msgstr "%s[%s%s%s] %s%s%s zakázal " #, fuzzy, c-format -msgid "%s%s[%s%s%s] %s%s%s banned" -msgstr "%s[%s%s%s] %s%s%s takázaný\n" +msgid "%s%s[%s%s%s] %s%s%s banned by %s%s %s(%s%s%s)" +msgstr "%s[%s%s%s] %s%s%s zakázal " #, fuzzy, c-format msgid "" @@ -4423,6 +4489,32 @@ msgstr "" msgid "%s%s: wrong arguments for function \"%s\"" msgstr "%s špatné parametry pro příkaz \"%s\"\n" +#, fuzzy +#~ msgid "%sError: wrong number \"%s\" for filter" +#~ msgstr "%s špatný počet parametrů pro příkaz \"%s\"\n" + +#, fuzzy +#~ msgid "%sError: command \"%s\" failed" +#~ msgstr "%s příkaz \"%s\" selhal\n" + +#, fuzzy +#~ msgid "%s%s: cannot identify channel for \"%s\" command" +#~ msgstr "%s nemohu identifikovat kanál pro příkaz \"%s\"\n" + +#, fuzzy +#~ msgid "%s%s: cannot identify nickname for \"%s\" command" +#~ msgstr "%s nemohu identifikovat přezdívku pro příkaz \"%s\"\n" + +#~ msgid " by %s%s %s(%s%s%s)" +#~ msgstr " od %s%s %s(%s%s%s)" + +#~ msgid " by %s%s" +#~ msgstr " od %s%s" + +#, fuzzy +#~ msgid "%s%s[%s%s%s] %s%s%s banned" +#~ msgstr "%s[%s%s%s] %s%s%s takázaný\n" + #~ msgid "/list end" #~ msgstr "/list konec" @@ -4959,9 +5051,6 @@ msgstr "%s špatné parametry pro příkaz \"%s\"\n" #~ msgid "%s cannot create new private window \"%s\"\n" #~ msgstr "%s nemohu vytvořít nové soukromé okno\"%s\"\n" -#~ msgid "%s[%s%s%s]%s idle: " -#~ msgstr "%s[%s%s%s]%s nečinný: " - #~ msgid "%s: trying 2nd nickname \"%s\"\n" #~ msgstr "%s: zkouším druhou přezdívku \"%s\"\n" @@ -5400,9 +5489,6 @@ msgstr "%s špatné parametry pro příkaz \"%s\"\n" #~ msgstr "" #~ "%s maska nebo typ/příkaz by neměla být obecná hodnota pro ignorování\n" -#~ msgid "%s ignore already exists\n" -#~ msgstr "%s ignorování již existuje\n" - #~ msgid "%s not enough memory to create ignore\n" #~ msgstr "%s nedostatek paměti pro vytvoření ignorování\n" @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-03-15 09:33+0100\n" +"POT-Creation-Date: 2008-03-22 23:32+0100\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Thomas Schuetz <i18n@internet-villa.de>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -211,6 +211,56 @@ msgstr "(Hotlist: Hervorhebungen und Nachrichten)\n" msgid "(hotlist: highlights + messages + join/part (all))" msgstr "(Hotlist: Hervorhebungen, Nachrichten, Betreten und Verlassen)\n" +#, fuzzy +msgid "Filters are enabled" +msgstr "/users wurde deaktiviert" + +#, fuzzy +msgid "Filters are disabled" +msgstr "/users wurde deaktiviert" + +msgid "Message filters:" +msgstr "" + +#, fuzzy, c-format +msgid " %s[%s%d%s]%s buffer: %s%s%s / tags: %s / regex: %s" +msgstr " (kein Message-Handler)\n" + +#, fuzzy +msgid "No message filter defined" +msgstr "Keine Aliases definiert.\n" + +msgid "Filters enabled" +msgstr "" + +#, fuzzy +msgid "Filters disabled" +msgstr "/users wurde deaktiviert" + +#, fuzzy, c-format +msgid "%sError: filter already exists" +msgstr "%s diese /ignore-Regel existiert bereits\n" + +#, c-format +msgid "%sError: you must specify at least tag(s) or regex for filter" +msgstr "" + +#, fuzzy +msgid "Filter added" +msgstr "/users wurde deaktiviert" + +#, fuzzy +msgid "Filter deleted" +msgstr "/users wurde deaktiviert" + +#, fuzzy, c-format +msgid "%sError: filter not found" +msgstr "%s Plugin \"%s\" nicht gefunden\n" + +#, fuzzy, c-format +msgid "%sError: wrong filter number" +msgstr "%s falsche Puffernummer\n" + #. TRANSLATORS: %s is "WeeChat" #, fuzzy, c-format msgid "%s internal commands:" @@ -587,6 +637,30 @@ msgstr "" "Befehl: auszuführender Befehl (falls nicht vorhanden wird automatisch ein " "'/' vorangestellt)\n" +msgid "" +"filter messages in buffers, to hide/show them according to tags or regex" +msgstr "" + +msgid "" +"[list] | [enable|disable|toggle] | [add buffer tags regex] | [del number]" +msgstr "" + +msgid "" +" list: list all filters\n" +" enable: enable filters (filters are enabled by default)\n" +"disable: disable filters\n" +" toggle: toggle filters\n" +" add: add a filter\n" +" del: delete a filter\n" +" number: number of filter to delete (look at list to find it)\n" +" buffer: buffer where filter is active: it may be a name (category.name) or " +"\"*\" for all buffers\n" +" tags: comma separated list of tags, for example: \"irc_join,irc_part," +"irc_quit\"\n" +" regex: regular expression to search in line (use \t to separate prefix " +"from message)" +msgstr "" + msgid "display help about commands" msgstr "Hilfe zu Befehlen abfragen" @@ -1477,10 +1551,6 @@ msgid " . description: %s\n" msgstr " . Beschreibung: %s\n" #, fuzzy, c-format -msgid "%sError: command \"%s\" failed" -msgstr "%s der Befehl \"%s\" schlug fehl\n" - -#, fuzzy, c-format msgid "%sError: unknown command \"%s\" (type /help for help)" msgstr "%s Alias oder Befehl \"%s\" nicht gefunden\n" @@ -1562,6 +1632,14 @@ msgstr "-MEHR-" msgid "server" msgstr "Server" +#, fuzzy, c-format +msgid "%s[%sF%s%s%s]" +msgstr "%s[%s%s%s]%s idlet: " + +#, fuzzy +msgid "filtered" +msgstr "/users wurde deaktiviert" + #, fuzzy msgid "(MORE)" msgstr "-MEHR-" @@ -3534,7 +3612,7 @@ msgid "%sUser mode for %s%s%s is %s[%s%s%s]" msgstr "Usermodus für %s%s%s ist %s[%s%s%s]\n" #, fuzzy, c-format -msgid "%s%s%s%s is away: %s" +msgid "%s%s[%s%s%s]%s is away: %s" msgstr "%s%s%s ist abwesend: %s\n" #, fuzzy, c-format @@ -3597,28 +3675,16 @@ msgid "%s%s%s%s has invited %s%s%s on %s%s" msgstr "%s%s%s hat %s%s%s in den Channel %s%s eingeladen\n" #, fuzzy, c-format -msgid "%s%s: cannot identify channel for \"%s\" command" -msgstr "%s kann für den \"%s\"-Befehl keinen Channel identifizieren\n" - -#, fuzzy, c-format -msgid "%s%s: cannot identify nickname for \"%s\" command" -msgstr "%s kann für den \"%s\"-Befehl keinen Nickname identifizieren\n" - -#, fuzzy, c-format msgid "%sChannel reop %s%s%s: %s%s" msgstr "Channel-Reop %s%s%s: %s%s\n" #, fuzzy, c-format -msgid "%s%s[%s%s%s]%s exception %s%s%s" +msgid "%s%s[%s%s%s]%s exception %s%s%s by %s%s %s(%s%s%s)%s on %s" msgstr "%s[%s%s%s] %s%s%s gebannt\n" -#, c-format -msgid " by %s%s %s(%s%s%s)" -msgstr " durch %s%s %s(%s%s%s)" - -#, c-format -msgid " by %s%s" -msgstr " durch %s%s" +#, fuzzy, c-format +msgid "%s%s[%s%s%s]%s exception %s%s" +msgstr "%s[%s%s%s] %s%s%s gebannt\n" #, fuzzy, c-format msgid "%s%s: cannot create nick \"%s\" for channel \"%s\"" @@ -3662,12 +3728,12 @@ msgid "normal" msgstr "normal" #, fuzzy, c-format -msgid "%s%s[%s%s%s] %s%s%s banned by " +msgid "%s%s[%s%s%s] %s%s%s banned by %s%s %s(%s%s%s)%s on %s" msgstr "%s[%s%s%s] %s%s%s wurde gebannt von " #, fuzzy, c-format -msgid "%s%s[%s%s%s] %s%s%s banned" -msgstr "%s[%s%s%s] %s%s%s gebannt\n" +msgid "%s%s[%s%s%s] %s%s%s banned by %s%s %s(%s%s%s)" +msgstr "%s[%s%s%s] %s%s%s wurde gebannt von " #, fuzzy, c-format msgid "" @@ -4415,6 +4481,32 @@ msgstr "" msgid "%s%s: wrong arguments for function \"%s\"" msgstr "%s fehlerhafte Argumente für der \"%s\"-Befehl\n" +#, fuzzy +#~ msgid "%sError: wrong number \"%s\" for filter" +#~ msgstr "%s fehlerhafte Anzahl von Argumenten für der \"%s\"-Befehl\n" + +#, fuzzy +#~ msgid "%sError: command \"%s\" failed" +#~ msgstr "%s der Befehl \"%s\" schlug fehl\n" + +#, fuzzy +#~ msgid "%s%s: cannot identify channel for \"%s\" command" +#~ msgstr "%s kann für den \"%s\"-Befehl keinen Channel identifizieren\n" + +#, fuzzy +#~ msgid "%s%s: cannot identify nickname for \"%s\" command" +#~ msgstr "%s kann für den \"%s\"-Befehl keinen Nickname identifizieren\n" + +#~ msgid " by %s%s %s(%s%s%s)" +#~ msgstr " durch %s%s %s(%s%s%s)" + +#~ msgid " by %s%s" +#~ msgstr " durch %s%s" + +#, fuzzy +#~ msgid "%s%s[%s%s%s] %s%s%s banned" +#~ msgstr "%s[%s%s%s] %s%s%s gebannt\n" + #~ msgid "/list end" #~ msgstr "Ende von /list" @@ -4954,9 +5046,6 @@ msgstr "%s fehlerhafte Argumente für der \"%s\"-Befehl\n" #~ msgid "%s cannot create new private window \"%s\"\n" #~ msgstr "%s kann kein neues privates Fenster \"%s\" erzeugen\n" -#~ msgid "%s[%s%s%s]%s idle: " -#~ msgstr "%s[%s%s%s]%s idlet: " - #~ msgid "%s: trying 2nd nickname \"%s\"\n" #~ msgstr "%s: versuche zweiten Nicknamen \"%s\"\n" @@ -5400,9 +5489,6 @@ msgstr "%s fehlerhafte Argumente für der \"%s\"-Befehl\n" #~ msgid "%s mask or type/command should be non generic value for ignore\n" #~ msgstr "%s Maske und Typ/Befehl dürfen nicht beide allgemein sein\n" -#~ msgid "%s ignore already exists\n" -#~ msgstr "%s diese /ignore-Regel existiert bereits\n" - #~ msgid "%s not enough memory to create ignore\n" #~ msgstr "%s nicht genug Speicher für neue /ignore-Regel\n" @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-03-15 09:33+0100\n" +"POT-Creation-Date: 2008-03-22 23:32+0100\n" "PO-Revision-Date: 2007-09-19 12:09+0200\n" "Last-Translator: Roberto González Cardenete <robert.glez@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -207,6 +207,56 @@ msgstr "(hotlist: resaltados + mensajes)\n" msgid "(hotlist: highlights + messages + join/part (all))" msgstr "(hotlist: resaltados + mensajes + join/part (todos))\n" +#, fuzzy +msgid "Filters are enabled" +msgstr "los usuarios han sido desactivados" + +#, fuzzy +msgid "Filters are disabled" +msgstr "los usuarios han sido desactivados" + +msgid "Message filters:" +msgstr "" + +#, fuzzy, c-format +msgid " %s[%s%d%s]%s buffer: %s%s%s / tags: %s / regex: %s" +msgstr " (sin manejador de mensaje)\n" + +#, fuzzy +msgid "No message filter defined" +msgstr "Ningún alias definido.\n" + +msgid "Filters enabled" +msgstr "" + +#, fuzzy +msgid "Filters disabled" +msgstr "los usuarios han sido desactivados" + +#, fuzzy, c-format +msgid "%sError: filter already exists" +msgstr "el ignore %s ya existe\n" + +#, c-format +msgid "%sError: you must specify at least tag(s) or regex for filter" +msgstr "" + +#, fuzzy +msgid "Filter added" +msgstr "los usuarios han sido desactivados" + +#, fuzzy +msgid "Filter deleted" +msgstr "los usuarios han sido desactivados" + +#, fuzzy, c-format +msgid "%sError: filter not found" +msgstr "%s plugin \"%s\" no encontrado\n" + +#, fuzzy, c-format +msgid "%sError: wrong filter number" +msgstr "%s número de búfer incorrecto\n" + #. TRANSLATORS: %s is "WeeChat" #, fuzzy, c-format msgid "%s internal commands:" @@ -584,6 +634,30 @@ msgstr "" "comando: comando a ejecutar (se añade un '/' automáticamente si no se " "encuentra al principio del comando)\n" +msgid "" +"filter messages in buffers, to hide/show them according to tags or regex" +msgstr "" + +msgid "" +"[list] | [enable|disable|toggle] | [add buffer tags regex] | [del number]" +msgstr "" + +msgid "" +" list: list all filters\n" +" enable: enable filters (filters are enabled by default)\n" +"disable: disable filters\n" +" toggle: toggle filters\n" +" add: add a filter\n" +" del: delete a filter\n" +" number: number of filter to delete (look at list to find it)\n" +" buffer: buffer where filter is active: it may be a name (category.name) or " +"\"*\" for all buffers\n" +" tags: comma separated list of tags, for example: \"irc_join,irc_part," +"irc_quit\"\n" +" regex: regular expression to search in line (use \t to separate prefix " +"from message)" +msgstr "" + msgid "display help about commands" msgstr "mostrar ayuda sobre los comandos" @@ -1471,10 +1545,6 @@ msgid " . description: %s\n" msgstr " . descripción: %s\n" #, fuzzy, c-format -msgid "%sError: command \"%s\" failed" -msgstr "%s el comando \"%s\" ha fallado\n" - -#, fuzzy, c-format msgid "%sError: unknown command \"%s\" (type /help for help)" msgstr "%s alias o comando \"%s\" no encontrado\n" @@ -1549,6 +1619,14 @@ msgstr "-MÃS-" msgid "server" msgstr "servidor" +#, fuzzy, c-format +msgid "%s[%sF%s%s%s]" +msgstr "%s[%s%s%s]%s inactividad: " + +#, fuzzy +msgid "filtered" +msgstr "los usuarios han sido desactivados" + #, fuzzy msgid "(MORE)" msgstr "-MÃS-" @@ -3538,7 +3616,7 @@ msgid "%sUser mode for %s%s%s is %s[%s%s%s]" msgstr "Modo de usuario %s[%s%s%s/%s%s%s]\n" #, fuzzy, c-format -msgid "%s%s%s%s is away: %s" +msgid "%s%s[%s%s%s]%s is away: %s" msgstr "%s%s%s está ausente: %s\n" #, fuzzy, c-format @@ -3601,29 +3679,16 @@ msgid "%s%s%s%s has invited %s%s%s on %s%s" msgstr "%s%s%s ha invitado a %s%s%s en %s%s\n" #, fuzzy, c-format -msgid "%s%s: cannot identify channel for \"%s\" command" -msgstr "%s no es posible identificar el canal para el comando \"%s\"\n" - -#, fuzzy, c-format -msgid "%s%s: cannot identify nickname for \"%s\" command" -msgstr "" -"%s no es posible determinar el nombre de usuario para el comando \"%s\"\n" - -#, fuzzy, c-format msgid "%sChannel reop %s%s%s: %s%s" msgstr "reop canal %s%s%s: %s%s\n" #, fuzzy, c-format -msgid "%s%s[%s%s%s]%s exception %s%s%s" +msgid "%s%s[%s%s%s]%s exception %s%s%s by %s%s %s(%s%s%s)%s on %s" msgstr "%s[%s%s%s] %s%s%s baneado\n" #, fuzzy, c-format -msgid " by %s%s %s(%s%s%s)" -msgstr "%s%s %s(%s%s%s)%s ha salido" - -#, c-format -msgid " by %s%s" -msgstr "" +msgid "%s%s[%s%s%s]%s exception %s%s" +msgstr "%s[%s%s%s] %s%s%s baneado\n" #, fuzzy, c-format msgid "%s%s: cannot create nick \"%s\" for channel \"%s\"" @@ -3667,12 +3732,12 @@ msgid "normal" msgstr "normal" #, fuzzy, c-format -msgid "%s%s[%s%s%s] %s%s%s banned by " +msgid "%s%s[%s%s%s] %s%s%s banned by %s%s %s(%s%s%s)%s on %s" msgstr "%s[%s%s%s] %s%s%s baneado por " #, fuzzy, c-format -msgid "%s%s[%s%s%s] %s%s%s banned" -msgstr "%s[%s%s%s] %s%s%s baneado\n" +msgid "%s%s[%s%s%s] %s%s%s banned by %s%s %s(%s%s%s)" +msgstr "%s[%s%s%s] %s%s%s baneado por " #, fuzzy, c-format msgid "" @@ -4428,6 +4493,31 @@ msgstr "" msgid "%s%s: wrong arguments for function \"%s\"" msgstr "%s argumentos incorrectos para el comando \"%s\"\n" +#, fuzzy +#~ msgid "%sError: wrong number \"%s\" for filter" +#~ msgstr "%s número de argumentos incorrecto para el comando \"%s\"\n" + +#, fuzzy +#~ msgid "%sError: command \"%s\" failed" +#~ msgstr "%s el comando \"%s\" ha fallado\n" + +#, fuzzy +#~ msgid "%s%s: cannot identify channel for \"%s\" command" +#~ msgstr "%s no es posible identificar el canal para el comando \"%s\"\n" + +#, fuzzy +#~ msgid "%s%s: cannot identify nickname for \"%s\" command" +#~ msgstr "" +#~ "%s no es posible determinar el nombre de usuario para el comando \"%s\"\n" + +#, fuzzy +#~ msgid " by %s%s %s(%s%s%s)" +#~ msgstr "%s%s %s(%s%s%s)%s ha salido" + +#, fuzzy +#~ msgid "%s%s[%s%s%s] %s%s%s banned" +#~ msgstr "%s[%s%s%s] %s%s%s baneado\n" + #~ msgid "/list end" #~ msgstr "/list fin" @@ -4963,9 +5053,6 @@ msgstr "%s argumentos incorrectos para el comando \"%s\"\n" #~ msgid "%s cannot create new private window \"%s\"\n" #~ msgstr "%s no es posible crear una nueva ventana privada \"%s\"\n" -#~ msgid "%s[%s%s%s]%s idle: " -#~ msgstr "%s[%s%s%s]%s inactividad: " - #, fuzzy #~ msgid "%s: trying 2nd nickname \"%s\"\n" #~ msgstr "" @@ -5436,9 +5523,6 @@ msgstr "%s argumentos incorrectos para el comando \"%s\"\n" #~ "%s máscara o tipo/comando deberÃa ser un valor no genérico para el " #~ "ignore\n" -#~ msgid "%s ignore already exists\n" -#~ msgstr "el ignore %s ya existe\n" - #~ msgid "%s not enough memory to create ignore\n" #~ msgstr "%s no hay suficiente memoria para crear el ignore\n" @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-03-15 09:33+0100\n" -"PO-Revision-Date: 2008-03-15 09:34+0100\n" +"POT-Creation-Date: 2008-03-22 23:32+0100\n" +"PO-Revision-Date: 2008-03-22 23:33+0100\n" "Last-Translator: FlashCode <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "MIME-Version: 1.0\n" @@ -194,6 +194,52 @@ msgstr "(hotlist: highlights + messages)" msgid "(hotlist: highlights + messages + join/part (all))" msgstr "(hotlist: highlights + messages + join/part (tous))" +msgid "Filters are enabled" +msgstr "Les filtres sont activés" + +msgid "Filters are disabled" +msgstr "Les filtres sont désactivés" + +msgid "Message filters:" +msgstr "Filtres de messages:" + +#, c-format +msgid " %s[%s%d%s]%s buffer: %s%s%s / tags: %s / regex: %s" +msgstr " %s[%s%d%s]%s tampon: %s%s%s / tags: %s / regex: %s" + +msgid "No message filter defined" +msgstr "Pas de filtre de message défini" + +msgid "Filters enabled" +msgstr "Filtres activés" + +msgid "Filters disabled" +msgstr "Filtres désactivés" + +#, c-format +msgid "%sError: filter already exists" +msgstr "%sErreur: le filtre existe déjà" + +#, c-format +msgid "%sError: you must specify at least tag(s) or regex for filter" +msgstr "" +"%sErreur: vous devez spécifier au moins un/plusieurs tags(s) ou une " +"expression régulière pour filtrer" + +msgid "Filter added" +msgstr "Filtre ajouté" + +msgid "Filter deleted" +msgstr "Filtre supprimé" + +#, c-format +msgid "%sError: filter not found" +msgstr "%sErreur: filtre non trouvé" + +#, c-format +msgid "%sError: wrong filter number" +msgstr "%sErreur: numéro de filtre incorrect" + #. TRANSLATORS: %s is "WeeChat" #, c-format msgid "%s internal commands:" @@ -565,6 +611,43 @@ msgstr "" "commande: commande à exécuter (un '/' est automatiquement ajouté s'il n'est " "pas trouvé au début de la commande)" +msgid "" +"filter messages in buffers, to hide/show them according to tags or regex" +msgstr "" +"filtre les messages dans les tampons, pour les cacher/afficher selon des " +"tags ou expressions régulières" + +msgid "" +"[list] | [enable|disable|toggle] | [add buffer tags regex] | [del number]" +msgstr "" +"[list] | [enable|disable|toggle] | [add buffer tags regex] | [del numéro]" + +msgid "" +" list: list all filters\n" +" enable: enable filters (filters are enabled by default)\n" +"disable: disable filters\n" +" toggle: toggle filters\n" +" add: add a filter\n" +" del: delete a filter\n" +" number: number of filter to delete (look at list to find it)\n" +" buffer: buffer where filter is active: it may be a name (category.name) or " +"\"*\" for all buffers\n" +" tags: comma separated list of tags, for example: \"irc_join,irc_part," +"irc_quit\"\n" +" regex: regular expression to search in line (use \t to separate prefix " +"from message)" +msgstr "" +" list: liste tous les filtres\n" +" enable: active les filtres (par défaut les filtres sont activés)\n" +"disable: désactive les filtres\n" +" toggle: active/désactive les filtres\n" +" add: ajoute un filtre\n" +" del: supprime un filtre\n" +" numéro: numéro du filtre à supprimer (voir la liste des filtres pour le trouver)\n" +" buffer: tampon où le filtre est actif: cela peut être un nom (catégorie.nom) ou \"*\" pour tous les tampons\n" +" tags: liste de tags, séparés par des virgules, par exemple: \"irc_join,irc_part,irc_quit\"\n" +" regex: expressoin régulière à rechercher dans la ligne (utiliser \\t pour séparer le préfixe du message)" + msgid "display help about commands" msgstr "afficher l'aide sur les commandes" @@ -1392,10 +1475,6 @@ msgid " . description: %s\n" msgstr " . description: %s\n" #, c-format -msgid "%sError: command \"%s\" failed" -msgstr "%sErreur: la commande \"%s\" a échoué" - -#, c-format msgid "%sError: unknown command \"%s\" (type /help for help)" msgstr "%sErreur: commande \"%s\" inconnue (tapez /help pour l'aide)" @@ -1475,6 +1554,13 @@ msgstr "-PLUS-" msgid "server" msgstr "serveur" +#, c-format +msgid "%s[%sF%s%s%s]" +msgstr "%s[%sF%s%s%s]" + +msgid "filtered" +msgstr "filtré" + msgid "(MORE)" msgstr "(PLUS)" @@ -3468,8 +3554,8 @@ msgid "%sUser mode for %s%s%s is %s[%s%s%s]" msgstr "%sMode utilisateur pour %s%s%s est %s[%s%s%s]" #, c-format -msgid "%s%s%s%s is away: %s" -msgstr "%s%s%s%s est absent: %s" +msgid "%s%s[%s%s%s]%s is away: %s" +msgstr "%s%s[%s%s%s]%s est absent: %s" #, c-format msgid "%sUsers online: %s%s" @@ -3533,28 +3619,16 @@ msgid "%s%s%s%s has invited %s%s%s on %s%s" msgstr "%s%s%s%s a invité %s%s%s sur %s%s" #, c-format -msgid "%s%s: cannot identify channel for \"%s\" command" -msgstr "%s%s: impossible de déterminer le canal pour la commande \"%s\"" - -#, c-format -msgid "%s%s: cannot identify nickname for \"%s\" command" -msgstr "%s%s: impossible de déterminer le pseudo pour la commande \"%s\"" - -#, c-format msgid "%sChannel reop %s%s%s: %s%s" msgstr "%sReop canal %s%s%s: %s%s" #, c-format -msgid "%s%s[%s%s%s]%s exception %s%s%s" -msgstr "%s%s[%s%s%s]%s exception %s%s%s" - -#, c-format -msgid " by %s%s %s(%s%s%s)" -msgstr " par %s%s %s(%s%s%s)" +msgid "%s%s[%s%s%s]%s exception %s%s%s by %s%s %s(%s%s%s)%s on %s" +msgstr "%s%s[%s%s%s]%s exception %s%s%s par %s%s %s(%s%s%s)%s le %s" #, c-format -msgid " by %s%s" -msgstr " par %s%s" +msgid "%s%s[%s%s%s]%s exception %s%s" +msgstr "%s%s[%s%s%s]%s exception %s%s" #, c-format msgid "%s%s: cannot create nick \"%s\" for channel \"%s\"" @@ -3598,12 +3672,12 @@ msgid "normal" msgstr "normal" #, c-format -msgid "%s%s[%s%s%s] %s%s%s banned by " -msgstr "%s%s[%s%s%s] %s%s%s banni par " +msgid "%s%s[%s%s%s] %s%s%s banned by %s%s %s(%s%s%s)%s on %s" +msgstr "%s%s[%s%s%s] %s%s%s banni par %s%s %s(%s%s%s)%s le %s" #, c-format -msgid "%s%s[%s%s%s] %s%s%s banned" -msgstr "%s%s[%s%s%s] %s%s%s banni" +msgid "%s%s[%s%s%s] %s%s%s banned by %s%s %s(%s%s%s)" +msgstr "%s%s[%s%s%s] %s%s%s banni par %s%s %s(%s%s%s)" #, c-format msgid "" @@ -3698,7 +3772,6 @@ msgstr "/list début" msgid "channel (for /list)" msgstr "canal (pour /list)" -#, fuzzy msgid "end of /list" msgstr "fin de /list" @@ -4369,6 +4442,27 @@ msgstr "" msgid "%s%s: wrong arguments for function \"%s\"" msgstr "%s%s: paramètres invalides pour la fonction \"%s\"" +#~ msgid "%s[%sfiltered%s]" +#~ msgstr "%s[%sfiltré%s]" + +#~ msgid "%sError: wrong number \"%s\" for filter" +#~ msgstr "%sErreur: numéro de filtre erroné" + +#~ msgid "%sError: command \"%s\" failed" +#~ msgstr "%sErreur: la commande \"%s\" a échoué" + +#~ msgid "%s%s: cannot identify channel for \"%s\" command" +#~ msgstr "%s%s: impossible de déterminer le canal pour la commande \"%s\"" + +#~ msgid "%s%s: cannot identify nickname for \"%s\" command" +#~ msgstr "%s%s: impossible de déterminer le pseudo pour la commande \"%s\"" + +#~ msgid " by %s%s" +#~ msgstr " par %s%s" + +#~ msgid "%s%s[%s%s%s] %s%s%s banned" +#~ msgstr "%s%s[%s%s%s] %s%s%s banni" + #~ msgid "/list end" #~ msgstr "/list fin" @@ -12,7 +12,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-03-15 09:33+0100\n" +"POT-Creation-Date: 2008-03-22 23:32+0100\n" "PO-Revision-Date: 2007-10-10 18:07+0200\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -210,6 +210,56 @@ msgstr "" msgid "(hotlist: highlights + messages + join/part (all))" msgstr "" +#, fuzzy +msgid "Filters are enabled" +msgstr "a felhasználók le lettek tiltva" + +#, fuzzy +msgid "Filters are disabled" +msgstr "a felhasználók le lettek tiltva" + +msgid "Message filters:" +msgstr "" + +#, fuzzy, c-format +msgid " %s[%s%d%s]%s buffer: %s%s%s / tags: %s / regex: %s" +msgstr " (nincs üzenetkezelő)\n" + +#, fuzzy +msgid "No message filter defined" +msgstr "Nincs aliasz definiálva.\n" + +msgid "Filters enabled" +msgstr "" + +#, fuzzy +msgid "Filters disabled" +msgstr "a felhasználók le lettek tiltva" + +#, fuzzy, c-format +msgid "%sError: filter already exists" +msgstr "%s az ignore már létezik\n" + +#, c-format +msgid "%sError: you must specify at least tag(s) or regex for filter" +msgstr "" + +#, fuzzy +msgid "Filter added" +msgstr "a felhasználók le lettek tiltva" + +#, fuzzy +msgid "Filter deleted" +msgstr "a felhasználók le lettek tiltva" + +#, fuzzy, c-format +msgid "%sError: filter not found" +msgstr "%s a \"%s\" modul nem található\n" + +#, fuzzy, c-format +msgid "%sError: wrong filter number" +msgstr "%s helytelen pufferszám\n" + #. TRANSLATORS: %s is "WeeChat" #, fuzzy, c-format msgid "%s internal commands:" @@ -601,6 +651,30 @@ msgstr "" "parancs: futtatandó parancs (egy '/' autómatikusan hozzáadódik, ha nincs " "megadva a parancs elején)\n" +msgid "" +"filter messages in buffers, to hide/show them according to tags or regex" +msgstr "" + +msgid "" +"[list] | [enable|disable|toggle] | [add buffer tags regex] | [del number]" +msgstr "" + +msgid "" +" list: list all filters\n" +" enable: enable filters (filters are enabled by default)\n" +"disable: disable filters\n" +" toggle: toggle filters\n" +" add: add a filter\n" +" del: delete a filter\n" +" number: number of filter to delete (look at list to find it)\n" +" buffer: buffer where filter is active: it may be a name (category.name) or " +"\"*\" for all buffers\n" +" tags: comma separated list of tags, for example: \"irc_join,irc_part," +"irc_quit\"\n" +" regex: regular expression to search in line (use \t to separate prefix " +"from message)" +msgstr "" + msgid "display help about commands" msgstr "segítség megjelenítése a parancsokhoz" @@ -1487,10 +1561,6 @@ msgid " . description: %s\n" msgstr " . leírás : %s\n" #, fuzzy, c-format -msgid "%sError: command \"%s\" failed" -msgstr "%s a \"%s\" parancs végrehajtása sikertelen\n" - -#, fuzzy, c-format msgid "%sError: unknown command \"%s\" (type /help for help)" msgstr "%s a \"%s\" aliasz vagy parancs nem található\n" @@ -1567,6 +1637,14 @@ msgstr "-TOVÁBB-" msgid "server" msgstr "szerver" +#, fuzzy, c-format +msgid "%s[%sF%s%s%s]" +msgstr "%s[%s%s%s]%s tétlen: " + +#, fuzzy +msgid "filtered" +msgstr "a felhasználók le lettek tiltva" + #, fuzzy msgid "(MORE)" msgstr "-TOVÁBB-" @@ -3552,7 +3630,7 @@ msgid "%sUser mode for %s%s%s is %s[%s%s%s]" msgstr "%s%s%s felhasználói módja: %s[%s%s%s]\n" #, fuzzy, c-format -msgid "%s%s%s%s is away: %s" +msgid "%s%s[%s%s%s]%s is away: %s" msgstr "%s%s%s távol: %s\n" #, fuzzy, c-format @@ -3615,28 +3693,16 @@ msgid "%s%s%s%s has invited %s%s%s on %s%s" msgstr "%s%s%s meghívta %s%s%s-t %s%s-kor\n" #, fuzzy, c-format -msgid "%s%s: cannot identify channel for \"%s\" command" -msgstr "%s nem sikerült azonosítani a szobát a \"%s\" parancshoz\n" - -#, fuzzy, c-format -msgid "%s%s: cannot identify nickname for \"%s\" command" -msgstr "%s nem sikerült a felhasználót meghatározni a \"%s\" parancshoz\n" - -#, fuzzy, c-format msgid "%sChannel reop %s%s%s: %s%s" msgstr "%s szoba: %s> %s" #, fuzzy, c-format -msgid "%s%s[%s%s%s]%s exception %s%s%s" +msgid "%s%s[%s%s%s]%s exception %s%s%s by %s%s %s(%s%s%s)%s on %s" msgstr "%s[%s%s%s] %s%s%s kitiltva\n" -#, c-format -msgid " by %s%s %s(%s%s%s)" -msgstr " a következőtől: %s%s %s(%s%s%s)" - -#, c-format -msgid " by %s%s" -msgstr " a következőtől: %s%s" +#, fuzzy, c-format +msgid "%s%s[%s%s%s]%s exception %s%s" +msgstr "%s[%s%s%s] %s%s%s kitiltva\n" #, fuzzy, c-format msgid "%s%s: cannot create nick \"%s\" for channel \"%s\"" @@ -3680,12 +3746,12 @@ msgid "normal" msgstr "normál" #, fuzzy, c-format -msgid "%s%s[%s%s%s] %s%s%s banned by " +msgid "%s%s[%s%s%s] %s%s%s banned by %s%s %s(%s%s%s)%s on %s" msgstr "%s[%s%s%s] %s%s%s-t kitiltotta " #, fuzzy, c-format -msgid "%s%s[%s%s%s] %s%s%s banned" -msgstr "%s[%s%s%s] %s%s%s kitiltva\n" +msgid "%s%s[%s%s%s] %s%s%s banned by %s%s %s(%s%s%s)" +msgstr "%s[%s%s%s] %s%s%s-t kitiltotta " #, fuzzy, c-format msgid "" @@ -4430,6 +4496,32 @@ msgstr "" msgid "%s%s: wrong arguments for function \"%s\"" msgstr "%s rossz argumentum a \"%s\" parancsnak\n" +#, fuzzy +#~ msgid "%sError: wrong number \"%s\" for filter" +#~ msgstr "%s rossz argumentum szám a \"%s\" parancsnak\n" + +#, fuzzy +#~ msgid "%sError: command \"%s\" failed" +#~ msgstr "%s a \"%s\" parancs végrehajtása sikertelen\n" + +#, fuzzy +#~ msgid "%s%s: cannot identify channel for \"%s\" command" +#~ msgstr "%s nem sikerült azonosítani a szobát a \"%s\" parancshoz\n" + +#, fuzzy +#~ msgid "%s%s: cannot identify nickname for \"%s\" command" +#~ msgstr "%s nem sikerült a felhasználót meghatározni a \"%s\" parancshoz\n" + +#~ msgid " by %s%s %s(%s%s%s)" +#~ msgstr " a következőtől: %s%s %s(%s%s%s)" + +#~ msgid " by %s%s" +#~ msgstr " a következőtől: %s%s" + +#, fuzzy +#~ msgid "%s%s[%s%s%s] %s%s%s banned" +#~ msgstr "%s[%s%s%s] %s%s%s kitiltva\n" + #~ msgid "/list end" #~ msgstr "/list vége" @@ -4957,9 +5049,6 @@ msgstr "%s rossz argumentum a \"%s\" parancsnak\n" #~ msgid "%s cannot create new private window \"%s\"\n" #~ msgstr "%s nem sikerült új privát ablakot nyitni \"%s\"\n" -#~ msgid "%s[%s%s%s]%s idle: " -#~ msgstr "%s[%s%s%s]%s tétlen: " - #~ msgid "%s: trying 2nd nickname \"%s\"\n" #~ msgstr "%s: próbálom a második nevet: \"%s\"\n" @@ -5400,9 +5489,6 @@ msgstr "%s rossz argumentum a \"%s\" parancsnak\n" #~ msgid "%s mask or type/command should be non generic value for ignore\n" #~ msgstr "%s maszk vagy típus/parancs nem általános érték az ignore-hoz\n" -#~ msgid "%s ignore already exists\n" -#~ msgstr "%s az ignore már létezik\n" - #~ msgid "Removing ignore:" #~ msgstr "Ignore eltávolítása:" @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.2.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-03-15 09:33+0100\n" +"POT-Creation-Date: 2008-03-22 23:32+0100\n" "PO-Revision-Date: 2007-09-06 12:44+0200\n" "Last-Translator: Pavel Shevchuk <stlwrt@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -208,6 +208,56 @@ msgstr "(hotlist: подсвечивание + сообщения)\n" msgid "(hotlist: highlights + messages + join/part (all))" msgstr "(хотлист: подсвечивание + сообщения + входы/выходы (всё))\n" +#, fuzzy +msgid "Filters are enabled" +msgstr "команда users отключена" + +#, fuzzy +msgid "Filters are disabled" +msgstr "команда users отключена" + +msgid "Message filters:" +msgstr "" + +#, fuzzy, c-format +msgid " %s[%s%d%s]%s buffer: %s%s%s / tags: %s / regex: %s" +msgstr " (нет обработчика сообщений)\n" + +#, fuzzy +msgid "No message filter defined" +msgstr "Сокращения не заданы.\n" + +msgid "Filters enabled" +msgstr "" + +#, fuzzy +msgid "Filters disabled" +msgstr "команда users отключена" + +#, fuzzy, c-format +msgid "%sError: filter already exists" +msgstr "%s игнорирование уже существует\n" + +#, c-format +msgid "%sError: you must specify at least tag(s) or regex for filter" +msgstr "" + +#, fuzzy +msgid "Filter added" +msgstr "команда users отключена" + +#, fuzzy +msgid "Filter deleted" +msgstr "команда users отключена" + +#, fuzzy, c-format +msgid "%sError: filter not found" +msgstr "%s plugin \"%s\" не найден\n" + +#, fuzzy, c-format +msgid "%sError: wrong filter number" +msgstr "%s неправильный номер буфера\n" + #. TRANSLATORS: %s is "WeeChat" #, fuzzy, c-format msgid "%s internal commands:" @@ -596,6 +646,30 @@ msgstr "" "команда: исполняемая команда ('/' автоматически добавляется в начало " "команды)\n" +msgid "" +"filter messages in buffers, to hide/show them according to tags or regex" +msgstr "" + +msgid "" +"[list] | [enable|disable|toggle] | [add buffer tags regex] | [del number]" +msgstr "" + +msgid "" +" list: list all filters\n" +" enable: enable filters (filters are enabled by default)\n" +"disable: disable filters\n" +" toggle: toggle filters\n" +" add: add a filter\n" +" del: delete a filter\n" +" number: number of filter to delete (look at list to find it)\n" +" buffer: buffer where filter is active: it may be a name (category.name) or " +"\"*\" for all buffers\n" +" tags: comma separated list of tags, for example: \"irc_join,irc_part," +"irc_quit\"\n" +" regex: regular expression to search in line (use \t to separate prefix " +"from message)" +msgstr "" + msgid "display help about commands" msgstr "отобразить помощь по командам" @@ -1487,10 +1561,6 @@ msgid " . description: %s\n" msgstr " . описание: %s\n" #, fuzzy, c-format -msgid "%sError: command \"%s\" failed" -msgstr "%s команда \"%s\" не удалась\n" - -#, fuzzy, c-format msgid "%sError: unknown command \"%s\" (type /help for help)" msgstr "%s сокращение или команда \"%s\" не найдены\n" @@ -1568,6 +1638,14 @@ msgstr "-ДАЛЬШЕ-" msgid "server" msgstr "сервер" +#, fuzzy, c-format +msgid "%s[%sF%s%s%s]" +msgstr "%s[%s%s%s]%s бездействует: " + +#, fuzzy +msgid "filtered" +msgstr "команда users отключена" + #, fuzzy msgid "(MORE)" msgstr "-ДАЛЬШЕ-" @@ -3540,7 +3618,7 @@ msgid "%sUser mode for %s%s%s is %s[%s%s%s]" msgstr "Режим пользователя %s%s%s - %s[%s%s%s]\n" #, fuzzy, c-format -msgid "%s%s%s%s is away: %s" +msgid "%s%s[%s%s%s]%s is away: %s" msgstr "%s%s%s отсутствует: %s\n" #, fuzzy, c-format @@ -3603,28 +3681,16 @@ msgid "%s%s%s%s has invited %s%s%s on %s%s" msgstr "%s%s%s пригласил %s%s%s на канал %s%s\n" #, fuzzy, c-format -msgid "%s%s: cannot identify channel for \"%s\" command" -msgstr "%s не могу опознать канал для команды \"%s\"\n" - -#, fuzzy, c-format -msgid "%s%s: cannot identify nickname for \"%s\" command" -msgstr "%s не могу опознать ник для команды \"%s\"\n" - -#, fuzzy, c-format msgid "%sChannel reop %s%s%s: %s%s" msgstr "Реоп канала %s%s%s: %s%s\n" #, fuzzy, c-format -msgid "%s%s[%s%s%s]%s exception %s%s%s" +msgid "%s%s[%s%s%s]%s exception %s%s%s by %s%s %s(%s%s%s)%s on %s" msgstr "%s[%s%s%s] %s%s%s забанен\n" -#, c-format -msgid " by %s%s %s(%s%s%s)" -msgstr " пользователем %s%s %s(%s%s%s)" - -#, c-format -msgid " by %s%s" -msgstr " пользователем %s%s" +#, fuzzy, c-format +msgid "%s%s[%s%s%s]%s exception %s%s" +msgstr "%s[%s%s%s] %s%s%s забанен\n" #, fuzzy, c-format msgid "%s%s: cannot create nick \"%s\" for channel \"%s\"" @@ -3668,12 +3734,12 @@ msgid "normal" msgstr "обычные" #, fuzzy, c-format -msgid "%s%s[%s%s%s] %s%s%s banned by " +msgid "%s%s[%s%s%s] %s%s%s banned by %s%s %s(%s%s%s)%s on %s" msgstr "%s[%s%s%s] %s%s%s забанен пользователем " #, fuzzy, c-format -msgid "%s%s[%s%s%s] %s%s%s banned" -msgstr "%s[%s%s%s] %s%s%s забанен\n" +msgid "%s%s[%s%s%s] %s%s%s banned by %s%s %s(%s%s%s)" +msgstr "%s[%s%s%s] %s%s%s забанен пользователем " #, fuzzy, c-format msgid "" @@ -4412,6 +4478,32 @@ msgstr "" msgid "%s%s: wrong arguments for function \"%s\"" msgstr "%s некорректные аргументы команды \"%s\"\n" +#, fuzzy +#~ msgid "%sError: wrong number \"%s\" for filter" +#~ msgstr "%s некорректное количество аргументов команды \"%s\"\n" + +#, fuzzy +#~ msgid "%sError: command \"%s\" failed" +#~ msgstr "%s команда \"%s\" не удалась\n" + +#, fuzzy +#~ msgid "%s%s: cannot identify channel for \"%s\" command" +#~ msgstr "%s не могу опознать канал для команды \"%s\"\n" + +#, fuzzy +#~ msgid "%s%s: cannot identify nickname for \"%s\" command" +#~ msgstr "%s не могу опознать ник для команды \"%s\"\n" + +#~ msgid " by %s%s %s(%s%s%s)" +#~ msgstr " пользователем %s%s %s(%s%s%s)" + +#~ msgid " by %s%s" +#~ msgstr " пользователем %s%s" + +#, fuzzy +#~ msgid "%s%s[%s%s%s] %s%s%s banned" +#~ msgstr "%s[%s%s%s] %s%s%s забанен\n" + #~ msgid "/list end" #~ msgstr "конец /list" @@ -4945,9 +5037,6 @@ msgstr "%s некорректные аргументы команды \"%s\"\n" #~ msgid "%s cannot create new private window \"%s\"\n" #~ msgstr "%s не могу создать новое окно привата \"%s\"\n" -#~ msgid "%s[%s%s%s]%s idle: " -#~ msgstr "%s[%s%s%s]%s бездействует: " - #~ msgid "%s: trying 2nd nickname \"%s\"\n" #~ msgstr "%s: пробую второй ник \"%s\"\n" @@ -5400,9 +5489,6 @@ msgstr "%s некорректные аргументы команды \"%s\"\n" #~ "%s маска или тип/команда должны быть необычного значения для " #~ "игнорирования\n" -#~ msgid "%s ignore already exists\n" -#~ msgstr "%s игнорирование уже существует\n" - #~ msgid "%s not enough memory to create ignore\n" #~ msgstr "%s недостаточно памяти для создания игнорирования\n" diff --git a/po/srcfiles.cmake b/po/srcfiles.cmake index 9acafbf79..cd8306674 100644 --- a/po/srcfiles.cmake +++ b/po/srcfiles.cmake @@ -63,6 +63,8 @@ SET(WEECHAT_SOURCES ./src/gui/gui-color.h ./src/gui/gui-completion.c ./src/gui/gui-completion.h +./src/gui/gui-filter.c +./src/gui/gui-filter.h ./src/gui/gui-history.c ./src/gui/gui-history.h ./src/gui/gui-hotlist.c diff --git a/po/weechat.pot b/po/weechat.pot index 527e36594..bf2820ee5 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2008-03-15 09:33+0100\n" +"POT-Creation-Date: 2008-03-22 23:32+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -177,6 +177,50 @@ msgstr "" msgid "(hotlist: highlights + messages + join/part (all))" msgstr "" +msgid "Filters are enabled" +msgstr "" + +msgid "Filters are disabled" +msgstr "" + +msgid "Message filters:" +msgstr "" + +#, c-format +msgid " %s[%s%d%s]%s buffer: %s%s%s / tags: %s / regex: %s" +msgstr "" + +msgid "No message filter defined" +msgstr "" + +msgid "Filters enabled" +msgstr "" + +msgid "Filters disabled" +msgstr "" + +#, c-format +msgid "%sError: filter already exists" +msgstr "" + +#, c-format +msgid "%sError: you must specify at least tag(s) or regex for filter" +msgstr "" + +msgid "Filter added" +msgstr "" + +msgid "Filter deleted" +msgstr "" + +#, c-format +msgid "%sError: filter not found" +msgstr "" + +#, c-format +msgid "%sError: wrong filter number" +msgstr "" + #. TRANSLATORS: %s is "WeeChat" #, c-format msgid "%s internal commands:" @@ -501,6 +545,30 @@ msgid "" "beginning of command)" msgstr "" +msgid "" +"filter messages in buffers, to hide/show them according to tags or regex" +msgstr "" + +msgid "" +"[list] | [enable|disable|toggle] | [add buffer tags regex] | [del number]" +msgstr "" + +msgid "" +" list: list all filters\n" +" enable: enable filters (filters are enabled by default)\n" +"disable: disable filters\n" +" toggle: toggle filters\n" +" add: add a filter\n" +" del: delete a filter\n" +" number: number of filter to delete (look at list to find it)\n" +" buffer: buffer where filter is active: it may be a name (category.name) or " +"\"*\" for all buffers\n" +" tags: comma separated list of tags, for example: \"irc_join,irc_part," +"irc_quit\"\n" +" regex: regular expression to search in line (use \t to separate prefix " +"from message)" +msgstr "" + msgid "display help about commands" msgstr "" @@ -1198,10 +1266,6 @@ msgid " . description: %s\n" msgstr "" #, c-format -msgid "%sError: command \"%s\" failed" -msgstr "" - -#, c-format msgid "%sError: unknown command \"%s\" (type /help for help)" msgstr "" @@ -1271,6 +1335,13 @@ msgstr "" msgid "server" msgstr "" +#, c-format +msgid "%s[%sF%s%s%s]" +msgstr "" + +msgid "filtered" +msgstr "" + msgid "(MORE)" msgstr "" @@ -3008,7 +3079,7 @@ msgid "%sUser mode for %s%s%s is %s[%s%s%s]" msgstr "" #, c-format -msgid "%s%s%s%s is away: %s" +msgid "%s%s[%s%s%s]%s is away: %s" msgstr "" #, c-format @@ -3069,27 +3140,15 @@ msgid "%s%s%s%s has invited %s%s%s on %s%s" msgstr "" #, c-format -msgid "%s%s: cannot identify channel for \"%s\" command" -msgstr "" - -#, c-format -msgid "%s%s: cannot identify nickname for \"%s\" command" -msgstr "" - -#, c-format msgid "%sChannel reop %s%s%s: %s%s" msgstr "" #, c-format -msgid "%s%s[%s%s%s]%s exception %s%s%s" -msgstr "" - -#, c-format -msgid " by %s%s %s(%s%s%s)" +msgid "%s%s[%s%s%s]%s exception %s%s%s by %s%s %s(%s%s%s)%s on %s" msgstr "" #, c-format -msgid " by %s%s" +msgid "%s%s[%s%s%s]%s exception %s%s" msgstr "" #, c-format @@ -3133,11 +3192,11 @@ msgid "normal" msgstr "" #, c-format -msgid "%s%s[%s%s%s] %s%s%s banned by " +msgid "%s%s[%s%s%s] %s%s%s banned by %s%s %s(%s%s%s)%s on %s" msgstr "" #, c-format -msgid "%s%s[%s%s%s] %s%s%s banned" +msgid "%s%s[%s%s%s] %s%s%s banned by %s%s %s(%s%s%s)" msgstr "" #, c-format diff --git a/src/core/wee-command.c b/src/core/wee-command.c index d42a99ce6..f7a7108d4 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -45,6 +45,7 @@ #include "../gui/gui-buffer.h" #include "../gui/gui-chat.h" #include "../gui/gui-color.h" +#include "../gui/gui-filter.h" #include "../gui/gui-history.h" #include "../gui/gui-input.h" #include "../gui/gui-keyboard.h" @@ -172,7 +173,7 @@ command_bar (void *data, struct t_gui_buffer *buffer, } error = NULL; number = strtol (argv[5], &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) { size = number; separator = 0; @@ -241,7 +242,7 @@ command_buffer (void *data, struct t_gui_buffer *buffer, ptr_buffer = ptr_buffer->next_buffer) { gui_chat_printf (NULL, - "%s[%s%d%s]%s (%s) %s / %s", + " %s[%s%d%s]%s (%s) %s / %s", GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), GUI_COLOR(GUI_COLOR_CHAT), ptr_buffer->number, @@ -268,7 +269,7 @@ command_buffer (void *data, struct t_gui_buffer *buffer, { error = NULL; number = strtol (argv[i], &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) { ptr_buffer = gui_buffer_search_by_number (number); if (ptr_buffer) @@ -297,7 +298,7 @@ command_buffer (void *data, struct t_gui_buffer *buffer, number = strtol (((argv[2][0] == '+') || (argv[2][0] == '-')) ? argv[2] + 1 : argv[2], &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) { if (argv[2][0] == '+') gui_buffer_move_to_number (buffer, @@ -354,7 +355,7 @@ command_buffer (void *data, struct t_gui_buffer *buffer, /* set notify level for buffer */ error = NULL; number = strtol (argv[2], &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) { if ((number < GUI_BUFFER_NOTIFY_LEVEL_MIN) || (number > GUI_BUFFER_NOTIFY_LEVEL_MAX)) @@ -441,7 +442,7 @@ command_buffer (void *data, struct t_gui_buffer *buffer, /* relative jump '-' */ error = NULL; number = strtol (argv[1] + 1, &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) { target_buffer = buffer->number - (int) number; if (target_buffer < 1) @@ -456,7 +457,7 @@ command_buffer (void *data, struct t_gui_buffer *buffer, /* relative jump '+' */ error = NULL; number = strtol (argv[1] + 1, &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) { target_buffer = buffer->number + (int) number; if (last_gui_buffer && target_buffer > last_gui_buffer->number) @@ -470,7 +471,7 @@ command_buffer (void *data, struct t_gui_buffer *buffer, /* absolute jump by number, or by category/name */ error = NULL; number = strtol (argv[1], &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) gui_buffer_switch_by_number (gui_current_window, (int) number); else @@ -539,6 +540,169 @@ command_builtin (void *data, struct t_gui_buffer *buffer, } /* + * command_filter: manage message filters + */ + +int +command_filter (void *data, struct t_gui_buffer *buffer, + int argc, char **argv, char **argv_eol) +{ + struct t_gui_filter *ptr_filter; + int i; + long number; + char *error; + + /* make C compiler happy */ + (void) data; + (void) buffer; + + if ((argc == 1) + || ((argc == 2) && (string_strcasecmp (argv[1], "list") == 0))) + { + /* display all key bindings */ + gui_chat_printf (NULL, ""); + gui_chat_printf (NULL, "%s", + (gui_filters_enabled) ? + _("Filters are enabled") : _("Filters are disabled")); + + if (gui_filters) + { + gui_chat_printf (NULL, _("Message filters:")); + i = 0; + for (ptr_filter = gui_filters; ptr_filter; + ptr_filter = ptr_filter->next_filter) + { + i++; + gui_chat_printf (NULL, + _(" %s[%s%d%s]%s buffer: %s%s%s / tags: %s / " + "regex: %s"), + GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), + GUI_COLOR(GUI_COLOR_CHAT), + i, + GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), + GUI_COLOR(GUI_COLOR_CHAT), + GUI_COLOR(GUI_COLOR_CHAT_BUFFER), + ptr_filter->buffer, + GUI_COLOR(GUI_COLOR_CHAT), + ptr_filter->tags, + ptr_filter->regex); + } + } + else + gui_chat_printf (NULL, _("No message filter defined")); + + return WEECHAT_RC_OK; + } + + /* enable filters */ + if (string_strcasecmp (argv[1], "enable") == 0) + { + if (!gui_filters_enabled) + { + gui_filter_enable (); + gui_chat_printf (NULL, _("Filters enabled")); + } + return WEECHAT_RC_OK; + } + + /* disable filters */ + if (string_strcasecmp (argv[1], "disable") == 0) + { + if (gui_filters_enabled) + { + gui_filter_disable (); + gui_chat_printf (NULL, _("Filters disabled")); + } + return WEECHAT_RC_OK; + } + + /* toggle filters on/off */ + if (string_strcasecmp (argv[1], "toggle") == 0) + { + if (gui_filters_enabled) + gui_filter_disable (); + else + gui_filter_enable (); + return WEECHAT_RC_OK; + } + + /* add filter */ + if (string_strcasecmp (argv[1], "add") == 0) + { + if (argc < 5) + { + gui_chat_printf (NULL, + _("%sError: missing arguments for \"%s\" " + "command"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + "filter add"); + return WEECHAT_RC_ERROR; + } + if (gui_filter_search (argv[2], argv[3], argv_eol[4])) + { + gui_chat_printf (NULL, + _("%sError: filter already exists"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]); + return WEECHAT_RC_ERROR; + } + if ((strcmp (argv[3], "*") == 0) && (strcmp (argv_eol[4], "*") == 0)) + { + gui_chat_printf (NULL, + _("%sError: you must specify at least tag(s) or " + "regex for filter"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]); + return WEECHAT_RC_ERROR; + } + + gui_filter_new (argv[2], argv[3], argv_eol[4]); + gui_chat_printf (NULL, _("Filter added")); + + return WEECHAT_RC_OK; + } + + /* delete filter */ + if (string_strcasecmp (argv[1], "del") == 0) + { + if (argc < 3) + { + gui_chat_printf (NULL, + _("%sError: missing arguments for \"%s\" " + "command"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + "filter del"); + return WEECHAT_RC_ERROR; + } + error = NULL; + number = strtol (argv[2], &error, 10); + if (error && !error[0]) + { + ptr_filter = gui_filter_search_by_number (number); + if (ptr_filter) + { + gui_filter_free (ptr_filter); + gui_chat_printf (NULL, _("Filter deleted")); + } + else + { + gui_chat_printf (NULL, + _("%sError: filter not found"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]); + return WEECHAT_RC_ERROR; + } + } + else + { + gui_chat_printf (NULL, + _("%sError: wrong filter number"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]); + return WEECHAT_RC_ERROR; + } + } + + return WEECHAT_RC_OK; +} + +/* * command_help: display help about commands */ @@ -1948,7 +2112,7 @@ command_window (void *data, struct t_gui_buffer *buffer, { error = NULL; number = strtol (argv[2], &error, 10); - if (error && (error[0] == '\0') + if (error && !error[0] && (number > 0) && (number < 100)) gui_window_split_horiz (gui_current_window, number); } @@ -1962,7 +2126,7 @@ command_window (void *data, struct t_gui_buffer *buffer, { error = NULL; number = strtol (argv[2], &error, 10); - if (error && (error[0] == '\0') + if (error && !error[0] && (number > 0) && (number < 100)) gui_window_split_vertic (gui_current_window, number); } @@ -1976,7 +2140,7 @@ command_window (void *data, struct t_gui_buffer *buffer, { error = NULL; number = strtol (argv[2], &error, 10); - if (error && (error[0] == '\0') + if (error && !error[0] && (number > 0) && (number < 100)) gui_window_resize (gui_current_window, number); } @@ -2016,7 +2180,7 @@ command_window (void *data, struct t_gui_buffer *buffer, /* jump to window by buffer number */ error = NULL; number = strtol (argv[1] + 1, &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) gui_window_switch_by_buffer (gui_current_window, number); } else if (string_strcasecmp (argv[1], "-1") == 0) @@ -2117,6 +2281,29 @@ command_init () "added if not found at beginning of command)"), "%w", &command_builtin, NULL); + hook_command (NULL, "filter", + N_("filter messages in buffers, to hide/show them according " + "to tags or regex"), + N_("[list] | [enable|disable|toggle] | " + "[add buffer tags regex] | " + "[del number]"), + N_(" list: list all filters\n" + " enable: enable filters (filters are enabled by " + "default)\n" + "disable: disable filters\n" + " toggle: toggle filters\n" + " add: add a filter\n" + " del: delete a filter\n" + " number: number of filter to delete (look at list to " + "find it)\n" + " buffer: buffer where filter is active: it may be " + "a name (category.name) or \"*\" for all buffers\n" + " tags: comma separated list of tags, for " + "example: \"irc_join,irc_part,irc_quit\"\n" + " regex: regular expression to search in " + "line (use \t to separate prefix from message)"), + "list|enable|disable|toggle|add|del", + &command_filter, NULL); hook_command (NULL, "help", N_("display help about commands"), N_("[command]"), diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index d8dc5317d..2a932b2bf 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -323,7 +323,7 @@ config_file_new_option (struct t_config_file *config_file, new_option->max = max; error = NULL; number = strtol (default_value, &error, 10); - if (!error || (error[0] != '\0')) + if (!error || error[0]) number = 0; new_option->default_value = malloc (sizeof (int)); *((int *)new_option->default_value) = number; @@ -337,7 +337,7 @@ config_file_new_option (struct t_config_file *config_file, new_option->max = max; new_option->default_value = (default_value) ? strdup (default_value) : NULL; - new_option->value = strdup (default_value) ? + new_option->value = (default_value) ? strdup (default_value) : NULL; break; case CONFIG_OPTION_COLOR: @@ -558,7 +558,7 @@ config_file_option_set (struct t_config_option *option, char *new_value, { error = NULL; number = strtol (new_value, &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) { if (number == *((int *)option->value)) return 1; @@ -867,7 +867,8 @@ config_file_write_internal (struct t_config_file *config_file, snprintf (filename2, filename_length + 32, "%s.weechattmp", filename); /* open temp file in write mode */ - if ((config_file->file = fopen (filename2, "w")) == NULL) + config_file->file = fopen (filename2, "w"); + if (!config_file->file) { gui_chat_printf (NULL, _("%sError: cannot create file \"%s\""), @@ -976,10 +977,12 @@ config_file_read (struct t_config_file *config_file) return -2; snprintf (filename, filename_length, "%s%s%s", weechat_home, DIR_SEPARATOR, config_file->filename); - if ((config_file->file = fopen (filename, "r")) == NULL) + config_file->file = fopen (filename, "r"); + if (!config_file->file) { config_file_write_internal (config_file, 1); - if ((config_file->file = fopen (filename, "r")) == NULL) + config_file->file = fopen (filename, "r"); + if (!config_file->file) { gui_chat_printf (NULL, _("%sWarning: config file \"%s\" not found"), @@ -1018,7 +1021,7 @@ config_file_read (struct t_config_file *config_file) if (ptr_line[0] == '[') { pos = strchr (line, ']'); - if (pos == NULL) + if (!pos) { gui_chat_printf (NULL, _("%sWarning: %s, line %d: invalid " @@ -1054,8 +1057,8 @@ config_file_read (struct t_config_file *config_file) } else { - pos = strchr (line, '='); - if (pos == NULL) + pos = strstr (line, " = "); + if (!pos) { gui_chat_printf (NULL, _("%sWarning: %s, line %d: invalid " @@ -1066,10 +1069,10 @@ config_file_read (struct t_config_file *config_file) else { pos[0] = '\0'; - pos++; + pos += 3; /* remove spaces before '=' */ - pos2 = pos - 2; + pos2 = pos - 4; while ((pos2 > line) && (pos2[0] == ' ')) { pos2[0] = '\0'; @@ -1237,6 +1240,25 @@ config_file_reload (struct t_config_file *config_file) } /* + * config_file_option_free: free data in an option + */ + +void +config_file_option_free_data (struct t_config_option *option) +{ + if (option->name) + free (option->name); + if (option->description) + free (option->description); + if (option->string_values) + string_free_exploded (option->string_values); + if (option->default_value) + free (option->default_value); + if (option->value) + free (option->value); +} + +/* * config_file_option_free: free an option */ @@ -1264,16 +1286,9 @@ config_file_option_free (struct t_config_section *section, (option->next_option)->prev_option = option->prev_option; /* free data */ - if (option->name) - free (option->name); - if (option->description) - free (option->description); - if (option->string_values) - string_free_exploded (option->string_values); - if (option->default_value) - free (option->default_value); - if (option->value) - free (option->value); + config_file_option_free_data (option); + + free (option); section->options = new_options; } @@ -1313,6 +1328,8 @@ config_file_section_free (struct t_config_file *config_file, if (section->name) free (section->name); + free (section); + config_file->sections = new_sections; } @@ -1350,6 +1367,8 @@ config_file_free (struct t_config_file *config_file) if (config_file->filename) free (config_file->filename); + free (config_file); + config_files = new_config_files; } diff --git a/src/core/wee-config-file.h b/src/core/wee-config-file.h index df21e2909..0b65f53f3 100644 --- a/src/core/wee-config-file.h +++ b/src/core/wee-config-file.h @@ -156,6 +156,7 @@ extern void config_file_write_line (struct t_config_file *config_file, extern int config_file_write (struct t_config_file *config_files); extern int config_file_read (struct t_config_file *config_file); extern int config_file_reload (struct t_config_file *config_file); +extern void config_file_option_free_data (struct t_config_option *option); extern void config_file_option_free (struct t_config_section *section, struct t_config_option *option); extern void config_file_section_free (struct t_config_file *config_file, diff --git a/src/core/wee-config.c b/src/core/wee-config.c index a7364d253..a6abd624c 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -45,6 +45,7 @@ #include "../gui/gui-buffer.h" #include "../gui/gui-chat.h" #include "../gui/gui-color.h" +#include "../gui/gui-filter.h" #include "../gui/gui-hotlist.h" #include "../gui/gui-infobar.h" #include "../gui/gui-keyboard.h" @@ -434,6 +435,12 @@ config_weechat_reload (void *data, struct t_config_file *config_file) /* remove all keys */ gui_keyboard_free_all (); + /* remove all bars */ + gui_bar_free_all (); + + /* remove all filters */ + gui_filter_free_all (); + return config_file_reload (weechat_config_file); } @@ -458,17 +465,21 @@ config_weechat_read_bar (void *data, struct t_config_file *config_file, if (value && value[0]) { argv = string_explode (value, ";", 0, 0, &argc); - if (argc == 5) + if (argv) { - error = NULL; - number = strtol (argv[2], &error, 10); - if (error && (error[0] == '\0')) + if (argc == 5) { - size = number; - gui_bar_new (NULL, option_name, argv[0], argv[1], size, - (argv[3][0] == '0') ? 0 : 1, - argv[4]); + error = NULL; + number = strtol (argv[2], &error, 10); + if (error && !error[0]) + { + size = number; + gui_bar_new (NULL, option_name, argv[0], argv[1], size, + (argv[3][0] == '0') ? 0 : 1, + argv[4]); + } } + string_free_exploded (argv); } } } @@ -505,6 +516,68 @@ config_weechat_write_bars (void *data, struct t_config_file *config_file, } /* + * config_weechat_read_filter: read a filter in configuration file + */ + +void +config_weechat_read_filter (void *data, struct t_config_file *config_file, + char *option_name, char *value) +{ + char **argv, **argv_eol; + int argc; + + /* make C compiler happy */ + (void) data; + (void) config_file; + + if (option_name) + { + if (value && value[0]) + { + argv = string_explode (value, ";", 0, 0, &argc); + argv_eol = string_explode (value, ";", 1, 0, NULL); + if (argv && argv_eol && (argc >= 3)) + { + gui_filter_new (argv[0], argv[1], argv_eol[2]); + } + if (argv) + string_free_exploded (argv); + if (argv_eol) + string_free_exploded (argv_eol); + } + } +} + +/* + * config_weechat_write_filters: write filters section in configuration file + * Return: 0 = successful + * -1 = write error + */ + +void +config_weechat_write_filters (void *data, struct t_config_file *config_file, + char *section_name) +{ + struct t_gui_filter *ptr_filter; + + /* make C compiler happy */ + (void) data; + + config_file_write_line (config_file, section_name, NULL); + + for (ptr_filter = gui_filters; ptr_filter; + ptr_filter = ptr_filter->next_filter) + { + config_file_write_line (config_file, + "filter", + "%s;%s;%s", + ptr_filter->buffer, + ptr_filter->tags, + ptr_filter->regex); + } +} + +/* * config_weechat_read_key: read a key in configuration file */ @@ -1398,6 +1471,20 @@ config_weechat_init () return 0; } + /* filters */ + ptr_section = config_file_new_section (weechat_config_file, "filters", + &config_weechat_read_filter, + NULL, + &config_weechat_write_filters, + NULL, + &config_weechat_write_filters, + NULL); + if (!ptr_section) + { + config_file_free (weechat_config_file); + return 0; + } + /* keys */ ptr_section = config_file_new_section (weechat_config_file, "keys", &config_weechat_read_key, diff --git a/src/core/wee-debug.c b/src/core/wee-debug.c index e886021a3..746d73c8e 100644 --- a/src/core/wee-debug.c +++ b/src/core/wee-debug.c @@ -35,6 +35,7 @@ #include "../gui/gui-bar-item.h" #include "../gui/gui-buffer.h" #include "../gui/gui-chat.h" +#include "../gui/gui-filter.h" #include "../gui/gui-hotlist.h" #include "../gui/gui-main.h" #include "../gui/gui-window.h" @@ -75,6 +76,7 @@ debug_dump (int crash) gui_window_print_log (); gui_buffer_print_log (); + gui_filter_print_log (); gui_bar_print_log (); gui_bar_item_print_log (); gui_hotlist_print_log (); diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index fe57e98c2..4816ff2fc 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -718,7 +718,7 @@ hook_fd_exec (fd_set *read_fds, fd_set *write_fds, fd_set *exception_fds) && (FD_ISSET(HOOK_FD(ptr_hook, fd), exception_fds))))) { ptr_hook->running = 1; - (HOOK_FD(ptr_hook, callback)) (ptr_hook->callback_data); + (void) (HOOK_FD(ptr_hook, callback)) (ptr_hook->callback_data); ptr_hook->running = 0; } @@ -734,8 +734,8 @@ hook_fd_exec (fd_set *read_fds, fd_set *write_fds, fd_set *exception_fds) struct t_hook * hook_print (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer, - char *message, int strip_colors, t_hook_callback_print *callback, - void *callback_data) + char *tags, char *message, int strip_colors, + t_hook_callback_print *callback, void *callback_data) { struct t_hook *new_hook; struct t_hook_print *new_hook_print; @@ -755,6 +755,16 @@ hook_print (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer, new_hook->hook_data = new_hook_print; new_hook_print->callback = callback; new_hook_print->buffer = buffer; + if (tags) + { + new_hook_print->tags_array = string_explode (tags, ",", 0, 0, + &new_hook_print->tags_count); + } + else + { + new_hook_print->tags_count = 0; + new_hook_print->tags_array = NULL; + } new_hook_print->message = (message) ? strdup (message) : NULL; new_hook_print->strip_colors = strip_colors; @@ -768,11 +778,12 @@ hook_print (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer, */ void -hook_print_exec (struct t_gui_buffer *buffer, time_t date, char *prefix, - char *message) +hook_print_exec (struct t_gui_buffer *buffer, time_t date, int tags_count, + char **tags_array, char *prefix, char *message) { struct t_hook *ptr_hook, *next_hook; char *prefix_no_color, *message_no_color; + int tags_match, tag_found, i, j; if (!message || !message[0]) return; @@ -802,17 +813,59 @@ hook_print_exec (struct t_gui_buffer *buffer, time_t date, char *prefix, || string_strcasestr (prefix_no_color, HOOK_PRINT(ptr_hook, message)) || string_strcasestr (message_no_color, HOOK_PRINT(ptr_hook, message)))) { - ptr_hook->running = 1; - (void) (HOOK_PRINT(ptr_hook, callback)) - (ptr_hook->callback_data, buffer, date, - (HOOK_PRINT(ptr_hook, strip_colors)) ? prefix_no_color : prefix, - (HOOK_PRINT(ptr_hook, strip_colors)) ? message_no_color : message); - ptr_hook->running = 0; + /* check if tags match */ + if (HOOK_PRINT(ptr_hook, tags_array)) + { + /* if there are tags in message printed */ + if (tags_array) + { + tags_match = 1; + for (i = 0; i < HOOK_PRINT(ptr_hook, tags_count); i++) + { + /* search for tag in message */ + tag_found = 0; + for (j = 0; j < tags_count; j++) + { + if (string_strcasecmp (HOOK_PRINT(ptr_hook, tags_array)[i], + tags_array[j]) != 0) + { + tag_found = 1; + break; + } + } + /* tag was asked by hook but not found in message? */ + if (!tag_found) + { + tags_match = 0; + break; + } + } + } + else + tags_match = 0; + } + else + tags_match = 1; + + /* run callback */ + if (tags_match) + { + ptr_hook->running = 1; + (void) (HOOK_PRINT(ptr_hook, callback)) + (ptr_hook->callback_data, buffer, date, + tags_count, tags_array, + (HOOK_PRINT(ptr_hook, strip_colors)) ? prefix_no_color : prefix, + (HOOK_PRINT(ptr_hook, strip_colors)) ? message_no_color : message); + ptr_hook->running = 0; + } } ptr_hook = next_hook; } + free (prefix_no_color); + free (message_no_color); + hook_exec_end (); } @@ -869,8 +922,7 @@ hook_signal_send (char *signal, char *type_data, void *signal_data) if (!ptr_hook->deleted && !ptr_hook->running - && ((string_strcasecmp (HOOK_SIGNAL(ptr_hook, signal), "*") == 0) - || (string_strcasecmp (HOOK_SIGNAL(ptr_hook, signal), signal) == 0))) + && (string_match (signal, HOOK_SIGNAL(ptr_hook, signal), 0))) { ptr_hook->running = 1; (void) (HOOK_SIGNAL(ptr_hook, callback)) diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h index 8cdb7946e..a287be2fa 100644 --- a/src/core/wee-hook.h +++ b/src/core/wee-hook.h @@ -104,12 +104,16 @@ struct t_hook_fd }; typedef int (t_hook_callback_print)(void *data, struct t_gui_buffer *buffer, - time_t date, char *prefix, char *message); + time_t date, int tags_count, + char **tags, char *prefix, + char *message); struct t_hook_print { t_hook_callback_print *callback; /* print callback */ struct t_gui_buffer *buffer; /* buffer selected (NULL = all) */ + int tags_count; /* number of tags selected */ + char **tags_array; /* tags selected (NULL = any) */ char *message; /* part of message (NULL/empty = all)*/ int strip_colors; /* strip colors in msg for callback? */ }; @@ -120,7 +124,8 @@ typedef int (t_hook_callback_signal)(void *data, char *signal, struct t_hook_signal { t_hook_callback_signal *callback; /* signal callback */ - char *signal; /* signal selected ("*" = any signal)*/ + char *signal; /* signal selected (may begin or end */ + /* with "*", "*" == any signal) */ }; typedef int (t_hook_callback_config)(void *data, char *type, char *option, @@ -190,11 +195,14 @@ extern void hook_fd_exec (fd_set *read_fds, fd_set *write_fds, fd_set *exception_fds); extern struct t_hook *hook_print (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer, - char *message, int strip_colors, + char *tags, char *message, + int strip_colors, t_hook_callback_print *callback, void *callback_data); extern void hook_print_exec (struct t_gui_buffer *buffer, - time_t date, char *prefix, char *message); + time_t date, int tags_count, + char **tags_array, char *prefix, + char *message); extern struct t_hook *hook_signal (struct t_weechat_plugin *plugin, char *signal, t_hook_callback_signal *callback, diff --git a/src/core/wee-input.c b/src/core/wee-input.c index ed1c34587..e0f18cf3a 100644 --- a/src/core/wee-input.c +++ b/src/core/wee-input.c @@ -111,10 +111,6 @@ input_exec_command (struct t_gui_buffer *buffer, char *string, switch (rc) { case 0: /* command hooked, KO */ - gui_chat_printf (NULL, - _("%sError: command \"%s\" failed"), - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], - command + 1); break; case 1: /* command hooked, OK (executed) */ break; diff --git a/src/core/wee-string.c b/src/core/wee-string.c index 827fad7ce..3fc7f9866 100644 --- a/src/core/wee-string.c +++ b/src/core/wee-string.c @@ -244,6 +244,90 @@ string_strcasestr (char *string, char *search) } /* + * string_match: return 1 if string matches a mask + * mask can begin or end with "*", no other "*" are allowed + * inside mask + */ + +int +string_match (char *string, char *mask, int case_sensitive) +{ + char last, *mask2; + int len_string, len_mask, rc; + + if (!mask || !mask[0]) + return 0; + + /* if mask is "*", then any string matches */ + if (strcmp (mask, "*") == 0) + return 1; + + len_string = strlen (string); + len_mask = strlen (mask); + + last = mask[len_mask - 1]; + + /* mask begins with "*" */ + if ((mask[0] == '*') && (last != '*')) + { + /* not enough chars in string to match */ + if (len_string < len_mask - 1) + return 0; + /* check if end of string matches */ + if ((case_sensitive && (strcmp (string + len_string - (len_mask - 1), + mask + 1) == 0)) + || (!case_sensitive && (string_strcasecmp (string + len_string - (len_mask - 1), + mask + 1) == 0))) + return 1; + /* no match */ + return 0; + } + + /* mask ends with "*" */ + if ((mask[0] != '*') && (last == '*')) + { + /* not enough chars in string to match */ + if (len_string < len_mask - 1) + return 0; + /* check if beginning of string matches */ + if ((case_sensitive && (strncmp (string, mask, len_mask - 1) == 0)) + || (!case_sensitive && (string_strncasecmp (string, + mask, + len_mask - 1) == 0))) + return 1; + /* no match */ + return 0; + } + + /* mask begins and ends with "*" */ + if ((mask[0] == '*') && (last == '*')) + { + /* not enough chars in string to match */ + if (len_string < len_mask - 1) + return 0; + /* keep only relevant chars in mask for searching string */ + mask2 = string_strndup (mask + 1, len_mask - 2); + if (!mask2) + return 0; + /* search string */ + rc = ((case_sensitive && strstr (string, mask2)) + || (!case_sensitive && string_strcasestr (string, mask2))) ? + 1 : 0; + /* free and return */ + free (mask2); + return rc; + } + + /* no "*" at all, compare strings */ + if ((case_sensitive && (strcmp (string, mask) == 0)) + || (!case_sensitive && (string_strcasecmp (string, mask) == 0))) + return 1; + + /* no match */ + return 0; +} + +/* * string_replace: replace a string by new one in a string * note: returned value has to be free() after use */ @@ -417,7 +501,7 @@ string_convert_hex_chars (char *string) snprintf (hex_str, sizeof (hex_str), "0x%c%c", string[1], string[2]); number = strtol (hex_str, &error, 16); - if (error && (error[0] == '\0')) + if (error && !error[0]) { output[pos_output++] = number; string += 3; @@ -550,7 +634,7 @@ string_explode (char *string, char *separators, int keep_eol, { array[i] = (char *)malloc ((ptr2 - ptr1 + 1) * sizeof (char)); - array[i] = strncpy (array[i], ptr1, ptr2 - ptr1); + strncpy (array[i], ptr1, ptr2 - ptr1); array[i][ptr2 - ptr1] = '\0'; } ptr1 = ++ptr2; @@ -566,6 +650,8 @@ string_explode (char *string, char *separators, int keep_eol, if (num_items != NULL) *num_items = i; + free (string2); + return array; } @@ -587,6 +673,41 @@ string_free_exploded (char **exploded_string) } /* + * string_build_with_exploded: build a string with exploded string + * note: returned value has to be free() after use + */ + +char * +string_build_with_exploded (char **exploded_string, char *separator) +{ + int i, length, length_separator; + char *result; + + if (!exploded_string || !separator) + return NULL; + + length = 0; + length_separator = strlen (separator); + + for (i = 0; exploded_string[i]; i++) + { + length += strlen (exploded_string[i]) + length_separator; + } + + result = (char *)malloc ((length + 1) * sizeof (char)); + result[0] = '\0'; + + for (i = 0; exploded_string[i]; i++) + { + strcat (result, exploded_string[i]); + if (exploded_string[i + 1]) + strcat (result, separator); + } + + return result; +} + +/* * string_split_command: split a list of commands separated by 'sep' * and ecscaped with '\' * - empty commands are removed diff --git a/src/core/wee-string.h b/src/core/wee-string.h index 8c7901302..a66ad12a1 100644 --- a/src/core/wee-string.h +++ b/src/core/wee-string.h @@ -28,6 +28,7 @@ extern int string_strncasecmp (char *string1, char *string2, int max); extern int string_strcmp_ignore_chars (char *string1, char *string2, char *chars_ignored, int case_sensitive); extern char *string_strcasestr (char *string, char *search); +extern int string_match (char *string, char *mask, int case_sensitive); extern char *string_replace (char *string, char *search, char *replace); extern char *string_remove_quotes (char *string, char *quotes); extern char *string_strip (char *string, int left, int right, char *chars); @@ -35,6 +36,8 @@ extern char *string_convert_hex_chars (char *string); extern char **string_explode (char *string, char *separators, int keep_eol, int num_items_max, int *num_items); extern void string_free_exploded (char **exploded_string); +extern char *string_build_with_exploded (char **exploded_string, + char *separator); extern char **string_split_command (char *command, char separator); extern void string_free_splitted_command (char **splitted_command); extern char *string_iconv (int from_utf8, char *from_code, char *to_code, diff --git a/src/core/wee-util.c b/src/core/wee-util.c index dec328343..e61a07eeb 100644 --- a/src/core/wee-util.c +++ b/src/core/wee-util.c @@ -174,6 +174,7 @@ util_exec_on_files (char *directory, void *data, DIR *dir; struct dirent *entry; struct stat statbuf; + int rc; if (!directory || !callback) return; @@ -188,7 +189,7 @@ util_exec_on_files (char *directory, void *data, lstat (complete_filename, &statbuf); if (!S_ISDIR(statbuf.st_mode)) { - (int) (*callback) (data, complete_filename); + rc = (*callback) (data, complete_filename); } } closedir (dir); diff --git a/src/core/weechat.c b/src/core/weechat.c index 3dd42e587..3f192968d 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -524,11 +524,15 @@ main (int argc, char *argv[]) command_startup (0); /* command executed before plugins */ plugin_init (auto_load_plugins); /* init plugin interface(s) */ command_startup (1); /* command executed after plugins */ + gui_main_loop (); /* WeeChat main loop */ + plugin_end (); /* end plugin interface(s) */ if (CONFIG_BOOLEAN(config_look_save_on_exit)) (void) config_weechat_write (NULL); /* save WeeChat config file */ gui_main_end (); /* shut down WeeChat GUI */ + config_file_free_all (); /* free all configuration files */ + gui_keyboard_end (); /* end keyboard */ unhook_all (); /* remove all hooks */ weechat_shutdown (EXIT_SUCCESS, 0); /* quit WeeChat (oh no, why?) */ diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index fef192a8f..6b6757ab6 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -20,11 +20,11 @@ ENDIF(NOT DISABLE_NCURSES) SET(LIB_GUI_COMMON_SRC gui-action.c gui-action.h gui-bar.c gui-bar.h gui-bar-item.c gui-bar-item.h gui-buffer.c gui-buffer.h gui-chat.c gui-chat.h -gui-color.c gui-color.h gui-completion.c gui-completion.h gui-history.c -gui-history.h gui-hotlist.c gui-hotlist.h gui-infobar.c gui-infobar.h -gui-input.c gui-input.h gui-keyboard.c gui-keyboard.h gui-main.h -gui-nicklist.c gui-nicklist.h gui-status.c gui-status.h gui-window.c -gui-window.h) +gui-color.c gui-color.h gui-filter.c gui-filter.h gui-completion.c +gui-completion.h gui-history.c gui-history.h gui-hotlist.c gui-hotlist.h +gui-infobar.c gui-infobar.h gui-input.c gui-input.h gui-keyboard.c +gui-keyboard.h gui-main.h gui-nicklist.c gui-nicklist.h gui-status.c +gui-status.h gui-window.c gui-window.h) INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}) ADD_LIBRARY(weechat_gui_common STATIC ${LIB_GUI_COMMON_SRC}) diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index 12c4575fa..916a4dc08 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -32,6 +32,8 @@ lib_weechat_gui_common_a_SOURCES = gui-action.c \ gui-color.h \ gui-completion.c \ gui-completion.h \ + gui-filter.c \ + gui-filter.h \ gui-history.c \ gui-history.h \ gui-hotlist.c \ diff --git a/src/gui/curses/gui-curses-bar.c b/src/gui/curses/gui-curses-bar.c index 2166542ad..bf167b092 100644 --- a/src/gui/curses/gui-curses-bar.c +++ b/src/gui/curses/gui-curses-bar.c @@ -352,6 +352,8 @@ gui_bar_window_draw (struct t_gui_window *window, } if (item_value2) free (item_value2); + if (items) + string_free_exploded (items); } free (item_value); } diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index 6adbb13f6..2e7375e1f 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -837,7 +837,7 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line, { /* display read marker if needed */ if (window->buffer->last_read_line && - (window->buffer->last_read_line == line->prev_line)) + (window->buffer->last_read_line == gui_chat_get_prev_line_displayed (line))) { gui_chat_set_weechat_color (window, GUI_COLOR_CHAT_READ_MARKER); @@ -874,7 +874,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window, /* if looking backward, start at last line of buffer */ if (backward) { - *line = window->buffer->last_line; + *line = gui_chat_get_last_line_displayed (window->buffer); if (!(*line)) return; current_size = gui_chat_display_line (window, *line, 0, 1); @@ -885,7 +885,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window, /* if looking forward, start at first line of buffer */ else { - *line = window->buffer->lines; + *line = gui_chat_get_first_line_displayed (window->buffer); if (!(*line)) return; *line_pos = 0; @@ -904,7 +904,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window, (*line_pos)--; else { - *line = (*line)->prev_line; + *line = gui_chat_get_prev_line_displayed (*line); if (*line) { current_size = gui_chat_display_line (window, *line, 0, 1); @@ -922,7 +922,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window, (*line_pos)++; else { - *line = (*line)->next_line; + *line = gui_chat_get_next_line_displayed (*line); if (*line) { current_size = gui_chat_display_line (window, *line, 0, 1); @@ -941,7 +941,7 @@ gui_chat_calculate_line_diff (struct t_gui_window *window, if (backward) { /* first line reached */ - *line = window->buffer->lines; + *line = gui_chat_get_first_line_displayed (window->buffer); *line_pos = 0; } else @@ -1158,19 +1158,19 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase) ptr_line, 0, 1) - line_pos, 0); - ptr_line = ptr_line->next_line; + ptr_line = gui_chat_get_next_line_displayed (ptr_line); ptr_win->first_line_displayed = 0; } else ptr_win->first_line_displayed = - (ptr_line == ptr_win->buffer->lines); + (ptr_line == gui_chat_get_first_line_displayed (ptr_win->buffer)); /* display lines */ count = 0; while (ptr_line && (ptr_win->win_chat_cursor_y <= ptr_win->win_chat_height - 1)) { count = gui_chat_display_line (ptr_win, ptr_line, 0, 0); - ptr_line = ptr_line->next_line; + ptr_line = gui_chat_get_next_line_displayed (ptr_line); } old_scroll = ptr_win->scroll; @@ -1191,7 +1191,8 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase) WEECHAT_HOOK_SIGNAL_POINTER, ptr_win); } - if (!ptr_win->scroll && (ptr_win->start_line == ptr_win->buffer->lines)) + if (!ptr_win->scroll + && (ptr_win->start_line == gui_chat_get_first_line_displayed (ptr_win->buffer))) { ptr_win->start_line = NULL; ptr_win->start_line_pos = 0; diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index a642cfebf..1adb758ee 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -459,3 +459,18 @@ gui_color_init () gui_color_init_pairs (); gui_color_init_weechat (); } + +/* + * gui_color_end: end GUI colors + */ + +void +gui_color_end () +{ + int i; + + for (i = 0; i < GUI_NUM_COLORS; i++) + { + gui_color_free (gui_color[i]); + } +} diff --git a/src/gui/curses/gui-curses-keyboard.c b/src/gui/curses/gui-curses-keyboard.c index d6353a50f..62be0e4c1 100644 --- a/src/gui/curses/gui-curses-keyboard.c +++ b/src/gui/curses/gui-curses-keyboard.c @@ -135,6 +135,7 @@ gui_keyboard_default_bindings () gui_keyboard_bind (/* m-w,m-down */ "meta-wmeta-meta2-B", "/window down"); gui_keyboard_bind (/* m-w,m-left */ "meta-wmeta-meta2-D", "/window left"); gui_keyboard_bind (/* m-w,m-right */ "meta-wmeta-meta2-C", "/window right"); + gui_keyboard_bind (/* m-= */ "meta-=", "/filter toggle"); gui_keyboard_bind (/* m-0 */ "meta-0", "/buffer 10"); gui_keyboard_bind (/* m-1 */ "meta-1", "/buffer 1"); gui_keyboard_bind (/* m-2 */ "meta-2", "/buffer 2"); diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index ff459062c..bf842dfcf 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -263,8 +263,9 @@ gui_main_loop () void gui_main_end () { - /* remove bar items */ + /* remove bar items and bars */ gui_bar_item_end (); + gui_bar_free_all (); /* free clipboard buffer */ if (gui_input_clipboard) @@ -290,6 +291,9 @@ gui_main_end () if (CONFIG_BOOLEAN(config_look_set_title)) gui_window_title_reset (); + /* end color */ + gui_color_end (); + /* end of Curses output */ refresh (); endwin (); diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index a23128f10..550d2a909 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -726,7 +726,7 @@ gui_window_scroll_top (struct t_gui_window *window) if (!window->first_line_displayed) { - window->start_line = window->buffer->lines; + window->start_line = gui_chat_get_first_line_displayed (window->buffer); window->start_line_pos = 0; gui_chat_draw (window->buffer, 0); if (!window->scroll) diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index 663b4963c..b5899ceb7 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -62,6 +62,7 @@ extern struct t_gui_color gui_weechat_colors[]; /* color functions */ extern int gui_color_get_pair (int num_color); extern void gui_color_init (); +extern void gui_color_end (); /* bar functions */ extern void gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window, diff --git a/src/gui/gtk/gui-gtk-color.c b/src/gui/gtk/gui-gtk-color.c index f2a622212..e441a05b3 100644 --- a/src/gui/gtk/gui-gtk-color.c +++ b/src/gui/gtk/gui-gtk-color.c @@ -170,3 +170,18 @@ gui_color_init () gui_color_init_pairs (); gui_color_init_weechat (); } + +/* + * gui_color_end: end GUI colors + */ + +void +gui_color_end () +{ + int i; + + for (i = 0; i < GUI_NUM_COLORS; i++) + { + gui_color_free (gui_color[i]); + } +} diff --git a/src/gui/gtk/gui-gtk.h b/src/gui/gtk/gui-gtk.h index 3909230b7..71cfc2e04 100644 --- a/src/gui/gtk/gui-gtk.h +++ b/src/gui/gtk/gui-gtk.h @@ -92,6 +92,7 @@ extern GtkWidget *gui_gtk_label1; /* color functions */ extern int gui_color_get_pair (int num_color); extern void gui_color_init (); +extern void gui_color_end (); /* chat functions */ extern void gui_chat_calculate_line_diff (struct t_gui_window *window, diff --git a/src/gui/gui-action.c b/src/gui/gui-action.c index aee963680..396de1ffd 100644 --- a/src/gui/gui-action.c +++ b/src/gui/gui-action.c @@ -1369,7 +1369,7 @@ gui_action_scroll_unread (char *args) gui_current_window->buffer->last_read_line->next_line; gui_current_window->start_line_pos = 0; gui_current_window->first_line_displayed = - (gui_current_window->start_line == gui_current_window->buffer->lines); + (gui_current_window->start_line == gui_chat_get_first_line_displayed (gui_current_window->buffer)); gui_current_window->buffer->chat_refresh_needed = 1; gui_status_refresh_needed = 1; } diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index f99191864..5bac05335 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -36,6 +36,7 @@ #include "gui-bar.h" #include "gui-buffer.h" #include "gui-color.h" +#include "gui-filter.h" #include "gui-hotlist.h" #include "gui-window.h" @@ -43,8 +44,8 @@ struct t_gui_bar_item *gui_bar_items = NULL; /* first bar item */ struct t_gui_bar_item *last_gui_bar_item = NULL; /* last bar item */ char *gui_bar_item_names[GUI_BAR_NUM_ITEMS] = -{ "buffer_count", "buffer_plugin", "buffer_name", "nicklist_count", "scroll", - "hotlist" +{ "buffer_count", "buffer_plugin", "buffer_name", "buffer_filter", + "nicklist_count", "scroll", "hotlist" }; struct t_gui_bar_item_hook *gui_bar_item_hooks = NULL; @@ -326,6 +327,40 @@ gui_bar_item_default_buffer_name (void *data, struct t_gui_bar_item *item, } /* + * gui_bar_item_default_buffer_filter: default item for buffer filter + */ + +char * +gui_bar_item_default_buffer_filter (void *data, struct t_gui_bar_item *item, + struct t_gui_window *window, + int max_width, int max_height) +{ + char buf[256]; + + /* make C compiler happy */ + (void) data; + (void) item; + (void) max_width; + (void) max_height; + + if (!window) + window = gui_current_window; + + if (!gui_filters_enabled) + return NULL; + + snprintf (buf, sizeof (buf), + _("%s[%sF%s%s%s]"), + GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS), + GUI_COLOR(GUI_COLOR_STATUS_NAME), + (window->buffer->lines_hidden) ? "," : "", + (window->buffer->lines_hidden) ? _("filtered") : "", + GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS)); + + return strdup (buf); +} + +/* * gui_bar_item_default_nicklist_count: default item for number of nicks in * buffer nicklist */ @@ -549,6 +584,15 @@ gui_bar_item_init () gui_bar_item_hook ("buffer_moved", gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_BUFFER_NAME]); + /* buffer filter */ + gui_bar_item_new (NULL, + gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_BUFFER_FILTER], + &gui_bar_item_default_buffer_filter, NULL); + gui_bar_item_hook ("buffer_lines_hidden", + gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_BUFFER_FILTER]); + gui_bar_item_hook ("filters_*", + gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_BUFFER_FILTER]); + /* nicklist count */ gui_bar_item_new (NULL, gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_NICKLIST_COUNT], diff --git a/src/gui/gui-bar-item.h b/src/gui/gui-bar-item.h index d0f878557..80324e3d4 100644 --- a/src/gui/gui-bar-item.h +++ b/src/gui/gui-bar-item.h @@ -25,6 +25,7 @@ enum t_gui_bar_item_weechat GUI_BAR_ITEM_WEECHAT_BUFFER_COUNT = 0, GUI_BAR_ITEM_WEECHAT_BUFFER_PLUGIN, GUI_BAR_ITEM_WEECHAT_BUFFER_NAME, + GUI_BAR_ITEM_WEECHAT_BUFFER_FILTER, GUI_BAR_ITEM_WEECHAT_NICKLIST_COUNT, GUI_BAR_ITEM_WEECHAT_SCROLL, GUI_BAR_ITEM_WEECHAT_HOTLIST, diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 0948439bd..c02ef92dc 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -55,7 +55,6 @@ struct t_gui_buffer *gui_buffers = NULL; /* first buffer */ struct t_gui_buffer *last_gui_buffer = NULL; /* last buffer */ struct t_gui_buffer *gui_previous_buffer = NULL; /* previous buffer */ -struct t_gui_buffer *gui_buffer_before_dcc = NULL; /* buffer before dcc */ /* @@ -89,7 +88,8 @@ gui_buffer_new (struct t_weechat_plugin *plugin, char *category, char *name, } /* create new buffer */ - if ((new_buffer = (struct t_gui_buffer *)(malloc (sizeof (struct t_gui_buffer))))) + new_buffer = (struct t_gui_buffer *)(malloc (sizeof (struct t_gui_buffer))); + if (new_buffer) { /* init buffer */ new_buffer->plugin = plugin; @@ -113,6 +113,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin, char *category, char *name, new_buffer->last_line = NULL; new_buffer->last_read_line = NULL; new_buffer->lines_count = 0; + new_buffer->lines_hidden = 0; new_buffer->prefix_max_length = 0; new_buffer->chat_refresh_needed = 1; @@ -219,14 +220,14 @@ gui_buffer_valid (struct t_gui_buffer *buffer) } /* - * gui_buffer_get: get a buffer property + * gui_buffer_get_string: get a buffer property as string */ -void * -gui_buffer_get (struct t_gui_buffer *buffer, char *property) +char * +gui_buffer_get_string (struct t_gui_buffer *buffer, char *property) { - if (string_strcasecmp (property, "plugin") == 0) - return buffer->plugin; + static char value[32]; + if (string_strcasecmp (property, "category") == 0) return buffer->category; else if (string_strcasecmp (property, "name") == 0) @@ -235,6 +236,24 @@ gui_buffer_get (struct t_gui_buffer *buffer, char *property) return buffer->title; else if (string_strcasecmp (property, "nick") == 0) return buffer->input_nick; + else if (string_strcasecmp (property, "lines_hidden") == 0) + { + snprintf (value, sizeof (value), "%d", buffer->lines_hidden); + return value; + } + + return NULL; +} + +/* + * gui_buffer_get_pointer: get a buffer property as pointer + */ + +void * +gui_buffer_get_pointer (struct t_gui_buffer *buffer, char *property) +{ + if (string_strcasecmp (property, "plugin") == 0) + return buffer->plugin; return NULL; } @@ -370,21 +389,21 @@ gui_buffer_set (struct t_gui_buffer *buffer, char *property, char *value) { error = NULL; number = strtol (value, &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) gui_buffer_set_nicklist (buffer, number); } else if (string_strcasecmp (property, "nicklist_case_sensitive") == 0) { error = NULL; number = strtol (value, &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) gui_buffer_set_nicklist_case_sensitive (buffer, number); } else if (string_strcasecmp (property, "nicklist_display_groups") == 0) { error = NULL; number = strtol (value, &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) gui_buffer_set_nicklist_display_groups (buffer, number); } else if (string_strcasecmp (property, "nick") == 0) @@ -401,7 +420,7 @@ gui_buffer_set (struct t_gui_buffer *buffer, char *property, char *value) { error = NULL; number = strtol (value, &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) gui_hotlist_add (buffer, number, NULL, 1); } } @@ -533,6 +552,54 @@ gui_buffer_is_scrolled (struct t_gui_buffer *buffer) } /* + * gui_buffer_match_category_name: return 1 if buffer matches category.name + * otherwise 0 + * category or name may begin or end with "*" + * examples: + * *.#weechat + * freenode.* + * freenode.#weechat* + * freenode.*chat* + */ + +int +gui_buffer_match_category_name (struct t_gui_buffer *buffer, char *mask, + int case_sensitive) +{ + char *pos_point, *category, *pos_name; + int rc; + + if (!mask || !mask[0]) + return 0; + + pos_point = strchr (mask, '.'); + if (pos_point) + { + category = string_strndup (mask, pos_point - mask); + pos_name = pos_point + 1; + } + else + { + category = NULL; + pos_name = mask; + } + + rc = 1; + + if (category && buffer->category + && !string_match (buffer->category, category, case_sensitive)) + rc = 0; + + if (rc && !string_match (buffer->name, pos_name, case_sensitive)) + rc = 0; + + if (category) + free (category); + + return rc; +} + +/* * gui_buffer_get_dcc: get pointer to DCC buffer (DCC buffer created if not existing) */ @@ -657,13 +724,6 @@ gui_buffer_close (struct t_gui_buffer *buffer, int switch_to_another) if (gui_previous_buffer == buffer) gui_previous_buffer = NULL; - if (gui_buffer_before_dcc == buffer) - gui_buffer_before_dcc = NULL; - - /* free title */ - if (buffer->title) - free (buffer->title); - if (buffer->type == GUI_BUFFER_TYPE_FORMATED) { /* decrease buffer number for all next buffers */ @@ -681,7 +741,14 @@ gui_buffer_close (struct t_gui_buffer *buffer, int switch_to_another) buffer->lines = ptr_line; } } - + + /* free some data */ + if (buffer->title) + free (buffer->title); + if (buffer->category) + free (buffer->category); + if (buffer->name) + free (buffer->name); if (buffer->input_buffer) free (buffer->input_buffer); if (buffer->input_buffer_color_mask) @@ -988,6 +1055,7 @@ gui_buffer_print_log () { struct t_gui_buffer *ptr_buffer; struct t_gui_line *ptr_line; + char *tags; int num; for (ptr_buffer = gui_buffers; ptr_buffer; @@ -1007,6 +1075,7 @@ gui_buffer_print_log () log_printf (" last_line. . . . . . . : 0x%x", ptr_buffer->last_line); log_printf (" last_read_line . . . . : 0x%x", ptr_buffer->last_read_line); log_printf (" lines_count. . . . . . : %d", ptr_buffer->lines_count); + log_printf (" lines_hidden . . . . . : %d", ptr_buffer->lines_hidden); log_printf (" prefix_max_length. . . : %d", ptr_buffer->prefix_max_length); log_printf (" chat_refresh_needed. . : %d", ptr_buffer->chat_refresh_needed); log_printf (" nicklist . . . . . . . : %d", ptr_buffer->nicklist); @@ -1060,10 +1129,17 @@ gui_buffer_print_log () while (ptr_line) { num--; - log_printf (" line N-%05d: str_time:'%s', prefix:'%s'", - num, ptr_line->str_time, ptr_line->prefix); + tags = string_build_with_exploded (ptr_line->tags_array, ","); + log_printf (" line N-%05d: str_time:'%s', tags:'%s', " + "displayed:%d, prefix:'%s'", + num, ptr_line->str_time, + (tags) ? tags : "", + (int)(ptr_line->displayed), + ptr_line->prefix); log_printf (" data: '%s'", - ptr_line->message); + ptr_line->message); + if (tags) + free (tags); ptr_line = ptr_line->next_line; } diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h index 6460fbd57..2ffced80d 100644 --- a/src/gui/gui-buffer.h +++ b/src/gui/gui-buffer.h @@ -43,6 +43,9 @@ struct t_gui_line time_t date; /* date/time of line (may be past) */ time_t date_printed; /* date/time when weechat print it */ char *str_time; /* time string (for display) */ + int tags_count; /* number of tags for line */ + char **tags_array; /* tags for line */ + char displayed; /* 1 if line is displayed */ char *prefix; /* prefix for line (may be NULL) */ int prefix_length; /* prefix length (on screen) */ char *message; /* line content (after prefix) */ @@ -78,6 +81,7 @@ struct t_gui_buffer struct t_gui_line *last_line; /* last line of chat window */ struct t_gui_line *last_read_line; /* last read line before jump */ int lines_count; /* number of lines in the buffer */ + int lines_hidden; /* 1 if at least one line is hidden */ int prefix_max_length; /* length for prefix align */ int chat_refresh_needed; /* refresh for chat is needed ? */ @@ -132,7 +136,6 @@ struct t_gui_buffer extern struct t_gui_buffer *gui_buffers; extern struct t_gui_buffer *last_gui_buffer; extern struct t_gui_buffer *gui_previous_buffer; -extern struct t_gui_buffer *gui_buffer_before_dcc; /* buffer functions */ @@ -146,7 +149,10 @@ extern struct t_gui_buffer *gui_buffer_new (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer), void *close_callback_data); extern int gui_buffer_valid (struct t_gui_buffer *buffer); -extern void *gui_buffer_get (struct t_gui_buffer *buffer, char *property); +extern char *gui_buffer_get_string (struct t_gui_buffer *buffer, + char *property); +extern void *gui_buffer_get_pointer (struct t_gui_buffer *buffer, + char *property); extern void gui_buffer_set_category (struct t_gui_buffer *buffer, char *category); extern void gui_buffer_set_name (struct t_gui_buffer *buffer, char *name); @@ -165,6 +171,8 @@ extern struct t_gui_buffer *gui_buffer_search_by_category_name (char *category, extern struct t_gui_buffer *gui_buffer_search_by_number (int number); extern struct t_gui_window *gui_buffer_find_window (struct t_gui_buffer *buffer); extern int gui_buffer_is_scrolled (struct t_gui_buffer *buffer); +extern int gui_buffer_match_category_name (struct t_gui_buffer *buffer, + char *mask, int case_sensitive); extern struct t_gui_buffer *gui_buffer_get_dcc (struct t_gui_window *window); extern void gui_buffer_clear (struct t_gui_buffer *buffer); extern void gui_buffer_clear_all (); diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index e8899c11f..b06bee0b7 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -27,6 +27,7 @@ #include <string.h> #include <stdarg.h> #include <ctype.h> +#include <regex.h> #include "../core/weechat.h" #include "../core/wee-config.h" @@ -34,9 +35,11 @@ #include "../core/wee-log.h" #include "../core/wee-string.h" #include "../core/wee-utf8.h" +#include "../plugins/plugin.h" #include "gui-chat.h" #include "gui-buffer.h" #include "gui-color.h" +#include "gui-filter.h" #include "gui-hotlist.h" #include "gui-main.h" #include "gui-status.h" @@ -375,6 +378,94 @@ gui_chat_get_line_align (struct t_gui_buffer *buffer, struct t_gui_line *line, } /* + * gui_chat_line_displayed: return 1 if line is displayed (no filter on line, + * or filters disabled), 0 if line is hidden + */ + +int +gui_chat_line_displayed (struct t_gui_line *line) +{ + /* line is hidden if filters are enabled and flag "displayed" is not set */ + if (gui_filters_enabled && !line->displayed) + return 0; + + /* in all other cases, line is displayed */ + return 1; +} + +/* + * gui_chat_get_first_line_displayed: get first line displayed of a buffer + */ + +struct t_gui_line * +gui_chat_get_first_line_displayed (struct t_gui_buffer *buffer) +{ + struct t_gui_line *ptr_line; + + ptr_line = buffer->lines; + while (ptr_line && !gui_chat_line_displayed (ptr_line)) + { + ptr_line = ptr_line->next_line; + } + + return ptr_line; +} + +/* + * gui_chat_get_last_line_displayed: get last line displayed of a buffer + */ + +struct t_gui_line * +gui_chat_get_last_line_displayed (struct t_gui_buffer *buffer) +{ + struct t_gui_line *ptr_line; + + ptr_line = buffer->last_line; + while (ptr_line && !gui_chat_line_displayed (ptr_line)) + { + ptr_line = ptr_line->prev_line; + } + + return ptr_line; +} + +/* + * gui_chat_get_prev_line_displayed: get previous line displayed + */ + +struct t_gui_line * +gui_chat_get_prev_line_displayed (struct t_gui_line *line) +{ + if (line) + { + line = line->prev_line; + while (line && !gui_chat_line_displayed (line)) + { + line = line->prev_line; + } + } + return line; +} + +/* + * gui_chat_get_next_line_displayed: get next line displayed + */ + +struct t_gui_line * +gui_chat_get_next_line_displayed (struct t_gui_line *line) +{ + if (line) + { + line = line->next_line; + while (line && !gui_chat_line_displayed (line)) + { + line = line->next_line; + } + } + return line; +} + +/* * gui_chat_line_search: search for text in a line */ @@ -400,6 +491,78 @@ gui_chat_line_search (struct t_gui_line *line, char *text, int case_sensitive) } /* + * gui_chat_line_match_regex: return 1 if message matches regex + * 0 if it doesn't match + */ + +int +gui_chat_line_match_regex (struct t_gui_line *line, regex_t *regex_prefix, + regex_t *regex_message) +{ + char *prefix, *message; + int match_prefix, match_message; + + if (!line || (!regex_prefix && !regex_message)) + return 0; + + match_prefix = 1; + match_message = 1; + + prefix = (char *)gui_color_decode ((unsigned char *)line->prefix); + if (prefix && regex_prefix) + { + if (regexec (regex_prefix, prefix, 0, NULL, 0) != 0) + match_prefix = 0; + } + + message = (char *)gui_color_decode ((unsigned char *)line->message); + if (message && regex_message) + { + if (regexec (regex_message, message, 0, NULL, 0) != 0) + match_message = 0; + } + + if (prefix) + free (prefix); + if (message) + free (message); + + return (match_prefix && match_message); +} + +/* + * gui_chat_line_match_tags: return 1 if line matches tags + * 0 if it doesn't match any tag in array + */ + +int +gui_chat_line_match_tags (struct t_gui_line *line, int tags_count, + char **tags_array) +{ + int i, j; + + if (!line) + return 0; + + if (line->tags_count == 0) + return 0; + + for (i = 0; i < tags_count; i++) + { + for (j = 0; j < line->tags_count; j++) + { + /* check tag */ + if (string_match (line->tags_array[j], + tags_array[i], + 0)) + return 1; + } + } + + return 0; +} + +/* * gui_chat_line_free: delete a line from a buffer */ @@ -420,6 +583,8 @@ gui_chat_line_free (struct t_gui_line *line) } if (line->str_time) free (line->str_time); + if (line->tags_array) + string_free_exploded (line->tags_array); if (line->prefix) free (line->prefix); if (line->message) @@ -433,7 +598,8 @@ gui_chat_line_free (struct t_gui_line *line) void gui_chat_line_add (struct t_gui_buffer *buffer, time_t date, - time_t date_printed, char *prefix, char *message) + time_t date_printed, char *tags, + char *prefix, char *message) { struct t_gui_line *new_line, *ptr_line; @@ -449,6 +615,16 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date, new_line->date_printed = date_printed; new_line->str_time = (date == 0) ? NULL : gui_chat_get_time_string (date); + if (tags) + { + new_line->tags_array = string_explode (tags, ",", 0, 0, + &new_line->tags_count); + } + else + { + new_line->tags_count = 0; + new_line->tags_array = NULL; + } new_line->prefix = (prefix) ? strdup (prefix) : ((date != 0) ? strdup ("") : NULL); new_line->prefix_length = (prefix) ? @@ -465,6 +641,18 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date, buffer->last_line = new_line; buffer->lines_count++; + /* check if line is filtered or not */ + new_line->displayed = gui_filter_check_line (buffer, new_line); + if (!new_line->displayed) + { + if (!buffer->lines_hidden) + { + buffer->lines_hidden = 1; + hook_signal_send ("buffer_lines_hidden", + WEECHAT_HOOK_SIGNAL_POINTER, buffer); + } + } + /* remove one line if necessary */ if ((CONFIG_INTEGER(config_history_max_lines) > 0) && (buffer->lines_count > CONFIG_INTEGER(config_history_max_lines))) @@ -480,12 +668,13 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date, } /* - * gui_chat_printf_date: display a message in a buffer + * gui_chat_printf_date_tags: display a message in a buffer with optional + * date and tags */ void -gui_chat_printf_date (struct t_gui_buffer *buffer, time_t date, - char *message, ...) +gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date, + char *tags, char *message, ...) { char buf[8192]; time_t date_printed; @@ -552,11 +741,15 @@ gui_chat_printf_date (struct t_gui_buffer *buffer, time_t date, { gui_chat_line_add (buffer, (display_time) ? date : 0, (display_time) ? date_printed : 0, - pos_prefix, pos); + tags, pos_prefix, pos); if (buffer->last_line) + { hook_print_exec (buffer, buffer->last_line->date, + buffer->last_line->tags_count, + buffer->last_line->tags_array, buffer->last_line->prefix, buffer->last_line->message); + } } else { diff --git a/src/gui/gui-chat.h b/src/gui/gui-chat.h index b7abda270..f63d0ae4e 100644 --- a/src/gui/gui-chat.h +++ b/src/gui/gui-chat.h @@ -20,12 +20,14 @@ #ifndef __WEECHAT_GUI_CHAT_H #define __WEECHAT_GUI_CHAT_H 1 +#include <regex.h> + struct t_gui_window; struct t_gui_buffer; struct t_gui_line; -#define gui_chat_printf(buffer, argz...) \ - gui_chat_printf_date(buffer, 0, ##argz) \ +#define gui_chat_printf(buffer, argz...) \ + gui_chat_printf_date_tags(buffer, 0, NULL, ##argz) enum t_gui_prefix { @@ -58,11 +60,22 @@ extern void gui_chat_change_time_format (); extern int gui_chat_get_line_align (struct t_gui_buffer *buffer, struct t_gui_line *line, int with_suffix); +extern int gui_chat_line_displayed (struct t_gui_line *line); +extern struct t_gui_line *gui_chat_get_first_line_displayed (struct t_gui_buffer *buffer); +extern struct t_gui_line *gui_chat_get_last_line_displayed (struct t_gui_buffer *buffer); +extern struct t_gui_line *gui_chat_get_prev_line_displayed (struct t_gui_line *line); +extern struct t_gui_line *gui_chat_get_next_line_displayed (struct t_gui_line *line); extern int gui_chat_line_search (struct t_gui_line *line, char *text, int case_sensitive); +extern int gui_chat_line_match_regex (struct t_gui_line *line, + regex_t *regex_prefix, + regex_t *regex_message); +extern int gui_chat_line_match_tags (struct t_gui_line *line, int tags_count, + char **tags_array); extern void gui_chat_line_free (struct t_gui_line *line); -extern void gui_chat_printf_date (struct t_gui_buffer *buffer, time_t date, - char *message, ...); +extern void gui_chat_printf_date_tags (struct t_gui_buffer *buffer, + time_t date, char *tags, + char *message, ...); /* chat functions (GUI dependent) */ diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index 6b34b758c..c267b1200 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -116,3 +116,16 @@ gui_color_decode (unsigned char *string) out[out_pos] = '\0'; return out; } + +/* + * gui_color_free: free a color + */ + +void +gui_color_free (struct t_gui_color *color) +{ + if (color->string) + free (color->string); + + free (color); +} diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h index 55e437034..ff6d431cd 100644 --- a/src/gui/gui-color.h +++ b/src/gui/gui-color.h @@ -147,6 +147,7 @@ extern struct t_gui_color *gui_color[GUI_NUM_COLORS]; extern int gui_color_search_config (char *color_name); extern unsigned char *gui_color_decode (unsigned char *string); +extern void gui_color_free (struct t_gui_color *color); /* color functions (GUI dependent) */ diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c index 9d8b5a974..7c41879b0 100644 --- a/src/gui/gui-completion.c +++ b/src/gui/gui-completion.c @@ -262,6 +262,27 @@ gui_completion_list_add_buffers_names (struct t_gui_completion *completion) } /* + * gui_completion_list_add_buffers_categories_names: add buffers categories + * and names to completion + * list + */ + +void +gui_completion_list_add_buffers_categories_names (struct t_gui_completion *completion) +{ + struct t_gui_buffer *ptr_buffer; + char name[256]; + + for (ptr_buffer = gui_buffers; ptr_buffer; + ptr_buffer = ptr_buffer->next_buffer) + { + snprintf (name, sizeof (name), "%s.%s", + ptr_buffer->category, ptr_buffer->name); + gui_completion_list_add (completion, name, 0, WEECHAT_LIST_POS_SORT); + } +} + +/* * gui_completion_list_add_buffers_categories: add buffers categories to * completion list */ @@ -728,6 +749,9 @@ gui_completion_build_list_template (struct t_gui_completion *completion, case 'b': /* buffers names */ gui_completion_list_add_buffers_names (completion); break; + case 'B': /* buffers categories + names */ + gui_completion_list_add_buffers_categories_names (completion); + break; case 'c': /* buffers categories */ gui_completion_list_add_buffers_categories (completion); break; diff --git a/src/gui/gui-filter.c b/src/gui/gui-filter.c new file mode 100644 index 000000000..b5259a788 --- /dev/null +++ b/src/gui/gui-filter.c @@ -0,0 +1,426 @@ +/* + * Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/* gui-filter.c: filter functions, used by all GUI */ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdlib.h> +#include <string.h> +#include <regex.h> + +#include "../core/weechat.h" +#include "../core/wee-hook.h" +#include "../core/wee-log.h" +#include "../core/wee-string.h" +#include "../plugins/plugin.h" +#include "gui-filter.h" +#include "gui-buffer.h" +#include "gui-chat.h" + + +struct t_gui_filter *gui_filters = NULL; /* first filter */ +struct t_gui_filter *last_gui_filter = NULL; /* last filter */ +int gui_filters_enabled = 1; /* filters enabled? */ + + +/* + * gui_filter_enable: enable filters + */ + +void +gui_filter_enable () +{ + struct t_gui_buffer *ptr_buffer; + + if (!gui_filters_enabled) + { + gui_filters_enabled = 1; + + /* ask refresh for buffer with hidden lines */ + for (ptr_buffer = gui_buffers; ptr_buffer; + ptr_buffer = ptr_buffer->next_buffer) + { + if (ptr_buffer->lines_hidden) + { + hook_signal_send ("buffer_lines_hidden", + WEECHAT_HOOK_SIGNAL_POINTER, ptr_buffer); + } + if (ptr_buffer->lines_hidden) + ptr_buffer->chat_refresh_needed = 1; + } + } + + hook_signal_send ("filters_enabled", + WEECHAT_HOOK_SIGNAL_STRING, NULL); +} + +/* + * gui_filter_disable: disable filters + */ + +void +gui_filter_disable () +{ + struct t_gui_buffer *ptr_buffer; + + if (gui_filters_enabled) + { + gui_filters_enabled = 0; + + /* ask refresh for buffer with hidden lines */ + for (ptr_buffer = gui_buffers; ptr_buffer; + ptr_buffer = ptr_buffer->next_buffer) + { + if (ptr_buffer->lines_hidden) + { + hook_signal_send ("buffer_lines_hidden", + WEECHAT_HOOK_SIGNAL_POINTER, ptr_buffer); + } + if (ptr_buffer->lines_hidden) + ptr_buffer->chat_refresh_needed = 1; + } + } + + hook_signal_send ("filters_disabled", + WEECHAT_HOOK_SIGNAL_STRING, NULL); +} + +/* + * gui_filter_check_line: return 1 if a line should be displayed, or + * 0 if line is hidden (tag or regex found) + */ + +int +gui_filter_check_line (struct t_gui_buffer *buffer, struct t_gui_line *line) +{ + struct t_gui_filter *ptr_filter; + + /* make C compiler happy */ + (void) buffer; + + for (ptr_filter = gui_filters; ptr_filter; + ptr_filter = ptr_filter->next_filter) + { + /* check buffer name */ + if (gui_buffer_match_category_name (buffer, + ptr_filter->buffer, 0)) + { + /* check line with regex */ + if (gui_chat_line_match_regex (line, + ptr_filter->regex_prefix, + ptr_filter->regex_message)) + return 0; + + if ((strcmp (ptr_filter->tags, "*") != 0) + && (gui_chat_line_match_tags (line, + ptr_filter->tags_count, + ptr_filter->tags_array))) + return 0; + } + } + + /* no tag or regex matching, then line is displayed */ + return 1; +} + +/* + * gui_filter_buffer: filter a buffer, using message filters + */ + +void +gui_filter_buffer (struct t_gui_buffer *buffer) +{ + struct t_gui_line *ptr_line; + int line_displayed, lines_hidden; + + lines_hidden = 0; + + for (ptr_line = buffer->lines; ptr_line; + ptr_line = ptr_line->next_line) + { + line_displayed = gui_filter_check_line (buffer, ptr_line); + + /* force chat refresh if at least one line changed */ + if (ptr_line->displayed != line_displayed) + buffer->chat_refresh_needed = 1; + + ptr_line->displayed = line_displayed; + + if (!line_displayed) + lines_hidden = 1; + } + + if (buffer->lines_hidden != lines_hidden) + { + buffer->lines_hidden = lines_hidden; + hook_signal_send ("buffer_lines_hidden", + WEECHAT_HOOK_SIGNAL_POINTER, buffer); + } +} + +/* + * gui_filter_all_buffers: filter all buffers, using message filters + */ + +void +gui_filter_all_buffers () +{ + struct t_gui_buffer *ptr_buffer; + + for (ptr_buffer = gui_buffers; ptr_buffer; + ptr_buffer = ptr_buffer->next_buffer) + { + gui_filter_buffer (ptr_buffer); + } +} + +/* + * gui_filter_search: search a filter + */ + +struct t_gui_filter * +gui_filter_search (char *buffer, char *tags, char *regex) +{ + struct t_gui_filter *ptr_filter; + + for (ptr_filter = gui_filters; ptr_filter; + ptr_filter = ptr_filter->next_filter) + { + if ((strcmp (ptr_filter->buffer, buffer) == 0) + && (strcmp (ptr_filter->tags, tags) == 0) + && (strcmp (ptr_filter->regex, regex) == 0)) + return ptr_filter; + } + + /* no filter found */ + return NULL; +} + +/* + * gui_filter_search_by_number: search a filter by number (first is #1) + */ + +struct t_gui_filter * +gui_filter_search_by_number (int number) +{ + struct t_gui_filter *ptr_filter; + int i; + + i = 1; + for (ptr_filter = gui_filters; ptr_filter; + ptr_filter = ptr_filter->next_filter) + { + if (i == number) + return ptr_filter; + i++; + } + + /* no filter found */ + return NULL; +} + +/* + * gui_filter_new: create a new filter + */ + +struct t_gui_filter * +gui_filter_new (char *buffer, char *tags, char *regex) +{ + struct t_gui_filter *new_filter; + regex_t *regex1, *regex2; + char *pos_tab, *regex_prefix, *pos_regex_message; + + if (!buffer || !tags || !regex) + return NULL; + + regex1 = NULL; + regex2 = NULL; + if (strcmp (regex, "*") != 0) + { + pos_tab = strstr (regex, "\\t"); + if (pos_tab) + { + regex_prefix = string_strndup (regex, pos_tab - regex); + pos_regex_message = pos_tab + 2; + } + else + { + regex_prefix = strdup (regex); + pos_regex_message = regex; + } + + if (!regex_prefix) + return NULL; + + regex1 = (regex_t *)malloc (sizeof (regex_t)); + if (regex1) + { + if (regcomp (regex1, regex_prefix, + REG_NOSUB | REG_ICASE) != 0) + { + free (regex_prefix); + free (regex1); + return NULL; + } + } + + regex2 = (regex_t *)malloc (sizeof (regex_t)); + if (regex2) + { + if (regcomp (regex2, pos_regex_message, + REG_NOSUB | REG_ICASE) != 0) + { + free (regex_prefix); + if (regex1) + free (regex1); + free (regex2); + return NULL; + } + } + + free (regex_prefix); + } + + /* create new filter */ + new_filter = (struct t_gui_filter *)(malloc (sizeof (struct t_gui_filter))); + if (new_filter) + { + /* init filter */ + new_filter->buffer = (buffer) ? strdup (buffer) : strdup ("*"); + if (tags) + { + new_filter->tags = (tags) ? strdup (tags) : NULL; + new_filter->tags_array = string_explode (tags, ",", 0, 0, + &new_filter->tags_count); + } + else + { + new_filter->tags = NULL; + new_filter->tags_count = 0; + new_filter->tags_array = NULL; + } + new_filter->regex = strdup (regex); + new_filter->regex_prefix = regex1; + new_filter->regex_message = regex2; + + /* add filter to filters list */ + new_filter->prev_filter = last_gui_filter; + if (gui_filters) + last_gui_filter->next_filter = new_filter; + else + gui_filters = new_filter; + last_gui_filter = new_filter; + new_filter->next_filter = NULL; + + gui_filter_all_buffers (); + + hook_signal_send ("filter_added", + WEECHAT_HOOK_SIGNAL_POINTER, new_filter); + } + + return new_filter; +} + +/* + * gui_filter_free: remove a filter + */ + +void +gui_filter_free (struct t_gui_filter *filter) +{ + hook_signal_send ("filter_removing", + WEECHAT_HOOK_SIGNAL_POINTER, filter); + + /* free data */ + if (filter->buffer) + free (filter->buffer); + if (filter->tags) + free (filter->tags); + if (filter->regex) + free (filter->regex); + if (filter->regex_prefix) + { + regfree (filter->regex_prefix); + free (filter->regex_prefix); + } + if (filter->regex_message) + { + regfree (filter->regex_message); + free (filter->regex_message); + } + + /* remove filter from filters list */ + if (filter->prev_filter) + filter->prev_filter->next_filter = filter->next_filter; + if (filter->next_filter) + filter->next_filter->prev_filter = filter->prev_filter; + if (gui_filters == filter) + gui_filters = filter->next_filter; + if (last_gui_filter == filter) + last_gui_filter = filter->prev_filter; + + free (filter); + + gui_filter_all_buffers (); + + hook_signal_send ("filter_removed", WEECHAT_HOOK_SIGNAL_STRING, NULL); +} + +/* + * gui_filter_free_all: remove all filters + */ + +void +gui_filter_free_all () +{ + while (gui_filters) + { + gui_filter_free (gui_filters); + } +} + +/* + * gui_filter_print_log: print filter infos in log (usually for crash dump) + */ + +void +gui_filter_print_log () +{ + struct t_gui_filter *ptr_filter; + + log_printf (""); + log_printf ("gui_filters_enabled = %d", gui_filters_enabled); + + for (ptr_filter = gui_filters; ptr_filter; + ptr_filter = ptr_filter->next_filter) + { + log_printf (""); + log_printf ("[filter (addr:0x%x)]", ptr_filter); + log_printf (" buffer . . . . . . . . : '%s'", ptr_filter->buffer); + log_printf (" tags . . . . . . . . . : '%s'", ptr_filter->tags); + log_printf (" regex. . . . . . . . . : '%s'", ptr_filter->regex); + log_printf (" regex_prefix . . . . . : 0x%x", ptr_filter->regex_prefix); + log_printf (" regex_message. . . . . : 0x%x", ptr_filter->regex_message); + log_printf (" prev_filter. . . . . . : 0x%x", ptr_filter->prev_filter); + log_printf (" next_filter. . . . . . : 0x%x", ptr_filter->next_filter); + } +} diff --git a/src/gui/gui-filter.h b/src/gui/gui-filter.h new file mode 100644 index 000000000..ef900a889 --- /dev/null +++ b/src/gui/gui-filter.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org> + * See README for License detail, AUTHORS for developers list. + * + * 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 + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef __WEECHAT_GUI_FILTER_H +#define __WEECHAT_GUI_FILTER_H 1 + +#include <regex.h> + +/* filter structures */ + +struct t_gui_line; + +struct t_gui_filter +{ + char *buffer; /* name of buffer */ + char *tags; /* tags */ + int tags_count; /* number of tags */ + char **tags_array; /* array of tags */ + char *regex; /* regex */ + regex_t *regex_prefix; /* regex for line prefix */ + regex_t *regex_message; /* regex for line message */ + struct t_gui_filter *prev_filter; /* link to previous line */ + struct t_gui_filter *next_filter; /* link to next line */ +}; + +/* filter variables */ + +extern struct t_gui_filter *gui_filters; +extern struct t_gui_filter *last_gui_filter; +extern int gui_filters_enabled; + +/* filter functions */ + +extern void gui_filter_enable (); +extern void gui_filter_disable (); +extern int gui_filter_check_line (struct t_gui_buffer *buffer, + struct t_gui_line *line); +extern struct t_gui_filter *gui_filter_search (char *buffer, char *tags, + char *regex); +extern struct t_gui_filter *gui_filter_search_by_number (int number); +extern struct t_gui_filter *gui_filter_new (char *buffer, char *tags, + char *regex); +extern void gui_filter_free (struct t_gui_filter *filter); +extern void gui_filter_free_all (); +extern void gui_filter_print_log (); + +#endif /* gui-filter.h */ diff --git a/src/gui/gui-keyboard.c b/src/gui/gui-keyboard.c index b0e6784b2..d32acb99e 100644 --- a/src/gui/gui-keyboard.c +++ b/src/gui/gui-keyboard.c @@ -714,7 +714,9 @@ void gui_keyboard_free_all () { while (gui_keys) + { gui_keyboard_free (gui_keys); + } } /* @@ -827,3 +829,18 @@ gui_keyboard_paste_cancel () gui_keyboard_buffer_reset (); gui_keyboard_paste_pending = 0; } + +/* + * gui_keyboard_end: end keyboard (free some data) + */ + +void +gui_keyboard_end () +{ + /* free keyboard buffer */ + if (gui_keyboard_buffer) + free (gui_keyboard_buffer); + + /* free all keys */ + gui_keyboard_free_all (); +} diff --git a/src/gui/gui-keyboard.h b/src/gui/gui-keyboard.h index 8971963b9..065d59f54 100644 --- a/src/gui/gui-keyboard.h +++ b/src/gui/gui-keyboard.h @@ -76,6 +76,7 @@ extern void gui_keyboard_buffer_add (int key); extern int gui_keyboard_get_paste_lines (); extern void gui_keyboard_paste_accept (); extern void gui_keyboard_paste_cancel (); +extern void gui_keyboard_end (); /* keyboard functions (GUI dependent) */ diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c index f2ee25a40..85c285d66 100644 --- a/src/gui/gui-window.c +++ b/src/gui/gui-window.c @@ -39,6 +39,7 @@ #include "gui-window.h" #include "gui-buffer.h" #include "gui-chat.h" +#include "gui-filter.h" #include "gui-input.h" #include "gui-hotlist.h" #include "gui-status.h" @@ -280,7 +281,11 @@ gui_window_free (struct t_gui_window *window) window->buffer->num_displayed--; /* free data */ - gui_window_objects_free (window, 1); + if (window->gui_objects) + { + gui_window_objects_free (window, 1); + free (window->gui_objects); + } /* remove window from windows list */ if (window->prev_window) @@ -448,7 +453,7 @@ gui_window_scroll (struct t_gui_window *window, char *scroll) number = 0; time_letter = ' '; - // search direction + /* search direction */ if (scroll[0] == '-') { direction = -1; @@ -460,7 +465,7 @@ gui_window_scroll (struct t_gui_window *window, char *scroll) scroll++; } - // search number and letter + /* search number and letter */ char *pos = scroll; while (pos && pos[0] && isdigit (pos[0])) { @@ -481,7 +486,7 @@ gui_window_scroll (struct t_gui_window *window, char *scroll) pos[0] = '\0'; error = NULL; number = strtol (scroll, &error, 10); - if (!error || (error[0] != '\0')) + if (!error || error[0]) number = 0; pos[0] = saved_char; } @@ -491,15 +496,27 @@ gui_window_scroll (struct t_gui_window *window, char *scroll) if ((number == 0) && (time_letter == ' ')) return; - // do the scroll! + /* do the scroll! */ stop = 0; count_msg = 0; if (direction < 0) + { ptr_line = (window->start_line) ? window->start_line : window->buffer->last_line; + while (ptr_line && !gui_chat_line_displayed (ptr_line)) + { + ptr_line = ptr_line->prev_line; + } + } else + { ptr_line = (window->start_line) ? window->start_line : window->buffer->lines; + while (ptr_line && !gui_chat_line_displayed (ptr_line)) + { + ptr_line = ptr_line->next_line; + } + } old_date = ptr_line->date; date_tmp = localtime (&old_date); @@ -507,7 +524,8 @@ gui_window_scroll (struct t_gui_window *window, char *scroll) while (ptr_line) { - ptr_line = (direction < 0) ? ptr_line->prev_line : ptr_line->next_line; + ptr_line = (direction < 0) ? + gui_chat_get_prev_line_displayed (ptr_line) : gui_chat_get_next_line_displayed (ptr_line); if (ptr_line) { @@ -614,7 +632,7 @@ gui_window_scroll (struct t_gui_window *window, char *scroll) window->start_line = ptr_line; window->start_line_pos = 0; window->first_line_displayed = - (window->start_line == window->buffer->lines); + (window->start_line == gui_chat_get_first_line_displayed (window->buffer)); window->buffer->chat_refresh_needed = 1; gui_status_refresh_needed = 1; return; @@ -644,6 +662,10 @@ gui_window_search_text (struct t_gui_window *window) { ptr_line = (window->start_line) ? window->start_line->prev_line : window->buffer->last_line; + while (ptr_line && !gui_chat_line_displayed (ptr_line)) + { + ptr_line = ptr_line->prev_line; + } while (ptr_line) { if (gui_chat_line_search (ptr_line, @@ -653,12 +675,12 @@ gui_window_search_text (struct t_gui_window *window) window->start_line = ptr_line; window->start_line_pos = 0; window->first_line_displayed = - (window->start_line == window->buffer->lines); + (window->start_line == gui_chat_get_first_line_displayed (window->buffer)); window->buffer->chat_refresh_needed = 1; gui_status_refresh_needed = 1; return 1; } - ptr_line = ptr_line->prev_line; + ptr_line = gui_chat_get_prev_line_displayed (ptr_line); } } } @@ -669,6 +691,10 @@ gui_window_search_text (struct t_gui_window *window) { ptr_line = (window->start_line) ? window->start_line->next_line : window->buffer->lines->next_line; + while (ptr_line && !gui_chat_line_displayed (ptr_line)) + { + ptr_line = ptr_line->next_line; + } while (ptr_line) { if (gui_chat_line_search (ptr_line, @@ -683,7 +709,7 @@ gui_window_search_text (struct t_gui_window *window) gui_status_refresh_needed = 1; return 1; } - ptr_line = ptr_line->next_line; + ptr_line = gui_chat_get_next_line_displayed (ptr_line); } } } diff --git a/src/plugins/demo/demo.c b/src/plugins/demo/demo.c index 342d0bc68..02529c49e 100644 --- a/src/plugins/demo/demo.c +++ b/src/plugins/demo/demo.c @@ -147,8 +147,8 @@ demo_buffer_input_data_cb (void *data, struct t_gui_buffer *buffer, "buffer_input_data_cb: buffer = %x (%s / %s), " "input_data = '%s'", buffer, - weechat_buffer_get (buffer, "category"), - weechat_buffer_get (buffer, "name"), + weechat_buffer_get_string (buffer, "category"), + weechat_buffer_get_string (buffer, "name"), input_data); return WEECHAT_RC_OK; @@ -169,8 +169,8 @@ demo_buffer_close_cb (void *data, struct t_gui_buffer *buffer) weechat_printf (NULL, "buffer_close_cb: buffer = %x (%s / %s)", buffer, - weechat_buffer_get (buffer, "category"), - weechat_buffer_get (buffer, "name")); + weechat_buffer_get_string (buffer, "category"), + weechat_buffer_get_string (buffer, "name")); } return WEECHAT_RC_OK; diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index 62f232919..0da623d24 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -169,12 +169,14 @@ irc_channel_free (struct t_irc_server *server, struct t_irc_channel *channel) free (channel->modes); if (channel->key) free (channel->key); - //irc_nick_free_all (channel); + irc_nick_free_all (channel); if (channel->away_message) free (channel->away_message); if (channel->nicks_speaking) weechat_list_free (channel->nicks_speaking); + free (channel); + server->channels = new_channels; } diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index 98d7b6d69..03a778590 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -568,7 +568,7 @@ irc_command_connect (void *data, struct t_gui_buffer *buffer, int argc, } error = NULL; number = strtol (argv[++i], &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) port = number; } } diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index e5ba83646..06c6913e6 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -352,9 +352,10 @@ irc_nick_free (struct t_irc_channel *channel, struct t_irc_nick *nick) free (nick->name); if (nick->host) free (nick->host); + free (nick); - channel->nicks = new_nicks; + channel->nicks = new_nicks; channel->nick_completion_reset = 1; } diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index f941c3b78..6dbda311e 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -105,6 +105,36 @@ irc_protocol_get_address_from_host (char *host) } /* + * irc_protocol_tags: build tags list with IRC command and/or tags + */ + +char * +irc_protocol_tags (char *command, char *tags) +{ + static char string[256]; + + if (command && tags) + { + snprintf (string, sizeof (string), "irc_cmd_%s,%s", command, tags); + return string; + } + + if (command) + { + snprintf (string, sizeof (string), "irc_cmd_%s", command); + return string; + } + + if (tags) + { + snprintf (string, sizeof (string), "%s", tags); + return string; + } + + return NULL; +} + +/* * irc_protocol_replace_vars: replace special IRC vars ($nick, $channel, * $server) in a string * Note: result has to be free() after use @@ -348,7 +378,7 @@ irc_protocol_is_highlight (char *message, char *nick) int irc_protocol_cmd_error (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { int first_arg; char *chan_nick, *args; @@ -357,7 +387,6 @@ irc_protocol_cmd_error (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) argc; - (void) ignore; (void) highlight; first_arg = (strcmp (argv[2], server->nick) == 0) ? 3 : 2; @@ -375,12 +404,13 @@ irc_protocol_cmd_error (struct t_irc_server *server, char *command, if (args[0] == ':') args++; - weechat_printf (server->buffer, - "%s%s%s%s", - weechat_prefix ("network"), - (chan_nick) ? chan_nick : "", - (chan_nick) ? ": " : "", - args); + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_error"), + "%s%s%s%s", + weechat_prefix ("network"), + (chan_nick) ? chan_nick : "", + (chan_nick) ? ": " : "", + args); if (strncmp (args, "Closing Link", 12) == 0) irc_server_disconnect (server, 1); @@ -395,7 +425,7 @@ irc_protocol_cmd_error (struct t_irc_server *server, char *command, int irc_protocol_cmd_invite (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* INVITE message looks like: :nick!user@host INVITE mynick :#channel @@ -408,20 +438,18 @@ irc_protocol_cmd_invite (struct t_irc_server *server, char *command, (void) argv_eol; (void) highlight; - if (!ignore) - { - weechat_printf (server->buffer, - _("%sYou have been invited to %s%s%s by " - "%s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - (argv[3][0] == ':') ? argv[3] + 1 : argv[3], - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - irc_protocol_get_nick_from_host (argv[0])); - weechat_buffer_set (server->buffer, "hotlist", - WEECHAT_HOTLIST_HIGHLIGHT); - } + weechat_printf_tags (server->buffer, + "irc_invite", + _("%sYou have been invited to %s%s%s by " + "%s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + (argv[3][0] == ':') ? argv[3] + 1 : argv[3], + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + irc_protocol_get_nick_from_host (argv[0])); + weechat_buffer_set (server->buffer, "hotlist", + WEECHAT_HOTLIST_HIGHLIGHT); return WEECHAT_RC_OK; } @@ -434,7 +462,7 @@ irc_protocol_cmd_invite (struct t_irc_server *server, char *command, int irc_protocol_cmd_join (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { struct t_irc_channel *ptr_channel; struct t_irc_nick *ptr_nick; @@ -467,21 +495,19 @@ irc_protocol_cmd_join (struct t_irc_server *server, char *command, } } - if (!ignore) - { - weechat_printf (ptr_channel->buffer, - _("%s%s%s %s(%s%s%s)%s has joined %s%s"), - weechat_prefix ("join"), - IRC_COLOR_CHAT_NICK, - irc_protocol_get_nick_from_host (argv[0]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - irc_protocol_get_address_from_host (argv[0]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_CHANNEL, - pos_channel); - } + weechat_printf_tags (ptr_channel->buffer, + "irc_join", + _("%s%s%s %s(%s%s%s)%s has joined %s%s"), + weechat_prefix ("join"), + IRC_COLOR_CHAT_NICK, + irc_protocol_get_nick_from_host (argv[0]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + irc_protocol_get_address_from_host (argv[0]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + pos_channel); /* remove topic and display channel creation date if joining new channel */ if (!ptr_channel->nicks) @@ -512,7 +538,7 @@ irc_protocol_cmd_join (struct t_irc_server *server, char *command, int irc_protocol_cmd_kick (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_comment; struct t_irc_channel *ptr_channel; @@ -542,40 +568,40 @@ irc_protocol_cmd_kick (struct t_irc_server *server, char *command, return WEECHAT_RC_ERROR; } - if (!ignore) + if (pos_comment) { - if (pos_comment) - { - weechat_printf (ptr_channel->buffer, - _("%s%s%s%s has kicked %s%s%s from %s%s %s(%s%s%s)"), - weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, - irc_protocol_get_nick_from_host (argv[0]), - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - argv[3], - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_CHANNEL, - argv[2], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - pos_comment, - IRC_COLOR_CHAT_DELIMITERS); - } - else - { - weechat_printf (ptr_channel->buffer, - _("%s%s%s%s has kicked %s%s%s from %s%s"), - weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, - irc_protocol_get_nick_from_host (argv[0]), - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - argv[3], - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_CHANNEL, - argv[2]); - } + weechat_printf_tags (ptr_channel->buffer, + "irc_kick", + _("%s%s%s%s has kicked %s%s%s from %s%s " + "%s(%s%s%s)"), + weechat_prefix ("quit"), + IRC_COLOR_CHAT_NICK, + irc_protocol_get_nick_from_host (argv[0]), + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + argv[3], + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + argv[2], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_comment, + IRC_COLOR_CHAT_DELIMITERS); + } + else + { + weechat_printf_tags (ptr_channel->buffer, + "irc_kick", + _("%s%s%s%s has kicked %s%s%s from %s%s"), + weechat_prefix ("quit"), + IRC_COLOR_CHAT_NICK, + irc_protocol_get_nick_from_host (argv[0]), + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + argv[3], + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + argv[2]); } if (strcmp (argv[3], server->nick) == 0) @@ -605,7 +631,7 @@ irc_protocol_cmd_kick (struct t_irc_server *server, char *command, int irc_protocol_cmd_kill (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_comment; struct t_irc_channel *ptr_channel; @@ -627,43 +653,42 @@ irc_protocol_cmd_kill (struct t_irc_server *server, char *command, for (ptr_channel = server->channels; ptr_channel; ptr_channel = ptr_channel->next_channel) { - if (!ignore) + if (pos_comment) { - if (pos_comment) - { - weechat_printf (ptr_channel->buffer, - _("%sYou were killed by %s%s %s(%s%s%s)"), - weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, - irc_protocol_get_nick_from_host (argv[0]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - pos_comment, - IRC_COLOR_CHAT_DELIMITERS); - } - else - { - weechat_printf (ptr_channel->buffer, - _("%sYou were killed by %s%s"), - weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, - irc_protocol_get_nick_from_host (argv[0])); - } - - if (strcmp (argv[2], server->nick) == 0) - { - /* my nick was killed => free all nicks, channel is not active any - more */ - irc_nick_free_all (ptr_channel); - } - else - { - /* someone was killed on channel (but not me) => remove only this - nick */ - ptr_nick = irc_nick_search (ptr_channel, argv[2]); - if (ptr_nick) - irc_nick_free (ptr_channel, ptr_nick); - } + weechat_printf_tags (ptr_channel->buffer, + "irc_kill", + _("%sYou were killed by %s%s %s(%s%s%s)"), + weechat_prefix ("quit"), + IRC_COLOR_CHAT_NICK, + irc_protocol_get_nick_from_host (argv[0]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_comment, + IRC_COLOR_CHAT_DELIMITERS); + } + else + { + weechat_printf_tags (ptr_channel->buffer, + "irc_kill", + _("%sYou were killed by %s%s"), + weechat_prefix ("quit"), + IRC_COLOR_CHAT_NICK, + irc_protocol_get_nick_from_host (argv[0])); + } + + if (strcmp (argv[2], server->nick) == 0) + { + /* my nick was killed => free all nicks, channel is not active any + more */ + irc_nick_free_all (ptr_channel); + } + else + { + /* someone was killed on channel (but not me) => remove only this + nick */ + ptr_nick = irc_nick_search (ptr_channel, argv[2]); + if (ptr_nick) + irc_nick_free (ptr_channel, ptr_nick); } } @@ -677,7 +702,7 @@ irc_protocol_cmd_kill (struct t_irc_server *server, char *command, int irc_protocol_cmd_mode (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_modes; struct t_irc_channel *ptr_channel; @@ -702,40 +727,36 @@ irc_protocol_cmd_mode (struct t_irc_server *server, char *command, irc_mode_channel_set (server, ptr_channel, pos_modes); irc_server_sendf (server, "MODE %s", ptr_channel->name); } - if (!ignore) - { - weechat_printf ((ptr_channel) ? - ptr_channel->buffer : server->buffer, - _("%sMode %s%s %s[%s%s%s]%s by %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - ptr_channel->name, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - pos_modes, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - irc_protocol_get_nick_from_host (argv[0])); - } + weechat_printf_tags ((ptr_channel) ? + ptr_channel->buffer : server->buffer, + "irc_mode", + _("%sMode %s%s %s[%s%s%s]%s by %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + ptr_channel->name, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_modes, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + irc_protocol_get_nick_from_host (argv[0])); } else { - if (!ignore) - { - weechat_printf (server->buffer, - _("%sUser mode %s[%s%s%s]%s by %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - pos_modes, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - irc_protocol_get_nick_from_host (argv[0])); - } - irc_mode_user_set (server, pos_modes); + weechat_printf_tags (server->buffer, + "irc_mode", + _("%sUser mode %s[%s%s%s]%s by %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_modes, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + irc_protocol_get_nick_from_host (argv[0])); } + irc_mode_user_set (server, pos_modes); return WEECHAT_RC_OK; } @@ -747,7 +768,7 @@ irc_protocol_cmd_mode (struct t_irc_server *server, char *command, int irc_protocol_cmd_nick (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { struct t_irc_channel *ptr_channel; struct t_irc_nick *ptr_nick; @@ -795,27 +816,28 @@ irc_protocol_cmd_nick (struct t_irc_server *server, char *command, /* change nick and display message on all channels */ irc_nick_change (server, ptr_channel, ptr_nick, new_nick); - if (!ignore) + if (nick_is_me) { - if (nick_is_me) - { - weechat_printf (ptr_channel->buffer, - _("%sYou are now known as %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, - new_nick); - } - else - { - weechat_printf (ptr_channel->buffer, - _("%s%s%s%s is now known as %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, - old_nick, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - new_nick); - } + weechat_printf_tags (ptr_channel->buffer, + "irc_nick", + _("%sYou are now known as " + "%s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK, + new_nick); + } + else + { + weechat_printf_tags (ptr_channel->buffer, + "irc_nick", + _("%s%s%s%s is now known as " + "%s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK, + old_nick, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + new_nick); } /* enable hotlist */ @@ -838,7 +860,7 @@ irc_protocol_cmd_nick (struct t_irc_server *server, char *command, int irc_protocol_cmd_notice (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *nick, *host, *pos_args, *pos_end, *pos_usec; struct timeval tv; @@ -869,181 +891,185 @@ irc_protocol_cmd_notice (struct t_irc_server *server, char *command, look_infobar_delay_highlight = weechat_config_integer ( weechat_config_get_weechat ("look_infobar_delay_highlight")); - if (!ignore) + if (nick && strncmp (pos_args, "\01VERSION", 8) == 0) { - if (nick && strncmp (pos_args, "\01VERSION", 8) == 0) - { - pos_args += 9; - pos_end = strchr (pos_args, '\01'); - if (pos_end) - pos_end[0] = '\0'; - weechat_printf (server->buffer, - _("%sCTCP %sVERSION%s reply from %s%s%s: %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT, - pos_args); - if (pos_end) - pos_end[0] = '\01'; - } - else + pos_args += 9; + pos_end = strchr (pos_args, '\01'); + if (pos_end) + pos_end[0] = '\0'; + weechat_printf_tags (server->buffer, + "irc_notice", + _("%sCTCP %sVERSION%s reply from %s%s%s: %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos_args); + if (pos_end) + pos_end[0] = '\01'; + } + else + { + if (nick && strncmp (pos_args, "\01PING", 5) == 0) { - if (nick && strncmp (pos_args, "\01PING", 5) == 0) + pos_args += 5; + while (pos_args[0] == ' ') { - pos_args += 5; - while (pos_args[0] == ' ') - { - pos_args++; - } - pos_usec = strchr (pos_args, ' '); - if (pos_usec) + pos_args++; + } + pos_usec = strchr (pos_args, ' '); + if (pos_usec) + { + pos_usec[0] = '\0'; + pos_end = strchr (pos_usec + 1, '\01'); + if (pos_end) { - pos_usec[0] = '\0'; - pos_end = strchr (pos_usec + 1, '\01'); - if (pos_end) - { - pos_end[0] = '\0'; + pos_end[0] = '\0'; - gettimeofday (&tv, NULL); - sec1 = atol (pos_args); - usec1 = atol (pos_usec + 1); - sec2 = tv.tv_sec; - usec2 = tv.tv_usec; + gettimeofday (&tv, NULL); + sec1 = atol (pos_args); + usec1 = atol (pos_usec + 1); + sec2 = tv.tv_sec; + usec2 = tv.tv_usec; - difftime = ((sec2 * 1000000) + usec2) - - ((sec1 * 1000000) + usec1); + difftime = ((sec2 * 1000000) + usec2) - + ((sec1 * 1000000) + usec1); - weechat_printf (server->buffer, - _("%sCTCP %sPING%s reply from " - "%s%s%s: %ld.%ld %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT, - difftime / 1000000, - (difftime % 1000000) / 1000, - (NG_("second", "seconds", - (difftime / 1000000)))); + weechat_printf_tags (server->buffer, + "irc_notice,irc_ctcp", + _("%sCTCP %sPING%s reply from " + "%s%s%s: %ld.%ld %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + difftime / 1000000, + (difftime % 1000000) / 1000, + (NG_("second", "seconds", + (difftime / 1000000)))); - pos_end[0] = '\01'; - } - pos_usec[0] = ' '; + pos_end[0] = '\01'; } + pos_usec[0] = ' '; } - else + } + else + { + if (nick && weechat_config_boolean (irc_config_irc_notice_as_pv)) { - if (nick && weechat_config_boolean (irc_config_irc_notice_as_pv)) + ptr_channel = irc_channel_search (server, nick); + if (!ptr_channel) { - ptr_channel = irc_channel_search (server, nick); + ptr_channel = irc_channel_new (server, + IRC_CHANNEL_TYPE_PRIVATE, + nick, 0); if (!ptr_channel) { - ptr_channel = irc_channel_new (server, - IRC_CHANNEL_TYPE_PRIVATE, - nick, 0); - if (!ptr_channel) - { - weechat_printf (server->buffer, - _("%s%s: cannot create new " - "private buffer \"%s\""), - weechat_prefix ("error"), "irc", - nick); - return WEECHAT_RC_ERROR; - } - } - if (!ptr_channel->topic) - { - ptr_channel->topic = strdup ((host) ? host : ""); - weechat_buffer_set (ptr_channel->buffer, - "title", ptr_channel->topic); + weechat_printf (server->buffer, + _("%s%s: cannot create new " + "private buffer \"%s\""), + weechat_prefix ("error"), "irc", + nick); + return WEECHAT_RC_ERROR; } + } + if (!ptr_channel->topic) + { + ptr_channel->topic = strdup ((host) ? host : ""); + weechat_buffer_set (ptr_channel->buffer, + "title", ptr_channel->topic); + } - if (highlight - || irc_protocol_is_highlight (pos_args, server->nick)) - { - weechat_printf (ptr_channel->buffer, - "%s%s", - irc_nick_as_prefix (NULL, nick, - IRC_COLOR_CHAT_HIGHLIGHT), - pos_args); - if ((look_infobar_delay_highlight > 0) - && (ptr_channel->buffer != weechat_current_buffer)) - { - weechat_infobar_printf (look_infobar_delay_highlight, - IRC_COLOR_INFOBAR_HIGHLIGHT, - _("Private %s> %s"), - nick, pos_args); - } - highlight_displayed = 1; - } - else + if (highlight + || irc_protocol_is_highlight (pos_args, server->nick)) + { + weechat_printf_tags (ptr_channel->buffer, + "irc_notice", + "%s%s", + irc_nick_as_prefix (NULL, nick, + IRC_COLOR_CHAT_HIGHLIGHT), + pos_args); + if ((look_infobar_delay_highlight > 0) + && (ptr_channel->buffer != weechat_current_buffer)) { - weechat_printf (ptr_channel->buffer, - "%s%s", - irc_nick_as_prefix (NULL, nick, - IRC_COLOR_CHAT_NICK_OTHER), - pos_args); - highlight_displayed = 0; + weechat_infobar_printf (look_infobar_delay_highlight, + IRC_COLOR_INFOBAR_HIGHLIGHT, + _("Private %s> %s"), + nick, pos_args); } + highlight_displayed = 1; + } + else + { + weechat_printf_tags (ptr_channel->buffer, + "irc_notice", + "%s%s", + irc_nick_as_prefix (NULL, nick, + IRC_COLOR_CHAT_NICK_OTHER), + pos_args); + highlight_displayed = 0; + } - /* send "irc_highlight" signal */ - if (highlight_displayed) - { - weechat_hook_signal_send ("irc_highlight", - WEECHAT_HOOK_SIGNAL_STRING, - argv_eol[0]); - } + /* send "irc_highlight" signal */ + if (highlight_displayed) + { + weechat_hook_signal_send ("irc_highlight", + WEECHAT_HOOK_SIGNAL_STRING, + argv_eol[0]); + } + } + else + { + if (host && host[0]) + { + weechat_printf_tags (server->buffer, + "irc_notice", + "%s%s%s %s(%s%s%s)%s: %s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + host, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_args); } else { - if (host && host[0]) + if (nick && nick[0]) { - weechat_printf (server->buffer, - "%s%s%s %s(%s%s%s)%s: %s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - host, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - pos_args); + weechat_printf_tags (server->buffer, + "irc_notice", + "%s%s%s%s: %s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos_args); } else { - if (nick && nick[0]) - { - weechat_printf (server->buffer, - "%s%s%s%s: %s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT, - pos_args); - } - else - { - weechat_printf (server->buffer, - "%s%s", - weechat_prefix ("network"), - pos_args); - } + weechat_printf_tags (server->buffer, + "irc_notice", + "%s%s", + weechat_prefix ("network"), + pos_args); } } + } - if (nick - && (weechat_strcasecmp (nick, "nickserv") != 0) - && (weechat_strcasecmp (nick, "chanserv") != 0) - && (weechat_strcasecmp (nick, "memoserv") != 0)) - { - weechat_buffer_set (server->buffer, "hotlist", - WEECHAT_HOTLIST_PRIVATE); - } + if (nick + && (weechat_strcasecmp (nick, "nickserv") != 0) + && (weechat_strcasecmp (nick, "chanserv") != 0) + && (weechat_strcasecmp (nick, "memoserv") != 0)) + { + weechat_buffer_set (server->buffer, "hotlist", + WEECHAT_HOTLIST_PRIVATE); } } } @@ -1058,7 +1084,7 @@ irc_protocol_cmd_notice (struct t_irc_server *server, char *command, int irc_protocol_cmd_part (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *nick, *host, *pos_comment, *join_string; int join_length; @@ -1088,42 +1114,43 @@ irc_protocol_cmd_part (struct t_irc_server *server, char *command, if (ptr_nick) { /* display part message */ - if (!ignore) + if (pos_comment) { - if (pos_comment) - { - weechat_printf (ptr_channel->buffer, - _("%s%s%s %s(%s%s%s)%s has left %s%s %s(%s%s%s)"), - weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - host, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_CHANNEL, - ptr_channel->name, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - pos_comment, - IRC_COLOR_CHAT_DELIMITERS); - } - else - { - weechat_printf (ptr_channel->buffer, - _("%s%s%s %s(%s%s%s)%s has left %s%s"), - weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - host, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_CHANNEL, - ptr_channel->name); - } + weechat_printf_tags (ptr_channel->buffer, + "irc_part", + _("%s%s%s %s(%s%s%s)%s has left %s%s " + "%s(%s%s%s)"), + weechat_prefix ("quit"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + host, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + ptr_channel->name, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_comment, + IRC_COLOR_CHAT_DELIMITERS); + } + else + { + weechat_printf_tags (ptr_channel->buffer, + "irc_part", + _("%s%s%s %s(%s%s%s)%s has left " + "%s%s"), + weechat_prefix ("quit"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + host, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + ptr_channel->name); } /* part request was issued by local client ? */ @@ -1177,7 +1204,7 @@ irc_protocol_cmd_part (struct t_irc_server *server, char *command, int irc_protocol_cmd_ping (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* PING message looks like: PING :server @@ -1187,7 +1214,6 @@ irc_protocol_cmd_ping (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) argv_eol; - (void) ignore; (void) highlight; irc_server_sendf (server, "PONG :%s", @@ -1203,7 +1229,7 @@ irc_protocol_cmd_ping (struct t_irc_server *server, char *command, int irc_protocol_cmd_pong (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { struct timeval tv; int old_lag; @@ -1213,7 +1239,6 @@ irc_protocol_cmd_pong (struct t_irc_server *server, char *command, (void) argc; (void) argv; (void) argv_eol; - (void) ignore; (void) highlight; if (server->lag_check_time.tv_sec != 0) @@ -1243,62 +1268,59 @@ irc_protocol_cmd_pong (struct t_irc_server *server, char *command, void irc_protocol_reply_version (struct t_irc_server *server, struct t_irc_channel *channel, char *nick, - char *message, char *str_version, int ignore) + char *message, char *str_version) { char *pos, *version, *date; struct t_gui_buffer *ptr_buffer; ptr_buffer = (channel) ? channel->buffer : server->buffer; - if (!ignore) + pos = strchr (str_version, ' '); + if (pos) + { + while (pos[0] == ' ') + pos++; + if (pos[0] == '\01') + pos = NULL; + else if (!pos[0]) + pos = NULL; + } + + version = weechat_info_get ("version"); + date = weechat_info_get ("date"); + if (version && date) { - pos = strchr (str_version, ' '); + irc_server_sendf (server, + "NOTICE %s :%sVERSION WeeChat %s (%s)%s", + nick, "\01", version, date, "\01"); + if (pos) { - while (pos[0] == ' ') - pos++; - if (pos[0] == '\01') - pos = NULL; - else if (!pos[0]) - pos = NULL; + weechat_printf (ptr_buffer, + _("%sCTCP %sVERSION%s received from %s%s%s: " + "%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos); } - - version = weechat_info_get ("version"); - date = weechat_info_get ("date"); - if (version && date) + else { - irc_server_sendf (server, - "NOTICE %s :%sVERSION WeeChat %s (%s)%s", - nick, "\01", version, date, "\01"); - - if (pos) - { - weechat_printf (ptr_buffer, - _("%sCTCP %sVERSION%s received from %s%s%s: " - "%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT, - pos); - } - else - { - weechat_printf (ptr_buffer, - _("%sCTCP %sVERSION%s received from %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - nick); - } + weechat_printf (ptr_buffer, + _("%sCTCP %sVERSION%s received from %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick); } - weechat_hook_signal_send ("irc_ctcp", - WEECHAT_HOOK_SIGNAL_STRING, - message); } + weechat_hook_signal_send ("irc_ctcp", + WEECHAT_HOOK_SIGNAL_STRING, + message); } /* @@ -1308,7 +1330,7 @@ irc_protocol_reply_version (struct t_irc_server *server, int irc_protocol_cmd_privmsg (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *nick, *host, *pos_args, *pos_end_01, *pos, *pos_message; char *dcc_args, *pos_file, *pos_addr, *pos_port, *pos_size, *pos_start_resume; /* for DCC */ @@ -1343,74 +1365,73 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *command, { if (strncmp (pos_args, "\01ACTION ", 8) == 0) { - if (!ignore) + pos_args += 8; + pos_end_01 = strchr (pos_args, '\01'); + if (pos_end_01) + pos_end_01[0] = '\0'; + + if (highlight + || irc_protocol_is_highlight (pos_args, server->nick)) { - pos_args += 8; - pos_end_01 = strchr (pos_args, '\01'); - if (pos_end_01) - pos_end_01[0] = '\0'; - - if (highlight - || irc_protocol_is_highlight (pos_args, server->nick)) - { - weechat_printf (ptr_channel->buffer, - "%s%s%s %s%s", - weechat_prefix ("action"), - IRC_COLOR_CHAT_HIGHLIGHT, - nick, - IRC_COLOR_CHAT, - pos_args); - if ((look_infobar_delay_highlight > 0) - && (ptr_channel->buffer != weechat_current_buffer)) - weechat_infobar_printf (look_infobar_delay_highlight, - "color_infobar_highlight", - _("Channel %s: * %s %s"), - ptr_channel->name, - nick, - pos_args); - weechat_hook_signal_send ("irc_highlight", - WEECHAT_HOOK_SIGNAL_STRING, - argv_eol[0]); - } - else - { - weechat_printf (ptr_channel->buffer, - "%s%s%s %s%s", - weechat_prefix ("action"), - IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT, - pos_args); - } - irc_channel_add_nick_speaking (ptr_channel, nick); - - if (pos_end_01) - pos_end_01[0] = '\01'; + weechat_printf_tags (ptr_channel->buffer, + "irc_privmsg,irc_action", + "%s%s%s %s%s", + weechat_prefix ("action"), + IRC_COLOR_CHAT_HIGHLIGHT, + nick, + IRC_COLOR_CHAT, + pos_args); + if ((look_infobar_delay_highlight > 0) + && (ptr_channel->buffer != weechat_current_buffer)) + weechat_infobar_printf (look_infobar_delay_highlight, + "color_infobar_highlight", + _("Channel %s: * %s %s"), + ptr_channel->name, + nick, + pos_args); + weechat_hook_signal_send ("irc_highlight", + WEECHAT_HOOK_SIGNAL_STRING, + argv_eol[0]); + } + else + { + weechat_printf_tags (ptr_channel->buffer, + "irc_privmsg,irc_action", + "%s%s%s %s%s", + weechat_prefix ("action"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos_args); } + irc_channel_add_nick_speaking (ptr_channel, nick); + + if (pos_end_01) + pos_end_01[0] = '\01'; + return WEECHAT_RC_OK; } if (strncmp (pos_args, "\01SOUND ", 7) == 0) { - if (!ignore) - { - pos_args += 7; - pos_end_01 = strchr (pos_args, '\01'); - if (pos_end_01) - pos_end_01[0] = '\0'; + pos_args += 7; + pos_end_01 = strchr (pos_args, '\01'); + if (pos_end_01) + pos_end_01[0] = '\0'; - weechat_printf (ptr_channel->buffer, - _("%sReceived a CTCP %sSOUND%s \"%s\" " - "from %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - IRC_COLOR_CHAT, - pos_args, - IRC_COLOR_CHAT_NICK, - nick); + weechat_printf_tags (ptr_channel->buffer, + "irc_privmsg,irc_ctcp", + _("%sReceived a CTCP %sSOUND%s \"%s\" " + "from %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + IRC_COLOR_CHAT, + pos_args, + IRC_COLOR_CHAT_NICK, + nick); - if (pos_end_01) - pos_end_01[0] = '\01'; - } + if (pos_end_01) + pos_end_01[0] = '\01'; + return WEECHAT_RC_OK; } if (strncmp (pos_args, "\01PING", 5) == 0) @@ -1431,24 +1452,24 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *command, else irc_server_sendf (server, "NOTICE %s :\01PING\01", nick); - weechat_printf (ptr_channel->buffer, - _("%sCTCP %sPING%s received from %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - nick); + weechat_printf_tags (ptr_channel->buffer, + "irc_privmsg,irc_ctcp", + _("%sCTCP %sPING%s received from %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick); if (pos_end_01) pos_end_01[0] = '\01'; + return WEECHAT_RC_OK; } if (strncmp (pos_args, "\01VERSION", 8) == 0) { - if (!ignore) - { - irc_protocol_reply_version (server, ptr_channel, nick, - argv_eol[0], pos_args, ignore); - } + irc_protocol_reply_version (server, ptr_channel, nick, + argv_eol[0], pos_args); + return WEECHAT_RC_OK; } @@ -1457,103 +1478,102 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *command, if ((pos_args[0] == '\01') && pos_end_01 && (pos_end_01[1] == '\0')) { - if (!ignore) + pos_args++; + pos_end_01[0] = '\0'; + pos = strchr (pos_args, ' '); + if (pos) { - pos_args++; - pos_end_01[0] = '\0'; - pos = strchr (pos_args, ' '); - if (pos) + pos[0] = '\0'; + pos_message = pos + 1; + while (pos_message[0] == ' ') { - pos[0] = '\0'; - pos_message = pos + 1; - while (pos_message[0] == ' ') - { - pos_message++; - } - if (!pos_message[0]) - pos_message = NULL; + pos_message++; } - else + if (!pos_message[0]) pos_message = NULL; + } + else + pos_message = NULL; - if (pos_message) - { - weechat_printf (ptr_channel->buffer, - _("%sUnknown CTCP %s%s%s received " - "from %s%s%s: %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - pos_args, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT, - pos_message); - } - else - { - weechat_printf (ptr_channel->buffer, - _("%sUnknown CTCP %s%s%s " - "received from %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - pos_args, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - nick); - } - if (pos_end_01) - pos_end_01[0] = '\01'; - if (pos) - pos[0] = ' '; - - weechat_hook_signal_send ("irc_ctcp", - WEECHAT_HOOK_SIGNAL_STRING, - argv_eol[0]); + if (pos_message) + { + weechat_printf_tags (ptr_channel->buffer, + "irc_privmsg,irc_ctcp", + _("%sUnknown CTCP %s%s%s " + "received from %s%s%s: %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + pos_args, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos_message); + } + else + { + weechat_printf_tags (ptr_channel->buffer, + "irc_privmsg,irc_ctcp", + _("%sUnknown CTCP %s%s%s " + "received from %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + pos_args, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick); } + if (pos_end_01) + pos_end_01[0] = '\01'; + if (pos) + pos[0] = ' '; + + weechat_hook_signal_send ("irc_ctcp", + WEECHAT_HOOK_SIGNAL_STRING, + argv_eol[0]); + return WEECHAT_RC_OK; } /* other message */ - if (!ignore) + ptr_nick = irc_nick_search (ptr_channel, nick); + if (highlight + || irc_protocol_is_highlight (pos_args, server->nick)) { - ptr_nick = irc_nick_search (ptr_channel, nick); - if (highlight - || irc_protocol_is_highlight (pos_args, server->nick)) - { - weechat_printf (ptr_channel->buffer, - "%s%s", - irc_nick_as_prefix (ptr_nick, - (ptr_nick) ? NULL : nick, - IRC_COLOR_CHAT_HIGHLIGHT), - pos_args); - if ((look_infobar_delay_highlight > 0) - && (ptr_channel->buffer != weechat_current_buffer)) - weechat_infobar_printf (look_infobar_delay_highlight, - "color_infobar_highlight", - _("Channel %s: %s> %s"), - ptr_channel->name, - nick, - pos_args); - weechat_buffer_set (ptr_channel->buffer, "hotlist", - WEECHAT_HOTLIST_HIGHLIGHT); - weechat_hook_signal_send ("irc_highlight", - WEECHAT_HOOK_SIGNAL_STRING, - argv_eol[0]); - } - else - { - weechat_printf (ptr_channel->buffer, - "%s%s", - irc_nick_as_prefix (ptr_nick, - (ptr_nick) ? NULL : nick, - NULL), - pos_args); - weechat_buffer_set (ptr_channel->buffer, "hotlist", - WEECHAT_HOTLIST_MESSAGE); - } - irc_channel_add_nick_speaking (ptr_channel, nick); + weechat_printf_tags (ptr_channel->buffer, + "irc_privmsg", + "%s%s", + irc_nick_as_prefix (ptr_nick, + (ptr_nick) ? NULL : nick, + IRC_COLOR_CHAT_HIGHLIGHT), + pos_args); + if ((look_infobar_delay_highlight > 0) + && (ptr_channel->buffer != weechat_current_buffer)) + weechat_infobar_printf (look_infobar_delay_highlight, + "color_infobar_highlight", + _("Channel %s: %s> %s"), + ptr_channel->name, + nick, + pos_args); + weechat_buffer_set (ptr_channel->buffer, "hotlist", + WEECHAT_HOTLIST_HIGHLIGHT); + weechat_hook_signal_send ("irc_highlight", + WEECHAT_HOOK_SIGNAL_STRING, + argv_eol[0]); } + else + { + weechat_printf_tags (ptr_channel->buffer, + "irc_privmsg", + "%s%s", + irc_nick_as_prefix (ptr_nick, + (ptr_nick) ? NULL : nick, + NULL), + pos_args); + weechat_buffer_set (ptr_channel->buffer, "hotlist", + WEECHAT_HOTLIST_MESSAGE); + } + irc_channel_add_nick_speaking (ptr_channel, nick); } else { @@ -1570,436 +1590,425 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *command, /* version asked by another user => answer with WeeChat version */ if (strncmp (pos_args, "\01VERSION", 8) == 0) { - if (!ignore) - { - irc_protocol_reply_version (server, NULL, nick, argv_eol[0], - pos_args, ignore); - } + irc_protocol_reply_version (server, NULL, nick, argv_eol[0], + pos_args); + return WEECHAT_RC_OK; } /* ping request from another user => answer */ if (strncmp (pos_args, "\01PING", 5) == 0) { - if (!ignore) + pos_args += 5; + while (pos_args[0] == ' ') { - pos_args += 5; - while (pos_args[0] == ' ') - { - pos_args++; - } - pos_end_01 = strchr (pos, '\01'); - if (pos_end_01) - pos_end_01[0] = '\0'; - else - pos_args = NULL; - if (pos_args && !pos_args[0]) - pos_args = NULL; - if (pos_args) - irc_server_sendf (server, "NOTICE %s :\01PING %s\01", - nick, pos_args); - else - irc_server_sendf (server, "NOTICE %s :\01PING\01", - nick); - weechat_printf (server->buffer, - _("%sCTCP %sPING%s received from %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - nick); - weechat_hook_signal_send ("irc_ctcp", - WEECHAT_HOOK_SIGNAL_STRING, - argv_eol[0]); - if (pos_end_01) - pos_end_01[0] = '\01'; + pos_args++; } + pos_end_01 = strchr (pos, '\01'); + if (pos_end_01) + pos_end_01[0] = '\0'; + else + pos_args = NULL; + if (pos_args && !pos_args[0]) + pos_args = NULL; + if (pos_args) + irc_server_sendf (server, "NOTICE %s :\01PING %s\01", + nick, pos_args); + else + irc_server_sendf (server, "NOTICE %s :\01PING\01", + nick); + weechat_printf_tags (server->buffer, + "irc_privmsg,irc_ctcp", + _("%sCTCP %sPING%s received from %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick); + weechat_hook_signal_send ("irc_ctcp", + WEECHAT_HOOK_SIGNAL_STRING, + argv_eol[0]); + if (pos_end_01) + pos_end_01[0] = '\01'; + return WEECHAT_RC_OK; } - + /* incoming DCC file */ if (strncmp (pos_args, "\01DCC SEND", 9) == 0) { - if (!ignore) + /* check if DCC SEND is ok, i.e. with 0x01 at end */ + pos_end_01 = strchr (pos_args + 1, '\01'); + if (!pos_end_01) { - /* check if DCC SEND is ok, i.e. with 0x01 at end */ - pos_end_01 = strchr (pos_args + 1, '\01'); - if (!pos_end_01) - { - weechat_printf (server->buffer, - _("%s%s: cannot parse \"%s\" command"), - weechat_prefix ("error"), "irc", - "privmsg"); - return WEECHAT_RC_ERROR; - } + weechat_printf (server->buffer, + _("%s%s: cannot parse \"%s\" command"), + weechat_prefix ("error"), "irc", + "privmsg"); + return WEECHAT_RC_ERROR; + } - pos_end_01[0] = '\0'; - dcc_args = strdup (pos_args + 9); - pos_end_01[0] = '\01'; + pos_end_01[0] = '\0'; + dcc_args = strdup (pos_args + 9); + pos_end_01[0] = '\01'; - if (!dcc_args) - { - weechat_printf (server->buffer, - _("%s%s: not enough memory for \"%s\" " - "command"), - weechat_prefix ("error"), "irc", - "privmsg"); - return WEECHAT_RC_ERROR; - } + if (!dcc_args) + { + weechat_printf (server->buffer, + _("%s%s: not enough memory for \"%s\" " + "command"), + weechat_prefix ("error"), "irc", + "privmsg"); + return WEECHAT_RC_ERROR; + } - /* DCC filename */ - pos_file = dcc_args; - while (pos_file[0] == ' ') - { - pos_file++; - } + /* DCC filename */ + pos_file = dcc_args; + while (pos_file[0] == ' ') + { + pos_file++; + } - /* look for file size */ - pos_size = strrchr (pos_file, ' '); - if (!pos_size) - { - weechat_printf (server->buffer, - _("%s%s: cannot parse \"%s\" command"), - weechat_prefix ("error"), "irc", - "privmsg"); - free (dcc_args); - return WEECHAT_RC_ERROR; - } - pos = pos_size; - pos_size++; - while (pos[0] == ' ') - { - pos--; - } - pos[1] = '\0'; + /* look for file size */ + pos_size = strrchr (pos_file, ' '); + if (!pos_size) + { + weechat_printf (server->buffer, + _("%s%s: cannot parse \"%s\" command"), + weechat_prefix ("error"), "irc", + "privmsg"); + free (dcc_args); + return WEECHAT_RC_ERROR; + } + pos = pos_size; + pos_size++; + while (pos[0] == ' ') + { + pos--; + } + pos[1] = '\0'; - /* look for DCC port */ - pos_port = strrchr (pos_file, ' '); - if (!pos_port) - { - weechat_printf (server->buffer, - _("%s%s: cannot parse \"%s\" command"), - weechat_prefix ("error"), "irc", - "privmsg"); - free (dcc_args); - return WEECHAT_RC_ERROR; - } - pos = pos_port; - pos_port++; - while (pos[0] == ' ') - { - pos--; - } - pos[1] = '\0'; + /* look for DCC port */ + pos_port = strrchr (pos_file, ' '); + if (!pos_port) + { + weechat_printf (server->buffer, + _("%s%s: cannot parse \"%s\" command"), + weechat_prefix ("error"), "irc", + "privmsg"); + free (dcc_args); + return WEECHAT_RC_ERROR; + } + pos = pos_port; + pos_port++; + while (pos[0] == ' ') + { + pos--; + } + pos[1] = '\0'; - /* look for DCC IP address */ - pos_addr = strrchr (pos_file, ' '); - if (!pos_addr) - { - weechat_printf (server->buffer, - _("%s%s: cannot parse \"%s\" command"), - weechat_prefix ("error"), "irc", - "privmsg"); - free (dcc_args); - return WEECHAT_RC_ERROR; - } - pos = pos_addr; - pos_addr++; - while (pos[0] == ' ') - { - pos--; - } - pos[1] = '\0'; + /* look for DCC IP address */ + pos_addr = strrchr (pos_file, ' '); + if (!pos_addr) + { + weechat_printf (server->buffer, + _("%s%s: cannot parse \"%s\" command"), + weechat_prefix ("error"), "irc", + "privmsg"); + free (dcc_args); + return WEECHAT_RC_ERROR; + } + pos = pos_addr; + pos_addr++; + while (pos[0] == ' ') + { + pos--; + } + pos[1] = '\0'; - /* TODO: add DCC file */ - //irc_dcc_add (server, IRC_DCC_FILE_RECV, - // strtoul (pos_addr, NULL, 10), - // atoi (pos_port), nick, -1, pos_file, NULL, - // strtoul (pos_size, NULL, 10)); + /* TODO: add DCC file */ + //irc_dcc_add (server, IRC_DCC_FILE_RECV, + // strtoul (pos_addr, NULL, 10), + // atoi (pos_port), nick, -1, pos_file, NULL, + // strtoul (pos_size, NULL, 10)); - weechat_hook_signal_send ("irc_dcc", - WEECHAT_HOOK_SIGNAL_STRING, - argv_eol[0]); + weechat_hook_signal_send ("irc_dcc", + WEECHAT_HOOK_SIGNAL_STRING, + argv_eol[0]); - free (dcc_args); - } + free (dcc_args); + return WEECHAT_RC_OK; } /* incoming DCC RESUME (asked by receiver) */ if (strncmp (pos_args, "\01DCC RESUME", 11) == 0) { - if (!ignore) + /* check if DCC RESUME is ok, i.e. with 0x01 at end */ + pos_end_01 = strchr (pos_args + 1, '\01'); + if (!pos_end_01) { - /* check if DCC RESUME is ok, i.e. with 0x01 at end */ - pos_end_01 = strchr (pos_args + 1, '\01'); - if (!pos_end_01) - { - weechat_printf (server->buffer, - _("%s%s: cannot parse \"%s\" command"), - weechat_prefix ("error"), "irc", - "privmsg"); - return WEECHAT_RC_ERROR; - } + weechat_printf (server->buffer, + _("%s%s: cannot parse \"%s\" command"), + weechat_prefix ("error"), "irc", + "privmsg"); + return WEECHAT_RC_ERROR; + } - pos_end_01[0] = '\0'; - dcc_args = strdup (pos_args + 11); - pos_end_01[0] = '\01'; + pos_end_01[0] = '\0'; + dcc_args = strdup (pos_args + 11); + pos_end_01[0] = '\01'; - if (!dcc_args) - { - weechat_printf (server->buffer, - _("%s%s: not enough memory for \"%s\" " - "command"), - weechat_prefix ("error"), "irc", - "privmsg"); - return WEECHAT_RC_ERROR; - } + if (!dcc_args) + { + weechat_printf (server->buffer, + _("%s%s: not enough memory for \"%s\" " + "command"), + weechat_prefix ("error"), "irc", + "privmsg"); + return WEECHAT_RC_ERROR; + } - /* DCC filename */ - pos_file = dcc_args; - while (pos_file[0] == ' ') - { - pos_file++; - } + /* DCC filename */ + pos_file = dcc_args; + while (pos_file[0] == ' ') + { + pos_file++; + } - /* look for resume start position */ - pos_start_resume = strrchr (pos_file, ' '); - if (!pos_start_resume) - { - weechat_printf (server->buffer, - _("%s%s: cannot parse \"%s\" command"), - weechat_prefix ("error"), "irc", - "privmsg"); - free (dcc_args); - return WEECHAT_RC_ERROR; - } - pos = pos_start_resume; - pos_start_resume++; - while (pos[0] == ' ') - { - pos--; - } - pos[1] = '\0'; + /* look for resume start position */ + pos_start_resume = strrchr (pos_file, ' '); + if (!pos_start_resume) + { + weechat_printf (server->buffer, + _("%s%s: cannot parse \"%s\" command"), + weechat_prefix ("error"), "irc", + "privmsg"); + free (dcc_args); + return WEECHAT_RC_ERROR; + } + pos = pos_start_resume; + pos_start_resume++; + while (pos[0] == ' ') + { + pos--; + } + pos[1] = '\0'; - /* look for DCC port */ - pos_port = strrchr (pos_file, ' '); - if (!pos_port) - { - weechat_printf (server->buffer, - _("%s%s: cannot parse \"%s\" command"), - weechat_prefix ("error"), "irc", - "privmsg"); - free (dcc_args); - return WEECHAT_RC_ERROR; - } - pos = pos_port; - pos_port++; - while (pos[0] == ' ') - { - pos--; - } - pos[1] = '\0'; + /* look for DCC port */ + pos_port = strrchr (pos_file, ' '); + if (!pos_port) + { + weechat_printf (server->buffer, + _("%s%s: cannot parse \"%s\" command"), + weechat_prefix ("error"), "irc", + "privmsg"); + free (dcc_args); + return WEECHAT_RC_ERROR; + } + pos = pos_port; + pos_port++; + while (pos[0] == ' ') + { + pos--; + } + pos[1] = '\0'; - /* TODO: accept DCC resume */ - //irc_dcc_accept_resume (server, pos_file, atoi (pos_port), - // strtoul (pos_start_resume, NULL, 10)); + /* TODO: accept DCC resume */ + //irc_dcc_accept_resume (server, pos_file, atoi (pos_port), + // strtoul (pos_start_resume, NULL, 10)); - weechat_hook_signal_send ("irc_dcc", - WEECHAT_HOOK_SIGNAL_STRING, - argv_eol[0]); + weechat_hook_signal_send ("irc_dcc", + WEECHAT_HOOK_SIGNAL_STRING, + argv_eol[0]); - free (dcc_args); - } + free (dcc_args); + return WEECHAT_RC_OK; } /* incoming DCC ACCEPT (resume accepted by sender) */ if (strncmp (pos, "\01DCC ACCEPT", 11) == 0) { - if (!ignore) + /* check if DCC ACCEPT is ok, i.e. with 0x01 at end */ + pos_end_01 = strchr (pos_args + 1, '\01'); + if (!pos_end_01) { - /* check if DCC ACCEPT is ok, i.e. with 0x01 at end */ - pos_end_01 = strchr (pos_args + 1, '\01'); - if (!pos_end_01) - { - weechat_printf (server->buffer, - _("%s%s: cannot parse \"%s\" command"), - weechat_prefix ("error"), "irc", - "privmsg"); - return WEECHAT_RC_ERROR; - } + weechat_printf (server->buffer, + _("%s%s: cannot parse \"%s\" command"), + weechat_prefix ("error"), "irc", + "privmsg"); + return WEECHAT_RC_ERROR; + } - pos_end_01[0] = '\0'; - dcc_args = strdup (pos_args + 11); - pos_end_01[0] = '\01'; + pos_end_01[0] = '\0'; + dcc_args = strdup (pos_args + 11); + pos_end_01[0] = '\01'; - if (!dcc_args) - { - weechat_printf (server->buffer, - _("%s%s: not enough memory for \"%s\" " - "command"), - weechat_prefix ("error"), "irc", - "privmsg"); - return WEECHAT_RC_ERROR; - } + if (!dcc_args) + { + weechat_printf (server->buffer, + _("%s%s: not enough memory for \"%s\" " + "command"), + weechat_prefix ("error"), "irc", + "privmsg"); + return WEECHAT_RC_ERROR; + } - /* DCC filename */ - pos_file = dcc_args; - while (pos_file[0] == ' ') - { - pos_file++; - } + /* DCC filename */ + pos_file = dcc_args; + while (pos_file[0] == ' ') + { + pos_file++; + } - /* look for resume start position */ - pos_start_resume = strrchr (pos_file, ' '); - if (!pos_start_resume) - { - weechat_printf (server->buffer, - _("%s%s: cannot parse \"%s\" command"), - weechat_prefix ("error"), "irc", - "privmsg"); - free (dcc_args); - return WEECHAT_RC_ERROR; - } - pos = pos_start_resume; - pos_start_resume++; - while (pos[0] == ' ') - { - pos--; - } - pos[1] = '\0'; + /* look for resume start position */ + pos_start_resume = strrchr (pos_file, ' '); + if (!pos_start_resume) + { + weechat_printf (server->buffer, + _("%s%s: cannot parse \"%s\" command"), + weechat_prefix ("error"), "irc", + "privmsg"); + free (dcc_args); + return WEECHAT_RC_ERROR; + } + pos = pos_start_resume; + pos_start_resume++; + while (pos[0] == ' ') + { + pos--; + } + pos[1] = '\0'; - /* look for DCC port */ - pos_port = strrchr (pos_file, ' '); - if (!pos_port) - { - weechat_printf (server->buffer, - _("%s%s: cannot parse \"%s\" command"), - weechat_prefix ("error"), "irc", - "privmsg"); - free (dcc_args); - return WEECHAT_RC_ERROR; - } - pos = pos_port; - pos_port++; - while (pos[0] == ' ') - { - pos--; - } - pos[1] = '\0'; + /* look for DCC port */ + pos_port = strrchr (pos_file, ' '); + if (!pos_port) + { + weechat_printf (server->buffer, + _("%s%s: cannot parse \"%s\" command"), + weechat_prefix ("error"), "irc", + "privmsg"); + free (dcc_args); + return WEECHAT_RC_ERROR; + } + pos = pos_port; + pos_port++; + while (pos[0] == ' ') + { + pos--; + } + pos[1] = '\0'; - /* TODO: resume DCC */ - //irc_dcc_start_resume (server, pos_file, atoi (pos_port), - // strtoul (pos_start_resume, NULL, 10)); + /* TODO: resume DCC */ + //irc_dcc_start_resume (server, pos_file, atoi (pos_port), + // strtoul (pos_start_resume, NULL, 10)); - weechat_hook_signal_send ("irc_dcc", - WEECHAT_HOOK_SIGNAL_STRING, - argv_eol[0]); + weechat_hook_signal_send ("irc_dcc", + WEECHAT_HOOK_SIGNAL_STRING, + argv_eol[0]); - free (dcc_args); - } + free (dcc_args); + return WEECHAT_RC_OK; } /* incoming DCC CHAT */ if (strncmp (pos, "\01DCC CHAT", 9) == 0) { - if (!ignore) + /* check if DCC CHAT is ok, i.e. with 0x01 at end */ + pos_end_01 = strchr (pos_args + 1, '\01'); + if (!pos_end_01) { - /* check if DCC CHAT is ok, i.e. with 0x01 at end */ - pos_end_01 = strchr (pos_args + 1, '\01'); - if (!pos_end_01) - { - weechat_printf (server->buffer, - _("%s%s: cannot parse \"%s\" command"), - weechat_prefix ("error"), "irc", - "privmsg"); - return WEECHAT_RC_ERROR; - } + weechat_printf (server->buffer, + _("%s%s: cannot parse \"%s\" command"), + weechat_prefix ("error"), "irc", + "privmsg"); + return WEECHAT_RC_ERROR; + } - pos_end_01[0] = '\0'; - dcc_args = strdup (pos_args + 9); - pos_end_01[0] = '\01'; + pos_end_01[0] = '\0'; + dcc_args = strdup (pos_args + 9); + pos_end_01[0] = '\01'; - if (!dcc_args) - { - weechat_printf (server->buffer, - _("%s%s: not enough memory for \"%s\" " - "command"), - weechat_prefix ("error"), "irc", - "privmsg"); - return WEECHAT_RC_ERROR; - } + if (!dcc_args) + { + weechat_printf (server->buffer, + _("%s%s: not enough memory for \"%s\" " + "command"), + weechat_prefix ("error"), "irc", + "privmsg"); + return WEECHAT_RC_ERROR; + } - /* CHAT type */ - pos_file = dcc_args; - while (pos_file[0] == ' ') - { - pos_file++; - } + /* CHAT type */ + pos_file = dcc_args; + while (pos_file[0] == ' ') + { + pos_file++; + } - /* DCC IP address */ - pos_addr = strchr (pos_file, ' '); - if (!pos_addr) - { - weechat_printf (server->buffer, - _("%s%s: cannot parse \"%s\" command"), - weechat_prefix ("error"), "irc", - "privmsg"); - free (dcc_args); - return WEECHAT_RC_ERROR; - } - pos_addr[0] = '\0'; + /* DCC IP address */ + pos_addr = strchr (pos_file, ' '); + if (!pos_addr) + { + weechat_printf (server->buffer, + _("%s%s: cannot parse \"%s\" command"), + weechat_prefix ("error"), "irc", + "privmsg"); + free (dcc_args); + return WEECHAT_RC_ERROR; + } + pos_addr[0] = '\0'; + pos_addr++; + while (pos_addr[0] == ' ') + { pos_addr++; - while (pos_addr[0] == ' ') - { - pos_addr++; - } + } - /* look for DCC port */ - pos_port = strchr (pos_addr, ' '); - if (!pos_port) - { - weechat_printf (server->buffer, - _("%s%s: cannot parse \"%s\" command"), - weechat_prefix ("error"), "irc", - "privmsg"); - free (dcc_args); - return WEECHAT_RC_ERROR; - } - pos_port[0] = '\0'; + /* look for DCC port */ + pos_port = strchr (pos_addr, ' '); + if (!pos_port) + { + weechat_printf (server->buffer, + _("%s%s: cannot parse \"%s\" command"), + weechat_prefix ("error"), "irc", + "privmsg"); + free (dcc_args); + return WEECHAT_RC_ERROR; + } + pos_port[0] = '\0'; + pos_port++; + while (pos_port[0] == ' ') + { pos_port++; - while (pos_port[0] == ' ') - { - pos_port++; - } + } - if (weechat_strcasecmp (pos_file, "chat") != 0) - { - weechat_printf (server->buffer, - _("%s%s: unknown DCC CHAT type " - "received from %s%s%s: \"%s\""), - weechat_prefix ("error"), "irc", - IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT, - pos_file); - free (dcc_args); - return WEECHAT_RC_ERROR; - } + if (weechat_strcasecmp (pos_file, "chat") != 0) + { + weechat_printf (server->buffer, + _("%s%s: unknown DCC CHAT type " + "received from %s%s%s: \"%s\""), + weechat_prefix ("error"), "irc", + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos_file); + free (dcc_args); + return WEECHAT_RC_ERROR; + } - /* TODO: add DCC chat */ - //irc_dcc_add (server, IRC_DCC_CHAT_RECV, - // strtoul (pos_addr, NULL, 10), - // atoi (pos_port), nick, -1, NULL, NULL, 0); + /* TODO: add DCC chat */ + //irc_dcc_add (server, IRC_DCC_CHAT_RECV, + // strtoul (pos_addr, NULL, 10), + // atoi (pos_port), nick, -1, NULL, NULL, 0); - weechat_hook_signal_send ("irc_dcc", - WEECHAT_HOOK_SIGNAL_STRING, - argv_eol[0]); + weechat_hook_signal_send ("irc_dcc", + WEECHAT_HOOK_SIGNAL_STRING, + argv_eol[0]); - free (dcc_args); - } + free (dcc_args); + return WEECHAT_RC_OK; } @@ -2008,77 +2017,76 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *command, if (strncmp (pos, "\01ACTION ", 8) == 0) { - if (!ignore) + if (!ptr_channel) { + ptr_channel = irc_channel_new (server, + IRC_CHANNEL_TYPE_PRIVATE, + nick, 0); if (!ptr_channel) { - ptr_channel = irc_channel_new (server, - IRC_CHANNEL_TYPE_PRIVATE, - nick, 0); - if (!ptr_channel) - { - weechat_printf (server->buffer, - _("%s%s: cannot create new " - "private buffer \"%s\""), - weechat_prefix ("error"), "irc", - nick); - return WEECHAT_RC_ERROR; - } - } - if (!ptr_channel->topic) - { - ptr_channel->topic = strdup (host); - weechat_buffer_set (ptr_channel->buffer, - "title", ptr_channel->topic); + weechat_printf (server->buffer, + _("%s%s: cannot create new " + "private buffer \"%s\""), + weechat_prefix ("error"), "irc", + nick); + return WEECHAT_RC_ERROR; } + } + if (!ptr_channel->topic) + { + ptr_channel->topic = strdup (host); + weechat_buffer_set (ptr_channel->buffer, + "title", ptr_channel->topic); + } - pos_args += 8; - pos_end_01 = strchr (pos, '\01'); - if (pos_end_01) - pos_end_01[0] = '\0'; - if (highlight - || irc_protocol_is_highlight (pos_args, server->nick)) - { - weechat_printf (ptr_channel->buffer, - "%s%s%s %s%s", - weechat_prefix ("action"), - IRC_COLOR_CHAT_HIGHLIGHT, - nick, - IRC_COLOR_CHAT, - pos_args); - if ((look_infobar_delay_highlight > 0) - && (ptr_channel->buffer != weechat_current_buffer)) - { - weechat_infobar_printf (look_infobar_delay_highlight, - "look_infobar_highlight", - _("Channel %s: * %s %s"), - ptr_channel->name, - nick, pos); - } - weechat_hook_signal_send ("irc_highlight", - WEECHAT_HOOK_SIGNAL_STRING, - argv_eol[0]); - weechat_buffer_set (ptr_channel->buffer, "hotlist", - WEECHAT_HOTLIST_HIGHLIGHT); - } - else + pos_args += 8; + pos_end_01 = strchr (pos, '\01'); + if (pos_end_01) + pos_end_01[0] = '\0'; + if (highlight + || irc_protocol_is_highlight (pos_args, server->nick)) + { + weechat_printf_tags (ptr_channel->buffer, + "irc_privmsg,irc_action", + "%s%s%s %s%s", + weechat_prefix ("action"), + IRC_COLOR_CHAT_HIGHLIGHT, + nick, + IRC_COLOR_CHAT, + pos_args); + if ((look_infobar_delay_highlight > 0) + && (ptr_channel->buffer != weechat_current_buffer)) { - weechat_printf (ptr_channel->buffer, - "%s%s%s %s%s", - weechat_prefix ("action"), - IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT, - pos_args); - weechat_hook_signal_send ("irc_pv", - WEECHAT_HOOK_SIGNAL_STRING, - argv_eol[0]); - weechat_buffer_set (ptr_channel->buffer, "hotlist", - WEECHAT_HOTLIST_MESSAGE); + weechat_infobar_printf (look_infobar_delay_highlight, + "look_infobar_highlight", + _("Channel %s: * %s %s"), + ptr_channel->name, + nick, pos); } - if (pos_end_01) - pos_end_01[0] = '\01'; + weechat_hook_signal_send ("irc_highlight", + WEECHAT_HOOK_SIGNAL_STRING, + argv_eol[0]); + weechat_buffer_set (ptr_channel->buffer, "hotlist", + WEECHAT_HOTLIST_HIGHLIGHT); + } + else + { + weechat_printf_tags (ptr_channel->buffer, + "irc_privmsg,irc_action", + "%s%s%s %s%s", + weechat_prefix ("action"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos_args); + weechat_hook_signal_send ("irc_pv", + WEECHAT_HOOK_SIGNAL_STRING, + argv_eol[0]); + weechat_buffer_set (ptr_channel->buffer, "hotlist", + WEECHAT_HOTLIST_MESSAGE); } + if (pos_end_01) + pos_end_01[0] = '\01'; } else { @@ -2087,130 +2095,129 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *command, if ((pos_args[0] == '\01') && pos_end_01 && (pos_end_01[1] == '\0')) { - if (!ignore) + pos_args++; + pos_end_01[0] = '\0'; + pos = strchr (pos_args, ' '); + if (pos) { - pos_args++; - pos_end_01[0] = '\0'; - pos = strchr (pos_args, ' '); - if (pos) + pos[0] = '\0'; + pos_message = pos + 1; + while (pos_message[0] == ' ') { - pos[0] = '\0'; - pos_message = pos + 1; - while (pos_message[0] == ' ') - { - pos_message++; - } - if (!pos_message[0]) - pos_message = NULL; + pos_message++; } - else + if (!pos_message[0]) pos_message = NULL; + } + else + pos_message = NULL; - if (pos_message) - { - weechat_printf (server->buffer, - _("%sUnknown CTCP %s%s%s received " - "from %s%s%s: %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - pos_args, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT, - pos_message); - } - else - { - weechat_printf (server->buffer, - _("%sUnknown CTCP %s%s%s received " - "from %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - pos_args, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - nick); - } - if (pos_end_01) - pos_end_01[0] = '\01'; - if (pos) - pos[0] = ' '; - - weechat_hook_signal_send ("irc_ctcp", - WEECHAT_HOOK_SIGNAL_STRING, - argv_eol[0]); + if (pos_message) + { + weechat_printf_tags (server->buffer, + "irc_privmsg,irc_ctcp", + _("%sUnknown CTCP %s%s%s " + "received from %s%s%s: %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + pos_args, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT, + pos_message); } + else + { + weechat_printf_tags (server->buffer, + "irc_privmsg,irc_ctcp", + _("%sUnknown CTCP %s%s%s " + "received from %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + pos_args, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + nick); + } + if (pos_end_01) + pos_end_01[0] = '\01'; + if (pos) + pos[0] = ' '; + + weechat_hook_signal_send ("irc_ctcp", + WEECHAT_HOOK_SIGNAL_STRING, + argv_eol[0]); + return WEECHAT_RC_OK; } else { /* private message */ - if (!ignore) + if (!ptr_channel) { + ptr_channel = irc_channel_new (server, + IRC_CHANNEL_TYPE_PRIVATE, + nick, 0); if (!ptr_channel) { - ptr_channel = irc_channel_new (server, - IRC_CHANNEL_TYPE_PRIVATE, - nick, 0); - if (!ptr_channel) - { - weechat_printf (server->buffer, - _("%s%s: cannot create new " - "private buffer \"%s\""), - weechat_prefix ("error"), - "irc", nick); - return WEECHAT_RC_ERROR; - } + weechat_printf (server->buffer, + _("%s%s: cannot create new " + "private buffer \"%s\""), + weechat_prefix ("error"), + "irc", nick); + return WEECHAT_RC_ERROR; } - if (ptr_channel->topic) - free (ptr_channel->topic); - ptr_channel->topic = strdup (host); - weechat_buffer_set (ptr_channel->buffer, "title", - ptr_channel->topic); + } + if (ptr_channel->topic) + free (ptr_channel->topic); + ptr_channel->topic = strdup (host); + weechat_buffer_set (ptr_channel->buffer, "title", + ptr_channel->topic); - if (highlight - || irc_protocol_is_highlight (pos, server->nick)) - { - weechat_printf (ptr_channel->buffer, - "%s%s", - irc_nick_as_prefix (NULL, - nick, - IRC_COLOR_CHAT_HIGHLIGHT), - pos_args); - if ((look_infobar_delay_highlight > 0) - && (ptr_channel->buffer != weechat_current_buffer)) - weechat_infobar_printf (look_infobar_delay_highlight, - "color_infobar_highlight", - _("Private %s> %s"), - nick, pos_args); - highlight_displayed = 1; - } - else - { - weechat_printf (ptr_channel->buffer, - "%s%s", - irc_nick_as_prefix (NULL, - nick, - IRC_COLOR_CHAT_NICK_OTHER), - pos_args); - highlight_displayed = 0; - } + if (highlight + || irc_protocol_is_highlight (pos, server->nick)) + { + weechat_printf_tags (ptr_channel->buffer, + "irc_privmsg", + "%s%s", + irc_nick_as_prefix (NULL, + nick, + IRC_COLOR_CHAT_HIGHLIGHT), + pos_args); + if ((look_infobar_delay_highlight > 0) + && (ptr_channel->buffer != weechat_current_buffer)) + weechat_infobar_printf (look_infobar_delay_highlight, + "color_infobar_highlight", + _("Private %s> %s"), + nick, pos_args); + highlight_displayed = 1; + } + else + { + weechat_printf_tags (ptr_channel->buffer, + "irc_privmsg", + "%s%s", + irc_nick_as_prefix (NULL, + nick, + IRC_COLOR_CHAT_NICK_OTHER), + pos_args); + highlight_displayed = 0; + } - weechat_hook_signal_send ("irc_pv", + weechat_hook_signal_send ("irc_pv", + WEECHAT_HOOK_SIGNAL_STRING, + argv_eol[0]); + + if (highlight_displayed) + { + weechat_hook_signal_send ("irc_highlight", WEECHAT_HOOK_SIGNAL_STRING, argv_eol[0]); - - if (highlight_displayed) - { - weechat_hook_signal_send ("irc_highlight", - WEECHAT_HOOK_SIGNAL_STRING, - argv_eol[0]); - } - - weechat_buffer_set (ptr_channel->buffer, - "hotlist", WEECHAT_HOTLIST_PRIVATE); } + + weechat_buffer_set (ptr_channel->buffer, + "hotlist", WEECHAT_HOTLIST_PRIVATE); } } } @@ -2225,7 +2232,7 @@ irc_protocol_cmd_privmsg (struct t_irc_server *server, char *command, int irc_protocol_cmd_quit (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *nick, *host, *pos_comment; struct t_irc_channel *ptr_channel; @@ -2260,39 +2267,38 @@ irc_protocol_cmd_quit (struct t_irc_server *server, char *command, { if (ptr_nick) irc_nick_free (ptr_channel, ptr_nick); - if (!ignore) + if (pos_comment && pos_comment[0]) { - if (pos_comment && pos_comment[0]) - { - weechat_printf (ptr_channel->buffer, - _("%s%s%s %s(%s%s%s)%s has quit " - "%s(%s%s%s)"), - weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - host, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - pos_comment, - IRC_COLOR_CHAT_DELIMITERS); - } - else - { - weechat_printf (ptr_channel->buffer, - _("%s%s%s %s(%s%s%s)%s has quit"), - weechat_prefix ("quit"), - IRC_COLOR_CHAT_NICK, - nick, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - host, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT); - } + weechat_printf_tags (ptr_channel->buffer, + "irc_quit", + _("%s%s%s %s(%s%s%s)%s has quit " + "%s(%s%s%s)"), + weechat_prefix ("quit"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + host, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_comment, + IRC_COLOR_CHAT_DELIMITERS); + } + else + { + weechat_printf_tags (ptr_channel->buffer, + "irc_quit", + _("%s%s%s %s(%s%s%s)%s has quit"), + weechat_prefix ("quit"), + IRC_COLOR_CHAT_NICK, + nick, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + host, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT); } } } @@ -2308,55 +2314,34 @@ irc_protocol_cmd_quit (struct t_irc_server *server, char *command, int irc_protocol_cmd_server_mode_reason (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { - char *pos_args, *ptr_msg, *ptr_msg2; + char *pos_mode, *pos_args; IRC_PROTOCOL_MIN_ARGS(3); /* make C compiler happy */ - (void) argv; (void) highlight; - if (!ignore) + /* skip nickname if at beginning of server message */ + if (strcmp (server->nick, argv[2]) == 0) { - /* skip nickname if at beginning of server message */ - pos_args = argv_eol[2]; - if (strncmp (server->nick, pos_args, strlen (server->nick)) == 0) - { - pos_args += strlen (server->nick) + 1; - while (pos_args[0] == ' ') - { - pos_args++; - } - } - - ptr_msg = strchr (pos_args, ' '); - ptr_msg2 = NULL; - if (ptr_msg) - { - ptr_msg[0] = '\0'; - ptr_msg2 = ptr_msg + 1; - while (ptr_msg2[0] == ' ') - { - ptr_msg2++; - } - if (ptr_msg2[0] == ':') - { - ptr_msg2++; - } - } - - weechat_printf (server->buffer, - "%s%s: %s", - weechat_prefix ("network"), - pos_args, - (ptr_msg2) ? ptr_msg2 : ""); - - if (ptr_msg) - ptr_msg[0] = ' '; + pos_mode = argv[3]; + pos_args = (argc > 4) ? ((argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]) : NULL; + } + else + { + pos_mode = argv[2]; + pos_args = (argc > 3) ? ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL; } + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + "%s%s: %s", + weechat_prefix ("network"), + pos_mode, + (pos_args) ? pos_args : ""); + return WEECHAT_RC_OK; } @@ -2367,7 +2352,7 @@ irc_protocol_cmd_server_mode_reason (struct t_irc_server *server, char *command, int irc_protocol_cmd_numeric (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_args; @@ -2377,24 +2362,22 @@ irc_protocol_cmd_numeric (struct t_irc_server *server, char *command, (void) argv; (void) highlight; - if (!ignore) + if (weechat_strcasecmp (server->nick, argv[2]) == 0) { - if (weechat_strcasecmp (server->nick, argv[2]) == 0) - { - pos_args = (argc > 3) ? - ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL; - } - else - { - pos_args = (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2]; - } - - weechat_printf (server->buffer, - "%s%s", - weechat_prefix ("network"), - pos_args); + pos_args = (argc > 3) ? + ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL; + } + else + { + pos_args = (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2]; } + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + "%s%s", + weechat_prefix ("network"), + pos_args); + return WEECHAT_RC_OK; } @@ -2405,7 +2388,7 @@ irc_protocol_cmd_numeric (struct t_irc_server *server, char *command, int irc_protocol_cmd_topic (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_topic; struct t_irc_channel *ptr_channel; @@ -2434,34 +2417,33 @@ irc_protocol_cmd_topic (struct t_irc_server *server, char *command, ptr_channel = irc_channel_search (server, argv[2]); buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer; - if (!ignore) + if (pos_topic && pos_topic[0]) { - if (pos_topic && pos_topic[0]) - { - weechat_printf (buffer, - _("%s%s%s%s has changed topic for %s%s%s to: " - "\"%s%s\""), - weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, - irc_protocol_get_nick_from_host (argv[0]), - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_CHANNEL, - argv[2], - IRC_COLOR_CHAT, - pos_topic, - IRC_COLOR_CHAT); - } - else - { - weechat_printf (buffer, - _("%s%s%s%s has unset topic for %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, - irc_protocol_get_nick_from_host (argv[0]), - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_CHANNEL, - argv[2]); - } + weechat_printf_tags (buffer, + "irc_topic", + _("%s%s%s%s has changed topic for %s%s%s to: " + "\"%s%s\""), + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK, + irc_protocol_get_nick_from_host (argv[0]), + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + argv[2], + IRC_COLOR_CHAT, + pos_topic, + IRC_COLOR_CHAT); + } + else + { + weechat_printf_tags (buffer, + "irc_topic", + _("%s%s%s%s has unset topic for %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK, + irc_protocol_get_nick_from_host (argv[0]), + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + argv[2]); } if (ptr_channel) @@ -2485,7 +2467,7 @@ irc_protocol_cmd_topic (struct t_irc_server *server, char *command, int irc_protocol_cmd_wallops (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* WALLOPS message looks like: :nick!user@host WALLOPS :message from admin @@ -2496,20 +2478,18 @@ irc_protocol_cmd_wallops (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) highlight; - if (!ignore) - { - weechat_printf (server->buffer, - _("%sWallops from %s%s %s(%s%s%s)%s: %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, - irc_protocol_get_nick_from_host (argv[0]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - irc_protocol_get_address_from_host (argv[0]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2]); - } + weechat_printf_tags (server->buffer, + "irc_wallops", + _("%sWallops from %s%s %s(%s%s%s)%s: %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK, + irc_protocol_get_nick_from_host (argv[0]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + irc_protocol_get_address_from_host (argv[0]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + (argv_eol[2][0] == ':') ? argv_eol[2] + 1 : argv_eol[2]); return WEECHAT_RC_OK; } @@ -2521,7 +2501,7 @@ irc_protocol_cmd_wallops (struct t_irc_server *server, char *command, int irc_protocol_cmd_001 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char **commands, **ptr_cmd, *vars_replaced; char *away_msg; @@ -2536,7 +2516,7 @@ irc_protocol_cmd_001 (struct t_irc_server *server, char *command, irc_server_set_nick (server, argv[2]); irc_protocol_cmd_numeric (server, command, argc, argv, argv_eol, - ignore, highlight); + highlight); /* connection to IRC server is ok! */ server->is_connected = 1; @@ -2591,7 +2571,7 @@ irc_protocol_cmd_001 (struct t_irc_server *server, char *command, int irc_protocol_cmd_005 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos, *pos2; @@ -2605,7 +2585,7 @@ irc_protocol_cmd_005 (struct t_irc_server *server, char *command, IRC_PROTOCOL_MIN_ARGS(4); irc_protocol_cmd_numeric (server, command, argc, argv, argv_eol, - ignore, highlight); + highlight); pos = strstr (argv_eol[3], "PREFIX="); if (pos) @@ -2638,7 +2618,7 @@ irc_protocol_cmd_005 (struct t_irc_server *server, char *command, int irc_protocol_cmd_221 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* 221 message looks like: :server 221 nick :+s @@ -2649,19 +2629,17 @@ irc_protocol_cmd_221 (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) highlight; - if (!ignore) - { - weechat_printf (server->buffer, - _("%sUser mode for %s%s%s is %s[%s%s%s]"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, - argv[2], - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3], - IRC_COLOR_CHAT_DELIMITERS); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + _("%sUser mode for %s%s%s is %s[%s%s%s]"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK, + argv[2], + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3], + IRC_COLOR_CHAT_DELIMITERS); return WEECHAT_RC_OK; } @@ -2675,7 +2653,7 @@ irc_protocol_cmd_221 (struct t_irc_server *server, char *command, int irc_protocol_cmd_301 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_away_msg; struct t_irc_channel *ptr_channel; @@ -2690,7 +2668,7 @@ irc_protocol_cmd_301 (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) highlight; - if ((argc > 4) && !ignore) + if (argc > 4) { pos_away_msg = (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]; @@ -2702,15 +2680,16 @@ irc_protocol_cmd_301 (struct t_irc_server *server, char *command, || (strcmp (ptr_channel->away_message, pos_away_msg) != 0)) { ptr_buffer = (ptr_channel) ? ptr_channel->buffer : server->buffer; - weechat_printf (ptr_buffer, - _("%s%s[%s%s%s]%s is away: %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - pos_away_msg); + weechat_printf_tags (ptr_buffer, + irc_protocol_tags (command, "irc_numeric"), + _("%s%s[%s%s%s]%s is away: %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_away_msg); if (ptr_channel) { if (ptr_channel->away_message) @@ -2730,7 +2709,7 @@ irc_protocol_cmd_301 (struct t_irc_server *server, char *command, int irc_protocol_cmd_303 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* 301 message looks like: :server 303 mynick :nick1 nick2 @@ -2742,14 +2721,12 @@ irc_protocol_cmd_303 (struct t_irc_server *server, char *command, (void) argv; (void) highlight; - if (!ignore) - { - weechat_printf (server->buffer, - _("%sUsers online: %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, - (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + _("%sUsers online: %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK, + (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); return WEECHAT_RC_OK; } @@ -2761,7 +2738,7 @@ irc_protocol_cmd_303 (struct t_irc_server *server, char *command, int irc_protocol_cmd_305 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* 305 message looks like: :server 305 mynick :Does this mean you're really back? @@ -2773,12 +2750,13 @@ irc_protocol_cmd_305 (struct t_irc_server *server, char *command, (void) argv; (void) highlight; - if (!ignore && (argc > 3)) + if (argc > 3) { - weechat_printf (server->buffer, - "%s%s", - weechat_prefix ("network"), - (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + "%s%s", + weechat_prefix ("network"), + (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); } server->is_away = 0; @@ -2804,7 +2782,7 @@ irc_protocol_cmd_305 (struct t_irc_server *server, char *command, int irc_protocol_cmd_306 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* 306 message looks like: :server 306 mynick :We'll miss you @@ -2816,12 +2794,13 @@ irc_protocol_cmd_306 (struct t_irc_server *server, char *command, (void) argv; (void) highlight; - if (!ignore && (argc > 3)) + if (argc > 3) { - weechat_printf (server->buffer, - "%s%s", - weechat_prefix ("network"), - (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + "%s%s", + weechat_prefix ("network"), + (argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]); } server->is_away = 1; @@ -2853,7 +2832,7 @@ irc_protocol_cmd_306 (struct t_irc_server *server, char *command, int irc_protocol_cmd_whois_nick_msg (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* messages look like: :server 319 flashy FlashCode :some text here @@ -2864,18 +2843,16 @@ irc_protocol_cmd_whois_nick_msg (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) highlight; - if (!ignore) - { - weechat_printf (server->buffer, - "%s%s[%s%s%s] %s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + "%s%s[%s%s%s] %s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); return WEECHAT_RC_OK; } @@ -2887,7 +2864,7 @@ irc_protocol_cmd_whois_nick_msg (struct t_irc_server *server, char *command, int irc_protocol_cmd_311 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* 311 message looks like: :server 311 mynick nick user host * :realname here @@ -2898,22 +2875,20 @@ irc_protocol_cmd_311 (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) highlight; - if (!ignore) - { - weechat_printf (server->buffer, - "%s%s[%s%s%s] (%s%s@%s%s)%s: %s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - argv[5], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - (argv_eol[7][0] == ':') ? argv_eol[7] + 1 : argv_eol[7]); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + "%s%s[%s%s%s] (%s%s@%s%s)%s: %s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + argv[5], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + (argv_eol[7][0] == ':') ? argv_eol[7] + 1 : argv_eol[7]); return WEECHAT_RC_OK; } @@ -2925,7 +2900,7 @@ irc_protocol_cmd_311 (struct t_irc_server *server, char *command, int irc_protocol_cmd_312 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* 312 message looks like: :server 312 mynick nick irc.freenode.net :http://freenode.net/ @@ -2936,22 +2911,20 @@ irc_protocol_cmd_312 (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) highlight; - if (!ignore) - { - weechat_printf (server->buffer, - "%s%s[%s%s%s] %s%s %s(%s%s%s)", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - argv[4], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5], - IRC_COLOR_CHAT_DELIMITERS); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + "%s%s[%s%s%s] %s%s %s(%s%s%s)", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + argv[4], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5], + IRC_COLOR_CHAT_DELIMITERS); return WEECHAT_RC_OK; } @@ -2963,7 +2936,7 @@ irc_protocol_cmd_312 (struct t_irc_server *server, char *command, int irc_protocol_cmd_314 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* 314 message looks like: :server 314 mynick nick user host * :realname here @@ -2974,21 +2947,19 @@ irc_protocol_cmd_314 (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) highlight; - if (!ignore) - { - weechat_printf (server->buffer, - _("%s%s%s %s(%s%s@%s%s)%s was %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - argv[5], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - (argv_eol[7][0] == ':') ? argv_eol[7] + 1 : argv_eol[7]); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + _("%s%s%s %s(%s%s@%s%s)%s was %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + argv[5], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + (argv_eol[7][0] == ':') ? argv_eol[7] + 1 : argv_eol[7]); return WEECHAT_RC_OK; } @@ -3000,7 +2971,7 @@ irc_protocol_cmd_314 (struct t_irc_server *server, char *command, int irc_protocol_cmd_315 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* 315 message looks like: :server 315 mynick #channel :End of /WHO list. @@ -3020,18 +2991,16 @@ irc_protocol_cmd_315 (struct t_irc_server *server, char *command, } else { - if (!ignore) - { - weechat_printf (server->buffer, - "%s%s[%s%s%s]%s %s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + "%s%s[%s%s%s]%s %s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); } return WEECHAT_RC_OK; @@ -3044,7 +3013,7 @@ irc_protocol_cmd_315 (struct t_irc_server *server, char *command, int irc_protocol_cmd_317 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { int idle_time, day, hour, min, sec; time_t datetime; @@ -3059,74 +3028,73 @@ irc_protocol_cmd_317 (struct t_irc_server *server, char *command, (void) argv_eol; (void) highlight; - if (!ignore) + idle_time = atoi (argv[4]); + day = idle_time / (60 * 60 * 24); + hour = (idle_time % (60 * 60 * 24)) / (60 * 60); + min = ((idle_time % (60 * 60 * 24)) % (60 * 60)) / 60; + sec = ((idle_time % (60 * 60 * 24)) % (60 * 60)) % 60; + + datetime = (time_t)(atol (argv[5])); + + if (day > 0) { - idle_time = atoi (argv[4]); - day = idle_time / (60 * 60 * 24); - hour = (idle_time % (60 * 60 * 24)) / (60 * 60); - min = ((idle_time % (60 * 60 * 24)) % (60 * 60)) / 60; - sec = ((idle_time % (60 * 60 * 24)) % (60 * 60)) % 60; - - datetime = (time_t)(atol (argv[5])); - - if (day > 0) - { - weechat_printf (server->buffer, - _("%s%s[%s%s%s]%s idle: %s%d %s%s, " - "%s%02d %s%s %s%02d %s%s %s%02d " - "%s%s, signon at: %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_CHANNEL, - day, - IRC_COLOR_CHAT, - NG_("day", "days", day), - IRC_COLOR_CHAT_CHANNEL, - hour, - IRC_COLOR_CHAT, - NG_("hour", "hours", hour), - IRC_COLOR_CHAT_CHANNEL, - min, - IRC_COLOR_CHAT, - NG_("minute", "minutes", min), - IRC_COLOR_CHAT_CHANNEL, - sec, - IRC_COLOR_CHAT, - NG_("second", "seconds", sec), - IRC_COLOR_CHAT_CHANNEL, - ctime (&datetime)); - } - else - { - weechat_printf (server->buffer, - _("%s%s[%s%s%s]%s idle: %s%02d %s%s " - "%s%02d %s%s %s%02d %s%s, " - "signon at: %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_CHANNEL, - hour, - IRC_COLOR_CHAT, - NG_("hour", "hours", hour), - IRC_COLOR_CHAT_CHANNEL, - min, - IRC_COLOR_CHAT, - NG_("minute", "minutes", min), - IRC_COLOR_CHAT_CHANNEL, - sec, - IRC_COLOR_CHAT, - NG_("second", "seconds", sec), - IRC_COLOR_CHAT_CHANNEL, - ctime (&datetime)); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + _("%s%s[%s%s%s]%s idle: %s%d %s%s, " + "%s%02d %s%s %s%02d %s%s %s%02d " + "%s%s, signon at: %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + day, + IRC_COLOR_CHAT, + NG_("day", "days", day), + IRC_COLOR_CHAT_CHANNEL, + hour, + IRC_COLOR_CHAT, + NG_("hour", "hours", hour), + IRC_COLOR_CHAT_CHANNEL, + min, + IRC_COLOR_CHAT, + NG_("minute", "minutes", min), + IRC_COLOR_CHAT_CHANNEL, + sec, + IRC_COLOR_CHAT, + NG_("second", "seconds", sec), + IRC_COLOR_CHAT_CHANNEL, + ctime (&datetime)); + } + else + { + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + _("%s%s[%s%s%s]%s idle: %s%02d %s%s " + "%s%02d %s%s %s%02d %s%s, " + "signon at: %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + hour, + IRC_COLOR_CHAT, + NG_("hour", "hours", hour), + IRC_COLOR_CHAT_CHANNEL, + min, + IRC_COLOR_CHAT, + NG_("minute", "minutes", min), + IRC_COLOR_CHAT_CHANNEL, + sec, + IRC_COLOR_CHAT, + NG_("second", "seconds", sec), + IRC_COLOR_CHAT_CHANNEL, + ctime (&datetime)); } return WEECHAT_RC_OK; @@ -3139,7 +3107,7 @@ irc_protocol_cmd_317 (struct t_irc_server *server, char *command, int irc_protocol_cmd_321 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_args; @@ -3155,15 +3123,13 @@ irc_protocol_cmd_321 (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) highlight; - if (!ignore) - { - weechat_printf (server->buffer, - "%s%s%s%s", - weechat_prefix ("network"), - argv[3], - (pos_args) ? " " : "", - (pos_args) ? pos_args : ""); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + "%s%s%s%s", + weechat_prefix ("network"), + argv[3], + (pos_args) ? " " : "", + (pos_args) ? pos_args : ""); return WEECHAT_RC_OK; } @@ -3175,7 +3141,7 @@ irc_protocol_cmd_321 (struct t_irc_server *server, char *command, int irc_protocol_cmd_322 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_topic; @@ -3191,24 +3157,22 @@ irc_protocol_cmd_322 (struct t_irc_server *server, char *command, pos_topic = (argc > 5) ? ((argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]) : NULL; - if (!ignore) + if (!server->cmd_list_regexp || + (regexec (server->cmd_list_regexp, argv[3], 0, NULL, 0) == 0)) { - if (!server->cmd_list_regexp || - (regexec (server->cmd_list_regexp, argv[3], 0, NULL, 0) == 0)) - { - weechat_printf (server->buffer, - "%s%s%s%s(%s%s%s)%s%s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - argv[4], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - (pos_topic && pos_topic[0]) ? ": " : "", - (pos_topic && pos_topic[0]) ? pos_topic : ""); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + "%s%s%s%s(%s%s%s)%s%s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + argv[4], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + (pos_topic && pos_topic[0]) ? ": " : "", + (pos_topic && pos_topic[0]) ? pos_topic : ""); } return WEECHAT_RC_OK; @@ -3221,7 +3185,7 @@ irc_protocol_cmd_322 (struct t_irc_server *server, char *command, int irc_protocol_cmd_323 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_args; @@ -3238,13 +3202,11 @@ irc_protocol_cmd_323 (struct t_irc_server *server, char *command, pos_args = (argc > 3) ? ((argv_eol[3][0] == ':') ? argv_eol[3] + 1 : argv_eol[3]) : NULL; - if (!ignore) - { - weechat_printf (server->buffer, - "%s%s", - weechat_prefix ("network"), - (pos_args && pos_args[0]) ? pos_args : ""); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + "%s%s", + weechat_prefix ("network"), + (pos_args && pos_args[0]) ? pos_args : ""); return WEECHAT_RC_OK; } @@ -3256,7 +3218,7 @@ irc_protocol_cmd_323 (struct t_irc_server *server, char *command, int irc_protocol_cmd_324 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { struct t_irc_channel *ptr_channel; @@ -3268,7 +3230,6 @@ irc_protocol_cmd_324 (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) argv_eol; - (void) ignore; (void) highlight; ptr_channel = irc_channel_search (server, argv[3]); @@ -3302,7 +3263,7 @@ irc_protocol_cmd_324 (struct t_irc_server *server, char *command, int irc_protocol_cmd_327 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_realname; @@ -3318,38 +3279,37 @@ irc_protocol_cmd_327 (struct t_irc_server *server, char *command, pos_realname = (argc > 6) ? ((argv_eol[6][0] == ':') ? argv_eol[6] + 1 : argv_eol[6]) : NULL; - if (!ignore) + if (pos_realname && pos_realname[0]) { - if (pos_realname && pos_realname[0]) - { - weechat_printf (server->buffer, - "%s%s[%s%s%s] %s%s %s %s(%s%s%s)", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - argv[5], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - pos_realname, - IRC_COLOR_CHAT_DELIMITERS); - } - else - { - weechat_printf (server->buffer, - "%s%s[%s%s%s] %s%s %s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - argv[5]); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + "%s%s[%s%s%s] %s%s %s %s(%s%s%s)", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + argv[5], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + pos_realname, + IRC_COLOR_CHAT_DELIMITERS); + } + else + { + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + "%s%s[%s%s%s] %s%s %s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + argv[5]); } return WEECHAT_RC_OK; @@ -3362,7 +3322,7 @@ irc_protocol_cmd_327 (struct t_irc_server *server, char *command, int irc_protocol_cmd_329 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { struct t_irc_channel *ptr_channel; time_t datetime; @@ -3378,33 +3338,32 @@ irc_protocol_cmd_329 (struct t_irc_server *server, char *command, ptr_channel = irc_channel_search (server, argv[3]); - if (!ignore) + datetime = (time_t)(atol ((argv_eol[4][0] == ':') ? + argv_eol[4] + 1 : argv_eol[4])); + + if (ptr_channel) { - datetime = (time_t)(atol ((argv_eol[4][0] == ':') ? - argv_eol[4] + 1 : argv_eol[4])); - - if (ptr_channel) + if (ptr_channel->display_creation_date) { - if (ptr_channel->display_creation_date) - { - weechat_printf (ptr_channel->buffer, - _("%sChannel created on %s"), - weechat_prefix ("network"), - ctime (&datetime)); - ptr_channel->display_creation_date = 0; - } - } - else - { - weechat_printf (server->buffer, - _("%sChannel %s%s%s created on %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT, - ctime (&datetime)); + weechat_printf_tags (ptr_channel->buffer, + irc_protocol_tags(command, "irc_numeric"), + _("%sChannel created on %s"), + weechat_prefix ("network"), + ctime (&datetime)); + ptr_channel->display_creation_date = 0; } } + else + { + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + _("%sChannel %s%s%s created on %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT, + ctime (&datetime)); + } return WEECHAT_RC_OK; } @@ -3416,7 +3375,7 @@ irc_protocol_cmd_329 (struct t_irc_server *server, char *command, int irc_protocol_cmd_331 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { struct t_irc_channel *ptr_channel; @@ -3430,16 +3389,14 @@ irc_protocol_cmd_331 (struct t_irc_server *server, char *command, (void) argv_eol; (void) highlight; - if (!ignore) - { - ptr_channel = irc_channel_search (server, argv[3]); - weechat_printf ((ptr_channel) ? - ptr_channel->buffer : server->buffer, - _("%sNo topic set for channel %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3]); - } + ptr_channel = irc_channel_search (server, argv[3]); + weechat_printf_tags ((ptr_channel) ? + ptr_channel->buffer : server->buffer, + irc_protocol_tags(command, "irc_numeric"), + _("%sNo topic set for channel %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3]); return WEECHAT_RC_OK; } @@ -3451,7 +3408,7 @@ irc_protocol_cmd_331 (struct t_irc_server *server, char *command, int irc_protocol_cmd_332 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_topic; struct t_irc_channel *ptr_channel; @@ -3477,18 +3434,16 @@ irc_protocol_cmd_332 (struct t_irc_server *server, char *command, weechat_buffer_set (ptr_channel->buffer, "title", ptr_channel->topic); } - if (!ignore) - { - weechat_printf ((ptr_channel && ptr_channel->nicks) ? - ptr_channel->buffer : server->buffer, - _("%sTopic for %s%s%s is: \"%s%s\""), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT, - pos_topic, - IRC_COLOR_CHAT); - } + weechat_printf_tags ((ptr_channel && ptr_channel->nicks) ? + ptr_channel->buffer : server->buffer, + irc_protocol_tags(command, "irc_numeric"), + _("%sTopic for %s%s%s is: \"%s%s\""), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT, + pos_topic, + IRC_COLOR_CHAT); return WEECHAT_RC_OK; } @@ -3500,7 +3455,7 @@ irc_protocol_cmd_332 (struct t_irc_server *server, char *command, int irc_protocol_cmd_333 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { struct t_irc_channel *ptr_channel; time_t datetime; @@ -3514,34 +3469,33 @@ irc_protocol_cmd_333 (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) highlight; - if (!ignore) + ptr_channel = irc_channel_search (server, argv[3]); + datetime = (time_t)(atol ((argv_eol[5][0] == ':') ? + argv_eol[5] + 1 : argv_eol[5])); + if (ptr_channel && ptr_channel->nicks) { - ptr_channel = irc_channel_search (server, argv[3]); - datetime = (time_t)(atol ((argv_eol[5][0] == ':') ? - argv_eol[5] + 1 : argv_eol[5])); - if (ptr_channel && ptr_channel->nicks) - { - weechat_printf (ptr_channel->buffer, - _("%sTopic set by %s%s%s on %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, - argv[4], - IRC_COLOR_CHAT, - ctime (&datetime)); - } - else - { - weechat_printf (server->buffer, - _("%sTopic for %s%s%s set by %s%s%s on %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - argv[4], - IRC_COLOR_CHAT, - ctime (&datetime)); - } + weechat_printf_tags (ptr_channel->buffer, + irc_protocol_tags(command, "irc_numeric"), + _("%sTopic set by %s%s%s on %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK, + argv[4], + IRC_COLOR_CHAT, + ctime (&datetime)); + } + else + { + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + _("%sTopic for %s%s%s set by %s%s%s on %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + argv[4], + IRC_COLOR_CHAT, + ctime (&datetime)); } return WEECHAT_RC_OK; @@ -3554,7 +3508,7 @@ irc_protocol_cmd_333 (struct t_irc_server *server, char *command, int irc_protocol_cmd_338 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* 338 message looks like: :server 338 mynick nick host :actually using host @@ -3565,20 +3519,18 @@ irc_protocol_cmd_338 (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) highlight; - if (!ignore) - { - weechat_printf (server->buffer, - "%s%s[%s%s%s]%s %s %s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5], - IRC_COLOR_CHAT_HOST, - argv[4]); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + "%s%s[%s%s%s]%s %s %s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5], + IRC_COLOR_CHAT_HOST, + argv[4]); return WEECHAT_RC_OK; } @@ -3590,7 +3542,7 @@ irc_protocol_cmd_338 (struct t_irc_server *server, char *command, int irc_protocol_cmd_341 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* 341 message looks like: :server 341 mynick nick #channel @@ -3602,20 +3554,18 @@ irc_protocol_cmd_341 (struct t_irc_server *server, char *command, (void) argv_eol; (void) highlight; - if (!ignore) - { - weechat_printf (server->buffer, - _("%s%s%s%s has invited %s%s%s on %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_NICK, - argv[2], - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - argv[3], - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_CHANNEL, - argv[4]); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + _("%s%s%s%s has invited %s%s%s on %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_NICK, + argv[2], + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + argv[3], + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + argv[4]); return WEECHAT_RC_OK; } @@ -3627,7 +3577,7 @@ irc_protocol_cmd_341 (struct t_irc_server *server, char *command, int irc_protocol_cmd_344 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* 344 message looks like: :server 344 mynick #channel nick!user@host @@ -3638,17 +3588,15 @@ irc_protocol_cmd_344 (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) highlight; - if (!ignore) - { - weechat_printf (server->buffer, - _("%sChannel reop %s%s%s: %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_HOST, - (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + _("%sChannel reop %s%s%s: %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_HOST, + (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); return WEECHAT_RC_OK; } @@ -3660,7 +3608,7 @@ irc_protocol_cmd_344 (struct t_irc_server *server, char *command, int irc_protocol_cmd_345 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* 345 message looks like: :server 345 mynick #channel :End of Channel Reop List @@ -3671,16 +3619,14 @@ irc_protocol_cmd_345 (struct t_irc_server *server, char *command, IRC_PROTOCOL_MIN_ARGS(5); - if (!ignore) - { - weechat_printf (server->buffer, - "%s%s%s%s: %s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT, - (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags(command, "irc_numeric"), + "%s%s%s%s: %s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT, + (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); return WEECHAT_RC_OK; } @@ -3692,7 +3638,7 @@ irc_protocol_cmd_345 (struct t_irc_server *server, char *command, int irc_protocol_cmd_348 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { struct t_irc_channel *ptr_channel; time_t datetime; @@ -3708,48 +3654,47 @@ irc_protocol_cmd_348 (struct t_irc_server *server, char *command, (void) argv_eol; (void) highlight; - if (!ignore) + ptr_channel = irc_channel_search (server, argv[3]); + if (argc >= 7) { - ptr_channel = irc_channel_search (server, argv[3]); - if (argc >= 7) - { - datetime = (time_t)(atol (argv[6])); - weechat_printf ((ptr_channel && ptr_channel->nicks) ? - ptr_channel->buffer : server->buffer, - _("%s%s[%s%s%s]%s exception %s%s%s " - "by %s%s %s(%s%s%s)%s on %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_HOST, - argv[4], - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - irc_protocol_get_nick_from_host (argv[5]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - irc_protocol_get_address_from_host (argv[5]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - ctime (&datetime)); - } - else - { - weechat_printf ((ptr_channel && ptr_channel->nicks) ? - ptr_channel->buffer : server->buffer, - _("%s%s[%s%s%s]%s exception %s%s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_HOST, - argv[4]); - } + datetime = (time_t)(atol (argv[6])); + weechat_printf_tags ((ptr_channel && ptr_channel->nicks) ? + ptr_channel->buffer : server->buffer, + irc_protocol_tags(command, "irc_numeric"), + _("%s%s[%s%s%s]%s exception %s%s%s " + "by %s%s %s(%s%s%s)%s on %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_HOST, + argv[4], + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + irc_protocol_get_nick_from_host (argv[5]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + irc_protocol_get_address_from_host (argv[5]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + ctime (&datetime)); + } + else + { + weechat_printf_tags ((ptr_channel && ptr_channel->nicks) ? + ptr_channel->buffer : server->buffer, + irc_protocol_tags(command, "irc_numeric"), + _("%s%s[%s%s%s]%s exception %s%s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_HOST, + argv[4]); } return WEECHAT_RC_OK; @@ -3762,7 +3707,7 @@ irc_protocol_cmd_348 (struct t_irc_server *server, char *command, int irc_protocol_cmd_349 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_args; struct t_irc_channel *ptr_channel; @@ -3779,21 +3724,19 @@ irc_protocol_cmd_349 (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) highlight; - if (!ignore) - { - ptr_channel = irc_channel_search (server, argv[3]); - weechat_printf ((ptr_channel && ptr_channel->nicks) ? - ptr_channel->buffer : server->buffer, - "%s%s[%s%s%s]%s%s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - (pos_args) ? " " : "", - (pos_args) ? pos_args : ""); - } + ptr_channel = irc_channel_search (server, argv[3]); + weechat_printf_tags ((ptr_channel && ptr_channel->nicks) ? + ptr_channel->buffer : server->buffer, + irc_protocol_tags (command, "irc_numeric"), + "%s%s[%s%s%s]%s%s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + (pos_args) ? " " : "", + (pos_args) ? pos_args : ""); return WEECHAT_RC_OK; } @@ -3805,7 +3748,7 @@ irc_protocol_cmd_349 (struct t_irc_server *server, char *command, int irc_protocol_cmd_351 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* 351 message looks like: :server 351 mynick dancer-ircd-1.0.36(2006/07/23_13:11:50). server :iMZ dncrTS/v4 @@ -3816,25 +3759,24 @@ irc_protocol_cmd_351 (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) highlight; - if (!ignore) + if (argc > 5) { - if (argc > 5) - { - weechat_printf (server->buffer, - "%s%s %s (%s)", - weechat_prefix ("network"), - argv[3], - argv[4], - (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]); - } - else - { - weechat_printf (server->buffer, - "%s%s %s", - weechat_prefix ("network"), - argv[3], - argv[4]); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + "%s%s %s (%s)", + weechat_prefix ("network"), + argv[3], + argv[4], + (argv_eol[5][0] == ':') ? argv_eol[5] + 1 : argv_eol[5]); + } + else + { + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + "%s%s %s", + weechat_prefix ("network"), + argv[3], + argv[4]); } return WEECHAT_RC_OK; @@ -3847,7 +3789,7 @@ irc_protocol_cmd_351 (struct t_irc_server *server, char *command, int irc_protocol_cmd_352 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_attr, *pos_hopcount, *pos_realname; int arg_start, length; @@ -3899,30 +3841,28 @@ irc_protocol_cmd_352 (struct t_irc_server *server, char *command, } else { - if (!ignore) - { - weechat_printf (server->buffer, - "%s%s[%s%s%s] %s%s%s(%s%s@%s%s)%s " - "%s%s%s%s(%s)", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_NICK, - argv[7], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - argv[5], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - (pos_attr) ? pos_attr : "", - (pos_attr) ? " " : "", - (pos_hopcount) ? pos_hopcount : "", - (pos_hopcount) ? " " : "", - (pos_realname) ? pos_realname : ""); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + "%s%s[%s%s%s] %s%s%s(%s%s@%s%s)%s " + "%s%s%s%s(%s)", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_NICK, + argv[7], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + argv[5], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + (pos_attr) ? pos_attr : "", + (pos_attr) ? " " : "", + (pos_hopcount) ? pos_hopcount : "", + (pos_hopcount) ? " " : "", + (pos_realname) ? pos_realname : ""); } return WEECHAT_RC_OK; @@ -3935,7 +3875,7 @@ irc_protocol_cmd_352 (struct t_irc_server *server, char *command, int irc_protocol_cmd_353 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_channel, *pos_nick, *color; int args, i, prefix_found; @@ -4040,21 +3980,19 @@ irc_protocol_cmd_353 (struct t_irc_server *server, char *command, } } - if (!ignore) - { - weechat_printf ((ptr_channel && ptr_channel->nicks) ? - ptr_channel->buffer : server->buffer, - _("%sNicks %s%s%s: %s[%s%s%s]"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - pos_channel, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - (argv_eol[args][0] == ':') ? - argv_eol[args] + 1 : argv_eol[args], - IRC_COLOR_CHAT_DELIMITERS); - } + weechat_printf_tags ((ptr_channel && ptr_channel->nicks) ? + ptr_channel->buffer : server->buffer, + irc_protocol_tags (command, "irc_numeric"), + _("%sNicks %s%s%s: %s[%s%s%s]"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + pos_channel, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + (argv_eol[args][0] == ':') ? + argv_eol[args] + 1 : argv_eol[args], + IRC_COLOR_CHAT_DELIMITERS); return WEECHAT_RC_OK; } @@ -4066,7 +4004,7 @@ irc_protocol_cmd_353 (struct t_irc_server *server, char *command, int irc_protocol_cmd_366 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { struct t_irc_channel *ptr_channel; int num_nicks, num_op, num_halfop, num_voice, num_normal; @@ -4083,56 +4021,53 @@ irc_protocol_cmd_366 (struct t_irc_server *server, char *command, ptr_channel = irc_channel_search (server, argv[3]); if (ptr_channel && ptr_channel->nicks) { - if (!ignore) - { - /* display number of nicks, ops, halfops & voices on the channel */ - irc_nick_count (ptr_channel, &num_nicks, &num_op, &num_halfop, - &num_voice, &num_normal); - weechat_printf (ptr_channel->buffer, - _("%sChannel %s%s%s: %s%d%s %s %s(%s%d%s %s, " - "%s%d%s %s, %s%d%s %s, %s%d%s %s%s)"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - ptr_channel->name, - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_CHANNEL, - num_nicks, - IRC_COLOR_CHAT, - (num_nicks > 1) ? _("nicks") : _("nick"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - num_op, - IRC_COLOR_CHAT, - (num_op > 1) ? _("ops") : _("op"), - IRC_COLOR_CHAT_CHANNEL, - num_halfop, - IRC_COLOR_CHAT, - (num_halfop > 1) ? _("halfops") : _("halfop"), - IRC_COLOR_CHAT_CHANNEL, - num_voice, - IRC_COLOR_CHAT, - (num_voice > 1) ? _("voices") : _("voice"), - IRC_COLOR_CHAT_CHANNEL, - num_normal, - IRC_COLOR_CHAT, - _("normal"), - IRC_COLOR_CHAT_DELIMITERS); - } + /* display number of nicks, ops, halfops & voices on the channel */ + irc_nick_count (ptr_channel, &num_nicks, &num_op, &num_halfop, + &num_voice, &num_normal); + weechat_printf_tags (ptr_channel->buffer, + irc_protocol_tags (command, "irc_numeric"), + _("%sChannel %s%s%s: %s%d%s %s %s(%s%d%s %s, " + "%s%d%s %s, %s%d%s %s, %s%d%s %s%s)"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + ptr_channel->name, + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_CHANNEL, + num_nicks, + IRC_COLOR_CHAT, + (num_nicks > 1) ? _("nicks") : _("nick"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + num_op, + IRC_COLOR_CHAT, + (num_op > 1) ? _("ops") : _("op"), + IRC_COLOR_CHAT_CHANNEL, + num_halfop, + IRC_COLOR_CHAT, + (num_halfop > 1) ? _("halfops") : _("halfop"), + IRC_COLOR_CHAT_CHANNEL, + num_voice, + IRC_COLOR_CHAT, + (num_voice > 1) ? _("voices") : _("voice"), + IRC_COLOR_CHAT_CHANNEL, + num_normal, + IRC_COLOR_CHAT, + _("normal"), + IRC_COLOR_CHAT_DELIMITERS); + irc_command_mode_server (server, ptr_channel->name); irc_channel_check_away (server, ptr_channel, 1); } else { - if (!ignore) - { - weechat_printf (server->buffer, - "%s%s%s%s: %s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT, - (argv[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + "%s%s%s%s: %s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT, + (argv[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); } return WEECHAT_RC_OK; @@ -4145,7 +4080,7 @@ irc_protocol_cmd_366 (struct t_irc_server *server, char *command, int irc_protocol_cmd_367 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { struct t_irc_channel *ptr_channel; time_t datetime; @@ -4160,54 +4095,53 @@ irc_protocol_cmd_367 (struct t_irc_server *server, char *command, (void) argv_eol; (void) highlight; - if (!ignore) + ptr_channel = irc_channel_search (server, argv[3]); + if (argc >= 7) { - ptr_channel = irc_channel_search (server, argv[3]); - if (argc >= 7) - { - datetime = (time_t)(atol (argv[6])); - weechat_printf ((ptr_channel && ptr_channel->nicks) ? - ptr_channel->buffer : server->buffer, - _("%s%s[%s%s%s] %s%s%s banned by " - "%s%s %s(%s%s%s)%s on %s"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - irc_protocol_get_nick_from_host (argv[5]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - irc_protocol_get_address_from_host (argv[5]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - ctime (&datetime)); - } - else - { - weechat_printf ((ptr_channel && ptr_channel->nicks) ? - ptr_channel->buffer : server->buffer, - _("%s%s[%s%s%s] %s%s%s banned by " - "%s%s %s(%s%s%s)"), - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - argv[4], - IRC_COLOR_CHAT, - IRC_COLOR_CHAT_NICK, - irc_protocol_get_nick_from_host (argv[5]), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_HOST, - irc_protocol_get_address_from_host (argv[5]), - IRC_COLOR_CHAT_DELIMITERS); - } + datetime = (time_t)(atol (argv[6])); + weechat_printf_tags ((ptr_channel && ptr_channel->nicks) ? + ptr_channel->buffer : server->buffer, + irc_protocol_tags (command, "irc_numeric"), + _("%s%s[%s%s%s] %s%s%s banned by " + "%s%s %s(%s%s%s)%s on %s"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + irc_protocol_get_nick_from_host (argv[5]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + irc_protocol_get_address_from_host (argv[5]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + ctime (&datetime)); + } + else + { + weechat_printf_tags ((ptr_channel && ptr_channel->nicks) ? + ptr_channel->buffer : server->buffer, + irc_protocol_tags (command, "irc_numeric"), + _("%s%s[%s%s%s] %s%s%s banned by " + "%s%s %s(%s%s%s)"), + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + argv[4], + IRC_COLOR_CHAT, + IRC_COLOR_CHAT_NICK, + irc_protocol_get_nick_from_host (argv[5]), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_HOST, + irc_protocol_get_address_from_host (argv[5]), + IRC_COLOR_CHAT_DELIMITERS); } return WEECHAT_RC_OK; @@ -4220,7 +4154,7 @@ irc_protocol_cmd_367 (struct t_irc_server *server, char *command, int irc_protocol_cmd_368 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { char *pos_args; struct t_irc_channel *ptr_channel; @@ -4237,21 +4171,19 @@ irc_protocol_cmd_368 (struct t_irc_server *server, char *command, pos_args = (argc > 4) ? ((argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]) : NULL; - if (!ignore) - { - ptr_channel = irc_channel_search (server, argv[3]); - weechat_printf ((ptr_channel && ptr_channel->nicks) ? - ptr_channel->buffer : server->buffer, - "%s%s[%s%s%s]%s%s%s", - weechat_prefix ("network"), - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT_CHANNEL, - argv[3], - IRC_COLOR_CHAT_DELIMITERS, - IRC_COLOR_CHAT, - (pos_args) ? " " : "", - (pos_args) ? pos_args : ""); - } + ptr_channel = irc_channel_search (server, argv[3]); + weechat_printf_tags ((ptr_channel && ptr_channel->nicks) ? + ptr_channel->buffer : server->buffer, + irc_protocol_tags (command, "irc_numeric"), + "%s%s[%s%s%s]%s%s%s", + weechat_prefix ("network"), + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT_CHANNEL, + argv[3], + IRC_COLOR_CHAT_DELIMITERS, + IRC_COLOR_CHAT, + (pos_args) ? " " : "", + (pos_args) ? pos_args : ""); return WEECHAT_RC_OK; } @@ -4263,13 +4195,11 @@ irc_protocol_cmd_368 (struct t_irc_server *server, char *command, int irc_protocol_cmd_432 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { - /* Note: this IRC command can not be ignored */ - int i, nick_found, nick_to_use; - irc_protocol_cmd_error (server, command, argc, argv, argv_eol, ignore, + irc_protocol_cmd_error (server, command, argc, argv, argv_eol, highlight); if (!server->is_connected) @@ -4323,10 +4253,8 @@ irc_protocol_cmd_432 (struct t_irc_server *server, char *command, int irc_protocol_cmd_433 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { - /* Note: this IRC command can not be ignored */ - int i, nick_found, nick_to_use; if (!server->is_connected) @@ -4372,7 +4300,7 @@ irc_protocol_cmd_433 (struct t_irc_server *server, char *command, else { return irc_protocol_cmd_error (server, command, argc, argv, argv_eol, - ignore, highlight); + highlight); } return WEECHAT_RC_OK; @@ -4385,7 +4313,7 @@ irc_protocol_cmd_433 (struct t_irc_server *server, char *command, int irc_protocol_cmd_438 (struct t_irc_server *server, char *command, int argc, char **argv, char **argv_eol, - int ignore, int highlight) + int highlight) { /* 438 message looks like: :server 438 mynick newnick :Nick change too fast. Please wait 30 seconds. @@ -4396,25 +4324,24 @@ irc_protocol_cmd_438 (struct t_irc_server *server, char *command, /* make C compiler happy */ (void) highlight; - if (!ignore) + if (argc >= 5) { - if (argc >= 5) - { - weechat_printf (server->buffer, - "%s%s (%s => %s)", - weechat_prefix ("network"), - (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4], - argv[2], - argv[3]); - } - else - { - weechat_printf (server->buffer, - "%s%s %s", - weechat_prefix ("network"), - argv[2], - argv[3]); - } + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + "%s%s (%s => %s)", + weechat_prefix ("network"), + (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4], + argv[2], + argv[3]); + } + else + { + weechat_printf_tags (server->buffer, + irc_protocol_tags (command, "irc_numeric"), + "%s%s %s", + weechat_prefix ("network"), + argv[2], + argv[3]); } return WEECHAT_RC_OK; @@ -4448,7 +4375,7 @@ void irc_protocol_recv_command (struct t_irc_server *server, char *entire_line, char *host, char *command, char *arguments) { - int i, cmd_found, return_code, ignore, highlight, argc; + int i, cmd_found, return_code, highlight, argc; char *pos, *nick; char *dup_entire_line, *dup_host, *dup_arguments, *irc_message; t_irc_recv_func *cmd_recv_func; @@ -4621,10 +4548,10 @@ irc_protocol_recv_command (struct t_irc_server *server, char *entire_line, dup_host = (host) ? strdup (host) : NULL; dup_arguments = (arguments) ? strdup (arguments) : NULL; - ignore = 0; highlight = 0; - /* TODO: call an IRC message handler */ + + //return_code = plugin_msg_handler_exec (server->name, // cmd_name, // dup_entire_line); @@ -4646,7 +4573,7 @@ irc_protocol_recv_command (struct t_irc_server *server, char *entire_line, return_code = (int) (cmd_recv_func) (server, cmd_name, argc, argv, argv_eol, - ignore, highlight); + highlight); if (return_code == WEECHAT_RC_ERROR) { diff --git a/src/plugins/irc/irc-protocol.h b/src/plugins/irc/irc-protocol.h index 2e2ec601e..07cd438d3 100644 --- a/src/plugins/irc/irc-protocol.h +++ b/src/plugins/irc/irc-protocol.h @@ -46,7 +46,7 @@ struct t_irc_server; typedef int (t_irc_recv_func)(struct t_irc_server *server, char *comand, int argc, char **argv, char **argv_eol, - int ignore, int highlight); + int highlight); struct t_irc_protocol_msg { diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 5202d8002..224ab557d 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -315,7 +315,7 @@ irc_server_set_addresses (struct t_irc_server *server, char *addresses) pos++; error = NULL; number = strtol (pos, &error, 10); - server->ports_array[i] = (error && (error[0] == '\0')) ? + server->ports_array[i] = (error && !error[0]) ? number : IRC_SERVER_DEFAULT_PORT; } else @@ -991,6 +991,124 @@ irc_server_outqueue_send (struct t_irc_server *server) } /* + * irc_server_parse_message: parse IRC message and return pointer to + * host, command, channel, target nick and arguments + * (if any) + */ + +void +irc_server_parse_message (char *message, char **nick, char **host, + char **command, char **channel, char **arguments) +{ + char *pos, *pos2, *pos3, *pos4; + + if (nick) + *nick = NULL; + if (host) + *host = NULL; + if (command) + *command = NULL; + if (channel) + *channel = NULL; + if (arguments) + *arguments = NULL; + + if (message[0] == ':') + { + pos2 = strchr (message, '!'); + pos = strchr (message, ' '); + if (pos2) + { + if (nick) + *nick = weechat_strndup (message + 1, pos2 - (message + 1)); + } + else if (pos) + { + if (nick) + *nick = weechat_strndup (message + 1, pos - (message + 1)); + } + if (pos) + { + if (host) + *host = weechat_strndup (message + 1, pos - (message + 1)); + pos++; + } + else + pos = message; + } + else + pos = message; + + if (pos && pos[0]) + { + while (pos[0] == ' ') + { + pos++; + } + pos2 = strchr (pos, ' '); + if (pos2) + { + if (command) + *command = weechat_strndup (pos, pos2 - pos); + pos2++; + while (pos2[0] == ' ') + { + pos2++; + } + if (arguments) + *arguments = strdup (pos2); + if (pos2[0] != ':') + { + if (irc_channel_is_channel (pos2)) + { + pos3 = strchr (pos2, ' '); + if (channel) + { + if (pos3) + *channel = weechat_strndup (pos2, pos3 - pos2); + else + *channel = strdup (pos2); + } + } + else + { + pos3 = strchr (pos2, ' '); + if (nick && !*nick) + { + if (nick) + { + if (pos3) + *nick = weechat_strndup (pos2, pos3 - pos2); + else + *nick = strdup (pos2); + } + } + if (pos3) + { + pos3++; + while (pos3[0] == ' ') + { + pos3++; + } + if (irc_channel_is_channel (pos3)) + { + pos4 = strchr (pos3, ' '); + if (channel) + { + if (pos4) + *channel = weechat_strndup (pos3, pos4 - pos3); + else + *channel = strdup (pos3); + } + } + } + } + } + } + } +} + +/* * irc_server_send_one_msg: send one message to IRC server */ @@ -998,20 +1116,24 @@ int irc_server_send_one_msg (struct t_irc_server *server, char *message) { static char buffer[4096]; - char *new_msg, *ptr_msg, *pos; + char *new_msg, *ptr_msg, *pos, *nick, *command, *channel; + char *ptr_chan_nick, *msg_encoded; + char str_modifier[64], modifier_data[256]; int rc, queue, first_message; time_t time_now; rc = 1; - /*new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_OUT, - server->name, - message) - */ - new_msg = NULL; + irc_server_parse_message (message, &nick, NULL, &command, &channel, NULL); + snprintf (str_modifier, sizeof (str_modifier), + "irc_out_%s", + (command) ? command : "unknown"); + new_msg = weechat_hook_modifier_exec (str_modifier, + server->name, + message); /* no changes in new message */ - if (new_msg && (strcmp (buffer, new_msg) == 0)) + if (new_msg && (strcmp (message, new_msg) == 0)) { free (new_msg); new_msg = NULL; @@ -1022,6 +1144,31 @@ irc_server_send_one_msg (struct t_irc_server *server, char *message) { first_message = 1; ptr_msg = (new_msg) ? new_msg : message; + + msg_encoded = NULL; + ptr_chan_nick = (channel) ? channel : nick; + if (ptr_chan_nick) + { + snprintf (modifier_data, sizeof (modifier_data), + "%s.%s.%s", + weechat_plugin->name, + server->name, + ptr_chan_nick); + } + else + { + snprintf (modifier_data, sizeof (modifier_data), + "%s.%s.%s", + weechat_plugin->name, + server->name, + ptr_chan_nick); + } + msg_encoded = weechat_hook_modifier_exec ("charset_decode", + modifier_data, + ptr_msg); + + if (msg_encoded) + ptr_msg = msg_encoded; while (rc && ptr_msg && ptr_msg[0]) { @@ -1073,9 +1220,18 @@ irc_server_send_one_msg (struct t_irc_server *server, char *message) first_message = 0; } + if (msg_encoded) + free (msg_encoded); } else irc_debug_printf (server, 1, 1, _("(message dropped)")); + + if (nick) + free (nick); + if (command) + free (command); + if (channel) + free (channel); if (new_msg) free (new_msg); @@ -1125,95 +1281,6 @@ irc_server_sendf (struct t_irc_server *server, char *format, ...) } /* - * irc_server_parse_message: parse IRC message and return pointer to - * host, command, channel, target nick and arguments - * (if any) - */ - -void -irc_server_parse_message (char *message, char **nick, char **host, - char **command, char **channel, char **arguments) -{ - char *pos, *pos2, *pos3, *pos4; - - *nick = NULL; - *host = NULL; - *command = NULL; - *channel = NULL; - *arguments = NULL; - - if (message[0] == ':') - { - pos2 = strchr (message, '!'); - pos = strchr (message, ' '); - if (pos2) - *nick = weechat_strndup (message + 1, pos2 - (message + 1)); - else if (pos) - *nick = weechat_strndup (message + 1, pos - (message + 1)); - if (pos) - { - *host = weechat_strndup (message + 1, pos - (message + 1)); - pos++; - } - else - pos = message; - } - else - pos = message; - - if (pos && pos[0]) - { - while (pos[0] == ' ') - pos++; - pos2 = strchr (pos, ' '); - if (pos2) - { - *command = weechat_strndup (pos, pos2 - pos); - pos2++; - while (pos2[0] == ' ') - pos2++; - *arguments = strdup (pos2); - if (pos2[0] != ':') - { - if (irc_channel_is_channel (pos2)) - { - pos3 = strchr (pos2, ' '); - if (pos3) - *channel = weechat_strndup (pos2, pos3 - pos2); - else - *channel = strdup (pos2); - } - else - { - pos3 = strchr (pos2, ' '); - if (!*nick) - { - if (pos3) - *nick = weechat_strndup (pos2, pos3 - pos2); - else - *nick = strdup (pos2); - } - if (pos3) - { - pos3++; - while (pos3[0] == ' ') - pos3++; - if (irc_channel_is_channel (pos3)) - { - pos4 = strchr (pos3, ' '); - if (pos4) - *channel = weechat_strndup (pos3, pos4 - pos3); - else - *channel = strdup (pos3); - } - } - } - } - } - } -} - -/* * irc_server_msgq_add_msg: add a message to received messages queue (at the end) */ @@ -1257,7 +1324,7 @@ irc_server_msgq_add_msg (struct t_irc_server *server, char *msg) else message->data = strdup (msg); message->next_message = NULL; - + if (irc_msgq_last_msg) { irc_msgq_last_msg->next_message = message; @@ -1357,8 +1424,7 @@ irc_server_msgq_flush () struct t_irc_message *next; char *ptr_data, *new_msg, *ptr_msg, *pos; char *nick, *host, *command, *channel, *arguments, *msg_decoded; - char *modifier_data, *ptr_chan_nick; - int length; + char str_modifier[64], modifier_data[256], *ptr_chan_nick; while (irc_recv_msgq) { @@ -1366,15 +1432,24 @@ irc_server_msgq_flush () { ptr_data = irc_recv_msgq->data; while (ptr_data[0] == ' ') + { ptr_data++; + } if (ptr_data[0]) { irc_debug_printf (irc_recv_msgq->server, 0, 0, ptr_data); - /*new_msg = plugin_modifier_exec (PLUGIN_MODIFIER_IRC_IN, - irc_recv_msgq->server->name, - ptr_data);*/ - new_msg = NULL; + + irc_server_parse_message (ptr_data, NULL, NULL, &command, + NULL, NULL); + snprintf (str_modifier, sizeof (str_modifier), + "irc_in_%s", + (command) ? command : "unknown"); + new_msg = weechat_hook_modifier_exec (str_modifier, + irc_recv_msgq->server->name, + ptr_data); + if (command) + free (command); /* no changes in new message */ if (new_msg && (strcmp (ptr_data, new_msg) == 0)) @@ -1404,33 +1479,26 @@ irc_server_msgq_flush () &arguments); /* convert charset for message */ - msg_decoded = NULL; ptr_chan_nick = (channel) ? channel : nick; - length = strlen (weechat_plugin->name) + 1 + - strlen (irc_recv_msgq->server->name) + 1 + - ((ptr_chan_nick) ? strlen (ptr_chan_nick) : 0) + 1; - modifier_data = (char *)malloc (length * sizeof (char)); - if (modifier_data) + if (ptr_chan_nick) { - if (ptr_chan_nick) - { - snprintf (modifier_data, length, "%s.%s.%s", - weechat_plugin->name, - irc_recv_msgq->server->name, - ptr_chan_nick); - } - else - { - snprintf (modifier_data, length, "%s.%s.%s", - weechat_plugin->name, - irc_recv_msgq->server->name, - ptr_chan_nick); - } - msg_decoded = weechat_hook_modifier_exec ("charset_decode", - modifier_data, - ptr_msg); - free (modifier_data); + snprintf (modifier_data, sizeof (modifier_data), + "%s.%s.%s", + weechat_plugin->name, + irc_recv_msgq->server->name, + ptr_chan_nick); } + else + { + snprintf (modifier_data, sizeof (modifier_data), + "%s.%s.%s", + weechat_plugin->name, + irc_recv_msgq->server->name, + ptr_chan_nick); + } + msg_decoded = weechat_hook_modifier_exec ("charset_decode", + modifier_data, + ptr_msg); /* parse and execute command */ irc_protocol_recv_command (irc_recv_msgq->server, @@ -1440,12 +1508,18 @@ irc_server_msgq_flush () command, arguments); + if (nick) + free (nick); if (host) free (host); if (command) free (command); + if (channel) + free (channel); if (arguments) free (arguments); + if (msg_decoded) + free (msg_decoded); if (pos) { @@ -1457,8 +1531,10 @@ irc_server_msgq_flush () } } else + { irc_debug_printf (irc_recv_msgq->server, 0, 1, _("(message dropped)")); + } if (new_msg) free (new_msg); } @@ -1468,7 +1544,7 @@ irc_server_msgq_flush () next = irc_recv_msgq->next_message; free (irc_recv_msgq); irc_recv_msgq = next; - if (irc_recv_msgq == NULL) + if (!irc_recv_msgq) irc_msgq_last_msg = NULL; } } @@ -1744,11 +1820,11 @@ irc_server_switch_address (struct t_irc_server *server) } /* - * irc_server_child_read: read connection progress from child process + * irc_server_child_read_cb: read connection progress from child process */ int -irc_server_child_read (void *arg_server) +irc_server_child_read_cb (void *arg_server) { struct t_irc_server *server; char buffer[1]; @@ -1843,6 +1919,7 @@ irc_server_child_read (void *arg_server) break; } } + return WEECHAT_RC_OK; } @@ -2560,7 +2637,7 @@ irc_server_connect (struct t_irc_server *server, int disable_autojoin) server->child_pid = pid; server->hook_fd = weechat_hook_fd (server->child_read, 1, 0, 0, - irc_server_child_read, + irc_server_child_read_cb, server); #endif diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h index 5fb33d46b..7febdbc8d 100644 --- a/src/plugins/irc/irc-server.h +++ b/src/plugins/irc/irc-server.h @@ -137,17 +137,12 @@ extern const int gnutls_prot_prio[]; #endif extern struct t_irc_message *irc_recv_msgq, *irc_msgq_last_msg; + extern void irc_server_init (struct t_irc_server *server); -extern int irc_server_init_with_url (struct t_irc_server *server, char *irc_url); -extern void irc_server_set_nick (struct t_irc_server *server, char *nick); +extern struct t_irc_server *irc_server_alloc (); extern void irc_server_init_with_config_options (struct t_irc_server *server, struct t_config_section *section, int config_reload); -extern struct t_irc_server *irc_server_alloc (); -extern void irc_server_outqueue_free_all (struct t_irc_server *server); -extern void irc_server_free_data (struct t_irc_server *server); -extern void irc_server_free (struct t_irc_server *server); -extern void irc_server_free_all (); extern struct t_irc_server *irc_server_new (char *name, int autoconnect, int autoreconnect, int autoreconnect_delay, @@ -162,46 +157,27 @@ extern struct t_irc_server *irc_server_new (char *name, int autoconnect, extern struct t_irc_server *irc_server_duplicate (struct t_irc_server *server, char *new_name); extern int irc_server_rename (struct t_irc_server *server, char *new_name); -extern int irc_server_send (struct t_irc_server *server, char *buffer, - int size_buf); -extern void irc_server_outqueue_send (struct t_irc_server *server); -extern void irc_server_sendf (struct t_irc_server *server, char *format, ...); -extern void irc_server_parse_message (char *message, char **nick, - char **host, char **command, - char **channel, char **arguments); -extern int irc_server_recv_cb (void *arg_server); -extern int irc_server_timer_cb (void *data); -extern void irc_server_timer_check_away (void *empty); -extern int irc_server_child_read (void *arg_server); -extern void irc_server_convbase64_8x3_to_6x4 (char *from, char *to); -extern void irc_server_base64encode (char *from, char *to); -extern int irc_server_pass_httpproxy (int sock, char *address, int port); -extern int irc_server_resolve (char *hostname, char *ip, int *version); -extern int irc_server_pass_socks4proxy (int sock, char *address, int port, - char *username); -extern int irc_server_pass_socks5proxy (int sock, char *address, int port); -extern int irc_server_pass_proxy (int sock, char *address, int port, - char *username); +extern void irc_server_set_nick (struct t_irc_server *server, char *nick); +extern struct t_irc_server *irc_server_search (char *server_name); +extern void irc_server_free_all (); extern int irc_server_connect (struct t_irc_server *server, int disable_autojoin); -extern void irc_server_reconnect (struct t_irc_server *server); extern void irc_server_auto_connect (int auto_connect, int temp_server); -extern void irc_server_disconnect (struct t_irc_server *server, int reconnect); -extern void irc_server_disconnect_all (); extern void irc_server_autojoin_channels (); -extern struct t_irc_server *irc_server_search (char *server_name); -extern int irc_server_get_number_connected (); -extern void irc_server_get_number_buffer (struct t_irc_server *server, - int *server_pos, int *server_total); +extern int irc_server_timer_cb (void *data); +extern void irc_server_sendf (struct t_irc_server *server, char *format, ...); +extern void irc_server_outqueue_free_all (struct t_irc_server *server); extern int irc_server_get_channel_count (struct t_irc_server *server); extern int irc_server_get_pv_count (struct t_irc_server *server); -extern void irc_server_remove_away (); -extern void irc_server_check_away (); extern void irc_server_set_away (struct t_irc_server *server, char *nick, int is_away); -extern int irc_server_get_default_notify_level (struct t_irc_server *server); -extern void irc_server_set_default_notify_level (struct t_irc_server *server, - int notify); +extern void irc_server_remove_away (); +extern void irc_server_check_away (); +extern void irc_server_reconnect (struct t_irc_server *server); +extern void irc_server_disconnect (struct t_irc_server *server, int reconnect); +extern void irc_server_disconnect_all (); +extern void irc_server_free (struct t_irc_server *server); +extern void irc_server_free_data (struct t_irc_server *server); extern void irc_server_print_log (); #endif /* irc-server.h */ diff --git a/src/plugins/irc/irc.h b/src/plugins/irc/irc.h index 3c458fd3c..6c0fd99bc 100644 --- a/src/plugins/irc/irc.h +++ b/src/plugins/irc/irc.h @@ -29,22 +29,22 @@ #define IRC_GET_SERVER(__buffer) \ struct t_weechat_plugin *buffer_plugin = NULL; \ struct t_irc_server *ptr_server = NULL; \ - buffer_plugin = weechat_buffer_get (__buffer, "plugin"); \ + buffer_plugin = weechat_buffer_get_pointer (__buffer, "plugin"); \ if (buffer_plugin == weechat_irc_plugin) \ ptr_server = irc_server_search ( \ - weechat_buffer_get (__buffer, "category")); + weechat_buffer_get_string (__buffer, "category")); #define IRC_GET_SERVER_CHANNEL(__buffer) \ struct t_weechat_plugin *buffer_plugin = NULL; \ struct t_irc_server *ptr_server = NULL; \ struct t_irc_channel *ptr_channel = NULL; \ - buffer_plugin = weechat_buffer_get (__buffer, "plugin"); \ + buffer_plugin = weechat_buffer_get_pointer (__buffer, "plugin"); \ if (buffer_plugin == weechat_irc_plugin) \ { \ ptr_server = irc_server_search ( \ - weechat_buffer_get (__buffer, "category")); \ + weechat_buffer_get_string (__buffer, "category")); \ ptr_channel = irc_channel_search ( \ - ptr_server, weechat_buffer_get (__buffer, "name")); \ + ptr_server, weechat_buffer_get_string (__buffer, "name")); \ } #define IRC_COLOR_CHAT weechat_color("color_chat") diff --git a/src/plugins/logger/logger.c b/src/plugins/logger/logger.c index 3f3f467f7..4d12cddce 100644 --- a/src/plugins/logger/logger.c +++ b/src/plugins/logger/logger.c @@ -130,10 +130,10 @@ logger_config_read () { error = NULL; number = strtol (string, &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) logger_option_backlog = number; } - if (logger_option_path && logger_option_time_format && logger_option_backlog) + if (logger_option_path && logger_option_time_format) return 1; else return 0; @@ -374,10 +374,14 @@ logger_start_buffer_all () struct t_plugin_infolist *ptr_infolist; ptr_infolist = weechat_infolist_get ("buffer", NULL); - while (weechat_infolist_next (ptr_infolist)) + if (ptr_infolist) { - logger_start_buffer (weechat_infolist_pointer (ptr_infolist, - "pointer")); + while (weechat_infolist_next (ptr_infolist)) + { + logger_start_buffer (weechat_infolist_pointer (ptr_infolist, + "pointer")); + } + weechat_infolist_free (ptr_infolist); } } @@ -598,6 +602,7 @@ logger_stop_signal_cb (void *data, char *signal, char *type_data, int logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date, + int tags_count, char **tags, char *prefix, char *message) { struct t_logger_buffer *ptr_logger_buffer; @@ -606,7 +611,9 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date, /* make C compiler happy */ (void) data; - + (void) tags_count; + (void) tags; + ptr_logger_buffer = logger_buffer_search (buffer); if (ptr_logger_buffer && ptr_logger_buffer->log_filename && ptr_logger_buffer->log_enabled) @@ -614,8 +621,10 @@ logger_print_cb (void *data, struct t_gui_buffer *buffer, time_t date, date_tmp = localtime (&date); buf_time[0] = '\0'; if (date_tmp) + { strftime (buf_time, sizeof (buf_time) - 1, logger_option_time_format, date_tmp); + } logger_write_line (ptr_logger_buffer, "%s\t%s\t%s", @@ -667,7 +676,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin) weechat_hook_signal ("logger_start", &logger_start_signal_cb, NULL); weechat_hook_signal ("logger_stop", &logger_stop_signal_cb, NULL); - weechat_hook_print (NULL, NULL, 1, &logger_print_cb, NULL); + weechat_hook_print (NULL, NULL, NULL, 1, &logger_print_cb, NULL); weechat_hook_config ("plugin", "logger." LOGGER_OPTION_PATH, &logger_config_cb, NULL); diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c index 71ea70427..ffa8a72e2 100644 --- a/src/plugins/plugin-api.c +++ b/src/plugins/plugin-api.c @@ -38,6 +38,7 @@ #include "../gui/gui-buffer.h" #include "../gui/gui-chat.h" #include "../gui/gui-color.h" +#include "../gui/gui-filter.h" #include "../gui/gui-infobar.h" #include "../gui/gui-keyboard.h" #include "../gui/gui-window.h" @@ -318,7 +319,7 @@ char * plugin_api_info_get (struct t_weechat_plugin *plugin, char *info) { time_t inactivity; - static char keyboard_inactivity[32]; + static char value[32]; if (!plugin || !info) return NULL; @@ -361,9 +362,13 @@ plugin_api_info_get (struct t_weechat_plugin *plugin, char *info) inactivity = 0; else inactivity = time (NULL) - gui_keyboard_last_activity_time; - snprintf (keyboard_inactivity, sizeof (keyboard_inactivity), - "%ld", (long int)inactivity); - return keyboard_inactivity; + snprintf (value, sizeof (value), "%ld", (long int)inactivity); + return value; + } + else if (string_strcasecmp (info, "filters_enabled") == 0) + { + snprintf (value, sizeof (value), "%d", gui_filters_enabled); + return value; } /* info not found */ @@ -402,6 +407,8 @@ plugin_api_infolist_get_add_buffer (struct t_plugin_infolist *infolist, return 0; if (!plugin_infolist_new_var_integer (ptr_item, "num_displayed", buffer->num_displayed)) return 0; + if (!plugin_infolist_new_var_integer (ptr_item, "lines_hidden", buffer->lines_hidden)) + return 0; if (!plugin_infolist_new_var_string (ptr_item, "title", buffer->title)) return 0; if (!plugin_infolist_new_var_integer (ptr_item, "input", buffer->input)) diff --git a/src/plugins/plugin-config.c b/src/plugins/plugin-config.c index 957f7dd13..e6b1f9186 100644 --- a/src/plugins/plugin-config.c +++ b/src/plugins/plugin-config.c @@ -261,12 +261,10 @@ plugin_config_free (struct t_config_option *option) if (option->next_option) (option->next_option)->prev_option = option->prev_option; - /* free data */ - if (option->name) - free (option->name); - if (option->value) - free (option->value); + /* free option */ + config_file_option_free_data (option); free (option); + plugin_options = new_plugin_options; } @@ -278,7 +276,9 @@ void plugin_config_free_all () { while (plugin_options) + { plugin_config_free (plugin_options); + } } /* @@ -396,3 +396,14 @@ plugin_config_write () log_printf (_("Saving plugins configuration to disk")); return config_file_write (plugin_config); } + +/* + * plugin_config_end: end plugin config + */ + +void +plugin_config_end () +{ + /* free all plugin config options */ + plugin_config_free_all (); +} diff --git a/src/plugins/plugin-config.h b/src/plugins/plugin-config.h index e32715287..5ad2f3eeb 100644 --- a/src/plugins/plugin-config.h +++ b/src/plugins/plugin-config.h @@ -35,5 +35,6 @@ extern void plugin_config_init (); extern int plugin_config_read (); extern int plugin_config_reload (); extern int plugin_config_write (); +extern void plugin_config_end (); #endif /* plugin-config.h */ diff --git a/src/plugins/plugin-infolist.c b/src/plugins/plugin-infolist.c index a05a897c4..233a9c1d9 100644 --- a/src/plugins/plugin-infolist.c +++ b/src/plugins/plugin-infolist.c @@ -476,6 +476,8 @@ plugin_infolist_var_free (struct t_plugin_infolist_item *item, free (var->value); } + free (var); + item->vars = new_vars; } @@ -511,6 +513,8 @@ plugin_infolist_item_free (struct t_plugin_infolist *list, if (item->fields) free (item->fields); + free (item); + list->items = new_items; } @@ -543,6 +547,8 @@ plugin_infolist_free (struct t_plugin_infolist *list) plugin_infolist_item_free (list, list->items); } + free (list); + plugin_infolists = new_plugin_infolists; } diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index efabf24bb..59cea632c 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -88,6 +88,7 @@ plugin_load (char *filename) void *handle; char *name, *author, *description, *version, *license, *charset; t_weechat_init_func *init_func; + int rc; struct t_weechat_plugin *new_plugin; if (!filename) @@ -242,6 +243,7 @@ plugin_load (char *filename) new_plugin->strncasecmp = &string_strncasecmp; new_plugin->strcmp_ignore_chars = &string_strcmp_ignore_chars; new_plugin->strcasestr = &string_strcasestr; + new_plugin->string_match = &string_match; new_plugin->string_replace = &string_replace; new_plugin->string_remove_quotes = &string_remove_quotes; new_plugin->string_strip = &string_strip; @@ -309,7 +311,7 @@ plugin_load (char *filename) new_plugin->prefix = &plugin_api_prefix; new_plugin->color = &plugin_api_color; - new_plugin->printf_date = &gui_chat_printf_date; + new_plugin->printf_date_tags = &gui_chat_printf_date_tags; new_plugin->infobar_printf = &plugin_api_infobar_printf; new_plugin->infobar_remove = &plugin_api_infobar_remove; new_plugin->log_printf = &log_printf; @@ -330,7 +332,8 @@ plugin_load (char *filename) new_plugin->buffer_new = &gui_buffer_new; new_plugin->buffer_search = &gui_buffer_search_by_category_name; new_plugin->buffer_close = &gui_buffer_close; - new_plugin->buffer_get = &gui_buffer_get; + new_plugin->buffer_get_string = &gui_buffer_get_string; + new_plugin->buffer_get_pointer = &gui_buffer_get_pointer; new_plugin->buffer_set = &gui_buffer_set; new_plugin->nicklist_add_group = &gui_nicklist_add_group; @@ -374,7 +377,8 @@ plugin_load (char *filename) last_weechat_plugin = new_plugin; /* init plugin */ - if (((t_weechat_init_func *)init_func) (new_plugin) < 0) + rc = ((t_weechat_init_func *)init_func) (new_plugin); + if (rc != WEECHAT_RC_OK) { gui_chat_printf (NULL, _("%sError: unable to initialize plugin " @@ -428,11 +432,14 @@ plugin_auto_load_file (void *plugin, char *filename) { if (string_strcasecmp (pos, CONFIG_STRING(config_plugins_extension)) == 0) + { plugin_load (filename); + } } } else plugin_load (filename); + return 1; } @@ -559,10 +566,15 @@ plugin_remove (struct t_weechat_plugin *plugin) free (plugin->name); if (plugin->description) free (plugin->description); + if (plugin->author) + free (plugin->author); if (plugin->version) free (plugin->version); + if (plugin->license) + free (plugin->license); if (plugin->charset) free (plugin->charset); + free (plugin); weechat_plugins = new_weechat_plugins; @@ -578,11 +590,12 @@ plugin_unload (struct t_weechat_plugin *plugin) t_weechat_end_func *end_func; char *name; - name = (plugin->name) ? strdup (plugin->name) : strdup ("???"); + name = (plugin->name) ? strdup (plugin->name) : NULL; end_func = dlsym (plugin->handle, "weechat_plugin_end"); if (end_func) (void) (end_func) (plugin); + plugin_remove (plugin); gui_chat_printf (NULL, @@ -622,7 +635,9 @@ void plugin_unload_all () { while (weechat_plugins) + { plugin_unload (last_weechat_plugin); + } } /* @@ -687,6 +702,9 @@ plugin_end () /* unload all plugins */ plugin_unload_all (); + + /* free all plugin options */ + plugin_config_end (); } /* diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index f996c847c..57800afa9 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -2208,22 +2208,27 @@ weechat_lua_api_hook_fd (lua_State *L) int weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, - time_t date, char *prefix, char *message) + time_t date, int tags_count, char **tags, + char *prefix, char *message) { struct t_script_callback *script_callback; - char *lua_argv[5]; + char *lua_argv[6]; static char timebuffer[64]; int *rc, ret; + /* make C compiler happy */ + (void) tags_count; + script_callback = (struct t_script_callback *)data; snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", date); lua_argv[0] = script_ptr2str (buffer); lua_argv[1] = timebuffer; - lua_argv[2] = prefix; - lua_argv[3] = message; - lua_argv[4] = NULL; + lua_argv[2] = weechat_string_build_with_exploded (tags, ","); + lua_argv[3] = prefix; + lua_argv[4] = message; + lua_argv[5] = NULL; rc = (int *) weechat_lua_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2237,6 +2242,10 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, ret = *rc; free (rc); } + if (lua_argv[0]) + free (lua_argv[0]); + if (lua_argv[2]) + free (lua_argv[2]); return ret; } @@ -2248,7 +2257,7 @@ weechat_lua_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, static int weechat_lua_api_hook_print (lua_State *L) { - const char *buffer, *message, *function; + const char *buffer, *tags, *message, *function; char *result; int n, strip_colors; @@ -2262,6 +2271,7 @@ weechat_lua_api_hook_print (lua_State *L) } buffer = NULL; + tags = NULL; message = NULL; strip_colors = 0; function = NULL; @@ -2274,7 +2284,8 @@ weechat_lua_api_hook_print (lua_State *L) LUA_RETURN_EMPTY; } - buffer = lua_tostring (lua_current_interpreter, -4); + buffer = lua_tostring (lua_current_interpreter, -5); + tags = lua_tostring (lua_current_interpreter, -4); message = lua_tostring (lua_current_interpreter, -3); strip_colors = lua_tonumber (lua_current_interpreter, -2); function = lua_tostring (lua_current_interpreter, -1); @@ -2282,6 +2293,7 @@ weechat_lua_api_hook_print (lua_State *L) result = script_ptr2str (script_api_hook_print (weechat_lua_plugin, lua_current_script, script_str2ptr ((char *)buffer), + (char *)tags, (char *)message, strip_colors, &weechat_lua_api_hook_print_cb, @@ -2979,11 +2991,11 @@ weechat_lua_api_buffer_close (lua_State *L) } /* - * weechat_lua_api_buffer_get: get a buffer property + * weechat_lua_api_buffer_get_string: get a buffer property as string */ static int -weechat_lua_api_buffer_get (lua_State *L) +weechat_lua_api_buffer_get_string (lua_State *L) { const char *buffer, *property; char *value; @@ -2994,7 +3006,7 @@ weechat_lua_api_buffer_get (lua_State *L) if (!lua_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_string"); LUA_RETURN_EMPTY; } @@ -3005,20 +3017,60 @@ weechat_lua_api_buffer_get (lua_State *L) if (n < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_string"); LUA_RETURN_EMPTY; } buffer = lua_tostring (lua_current_interpreter, -2); property = lua_tostring (lua_current_interpreter, -1); - value = weechat_buffer_get (script_str2ptr ((char *)buffer), - (char *)property); + value = weechat_buffer_get_string (script_str2ptr ((char *)buffer), + (char *)property); LUA_RETURN_STRING(value); } /* + * weechat_lua_api_buffer_get_pointer: get a buffer property as pointer + */ + +static int +weechat_lua_api_buffer_get_pointer (lua_State *L) +{ + const char *buffer, *property; + char *value; + int n; + + /* make C compiler happy */ + (void) L; + + if (!lua_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_pointer"); + LUA_RETURN_EMPTY; + } + + buffer = NULL; + property = NULL; + + n = lua_gettop (lua_current_interpreter); + + if (n < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_pointer"); + LUA_RETURN_EMPTY; + } + + buffer = lua_tostring (lua_current_interpreter, -2); + property = lua_tostring (lua_current_interpreter, -1); + + value = script_ptr2str (weechat_buffer_get_string (script_str2ptr ((char *)buffer), + (char *)property)); + + LUA_RETURN_STRING_FREE(value); +} + +/* * weechat_lua_api_buffer_set: set a buffer property */ @@ -4170,46 +4222,6 @@ weechat_lua_api_constant_weechat_rc_error (lua_State *L) } static int -weechat_lua_api_constant_weechat_rc_ok_ignore_weechat (lua_State *L) -{ - /* make C compiler happy */ - (void) L; - - lua_pushnumber (lua_current_interpreter, WEECHAT_RC_OK_IGNORE_WEECHAT); - return 1; -} - -static int -weechat_lua_api_constant_weechat_rc_ok_ignore_plugins (lua_State *L) -{ - /* make C compiler happy */ - (void) L; - - lua_pushnumber (lua_current_interpreter, WEECHAT_RC_OK_IGNORE_PLUGINS); - return 1; -} - -static int -weechat_lua_api_constant_weechat_rc_ok_ignore_all (lua_State *L) -{ - /* make C compiler happy */ - (void) L; - - lua_pushnumber (lua_current_interpreter, WEECHAT_RC_OK_IGNORE_ALL); - return 1; -} - -static int -weechat_lua_api_constant_weechat_rc_ok_with_highlight (lua_State *L) -{ - /* make C compiler happy */ - (void) L; - - lua_pushnumber (lua_current_interpreter, WEECHAT_RC_OK_WITH_HIGHLIGHT); - return 1; -} - -static int weechat_lua_api_constant_weechat_list_pos_sort (lua_State *L) { /* make C compiler happy */ @@ -4372,7 +4384,8 @@ const struct luaL_reg weechat_lua_api_funcs[] = { { "buffer_new", &weechat_lua_api_buffer_new }, { "buffer_search", &weechat_lua_api_buffer_search }, { "buffer_close", &weechat_lua_api_buffer_close }, - { "buffer_get", &weechat_lua_api_buffer_get }, + { "buffer_get_string", &weechat_lua_api_buffer_get_string }, + { "buffer_get_pointer", &weechat_lua_api_buffer_get_pointer }, { "buffer_set", &weechat_lua_api_buffer_set }, { "nicklist_add_group", &weechat_lua_api_nicklist_add_group }, { "nicklist_search_group", &weechat_lua_api_nicklist_search_group }, @@ -4403,10 +4416,6 @@ const struct luaL_reg weechat_lua_api_funcs[] = { /* define constants as function which returns values */ { "WEECHAT_RC_OK", &weechat_lua_api_constant_weechat_rc_ok }, { "WEECHAT_RC_ERROR", &weechat_lua_api_constant_weechat_rc_error }, - { "WEECHAT_RC_OK_IGNORE_WEECHAT", &weechat_lua_api_constant_weechat_rc_ok_ignore_weechat }, - { "WEECHAT_RC_OK_IGNORE_PLUGINS", &weechat_lua_api_constant_weechat_rc_ok_ignore_plugins }, - { "WEECHAT_RC_OK_IGNORE_ALL", &weechat_lua_api_constant_weechat_rc_ok_ignore_all }, - { "WEECHAT_RC_OK_WITH_HIGHLIGHT", &weechat_lua_api_constant_weechat_rc_ok_with_highlight }, { "WEECHAT_LIST_POS_SORT", &weechat_lua_api_constant_weechat_list_pos_sort }, { "WEECHAT_LIST_POS_BEGINNING", &weechat_lua_api_constant_weechat_list_pos_beginning }, { "WEECHAT_LIST_POS_END", &weechat_lua_api_constant_weechat_list_pos_end }, diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 570e06d0c..9cce80803 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -1815,22 +1815,27 @@ static XS (XS_weechat_hook_fd) int weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, - time_t date, char *prefix, char *message) + time_t date, int tags_count, char **tags, + char *prefix, char *message) { struct t_script_callback *script_callback; - char *perl_argv[5]; + char *perl_argv[6]; static char timebuffer[64]; int *rc, ret; + /* make C compiler happy */ + (void) tags_count; + script_callback = (struct t_script_callback *)data; snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", date); perl_argv[0] = script_ptr2str (buffer); perl_argv[1] = timebuffer; - perl_argv[2] = prefix; - perl_argv[3] = message; - perl_argv[4] = NULL; + perl_argv[2] = weechat_string_build_with_exploded (tags, ","); + perl_argv[3] = prefix; + perl_argv[4] = message; + perl_argv[5] = NULL; rc = (int *) weechat_perl_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1846,6 +1851,8 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, } if (perl_argv[0]) free (perl_argv[0]); + if (perl_argv[2]) + free (perl_argv[2]); return ret; } @@ -1856,7 +1863,7 @@ weechat_perl_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, static XS (XS_weechat_hook_print) { - char *result, *buffer, *message, *function; + char *result, *buffer, *tags, *message, *function; dXSARGS; /* make C compiler happy */ @@ -1868,20 +1875,22 @@ static XS (XS_weechat_hook_print) PERL_RETURN_EMPTY; } - if (items < 4) + if (items < 5) { WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_print"); PERL_RETURN_EMPTY; } buffer = SvPV (ST (0), PL_na); - message = SvPV (ST (1), PL_na); - function = SvPV (ST (3), PL_na); + tags = SvPV (ST (1), PL_na); + message = SvPV (ST (2), PL_na); + function = SvPV (ST (4), PL_na); result = script_ptr2str (script_api_hook_print (weechat_perl_plugin, perl_current_script, script_str2ptr (buffer), + tags, message, - SvIV (ST (2)), /* strip_colors */ + SvIV (ST (3)), /* strip_colors */ &weechat_perl_api_hook_print_cb, function)); @@ -2492,10 +2501,10 @@ static XS (XS_weechat_buffer_close) } /* - * weechat::buffer_get: get a buffer property + * weechat::buffer_get_string: get a buffer property as string */ -static XS (XS_weechat_buffer_get) +static XS (XS_weechat_buffer_get_string) { char *value, *buffer, *property; dXSARGS; @@ -2505,24 +2514,56 @@ static XS (XS_weechat_buffer_get) if (!perl_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_string"); PERL_RETURN_EMPTY; } if (items < 2) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_string"); PERL_RETURN_EMPTY; } buffer = SvPV (ST (0), PL_na); property = SvPV (ST (1), PL_na); - value = weechat_buffer_get (script_str2ptr (buffer), property); + value = weechat_buffer_get_string (script_str2ptr (buffer), property); PERL_RETURN_STRING(value); } /* + * weechat::buffer_get_pointer: get a buffer property as pointer + */ + +static XS (XS_weechat_buffer_get_pointer) +{ + char *value, *buffer, *property; + dXSARGS; + + /* make C compiler happy */ + (void) cv; + + if (!perl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_pointer"); + PERL_RETURN_EMPTY; + } + + if (items < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_pointer"); + PERL_RETURN_EMPTY; + } + + buffer = SvPV (ST (0), PL_na); + property = SvPV (ST (1), PL_na); + value = script_ptr2str (weechat_buffer_get_pointer (script_str2ptr (buffer), + property)); + + PERL_RETURN_STRING_FREE(value); +} + +/* * weechat::buffer_set: set a buffer property */ @@ -3489,7 +3530,8 @@ weechat_perl_api_init (pTHX) newXS ("weechat::buffer_new", XS_weechat_buffer_new, "weechat"); newXS ("weechat::buffer_search", XS_weechat_buffer_search, "weechat"); newXS ("weechat::buffer_close", XS_weechat_buffer_close, "weechat"); - newXS ("weechat::buffer_get", XS_weechat_buffer_get, "weechat"); + newXS ("weechat::buffer_get_string", XS_weechat_buffer_get_string, "weechat"); + newXS ("weechat::buffer_get_pointer", XS_weechat_buffer_get_pointer, "weechat"); newXS ("weechat::buffer_set", XS_weechat_buffer_set, "weechat"); newXS ("weechat::nicklist_add_group", XS_weechat_nicklist_add_group, "weechat"); newXS ("weechat::nicklist_search_group", XS_weechat_nicklist_search_group, "weechat"); @@ -3522,10 +3564,6 @@ weechat_perl_api_init (pTHX) stash = gv_stashpv ("weechat", TRUE); newCONSTSUB (stash, "weechat::WEECHAT_RC_OK", newSViv (WEECHAT_RC_OK)); newCONSTSUB (stash, "weechat::WEECHAT_RC_ERROR", newSViv (WEECHAT_RC_ERROR)); - newCONSTSUB (stash, "weechat::WEECHAT_RC_OK_IGNORE_WEECHAT", newSViv (WEECHAT_RC_OK_IGNORE_WEECHAT)); - newCONSTSUB (stash, "weechat::WEECHAT_RC_OK_IGNORE_PLUGINS", newSViv (WEECHAT_RC_OK_IGNORE_PLUGINS)); - newCONSTSUB (stash, "weechat::WEECHAT_RC_OK_IGNORE_ALL", newSViv (WEECHAT_RC_OK_IGNORE_ALL)); - newCONSTSUB (stash, "weechat::WEECHAT_RC_OK_WITH_HIGHLIGHT", newSViv (WEECHAT_RC_OK_WITH_HIGHLIGHT)); newCONSTSUB (stash, "weechat::WEECHAT_LIST_POS_SORT", newSVpv (WEECHAT_LIST_POS_SORT, PL_na)); newCONSTSUB (stash, "weechat::WEECHAT_LIST_POS_BEGINNING", newSVpv (WEECHAT_LIST_POS_BEGINNING, PL_na)); newCONSTSUB (stash, "weechat::WEECHAT_LIST_POS_END", newSVpv (WEECHAT_LIST_POS_END, PL_na)); diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index 79092b528..20b80882a 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -1939,22 +1939,27 @@ weechat_python_api_hook_fd (PyObject *self, PyObject *args) int weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, - time_t date, char *prefix, char *message) + time_t date, int tags_count, char **tags, + char *prefix, char *message) { struct t_script_callback *script_callback; - char *python_argv[5]; + char *python_argv[6]; static char timebuffer[64]; int *rc, ret; + /* make C compiler happy */ + (void) tags_count; + script_callback = (struct t_script_callback *)data; snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", date); python_argv[0] = script_ptr2str (buffer); python_argv[1] = timebuffer; - python_argv[2] = prefix; - python_argv[3] = message; - python_argv[4] = NULL; + python_argv[2] = weechat_string_build_with_exploded (tags, ","); + python_argv[3] = prefix; + python_argv[4] = message; + python_argv[5] = NULL; rc = (int *) weechat_python_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -1970,6 +1975,8 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, } if (python_argv[0]) free (python_argv[0]); + if (python_argv[2]) + free (python_argv[2]); return ret; } @@ -1981,7 +1988,7 @@ weechat_python_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, static PyObject * weechat_python_api_hook_print (PyObject *self, PyObject *args) { - char *buffer, *message, *function, *result; + char *buffer, *tags, *message, *function, *result; int strip_colors; PyObject *object; @@ -1995,12 +2002,13 @@ weechat_python_api_hook_print (PyObject *self, PyObject *args) } buffer = NULL; + tags = NULL; message = NULL; strip_colors = 0; function = NULL; - if (!PyArg_ParseTuple (args, "ssis", &buffer, &message, &strip_colors, - &function)) + if (!PyArg_ParseTuple (args, "sssis", &buffer, &tags, &message, + &strip_colors, &function)) { WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_print"); PYTHON_RETURN_EMPTY; @@ -2009,6 +2017,7 @@ weechat_python_api_hook_print (PyObject *self, PyObject *args) result = script_ptr2str(script_api_hook_print (weechat_python_plugin, python_current_script, script_str2ptr (buffer), + tags, message, strip_colors, &weechat_python_api_hook_print_cb, @@ -2146,7 +2155,7 @@ weechat_python_api_hook_signal_send (PyObject *self, PyObject *args) { error = NULL; number = (int)strtol (signal_data, &error, 10); - if (error && (error[0] == '\0')) + if (error && !error[0]) { weechat_hook_signal_send (signal, type_data, &number); } @@ -2645,11 +2654,11 @@ weechat_python_api_buffer_close (PyObject *self, PyObject *args) } /* - * weechat_python_api_buffer_get: get a buffer property + * weechat_python_api_buffer_get_string: get a buffer property as string */ static PyObject * -weechat_python_api_buffer_get (PyObject *self, PyObject *args) +weechat_python_api_buffer_get_string (PyObject *self, PyObject *args) { char *buffer, *property, *value; @@ -2658,7 +2667,7 @@ weechat_python_api_buffer_get (PyObject *self, PyObject *args) if (!python_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_string"); PYTHON_RETURN_ERROR; } @@ -2667,16 +2676,50 @@ weechat_python_api_buffer_get (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &buffer, &property)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_string"); PYTHON_RETURN_EMPTY; } - value = weechat_buffer_get (script_str2ptr (buffer), property); + value = weechat_buffer_get_string (script_str2ptr (buffer), property); PYTHON_RETURN_STRING(value); } /* + * weechat_python_api_buffer_get_pointer: get a buffer property as pointer + */ + +static PyObject * +weechat_python_api_buffer_get_pointer (PyObject *self, PyObject *args) +{ + char *buffer, *property, *value; + PyObject *object; + + /* make C compiler happy */ + (void) self; + + if (!python_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_pointer"); + PYTHON_RETURN_ERROR; + } + + buffer = NULL; + property = NULL; + + if (!PyArg_ParseTuple (args, "ss", &buffer, &property)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_pointer"); + PYTHON_RETURN_EMPTY; + } + + value = script_ptr2str (weechat_buffer_get_pointer (script_str2ptr (buffer), + property)); + + PYTHON_RETURN_STRING_FREE(value); +} + +/* * weechat_python_api_buffer_set: set a buffer property */ @@ -3710,7 +3753,8 @@ PyMethodDef weechat_python_funcs[] = { "buffer_new", &weechat_python_api_buffer_new, METH_VARARGS, "" }, { "buffer_search", &weechat_python_api_buffer_search, METH_VARARGS, "" }, { "buffer_close", &weechat_python_api_buffer_close, METH_VARARGS, "" }, - { "buffer_get", &weechat_python_api_buffer_get, METH_VARARGS, "" }, + { "buffer_get_string", &weechat_python_api_buffer_get_string, METH_VARARGS, "" }, + { "buffer_get_pointer", &weechat_python_api_buffer_get_pointer, METH_VARARGS, "" }, { "buffer_set", &weechat_python_api_buffer_set, METH_VARARGS, "" }, { "nicklist_add_group", &weechat_python_api_nicklist_add_group, METH_VARARGS, "" }, { "nicklist_search_group", &weechat_python_api_nicklist_search_group, METH_VARARGS, "" }, diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index 216a0c087..2deb39302 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -87,9 +87,16 @@ weechat_python_exec (struct t_plugin_script *script, { if (argv[4]) { - rc = PyObject_CallFunction (evFunc, "sssss", argv[0], - argv[1], argv[2], argv[3], - argv[4]); + if (argv[5]) + { + rc = PyObject_CallFunction (evFunc, "ssssss", argv[0], + argv[1], argv[2], argv[3], + argv[4], argv[5]); + } + else + rc = PyObject_CallFunction (evFunc, "sssss", argv[0], + argv[1], argv[2], argv[3], + argv[4]); } else rc = PyObject_CallFunction (evFunc, "ssss", argv[0], @@ -315,10 +322,6 @@ weechat_python_load (char *filename) weechat_dict = PyModule_GetDict(weechat_module); PyDict_SetItemString(weechat_dict, "WEECHAT_RC_OK", PyInt_FromLong((long) WEECHAT_RC_OK)); PyDict_SetItemString(weechat_dict, "WEECHAT_RC_ERROR", PyInt_FromLong((long) WEECHAT_RC_ERROR)); - PyDict_SetItemString(weechat_dict, "WEECHAT_RC_OK_IGNORE_WEECHAT", PyInt_FromLong((long) WEECHAT_RC_OK_IGNORE_WEECHAT)); - PyDict_SetItemString(weechat_dict, "WEECHAT_RC_OK_IGNORE_PLUGINS", PyInt_FromLong((long) WEECHAT_RC_OK_IGNORE_PLUGINS)); - PyDict_SetItemString(weechat_dict, "WEECHAT_RC_OK_IGNORE_ALL", PyInt_FromLong((long) WEECHAT_RC_OK_IGNORE_ALL)); - PyDict_SetItemString(weechat_dict, "WEECHAT_RC_OK_WITH_HIGHLIGHT", PyInt_FromLong((long) WEECHAT_RC_OK_WITH_HIGHLIGHT)); PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_SORT", PyString_FromString(WEECHAT_LIST_POS_SORT)); PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_BEGINNING", PyString_FromString(WEECHAT_LIST_POS_BEGINNING)); PyDict_SetItemString(weechat_dict, "WEECHAT_LIST_POS_END", PyString_FromString(WEECHAT_LIST_POS_END)); diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index 46c1c8db0..bc727e142 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -2244,22 +2244,27 @@ weechat_ruby_api_hook_fd (VALUE class, VALUE fd, VALUE read, VALUE write, int weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, - time_t date, char *prefix, char *message) + time_t date, int tags_count, char **tags, + char *prefix, char *message) { struct t_script_callback *script_callback; - char *ruby_argv[5]; + char *ruby_argv[6]; static char timebuffer[64]; int *rc, ret; + /* make C compiler happy */ + (void) tags_count; + script_callback = (struct t_script_callback *)data; - + snprintf (timebuffer, sizeof (timebuffer) - 1, "%ld", date); ruby_argv[0] = script_ptr2str (buffer); ruby_argv[1] = timebuffer; - ruby_argv[2] = prefix; - ruby_argv[3] = message; - ruby_argv[4] = NULL; + ruby_argv[2] = weechat_string_build_with_exploded (tags, ","); + ruby_argv[3] = prefix; + ruby_argv[4] = message; + ruby_argv[5] = NULL; rc = (int *) weechat_ruby_exec (script_callback->script, WEECHAT_SCRIPT_EXEC_INT, @@ -2275,6 +2280,8 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, } if (ruby_argv[0]) free (ruby_argv[0]); + if (ruby_argv[2]) + free (ruby_argv[2]); return ret; } @@ -2284,10 +2291,10 @@ weechat_ruby_api_hook_print_cb (void *data, struct t_gui_buffer *buffer, */ static VALUE -weechat_ruby_api_hook_print (VALUE class, VALUE buffer, VALUE message, - VALUE strip_colors, VALUE function) +weechat_ruby_api_hook_print (VALUE class, VALUE buffer, VALUE tags, + VALUE message, VALUE strip_colors, VALUE function) { - char *c_buffer, *c_message, *c_function, *result; + char *c_buffer, *c_tags, *c_message, *c_function, *result; int c_strip_colors; VALUE return_value; @@ -2301,23 +2308,26 @@ weechat_ruby_api_hook_print (VALUE class, VALUE buffer, VALUE message, } c_buffer = NULL; + c_tags = NULL; c_message = NULL; c_strip_colors = 0; c_function = NULL; - if (NIL_P (buffer) || NIL_P (message) || NIL_P (strip_colors) - || NIL_P (function)) + if (NIL_P (buffer) || NIL_P (tags) || NIL_P (message) + || NIL_P (strip_colors) || NIL_P (function)) { WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_print"); RUBY_RETURN_EMPTY; } Check_Type (buffer, T_STRING); + Check_Type (tags, T_STRING); Check_Type (message, T_STRING); Check_Type (strip_colors, T_FIXNUM); Check_Type (function, T_STRING); c_buffer = STR2CSTR (buffer); + c_tags = STR2CSTR (tags); c_message = STR2CSTR (message); c_strip_colors = FIX2INT (strip_colors); c_function = STR2CSTR (function); @@ -2325,6 +2335,7 @@ weechat_ruby_api_hook_print (VALUE class, VALUE buffer, VALUE message, result = script_ptr2str (script_api_hook_print (weechat_ruby_plugin, ruby_current_script, script_str2ptr (c_buffer), + c_tags, c_message, c_strip_colors, &weechat_ruby_api_hook_print_cb, @@ -3034,11 +3045,11 @@ weechat_ruby_api_buffer_close (VALUE class, VALUE buffer, } /* - * weechat_ruby_api_buffer_get: get a buffer property + * weechat_ruby_api_buffer_get_string: get a buffer property as string */ static VALUE -weechat_ruby_api_buffer_get (VALUE class, VALUE buffer, VALUE property) +weechat_ruby_api_buffer_get_string (VALUE class, VALUE buffer, VALUE property) { char *c_buffer, *c_property, *value; @@ -3047,13 +3058,13 @@ weechat_ruby_api_buffer_get (VALUE class, VALUE buffer, VALUE property) if (!ruby_current_script) { - WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get"); + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_string"); RUBY_RETURN_EMPTY; } if (NIL_P (buffer) || NIL_P (property)) { - WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get"); + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_string"); RUBY_RETURN_EMPTY; } @@ -3063,13 +3074,50 @@ weechat_ruby_api_buffer_get (VALUE class, VALUE buffer, VALUE property) c_buffer = STR2CSTR (buffer); c_property = STR2CSTR (property); - value = weechat_buffer_get (script_str2ptr (c_buffer), - c_property); + value = weechat_buffer_get_string (script_str2ptr (c_buffer), + c_property); RUBY_RETURN_STRING(value); } /* + * weechat_ruby_api_buffer_get_pointer: get a buffer property as pointer + */ + +static VALUE +weechat_ruby_api_buffer_get_pointer (VALUE class, VALUE buffer, VALUE property) +{ + char *c_buffer, *c_property, *value; + VALUE return_value; + + /* make C compiler happy */ + (void) class; + + if (!ruby_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("buffer_get_pointer"); + RUBY_RETURN_EMPTY; + } + + if (NIL_P (buffer) || NIL_P (property)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("buffer_get_pointer"); + RUBY_RETURN_EMPTY; + } + + Check_Type (buffer, T_STRING); + Check_Type (property, T_STRING); + + c_buffer = STR2CSTR (buffer); + c_property = STR2CSTR (property); + + value = script_ptr2str (weechat_buffer_get_string (script_str2ptr (c_buffer), + c_property)); + + RUBY_RETURN_STRING_FREE(value); +} + +/* * weechat_ruby_api_buffer_set: set a buffer property */ @@ -4171,10 +4219,6 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) { rb_define_const(ruby_mWeechat, "WEECHAT_RC_OK", INT2NUM(WEECHAT_RC_OK)); rb_define_const(ruby_mWeechat, "WEECHAT_RC_ERROR", INT2NUM(WEECHAT_RC_ERROR)); - rb_define_const(ruby_mWeechat, "WEECHAT_RC_OK_IGNORE_WEECHAT", INT2NUM(WEECHAT_RC_OK_IGNORE_WEECHAT)); - rb_define_const(ruby_mWeechat, "WEECHAT_RC_OK_IGNORE_PLUGINS", INT2NUM(WEECHAT_RC_OK_IGNORE_PLUGINS)); - rb_define_const(ruby_mWeechat, "WEECHAT_RC_OK_IGNORE_ALL", INT2NUM(WEECHAT_RC_OK_IGNORE_ALL)); - rb_define_const(ruby_mWeechat, "WEECHAT_RC_OK_WITH_HIGHLIGHT", INT2NUM(WEECHAT_RC_OK_WITH_HIGHLIGHT)); rb_define_const(ruby_mWeechat, "WEECHAT_LIST_POS_SORT", rb_str_new2(WEECHAT_LIST_POS_SORT)); rb_define_const(ruby_mWeechat, "WEECHAT_LIST_POS_BEGINNING", rb_str_new2(WEECHAT_LIST_POS_BEGINNING)); rb_define_const(ruby_mWeechat, "WEECHAT_LIST_POS_END", rb_str_new2(WEECHAT_LIST_POS_END)); @@ -4231,7 +4275,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) rb_define_module_function (ruby_mWeechat, "hook_command", &weechat_ruby_api_hook_command, 6); rb_define_module_function (ruby_mWeechat, "hook_timer", &weechat_ruby_api_hook_timer, 4); rb_define_module_function (ruby_mWeechat, "hook_fd", &weechat_ruby_api_hook_fd, 5); - rb_define_module_function (ruby_mWeechat, "hook_print", &weechat_ruby_api_hook_print, 4); + rb_define_module_function (ruby_mWeechat, "hook_print", &weechat_ruby_api_hook_print, 5); rb_define_module_function (ruby_mWeechat, "hook_signal", &weechat_ruby_api_hook_signal, 2); rb_define_module_function (ruby_mWeechat, "hook_signal_send", &weechat_ruby_api_hook_signal_send, 3); rb_define_module_function (ruby_mWeechat, "hook_config", &weechat_ruby_api_hook_config, 3); @@ -4243,7 +4287,8 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) rb_define_module_function (ruby_mWeechat, "buffer_new", &weechat_ruby_api_buffer_new, 4); rb_define_module_function (ruby_mWeechat, "buffer_search", &weechat_ruby_api_buffer_search, 2); rb_define_module_function (ruby_mWeechat, "buffer_close", &weechat_ruby_api_buffer_close, 1); - rb_define_module_function (ruby_mWeechat, "buffer_get", &weechat_ruby_api_buffer_get, 2); + rb_define_module_function (ruby_mWeechat, "buffer_get_string", &weechat_ruby_api_buffer_get_string, 2); + rb_define_module_function (ruby_mWeechat, "buffer_get_pointer", &weechat_ruby_api_buffer_get_pointer, 2); rb_define_module_function (ruby_mWeechat, "buffer_set", &weechat_ruby_api_buffer_set, 3); rb_define_module_function (ruby_mWeechat, "nicklist_add_group", &weechat_ruby_api_nicklist_add_group, 5); rb_define_module_function (ruby_mWeechat, "nicklist_search_group", &weechat_ruby_api_nicklist_search_group, 3); diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c index b53f94dd0..d351ebadc 100644 --- a/src/plugins/scripts/ruby/weechat-ruby.c +++ b/src/plugins/scripts/ruby/weechat-ruby.c @@ -124,13 +124,25 @@ weechat_ruby_exec (struct t_plugin_script *script, { if (argv[4]) { - rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), - &ruby_error, 5, - rb_str_new2(argv[0]), - rb_str_new2(argv[1]), - rb_str_new2(argv[2]), - rb_str_new2(argv[3]), - rb_str_new2(argv[4])); + if (argv[5]) + { + rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), + &ruby_error, 6, + rb_str_new2(argv[0]), + rb_str_new2(argv[1]), + rb_str_new2(argv[2]), + rb_str_new2(argv[3]), + rb_str_new2(argv[4]), + rb_str_new2(argv[5])); + } + else + rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), + &ruby_error, 5, + rb_str_new2(argv[0]), + rb_str_new2(argv[1]), + rb_str_new2(argv[2]), + rb_str_new2(argv[3]), + rb_str_new2(argv[4])); } else rc = rb_protect_funcall ((VALUE) script->interpreter, rb_intern(function), diff --git a/src/plugins/scripts/script-api.c b/src/plugins/scripts/script-api.c index 1230254df..7f8f42219 100644 --- a/src/plugins/scripts/script-api.c +++ b/src/plugins/scripts/script-api.c @@ -481,11 +481,12 @@ struct t_hook * script_api_hook_print (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, struct t_gui_buffer *buffer, - char *message, int strip_colors, + char *tags, char *message, int strip_colors, int (*callback)(void *data, struct t_gui_buffer *buffer, - time_t date, char *prefix, - char *message), + time_t date, + int tags_count, char **tags, + char *prefix, char *message), char *function) { struct t_script_callback *new_script_callback; @@ -495,7 +496,7 @@ script_api_hook_print (struct t_weechat_plugin *weechat_plugin, if (!new_script_callback) return NULL; - new_hook = weechat_hook_print (buffer, message, strip_colors, + new_hook = weechat_hook_print (buffer, tags, message, strip_colors, callback, new_script_callback); if (!new_hook) { diff --git a/src/plugins/scripts/script-api.h b/src/plugins/scripts/script-api.h index 2aa7bd085..50fa7254c 100644 --- a/src/plugins/scripts/script-api.h +++ b/src/plugins/scripts/script-api.h @@ -95,10 +95,14 @@ extern struct t_hook *script_api_hook_fd (struct t_weechat_plugin *weechat_plugi extern struct t_hook *script_api_hook_print (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, struct t_gui_buffer *buffer, - char *message, int strip_colors, + char *tags, + char *message, + int strip_colors, int (*callback)(void *data, struct t_gui_buffer *buffer, time_t date, + int tags_count, + char **tags, char *prefix, char *message), char *function); diff --git a/src/plugins/trigger/dump.c b/src/plugins/trigger/dump.c index e93559f14..cd1f04e1c 100644 --- a/src/plugins/trigger/dump.c +++ b/src/plugins/trigger/dump.c @@ -98,7 +98,7 @@ weechat_trigger_list_del (char *pattern, char *commands, number = strtol (pattern, &error, 10); p = NULL; - if (error && (error[0] == '\0') && number > 0) + if (error && !error[0] && number > 0) { l = weechat_trigger_list; while (l && number >= 0) diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index f4f22e454..b79d57f4c 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -45,16 +45,6 @@ struct t_weelist; #define WEECHAT_RC_ERROR -1 /* function failed with an error */ #define WEECHAT_RC_OK 0 /* function ok */ -/* return codes specific to message handlers: messages can be discarded for - WeeChat, for plugins, or both */ -#define WEECHAT_RC_OK_IGNORE_WEECHAT 1 /* ignore WeeChat for this message */ -#define WEECHAT_RC_OK_IGNORE_PLUGINS 2 /* ignore other plugins for msg */ -#define WEECHAT_RC_OK_IGNORE_ALL (WEECHAT_RC_OK_IGNORE_WEECHAT \ - | WEECHAT_RC_OK_IGNORE_PLUGINS) - /* ignore WeeChat and other plugins */ -#define WEECHAT_RC_OK_WITH_HIGHLIGHT 4 /* ok and ask for highlight */ - /* (for message handler only) */ - /* list management (order of elements) */ #define WEECHAT_LIST_POS_SORT "sort" #define WEECHAT_LIST_POS_BEGINNING "beginning" @@ -105,12 +95,15 @@ struct t_weechat_plugin int (*strcmp_ignore_chars) (char *string1, char *string2, char *chars_ignored, int case_sensitive); char *(*strcasestr) (char *string1, char *string2); + int (*string_match) (char *string, char *mask, int case_sensitive); char *(*string_replace) (char *string, char *search, char *replace); char *(*string_remove_quotes) (char *string, char *quotes); char *(*string_strip) (char *string, int left, int right, char *chars); char **(*string_explode) (char *string, char *separators, int keep_eol, int num_items_max, int *num_items); void (*string_free_exploded) (char **exploded_string); + char *(*string_build_with_exploded) (char **exploded_string, + char *separator); char **(*string_split_command) (char *command, char separator); void (*string_free_splitted_command) (char **splitted_command); @@ -218,8 +211,8 @@ struct t_weechat_plugin /* display */ char *(*prefix) (char *prefix); char *(*color) (char *color_name); - void (*printf_date) (struct t_gui_buffer *buffer, time_t date, - char *message, ...); + void (*printf_date_tags) (struct t_gui_buffer *buffer, time_t date, + char *tags, char *message, ...); void (*infobar_printf) (struct t_weechat_plugin *plugin, int delay, char *color_name, char *format, ...); void (*infobar_remove) (int how_many); @@ -247,11 +240,14 @@ struct t_weechat_plugin void *callback_data); struct t_hook *(*hook_print) (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer, - char *message, int strip_colors, + char *tags, char *message, + int strip_colors, int (*callback)(void *data, struct t_gui_buffer *buffer, - time_t date, char *prefix, - char *message), + time_t date, + int tags_count, + char **tags, + char *prefix, char *message), void *callback_data); struct t_hook *(*hook_signal) (struct t_weechat_plugin *plugin, char *signal, @@ -298,7 +294,8 @@ struct t_weechat_plugin void *close_callback_data); struct t_gui_buffer *(*buffer_search) (char *category, char *name); void (*buffer_close) (struct t_gui_buffer *buffer, int switch_to_another); - void *(*buffer_get) (struct t_gui_buffer *buffer, char *property); + char *(*buffer_get_string) (struct t_gui_buffer *buffer, char *property); + void *(*buffer_get_pointer) (struct t_gui_buffer *buffer, char *property); void (*buffer_set) (struct t_gui_buffer *buffer, char *property, char *value); @@ -403,6 +400,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); __case_sensitive) #define weechat_strcasestr(__string1, __string2) \ weechat_plugin->strcasestr(__string1, __string2) +#define weechat_string_match(__string, __mask, __case_sensitive) \ + weechat_plugin->string_match(__string, __mask, __case_sensitive) #define weechat_string_replace(__string, __search, __replace) \ weechat_plugin->string_replace(__string, __search, __replace) #define weechat_string_remove_quotes(__string, __quotes) \ @@ -415,6 +414,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); __max, __num_items) #define weechat_string_free_exploded(__exploded_string) \ weechat_plugin->string_free_exploded(__exploded_string) +#define weechat_string_build_with_exploded(__exploded_string, \ + __separator) \ + weechat_plugin->string_build_with_exploded(__exploded_string, \ + __separator) #define weechat_string_split_command(__command, __separator) \ weechat_plugin->string_split_command(__command, __separator) #define weechat_string_free_splitted_command(__splitted_command) \ @@ -559,9 +562,18 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); #define weechat_color(__color_name) \ weechat_plugin->color(__color_name) #define weechat_printf(__buffer, __message, __argz...) \ - weechat_plugin->printf_date(__buffer, 0, __message, ##__argz) + weechat_plugin->printf_date_tags(__buffer, 0, NULL, __message, \ + ##__argz) #define weechat_printf_date(__buffer, __date, __message, __argz...) \ - weechat_plugin->printf_date(__buffer, __date, __message, ##__argz) + weechat_plugin->printf_date_tags(__buffer, __date, NULL, \ + __message, ##__argz) +#define weechat_printf_tags(__buffer, __tags, __message, __argz...) \ + weechat_plugin->printf_date_tags(__buffer, 0, __tags, __message, \ + ##__argz) +#define weechat_printf_date_tags(__buffer, __date, __tags, __message, \ + __argz...) \ + weechat_plugin->printf_date_tags(__buffer, __date, __tags, \ + __message, ##__argz) #define weechat_infobar_printf(__delay, __color_name, __message, \ __argz...) \ weechat_plugin->infobar_printf(weechat_plugin, __delay, \ @@ -588,10 +600,11 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); weechat_plugin->hook_fd(weechat_plugin, __fd, __flag_read, \ __flag_write, __flag_exception, __callback, \ __data) -#define weechat_hook_print(__buffer, __msg, __stri__colors, __callback, \ - __data) \ - weechat_plugin->hook_print(weechat_plugin, __buffer, __msg, \ - __stri__colors, __callback, __data) +#define weechat_hook_print(__buffer, __tags, __msg, __strip__colors, \ + __callback, __data) \ + weechat_plugin->hook_print(weechat_plugin, __buffer, __tags, \ + __msg, __strip__colors, __callback, \ + __data) #define weechat_hook_signal(__signal, __callback, __data) \ weechat_plugin->hook_signal(weechat_plugin, __signal, __callback, \ __data) @@ -629,8 +642,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); weechat_plugin->buffer_search(NULL, NULL) #define weechat_buffer_close(__buffer, __switch_to_another) \ weechat_plugin->buffer_close(__buffer, __switch_to_another) -#define weechat_buffer_get(__buffer, __property) \ - weechat_plugin->buffer_get(__buffer, __property) +#define weechat_buffer_get_string(__buffer, __property) \ + weechat_plugin->buffer_get_string(__buffer, __property) +#define weechat_buffer_get_pointer(__buffer, __property) \ + weechat_plugin->buffer_get_pointer(__buffer, __property) #define weechat_buffer_set(__buffer, __property, __value) \ weechat_plugin->buffer_set(__buffer, __property, __value) |