int weechat_ruby_timer_action_cb (void *data, int remaining_calls) { /* make C compiler happy */ (void) remaining_calls; if (data) { if (data == &ruby_action_install_list) { script_action_install (weechat_ruby_plugin, ruby_scripts, &weechat_ruby_unload, &weechat_ruby_load, &ruby_action_install_list); } else if (data == &ruby_action_remove_list) { script_action_remove (weechat_ruby_plugin, ruby_scripts, &weechat_ruby_unload, &ruby_action_remove_list); } } return WEECHAT_RC_OK; }
int script_action_installnext_timer_cb (void *data, int remaining_calls) { /* make C compiler happy */ (void) remaining_calls; script_action_install ((data) ? 1 : 0); return DOGECHAT_RC_OK; }
int script_action_run () { char **actions, **argv, **argv_eol, *ptr_action; int num_actions, argc, i, j, quiet, script_found; struct t_script_repo *ptr_script; if (!script_actions) return 0; script_get_loaded_plugins (); actions = dogechat_string_split (script_actions, "\n", 0, 0, &num_actions); if (actions) { for (i = 0; i < num_actions; i++) { quiet = 0; ptr_action = actions[i]; if (ptr_action[0] == '-') { /* * if action starts with options (like "-q"), * read and skip them */ ptr_action++; while (ptr_action[0] && (ptr_action[0] != ' ')) { switch (ptr_action[0]) { case 'q': /* quiet */ quiet = 1; break; } ptr_action++; } while (ptr_action[0] == ' ') { ptr_action++; } } argv = dogechat_string_split (ptr_action, " ", 0, 0, &argc); argv_eol = dogechat_string_split (ptr_action, " ", 1, 0, &argc); if (argv && argv_eol) { if (dogechat_strcasecmp (argv[0], "buffer") == 0) { /* open buffer with list of scripts */ if (!script_buffer) { script_buffer_open (); script_buffer_refresh (1); } dogechat_buffer_set (script_buffer, "display", "1"); } else if (dogechat_strcasecmp (argv[0], "list") == 0) { if (argc > 1) { if (dogechat_strcasecmp (argv[1], "-i") == 0) script_action_list_input (0); else if (dogechat_strcasecmp (argv[1], "-o") == 0) script_action_list_input (1); else script_action_list (); } else script_action_list (); } else if (dogechat_strcasecmp (argv[0], "load") == 0) { for (j = 1; j < argc; j++) { script_action_load (argv[j], quiet); } } else if (dogechat_strcasecmp (argv[0], "unload") == 0) { for (j = 1; j < argc; j++) { script_action_unload (argv[j], quiet); } } else if (dogechat_strcasecmp (argv[0], "reload") == 0) { for (j = 1; j < argc; j++) { script_action_reload (argv[j], quiet); } } else if (dogechat_strcasecmp (argv[0], "autoload") == 0) { for (j = 1; j < argc; j++) { script_action_autoload (argv[j], quiet, 1); } } else if (dogechat_strcasecmp (argv[0], "noautoload") == 0) { for (j = 1; j < argc; j++) { script_action_autoload (argv[j], quiet, 0); } } else if (dogechat_strcasecmp (argv[0], "toggleautoload") == 0) { for (j = 1; j < argc; j++) { script_action_autoload (argv[j], quiet, -1); } } else if (dogechat_strcasecmp (argv[0], "install") == 0) { script_found = 0; for (j = 1; j < argc; j++) { ptr_script = script_repo_search_by_name_ext (argv[j]); if (ptr_script) { if (ptr_script->status & SCRIPT_STATUS_HELD) { dogechat_printf (NULL, _("%s: script \"%s\" is held"), SCRIPT_PLUGIN_NAME, argv[j]); } else if ((ptr_script->status & SCRIPT_STATUS_INSTALLED) && !(ptr_script->status & SCRIPT_STATUS_NEW_VERSION)) { dogechat_printf (NULL, _("%s: script \"%s\" is already " "installed and up-to-date"), SCRIPT_PLUGIN_NAME, argv[j]); } else { script_found++; ptr_script->install_order = script_found; } } else { dogechat_printf (NULL, _("%s: script \"%s\" not found"), SCRIPT_PLUGIN_NAME, argv[j]); } } if (script_found) script_action_install (quiet); } else if (dogechat_strcasecmp (argv[0], "remove") == 0) { for (j = 1; j < argc; j++) { script_action_remove (argv[j], quiet); } } else if (dogechat_strcasecmp (argv[0], "installremove") == 0) { script_found = 0; for (j = 1; j < argc; j++) { ptr_script = script_repo_search_by_name_ext (argv[j]); if (ptr_script) { if (ptr_script->status & SCRIPT_STATUS_HELD) { dogechat_printf (NULL, _("%s: script \"%s\" is held"), SCRIPT_PLUGIN_NAME, argv[j]); } else if (ptr_script->status & SCRIPT_STATUS_INSTALLED) { script_action_remove (argv[j], quiet); } else { script_found++; ptr_script->install_order = script_found; } } else { dogechat_printf (NULL, _("%s: script \"%s\" not found"), SCRIPT_PLUGIN_NAME, argv[j]); } } if (script_found) script_action_install (quiet); } else if (dogechat_strcasecmp (argv[0], "hold") == 0) { script_found = 0; for (j = 1; j < argc; j++) { if (script_action_hold (argv[j], quiet)) script_found = 1; } if (script_found) script_buffer_refresh (0); } else if (dogechat_strcasecmp (argv[0], "show") == 0) { if (!script_buffer) script_buffer_open (); script_action_show ((argc >= 2) ? argv[1] : NULL, quiet); dogechat_buffer_set (script_buffer, "display", "1"); } else if (dogechat_strcasecmp (argv[0], "showdiff") == 0) { script_action_showdiff (); } else if (dogechat_strcasecmp (argv[0], "upgrade") == 0) { script_found = 0; for (ptr_script = scripts_repo; ptr_script; ptr_script = ptr_script->next_script) { /* * if script is installed, with new version available, * and not held, then upgrade it */ if ((ptr_script->status & SCRIPT_STATUS_INSTALLED) && (ptr_script->status & SCRIPT_STATUS_NEW_VERSION) && !(ptr_script->status & SCRIPT_STATUS_HELD)) { script_found++; ptr_script->install_order = script_found; } } if (script_found) script_action_install (quiet); else { dogechat_printf (NULL, _("%s: all scripts are up-to-date"), SCRIPT_PLUGIN_NAME); } } } if (argv) dogechat_string_free_split (argv); if (argv_eol) dogechat_string_free_split (argv_eol); } dogechat_string_free_split (actions); } free (script_actions); script_actions = NULL; return 1; }