3 /// Entry point for barrybackup GUI
7 Copyright (C) 2007, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
25 #include <libglademm.h>
26 #include <barry/barry.h>
27 #include "BackupWindow.h"
31 // The catch-all handler for exceptions that occur inside signals
33 void main_exception_handler()
38 catch( Glib::Exception
&e
) {
39 std::cerr
<< "Glib::Exception caught in main: " << std::endl
;
40 std::cerr
<< e
.what() << std::endl
;
41 Gtk::MessageDialog
msg(e
.what());
44 catch( std::exception
&e
) {
45 std::cerr
<< "std::exception caught in main: " << std::endl
;
46 std::cerr
<< e
.what() << std::endl
;
47 Gtk::MessageDialog
msg(e
.what());
54 // These are for debugging... hopefully should never need them in the field,
55 // but you never know...
58 void (*old_unexpected_handler
)() = 0;
59 void unexpected_handler()
61 std::cerr
<< "main.cc: Unexpected exception detected - check your throw() specifications" << std::endl
;
62 (*old_unexpected_handler
)();
65 void (*old_terminate_handler
)() = 0;
66 void terminate_handler()
68 std::cerr
<< "main.cc: terminate_handler() called - exception handling "
69 "could not complete, most likely due to exception inside "
70 "a destructor or catch()" << std::endl
;
71 (*old_terminate_handler
)();
76 int main(int argc
, char *argv
[])
78 old_unexpected_handler
= std::set_unexpected(&unexpected_handler
);
79 old_terminate_handler
= std::set_terminate(&terminate_handler
);
84 OptionEntry debug_opt
;
86 OptionEntry::FLAG_NO_ARG
|
87 OptionEntry::FLAG_IN_MAIN
|
88 OptionEntry::FLAG_OPTIONAL_ARG
);
89 debug_opt
.set_short_name('d');
90 debug_opt
.set_long_name("debug-output");
91 debug_opt
.set_description("Enable protocol debug output to stdout/stderr");
93 OptionGroup
option_group("barry",
94 "Options specific to the Barry Backup application.",
95 "Options specific to the Barry Backup application.");
96 bool debug_flag
= false;
97 option_group
.add_entry(debug_opt
, debug_flag
);
99 OptionContext
option_context("Backup program for the Blackberry Handheld");
100 option_context
.add_group(option_group
);
102 Gtk::Main
app(argc
, argv
, option_context
);
103 Glib::add_exception_handler( sigc::ptr_fun(main_exception_handler
) );
105 Barry::Init(debug_flag
);
109 Glib::RefPtr
<Gnome::Glade::Xml
> refXml
= LoadXml("BackupWindow.glade");
111 BackupWindow
*pWnd
= 0;
112 refXml
->get_widget_derived("BackupWindow", pWnd
);
113 std::auto_ptr
<BackupWindow
> apWnd(pWnd
);
115 Gtk::Main::run(*pWnd
);
119 main_exception_handler();