From: Nicolas Boichat Date: Sat, 8 May 2004 09:57:20 +0000 (+0000) Subject: - console_thread : Added support for the new parse_config which returns a status... X-Git-Tag: Release-1.34.3~52 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=373b0de5e0bc2f2f076b17d70bd810febc03c9c8;p=bacula%2Fbacula - 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. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1348 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/wx-console/CHANGELOG b/bacula/src/wx-console/CHANGELOG index f171005a90..f04b99b4e5 100644 --- a/bacula/src/wx-console/CHANGELOG +++ b/bacula/src/wx-console/CHANGELOG @@ -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 diff --git a/bacula/src/wx-console/TODO b/bacula/src/wx-console/TODO index 1541ad0309..638810ea53 100644 --- a/bacula/src/wx-console/TODO +++ b/bacula/src/wx-console/TODO @@ -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. diff --git a/bacula/src/wx-console/console_thread.cpp b/bacula/src/wx-console/console_thread.cpp index ebf36055fd..3baadff4df 100644 --- a/bacula/src/wx-console/console_thread.cpp +++ b/bacula/src/wx-console/console_thread.cpp @@ -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(); diff --git a/bacula/src/wx-console/console_thread.h b/bacula/src/wx-console/console_thread.h index 50f5703a2a..419fe0eec4 100644 --- a/bacula/src/wx-console/console_thread.h +++ b/bacula/src/wx-console/console_thread.h @@ -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); diff --git a/bacula/src/wx-console/wxbmainframe.cpp b/bacula/src/wx-console/wxbmainframe.cpp index d066bc9237..560cf5954f 100644 --- a/bacula/src/wx-console/wxbmainframe.cpp +++ b/bacula/src/wx-console/wxbmainframe.cpp @@ -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...");