From 85bdb06cad4e8a58509f7421610ef9c82bbabc02 Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Tue, 8 Nov 2016 22:34:31 -0500 Subject: Convert doat to an internal command - Trivial plugin - Useful for many users - Was under a dumb license --- configure.ac | 22 ------- plugins/Makefile.am | 6 +- plugins/doat/Makefile.am | 9 --- plugins/doat/doat.c | 92 ----------------------------- plugins/doat/doat.def | 3 - plugins/doat/doat.vcxproj | 59 ------------------- plugins/doat/doat.vcxproj.filters | 23 -------- src/common/outbound.c | 36 ++++++++++++ src/common/plugin.c | 118 ++++++++++++++++++++------------------ src/common/plugin.h | 1 + win32/hexchat.sln | 11 ---- win32/installer/hexchat.iss.tt | 2 - 12 files changed, 100 insertions(+), 282 deletions(-) delete mode 100644 plugins/doat/Makefile.am delete mode 100644 plugins/doat/doat.c delete mode 100644 plugins/doat/doat.def delete mode 100644 plugins/doat/doat.vcxproj delete mode 100644 plugins/doat/doat.vcxproj.filters diff --git a/configure.ac b/configure.ac index 672752e7..ca00ec33 100644 --- a/configure.ac +++ b/configure.ac @@ -134,10 +134,6 @@ AC_ARG_ENABLE(checksum, [AS_HELP_STRING([--disable-checksum],[disable the Checksum plugin])], checksum=$enableval, checksum=yes) -AC_ARG_ENABLE(doat, - [AS_HELP_STRING([--disable-doat],[disable the Do At plugin])], - doat=$enableval, doat=yes) - AC_ARG_ENABLE(fishlim, [AS_HELP_STRING([--disable-fishlim],[disable the FiSHLiM plugin])], fishlim=$enableval, fishlim=yes) @@ -457,21 +453,6 @@ AS_IF([test "$checksum" != "no"], [ ]) ]) -dnl ********************************************************************* -dnl ** DO AT ************************************************************ -dnl ********************************************************************* - -AS_IF([test "$doat" != "no"], [ - AC_MSG_CHECKING(for plugin interface used by Do At) - doat=no - AS_IF([test "$plugin" = yes], [ - doat=yes - AC_MSG_RESULT([yes]) - ], [ - AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option for Do At]) - ]) -]) - dnl ********************************************************************* dnl ** FiSHLiM ********************************************************** dnl ********************************************************************* @@ -609,7 +590,6 @@ AM_CONDITIONAL(DO_LUA, test "x$lua" = "xyes") AM_CONDITIONAL(DO_PYTHON, test "x$python" != "xno") AM_CONDITIONAL(DO_PLUGIN, test "x$plugin" = "xyes") AM_CONDITIONAL(DO_CHECKSUM, test "x$checksum" = "xyes") -AM_CONDITIONAL(DO_DOAT, test "x$doat" = "xyes") AM_CONDITIONAL(DO_FISHLIM, test "x$fishlim" = "xyes") AM_CONDITIONAL(DO_SYSINFO, test "x$sysinfo" = "xyes") AM_CONDITIONAL(DO_STATIC_ANALYSIS, test "x$analyze" = "xyes") @@ -767,7 +747,6 @@ plugins/lua/Makefile plugins/python/Makefile plugins/perl/Makefile plugins/checksum/Makefile -plugins/doat/Makefile plugins/fishlim/Makefile plugins/sysinfo/Makefile po/Makefile.in @@ -794,7 +773,6 @@ echo Perl .................. : $perl echo Python ................ : $python echo echo Checksum .............. : $checksum -echo Do At ................. : $doat echo FiSHLiM ............... : $fishlim echo SysInfo ............... : $sysinfo echo diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 018cb924..3880f15d 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -10,10 +10,6 @@ if DO_PERL perldir = perl endif -if DO_DOAT -doatdir = doat -endif - if DO_FISHLIM fishlimdir = fishlim endif @@ -26,4 +22,4 @@ if DO_SYSINFO sysinfodir = sysinfo endif -SUBDIRS = $(lua) $(pythondir) $(perldir) $(checksumdir) $(doatdir) $(fishlimdir) $(sysinfodir) +SUBDIRS = $(lua) $(pythondir) $(perldir) $(checksumdir) $(fishlimdir) $(sysinfodir) diff --git a/plugins/doat/Makefile.am b/plugins/doat/Makefile.am deleted file mode 100644 index d8765946..00000000 --- a/plugins/doat/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -libdir = $(hexchatlibdir) - -lib_LTLIBRARIES = doat.la -doat_la_SOURCES = doat.c -doat_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module -doat_la_LIBADD = $(GLIB_LIBS) -doat_la_CPPFLAGS = -I$(top_srcdir)/src/common -doat_la_CFLAGS = $(GLIB_CFLAGS) - diff --git a/plugins/doat/doat.c b/plugins/doat/doat.c deleted file mode 100644 index 1d1bfcdf..00000000 --- a/plugins/doat/doat.c +++ /dev/null @@ -1,92 +0,0 @@ -/* This program is free software. It comes without any warranty, to - * the extent permitted by applicable law. You can redistribute it - * and/or modify it under the terms of the Do What The Fuck You Want - * To Public License, Version 2, as published by Sam Hocevar. See - * http://sam.zoy.org/wtfpl/COPYING or http://lwsitu.com/xchat/COPYING - * for more details. */ - -#include "config.h" - -#include -#include -#include -#include -#include "hexchat-plugin.h" - -static hexchat_plugin *ph; - -static int -parse_command( char *word[], char *word_eol[], void *userdata ) { - char *channel = NULL, *server = NULL, *token = NULL; -/* char *save_ptr1 = NULL;*/ - char *str1 = NULL; - char *delimiter = NULL; - - hexchat_context *ctx = NULL; - - if( word[2] != NULL && word[3] != NULL ) { - for( str1 = word[2]; ; str1 = NULL ) { -/* token = strtok_r( str1, ",", &save_ptr1 );*/ - token = strtok( str1, "," ); -/* printf( "token: %s\n", token );*/ - - if( token == NULL ) { - break; - } - - channel = g_strdup( token ); - - delimiter = strchr( channel, '/' ); - - server = NULL; - if( delimiter != NULL ) { - *delimiter = '\0'; - - if( strlen( delimiter + 1 ) > 0 ) { - server = g_strdup( delimiter + 1 ); - } - } - - /* /Network form */ - if( strlen( channel ) == 0 ) { - g_free( channel ); - channel = NULL; - } - -/* printf( "channel[%s] server[%s]\n", channel, server );*/ - - if( (ctx = hexchat_find_context( ph, server, channel ) ) != NULL ) { - if( hexchat_set_context( ph, ctx ) ) { - hexchat_command( ph, word_eol[3] ); - } - } - - g_free( channel ); - g_free( server ); - } - } - return HEXCHAT_EAT_HEXCHAT; -} - -int -hexchat_plugin_init( hexchat_plugin * plugin_handle, char **plugin_name, - char **plugin_desc, char **plugin_version, char *arg ) { - - ph = plugin_handle; - *plugin_name = "Do At"; - *plugin_version = "1.0001"; - *plugin_desc = "Perform an arbitrary command on multiple channels"; - - hexchat_hook_command( ph, "doat", HEXCHAT_PRI_NORM, parse_command, "DOAT [channel,list,/network] [command], perform a command on multiple contexts", NULL ); - - hexchat_print (ph, "Do At plugin loaded\n"); - - return 1; -} - -int -hexchat_plugin_deinit (void) -{ - hexchat_print (ph, "Do At plugin unloaded\n"); - return 1; -} diff --git a/plugins/doat/doat.def b/plugins/doat/doat.def deleted file mode 100644 index e560f50f..00000000 --- a/plugins/doat/doat.def +++ /dev/null @@ -1,3 +0,0 @@ -EXPORTS -hexchat_plugin_init -hexchat_plugin_deinit diff --git a/plugins/doat/doat.vcxproj b/plugins/doat/doat.vcxproj deleted file mode 100644 index f11dac64..00000000 --- a/plugins/doat/doat.vcxproj +++ /dev/null @@ -1,59 +0,0 @@ - - - - v140 - DynamicLibrary - - - - Release - Win32 - - - Release - x64 - - - - {4980AF24-9D42-427D-A8E6-0DF3B97C455D} - Win32Proj - doat - - - - - - - hcdoat - $(HexChatRel)plugins\ - - - - WIN32;NDEBUG;_WINDOWS;_USRDLL;DOAT_EXPORTS;%(PreprocessorDefinitions) - ..\..\src\common;$(HexChatLib);$(Glib);%(AdditionalIncludeDirectories) - - - $(DepsRoot)\lib;%(AdditionalLibraryDirectories) - $(DepLibs);%(AdditionalDependencies) - doat.def - - - - - WIN32;_WIN64;_AMD64_;NDEBUG;_WINDOWS;_USRDLL;DOAT_EXPORTS;%(PreprocessorDefinitions) - ..\..\src\common;$(HexChatLib);$(Glib);%(AdditionalIncludeDirectories) - - - $(DepsRoot)\lib;%(AdditionalLibraryDirectories) - $(DepLibs);%(AdditionalDependencies) - doat.def - - - - - - - - - - diff --git a/plugins/doat/doat.vcxproj.filters b/plugins/doat/doat.vcxproj.filters deleted file mode 100644 index 43ea8307..00000000 --- a/plugins/doat/doat.vcxproj.filters +++ /dev/null @@ -1,23 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - - - Resource Files - - - \ No newline at end of file diff --git a/src/common/outbound.c b/src/common/outbound.c index 61626821..3c717526 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -1447,6 +1447,41 @@ cmd_dns (struct session *sess, char *tbuf, char *word[], char *word_eol[]) return FALSE; } +static int +cmd_doat (struct session *sess, char *tbuf, char *word[], char *word_eol[]) +{ + GStrv channels; + guint i; + + if (!word[2] || !*word[2] || !word[3] || !*word[3]) + return FALSE; + + channels = g_strsplit (word[2], ",", -1); + for (i = 0; channels[i] && *channels[i]; ++i) + { + char *chan = channels[i]; + char *serv; + session *ctx; + + /* Split channel and network, either may be empty */ + if ((serv = strchr (chan, '/'))) + { + *serv = '\0'; + serv++; + if (!strlen (serv)) + serv = NULL; + } + if (!strlen (chan)) + chan = NULL; + + if ((ctx = plugin_find_context (serv, chan, sess->server))) + handle_command (ctx, word_eol[3], FALSE); + } + g_strfreev (channels); + + return TRUE; +} + static int cmd_echo (struct session *sess, char *tbuf, char *word[], char *word_eol[]) { @@ -3931,6 +3966,7 @@ const struct commands xc_cmds[] = { N_("DEVOICE , removes voice status from the nick on the current channel (needs chanop)")}, {"DISCON", cmd_discon, 0, 0, 1, N_("DISCON, Disconnects from server")}, {"DNS", cmd_dns, 0, 0, 1, N_("DNS , Resolves an IP or hostname")}, + {"DOAT", cmd_doat, 0, 0, 1, N_("DOAT ")}, {"ECHO", cmd_echo, 0, 0, 1, N_("ECHO , Prints text locally")}, #ifndef WIN32 {"EXEC", cmd_exec, 0, 0, 1, diff --git a/src/common/plugin.c b/src/common/plugin.c index 07012736..b49afd96 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -452,7 +452,6 @@ plugin_auto_load (session *sess) /* a long list of bundled plugins that should be loaded automatically, * user plugins should go to , leave Program Files alone! */ for_files (lib_dir, "hcchecksum.dll", plugin_auto_load_cb); - for_files (lib_dir, "hcdoat.dll", plugin_auto_load_cb); for_files (lib_dir, "hcexec.dll", plugin_auto_load_cb); for_files (lib_dir, "hcfishlim.dll", plugin_auto_load_cb); for_files(lib_dir, "hclua.dll", plugin_auto_load_cb); @@ -871,6 +870,67 @@ plugin_show_help (session *sess, char *cmd) return 0; } +session * +plugin_find_context (const char *servname, const char *channel, server *current_server) +{ + GSList *slist, *clist, *sessions = NULL; + server *serv; + session *sess; + char *netname; + + if (servname == NULL && channel == NULL) + return current_sess; + + slist = serv_list; + while (slist) + { + serv = slist->data; + netname = server_get_network (serv, TRUE); + + if (servname == NULL || + rfc_casecmp (servname, serv->servername) == 0 || + g_ascii_strcasecmp (servname, serv->hostname) == 0 || + g_ascii_strcasecmp (servname, netname) == 0) + { + if (channel == NULL) + return serv->front_session; + + clist = sess_list; + while (clist) + { + sess = clist->data; + if (sess->server == serv) + { + if (rfc_casecmp (channel, sess->channel) == 0) + { + if (sess->server == current_server) + { + g_slist_free (sessions); + return sess; + } else + { + sessions = g_slist_prepend (sessions, sess); + } + } + } + clist = clist->next; + } + } + slist = slist->next; + } + + if (sessions) + { + sessions = g_slist_reverse (sessions); + sess = sessions->data; + g_slist_free (sessions); + return sess; + } + + return NULL; +} + + /* ========================================================= */ /* ===== these are the functions plugins actually call ===== */ /* ========================================================= */ @@ -1038,61 +1098,7 @@ hexchat_set_context (hexchat_plugin *ph, hexchat_context *context) hexchat_context * hexchat_find_context (hexchat_plugin *ph, const char *servname, const char *channel) { - GSList *slist, *clist, *sessions = NULL; - server *serv; - session *sess; - char *netname; - - if (servname == NULL && channel == NULL) - return current_sess; - - slist = serv_list; - while (slist) - { - serv = slist->data; - netname = server_get_network (serv, TRUE); - - if (servname == NULL || - rfc_casecmp (servname, serv->servername) == 0 || - g_ascii_strcasecmp (servname, serv->hostname) == 0 || - g_ascii_strcasecmp (servname, netname) == 0) - { - if (channel == NULL) - return serv->front_session; - - clist = sess_list; - while (clist) - { - sess = clist->data; - if (sess->server == serv) - { - if (rfc_casecmp (channel, sess->channel) == 0) - { - if (sess->server == ph->context->server) - { - g_slist_free (sessions); - return sess; - } else - { - sessions = g_slist_prepend (sessions, sess); - } - } - } - clist = clist->next; - } - } - slist = slist->next; - } - - if (sessions) - { - sessions = g_slist_reverse (sessions); - sess = sessions->data; - g_slist_free (sessions); - return sess; - } - - return NULL; + return plugin_find_context (servname, channel, ph->context->server); } const char * diff --git a/src/common/plugin.h b/src/common/plugin.h index 5743f39a..76ce97a3 100644 --- a/src/common/plugin.h +++ b/src/common/plugin.h @@ -179,5 +179,6 @@ int plugin_emit_keypress (session *sess, unsigned int state, unsigned int keyval GList* plugin_command_list(GList *tmp_list); int plugin_show_help (session *sess, char *cmd); void plugin_command_foreach (session *sess, void *userdata, void (*cb) (session *sess, void *userdata, char *name, char *usage)); +session *plugin_find_context (const char *servname, const char *channel, server *current_server); #endif diff --git a/win32/hexchat.sln b/win32/hexchat.sln index 19c67ae8..1c6367ca 100644 --- a/win32/hexchat.sln +++ b/win32/hexchat.sln @@ -29,11 +29,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python2", "..\plugins\pytho {87554B59-006C-4D94-9714-897B27067BA3} = {87554B59-006C-4D94-9714-897B27067BA3} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doat", "..\plugins\doat\doat.vcxproj", "{4980AF24-9D42-427D-A8E6-0DF3B97C455D}" - ProjectSection(ProjectDependencies) = postProject - {87554B59-006C-4D94-9714-897B27067BA3} = {87554B59-006C-4D94-9714-897B27067BA3} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "checksum", "..\plugins\checksum\checksum.vcxproj", "{5EF7F47D-D09C-43C4-BF64-B28B11A0FF91}" ProjectSection(ProjectDependencies) = postProject {87554B59-006C-4D94-9714-897B27067BA3} = {87554B59-006C-4D94-9714-897B27067BA3} @@ -87,7 +82,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "installer", "installer\inst {C2321A03-0BA7-45B3-8740-ABD82B36B0BF} = {C2321A03-0BA7-45B3-8740-ABD82B36B0BF} {19C52A0A-A790-409E-A28A-9745FF990F5C} = {19C52A0A-A790-409E-A28A-9745FF990F5C} {BF0EBC16-68AD-4CD1-864C-5B56836EBE2A} = {BF0EBC16-68AD-4CD1-864C-5B56836EBE2A} - {4980AF24-9D42-427D-A8E6-0DF3B97C455D} = {4980AF24-9D42-427D-A8E6-0DF3B97C455D} {17E4BE39-76F7-4A06-AD21-EFD0C5091F76} = {17E4BE39-76F7-4A06-AD21-EFD0C5091F76} {4C0F3940-2EEE-4646-82F7-6CE75B9A72F4} = {4C0F3940-2EEE-4646-82F7-6CE75B9A72F4} {B10A2C41-344C-43E0-A32D-B9587C198D8B} = {B10A2C41-344C-43E0-A32D-B9587C198D8B} @@ -156,10 +150,6 @@ Global {19C52A0A-A790-409E-A28A-9745FF990F5C}.Release|Win32.Build.0 = Release|Win32 {19C52A0A-A790-409E-A28A-9745FF990F5C}.Release|x64.ActiveCfg = Release|x64 {19C52A0A-A790-409E-A28A-9745FF990F5C}.Release|x64.Build.0 = Release|x64 - {4980AF24-9D42-427D-A8E6-0DF3B97C455D}.Release|Win32.ActiveCfg = Release|Win32 - {4980AF24-9D42-427D-A8E6-0DF3B97C455D}.Release|Win32.Build.0 = Release|Win32 - {4980AF24-9D42-427D-A8E6-0DF3B97C455D}.Release|x64.ActiveCfg = Release|x64 - {4980AF24-9D42-427D-A8E6-0DF3B97C455D}.Release|x64.Build.0 = Release|x64 {5EF7F47D-D09C-43C4-BF64-B28B11A0FF91}.Release|Win32.ActiveCfg = Release|Win32 {5EF7F47D-D09C-43C4-BF64-B28B11A0FF91}.Release|Win32.Build.0 = Release|Win32 {5EF7F47D-D09C-43C4-BF64-B28B11A0FF91}.Release|x64.ActiveCfg = Release|x64 @@ -237,7 +227,6 @@ Global {E4BDB4C8-2335-415A-ACEE-BA88B19BFE82} = {AAACEB12-9475-410E-AF5A-FDFF907E9043} {E93E1255-95D1-4B08-8FDF-B53CC6A21280} = {AAACEB12-9475-410E-AF5A-FDFF907E9043} {19C52A0A-A790-409E-A28A-9745FF990F5C} = {D237DA6B-BD5F-46C0-8BEA-50E9A1340240} - {4980AF24-9D42-427D-A8E6-0DF3B97C455D} = {561126F4-FA18-45FC-A2BF-8F858F161D6D} {5EF7F47D-D09C-43C4-BF64-B28B11A0FF91} = {561126F4-FA18-45FC-A2BF-8F858F161D6D} {17E4BE39-76F7-4A06-AD21-EFD0C5091F76} = {561126F4-FA18-45FC-A2BF-8F858F161D6D} {3C4F42FC-292A-420B-B63D-C03DFBDD8E4E} = {561126F4-FA18-45FC-A2BF-8F858F161D6D} diff --git a/win32/installer/hexchat.iss.tt b/win32/installer/hexchat.iss.tt index 119c12e5..ad8ccafa 100644 --- a/win32/installer/hexchat.iss.tt +++ b/win32/installer/hexchat.iss.tt @@ -64,7 +64,6 @@ Name: "translations"; Description: "Translations"; Types: normal custom; Flags: Name: "spell"; Description: "Spelling Dictionaries"; Types: custom; Flags: disablenouninstallwarning Name: "plugins"; Description: "Plugins"; Types: custom; Flags: disablenouninstallwarning Name: "plugins\checksum"; Description: "Checksum"; Types: custom; Flags: disablenouninstallwarning -Name: "plugins\doat"; Description: "Do At"; Types: normal custom; Flags: disablenouninstallwarning Name: "plugins\exec"; Description: "Exec"; Types: custom; Flags: disablenouninstallwarning Name: "plugins\fishlim"; Description: "FiSHLiM"; Types: custom; Flags: disablenouninstallwarning Name: "plugins\mpcinfo"; Description: "mpcInfo"; Types: custom; Flags: disablenouninstallwarning @@ -167,7 +166,6 @@ Source: "share\lua\lgi\*.lua"; DestDir: "{app}\share\lua\lgi"; Flags: ignorevers Source: "share\lua\lgi\override\*.lua"; DestDir: "{app}\share\lua\lgi\override"; Flags: ignoreversion; Components: langs\lua Source: "plugins\hcchecksum.dll"; DestDir: "{app}\plugins"; Flags: ignoreversion; Components: plugins\checksum -Source: "plugins\hcdoat.dll"; DestDir: "{app}\plugins"; Flags: ignoreversion; Components: plugins\doat Source: "plugins\hcexec.dll"; DestDir: "{app}\plugins"; Flags: ignoreversion; Components: plugins\exec Source: "plugins\hcfishlim.dll"; DestDir: "{app}\plugins"; Flags: ignoreversion; Components: plugins\fishlim Source: "share\music.png"; DestDir: "{app}\share"; Flags: ignoreversion; Components: plugins\winamp or plugins\mpcinfo -- cgit 1.4.1