1 | // ============================================================= // |
---|
2 | // // |
---|
3 | // File : DI_main.cxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // ============================================================= // |
---|
10 | |
---|
11 | #include <servercntrl.h> |
---|
12 | #include <arbdb.h> |
---|
13 | #include <awt.hxx> |
---|
14 | |
---|
15 | #include <aw_preset.hxx> |
---|
16 | #include <aw_root.hxx> |
---|
17 | #include <macros.hxx> |
---|
18 | #include <aw_question.hxx> |
---|
19 | #include <awt_TreeAwars.hxx> |
---|
20 | |
---|
21 | |
---|
22 | AW_HEADER_MAIN |
---|
23 | |
---|
24 | AW_window *DI_create_matrix_window(AW_root *aw_root, GBDATA *gb_main); |
---|
25 | GB_ERROR DI_create_matrix_variables(AW_root *aw_root, AW_default aw_def, AW_default db); |
---|
26 | |
---|
27 | static unsigned DI_timer(AW_root*, GBDATA *gb_main) { |
---|
28 | { |
---|
29 | GB_transaction ta(gb_main); |
---|
30 | GB_tell_server_dont_wait(gb_main); // trigger database callbacks |
---|
31 | } |
---|
32 | return 500; // recall after 500 ms |
---|
33 | } |
---|
34 | |
---|
35 | int ARB_main(int argc, char *argv[]) { |
---|
36 | aw_initstatus(); |
---|
37 | |
---|
38 | GB_shell shell; |
---|
39 | AW_root *aw_root = AWT_create_root("dist.arb", "ARB_DIST", need_macro_ability()); |
---|
40 | |
---|
41 | if (argc >= 2 && strcmp(argv[1], "--help") == 0) { |
---|
42 | fprintf(stderr, |
---|
43 | "Usage: arb_dist\n" |
---|
44 | "Is called from ARB.\n" |
---|
45 | ); |
---|
46 | exit(EXIT_FAILURE); |
---|
47 | } |
---|
48 | |
---|
49 | GB_ERROR error = NULp; |
---|
50 | GBDATA *gb_main = NULp; |
---|
51 | { |
---|
52 | arb_params *params = arb_trace_argv(&argc, (const char **)argv); |
---|
53 | if (argc==2) { |
---|
54 | freedup(params->db_server, argv[1]); |
---|
55 | } |
---|
56 | gb_main = GB_open(params->db_server, "rw"); |
---|
57 | if (!gb_main) { |
---|
58 | error = GB_await_error(); |
---|
59 | } |
---|
60 | else { |
---|
61 | error = configure_macro_recording(aw_root, "ARB_DIST", gb_main); |
---|
62 | |
---|
63 | #if defined(DEBUG) |
---|
64 | if (!error) AWT_announce_db_to_browser(gb_main, GBS_global_string("ARB-database (%s)", params->db_server)); |
---|
65 | #endif // DEBUG |
---|
66 | } |
---|
67 | free_arb_params(params); |
---|
68 | } |
---|
69 | |
---|
70 | if (!error) { |
---|
71 | ARB_init_global_awars(aw_root, AW_ROOT_DEFAULT, gb_main); |
---|
72 | AWT_initTreeAwarRegistry(gb_main); |
---|
73 | error = DI_create_matrix_variables(aw_root, AW_ROOT_DEFAULT, gb_main); |
---|
74 | } |
---|
75 | if (!error) { |
---|
76 | AW_window *aww = DI_create_matrix_window(aw_root, gb_main); |
---|
77 | aww->show(); |
---|
78 | |
---|
79 | AWT_install_cb_guards(); |
---|
80 | |
---|
81 | aw_root->add_timed_callback(2000, makeTimedCallback(DI_timer, gb_main)); |
---|
82 | aw_root->main_loop(); |
---|
83 | } |
---|
84 | |
---|
85 | if (error) aw_popup_exit(error); |
---|
86 | return EXIT_SUCCESS; |
---|
87 | } |
---|
88 | |
---|