1
0
Fork 0

Remove FGAdmin

This commit is contained in:
James Turner 2016-06-15 22:31:47 +01:00
parent 3f7e59a1a5
commit a0b7abf7ff
16 changed files with 2 additions and 2521 deletions

View file

@ -182,7 +182,6 @@ option(FG_NIGHTLY "Set to ON to mark this as a nightly build" OFF)
option(ENABLE_DEV_WARNINGS "Set to ON to include developer-warnings" OFF)
# additional utilities
option(ENABLE_FGADMIN "Set to ON to build the FGADMIN application (default)" ON)
option(ENABLE_FGELEV "Set to ON to build the fgelev application (default)" ON)
option(WITH_FGPANEL "Set to ON to build the fgpanel application (default)" ON)
option(ENABLE_FGVIEWER "Set to ON to build the fgviewer application (default)" ON)

View file

@ -38,16 +38,10 @@ if (MSVC AND MSVC_3RDPARTY_ROOT)
set( MSVC_3RDPARTY_DIR 3rdParty )
set( BOOST_LIB lib )
endif (CMAKE_CL_64)
find_path(FLTK_DIR include/FL/Fl.H
${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/fltk
${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/fltk-1.3
${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}
)
list (APPEND CMAKE_PROGRAM_PATH ${FLTK_DIR}/bin)
GET_FILENAME_COMPONENT(MSVC_ROOT_PARENT_DIR ${MSVC_3RDPARTY_ROOT} PATH)
set (CMAKE_LIBRARY_PATH ${FLTK_DIR}/lib ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenRTI/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/SimGear/lib $(BOOST_ROOT)/$(BOOST_LIB) )
set (CMAKE_INCLUDE_PATH ${FLTK_DIR}/include ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenRTI/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/SimGear/include)
set (CMAKE_LIBRARY_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenRTI/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/SimGear/lib $(BOOST_ROOT)/$(BOOST_LIB) )
set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenRTI/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/SimGear/include)
find_path(BOOST_ROOT boost/version.hpp
${MSVC_ROOT_PARENT_DIR}
${MSVC_3RDPARTY_ROOT}/boost

View file

@ -1,7 +1,3 @@
if(ENABLE_FGADMIN)
add_subdirectory(fgadmin)
endif()
# win32 is just excluded because of not having argument parsing there ...
if(RTI_FOUND AND NOT WIN32)
add_subdirectory(fgai)

View file

@ -1,3 +0,0 @@
Curtis Olson
Frederic Bouvier
Erik Hofman

View file

@ -1,47 +0,0 @@
#Zlib is already required by FG but we check it just in case
if( ZLIB_FOUND )
include_directories(${ZLIB_INCLUDE_DIR})
set( HAVE_ZLIB 1)
message(STATUS "Zlib found for fgadmin")
endif( ZLIB_FOUND )
find_package(BZip2)
if( BZIP2_FOUND )
include_directories(${BZIP2_INCLUDE_DIR})
set( HAVE_BZ2LIB 1)
message(STATUS "BZip2 found for fgadmin")
endif( BZIP2_FOUND )
find_package(FLTK)
if( FLTK_FOUND )
include_directories(${FLTK_INCLUDE_DIR})
if ( X11_Xinerama_FOUND )
message(STATUS "Found X11_Xinerama...")
list(APPEND FLTK_LIBRARIES ${X11_Xinerama_LIB})
endif()
if ( X11_Xft_FOUND )
message(STATUS "Found X11_Xft...")
list(APPEND FLTK_LIBRARIES ${X11_Xft_LIB})
endif()
if ( CMAKE_DL_LIBS )
list(APPEND FLTK_LIBRARIES ${CMAKE_DL_LIBS})
endif()
if( EXISTS ${FLTK_FLUID_EXECUTABLE} )
add_subdirectory(src)
else()
message(STATUS "Fluid executable not found, disabling fgadmin")
endif()
message(STATUS "Using FLTK_LIBRARIES for fgadmin: ${FLTK_LIBRARIES}")
else()
message(STATUS "FLTK not found, disabling fgadmin")
endif( FLTK_FOUND )
configure_file(
"${PROJECT_SOURCE_DIR}/utils/fgadmin/src/config_cmake.h.in"
"${PROJECT_BINARY_DIR}/utils/fgadmin/src/config_fgadmin.h"
)

View file

@ -1,35 +0,0 @@
Welcome to the FlightGear Flight Simulator project.
===================================================
The primary web page for this project is: http://www.flightgear.org
For basic installation instructions see the "INSTALL" file.
Before you can run FlightGear you will also need to download and
install the "base" package which is a collection of textures, sounds,
sample scenery, and other data files need by the sim.
For additional install help for specific platforms please browse the
"docs-mini/" subdirectory.
More complete documentation is available from our web page as a
separate distribution.
Please take a look at the "Thanks" file for a list of people who have
contributed to this project. If you have contributed something but
don't find your name in this file. Please send a polite reminder to
http://www.flightgear.org/~curt
For a summary of changes/additions by version see the "NEWS" file.
This project is GPL'd. For complete details on our licensing please
see the "COPYING" file.
For information on available mailing lists, mailing list archives, and
other available source code and documenation, please visit our web
site.
FlightGear is a product of the collaboration of large international
group of volunteers. FlightGear is a work in progress. FlightGear
comes with no warrantee. We hope you enjoy FlightGear and/or find it
of some value!

View file

@ -1 +0,0 @@
fgadmin

View file

@ -1,19 +0,0 @@
fltk_wrap_ui(FGAdminUI fgadmin.fl)
add_library(FGAdminUI ${FGAdminUI_FLTK_UI_SRCS})
add_executable(fgadmin WIN32 fgadmin_funcs.cxx main.cxx untarka.c)
add_dependencies(fgadmin FGAdminUI)
target_link_libraries(fgadmin FGAdminUI
${SIMGEAR_CORE_LIBRARIES}
${PLIB_LIBRARIES}
${FLTK_LIBRARIES}
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
${ZLIB_LIBRARIES}
)
if( BZIP2_FOUND )
target_link_libraries(fgadmin ${BZIP2_LIBRARIES})
endif( BZIP2_FOUND )
install(TARGETS fgadmin RUNTIME DESTINATION bin)

View file

@ -1,2 +0,0 @@
#cmakedefine HAVE_BZ2LIB
#cmakedefine HAVE_ZLIB

View file

@ -1,142 +0,0 @@
// generated by Fast Light User Interface Designer (fluid) version 1.0106
#include <iostream>
// using std::cout;
using std::endl;
#include "fgadmin.h"
#include <FL/fl_ask.H>
inline void FGAdminUI::cb_main_window_i(Fl_Double_Window*, void*) {
fl_alert("Use the Quit button to exit fgadmin");
}
void FGAdminUI::cb_main_window(Fl_Double_Window* o, void* v) {
((FGAdminUI*)(o->user_data()))->cb_main_window_i(o,v);
}
inline void FGAdminUI::cb_quit_b_i(Fl_Button*, void*) {
quit();
}
void FGAdminUI::cb_quit_b(Fl_Button* o, void* v) {
((FGAdminUI*)(o->parent()->parent()->user_data()))->cb_quit_b_i(o,v);
}
inline void FGAdminUI::cb_source_b_i(Fl_Button*, void*) {
select_install_source();
refresh_lists();
}
void FGAdminUI::cb_source_b(Fl_Button* o, void* v) {
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_source_b_i(o,v);
}
inline void FGAdminUI::cb_install_b_i(Fl_Button*, void*) {
install_selected();
}
void FGAdminUI::cb_install_b(Fl_Button* o, void* v) {
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_install_b_i(o,v);
}
inline void FGAdminUI::cb_source_sel_all_i(Fl_Button*, void*) {
install_box->check_all();
}
void FGAdminUI::cb_source_sel_all(Fl_Button* o, void* v) {
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_source_sel_all_i(o,v);
}
inline void FGAdminUI::cb_source_desel_all_i(Fl_Button*, void*) {
install_box->check_none();
}
void FGAdminUI::cb_source_desel_all(Fl_Button* o, void* v) {
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_source_desel_all_i(o,v);
}
inline void FGAdminUI::cb_dest_b_i(Fl_Button*, void*) {
select_install_dest();
refresh_lists();
}
void FGAdminUI::cb_dest_b(Fl_Button* o, void* v) {
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_dest_b_i(o,v);
}
inline void FGAdminUI::cb_remove_b_i(Fl_Button*, void*) {
remove_selected();
}
void FGAdminUI::cb_remove_b(Fl_Button* o, void* v) {
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_remove_b_i(o,v);
}
inline void FGAdminUI::cb_dest_sel_all_i(Fl_Button*, void*) {
remove_box->check_all();
}
void FGAdminUI::cb_dest_sel_all(Fl_Button* o, void* v) {
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_dest_sel_all_i(o,v);
}
inline void FGAdminUI::cb_dest_desel_all_i(Fl_Button*, void*) {
remove_box->check_none();
}
void FGAdminUI::cb_dest_desel_all(Fl_Button* o, void* v) {
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_dest_desel_all_i(o,v);
}
FGAdminUI::FGAdminUI() {
{ Fl_Double_Window* o = main_window = new Fl_Double_Window(465, 435, "FlightGear Admin Wizard");
o->callback((Fl_Callback*)cb_main_window, (void*)(this));
{ Fl_Group* o = new Fl_Group(5, 405, 455, 25);
{ Fl_Button* o = quit_b = new Fl_Button(375, 405, 85, 25, "Quit");
o->callback((Fl_Callback*)cb_quit_b);
}
{ Fl_Progress* o = progress = new Fl_Progress(5, 405, 365, 25);
o->color(FL_BACKGROUND_COLOR);
o->selection_color((Fl_Color)175);
Fl_Group::current()->resizable(o);
}
o->end();
}
{ Fl_Group* o = new Fl_Group(5, 5, 460, 390);
{ Fl_Group* o = new Fl_Group(5, 5, 225, 390);
{ Fl_Button* o = source_b = new Fl_Button(5, 5, 225, 25, "Select Scenery Source ...");
o->callback((Fl_Callback*)cb_source_b);
}
source_text = new Fl_Input(5, 35, 225, 25);
{ Fl_Check_Browser* o = install_box = new Fl_Check_Browser(5, 95, 225, 240, "Select Files to Install");
Fl_Group::current()->resizable(o);
}
{ Fl_Button* o = install_b = new Fl_Button(20, 360, 195, 35, "Install Selected Files");
o->labelfont(1);
o->callback((Fl_Callback*)cb_install_b);
}
{ Fl_Button* o = source_sel_all = new Fl_Button(5, 65, 110, 25, "Select all");
o->callback((Fl_Callback*)cb_source_sel_all);
}
{ Fl_Button* o = source_desel_all = new Fl_Button(120, 65, 110, 25, "Deselect all");
o->callback((Fl_Callback*)cb_source_desel_all);
}
o->end();
}
{ Fl_Group* o = new Fl_Group(230, 5, 230, 390);
{ Fl_Button* o = dest_b = new Fl_Button(235, 5, 225, 25, "Select Install Destination ...");
o->callback((Fl_Callback*)cb_dest_b);
}
dest_text = new Fl_Input(235, 35, 225, 25);
{ Fl_Check_Browser* o = remove_box = new Fl_Check_Browser(235, 95, 225, 240, "Select Files to Remove");
Fl_Group::current()->resizable(o);
}
{ Fl_Button* o = remove_b = new Fl_Button(250, 360, 195, 35, "Remove Selected Files");
o->labelfont(1);
o->callback((Fl_Callback*)cb_remove_b);
}
{ Fl_Button* o = dest_sel_all = new Fl_Button(235, 65, 110, 25, "Select all");
o->callback((Fl_Callback*)cb_dest_sel_all);
}
{ Fl_Button* o = dest_desel_all = new Fl_Button(350, 65, 110, 25, "Deselect all");
o->callback((Fl_Callback*)cb_dest_desel_all);
}
o->end();
}
o->end();
Fl_Group::current()->resizable(o);
}
o->end();
}
}

View file

@ -1,136 +0,0 @@
# data file for the Fltk User Interface Designer (fluid)
version 1.0106
header_name {.h}
code_name {.cxx}
decl {\#include <string>} {public
}
decl {\#include <FL/Fl_Preferences.H>} {public
}
decl {\#include <FL/fl_ask.H>} {}
decl {using std::string;} {public
}
class FGAdminUI {open
} {
decl {\#include <iostream>} {}
decl {using std::cout;} {}
decl {using std::endl;} {}
Function {FGAdminUI()} {open
} {
Fl_Window main_window {
label {FlightGear Admin Wizard}
callback {fl_alert("Use the Quit button to exit fgadmin");} open
xywh {500 247 465 435} type Double resizable visible
} {
Fl_Group {} {open
xywh {5 405 455 25}
} {
Fl_Button quit_b {
label Quit
callback {quit();}
xywh {375 405 85 25}
}
Fl_Progress progress {
xywh {5 405 365 25} color 49 selection_color 175 resizable
}
}
Fl_Group {} {open
xywh {5 5 460 390} resizable
} {
Fl_Group {} {open
xywh {5 5 225 390}
} {
Fl_Button source_b {
label {Select Scenery Source ...}
callback {select_install_source();
refresh_lists();}
xywh {5 5 225 25}
}
Fl_Input source_text {
xywh {5 35 225 25}
}
Fl_Check_Browser install_box {
label {Select Files to Install}
xywh {5 95 225 240} resizable
}
Fl_Button install_b {
label {Install Selected Files}
callback {install_selected();}
xywh {20 360 195 35} labelfont 1
}
Fl_Button source_sel_all {
label {Select all}
callback {install_box->check_all();}
xywh {5 65 110 25}
}
Fl_Button source_desel_all {
label {Deselect all}
callback {install_box->check_none();}
xywh {120 65 110 25}
}
}
Fl_Group {} {open
xywh {230 5 230 390}
} {
Fl_Button dest_b {
label {Select Install Destination ...}
callback {select_install_dest();
refresh_lists();}
xywh {235 5 225 25}
}
Fl_Input dest_text {
xywh {235 35 225 25}
}
Fl_Check_Browser remove_box {
label {Select Files to Remove}
xywh {235 95 225 240} resizable
}
Fl_Button remove_b {
label {Remove Selected Files}
callback {remove_selected();}
xywh {250 360 195 35} labelfont 1
}
Fl_Button dest_sel_all {
label {Select all}
callback {remove_box->check_all();}
xywh {235 65 110 25}
}
Fl_Button dest_desel_all {
label {Deselect all}
callback {remove_box->check_none();} selected
xywh {350 65 110 25}
}
}
}
}
}
decl {~FGAdminUI();} {public
}
decl {void init();} {public
}
decl {void show();} {public
}
decl {static void step( void * );} {public
}
decl {static void step( void *, int );} {public
}
decl {void refresh_lists();} {}
decl {void quit();} {}
decl {void select_install_source();} {}
decl {void select_install_dest();} {}
decl {void update_install_box();} {}
decl {void update_remove_box();} {}
decl {void install_selected();} {}
decl {void remove_selected();} {}
decl {void select_all_source();} {}
decl {void deselect_all_source();} {}
decl {void select_all_dest();} {}
decl {void deselect_all_dest();} {}
decl {Fl_Preferences *prefs;} {}
decl {string source;} {}
decl {string dest;} {}
decl {string progress_label;} {}
}

View file

@ -1,98 +0,0 @@
// generated by Fast Light User Interface Designer (fluid) version 1.0106
#ifndef fgadmin_h
#define fgadmin_h
#include <string>
using std::string;
#include <FL/Fl.H>
#include <FL/Fl_Preferences.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Progress.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Check_Browser.H>
class FGAdminUI {
public:
FGAdminUI();
Fl_Double_Window *main_window;
private:
inline void cb_main_window_i(Fl_Double_Window*, void*);
static void cb_main_window(Fl_Double_Window*, void*);
public:
Fl_Button *quit_b;
private:
inline void cb_quit_b_i(Fl_Button*, void*);
static void cb_quit_b(Fl_Button*, void*);
public:
Fl_Progress *progress;
Fl_Button *source_b;
private:
inline void cb_source_b_i(Fl_Button*, void*);
static void cb_source_b(Fl_Button*, void*);
public:
Fl_Input *source_text;
Fl_Check_Browser *install_box;
Fl_Button *install_b;
private:
inline void cb_install_b_i(Fl_Button*, void*);
static void cb_install_b(Fl_Button*, void*);
public:
Fl_Button *source_sel_all;
private:
inline void cb_source_sel_all_i(Fl_Button*, void*);
static void cb_source_sel_all(Fl_Button*, void*);
public:
Fl_Button *source_desel_all;
private:
inline void cb_source_desel_all_i(Fl_Button*, void*);
static void cb_source_desel_all(Fl_Button*, void*);
public:
Fl_Button *dest_b;
private:
inline void cb_dest_b_i(Fl_Button*, void*);
static void cb_dest_b(Fl_Button*, void*);
public:
Fl_Input *dest_text;
Fl_Check_Browser *remove_box;
Fl_Button *remove_b;
private:
inline void cb_remove_b_i(Fl_Button*, void*);
static void cb_remove_b(Fl_Button*, void*);
public:
Fl_Button *dest_sel_all;
private:
inline void cb_dest_sel_all_i(Fl_Button*, void*);
static void cb_dest_sel_all(Fl_Button*, void*);
public:
Fl_Button *dest_desel_all;
private:
inline void cb_dest_desel_all_i(Fl_Button*, void*);
static void cb_dest_desel_all(Fl_Button*, void*);
public:
~FGAdminUI();
void init();
void show();
static void step( void * );
static void step( void *, int );
private:
void refresh_lists();
void quit();
void select_install_source();
void select_install_dest();
void update_install_box();
void update_remove_box();
void install_selected();
void remove_selected();
void select_all_source();
void deselect_all_source();
void select_all_dest();
void deselect_all_dest();
Fl_Preferences *prefs;
string source;
string dest;
string progress_label;
};
#endif

View file

@ -1,447 +0,0 @@
// fgadmin_funcs.cxx -- FG Admin UI functions.
//
// Written by Curtis Olson, started February 2004.
//
// Copyright (c) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program 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
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#include <iostream>
#include <string>
#include <set>
#include <sys/stat.h>
#ifdef _WIN32
# include <direct.h>
# include <io.h>
#define unlink _unlink
#define mkdir _mkdir
#else // !_WIN32
#include <unistd.h>
#endif
#include <FL/Fl_File_Chooser.H>
#include <simgear/misc/sg_path.hxx>
#include "fgadmin.h"
#include "untarka.h"
using std::cout;
using std::endl;
using std::set;
using std::string;
extern string def_install_source;
extern string def_scenery_dest;
static const float min_progress = 0.0;
static const float max_progress = 5000.0;
// FIXME: Ugly hack to detect the situation below
#ifdef FL_Volume_Down
//#if (FL_MAJOR_VERSION > 1)||((FL_MAJOR_VERSION == 1)&&(FL_MINOR_VERSION >= 3))
// Fltk 1.3 or newer, need to use "fl_filename_free_list"
#define FL_FREE_DIR_ENTRY(e) // do nothing, since "fl_filename_free_list" frees entire list
#define FL_FREE_DIR_LIST(list,count) fl_filename_free_list(&list, count)
#define FL_STAT(file,info) fl_stat( file.str().c_str(), info )
#else
// Fltk < 1.3, "fl_filename_free_list", "fl_stat" not available
#define FL_FREE_DIR_ENTRY(e) free(e)
#define FL_FREE_DIR_LIST(list,count) free(list)
#define FL_STAT(file,info) stat( file.str().c_str(), info );
#endif
/** Strip a single trailing '/' or '\\' */
static char* stripSlash(char* str)
{
int l = strlen(str);
if ((l>0)&&
((str[l-1]=='/')||(str[l-1]=='\\')))
{
str[l-1] = 0;
}
return str;
}
// destructor
FGAdminUI::~FGAdminUI() {
delete prefs;
}
// initialize additional class elements
void FGAdminUI::init() {
prefs = new Fl_Preferences( Fl_Preferences::USER,
"flightgear.org",
"fgadmin" );
char buf[FL_PATH_MAX];
prefs->get( "install-source", buf, def_install_source.c_str(), FL_PATH_MAX );
source_text->value( buf );
source = buf;
prefs->get( "scenery-dest", buf, def_scenery_dest.c_str(), FL_PATH_MAX );
dest_text->value( buf );
dest = buf;
refresh_lists();
progress->minimum( min_progress );
progress->maximum( max_progress );
main_window->size_range( 465, 435 );
}
// show our UI
void FGAdminUI::show() {
main_window->show();
}
// refresh the check box lists
void FGAdminUI::refresh_lists() {
update_install_box();
update_remove_box();
}
// scan the source directory and update the install_box contents
// quit
void FGAdminUI::quit() {
main_window->hide();
}
// select the install source
void FGAdminUI::select_install_source() {
char* p = fl_dir_chooser( "Select Scenery Source Directory",
source.c_str(),
0 );
if ( p != 0 ) {
source = p;
source_text->value( p );
prefs->set( "install-source", p );
prefs->flush();
}
}
// select the install source
void FGAdminUI::select_install_dest() {
char* p = fl_dir_chooser( "Select Scenery Install Directory",
dest.c_str(),
0 );
if ( p != 0 ) {
dest = p;
dest_text->value( p );
prefs->set( "scenery-dest", p );
prefs->flush();
}
}
#if 0
// Like strcmp, but for strings
static int stringCompare(const void *string1, const void *string2)
{
const string *s1 = (const string *)string1;
const string *s2 = (const string *)string2;
// Compare name first, and then index.
return strcmp(s1->c_str(), s2->c_str());
}
#endif
void FGAdminUI::update_install_box() {
set<string> file_list;
install_box->clear();
if ( source.length() ) {
struct dirent **list;
int nb = fl_filename_list( source.c_str(), &list );
for ( int i = 0; i < nb; ++i ) {
// find base name of archive file
char base[FL_PATH_MAX];
dirent *ent = list[i];
stripSlash(ent->d_name);
strncpy( base, ent->d_name, FL_PATH_MAX );
const char *p = fl_filename_ext( base );
int offset;
string::size_type expected_length = 0;
if ( strcmp( p, ".gz" ) == 0 ) {
offset = p - base;
base[offset] = '\0';
p = fl_filename_ext( base );
if ( strcmp( p, ".tar" ) == 0 ) {
offset = p - base;
base[offset] = '\0';
expected_length = 14;
}
} else if ( strcmp( p, ".tgz" ) == 0 ) {
offset = p - base;
base[offset] = '\0';
expected_length = 11;
} else if ( strcmp( p, ".zip" ) == 0 ) {
offset = p - base;
base[offset] = '\0';
expected_length = 11;
}
if ( strlen(ent->d_name) != expected_length ) {
// simple heuristic to ignore non-scenery files
} else if ( ent->d_name[0] != 'e' && ent->d_name[0] != 'w' ) {
// further sanity checks on name
} else if ( ent->d_name[4] != 'n' && ent->d_name[4] != 's' ) {
// further sanity checks on name
} else {
// add to list if not installed
SGPath install( dest );
install.append( base );
if ( ! fl_filename_isdir( install.c_str() ) ) {
// cout << install.str() << " install candidate." << endl;
file_list.insert( ent->d_name );
} else {
// cout << install.str() << " exists." << endl;
}
}
FL_FREE_DIR_ENTRY(ent);
}
FL_FREE_DIR_LIST(list, nb);
for ( set<string>::iterator it = file_list.begin(); it != file_list.end(); ++it ) {
install_box->add( it->c_str() );
}
install_box->redraw();
}
}
// scan the source directory and update the install_box contents
void FGAdminUI::update_remove_box() {
remove_box->clear();
if ( dest.length() ) {
string path[2];
path[0] = dest + "/Terrain";
path[1] = dest + "/Objects";
if ( !fl_filename_isdir( path[0].c_str() ) ) {
path[0] = dest;
path[1] = "";
} else if ( !fl_filename_isdir( path[1].c_str() ) ) {
path[1] = "";
}
set<string> dir_list;
for ( int i = 0; i < 2; i++ ) {
if ( !path[i].empty() ) {
dirent **list;
int nb = fl_filename_list( path[i].c_str(), &list );
for ( int i = 0; i < nb; ++i ) {
dirent *ent = list[i];
stripSlash(ent->d_name);
if ( strlen(ent->d_name) == 7 &&
( ent->d_name[0] == 'e' || ent->d_name[0] == 'w' ) &&
( ent->d_name[4] == 'n' || ent->d_name[4] == 's' ) ) {
dir_list.insert( ent->d_name );
}
FL_FREE_DIR_ENTRY(ent);
}
FL_FREE_DIR_LIST(list, nb);
}
}
for ( set<string>::iterator it = dir_list.begin(); it != dir_list.end(); ++it ) {
remove_box->add( it->c_str() );
}
remove_box->redraw();
}
}
// install selected files
void FGAdminUI::install_selected() {
char *f;
install_b->deactivate();
remove_b->deactivate();
quit_b->deactivate();
// traverse install box and install each item
for ( int i = 0; i <= install_box->nitems(); ++i ) {
if ( install_box->checked( i ) ) {
f = install_box->text( i );
SGPath file( source );
file.append( f );
struct ::stat info;
FL_STAT( file, &info );
float old_max = progress->maximum();
progress->maximum( info.st_size );
progress_label = "Installing ";
progress_label += f;
progress->label( progress_label.c_str() );
progress->value( min_progress );
main_window->cursor( FL_CURSOR_WAIT );
tarextract( (char *)file.c_str(), (char *)dest.c_str(), true, &FGAdminUI::step, this );
progress->value( min_progress );
main_window->cursor( FL_CURSOR_DEFAULT );
progress->label( "" );
progress->maximum( old_max );
}
}
quit_b->activate();
install_b->activate();
remove_b->activate();
refresh_lists();
}
static unsigned long count_dir( const char *dir_name, bool top = true ) {
unsigned long cnt = 0L;
dirent **list;
int nb = fl_filename_list( dir_name, &list );
if ( nb != 0 ) {
for ( int i = 0; i < nb; ++i ) {
dirent *ent = list[i];
stripSlash(ent->d_name);
if ( strcmp( ent->d_name, "." ) == 0 ) {
// ignore "."
} else if ( strcmp( ent->d_name, ".." ) == 0 ) {
// ignore ".."
} else if ( fl_filename_isdir( ent->d_name ) ) {
SGPath child( dir_name );
child.append( ent->d_name );
cnt += count_dir( child.c_str(), false );
} else {
cnt += 1;
}
FL_FREE_DIR_ENTRY(ent);
}
FL_FREE_DIR_LIST(list, nb);
} else if ( top ) {
string base = dir_name;
size_t pos = base.rfind('/');
string file = base.substr( pos );
base.erase( pos );
string path = base + "/Terrain" + file;
cnt = count_dir( path.c_str(), false );
path = base + "/Objects" + file;
cnt += count_dir( path.c_str(), false );
}
return cnt;
}
static void remove_dir( const char *dir_name, void (*step)(void*,int), void *data, bool top = true ) {
dirent **list;
int nb = fl_filename_list( dir_name, &list );
if ( nb > 0 ) {
for ( int i = 0; i < nb; ++i ) {
dirent *ent = list[i];
SGPath child( dir_name );
child.append( ent->d_name );
stripSlash(ent->d_name);
if ( strcmp( ent->d_name, "." ) == 0 ) {
// ignore "."
} else if ( strcmp( ent->d_name, ".." ) == 0 ) {
// ignore ".."
} else if ( child.isDir() ) {
remove_dir( child.c_str(), step, data, false );
} else {
unlink( child.c_str() );
if (step) step( data, 1 );
}
FL_FREE_DIR_ENTRY(ent);
}
FL_FREE_DIR_LIST(list, nb);
rmdir( dir_name );
} else if ( top ) {
string base = dir_name;
size_t pos = base.rfind('/');
string file = base.substr( pos );
base.erase( pos );
string path = base + "/Terrain" + file;
remove_dir( path.c_str(), step, data, false );
path = base + "/Objects" + file;
remove_dir( path.c_str(), step, data, false );
}
}
// remove selected files
void FGAdminUI::remove_selected() {
char *f;
install_b->deactivate();
remove_b->deactivate();
quit_b->deactivate();
// traverse remove box and recursively remove each item
for ( int i = 0; i <= remove_box->nitems(); ++i ) {
if ( remove_box->checked( i ) ) {
f = remove_box->text( i );
SGPath dir( dest );
dir.append( f );
float old_max = progress->maximum();
progress_label = "Removing ";
progress_label += f;
progress->label( progress_label.c_str() );
progress->value( min_progress );
main_window->cursor( FL_CURSOR_WAIT );
progress->maximum( count_dir( dir.c_str() ) );
remove_dir( dir.c_str(), &FGAdminUI::step, this );
progress->value( min_progress );
main_window->cursor( FL_CURSOR_DEFAULT );
progress->label( "" );
progress->maximum( old_max );
}
}
quit_b->activate();
install_b->activate();
remove_b->activate();
refresh_lists();
}
void FGAdminUI::step(void *data)
{
Fl_Progress *p = ((FGAdminUI*)data)->progress;
// we don't actually know the total work in advanced due to the
// nature of tar archives, and it would be inefficient to prescan
// the files, so just cycle the progress bar until we are done.
float tmp = p->value() + 1;
if ( tmp > max_progress ) {
tmp = 0.0;
}
p->value( tmp );
Fl::check();
}
void FGAdminUI::step(void *data, int n)
{
Fl_Progress *p = ((FGAdminUI*)data)->progress;
float tmp = p->value() + n;
p->value( tmp );
Fl::check();
}

View file

@ -1,91 +0,0 @@
// main.cxx -- FlightGear Scenery/Aircraft Admin Tool
//
// Written by Curtis Olson, started February 2004.
//
// Copyright (c) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program 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
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
#include <string>
#include <cstring>
#include <FL/Fl.H>
#include <FL/filename.H>
#include "fgadmin.h"
std::string def_install_source;
std::string def_scenery_dest;
bool silent = false;
/**
* --silent
* --install-source=<DIR>
* --scenery-dest=<DIR>
*/
static int
parse_args( int, char** argv, int& i )
{
if (strcmp( argv[i], "--silent" ) == 0)
{
silent = true;
++i;
return 1;
}
else if (strncmp( argv[i], "--install-source=", 17 ) == 0)
{
def_install_source.assign( &argv[i][17] );
++i;
return 1;
}
else if (strncmp( argv[i], "--scenery-dest=", 15 ) == 0)
{
def_scenery_dest.assign( &argv[i][15] );
++i;
return 1;
}
return 0;
}
int
main( int argc, char* argv[] )
{
int i = 0;
if (Fl::args( argc, argv, i, parse_args ) < argc)
{
Fl::fatal("Options are:\n --silent\n --install-source=<DIR>\n --scenery-dest=<DIR>\n%s", Fl::help );
}
if ( silent )
{
Fl_Preferences prefs( Fl_Preferences::USER, "flightgear.org", "fgadmin" );
char abs_name[ FL_PATH_MAX ];
fl_filename_absolute( abs_name, def_install_source.c_str() );
prefs.set( "install-source", abs_name );
fl_filename_absolute( abs_name, def_scenery_dest.c_str() );
prefs.set( "scenery-dest", abs_name );
return 0;
}
FGAdminUI ui;
ui.init();
ui.show();
return Fl::run();
}

File diff suppressed because it is too large Load diff

View file

@ -1,15 +0,0 @@
// list the contents of the specified tar file
// bool tarlist( char *tarfile, char *destdir, bool verbose );
// extract the specified tar file into the specified destination
// directory
#ifdef __cplusplus
extern "C" {
#endif
void tarextract( char *tarfile, char *destdir, int verbose, void (*step)(void*,int), void *data );
#ifdef __cplusplus
}
#endif