]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/gnome2-console/console.c
kes Convert dbcheck to use 64 bit DB IDs.
[bacula/bacula] / bacula / src / gnome2-console / console.c
index e2223c49a25f1f2b3159f8a3c9300a7e1d41fcdf..063fce15a1f4f70f048e58ebe3f25a0d5dee0dc1 100644 (file)
@@ -7,19 +7,32 @@
  *     Version $Id$
  */
 /*
-   Copyright (C) 2002-2005 Kern Sibbald
+   Bacula® - The Network Backup Solution
 
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License
-   version 2 as amended with additional clauses defined in the
-   file LICENSE in the main source directory.
+   Copyright (C) 2002-2006 Free Software Foundation Europe e.V.
 
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
-   the file LICENSE for additional details.
+   The main author of Bacula is Kern Sibbald, with contributions from
+   many others, a complete list can be found in the file AUTHORS.
+   This program is Free Software; you can redistribute it and/or
+   modify it under the terms of version two of the GNU General Public
+   License as published by the Free Software Foundation plus additions
+   that are listed in the file LICENSE.
 
- */
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
 
 #include "bacula.h"
 #include "console.h"
@@ -48,8 +61,8 @@ GtkWidget *restore_file_selection;
 GtkWidget *dir_select;
 GtkWidget *about1;           /* about box */
 GtkWidget *label_dialog;
-GdkFont   *text_font = NULL;
-PangoFontDescription *font_desc;
+PangoFontDescription *font_desc = NULL;
+PangoFontDescription *text_font_desc = NULL;
 pthread_mutex_t cmd_mutex = PTHREAD_MUTEX_INITIALIZER;
 pthread_cond_t  cmd_wait;
 char cmd[1000];
@@ -85,15 +98,15 @@ static int numdir = 0;
 static void usage()
 {
    fprintf(stderr, _(
-"Copyright (C) 2002-2005 Kern Sibbald\n"
-"\nVersion: " VERSION " (" BDATE ") %s %s %s\n\n"
+PROG_COPYRIGHT
+"\nVersion: %s (%s) %s %s %s\n\n"
 "Usage: gnome-console [-s] [-c config_file] [-d debug_level] [config_file]\n"
 "       -c <file>   set configuration file to file\n"
 "       -dnn        set debug level to nn\n"
 "       -s          no signals\n"
 "       -t          test - read configuration and exit\n"
 "       -?          print this message.\n"
-"\n"), HOST_OS, DISTNAME, DISTVER);
+"\n"), 2002, VERSION, BDATE, HOST_OS, DISTNAME, DISTVER);
 
    exit(1);
 }
@@ -124,7 +137,7 @@ static int tls_pem_callback(char *buf, int size, const void *userdata)
  */
 static int check_resources()
 {
-   int xOK = true;
+   bool ok = true;
    DIRRES *director;
 
    LockRes();
@@ -138,7 +151,7 @@ static int check_resources()
             director->tls_enable = true;
          } else {
             Jmsg(NULL, M_FATAL, 0, _("TLS required but not configured in Bacula.\n"));
-            xOK = false;
+            ok = false;
             continue;
          }
       }
@@ -148,14 +161,14 @@ static int check_resources()
                              " or \"TLS CA Certificate Dir\" are defined for Director \"%s\" in %s."
                              " At least one CA certificate store is required.\n"),
                              director->hdr.name, configfile);
-         xOK = false;
+         ok = false;
       }
    }
    
    if (numdir == 0) {
       Emsg1(M_FATAL, 0, _("No Director resource defined in %s\n"
                           "Without that I don't how to speak to the Director :-(\n"), configfile);
-      xOK = false;
+      ok = false;
    }
 
    CONRES *cons;
@@ -167,7 +180,7 @@ static int check_resources()
             cons->tls_enable = true;
          } else {
             Jmsg(NULL, M_FATAL, 0, _("TLS required but not configured in Bacula.\n"));
-            xOK = false;
+            ok = false;
             continue;
          }
       }
@@ -176,13 +189,13 @@ static int check_resources()
          Emsg2(M_FATAL, 0, _("Neither \"TLS CA Certificate\""
                              " or \"TLS CA Certificate Dir\" are defined for Console \"%s\" in %s.\n"),
                              cons->hdr.name, configfile);
-         xOK = false;
+         ok = false;
       }
    }
 
    UnlockRes();
 
-   return xOK;
+   return ok;
 }
 
 
@@ -200,6 +213,12 @@ int main(int argc, char *argv[])
    const char *gargv[2] = {"gnome-console", NULL};
    CONFONTRES *con_font;
 
+#ifdef ENABLE_NLS
+   setlocale(LC_ALL, "");
+   bindtextdomain("bacula", LOCALEDIR);
+   textdomain("bacula");
+#endif
+
    init_stack_dump();
    my_name_is(argc, argv, "gnome-console");
    init_msg(NULL, NULL);
@@ -263,8 +282,8 @@ int main(int argc, char *argv[])
 
    parse_config(configfile);
 
-   if (init_tls() != 0) {
-      Emsg0(M_ERROR_TERM, 0, _("TLS library initialization failed.\n"));
+   if (init_crypto() != 0) {
+      Emsg0(M_ERROR_TERM, 0, _("Cryptography library initialization failed.\n"));
    }
 
    if (!check_resources()) {
@@ -288,12 +307,7 @@ int main(int argc, char *argv[])
    gtk_widget_show(console);
 
 /*
- * Thanks to Phil Stracchino for providing the font configuration code.
- * original default:
-   text_font = gdk_font_load("-misc-fixed-medium-r-normal-*-*-130-*-*-c-*-koi8-r");
- * this works for me:
-   text_font = gdk_font_load("-Bigelow & Holmes-lucida console-medium-r-semi condensed-*-12-0-100-100-m-0-iso8859-1");
- * and, new automagic:font specification!
+ * Gtk2/pango have different font names. Gnome2 comes with "Monospace 10"
  */
 
    LockRes();
@@ -302,8 +316,9 @@ int main(int argc, char *argv[])
           Dmsg1(400, "No fontface for %s\n", con_font->hdr.name);
           continue;
        }
-       text_font = gdk_font_load(con_font->fontface);
-       if (text_font == NULL) {
+       Dmsg1(100, "Now loading: %s\n",con_font->fontface);
+       text_font_desc = pango_font_description_from_string(con_font->fontface);
+       if (text_font_desc == NULL) {
            Dmsg2(400, "Load of requested ConsoleFont \"%s\" (%s) failed!\n",
                   con_font->hdr.name, con_font->fontface);
        } else {
@@ -313,17 +328,24 @@ int main(int argc, char *argv[])
        }
    }
    UnlockRes();
-
-   if (text_font == NULL) {
-       Dmsg1(400, "Attempting to load fallback font %s\n",
-              "-misc-fixed-medium-r-normal-*-*-130-*-*-c-*-iso8859-1");
-       text_font = gdk_font_load("-misc-fixed-medium-r-normal-*-*-130-*-*-c-*-iso8859-1");
-   }
+    
    font_desc = pango_font_description_from_string("LucidaTypewriter 9");
+   if (!text_font_desc) {
+      text_font_desc = pango_font_description_from_string("Monospace 10");
+   }
+   if (!text_font_desc) {
+      text_font_desc = pango_font_description_from_string("monospace");
+   }
+
    gtk_widget_modify_font(console, font_desc);
-   gtk_widget_modify_font(text1, font_desc);
    gtk_widget_modify_font(entry1, font_desc);
    gtk_widget_modify_font(status1, font_desc);
+   if (text_font_desc) {
+      gtk_widget_modify_font(text1, text_font_desc);
+      pango_font_description_free(text_font_desc);
+   } else {
+      gtk_widget_modify_font(text1, font_desc);
+   }
    pango_font_description_free(font_desc);
 
    if (test_config) {
@@ -395,13 +417,13 @@ static GList *get_list(char *cmd)
 
 }
 
-static GList *get_and_fill_combo(GtkWidget *dialog, const char *combo_name, const char *cm)
+static GList *get_and_fill_combo(GtkWidget *dialog, const char *combo_name, const char *dircmd)
 {
    GtkWidget *combo;
    GList *options;
 
    combo = lookup_widget(dialog, combo_name);
-   options = get_list(cmd);
+   options = get_list((char *)dircmd);
    if (combo && options) {
       gtk_combo_set_popdown_strings(GTK_COMBO(combo), options);
    }
@@ -491,7 +513,7 @@ int connect_to_director(gpointer data)
    /* Initialize Console TLS context */
    if (cons && (cons->tls_enable || cons->tls_require)) {
       /* Generate passphrase prompt */
-      bsnprintf(buf, sizeof(buf), "Passphrase for Console \"%s\" TLS private key: ", cons->hdr.name);
+      bsnprintf(buf, sizeof(buf), _("Passphrase for Console \"%s\" TLS private key: "), cons->hdr.name);
 
       /* Initialize TLS context:
        * Args: CA certfile, CA certdir, Certfile, Keyfile,
@@ -513,7 +535,7 @@ int connect_to_director(gpointer data)
    /* Initialize Director TLS context */
    if (dir->tls_enable || dir->tls_require) {
       /* Generate passphrase prompt */
-      bsnprintf(buf, sizeof(buf), "Passphrase for Director \"%s\" TLS private key: ", dir->hdr.name);
+      bsnprintf(buf, sizeof(buf), _("Passphrase for Director \"%s\" TLS private key: "), dir->hdr.name);
 
       /* Initialize TLS context:
        * Args: CA certfile, CA certdir, Certfile, Keyfile,
@@ -532,7 +554,7 @@ int connect_to_director(gpointer data)
    }
 
 
-   UA_sock = bnet_connect(NULL, 5, 15, "Director daemon", dir->address,
+   UA_sock = bnet_connect(NULL, 5, 15, _("Director daemon"), dir->address,
                           NULL, dir->DIRport, 0);
    if (UA_sock == NULL) {
       return 0;
@@ -544,7 +566,7 @@ int connect_to_director(gpointer data)
       return 0;
    }
 
-   set_status(" Initializing ...");
+   set_status(_(" Initializing ..."));
 
    bnet_fsend(UA_sock, "autodisplay on");
 
@@ -580,7 +602,7 @@ int connect_to_director(gpointer data)
    fill_combo(restore_dialog, "combo_restore_pool", pool_list);
    fill_combo(restore_dialog, "combo_restore_storage", storage_list);
 
-   set_status(" Connected");
+   set_status(_(" Connected"));
    return 1;
 }
 
@@ -672,7 +694,7 @@ void terminate_console(int sig)
    if (already_here)                  /* avoid recursive temination problems */
       exit(1);
    already_here = true;
-   cleanup_tls();
+   cleanup_crypto();
    disconnect_from_director((gpointer)NULL);
    gtk_main_quit();
    exit(0);
@@ -743,7 +765,7 @@ void set_statusf(const char *fmt, ...)
 
 void set_status_ready()
 {
-   gtk_label_set_text(GTK_LABEL(status1), " Ready");
+   gtk_label_set_text(GTK_LABEL(status1), _(" Ready"));
    ready = true;
 // set_scroll_bar_to_end();
 }