/[weechat]/weechat/src/common/command.c
ViewVC logotype

Diff of /weechat/src/common/command.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.89 by flashcode, Tue Nov 29 08:23:03 2005 UTC revision 1.90 by flashcode, Tue Dec 6 18:21:01 2005 UTC
# Line 24  Line 24 
24  #include "config.h"  #include "config.h"
25  #endif  #endif
26    
27    #include <unistd.h>
28  #include <stdlib.h>  #include <stdlib.h>
29  #include <string.h>  #include <string.h>
30    
# Line 31  Line 32 
32  #include "command.h"  #include "command.h"
33  #include "weelist.h"  #include "weelist.h"
34  #include "weeconfig.h"  #include "weeconfig.h"
35    #include "session.h"
36  #include "../irc/irc.h"  #include "../irc/irc.h"
37  #include "../gui/gui.h"  #include "../gui/gui.h"
38  #include "../plugins/plugins.h"  #include "../plugins/plugins.h"
# Line 77  t_weechat_command weechat_commands[] = Line 79  t_weechat_command weechat_commands[] =
79    { "history", N_("show buffer command history"),    { "history", N_("show buffer command history"),
80      N_("[clear | value]"),      N_("[clear | value]"),
81      N_("clear: clear history\n"      N_("clear: clear history\n"
82         "value: number of history entries to show"         "value: number of history entries to show"),
         ),  
83      0, 1, weechat_cmd_history, NULL },      0, 1, weechat_cmd_history, NULL },
84    { "ignore", N_("ignore IRC messages and/or hosts"),    { "ignore", N_("ignore IRC messages and/or hosts"),
85      N_("[mask [[type | command] [channel [server]]]]"),      N_("[mask [[type | command] [channel [server]]]]"),
# Line 143  t_weechat_command weechat_commands[] = Line 144  t_weechat_command weechat_commands[] =
144         "For each argument, '*' means all.\n"         "For each argument, '*' means all.\n"
145         "Without argument, /unignore command lists all defined ignore."),         "Without argument, /unignore command lists all defined ignore."),
146      0, 4, weechat_cmd_unignore, NULL },      0, 4, weechat_cmd_unignore, NULL },
147      { "upgrade", N_("upgrade WeeChat without disconnecting from servers"),
148        "",
149        "",
150        0, 0, weechat_cmd_upgrade, NULL },
151    { "uptime", N_("show WeeChat uptime"),    { "uptime", N_("show WeeChat uptime"),
152      N_("[-o]"),      N_("[-o]"),
153      N_("-o: send uptime on current channel as an IRC message"),      N_("-o: send uptime on current channel as an IRC message"),
# Line 760  user_command (t_irc_server *server, t_gu Line 765  user_command (t_irc_server *server, t_gu
765              command_with_colors2 = (command_with_colors) ?              command_with_colors2 = (command_with_colors) ?
766                  (char *)gui_color_decode ((unsigned char *)command_with_colors, 1) : NULL;                  (char *)gui_color_decode ((unsigned char *)command_with_colors, 1) : NULL;
767                            
768              if (CHANNEL(buffer)->type == CHAT_PRIVATE)              if (CHANNEL(buffer)->type == CHANNEL_TYPE_PRIVATE)
769              {              {
770                  gui_printf_type (CHANNEL(buffer)->buffer,                  gui_printf_type (CHANNEL(buffer)->buffer,
771                                   MSG_TYPE_NICK,                                   MSG_TYPE_NICK,
# Line 937  weechat_cmd_buffer_display_info (t_gui_b Line 942  weechat_cmd_buffer_display_info (t_gui_b
942      if (buffer->dcc)      if (buffer->dcc)
943          gui_printf (NULL, "%sDCC\n",          gui_printf (NULL, "%sDCC\n",
944                      GUI_COLOR(COLOR_WIN_CHAT_CHANNEL));                      GUI_COLOR(COLOR_WIN_CHAT_CHANNEL));
945      else if (BUFFER_IS_SERVER (buffer))      else if (BUFFER_IS_SERVER(buffer))
946          gui_printf (NULL, _("%sServer: %s%s\n"),      {
947                      GUI_COLOR(COLOR_WIN_CHAT),          if (SERVER(buffer))
948                      GUI_COLOR(COLOR_WIN_CHAT_SERVER),              gui_printf (NULL, _("%sServer: %s%s\n"),
949                      SERVER(buffer)->name);                          GUI_COLOR(COLOR_WIN_CHAT),
950                            GUI_COLOR(COLOR_WIN_CHAT_SERVER),
951                            SERVER(buffer)->name);
952            else
953                gui_printf (NULL, _("%snot connected\n"),
954                            GUI_COLOR(COLOR_WIN_CHAT));
955        }
956      else if (BUFFER_IS_CHANNEL (buffer))      else if (BUFFER_IS_CHANNEL (buffer))
957          gui_printf (NULL, _("%sChannel: %s%s %s(server: %s%s%s)\n"),          gui_printf (NULL, _("%sChannel: %s%s %s(server: %s%s%s)\n"),
958                      GUI_COLOR(COLOR_WIN_CHAT),                      GUI_COLOR(COLOR_WIN_CHAT),
# Line 961  weechat_cmd_buffer_display_info (t_gui_b Line 972  weechat_cmd_buffer_display_info (t_gui_b
972                      SERVER(buffer)->name,                      SERVER(buffer)->name,
973                      GUI_COLOR(COLOR_WIN_CHAT));                      GUI_COLOR(COLOR_WIN_CHAT));
974      else      else
975          gui_printf (NULL, _("not connected\n"));          gui_printf (NULL, _("%sunknown\n"),
976                        GUI_COLOR(COLOR_WIN_CHAT));
977  }  }
978    
979  /*  /*
# Line 1384  weechat_cmd_debug (int argc, char **argv Line 1396  weechat_cmd_debug (int argc, char **argv
1396            
1397      if (ascii_strcasecmp (argv[0], "dump") == 0)      if (ascii_strcasecmp (argv[0], "dump") == 0)
1398      {      {
1399          wee_dump (0);          weechat_dump (0);
1400      }      }
1401      else if (ascii_strcasecmp (argv[0], "windows") == 0)      else if (ascii_strcasecmp (argv[0], "windows") == 0)
1402      {      {
# Line 2795  weechat_cmd_unignore (int argc, char **a Line 2807  weechat_cmd_unignore (int argc, char **a
2807  }  }
2808    
2809  /*  /*
2810     * weechat_cmd_upgrade: upgrade WeeChat
2811     */
2812    
2813    int
2814    weechat_cmd_upgrade (int argc, char **argv)
2815    {
2816        t_irc_server *ptr_server;
2817        int filename_length;
2818        char *filename;
2819        char *exec_args[5] = { NULL, "-a", "--session", NULL, NULL };
2820        
2821        /* make gcc happy */
2822        (void) argc;
2823        (void) argv;
2824        
2825        for (ptr_server = irc_servers; ptr_server;
2826             ptr_server = ptr_server->next_server)
2827        {
2828            if (ptr_server->child_pid != 0)
2829            {
2830                irc_display_prefix (NULL, gui_current_window->buffer, PREFIX_ERROR);
2831                gui_printf_nolog (NULL,
2832                                  _("%s can't upgrade: connection to at least "
2833                                    "one server is pending"),
2834                                  WEECHAT_ERROR);
2835                return -1;
2836            }
2837        }
2838        
2839        filename_length = strlen (weechat_home) + strlen (WEECHAT_SESSION_NAME) + 2;
2840        filename = (char *) malloc (filename_length * sizeof (char));
2841        if (!filename)
2842            return -2;
2843        snprintf (filename, filename_length, "%s%s" WEECHAT_SESSION_NAME,
2844                  weechat_home, DIR_SEPARATOR);
2845        
2846        irc_display_prefix (NULL, NULL, PREFIX_INFO);
2847        gui_printf_nolog (NULL, _("Upgrading WeeChat...\n"));
2848        
2849        if (!session_save (filename))
2850        {
2851            free (filename);
2852            irc_display_prefix (NULL, NULL, PREFIX_ERROR);
2853            gui_printf_nolog (NULL,
2854                              _("%s unable to save session in file\n"),
2855                              WEECHAT_ERROR);
2856            return -1;
2857        }
2858        
2859        exec_args[0] = strdup (weechat_argv0);
2860        exec_args[3] = strdup (filename);
2861        
2862        /* unload plugins, save config, then upgrade */
2863    #ifdef PLUGINS    
2864        plugin_end ();
2865    #endif
2866        (void) config_write (NULL);
2867        gui_end ();
2868        
2869        execvp (exec_args[0], exec_args);
2870        
2871        /* this code should not be reached if execvp is ok */
2872    #ifdef PLUGINS
2873        plugin_init (1);
2874    #endif
2875        
2876        fprintf (stderr, _("%s exec failed (program: \"%s\"), exiting WeeChat\n"),
2877                 WEECHAT_ERROR,
2878                 exec_args[0]);
2879                    
2880        free (exec_args[0]);
2881        free (exec_args[3]);
2882        free (filename);
2883        
2884        weechat_shutdown (EXIT_FAILURE, 0);
2885        
2886        /* never executed */
2887        return -1;
2888    }
2889    
2890    /*
2891   * weechat_cmd_uptime: display WeeChat uptime   * weechat_cmd_uptime: display WeeChat uptime
2892   */   */
2893    

Legend:
Removed from v.1.89  
changed lines
  Added in v.1.90

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26