+console_thread: Find an alternate way to get error messages, without using
+ a temporary file. (See Kern's mail 15.11.04 - 17:32)
+
general : Show nice messages boxes when errors occurs.
general : Bug reported by Kern:
bool console_thread::inited = false;
bool console_thread::configloaded = false;
+wxString console_thread::working_dir = ".";
+
+void console_thread::SetWorkingDirectory(wxString w_dir) {
+ if ((w_dir.Last() == '/') || (w_dir.Last() == '\\')) {
+ console_thread::working_dir = w_dir.Mid(0, w_dir.Length()-1);
+ }
+ else {
+ console_thread::working_dir = w_dir;
+ }
+}
void console_thread::InitLib() {
if (WSA_Init() != 0) {
init_stack_dump();
my_name_is(0, NULL, "wx-console");
//textdomain("bacula-console");
- working_directory = ".";
+ working_directory = console_thread::working_dir;
inited = true;
}
}
init_msg(NULL, msgs);
- init_console_msg(".");
+ init_console_msg(console_thread::working_dir);
if (!parse_config(configfile.c_str(), 0)) {
configloaded = false;
- wxFile file("./wx-console.conmsg");
+ wxFile file(console_thread::working_dir + "/wx-console.conmsg");
if (!file.IsOpened())
return "Unable to retrieve error message.";
wxString err = "";
}
file.Close();
term_msg();
- wxRemoveFile("./wx-console.conmsg");
+ wxRemoveFile(console_thread::working_dir + "/wx-console.conmsg");
return err;
}
term_msg();
- wxRemoveFile("./wx-console.conmsg");
+ wxRemoveFile(console_thread::working_dir + "/wx-console.conmsg");
init_msg(NULL, NULL);
configloaded = true;
static void InitLib();
static void FreeLib();
static wxString LoadConfig(wxString configfile);
+ static void SetWorkingDirectory(wxString w_dir);
private:
static bool inited;
static bool configloaded;
bool choosingdirector;
+ static wxString working_dir;
+
int directorchoosen;
BSOCK* UA_sock;
promptparser = new wxbPromptParser();
}
- if (config == "") {
- if ((wxTheApp->argc == 3) && (wxString(wxTheApp->argv[1]) == "-c")) {
- configfile = wxTheApp->argv[2];
+ if (config == "") {
+ configfile = "";
+
+ if (((wxTheApp->argc % 2) != 1)) {
+ Print("Error while parsing command line arguments, using defaults.\n", CS_DEBUG);
+ Print("Usage: wx-console [-c configfile] [-w tmp]\n", CS_DEBUG);
}
else {
+ for (int c = 1; c < wxTheApp->argc; c += 2) {
+ if ((wxTheApp->argc >= c+2) && (wxString(wxTheApp->argv[c]) == "-c")) {
+ configfile = wxTheApp->argv[c+1];
+ }
+ if ((wxTheApp->argc >= c+2) && (wxString(wxTheApp->argv[c]) == "-w")) {
+ console_thread::SetWorkingDirectory(wxTheApp->argv[c+1]);
+ }
+ if (wxTheApp->argv[c][0] != '-') {
+ Print("Error while parsing command line arguments, using defaults.\n", CS_DEBUG);
+ Print("Usage: wx-console [-c configfile] [-w tmp]\n", CS_DEBUG);
+ break;
+ }
+ }
+ }
+
+ if (configfile == "") {
wxConfig::Set(new wxConfig("wx-console", "bacula"));
if (!wxConfig::Get()->Read("/ConfigFile", &configfile)) {
#ifdef HAVE_MACOSX
#endif //HAVE_WIN32
#endif //HAVE_MACOSX
wxConfig::Get()->Write("/ConfigFile", configfile);
- 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);
- }
int answer = wxMessageBox(
wxString("It seems that it is the first time you run wx-console.\n") <<