FS#6948 - Fix the broken 'follow playlist' feature
[Rockbox.git] / rbutil / rbutil.h
blobae00bd21fb5fe3521fdb7da57dc037895f91b90f
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * Module: rbutil
9 * File: rbutil.h
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>
22 #ifdef __BORLANDC__
23 #pragma hdrstop
24 #endif
25 #ifndef WX_PRECOMP
26 #include <wx/wx.h>
27 #endif
29 #ifndef __rbutil_HPP_
30 #define __rbutil_HPP_
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>
43 #include <wx/url.h>
44 #include <wx/ptr_scpd.h>
45 #include <wx/zipstrm.h>
46 #include <wx/dir.h>
47 #include <wx/filefn.h>
48 #include <wx/sstream.h>
49 #include <wx/msgdlg.h>
50 #include <wx/log.h>
51 #include <wx/file.h>
52 #include <wx/wizard.h>
53 #include <wx/event.h>
55 #ifdef __WXMSW__
56 #define PATH_SEP "\\"
57 #define PATH_SEP_CHR '\\'
58 #define EXE_NAME wxT("rbutil.exe")
59 #else
60 #define PATH_SEP wxT("/")
61 #define PATH_SEP_CHR '/'
62 #define EXE_NAME wxT("rbutil")
63 #endif
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);
72 class GlobalVars
74 public:
75 // Program configuration data (rbutil.ini and environment)
76 wxFileConfig* GlobalConfig;
77 wxFileConfig* UserConfig;
78 wxString UserConfigFile;
79 wxString GlobalConfigFile;
80 wxString AppDir;
81 wxString ResourceDir;
83 wxString* ErrStr;
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;
95 wxString daily_url;
96 wxString bleeding_url;
97 wxString server_conf_url;
98 wxString font_url;
99 wxString last_release;
100 wxString prog_name;
101 wxString bootloader_url;
102 wxString themes_url;
104 // User configuration data.
105 wxString curplat;
106 unsigned int curplatnum;
107 wxString curdestdir;
108 unsigned int curbuild;
109 bool curisfull;
110 bool nocache;
111 bool portable;
112 wxString curbootloadermethod;
113 wxString curbootloader;
114 wxString curfirmware;
115 wxString curresolution;
116 wxArrayString themesToInstall;
118 // Global system variables
119 wxFFile* logfile;
120 wxLogStderr* logstderr;
121 wxLogChain* logchain;
122 wxLogGui* loggui;
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) \
146 wxLogMessage(msg)
148 #define INFO_DIALOG(msg) \
149 wxLogInfo(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
158 #endif