diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index aeaf6c27..61de72ff 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -118,5 +118,5 @@ jobs: echo load perl >> irssi-test/startup echo load proxy >> irssi-test/startup echo ^quit >> irssi-test/startup - irssi-build/bin/irssi --home irssi-test | ~/render.pl + irssi-build/bin/irssi --home irssi-test | perl -Mutf8 -C ~/render.pl cat irc.log.* diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml index a32e335d..6325d671 100644 --- a/.github/workflows/cifuzz.yml +++ b/.github/workflows/cifuzz.yml @@ -19,13 +19,23 @@ jobs: matrix: sanitizer: [address, undefined, memory] steps: + - uses: actions/checkout@main + with: + path: irssi + - name: Docker build build_fuzzers container + run: | + # google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master + docker build -t build_fuzzers:actions -f "/home/runner/work/_actions/google/oss-fuzz/master/infra/build_fuzzers.Dockerfile" "/home/runner/work/_actions/google/oss-fuzz/master/infra" - name: Build Fuzzers (${{ matrix.sanitizer }}) id: build - uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master - with: - oss-fuzz-project-name: 'irssi' - dry-run: false - sanitizer: ${{ matrix.sanitizer }} + env: + OSS_FUZZ_PROJECT_NAME: 'irssi' + DRY_RUN: false + SANITIZER: ${{ matrix.sanitizer }} + PROJECT_SRC_PATH: /github/workspace/irssi + REPOSITORY: 'irssi' + run: | + docker run --workdir /github/workspace --rm -e OSS_FUZZ_PROJECT_NAME -e DRY_RUN -e SANITIZER -e PROJECT_SRC_PATH -e REPOSITORY -e WORKSPACE=/github/workspace -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "$GITHUB_WORKSPACE":"/github/workspace" build_fuzzers:actions - name: Run Fuzzers (${{ matrix.sanitizer }}) uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master with: diff --git a/NEWS b/NEWS index 1bdffd82..b3282761 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,274 @@ -v1.3-head 2021-xx-xx The Irssi team +v1.3.0-an 2021-09-05 Ailin Nemui + * /SET resolve_reverse_lookup setting was removed (#1135) + * Irssi will try to connect on IPv4 if IPv6 connection failed + (#1146). By Shivaram Lingamneni + * The display system now renders formats on the fly (#1079, + #1188, #1191, #1192, #1204, #1205, #1209, an#13, an#14, an#28, + an#29) + + This major change will break scripts that try to modify + printed text during "print text" signal (#1189). They need + to be ported to modify the text during "print format" + instead. It also breaks the usage of using /FORMAT to add + different colours to a line. Such usage needs to be ported + to using $expando variables instead. Affected scripts + include format_identify.pl, friends_peder.pl, nickcolor.pl, + nm.pl, people.pl + + The "gui print text finished" and "gui print text after + finished" signals gained a TEXT_DEST_REC *parameter in the + process. + + A new "gui render line text" signal is available to change + the rendering of a line + + * made the $Z expando (time) dynamic (#1087, #1207, #1208) + + This change breaks the usage of /SET timestamp_format to + supply a custom displayed time stamp. Affected scripts + include binary_time.pl + + * /HILIGHT -priority now affects which hilight rule gets + applied (#1228, #1232) + * The NAMES list is now hidden by default if there are more + than 18 users on the channel (an#7) + + To revert to the previous behaviour + + /SET show_names_on_join_limit -1 + + * -tls_verify is now enabled by default (#1170, an#18, #1309, + an#23) + + This may cause an ugly display of notls_verify in the output + of /SERVER LIST, even on plain-text connection, on old + configs. Kindly remove the "tls_verify = "no";" entries from + your config file manually. + + * Irssi will now attempt STARTTLS if advertised (#1170, #1312, + an#19) + + Use -disallow_starttls if you absolutely do not want this + + In order to check for a STARTTLS advertisement, Irssi will + now wait for a response (even an error) to CAP LS 302. If + your bouncer/server does not want to communicate before + receiving USER/PASS at all, use -nocap to disable the CAP + check. + + * Channel sync requests (WHO, MODE) are now sent "later" than + user commands. This should improve responsiveness to user + commands in the autojoin phase (an#26, an#32, an#33) + * Irssi is now using full paths in #include directives and + consequently does not add all directories to the include + path anymore (#1040) + * The Build System was ported to Meson (#1064, #1065, #1068, + #1071, #1072, #1073, #1074, #1075, #1084, #1085, #1118, #1166, + #1223, #1224, #1245, #1313, #1314, an#31) + * Scriptassist was changed to use a YAML database (#1163) + + It will tell you when you need to update your setting + + * /BIND shows all partial matches (#1155) + * Cleanup of unused functions (#1017, #1132, #1145, #1182, + #1246, #1264) + + Functions removed: + + NET_CALLBACK + NET_HOST_CALLBACK + RESOLVED_NAME_REC + net_gethostbyaddr_nonblock + net_connect_nonblock + [ SIMPLE_THREAD_REC, simple_init, simple_readpipe ] + hash_save_key + + Functions deprecated: + + dec2octal + g_timeval_cmp + get_timeval_diff + + Function names corrected: + + g_input -> i_input + g_istr -> i_istr + g_io_channel -> i_io_channel + g_hash_free_value -> i_hash_free_value + remove g_free_true + gslist -> i_slist + glog_func -> i_log_func + glist -> i_list + + If multi-version compatibility is desired, module authors + can find an example of backwards compatible code in + cdidier/irssi-xmpp#55 + + + Add MSGLEVEL_HIDDEN to Perl (#1044) + + Add $view->set_hidden_level and $view->remove_lines_by_level + to Perl (#1026) + + Add a /SET scrollback_max_age setting (#1022). By Heikki + Orsila + + Add /SET actlist_prefer_window_name (#1025) + + Add -window option to /CAT (#1023, #1159) + + Add an option to list specific sections with + + /SET -section lookandfeel + + (#1048) + + + Add support for IRCv3 CAP LS 302 (#1091) + + Add a new "print noformat" signal that goes together with + "print format" (#1088, #1192) + + Add support for IRCv3 extended-join. /SET show_extended_join + to enable (#1097, #1107, #1124) + + There are two new /FORMATs, join_extended and + join_extended_account, that theme writers need to take into + account if desired. + + + Add support for IRCv3 setname (#1093, #1104, #1254, GL#33, + #1104, #1254) + + Add support for IRCv3 account-notify (#1100, #1098, GL#33, + #1105, #1131). Credit to oss-fuzz + /SET show_account_notify to enable + + Add support for IRCv3 invite-notify (#1094) + + Add support for receiving IRCv3 message-tags (#576, #1090) + + Add support for sending IRCv3 message-tags (#1092) + + Add support for the oragono.io/maxline-2 CAP to increase IRC + protocol line length (#1092) + + Enable the znc.in/self-message CAP by default (#1123) + + Add support for IRCv3 away-notify. /SET away_notify_public + to enable (#1099, GL#33, #1105) + + Add support for IRCv3 chghost (#1096, GL#33, #1105) + + Add support for IRCv3 account-notify. + + Add support for IRCv3 server-time. /SET show_server_time to + enable (#1108) + + Add support for logging IRCv3 server-time. + /SET log_server_time to disable (#1318, an#16) + + Add IRCv3 features to signals.txt (#1111) + + In particular, "message join" now takes 2 additional + arguments, script and module authors must beware of this + change. + + + Show the unignore time in /IGNORE output (#1158, #1161) + + Add /SET quit_on_hup to make the behaviour of SIGHUP + configurable (#828, #1169). By Pinguin1234 + + Support numeric 489 as ERR_SECUREONLYCHAN (#1193, #1196). By + Michael Hansen + + Improve support for building Irssi in Termux-Android with + Meson (#1199) + + Add usermode key to Irssi::Irc::Chatnet in Perl (#1288). By + Jessica Sophie Porter + + Add format_string_expand and format_string_unexpand + functions to Perl (#1286) + + Add ...->format_create_dest(...)->printformat("format", + args...) and ...->printformat_module("module", "format", + args...) methods to Perl (#1284) + + You can avoid any CORE::GLOBAL::caller hacks using the + printformat_module method, especially sind that hack was not + safe during signal emissions + + + Add tracking of user accounts in the channel nicklist using + WHOX on join (#1250) + + Add auto-loading of the Perl and otr module from /SET + autoload_modules (#1295) + + Add /IGNORE ... NOHILIGHT to ignore some hilights (#1260) + + Do not beep on hidden lines with /SET beep_msg_level + ... -HIDDEN (#1259) + + Added /CS, /MS, /NS, and /OS aliases to the default config + (#1316). By Mathis Beer + + Allow -tls_ca{file,path} '' to unset an argument (#730, + #1060, an#30) + + Add a "server outgoing modify" signal to intercept outgoing + messages (#1148, #1151, an#15). Original by + JustAnotherArchivist + - remove some hard-coded 510 byte assumptions (#1086) + - Several fixes for error checks in SSL (#944, #1037, #943, + #1036). Reported by Chi Li + - Wrong variable tested in mask_match (#902, #1035) + - Fix bug where irssi-proxy with `?'-port would not reconnect + (#1041) + - Allow shrinking of /SET rawlog_lines (#957, #1020). By + Marcus "Teschi" Prinz + - Fix /WINDOW BALANCE warning (#1054) + - fix overflow when first command history entry expires + (#1070) + - begin modularising IRC module (#1067, #1112, #1113) + - fix some memory leaks in /DCC RESUME and settings_add + (#1077). By Zero King + - fix cut-off text with theme_indent module and /SET + indent_always OFF (#1078) + - fix the cap_queue order (#1095) + - add reference counted strings (#1089) + - Fix irc_op_public messages not triggering hilights (#354, + #891, #1129). By Dan Collins + - Fix /IGNORE not setting the right level in irc_op_public + messages (#1280). Credit to oss-fuzz + - Fix GTimeVal deprecation (#1141, #1144, #1145) + + If multi-version compatibility is desired, module authors + can find an example of backwards compatible code in + cdidier/irssi-xmpp#53 + + - Fix /IGNORE ... MODES NO_ACT not working (#1164) + - Deprecated -ssl* options are hidden from tab completion + (#1171) + - Make /SET actlist_sort a choice type (#1198) + - Fix crash from self-unloading script (#1206). By Thomas + Stagner + - Fix crash during Perl signal emission (#1233, #1234) + - Fix a case where empty lines or comments inside channels or + servers in the config would confuse Irssi (#1062, #1242, + #1243) + - Fix reported freezing in DCC GET on slow disks (#159, #1271) + - Fix message-tags parsing (#1274, #1275). Credit to oss-fuzz + - Fail redirects when receiving numeric 263 (RPL_TRYAGAIN) in + response to /WHO (#1283) + - Some updates to .gitignore (#1302). By Rene Kita + - Fix build on operating systems with X/Open Curses, version 2 + (#1305, #1308). By Nia Alarie (Regression introduced with + #1290, alternative fix for Irssi 1.2.3 no-term.h.patch) + - Fix otr module not using g_strndup, e.g. on Solaris 10 + (#1315). By Claes Nästén + - Fix cursor getting stuck for auto completions that changes + case (#1176, #1322, an#8). By ffrogman + - Restore operation of tag/* in /SET activity_hide_targets + (#1337, an#11) nb. the ::all syntax was working in Irssi 1.1 + and 1.2 (and continues to work) + - Fix /SERVER ADD -matrix -network my_matrix_network + (an#12). By Andrej Kacian + - Fix /SERVER ADD creating duplicated entries in the config + file (#1317, an#22) + - Fix critical when SASL user is set and SASL password is + empty (#1325, an#21) + - Misc fixes (#1106, #1141, #1272, #1297) + - Fuzz fixes (#1116, #1117, #1119, #1125, #1126, an#20) + - Build system fixes (#1101, #1102, #1069, #1140, #1181, #1253) + - Text and Help updates + - add -tls_* options to manual (#1029, #1030). By Jacob + V. Rasmussen + - missing targets in /MSG (#1032) + - wrong parameter in /ECHO (#1024) + - Spelling in OTR (#1047). By David Gall + - Clarify statusbar priority (#1049). By Marius Gedminas + - Document get_irssi_dir in Perl (#1051, #1052). By Alex + Shafer + - typo in /HILIGHT help (#1081). By DFrostByte + - improved clarity of your_nick_owned (#1138). By Mike Quin + - Update some URLs to https (#1163) + - Add documentation for escaping some characters (#1329, + #1330, an#9). By Guntbert Reiter + - Fix some typos (#1336, an#10). By Francis Mteo + - Infrastructure updates: + - Support for Github Actions (#1039, #1103, #1160, #1212, + #1231, #1252, #1261) + - Run clang-format on pull requests (#1172, #1173, #1184, + #1230, #1247, #1287) + - Run abidiff on pull requests (#1179, #1195) + - Test CI-Fuzz (#1279, #1304, an#17) v1.2.3 2021-04-11 The Irssi team - Fix the compilation of utf8proc (#1021) @@ -40,7 +310,7 @@ v1.2.3 2021-04-11 The Irssi team v1.2.2 2019-08-29 The Irssi team - Fix a use after free issue when receiving IRCv3 CAP - information from the server (GL#34) + information from the server (GL#34, GL!35) - Fix a crash during startup when windows weren't fully initialised yet (#1114, bdo#935813) diff --git a/README.md b/README.md index d1232764..21fa14e8 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ -# [Irssi](https://irssi.org/) +# Neırssi -![Build Status](https://github.com/irssi/irssi/workflows/Check%20Irssi/badge.svg?branch=master) +![Build Status](https://github.com/ailin-nemui/irssi/workflows/Check%20Irssi/badge.svg?branch=master) -Irssi is a modular chat client that is most commonly known for its -text mode user interface, but 80% of the code isn't text mode -specific. Irssi comes with IRC support built in, and there are -third party [ICB](https://github.com/jperkin/irssi-icb), +Neırssi is a modular text mode chat client mostly compatible with +[Irssi](https://irssi.org). It comes with IRC support built in, and +there are third party [ICB](https://github.com/jperkin/irssi-icb), [SILC](http://www.silcnet.org/), [XMPP](http://cybione.org/~irssi-xmpp/) (Jabber), [PSYC](http://about.psyc.eu/Irssyc) and @@ -14,14 +13,14 @@ available. ![irssi](https://user-images.githubusercontent.com/5665186/32180643-cf127f60-bd92-11e7-8aa2-882313ce1d8e.png) -## [Download information](https://irssi.org/download/) +## [Download information](https://ailin-nemui.github.io/irssi/Getting.html) #### Development source installation [Ninja](https://ninja-build.org/) 1.5 and [Meson](https://mesonbuild.com/) 0.49 ``` -git clone https://github.com/irssi/irssi +git clone https://github.com/ailin-nemui/irssi cd irssi meson Build ninja -C Build && sudo ninja -C Build install @@ -29,13 +28,13 @@ ninja -C Build && sudo ninja -C Build install #### Release source installation -* Download [release](https://github.com/irssi/irssi/releases) -* [Verify](https://irssi.org/download/#release-sources) signature +* Download [release](https://github.com/ailin-nemui/irssi/releases) +* Verify signature ``` tar xJf irssi-*.tar.xz cd irssi-* -./configure -make && sudo make install +meson Build +ninja -C Build && sudo ninja -C Build install ``` ### Requirements @@ -47,23 +46,23 @@ make && sudo make install #### See the [INSTALL](INSTALL) file for details -## [Documentation](https://irssi.org/documentation/) +## Documentation -* [Frequently Asked Questions](https://irssi.org/documentation/faq) -* [Startup How-To](https://irssi.org/documentation/startup) +* [New users guide](https://ailin-nemui.github.io/irssi/New-users.html) * Check the built-in `/HELP`, it has all the details on command syntax +* Other random Irssi documentation on https://irssi.org/documentation/ ## [Themes](https://irssi-import.github.io/themes/) ## [Scripts](https://scripts.irssi.org/) -## [Modules](https://irssi.org/modules/) +## [Modules](https://ailin-nemui.github.io/irssi/Modules.html) ## [Security information](https://irssi.org/security/) Please report security issues to staff@irssi.org. Thanks! -## [Bugs](https://github.com/irssi/irssi/issues) / Suggestions / [Contributing](https://irssi.org/development/) +## [Bugs](https://github.com/irssi/irssi/issues) / Suggestions / Contributing Check the GitHub issues if it is already listed in there; if not, open an issue on GitHub or send a mail to [staff@irssi.org](mailto:staff@irssi.org). diff --git a/docs/help/in/eval.in b/docs/help/in/eval.in index b2d4b625..b0c904b4 100644 --- a/docs/help/in/eval.in +++ b/docs/help/in/eval.in @@ -11,11 +11,17 @@ Evaluates the given commands and executes them; you can use internal variables and separate multiple commands by using the ';' character. + If the command contains a string with '$', '\' or ';' those characters + need to be escaped: + '$' -> '$$' + '\' -> '\\' (or even '\\\\', depending on where they are used) + ';' -> '\;' %9Examples:%9 /EVAL echo I am connected to ${S} on ${chatnet} as ${N} /EVAL echo My user privileges are +${usermode}; echo Let's party! + to print '1;2$3\4': /EVAL echo 1\;2$$3\\4 %9References:%9 diff --git a/docs/help/in/network.in b/docs/help/in/network.in index 0542bd7d..788c1c65 100644 --- a/docs/help/in/network.in +++ b/docs/help/in/network.in @@ -18,7 +18,8 @@ -usermode: Specifies the user modes to set on yourself. -autosendcmd: Specifies the commands, separated by the ';' character, and enclosed within two "'" characters, to perform after - connecting. + connecting. + (Some characters need to be escaped - see /help eval) -querychans: Specifies the maximum number of channels to put in one MODE or WHO command when synchronizing. -whois: Specifies the maximum number of nicknames in one WHOIS diff --git a/docs/help/in/otr.in b/docs/help/in/otr.in index f76a2d53..fcfcd875 100644 --- a/docs/help/in/otr.in +++ b/docs/help/in/otr.in @@ -51,7 +51,7 @@ GENKEY This process is done in a background worker and can take an arbitrary amount of time. The completion is checked when another irssi event is - catched. + caught. HELP Print this help. diff --git a/docs/help/in/window.in b/docs/help/in/window.in index aa133766..9a7a7b10 100644 --- a/docs/help/in/window.in +++ b/docs/help/in/window.in @@ -33,12 +33,12 @@ THEME: %|Applies or removes a per-window theme. GROW: %|Increase the size of the active split window by the specified number of lines. SHRINK: %|Decrease the size of the active split window by the specified number of lines. - SIZE: %|Set the current split window size to the specified numer of lines. + SIZE: %|Set the current split window size to the specified number of lines. BALANCE: %|Balance the heights of all split windows. HIDE: %|Hides the current split window, or the split window specified by number or item name. SHOW: %|Show the window specified by number or item name as a new split windows. It is made sticky when autostick_split_windows is turned on. UP: %|Set the split window left or above the current one active. At the top, wraps to the bottom. - DOWN: %|Set the split window right or below the current one active. At the bottom, wraps teft. + DOWN: %|Set the split window right or below the current one active. At the bottom, wraps left. LEFT: %|Go to the previous window numerically that is part of the current sticky group (or not part of any sticky group). RIGHT: %|Go to the next window numerically that is part of the current sticky group (or not part of any sticky group). STICK: %|Make the currently active window sticky, or stick the window specified by number to the currently visible split window. Or turn off stickyness of the currently active window or the window specified by number. diff --git a/docs/signals.txt b/docs/signals.txt index 1eefc7e0..6128084b 100644 --- a/docs/signals.txt +++ b/docs/signals.txt @@ -151,6 +151,7 @@ irc.c: "whois default event", SERVER_REC, char *args, char *sender_nick, char *sender_address "server incoming", SERVER_REC, char *data + "server outgoing modify", SERVER_REC, GString *data (for perl parser..) "redir ", SERVER_REC, char *args, char *sender_nick, char *sender_address @@ -358,6 +359,9 @@ gui-printtext.c: textbuffer-view.c "gui textbuffer line removed", TEXTBUFFER_VIEW_REC *view, LINE_REC *line, LINE_REC *prev_line +textbuffer-formats.c + "gui render line text", TEXT_DEST_REC, GString *str, LINE_INFO_META_REC + Perl ---- diff --git a/meson.build b/meson.build index 1a5182af..bd192a92 100644 --- a/meson.build +++ b/meson.build @@ -53,6 +53,8 @@ require_glib_internal = get_option('install-glib') == 'force' want_static_dependency = get_option('static-dependency') == 'yes' +package_version = get_option('PACKAGE_VERSION') != '' ? get_option('PACKAGE_VERSION') : meson.project_version() + chat_modules = ['irc'] run_command('mkdir', meson.current_build_dir() / incdir) @@ -273,7 +275,12 @@ endif dep += glib_dep dep += gmodule_dep -openssl_dep = dependency('openssl', static : want_static_dependency) +if glib_internal and want_static_dependency and want_fuzzer + openssl_proj = subproject('openssl', default_options : ['default_library=static', 'asm=disabled']) + openssl_dep = openssl_proj.get_variable('openssl_dep') +else + openssl_dep = dependency('openssl', static : want_static_dependency) +endif dep += openssl_dep ############ @@ -535,7 +542,7 @@ foreach h : headers endforeach conf.set('HAVE_LIBUTF8PROC', have_libutf8proc) -conf.set_quoted('PACKAGE_VERSION', meson.project_version()) +conf.set_quoted('PACKAGE_VERSION', package_version) conf.set_quoted('PACKAGE_TARNAME', meson.project_name()) configure_file(output : 'irssi-config.h', @@ -576,7 +583,11 @@ pc_requires = [] if not glib_internal pc_requires += glib_dep endif -pc.generate(filebase : 'irssi-1', name : 'Irssi', description : 'Irssi chat client', requires : pc_requires) +pc.generate(filebase : 'irssi-1', + name : 'Irssi', + description : 'Irssi chat client', + version : package_version, + requires : pc_requires) ########### # irssi.1 # diff --git a/meson_options.txt b/meson_options.txt index 5dc9c514..1013166d 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -15,3 +15,4 @@ option('static-dependency', type : 'combo', description : 'Request static depen option('install-glib', type : 'combo', description : 'Download and install GLib for you', choices : ['no', 'yes', 'force']) option('docdir', type : 'string', description : 'Documentation directory') option('fhs-prefix', type : 'string', description : 'System prefix for Termux') +option('PACKAGE_VERSION', type : 'string', description : 'Override PACKAGE_VERSION in tarballs') diff --git a/src/common.h b/src/common.h index bdbafca7..d2dd2f7c 100644 --- a/src/common.h +++ b/src/common.h @@ -6,7 +6,7 @@ #define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */ #define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */ -#define IRSSI_ABI_VERSION 36 +#define IRSSI_ABI_VERSION 41 #define DEFAULT_SERVER_ADD_PORT 6667 #define DEFAULT_SERVER_ADD_TLS_PORT 6697 diff --git a/src/core/expandos.c b/src/core/expandos.c index 0f317e51..da84b568 100644 --- a/src/core/expandos.c +++ b/src/core/expandos.c @@ -322,7 +322,7 @@ static char *expando_last_invite(SERVER_REC *server, void *item, int *free_ret) /* client version text string */ static char *expando_version(SERVER_REC *server, void *item, int *free_ret) { - return PACKAGE_VERSION; + return PACKAGE_VERSION "-an"; } /* current value of CMDCHARS */ diff --git a/src/core/log.c b/src/core/log.c index cb6f1edd..5bc953a1 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -204,11 +204,10 @@ static void log_rotate_check(LOG_REC *log) g_free(new_fname); } -void log_write_rec(LOG_REC *log, const char *str, int level) +void log_write_rec(LOG_REC *log, const char *str, int level, time_t now) { char *colorstr; struct tm *tm; - time_t now; int hour, day; g_return_if_fail(log != NULL); @@ -217,7 +216,8 @@ void log_write_rec(LOG_REC *log, const char *str, int level) if (log->handle == -1) return; - now = time(NULL); + if (now == (time_t) -1) + now = time(NULL); tm = localtime(&now); hour = tm->tm_hour; day = tm->tm_mday; @@ -282,8 +282,8 @@ LOG_ITEM_REC *log_item_find(LOG_REC *log, int type, const char *item, return NULL; } -void log_file_write(const char *server_tag, const char *item, int level, - const char *str, int no_fallbacks) +void log_file_write(const char *server_tag, const char *item, int level, time_t t, const char *str, + int no_fallbacks) { GSList *tmp, *fallbacks; char *tmpstr; @@ -309,7 +309,7 @@ void log_file_write(const char *server_tag, const char *item, int level, fallbacks = g_slist_append(fallbacks, rec); else if (log_item_find(rec, LOG_ITEM_TARGET, item, server_tag) != NULL) - log_write_rec(rec, str, level); + log_write_rec(rec, str, level, t); } if (!found && !no_fallbacks && fallbacks != NULL) { @@ -319,7 +319,7 @@ void log_file_write(const char *server_tag, const char *item, int level, g_strdup(str); for (tmp = fallbacks; tmp != NULL; tmp = tmp->next) - log_write_rec(tmp->data, tmpstr, level); + log_write_rec(tmp->data, tmpstr, level, t); g_free(tmpstr); } diff --git a/src/core/log.h b/src/core/log.h index 1c529670..19bca4f3 100644 --- a/src/core/log.h +++ b/src/core/log.h @@ -51,9 +51,9 @@ void log_item_destroy(LOG_REC *log, LOG_ITEM_REC *item); LOG_ITEM_REC *log_item_find(LOG_REC *log, int type, const char *item, const char *servertag); -void log_file_write(const char *server_tag, const char *item, int level, - const char *str, int no_fallbacks); -void log_write_rec(LOG_REC *log, const char *str, int level); +void log_file_write(const char *server_tag, const char *item, int level, time_t t, const char *str, + int no_fallbacks); +void log_write_rec(LOG_REC *log, const char *str, int level, time_t now); int log_start_logging(LOG_REC *log); void log_stop_logging(LOG_REC *log); diff --git a/src/core/misc.c b/src/core/misc.c index c66bbd6d..f0bbf4e0 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -95,7 +95,6 @@ int i_input_add_poll(int fd, int priority, int condition, GInputFunction functio #pragma GCC diagnostic ignored "-Wdeprecated-declarations" int g_timeval_cmp(const GTimeVal *tv1, const GTimeVal *tv2) { -#pragma GCC diagnostic pop if (tv1->tv_sec < tv2->tv_sec) return -1; if (tv1->tv_sec > tv2->tv_sec) @@ -105,11 +104,8 @@ int g_timeval_cmp(const GTimeVal *tv1, const GTimeVal *tv2) tv1->tv_usec > tv2->tv_usec ? 1 : 0; } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" long get_timeval_diff(const GTimeVal *tv1, const GTimeVal *tv2) { -#pragma GCC diagnostic pop long secs, usecs; secs = tv1->tv_sec - tv2->tv_sec; @@ -122,6 +118,22 @@ long get_timeval_diff(const GTimeVal *tv1, const GTimeVal *tv2) return usecs; } +#pragma GCC diagnostic pop + +#if GLIB_CHECK_VERSION(2, 56, 0) +/* nothing */ +#else +/* compatibility code for old GLib */ +GDateTime *g_date_time_new_from_iso8601(const gchar *iso_date, GTimeZone *default_tz) +{ + GTimeVal time; + if (g_time_val_from_iso8601(iso_date, &time)) { + return g_date_time_new_from_timeval_utc(&time); + } else { + return NULL; + } +} +#endif int find_substr(const char *list, const char *item) { diff --git a/src/core/misc.h b/src/core/misc.h index 76f5644b..622470f7 100644 --- a/src/core/misc.h +++ b/src/core/misc.h @@ -19,6 +19,13 @@ int g_timeval_cmp(const GTimeVal *tv1, const GTimeVal *tv2) G_GNUC_DEPRECATED; long get_timeval_diff(const GTimeVal *tv1, const GTimeVal *tv2) G_GNUC_DEPRECATED; #pragma GCC diagnostic pop +#if GLIB_CHECK_VERSION(2, 56, 0) +/* nothing */ +#else +/* compatibility code for old GLib */ +GDateTime *g_date_time_new_from_iso8601(const gchar *iso_date, GTimeZone *default_tz); +#endif + GSList *i_slist_find_string(GSList *list, const char *key); GSList *i_slist_find_icase_string(GSList *list, const char *key); GList *i_list_find_string(GList *list, const char *key); diff --git a/src/core/servers-setup.c b/src/core/servers-setup.c index 357e8ebe..82e5f6be 100644 --- a/src/core/servers-setup.c +++ b/src/core/servers-setup.c @@ -191,8 +191,10 @@ static void server_setup_fill_optlist(SERVER_CONNECT_REC *conn, GHashTable *optl /* ad-hoc TLS settings from command optlist */ if ((tmp = g_hash_table_lookup(optlist, "tls_cert")) != NULL || - (tmp = g_hash_table_lookup(optlist, "ssl_cert")) != NULL) + (tmp = g_hash_table_lookup(optlist, "ssl_cert")) != NULL) { conn->tls_cert = g_strdup(tmp); + conn->use_tls = TRUE; + } if ((tmp = g_hash_table_lookup(optlist, "tls_pkey")) != NULL || (tmp = g_hash_table_lookup(optlist, "ssl_pkey")) != NULL) conn->tls_pkey = g_strdup(tmp); @@ -220,10 +222,10 @@ static void server_setup_fill_optlist(SERVER_CONNECT_REC *conn, GHashTable *optl if (g_hash_table_lookup(optlist, "notls_verify") != NULL) conn->tls_verify = FALSE; if (g_hash_table_lookup(optlist, "tls_verify") != NULL || - g_hash_table_lookup(optlist, "ssl_verify") != NULL) + g_hash_table_lookup(optlist, "ssl_verify") != NULL) { conn->tls_verify = TRUE; - if ((conn->tls_cert != NULL && conn->tls_cert[0] != '\0') || conn->tls_verify) conn->use_tls = TRUE; + } if (g_hash_table_lookup(optlist, "notls") != NULL) conn->use_tls = FALSE; if (g_hash_table_lookup(optlist, "tls") != NULL || @@ -457,8 +459,9 @@ static SERVER_SETUP_REC *server_setup_read(CONFIG_NODE *node) port = config_node_get_int(node, "port", 0); chatnet = config_node_get_str(node, "chatnet", NULL); - if (server_setup_find(server, port, chatnet) != NULL) { - return NULL; + if ((rec = server_setup_find(server, port, chatnet)) != NULL && rec->port == port) { + /* duplicate server setup */ + server_setup_remove(rec); } rec = NULL; @@ -484,8 +487,9 @@ static SERVER_SETUP_REC *server_setup_read(CONFIG_NODE *node) rec->password = g_strdup(config_node_get_str(node, "password", NULL)); rec->use_tls = config_node_get_bool(node, "use_tls", FALSE) || config_node_get_bool(node, "use_ssl", FALSE); - rec->tls_verify = config_node_get_bool(node, "tls_verify", TRUE) || - config_node_get_bool(node, "ssl_verify", FALSE); + rec->tls_verify = config_node_find(node, "tls_verify") != NULL ? + config_node_get_bool(node, "tls_verify", TRUE) : + config_node_get_bool(node, "ssl_verify", TRUE); value = config_node_get_str(node, "tls_cert", NULL); if (value == NULL) @@ -548,7 +552,7 @@ static int compare_server_setup (CONFIG_NODE *node, SERVER_SETUP_REC *server) return -1; address = config_node_get_str(node, "address", NULL); - chatnet = config_node_get_str(node, "chatnet", NULL); + chatnet = config_node_get_str(node, "chatnet", ""); port = config_node_get_int(node, "port", 0); if (address == NULL || chatnet == NULL) { @@ -556,7 +560,7 @@ static int compare_server_setup (CONFIG_NODE *node, SERVER_SETUP_REC *server) } if (g_ascii_strcasecmp(address, server->address) != 0 || - g_ascii_strcasecmp(chatnet, server->chatnet) != 0 || + g_ascii_strcasecmp(chatnet, server->chatnet != NULL ? server->chatnet : "") != 0 || port != server->port) { return 1; } @@ -564,16 +568,20 @@ static int compare_server_setup (CONFIG_NODE *node, SERVER_SETUP_REC *server) return 0; } -static void server_setup_save(SERVER_SETUP_REC *rec) +static void server_setup_save(SERVER_SETUP_REC *rec, int old_port, const char *old_chatnet) { CONFIG_NODE *parent_node, *node; + SERVER_SETUP_REC search_rec = { 0 }; GSList *config_node; parent_node = iconfig_node_traverse("(servers", TRUE); /* Try to find this channel in the configuration */ - config_node = g_slist_find_custom(parent_node->value, rec, - (GCompareFunc)compare_server_setup); + search_rec.address = rec->address; + search_rec.chatnet = old_chatnet != NULL ? (char *) old_chatnet : rec->chatnet; + search_rec.port = old_port; + config_node = g_slist_find_custom(parent_node->value, &search_rec, + (GCompareFunc) compare_server_setup); if (config_node != NULL) /* Let's update this server record */ node = config_node->data; @@ -654,16 +662,23 @@ static void server_setup_destroy(SERVER_SETUP_REC *rec) g_free(rec); } -void server_setup_add(SERVER_SETUP_REC *rec) +void server_setup_modify(SERVER_SETUP_REC *rec, int old_port, const char *old_chatnet) { + g_return_if_fail(g_slist_find(setupservers, rec) != NULL); + rec->type = module_get_uniq_id("SERVER SETUP", 0); - if (g_slist_find(setupservers, rec) == NULL) - setupservers = g_slist_append(setupservers, rec); - server_setup_save(rec); + server_setup_save(rec, old_port, old_chatnet); signal_emit("server setup updated", 1, rec); } +void server_setup_add(SERVER_SETUP_REC *rec) +{ + if (g_slist_find(setupservers, rec) == NULL) + setupservers = g_slist_append(setupservers, rec); + server_setup_modify(rec, -1, NULL); +} + void server_setup_remove_chatnet(const char *chatnet) { GSList *tmp, *next; diff --git a/src/core/servers-setup.h b/src/core/servers-setup.h index f35c3873..742ed4dd 100644 --- a/src/core/servers-setup.h +++ b/src/core/servers-setup.h @@ -41,6 +41,7 @@ SERVER_SETUP_REC *server_setup_find(const char *address, int port, const char *chatnet); void server_setup_add(SERVER_SETUP_REC *rec); +void server_setup_modify(SERVER_SETUP_REC *rec, int old_port, const char *old_chatnet); void server_setup_remove(SERVER_SETUP_REC *rec); /* Remove servers attached to chatne */ diff --git a/src/core/servers.c b/src/core/servers.c index 159af0e1..30fc6844 100644 --- a/src/core/servers.c +++ b/src/core/servers.c @@ -369,7 +369,7 @@ void server_connect_init(SERVER_REC *server) server->type = module_get_uniq_id("SERVER", 0); server_ref(server); server->current_incoming_meta = - g_hash_table_new_full(g_str_hash, (GEqualFunc) g_strcmp0, + g_hash_table_new_full(g_str_hash, (GEqualFunc) g_str_equal, (GDestroyNotify) i_refstr_release, (GDestroyNotify) g_free); server->nick = g_strdup(server->connrec->nick); diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index 06ac124c..e2c4d2a9 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -104,7 +104,7 @@ char *auto_word_complete(const char *line, int *pos) /* check for words in autocompletion list */ replace = completion_find(word, TRUE); - if (replace == NULL) { + if (replace == NULL || (!g_strcmp0(replace, word))) { ret = NULL; g_string_free(result, TRUE); } else { diff --git a/src/fe-common/core/fe-channels.c b/src/fe-common/core/fe-channels.c index 8c914cb8..2d4e9ece 100644 --- a/src/fe-common/core/fe-channels.c +++ b/src/fe-common/core/fe-channels.c @@ -107,9 +107,14 @@ static void signal_window_item_changed(WINDOW_REC *window, WI_ITEM_REC *item) static void sig_channel_joined(CHANNEL_REC *channel) { - if (settings_get_bool("show_names_on_join") && - !channel->session_rejoin) - fe_channels_nicklist(channel, CHANNEL_NICKLIST_FLAG_ALL); + if (settings_get_bool("show_names_on_join") && !channel->session_rejoin) { + int limit = settings_get_int("show_names_on_join_limit"); + int flags = CHANNEL_NICKLIST_FLAG_ALL; + if (limit > 0 && g_hash_table_size(channel->nicks) > limit) { + flags |= CHANNEL_NICKLIST_FLAG_COUNT; + } + fe_channels_nicklist(channel, flags); + } } /* SYNTAX: JOIN [-window] [-invite] [-] [] */ @@ -625,6 +630,7 @@ void fe_channels_init(void) { settings_add_bool("lookandfeel", "autoclose_windows", TRUE); settings_add_bool("lookandfeel", "show_names_on_join", TRUE); + settings_add_int("lookandfeel", "show_names_on_join_limit", 18); settings_add_int("lookandfeel", "names_max_columns", 6); settings_add_int("lookandfeel", "names_max_width", 0); diff --git a/src/fe-common/core/fe-common-core.c b/src/fe-common/core/fe-common-core.c index 63df1698..1fcd5df1 100644 --- a/src/fe-common/core/fe-common-core.c +++ b/src/fe-common/core/fe-common-core.c @@ -500,7 +500,7 @@ gboolean strarray_find_dest(char **array, const TEXT_DEST_REC *dest) str += server_tag_len + 1; } - if (g_strcmp0(str, "") == 0 || g_strcmp0(str, "::all") == 0) { + if (g_strcmp0(str, "*") == 0 || g_strcmp0(str, "::all") == 0) { return TRUE; } else if (g_ascii_strcasecmp(str, dest->target) == 0) { return TRUE; diff --git a/src/fe-common/core/fe-log.c b/src/fe-common/core/fe-log.c index b5222059..984b3548 100644 --- a/src/fe-common/core/fe-log.c +++ b/src/fe-common/core/fe-log.c @@ -48,6 +48,7 @@ #define AUTOLOG_INACTIVITY_CLOSE (60*5) static int autolog_level; +static int log_server_time; static int autoremove_tag; static char *autolog_path; @@ -502,8 +503,8 @@ static void autolog_open_check(TEXT_DEST_REC *dest) autolog_open(server, server_tag, g_strcmp0(target, "*") ? target : deftarget); } -static void log_single_line(WINDOW_REC *window, const char *server_tag, - const char *target, int level, const char *text) +static void log_single_line(WINDOW_REC *window, const char *server_tag, const char *target, + int level, time_t t, const char *text) { char windownum[MAX_INT_STRLEN]; LOG_REC *log; @@ -514,15 +515,16 @@ static void log_single_line(WINDOW_REC *window, const char *server_tag, log = logs_find_item(LOG_ITEM_WINDOW_REFNUM, windownum, NULL, NULL); if (log != NULL) - log_write_rec(log, text, level); + log_write_rec(log, text, level, t); } - log_file_write(server_tag, target, level, text, FALSE); + log_file_write(server_tag, target, level, t, text, FALSE); } static void log_line(TEXT_DEST_REC *dest, const char *text) { char **lines, **tmp; + time_t t = (time_t) -1; if (dest->level == MSGLEVEL_NEVER) return; @@ -536,9 +538,18 @@ static void log_line(TEXT_DEST_REC *dest, const char *text) /* text may contain one or more lines, log wants to eat them one line at a time */ lines = g_strsplit(text, "\n", -1); + if (log_server_time && dest->meta != NULL) { + char *val; + if ((val = g_hash_table_lookup(dest->meta, "time")) != NULL) { + GDateTime *time; + if ((time = g_date_time_new_from_iso8601(val, NULL)) != NULL) { + t = g_date_time_to_unix(time); + g_date_time_unref(time); + } + } + } for (tmp = lines; *tmp != NULL; tmp++) - log_single_line(dest->window, dest->server_tag, - dest->target, dest->level, *tmp); + log_single_line(dest->window, dest->server_tag, dest->target, dest->level, t, *tmp); g_strfreev(lines); } @@ -720,6 +731,13 @@ static void read_settings(void) g_strfreev(autolog_ignore_targets); autolog_ignore_targets = g_strsplit(settings_get_str("autolog_ignore_targets"), " ", -1); + + log_server_time = settings_get_choice("log_server_time"); + if (log_server_time == 2) { + SETTINGS_REC *rec = settings_get_record("show_server_time"); + if (rec != NULL) + log_server_time = settings_get_bool("show_server_time"); + } } void fe_log_init(void) @@ -731,7 +749,8 @@ void fe_log_init(void) settings_add_bool("log", "autolog", FALSE); settings_add_bool("log", "autolog_colors", FALSE); settings_add_bool("log", "autolog_only_saved_channels", FALSE); - settings_add_str("log", "autolog_path", "~/irclogs/$tag/$0.log"); + settings_add_choice("log", "log_server_time", 2, "off;on;auto"); + settings_add_str("log", "autolog_path", "~/irclogs/$tag/$0.log"); settings_add_level("log", "autolog_level", "all -crap -clientcrap -ctcps"); settings_add_str("log", "log_theme", ""); settings_add_str("log", "autolog_ignore_targets", ""); diff --git a/src/fe-common/core/fe-server.c b/src/fe-common/core/fe-server.c index e0100618..78e7202c 100644 --- a/src/fe-common/core/fe-server.c +++ b/src/fe-common/core/fe-server.c @@ -91,7 +91,9 @@ static SERVER_SETUP_REC *create_server_setup(GHashTable *optlist) if (rec == NULL) rec = chat_protocol_get_default(); else { - chatnet = g_hash_table_lookup(optlist, rec->chatnet); + chatnet = g_hash_table_lookup(optlist, "network"); + if (chatnet == NULL && g_hash_table_lookup(optlist, rec->chatnet) != NULL) + chatnet = rec->chatnet; if (chatnet_find(chatnet) == NULL) { printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_UNKNOWN_CHATNET, chatnet); @@ -108,11 +110,11 @@ static SERVER_SETUP_REC *create_server_setup(GHashTable *optlist) static void cmd_server_add_modify(const char *data, gboolean add) { GHashTable *optlist; - SERVER_SETUP_REC *rec; - char *addr, *portstr, *password, *value, *chatnet; + SERVER_SETUP_REC *rec, *tmp; + char *addr, *portstr, *password, *value, *chatnet, *old_chatnet; void *free_arg; gboolean newrec; - int port; + int port, old_port, add_port; if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_OPTIONS, "server add", &optlist, &addr, &portstr, &password)) @@ -120,27 +122,39 @@ static void cmd_server_add_modify(const char *data, gboolean add) if (*addr == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); - value = g_hash_table_lookup(optlist, "port"); + port = old_port = -1; if (*portstr != '\0') - port = atoi(portstr); - else if (value != NULL && *value != '\0') - port = atoi(value); + port = add_port = atoi(portstr); else if (g_hash_table_lookup(optlist, "tls") || g_hash_table_lookup(optlist, "ssl")) - port = DEFAULT_SERVER_ADD_TLS_PORT; + add_port = DEFAULT_SERVER_ADD_TLS_PORT; else - port = DEFAULT_SERVER_ADD_PORT; + add_port = DEFAULT_SERVER_ADD_PORT; + + value = g_hash_table_lookup(optlist, "port"); + if (value != NULL && *value != '\0') + old_port = atoi(value); chatnet = g_hash_table_lookup(optlist, "network"); - rec = server_setup_find(addr, port, chatnet); + rec = server_setup_find(addr, old_port != -1 ? old_port : add_port, chatnet); + if (old_port == -1 && rec != NULL) + old_port = rec->port; - if (rec == NULL) { + if (port == -1) + port = old_port != -1 ? old_port : add_port; + + /* make sure the new port doesn't exist */ + tmp = server_setup_find(addr, port, chatnet); + if (tmp != NULL && tmp->port == port) + rec = tmp; + + if (rec == NULL || (rec->port != old_port && rec->port != port)) { newrec = TRUE; if (add == FALSE) { - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, - TXT_SETUPSERVER_NOT_FOUND, addr, port); + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_SETUPSERVER_NOT_FOUND, + addr, old_port == -1 ? port : old_port); cmd_params_free(free_arg); return; } @@ -154,8 +168,9 @@ static void cmd_server_add_modify(const char *data, gboolean add) rec->port = port; } else { newrec = FALSE; - if (*portstr != '\0' || g_hash_table_lookup(optlist, "port")) - rec->port = port; + old_chatnet = g_strdup(rec->chatnet); + old_port = rec->port; + rec->port = port; if (*password != '\0') g_free_and_null(rec->password); if (g_hash_table_lookup(optlist, "host")) { @@ -198,12 +213,16 @@ static void cmd_server_add_modify(const char *data, gboolean add) value = g_hash_table_lookup(optlist, "ssl_cafile"); if (value != NULL && *value != '\0') rec->tls_cafile = g_strdup(value); + else if (value != NULL && *value == '\0') + g_free_and_null(rec->tls_cafile); value = g_hash_table_lookup(optlist, "tls_capath"); if (value == NULL) value = g_hash_table_lookup(optlist, "ssl_capath"); if (value != NULL && *value != '\0') rec->tls_capath = g_strdup(value); + else if (value != NULL && *value == '\0') + g_free_and_null(rec->tls_capath); value = g_hash_table_lookup(optlist, "tls_ciphers"); if (value == NULL) @@ -259,7 +278,13 @@ static void cmd_server_add_modify(const char *data, gboolean add) signal_emit("server add fill", 3, rec, optlist, GINT_TO_POINTER(add)); - server_setup_add(rec); + if (newrec) { + server_setup_add(rec); + } else { + server_setup_modify(rec, old_port, old_chatnet); + g_free(old_chatnet); + } + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_SETUPSERVER_ADDED, addr, port); diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c index 51588afb..b660b616 100644 --- a/src/fe-common/core/formats.c +++ b/src/fe-common/core/formats.c @@ -34,6 +34,7 @@ #include #include #include +#include static const char *format_backs = "04261537"; static const char *format_fores = "kbgcrmyw"; @@ -46,6 +47,8 @@ static int hide_text_style, hide_server_tags, hide_colors; static int timestamp_level; static int timestamp_timeout; +static GHashTable *global_meta; + int format_find_tag(const char *module, const char *tag) { FORMAT_REC *formats; @@ -453,6 +456,27 @@ void format_read_arglist(va_list va, FORMAT_REC *format, } } +void format_dest_meta_stash(TEXT_DEST_REC *dest, const char *meta_key, const char *meta_value) +{ + g_hash_table_replace(dest->meta, i_refstr_intern(meta_key), g_strdup(meta_value)); +} + +const char *format_dest_meta_stash_find(TEXT_DEST_REC *dest, const char *meta_key) +{ + return g_hash_table_lookup(dest->meta, meta_key); +} + +void format_dest_meta_clear_all(TEXT_DEST_REC *dest) +{ + g_hash_table_remove_all(dest->meta); +} + +static void clear_global_meta(WINDOW_REC *window, TEXT_DEST_REC *dest) +{ + if (dest != NULL && dest->meta == global_meta) + g_hash_table_remove_all(global_meta); +} + void format_create_dest_tag_meta(TEXT_DEST_REC *dest, void *server, const char *server_tag, const char *target, int level, WINDOW_REC *window, GHashTable *meta) @@ -465,7 +489,7 @@ void format_create_dest_tag_meta(TEXT_DEST_REC *dest, void *server, const char * dest->level = level; dest->window = window != NULL ? window : window_find_closest(server, target, level); - dest->meta = meta; + dest->meta = meta != NULL ? meta : global_meta; } void format_create_dest_tag(TEXT_DEST_REC *dest, void *server, const char *server_tag, @@ -1705,12 +1729,18 @@ static void read_settings(void) void formats_init(void) { signal_gui_print_text = signal_get_uniq_id("gui print text"); + global_meta = + g_hash_table_new_full(g_str_hash, (GEqualFunc) g_str_equal, + (GDestroyNotify) i_refstr_release, (GDestroyNotify) g_free); read_settings(); signal_add("setup changed", (SIGNAL_FUNC) read_settings); + signal_add_last("gui print text finished", (SIGNAL_FUNC) clear_global_meta); } void formats_deinit(void) { + g_hash_table_destroy(global_meta); signal_remove("setup changed", (SIGNAL_FUNC) read_settings); + signal_remove("gui print text finished", (SIGNAL_FUNC) clear_global_meta); } diff --git a/src/fe-common/core/formats.h b/src/fe-common/core/formats.h index 12274638..5666c73b 100644 --- a/src/fe-common/core/formats.h +++ b/src/fe-common/core/formats.h @@ -63,10 +63,15 @@ typedef struct _TEXT_DEST_REC { int hilight_priority; char *hilight_color; - int flags; + int flags; /* PRINT_FLAG */ GHashTable *meta; } TEXT_DEST_REC; +typedef struct _LINE_INFO_META_REC { + gint64 server_time; + GHashTable *hash; +} LINE_INFO_META_REC; + #define window_get_theme(window) \ (window != NULL && (window)->theme != NULL ? \ (window)->theme : current_theme) @@ -116,12 +121,16 @@ char *format_get_line_start(THEME_REC *theme, TEXT_DEST_REC *dest, time_t t); void format_create_dest(TEXT_DEST_REC *dest, void *server, const char *target, int level, WINDOW_REC *window); -void format_create_dest_tag(TEXT_DEST_REC *dest, void *server, - const char *server_tag, const char *target, - int level, WINDOW_REC *window); +void format_create_dest_tag(TEXT_DEST_REC *dest, void *server, const char *server_tag, + const char *target, int level, WINDOW_REC *window); void format_newline(TEXT_DEST_REC *dest); +/* manipulate the meta table of a dest */ +void format_dest_meta_stash(TEXT_DEST_REC *dest, const char *meta_key, const char *meta_value); +const char *format_dest_meta_stash_find(TEXT_DEST_REC *dest, const char *meta_key); +void format_dest_meta_clear_all(TEXT_DEST_REC *dest); + /* Return how many characters in `str' must be skipped before `len' characters of text is skipped. */ int strip_real_length(const char *str, int len, diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index 153a7a15..d308bd04 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -323,6 +323,71 @@ void hilight_update_text_dest(TEXT_DEST_REC *dest, HILIGHT_REC *rec) static void hilight_print(int index, HILIGHT_REC *rec); +static void sig_render_line_text(TEXT_DEST_REC *dest, GString *str, LINE_INFO_META_REC *meta) +{ + char *color, *tmp, *tmp2; + + if (meta == NULL || meta->hash == NULL) + return; + + color = g_hash_table_lookup(meta->hash, "hilight-color"); + + if ((tmp = g_hash_table_lookup(meta->hash, "hilight-line")) != NULL) { + /* hilight whole line */ + + tmp = strip_codes(str->str); + + color = format_string_expand( + color != NULL ? color : settings_get_str("hilight_color"), NULL); + + g_string_truncate(str, 0); + g_string_append(str, color); + g_string_append(str, tmp); + + g_free(color); + g_free(tmp); + } else if ((tmp = g_hash_table_lookup(meta->hash, "hilight-start")) != NULL && + (tmp2 = g_hash_table_lookup(meta->hash, "hilight-end")) != NULL) { + /* hilight part of the line */ + int hilight_start, hilight_end; + int pos, color_pos, color_len; + char *middle; + GString *str2; + + hilight_start = atoi(tmp); + hilight_end = atoi(tmp2); + + /* start of the line */ + pos = strip_real_length(str->str, hilight_start, NULL, NULL); + + str2 = g_string_new_len(str->str, pos); + + /* color */ + color = format_string_expand( + color != NULL ? color : settings_get_str("hilight_color"), NULL); + g_string_append(str2, color); + g_free(color); + + /* middle of the line, stripped */ + middle = strip_codes(str->str + pos); + g_string_append_len(str2, middle, hilight_end - hilight_start); + g_free(middle); + + /* end of the line */ + pos = strip_real_length(str->str, hilight_end, &color_pos, &color_len); + if (color_pos > 0) { + g_string_append_len(str2, str->str + color_pos, color_len); + } else { + /* no colors in line, change back to default */ + g_string_append_c(str2, 4); + g_string_append_c(str2, FORMAT_STYLE_DEFAULTS); + } + g_string_append(str2, str->str + pos); + + g_string_assign(str, g_string_free(str2, FALSE)); + } +} + static void sig_print_text(TEXT_DEST_REC *dest, const char *text, const char *stripped) { @@ -372,39 +437,50 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *text, char *tmp = strip_codes(text); newstr = g_strconcat(color, tmp, NULL); g_free(tmp); + + format_dest_meta_stash(dest, "hilight-line", "\001"); } else { /* hilight part of the line */ - GString *tmp; - char *middle; + GString *str; + char *middle, *tmp; int pos, color_pos, color_len; /* start of the line */ pos = strip_real_length(text, hilight_start, NULL, NULL); - tmp = g_string_new_len(text, pos); + str = g_string_new_len(text, pos); /* color */ - g_string_append(tmp, color); + g_string_append(str, color); /* middle of the line, stripped */ middle = strip_codes(text + pos); - g_string_append_len(tmp, middle, hilight_len); + g_string_append_len(str, middle, hilight_len); g_free(middle); /* end of the line */ pos = strip_real_length(text, hilight_end, &color_pos, &color_len); if (color_pos > 0) { - g_string_append_len(tmp, text + color_pos, color_len); + g_string_append_len(str, text + color_pos, color_len); } else { /* no colors in line, change back to default */ - g_string_append_c(tmp, 4); - g_string_append_c(tmp, FORMAT_STYLE_DEFAULTS); + g_string_append_c(str, 4); + g_string_append_c(str, FORMAT_STYLE_DEFAULTS); } - g_string_append(tmp, text + pos); + g_string_append(str, text + pos); - newstr = tmp->str; - g_string_free(tmp, FALSE); + newstr = str->str; + g_string_free(str, FALSE); + + format_dest_meta_stash(dest, "hilight-start", + tmp = g_strdup_printf("%d", hilight_start)); + g_free(tmp); + format_dest_meta_stash(dest, "hilight-end", + tmp = g_strdup_printf("%d", hilight_end)); + g_free(tmp); } + if (hilight->color != NULL) + format_dest_meta_stash(dest, "hilight-color", hilight->color); signal_emit("print text", 3, dest, newstr, stripped); @@ -721,6 +797,7 @@ void hilight_text_init(void) read_hilight_config(); signal_add_first("print text", (SIGNAL_FUNC) sig_print_text); + signal_add("gui render line text", (SIGNAL_FUNC) sig_render_line_text); signal_add("setup reread", (SIGNAL_FUNC) read_hilight_config); signal_add("setup changed", (SIGNAL_FUNC) read_settings); @@ -735,6 +812,7 @@ void hilight_text_deinit(void) nickmatch_deinit(nickmatch); signal_remove("print text", (SIGNAL_FUNC) sig_print_text); + signal_remove("gui render line text", (SIGNAL_FUNC) sig_render_line_text); signal_remove("setup reread", (SIGNAL_FUNC) read_hilight_config); signal_remove("setup changed", (SIGNAL_FUNC) read_settings); diff --git a/src/fe-fuzz/server.c b/src/fe-fuzz/server.c index 83ce7bfa..b74a29b9 100644 --- a/src/fe-fuzz/server.c +++ b/src/fe-fuzz/server.c @@ -152,6 +152,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv) { args_execute(0, NULL); core_preinit((*argv)[0]); core_init(); + irssi_ssl_init(); irc_init(); fe_common_core_init(); fe_common_irc_init(); diff --git a/src/fe-text/module-formats.c b/src/fe-text/module-formats.c index 7cdc5654..e9d4fab9 100644 --- a/src/fe-text/module-formats.c +++ b/src/fe-text/module-formats.c @@ -84,11 +84,7 @@ FORMAT_REC gui_text_formats[] = { NULL, "Welcome", 0 }, { "irssi_banner", - " ___ _%:" - "|_ _|_ _ _____(_)%:" - " | || '_(_-<_-< |%:" - "|___|_| /__/__/_|%:" - "Irssi v$J - https://irssi.org", 0 }, + "Neırssi v$J", 0 }, { "welcome_firsttime", "- - - - - - - - - - - - - - - - - - - - - - - - - - - -\n" "Hi there! If this is your first time using Irssi, you%:" diff --git a/src/fe-text/textbuffer-formats.c b/src/fe-text/textbuffer-formats.c index 2aa06cb2..20abc0df 100644 --- a/src/fe-text/textbuffer-formats.c +++ b/src/fe-text/textbuffer-formats.c @@ -1,6 +1,7 @@ #include "module.h" #include #include +#include #include #include #include @@ -16,21 +17,7 @@ TEXT_BUFFER_REC *color_buf; gboolean scrollback_format; gboolean show_server_time; - -#if GLIB_CHECK_VERSION(2, 56, 0) -/* nothing */ -#else -/* compatibility code for old GLib */ -static GDateTime *g_date_time_new_from_iso8601(const gchar *iso_date, GTimeZone *default_tz) -{ - GTimeVal time; - if (g_time_val_from_iso8601(iso_date, &time)) { - return g_date_time_new_from_timeval_utc(&time); - } else { - return NULL; - } -} -#endif +int signal_gui_render_line_text; static void collector_free(GSList **collector) { @@ -102,7 +89,7 @@ static void format_rec_set_dest(TEXT_BUFFER_FORMAT_REC *rec, const TEXT_DEST_REC rec->flags = dest->flags & ~PRINT_FLAG_FORMAT; } -void textbuffer_meta_rec_free(TEXT_BUFFER_META_REC *rec) +void textbuffer_meta_rec_free(LINE_INFO_META_REC *rec) { if (rec == NULL) return; @@ -113,18 +100,18 @@ void textbuffer_meta_rec_free(TEXT_BUFFER_META_REC *rec) g_free(rec); } -static void meta_hash_create(struct _TEXT_BUFFER_META_REC *meta) +static void meta_hash_create(struct _LINE_INFO_META_REC *meta) { if (meta->hash == NULL) { - meta->hash = g_hash_table_new_full(g_str_hash, (GEqualFunc) g_strcmp0, + meta->hash = g_hash_table_new_full(g_str_hash, (GEqualFunc) g_str_equal, (GDestroyNotify) i_refstr_release, (GDestroyNotify) g_free); } } -static TEXT_BUFFER_META_REC *line_meta_create(GHashTable *meta_hash) +static LINE_INFO_META_REC *line_meta_create(GHashTable *meta_hash) { - struct _TEXT_BUFFER_META_REC *meta; + struct _LINE_INFO_META_REC *meta; GHashTableIter iter; const char *key; const char *val; @@ -132,7 +119,7 @@ static TEXT_BUFFER_META_REC *line_meta_create(GHashTable *meta_hash) if (meta_hash == NULL || g_hash_table_size(meta_hash) == 0) return NULL; - meta = g_new0(struct _TEXT_BUFFER_META_REC, 1); + meta = g_new0(struct _LINE_INFO_META_REC, 1); g_hash_table_iter_init(&iter, meta_hash); while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) { @@ -362,8 +349,8 @@ char *textbuffer_line_get_text(TEXT_BUFFER_REC *buffer, LINE_REC *line, gboolean THEME_REC *theme; int formatnum; TEXT_BUFFER_FORMAT_REC *format_rec; - TEXT_BUFFER_META_REC *meta; - char *str; + LINE_INFO_META_REC *meta; + char *tmp2; curr = line; line = NULL; @@ -396,6 +383,8 @@ char *textbuffer_line_get_text(TEXT_BUFFER_REC *buffer, LINE_REC *line, gboolean } if (text != NULL && *text != '\0') { + GString *str; + reference_time = curr->info.time; if (show_server_time && meta != NULL && meta->server_time != 0) { current_time = meta->server_time; @@ -403,18 +392,27 @@ char *textbuffer_line_get_text(TEXT_BUFFER_REC *buffer, LINE_REC *line, gboolean current_time = curr->info.time; } + str = g_string_new(text); + signal_emit_id(signal_gui_render_line_text, 3, &dest, str, meta); + if (g_strcmp0(text, str->str) == 0) { + g_string_free(str, TRUE); + } else { + g_free(text); + text = g_string_free(str, FALSE); + } + tmp = format_get_level_tag(theme, &dest); - str = !theme->info_eol ? format_add_linestart(text, tmp) : - format_add_lineend(text, tmp); + tmp2 = !theme->info_eol ? format_add_linestart(text, tmp) : + format_add_lineend(text, tmp); g_free_not_null(tmp); g_free_not_null(text); - text = str; + text = tmp2; tmp = format_get_line_start(theme, &dest, current_time); - str = !theme->info_eol ? format_add_linestart(text, tmp) : - format_add_lineend(text, tmp); + tmp2 = !theme->info_eol ? format_add_linestart(text, tmp) : + format_add_lineend(text, tmp); g_free_not_null(tmp); g_free_not_null(text); - text = str; + text = tmp2; /* str = g_strconcat(text, "\n", NULL); */ /* g_free(text); */ @@ -447,6 +445,8 @@ static void read_settings(void) void textbuffer_formats_init(void) { + signal_gui_render_line_text = signal_get_uniq_id("gui render line text"); + settings_add_bool("lookandfeel", "scrollback_format", TRUE); settings_add_bool("lookandfeel", "show_server_time", FALSE); diff --git a/src/fe-text/textbuffer-formats.h b/src/fe-text/textbuffer-formats.h index 17a907c1..86587563 100644 --- a/src/fe-text/textbuffer-formats.h +++ b/src/fe-text/textbuffer-formats.h @@ -2,11 +2,7 @@ #define IRSSI_FE_TEXT_TEXTBUFFER_FORMATS_H #include - -typedef struct _TEXT_BUFFER_META_REC { - gint64 server_time; - GHashTable *hash; -} TEXT_BUFFER_META_REC; +#include typedef struct _TEXT_BUFFER_FORMAT_REC { char *module; @@ -22,7 +18,7 @@ typedef struct _TEXT_BUFFER_FORMAT_REC { } TEXT_BUFFER_FORMAT_REC; void textbuffer_format_rec_free(TEXT_BUFFER_FORMAT_REC *rec); -void textbuffer_meta_rec_free(TEXT_BUFFER_META_REC *rec); +void textbuffer_meta_rec_free(LINE_INFO_META_REC *rec); char *textbuffer_line_get_text(TEXT_BUFFER_REC *buffer, LINE_REC *line, gboolean raw); void textbuffer_formats_init(void); void textbuffer_formats_deinit(void); diff --git a/src/fe-text/textbuffer.h b/src/fe-text/textbuffer.h index 5f5f9a27..6c72a569 100644 --- a/src/fe-text/textbuffer.h +++ b/src/fe-text/textbuffer.h @@ -24,7 +24,7 @@ typedef struct { int level; time_t time; char *text; - struct _TEXT_BUFFER_META_REC *meta; + struct _LINE_INFO_META_REC *meta; struct _TEXT_BUFFER_FORMAT_REC *format; } LINE_INFO_REC; diff --git a/src/irc/core/channels-query.c b/src/irc/core/channels-query.c index 6cf3dd2b..05c9768c 100644 --- a/src/irc/core/channels-query.c +++ b/src/irc/core/channels-query.c @@ -53,9 +53,9 @@ loop: /* here are the WHOX commands we send. the full spec can be found on [1]. (1) WHOX_CHANNEL_FULL_CMD for getting the user list when we join a channel. we request the fields - c (channel), u (user), h (host), n (nick), f (flags), d (hops), a (important, account!), and - r (the real name goes last because it os the only that can contain spaces.) we request all - those fields as they are also included in the "regular" WHO reply we would get without WHOX. + c (channel), u (user), h (host), n (nick), f (flags), d (hops), a (account), and r (the real + name goes last because it is the only that can contain spaces.) we request all those fields + as they are also included in the "regular" WHO reply we would get without WHOX. (2) WHOX_USERACCOUNT_CMD for getting the account names of people that joined. this code is obviously only used when we don't have extended-joins. we request n (nick) and a (account) @@ -265,7 +265,7 @@ static void query_send(IRC_SERVER_REC *server, int query) cmd = NULL; } - irc_send_cmd(server, cmd); + irc_send_cmd_later(server, cmd); g_free(chanstr); g_free(chanstr_commas); @@ -440,6 +440,7 @@ void irc_channels_query_purge_accountquery(IRC_SERVER_REC *server, const char *n g_free(cmd); server->cmdcount--; + server->cmdlater--; } else { prev = tmp->next; } @@ -528,7 +529,10 @@ static void sig_event_join(IRC_SERVER_REC *server, const char *data, const char } if (g_hash_table_size(chanrec->nicks) < settings_get_int("channel_max_who_sync") && - server->isupport != NULL && g_hash_table_lookup(server->isupport, "whox") != NULL) { + server->isupport != NULL && g_hash_table_lookup(server->isupport, "whox") != NULL && + server->split_servers == NULL && + g_hash_table_size(server->chanqueries->accountqueries) < + settings_get_int("account_max_chase")) { char *cmd; server_redirect_event(server, "who user", 1, nick, -1, "chanquery useraccount abort", /* failure signal */ @@ -538,7 +542,7 @@ static void sig_event_join(IRC_SERVER_REC *server, const char *data, const char cmd = g_strdup_printf(WHOX_USERACCOUNT_CMD, nick); g_hash_table_add(server->chanqueries->accountqueries, g_strdup(nick)); /* queue the command */ - irc_send_cmd_full(server, cmd, FALSE, FALSE, FALSE); + irc_send_cmd_later(server, cmd); g_free(cmd); } } @@ -635,6 +639,7 @@ void channels_query_init(void) { settings_add_bool("misc", "channel_sync", TRUE); settings_add_int("misc", "channel_max_who_sync", 1000); + settings_add_int("misc", "account_max_chase", 10); signal_add("server connected", (SIGNAL_FUNC) sig_connected); signal_add("server disconnected", (SIGNAL_FUNC) sig_disconnected); diff --git a/src/irc/core/irc-servers-setup.c b/src/irc/core/irc-servers-setup.c index 5299ef04..e9e38504 100644 --- a/src/irc/core/irc-servers-setup.c +++ b/src/irc/core/irc-servers-setup.c @@ -121,9 +121,9 @@ static void sig_server_setup_fill_chatnet(IRC_SERVER_CONNECT_REC *conn, if (ircnet->sasl_mechanism != NULL) { if (!g_ascii_strcasecmp(ircnet->sasl_mechanism, "plain")) { /* The PLAIN method needs both the username and the password */ - conn->sasl_mechanism = SASL_MECHANISM_PLAIN; if (ircnet->sasl_username != NULL && *ircnet->sasl_username && ircnet->sasl_password != NULL && *ircnet->sasl_password) { + conn->sasl_mechanism = SASL_MECHANISM_PLAIN; conn->sasl_username = g_strdup(ircnet->sasl_username); conn->sasl_password = g_strdup(ircnet->sasl_password); } else @@ -188,6 +188,7 @@ static void init_userinfo(void) static void sig_server_setup_read(IRC_SERVER_SETUP_REC *rec, CONFIG_NODE *node) { + int starttls; g_return_if_fail(rec != NULL); g_return_if_fail(node != NULL); @@ -197,7 +198,10 @@ static void sig_server_setup_read(IRC_SERVER_SETUP_REC *rec, CONFIG_NODE *node) rec->max_cmds_at_once = config_node_get_int(node, "cmds_max_at_once", 0); rec->cmd_queue_speed = config_node_get_int(node, "cmd_queue_speed", 0); rec->max_query_chans = config_node_get_int(node, "max_query_chans", 0); - rec->starttls = config_node_get_bool(node, "starttls", STARTTLS_NOTSET); + starttls = config_node_get_bool(node, "starttls", -1); + rec->starttls = starttls == -1 ? STARTTLS_NOTSET : + starttls == 0 ? STARTTLS_DISALLOW : + STARTTLS_ENABLED; if (rec->starttls == STARTTLS_ENABLED) { rec->use_tls = 0; } diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c index 676e8cb9..1c9f0cec 100644 --- a/src/irc/core/irc-servers.c +++ b/src/irc/core/irc-servers.c @@ -734,9 +734,9 @@ static int server_cmd_timeout(IRC_SERVER_REC *server, gint64 now) { REDIRECT_REC *redirect; GSList *link; + GString *str; long usecs; char *cmd; - int len; if (!IS_IRC_SERVER(server)) return 0; @@ -759,16 +759,20 @@ static int server_cmd_timeout(IRC_SERVER_REC *server, gint64 now) redirect = server->cmdqueue->next->data; /* send command */ - len = strlen(cmd); - irc_server_send_data(server, cmd, len); + str = g_string_new(cmd); + signal_emit("server outgoing modify", 2, server, str); + if (str->len) { + irc_server_send_data(server, str->str, str->len); - /* add to rawlog without [CR+]LF */ - if (len > 2 && cmd[len-2] == '\r') - cmd[len-2] = '\0'; - else if (cmd[len-1] == '\n') - cmd[len-1] = '\0'; - rawlog_output(server->rawlog, cmd); - server_redirect_command(server, cmd, redirect); + /* add to rawlog without [CR+]LF */ + if (str->len > 2 && str->str[str->len - 2] == '\r') + str->str[str->len - 2] = '\0'; + else if (str->str[str->len - 1] == '\n') + str->str[str->len - 1] = '\0'; + rawlog_output(server->rawlog, str->str); + server_redirect_command(server, str->str, redirect); + } + g_string_free(str, TRUE); /* remove from queue */ server->cmdqueue = g_slist_remove(server->cmdqueue, cmd); diff --git a/src/irc/core/irc-servers.h b/src/irc/core/irc-servers.h index 544baba9..93fa02a4 100644 --- a/src/irc/core/irc-servers.h +++ b/src/irc/core/irc-servers.h @@ -119,6 +119,7 @@ struct _IRC_SERVER_REC { there actually is, to make flood control remember how many messages can be sent before starting the flood control */ + int cmdlater; /* number of commands in queue to be sent later */ GSList *cmdqueue; /* command, redirection, ... */ gint64 wait_cmd; /* don't send anything to server before this */ gint64 last_cmd; /* last time command was sent to server */ diff --git a/src/irc/core/irc.c b/src/irc/core/irc.c index 628d7130..c17e2470 100644 --- a/src/irc/core/irc.c +++ b/src/irc/core/irc.c @@ -47,11 +47,11 @@ static void strip_params_colon(char *const); /* The core of the irc_send_cmd* functions. If `raw' is TRUE, the `cmd' won't be checked at all if it's 512 bytes or not, or if it contains line feeds or not. Use with extreme caution! */ -void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd, - int send_now, int immediate, int raw) +void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd, int irc_send_when, int raw) { GString *str; int len; + guint pos; gboolean server_supports_tag; g_return_if_fail(server != NULL); @@ -67,6 +67,14 @@ void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd, irc_servers_start_cmd_timeout(); server->cmdcount++; + pos = g_slist_length(server->cmdqueue); + if (server->cmdlater > pos / 2) { + server->cmdlater = pos / 2; + pos = 0; + } else { + pos -= 2 * server->cmdlater; + } + if (!raw) { const char *tmp = cmd; @@ -105,37 +113,42 @@ void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd, g_string_append(str, cmd); } - if (send_now) { - rawlog_output(server->rawlog, str->str); - server_redirect_command(server, str->str, server->redirect_next); - server->redirect_next = NULL; - } - if (!raw) { - /* Add CR+LF to command */ + /* Add CR+LF to command */ g_string_append_c(str, 13); g_string_append_c(str, 10); } - if (send_now) { - irc_server_send_data(server, str->str, str->len); - g_string_free(str, TRUE); - } else { + if (irc_send_when == IRC_SEND_NOW) { + signal_emit("server outgoing modify", 2, server, str); + if (str->len) { + irc_server_send_data(server, str->str, str->len); - /* add to queue */ - if (immediate) { - server->cmdqueue = g_slist_prepend(server->cmdqueue, - server->redirect_next); - server->cmdqueue = g_slist_prepend(server->cmdqueue, - g_string_free(str, FALSE)); - } else { - server->cmdqueue = g_slist_append(server->cmdqueue, - g_string_free(str, FALSE)); - server->cmdqueue = g_slist_append(server->cmdqueue, - server->redirect_next); + /* add to rawlog without [CR+]LF */ + if (str->len > 2 && str->str[str->len - 2] == '\r') + str->str[str->len - 2] = '\0'; + else if (str->str[str->len - 1] == '\n') + str->str[str->len - 1] = '\0'; + rawlog_output(server->rawlog, str->str); + server_redirect_command(server, str->str, server->redirect_next); } + g_string_free(str, TRUE); + } else if (irc_send_when == IRC_SEND_NEXT) { + /* add to queue */ + server->cmdqueue = g_slist_prepend(server->cmdqueue, server->redirect_next); + server->cmdqueue = g_slist_prepend(server->cmdqueue, g_string_free(str, FALSE)); + } else if (irc_send_when == IRC_SEND_NORMAL) { + server->cmdqueue = g_slist_insert(server->cmdqueue, server->redirect_next, pos); + server->cmdqueue = g_slist_insert(server->cmdqueue, g_string_free(str, FALSE), pos); + } else if (irc_send_when == IRC_SEND_LATER) { + server->cmdqueue = g_slist_append(server->cmdqueue, g_string_free(str, FALSE)); + server->cmdqueue = g_slist_append(server->cmdqueue, server->redirect_next); + server->cmdlater++; + } else { + g_warn_if_reached(); } - server->redirect_next = NULL; + + server->redirect_next = NULL; } /* Send command to IRC server */ @@ -149,7 +162,7 @@ void irc_send_cmd(IRC_SERVER_REC *server, const char *cmd) (server->cmdcount < server->max_cmds_at_once || server->cmd_queue_speed <= 0); - irc_send_cmd_full(server, cmd, send_now, FALSE, FALSE); + irc_send_cmd_full(server, cmd, send_now ? IRC_SEND_NOW : IRC_SEND_NORMAL, FALSE); } /* Send command to IRC server */ @@ -173,7 +186,7 @@ void irc_send_cmd_now(IRC_SERVER_REC *server, const char *cmd) { g_return_if_fail(cmd != NULL); - irc_send_cmd_full(server, cmd, TRUE, TRUE, FALSE); + irc_send_cmd_full(server, cmd, IRC_SEND_NOW, FALSE); } /* Send command to server putting it at the beginning of the queue of @@ -183,7 +196,15 @@ void irc_send_cmd_first(IRC_SERVER_REC *server, const char *cmd) { g_return_if_fail(cmd != NULL); - irc_send_cmd_full(server, cmd, FALSE, TRUE, FALSE); + irc_send_cmd_full(server, cmd, IRC_SEND_NEXT, FALSE); +} + +/* Send command to server putting it at the end of the queue. */ +void irc_send_cmd_later(IRC_SERVER_REC *server, const char *cmd) +{ + g_return_if_fail(cmd != NULL); + + irc_send_cmd_full(server, cmd, IRC_SEND_LATER, FALSE); } static char *split_nicks(const char *cmd, char **pre, char **nicks, char **post, int arg) diff --git a/src/irc/core/irc.h b/src/irc/core/irc.h index 8803f662..92fb4ccb 100644 --- a/src/irc/core/irc.h +++ b/src/irc/core/irc.h @@ -27,6 +27,13 @@ typedef struct _REDIRECT_REC REDIRECT_REC; extern char *current_server_event; /* current server event being processed */ +enum { + IRC_SEND_NOW, /* */ + IRC_SEND_NEXT, + IRC_SEND_NORMAL, + IRC_SEND_LATER +}; + /* Send command to IRC server */ void irc_send_cmd(IRC_SERVER_REC *server, const char *cmd); void irc_send_cmdv(IRC_SERVER_REC *server, const char *cmd, ...) G_GNUC_PRINTF (2, 3); @@ -42,11 +49,12 @@ void irc_send_cmd_now(IRC_SERVER_REC *server, const char *cmd); commands to send -- it will go out as soon as possible in accordance to the flood protection settings. */ void irc_send_cmd_first(IRC_SERVER_REC *server, const char *cmd); +/* Send command to server putting it at the end of the queue. */ +void irc_send_cmd_later(IRC_SERVER_REC *server, const char *cmd); /* The core of the irc_send_cmd* functions. If `raw' is TRUE, the `cmd' won't be checked at all if it's 512 bytes or not, or if it contains line feeds or not. Use with extreme caution! */ -void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd, - int send_now, int immediate, int raw); +void irc_send_cmd_full(IRC_SERVER_REC *server, const char *cmd, int irc_send_when, int raw); /* Extract a tag value from tags */ GHashTable *irc_parse_message_tags(const char *tags); diff --git a/src/irc/notifylist/notify-ison.c b/src/irc/notifylist/notify-ison.c index 32316038..809394c4 100644 --- a/src/irc/notifylist/notify-ison.c +++ b/src/irc/notifylist/notify-ison.c @@ -92,7 +92,7 @@ static void ison_send(IRC_SERVER_REC *server, GString *cmd) server_redirect_event(server, "ison", 1, NULL, -1, NULL, "event 303", "notifylist event", NULL); - irc_send_cmd(server, cmd->str); + irc_send_cmd_later(server, cmd->str); g_string_truncate(cmd, 0); } @@ -183,7 +183,9 @@ static void whois_send(IRC_SERVER_REC *server, const char *nicks, "", "event empty", NULL); g_free(str); - irc_send_cmdv(server, "WHOIS %s", whois_request); + str = g_strdup_printf("WHOIS %s", whois_request); + irc_send_cmd_later(server, str); + g_free(str); } static void whois_send_server(IRC_SERVER_REC *server, char *nick) diff --git a/src/perl/common/Log.xs b/src/perl/common/Log.xs index cdcdbd90..532095fb 100644 --- a/src/perl/common/Log.xs +++ b/src/perl/common/Log.xs @@ -54,10 +54,11 @@ log_close(log) Irssi::Log log void -log_write_rec(log, str, level) +log_write_rec(log, str, level, now = -1) Irssi::Log log char *str int level + time_t now void log_start_logging(log) diff --git a/src/perl/get-signals.pl b/src/perl/get-signals.pl index 12aebdba..f7675f1b 100755 --- a/src/perl/get-signals.pl +++ b/src/perl/get-signals.pl @@ -19,6 +19,8 @@ while (<>) { s/GList \* of ([^,]*)s/glistptr_\1/g; s/GSList of ([^,]*)s/gslist_\1/g; + s/GString \*[^,]*/gstring/g; + s/char \*[^,]*/string/g; s/ulong \*[^,]*/ulongptr/g; s/int \*[^,]*/intptr/g; @@ -52,12 +54,13 @@ while (<>) { CLIENT_REC => 'Irssi::Irc::Client', # fe-common - THEME_REC => 'Irssi::UI::Theme', - KEYINFO_REC => 'Irssi::UI::Keyinfo', - PROCESS_REC => 'Irssi::UI::Process', - TEXT_DEST_REC => 'Irssi::UI::TextDest', - WINDOW_REC => 'Irssi::UI::Window', - WI_ITEM_REC => 'iobject', + THEME_REC => 'Irssi::UI::Theme', + KEYINFO_REC => 'Irssi::UI::Keyinfo', + PROCESS_REC => 'Irssi::UI::Process', + TEXT_DEST_REC => 'Irssi::UI::TextDest', + LINE_INFO_META_REC => 'Irssi::UI::LineInfoMeta', + WINDOW_REC => 'Irssi::UI::Window', + WI_ITEM_REC => 'iobject', # fe-text TEXTBUFFER_VIEW_REC => 'Irssi::TextUI::TextBufferView', diff --git a/src/perl/irc/Server.xs b/src/perl/irc/Server.xs index fef3698f..63e3111a 100644 --- a/src/perl/irc/Server.xs +++ b/src/perl/irc/Server.xs @@ -86,6 +86,13 @@ send_raw_first(server, cmd) CODE: irc_send_cmd_first(server, cmd); +void +send_raw_later(server, cmd) + Irssi::Irc::Server server + char *cmd +CODE: + irc_send_cmd_later(server, cmd); + void send_raw_split(server, cmd, nickarg, max_nicks) Irssi::Irc::Server server diff --git a/src/perl/perl-signals.c b/src/perl/perl-signals.c index 9f49fba8..683b4c3f 100644 --- a/src/perl/perl-signals.c +++ b/src/perl/perl-signals.c @@ -86,7 +86,8 @@ void perl_signal_args_to_c(void (*callback)(void *, int, void **), void *cb_arg, unsigned long v_ulong; GSList *v_gslist; GList *v_glist; - } saved_args[SIGNAL_MAX_ARGUMENTS]; + GString *v_gstring; + } saved_args[SIGNAL_MAX_ARGUMENTS]; AV *aargs; void *p[SIGNAL_MAX_ARGUMENTS]; PERL_SIGNAL_ARGS_REC *rec; @@ -146,6 +147,12 @@ void perl_signal_args_to_c(void (*callback)(void *, int, void **), void *cb_arg, } else if (g_strcmp0(rec->args[n], "intptr") == 0) { saved_args[n].v_int = SvIV(SvRV(arg)); c_arg = &saved_args[n].v_int; + } else if (g_strcmp0(rec->args[n], "gstring") == 0) { + char *pv; + size_t len; + + pv = SvPV(SvRV(arg), len); + c_arg = saved_args[n].v_gstring = g_string_new_len(pv, len); } else if (strncmp(rec->args[n], "glistptr_", 9) == 0) { GList *gl; int is_str; @@ -220,6 +227,16 @@ void perl_signal_args_to_c(void (*callback)(void *, int, void **), void *cb_arg, SV *t = SvRV(arg); SvIOK_only(t); SvIV_set(t, saved_args[n].v_int); + } else if (g_strcmp0(rec->args[n], "gstring") == 0) { + GString *str; + SV *t; + + str = saved_args[n].v_gstring; + t = SvRV(arg); + SvPOK_only(t); + sv_setpvn(t, str->str, str->len); + + g_string_free(str, TRUE); } else if (strncmp(rec->args[n], "gslist_", 7) == 0) { g_slist_free(saved_args[n].v_gslist); } else if (strncmp(rec->args[n], "glistptr_", 9) == 0) { @@ -306,7 +323,10 @@ static void perl_call_signal(PERL_SCRIPT_REC *script, SV *func, perlarg = newSViv(*(unsigned long *) arg); else if (g_strcmp0(rec->args[n], "intptr") == 0) saved_args[n] = perlarg = newRV_noinc(newSViv(*(int *) arg)); - else if (g_strcmp0(rec->args[n], "formatnum_args") == 0 && n >= 3) { + else if (g_strcmp0(rec->args[n], "gstring") == 0) { + GString *str = arg; + saved_args[n] = perlarg = newRV_noinc(newSVpvn(str->str, str->len)); + } else if (g_strcmp0(rec->args[n], "formatnum_args") == 0 && n >= 3) { const THEME_REC *theme; const MODULE_THEME_REC *rec; const FORMAT_REC *formats; @@ -399,6 +419,7 @@ static void perl_call_signal(PERL_SCRIPT_REC *script, SV *func, if (SvTRUE(ERRSV)) { char *error = g_strdup(SvPV_nolen(ERRSV)); + perl_signal_remove_script(script); signal_emit("script error", 2, script, error); g_free(error); rec = NULL; @@ -415,8 +436,21 @@ static void perl_call_signal(PERL_SCRIPT_REC *script, SV *func, if (g_strcmp0(rec->args[n], "intptr") == 0) { int *val = arg; *val = SvIV(SvRV(saved_args[n])); + } else if (g_strcmp0(rec->args[n], "gstring") == 0) { + SV *os, *ns; + GString *str = arg; + + os = sv_2mortal(newSVpvn(str->str, str->len)); + ns = SvRV(saved_args[n]); + if (sv_cmp(os, ns) != 0) { + size_t len; + char *pv = SvPV(ns, len); + + g_string_truncate(str, 0); + g_string_append_len(str, pv, len); + } } else if (strncmp(rec->args[n], "glistptr_", 9) == 0) { - GList **ret = arg; + GList **ret = arg; GList *out = NULL; void *val; int count; diff --git a/src/perl/perl-sources.c b/src/perl/perl-sources.c index 9f5773f1..9f9ec6b5 100644 --- a/src/perl/perl-sources.c +++ b/src/perl/perl-sources.c @@ -83,6 +83,7 @@ static int perl_source_event(PERL_SOURCE_REC *rec) if (SvTRUE(ERRSV)) { char *error = g_strdup(SvPV_nolen(ERRSV)); + perl_source_remove_script(rec->script); signal_emit("script error", 2, rec->script, error); g_free(error); } diff --git a/src/perl/textui/TextBuffer.xs b/src/perl/textui/TextBuffer.xs index 6695eae0..655dbd3c 100644 --- a/src/perl/textui/TextBuffer.xs +++ b/src/perl/textui/TextBuffer.xs @@ -101,28 +101,10 @@ PPCODE: } XPUSHs(sv_2mortal(newRV_noinc((SV *) hv))); -void +Irssi::UI::LineInfoMeta textbuffer_line_get_meta(line) Irssi::TextUI::Line line -PREINIT: - HV *hv; - LINE_REC *l; - TEXT_BUFFER_META_REC *m; - GHashTableIter iter; - char *key; - char *val; -PPCODE: - hv = newHV(); - l = line->line; - if (l->info.meta != NULL) { - m = l->info.meta; - if (m->hash != NULL) { - g_hash_table_iter_init(&iter, m->hash); - while ( - g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) { - (void) hv_store(hv, key, strlen(key), new_pv(val), 0); - } - } - (void) hv_store(hv, "server_time", 11, newSViv(m->server_time), 0); - } - XPUSHs(sv_2mortal(newRV_noinc((SV *) hv))); +CODE: + RETVAL = line->line->info.meta; +OUTPUT: + RETVAL diff --git a/src/perl/ui/Formats.xs b/src/perl/ui/Formats.xs index c03e6bb5..0f8b59b7 100644 --- a/src/perl/ui/Formats.xs +++ b/src/perl/ui/Formats.xs @@ -156,3 +156,22 @@ print(dest, str) char *str CODE: printtext_dest(dest, "%s", str); + +#******************************* +MODULE = Irssi::UI::Formats PACKAGE = Irssi::UI::TextDest PREFIX = format_dest_ +#******************************* + +void +format_dest_meta_stash(dest, meta_key, meta_value) + Irssi::UI::TextDest dest + char *meta_key + char *meta_value + +char * +format_dest_meta_stash_find(dest, meta_key) + Irssi::UI::TextDest dest + char *meta_key +CODE: + RETVAL = (char *) format_dest_meta_stash_find(dest, meta_key); +OUTPUT: + RETVAL diff --git a/src/perl/ui/UI.xs b/src/perl/ui/UI.xs index 5ac3da4e..30b0f637 100644 --- a/src/perl/ui/UI.xs +++ b/src/perl/ui/UI.xs @@ -64,6 +64,26 @@ static void perl_text_dest_fill_hash(HV *hv, TEXT_DEST_REC *dest) (void) hv_store(hv, "hilight_color", 13, new_pv(dest->hilight_color), 0); } +static void perl_line_info_meta_fill_hash(HV *hv, LINE_INFO_META_REC *meta) +{ + GHashTableIter iter; + char *key; + char *val; + + if (meta != NULL) { + if (meta->hash != NULL) { + g_hash_table_iter_init(&iter, meta->hash); + while ( + g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) { + (void) hv_store(hv, key, strlen(key), new_pv(val), 0); + } + } + if (meta->server_time) { + (void) hv_store(hv, "server_time", 11, newSViv(meta->server_time), 0); + } + } +} + static void perl_exec_fill_hash(HV *hv, EXEC_WI_REC *item) { g_return_if_fail(hv != NULL); @@ -81,6 +101,7 @@ static PLAIN_OBJECT_INIT_REC fe_plains[] = { { "Irssi::UI::Process", (PERL_OBJECT_FUNC) perl_process_fill_hash }, { "Irssi::UI::Window", (PERL_OBJECT_FUNC) perl_window_fill_hash }, { "Irssi::UI::TextDest", (PERL_OBJECT_FUNC) perl_text_dest_fill_hash }, + { "Irssi::UI::LineInfoMeta", (PERL_OBJECT_FUNC) perl_line_info_meta_fill_hash }, { NULL, NULL } }; diff --git a/src/perl/ui/module.h b/src/perl/ui/module.h index 4e19d4c0..4106aec4 100644 --- a/src/perl/ui/module.h +++ b/src/perl/ui/module.h @@ -12,3 +12,4 @@ typedef WINDOW_REC *Irssi__UI__Window; typedef TEXT_DEST_REC *Irssi__UI__TextDest; typedef THEME_REC *Irssi__UI__Theme; typedef KEYINFO_REC *Irssi__UI__Keyinfo; +typedef LINE_INFO_META_REC *Irssi__UI__LineInfoMeta; diff --git a/src/perl/ui/typemap b/src/perl/ui/typemap index 2a16fe44..4afb273d 100644 --- a/src/perl/ui/typemap +++ b/src/perl/ui/typemap @@ -3,6 +3,7 @@ Irssi::UI::Theme T_PlainObj Irssi::UI::Window T_PlainObj Irssi::UI::Keyinfo T_PlainObj Irssi::UI::TextDest T_PlainObj +Irssi::UI::LineInfoMeta T_PlainObj INPUT diff --git a/subprojects/openssl.wrap b/subprojects/openssl.wrap new file mode 100644 index 00000000..4aaaba38 --- /dev/null +++ b/subprojects/openssl.wrap @@ -0,0 +1,14 @@ +[wrap-file] +directory = openssl-1.1.1l +source_url = https://www.openssl.org/source/openssl-1.1.1l.tar.gz +source_filename = openssl-1.1.1l.tar.gz +source_hash = 0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1 +patch_filename = openssl_1.1.1l-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/openssl_1.1.1l-1/get_patch +patch_hash = 670db31580039e06c17f48bcd31e489f453fe72c22006de6d693b9b033f1003a + +[provide] +libcrypto = libcrypto_dep +libssl = libssl_dep +openssl = openssl_dep +