Include the required headers. Strangely this only broke on linux. Also fix a warning.
[Rockbox.git] / rbutil / rbutilFrm.cpp
blob306f955d46c4e80b7306f75c22797647154c0405
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * Module: rbutil
9 * File: rbutilFrm.cpp
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 "rbutilFrm.h"
22 #include "credits.h"
24 #include "rbutilFrm_XPM.xpm"
25 #include "icons/rbinstall_btn.h"
26 #include "icons/remrb_btn.h"
27 #include "icons/font_btn.h"
28 #include "icons/bootloader_btn.h"
29 #include "icons/rembootloader_btn.h"
30 #include "icons/themes_btn.h"
31 #include "icons/doom_btn.h"
32 #include "icons/talkfile_btn.h"
34 #include "rblogo.xpm"
36 #include "bootloaders.h"
37 #include "install_dialogs.h"
41 //----------------------------------------------------------------------------
42 // rbutilFrm
43 //----------------------------------------------------------------------------
45 BEGIN_EVENT_TABLE(rbutilFrm,wxFrame)
46 EVT_BUTTON (ID_INSTALL_BTN, rbutilFrm::OnInstallBtn)
47 EVT_BUTTON (ID_REMOVE_BTN, rbutilFrm::OnRemoveBtn)
48 EVT_BUTTON (ID_FONT_BTN, rbutilFrm::OnFontBtn)
49 EVT_BUTTON (ID_THEMES_BTN, rbutilFrm::OnThemesBtn)
50 EVT_BUTTON (ID_BOOTLOADER_BTN, rbutilFrm::OnBootloaderBtn)
51 EVT_BUTTON (ID_BOOTLOADERREMOVE_BTN, rbutilFrm::OnBootloaderRemoveBtn)
52 EVT_BUTTON (ID_DOOM_BTN, rbutilFrm::OnDoomBtn)
53 EVT_BUTTON (ID_TALK_BTN, rbutilFrm::OnTalkBtn)
55 EVT_CLOSE(rbutilFrm::rbutilFrmClose)
56 EVT_MENU(ID_FILE_EXIT, rbutilFrm::OnFileExit)
57 EVT_MENU(ID_FILE_ABOUT, rbutilFrm::OnFileAbout)
58 EVT_MENU(ID_FILE_WIPECACHE, rbutilFrm::OnFileWipeCache)
59 EVT_MENU(ID_PORTABLE_INSTALL, rbutilFrm::OnPortableInstall)
61 EVT_MENU(ID_FILE_PROXY, rbutilFrm::OnFileProxy)
63 EVT_UPDATE_UI (ID_MANUAL, rbutilFrm::OnManualUpdate)
65 END_EVENT_TABLE()
67 rbutilFrm::rbutilFrm( wxWindow *parent, wxWindowID id, const wxString &title,
68 const wxPoint &position, const wxSize& size, long style )
69 : wxFrame( parent, id, title, position, size, style)
71 wxLogVerbose(wxT("=== begin rbutilFrm::rbutilFrm(...)"));
72 CreateGUIControls();
73 wxLogVerbose(wxT("=== end rbutilFrm::rbutilFrm"));
76 rbutilFrm::~rbutilFrm() {}
78 void rbutilFrm::CreateGUIControls(void)
80 wxLogVerbose(wxT("=== begin rbutilFrm::CreateGUIControls()"));
82 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
83 this->SetSizer(WxBoxSizer1);
84 this->SetAutoLayout(TRUE);
86 wxPanel* mainPanel = new wxPanel(this,wxID_ANY);
87 WxBoxSizer1->Add(mainPanel,1,wxGROW|wxALL,0);
88 wxBoxSizer* WxBoxSizer0 = new wxBoxSizer(wxVERTICAL);
89 mainPanel->SetSizer(WxBoxSizer0);
90 mainPanel->SetAutoLayout(TRUE);
92 wxBitmap rockboxbmp(rblogo_xpm);
93 ImageCtrl* rockboxbmpCtrl = new ImageCtrl(mainPanel,wxID_ANY);
94 rockboxbmpCtrl->SetBitmap(rockboxbmp);
96 WxBoxSizer0->Add(rockboxbmpCtrl,0,wxALIGN_CENTER_HORIZONTAL | wxALL,5);
98 myDeviceSelector = new DeviceSelectorCtrl(mainPanel,wxID_ANY);
99 myDeviceSelector->setDefault();
100 myDeviceSelector->AutoDetect();
101 WxBoxSizer0->Add(myDeviceSelector,0,wxGROW|wxALL,5);
104 wxNotebook* tabwindow = new wxNotebook(mainPanel,wxID_ANY);
105 WxBoxSizer0->Add(tabwindow,1,wxGROW|wxALL,5);
107 wxPanel* installpage = new wxPanel(tabwindow,wxID_ANY);
108 wxPanel* themepage = new wxPanel(tabwindow,wxID_ANY);
109 wxPanel* uninstallpage = new wxPanel(tabwindow,wxID_ANY);
110 wxPanel* manualpage = new wxPanel(tabwindow,wxID_ANY);
111 tabwindow->AddPage(installpage,wxT("Installation"),true);
112 tabwindow->AddPage(themepage,wxT("Extras"));
113 tabwindow->AddPage(uninstallpage,wxT("Uninstallation"));
114 tabwindow->AddPage(manualpage,wxT("Manual"));
116 /*********************
117 Install Page
118 ***********************/
120 wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxVERTICAL);
121 installpage->SetSizer(WxBoxSizer2);
122 installpage->SetAutoLayout(TRUE);
124 wxStaticBox* WxStaticBoxSizer3_StaticBoxObj = new wxStaticBox(installpage,
125 wxID_ANY, wxT("Please choose an option"));
126 wxStaticBoxSizer* WxStaticBoxSizer3 =
127 new wxStaticBoxSizer(WxStaticBoxSizer3_StaticBoxObj,wxHORIZONTAL);
128 WxBoxSizer2->Add(WxStaticBoxSizer3,1,wxALIGN_CENTER_HORIZONTAL|wxGROW | wxALL, 5);
130 wxFlexGridSizer* WxFlexGridSizer1 = new wxFlexGridSizer(2,2,0,0);
131 WxStaticBoxSizer3->Add(WxFlexGridSizer1,0,wxGROW | wxALL,0);
134 wxBitmap BootloaderInstallButton (wxGetBitmapFromMemory(bootloader_btn_png,bootloader_btn_png_length));
135 WxBitmapButton4 = new wxBitmapButton(installpage, ID_BOOTLOADER_BTN,
136 BootloaderInstallButton, wxPoint(0,0), wxSize(64,54),
137 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,wxT("Bootloader Installation"));
138 WxBitmapButton4->SetToolTip(wxT("Click here to install the Rockbox bootloader"));
139 WxFlexGridSizer1->Add(WxBitmapButton4, 0,
140 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
142 wxStaticText* WxStaticText5 = new wxStaticText(installpage, wxID_ANY,
143 wxT("Bootloader installation\n\n"
144 "Before Rockbox can be installed on your audio player, you "
145 "may have to\ninstall a bootloader.\nThis is only necessary the first time "
146 "Rockbox is installed."));
147 WxFlexGridSizer1->Add(WxStaticText5, 0,
148 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
150 wxBitmap WxBitmapButton1_BITMAP (wxGetBitmapFromMemory(rbinstall_btn_png,rbinstall_btn_png_length));
151 WxBitmapButton1 = new wxBitmapButton(installpage, ID_INSTALL_BTN,
152 WxBitmapButton1_BITMAP, wxPoint(0,0), wxSize(64,54),
153 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
154 wxT("Rockbox Installation"));
155 WxBitmapButton1->SetToolTip(wxT("Click here to install Rockbox"));
156 WxFlexGridSizer1->Add(WxBitmapButton1,0,
157 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
159 WxStaticText2 = new wxStaticText(installpage, ID_WXSTATICTEXT2,
160 wxT("Install Rockbox on your audio player"));
161 WxFlexGridSizer1->Add(WxStaticText2,0,
162 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
164 /*********************+
165 Extras Page
166 ***********************/
168 wxBoxSizer* WxBoxSizer3 = new wxBoxSizer(wxVERTICAL);
169 themepage->SetSizer(WxBoxSizer3);
170 themepage->SetAutoLayout(TRUE);
172 wxStaticBox* WxStaticBoxSizer4_StaticBoxObj = new wxStaticBox(themepage,
173 wxID_ANY, wxT("Please choose an option"));
174 wxStaticBoxSizer* WxStaticBoxSizer4 =
175 new wxStaticBoxSizer(WxStaticBoxSizer4_StaticBoxObj,wxHORIZONTAL);
176 WxBoxSizer3->Add(WxStaticBoxSizer4,1,wxALIGN_CENTER_HORIZONTAL |wxGROW| wxALL, 5);
178 wxFlexGridSizer* WxFlexGridSizer2 = new wxFlexGridSizer(2,2,0,0);
179 WxStaticBoxSizer4->Add(WxFlexGridSizer2,0,wxGROW | wxALL,0);
181 wxBitmap FontInstallButton (wxGetBitmapFromMemory(font_btn_png,font_btn_png_length));
182 WxBitmapButton3 = new wxBitmapButton(themepage, ID_FONT_BTN,
183 FontInstallButton, wxPoint(0,0), wxSize(64,54),
184 wxRAISED_BORDER | wxBU_AUTODRAW,wxDefaultValidator, wxT("Font installation"));
185 WxBitmapButton3->SetToolTip(wxT("Click here to install the most up to date "
186 "Rockbox fonts."));
187 WxFlexGridSizer2->Add(WxBitmapButton3, 0,
188 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
190 wxStaticText* WxStaticText4 = new wxStaticText(themepage, wxID_ANY,
191 wxT("Install the Rockbox fonts package\n\n"
192 "This step is needed for many Themes. You "
193 "will not need to download these\nagain unless you uninstall "
194 "Rockbox."));
195 WxFlexGridSizer2->Add(WxStaticText4, 0,
196 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
198 wxBitmap ThemesInstallButton (wxGetBitmapFromMemory(themes_btn_png,themes_btn_png_length));
199 WxBitmapButton5 = new wxBitmapButton(themepage, ID_THEMES_BTN,
200 ThemesInstallButton, wxPoint(0,0), wxSize(64,54),
201 wxRAISED_BORDER | wxBU_AUTODRAW,wxDefaultValidator, wxT("Theme installation"));
202 WxBitmapButton5->SetToolTip(wxT("Click here to install themes for Rockbox."));
203 WxFlexGridSizer2->Add(WxBitmapButton5, 0,
204 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
206 wxStaticText* WxStaticText6 = new wxStaticText(themepage, wxID_ANY,
207 wxT("Install more Themes for Rockbox.\n\n"));
208 WxFlexGridSizer2->Add(WxStaticText6, 0,
209 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
211 wxBitmap DoomInstallButton (wxGetBitmapFromMemory(doom_btn_png,doom_btn_png_length));
212 WxBitmapButton6 = new wxBitmapButton(themepage, ID_DOOM_BTN,
213 DoomInstallButton, wxPoint(0,0), wxSize(64,54),
214 wxRAISED_BORDER | wxBU_AUTODRAW,wxDefaultValidator, wxT("Freedoom installation"));
215 WxBitmapButton6->SetToolTip(wxT("Click here to install the freedoom wad files."));
216 WxFlexGridSizer2->Add(WxBitmapButton6, 0,
217 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
219 wxStaticText* WxStaticText7 = new wxStaticText(themepage, wxID_ANY,
220 wxT("Install the freedoom wad files.\n\n"));
221 WxFlexGridSizer2->Add(WxStaticText7, 0,
222 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
224 wxBitmap TalkInstallButton (wxGetBitmapFromMemory(talkfile_btn_png,talkfile_btn_png_length));
225 WxBitmapButton7 = new wxBitmapButton(themepage, ID_TALK_BTN,
226 TalkInstallButton, wxPoint(0,0), wxSize(64,54),
227 wxRAISED_BORDER | wxBU_AUTODRAW,wxDefaultValidator, wxT("Create Talk Files"));
228 WxBitmapButton7->SetToolTip(wxT("Click here to create Talk files."));
229 WxFlexGridSizer2->Add(WxBitmapButton7, 0,
230 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
232 wxStaticText* WxStaticText8 = new wxStaticText(themepage, wxID_ANY,
233 wxT("Create Talk Files.\n\n"));
234 WxFlexGridSizer2->Add(WxStaticText8, 0,
235 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
239 /*********************+
240 Uninstall Page
241 ***********************/
243 wxBoxSizer* WxBoxSizer4 = new wxBoxSizer(wxVERTICAL);
244 uninstallpage->SetSizer(WxBoxSizer4);
245 uninstallpage->SetAutoLayout(TRUE);
247 wxStaticBox* WxStaticBoxSizer5_StaticBoxObj = new wxStaticBox(uninstallpage,
248 wxID_ANY, wxT("Please choose an option"));
249 wxStaticBoxSizer* WxStaticBoxSizer5 =
250 new wxStaticBoxSizer(WxStaticBoxSizer5_StaticBoxObj,wxHORIZONTAL);
251 WxBoxSizer4->Add(WxStaticBoxSizer5,1,wxALIGN_CENTER_HORIZONTAL|wxGROW | wxALL, 5);
253 wxFlexGridSizer* WxFlexGridSizer3 = new wxFlexGridSizer(2,2,0,0);
254 WxStaticBoxSizer5->Add(WxFlexGridSizer3,0,wxGROW | wxALL,0);
256 wxBitmap WxBitmapButton2_BITMAP (wxGetBitmapFromMemory(remrb_btn_png,remrb_btn_png_length));
257 WxBitmapButton2 = new wxBitmapButton(uninstallpage, ID_REMOVE_BTN,
258 WxBitmapButton2_BITMAP, wxPoint(0,0), wxSize(64,54),
259 wxRAISED_BORDER | wxBU_AUTODRAW,wxDefaultValidator, wxT("Rockbox uninstallation"));
260 WxBitmapButton2->SetToolTip(wxT("Click here to uninstall Rockbox"));
261 WxFlexGridSizer3->Add(WxBitmapButton2,0,
262 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
264 WxStaticText3 = new wxStaticText(uninstallpage, ID_WXSTATICTEXT3,
265 wxT("Remove Rockbox from your audio player"));
266 WxFlexGridSizer3->Add(WxStaticText3,0,
267 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
269 wxBitmap WxBitmapButton4_BITMAP (wxGetBitmapFromMemory(rembootloader_btn_png,rembootloader_btn_png_length));
270 WxBitmapButton4 = new wxBitmapButton(uninstallpage, ID_BOOTLOADERREMOVE_BTN,
271 WxBitmapButton4_BITMAP, wxPoint(0,0), wxSize(64,54),
272 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
273 wxT("Bootloader uninstallation"));
274 WxBitmapButton4->SetToolTip(wxT("Click here to uninstall the Bootloader"));
275 WxFlexGridSizer3->Add(WxBitmapButton4,0,
276 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
278 WxStaticText4 = new wxStaticText(uninstallpage, ID_WXSTATICTEXT4,
279 wxT("Remove Rockbox Bootloader from your audio player"));
280 WxFlexGridSizer3->Add(WxStaticText4,0,
281 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
284 /*****************
285 * Manual Page
286 ******************/
288 wxBoxSizer* WxBoxSizer5 = new wxBoxSizer(wxVERTICAL);
289 manualpage->SetSizer(WxBoxSizer5);
290 manualpage->SetAutoLayout(TRUE);
292 manuallink = new wxHyperlinkCtrl(manualpage,wxID_ANY,wxT("Rockbox PDF Manual"),wxT("http://www.rockbox.org"));
293 WxBoxSizer5->Add(manuallink,1,wxGROW | wxALL, 5);
295 manual =new wxHtmlWindow(manualpage,ID_MANUAL);
296 WxBoxSizer5->Add(manual,10,wxGROW | wxALL, 5);
299 /**********
300 ** rest of the controls
301 **********/
303 WxMenuBar1 = new wxMenuBar();
304 wxMenu *ID_FILE_MENU_Mnu_Obj = new wxMenu(0);
305 WxMenuBar1->Append(ID_FILE_MENU_Mnu_Obj, wxT("&File"));
307 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_WIPECACHE,
308 wxT("&Empty local download cache"), wxT(""), wxITEM_NORMAL);
309 if (! gv->portable )
311 ID_FILE_MENU_Mnu_Obj->Append(ID_PORTABLE_INSTALL,
312 wxT("&Install Rockbox Utility on device"), wxT(""), wxITEM_NORMAL);
314 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_PROXY, wxT("Set &Proxy"), wxT(""),
315 wxITEM_NORMAL);
316 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_ABOUT, wxT("&About"), wxT(""),
317 wxITEM_NORMAL);
318 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_EXIT, wxT("E&xit\tCtrl+X"), wxT(""),
319 wxITEM_NORMAL);
321 this->SetMenuBar(WxMenuBar1);
322 Layout();
323 GetSizer()->Fit(this);
324 GetSizer()->SetSizeHints(this);
325 if (gv->portable)
327 this->SetTitle(wxT("Rockbox Utility (portable)"));
328 } else
330 this->SetTitle(wxT("Rockbox Utility"));
332 this->Center();
333 wxIcon rbutilFrm_ICON (rbutilFrm_XPM);
334 this->SetIcon(rbutilFrm_XPM);
335 this->SetToolTip(wxT("Install Rockbox"));
337 wxLogVerbose(wxT("=== end rbutilFrm::CreateGUIControls"));
340 void rbutilFrm::OnManualUpdate(wxUpdateUIEvent& event)
342 wxString tmp = wxT("/rockbox-") + gv->curplat;
344 int index = GetDeviceId(false);
345 if(index < 0) {
346 curManualDevice = tmp;
347 wxString pdflink;
348 pdflink = gv->manual_url;
349 manuallink->SetURL(pdflink);
350 manual->SetPage(wxT("<p><b>no device selected</b> &mdash; "
351 "You can find an overview of available manuals at "
352 "<a href='http://www.rockbox.org/manual.shtml'>"
353 "http://www.rockbox.org/manual.shtml</a></p>"));
354 return;
357 if(gv->plat_manualname[index] != wxT(""))
358 tmp = wxT("/") + gv->plat_manualname[index];
360 if( tmp == curManualDevice)
361 return;
363 curManualDevice = tmp;
365 // construct link to pdf
366 wxString pdflink;
367 pdflink = gv->manual_url + tmp + wxT(".pdf");
368 manuallink->SetURL(pdflink);
370 // construct link to html
371 wxString htmllink;
372 htmllink = gv->manual_url + tmp + wxT("/rockbox-build.html");
373 if(gv->proxy_url == wxT(""))
374 if(manual->LoadPage(htmllink)) return;
375 manual->SetPage(wxT("<p>unable to display manual &mdash;"
376 "please use the PDF link above</p>"));
382 void rbutilFrm::OnFileProxy(wxCommandEvent& event)
385 wxTextEntryDialog proxydlg(this,wxT("Please enter your Proxy in the Format: URL:PORT"),wxT("Proxy Configuration"), gv->proxy_url);
387 if(proxydlg.ShowModal() == wxID_OK)
389 gv->proxy_url = proxydlg.GetValue();
395 void rbutilFrm::rbutilFrmClose(wxCloseEvent& event)
397 wxLogVerbose(wxT("=== begin rbutilFrm::rbutilFrmClose(event)"));
398 Destroy();
399 wxLogVerbose(wxT("=== end rbutilFrm::rbutilFrmClose"));
405 * OnFileExit
407 void rbutilFrm::OnFileExit(wxCommandEvent& event)
409 wxLogVerbose(wxT("=== begin rbutilFrm::OnFileExit(event)"));
410 Close();
411 wxLogVerbose(wxT("=== end rbutilFrm::OnFileExit"));
414 // The routines this code uses are in the wxWidgets documentation, but
415 // not yet the library (2.7.0-1). This code can be re-enabled later.
417 void rbutilFrm::OnFileAbout(wxCommandEvent& event)
420 wxAboutDialogInfo *info = new wxAboutDialogInfo();
422 info->SetName(wxT(RBUTIL_FULLNAME));
423 info->SetVersion(wxT(RBUTIL_VERSION));
424 info->SetCopyright(wxT(RBUTIL_COPYRIGHT));
425 info->SetDescription(wxT(RBUTIL_DESCRIPTION));
426 info->SetWebSite(wxT(RBUTIL_WEBSITE));
428 long i = 0;
429 while (rbutil_developers[i] != "")
431 info->AddDeveloper(wxT(rbutil_developers[i++]));
434 wxAboutBox(*info);
435 delete info;
438 AboutDlg(this).ShowModal();
441 void rbutilFrm::OnFileWipeCache(wxCommandEvent& event)
443 wxString cacheloc, datadir;
445 datadir = gv->stdpaths->GetUserDataDir();
446 if (datadir == wxT(""))
448 ERR_DIALOG(wxT("Can't locate user data directory. Unable to delete "
449 "cache."), wxT("Delete download cache.") );
450 return;
453 cacheloc = datadir + wxT("" PATH_SEP "download");
455 if (! rm_rf(cacheloc) )
457 wxMessageDialog* msg = new wxMessageDialog(this, wxT("Local download cache has been deleted.")
458 , wxT("Cache deletion"), wxOK |wxICON_INFORMATION);
459 msg->ShowModal();
460 delete msg;
462 else {
463 MESG_DIALOG(wxT("Errors occured deleting the local download cache."));
466 wxMkdir(cacheloc, 0777);
469 void rbutilFrm::OnBootloaderRemoveBtn(wxCommandEvent& event)
471 wxLogVerbose(wxT("=== begin rbutilFrm::OnBootloaderRemoveBtn(event)"));
473 int index = GetDeviceId(true);
474 if(index < 0)
475 return;
477 wxString bootloadermethod = gv->plat_bootloadermethod[index];
479 if(!gv->plat_needsbootloader[index])
481 WARN_DIALOG(wxT("This Device doesnt need a Bootloader"),
482 wxT("Bootloader"));
483 return;
486 // really deinstall ?
487 wxMessageDialog msg(this,wxT("Do you really want to deinstall the Bootloader ?"),wxT("Bootloader deinstallation"),wxOK|wxCANCEL);
488 if(msg.ShowModal() != wxID_OK )
489 return;
492 if(bootloadermethod == wxT("ipodpatcher"))
494 wxString bootloadername = wxT("bootloader-");
495 bootloadername.Append(gv->plat_bootloadername[index] );
496 if(ipodpatcher(BOOTLOADER_REM,bootloadername))
498 MESG_DIALOG(wxT("The Bootloader has been uninstalled.") );
500 else
502 MESG_DIALOG(wxT("The Uninstallation failed.") );
505 else if(bootloadermethod == wxT("sansapatcher"))
507 if(sansapatcher(BOOTLOADER_REM,gv->plat_bootloadername[index]))
509 MESG_DIALOG(wxT("The Bootloader has been uninstalled.") );
511 else
513 MESG_DIALOG(wxT("The Uninstallation failed.") );
516 else if(bootloadermethod== wxT("gigabeatf"))
519 if(gigabeatf(BOOTLOADER_REM,gv->plat_bootloadername[index],gv->curdestdir))
521 MESG_DIALOG(wxT("The Bootloader has been uninstalled."));
523 else
524 MESG_DIALOG(wxT("The Uninstallation failed.") );
526 else if(bootloadermethod == wxT("iaudio") )
528 MESG_DIALOG(wxT("To uninstall the Bootloader on this Device,\n"
529 "you need to download and install an Original Firmware from the Manufacturer."));
531 else if(bootloadermethod == wxT("fwpatcher"))
533 MESG_DIALOG(wxT("To uninstall the Bootloader on this Device,\n"
534 "you need to download and install an original Firmware from the Manufacturer.\n"
535 "To do this, you need to boot into the original Firmware."));
537 else if(bootloadermethod == wxT("h10"))
539 if(h10(BOOTLOADER_REM,gv->plat_bootloadername[index],gv->curdestdir))
541 MESG_DIALOG(wxT("The Bootloader has been uninstalled."));
543 else
544 MESG_DIALOG(wxT("The Uninstallation failed.") );
546 else
548 MESG_DIALOG(wxT("Unsupported Bootloader Uninstall method.") );
551 wxLogVerbose(wxT("=== end rbutilFrm::OnBootloaderRemoveBtn"));
554 void rbutilFrm::OnBootloaderBtn(wxCommandEvent& event)
556 wxLogVerbose(wxT("=== begin rbutilFrm::OnBootloaderBtn(event)"));
558 int index = GetDeviceId(true);
559 if(index < 0)
560 return;
562 wxString bootloadermethod = gv->plat_bootloadermethod[index];
564 if(!gv->plat_needsbootloader[index])
566 WARN_DIALOG(wxT("This Device doesnt need a Bootloader"),
567 wxT("Bootloader"));
568 return;
571 // Bootloader dialog
572 if(bootloadermethod != wxT("ipodpatcher") && bootloadermethod != wxT("sansapatcher") )
574 bootloaderInstallDlg dialog(NULL, wxID_ANY,wxT("Bootloader Installation"));
575 if (dialog.ShowModal() != wxID_OK)
576 return;
579 // really install ?
580 wxMessageDialog msg(this,wxT("Do you really want to install the Bootloader ?"),wxT("Bootloader installation"),wxOK|wxCANCEL);
581 if(msg.ShowModal() != wxID_OK )
582 return;
585 if(bootloadermethod == wxT("ipodpatcher"))
587 wxString bootloadername = wxT("bootloader-");
588 bootloadername.Append(gv->plat_bootloadername[index] );
589 if(ipodpatcher(BOOTLOADER_ADD,bootloadername))
591 MESG_DIALOG(wxT("The Bootloader has been installed on your device.") );
593 else
595 MESG_DIALOG(wxT("The installation has failed.") );
598 else if(bootloadermethod == wxT("sansapatcher"))
600 if(sansapatcher(BOOTLOADER_ADD,gv->plat_bootloadername[index]))
602 MESG_DIALOG(wxT("The Bootloader has been installed on your device.") );
604 else
606 MESG_DIALOG(wxT("The installation has failed.") );
610 else if(bootloadermethod== wxT("gigabeatf"))
613 if(gigabeatf(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir))
615 MESG_DIALOG(wxT("The Bootloader has been installed on your device."));
617 else
618 MESG_DIALOG(wxT("The installation has failed.") );
620 else if(bootloadermethod == wxT("iaudio") )
622 if(iaudiox5(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir))
624 MESG_DIALOG(wxT("The Bootloader has been installed on your device.\n"
625 "Now turn OFF your Device, unplug USB,and insert Charger\n"
626 "Your Device will automatically upgrade the flash with the Rockbox bootloader"));
628 else
629 MESG_DIALOG(wxT("The installation has failed.") );
631 else if(bootloadermethod == wxT("fwpatcher"))
633 if(fwpatcher(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir,gv->curfirmware))
635 MESG_DIALOG(wxT("The Bootloader has been patched and copied on your device.\n"
636 "Now use the Firmware upgrade option of your Device\n"));
638 else
639 MESG_DIALOG(wxT("The installation has failed.") );
641 else if(bootloadermethod == wxT("h10"))
643 if(h10(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir))
645 MESG_DIALOG(wxT("The Bootloader has been patched and copied on your device.\n"));
647 else
648 MESG_DIALOG(wxT("The installation has failed.") );
650 else
652 MESG_DIALOG(wxT("Unsupported Bootloader Install method.") );
657 wxLogVerbose(wxT("=== end rbutilFrm::OnBootloaderBtn"));
661 void rbutilFrm::OnInstallBtn(wxCommandEvent& event)
663 wxString src, dest, buf;
664 wxDateTime date;
665 wxTimeSpan day(24);
666 wxLogVerbose(wxT("=== begin rbutilFrm::OnInstallBtn(event)"));
667 wxFileSystem fs;
668 wxFileConfig* buildinfo;
669 wxDateSpan oneday;
671 int index = GetDeviceId(true);
672 if(index < 0)
673 return;
675 // rockbox install dialog
676 rockboxInstallDlg dialog(NULL, wxID_ANY,
677 wxT("Rockbox Installation"));
678 if (dialog.ShowModal() != wxID_OK)
679 return;
681 // really install
682 wxMessageDialog msg(this,wxT("Do you really want to install Rockbox ?"),wxT("rockbox installation"),wxOK|wxCANCEL);
683 if(msg.ShowModal() != wxID_OK )
684 return;
687 switch (gv->curbuild)
689 case BUILD_RELEASE:
690 // This is a URL - don't use PATH_SEP
691 src = gv->download_url + gv->prog_name + wxT("-")
692 + gv->last_release + wxT("-") + gv->curplat + wxT(".zip");
693 dest = gv->stdpaths->GetUserDataDir() + wxT("download" PATH_SEP)
694 + gv->prog_name + wxT("-") + gv->last_release + wxT("-")
695 + gv->curplat + wxT(".zip");
696 break;
697 case BUILD_DAILY:
698 dest = gv->stdpaths->GetUserDataDir()
699 + PATH_SEP + wxT("download") + PATH_SEP + wxT("build-info");
700 if (DownloadURL(gv->server_conf_url, dest)) {
701 WARN_DIALOG(wxT("Unable to download build status."),
702 wxT("Install"));
703 buf = wxT("");
704 } else
706 buildinfo = new wxFileConfig(wxEmptyString,
707 wxEmptyString, dest);
708 buf = buildinfo->Read(wxT("/dailies/date"));
709 buildinfo->DeleteAll();
711 if (buf.Len() != 8) {
712 dest = wxT("Invalid build date: ") + buf;
713 WARN_DIALOG(dest, wxT("Install"));
714 buf = wxT("");
718 if (buf == wxT("")) {
719 WARN_DIALOG(wxT("Can't get date of latest build from "
720 "server. Using yesterday's date."), wxT("Install") );
721 date = wxDateTime::Now();
722 date.Subtract(oneday.Day());
723 buf = date.Format(wxT("%Y%m%d")); // yes, we want UTC
726 src = gv->daily_url + gv->curplat + wxT("/") + gv->prog_name
727 + wxT("-") + gv->curplat + wxT("-") + buf + wxT(".zip");
729 dest = gv->stdpaths->GetUserDataDir() + PATH_SEP wxT("download")
730 + gv->prog_name + wxT("-") + gv->curplat + wxT("-")
731 + buf + wxT(".zip");
732 break;
733 case BUILD_BLEEDING:
734 src = gv->bleeding_url + gv->curplat + wxT("/")
735 + gv->prog_name + wxT(".zip");
736 dest = gv->stdpaths->GetUserDataDir()
737 + PATH_SEP wxT("download") PATH_SEP
738 + gv->prog_name + wxT(".zip");
739 break;
740 default:
741 ERR_DIALOG(wxT("Something seriously odd has happened."),
742 wxT("Install"));
743 return;
744 break;
747 if (gv->nocache || ( ! wxFileExists(dest) ) )
749 if ( DownloadURL(src, dest) )
751 wxRemoveFile(dest);
752 ERR_DIALOG(wxT("Unable to download ")+src, wxT("Install"));
753 return;
757 if ( !UnzipFile(dest, gv->curdestdir, true) )
759 wxMessageDialog* msg = new wxMessageDialog(this, wxT("Rockbox has been installed on your device.")
760 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
761 msg->ShowModal();
762 delete msg;
763 } else
765 wxRemoveFile(dest);
766 ERR_DIALOG(wxT("Unable to unzip ")+dest, wxT("Install"));
770 wxLogVerbose(wxT("=== end rbutilFrm::OnInstallBtn"));
773 void rbutilFrm::OnFontBtn(wxCommandEvent& event)
775 wxString src, dest, buf;
776 wxDateTime date;
777 wxTimeSpan day(24);
778 wxLogVerbose(wxT("=== begin rbutilFrm::OnFontBtn(event)"));
779 wxFileSystem fs;
780 wxFileConfig* buildinfo;
781 wxDateSpan oneday;
783 int index = GetDeviceId(true);
784 if(index < 0)
785 return;
787 // font install dialog
788 fontInstallDlg dialog(NULL, wxID_ANY,
789 wxT("Font Installation"));
790 if (dialog.ShowModal() != wxID_OK)
791 return;
793 // really install ?
794 wxMessageDialog msg(this,wxT("Do you really want to install the Fonts ?"),wxT("Font installation"),wxOK|wxCANCEL);
795 if(msg.ShowModal() != wxID_OK )
796 return;
799 buf = gv->curdestdir + wxT("" PATH_SEP ".rockbox");
800 if (! wxDirExists(buf) )
802 WARN_DIALOG(wxT("Rockbox is not yet installed on ") + buf
803 + wxT(" - install Rockbox first."),
804 wxT("Can't install fonts") );
805 return;
808 dest = gv->stdpaths->GetUserDataDir()
809 + wxT( "" PATH_SEP "download" PATH_SEP "build-info");
810 if (DownloadURL(gv->server_conf_url, dest))
812 WARN_DIALOG(wxT("Unable to download build status."),
813 wxT("Font Install"));
814 buf = wxT("");
815 } else
817 buildinfo = new wxFileConfig(wxEmptyString,
818 wxEmptyString, dest);
819 buf = buildinfo->Read(wxT("/dailies/date"));
820 buildinfo->DeleteAll();
822 if (buf.Len() != 8) {
823 WARN_DIALOG(wxT("Invalid build date: ") + buf, wxT("Font Install"));
824 buf = wxT("");
828 if (buf == wxT("")) {
829 WARN_DIALOG(wxT("Can't get date of latest build from "
830 "server. Using yesterday's date."),
831 wxT("Font Install") );
832 date = wxDateTime::Now();
833 date.Subtract(oneday.Day());
834 buf = date.Format(wxT("%Y%m%d")); // yes, we want UTC
837 src = gv->font_url + buf + wxT(".zip");
839 dest = gv->stdpaths->GetUserDataDir() + wxT( "" PATH_SEP "download"
840 PATH_SEP "rockbox-fonts-") + buf + wxT(".zip");
842 if ( ! wxFileExists(dest) )
844 if ( DownloadURL(src, dest) )
846 wxRemoveFile(dest);
847 ERR_DIALOG(wxT("Unable to download ") + src, wxT("Font Install"));
848 return;
852 if ( !UnzipFile(dest, gv->curdestdir, true) )
854 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Rockbox fonts have been installed on your device.")
855 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
856 msg->ShowModal();
857 delete msg;
858 } else
860 wxRemoveFile(dest);
861 ERR_DIALOG(wxT("Unable to unzip ") + dest, wxT("Font Install"));
864 wxLogVerbose(wxT("=== end rbutilFrm::OnFontBtn"));
867 void rbutilFrm::OnDoomBtn(wxCommandEvent& event)
869 wxString src, dest, buf;
870 wxLogVerbose(wxT("=== begin rbutilFrm::OnDoomBtn(event)"));
872 int index = GetDeviceId(true);
873 if(index < 0)
874 return;
876 // font install dialog, reused
877 fontInstallDlg dialog(NULL, wxID_ANY,
878 wxT("Freedoom wad file Installation"));
879 if (dialog.ShowModal() != wxID_OK)
880 return;
882 // really install ?
883 wxMessageDialog msg(this,wxT("Do you really want to install the Freedoom wads ?"),wxT("Freedoom installation"),wxOK|wxCANCEL);
884 if(msg.ShowModal() != wxID_OK )
885 return;
887 buf = gv->curdestdir + wxT("" PATH_SEP ".rockbox");
888 if (! wxDirExists(buf) )
890 WARN_DIALOG(wxT("Rockbox is not yet installed on ") + buf
891 + wxT(" - install Rockbox first."),
892 wxT("Can't install freedoom wads") );
893 return;
896 src = gv->doom_url;
898 dest = gv->stdpaths->GetUserDataDir() + wxT("" PATH_SEP "download" PATH_SEP
899 "rockdoom.zip");
901 if ( ! wxFileExists(dest) )
903 if ( DownloadURL(src, dest) )
905 wxRemoveFile(dest);
906 ERR_DIALOG(wxT("Unable to download ") + src,
907 wxT("Freedoom Install"));
908 return;
912 if ( !UnzipFile(dest, gv->curdestdir, true) )
914 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Freedoom wads have been installed on your device.")
915 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
916 msg->ShowModal();
917 delete msg;
918 } else
920 wxRemoveFile(dest);
921 ERR_DIALOG(wxT("Unable to unzip ") + dest, wxT("Freedoom Install"));
925 wxLogVerbose(wxT("=== end rbutilFrm::OnDoomBtn"));
929 void rbutilFrm::OnThemesBtn(wxCommandEvent& event)
931 wxString src, dest, buf;
932 wxLogVerbose(wxT("=== begin rbutilFrm::OnThemesBtn(event)"));
934 int index = GetDeviceId(true);
935 if(index < 0)
936 return;
938 // Theme install dialog
939 themesInstallDlg dialog(NULL, wxID_ANY,
940 wxT("Theme Installation"));
941 if (dialog.ShowModal() != wxID_OK)
942 return;
944 // really install ?
945 wxMessageDialog msg(this,wxT("Do you really want to install the selected Themes ?"),wxT("Theme installation"),wxOK|wxCANCEL);
946 if(msg.ShowModal() != wxID_OK )
947 return;
949 bool success=true;
950 for(unsigned int i=0 ;i < gv->themesToInstall.GetCount();i++)
952 if(!InstallTheme(gv->themesToInstall[i]))
954 MESG_DIALOG(wxT("The Themes installation has failed") );
955 success=false;
956 break;
959 if(success)
961 MESG_DIALOG(wxT("The Theme installation completed successfully.") );
965 wxLogVerbose(wxT("=== end rbutilFrm::OnThemesBtn(event)"));
969 void rbutilFrm::OnRemoveBtn(wxCommandEvent& event)
971 wxLogVerbose(wxT("=== begin rbutilFrm::OnRemoveBtn(event)"));
973 int index = GetDeviceId(true);
974 if(index < 0)
975 return;
977 // Rockbox deinstall dialog
978 rockboxDeInstallDlg dialog(NULL, wxID_ANY,
979 wxT("Rockbox Deinstallation"));
980 if (dialog.ShowModal() != wxID_OK)
981 return;
983 // really install ?
984 wxMessageDialog msg(this,wxT("Do you really want to deinstall Rockbox ?"),wxT("Rockbox deinstallation"),wxOK|wxCANCEL);
985 if(msg.ShowModal() != wxID_OK )
986 return;
989 if (Uninstall(gv->curdestdir, gv->curisfull) )
991 MESG_DIALOG(
992 wxT("The uninstallation wizard was cancelled or completed with "
993 "some errors.") );
994 } else {
995 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The uninstall wizard completed successfully\n"
996 "Depending on which Device you own, you also have to uninstall the Bootloader")
997 ,wxT("Uninstallation"), wxOK |wxICON_INFORMATION);
998 msg->ShowModal();
999 delete msg;
1002 wxLogVerbose(wxT("=== end rbutilFrm::OnRemoveBtn"));
1005 void rbutilFrm::OnPortableInstall(wxCommandEvent& event)
1007 wxString src, dest, buf;
1008 wxLogVerbose(wxT("=== begin rbutilFrm::OnPortableInstall(event)"));
1009 wxFileSystem fs;
1010 wxDateSpan oneday;
1012 int index = GetDeviceId(true);
1013 if(index < 0)
1014 return;
1016 //portable install dialog ( reused font dialog)
1017 fontInstallDlg dialog(NULL, wxID_ANY,
1018 wxT("Rockbox Utility Portable Installation"));
1019 if (dialog.ShowModal() != wxID_OK)
1020 return;
1022 // really install ?
1023 wxMessageDialog msg(this,wxT("Do you really want a portable install of rbutil ?"),wxT("rbutil installation"),wxOK|wxCANCEL);
1024 if(msg.ShowModal() != wxID_OK )
1025 return;
1027 if ( InstallRbutil(gv->curdestdir) )
1029 MESG_DIALOG(wxT("The Rockbox Utility has been installed on your device."));
1031 } else
1033 ERR_DIALOG(wxT("Installation failed"), wxT("Portable Install"));
1036 wxLogVerbose(wxT("=== end rbutilFrm::OnUnstallPortable"));
1039 void rbutilFrm::OnTalkBtn(wxCommandEvent& event)
1041 wxLogVerbose(wxT("=== begin rbutilFrm::OnTalkBtn(event)"));
1043 TalkFileCreator talk;
1045 talkInstallDlg dialog(&talk,NULL,wxID_ANY);
1047 if (dialog.ShowModal() != wxID_OK)
1048 return;
1050 // really install ?
1051 wxMessageDialog msg(this,wxT("Do you really want to create Talkfiles ?"),wxT("Talk file creation"),wxOK|wxCANCEL);
1052 if(msg.ShowModal() != wxID_OK )
1053 return;
1055 if(talk.createTalkFiles())
1057 MESG_DIALOG(wxT("Talk files have been successfully created."));
1059 else
1061 ERR_DIALOG(wxT("Talkfile creation failed"), wxT("Talk file creation"));
1064 wxLogVerbose(wxT("=== end rbutilFrm::OnTalkBtn"));
1067 int rbutilFrm::GetDeviceId(bool detect)
1069 int index = gv->plat_id.Index(gv->curplat);
1070 if(index < 0 && detect)
1072 if( wxMessageBox(wxT("No device selected. Do you want to autodetect "
1073 "the device?"),
1074 wxT("Warning"), wxYES_NO ) == wxYES )
1076 myDeviceSelector->AutoDetect();
1077 index = gv->plat_id.Index(gv->curplat);
1078 if(index < 0)
1080 WARN_DIALOG( wxT("Aborting"), wxT("Auto detection failed") );
1081 return index;
1083 else
1085 if( wxMessageBox(wxT("Found ") + gv->plat_name[index] +
1086 wxT(". Do you want to continue?"),
1087 wxT("Device found"), wxYES_NO ) == wxYES )
1088 return index;
1089 else
1090 return -1;
1093 else
1095 return -1;
1098 return index;
1101 AboutDlg::AboutDlg(rbutilFrm* parent)
1102 : wxDialog(parent, -1, wxT("About"), wxDefaultPosition, wxDefaultSize,
1103 wxDEFAULT_DIALOG_STYLE)
1105 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
1106 this->SetSizer(WxBoxSizer1);
1107 this->SetAutoLayout(TRUE);
1109 wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
1111 wxBitmap WxBitmap1 = wxBitmap(rbutilFrm_XPM);
1112 wxStaticBitmap* WxStaticBitmap1 = new wxStaticBitmap(this, wxID_ANY,
1113 WxBitmap1);
1114 WxBoxSizer2->Add(WxStaticBitmap1, 0, wxALL | wxCENTER, 5);
1116 wxStaticText* WxStaticText1 = new wxStaticText(this, wxID_ANY,
1117 wxT(RBUTIL_FULLNAME), wxDefaultPosition, wxDefaultSize,
1118 wxALIGN_CENTER | wxST_NO_AUTORESIZE );
1119 WxBoxSizer2->Add(WxStaticText1, 0, wxALL | wxCENTER, 5);
1120 WxBoxSizer1->Add(WxBoxSizer2, 0, wxALL, 5);
1122 wxStaticText* WxStaticText2 = new wxStaticText(this, wxID_ANY,
1123 wxT(RBUTIL_VERSION "\n" RBUTIL_DESCRIPTION "\n\n" RBUTIL_COPYRIGHT));
1124 WxStaticText2->Wrap(400);
1125 WxBoxSizer1->Add(WxStaticText2, 0, wxALL, 5);
1127 wxHyperlinkCtrl* WxHyperlink1 = new wxHyperlinkCtrl(this, wxID_ANY,
1128 wxT(RBUTIL_WEBSITE), wxT(RBUTIL_WEBSITE) );
1129 WxBoxSizer1->Add(WxHyperlink1, 0, wxALL, 5);
1131 wxStaticBox* WxStaticBox1 = new wxStaticBox(this, wxID_ANY, wxT("Contributors:"));
1132 wxStaticBoxSizer* WxStaticBoxSizer2 = new wxStaticBoxSizer(WxStaticBox1,
1133 wxVERTICAL);
1134 wxTextCtrl* WxTextCtrl1 = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
1135 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY);
1137 long i = 0;
1138 while ( rbutil_developers[i] != wxT(""))
1140 WxTextCtrl1->AppendText(rbutil_developers[i++]);
1141 WxTextCtrl1->AppendText(wxT("\n"));
1144 WxBoxSizer1->Add(WxStaticBoxSizer2, 1, wxGROW | wxALL, 5);
1145 WxStaticBoxSizer2->Add(WxTextCtrl1, 1, wxGROW | wxALL, 0);
1147 wxStdDialogButtonSizer* WxStdDialogButtonSizer1 = new wxStdDialogButtonSizer();
1148 wxButton* WxOKButton = new wxButton(this, wxID_OK);
1149 WxStdDialogButtonSizer1->AddButton(WxOKButton);
1150 WxStdDialogButtonSizer1->Realize();
1152 WxBoxSizer1->Add(WxStdDialogButtonSizer1, 0, wxALL | wxCENTER, 5);
1154 GetSizer()->Fit(this);
1155 GetSizer()->SetSizeHints(this);
1157 //this->Center();
1158 this->Show();
1162 AboutDlg::~AboutDlg()