From 1a75c8e1be58a25510642605dcd40c5c65e9c3f3 Mon Sep 17 00:00:00 2001 From: Berke Viktor Date: Wed, 24 Oct 2012 21:33:02 +0200 Subject: A lot more rebranding --- plugins/Makefile.am | 2 +- plugins/checksum/checksum.c | 2 +- plugins/dns/dns.c | 2 +- plugins/doat/doat.c | 2 +- plugins/ewc/ewc.c | 2 +- plugins/exec/exec.c | 2 +- plugins/fishlim/Makefile.am | 2 +- plugins/fishlim/fishlim-xp.vcxproj | 4 +- plugins/fishlim/fishlim-xp.vcxproj.filters | 4 +- plugins/fishlim/fishlim.vcxproj | 4 +- plugins/fishlim/fishlim.vcxproj.filters | 4 +- plugins/fishlim/keystore.c | 2 +- plugins/fishlim/plugin_hexchat.c | 292 +++++++ plugins/fishlim/plugin_hexchat.h | 31 + plugins/fishlim/plugin_xchat.c | 292 ------- plugins/fishlim/plugin_xchat.h | 31 - plugins/gtkpref/gtkpref.c | 2 +- plugins/hexchat-plugin.h | 381 +++++++++ plugins/hextray/callbacks.cpp | 8 +- plugins/hextray/hexchat.cpp | 320 ++++++++ plugins/hextray/hexchat.h | 32 + plugins/hextray/hextray-xp.vcxproj | 14 +- plugins/hextray/hextray-xp.vcxproj.filters | 10 +- plugins/hextray/hextray.cpp | 219 +++++ plugins/hextray/hextray.def | 3 + plugins/hextray/hextray.h | 77 ++ plugins/hextray/hextray.vcxproj | 14 +- plugins/hextray/hextray.vcxproj.filters | 10 +- plugins/hextray/resource.rc | 4 +- plugins/hextray/utility.cpp | 4 +- plugins/hextray/xchat.cpp | 320 -------- plugins/hextray/xchat.h | 32 - plugins/hextray/xtray.cpp | 219 ----- plugins/hextray/xtray.def | 3 - plugins/hextray/xtray.h | 77 -- plugins/lua/lua.c | 2 +- plugins/mailcheck/mailcheck.c | 2 +- plugins/mpcinfo/mpcInfo.c | 2 +- plugins/perl/perl.c | 2 +- plugins/plugin-conf.in | 4 +- plugins/plugin20.html | 54 +- plugins/python/python.c | 2 +- plugins/sasl/sasl.c | 2 +- plugins/sysinfo/sysinfo.cpp | 2 +- plugins/sysinfo/xsys.c | 2 +- plugins/tcl/tclplugin.c | 2 +- plugins/upd/upd.c | 2 +- plugins/winamp/winamp.c | 2 +- plugins/wmpa/hexchat-plugin.cpp | 590 ++++++++++++++ plugins/wmpa/hexchat-plugin.h | 368 +++++++++ plugins/wmpa/wmpa-xp.vcxproj | 4 +- plugins/wmpa/wmpa-xp.vcxproj.filters | 4 +- plugins/wmpa/wmpa.vcxproj | 4 +- plugins/wmpa/wmpa.vcxproj.filters | 4 +- plugins/wmpa/wmpadialog.cpp | 2 +- plugins/wmpa/xchat-plugin.cpp | 590 -------------- plugins/wmpa/xchat-plugin.h | 368 --------- plugins/xchat-plugin.h | 381 --------- plugins/xdcc/xdcc.c | 4 +- src/common/Makefile.am | 16 +- src/common/cfgfiles.c | 4 +- src/common/cfgfiles.h | 2 +- src/common/chanopt.c | 4 +- src/common/common-xp.vcxproj | 8 +- src/common/common-xp.vcxproj.filters | 8 +- src/common/common.vcxproj | 8 +- src/common/common.vcxproj.filters | 8 +- src/common/ctcp.c | 4 +- src/common/dcc.c | 4 +- src/common/hexchat-plugin.h | 381 +++++++++ src/common/hexchat.c | 1207 ++++++++++++++++++++++++++++ src/common/hexchat.h | 595 ++++++++++++++ src/common/hexchatc.h | 39 + src/common/identd.c | 4 +- src/common/ignore.c | 4 +- src/common/inbound.c | 4 +- src/common/modes.c | 4 +- src/common/msproxy.c | 4 +- src/common/notify.c | 4 +- src/common/outbound.c | 4 +- src/common/plugin-timer.c | 2 +- src/common/plugin.c | 6 +- src/common/proto-irc.c | 4 +- src/common/server.c | 4 +- src/common/servlist.c | 4 +- src/common/text.c | 4 +- src/common/url.c | 4 +- src/common/userlist.c | 4 +- src/common/util.c | 4 +- src/common/xchat-plugin.h | 381 --------- src/common/xchat.c | 1207 ---------------------------- src/common/xchat.h | 595 -------------- src/common/xchatc.h | 39 - src/fe-gtk/about.c | 4 +- src/fe-gtk/ascii.c | 4 +- src/fe-gtk/banlist.c | 4 +- src/fe-gtk/chanlist.c | 4 +- src/fe-gtk/chanview-tree.c | 4 +- src/fe-gtk/dccgui.c | 4 +- src/fe-gtk/editlist.c | 4 +- src/fe-gtk/fe-gtk.c | 4 +- src/fe-gtk/fkeys.c | 4 +- src/fe-gtk/gtkutil.c | 4 +- src/fe-gtk/ignoregui.c | 2 +- src/fe-gtk/joind.c | 4 +- src/fe-gtk/maingui.c | 4 +- src/fe-gtk/menu.c | 4 +- src/fe-gtk/notifygui.c | 2 +- src/fe-gtk/palette.c | 2 +- src/fe-gtk/pixmaps.c | 2 +- src/fe-gtk/plugin-tray.c | 6 +- src/fe-gtk/plugingui.c | 6 +- src/fe-gtk/rawlog.c | 4 +- src/fe-gtk/search.c | 4 +- src/fe-gtk/servlistgui.c | 4 +- src/fe-gtk/setup.c | 4 +- src/fe-gtk/sexy-spell-entry.c | 2 +- src/fe-gtk/textgui.c | 4 +- src/fe-gtk/urlgrab.c | 4 +- src/fe-gtk/userlistgui.c | 4 +- src/fe-gtk/xtext.c | 4 +- src/fe-text/fe-text.c | 4 +- 122 files changed, 4755 insertions(+), 4755 deletions(-) create mode 100644 plugins/fishlim/plugin_hexchat.c create mode 100644 plugins/fishlim/plugin_hexchat.h delete mode 100644 plugins/fishlim/plugin_xchat.c delete mode 100644 plugins/fishlim/plugin_xchat.h create mode 100644 plugins/hexchat-plugin.h create mode 100644 plugins/hextray/hexchat.cpp create mode 100644 plugins/hextray/hexchat.h create mode 100644 plugins/hextray/hextray.cpp create mode 100644 plugins/hextray/hextray.def create mode 100644 plugins/hextray/hextray.h delete mode 100644 plugins/hextray/xchat.cpp delete mode 100644 plugins/hextray/xchat.h delete mode 100644 plugins/hextray/xtray.cpp delete mode 100644 plugins/hextray/xtray.def delete mode 100644 plugins/hextray/xtray.h create mode 100644 plugins/wmpa/hexchat-plugin.cpp create mode 100644 plugins/wmpa/hexchat-plugin.h delete mode 100644 plugins/wmpa/xchat-plugin.cpp delete mode 100644 plugins/wmpa/xchat-plugin.h delete mode 100644 plugins/xchat-plugin.h create mode 100644 src/common/hexchat-plugin.h create mode 100644 src/common/hexchat.c create mode 100644 src/common/hexchat.h create mode 100644 src/common/hexchatc.h delete mode 100644 src/common/xchat-plugin.h delete mode 100644 src/common/xchat.c delete mode 100644 src/common/xchat.h delete mode 100644 src/common/xchatc.h diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 4a9cee09..9ca89e34 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -3,7 +3,7 @@ EXTRA_DIST = plugin20.html Make.plugin plugin-conf.in \ xdcc/xdcc.c \ xdcc/Makefile.am -noinst_HEADERS = xchat-plugin.h +noinst_HEADERS = hexchat-plugin.h if DO_PYTHON pythondir = python diff --git a/plugins/checksum/checksum.c b/plugins/checksum/checksum.c index f84eb243..d00249b0 100644 --- a/plugins/checksum/checksum.c +++ b/plugins/checksum/checksum.c @@ -46,7 +46,7 @@ #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #define BUFSIZE 32768 #define DEFAULT_LIMIT 256 /* default size is 256 MiB */ diff --git a/plugins/dns/dns.c b/plugins/dns/dns.c index eb9bb7ee..2d269b01 100644 --- a/plugins/dns/dns.c +++ b/plugins/dns/dns.c @@ -43,7 +43,7 @@ #include #endif -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #include "thread.h" #define HELP "Usage: DNS \n" diff --git a/plugins/doat/doat.c b/plugins/doat/doat.c index a0b5707a..237233c5 100644 --- a/plugins/doat/doat.c +++ b/plugins/doat/doat.c @@ -8,7 +8,7 @@ #include #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" static xchat_plugin *ph; diff --git a/plugins/ewc/ewc.c b/plugins/ewc/ewc.c index 78e7e9ac..55366da6 100644 --- a/plugins/ewc/ewc.c +++ b/plugins/ewc/ewc.c @@ -17,8 +17,8 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "xchat-plugin.h" #include +#include "hexchat-plugin.h" static xchat_plugin *ph; /* plugin handle */ static int enable = 1; diff --git a/plugins/exec/exec.c b/plugins/exec/exec.c index 28bc13ab..6f3e350c 100644 --- a/plugins/exec/exec.c +++ b/plugins/exec/exec.c @@ -23,7 +23,7 @@ #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" static xchat_plugin *ph; /* plugin handle */ static const char name[] = "Exec"; diff --git a/plugins/fishlim/Makefile.am b/plugins/fishlim/Makefile.am index 0f1189de..913312b5 100644 --- a/plugins/fishlim/Makefile.am +++ b/plugins/fishlim/Makefile.am @@ -3,7 +3,7 @@ EXTRA_DIST = INSTALL LICENSE README libdir = $(hexchatlibdir)/plugins lib_LTLIBRARIES = fishlim.la -fishlim_la_SOURCES = fish.c irc.c keystore.c misc.c plugin_xchat.c +fishlim_la_SOURCES = fish.c irc.c keystore.c misc.c plugin_hexchat.c fishlim_la_LDFLAGS = -avoid-version -module fishlim_la_LIBADD = AM_CPPFLAGS = $(COMMON_CFLAGS) -I$(srcdir)/.. diff --git a/plugins/fishlim/fishlim-xp.vcxproj b/plugins/fishlim/fishlim-xp.vcxproj index cabcd2fd..8b19b6dc 100644 --- a/plugins/fishlim/fishlim-xp.vcxproj +++ b/plugins/fishlim/fishlim-xp.vcxproj @@ -106,14 +106,14 @@ - + - + diff --git a/plugins/fishlim/fishlim-xp.vcxproj.filters b/plugins/fishlim/fishlim-xp.vcxproj.filters index 72e9f017..7c13733b 100644 --- a/plugins/fishlim/fishlim-xp.vcxproj.filters +++ b/plugins/fishlim/fishlim-xp.vcxproj.filters @@ -35,7 +35,7 @@ Header Files - + Header Files @@ -52,7 +52,7 @@ Source Files - + Source Files diff --git a/plugins/fishlim/fishlim.vcxproj b/plugins/fishlim/fishlim.vcxproj index 0f166e6b..91925660 100644 --- a/plugins/fishlim/fishlim.vcxproj +++ b/plugins/fishlim/fishlim.vcxproj @@ -103,14 +103,14 @@ - + - + diff --git a/plugins/fishlim/fishlim.vcxproj.filters b/plugins/fishlim/fishlim.vcxproj.filters index 72e9f017..7c13733b 100644 --- a/plugins/fishlim/fishlim.vcxproj.filters +++ b/plugins/fishlim/fishlim.vcxproj.filters @@ -35,7 +35,7 @@ Header Files - + Header Files @@ -52,7 +52,7 @@ Source Files - + Source Files diff --git a/plugins/fishlim/keystore.c b/plugins/fishlim/keystore.c index c54b5dca..9f1c446e 100644 --- a/plugins/fishlim/keystore.c +++ b/plugins/fishlim/keystore.c @@ -29,7 +29,7 @@ #include "fish.h" #include "misc.h" #include "keystore.h" -#include "plugin_xchat.h" +#include "plugin_hexchat.h" static char *keystore_password = NULL; diff --git a/plugins/fishlim/plugin_hexchat.c b/plugins/fishlim/plugin_hexchat.c new file mode 100644 index 00000000..91ba1d6a --- /dev/null +++ b/plugins/fishlim/plugin_hexchat.c @@ -0,0 +1,292 @@ +/* + + Copyright (c) 2010-2011 Samuel Lidén Borell + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +*/ + +#include +#include +#include + +// #pragma GCC visibility push(default) +#include "hexchat-plugin.h" +#define XCHAT_MAX_WORDS 32 +// #pragma GCC visibility pop + +//#define EXPORT __attribute((visibility("default"))) +//#define EXPORT + +#include "fish.h" +#include "keystore.h" +#include "irc.h" + +static const char plugin_name[] = "FiSHLiM"; +static const char plugin_desc[] = "Encryption plugin for the FiSH protocol. Less is More!"; +static const char plugin_version[] = "0.0.16"; + +static const char usage_setkey[] = "Usage: SETKEY [] , sets the key for a channel or nick"; +static const char usage_delkey[] = "Usage: DELKEY , deletes the key for a channel or nick"; + +static xchat_plugin *ph; + + +/** + * Returns the path to the key store file. + */ +gchar *get_config_filename() { + return g_build_filename(xchat_get_info(ph, "xchatdirfs"), "addon_fishlim.conf", NULL); +} + +/** + * Appends data to a string. Returns true if there was sufficient memory. + * Frees *s and returns false if an error occurs. + */ +static bool append(char **s, size_t *length, const char *data) { + size_t datalen = strlen(data); + char *extended = realloc(*s, *length + datalen + 1); + if (!extended) { + free(*s); + return false; + } + memcpy(extended + *length, data, datalen + 1); + *s = extended; + *length += datalen; + return true; +} + + +/*static int handle_debug(char *word[], char *word_eol[], void *userdata) { + xchat_printf(ph, "debug incoming: "); + for (size_t i = 1; word[i] != NULL && word[i][0] != '\0'; i++) { + xchat_printf(ph, ">%s< ", word[i]); + } + xchat_printf(ph, "\n"); + return XCHAT_EAT_NONE; +}*/ + +/** + * Called when a message is to be sent. + */ +static int handle_outgoing(char *word[], char *word_eol[], void *userdata) { + const char *own_nick; + // Encrypt the message if possible + const char *channel = xchat_get_info(ph, "channel"); + char *encrypted = fish_encrypt_for_nick(channel, word_eol[1]); + if (!encrypted) return XCHAT_EAT_NONE; + + // Display message + own_nick = xchat_get_info(ph, "nick"); + xchat_emit_print(ph, "Your Message", own_nick, word_eol[1], NULL); + + // Send message + xchat_commandf(ph, "PRIVMSG %s :+OK %s", channel, encrypted); + + free(encrypted); + return XCHAT_EAT_XCHAT; +} + +/** + * Called when a channel message or private message is received. + */ +static int handle_incoming(char *word[], char *word_eol[], void *userdata) { + const char *prefix; + const char *command; + const char *recipient; + const char *encrypted; + const char *peice; + char *sender_nick; + char *decrypted; + char *message; + size_t w; + size_t ew; + size_t uw; + size_t length; + + if (!irc_parse_message((const char **)word, &prefix, &command, &w)) + return XCHAT_EAT_NONE; + + // Topic (command 332) has an extra parameter + if (!strcmp(command, "332")) w++; + + // Look for encrypted data + for (ew = w+1; ew < XCHAT_MAX_WORDS-1; ew++) { + const char *s = (ew == w+1 ? word[ew]+1 : word[ew]); + if (strcmp(s, "+OK") == 0 || strcmp(s, "mcps") == 0) goto has_encrypted_data; + } + return XCHAT_EAT_NONE; + has_encrypted_data: ; + // Extract sender nick and recipient nick/channel + sender_nick = irc_prefix_get_nick(prefix); + recipient = word[w]; + + // Try to decrypt with these (the keys are searched for in the key store) + encrypted = word[ew+1]; + decrypted = fish_decrypt_from_nick(recipient, encrypted); + if (!decrypted) decrypted = fish_decrypt_from_nick(sender_nick, encrypted); + + // Check for error + if (!decrypted) goto decrypt_error; + + // Build unecrypted message + message = NULL; + length = 0; + if (!append(&message, &length, "RECV")) goto decrypt_error; + + for (uw = 1; uw < XCHAT_MAX_WORDS; uw++) { + if (word[uw][0] != '\0' && !append(&message, &length, " ")) goto decrypt_error; + + if (uw == ew) { + // Add the encrypted data + peice = decrypted; + uw++; // Skip "OK+" + + if (ew == w+1) { + // Prefix with colon, which gets stripped out otherwise + if (!append(&message, &length, ":")) goto decrypt_error; + } + + } else { + // Add unencrypted data (for example, a prefix from a bouncer or bot) + peice = word[uw]; + } + + if (!append(&message, &length, peice)) goto decrypt_error; + } + free(decrypted); + + // Simulate unencrypted message + //xchat_printf(ph, "simulating: %s\n", message); + xchat_command(ph, message); + + free(message); + free(sender_nick); + return XCHAT_EAT_XCHAT; + + decrypt_error: + free(decrypted); + free(sender_nick); + return XCHAT_EAT_NONE; +} + +/** + * Command handler for /setkey + */ +static int handle_setkey(char *word[], char *word_eol[], void *userdata) { + const char *nick; + const char *key; + + // Check syntax + if (*word[2] == '\0') { + xchat_printf(ph, "%s\n", usage_setkey); + return XCHAT_EAT_XCHAT; + } + + if (*word[3] == '\0') { + // /setkey password + nick = xchat_get_info(ph, "channel"); + key = word_eol[2]; + } else { + // /setkey #channel password + nick = word[2]; + key = word_eol[3]; + } + + // Set password + if (keystore_store_key(nick, key)) { + xchat_printf(ph, "Stored key for %s\n", nick); + } else { + xchat_printf(ph, "\00305Failed to store key in blow.ini\n", nick, key); + } + + return XCHAT_EAT_XCHAT; +} + +/** + * Command handler for /delkey + */ +static int handle_delkey(char *word[], char *word_eol[], void *userdata) { + const char *nick; + + // Check syntax + if (*word[2] == '\0' || *word[3] != '\0') { + xchat_printf(ph, "%s\n", usage_delkey); + return XCHAT_EAT_XCHAT; + } + + nick = word_eol[2]; + + // Delete the given nick from the key store + if (keystore_delete_nick(nick)) { + xchat_printf(ph, "Deleted key for %s\n", nick); + } else { + xchat_printf(ph, "\00305Failed to delete key in blow.ini!\n", nick); + } + + return XCHAT_EAT_XCHAT; +} + +/** + * Returns the plugin name version information. + */ +void xchat_plugin_get_info(const char **name, const char **desc, + const char **version, void **reserved) { + *name = plugin_name; + *desc = plugin_desc; + *version = plugin_version; +} + +/** + * Plugin entry point. + */ +int xchat_plugin_init(xchat_plugin *plugin_handle, + const char **name, + const char **desc, + const char **version, + char *arg) { + ph = plugin_handle; + + /* Send our info to XChat */ + *name = plugin_name; + *desc = plugin_desc; + *version = plugin_version; + + /* Register commands */ + xchat_hook_command(ph, "SETKEY", XCHAT_PRI_NORM, handle_setkey, usage_setkey, NULL); + xchat_hook_command(ph, "DELKEY", XCHAT_PRI_NORM, handle_delkey, usage_delkey, NULL); + + /* Add handlers */ + xchat_hook_command(ph, "", XCHAT_PRI_NORM, handle_outgoing, NULL, NULL); + xchat_hook_server(ph, "NOTICE", XCHAT_PRI_NORM, handle_incoming, NULL); + xchat_hook_server(ph, "PRIVMSG", XCHAT_PRI_NORM, handle_incoming, NULL); + //xchat_hook_server(ph, "RAW LINE", XCHAT_PRI_NORM, handle_debug, NULL); + xchat_hook_server(ph, "TOPIC", XCHAT_PRI_NORM, handle_incoming, NULL); + xchat_hook_server(ph, "332", XCHAT_PRI_NORM, handle_incoming, NULL); + + xchat_printf(ph, "%s plugin loaded\n", plugin_name); + /* Return success */ + return 1; +} + +int xchat_plugin_deinit(void) { + xchat_printf(ph, "%s plugin unloaded\n", plugin_name); + return 1; +} + diff --git a/plugins/fishlim/plugin_hexchat.h b/plugins/fishlim/plugin_hexchat.h new file mode 100644 index 00000000..04a1f4ff --- /dev/null +++ b/plugins/fishlim/plugin_hexchat.h @@ -0,0 +1,31 @@ +/* + + Copyright (c) 2010 Samuel Lidén Borell + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + +*/ + +#ifndef PLUGIN_HEXCHAT_H +#define PLUGIN_HEXCHAT_H + +gchar *get_config_filename(); + +#endif + diff --git a/plugins/fishlim/plugin_xchat.c b/plugins/fishlim/plugin_xchat.c deleted file mode 100644 index ff75fa93..00000000 --- a/plugins/fishlim/plugin_xchat.c +++ /dev/null @@ -1,292 +0,0 @@ -/* - - Copyright (c) 2010-2011 Samuel Lidén Borell - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -*/ - -#include -#include -#include - -// #pragma GCC visibility push(default) -#include "xchat-plugin.h" -#define XCHAT_MAX_WORDS 32 -// #pragma GCC visibility pop - -//#define EXPORT __attribute((visibility("default"))) -//#define EXPORT - -#include "fish.h" -#include "keystore.h" -#include "irc.h" - -static const char plugin_name[] = "FiSHLiM"; -static const char plugin_desc[] = "Encryption plugin for the FiSH protocol. Less is More!"; -static const char plugin_version[] = "0.0.16"; - -static const char usage_setkey[] = "Usage: SETKEY [] , sets the key for a channel or nick"; -static const char usage_delkey[] = "Usage: DELKEY , deletes the key for a channel or nick"; - -static xchat_plugin *ph; - - -/** - * Returns the path to the key store file. - */ -gchar *get_config_filename() { - return g_build_filename(xchat_get_info(ph, "xchatdirfs"), "addon_fishlim.conf", NULL); -} - -/** - * Appends data to a string. Returns true if there was sufficient memory. - * Frees *s and returns false if an error occurs. - */ -static bool append(char **s, size_t *length, const char *data) { - size_t datalen = strlen(data); - char *extended = realloc(*s, *length + datalen + 1); - if (!extended) { - free(*s); - return false; - } - memcpy(extended + *length, data, datalen + 1); - *s = extended; - *length += datalen; - return true; -} - - -/*static int handle_debug(char *word[], char *word_eol[], void *userdata) { - xchat_printf(ph, "debug incoming: "); - for (size_t i = 1; word[i] != NULL && word[i][0] != '\0'; i++) { - xchat_printf(ph, ">%s< ", word[i]); - } - xchat_printf(ph, "\n"); - return XCHAT_EAT_NONE; -}*/ - -/** - * Called when a message is to be sent. - */ -static int handle_outgoing(char *word[], char *word_eol[], void *userdata) { - const char *own_nick; - // Encrypt the message if possible - const char *channel = xchat_get_info(ph, "channel"); - char *encrypted = fish_encrypt_for_nick(channel, word_eol[1]); - if (!encrypted) return XCHAT_EAT_NONE; - - // Display message - own_nick = xchat_get_info(ph, "nick"); - xchat_emit_print(ph, "Your Message", own_nick, word_eol[1], NULL); - - // Send message - xchat_commandf(ph, "PRIVMSG %s :+OK %s", channel, encrypted); - - free(encrypted); - return XCHAT_EAT_XCHAT; -} - -/** - * Called when a channel message or private message is received. - */ -static int handle_incoming(char *word[], char *word_eol[], void *userdata) { - const char *prefix; - const char *command; - const char *recipient; - const char *encrypted; - const char *peice; - char *sender_nick; - char *decrypted; - char *message; - size_t w; - size_t ew; - size_t uw; - size_t length; - - if (!irc_parse_message((const char **)word, &prefix, &command, &w)) - return XCHAT_EAT_NONE; - - // Topic (command 332) has an extra parameter - if (!strcmp(command, "332")) w++; - - // Look for encrypted data - for (ew = w+1; ew < XCHAT_MAX_WORDS-1; ew++) { - const char *s = (ew == w+1 ? word[ew]+1 : word[ew]); - if (strcmp(s, "+OK") == 0 || strcmp(s, "mcps") == 0) goto has_encrypted_data; - } - return XCHAT_EAT_NONE; - has_encrypted_data: ; - // Extract sender nick and recipient nick/channel - sender_nick = irc_prefix_get_nick(prefix); - recipient = word[w]; - - // Try to decrypt with these (the keys are searched for in the key store) - encrypted = word[ew+1]; - decrypted = fish_decrypt_from_nick(recipient, encrypted); - if (!decrypted) decrypted = fish_decrypt_from_nick(sender_nick, encrypted); - - // Check for error - if (!decrypted) goto decrypt_error; - - // Build unecrypted message - message = NULL; - length = 0; - if (!append(&message, &length, "RECV")) goto decrypt_error; - - for (uw = 1; uw < XCHAT_MAX_WORDS; uw++) { - if (word[uw][0] != '\0' && !append(&message, &length, " ")) goto decrypt_error; - - if (uw == ew) { - // Add the encrypted data - peice = decrypted; - uw++; // Skip "OK+" - - if (ew == w+1) { - // Prefix with colon, which gets stripped out otherwise - if (!append(&message, &length, ":")) goto decrypt_error; - } - - } else { - // Add unencrypted data (for example, a prefix from a bouncer or bot) - peice = word[uw]; - } - - if (!append(&message, &length, peice)) goto decrypt_error; - } - free(decrypted); - - // Simulate unencrypted message - //xchat_printf(ph, "simulating: %s\n", message); - xchat_command(ph, message); - - free(message); - free(sender_nick); - return XCHAT_EAT_XCHAT; - - decrypt_error: - free(decrypted); - free(sender_nick); - return XCHAT_EAT_NONE; -} - -/** - * Command handler for /setkey - */ -static int handle_setkey(char *word[], char *word_eol[], void *userdata) { - const char *nick; - const char *key; - - // Check syntax - if (*word[2] == '\0') { - xchat_printf(ph, "%s\n", usage_setkey); - return XCHAT_EAT_XCHAT; - } - - if (*word[3] == '\0') { - // /setkey password - nick = xchat_get_info(ph, "channel"); - key = word_eol[2]; - } else { - // /setkey #channel password - nick = word[2]; - key = word_eol[3]; - } - - // Set password - if (keystore_store_key(nick, key)) { - xchat_printf(ph, "Stored key for %s\n", nick); - } else { - xchat_printf(ph, "\00305Failed to store key in blow.ini\n", nick, key); - } - - return XCHAT_EAT_XCHAT; -} - -/** - * Command handler for /delkey - */ -static int handle_delkey(char *word[], char *word_eol[], void *userdata) { - const char *nick; - - // Check syntax - if (*word[2] == '\0' || *word[3] != '\0') { - xchat_printf(ph, "%s\n", usage_delkey); - return XCHAT_EAT_XCHAT; - } - - nick = word_eol[2]; - - // Delete the given nick from the key store - if (keystore_delete_nick(nick)) { - xchat_printf(ph, "Deleted key for %s\n", nick); - } else { - xchat_printf(ph, "\00305Failed to delete key in blow.ini!\n", nick); - } - - return XCHAT_EAT_XCHAT; -} - -/** - * Returns the plugin name version information. - */ -void xchat_plugin_get_info(const char **name, const char **desc, - const char **version, void **reserved) { - *name = plugin_name; - *desc = plugin_desc; - *version = plugin_version; -} - -/** - * Plugin entry point. - */ -int xchat_plugin_init(xchat_plugin *plugin_handle, - const char **name, - const char **desc, - const char **version, - char *arg) { - ph = plugin_handle; - - /* Send our info to XChat */ - *name = plugin_name; - *desc = plugin_desc; - *version = plugin_version; - - /* Register commands */ - xchat_hook_command(ph, "SETKEY", XCHAT_PRI_NORM, handle_setkey, usage_setkey, NULL); - xchat_hook_command(ph, "DELKEY", XCHAT_PRI_NORM, handle_delkey, usage_delkey, NULL); - - /* Add handlers */ - xchat_hook_command(ph, "", XCHAT_PRI_NORM, handle_outgoing, NULL, NULL); - xchat_hook_server(ph, "NOTICE", XCHAT_PRI_NORM, handle_incoming, NULL); - xchat_hook_server(ph, "PRIVMSG", XCHAT_PRI_NORM, handle_incoming, NULL); - //xchat_hook_server(ph, "RAW LINE", XCHAT_PRI_NORM, handle_debug, NULL); - xchat_hook_server(ph, "TOPIC", XCHAT_PRI_NORM, handle_incoming, NULL); - xchat_hook_server(ph, "332", XCHAT_PRI_NORM, handle_incoming, NULL); - - xchat_printf(ph, "%s plugin loaded\n", plugin_name); - /* Return success */ - return 1; -} - -int xchat_plugin_deinit(void) { - xchat_printf(ph, "%s plugin unloaded\n", plugin_name); - return 1; -} - diff --git a/plugins/fishlim/plugin_xchat.h b/plugins/fishlim/plugin_xchat.h deleted file mode 100644 index d606526d..00000000 --- a/plugins/fishlim/plugin_xchat.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - - Copyright (c) 2010 Samuel Lidén Borell - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - -*/ - -#ifndef XCHAT_PLUGIN_H -#define XCHAT_PLUGIN_H - -gchar *get_config_filename(); - -#endif - diff --git a/plugins/gtkpref/gtkpref.c b/plugins/gtkpref/gtkpref.c index 84f51726..1f6241c1 100644 --- a/plugins/gtkpref/gtkpref.c +++ b/plugins/gtkpref/gtkpref.c @@ -22,7 +22,7 @@ #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" static xchat_plugin *ph; /* plugin handle */ diff --git a/plugins/hexchat-plugin.h b/plugins/hexchat-plugin.h new file mode 100644 index 00000000..43621f78 --- /dev/null +++ b/plugins/hexchat-plugin.h @@ -0,0 +1,381 @@ +/* You can distribute this header with your plugins for easy compilation */ +#ifndef HEXCHAT_PLUGIN_H +#define HEXCHAT_PLUGIN_H + +#include + +#define XCHAT_IFACE_MAJOR 1 +#define XCHAT_IFACE_MINOR 9 +#define XCHAT_IFACE_MICRO 11 +#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \ + (XCHAT_IFACE_MINOR * 100) + \ + (XCHAT_IFACE_MICRO)) + +#define XCHAT_PRI_HIGHEST 127 +#define XCHAT_PRI_HIGH 64 +#define XCHAT_PRI_NORM 0 +#define XCHAT_PRI_LOW (-64) +#define XCHAT_PRI_LOWEST (-128) + +#define XCHAT_FD_READ 1 +#define XCHAT_FD_WRITE 2 +#define XCHAT_FD_EXCEPTION 4 +#define XCHAT_FD_NOTSOCKET 8 + +#define XCHAT_EAT_NONE 0 /* pass it on through! */ +#define XCHAT_EAT_XCHAT 1 /* don't let xchat see this event */ +#define XCHAT_EAT_PLUGIN 2 /* don't let other plugins see this event */ +#define XCHAT_EAT_ALL (XCHAT_EAT_XCHAT|XCHAT_EAT_PLUGIN) /* don't let anything see this event */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xchat_plugin xchat_plugin; +typedef struct _xchat_list xchat_list; +typedef struct _xchat_hook xchat_hook; +#ifndef PLUGIN_C +typedef struct _xchat_context xchat_context; +#endif + +#ifndef PLUGIN_C +struct _xchat_plugin +{ + /* these are only used on win32 */ + xchat_hook *(*xchat_hook_command) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + const char *help_text, + void *userdata); + xchat_hook *(*xchat_hook_server) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_print) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_timer) (xchat_plugin *ph, + int timeout, + int (*callback) (void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_fd) (xchat_plugin *ph, + int fd, + int flags, + int (*callback) (int fd, int flags, void *user_data), + void *userdata); + void *(*xchat_unhook) (xchat_plugin *ph, + xchat_hook *hook); + void (*xchat_print) (xchat_plugin *ph, + const char *text); + void (*xchat_printf) (xchat_plugin *ph, + const char *format, ...); + void (*xchat_command) (xchat_plugin *ph, + const char *command); + void (*xchat_commandf) (xchat_plugin *ph, + const char *format, ...); + int (*xchat_nickcmp) (xchat_plugin *ph, + const char *s1, + const char *s2); + int (*xchat_set_context) (xchat_plugin *ph, + xchat_context *ctx); + xchat_context *(*xchat_find_context) (xchat_plugin *ph, + const char *servname, + const char *channel); + xchat_context *(*xchat_get_context) (xchat_plugin *ph); + const char *(*xchat_get_info) (xchat_plugin *ph, + const char *id); + int (*xchat_get_prefs) (xchat_plugin *ph, + const char *name, + const char **string, + int *integer); + xchat_list * (*xchat_list_get) (xchat_plugin *ph, + const char *name); + void (*xchat_list_free) (xchat_plugin *ph, + xchat_list *xlist); + const char * const * (*xchat_list_fields) (xchat_plugin *ph, + const char *name); + int (*xchat_list_next) (xchat_plugin *ph, + xchat_list *xlist); + const char * (*xchat_list_str) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + int (*xchat_list_int) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + void * (*xchat_plugingui_add) (xchat_plugin *ph, + const char *filename, + const char *name, + const char *desc, + const char *version, + char *reserved); + void (*xchat_plugingui_remove) (xchat_plugin *ph, + void *handle); + int (*xchat_emit_print) (xchat_plugin *ph, + const char *event_name, ...); + int (*xchat_read_fd) (xchat_plugin *ph, + void *src, + char *buf, + int *len); + time_t (*xchat_list_time) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + char *(*xchat_gettext) (xchat_plugin *ph, + const char *msgid); + void (*xchat_send_modes) (xchat_plugin *ph, + const char **targets, + int ntargets, + int modes_per_line, + char sign, + char mode); + char *(*xchat_strip) (xchat_plugin *ph, + const char *str, + int len, + int flags); + void (*xchat_free) (xchat_plugin *ph, + void *ptr); + int (*xchat_pluginpref_set_str) (xchat_plugin *ph, + const char *var, + const char *value); + int (*xchat_pluginpref_get_str) (xchat_plugin *ph, + const char *var, + char *dest); + int (*xchat_pluginpref_set_int) (xchat_plugin *ph, + const char *var, + int value); + int (*xchat_pluginpref_get_int) (xchat_plugin *ph, + const char *var); + int (*xchat_pluginpref_delete) (xchat_plugin *ph, + const char *var); + int (*xchat_pluginpref_list) (xchat_plugin *ph, + char *dest); +}; +#endif + + +xchat_hook * +xchat_hook_command (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + const char *help_text, + void *userdata); + +xchat_hook * +xchat_hook_server (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + void *userdata); + +xchat_hook * +xchat_hook_print (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], void *user_data), + void *userdata); + +xchat_hook * +xchat_hook_timer (xchat_plugin *ph, + int timeout, + int (*callback) (void *user_data), + void *userdata); + +xchat_hook * +xchat_hook_fd (xchat_plugin *ph, + int fd, + int flags, + int (*callback) (int fd, int flags, void *user_data), + void *userdata); + +void * +xchat_unhook (xchat_plugin *ph, + xchat_hook *hook); + +void +xchat_print (xchat_plugin *ph, + const char *text); + +void +xchat_printf (xchat_plugin *ph, + const char *format, ...); + +void +xchat_command (xchat_plugin *ph, + const char *command); + +void +xchat_commandf (xchat_plugin *ph, + const char *format, ...); + +int +xchat_nickcmp (xchat_plugin *ph, + const char *s1, + const char *s2); + +int +xchat_set_context (xchat_plugin *ph, + xchat_context *ctx); + +xchat_context * +xchat_find_context (xchat_plugin *ph, + const char *servname, + const char *channel); + +xchat_context * +xchat_get_context (xchat_plugin *ph); + +const char * +xchat_get_info (xchat_plugin *ph, + const char *id); + +int +xchat_get_prefs (xchat_plugin *ph, + const char *name, + const char **string, + int *integer); + +xchat_list * +xchat_list_get (xchat_plugin *ph, + const char *name); + +void +xchat_list_free (xchat_plugin *ph, + xchat_list *xlist); + +const char * const * +xchat_list_fields (xchat_plugin *ph, + const char *name); + +int +xchat_list_next (xchat_plugin *ph, + xchat_list *xlist); + +const char * +xchat_list_str (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + +int +xchat_list_int (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + +time_t +xchat_list_time (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + +void * +xchat_plugingui_add (xchat_plugin *ph, + const char *filename, + const char *name, + const char *desc, + const char *version, + char *reserved); + +void +xchat_plugingui_remove (xchat_plugin *ph, + void *handle); + +int +xchat_emit_print (xchat_plugin *ph, + const char *event_name, ...); + +char * +xchat_gettext (xchat_plugin *ph, + const char *msgid); + +void +xchat_send_modes (xchat_plugin *ph, + const char **targets, + int ntargets, + int modes_per_line, + char sign, + char mode); + +char * +xchat_strip (xchat_plugin *ph, + const char *str, + int len, + int flags); + +void +xchat_free (xchat_plugin *ph, + void *ptr); + +int +xchat_pluginpref_set_str (xchat_plugin *ph, + const char *var, + const char *value); + +int +xchat_pluginpref_get_str (xchat_plugin *ph, + const char *var, + char *dest); + +int +xchat_pluginpref_set_int (xchat_plugin *ph, + const char *var, + int value); +int +xchat_pluginpref_get_int (xchat_plugin *ph, + const char *var); + +int +xchat_pluginpref_delete (xchat_plugin *ph, + const char *var); + +int +xchat_pluginpref_list (xchat_plugin *ph, + char *dest); + +#if !defined(PLUGIN_C) && defined(WIN32) +#ifndef XCHAT_PLUGIN_HANDLE +#define XCHAT_PLUGIN_HANDLE (ph) +#endif +#define xchat_hook_command ((XCHAT_PLUGIN_HANDLE)->xchat_hook_command) +#define xchat_hook_server ((XCHAT_PLUGIN_HANDLE)->xchat_hook_server) +#define xchat_hook_print ((XCHAT_PLUGIN_HANDLE)->xchat_hook_print) +#define xchat_hook_timer ((XCHAT_PLUGIN_HANDLE)->xchat_hook_timer) +#define xchat_hook_fd ((XCHAT_PLUGIN_HANDLE)->xchat_hook_fd) +#define xchat_unhook ((XCHAT_PLUGIN_HANDLE)->xchat_unhook) +#define xchat_print ((XCHAT_PLUGIN_HANDLE)->xchat_print) +#define xchat_printf ((XCHAT_PLUGIN_HANDLE)->xchat_printf) +#define xchat_command ((XCHAT_PLUGIN_HANDLE)->xchat_command) +#define xchat_commandf ((XCHAT_PLUGIN_HANDLE)->xchat_commandf) +#define xchat_nickcmp ((XCHAT_PLUGIN_HANDLE)->xchat_nickcmp) +#define xchat_set_context ((XCHAT_PLUGIN_HANDLE)->xchat_set_context) +#define xchat_find_context ((XCHAT_PLUGIN_HANDLE)->xchat_find_context) +#define xchat_get_context ((XCHAT_PLUGIN_HANDLE)->xchat_get_context) +#define xchat_get_info ((XCHAT_PLUGIN_HANDLE)->xchat_get_info) +#define xchat_get_prefs ((XCHAT_PLUGIN_HANDLE)->xchat_get_prefs) +#define xchat_list_get ((XCHAT_PLUGIN_HANDLE)->xchat_list_get) +#define xchat_list_free ((XCHAT_PLUGIN_HANDLE)->xchat_list_free) +#define xchat_list_fields ((XCHAT_PLUGIN_HANDLE)->xchat_list_fields) +#define xchat_list_str ((XCHAT_PLUGIN_HANDLE)->xchat_list_str) +#define xchat_list_int ((XCHAT_PLUGIN_HANDLE)->xchat_list_int) +#define xchat_list_time ((XCHAT_PLUGIN_HANDLE)->xchat_list_time) +#define xchat_list_next ((XCHAT_PLUGIN_HANDLE)->xchat_list_next) +#define xchat_plugingui_add ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_add) +#define xchat_plugingui_remove ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_remove) +#define xchat_emit_print ((XCHAT_PLUGIN_HANDLE)->xchat_emit_print) +#define xchat_gettext ((XCHAT_PLUGIN_HANDLE)->xchat_gettext) +#define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) +#define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) +#define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) +#define xchat_pluginpref_set_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_str) +#define xchat_pluginpref_get_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_str) +#define xchat_pluginpref_set_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_int) +#define xchat_pluginpref_get_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_int) +#define xchat_pluginpref_delete ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_delete) +#define xchat_pluginpref_list ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_list) +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/plugins/hextray/callbacks.cpp b/plugins/hextray/callbacks.cpp index 96990050..e7dcfdba 100644 --- a/plugins/hextray/callbacks.cpp +++ b/plugins/hextray/callbacks.cpp @@ -23,10 +23,10 @@ #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #include "utility.h" -#include "xtray.h" -#include "xchat.h" +#include "hextray.h" +#include "hexchat.h" #include "callbacks.h" #include "resource.h" #include "sdTray.h" @@ -45,7 +45,7 @@ BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam) TCHAR szTitle[10]; GetWindowText(hWnd, szTitle, 9); - if(_tcsstr(szTitle, _T("XChat ["))) + if(_tcsstr(szTitle, _T("HexChat ["))) { g_hXchatWnd = hWnd; return false; diff --git a/plugins/hextray/hexchat.cpp b/plugins/hextray/hexchat.cpp new file mode 100644 index 00000000..b1defc1f --- /dev/null +++ b/plugins/hextray/hexchat.cpp @@ -0,0 +1,320 @@ +/* X-Tray + * Copyright (C) 1998, 2005 Peter Zelezny, Michael Hotaling + * + * X-Tray 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 2 of the License, or + * (at your option) any later version. + * + * X-Tray 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 X-Tray; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include + +#include "hexchat-plugin.h" +#include "hextray.h" +#include "resource.h" +#include "hexchat.h" +#include "utility.h" + +// from util.c of xchat source code ( slightly modified to fit X-Tray Syntax ) +char *xchat_strip_color (char *text) +{ + int nc = 0; + int i = 0; + int col = 0; + int len = strlen(text); + char *new_str = (char *)malloc(len + 2); + + while (len > 0) + { + if ((col && isdigit(*text) && (nc < 2)) || (col && isdigit(*(text+1)) && (nc < 3) && (*text == ','))) + { + nc++; + + if(*text == ',') + { + nc = 0; + } + } + else + { + col = 0; + + switch (*text) + { + case '\003': /*ATTR_COLOR: */ + { + col = 1; + nc = 0; + } + break; + case '\007': /*ATTR_BEEP: */ + case '\017': /*ATTR_RESET: */ + case '\026': /*ATTR_REVERSE: */ + case '\002': /*ATTR_BOLD: */ + case '\037': /*ATTR_UNDERLINE: */ + break; + default: + { + new_str[i] = *text; + i++; + } + break; + } + } + + text++; + len--; + } + + new_str[i] = 0; + + return new_str; +} + +void check_special_chars (char *cmd) +{ + int occur = 0; + int len = strlen (cmd); + int i = 0, j = 0; + char *buf; + + if (!len) + return; + + buf = (char *)malloc (len + 1); + + if (buf) + { + while (cmd[j]) + { + switch (cmd[j]) + { + case '%': + { + occur++; + + switch (cmd[j + 1]) + { + case 'R': + buf[i] = '\026'; + break; + case 'U': + buf[i] = '\037'; + break; + case 'B': + buf[i] = '\002'; + break; + case 'C': + buf[i] = '\003'; + break; + case 'O': + buf[i] = '\017'; + break; + case '%': + buf[i] = '%'; + break; + default: + buf[i] = '%'; + j--; + break; + } + + j++; + } + break; + default: + { + buf[i] = cmd[j]; + } + break; + } + + j++; + i++; + } + + buf[i] = 0; + + if (occur) + strcpy (cmd, buf); + + free (buf); + } +} + +void xchat_globally_away(TCHAR *tszAway) +{ + char szTemp[512]; + char szAway[512]; + + ConvertString(tszAway, szAway, 512); + _snprintf(szTemp, 512, "ALLSERV AWAY %s\0", szAway); + check_special_chars(szTemp); + xchat_exec(szTemp); +} + +void xchat_away(TCHAR *tszAway) +{ + char szTemp[512]; + char szAway[512]; + + ConvertString(tszAway, szAway, 512); + _snprintf(szTemp, 512, szAway); + check_special_chars(szTemp); + xchat_commandf(ph, "AWAY %s\0", szTemp); +} + +void xchat_globally_back() +{ + std::vector xs; + std::vector::iterator xsi; + xchat_list *xl = xchat_list_get(ph, "channels"); + + if(xl) + { + while(xchat_list_next(ph, xl)) + { + xsi = std::find(xs.begin(), xs.end(), xchat_list_int(ph, xl, "id")); + + if((xsi == xs.end()) && + ((strlen(xchat_list_str(ph, xl, "server")) > 0) || + (strlen(xchat_list_str(ph, xl, "channel")) > 0))) + { + xs.push_back(xchat_list_int(ph, xl, "id")); + xchat_set_context(ph, (xchat_context *)xchat_list_str(ph, xl, "context")); + xchat_back(); + } + } + + xchat_list_free(ph, xl); + } +} + + + +void xchat_back() +{ + if(xchat_get_info(ph, "away")) + { + xchat_command(ph, "BACK"); + } +} + +HMENU setServerMenu() +{ + HMENU sTemp = CreateMenu(); + TCHAR wszServer[128]; + TCHAR wszNick[128]; + TCHAR wszMenuEntry[256]; + + std::vector xs; + std::vector::iterator xsi; + xchat_list *xl = xchat_list_get(ph, "channels"); + + AppendMenu(sTemp, MF_STRING, ACT_AWAY, _T("Set Globally Away")); + AppendMenu(sTemp, MF_STRING, ACT_BACK, _T("Set Globally Back")); + AppendMenu(sTemp, MF_SEPARATOR, 0, NULL); + + if(xl) + { + while(xchat_list_next(ph, xl)) + { + xsi = std::find(xs.begin(), xs.end(), xchat_list_int(ph, xl, "id")); + + if( (xsi == xs.end()) && + ((strlen(xchat_list_str(ph, xl, "server")) > 0) || + (strlen(xchat_list_str(ph, xl, "channel")) > 0))) + { + xchat_set_context(ph, (xchat_context *)xchat_list_str(ph, xl, "context")); + xs.push_back(xchat_list_int(ph, xl, "id")); + + char *network = _strdup(xchat_list_str(ph, xl, "network")); + char *server = _strdup(xchat_list_str(ph, xl, "server")); + char *nick = _strdup(xchat_get_info(ph, "nick")); + + if(network != NULL) + { + ConvertString(network, wszServer, 128); + } + else + { + ConvertString(server, wszServer, 128); + } + + if(server != NULL) + { + ConvertString(nick, wszNick, 128); + _sntprintf(wszMenuEntry, 256, _T("%s @ %s\0"), wszNick, wszServer); + + if(!xchat_get_info(ph, "away")) + { + AppendMenu(sTemp, MF_STRING, (xchat_list_int(ph, xl, "id") + 1), wszMenuEntry); + } + else + { + AppendMenu(sTemp, (MF_CHECKED | MF_STRING), (xchat_list_int(ph, xl, "id") + 1), wszMenuEntry); + } + } + + free(network); + free(server); + free(nick); + } + } + + xchat_list_free(ph, xl); + } + + return sTemp; +} + +struct _xchat_context *xchat_find_server(int find_id) +{ + xchat_context *xc; + xchat_list *xl = xchat_list_get(ph, "channels"); + int id; + + if(!xl) + return NULL; + + while(xchat_list_next(ph, xl)) + { + id = xchat_list_int(ph, xl, "id"); + + if(id == -1) + { + return NULL; + } + else if(id == find_id) + { + xc = (xchat_context *)xchat_list_str(ph, xl, "context"); + + xchat_list_free(ph, xl); + + return xc; + } + } + + xchat_list_free(ph, xl); + + return NULL; +} + +void xchat_exec(char *command) +{ + xchat_set_context(ph, xchat_find_context(ph, NULL, NULL)); + xchat_command(ph, command); +} \ No newline at end of file diff --git a/plugins/hextray/hexchat.h b/plugins/hextray/hexchat.h new file mode 100644 index 00000000..76452aeb --- /dev/null +++ b/plugins/hextray/hexchat.h @@ -0,0 +1,32 @@ +/* X-Tray + * Copyright (C) 2005 Michael Hotaling + * + * X-Tray 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 2 of the License, or + * (at your option) any later version. + * + * X-Tray 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 X-Tray; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _H_XCHAT_H +#define _H_XCHAT_H + +void xchat_exec (char *); +char *xchat_strip_color (char *); +void xchat_parse (char *); +struct _xchat_context *xchat_find_server (int); +void xchat_globally_away (TCHAR *); +void xchat_away (TCHAR *); +void xchat_globally_back (); +void xchat_back (); +HMENU setServerMenu (); + +#endif \ No newline at end of file diff --git a/plugins/hextray/hextray-xp.vcxproj b/plugins/hextray/hextray-xp.vcxproj index cd7581d5..72d1599e 100644 --- a/plugins/hextray/hextray-xp.vcxproj +++ b/plugins/hextray/hextray-xp.vcxproj @@ -69,7 +69,7 @@ true true true - xtray.def + hextray.def ntstc_msvcrt.lib;%(AdditionalDependencies) @@ -89,7 +89,7 @@ true true true - xtray.def + hextray.def ntstc_msvcrt.lib;%(AdditionalDependencies) @@ -103,7 +103,7 @@ - + @@ -113,8 +113,8 @@ - - + + @@ -122,8 +122,8 @@ - - + + diff --git a/plugins/hextray/hextray-xp.vcxproj.filters b/plugins/hextray/hextray-xp.vcxproj.filters index b83dc813..1f9a4057 100644 --- a/plugins/hextray/hextray-xp.vcxproj.filters +++ b/plugins/hextray/hextray-xp.vcxproj.filters @@ -21,7 +21,7 @@ - + Resource Files @@ -70,10 +70,10 @@ Source Files - + Source Files - + Source Files @@ -93,10 +93,10 @@ Header Files - + Header Files - + Header Files diff --git a/plugins/hextray/hextray.cpp b/plugins/hextray/hextray.cpp new file mode 100644 index 00000000..9741e5f7 --- /dev/null +++ b/plugins/hextray/hextray.cpp @@ -0,0 +1,219 @@ +/* X-Tray + * Copyright (C) 2005 Michael Hotaling + * + * X-Tray 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 2 of the License, or + * (at your option) any later version. + * + * X-Tray 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 X-Tray; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define _WIN32_IE 0x0601 + +#include +#include +#include +#include + +#include "hexchat-plugin.h" +#include "resource.h" +#include "callbacks.h" +#include "utility.h" +#include "hextray.h" +#include "sdTray.h" +#include "sdAlerts.h" + +/*****************************************************/ +/**** Don't want to pollute the namespace do we? *****/ +/*****************************************************/ +std::list g_vHooks; + +/*****************************************************/ +/************ Global Identifiers *********************/ +/*****************************************************/ +WNDPROC g_hOldProc; +xchat_plugin *ph; + +/*****************************************************/ +/***************** Resources *************************/ +/*****************************************************/ +HWND g_hXchatWnd; +HWND g_hHotkeyWnd; +HWND g_hPrefDlg; +HMENU g_hTrayMenu; +HICON g_hIcons[24]; +HANDLE g_hInstance; +/*****************************************************/ +/***************** Preferences ***********************/ +/*****************************************************/ +unsigned int g_dwPrefs; +TCHAR g_szAway[512]; +int g_iTime; + + +BOOL WINAPI DllMain(HANDLE hModule, DWORD fdwReason, LPVOID lpVoid) +{ + if((fdwReason == DLL_PROCESS_ATTACH) || (fdwReason == DLL_THREAD_ATTACH)) + { + g_hInstance = hModule; + } + + return TRUE; +} + +int xchat_plugin_init(xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) +{ + ph = plugin_handle; + + *plugin_name = "HexTray"; + *plugin_desc = "Minimize HexChat to the Windows system tray"; + *plugin_version = "1.2.4"; + + /***************************************************************************************************************************/ + /************************* Load our preferances from xTray.ini *************************************************************/ + /***************************************************************************************************************************/ + LoadPrefs(); + + /***************************************************************************************************************************/ + /************************* Finds the xChat window and saves it for later use ***********************************************/ + /***************************************************************************************************************************/ + g_hXchatWnd = (HWND)xchat_get_info(ph, "win_ptr"); + + if(g_hXchatWnd == NULL) + { + EnumThreadWindows(GetCurrentThreadId(), EnumWindowsProc, 0); + } + + g_hOldProc = (WNDPROC)GetWindowLongPtr(g_hXchatWnd, GWLP_WNDPROC); + SetWindowLongPtr(g_hXchatWnd, GWLP_WNDPROC, (LONG_PTR)WindowProc); + + /***************************************************************************************************************************/ + /************************* Grab the xChat Icon, Load our menu, create the window to receive the hotkey messages ***********/ + /************************* and register the windows message so we know if explorer crashes ***********/ + /***************************************************************************************************************************/ + g_hTrayMenu = GetSubMenu(LoadMenu((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDR_TRAY_MENU)), 0); + g_hHotkeyWnd = CreateDialog((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDD_ALERT), NULL, (DLGPROC)HotKeyProc); + g_hPrefDlg = CreateDialog((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDD_PREF), g_hXchatWnd, (DLGPROC)PrefProc); + + g_hIcons[0] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_XCHAT), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + g_hIcons[2] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_HIGHLIGHT), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + g_hIcons[5] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_BANNED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + g_hIcons[6] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_KICKED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + g_hIcons[8] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_PMSG), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + g_hIcons[10]= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_SNOTICE), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + g_hIcons[11]= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_DISCONNECTED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + g_hIcons[22] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_CHANMSG), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); + + /***************************************************************************************************************************/ + /************************* Add our icon to the tray ************************************************************************/ + /***************************************************************************************************************************/ + char szVersion[64]; + _snprintf(szVersion, 64, "HexChat %s", xchat_get_info(ph, "version")); + AddIcon(g_hXchatWnd, 1, g_hIcons[0], szVersion, (NIF_ICON | NIF_MESSAGE | NIF_TIP), WM_TRAYMSG); + + /***************************************************************************************************************************/ + /***************************************************************************************************************************/ + /***************************************************************************************************************************/ + if(g_dwPrefs & (1< + * + * X-Tray 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 2 of the License, or + * (at your option) any later version. + * + * X-Tray 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 X-Tray; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _XTRAY_H +#define _XTRAY_H + +/******************** Globals *************************/ +extern HWND g_hXchatWnd; +extern HWND g_hHotkeyWnd; +extern HWND g_hPrefDlg; +extern HMENU g_hTrayMenu; +extern HICON g_hIcons[24]; +extern HANDLE g_hInstance; +extern unsigned int g_dwPrefs; +extern TCHAR g_szAway[512]; +extern int g_iTime; +extern WNDPROC g_hOldProc; +extern struct _xchat_plugin *ph; +/******************************************************/ + +/******************** Messages ************************/ +#define WM_TRAYMSG WM_APP +/******************************************************/ + +/********************* Events *************************/ +#define CHAN_HILIGHT 1 +#define CHAN_INVITE 2 +#define CHAN_TOPIC_CHANGE 3 +#define CHAN_BANNED 4 +#define CHAN_KICKED 5 + +#define CTCP_GENERIC 6 +#define PMSG_RECEIVE 7 + +#define SERV_KILLED 8 +#define SERV_NOTICE 9 +#define SERV_DISCONNECT 10 + +/* new events */ +#define CHAN_MESSAGE 21 + +#define PREF_AOM 11 // away on minimize +#define PREF_TOT 12 // Tray on Taskbar +#define PREF_AMAE 13 // alert me about events +#define PREF_OSBWM 14 // Only Show Balloon When Minimized +#define PREF_UWIOB 15 // Use Window Instead of Balloon +#define PREF_KAOI 16 // Keep alerts open indefinitely +#define PREF_MIOC 17 // Minimize instead of close +#define PREF_BLINK 18 // blink icon +#define PREF_CICO 19 // change icon - not implemented +#define PREF_DNSIT 20 // Do not show in taskbar +/******************************************************/ +#endif + +#ifdef _WIN64 +/* use replacement with the same value, and use SetWindowLongPtr instead + of SetWindowLong. more info: + + http://msdn.microsoft.com/en-us/library/ms633591.aspx + http://msdn.microsoft.com/en-us/library/ms644898.aspx */ +#define GWL_HWNDPARENT GWLP_HWNDPARENT +#endif diff --git a/plugins/hextray/hextray.vcxproj b/plugins/hextray/hextray.vcxproj index 47f4c273..fd28aae3 100644 --- a/plugins/hextray/hextray.vcxproj +++ b/plugins/hextray/hextray.vcxproj @@ -66,7 +66,7 @@ true true true - xtray.def + hextray.def @@ -85,7 +85,7 @@ true true true - xtray.def + hextray.def @@ -98,7 +98,7 @@ - + @@ -108,8 +108,8 @@ - - + + @@ -117,8 +117,8 @@ - - + + diff --git a/plugins/hextray/hextray.vcxproj.filters b/plugins/hextray/hextray.vcxproj.filters index b83dc813..1f9a4057 100644 --- a/plugins/hextray/hextray.vcxproj.filters +++ b/plugins/hextray/hextray.vcxproj.filters @@ -21,7 +21,7 @@ - + Resource Files @@ -70,10 +70,10 @@ Source Files - + Source Files - + Source Files @@ -93,10 +93,10 @@ Header Files - + Header Files - + Header Files diff --git a/plugins/hextray/resource.rc b/plugins/hextray/resource.rc index 4b028421..01899ac7 100644 --- a/plugins/hextray/resource.rc +++ b/plugins/hextray/resource.rc @@ -201,7 +201,7 @@ END 3 TEXTINCLUDE BEGIN - "xtray.h\0" + "hextray.h\0" END 4 TEXTINCLUDE @@ -303,7 +303,7 @@ IDB_SD_LOGO BITMAP "bitmaps\\sd.bmp" // // Generated from the TEXTINCLUDE 3 resource. // -xtray.h +hextray.h ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED diff --git a/plugins/hextray/utility.cpp b/plugins/hextray/utility.cpp index 8f6caa27..4a2ddde7 100644 --- a/plugins/hextray/utility.cpp +++ b/plugins/hextray/utility.cpp @@ -21,9 +21,9 @@ #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #include "utility.h" -#include "xtray.h" +#include "hextray.h" #include "callbacks.h" #include "resource.h" diff --git a/plugins/hextray/xchat.cpp b/plugins/hextray/xchat.cpp deleted file mode 100644 index 47ce46a9..00000000 --- a/plugins/hextray/xchat.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/* X-Tray - * Copyright (C) 1998, 2005 Peter Zelezny, Michael Hotaling - * - * X-Tray 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 2 of the License, or - * (at your option) any later version. - * - * X-Tray 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 X-Tray; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "xchat-plugin.h" -#include "xtray.h" -#include "resource.h" -#include "xchat.h" -#include "utility.h" - -// from util.c of xchat source code ( slightly modified to fit X-Tray Syntax ) -char *xchat_strip_color (char *text) -{ - int nc = 0; - int i = 0; - int col = 0; - int len = strlen(text); - char *new_str = (char *)malloc(len + 2); - - while (len > 0) - { - if ((col && isdigit(*text) && (nc < 2)) || (col && isdigit(*(text+1)) && (nc < 3) && (*text == ','))) - { - nc++; - - if(*text == ',') - { - nc = 0; - } - } - else - { - col = 0; - - switch (*text) - { - case '\003': /*ATTR_COLOR: */ - { - col = 1; - nc = 0; - } - break; - case '\007': /*ATTR_BEEP: */ - case '\017': /*ATTR_RESET: */ - case '\026': /*ATTR_REVERSE: */ - case '\002': /*ATTR_BOLD: */ - case '\037': /*ATTR_UNDERLINE: */ - break; - default: - { - new_str[i] = *text; - i++; - } - break; - } - } - - text++; - len--; - } - - new_str[i] = 0; - - return new_str; -} - -void check_special_chars (char *cmd) -{ - int occur = 0; - int len = strlen (cmd); - int i = 0, j = 0; - char *buf; - - if (!len) - return; - - buf = (char *)malloc (len + 1); - - if (buf) - { - while (cmd[j]) - { - switch (cmd[j]) - { - case '%': - { - occur++; - - switch (cmd[j + 1]) - { - case 'R': - buf[i] = '\026'; - break; - case 'U': - buf[i] = '\037'; - break; - case 'B': - buf[i] = '\002'; - break; - case 'C': - buf[i] = '\003'; - break; - case 'O': - buf[i] = '\017'; - break; - case '%': - buf[i] = '%'; - break; - default: - buf[i] = '%'; - j--; - break; - } - - j++; - } - break; - default: - { - buf[i] = cmd[j]; - } - break; - } - - j++; - i++; - } - - buf[i] = 0; - - if (occur) - strcpy (cmd, buf); - - free (buf); - } -} - -void xchat_globally_away(TCHAR *tszAway) -{ - char szTemp[512]; - char szAway[512]; - - ConvertString(tszAway, szAway, 512); - _snprintf(szTemp, 512, "ALLSERV AWAY %s\0", szAway); - check_special_chars(szTemp); - xchat_exec(szTemp); -} - -void xchat_away(TCHAR *tszAway) -{ - char szTemp[512]; - char szAway[512]; - - ConvertString(tszAway, szAway, 512); - _snprintf(szTemp, 512, szAway); - check_special_chars(szTemp); - xchat_commandf(ph, "AWAY %s\0", szTemp); -} - -void xchat_globally_back() -{ - std::vector xs; - std::vector::iterator xsi; - xchat_list *xl = xchat_list_get(ph, "channels"); - - if(xl) - { - while(xchat_list_next(ph, xl)) - { - xsi = std::find(xs.begin(), xs.end(), xchat_list_int(ph, xl, "id")); - - if((xsi == xs.end()) && - ((strlen(xchat_list_str(ph, xl, "server")) > 0) || - (strlen(xchat_list_str(ph, xl, "channel")) > 0))) - { - xs.push_back(xchat_list_int(ph, xl, "id")); - xchat_set_context(ph, (xchat_context *)xchat_list_str(ph, xl, "context")); - xchat_back(); - } - } - - xchat_list_free(ph, xl); - } -} - - - -void xchat_back() -{ - if(xchat_get_info(ph, "away")) - { - xchat_command(ph, "BACK"); - } -} - -HMENU setServerMenu() -{ - HMENU sTemp = CreateMenu(); - TCHAR wszServer[128]; - TCHAR wszNick[128]; - TCHAR wszMenuEntry[256]; - - std::vector xs; - std::vector::iterator xsi; - xchat_list *xl = xchat_list_get(ph, "channels"); - - AppendMenu(sTemp, MF_STRING, ACT_AWAY, _T("Set Globally Away")); - AppendMenu(sTemp, MF_STRING, ACT_BACK, _T("Set Globally Back")); - AppendMenu(sTemp, MF_SEPARATOR, 0, NULL); - - if(xl) - { - while(xchat_list_next(ph, xl)) - { - xsi = std::find(xs.begin(), xs.end(), xchat_list_int(ph, xl, "id")); - - if( (xsi == xs.end()) && - ((strlen(xchat_list_str(ph, xl, "server")) > 0) || - (strlen(xchat_list_str(ph, xl, "channel")) > 0))) - { - xchat_set_context(ph, (xchat_context *)xchat_list_str(ph, xl, "context")); - xs.push_back(xchat_list_int(ph, xl, "id")); - - char *network = _strdup(xchat_list_str(ph, xl, "network")); - char *server = _strdup(xchat_list_str(ph, xl, "server")); - char *nick = _strdup(xchat_get_info(ph, "nick")); - - if(network != NULL) - { - ConvertString(network, wszServer, 128); - } - else - { - ConvertString(server, wszServer, 128); - } - - if(server != NULL) - { - ConvertString(nick, wszNick, 128); - _sntprintf(wszMenuEntry, 256, _T("%s @ %s\0"), wszNick, wszServer); - - if(!xchat_get_info(ph, "away")) - { - AppendMenu(sTemp, MF_STRING, (xchat_list_int(ph, xl, "id") + 1), wszMenuEntry); - } - else - { - AppendMenu(sTemp, (MF_CHECKED | MF_STRING), (xchat_list_int(ph, xl, "id") + 1), wszMenuEntry); - } - } - - free(network); - free(server); - free(nick); - } - } - - xchat_list_free(ph, xl); - } - - return sTemp; -} - -struct _xchat_context *xchat_find_server(int find_id) -{ - xchat_context *xc; - xchat_list *xl = xchat_list_get(ph, "channels"); - int id; - - if(!xl) - return NULL; - - while(xchat_list_next(ph, xl)) - { - id = xchat_list_int(ph, xl, "id"); - - if(id == -1) - { - return NULL; - } - else if(id == find_id) - { - xc = (xchat_context *)xchat_list_str(ph, xl, "context"); - - xchat_list_free(ph, xl); - - return xc; - } - } - - xchat_list_free(ph, xl); - - return NULL; -} - -void xchat_exec(char *command) -{ - xchat_set_context(ph, xchat_find_context(ph, NULL, NULL)); - xchat_command(ph, command); -} \ No newline at end of file diff --git a/plugins/hextray/xchat.h b/plugins/hextray/xchat.h deleted file mode 100644 index 76452aeb..00000000 --- a/plugins/hextray/xchat.h +++ /dev/null @@ -1,32 +0,0 @@ -/* X-Tray - * Copyright (C) 2005 Michael Hotaling - * - * X-Tray 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 2 of the License, or - * (at your option) any later version. - * - * X-Tray 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 X-Tray; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _H_XCHAT_H -#define _H_XCHAT_H - -void xchat_exec (char *); -char *xchat_strip_color (char *); -void xchat_parse (char *); -struct _xchat_context *xchat_find_server (int); -void xchat_globally_away (TCHAR *); -void xchat_away (TCHAR *); -void xchat_globally_back (); -void xchat_back (); -HMENU setServerMenu (); - -#endif \ No newline at end of file diff --git a/plugins/hextray/xtray.cpp b/plugins/hextray/xtray.cpp deleted file mode 100644 index df4a5c89..00000000 --- a/plugins/hextray/xtray.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* X-Tray - * Copyright (C) 2005 Michael Hotaling - * - * X-Tray 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 2 of the License, or - * (at your option) any later version. - * - * X-Tray 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 X-Tray; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#define _WIN32_IE 0x0601 - -#include -#include -#include -#include - -#include "xchat-plugin.h" -#include "resource.h" -#include "callbacks.h" -#include "utility.h" -#include "xtray.h" -#include "sdTray.h" -#include "sdAlerts.h" - -/*****************************************************/ -/**** Don't want to pollute the namespace do we? *****/ -/*****************************************************/ -std::list g_vHooks; - -/*****************************************************/ -/************ Global Identifiers *********************/ -/*****************************************************/ -WNDPROC g_hOldProc; -xchat_plugin *ph; - -/*****************************************************/ -/***************** Resources *************************/ -/*****************************************************/ -HWND g_hXchatWnd; -HWND g_hHotkeyWnd; -HWND g_hPrefDlg; -HMENU g_hTrayMenu; -HICON g_hIcons[24]; -HANDLE g_hInstance; -/*****************************************************/ -/***************** Preferences ***********************/ -/*****************************************************/ -unsigned int g_dwPrefs; -TCHAR g_szAway[512]; -int g_iTime; - - -BOOL WINAPI DllMain(HANDLE hModule, DWORD fdwReason, LPVOID lpVoid) -{ - if((fdwReason == DLL_PROCESS_ATTACH) || (fdwReason == DLL_THREAD_ATTACH)) - { - g_hInstance = hModule; - } - - return TRUE; -} - -int xchat_plugin_init(xchat_plugin *plugin_handle, char **plugin_name, char **plugin_desc, char **plugin_version, char *arg) -{ - ph = plugin_handle; - - *plugin_name = "HexTray"; - *plugin_desc = "Minimize HexChat to the Windows system tray"; - *plugin_version = "1.2.4"; - - /***************************************************************************************************************************/ - /************************* Load our preferances from xTray.ini *************************************************************/ - /***************************************************************************************************************************/ - LoadPrefs(); - - /***************************************************************************************************************************/ - /************************* Finds the xChat window and saves it for later use ***********************************************/ - /***************************************************************************************************************************/ - g_hXchatWnd = (HWND)xchat_get_info(ph, "win_ptr"); - - if(g_hXchatWnd == NULL) - { - EnumThreadWindows(GetCurrentThreadId(), EnumWindowsProc, 0); - } - - g_hOldProc = (WNDPROC)GetWindowLongPtr(g_hXchatWnd, GWLP_WNDPROC); - SetWindowLongPtr(g_hXchatWnd, GWLP_WNDPROC, (LONG_PTR)WindowProc); - - /***************************************************************************************************************************/ - /************************* Grab the xChat Icon, Load our menu, create the window to receive the hotkey messages ***********/ - /************************* and register the windows message so we know if explorer crashes ***********/ - /***************************************************************************************************************************/ - g_hTrayMenu = GetSubMenu(LoadMenu((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDR_TRAY_MENU)), 0); - g_hHotkeyWnd = CreateDialog((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDD_ALERT), NULL, (DLGPROC)HotKeyProc); - g_hPrefDlg = CreateDialog((HINSTANCE)g_hInstance, MAKEINTRESOURCE(IDD_PREF), g_hXchatWnd, (DLGPROC)PrefProc); - - g_hIcons[0] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_XCHAT), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - g_hIcons[2] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_HIGHLIGHT), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - g_hIcons[5] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_BANNED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - g_hIcons[6] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_KICKED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - g_hIcons[8] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_PMSG), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - g_hIcons[10]= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_SNOTICE), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - g_hIcons[11]= (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_DISCONNECTED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - g_hIcons[22] = (HICON)LoadImage((HINSTANCE)g_hInstance, MAKEINTRESOURCE(ICO_CHANMSG), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); - - /***************************************************************************************************************************/ - /************************* Add our icon to the tray ************************************************************************/ - /***************************************************************************************************************************/ - char szVersion[64]; - _snprintf(szVersion, 64, "HexChat %s", xchat_get_info(ph, "version")); - AddIcon(g_hXchatWnd, 1, g_hIcons[0], szVersion, (NIF_ICON | NIF_MESSAGE | NIF_TIP), WM_TRAYMSG); - - /***************************************************************************************************************************/ - /***************************************************************************************************************************/ - /***************************************************************************************************************************/ - if(g_dwPrefs & (1< - * - * X-Tray 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 2 of the License, or - * (at your option) any later version. - * - * X-Tray 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 X-Tray; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef _XTRAY_H -#define _XTRAY_H - -/******************** Globals *************************/ -extern HWND g_hXchatWnd; -extern HWND g_hHotkeyWnd; -extern HWND g_hPrefDlg; -extern HMENU g_hTrayMenu; -extern HICON g_hIcons[24]; -extern HANDLE g_hInstance; -extern unsigned int g_dwPrefs; -extern TCHAR g_szAway[512]; -extern int g_iTime; -extern WNDPROC g_hOldProc; -extern struct _xchat_plugin *ph; -/******************************************************/ - -/******************** Messages ************************/ -#define WM_TRAYMSG WM_APP -/******************************************************/ - -/********************* Events *************************/ -#define CHAN_HILIGHT 1 -#define CHAN_INVITE 2 -#define CHAN_TOPIC_CHANGE 3 -#define CHAN_BANNED 4 -#define CHAN_KICKED 5 - -#define CTCP_GENERIC 6 -#define PMSG_RECEIVE 7 - -#define SERV_KILLED 8 -#define SERV_NOTICE 9 -#define SERV_DISCONNECT 10 - -/* new events */ -#define CHAN_MESSAGE 21 - -#define PREF_AOM 11 // away on minimize -#define PREF_TOT 12 // Tray on Taskbar -#define PREF_AMAE 13 // alert me about events -#define PREF_OSBWM 14 // Only Show Balloon When Minimized -#define PREF_UWIOB 15 // Use Window Instead of Balloon -#define PREF_KAOI 16 // Keep alerts open indefinitely -#define PREF_MIOC 17 // Minimize instead of close -#define PREF_BLINK 18 // blink icon -#define PREF_CICO 19 // change icon - not implemented -#define PREF_DNSIT 20 // Do not show in taskbar -/******************************************************/ -#endif - -#ifdef _WIN64 -/* use replacement with the same value, and use SetWindowLongPtr instead - of SetWindowLong. more info: - - http://msdn.microsoft.com/en-us/library/ms633591.aspx - http://msdn.microsoft.com/en-us/library/ms644898.aspx */ -#define GWL_HWNDPARENT GWLP_HWNDPARENT -#endif diff --git a/plugins/lua/lua.c b/plugins/lua/lua.c index 8fc55a26..3809e66e 100644 --- a/plugins/lua/lua.c +++ b/plugins/lua/lua.c @@ -65,7 +65,7 @@ #define lua_pop(L,n) lua_settop(L, -(n)-1) -#include "xchat-plugin.h" +#include "hexchat-plugin.h" static xchat_plugin *ph; /* plugin handle */ diff --git a/plugins/mailcheck/mailcheck.c b/plugins/mailcheck/mailcheck.c index 19011ab3..fb507539 100644 --- a/plugins/mailcheck/mailcheck.c +++ b/plugins/mailcheck/mailcheck.c @@ -7,7 +7,7 @@ #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" static xchat_plugin *ph; /* plugin handle */ diff --git a/plugins/mpcinfo/mpcInfo.c b/plugins/mpcinfo/mpcInfo.c index e467e516..cfbcc3b7 100644 --- a/plugins/mpcinfo/mpcInfo.c +++ b/plugins/mpcinfo/mpcInfo.c @@ -23,7 +23,7 @@ static char *VERSION="0.0.6"; #include #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" static xchat_plugin *ph; #include "functions.c" diff --git a/plugins/perl/perl.c b/plugins/perl/perl.c index c9bfa5e9..38de8208 100644 --- a/plugins/perl/perl.c +++ b/plugins/perl/perl.c @@ -33,7 +33,7 @@ #undef PACKAGE #include "../../config.h" /* for #define OLD_PERL */ -#include "xchat-plugin.h" +#include "hexchat-plugin.h" static xchat_plugin *ph; /* plugin handle */ diff --git a/plugins/plugin-conf.in b/plugins/plugin-conf.in index 1e2c338e..f43f5c53 100644 --- a/plugins/plugin-conf.in +++ b/plugins/plugin-conf.in @@ -1,12 +1,12 @@ AC_INIT(@PLUGIN@-config.h.in) AM_CONFIG_HEADER(@PLUGIN@-config.h) -AM_INIT_AUTOMAKE(xchat-@PLUGIN@, @PLUGIN_VERSION@) +AM_INIT_AUTOMAKE(hexchat-@PLUGIN@, @PLUGIN_VERSION@) AM_MAINTAINER_MODE AM_DISABLE_STATIC AM_PROG_LIBTOOL AC_ARG_WITH(plugin-includes, -[ --with-plugin-includes directory containing xchat-plugin.h], +[ --with-plugin-includes directory containing hexchat-plugin.h], PLUGIN_INCLUDES=$enableval) AC_SUBST(PLUGIN_INCLUDES) diff --git a/plugins/plugin20.html b/plugins/plugin20.html index 2c2d106c..e17f3346 100644 --- a/plugins/plugin20.html +++ b/plugins/plugin20.html @@ -101,12 +101,12 @@ margin-right: 32px;

Introduction

-Plugins for XChat are written in C. The interface aims to keep 100% -binary compatability. This means that if you upgrade XChat, you will +Plugins for HexChat are written in C. The interface aims to keep 100% +binary compatability. This means that if you upgrade HexChat, you will not need to recompile your plugins, they'll continue to work. The interface doesn't depend on any structures and offsets, so compiler versions shouldn't have an impact either. The only real requirement of -an XChat plugin, is that it define a "xchat_plugin_init" symbol. This +an HexChat plugin, is that it define a "xchat_plugin_init" symbol. This is your entry point function, see the example below. You should make all your global variables and functions static, so that a symbol is not exported. There is no harm in exporting these symbols, but they @@ -130,7 +130,7 @@ of locale. What does this mean?

Sample plugin

This simple plugin autoOps anyone who joins a channel you're in. It also adds a new command /AUTOOPTOGGLE, which can be used to turn the feature ON -or OFF. Every XChat plugin must define an xchat_plugin_init function, this +or OFF. Every HexChat plugin must define an xchat_plugin_init function, this is the normal entry point. xchat_plugin_deinit is optional.
@@ -142,7 +142,7 @@ is the normal entry point. xchat_plugin_deinit is optional. #define PDESC "Auto Ops anyone that joins" #define PVERSION "0.1" -static xchat_plugin *ph; /* plugin handle */ +static hexchat_plugin *ph; /* plugin handle */ static int enable = 1; static int join_cb(char *word[], void *userdata) @@ -152,7 +152,7 @@ is the normal entry point. xchat_plugin_deinit is optional. xchat_commandf(ph, "OP %s", word[1]); /* word[1] is the nickname, as in the Settings->Advanced->TextEvents window in xchat */ - return XCHAT_EAT_NONE; /* don't eat this event, xchat needs to see it! */ + return XCHAT_EAT_NONE; /* don't eat this event, HexChat needs to see it! */ } static int autooptoggle_cb(char *word[], char *word_eol[], void *userdata) @@ -167,7 +167,7 @@ is the normal entry point. xchat_plugin_deinit is optional. xchat_print(ph, "AutoOping now disabled!\n"); } - return XCHAT_EAT_ALL; /* eat this command so xchat and other plugins can't process it */ + return XCHAT_EAT_ALL; /* eat this command so HexChat and other plugins can't process it */ } void xchat_plugin_get_info(char **name, char **desc, char **version, void **reserved) @@ -186,7 +186,7 @@ is the normal entry point. xchat_plugin_deinit is optional. /* we need to save this for use with any xchat_* functions */ ph = plugin_handle; - /* tell xchat our info */ + /* tell HexChat our info */ *plugin_name = PNAME; *plugin_desc = PDESC; *plugin_version = PVERSION; @@ -358,7 +358,7 @@ Yes, it can be done. All you need is either Simply compile your plugin as a DLL. You should have the following files:
    -
  • xchat-plugin.h - Main Plugin header
  • +
  • hexchat-plugin.h - Main Plugin header
  • plugin.c - Your plugin, you need to write this one :)
  • plugin.def - A simple text file containing the following:
@@ -395,16 +395,16 @@ xchat_command(ph, "GUI .....");.

- - + + - - + + - +
GUI ATTACHSame function as "Attach Window" in the XChat menu (new for 2.6.2).
GUI DETACHSame function as "Detach Tab" in the XChat menu (new for 2.6.2).
GUI ATTACHSame function as "Attach Window" in the HexChat menu (new for 2.6.2).
GUI DETACHSame function as "Detach Tab" in the HexChat menu (new for 2.6.2).
GUI APPLYSimilar to clicking OK in the settings window. Execute this after /SET to activate GUI changes (new for 2.8.0)
GUI COLOR nChange the tab color of the current context, where n is a number from 0 to 3.
GUI FOCUSFocus the current window or tab.
GUI FLASHFlash the taskbar button. It will flash only if the window isn't focused and will stop when it is focused by the user.
GUI HIDEHide the main xchat window completely (this is used by the Systray plugin).
GUI ICONIFYIconify (minimize to taskbar) the current xchat window.
GUI HIDEHide the main HexChat window completely (this is used by the Systray plugin).
GUI ICONIFYIconify (minimize to taskbar) the current HexChat window.
GUI MSGBOX textDisplays a asynchronous message box with your text (new for 2.4.5).
GUI SHOWShow the main xchat window (if currently hidden).
GUI SHOWShow the main HexChat window (if currently hidden).

@@ -439,11 +439,11 @@ Parameters and flags: If you want to change an item's toggle state or enabled flag, just ADD an item with exactly the same name and command and specify the -tX -eX parameters you need. -

It's also possible to add items to XChat's existing menus, for example:
+

It's also possible to add items to HexChat's existing menus, for example:

	MENU ADD "Settings/Sub Menu"
 	MENU -t0 ADD "Settings/Sub Menu/My Setting" myseton mysetoff
 
-However, internal names and layouts of XChat's menu may change in the future, so use at own risk. +However, internal names and layouts of HexChat's menu may change in the future, so use at own risk.

Here is an example of Radio items:
	MENU ADD "Language"
@@ -468,10 +468,10 @@ From 2.8.0, you can also change menus other than the main one (i.e popup menus).
 

-Starting from 2.8.0 you can manipulate XChat's system tray icon using the /TRAY command: +Starting from 2.8.0 you can manipulate HexChat's system tray icon using the /TRAY command:
  Usage: 
- TRAY -f <timeout> <file1> [<file2>] Flash tray between two icons. Leave off file2 to use default xchat icon.
+ TRAY -f <timeout> <file1> [<file2>] Flash tray between two icons. Leave off file2 to use default HexChat icon.
  TRAY -f <filename>                  Set tray to a fixed icon.
  TRAY -i <number>                    Flash tray with an internal icon.
                                      2=Message 5=Highlight 8=Private 11=File
@@ -479,12 +479,12 @@ From 2.8.0, you can also change menus other than the main one (i.e popup menus).
  TRAY -b <title> <text>              Set the tray balloon.
                                      Supported on Windows from 2.8.1 and 2.8.2 on Linux (libnotify required on Linux).
 
-Filenames can be ICO or PNG format. PNG format is supported on Linux/BSD and Windows XP (but requires installation of GDI+ on Windows 2000). Set a timeout of -1 to use XChat's default. +Filenames can be ICO or PNG format. PNG format is supported on Linux/BSD and Windows XP (but requires installation of GDI+ on Windows 2000). Set a timeout of -1 to use HexChat's default.

Handling UTF-8/Unicode strings

-The XChat plugin API specifies that strings passed to and from xchat must be encoded in UTF-8. +The HexChat plugin API specifies that strings passed to and from HexChat must be encoded in UTF-8.

What does this mean for the plugin programmer? You just have to be a little careful when passing strings obtained from IRC to system calls. For example, if you're writing a file-server @@ -512,7 +512,7 @@ static void get_file_name(char *nick, char *fname) char buf[256]; FILE *fp; - /* the fname is in UTF-8, because it came from the xchat API */ + /* the fname is in UTF-8, because it came from the HexChat API */ #ifdef _WIN32

 	wchar_t wide_name[MAX_PATH];
 
@@ -601,7 +601,7 @@ xchat_hook_command(ph, "ONOTICE", XCHAT_PRI_NORM, onotice_cb,
 
ph: Plugin handle (as given to xchat_plugin_init).
fd: The file descriptor or socket.
flags: One or more of XCHAT_FD_READ, XCHAT_FD_WRITE, XCHAT_FD_EXCEPTION, XCHAT_FD_NOTSOCKET. Use bitwise OR to combine them. -XCHAT_FD_NOTSOCKET tells xchat that the provided fd is not a socket, but a "MSVCRT.DLL" pipe. +XCHAT_FD_NOTSOCKET tells HexChat that the provided fd is not a socket, but a "MSVCRT.DLL" pipe.
callb: Callback function. This will be called when the socket is available for reading/writing or exception (depending on your chosen flags)
userdata: Pointer passed to the callback function.
Returns: Pointer to the hook. Can be passed to xchat_unhook. @@ -644,7 +644,7 @@ tab-window is focused by the window manager. static int youpart_cb(char *word[], void *userdata) { xchat_printf(ph, "You have left channel %s\n", word[3]); - return XCHAT_EAT_XCHAT; /* dont let xchat do its normal printing */ + return XCHAT_EAT_XCHAT; /* dont let HexChat do its normal printing */ } xchat_hook_print(ph, "You Part", XCHAT_PRI_NORM, youpart_cb, NULL); @@ -673,7 +673,7 @@ hook every line that comes from the IRC server, you may use the special name of static int kick_cb(char *word[], char *word_eol[], void *userdata) { xchat_printf(ph, "%s was kicked from %s (reason=%s)\n", word[4], word[3], word_eol[5]); - return XCHAT_EAT_NONE; /* don't eat this event, let other plugins and xchat see it too */ + return XCHAT_EAT_NONE; /* don't eat this event, let other plugins and HexChat see it too */ } xchat_hook_server(ph, "KICK", XCHAT_PRI_NORM, kick_cb, NULL); @@ -737,7 +737,7 @@ removed, so you don't need to call this within your xchat_plugin_deinit() functi

 xchat_command() 

Prototype: void xchat_command(xchat_plugin *ph, const char *command);
-
Description: Executes a command as if it were typed in xchat's input box. +
Description: Executes a command as if it were typed in HexChat's input box.

Arguments:
ph: Plugin handle (as given to xchat_plugin_init). @@ -748,7 +748,7 @@ removed, so you don't need to call this within your xchat_plugin_deinit() functi

 xchat_commandf() 

Prototype: void xchat_commandf(xchat_plugin *ph, const char *format, ...);
-
Description: Executes a command as if it were typed in xchat's input box and provides string formating like printf. +
Description: Executes a command as if it were typed in HexChat's input box and provides string formating like printf.

Arguments:
ph: Plugin handle (as given to xchat_plugin_init). @@ -877,7 +877,7 @@ Changed in 2.6.1. If servname is NULL, it finds the channel (or query) by the gi win_ptrnative window pointer. Unix: (GtkWindow *) Win32: HWND (since 2.6.0). win_statuswindow status: "active", "hidden" or "normal" (since 2.0.9). xchatdirxchat config directory, e.g.: /home/user/.xchat2 This string is encoded in UTF-8, which means you _should_ convert it to "locale" encoding before using functions like open() or OpenFile(). For best Unicode support on Linux, convert this string using g_filename_from_utf8 and on Windows convert this string to UTF-16LE (wide) and use OpenFileW() etc. - xchatdirfsxchat config directory, e.g.: /home/user/.xchat2 (since 2.0.9).This string is encoded in local file system encoding, making it ideal for direct use with functions like open() or OpenFile(). For real Unicode support on Windows, it's best not to use xchatdirfs, but xchatdir instead. + xchatdirfsxchat config directory, e.g.: /home/user/.xchat2 (since 2.0.9).This string is encoded in local file system encoding, making it ideal for direct use with functions like open() or OpenFile(). For real Unicode support on Windows, it's best not to use HexChatdirfs, but HexChatdir instead.
diff --git a/plugins/python/python.c b/plugins/python/python.c index 4a594e05..9f3dd211 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -64,7 +64,7 @@ #include #endif -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #include "Python.h" #include "structmember.h" #include "pythread.h" diff --git a/plugins/sasl/sasl.c b/plugins/sasl/sasl.c index 5e2ea5c4..7978251e 100644 --- a/plugins/sasl/sasl.c +++ b/plugins/sasl/sasl.c @@ -38,7 +38,7 @@ #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" static xchat_plugin *ph; /* plugin handle */ static const char name[] = "SASL"; diff --git a/plugins/sysinfo/sysinfo.cpp b/plugins/sysinfo/sysinfo.cpp index 5cb4b766..d525e6b3 100644 --- a/plugins/sysinfo/sysinfo.cpp +++ b/plugins/sysinfo/sysinfo.cpp @@ -25,7 +25,7 @@ #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" static xchat_plugin *ph; /* plugin handle */ static char name[] = "SysInfo"; diff --git a/plugins/sysinfo/xsys.c b/plugins/sysinfo/xsys.c index f328b9b0..1d867dd1 100644 --- a/plugins/sysinfo/xsys.c +++ b/plugins/sysinfo/xsys.c @@ -28,7 +28,7 @@ #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #include "parse.h" #include "match.h" #include "xsys.h" diff --git a/plugins/tcl/tclplugin.c b/plugins/tcl/tclplugin.c index 17b0b99b..fe507bee 100644 --- a/plugins/tcl/tclplugin.c +++ b/plugins/tcl/tclplugin.c @@ -36,7 +36,7 @@ static char RCSID[] = "$Id: tclplugin.c,v 1.65 2012/07/26 20:02:12 mooooooo Exp #include #endif -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #include "tclplugin.h" #include "printevents.h" diff --git a/plugins/upd/upd.c b/plugins/upd/upd.c index f0ed0a2d..f6030910 100644 --- a/plugins/upd/upd.c +++ b/plugins/upd/upd.c @@ -23,7 +23,7 @@ #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" static xchat_plugin *ph; /* plugin handle */ static const char name[] = "Update Checker"; diff --git a/plugins/winamp/winamp.c b/plugins/winamp/winamp.c index 67907eba..eb9493a6 100644 --- a/plugins/winamp/winamp.c +++ b/plugins/winamp/winamp.c @@ -14,7 +14,7 @@ #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #define PLAYING 1 #define PAUSED 3 diff --git a/plugins/wmpa/hexchat-plugin.cpp b/plugins/wmpa/hexchat-plugin.cpp new file mode 100644 index 00000000..b8a21135 --- /dev/null +++ b/plugins/wmpa/hexchat-plugin.cpp @@ -0,0 +1,590 @@ +/****************************************************************** +* $Id$ +* +* $Log$ +* +* Copyright © 2005 David Cullen, All rights reserved +* +******************************************************************/ +#include "stdafx.h" +#include "hexchat-plugin.h" +#include +#include +#include "wmpa.h" +#include "WMPADialog.h" + +#define XMMS_SESSION 0 + +/****************************************************************** +* Globalss +******************************************************************/ +xchat_plugin *ph = NULL; +CWMPPlayer4 *wmp; +static const char subKey[] = "Software\\FlowerSoft\\WMPA"; + +/****************************************************************** +* xchat_plugin_init +******************************************************************/ +int xchat_plugin_init(xchat_plugin *plugin_handle, + char **plugin_name, + char **plugin_desc, + char **plugin_version, + char *arg) +{ + BOOL success; + + ph = plugin_handle; + + *plugin_name = "WMPA"; + *plugin_desc = "Announce the current song from Windows Media Player."; + *plugin_version = VER_STRING; + + // Show the song browser + success = StartWindowsMediaPlayer(); + if (!success) { + xchat_printf(ph, "WMPA: Failed to show the song browser."); + xchat_printf(ph, "WMPA: Could not load plug-in version %s.", VER_STRING); + return(E_FAIL); + } + + // Get a pointer to the Windows Media Player control + wmp = GetWindowsMediaPlayer(); + if (wmp == NULL) { + xchat_printf(ph, "WMPA: Failed to get a pointer to the Windows Media Player interface."); + xchat_printf(ph, "WMPA: Could not load plug-in version %s.", VER_STRING); + return(E_POINTER); + } + + // Restore the settings (need wmp first) + success = wmpaRestoreSettings(); + if (!success) { + xchat_printf(ph, "WMPA: Failed to restore the settings."); + } + + xchat_hook_command(ph, "auto", XCHAT_PRI_NORM, wmpaAuto, 0, 0); + xchat_hook_command(ph, "curr", XCHAT_PRI_NORM, wmpaCurr, 0, 0); + xchat_hook_command(ph, "find", XCHAT_PRI_NORM, wmpaFind, 0, 0); + xchat_hook_command(ph, "slist", XCHAT_PRI_NORM, wmpaList, 0, 0); + xchat_hook_command(ph, "next", XCHAT_PRI_NORM, wmpaNext, 0, 0); + xchat_hook_command(ph, "play", XCHAT_PRI_NORM, wmpaPlay, 0, 0); + xchat_hook_command(ph, "pause", XCHAT_PRI_NORM, wmpaPause, 0, 0); + xchat_hook_command(ph, "prev", XCHAT_PRI_NORM, wmpaPrev, 0, 0); + xchat_hook_command(ph, "song", XCHAT_PRI_NORM, wmpaSong, 0, 0); + xchat_hook_command(ph, "stop", XCHAT_PRI_NORM, wmpaStop, 0, 0); + xchat_hook_command(ph, "volume", XCHAT_PRI_NORM, wmpaVolume, 0, 0); + xchat_hook_command(ph, "wmpahelp", XCHAT_PRI_NORM, wmpaHelp, 0, 0); + + xchat_printf(ph, "WMPA %s successfully loaded.", VER_STRING); + wmpaCommands(); + xchat_printf(ph, "WMPA: e-mail me if you find any bugs: dcullen@intergate.com"); + + return 1; +} + +/****************************************************************** +* xchat_plugin_deinit +******************************************************************/ +int xchat_plugin_deinit(void) +{ + BOOL success; + + xchat_printf(ph, "WMPA %s is unloading.", VER_STRING); + + // Save the settings + success = wmpaSaveSettings(); + if (!success) { + xchat_printf(ph, "WMPA: Failed to save the settings."); + } + + wmp = NULL; + + BOOL result = StopWindowsMediaPlayer(); + if (!result) { + xchat_printf(ph, "WMPA could not shut down Windows Media Player."); + } + + xchat_printf(ph, "WMPA %s has unloaded.", VER_STRING); + return 1; +} + +/****************************************************************** +* xchat_plugin_get_info +******************************************************************/ +void xchat_plugin_get_info(char **name, char **desc, char **version, void **reserved) +{ + *name = "WMPA"; + *desc = "Announce the current song from Windows Media Player."; + *version = VER_STRING; + if (reserved) *reserved = NULL; +} + +/****************************************************************** +* wmpaCommands +******************************************************************/ +void wmpaCommands(void) +{ + xchat_printf(ph, "WMPA: /auto [on/off] : Turn on/off auto announce of the current song or display the current setting"); + xchat_printf(ph, "WMPA: /curr : Tell what song is currently playing"); + xchat_printf(ph, "WMPA: /find [word] : Find songs with \"word\" in their title, create a new playlist, and play it"); + xchat_printf(ph, "WMPA: /slist [word] : List songs with \"word\" in their title"); + xchat_printf(ph, "WMPA: /next : Play the next song"); + xchat_printf(ph, "WMPA: /play : Play the current song"); + xchat_printf(ph, "WMPA: /pause : Pause the current song"); + xchat_printf(ph, "WMPA: /prev : Play the previous song"); + xchat_printf(ph, "WMPA: /song : Announce the current song from Windows Media Player in HexChat"); + xchat_printf(ph, "WMPA: /stop : Stop the current song"); + xchat_printf(ph, "WMPA: /volume [volume] : Set the volume (0 to 100) or display the current volume"); + xchat_printf(ph, "WMPA: /wmpahelp : Display this help."); +} + +/****************************************************************** +* wmpaAuto +******************************************************************/ +int wmpaAuto(char *word[], char *word_eol[], void *user_data) +{ + CWMPADialog *pDialog; + char *state; + + pDialog = GetWMPADialog(); + if (pDialog == NULL) return(XCHAT_EAT_ALL); + + if (CString(word[2]).IsEmpty()) { + if (pDialog->autoAnnounce) { + state = "on"; + } + else { + state = "off"; + } + } + else { + state = word[2]; + if (CString(state) == "on") { + pDialog->autoAnnounce = TRUE; + } + if (CString(state) == "off") { + pDialog->autoAnnounce = FALSE; + } + wmpaSaveSettings(); + } + + xchat_printf(ph, "WMPA: auto is %s", state); + + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaCurr +******************************************************************/ +int wmpaCurr(char *word[], char *word_eol[], void *user_data) +{ + xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); + + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaFind +******************************************************************/ +int wmpaFind(char *word[], char *word_eol[], void *user_data) +{ + long index; + long count; + long found; + + if (wmp != NULL) { + CWMPMediaCollection mc = wmp->GetMediaCollection(); + CWMPPlaylist all = mc.getAll(); + CWMPPlaylistCollection pc = wmp->GetPlaylistCollection(); + CWMPPlaylistArray pa = pc.getAll(); + CWMPPlaylist playlist; + CWMPMedia media; + + for (index = 0; index < pc.getAll().GetCount(); index++) { + if (pc.getAll().Item(index).GetName() == CString(word_eol[2])) { + playlist = pc.getAll().Item(index); + pc.remove(playlist); + } + } + + playlist = pc.newPlaylist(word_eol[2]); + + count = all.GetCount(); + found = 0; + for (index = 0; index < count; index++) { + media = all.GetItem(index); + CString artist = media.getItemInfo("Artist"); + CString title = media.getItemInfo("Title"); + CString album = media.getItemInfo("Album"); + if ( (artist.Find(word_eol[2]) != -1) || + (title.Find(word_eol[2]) != -1) || + (album.Find(word_eol[2]) != -1) ) { + playlist.appendItem(media); + found++; + } + } + + if (found > 0) { + xchat_printf(ph, "WMPA: Found %d songs with \"%s\" in them", found, word_eol[2]); + wmp->SetCurrentPlaylist(playlist); + wmp->GetControls().play(); + xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); + + CWMPADialog *dialog = GetWMPADialog(); + if (dialog != NULL) { + dialog->UpdateSongList(); + dialog->SelectCurrentSong(); + dialog->UpdatePlayLists(); + } + + } + else { + xchat_printf(ph, "WMPA: Could not find %s", word_eol[2]); + } + + } + + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaList +******************************************************************/ +int wmpaList(char *word[], char *word_eol[], void *user_data) +{ + long index; + long count; + long found; + + if (wmp != NULL) { + xchat_printf(ph, "WMPA: Listing songs with \"%s\" in them", word_eol[2]); + + CWMPMediaCollection mc = wmp->GetMediaCollection(); + CWMPPlaylist all = mc.getAll(); + CWMPMedia media; + + count = all.GetCount(); + found = 0; + for (index = 0; index < count; index++) { + media = all.GetItem(index); + CString artist = media.getItemInfo("Artist"); + CString title = media.getItemInfo("Title"); + CString album = media.getItemInfo("Album"); + if ( (artist.Find(word_eol[2]) != -1) || + (title.Find(word_eol[2]) != -1) || + (album.Find(word_eol[2]) != -1) ) { + xchat_printf(ph, "WMPA: Found \"%s - %s (%s)\"", artist, title, album); + found++; + } + } + + if (found > 0) { + if (found == 1) + xchat_printf(ph, "WMPA: Found %d song with \"%s\" in it", found, word_eol[2]); + else + xchat_printf(ph, "WMPA: Found %d songs with \"%s\" in them", found, word_eol[2]); + } + else { + xchat_printf(ph, "WMPA: Could not find any songs with \"%s\" in them", word_eol[2]); + } + + } + + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaNext +******************************************************************/ +int wmpaNext(char *word[], char *word_eol[], void *user_data) +{ + if (wmp != NULL) { + wmp->GetControls().next(); + xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); + } + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaPlay +******************************************************************/ +int wmpaPlay(char *word[], char *word_eol[], void *user_data) +{ + if (wmp != NULL) { + wmp->GetControls().play(); + xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); + } + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaPause +******************************************************************/ +int wmpaPause(char *word[], char *word_eol[], void *user_data) +{ + if (wmp != NULL) { + wmp->GetControls().pause(); + xchat_printf(ph, "WMPA: Pausing %s", (LPCTSTR) wmpaGetSongTitle()); + } + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaPrev +******************************************************************/ +int wmpaPrev(char *word[], char *word_eol[], void *user_data) +{ + if (wmp != NULL) { + wmp->GetControls().previous(); + xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); + } + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaSong +******************************************************************/ +int wmpaSong(char *word[], char *word_eol[], void *user_data) +{ + CString songTitle = wmpaGetSongTitle(); + + xchat_commandf(ph, "me is playing %s", (LPCTSTR) songTitle); + + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaStop +******************************************************************/ +int wmpaStop(char *word[], char *word_eol[], void *user_data) +{ + if (wmp != NULL) { + wmp->GetControls().stop(); + xchat_printf(ph, "WMPA: Stopping %s", (LPCTSTR) wmpaGetSongTitle()); + } + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaHelp +******************************************************************/ +int wmpaHelp(char *word[], char *word_eol[], void *user_data) +{ + xchat_printf(ph, "\n"); + xchat_printf(ph, "WMPA %s Help", VER_STRING); + wmpaCommands(); + xchat_printf(ph, "\n"); + + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaVolume +******************************************************************/ +int wmpaVolume(char *word[], char *word_eol[], void *user_data) +{ + char *endPtr; + long volume; + + if (CString(word[2]).IsEmpty()) { + volume = wmp->GetSettings().GetVolume(); + } + else { + volume = strtol(word[2], &endPtr, 10); + + if ((wmp != NULL) && (volume >= 0) && (volume <= 100)) { + wmp->GetSettings().SetVolume(volume); + wmpaSaveSettings(); + } + } + + xchat_printf(ph, "WMPA: volume is %d", volume); + + return(XCHAT_EAT_ALL); +} + +/****************************************************************** +* wmpaRestoreSettings +******************************************************************/ +BOOL wmpaRestoreSettings(void) +{ + CWMPADialog *pDialog; + DWORD type; + int volume; + BOOL autoAnnounce; + DWORD size; + BOOL result; + + if (wmp == NULL) return(FALSE); + + volume = 50; + result = GetSetting("Volume", &type, (LPBYTE) &volume, &size); + wmp->GetSettings().SetVolume(volume); + + autoAnnounce = FALSE; + pDialog = GetWMPADialog(); + if (pDialog != NULL) { + result = result && GetSetting("Auto", &type, (LPBYTE) &autoAnnounce, &size); + pDialog->autoAnnounce = autoAnnounce; + } + else { + result = FALSE; + } + + return(result); +} + +/****************************************************************** +* wmpaSaveSettings +******************************************************************/ +BOOL wmpaSaveSettings(void) +{ + CWMPADialog *pDialog; + int volume; + BOOL autoAnnounce; + BOOL result; + + if (wmp == NULL) return(FALSE); + + volume = wmp->GetSettings().GetVolume(); + result = SaveSetting("Volume", REG_DWORD, (CONST BYTE *) &volume, sizeof(volume)); + + pDialog = GetWMPADialog(); + if (pDialog != NULL) { + autoAnnounce = pDialog->autoAnnounce; + result = result && SaveSetting("Auto", REG_DWORD, (CONST BYTE *) &autoAnnounce, sizeof(autoAnnounce)); + } + else { + result = FALSE; + } + + return(result); +} + +/****************************************************************** +* wmpaGetSongTitle +******************************************************************/ +CString wmpaGetSongTitle(void) +{ + char buffer[32]; + + if (wmp == NULL) return(CString()); + + CWMPMedia media = wmp->GetCurrentMedia(); + if (media == NULL) { + xchat_printf(ph, "WMPA: Could not get current media"); + return(XCHAT_EAT_ALL); + } + + CString artist = media.getItemInfo("Artist"); + CString title = media.getItemInfo("Title"); + CString album = media.getItemInfo("Album"); + CString bitrate = media.getItemInfo("Bitrate"); + CString duration = media.GetDurationString(); + + long krate = strtoul((LPCTSTR) bitrate, NULL, 10) / 1000; + _ultoa(krate, buffer, 10); + bitrate = CString(buffer); + + // Creatte the song title + CString songTitle(""); + songTitle += artist; + if (songTitle.IsEmpty()) songTitle += "Various"; + songTitle += " - "; + songTitle += title; + songTitle += " ("; + songTitle += album; + songTitle += ") ["; + songTitle += duration; + songTitle += "/"; + songTitle += bitrate; + songTitle += "Kbps]"; + + return(songTitle); +} + +/****************************************************************** +* SaveSetting +******************************************************************/ +BOOL SaveSetting(LPCTSTR name, DWORD type, CONST BYTE *value, DWORD size) +{ + HKEY hKey; + DWORD disposition; + LONG result; + + if (wmp == NULL) return(FALSE); + if (name == NULL) return(FALSE); + + result = RegOpenKeyEx(HKEY_CURRENT_USER, + subKey, + 0, + KEY_WRITE, + &hKey); + + if (result != ERROR_SUCCESS) { + result = RegCreateKeyEx(HKEY_CURRENT_USER, + subKey, + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_WRITE, + NULL, + &hKey, + &disposition); + + if (result != ERROR_SUCCESS) return(FALSE); + } + + result = RegSetValueEx(hKey, + name, + 0, + type, + value, + size); + + if (result == ERROR_SUCCESS) { + RegCloseKey(hKey); + return(TRUE); + } + + RegCloseKey(hKey); + return(FALSE); +} + +/****************************************************************** +* GetSetting +******************************************************************/ +BOOL GetSetting(LPCTSTR name, DWORD *type, LPBYTE value, DWORD *size) +{ + HKEY hKey; + LONG result; + + if (wmp == NULL) return(FALSE); + if (type == NULL) return(FALSE); + if (value == NULL) return(FALSE); + if (size == NULL) return(FALSE); + + result = RegOpenKeyEx(HKEY_CURRENT_USER, + subKey, + 0, + KEY_READ, + &hKey); + + if (result != ERROR_SUCCESS) return(FALSE); + + result = RegQueryValueEx(hKey, + name, + 0, + type, + value, + size); + + RegCloseKey(hKey); + + if (result == ERROR_SUCCESS) { + return(TRUE); + } + + RegCloseKey(hKey); + return(FALSE); +} + diff --git a/plugins/wmpa/hexchat-plugin.h b/plugins/wmpa/hexchat-plugin.h new file mode 100644 index 00000000..cec27a6f --- /dev/null +++ b/plugins/wmpa/hexchat-plugin.h @@ -0,0 +1,368 @@ +/* You can distribute this header with your plugins for easy compilation */ +#ifndef HEXCHAT_PLUGIN_H +#define HEXCHAT_PLUGIN_H + +#define VER_STRING _T("1.0.2 (BETA)") + +#include "stdafx.h" +#include +#include +#include + +#define XCHAT_IFACE_MAJOR 1 +#define XCHAT_IFACE_MINOR 9 +#define XCHAT_IFACE_MICRO 11 +#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \ + (XCHAT_IFACE_MINOR * 100) + \ + (XCHAT_IFACE_MICRO)) + +#define XCHAT_PRI_HIGHEST 127 +#define XCHAT_PRI_HIGH 64 +#define XCHAT_PRI_NORM 0 +#define XCHAT_PRI_LOW (-64) +#define XCHAT_PRI_LOWEST (-128) + +#define XCHAT_FD_READ 1 +#define XCHAT_FD_WRITE 2 +#define XCHAT_FD_EXCEPTION 4 +#define XCHAT_FD_NOTSOCKET 8 + +#define XCHAT_EAT_NONE 0 /* pass it on through! */ +#define XCHAT_EAT_XCHAT 1 /* don't let xchat see this event */ +#define XCHAT_EAT_PLUGIN 2 /* don't let other plugins see this event */ +#define XCHAT_EAT_ALL (XCHAT_EAT_XCHAT|XCHAT_EAT_PLUGIN) /* don't let anything see this event */ + +#ifdef __cplusplus +extern "C" { +#endif + + + typedef struct _xchat_plugin xchat_plugin; + typedef struct _xchat_list xchat_list; + typedef struct _xchat_hook xchat_hook; +#ifndef PLUGIN_C + typedef struct _xchat_context xchat_context; +#endif + +#ifndef PLUGIN_C + struct _xchat_plugin { + /* these are only used on win32 */ + xchat_hook *(*xchat_hook_command) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + const char *help_text, + void *userdata); + xchat_hook *(*xchat_hook_server) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_print) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_timer) (xchat_plugin *ph, + int timeout, + int (*callback) (void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_fd) (xchat_plugin *ph, + int fd, + int flags, + int (*callback) (int fd, int flags, void *user_data), + void *userdata); + void *(*xchat_unhook) (xchat_plugin *ph, + xchat_hook *hook); + void (*xchat_print) (xchat_plugin *ph, + const char *text); + void (*xchat_printf) (xchat_plugin *ph, + const char *format, ...); + void (*xchat_command) (xchat_plugin *ph, + const char *command); + void (*xchat_commandf) (xchat_plugin *ph, + const char *format, ...); + int (*xchat_nickcmp) (xchat_plugin *ph, + const char *s1, + const char *s2); + int (*xchat_set_context) (xchat_plugin *ph, + xchat_context *ctx); + xchat_context *(*xchat_find_context) (xchat_plugin *ph, + const char *servname, + const char *channel); + xchat_context *(*xchat_get_context) (xchat_plugin *ph); + const char *(*xchat_get_info) (xchat_plugin *ph, + const char *id); + int (*xchat_get_prefs) (xchat_plugin *ph, + const char *name, + const char **string, + int *integer); + xchat_list * (*xchat_list_get) (xchat_plugin *ph, + const char *name); + void (*xchat_list_free) (xchat_plugin *ph, + xchat_list *xlist); + const char * const * (*xchat_list_fields) (xchat_plugin *ph, + const char *name); + int (*xchat_list_next) (xchat_plugin *ph, + xchat_list *xlist); + const char * (*xchat_list_str) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + int (*xchat_list_int) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + void * (*xchat_plugingui_add) (xchat_plugin *ph, + const char *filename, + const char *name, + const char *desc, + const char *version, + char *reserved); + void (*xchat_plugingui_remove) (xchat_plugin *ph, + void *handle); + int (*xchat_emit_print) (xchat_plugin *ph, + const char *event_name, ...); + int (*xchat_read_fd) (xchat_plugin *ph, + void *src, + char *buf, + int *len); + time_t (*xchat_list_time) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + char *(*xchat_gettext) (xchat_plugin *ph, + const char *msgid); + void (*xchat_send_modes) (xchat_plugin *ph, + const char **targets, + int ntargets, + int modes_per_line, + char sign, + char mode); + char *(*xchat_strip) (xchat_plugin *ph, + const char *str, + int len, + int flags); + void (*xchat_free) (xchat_plugin *ph, + void *ptr); + }; +#endif + + + xchat_hook * + xchat_hook_command (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + const char *help_text, + void *userdata); + + xchat_hook * + xchat_hook_server (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + void *userdata); + + xchat_hook * + xchat_hook_print (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], void *user_data), + void *userdata); + + xchat_hook * + xchat_hook_timer (xchat_plugin *ph, + int timeout, + int (*callback) (void *user_data), + void *userdata); + + xchat_hook * + xchat_hook_fd (xchat_plugin *ph, + int fd, + int flags, + int (*callback) (int fd, int flags, void *user_data), + void *userdata); + + void * + xchat_unhook (xchat_plugin *ph, + xchat_hook *hook); + + void + xchat_print (xchat_plugin *ph, + const char *text); + + void + xchat_printf (xchat_plugin *ph, + const char *format, ...); + + void + xchat_command (xchat_plugin *ph, + const char *command); + + void + xchat_commandf (xchat_plugin *ph, + const char *format, ...); + + int + xchat_nickcmp (xchat_plugin *ph, + const char *s1, + const char *s2); + + int + xchat_set_context (xchat_plugin *ph, + xchat_context *ctx); + + xchat_context * + xchat_find_context (xchat_plugin *ph, + const char *servname, + const char *channel); + + xchat_context * + xchat_get_context (xchat_plugin *ph); + + const char * + xchat_get_info (xchat_plugin *ph, + const char *id); + + int + xchat_get_prefs (xchat_plugin *ph, + const char *name, + const char **string, + int *integer); + + xchat_list * + xchat_list_get (xchat_plugin *ph, + const char *name); + + void + xchat_list_free (xchat_plugin *ph, + xchat_list *xlist); + + const char * const * + xchat_list_fields (xchat_plugin *ph, + const char *name); + + int + xchat_list_next (xchat_plugin *ph, + xchat_list *xlist); + + const char * + xchat_list_str (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + + int + xchat_list_int (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + + time_t + xchat_list_time (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + + void * + xchat_plugingui_add (xchat_plugin *ph, + const char *filename, + const char *name, + const char *desc, + const char *version, + char *reserved); + + void + xchat_plugingui_remove (xchat_plugin *ph, + void *handle); + + int + xchat_emit_print (xchat_plugin *ph, + const char *event_name, ...); + + char * + xchat_gettext (xchat_plugin *ph, + const char *msgid); + + void + xchat_send_modes (xchat_plugin *ph, + const char **targets, + int ntargets, + int modes_per_line, + char sign, + char mode); + + char * + xchat_strip (xchat_plugin *ph, + const char *str, + int len, + int flags); + + void + xchat_free (xchat_plugin *ph, + void *ptr); + +#if !defined(PLUGIN_C) && defined(WIN32) +#ifndef XCHAT_PLUGIN_HANDLE +#define XCHAT_PLUGIN_HANDLE (ph) +#endif +#define xchat_hook_command ((XCHAT_PLUGIN_HANDLE)->xchat_hook_command) +#define xchat_hook_server ((XCHAT_PLUGIN_HANDLE)->xchat_hook_server) +#define xchat_hook_print ((XCHAT_PLUGIN_HANDLE)->xchat_hook_print) +#define xchat_hook_timer ((XCHAT_PLUGIN_HANDLE)->xchat_hook_timer) +#define xchat_hook_fd ((XCHAT_PLUGIN_HANDLE)->xchat_hook_fd) +#define xchat_unhook ((XCHAT_PLUGIN_HANDLE)->xchat_unhook) +#define xchat_print ((XCHAT_PLUGIN_HANDLE)->xchat_print) +#define xchat_printf ((XCHAT_PLUGIN_HANDLE)->xchat_printf) +#define xchat_command ((XCHAT_PLUGIN_HANDLE)->xchat_command) +#define xchat_commandf ((XCHAT_PLUGIN_HANDLE)->xchat_commandf) +#define xchat_nickcmp ((XCHAT_PLUGIN_HANDLE)->xchat_nickcmp) +#define xchat_set_context ((XCHAT_PLUGIN_HANDLE)->xchat_set_context) +#define xchat_find_context ((XCHAT_PLUGIN_HANDLE)->xchat_find_context) +#define xchat_get_context ((XCHAT_PLUGIN_HANDLE)->xchat_get_context) +#define xchat_get_info ((XCHAT_PLUGIN_HANDLE)->xchat_get_info) +#define xchat_get_prefs ((XCHAT_PLUGIN_HANDLE)->xchat_get_prefs) +#define xchat_list_get ((XCHAT_PLUGIN_HANDLE)->xchat_list_get) +#define xchat_list_free ((XCHAT_PLUGIN_HANDLE)->xchat_list_free) +#define xchat_list_fields ((XCHAT_PLUGIN_HANDLE)->xchat_list_fields) +#define xchat_list_str ((XCHAT_PLUGIN_HANDLE)->xchat_list_str) +#define xchat_list_int ((XCHAT_PLUGIN_HANDLE)->xchat_list_int) +#define xchat_list_time ((XCHAT_PLUGIN_HANDLE)->xchat_list_time) +#define xchat_list_next ((XCHAT_PLUGIN_HANDLE)->xchat_list_next) +#define xchat_plugingui_add ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_add) +#define xchat_plugingui_remove ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_remove) +#define xchat_emit_print ((XCHAT_PLUGIN_HANDLE)->xchat_emit_print) +#define xchat_gettext ((XCHAT_PLUGIN_HANDLE)->xchat_gettext) +#define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) +#define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) +#define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) +#endif + +#ifdef __cplusplus +} +#endif + +/****************************************************************** +* Globals +******************************************************************/ +extern xchat_plugin *ph; + +/****************************************************************** +* Prototypes +******************************************************************/ +void wmpaCommands(void); +int wmpaAuto(char *word[], char *word_eol[], void *user_data); +int wmpaCurr(char *word[], char *word_eol[], void *user_data); +int wmpaFind(char *word[], char *word_eol[], void *user_data); +int wmpaList(char *word[], char *word_eol[], void *user_data); +int wmpaNext(char *word[], char *word_eol[], void *user_data); +int wmpaPlay(char *word[], char *word_eol[], void *user_data); +int wmpaPause(char *word[], char *word_eol[], void *user_data); +int wmpaPrev(char *word[], char *word_eol[], void *user_data); +int wmpaSong(char *word[], char *word_eol[], void *user_data); +int wmpaStop(char *word[], char *word_eol[], void *user_data); +int wmpaVolume(char *word[], char *word_eol[], void *user_data); +int wmpaHelp(char *word[], char *word_eol[], void *user_data); +BOOL wmpaRestoreSettings(void); +BOOL wmpaSaveSettings(void); +CString wmpaGetSongTitle(void); +BOOL SaveSetting(LPCTSTR name, DWORD type, CONST BYTE *value, DWORD size); +BOOL GetSetting(LPCTSTR name, DWORD *type, LPBYTE value, DWORD *size); + +#endif /* XCHAT_PLUGIN_H */ + diff --git a/plugins/wmpa/wmpa-xp.vcxproj b/plugins/wmpa/wmpa-xp.vcxproj index fb367520..15fed71d 100644 --- a/plugins/wmpa/wmpa-xp.vcxproj +++ b/plugins/wmpa/wmpa-xp.vcxproj @@ -118,7 +118,7 @@ - + @@ -142,7 +142,7 @@ - + diff --git a/plugins/wmpa/wmpa-xp.vcxproj.filters b/plugins/wmpa/wmpa-xp.vcxproj.filters index 2be9d82f..7910f0d8 100644 --- a/plugins/wmpa/wmpa-xp.vcxproj.filters +++ b/plugins/wmpa/wmpa-xp.vcxproj.filters @@ -78,7 +78,7 @@ Source Files - + Source Files @@ -146,7 +146,7 @@ Header Files - + Header Files diff --git a/plugins/wmpa/wmpa.vcxproj b/plugins/wmpa/wmpa.vcxproj index 7dafe2a6..0e5db7dc 100644 --- a/plugins/wmpa/wmpa.vcxproj +++ b/plugins/wmpa/wmpa.vcxproj @@ -115,7 +115,7 @@ - + @@ -139,7 +139,7 @@ - + diff --git a/plugins/wmpa/wmpa.vcxproj.filters b/plugins/wmpa/wmpa.vcxproj.filters index 2be9d82f..7910f0d8 100644 --- a/plugins/wmpa/wmpa.vcxproj.filters +++ b/plugins/wmpa/wmpa.vcxproj.filters @@ -78,7 +78,7 @@ Source Files - + Source Files @@ -146,7 +146,7 @@ Header Files - + Header Files diff --git a/plugins/wmpa/wmpadialog.cpp b/plugins/wmpa/wmpadialog.cpp index b0cdd16e..90bae309 100644 --- a/plugins/wmpa/wmpadialog.cpp +++ b/plugins/wmpa/wmpadialog.cpp @@ -10,7 +10,7 @@ #include "wmpa.h" #include "WMPADialog.h" #include "shellapi.h" -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #ifdef _DEBUG #define new DEBUG_NEW diff --git a/plugins/wmpa/xchat-plugin.cpp b/plugins/wmpa/xchat-plugin.cpp deleted file mode 100644 index 7b3bc737..00000000 --- a/plugins/wmpa/xchat-plugin.cpp +++ /dev/null @@ -1,590 +0,0 @@ -/****************************************************************** -* $Id$ -* -* $Log$ -* -* Copyright © 2005 David Cullen, All rights reserved -* -******************************************************************/ -#include "stdafx.h" -#include "xchat-plugin.h" -#include -#include -#include "wmpa.h" -#include "WMPADialog.h" - -#define XMMS_SESSION 0 - -/****************************************************************** -* Globalss -******************************************************************/ -xchat_plugin *ph = NULL; -CWMPPlayer4 *wmp; -static const char subKey[] = "Software\\FlowerSoft\\WMPA"; - -/****************************************************************** -* xchat_plugin_init -******************************************************************/ -int xchat_plugin_init(xchat_plugin *plugin_handle, - char **plugin_name, - char **plugin_desc, - char **plugin_version, - char *arg) -{ - BOOL success; - - ph = plugin_handle; - - *plugin_name = "WMPA"; - *plugin_desc = "Announce the current song from Windows Media Player."; - *plugin_version = VER_STRING; - - // Show the song browser - success = StartWindowsMediaPlayer(); - if (!success) { - xchat_printf(ph, "WMPA: Failed to show the song browser."); - xchat_printf(ph, "WMPA: Could not load plug-in version %s.", VER_STRING); - return(E_FAIL); - } - - // Get a pointer to the Windows Media Player control - wmp = GetWindowsMediaPlayer(); - if (wmp == NULL) { - xchat_printf(ph, "WMPA: Failed to get a pointer to the Windows Media Player interface."); - xchat_printf(ph, "WMPA: Could not load plug-in version %s.", VER_STRING); - return(E_POINTER); - } - - // Restore the settings (need wmp first) - success = wmpaRestoreSettings(); - if (!success) { - xchat_printf(ph, "WMPA: Failed to restore the settings."); - } - - xchat_hook_command(ph, "auto", XCHAT_PRI_NORM, wmpaAuto, 0, 0); - xchat_hook_command(ph, "curr", XCHAT_PRI_NORM, wmpaCurr, 0, 0); - xchat_hook_command(ph, "find", XCHAT_PRI_NORM, wmpaFind, 0, 0); - xchat_hook_command(ph, "slist", XCHAT_PRI_NORM, wmpaList, 0, 0); - xchat_hook_command(ph, "next", XCHAT_PRI_NORM, wmpaNext, 0, 0); - xchat_hook_command(ph, "play", XCHAT_PRI_NORM, wmpaPlay, 0, 0); - xchat_hook_command(ph, "pause", XCHAT_PRI_NORM, wmpaPause, 0, 0); - xchat_hook_command(ph, "prev", XCHAT_PRI_NORM, wmpaPrev, 0, 0); - xchat_hook_command(ph, "song", XCHAT_PRI_NORM, wmpaSong, 0, 0); - xchat_hook_command(ph, "stop", XCHAT_PRI_NORM, wmpaStop, 0, 0); - xchat_hook_command(ph, "volume", XCHAT_PRI_NORM, wmpaVolume, 0, 0); - xchat_hook_command(ph, "wmpahelp", XCHAT_PRI_NORM, wmpaHelp, 0, 0); - - xchat_printf(ph, "WMPA %s successfully loaded.", VER_STRING); - wmpaCommands(); - xchat_printf(ph, "WMPA: e-mail me if you find any bugs: dcullen@intergate.com"); - - return 1; -} - -/****************************************************************** -* xchat_plugin_deinit -******************************************************************/ -int xchat_plugin_deinit(void) -{ - BOOL success; - - xchat_printf(ph, "WMPA %s is unloading.", VER_STRING); - - // Save the settings - success = wmpaSaveSettings(); - if (!success) { - xchat_printf(ph, "WMPA: Failed to save the settings."); - } - - wmp = NULL; - - BOOL result = StopWindowsMediaPlayer(); - if (!result) { - xchat_printf(ph, "WMPA could not shut down Windows Media Player."); - } - - xchat_printf(ph, "WMPA %s has unloaded.", VER_STRING); - return 1; -} - -/****************************************************************** -* xchat_plugin_get_info -******************************************************************/ -void xchat_plugin_get_info(char **name, char **desc, char **version, void **reserved) -{ - *name = "WMPA"; - *desc = "Announce the current song from Windows Media Player."; - *version = VER_STRING; - if (reserved) *reserved = NULL; -} - -/****************************************************************** -* wmpaCommands -******************************************************************/ -void wmpaCommands(void) -{ - xchat_printf(ph, "WMPA: /auto [on/off] : Turn on/off auto announce of the current song or display the current setting"); - xchat_printf(ph, "WMPA: /curr : Tell what song is currently playing"); - xchat_printf(ph, "WMPA: /find [word] : Find songs with \"word\" in their title, create a new playlist, and play it"); - xchat_printf(ph, "WMPA: /slist [word] : List songs with \"word\" in their title"); - xchat_printf(ph, "WMPA: /next : Play the next song"); - xchat_printf(ph, "WMPA: /play : Play the current song"); - xchat_printf(ph, "WMPA: /pause : Pause the current song"); - xchat_printf(ph, "WMPA: /prev : Play the previous song"); - xchat_printf(ph, "WMPA: /song : Announce the current song from Windows Media Player in HexChat"); - xchat_printf(ph, "WMPA: /stop : Stop the current song"); - xchat_printf(ph, "WMPA: /volume [volume] : Set the volume (0 to 100) or display the current volume"); - xchat_printf(ph, "WMPA: /wmpahelp : Display this help."); -} - -/****************************************************************** -* wmpaAuto -******************************************************************/ -int wmpaAuto(char *word[], char *word_eol[], void *user_data) -{ - CWMPADialog *pDialog; - char *state; - - pDialog = GetWMPADialog(); - if (pDialog == NULL) return(XCHAT_EAT_ALL); - - if (CString(word[2]).IsEmpty()) { - if (pDialog->autoAnnounce) { - state = "on"; - } - else { - state = "off"; - } - } - else { - state = word[2]; - if (CString(state) == "on") { - pDialog->autoAnnounce = TRUE; - } - if (CString(state) == "off") { - pDialog->autoAnnounce = FALSE; - } - wmpaSaveSettings(); - } - - xchat_printf(ph, "WMPA: auto is %s", state); - - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaCurr -******************************************************************/ -int wmpaCurr(char *word[], char *word_eol[], void *user_data) -{ - xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); - - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaFind -******************************************************************/ -int wmpaFind(char *word[], char *word_eol[], void *user_data) -{ - long index; - long count; - long found; - - if (wmp != NULL) { - CWMPMediaCollection mc = wmp->GetMediaCollection(); - CWMPPlaylist all = mc.getAll(); - CWMPPlaylistCollection pc = wmp->GetPlaylistCollection(); - CWMPPlaylistArray pa = pc.getAll(); - CWMPPlaylist playlist; - CWMPMedia media; - - for (index = 0; index < pc.getAll().GetCount(); index++) { - if (pc.getAll().Item(index).GetName() == CString(word_eol[2])) { - playlist = pc.getAll().Item(index); - pc.remove(playlist); - } - } - - playlist = pc.newPlaylist(word_eol[2]); - - count = all.GetCount(); - found = 0; - for (index = 0; index < count; index++) { - media = all.GetItem(index); - CString artist = media.getItemInfo("Artist"); - CString title = media.getItemInfo("Title"); - CString album = media.getItemInfo("Album"); - if ( (artist.Find(word_eol[2]) != -1) || - (title.Find(word_eol[2]) != -1) || - (album.Find(word_eol[2]) != -1) ) { - playlist.appendItem(media); - found++; - } - } - - if (found > 0) { - xchat_printf(ph, "WMPA: Found %d songs with \"%s\" in them", found, word_eol[2]); - wmp->SetCurrentPlaylist(playlist); - wmp->GetControls().play(); - xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); - - CWMPADialog *dialog = GetWMPADialog(); - if (dialog != NULL) { - dialog->UpdateSongList(); - dialog->SelectCurrentSong(); - dialog->UpdatePlayLists(); - } - - } - else { - xchat_printf(ph, "WMPA: Could not find %s", word_eol[2]); - } - - } - - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaList -******************************************************************/ -int wmpaList(char *word[], char *word_eol[], void *user_data) -{ - long index; - long count; - long found; - - if (wmp != NULL) { - xchat_printf(ph, "WMPA: Listing songs with \"%s\" in them", word_eol[2]); - - CWMPMediaCollection mc = wmp->GetMediaCollection(); - CWMPPlaylist all = mc.getAll(); - CWMPMedia media; - - count = all.GetCount(); - found = 0; - for (index = 0; index < count; index++) { - media = all.GetItem(index); - CString artist = media.getItemInfo("Artist"); - CString title = media.getItemInfo("Title"); - CString album = media.getItemInfo("Album"); - if ( (artist.Find(word_eol[2]) != -1) || - (title.Find(word_eol[2]) != -1) || - (album.Find(word_eol[2]) != -1) ) { - xchat_printf(ph, "WMPA: Found \"%s - %s (%s)\"", artist, title, album); - found++; - } - } - - if (found > 0) { - if (found == 1) - xchat_printf(ph, "WMPA: Found %d song with \"%s\" in it", found, word_eol[2]); - else - xchat_printf(ph, "WMPA: Found %d songs with \"%s\" in them", found, word_eol[2]); - } - else { - xchat_printf(ph, "WMPA: Could not find any songs with \"%s\" in them", word_eol[2]); - } - - } - - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaNext -******************************************************************/ -int wmpaNext(char *word[], char *word_eol[], void *user_data) -{ - if (wmp != NULL) { - wmp->GetControls().next(); - xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); - } - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaPlay -******************************************************************/ -int wmpaPlay(char *word[], char *word_eol[], void *user_data) -{ - if (wmp != NULL) { - wmp->GetControls().play(); - xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); - } - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaPause -******************************************************************/ -int wmpaPause(char *word[], char *word_eol[], void *user_data) -{ - if (wmp != NULL) { - wmp->GetControls().pause(); - xchat_printf(ph, "WMPA: Pausing %s", (LPCTSTR) wmpaGetSongTitle()); - } - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaPrev -******************************************************************/ -int wmpaPrev(char *word[], char *word_eol[], void *user_data) -{ - if (wmp != NULL) { - wmp->GetControls().previous(); - xchat_printf(ph, "WMPA: Playing %s", (LPCTSTR) wmpaGetSongTitle()); - } - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaSong -******************************************************************/ -int wmpaSong(char *word[], char *word_eol[], void *user_data) -{ - CString songTitle = wmpaGetSongTitle(); - - xchat_commandf(ph, "me is playing %s", (LPCTSTR) songTitle); - - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaStop -******************************************************************/ -int wmpaStop(char *word[], char *word_eol[], void *user_data) -{ - if (wmp != NULL) { - wmp->GetControls().stop(); - xchat_printf(ph, "WMPA: Stopping %s", (LPCTSTR) wmpaGetSongTitle()); - } - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaHelp -******************************************************************/ -int wmpaHelp(char *word[], char *word_eol[], void *user_data) -{ - xchat_printf(ph, "\n"); - xchat_printf(ph, "WMPA %s Help", VER_STRING); - wmpaCommands(); - xchat_printf(ph, "\n"); - - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaVolume -******************************************************************/ -int wmpaVolume(char *word[], char *word_eol[], void *user_data) -{ - char *endPtr; - long volume; - - if (CString(word[2]).IsEmpty()) { - volume = wmp->GetSettings().GetVolume(); - } - else { - volume = strtol(word[2], &endPtr, 10); - - if ((wmp != NULL) && (volume >= 0) && (volume <= 100)) { - wmp->GetSettings().SetVolume(volume); - wmpaSaveSettings(); - } - } - - xchat_printf(ph, "WMPA: volume is %d", volume); - - return(XCHAT_EAT_ALL); -} - -/****************************************************************** -* wmpaRestoreSettings -******************************************************************/ -BOOL wmpaRestoreSettings(void) -{ - CWMPADialog *pDialog; - DWORD type; - int volume; - BOOL autoAnnounce; - DWORD size; - BOOL result; - - if (wmp == NULL) return(FALSE); - - volume = 50; - result = GetSetting("Volume", &type, (LPBYTE) &volume, &size); - wmp->GetSettings().SetVolume(volume); - - autoAnnounce = FALSE; - pDialog = GetWMPADialog(); - if (pDialog != NULL) { - result = result && GetSetting("Auto", &type, (LPBYTE) &autoAnnounce, &size); - pDialog->autoAnnounce = autoAnnounce; - } - else { - result = FALSE; - } - - return(result); -} - -/****************************************************************** -* wmpaSaveSettings -******************************************************************/ -BOOL wmpaSaveSettings(void) -{ - CWMPADialog *pDialog; - int volume; - BOOL autoAnnounce; - BOOL result; - - if (wmp == NULL) return(FALSE); - - volume = wmp->GetSettings().GetVolume(); - result = SaveSetting("Volume", REG_DWORD, (CONST BYTE *) &volume, sizeof(volume)); - - pDialog = GetWMPADialog(); - if (pDialog != NULL) { - autoAnnounce = pDialog->autoAnnounce; - result = result && SaveSetting("Auto", REG_DWORD, (CONST BYTE *) &autoAnnounce, sizeof(autoAnnounce)); - } - else { - result = FALSE; - } - - return(result); -} - -/****************************************************************** -* wmpaGetSongTitle -******************************************************************/ -CString wmpaGetSongTitle(void) -{ - char buffer[32]; - - if (wmp == NULL) return(CString()); - - CWMPMedia media = wmp->GetCurrentMedia(); - if (media == NULL) { - xchat_printf(ph, "WMPA: Could not get current media"); - return(XCHAT_EAT_ALL); - } - - CString artist = media.getItemInfo("Artist"); - CString title = media.getItemInfo("Title"); - CString album = media.getItemInfo("Album"); - CString bitrate = media.getItemInfo("Bitrate"); - CString duration = media.GetDurationString(); - - long krate = strtoul((LPCTSTR) bitrate, NULL, 10) / 1000; - _ultoa(krate, buffer, 10); - bitrate = CString(buffer); - - // Creatte the song title - CString songTitle(""); - songTitle += artist; - if (songTitle.IsEmpty()) songTitle += "Various"; - songTitle += " - "; - songTitle += title; - songTitle += " ("; - songTitle += album; - songTitle += ") ["; - songTitle += duration; - songTitle += "/"; - songTitle += bitrate; - songTitle += "Kbps]"; - - return(songTitle); -} - -/****************************************************************** -* SaveSetting -******************************************************************/ -BOOL SaveSetting(LPCTSTR name, DWORD type, CONST BYTE *value, DWORD size) -{ - HKEY hKey; - DWORD disposition; - LONG result; - - if (wmp == NULL) return(FALSE); - if (name == NULL) return(FALSE); - - result = RegOpenKeyEx(HKEY_CURRENT_USER, - subKey, - 0, - KEY_WRITE, - &hKey); - - if (result != ERROR_SUCCESS) { - result = RegCreateKeyEx(HKEY_CURRENT_USER, - subKey, - 0, - NULL, - REG_OPTION_NON_VOLATILE, - KEY_WRITE, - NULL, - &hKey, - &disposition); - - if (result != ERROR_SUCCESS) return(FALSE); - } - - result = RegSetValueEx(hKey, - name, - 0, - type, - value, - size); - - if (result == ERROR_SUCCESS) { - RegCloseKey(hKey); - return(TRUE); - } - - RegCloseKey(hKey); - return(FALSE); -} - -/****************************************************************** -* GetSetting -******************************************************************/ -BOOL GetSetting(LPCTSTR name, DWORD *type, LPBYTE value, DWORD *size) -{ - HKEY hKey; - LONG result; - - if (wmp == NULL) return(FALSE); - if (type == NULL) return(FALSE); - if (value == NULL) return(FALSE); - if (size == NULL) return(FALSE); - - result = RegOpenKeyEx(HKEY_CURRENT_USER, - subKey, - 0, - KEY_READ, - &hKey); - - if (result != ERROR_SUCCESS) return(FALSE); - - result = RegQueryValueEx(hKey, - name, - 0, - type, - value, - size); - - RegCloseKey(hKey); - - if (result == ERROR_SUCCESS) { - return(TRUE); - } - - RegCloseKey(hKey); - return(FALSE); -} - diff --git a/plugins/wmpa/xchat-plugin.h b/plugins/wmpa/xchat-plugin.h deleted file mode 100644 index ee189ffe..00000000 --- a/plugins/wmpa/xchat-plugin.h +++ /dev/null @@ -1,368 +0,0 @@ -/* You can distribute this header with your plugins for easy compilation */ -#ifndef XCHAT_PLUGIN_H -#define XCHAT_PLUGIN_H - -#define VER_STRING _T("1.0.2 (BETA)") - -#include "stdafx.h" -#include -#include -#include - -#define XCHAT_IFACE_MAJOR 1 -#define XCHAT_IFACE_MINOR 9 -#define XCHAT_IFACE_MICRO 11 -#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \ - (XCHAT_IFACE_MINOR * 100) + \ - (XCHAT_IFACE_MICRO)) - -#define XCHAT_PRI_HIGHEST 127 -#define XCHAT_PRI_HIGH 64 -#define XCHAT_PRI_NORM 0 -#define XCHAT_PRI_LOW (-64) -#define XCHAT_PRI_LOWEST (-128) - -#define XCHAT_FD_READ 1 -#define XCHAT_FD_WRITE 2 -#define XCHAT_FD_EXCEPTION 4 -#define XCHAT_FD_NOTSOCKET 8 - -#define XCHAT_EAT_NONE 0 /* pass it on through! */ -#define XCHAT_EAT_XCHAT 1 /* don't let xchat see this event */ -#define XCHAT_EAT_PLUGIN 2 /* don't let other plugins see this event */ -#define XCHAT_EAT_ALL (XCHAT_EAT_XCHAT|XCHAT_EAT_PLUGIN) /* don't let anything see this event */ - -#ifdef __cplusplus -extern "C" { -#endif - - - typedef struct _xchat_plugin xchat_plugin; - typedef struct _xchat_list xchat_list; - typedef struct _xchat_hook xchat_hook; -#ifndef PLUGIN_C - typedef struct _xchat_context xchat_context; -#endif - -#ifndef PLUGIN_C - struct _xchat_plugin { - /* these are only used on win32 */ - xchat_hook *(*xchat_hook_command) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - const char *help_text, - void *userdata); - xchat_hook *(*xchat_hook_server) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_print) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_timer) (xchat_plugin *ph, - int timeout, - int (*callback) (void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_fd) (xchat_plugin *ph, - int fd, - int flags, - int (*callback) (int fd, int flags, void *user_data), - void *userdata); - void *(*xchat_unhook) (xchat_plugin *ph, - xchat_hook *hook); - void (*xchat_print) (xchat_plugin *ph, - const char *text); - void (*xchat_printf) (xchat_plugin *ph, - const char *format, ...); - void (*xchat_command) (xchat_plugin *ph, - const char *command); - void (*xchat_commandf) (xchat_plugin *ph, - const char *format, ...); - int (*xchat_nickcmp) (xchat_plugin *ph, - const char *s1, - const char *s2); - int (*xchat_set_context) (xchat_plugin *ph, - xchat_context *ctx); - xchat_context *(*xchat_find_context) (xchat_plugin *ph, - const char *servname, - const char *channel); - xchat_context *(*xchat_get_context) (xchat_plugin *ph); - const char *(*xchat_get_info) (xchat_plugin *ph, - const char *id); - int (*xchat_get_prefs) (xchat_plugin *ph, - const char *name, - const char **string, - int *integer); - xchat_list * (*xchat_list_get) (xchat_plugin *ph, - const char *name); - void (*xchat_list_free) (xchat_plugin *ph, - xchat_list *xlist); - const char * const * (*xchat_list_fields) (xchat_plugin *ph, - const char *name); - int (*xchat_list_next) (xchat_plugin *ph, - xchat_list *xlist); - const char * (*xchat_list_str) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - int (*xchat_list_int) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - void * (*xchat_plugingui_add) (xchat_plugin *ph, - const char *filename, - const char *name, - const char *desc, - const char *version, - char *reserved); - void (*xchat_plugingui_remove) (xchat_plugin *ph, - void *handle); - int (*xchat_emit_print) (xchat_plugin *ph, - const char *event_name, ...); - int (*xchat_read_fd) (xchat_plugin *ph, - void *src, - char *buf, - int *len); - time_t (*xchat_list_time) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - char *(*xchat_gettext) (xchat_plugin *ph, - const char *msgid); - void (*xchat_send_modes) (xchat_plugin *ph, - const char **targets, - int ntargets, - int modes_per_line, - char sign, - char mode); - char *(*xchat_strip) (xchat_plugin *ph, - const char *str, - int len, - int flags); - void (*xchat_free) (xchat_plugin *ph, - void *ptr); - }; -#endif - - - xchat_hook * - xchat_hook_command (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - const char *help_text, - void *userdata); - - xchat_hook * - xchat_hook_server (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - void *userdata); - - xchat_hook * - xchat_hook_print (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], void *user_data), - void *userdata); - - xchat_hook * - xchat_hook_timer (xchat_plugin *ph, - int timeout, - int (*callback) (void *user_data), - void *userdata); - - xchat_hook * - xchat_hook_fd (xchat_plugin *ph, - int fd, - int flags, - int (*callback) (int fd, int flags, void *user_data), - void *userdata); - - void * - xchat_unhook (xchat_plugin *ph, - xchat_hook *hook); - - void - xchat_print (xchat_plugin *ph, - const char *text); - - void - xchat_printf (xchat_plugin *ph, - const char *format, ...); - - void - xchat_command (xchat_plugin *ph, - const char *command); - - void - xchat_commandf (xchat_plugin *ph, - const char *format, ...); - - int - xchat_nickcmp (xchat_plugin *ph, - const char *s1, - const char *s2); - - int - xchat_set_context (xchat_plugin *ph, - xchat_context *ctx); - - xchat_context * - xchat_find_context (xchat_plugin *ph, - const char *servname, - const char *channel); - - xchat_context * - xchat_get_context (xchat_plugin *ph); - - const char * - xchat_get_info (xchat_plugin *ph, - const char *id); - - int - xchat_get_prefs (xchat_plugin *ph, - const char *name, - const char **string, - int *integer); - - xchat_list * - xchat_list_get (xchat_plugin *ph, - const char *name); - - void - xchat_list_free (xchat_plugin *ph, - xchat_list *xlist); - - const char * const * - xchat_list_fields (xchat_plugin *ph, - const char *name); - - int - xchat_list_next (xchat_plugin *ph, - xchat_list *xlist); - - const char * - xchat_list_str (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - - int - xchat_list_int (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - - time_t - xchat_list_time (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - - void * - xchat_plugingui_add (xchat_plugin *ph, - const char *filename, - const char *name, - const char *desc, - const char *version, - char *reserved); - - void - xchat_plugingui_remove (xchat_plugin *ph, - void *handle); - - int - xchat_emit_print (xchat_plugin *ph, - const char *event_name, ...); - - char * - xchat_gettext (xchat_plugin *ph, - const char *msgid); - - void - xchat_send_modes (xchat_plugin *ph, - const char **targets, - int ntargets, - int modes_per_line, - char sign, - char mode); - - char * - xchat_strip (xchat_plugin *ph, - const char *str, - int len, - int flags); - - void - xchat_free (xchat_plugin *ph, - void *ptr); - -#if !defined(PLUGIN_C) && defined(WIN32) -#ifndef XCHAT_PLUGIN_HANDLE -#define XCHAT_PLUGIN_HANDLE (ph) -#endif -#define xchat_hook_command ((XCHAT_PLUGIN_HANDLE)->xchat_hook_command) -#define xchat_hook_server ((XCHAT_PLUGIN_HANDLE)->xchat_hook_server) -#define xchat_hook_print ((XCHAT_PLUGIN_HANDLE)->xchat_hook_print) -#define xchat_hook_timer ((XCHAT_PLUGIN_HANDLE)->xchat_hook_timer) -#define xchat_hook_fd ((XCHAT_PLUGIN_HANDLE)->xchat_hook_fd) -#define xchat_unhook ((XCHAT_PLUGIN_HANDLE)->xchat_unhook) -#define xchat_print ((XCHAT_PLUGIN_HANDLE)->xchat_print) -#define xchat_printf ((XCHAT_PLUGIN_HANDLE)->xchat_printf) -#define xchat_command ((XCHAT_PLUGIN_HANDLE)->xchat_command) -#define xchat_commandf ((XCHAT_PLUGIN_HANDLE)->xchat_commandf) -#define xchat_nickcmp ((XCHAT_PLUGIN_HANDLE)->xchat_nickcmp) -#define xchat_set_context ((XCHAT_PLUGIN_HANDLE)->xchat_set_context) -#define xchat_find_context ((XCHAT_PLUGIN_HANDLE)->xchat_find_context) -#define xchat_get_context ((XCHAT_PLUGIN_HANDLE)->xchat_get_context) -#define xchat_get_info ((XCHAT_PLUGIN_HANDLE)->xchat_get_info) -#define xchat_get_prefs ((XCHAT_PLUGIN_HANDLE)->xchat_get_prefs) -#define xchat_list_get ((XCHAT_PLUGIN_HANDLE)->xchat_list_get) -#define xchat_list_free ((XCHAT_PLUGIN_HANDLE)->xchat_list_free) -#define xchat_list_fields ((XCHAT_PLUGIN_HANDLE)->xchat_list_fields) -#define xchat_list_str ((XCHAT_PLUGIN_HANDLE)->xchat_list_str) -#define xchat_list_int ((XCHAT_PLUGIN_HANDLE)->xchat_list_int) -#define xchat_list_time ((XCHAT_PLUGIN_HANDLE)->xchat_list_time) -#define xchat_list_next ((XCHAT_PLUGIN_HANDLE)->xchat_list_next) -#define xchat_plugingui_add ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_add) -#define xchat_plugingui_remove ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_remove) -#define xchat_emit_print ((XCHAT_PLUGIN_HANDLE)->xchat_emit_print) -#define xchat_gettext ((XCHAT_PLUGIN_HANDLE)->xchat_gettext) -#define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) -#define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) -#define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) -#endif - -#ifdef __cplusplus -} -#endif - -/****************************************************************** -* Globals -******************************************************************/ -extern xchat_plugin *ph; - -/****************************************************************** -* Prototypes -******************************************************************/ -void wmpaCommands(void); -int wmpaAuto(char *word[], char *word_eol[], void *user_data); -int wmpaCurr(char *word[], char *word_eol[], void *user_data); -int wmpaFind(char *word[], char *word_eol[], void *user_data); -int wmpaList(char *word[], char *word_eol[], void *user_data); -int wmpaNext(char *word[], char *word_eol[], void *user_data); -int wmpaPlay(char *word[], char *word_eol[], void *user_data); -int wmpaPause(char *word[], char *word_eol[], void *user_data); -int wmpaPrev(char *word[], char *word_eol[], void *user_data); -int wmpaSong(char *word[], char *word_eol[], void *user_data); -int wmpaStop(char *word[], char *word_eol[], void *user_data); -int wmpaVolume(char *word[], char *word_eol[], void *user_data); -int wmpaHelp(char *word[], char *word_eol[], void *user_data); -BOOL wmpaRestoreSettings(void); -BOOL wmpaSaveSettings(void); -CString wmpaGetSongTitle(void); -BOOL SaveSetting(LPCTSTR name, DWORD type, CONST BYTE *value, DWORD size); -BOOL GetSetting(LPCTSTR name, DWORD *type, LPBYTE value, DWORD *size); - -#endif /* XCHAT_PLUGIN_H */ - diff --git a/plugins/xchat-plugin.h b/plugins/xchat-plugin.h deleted file mode 100644 index 1b7da8fb..00000000 --- a/plugins/xchat-plugin.h +++ /dev/null @@ -1,381 +0,0 @@ -/* You can distribute this header with your plugins for easy compilation */ -#ifndef XCHAT_PLUGIN_H -#define XCHAT_PLUGIN_H - -#include - -#define XCHAT_IFACE_MAJOR 1 -#define XCHAT_IFACE_MINOR 9 -#define XCHAT_IFACE_MICRO 11 -#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \ - (XCHAT_IFACE_MINOR * 100) + \ - (XCHAT_IFACE_MICRO)) - -#define XCHAT_PRI_HIGHEST 127 -#define XCHAT_PRI_HIGH 64 -#define XCHAT_PRI_NORM 0 -#define XCHAT_PRI_LOW (-64) -#define XCHAT_PRI_LOWEST (-128) - -#define XCHAT_FD_READ 1 -#define XCHAT_FD_WRITE 2 -#define XCHAT_FD_EXCEPTION 4 -#define XCHAT_FD_NOTSOCKET 8 - -#define XCHAT_EAT_NONE 0 /* pass it on through! */ -#define XCHAT_EAT_XCHAT 1 /* don't let xchat see this event */ -#define XCHAT_EAT_PLUGIN 2 /* don't let other plugins see this event */ -#define XCHAT_EAT_ALL (XCHAT_EAT_XCHAT|XCHAT_EAT_PLUGIN) /* don't let anything see this event */ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _xchat_plugin xchat_plugin; -typedef struct _xchat_list xchat_list; -typedef struct _xchat_hook xchat_hook; -#ifndef PLUGIN_C -typedef struct _xchat_context xchat_context; -#endif - -#ifndef PLUGIN_C -struct _xchat_plugin -{ - /* these are only used on win32 */ - xchat_hook *(*xchat_hook_command) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - const char *help_text, - void *userdata); - xchat_hook *(*xchat_hook_server) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_print) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_timer) (xchat_plugin *ph, - int timeout, - int (*callback) (void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_fd) (xchat_plugin *ph, - int fd, - int flags, - int (*callback) (int fd, int flags, void *user_data), - void *userdata); - void *(*xchat_unhook) (xchat_plugin *ph, - xchat_hook *hook); - void (*xchat_print) (xchat_plugin *ph, - const char *text); - void (*xchat_printf) (xchat_plugin *ph, - const char *format, ...); - void (*xchat_command) (xchat_plugin *ph, - const char *command); - void (*xchat_commandf) (xchat_plugin *ph, - const char *format, ...); - int (*xchat_nickcmp) (xchat_plugin *ph, - const char *s1, - const char *s2); - int (*xchat_set_context) (xchat_plugin *ph, - xchat_context *ctx); - xchat_context *(*xchat_find_context) (xchat_plugin *ph, - const char *servname, - const char *channel); - xchat_context *(*xchat_get_context) (xchat_plugin *ph); - const char *(*xchat_get_info) (xchat_plugin *ph, - const char *id); - int (*xchat_get_prefs) (xchat_plugin *ph, - const char *name, - const char **string, - int *integer); - xchat_list * (*xchat_list_get) (xchat_plugin *ph, - const char *name); - void (*xchat_list_free) (xchat_plugin *ph, - xchat_list *xlist); - const char * const * (*xchat_list_fields) (xchat_plugin *ph, - const char *name); - int (*xchat_list_next) (xchat_plugin *ph, - xchat_list *xlist); - const char * (*xchat_list_str) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - int (*xchat_list_int) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - void * (*xchat_plugingui_add) (xchat_plugin *ph, - const char *filename, - const char *name, - const char *desc, - const char *version, - char *reserved); - void (*xchat_plugingui_remove) (xchat_plugin *ph, - void *handle); - int (*xchat_emit_print) (xchat_plugin *ph, - const char *event_name, ...); - int (*xchat_read_fd) (xchat_plugin *ph, - void *src, - char *buf, - int *len); - time_t (*xchat_list_time) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - char *(*xchat_gettext) (xchat_plugin *ph, - const char *msgid); - void (*xchat_send_modes) (xchat_plugin *ph, - const char **targets, - int ntargets, - int modes_per_line, - char sign, - char mode); - char *(*xchat_strip) (xchat_plugin *ph, - const char *str, - int len, - int flags); - void (*xchat_free) (xchat_plugin *ph, - void *ptr); - int (*xchat_pluginpref_set_str) (xchat_plugin *ph, - const char *var, - const char *value); - int (*xchat_pluginpref_get_str) (xchat_plugin *ph, - const char *var, - char *dest); - int (*xchat_pluginpref_set_int) (xchat_plugin *ph, - const char *var, - int value); - int (*xchat_pluginpref_get_int) (xchat_plugin *ph, - const char *var); - int (*xchat_pluginpref_delete) (xchat_plugin *ph, - const char *var); - int (*xchat_pluginpref_list) (xchat_plugin *ph, - char *dest); -}; -#endif - - -xchat_hook * -xchat_hook_command (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - const char *help_text, - void *userdata); - -xchat_hook * -xchat_hook_server (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - void *userdata); - -xchat_hook * -xchat_hook_print (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], void *user_data), - void *userdata); - -xchat_hook * -xchat_hook_timer (xchat_plugin *ph, - int timeout, - int (*callback) (void *user_data), - void *userdata); - -xchat_hook * -xchat_hook_fd (xchat_plugin *ph, - int fd, - int flags, - int (*callback) (int fd, int flags, void *user_data), - void *userdata); - -void * -xchat_unhook (xchat_plugin *ph, - xchat_hook *hook); - -void -xchat_print (xchat_plugin *ph, - const char *text); - -void -xchat_printf (xchat_plugin *ph, - const char *format, ...); - -void -xchat_command (xchat_plugin *ph, - const char *command); - -void -xchat_commandf (xchat_plugin *ph, - const char *format, ...); - -int -xchat_nickcmp (xchat_plugin *ph, - const char *s1, - const char *s2); - -int -xchat_set_context (xchat_plugin *ph, - xchat_context *ctx); - -xchat_context * -xchat_find_context (xchat_plugin *ph, - const char *servname, - const char *channel); - -xchat_context * -xchat_get_context (xchat_plugin *ph); - -const char * -xchat_get_info (xchat_plugin *ph, - const char *id); - -int -xchat_get_prefs (xchat_plugin *ph, - const char *name, - const char **string, - int *integer); - -xchat_list * -xchat_list_get (xchat_plugin *ph, - const char *name); - -void -xchat_list_free (xchat_plugin *ph, - xchat_list *xlist); - -const char * const * -xchat_list_fields (xchat_plugin *ph, - const char *name); - -int -xchat_list_next (xchat_plugin *ph, - xchat_list *xlist); - -const char * -xchat_list_str (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - -int -xchat_list_int (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - -time_t -xchat_list_time (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - -void * -xchat_plugingui_add (xchat_plugin *ph, - const char *filename, - const char *name, - const char *desc, - const char *version, - char *reserved); - -void -xchat_plugingui_remove (xchat_plugin *ph, - void *handle); - -int -xchat_emit_print (xchat_plugin *ph, - const char *event_name, ...); - -char * -xchat_gettext (xchat_plugin *ph, - const char *msgid); - -void -xchat_send_modes (xchat_plugin *ph, - const char **targets, - int ntargets, - int modes_per_line, - char sign, - char mode); - -char * -xchat_strip (xchat_plugin *ph, - const char *str, - int len, - int flags); - -void -xchat_free (xchat_plugin *ph, - void *ptr); - -int -xchat_pluginpref_set_str (xchat_plugin *ph, - const char *var, - const char *value); - -int -xchat_pluginpref_get_str (xchat_plugin *ph, - const char *var, - char *dest); - -int -xchat_pluginpref_set_int (xchat_plugin *ph, - const char *var, - int value); -int -xchat_pluginpref_get_int (xchat_plugin *ph, - const char *var); - -int -xchat_pluginpref_delete (xchat_plugin *ph, - const char *var); - -int -xchat_pluginpref_list (xchat_plugin *ph, - char *dest); - -#if !defined(PLUGIN_C) && defined(WIN32) -#ifndef XCHAT_PLUGIN_HANDLE -#define XCHAT_PLUGIN_HANDLE (ph) -#endif -#define xchat_hook_command ((XCHAT_PLUGIN_HANDLE)->xchat_hook_command) -#define xchat_hook_server ((XCHAT_PLUGIN_HANDLE)->xchat_hook_server) -#define xchat_hook_print ((XCHAT_PLUGIN_HANDLE)->xchat_hook_print) -#define xchat_hook_timer ((XCHAT_PLUGIN_HANDLE)->xchat_hook_timer) -#define xchat_hook_fd ((XCHAT_PLUGIN_HANDLE)->xchat_hook_fd) -#define xchat_unhook ((XCHAT_PLUGIN_HANDLE)->xchat_unhook) -#define xchat_print ((XCHAT_PLUGIN_HANDLE)->xchat_print) -#define xchat_printf ((XCHAT_PLUGIN_HANDLE)->xchat_printf) -#define xchat_command ((XCHAT_PLUGIN_HANDLE)->xchat_command) -#define xchat_commandf ((XCHAT_PLUGIN_HANDLE)->xchat_commandf) -#define xchat_nickcmp ((XCHAT_PLUGIN_HANDLE)->xchat_nickcmp) -#define xchat_set_context ((XCHAT_PLUGIN_HANDLE)->xchat_set_context) -#define xchat_find_context ((XCHAT_PLUGIN_HANDLE)->xchat_find_context) -#define xchat_get_context ((XCHAT_PLUGIN_HANDLE)->xchat_get_context) -#define xchat_get_info ((XCHAT_PLUGIN_HANDLE)->xchat_get_info) -#define xchat_get_prefs ((XCHAT_PLUGIN_HANDLE)->xchat_get_prefs) -#define xchat_list_get ((XCHAT_PLUGIN_HANDLE)->xchat_list_get) -#define xchat_list_free ((XCHAT_PLUGIN_HANDLE)->xchat_list_free) -#define xchat_list_fields ((XCHAT_PLUGIN_HANDLE)->xchat_list_fields) -#define xchat_list_str ((XCHAT_PLUGIN_HANDLE)->xchat_list_str) -#define xchat_list_int ((XCHAT_PLUGIN_HANDLE)->xchat_list_int) -#define xchat_list_time ((XCHAT_PLUGIN_HANDLE)->xchat_list_time) -#define xchat_list_next ((XCHAT_PLUGIN_HANDLE)->xchat_list_next) -#define xchat_plugingui_add ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_add) -#define xchat_plugingui_remove ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_remove) -#define xchat_emit_print ((XCHAT_PLUGIN_HANDLE)->xchat_emit_print) -#define xchat_gettext ((XCHAT_PLUGIN_HANDLE)->xchat_gettext) -#define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) -#define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) -#define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) -#define xchat_pluginpref_set_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_str) -#define xchat_pluginpref_get_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_str) -#define xchat_pluginpref_set_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_int) -#define xchat_pluginpref_get_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_int) -#define xchat_pluginpref_delete ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_delete) -#define xchat_pluginpref_list ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_list) -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/plugins/xdcc/xdcc.c b/plugins/xdcc/xdcc.c index 060dbbe3..9233f12b 100644 --- a/plugins/xdcc/xdcc.c +++ b/plugins/xdcc/xdcc.c @@ -9,8 +9,8 @@ #include #endif -#include "xchat-plugin.h" -#include "../../src/common/xchat.h" +#include "hexchat-plugin.h" +#include "../../src/common/hexchat.h" static xchat_plugin *ph; /* plugin handle */ diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 830d73eb..22534bdd 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -10,6 +10,9 @@ EXTRA_DIST = \ ctcp.h \ dcc.h \ fe.h \ + hexchat.h \ + hexchatc.h \ + hexchat-plugin.h \ history.h \ identd.c \ ignore.h \ @@ -36,10 +39,7 @@ EXTRA_DIST = \ tree.h \ url.h \ userlist.h \ - util.h \ - xchat.h \ - xchatc.h \ - xchat-plugin.h + util.h if USE_OPENSSL ssl_c = ssl.c @@ -52,10 +52,10 @@ libhexchatcommon_a_LIBADD = \ endif SUBDIRS = $(dbusdir) . -libhexchatcommon_a_SOURCES = cfgfiles.c chanopt.c ctcp.c dcc.c history.c ignore.c \ - inbound.c modes.c msproxy.c network.c notify.c outbound.c \ - plugin.c plugin-timer.c proto-irc.c server.c servlist.c $(ssl_c) \ - strlutil.c text.c tree.c url.c userlist.c util.c xchat.c +libhexchatcommon_a_SOURCES = cfgfiles.c chanopt.c ctcp.c dcc.c hexchat.c \ + history.c ignore.c inbound.c modes.c msproxy.c network.c notify.c \ + outbound.c plugin.c plugin-timer.c proto-irc.c server.c servlist.c \ + $(ssl_c) strlutil.c text.c tree.c url.c userlist.c util.c libhexchatcommon_a_CFLAGS = $(LIBPROXY_CFLAGS) textevents: make-te diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c index 2312dada..9f3bc920 100644 --- a/src/common/cfgfiles.c +++ b/src/common/cfgfiles.c @@ -23,12 +23,12 @@ #include #include -#include "xchat.h" +#include "hexchat.h" #include "cfgfiles.h" #include "util.h" #include "fe.h" #include "text.h" -#include "xchatc.h" +#include "hexchatc.h" #ifdef WIN32 #include diff --git a/src/common/cfgfiles.h b/src/common/cfgfiles.h index 2cb4a4e2..9371f572 100644 --- a/src/common/cfgfiles.h +++ b/src/common/cfgfiles.h @@ -3,7 +3,7 @@ #ifndef XCHAT_CFGFILES_H #define XCHAT_CFGFILES_H -#include "xchat.h" +#include "hexchat.h" extern char *xdir_fs; extern char *xdir_utf; diff --git a/src/common/chanopt.c b/src/common/chanopt.c index 8e8b0312..d6d47fb2 100644 --- a/src/common/chanopt.c +++ b/src/common/chanopt.c @@ -14,13 +14,13 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include "cfgfiles.h" #include "server.h" #include "text.h" #include "util.h" -#include "xchatc.h" +#include "hexchatc.h" static GSList *chanopt_list = NULL; diff --git a/src/common/common-xp.vcxproj b/src/common/common-xp.vcxproj index 6eec3b12..736eacb1 100644 --- a/src/common/common-xp.vcxproj +++ b/src/common/common-xp.vcxproj @@ -43,9 +43,9 @@ - - - + + + @@ -74,7 +74,7 @@ - + {87554B59-006C-4D94-9714-897B27067BA3} diff --git a/src/common/common-xp.vcxproj.filters b/src/common/common-xp.vcxproj.filters index 4940a6fd..3707caa0 100644 --- a/src/common/common-xp.vcxproj.filters +++ b/src/common/common-xp.vcxproj.filters @@ -98,13 +98,13 @@ Header Files - + Header Files - + Header Files - + Header Files @@ -193,7 +193,7 @@ Source Files - + Source Files diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj index 55116995..9bb79ac5 100644 --- a/src/common/common.vcxproj +++ b/src/common/common.vcxproj @@ -43,9 +43,9 @@ - - - + + + @@ -74,7 +74,7 @@ - + {87554B59-006C-4D94-9714-897B27067BA3} diff --git a/src/common/common.vcxproj.filters b/src/common/common.vcxproj.filters index 4940a6fd..3707caa0 100644 --- a/src/common/common.vcxproj.filters +++ b/src/common/common.vcxproj.filters @@ -98,13 +98,13 @@ Header Files - + Header Files - + Header Files - + Header Files @@ -193,7 +193,7 @@ Source Files - + Source Files diff --git a/src/common/ctcp.c b/src/common/ctcp.c index c0d1ce49..f950a901 100644 --- a/src/common/ctcp.c +++ b/src/common/ctcp.c @@ -24,7 +24,7 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include "cfgfiles.h" #include "util.h" #include "modes.h" @@ -35,7 +35,7 @@ #include "text.h" #include "ctcp.h" #include "server.h" -#include "xchatc.h" +#include "hexchatc.h" static void diff --git a/src/common/dcc.c b/src/common/dcc.c index 4aa581a7..d9b1b855 100644 --- a/src/common/dcc.c +++ b/src/common/dcc.c @@ -48,7 +48,7 @@ #include #include -#include "xchat.h" +#include "hexchat.h" #include "util.h" #include "fe.h" #include "outbound.h" @@ -58,7 +58,7 @@ #include "server.h" #include "text.h" #include "url.h" -#include "xchatc.h" +#include "hexchatc.h" #ifdef USE_DCC64 #define BIG_STR_TO_INT(x) strtoull(x,NULL,10) diff --git a/src/common/hexchat-plugin.h b/src/common/hexchat-plugin.h new file mode 100644 index 00000000..43621f78 --- /dev/null +++ b/src/common/hexchat-plugin.h @@ -0,0 +1,381 @@ +/* You can distribute this header with your plugins for easy compilation */ +#ifndef HEXCHAT_PLUGIN_H +#define HEXCHAT_PLUGIN_H + +#include + +#define XCHAT_IFACE_MAJOR 1 +#define XCHAT_IFACE_MINOR 9 +#define XCHAT_IFACE_MICRO 11 +#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \ + (XCHAT_IFACE_MINOR * 100) + \ + (XCHAT_IFACE_MICRO)) + +#define XCHAT_PRI_HIGHEST 127 +#define XCHAT_PRI_HIGH 64 +#define XCHAT_PRI_NORM 0 +#define XCHAT_PRI_LOW (-64) +#define XCHAT_PRI_LOWEST (-128) + +#define XCHAT_FD_READ 1 +#define XCHAT_FD_WRITE 2 +#define XCHAT_FD_EXCEPTION 4 +#define XCHAT_FD_NOTSOCKET 8 + +#define XCHAT_EAT_NONE 0 /* pass it on through! */ +#define XCHAT_EAT_XCHAT 1 /* don't let xchat see this event */ +#define XCHAT_EAT_PLUGIN 2 /* don't let other plugins see this event */ +#define XCHAT_EAT_ALL (XCHAT_EAT_XCHAT|XCHAT_EAT_PLUGIN) /* don't let anything see this event */ + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _xchat_plugin xchat_plugin; +typedef struct _xchat_list xchat_list; +typedef struct _xchat_hook xchat_hook; +#ifndef PLUGIN_C +typedef struct _xchat_context xchat_context; +#endif + +#ifndef PLUGIN_C +struct _xchat_plugin +{ + /* these are only used on win32 */ + xchat_hook *(*xchat_hook_command) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + const char *help_text, + void *userdata); + xchat_hook *(*xchat_hook_server) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_print) (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_timer) (xchat_plugin *ph, + int timeout, + int (*callback) (void *user_data), + void *userdata); + xchat_hook *(*xchat_hook_fd) (xchat_plugin *ph, + int fd, + int flags, + int (*callback) (int fd, int flags, void *user_data), + void *userdata); + void *(*xchat_unhook) (xchat_plugin *ph, + xchat_hook *hook); + void (*xchat_print) (xchat_plugin *ph, + const char *text); + void (*xchat_printf) (xchat_plugin *ph, + const char *format, ...); + void (*xchat_command) (xchat_plugin *ph, + const char *command); + void (*xchat_commandf) (xchat_plugin *ph, + const char *format, ...); + int (*xchat_nickcmp) (xchat_plugin *ph, + const char *s1, + const char *s2); + int (*xchat_set_context) (xchat_plugin *ph, + xchat_context *ctx); + xchat_context *(*xchat_find_context) (xchat_plugin *ph, + const char *servname, + const char *channel); + xchat_context *(*xchat_get_context) (xchat_plugin *ph); + const char *(*xchat_get_info) (xchat_plugin *ph, + const char *id); + int (*xchat_get_prefs) (xchat_plugin *ph, + const char *name, + const char **string, + int *integer); + xchat_list * (*xchat_list_get) (xchat_plugin *ph, + const char *name); + void (*xchat_list_free) (xchat_plugin *ph, + xchat_list *xlist); + const char * const * (*xchat_list_fields) (xchat_plugin *ph, + const char *name); + int (*xchat_list_next) (xchat_plugin *ph, + xchat_list *xlist); + const char * (*xchat_list_str) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + int (*xchat_list_int) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + void * (*xchat_plugingui_add) (xchat_plugin *ph, + const char *filename, + const char *name, + const char *desc, + const char *version, + char *reserved); + void (*xchat_plugingui_remove) (xchat_plugin *ph, + void *handle); + int (*xchat_emit_print) (xchat_plugin *ph, + const char *event_name, ...); + int (*xchat_read_fd) (xchat_plugin *ph, + void *src, + char *buf, + int *len); + time_t (*xchat_list_time) (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + char *(*xchat_gettext) (xchat_plugin *ph, + const char *msgid); + void (*xchat_send_modes) (xchat_plugin *ph, + const char **targets, + int ntargets, + int modes_per_line, + char sign, + char mode); + char *(*xchat_strip) (xchat_plugin *ph, + const char *str, + int len, + int flags); + void (*xchat_free) (xchat_plugin *ph, + void *ptr); + int (*xchat_pluginpref_set_str) (xchat_plugin *ph, + const char *var, + const char *value); + int (*xchat_pluginpref_get_str) (xchat_plugin *ph, + const char *var, + char *dest); + int (*xchat_pluginpref_set_int) (xchat_plugin *ph, + const char *var, + int value); + int (*xchat_pluginpref_get_int) (xchat_plugin *ph, + const char *var); + int (*xchat_pluginpref_delete) (xchat_plugin *ph, + const char *var); + int (*xchat_pluginpref_list) (xchat_plugin *ph, + char *dest); +}; +#endif + + +xchat_hook * +xchat_hook_command (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + const char *help_text, + void *userdata); + +xchat_hook * +xchat_hook_server (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], char *word_eol[], void *user_data), + void *userdata); + +xchat_hook * +xchat_hook_print (xchat_plugin *ph, + const char *name, + int pri, + int (*callback) (char *word[], void *user_data), + void *userdata); + +xchat_hook * +xchat_hook_timer (xchat_plugin *ph, + int timeout, + int (*callback) (void *user_data), + void *userdata); + +xchat_hook * +xchat_hook_fd (xchat_plugin *ph, + int fd, + int flags, + int (*callback) (int fd, int flags, void *user_data), + void *userdata); + +void * +xchat_unhook (xchat_plugin *ph, + xchat_hook *hook); + +void +xchat_print (xchat_plugin *ph, + const char *text); + +void +xchat_printf (xchat_plugin *ph, + const char *format, ...); + +void +xchat_command (xchat_plugin *ph, + const char *command); + +void +xchat_commandf (xchat_plugin *ph, + const char *format, ...); + +int +xchat_nickcmp (xchat_plugin *ph, + const char *s1, + const char *s2); + +int +xchat_set_context (xchat_plugin *ph, + xchat_context *ctx); + +xchat_context * +xchat_find_context (xchat_plugin *ph, + const char *servname, + const char *channel); + +xchat_context * +xchat_get_context (xchat_plugin *ph); + +const char * +xchat_get_info (xchat_plugin *ph, + const char *id); + +int +xchat_get_prefs (xchat_plugin *ph, + const char *name, + const char **string, + int *integer); + +xchat_list * +xchat_list_get (xchat_plugin *ph, + const char *name); + +void +xchat_list_free (xchat_plugin *ph, + xchat_list *xlist); + +const char * const * +xchat_list_fields (xchat_plugin *ph, + const char *name); + +int +xchat_list_next (xchat_plugin *ph, + xchat_list *xlist); + +const char * +xchat_list_str (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + +int +xchat_list_int (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + +time_t +xchat_list_time (xchat_plugin *ph, + xchat_list *xlist, + const char *name); + +void * +xchat_plugingui_add (xchat_plugin *ph, + const char *filename, + const char *name, + const char *desc, + const char *version, + char *reserved); + +void +xchat_plugingui_remove (xchat_plugin *ph, + void *handle); + +int +xchat_emit_print (xchat_plugin *ph, + const char *event_name, ...); + +char * +xchat_gettext (xchat_plugin *ph, + const char *msgid); + +void +xchat_send_modes (xchat_plugin *ph, + const char **targets, + int ntargets, + int modes_per_line, + char sign, + char mode); + +char * +xchat_strip (xchat_plugin *ph, + const char *str, + int len, + int flags); + +void +xchat_free (xchat_plugin *ph, + void *ptr); + +int +xchat_pluginpref_set_str (xchat_plugin *ph, + const char *var, + const char *value); + +int +xchat_pluginpref_get_str (xchat_plugin *ph, + const char *var, + char *dest); + +int +xchat_pluginpref_set_int (xchat_plugin *ph, + const char *var, + int value); +int +xchat_pluginpref_get_int (xchat_plugin *ph, + const char *var); + +int +xchat_pluginpref_delete (xchat_plugin *ph, + const char *var); + +int +xchat_pluginpref_list (xchat_plugin *ph, + char *dest); + +#if !defined(PLUGIN_C) && defined(WIN32) +#ifndef XCHAT_PLUGIN_HANDLE +#define XCHAT_PLUGIN_HANDLE (ph) +#endif +#define xchat_hook_command ((XCHAT_PLUGIN_HANDLE)->xchat_hook_command) +#define xchat_hook_server ((XCHAT_PLUGIN_HANDLE)->xchat_hook_server) +#define xchat_hook_print ((XCHAT_PLUGIN_HANDLE)->xchat_hook_print) +#define xchat_hook_timer ((XCHAT_PLUGIN_HANDLE)->xchat_hook_timer) +#define xchat_hook_fd ((XCHAT_PLUGIN_HANDLE)->xchat_hook_fd) +#define xchat_unhook ((XCHAT_PLUGIN_HANDLE)->xchat_unhook) +#define xchat_print ((XCHAT_PLUGIN_HANDLE)->xchat_print) +#define xchat_printf ((XCHAT_PLUGIN_HANDLE)->xchat_printf) +#define xchat_command ((XCHAT_PLUGIN_HANDLE)->xchat_command) +#define xchat_commandf ((XCHAT_PLUGIN_HANDLE)->xchat_commandf) +#define xchat_nickcmp ((XCHAT_PLUGIN_HANDLE)->xchat_nickcmp) +#define xchat_set_context ((XCHAT_PLUGIN_HANDLE)->xchat_set_context) +#define xchat_find_context ((XCHAT_PLUGIN_HANDLE)->xchat_find_context) +#define xchat_get_context ((XCHAT_PLUGIN_HANDLE)->xchat_get_context) +#define xchat_get_info ((XCHAT_PLUGIN_HANDLE)->xchat_get_info) +#define xchat_get_prefs ((XCHAT_PLUGIN_HANDLE)->xchat_get_prefs) +#define xchat_list_get ((XCHAT_PLUGIN_HANDLE)->xchat_list_get) +#define xchat_list_free ((XCHAT_PLUGIN_HANDLE)->xchat_list_free) +#define xchat_list_fields ((XCHAT_PLUGIN_HANDLE)->xchat_list_fields) +#define xchat_list_str ((XCHAT_PLUGIN_HANDLE)->xchat_list_str) +#define xchat_list_int ((XCHAT_PLUGIN_HANDLE)->xchat_list_int) +#define xchat_list_time ((XCHAT_PLUGIN_HANDLE)->xchat_list_time) +#define xchat_list_next ((XCHAT_PLUGIN_HANDLE)->xchat_list_next) +#define xchat_plugingui_add ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_add) +#define xchat_plugingui_remove ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_remove) +#define xchat_emit_print ((XCHAT_PLUGIN_HANDLE)->xchat_emit_print) +#define xchat_gettext ((XCHAT_PLUGIN_HANDLE)->xchat_gettext) +#define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) +#define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) +#define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) +#define xchat_pluginpref_set_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_str) +#define xchat_pluginpref_get_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_str) +#define xchat_pluginpref_set_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_int) +#define xchat_pluginpref_get_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_int) +#define xchat_pluginpref_delete ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_delete) +#define xchat_pluginpref_list ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_list) +#endif + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/common/hexchat.c b/src/common/hexchat.c new file mode 100644 index 00000000..66612a30 --- /dev/null +++ b/src/common/hexchat.c @@ -0,0 +1,1207 @@ +/* X-Chat + * Copyright (C) 1998 Peter Zelezny. + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include +#include +#include +#include +#include +#include + +#define WANTSOCKET +#include "inet.h" + +#ifdef WIN32 +#include +#else +#include +#include +#include +#endif + +#include "hexchat.h" +#include "fe.h" +#include "util.h" +#include "cfgfiles.h" +#include "chanopt.h" +#include "ignore.h" +#include "hexchat-plugin.h" +#include "plugin.h" +#include "plugin-timer.h" +#include "notify.h" +#include "server.h" +#include "servlist.h" +#include "outbound.h" +#include "text.h" +#include "url.h" +#include "hexchatc.h" + +#ifdef USE_OPENSSL +#include /* SSL_() */ +#include "ssl.h" +#endif + +#ifdef USE_MSPROXY +#include "msproxy.h" +#endif + +#ifdef USE_LIBPROXY +#include +#endif + +GSList *popup_list = 0; +GSList *button_list = 0; +GSList *dlgbutton_list = 0; +GSList *command_list = 0; +GSList *ctcp_list = 0; +GSList *replace_list = 0; +GSList *sess_list = 0; +GSList *dcc_list = 0; +GSList *ignore_list = 0; +GSList *usermenu_list = 0; +GSList *urlhandler_list = 0; +GSList *tabmenu_list = 0; + +static int in_xchat_exit = FALSE; +int xchat_is_quitting = FALSE; +/* command-line args */ +int arg_dont_autoconnect = FALSE; +int arg_skip_plugins = FALSE; +char *arg_url = NULL; +char *arg_command = NULL; +gint arg_existing = FALSE; + +#ifdef USE_DBUS +#include "dbus/dbus-client.h" +#include "dbus/dbus-plugin.h" +#endif /* USE_DBUS */ + +struct session *current_tab; +struct session *current_sess = 0; +struct hexchatprefs prefs; + +#ifdef USE_OPENSSL +SSL_CTX *ctx = NULL; +#endif + +#ifdef USE_LIBPROXY +pxProxyFactory *libproxy_factory; +#endif + +int +is_session (session * sess) +{ + return g_slist_find (sess_list, sess) ? 1 : 0; +} + +session * +find_dialog (server *serv, char *nick) +{ + GSList *list = sess_list; + session *sess; + + while (list) + { + sess = list->data; + if (sess->server == serv && sess->type == SESS_DIALOG) + { + if (!serv->p_cmp (nick, sess->channel)) + return (sess); + } + list = list->next; + } + return 0; +} + +session * +find_channel (server *serv, char *chan) +{ + session *sess; + GSList *list = sess_list; + while (list) + { + sess = list->data; + if ((!serv || serv == sess->server) && sess->type != SESS_DIALOG) + { + if (!serv->p_cmp (chan, sess->channel)) + return sess; + } + list = list->next; + } + return 0; +} + +static void +lagcheck_update (void) +{ + server *serv; + GSList *list = serv_list; + + if (!prefs.hex_gui_lagometer) + return; + + while (list) + { + serv = list->data; + if (serv->lag_sent) + fe_set_lag (serv, -1); + + list = list->next; + } +} + +void +lag_check (void) +{ + server *serv; + GSList *list = serv_list; + unsigned long tim; + char tbuf[128]; + time_t now = time (0); + int lag; + + tim = make_ping_time (); + + while (list) + { + serv = list->data; + if (serv->connected && serv->end_of_motd) + { + lag = now - serv->ping_recv; + if (prefs.hex_net_ping_timeout && lag > prefs.hex_net_ping_timeout && lag > 0) + { + sprintf (tbuf, "%d", lag); + EMIT_SIGNAL (XP_TE_PINGTIMEOUT, serv->server_session, tbuf, NULL, + NULL, NULL, 0); + if (prefs.hex_net_auto_reconnect) + serv->auto_reconnect (serv, FALSE, -1); + } else + { + snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim); + serv->p_ping (serv, "", tbuf); + serv->lag_sent = tim; + fe_set_lag (serv, -1); + } + } + list = list->next; + } +} + +static int +away_check (void) +{ + session *sess; + GSList *list; + int full, sent, loop = 0; + + if (!prefs.hex_away_track || prefs.hex_away_size_max < 1) + return 1; + +doover: + /* request an update of AWAY status of 1 channel every 30 seconds */ + full = TRUE; + sent = 0; /* number of WHOs (users) requested */ + list = sess_list; + while (list) + { + sess = list->data; + + if (sess->server->connected && + sess->type == SESS_CHANNEL && + sess->channel[0] && + sess->total <= prefs.hex_away_size_max) + { + if (!sess->done_away_check) + { + full = FALSE; + + /* if we're under 31 WHOs, send another channels worth */ + if (sent < 31 && !sess->doing_who) + { + sess->done_away_check = TRUE; + sess->doing_who = TRUE; + /* this'll send a WHO #channel */ + sess->server->p_away_status (sess->server, sess->channel); + sent += sess->total; + } + } + } + + list = list->next; + } + + /* done them all, reset done_away_check to FALSE and start over */ + if (full) + { + list = sess_list; + while (list) + { + sess = list->data; + sess->done_away_check = FALSE; + list = list->next; + } + loop++; + if (loop < 2) + goto doover; + } + + return 1; +} + +static int +xchat_misc_checks (void) /* this gets called every 1/2 second */ +{ + static int count = 0; +#ifdef USE_MSPROXY + static int count2 = 0; +#endif + + count++; + + lagcheck_update (); /* every 500ms */ + + if (count % 2) + dcc_check_timeouts (); /* every 1 second */ + + if (count >= 60) /* every 30 seconds */ + { + if (prefs.hex_gui_lagometer) + lag_check (); + count = 0; + } + +#ifdef USE_MSPROXY + count2++; + if (count2 >= 720) /* 720 every 6 minutes */ + { + msproxy_keepalive (); + count2 = 0; + } +#endif + + return 1; +} + +/* executed when the first irc window opens */ + +static void +irc_init (session *sess) +{ + static int done_init = FALSE; + char buf[512]; + + if (done_init) + return; + + done_init = TRUE; + + plugin_add (sess, NULL, NULL, timer_plugin_init, NULL, NULL, FALSE); + +#ifdef USE_PLUGIN + if (!arg_skip_plugins) + plugin_auto_load (sess); /* autoload ~/.xchat *.so */ +#endif + +#ifdef USE_DBUS + plugin_add (sess, NULL, NULL, dbus_plugin_init, NULL, NULL, FALSE); +#endif + + if (prefs.hex_notify_timeout) + notify_tag = fe_timeout_add (prefs.hex_notify_timeout * 1000, + notify_checklist, 0); + + fe_timeout_add (prefs.hex_away_timeout * 1000, away_check, 0); + fe_timeout_add (500, xchat_misc_checks, 0); + + if (arg_url != NULL) + { + snprintf (buf, sizeof (buf), "server %s", arg_url); + handle_command (sess, buf, FALSE); + g_free (arg_url); /* from GOption */ + } + + if (arg_command != NULL) + { + g_free (arg_command); + } + + /* load -e ~/.xchat2/startup.txt */ + snprintf (buf, sizeof (buf), "%s/%s", get_xdir_fs (), "startup.txt"); + load_perform_file (sess, buf); +} + +static session * +session_new (server *serv, char *from, int type, int focus) +{ + session *sess; + + sess = malloc (sizeof (struct session)); + if (sess == NULL) + { + return NULL; + } + memset (sess, 0, sizeof (struct session)); + + sess->server = serv; + sess->logfd = -1; + sess->scrollfd = -1; + sess->type = type; + + sess->alert_beep = SET_DEFAULT; + sess->alert_taskbar = SET_DEFAULT; + sess->alert_tray = SET_DEFAULT; + + sess->text_hidejoinpart = SET_DEFAULT; + sess->text_logging = SET_DEFAULT; + sess->text_scrollback = SET_DEFAULT; + + if (from != NULL) + safe_strcpy (sess->channel, from, CHANLEN); + + sess_list = g_slist_prepend (sess_list, sess); + + fe_new_window (sess, focus); + + return sess; +} + +session * +new_ircwindow (server *serv, char *name, int type, int focus) +{ + session *sess; + + switch (type) + { + case SESS_SERVER: + serv = server_new (); + if (prefs.hex_gui_tab_server) + sess = session_new (serv, name, SESS_SERVER, focus); + else + sess = session_new (serv, name, SESS_CHANNEL, focus); + serv->server_session = sess; + serv->front_session = sess; + break; + case SESS_DIALOG: + sess = session_new (serv, name, type, focus); + log_open_or_close (sess); + break; + default: +/* case SESS_CHANNEL: + case SESS_NOTICES: + case SESS_SNOTICES:*/ + sess = session_new (serv, name, type, focus); + break; + } + + irc_init (sess); + scrollback_load (sess); + chanopt_load (sess); + plugin_emit_dummy_print (sess, "Open Context"); + + return sess; +} + +static void +exec_notify_kill (session * sess) +{ +#ifndef WIN32 + struct nbexec *re; + if (sess->running_exec != NULL) + { + re = sess->running_exec; + sess->running_exec = NULL; + kill (re->childpid, SIGKILL); + waitpid (re->childpid, NULL, WNOHANG); + fe_input_remove (re->iotag); + close (re->myfd); + if (re->linebuf) + free(re->linebuf); + free (re); + } +#endif +} + +static void +send_quit_or_part (session * killsess) +{ + int willquit = TRUE; + GSList *list; + session *sess; + server *killserv = killsess->server; + + /* check if this is the last session using this server */ + list = sess_list; + while (list) + { + sess = (session *) list->data; + if (sess->server == killserv && sess != killsess) + { + willquit = FALSE; + list = 0; + } else + list = list->next; + } + + if (xchat_is_quitting) + willquit = TRUE; + + if (killserv->connected) + { + if (willquit) + { + if (!killserv->sent_quit) + { + killserv->flush_queue (killserv); + server_sendquit (killsess); + killserv->sent_quit = TRUE; + } + } else + { + if (killsess->type == SESS_CHANNEL && killsess->channel[0] && + !killserv->sent_quit) + { + server_sendpart (killserv, killsess->channel, 0); + } + } + } +} + +void +session_free (session *killsess) +{ + server *killserv = killsess->server; + session *sess; + GSList *list; + + plugin_emit_dummy_print (killsess, "Close Context"); + + if (current_tab == killsess) + current_tab = NULL; + + if (killserv->server_session == killsess) + killserv->server_session = NULL; + + if (killserv->front_session == killsess) + { + /* front_session is closed, find a valid replacement */ + killserv->front_session = NULL; + list = sess_list; + while (list) + { + sess = (session *) list->data; + if (sess != killsess && sess->server == killserv) + { + killserv->front_session = sess; + if (!killserv->server_session) + killserv->server_session = sess; + break; + } + list = list->next; + } + } + + if (!killserv->server_session) + killserv->server_session = killserv->front_session; + + sess_list = g_slist_remove (sess_list, killsess); + + if (killsess->type == SESS_CHANNEL) + userlist_free (killsess); + + exec_notify_kill (killsess); + + log_close (killsess); + scrollback_close (killsess); + chanopt_save (killsess); + + send_quit_or_part (killsess); + + history_free (&killsess->history); + if (killsess->topic) + free (killsess->topic); + if (killsess->current_modes) + free (killsess->current_modes); + + fe_session_callback (killsess); + + if (current_sess == killsess) + { + current_sess = NULL; + if (sess_list) + current_sess = sess_list->data; + } + + free (killsess); + + if (!sess_list && !in_xchat_exit) + xchat_exit (); /* sess_list is empty, quit! */ + + list = sess_list; + while (list) + { + sess = (session *) list->data; + if (sess->server == killserv) + return; /* this server is still being used! */ + list = list->next; + } + + server_free (killserv); +} + +static void +free_sessions (void) +{ + GSList *list = sess_list; + + while (list) + { + fe_close_window (list->data); + list = sess_list; + } +} + + +static char defaultconf_ctcp[] = + "NAME TIME\n" "CMD nctcp %s TIME %t\n\n"\ + "NAME PING\n" "CMD nctcp %s PING %d\n\n"; + +static char defaultconf_replace[] = + "NAME teh\n" "CMD the\n\n"; +/* "NAME r\n" "CMD are\n\n"\ + "NAME u\n" "CMD you\n\n"*/ + +static char defaultconf_commands[] = + "NAME ACTION\n" "CMD me &2\n\n"\ + "NAME AME\n" "CMD allchan me &2\n\n"\ + "NAME ANICK\n" "CMD allserv nick &2\n\n"\ + "NAME AMSG\n" "CMD allchan say &2\n\n"\ + "NAME BANLIST\n" "CMD quote MODE %c +b\n\n"\ + "NAME CHAT\n" "CMD dcc chat %2\n\n"\ + "NAME DIALOG\n" "CMD query %2\n\n"\ + "NAME DMSG\n" "CMD msg =%2 &3\n\n"\ + "NAME EXIT\n" "CMD quit\n\n"\ + "NAME GREP\n" "CMD lastlog -r -- &2\n\n"\ + "NAME IGNALL\n" "CMD ignore %2!*@* ALL\n\n"\ + "NAME J\n" "CMD join &2\n\n"\ + "NAME KILL\n" "CMD quote KILL %2 :&3\n\n"\ + "NAME LEAVE\n" "CMD part &2\n\n"\ + "NAME M\n" "CMD msg &2\n\n"\ + "NAME ONOTICE\n" "CMD notice @%c &2\n\n"\ + "NAME RAW\n" "CMD quote &2\n\n"\ + "NAME SERVHELP\n" "CMD quote HELP\n\n"\ + "NAME SPING\n" "CMD ping\n\n"\ + "NAME SQUERY\n" "CMD quote SQUERY %2 :&3\n\n"\ + "NAME SSLSERVER\n" "CMD server -ssl &2\n\n"\ + "NAME SV\n" "CMD echo xchat %v %m\n\n"\ + "NAME UMODE\n" "CMD mode %n &2\n\n"\ + "NAME UPTIME\n" "CMD quote STATS u\n\n"\ + "NAME VER\n" "CMD ctcp %2 VERSION\n\n"\ + "NAME VERSION\n" "CMD ctcp %2 VERSION\n\n"\ + "NAME WALLOPS\n" "CMD quote WALLOPS :&2\n\n"\ + "NAME WII\n" "CMD quote WHOIS %2 %2\n\n"; + +static char defaultconf_urlhandlers[] = + "NAME Open Link in Opera\n" "CMD !opera -remote 'openURL(%s)'\n\n"; + +#ifdef USE_SIGACTION +/* Close and open log files on SIGUSR1. Usefull for log rotating */ + +static void +sigusr1_handler (int signal, siginfo_t *si, void *un) +{ + GSList *list = sess_list; + session *sess; + + while (list) + { + sess = list->data; + log_open_or_close (sess); + list = list->next; + } +} + +/* Execute /SIGUSR2 when SIGUSR2 received */ + +static void +sigusr2_handler (int signal, siginfo_t *si, void *un) +{ + session *sess = current_sess; + + if (sess) + handle_command (sess, "SIGUSR2", FALSE); +} +#endif + +static gint +xchat_auto_connect (gpointer userdata) +{ + servlist_auto_connect (NULL); + return 0; +} + +static void +xchat_init (void) +{ + char buf[3068]; + const char *cs = NULL; + +#ifdef WIN32 + WSADATA wsadata; + +#ifdef USE_IPV6 + if (WSAStartup(0x0202, &wsadata) != 0) + { + MessageBox (NULL, "Cannot find winsock 2.2+", "Error", MB_OK); + exit (0); + } +#else + WSAStartup(0x0101, &wsadata); +#endif /* !USE_IPV6 */ +#endif /* !WIN32 */ + +#ifdef USE_SIGACTION + struct sigaction act; + + /* ignore SIGPIPE's */ + act.sa_handler = SIG_IGN; + act.sa_flags = 0; + sigemptyset (&act.sa_mask); + sigaction (SIGPIPE, &act, NULL); + + /* Deal with SIGUSR1's & SIGUSR2's */ + act.sa_sigaction = sigusr1_handler; + act.sa_flags = 0; + sigemptyset (&act.sa_mask); + sigaction (SIGUSR1, &act, NULL); + + act.sa_sigaction = sigusr2_handler; + act.sa_flags = 0; + sigemptyset (&act.sa_mask); + sigaction (SIGUSR2, &act, NULL); +#else +#ifndef WIN32 + /* good enough for these old systems */ + signal (SIGPIPE, SIG_IGN); +#endif +#endif + + if (g_get_charset (&cs)) + prefs.utf8_locale = TRUE; + + load_text_events (); + sound_load (); + notify_load (); + ignore_load (); + + snprintf (buf, sizeof (buf), + "NAME %s~%s~\n" "CMD query %%s\n\n"\ + "NAME %s~%s~\n" "CMD send %%s\n\n"\ + "NAME %s~%s~\n" "CMD whois %%s %%s\n\n"\ + "NAME %s~%s~\n" "CMD notify -n ASK %%s\n\n"\ + "NAME %s~%s~\n" "CMD ignore %%s!*@* ALL\n\n"\ + + "NAME SUB\n" "CMD %s\n\n"\ + "NAME %s\n" "CMD op %%a\n\n"\ + "NAME %s\n" "CMD deop %%a\n\n"\ + "NAME SEP\n" "CMD \n\n"\ + "NAME %s\n" "CMD voice %%a\n\n"\ + "NAME %s\n" "CMD devoice %%a\n"\ + "NAME SEP\n" "CMD \n\n"\ + "NAME SUB\n" "CMD %s\n\n"\ + "NAME %s\n" "CMD kick %%s\n\n"\ + "NAME %s\n" "CMD ban %%s\n\n"\ + "NAME SEP\n" "CMD \n\n"\ + "NAME %s *!*@*.host\n""CMD ban %%s 0\n\n"\ + "NAME %s *!*@domain\n""CMD ban %%s 1\n\n"\ + "NAME %s *!*user@*.host\n""CMD ban %%s 2\n\n"\ + "NAME %s *!*user@domain\n""CMD ban %%s 3\n\n"\ + "NAME SEP\n" "CMD \n\n"\ + "NAME %s *!*@*.host\n""CMD kickban %%s 0\n\n"\ + "NAME %s *!*@domain\n""CMD kickban %%s 1\n\n"\ + "NAME %s *!*user@*.host\n""CMD kickban %%s 2\n\n"\ + "NAME %s *!*user@domain\n""CMD kickban %%s 3\n\n"\ + "NAME ENDSUB\n" "CMD \n\n"\ + "NAME ENDSUB\n" "CMD \n\n", + + _("_Open Dialog Window"), "gtk-go-up", + _("_Send a File"), "gtk-floppy", + _("_User Info (WhoIs)"), "gtk-info", + _("_Add to Friends List"), "gtk-add", + _("_Ignore"), "gtk-stop", + _("O_perator Actions"), + + _("Give Ops"), + _("Take Ops"), + _("Give Voice"), + _("Take Voice"), + + _("Kick/Ban"), + _("Kick"), + _("Ban"), + _("Ban"), + _("Ban"), + _("Ban"), + _("Ban"), + _("KickBan"), + _("KickBan"), + _("KickBan"), + _("KickBan")); + + list_loadconf ("popup.conf", &popup_list, buf); + + snprintf (buf, sizeof (buf), + "NAME %s\n" "CMD part\n\n" + "NAME %s\n" "CMD getstr # join \"%s\"\n\n" + "NAME %s\n" "CMD quote LINKS\n\n" + "NAME %s\n" "CMD ping\n\n" + "NAME TOGGLE %s\n" "CMD irc_hide_version\n\n", + _("Leave Channel"), + _("Join Channel..."), + _("Enter Channel to Join:"), + _("Server Links"), + _("Ping Server"), + _("Hide Version")); + list_loadconf ("usermenu.conf", &usermenu_list, buf); + + snprintf (buf, sizeof (buf), + "NAME %s\n" "CMD op %%a\n\n" + "NAME %s\n" "CMD deop %%a\n\n" + "NAME %s\n" "CMD ban %%s\n\n" + "NAME %s\n" "CMD getstr \"%s\" \"kick %%s\" \"%s\"\n\n" + "NAME %s\n" "CMD send %%s\n\n" + "NAME %s\n" "CMD query %%s\n\n", + _("Op"), + _("DeOp"), + _("Ban"), + _("Kick"), + _("bye"), + _("Enter reason to kick %s:"), + _("Sendfile"), + _("Dialog")); + list_loadconf ("buttons.conf", &button_list, buf); + + snprintf (buf, sizeof (buf), + "NAME %s\n" "CMD whois %%s %%s\n\n" + "NAME %s\n" "CMD send %%s\n\n" + "NAME %s\n" "CMD dcc chat %%s\n\n" + "NAME %s\n" "CMD clear\n\n" + "NAME %s\n" "CMD ping %%s\n\n", + _("WhoIs"), + _("Send"), + _("Chat"), + _("Clear"), + _("Ping")); + list_loadconf ("dlgbuttons.conf", &dlgbutton_list, buf); + + list_loadconf ("tabmenu.conf", &tabmenu_list, NULL); + list_loadconf ("ctcpreply.conf", &ctcp_list, defaultconf_ctcp); + list_loadconf ("commands.conf", &command_list, defaultconf_commands); + list_loadconf ("replace.conf", &replace_list, defaultconf_replace); + list_loadconf ("urlhandlers.conf", &urlhandler_list, + defaultconf_urlhandlers); + + servlist_init (); /* load server list */ + + /* if we got a URL, don't open the server list GUI */ + if (!prefs.hex_gui_slist_skip && !arg_url) + fe_serverlist_open (NULL); + + /* turned OFF via -a arg */ + if (!arg_dont_autoconnect) + { + /* do any auto connects */ + if (!servlist_have_auto ()) /* if no new windows open .. */ + { + /* and no serverlist gui ... */ + if (prefs.hex_gui_slist_skip || arg_url) + /* we'll have to open one. */ + new_ircwindow (NULL, NULL, SESS_SERVER, 0); + } else + { + fe_idle_add (xchat_auto_connect, NULL); + } + } else + { + if (prefs.hex_gui_slist_skip || arg_url) + new_ircwindow (NULL, NULL, SESS_SERVER, 0); + } +} + +void +xchat_exit (void) +{ + xchat_is_quitting = TRUE; + in_xchat_exit = TRUE; + plugin_kill_all (); + fe_cleanup (); + + save_config (); + if (prefs.save_pevents) + { + pevent_save (NULL); + } + + sound_save (); + notify_save (); + ignore_save (); + free_sessions (); + chanopt_save_all (); + servlist_cleanup (); + fe_exit (); +} + +#ifndef WIN32 + +static int +child_handler (gpointer userdata) +{ + int pid = GPOINTER_TO_INT (userdata); + + if (waitpid (pid, 0, WNOHANG) == pid) + return 0; /* remove timeout handler */ + return 1; /* keep the timeout handler */ +} + +#endif + +void +xchat_exec (const char *cmd) +{ +#ifdef WIN32 + util_exec (cmd); +#else + int pid = util_exec (cmd); + if (pid != -1) + /* zombie avoiding system. Don't ask! it has to be like this to work + with zvt (which overrides the default handler) */ + fe_timeout_add (1000, child_handler, GINT_TO_POINTER (pid)); +#endif +} + +void +xchat_execv (char * const argv[]) +{ +#ifdef WIN32 + util_execv (argv); +#else + int pid = util_execv (argv); + if (pid != -1) + /* zombie avoiding system. Don't ask! it has to be like this to work + with zvt (which overrides the default handler) */ + fe_timeout_add (1000, child_handler, GINT_TO_POINTER (pid)); +#endif +} + +#ifdef WIN32 +static void +xchat_restore_window (HWND xchat_window) +{ + /* ShowWindow (xchat_window, SW_RESTORE); another way, but works worse */ + SendMessage (xchat_window, WM_SYSCOMMAND, SC_RESTORE, 0); + SetForegroundWindow (xchat_window); +} + +BOOL CALLBACK +enum_windows_impl (HWND current_window, LPARAM lParam) +{ + TCHAR window_name[8]; + TCHAR module_path[1024]; + ZeroMemory (&window_name, sizeof (window_name)); + + if (!current_window) + { + return TRUE; + } + + GetWindowText (current_window, window_name, 8); /* name length + 1 */ + if (strcmp (window_name, "HexChat") == 0) + { + /* use a separate if block, this way we don't have to call GetWindowModuleFileName() for each hit */ + ZeroMemory (&module_path, sizeof (module_path)); + GetWindowModuleFileName (current_window, module_path, sizeof (module_path)); + + if (strstr (module_path, "hexchat.exe")) /* We've found it, stop */ + { + xchat_restore_window (current_window); + return FALSE; + } + } + + return TRUE; /* Keep searching */ + +} +#endif + +int +main (int argc, char *argv[]) +{ + int ret; + +#ifdef WIN32 + char hexchat_lang[13]; /* LC_ALL= plus 5 chars of hex_gui_lang and trailing \0 */ + HANDLE mutex; +#endif + + srand (time (0)); /* CL: do this only once! */ + + load_config (); + +#ifdef WIN32 + /* we MUST do this after load_config () AND before fe_init (thus gtk_init) otherwise it will fail */ + strcpy (hexchat_lang, "LC_ALL="); + + /* this must be ordered EXACTLY as langsmenu[] */ + switch (prefs.hex_gui_lang) + { + case 0: + strcat (hexchat_lang, "af"); + break; + case 1: + strcat (hexchat_lang, "sq"); + break; + case 2: + strcat (hexchat_lang, "am"); + break; + case 3: + strcat (hexchat_lang, "ast"); + break; + case 4: + strcat (hexchat_lang, "az"); + break; + case 5: + strcat (hexchat_lang, "eu"); + break; + case 6: + strcat (hexchat_lang, "be"); + break; + case 7: + strcat (hexchat_lang, "bg"); + break; + case 8: + strcat (hexchat_lang, "ca"); + break; + case 9: + strcat (hexchat_lang, "zh_CN"); + break; + case 10: + strcat (hexchat_lang, "zh_TW"); + break; + case 11: + strcat (hexchat_lang, "cs"); + break; + case 12: + strcat (hexchat_lang, "da"); + break; + case 13: + strcat (hexchat_lang, "nl"); + break; + case 14: + strcat (hexchat_lang, "en_GB"); + break; + case 15: + strcat (hexchat_lang, "en"); + break; + case 16: + strcat (hexchat_lang, "et"); + break; + case 17: + strcat (hexchat_lang, "fi"); + break; + case 18: + strcat (hexchat_lang, "fr"); + break; + case 19: + strcat (hexchat_lang, "gl"); + break; + case 20: + strcat (hexchat_lang, "de"); + break; + case 21: + strcat (hexchat_lang, "el"); + break; + case 22: + strcat (hexchat_lang, "gu"); + break; + case 23: + strcat (hexchat_lang, "hi"); + break; + case 24: + strcat (hexchat_lang, "hu"); + break; + case 25: + strcat (hexchat_lang, "id"); + break; + case 26: + strcat (hexchat_lang, "it"); + break; + case 27: + strcat (hexchat_lang, "ja"); + break; + case 28: + strcat (hexchat_lang, "kn"); + break; + case 29: + strcat (hexchat_lang, "rw"); + break; + case 30: + strcat (hexchat_lang, "ko"); + break; + case 31: + strcat (hexchat_lang, "lv"); + break; + case 32: + strcat (hexchat_lang, "lt"); + break; + case 33: + strcat (hexchat_lang, "mk"); + break; + case 34: + strcat (hexchat_lang, "ml"); + break; + case 35: + strcat (hexchat_lang, "ms"); + break; + case 36: + strcat (hexchat_lang, "nb"); + break; + case 37: + strcat (hexchat_lang, "no"); + break; + case 38: + strcat (hexchat_lang, "pl"); + break; + case 39: + strcat (hexchat_lang, "pt"); + break; + case 40: + strcat (hexchat_lang, "pt_BR"); + break; + case 41: + strcat (hexchat_lang, "pa"); + break; + case 42: + strcat (hexchat_lang, "ru"); + break; + case 43: + strcat (hexchat_lang, "sr"); + break; + case 44: + strcat (hexchat_lang, "sk"); + break; + case 45: + strcat (hexchat_lang, "sl"); + break; + case 46: + strcat (hexchat_lang, "es"); + break; + case 47: + strcat (hexchat_lang, "sv"); + break; + case 48: + strcat (hexchat_lang, "th"); + break; + case 49: + strcat (hexchat_lang, "uk"); + break; + case 50: + strcat (hexchat_lang, "vi"); + break; + case 51: + strcat (hexchat_lang, "wa"); + break; + default: + strcat (hexchat_lang, "en"); + break; + } + + putenv (hexchat_lang); + + if (prefs.hex_gui_single && !portable_mode ()) + { + DWORD error; + + mutex = CreateMutex (NULL, TRUE, "Local\\hexchat"); + error = GetLastError (); + + if (error == ERROR_ALREADY_EXISTS || mutex == NULL) + { + /* restoring the XChat window from the tray via the taskbar icon + * only works correctly when X-Tray is used, but it's not a big deal + * since you can only minimize XChat to tray via the taskbar if you + * use X-Tray*/ + if (hextray_mode ()) + { + /* FindWindow() doesn't support wildcards so we check all the open windows */ + EnumWindows (enum_windows_impl, NULL); + return 0; + } + else + { + return 1; + } + } + } +#endif + +#ifdef SOCKS + SOCKSinit (argv[0]); +#endif + + ret = fe_args (argc, argv); + if (ret != -1) + return ret; + +#ifdef USE_DBUS + xchat_remote (); +#endif + +#ifdef USE_LIBPROXY + libproxy_factory = px_proxy_factory_new(); +#endif + + fe_init (); + + xchat_init (); + + fe_main (); + +#ifdef USE_LIBPROXY + px_proxy_factory_free(libproxy_factory); +#endif + +#ifdef USE_OPENSSL + if (ctx) + _SSL_context_free (ctx); +#endif + +#ifdef USE_DEBUG + xchat_mem_list (); +#endif + +#ifdef WIN32 + WSACleanup (); + + if (prefs.hex_gui_single && !portable_mode ()) + { + ReleaseMutex (mutex); + CloseHandle (mutex); + } +#endif + + return 0; +} diff --git a/src/common/hexchat.h b/src/common/hexchat.h new file mode 100644 index 00000000..2980fc1c --- /dev/null +++ b/src/common/hexchat.h @@ -0,0 +1,595 @@ +#include "../../config.h" + +#include +#include /* need time_t */ + +#ifndef XCHAT_H +#define XCHAT_H + +#include "history.h" + +#ifndef HAVE_SNPRINTF +#define snprintf g_snprintf +#endif + +#ifndef HAVE_VSNPRINTF +#define vsnprintf _vsnprintf +#endif + +#ifdef USE_DEBUG +#define malloc(n) xchat_malloc(n, __FILE__, __LINE__) +#define realloc(n, m) xchat_realloc(n, m, __FILE__, __LINE__) +#define free(n) xchat_dfree(n, __FILE__, __LINE__) +#define strdup(n) xchat_strdup(n, __FILE__, __LINE__) +void *xchat_malloc (int size, char *file, int line); +void *xchat_strdup (char *str, char *file, int line); +void xchat_dfree (void *buf, char *file, int line); +void *xchat_realloc (char *old, int len, char *file, int line); +#endif + +#ifdef SOCKS +#ifdef __sgi +#include +#define INCLUDE_PROTOTYPES 1 +#endif +#include +#endif + +#ifdef USE_OPENSSL +#include /* SSL_() */ +#endif + +#ifdef __EMX__ /* for o/s 2 */ +#define OFLAGS O_BINARY +#define g_ascii_strcasecmp stricmp +#define g_ascii_strncasecmp strnicmp +#define PATH_MAX MAXPATHLEN +#define FILEPATH_LEN_MAX MAXPATHLEN +#endif + +/* force a 32bit CMP.L */ +#define CMPL(a, c0, c1, c2, c3) (a == (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24))) +#define WORDL(c0, c1, c2, c3) (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24)) +#define WORDW(c0, c1) (guint16)(c0 | (c1 << 8)) + +#ifdef WIN32 /* for win32 */ +#define OFLAGS O_BINARY +#define sleep(t) Sleep(t*1000) +#include +#define F_OK 0 +#define X_OK 1 +#define W_OK 2 +#define R_OK 4 +#ifndef S_ISDIR +#define S_ISDIR(m) ((m) & _S_IFDIR) +#endif +#define NETWORK_PRIVATE +#else /* for unix */ +#define OFLAGS 0 +#endif + +#define FONTNAMELEN 127 +#define PATHLEN 255 +#define DOMAINLEN 100 +#define NICKLEN 64 /* including the NULL, so 63 really */ +#define CHANLEN 300 +#define PDIWORDS 32 +#define USERNAMELEN 10 +#define HIDDEN_CHAR 8 /* invisible character for xtext */ + +#if defined(ENABLE_NLS) && !defined(_) +# include +# define _(x) gettext(x) +# ifdef gettext_noop +# define N_(String) gettext_noop (String) +# else +# define N_(String) (String) +# endif +#endif +#if !defined(_) +# define N_(String) (String) +# define _(x) (x) +#endif + +struct nbexec +{ + int myfd; + int childpid; + int tochannel; /* making this int keeps the struct 4-byte aligned */ + int iotag; + char *linebuf; + int buffill; + struct session *sess; +}; + +struct hexchatprefs +{ + /* these are the rebranded, consistent, sorted hexchat variables */ + + /* BOOLEANS */ + unsigned int hex_away_auto_unmark; + unsigned int hex_away_omit_alerts; + unsigned int hex_away_show_message; + unsigned int hex_away_show_once; + unsigned int hex_away_track; + unsigned int hex_completion_auto; + unsigned int hex_dcc_auto_chat; + unsigned int hex_dcc_auto_resume; + unsigned int hex_dcc_fast_send; + unsigned int hex_dcc_ip_from_server; + unsigned int hex_dcc_remove; + unsigned int hex_dcc_save_nick; + unsigned int hex_dcc_send_fillspaces; + unsigned int hex_gui_autoopen_chat; + unsigned int hex_gui_autoopen_dialog; + unsigned int hex_gui_autoopen_recv; + unsigned int hex_gui_autoopen_send; + unsigned int hex_gui_compact; + unsigned int hex_gui_hide_menu; + unsigned int hex_gui_input_nick; + unsigned int hex_gui_input_spell; + unsigned int hex_gui_input_style; + unsigned int hex_gui_join_dialog; + unsigned int hex_gui_mode_buttons; + unsigned int hex_gui_quit_dialog; + unsigned int hex_gui_single; + unsigned int hex_gui_slist_fav; + unsigned int hex_gui_slist_skip; + unsigned int hex_gui_tab_chans; + unsigned int hex_gui_tab_dialogs; + unsigned int hex_gui_tab_dots; + unsigned int hex_gui_tab_icons; + unsigned int hex_gui_tab_notices; + unsigned int hex_gui_tab_server; + unsigned int hex_gui_tab_sort; + unsigned int hex_gui_tab_utils; + unsigned int hex_gui_topicbar; + unsigned int hex_gui_tray; + unsigned int hex_gui_ulist_buttons; + unsigned int hex_gui_ulist_count; + unsigned int hex_gui_ulist_hide; + unsigned int hex_gui_ulist_icons; + unsigned int hex_gui_ulist_resizable; + unsigned int hex_gui_ulist_show_hosts; + unsigned int hex_gui_ulist_style; + unsigned int hex_gui_usermenu; + unsigned int hex_gui_win_modes; + unsigned int hex_gui_win_save; + unsigned int hex_gui_win_swap; + unsigned int hex_gui_win_ucount; + unsigned int hex_identd; + unsigned int hex_input_balloon_chans; + unsigned int hex_input_balloon_hilight; + unsigned int hex_input_balloon_priv; + unsigned int hex_input_beep_chans; + unsigned int hex_input_beep_hilight; + unsigned int hex_input_beep_priv; + unsigned int hex_input_filter_beep; + unsigned int hex_input_flash_chans; + unsigned int hex_input_flash_hilight; + unsigned int hex_input_flash_priv; + unsigned int hex_input_perc_ascii; + unsigned int hex_input_perc_color; + unsigned int hex_input_tray_chans; + unsigned int hex_input_tray_hilight; + unsigned int hex_input_tray_priv; + unsigned int hex_irc_auto_rejoin; + unsigned int hex_irc_conf_mode; + unsigned int hex_irc_hide_version; + unsigned int hex_irc_invisible; + unsigned int hex_irc_logging; + unsigned int hex_irc_raw_modes; + unsigned int hex_irc_servernotice; + unsigned int hex_irc_skip_motd; + unsigned int hex_irc_wallops; + unsigned int hex_irc_who_join; + unsigned int hex_irc_whois_front; + unsigned int hex_net_auto_reconnect; + unsigned int hex_net_auto_reconnectonfail; + unsigned int hex_net_proxy_auth; + unsigned int hex_net_throttle; + unsigned int hex_notify_whois_online; + unsigned int hex_perl_warnings; + unsigned int hex_stamp_log; + unsigned int hex_stamp_text; + unsigned int hex_text_autocopy_color; + unsigned int hex_text_autocopy_stamp; + unsigned int hex_text_autocopy_text; + unsigned int hex_text_color_nicks; + unsigned int hex_text_indent; + unsigned int hex_text_replay; + unsigned int hex_text_search_case_match; + unsigned int hex_text_search_backward; + unsigned int hex_text_search_highlight_all; + unsigned int hex_text_search_follow; + unsigned int hex_text_search_regexp; + unsigned int hex_text_show_marker; + unsigned int hex_text_show_sep; + unsigned int hex_text_stripcolor_msg; + unsigned int hex_text_stripcolor_replay; + unsigned int hex_text_stripcolor_topic; + unsigned int hex_text_thin_sep; + unsigned int hex_text_transparent; + unsigned int hex_text_wordwrap; + unsigned int hex_url_grabber; + unsigned int hex_url_logging; + + /* NUMBERS */ + int hex_away_size_max; + int hex_away_timeout; + int hex_completion_amount; + int hex_completion_sort; + int hex_dcc_auto_recv; + int hex_dcc_blocksize; + int hex_dcc_global_max_get_cps; + int hex_dcc_global_max_send_cps; + int hex_dcc_max_get_cps; + int hex_dcc_max_send_cps; + int hex_dcc_permissions; + int hex_dcc_port_first; + int hex_dcc_port_last; + int hex_dcc_stall_timeout; + int hex_dcc_timeout; + int hex_flood_ctcp_num; /* flood */ + int hex_flood_ctcp_time; /* seconds of floods */ + int hex_flood_msg_num; /* same deal */ + int hex_flood_msg_time; + int hex_gui_chanlist_maxusers; + int hex_gui_chanlist_minusers; + int hex_gui_dialog_height; + int hex_gui_dialog_left; + int hex_gui_dialog_top; + int hex_gui_dialog_width; + int hex_gui_lagometer; + int hex_gui_lang; + int hex_gui_pane_left_size; + int hex_gui_pane_right_size; + int hex_gui_pane_right_size_min; + int hex_gui_slist_select; + int hex_gui_tab_layout; + int hex_gui_tab_newtofront; + int hex_gui_tab_pos; + int hex_gui_tab_small; + int hex_gui_tab_trunc; + int hex_gui_throttlemeter; + int hex_gui_tray_flags; + int hex_gui_ulist_pos; + int hex_gui_ulist_sort; + int hex_gui_url_mod; + int hex_gui_win_height; + int hex_gui_win_left; + int hex_gui_win_state; + int hex_gui_win_top; + int hex_gui_win_width; + int hex_input_balloon_time; + int hex_irc_ban_type; + int hex_irc_join_delay; + int hex_net_ping_timeout; + int hex_net_proxy_port; + int hex_net_proxy_type; /* 0=disabled, 1=wingate 2=socks4, 3=socks5, 4=http */ + int hex_net_proxy_use; /* 0=all 1=IRC_ONLY 2=DCC_ONLY */ + int hex_net_reconnect_delay; + int hex_notify_timeout; + int hex_text_max_indent; + int hex_text_max_lines; + int hex_text_tint_blue; + int hex_text_tint_green; + int hex_text_tint_red; + int hex_url_grabber_limit; + + /* STRINGS */ + char hex_away_reason[256]; + char hex_completion_suffix[4]; /* Only ever holds a one-character string. */ + char hex_dcc_completed_dir[PATHLEN + 1]; + char hex_dcc_dir[PATHLEN + 1]; + char hex_dcc_ip[DOMAINLEN + 1]; + char hex_dnsprogram[72]; + char hex_gui_ulist_doubleclick[256]; + char hex_input_command_char[4]; + char hex_irc_extra_hilight[300]; + char hex_irc_id_ntext[64]; + char hex_irc_id_ytext[64]; + char hex_irc_logmask[256]; + char hex_irc_nick1[NICKLEN]; + char hex_irc_nick2[NICKLEN]; + char hex_irc_nick3[NICKLEN]; + char hex_irc_nick_hilight[300]; + char hex_irc_no_hilight[300]; + char hex_irc_part_reason[256]; + char hex_irc_quit_reason[256]; + char hex_irc_real_name[127]; + char hex_irc_user_name[127]; + char hex_net_bind_host[127]; + char hex_net_proxy_host[64]; + char hex_net_proxy_pass[32]; + char hex_net_proxy_user[32]; + char hex_sound_command[PATHLEN + 1]; + char hex_sound_dir[PATHLEN + 1]; + char hex_stamp_log_format[64]; + char hex_stamp_text_format[64]; + char hex_text_background[PATHLEN + 1]; + char hex_text_font[4 * FONTNAMELEN + 1]; + char hex_text_font_main[FONTNAMELEN + 1]; + char hex_text_font_alternative[3 * FONTNAMELEN + 1]; + char hex_text_spell_langs[64]; + + /* these are the private variables */ + guint32 local_ip; + guint32 dcc_ip; + + unsigned int wait_on_exit; /* wait for logs to be flushed to disk IF we're connected */ + unsigned int utf8_locale; + + /* Tells us if we need to save, only when they've been edited. + This is so that we continue using internal defaults (which can + change in the next release) until the user edits them. */ + unsigned int save_pevents:1; +}; + +/* Session types */ +#define SESS_SERVER 1 +#define SESS_CHANNEL 2 +#define SESS_DIALOG 3 +#define SESS_NOTICES 4 +#define SESS_SNOTICES 5 + +/* Per-Channel Settings */ +#define SET_OFF 0 +#define SET_ON 1 +#define SET_DEFAULT 2 /* use global setting */ + +/* Moved from fe-gtk for use in outbound.c as well -- */ +typedef enum gtk_xtext_search_flags_e { + case_match = 1, + backward = 2, + highlight = 4, + follow = 8, + regexp = 16 +} gtk_xtext_search_flags; + +typedef struct session +{ + /* Per-Channel Alerts */ + /* use a byte, because we need a pointer to each element */ + guint8 alert_beep; + guint8 alert_taskbar; + guint8 alert_tray; + + /* Per-Channel Settings */ + guint8 text_hidejoinpart; + guint8 text_logging; + guint8 text_scrollback; + + struct server *server; + void *usertree_alpha; /* pure alphabetical tree */ + void *usertree; /* ordered with Ops first */ + struct User *me; /* points to myself in the usertree */ + char channel[CHANLEN]; + char waitchannel[CHANLEN]; /* waiting to join channel (/join sent) */ + char willjoinchannel[CHANLEN]; /* will issue /join for this channel */ + char channelkey[64]; /* XXX correct max length? */ + int limit; /* channel user limit */ + int logfd; + int scrollfd; /* scrollback filedes */ + int scrollwritten; /* number of lines written */ + + char lastnick[NICKLEN]; /* last nick you /msg'ed */ + + struct history history; + + int ops; /* num. of ops in channel */ + int hops; /* num. of half-oped users */ + int voices; /* num. of voiced people */ + int total; /* num. of users in channel */ + + char *quitreason; + char *topic; + char *current_modes; /* free() me */ + + int mode_timeout_tag; + + struct session *lastlog_sess; + struct nbexec *running_exec; + + struct session_gui *gui; /* initialized by fe_new_window */ + struct restore_gui *res; + + int type; /* SESS_* */ + + int new_data:1; /* new data avail? (purple tab) */ + int nick_said:1; /* your nick mentioned? (blue tab) */ + int msg_said:1; /* new msg available? (red tab) */ + + int ignore_date:1; + int ignore_mode:1; + int ignore_names:1; + int end_of_names:1; + int doing_who:1; /* /who sent on this channel */ + int done_away_check:1; /* done checking for away status changes */ + gtk_xtext_search_flags lastlog_flags; +} session; + +struct msproxy_state_t +{ + gint32 clientid; + gint32 serverid; + unsigned char seq_recv; /* seq number of last packet recv. */ + unsigned char seq_sent; /* seq number of last packet sent. */ +}; + +typedef struct server +{ + /* server control operations (in server*.c) */ + void (*connect)(struct server *, char *hostname, int port, int no_login); + void (*disconnect)(struct session *, int sendquit, int err); + int (*cleanup)(struct server *); + void (*flush_queue)(struct server *); + void (*auto_reconnect)(struct server *, int send_quit, int err); + /* irc protocol functions (in proto*.c) */ + void (*p_inline)(struct server *, char *buf, int len); + void (*p_invite)(struct server *, char *channel, char *nick); + void (*p_cycle)(struct server *, char *channel, char *key); + void (*p_ctcp)(struct server *, char *to, char *msg); + void (*p_nctcp)(struct server *, char *to, char *msg); + void (*p_quit)(struct server *, char *reason); + void (*p_kick)(struct server *, char *channel, char *nick, char *reason); + void (*p_part)(struct server *, char *channel, char *reason); + void (*p_ns_identify)(struct server *, char *pass); + void (*p_ns_ghost)(struct server *, char *usname, char *pass); + void (*p_join)(struct server *, char *channel, char *key); + void (*p_join_list)(struct server *, GSList *channels, GSList *keys); + void (*p_login)(struct server *, char *user, char *realname); + void (*p_join_info)(struct server *, char *channel); + void (*p_mode)(struct server *, char *target, char *mode); + void (*p_user_list)(struct server *, char *channel); + void (*p_away_status)(struct server *, char *channel); + void (*p_whois)(struct server *, char *nicks); + void (*p_get_ip)(struct server *, char *nick); + void (*p_get_ip_uh)(struct server *, char *nick); + void (*p_set_back)(struct server *); + void (*p_set_away)(struct server *, char *reason); + void (*p_message)(struct server *, char *channel, char *text); + void (*p_action)(struct server *, char *channel, char *act); + void (*p_notice)(struct server *, char *channel, char *text); + void (*p_topic)(struct server *, char *channel, char *topic); + void (*p_list_channels)(struct server *, char *arg, int min_users); + void (*p_change_nick)(struct server *, char *new_nick); + void (*p_names)(struct server *, char *channel); + void (*p_ping)(struct server *, char *to, char *timestring); +/* void (*p_set_away)(struct server *);*/ + int (*p_raw)(struct server *, char *raw); + int (*p_cmp)(const char *s1, const char *s2); + + int port; + int sok; /* is equal to sok4 or sok6 (the one we are using) */ + int sok4; /* tcp4 socket */ + int sok6; /* tcp6 socket */ + int proxy_type; + int proxy_sok; /* Additional information for MS Proxy beast */ + int proxy_sok4; + int proxy_sok6; + struct msproxy_state_t msp_state; + int id; /* unique ID number (for plugin API) */ +#ifdef USE_OPENSSL + SSL *ssl; + int ssl_do_connect_tag; +#else + void *ssl; +#endif + int childread; + int childwrite; + int childpid; + int iotag; + int recondelay_tag; /* reconnect delay timeout */ + int joindelay_tag; /* waiting before we send JOIN */ + char hostname[128]; /* real ip number */ + char servername[128]; /* what the server says is its name */ + char password[86]; + char nick[NICKLEN]; + char linebuf[2048]; /* RFC says 512 chars including \r\n */ + char *last_away_reason; + int pos; /* current position in linebuf */ + int nickcount; + int nickservtype; /* 0=/MSG nickserv 1=/NICKSERV 2=/NS */ + + char *chantypes; /* for 005 numeric - free me */ + char *chanmodes; /* for 005 numeric - free me */ + char *nick_prefixes; /* e.g. "*@%+" */ + char *nick_modes; /* e.g. "aohv" */ + char *bad_nick_prefixes; /* for ircd that doesn't give the modes */ + int modes_per_line; /* 6 on undernet, 4 on efnet etc... */ + + void *network; /* points to entry in servlist.c or NULL! */ + + GSList *outbound_queue; + time_t next_send; /* cptr->since in ircu */ + time_t prev_now; /* previous now-time */ + int sendq_len; /* queue size */ + int lag; /* milliseconds */ + + struct session *front_session; /* front-most window/tab */ + struct session *server_session; /* server window/tab */ + + struct server_gui *gui; /* initialized by fe_new_server */ + + unsigned int ctcp_counter; /*flood */ + time_t ctcp_last_time; + + unsigned int msg_counter; /*counts the msg tab opened in a certain time */ + time_t msg_last_time; + + /*time_t connect_time;*/ /* when did it connect? */ + time_t lag_sent; + time_t ping_recv; /* when we last got a ping reply */ + time_t away_time; /* when we were marked away */ + + char *encoding; /* NULL for system */ + char *autojoin; /* list of channels & keys to join */ + + unsigned int motd_skipped:1; + unsigned int connected:1; + unsigned int connecting:1; + unsigned int no_login:1; + unsigned int skip_next_userhost:1;/* used for "get my ip from server" */ + unsigned int skip_next_whois:1; /* hide whois output */ + unsigned int inside_whois:1; + unsigned int doing_dns:1; /* /dns has been done */ + unsigned int end_of_motd:1; /* end of motd reached (logged in) */ + unsigned int sent_quit:1; /* sent a QUIT already? */ + unsigned int use_listargs:1; /* undernet and dalnet need /list >0,<10000 */ + unsigned int is_away:1; + unsigned int reconnect_away:1; /* whether to reconnect in is_away state */ + unsigned int dont_use_proxy:1; /* to proxy or not to proxy */ + unsigned int supports_watch:1; /* supports the WATCH command */ + unsigned int bad_prefix:1; /* gave us a bad PREFIX= 005 number */ + unsigned int have_namesx:1; /* 005 tokens NAMESX and UHNAMES */ + unsigned int have_uhnames:1; + unsigned int have_whox:1; /* have undernet's WHOX features */ + unsigned int have_capab:1; /* supports CAPAB (005 tells us) */ + unsigned int have_idmsg:1; /* freenode's IDENTIFY-MSG */ + unsigned int have_except:1; /* ban exemptions +e */ + unsigned int using_cp1255:1; /* encoding is CP1255/WINDOWS-1255? */ + unsigned int using_irc:1; /* encoding is "IRC" (CP1252/UTF-8 hybrid)? */ + unsigned int use_who:1; /* whether to use WHO command to get dcc_ip */ +#ifdef USE_OPENSSL + unsigned int use_ssl:1; /* is server SSL capable? */ + unsigned int accept_invalid_cert:1;/* ignore result of server's cert. verify */ +#endif +} server; + +typedef int (*cmd_callback) (struct session * sess, char *tbuf, char *word[], + char *word_eol[]); + +struct commands +{ + char *name; + cmd_callback callback; + char needserver; + char needchannel; + gint16 handle_quotes; + char *help; +}; + +struct away_msg +{ + struct server *server; + char nick[NICKLEN]; + char *message; +}; + +/* not just for popups, but used for usercommands, ctcp replies, + userlist buttons etc */ + +struct popup +{ + char *cmd; + char *name; +}; + +/* CL: get a random int in the range [0..n-1]. DON'T use rand() % n, it gives terrible results. */ +#define RAND_INT(n) ((int)(rand() / (RAND_MAX + 1.0) * (n))) + +#define xchat_filename_from_utf8 g_filename_from_utf8 +#define xchat_filename_to_utf8 g_filename_to_utf8 + +#endif diff --git a/src/common/hexchatc.h b/src/common/hexchatc.h new file mode 100644 index 00000000..1d955055 --- /dev/null +++ b/src/common/hexchatc.h @@ -0,0 +1,39 @@ +#ifndef XCHAT_C_H +#define XCHAT_C_H + +extern struct hexchatprefs prefs; + +extern int xchat_is_quitting; +extern gint arg_skip_plugins; /* command-line args */ +extern gint arg_dont_autoconnect; +extern char *arg_url; +extern char *arg_command; +extern gint arg_existing; + +extern session *current_sess; +extern session *current_tab; + +extern GSList *popup_list; +extern GSList *button_list; +extern GSList *dlgbutton_list; +extern GSList *command_list; +extern GSList *ctcp_list; +extern GSList *replace_list; +extern GSList *sess_list; +extern GSList *dcc_list; +extern GSList *ignore_list; +extern GSList *usermenu_list; +extern GSList *urlhandler_list; +extern GSList *tabmenu_list; + +session * find_channel (server *serv, char *chan); +session * find_dialog (server *serv, char *nick); +session * new_ircwindow (server *serv, char *name, int type, int focus); +int is_session (session * sess); +void session_free (session *killsess); +void lag_check (void); +void xchat_exit (void); +void xchat_exec (const char *cmd); +void xchat_execv (char * const argv[]); + +#endif diff --git a/src/common/identd.c b/src/common/identd.c index 5ef5e0c6..db08ff90 100644 --- a/src/common/identd.c +++ b/src/common/identd.c @@ -1,8 +1,8 @@ /* simple identd server for xchat under win32 */ #include "inet.h" -#include "xchat.h" -#include "xchatc.h" +#include "hexchat.h" +#include "hexchatc.h" #include "text.h" static int identd_is_running = FALSE; diff --git a/src/common/ignore.c b/src/common/ignore.c index 12a2926a..b6eae41a 100644 --- a/src/common/ignore.c +++ b/src/common/ignore.c @@ -29,13 +29,13 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include "ignore.h" #include "cfgfiles.h" #include "fe.h" #include "text.h" #include "util.h" -#include "xchatc.h" +#include "hexchatc.h" int ignored_ctcp = 0; /* keep a count of all we ignore */ diff --git a/src/common/inbound.c b/src/common/inbound.c index 9d39e5cd..3d42279f 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -33,7 +33,7 @@ #define WANTDNS #include "inet.h" -#include "xchat.h" +#include "hexchat.h" #include "util.h" #include "ignore.h" #include "fe.h" @@ -46,7 +46,7 @@ #include "text.h" #include "ctcp.h" #include "plugin.h" -#include "xchatc.h" +#include "hexchatc.h" void diff --git a/src/common/modes.c b/src/common/modes.c index 07a5cea4..b84b2b84 100644 --- a/src/common/modes.c +++ b/src/common/modes.c @@ -22,8 +22,8 @@ #include #include -#include "xchat.h" -#include "xchatc.h" +#include "hexchat.h" +#include "hexchatc.h" #include "modes.h" #include "server.h" #include "text.h" diff --git a/src/common/msproxy.c b/src/common/msproxy.c index 01b6120a..9febe8d0 100644 --- a/src/common/msproxy.c +++ b/src/common/msproxy.c @@ -36,9 +36,9 @@ #define WANTARPA #include "inet.h" -#include "xchat.h" +#include "hexchat.h" #include "network.h" -#include "xchatc.h" +#include "hexchatc.h" #include "server.h" #include "msproxy.h" diff --git a/src/common/notify.c b/src/common/notify.c index f9fbe121..1dff8ec7 100644 --- a/src/common/notify.c +++ b/src/common/notify.c @@ -30,14 +30,14 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include "notify.h" #include "cfgfiles.h" #include "fe.h" #include "server.h" #include "text.h" #include "util.h" -#include "xchatc.h" +#include "hexchatc.h" GSList *notify_list = 0; diff --git a/src/common/outbound.c b/src/common/outbound.c index bb652aad..ed97886e 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -38,7 +38,7 @@ #include #include -#include "xchat.h" +#include "hexchat.h" #include "plugin.h" #include "ignore.h" #include "util.h" @@ -49,7 +49,7 @@ #include "notify.h" #include "inbound.h" #include "text.h" -#include "xchatc.h" +#include "hexchatc.h" #include "servlist.h" #include "server.h" #include "tree.h" diff --git a/src/common/plugin-timer.c b/src/common/plugin-timer.c index 431ce8ab..eaf6cde6 100644 --- a/src/common/plugin-timer.c +++ b/src/common/plugin-timer.c @@ -1,7 +1,7 @@ #include #include #include -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #ifdef WIN32 #define g_ascii_strcasecmp stricmp diff --git a/src/common/plugin.c b/src/common/plugin.c index 7111289c..cc626659 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -29,7 +29,7 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include "fe.h" #include "util.h" #include "outbound.h" @@ -42,11 +42,11 @@ #include "text.h" #define PLUGIN_C typedef struct session xchat_context; -#include "xchat-plugin.h" +#include "hexchat-plugin.h" #include "plugin.h" -#include "xchatc.h" +#include "hexchatc.h" /* the USE_PLUGIN define only removes libdl stuff */ diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index ed7d9a4d..8967504e 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -28,7 +28,7 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include "ctcp.h" #include "fe.h" #include "ignore.h" @@ -40,7 +40,7 @@ #include "text.h" #include "outbound.h" #include "util.h" -#include "xchatc.h" +#include "hexchatc.h" #include "url.h" diff --git a/src/common/server.c b/src/common/server.c index 8c831ad0..04b955bb 100644 --- a/src/common/server.c +++ b/src/common/server.c @@ -42,12 +42,12 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include "fe.h" #include "cfgfiles.h" #include "network.h" #include "notify.h" -#include "xchatc.h" +#include "hexchatc.h" #include "inbound.h" #include "outbound.h" #include "text.h" diff --git a/src/common/servlist.c b/src/common/servlist.c index 201652da..86a78ebf 100644 --- a/src/common/servlist.c +++ b/src/common/servlist.c @@ -26,7 +26,7 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include #include "cfgfiles.h" @@ -34,7 +34,7 @@ #include "server.h" #include "text.h" #include "util.h" /* token_foreach */ -#include "xchatc.h" +#include "hexchatc.h" #include "servlist.h" diff --git a/src/common/text.c b/src/common/text.c index 1076f8a0..39dd92c2 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -32,7 +32,7 @@ #include #endif -#include "xchat.h" +#include "hexchat.h" #include #include "cfgfiles.h" #include "chanopt.h" @@ -41,7 +41,7 @@ #include "server.h" #include "util.h" #include "outbound.h" -#include "xchatc.h" +#include "hexchatc.h" #include "text.h" #ifdef WIN32 #include diff --git a/src/common/url.c b/src/common/url.c index 32d282db..f722ca34 100644 --- a/src/common/url.c +++ b/src/common/url.c @@ -20,8 +20,8 @@ #include #include #include -#include "xchat.h" -#include "xchatc.h" +#include "hexchat.h" +#include "hexchatc.h" #include "cfgfiles.h" #include "fe.h" #include "tree.h" diff --git a/src/common/userlist.c b/src/common/userlist.c index 2dedb997..620ed4aa 100644 --- a/src/common/userlist.c +++ b/src/common/userlist.c @@ -20,12 +20,12 @@ #include #include -#include "xchat.h" +#include "hexchat.h" #include "modes.h" #include "fe.h" #include "notify.h" #include "tree.h" -#include "xchatc.h" +#include "hexchatc.h" #include "util.h" diff --git a/src/common/util.c b/src/common/util.c index 15184250..38a87f26 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -43,8 +43,8 @@ #include #include -#include "xchat.h" -#include "xchatc.h" +#include "hexchat.h" +#include "hexchatc.h" #include #include #include "util.h" diff --git a/src/common/xchat-plugin.h b/src/common/xchat-plugin.h deleted file mode 100644 index 1b7da8fb..00000000 --- a/src/common/xchat-plugin.h +++ /dev/null @@ -1,381 +0,0 @@ -/* You can distribute this header with your plugins for easy compilation */ -#ifndef XCHAT_PLUGIN_H -#define XCHAT_PLUGIN_H - -#include - -#define XCHAT_IFACE_MAJOR 1 -#define XCHAT_IFACE_MINOR 9 -#define XCHAT_IFACE_MICRO 11 -#define XCHAT_IFACE_VERSION ((XCHAT_IFACE_MAJOR * 10000) + \ - (XCHAT_IFACE_MINOR * 100) + \ - (XCHAT_IFACE_MICRO)) - -#define XCHAT_PRI_HIGHEST 127 -#define XCHAT_PRI_HIGH 64 -#define XCHAT_PRI_NORM 0 -#define XCHAT_PRI_LOW (-64) -#define XCHAT_PRI_LOWEST (-128) - -#define XCHAT_FD_READ 1 -#define XCHAT_FD_WRITE 2 -#define XCHAT_FD_EXCEPTION 4 -#define XCHAT_FD_NOTSOCKET 8 - -#define XCHAT_EAT_NONE 0 /* pass it on through! */ -#define XCHAT_EAT_XCHAT 1 /* don't let xchat see this event */ -#define XCHAT_EAT_PLUGIN 2 /* don't let other plugins see this event */ -#define XCHAT_EAT_ALL (XCHAT_EAT_XCHAT|XCHAT_EAT_PLUGIN) /* don't let anything see this event */ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _xchat_plugin xchat_plugin; -typedef struct _xchat_list xchat_list; -typedef struct _xchat_hook xchat_hook; -#ifndef PLUGIN_C -typedef struct _xchat_context xchat_context; -#endif - -#ifndef PLUGIN_C -struct _xchat_plugin -{ - /* these are only used on win32 */ - xchat_hook *(*xchat_hook_command) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - const char *help_text, - void *userdata); - xchat_hook *(*xchat_hook_server) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_print) (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_timer) (xchat_plugin *ph, - int timeout, - int (*callback) (void *user_data), - void *userdata); - xchat_hook *(*xchat_hook_fd) (xchat_plugin *ph, - int fd, - int flags, - int (*callback) (int fd, int flags, void *user_data), - void *userdata); - void *(*xchat_unhook) (xchat_plugin *ph, - xchat_hook *hook); - void (*xchat_print) (xchat_plugin *ph, - const char *text); - void (*xchat_printf) (xchat_plugin *ph, - const char *format, ...); - void (*xchat_command) (xchat_plugin *ph, - const char *command); - void (*xchat_commandf) (xchat_plugin *ph, - const char *format, ...); - int (*xchat_nickcmp) (xchat_plugin *ph, - const char *s1, - const char *s2); - int (*xchat_set_context) (xchat_plugin *ph, - xchat_context *ctx); - xchat_context *(*xchat_find_context) (xchat_plugin *ph, - const char *servname, - const char *channel); - xchat_context *(*xchat_get_context) (xchat_plugin *ph); - const char *(*xchat_get_info) (xchat_plugin *ph, - const char *id); - int (*xchat_get_prefs) (xchat_plugin *ph, - const char *name, - const char **string, - int *integer); - xchat_list * (*xchat_list_get) (xchat_plugin *ph, - const char *name); - void (*xchat_list_free) (xchat_plugin *ph, - xchat_list *xlist); - const char * const * (*xchat_list_fields) (xchat_plugin *ph, - const char *name); - int (*xchat_list_next) (xchat_plugin *ph, - xchat_list *xlist); - const char * (*xchat_list_str) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - int (*xchat_list_int) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - void * (*xchat_plugingui_add) (xchat_plugin *ph, - const char *filename, - const char *name, - const char *desc, - const char *version, - char *reserved); - void (*xchat_plugingui_remove) (xchat_plugin *ph, - void *handle); - int (*xchat_emit_print) (xchat_plugin *ph, - const char *event_name, ...); - int (*xchat_read_fd) (xchat_plugin *ph, - void *src, - char *buf, - int *len); - time_t (*xchat_list_time) (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - char *(*xchat_gettext) (xchat_plugin *ph, - const char *msgid); - void (*xchat_send_modes) (xchat_plugin *ph, - const char **targets, - int ntargets, - int modes_per_line, - char sign, - char mode); - char *(*xchat_strip) (xchat_plugin *ph, - const char *str, - int len, - int flags); - void (*xchat_free) (xchat_plugin *ph, - void *ptr); - int (*xchat_pluginpref_set_str) (xchat_plugin *ph, - const char *var, - const char *value); - int (*xchat_pluginpref_get_str) (xchat_plugin *ph, - const char *var, - char *dest); - int (*xchat_pluginpref_set_int) (xchat_plugin *ph, - const char *var, - int value); - int (*xchat_pluginpref_get_int) (xchat_plugin *ph, - const char *var); - int (*xchat_pluginpref_delete) (xchat_plugin *ph, - const char *var); - int (*xchat_pluginpref_list) (xchat_plugin *ph, - char *dest); -}; -#endif - - -xchat_hook * -xchat_hook_command (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - const char *help_text, - void *userdata); - -xchat_hook * -xchat_hook_server (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], char *word_eol[], void *user_data), - void *userdata); - -xchat_hook * -xchat_hook_print (xchat_plugin *ph, - const char *name, - int pri, - int (*callback) (char *word[], void *user_data), - void *userdata); - -xchat_hook * -xchat_hook_timer (xchat_plugin *ph, - int timeout, - int (*callback) (void *user_data), - void *userdata); - -xchat_hook * -xchat_hook_fd (xchat_plugin *ph, - int fd, - int flags, - int (*callback) (int fd, int flags, void *user_data), - void *userdata); - -void * -xchat_unhook (xchat_plugin *ph, - xchat_hook *hook); - -void -xchat_print (xchat_plugin *ph, - const char *text); - -void -xchat_printf (xchat_plugin *ph, - const char *format, ...); - -void -xchat_command (xchat_plugin *ph, - const char *command); - -void -xchat_commandf (xchat_plugin *ph, - const char *format, ...); - -int -xchat_nickcmp (xchat_plugin *ph, - const char *s1, - const char *s2); - -int -xchat_set_context (xchat_plugin *ph, - xchat_context *ctx); - -xchat_context * -xchat_find_context (xchat_plugin *ph, - const char *servname, - const char *channel); - -xchat_context * -xchat_get_context (xchat_plugin *ph); - -const char * -xchat_get_info (xchat_plugin *ph, - const char *id); - -int -xchat_get_prefs (xchat_plugin *ph, - const char *name, - const char **string, - int *integer); - -xchat_list * -xchat_list_get (xchat_plugin *ph, - const char *name); - -void -xchat_list_free (xchat_plugin *ph, - xchat_list *xlist); - -const char * const * -xchat_list_fields (xchat_plugin *ph, - const char *name); - -int -xchat_list_next (xchat_plugin *ph, - xchat_list *xlist); - -const char * -xchat_list_str (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - -int -xchat_list_int (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - -time_t -xchat_list_time (xchat_plugin *ph, - xchat_list *xlist, - const char *name); - -void * -xchat_plugingui_add (xchat_plugin *ph, - const char *filename, - const char *name, - const char *desc, - const char *version, - char *reserved); - -void -xchat_plugingui_remove (xchat_plugin *ph, - void *handle); - -int -xchat_emit_print (xchat_plugin *ph, - const char *event_name, ...); - -char * -xchat_gettext (xchat_plugin *ph, - const char *msgid); - -void -xchat_send_modes (xchat_plugin *ph, - const char **targets, - int ntargets, - int modes_per_line, - char sign, - char mode); - -char * -xchat_strip (xchat_plugin *ph, - const char *str, - int len, - int flags); - -void -xchat_free (xchat_plugin *ph, - void *ptr); - -int -xchat_pluginpref_set_str (xchat_plugin *ph, - const char *var, - const char *value); - -int -xchat_pluginpref_get_str (xchat_plugin *ph, - const char *var, - char *dest); - -int -xchat_pluginpref_set_int (xchat_plugin *ph, - const char *var, - int value); -int -xchat_pluginpref_get_int (xchat_plugin *ph, - const char *var); - -int -xchat_pluginpref_delete (xchat_plugin *ph, - const char *var); - -int -xchat_pluginpref_list (xchat_plugin *ph, - char *dest); - -#if !defined(PLUGIN_C) && defined(WIN32) -#ifndef XCHAT_PLUGIN_HANDLE -#define XCHAT_PLUGIN_HANDLE (ph) -#endif -#define xchat_hook_command ((XCHAT_PLUGIN_HANDLE)->xchat_hook_command) -#define xchat_hook_server ((XCHAT_PLUGIN_HANDLE)->xchat_hook_server) -#define xchat_hook_print ((XCHAT_PLUGIN_HANDLE)->xchat_hook_print) -#define xchat_hook_timer ((XCHAT_PLUGIN_HANDLE)->xchat_hook_timer) -#define xchat_hook_fd ((XCHAT_PLUGIN_HANDLE)->xchat_hook_fd) -#define xchat_unhook ((XCHAT_PLUGIN_HANDLE)->xchat_unhook) -#define xchat_print ((XCHAT_PLUGIN_HANDLE)->xchat_print) -#define xchat_printf ((XCHAT_PLUGIN_HANDLE)->xchat_printf) -#define xchat_command ((XCHAT_PLUGIN_HANDLE)->xchat_command) -#define xchat_commandf ((XCHAT_PLUGIN_HANDLE)->xchat_commandf) -#define xchat_nickcmp ((XCHAT_PLUGIN_HANDLE)->xchat_nickcmp) -#define xchat_set_context ((XCHAT_PLUGIN_HANDLE)->xchat_set_context) -#define xchat_find_context ((XCHAT_PLUGIN_HANDLE)->xchat_find_context) -#define xchat_get_context ((XCHAT_PLUGIN_HANDLE)->xchat_get_context) -#define xchat_get_info ((XCHAT_PLUGIN_HANDLE)->xchat_get_info) -#define xchat_get_prefs ((XCHAT_PLUGIN_HANDLE)->xchat_get_prefs) -#define xchat_list_get ((XCHAT_PLUGIN_HANDLE)->xchat_list_get) -#define xchat_list_free ((XCHAT_PLUGIN_HANDLE)->xchat_list_free) -#define xchat_list_fields ((XCHAT_PLUGIN_HANDLE)->xchat_list_fields) -#define xchat_list_str ((XCHAT_PLUGIN_HANDLE)->xchat_list_str) -#define xchat_list_int ((XCHAT_PLUGIN_HANDLE)->xchat_list_int) -#define xchat_list_time ((XCHAT_PLUGIN_HANDLE)->xchat_list_time) -#define xchat_list_next ((XCHAT_PLUGIN_HANDLE)->xchat_list_next) -#define xchat_plugingui_add ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_add) -#define xchat_plugingui_remove ((XCHAT_PLUGIN_HANDLE)->xchat_plugingui_remove) -#define xchat_emit_print ((XCHAT_PLUGIN_HANDLE)->xchat_emit_print) -#define xchat_gettext ((XCHAT_PLUGIN_HANDLE)->xchat_gettext) -#define xchat_send_modes ((XCHAT_PLUGIN_HANDLE)->xchat_send_modes) -#define xchat_strip ((XCHAT_PLUGIN_HANDLE)->xchat_strip) -#define xchat_free ((XCHAT_PLUGIN_HANDLE)->xchat_free) -#define xchat_pluginpref_set_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_str) -#define xchat_pluginpref_get_str ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_str) -#define xchat_pluginpref_set_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_set_int) -#define xchat_pluginpref_get_int ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_get_int) -#define xchat_pluginpref_delete ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_delete) -#define xchat_pluginpref_list ((XCHAT_PLUGIN_HANDLE)->xchat_pluginpref_list) -#endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/common/xchat.c b/src/common/xchat.c deleted file mode 100644 index d1916384..00000000 --- a/src/common/xchat.c +++ /dev/null @@ -1,1207 +0,0 @@ -/* X-Chat - * Copyright (C) 1998 Peter Zelezny. - * - * 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 2 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -#include -#include -#include -#include -#include -#include - -#define WANTSOCKET -#include "inet.h" - -#ifdef WIN32 -#include -#else -#include -#include -#include -#endif - -#include "xchat.h" -#include "fe.h" -#include "util.h" -#include "cfgfiles.h" -#include "chanopt.h" -#include "ignore.h" -#include "xchat-plugin.h" -#include "plugin.h" -#include "plugin-timer.h" -#include "notify.h" -#include "server.h" -#include "servlist.h" -#include "outbound.h" -#include "text.h" -#include "url.h" -#include "xchatc.h" - -#ifdef USE_OPENSSL -#include /* SSL_() */ -#include "ssl.h" -#endif - -#ifdef USE_MSPROXY -#include "msproxy.h" -#endif - -#ifdef USE_LIBPROXY -#include -#endif - -GSList *popup_list = 0; -GSList *button_list = 0; -GSList *dlgbutton_list = 0; -GSList *command_list = 0; -GSList *ctcp_list = 0; -GSList *replace_list = 0; -GSList *sess_list = 0; -GSList *dcc_list = 0; -GSList *ignore_list = 0; -GSList *usermenu_list = 0; -GSList *urlhandler_list = 0; -GSList *tabmenu_list = 0; - -static int in_xchat_exit = FALSE; -int xchat_is_quitting = FALSE; -/* command-line args */ -int arg_dont_autoconnect = FALSE; -int arg_skip_plugins = FALSE; -char *arg_url = NULL; -char *arg_command = NULL; -gint arg_existing = FALSE; - -#ifdef USE_DBUS -#include "dbus/dbus-client.h" -#include "dbus/dbus-plugin.h" -#endif /* USE_DBUS */ - -struct session *current_tab; -struct session *current_sess = 0; -struct hexchatprefs prefs; - -#ifdef USE_OPENSSL -SSL_CTX *ctx = NULL; -#endif - -#ifdef USE_LIBPROXY -pxProxyFactory *libproxy_factory; -#endif - -int -is_session (session * sess) -{ - return g_slist_find (sess_list, sess) ? 1 : 0; -} - -session * -find_dialog (server *serv, char *nick) -{ - GSList *list = sess_list; - session *sess; - - while (list) - { - sess = list->data; - if (sess->server == serv && sess->type == SESS_DIALOG) - { - if (!serv->p_cmp (nick, sess->channel)) - return (sess); - } - list = list->next; - } - return 0; -} - -session * -find_channel (server *serv, char *chan) -{ - session *sess; - GSList *list = sess_list; - while (list) - { - sess = list->data; - if ((!serv || serv == sess->server) && sess->type != SESS_DIALOG) - { - if (!serv->p_cmp (chan, sess->channel)) - return sess; - } - list = list->next; - } - return 0; -} - -static void -lagcheck_update (void) -{ - server *serv; - GSList *list = serv_list; - - if (!prefs.hex_gui_lagometer) - return; - - while (list) - { - serv = list->data; - if (serv->lag_sent) - fe_set_lag (serv, -1); - - list = list->next; - } -} - -void -lag_check (void) -{ - server *serv; - GSList *list = serv_list; - unsigned long tim; - char tbuf[128]; - time_t now = time (0); - int lag; - - tim = make_ping_time (); - - while (list) - { - serv = list->data; - if (serv->connected && serv->end_of_motd) - { - lag = now - serv->ping_recv; - if (prefs.hex_net_ping_timeout && lag > prefs.hex_net_ping_timeout && lag > 0) - { - sprintf (tbuf, "%d", lag); - EMIT_SIGNAL (XP_TE_PINGTIMEOUT, serv->server_session, tbuf, NULL, - NULL, NULL, 0); - if (prefs.hex_net_auto_reconnect) - serv->auto_reconnect (serv, FALSE, -1); - } else - { - snprintf (tbuf, sizeof (tbuf), "LAG%lu", tim); - serv->p_ping (serv, "", tbuf); - serv->lag_sent = tim; - fe_set_lag (serv, -1); - } - } - list = list->next; - } -} - -static int -away_check (void) -{ - session *sess; - GSList *list; - int full, sent, loop = 0; - - if (!prefs.hex_away_track || prefs.hex_away_size_max < 1) - return 1; - -doover: - /* request an update of AWAY status of 1 channel every 30 seconds */ - full = TRUE; - sent = 0; /* number of WHOs (users) requested */ - list = sess_list; - while (list) - { - sess = list->data; - - if (sess->server->connected && - sess->type == SESS_CHANNEL && - sess->channel[0] && - sess->total <= prefs.hex_away_size_max) - { - if (!sess->done_away_check) - { - full = FALSE; - - /* if we're under 31 WHOs, send another channels worth */ - if (sent < 31 && !sess->doing_who) - { - sess->done_away_check = TRUE; - sess->doing_who = TRUE; - /* this'll send a WHO #channel */ - sess->server->p_away_status (sess->server, sess->channel); - sent += sess->total; - } - } - } - - list = list->next; - } - - /* done them all, reset done_away_check to FALSE and start over */ - if (full) - { - list = sess_list; - while (list) - { - sess = list->data; - sess->done_away_check = FALSE; - list = list->next; - } - loop++; - if (loop < 2) - goto doover; - } - - return 1; -} - -static int -xchat_misc_checks (void) /* this gets called every 1/2 second */ -{ - static int count = 0; -#ifdef USE_MSPROXY - static int count2 = 0; -#endif - - count++; - - lagcheck_update (); /* every 500ms */ - - if (count % 2) - dcc_check_timeouts (); /* every 1 second */ - - if (count >= 60) /* every 30 seconds */ - { - if (prefs.hex_gui_lagometer) - lag_check (); - count = 0; - } - -#ifdef USE_MSPROXY - count2++; - if (count2 >= 720) /* 720 every 6 minutes */ - { - msproxy_keepalive (); - count2 = 0; - } -#endif - - return 1; -} - -/* executed when the first irc window opens */ - -static void -irc_init (session *sess) -{ - static int done_init = FALSE; - char buf[512]; - - if (done_init) - return; - - done_init = TRUE; - - plugin_add (sess, NULL, NULL, timer_plugin_init, NULL, NULL, FALSE); - -#ifdef USE_PLUGIN - if (!arg_skip_plugins) - plugin_auto_load (sess); /* autoload ~/.xchat *.so */ -#endif - -#ifdef USE_DBUS - plugin_add (sess, NULL, NULL, dbus_plugin_init, NULL, NULL, FALSE); -#endif - - if (prefs.hex_notify_timeout) - notify_tag = fe_timeout_add (prefs.hex_notify_timeout * 1000, - notify_checklist, 0); - - fe_timeout_add (prefs.hex_away_timeout * 1000, away_check, 0); - fe_timeout_add (500, xchat_misc_checks, 0); - - if (arg_url != NULL) - { - snprintf (buf, sizeof (buf), "server %s", arg_url); - handle_command (sess, buf, FALSE); - g_free (arg_url); /* from GOption */ - } - - if (arg_command != NULL) - { - g_free (arg_command); - } - - /* load -e ~/.xchat2/startup.txt */ - snprintf (buf, sizeof (buf), "%s/%s", get_xdir_fs (), "startup.txt"); - load_perform_file (sess, buf); -} - -static session * -session_new (server *serv, char *from, int type, int focus) -{ - session *sess; - - sess = malloc (sizeof (struct session)); - if (sess == NULL) - { - return NULL; - } - memset (sess, 0, sizeof (struct session)); - - sess->server = serv; - sess->logfd = -1; - sess->scrollfd = -1; - sess->type = type; - - sess->alert_beep = SET_DEFAULT; - sess->alert_taskbar = SET_DEFAULT; - sess->alert_tray = SET_DEFAULT; - - sess->text_hidejoinpart = SET_DEFAULT; - sess->text_logging = SET_DEFAULT; - sess->text_scrollback = SET_DEFAULT; - - if (from != NULL) - safe_strcpy (sess->channel, from, CHANLEN); - - sess_list = g_slist_prepend (sess_list, sess); - - fe_new_window (sess, focus); - - return sess; -} - -session * -new_ircwindow (server *serv, char *name, int type, int focus) -{ - session *sess; - - switch (type) - { - case SESS_SERVER: - serv = server_new (); - if (prefs.hex_gui_tab_server) - sess = session_new (serv, name, SESS_SERVER, focus); - else - sess = session_new (serv, name, SESS_CHANNEL, focus); - serv->server_session = sess; - serv->front_session = sess; - break; - case SESS_DIALOG: - sess = session_new (serv, name, type, focus); - log_open_or_close (sess); - break; - default: -/* case SESS_CHANNEL: - case SESS_NOTICES: - case SESS_SNOTICES:*/ - sess = session_new (serv, name, type, focus); - break; - } - - irc_init (sess); - scrollback_load (sess); - chanopt_load (sess); - plugin_emit_dummy_print (sess, "Open Context"); - - return sess; -} - -static void -exec_notify_kill (session * sess) -{ -#ifndef WIN32 - struct nbexec *re; - if (sess->running_exec != NULL) - { - re = sess->running_exec; - sess->running_exec = NULL; - kill (re->childpid, SIGKILL); - waitpid (re->childpid, NULL, WNOHANG); - fe_input_remove (re->iotag); - close (re->myfd); - if (re->linebuf) - free(re->linebuf); - free (re); - } -#endif -} - -static void -send_quit_or_part (session * killsess) -{ - int willquit = TRUE; - GSList *list; - session *sess; - server *killserv = killsess->server; - - /* check if this is the last session using this server */ - list = sess_list; - while (list) - { - sess = (session *) list->data; - if (sess->server == killserv && sess != killsess) - { - willquit = FALSE; - list = 0; - } else - list = list->next; - } - - if (xchat_is_quitting) - willquit = TRUE; - - if (killserv->connected) - { - if (willquit) - { - if (!killserv->sent_quit) - { - killserv->flush_queue (killserv); - server_sendquit (killsess); - killserv->sent_quit = TRUE; - } - } else - { - if (killsess->type == SESS_CHANNEL && killsess->channel[0] && - !killserv->sent_quit) - { - server_sendpart (killserv, killsess->channel, 0); - } - } - } -} - -void -session_free (session *killsess) -{ - server *killserv = killsess->server; - session *sess; - GSList *list; - - plugin_emit_dummy_print (killsess, "Close Context"); - - if (current_tab == killsess) - current_tab = NULL; - - if (killserv->server_session == killsess) - killserv->server_session = NULL; - - if (killserv->front_session == killsess) - { - /* front_session is closed, find a valid replacement */ - killserv->front_session = NULL; - list = sess_list; - while (list) - { - sess = (session *) list->data; - if (sess != killsess && sess->server == killserv) - { - killserv->front_session = sess; - if (!killserv->server_session) - killserv->server_session = sess; - break; - } - list = list->next; - } - } - - if (!killserv->server_session) - killserv->server_session = killserv->front_session; - - sess_list = g_slist_remove (sess_list, killsess); - - if (killsess->type == SESS_CHANNEL) - userlist_free (killsess); - - exec_notify_kill (killsess); - - log_close (killsess); - scrollback_close (killsess); - chanopt_save (killsess); - - send_quit_or_part (killsess); - - history_free (&killsess->history); - if (killsess->topic) - free (killsess->topic); - if (killsess->current_modes) - free (killsess->current_modes); - - fe_session_callback (killsess); - - if (current_sess == killsess) - { - current_sess = NULL; - if (sess_list) - current_sess = sess_list->data; - } - - free (killsess); - - if (!sess_list && !in_xchat_exit) - xchat_exit (); /* sess_list is empty, quit! */ - - list = sess_list; - while (list) - { - sess = (session *) list->data; - if (sess->server == killserv) - return; /* this server is still being used! */ - list = list->next; - } - - server_free (killserv); -} - -static void -free_sessions (void) -{ - GSList *list = sess_list; - - while (list) - { - fe_close_window (list->data); - list = sess_list; - } -} - - -static char defaultconf_ctcp[] = - "NAME TIME\n" "CMD nctcp %s TIME %t\n\n"\ - "NAME PING\n" "CMD nctcp %s PING %d\n\n"; - -static char defaultconf_replace[] = - "NAME teh\n" "CMD the\n\n"; -/* "NAME r\n" "CMD are\n\n"\ - "NAME u\n" "CMD you\n\n"*/ - -static char defaultconf_commands[] = - "NAME ACTION\n" "CMD me &2\n\n"\ - "NAME AME\n" "CMD allchan me &2\n\n"\ - "NAME ANICK\n" "CMD allserv nick &2\n\n"\ - "NAME AMSG\n" "CMD allchan say &2\n\n"\ - "NAME BANLIST\n" "CMD quote MODE %c +b\n\n"\ - "NAME CHAT\n" "CMD dcc chat %2\n\n"\ - "NAME DIALOG\n" "CMD query %2\n\n"\ - "NAME DMSG\n" "CMD msg =%2 &3\n\n"\ - "NAME EXIT\n" "CMD quit\n\n"\ - "NAME GREP\n" "CMD lastlog -r -- &2\n\n"\ - "NAME IGNALL\n" "CMD ignore %2!*@* ALL\n\n"\ - "NAME J\n" "CMD join &2\n\n"\ - "NAME KILL\n" "CMD quote KILL %2 :&3\n\n"\ - "NAME LEAVE\n" "CMD part &2\n\n"\ - "NAME M\n" "CMD msg &2\n\n"\ - "NAME ONOTICE\n" "CMD notice @%c &2\n\n"\ - "NAME RAW\n" "CMD quote &2\n\n"\ - "NAME SERVHELP\n" "CMD quote HELP\n\n"\ - "NAME SPING\n" "CMD ping\n\n"\ - "NAME SQUERY\n" "CMD quote SQUERY %2 :&3\n\n"\ - "NAME SSLSERVER\n" "CMD server -ssl &2\n\n"\ - "NAME SV\n" "CMD echo xchat %v %m\n\n"\ - "NAME UMODE\n" "CMD mode %n &2\n\n"\ - "NAME UPTIME\n" "CMD quote STATS u\n\n"\ - "NAME VER\n" "CMD ctcp %2 VERSION\n\n"\ - "NAME VERSION\n" "CMD ctcp %2 VERSION\n\n"\ - "NAME WALLOPS\n" "CMD quote WALLOPS :&2\n\n"\ - "NAME WII\n" "CMD quote WHOIS %2 %2\n\n"; - -static char defaultconf_urlhandlers[] = - "NAME Open Link in Opera\n" "CMD !opera -remote 'openURL(%s)'\n\n"; - -#ifdef USE_SIGACTION -/* Close and open log files on SIGUSR1. Usefull for log rotating */ - -static void -sigusr1_handler (int signal, siginfo_t *si, void *un) -{ - GSList *list = sess_list; - session *sess; - - while (list) - { - sess = list->data; - log_open_or_close (sess); - list = list->next; - } -} - -/* Execute /SIGUSR2 when SIGUSR2 received */ - -static void -sigusr2_handler (int signal, siginfo_t *si, void *un) -{ - session *sess = current_sess; - - if (sess) - handle_command (sess, "SIGUSR2", FALSE); -} -#endif - -static gint -xchat_auto_connect (gpointer userdata) -{ - servlist_auto_connect (NULL); - return 0; -} - -static void -xchat_init (void) -{ - char buf[3068]; - const char *cs = NULL; - -#ifdef WIN32 - WSADATA wsadata; - -#ifdef USE_IPV6 - if (WSAStartup(0x0202, &wsadata) != 0) - { - MessageBox (NULL, "Cannot find winsock 2.2+", "Error", MB_OK); - exit (0); - } -#else - WSAStartup(0x0101, &wsadata); -#endif /* !USE_IPV6 */ -#endif /* !WIN32 */ - -#ifdef USE_SIGACTION - struct sigaction act; - - /* ignore SIGPIPE's */ - act.sa_handler = SIG_IGN; - act.sa_flags = 0; - sigemptyset (&act.sa_mask); - sigaction (SIGPIPE, &act, NULL); - - /* Deal with SIGUSR1's & SIGUSR2's */ - act.sa_sigaction = sigusr1_handler; - act.sa_flags = 0; - sigemptyset (&act.sa_mask); - sigaction (SIGUSR1, &act, NULL); - - act.sa_sigaction = sigusr2_handler; - act.sa_flags = 0; - sigemptyset (&act.sa_mask); - sigaction (SIGUSR2, &act, NULL); -#else -#ifndef WIN32 - /* good enough for these old systems */ - signal (SIGPIPE, SIG_IGN); -#endif -#endif - - if (g_get_charset (&cs)) - prefs.utf8_locale = TRUE; - - load_text_events (); - sound_load (); - notify_load (); - ignore_load (); - - snprintf (buf, sizeof (buf), - "NAME %s~%s~\n" "CMD query %%s\n\n"\ - "NAME %s~%s~\n" "CMD send %%s\n\n"\ - "NAME %s~%s~\n" "CMD whois %%s %%s\n\n"\ - "NAME %s~%s~\n" "CMD notify -n ASK %%s\n\n"\ - "NAME %s~%s~\n" "CMD ignore %%s!*@* ALL\n\n"\ - - "NAME SUB\n" "CMD %s\n\n"\ - "NAME %s\n" "CMD op %%a\n\n"\ - "NAME %s\n" "CMD deop %%a\n\n"\ - "NAME SEP\n" "CMD \n\n"\ - "NAME %s\n" "CMD voice %%a\n\n"\ - "NAME %s\n" "CMD devoice %%a\n"\ - "NAME SEP\n" "CMD \n\n"\ - "NAME SUB\n" "CMD %s\n\n"\ - "NAME %s\n" "CMD kick %%s\n\n"\ - "NAME %s\n" "CMD ban %%s\n\n"\ - "NAME SEP\n" "CMD \n\n"\ - "NAME %s *!*@*.host\n""CMD ban %%s 0\n\n"\ - "NAME %s *!*@domain\n""CMD ban %%s 1\n\n"\ - "NAME %s *!*user@*.host\n""CMD ban %%s 2\n\n"\ - "NAME %s *!*user@domain\n""CMD ban %%s 3\n\n"\ - "NAME SEP\n" "CMD \n\n"\ - "NAME %s *!*@*.host\n""CMD kickban %%s 0\n\n"\ - "NAME %s *!*@domain\n""CMD kickban %%s 1\n\n"\ - "NAME %s *!*user@*.host\n""CMD kickban %%s 2\n\n"\ - "NAME %s *!*user@domain\n""CMD kickban %%s 3\n\n"\ - "NAME ENDSUB\n" "CMD \n\n"\ - "NAME ENDSUB\n" "CMD \n\n", - - _("_Open Dialog Window"), "gtk-go-up", - _("_Send a File"), "gtk-floppy", - _("_User Info (WhoIs)"), "gtk-info", - _("_Add to Friends List"), "gtk-add", - _("_Ignore"), "gtk-stop", - _("O_perator Actions"), - - _("Give Ops"), - _("Take Ops"), - _("Give Voice"), - _("Take Voice"), - - _("Kick/Ban"), - _("Kick"), - _("Ban"), - _("Ban"), - _("Ban"), - _("Ban"), - _("Ban"), - _("KickBan"), - _("KickBan"), - _("KickBan"), - _("KickBan")); - - list_loadconf ("popup.conf", &popup_list, buf); - - snprintf (buf, sizeof (buf), - "NAME %s\n" "CMD part\n\n" - "NAME %s\n" "CMD getstr # join \"%s\"\n\n" - "NAME %s\n" "CMD quote LINKS\n\n" - "NAME %s\n" "CMD ping\n\n" - "NAME TOGGLE %s\n" "CMD irc_hide_version\n\n", - _("Leave Channel"), - _("Join Channel..."), - _("Enter Channel to Join:"), - _("Server Links"), - _("Ping Server"), - _("Hide Version")); - list_loadconf ("usermenu.conf", &usermenu_list, buf); - - snprintf (buf, sizeof (buf), - "NAME %s\n" "CMD op %%a\n\n" - "NAME %s\n" "CMD deop %%a\n\n" - "NAME %s\n" "CMD ban %%s\n\n" - "NAME %s\n" "CMD getstr \"%s\" \"kick %%s\" \"%s\"\n\n" - "NAME %s\n" "CMD send %%s\n\n" - "NAME %s\n" "CMD query %%s\n\n", - _("Op"), - _("DeOp"), - _("Ban"), - _("Kick"), - _("bye"), - _("Enter reason to kick %s:"), - _("Sendfile"), - _("Dialog")); - list_loadconf ("buttons.conf", &button_list, buf); - - snprintf (buf, sizeof (buf), - "NAME %s\n" "CMD whois %%s %%s\n\n" - "NAME %s\n" "CMD send %%s\n\n" - "NAME %s\n" "CMD dcc chat %%s\n\n" - "NAME %s\n" "CMD clear\n\n" - "NAME %s\n" "CMD ping %%s\n\n", - _("WhoIs"), - _("Send"), - _("Chat"), - _("Clear"), - _("Ping")); - list_loadconf ("dlgbuttons.conf", &dlgbutton_list, buf); - - list_loadconf ("tabmenu.conf", &tabmenu_list, NULL); - list_loadconf ("ctcpreply.conf", &ctcp_list, defaultconf_ctcp); - list_loadconf ("commands.conf", &command_list, defaultconf_commands); - list_loadconf ("replace.conf", &replace_list, defaultconf_replace); - list_loadconf ("urlhandlers.conf", &urlhandler_list, - defaultconf_urlhandlers); - - servlist_init (); /* load server list */ - - /* if we got a URL, don't open the server list GUI */ - if (!prefs.hex_gui_slist_skip && !arg_url) - fe_serverlist_open (NULL); - - /* turned OFF via -a arg */ - if (!arg_dont_autoconnect) - { - /* do any auto connects */ - if (!servlist_have_auto ()) /* if no new windows open .. */ - { - /* and no serverlist gui ... */ - if (prefs.hex_gui_slist_skip || arg_url) - /* we'll have to open one. */ - new_ircwindow (NULL, NULL, SESS_SERVER, 0); - } else - { - fe_idle_add (xchat_auto_connect, NULL); - } - } else - { - if (prefs.hex_gui_slist_skip || arg_url) - new_ircwindow (NULL, NULL, SESS_SERVER, 0); - } -} - -void -xchat_exit (void) -{ - xchat_is_quitting = TRUE; - in_xchat_exit = TRUE; - plugin_kill_all (); - fe_cleanup (); - - save_config (); - if (prefs.save_pevents) - { - pevent_save (NULL); - } - - sound_save (); - notify_save (); - ignore_save (); - free_sessions (); - chanopt_save_all (); - servlist_cleanup (); - fe_exit (); -} - -#ifndef WIN32 - -static int -child_handler (gpointer userdata) -{ - int pid = GPOINTER_TO_INT (userdata); - - if (waitpid (pid, 0, WNOHANG) == pid) - return 0; /* remove timeout handler */ - return 1; /* keep the timeout handler */ -} - -#endif - -void -xchat_exec (const char *cmd) -{ -#ifdef WIN32 - util_exec (cmd); -#else - int pid = util_exec (cmd); - if (pid != -1) - /* zombie avoiding system. Don't ask! it has to be like this to work - with zvt (which overrides the default handler) */ - fe_timeout_add (1000, child_handler, GINT_TO_POINTER (pid)); -#endif -} - -void -xchat_execv (char * const argv[]) -{ -#ifdef WIN32 - util_execv (argv); -#else - int pid = util_execv (argv); - if (pid != -1) - /* zombie avoiding system. Don't ask! it has to be like this to work - with zvt (which overrides the default handler) */ - fe_timeout_add (1000, child_handler, GINT_TO_POINTER (pid)); -#endif -} - -#ifdef WIN32 -static void -xchat_restore_window (HWND xchat_window) -{ - /* ShowWindow (xchat_window, SW_RESTORE); another way, but works worse */ - SendMessage (xchat_window, WM_SYSCOMMAND, SC_RESTORE, 0); - SetForegroundWindow (xchat_window); -} - -BOOL CALLBACK -enum_windows_impl (HWND current_window, LPARAM lParam) -{ - TCHAR window_name[8]; - TCHAR module_path[1024]; - ZeroMemory (&window_name, sizeof (window_name)); - - if (!current_window) - { - return TRUE; - } - - GetWindowText (current_window, window_name, 8); /* name length + 1 */ - if (strcmp (window_name, "HexChat") == 0) - { - /* use a separate if block, this way we don't have to call GetWindowModuleFileName() for each hit */ - ZeroMemory (&module_path, sizeof (module_path)); - GetWindowModuleFileName (current_window, module_path, sizeof (module_path)); - - if (strstr (module_path, "hexchat.exe")) /* We've found it, stop */ - { - xchat_restore_window (current_window); - return FALSE; - } - } - - return TRUE; /* Keep searching */ - -} -#endif - -int -main (int argc, char *argv[]) -{ - int ret; - -#ifdef WIN32 - char hexchat_lang[13]; /* LC_ALL= plus 5 chars of hex_gui_lang and trailing \0 */ - HANDLE mutex; -#endif - - srand (time (0)); /* CL: do this only once! */ - - load_config (); - -#ifdef WIN32 - /* we MUST do this after load_config () AND before fe_init (thus gtk_init) otherwise it will fail */ - strcpy (hexchat_lang, "LC_ALL="); - - /* this must be ordered EXACTLY as langsmenu[] */ - switch (prefs.hex_gui_lang) - { - case 0: - strcat (hexchat_lang, "af"); - break; - case 1: - strcat (hexchat_lang, "sq"); - break; - case 2: - strcat (hexchat_lang, "am"); - break; - case 3: - strcat (hexchat_lang, "ast"); - break; - case 4: - strcat (hexchat_lang, "az"); - break; - case 5: - strcat (hexchat_lang, "eu"); - break; - case 6: - strcat (hexchat_lang, "be"); - break; - case 7: - strcat (hexchat_lang, "bg"); - break; - case 8: - strcat (hexchat_lang, "ca"); - break; - case 9: - strcat (hexchat_lang, "zh_CN"); - break; - case 10: - strcat (hexchat_lang, "zh_TW"); - break; - case 11: - strcat (hexchat_lang, "cs"); - break; - case 12: - strcat (hexchat_lang, "da"); - break; - case 13: - strcat (hexchat_lang, "nl"); - break; - case 14: - strcat (hexchat_lang, "en_GB"); - break; - case 15: - strcat (hexchat_lang, "en"); - break; - case 16: - strcat (hexchat_lang, "et"); - break; - case 17: - strcat (hexchat_lang, "fi"); - break; - case 18: - strcat (hexchat_lang, "fr"); - break; - case 19: - strcat (hexchat_lang, "gl"); - break; - case 20: - strcat (hexchat_lang, "de"); - break; - case 21: - strcat (hexchat_lang, "el"); - break; - case 22: - strcat (hexchat_lang, "gu"); - break; - case 23: - strcat (hexchat_lang, "hi"); - break; - case 24: - strcat (hexchat_lang, "hu"); - break; - case 25: - strcat (hexchat_lang, "id"); - break; - case 26: - strcat (hexchat_lang, "it"); - break; - case 27: - strcat (hexchat_lang, "ja"); - break; - case 28: - strcat (hexchat_lang, "kn"); - break; - case 29: - strcat (hexchat_lang, "rw"); - break; - case 30: - strcat (hexchat_lang, "ko"); - break; - case 31: - strcat (hexchat_lang, "lv"); - break; - case 32: - strcat (hexchat_lang, "lt"); - break; - case 33: - strcat (hexchat_lang, "mk"); - break; - case 34: - strcat (hexchat_lang, "ml"); - break; - case 35: - strcat (hexchat_lang, "ms"); - break; - case 36: - strcat (hexchat_lang, "nb"); - break; - case 37: - strcat (hexchat_lang, "no"); - break; - case 38: - strcat (hexchat_lang, "pl"); - break; - case 39: - strcat (hexchat_lang, "pt"); - break; - case 40: - strcat (hexchat_lang, "pt_BR"); - break; - case 41: - strcat (hexchat_lang, "pa"); - break; - case 42: - strcat (hexchat_lang, "ru"); - break; - case 43: - strcat (hexchat_lang, "sr"); - break; - case 44: - strcat (hexchat_lang, "sk"); - break; - case 45: - strcat (hexchat_lang, "sl"); - break; - case 46: - strcat (hexchat_lang, "es"); - break; - case 47: - strcat (hexchat_lang, "sv"); - break; - case 48: - strcat (hexchat_lang, "th"); - break; - case 49: - strcat (hexchat_lang, "uk"); - break; - case 50: - strcat (hexchat_lang, "vi"); - break; - case 51: - strcat (hexchat_lang, "wa"); - break; - default: - strcat (hexchat_lang, "en"); - break; - } - - putenv (hexchat_lang); - - if (prefs.hex_gui_single && !portable_mode ()) - { - DWORD error; - - mutex = CreateMutex (NULL, TRUE, "Local\\hexchat"); - error = GetLastError (); - - if (error == ERROR_ALREADY_EXISTS || mutex == NULL) - { - /* restoring the XChat window from the tray via the taskbar icon - * only works correctly when X-Tray is used, but it's not a big deal - * since you can only minimize XChat to tray via the taskbar if you - * use X-Tray*/ - if (hextray_mode ()) - { - /* FindWindow() doesn't support wildcards so we check all the open windows */ - EnumWindows (enum_windows_impl, NULL); - return 0; - } - else - { - return 1; - } - } - } -#endif - -#ifdef SOCKS - SOCKSinit (argv[0]); -#endif - - ret = fe_args (argc, argv); - if (ret != -1) - return ret; - -#ifdef USE_DBUS - xchat_remote (); -#endif - -#ifdef USE_LIBPROXY - libproxy_factory = px_proxy_factory_new(); -#endif - - fe_init (); - - xchat_init (); - - fe_main (); - -#ifdef USE_LIBPROXY - px_proxy_factory_free(libproxy_factory); -#endif - -#ifdef USE_OPENSSL - if (ctx) - _SSL_context_free (ctx); -#endif - -#ifdef USE_DEBUG - xchat_mem_list (); -#endif - -#ifdef WIN32 - WSACleanup (); - - if (prefs.hex_gui_single && !portable_mode ()) - { - ReleaseMutex (mutex); - CloseHandle (mutex); - } -#endif - - return 0; -} diff --git a/src/common/xchat.h b/src/common/xchat.h deleted file mode 100644 index 2980fc1c..00000000 --- a/src/common/xchat.h +++ /dev/null @@ -1,595 +0,0 @@ -#include "../../config.h" - -#include -#include /* need time_t */ - -#ifndef XCHAT_H -#define XCHAT_H - -#include "history.h" - -#ifndef HAVE_SNPRINTF -#define snprintf g_snprintf -#endif - -#ifndef HAVE_VSNPRINTF -#define vsnprintf _vsnprintf -#endif - -#ifdef USE_DEBUG -#define malloc(n) xchat_malloc(n, __FILE__, __LINE__) -#define realloc(n, m) xchat_realloc(n, m, __FILE__, __LINE__) -#define free(n) xchat_dfree(n, __FILE__, __LINE__) -#define strdup(n) xchat_strdup(n, __FILE__, __LINE__) -void *xchat_malloc (int size, char *file, int line); -void *xchat_strdup (char *str, char *file, int line); -void xchat_dfree (void *buf, char *file, int line); -void *xchat_realloc (char *old, int len, char *file, int line); -#endif - -#ifdef SOCKS -#ifdef __sgi -#include -#define INCLUDE_PROTOTYPES 1 -#endif -#include -#endif - -#ifdef USE_OPENSSL -#include /* SSL_() */ -#endif - -#ifdef __EMX__ /* for o/s 2 */ -#define OFLAGS O_BINARY -#define g_ascii_strcasecmp stricmp -#define g_ascii_strncasecmp strnicmp -#define PATH_MAX MAXPATHLEN -#define FILEPATH_LEN_MAX MAXPATHLEN -#endif - -/* force a 32bit CMP.L */ -#define CMPL(a, c0, c1, c2, c3) (a == (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24))) -#define WORDL(c0, c1, c2, c3) (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24)) -#define WORDW(c0, c1) (guint16)(c0 | (c1 << 8)) - -#ifdef WIN32 /* for win32 */ -#define OFLAGS O_BINARY -#define sleep(t) Sleep(t*1000) -#include -#define F_OK 0 -#define X_OK 1 -#define W_OK 2 -#define R_OK 4 -#ifndef S_ISDIR -#define S_ISDIR(m) ((m) & _S_IFDIR) -#endif -#define NETWORK_PRIVATE -#else /* for unix */ -#define OFLAGS 0 -#endif - -#define FONTNAMELEN 127 -#define PATHLEN 255 -#define DOMAINLEN 100 -#define NICKLEN 64 /* including the NULL, so 63 really */ -#define CHANLEN 300 -#define PDIWORDS 32 -#define USERNAMELEN 10 -#define HIDDEN_CHAR 8 /* invisible character for xtext */ - -#if defined(ENABLE_NLS) && !defined(_) -# include -# define _(x) gettext(x) -# ifdef gettext_noop -# define N_(String) gettext_noop (String) -# else -# define N_(String) (String) -# endif -#endif -#if !defined(_) -# define N_(String) (String) -# define _(x) (x) -#endif - -struct nbexec -{ - int myfd; - int childpid; - int tochannel; /* making this int keeps the struct 4-byte aligned */ - int iotag; - char *linebuf; - int buffill; - struct session *sess; -}; - -struct hexchatprefs -{ - /* these are the rebranded, consistent, sorted hexchat variables */ - - /* BOOLEANS */ - unsigned int hex_away_auto_unmark; - unsigned int hex_away_omit_alerts; - unsigned int hex_away_show_message; - unsigned int hex_away_show_once; - unsigned int hex_away_track; - unsigned int hex_completion_auto; - unsigned int hex_dcc_auto_chat; - unsigned int hex_dcc_auto_resume; - unsigned int hex_dcc_fast_send; - unsigned int hex_dcc_ip_from_server; - unsigned int hex_dcc_remove; - unsigned int hex_dcc_save_nick; - unsigned int hex_dcc_send_fillspaces; - unsigned int hex_gui_autoopen_chat; - unsigned int hex_gui_autoopen_dialog; - unsigned int hex_gui_autoopen_recv; - unsigned int hex_gui_autoopen_send; - unsigned int hex_gui_compact; - unsigned int hex_gui_hide_menu; - unsigned int hex_gui_input_nick; - unsigned int hex_gui_input_spell; - unsigned int hex_gui_input_style; - unsigned int hex_gui_join_dialog; - unsigned int hex_gui_mode_buttons; - unsigned int hex_gui_quit_dialog; - unsigned int hex_gui_single; - unsigned int hex_gui_slist_fav; - unsigned int hex_gui_slist_skip; - unsigned int hex_gui_tab_chans; - unsigned int hex_gui_tab_dialogs; - unsigned int hex_gui_tab_dots; - unsigned int hex_gui_tab_icons; - unsigned int hex_gui_tab_notices; - unsigned int hex_gui_tab_server; - unsigned int hex_gui_tab_sort; - unsigned int hex_gui_tab_utils; - unsigned int hex_gui_topicbar; - unsigned int hex_gui_tray; - unsigned int hex_gui_ulist_buttons; - unsigned int hex_gui_ulist_count; - unsigned int hex_gui_ulist_hide; - unsigned int hex_gui_ulist_icons; - unsigned int hex_gui_ulist_resizable; - unsigned int hex_gui_ulist_show_hosts; - unsigned int hex_gui_ulist_style; - unsigned int hex_gui_usermenu; - unsigned int hex_gui_win_modes; - unsigned int hex_gui_win_save; - unsigned int hex_gui_win_swap; - unsigned int hex_gui_win_ucount; - unsigned int hex_identd; - unsigned int hex_input_balloon_chans; - unsigned int hex_input_balloon_hilight; - unsigned int hex_input_balloon_priv; - unsigned int hex_input_beep_chans; - unsigned int hex_input_beep_hilight; - unsigned int hex_input_beep_priv; - unsigned int hex_input_filter_beep; - unsigned int hex_input_flash_chans; - unsigned int hex_input_flash_hilight; - unsigned int hex_input_flash_priv; - unsigned int hex_input_perc_ascii; - unsigned int hex_input_perc_color; - unsigned int hex_input_tray_chans; - unsigned int hex_input_tray_hilight; - unsigned int hex_input_tray_priv; - unsigned int hex_irc_auto_rejoin; - unsigned int hex_irc_conf_mode; - unsigned int hex_irc_hide_version; - unsigned int hex_irc_invisible; - unsigned int hex_irc_logging; - unsigned int hex_irc_raw_modes; - unsigned int hex_irc_servernotice; - unsigned int hex_irc_skip_motd; - unsigned int hex_irc_wallops; - unsigned int hex_irc_who_join; - unsigned int hex_irc_whois_front; - unsigned int hex_net_auto_reconnect; - unsigned int hex_net_auto_reconnectonfail; - unsigned int hex_net_proxy_auth; - unsigned int hex_net_throttle; - unsigned int hex_notify_whois_online; - unsigned int hex_perl_warnings; - unsigned int hex_stamp_log; - unsigned int hex_stamp_text; - unsigned int hex_text_autocopy_color; - unsigned int hex_text_autocopy_stamp; - unsigned int hex_text_autocopy_text; - unsigned int hex_text_color_nicks; - unsigned int hex_text_indent; - unsigned int hex_text_replay; - unsigned int hex_text_search_case_match; - unsigned int hex_text_search_backward; - unsigned int hex_text_search_highlight_all; - unsigned int hex_text_search_follow; - unsigned int hex_text_search_regexp; - unsigned int hex_text_show_marker; - unsigned int hex_text_show_sep; - unsigned int hex_text_stripcolor_msg; - unsigned int hex_text_stripcolor_replay; - unsigned int hex_text_stripcolor_topic; - unsigned int hex_text_thin_sep; - unsigned int hex_text_transparent; - unsigned int hex_text_wordwrap; - unsigned int hex_url_grabber; - unsigned int hex_url_logging; - - /* NUMBERS */ - int hex_away_size_max; - int hex_away_timeout; - int hex_completion_amount; - int hex_completion_sort; - int hex_dcc_auto_recv; - int hex_dcc_blocksize; - int hex_dcc_global_max_get_cps; - int hex_dcc_global_max_send_cps; - int hex_dcc_max_get_cps; - int hex_dcc_max_send_cps; - int hex_dcc_permissions; - int hex_dcc_port_first; - int hex_dcc_port_last; - int hex_dcc_stall_timeout; - int hex_dcc_timeout; - int hex_flood_ctcp_num; /* flood */ - int hex_flood_ctcp_time; /* seconds of floods */ - int hex_flood_msg_num; /* same deal */ - int hex_flood_msg_time; - int hex_gui_chanlist_maxusers; - int hex_gui_chanlist_minusers; - int hex_gui_dialog_height; - int hex_gui_dialog_left; - int hex_gui_dialog_top; - int hex_gui_dialog_width; - int hex_gui_lagometer; - int hex_gui_lang; - int hex_gui_pane_left_size; - int hex_gui_pane_right_size; - int hex_gui_pane_right_size_min; - int hex_gui_slist_select; - int hex_gui_tab_layout; - int hex_gui_tab_newtofront; - int hex_gui_tab_pos; - int hex_gui_tab_small; - int hex_gui_tab_trunc; - int hex_gui_throttlemeter; - int hex_gui_tray_flags; - int hex_gui_ulist_pos; - int hex_gui_ulist_sort; - int hex_gui_url_mod; - int hex_gui_win_height; - int hex_gui_win_left; - int hex_gui_win_state; - int hex_gui_win_top; - int hex_gui_win_width; - int hex_input_balloon_time; - int hex_irc_ban_type; - int hex_irc_join_delay; - int hex_net_ping_timeout; - int hex_net_proxy_port; - int hex_net_proxy_type; /* 0=disabled, 1=wingate 2=socks4, 3=socks5, 4=http */ - int hex_net_proxy_use; /* 0=all 1=IRC_ONLY 2=DCC_ONLY */ - int hex_net_reconnect_delay; - int hex_notify_timeout; - int hex_text_max_indent; - int hex_text_max_lines; - int hex_text_tint_blue; - int hex_text_tint_green; - int hex_text_tint_red; - int hex_url_grabber_limit; - - /* STRINGS */ - char hex_away_reason[256]; - char hex_completion_suffix[4]; /* Only ever holds a one-character string. */ - char hex_dcc_completed_dir[PATHLEN + 1]; - char hex_dcc_dir[PATHLEN + 1]; - char hex_dcc_ip[DOMAINLEN + 1]; - char hex_dnsprogram[72]; - char hex_gui_ulist_doubleclick[256]; - char hex_input_command_char[4]; - char hex_irc_extra_hilight[300]; - char hex_irc_id_ntext[64]; - char hex_irc_id_ytext[64]; - char hex_irc_logmask[256]; - char hex_irc_nick1[NICKLEN]; - char hex_irc_nick2[NICKLEN]; - char hex_irc_nick3[NICKLEN]; - char hex_irc_nick_hilight[300]; - char hex_irc_no_hilight[300]; - char hex_irc_part_reason[256]; - char hex_irc_quit_reason[256]; - char hex_irc_real_name[127]; - char hex_irc_user_name[127]; - char hex_net_bind_host[127]; - char hex_net_proxy_host[64]; - char hex_net_proxy_pass[32]; - char hex_net_proxy_user[32]; - char hex_sound_command[PATHLEN + 1]; - char hex_sound_dir[PATHLEN + 1]; - char hex_stamp_log_format[64]; - char hex_stamp_text_format[64]; - char hex_text_background[PATHLEN + 1]; - char hex_text_font[4 * FONTNAMELEN + 1]; - char hex_text_font_main[FONTNAMELEN + 1]; - char hex_text_font_alternative[3 * FONTNAMELEN + 1]; - char hex_text_spell_langs[64]; - - /* these are the private variables */ - guint32 local_ip; - guint32 dcc_ip; - - unsigned int wait_on_exit; /* wait for logs to be flushed to disk IF we're connected */ - unsigned int utf8_locale; - - /* Tells us if we need to save, only when they've been edited. - This is so that we continue using internal defaults (which can - change in the next release) until the user edits them. */ - unsigned int save_pevents:1; -}; - -/* Session types */ -#define SESS_SERVER 1 -#define SESS_CHANNEL 2 -#define SESS_DIALOG 3 -#define SESS_NOTICES 4 -#define SESS_SNOTICES 5 - -/* Per-Channel Settings */ -#define SET_OFF 0 -#define SET_ON 1 -#define SET_DEFAULT 2 /* use global setting */ - -/* Moved from fe-gtk for use in outbound.c as well -- */ -typedef enum gtk_xtext_search_flags_e { - case_match = 1, - backward = 2, - highlight = 4, - follow = 8, - regexp = 16 -} gtk_xtext_search_flags; - -typedef struct session -{ - /* Per-Channel Alerts */ - /* use a byte, because we need a pointer to each element */ - guint8 alert_beep; - guint8 alert_taskbar; - guint8 alert_tray; - - /* Per-Channel Settings */ - guint8 text_hidejoinpart; - guint8 text_logging; - guint8 text_scrollback; - - struct server *server; - void *usertree_alpha; /* pure alphabetical tree */ - void *usertree; /* ordered with Ops first */ - struct User *me; /* points to myself in the usertree */ - char channel[CHANLEN]; - char waitchannel[CHANLEN]; /* waiting to join channel (/join sent) */ - char willjoinchannel[CHANLEN]; /* will issue /join for this channel */ - char channelkey[64]; /* XXX correct max length? */ - int limit; /* channel user limit */ - int logfd; - int scrollfd; /* scrollback filedes */ - int scrollwritten; /* number of lines written */ - - char lastnick[NICKLEN]; /* last nick you /msg'ed */ - - struct history history; - - int ops; /* num. of ops in channel */ - int hops; /* num. of half-oped users */ - int voices; /* num. of voiced people */ - int total; /* num. of users in channel */ - - char *quitreason; - char *topic; - char *current_modes; /* free() me */ - - int mode_timeout_tag; - - struct session *lastlog_sess; - struct nbexec *running_exec; - - struct session_gui *gui; /* initialized by fe_new_window */ - struct restore_gui *res; - - int type; /* SESS_* */ - - int new_data:1; /* new data avail? (purple tab) */ - int nick_said:1; /* your nick mentioned? (blue tab) */ - int msg_said:1; /* new msg available? (red tab) */ - - int ignore_date:1; - int ignore_mode:1; - int ignore_names:1; - int end_of_names:1; - int doing_who:1; /* /who sent on this channel */ - int done_away_check:1; /* done checking for away status changes */ - gtk_xtext_search_flags lastlog_flags; -} session; - -struct msproxy_state_t -{ - gint32 clientid; - gint32 serverid; - unsigned char seq_recv; /* seq number of last packet recv. */ - unsigned char seq_sent; /* seq number of last packet sent. */ -}; - -typedef struct server -{ - /* server control operations (in server*.c) */ - void (*connect)(struct server *, char *hostname, int port, int no_login); - void (*disconnect)(struct session *, int sendquit, int err); - int (*cleanup)(struct server *); - void (*flush_queue)(struct server *); - void (*auto_reconnect)(struct server *, int send_quit, int err); - /* irc protocol functions (in proto*.c) */ - void (*p_inline)(struct server *, char *buf, int len); - void (*p_invite)(struct server *, char *channel, char *nick); - void (*p_cycle)(struct server *, char *channel, char *key); - void (*p_ctcp)(struct server *, char *to, char *msg); - void (*p_nctcp)(struct server *, char *to, char *msg); - void (*p_quit)(struct server *, char *reason); - void (*p_kick)(struct server *, char *channel, char *nick, char *reason); - void (*p_part)(struct server *, char *channel, char *reason); - void (*p_ns_identify)(struct server *, char *pass); - void (*p_ns_ghost)(struct server *, char *usname, char *pass); - void (*p_join)(struct server *, char *channel, char *key); - void (*p_join_list)(struct server *, GSList *channels, GSList *keys); - void (*p_login)(struct server *, char *user, char *realname); - void (*p_join_info)(struct server *, char *channel); - void (*p_mode)(struct server *, char *target, char *mode); - void (*p_user_list)(struct server *, char *channel); - void (*p_away_status)(struct server *, char *channel); - void (*p_whois)(struct server *, char *nicks); - void (*p_get_ip)(struct server *, char *nick); - void (*p_get_ip_uh)(struct server *, char *nick); - void (*p_set_back)(struct server *); - void (*p_set_away)(struct server *, char *reason); - void (*p_message)(struct server *, char *channel, char *text); - void (*p_action)(struct server *, char *channel, char *act); - void (*p_notice)(struct server *, char *channel, char *text); - void (*p_topic)(struct server *, char *channel, char *topic); - void (*p_list_channels)(struct server *, char *arg, int min_users); - void (*p_change_nick)(struct server *, char *new_nick); - void (*p_names)(struct server *, char *channel); - void (*p_ping)(struct server *, char *to, char *timestring); -/* void (*p_set_away)(struct server *);*/ - int (*p_raw)(struct server *, char *raw); - int (*p_cmp)(const char *s1, const char *s2); - - int port; - int sok; /* is equal to sok4 or sok6 (the one we are using) */ - int sok4; /* tcp4 socket */ - int sok6; /* tcp6 socket */ - int proxy_type; - int proxy_sok; /* Additional information for MS Proxy beast */ - int proxy_sok4; - int proxy_sok6; - struct msproxy_state_t msp_state; - int id; /* unique ID number (for plugin API) */ -#ifdef USE_OPENSSL - SSL *ssl; - int ssl_do_connect_tag; -#else - void *ssl; -#endif - int childread; - int childwrite; - int childpid; - int iotag; - int recondelay_tag; /* reconnect delay timeout */ - int joindelay_tag; /* waiting before we send JOIN */ - char hostname[128]; /* real ip number */ - char servername[128]; /* what the server says is its name */ - char password[86]; - char nick[NICKLEN]; - char linebuf[2048]; /* RFC says 512 chars including \r\n */ - char *last_away_reason; - int pos; /* current position in linebuf */ - int nickcount; - int nickservtype; /* 0=/MSG nickserv 1=/NICKSERV 2=/NS */ - - char *chantypes; /* for 005 numeric - free me */ - char *chanmodes; /* for 005 numeric - free me */ - char *nick_prefixes; /* e.g. "*@%+" */ - char *nick_modes; /* e.g. "aohv" */ - char *bad_nick_prefixes; /* for ircd that doesn't give the modes */ - int modes_per_line; /* 6 on undernet, 4 on efnet etc... */ - - void *network; /* points to entry in servlist.c or NULL! */ - - GSList *outbound_queue; - time_t next_send; /* cptr->since in ircu */ - time_t prev_now; /* previous now-time */ - int sendq_len; /* queue size */ - int lag; /* milliseconds */ - - struct session *front_session; /* front-most window/tab */ - struct session *server_session; /* server window/tab */ - - struct server_gui *gui; /* initialized by fe_new_server */ - - unsigned int ctcp_counter; /*flood */ - time_t ctcp_last_time; - - unsigned int msg_counter; /*counts the msg tab opened in a certain time */ - time_t msg_last_time; - - /*time_t connect_time;*/ /* when did it connect? */ - time_t lag_sent; - time_t ping_recv; /* when we last got a ping reply */ - time_t away_time; /* when we were marked away */ - - char *encoding; /* NULL for system */ - char *autojoin; /* list of channels & keys to join */ - - unsigned int motd_skipped:1; - unsigned int connected:1; - unsigned int connecting:1; - unsigned int no_login:1; - unsigned int skip_next_userhost:1;/* used for "get my ip from server" */ - unsigned int skip_next_whois:1; /* hide whois output */ - unsigned int inside_whois:1; - unsigned int doing_dns:1; /* /dns has been done */ - unsigned int end_of_motd:1; /* end of motd reached (logged in) */ - unsigned int sent_quit:1; /* sent a QUIT already? */ - unsigned int use_listargs:1; /* undernet and dalnet need /list >0,<10000 */ - unsigned int is_away:1; - unsigned int reconnect_away:1; /* whether to reconnect in is_away state */ - unsigned int dont_use_proxy:1; /* to proxy or not to proxy */ - unsigned int supports_watch:1; /* supports the WATCH command */ - unsigned int bad_prefix:1; /* gave us a bad PREFIX= 005 number */ - unsigned int have_namesx:1; /* 005 tokens NAMESX and UHNAMES */ - unsigned int have_uhnames:1; - unsigned int have_whox:1; /* have undernet's WHOX features */ - unsigned int have_capab:1; /* supports CAPAB (005 tells us) */ - unsigned int have_idmsg:1; /* freenode's IDENTIFY-MSG */ - unsigned int have_except:1; /* ban exemptions +e */ - unsigned int using_cp1255:1; /* encoding is CP1255/WINDOWS-1255? */ - unsigned int using_irc:1; /* encoding is "IRC" (CP1252/UTF-8 hybrid)? */ - unsigned int use_who:1; /* whether to use WHO command to get dcc_ip */ -#ifdef USE_OPENSSL - unsigned int use_ssl:1; /* is server SSL capable? */ - unsigned int accept_invalid_cert:1;/* ignore result of server's cert. verify */ -#endif -} server; - -typedef int (*cmd_callback) (struct session * sess, char *tbuf, char *word[], - char *word_eol[]); - -struct commands -{ - char *name; - cmd_callback callback; - char needserver; - char needchannel; - gint16 handle_quotes; - char *help; -}; - -struct away_msg -{ - struct server *server; - char nick[NICKLEN]; - char *message; -}; - -/* not just for popups, but used for usercommands, ctcp replies, - userlist buttons etc */ - -struct popup -{ - char *cmd; - char *name; -}; - -/* CL: get a random int in the range [0..n-1]. DON'T use rand() % n, it gives terrible results. */ -#define RAND_INT(n) ((int)(rand() / (RAND_MAX + 1.0) * (n))) - -#define xchat_filename_from_utf8 g_filename_from_utf8 -#define xchat_filename_to_utf8 g_filename_to_utf8 - -#endif diff --git a/src/common/xchatc.h b/src/common/xchatc.h deleted file mode 100644 index 1d955055..00000000 --- a/src/common/xchatc.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef XCHAT_C_H -#define XCHAT_C_H - -extern struct hexchatprefs prefs; - -extern int xchat_is_quitting; -extern gint arg_skip_plugins; /* command-line args */ -extern gint arg_dont_autoconnect; -extern char *arg_url; -extern char *arg_command; -extern gint arg_existing; - -extern session *current_sess; -extern session *current_tab; - -extern GSList *popup_list; -extern GSList *button_list; -extern GSList *dlgbutton_list; -extern GSList *command_list; -extern GSList *ctcp_list; -extern GSList *replace_list; -extern GSList *sess_list; -extern GSList *dcc_list; -extern GSList *ignore_list; -extern GSList *usermenu_list; -extern GSList *urlhandler_list; -extern GSList *tabmenu_list; - -session * find_channel (server *serv, char *chan); -session * find_dialog (server *serv, char *nick); -session * new_ircwindow (server *serv, char *name, int type, int focus); -int is_session (session * sess); -void session_free (session *killsess); -void lag_check (void); -void xchat_exit (void); -void xchat_exec (const char *cmd); -void xchat_execv (char * const argv[]); - -#endif diff --git a/src/fe-gtk/about.c b/src/fe-gtk/about.c index f63cf80e..d33c6ae3 100644 --- a/src/fe-gtk/about.c +++ b/src/fe-gtk/about.c @@ -37,9 +37,9 @@ #include #endif -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/util.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "palette.h" #include "pixmaps.h" #include "gtkutil.h" diff --git a/src/fe-gtk/ascii.c b/src/fe-gtk/ascii.c index f1adbdfc..85dcf26d 100644 --- a/src/fe-gtk/ascii.c +++ b/src/fe-gtk/ascii.c @@ -28,8 +28,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "gtkutil.h" #include "ascii.h" #include "maingui.h" diff --git a/src/fe-gtk/banlist.c b/src/fe-gtk/banlist.c index 43bc9e42..f91be2fc 100644 --- a/src/fe-gtk/banlist.c +++ b/src/fe-gtk/banlist.c @@ -37,11 +37,11 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/fe.h" #include "../common/modes.h" #include "../common/outbound.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "gtkutil.h" #include "maingui.h" #include "banlist.h" diff --git a/src/fe-gtk/chanlist.c b/src/fe-gtk/chanlist.c index 54348565..8a431ebc 100644 --- a/src/fe-gtk/chanlist.c +++ b/src/fe-gtk/chanlist.c @@ -47,8 +47,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/outbound.h" #include "../common/util.h" diff --git a/src/fe-gtk/chanview-tree.c b/src/fe-gtk/chanview-tree.c index 5a678550..bceabc8f 100644 --- a/src/fe-gtk/chanview-tree.c +++ b/src/fe-gtk/chanview-tree.c @@ -6,8 +6,8 @@ typedef struct GtkWidget *scrollw; /* scrolledWindow */ } treeview; -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "fe-gtk.h" #include "maingui.h" diff --git a/src/fe-gtk/dccgui.c b/src/fe-gtk/dccgui.c index 737963d5..60881959 100644 --- a/src/fe-gtk/dccgui.c +++ b/src/fe-gtk/dccgui.c @@ -44,8 +44,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/fe.h" #include "../common/util.h" #include "../common/network.h" diff --git a/src/fe-gtk/editlist.c b/src/fe-gtk/editlist.c index 05be3128..2ce48ee4 100644 --- a/src/fe-gtk/editlist.c +++ b/src/fe-gtk/editlist.c @@ -37,9 +37,9 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/cfgfiles.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "../common/fe.h" #include "menu.h" #include "gtkutil.h" diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index 9272c6b3..f89bb650 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -37,12 +37,12 @@ #include #endif -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/fe.h" #include "../common/util.h" #include "../common/text.h" #include "../common/cfgfiles.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "../common/plugin.h" #include "../common/server.h" #include "../common/url.h" diff --git a/src/fe-gtk/fkeys.c b/src/fe-gtk/fkeys.c index 3018667d..eee48b8d 100644 --- a/src/fe-gtk/fkeys.c +++ b/src/fe-gtk/fkeys.c @@ -46,8 +46,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/fe.h" #include "../common/userlist.h" diff --git a/src/fe-gtk/gtkutil.c b/src/fe-gtk/gtkutil.c index 58f7b804..8de4325d 100644 --- a/src/fe-gtk/gtkutil.c +++ b/src/fe-gtk/gtkutil.c @@ -46,11 +46,11 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/fe.h" #include "../common/util.h" #include "../common/cfgfiles.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "gtkutil.h" #include "pixmaps.h" diff --git a/src/fe-gtk/ignoregui.c b/src/fe-gtk/ignoregui.c index 13cd8f0b..6531bd27 100644 --- a/src/fe-gtk/ignoregui.c +++ b/src/fe-gtk/ignoregui.c @@ -39,7 +39,7 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/ignore.h" #include "../common/cfgfiles.h" #include "../common/fe.h" diff --git a/src/fe-gtk/joind.c b/src/fe-gtk/joind.c index 5c591070..41f3f405 100644 --- a/src/fe-gtk/joind.c +++ b/src/fe-gtk/joind.c @@ -28,8 +28,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/server.h" #include "../common/fe.h" #include "fe-gtk.h" diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index c1b60c27..27f26d2b 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -44,10 +44,10 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/fe.h" #include "../common/server.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "../common/outbound.h" #include "../common/inbound.h" #include "../common/plugin.h" diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c index bf12f25d..572335ab 100644 --- a/src/fe-gtk/menu.c +++ b/src/fe-gtk/menu.c @@ -44,8 +44,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/outbound.h" #include "../common/ignore.h" diff --git a/src/fe-gtk/notifygui.c b/src/fe-gtk/notifygui.c index 679b3f02..7daf2484 100644 --- a/src/fe-gtk/notifygui.c +++ b/src/fe-gtk/notifygui.c @@ -38,7 +38,7 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/notify.h" #include "../common/cfgfiles.h" #include "../common/fe.h" diff --git a/src/fe-gtk/palette.c b/src/fe-gtk/palette.c index 80e0a11d..072646dd 100644 --- a/src/fe-gtk/palette.c +++ b/src/fe-gtk/palette.c @@ -31,7 +31,7 @@ #include "fe-gtk.h" #include "palette.h" -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/util.h" #include "../common/cfgfiles.h" diff --git a/src/fe-gtk/pixmaps.c b/src/fe-gtk/pixmaps.c index 4211c6f5..b7fc40e2 100644 --- a/src/fe-gtk/pixmaps.c +++ b/src/fe-gtk/pixmaps.c @@ -22,7 +22,7 @@ #include "fe-gtk.h" #include "../common/cfgfiles.h" -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/fe.h" #include diff --git a/src/fe-gtk/plugin-tray.c b/src/fe-gtk/plugin-tray.c index 922515fe..581e9dfc 100644 --- a/src/fe-gtk/plugin-tray.c +++ b/src/fe-gtk/plugin-tray.c @@ -1,9 +1,9 @@ /* Copyright (C) 2006-2007 Peter Zelezny. */ #include -#include "../common/xchat-plugin.h" -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat-plugin.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/inbound.h" #include "../common/server.h" #include "../common/fe.h" diff --git a/src/fe-gtk/plugingui.c b/src/fe-gtk/plugingui.c index 00566533..401abfbf 100644 --- a/src/fe-gtk/plugingui.c +++ b/src/fe-gtk/plugingui.c @@ -32,15 +32,15 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #define PLUGIN_C typedef struct session xchat_context; -#include "../common/xchat-plugin.h" +#include "../common/hexchat-plugin.h" #include "../common/plugin.h" #include "../common/util.h" #include "../common/outbound.h" #include "../common/fe.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "gtkutil.h" diff --git a/src/fe-gtk/rawlog.c b/src/fe-gtk/rawlog.c index 60b359a0..945facdf 100644 --- a/src/fe-gtk/rawlog.c +++ b/src/fe-gtk/rawlog.c @@ -35,8 +35,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/server.h" #include "gtkutil.h" diff --git a/src/fe-gtk/search.c b/src/fe-gtk/search.c index f90b685d..e0839f79 100644 --- a/src/fe-gtk/search.c +++ b/src/fe-gtk/search.c @@ -34,10 +34,10 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/fe.h" #include "../common/util.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "gtkutil.h" #include "xtext.h" #include "maingui.h" diff --git a/src/fe-gtk/servlistgui.c b/src/fe-gtk/servlistgui.c index c0c504f6..fe8aa319 100644 --- a/src/fe-gtk/servlistgui.c +++ b/src/fe-gtk/servlistgui.c @@ -32,8 +32,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/servlist.h" #include "../common/cfgfiles.h" #include "../common/fe.h" diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index 1f940d9f..a83e423a 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -8,13 +8,13 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/cfgfiles.h" #include "../common/fe.h" #include "../common/text.h" #include "../common/userlist.h" #include "../common/util.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "fe-gtk.h" #include "gtkutil.h" #include "maingui.h" diff --git a/src/fe-gtk/sexy-spell-entry.c b/src/fe-gtk/sexy-spell-entry.c index 22404855..190c62e7 100644 --- a/src/fe-gtk/sexy-spell-entry.c +++ b/src/fe-gtk/sexy-spell-entry.c @@ -41,7 +41,7 @@ #endif #include "../common/cfgfiles.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" /* * Bunch of poop to make enchant into a runtime dependency rather than a diff --git a/src/fe-gtk/textgui.c b/src/fe-gtk/textgui.c index 851ad392..7d4c38bd 100644 --- a/src/fe-gtk/textgui.c +++ b/src/fe-gtk/textgui.c @@ -36,8 +36,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/outbound.h" #include "../common/fe.h" diff --git a/src/fe-gtk/urlgrab.c b/src/fe-gtk/urlgrab.c index a5bb4e0a..68d796eb 100644 --- a/src/fe-gtk/urlgrab.c +++ b/src/fe-gtk/urlgrab.c @@ -32,8 +32,8 @@ #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/fe.h" #include "../common/url.h" diff --git a/src/fe-gtk/userlistgui.c b/src/fe-gtk/userlistgui.c index d4834581..e6d57891 100644 --- a/src/fe-gtk/userlistgui.c +++ b/src/fe-gtk/userlistgui.c @@ -34,12 +34,12 @@ #include #include -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/util.h" #include "../common/userlist.h" #include "../common/modes.h" #include "../common/notify.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "../common/fe.h" #include "gtkutil.h" #include "palette.h" diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c index e45d47f0..656a4c92 100644 --- a/src/fe-gtk/xtext.c +++ b/src/fe-gtk/xtext.c @@ -65,10 +65,10 @@ #include "mmx_cmod.h" #endif -#include "../common/xchat.h" +#include "../common/hexchat.h" #include "../common/fe.h" #include "../common/util.h" -#include "../common/xchatc.h" +#include "../common/hexchatc.h" #include "fe-gtk.h" #include "xtext.h" #include "fkeys.h" diff --git a/src/fe-text/fe-text.c b/src/fe-text/fe-text.c index 173ef438..0eb68dce 100644 --- a/src/fe-text/fe-text.c +++ b/src/fe-text/fe-text.c @@ -32,8 +32,8 @@ #include #include #include -#include "../common/xchat.h" -#include "../common/xchatc.h" +#include "../common/hexchat.h" +#include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/outbound.h" #include "../common/util.h" -- cgit 1.4.1