]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/qt-console/main.cpp
Backport from Bacula Enterprise
[bacula/bacula] / bacula / src / qt-console / main.cpp
index b34b49755c276d7eaf8e3f14d3bb5cab8d436dd3..9e8c723be1607d698201976e862a088aca9b2461 100644 (file)
@@ -1,36 +1,26 @@
 /*
-   Bacula® - The Network Backup Solution
-
-   Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
-
-   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 and included
-   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 Kern Sibbald.
-   The licensor of Bacula is the Free Software Foundation Europe
-   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
-   Switzerland, email:ftf@fsfeurope.org.
+   Bacula(R) - The Network Backup Solution
+
+   Copyright (C) 2000-2015 Kern Sibbald
+   Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
+
+   The original author of Bacula is Kern Sibbald, with contributions
+   from many others, a complete list can be found in the file AUTHORS.
+
+   You may use this file and others of this release according to the
+   license defined in the LICENSE file, which includes the Affero General
+   Public License, v3.0 ("AGPLv3") and some additional permissions and
+   terms pursuant to its AGPLv3 Section 7.
+
+   This notice must be preserved when any source code is 
+   conveyed and/or propagated.
+
+   Bacula(R) is a registered trademark of Kern Sibbald.
 */
 /*
- *   Version $Id$
- *
  *  Main program for bat (qt-console)
  *
- *   Kern Sibbald, January MMVII
+ *   Written by Kern Sibbald, January MMVII
  *
  */ 
 
 #include <QApplication>
 #include <QTranslator>
 
+/*
+ * We need Qt version 4.8.4 or later to be able to comple correctly
+ */
+#if QT_VERSION < 0x040804
+#error "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+#error "You need Qt version 4.8.4 or later to build Bat"
+#error "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
+#endif
+
 MainWin *mainWin;
 QApplication *app;
 
@@ -48,6 +47,8 @@ static void usage();
 static int check_resources();
 
 extern bool parse_bat_config(CONFIG *config, const char *configfile, int exit_code);
+extern void message_callback(int /* type */, char *msg);
+
 
 #define CONFIG_FILE "bat.conf"     /* default configuration file */
 
@@ -58,24 +59,24 @@ static char *configfile = NULL;
 int main(int argc, char *argv[])
 {
    int ch;
-   int rc;
    bool no_signals = true;
    bool test_config = false;
 
 
    app = new QApplication(argc, argv);        
+   app->setStyle(new QPlastiqueStyle());
    app->setQuitOnLastWindowClosed(true);
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
      
    QTranslator qtTranslator;
-   qtTranslator.load(QString("qt_") + QLocale::system().name());
+   qtTranslator.load(QString("qt_") + QLocale::system().name(),QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    app->installTranslator(&qtTranslator);
 
    QTranslator batTranslator;
-   batTranslator.load(QString("bat_") + QLocale::system().name());
+   batTranslator.load(QString("bat_") + QLocale::system().name(),QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    app->installTranslator(&batTranslator);
 
-
+   register_message_callback(message_callback);
 
 #ifdef xENABLE_NLS
    setlocale(LC_ALL, "");
@@ -83,18 +84,24 @@ int main(int argc, char *argv[])
    textdomain("bacula");
 #endif
 
+#ifdef HAVE_WIN32
+   set_trace(true);          /* output to trace file */
+#endif
+
    init_stack_dump();
    my_name_is(argc, argv, "bat");
+   lmgr_init_thread();
    init_msg(NULL, NULL);
    working_directory  = "/tmp";
 
+#ifndef HAVE_WIN32
    struct sigaction sigignore;
    sigignore.sa_flags = 0;
    sigignore.sa_handler = SIG_IGN;
    sigfillset(&sigignore.sa_mask);
    sigaction(SIGPIPE, &sigignore, NULL);
    sigaction(SIGUSR2, &sigignore, NULL);
-
+#endif
 
    while ((ch = getopt(argc, argv, "bc:d:r:st?")) != -1) {
       switch (ch) {
@@ -155,18 +162,21 @@ int main(int argc, char *argv[])
    if (!check_resources()) {
       Emsg1(M_ERROR_TERM, 0, _("Please correct configuration file: %s\n"), configfile);
    }
+   if (test_config) {
+      exit(0);
+   }
 
    mainWin = new MainWin;
    mainWin->show();
 
-   rc = app->exec();
-// sm_dump(false);
-   return rc;
+   return app->exec();
 }
 
 void terminate_console(int /*sig*/)
 {
-// WSA_Cleanup();                  /* TODO: check when we have to call it */
+#ifdef HAVE_WIN32
+   WSACleanup();                  /* TODO: check when we have to call it */
+#endif
    exit(0);
 }