From 35160dac885f7bb60dcf58566c523d4856c4fa0c Mon Sep 17 00:00:00 2001 From: Harbour Date: Sat, 26 Apr 2008 12:48:37 +0300 Subject: [PATCH] . --- faraon/faraon.C | 14 +- faraon/file.xpm | 23 + faraon/x11_ui.C | 1046 +++++++++++++++++++++++++-------------------- faraon/x11_ui.H | 25 +- faraon/x11_ui.fl | 856 ++++++++++++++++++++----------------- include/elements.H | 75 ++-- include/faraon.H | 6 +- include/proto_data.H | 6 +- include/sfinx.H | 21 +- scripts/db.sql | 1 + scripts/sfinx_compress.sh | 1 - sfinx/sfinx.C | 459 ++++++++++---------- 12 files changed, 1376 insertions(+), 1157 deletions(-) create mode 100644 faraon/file.xpm diff --git a/faraon/faraon.C b/faraon/faraon.C index f431586..6cdec54 100644 --- a/faraon/faraon.C +++ b/faraon/faraon.C @@ -18,6 +18,11 @@ bool faraon_app::process_requests() sfinx_t *el; while ((el = sfinx.rx_elements.next())) { switch (el->tid()) { + case SFINX_NOTES_MODULE_UNSORT_REPLY: + case SFINX_NOTES_MODULE_UNLINK_REPLY: + case SFINX_FILES_MODULE_SORTED_UNLINK_REPLY: + case SFINX_FILES_MODULE_UNSORT_REPLY: + break; case SFINX_NOTES_MODULE_EDIT_REPLY: ui()->notes_module_reply((sfinx_string_t *)el); break; @@ -37,20 +42,17 @@ bool faraon_app::process_requests() ui()->notes_module_reply((sfinx_string_t *)el); break; case SFINX_FILES_MODULE_EDIT_REPLY: - ui()->files_module_edit_reply((sfinx_string_t *)el); - break; case SFINX_FILES_MODULE_CLASSIFY_REPLY: - ui()->files_module_classify_reply((sfinx_string_t *)el); + ui()->files_module_edit_reply((sfinx_string_t *)el); break; case SFINX_ELEMENT_PROGRESS: ui()->progress((sfinx_progress_t *)el); break; // case SFINX_FILES_MODULE_SORTED_TREE: case SFINX_FILES_MODULE_UNSORTED_TREE: - ui()->fill_files_module_tree((sfinx_files_vector_t *)el); + ui()->fill_unsorted_files_tree((sfinx_files_vector_t *)el); break; case SFINX_FILES_MODULE_CONF: - // set files module conf files_module_conf.copy(el); ui()->fill_preferences(); break; @@ -58,7 +60,6 @@ bool faraon_app::process_requests() ui()->edit_slice((sfinx_slice_t *)el); break; case SFINX_OBJECTS_TREE: - //ui()->fill_slices_tree((sfinx_slice_vector_t *)el); slices.copy((sfinx_slice_vector_t *)el); slices_need_update = false; ui()->fill_objects_tree(); @@ -74,6 +75,7 @@ bool faraon_app::process_requests() // main loop void faraon_app::main() { + sfinx.send(SFINX_FILES_MODULE_CONF_REQUEST, (u8_t) 0); // after connecting get all objects info refresh_slices(1); while(1) { diff --git a/faraon/file.xpm b/faraon/file.xpm new file mode 100644 index 0000000..155a42d --- /dev/null +++ b/faraon/file.xpm @@ -0,0 +1,23 @@ +/* XPM */ +static const char * file_xpm_data[] = { +"16 16 4 1", +" s None c None", +". c white", +"X c steelblue1", +"o c black", +" ", +" ", +" ..........X ", +" .XXXXXXXXXo ", +" .XXXXXXXXXo ", +" .XXoooooooo ", +" .XXo ", +" .XXX...X ", +" .XXXXXXo ", +" .XXXXXXo ", +" .XXooooo ", +" .XXo ", +" .XXo ", +" .XXo ", +" oooo ", +" "}; diff --git a/faraon/x11_ui.C b/faraon/x11_ui.C index 4aaca6e..3605d69 100644 --- a/faraon/x11_ui.C +++ b/faraon/x11_ui.C @@ -8,16 +8,19 @@ #include #include "slice.xpm" #include "note.xpm" +#include "file.xpm" static Fl_Pixmap slice_pixmap(slice_xpm_data); static Fl_Pixmap note_pixmap(note_xpm_data); +static Fl_Pixmap file_pixmap(file_xpm_data); Fl_Toggle_Tree *config_tree; Fl_Toggle_Tree *slices_tree; Fl_Toggle_Tree *select_slice_tree; Fl_Toggle_Tree *notes_tree; +Fl_Toggle_Tree *files_tree; static Fl_Toggle_Tree *fill_tree; sfinx_slice_t *fill_tree_except; u32_t fill_tree_mask; -static sfinx_file_t current_files_module_tree_path(SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST); +static sfinx_file_t current_file(SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST); static void fill_objects_tree(Fl_Toggle_Tree *ft, u32_t m, sfinx_slice_t *except, bool force) { fill_tree = ft; @@ -26,19 +29,22 @@ fill_tree_except = except; app->refresh_slices(force); } -static void relink_slice_action(sfinx_slice_t *selected) { +static void relink_slice_action() { sfinx_slice_t slice(SFINX_SLICE_RELINK); // slice to be relinked Fl_Toggle_Node *node = slices_tree->selected(); if (!node) return; +Fl_Toggle_Node *snode = select_slice_tree->selected(); +if (!snode) + return; +sfinx_slice_t *selected = (sfinx_slice_t *)snode->user_data(); sfinx_slice_t *rslice = (sfinx_slice_t *)node->user_data(); slice.id = rslice->id; // new parent id slice.parent_id = selected->id; debug("moving from %lld to %lld", rslice->parent_id, selected->id); app->sfinx.send(slice); -select_slice_w->hide(); fill_objects_tree(slices_tree, SFINX_SLICE_OBJECT, 0, 1); // force refresh } @@ -55,7 +61,7 @@ Fl_Toggle_Node *snode = notes_tree->selected(); sfinx_object_t *sobj = (sfinx_object_t *)snode->user_data(); if (sobj == obj) // try to self tag return; -if (!obj->cmp((sfinx_object_t *)note_mtag_b->user_data())) // already set as main tag +if (note_mtag_b->user_data() && !obj->cmp((sfinx_object_t *)note_mtag_b->user_data())) // already set as main tag return; for (int i = 1; i <= note_tags_br->size(); i++) { if (!obj->cmp((sfinx_object_t *)note_tags_br->data(i))) // already set as additional tag @@ -91,32 +97,48 @@ for (int i = 1; i <= note_tags_br->size(); i++) { } } -static void select_file_main_slice_action() { - //file_main_slice_b->user_data(to_voidp(current_slice_id)); -static string l; -sfinx_slice_t *slice = (sfinx_slice_t *)slices_tree->selected()->user_data(); -l = slice->name(); -file_main_slice_b->label(l.c_str()); -file_main_slice_b->redraw(); -// check for additional slices if it is here - remove it -for (int i = 1; i <= file_additional_slices_br->size(); i++) { -// if (file_additional_slices_br->data(i) == to_voidp(current_slice_id)) { -// file_additional_slices_br->remove(i); -// return; -// } +static void select_file_mtag_action() { + sfinx_object_t *obj; +Fl_Toggle_Node *node = select_slice_tree->selected(); +if (!node) + return; +if (node->can_open()) // slice + obj = ((sfinx_slice_t *)node->user_data())->object(); +else // object + obj = (sfinx_object_t *)node->user_data(); +file_mtag_b->user_data(obj); +file_mtag_b->copy_label((obj->name + " [ " + obj->description + " ]").c_str()); +file_mtag_b->redraw(); +// check for additional tags if it is here - remove it +for (int i = 1; i <= file_tags_br->size(); i++) { + if (!obj->cmp((sfinx_object_t *)file_tags_br->data(i))) { + file_tags_br->remove(i); + return; + } } } -static void select_file_additional_slice_action() { - //if (to_voidp(current_slice_id) == file_main_slice_b->user_data()) // already set as main slice - //return; -//for (int i = 1; i <= file_additional_slices_br->size(); i++) { -// if (file_additional_slices_br->data(i) == to_voidp(current_slice_id)) -// return; -//} -//sfinx_slice_t *slice = (sfinx_slice_t *)slices_tree->selected()->user_data(); -//file_additional_slices_br->add(slice->name(), to_voidp(current_slice_id)); -file_additional_slices_br->redraw(); +static void select_file_atag_action() { + sfinx_object_t *obj; +Fl_Toggle_Node *node = select_slice_tree->selected(); +if (!node) + return; +string s; +if (node->can_open()) { // slice + obj = ((sfinx_slice_t *)node->user_data())->object(); + s = obj->name + " [ " + obj->description + " ]"; +} else { // object + obj = (sfinx_object_t *)node->user_data(); + s = obj->name + obj->description; +} +if (file_mtag_b->user_data() && !obj->cmp((sfinx_object_t *)file_mtag_b->user_data())) // already set as main tag + return; +for (int i = 1; i <= file_tags_br->size(); i++) { + if (!obj->cmp((sfinx_object_t *)file_tags_br->data(i))) // already set as additional tag + return; +} +file_tags_br->add(s.c_str(), obj); +file_tags_br->redraw(); } static void search_add_slice_action() { @@ -158,6 +180,19 @@ if (select_note_action) { } } +static void files_tree_cb(Fl_Widget *, void *) { + Fl_Toggle_Node *node = files_tree->selected(); +if (!node) + return; +if (!Fl::event_clicks()) + return; +void (*select_file_action)(void) = (void (*)())(files_module_w->user_data()); +if (select_file_action) { + files_module_w->user_data(0); + select_file_action(); +} +} + static void select_slice_tree_cb(Fl_Widget *, void *) { if (!Fl::event_clicks()) return; @@ -273,8 +308,7 @@ static void cb_Files(Fl_Menu_*, void*) { fl_message("Not connected to Sfinx Server !"); return; } -app->sfinx.send(SFINX_FILES_MODULE_CONF_REQUEST, (u8_t) 0); -if (app->sfinx.send(current_files_module_tree_path)) +if (app->sfinx.send(current_file)) return; files_module_w->show(); } @@ -464,9 +498,12 @@ static void cb_select_slice_b(Fl_Button*, void*) { Fl_Toggle_Node *node = select_slice_tree->selected(); if (!node) return; -sfinx_slice_t *slice = (sfinx_slice_t *) node->user_data(); -void (*select_slice_action)(sfinx_slice_t *) = (void (*)(sfinx_slice_t *))(select_slice_b->user_data()); -select_slice_action(slice); +void (*select_slice_action)() = (void (*)())(select_slice_w->user_data()); +if (select_slice_action) { + select_slice_w->user_data(0); + select_slice_action(); +} +select_slice_w->hide(); } Fl_Scroll_Resize *select_slice_tree_scroll=(Fl_Scroll_Resize *)0; @@ -530,7 +567,7 @@ sfinx_slice_t *slice = (sfinx_slice_t *)node->user_data(); if (slice->id == 1) // root slice can't be relinked return; fill_objects_tree(select_slice_tree, SFINX_SLICE_OBJECT, slice, 0); -select_slice_b->user_data((void *)relink_slice_action); +select_slice_w->user_data((void *)relink_slice_action); select_slice_w->show(); } @@ -635,13 +672,8 @@ static void cb_classify_file_b(Fl_Button*, void*) { if (!n) return; sfinx_file_t *file = ((sfinx_files_vector_t *)files_module_tree_br->user_data())->files[n - 1]; -//debug("slice_id - %d, parent_id - %d, name - %s", current_files_module_tree_path.file_id, current_files_module_tree_path.mtag_slice_id, -// file->name.c_str()); string path; -//if (current_files_module_tree_path.tid() == SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST) -// app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, path); -//else -// app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, path); +app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, path); char buf[256]; int eyear, emonth, eday, ehour, emin, esec, cyear, cmonth, cday, chour, cmin, csec; file->etime.GetDate(eyear, emonth, eday); @@ -650,7 +682,7 @@ file->ctime.GetDate(cyear, cmonth, cday); file->ctime.GetTime(chour, cmin, csec); sprintf(buf, "%llu bytes | Modified: %02d/%02d/%04d %02d:%02d:%02d | Last Status Changed: %02d/%02d/%04d %02d:%02d:%02d", file->fsize, cday, cmonth, cyear, chour, cmin, csec, eday, emonth, eyear, ehour, emin, esec); -string t = "URL: " + path + current_files_module_tree_path.name + "/" + file->name + " | " + file->mimetype + " | Size: " + buf; +string t = "URL: " + path + current_file.name + "/" + file->name + " | " + file->mimetype + " | Size: " + buf; classify_file_to->value(t.c_str()); file_title_i->value(0); file_name_i->value(file->name.c_str()); @@ -664,13 +696,27 @@ file_comments_i->value(0); sorted_location_b->value(1); file_compress_b->value(1); file_gen_csum_b->value(1); -file_main_slice_b->label("Main Slice (Not Set)"); -file_main_slice_b->user_data(0); // ÔÕÔÁ ÈÒÁÎÉÔÓÑ slice_id -file_additional_slices_br->clear(); +file_mtag_b->label("Main Slice (Not Set)"); +file_mtag_b->user_data(0); // ÔÕÔÁ ÈÒÁÎÉÔÓÑ mtag +file_tags_br->clear(); classify_file_w->user_data((void *)file); classify_file_w->show(); } +static void cb_Edit1(Fl_Button*, void*) { + Fl_Toggle_Node *node = files_tree->selected(); +if (!node || node->can_open()) { + fl_alert("Please select file to edit !"); + return; +} +sfinx_object_t *obj = (sfinx_object_t *) node->user_data(); +if (obj->type != SFINX_FILE_OBJECT) + bug(); +sfinx_file_t file(SFINX_FILES_MODULE_EDIT_REQUEST); +file.id = obj->id; +app->sfinx.send(file); +} + Fl_Browser *files_module_tree_br=(Fl_Browser *)0; static void cb_files_module_tree_br(Fl_Browser*, void*) { @@ -683,18 +729,18 @@ if (tree->files[n - 1]->is_directory) { // // × file_id ÈÒÁÎÉÔÓÑ id ÔÅËÕÝÅÊ ÄÉÒÅËÔÏÒÉÉ-ÓÌÁÊÓÁ × ËÏÔÏÒÏÊ ÎÁÈÏÄÉÍÓÑ/×ÙÂÒÁÌÉ // × mtag_id - parent_id ÄÉÒÅËÔÏÒÉÉ // ÚÁÈÏÄÉÍ × ÄÉÒÅËÔÏÒÉÀ - ÔÅËÕÝÁÑ ÓÔÁÎÏ×ÉÔÓÑ parent'ÏÍ - current_files_module_tree_path.file_id = tree->files[n - 1]->file_id; - current_files_module_tree_path.mtag_id = tree->files[n - 1]->mtag_id; + current_file.id = tree->files[n - 1]->id; + current_file.mtag.id = tree->files[n - 1]->mtag.id; // × name ÈÒÁÎÉÔÓÑ ×ÅÓØ ÐÕÔØ ÏÔ root location // × orig_name ÔÏÌØËÏ ÉÍÑ ÔÅËÕÝÅÊ - string t = current_files_module_tree_path.name.c_str(); -// current_files_module_tree_path.orig_name = tree->files[n - 1]->name; + string t = current_file.name.c_str(); +// current_file.orig_name = tree->files[n - 1]->name; t += ('/' + tree->files[n - 1]->name); - current_files_module_tree_path.name = t; - //debug("requesting dir %s", current_files_module_tree_path.c_str()); - app->sfinx.send(current_files_module_tree_path); + current_file.name = t; + //debug("requesting dir %s", current_file.c_str()); + app->sfinx.send(current_file); } else { - if (!(tree->files[n - 1]->file_id)) // classify file + if (!(tree->files[n - 1]->id)) // classify file classify_file_b->do_callback(); else { // app->sfinx.send(SFINX_SLICES_MODULE_TREE_REQUEST, (u8_t)0); // prepare for slice_name() calls @@ -706,88 +752,97 @@ if (tree->files[n - 1]->is_directory) { // } static void cb_Delete2(Fl_Button*, void*) { - int n = files_module_tree_br->value(); -if (!n) - return; -sfinx_file_t *file = ((sfinx_files_vector_t *)files_module_tree_br->user_data())->files[n - 1]; -string path; -if (current_files_module_tree_path.tid() == SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST) { - // sure ? - string message = "Deleting \'" + file->name + "\'. Are you sure ?"; + if (current_file.tid() == SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST) { // unsorted tree + int n = files_module_tree_br->value(); + if (!n) + return; + sfinx_file_t *file = ((sfinx_files_vector_t *)files_module_tree_br->user_data())->files[n - 1]; + string path; // sure ? + string message = "Deleting "; + if (file->is_directory) + message += "directory"; + else + message += "file"; + message += (" \'" + file->name + "\'. Are you sure ?"); if (fl_choice(message.c_str(), "Yes", "No", 0L)) return; - app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, path); - path += "/" + file->name; - sfinx_string_t f(SFINX_FILES_MODULE_UNLINK); - f.set(path); - app->sfinx.send(f); -} else { - // sorted can be marked unsorted or deleted - string message = "Delete or Unsort \'" + file->name + "\' ?"; + file->tid(SFINX_FILES_MODULE_UNSORTED_DELETE); + app->sfinx.send(file); // check for errors ? + app->sfinx.send(current_file); +} else { // sorted tree + Fl_Toggle_Node *node = files_tree->selected(); + if (!node || node->can_open()) + return; + sfinx_object_t *obj = (sfinx_object_t *) node->user_data(); + string message = "Delete or Unsort \'" + obj->name + "\' ?"; int res = fl_choice(message.c_str(), "Cancel", "Unsort", "Delete"); + sfinx_file_t file; + file.id = obj->id; + file.mtag.slice_id = obj->slice_id; if (!res) return; - if (res == 2) { // delete - file->tid(SFINX_FILES_MODULE_SORTED_UNLINK); - app->sfinx.send(file); - } else { - file->tid(SFINX_FILES_MODULE_UNSORT); - app->sfinx.send(file); - } -} -//files_module_tree_br->remove(n); -app->sfinx.send(current_files_module_tree_path); + if (res == 2) // delete + file.tid(SFINX_FILES_MODULE_SORTED_UNLINK); + else + file.tid(SFINX_FILES_MODULE_UNSORT); + app->sfinx.send(file); + fill_objects_tree(files_tree, (1 << SFINX_FILE_OBJECT), 0, 1); // fluid bugs if any default params exists ! + +}; } Fl_Button *select_files_tree_b=(Fl_Button *)0; static void cb_select_files_tree_b(Fl_Button*, void*) { - files_module_tree_br->clear(); -current_files_module_tree_path.name.clear(); -current_files_module_tree_path.orig_name.clear(); + current_file.name.clear(); +current_file.orig_name.clear(); if (select_files_tree_b->user_data()) { - select_files_tree_b->user_data(0); - select_files_tree_b->label("Sorted tree"); - current_files_module_tree_path.tid(SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST); - current_files_module_tree_path.file_id = 0; + current_file.tid(SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST); + current_file.id = 0; + app->sfinx.send(current_file); } else { select_files_tree_b->user_data((void *)1); - select_files_tree_b->label("Unsorted tree"); -// current_files_module_tree_path.tid(SFINX_FILES_MODULE_SORTED_TREE_REQUEST); - current_files_module_tree_path.file_id = 1; // root id - -} -select_files_tree_b->redraw(); -app->sfinx.send(current_files_module_tree_path); + select_files_tree_b->label("Show Unsorted"); + select_files_tree_b->redraw(); + current_file.tid(0); + current_file.id = 1; // root id + fill_objects_tree(files_tree, 1 << SFINX_FILE_OBJECT, 0, 0); // fluid bugs if any default params exists ! + files_module_tree_br->hide(); + files_tree_scroll->show(); +}; } static void cb_Up(Fl_Button*, void*) { - const char *p = strrchr(current_files_module_tree_path.name.c_str(), '/'); -if (!p) - current_files_module_tree_path.name.clear(); -else { + const char *p = strrchr(current_file.name.c_str(), '/'); +if (!p) { + if (!current_file.name.size()) + return; + current_file.name.clear(); +} else { char path[1024]; path[0] = 0; - strncat(path, current_files_module_tree_path.name.c_str(), p - current_files_module_tree_path.name.c_str()); - current_files_module_tree_path.name = path; - current_files_module_tree_path.file_id = current_files_module_tree_path.mtag_id; + strncat(path, current_file.name.c_str(), p - current_file.name.c_str()); + current_file.name = path; + current_file.id = current_file.mtag.id; } -app->sfinx.send(current_files_module_tree_path); +app->sfinx.send(current_file); } static void cb_Reload(Fl_Button*, void*) { - app->sfinx.send(current_files_module_tree_path); + app->sfinx.send(current_file); } static void cb_Select(Fl_Button*, void*) { - for (int i = 1; i <= files_module_tree_br->size(); i++) - files_module_tree_br->select(i); + //for (int i = 1; i <= files_module_tree_br->size(); i++) +// files_module_tree_br->select(i); } static void cb_Unselect(Fl_Button*, void*) { files_module_tree_br->deselect(); } +Fl_Scroll_Resize *files_tree_scroll=(Fl_Scroll_Resize *)0; + Fl_Double_Window *classify_file_w=(Fl_Double_Window *)0; static void cb_Cancel6(Fl_Button*, void*) { @@ -805,7 +860,7 @@ Fl_Input *file_comments_i=(Fl_Input *)0; Fl_Output *classify_file_to=(Fl_Output *)0; static void cb_Ok1(Fl_Return_Button*, void*) { - if (!file_main_slice_b->user_data()) { + if (!file_mtag_b->user_data()) { fl_alert("You have to select Main Slice for file !"); return; } @@ -814,7 +869,6 @@ if (!file_name_i->size()) { return; } sfinx_file_t *file = (sfinx_file_t *)classify_file_w->user_data(); -// file->tid(SFINX_FILES_MODULE_CLASSIFY_REQUEST); file->name = file_name_i->value(); file->title = file_title_i->value(); file->authority = file_authority_i->value(); @@ -823,10 +877,16 @@ file->comments = file_comments_i->value(); file->sorted_location = sorted_location_b->value(); file->store_compressed = file_compress_b->value(); file->generate_csum = file_gen_csum_b->value(); -file->mtag_id = from_voidp(file_main_slice_b->user_data()); -file->objects.clear(); -for (int i = 1; i <= file_additional_slices_br->size(); i++) { -// file->objects.push_back(from_voidp(file_additional_slices_br->data(i))); +sfinx_object_t *obj = (sfinx_object_t *)file_mtag_b->user_data(); +file->mtag.id = obj->id; +file->mtag.type = obj->type; +file->mtag.slice_id = obj->slice_id; +file_mtag_b->user_data(0); +file->tags.clear(); +for (int i = 1; i <= file_tags_br->size(); i++) { + obj = (sfinx_object_t *)file_tags_br->data(i); + file->tags.push_back(*obj); + file_tags_br->data(i, 0); } app->sfinx.send(file); } @@ -837,30 +897,30 @@ Fl_Check_Button *file_crypt_b=(Fl_Check_Button *)0; Fl_Check_Button *file_compress_b=(Fl_Check_Button *)0; -Fl_Button *file_main_slice_b=(Fl_Button *)0; +Fl_Button *file_mtag_b=(Fl_Button *)0; -static void cb_file_main_slice_b(Fl_Button*, void*) { - app->refresh_slices(); -slices_w->user_data((void *)select_file_main_slice_action); -slices_w->show(); +static void cb_file_mtag_b(Fl_Button*, void*) { + fill_objects_tree(select_slice_tree, (1 << SFINX_SLICE_OBJECT) | (1 << SFINX_FILE_OBJECT) | (1 << SFINX_NOTE_OBJECT), 0, 0); // fluid bugs if any default params exists ! +select_slice_w->user_data((void *)select_file_mtag_action); +select_slice_w->show(); } -Fl_Browser *file_additional_slices_br=(Fl_Browser *)0; +Fl_Browser *file_tags_br=(Fl_Browser *)0; -Fl_Button *file_add_slice_b=(Fl_Button *)0; +Fl_Button *file_add_tag_b=(Fl_Button *)0; -static void cb_file_add_slice_b(Fl_Button*, void*) { - app->refresh_slices(); -slices_w->user_data((void *)select_file_additional_slice_action); -slices_w->show(); +static void cb_file_add_tag_b(Fl_Button*, void*) { + fill_objects_tree(select_slice_tree, (1 << SFINX_SLICE_OBJECT) | (1 << SFINX_FILE_OBJECT) | (1 << SFINX_NOTE_OBJECT), 0, 0); // fluid bugs if any default params exists ! +select_slice_w->user_data((void *)select_file_atag_action); +select_slice_w->show(); } -Fl_Button *file_remove_slice_b=(Fl_Button *)0; +Fl_Button *file_remove_tag_b=(Fl_Button *)0; -static void cb_file_remove_slice_b(Fl_Button*, void*) { - for (int i = file_additional_slices_br->size(); i >= 1; i--) { - if (file_additional_slices_br->selected(i)) - file_additional_slices_br->remove(i); +static void cb_file_remove_tag_b(Fl_Button*, void*) { + for (int i = file_tags_br->size(); i >= 1; i--) { + if (file_tags_br->selected(i)) + file_tags_br->remove(i); }; } @@ -868,55 +928,9 @@ Fl_Input *file_name_i=(Fl_Input *)0; Fl_Check_Button *file_gen_csum_b=(Fl_Check_Button *)0; -Fl_Double_Window *search_w=(Fl_Double_Window *)0; - -static void cb_Cancel7(Fl_Button*, void*) { - search_w->hide(); -} - -static void cb_Search1(Fl_Return_Button*, void*) { - sfinx_search_query_t query; -query.pattern = search_i->value(); -if (search_in_files_b->value()) - query.add_area(SFINX_SEARCH_IN_FILES); -// add restrictions ... -app->sfinx.send(query); -} - -Fl_Check_Button *search_in_files_b=(Fl_Check_Button *)0; - -Fl_Browser *search_slices_br=(Fl_Browser *)0; - -Fl_Button *search_add_slice_b=(Fl_Button *)0; - -static void cb_search_add_slice_b(Fl_Button*, void*) { - app->refresh_slices(); -slices_w->user_data((void *)search_add_slice_action); -slices_w->show(); -} - -static void cb_Remove(Fl_Button*, void*) { - for (int i = search_slices_br->size(); i >= 1; i--) { - if (search_slices_br->selected(i)) - search_slices_br->remove(i); -}; -} - -Fl_Input *search_i=(Fl_Input *)0; - -Fl_Double_Window *search_browser_w=(Fl_Double_Window *)0; - -static void cb_Cancel8(Fl_Button*, void*) { - search_browser_w->hide(); -} - -Fl_Browser *search_browser_br=(Fl_Browser *)0; - -Fl_Choice *goto_page_ch=(Fl_Choice *)0; - Fl_Double_Window *notes_w=(Fl_Double_Window *)0; -static void cb_Cancel9(Fl_Button*, void*) { +static void cb_Cancel7(Fl_Button*, void*) { notes_w->hide(); } @@ -945,7 +959,7 @@ note_name_i->take_focus(); edit_note_w->show(); } -static void cb_Edit1(Fl_Button*, void*) { +static void cb_Edit2(Fl_Button*, void*) { Fl_Toggle_Node *node = notes_tree->selected(); if (!node || node->can_open()) { fl_alert("Please select note to edit !"); @@ -973,7 +987,7 @@ delete_note_w->show(); Fl_Double_Window *edit_note_w=(Fl_Double_Window *)0; -static void cb_Cancela(Fl_Button*, void*) { +static void cb_Cancel8(Fl_Button*, void*) { edit_note_w->hide(); } @@ -1016,7 +1030,6 @@ for (int i = 1; i <= note_tags_br->size(); i++) { app->sfinx.send(note); delete note; edit_note_w->user_data(0); -fill_objects_tree(notes_tree, 1 << SFINX_NOTE_OBJECT, 0, 1); // force refresh; } Fl_Button *note_mtag_b=(Fl_Button *)0; @@ -1056,7 +1069,7 @@ Fl_Menu_Item menu_note_secured_ch[] = { Fl_Double_Window *delete_note_w=(Fl_Double_Window *)0; -static void cb_Cancelb(Fl_Button*, void*) { +static void cb_Cancel9(Fl_Button*, void*) { delete_note_w->hide(); } @@ -1064,6 +1077,7 @@ static void cb_Delete4(Fl_Button*, void*) { sfinx_object_t *obj = (sfinx_object_t *) delete_note_w->user_data(); sfinx_note_t note(note_deletion_type_ch->value() ? SFINX_NOTES_MODULE_UNLINK : SFINX_NOTES_MODULE_UNSORT); note.id = obj->id; +note.mtag.slice_id = obj->slice_id; app->sfinx.send(note); delete_note_w->user_data(0); delete_note_w->hide(); @@ -1080,6 +1094,52 @@ Fl_Menu_Item menu_note_deletion_type_ch[] = { {0,0,0,0,0,0,0,0,0} }; +Fl_Double_Window *search_browser_w=(Fl_Double_Window *)0; + +static void cb_Cancela(Fl_Button*, void*) { + search_browser_w->hide(); +} + +Fl_Browser *search_browser_br=(Fl_Browser *)0; + +Fl_Choice *goto_page_ch=(Fl_Choice *)0; + +Fl_Double_Window *search_w=(Fl_Double_Window *)0; + +static void cb_Cancelb(Fl_Button*, void*) { + search_w->hide(); +} + +static void cb_Search1(Fl_Return_Button*, void*) { + sfinx_search_query_t query; +query.pattern = search_i->value(); +if (search_in_files_b->value()) + query.add_area(SFINX_SEARCH_IN_FILES); +// add restrictions ... +app->sfinx.send(query); +} + +Fl_Check_Button *search_in_files_b=(Fl_Check_Button *)0; + +Fl_Browser *search_slices_br=(Fl_Browser *)0; + +Fl_Button *search_add_slice_b=(Fl_Button *)0; + +static void cb_search_add_slice_b(Fl_Button*, void*) { + app->refresh_slices(); +slices_w->user_data((void *)search_add_slice_action); +slices_w->show(); +} + +static void cb_Remove(Fl_Button*, void*) { + for (int i = search_slices_br->size(); i >= 1; i--) { + if (search_slices_br->selected(i)) + search_slices_br->remove(i); +}; +} + +Fl_Input *search_i=(Fl_Input *)0; + Fl_Double_Window *about_w=(Fl_Double_Window *)0; static void cb_Ok3(Fl_Button*, void*) { @@ -3016,8 +3076,9 @@ void x11_ui::init() { } // Fl_Button* classify_file_b { Fl_Button* o = new Fl_Button(154, 312, 128, 25, gettext("Edit")); o->labeltype(FL_ENGRAVED_LABEL); + o->callback((Fl_Callback*)cb_Edit1); } // Fl_Button* o - { files_module_tree_br = new Fl_Browser(8, 45, 716, 255); + { files_module_tree_br = new Fl_Browser(7, 45, 716, 255); files_module_tree_br->type(3); files_module_tree_br->color((Fl_Color)31); files_module_tree_br->callback((Fl_Callback*)cb_files_module_tree_br); @@ -3049,6 +3110,23 @@ void x11_ui::init() { o->labeltype(FL_ENGRAVED_LABEL); o->callback((Fl_Callback*)cb_Unselect); } // Fl_Button* o + { files_tree_scroll = new Fl_Scroll_Resize(7, 45, 716, 255); + files_tree_scroll->box(FL_ENGRAVED_FRAME); + files_tree_scroll->color((Fl_Color)28); + files_tree_scroll->selection_color(FL_BACKGROUND_COLOR); + files_tree_scroll->labeltype(FL_NORMAL_LABEL); + files_tree_scroll->labelfont(0); + files_tree_scroll->labelsize(14); + files_tree_scroll->labelcolor(FL_FOREGROUND_COLOR); + files_tree_scroll->align(FL_ALIGN_TOP); + files_tree_scroll->when(FL_WHEN_RELEASE); + files_tree_scroll->hide(); + files_tree = new Fl_Toggle_Tree(12, 12, files_tree_scroll->w(), 10); + files_tree->callback(files_tree_cb); files_tree->user_data((void *)files_tree_scroll); + files_module_w->resizable(files_tree_scroll); + files_tree_scroll->resizable(files_tree); + files_tree_scroll->end(); + } // Fl_Scroll_Resize* files_tree_scroll files_module_w->end(); } // Fl_Double_Window* files_module_w { classify_file_w = new Fl_Double_Window(1020, 515, gettext("Classify File")); @@ -3114,28 +3192,28 @@ void x11_ui::init() { { Fl_Box* o = new Fl_Box(13, 205, 552, 227); o->box(FL_ENGRAVED_FRAME); } // Fl_Box* o - { file_main_slice_b = new Fl_Button(45, 226, 489, 25, gettext("Main Slice (Not Set)")); - file_main_slice_b->tooltip(gettext("File Main Slice")); - file_main_slice_b->box(FL_PLASTIC_THIN_UP_BOX); - file_main_slice_b->labeltype(FL_ENGRAVED_LABEL); - file_main_slice_b->callback((Fl_Callback*)cb_file_main_slice_b); - } // Fl_Button* file_main_slice_b - { file_additional_slices_br = new Fl_Browser(26, 275, 525, 102, gettext("Additional Slices")); - file_additional_slices_br->type(3); - file_additional_slices_br->color((Fl_Color)46); - file_additional_slices_br->labeltype(FL_ENGRAVED_LABEL); - file_additional_slices_br->align(FL_ALIGN_TOP); - } // Fl_Browser* file_additional_slices_br - { file_add_slice_b = new Fl_Button(82, 391, 138, 25, gettext("Add Slice")); - file_add_slice_b->box(FL_PLASTIC_THIN_UP_BOX); - file_add_slice_b->labeltype(FL_ENGRAVED_LABEL); - file_add_slice_b->callback((Fl_Callback*)cb_file_add_slice_b); - } // Fl_Button* file_add_slice_b - { file_remove_slice_b = new Fl_Button(358, 391, 138, 25, gettext("Remove Slice")); - file_remove_slice_b->box(FL_PLASTIC_THIN_UP_BOX); - file_remove_slice_b->labeltype(FL_ENGRAVED_LABEL); - file_remove_slice_b->callback((Fl_Callback*)cb_file_remove_slice_b); - } // Fl_Button* file_remove_slice_b + { file_mtag_b = new Fl_Button(45, 226, 489, 25, gettext("Main Slice (Not Set)")); + file_mtag_b->tooltip(gettext("File Main Slice")); + file_mtag_b->box(FL_PLASTIC_THIN_UP_BOX); + file_mtag_b->labeltype(FL_ENGRAVED_LABEL); + file_mtag_b->callback((Fl_Callback*)cb_file_mtag_b); + } // Fl_Button* file_mtag_b + { file_tags_br = new Fl_Browser(26, 275, 525, 102, gettext("Additional Slices")); + file_tags_br->type(3); + file_tags_br->color((Fl_Color)46); + file_tags_br->labeltype(FL_ENGRAVED_LABEL); + file_tags_br->align(FL_ALIGN_TOP); + } // Fl_Browser* file_tags_br + { file_add_tag_b = new Fl_Button(82, 391, 138, 25, gettext("Add Slice")); + file_add_tag_b->box(FL_PLASTIC_THIN_UP_BOX); + file_add_tag_b->labeltype(FL_ENGRAVED_LABEL); + file_add_tag_b->callback((Fl_Callback*)cb_file_add_tag_b); + } // Fl_Button* file_add_tag_b + { file_remove_tag_b = new Fl_Button(358, 391, 138, 25, gettext("Remove Slice")); + file_remove_tag_b->box(FL_PLASTIC_THIN_UP_BOX); + file_remove_tag_b->labeltype(FL_ENGRAVED_LABEL); + file_remove_tag_b->callback((Fl_Callback*)cb_file_remove_tag_b); + } // Fl_Button* file_remove_tag_b { file_name_i = new Fl_Input(549, 26, 447, 26, gettext("File Name")); file_name_i->color((Fl_Color)29); file_name_i->labeltype(FL_ENGRAVED_LABEL); @@ -3151,123 +3229,43 @@ void x11_ui::init() { classify_file_w->set_modal(); classify_file_w->end(); } // Fl_Double_Window* classify_file_w - { search_w = new Fl_Double_Window(749, 389, gettext("Search")); - search_w->color((Fl_Color)31); - { Fl_Button* o = new Fl_Button(182, 347, 363, 25, gettext("Cancel")); - o->box(FL_PLASTIC_ROUND_UP_BOX); + { notes_w = new Fl_Double_Window(730, 370, gettext("Notes Module")); + notes_w->color((Fl_Color)31); + { Fl_Button* o = new Fl_Button(605, 312, 112, 25, gettext("Cancel")); o->labeltype(FL_ENGRAVED_LABEL); o->callback((Fl_Callback*)cb_Cancel7); } // Fl_Button* o - { Fl_Return_Button* o = new Fl_Return_Button(539, 48, 163, 25, gettext("Search")); - o->box(FL_PLASTIC_ROUND_UP_BOX); + { notes_module_status_to = new Fl_Output(0, 349, 733, 21); + notes_module_status_to->box(FL_PLASTIC_UP_BOX); + notes_module_status_to->color((Fl_Color)31); + } // Fl_Output* notes_module_status_to + { Fl_Button* o = new Fl_Button(21, 312, 112, 25, gettext("New")); o->labeltype(FL_ENGRAVED_LABEL); - o->callback((Fl_Callback*)cb_Search1); - } // Fl_Return_Button* o - { search_in_files_b = new Fl_Check_Button(48, 96, 241, 23, gettext("Search in Files")); - search_in_files_b->box(FL_PLASTIC_UP_BOX); - search_in_files_b->down_box(FL_DOWN_BOX); - search_in_files_b->selection_color(FL_SELECTION_COLOR); - search_in_files_b->labeltype(FL_ENGRAVED_LABEL); - search_in_files_b->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); - search_in_files_b->deactivate(); - } // Fl_Check_Button* search_in_files_b - { Fl_Box* o = new Fl_Box(87, 141, 561, 189); - o->box(FL_ROUNDED_FRAME); - } // Fl_Box* o - { search_slices_br = new Fl_Browser(105, 173, 525, 102, gettext("Restrict Search by Slices")); - search_slices_br->type(3); - search_slices_br->color((Fl_Color)46); - search_slices_br->labeltype(FL_ENGRAVED_LABEL); - search_slices_br->align(FL_ALIGN_TOP); - } // Fl_Browser* search_slices_br - { search_add_slice_b = new Fl_Button(161, 289, 138, 25, gettext("Add Slice")); - search_add_slice_b->box(FL_PLASTIC_THIN_UP_BOX); - search_add_slice_b->labeltype(FL_ENGRAVED_LABEL); - search_add_slice_b->callback((Fl_Callback*)cb_search_add_slice_b); - } // Fl_Button* search_add_slice_b - { Fl_Button* o = new Fl_Button(437, 289, 138, 25, gettext("Remove Slice")); - o->box(FL_PLASTIC_THIN_UP_BOX); + o->callback((Fl_Callback*)cb_New1); + } // Fl_Button* o + { Fl_Button* o = new Fl_Button(154, 312, 128, 25, gettext("Edit")); o->labeltype(FL_ENGRAVED_LABEL); - o->callback((Fl_Callback*)cb_Remove); + o->callback((Fl_Callback*)cb_Edit2); } // Fl_Button* o - { search_i = new Fl_Input(46, 47, 447, 26, gettext("Search for ...")); - search_i->color((Fl_Color)29); - search_i->labeltype(FL_ENGRAVED_LABEL); - search_i->align(FL_ALIGN_TOP); - } // Fl_Input* search_i - search_w->set_modal(); - search_w->end(); - } // Fl_Double_Window* search_w - { search_browser_w = new Fl_Double_Window(854, 476, gettext("Search Browser")); - search_browser_w->color((Fl_Color)31); - { Fl_Button* o = new Fl_Button(638, 449, 187, 20, gettext("Cancel")); - o->box(FL_PLASTIC_ROUND_UP_BOX); - o->color(FL_FOREGROUND_COLOR); + { notes_tree_scroll = new Fl_Scroll_Resize(13, 10, 705, 289); + notes_tree_scroll->box(FL_ENGRAVED_FRAME); + notes_tree_scroll->color((Fl_Color)28); + notes_tree_scroll->selection_color(FL_BACKGROUND_COLOR); + notes_tree_scroll->labeltype(FL_NORMAL_LABEL); + notes_tree_scroll->labelfont(0); + notes_tree_scroll->labelsize(14); + notes_tree_scroll->labelcolor(FL_FOREGROUND_COLOR); + notes_tree_scroll->align(FL_ALIGN_TOP); + notes_tree_scroll->when(FL_WHEN_RELEASE); + notes_tree = new Fl_Toggle_Tree(12, 12, notes_tree_scroll->w(), 10); + notes_tree->callback(notes_tree_cb); notes_tree->user_data((void *)notes_tree_scroll); + notes_w->resizable(notes_tree_scroll); + notes_tree_scroll->resizable(notes_tree); + notes_tree_scroll->end(); + } // Fl_Scroll_Resize* notes_tree_scroll + { Fl_Button* o = new Fl_Button(300, 312, 112, 25, gettext("Delete")); o->labeltype(FL_ENGRAVED_LABEL); - o->callback((Fl_Callback*)cb_Cancel8); - } // Fl_Button* o - { search_browser_br = new Fl_Browser(4, 4, 846, 439); - search_browser_br->type(2); - search_browser_br->box(FL_GTK_THIN_UP_BOX); - search_browser_br->color((Fl_Color)44); - Fl_Group::current()->resizable(search_browser_br); - } // Fl_Browser* search_browser_br - { Fl_Button* o = new Fl_Button(25, 449, 169, 20, gettext("Previous Page")); - o->box(FL_PLASTIC_ROUND_UP_BOX); - o->color(FL_FOREGROUND_COLOR); - o->labeltype(FL_ENGRAVED_LABEL); - } // Fl_Button* o - { Fl_Button* o = new Fl_Button(231, 449, 169, 20, gettext("Next Page")); - o->box(FL_PLASTIC_ROUND_UP_BOX); - o->color(FL_FOREGROUND_COLOR); - o->labeltype(FL_ENGRAVED_LABEL); - } // Fl_Button* o - { goto_page_ch = new Fl_Choice(531, 450, 72, 20, gettext("Current Page ")); - goto_page_ch->box(FL_PLASTIC_THIN_UP_BOX); - goto_page_ch->down_box(FL_PLASTIC_THIN_UP_BOX); - goto_page_ch->color((Fl_Color)44); - goto_page_ch->labeltype(FL_ENGRAVED_LABEL); - } // Fl_Choice* goto_page_ch - search_browser_w->set_modal(); - search_browser_w->end(); - } // Fl_Double_Window* search_browser_w - { notes_w = new Fl_Double_Window(730, 370, gettext("Notes Module")); - notes_w->color((Fl_Color)31); - { Fl_Button* o = new Fl_Button(605, 312, 112, 25, gettext("Cancel")); - o->labeltype(FL_ENGRAVED_LABEL); - o->callback((Fl_Callback*)cb_Cancel9); - } // Fl_Button* o - { notes_module_status_to = new Fl_Output(0, 349, 733, 21); - notes_module_status_to->box(FL_PLASTIC_UP_BOX); - notes_module_status_to->color((Fl_Color)31); - } // Fl_Output* notes_module_status_to - { Fl_Button* o = new Fl_Button(21, 312, 112, 25, gettext("New")); - o->labeltype(FL_ENGRAVED_LABEL); - o->callback((Fl_Callback*)cb_New1); - } // Fl_Button* o - { Fl_Button* o = new Fl_Button(154, 312, 128, 25, gettext("Edit")); - o->labeltype(FL_ENGRAVED_LABEL); - o->callback((Fl_Callback*)cb_Edit1); - } // Fl_Button* o - { notes_tree_scroll = new Fl_Scroll_Resize(13, 10, 705, 289); - notes_tree_scroll->box(FL_ENGRAVED_FRAME); - notes_tree_scroll->color((Fl_Color)28); - notes_tree_scroll->selection_color(FL_BACKGROUND_COLOR); - notes_tree_scroll->labeltype(FL_NORMAL_LABEL); - notes_tree_scroll->labelfont(0); - notes_tree_scroll->labelsize(14); - notes_tree_scroll->labelcolor(FL_FOREGROUND_COLOR); - notes_tree_scroll->align(FL_ALIGN_TOP); - notes_tree_scroll->when(FL_WHEN_RELEASE); - notes_tree = new Fl_Toggle_Tree(12, 12, notes_tree_scroll->w(), 10); - notes_tree->callback(notes_tree_cb); notes_tree->user_data((void *)notes_tree_scroll); - notes_w->resizable(notes_tree_scroll); - notes_tree_scroll->resizable(notes_tree); - notes_tree_scroll->end(); - } // Fl_Scroll_Resize* notes_tree_scroll - { Fl_Button* o = new Fl_Button(300, 312, 112, 25, gettext("Delete")); - o->labeltype(FL_ENGRAVED_LABEL); - o->callback((Fl_Callback*)cb_Delete3); + o->callback((Fl_Callback*)cb_Delete3); } // Fl_Button* o notes_w->end(); notes_w->resizable(notes_w); @@ -3276,7 +3274,7 @@ void x11_ui::init() { edit_note_w->color((Fl_Color)31); { Fl_Button* o = new Fl_Button(648, 321, 112, 25, gettext("Cancel")); o->labeltype(FL_ENGRAVED_LABEL); - o->callback((Fl_Callback*)cb_Cancela); + o->callback((Fl_Callback*)cb_Cancel8); } // Fl_Button* o { note_name_i = new Fl_Input(16, 27, 496, 26, gettext("Name")); note_name_i->color((Fl_Color)29); @@ -3344,7 +3342,7 @@ void x11_ui::init() { delete_note_w->color((Fl_Color)31); { Fl_Button* o = new Fl_Button(239, 122, 112, 25, gettext("Cancel")); o->labeltype(FL_ENGRAVED_LABEL); - o->callback((Fl_Callback*)cb_Cancelb); + o->callback((Fl_Callback*)cb_Cancel9); } // Fl_Button* o { Fl_Button* o = new Fl_Button(40, 122, 112, 25, gettext("Delete")); o->labeltype(FL_ENGRAVED_LABEL); @@ -3366,6 +3364,86 @@ void x11_ui::init() { delete_note_w->set_modal(); delete_note_w->end(); } // Fl_Double_Window* delete_note_w + { search_browser_w = new Fl_Double_Window(854, 476, gettext("Search Browser")); + search_browser_w->color((Fl_Color)31); + { Fl_Button* o = new Fl_Button(638, 449, 187, 20, gettext("Cancel")); + o->box(FL_PLASTIC_ROUND_UP_BOX); + o->color(FL_FOREGROUND_COLOR); + o->labeltype(FL_ENGRAVED_LABEL); + o->callback((Fl_Callback*)cb_Cancela); + } // Fl_Button* o + { search_browser_br = new Fl_Browser(4, 4, 846, 439); + search_browser_br->type(2); + search_browser_br->box(FL_GTK_THIN_UP_BOX); + search_browser_br->color((Fl_Color)44); + Fl_Group::current()->resizable(search_browser_br); + } // Fl_Browser* search_browser_br + { Fl_Button* o = new Fl_Button(25, 449, 169, 20, gettext("Previous Page")); + o->box(FL_PLASTIC_ROUND_UP_BOX); + o->color(FL_FOREGROUND_COLOR); + o->labeltype(FL_ENGRAVED_LABEL); + } // Fl_Button* o + { Fl_Button* o = new Fl_Button(231, 449, 169, 20, gettext("Next Page")); + o->box(FL_PLASTIC_ROUND_UP_BOX); + o->color(FL_FOREGROUND_COLOR); + o->labeltype(FL_ENGRAVED_LABEL); + } // Fl_Button* o + { goto_page_ch = new Fl_Choice(531, 450, 72, 20, gettext("Current Page ")); + goto_page_ch->box(FL_PLASTIC_THIN_UP_BOX); + goto_page_ch->down_box(FL_PLASTIC_THIN_UP_BOX); + goto_page_ch->color((Fl_Color)44); + goto_page_ch->labeltype(FL_ENGRAVED_LABEL); + } // Fl_Choice* goto_page_ch + search_browser_w->set_modal(); + search_browser_w->end(); + } // Fl_Double_Window* search_browser_w + { search_w = new Fl_Double_Window(749, 389, gettext("Search")); + search_w->color((Fl_Color)31); + { Fl_Button* o = new Fl_Button(182, 347, 363, 25, gettext("Cancel")); + o->box(FL_PLASTIC_ROUND_UP_BOX); + o->labeltype(FL_ENGRAVED_LABEL); + o->callback((Fl_Callback*)cb_Cancelb); + } // Fl_Button* o + { Fl_Return_Button* o = new Fl_Return_Button(539, 48, 163, 25, gettext("Search")); + o->box(FL_PLASTIC_ROUND_UP_BOX); + o->labeltype(FL_ENGRAVED_LABEL); + o->callback((Fl_Callback*)cb_Search1); + } // Fl_Return_Button* o + { search_in_files_b = new Fl_Check_Button(48, 96, 241, 23, gettext("Search in Files")); + search_in_files_b->box(FL_PLASTIC_UP_BOX); + search_in_files_b->down_box(FL_DOWN_BOX); + search_in_files_b->selection_color(FL_SELECTION_COLOR); + search_in_files_b->labeltype(FL_ENGRAVED_LABEL); + search_in_files_b->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); + search_in_files_b->deactivate(); + } // Fl_Check_Button* search_in_files_b + { Fl_Box* o = new Fl_Box(87, 141, 561, 189); + o->box(FL_ROUNDED_FRAME); + } // Fl_Box* o + { search_slices_br = new Fl_Browser(105, 173, 525, 102, gettext("Restrict Search by Slices")); + search_slices_br->type(3); + search_slices_br->color((Fl_Color)46); + search_slices_br->labeltype(FL_ENGRAVED_LABEL); + search_slices_br->align(FL_ALIGN_TOP); + } // Fl_Browser* search_slices_br + { search_add_slice_b = new Fl_Button(161, 289, 138, 25, gettext("Add Slice")); + search_add_slice_b->box(FL_PLASTIC_THIN_UP_BOX); + search_add_slice_b->labeltype(FL_ENGRAVED_LABEL); + search_add_slice_b->callback((Fl_Callback*)cb_search_add_slice_b); + } // Fl_Button* search_add_slice_b + { Fl_Button* o = new Fl_Button(437, 289, 138, 25, gettext("Remove Slice")); + o->box(FL_PLASTIC_THIN_UP_BOX); + o->labeltype(FL_ENGRAVED_LABEL); + o->callback((Fl_Callback*)cb_Remove); + } // Fl_Button* o + { search_i = new Fl_Input(46, 47, 447, 26, gettext("Search for ...")); + search_i->color((Fl_Color)29); + search_i->labeltype(FL_ENGRAVED_LABEL); + search_i->align(FL_ALIGN_TOP); + } // Fl_Input* search_i + search_w->set_modal(); + search_w->end(); + } // Fl_Double_Window* search_w { about_w = new Fl_Double_Window(374, 154); { Fl_Button* o = new Fl_Button(72, 122, 226, 20, gettext("Ok")); o->box(FL_PLASTIC_ROUND_UP_BOX); @@ -3407,40 +3485,6 @@ void x11_ui::init() { main_w->show(); } -void x11_ui::log(int level, const char *fmt, ...) { - char buf[10240]; -const char *level_str; -static Mutex log_m; -log_m.enterMutex(); -Fl::lock(); -::va_list args; -::va_start(args, fmt); -::va_end(args); -switch (level) { - case SFINX_LOG_NOTICE: - level_str = "NOTICE"; - break; - case SFINX_LOG_WARN: - level_str = "WARN"; - break; - case SFINX_LOG_ERROR: - level_str = "ERROR"; - break; - case SFINX_LOG_FATAL: - level_str = "FATAL"; - break; - default: - level_str = "UNKN_LEVEL"; -} -// add time ? -strcpy(buf, level_str); -strcat(buf, ": "); -::vsnprintf(buf + strlen(level_str) + 2, sizeof(buf) - (strlen(level_str) + 2), fmt, args); -log_br->add(buf); -Fl::unlock(); -log_m.leaveMutex(); -} - void x11_ui::edit_slice(sfinx_slice_t *slice) { // need locks Fl::lock(); @@ -3464,110 +3508,6 @@ edit_slice_w->show(); Fl::unlock(); } -void x11_ui::fill_preferences() { - Fl::lock(); -string t; -app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, t); -config_files_module_unsorted_path_i->value(t.c_str()); -app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, t); -config_files_module_sorted_path_i->value(t.c_str()); -app->files_module_conf.get(FILES_MODULE_DESC_FILE_NAME, t); -config_files_module_desc_file_name_i->value(t.c_str()); -u32_t gen_desc_files; -app->files_module_conf.get(FILES_MODULE_DESC_FILE_ENABLE, &gen_desc_files); -gen_desc_files_b->value(gen_desc_files); -Fl::unlock(); -} - -void x11_ui::fill_files_module_tree(sfinx_files_vector_t *tree_) { - Fl::lock(); -static sfinx_files_vector_t tree; -tree.copy(tree_); -files_module_tree_br->user_data((void *)&tree); -files_module_tree_br->clear(); -char buf[256]; -u32_t files = 0, dirs = 0; -// set parent dir id -if (tree.files.size()) - current_files_module_tree_path.mtag_id = tree.files[0]->compressed_fsize; -for (u32_t i = 0; i < tree.files.size(); i++) { - if (tree.files[i]->is_directory) - strcpy(buf, "\t@b@."); - else - strcpy(buf, "\t"); - strncat(buf, tree.files[i]->name.c_str(), 50); - char dir_len[64]; - if (tree.files[i]->is_directory) { - strcpy(dir_len, "\t@b@.< DIR >\t"); - dirs++; - } else { - sprintf(dir_len, "\t%llu\t", tree.files[i]->fsize); - files++; - } - strcat(buf, dir_len); - int cyear, cmonth, cday, chour, cmin, csec; - tree.files[i]->ctime.GetDate(cyear, cmonth, cday); - tree.files[i]->ctime.GetTime(chour, cmin, csec); - sprintf(dir_len, "%02d/%02d/%04d %02d:%02d:%02d\t", cday, cmonth, cyear, chour, cmin, csec); - strcat(buf, dir_len); - strcat(buf, tree.files[i]->mimetype.c_str()); - files_module_tree_br->add(buf); -} -files_module_tree_br->redraw(); -string root; -if (current_files_module_tree_path.tid() == SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST) - app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, root); -else - app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, root); -sprintf(buf, "Path: %s | Total %d file%s and %d director%s", (root + current_files_module_tree_path.name.c_str()).c_str(), files, (files == 1) ? "" : "s", dirs, - (dirs == 1) ? "y" : "ies"); -files_module_status_to->value(buf); -files_module_status_to->redraw(); -Fl::unlock(); -} - -void x11_ui::files_module_classify_reply(sfinx_string_t *classify_error) { - Fl::lock(); -if (classify_error->size() == 1) { - classify_file_w->hide(); - app->sfinx.send(current_files_module_tree_path); - // files_module_tree_br->remove(files_module_tree_br->value()); -} else - fl_alert(classify_error->c_str()); -Fl::unlock(); -} - -void x11_ui::progress(sfinx_progress_t *p) { - Fl::lock(); -static char buf[128]; -switch (p->status()) { - case SFINX_PROGRESS_START: - progress_l->label(p->label()); - strcpy(buf, p->strvalue()); - progress_bar->label(buf); - progress_bar->minimum(0); - progress_bar->maximum(p->max()); - progress_bar->value(p->value()); - progress_w->show(); - progress_w->redraw(); - break; - case SFINX_PROGRESS_END: - progress_w->hide(); - break; - case SFINX_PROGRESS_NONE: - default: - break; -} -Fl::unlock(); -} - -void x11_ui::alert(sfinx_string_t *alert) { - Fl::lock(); -if (alert->size() != 1) - fl_alert(alert->c_str()); -Fl::unlock(); -} - void x11_ui::notes_module_edit(sfinx_note_t *n) { Fl::lock(); sfinx_note_t *note = new sfinx_note_t; @@ -3614,7 +3554,10 @@ Fl::unlock(); void x11_ui::files_module_edit_reply(sfinx_string_t *classify_error) { Fl::lock(); if (classify_error->size() == 1) { - app->sfinx.send(current_files_module_tree_path); + if (current_file.tid() != SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST) + ::fill_objects_tree(files_tree, (1 << SFINX_FILE_OBJECT), 0, 1); // fluid bugs if any default params exists ! + else + app->sfinx.send(current_file); classify_file_w->hide(); } else fl_alert(classify_error->c_str()); @@ -3634,11 +3577,8 @@ file.ctime.GetTime(chour, cmin, csec); sprintf(buf, "%llu bytes | Modified: %02d/%02d/%04d %02d:%02d:%02d | Last Status Changed: %02d/%02d/%04d %02d:%02d:%02d", file.fsize, cday, cmonth, cyear, chour, cmin, csec, eday, emonth, eyear, ehour, emin, esec); string path; -if (current_files_module_tree_path.tid() == SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST) - app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, path); -else - app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, path); -string t = "URL: " + path + current_files_module_tree_path.name + "/" + file.name + " | " + file.mimetype + " | Size: " + buf; +app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, path); +string t = "URL: " + path + current_file.name + "/" + file.name + " | " + file.mimetype + " | Size: " + buf; classify_file_to->value(t.c_str()); file_title_i->value(file.title.c_str()); file_name_i->value(file.name.c_str()); @@ -3652,13 +3592,13 @@ file_comments_i->value(file.comments.c_str()); sorted_location_b->value(file.sorted_location); file_compress_b->value(file.store_compressed); file_gen_csum_b->value(file.generate_csum); -static string main_slice_name; -main_slice_name = app->slice_name(file.mtag_id); -file_main_slice_b->label(main_slice_name.c_str()); -file_main_slice_b->user_data(to_voidp(file.mtag_id)); // ÔÕÔÁ ÈÒÁÎÉÔÓÑ mtag_slice_id -file_additional_slices_br->clear(); -//for (u32_t i = 0; i < file.objects.size(); i++) -// file_additional_slices_br->add((app->slice_name(file.objects[i]).c_str()), to_voidp(file.objects[i])); +file_mtag_b->copy_label((file.mtag.name + " [ " + file.mtag.description + " ]").c_str()); +file_mtag_b->user_data(&file.mtag); +file_tags_br->clear(); +for (u32_t i = 0; i < file.tags.size(); i++) { + string s = file.tags[i].name + " [ " + file.tags[i].description + " ]"; + file_tags_br->add(s.c_str(), &(file.tags[i])); +} classify_file_w->user_data((void *)&file); classify_file_w->show(); Fl::unlock(); @@ -3712,7 +3652,7 @@ switch (el->tid()) { case SFINX_ELEMENT_FILE: f = (sfinx_file_t *)el; inf = "\nType: File\n"; - inf.append("Slice Hierarchy: " + app->slice_hierarchy(f->mtag_id) + "\n"); + inf.append("Slice Hierarchy: " + app->slice_hierarchy(f->mtag.id) + "\n"); /* if (f->slices.size()) { inf.append("Additional Slices : "); for (u32_t i = 0; i < f->slices.size(); i++) { @@ -3787,14 +3727,27 @@ for (u32_t i = 0; i < app->slices.len(); i++) { max_name_len = name.size(); if (!slice->parent_id) { node = tree->add_sub((char *)name.c_str(), 1, &slice_pixmap, to_voidp(slice)); - if (fill_tree_mask & (1 << SFINX_NOTE_OBJECT)) { + if (fill_tree_mask & ((1 << SFINX_NOTE_OBJECT) | (1 << SFINX_FILE_OBJECT))) { tree->open(node); // add notes for (u32_t x = 0; x < slice->objs.size(); x++) { - tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, ¬e_pixmap, - to_voidp(&(slice->objs[x]))); + switch (slice->objs[x].type) { + case SFINX_NOTE_OBJECT: + if (fill_tree_mask & (1 << SFINX_NOTE_OBJECT)) + tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, ¬e_pixmap, + to_voidp(&(slice->objs[x]))); + break; + case SFINX_FILE_OBJECT: + if (fill_tree_mask & (1 << SFINX_FILE_OBJECT)) + tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, &file_pixmap, + to_voidp(&(slice->objs[x]))); + break; + default: + debug("unsupported fill tree type %d", slice->objs[x].type); + break; + } // switch tree->traverse_up(); - } + } // for } } else { node = tree->traverse_start(); @@ -3807,15 +3760,28 @@ for (u32_t i = 0; i < app->slices.len(); i++) { if (node) { tree->open(node); node = tree->add_sub((char *)name.c_str(), 1, &slice_pixmap, to_voidp(slice)); - if (fill_tree_mask & (1 << SFINX_NOTE_OBJECT)) { - tree->open(node); - // add notes - for (u32_t x = 0; x < slice->objs.size(); x++) { - tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, ¬e_pixmap, - to_voidp(&(slice->objs[x]))); - tree->traverse_up(); - } - } + if (fill_tree_mask & ((1 << SFINX_NOTE_OBJECT) | (1 << SFINX_FILE_OBJECT))) { + tree->open(node); + // add notes + for (u32_t x = 0; x < slice->objs.size(); x++) { + switch (slice->objs[x].type) { + case SFINX_NOTE_OBJECT: + if (fill_tree_mask & (1 << SFINX_NOTE_OBJECT)) + tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, ¬e_pixmap, + to_voidp(&(slice->objs[x]))); + break; + case SFINX_FILE_OBJECT: + if (fill_tree_mask & (1 << SFINX_FILE_OBJECT)) + tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, &file_pixmap, + to_voidp(&(slice->objs[x]))); + break; + default: + debug("unsupported fill tree type %d", slice->objs[x].type); + break; + } // switch + tree->traverse_up(); + } // for + } } // node not found - just ignore } } @@ -3831,3 +3797,133 @@ tree->resize(tree->x(), tree->y(), width > tree_scroll->w() ? width : tree_scrol // slices_tree->select_range(node, node); Fl::unlock(); } + +void x11_ui::fill_unsorted_files_tree(sfinx_files_vector_t *tree_) { + Fl::lock(); +static sfinx_files_vector_t tree; +tree.copy(tree_); +files_module_tree_br->user_data((void *)&tree); +files_module_tree_br->clear(); +char buf[256]; +u32_t files = 0, dirs = 0; +// set parent dir id +if (tree.files.size()) + current_file.mtag.id = tree.files[0]->compressed_fsize; +for (u32_t i = 0; i < tree.files.size(); i++) { + if (tree.files[i]->is_directory) + strcpy(buf, "\t@b@."); + else + strcpy(buf, "\t"); + strncat(buf, tree.files[i]->name.c_str(), 50); + char dir_len[64]; + if (tree.files[i]->is_directory) { + strcpy(dir_len, "\t@b@.< DIR >\t"); + dirs++; + } else { + sprintf(dir_len, "\t%llu\t", tree.files[i]->fsize); + files++; + } + strcat(buf, dir_len); + int cyear, cmonth, cday, chour, cmin, csec; + tree.files[i]->ctime.GetDate(cyear, cmonth, cday); + tree.files[i]->ctime.GetTime(chour, cmin, csec); + sprintf(dir_len, "%02d/%02d/%04d %02d:%02d:%02d\t", cday, cmonth, cyear, chour, cmin, csec); + strcat(buf, dir_len); + strcat(buf, tree.files[i]->mimetype.c_str()); + files_module_tree_br->add(buf); +} +files_module_tree_br->redraw(); +string root; +app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, root); +sprintf(buf, "Path: %s | Total %d file%s and %d director%s", (root + current_file.name.c_str()).c_str(), files, (files == 1) ? "" : "s", dirs, + (dirs == 1) ? "y" : "ies"); +files_module_status_to->value(buf); +files_module_status_to->redraw(); +// this is unsorted tree +select_files_tree_b->user_data(0); +select_files_tree_b->label("Show Sorted"); +select_files_tree_b->redraw(); +files_tree_scroll->hide(); +files_module_tree_br->show(); +Fl::unlock(); +} + +void x11_ui::fill_preferences() { + Fl::lock(); +string t; +app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, t); +config_files_module_unsorted_path_i->value(t.c_str()); +app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, t); +config_files_module_sorted_path_i->value(t.c_str()); +app->files_module_conf.get(FILES_MODULE_DESC_FILE_NAME, t); +config_files_module_desc_file_name_i->value(t.c_str()); +u32_t gen_desc_files; +app->files_module_conf.get(FILES_MODULE_DESC_FILE_ENABLE, &gen_desc_files); +gen_desc_files_b->value(gen_desc_files); +Fl::unlock(); +} + +void x11_ui::log(int level, const char *fmt, ...) { + char buf[10240]; +const char *level_str; +static Mutex log_m; +log_m.enterMutex(); +Fl::lock(); +::va_list args; +::va_start(args, fmt); +::va_end(args); +switch (level) { + case SFINX_LOG_NOTICE: + level_str = "NOTICE"; + break; + case SFINX_LOG_WARN: + level_str = "WARN"; + break; + case SFINX_LOG_ERROR: + level_str = "ERROR"; + break; + case SFINX_LOG_FATAL: + level_str = "FATAL"; + break; + default: + level_str = "UNKN_LEVEL"; +} +// add time ? +strcpy(buf, level_str); +strcat(buf, ": "); +::vsnprintf(buf + strlen(level_str) + 2, sizeof(buf) - (strlen(level_str) + 2), fmt, args); +log_br->add(buf); +Fl::unlock(); +log_m.leaveMutex(); +} + +void x11_ui::progress(sfinx_progress_t *p) { + Fl::lock(); +static char buf[128]; +switch (p->status()) { + case SFINX_PROGRESS_START: + progress_l->label(p->label()); + strcpy(buf, p->strvalue()); + progress_bar->label(buf); + progress_bar->minimum(0); + progress_bar->maximum(p->max()); + progress_bar->value(p->value()); + progress_w->show(); + progress_w->redraw(); + break; + case SFINX_PROGRESS_END: + progress_w->hide(); + break; + case SFINX_PROGRESS_NONE: + default: + break; +} +Fl::unlock(); +} + +void x11_ui::alert(sfinx_string_t *alert) { + Fl::lock(); +if (alert->size() != 1) + fl_alert(alert->c_str()); +Fl::unlock(); +} diff --git a/faraon/x11_ui.H b/faraon/x11_ui.H index 4ff54e5..19c46e6 100644 --- a/faraon/x11_ui.H +++ b/faraon/x11_ui.H @@ -55,6 +55,7 @@ extern Fl_Output *files_module_status_to; extern Fl_Button *classify_file_b; extern Fl_Browser *files_module_tree_br; extern Fl_Button *select_files_tree_b; +extern Fl_Scroll_Resize *files_tree_scroll; extern Fl_Double_Window *classify_file_w; extern Fl_Input *file_title_i; extern Fl_Input *file_authority_i; @@ -64,20 +65,12 @@ extern Fl_Output *classify_file_to; extern Fl_Check_Button *sorted_location_b; extern Fl_Check_Button *file_crypt_b; extern Fl_Check_Button *file_compress_b; -extern Fl_Button *file_main_slice_b; -extern Fl_Browser *file_additional_slices_br; -extern Fl_Button *file_add_slice_b; -extern Fl_Button *file_remove_slice_b; +extern Fl_Button *file_mtag_b; +extern Fl_Browser *file_tags_br; +extern Fl_Button *file_add_tag_b; +extern Fl_Button *file_remove_tag_b; extern Fl_Input *file_name_i; extern Fl_Check_Button *file_gen_csum_b; -extern Fl_Double_Window *search_w; -extern Fl_Check_Button *search_in_files_b; -extern Fl_Browser *search_slices_br; -extern Fl_Button *search_add_slice_b; -extern Fl_Input *search_i; -extern Fl_Double_Window *search_browser_w; -extern Fl_Browser *search_browser_br; -extern Fl_Choice *goto_page_ch; extern Fl_Double_Window *notes_w; extern Fl_Output *notes_module_status_to; extern Fl_Scroll_Resize *notes_tree_scroll; @@ -94,6 +87,14 @@ extern Fl_Choice *note_secured_ch; extern Fl_Double_Window *delete_note_w; extern Fl_Output *delete_sfinx_note_to; extern Fl_Choice *note_deletion_type_ch; +extern Fl_Double_Window *search_browser_w; +extern Fl_Browser *search_browser_br; +extern Fl_Choice *goto_page_ch; +extern Fl_Double_Window *search_w; +extern Fl_Check_Button *search_in_files_b; +extern Fl_Browser *search_slices_br; +extern Fl_Button *search_add_slice_b; +extern Fl_Input *search_i; extern Fl_Double_Window *about_w; extern Fl_Menu_Item menu_[]; #define search_mi (menu_+21) diff --git a/faraon/x11_ui.fl b/faraon/x11_ui.fl index 29285d2..ea5d767 100644 --- a/faraon/x11_ui.fl +++ b/faraon/x11_ui.fl @@ -24,10 +24,14 @@ decl {\#include "slice.xpm"} {} decl {\#include "note.xpm"} {} +decl {\#include "file.xpm"} {} + decl {Fl_Pixmap slice_pixmap(slice_xpm_data);} {} decl {Fl_Pixmap note_pixmap(note_xpm_data);} {} +decl {Fl_Pixmap file_pixmap(file_xpm_data);} {} + decl {Fl_Toggle_Tree *config_tree;} {global } @@ -40,6 +44,9 @@ decl {Fl_Toggle_Tree *select_slice_tree;} {global decl {Fl_Toggle_Tree *notes_tree;} {global } +decl {Fl_Toggle_Tree *files_tree;} {global +} + decl {Fl_Toggle_Tree *fill_tree;} {} decl {sfinx_slice_t *fill_tree_except;} {global @@ -48,9 +55,9 @@ decl {sfinx_slice_t *fill_tree_except;} {global decl {u32_t fill_tree_mask;} {global } -decl {sfinx_file_t current_files_module_tree_path(SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST);} {} +decl {sfinx_file_t current_file(SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST);} {} -Function {fill_objects_tree(Fl_Toggle_Tree *ft, u32_t m, sfinx_slice_t *except, bool force)} {open private return_type void +Function {fill_objects_tree(Fl_Toggle_Tree *ft, u32_t m, sfinx_slice_t *except, bool force)} {private return_type void } { code {fill_tree = ft; fill_tree_mask = m; @@ -58,24 +65,27 @@ fill_tree_except = except; app->refresh_slices(force);} {} } -Function {relink_slice_action(sfinx_slice_t *selected)} {private return_type void +Function {relink_slice_action()} {private return_type void } { code {sfinx_slice_t slice(SFINX_SLICE_RELINK); // slice to be relinked Fl_Toggle_Node *node = slices_tree->selected(); if (!node) return; +Fl_Toggle_Node *snode = select_slice_tree->selected(); +if (!snode) + return; +sfinx_slice_t *selected = (sfinx_slice_t *)snode->user_data(); sfinx_slice_t *rslice = (sfinx_slice_t *)node->user_data(); slice.id = rslice->id; // new parent id slice.parent_id = selected->id; debug("moving from %lld to %lld", rslice->parent_id, selected->id); app->sfinx.send(slice); -select_slice_w->hide(); fill_objects_tree(slices_tree, SFINX_SLICE_OBJECT, 0, 1); // force refresh} {} } -Function {select_note_atag_action()} {open private return_type void +Function {select_note_atag_action()} {private return_type void } { code {sfinx_object_t *obj; Fl_Toggle_Node *node = slices_tree->selected(); @@ -89,7 +99,7 @@ Fl_Toggle_Node *snode = notes_tree->selected(); sfinx_object_t *sobj = (sfinx_object_t *)snode->user_data(); if (sobj == obj) // try to self tag return; -if (!obj->cmp((sfinx_object_t *)note_mtag_b->user_data())) // already set as main tag +if (note_mtag_b->user_data() && !obj->cmp((sfinx_object_t *)note_mtag_b->user_data())) // already set as main tag return; for (int i = 1; i <= note_tags_br->size(); i++) { if (!obj->cmp((sfinx_object_t *)note_tags_br->data(i))) // already set as additional tag @@ -100,7 +110,7 @@ note_tags_br->add(s.c_str(), obj); note_tags_br->redraw();} {} } -Function {select_note_mtag_action()} {open private return_type void +Function {select_note_mtag_action()} {private return_type void } { code {sfinx_object_t *obj; Fl_Toggle_Node *node = slices_tree->selected(); @@ -126,34 +136,50 @@ for (int i = 1; i <= note_tags_br->size(); i++) { }} {} } -Function {select_file_main_slice_action()} {private return_type void +Function {select_file_mtag_action()} {open private return_type void } { - code {//file_main_slice_b->user_data(to_voidp(current_slice_id)); -static string l; -sfinx_slice_t *slice = (sfinx_slice_t *)slices_tree->selected()->user_data(); -l = slice->name(); -file_main_slice_b->label(l.c_str()); -file_main_slice_b->redraw(); -// check for additional slices if it is here - remove it -for (int i = 1; i <= file_additional_slices_br->size(); i++) { -// if (file_additional_slices_br->data(i) == to_voidp(current_slice_id)) { -// file_additional_slices_br->remove(i); -// return; -// } + code {sfinx_object_t *obj; +Fl_Toggle_Node *node = select_slice_tree->selected(); +if (!node) + return; +if (node->can_open()) // slice + obj = ((sfinx_slice_t *)node->user_data())->object(); +else // object + obj = (sfinx_object_t *)node->user_data(); +file_mtag_b->user_data(obj); +file_mtag_b->copy_label((obj->name + " [ " + obj->description + " ]").c_str()); +file_mtag_b->redraw(); +// check for additional tags if it is here - remove it +for (int i = 1; i <= file_tags_br->size(); i++) { + if (!obj->cmp((sfinx_object_t *)file_tags_br->data(i))) { + file_tags_br->remove(i); + return; + } }} {} } -Function {select_file_additional_slice_action()} {private return_type void +Function {select_file_atag_action()} {open private return_type void } { - code {//if (to_voidp(current_slice_id) == file_main_slice_b->user_data()) // already set as main slice - //return; -//for (int i = 1; i <= file_additional_slices_br->size(); i++) { -// if (file_additional_slices_br->data(i) == to_voidp(current_slice_id)) -// return; -//} -//sfinx_slice_t *slice = (sfinx_slice_t *)slices_tree->selected()->user_data(); -//file_additional_slices_br->add(slice->name(), to_voidp(current_slice_id)); -file_additional_slices_br->redraw();} {} + code {sfinx_object_t *obj; +Fl_Toggle_Node *node = select_slice_tree->selected(); +if (!node) + return; +string s; +if (node->can_open()) { // slice + obj = ((sfinx_slice_t *)node->user_data())->object(); + s = obj->name + " [ " + obj->description + " ]"; +} else { // object + obj = (sfinx_object_t *)node->user_data(); + s = obj->name + obj->description; +} +if (file_mtag_b->user_data() && !obj->cmp((sfinx_object_t *)file_mtag_b->user_data())) // already set as main tag + return; +for (int i = 1; i <= file_tags_br->size(); i++) { + if (!obj->cmp((sfinx_object_t *)file_tags_br->data(i))) // already set as additional tag + return; +} +file_tags_br->add(s.c_str(), obj); +file_tags_br->redraw();} {} } Function {search_add_slice_action()} {private return_type void @@ -167,7 +193,7 @@ Function {search_add_slice_action()} {private return_type void search_slices_br->redraw();} {} } -Function {slices_tree_cb(Fl_Widget *, void *)} {open private return_type void +Function {slices_tree_cb(Fl_Widget *, void *)} {private return_type void } { code {Fl_Toggle_Node *node = slices_tree->selected(); if (!node) @@ -198,6 +224,20 @@ if (select_note_action) { }} {} } +Function {files_tree_cb(Fl_Widget *, void *)} {private return_type void +} { + code {Fl_Toggle_Node *node = files_tree->selected(); +if (!node) + return; +if (!Fl::event_clicks()) + return; +void (*select_file_action)(void) = (void (*)())(files_module_w->user_data()); +if (select_file_action) { + files_module_w->user_data(0); + select_file_action(); +}} {} +} + Function {select_slice_tree_cb(Fl_Widget *, void *)} {private return_type void } { code {if (!Fl::event_clicks()) @@ -248,7 +288,7 @@ Function {x11_ui::init()} {open return_type void Fl_Window main_w { label Faraon callback {if (fl_choice("Really quit ?", "No", "Yes", 0L)) - F::shutdown(0);} + F::shutdown(0);} open xywh {171 126 945 365} type Double hide } { Fl_Menu_Bar {} {open @@ -360,8 +400,7 @@ slices_w->show();} fl_message("Not connected to Sfinx Server !"); return; } -app->sfinx.send(SFINX_FILES_MODULE_CONF_REQUEST, (u8_t) 0); -if (app->sfinx.send(current_files_module_tree_path)) +if (app->sfinx.send(current_file)) return; files_module_w->show();} xywh {20 20 34 22} shortcut 0x66 labeltype ENGRAVED_LABEL @@ -614,9 +653,12 @@ preferences_w->hide();} callback {Fl_Toggle_Node *node = select_slice_tree->selected(); if (!node) return; -sfinx_slice_t *slice = (sfinx_slice_t *) node->user_data(); -void (*select_slice_action)(sfinx_slice_t *) = (void (*)(sfinx_slice_t *))(select_slice_b->user_data()); -select_slice_action(slice);} +void (*select_slice_action)() = (void (*)())(select_slice_w->user_data()); +if (select_slice_action) { + select_slice_w->user_data(0); + select_slice_action(); +} +select_slice_w->hide();} xywh {16 312 548 25} box PLASTIC_UP_BOX labeltype ENGRAVED_LABEL } Fl_Scroll select_slice_tree_scroll {open @@ -629,7 +671,7 @@ select_slice_action(slice);} } {} } Fl_Window slices_w { - label {Sfinx Data} open + label {Sfinx Data} xywh {200 315 866 370} type Double color 31 hide modal } { Fl_Button {} { @@ -701,7 +743,7 @@ sfinx_slice_t *slice = (sfinx_slice_t *)node->user_data(); if (slice->id == 1) // root slice can't be relinked return; fill_objects_tree(select_slice_tree, SFINX_SLICE_OBJECT, slice, 0); -select_slice_b->user_data((void *)relink_slice_action); +select_slice_w->user_data((void *)relink_slice_action); select_slice_w->show();} xywh {155 312 128 25} labeltype ENGRAVED_LABEL } @@ -830,7 +872,7 @@ fill_objects_tree(slices_tree, 1 << SFINX_SLICE_OBJECT, 0, 1); // force refresh} } } Fl_Window files_module_w { - label {Files Module} + label {Files Module} open xywh {87 152 730 370} type Double color 31 hide resizable } { Fl_Button {} { @@ -847,13 +889,8 @@ fill_objects_tree(slices_tree, 1 << SFINX_SLICE_OBJECT, 0, 1); // force refresh} if (!n) return; sfinx_file_t *file = ((sfinx_files_vector_t *)files_module_tree_br->user_data())->files[n - 1]; -//debug("slice_id - %d, parent_id - %d, name - %s", current_files_module_tree_path.file_id, current_files_module_tree_path.mtag_slice_id, -// file->name.c_str()); string path; -//if (current_files_module_tree_path.tid() == SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST) -// app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, path); -//else -// app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, path); +app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, path); char buf[256]; int eyear, emonth, eday, ehour, emin, esec, cyear, cmonth, cday, chour, cmin, csec; file->etime.GetDate(eyear, emonth, eday); @@ -862,7 +899,7 @@ file->ctime.GetDate(cyear, cmonth, cday); file->ctime.GetTime(chour, cmin, csec); sprintf(buf, "%llu bytes | Modified: %02d/%02d/%04d %02d:%02d:%02d | Last Status Changed: %02d/%02d/%04d %02d:%02d:%02d", file->fsize, cday, cmonth, cyear, chour, cmin, csec, eday, emonth, eyear, ehour, emin, esec); -string t = "URL: " + path + current_files_module_tree_path.name + "/" + file->name + " | " + file->mimetype + " | Size: " + buf; +string t = "URL: " + path + current_file.name + "/" + file->name + " | " + file->mimetype + " | Size: " + buf; classify_file_to->value(t.c_str()); file_title_i->value(0); file_name_i->value(file->name.c_str()); @@ -876,15 +913,26 @@ file_comments_i->value(0); sorted_location_b->value(1); file_compress_b->value(1); file_gen_csum_b->value(1); -file_main_slice_b->label("Main Slice (Not Set)"); -file_main_slice_b->user_data(0); // ÔÕÔÁ ÈÒÁÎÉÔÓÑ slice_id -file_additional_slices_br->clear(); +file_mtag_b->label("Main Slice (Not Set)"); +file_mtag_b->user_data(0); // ÔÕÔÁ ÈÒÁÎÉÔÓÑ mtag +file_tags_br->clear(); classify_file_w->user_data((void *)file); classify_file_w->show();} xywh {21 312 112 25} labeltype ENGRAVED_LABEL } Fl_Button {} { label Edit + callback {Fl_Toggle_Node *node = files_tree->selected(); +if (!node || node->can_open()) { + fl_alert("Please select file to edit !"); + return; +} +sfinx_object_t *obj = (sfinx_object_t *) node->user_data(); +if (obj->type != SFINX_FILE_OBJECT) + bug(); +sfinx_file_t file(SFINX_FILES_MODULE_EDIT_REQUEST); +file.id = obj->id; +app->sfinx.send(file);} xywh {154 312 128 25} labeltype ENGRAVED_LABEL } Fl_Browser files_module_tree_br { @@ -897,18 +945,18 @@ if (tree->files[n - 1]->is_directory) { // // × file_id ÈÒÁÎÉÔÓÑ id ÔÅËÕÝÅÊ ÄÉÒÅËÔÏÒÉÉ-ÓÌÁÊÓÁ × ËÏÔÏÒÏÊ ÎÁÈÏÄÉÍÓÑ/×ÙÂÒÁÌÉ // × mtag_id - parent_id ÄÉÒÅËÔÏÒÉÉ // ÚÁÈÏÄÉÍ × ÄÉÒÅËÔÏÒÉÀ - ÔÅËÕÝÁÑ ÓÔÁÎÏ×ÉÔÓÑ parent'ÏÍ - current_files_module_tree_path.file_id = tree->files[n - 1]->file_id; - current_files_module_tree_path.mtag_id = tree->files[n - 1]->mtag_id; + current_file.id = tree->files[n - 1]->id; + current_file.mtag.id = tree->files[n - 1]->mtag.id; // × name ÈÒÁÎÉÔÓÑ ×ÅÓØ ÐÕÔØ ÏÔ root location // × orig_name ÔÏÌØËÏ ÉÍÑ ÔÅËÕÝÅÊ - string t = current_files_module_tree_path.name.c_str(); -// current_files_module_tree_path.orig_name = tree->files[n - 1]->name; + string t = current_file.name.c_str(); +// current_file.orig_name = tree->files[n - 1]->name; t += ('/' + tree->files[n - 1]->name); - current_files_module_tree_path.name = t; - //debug("requesting dir %s", current_files_module_tree_path.c_str()); - app->sfinx.send(current_files_module_tree_path); + current_file.name = t; + //debug("requesting dir %s", current_file.c_str()); + app->sfinx.send(current_file); } else { - if (!(tree->files[n - 1]->file_id)) // classify file + if (!(tree->files[n - 1]->id)) // classify file classify_file_b->do_callback(); else { // app->sfinx.send(SFINX_SLICES_MODULE_TREE_REQUEST, (u8_t)0); // prepare for slice_name() calls @@ -917,90 +965,97 @@ if (tree->files[n - 1]->is_directory) { // app->sfinx.send(file); } }} - xywh {8 45 716 255} type Multi color 31 resizable + xywh {7 45 716 255} type Multi color 31 resizable code0 {static int widths[] = { 10, 450, 200, 200, 0};} code1 {files_module_tree_br->column_widths(widths);} } Fl_Button {} { label Delete - callback {int n = files_module_tree_br->value(); -if (!n) - return; -sfinx_file_t *file = ((sfinx_files_vector_t *)files_module_tree_br->user_data())->files[n - 1]; -string path; -if (current_files_module_tree_path.tid() == SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST) { - // sure ? - string message = "Deleting \\'" + file->name + "\\'. Are you sure ?"; + callback {if (current_file.tid() == SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST) { // unsorted tree + int n = files_module_tree_br->value(); + if (!n) + return; + sfinx_file_t *file = ((sfinx_files_vector_t *)files_module_tree_br->user_data())->files[n - 1]; + string path; // sure ? + string message = "Deleting "; + if (file->is_directory) + message += "directory"; + else + message += "file"; + message += (" \\'" + file->name + "\\'. Are you sure ?"); if (fl_choice(message.c_str(), "Yes", "No", 0L)) return; - app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, path); - path += "/" + file->name; - sfinx_string_t f(SFINX_FILES_MODULE_UNLINK); - f.set(path); - app->sfinx.send(f); -} else { - // sorted can be marked unsorted or deleted - string message = "Delete or Unsort \\'" + file->name + "\\' ?"; + file->tid(SFINX_FILES_MODULE_UNSORTED_DELETE); + app->sfinx.send(file); // check for errors ? + app->sfinx.send(current_file); +} else { // sorted tree + Fl_Toggle_Node *node = files_tree->selected(); + if (!node || node->can_open()) + return; + sfinx_object_t *obj = (sfinx_object_t *) node->user_data(); + string message = "Delete or Unsort \\'" + obj->name + "\\' ?"; int res = fl_choice(message.c_str(), "Cancel", "Unsort", "Delete"); + sfinx_file_t file; + file.id = obj->id; + file.mtag.slice_id = obj->slice_id; if (!res) return; - if (res == 2) { // delete - file->tid(SFINX_FILES_MODULE_SORTED_UNLINK); - app->sfinx.send(file); - } else { - file->tid(SFINX_FILES_MODULE_UNSORT); - app->sfinx.send(file); - } -} -//files_module_tree_br->remove(n); -app->sfinx.send(current_files_module_tree_path);} + if (res == 2) // delete + file.tid(SFINX_FILES_MODULE_SORTED_UNLINK); + else + file.tid(SFINX_FILES_MODULE_UNSORT); + app->sfinx.send(file); + fill_objects_tree(files_tree, (1 << SFINX_FILE_OBJECT), 0, 1); // fluid bugs if any default params exists ! + +}} xywh {300 312 112 25} labeltype ENGRAVED_LABEL } Fl_Button select_files_tree_b { label {Sorted tree} - callback {files_module_tree_br->clear(); -current_files_module_tree_path.name.clear(); -current_files_module_tree_path.orig_name.clear(); + callback {current_file.name.clear(); +current_file.orig_name.clear(); if (select_files_tree_b->user_data()) { - select_files_tree_b->user_data(0); - select_files_tree_b->label("Sorted tree"); - current_files_module_tree_path.tid(SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST); - current_files_module_tree_path.file_id = 0; + current_file.tid(SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST); + current_file.id = 0; + app->sfinx.send(current_file); } else { select_files_tree_b->user_data((void *)1); - select_files_tree_b->label("Unsorted tree"); -// current_files_module_tree_path.tid(SFINX_FILES_MODULE_SORTED_TREE_REQUEST); - current_files_module_tree_path.file_id = 1; // root id - -} -select_files_tree_b->redraw(); -app->sfinx.send(current_files_module_tree_path);} + select_files_tree_b->label("Show Unsorted"); + select_files_tree_b->redraw(); + current_file.tid(0); + current_file.id = 1; // root id + fill_objects_tree(files_tree, 1 << SFINX_FILE_OBJECT, 0, 0); // fluid bugs if any default params exists ! + files_module_tree_br->hide(); + files_tree_scroll->show(); +}} xywh {562 10 128 25} labeltype ENGRAVED_LABEL } Fl_Button {} { label {Up [ .. ]} - callback {const char *p = strrchr(current_files_module_tree_path.name.c_str(), '/'); -if (!p) - current_files_module_tree_path.name.clear(); -else { + callback {const char *p = strrchr(current_file.name.c_str(), '/'); +if (!p) { + if (!current_file.name.size()) + return; + current_file.name.clear(); +} else { char path[1024]; path[0] = 0; - strncat(path, current_files_module_tree_path.name.c_str(), p - current_files_module_tree_path.name.c_str()); - current_files_module_tree_path.name = path; - current_files_module_tree_path.file_id = current_files_module_tree_path.mtag_id; + strncat(path, current_file.name.c_str(), p - current_file.name.c_str()); + current_file.name = path; + current_file.id = current_file.mtag.id; } -app->sfinx.send(current_files_module_tree_path);} +app->sfinx.send(current_file);} xywh {35 10 112 25} labeltype ENGRAVED_LABEL } Fl_Button {} { label Reload - callback {app->sfinx.send(current_files_module_tree_path);} + callback {app->sfinx.send(current_file);} xywh {166 10 112 25} labeltype ENGRAVED_LABEL } Fl_Button {} { label {Select All} - callback {for (int i = 1; i <= files_module_tree_br->size(); i++) - files_module_tree_br->select(i);} + callback {//for (int i = 1; i <= files_module_tree_br->size(); i++) +// files_module_tree_br->select(i);} xywh {295 10 112 25} labeltype ENGRAVED_LABEL } Fl_Button {} { @@ -1008,9 +1063,17 @@ app->sfinx.send(current_files_module_tree_path);} callback {files_module_tree_br->deselect();} xywh {428 10 112 25} labeltype ENGRAVED_LABEL } + Fl_Scroll files_tree_scroll { + xywh {7 45 716 255} box ENGRAVED_FRAME color 28 hide + code0 {files_tree = new Fl_Toggle_Tree(12, 12, files_tree_scroll->w(), 10);} + code1 {files_tree->callback(files_tree_cb); files_tree->user_data((void *)files_tree_scroll);} + code2 {files_module_w->resizable(files_tree_scroll);} + code3 {files_tree_scroll->resizable(files_tree);} + class Fl_Scroll_Resize + } {} } Fl_Window classify_file_w { - label {Classify File} + label {Classify File} open xywh {84 298 1020 515} type Double color 31 hide modal } { Fl_Button {} { @@ -1039,7 +1102,7 @@ app->sfinx.send(current_files_module_tree_path);} } Fl_Return_Button {} { label Ok - callback {if (!file_main_slice_b->user_data()) { + callback {if (!file_mtag_b->user_data()) { fl_alert("You have to select Main Slice for file !"); return; } @@ -1048,7 +1111,6 @@ if (!file_name_i->size()) { return; } sfinx_file_t *file = (sfinx_file_t *)classify_file_w->user_data(); -// file->tid(SFINX_FILES_MODULE_CLASSIFY_REQUEST); file->name = file_name_i->value(); file->title = file_title_i->value(); file->authority = file_authority_i->value(); @@ -1057,10 +1119,16 @@ file->comments = file_comments_i->value(); file->sorted_location = sorted_location_b->value(); file->store_compressed = file_compress_b->value(); file->generate_csum = file_gen_csum_b->value(); -file->mtag_id = from_voidp(file_main_slice_b->user_data()); -file->objects.clear(); -for (int i = 1; i <= file_additional_slices_br->size(); i++) { -// file->objects.push_back(from_voidp(file_additional_slices_br->data(i))); +sfinx_object_t *obj = (sfinx_object_t *)file_mtag_b->user_data(); +file->mtag.id = obj->id; +file->mtag.type = obj->type; +file->mtag.slice_id = obj->slice_id; +file_mtag_b->user_data(0); +file->tags.clear(); +for (int i = 1; i <= file_tags_br->size(); i++) { + obj = (sfinx_object_t *)file_tags_br->data(i); + file->tags.push_back(*obj); + file_tags_br->data(i, 0); } app->sfinx.send(file);} xywh {243 454 112 25} labeltype ENGRAVED_LABEL @@ -1080,29 +1148,29 @@ app->sfinx.send(file);} Fl_Box {} { xywh {13 205 552 227} box ENGRAVED_FRAME } - Fl_Button file_main_slice_b { + Fl_Button file_mtag_b { label {Main Slice (Not Set)} - callback {app->refresh_slices(); -slices_w->user_data((void *)select_file_main_slice_action); -slices_w->show();} + callback {fill_objects_tree(select_slice_tree, (1 << SFINX_SLICE_OBJECT) | (1 << SFINX_FILE_OBJECT) | (1 << SFINX_NOTE_OBJECT), 0, 0); // fluid bugs if any default params exists ! +select_slice_w->user_data((void *)select_file_mtag_action); +select_slice_w->show();} tooltip {File Main Slice} xywh {45 226 489 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL } - Fl_Browser file_additional_slices_br { + Fl_Browser file_tags_br { label {Additional Slices} xywh {26 275 525 102} type Multi color 46 labeltype ENGRAVED_LABEL align 1 } - Fl_Button file_add_slice_b { + Fl_Button file_add_tag_b { label {Add Slice} - callback {app->refresh_slices(); -slices_w->user_data((void *)select_file_additional_slice_action); -slices_w->show();} + callback {fill_objects_tree(select_slice_tree, (1 << SFINX_SLICE_OBJECT) | (1 << SFINX_FILE_OBJECT) | (1 << SFINX_NOTE_OBJECT), 0, 0); // fluid bugs if any default params exists ! +select_slice_w->user_data((void *)select_file_atag_action); +select_slice_w->show();} xywh {82 391 138 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL } - Fl_Button file_remove_slice_b { + Fl_Button file_remove_tag_b { label {Remove Slice} - callback {for (int i = file_additional_slices_br->size(); i >= 1; i--) { - if (file_additional_slices_br->selected(i)) - file_additional_slices_br->remove(i); + callback {for (int i = file_tags_br->size(); i >= 1; i--) { + if (file_tags_br->selected(i)) + file_tags_br->remove(i); }} xywh {358 391 138 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL } @@ -1115,84 +1183,9 @@ slices_w->show();} xywh {274 165 241 23} box PLASTIC_UP_BOX down_box DOWN_BOX selection_color 15 labeltype ENGRAVED_LABEL align 16 } } - Fl_Window search_w { - label Search - xywh {169 380 749 389} type Double color 31 hide modal - } { - Fl_Button {} { - label Cancel - callback {search_w->hide();} - xywh {182 347 363 25} box PLASTIC_ROUND_UP_BOX labeltype ENGRAVED_LABEL - } - Fl_Return_Button {} { - label Search - callback {sfinx_search_query_t query; -query.pattern = search_i->value(); -if (search_in_files_b->value()) - query.add_area(SFINX_SEARCH_IN_FILES); -// add restrictions ... -app->sfinx.send(query);} - xywh {539 48 163 25} box PLASTIC_ROUND_UP_BOX labeltype ENGRAVED_LABEL - } - Fl_Check_Button search_in_files_b { - label {Search in Files} - xywh {48 96 241 23} box PLASTIC_UP_BOX down_box DOWN_BOX selection_color 15 labeltype ENGRAVED_LABEL align 16 deactivate - } - Fl_Box {} { - xywh {87 141 561 189} box ROUNDED_FRAME - } - Fl_Browser search_slices_br { - label {Restrict Search by Slices} - xywh {105 173 525 102} type Multi color 46 labeltype ENGRAVED_LABEL align 1 - } - Fl_Button search_add_slice_b { - label {Add Slice} - callback {app->refresh_slices(); -slices_w->user_data((void *)search_add_slice_action); -slices_w->show();} - xywh {161 289 138 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL - } - Fl_Button {} { - label {Remove Slice} - callback {for (int i = search_slices_br->size(); i >= 1; i--) { - if (search_slices_br->selected(i)) - search_slices_br->remove(i); -}} - xywh {437 289 138 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL - } - Fl_Input search_i { - label {Search for ...} - xywh {46 47 447 26} color 29 labeltype ENGRAVED_LABEL align 1 - } - } - Fl_Window search_browser_w { - label {Search Browser} - xywh {217 305 854 476} type Double color 31 hide resizable modal - } { - Fl_Button {} { - label Cancel - callback {search_browser_w->hide();} - xywh {638 449 187 20} box PLASTIC_ROUND_UP_BOX color 0 labeltype ENGRAVED_LABEL - } - Fl_Browser search_browser_br { - xywh {4 4 846 439} type Hold box GTK_THIN_UP_BOX color 44 resizable - } - Fl_Button {} { - label {Previous Page} - xywh {25 449 169 20} box PLASTIC_ROUND_UP_BOX color 0 labeltype ENGRAVED_LABEL - } - Fl_Button {} { - label {Next Page} - xywh {231 449 169 20} box PLASTIC_ROUND_UP_BOX color 0 labeltype ENGRAVED_LABEL - } - Fl_Choice goto_page_ch { - label {Current Page } - xywh {531 450 72 20} box PLASTIC_THIN_UP_BOX down_box PLASTIC_THIN_UP_BOX color 44 labeltype ENGRAVED_LABEL - } {} - } Fl_Window notes_w { - label {Notes Module} open - xywh {272 69 730 370} type Double color 31 hide resizable + label {Notes Module} + xywh {272 69 730 370} type Double color 31 resizable visible } { Fl_Button {} { label Cancel @@ -1241,7 +1234,7 @@ note.id = obj->id; app->sfinx.send(note);} xywh {154 312 128 25} labeltype ENGRAVED_LABEL } - Fl_Scroll notes_tree_scroll {selected + Fl_Scroll notes_tree_scroll { xywh {13 10 705 289} box ENGRAVED_FRAME color 28 code0 {notes_tree = new Fl_Toggle_Tree(12, 12, notes_tree_scroll->w(), 10);} code1 {notes_tree->callback(notes_tree_cb); notes_tree->user_data((void *)notes_tree_scroll);} @@ -1316,8 +1309,7 @@ for (int i = 1; i <= note_tags_br->size(); i++) { } app->sfinx.send(note); delete note; -edit_note_w->user_data(0); -fill_objects_tree(notes_tree, 1 << SFINX_NOTE_OBJECT, 0, 1); // force refresh} +edit_note_w->user_data(0);} xywh {279 321 112 25} labeltype ENGRAVED_LABEL } Fl_Box {} { @@ -1364,7 +1356,7 @@ slices_w->show();} } } Fl_Window delete_note_w { - label {Delete Note} open + label {Delete Note} xywh {44 182 388 168} type Double color 31 hide modal } { Fl_Button {} { @@ -1377,6 +1369,7 @@ slices_w->show();} callback {sfinx_object_t *obj = (sfinx_object_t *) delete_note_w->user_data(); sfinx_note_t note(note_deletion_type_ch->value() ? SFINX_NOTES_MODULE_UNLINK : SFINX_NOTES_MODULE_UNSORT); note.id = obj->id; +note.mtag.slice_id = obj->slice_id; app->sfinx.send(note); delete_note_w->user_data(0); delete_note_w->hide(); @@ -1401,6 +1394,81 @@ fill_objects_tree(notes_tree, (1 << SFINX_SLICE_OBJECT) | (1 << SFINX_NOTE_OBJEC } } } + Fl_Window search_browser_w { + label {Search Browser} + xywh {217 305 854 476} type Double color 31 hide resizable modal + } { + Fl_Button {} { + label Cancel + callback {search_browser_w->hide();} + xywh {638 449 187 20} box PLASTIC_ROUND_UP_BOX color 0 labeltype ENGRAVED_LABEL + } + Fl_Browser search_browser_br { + xywh {4 4 846 439} type Hold box GTK_THIN_UP_BOX color 44 resizable + } + Fl_Button {} { + label {Previous Page} + xywh {25 449 169 20} box PLASTIC_ROUND_UP_BOX color 0 labeltype ENGRAVED_LABEL + } + Fl_Button {} { + label {Next Page} + xywh {231 449 169 20} box PLASTIC_ROUND_UP_BOX color 0 labeltype ENGRAVED_LABEL + } + Fl_Choice goto_page_ch { + label {Current Page } + xywh {531 450 72 20} box PLASTIC_THIN_UP_BOX down_box PLASTIC_THIN_UP_BOX color 44 labeltype ENGRAVED_LABEL + } {} + } + Fl_Window search_w { + label Search + xywh {169 380 749 389} type Double color 31 hide modal + } { + Fl_Button {} { + label Cancel + callback {search_w->hide();} + xywh {182 347 363 25} box PLASTIC_ROUND_UP_BOX labeltype ENGRAVED_LABEL + } + Fl_Return_Button {} { + label Search + callback {sfinx_search_query_t query; +query.pattern = search_i->value(); +if (search_in_files_b->value()) + query.add_area(SFINX_SEARCH_IN_FILES); +// add restrictions ... +app->sfinx.send(query);} + xywh {539 48 163 25} box PLASTIC_ROUND_UP_BOX labeltype ENGRAVED_LABEL + } + Fl_Check_Button search_in_files_b { + label {Search in Files} + xywh {48 96 241 23} box PLASTIC_UP_BOX down_box DOWN_BOX selection_color 15 labeltype ENGRAVED_LABEL align 16 deactivate + } + Fl_Box {} { + xywh {87 141 561 189} box ROUNDED_FRAME + } + Fl_Browser search_slices_br { + label {Restrict Search by Slices} + xywh {105 173 525 102} type Multi color 46 labeltype ENGRAVED_LABEL align 1 + } + Fl_Button search_add_slice_b { + label {Add Slice} + callback {app->refresh_slices(); +slices_w->user_data((void *)search_add_slice_action); +slices_w->show();} + xywh {161 289 138 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL + } + Fl_Button {} { + label {Remove Slice} + callback {for (int i = search_slices_br->size(); i >= 1; i--) { + if (search_slices_br->selected(i)) + search_slices_br->remove(i); +}} + xywh {437 289 138 25} box PLASTIC_THIN_UP_BOX labeltype ENGRAVED_LABEL + } + Fl_Input search_i { + label {Search for ...} + xywh {46 47 447 26} color 29 labeltype ENGRAVED_LABEL align 1 + } + } Fl_Window about_w { xywh {357 229 374 154} type Double hide } { @@ -1436,41 +1504,6 @@ fill_objects_tree(notes_tree, (1 << SFINX_SLICE_OBJECT) | (1 << SFINX_NOTE_OBJEC code {main_w->show();} {} } -Function {x11_ui::log(int level, const char *fmt, ...)} {return_type void -} { - code {char buf[10240]; -const char *level_str; -static Mutex log_m; -log_m.enterMutex(); -Fl::lock(); -::va_list args; -::va_start(args, fmt); -::va_end(args); -switch (level) { - case SFINX_LOG_NOTICE: - level_str = "NOTICE"; - break; - case SFINX_LOG_WARN: - level_str = "WARN"; - break; - case SFINX_LOG_ERROR: - level_str = "ERROR"; - break; - case SFINX_LOG_FATAL: - level_str = "FATAL"; - break; - default: - level_str = "UNKN_LEVEL"; -} -// add time ? -strcpy(buf, level_str); -strcat(buf, ": "); -::vsnprintf(buf + strlen(level_str) + 2, sizeof(buf) - (strlen(level_str) + 2), fmt, args); -log_br->add(buf); -Fl::unlock(); -log_m.leaveMutex();} {} -} - Function {x11_ui::edit_slice(sfinx_slice_t *slice)} {return_type void } { code {// need locks @@ -1495,115 +1528,6 @@ edit_slice_w->show(); Fl::unlock();} {} } -Function {x11_ui::fill_preferences()} {return_type void -} { - code {Fl::lock(); -string t; -app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, t); -config_files_module_unsorted_path_i->value(t.c_str()); -app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, t); -config_files_module_sorted_path_i->value(t.c_str()); -app->files_module_conf.get(FILES_MODULE_DESC_FILE_NAME, t); -config_files_module_desc_file_name_i->value(t.c_str()); -u32_t gen_desc_files; -app->files_module_conf.get(FILES_MODULE_DESC_FILE_ENABLE, &gen_desc_files); -gen_desc_files_b->value(gen_desc_files); -Fl::unlock();} {} -} - -Function {x11_ui::fill_files_module_tree(sfinx_files_vector_t *tree_)} {return_type void -} { - code {Fl::lock(); -static sfinx_files_vector_t tree; -tree.copy(tree_); -files_module_tree_br->user_data((void *)&tree); -files_module_tree_br->clear(); -char buf[256]; -u32_t files = 0, dirs = 0; -// set parent dir id -if (tree.files.size()) - current_files_module_tree_path.mtag_id = tree.files[0]->compressed_fsize; -for (u32_t i = 0; i < tree.files.size(); i++) { - if (tree.files[i]->is_directory) - strcpy(buf, "\\t@b@."); - else - strcpy(buf, "\\t"); - strncat(buf, tree.files[i]->name.c_str(), 50); - char dir_len[64]; - if (tree.files[i]->is_directory) { - strcpy(dir_len, "\\t@b@.< DIR >\\t"); - dirs++; - } else { - sprintf(dir_len, "\\t%llu\\t", tree.files[i]->fsize); - files++; - } - strcat(buf, dir_len); - int cyear, cmonth, cday, chour, cmin, csec; - tree.files[i]->ctime.GetDate(cyear, cmonth, cday); - tree.files[i]->ctime.GetTime(chour, cmin, csec); - sprintf(dir_len, "%02d/%02d/%04d %02d:%02d:%02d\\t", cday, cmonth, cyear, chour, cmin, csec); - strcat(buf, dir_len); - strcat(buf, tree.files[i]->mimetype.c_str()); - files_module_tree_br->add(buf); -} -files_module_tree_br->redraw(); -string root; -if (current_files_module_tree_path.tid() == SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST) - app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, root); -else - app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, root); -sprintf(buf, "Path: %s | Total %d file%s and %d director%s", (root + current_files_module_tree_path.name.c_str()).c_str(), files, (files == 1) ? "" : "s", dirs, - (dirs == 1) ? "y" : "ies"); -files_module_status_to->value(buf); -files_module_status_to->redraw(); -Fl::unlock();} {} -} - -Function {x11_ui::files_module_classify_reply(sfinx_string_t *classify_error)} {return_type void -} { - code {Fl::lock(); -if (classify_error->size() == 1) { - classify_file_w->hide(); - app->sfinx.send(current_files_module_tree_path); - // files_module_tree_br->remove(files_module_tree_br->value()); -} else - fl_alert(classify_error->c_str()); -Fl::unlock();} {} -} - -Function {x11_ui::progress(sfinx_progress_t *p)} {return_type void -} { - code {Fl::lock(); -static char buf[128]; -switch (p->status()) { - case SFINX_PROGRESS_START: - progress_l->label(p->label()); - strcpy(buf, p->strvalue()); - progress_bar->label(buf); - progress_bar->minimum(0); - progress_bar->maximum(p->max()); - progress_bar->value(p->value()); - progress_w->show(); - progress_w->redraw(); - break; - case SFINX_PROGRESS_END: - progress_w->hide(); - break; - case SFINX_PROGRESS_NONE: - default: - break; -} -Fl::unlock();} {} -} - -Function {x11_ui::alert(sfinx_string_t *alert)} {return_type void -} { - code {Fl::lock(); -if (alert->size() != 1) - fl_alert(alert->c_str()); -Fl::unlock();} {} -} - Function {x11_ui::notes_module_edit(sfinx_note_t *n)} {open return_type void } { code {Fl::lock(); @@ -1638,7 +1562,7 @@ edit_note_w->show(); Fl::unlock();} {} } -Function {x11_ui::notes_module_reply(sfinx_string_t *classify_error)} {open return_type void +Function {x11_ui::notes_module_reply(sfinx_string_t *classify_error)} {return_type void } { code {Fl::lock(); if (classify_error->size() == 1) { @@ -1653,14 +1577,17 @@ Function {x11_ui::files_module_edit_reply(sfinx_string_t *classify_error)} {open } { code {Fl::lock(); if (classify_error->size() == 1) { - app->sfinx.send(current_files_module_tree_path); + if (current_file.tid() != SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST) + ::fill_objects_tree(files_tree, (1 << SFINX_FILE_OBJECT), 0, 1); // fluid bugs if any default params exists ! + else + app->sfinx.send(current_file); classify_file_w->hide(); } else fl_alert(classify_error->c_str()); Fl::unlock();} {} } -Function {x11_ui::files_module_edit(sfinx_file_t *f)} {open return_type void +Function {x11_ui::files_module_edit(sfinx_file_t *f)} {return_type void } { code {Fl::lock(); static sfinx_file_t file; @@ -1674,11 +1601,8 @@ file.ctime.GetTime(chour, cmin, csec); sprintf(buf, "%llu bytes | Modified: %02d/%02d/%04d %02d:%02d:%02d | Last Status Changed: %02d/%02d/%04d %02d:%02d:%02d", file.fsize, cday, cmonth, cyear, chour, cmin, csec, eday, emonth, eyear, ehour, emin, esec); string path; -if (current_files_module_tree_path.tid() == SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST) - app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, path); -else - app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, path); -string t = "URL: " + path + current_files_module_tree_path.name + "/" + file.name + " | " + file.mimetype + " | Size: " + buf; +app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, path); +string t = "URL: " + path + current_file.name + "/" + file.name + " | " + file.mimetype + " | Size: " + buf; classify_file_to->value(t.c_str()); file_title_i->value(file.title.c_str()); file_name_i->value(file.name.c_str()); @@ -1692,13 +1616,13 @@ file_comments_i->value(file.comments.c_str()); sorted_location_b->value(file.sorted_location); file_compress_b->value(file.store_compressed); file_gen_csum_b->value(file.generate_csum); -static string main_slice_name; -main_slice_name = app->slice_name(file.mtag_id); -file_main_slice_b->label(main_slice_name.c_str()); -file_main_slice_b->user_data(to_voidp(file.mtag_id)); // ÔÕÔÁ ÈÒÁÎÉÔÓÑ mtag_slice_id -file_additional_slices_br->clear(); -//for (u32_t i = 0; i < file.objects.size(); i++) -// file_additional_slices_br->add((app->slice_name(file.objects[i]).c_str()), to_voidp(file.objects[i])); +file_mtag_b->copy_label((file.mtag.name + " [ " + file.mtag.description + " ]").c_str()); +file_mtag_b->user_data(&file.mtag); +file_tags_br->clear(); +for (u32_t i = 0; i < file.tags.size(); i++) { + string s = file.tags[i].name + " [ " + file.tags[i].description + " ]"; + file_tags_br->add(s.c_str(), &(file.tags[i])); +} classify_file_w->user_data((void *)&file); classify_file_w->show(); Fl::unlock();} {} @@ -1754,7 +1678,7 @@ switch (el->tid()) { case SFINX_ELEMENT_FILE: f = (sfinx_file_t *)el; inf = "\\nType: File\\n"; - inf.append("Slice Hierarchy: " + app->slice_hierarchy(f->mtag_id) + "\\n"); + inf.append("Slice Hierarchy: " + app->slice_hierarchy(f->mtag.id) + "\\n"); /* if (f->slices.size()) { inf.append("Additional Slices : "); for (u32_t i = 0; i < f->slices.size(); i++) { @@ -1797,7 +1721,7 @@ switch (el->tid()) { }} {} } -Function {x11_ui::fill_objects_tree()} {open return_type void +Function {x11_ui::fill_objects_tree()} {return_type void } { code {Fl::lock(); Fl_Toggle_Tree *tree = fill_tree; @@ -1830,14 +1754,27 @@ for (u32_t i = 0; i < app->slices.len(); i++) { max_name_len = name.size(); if (!slice->parent_id) { node = tree->add_sub((char *)name.c_str(), 1, &slice_pixmap, to_voidp(slice)); - if (fill_tree_mask & (1 << SFINX_NOTE_OBJECT)) { + if (fill_tree_mask & ((1 << SFINX_NOTE_OBJECT) | (1 << SFINX_FILE_OBJECT))) { tree->open(node); // add notes for (u32_t x = 0; x < slice->objs.size(); x++) { - tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, ¬e_pixmap, - to_voidp(&(slice->objs[x]))); + switch (slice->objs[x].type) { + case SFINX_NOTE_OBJECT: + if (fill_tree_mask & (1 << SFINX_NOTE_OBJECT)) + tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, ¬e_pixmap, + to_voidp(&(slice->objs[x]))); + break; + case SFINX_FILE_OBJECT: + if (fill_tree_mask & (1 << SFINX_FILE_OBJECT)) + tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, &file_pixmap, + to_voidp(&(slice->objs[x]))); + break; + default: + debug("unsupported fill tree type %d", slice->objs[x].type); + break; + } // switch tree->traverse_up(); - } + } // for } } else { node = tree->traverse_start(); @@ -1850,15 +1787,28 @@ for (u32_t i = 0; i < app->slices.len(); i++) { if (node) { tree->open(node); node = tree->add_sub((char *)name.c_str(), 1, &slice_pixmap, to_voidp(slice)); - if (fill_tree_mask & (1 << SFINX_NOTE_OBJECT)) { - tree->open(node); - // add notes - for (u32_t x = 0; x < slice->objs.size(); x++) { - tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, ¬e_pixmap, - to_voidp(&(slice->objs[x]))); - tree->traverse_up(); - } - } + if (fill_tree_mask & ((1 << SFINX_NOTE_OBJECT) | (1 << SFINX_FILE_OBJECT))) { + tree->open(node); + // add notes + for (u32_t x = 0; x < slice->objs.size(); x++) { + switch (slice->objs[x].type) { + case SFINX_NOTE_OBJECT: + if (fill_tree_mask & (1 << SFINX_NOTE_OBJECT)) + tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, ¬e_pixmap, + to_voidp(&(slice->objs[x]))); + break; + case SFINX_FILE_OBJECT: + if (fill_tree_mask & (1 << SFINX_FILE_OBJECT)) + tree->add_sub((char *)(slice->objs[x].name + slice->objs[x].description).c_str(), 0, &file_pixmap, + to_voidp(&(slice->objs[x]))); + break; + default: + debug("unsupported fill tree type %d", slice->objs[x].type); + break; + } // switch + tree->traverse_up(); + } // for + } } // node not found - just ignore } } @@ -1874,3 +1824,139 @@ tree->resize(tree->x(), tree->y(), width > tree_scroll->w() ? width : tree_scrol // slices_tree->select_range(node, node); Fl::unlock();} {} } + +Function {x11_ui::fill_unsorted_files_tree(sfinx_files_vector_t *tree_)} {open return_type void +} { + code {Fl::lock(); +static sfinx_files_vector_t tree; +tree.copy(tree_); +files_module_tree_br->user_data((void *)&tree); +files_module_tree_br->clear(); +char buf[256]; +u32_t files = 0, dirs = 0; +// set parent dir id +if (tree.files.size()) + current_file.mtag.id = tree.files[0]->compressed_fsize; +for (u32_t i = 0; i < tree.files.size(); i++) { + if (tree.files[i]->is_directory) + strcpy(buf, "\\t@b@."); + else + strcpy(buf, "\\t"); + strncat(buf, tree.files[i]->name.c_str(), 50); + char dir_len[64]; + if (tree.files[i]->is_directory) { + strcpy(dir_len, "\\t@b@.< DIR >\\t"); + dirs++; + } else { + sprintf(dir_len, "\\t%llu\\t", tree.files[i]->fsize); + files++; + } + strcat(buf, dir_len); + int cyear, cmonth, cday, chour, cmin, csec; + tree.files[i]->ctime.GetDate(cyear, cmonth, cday); + tree.files[i]->ctime.GetTime(chour, cmin, csec); + sprintf(dir_len, "%02d/%02d/%04d %02d:%02d:%02d\\t", cday, cmonth, cyear, chour, cmin, csec); + strcat(buf, dir_len); + strcat(buf, tree.files[i]->mimetype.c_str()); + files_module_tree_br->add(buf); +} +files_module_tree_br->redraw(); +string root; +app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, root); +sprintf(buf, "Path: %s | Total %d file%s and %d director%s", (root + current_file.name.c_str()).c_str(), files, (files == 1) ? "" : "s", dirs, + (dirs == 1) ? "y" : "ies"); +files_module_status_to->value(buf); +files_module_status_to->redraw(); +// this is unsorted tree +select_files_tree_b->user_data(0); +select_files_tree_b->label("Show Sorted"); +select_files_tree_b->redraw(); +files_tree_scroll->hide(); +files_module_tree_br->show(); +Fl::unlock();} {selected + } +} + +Function {x11_ui::fill_preferences()} {return_type void +} { + code {Fl::lock(); +string t; +app->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, t); +config_files_module_unsorted_path_i->value(t.c_str()); +app->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, t); +config_files_module_sorted_path_i->value(t.c_str()); +app->files_module_conf.get(FILES_MODULE_DESC_FILE_NAME, t); +config_files_module_desc_file_name_i->value(t.c_str()); +u32_t gen_desc_files; +app->files_module_conf.get(FILES_MODULE_DESC_FILE_ENABLE, &gen_desc_files); +gen_desc_files_b->value(gen_desc_files); +Fl::unlock();} {} +} + +Function {x11_ui::log(int level, const char *fmt, ...)} {return_type void +} { + code {char buf[10240]; +const char *level_str; +static Mutex log_m; +log_m.enterMutex(); +Fl::lock(); +::va_list args; +::va_start(args, fmt); +::va_end(args); +switch (level) { + case SFINX_LOG_NOTICE: + level_str = "NOTICE"; + break; + case SFINX_LOG_WARN: + level_str = "WARN"; + break; + case SFINX_LOG_ERROR: + level_str = "ERROR"; + break; + case SFINX_LOG_FATAL: + level_str = "FATAL"; + break; + default: + level_str = "UNKN_LEVEL"; +} +// add time ? +strcpy(buf, level_str); +strcat(buf, ": "); +::vsnprintf(buf + strlen(level_str) + 2, sizeof(buf) - (strlen(level_str) + 2), fmt, args); +log_br->add(buf); +Fl::unlock(); +log_m.leaveMutex();} {} +} + +Function {x11_ui::progress(sfinx_progress_t *p)} {return_type void +} { + code {Fl::lock(); +static char buf[128]; +switch (p->status()) { + case SFINX_PROGRESS_START: + progress_l->label(p->label()); + strcpy(buf, p->strvalue()); + progress_bar->label(buf); + progress_bar->minimum(0); + progress_bar->maximum(p->max()); + progress_bar->value(p->value()); + progress_w->show(); + progress_w->redraw(); + break; + case SFINX_PROGRESS_END: + progress_w->hide(); + break; + case SFINX_PROGRESS_NONE: + default: + break; +} +Fl::unlock();} {} +} + +Function {x11_ui::alert(sfinx_string_t *alert)} {return_type void +} { + code {Fl::lock(); +if (alert->size() != 1) + fl_alert(alert->c_str()); +Fl::unlock();} {} +} diff --git a/include/elements.H b/include/elements.H index 495f84c..94c79c6 100644 --- a/include/elements.H +++ b/include/elements.H @@ -354,21 +354,21 @@ class sfinx_slice_t : public sfinx_t { sfinx_id_t parent_id; sfinx_timestamp_t ctime, etime; vector objs; // ×ÌÏÖÅÎÎÙÅ × ÓÌÁÊÓ ÏÂØÅËÔÙ + sfinx_object_t slice_obj; const char *name() { return name_.c_str(); } const char *directory() { return directory_.c_str(); } const char *description() { return description_.c_str(); } const char *parent_name() { return parent_name_.c_str(); } sfinx_object_t *object() { - static sfinx_object_t o; - o.ctime = ctime; - o.etime = etime; - o.name = name_; - o.type = SFINX_SLICE_OBJECT; - o.slice_id = o.id = id; - o.path_name = directory_; - o.description = description_; - return &o; + slice_obj.ctime = ctime; + slice_obj.etime = etime; + slice_obj.name = name_; + slice_obj.type = SFINX_SLICE_OBJECT; + slice_obj.slice_id = slice_obj.id = id; + slice_obj.path_name = directory_; + slice_obj.description = description_; + return &slice_obj; } void add(sfinx_object_t &obj) { objs.push_back(obj); } @@ -766,10 +766,10 @@ class sfinx_pair_vector_t : public sfinx_t { class sfinx_file_t : public sfinx_t { sfinx_size_t size() { - u32_t objs_size = sizeof(u32_t); // obj counter - for (u32_t i = 0; i < objects.size(); i++) - objs_size += objects[i].size(); - return (size_ = 4 * sizeof(sfinx_id_t) + 2 * sizeof(sfinx_size_t) + objs_size + + u32_t tags_size = sizeof(u32_t); // obj counter + for (u32_t i = 0; i < tags.size(); i++) + tags_size += tags[i].size(); + return (size_ = sizeof(sfinx_id_t) + mtag.size() + 2 * sizeof(sfinx_size_t) + tags_size + name.size() + 1 + orig_name.size() + 1 + title.size() + 1 + authority.size() + 1 + description.size() + 1 + comments.size() + 1 + ctime.size() + etime.size() + 4 * sizeof(u8_t) + mimetype.size() + 1 + csum.size() + 1 + compressed_csum.size() + 1); @@ -777,7 +777,7 @@ class sfinx_file_t : public sfinx_t { sfinx_size_t put(u8_t *buf, sfinx_size_t available_buf_space) { if (size() > available_buf_space) return 0; - buf += ::put(file_id, buf); + buf += ::put(id, buf); u8_t v = is_directory; buf += ::put(v, buf); v = sorted_location; @@ -786,15 +786,13 @@ class sfinx_file_t : public sfinx_t { buf += ::put(v, buf); v = generate_csum; buf += ::put(v, buf); - buf += ::put(mtag_id, buf); - buf += ::put(mtag_type, buf); - buf += ::put(mtag_slice_id, buf); + buf += mtag.put(buf); buf += ::put(fsize, buf); buf += ::put(compressed_fsize, buf); - u32_t t = objects.size(); + u32_t t = tags.size(); buf += ::put(t, buf); - for (u32_t i = 0; i < objects.size(); i++) - buf += objects[i].put(buf); + for (u32_t i = 0; i < tags.size(); i++) + buf += tags[i].put(buf); buf += ::put(name, buf); buf += ::put(orig_name, buf); buf += ::put(title, buf); @@ -811,7 +809,7 @@ class sfinx_file_t : public sfinx_t { sfinx_size_t get(u8_t *buf, sfinx_size_t object_size_in_buf) { u8_t *tmp = buf; clear(); - buf += ::get(&file_id, buf); + buf += ::get(&id, buf); u8_t v; buf += ::get(&v, buf); is_directory = v; @@ -821,17 +819,15 @@ class sfinx_file_t : public sfinx_t { store_compressed = v; buf += ::get(&v, buf); generate_csum = v; - buf += ::get(&mtag_id, buf); - buf += ::get(&mtag_type, buf); - buf += ::get(&mtag_slice_id, buf); + buf += mtag.get(buf); buf += ::get(&fsize, buf); buf += ::get(&compressed_fsize, buf); - u32_t objects_size; - buf += ::get(&objects_size, buf); - for (u32_t i = 0; i < objects_size; i++) { + u32_t tags_size; + buf += ::get(&tags_size, buf); + for (u32_t i = 0; i < tags_size; i++) { sfinx_object_t o; buf += o.get(buf); - objects.push_back(o); + tags.push_back(o); } buf += ::get(&name, buf); buf += ::get(&orig_name, buf); @@ -850,8 +846,8 @@ class sfinx_file_t : public sfinx_t { } public: void clear() { - objects.clear(); - file_id = mtag_type = mtag_id = fsize = 0; + tags.clear(); + id = mtag.type = mtag.id = fsize = 0; is_directory = false; size_ = 0; } void copy(const sfinx_t *s) { @@ -861,10 +857,8 @@ class sfinx_file_t : public sfinx_t { clear(); ((sfinx_t *)s)->size(); copy_size_tid(src); - file_id = src->file_id; - mtag_id = src->mtag_id; - mtag_type = src->mtag_type; - mtag_slice_id = src->mtag_slice_id; + id = src->id; + mtag = src->mtag; fsize = src->fsize; compressed_fsize = src->compressed_fsize; name = src->name; @@ -875,7 +869,7 @@ class sfinx_file_t : public sfinx_t { comments = src->comments; ctime = src->ctime; etime = src->etime; - objects = src->objects; + tags = src->tags; is_directory = src->is_directory; sorted_location = src->sorted_location; store_compressed = src->store_compressed; @@ -884,13 +878,14 @@ class sfinx_file_t : public sfinx_t { csum = src->csum; compressed_csum = src->compressed_csum; } - sfinx_id_t file_id, mtag_id, mtag_type, mtag_slice_id; + sfinx_id_t id; + sfinx_object_t mtag; sfinx_size_t fsize, compressed_fsize; string name, orig_name, title, authority, description, comments, mimetype, csum, compressed_csum; sfinx_timestamp_t ctime, etime; bool is_directory, sorted_location, store_compressed, generate_csum; - vector objects; // ÍÁÓÓÉ× ÔÉÐÏ× É id ÄÏÐÏÌÎÉÔÅÌØÎÙÈ ÏÂØÅËÔÏ× + vector tags; sfinx_file_t(sfinx_tid_t tid = SFINX_ELEMENT_FILE) : sfinx_t(tid) { clear(); } const char *sidstr() { return "File"; } @@ -1217,7 +1212,10 @@ static sfinx_t *make_sfinx_element(sfinx_tid_t tid) case SFINX_FILES_MODULE_EDIT_REPLY: case SFINX_NOTES_MODULE_ADD_REPLY: case SFINX_NOTES_MODULE_EDIT_REPLY: - case SFINX_FILES_MODULE_UNLINK: + case SFINX_NOTES_MODULE_UNLINK_REPLY: + case SFINX_NOTES_MODULE_UNSORT_REPLY: + case SFINX_FILES_MODULE_SORTED_UNLINK_REPLY: + case SFINX_FILES_MODULE_UNSORT_REPLY: return new sfinx_string_t(tid); case SFINX_ELEMENT_FILE_VECTOR: // case SFINX_FILES_MODULE_SORTED_TREE: @@ -1233,6 +1231,7 @@ static sfinx_t *make_sfinx_element(sfinx_tid_t tid) case SFINX_FILES_MODULE_EDIT_FILE: case SFINX_FILES_MODULE_SORTED_UNLINK: case SFINX_FILES_MODULE_UNSORT: + case SFINX_FILES_MODULE_UNSORTED_DELETE: return new sfinx_file_t(tid); case SFINX_ELEMENT_SEARCH_QUERY: return new sfinx_search_query_t(tid); diff --git a/include/faraon.H b/include/faraon.H index 31ccb09..b367e5c 100644 --- a/include/faraon.H +++ b/include/faraon.H @@ -34,9 +34,8 @@ class app_specific_ui { virtual void log(int level, const char *fmt, ...) = 0; virtual void edit_slice(sfinx_slice_t *slice) = 0; virtual void fill_preferences() = 0; - virtual void fill_files_module_tree(sfinx_files_vector_t *) = 0; + virtual void fill_unsorted_files_tree(sfinx_files_vector_t *) = 0; virtual void progress(sfinx_progress_t *) = 0; - virtual void files_module_classify_reply(sfinx_string_t *) = 0; virtual void files_module_edit_reply(sfinx_string_t *) = 0; virtual void files_module_edit(sfinx_file_t *) = 0; virtual void notes_module_reply(sfinx_string_t *) = 0; @@ -58,9 +57,8 @@ class x11_ui: public F_FLTK_UI, public app_specific_ui { void log(int level, const char *fmt, ...); void edit_slice(sfinx_slice_t *slice); void fill_preferences(); - void fill_files_module_tree(sfinx_files_vector_t *); + void fill_unsorted_files_tree(sfinx_files_vector_t *); void progress(sfinx_progress_t *); - void files_module_classify_reply(sfinx_string_t *); void files_module_edit_reply(sfinx_string_t *); void files_module_edit(sfinx_file_t *); void notes_module_edit(sfinx_note_t *); diff --git a/include/proto_data.H b/include/proto_data.H index bb84349..c9379e2 100644 --- a/include/proto_data.H +++ b/include/proto_data.H @@ -104,9 +104,11 @@ _new_enum(SFINX_FILES_MODULE_CLASSIFY_REPLY) _new_enum(SFINX_FILES_MODULE_EDIT_REQUEST) _new_enum(SFINX_FILES_MODULE_EDIT_FILE) _new_enum(SFINX_FILES_MODULE_EDIT_REPLY) -_new_enum(SFINX_FILES_MODULE_UNLINK) +_new_enum(SFINX_FILES_MODULE_UNSORTED_DELETE) _new_enum(SFINX_FILES_MODULE_SORTED_UNLINK) +_new_enum(SFINX_FILES_MODULE_SORTED_UNLINK_REPLY) _new_enum(SFINX_FILES_MODULE_UNSORT) +_new_enum(SFINX_FILES_MODULE_UNSORT_REPLY) // notes _new_enum(SFINX_NOTES_MODULE_ADD) @@ -115,7 +117,9 @@ _new_enum(SFINX_NOTES_MODULE_EDIT_REQUEST) _new_enum(SFINX_NOTES_MODULE_EDIT) _new_enum(SFINX_NOTES_MODULE_EDIT_REPLY) _new_enum(SFINX_NOTES_MODULE_UNLINK) +_new_enum(SFINX_NOTES_MODULE_UNLINK_REPLY) _new_enum(SFINX_NOTES_MODULE_UNSORT) +_new_enum(SFINX_NOTES_MODULE_UNSORT_REPLY) // search _new_enum(SFINX_SEARCH_QUERY) diff --git a/include/sfinx.H b/include/sfinx.H index 9072e34..8b8441a 100644 --- a/include/sfinx.H +++ b/include/sfinx.H @@ -95,26 +95,28 @@ class faraon_session : public sfinx_stream, public TCPSession { void delete_slice_recursivly(sfinx_id_t slice_id); void module_conf_request(u32_t module_id); void update_files_module_conf(sfinx_pair_vector_t *conf); - void send_dir(bool sorted, sfinx_file_t *f); + void send_unsorted_dir(sfinx_file_t *f); void send_file(sfinx_file_t *f); void send_note(sfinx_note_t *n); void files_module_classify(sfinx_file_t *f); void update_file(sfinx_file_t *f); + void delete_file(sfinx_file_t *f); void update_note(sfinx_note_t *n); - bool gen_desc_file(sfinx_type_t obj_type, sfinx_id_t obj_id, sfinx_id_t slice_id); + bool gen_desc_file(sfinx_object_t &o); void search_query(sfinx_search_query_t *); void search_in_files(string &pattern, sfinx_pair_vector_t *r); void mark_files_unsorted(sfinx_id_t slice_id, bool recursivly, bool remove = false); - void mark_file_unsorted(sfinx_file_t *f, bool remove = false); bool get_file_by_id(sfinx_file_t *f); bool get_object(sfinx_object_t *dst, sfinx_type_t obj_type, sfinx_id_t obj_id); bool get_object(sfinx_object_t *dst) { return get_object(dst, dst->type, dst->id); } - void delete_object_recursivly(sfinx_object_t *o); - void delete_from_notes(sfinx_object_t *o); - void delete_by_mtag_from_notes(sfinx_object_t *o); - void delete_by_mtag(sfinx_object_t *o) { - delete_by_mtag_from_notes(o); - // delete_by_mtag_from_files(o); + void delete_object_recursivly(sfinx_object_t *o, bool remove = false); + void delete_from_notes(sfinx_object_t *o, bool remove); + void delete_by_mtag_from_notes(sfinx_object_t *o, bool remove); + void delete_from_files(sfinx_object_t *o, bool remove); + void delete_by_mtag_from_files(sfinx_object_t *o, bool remove); + void delete_by_mtag(sfinx_object_t *o, bool remove) { + delete_by_mtag_from_notes(o, remove); + delete_by_mtag_from_files(o, remove); // ... } void notes_module_add(sfinx_note_t *n); @@ -174,7 +176,6 @@ class sfinx_app : public F_App { return sorted_path_mkdir(obj); } sfinx_id_t parent_slice_id(sfinx_id_t slice_id); - bool parent_object(sfinx_object_t &src, sfinx_object_t *dst); string slice_name(sfinx_id_t slice_id); string slice_directory(sfinx_id_t slice_id); diff --git a/scripts/db.sql b/scripts/db.sql index ecd09de..8f7ef69 100644 --- a/scripts/db.sql +++ b/scripts/db.sql @@ -120,6 +120,7 @@ create table files ( mtag_id BIGINT not null, /* ÌÀÂÁÑ ÉÅÒÁÒÈÉÑ ÏÂØÅËÔÏ× ÉÍÅÅÔ Ó×ÏÊ ÇÌÁ×ÎÙÊ ÓÌÁÊÓ-ÒÏÄÉÔÅÌØ ÉÓÐÏÌØÚÕÅÔÓÑ ÄÌÑ ÂÙÓÔÒÏÊ ×ÙÂÏÒËÉ ×ÎÕÔÒÉ ÓÌÁÊÓÁ + ÔÅÏÒÅÔÉÞÅÓËÉ - ÎÅ ÎÕÖÅÎ - ÍÏÖÎÏ ×ÙÞÉÓÌÑÔØ ÎÁ ÈÏÄÕ, ÐÏËÁ ÌÏÍÁÅÔ */ mtag_slice_id BIGINT not null, diff --git a/scripts/sfinx_compress.sh b/scripts/sfinx_compress.sh index 58cf11c..338197c 100755 --- a/scripts/sfinx_compress.sh +++ b/scripts/sfinx_compress.sh @@ -1,5 +1,4 @@ #!/bin/sh -#echo $0: $* 7zr -mx=9 a $1.7z $1 >/dev/null 2>&1 exit $? diff --git a/sfinx/sfinx.C b/sfinx/sfinx.C index e9897c6..1c7d17e 100644 --- a/sfinx/sfinx.C +++ b/sfinx/sfinx.C @@ -114,42 +114,20 @@ string sfinx_app::slice_directory(sfinx_id_t slice_id) return t; } -bool sfinx_app::parent_object(sfinx_object_t &src, sfinx_object_t *dst) -{ - switch (src.type) { - case SFINX_SLICE_OBJECT: - *dst = src; - dst->id = parent_slice_id(src.id); - return true; - default: - break; - } - return false; -} - -// for objects other than slices if the mtag_id == SFINX_SLICE_OBJECT -// directory is the slice one -// for other mtag_id we look up in the hierarchy - all is created from the -// some slice -// TODO: think about editing object property (mtag_xxx) ! - +// set path_name to sorted location (slice names as dirs) bool sfinx_app::set_sorted_path(sfinx_object_t &obj) { string path; sfinx->files_module_conf.get(FILES_MODULE_SORTED_TREE_PATH, obj.path_name); sfinx_object_t t = obj; while (1) { - if (t.type == SFINX_SLICE_OBJECT) { - path.insert(0, "/" + slice_directory(t.id)); // TODO: handle spaces in names - if (t.id == 1) // root slice - break; - } - if (!parent_object(obj, &t)) - return false; - obj = t; + if (t.slice_id == 1) // root slice + break; + path.insert(0, "/" + slice_directory(t.slice_id)); // TODO: handle spaces in names + t.slice_id = parent_slice_id(t.slice_id); } - obj.path_name += path; - return true; + obj.path_name += path; + return false; } // returns true on error @@ -275,6 +253,30 @@ void faraon_session::get_slice(sfinx_id_t slice_id, sfinx_tid_t tid) void faraon_session::fill_files(sfinx_slice_t *slice) { + IBPP::Transaction tr = sfinx->driver_->TransactionFactory(sfinx->db_, IBPP::amRead, + IBPP::ilConcurrency, IBPP::lrWait); + tr->Start(); + IBPP::Statement st = sfinx->driver_->StatementFactory(sfinx->db_, tr); + st->Prepare("select id, name, description, ctime, etime, mtag_id, mtag_type from files where " + "mtag_slice_id = ? order by ctime desc"); + st->Set(1, int64_t(slice->id)); + st->Execute(); + int64_t id, mtag_id; + int32 mtag_type; + sfinx_timestamp_t ctime, etime; + string name, description; + while (st->Fetch()) { + st->Get(1, &id); + st->Get(2, name); + st->Get(3, description); + st->Get(4, ctime); + st->Get(5, etime); + st->Get(6, &mtag_id); + st->Get(7, &mtag_type); + sfinx_object_t file(SFINX_FILE_OBJECT, (sfinx_id_t)id, slice->id, name.c_str(), ctime, etime); + file.description = " [ " + description + " ]"; + slice->add(file); + } } void faraon_session::fill_notes(sfinx_slice_t *slice) @@ -500,7 +502,7 @@ void faraon_session::mark_files_unsorted(sfinx_id_t slice_id, bool recursivly, b st->Prepare("delete from files where mtag_id = 1 and mtag_id = ?"); st->Set(1, (int64_t)slice_id); st->Execute(); - gen_desc_file(SFINX_SLICE_OBJECT, slice_id, slice_id); + gen_desc_file(o); if (recursivly) { u32_t pid = sfinx->parent_slice_id(slice_id); if (pid) @@ -509,38 +511,20 @@ void faraon_session::mark_files_unsorted(sfinx_id_t slice_id, bool recursivly, b tr->Commit(); } -// ÕÓÔÁÎÏ×ÌÅÎ file_id = mtag_slice_id É name -// ÎÕÖÎÏ ÎÁÊÔÉ ÆÁÊÌ Õ ËÏÔÏÒÏÇÏ ÉÌÉ parent ÉÌÉ ÒÏÄÎÏÊ ÓÌÁÊÓ ÔÁËÏÊ-ÖÅ -void faraon_session::mark_file_unsorted(sfinx_file_t *f, bool remove) +void faraon_session::delete_from_files(sfinx_object_t *f, bool remove) { // delete from file_tags IBPP::Transaction tr = sfinx->driver_->TransactionFactory(sfinx->db_, IBPP::amWrite, IBPP::ilConcurrency, IBPP::lrWait); tr->Start(); IBPP::Statement st = sfinx->driver_->StatementFactory(sfinx->db_, tr); - f->mtag_id = f->file_id; - f->mtag_type = SFINX_SLICE_OBJECT; - // get file_id - st->Prepare("select id from files where mtag_type = ? and mtag_id = ? and mtag_slice_id = ? and name = ?"); - st->Set(1, (int32_t)f->mtag_type); - st->Set(2, (int64_t)f->mtag_id); - st->Set(3, (int64_t)f->mtag_slice_id); - st->Set(4, f->name); - int64_t file_id; - st->Execute(); - if (!st->Fetch()) { // try to find parent id - bug(); - return; - } else - st->Get(1, file_id); st->Prepare("delete from file_tags where file_id = ?"); - st->Set(1, file_id); + st->Set(1, (int64_t)f->id); st->Execute(); // move to unsorted location string udir, sdir; - sfinx_object_t o(f->mtag_type, f->mtag_id, f->mtag_slice_id); - sfinx->set_sorted_path(o); - sdir = o.path_name + "/"; + sfinx->set_sorted_path(*f); + sdir = f->path_name + "/"; sfinx->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, udir); string from = sdir + f->name; if (remove) @@ -549,13 +533,13 @@ void faraon_session::mark_file_unsorted(sfinx_file_t *f, bool remove) move(from, udir); // delete from files st->Prepare("delete from files where id = ?"); - st->Set(1, file_id); + st->Set(1, (int64_t)f->id); st->Execute(); tr->Commit(); - gen_desc_file(f->mtag_type, f->mtag_id, f->mtag_slice_id); + gen_desc_file(*f); } -void faraon_session::delete_from_notes(sfinx_object_t *o) +void faraon_session::delete_from_notes(sfinx_object_t *o, bool remove) { IBPP::Transaction tr = sfinx->driver_->TransactionFactory(sfinx->db_, IBPP::amWrite, IBPP::ilConcurrency, IBPP::lrWait); @@ -572,7 +556,7 @@ void faraon_session::delete_from_notes(sfinx_object_t *o) tr->Commit(); } -void faraon_session::delete_by_mtag_from_notes(sfinx_object_t *o) +void faraon_session::delete_by_mtag_from_notes(sfinx_object_t *o, bool remove) { IBPP::Transaction tr = sfinx->driver_->TransactionFactory(sfinx->db_, IBPP::amRead, IBPP::ilConcurrency, IBPP::lrWait); @@ -588,21 +572,46 @@ void faraon_session::delete_by_mtag_from_notes(sfinx_object_t *o) st->Get(1, &dn_id); sfinx_object_t dn(SFINX_NOTE_OBJECT, dn_id); // depended note // × Ó×ÏÀ ÏÞÅÒÅÄØ ÕÄÁÌÑÅÍ ×ÓÅ ÏÂØÅËÔÙ, ÚÁ×ÉÓÑÝÉÅ ÏÔ ÜÔÏÊ note - delete_by_mtag(&dn); - delete_from_notes(&dn); + delete_by_mtag(&dn, remove); + delete_from_notes(&dn, remove); + } + tr->Commit(); +} + +void faraon_session::delete_by_mtag_from_files(sfinx_object_t *o, bool remove) +{ + IBPP::Transaction tr = sfinx->driver_->TransactionFactory(sfinx->db_, IBPP::amRead, + IBPP::ilConcurrency, IBPP::lrWait); + tr->Start(); + IBPP::Statement st = sfinx->driver_->StatementFactory(sfinx->db_, tr); + // search for note mtagged with o + st->Prepare("select id from files where mtag_type = ? and mtag_id = ?"); + st->Set(1, (int32_t)o->type); + st->Set(2, (int64_t)o->id); + st->Execute(); + while(st->Fetch()) { + int64_t df_id; + st->Get(1, &df_id); + sfinx_object_t df(SFINX_FILE_OBJECT, df_id); // depended file + // × Ó×ÏÀ ÏÞÅÒÅÄØ ÕÄÁÌÑÅÍ ×ÓÅ ÏÂØÅËÔÙ, ÚÁ×ÉÓÑÝÉÅ ÏÔ ÜÔÏÇÏ file + delete_by_mtag(&df, remove); + delete_from_files(&df, remove); } tr->Commit(); } // ÍÏÖÅÔ ÐÅÒÅÄÁ×ÁÔØ tr ÐÏ ÒÅËÕÒÓÉÉ ? -void faraon_session::delete_object_recursivly(sfinx_object_t *o) +void faraon_session::delete_object_recursivly(sfinx_object_t *o, bool remove) { // delete depended objects - delete_by_mtag(o); + delete_by_mtag(o, remove); // delete object itself switch (o->type) { case SFINX_NOTE_OBJECT: - delete_from_notes(o); + delete_from_notes(o, remove); + break; + case SFINX_FILE_OBJECT: + delete_from_files(o, remove); break; default: break; @@ -705,15 +714,12 @@ void faraon_session::relink_slice(sfinx_slice_t *slice) #include #include -// × file_id ÈÒÁÎÉÔÓÑ id ÔÅËÕÝÅÊ ÄÉÒÅËÔÏÒÉÉ-ÓÌÁÊÓÁ × ËÏÔÏÒÏÊ ÎÁÈÏÄÉÍÓÑ/×ÙÂÒÁÌÉ -// × mtag_slice_id - parent_id ÄÉÒÅËÔÏÒÉÉ -// name - full dir path -// orig_name - dir entry -/*void faraon_session::send_dir(bool sorted, sfinx_file_t *f) +// f->name - current unsorted dir +void faraon_session::send_unsorted_dir(sfinx_file_t *f) { string dir; - sfinx->files_module_conf.get(sorted ? FILES_MODULE_SORTED_TREE_PATH : FILES_MODULE_UNSORTED_PATH, dir); - sfinx_files_vector_t files(sorted ? SFINX_FILES_MODULE_SORTED_TREE : SFINX_FILES_MODULE_UNSORTED_TREE); + sfinx->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, dir); + sfinx_files_vector_t files(SFINX_FILES_MODULE_UNSORTED_TREE); if (f->name.size()) dir += f->name; bool mime_detect = true; @@ -743,9 +749,6 @@ void faraon_session::relink_slice(sfinx_slice_t *slice) sfinx_progress_t prg("Processing files metadata ..."); prg.max(n); send(prg); - u32_t p_id = 0; - if (sorted) - p_id = sfinx->parent_slice_id(f->file_id); for (int i = 0; i < n; i++) { if (prg.set(i, .5)) // ÛÁÇ 0.5% send(prg); @@ -763,37 +766,7 @@ void faraon_session::relink_slice(sfinx_slice_t *slice) file.is_directory = true; file.etime.set(inode.st_ctime); // status changes file.ctime.set(inode.st_mtime); // last modification - if (sorted) { - // set parent_id for up traverse - file.compressed_fsize = p_id; - if (file.is_directory) { // set dir id & dir parent_id from database - IBPP::Transaction tr = sfinx->driver_->TransactionFactory(sfinx->db_, IBPP::amRead, - IBPP::ilConcurrency, IBPP::lrWait); - tr->Start(); - IBPP::Statement st = sfinx->driver_->StatementFactory(sfinx->db_, tr); - st->Prepare("select id from slices where directory = ? and parent_id = ?"); - st->Set(1, file.name); - st->Set(2, (int64_t)f->file_id); - st->Execute(); - if (!st->Fetch()) - debug("*** no data for name %s and pid %d", file.name.c_str(), f->file_id); - else { - int64_t id; - st->Get(1, &id); - file.file_id = id; - file.mtag_id = f->file_id; - file.mtag_type = SFINX_SLICE_OBJECT; - // debug("for name %s id %d, pid %d", file.name.c_str(), id, f->file_id); - } - tr->Commit(); - } else { // file - ÄÏÓÔÁÔÏÞÎÏ ÕÓÔÁÎÏ×ÉÔØ dir id, ÞÔÏ ÂÕÄÅÔ mtag_slice_id ÄÌÑ ÄÁÎÎÏÇÏ ÆÁÊÌÁ - file.file_id = f->file_id; - file.mtag_type = file.mtag_id = 0; - } - } else { // not sorted - file.file_id = 0; - file.compressed_fsize = file.mtag_type = file.mtag_id = 0; - } + file.id = file.compressed_fsize = file.mtag.type = file.mtag.id = 0; if (mime_detect) { const char *mimetype = magic_file(ms, full_path.c_str()); if (mimetype) @@ -811,7 +784,7 @@ void faraon_session::relink_slice(sfinx_slice_t *slice) send(prg); free(namelist); send(files); -}*/ +} // may be use 7z.so ? bool compress(string &infile, string *newname) @@ -825,7 +798,7 @@ bool compress(string &infile, string *newname) return false; } -// × ÄÉÒÅËÔÏÒÉÉ mtag_slice_id ÄÌÑ ×ÓÅÈ ÆÁÊÌÏ× ÓÏÚÄÁÅÍ description.txt ×ÉÄÁ: +// × ÄÉÒÅËÔÏÒÉÉ Ó ÉÍÅÎÅÍ ÓÌÁÊÓÁ ÄÌÑ ×ÓÅÈ ÆÁÊÌÏ× ÓÏÚÄÁÅÍ description.txt ×ÉÄÁ: // // slice_name - slice_decription // @@ -852,13 +825,12 @@ bool compress(string &infile, string *newname) // // file2 ... -bool faraon_session::gen_desc_file(sfinx_type_t obj_type, sfinx_id_t obj_id, sfinx_id_t slice_id) +bool faraon_session::gen_desc_file(sfinx_object_t &o) { string dir, fname; - // u32_t slice_id = sfinx->get_object_slice(obj_type, obj_id); - sfinx_object_t o(SFINX_SLICE_OBJECT, slice_id, slice_id); - sfinx->set_sorted_path(o); - dir = o.path_name; + sfinx_object_t t(SFINX_SLICE_OBJECT, o.slice_id, o.slice_id); + sfinx->set_sorted_path(t); + dir = t.path_name; sfinx->files_module_conf.get(FILES_MODULE_DESC_FILE_NAME, fname); string desc_fname = dir + "/" + fname; IBPP::Transaction tr = sfinx->driver_->TransactionFactory(sfinx->db_, IBPP::amRead, @@ -866,7 +838,7 @@ bool faraon_session::gen_desc_file(sfinx_type_t obj_type, sfinx_id_t obj_id, sfi tr->Start(); IBPP::Statement st = sfinx->driver_->StatementFactory(sfinx->db_, tr); st->Prepare("select name, description, ctime, etime from slices where id = ?"); - st->Set(1, (int64_t)slice_id); + st->Set(1, (int64_t)o.slice_id); st->Execute(); if (!st->Fetch()) { // hmm, no such slice ? unlink(desc_fname.c_str()); @@ -899,10 +871,10 @@ bool faraon_session::gen_desc_file(sfinx_type_t obj_type, sfinx_id_t obj_id, sfi } // store_compressed // mimetype - st->Prepare("select id, name, title, authority, description, comments, ctime, etime, mtag_slice_id, " + st->Prepare("select id, name, title, authority, description, comments, ctime, etime, " "fsize, sha256, fsize_compressed, sha256_compressed, csum_last_checked, csum_valid, " - "store_in_sorted_location from files where mtag_type = 1 and mtag_id = ?"); - st->Set(1, (int64_t)slice_id); + "store_in_sorted_location from files where mtag_slice_id = ?"); + st->Set(1, (int64_t)o.slice_id); st->Execute(); while (st->Fetch()) { ofstream f(desc_fname.c_str(), ios::out | ios::binary | ios::app); @@ -936,27 +908,39 @@ bool faraon_session::gen_desc_file(sfinx_type_t obj_type, sfinx_id_t obj_id, sfi sprintf(buf, "Entry modifed: %02d/%02d/%04d %02d:%02d:%02d", day, month, year, hour, min, sec); f << buf << endl; int64_t fsize, compressed_fsize; - int64_t mtag_slice_id; - st->Get(9, mtag_slice_id); - st->Get(10, fsize); + st->Get(9, fsize); f << "Size: " << fsize << endl; - st->Get(11, t); // csum + st->Get(10, t); // csum f << "Csum: " << t << endl; - st->Get(12, compressed_fsize); + st->Get(11, compressed_fsize); f << "Compressed size: " << compressed_fsize << endl; - st->Get(13, t); // compressed_csum + st->Get(12, t); // compressed_csum f << "Compressed csum: " << t << endl; - // additional slices + // additional tags IBPP::Statement st1 = sfinx->driver_->StatementFactory(sfinx->db_, tr); - st1->Prepare("select s.name, s.description from slices s, file_tags fs where fs.file_id = ? and fs.obj_id = s.id and fs.obj_type = 1"); + switch (o.type) { + case SFINX_SLICE_OBJECT: + st1->Prepare("select s.name, s.description from slices s, file_tags ft where ft.file_id = ? " + "and ft.obj_id = s.id and ft.obj_type = ?"); + break; + case SFINX_NOTE_OBJECT: + st1->Prepare("select n.name, n.url from notes n, file_tags ft where ft.file_id = ? " + "and ft.obj_id = n.id and ft.obj_type = ?"); + break; + default: + debug("gen_desc: undefined tag type %d !", o.type); + break; + } st1->Set(1, (int64_t)fid); + st1->Set(2, (int32_t)o.type); st1->Execute(); if (st1->Fetch()) { - f << "Additional Slices: "; + f << "Additional Tags: "; bool comma = false; while (st1->Fetch()) { if (comma) f << ", "; + f << tagtype2str(o) << ": "; st1->Get(1, t); // name f << t << " [ "; st1->Get(2, t); // description @@ -973,6 +957,7 @@ bool faraon_session::gen_desc_file(sfinx_type_t obj_type, sfinx_id_t obj_id, sfi // sets slice_id, name, description for type/id // return true if success +// TODO: set ctime/etime too bool faraon_session::get_object(sfinx_object_t *dst, sfinx_type_t obj_type, sfinx_id_t obj_id) { IBPP::Transaction tr = sfinx->driver_->TransactionFactory(sfinx->db_, IBPP::amRead, @@ -1074,68 +1059,71 @@ void faraon_session::send_note(sfinx_note_t *n) send(note); } -// send file by name & mtag +// send file by id void faraon_session::send_file(sfinx_file_t *f) { - //debug("name - %s, fid - %d, msid - %d", f->name.c_str(), f->file_id, f->mtag_slice_id); IBPP::Transaction tr = sfinx->driver_->TransactionFactory(sfinx->db_, IBPP::amRead, IBPP::ilConcurrency, IBPP::lrWait); tr->Start(); IBPP::Statement st = sfinx->driver_->StatementFactory(sfinx->db_, tr); // store_compressed // mimetype - // mtag_slice_id ? - st->Prepare("select id, name, title, authority, description, comments, ctime, etime, " + st->Prepare("select name, title, authority, description, comments, ctime, etime, " "fsize, sha256, fsize_compressed, sha256_compressed, csum_last_checked, csum_valid, " - "store_in_sorted_location from files where mtag_type = 1 and mtag_id = ? and name = ?"); - st->Set(1, (int64_t)f->file_id); - st->Set(2, f->name); + "store_in_sorted_location, mtag_type, mtag_id from files where id = ?"); + st->Set(1, (int64_t)f->id); st->Execute(); - int64_t fid; sfinx_file_t file(f->tid()); + file.id = f->id; if (!st->Fetch()) { sfinx_string_t alert(SFINX_ALERT); alert.set("No such file in database !"); send(alert); return; } else { - st->Get(1, &fid); - file.file_id = fid; - st->Get(2, file.name); - st->Get(3, file.title); - st->Get(4, file.authority); - st->Get(5, file.description); - st->Get(6, file.comments); - st->Get(7, file.ctime); - st->Get(8, file.etime); + st->Get(1, file.name); + st->Get(2, file.title); + st->Get(3, file.authority); + st->Get(4, file.description); + st->Get(5, file.comments); + st->Get(6, file.ctime); + st->Get(7, file.etime); int64_t fsize, compressed_fsize; - st->Get(9, fsize); - st->Get(10, file.csum); - st->Get(11, compressed_fsize); - file.mtag_id = f->file_id; - file.mtag_type = SFINX_SLICE_OBJECT; + st->Get(8, fsize); + st->Get(9, file.csum); + st->Get(10, compressed_fsize); file.fsize = fsize; file.compressed_fsize = compressed_fsize; - st->Get(12, file.compressed_csum); - int32_t sorted_location; - st->Get(15, &sorted_location); + st->Get(11, file.compressed_csum); + int16_t sorted_location; + st->Get(14, &sorted_location); file.sorted_location = sorted_location; file.mimetype = "Not Set"; + int64_t mid; + int32_t mtype; + st->Get(15, &mtype); + file.mtag.type = mtype; + st->Get(16, &mid); + file.mtag.id = mid; + get_object(&file.mtag); } // fill file slices st->Prepare("select obj_id, obj_type from file_tags where file_id = ?"); - st->Set(1, fid); + st->Set(1, (int64_t)f->id); st->Execute(); while (st->Fetch()) { - int64_t obj_id; - int32_t obj_type; - st->Get(1, &obj_id); - st->Get(2, &obj_type); - sfinx_object_t o(obj_id, obj_type, f->mtag_slice_id); - file.objects.push_back(o); + int64_t id; + int32_t type; + st->Get(1, &id); + st->Get(2, &type); + sfinx_object_t o; + o.id = id; + o.type = type; + if (get_object(&o)) + file.tags.push_back(o); } - tr->Commit(); - send(file); + tr->Commit(); + send(file); } void faraon_session::files_module_classify(sfinx_file_t *f) @@ -1143,7 +1131,7 @@ void faraon_session::files_module_classify(sfinx_file_t *f) IBPP::Transaction tr; IBPP::Statement st; sfinx_string_t reply(SFINX_FILES_MODULE_CLASSIFY_REPLY); - string compressed_name, sorted_location, dir, fname; + string compressed_name, dir, fname; sfinx_hash_t csum(GCRY_MD_SHA256), compressed_csum(GCRY_MD_SHA256); sfinx->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, dir); fname = dir + "/" + f->name; @@ -1160,18 +1148,14 @@ void faraon_session::files_module_classify(sfinx_file_t *f) goto out; f->csum = csum.strvalue(); if (f->sorted_location) { - sfinx_object_t o(f->mtag_type, f->mtag_id, f->mtag_slice_id); reply.set("Error creating Sorted Location !"); - if (!sfinx->set_sorted_path(o)) - goto out; - sorted_location = o.path_name; - if (sfinx->sorted_path_mkdir(f->mtag_type, f->mtag_id, f->mtag_slice_id)) + if (sfinx->sorted_path_mkdir(f->mtag)) goto out; reply.set("Error moving file to Sorted Location !"); - if (move(fname, sorted_location)) + if (move(fname, f->mtag.path_name)) goto out; } - fname = sorted_location + "/" + f->name; + fname = f->mtag.path_name + "/" + f->name; // get size struct stat64 inode; reply.set("Error getting file size !"); @@ -1210,27 +1194,28 @@ void faraon_session::files_module_classify(sfinx_file_t *f) tr = sfinx->driver_->TransactionFactory(sfinx->db_, IBPP::amWrite, IBPP::ilConcurrency, IBPP::lrWait); tr->Start(); st = sfinx->driver_->StatementFactory(sfinx->db_, tr); - st->Prepare("insert into files (name, title, authority, description, comments, mtag_id, mtag_type, fsize, " - "sha256, fsize_compressed, sha256_compressed, store_in_sorted_location) values (?, ?, ?, ?, ?, ?, ?, " - "?, ?, ?, ?, ?)"); + st->Prepare("insert into files (name, title, authority, description, comments, mtag_id, mtag_type, " + "mtag_slice_id, fsize, sha256, fsize_compressed, sha256_compressed, store_in_sorted_location) values " + "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); st->Set(1, f->name); st->Set(2, f->title); st->Set(3, f->authority); st->Set(4, f->description); st->Set(5, f->comments); - st->Set(6, (int64_t)f->mtag_id); - st->Set(7, (int32_t)f->mtag_type); - st->Set(8, (int64_t)f->fsize); - st->Set(9, f->csum); - st->Set(10, (int64_t)f->compressed_fsize); - st->Set(11, f->compressed_csum); - st->Set(12, f->sorted_location); + st->Set(6, (int64_t)f->mtag.id); + st->Set(7, (int32_t)f->mtag.type); + st->Set(8, (int64_t)f->mtag.slice_id); + st->Set(9, (int64_t)f->fsize); + st->Set(10, f->csum); + st->Set(11, (int64_t)f->compressed_fsize); + st->Set(12, f->compressed_csum); + st->Set(13, f->sorted_location); st->Execute(); st->Prepare("select id from files where name = ? and mtag_type = ? and mtag_id = ?"); st->Set(1, f->name); - st->Set(2, (int32_t)f->mtag_type); - st->Set(3, (int64_t)f->mtag_id); + st->Set(2, (int32_t)f->mtag.type); + st->Set(3, (int64_t)f->mtag.id); st->Execute(); int64_t file_id; if (!st->Fetch()) @@ -1240,12 +1225,11 @@ void faraon_session::files_module_classify(sfinx_file_t *f) // debug("added file has id - %d", file_id); } // add to file_tags - for (u32_t i = 0; i < f->objects.size(); i++) { - st->Prepare("insert into file_tags (file_id, obj_id. obj_type) values (?, ?, ?)"); + for (u32_t i = 0; i < f->tags.size(); i++) { + st->Prepare("insert into file_tags (file_id, obj_id, obj_type) values (?, ?, ?)"); st->Set(1, file_id); - sfinx_object_t o = f->objects[i]; - st->Set(2, (int64_t)o.id); - st->Set(3, (int32_t)o.type); + st->Set(2, (int64_t)f->tags[i].id); + st->Set(3, (int32_t)f->tags[i].type); st->Execute(); } tr->Commit(); @@ -1253,7 +1237,7 @@ void faraon_session::files_module_classify(sfinx_file_t *f) sfinx->files_module_conf.get(FILES_MODULE_DESC_FILE_ENABLE, &gen_desc_files); if (gen_desc_files) { // generate decription file reply.set("Error generating description file !"); - if (gen_desc_file(f->mtag_type, f->mtag_id, f->mtag_slice_id)) + if (gen_desc_file(f->mtag)) goto out; } reply.set(""); // No error @@ -1316,7 +1300,7 @@ bool faraon_session::get_file_by_id(sfinx_file_t *f) st->Prepare("select name, title, authority, description, comments, ctime, etime, mtag_id, " "mtag_type, fsize, sha256, fsize_compressed, sha256_compressed, csum_last_checked, csum_valid, " "store_in_sorted_location, mtag_slice_id from files where id = ?"); - st->Set(1, (int64_t)f->file_id); + st->Set(1, (int64_t)f->id); st->Execute(); if (!st->Fetch()) return false; @@ -1335,8 +1319,8 @@ bool faraon_session::get_file_by_id(sfinx_file_t *f) st->Get(10, fsize); st->Get(11, f->csum); st->Get(12, compressed_fsize); - f->mtag_id = mtag_id; - f->mtag_type = mtag_type; + f->mtag.id = mtag_id; + f->mtag.type = mtag_type; f->fsize = fsize; f->compressed_fsize = compressed_fsize; st->Get(13, f->compressed_csum); @@ -1344,30 +1328,41 @@ bool faraon_session::get_file_by_id(sfinx_file_t *f) st->Get(16, &sorted_location); f->sorted_location = sorted_location; st->Get(17, &mtag_slice_id); - f->mtag_slice_id = mtag_slice_id; + f->mtag.slice_id = mtag_slice_id; // st->Get(xxx, f->mimetype); } // fill file tags - f->objects.clear(); + f->tags.clear(); st->Prepare("select obj_id, obj_type from file_tags where file_id = ?"); - st->Set(1, (int64_t)f->file_id); + st->Set(1, (int64_t)f->id); st->Execute(); while (st->Fetch()) { int32_t object_type; int64_t object_id; st->Get(1, &object_id); st->Get(2, &object_type); - sfinx_object_t o(object_type, object_id, f->mtag_slice_id); - f->objects.push_back(o); + sfinx_object_t o(object_type, object_id, f->mtag.slice_id); + f->tags.push_back(o); } tr->Commit(); return true; } +void faraon_session::delete_file(sfinx_file_t *f) +{ + string fname; + sfinx->files_module_conf.get(FILES_MODULE_UNSORTED_PATH, fname); + fname += ("/" + f->name); + if (f->is_directory) + rmdir(fname.c_str()); + else + unlink(fname.c_str()); +} + void faraon_session::update_file(sfinx_file_t *f) { sfinx_file_t old_file; - old_file.file_id = f->file_id; + old_file.id = f->id; if (!get_file_by_id(&old_file)) bug(); IBPP::Transaction tr; @@ -1375,7 +1370,7 @@ void faraon_session::update_file(sfinx_file_t *f) sfinx_string_t reply(SFINX_FILES_MODULE_EDIT_REPLY); string compressed_name, sorted_location, dir, fname; if (f->sorted_location) { - sfinx_object_t o(f->mtag_type, f->mtag_id, f->mtag_slice_id); + sfinx_object_t o(f->mtag.type, f->mtag.id, f->mtag.slice_id); sfinx->set_sorted_path(o); dir = o.path_name; } else @@ -1400,24 +1395,24 @@ void faraon_session::update_file(sfinx_file_t *f) st->Set(3, f->authority); st->Set(4, f->description); st->Set(5, f->comments); - st->Set(6, (int64_t)f->mtag_id); - st->Set(7, (int32_t)f->mtag_type); + st->Set(6, (int64_t)f->mtag.id); + st->Set(7, (int32_t)f->mtag.type); st->Set(8, (int64_t)f->fsize); st->Set(9, f->csum); st->Set(10, (int64_t)f->compressed_fsize); st->Set(11, f->compressed_csum); st->Set(12, f->sorted_location); - st->Set(13, (int64_t)f->file_id); + st->Set(13, (int64_t)f->id); st->Execute(); // add to file_tags st->Prepare("delete from file_tags where file_id = ?"); - st->Set(1, (int64_t)f->file_id); + st->Set(1, (int64_t)f->id); st->Execute(); - for (u32_t i = 0; i < f->objects.size(); i++) { + for (u32_t i = 0; i < f->tags.size(); i++) { st->Prepare("insert into file_tags (file_id, obj_id, obj_type) values (?, ?, ?)"); - st->Set(1, (int64_t)f->file_id); - sfinx_object_t o = f->objects[i]; + st->Set(1, (int64_t)f->id); + sfinx_object_t o = f->tags[i]; st->Set(2, (int64_t)o.id); st->Set(3, (int32_t)o.type); st->Execute(); @@ -1427,25 +1422,25 @@ void faraon_session::update_file(sfinx_file_t *f) sfinx->files_module_conf.get(FILES_MODULE_DESC_FILE_ENABLE, &gen_desc_files); if (gen_desc_files) { // generate decription file reply.set("Error generating description file !"); - if (gen_desc_file(f->mtag_type, f->mtag_id, f->mtag_slice_id)) + if (gen_desc_file(f->mtag)) goto out; } // move file if (old_file.sorted_location && f->sorted_location && - ((old_file.mtag_id != f->mtag_id) || - (old_file.mtag_type != f->mtag_type))) { - sfinx_object_t o(old_file.mtag_type, old_file.mtag_id, old_file.mtag_slice_id); + ((old_file.mtag.id != f->mtag.id) || + (old_file.mtag.type != f->mtag.type))) { + sfinx_object_t o(old_file.mtag.type, old_file.mtag.id, old_file.mtag.slice_id); sfinx->set_sorted_path(o); string from = o.path_name + "/" + old_file.name; - o.type = f->mtag_type; - o.id = f->mtag_id; + o.type = f->mtag.type; + o.id = f->mtag.id; sfinx->set_sorted_path(o); string to = o.path_name + "/" + f->name; - sfinx->sorted_path_mkdir(f->mtag_type, f->mtag_id, f->mtag_slice_id); + sfinx->sorted_path_mkdir(f->mtag.type, f->mtag.id, f->mtag.slice_id); move(from, to); // regen descs - gen_desc_file(f->mtag_type, f->mtag_id, f->mtag_slice_id); - gen_desc_file(old_file.mtag_type, old_file.mtag_id, old_file.mtag_slice_id); + gen_desc_file(f->mtag); + gen_desc_file(old_file.mtag); } reply.set(""); // No error out: @@ -1509,7 +1504,7 @@ void faraon_session::search_in_files(string &pattern, sfinx_pair_vector_t *r) sfinx_file_t file; int64_t fid; st->Get(1, &fid); - file.file_id = fid; + file.id = fid; st->Get(2, file.name); st->Get(3, file.title); st->Get(4, file.authority); @@ -1524,8 +1519,8 @@ void faraon_session::search_in_files(string &pattern, sfinx_pair_vector_t *r) st->Get(11, fsize); st->Get(12, file.csum); st->Get(13, compressed_fsize); - file.mtag_id = mtag_id; - file.mtag_type = mtag_type; + file.mtag.id = mtag_id; + file.mtag.type = mtag_type; file.fsize = fsize; file.compressed_fsize = compressed_fsize; st->Get(14, file.compressed_csum); @@ -1533,7 +1528,7 @@ void faraon_session::search_in_files(string &pattern, sfinx_pair_vector_t *r) st->Get(17, &sorted_location); file.sorted_location = sorted_location; st->Get(18, &mtag_slice_id); - file.mtag_slice_id = mtag_slice_id; + file.mtag.slice_id = mtag_slice_id; file.mimetype = "Not Set"; // fill file slices st1->Prepare("select obj_id, obj_type from file_tags where file_id = ?"); @@ -1544,8 +1539,8 @@ void faraon_session::search_in_files(string &pattern, sfinx_pair_vector_t *r) int32_t obj_type; st1->Get(1, &obj_id); st1->Get(2, &obj_type); - sfinx_object_t o(obj_type, obj_id, file.mtag_slice_id); - file.objects.push_back(o); + sfinx_object_t o(obj_type, obj_id, file.mtag.slice_id); + file.tags.push_back(o); } r->add(rid++, &file); } @@ -1577,11 +1572,19 @@ bool faraon_session::process_requests() while ((el = rx_elements.next())) { switch (el->tid()) { case SFINX_NOTES_MODULE_UNSORT: - case SFINX_NOTES_MODULE_UNLINK: o.type = SFINX_NOTE_OBJECT; o.id = ((sfinx_note_t *)el)->id; + o.slice_id = ((sfinx_file_t *)el)->mtag.slice_id; delete_object_recursivly(&o); - reply.tid(el->tid()); + reply.tid(SFINX_NOTES_MODULE_UNSORT_REPLY); + send(reply); + break; + case SFINX_NOTES_MODULE_UNLINK: + o.type = SFINX_NOTE_OBJECT; + o.id = ((sfinx_note_t *)el)->id; + o.slice_id = ((sfinx_file_t *)el)->mtag.slice_id; + delete_object_recursivly(&o, 1); + reply.tid(SFINX_NOTES_MODULE_UNLINK_REPLY); send(reply); break; case SFINX_NOTES_MODULE_EDIT: @@ -1594,13 +1597,23 @@ bool faraon_session::process_requests() notes_module_add((sfinx_note_t *)el); break; case SFINX_FILES_MODULE_SORTED_UNLINK: - mark_file_unsorted((sfinx_file_t *)el, true); + o.type = SFINX_FILE_OBJECT; + o.id = ((sfinx_file_t *)el)->id; + o.slice_id = ((sfinx_file_t *)el)->mtag.slice_id; + delete_object_recursivly(&o, 1); + reply.tid(SFINX_FILES_MODULE_SORTED_UNLINK_REPLY); + send(reply); break; case SFINX_FILES_MODULE_UNSORT: - mark_file_unsorted((sfinx_file_t *)el); + o.type = SFINX_FILE_OBJECT; + o.id = ((sfinx_file_t *)el)->id; + o.slice_id = ((sfinx_file_t *)el)->mtag.slice_id; + delete_object_recursivly(&o); + reply.tid(SFINX_FILES_MODULE_UNSORT_REPLY); + send(reply); break; - case SFINX_FILES_MODULE_UNLINK: - unlink(((sfinx_string_t *)el)->c_str()); + case SFINX_FILES_MODULE_UNSORTED_DELETE: + delete_file((sfinx_file_t *)el); break; case SFINX_ELEMENT_SEARCH_QUERY: search_query((sfinx_search_query_t *)el); @@ -1614,17 +1627,13 @@ bool faraon_session::process_requests() case SFINX_FILES_MODULE_CLASSIFY_REQUEST: files_module_classify((sfinx_file_t *)el); break; -// case SFINX_FILES_MODULE_SORTED_TREE_REQUEST: -// send_dir(true, (sfinx_file_t *)el); -// break; case SFINX_FILES_MODULE_UNSORTED_TREE_REQUEST: -// send_dir(false, (sfinx_file_t *)el); + send_unsorted_dir((sfinx_file_t *)el); break; case SFINX_FILES_MODULE_CONF: update_files_module_conf((sfinx_pair_vector_t *)el); break; case SFINX_FILES_MODULE_CONF_REQUEST: -// case SFINX_XXX_MODULE_CONF_REQUEST: module_conf_request(el->tid()); break; case SFINX_SLICE_RELINK: -- 2.11.4.GIT