3 * Copyright (C) 2007, Rus V. Brushkoff, All rights reserved.
11 #include <FL/Fl_Preferences.H>
12 #include <cc++/socket.h>
20 #define SFINX_LOG_DEBUG 0
21 #define SFINX_LOG_NOTICE 1
22 #define SFINX_LOG_WARN 2
23 #define SFINX_LOG_ERROR 3
24 #define SFINX_LOG_FATAL 4
26 class app_specific_ui {
33 virtual ~app_specific_ui() { }
34 virtual void log(int level, const char *fmt, ...) = 0;
35 virtual void fill_slices_tree(sfinx_slice_vector_t *) = 0;
36 virtual void fill_notes_tree(sfinx_slice_vector_t *) = 0;
37 virtual void fill_select_slice_tree(sfinx_slice_vector_t *) = 0;
38 virtual void edit_slice(sfinx_slice_t *slice) = 0;
39 virtual void fill_preferences() = 0;
40 virtual void fill_files_module_tree(sfinx_files_vector_t *) = 0;
41 virtual void progress(sfinx_progress_t *) = 0;
42 virtual void files_module_classify_reply(sfinx_string_t *) = 0;
43 virtual void files_module_edit_reply(sfinx_string_t *) = 0;
44 virtual void files_module_edit(sfinx_file_t *) = 0;
45 virtual void notes_module_edit_reply(sfinx_string_t *) = 0;
46 virtual void notes_module_edit(sfinx_note_t *) = 0;
47 virtual void alert(sfinx_string_t *) = 0;
48 virtual void search_browser(sfinx_pair_vector_t *) = 0;
49 virtual void prepare_search_info (sfinx_t *el, string &inf) = 0;
50 virtual void notes_module_add_reply(sfinx_string_t *) = 0;
52 void lock() { big_lock.enterMutex(); }
53 void unlock() { big_lock.leaveMutex(); }
56 class x11_ui: public F_FLTK_UI, public app_specific_ui {
58 x11_ui() : F_FLTK_UI() { }
61 void log(int level, const char *fmt, ...);
62 void fill_slices_tree(sfinx_slice_vector_t *);
63 void fill_notes_tree(sfinx_slice_vector_t *);
64 void fill_select_slice_tree(sfinx_slice_vector_t *);
65 void edit_slice(sfinx_slice_t *slice);
66 void fill_preferences();
67 void fill_files_module_tree(sfinx_files_vector_t *);
68 void progress(sfinx_progress_t *);
69 void files_module_classify_reply(sfinx_string_t *);
70 void files_module_edit_reply(sfinx_string_t *);
71 void files_module_edit(sfinx_file_t *);
72 void notes_module_edit(sfinx_note_t *);
73 void notes_module_edit_reply(sfinx_string_t *);
74 void alert(sfinx_string_t *);
75 void search_browser(sfinx_pair_vector_t *);
76 void prepare_search_info (sfinx_t *el, string &inf);
77 void notes_module_add_reply(sfinx_string_t *);
80 class faraon_app : public F_App {
81 // available ui's for this app
86 connection_to_sfinx sfinx;
89 sfinx_pair_vector_t files_module_conf;
90 sfinx_slice_vector_t slices, notes; // TODO: make this single cached objects tree
92 faraon_app(int argc, char **argv, const char *name = 0,
93 const char *version = 0, const char *author = 0,
94 const char *license = 0, CommandOption *opts = 0) :
95 F_App(argc, argv, name, version, author, license, opts) {
96 files_module_conf.tid(SFINX_FILES_MODULE_CONF);
97 files_module_conf.add(FILES_MODULE_UNSORTED_PATH, new sfinx_string_t);
98 files_module_conf.add(FILES_MODULE_SORTED_TREE_PATH, new sfinx_string_t);
99 files_module_conf.add(FILES_MODULE_DESC_FILE_ENABLE, new sfinx_8bit_t);
100 files_module_conf.add(FILES_MODULE_DESC_FILE_NAME, new sfinx_string_t);
102 app_specific_ui *ui() { return dynamic_cast<app_specific_ui *>(ui_); }
104 void read_preferences();
105 void write_preferences();
107 bool connected() { return sfinx.connected(); }
109 bool process_requests();
110 string slice_name(sfinx_id_t slice_id) {
111 sfinx_slice_t *slice = slices.find(slice_id);
117 t += slice->description();
121 string slice_hierarchy(sfinx_id_t sid) {
123 sfinx_slice_t *slice;
125 slice = slices.find(sid);
128 string t = slice->name();
130 t += slice->description();
132 sid = slice->parent_id;
137 for (int32_t i = h.size() - 1; i >= 0; i--) {
147 extern faraon_app *app;