]> git.sur5r.net Git - bacula/bacula/commitdiff
- console_thread : Added support for the new parse_config which returns a status...
authorNicolas Boichat <nicolas@boichat.ch>
Sat, 8 May 2004 09:57:20 +0000 (09:57 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Sat, 8 May 2004 09:57:20 +0000 (09:57 +0000)
 - wxbMainFrame/console_thread : A command line parameter now allows the user to choose his config file.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1348 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/wx-console/CHANGELOG
bacula/src/wx-console/TODO
bacula/src/wx-console/console_thread.cpp
bacula/src/wx-console/console_thread.h
bacula/src/wx-console/wxbmainframe.cpp

index f171005a90580067ee8d40eaa69ee31d0880c4a8..f04b99b4e5b246d14692a3213083b546f30b4099 100644 (file)
@@ -1,3 +1,9 @@
+07-05-2004 :
+ - console_thread : Added support for the new parse_config which
+      returns a status code.
+ - wxbMainFrame/console_thread : A command line parameter now
+      allows the user to choose his config file.
+
 06-05-2004 :
  - wxbMainFrame : Corrected font bug in GTK+ 1.2
  - console_thread : Added support for Mac OS X configuration
index 1541ad0309172d797d4362456f06bf1e49fba6c1..638810ea5382275e2f0cc0ed7b185bb6d7418531 100644 (file)
@@ -1,10 +1,16 @@
 FEATURES
 --------
 
-wxbRestorePanel : When cancelling, check for commands results
-
 general : Show nice messages boxes when errors occurs.
 
+console_thread : Check for config file parsing error messages
+    in console file.
+
+console_thread : Allow the user to choose his config file.
+
+console_thread : Allow the user to choose his director when there's multiple
+    directors.
+
 Mac OS X : Integrate Mac OS X into the automake process
   (note : add -DNO_GCC_PRAGMA to CPPFLAGS, build app,
   define HAVE_MACOSX)
@@ -19,6 +25,8 @@ Mac OS X : Ask kern for the status of this distribution (who is
 
 [postponed to July:]
 
+wxbRestorePanel : When cancelling, check for commands results
+
 general : Do not quit when configuration file not found.
 
 wxbRestorePanel : Add a way to cancel restore when building tree
@@ -55,11 +63,6 @@ general : Implement dis/reconnecting
 wxbRestorePanel : Use ".default job=RestoreFiles" to get defaults parameters
        when changing a restore parameter fails.
 
-console_thread : Allow the user to choose his config file.
-
-console_thread : Allow the user to choose his director when there's multiple
-    directors.
-
 wxbDataParser : Add a boolean in the constructor to avoid storing data is 
     will not be used.
 
index ebf36055fdfcf63d0b18e30a54ef18313577860b..3baadff4df09b52bb1eea0ec8f59883294d46334 100644 (file)
@@ -42,18 +42,13 @@ char OK_msg[]   = "2000 OK\n";
 char TERM_msg[] = "2999 Terminate\n";
 #endif
 
-#ifdef HAVE_MACOSX
-#define CONFIGFILE "/Library/Preferences/org.bacula.wxconsole/wx-console.conf"
-#else
-#define CONFIGFILE "./wx-console.conf"
-#endif
-
 /* Imported functions */
 int authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons);
 
 // class constructor
-console_thread::console_thread() {
+console_thread::console_thread(wxString configfile) {
    UA_sock = NULL;
+   this->configfile = configfile;
 }
 
 // class destructor
@@ -87,11 +82,34 @@ void* console_thread::Entry() {
    init_stack_dump();
    my_name_is(0, NULL, "wx-console");
    //textdomain("bacula-console");
-   init_msg(NULL, NULL);
+   
+   MSGS* msgs = (MSGS *)malloc(sizeof(MSGS));
+   memset(msgs, 0, sizeof(MSGS));
+   for (int i=1; i<=M_MAX; i++) {
+#ifndef WIN32
+      add_msg_dest(msgs, MD_STDOUT, i, NULL, NULL);
+#endif
+      add_msg_dest(msgs, MD_SYSLOG, i, NULL, NULL);
+      add_msg_dest(msgs, MD_CONSOLE, i, NULL, NULL);
+   }
+   
+   init_msg(NULL, msgs);
+   init_console_msg(".");
 
    /* TODO (#4#): Allow the user to choose his config file. */
-   parse_config(CONFIGFILE);
-
+   if (!parse_config(configfile.c_str(), 0)) {
+      csprint("Unable to read configuration file.\n");
+      csprint(NULL, CS_END);
+      csprint(NULL, CS_DISCONNECTED);
+      csprint(NULL, CS_TERMINATED);
+      #ifdef HAVE_WIN32
+         Exit();
+      #endif
+      return NULL;
+   }
+   
+   init_msg(NULL, NULL);
+   
    LockRes();
    DIRRES *dir = (DIRRES *)GetNextRes(R_DIRECTOR, NULL);
    UnlockRes();
index 50f5703a2a171d52b418c92a2a708fef991fd36c..419fe0eec493b0333f5c8f4bebb645caaf0142d4 100644 (file)
@@ -39,7 +39,7 @@ class console_thread : public wxThread
 {
    public:
       // class constructor
-      console_thread();
+      console_thread(wxString configfile);
       // class destructor
       ~console_thread();
 
@@ -49,6 +49,7 @@ class console_thread : public wxThread
    private:
       BSOCK* UA_sock;
       JCR jcr;
+      wxString configfile;
 };
 
 int pm_cst_strcpy(POOLMEM **pm, const char *str);
index d066bc92373519cd5c19b9b574c624b275305746..560cf5954f06503b29b268bf9c184f5488215f59 100644 (file)
@@ -299,7 +299,26 @@ void wxbMainFrame::StartConsoleThread()
    else {
       promptparser = new wxbPromptParser();      
    }
-   ct = new console_thread();
+   
+   wxString configfile;
+   
+   
+   if ((wxTheApp->argc == 3) && (wxString(wxTheApp->argv[1]) == "-c")) {
+      configfile = wxTheApp->argv[2];
+   }
+   else {
+#ifdef HAVE_MACOSX
+      configfile = "/Library/Preferences/org.bacula.wxconsole.conf";
+#else
+      configfile = "./wx-console.conf";
+#endif
+      if (wxTheApp->argc > 1) {
+         Print("Error while parsing command line arguments, using defaults.\n", CS_DEBUG);
+         Print("Usage: wx-console [-c configfile]\n", CS_DEBUG);
+      }
+   }
+   
+   ct = new console_thread(configfile);
    ct->Create();
    ct->Run();
    SetStatusText("Connecting to the director...");