1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
11 * Copyright (C) 2005 Christi Alice Scarborough
13 * All files in this archive are subject to the GNU General Public License.
14 * See the file COPYING in the source tree root for full license agreement.
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
19 ****************************************************************************/
21 #include <wx/wxprec.h>
32 #include <wx/config.h>
33 #include <wx/confbase.h>
34 #include <wx/fileconf.h>
35 #include <wx/stdpaths.h>
36 #include <wx/wfstream.h>
37 #include <wx/filesys.h>
38 #include <wx/fs_inet.h>
39 #include <wx/fs_zip.h>
40 #include <wx/progdlg.h>
41 #include <wx/protocol/http.h>
42 #include <wx/string.h>
44 #include <wx/ptr_scpd.h>
45 #include <wx/zipstrm.h>
47 #include <wx/filefn.h>
48 #include <wx/sstream.h>
49 #include <wx/msgdlg.h>
52 #include <wx/wizard.h>
57 #define PATH_SEP_CHR '\\'
58 #define EXE_NAME wxT("rbutil.exe")
60 #define PATH_SEP wxT("/")
61 #define PATH_SEP_CHR '/'
62 #define EXE_NAME wxT("rbutil")
65 #define UNINSTALL_FILE wxT(".rockbox" PATH_SEP ".rbutil_install_data")
66 #define MAX_PLATFORMS 50
67 #define SYSTEM_CONFIG rbutil.ini
68 #define FILE_BUFFER_SIZE 1024
70 //WX_DEFINE_OBJARRAY(bool, wxArrayBool);
75 // Program configuration data (rbutil.ini and environment)
76 wxFileConfig
* GlobalConfig
;
77 wxFileConfig
* UserConfig
;
78 wxString UserConfigFile
;
79 wxString GlobalConfigFile
;
84 wxStandardPaths
* stdpaths
;
85 wxArrayString plat_id
;
86 wxArrayString plat_name
;
87 wxArrayInt plat_released
;
88 wxArrayInt plat_needsbootloader
;
89 wxArrayString plat_bootloadermethod
;
90 wxArrayString plat_bootloadername
;
91 wxArrayInt plat_autodetect
;
92 wxArrayString plat_combinedname
;
93 wxArrayString plat_resolution
;
94 wxString download_url
;
96 wxString bleeding_url
;
97 wxString server_conf_url
;
99 wxString last_release
;
101 wxString bootloader_url
;
104 // User configuration data.
106 unsigned int curplatnum
;
108 unsigned int curbuild
;
112 wxString curbootloadermethod
;
113 wxString curbootloader
;
114 wxString curfirmware
;
115 wxString curresolution
;
116 wxArrayString themesToInstall
;
118 // Global system variables
120 wxLogStderr
* logstderr
;
121 wxLogChain
* logchain
;
125 extern GlobalVars
* gv
;
127 wxString
wxFindAppPath(const wxString
& argv0
, const wxString
& cwd
,
128 const wxString
& appVariableName
);
129 int DownloadURL(wxString src
, wxString dest
);
130 int UnzipFile(wxString src
, wxString destdir
, bool isInstall
= false);
131 int Uninstall(const wxString dir
, bool isFullUninstall
= false);
132 bool InstallRbutil(wxString dest
);
133 bool InstallTheme(wxString src
);
134 bool checkZip(wxString zipname
);
135 wxString
stream_err_str(int errnum
);
136 bool rm_rf(wxString file
);
139 #define ERR_DIALOG(msg, title) \
140 wxLogError(wxT("%s: %s"), ((wxString) title).c_str(), ((wxString) msg).c_str())
142 #define WARN_DIALOG(msg, title) \
143 wxLogWarning(wxT("%s: %s"), ((wxString) title).c_str(), ((wxString) msg).c_str())
145 #define MESG_DIALOG(msg) \
148 #define INFO_DIALOG(msg) \
151 #define BUILD_RELEASE 0
152 #define BUILD_DAILY 1
153 #define BUILD_BLEEDING 2
155 #define BOOTLOADER_ADD 0
156 #define BOOTLOADER_REM 1