diff options
author | Berke Viktor <bviktor@hexchat.org> | 2012-07-26 20:53:59 +0200 |
---|---|---|
committer | Berke Viktor <bviktor@hexchat.org> | 2012-07-26 20:53:59 +0200 |
commit | ec301a5a5486898cb4d9854a56eb866f1b93f634 (patch) | |
tree | c0cec2f567df7e1f62fc0168b2fe3cc68c9d8954 /src | |
parent | 7f831646bb8c31966e0f3ff77d40ce66711daa99 (diff) |
Auto-load user plugins and scripts from <config>/addons
On Unix leave $(libdir)/hexchat/plugins for plugin packagers, on Windows prevent users from modifying Program Files by ignoring everything except bundled plugins
Diffstat (limited to 'src')
-rw-r--r-- | src/common/plugin.c | 35 | ||||
-rw-r--r-- | src/fe-gtk/plugingui.c | 15 |
2 files changed, 40 insertions, 10 deletions
diff --git a/src/common/plugin.c b/src/common/plugin.c index 1bec7a7a..6756e0fc 100644 --- a/src/common/plugin.c +++ b/src/common/plugin.c @@ -457,19 +457,38 @@ plugin_auto_load_cb (char *filename) void plugin_auto_load (session *sess) { - ps = sess; - /* let's do it the Perl way */ const char *xdir; char *sub_dir; + ps = sess; xdir = get_xdir_fs (); - sub_dir = malloc (strlen (xdir) + 9); + sub_dir = malloc (strlen (xdir) + 8); strcpy (sub_dir, xdir); - strcat (sub_dir, "/plugins"); + strcat (sub_dir, "/addons"); #ifdef WIN32 - for_files ("./plugins", "*.dll", plugin_auto_load_cb); + /* a long list of bundled plugins that should be loaded automatically, + * user plugins should go to <config>, leave Program Files alone! */ + for_files ("./plugins", "hcchecksum.dll", plugin_auto_load_cb); + for_files ("./plugins", "hcdns.dll", plugin_auto_load_cb); + for_files ("./plugins", "hcdoat.dll", plugin_auto_load_cb); + for_files ("./plugins", "hcexec.dll", plugin_auto_load_cb); + for_files ("./plugins", "hcfishlim.dll", plugin_auto_load_cb); + for_files ("./plugins", "hclua.dll", plugin_auto_load_cb); + for_files ("./plugins", "hcmpcinfo.dll", plugin_auto_load_cb); + for_files ("./plugins", "hcperl-512.dll", plugin_auto_load_cb); + for_files ("./plugins", "hcperl-514.dll", plugin_auto_load_cb); + for_files ("./plugins", "hcperl-516.dll", plugin_auto_load_cb); + for_files ("./plugins", "hcpython.dll", plugin_auto_load_cb); + for_files ("./plugins", "hcsasl.dll", plugin_auto_load_cb); + for_files ("./plugins", "hctcl.dll", plugin_auto_load_cb); + for_files ("./plugins", "hcupd.dll", plugin_auto_load_cb); + for_files ("./plugins", "hcwinamp.dll", plugin_auto_load_cb); + for_files ("./plugins", "hcwinsys.dll", plugin_auto_load_cb); + for_files ("./plugins", "hcwmpa.dll", plugin_auto_load_cb); + for_files ("./plugins", "hextray.dll", plugin_auto_load_cb); + for_files (sub_dir, "*.dll", plugin_auto_load_cb); #else #if defined(__hpux) @@ -1620,7 +1639,7 @@ xchat_pluginpref_set_str_real (xchat_plugin *pl, const char *var, const char *va canon = g_strdup (pl->name); canonalize_key (canon); - sprintf (confname, "plugin_%s.conf", canon); + sprintf (confname, "addon_%s.conf", canon); g_free (canon); sprintf (confname_tmp, "%s.new", confname); @@ -1737,7 +1756,7 @@ xchat_pluginpref_get_str (xchat_plugin *pl, const char *var, char *dest) canon = g_strdup (pl->name); canonalize_key (canon); - sprintf (confname, "plugin_%s.conf", canon); + sprintf (confname, "addon_%s.conf", canon); g_free (canon); /* partly borrowed from palette.c */ @@ -1817,7 +1836,7 @@ xchat_pluginpref_list (xchat_plugin *pl, char* dest) token = g_strdup (pl->name); canonalize_key (token); - sprintf (confname, "plugin_%s.conf", token); + sprintf (confname, "addon_%s.conf", token); g_free (token); fpIn = xchat_fopen_file (confname, "r", 0); diff --git a/src/fe-gtk/plugingui.c b/src/fe-gtk/plugingui.c index d17aadb7..00566533 100644 --- a/src/fe-gtk/plugingui.c +++ b/src/fe-gtk/plugingui.c @@ -147,6 +147,15 @@ plugingui_load_cb (session *sess, char *file) void plugingui_load (void) { + /* let's do it the Perl way */ + const char *xdir; + char *sub_dir; + + xdir = get_xdir_utf8 (); + sub_dir = malloc (strlen (xdir) + 8); + strcpy (sub_dir, xdir); + strcat (sub_dir, "/addons"); + gtkutil_file_req (_("Select a Plugin or Script to load"), plugingui_load_cb, current_sess, #if 0 /* native file dialogs */ #ifdef WIN32 @@ -156,10 +165,12 @@ plugingui_load (void) #endif #endif /* native file dialogs */ #ifdef WIN32 - get_xdir_utf8 (), "*.dll;*.lua;*.pl;*.py;*.tcl", FRF_ADDFOLDER|FRF_FILTERISINITIAL|FRF_EXTENSIONS); + sub_dir, "*.dll;*.lua;*.pl;*.py;*.tcl", FRF_ADDFOLDER|FRF_FILTERISINITIAL|FRF_EXTENSIONS); #else - get_xdir_utf8 (), "*.so;*.lua;*.pl;*.py;*.tcl", FRF_ADDFOLDER|FRF_FILTERISINITIAL|FRF_EXTENSIONS); + sub_dir, "*.so;*.lua;*.pl;*.py;*.tcl", FRF_ADDFOLDER|FRF_FILTERISINITIAL|FRF_EXTENSIONS); #endif + + free (sub_dir); } static void |