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 +- 59 files changed, 2413 insertions(+), 2413 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 (limited to 'plugins') 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 */ -- cgit 1.4.1