diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | doc/en/weechat_plugin_api.en.txt | 120 | ||||
-rw-r--r-- | doc/fr/weechat_plugin_api.fr.txt | 120 | ||||
-rw-r--r-- | doc/it/weechat_plugin_api.it.txt | 144 | ||||
-rw-r--r-- | src/plugins/guile/weechat-guile.c | 10 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua.c | 10 | ||||
-rw-r--r-- | src/plugins/perl/weechat-perl.c | 12 | ||||
-rw-r--r-- | src/plugins/plugin-script.c | 186 | ||||
-rw-r--r-- | src/plugins/python/weechat-python.c | 10 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby.c | 10 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl.c | 10 |
11 files changed, 547 insertions, 88 deletions
@@ -1,7 +1,7 @@ WeeChat ChangeLog ================= Sébastien Helleu <flashcode@flashtux.org> -v0.3.9-dev, 2012-08-07 +v0.3.9-dev, 2012-08-08 Version 0.3.9 (under dev!) @@ -73,6 +73,7 @@ Version 0.3.9 (under dev!) * relay: fix freeze when writing on relay socket (use non-blocking sockets in relay for irc and weechat protocols) (bug #36655) * ruby: detect ruby version 1.9.3 in cmake and autotools +* scripts: add signals for scripts loaded/unloaded/installed/removed * scripts: add hdata with list of scripts for each language * scripts: fix deletion of configuration files when script is unloaded (bug #36977) diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt index 7b996fba7..0e6201878 100644 --- a/doc/en/weechat_plugin_api.en.txt +++ b/doc/en/weechat_plugin_api.en.txt @@ -7371,6 +7371,26 @@ Arguments: |======================================== | Plugin | Signal | Arguments | Description +| guile | guile_script_loaded + + (_new in version 0.3.9_) | + string: path to script | + scheme script loaded + +| guile | guile_script_unloaded + + (_new in version 0.3.9_) | + string: path to script | + scheme script unloaded + +| guile | guile_script_installed + + (_new in version 0.3.9_) | + string: comma-separated list of paths to scripts installed (example: "/path/to/script1.scm,/path/to/script2.scm") | + scheme script(s) installed + +| guile | guile_script_removed + + (_new in version 0.3.9_) | + string: comma-separated list of scripts removed (example: "script1.scm,script2.scm") | + scheme script(s) removed + | irc | xxx,irc_in_yyy ^(1)^ | string: message | irc message from server (before irc plugin uses it, @@ -7489,6 +7509,106 @@ Arguments: pointer: buffer | display backlog for buffer +| lua | lua_script_loaded + + (_new in version 0.3.9_) | + string: path to script | + lua script loaded + +| lua | lua_script_unloaded + + (_new in version 0.3.9_) | + string: path to script | + lua script unloaded + +| lua | lua_script_installed + + (_new in version 0.3.9_) | + string: comma-separated list of paths to scripts installed (example: "/path/to/script1.lua,/path/to/script2.lua") | + lua script(s) installed + +| lua | lua_script_removed + + (_new in version 0.3.9_) | + string: comma-separated list of scripts removed (example: "script1.lua,script2.lua") | + lua script(s) removed + +| perl | perl_script_loaded + + (_new in version 0.3.9_) | + string: path to script | + perl script loaded + +| perl | perl_script_unloaded + + (_new in version 0.3.9_) | + string: path to script | + perl script unloaded + +| perl | perl_script_installed + + (_new in version 0.3.9_) | + string: comma-separated list of paths to scripts installed (example: "/path/to/script1.pl,/path/to/script2.pl") | + perl script(s) installed + +| perl | perl_script_removed + + (_new in version 0.3.9_) | + string: comma-separated list of scripts removed (example: "script1.pl,script2.pl") | + perl script(s) removed + +| python | python_script_loaded + + (_new in version 0.3.9_) | + string: path to script | + python script loaded + +| python | python_script_unloaded + + (_new in version 0.3.9_) | + string: path to script | + python script unloaded + +| python | python_script_installed + + (_new in version 0.3.9_) | + string: comma-separated list of paths to scripts installed (example: "/path/to/script1.py,/path/to/script2.py") | + python script(s) installed + +| python | python_script_removed + + (_new in version 0.3.9_) | + string: comma-separated list of scripts removed (example: "script1.py,script2.py") | + python script(s) removed + +| ruby | ruby_script_loaded + + (_new in version 0.3.9_) | + string: path to script | + ruby script loaded + +| ruby | ruby_script_unloaded + + (_new in version 0.3.9_) | + string: path to script | + ruby script unloaded + +| ruby | ruby_script_installed + + (_new in version 0.3.9_) | + string: comma-separated list of paths to scripts installed (example: "/path/to/script1.rb,/path/to/script2.rb") | + ruby script(s) installed + +| ruby | ruby_script_removed + + (_new in version 0.3.9_) | + string: comma-separated list of scripts removed (example: "script1.rb,script2.rb") | + ruby script(s) removed + +| tcl | tcl_script_loaded + + (_new in version 0.3.9_) | + string: path to script | + tcl script loaded + +| tcl | tcl_script_unloaded + + (_new in version 0.3.9_) | + string: path to script | + tcl script unloaded + +| tcl | tcl_script_installed + + (_new in version 0.3.9_) | + string: comma-separated list of paths to scripts installed (example: "/path/to/script1.tcl,/path/to/script2.tcl") | + tcl script(s) installed + +| tcl | tcl_script_removed + + (_new in version 0.3.9_) | + string: comma-separated list of scripts removed (example: "script1.tcl,script2.tcl") | + tcl script(s) removed + | weechat | buffer_closing | pointer: buffer | closing buffer diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt index 71309fbc9..e5a263424 100644 --- a/doc/fr/weechat_plugin_api.fr.txt +++ b/doc/fr/weechat_plugin_api.fr.txt @@ -7481,6 +7481,26 @@ Paramètres : |======================================== | Extension | Signal | Paramètres | Description +| guile | guile_script_loaded + + (_nouveau dans la version 0.3.9_) | + chaîne: chemin vers le script | + script scheme chargé + +| guile | guile_script_unloaded + + (_nouveau dans la version 0.3.9_) | + chaîne: chemin vers le script | + script scheme déchargé + +| guile | guile_script_installed + + (_nouveau dans la version 0.3.9_) | + chaîne: liste de chemins vers scripts installés (séparés par des virgules) (exemple: "/chemin/vers/script1.scm,/chemin/vers/script2.scm") | + script(s) scheme installé(s) + +| guile | guile_script_removed + + (_nouveau dans la version 0.3.9_) | + chaîne: liste de scripts supprimés (séparés par des virgules) (exemple: "script1.scm,script2.scm") | + script(s) scheme supprimé(s) + | irc | xxx,irc_in_yyy ^(1)^ | chaîne : message | message irc du serveur (avant utilisation par l'extension irc, @@ -7599,6 +7619,106 @@ Paramètres : pointeur : tampon | affichage du backlog pour le tampon +| lua | lua_script_loaded + + (_nouveau dans la version 0.3.9_) | + chaîne: chemin vers le script | + script lua chargé + +| lua | lua_script_unloaded + + (_nouveau dans la version 0.3.9_) | + chaîne: chemin vers le script | + script lua déchargé + +| lua | lua_script_installed + + (_nouveau dans la version 0.3.9_) | + chaîne: liste de chemins vers scripts installés (séparés par des virgules) (exemple: "/chemin/vers/script1.lua,/chemin/vers/script2.lua") | + script(s) lua installé(s) + +| lua | lua_script_removed + + (_nouveau dans la version 0.3.9_) | + chaîne: liste de scripts supprimés (séparés par des virgules) (exemple: "script1.lua,script2.lua") | + script(s) lua supprimé(s) + +| perl | perl_script_loaded + + (_nouveau dans la version 0.3.9_) | + chaîne: chemin vers le script | + script perl chargé + +| perl | perl_script_unloaded + + (_nouveau dans la version 0.3.9_) | + chaîne: chemin vers le script | + script perl déchargé + +| perl | perl_script_installed + + (_nouveau dans la version 0.3.9_) | + chaîne: liste de chemins vers scripts installés (séparés par des virgules) (exemple: "/chemin/vers/script1.pl,/chemin/vers/script2.pl") | + script(s) perl installé(s) + +| perl | perl_script_removed + + (_nouveau dans la version 0.3.9_) | + chaîne: liste de scripts supprimés (séparés par des virgules) (exemple: "script1.pl,script2.pl") | + script(s) perl supprimé(s) + +| python | python_script_loaded + + (_nouveau dans la version 0.3.9_) | + chaîne: chemin vers le script | + script python chargé + +| python | python_script_unloaded + + (_nouveau dans la version 0.3.9_) | + chaîne: chemin vers le script | + script python déchargé + +| python | python_script_installed + + (_nouveau dans la version 0.3.9_) | + chaîne: liste de chemins vers scripts installés (séparés par des virgules) (exemple: "/chemin/vers/script1.py,/chemin/vers/script2.py") | + script(s) python installé(s) + +| python | python_script_removed + + (_nouveau dans la version 0.3.9_) | + chaîne: liste de scripts supprimés (séparés par des virgules) (exemple: "script1.py,script2.py") | + script(s) python supprimé(s) + +| ruby | ruby_script_loaded + + (_nouveau dans la version 0.3.9_) | + chaîne: chemin vers le script | + script ruby chargé + +| ruby | ruby_script_unloaded + + (_nouveau dans la version 0.3.9_) | + chaîne: chemin vers le script | + script ruby déchargé + +| ruby | ruby_script_installed + + (_nouveau dans la version 0.3.9_) | + chaîne: liste de chemins vers scripts installés (séparés par des virgules) (exemple: "/chemin/vers/script1.rb,/chemin/vers/script2.rb") | + script(s) ruby installé(s) + +| ruby | ruby_script_removed + + (_nouveau dans la version 0.3.9_) | + chaîne: liste de scripts supprimés (séparés par des virgules) (exemple: "script1.rb,script2.rb") | + script(s) ruby supprimé(s) + +| tcl | tcl_script_loaded + + (_nouveau dans la version 0.3.9_) | + chaîne: chemin vers le script | + script tcl chargé + +| tcl | tcl_script_unloaded + + (_nouveau dans la version 0.3.9_) | + chaîne: chemin vers le script | + script tcl déchargé + +| tcl | tcl_script_installed + + (_nouveau dans la version 0.3.9_) | + chaîne: liste de chemins vers scripts installés (séparés par des virgules) (exemple: "/chemin/vers/script1.tcl,/chemin/vers/script2.tcl") | + script(s) tcl installé(s) + +| tcl | tcl_script_removed + + (_nouveau dans la version 0.3.9_) | + chaîne: liste de scripts supprimés (séparés par des virgules) (exemple: "script1.tcl,script2.tcl") | + script(s) tcl supprimé(s) + | weechat | buffer_closing | pointeur : tampon | fermeture du tampon en cours diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt index ff0f90e43..9a4c0c9c9 100644 --- a/doc/it/weechat_plugin_api.it.txt +++ b/doc/it/weechat_plugin_api.it.txt @@ -7407,6 +7407,30 @@ Argomenti: |======================================== | Plugin | Segnale | Argomenti | Descrizione +// TRANSLATION MISSING +| guile | guile_script_loaded + + (_novità nella versione 0.3.9_) | + string: path to script | + scheme script loaded + +// TRANSLATION MISSING +| guile | guile_script_unloaded + + (_novità nella versione 0.3.9_) | + string: path to script | + scheme script unloaded + +// TRANSLATION MISSING +| guile | guile_script_installed + + (_novità nella versione 0.3.9_) | + string: comma-separated list of paths to scripts installed (example: "/path/to/script1.scm,/path/to/script2.scm") | + scheme script(s) installed + +// TRANSLATION MISSING +| guile | guile_script_removed + + (_novità nella versione 0.3.9_) | + string: comma-separated list of scripts removed (example: "script1.scm,script2.scm") | + scheme script(s) removed + | irc | xxx,irc_in_yyy ^(1)^ | string: messaggio | messaggio irc dal server (prima di essere utilizzato @@ -7529,6 +7553,126 @@ Argomenti: puntatore: buffer | visualizza log precedenti per il buffer +// TRANSLATION MISSING +| lua | lua_script_loaded + + (_novità nella versione 0.3.9_) | + string: path to script | + lua script loaded + +// TRANSLATION MISSING +| lua | lua_script_unloaded + + (_novità nella versione 0.3.9_) | + string: path to script | + lua script unloaded + +// TRANSLATION MISSING +| lua | lua_script_installed + + (_novità nella versione 0.3.9_) | + string: comma-separated list of paths to scripts installed (example: "/path/to/script1.lua,/path/to/script2.lua") | + lua script(s) installed + +// TRANSLATION MISSING +| lua | lua_script_removed + + (_novità nella versione 0.3.9_) | + string: comma-separated list of scripts removed (example: "script1.lua,script2.lua") | + lua script(s) removed + +// TRANSLATION MISSING +| perl | perl_script_loaded + + (_novità nella versione 0.3.9_) | + string: path to script | + perl script loaded + +// TRANSLATION MISSING +| perl | perl_script_unloaded + + (_novità nella versione 0.3.9_) | + string: path to script | + perl script unloaded + +// TRANSLATION MISSING +| perl | perl_script_installed + + (_novità nella versione 0.3.9_) | + string: comma-separated list of paths to scripts installed (example: "/path/to/script1.pl,/path/to/script2.pl") | + perl script(s) installed + +// TRANSLATION MISSING +| perl | perl_script_removed + + (_novità nella versione 0.3.9_) | + string: comma-separated list of scripts removed (example: "script1.pl,script2.pl") | + perl script(s) removed + +// TRANSLATION MISSING +| python | python_script_loaded + + (_novità nella versione 0.3.9_) | + string: path to script | + python script loaded + +// TRANSLATION MISSING +| python | python_script_unloaded + + (_novità nella versione 0.3.9_) | + string: path to script | + python script unloaded + +// TRANSLATION MISSING +| python | python_script_installed + + (_novità nella versione 0.3.9_) | + string: comma-separated list of paths to scripts installed (example: "/path/to/script1.py,/path/to/script2.py") | + python script(s) installed + +// TRANSLATION MISSING +| python | python_script_removed + + (_novità nella versione 0.3.9_) | + string: comma-separated list of scripts removed (example: "script1.py,script2.py") | + python script(s) removed + +// TRANSLATION MISSING +| ruby | ruby_script_loaded + + (_novità nella versione 0.3.9_) | + string: path to script | + ruby script loaded + +// TRANSLATION MISSING +| ruby | ruby_script_unloaded + + (_novità nella versione 0.3.9_) | + string: path to script | + ruby script unloaded + +// TRANSLATION MISSING +| ruby | ruby_script_installed + + (_novità nella versione 0.3.9_) | + string: comma-separated list of paths to scripts installed (example: "/path/to/script1.rb,/path/to/script2.rb") | + ruby script(s) installed + +// TRANSLATION MISSING +| ruby | ruby_script_removed + + (_novità nella versione 0.3.9_) | + string: comma-separated list of scripts removed (example: "script1.rb,script2.rb") | + ruby script(s) removed + +// TRANSLATION MISSING +| tcl | tcl_script_loaded + + (_novità nella versione 0.3.9_) | + string: path to script | + tcl script loaded + +// TRANSLATION MISSING +| tcl | tcl_script_unloaded + + (_novità nella versione 0.3.9_) | + string: path to script | + tcl script unloaded + +// TRANSLATION MISSING +| tcl | tcl_script_installed + + (_novità nella versione 0.3.9_) | + string: comma-separated list of paths to scripts installed (example: "/path/to/script1.tcl,/path/to/script2.tcl") | + tcl script(s) installed + +// TRANSLATION MISSING +| tcl | tcl_script_removed + + (_novità nella versione 0.3.9_) | + string: comma-separated list of scripts removed (example: "script1.tcl,script2.tcl") | + tcl script(s) removed + | weechat | buffer_closing | puntatore: buffer | chiusura del buffer diff --git a/src/plugins/guile/weechat-guile.c b/src/plugins/guile/weechat-guile.c index 071c5252c..93d84a24c 100644 --- a/src/plugins/guile/weechat-guile.c +++ b/src/plugins/guile/weechat-guile.c @@ -412,6 +412,9 @@ weechat_guile_load (const char *filename) &weechat_guile_api_buffer_input_data_cb, &weechat_guile_api_buffer_close_cb); + weechat_hook_signal_send ("guile_script_loaded", WEECHAT_HOOK_SIGNAL_STRING, + guile_current_script->filename); + return 1; } @@ -437,6 +440,7 @@ weechat_guile_unload (struct t_plugin_script *script) { int *rc; void *interpreter; + char *filename; if ((weechat_guile_plugin->debug >= 2) || !guile_quiet) { @@ -453,6 +457,7 @@ weechat_guile_unload (struct t_plugin_script *script) free (rc); } + filename = strdup (script->filename); interpreter = script->interpreter; if (guile_current_script == script) @@ -464,6 +469,11 @@ weechat_guile_unload (struct t_plugin_script *script) if (interpreter) weechat_guile_catch (scm_gc_unprotect_object, interpreter); + + weechat_hook_signal_send ("guile_script_unloaded", + WEECHAT_HOOK_SIGNAL_STRING, filename); + if (filename) + free (filename); } /* diff --git a/src/plugins/lua/weechat-lua.c b/src/plugins/lua/weechat-lua.c index a1e9110bb..eed431cdf 100644 --- a/src/plugins/lua/weechat-lua.c +++ b/src/plugins/lua/weechat-lua.c @@ -383,6 +383,9 @@ weechat_lua_load (const char *filename) &weechat_lua_api_buffer_input_data_cb, &weechat_lua_api_buffer_close_cb); + weechat_hook_signal_send ("lua_script_loaded", WEECHAT_HOOK_SIGNAL_STRING, + lua_current_script->filename); + return 1; } @@ -408,6 +411,7 @@ weechat_lua_unload (struct t_plugin_script *script) { int *rc; void *interpreter; + char *filename; if ((weechat_lua_plugin->debug >= 2) || !lua_quiet) { @@ -426,6 +430,7 @@ weechat_lua_unload (struct t_plugin_script *script) free (rc); } + filename = strdup (script->filename); interpreter = script->interpreter; if (lua_current_script == script) @@ -436,6 +441,11 @@ weechat_lua_unload (struct t_plugin_script *script) if (interpreter) lua_close (interpreter); + + weechat_hook_signal_send ("lua_script_unloaded", + WEECHAT_HOOK_SIGNAL_STRING, filename); + if (filename) + free (filename); } /* diff --git a/src/plugins/perl/weechat-perl.c b/src/plugins/perl/weechat-perl.c index baf921191..26334a203 100644 --- a/src/plugins/perl/weechat-perl.c +++ b/src/plugins/perl/weechat-perl.c @@ -531,6 +531,9 @@ weechat_perl_load (const char *filename) &weechat_perl_api_buffer_input_data_cb, &weechat_perl_api_buffer_close_cb); + weechat_hook_signal_send ("perl_script_loaded", WEECHAT_HOOK_SIGNAL_STRING, + perl_current_script->filename); + return 1; } @@ -556,6 +559,7 @@ weechat_perl_unload (struct t_plugin_script *script) { int *rc; void *interpreter; + char *filename; if ((weechat_perl_plugin->debug >= 2) || !perl_quiet) { @@ -580,11 +584,14 @@ weechat_perl_unload (struct t_plugin_script *script) free (rc); } + filename = strdup (script->filename); interpreter = script->interpreter; if (perl_current_script == script) + { perl_current_script = (perl_current_script->prev_script) ? perl_current_script->prev_script : perl_current_script->next_script; + } plugin_script_remove (weechat_perl_plugin, &perl_scripts, &last_perl_script, script); @@ -599,6 +606,11 @@ weechat_perl_unload (struct t_plugin_script *script) if (interpreter) free (interpreter); #endif + + weechat_hook_signal_send ("perl_script_unloaded", + WEECHAT_HOOK_SIGNAL_STRING, filename); + if (filename) + free (filename); } /* diff --git a/src/plugins/plugin-script.c b/src/plugins/plugin-script.c index 611da04a2..188df6232 100644 --- a/src/plugins/plugin-script.c +++ b/src/plugins/plugin-script.c @@ -926,97 +926,103 @@ plugin_script_action_install (struct t_weechat_plugin *weechat_plugin, char **list) { char **argv, *name, *ptr_base_name, *base_name, *new_path, *autoload_path; - char *symlink_path; + char *symlink_path, str_signal[128]; const char *dir_home, *dir_separator; int argc, i, length, rc; struct t_plugin_script *ptr_script; - if (*list) + if (!*list) + return; + + argv = weechat_string_split (*list, ",", 0, 0, &argc); + if (argv) { - argv = weechat_string_split (*list, ",", 0, 0, &argc); - if (argv) + for (i = 0; i < argc; i++) { - for (i = 0; i < argc; i++) + name = strdup (argv[i]); + if (name) { - name = strdup (argv[i]); - if (name) + ptr_base_name = basename (name); + base_name = strdup (ptr_base_name); + if (base_name) { - ptr_base_name = basename (name); - base_name = strdup (ptr_base_name); - if (base_name) + /* unload script, if script is loaded */ + ptr_script = plugin_script_search_by_full_name (scripts, + base_name); + if (ptr_script) + (*script_unload) (ptr_script); + + /* remove script file(s) */ + plugin_script_remove_file (weechat_plugin, base_name, 0); + + /* move file from install dir to language dir */ + dir_home = weechat_info_get ("weechat_dir", ""); + length = strlen (dir_home) + strlen (weechat_plugin->name) + + strlen (base_name) + 16; + new_path = malloc (length); + if (new_path) { - /* unload script, if script is loaded */ - ptr_script = plugin_script_search_by_full_name (scripts, - base_name); - if (ptr_script) - (*script_unload) (ptr_script); - - /* remove script file(s) */ - plugin_script_remove_file (weechat_plugin, base_name, 0); - - /* move file from install dir to language dir */ - dir_home = weechat_info_get ("weechat_dir", ""); - length = strlen (dir_home) + strlen (weechat_plugin->name) + - strlen (base_name) + 16; - new_path = malloc (length); - if (new_path) + snprintf (new_path, length, "%s/%s/%s", + dir_home, weechat_plugin->name, base_name); + if (rename (name, new_path) == 0) { - snprintf (new_path, length, "%s/%s/%s", - dir_home, weechat_plugin->name, base_name); - if (rename (name, new_path) == 0) + /* make link in autoload dir */ + length = strlen (dir_home) + + strlen (weechat_plugin->name) + 8 + + strlen (base_name) + 16; + autoload_path = malloc (length); + if (autoload_path) { - /* make link in autoload dir */ - length = strlen (dir_home) + - strlen (weechat_plugin->name) + 8 + - strlen (base_name) + 16; - autoload_path = malloc (length); - if (autoload_path) + snprintf (autoload_path, length, + "%s/%s/autoload/%s", + dir_home, weechat_plugin->name, + base_name); + dir_separator = weechat_info_get ("dir_separator", ""); + length = 2 + strlen (dir_separator) + + strlen (base_name) + 1; + symlink_path = malloc (length); + if (symlink_path) { - snprintf (autoload_path, length, - "%s/%s/autoload/%s", - dir_home, weechat_plugin->name, - base_name); - dir_separator = weechat_info_get ("dir_separator", ""); - length = 2 + strlen (dir_separator) + - strlen (base_name) + 1; - symlink_path = malloc (length); - if (symlink_path) - { - snprintf (symlink_path, length, "..%s%s", - dir_separator, base_name); - rc = symlink (symlink_path, autoload_path); - (void) rc; - free (symlink_path); - } - free (autoload_path); + snprintf (symlink_path, length, "..%s%s", + dir_separator, base_name); + rc = symlink (symlink_path, autoload_path); + (void) rc; + free (symlink_path); } - - /* load script */ - (*script_load) (new_path); - } - else - { - weechat_printf (NULL, - _("%s%s: failed to move script %s " - "to %s (%s)"), - weechat_prefix ("error"), - weechat_plugin->name, - name, - new_path, - strerror (errno)); + free (autoload_path); } - free (new_path); + + /* load script */ + (*script_load) (new_path); + } + else + { + weechat_printf (NULL, + _("%s%s: failed to move script %s " + "to %s (%s)"), + weechat_prefix ("error"), + weechat_plugin->name, + name, + new_path, + strerror (errno)); } - free (base_name); + free (new_path); } - free (name); + free (base_name); } + free (name); } - weechat_string_free_split (argv); } - free (*list); - *list = NULL; + weechat_string_free_split (argv); } + + snprintf (str_signal, sizeof (str_signal), + "%s_script_installed", weechat_plugin->name); + weechat_hook_signal_send (str_signal, WEECHAT_HOOK_SIGNAL_STRING, + *list); + + free (*list); + *list = NULL; } /* @@ -1032,30 +1038,36 @@ plugin_script_action_remove (struct t_weechat_plugin *weechat_plugin, void (*script_unload)(struct t_plugin_script *script), char **list) { - char **argv; + char **argv, str_signal[128]; int argc, i; struct t_plugin_script *ptr_script; - if (*list) + if (!*list) + return; + + argv = weechat_string_split (*list, ",", 0, 0, &argc); + if (argv) { - argv = weechat_string_split (*list, ",", 0, 0, &argc); - if (argv) + for (i = 0; i < argc; i++) { - for (i = 0; i < argc; i++) - { - /* unload script, if script is loaded */ - ptr_script = plugin_script_search_by_full_name (scripts, argv[i]); - if (ptr_script) - (*script_unload) (ptr_script); + /* unload script, if script is loaded */ + ptr_script = plugin_script_search_by_full_name (scripts, argv[i]); + if (ptr_script) + (*script_unload) (ptr_script); - /* remove script file(s) */ - plugin_script_remove_file (weechat_plugin, argv[i], 1); - } - weechat_string_free_split (argv); + /* remove script file(s) */ + plugin_script_remove_file (weechat_plugin, argv[i], 1); } - free (*list); - *list = NULL; + weechat_string_free_split (argv); } + + snprintf (str_signal, sizeof (str_signal), + "%s_script_removed", weechat_plugin->name); + weechat_hook_signal_send (str_signal, WEECHAT_HOOK_SIGNAL_STRING, + *list); + + free (*list); + *list = NULL; } /* diff --git a/src/plugins/python/weechat-python.c b/src/plugins/python/weechat-python.c index ef19891d9..d237df29d 100644 --- a/src/plugins/python/weechat-python.c +++ b/src/plugins/python/weechat-python.c @@ -740,6 +740,9 @@ weechat_python_load (const char *filename) &weechat_python_api_buffer_input_data_cb, &weechat_python_api_buffer_close_cb); + weechat_hook_signal_send ("python_script_loaded", WEECHAT_HOOK_SIGNAL_STRING, + python_current_script->filename); + return 1; } @@ -766,6 +769,7 @@ weechat_python_unload (struct t_plugin_script *script) int *rc; void *interpreter; PyThreadState *old_interpreter; + char *filename; if ((weechat_python_plugin->debug >= 2) || !python_quiet) { @@ -782,6 +786,7 @@ weechat_python_unload (struct t_plugin_script *script) free (rc); } + filename = strdup (script->filename); old_interpreter = PyThreadState_Swap (NULL); interpreter = script->interpreter; @@ -800,6 +805,11 @@ weechat_python_unload (struct t_plugin_script *script) if (old_interpreter) PyThreadState_Swap (old_interpreter); + + weechat_hook_signal_send ("python_script_unloaded", + WEECHAT_HOOK_SIGNAL_STRING, filename); + if (filename) + free (filename); } /* diff --git a/src/plugins/ruby/weechat-ruby.c b/src/plugins/ruby/weechat-ruby.c index 248f2f564..cb8f3354a 100644 --- a/src/plugins/ruby/weechat-ruby.c +++ b/src/plugins/ruby/weechat-ruby.c @@ -595,6 +595,9 @@ weechat_ruby_load (const char *filename) &weechat_ruby_api_buffer_input_data_cb, &weechat_ruby_api_buffer_close_cb); + weechat_hook_signal_send ("ruby_script_loaded", WEECHAT_HOOK_SIGNAL_STRING, + ruby_current_script->filename); + return 1; } @@ -620,6 +623,7 @@ weechat_ruby_unload (struct t_plugin_script *script) { int *rc; void *interpreter; + char *filename; if ((weechat_ruby_plugin->debug >= 2) || !ruby_quiet) { @@ -638,6 +642,7 @@ weechat_ruby_unload (struct t_plugin_script *script) free (rc); } + filename = strdup (script->filename); interpreter = script->interpreter; if (ruby_current_script == script) @@ -649,6 +654,11 @@ weechat_ruby_unload (struct t_plugin_script *script) if (interpreter) rb_gc_unregister_address (interpreter); + + weechat_hook_signal_send ("ruby_script_unloaded", + WEECHAT_HOOK_SIGNAL_STRING, filename); + if (filename) + free (filename); } /* diff --git a/src/plugins/tcl/weechat-tcl.c b/src/plugins/tcl/weechat-tcl.c index e6dde9041..549e1acd0 100644 --- a/src/plugins/tcl/weechat-tcl.c +++ b/src/plugins/tcl/weechat-tcl.c @@ -343,6 +343,9 @@ weechat_tcl_load (const char *filename) &weechat_tcl_api_buffer_input_data_cb, &weechat_tcl_api_buffer_close_cb); + weechat_hook_signal_send ("tcl_script_loaded", WEECHAT_HOOK_SIGNAL_STRING, + tcl_current_script->filename); + return 1; } @@ -368,6 +371,7 @@ weechat_tcl_unload (struct t_plugin_script *script) { Tcl_Interp* interp; int *rc; + char *filename; if ((weechat_tcl_plugin->debug >= 2) || !tcl_quiet) { @@ -386,6 +390,7 @@ weechat_tcl_unload (struct t_plugin_script *script) free (rc); } + filename = strdup (script->filename); interp = (Tcl_Interp*)script->interpreter; if (tcl_current_script == script) @@ -395,6 +400,11 @@ weechat_tcl_unload (struct t_plugin_script *script) plugin_script_remove (weechat_tcl_plugin, &tcl_scripts, &last_tcl_script, script); Tcl_DeleteInterp(interp); + + weechat_hook_signal_send ("tcl_script_unloaded", + WEECHAT_HOOK_SIGNAL_STRING, filename); + if (filename) + free (filename); } /* |