From ee6e3ccfb37f59de3d7038e0c0929246844943b1 Mon Sep 17 00:00:00 2001 From: chrisparker126 Date: Sat, 27 Mar 2010 15:00:16 +0000 Subject: [PATCH] Cleaning up source - deleted fltkgui folder git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2645 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/fltkgui/Fl_File_Item.cc | 328 -- libretroshare/src/fltkgui/Fl_Funky_Browser.cc | 1704 -------- libretroshare/src/fltkgui/Fl_Funky_Browser.h | 179 - libretroshare/src/fltkgui/Fl_Tree_Browser.cc | 752 ---- libretroshare/src/fltkgui/Fl_Tree_Browser.h | 210 - libretroshare/src/fltkgui/Makefile | 39 - libretroshare/src/fltkgui/alertbox.cc | 197 - libretroshare/src/fltkgui/alertbox.h | 91 - libretroshare/src/fltkgui/fltkpqi.cc | 1852 --------- libretroshare/src/fltkgui/fltkserver.cc | 3448 ----------------- libretroshare/src/fltkgui/fltkserver.h | 222 -- libretroshare/src/fltkgui/guitab.cc | 675 ---- libretroshare/src/fltkgui/guitab.fld | 788 ---- libretroshare/src/fltkgui/guitab.h | 226 -- libretroshare/src/fltkgui/pqibrowseitem.cc | 996 ----- libretroshare/src/fltkgui/pqibrowseitem.h | 219 -- libretroshare/src/fltkgui/pqistrings.cc | 745 ---- libretroshare/src/fltkgui/pqistrings.h | 79 - libretroshare/src/fltkgui/retrotray.cc | 338 -- libretroshare/src/fltkgui/retrotray.h | 112 - 20 files changed, 13200 deletions(-) delete mode 100644 libretroshare/src/fltkgui/Fl_File_Item.cc delete mode 100644 libretroshare/src/fltkgui/Fl_Funky_Browser.cc delete mode 100644 libretroshare/src/fltkgui/Fl_Funky_Browser.h delete mode 100644 libretroshare/src/fltkgui/Fl_Tree_Browser.cc delete mode 100644 libretroshare/src/fltkgui/Fl_Tree_Browser.h delete mode 100644 libretroshare/src/fltkgui/Makefile delete mode 100644 libretroshare/src/fltkgui/alertbox.cc delete mode 100644 libretroshare/src/fltkgui/alertbox.h delete mode 100644 libretroshare/src/fltkgui/fltkpqi.cc delete mode 100644 libretroshare/src/fltkgui/fltkserver.cc delete mode 100644 libretroshare/src/fltkgui/fltkserver.h delete mode 100644 libretroshare/src/fltkgui/guitab.cc delete mode 100644 libretroshare/src/fltkgui/guitab.fld delete mode 100644 libretroshare/src/fltkgui/guitab.h delete mode 100644 libretroshare/src/fltkgui/pqibrowseitem.cc delete mode 100644 libretroshare/src/fltkgui/pqibrowseitem.h delete mode 100644 libretroshare/src/fltkgui/pqistrings.cc delete mode 100644 libretroshare/src/fltkgui/pqistrings.h delete mode 100644 libretroshare/src/fltkgui/retrotray.cc delete mode 100644 libretroshare/src/fltkgui/retrotray.h diff --git a/libretroshare/src/fltkgui/Fl_File_Item.cc b/libretroshare/src/fltkgui/Fl_File_Item.cc deleted file mode 100644 index 7c97ae5bf..000000000 --- a/libretroshare/src/fltkgui/Fl_File_Item.cc +++ /dev/null @@ -1,328 +0,0 @@ -// -// "$Id: Fl_File_Item.cc,v 1.3 2007-02-18 21:46:49 rmf24 Exp $" -// -// This is hacked up FLTK code, and so is released under -// their licence. (below) -// Copyright 2004-2006 by Robert Fernie. -// -// Please report all bugs and problems to "retroshare@lunamutt.com". -// -///////////////////////////////////////////////////////////////////// -// -// C function type code for the Fast Light Tool Kit (FLTK). -// -// Copyright 1998-2004 by Bill Spitzak and others. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// -// Please report all bugs and problems to "fltk-bugs@fltk.org". -// - -#include -#include "Fl_Tree_Browser.h" -#include -#include - -#include - -// -//extern int i18n_type; -//extern const char* i18n_include; -//extern const char* i18n_function; -//extern const char* i18n_file; -//extern const char* i18n_set; -//extern char i18n_program[]; - -//////////////////////////////////////////////////////////////// -// quick check of any C code for legality, returns an error message - -static char buffer[128]; // for error messages - -// check a quoted string ending in either " or ' or >: -const char *_q_check(const char * & c, int type) { - for (;;) switch (*c++) { - case '\0': - sprintf(buffer,"missing %c",type); - return buffer; - case '\\': - if (*c) c++; - break; - default: - if (*(c-1) == type) return 0; - } -} - -// check normal code, match braces and parenthesis: -const char *_c_check(const char * & c, int type) { - const char *d; - for (;;) switch (*c++) { - case 0: - if (!type) return 0; - sprintf(buffer, "missing %c", type); - return buffer; - case '/': - // Skip comments as needed... - if (*c == '/') { - while (*c != '\n' && *c) c++; - } else if (*c == '*') { - c++; - while ((*c != '*' || c[1] != '/') && *c) c++; - if (*c == '*') c+=2; - else { - return "missing '*/'"; - } - } - break; - case '#': - // treat cpp directives as a comment: - while (*c != '\n' && *c) c++; - break; - case '{': - if (type==')') goto UNEXPECTED; - d = _c_check(c,'}'); - if (d) return d; - break; - case '(': - d = _c_check(c,')'); - if (d) return d; - break; - case '\"': - d = _q_check(c,'\"'); - if (d) return d; - break; - case '\'': - d = _q_check(c,'\''); - if (d) return d; - break; - case '}': - case ')': - UNEXPECTED: - if (type == *(c-1)) return 0; - sprintf(buffer, "unexpected %c", *(c-1)); - return buffer; - } -} - -const char *c_check(const char *c, int type) { - return _c_check(c,type); -} - -//////////////////////////////////////////////////////////////// -// UNSURE -//#include "function_panel.h" -//#include -//////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// - -Fl_Item *Fl_Dir_Item::make(Fl_Item *p) { - //std::cerr << "Fl_Dir_Item::make()" << std::endl; - //Fl_Item *p = Fl_Item::current; - while (p && p->is_file()) p = p->parent; - - Fl_Dir_Item *o = new Fl_Dir_Item(); - o->name("Dir: printf(\"Hello, World!\\n\");"); - o->add(p); - o->factory = this; - return o; -} - -void file_requestdir(std::string person, std::string dir); - -void Fl_Dir_Item::open() -{ - //std::cerr << "open Dir..." << std::endl; - Fl_Item *p = NULL; - - int ccount = 0; - for(p = next; (p && (p->parent == this));p = p->next) - { - ccount++; - } - - //std::cerr << "count:" << ccount << std::endl; - - if (ccount == 0) // && (lload > time(NULL) + MIN_RELOAD)) - { - // get our path.... - std::string fulldir(name()); - int lvl = level; - //std::cerr << "level:" << level << std::endl; - //std::cerr << "prev:" << (int) prev << std::endl; - //std::cerr << "prev->parent:" << (int) prev->parent << std::endl; - - for(p = prev; (p && p->parent);p = p->prev) - { - //std::cerr << "fulldir srch: " << p -> name() << std::endl; - if (p->level < lvl) - { - std::string subdir(p->name()); - fulldir = subdir + "/" + fulldir; - lvl = p->level; - } - } - fulldir = "/" + fulldir; - - if (p) - { - Fl_Person_Item *pi; - if ((pi = dynamic_cast(p))) - { - std::string person(pi->person_hash); - file_requestdir(person, fulldir); - //std::cerr << "Requesting: " << person << ":" << fulldir << std::endl; - } - else - { - //std::cerr << "Not PersonItem" << std::endl; - } - - } - else - { - //std::cerr << "No Requesting: NULL" << ":" << fulldir << std::endl; - } - - - } - else - { - for(p = next; (p && (p->parent == this));p = p->next) - { - //std::cerr << "Setting Item Visible" << std::endl; - p -> visible = 1; - //p -> open_ = 1; - } - redraw_browser(); - } -} - -Fl_Dir_Item Fl_Dir_Item_type; - -//////////////////////////////////////////////////////////////// - -Fl_Item *Fl_File_Item::make(Fl_Item *p) { - //std::cerr << "Fl_File_Item::make()" << std::endl; - while (p && p->is_file()) p = p->parent; - if (!p) { - //std::cerr << "File in no directory!" << std::endl; - return 0; - } - - Fl_File_Item *o = new Fl_File_Item(); - o->name("file: hello world"); - o->add(p); - o->factory = this; - //redraw_browser(); - return o; -} - -void Fl_File_Item::open() -{ - //std::cerr << "open File? How..." << std::endl; - redraw_browser(); -} - -Fl_File_Item Fl_File_Item_type; - -//////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// - -Fl_Item *Fl_Person_Item::make(Fl_Item *p) { - //std::cerr << "Fl_Person_Item::make()" << std::endl; - //while (p) && p->is_file()) p = p->parent; - //while (p) && p->is_file()) p = p->parent; - p = NULL; // always at top. - - Fl_Person_Item *o = new Fl_Person_Item(); - o->name("person"); - o->add(p); - o->factory = this; - return o; -} - - -void Fl_Person_Item::open() -{ - //std::cerr << "open Person? How..." << std::endl; - Fl_Item *p; - { - for(p = next; (p && (p->parent == this));p = p->next) - { - //std::cerr << "Setting Item Visible" << std::endl; - p -> visible = 1; - } - redraw_browser(); - } -} - -Fl_Person_Item Fl_Person_Item_type; - -//////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// - -Fl_Item *Fl_Msg_Item::make(Fl_Item *p) { - //std::cerr << "Fl_Msg_Item::make()" << std::endl; - while (p && p->is_file()) p = p->parent; - if (!p) { - //std::cerr << "File in no directory!" << std::endl; - return 0; - } - - Fl_Msg_Item *o = new Fl_Msg_Item(); - o->name("msg"); - o->add(p); - o->factory = this; - //redraw_browser(); - return o; -} - -void Fl_Msg_Item::open() -{ - //std::cerr << "open Msg? How..." << std::endl; - redraw_browser(); -} - -Fl_Msg_Item Fl_Msg_Item_type; - -//////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////// - -const char* Fl_Item::class_name(const int need_nest) const { - Fl_Item* p = parent; - while (p) { - if (p->is_class()) { - // see if we are nested in another class, we must fully-qualify name: - // this is lame but works... - const char* q = 0; - if(need_nest) q=p->class_name(need_nest); - if (q) { - static char s[256]; - if (q != s) fltk_strlcpy(s, q, sizeof(s)); - fltk_strlcat(s, "::", sizeof(s)); - fltk_strlcat(s, p->name(), sizeof(s)); - return s; - } - return p->name(); - } - p = p->parent; - } - return 0; -} - -// -// End of "$Id: Fl_File_Item.cc,v 1.3 2007-02-18 21:46:49 rmf24 Exp $". -// diff --git a/libretroshare/src/fltkgui/Fl_Funky_Browser.cc b/libretroshare/src/fltkgui/Fl_Funky_Browser.cc deleted file mode 100644 index 454e725e1..000000000 --- a/libretroshare/src/fltkgui/Fl_Funky_Browser.cc +++ /dev/null @@ -1,1704 +0,0 @@ -/* - * "$Id: Fl_Funky_Browser.cc,v 1.11 2007-02-18 21:46:49 rmf24 Exp $" - * - * FltkGUI for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * NB: Parts of this code are derived from FLTK Fl_Browser code. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - -/* My new funky browser..... - * - * - Designed to sort/display a tree brower - * for search results.... - * - * First we need the basic interface class that - * must wrap the Data.... - */ - -const static int FUNKY_EXPANDED = 0x001; -const static int FUNKY_VISIBLE = 0x002; -const static int FUNKY_SELECTED = 0x004; - -#include -#include "pqi/pqidebug.h" -const int pqiflfbzone = 91393; - -#include "fltkgui/Fl_Funky_Browser.h" -#include -#include -#include - -#include - - Fl_Funky_Browser::Fl_Funky_Browser(int a, int b, int c, - int d, const char *n, int ncol) - :Fl_Browser(a,b,c,d,n), - ncols(ncol), sort_order(ncol), sort_direction(ncol), tree(ncol), - display_order(ncol), widths(ncol), titles(ncol), check_box(ncol), - drag_mode(0), one_select(true) -{ - // set the widths for the Columns onto Fl_Browser. - fl_widths = (int *) malloc((ncol + 1) * sizeof(int)); - - for(int i = 0; i < ncol; i++) - { - sort_order[i] = i; - sort_direction[i] = 1; - tree[i] = 0; - display_order[i] = i; - widths[i] = 150; - fl_widths[i] = widths[i]; - titles[i] = "Unknown"; - check_box[i] = false; - } - // temp hack to make the first two columns expandable. - if (ncol > 0) - tree[0] = 1; - if (ncol > 1) - tree[1] = 1; - ntrees = 2; - - // NOTE: It only makes sense to have the tree at the - // left hand side..... so all tree ticked ones - // should automatically be moved to left columns. - - fl_widths[ncol] = 0; - column_widths(fl_widths); - - return; -} - -int Fl_Funky_Browser::addItemSeries(DisplayData *d) -{ - int idx = 1; - int i; - - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Fl_Funky_Browser::addItem Properly()...."); - - idx++; - - std::list::iterator it; - - DisplayItem *last[ntrees]; - - DisplayItem *ni = new DisplayItem(); - ni -> expander = -1; - ni -> flags = FUNKY_EXPANDED | FUNKY_VISIBLE; - ni -> ref = d; - - it = dlist.begin(); - if (it == dlist.end()) - { - dlist.push_back(ni); - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Fl_Funky_Browser::addItem Empty List"); - - RePopulate(); - return 1; - } - - // add in all the initial levels. - for(i = 0; (i < ntrees) && (it != dlist.end()); i++, it++) - { - last[i] = (*it); - } - - if (it == dlist.end()) - { - pqioutput(PQL_ALERT, pqiflfbzone, - "FL_Funky_Browser::Serious Accounting Condition!"); - - SortList(); - RePopulate(); - return 1; - } - - - idx += ntrees; - { - std::ostringstream out; - - out << "Fl_Funky_Browser::addItem Inserting:"; - out << std::endl; - - for(i = 0; i < d -> ndix();i++) - { - out << "\t:" << d -> txt(i) << std::endl; - } - - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - - for(; it != dlist.end(); it++, idx++) - { - std::ostringstream out; - out << "Fl_Funky_Browser::addItem Checking Against:"; - out << std::endl; - for(i = 0; i < (*it)->ref->ndix();i++) - { - out << "\t:" << (*it)->ref->txt(i); - out << std::endl; - } - - // cmp with item. - int res = cmp(ni, *it); // if ni < *it - out << "Cmp *ni vs *it: " << res << std::endl; - - if (0 > res) // if ni < *it - { - // if before it, stop and add item in. - // check the level difference between - // item and location... - // best way to do this is checking against - // the last[ntree], and *it. - - int level = 0; - level = cmp_upto(ntrees, ni, *it); - out << "(Cmp < 0):Level Match:" << level; - out << std::endl; - - // if expanders following - redirect. - for(i = 0;(it != dlist.end()) && - ((*it) -> expander < level) && - ((*it) -> expander != -1); it++, idx++) - { - (*it) -> ref = ni -> ref; - last[(*it) -> expander] = (*it); - } - - // add in extra unique ones. - for(i = level; i < ntrees; i++) - { - last[i] = new DisplayItem(); - last[i] -> expander = i; - last[i] -> index = idx++; - last[i] -> ref = ni -> ref; - // random initial flags - visibility checked later. - if (i == 0) - last[i] -> flags = FUNKY_EXPANDED | FUNKY_VISIBLE; - else - last[i] -> flags = FUNKY_VISIBLE; - //last[i-1] -> flags; - - dlist.insert(it, last[i]); - } - - - // add in item. - dlist.insert(it, ni); - // update details. - ni -> index = idx++; - if ((last[ntrees-1]->flags & FUNKY_EXPANDED) - &(last[ntrees-1]->flags & FUNKY_VISIBLE)) - { - ni -> flags = FUNKY_VISIBLE; - } - - // update indices. - for(; it != dlist.end(); it++) - { - (*it) -> index = idx++; - } - - // finished and added item. - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - return 1; - // drawList(); //not every time! - } - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - - // emergency procedures. (stick in at the end) - // if before it, stop and add item in. - // check the level difference between - // item and location... - // best way to do this is checking against - // the last[ntree] - - int level = 0; - level = cmp_upto(ntrees, last[ntrees-1], ni); - - { - std::ostringstream out; - out << "Sticking at the End." << std::endl; - out << "(Cmp < 0): Level Match:" << level; - out << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - - // add in extra unique ones. - for(i = level; i < ntrees; i++) - { - std::ostringstream out; - out << "--> Adding in extra Unique Ones." << std::endl; - out << "i: " << i << " index: " << idx << " ref: " << ni->ref; - out << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - - last[i] = new DisplayItem(); - last[i] -> expander = i; - last[i] -> index = idx++; - last[i] -> ref = ni -> ref; - // random initial flags - visibility checked later. - if (i == 0) - last[i] -> flags = FUNKY_EXPANDED | FUNKY_VISIBLE; - else - last[i] -> flags = FUNKY_VISIBLE; - //last[i-1] -> flags; - - dlist.push_back(last[i]); - } - - - // add in item. - { - std::ostringstream out; - out << "--> Adding in Last Item" << std::endl; - out << " index: "; - out << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - - dlist.push_back(ni); - // update details. - ni -> index = idx++; - if ((last[ntrees-1]->flags & FUNKY_EXPANDED) - &(last[ntrees-1]->flags & FUNKY_VISIBLE)) - { - ni -> flags = FUNKY_VISIBLE; - } - - // finished and added item. - return 1; -} - -int Fl_Funky_Browser::selectDD(DisplayData *dd) -{ - std::list::iterator it; - - if (dd == NULL) - return 0; - for(it = dlist.begin(); it != dlist.end();it++) - { - if (dd == (*it) -> ref) - { - return selectItems((*it) -> index); - } - - } - return 0; -} - - -int Fl_Funky_Browser::addItem(DisplayData *d) -{ - addItemSeries(d); - return ItemSeriesDone(); -} - -int Fl_Funky_Browser::ItemSeriesDone() -{ - updateList(); - return 1; -} - -int Fl_Funky_Browser::updateList() -{ - if (0 > checkSort()) - { - checkIndices(); - SortList(); - RePopulate(); - } - return drawList(); -} - - -// if sorted 1 -int Fl_Funky_Browser::checkSort() -{ - std::list::iterator it, prev; - - it = dlist.begin(); - if (it == dlist.end()) - { - return 1; - } - - // add in all the initial levels. - int res; - for(prev = it++; it != dlist.end(); prev = it++) - { - if (0 < (res = cmp(*prev, *it))) // expect prev <= it, so if (prev > it) - { - pqioutput(PQL_WARNING, pqiflfbzone, - "Fl_Funky_Browser::checkSort() Not Sorted()"); - return -1; - } - else - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Fl_Funky_Browser::checkSort() Sorted()"); - } - } - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Fl_Funky_Browser::checkSort() ListSorted()"); - // sorted! - return 1; -} - - - - - -void Fl_Funky_Browser::clear() -{ - std::list::iterator it; - for(it = dlist.begin(); it != dlist.end();) - { - delete *it; - it = dlist.erase(it); - } - Fl_Browser::clear(); -} - -DisplayData *Fl_Funky_Browser::removeItem(int idx) -{ - return NULL; -} - -DisplayData *Fl_Funky_Browser::removeItem(int (*fn)(DisplayData *)) -{ - return NULL; -} - -DisplayData *Fl_Funky_Browser::getSelected() -{ - return NULL; -} - -DisplayData *Fl_Funky_Browser::getCurrentItem() -{ - int itemnum = value(); - if (value() <= 1) - return NULL; - - std::list::iterator it; - for(it = dlist.begin(); it != dlist.end(); it++) - { - if (itemnum == (*it) -> index) - { - if ((*it) -> expander != -1) - return NULL; - return (*it) -> ref; - } - } - return NULL; -} - - // Worker Functions. -int Fl_Funky_Browser::SortList() -{ - std::list tmplist = dlist; - std::list::iterator it; - std::list::iterator it2; - - dlist.clear(); - - // terrible sorting algorithm --- fix with template class. - // But Okay for now. - - // clean out the expanders first. - it = tmplist.begin(); - while(it != tmplist.end()) - { - if ((*it) -> expander > -1) - { - // XXX Memory leak??? - it = tmplist.erase(it); - } - else - { - it++; - } - } - - while(tmplist.size() > 0) - { - for(it2 = it = tmplist.begin(); it != tmplist.end(); it++) - { - if (0 > cmp(*it, *it2)) // if *it < *it2 - { - it2 = it; - } - } - dlist.push_back(*it2); - tmplist.erase(it2); - } - // sorted! - return 1; -} - -int Fl_Funky_Browser::RePopulate() -{ - // This adds in the expanders where necessary - // a major change that should be done as - // little as possible. - - int idx = 1; - int i; - std::string titleline; - - Fl_Browser::clear(); - - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Fl_Funky_Browser::RePopulate()...."); - - idx++; - - std::list::iterator it; - - DisplayItem *last[ntrees]; - - it = dlist.begin(); - if (it == dlist.end()) - { - return drawList(); - } - - // add in all the initial levels. - for(i = ntrees - 1; i >= 0; i--) - { - last[i] = new DisplayItem(); - last[i] -> expander = i; - last[i] -> index = idx + i; - last[i] -> ref = (*it) -> ref; - // random initial flags - visibility checked later. - if (i == 0) - last[i] -> flags = FUNKY_EXPANDED | FUNKY_VISIBLE; - else - last[i] -> flags = FUNKY_VISIBLE; - - dlist.push_front(last[i]); - } - - idx += ntrees; - (*it) -> index = idx++; - - DisplayItem *prev = (*it); - - for(it++; it != dlist.end(); it++) - { - // if matching at current of expansion. then ignore. - int level = 0; - level = cmp_upto(ntrees, prev, *it); - for(i = level; i < ntrees; i++) - { - last[i] = new DisplayItem(); - last[i] -> expander = i; - last[i] -> index = idx++; - last[i] -> ref = (*it) -> ref; - // random initial flags - visibility checked later. - if (i == 0) - last[i] -> flags = FUNKY_EXPANDED | FUNKY_VISIBLE; - else - last[i] -> flags = FUNKY_VISIBLE; - - dlist.insert(it, last[i]); - } - (*it) -> index = idx++; - (*it) -> flags |= FUNKY_VISIBLE; - prev = (*it); - } - - return drawList(); -} - - - -int Fl_Funky_Browser::drawList() -{ - // No need to remake list... - // just iterate through and change the text. - - int i; - int idx = 1; - std::string titleline; - //std::cerr << "Fl_Funky_Browser::drawList() 1...." << std::endl; - - int nlen = dlist.size() + 1; - if (nlen != size()) - { - // fix size. - // two loops should do the trick. - for(;size() > nlen;) - remove(size()); - add("dummy"); - for(;nlen > size();) - add("dummy"); - } - - //std::cerr << "Fl_Funky_Browser::drawList() 1b...." << std::endl; - - // draw the title. - for(i = 0; i < ncols; i++) - { - // ticked header or not..... - if (tree[display_order[i]] == 1) - { - titleline += "@T"; - } - else - { - titleline += "@E"; - } - if (sort_direction[display_order[i]] == 1) - { - titleline += "@A"; - } - else - { - titleline += "@a"; - } - - titleline += "@D@b@i@."; - - titleline += titles[display_order[i]]; - titleline += "\t"; - } - // change the text. - text(idx++, titleline.c_str()); - - std::list::iterator it; - DisplayItem *last[ntrees]; - // Now create it.... - for(it = dlist.begin(); it != dlist.end(); it++, idx++) - { - std::string line; - bool vis = true; - int depth = ntrees; - - //std::cerr << "Fl_Funky_Browser::drawList() " << idx << std::endl; - - if ((*it) -> expander > -1) - { - // save. - depth = (*it) -> expander; - last[(*it) -> expander] = (*it); - - // the line is visible if all of the lasts.. - // are expanded. - - // have an expander.... get the text. - // only creating the unique bit. - do spaces before. - for(i = 0; i < (*it) -> expander; i++) - { - line += "\t"; - } - - // put the subsign.. - line += "@I"; - - // if the last one add an expander. - if ((*it) -> flags & FUNKY_EXPANDED) - { - line += "@p@."; - } - else - { - line += "@P@."; - } - - line += (*it) -> ref -> txt(display_order[(*it) -> expander]); - line += "\t"; - } - else // A Normal element. - { - for(i = 0; i < ntrees; i++) - { - line += "\t"; - } - for(i = ntrees; i < ncols; i++) - { - if (check_box[display_order[i]]) - { - if (1 == (*it) -> ref -> check(i)) - { - line += "@T@."; - } - else - { - line += "@E@."; - } - } - - line += (*it) -> ref -> txt(display_order[i]); - line += "\t"; - } - std::ostringstream out; - out << "Normal Line:" << line << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - - // check the visibility. - for(i = 0; i < depth; i++) - { - if (!(last[i] -> flags & FUNKY_EXPANDED)) - vis = false; - line += "\t"; - } - - text(idx, line.c_str()); - // Set Visibility and Selected. - if (!vis) - { - (*it) -> flags &= ~FUNKY_VISIBLE; - hide(idx); - } - else - { - (*it) -> flags |= FUNKY_VISIBLE; - show(idx); - } - - if ((*it) -> flags & FUNKY_SELECTED) - { - select(idx, 1); - } - } - redraw(); - return 1; -} - -int Fl_Funky_Browser::checkIndices() -{ - // The just checks that the indices are valid.... - // interestingly - you could justifiably want to - // display the same column twice so we only have to check - // that they are valid. - - // Now sort columns so all the trees are - // first (both in display + sort) - int nontree = -1; - int i; - - // simple sort which is order n if correct. - for(i = 0; i < ncols; i++) - { - // check item. - if (tree[display_order[i]] == 0) - { - // catch first non tree. - if (nontree < 0) - { - nontree = i; - } - } - else // a tree one - { - if (nontree != -1) // with nontrees ahead! - { - std::ostringstream out; - out << "Swapping Items (" << i; - out << ") and (" << nontree << ")"; - out << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - - // swap the items along. - for(;i > nontree; i--) - { - int sdo = display_order[i - 1]; - display_order[i - 1] = display_order[i]; - sort_order[i - 1] = display_order[i]; - display_order[i] = sdo; - sort_order[i] = sdo; - } - // increment and continue. - nontree++; - i++; - } - } - } - // finally fix the fl_width array. - for(i = 0; i < ncols; i++) - { - fl_widths[i] = widths[display_order[i]]; - } - fl_widths[ncols] = 0; - return 1; -} - - - -int Fl_Funky_Browser::toggleCollapseLevel(int row) -{ - int itemnum = row; - int i; - std::list::iterator it, it2; - - DisplayItem *last[ntrees]; - - for(it = dlist.begin(); it != dlist.end(); it++) - { - if ((*it) -> expander > -1) - { - last[(*it) -> expander] = (*it); - } - - if (itemnum == (*it) -> index) - { - if ((*it) -> expander < 0) - { - // not a expansion point. - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "toggleCollapseLevel() Bad PT"); - return 0; - } - - { - std::ostringstream out; - out << "toggleCollapseLevel() Found(" << itemnum; - out << ")" << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - - if ((*it) -> flags & FUNKY_EXPANDED) - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Setting EXP -> OFF"); - (*it) -> flags &= ~FUNKY_EXPANDED; // FLIP BIT. - } - else - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Setting EXP -> ON"); - (*it) -> flags |= FUNKY_EXPANDED; // FLIP BIT. - } - - // Must change the text to match!. - std::string line; - - // only creating the unique bit. - do spaces before. - for(i = 0; i < (*it) -> expander; i++) - { - line += "\t"; - } - - // put the subsign.. - line += "@I"; - - // if the last one add an expander. - if ((*it) -> flags & FUNKY_EXPANDED) - { - line += "@p@."; - } - else - { - line += "@P@."; - } - - line += (*it) -> ref -> txt(display_order[(*it) -> expander]); - line += "\t"; - // replace the text. - text(itemnum, line.c_str()); - - - // continue down the list - // until we reach the next collapse - // of the same level. - it2 = it; - int idx = itemnum; - for(it2++, idx++; it2 != dlist.end(); it2++, idx++) - { - // if expander + higher level. - if (((*it2) -> expander > -1) && - ((*it2) -> expander <= (*it) -> expander)) - { - // finished. - return 1; - } - int depth = ntrees; - // update still. - if ((*it2) -> expander > -1) - { - depth = (*it2) -> expander; - last[(*it2) -> expander] = (*it2); - } - - // check visibility. - bool vis = true; - - { - std::ostringstream out; - out << "LINE: " << text(idx) << std::endl; - out << "EXP_TREE: "; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - - for(i = 0; i < depth; i++) - { - if (!(last[i] -> flags & FUNKY_EXPANDED)) - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, "\tOFF"); - vis = false; - } - else - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, "\tON"); - } - } - - // Set Visibility and Selected. - if (!vis) - { - (*it2) -> flags &= ~FUNKY_VISIBLE; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, "\tSUB EXP -> OFF"); - hide(idx); - } - else - { - (*it2) -> flags |= FUNKY_VISIBLE; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, "\tSUB EXP -> ON"); - show(idx); - } - } - } - } - return 0; -} - - -int Fl_Funky_Browser::selectItems(int row) -{ - int itemnum = row; - int idx; - std::list::iterator it, it2; - - for(it = dlist.begin(), idx = 2; it != dlist.end(); it++, idx++) - { - // Not Selected. - (*it) -> flags &= ~FUNKY_SELECTED; - select(idx, 0); - - { - std::ostringstream out; - out << "Un - Selecting(" << idx << "):"; - out << text(idx) << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - - if (itemnum == (*it) -> index) { - if (one_select) - { - if ((*it) -> expander == -1) - { - (*it) -> flags |= FUNKY_SELECTED; - select(idx, 1); - } - else // iterate down until. - { - for(; (it != dlist.end()) && - ((*it) -> expander != -1); it++, idx++) - { - (*it) -> flags &= ~FUNKY_SELECTED; - select(idx, 0); - if (!((*it) -> flags & FUNKY_EXPANDED)) - toggleCollapseLevel(idx); - } - // end condition - if (it == dlist.end()) - { - do_callback(); - return 1; - } - (*it) -> flags |= FUNKY_SELECTED; - select(idx, 1); - - } - } - else - { - (*it) -> flags |= FUNKY_SELECTED; - select(idx, 1); - int depth = (*it) -> expander; - - for(it++, idx++; (it != dlist.end()) && - (((*it) -> expander == -1) || - ((*it) -> expander > depth)); it++, idx++) - { - (*it) -> flags |= FUNKY_SELECTED; - select(idx, 1); - - std::ostringstream out; - out << "Selecting(" << idx << "):"; - out << text(idx) << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - if (it == dlist.end()) - { - do_callback(); - return 1; - } - }} - } - do_callback(); - return 0; -} - - -int Fl_Funky_Browser::getCheckState(int row, int col) -{ - if (row != -1) - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Fl_Funky_Browser::getCheckState() Cannot Handle Random Row yet!"); - } - row = value(); - col = 0; - - int idx; - std::list::iterator it, it2; - - for(it = dlist.begin(), idx = 2; it != dlist.end() - && (idx <= row); it++, idx++) - { - if (row == (*it) -> index) - { - if ((*it) -> expander != -1) - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, "No CheckBox"); - return 0; - } - - // toggle. - return (*it) -> ref -> check(display_order[col]); - } - } - return 0; -} - - -int Fl_Funky_Browser::toggleCheckBox(int row, int col) -{ - int itemnum = row; - col = 0; - int i, idx; - std::list::iterator it, it2; - - { - std::ostringstream out; - out << "Fl_Funky_Browser::toggleCheckBox(" << row << "."; - out << col << ")" << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - - for(it = dlist.begin(), idx = 2; it != dlist.end(); it++, idx++) - { - if (itemnum == (*it) -> index) - { - if ((*it) -> expander != -1) - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, "No CheckBox"); - return 0; - } - - // toggle. - int chk = (*it) -> ref -> check(display_order[col]); - if (chk == 1) - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, "Checked Off"); - (*it) -> ref -> check(display_order[col], 0); - } - else - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, "Checked On"); - (*it) -> ref -> check(display_order[col], 1); - } - - // do line again.... - std::string line; - for(i = 0; i < ntrees; i++) - { - line += "\t"; - } - for(i = ntrees; i < ncols; i++) - { - if (check_box[display_order[i]]) - { - if (1 == (*it) -> ref -> check(i)) - { - line += "@T@."; - } - else - { - line += "@E@."; - } - } - - line += (*it) -> ref -> txt(display_order[i]); - line += "\t"; - } - text(itemnum, line.c_str()); - - - // select line, and then return. - return selectItems(itemnum); - } - } - return 0; -} - -int Fl_Funky_Browser::toggle_TreeSetting(int col) -{ - if (tree[display_order[col]] == 1) - { - // already a tree -> make non tree. - tree[display_order[col]] = 0; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Fl_Funky_Browser::toggle_TreeSetting() - Off!"); - ntrees--; - } - else - { - tree[display_order[col]] = 1; - ntrees++; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Fl_Funky_Browser::toggle_TreeSetting() - On!"); - } - - checkIndices(); - SortList(); - RePopulate(); - return 1; -} - - - -int Fl_Funky_Browser::toggle_ArrowSetting(int col) -{ - if (sort_direction[display_order[col]] == 1) - { - sort_direction[display_order[col]] = 0; - } - else - { - sort_direction[display_order[col]] = 1; - } - SortList(); - RePopulate(); - - return 1; -} - - - - - - - -// can handle NULLs. -int Fl_Funky_Browser::cmp_upto(int lvl, DisplayItem *i1, DisplayItem *i2) -{ - if ((i1 == NULL) || (i2 == NULL)) - { - return 0; - } - - //std::cerr << "Fl_Funky_Browser::cmp_upto(): "; - int i; - for(i = 0; i < lvl; i++) - { - if (0 != i1 -> ref -> cmp(sort_order[i], i2 -> ref)) - { - // std::cerr << "D(" << i << ")" << std::endl; - return i; - } - // std::cerr << "M(" << i << ") "; - } - //std::cerr << "S(" << lvl << ")" << std::endl; - return lvl; -} - - -int Fl_Funky_Browser::cmp(DisplayItem *i1, DisplayItem *i2) -{ - int i; - int ret; - for(i = 0; i < ncols; i++) - { - if (0 != (ret = i1 -> ref -> cmp(sort_order[i], i2 -> ref))) - { - if (sort_direction[sort_order[i]] < 1) - { - // reverse direction. - return -ret; - } - return ret; - } - } - return 0; -} - -int Fl_Funky_Browser::setTitle(int col, std::string name) -{ - titles[col % ncols] = name; - drawList(); - return 1; -} - - -int Fl_Funky_Browser::setCheck(int col) -{ - check_box[col % ncols] = true; - return 1; -} - - -static const int FL_SIGN_NONE = 0; -static const int FL_SIGN_EXPANDED = 0x01; -static const int FL_SIGN_CONTRACT = 0x02; -static const int FL_SIGN_SUBITEM = 0x04; -static const int FL_SIGN_TICKED = 0x08; -static const int FL_SIGN_BOX = 0x10; -static const int FL_SIGN_UP_ARROW = 0x20; -static const int FL_SIGN_DOWN_ARROW = 0x40; - -void Fl_Funky_Browser::item_draw(void* v, int X, int Y, int W, int H) const -{ - // Round About way of getting the text. - int inum = lineno(v); - // bad cast, but it doesn't change the text.... - // actually it does!!!! XXX BAD. should copy. - char* str = (char *) text(inum); - const int* i = column_widths(); - - - while (W > 6) { // do each tab-seperated field - int w1 = W; // width for this field - char* e = 0; // pointer to end of field or null if none - if (*i) { // find end of field and temporarily replace with 0 - e = strchr(str, column_char()); - if (e) {*e = 0; w1 = *i++;} - } - int tsize = textsize(); - Fl_Font font = textfont(); - Fl_Color lcol = textcolor(); - Fl_Align talign = FL_ALIGN_LEFT; - - //rmf24 new variable. - int expand = FL_SIGN_NONE; - - // check for all the @-lines recognized by XForms: - while (*str == format_char() && *++str && *str != format_char()) { - switch (*str++) { - case 'l': case 'L': tsize = 24; break; - case 'm': case 'M': tsize = 18; break; - case 's': tsize = 11; break; - case 'b': font = (Fl_Font)(font|FL_BOLD); break; - case 'i': font = (Fl_Font)(font|FL_ITALIC); break; - case 'f': case 't': font = FL_COURIER; break; - case 'c': talign = FL_ALIGN_CENTER; break; - case 'r': talign = FL_ALIGN_RIGHT; break; - case 'B': - // rmf24 changing to we can reach the info, - //if (!(((FL_BLINE*)v)->flags & SELECTED)) { - if (1 == selected(inum)) - { - fl_color((Fl_Color)strtol(str, &str, 10)); - fl_rectf(X, Y, w1, H); - } else strtol(str, &str, 10); - break; - case 'C': - lcol = (Fl_Color)strtol(str, &str, 10); - break; - case 'F': - font = (Fl_Font)strtol(str, &str, 10); - break; - case 'N': - lcol = FL_INACTIVE_COLOR; - break; - case 'S': - tsize = strtol(str, &str, 10); - break; - case '-': - fl_color(FL_DARK3); - fl_line(X+3, Y+H/2, X+w1-3, Y+H/2); - fl_color(FL_LIGHT3); - fl_line(X+3, Y+H/2+1, X+w1-3, Y+H/2+1); - break; - case 'u': - case '_': - fl_color(lcol); - fl_line(X+3, Y+H-1, X+w1-3, Y+H-1); - break; -// rmf24 - mods to include the (P)lus/(p) available Buttons. - case 'T': - expand |= FL_SIGN_TICKED; - break; - case 'E': - expand |= FL_SIGN_BOX; - break; - case 'P': - expand |= FL_SIGN_EXPANDED; - break; - case 'p': - expand |= FL_SIGN_CONTRACT; - break; - case 'I': - expand |= FL_SIGN_SUBITEM; - break; - case 'A': - expand |= FL_SIGN_UP_ARROW; - break; - case 'a': - expand |= FL_SIGN_DOWN_ARROW; - break; - case 'D': - fl_color(FL_DARK3); - fl_rectf(X + 2, Y + 1, w1 - 4, H - 2); - // change the drawing color. - lcol = fl_contrast(lcol, selection_color()); - break; - case '.': - goto BREAK; - case '@': - str--; goto BREAK; - } - } - BREAK: - fl_font(font, tsize); - // changed to reach the data. - //if (((FL_BLINE*)v)->flags & SELECTED) - if (1 == selected(inum)) - lcol = fl_contrast(lcol, selection_color()); - if (!active_r()) lcol = fl_inactive(lcol); - fl_color(lcol); - -// rmf24 extensions to the class. - if (expand != FL_SIGN_NONE) - { - int req_end_len = 0; - int req_init_len = 0; - int CS = H - 4; - - if (expand & FL_SIGN_TICKED) - { - CS = H - 6; - // draw a box with tick at the start. - fl_loop(X+H/2-CS/2, Y+H/2-CS/2, - X+H/2-CS/2, Y+H/2+CS/2, - X+H/2+CS/2, Y+H/2+CS/2, - X+H/2+CS/2, Y+H/2-CS/2); - - fl_line(X+H/2-CS/2, Y+H/2, X+H/2, Y+H/2+CS/2); - fl_line(X+H/2, Y+H/2+CS/2, X+H/2+CS/2, Y+H/2-CS/2); - // second set of lines.... to make it visible. - fl_line(X+H/2-CS/2-1, Y+H/2, X+H/2-1, Y+H/2+CS/2); - fl_line(X+H/2-1, Y+H/2+CS/2, X+H/2+CS/2-1, Y+H/2-CS/2); - - // indicate space required. - req_init_len = (int) H; - } - else if (expand & FL_SIGN_BOX) - { - CS = H - 6; - // draw a box at the start. - fl_loop(X+H/2-CS/2, Y+H/2-CS/2, - X+H/2-CS/2, Y+H/2+CS/2, - X+H/2+CS/2, Y+H/2+CS/2, - X+H/2+CS/2, Y+H/2-CS/2); - - // indicate space required. - req_init_len = (int) H; - } - else if (expand & FL_SIGN_CONTRACT) - { - // draw a sign with a plus.... at the start. - fl_loop(X+H/2-CS/2, Y+H/2-CS/2, - X+H/2-CS/2, Y+H/2+CS/2, - X+H/2+CS/2, Y+H/2+CS/2, - X+H/2+CS/2, Y+H/2-CS/2); - - fl_line(X+H/2, Y+H/2-CS/2, X+H/2, Y+H/2+CS/2); - fl_line(X+H/2-CS/2, Y+H/2, X+H/2+CS/2, Y+H/2); - - // indicate space required. - req_init_len = (int) H; - } - else if (expand & FL_SIGN_EXPANDED) - { - // draw a sign with a minus.... at the start. - fl_loop(X+H/2-CS/2, Y+H/2, - X+H/2, Y+H/2+CS/2, - X+H/2+CS/2, Y+H/2, - X+H/2, Y+H/2-CS/2); - - // No Vertical Line. - //fl_line(X+H/2, Y+H/2-CS/2, X+H/2, Y+H/2+CS/2); - fl_line(X+H/2-CS/2, Y+H/2, X+H/2+CS/2, Y+H/2); - - // indicate space required. - req_init_len = (int) H; - } - - if (expand & FL_SIGN_UP_ARROW) - { - // draw an uparrow. - fl_polygon(X+req_init_len+H/2-CS/2, Y+H/2+CS/2, - X+req_init_len+H/2, Y+H/2-CS/2, - X+req_init_len+H/2+CS/2, Y+H/2+CS/2); - - // indicate space required. - req_init_len += (int) H; - } - else if (expand & FL_SIGN_DOWN_ARROW) - { - fl_polygon(X+req_init_len+H/2-CS/2, Y+H/2-CS/2, - X+req_init_len+H/2, Y+H/2+CS/2, - X+req_init_len+H/2+CS/2, Y+H/2-CS/2); - - // indicate space required. - req_init_len += (int) H; - } - - // actually draw the text - fl_draw(str, X+3+req_init_len, Y, w1-6-req_end_len-req_init_len, H, e ? Fl_Align(talign|FL_ALIGN_CLIP) : talign, 0, 0); - } - else - { - // the original case. - fl_draw(str, X+3, Y, w1-6, H, e ? Fl_Align(talign|FL_ALIGN_CLIP) : talign, 0, 0); - } - - if (!e) break; // no more fields... - *e = column_char(); // put the seperator back - X += w1; - W -= w1; - str = e+1; - } -} - - -// taken from the FLTK template - -int Fl_Funky_Browser::handle(int event) -{ - int x = Fl::event_x(); - int y = Fl::event_y(); - - int bbx, bby, bbw, bbh; - bbox(bbx, bby, bbw, bbh); - if (!Fl::event_inside(bbx, bby, bbw, bbh)) - { - return Fl_Browser::handle(event); - } - - - switch(event) - { - case FL_PUSH: - // save location, and tell the world. - { - std::ostringstream out; - out << "FL_PUSH Event at (" << x << "," << y << ")"; - out << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - // if in row 1, then dragndrop. else - // might before an expansion. - if (0 == handle_push(x,y)) - { - std::ostringstream out; - out << "Sending FL_PUSH to Fl_Browser..."; - out << " for selection and callback."; - out << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - - return Fl_Browser::handle(event); - } - redraw(); - return 1; - case FL_DRAG: - { - std::ostringstream out; - out << "FL_DRAG Event at (" << x << "," << y << ")"; - out << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - return 1; - case FL_RELEASE: - { - std::ostringstream out; - out << "FL_RELEASE Event at (" << x << "," << y << ")"; - out << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - if (dragging()) - { - handle_release(x,y); - redraw(); - } - return 1; - default: - return Fl_Browser::handle(event); - } -} - -static const int DRAG_MODE_NONE = 0; -static const int DRAG_MODE_EDGE = 1; -static const int DRAG_MODE_COLUMN = 2; - -static const int EDGE_TOLERANCE = 5; -static const int BOX_TOLERANCE_RIGHT = 15; -static const int ARROW_TOLERANCE_RIGHT = 30; - -static const int BOX_TOLERANCE_LEFT = -10; -static const int MIN_WIDTH = 40; - -int Fl_Funky_Browser::handle_push(int x, int y) -{ - void *v = find_item(y); - if (v == NULL) - { - // deselect. - //deselect(); - return 0; - } - int inum = lineno(v); - int i; - - // which row??? - // if standard row - was it at a box (ie H from start).... - if (inum != 1) - { - drag_mode = DRAG_MODE_NONE; - int xloc = x - leftedge(); - for(i = 0; (xloc > BOX_TOLERANCE_RIGHT) && (i < ncols); i++) - { - xloc -= widths[display_order[i]]; - } - if (xloc > BOX_TOLERANCE_LEFT) - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, "Clicked on The Edge!"); - // we hit an edge. - if (tree[display_order[i]] == 1) - { - toggleCollapseLevel(inum); - return 1; - } - else if (check_box[display_order[i]] == true) - { - toggleCheckBox(inum, i); - return 1; - } - } - // our select policy... - selectItems(inum); - // else select it. - // select(inum); - return 1; - } - else - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, "Clicked on The Header!"); - drag_mode = DRAG_MODE_NONE; - int xloc = x - leftedge(); - for(i = 0; (xloc > widths[display_order[i]]) && (i < ncols); i++) - { - xloc -= widths[display_order[i]]; - } - { - std::ostringstream out; - out << "Click Parameters: X: " << x << " Y: " << y; - out << " NCols: " << ncols; - out << " Drag Column: " << i << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - - if (abs(xloc) < EDGE_TOLERANCE) - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Clicked on The Edge!"); - drag_mode = DRAG_MODE_EDGE; - // set mouse icon. - // save point. - drag_column = i; - drag_x = x; - drag_y = y; - fl_cursor(FL_CURSOR_INSERT, FL_FOREGROUND_COLOR, FL_BACKGROUND_COLOR); - return 1; - } - else if ((xloc > EDGE_TOLERANCE) && - (xloc < BOX_TOLERANCE_RIGHT)) - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Clicked on The Box!"); - toggle_TreeSetting(i); - } - else if ((xloc > BOX_TOLERANCE_RIGHT) && - (xloc < ARROW_TOLERANCE_RIGHT)) - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Clicked on The Arrow!"); - toggle_ArrowSetting(i); - } - else if ((xloc > ARROW_TOLERANCE_RIGHT) && - (xloc < widths[display_order[i]] - EDGE_TOLERANCE)) - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Clicked on The Title!"); - - drag_mode = DRAG_MODE_COLUMN; - // set mouse icon. - // save point. - drag_column = i; - drag_x = x; - drag_y = y; - fl_cursor(FL_CURSOR_HAND, FL_FOREGROUND_COLOR, FL_BACKGROUND_COLOR); - return 1; - } - } - - drag_mode = DRAG_MODE_NONE; - - return 1; -} - -bool Fl_Funky_Browser::dragging() -{ - if (drag_mode != DRAG_MODE_NONE) - return true; - return false; -} - -int Fl_Funky_Browser::handle_release(int x, int y) -{ - { - std::ostringstream out; - out << "Drag Handling from (" << drag_x << ","; - out << drag_y << ") -> (" << x << "," << y << ")" << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - - fl_cursor(FL_CURSOR_DEFAULT, FL_FOREGROUND_COLOR, FL_BACKGROUND_COLOR); - if (drag_mode == DRAG_MODE_EDGE) - { - if ((drag_column < 1) || (drag_column > ncols)) - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, "Can't Drag that Column!"); - drag_mode = DRAG_MODE_NONE; - return 1; - } - - int x_change = x - drag_x; - int new_width = widths[display_order[drag_column - 1]]; - new_width += x_change; - if (new_width < MIN_WIDTH) - { - new_width = MIN_WIDTH; - } - - widths[display_order[drag_column - 1]] = new_width; - fl_widths[drag_column - 1] = new_width; - } - else - { - - } - - drag_mode = DRAG_MODE_NONE; - return 1; -} - - -int Fl_Funky_Browser::setup(std::string opts) -{ - { - std::ostringstream out; - out << "Fl_Funky_Browser::setup(" << opts << ")" << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - int loc = 0; - char name[1024]; - int so, w, n, t; - - int tc = 0; - for(int i = 0; i < ncols; i++) - { - int r = sscanf(&(opts.c_str()[loc]), - " %1000s (%d:%d:%d)%n", name, &so, &w, &t, &n); - if (r < 4) - { - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, - "Failed to Finish Reading"); - break; - } - // save - { - std::ostringstream out; - out << "Data for Column(" << i << ") Name: " << name; - out << " sOrder: " << so << " Width: " << w; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - titles[i] = name; - sort_order[i] = display_order[i] = so; - widths[i] = w; - if (t == 1) - { - tree[i] = 1; - tc++; - } - else - tree[i] = 0; - - - loc += n; - } - ntrees = tc; - checkIndices(); - SortList(); - RePopulate(); - return 1; -} - -std::string Fl_Funky_Browser::setup() -{ - std::string opts; - char str[1024]; - for(int i = 0; i < ncols; i++) - { - sprintf(str, "%s (%d:%d:%d)", titles[i].c_str(), sort_order[i], widths[i], tree[i]); - opts += str; - if (i + 1 != ncols) - opts += "\t"; - } - - { - std::ostringstream out; - out << "Fl_Funky_Browser::setup() = " << opts << std::endl; - pqioutput(PQL_DEBUG_BASIC, pqiflfbzone, out.str()); - } - - return opts; -} - - diff --git a/libretroshare/src/fltkgui/Fl_Funky_Browser.h b/libretroshare/src/fltkgui/Fl_Funky_Browser.h deleted file mode 100644 index 6cbbd81c1..000000000 --- a/libretroshare/src/fltkgui/Fl_Funky_Browser.h +++ /dev/null @@ -1,179 +0,0 @@ -/* - * "$Id: Fl_Funky_Browser.h,v 1.4 2007-02-18 21:46:49 rmf24 Exp $" - * - * FltkGUI for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - -#ifndef RS_FL_FUNKY_BROWSER -#define RS_FL_FUNKY_BROWSER - -/* My new funky browser..... - * - * - Designed to sort/display a tree brower - * for search results.... - * - * First we need the basic interface class that - * must wrap the Data.... - */ - -#include -#include -#include - -class DisplayData; - -class DisplayItem -{ - public: - int expander; - int index; - int flags; - std::string txt; - DisplayData *ref; -}; - -class DisplayData -{ - public: - DisplayData() { return;} -virtual ~DisplayData() { return;} - - // a couple of functions that do the work. -virtual int ndix() = 0; // Number of Indices. - -std::string txt(int col, int width) - { - std::string out1 = txt(col); - int i; - for(i = (signed) out1.length() + 1; i < width; i++) - { - out1 += " "; - } - if ((signed) out1.length() > width) - { - std::string out2; - for(i = 0; i < width; i++) - { - out2 += out1[i]; - } - return out2; - } - return out1; - } - -virtual std::string txt(int col) = 0; - -virtual int cmp(int col, DisplayData *) = 0; -virtual int check(int n, int v = -1) { return -1;} - // return -1 unless have a check box. then return 0/1 - // if v != -1 attempt to set value. -}; - -#include - -class Fl_Funky_Browser : public Fl_Browser -{ - public: - Fl_Funky_Browser(int, int, int, int, const char *, int ncol); - //Fl_Funky_Browser(int ncol); - - // add items. -int selectDD(DisplayData *); -int addItem(DisplayData *); - // add in a batch (faster) -int addItemSeries(DisplayData *); -int ItemSeriesDone(); - -int setTitle(int col, std::string name); -int setCheck(int col); // enables check for the column; - -DisplayData *removeItem(int idx = -1); -DisplayData *removeItem(int (*fn)(DisplayData *)); // remove first matching fn. -DisplayData *getSelected(); -DisplayData *getCurrentItem(); - -int checkSort(); // check if update affected order. -int updateList(); // if affected call this. - -int toggleCheckBox(int row, int col = -1); -int getCheckState(int row = -1, int col = -1); - - // old - don't use -int current_SetCollapsed(bool col) { return 1;} - -void clear(); - - // change browser config. -int setup(std::string opts); -std::string setup(); - - // Worker Functions. -int drawList(); - - // Overload the Browser Functions....... - protected: -virtual void item_draw(void* v, int X, int Y, int W, int H) const; -virtual int handle(int event); - private: - -int toggleCollapseLevel(int row); -int toggle_TreeSetting(int); -int toggle_ArrowSetting(int); -int selectItems(int row); - -int cmp_upto(int lvl, DisplayItem *i1, DisplayItem *i2); -int cmp(DisplayItem *i1, DisplayItem *i2); - - // Worker Functions. -int checkIndices(); - -int SortList(); -int RePopulate(); - - // drag and ticks mouse stuff - int handle_push(int x, int y); - bool dragging(); - int handle_release(int x, int y); - - int ncols; - std::list dlist; - std::vector sort_order; - std::vector sort_direction; - std::vector tree; - std::vector display_order; - std::vector widths; - std::vector titles; - std::vector check_box; - - int *fl_widths; - int ntrees; - - int drag_mode; - int drag_column; // which column - int drag_x, drag_y; - bool one_select; -}; - - -#endif - diff --git a/libretroshare/src/fltkgui/Fl_Tree_Browser.cc b/libretroshare/src/fltkgui/Fl_Tree_Browser.cc deleted file mode 100644 index 8d7e09764..000000000 --- a/libretroshare/src/fltkgui/Fl_Tree_Browser.cc +++ /dev/null @@ -1,752 +0,0 @@ -// -// "$Id: Fl_Tree_Browser.cc,v 1.3 2007-02-18 21:46:49 rmf24 Exp $" -// -// This is hacked up FLTK code, and so is released under -// their licence. (below) -// Copyright 2004-2006 by Robert Fernie. -// -// Please report all bugs and problems to "retroshare@lunamutt.com". -// -///////////////////////////////////////////////////////////////////// -// -// Widget type code for the Fast Light Tool Kit (FLTK). -// -// Each object described by Fluid is one of these objects. They -// are all stored in a double-linked list. -// -// They "type" of the object is covered by the virtual functions. -// There will probably be a lot of these virtual functions. -// -// The type browser is also a list of these objects, but they -// are "factory" instances, not "real" ones. These objects exist -// only so the "make" method can be called on them. They are -// not in the linked list and are not written to files or -// copied or otherwise examined. -// -// Copyright 1998-2004 by Bill Spitzak and others. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// -// Please report all bugs and problems to "fltk-bugs@fltk.org". -// - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Fl_Tree_Browser.h" - -#include - -//static Fl_Pixmap lock_pixmap(lock_xpm); -//static Fl_Pixmap unlock_pixmap(unlock_xpm); - -void selection_changed(Fl_Item *p); -size_t fltk_strlcpy(char *dst, const char *src, size_t size); -const char* subclassname(Fl_Item *i) { return i -> type_name(); } - - -//////////////////////////////////////////////////////////////// - -class Fl_Tree_Browser : public Fl_Browser_ { - friend class Fl_Item; - - // required routines for Fl_Browser_ subclass: - void *item_first() const ; - void *item_next(void *) const ; - void *item_prev(void *) const ; - int item_selected(void *) const ; - void item_select(void *,int); - int item_width(void *) const ; - int item_height(void *) const ; - void item_draw(void *,int,int,int,int) const ; - int incr_height() const ; - -public: - - int handle(int); - void callback(); - Fl_Tree_Browser(int,int,int,int,const char * =0); -}; - -static Fl_Tree_Browser *tree_browser; - -Fl_Widget *make_tree_browser(int x,int y,int w,int h, const char *) { - return (tree_browser = new Fl_Tree_Browser(x,y,w,h)); -} - -void select(Fl_Item *o, int v) { - tree_browser->select(o,v,1); - // Fl_Item::current = o; -} - -void select_only(Fl_Item *o) { - tree_browser->select_only(o,1); -} - -void deselect() { - tree_browser->deselect(); - //Fl_Item::current = 0; // this breaks the paste & merge functions -} - -Fl_Item *Fl_Item::first; -Fl_Item *Fl_Item::last; -Fl_Item *Fl_Item::current; - -static void Fl_Tree_Browser_callback(Fl_Widget *o,void *) { - ((Fl_Tree_Browser *)o)->callback(); -} - -Fl_Tree_Browser::Fl_Tree_Browser(int X,int Y,int W,int H,const char*l) -: Fl_Browser_(X,Y,W,H,l) { - type(FL_MULTI_BROWSER); - Fl_Widget::callback(Fl_Tree_Browser_callback); - when(FL_WHEN_RELEASE); -} - -void *Fl_Tree_Browser::item_first() const {return Fl_Item::first;} - -void *Fl_Tree_Browser::item_next(void *l) const {return ((Fl_Item*)l)->next;} - -void *Fl_Tree_Browser::item_prev(void *l) const {return ((Fl_Item*)l)->prev;} - -int Fl_Tree_Browser::item_selected(void *l) const {return ((Fl_Item*)l)->new_selected;} - -void Fl_Tree_Browser::item_select(void *l,int v) {((Fl_Item*)l)->new_selected = v;} - -int Fl_Tree_Browser::item_height(void *l) const { - return ((Fl_Item *)l)->visible ? textsize()+2 : 0; -} - -int Fl_Tree_Browser::incr_height() const {return textsize()+2;} - -static Fl_Item* pushedtitle; - -// Generate a descriptive text for this item, to put in browser & window titles -const char* Fl_Item::title() { - const char* c = name(); if (c) return c; - return type_name(); -} - -extern const char* subclassname(Fl_Item*); - -void Fl_Tree_Browser::item_draw(void *v, int X, int Y, int, int) const { - Fl_Item *l = (Fl_Item *)v; - X += 3 + 18 + l->level * 12; - if (l->new_selected) fl_color(fl_contrast(FL_BLACK,FL_SELECTION_COLOR)); - else fl_color(FL_BLACK); - Fl_Pixmap *pm = NULL; //pixmap[l->pixmapID()]; - if (pm) pm->draw(X-18, Y); - //if (l->is_public() == 0) lock_pixmap.draw(X - 17, Y); - //else if (l->is_public() > 0) ; //unlock_pixmap.draw(X - 17, Y); - if (l->is_parent()) { - if (!l->next || l->next->level <= l->level) { - if (l->open_!=(l==pushedtitle)) { - fl_loop(X,Y+7,X+5,Y+12,X+10,Y+7); - } else { - fl_loop(X+2,Y+2,X+7,Y+7,X+2,Y+12); - } - } else { - if (l->open_!=(l==pushedtitle)) { - fl_polygon(X,Y+7,X+5,Y+12,X+10,Y+7); - } else { - fl_polygon(X+2,Y+2,X+7,Y+7,X+2,Y+12); - } - } - X += 10; - } - if (l->is_widget() || l->is_class()) { - //if (l->is_widget()) { - const char* c = subclassname(l); - if (!strncmp(c,"Fl_",3)) c += 3; - fl_font(textfont(), textsize()); - fl_draw(c, X, Y+13); - X += int(fl_width(c)+fl_width('n')); - c = l->name(); - if (c) { - fl_font(textfont()|FL_BOLD, textsize()); - fl_draw(c, X, Y+13); - } else if ((c=l->label())) { - char buf[50]; char* p = buf; - *p++ = '"'; - for (int i = 20; i--;) { - if (! (*c & -32)) break; - *p++ = *c++; - } - if (*c) {strcpy(p,"..."); p+=3;} - *p++ = '"'; - *p = 0; - fl_draw(buf, X, Y+13); - } - } else { - const char* c = l->title(); - char buf[60]; char* p = buf; - for (int i = 55; i--;) { - if (! (*c & -32)) break; - *p++ = *c++; - } - if (*c) {strcpy(p,"..."); p+=3;} - *p = 0; - fl_font(textfont() | (l->is_code_block() && (l->level==0 || l->parent->is_class())?0:FL_BOLD), textsize()); - fl_draw(buf, X, Y+13); - } -} - -int Fl_Tree_Browser::item_width(void *v) const { - Fl_Item *l = (Fl_Item *)v; - - if (!l->visible) return 0; - - int W = 3 + 16 + 18 + l->level*10; - if (l->is_parent()) W += 10; - - if (l->is_widget() || l->is_class()) { - const char* c = l->type_name(); - if (!strncmp(c,"Fl_",3)) c += 3; - fl_font(textfont(), textsize()); - W += int(fl_width(c) + fl_width('n')); - c = l->name(); - if (c) { - fl_font(textfont()|FL_BOLD, textsize()); - W += int(fl_width(c)); - } else if ((c=l->label())) { - char buf[50]; char* p = buf; - *p++ = '"'; - for (int i = 20; i--;) { - if (! (*c & -32)) break; - *p++ = *c++; - } - if (*c) {strcpy(p,"..."); p+=3;} - *p++ = '"'; - *p = 0; - W += int(fl_width(buf)); - } - } else { - const char* c = l->title(); - char buf[60]; char* p = buf; - for (int i = 55; i--;) { - if (! (*c & -32)) break; - *p++ = *c++; - } - if (*c) {strcpy(p,"..."); p+=3;} - *p = 0; - fl_font(textfont() | (l->is_code_block() && (l->level==0 || l->parent->is_class())?0:FL_BOLD), textsize()); - W += int(fl_width(buf)); - } - - return W; -} - -void redraw_browser() { - tree_browser->redraw(); -} - -void Fl_Tree_Browser::callback() { - selection_changed((Fl_Item*)selection()); -} - -int Fl_Tree_Browser::handle(int e) { - static Fl_Item *title; - Fl_Item *l; - int X,Y,W,H; bbox(X,Y,W,H); - switch (e) { - case FL_PUSH: - if (!Fl::event_inside(X,Y,W,H)) break; - l = (Fl_Item*)find_item(Fl::event_y()); - if (l) { - X += 12*l->level + 18 - hposition(); - if (l->is_parent() && Fl::event_x()>X && Fl::event_x()level + 18 - hposition(); - if (l->is_parent() && Fl::event_x()>X && Fl::event_x()new_selected && (Fl::event_clicks() || Fl::event_state(FL_CTRL))) - l->open(); - break; - } - l = pushedtitle; - title = pushedtitle = 0; - if (l) { - if (l->open_) { - l->open_ = 0; - for (Fl_Item*k = l->next; k&&k->level>l->level; k = k->next) - k->visible = 0; - } else { - l->open_ = 1; - for (Fl_Item*k=l->next; k&&k->level>l->level;) { - k->visible = 1; - if (k->is_parent() && !k->open_) { - Fl_Item *j; - for (j = k->next; j && j->level>k->level; j = j->next); - k = j; - } else - k = k->next; - } - } - redraw(); - } - return 1; - } - return Fl_Browser_::handle(e); -} - -Fl_Item::Fl_Item() { - factory = 0; - parent = 0; - next = prev = 0; - selected = new_selected = 0; - visible = 0; - name_ = 0; - label_ = 0; - user_data_ = 0; - user_data_type_ = 0; - callback_ = 0; - rtti = 0; - level = 0; -} - -static void fixvisible(Fl_Item *p) { - Fl_Item *t = p; - for (;;) { - if (t->parent) t->visible = t->parent->visible && t->parent->open_; - else t->visible = 1; - t = t->next; - if (!t || t->level <= p->level) break; - } -} - -// turn a click at x,y on this into the actual picked object: -Fl_Item* Fl_Item::click_test(int,int) {return 0;} -void Fl_Item::add_child(Fl_Item*, Fl_Item*) {} -void Fl_Item::move_child(Fl_Item*, Fl_Item*) {} -void Fl_Item::remove_child(Fl_Item*) {} - -// add a list of widgets as a new child of p: -void Fl_Item::add(Fl_Item *p) { - if (p && parent == p) return; - parent = p; - Fl_Item *end = this; - while (end->next) end = end->next; - Fl_Item *q; - int newlevel; - if (p) { - for (q = p->next; q && q->level > p->level; q = q->next); - newlevel = p->level+1; - } else { - q = 0; - newlevel = 0; - } - for (Fl_Item *t = this->next; t; t = t->next) t->level += (newlevel-level); - //std::cerr << "add -> level = " << newlevel << std::endl; - - level = newlevel; - if (q) { - prev = q->prev; - prev->next = this; - q->prev = end; - end->next = q; - } else if (first) { - prev = last; - prev->next = this; - end->next = 0; - last = end; - } else { - first = this; - last = end; - prev = end->next = 0; - } - if (p) p->add_child(this,0); - open_ = 1; - fixvisible(this); - //modflag = 1; - tree_browser->redraw(); -} - -// add to a parent before another widget: -void Fl_Item::insert(Fl_Item *g) { - Fl_Item *end = this; - while (end->next) end = end->next; - parent = g->parent; - int newlevel = g->level; - visible = g->visible; - for (Fl_Item *t = this->next; t; t = t->next) t->level += newlevel-level; - level = newlevel; - prev = g->prev; - if (prev) prev->next = this; else first = this; - end->next = g; - g->prev = end; - fixvisible(this); - if (parent) parent->add_child(this, g); - tree_browser->redraw(); -} - -// Return message number for I18N... -int -Fl_Item::msgnum() { - int count; - Fl_Item *p; - - for (count = 0, p = this; p;) { - if (p->label()) count ++; - //if (p != this && p->is_widget() && ((Fl_Widget_Type *)p)->tooltip()) count ++; - if (p != this && p->is_widget()) count ++; - - if (p->prev) p = p->prev; - else p = p->parent; - } - - return count; -} - - -// delete from parent: -Fl_Item *Fl_Item::remove() { - Fl_Item *end = this; - for (;;) { - if (!end->next || end->next->level <= level) break; - end = end->next; - } - if (prev) prev->next = end->next; - else first = end->next; - if (end->next) end->next->prev = prev; - else last = prev; - Fl_Item *r = end->next; - prev = end->next = 0; - if (parent) parent->remove_child(this); - parent = 0; - tree_browser->redraw(); - selection_changed(0); - return r; -} - -// update a string member: -int storestring(const char *n, const char * & p, int nostrip) { - if (n == p) return 0; - int length = 0; - if (n) { // see if blank, strip leading & trailing blanks - if (!nostrip) while (isspace(*n)) n++; - const char *e = n + strlen(n); - if (!nostrip) while (e > n && isspace(*(e-1))) e--; - length = e-n; - if (!length) n = 0; - } - if (n == p) return 0; - if (n && p && !strncmp(n,p,length) && !p[length]) return 0; - if (p) free((void *)p); - if (!n || !*n) { - p = 0; - } else { - char *q = (char *)malloc(length+1); - fltk_strlcpy(q,n,length+1); - p = q; - } - //modflag = 1; - return 1; -} - -void Fl_Item::name(const char *n) { - if (storestring(n,name_)) { - if (visible) tree_browser->redraw(); - } -} - -void Fl_Item::label(const char *n) { - if (storestring(n,label_,1)) { - setlabel(label_); - if (visible && !name_) tree_browser->redraw(); - } -} - -void Fl_Item::callback(const char *n) { - storestring(n,callback_); -} - -void Fl_Item::user_data(const char *n) { - storestring(n,user_data_); -} - -void Fl_Item::user_data_type(const char *n) { - storestring(n,user_data_type_); -} - -void Fl_Item::open() { - printf("Open of '%s' is not yet implemented\n",type_name()); -} - -void Fl_Item::setlabel(const char *) {} - -Fl_Item::~Fl_Item() { - // warning: destructor only works for widgets that have been add()ed. - if (tree_browser) tree_browser->deleting(this); - if (prev) prev->next = next; else first = next; - if (next) next->prev = prev; else last = prev; - if (current == this) current = 0; - //modflag = 1; - if (parent) parent->remove_child(this); -} - -int Fl_Item::is_parent() const {return 0;} -int Fl_Item::is_widget() const {return 0;} -int Fl_Item::is_valuator() const {return 0;} -int Fl_Item::is_button() const {return 0;} -int Fl_Item::is_menu_item() const {return 0;} -int Fl_Item::is_menu_button() const {return 0;} -int Fl_Item::is_group() const {return 0;} -int Fl_Item::is_window() const {return 0;} -int Fl_Item::is_code_block() const {return 0;} -int Fl_Item::is_decl_block() const {return 0;} -int Fl_Item::is_class() const {return 1;} -int Fl_Item::is_public() const {return 1;} -int Fl_Item::is_file() const {return 0;} - -int Fl_File_Item::is_public()const { return 1; } -int Fl_Dir_Item::is_public()const { return 1; } -int Fl_File_Item::is_parent() const {return 0;} -int Fl_Dir_Item::is_parent() const {return 1;} - -int Fl_Person_Item::is_public()const { return 1; } -int Fl_Person_Item::is_parent() const {return 1;} -int Fl_Msg_Item::is_public()const { return 1; } -int Fl_Msg_Item::is_parent() const {return 0;} - - -//////////////////////////////////////////////////////////////// - -Fl_Item *in_this_only; // set if menu popped-up in window - -void select_all_cb(Fl_Widget *,void *) { - Fl_Item *p = Fl_Item::current ? Fl_Item::current->parent : 0; - if (in_this_only) { - Fl_Item *t = p; - for (; t && t != in_this_only; t = t->parent); - if (t != in_this_only) p = in_this_only; - } - for (;;) { - if (p) { - int foundany = 0; - for (Fl_Item *t = p->next; t && t->level>p->level; t = t->next) { - if (!t->new_selected) {tree_browser->select(t,1,0); foundany = 1;} - } - if (foundany) break; - p = p->parent; - } else { - for (Fl_Item *t = Fl_Item::first; t; t = t->next) - tree_browser->select(t,1,0); - break; - } - } - selection_changed(p); -} - -// rmfern - removed static.... -void delete_children(Fl_Item *p) { - Fl_Item *f; - for (f = p; f && f->next && f->next->level > p->level; f = f->next); - for (; f != p; ) { - Fl_Item *g = f->prev; - delete f; - f = g; - } -} - -void delete_all(int selected_only) { - for (Fl_Item *f = Fl_Item::first; f;) { - if (f->selected || !selected_only) { - delete_children(f); - Fl_Item *g = f->next; - delete f; - f = g; - } else f = f->next; - } - //if(!selected_only) include_H_from_C=1; - - selection_changed(0); -} - -// move f (and it's children) into list before g: -// returns pointer to whatever is after f & children -void Fl_Item::move_before(Fl_Item* g) { - if (level != g->level) printf("move_before levels don't match! %d %d\n", - level, g->level); - Fl_Item* n; - for (n = next; n && n->level > level; n = n->next); - if (n == g) return; - Fl_Item *l = n ? n->prev : Fl_Item::last; - prev->next = n; - if (n) n->prev = prev; else Fl_Item::last = prev; - prev = g->prev; - l->next = g; - if (prev) prev->next = this; else Fl_Item::first = this; - g->prev = l; - if (parent) parent->move_child(this,g); - tree_browser->redraw(); -} - -// move selected widgets in their parent's list: -void earlier_cb(Fl_Widget*,void*) { - Fl_Item *f; - for (f = Fl_Item::first; f; ) { - Fl_Item* nxt = f->next; - if (f->selected) { - Fl_Item* g; - for (g = f->prev; g && g->level > f->level; g = g->prev); - if (g && g->level == f->level && !g->selected) f->move_before(g); - } - f = nxt; - } -} - -void later_cb(Fl_Widget*,void*) { - Fl_Item *f; - for (f = Fl_Item::last; f; ) { - Fl_Item* prv = f->prev; - if (f->selected) { - Fl_Item* g; - for (g = f->next; g && g->level > f->level; g = g->next); - if (g && g->level == f->level && !g->selected) g->move_before(f); - } - f = prv; - } -} - -// FROM Fl_Widget_Type.cxx - -// Called when ui changes what objects are selected: -// p is selected object, null for all deletions (we must throw away -// old panel in that case, as the object may no longer exist) -void selection_changed(Fl_Item *p) { - // store all changes to the current selected objects: - //if (p && the_panel && the_panel->visible()) { - if (p) { - //set_cb(0,0); - // if there was an error, we try to leave the selected set unchanged: -// if (haderror) { -// Fl_Item *q = 0; -// for (Fl_Item *o = Fl_Item::first; o; o = o->next) { -// o->new_selected = o->selected; -// if (!q && o->selected) q = o; -// } -// if (!p || !p->selected) p = q; -// Fl_Item::current = p; -// redraw_browser(); -// return; -// } - } - // update the selected flags to new set: - Fl_Item *q = 0; - for (Fl_Item *o = Fl_Item::first; o; o = o->next) { - o->selected = o->new_selected; - if (!q && o->selected) q = o; - } - if (!p || !p->selected) p = q; - Fl_Item::current = p; -} - - -/* - * 'fltk_strlcpy()' - Safely copy two strings. (BSD style) - * Taken from fltk/src/flstring.c - */ - -size_t /* O - Length of string */ -fltk_strlcpy(char *dst, /* O - Destination string */ - const char *src, /* I - Source string */ - size_t size) { /* I - Size of destination string buffer */ - size_t srclen; /* Length of source string */ - - - /* - * Figure out how much room is needed... - */ - - size --; - - srclen = strlen(src); - - /* - * Copy the appropriate amount... - */ - - if (srclen > size) srclen = size; - - memcpy(dst, src, srclen); - dst[srclen] = '\0'; - - return (srclen); -} - -size_t /* O - Length of string */ -fltk_strlcat(char *dst, /* O - Destination string */ - const char *src, /* I - Source string */ - size_t size) { /* I - Size of destination string buffer */ - size_t srclen; /* Length of source string */ - size_t dstlen; /* Length of destination string */ - - - /* - * * Figure out how much room is left... - * */ - - dstlen = strlen(dst); - size -= dstlen + 1; - - if (!size) return (dstlen); /* No room, return immediately... */ - - /* - * * Figure out how much room is needed... - * */ - - srclen = strlen(src); - - /* - * * Copy the appropriate amount... - * */ - - if (srclen > size) srclen = size; - - memcpy(dst + dstlen, src, srclen); - dst[dstlen + srclen] = '\0'; - - return (dstlen + srclen); -} - -// -// End of "$Id: Fl_Tree_Browser.cc,v 1.3 2007-02-18 21:46:49 rmf24 Exp $". -// diff --git a/libretroshare/src/fltkgui/Fl_Tree_Browser.h b/libretroshare/src/fltkgui/Fl_Tree_Browser.h deleted file mode 100644 index 097976d4b..000000000 --- a/libretroshare/src/fltkgui/Fl_Tree_Browser.h +++ /dev/null @@ -1,210 +0,0 @@ -// -// "$Id: Fl_Tree_Browser.h,v 1.2 2007-02-18 21:46:49 rmf24 Exp $" -// -// This is hacked up FLTK code, and so is released under -// their licence. (below) -// Copyright 2004-2006 by Robert Fernie. -// -// Please report all bugs and problems to "retroshare@lunamutt.com". -// -/////////////////////////////////////////////////////////////////// -// -// Widget type header file for the Fast Light Tool Kit (FLTK). -// -// Each object described by Fluid is one of these objects. They -// are all stored in a double-linked list. -// -// There is also a single "factory" instance of each type of this. -// The method "make()" is called on this factory to create a new -// instance of this object. It could also have a "copy()" function, -// but it was easier to implement this by using the file read/write -// that is needed to save the setup anyways. -// Copyright 1998-2004 by Bill Spitzak and others. -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -// USA. -// -// Please report all bugs and problems to "fltk-bugs@fltk.org". -// - -#include -#include -#include -#include - -size_t fltk_strlcpy(char *dst, const char *src, size_t size); -size_t fltk_strlcat(char *dst, const char *src, size_t size); - -Fl_Widget *make_tree_browser(int,int,int,int,const char *l=0); -void redraw_browser(); -void delete_all(int selected_only); - -class Fl_Item { - - friend class Tree_Browser; - friend Fl_Widget *make_tree_browser(int,int,int,int,const char *l); - friend class Fl_Window_Type; - virtual void setlabel(const char *); // virtual part of label(char*) - -protected: - - Fl_Item(); - - const char *name_; - const char *label_; - const char *callback_; - const char *user_data_; - const char *user_data_type_; - -public: // things that should not be public: - - Fl_Item *parent; // parent, which is previous in list - char new_selected; // browser highlight - char selected; // copied here by selection_changed() - char open_; // state of triangle in browser - char visible; // true if all parents are open - char rtti; // hack because I have no rtti, this is 0 for base class - int level; // number of parents over this - static Fl_Item *first, *last; // linked list of all objects - Fl_Item *next, *prev; // linked list of all objects - - Fl_Item *factory; - const char *callback_name(); - -public: - - virtual ~Fl_Item(); - virtual Fl_Item *make(Fl_Item *p) = 0; - - void add(Fl_Item *parent); // add as new child - void insert(Fl_Item *n); // insert into list before n - Fl_Item* remove(); // remove from list - void move_before(Fl_Item*); // move before a sibling - - virtual const char *title(); // string for browser - virtual const char *type_name() = 0; // type for code output - - const char *name() const {return name_;} - void name(const char *); - const char *label() const {return label_;} - void label(const char *); - const char *callback() const {return callback_;} - void callback(const char *); - const char *user_data() const {return user_data_;} - void user_data(const char *); - const char *user_data_type() const {return user_data_type_;} - void user_data_type(const char *); - - virtual Fl_Item* click_test(int,int); - virtual void add_child(Fl_Item*, Fl_Item* beforethis); - virtual void move_child(Fl_Item*, Fl_Item* beforethis); - virtual void remove_child(Fl_Item*); - - static Fl_Item *current; // most recently picked object - virtual void open(); // what happens when you double-click - - // get message number for I18N - int msgnum(); - - // fake rtti: - virtual int is_parent() const; - virtual int is_widget() const; - virtual int is_button() const; - virtual int is_valuator() const; - virtual int is_menu_item() const; - virtual int is_menu_button() const; - virtual int is_public() const; - virtual int is_group() const; - virtual int is_window() const; - virtual int is_code_block() const; - virtual int is_decl_block() const; - virtual int is_class() const; - virtual int is_file() const; - - - virtual int pixmapID() { return 0; } - - const char* class_name(const int need_nest) const; -}; - -class Fl_Dir_Item : public Fl_Item { -public: - Fl_Item *make(Fl_Item *p); - void open(); - virtual const char *type_name() {return "dir";} - int is_file() const {return 0;} - int is_parent() const; /* {return 1;} */ - int pixmapID() { return 8; } - virtual int is_public() const; -}; - -extern Fl_Dir_Item Fl_Dir_Item_type; - -class Fl_File_Item : public Fl_Item { -public: - int size; - std::string filename; - - Fl_Item *make(Fl_Item *p); - void open(); - virtual const char *type_name() {return "file";} - int is_file() const {return 1;} - int is_parent() const; /* {return 0;} */ - virtual int is_public() const; - int pixmapID() { return 9; } -}; - -extern Fl_File_Item Fl_File_Item_type; - - -class Fl_Person_Item : public Fl_Item { -public: - Fl_Item *make(Fl_Item *p); - void open(); - virtual const char *type_name() {return "Person:";} - int is_file() const {return 0;} - int is_parent() const; /* {return 1;} */ - virtual int is_public() const; - int pixmapID() { return 1; } - std::string person_hash; -}; - -extern Fl_Person_Item Fl_Person_Item_type; - -class Fl_Msg_Item : public Fl_Item { -public: - Fl_Item *make(Fl_Item *p); - void open(); - virtual const char *type_name() {return "msg";} - int is_file() const {return 0;} - int is_parent() const; /* {return 1;} */ - virtual int is_public() const; - int pixmapID() { return 2; } -}; - -extern Fl_Msg_Item Fl_Msg_Item_type; - - -// bonus helper function. -void delete_children(Fl_Item *p); - - - -// replace a string pointer with new value, strips leading/trailing blanks: -int storestring(const char *n, const char * & p, int nostrip=0); - -// -// End of "$Id: Fl_Tree_Browser.h,v 1.2 2007-02-18 21:46:49 rmf24 Exp $". -// diff --git a/libretroshare/src/fltkgui/Makefile b/libretroshare/src/fltkgui/Makefile deleted file mode 100644 index f93c22ffc..000000000 --- a/libretroshare/src/fltkgui/Makefile +++ /dev/null @@ -1,39 +0,0 @@ - -RS_TOP_DIR = .. -include ../make.opt - -STRIP=strip - -OBJ = fltkserver.o guitab.o Fl_Funky_Browser.o pqibrowseitem.o pqistrings.o \ - Fl_Tree_Browser.o Fl_File_Item.o fltkpqi.o alertbox.o - -WIN_OBJ = retrotray.o - -# add in windows objs -ifeq ($(OS),Linux) -else - OBJ += $(WIN_OBJ) -endif - -all : $(OBJ) RetroShare - -RetroShare : $(OBJ) - $(CC) $(CFLAGS) -static -o RetroShare $(OBJ) -lfltk $(RSLIBS) -# $(STRIP) -s RetroShare.exe -# $(STRIP) -s RetroShare - -.cc.o: - $(CC) $(CFLAGS) -c $< - -clean: - -$(RM) $(OBJ) - -clobber: clean - -$(RM) RetroShare - - - - - - - diff --git a/libretroshare/src/fltkgui/alertbox.cc b/libretroshare/src/fltkgui/alertbox.cc deleted file mode 100644 index 7996033d8..000000000 --- a/libretroshare/src/fltkgui/alertbox.cc +++ /dev/null @@ -1,197 +0,0 @@ -/* - * "$Id: alertbox.cc,v 1.3 2007-02-18 21:46:49 rmf24 Exp $" - * - * FltkGUI for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - - -#include "fltkgui/pqistrings.h" -#include "fltkgui/alertbox.h" - -#include - -alertBox::alertBox(Fl_Window *w, Fl_Text_Display *box) - :showThreshold(2), alert_win(w), alert_box(box), - maxMessages(40) - { - /* can't call virtual fn here! */ - alertBox::loadInitMsg(); - return; - } - -alertBox::~alertBox() -{ - /* clean up msgs */ - return; -} - -int alertBox::loadInitMsg() -{ - sendMsg(0, 10,"Welcome to RetroShare ----", ""); - return 1; -} - -int chatterBox::loadInitMsg() -{ - sendMsg(0, 10,"", ""); - sendMsg(0, 10,"\tThis is your Universal ChatterBox Window", ""); - sendMsg(0, 10,"", ""); - sendMsg(0, 10,"\tYou can use it to chat with everyone", ""); - sendMsg(0, 10,"\tthat is online at this moment", ""); - - sendMsg(0, 10,"", ""); - sendMsg(0, 10,"\tSometimes the conversations can seem", ""); - sendMsg(0, 10,"\tweird and wonderful, if you're not", ""); - sendMsg(0, 10,"\tconnected all the same people.", ""); - sendMsg(0, 10,"", ""); - sendMsg(0, 10,"\tIt is a bit of an experiment, so", ""); - sendMsg(0, 10,"\tlet me know if you enjoy it or hate it!", ""); - sendMsg(0, 10,"", ""); - sendMsg(0, 10,"Note. Your ChatterBox only pop up once, when the", ""); - sendMsg(0, 10,"first message is received. After that it'll leave", ""); - sendMsg(0, 10,"you in peace. Use the \"Chat\" Button on the main", ""); - sendMsg(0, 10,"window to open and close your ChatterBox", ""); - sendMsg(0, 10,"", ""); - sendMsg(0, 10,"", ""); - return 1; -} - - -int alertBox::sendMsg(int type, int severity, - std::string msg, std::string source) -{ - alertMsg newal; - - newal.epoch = time(NULL); - newal.type = type; - newal.severity = severity; - newal.msg = msg; - newal.source = source; - - msgs.push_front(newal); - if (msgs.size() > (unsigned) maxMessages) - { - msgs.pop_back(); - } - displayMsgs(); - showMsgs(severity); - return 1; -} - - -int alertBox::showMsgs(int severity) -{ - if (severity <= showThreshold) - { - alert_win -> show(); - return 1; - } - return 0; -} - -/* chatterbox will only pop up for the first chat */ -int chatterBox::showMsgs(int severity) -{ - if ((firstMsg) && (alertBox::showMsgs(severity))) - { - firstMsg = false; - return 1; - } - return 0; -} - -void alertBox::displayMsgs() -{ - std::ostringstream msg; - - std::deque::reverse_iterator it; - for(it = msgs.rbegin(); it != msgs.rend(); it++) - { - if (it -> severity <= showThreshold) - { - msg << "----------------->>>> ALERT: "; - msg << timeFormat(it -> epoch, TIME_FORMAT_NORMAL); - msg << std::endl; - msg << std::endl; - - msg << it -> msg << std::endl; - msg << std::endl; - msg << "<<<<----------------"; - msg << std::endl; - msg << std::endl; - } - else - { - msg << timeFormat(it -> epoch, TIME_FORMAT_NORMAL); - msg << ":" << it -> msg << std::endl; - msg << std::endl; - } - } - Fl_Text_Buffer *buf = alert_box -> buffer(); - buf -> text(msg.str().c_str()); - int c = buf -> length(); - int lines = buf -> count_lines(0, c-1); - // want to scroll to the bottom. - alert_box -> scroll(lines, 0); -} - - -void chatterBox::displayMsgs() -{ - std::ostringstream msg; - - std::deque::reverse_iterator it; - std::string lsrc = ""; - int lts = 0; - for(it = msgs.rbegin(); it != msgs.rend(); it++) - { - if ((it->epoch-lts > 30) || // more than 30 seconds. - (it->source != lsrc)) // not same source - { - msg << "\t\t\t\t\t\t["; - msg << it->source; - msg << " @ "; - msg << timeFormat(it -> epoch, TIME_FORMAT_NORMAL); - msg << "]"; - msg << std::endl; - } - - msg << it -> msg; - msg << std::endl; - - /* store last one */ - lts = it->epoch; - lsrc = it->source; - } - - Fl_Text_Buffer *buf = alert_box -> buffer(); - buf -> text(msg.str().c_str()); - int c = buf -> length(); - int lines = buf -> count_lines(0, c-1); - // want to scroll to the bottom. - alert_box -> scroll(lines, 0); -} - - - diff --git a/libretroshare/src/fltkgui/alertbox.h b/libretroshare/src/fltkgui/alertbox.h deleted file mode 100644 index 93ff55a00..000000000 --- a/libretroshare/src/fltkgui/alertbox.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * "$Id: alertbox.h,v 1.4 2007-02-18 21:46:49 rmf24 Exp $" - * - * FltkGUI for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - -#ifndef RETROSHARE_ALERT_H -#define RETROSHARE_ALERT_H - -#include -#include - -#include -#include - -class alertMsg -{ - public: - - int epoch; - int type; - int severity; - std::string msg; - std::string source; -}; - -class alertBox -{ - public: - alertBox(Fl_Window *w, Fl_Text_Display *box); -virtual ~alertBox(); - -int sendMsg(int type, int severity, - std::string msg, std::string source); - - protected: - int loadInitMsg(); -virtual void displayMsgs(); -virtual int showMsgs(int severity); - - int showThreshold; // At what severity we show ourselves. - Fl_Window *alert_win; - Fl_Text_Display *alert_box; - int maxMessages; - - std::deque msgs; -}; - -class chatterBox: public alertBox -{ - public: - chatterBox(Fl_Window *w, Fl_Text_Display *box) - :alertBox(w, box), firstMsg(true) - { - chatterBox::loadInitMsg(); - return; - } - - protected: - int loadInitMsg(); -virtual void displayMsgs(); -virtual int showMsgs(int severity); - - private: - bool firstMsg; - -}; - - -#endif diff --git a/libretroshare/src/fltkgui/fltkpqi.cc b/libretroshare/src/fltkgui/fltkpqi.cc deleted file mode 100644 index ddde097e4..000000000 --- a/libretroshare/src/fltkgui/fltkpqi.cc +++ /dev/null @@ -1,1852 +0,0 @@ -/* - * "$Id: fltkpqi.cc,v 1.34 2007-02-19 20:30:05 rmf24 Exp $" - * - * FltkGUI for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - -#include "dbase/filedex.h" -#include "server/filedexserver.h" -#include "pqi/pqipersongrp.h" -#include "pqi/pqiloopback.h" - -#include "fltkgui/guitab.h" -#include "fltkgui/fltkserver.h" - -#include -#include -#include - -// Includes for directory creation. -#include -#include -#include -// Conflicts with FLTK def - hope they are the same. -//#include - -// for blocking signals -#include - -#include "fltkgui/alertbox.h" - -#include "pqi/pqidebug.h" - -// key callback functions. - -void gui_update(); -void update_connections(); -void update_search(); -void update_messages(); -void update_about(); -void update_files(); - - -// Global Pointers for the callback functions. -fltkserver *fserv; -UserInterface *ui; - -alertBox *chatbox; -alertBox *alertbox; - -// initial configuration bootstrapping... -static const std::string config_init_file = "default_cert.txt"; -static const std::string config_file = "config.rs"; -static const std::string cert_dir = "friends"; -static const std::string key_dir = "keys"; -static const std::string ca_file = "cacerts.pem"; - -static std::string config_basedir; -static std::string load_cert; -static std::string load_key; - -static std::string load_trustedpeer_file; -static bool load_trustedpeer = false; - -static bool firsttime_run = false; - -int create_configinit(); -int check_create_directory(std::string dir); -void load_check_basedir(); -void clear_passwds(); - - - -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ -#ifndef WINDOWS_SYS -static const char dirSeperator = '/'; // For unix. - -// standard start for unix. -int main(int argc, char **argv) -{ - - // setup debugging for desired zones. - setOutputLevel(PQL_WARNING); // default to Warnings. - - // For Testing purposes. - // We can adjust everything under Linux. - //setZoneLevel(PQL_DEBUG_BASIC, 38422); // pqipacket. - //setZoneLevel(PQL_DEBUG_BASIC, 96184); // pqinetwork; - //setZoneLevel(PQL_DEBUG_BASIC, 82371); // pqiperson. - //setZoneLevel(PQL_DEBUG_BASIC, 60478); // pqitunnel. - //setZoneLevel(PQL_DEBUG_BASIC, 34283); // pqihandler. - //setZoneLevel(PQL_DEBUG_BASIC, 44863); // discItems. - //setZoneLevel(PQL_DEBUG_BASIC, 2482); // p3disc - //setZoneLevel(PQL_DEBUG_BASIC, 1728); // pqi/p3proxy - //setZoneLevel(PQL_DEBUG_BASIC, 1211); // sslroot. - //setZoneLevel(PQL_DEBUG_BASIC, 37714); // pqissl. - //setZoneLevel(PQL_DEBUG_BASIC, 8221); // pqistreamer. - //setZoneLevel(PQL_DEBUG_BASIC, 9326); // pqiarchive - //setZoneLevel(PQL_DEBUG_BASIC, 3334); // p3channel. - //setZoneLevel(PQL_DEBUG_BASIC, 354); // pqipersongrp. - //setZoneLevel(PQL_DEBUG_BASIC, 6846); // pqiudpproxy - //setZoneLevel(PQL_DEBUG_BASIC, 3144); // pqissludp; - //setZoneLevel(PQL_DEBUG_BASIC, 86539); // pqifiler. - //setZoneLevel(PQL_DEBUG_BASIC, 91393); // Funky_Browser. - //setZoneLevel(PQL_DEBUG_BASIC, 25915); // fltkserver - //setZoneLevel(PQL_DEBUG_BASIC, 47659); // fldxsrvr - //setZoneLevel(PQL_DEBUG_BASIC, 49787); // pqissllistener - - - -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ -#else - -static const char dirSeperator = '\\'; // For windows. - -// Include for the windows system tray... -// the reason for the alternative -// program start. - -#include "retroTray.h" - -/* believe this fn exists! */ -LPSTR * WINAPI CommandLineToArgvA(LPCSTR,int*); - -const int MAX_ARGS = 32; - -int WinMain(HINSTANCE hinst, HINSTANCE prevhinst, char *argv_crap, int argc_crap) -{ - int i,j; - - int argc; - char *argv[MAX_ARGS]; - char *wholeline = GetCommandLine(); - int cmdlen = strlen(wholeline); - // duplicate line, so we can put in spaces.. - char dupline[cmdlen+1]; - strcpy(dupline, wholeline); - - /* break wholeline down .... - * NB. This is very simplistic, and will not - * handle multiple spaces, or quotations etc, only for debugging purposes - */ - argv[0] = dupline; - for(i = 1, j = 0; (j + 1 < cmdlen) && (i < MAX_ARGS);) - { - /* find next space. */ - for(;(j + 1 < cmdlen) && (dupline[j] != ' ');j++); - if (j + 1 < cmdlen) - { - dupline[j] = '\0'; - argv[i++] = &(dupline[j+1]); - } - } - argc = i; - for( i=0; i dirs; - - short port = 7812; // default port. - bool forceLocalAddr = false; - bool haveLogFile = false; - bool outStderr = false; - - char inet[256] = "127.0.0.1"; - char passwd[256] = ""; - char logfname[1024] = ""; - - int c; - bool havePasswd = false; - bool haveDebugLevel = false; - int debugLevel = PQL_WARNING; - bool udpListenerOnly = false; - - while((c = getopt(argc, argv,"i:p:c:sw:l:d:u")) != -1) - { - switch (c) - { - case 'l': - strncpy(logfname, optarg, 1024); - std::cerr << "LogFile (" << logfname; - std::cerr << ") Selected" << std::endl; - haveLogFile = true; - break; - case 'w': - strncpy(passwd, optarg, 256); - std::cerr << "Password Specified(" << passwd; - std::cerr << ") Selected" << std::endl; - havePasswd = true; - break; - case 'i': - strncpy(inet, optarg, 256); - std::cerr << "New Inet Addr(" << inet; - std::cerr << ") Selected" << std::endl; - forceLocalAddr = true; - break; - case 'p': - port = atoi(optarg); - std::cerr << "New Listening Port(" << port; - std::cerr << ") Selected" << std::endl; - break; - case 'c': - config_basedir = optarg; - std::cerr << "New Base Config Dir("; - std::cerr << config_basedir; - std::cerr << ") Selected" << std::endl; - break; - case 's': - outStderr = true; - haveLogFile = false; - std::cerr << "Output to Stderr"; - std::cerr << std::endl; - break; - case 'd': - haveDebugLevel = true; - debugLevel = atoi(optarg); - std::cerr << "Opt for new Debug Level"; - std::cerr << std::endl; - break; - case 'u': - udpListenerOnly = true; - std::cerr << "Opt for only udpListener"; - std::cerr << std::endl; - break; - default: - std::cerr << "Unknown Option!"; - exit(1); - } - } - - - // set the default Debug Level... - if (haveDebugLevel) - { - if ((debugLevel > 0) && (debugLevel <= PQL_DEBUG_ALL)) - { - std::cerr << "Setting Debug Level to: " << debugLevel; - std::cerr << std::endl; - setOutputLevel(debugLevel); - } - else - { - std::cerr << "Ignoring Invalid Debug Level: "; - std::cerr << debugLevel; - std::cerr << std::endl; - } - } - - // set the debug file. - if (haveLogFile) - { - setDebugFile(logfname); - } - -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ -#ifndef WINDOWS_SYS -/********************************** WINDOWS/UNIX SPECIFIC PART ******************/ -#else - // As windows doesn't have commandline options - we have to set them... - // or make them part of prog config. - - /* - char certloc[256] = "./keys/bobby_cert.pem"; - char pkeyloc[256] = "./keys/bobby_pk.pem"; - */ - //char inet[256] = "10.0.0.2"; - - // only the currnet directory for the moment. - //dirs.push_back("."); - - // Windows Networking Init. - WORD wVerReq = MAKEWORD(2,2); - WSADATA wsaData; - - if (0 != WSAStartup(wVerReq, &wsaData)) - { - std::cerr << "Failed to Startup Windows Networking"; - std::cerr << std::endl; - } - else - { - std::cerr << "Started Windows Networking"; - std::cerr << std::endl; - } - -#endif -/********************************** WINDOWS/UNIX SPECIFIC PART ******************/ - - // first check config directories, and set bootstrap values. - load_check_basedir(); - - // blank the trustedpeer loading variables. - load_trustedpeer = false; - load_trustedpeer_file = ""; - - firsttime_run = false; - - // Next - Setup the GUI defaults...... - ui = new UserInterface(); - ui -> make_windows(); - - // SWITCH off the SIGPIPE - kills process on Linux. -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ -#ifndef WINDOWS_SYS - struct sigaction sigact; - sigact.sa_handler = SIG_IGN; - sigact.sa_flags = 0; - - if (0 == sigaction(SIGPIPE, &sigact, NULL)) - { - std::cerr << "RetroShare:: Successfully Installed"; - std::cerr << "the SIGPIPE Block" << std::endl; - } - else - { - std::cerr << "RetroShare:: Failed to Install"; - std::cerr << "the SIGPIPE Block" << std::endl; - } -#else - // in windows case, install the system tray. - std::string iconpath = config_basedir + dirSeperator; - iconpath += "tst.ico"; - SetIconPath(iconpath.c_str()); - InitialiseRetroTray(hinst, NULL, ui); - -#endif -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ - - // add the text_buffers to the correct displays... - ui -> cert_details -> buffer(new Fl_Text_Buffer(10000)); - ui -> msg_details -> buffer(new Fl_Text_Buffer(10000)); - ui -> msg_text -> buffer(new Fl_Text_Buffer(10000)); - ui -> transfer_overview -> buffer(new Fl_Text_Buffer(10000)); - ui -> chan_createmsg_msg -> buffer(new Fl_Text_Buffer(10000)); - ui -> chan_msgdetails_msg -> buffer(new Fl_Text_Buffer(10000)); - - ui -> alert_box -> buffer(new Fl_Text_Buffer(10000)); - ui -> chatter_box -> buffer(new Fl_Text_Buffer(10000)); - - //ui -> cert_list -> Fl_Browser::handle(FL_PUSH); - ui -> cert_list -> when(FL_WHEN_CHANGED); - ui -> srch_results -> when(FL_WHEN_CHANGED); - ui -> msg_list -> when(FL_WHEN_CHANGED); - ui -> cert_list -> setCheck(2); - -// ui -> cert_list -> setTitle(0,"Status"); -// ui -> cert_list -> setTitle(1,"Person"); -// ui -> cert_list -> setTitle(2,"Auto Connect"); -// ui -> cert_list -> setTitle(3,"Server"); -// -// -// ui -> srch_results -> setTitle(0,"Source"); -// ui -> srch_results -> setTitle(1,"KeyWord"); -// ui -> srch_results -> setTitle(2,"FileName"); -// ui -> srch_results -> setTitle(3,"Size"); -// -// -// ui -> msg_list -> setTitle(0,"Source"); -// ui -> msg_list -> setTitle(1,"Message"); -// ui -> msg_list -> setTitle(2,"Date"); -// -// ui -> transfer_downloads -> setTitle(0,"Source"); -// ui -> transfer_downloads -> setTitle(1,"Direction"); -// ui -> transfer_downloads -> setTitle(2,"Filename"); -// ui -> transfer_downloads -> setTitle(3,"Completed"); -// ui -> transfer_downloads -> setTitle(4,"Rate"); - - - // disable the channel stuff (and recommend stuff) for now! - ui ->file_channel_button->deactivate(); - ui ->search_channel_button->deactivate(); - //ui ->channels->deactivate(); - - - - chatbox = new chatterBox(ui->chatter_window, ui->chatter_box); - alertbox = new alertBox(ui->alert_window,ui->alert_box); - - //static int neighbour_widths[3] = { 150, 250, 0 }; - //ui -> cert_neighbour_list -> column_widths(neighbour_widths); -static int neighbour_widths[3] = { 150, 250, 0 }; - ui -> neigh_signers -> column_widths(neighbour_widths); - - ui -> file_chooser -> preview(0); - - // Next bring up the welcome window..... - // load up the default welcome settings. - //ui -> load_cert -> value(load_cert.c_str()); - //ui -> load_key -> value(load_key.c_str()); - - std::string userName; - bool existingUser = false; - if (LoadCheckXPGPandGetName(load_cert.c_str(), userName)) - { - ui -> load_name -> value(userName.c_str()); - existingUser = true; - } - else - { - ui -> load_name -> value("No Existing User -> Create New"); - } - - //ui -> gen_basename -> value("user"); - - ui -> welcome_window -> show(); - if (existingUser) - { - ui -> load_passwd -> take_focus(); - } - else - { - ui -> gen_name -> take_focus(); - } - - - alertbox ->sendMsg(0, 10, "RetroShare GUI Loading.", ""); - alertbox ->sendMsg(0, 10, "RetroShare: Alert Msgs activated", ""); - - /* do a null init to allow the SSL libray to startup! */ -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - /* do a null init to allow the SSL libray to startup! */ - getSSLRoot() -> initssl(NULL, NULL, NULL); -#else /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - getSSLRoot() -> initssl(NULL, NULL, NULL, NULL); -#endif /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ -#ifndef WINDOWS_SYS - if (havePasswd) - { - ui -> load_passwd -> value(passwd); - load_existing(NULL, NULL); - // do we need to shut down the window? - } -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ -#else // WINDOWS - // can't load passwd from command line. -#endif - - // wait for this window to be finished.... - while(!(getSSLRoot() -> active())) - { - Fl::wait(); - } - - // ssl root is setup already.... by welcome_window. - // this means that the cert/key + cacerts have been loaded. - sslroot *sr = getSSLRoot(); - -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - if (1 != sr -> initssl(NULL, NULL, NULL)) -#else /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - if (1 != sr -> initssl(NULL, NULL, NULL, NULL)) -#endif /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - { - std::cerr << "main() - Fatal Error....." << std::endl; - std::cerr << "Invalid Certificate configuration!" << std::endl; - std::cerr << std::endl; - exit(1); - } - - /* set the debugging to crashMode */ - if ((!haveLogFile) && (!outStderr)) - { - std::string crashfile = config_basedir + dirSeperator; - crashfile += "retro.log"; - setDebugCrashMode(crashfile.c_str()); - } - - alertbox ->sendMsg(0, 10, "RetroShare: Loading", ""); - - // set the directories for full configuration load. - sr -> setConfigDirs(config_basedir.c_str(), cert_dir.c_str()); - sr -> loadCertificates(config_file.c_str()); - sr -> checkNetAddress(); - - // filedex server. - filedexserver server; - - -#ifdef USE_FILELOOK - fileLook *fl = new fileLook(); - fl -> start(); /* background look thread */ - server.setFileLook(fl); -#else /*********************************************************************/ - filedex *fd = new filedex(); - server.setFileDex(fd); -#endif - - server.setConfigDir(config_basedir.c_str()); - - SecurityPolicy *none = secpolicy_create(); - - if (forceLocalAddr) - { - struct sockaddr_in laddr; - - laddr.sin_family = AF_INET; - laddr.sin_port = htons(port); - - // universal - laddr.sin_addr.s_addr = inet_addr(inet); - // unix specific - //inet_aton(inet, &(laddr.sin_addr)); - - cert *own = sr -> getOwnCert(); - if (own != NULL) - { - own -> localaddr = laddr; - } - } - - /* must load the trusted_peer before setting up the pqipersongrp */ - if (firsttime_run) - { - /* at this point we want to load and start the trusted peer -> if selected */ - if (load_trustedpeer) - { - /* sslroot does further checks */ - sr -> loadInitialTrustedPeer(load_trustedpeer_file); - } - } - - unsigned long flags = 0; - if (udpListenerOnly) - { - flags |= PQIPERSON_NO_SSLLISTENER; - } - - pqipersongrp psg(none, sr, flags); - psg.load_config(); - server.setSearchInterface(&psg, sr); - -#ifdef PQI_USE_CHANNELS - server.setP3Channel(psg.getP3Channel()); -#endif - - // create loopback device, and add to pqisslgrp. - - SearchModule *mod = new SearchModule(); - pqiloopback *ploop = new pqiloopback(); - - mod -> smi = 1; - mod -> pqi = ploop; - mod -> sp = secpolicy_create(); - - psg.AddSearchModule(mod); - - //autoDiscovery ad(&psg, sr); - //ad.load_configuration(); - //ad.localSetup(); - - fltkserver ncs; - fserv = &ncs; - - ncs.setuppqissl(&server, &psg, sr, ui); - ncs.addAlerts(alertbox, chatbox); - - // Set Default Save Dir. pre-load - // Load from config will overwrite... - std::string hdefpath = fserv -> getHomePath(); - server.setSaveDir(hdefpath.c_str()); - - // load the GUI browser settings from sslroot. - ncs.cert_load_gui_config(); - - server.load_config(); - - ncs.addAutoDiscovery(psg.getP3Disc()); - - // load up the help page - std::string helppage = config_basedir + dirSeperator; - //helppage += "html"; - //helppage += dirSeperator; - //helppage += "retro_help.html"; - helppage += "retro.htm"; - //helppage += "index.html"; - //helppage = "/home/rmf24/prog/src/FLTK/fltk-1.1.6/documentation/index.html"; - - // Temp remove about page. - ui -> help_view -> load(helppage.c_str()); - ui -> help_view -> textsize(14); - - alertbox ->sendMsg(0, 10, "RetroShare: Loaded", ""); - - - /* finally show the main window */ - ui -> main_win -> show(); - - if (firsttime_run) - { - /* change any gui options that should be setup for the initial run */ - - /* set the help to be the default visible tab */ - ui -> gui_tabs->value(ui->about_help_tab); - } - else - { - /* make connect gui the initial tab */ - ui -> gui_tabs->value(ui->connect_tab); - } - - ncs.init(); - ncs.run(); - - return 1; -} - - -/* Neighbour Fns. - */ -void cert_neighbour_list_select(Fl_Funky_Browser*, void*) -{ - fserv -> cert_neighbour_item_ok = false; - std::cerr << "cert_neighbour_list_select() callback!" << std::endl; - return; -} - -void cert_neigh_signers_select(Fl_Browser*, void*) -{ - std::cerr << "cert_neigh_signers_select() callback!" << std::endl; -} - -void neigh_auth_callback(Fl_Input*, void*) -{ - fserv -> neigh_update_auth(); - return; -} - -/* Cert fns */ - -void cert_list_select(Fl_Funky_Browser*, void*) -{ - fserv -> cert_item_ok = false; - // check if this was called by ticking the box. - fserv -> cert_check_auto(); - std::cerr << "cert_list_select() callback!" << std::endl; - return; -} - -void cert_move_to_friends(Fl_Button*, void*) -{ - fserv -> cert_add_neighbour(); - std::cerr << "cert_move_to_friend() callback!" << std::endl; - return; -} - - -void cert_show_config(Fl_Button*, void*) -{ - ui -> cert_config -> show(); - return; -} - -void cert_hide_config(Fl_Button*, void*) -{ - ui -> cert_config -> hide(); - return; -} - -void cert_show_neighbour_config(Fl_Button*, void*) -{ - //ui -> cert_neighbour_config -> show(); - return; -} - -void cert_hide_neighbour_config(Fl_Button*, void*) -{ - //ui -> cert_neighbour_config -> hide(); - return; -} - -void cert_allow_change(Fl_Check_Button*, void*) -{ - if (ui -> cert_allow -> value() == 0) - { - fserv -> cert_deny_current(); - } - else - { - fserv -> cert_allow_current(); - } - fserv -> cert_list_ok = false; - fserv -> cert_item_ok = false; - return; -} - -void cert_listen_change(Fl_Check_Button*, void*) -{ - fserv -> cert_listen_current(); - fserv -> cert_list_ok = false; - fserv -> cert_item_ok = false; - return; -} - -void cert_connect_change(Fl_Check_Button*, void*) -{ - fserv -> cert_connect_current(); - fserv -> cert_list_ok = false; - fserv -> cert_item_ok = false; - return; -} - -void cert_auth_callback(Fl_Input*, void*) -{ - fserv -> cert_update_auth(); - return; -} - - -void cert_save_servaddr(Fl_Button*, void*) -{ - // if success - update gui. - // else leave for error message. - if (0 != fserv -> cert_save_servaddr()) - { - fserv -> cert_item_ok = false; - } - return; -} - - -void cert_save_n_connect(Fl_Button*, void*) -{ - if (0 != fserv -> cert_saveaddr_connect()) - { - fserv -> cert_item_ok = false; - } - return; -} - - -void cert_save_config(Fl_Button*, void*) -{ - /* - fserv -> cert_save_config(config_file.c_str()); - */ - // To allow autosave. - fserv -> cert_save_config(); - std::cerr << "fserv -> cert_save_config() Done!" << std::endl; - return; -} - - -void cert_remove_cert(Fl_Button*, void*) -{ - fserv -> cert_remove_current(); - fserv -> cert_list_ok = false; - fserv -> cert_item_ok = false; - return; -} - - -void cert_trust_person_change(Fl_Check_Button*, void*) -{ - std::cerr << "cert_trust_person_change()" << std::endl; - /* at this point we ask the sslroot->tosign(current *) */ - fserv -> cert_trust_current_toggle(); - return; -} - -void cert_auto_change(Fl_Check_Button*, void*) -{ - std::cerr << "cert_auto_change()" << std::endl; - fserv -> cert_toggle_auto(); - return; -} - - -void cert_local_change(Fl_Check_Button*, void*) -{ - std::cerr << "cert_local_change()" << std::endl; - //fserv -> cert_toggle_auto(); - return; -} - - -void cert_sign(Fl_Button*, void*) -{ - std::cerr << "cert_sign()" << std::endl; - - /* at this point we ask the sslroot->tosign(current *) */ - fserv -> cert_sign_current(); - return; -} - - -void msg_send(Fl_Button*, void*) -{ - fserv -> msg_send(); - ui -> msg_dialog -> hide(); - return; -} - - -void msg_select(Fl_Funky_Browser*, void*) -{ - fserv -> msg_list_ok = false; - fserv -> msg_item_ok = false; - return; -} - - -void msg_toggle_select(Fl_Button*, void*) -{ - return; -} - - -void msg_dialog_hide(Fl_Button*, void*) -{ - ui -> msg_dialog -> hide(); - return; -} - -void msg_dialog_show(Fl_Button*, void*) -{ - ui -> msg_dialog -> show(); - return; -} - -void msg_remove(Fl_Button*, void*) -{ - fserv -> msg_remove(); - fserv -> msg_list_ok = false; - fserv -> msg_item_ok = false; - return; -} - - -void msg_dialog_reply(Fl_Button*, void*) -{ - fserv -> msg_reply(); - fserv -> msg_item_ok = false; - ui -> msg_dialog -> show(); - return; -} - - -void msg_get_recommendation(Fl_Button*, void*) -{ - fserv -> download_recommend(); - return; -} - - -void channel_select(Fl_Browser*, void*) -{ - std::cerr << "Channel callback" << std::endl; - fserv -> msg_channel_select(); -} - - -void transfer_select(Fl_Funky_Browser*, void*) -{ - std::cerr << "Transfer callback" << std::endl; - //fserv -> transfer_select(); -} - -void file_transfer_cancel(Fl_Button*, void*) -{ - std::cerr << "File Transfer Cancel callback" << std::endl; - fserv -> transfer_cancel(); -} - -void file_transfer_clear(Fl_Button*, void*) -{ - std::cerr << "File Transfer Clear callback" << std::endl; - fserv -> transfer_clear(); -} - -void file_transfer_total_rate(Fl_Counter*, void*) -{ - std::cerr << "File Transfer Total Rate callback" << std::endl; - fserv -> transfer_rates(); -} - - -void file_transfer_indiv_rate(Fl_Counter*, void*) -{ - std::cerr << "File Transfer Individual Rate callback" << std::endl; - fserv -> transfer_rates(); -} - - -void file_transfers_max(Fl_Counter*, void*) -{ - std::cerr << "File Transfer Max callback" << std::endl; - fserv -> transfer_rates(); -} - - -void do_new_search(Fl_Input *, void*) -{ - fserv -> search_new(); - return; -} - -void do_search_button(Fl_Button *, void*) -{ - fserv -> search_new(); - return; -} - -void search_remove(Fl_Button*, void*) -{ - fserv -> search_remove(); - return; -} - -void search_result_select(Fl_Funky_Browser*, void*) -{ - fserv -> result_item_ok = false; - std::cerr << "search_result_select() callback!" << std::endl; - return; -} - -void search_download(Fl_Button*, void*) -{ - fserv -> search_download(); - return; -} - -void search_recommend(Fl_Button*, void*) -{ - fserv -> search_recommend(); - return; -} - -void gui_hide(Fl_Button*, void*); - -void gui_quit(Fl_Button*a, void*b) -{ - gui_hide(a,b); - //exit(1); - return; -} - -void gui_hide(Fl_Button*, void*) -{ - // Temp use to shown chatter window. - // ui -> chatter_window -> show(); -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ -#ifndef WINDOWS_SYS - // iconize. - ui -> main_win -> iconize(); -#else - // windows we can hide (cos the system tray is still there) - ui -> main_win -> hide(); -#endif -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ - return; -} - -void file_import(Fl_Button*, void*) -{ - fserv -> file_select(FILE_CHOOSER_IMPORT); - ui -> file_chooser -> show(); - return; -} - - -void file_export(Fl_Button*, void*) -{ - fserv -> file_select(FILE_CHOOSER_EXPORT); - ui -> file_chooser -> show(); - return; -} - -/* Have to fix buggy Fl_File_Chooser Code..... - * Forcing the use of Enter Button. - * - * - * if valid selection..... + Enter.... - * do I/O - * - * else add timeout. - * and unhide..... - */ - -void fc_timeout(void *); - -void file_chooser_select(Fl_File_Chooser *, void*v) -{ - std::cerr << "file_chooser_select()" << std::endl; - if ((Fl::event_key() == FL_Enter) && - (NULL != ui -> file_chooser -> value())) - { - std::cerr << "file_chooser_select() Hit Enter (With Val)!" << std::endl; - fserv -> file_completeIO(); - ui -> file_chooser -> hide(); - return; - } - - // Else add timeout callback .... - Fl::add_timeout(0.5, fc_timeout); - - //fserv -> file_completeIO(); - //ui -> file_chooser -> hide(); - - -} - - -void fc_timeout(void *) -{ - std::cerr << "fc_timeout()" << std::endl; - - // ignore timeout if still shown... - if (ui -> file_chooser -> shown()) - { - std::cerr << "Visible - Ignoring fc_timeout()" << std::endl; - return; - } - - // if valid selection.... do it. - if (NULL != ui -> file_chooser -> value()) - { - std::cerr << "Hidden + Value - Do I/O" << std::endl; - fserv -> file_completeIO(); - return; - } - // else reshow the window, - std::cerr << "Hidden + No Value - re-Show" << std::endl; - ui -> file_chooser -> show(); - return; -} - - -void config_server_update(Fl_Check_Button*, void*) -{ - // save the settings. - fserv -> config_server_update(); - return; -} - - -void config_server_change(Fl_Button*, void*) -{ - // save the settings. - fserv -> config_server_change(); - return; -} - - -void config_save_dir_change(Fl_Button*, void*) -{ - fserv -> file_select(FILE_CHOOSER_SAVEDIR); - ui -> file_chooser -> show(); - // save the settings. - return; -} - - -void config_add_dir(Fl_Button*, void*) -{ - fserv -> file_select(FILE_CHOOSER_DIR); - ui -> file_chooser -> show(); - // save the settings. - return; -} - -void config_remove_dir(Fl_Button*, void*) -{ - fserv -> config_remove_dir(); - return; -} - - - - -void load_passwd_callback(Fl_Input*, void*) -{ - load_existing(NULL, NULL); - return; -} - - -void load_existing(Fl_Button*, void*) -{ - std::string cert_loc = load_cert; //ui -> load_cert -> value(); - std::string key_loc = load_key; //ui -> load_key -> value(); - std::string passwd = ui -> load_passwd -> value(); - - // hack to use the generate passwd. - if (passwd == "") - { - passwd = ui -> gen_passwd -> value(); - } - - if (cert_loc == "") - { - alertbox ->sendMsg(0, 0, "RetroShare needs a certificate", ""); - return; - } - if (key_loc == "") - { - alertbox ->sendMsg(0, 0, "RetroShare needs a Key", ""); - return; - } - if (passwd == "") - { - alertbox ->sendMsg(0, 0, "RetroShare needs a passwd", ""); - return; - } - - std::string std_key_dir = config_basedir + dirSeperator; - std_key_dir += key_dir; - - // check that the key file exists....., - // and if it is not in the configuration directory - copy it there. - - - std::string ca_loc = std_key_dir + dirSeperator; - ca_loc += ca_file; - - sslroot *sr = getSSLRoot(); - -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - if (0 < sr -> initssl(cert_loc.c_str(), key_loc.c_str(), - passwd.c_str())) -#else /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - if (0 < sr -> initssl(cert_loc.c_str(), key_loc.c_str(), - ca_loc.c_str(), passwd.c_str())) -#endif /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - - { - ui -> welcome_window -> hide(); - clear_passwds(); - - // success..... save the cert + key locations. - // as the keys are good we can create a initfile - load_cert = cert_loc; - load_key = key_loc; - - create_configinit(); - - return; - } - - // else clean up .... - alertbox ->sendMsg(0, 0, "RetroShare Failed To Start!",""); - alertbox ->sendMsg(0, 0, "Please Check File Names/Password",""); - - return; -} - -void generate_certificate(Fl_Button *button, void *nuffing) -{ - // In the XPGP world this is easy... - // generate the private_key / certificate. - // save to file. - // - // then load as if they had entered a passwd. - - // check basename exists. - // check that passwords match. - if ((strlen(ui -> gen_passwd -> value()) < 4) || - (0 != strcmp(ui -> gen_passwd -> value(), - ui -> gen_passwd2 -> value()))) - { - std::ostringstream out; - out << "RetroShare cannot generate your"; - out << "Certficate because:" << std::endl; - out << "\tPassword is Unsatisfactory..." << std::endl; - out << "\tMust be 4+ chars and entered twice" << std::endl; - alertbox ->sendMsg(0, 0, out.str(), ""); - return; - } - - if (strlen(ui -> gen_name -> value()) < 3) - { - std::ostringstream out; - out << "RetroShare cannot generate your"; - out << "Certficate because:" << std::endl; - out << "\tThe Name is bad..." << std::endl; - out << "\tMust be 3+ chars" << std::endl; - alertbox ->sendMsg(0, 0, out.str(), ""); - return; - } - - int nbits = 2048; - - // Create the filename. - std::string basename = config_basedir; - basename += dirSeperator; - basename += key_dir + dirSeperator; - basename += "user"; //ui -> gen_basename -> value(); - - std::string key_name = basename + "_pk.pem"; - std::string cert_name = basename + "_cert.pem"; - - -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - if (!generate_xpgp(cert_name.c_str(), key_name.c_str(), - ui -> gen_passwd2 -> value(), - ui -> gen_name -> value(), - "", //ui -> gen_email -> value(), - ui -> gen_org -> value(), - ui -> gen_loc -> value(), - "", //ui -> gen_state -> value(), - ui -> gen_country -> value(), - nbits)) -#else /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - /* UNTIL THIS IS FILLED IN CANNOT GENERATE X509 REQ */ -#endif /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - { - std::ostringstream out; - out << "RetroShare cannot generate your"; - out << "Certficate: UNKNOWN REASON!" << std::endl; - alertbox ->sendMsg(0, 0, out.str(), ""); - return; - } - - - /* set the load passwd to the gen version - * and try to load it! - */ - - //ui -> load_cert -> value(cert_name.c_str()); - //ui -> load_key -> value(key_name.c_str()); - load_cert = cert_name.c_str(); - load_key = key_name.c_str(); - //ui -> load_passwd -> value(ui -> load_passwd -> value()); - - { - std::ostringstream out; - out << "RetroShare has Successfully generated"; - out << "a Certficate/Key" << std::endl; - out << "\tCert Located: " << cert_name << std::endl; - out << "\tLocated: " << key_name << std::endl; - alertbox ->sendMsg(0, 10, out.str(), ""); - } - - /* now if the user has selected to load a trusted certificate - * we must save the details to we can load it in a second. - * - * load_trustedpeer is taken from the gen_trusted_tick_box, - * while load_trusted_cert(Fl_Button*, void*) sets the load_trustedpeer_file string. - */ - - if (1 == ui -> gen_trusted_tick_box -> value()) - { - load_trustedpeer = true; - } - else - { - load_trustedpeer = false; - } - - // Also set the first time flag. - firsttime_run = true; - - /* call standard load ! */ - load_existing(button, nuffing); - - return; -} - - -void load_trusted_cert(Fl_Button*, void*) -{ - Fl_File_Chooser *fc = new Fl_File_Chooser("", - "Certificate File (*.{pqi})", 0, "Trusted Friend Selection"); - fc -> show(); - while(fc -> shown()) - Fl::wait(); - - /* if we are successful, - * 1) load certificate.... if that is successful... - * 2) display name, - * 3) and tick box.. - */ - - bool valid = false; - bool trustedFriend = false; - - std::string userName; - if (fc->value()) - { - valid = true; - load_trustedpeer_file = fc -> value(); - } - - if ((valid) && (LoadCheckXPGPandGetName(load_trustedpeer_file.c_str(), userName))) - { - ui -> gen_trusted_peer -> value(userName.c_str()); - ui -> gen_trusted_tick_box -> value(1); - trustedFriend = true; - } - else - { - load_trustedpeer_file = ""; - if (valid) - { - ui -> gen_trusted_peer -> value("-Bad-File-"); - } - else - { - ui -> gen_trusted_peer -> value(""); - } - ui -> gen_trusted_tick_box -> value(0); - } - - delete fc; - return; -} - - -void gen_trusted_tick_callback(Fl_Check_Button*, void*) -{ - std::cerr << "gen_trusted_tick_callback()"; - std::cerr << std::endl; - if (ui -> gen_trusted_tick_box -> value()) - { - load_trusted_cert(NULL, NULL); - } - else - { - ui -> gen_trusted_peer -> value(""); - } - - return; -} - -void gen_load_trusted(Fl_Button*, void*) -{ - std::cerr << "gen_load_trusted()"; - std::cerr << std::endl; - - load_trusted_cert(NULL, NULL); - return; -} - - -void load_cert_change(Fl_Button*, void*) -{ - std::string std_key_dir = config_basedir + dirSeperator; - std_key_dir += key_dir; -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ -#ifdef WINDOWS_SYS /* ONLY FOR WINDOWS */ - std_key_dir = make_path_unix(std_key_dir); -#endif -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ - - - Fl_File_Chooser *fc = new Fl_File_Chooser(std_key_dir.c_str(), - "Certificate File (*.{pem})", 0, "Certificate Selection"); - fc -> show(); - while(fc -> shown()) - Fl::wait(); - - //ui -> load_cert -> value(fc -> value()); - delete fc; - return; -} - -void load_key_change(Fl_Button*, void*) -{ - std::string std_key_dir = config_basedir + dirSeperator; - std_key_dir += key_dir; -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ -#ifdef WINDOWS_SYS /* ONLY FOR WINDOWS */ - std_key_dir = make_path_unix(std_key_dir); -#endif -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ - - Fl_File_Chooser *fc = new Fl_File_Chooser(std_key_dir.c_str(), - "Private Key File (*.{pem})", 0, "Key Selection"); - fc -> show(); - while(fc -> shown()) - Fl::wait(); - - - //ui -> load_key -> value(fc -> value()); - delete fc; - return; -} - - - -void clear_passwds() -{ - ui -> load_passwd -> value("UNKNOWN.....0"); - ui -> gen_passwd -> value("UNKNOWN.....1"); - ui -> gen_passwd2 -> value("UNKNOWN.....2"); -} - - -void load_check_basedir() -{ - // get the default configuration location. - - if (config_basedir == "") - { - // if unix. homedir + /.pqiPGPrc -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ -#ifndef WINDOWS_SYS - char *h = getenv("HOME"); - std::cerr << "fltkpqi::basedir() -> $HOME = "; - std::cerr << h << std::endl; - if (h == NULL) - { - std::cerr << "load_check_basedir() Fatal Error --"; - std::cerr << std::endl; - std::cerr << "\tcannot determine $HOME dir" < $APPDATA = "; - std::cerr << h << std::endl; - char *h2 = getenv("HOMEDRIVE"); - std::cerr << "fltkpqi::basedir() -> $HOMEDRIVE = "; - std::cerr << h2 << std::endl; - char *h3 = getenv("HOMEPATH"); - std::cerr << "fltkpqi::basedir() -> $HOMEPATH = "; - std::cerr << h3 << std::endl; - if (h == NULL) - { - // generating default - std::cerr << "load_check_basedir() getEnv Error --Win95/98?"; - std::cerr << std::endl; - - config_basedir="C:\\Retro"; - - } - else - { - config_basedir = h; - } - - check_create_directory(config_basedir); - config_basedir += "\\RetroShare"; -#endif -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ - } - - - std::string subdir1 = config_basedir + dirSeperator; - std::string subdir2 = subdir1; - subdir1 += key_dir; - subdir2 += cert_dir; - - // fatal if cannot find/create. - std::cerr << "Checking For Directories" << std::endl; - check_create_directory(config_basedir); - check_create_directory(subdir1); - check_create_directory(subdir2); - - // have a config directories. - - // Check for config file. - std::string initfile = config_basedir + dirSeperator; - initfile += config_init_file; - - // open and read in the lines. - FILE *ifd = fopen(initfile.c_str(), "r"); - char path[1024]; - int i; - - if (ifd != NULL) - { - if (NULL != fgets(path, 1024, ifd)) - { - for(i = 0; (path[i] != '\0') && (path[i] != '\n'); i++); - path[i] = '\0'; - load_cert = path; - } - if (NULL != fgets(path, 1024, ifd)) - { - for(i = 0; (path[i] != '\0') && (path[i] != '\n'); i++); - path[i] = '\0'; - load_key = path; - } - fclose(ifd); - } - - // we have now - // 1) checked or created the config dirs. - // 2) loaded the config_init file - if possible. - return; -} - -int create_configinit() -{ - // Check for config file. - std::string initfile = config_basedir + dirSeperator; - initfile += config_init_file; - - // open and read in the lines. - FILE *ifd = fopen(initfile.c_str(), "w"); -/* - char path[1024]; - int i; -*/ - - if (ifd != NULL) - { - fprintf(ifd, "%s\n", load_cert.c_str()); - fprintf(ifd, "%s\n", load_key.c_str()); - fclose(ifd); - - std::cerr << "Creating Init File: " << initfile << std::endl; - std::cerr << "\tLoad Cert: " << load_cert << std::endl; - std::cerr << "\tLoad Key: " << load_key << std::endl; - - return 1; - } - std::cerr << "Failed To Create Init File: " << initfile << std::endl; - return -1; -} - - -int check_create_directory(std::string dir) -{ - struct stat buf; - int val = stat(dir.c_str(), &buf); - if (val == -1) - { - // directory don't exist. create. -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ -#ifndef WINDOWS_SYS // UNIX - if (-1 == mkdir(dir.c_str(), 0777)) -#else // WIN - if (-1 == mkdir(dir.c_str())) -#endif -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ - - { - std::cerr << "check_create_directory() Fatal Error --"; - std::cerr <value()); - std::string s("LOCL USR"); - inp -> value(""); - - //fserv -> chatmsg(m,s); - fserv -> ownchatmsg(m); - std::cerr << "Wish we could talk!" << std::endl; - return; -} - -void alert_okay_msg(Fl_Return_Button*, void*) -{ - ui -> alert_window -> hide(); - std::cerr << "Alert Okay" << std::endl; - return; -} - - -void alert_cancel_msg(Fl_Button*, void*) -{ - ui -> alert_window -> hide(); - std::cerr << "Abort Cancel" << std::endl; - return; -} - -void file_result_select(Fl_File_Browser*, void*) -{ - std::cerr << "FL_FILE_BROWSER::file_select!!!!" << std::endl; -} - - -void file_download(Fl_Button*, void*) -{ - std::cerr << "FL_BUTTON::file_download!!!!" << std::endl; - fserv->dirlist_download(); -} - -void file_recommend(Fl_Button*, void*) -{ - std::cerr << "FL_BUTTON::file_recommend!!!!" << std::endl; - fserv->dirlist_recommend(); -} - - -void file_requestdir(std::string person, std::string dir) -{ - std::cerr << "Request Dir Listing:" << person << ":" << dir << std::endl; - fserv->load_dir(person, dir); -} - - - -/* New Callback Fns for Channels *****************************/ - -/* add to channel broadcast (from dir_listing) */ -void file_channel_broadcast(Fl_Button*, void*) -{ - std::cerr << "file_channel_broadcast()"; - std::cerr << std::endl; - - return; -} - -/* add to channel broadcast (from search) */ -void search_channel_broadcast(Fl_Button*, void*) -{ - std::cerr << "search_channel_broadcast()"; - std::cerr << std::endl; - - return; -} - -/* callback for own channel select */ -void channel_own_list_select(Fl_Browser*, void*) -{ - std::cerr << "channel_own_list_select()"; - std::cerr << std::endl; - - return; -} - -/* callback for others channel select */ -void channel_list_select(Fl_Funky_Browser*, void*) -{ - std::cerr << "channel_list_select()"; - std::cerr << std::endl; - - return; -} - -/* callback for channel file listing select */ -void channel_file_list_select(Fl_Funky_Browser*, void*) -{ - std::cerr << "channel_file_list_select()"; - std::cerr << std::endl; - - return; -} - - -/* button press to create channel */ -void channel_create(Fl_Button*, void*) -{ - std::cerr << "channel_create()"; - std::cerr << std::endl; - ui->channel_create_window->show(); - return; -} - -/* button press to delete selected own channel */ -void channel_delete(Fl_Button*, void*) -{ - std::cerr << "channel_delete()"; - std::cerr << std::endl; - - return; -} - -/* open/close chat window */ -void chat_open_callback(Fl_Button*, void*) -{ - std::cerr << "chat_open()"; - std::cerr << std::endl; - if (ui->chatter_window->shown()) - { - ui->chatter_window->hide(); - } - else - { - ui->chatter_window->show(); - } - return; -} - -void channel_show_callback(Fl_Button*, void*) -{ - std::cerr << "channel_show_callback()"; - std::cerr << std::endl; - ui->channel_details_window->show(); - - return; -} - -void channel_delete_callback(Fl_Button*, void*) -{ - std::cerr << "channel_delete_callback()"; - std::cerr << std::endl; - - return; -} - - -void chan_createmsg_list_select(Fl_Funky_Browser*, void*) -{ - std::cerr << "chan_createmsg_list_select()"; - std::cerr << std::endl; - - return; -} - -void chan_createmsg_sendmsg_callback(Fl_Button*, void*) -{ - std::cerr << "chan_createmsg_sendmsg_callback()"; - std::cerr << std::endl; - - return; -} - -void chan_createmsg_postpone_callback(Fl_Button*, void*) -{ - std::cerr << "chan_createmsg_postpone_callback()"; - std::cerr << std::endl; - - ui->channel_create_window->hide(); - return; -} - -void chan_createmsg_cancel_callback(Fl_Button*, void*) -{ - std::cerr << "chan_createmsg_cancel_callback()"; - std::cerr << std::endl; - - ui->channel_create_window->hide(); - return; -} - -void chan_createmsg_remove_callback(Fl_Button*, void*) -{ - std::cerr << "chan_createmsg_remove_callback()"; - std::cerr << std::endl; - - return; -} - -void chan_createmsg_newname_callback(Fl_Input*, void*) -{ - std::cerr << "chan_createmsg_newname_callback()"; - std::cerr << std::endl; - - return; -} - -void chan_createmsg_newname_button_callback(Fl_Round_Button*, void*) -{ - std::cerr << "chan_createmsg_newname_button_callback()"; - std::cerr << std::endl; - - return; -} - -void chan_createmsg_title_button_callback(Fl_Round_Button*, void*) -{ - std::cerr << "chan_createmsg_button_callback()"; - std::cerr << std::endl; - - return; -} - - -void chan_msgdetails_list_select(Fl_Funky_Browser*, void*) -{ - std::cerr << "chan_msgdetails_list_select()"; - std::cerr << std::endl; - - return; -} - -void chan_msgdetails_download_callback(Fl_Button*, void*) -{ - std::cerr << "chan_msgdetails_download_callback()"; - std::cerr << std::endl; - - return; -} - -void chan_msgdetails_subscribe_callback(Fl_Button*, void*) -{ - std::cerr << "chan_msgdetails_subscribe_callback()"; - std::cerr << std::endl; - - return; -} - -void chan_msgdetails_close_callback(Fl_Button*, void*) -{ - std::cerr << "chan_msgdetails_close_callback()"; - std::cerr << std::endl; - ui->channel_details_window->hide(); - - return; -} - diff --git a/libretroshare/src/fltkgui/fltkserver.cc b/libretroshare/src/fltkgui/fltkserver.cc deleted file mode 100644 index 069ade6c7..000000000 --- a/libretroshare/src/fltkgui/fltkserver.cc +++ /dev/null @@ -1,3448 +0,0 @@ -/* - * "$Id: fltkserver.cc,v 1.29 2007-02-18 21:46:49 rmf24 Exp $" - * - * FltkGUI for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - - -#include "fltkgui/fltkserver.h" -#include "fltkgui/pqibrowseitem.h" - -#include -#include - -#include "pqi/pqidebug.h" -const int fltksrvrzone = 25915; - -#include -#include - -/* add in an extension if necessary */ -int ensureExtension(std::string &name, std::string def_ext); - -fltkserver::fltkserver() - :server(NULL), pqih(NULL), sslr(NULL), ui(NULL), ad(NULL), - msg(NULL), chat(NULL),loop(0), - search_browser(NULL) -{ - recommend = NULL; - - - init(); - return; -} - -fltkserver::~fltkserver() -{ - return; -} - -int fltkserver::init() -{ - cert_list_ok = false; - cert_neighbour_list_ok = false; - cert_item_ok = false; - cert_neighbour_item_ok = false; - - search_list_ok = false; - result_list_ok = false; - result_item_ok = false; - msg_list_ok = false; - msg_item_ok = false; - msg_dialog_ok = false; - transfer_ok = false; - transfer_item_ok = false; - - dir_list_ok = false; - save_dir_ok = false; - - server_set_ok = false; - transfer_rates_ok = false; - - -#ifdef PQI_USE_CHANNELS - channel_list_ok = false; - channel_msg_list_ok = false; - channel_msg_item_ok = false; -#endif - - - - return 1; -} - -int fltkserver::run() -{ - - double timeDelta = 0.25; - double minTimeDelta = 0.1; // 25; - double maxTimeDelta = 2.0; - double kickLimit = 0.5; - - double avgTickRate = timeDelta; - - struct timeval lastts, ts; - gettimeofday(&lastts, NULL); - long lastSec = 0; /* for the slower ticked stuff */ - - int min = 0; - - while(1) - { - Fl::wait(timeDelta); - - gettimeofday(&ts, NULL); - double delta = (ts.tv_sec - lastts.tv_sec) + - ((double) ts.tv_usec - lastts.tv_usec) / 1000000.0; - - /* for the fast ticked stuff */ - if (delta > timeDelta) - { - //std::cerr << "Delta: " << delta << std::endl; - //std::cerr << "Time Delta: " << timeDelta << std::endl; - //std::cerr << "Avg Tick Rate: " << avgTickRate << std::endl; - - lastts = ts; - int moreToTick = server -> tick(); - - /* adjust tick rate depending on whether there is more. - */ - - avgTickRate = 0.2 * timeDelta + 0.8 * avgTickRate; - - if (1 == moreToTick) - { - timeDelta = 0.9 * avgTickRate; - if (timeDelta > kickLimit) - { - /* force next tick in one sec - * if we are reading data. - */ - timeDelta = kickLimit; - avgTickRate = kickLimit; - } - } - else - { - timeDelta = 1.1 * avgTickRate; - } - - /* limiter */ - if (timeDelta < minTimeDelta) - { - timeDelta = minTimeDelta; - } - else if (timeDelta > maxTimeDelta) - { - timeDelta = maxTimeDelta; - } - - /* now we have the slow ticking stuff */ - /* stuff ticked once a second (but can be slowed down) */ - if (ts.tv_sec > lastSec) - { - lastSec = ts.tv_sec; - - // every ten loops (> 10 secs) - if (loop % 10 == 0) - { - update_quick_stats(); - } - - // every 60 loops (> 1 min) - if (++loop >= 60) - { - loop = 0; - - update_other_stats(); - server -> status(); - - // save the config every 5 minutes. - if (min % 5 == 0) - { - cert_save_config(); -#ifdef PQI_USE_CHANNELS - /* hack to update for now - * Only occassionally - cos disabled - */ - channel_list_ok = false; - update_channels(); -#endif - } - - /* hour loop */ - if (++min >= 60) - { - min = 0; - } - update_dirlist(); - } - - // slow update tick as well. - update(); - } // end of slow tick. - - } // end of only once a second. - - // update graphics.. ( but only if gui is visible ) - // This is also triggered in slow tick... - if ((ui->main_win->shown()) || (ui->chatter_window->shown())) - { - update(); - } - } - return 1; -} - - - -/*********************** DISPLAY DETAILS ************************************/ - -int fltkserver::update() -{ - update_certs(); - update_neighbour_certs(); - - update_search(); - update_msgs(); - update_transfer(); - update_config(); - update_dirs(); - - return 1; -} - - -int fltkserver::update_quick_stats() -{ - cert_list_ok = false; - cert_neighbour_list_ok = false; - transfer_ok = false; - transfer_item_ok = false; - - return 1; -} - -int fltkserver::update_other_stats() -{ - search_list_ok = false; - result_list_ok = false; - result_item_ok = false; - msg_list_ok = false; - msg_item_ok = false; - msg_dialog_ok = false; - - //transfer_ok = false; - //server_set_ok = false; - //transfer_rates_ok = false; - - return 1; -} - -// Now including Funky_Browser. -int fltkserver::update_certs() -{ - // to draw certs, we need to retrieve the list from sslroot. - if (sslr == NULL) - return -1; - - // once this is true, we do all following redraw steps. - bool certs_mod = false; - int i; - - Fl_Funky_Browser *cb = ui -> cert_list; - // Get the Current Cert, by getting current item - // and extracting ref. - DisplayData *selected = cb -> getSelected(); - Person *selperson = NULL; - if (selected != NULL) - { - selperson = ((PersonDisItem *) selected) -> getItem(); - } - - //int inum = cb -> value(); - - // attempt to reset item. - - // only do if - if ((sslr -> CertsChanged()) || (!cert_list_ok)) - { - certs_mod = true; - - if (sslr -> CertsMajorChanged()) // add or remove. - { - // full repopulate. - // or add/remove. (do later) - - // clear the data. - cb -> clear(); - ui -> msg_online -> clear(); - - std::list::iterator it; - std::list &certs = sslr -> getCertList(); - - std::string emptystr(""); - int online = 0; - - selected = NULL; - for(it = certs.begin(), i = 0; - it != certs.end(); it++, i++) - { - cert *c = (*it); - - PersonDisItem *cdi = new PersonDisItem(c); - - if (selperson == c) - selected = cdi; - - // set the check flag. - if (c -> Manual()) - cdi -> check(0, 0); - else - cdi -> check(0, 1); - - if (c -> Connected()) - online++; - - cb -> addItemSeries(cdi); - - //ui -> msg_online -> add((*it).c_str(), - // c -> Group("msg")); - } - cb -> ItemSeriesDone(); - ui -> onlinecounter -> value(online); - } - else - { - // else just update list. - cb -> updateList(); - } - - cb -> selectDD(selected); - cert_list_ok = true; - } - - - if ((certs_mod) || (!cert_item_ok)) - { - PersonDisItem *pdi = (PersonDisItem *) cb -> getCurrentItem(); - Person *p = NULL; - if (pdi != NULL) - { - p = pdi -> getItem(); - } - // do always - neighbours does it afterwards. - cert_display((cert *) p, true); - } - return 1; -} - -int fltkserver::cert_display(cert *c, bool isfriend) -{ - Fl_Text_Buffer *buf = NULL; - std::string certtext; - - if ((c == NULL) || (c->certificate == NULL)) - { - ui -> cert_status -> value("N/A"); - - ui -> cert_server -> value("None"); - ui -> cert_port -> value(0); - - ui -> cert_authcode -> value(""); - ui ->cert_authcode->deactivate(); - ui ->cert_sign_button->deactivate(); - - buf = ui -> cert_details -> buffer(); - buf -> text(certtext.c_str()); - - ui -> cert_allow -> value(0); - ui -> cert_listen -> value(0); - ui -> cert_connect -> value(0); - - cert_item_ok = false; - return 0; - } - - int status = c -> Status(); - if (!isfriend) - { - status = 0; - } - - ui -> cert_status -> value((get_status_string(status)).c_str()); - - if (isfriend) - { - ui -> cert_status -> value((get_status_string(status)).c_str()); - } - else - { - ui -> cert_status -> value("Neighbour"); - } - - // SET SERVER. - if (!cert_item_ok) - { - ui->cert_server->value(inet_ntoa(c->serveraddr.sin_addr)); - ui ->cert_port->value(ntohs(c->serveraddr.sin_port)); - - /* check if we have signed the certificate */ - if (0 < validateCertificateIsSignedByKey(c->certificate, - sslr -> getOwnCert() -> certificate)) - - { - ui->cert_authcode->value( - getXPGPAuthCode(c->certificate).c_str()); - ui ->cert_authcode->deactivate(); - ui ->cert_sign_button->deactivate(); - } - else - { - ui ->cert_authcode->value(""); - ui ->cert_authcode->activate(); - ui ->cert_sign_button->deactivate(); - } - } - - if (c -> Manual() || (!isfriend)) - ui -> cert_auto -> value(0); - else - ui -> cert_auto -> value(1); - - // Finally Fill in the Text Editor. - certtext = get_cert_info(c); - - // Last Connection - // Server Address - // Status - // Hashes - - buf = ui -> cert_details -> buffer(); - buf -> text(certtext.c_str()); - - - if (status & PERSON_STATUS_ACCEPTED) - ui -> cert_allow -> value(1); - else - ui -> cert_allow -> value(0); - - if (status & PERSON_STATUS_WILL_LISTEN) - ui -> cert_listen -> value(1); - else - ui -> cert_listen -> value(0); - - if (status & PERSON_STATUS_WILL_CONNECT) - ui -> cert_connect -> value(1); - else - ui -> cert_connect -> value(0); - - if (status & PERSON_STATUS_TRUSTED) - { - ui -> cert_trust_person -> value(1); - } - else - { - ui -> cert_trust_person -> value(0); - } - - - cert_item_ok = true; - return 1; -} - - -int fltkserver::cert_update_auth() -{ - - cert *c = cert_get_current(); - if ((c == NULL) || (c->certificate == NULL)) - { - ui -> cert_authcode -> value(""); - ui ->cert_authcode->deactivate(); - ui ->cert_sign_button->deactivate(); - return 0; - } - - std::string inp_code = ui->cert_authcode->value(); - std::string real_code = getXPGPAuthCode(c->certificate); - if (inp_code == real_code) - { - ui ->cert_sign_button->activate(); - } - else - { - ui ->cert_sign_button->deactivate(); - } - return 1; -} - - - - -int fltkserver::update_neighbour_certs() -{ - - // to draw certs, we need to retrieve the list from AutoDiscovery. - if (ad == NULL) - return -1; - - - // once this is true, we do all following redraw steps. - bool certs_mod = false; - int i; - - Fl_Funky_Browser *cb = ui -> cert_neighbour_list; - - - // only do if - //if ((sslr -> CertsChanged()) || (!cert_list_ok)) - if (!cert_neighbour_list_ok) - { - certs_mod = true; - - DisplayData *selected = cb -> getCurrentItem(); - Person *selperson = NULL; - if (selected != NULL) - { - selperson = ((NeighDisItem *) selected) -> getItem(); - std::cerr << "Currently Selected is: "; - std::cerr << selperson -> Name(); - std::cerr << std::endl; - } - else - { - std::cerr << "Nothing Selected"; - std::cerr << std::endl; - } - - std::cerr << "Updating Neighbour List"; - std::cerr << std::endl; - - // if (sslr -> CertsMajorChanged()) // add or remove. - { - // full repopulate. - cb -> clear(); - std::list::iterator it; - std::list &certs = ad -> getDiscovered(); - - std::string emptystr(""); - - selected = NULL; - for(it = certs.begin(), i = 0; - it != certs.end(); it++, i++) - { - cert *c = (*it); - NeighDisItem *cdi = new NeighDisItem(c); - - if (selperson == c) - { - std::cerr << "Matched Selected: "; - std::cerr << c -> Name(); - std::cerr << std::endl; - - selected = cdi; - } - - cb -> addItemSeries(cdi); - } - cb -> ItemSeriesDone(); - } - //else - //{ - // // else just update list. - // cb -> updateList(); - //} - - cb -> selectDD(selected); - cert_neighbour_list_ok = true; - } - - - if ((certs_mod) || (!cert_neighbour_item_ok)) - { - NeighDisItem *pdi = (NeighDisItem *) cb -> getCurrentItem(); - Person *p = NULL; - if (pdi != NULL) - { - p = pdi -> getItem(); - } - // do always - neighbours does it afterwards. - neigh_display((cert *) p); - } - return 1; -} - -int fltkserver::neigh_display(cert *c) -{ - ui -> neigh_signers -> clear(); - if ((c == NULL) || (c->certificate == NULL)) - { - ui -> neigh_name -> value("N/A"); - ui -> neigh_org -> value("N/A"); - ui -> neigh_loc -> value("N/A"); - ui -> neigh_country -> value("N/A"); - ui -> neigh_trust -> value("N/A"); - ui -> neigh_auth_notice -> hide(); - ui -> neigh_authcode -> value(""); - ui -> neigh_authcode ->deactivate(); - ui -> neigh_add_button ->deactivate(); - - cert_neighbour_item_ok = true; - return 0; - } - - /* else we need to populate it properly - * - */ - ui -> neigh_name -> value((get_cert_name(c)).c_str()); - ui -> neigh_org -> value((get_cert_org(c)).c_str()); - ui -> neigh_loc -> value((get_cert_loc(c)).c_str()); - ui -> neigh_country -> value((get_cert_country(c)).c_str()); - - std::list::iterator it; - std::list signers = getXPGPsigners(c->certificate); - for(it = signers.begin(); it != signers.end(); it++) - { - ui -> neigh_signers -> add(it->c_str()); - std::cerr << *it << std::endl; - } - - if (c->trustLvl < TRUST_SIGN_AUTHEN) - { - sslr -> checkAuthCertificate(c); - } - - /* calculate trust level! */ - ui -> neigh_trust -> value((get_trust_string(c)).c_str()); - if (!cert_neighbour_item_ok) - { - /* check if we have signed the certificate */ - if (0 < validateCertificateIsSignedByKey(c->certificate, - sslr -> getOwnCert() -> certificate)) - - { - ui -> neigh_authcode->value( - getXPGPAuthCode(c->certificate).c_str()); - ui -> neigh_authcode->deactivate(); - ui -> neigh_auth_notice -> hide(); - if ((c->Accepted()) || (c == sslr->getOwnCert())) - { - ui -> neigh_add_button->deactivate(); - } - else - { - ui -> neigh_add_button->activate(); /* can add! */ - } - } - else - { - /* only reset auth code if it was inactive */ - if (!ui -> neigh_authcode -> active()) - { - ui -> neigh_authcode -> value(""); - } - if (c->trustLvl < TRUST_SIGN_AUTHEN) - { - /* need auth code to add */ - ui -> neigh_authcode ->activate(); - //ui -> neigh_auth_notice -> show(); - //ui -> neigh_add_button ->deactivate(); - //handled in update_auth. - neigh_update_auth(); - } - else - { - /* can add without auth code */ - ui -> neigh_auth_notice -> hide(); - ui -> neigh_authcode ->activate(); - ui -> neigh_add_button ->activate(); - } - } - } - - - /* TODO: - * 1) signer list - * 2) trust level - */ - - cert_neighbour_item_ok = true; - return 1; -} - - -int fltkserver::neigh_update_auth() -{ - - std::cerr << "fltkserver::neigh_update_auth() called"; - std::cerr << std::endl; - - cert *c = cert_get_current_neighbour(); - if ((c == NULL) || (c->certificate == NULL)) - { - std::cerr << "fltkserver::neigh_update_auth() found NULL"; - std::cerr << std::endl; - - ui -> neigh_authcode -> value(""); - ui -> neigh_authcode->deactivate(); - ui -> neigh_add_button->deactivate(); - ui -> neigh_auth_notice -> hide(); - return 0; - } - - std::string inp_code = ui->neigh_authcode->value(); - std::string real_code = getXPGPAuthCode(c->certificate); - if (inp_code == real_code) - { - std::cerr << "fltkserver::neigh_update_auth() ANS!"; - std::cerr << std::endl; - ui -> neigh_auth_notice -> hide(); - ui ->neigh_add_button->activate(); - } - else - { - std::cerr << "fltkserver::neigh_update_auth() NC"; - std::cerr << std::endl; - ui -> neigh_auth_notice -> show(); - ui -> neigh_add_button->deactivate(); - } - return 1; -} - -int fltkserver::update_msgs() -{ - if (server == NULL) - return -1; - - // draw the Messages. - - Fl_Funky_Browser *mb = ui -> msg_list; - bool msg_changed = false; - std::list::iterator mit; - - DisplayData *selected = mb -> getSelected(); - MsgItem *selitem; - if (selected != NULL) - { - selitem = ((MsgDisItem *) selected) -> getItem(); - } - - if ((server -> msgChanged.Changed(0)) || (!msg_list_ok)) - { - if (server->msgMajorChanged.Changed(0)) - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "fltkserver::update_msgs() (server->searchMajorChanged.Changed(0))"); - - std::list &msgs = server -> getMsgList(); - mb -> clear(); - for(mit = msgs.begin(); mit != msgs.end(); mit++) - { - MsgDisItem *mdi = new MsgDisItem(*mit); - mb -> addItemSeries(mdi); - } - } - else - { - std::list msgs = server -> getNewMsgs(); - for(mit = msgs.begin(); mit != msgs.end(); mit++) - { - MsgDisItem *mdi = new MsgDisItem(*mit); - mb -> addItemSeries(mdi); - } - } - - mb -> ItemSeriesDone(); - mb -> selectDD(selected); - msg_list_ok = true; - msg_changed = true; - } - - if ((msg_changed) || (!msg_item_ok)) - { - Fl_Text_Buffer *buf = ui -> msg_details -> buffer(); - - MsgDisItem *mdi = (MsgDisItem *) mb -> getCurrentItem(); - MsgItem *mi = NULL; - - if (mdi != NULL) - { - mi = mdi -> getItem(); - } - if (mi != NULL) - { - // beautify the message. - std::string msgtext; - msgtext += "From:"; - int width = 60; - int i; - - if (mi -> p != NULL) - { - msgtext += (mi -> p) -> Name(); - } - else - { - msgtext += "Unknown"; - } - msgtext += " Date: N/A\n"; - - msgtext += "Recommendation:"; - msgtext += mi -> recommendname; - msgtext += "\n"; - - msgtext += "__Message"; - - for(i = 9; i < width - 1; i++) - { - msgtext += "_"; - } - msgtext += "\n\n"; - - // draw Message Details. - msgtext += mi -> msg; - - // set the buffer - buf -> text(msgtext.c_str()); - } - else - { - buf -> text("Select Message for Details!"); - } - msg_item_ok = true; - } - - if (!msg_dialog_ok) - { - // display the recommendation. - PQFileItem *fi = get_recommend(); - if (fi == NULL) - { - ui -> msg_recommend -> value(""); - } - else - { - ui -> msg_recommend -> value((fi -> name).c_str()); - } - msg_dialog_ok = true; - } - - // at the end here, we handle chats. - if (server -> chatChanged.Changed(0)) - { - // get the items from the list. - std::list clist = server -> getChatQueue(); - std::list::iterator it; - for(it = clist.begin(); it != clist.end(); it++) - { - if ((*it) -> p) - { - chatmsg((*it) -> msg, (*it) -> p -> Name()); - } - else - { - /* ignore (from loopback device!) */ - } - - delete (*it); - } - } - return 1; -} - -bool isFileTransferItem(PQItem *item) -{ - if ((item -> type == PQI_ITEM_TYPE_FILEITEM) && - (item -> subtype == PQI_FI_SUBTYPE_TRANSFER)) - return true; - return false; -} - - -int fltkserver::update_transfer() -{ - /* only update this irregularly */ - if (transfer_ok) - return 0; - - FileTransferItem *fti; - std::list::iterator it, it_in; - std::list trans_in = server -> getTransfers(); - - Fl_Funky_Browser *tb = ui -> transfer_downloads; - bool transfer_changed = false; - - for(it_in = trans_in.begin(); it_in != trans_in.end(); it_in = trans_in.erase(it_in)) - { - fti = (*it_in); - - std::ostringstream out; - - out << "fltkserver::update_transfer() Received Info: " << fti -> name; - out << std::endl; - - // update local list. - for(it = transfers.begin(); (fti != NULL) && - (it != transfers.end()); it++) - { - out << "fltkserver::update_transfer() Checking Against: " << (*it) -> name; - - if ((fti -> sid == (*it) -> sid) && - (fti -> name == (*it) -> name)) - { - // then the same update... - out << " Match!: incoming crate: " << fti->crate; - (*it) -> copy(fti); - delete fti; - fti = NULL; - } - - out << std::endl; - } - if (fti != NULL) - { - out << "fltkserver::update_transfer() Adding: " << fti -> name; - transfers.push_back(fti); - transfer_ok = false; - } - - // but still trigger details redraw. - transfer_changed = true; - - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - } - - if (!transfer_ok) - { - int inum = tb -> value(); - tb -> clear(); - - for(it = transfers.begin(); (it != transfers.end()); it++) - { - FTDisItem *fdi = new FTDisItem(*it); - tb -> addItemSeries(fdi); - } - - tb -> ItemSeriesDone(); - tb -> value(inum); - transfer_ok = true; - transfer_changed = true; - } - else if (transfer_changed) - { - // speedup hack.... - tb -> drawList(); - } - - if ((transfer_changed) || (!transfer_item_ok)) - { - Fl_Text_Buffer *buf = ui -> transfer_overview -> buffer(); - - FTDisItem *fdi = (FTDisItem *) tb -> getCurrentItem(); - FileTransferItem *fti = NULL; - - if (fdi != NULL) - { - fti = fdi -> getItem(); - } - if (fti != NULL) - { - std::string msgtext; - - if (fti -> in) - { - msgtext += "Downloading From: "; - } - else - { - msgtext += "Uploading To: "; - } - - if (fti -> p != NULL) - { - msgtext += (fti -> p) -> Name(); - } - else - { - msgtext += "Unknown"; - } - - - msgtext += "\n"; - msgtext += "File: "; - msgtext += fti -> name; - msgtext += "\n"; - msgtext += "\n"; - msgtext += "Rate: "; - msgtext += fdi -> txt(4); - msgtext += "\n"; - msgtext += "Transferred: "; - msgtext += fdi -> txt(3); - msgtext += "\n"; - - // set the buffer - buf -> text(msgtext.c_str()); - - } - else - { - buf -> text("Select Transfer for Details!"); - } - transfer_item_ok = true; - } - if (!transfer_rates_ok) - { - ui -> rate_total -> value(pqih -> getMaxRate(true)); - ui -> rate_indiv -> value(pqih -> getMaxIndivRate(true)); - transfer_rates_ok = true; - } - - return 1; -} - - -int fltkserver::update_search() -{ - if (server == NULL) - return -1; - - bool search_changed = false; - - Fl_Funky_Browser *sb = ui -> srch_results; - FileDisItem *fdi = NULL; - PQFileItem *result_item = NULL; - - if ((server -> searchChanged.Changed(0)) || (!search_list_ok)) - { - search_changed = true; - update_search_browser(); - search_list_ok = true; - } - if ((search_changed) || (!result_item_ok)) - { - fdi = (FileDisItem *) sb -> getCurrentItem(); - if (fdi != NULL) - { - result_item = fdi -> getItem(); - } - - if (result_item != NULL) - { - // instead of changing the label -> allow the - // activate the buttons. - if (result_item -> flags & PQI_ITEM_FLAG_LOCAL) - { - //ui -> download_button -> label("Recommend"); - ui -> download_button -> deactivate(); - ui -> recommend_button -> activate(); - } - else - { - //ui -> download_button -> label("Download"); - ui -> download_button -> activate(); - ui -> recommend_button -> deactivate(); - } - } - result_item_ok = true; - } - return 1; -} - - -int fltkserver::update_config() -{ - // draw the Messages. - std::list &dirs = server -> getSearchDirectories(); - - std::list::iterator mit; - - Fl_Browser *br = ui -> config_search_dir; - int itemnum = br -> value(); - bool dir_changed = false; - - if (!dir_list_ok) - { - dir_changed = true; - br -> clear(); - - for(mit = dirs.begin(); mit != dirs.end(); mit++) - { - br -> add((*mit).c_str()); - } - - br -> value(itemnum); - dir_list_ok = true; - } - if (!save_dir_ok) - { - ui -> config_save_dir -> value((server->getSaveDir()).c_str()); - save_dir_ok = true; - } - - if (!server_set_ok) - { - cert *own = sslr -> getOwnCert(); - ui -> config_local_addr -> value( - inet_ntoa(own -> localaddr.sin_addr)); - ui -> config_local_port -> value( - ntohs(own -> localaddr.sin_port)); - - ui -> config_firewall -> value(own -> Firewalled()); - ui -> config_forward -> value(own -> Forwarded()); - - if (own -> Firewalled()) - { - if (own -> Forwarded()) - { - ui -> config_server_addr -> value( - inet_ntoa(own -> serveraddr.sin_addr)); - ui -> config_server_port -> value( - ntohs(own -> serveraddr.sin_port)); - ui -> config_server_addr -> readonly(0); - //ui -> config_server_port -> readonly(0); - } - else - { - ui -> config_server_addr -> value("0.0.0.0"); - ui -> config_server_port -> value(0); - ui -> config_server_addr -> readonly(1); - //ui -> config_server_port -> readonly(1); - } - } - else - { - ui -> config_server_addr -> value( - inet_ntoa(own -> localaddr.sin_addr)); - ui -> config_server_port -> value( - ntohs(own -> localaddr.sin_port)); - ui -> config_server_addr -> readonly(1); - //ui -> config_server_port -> readonly(1); - } - - server_set_ok = true; - } - - return 1; -} - -/********************** PQI SSL INTERFACE ************************/ -int fltkserver::setuppqissl(filedexserver *fd, pqipersongrp *ph, sslroot *r, UserInterface *u) -{ - server = fd; - pqih = ph; - sslr = r; - ui = u; - - return 1; -} - -int fltkserver::search_new() -{ - // read text from new_search. - // send to server. - // clear search terms. - // - int i; - std::list terms; - std::list::iterator it; - - const char *termlist = ui -> new_search -> value(); - int num_str_len = strlen(termlist) + 2; - - char numstr[num_str_len]; - for(i = 0; i < (signed) strlen(termlist); i++) - { - numstr[i] = termlist[i]; - } - for(;i < num_str_len; i++) - { - numstr[i] = '\0'; - } - - std::ostringstream out; - out << "Read in:" << numstr << std::endl; - - // now break it into terms. - int sword = 0; - for(i = 0; (i < num_str_len - 1) && (numstr[i] != '\0'); i++) - { - if (isspace(numstr[i])) - { - numstr[i] = '\0'; - if (i - sword > 0) - { - terms.push_back(std::string(&(numstr[sword]))); - out << "Found Search Term:" << &(numstr[sword]); - out << std::endl; - } - sword = i+1; - } - } - // do the final term. - if (i - sword > 0) - { - terms.push_back(std::string(&(numstr[sword]))); - out << "Found Search Term:" << &(numstr[sword]); - out << std::endl; - } - - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - - server -> doSearch(terms); - return 1; -} - -int fltkserver::search_remove() -{ - Fl_Funky_Browser *sb = ui -> srch_results; - FileDisItem *fdi = NULL; - SearchItem *sitem = NULL; - fdi = (FileDisItem *) sb -> getCurrentItem(); - if (fdi != NULL) - { - sitem = fdi -> getSearchItem(); - } - - if (sitem != NULL) - { - server -> removeSearchResults(sitem); - search_list_ok = false; - // update straight away - so no possibility of bad data. - update_search(); - return 1; - } - return 0; -} - - -/***** CERT COMMANDS *****/ - -/* Transfer from Neighbour to Cert list */ -int fltkserver::cert_add_neighbour() -{ - /* get the current neighbour */ - cert *c = cert_get_current_neighbour(); - - /* check auth code */ - if ((c == NULL) || (c->certificate == NULL)) - { - std::cerr << "fltkserver::cert_add_neighbour() no cert"; - std::cerr << std::endl; - return 1; - } - - if (c == sslr -> getOwnCert()) - { - std::cerr << "fltkserver::cert_add_neighbour() Own Cert"; - std::cerr << std::endl; - return 1; - } - - std::string inp_code = ui->neigh_authcode->value(); - std::string real_code = getXPGPAuthCode(c->certificate); - bool validAuthCode = (inp_code == real_code); - - if (validAuthCode) - { - std::cerr << "fltkserver::cert_add_neighbour() Valid Auth Code"; - std::cerr << std::endl; - } - else - { - std::cerr << "fltkserver::cert_add_neighbour() No Auth Code"; - std::cerr << std::endl; - } - - /* if correct -> sign */ - if (validAuthCode) - { - if (0 < validateCertificateIsSignedByKey(c->certificate, - sslr -> getOwnCert() -> certificate)) - { - std::cerr << "fltkserver::cert_add_neighbour() Signed Already"; - std::cerr << std::endl; - } - else - { - /* if not signed already */ - std::cerr << "fltkserver::cert_add_neighbour() Signing Cert"; - std::cerr << std::endl; - - /* sign certificate */ - sslr -> signCertificate(c); - } - } - - /* check authentication */ - sslr -> checkAuthCertificate(c); - if (c->trustLvl < TRUST_SIGN_AUTHEN) - { - /* do nothing */ - std::cerr << "fltkserver::cert_add_neighbour() Not Authed"; - std::cerr << std::endl; - std::cerr << "fltkserver::cert_add_neighbour() Do Nothing"; - std::cerr << std::endl; - } - else - { - - - std::cerr << "fltkserver::cert_add_neighbour() Adding Cert"; - std::cerr << std::endl; - - /* add */ - sslr -> addUntrustedCertificate(c); - - - std::cerr << "fltkserver::cert_add_neighbour() Auto Connecting"; - std::cerr << std::endl; - /* auto connect */ - pqih -> cert_auto(c, true); - - // tell to redraw. - cert_neighbour_list_ok = false; - cert_neighbour_item_ok = false; - - cert_list_ok = false; - cert_item_ok = false; - } - return 1; -} - - -int fltkserver::cert_allow_current() -{ - cert *c = cert_get_current(); - - if ((c == NULL) || (c == sslr -> getOwnCert())) - { - return -1; - } - pqih -> cert_accept(c); - return 1; -} - -int fltkserver::cert_deny_current() -{ - cert *c = cert_get_current(); - - if ((c == NULL) || (c == sslr -> getOwnCert())) - { - return -1; - } - pqih -> cert_deny(c); - return 1; -} - -int fltkserver::cert_listen_current() -{ - cert *c = cert_get_current(); - - if ((c == NULL) || (c == sslr -> getOwnCert())) - { - return -1; - } - - if (c -> WillListen()) - { - c -> WillListen(false); - } - else - { - c -> WillListen(true); - } - return 1; -} - -int fltkserver::cert_connect_current() -{ - cert *c = cert_get_current(); - - if ((c == NULL) || (c == sslr -> getOwnCert())) - { - return -1; - } - if (c -> WillConnect()) - { - c -> WillConnect(false); - } - else - { - c -> WillConnect(true); - } - return 1; -} - - -int fltkserver::cert_tag_current() -{ - cert *c = cert_get_current(); - // can change our tag. - if (c == NULL) - { - return -1; - } - //c -> Name(std::string(ui -> cert_newtag -> value())); - return 1; -} - -int fltkserver::cert_check_auto() -{ - std::ostringstream out; - out << "fltkserver::cert_check_auto()"; - cert *c = cert_get_current(); - // don't check own here, as we want to change it back - // if checked. - if (c == NULL) - { - out << "NULL cert!" << std::endl; - return -1; - } - - Fl_Funky_Browser *cb = ui -> cert_list; - bool ac = ((bool) cb -> getCheckState()); - if (c -> Manual() == ac) // ie mean different things. - { - out << " fltkserver::cert_check_auto() Changing State! ("; - out << cb -> value(); - out << ") cert -> Manual():" << c -> Manual(); - out << " Check Box: " << ac << std::endl; - out << " Toggling Auto to: " << ac << std::endl; - //cb -> toggleCheckBox(cb -> value()); - - if ((c != sslr -> getOwnCert()) && - (c->trustLvl >= TRUST_SIGN_AUTHEN)) - { - pqih -> cert_auto(c, ac); - } - else - { - // toggle to off. - cb -> toggleCheckBox(cb->value()); - } - } - out << " fltkserver::cert_check_auto() Final State("; - out << cb -> value(); - out << ") cert -> Manual():" << c -> Manual(); - out << " Check Box: " << cb -> getCheckState() << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - return 1; -} - -int fltkserver::cert_toggle_auto() -{ - std::ostringstream out; - out << "fltkserver::cert_toggle_auto()"; - cert *c = cert_get_current(); - if ((c == NULL) || (c == sslr -> getOwnCert())) - { - out << "NULL cert!" << std::endl; - return -1; - } - - Fl_Funky_Browser *cb = ui -> cert_list; - bool ac = ((bool) cb -> getCheckState()); - out << " Toggling Auto:" << ac << " to " << !ac << std::endl; - - cb -> toggleCheckBox(cb -> value()); - pqih -> cert_auto(c, !ac); - - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - return 1; -} - - - -static const std::string gui_nb = "GUI_NB"; -static const std::string gui_cb = "GUI_CB"; -static const std::string gui_srb = "GUI_SRB"; -static const std::string gui_mb = "GUI_MB"; -static const std::string gui_ftb = "GUI_FTB"; -static const std::string gui_chab = "GUI_CHAB"; -static const std::string gui_chfb = "GUI_CHFB"; - -static const std::string gui_nb_default = "Acpt (0:60:0)\tTrust (1:70:0)\tLast_Seen (2:80:0)\tName (3:150:0)"; - -static const std::string gui_cb_default = "Person (1:110:0)\tStatus (0:120:0)\tAuto_Connect (2:150:0)\tTrust_Lvl (3:120:0)\tPeer_Address (4:150:0)"; - -static const std::string gui_srb_default = "Source (1:100:0)\tKeyword (0:110:1)\tFilename (2:340:0)\tSize (3:100:0)\tN/A (4:100:0)"; - -static const std::string gui_mb_default = "Source (0:100:1)\tMessage (2:150:0)\tDate (1:100:0)\tRecommendation (3:250:0)\tSize (4:100:0)"; - -static const std::string gui_ftb_default = "Source (0:110:0)\tStatus (1:120:0)\tFilename (2:250:0)\tCompleted (3:150:0)\tRate (4:100:0)"; - -// Channel Available and File browsers. -static const std::string gui_chab_default = "Mode (0:85:0)\tRank (1:80:0)\tName (2:250:0)\t#Msgs (3:90:0)\tHash (4:200:0)"; -static const std::string gui_chfb_default = "Date (0:80:0)\tMsg (1:360:0)\t#Files (2:80:0)\tSize (3:85:0)\tHash (4:200:0)"; - - -int fltkserver::cert_save_config() -{ - if (sslr == NULL) - return -1; - - // First update the gui config. - Fl_Funky_Browser *fb = ui -> cert_list; - sslr -> setSetting(gui_cb, fb -> setup()); - - fb = ui -> cert_neighbour_list; - sslr -> setSetting(gui_nb, fb -> setup()); - - fb = ui -> srch_results; - sslr -> setSetting(gui_srb, fb -> setup()); - - fb = ui -> msg_list; - sslr -> setSetting(gui_mb, fb -> setup()); - - fb = ui -> transfer_downloads; - sslr -> setSetting(gui_ftb, fb -> setup()); - - // save channel setting. - fb = ui -> channel_list; - sslr -> setSetting(gui_chab, fb -> setup()); - fb = ui -> channel_file_list; - sslr -> setSetting(gui_chfb, fb -> setup()); - - // also call save all the other parts. - server -> save_config(); - ad -> save_configuration(); - pqih -> save_config(); - - sslr -> saveCertificates(); - return 1; -} - -int fltkserver::cert_load_gui_config() -{ - if (sslr == NULL) - return -1; - - std::string empty(""); - std::string tmp(""); - - // First update the gui config. - Fl_Funky_Browser *fb = ui -> cert_list; - if (empty != (tmp = sslr -> getSetting(gui_cb))) - { - fb -> setup(tmp); - } - else - { - fb -> setup(gui_cb_default); - } - - fb = ui -> cert_neighbour_list; - if (empty != (tmp = sslr -> getSetting(gui_nb))) - { - //fb -> setup(tmp); - fb -> setup(gui_nb_default); - } - else - { - fb -> setup(gui_nb_default); - } - - fb = ui -> srch_results; - if (empty != (tmp = sslr -> getSetting(gui_srb))) - { - fb -> setup(tmp); - } - else - { - fb -> setup(gui_srb_default); - } - - fb = ui -> msg_list; - if (empty != (tmp = sslr -> getSetting(gui_mb))) - { - fb -> setup(tmp); - } - else - { - fb -> setup(gui_mb_default); - } - - fb = ui -> transfer_downloads; - if (empty != (tmp = sslr -> getSetting(gui_ftb))) - { - fb -> setup(tmp); - } - else - { - fb -> setup(gui_ftb_default); - } - - fb = ui -> channel_list; - if (empty != (tmp = sslr -> getSetting(gui_chab))) - { - fb -> setup(tmp); - } - else - { - fb -> setup(gui_chab_default); - } - - fb = ui -> channel_file_list; - if (empty != (tmp = sslr -> getSetting(gui_chfb))) - { - fb -> setup(tmp); - } - else - { - fb -> setup(gui_chfb_default); - } - - // these are done externally... - //pqih -> load_config(); - //server -> load_config(); - //ad -> load_configuration(); - return 1; -} - - -cert *fltkserver::cert_get_current() -{ - if (sslr == NULL) - return NULL; - - Fl_Funky_Browser *cb = ui -> cert_list; - PersonDisItem *pdi = (PersonDisItem *) cb -> getCurrentItem(); - Person *p = NULL; - cert *c = NULL; - if (pdi != NULL) - { - - p = pdi -> getItem(); - } - // dynamic to be save - shouldn't be needed. - c = dynamic_cast(p); - return c; -} - -cert *fltkserver::cert_get_current_neighbour() -{ - Fl_Funky_Browser *cb = ui -> cert_neighbour_list; - PersonDisItem *pdi = (PersonDisItem *) cb -> getCurrentItem(); - Person *p = NULL; - cert *c = NULL; - if (pdi != NULL) - { - - p = pdi -> getItem(); - } - // dynamic to be save - shouldn't be needed. - c = dynamic_cast(p); - return c; -} - -int fltkserver::cert_remove_current() -{ - cert * c = cert_get_current(); - if (c != NULL) - { - if (c->Accepted()) - { - std::ostringstream out; - out << "Please Deactivate Person"; - out << " (by unticking the box) "; - out << std::endl; - out << "\tBefore attempting to remove them"; - alertmsg(0, 1, out.str(), ""); - } - return sslr -> removeCertificate(c); - } - return -1; -} - -int fltkserver::cert_save_servaddr() -{ - // read inet + port address from gui. - - struct sockaddr_in addr; - - // check if valid. - cert *c = cert_get_current(); - if ((c == NULL) || (c == sslr -> getOwnCert())) - { - pqioutput(PQL_ALERT, fltksrvrzone, "NULL/Own cert!"); - return -1; - } - - -/********************************** WINDOWS/UNIX SPECIFIC PART *******************/ -#ifndef WINDOWS_SYS - if (0 != inet_aton(ui -> cert_server -> value(), &(addr.sin_addr))) -#else - addr.sin_addr.s_addr = inet_addr(ui -> cert_server -> value()); - if (1) -#endif -/********************************** WINDOWS/UNIX SPECIFIC PART *******************/ - { - // get the server address. - c -> serveraddr.sin_addr = addr.sin_addr; - c -> serveraddr.sin_port = htons((short) ui -> cert_port -> value()); - return 1; - } - else - { - // invalid ... reset the text to indicate. - ui -> cert_server -> value("Invalid Address"); - return 0; - } -} - -int fltkserver::cert_saveaddr_connect() -{ - if (0 < cert_save_servaddr()) - { - cert *c = cert_get_current(); - c -> nc_timestamp = 0; - // set Firewall to off -> so we - // will definitely have connect attempt. - c -> Firewalled(false); - - c -> WillConnect(true); - return 1; - } - return 0; -} - - -int fltkserver::msg_channel_select() -{ - return 1; -} - - - -int fltkserver::msg_reply() -{ - return 1; -} - - -int fltkserver::msg_remove() -{ - Fl_Funky_Browser *mb = ui -> msg_list; - MsgDisItem *mdi = NULL; - MsgItem *mitem = NULL; - mdi = (MsgDisItem *) mb -> getCurrentItem(); - if (mdi != NULL) - { - mitem = mdi -> getItem(); - } - - if (mitem != NULL) - { - server -> removeMsgItem(mitem); - msg_list_ok = false; - msg_item_ok = false; - msg_dialog_ok = false; - - update_msgs(); - return 1; - } - return 0; -} - - -int fltkserver::transfer_select() -{ - return 1; -} - - -int fltkserver::transfer_cancel() -{ - PQFileItem *cancelled; - - /* get the current item */ - Fl_Funky_Browser *tfb = ui -> transfer_downloads; - FTDisItem *tfdi = NULL; - - tfdi = (FTDisItem *) tfb -> getCurrentItem(); - if (tfdi != NULL) - { - cancelled = tfdi -> getItem(); - } - - if (cancelled == NULL) - { - return 0; - } - - server -> cancelTransfer(cancelled -> clone()); - return 1; -} - -// just clear the list - it'll be repopulated. -int fltkserver::transfer_clear() -{ - std::list::iterator it; - for(it = transfers.begin(); (it != transfers.end());) - { - delete (*it); - it = transfers.erase(it); - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "fltkserver::transfer_clear() Deleting FT Info!"); - } - /* now tell server to do the same */ - server -> clear_old_transfers(); - transfer_ok = false; - return 1; -} - - -int fltkserver::transfer_rates() -{ - pqih -> setMaxRate(true, ui -> rate_total -> value()); - pqih -> setMaxRate(false, ui -> rate_total -> value()); - pqih -> setMaxIndivRate(true, ui -> rate_indiv -> value()); - pqih -> setMaxIndivRate(false, ui -> rate_indiv -> value()); - return 1; -} - -int fltkserver::set_recommend(PQFileItem *rec) -{ - msg_dialog_ok = false; - if (rec == NULL) - { - recommend = NULL; - return 1; - } - if (recommend != NULL) - { - delete recommend; - } - recommend = (PQFileItem *) rec -> clone(); - return 1; -} - -PQFileItem *fltkserver::get_recommend() -{ - return recommend; -} - -int fltkserver::search_download() -{ - if (server == NULL) - return -1; - - Fl_Funky_Browser *sb = ui -> srch_results; - FileDisItem *fdi = NULL; - PQFileItem *result_item = NULL; - - fdi = (FileDisItem *) sb -> getCurrentItem(); - if (fdi != NULL) - { - result_item = fdi -> getItem(); - } - - if (result_item == NULL) - { - return 0; - } - - // check if remote -> then download. - if (result_item -> flags & PQI_ITEM_FLAG_LOCAL) - { - return -1; - } - - // otherwise ... can get search item. - server -> getSearchFile(result_item); - return 1; -} - - -int fltkserver::search_recommend() -{ - if (server == NULL) - return -1; - - Fl_Funky_Browser *sb = ui -> srch_results; - FileDisItem *fdi = NULL; - PQFileItem *result_item = NULL; - - fdi = (FileDisItem *) sb -> getCurrentItem(); - if (fdi != NULL) - { - result_item = fdi -> getItem(); - } - - if (result_item == NULL) - { - return 0; - } - - // check if remote -> then download. - if (result_item -> flags & PQI_ITEM_FLAG_LOCAL) - { - // Setup the recommend message.... - std::ostringstream out; - out << "fltkserver::search_download() Recommending: "; - out << result_item -> name << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - - // setup recommend gui. - set_recommend(result_item); - ui -> msg_dialog -> show(); - return 2; - } - return -1; -} - -int fltkserver::msg_send() -{ - if (server == NULL) - { - return -1; - } - - // get msg_text from dialog. - Fl_Text_Buffer *buf = ui -> msg_text -> buffer(); - std::string msg = buf -> text(); - - server -> sendRecommend(get_recommend(), msg); - - // clear the buffer, and the recommend. - buf -> text(""); - set_recommend(NULL); - - return 1; -} - - -int fltkserver::download_recommend() -{ - if (server == NULL) - return -1; - - Fl_Funky_Browser *mb = ui -> msg_list; - MsgDisItem *mdi = NULL; - MsgItem *msg_item = NULL; - - mdi = (MsgDisItem *) mb -> getCurrentItem(); - if (mdi != NULL) - { - msg_item = mdi -> getItem(); - } - if (msg_item == NULL) - { - return 0; - } - - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "fltkserver::download_recommend() passed ET -> getting file"); - return server -> getSearchFile(msg_item); -} - - -/* The new search regime.... for data handling.... */ - -int fltkserver::update_search_browser() -{ - if (server == NULL) - return -1; - - Fl_Funky_Browser *sb = ui -> srch_results; - - std::map >::iterator it; - std::list::iterator fit; - - DisplayData *selected = sb -> getSelected(); - PQFileItem *selitem; - if (selected != NULL) - { - selitem = ((FileDisItem *) selected) -> getItem(); - } - - if ((server->searchMajorChanged.Changed(0)) || (1 != sb->checkSort())) - { - std::map > - &results = server -> getResults(); - sb -> clear(); - for(it = results.begin(); it != results.end(); it++) - { - for(fit = (it -> second).begin(); - fit != (it -> second).end(); fit++) - { - FileDisItem *fdi = new FileDisItem(*fit, it -> first); - sb -> addItemSeries(fdi); - } - } - } - else - { - // else take it easy. - // get new item - not reference - std::map > - new_results = server -> getNewResults(); - for(it = new_results.begin(); it != new_results.end(); it++) - { - for(fit = (it -> second).begin(); - fit != (it -> second).end(); fit++) - { - FileDisItem *fdi = new FileDisItem(*fit, it -> first); - sb -> addItemSeries(fdi); - } - } - } - - sb -> ItemSeriesDone(); - sb -> selectDD(selected); - return 1; -} - - - -std::string fltkserver::getHomePath() -{ - std::string home; -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ -#ifndef WINDOWS_SYS /* UNIX */ - - home = getenv("HOME"); - -#else /* Windows */ - - std::ostringstream out; - char *h2 = getenv("HOMEDRIVE"); - out << "fltkpqi::basedir() -> $HOMEDRIVE = "; - out << h2 << std::endl; - char *h3 = getenv("HOMEPATH"); - out << "fltkpqi::basedir() -> $HOMEPATH = "; - out << h3 << std::endl; - - if (h2 == NULL) - { - // Might be Win95/98 - // generate default. - home = "C:\\Retro"; - } - else - { - home = h2; - home += h3; - home += "\\Desktop"; - } - - out << "fltkserver::getHomePath() -> " << home << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - - // convert to FLTK desired format. - home = make_path_unix(home); -#endif -/******************************** WINDOWS/UNIX SPECIFIC PART ******************/ - return home; -} - - -int fltkserver::file_select(int type) -{ - std::string home = getHomePath(); - // save the type then setup the selector. - fselect_type = type; - ui -> file_chooser -> directory(home.c_str()); - - switch(type) - { - case FILE_CHOOSER_IMPORT: - ui -> file_chooser -> type(Fl_File_Chooser::SINGLE); - ui -> file_chooser -> filter("Certificate Files (*.{pem,pqi})"); - //ui -> file_chooser -> title("Import Certificate"); - break; - case FILE_CHOOSER_EXPORT: - ui -> file_chooser -> type(Fl_File_Chooser::CREATE); - ui -> file_chooser -> filter("Certificate Files (*.{pem,pqi})"); - //ui -> file_chooser -> title("Export Certificate"); - break; - case FILE_CHOOSER_DIR: - ui -> file_chooser -> type(Fl_File_Chooser::DIRECTORY); - ui -> file_chooser -> filter("Directories (*.*)"); - //ui -> file_chooser -> title("Add Share Directory"); - break; - case FILE_CHOOSER_SAVEDIR: - ui -> file_chooser -> type(Fl_File_Chooser::DIRECTORY); - ui -> file_chooser -> filter("Directories (*.*)"); - //ui -> file_chooser -> title("Select Save Directory"); - break; - default: - break; - } - return 1; -} - -int fltkserver::file_updateName() -{ - return 1; -} - -int fltkserver::file_completeIO() -{ - // take filename from line. - std::string nullhash(""); // empty hash - as signature not correct. - - if (NULL == ui -> file_chooser -> value()) - { - pqioutput(PQL_ALERT, fltksrvrzone, - "filtserver::file_completeIO() NULL file selected!"); - return 1; - } - - std::string fileio_name = std::string(ui -> file_chooser -> value()); - - std::ostringstream out; - out << "fltkserver::file_completeIO() supposed to "; - - cert *nc, *c; - - switch(fselect_type) - { - case FILE_CHOOSER_IMPORT: - - out << " IMPORT " << fileio_name << std::endl; - // The load makes sure it is unique. - nc = sslr -> loadcertificate(fileio_name.c_str(), nullhash); - if (nc == NULL) - { - out << "File Import (" << fileio_name; - out << ") Failed!" << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - return -1; - } - else if (0 > sslr -> addCollectedCertificate(nc)) - { - out << "Imported Certificate....but no"; - out << " need for addition - As it exists!"; - out << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - return 0; - } - - /* ensure it gets to p3disc */ - if (ad) - { - /* tick the p3disc to ensure the new one gets into - * the list before the next update. - */ - ad -> distillData(); - //ad->collectCerts(); - cert_neighbour_list_ok = false; - } - - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - return 1; - break; - - case FILE_CHOOSER_EXPORT: - - /* before we save the file we need to ensure that - * it has the correct extension - */ - - ensureExtension(fileio_name, "pqi"); - - out << " EXPORT to " << fileio_name << std::endl; - c = cert_get_current(); - if (c == NULL) - { - c = cert_get_current_neighbour(); - } - - if (c == NULL) - { - out << "File Export (" << fileio_name; - out << ") Failed - Select A Cert!" << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - return -1; - } - if (c -> certificate == NULL) - { - out << "File Export (" << fileio_name; - out << ") Failed - X509 == NULL!" << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - return -1; - } - - - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - return sslr -> savecertificate(c, fileio_name.c_str()); - break; - - case FILE_CHOOSER_DIR: - // add the directory to the servers list. - ui -> file_chooser -> type(Fl_File_Chooser::DIRECTORY); - server -> addSearchDirectory(fileio_name.c_str()); - dir_list_ok = false; - - break; - case FILE_CHOOSER_SAVEDIR: - // change the save directory. - save_dir_ok = false; - ui -> file_chooser -> type(Fl_File_Chooser::DIRECTORY); - server -> setSaveDir(fileio_name.c_str()); - break; - default: - break; - } - - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - - return 1; - if (fileio_import) - { - } - else // export - { - } - return 0; -} - -int fltkserver::config_remove_dir() -{ - int i = ui -> config_search_dir -> value(); - if (i > 0) - { - server -> removeSearchDirectory( - ui -> config_search_dir -> text(i)); - dir_list_ok = false; - } - return 1; -} - - -// this is call if the ticks are changed. -int fltkserver::config_server_update() -{ - cert *own = sslr -> getOwnCert(); - - // can forward on if firewalled. - if (ui -> config_forward -> value()) - ui -> config_firewall -> value(1); - - if (ui -> config_firewall -> value()) - { - if (ui -> config_forward -> value()) - { - ui -> config_server_addr -> value( - inet_ntoa(own -> serveraddr.sin_addr)); - ui -> config_server_port -> value( - ntohs(own -> serveraddr.sin_port)); - ui -> config_server_addr -> readonly(0); - //ui -> config_server_port -> readonly(0); - } - else - { - ui -> config_server_addr -> value("0.0.0.0"); - ui -> config_server_port -> value(0); - ui -> config_server_addr -> readonly(1); - //ui -> config_server_port -> readonly(1); - } - } - else - { - ui -> config_server_addr -> value( - inet_ntoa(own -> localaddr.sin_addr)); - ui -> config_server_port -> value( - ntohs(own -> localaddr.sin_port)); - ui -> config_server_addr -> readonly(1); - //ui -> config_server_port -> readonly(1); - } - return 1; -} - -int fltkserver::config_server_change() -{ - // check which settings have changed. - // if localaddress is different. then restart server. - // - // all the other settings just get stored and sent to - // others for their info. - - struct in_addr inaddr_local, inaddr_server; - if (0 == inet_aton(ui -> config_local_addr -> value(), &inaddr_local)) - { - // bad address - reset. - server_set_ok = false; - return -1; - } - - cert *c = sslr -> getOwnCert(); - bool local_changed = false; - - - /* always change the address (checked by sslr->checkNetAddress()) */ - c -> localaddr.sin_addr = inaddr_local; - c -> localaddr.sin_port = htons((short) ui -> config_local_port -> value()); - local_changed = true; - - if ((ui -> config_firewall -> value()) && - (ui -> config_forward -> value())) - { - if (0 != inet_aton(ui -> config_server_addr -> value(), - &inaddr_server)) - { - c -> serveraddr.sin_addr = inaddr_server; - c -> serveraddr.sin_port = htons((short) ui -> config_server_port -> value()); - } - } - - c -> Firewalled(ui -> config_firewall -> value()); - c -> Forwarded(ui -> config_forward -> value()); - - if (local_changed) - { - sslr -> checkNetAddress(); - pqih -> restart_listener(); - sslr -> CertsChanged(); - } - server_set_ok = false; - return 1; -} - -std::string make_path_unix(std::string path) -{ - for(unsigned int i = 0; i < path.length(); i++) - { - if (path[i] == '\\') - path[i] = '/'; - } - return path; -} - - - -int fltkserver::addAlerts(alertBox *m, alertBox *c) -{ - msg = m; - chat = c; - return 1; -} - - -int fltkserver::ownchatmsg(std::string m) -{ - server -> sendChat(m); - return 1; -} - - -int fltkserver::chatmsg(std::string m, std::string source) -{ - chat -> sendMsg(0,2,m, source); - return 1; -} - - -int fltkserver::alertmsg(int type, int sev, std::string m, std::string src) -{ - msg -> sendMsg(type, sev,m, src); - return 1; -} - -int fltkserver::update_dirlist() -{ - // get the list of certificates. - // get the dirlist. - std::list &dirs = server -> getDirList(); - std::list::iterator dit; - - std::list::iterator it; - std::list &certs = sslr -> getCertList(); - - for(it = certs.begin(); it != certs.end(); it++) - { - cert *c = (*it); - if ((c != NULL) && (c -> Connected())) - { - bool found = false; - for(dit = dirs.begin(); dit != dirs.end(); dit++) - { - if ((*dit) -> p == c) - { - found = true; - } - } - if (!found) - { - // send off searchitem.... - std::ostringstream out; - out << "Generating FileDir Search Item for: " << *it << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - - SearchItem *si = new SearchItem(PQI_SI_SUBTYPE_SEARCH); - si -> datatype = PQI_SI_DATATYPE_DIR; - si -> data = ""; - // set the target, so it don't go to all!. - si -> cid = c -> cid; - si -> p = c; - server -> handleDirectoryRequest(si); - } - } - } - - server -> printDirectoryListings(); - check_dirlist2(); - //check_dirlist(); - return 1; -} - -//int fltkserver::check_dirlist() -//int fltkserver::load_dir(std::string person, std::string dir) -// -int fltkserver::load_dir(std::string person, std::string dir) -{ - // get the list of certificates. - // get the dirlist. - - cert *c = sslr -> findpeercert(person.c_str()); - std::ostringstream out; - out << "fltkserver::load_dir() chk:" << person << std::endl; - if ((c != NULL) && (c -> Connected())) - { - // send off searchitem.... - out << "Generating FileDir Search Item for: " << c -> certificate -> name << std::endl; - SearchItem *si = new SearchItem(PQI_SI_SUBTYPE_SEARCH); - si -> datatype = PQI_SI_DATATYPE_DIR; - si -> data = dir; - si -> cid = c -> cid; - si -> p = c; - server -> handleDirectoryRequest(si); - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - return 1; - } - out << "fltkserver::load_dir() Failed to match request to person: " << person << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - return 1; -} - - -int process_subdir(DirNode * dir, Fl_Item *p); - -int fltkserver::check_dirlist() -{ - // get the list of certificates. - // get the dirlist. - std::list &dirs = server -> getDirList(); - std::list::iterator dit; - - //std::list certs = sslr -> listCertificates(); - //std::list::iterator it; - - // clear browser. - delete_all(0); - - Fl_Item *p = NULL; - - for(dit = dirs.begin(); dit != dirs.end(); dit++) - { - Fl_Item *di = Fl_Person_Item_type.make(p); - if ((*dit)->p) - { - di->name((*dit)->p->Name().c_str()); - // put proper link in. - ((Fl_Person_Item *) di) -> person_hash = - ((cert *) ((*dit)->p)) -> certificate -> name; - } - else - { - di->name("LOCAL"); - ((Fl_Person_Item *) di) -> person_hash = - sslr -> getOwnCert() -> certificate -> name; - } - process_subdir(*dit, di); - } - return 1; -} - -int process_subdir(DirNode * dir, Fl_Item *p) -{ - std::list &files = dir->files; - std::list &dirs = dir->subdirs; - std::list::iterator fit; - std::list::iterator dit; - - { - std::ostringstream out; - out << "process_subdir(" << dir -> name << ")"; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - } - - for(dit = dirs.begin(); dit != dirs.end(); dit++) - { - Fl_Item *di = Fl_Dir_Item_type.make(p); - process_subdir(*dit, di); - di -> name((*dit)->name.c_str()); - } - - for(fit = files.begin(); fit != files.end(); fit++) - { - std::ostringstream out; - out << (*fit)->name; - out << " ---> " << (*fit)->size << " bytes"; - - Fl_Item *fi = Fl_File_Item_type.make(p); - fi -> name(out.str().c_str()); - ((Fl_File_Item *) fi) -> filename = (*fit) -> name; - ((Fl_File_Item *) fi) -> size = (*fit) -> size; - } - return 1; -} - - - -int fltkserver::update_dirs() -{ - if (server == NULL) - return -1; - - // draw the Messages. - - if ((server -> dirListChanged.Changed(0)) || - (server->dirListMajorChanged.Changed(0))) - { - // load lists. - check_dirlist2(); - //check_dirlist(); - } - return 1; -} - -Person *getperson(Fl_Item *p) -{ - while(p && p->parent) - p=p->parent; - Fl_Person_Item *pi; - if ((p) && (NULL != (pi = dynamic_cast(p)))) - { - return getSSLRoot() -> findpeercert(pi -> person_hash.c_str()); - } - return NULL; -} - -int fltkserver::dirlist_download() -{ - std::list itemlist; - - // get the list of certificates. - // get the dirlist. - Fl_Item *it = Fl_Item::first; - for(;it; it = it -> next) - { - if (it -> selected && it -> is_file()) - { - Person *p = getperson(it); - std::ostringstream out; - out << "downloading:" << ((Fl_File_Item *) it) -> filename << std::endl; - - if (p) - { - out << "from :" << p -> Name() << std::endl; - } - else - { - out << "from NULL" << std::endl; - } - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - - PQFileItem *fi = new PQFileItem(); - - fi -> sid = getPQIsearchId(); - fi -> subtype = PQI_FI_SUBTYPE_REQUEST; - fi -> name = ((Fl_File_Item *) it) -> filename; - fi -> size = ((Fl_File_Item *) it) -> size; - fi -> cid = p -> cid; - fi -> p = p; - server -> getSearchFile(fi); - } - } - return 1; -} - -int fltkserver::dirlist_recommend() -{ - std::list itemlist; - - // get the list of certificates. - // get the dirlist. - Fl_Item *it = Fl_Item::first; - for(;it; it = it -> next) - { - if (it -> selected && it -> is_file()) - { - Person *p = getperson(it); - - std::ostringstream out; - out << "recommending(NOT YET!): " << it -> name() << std::endl; - if (p) - { - out << "from :" << p -> Name() << std::endl; - } - else - { - out << "from NULL" << std::endl; - } - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - - //SearchItem *si = new SearchItem(PQI_SI_SUBTYPE_SEARCH); - //si -> datatype = PQI_SI_DATATYPE_DIR; - //si -> data = dir; - //si -> cid = c -> cid; - //server -> handleDirectoryRequest(si); - //return 1; - } - } - return 1; - -} - - -Fl_Item *process_subdir2(DirNode * dir, Fl_Item *p); -int add_person(DirBase *db, Fl_Item *next); -int add_subdir(DirNode *dir, Fl_Item *p, Fl_Item *next); -int add_file(PQFileItem *file, Fl_Item *p, Fl_Item *next); - -/* must iterate through in parallel */ - -int fltkserver::check_dirlist2() -{ - // get the list of certificates. - // get the dirlist. - std::list &dirs = server -> getDirList(); - std::list::iterator dit; - - //Fl_Item *p = NULL; - Fl_Item *c = Fl_Item::first; - bool init = true; // needed to check first item (as items loop) - - /* cannot copy Fl_Item::last, as it can change with item addition! */ - for(dit = dirs.begin(); dit != dirs.end() && (c); dit++) - { - if (init) - init = false; - - Person *prsn = (*dit)->p; - std::string name1; - if (prsn) - name1 = prsn -> Name(); - else - name1 = "LOCAL"; - - std::string name2(c->name()); - - { - std::stringstream out; - out << "Person: " << name1; - out << " vs Item: " << name2 << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - } - - if (name1 != name2) - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, "MISMATCH!"); - // more complete check ... see if its there. - // search through all the next ones.... see if its there. - Fl_Item *c2 = c; - bool found = false; - for(; (c2) && (!found); c2=c2->next) - { - std::ostringstream out; - out << "Iterating through All People... " << c2->name(); - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - - if ((c2->parent == NULL) && - (name1 == std::string(c2->name()))) - { - found = true; - } - } - if (found) - { - // remove current Fl_Item *.... - std::ostringstream out; - out << "Found PERSON LATER - Should Delete Stuff!"; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - - // delete stuff inbetween. c -> before c2. - Fl_Item *c3 = NULL; - for(; c != c2; c = c3) - { - delete_children(c); - c3 = c -> next; - c->remove(); - delete c; - } - - // delete subdir. - // continue. - c = process_subdir2(*dit, c2); - } - else - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, "Should Add PERSON"); - // add person before current item. - // no increment of c. - add_person(*dit, c); /* add before c */ - } - } - else - { - c = process_subdir2(*dit, c); - } - } - if (dit != dirs.end()) - { - /* add in extras */ - std::ostringstream out; - out << "At end of Fl_Items" << std::endl; - out << "Should Add Extra PERSONS" << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - - for(; dit != dirs.end(); dit++) - { - add_person(*dit, NULL); /* add at end! */ - } - } - else if (c) - { - /* should remove any extra files */ - std::ostringstream out; - out << "At end of Persons, but still Fl_Items" << std::endl; - out << "Should Remove an Extra People" << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - - Fl_Item *c2 = NULL; - for(; c; c = c2) - { - delete_children(c); - c2 = c -> next; - c->remove(); - delete c; - } - } - return 1; -} - -Fl_Item *process_subdir2(DirNode * dir, Fl_Item *p) -{ - std::list &files = dir->files; - std::list &dirs = dir->subdirs; - std::list::iterator fit; - std::list::iterator dit; - - { - std::ostringstream out; - out << "process_subdir2(" << dir -> name << ")" << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - } - - Fl_Item *c = p -> next; - - /* cannot copy Fl_Item::last, as it can change with item addition! */ - for(dit = dirs.begin(); dit != dirs.end() && (c); dit++) - { - { - std::ostringstream out; - out << "Directory: " << (*dit)->name; - out << " vs Item: " << c->name(); - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - } - - if ((*dit)->name != std::string(c->name())) - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, "MISMATCH!"); - // more complete check ... see if its there. - // search through all the next ones.... see if its there. - // if we find dir further on.... - // delete Fl_Items.... (obviously deleted from Dirlist) - // else - // add Directory (missing) - bool found = false; - bool child = true; - Fl_Item *c2 = c; - for(; (c2) && (!found) && (child); c2=c2->next) - { - { - std::ostringstream out; - out << "Iterating through Directories... " << c2->name(); - out << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - } - - // check if it's a child. - Fl_Item *p2 = c2->parent; - while((p2 != NULL) && (p2 != p)) - { - p2 = p2 -> parent; - } - - // if no longer children. - if (p2 != p) - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, "End of Children "); - child = false; - } - - if ((c2->parent == p) && - ((*dit)->name == std::string(c2->name()))) - { - found = true; - } - } - if (found) - { - // remove current Fl_Item *.... - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "Found DIR LATER - Should Delete Stuff!"); - // delete stuff inbetween. c -> before c2. - Fl_Item *c3 = NULL; - for(; c != c2; c = c3) - { - delete_children(c); - c3 = c -> next; - c->remove(); - delete c; - } - // continue. - c = process_subdir2(*dit, c2); - } - else - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "Should Add DIR"); - // add subdir.... before c, and processdir. - // no increment of c. - - if (c->parent==p) - { - add_subdir(*dit, p, c); - } - else - { - add_subdir(*dit, p, NULL); - } - } - } - else - { - c = process_subdir2(*dit, c); - } - } - if (dit != dirs.end()) - { - /* add in extras */ - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "At end of Fl_Items, Should Add Extra DIRS"); - for(; dit != dirs.end(); dit++) - { - add_subdir(*dit, p, NULL); - } - } - // if same parent, and not a file.... - else if ((c) && (c->parent == p) && (!dynamic_cast(c))) - { - - /* should remove any extra files */ - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "At end of Dirs, but still some, Should Remove Extra DIRS"); - - Fl_Item *c2 = NULL; - for(; (c) && (c->parent==p) && (!dynamic_cast(c)); c = c2) - { - delete_children(c); - c2 = c -> next; - c->remove(); - delete c; - } - } - - - for(fit = files.begin(); fit != files.end() && (c); fit++) - { - std::ostringstream out; - out << (*fit)->name; - out << " ---> " << (*fit)->size << " bytes"; - - { - std::ostringstream out; - out << "File: " << out.str(); - out << " vs Item: " << c->name() << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - } - - Fl_File_Item *fi = dynamic_cast(c); - if ((fi == NULL) || ((*fit)->name != fi->filename)) - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, "MISMATCH!"); - // more complete check ... see if its there. - - // search through all the next ones.... see if its there. - // if we find dir further on.... - // delete Fl_Items.... (obviously deleted from Dirlist) - // else - // add Directory (missing) - bool found = false; - bool child = true; - Fl_Item *c2 = c; - for(; (c2) && (!found) && (child); c2=c2->next) - { - { - std::ostringstream out; - out << "Iterating through Files... " << c2->name(); - out << std::endl; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - } - - // check if it's a child. - Fl_Item *p2 = c2->parent; - while((p2 != NULL) && (p2 != p)) - { - p2 = p2 -> parent; - } - - // if no longer children. - if (p2 != p) - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, "End of Children "); - child = false; - } - - if ((c2->parent == p) && - ((*fit)->name == std::string(c2->name()))) - { - found = true; - } - } - if (found) - { - // remove current Fl_Item *.... - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "Found File LATER - Should Delete Stuff!"); - - // delete stuff inbetween. c -> before c2. - Fl_Item *c3 = NULL; - for(; c != c2; c = c3) - { - delete_children(c); - c3 = c -> next; - c->remove(); - delete c; - } - // continue. - c = c2 -> next; - } - else - { - // add file before current. - // no increment of c. - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "Should Add FILE"); - if (c->parent==p) - { - add_file(*fit, p, c); - } - else - { - add_file(*fit, p, NULL); - } - } - - } - else - { - // iterate. - c=c->next; - } - } - if (fit != files.end()) - { - /* add in extras */ - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "At end of Fl_Items, Should Add Extra FILES"); - for(; fit != files.end(); fit++) - { - add_file(*fit, p, NULL); - } - } - else if ((c) && (c->parent == p)) - { - /* should remove any extra files */ - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "At end of Files, but still some, Should Remove Extra File"); - - Fl_Item *c2 = NULL; - for(; (c) && (c->parent==p) ; c = c2) - { - delete_children(c); - c2 = c -> next; - c->remove(); - delete c; - } - } - - return c; -} - - - -int add_person(DirBase *db, Fl_Item *next) -{ - Fl_Item *p = NULL; - - Fl_Item *di = NULL; - if (db->p) - { - di = Fl_Person_Item_type.make(p); - { - std::ostringstream out; - out << "add_person() :" << db->p->Name().c_str(); - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - } - - di->name(db->p->Name().c_str()); - // put proper link in. - ((Fl_Person_Item *) di) -> person_hash = - ((cert *) (db->p)) -> certificate -> name; - } - else - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "add_person() : SHOULD ADD LOCAL"); - } - - if ((next) && (di)) - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "add_person() : SHIFTING"); - - di -> remove(); - di -> insert(next); - } - - if (di) - { - process_subdir2(db, di); - } - return 1; -} - -int add_subdir(DirNode *dir, Fl_Item *p, Fl_Item *next) -{ - std::cerr << std::endl; - { - std::ostringstream out; - out << "add_subdir() :" << dir->name; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - } - - /* add subdir with parent p, before next */ - Fl_Item *di = Fl_Dir_Item_type.make(p); - di -> name(dir->name.c_str()); - - if (next) - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "add_subdir() : SHIFTING"); - - /* must move */ - di->remove(); - di->insert(next); - } - - /* then subprocess. */ - process_subdir2(dir, di); - return 1; -} - - -std::string sizeToString(int size); - -int add_file(PQFileItem *file, Fl_Item *p, Fl_Item *next) -{ - { - std::ostringstream out; - out << "add_file() :" << file->name; - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - } - - /* add file with parent p, before next */ - std::ostringstream out; - out << "[ " << sizeToString(file->size) << " ] " << file->name; - //out << " ---> " << file->size << " bytes"; - - Fl_Item *fi = Fl_File_Item_type.make(p); - fi -> name(out.str().c_str()); - ((Fl_File_Item *) fi) -> filename = file -> name; - ((Fl_File_Item *) fi) -> size = file -> size; - - if (next) - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "add_file() SHIFTING:"); - - /* must move */ - fi->remove(); - fi->insert(next); - } - - return 1; -} - - - - - -int fltkserver::cert_sign_current() -{ - /* get the current cert, check that its - * in the allowed group. - */ - - /* ask sslroot to sign certificate - */ - cert *c = cert_get_current(); - - if ((c == NULL) || (c == sslr -> getOwnCert())) - { - return -1; - } - return sslr -> signCertificate(c); -} - -int fltkserver::cert_trust_current_toggle() -{ - /* ensure that they are in the allowed group - */ - - cert *c = cert_get_current(); - if ((c == NULL) || (c == sslr -> getOwnCert())) - { - return -1; - } - return sslr -> trustCertificate(c, !(c -> Trusted())); -} - - -#ifdef PQI_USE_CHANNELS - -int fltkserver::update_channels() -{ - if (server == NULL) - return -1; - - // draw the channels - - Fl_Funky_Browser *chb = ui -> channel_list; - Fl_Funky_Browser *chmb = ui -> channel_file_list; - Fl_Funky_Browser *chfb = ui -> chan_msgdetails_filelist; - - bool channels_changed = false; - bool channel_msgs_changed = false; - - // save data on currently selected. - DisplayData *selChannel = chb -> getCurrentItem(); // getSelected() returns NULL??? why; - channelSign selChanSign; - ChanDisItem *selCDI = NULL; - - if (selChannel) - { - selChanSign = ((ChanDisItem *) selChannel) -> cs; - std::ostringstream out; - out << "fltkserver::update_channels() Currently Selected is:"; - selChanSign.print(out); - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - } - - if ((server -> channelsChanged.Changed(0)) || (!channel_list_ok)) - { - std::list chanlist; - std::list::iterator cit; - - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "fltkserver::update_channels() (server->channelsChanged.Changed(0))"); - -#ifdef PQI_USE_CHANNELS - server->getAvailableChannels(chanlist); -#endif - chb -> clear(); - for(cit = chanlist.begin(); cit != chanlist.end(); ++cit) - { - ChanDisItem *cdi = new ChanDisItem(*cit); - chb -> addItemSeries(cdi); - - std::ostringstream out; - out << "fltkserver::update_channels() Added: "; - cdi->cs.print(out); - - /* check if previously selected channel */ - if ((selChannel) && (selChanSign == cdi -> cs)) - { - selCDI = cdi; - out << " Matches Previous Selection!"; - } - - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, out.str()); - } - - chb -> ItemSeriesDone(); - if (selCDI) /* if channel still exists */ - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, "Selecting Previous Channel"); - chb -> selectDD(selCDI); - } - channel_list_ok = true; - channels_changed = true; - } - - - // save data on currently selected. - DisplayData *selChanMsg = chmb -> getCurrentItem(); - MsgHash selMsgHash; - ChanMsgDisItem *selCMDI = NULL; - - if (selChanMsg) - { - selMsgHash = ((ChanMsgDisItem *) selChanMsg) -> mh; - } - - if ((channels_changed) || (!channel_msg_list_ok)) - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "fltkserver::update_channels() (channel_changed) || (!channel_msg_list_ok)"); - - if (!selCDI) - { - chmb->clear(); - // selCMDI == NULL as well (so empty Msg Display) - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "fltkserver::update_channels() No Channel Selected"); - ui->chan_createmsg_title->value("No Channel Selected!"); - ui->chan_msgdetails_title->value("No Channel Selected!"); - } - else - { - // a channel is selected! - // signature is in selChanSign. - std::list summarylist; - std::list::iterator it; - - /* set the channel names */ - if (selCDI -> mode & 0x040) - { - ui->chan_createmsg_title->value(selCDI->name.c_str()); - } - else - { - ui->chan_createmsg_title->value("Publisher Channel Not Selected!"); - } - ui->chan_msgdetails_title->value(selCDI->name.c_str()); - -#ifdef PQI_USE_CHANNELS - server->getChannelMsgList(selChanSign, summarylist); -#endif - chmb -> clear(); - for(it = summarylist.begin(); it != summarylist.end(); ++it) - { - ChanMsgDisItem *cmdi = new ChanMsgDisItem(*it); - chmb -> addItemSeries(cmdi); - - /* check if previously selected channel */ - if ((selChanMsg) && (selMsgHash == cmdi -> mh)) - { - selCMDI = cmdi; - } - } - - chmb -> ItemSeriesDone(); - if (selCMDI) - { - chmb -> selectDD(selCMDI); - } - } - - channel_msg_list_ok = true; - channel_msgs_changed = true; - } - - - /* Finally do the File List .... but need to do gui first */ - // save data on currently selected. - DisplayData *selChanFile = chfb -> getCurrentItem(); - std::string selName; - int selSize; - ChanFileDisItem *selCFDI = NULL; - - if (selChanFile) - { - selName = ((ChanFileDisItem *) selChanMsg) -> name; - selSize = ((ChanFileDisItem *) selChanMsg) -> size; - } - - if ((channel_msgs_changed) || (!channel_msg_item_ok)) - { - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "fltkserver::update_channels() (channel_changed) || (!channel_msg_item_ok)"); - - if ((!selCMDI) || (!selCDI)) - { - chfb->clear(); - // selCMDI == NULL as well (so empty Msg Display) - pqioutput(PQL_DEBUG_BASIC, fltksrvrzone, - "fltkserver::update_channels() No Msg Selected"); - } - else - { - // a channel is selected! - // signature is in selChanSign. - - channelMsg *cm = NULL; -#ifdef PQI_USE_CHANNELS - cm = server->getChannelMsg(selChanSign,selMsgHash); -#endif - if (!cm) - { - channel_msg_item_ok = true; - chfb -> clear(); - /* should never get here! */ - pqioutput(PQL_DEBUG_ALERT, fltksrvrzone, - "fltkserver::update_channels() Channels not enabled"); - return 1; - } - - // Fill in the details. - - // the msg. - Fl_Text_Buffer *buf = ui -> chan_msgdetails_msg -> buffer(); - buf -> text(cm->msg->msg.c_str()); - - // the files.... - PQChanItem::FileList::const_iterator it; - - chfb -> clear(); - for(it = cm->msg->files.begin(); it != cm->msg->files.end(); ++it) - { - ChanFileDisItem *cfdi = new ChanFileDisItem(it->name, it->size); - chfb -> addItemSeries(cfdi); - - /* check if previously selected channel */ - if ((selChanFile) && - (selName == cfdi -> name) && - (selSize == cfdi -> size)) - { - selCFDI = cfdi; - } - } - - chfb -> ItemSeriesDone(); - if (selCMDI) - { - chfb -> selectDD(selCFDI); - } - } - - channel_msg_item_ok = true; - // not needed, channel_msg_item_changed = true; - } - - return 1; -} - -#endif - - -#include - -std::string sizeToString(int size) -{ - std::ostringstream out; - float fsize = size; - int mag = 1; - while(fsize > 1000) - { - fsize /= 1000; - mag++; - } - - out << std::setw(4) << std::setprecision(3) << fsize; - switch(mag) - { - case 1: - out << " B"; - break; - case 2: - out << " kB"; - break; - case 3: - out << " MB"; - break; - case 4: - out << " GB"; - break; - case 5: - out << " TB"; - break; - default: - out << " ??"; - break; - } - return out.str(); -} - - -int ensureExtension(std::string &name, std::string def_ext) -{ - /* if it has an extension, don't change */ - int len = name.length(); - int extpos = name.find_last_of('.'); - - std::ostringstream out; - out << "ensureExtension() name: " << name << std::endl; - out << "\t\t extpos: " << extpos; - out << " len: " << len << std::endl; - - /* check that the '.' has between 1 and 4 char after it (an extension) */ - if ((extpos > 0) && (extpos < len - 1) && (extpos + 6 > len)) - { - /* extension there */ - std::string curext = name.substr(extpos, len); - out << "ensureExtension() curext: " << curext << std::endl; - std::cerr << out.str(); - return 0; - } - - if (extpos != len - 1) - { - name += "."; - } - name += def_ext; - - out << "ensureExtension() added ext: " << name << std::endl; - - std::cerr << out.str(); - return 1; -} - - diff --git a/libretroshare/src/fltkgui/fltkserver.h b/libretroshare/src/fltkgui/fltkserver.h deleted file mode 100644 index 8ce8bca30..000000000 --- a/libretroshare/src/fltkgui/fltkserver.h +++ /dev/null @@ -1,222 +0,0 @@ -/* - * "$Id: fltkserver.h,v 1.15 2007-02-18 21:46:49 rmf24 Exp $" - * - * FltkGUI for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - - -#ifndef MRK_FLTK_PQI_INTERFACE -#define MRK_FLTK_PQI_INTERFACE - -#include "server/filedexserver.h" -#include "pqi/pqipersongrp.h" -#include "pqi/pqissl.h" - -#include "fltkgui/Fl_Funky_Browser.h" -#include "fltkgui/pqistrings.h" - - -#include "fltkgui/alertbox.h" -#include "fltkgui/guitab.h" - -#include "pqi/p3disc.h" - -class fltkserver -{ - public: - fltkserver(); - ~fltkserver(); - -int init(); -int run(); - - // setup pqissl -int setuppqissl(filedexserver *fd, pqipersongrp *ph, sslroot *r, UserInterface *u); -int addAutoDiscovery(p3disc *a) {ad = a; return 1; } - -int addAlerts(alertBox *msg, alertBox *chat); -int ownchatmsg(std::string); -int chatmsg(std::string msg, std::string source); -int alertmsg(int type, int sev, std::string msg, std::string source); - - - // flags to indicate if something needs updating. - // This are public advisory flags that - // can be altered by callbacks. - bool cert_list_ok; - bool cert_item_ok; - bool cert_neighbour_list_ok; - bool cert_neighbour_item_ok; - bool search_list_ok; - bool result_list_ok; - bool result_item_ok; - bool msg_list_ok; - bool msg_item_ok; - bool msg_dialog_ok; - - bool transfer_ok; - bool transfer_item_ok; - bool dir_list_ok; - bool save_dir_ok; - bool server_set_ok; - - bool transfer_rates_ok; - - // Neighbour fns -cert * cert_get_current_neighbour(); - -int cert_add_neighbour(); -int neigh_display(cert*); -int neigh_update_auth(); - -cert * cert_get_current(); - -int cert_allow_current(); -int cert_deny_current(); -int cert_listen_current(); -int cert_connect_current(); -int cert_remove_current(); -int cert_tag_current(); -/* int cert_save_config(const char *fname); */ -int cert_save_config(); -int cert_load_gui_config(); -int cert_save_servaddr(); -int cert_saveaddr_connect(); -int cert_check_auto(); -int cert_toggle_auto(); -int cert_sign_current(); -int cert_trust_current_toggle(); -int cert_update_auth(); - -std::string getHomePath(); -int config_remove_dir(); -int file_select(int); -int file_updateName(); -int file_completeIO(); - -int config_server_update(); -int config_server_change(); - -int fselect_type; // what type of file selection is in progress. - - -int search_new(); // read words from keyboard. -int search_download(); -int search_recommend(); -int search_remove(); - - // new results display system. -int update_search_browser(); - -int set_recommend(PQFileItem *rec); -PQFileItem *get_recommend(); - -int getnsend_chat(); -int msg_send(); -int msg_channel_select(); -int msg_remove(); -int msg_reply(); -int download_recommend(); - -int transfer_select(); -int transfer_cancel(); -int transfer_clear(); -int transfer_rates(); - -int load_dir(std::string person, std::string dir); -int dirlist_download(); -int dirlist_recommend(); - - private: - -int update(); - -int update_quick_stats(); -int update_other_stats(); - -int update_certs(); - // display certificate details. -int cert_display(cert*, bool); - -int update_neighbour_certs(); -int update_search(); -int update_msgs(); -int update_transfer(); -int update_config(); - -int update_dirs(); -int update_dirlist(); -int check_dirlist(); -int check_dirlist2(); - -#ifdef PQI_USE_CHANNELS - -int update_channels(); -bool channel_list_ok; -bool channel_msg_list_ok; -bool channel_msg_item_ok; - -#endif - - -std::list transfers; - - // pointers to pqissl stuff. - filedexserver *server; - pqipersongrp *pqih; - sslroot *sslr; - UserInterface *ui; - - p3disc *ad; - - alertBox *msg; - alertBox *chat; - - // recommendation. - PQFileItem *recommend; - - // File Import/Export Flags. - bool fileio_import; - - int loop; - - Fl_Funky_Browser *search_browser; -}; - - -#define FILE_CHOOSER_IMPORT 1 -#define FILE_CHOOSER_EXPORT 2 -#define FILE_CHOOSER_DIR 3 -#define FILE_CHOOSER_SAVEDIR 4 -#define FILE_CHOOSER_KEY 5 -#define FILE_CHOOSER_CERT 6 - -/* Helper function to convert windows paths - * into unix (ie switch \ to /) for FLTK's file chooser - */ - -std::string make_path_unix(std::string winpath); - - -#endif diff --git a/libretroshare/src/fltkgui/guitab.cc b/libretroshare/src/fltkgui/guitab.cc deleted file mode 100644 index c89db6e94..000000000 --- a/libretroshare/src/fltkgui/guitab.cc +++ /dev/null @@ -1,675 +0,0 @@ -// generated by Fast Light User Interface Designer (fluid) version 1.0107 - -#include "guitab.h" - -Fl_Double_Window* UserInterface::make_windows() { - Fl_Double_Window* w; - { Fl_Double_Window* o = main_win = new Fl_Double_Window(710, 535, "RetroShare"); - w = o; - o->box(FL_DOWN_BOX); - o->user_data((void*)(this)); - { Fl_Tabs* o = gui_tabs = new Fl_Tabs(10, 10, 690, 470); - o->box(FL_UP_BOX); - { Fl_Group* o = neighbours_tab = new Fl_Group(15, 40, 680, 435, "Connect"); - o->labelfont(1); - { Fl_Button* o = new Fl_Button(50, 439, 280, 31, "Load Certificate from File"); - o->callback((Fl_Callback*)file_import); - } - { Fl_Funky_Browser* o = cert_neighbour_list = new Fl_Funky_Browser(25, 70, 350, 355, "", 4); - o->box(FL_NO_BOX); - o->color(FL_BACKGROUND2_COLOR); - o->selection_color(FL_SELECTION_COLOR); - o->labeltype(FL_NORMAL_LABEL); - o->labelfont(0); - o->labelsize(14); - o->labelcolor(FL_FOREGROUND_COLOR); - o->textfont(4); - o->callback((Fl_Callback*)cert_neighbour_list_select); - o->align(FL_ALIGN_BOTTOM); - o->when(FL_WHEN_RELEASE_ALWAYS); - } - { Fl_Button* o = neigh_add_button = new Fl_Button(420, 440, 240, 30, "Sign + Add to Friends >>>"); - o->callback((Fl_Callback*)cert_move_to_friends); - } - { Fl_Box* o = new Fl_Box(35, 49, 290, 20, "Your Neighbour List"); - o->box(FL_FLAT_BOX); - o->labelfont(1); - } - { Fl_Input* o = neigh_authcode = new Fl_Input(540, 397, 70, 30, "AUTH CODE:"); - o->labelfont(1); - o->callback((Fl_Callback*)neigh_auth_callback); - o->when(FL_WHEN_CHANGED); - } - { Fl_Group* o = new Fl_Group(390, 54, 295, 305); - o->box(FL_DOWN_BOX); - { Fl_Box* o = new Fl_Box(395, 65, 125, 20, "Peer Details"); - o->box(FL_FLAT_BOX); - o->labelfont(1); - o->labelsize(16); - } - { Fl_Browser* o = neigh_signers = new Fl_Browser(440, 195, 225, 140, "Certificate signers"); - o->type(2); - o->textfont(4); - o->callback((Fl_Callback*)cert_neigh_signers_select); - Fl_Group::current()->resizable(o); - } - neigh_name = new Fl_Output(450, 90, 226, 20, "Name:"); - neigh_org = new Fl_Output(450, 115, 226, 20, "Org:"); - neigh_loc = new Fl_Output(450, 140, 225, 20, "Loc:"); - neigh_country = new Fl_Output(495, 165, 168, 20, "Country:"); - neigh_trust = new Fl_Output(565, 65, 110, 20, "Trust:"); - o->end(); - } - { Fl_Box* o = neigh_auth_notice = new Fl_Box(405, 369, 270, 26, "AUTH CODE REQUIRED"); - o->box(FL_FLAT_BOX); - o->labelfont(1); - o->labelsize(18); - o->labelcolor(FL_YELLOW); - } - o->end(); - } - { Fl_Group* o = connect_tab = new Fl_Group(15, 40, 680, 435, "Friends"); - o->labelfont(1); - o->hide(); - { Fl_Button* o = new Fl_Button(62, 440, 185, 25, "<<< Remove Friend"); - o->callback((Fl_Callback*)cert_remove_cert); - } - { Fl_Button* o = new Fl_Button(264, 440, 185, 25, "Configure Friend"); - o->callback((Fl_Callback*)cert_show_config); - } - { Fl_Funky_Browser* o = cert_list = new Fl_Funky_Browser(25, 70, 660, 360, "", 5); - o->type(2); - o->box(FL_NO_BOX); - o->color(FL_BACKGROUND2_COLOR); - o->selection_color(FL_SELECTION_COLOR); - o->labeltype(FL_NORMAL_LABEL); - o->labelfont(0); - o->labelsize(14); - o->labelcolor(FL_FOREGROUND_COLOR); - o->textfont(4); - o->callback((Fl_Callback*)cert_list_select); - o->align(FL_ALIGN_BOTTOM); - o->when(FL_WHEN_RELEASE_ALWAYS); - } - { Fl_Button* o = new Fl_Button(466, 440, 185, 25, "Export Friend"); - o->callback((Fl_Callback*)file_export); - } - { Fl_Box* o = new Fl_Box(190, 50, 340, 20, "Your Friends "); - o->box(FL_FLAT_BOX); - o->labelfont(1); - } - o->end(); - } - { Fl_Group* o = new Fl_Group(15, 40, 680, 435, "File Listing"); - o->labelfont(1); - o->hide(); - { Fl_Widget *o = file_results = make_tree_browser(25, 50, 660, 380); - } -// { Fl_File_Browser* o = file_results = new Fl_File_Browser(45, 50, 625, 380); -// o->callback((Fl_Callback*)file_result_select); -// } - { Fl_Button* o = file_download_button = new Fl_Button(65, 440, 185, 25, "Download"); - o->callback((Fl_Callback*)file_download); - } - { Fl_Button* o = file_recommend_button = new Fl_Button(465, 440, 185, 25, "Recommend to Friends"); - o->callback((Fl_Callback*)file_recommend); - o->deactivate(); - } - { Fl_Button* o = file_channel_button = new Fl_Button(265, 440, 185, 25, "Broadcast on Channel"); - o->callback((Fl_Callback*)file_channel_broadcast); - o->deactivate(); - } - o->end(); - } - { Fl_Group* o = new Fl_Group(15, 40, 680, 435, "Search "); - o->labelfont(1); - o->hide(); - { Fl_Input* o = new_search = new Fl_Input(105, 50, 225, 25, "Terms:"); - o->labelfont(1); - o->callback((Fl_Callback*)do_new_search); - } - { Fl_Button* o = new Fl_Button(535, 50, 125, 25, "Remove Search"); - o->callback((Fl_Callback*)search_remove); - } - { Fl_Button* o = recommend_button = new Fl_Button(460, 440, 185, 25, "Recommend to Friends"); - o->callback((Fl_Callback*)search_recommend); - o->deactivate(); - } - { Fl_Funky_Browser* o = srch_results = new Fl_Funky_Browser(25, 80, 660, 350, "", 5); - o->type(2); - o->box(FL_NO_BOX); - o->color(FL_BACKGROUND2_COLOR); - o->selection_color(FL_SELECTION_COLOR); - o->labeltype(FL_NORMAL_LABEL); - o->labelfont(0); - o->labelsize(14); - o->labelcolor(FL_FOREGROUND_COLOR); - o->callback((Fl_Callback*)search_result_select); - o->align(FL_ALIGN_BOTTOM); - o->when(FL_WHEN_RELEASE_ALWAYS); - } - { Fl_Button* o = search_button = new Fl_Button(340, 50, 79, 25, "Search"); - o->labelfont(1); - o->callback((Fl_Callback*)do_search_button); - } - { Fl_Button* o = download_button = new Fl_Button(60, 440, 185, 25, "Download"); - o->callback((Fl_Callback*)search_download); - } - { Fl_Button* o = search_channel_button = new Fl_Button(260, 440, 185, 25, "Broadcast on Channel"); - o->callback((Fl_Callback*)search_channel_broadcast); - o->deactivate(); - } - o->end(); - } - { Fl_Group* o = new Fl_Group(15, 40, 680, 435, "File Transfer"); - o->hide(); - { Fl_Funky_Browser* o = transfer_downloads = new Fl_Funky_Browser(25, 50, 660, 250, "", 5); - o->type(2); - o->box(FL_NO_BOX); - o->color(FL_BACKGROUND2_COLOR); - o->selection_color(FL_SELECTION_COLOR); - o->labeltype(FL_NORMAL_LABEL); - o->labelfont(0); - o->labelsize(14); - o->labelcolor(FL_FOREGROUND_COLOR); - o->callback((Fl_Callback*)transfer_select); - o->align(FL_ALIGN_BOTTOM); - o->when(FL_WHEN_RELEASE_ALWAYS); - } - { Fl_Button* o = transfer_cancel = new Fl_Button(70, 310, 165, 25, "Cancel"); - o->callback((Fl_Callback*)file_transfer_cancel); - } - { Fl_Button* o = transfer_clear = new Fl_Button(275, 310, 155, 25, "Clear Finished"); - o->callback((Fl_Callback*)file_transfer_clear); - } - { Fl_Text_Display* o = transfer_overview = new Fl_Text_Display(25, 345, 450, 120); - o->textfont(5); - } - { Fl_Counter* o = rate_total = new Fl_Counter(510, 380, 135, 25, "Max Total Data Rate (kB/s)"); - o->step(0.1); - o->callback((Fl_Callback*)file_transfer_total_rate); - } - { Fl_Counter* o = rate_indiv = new Fl_Counter(510, 425, 135, 25, "Rate Per Person (kB/s)"); - o->step(0.1); - o->callback((Fl_Callback*)file_transfer_indiv_rate); - } - o->end(); - } - { Fl_Group* o = new Fl_Group(15, 40, 680, 435, "Messages"); - o->labelfont(1); - o->hide(); - o->deactivate(); - { Fl_Funky_Browser* o = msg_list = new Fl_Funky_Browser(25, 65, 660, 270, "", 5); - o->type(2); - o->box(FL_NO_BOX); - o->color(FL_BACKGROUND2_COLOR); - o->selection_color(FL_SELECTION_COLOR); - o->labeltype(FL_NORMAL_LABEL); - o->labelfont(0); - o->labelsize(14); - o->labelcolor(FL_FOREGROUND_COLOR); - o->callback((Fl_Callback*)msg_select); - o->align(FL_ALIGN_BOTTOM); - o->when(FL_WHEN_RELEASE_ALWAYS); - } - { Fl_Button* o = new Fl_Button(45, 350, 125, 25, "New Msg"); - o->callback((Fl_Callback*)msg_dialog_show); - } - { Fl_Button* o = new Fl_Button(45, 380, 125, 25, "Reply to Msg"); - o->callback((Fl_Callback*)msg_dialog_reply); - } - { Fl_Button* o = new Fl_Button(245, 450, 380, 25, "(2) -- Get The Recommended File"); - o->labelfont(1); - o->callback((Fl_Callback*)msg_get_recommendation); - } - { Fl_Button* o = new Fl_Button(45, 410, 125, 25, "Remove Msg"); - o->callback((Fl_Callback*)msg_remove); - } - { Fl_Text_Display* o = msg_details = new Fl_Text_Display(180, 340, 485, 105); - o->textfont(5); - } - { Fl_Box* o = new Fl_Box(55, 45, 305, 20, "(1) -- Select Message"); - o->box(FL_FLAT_BOX); - o->labelfont(1); - } - o->end(); - } - { Fl_Group* o = channels = new Fl_Group(15, 40, 680, 435, "Channels"); - o->hide(); - o->deactivate(); - { Fl_Funky_Browser* o = channel_list = new Fl_Funky_Browser(25, 80, 660, 225, "", 5); - o->type(2); - o->box(FL_NO_BOX); - o->color(FL_BACKGROUND2_COLOR); - o->selection_color(FL_SELECTION_COLOR); - o->labeltype(FL_NORMAL_LABEL); - o->labelfont(0); - o->labelsize(14); - o->labelcolor(FL_FOREGROUND_COLOR); - o->callback((Fl_Callback*)channel_list_select); - o->align(FL_ALIGN_BOTTOM); - o->when(FL_WHEN_RELEASE_ALWAYS); - } - { Fl_Box* o = new Fl_Box(40, 61, 170, 19, "Available Channels"); - o->labelfont(1); - } - { Fl_Group* o = new Fl_Group(25, 310, 655, 160); - o->box(FL_DOWN_BOX); - { Fl_Funky_Browser* o = channel_file_list = new Fl_Funky_Browser(35, 345, 635, 120, "", 5); - o->box(FL_NO_BOX); - o->color(FL_BACKGROUND2_COLOR); - o->selection_color(FL_SELECTION_COLOR); - o->labeltype(FL_NORMAL_LABEL); - o->labelfont(0); - o->labelsize(14); - o->labelcolor(FL_FOREGROUND_COLOR); - o->callback((Fl_Callback*)channel_file_list_select); - o->align(FL_ALIGN_BOTTOM); - o->when(FL_WHEN_RELEASE_ALWAYS); - } - { Fl_Output* o = channel_selected_name = new Fl_Output(185, 315, 270, 25, "Msgs on Channel"); - o->labelfont(1); - } - { Fl_Button* o = channel_show_button = new Fl_Button(485, 315, 160, 25, "Show Msg Details"); - o->callback((Fl_Callback*)channel_show_callback); - } - o->end(); - } - { Fl_Button* o = channel_delete_button = new Fl_Button(290, 50, 160, 25, "Delete Channel"); - o->callback((Fl_Callback*)channel_delete_callback); - } - { Fl_Button* o = channel_create_button = new Fl_Button(475, 50, 160, 25, "Create Channel Msg"); - o->callback((Fl_Callback*)channel_create); - } - o->end(); - } - { Fl_Group* o = new Fl_Group(15, 40, 680, 435, "Config"); - o->hide(); - { Fl_Group* o = new Fl_Group(460, 55, 210, 80); - o->box(FL_DOWN_BOX); - o->hide(); - { Fl_Check_Button* o = config_local_disc = new Fl_Check_Button(490, 80, 145, 25, "local discovery"); - o->down_box(FL_DOWN_BOX); - } - { Fl_Check_Button* o = config_remote_disc = new Fl_Check_Button(490, 100, 145, 25, "remote discovery"); - o->down_box(FL_DOWN_BOX); - } - { Fl_Box* o = new Fl_Box(470, 60, 165, 20, "Discovery Options:"); - o->box(FL_FLAT_BOX); - o->labelfont(1); - } - o->end(); - } - { Fl_Group* o = new Fl_Group(25, 225, 405, 240); - o->box(FL_DOWN_BOX); - { Fl_Browser* o = config_search_dir = new Fl_Browser(40, 245, 355, 105); - o->type(2); - } - { Fl_Button* o = new Fl_Button(40, 370, 135, 25, "Add Directory"); - o->callback((Fl_Callback*)config_add_dir); - } - { Fl_Button* o = new Fl_Button(40, 400, 135, 25, "Remove Directory"); - o->callback((Fl_Callback*)config_remove_dir); - } - config_save_dir = new Fl_Output(145, 435, 250, 20, "Save Directory"); - { Fl_Button* o = new Fl_Button(230, 405, 165, 25, "Select save directory"); - o->callback((Fl_Callback*)config_save_dir_change); - } - { Fl_Box* o = new Fl_Box(41, 230, 174, 15, "Share Directories:"); - o->box(FL_FLAT_BOX); - o->labelfont(1); - } - o->end(); - } - { Fl_Group* o = new Fl_Group(25, 55, 405, 160); - o->box(FL_DOWN_BOX); - config_local_addr = new Fl_Input(165, 80, 130, 20, "Local Address:"); - config_local_port = new Fl_Value_Input(335, 80, 60, 20, "Port:"); - config_server_addr = new Fl_Input(165, 145, 130, 25, "External Address:"); - config_server_port = new Fl_Value_Input(335, 145, 60, 25, "Port:"); - { Fl_Check_Button* o = config_firewall = new Fl_Check_Button(195, 100, 190, 25, "behind firewall"); - o->down_box(FL_DOWN_BOX); - o->callback((Fl_Callback*)config_server_update); - } - { Fl_Check_Button* o = config_forward = new Fl_Check_Button(195, 120, 190, 25, "forwarded external port"); - o->down_box(FL_DOWN_BOX); - o->callback((Fl_Callback*)config_server_update); - } - { Fl_Box* o = new Fl_Box(45, 60, 150, 20, "Server Settings:"); - o->box(FL_FLAT_BOX); - o->labelfont(1); - } - { Fl_Button* o = config_server_button = new Fl_Button(185, 180, 190, 25, "Change + Restart Server"); - o->callback((Fl_Callback*)config_server_change); - } - o->end(); - } - { Fl_Button* o = new Fl_Button(485, 434, 170, 25, "Save Configuration"); - o->callback((Fl_Callback*)cert_save_config); - } - o->end(); - } - { Fl_Group* o = about_help_tab = new Fl_Group(15, 40, 680, 435, "About"); - o->hide(); - help_view = new Fl_Help_View(25, 50, 660, 415); - o->end(); - } - o->end(); - } - onlinecounter = new Fl_Value_Output(100, 485, 35, 20, "#Online:"); - new Fl_Value_Output(100, 505, 35, 20, "New Msgs:"); - { Fl_Button* o = new Fl_Button(605, 490, 85, 30, "Hide"); - o->callback((Fl_Callback*)gui_quit); - } - new Fl_Text_Display(140, 485, 360, 40); - { Fl_Button* o = chat_button = new Fl_Button(510, 490, 85, 30, "Chat"); - o->callback((Fl_Callback*)chat_open_callback); - } - o->end(); - } - { Fl_Double_Window* o = msg_dialog = new Fl_Double_Window(580, 355, "Msg Dialog"); - w = o; - o->user_data((void*)(this)); - msg_online = new Fl_Check_Browser(20, 25, 140, 215); - { Fl_Button* o = msg_button_select = new Fl_Button(20, 240, 140, 25, "Select All/None"); - o->callback((Fl_Callback*)msg_toggle_select); - } - { Fl_Text_Editor* o = msg_text = new Fl_Text_Editor(175, 25, 385, 240, "(1) -- Enter Message Text:"); - o->labelfont(1); - } - msg_recommend = new Fl_Output(175, 275, 385, 30, "Recommendation:"); - { Fl_Button* o = new Fl_Button(245, 315, 160, 30, "(2) -- Send Msg"); - o->labelfont(1); - o->callback((Fl_Callback*)msg_send); - } - { Fl_Button* o = new Fl_Button(415, 315, 115, 30, "Cancel"); - o->callback((Fl_Callback*)msg_dialog_hide); - } - o->end(); - } - { Fl_Double_Window* o = cert_config = new Fl_Double_Window(430, 535, "Certificate Configuration"); - w = o; - o->user_data((void*)(this)); - { Fl_Group* o = new Fl_Group(10, 10, 410, 490); - o->box(FL_UP_BOX); - { Fl_Group* o = new Fl_Group(25, 355, 380, 135); - o->box(FL_DOWN_BOX); - cert_server = new Fl_Input(155, 430, 130, 25, "Server Address:"); - { Fl_Button* o = new Fl_Button(165, 460, 220, 25, "Save and attempt to Connect"); - o->callback((Fl_Callback*)cert_save_n_connect); - } - { Fl_Button* o = new Fl_Button(35, 460, 115, 25, "Save Address"); - o->callback((Fl_Callback*)cert_save_servaddr); - } - cert_port = new Fl_Value_Input(325, 430, 60, 25, "Port:"); - { Fl_Check_Button* o = cert_connect = new Fl_Check_Button(30, 410, 365, 20, "Outgoing Connections (Server Address Required)"); - o->down_box(FL_DOWN_BOX); - o->callback((Fl_Callback*)cert_connect_change); - } - { Fl_Check_Button* o = cert_allow = new Fl_Check_Button(30, 380, 115, 20, "Allow Access"); - o->down_box(FL_DOWN_BOX); - o->callback((Fl_Callback*)cert_allow_change); - } - { Fl_Check_Button* o = cert_listen = new Fl_Check_Button(30, 395, 170, 20, "Listen for connection"); - o->down_box(FL_DOWN_BOX); - o->callback((Fl_Callback*)cert_listen_change); - } - { Fl_Check_Button* o = cert_local = new Fl_Check_Button(220, 385, 130, 20, "Local Network"); - o->down_box(FL_DOWN_BOX); - o->callback((Fl_Callback*)cert_local_change); - } - { Fl_Check_Button* o = cert_auto = new Fl_Check_Button(220, 362, 140, 20, "Auto Connect"); - o->down_box(FL_DOWN_BOX); - o->labelfont(1); - o->callback((Fl_Callback*)cert_auto_change); - } - { Fl_Box* o = new Fl_Box(32, 363, 190, 20, "Connectivity Options:"); - o->box(FL_FLAT_BOX); - o->labelfont(1); - } - o->end(); - } - cert_status = new Fl_Output(80, 20, 130, 25, "Status:"); - cert_details = new Fl_Text_Display(25, 50, 380, 210); - { Fl_Group* o = new Fl_Group(25, 267, 380, 82); - o->box(FL_DOWN_BOX); - { Fl_Button* o = cert_sign_button = new Fl_Button(239, 295, 145, 29, "Sign Certificate"); - o->callback((Fl_Callback*)cert_sign); - } - { Fl_Check_Button* o = cert_trust_person = new Fl_Check_Button(95, 323, 230, 25, "Trust This Person\'s Signature"); - o->down_box(FL_DOWN_BOX); - o->callback((Fl_Callback*)cert_trust_person_change); - } - { Fl_Input* o = cert_authcode = new Fl_Input(145, 295, 80, 28, "AUTH CODE:"); - o->labelfont(1); - o->callback((Fl_Callback*)cert_auth_callback); - o->when(FL_WHEN_CHANGED); - } - { Fl_Box* o = new Fl_Box(35, 272, 360, 20, "Authenticate Friend By Entering Their Code"); - o->box(FL_FLAT_BOX); - o->labelfont(1); - } - o->end(); - } - cert_trust = new Fl_Output(260, 20, 140, 25, "Trust:"); - o->end(); - } - { Fl_Button* o = new Fl_Button(305, 505, 100, 25, "Done"); - o->callback((Fl_Callback*)cert_hide_config); - } - o->end(); - } - { Fl_Double_Window* o = new Fl_Double_Window(360, 290); - w = o; - o->user_data((void*)(this)); - { //Fl_File_Chooser* o = file_chooser = new Fl_File_Chooser(5, 5, 350, 280); - Fl_File_Chooser* o = file_chooser = new Fl_File_Chooser("/", - "Certificate Files (*.{pem,pqi})", 0, "Select File/Dir"); - -// o->box(FL_NO_BOX); -// o->color(FL_BACKGROUND_COLOR); -// o->selection_color(FL_BACKGROUND_COLOR); -// o->labeltype(FL_NORMAL_LABEL); -// o->labelfont(0); -// o->labelsize(14); -// o->labelcolor(FL_FOREGROUND_COLOR); -// o->callback((Fl_Callback*)file_chooser_select); - o->callback(file_chooser_select); -// o->align(FL_ALIGN_TOP); -// o->when(FL_WHEN_RELEASE); -// o->end(); - } - o->end(); - } - { Fl_Double_Window* o = welcome_window = new Fl_Double_Window(405, 580, "RetroShare Setup"); - w = o; - o->user_data((void*)(this)); - { Fl_Group* o = new Fl_Group(10, 10, 385, 35); - o->box(FL_DOWN_BOX); - { Fl_Box* o = new Fl_Box(85, 15, 230, 20, "Welcome to RetroShare"); - o->box(FL_FLAT_BOX); - o->labelfont(1); - o->labelsize(16); - } - o->end(); - } - { Fl_Group* o = new Fl_Group(10, 55, 385, 140); - o->box(FL_DOWN_BOX); - { Fl_Box* o = new Fl_Box(75, 65, 285, 20, "Please login ...."); - o->box(FL_FLAT_BOX); - o->labelfont(1); - } - load_name = new Fl_Output(90, 90, 250, 25, "Name:"); - { Fl_Input* o = load_passwd = new Fl_Input(90, 125, 250, 25, "Password"); - o->type(5); - o->callback((Fl_Callback*)load_passwd_callback); - o->when(FL_WHEN_ENTER_KEY); - } - { Fl_Button* o = load_button = new Fl_Button(110, 160, 210, 30, "Load Existing User"); - o->callback((Fl_Callback*)load_existing); - } - o->end(); - } - { Fl_Group* o = new Fl_Group(10, 205, 385, 365); - o->box(FL_DOWN_BOX); - { Fl_Box* o = new Fl_Box(55, 210, 300, 20, "Or create a New User..."); - o->box(FL_FLAT_BOX); - o->labelfont(1); - } - { Fl_Group* o = new Fl_Group(50, 360, 300, 5); - o->box(FL_UP_BOX); - o->end(); - } - { Fl_Group* o = new Fl_Group(50, 440, 300, 5); - o->box(FL_UP_BOX); - o->end(); - } - { Fl_Group* o = new Fl_Group(50, 511, 300, 5); - o->box(FL_UP_BOX); - o->end(); - } - gen_name = new Fl_Input(120, 235, 250, 25, "Name:"); - gen_org = new Fl_Input(120, 265, 250, 25, "Organisation:"); - gen_loc = new Fl_Input(120, 295, 250, 25, "Location:"); - gen_country = new Fl_Input(120, 325, 250, 25, "Country:"); - { Fl_Input* o = gen_passwd = new Fl_Input(170, 375, 130, 25, "New Password"); - o->type(5); - } - { Fl_Input* o = gen_passwd2 = new Fl_Input(170, 405, 130, 25, "Password (Again)"); - o->type(5); - } - { Fl_Check_Button* o = gen_trusted_tick_box = new Fl_Check_Button(50, 450, 305, 20, "Load Trusted Certificate (Optional)"); - o->down_box(FL_DOWN_BOX); - o->labelfont(1); - o->callback((Fl_Callback*)gen_trusted_tick_callback); - } - gen_trusted_peer = new Fl_Output(105, 474, 135, 25, "Friend:"); - { Fl_Button* o = gen_trusted_select_button = new Fl_Button(252, 470, 93, 30, "Select File"); - o->callback((Fl_Callback*)gen_load_trusted); - } - { Fl_Button* o = gen_button = new Fl_Button(100, 528, 210, 30, "Generate New Certificate"); - o->callback((Fl_Callback*)generate_certificate); - } - o->end(); - } - o->end(); - } - { Fl_Double_Window* o = chatter_window = new Fl_Double_Window(455, 435, "ChatterBox"); - w = o; - o->user_data((void*)(this)); - chatter_box = new Fl_Text_Display(5, 10, 445, 370); - { Fl_Input* o = chatter_input = new Fl_Input(5, 390, 445, 40); - o->callback((Fl_Callback*)chatterbox_message); - o->when(FL_WHEN_ENTER_KEY); - } - o->end(); - } - { Fl_Double_Window* o = alert_window = new Fl_Double_Window(540, 200, "Alerts"); - w = o; - o->user_data((void*)(this)); - { Fl_Return_Button* o = alert_okay = new Fl_Return_Button(75, 175, 180, 20, "OK"); - o->callback((Fl_Callback*)alert_okay_msg); - } - alert_box = new Fl_Text_Display(15, 5, 515, 165); - { Fl_Button* o = alert_cancel = new Fl_Button(270, 175, 180, 20, "Cancel"); - o->labelfont(3); - o->labelsize(16); - o->labelcolor((Fl_Color)80); - o->callback((Fl_Callback*)alert_cancel_msg); - } - o->end(); - } - { Fl_Double_Window* o = channel_create_window = new Fl_Double_Window(460, 535, "Create New Channel Msg"); - w = o; - o->user_data((void*)(this)); - { Fl_Funky_Browser* o = chan_createmsg_filelist = new Fl_Funky_Browser(10, 195, 440, 265, "", 2); - o->type(2); - o->box(FL_NO_BOX); - o->color(FL_BACKGROUND2_COLOR); - o->selection_color(FL_SELECTION_COLOR); - o->labeltype(FL_NORMAL_LABEL); - o->labelfont(0); - o->labelsize(14); - o->labelcolor(FL_FOREGROUND_COLOR); - o->callback((Fl_Callback*)chan_createmsg_list_select); - o->align(FL_ALIGN_BOTTOM); - o->when(FL_WHEN_RELEASE_ALWAYS); - } - { Fl_Button* o = chan_createmsg_sendmsg_button = new Fl_Button(25, 500, 125, 25, "Send Msg"); - o->callback((Fl_Callback*)chan_createmsg_sendmsg_callback); - } - { Fl_Button* o = chan_createmsg_postpone_button = new Fl_Button(165, 500, 125, 25, "Postpone Msg"); - o->callback((Fl_Callback*)chan_createmsg_postpone_callback); - } - { Fl_Button* o = chan_createmsg_cancel_button = new Fl_Button(305, 500, 125, 25, "Cancel Msg"); - o->callback((Fl_Callback*)chan_createmsg_cancel_callback); - } - chan_createmsg_msg = new Fl_Text_Editor(10, 110, 440, 75); - { Fl_Box* o = new Fl_Box(10, 91, 135, 19, "Message Text:"); - o->labelfont(1); - } - { Fl_Button* o = chan_createmsg_remove_button = new Fl_Button(305, 470, 125, 25, "Remove File"); - o->callback((Fl_Callback*)chan_createmsg_remove_callback); - } - { Fl_Group* o = new Fl_Group(10, 5, 440, 80); - o->box(FL_DOWN_BOX); - { Fl_Input* o = chan_createmsg_newname = new Fl_Input(155, 50, 280, 25); - o->callback((Fl_Callback*)chan_createmsg_newname_callback); - } - chan_createmsg_title = new Fl_Output(155, 15, 280, 25); - { Fl_Round_Button* o = chan_createmsg_newname_button = new Fl_Round_Button(20, 55, 135, 20, "Create Channel"); - o->type(102); - o->down_box(FL_ROUND_DOWN_BOX); - o->callback((Fl_Callback*)chan_createmsg_newname_button_callback); - } - { Fl_Round_Button* o = chan_createmsg_title_button = new Fl_Round_Button(20, 15, 135, 20, "Active Channel"); - o->type(102); - o->down_box(FL_ROUND_DOWN_BOX); - o->callback((Fl_Callback*)chan_createmsg_title_button_callback); - } - { Fl_Box* o = new Fl_Box(45, 33, 70, 22, "OR"); - o->labelfont(3); - } - o->end(); - } - o->end(); - } - { Fl_Double_Window* o = channel_details_window = new Fl_Double_Window(460, 445, "Channel Msg Details"); - w = o; - o->user_data((void*)(this)); - { Fl_Funky_Browser* o = chan_msgdetails_filelist = new Fl_Funky_Browser(10, 146, 440, 255, "", 2); - o->type(2); - o->box(FL_NO_BOX); - o->color(FL_BACKGROUND2_COLOR); - o->selection_color(FL_SELECTION_COLOR); - o->labeltype(FL_NORMAL_LABEL); - o->labelfont(0); - o->labelsize(14); - o->labelcolor(FL_FOREGROUND_COLOR); - o->callback((Fl_Callback*)chan_msgdetails_list_select); - o->align(FL_ALIGN_BOTTOM); - o->when(FL_WHEN_RELEASE_ALWAYS); - } - { Fl_Button* o = chan_msgdetails_download_button = new Fl_Button(165, 410, 125, 25, "Download Files"); - o->callback((Fl_Callback*)chan_msgdetails_download_callback); - } - { Fl_Box* o = new Fl_Box(10, 42, 135, 19, "Message Text:"); - o->labelfont(1); - } - { Fl_Button* o = chan_msgdetails_subscribe_button = new Fl_Button(25, 410, 125, 25, "Subscribe "); - o->callback((Fl_Callback*)chan_msgdetails_subscribe_callback); - } - { Fl_Output* o = chan_msgdetails_title = new Fl_Output(75, 10, 210, 25, "Channel"); - o->labelfont(1); - } - chan_msgdetails_msg = new Fl_Text_Display(10, 61, 440, 75); - { Fl_Output* o = chan_msgdetails_date = new Fl_Output(330, 10, 120, 25, "Date"); - o->labelfont(1); - } - { Fl_Button* o = chan_msgdetails_close_button = new Fl_Button(305, 410, 125, 25, "Close WIndow"); - o->callback((Fl_Callback*)chan_msgdetails_close_callback); - } - o->end(); - } - return w; -} diff --git a/libretroshare/src/fltkgui/guitab.fld b/libretroshare/src/fltkgui/guitab.fld deleted file mode 100644 index 3328241b8..000000000 --- a/libretroshare/src/fltkgui/guitab.fld +++ /dev/null @@ -1,788 +0,0 @@ -# data file for the Fltk User Interface Designer (fluid) -version 1.0107 -header_name {.h} -code_name {.cxx} -class UserInterface {open -} { - Function {make_windows()} {open - } { - Fl_Window main_win { - label RetroShare open - xywh {10 180 710 535} type Double box DOWN_BOX visible - } { - Fl_Tabs gui_tabs {open - xywh {10 10 690 470} box UP_BOX - } { - Fl_Group neighbours_tab { - label Connect - xywh {15 40 680 435} labelfont 1 - } { - Fl_Button {} { - label {Load Certificate from File} - callback file_import - xywh {50 439 280 31} - } - Fl_Browser cert_neighbour_list { - callback cert_neighbour_list_select - xywh {25 70 350 355} type Hold textfont 4 - code0 {\#include "Fl_Funky_Browser.h"} - class Fl_Funky_Browser - } - Fl_Button neigh_add_button { - label {Sign + Add to Friends >>>} - callback cert_move_to_friends - xywh {420 440 240 30} - } - Fl_Box {} { - label {Your Neighbour List} - xywh {35 49 290 20} box FLAT_BOX labelfont 1 - } - Fl_Input neigh_authcode { - label {AUTH CODE:} - callback neigh_auth_callback selected - xywh {540 397 70 30} labelfont 1 - } - Fl_Group {} {open - xywh {390 54 295 305} box DOWN_BOX - } { - Fl_Box {} { - label {Peer Details} - xywh {395 65 125 20} box FLAT_BOX labelfont 1 labelsize 16 - } - Fl_Browser neigh_signers { - label {Certificate signers} - callback cert_neigh_signers_select - xywh {440 195 225 140} type Hold textfont 4 resizable - } - Fl_Output neigh_name { - label {Name:} - xywh {450 90 226 20} - } - Fl_Output neigh_org { - label {Org:} - xywh {450 115 226 20} - } - Fl_Output neigh_loc { - label {Loc:} - xywh {450 140 225 20} - } - Fl_Output neigh_country { - label {Country:} - xywh {495 165 168 20} - } - Fl_Output neigh_trust { - label {Trust:} - xywh {565 65 110 20} - } - } - Fl_Box neigh_auth_notice { - label {AUTH CODE REQUIRED} - xywh {405 369 270 26} box FLAT_BOX labelfont 1 labelsize 18 labelcolor 95 - } - } - Fl_Group connect_tab { - label Friends - xywh {15 40 680 435} labelfont 1 hide - } { - Fl_Button {} { - label {<<< Remove Friend} - callback cert_remove_cert - xywh {62 440 185 25} - } - Fl_Button {} { - label {Configure Friend} - callback cert_show_config - xywh {264 440 185 25} - } - Fl_Browser cert_list { - callback cert_list_select - xywh {25 70 660 360} type Hold textfont 4 - code0 {\#include "Fl_Funky_Browser.h"} - class Fl_Funky_Browser - } - Fl_Button {} { - label {Export Friend} - callback file_export - xywh {466 440 185 25} - } - Fl_Box {} { - label {Your Friends } - xywh {190 50 340 20} box FLAT_BOX labelfont 1 - } - } - Fl_Group {} { - label {File Listing} - xywh {15 40 680 435} labelfont 1 hide - } { - Fl_File_Browser file_results { - callback file_result_select - xywh {25 50 660 380} - } - Fl_Button file_download_button { - label Download - callback file_download - xywh {65 440 185 25} - } - Fl_Button file_recommend_button { - label {Recommend to Friends} - callback file_recommend - xywh {465 440 185 25} deactivate - } - Fl_Button file_channel_button { - label {Broadcast on Channel} - callback file_channel_broadcast - xywh {265 440 185 25} deactivate - } - } - Fl_Group {} { - label {Search } - xywh {15 40 680 435} labelfont 1 hide - } { - Fl_Input new_search { - label {Terms:} - callback do_new_search - xywh {105 50 225 25} labelfont 1 - } - Fl_Button {} { - label {Remove Search} - callback search_remove - xywh {535 50 125 25} - } - Fl_Button recommend_button { - label {Recommend to Friends} - callback search_recommend - xywh {460 440 185 25} deactivate - } - Fl_Browser srch_results { - callback search_result_select - xywh {25 80 660 350} type Hold - code0 {\#include "Fl_Funky_Browser.h"} - class Fl_Funky_Browser - } - Fl_Button search_button { - label Search - callback do_search_button - xywh {340 50 79 25} labelfont 1 - } - Fl_Button download_button { - label Download - callback search_download - xywh {60 440 185 25} - } - Fl_Button search_channel_button { - label {Broadcast on Channel} - callback search_channel_broadcast - xywh {260 440 185 25} deactivate - } - } - Fl_Group {} { - label {File Transfer} open - xywh {15 40 680 435} hide - } { - Fl_Browser transfer_downloads { - callback transfer_select - xywh {25 50 660 250} type Hold - class Fl_Funky_Browser - } - Fl_Button transfer_cancel { - label Cancel - callback file_transfer_cancel - xywh {70 310 165 25} - } - Fl_Button transfer_clear { - label {Clear Finished} - callback file_transfer_clear - xywh {275 310 155 25} - } - Fl_Text_Display transfer_overview { - xywh {25 345 450 120} textfont 5 - } - Fl_Counter rate_total { - label {Max Total Data Rate (kB/s)} - callback file_transfer_total_rate - xywh {510 380 135 25} - } - Fl_Counter rate_indiv { - label {Rate Per Person (kB/s)} - callback file_transfer_indiv_rate - xywh {510 425 135 25} - } - } - Fl_Group {} { - label Messages - xywh {15 40 680 435} labelfont 1 hide deactivate - } { - Fl_Browser msg_list { - callback msg_select - xywh {25 65 660 270} type Hold - class Fl_Funky_Browser - } - Fl_Button {} { - label {New Msg} - callback msg_dialog_show - xywh {45 350 125 25} - } - Fl_Button {} { - label {Reply to Msg} - callback msg_dialog_reply - xywh {45 380 125 25} - } - Fl_Button {} { - label {(2) -- Get The Recommended File} - callback msg_get_recommendation - xywh {245 450 380 25} labelfont 1 - } - Fl_Button {} { - label {Remove Msg} - callback msg_remove - xywh {45 410 125 25} - } - Fl_Text_Display msg_details { - xywh {180 340 485 105} textfont 5 - } - Fl_Box {} { - label {(1) -- Select Message} - xywh {55 45 305 20} box FLAT_BOX labelfont 1 - } - } - Fl_Group channels { - label Channels - xywh {15 40 680 435} hide deactivate - } { - Fl_Browser channel_list { - callback channel_list_select - xywh {25 80 660 225} type Hold - code0 {\#include "Fl_Funky_Browser.h"} - class Fl_Funky_Browser - } - Fl_Box {} { - label {Available Channels} - xywh {40 61 170 19} labelfont 1 - } - Fl_Group {} {open - xywh {25 310 655 160} box DOWN_BOX - } { - Fl_Browser channel_file_list { - callback channel_file_list_select - xywh {35 345 635 120} - code0 {\#include "Fl_Funky_Browser.h"} - class Fl_Funky_Browser - } - Fl_Output channel_selected_name { - label {Msgs on Channel} - xywh {185 315 270 25} labelfont 1 - } - Fl_Button channel_show_button { - label {Show Msg Details} - callback channel_show_callback - xywh {485 315 160 25} - } - } - Fl_Button channel_delete_button { - label {Delete Channel} - callback channel_delete_callback - xywh {290 50 160 25} - } - Fl_Button channel_create_button { - label {Create Channel Msg} - callback channel_create - xywh {475 50 160 25} - } - } - Fl_Group {} { - label Config - xywh {15 40 680 435} hide - } { - Fl_Group {} {open - xywh {460 55 210 80} box DOWN_BOX hide - } { - Fl_Check_Button config_local_disc { - label {local discovery} - xywh {490 80 145 25} down_box DOWN_BOX - } - Fl_Check_Button config_remote_disc { - label {remote discovery} - xywh {490 100 145 25} down_box DOWN_BOX - } - Fl_Box {} { - label {Discovery Options:} - xywh {470 60 165 20} box FLAT_BOX labelfont 1 - } - } - Fl_Group {} {open - xywh {25 225 405 240} box DOWN_BOX - } { - Fl_Browser config_search_dir { - xywh {40 245 355 105} type Hold - } - Fl_Button {} { - label {Add Directory} - callback config_add_dir - xywh {40 370 135 25} - } - Fl_Button {} { - label {Remove Directory} - callback config_remove_dir - xywh {40 400 135 25} - } - Fl_Output config_save_dir { - label {Save Directory} - xywh {145 435 250 20} - } - Fl_Button {} { - label {Select save directory} - callback config_save_dir_change - xywh {230 405 165 25} - } - Fl_Box {} { - label {Share Directories:} - xywh {41 230 174 15} box FLAT_BOX labelfont 1 - } - } - Fl_Group {} {open - xywh {25 55 405 160} box DOWN_BOX - } { - Fl_Input config_local_addr { - label {Local Address:} - xywh {165 80 130 20} - } - Fl_Value_Input config_local_port { - label {Port:} - xywh {335 80 60 20} - } - Fl_Input config_server_addr { - label {External Address:} - xywh {165 145 130 25} - } - Fl_Value_Input config_server_port { - label {Port:} - xywh {335 145 60 25} - } - Fl_Check_Button config_firewall { - label {behind firewall} - callback config_server_update - xywh {195 100 190 25} down_box DOWN_BOX - } - Fl_Check_Button config_forward { - label {forwarded external port} - callback config_server_update - xywh {195 120 190 25} down_box DOWN_BOX - } - Fl_Box {} { - label {Server Settings:} - xywh {45 60 150 20} box FLAT_BOX labelfont 1 - } - Fl_Button config_server_button { - label {Change + Restart Server} - callback config_server_change - xywh {185 180 190 25} - } - } - Fl_Button {} { - label {Save Configuration} - callback cert_save_config - xywh {485 434 170 25} - } - } - Fl_Group about_help_tab { - label About - xywh {15 40 680 435} hide - } { - Fl_Help_View help_view { - xywh {25 50 660 415} - } - } - } - Fl_Value_Output onlinecounter { - label {\#Online:} - xywh {100 485 35 20} - } - Fl_Value_Output {} { - label {New Msgs:} - xywh {100 505 35 20} - } - Fl_Button {} { - label Hide - callback gui_quit - xywh {605 490 85 30} - } - Fl_Text_Display {} { - xywh {140 485 360 40} - } - Fl_Button chat_button { - label Chat - callback chat_open_callback - xywh {510 490 85 30} - } - } - Fl_Window msg_dialog { - label {Msg Dialog} - xywh {1 30 580 355} type Double hide - } { - Fl_Check_Browser msg_online { - xywh {20 25 140 215} - } - Fl_Button msg_button_select { - label {Select All/None} - callback msg_toggle_select - xywh {20 240 140 25} - } - Fl_Text_Editor msg_text { - label {(1) -- Enter Message Text:} - xywh {175 25 385 240} labelfont 1 - } - Fl_Output msg_recommend { - label {Recommendation:} - xywh {175 275 385 30} - } - Fl_Button {} { - label {(2) -- Send Msg} - callback msg_send - xywh {245 315 160 30} labelfont 1 - } - Fl_Button {} { - label Cancel - callback msg_dialog_hide - xywh {415 315 115 30} - } - } - Fl_Window cert_config { - label {Certificate Configuration} - xywh {168 116 430 535} type Double hide - } { - Fl_Group {} {open - xywh {10 10 410 490} box UP_BOX - } { - Fl_Group {} { - xywh {25 355 380 135} box DOWN_BOX - } { - Fl_Input cert_server { - label {Server Address:} - xywh {155 430 130 25} - } - Fl_Button {} { - label {Save and attempt to Connect} - callback cert_save_n_connect - xywh {165 460 220 25} - } - Fl_Button {} { - label {Save Address} - callback cert_save_servaddr - xywh {35 460 115 25} - } - Fl_Value_Input cert_port { - label {Port:} - xywh {325 430 60 25} - } - Fl_Check_Button cert_connect { - label {Outgoing Connections (Server Address Required)} - callback cert_connect_change - xywh {30 410 365 20} down_box DOWN_BOX - } - Fl_Check_Button cert_allow { - label {Allow Access} - callback cert_allow_change - xywh {30 380 115 20} down_box DOWN_BOX - } - Fl_Check_Button cert_listen { - label {Listen for connection} - callback cert_listen_change - xywh {30 395 170 20} down_box DOWN_BOX - } - Fl_Check_Button cert_local { - label {Local Network} - callback cert_local_change - xywh {220 385 130 20} down_box DOWN_BOX - } - Fl_Check_Button cert_auto { - label {Auto Connect} - callback cert_auto_change - xywh {220 362 140 20} down_box DOWN_BOX labelfont 1 - } - Fl_Box {} { - label {Connectivity Options:} - xywh {32 363 190 20} box FLAT_BOX labelfont 1 - } - } - Fl_Output cert_status { - label {Status:} - xywh {80 20 130 25} - } - Fl_Text_Display cert_details { - xywh {25 50 380 210} - } - Fl_Group {} { - xywh {25 267 380 82} box DOWN_BOX - } { - Fl_Button cert_sign_button { - label {Sign Certificate} - callback cert_sign - xywh {239 295 145 29} - } - Fl_Check_Button cert_trust_person { - label {Trust This Person's Signature} - callback cert_trust_person_change - xywh {95 323 230 25} down_box DOWN_BOX - } - Fl_Input cert_authcode { - label {AUTH CODE:} - callback cert_auth_callback - xywh {145 295 80 28} labelfont 1 when 1 - } - Fl_Box {} { - label {Authenticate Friend By Entering Their Code} - xywh {35 272 360 20} box FLAT_BOX labelfont 1 - } - } - Fl_Output cert_trust { - label {Trust:} - xywh {260 20 140 25} - } - } - Fl_Button {} { - label Done - callback cert_hide_config - xywh {305 505 100 25} - } - } - Fl_Window {} { - xywh {-32000 -32000 360 290} type Double hide - } { - Fl_Group file_chooser { - callback file_chooser_select open - xywh {5 5 350 280} - code0 {\#include } - class Fl_File_Chooser - } {} - } - Fl_Window welcome_window { - label {RetroShare Setup} - xywh {618 195 405 580} type Double hide - } { - Fl_Group {} {open - xywh {10 10 385 35} box DOWN_BOX - } { - Fl_Box {} { - label {Welcome to RetroShare} - xywh {85 15 230 20} box FLAT_BOX labelfont 1 labelsize 16 - } - } - Fl_Group {} {open - xywh {10 55 385 140} box DOWN_BOX - } { - Fl_Box {} { - label {Please login ....} - xywh {75 65 285 20} box FLAT_BOX labelfont 1 - } - Fl_Output load_name { - label {Name:} - xywh {90 90 250 25} - } - Fl_Input load_passwd { - label Password - callback load_passwd_callback - xywh {90 125 250 25} type Secret when 8 - } - Fl_Button load_button { - label {Load Existing User} - callback load_existing - xywh {110 160 210 30} - } - } - Fl_Group {} {open - xywh {10 205 385 365} box DOWN_BOX - } { - Fl_Box {} { - label {Or create a New User...} - xywh {55 210 300 20} box FLAT_BOX labelfont 1 - } - Fl_Group {} { - xywh {50 360 300 5} box UP_BOX - } {} - Fl_Group {} { - xywh {50 440 300 5} box UP_BOX - } {} - Fl_Group {} { - xywh {50 511 300 5} box UP_BOX - } {} - Fl_Input gen_name { - label {Name:} - xywh {120 235 250 25} - } - Fl_Input gen_org { - label {Organisation:} - xywh {120 265 250 25} - } - Fl_Input gen_loc { - label {Location:} - xywh {120 295 250 25} - } - Fl_Input gen_country { - label {Country:} - xywh {120 325 250 25} - } - Fl_Input gen_passwd { - label {New Password} - xywh {170 375 130 25} type Secret - } - Fl_Input gen_passwd2 { - label {Password (Again)} - xywh {170 405 130 25} type Secret - } - Fl_Check_Button gen_trusted_tick_box { - label {Load Trusted Certificate (Optional)} - callback gen_trusted_tick_callback - xywh {50 450 305 20} down_box DOWN_BOX labelfont 1 - } - Fl_Output gen_trusted_peer { - label {Friend:} - xywh {105 474 135 25} - } - Fl_Button gen_trusted_select_button { - label {Select File} - callback gen_load_trusted - xywh {252 470 93 30} - } - Fl_Button gen_button { - label {Generate New Certificate} - callback generate_certificate - xywh {100 528 210 30} - } - } - } - Fl_Window chatter_window { - label ChatterBox - xywh {457 94 455 435} type Double hide - } { - Fl_Text_Display chatter_box { - xywh {5 10 445 370} - } - Fl_Input chatter_input { - callback chatterbox_message - xywh {5 390 445 40} when 8 - } - } - Fl_Window alert_window { - label Alerts - xywh {46 543 540 200} type Double hide - } { - Fl_Return_Button alert_okay { - label OK - callback alert_okay_msg - xywh {75 175 180 20} - } - Fl_Text_Display alert_box { - xywh {15 5 515 165} - } - Fl_Button alert_cancel { - label Cancel - callback alert_cancel_msg - xywh {270 175 180 20} labelfont 3 labelsize 16 labelcolor 80 - } - } - Fl_Window channel_create_window { - label {Create New Channel Msg} - xywh {30 127 460 535} type Double hide - } { - Fl_Browser chan_createmsg_filelist { - callback chan_createmsg_list_select - xywh {10 195 440 265} type Hold - code0 {\#include "Fl_Funky_Browser.h"} - class Fl_Funky_Browser - } - Fl_Button chan_createmsg_sendmsg_button { - label {Send Msg} - callback chan_createmsg_sendmsg_callback - xywh {25 500 125 25} - } - Fl_Button chan_createmsg_postpone_button { - label {Postpone Msg} - callback chan_createmsg_postpone_callback - xywh {165 500 125 25} - } - Fl_Button chan_createmsg_cancel_button { - label {Cancel Msg} - callback chan_createmsg_cancel_callback - xywh {305 500 125 25} - } - Fl_Text_Editor chan_createmsg_msg { - xywh {10 110 440 75} - } - Fl_Box {} { - label {Message Text:} - xywh {10 91 135 19} labelfont 1 - } - Fl_Button chan_createmsg_remove_button { - label {Remove File} - callback chan_createmsg_remove_callback - xywh {305 470 125 25} - } - Fl_Group {} { - xywh {10 5 440 80} box DOWN_BOX - } { - Fl_Input chan_createmsg_newname { - callback chan_createmsg_newname_callback - xywh {155 50 280 25} - } - Fl_Output chan_createmsg_title { - xywh {155 15 280 25} - } - Fl_Round_Button chan_createmsg_newname_button { - label {Create Channel} - callback chan_createmsg_newname_button_callback - xywh {20 55 135 20} type Radio down_box ROUND_DOWN_BOX - } - Fl_Round_Button chan_createmsg_title_button { - label {Active Channel} - callback chan_createmsg_title_button_callback - xywh {20 15 135 20} type Radio down_box ROUND_DOWN_BOX - } - Fl_Box {} { - label OR - xywh {45 33 70 22} labelfont 3 - } - } - } - Fl_Window channel_details_window { - label {Channel Msg Details} - xywh {714 557 460 445} type Double hide - } { - Fl_Browser chan_msgdetails_filelist { - callback chan_msgdetails_list_select - xywh {10 146 440 255} type Hold - code0 {\#include "Fl_Funky_Browser.h"} - class Fl_Funky_Browser - } - Fl_Button chan_msgdetails_download_button { - label {Download Files} - callback chan_msgdetails_download_callback - xywh {165 410 125 25} - } - Fl_Box {} { - label {Message Text:} - xywh {10 42 135 19} labelfont 1 - } - Fl_Button chan_msgdetails_subscribe_button { - label {Subscribe } - callback chan_msgdetails_subscribe_callback - xywh {25 410 125 25} - } - Fl_Output chan_msgdetails_title { - label Channel - xywh {75 10 210 25} labelfont 1 - } - Fl_Text_Display chan_msgdetails_msg { - xywh {10 61 440 75} - } - Fl_Output chan_msgdetails_date { - label Date - xywh {330 10 120 25} labelfont 1 - } - Fl_Button chan_msgdetails_close_button { - label {Close WIndow} - callback chan_msgdetails_close_callback - xywh {305 410 125 25} - } - } - } -} diff --git a/libretroshare/src/fltkgui/guitab.h b/libretroshare/src/fltkgui/guitab.h deleted file mode 100644 index ef65bca78..000000000 --- a/libretroshare/src/fltkgui/guitab.h +++ /dev/null @@ -1,226 +0,0 @@ -// generated by Fast Light User Interface Designer (fluid) version 1.0107 - -#ifndef guitab_h -#define guitab_h -#include -#include -#include -#include -#include -extern void file_import(Fl_Button*, void*); -#include "Fl_Tree_Browser.h" -#include "Fl_Funky_Browser.h" -extern void cert_neighbour_list_select(Fl_Funky_Browser*, void*); -extern void cert_move_to_friends(Fl_Button*, void*); -#include -#include -extern void neigh_auth_callback(Fl_Input*, void*); -#include -extern void cert_neigh_signers_select(Fl_Browser*, void*); -#include -extern void cert_remove_cert(Fl_Button*, void*); -extern void cert_show_config(Fl_Button*, void*); -extern void cert_list_select(Fl_Funky_Browser*, void*); -extern void file_export(Fl_Button*, void*); -#include -extern void file_result_select(Fl_File_Browser*, void*); -extern void file_download(Fl_Button*, void*); -extern void file_recommend(Fl_Button*, void*); -extern void file_channel_broadcast(Fl_Button*, void*); -extern void do_new_search(Fl_Input*, void*); -extern void search_remove(Fl_Button*, void*); -extern void search_recommend(Fl_Button*, void*); -extern void search_result_select(Fl_Funky_Browser*, void*); -extern void do_search_button(Fl_Button*, void*); -extern void search_download(Fl_Button*, void*); -extern void search_channel_broadcast(Fl_Button*, void*); -extern void transfer_select(Fl_Funky_Browser*, void*); -extern void file_transfer_cancel(Fl_Button*, void*); -extern void file_transfer_clear(Fl_Button*, void*); -#include -#include -extern void file_transfer_total_rate(Fl_Counter*, void*); -extern void file_transfer_indiv_rate(Fl_Counter*, void*); -extern void msg_select(Fl_Funky_Browser*, void*); -extern void msg_dialog_show(Fl_Button*, void*); -extern void msg_dialog_reply(Fl_Button*, void*); -extern void msg_get_recommendation(Fl_Button*, void*); -extern void msg_remove(Fl_Button*, void*); -extern void channel_list_select(Fl_Funky_Browser*, void*); -extern void channel_file_list_select(Fl_Funky_Browser*, void*); -extern void channel_show_callback(Fl_Button*, void*); -extern void channel_delete_callback(Fl_Button*, void*); -extern void channel_create(Fl_Button*, void*); -#include -extern void config_add_dir(Fl_Button*, void*); -extern void config_remove_dir(Fl_Button*, void*); -extern void config_save_dir_change(Fl_Button*, void*); -#include -extern void config_server_update(Fl_Check_Button*, void*); -extern void config_server_change(Fl_Button*, void*); -extern void cert_save_config(Fl_Button*, void*); -#include -#include -extern void gui_quit(Fl_Button*, void*); -extern void chat_open_callback(Fl_Button*, void*); -#include -extern void msg_toggle_select(Fl_Button*, void*); -#include -extern void msg_send(Fl_Button*, void*); -extern void msg_dialog_hide(Fl_Button*, void*); -extern void cert_save_n_connect(Fl_Button*, void*); -extern void cert_save_servaddr(Fl_Button*, void*); -extern void cert_connect_change(Fl_Check_Button*, void*); -extern void cert_allow_change(Fl_Check_Button*, void*); -extern void cert_listen_change(Fl_Check_Button*, void*); -extern void cert_local_change(Fl_Check_Button*, void*); -extern void cert_auto_change(Fl_Check_Button*, void*); -extern void cert_sign(Fl_Button*, void*); -extern void cert_trust_person_change(Fl_Check_Button*, void*); -extern void cert_auth_callback(Fl_Input*, void*); -extern void cert_hide_config(Fl_Button*, void*); -#include -extern void file_chooser_select(Fl_File_Chooser*, void*); -extern void load_passwd_callback(Fl_Input*, void*); -extern void load_existing(Fl_Button*, void*); -extern void gen_trusted_tick_callback(Fl_Check_Button*, void*); -extern void gen_load_trusted(Fl_Button*, void*); -extern void generate_certificate(Fl_Button*, void*); -extern void chatterbox_message(Fl_Input*, void*); -#include -extern void alert_okay_msg(Fl_Return_Button*, void*); -extern void alert_cancel_msg(Fl_Button*, void*); -extern void chan_createmsg_list_select(Fl_Funky_Browser*, void*); -extern void chan_createmsg_sendmsg_callback(Fl_Button*, void*); -extern void chan_createmsg_postpone_callback(Fl_Button*, void*); -extern void chan_createmsg_cancel_callback(Fl_Button*, void*); -extern void chan_createmsg_remove_callback(Fl_Button*, void*); -extern void chan_createmsg_newname_callback(Fl_Input*, void*); -#include -extern void chan_createmsg_newname_button_callback(Fl_Round_Button*, void*); -extern void chan_createmsg_title_button_callback(Fl_Round_Button*, void*); -extern void chan_msgdetails_list_select(Fl_Funky_Browser*, void*); -extern void chan_msgdetails_download_callback(Fl_Button*, void*); -extern void chan_msgdetails_subscribe_callback(Fl_Button*, void*); -extern void chan_msgdetails_close_callback(Fl_Button*, void*); - -class UserInterface { -public: - Fl_Double_Window* make_windows(); - Fl_Double_Window *main_win; - Fl_Tabs *gui_tabs; - Fl_Group *neighbours_tab; - Fl_Funky_Browser *cert_neighbour_list; - Fl_Button *neigh_add_button; - Fl_Input *neigh_authcode; - Fl_Browser *neigh_signers; - Fl_Output *neigh_name; - Fl_Output *neigh_org; - Fl_Output *neigh_loc; - Fl_Output *neigh_country; - Fl_Output *neigh_trust; - Fl_Box *neigh_auth_notice; - Fl_Group *connect_tab; - Fl_Funky_Browser *cert_list; - Fl_Widget *file_results; - Fl_Button *file_download_button; - Fl_Button *file_recommend_button; - Fl_Button *file_channel_button; - Fl_Input *new_search; - Fl_Button *recommend_button; - Fl_Funky_Browser *srch_results; - Fl_Button *search_button; - Fl_Button *download_button; - Fl_Button *search_channel_button; - Fl_Funky_Browser *transfer_downloads; - Fl_Button *transfer_cancel; - Fl_Button *transfer_clear; - Fl_Text_Display *transfer_overview; - Fl_Counter *rate_total; - Fl_Counter *rate_indiv; - Fl_Funky_Browser *msg_list; - Fl_Text_Display *msg_details; - Fl_Group *channels; - Fl_Funky_Browser *channel_list; - Fl_Funky_Browser *channel_file_list; - Fl_Output *channel_selected_name; - Fl_Button *channel_show_button; - Fl_Button *channel_delete_button; - Fl_Button *channel_create_button; - Fl_Check_Button *config_local_disc; - Fl_Check_Button *config_remote_disc; - Fl_Browser *config_search_dir; - Fl_Output *config_save_dir; - Fl_Input *config_local_addr; - Fl_Value_Input *config_local_port; - Fl_Input *config_server_addr; - Fl_Value_Input *config_server_port; - Fl_Check_Button *config_firewall; - Fl_Check_Button *config_forward; - Fl_Button *config_server_button; - Fl_Group *about_help_tab; - Fl_Help_View *help_view; - Fl_Value_Output *onlinecounter; - Fl_Button *chat_button; - Fl_Double_Window *msg_dialog; - Fl_Check_Browser *msg_online; - Fl_Button *msg_button_select; - Fl_Text_Editor *msg_text; - Fl_Output *msg_recommend; - Fl_Double_Window *cert_config; - Fl_Input *cert_server; - Fl_Value_Input *cert_port; - Fl_Check_Button *cert_connect; - Fl_Check_Button *cert_allow; - Fl_Check_Button *cert_listen; - Fl_Check_Button *cert_local; - Fl_Check_Button *cert_auto; - Fl_Output *cert_status; - Fl_Text_Display *cert_details; - Fl_Button *cert_sign_button; - Fl_Check_Button *cert_trust_person; - Fl_Input *cert_authcode; - Fl_Output *cert_trust; - Fl_File_Chooser *file_chooser; - Fl_Double_Window *welcome_window; - Fl_Output *load_name; - Fl_Input *load_passwd; - Fl_Button *load_button; - Fl_Input *gen_name; - Fl_Input *gen_org; - Fl_Input *gen_loc; - Fl_Input *gen_country; - Fl_Input *gen_passwd; - Fl_Input *gen_passwd2; - Fl_Check_Button *gen_trusted_tick_box; - Fl_Output *gen_trusted_peer; - Fl_Button *gen_trusted_select_button; - Fl_Button *gen_button; - Fl_Double_Window *chatter_window; - Fl_Text_Display *chatter_box; - Fl_Input *chatter_input; - Fl_Double_Window *alert_window; - Fl_Return_Button *alert_okay; - Fl_Text_Display *alert_box; - Fl_Button *alert_cancel; - Fl_Double_Window *channel_create_window; - Fl_Funky_Browser *chan_createmsg_filelist; - Fl_Button *chan_createmsg_sendmsg_button; - Fl_Button *chan_createmsg_postpone_button; - Fl_Button *chan_createmsg_cancel_button; - Fl_Text_Editor *chan_createmsg_msg; - Fl_Button *chan_createmsg_remove_button; - Fl_Input *chan_createmsg_newname; - Fl_Output *chan_createmsg_title; - Fl_Round_Button *chan_createmsg_newname_button; - Fl_Round_Button *chan_createmsg_title_button; - Fl_Double_Window *channel_details_window; - Fl_Funky_Browser *chan_msgdetails_filelist; - Fl_Button *chan_msgdetails_download_button; - Fl_Button *chan_msgdetails_subscribe_button; - Fl_Output *chan_msgdetails_title; - Fl_Text_Display *chan_msgdetails_msg; - Fl_Output *chan_msgdetails_date; - Fl_Button *chan_msgdetails_close_button; -}; -#endif diff --git a/libretroshare/src/fltkgui/pqibrowseitem.cc b/libretroshare/src/fltkgui/pqibrowseitem.cc deleted file mode 100644 index 89d659f94..000000000 --- a/libretroshare/src/fltkgui/pqibrowseitem.cc +++ /dev/null @@ -1,996 +0,0 @@ -/* - * "$Id: pqibrowseitem.cc,v 1.11 2007-02-18 21:46:49 rmf24 Exp $" - * - * FltkGUI for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - -#include "fltkgui/pqibrowseitem.h" - -#include "pqi/pqichannel.h" /* for mode bits */ - - -// for a helper fn. -#include "fltkgui/pqistrings.h" -#include - - - // a couple of functions that do the work. -int FileDisItem::ndix() // Number of Indices. -{ - return 4; -} - -static const int FI_COL_SOURCE_NAME = 0; -static const int FI_COL_SEARCH_TERMS = 1; -static const int FI_COL_NAME = 2; -static const int FI_COL_SIZE = 3; - -std::string FileDisItem::txt(int col) -{ - char numstr[100]; // this will be used regularly.... - std::string out; - switch(col) - { - case FI_COL_SOURCE_NAME: - if ((item -> p) != NULL) - { - out = item -> p -> Name(); - //std::cerr << "FDI::txt() Returning sn: " << out << std::endl; - return out; - } - return std::string("Local"); - //std::cerr << "FDI::txt() person = NULL" << std::endl; - break; - case FI_COL_SEARCH_TERMS: - if (terms != NULL) - { - out = terms -> data; - //std::cerr << "FDI::txt() Returning terms: " << out << std::endl; - return out; - } - //std::cerr << "FDI::txt() terms = NULL" << std::endl; - break; - case FI_COL_NAME: - out = item -> name; - //std::cerr << "FDI::txt() Returning name: " << out << std::endl; - return out; - break; - case FI_COL_SIZE: - sprintf(numstr, "%d kB", item -> size / 1000); - out = numstr; - //std::cerr << "FDI::txt() Returning size: " << out << std::endl; - return out; - break; - default: - break; - } - out = ""; - return out; -} - -int FileDisItem::cmp(int col, DisplayData *fdi) -{ - FileDisItem *other = (FileDisItem *) fdi; - int ret = 0; - switch(col) - { - case FI_COL_SOURCE_NAME: - // std::cerr << "FileDisItem::cmp() SRC NAME" << std::endl; - if (item -> p == - other -> item -> p) - { - ret = 0; - break; - } - if (item -> p == NULL) - { - ret = -1; - break; - } - if (other -> item -> p == NULL) - { - ret = 1; - break; - } - ret = strcmp((item -> p -> Name()).c_str(), - (other -> item -> p -> Name()).c_str()); - break; - case FI_COL_SEARCH_TERMS: - // std::cerr << "FileDisItem::cmp() TERMS" << std::endl; - if (terms == other -> terms) - { - ret = 0; - break; - } - if (terms == NULL) - { - ret = -1; - break; - } - if (other -> terms == NULL) - { - ret = 1; - break; - } - ret = strcmp((terms -> data).c_str(), - (other -> terms -> data).c_str()); - break; - case FI_COL_NAME: - // std::cerr << "FileDisItem::cmp() NAME" << std::endl; - ret = strcmp((item -> name).c_str(), - (other -> item -> name).c_str()); - break; - case FI_COL_SIZE: - // std::cerr << "FileDisItem::cmp() SIZE" << std::endl; - if (item -> size == other -> item -> size) - { - ret = 0; - break; - } - if (item -> size > other -> item -> size) - { - ret = 1; - break; - } - ret = -1; - break; - default: - // std::cerr << "FileDisItem::cmp() Default" << std::endl; - ret = 0; - break; - } - //std::cerr << "FileDisItem::cmp() ret: " << ret << std::endl; - return ret; -} - - - - // a couple of functions that do the work. -int PersonDisItem::ndix() // Number of Indices. -{ - return 5; -} - -static const int PI_COL_NAME = 0; -static const int PI_COL_STATUS = 1; -static const int PI_COL_AUTOCONNECT = 2; -static const int PI_COL_TRUST = 3; -static const int PI_COL_SERVER = 4; - -std::string PersonDisItem::txt(int col) -{ - char numstr[100]; // this will be used regularly.... - std::string out; - if (item == NULL) - return out; - - switch(col) - { - case PI_COL_NAME: - out = item -> Name(); - break; - case PI_COL_STATUS: - out = get_status_string(item -> Status()); - break; - case PI_COL_AUTOCONNECT: - out = get_autoconnect_string(item); - break; - case PI_COL_TRUST: - out = get_trust_string(item); - break; - case PI_COL_SERVER: - out = get_server_string(item); - break; - default: - break; - } - return out; -} - -int PersonDisItem::cmp(int col, DisplayData *fdi) -{ - PersonDisItem *other = (PersonDisItem *) fdi; - switch(col) - { - case PI_COL_NAME: - return strcmp((item -> Name()).c_str(), - (other -> item -> Name()).c_str()); - break; - case PI_COL_STATUS: - if (item -> Connected() == - other -> item -> Connected()) - { - if (item -> Accepted() == - other -> item -> Accepted()) - { - return 0; - } - if (item -> Accepted()) - return -1; - return 1; - } - if (item -> Connected()) - return -1; - return 1; - break; - - case PI_COL_AUTOCONNECT: - return 0; - break; - case PI_COL_TRUST: - return other->item->trustLvl - item->trustLvl; - break; - case PI_COL_SERVER: - return 0; - break; - default: - return 0; - break; - } - return 0; -} - - - // a couple of functions that do the work. -int NeighDisItem::ndix() // Number of Indices. -{ - return 3; -} - -static const int NI_COL_STATUS = 0; -static const int NI_COL_TRUST = 1; -static const int NI_COL_CONNECT = 2; -static const int NI_COL_NAME = 3; - -std::string NeighDisItem::txt(int col) -{ - char numstr[100]; // this will be used regularly.... - std::string out; - if (item == NULL) - return out; - - switch(col) - { - - case NI_COL_STATUS: - if (item->Accepted()) - { - out = "Accept"; - } - else - { - out = "Deny"; - } - break; - case NI_COL_TRUST: - out = get_trust_string(item); - break; - case NI_COL_CONNECT: - out = get_lastconnecttime_string(item); - break; - case NI_COL_NAME: - out = item -> Name(); - break; - default: - break; - } - return out; -} - -int NeighDisItem::cmp(int col, DisplayData *fdi) -{ - NeighDisItem *other = (NeighDisItem *) fdi; - switch(col) - { - case NI_COL_STATUS: - if (item -> Accepted() == - other -> item -> Accepted()) - { - return 0; - } - if (item -> Accepted()) - return 1; - return -1; - break; - - case NI_COL_TRUST: - return other->item->trustLvl - item->trustLvl; - break; - case NI_COL_CONNECT: - return get_lastconnecttime(item) - - get_lastconnecttime(other->item); - break; - case NI_COL_NAME: - return strcmp((item -> Name()).c_str(), - (other -> item -> Name()).c_str()); - break; - default: - return 0; - break; - } - return 0; -} - - - - // a couple of functions that do the work. -int MsgDisItem::ndix() // Number of Indices. -{ - return 5; -} - -static const int MI_COL_NAME = 0; -static const int MI_COL_MSG = 1; -static const int MI_COL_DATE = 2; -static const int MI_COL_REC_NAME = 3; -static const int MI_COL_REC_SIZE = 4; - -std::string MsgDisItem::txt(int col) -{ - char numstr[100]; // this will be used regularly.... - std::string out; - switch(col) - { - case MI_COL_NAME: - if ((item -> p) != NULL) - { - out = item -> p -> Name(); - return out; - } - return std::string("Local"); - break; - case MI_COL_MSG: - out = ""; - // remove \n and \t... - for(unsigned int i =0; i < item -> msg.length(); i++) - { - if ((item -> msg[i] == '\n') || - (item -> msg[i] == '\t')) - { - out += " "; - } - else - { - out += item -> msg[i]; - } - } - return out; - break; - case MI_COL_DATE: - out = timeFormat(item->epoch, TIME_FORMAT_OLDVAGUE); - //out = "Today!"; - return out; - break; - case MI_COL_REC_NAME: - out = item -> recommendname; - return out; - break; - case MI_COL_REC_SIZE: - //sprintf(numstr, "%d kB", item -> recommendsize / 1000); - //out = numstr; - out = "N/A"; - return out; - break; - default: - break; - } - out = ""; - return out; -} - -int MsgDisItem::cmp(int col, DisplayData *fdi) -{ - MsgDisItem *other = (MsgDisItem *) fdi; - switch(col) - { - case MI_COL_NAME: - if (item -> p == - other -> item -> p) - { - return 0; - } - if (item -> p == NULL) - { - return -1; - } - if (other -> item -> p == NULL) - { - return 1; - } - return strcmp((item -> p -> Name()).c_str(), - (other -> item -> p -> Name()).c_str()); - break; - - case MI_COL_MSG: - return strcmp((item -> msg).c_str(), - (other -> item -> msg).c_str()); - break; - case MI_COL_DATE: - return 0; - break; - case MI_COL_REC_NAME: - return strcmp((item -> recommendname).c_str(), - (other -> item -> recommendname).c_str()); - break; - case MI_COL_REC_SIZE: - return 0; -// if (item -> recommend_size == -// other -> item -> recommend_size) -// { -// return 0; -// } -// if (item -> recommend_size > -// other -> item -> recommend_size) -// { -// return 1; -// } -// return -1; - break; - default: - return 0; - break; - } - return 0; -} - - - // a couple of functions that do the work. -int FTDisItem::ndix() // Number of Indices. -{ - return 5; -} - -static const int FT_COL_SOURCE_NAME = 0; -static const int FT_COL_DIRECTION = 1; -static const int FT_COL_FILE_NAME = 2; -static const int FT_COL_FILE_SIZE = 3; -static const int FT_COL_FILE_RATE = 4; - - -static const int SEC_PER_DAY = 24 * 3600; - -std::string FTDisItem::txt(int col) -{ - char numstr[100]; // this will be used regularly.... - std::string out; - switch(col) - { - case FT_COL_SOURCE_NAME: - if ((item -> p) != NULL) - { - out = item -> p -> Name(); - return out; - } - return std::string("Unknown"); - break; - - case FT_COL_DIRECTION: /* This has now become state.... */ - switch(item -> state) - { - case FT_STATE_OKAY: - if (item->crate > 0) - { - out += "Downloading"; - } - else - { - out += "Waiting"; - } - break; - case FT_STATE_FAILED: - out += "Failed"; - break; - case FT_STATE_COMPLETE: - out += "Complete"; - break; - default: - out += "UNKNOWN"; - break; - } - return out; - break; - - case FT_COL_FILE_NAME: - out = item -> name; - return out; - break; - - case FT_COL_FILE_SIZE: - { - - float trans = item -> transferred; - float size = item -> size; - float percent = 100 * trans / size; - char lets[] = "kMGT"; - char let = ' '; - - // if bigger than 50 kbytes -> display - for(int i = 0; (i < 4) && (size / 1024 > 1); i++) - { - size /= 1024; - trans /= 1024; - let = lets[i]; - } - sprintf(numstr, "%.2f/%.2f %cBytes (%.2f%%)", - trans, size, let, percent); - - out = numstr; - return out; - } - break; - - case FT_COL_FILE_RATE: - if (item->size == item->transferred) - { - sprintf(numstr, "Done"); - } - else if (item->crate > 0.01) /* 10 bytes / sec */ - { - float secs = item->size - item->transferred; - secs /= (item -> crate * 1000.0); - - - if (secs > SEC_PER_DAY) - { - sprintf(numstr, "%.2f kB/s, %d days to go.", item -> crate, - (int) (secs + SEC_PER_DAY / 2) / SEC_PER_DAY); - } - else - { - int hours = (int) secs / 3600; - secs -= 3600 * hours; - int min = (int) secs / 60; - secs -= 60 * min; - sprintf(numstr, "%.2f kB/s, %d:%02d:%02d to go.", item -> crate, - hours, min, (int) secs); - } - } - else - { - sprintf(numstr, "%.2f kB/s, ... Forever", item -> crate); - - } - out = numstr; - return out; - break; - default: - break; - } - out = ""; - return out; -} - -int FTDisItem::cmp(int col, DisplayData *fdi) -{ - FTDisItem *other = (FTDisItem *) fdi; - switch(col) - { - case FT_COL_SOURCE_NAME: - if (item -> p == - other -> item -> p) - { - return 0; - } - if (item -> p == NULL) - { - return -1; - } - if (other -> item -> p == NULL) - { - return 1; - } - return strcmp((item -> p -> Name()).c_str(), - (other -> item -> p -> Name()).c_str()); - break; - case FT_COL_DIRECTION: - if (item -> in == other -> item -> in) - { - return 0; - } - if (item -> in == true) - { - return 1; - } - return -1; - break; - - case FT_COL_FILE_NAME: - return strcmp((item -> name).c_str(), - (other -> item -> name).c_str()); - break; - case FT_COL_FILE_SIZE: - if (item -> size == other -> item -> size) - { - return 0; - } - if (item -> size > other -> item -> size) - { - return 1; - } - return -1; - break; - - case FT_COL_FILE_RATE: - if (item -> crate == other -> item -> crate) - { - return 0; - } - if (item -> crate > other -> item -> crate) - { - return 1; - } - return -1; - break; - default: - return 0; - break; - } - return 0; -} - - - // a couple of functions that do the work. -int ChanDisItem::ndix() // Number of Indices. -{ - return 5; -} - - -static const int CDI_COL_MODE = 0; -static const int CDI_COL_RANK = 1; -static const int CDI_COL_TITLE = 2; -static const int CDI_COL_COUNT = 3; -static const int CDI_COL_SIGN = 4; - -ChanDisItem::ChanDisItem(pqichannel *i) - :mode(0), name("NULL CHANNEL") -{ - if (!i) - { - mode = -1; - return; - } - - cs = i->getSign(); - mode = i->getMode(); - name = i->getName(); - ranking = i->getRanking(); - msgcount = i->getMsgCount(); - return; -} - - -std::string ChanDisItem::txt(int col) -{ - char numstr[100]; // this will be used regularly.... - std::ostringstream out; - switch(col) - { - case CDI_COL_MODE: - { - if (mode == -1) - { - out << "Invalid"; - } - else if (mode & 0x040) - { - out << "Publisher"; - } - else if (mode & 0x020) - { - out << "Subscriber"; - } - else if (mode & 0x010) - { - out << "Listener"; - } - else - { - out << "Other"; - } - - return out.str(); - } - break; - - case CDI_COL_RANK: - { - out << ranking; - return out.str(); - } - break; - - case CDI_COL_TITLE: - { - return name; - } - break; - - - case CDI_COL_COUNT: - { - out << msgcount; - return out.str(); - } - break; - - case CDI_COL_SIGN: - { - cs.printHex(out); - return out.str(); - } - return std::string(""); - break; - - - default: - break; - } - return out.str(); -} - - -int ChanDisItem::cmp(int col, DisplayData *fdi) -{ - ChanDisItem *other = (ChanDisItem *) fdi; - switch(col) - { - case CDI_COL_MODE: - { - return mode - other->mode; - } - case CDI_COL_RANK: - { - return (int) (100.0 * (ranking - other->ranking)); - } - case CDI_COL_TITLE: - { - return strcmp(name.c_str(), other->name.c_str()); - } - case CDI_COL_COUNT: - { - return msgcount-other->msgcount; - } - break; - case CDI_COL_SIGN: - { - if (cs == other->cs) - return 0; - if (cs < other->cs) - return -1; - return 1; - } - break; - - default: - break; - } - return 0; -} - - - // a couple of functions that do the work. -int ChanMsgDisItem::ndix() // Number of Indices. -{ - return 5; -} - -static const int CMDI_COL_DATE = 0; -static const int CMDI_COL_MSG = 1; -static const int CMDI_COL_NOFILES = 2; -static const int CMDI_COL_SIZE = 3; -static const int CMDI_COL_MSGHASH = 4; - - -ChanMsgDisItem::ChanMsgDisItem(chanMsgSummary &s) - :msg(s.msg), mh(s.mh), nofiles(s.nofiles), - totalsize(s.totalsize), recvd(s.recvd) -{ - /* change \t & \n into " " */ - for(unsigned int i =0; i < msg.length(); i++) - { - if ((msg[i] == '\n') || - (msg[i] == '\t')) - { - msg[i] = ' '; - } - } -} - - -std::string ChanMsgDisItem::txt(int col) -{ - char numstr[100]; // this will be used regularly.... - std::ostringstream out; - switch(col) - { - case CMDI_COL_DATE: - { - int t = time(NULL); - int ago_sec = t - recvd; - out << ago_sec << " secs"; - return out.str(); - } - break; - case CMDI_COL_MSG: - // remove \n and \t... (done at init) - return msg; - break; - case CMDI_COL_NOFILES: - { - out << nofiles; - return out.str(); - } - break; - case CMDI_COL_SIZE: - { - if (totalsize > 1000000) - { - out << (totalsize / 1000000.0) << " MB"; - } - else if (totalsize > 1000) - { - out << (totalsize / 1000.0) << " kB"; - } - else - { - out << totalsize << " B"; - } - - return out.str(); - } - break; - - case CMDI_COL_MSGHASH: - { - mh.printHex(out); - return out.str(); - } - break; - - default: - break; - } - return out.str(); -} - -int ChanMsgDisItem::cmp(int col, DisplayData *fdi) -{ - ChanMsgDisItem *other = (ChanMsgDisItem *) fdi; - switch(col) - { - case CMDI_COL_DATE: - { - return recvd - other->recvd; - } - break; - - case CMDI_COL_MSG: - { - return strcmp(msg.c_str(), - other->msg.c_str()); - } - break; - - case CMDI_COL_NOFILES: - { - return nofiles-other->nofiles; - } - break; - - case CMDI_COL_SIZE: - { - return totalsize-other->totalsize; - } - break; - - case CMDI_COL_MSGHASH: - { - if (mh == other->mh) - return 0; - if (mh < other->mh) - return -1; - return 1; - } - break; - - default: - break; - } - return 0; -} - - -static const int CFDI_COL_SIZE = 0; -static const int CFDI_COL_NAME = 1; - - // a couple of functions that do the work. -int ChanFileDisItem::ndix() // Number of Indices. -{ - return 2; -} - - -ChanFileDisItem::ChanFileDisItem(std::string n, int s) - :name(n), size(s) -{ - return; -} - -std::string ChanFileDisItem::txt(int col) -{ - char numstr[100]; // this will be used regularly.... - std::ostringstream out; - switch(col) - { - case CFDI_COL_SIZE: - { - if (size > 1000000) - { - out << (size / 1000000.0) << " MB"; - } - else if (size > 1000) - { - out << (size / 1000.0) << " kB"; - } - else - { - out << size << " B"; - } - return out.str(); - } - break; - case CFDI_COL_NAME: - return name; - break; - default: - break; - } - return out.str(); -} - -int ChanFileDisItem::cmp(int col, DisplayData *fdi) -{ - ChanFileDisItem *other = (ChanFileDisItem *) fdi; - switch(col) - { - case CFDI_COL_SIZE: - { - return size - other->size; - } - break; - - case CFDI_COL_NAME: - { - return strcmp(name.c_str(), - other->name.c_str()); - } - break; - - default: - break; - } - return 0; -} - diff --git a/libretroshare/src/fltkgui/pqibrowseitem.h b/libretroshare/src/fltkgui/pqibrowseitem.h deleted file mode 100644 index fd1497a9d..000000000 --- a/libretroshare/src/fltkgui/pqibrowseitem.h +++ /dev/null @@ -1,219 +0,0 @@ -/* - * "$Id: pqibrowseitem.h,v 1.7 2007-02-18 21:46:49 rmf24 Exp $" - * - * FltkGUI for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - -#ifndef MRKS_PQI_BROWSER_ITEMS -#define MRKS_PQI_BROWSER_ITEMS - -/* My new funky browser..... - * - * - Designed to sort/display a tree brower - * for search results.... - * - * First we need the basic interface class that - * must wrap the Data.... - */ - -#include "fltkgui/Fl_Funky_Browser.h" -#include "pqi/pqi.h" -#include "pqi/p3channel.h" - -class FileDisItem: public DisplayData -{ - public: - FileDisItem(PQFileItem *i, SearchItem *s) :item(i), terms(s) { return; } - - // a couple of functions that do the work. -virtual int ndix(); // Number of Indices. -virtual std::string txt(int col); -virtual int cmp(int col, DisplayData *); - - PQFileItem *getItem() { return item;} - void setItem(PQFileItem *i) {item = i;} - SearchItem *getSearchItem() { return terms;} - void setSearchItem(SearchItem *s) {terms = s;} - - private: - PQFileItem *item; - SearchItem *terms; -}; - - -class PersonDisItem: public DisplayData -{ - public: - PersonDisItem(Person *i) :item(i), checked(false) { return; } - - // a couple of functions that do the work. -virtual int ndix(); // Number of Indices. -virtual std::string txt(int col); -virtual int cmp(int col, DisplayData *); -virtual int check(int n, int v = -1) - { - if (v == -1) - return (int) checked; - if (v == 0) - return checked = false; - return checked = true; - }; - - Person *getItem() { return item;} - void setItem(Person *i) {item = i;} - - private: - Person *item; - bool checked; -}; - - -class NeighDisItem: public DisplayData -{ - public: - NeighDisItem(Person *i) :item(i) { return; } - - // a couple of functions that do the work. -virtual int ndix(); // Number of Indices. -virtual std::string txt(int col); -virtual int cmp(int col, DisplayData *); - - Person *getItem() { return item;} - void setItem(Person *i) {item = i;} - - private: - Person *item; -}; - - -class MsgDisItem: public DisplayData -{ - public: - MsgDisItem(MsgItem *i) :item(i) { return; } - - // a couple of functions that do the work. -virtual int ndix(); // Number of Indices. -virtual std::string txt(int col); -virtual int cmp(int col, DisplayData *); - - MsgItem *getItem() { return item;} - void setItem(MsgItem *i) {item = i;} - - private: - MsgItem *item; -}; - - -class FTDisItem: public DisplayData -{ - public: - FTDisItem(FileTransferItem *i) :item(i) { return; } - - // a couple of functions that do the work. -virtual int ndix(); // Number of Indices. -virtual std::string txt(int col); -virtual int cmp(int col, DisplayData *); - - FileTransferItem *getItem() { return item;} - void setItem(FileTransferItem *i) {item = i;} - - private: - FileTransferItem *item; -}; - -/* NOTE The Channel classes should be changed to just - * carry the channelSign around.... this is enough - * to refer to the channels.... - * - * don't want pointers to pqichannels.... - */ - -class ChanDisItem: public DisplayData -{ - public: - ChanDisItem(pqichannel *i); - - // a couple of functions that do the work. -virtual int ndix(); // Number of Indices. -virtual std::string txt(int col); -virtual int cmp(int col, DisplayData *); -virtual int check(int n, int v = -1) - { - if (v == -1) - return (int) checked; - if (v == 0) - return checked = false; - return checked = true; - }; - - public: - - channelSign cs; - int mode; - std::string name; - float ranking; - int msgcount; - - bool checked; // subscribed.. -}; - - -class ChanMsgDisItem: public DisplayData -{ - public: - ChanMsgDisItem(chanMsgSummary &s); - - // a couple of functions that do the work. -virtual int ndix(); // Number of Indices. -virtual std::string txt(int col); -virtual int cmp(int col, DisplayData *); - - public: - - std::string msg; - MsgHash mh; - int nofiles; - int totalsize; - long recvd; - -}; - -class ChanFileDisItem: public DisplayData -{ - public: - ChanFileDisItem(std::string n, int s); - - // a couple of functions that do the work. -virtual int ndix(); // Number of Indices. -virtual std::string txt(int col); -virtual int cmp(int col, DisplayData *); - - //private: - std::string name; - int size; -}; - - -#endif - diff --git a/libretroshare/src/fltkgui/pqistrings.cc b/libretroshare/src/fltkgui/pqistrings.cc deleted file mode 100644 index 8db222426..000000000 --- a/libretroshare/src/fltkgui/pqistrings.cc +++ /dev/null @@ -1,745 +0,0 @@ -/* - * "$Id: pqistrings.cc,v 1.11 2007-02-18 21:46:49 rmf24 Exp $" - * - * FltkGUI for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - - -#include "pqi/pqi.h" -#include "pqi/pqinetwork.h" - -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - -#include "pqi/xpgpcert.h" - -#else /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - -#include "pqi/sslcert.h" - -#endif /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - -#include "fltkgui/pqistrings.h" - -#include -#include -#include -#include - -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) -std::string getXPGPInfo(XPGP *cert); -#endif /* XPGP Certificates */ -/**************** PQI_USE_XPGP ******************/ - -std::string get_status_string(int status) -{ - std::string sstr(""); - if (status & PERSON_STATUS_CONNECTED) - { - sstr += "Online"; - return sstr; - } - if (!(status & PERSON_STATUS_ACCEPTED)) - { - sstr += "Denied Access"; - return sstr; - } - - if (status & PERSON_STATUS_INUSE) - { - sstr += "Connecting"; - /* - if (status & PERSON_STATUS_WILL_LISTEN) - { - sstr += "Listening"; - } - sstr += "/"; - if (status & PERSON_STATUS_WILL_CONNECT) - { - sstr += "Connecting"; - } - sstr += "]"; - */ - return sstr; - } - sstr += "Unknown"; - return sstr; -} - - -std::string get_neighbourstatus_string(Person *p) -{ - // if connected - show how long - // if !autoconnected - tick to connect. - // - // if connecting. - // show time to next connect attempt. - // else show the last connect time. - - std::ostringstream connstr; - - connstr << "Last Conn/Recv: "; - int lct = time(NULL) - p -> lc_timestamp; - int lrt = time(NULL) - p -> lr_timestamp; - if (lct < 100000000) - { - connstr << get_timeperiod_string(lct); - } - else - { - connstr << "Never"; - } - connstr << "/"; - if (lrt < 100000000) - { - connstr << get_timeperiod_string(lrt); - } - else - { - connstr << "Never"; - } - - return connstr.str(); -} - - -int get_lastconnecttime(Person *p) -{ - std::ostringstream connstr; - - int lct = time(NULL) - p -> lc_timestamp; - int lrt = time(NULL) - p -> lr_timestamp; - if (lrt < lct) - { - lct = lrt; - } - return lct; -} - -std::string get_lastconnecttime_string(Person *p) -{ - int lct = get_lastconnecttime(p); - if (lct < 32000000) - { - return get_timeperiod_string(lct); - } - else - { - return std::string("Never"); - } -} - - -std::string get_autoconnect_string(Person *p) -{ - // if connected - show how long - // if !autoconnected - tick to connect. - // - // if connecting. - // show time to next connect attempt. - // else show the last connect time. - - std::ostringstream connstr; - - Person *own = getSSLRoot() -> getOwnCert(); - if (p == own) - { - connstr << "Yourself"; - return connstr.str(); - } - - if (p -> Connected()) - { - /* - long ct = p->lc_timestamp; - if (ct < p->lr_timestamp) - ct = p->lr_timestamp; - - connstr << "Online: " << get_timeperiod_string(time(NULL) - ct); - */ - connstr << "Online"; - } - else if (p -> Manual()) - { - if (p->trustLvl < TRUST_SIGN_AUTHEN) - { - connstr << "Please Authenticate"; - } - else - { - connstr << "Tick to Connect"; - } - } - else - { - connstr << "Offline"; - } - - /* - else if (p -> WillConnect()) - { - connstr << "Connect in:"; - connstr << get_timeperiod_string(p->nc_timestamp - time(NULL)); - } - else - { - connstr << "Last Conn:"; - long ct = p->lc_timestamp; - if (ct < p->lr_timestamp) - { - ct = p->lr_timestamp; - connstr << "(I):"; - } - else - { - connstr << "(O):"; - } - connstr << get_timeperiod_string(time(NULL) - ct); - } - */ - - return connstr.str(); -} - - -std::string get_trust_string(Person *p) -{ - std::ostringstream srvstr; - - /* This is now changing to display 2 things. - * - * (1) - Proxy - * (2) - Auth Level. - */ - - Person *own = getSSLRoot() -> getOwnCert(); - if (p == own) - { - srvstr << "Yourself"; // Certificate"; - return srvstr.str(); - } - - switch(p -> trustLvl) - { - case TRUST_SIGN_OWN: - srvstr << "Auth (S)"; //Good: Own Signature"; - break; - case TRUST_SIGN_TRSTED: - srvstr << "Trusted (ST)"; //Good: Trusted Signer"; - break; - case TRUST_SIGN_AUTHEN: - srvstr << "Auth"; //Good: Authenticated"; - break; - case TRUST_SIGN_BASIC: - srvstr << "Untrusted"; // : Acquaintance "; - break; - case TRUST_SIGN_UNTRUSTED: - srvstr << "Unknown (2)"; - break; - case TRUST_SIGN_UNKNOWN: - srvstr << "Unknown (1)"; - break; - case TRUST_SIGN_NONE: - srvstr << "Unknown (0)"; - break; - case TRUST_SIGN_BAD: /* not checked yet */ - srvstr << "Not Avail"; - break; - default: - srvstr << "UNKNOWN"; - break; - } - return srvstr.str(); -} - - - -std::string get_server_string(Person *p) -{ - std::ostringstream srvstr; - - if ((0 == inaddr_cmp(p -> serveraddr, 0)) || (p -> Local())) - { - if (0 == inaddr_cmp(p -> localaddr, 0)) - { - srvstr << "Unknown Addr"; - } - else - { - srvstr << "L: " << inet_ntoa(p -> localaddr.sin_addr); - srvstr << ":" << ntohs(p -> localaddr.sin_port); - } - } - else - { - srvstr << "S: " << inet_ntoa(p -> serveraddr.sin_addr); - srvstr << ":" << ntohs(p -> serveraddr.sin_port); - } - - // need own cert! - Person *own = getSSLRoot() -> getOwnCert(); - - if ((isValidNet(&(p->serveraddr.sin_addr))) && - (!isPrivateNet(&(p->serveraddr.sin_addr))) && - (!sameNet(&(own->localaddr.sin_addr), &(p->serveraddr.sin_addr)))) - { - srvstr << " (Proxy-S) "; - } - else if ((!p->Firewalled()) && (isValidNet(&(p->localaddr.sin_addr))) && - (!isPrivateNet(&(p->localaddr.sin_addr))) && - (!sameNet(&(own->localaddr.sin_addr), &(p->localaddr.sin_addr)))) - { - srvstr << " (Proxy-L) "; - } - return srvstr.str(); -} - -const int sec_per_min = 60; -const int sec_per_hour = 3600; -const int sec_per_day = 3600 * 24; - -std::string get_timeperiod_string(int secs) -{ - - int days = secs / sec_per_day; - secs -= days * sec_per_day; - int hours = secs / sec_per_hour; - secs -= hours * sec_per_hour; - int mins = secs / sec_per_min; - secs -= mins * sec_per_min; - - std::ostringstream srvstr; - - if (days > 0) - { - srvstr << days << " days "; - } - else if (hours > 0) - { - srvstr << hours << ":" << mins << " hours"; - } - else - { - srvstr << mins << ":" << secs << " min"; - } - return srvstr.str(); -} - -std::string get_neighbour_info(cert *c) -{ - std::ostringstream ostr; - -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - ostr << getX509CNString(c -> certificate -> subject -> subject); -#else /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - ostr << getX509CNString(c -> certificate -> cert_info -> subject); -#endif /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - - - ostr << "\t" << get_neighbourstatus_string(c); - return ostr.str(); -} - -std::string get_cert_info(cert *c) -{ - std::ostringstream ostr; - ostr << "************ Certificate **************" << std::endl; -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - ostr << getXPGPInfo(c -> certificate); -#else /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - ostr << getX509Info(c -> certificate); -#endif /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - ostr << "********** Connection Info ************" << std::endl; - ostr << "Local Addr : " << inet_ntoa(c -> localaddr.sin_addr); - ostr << ":" << ntohs(c -> localaddr.sin_port) << std::endl; - ostr << "Server Addr : " << inet_ntoa(c -> serveraddr.sin_addr); - ostr << ":" << ntohs(c -> serveraddr.sin_port) << std::endl; - ostr << "FLAGS: "; - if (!c -> Firewalled()) - { - ostr << "Not "; - } - ostr << "Firewalled, "; - if (!c -> Forwarded()) - { - ostr << "Not "; - } - ostr << "Forwarded" << std::endl; - ostr << std::endl; - - - ostr << "Last Connect Addr: " << inet_ntoa(c -> lastaddr.sin_addr); - ostr << ":" << ntohs(c -> lastaddr.sin_port) << std::endl; - - ostr << "Last Connect Time: "; - ostr << get_timeperiod_string(time(NULL) - c -> lc_timestamp); - ostr << std::endl; - ostr << "Last Receive Time: "; - ostr << get_timeperiod_string(time(NULL) - c -> lr_timestamp); - ostr << std::endl; - ostr << std::endl; - - ostr << "Next Connect in : "; - ostr << get_timeperiod_string(c->nc_timestamp - time(NULL)); - ostr << std::endl; - - ostr << "AutoConnect: " << get_autoconnect_string(c); - ostr << std::endl; - - ostr << "***************************************" << std::endl; - - return ostr.str(); -} - - -std::string getX509Info(X509 *cert) -{ - // Details from the structure - // cert_info (X509_CINF *) - // sig_alg (X509_ALGOR *) - // signature (ASN1_BIT_STRING *) - // valid (int) - // references (int) - // name (char *) - // - // random flags - // - // skid (ASN1_OCTET_STRING *) - // akid (AUTHORITY_KEYID *) - // aux (X509_CERT_AUX *) - std::string certstr; - char numstr[1000]; - - sprintf(numstr, "%ld", ASN1_INTEGER_get(cert -> cert_info -> version)); - certstr += "Version: "; - certstr += numstr; - - sprintf(numstr, "%ld", ASN1_INTEGER_get(cert -> - cert_info -> serialNumber)); - certstr += "\nSerial Number: "; - certstr += numstr; - -// switch(cert -> cert_info -> signature) -// { -// case STANDRD: -// certstr += "\nSig Algorithm: Standard"; -// break; -// default: -// certstr += "\nSig Algorithm: Unknown"; -// break; -// } -// - - - certstr += "\nSubject:\n"; - certstr += getX509NameString(cert -> cert_info -> subject); - - // Validity in Here. cert -> cert_info -> validity; - - certstr += "\nIssuer:\n"; - certstr += getX509NameString(cert -> cert_info -> issuer); - - // Key cert -> cert_info -> key; - // - // IDS + extensions. cert -> cert_info -> issuerUID/subjectUID; - // cert -> cert_info -> extensions; - - // END OF INFO. - - // Next sigalg again? - // next sig... - certstr += "\nSignature:"; - for(int i = 0; i < cert -> signature -> length;) - { - if (i % 128 == 0) - { - certstr += "\n\t"; - } - char hbyte = 0; - for(int j = 0; (j < 4) && (i < cert -> signature -> length); - j++, i++) - { - hbyte = hbyte << 1; - if (ASN1_BIT_STRING_get_bit(cert -> signature, i) == 1) - { - hbyte++; - //std::cerr << "1"; - } - else - { - //std::cerr << "0"; - } - } - if (hbyte > 9) - { - certstr += ('a' + (hbyte - 10)); - } - else - { - certstr += ('0' + hbyte); - } - //std::cerr << " " << i << " " << (char) ('0' + hbyte); - //std::cerr << " " << (int) hbyte << std::endl; - } - - - sprintf(numstr, "%d/%d", cert -> valid, cert -> references); - certstr += "\nValid/References: "; - certstr += numstr; - certstr += "\n"; - - // That will do for now. - return certstr; -} - -/* Helper function to convert a Epoch Timestamp - * into a string. - */ - -static char *TIME_FORMAT_STR_BRIEF = "%H:%M:%S"; -static char *TIME_FORMAT_STR_OLDVAGUE_NOW = "%H:%M:%S"; -static char *TIME_FORMAT_STR_OLDVAGUE_WEEK = "%a %H:%M"; -static char *TIME_FORMAT_STR_OLDVAGUE_OLD = "%a, %d %b"; -static char *TIME_FORMAT_STR_LONG = "%c"; -static char *TIME_FORMAT_STR_NORMAL = "%a, %H:%M:%S"; - -std::string timeFormat(int epoch, int format) -{ - time_t ctime = epoch; - struct tm *stime = localtime(&ctime); - - size_t msize = 1024; - char space[msize]; - char *fmtstr = NULL; - - if (format == TIME_FORMAT_OLDVAGUE) - { - int itime = time(NULL); - int delta = abs(itime - ctime); - if (delta < 12 * 3600) - { - format = TIME_FORMAT_OLDVAGUE_NOW; - } - else if (delta < 3 * 24 * 3600) - { - format = TIME_FORMAT_OLDVAGUE_WEEK; - } - else - { - format = TIME_FORMAT_OLDVAGUE_OLD; - } - } - - switch(format) - { - case TIME_FORMAT_BRIEF: - fmtstr = TIME_FORMAT_STR_BRIEF; - break; - case TIME_FORMAT_OLDVAGUE_NOW: - fmtstr = TIME_FORMAT_STR_OLDVAGUE_NOW; - break; - case TIME_FORMAT_OLDVAGUE_WEEK: - fmtstr = TIME_FORMAT_STR_OLDVAGUE_WEEK; - break; - case TIME_FORMAT_OLDVAGUE_OLD: - fmtstr = TIME_FORMAT_STR_OLDVAGUE_OLD; - break; - case TIME_FORMAT_LONG: - fmtstr = TIME_FORMAT_STR_LONG; - break; - case TIME_FORMAT_NORMAL: - default: - fmtstr = TIME_FORMAT_STR_NORMAL; - break; - } - - if (fmtstr != NULL) // Short -> Only Time. - { - int usize = strftime(space, msize, fmtstr, stime); - if (usize > 0) - return std::string(space); - } - return std::string(""); -} - -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - - -std::string getXPGPInfo(XPGP *cert) -{ - std::stringstream out; - long l; - int i,j; - - out << "XPGP Certificate:" << std::endl; - l=XPGP_get_version(cert); - out << " Version: " << l+1 << "(0x" << l << ")" << std::endl; - out << " Subject: " << std::endl; - out << " " << getX509NameString(cert -> subject -> subject); - out << std::endl; - out << std::endl; - out << " Signatures:" << std::endl; - - for(i = 0; i < sk_XPGP_SIGNATURE_num(cert->signs); i++) - { - out << "Sign[" << i << "] -> ["; - - XPGP_SIGNATURE *sig = sk_XPGP_SIGNATURE_value(cert->signs,i); - ASN1_BIT_STRING *signature = sig->signature; - int signlen = ASN1_STRING_length(signature); - unsigned char *signdata = ASN1_STRING_data(signature); - - /* only show the first 8 bytes */ - if (signlen > 8) - signlen = 8; - for(j=0;jissuer); - out << std::endl; - out << std::endl; - } - - return out.str(); -} - - - -std::string getXPGPAuthCode(XPGP *xpgp) -{ - /* get the self signature -> the first signature */ - - std::stringstream out; - if (1 > sk_XPGP_SIGNATURE_num(xpgp->signs)) - { - out.str(); - } - - XPGP_SIGNATURE *sig = sk_XPGP_SIGNATURE_value(xpgp->signs,0); - ASN1_BIT_STRING *signature = sig->signature; - int signlen = ASN1_STRING_length(signature); - unsigned char *signdata = ASN1_STRING_data(signature); - - /* extract the authcode from the signature */ - /* convert it to a string, inverse of 2 bytes of signdata */ - if (signlen > 2) - signlen = 2; - int j; - for(j=0;j getXPGPsigners(XPGP *cert) -{ - std::list signers; - int i; - - for(i = 0; i < sk_XPGP_SIGNATURE_num(cert->signs); i++) - { - XPGP_SIGNATURE *sig = sk_XPGP_SIGNATURE_value(cert->signs,i); - std::string str = getX509CNString(sig->issuer); - signers.push_back(str); - std::cerr << "XPGPsigners(" << i << ")" << str << std::endl; - } - return signers; -} - - -#endif /* XPGP Certificates */ -/**************** PQI_USE_XPGP ******************/ - - -std::string get_cert_name(cert *c) -{ -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - return getX509CNString(c->certificate->subject -> subject); -#else - return getX509CNString(c->certificate->cert_info -> subject); -#endif /* XPGP Certificates */ -/**************** PQI_USE_XPGP ******************/ -} - -std::string get_cert_org(cert *c) -{ -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - return getX509OrgString(c->certificate->subject -> subject); -#else - return getX509OrgString(c->certificate->cert_info -> subject); -#endif /* XPGP Certificates */ -/**************** PQI_USE_XPGP ******************/ -} - -std::string get_cert_loc(cert *c) -{ -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - return getX509LocString(c->certificate->subject -> subject); -#else - return getX509LocString(c->certificate->cert_info -> subject); -#endif /* XPGP Certificates */ -/**************** PQI_USE_XPGP ******************/ -} - -std::string get_cert_country(cert *c) -{ -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - return getX509CountryString(c->certificate->subject -> subject); -#else - return getX509CountryString(c->certificate->cert_info -> subject); -#endif /* XPGP Certificates */ -/**************** PQI_USE_XPGP ******************/ -} - - - - - diff --git a/libretroshare/src/fltkgui/pqistrings.h b/libretroshare/src/fltkgui/pqistrings.h deleted file mode 100644 index e79cf77ed..000000000 --- a/libretroshare/src/fltkgui/pqistrings.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * "$Id: pqistrings.h,v 1.6 2007-02-18 21:46:49 rmf24 Exp $" - * - * FltkGUI for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - -#ifndef PQI_STRINGS_H -#define PQI_STRINGS_H - -#include -#include - -class Person; -class cert; - -#include - -std::string get_cert_country(cert *c); -std::string get_cert_loc(cert *c); -std::string get_cert_org(cert *c); -std::string get_cert_name(cert *c); - -std::string get_status_string(int status); -std::string get_autoconnect_string(Person *p); -std::string get_server_string(Person *p); -std::string get_trust_string(Person *p); -std::string get_timeperiod_string(int secs); - -std::string get_cert_info(cert *c); -std::string get_neighbour_info(cert *c); - -int get_lastconnecttime(Person *p); -std::string get_lastconnecttime_string(Person *p); - -std::string getX509NameString(X509_NAME *name); -std::string getX509Info(X509 *cert); -std::string getX509CNString(X509_NAME *name); - -#define TIME_FORMAT_BRIEF 0x001 -#define TIME_FORMAT_LONG 0x002 -#define TIME_FORMAT_NORMAL 0x003 -#define TIME_FORMAT_OLDVAGUE 0x004 -#define TIME_FORMAT_OLDVAGUE_NOW 0x005 -#define TIME_FORMAT_OLDVAGUE_WEEK 0x006 -#define TIME_FORMAT_OLDVAGUE_OLD 0x007 - -std::string timeFormat(int epoch, int format); - -#if defined(PQI_USE_XPGP) - -std::string getXPGPInfo(XPGP *cert); -std::string getXPGPAuthCode(XPGP *xpgp); -std::list getXPGPsigners(XPGP *cert); - -#endif /* XPGP Certificates */ - - -#endif diff --git a/libretroshare/src/fltkgui/retrotray.cc b/libretroshare/src/fltkgui/retrotray.cc deleted file mode 100644 index 6c74ae571..000000000 --- a/libretroshare/src/fltkgui/retrotray.cc +++ /dev/null @@ -1,338 +0,0 @@ -/* - * "$Id: retrotray.cc,v 1.5 2007-02-18 21:46:49 rmf24 Exp $" - * - * FltkGUI for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - - -#include -#include -#include - -#include "fltkgui/retroTray.h" -#include "pqi/pqidebug.h" - -static retroTray tray; -static NOTIFYICONDATA s_nid; -static std::string icn_path; - - -int SetIconPath(const char *iconpath) -{ - icn_path = iconpath; - return 1; -} - - -int InitialiseRetroTray(HINSTANCE hi, HICON icn, UserInterface *ui) -{ - tray.init(hi); - - std::string iconpath = "/programs/icons"; - std::string fname = "tst.ico"; - - // for now install a default one. -// if (icn == (HICON) NULL) - { - //icn = LoadCursorFromFile(fname.c_str()); - icn = LoadCursorFromFile(icn_path.c_str()); - //icn = (HICON) LoadImage(hi, fname.c_str(), IMAGE_ICON, 16, 16, 0); - std::cerr << "Loaded ICON: " << icn << std::endl; - } - - //tray.loadIcons(iconpath); - tray.installIcon(icn, ui); - -// while(1) -// Sleep(1000); - return 1; -} - - - - -static LRESULT CALLBACK systray_handler(HWND hwnd, UINT msg, WPARAM type0, LPARAM type) { - static UINT taskbarRestartMsg; /* static here means value is kept across multiple calls to this func */ - - - std::cerr << "Call of The Handler(" << msg << ","; - std::cerr << type0 << "," << type << ")" << std::endl; - - switch(msg) { - case WM_CREATE: - std::cerr << "WM_CREATE"; - //taskbarRestartMsg = RegisterWindowMessage("TaskbarCreated"); - break; - - case WM_TIMER: - std::cerr << "WM_TIMER"; - break; - - case WM_DESTROY: - std::cerr << "WM_DESTROY"; - break; - - case WM_USER: - { - std::cerr << "WM_USER"; - tray.buttonPressed(type0, type); - break; - } - default: - std::cerr << "default"; - if (msg == taskbarRestartMsg) - { - std::cerr << " RESTART MSG"; - //tray.InstallIcon(0); - } - break; - } - - std::cerr << std::endl; - //return CallDefWindowProc(hwnd, msg, type0, type); - return CallWindowProc(DefWindowProc, hwnd, msg, type0, type); -} - - -retroTray::retroTray() - :hInst(0) -{ - //ZeroMemory(&hwin, sizeof(hwin)); - ZeroMemory(&nid, sizeof(nid)); - return; -} - - -int retroTray::init(HINSTANCE hi) -{ - hInst = hi; - return 1; -} - - -int retroTray::installIcon(HICON ic, UserInterface *ui) -{ - retroRoot = ui; - hIcon = ic; -//(HICON) IDI_QUESTION; -//icn; - - // First create hidden window (could be RetroShare) - if (nid.cbSize!=sizeof(NOTIFYICONDATA)) - { - WNDCLASSEX wcex; - wcex.style = 0; - wcex.cbClsExtra = 0; - wcex.cbWndExtra = 0; - wcex.hIcon = NULL; - wcex.hIconSm = NULL; - wcex.hCursor = NULL; - wcex.hbrBackground = NULL; - wcex.lpszMenuName = NULL; - wcex.lpszClassName = "retroTray"; - - wcex.hInstance = hInst; - wcex.lpfnWndProc = (WNDPROC) systray_handler; - wcex.cbSize = sizeof(WNDCLASSEX); - - RegisterClassEx(&wcex); - - hWnd = CreateWindow("retroTray", "", 0,0,0,0,0, - GetDesktopWindow(), NULL, hInst, 0); - - std::cerr << "Created Hidden Window" << std::endl; - } - - ZeroMemory(&nid, sizeof(nid)); - nid.hWnd = hWnd; - nid.uID = 0; //nextid++; - nid.uFlags= NIF_ICON | NIF_MESSAGE | NIF_TIP; - nid.uCallbackMessage=WM_USER; - nid.hIcon=hIcon; - - strcpy(nid.szTip, "Hello World from RetroShare"); - nid.cbSize=sizeof(NOTIFYICONDATA); - - s_nid = nid; - - if (Shell_NotifyIcon(NIM_ADD, &s_nid)) - { - std::cerr << "Notify Success" << std::endl; - } - else - { - std::cerr << "Notify Failure" << std::endl; - } - - std::cerr << "Icon Installed??" << std::endl; - return 1; -} - -int retroTray::buttonPressed(int type0, int type) -{ - std::cerr << "retroTray::buttonPressed(" << type0; - std::cerr << "," << type << ")" << std::endl; - - if (type == WM_LBUTTONDBLCLK) - { - std::cerr << "Showing RetroShare!" << std::endl; - showRetroShare(); - } - else if (type == WM_LBUTTONUP) - { - std::cerr << "Showing RetroShare(B)!" << std::endl; - showRetroShare(); - } - else if (type == WM_MBUTTONUP) - { - std::cerr << "Hiding RetroShare!" << std::endl; - hideRetroShare(); - } - else if (type == WM_RBUTTONDOWN) - { - std::cerr << "Showing TaskMenu!" << std::endl; - showTrayMenu(); - } - else //if (type == WM_RBUTTONUP) - { - std::cerr << "Leaving RetroShare!" << std::endl; - // do nothing. - } - return 1; -} - -// -//int retroTray::addIcon() -//{ -// return 1; -//} -// -// -//int retroTray::removeIcon() -//{ -// return 1; -//} -// -// -//int retroTray::exitCall() -//{ -// // if -//static int times = 0; -// if (++times > 20) -// removeIcon(); -// return 1; -//} -// -// -// - - - -#define RTRAY_MENU_NULL 0 -#define RTRAY_MENU_HIDE 1 -#define RTRAY_MENU_SHOW 2 -#define RTRAY_MENU_QUIT 3 - - -int retroTray::showTrayMenu(void) -{ - long menuChoice; - -// First We need a Menu. - HMENU popup; - unsigned int flag; - - popup = ::CreatePopupMenu(); - - flag = MF_BYPOSITION; - ::InsertMenu(popup, 0, flag, RTRAY_MENU_QUIT, "Quit"); - flag = MF_BYPOSITION | MF_SEPARATOR; - ::InsertMenu(popup, 0, flag, 0x000, "Seperator"); - flag = MF_BYPOSITION; - ::InsertMenu(popup, 0, flag, RTRAY_MENU_HIDE, "Hide RetroShare"); - ::InsertMenu(popup, 0, flag, RTRAY_MENU_SHOW, "Open RetroShare"); - - flag = MF_BYPOSITION | MF_SEPARATOR; - ::InsertMenu(popup, 0, flag, 0x000, "Seperator"); - flag = MF_BYPOSITION; - ::InsertMenu(popup, 0, flag, 0x001, "About RetroShare"); - - POINT pp; - - RECT rect; - rect.left = 0; - rect.top = 0; - rect.right = 1000; - rect.bottom = 1000; - - ::GetCursorPos(&pp); - menuChoice = ::TrackPopupMenu(popup, - TPM_LEFTALIGN | - TPM_LEFTBUTTON | - TPM_RIGHTBUTTON | - TPM_NONOTIFY | - TPM_RETURNCMD, - pp.x,pp.y, 0, hWnd, &rect); - ::DestroyMenu(popup); - - // The value of SelectionMade is the id of the command selected or 0 if no - // selection was made - - - switch(menuChoice) - { - case RTRAY_MENU_NULL: -/* - AfxMessageBox("Starting Null"); -*/ - break; - - case RTRAY_MENU_HIDE: - hideRetroShare(); - break; - case RTRAY_MENU_SHOW: - showRetroShare(); - break; - - case RTRAY_MENU_QUIT: - /* before exiting - clear the debug log */ - clearDebugCrashLog(); - exit(1); - break; - } - return 1; -} - - -/********************** -HWND CreateDialog( - - HINSTANCE hInstance, - LPCTSTR lpTemplate, - HWND hWndParent, - DLGPROC lpDialogFunc -); - -**********************/ - diff --git a/libretroshare/src/fltkgui/retrotray.h b/libretroshare/src/fltkgui/retrotray.h deleted file mode 100644 index 0d17780a7..000000000 --- a/libretroshare/src/fltkgui/retrotray.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * "$Id: retrotray.h,v 1.5 2007-02-18 21:46:49 rmf24 Exp $" - * - * FltkGUI for RetroShare. - * - * Copyright 2004-2006 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - - -#ifndef MRK_RETRO_TRAY_H -#define MRK_RETRO_TRAY_H - -/** - * - * This class encapsulates the windows? system tray icon. - * - */ - -#include -#include -#include -//#include -//#include -#include -#include - -// The Gui type of Window. -#include "fltkgui/guitab.h" - -/**************** PQI_USE_XPGP ******************/ -#if defined(PQI_USE_XPGP) - -#include "pqi/xpgpcert.h" - -#else /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - -#include "pqi/sslcert.h" - -#endif /* X509 Certificates */ -/**************** PQI_USE_XPGP ******************/ - -int SetIconPath(const char *path); - -int InitialiseRetroTray(HINSTANCE hi, HICON icn, UserInterface *ui); - -class retroTray -{ - -public: - retroTray(); -int init(HINSTANCE hi); -int installIcon(HICON icn, UserInterface *ui); - -int buttonPressed(int, int); -private: -void showRetroShare() -{ - if (getSSLRoot() -> active()) - { - retroRoot -> main_win -> show(); - visible = true; - } - else - { - retroRoot -> welcome_window -> show(); - } -} - -void hideRetroShare() -{ - retroRoot -> main_win -> hide(); - retroRoot -> welcome_window -> hide(); - retroRoot -> alert_window -> hide(); - retroRoot -> chatter_window -> hide(); - - visible = false; -} - -int showTrayMenu(); - - HINSTANCE hInst; - HWND hWnd; - HICON hIcon; - NOTIFYICONDATA nid; - UserInterface *retroRoot; - bool visible; -}; - - -#endif - - -