Fix the manual build issue on ubuntu by using printf instead of echo (FS#6919). Thank...
[Rockbox.git] / rbutil / rbutilFrm.cpp
blob0dc85c09b03046b5eb075c1d8e321ea63d754061
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 "install_3d.xpm"
26 #include "uninstall_3d.xpm"
27 #include "fonts_3d.xpm"
28 #include "tools2_3d.xpm"
29 #include "rblogo.xpm"
30 #include "untools2_3d.xpm"
31 #include "themes_3d.xpm"
32 #include "doom_3d.xpm"
34 #include "bootloaders.h"
35 #include "install_dialogs.h"
38 //----------------------------------------------------------------------------
39 // rbutilFrm
40 //----------------------------------------------------------------------------
42 BEGIN_EVENT_TABLE(rbutilFrm,wxFrame)
43 EVT_BUTTON (ID_INSTALL_BTN, rbutilFrm::OnInstallBtn)
44 EVT_BUTTON (ID_REMOVE_BTN, rbutilFrm::OnRemoveBtn)
45 EVT_BUTTON (ID_FONT_BTN, rbutilFrm::OnFontBtn)
46 EVT_BUTTON (ID_THEMES_BTN, rbutilFrm::OnThemesBtn)
47 EVT_BUTTON (ID_BOOTLOADER_BTN, rbutilFrm::OnBootloaderBtn)
48 EVT_BUTTON (ID_BOOTLOADERREMOVE_BTN, rbutilFrm::OnBootloaderRemoveBtn)
49 EVT_BUTTON (ID_DOOM_BTN, rbutilFrm::OnDoomBtn)
52 EVT_CLOSE(rbutilFrm::rbutilFrmClose)
53 EVT_MENU(ID_FILE_EXIT, rbutilFrm::OnFileExit)
54 EVT_MENU(ID_FILE_ABOUT, rbutilFrm::OnFileAbout)
55 EVT_MENU(ID_FILE_WIPECACHE, rbutilFrm::OnFileWipeCache)
56 EVT_MENU(ID_PORTABLE_INSTALL, rbutilFrm::OnPortableInstall)
58 EVT_MENU(ID_FILE_PROXY, rbutilFrm::OnFileProxy)
60 EVT_UPDATE_UI (ID_MANUAL, rbutilFrm::OnManualUpdate)
62 END_EVENT_TABLE()
64 rbutilFrm::rbutilFrm( wxWindow *parent, wxWindowID id, const wxString &title,
65 const wxPoint &position, const wxSize& size, long style )
66 : wxFrame( parent, id, title, position, size, style)
68 wxLogVerbose(wxT("=== begin rbutilFrm::rbutilFrm(...)"));
69 CreateGUIControls();
70 wxLogVerbose(wxT("=== end rbutilFrm::rbutilFrm"));
73 rbutilFrm::~rbutilFrm() {}
75 void rbutilFrm::CreateGUIControls(void)
77 wxLogVerbose(wxT("=== begin rbutilFrm::CreateGUIControls()"));
79 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
80 this->SetSizer(WxBoxSizer1);
81 this->SetAutoLayout(TRUE);
83 wxPanel* mainPanel = new wxPanel(this,wxID_ANY);
84 WxBoxSizer1->Add(mainPanel,1,wxGROW|wxALL,0);
85 wxBoxSizer* WxBoxSizer0 = new wxBoxSizer(wxVERTICAL);
86 mainPanel->SetSizer(WxBoxSizer0);
87 mainPanel->SetAutoLayout(TRUE);
89 wxBitmap rockboxbmp(rblogo_xpm);
90 ImageCtrl* rockboxbmpCtrl = new ImageCtrl(mainPanel,wxID_ANY);
91 rockboxbmpCtrl->SetBitmap(rockboxbmp);
93 WxBoxSizer0->Add(rockboxbmpCtrl,0,wxALIGN_CENTER_HORIZONTAL | wxALL,5);
95 myDeviceSelector = new DeviceSelectorCtrl(mainPanel,wxID_ANY);
96 myDeviceSelector->setDefault();
97 WxBoxSizer0->Add(myDeviceSelector,0,wxGROW|wxALL,5);
99 wxNotebook* tabwindow = new wxNotebook(mainPanel,wxID_ANY);
100 WxBoxSizer0->Add(tabwindow,1,wxGROW|wxALL,5);
102 wxPanel* installpage = new wxPanel(tabwindow,wxID_ANY);
103 wxPanel* themepage = new wxPanel(tabwindow,wxID_ANY);
104 wxPanel* uninstallpage = new wxPanel(tabwindow,wxID_ANY);
105 wxPanel* manualpage = new wxPanel(tabwindow,wxID_ANY);
106 tabwindow->AddPage(installpage,wxT("Installation"),true);
107 tabwindow->AddPage(themepage,wxT("Extras"));
108 tabwindow->AddPage(uninstallpage,wxT("Uninstallation"));
109 tabwindow->AddPage(manualpage,wxT("Manual"));
111 /*********************
112 Install Page
113 ***********************/
115 wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxVERTICAL);
116 installpage->SetSizer(WxBoxSizer2);
117 installpage->SetAutoLayout(TRUE);
119 wxStaticBox* WxStaticBoxSizer3_StaticBoxObj = new wxStaticBox(installpage,
120 wxID_ANY, wxT("Please choose an option"));
121 wxStaticBoxSizer* WxStaticBoxSizer3 =
122 new wxStaticBoxSizer(WxStaticBoxSizer3_StaticBoxObj,wxHORIZONTAL);
123 WxBoxSizer2->Add(WxStaticBoxSizer3,1,wxALIGN_CENTER_HORIZONTAL|wxGROW | wxALL, 5);
125 wxFlexGridSizer* WxFlexGridSizer1 = new wxFlexGridSizer(2,2,0,0);
126 WxStaticBoxSizer3->Add(WxFlexGridSizer1,0,wxGROW | wxALL,0);
128 wxBitmap BootloaderInstallButton (tools2_3d_xpm);
129 WxBitmapButton4 = new wxBitmapButton(installpage, ID_BOOTLOADER_BTN,
130 BootloaderInstallButton, wxPoint(0,0), wxSize(64,54),
131 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,wxT("Bootloader Installation"));
132 WxBitmapButton4->SetToolTip(wxT("Click here to install the Rockbox bootloader"));
133 WxFlexGridSizer1->Add(WxBitmapButton4, 0,
134 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
136 wxStaticText* WxStaticText5 = new wxStaticText(installpage, wxID_ANY,
137 wxT("Bootloader installation instructions\n\n"
138 "Before Rockbox can be installed on your audio player, you "
139 "may have to\ninstall a bootloader.\nThis is only necessary the first time "
140 "Rockbox is installed."));
141 WxFlexGridSizer1->Add(WxStaticText5, 0,
142 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
144 wxBitmap WxBitmapButton1_BITMAP (install_3d_xpm);
145 WxBitmapButton1 = new wxBitmapButton(installpage, ID_INSTALL_BTN,
146 WxBitmapButton1_BITMAP, wxPoint(0,0), wxSize(64,54),
147 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
148 wxT("Rockbox Installation"));
149 WxBitmapButton1->SetToolTip(wxT("Click here to install Rockbox"));
150 WxFlexGridSizer1->Add(WxBitmapButton1,0,
151 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
153 WxStaticText2 = new wxStaticText(installpage, ID_WXSTATICTEXT2,
154 wxT("Install Rockbox on your audio player"));
155 WxFlexGridSizer1->Add(WxStaticText2,0,
156 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
158 /*********************+
159 Extras Page
160 ***********************/
162 wxBoxSizer* WxBoxSizer3 = new wxBoxSizer(wxVERTICAL);
163 themepage->SetSizer(WxBoxSizer3);
164 themepage->SetAutoLayout(TRUE);
166 wxStaticBox* WxStaticBoxSizer4_StaticBoxObj = new wxStaticBox(themepage,
167 wxID_ANY, wxT("Please choose an option"));
168 wxStaticBoxSizer* WxStaticBoxSizer4 =
169 new wxStaticBoxSizer(WxStaticBoxSizer4_StaticBoxObj,wxHORIZONTAL);
170 WxBoxSizer3->Add(WxStaticBoxSizer4,1,wxALIGN_CENTER_HORIZONTAL |wxGROW| wxALL, 5);
172 wxFlexGridSizer* WxFlexGridSizer2 = new wxFlexGridSizer(2,2,0,0);
173 WxStaticBoxSizer4->Add(WxFlexGridSizer2,0,wxGROW | wxALL,0);
175 wxBitmap FontInstallButton (fonts_3d_xpm);
176 WxBitmapButton3 = new wxBitmapButton(themepage, ID_FONT_BTN,
177 FontInstallButton, wxPoint(0,0), wxSize(64,54),
178 wxRAISED_BORDER | wxBU_AUTODRAW,wxDefaultValidator, wxT("Font installation"));
179 WxBitmapButton3->SetToolTip(wxT("Click here to install the most up to date "
180 "Rockbox fonts."));
181 WxFlexGridSizer2->Add(WxBitmapButton3, 0,
182 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
184 wxStaticText* WxStaticText4 = new wxStaticText(themepage, wxID_ANY,
185 wxT("Install the Rockbox fonts package\n\n"
186 "This step is needed for many Themes. You "
187 "will not need to download these\nagain unless you uninstall "
188 "Rockbox."));
189 WxFlexGridSizer2->Add(WxStaticText4, 0,
190 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
192 wxBitmap ThemesInstallButton (themes_3d_xpm);
193 WxBitmapButton5 = new wxBitmapButton(themepage, ID_THEMES_BTN,
194 ThemesInstallButton, wxPoint(0,0), wxSize(64,54),
195 wxRAISED_BORDER | wxBU_AUTODRAW,wxDefaultValidator, wxT("Theme installation"));
196 WxBitmapButton5->SetToolTip(wxT("Click here to install themes for Rockbox."));
197 WxFlexGridSizer2->Add(WxBitmapButton5, 0,
198 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
200 wxStaticText* WxStaticText6 = new wxStaticText(themepage, wxID_ANY,
201 wxT("Install more Themes for Rockbox.\n\n"));
202 WxFlexGridSizer2->Add(WxStaticText6, 0,
203 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
206 wxBitmap DoomInstallButton (doom_3d_xpm);
207 WxBitmapButton6 = new wxBitmapButton(themepage, ID_DOOM_BTN,
208 DoomInstallButton, wxPoint(0,0), wxSize(64,54),
209 wxRAISED_BORDER | wxBU_AUTODRAW,wxDefaultValidator, wxT("Freedoom installation"));
210 WxBitmapButton6->SetToolTip(wxT("Click here to install the freedoom wad files."));
211 WxFlexGridSizer2->Add(WxBitmapButton6, 0,
212 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
214 wxStaticText* WxStaticText7 = new wxStaticText(themepage, wxID_ANY,
215 wxT("Install the freedoom wad files.\n\n"));
216 WxFlexGridSizer2->Add(WxStaticText7, 0,
217 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
219 /*********************+
220 Uninstall Page
221 ***********************/
223 wxBoxSizer* WxBoxSizer4 = new wxBoxSizer(wxVERTICAL);
224 uninstallpage->SetSizer(WxBoxSizer4);
225 uninstallpage->SetAutoLayout(TRUE);
227 wxStaticBox* WxStaticBoxSizer5_StaticBoxObj = new wxStaticBox(uninstallpage,
228 wxID_ANY, wxT("Please choose an option"));
229 wxStaticBoxSizer* WxStaticBoxSizer5 =
230 new wxStaticBoxSizer(WxStaticBoxSizer5_StaticBoxObj,wxHORIZONTAL);
231 WxBoxSizer4->Add(WxStaticBoxSizer5,1,wxALIGN_CENTER_HORIZONTAL|wxGROW | wxALL, 5);
233 wxFlexGridSizer* WxFlexGridSizer3 = new wxFlexGridSizer(2,2,0,0);
234 WxStaticBoxSizer5->Add(WxFlexGridSizer3,0,wxGROW | wxALL,0);
236 wxBitmap WxBitmapButton2_BITMAP (uninstall_3d_xpm);
237 WxBitmapButton2 = new wxBitmapButton(uninstallpage, ID_REMOVE_BTN,
238 WxBitmapButton2_BITMAP, wxPoint(0,0), wxSize(64,54),
239 wxRAISED_BORDER | wxBU_AUTODRAW,wxDefaultValidator, wxT("Rockbox uninstallation"));
240 WxBitmapButton2->SetToolTip(wxT("Click here to uninstall Rockbox"));
241 WxFlexGridSizer3->Add(WxBitmapButton2,0,
242 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
244 WxStaticText3 = new wxStaticText(uninstallpage, ID_WXSTATICTEXT3,
245 wxT("Remove Rockbox from your audio player"));
246 WxFlexGridSizer3->Add(WxStaticText3,0,
247 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
249 wxBitmap WxBitmapButton4_BITMAP (untools2_3d_xpm);
250 WxBitmapButton4 = new wxBitmapButton(uninstallpage, ID_BOOTLOADERREMOVE_BTN,
251 WxBitmapButton4_BITMAP, wxPoint(0,0), wxSize(64,54),
252 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
253 wxT("Bootloader uninstallation"));
254 WxBitmapButton4->SetToolTip(wxT("Click here to uninstall the Bootloader"));
255 WxFlexGridSizer3->Add(WxBitmapButton4,0,
256 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
258 WxStaticText4 = new wxStaticText(uninstallpage, ID_WXSTATICTEXT4,
259 wxT("Remove Rockbox Bootloader from your audio player"));
260 WxFlexGridSizer3->Add(WxStaticText4,0,
261 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
264 /*****************
265 * Manual Page
266 ******************/
268 wxBoxSizer* WxBoxSizer5 = new wxBoxSizer(wxVERTICAL);
269 manualpage->SetSizer(WxBoxSizer5);
270 manualpage->SetAutoLayout(TRUE);
272 manuallink = new wxHyperlinkCtrl(manualpage,wxID_ANY,wxT("Rockbox PDF Manual"),wxT("http://www.rockbox.org"));
273 WxBoxSizer5->Add(manuallink,1,wxGROW | wxALL, 5);
275 manual =new wxHtmlWindow(manualpage,ID_MANUAL);
276 WxBoxSizer5->Add(manual,10,wxGROW | wxALL, 5);
279 /**********
280 ** rest of the controls
281 **********/
283 WxMenuBar1 = new wxMenuBar();
284 wxMenu *ID_FILE_MENU_Mnu_Obj = new wxMenu(0);
285 WxMenuBar1->Append(ID_FILE_MENU_Mnu_Obj, wxT("&File"));
287 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_WIPECACHE,
288 wxT("&Empty local download cache"), wxT(""), wxITEM_NORMAL);
289 if (! gv->portable )
291 ID_FILE_MENU_Mnu_Obj->Append(ID_PORTABLE_INSTALL,
292 wxT("&Install Rockbox Utility on device"), wxT(""), wxITEM_NORMAL);
294 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_PROXY, wxT("Set &Proxy"), wxT(""),
295 wxITEM_NORMAL);
296 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_ABOUT, wxT("&About"), wxT(""),
297 wxITEM_NORMAL);
298 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_EXIT, wxT("E&xit\tCtrl+X"), wxT(""),
299 wxITEM_NORMAL);
301 this->SetMenuBar(WxMenuBar1);
302 Layout();
303 GetSizer()->Fit(this);
304 GetSizer()->SetSizeHints(this);
305 if (gv->portable)
307 this->SetTitle(wxT("Rockbox Utility (portable)"));
308 } else
310 this->SetTitle(wxT("Rockbox Utility"));
312 this->Center();
313 wxIcon rbutilFrm_ICON (rbutilFrm_XPM);
314 this->SetIcon(rbutilFrm_XPM);
315 this->SetToolTip(wxT("Install Rockbox"));
317 wxLogVerbose(wxT("=== end rbutilFrm::CreateGUIControls"));
320 void rbutilFrm::OnManualUpdate(wxUpdateUIEvent& event)
322 wxString tmp = gv->curplat;
324 if(tmp == wxT("h120")) tmp = wxT("h100"); //h120 has the h100 manual
325 if(tmp == wxT("fmrecorder8mb")) tmp = wxT("fmrecorder");
326 if(tmp == wxT("ipodmini1g")) tmp = wxT("ipodmini2g");
327 if(tmp == wxT("recorder8mb")) tmp = wxT("recorder");
329 if( tmp == curManualDevice)
330 return;
332 curManualDevice = tmp;
334 // construct link to pdf
335 wxString pdflink;
336 pdflink = gv->manual_url + curManualDevice + wxT(".pdf");
337 manuallink->SetURL(pdflink);
339 // construct link to html
340 wxString htmllink;
341 htmllink = gv->manual_url + curManualDevice + wxT("/rockbox-build.html");
342 if(!manual->LoadPage(htmllink))
343 manual->SetPage(wxT("<p>unable to display manual -- please use the PDF link above</p>"));
349 void rbutilFrm::OnFileProxy(wxCommandEvent& event)
352 wxTextEntryDialog proxydlg(this,wxT("Please enter your Proxy in the Format: URL:PORT"),wxT("Proxy Configuration"));
354 if(proxydlg.ShowModal() == wxID_OK)
356 gv->proxy_url = proxydlg.GetValue();
362 void rbutilFrm::rbutilFrmClose(wxCloseEvent& event)
364 wxLogVerbose(wxT("=== begin rbutilFrm::rbutilFrmClose(event)"));
365 Destroy();
366 wxLogVerbose(wxT("=== end rbutilFrm::rbutilFrmClose"));
372 * OnFileExit
374 void rbutilFrm::OnFileExit(wxCommandEvent& event)
376 wxLogVerbose(wxT("=== begin rbutilFrm::OnFileExit(event)"));
377 Close();
378 wxLogVerbose(wxT("=== end rbutilFrm::OnFileExit"));
381 // The routines this code uses are in the wxWidgets documentation, but
382 // not yet the library (2.7.0-1). This code can be re-enabled later.
384 void rbutilFrm::OnFileAbout(wxCommandEvent& event)
387 wxAboutDialogInfo *info = new wxAboutDialogInfo();
389 info->SetName(wxT(RBUTIL_FULLNAME));
390 info->SetVersion(wxT(RBUTIL_VERSION));
391 info->SetCopyright(wxT(RBUTIL_COPYRIGHT));
392 info->SetDescription(wxT(RBUTIL_DESCRIPTION));
393 info->SetWebSite(wxT(RBUTIL_WEBSITE));
395 long i = 0;
396 while (rbutil_developers[i] != "")
398 info->AddDeveloper(wxT(rbutil_developers[i++]));
401 wxAboutBox(*info);
402 delete info;
405 AboutDlg(this).ShowModal();
408 void rbutilFrm::OnFileWipeCache(wxCommandEvent& event)
410 wxString cacheloc, datadir;
412 datadir = gv->stdpaths->GetUserDataDir();
413 if (datadir == wxT(""))
415 ERR_DIALOG(wxT("Can't locate user data directory. Unable to delete "
416 "cache."), wxT("Delete download cache.") );
417 return;
420 cacheloc = datadir + wxT("" PATH_SEP "download");
422 if (! rm_rf(cacheloc) )
424 wxMessageDialog* msg = new wxMessageDialog(this, wxT("Local download cache has been deleted.")
425 , wxT("Cache deletion"), wxOK |wxICON_INFORMATION);
426 msg->ShowModal();
427 delete msg;
429 else {
430 MESG_DIALOG(wxT("Errors occured deleting the local download cache."));
433 wxMkdir(cacheloc, 0777);
436 void rbutilFrm::OnBootloaderRemoveBtn(wxCommandEvent& event)
438 wxLogVerbose(wxT("=== begin rbutilFrm::OnBootloaderRemoveBtn(event)"));
440 int index = GetDeviceId();
441 if(index < 0)
442 return;
444 wxString bootloadermethod = gv->plat_bootloadermethod[index];
446 if(!gv->plat_needsbootloader[index])
448 WARN_DIALOG(wxT("This Device doesnt need a Bootloader"),
449 wxT("Bootloader"));
450 return;
453 // really deinstall ?
454 wxMessageDialog msg(this,wxT("Do you really want to deinstall the Bootloader ?"),wxT("Bootloader deinstallation"),wxOK|wxCANCEL);
455 if(msg.ShowModal() != wxID_OK )
456 return;
459 if(bootloadermethod == wxT("ipodpatcher"))
461 wxString bootloadername = wxT("bootloader-");
462 bootloadername.Append(gv->plat_bootloadername[index] );
463 if(ipodpatcher(BOOTLOADER_REM,bootloadername))
465 MESG_DIALOG(wxT("The Bootloader has been uninstalled.") );
467 else
469 MESG_DIALOG(wxT("The Uninstallation failed.") );
472 if(bootloadermethod == wxT("sansapatcher"))
474 if(sansapatcher(BOOTLOADER_REM,gv->plat_bootloadername[index]))
476 MESG_DIALOG(wxT("The Bootloader has been uninstalled.") );
478 else
480 MESG_DIALOG(wxT("The Uninstallation failed.") );
483 else if(bootloadermethod== wxT("gigabeatf"))
486 if(gigabeatf(BOOTLOADER_REM,gv->plat_bootloadername[index],gv->curdestdir))
488 MESG_DIALOG(wxT("The Bootloader has been uninstalled."));
490 else
491 MESG_DIALOG(wxT("The Uninstallation failed.") );
493 else if(bootloadermethod == wxT("iaudio") )
495 MESG_DIALOG(wxT("To uninstall the Bootloader on this Device,\n"
496 "you need to download and install an Original Firmware from the Manufacturer."));
498 else if(bootloadermethod == wxT("fwpatcher"))
500 MESG_DIALOG(wxT("To uninstall the Bootloader on this Device,\n"
501 "you need to download and install an original Firmware from the Manufacturer.\n"
502 "To do this, you need to boot into the original Firmware."));
504 else if(bootloadermethod == wxT("h10"))
506 if(h10(BOOTLOADER_REM,gv->plat_bootloadername[index],gv->curdestdir))
508 MESG_DIALOG(wxT("The Bootloader has been uninstalled."));
510 else
511 MESG_DIALOG(wxT("The Uninstallation failed.") );
513 else
515 MESG_DIALOG(wxT("Unsupported Bootloader Uninstall method.") );
518 wxLogVerbose(wxT("=== end rbutilFrm::OnBootloaderRemoveBtn"));
521 void rbutilFrm::OnBootloaderBtn(wxCommandEvent& event)
523 wxLogVerbose(wxT("=== begin rbutilFrm::OnBootloaderBtn(event)"));
525 int index = GetDeviceId();
526 if(index < 0)
527 return;
529 wxString bootloadermethod = gv->plat_bootloadermethod[index];
531 if(!gv->plat_needsbootloader[index])
533 WARN_DIALOG(wxT("This Device doesnt need a Bootloader"),
534 wxT("Bootloader"));
535 return;
538 // Bootloader dialog
539 if(bootloadermethod != wxT("ipodpatcher") && bootloadermethod != wxT("sansapatcher") )
541 bootloaderInstallDlg dialog(NULL, wxID_ANY,wxT("Bootloader Installation"));
542 if (dialog.ShowModal() != wxID_OK)
543 return;
546 // really install ?
547 wxMessageDialog msg(this,wxT("Do you really want to install the Bootloader ?"),wxT("Bootloader installation"),wxOK|wxCANCEL);
548 if(msg.ShowModal() != wxID_OK )
549 return;
552 if(bootloadermethod == wxT("ipodpatcher"))
554 wxString bootloadername = wxT("bootloader-");
555 bootloadername.Append(gv->plat_bootloadername[index] );
556 if(ipodpatcher(BOOTLOADER_ADD,bootloadername))
558 MESG_DIALOG(wxT("The Bootloader has been installed on your device.") );
560 else
562 MESG_DIALOG(wxT("The installation has failed.") );
565 if(bootloadermethod == wxT("sansapatcher"))
567 if(sansapatcher(BOOTLOADER_ADD,gv->plat_bootloadername[index]))
569 MESG_DIALOG(wxT("The Bootloader has been installed on your device.") );
571 else
573 MESG_DIALOG(wxT("The installation has failed.") );
577 else if(bootloadermethod== wxT("gigabeatf"))
580 if(gigabeatf(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir))
582 MESG_DIALOG(wxT("The Bootloader has been installed on your device."));
584 else
585 MESG_DIALOG(wxT("The installation has failed.") );
587 else if(bootloadermethod == wxT("iaudio") )
589 if(iaudiox5(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir))
591 MESG_DIALOG(wxT("The Bootloader has been installed on your device.\n"
592 "Now turn OFF your Device, unplug USB,and insert Charger\n"
593 "Your Device will automatically upgrade the flash with the Rockbox bootloader"));
595 else
596 MESG_DIALOG(wxT("The installation has failed.") );
598 else if(bootloadermethod == wxT("fwpatcher"))
600 if(fwpatcher(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir,gv->curfirmware))
602 MESG_DIALOG(wxT("The Bootloader has been patched and copied on your device.\n"
603 "Now use the Firmware upgrade option of your Device\n"));
605 else
606 MESG_DIALOG(wxT("The installation has failed.") );
608 else if(bootloadermethod == wxT("h10"))
610 if(h10(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir))
612 MESG_DIALOG(wxT("The Bootloader has been patched and copied on your device.\n"));
614 else
615 MESG_DIALOG(wxT("The installation has failed.") );
617 else
619 MESG_DIALOG(wxT("Unsupported Bootloader Install method.") );
624 wxLogVerbose(wxT("=== end rbutilFrm::OnBootloaderBtn"));
628 void rbutilFrm::OnInstallBtn(wxCommandEvent& event)
630 wxString src, dest, buf;
631 wxDateTime date;
632 wxTimeSpan day(24);
633 wxLogVerbose(wxT("=== begin rbutilFrm::OnInstallBtn(event)"));
634 wxFileSystem fs;
635 wxFileConfig* buildinfo;
636 wxDateSpan oneday;
638 int index = GetDeviceId();
639 if(index < 0)
640 return;
642 // rockbox install dialog
643 rockboxInstallDlg dialog(NULL, wxID_ANY,
644 wxT("Rockbox Installation"));
645 if (dialog.ShowModal() != wxID_OK)
646 return;
648 // really install
649 wxMessageDialog msg(this,wxT("Do you really want to install Rockbox ?"),wxT("rockbox installation"),wxOK|wxCANCEL);
650 if(msg.ShowModal() != wxID_OK )
651 return;
654 switch (gv->curbuild)
656 case BUILD_RELEASE:
657 // This is a URL - don't use PATH_SEP
658 src = gv->download_url + gv->prog_name + wxT("-")
659 + gv->last_release + wxT("-") + gv->curplat + wxT(".zip");
660 dest = gv->stdpaths->GetUserDataDir() + wxT("download" PATH_SEP)
661 + gv->prog_name + wxT("-") + gv->last_release + wxT("-")
662 + gv->curplat + wxT(".zip");
663 break;
664 case BUILD_DAILY:
665 dest = gv->stdpaths->GetUserDataDir()
666 + PATH_SEP + wxT("download") + PATH_SEP + wxT("build-info");
667 if (DownloadURL(gv->server_conf_url, dest)) {
668 WARN_DIALOG(wxT("Unable to download build status."),
669 wxT("Install"));
670 buf = wxT("");
671 } else
673 buildinfo = new wxFileConfig(wxEmptyString,
674 wxEmptyString, dest);
675 buf = buildinfo->Read(wxT("/dailies/date"));
676 buildinfo->DeleteAll();
678 if (buf.Len() != 8) {
679 dest = wxT("Invalid build date: ") + buf;
680 WARN_DIALOG(dest, wxT("Install"));
681 buf = wxT("");
685 if (buf == wxT("")) {
686 WARN_DIALOG(wxT("Can't get date of latest build from "
687 "server. Using yesterday's date."), wxT("Install") );
688 date = wxDateTime::Now();
689 date.Subtract(oneday.Day());
690 buf = date.Format(wxT("%Y%m%d")); // yes, we want UTC
693 src = gv->daily_url + gv->curplat + wxT("/") + gv->prog_name
694 + wxT("-") + gv->curplat + wxT("-") + buf + wxT(".zip");
696 dest = gv->stdpaths->GetUserDataDir() + PATH_SEP wxT("download")
697 + gv->prog_name + wxT("-") + gv->curplat + wxT("-")
698 + buf + wxT(".zip");
699 break;
700 case BUILD_BLEEDING:
701 src = gv->bleeding_url + gv->curplat + wxT("/")
702 + gv->prog_name + wxT(".zip");
703 dest = gv->stdpaths->GetUserDataDir()
704 + PATH_SEP wxT("download") PATH_SEP
705 + gv->prog_name + wxT(".zip");
706 break;
707 default:
708 ERR_DIALOG(wxT("Something seriously odd has happened."),
709 wxT("Install"));
710 return;
711 break;
714 if (gv->nocache || ( ! wxFileExists(dest) ) )
716 if ( DownloadURL(src, dest) )
718 wxRemoveFile(dest);
719 ERR_DIALOG(wxT("Unable to download ")+src, wxT("Install"));
720 return;
724 if ( !UnzipFile(dest, gv->curdestdir, true) )
726 wxMessageDialog* msg = new wxMessageDialog(this, wxT("Rockbox has been installed on your device.")
727 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
728 msg->ShowModal();
729 delete msg;
730 } else
732 wxRemoveFile(dest);
733 ERR_DIALOG(wxT("Unable to unzip ")+dest, wxT("Install"));
737 wxLogVerbose(wxT("=== end rbutilFrm::OnInstallBtn"));
740 void rbutilFrm::OnFontBtn(wxCommandEvent& event)
742 wxString src, dest, buf;
743 wxDateTime date;
744 wxTimeSpan day(24);
745 wxLogVerbose(wxT("=== begin rbutilFrm::OnFontBtn(event)"));
746 wxFileSystem fs;
747 wxFileConfig* buildinfo;
748 wxDateSpan oneday;
750 int index = GetDeviceId();
751 if(index < 0)
752 return;
754 // font install dialog
755 fontInstallDlg dialog(NULL, wxID_ANY,
756 wxT("Font Installation"));
757 if (dialog.ShowModal() != wxID_OK)
758 return;
760 // really install ?
761 wxMessageDialog msg(this,wxT("Do you really want to install the Fonts ?"),wxT("Font installation"),wxOK|wxCANCEL);
762 if(msg.ShowModal() != wxID_OK )
763 return;
766 buf = gv->curdestdir + wxT("" PATH_SEP ".rockbox");
767 if (! wxDirExists(buf) )
769 WARN_DIALOG(wxT("Rockbox is not yet installed on ") + buf
770 + wxT(" - install Rockbox first."),
771 wxT("Can't install fonts") );
772 return;
775 dest = gv->stdpaths->GetUserDataDir()
776 + wxT( "" PATH_SEP "download" PATH_SEP "build-info");
777 if (DownloadURL(gv->server_conf_url, dest))
779 WARN_DIALOG(wxT("Unable to download build status."),
780 wxT("Font Install"));
781 buf = wxT("");
782 } else
784 buildinfo = new wxFileConfig(wxEmptyString,
785 wxEmptyString, dest);
786 buf = buildinfo->Read(wxT("/dailies/date"));
787 buildinfo->DeleteAll();
789 if (buf.Len() != 8) {
790 WARN_DIALOG(wxT("Invalid build date: ") + buf, wxT("Font Install"));
791 buf = wxT("");
795 if (buf == wxT("")) {
796 WARN_DIALOG(wxT("Can't get date of latest build from "
797 "server. Using yesterday's date."),
798 wxT("Font Install") );
799 date = wxDateTime::Now();
800 date.Subtract(oneday.Day());
801 buf = date.Format(wxT("%Y%m%d")); // yes, we want UTC
804 src = gv->font_url + buf + wxT(".zip");
806 dest = gv->stdpaths->GetUserDataDir() + wxT( "" PATH_SEP "download"
807 PATH_SEP "rockbox-fonts-") + buf + wxT(".zip");
809 if ( ! wxFileExists(dest) )
811 if ( DownloadURL(src, dest) )
813 wxRemoveFile(dest);
814 ERR_DIALOG(wxT("Unable to download ") + src, wxT("Font Install"));
815 return;
819 if ( !UnzipFile(dest, gv->curdestdir, true) )
821 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Rockbox fonts have been installed on your device.")
822 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
823 msg->ShowModal();
824 delete msg;
825 } else
827 wxRemoveFile(dest);
828 ERR_DIALOG(wxT("Unable to unzip ") + dest, wxT("Font Install"));
831 wxLogVerbose(wxT("=== end rbutilFrm::OnFontBtn"));
834 void rbutilFrm::OnDoomBtn(wxCommandEvent& event)
836 wxString src, dest, buf;
837 wxLogVerbose(wxT("=== begin rbutilFrm::OnDoomBtn(event)"));
839 int index = GetDeviceId();
840 if(index < 0)
841 return;
843 // font install dialog, reused
844 fontInstallDlg dialog(NULL, wxID_ANY,
845 wxT("Freedoom wad file Installation"));
846 if (dialog.ShowModal() != wxID_OK)
847 return;
849 // really install ?
850 wxMessageDialog msg(this,wxT("Do you really want to install the Freedoom wads ?"),wxT("Freedoom installation"),wxOK|wxCANCEL);
851 if(msg.ShowModal() != wxID_OK )
852 return;
854 buf = gv->curdestdir + wxT("" PATH_SEP ".rockbox");
855 if (! wxDirExists(buf) )
857 WARN_DIALOG(wxT("Rockbox is not yet installed on ") + buf
858 + wxT(" - install Rockbox first."),
859 wxT("Can't install freedoom wads") );
860 return;
863 src = gv->doom_url;
865 dest = gv->stdpaths->GetUserDataDir() + wxT("" PATH_SEP "download" PATH_SEP
866 "rockdoom.zip");
868 if ( ! wxFileExists(dest) )
870 if ( DownloadURL(src, dest) )
872 wxRemoveFile(dest);
873 ERR_DIALOG(wxT("Unable to download ") + src,
874 wxT("Freedoom Install"));
875 return;
879 if ( !UnzipFile(dest, gv->curdestdir, true) )
881 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Freedoom wads have been installed on your device.")
882 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
883 msg->ShowModal();
884 delete msg;
885 } else
887 wxRemoveFile(dest);
888 ERR_DIALOG(wxT("Unable to unzip ") + dest, wxT("Freedoom Install"));
892 wxLogVerbose(wxT("=== end rbutilFrm::OnDoomBtn"));
896 void rbutilFrm::OnThemesBtn(wxCommandEvent& event)
898 wxString src, dest, buf;
899 wxLogVerbose(wxT("=== begin rbutilFrm::OnThemesBtn(event)"));
901 int index = GetDeviceId();
902 if(index < 0)
903 return;
905 // Theme install dialog
906 themesInstallDlg dialog(NULL, wxID_ANY,
907 wxT("Theme Installation"));
908 if (dialog.ShowModal() != wxID_OK)
909 return;
911 // really install ?
912 wxMessageDialog msg(this,wxT("Do you really want to install the selected Themes ?"),wxT("Theme installation"),wxOK|wxCANCEL);
913 if(msg.ShowModal() != wxID_OK )
914 return;
916 bool success=true;
917 for(unsigned int i=0 ;i < gv->themesToInstall.GetCount();i++)
919 if(!InstallTheme(gv->themesToInstall[i]))
921 MESG_DIALOG(wxT("The Themes installation has failed") );
922 success=false;
923 break;
926 if(success)
928 MESG_DIALOG(wxT("The Theme installation completed successfully.") );
932 wxLogVerbose(wxT("=== end rbutilFrm::OnThemesBtn(event)"));
936 void rbutilFrm::OnRemoveBtn(wxCommandEvent& event)
938 wxLogVerbose(wxT("=== begin rbutilFrm::OnRemoveBtn(event)"));
940 int index = GetDeviceId();
941 if(index < 0)
942 return;
944 // Rockbox deinstall dialog
945 rockboxDeInstallDlg dialog(NULL, wxID_ANY,
946 wxT("Rockbox Deinstallation"));
947 if (dialog.ShowModal() != wxID_OK)
948 return;
950 // really install ?
951 wxMessageDialog msg(this,wxT("Do you really want to deinstall Rockbox ?"),wxT("Rockbox deinstallation"),wxOK|wxCANCEL);
952 if(msg.ShowModal() != wxID_OK )
953 return;
956 if (Uninstall(gv->curdestdir, gv->curisfull) )
958 MESG_DIALOG(
959 wxT("The uninstallation wizard was cancelled or completed with "
960 "some errors.") );
961 } else {
962 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The uninstall wizard completed successfully\n"
963 "Depending on which Device you own, you also have to uninstall the Bootloader")
964 ,wxT("Uninstallation"), wxOK |wxICON_INFORMATION);
965 msg->ShowModal();
966 delete msg;
969 wxLogVerbose(wxT("=== end rbutilFrm::OnRemoveBtn"));
972 void rbutilFrm::OnPortableInstall(wxCommandEvent& event)
974 wxString src, dest, buf;
975 wxLogVerbose(wxT("=== begin rbutilFrm::OnPortableInstall(event)"));
976 wxFileSystem fs;
977 wxDateSpan oneday;
979 int index = GetDeviceId();
980 if(index < 0)
981 return;
983 //portable install dialog ( reused font dialog)
984 fontInstallDlg dialog(NULL, wxID_ANY,
985 wxT("Rockbox Utility Portable Installation"));
986 if (dialog.ShowModal() != wxID_OK)
987 return;
989 // really install ?
990 wxMessageDialog msg(this,wxT("Do you really want a portable install of rbutil ?"),wxT("rbutil installation"),wxOK|wxCANCEL);
991 if(msg.ShowModal() != wxID_OK )
992 return;
994 if ( InstallRbutil(gv->curdestdir) )
996 MESG_DIALOG(wxT("The Rockbox Utility has been installed on your device."));
998 } else
1000 ERR_DIALOG(wxT("Installation failed"), wxT("Portable Install"));
1003 wxLogVerbose(wxT("=== end rbutilFrm::OnUnstallPortable"));
1006 int rbutilFrm::GetDeviceId()
1008 int index = gv->plat_id.Index(gv->curplat);
1009 if(index < 0)
1011 if( wxMessageBox(wxT("No device selected. Do you want to autodetect "
1012 "the device?"),
1013 wxT("Warning"), wxYES_NO ) == wxYES )
1015 myDeviceSelector->AutoDetect();
1016 index = gv->plat_id.Index(gv->curplat);
1017 if(index < 0)
1019 WARN_DIALOG( wxT("Aborting"), wxT("Auto detection failed") );
1020 return index;
1022 else
1024 if( wxMessageBox(wxT("Found ") + gv->plat_name[index] +
1025 wxT(". Do you want to continue?"),
1026 wxT("Device found"), wxYES_NO ) == wxYES )
1027 return index;
1028 else
1029 return -1;
1032 else
1034 return -1;
1037 return index;
1040 AboutDlg::AboutDlg(rbutilFrm* parent)
1041 : wxDialog(parent, -1, wxT("About"), wxDefaultPosition, wxDefaultSize,
1042 wxDEFAULT_DIALOG_STYLE)
1044 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
1045 this->SetSizer(WxBoxSizer1);
1046 this->SetAutoLayout(TRUE);
1048 wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
1050 wxBitmap WxBitmap1 = wxBitmap(rbutilFrm_XPM);
1051 wxStaticBitmap* WxStaticBitmap1 = new wxStaticBitmap(this, wxID_ANY,
1052 WxBitmap1);
1053 WxBoxSizer2->Add(WxStaticBitmap1, 0, wxALL | wxCENTER, 5);
1055 wxStaticText* WxStaticText1 = new wxStaticText(this, wxID_ANY,
1056 wxT(RBUTIL_FULLNAME), wxDefaultPosition, wxDefaultSize,
1057 wxALIGN_CENTER | wxST_NO_AUTORESIZE );
1058 WxBoxSizer2->Add(WxStaticText1, 0, wxALL | wxCENTER, 5);
1059 WxBoxSizer1->Add(WxBoxSizer2, 0, wxALL, 5);
1061 wxStaticText* WxStaticText2 = new wxStaticText(this, wxID_ANY,
1062 wxT(RBUTIL_VERSION "\n" RBUTIL_DESCRIPTION "\n\n" RBUTIL_COPYRIGHT));
1063 WxStaticText2->Wrap(400);
1064 WxBoxSizer1->Add(WxStaticText2, 0, wxALL, 5);
1066 wxHyperlinkCtrl* WxHyperlink1 = new wxHyperlinkCtrl(this, wxID_ANY,
1067 wxT(RBUTIL_WEBSITE), wxT(RBUTIL_WEBSITE) );
1068 WxBoxSizer1->Add(WxHyperlink1, 0, wxALL, 5);
1070 wxStaticBox* WxStaticBox1 = new wxStaticBox(this, wxID_ANY, wxT("Contributors:"));
1071 wxStaticBoxSizer* WxStaticBoxSizer2 = new wxStaticBoxSizer(WxStaticBox1,
1072 wxVERTICAL);
1073 wxTextCtrl* WxTextCtrl1 = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
1074 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY);
1076 long i = 0;
1077 while ( rbutil_developers[i] != wxT(""))
1079 WxTextCtrl1->AppendText(rbutil_developers[i++]);
1080 WxTextCtrl1->AppendText(wxT("\n"));
1083 WxBoxSizer1->Add(WxStaticBoxSizer2, 1, wxGROW | wxALL, 5);
1084 WxStaticBoxSizer2->Add(WxTextCtrl1, 1, wxGROW | wxALL, 0);
1086 wxStdDialogButtonSizer* WxStdDialogButtonSizer1 = new wxStdDialogButtonSizer();
1087 wxButton* WxOKButton = new wxButton(this, wxID_OK);
1088 WxStdDialogButtonSizer1->AddButton(WxOKButton);
1089 WxStdDialogButtonSizer1->Realize();
1091 WxBoxSizer1->Add(WxStdDialogButtonSizer1, 0, wxALL | wxCENTER, 5);
1093 GetSizer()->Fit(this);
1094 GetSizer()->SetSizeHints(this);
1096 //this->Center();
1097 this->Show();
1101 AboutDlg::~AboutDlg()