Limit minimum db scale value when switching from linear to logaritmic peakmeter scale...
[Rockbox.git] / rbutil / rbutilFrm.cpp
blob8654dd070685be5d9dc9d615c0025c6cd3b95d9b
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"
33 #include "rblogo.xpm"
35 #include "bootloaders.h"
36 #include "install_dialogs.h"
40 //----------------------------------------------------------------------------
41 // rbutilFrm
42 //----------------------------------------------------------------------------
44 BEGIN_EVENT_TABLE(rbutilFrm,wxFrame)
45 EVT_BUTTON (ID_INSTALL_BTN, rbutilFrm::OnInstallBtn)
46 EVT_BUTTON (ID_REMOVE_BTN, rbutilFrm::OnRemoveBtn)
47 EVT_BUTTON (ID_FONT_BTN, rbutilFrm::OnFontBtn)
48 EVT_BUTTON (ID_THEMES_BTN, rbutilFrm::OnThemesBtn)
49 EVT_BUTTON (ID_BOOTLOADER_BTN, rbutilFrm::OnBootloaderBtn)
50 EVT_BUTTON (ID_BOOTLOADERREMOVE_BTN, rbutilFrm::OnBootloaderRemoveBtn)
51 EVT_BUTTON (ID_DOOM_BTN, rbutilFrm::OnDoomBtn)
54 EVT_CLOSE(rbutilFrm::rbutilFrmClose)
55 EVT_MENU(ID_FILE_EXIT, rbutilFrm::OnFileExit)
56 EVT_MENU(ID_FILE_ABOUT, rbutilFrm::OnFileAbout)
57 EVT_MENU(ID_FILE_WIPECACHE, rbutilFrm::OnFileWipeCache)
58 EVT_MENU(ID_PORTABLE_INSTALL, rbutilFrm::OnPortableInstall)
60 EVT_MENU(ID_FILE_PROXY, rbutilFrm::OnFileProxy)
62 EVT_UPDATE_UI (ID_MANUAL, rbutilFrm::OnManualUpdate)
64 END_EVENT_TABLE()
66 rbutilFrm::rbutilFrm( wxWindow *parent, wxWindowID id, const wxString &title,
67 const wxPoint &position, const wxSize& size, long style )
68 : wxFrame( parent, id, title, position, size, style)
70 wxLogVerbose(wxT("=== begin rbutilFrm::rbutilFrm(...)"));
71 CreateGUIControls();
72 wxLogVerbose(wxT("=== end rbutilFrm::rbutilFrm"));
75 rbutilFrm::~rbutilFrm() {}
77 void rbutilFrm::CreateGUIControls(void)
79 wxLogVerbose(wxT("=== begin rbutilFrm::CreateGUIControls()"));
81 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
82 this->SetSizer(WxBoxSizer1);
83 this->SetAutoLayout(TRUE);
85 wxPanel* mainPanel = new wxPanel(this,wxID_ANY);
86 WxBoxSizer1->Add(mainPanel,1,wxGROW|wxALL,0);
87 wxBoxSizer* WxBoxSizer0 = new wxBoxSizer(wxVERTICAL);
88 mainPanel->SetSizer(WxBoxSizer0);
89 mainPanel->SetAutoLayout(TRUE);
91 wxBitmap rockboxbmp(rblogo_xpm);
92 ImageCtrl* rockboxbmpCtrl = new ImageCtrl(mainPanel,wxID_ANY);
93 rockboxbmpCtrl->SetBitmap(rockboxbmp);
95 WxBoxSizer0->Add(rockboxbmpCtrl,0,wxALIGN_CENTER_HORIZONTAL | wxALL,5);
97 myDeviceSelector = new DeviceSelectorCtrl(mainPanel,wxID_ANY);
98 myDeviceSelector->setDefault();
99 WxBoxSizer0->Add(myDeviceSelector,0,wxGROW|wxALL,5);
101 wxNotebook* tabwindow = new wxNotebook(mainPanel,wxID_ANY);
102 WxBoxSizer0->Add(tabwindow,1,wxGROW|wxALL,5);
104 wxPanel* installpage = new wxPanel(tabwindow,wxID_ANY);
105 wxPanel* themepage = new wxPanel(tabwindow,wxID_ANY);
106 wxPanel* uninstallpage = new wxPanel(tabwindow,wxID_ANY);
107 wxPanel* manualpage = new wxPanel(tabwindow,wxID_ANY);
108 tabwindow->AddPage(installpage,wxT("Installation"),true);
109 tabwindow->AddPage(themepage,wxT("Extras"));
110 tabwindow->AddPage(uninstallpage,wxT("Uninstallation"));
111 tabwindow->AddPage(manualpage,wxT("Manual"));
113 /*********************
114 Install Page
115 ***********************/
117 wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxVERTICAL);
118 installpage->SetSizer(WxBoxSizer2);
119 installpage->SetAutoLayout(TRUE);
121 wxStaticBox* WxStaticBoxSizer3_StaticBoxObj = new wxStaticBox(installpage,
122 wxID_ANY, wxT("Please choose an option"));
123 wxStaticBoxSizer* WxStaticBoxSizer3 =
124 new wxStaticBoxSizer(WxStaticBoxSizer3_StaticBoxObj,wxHORIZONTAL);
125 WxBoxSizer2->Add(WxStaticBoxSizer3,1,wxALIGN_CENTER_HORIZONTAL|wxGROW | wxALL, 5);
127 wxFlexGridSizer* WxFlexGridSizer1 = new wxFlexGridSizer(2,2,0,0);
128 WxStaticBoxSizer3->Add(WxFlexGridSizer1,0,wxGROW | wxALL,0);
131 wxBitmap BootloaderInstallButton (wxGetBitmapFromMemory(bootloader_btn_png,bootloader_btn_png_length));
132 WxBitmapButton4 = new wxBitmapButton(installpage, ID_BOOTLOADER_BTN,
133 BootloaderInstallButton, wxPoint(0,0), wxSize(64,54),
134 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,wxT("Bootloader Installation"));
135 WxBitmapButton4->SetToolTip(wxT("Click here to install the Rockbox bootloader"));
136 WxFlexGridSizer1->Add(WxBitmapButton4, 0,
137 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
139 wxStaticText* WxStaticText5 = new wxStaticText(installpage, wxID_ANY,
140 wxT("Bootloader installation instructions\n\n"
141 "Before Rockbox can be installed on your audio player, you "
142 "may have to\ninstall a bootloader.\nThis is only necessary the first time "
143 "Rockbox is installed."));
144 WxFlexGridSizer1->Add(WxStaticText5, 0,
145 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
147 wxBitmap WxBitmapButton1_BITMAP (wxGetBitmapFromMemory(rbinstall_btn_png,rbinstall_btn_png_length));
148 WxBitmapButton1 = new wxBitmapButton(installpage, ID_INSTALL_BTN,
149 WxBitmapButton1_BITMAP, wxPoint(0,0), wxSize(64,54),
150 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
151 wxT("Rockbox Installation"));
152 WxBitmapButton1->SetToolTip(wxT("Click here to install Rockbox"));
153 WxFlexGridSizer1->Add(WxBitmapButton1,0,
154 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
156 WxStaticText2 = new wxStaticText(installpage, ID_WXSTATICTEXT2,
157 wxT("Install Rockbox on your audio player"));
158 WxFlexGridSizer1->Add(WxStaticText2,0,
159 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
161 /*********************+
162 Extras Page
163 ***********************/
165 wxBoxSizer* WxBoxSizer3 = new wxBoxSizer(wxVERTICAL);
166 themepage->SetSizer(WxBoxSizer3);
167 themepage->SetAutoLayout(TRUE);
169 wxStaticBox* WxStaticBoxSizer4_StaticBoxObj = new wxStaticBox(themepage,
170 wxID_ANY, wxT("Please choose an option"));
171 wxStaticBoxSizer* WxStaticBoxSizer4 =
172 new wxStaticBoxSizer(WxStaticBoxSizer4_StaticBoxObj,wxHORIZONTAL);
173 WxBoxSizer3->Add(WxStaticBoxSizer4,1,wxALIGN_CENTER_HORIZONTAL |wxGROW| wxALL, 5);
175 wxFlexGridSizer* WxFlexGridSizer2 = new wxFlexGridSizer(2,2,0,0);
176 WxStaticBoxSizer4->Add(WxFlexGridSizer2,0,wxGROW | wxALL,0);
178 wxBitmap FontInstallButton (wxGetBitmapFromMemory(font_btn_png,font_btn_png_length));
179 WxBitmapButton3 = new wxBitmapButton(themepage, ID_FONT_BTN,
180 FontInstallButton, wxPoint(0,0), wxSize(64,54),
181 wxRAISED_BORDER | wxBU_AUTODRAW,wxDefaultValidator, wxT("Font installation"));
182 WxBitmapButton3->SetToolTip(wxT("Click here to install the most up to date "
183 "Rockbox fonts."));
184 WxFlexGridSizer2->Add(WxBitmapButton3, 0,
185 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
187 wxStaticText* WxStaticText4 = new wxStaticText(themepage, wxID_ANY,
188 wxT("Install the Rockbox fonts package\n\n"
189 "This step is needed for many Themes. You "
190 "will not need to download these\nagain unless you uninstall "
191 "Rockbox."));
192 WxFlexGridSizer2->Add(WxStaticText4, 0,
193 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
195 wxBitmap ThemesInstallButton (wxGetBitmapFromMemory(themes_btn_png,themes_btn_png_length));
196 WxBitmapButton5 = new wxBitmapButton(themepage, ID_THEMES_BTN,
197 ThemesInstallButton, wxPoint(0,0), wxSize(64,54),
198 wxRAISED_BORDER | wxBU_AUTODRAW,wxDefaultValidator, wxT("Theme installation"));
199 WxBitmapButton5->SetToolTip(wxT("Click here to install themes for Rockbox."));
200 WxFlexGridSizer2->Add(WxBitmapButton5, 0,
201 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
203 wxStaticText* WxStaticText6 = new wxStaticText(themepage, wxID_ANY,
204 wxT("Install more Themes for Rockbox.\n\n"));
205 WxFlexGridSizer2->Add(WxStaticText6, 0,
206 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
209 wxBitmap DoomInstallButton (wxGetBitmapFromMemory(doom_btn_png,doom_btn_png_length));
210 WxBitmapButton6 = new wxBitmapButton(themepage, ID_DOOM_BTN,
211 DoomInstallButton, wxPoint(0,0), wxSize(64,54),
212 wxRAISED_BORDER | wxBU_AUTODRAW,wxDefaultValidator, wxT("Freedoom installation"));
213 WxBitmapButton6->SetToolTip(wxT("Click here to install the freedoom wad files."));
214 WxFlexGridSizer2->Add(WxBitmapButton6, 0,
215 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
217 wxStaticText* WxStaticText7 = new wxStaticText(themepage, wxID_ANY,
218 wxT("Install the freedoom wad files.\n\n"));
219 WxFlexGridSizer2->Add(WxStaticText7, 0,
220 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
222 /*********************+
223 Uninstall Page
224 ***********************/
226 wxBoxSizer* WxBoxSizer4 = new wxBoxSizer(wxVERTICAL);
227 uninstallpage->SetSizer(WxBoxSizer4);
228 uninstallpage->SetAutoLayout(TRUE);
230 wxStaticBox* WxStaticBoxSizer5_StaticBoxObj = new wxStaticBox(uninstallpage,
231 wxID_ANY, wxT("Please choose an option"));
232 wxStaticBoxSizer* WxStaticBoxSizer5 =
233 new wxStaticBoxSizer(WxStaticBoxSizer5_StaticBoxObj,wxHORIZONTAL);
234 WxBoxSizer4->Add(WxStaticBoxSizer5,1,wxALIGN_CENTER_HORIZONTAL|wxGROW | wxALL, 5);
236 wxFlexGridSizer* WxFlexGridSizer3 = new wxFlexGridSizer(2,2,0,0);
237 WxStaticBoxSizer5->Add(WxFlexGridSizer3,0,wxGROW | wxALL,0);
239 wxBitmap WxBitmapButton2_BITMAP (wxGetBitmapFromMemory(remrb_btn_png,remrb_btn_png_length));
240 WxBitmapButton2 = new wxBitmapButton(uninstallpage, ID_REMOVE_BTN,
241 WxBitmapButton2_BITMAP, wxPoint(0,0), wxSize(64,54),
242 wxRAISED_BORDER | wxBU_AUTODRAW,wxDefaultValidator, wxT("Rockbox uninstallation"));
243 WxBitmapButton2->SetToolTip(wxT("Click here to uninstall Rockbox"));
244 WxFlexGridSizer3->Add(WxBitmapButton2,0,
245 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
247 WxStaticText3 = new wxStaticText(uninstallpage, ID_WXSTATICTEXT3,
248 wxT("Remove Rockbox from your audio player"));
249 WxFlexGridSizer3->Add(WxStaticText3,0,
250 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
252 wxBitmap WxBitmapButton4_BITMAP (wxGetBitmapFromMemory(rembootloader_btn_png,rembootloader_btn_png_length));
253 WxBitmapButton4 = new wxBitmapButton(uninstallpage, ID_BOOTLOADERREMOVE_BTN,
254 WxBitmapButton4_BITMAP, wxPoint(0,0), wxSize(64,54),
255 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
256 wxT("Bootloader uninstallation"));
257 WxBitmapButton4->SetToolTip(wxT("Click here to uninstall the Bootloader"));
258 WxFlexGridSizer3->Add(WxBitmapButton4,0,
259 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
261 WxStaticText4 = new wxStaticText(uninstallpage, ID_WXSTATICTEXT4,
262 wxT("Remove Rockbox Bootloader from your audio player"));
263 WxFlexGridSizer3->Add(WxStaticText4,0,
264 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
267 /*****************
268 * Manual Page
269 ******************/
271 wxBoxSizer* WxBoxSizer5 = new wxBoxSizer(wxVERTICAL);
272 manualpage->SetSizer(WxBoxSizer5);
273 manualpage->SetAutoLayout(TRUE);
275 manuallink = new wxHyperlinkCtrl(manualpage,wxID_ANY,wxT("Rockbox PDF Manual"),wxT("http://www.rockbox.org"));
276 WxBoxSizer5->Add(manuallink,1,wxGROW | wxALL, 5);
278 manual =new wxHtmlWindow(manualpage,ID_MANUAL);
279 WxBoxSizer5->Add(manual,10,wxGROW | wxALL, 5);
282 /**********
283 ** rest of the controls
284 **********/
286 WxMenuBar1 = new wxMenuBar();
287 wxMenu *ID_FILE_MENU_Mnu_Obj = new wxMenu(0);
288 WxMenuBar1->Append(ID_FILE_MENU_Mnu_Obj, wxT("&File"));
290 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_WIPECACHE,
291 wxT("&Empty local download cache"), wxT(""), wxITEM_NORMAL);
292 if (! gv->portable )
294 ID_FILE_MENU_Mnu_Obj->Append(ID_PORTABLE_INSTALL,
295 wxT("&Install Rockbox Utility on device"), wxT(""), wxITEM_NORMAL);
297 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_PROXY, wxT("Set &Proxy"), wxT(""),
298 wxITEM_NORMAL);
299 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_ABOUT, wxT("&About"), wxT(""),
300 wxITEM_NORMAL);
301 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_EXIT, wxT("E&xit\tCtrl+X"), wxT(""),
302 wxITEM_NORMAL);
304 this->SetMenuBar(WxMenuBar1);
305 Layout();
306 GetSizer()->Fit(this);
307 GetSizer()->SetSizeHints(this);
308 if (gv->portable)
310 this->SetTitle(wxT("Rockbox Utility (portable)"));
311 } else
313 this->SetTitle(wxT("Rockbox Utility"));
315 this->Center();
316 wxIcon rbutilFrm_ICON (rbutilFrm_XPM);
317 this->SetIcon(rbutilFrm_XPM);
318 this->SetToolTip(wxT("Install Rockbox"));
320 wxLogVerbose(wxT("=== end rbutilFrm::CreateGUIControls"));
323 void rbutilFrm::OnManualUpdate(wxUpdateUIEvent& event)
325 wxString tmp = gv->curplat;
327 if(tmp == wxT("h120")) tmp = wxT("h100"); //h120 has the h100 manual
328 if(tmp == wxT("fmrecorder8mb")) tmp = wxT("fmrecorder");
329 if(tmp == wxT("ipodmini1g")) tmp = wxT("ipodmini2g");
330 if(tmp == wxT("recorder8mb")) tmp = wxT("recorder");
332 if( tmp == curManualDevice)
333 return;
335 curManualDevice = tmp;
337 // construct link to pdf
338 wxString pdflink;
339 pdflink = gv->manual_url + curManualDevice + wxT(".pdf");
340 manuallink->SetURL(pdflink);
342 // construct link to html
343 wxString htmllink;
344 htmllink = gv->manual_url + curManualDevice + wxT("/rockbox-build.html");
345 if(!manual->LoadPage(htmllink))
346 manual->SetPage(wxT("<p>unable to display manual -- please use the PDF link above</p>"));
352 void rbutilFrm::OnFileProxy(wxCommandEvent& event)
355 wxTextEntryDialog proxydlg(this,wxT("Please enter your Proxy in the Format: URL:PORT"),wxT("Proxy Configuration"), gv->proxy_url);
357 if(proxydlg.ShowModal() == wxID_OK)
359 gv->proxy_url = proxydlg.GetValue();
365 void rbutilFrm::rbutilFrmClose(wxCloseEvent& event)
367 wxLogVerbose(wxT("=== begin rbutilFrm::rbutilFrmClose(event)"));
368 Destroy();
369 wxLogVerbose(wxT("=== end rbutilFrm::rbutilFrmClose"));
375 * OnFileExit
377 void rbutilFrm::OnFileExit(wxCommandEvent& event)
379 wxLogVerbose(wxT("=== begin rbutilFrm::OnFileExit(event)"));
380 Close();
381 wxLogVerbose(wxT("=== end rbutilFrm::OnFileExit"));
384 // The routines this code uses are in the wxWidgets documentation, but
385 // not yet the library (2.7.0-1). This code can be re-enabled later.
387 void rbutilFrm::OnFileAbout(wxCommandEvent& event)
390 wxAboutDialogInfo *info = new wxAboutDialogInfo();
392 info->SetName(wxT(RBUTIL_FULLNAME));
393 info->SetVersion(wxT(RBUTIL_VERSION));
394 info->SetCopyright(wxT(RBUTIL_COPYRIGHT));
395 info->SetDescription(wxT(RBUTIL_DESCRIPTION));
396 info->SetWebSite(wxT(RBUTIL_WEBSITE));
398 long i = 0;
399 while (rbutil_developers[i] != "")
401 info->AddDeveloper(wxT(rbutil_developers[i++]));
404 wxAboutBox(*info);
405 delete info;
408 AboutDlg(this).ShowModal();
411 void rbutilFrm::OnFileWipeCache(wxCommandEvent& event)
413 wxString cacheloc, datadir;
415 datadir = gv->stdpaths->GetUserDataDir();
416 if (datadir == wxT(""))
418 ERR_DIALOG(wxT("Can't locate user data directory. Unable to delete "
419 "cache."), wxT("Delete download cache.") );
420 return;
423 cacheloc = datadir + wxT("" PATH_SEP "download");
425 if (! rm_rf(cacheloc) )
427 wxMessageDialog* msg = new wxMessageDialog(this, wxT("Local download cache has been deleted.")
428 , wxT("Cache deletion"), wxOK |wxICON_INFORMATION);
429 msg->ShowModal();
430 delete msg;
432 else {
433 MESG_DIALOG(wxT("Errors occured deleting the local download cache."));
436 wxMkdir(cacheloc, 0777);
439 void rbutilFrm::OnBootloaderRemoveBtn(wxCommandEvent& event)
441 wxLogVerbose(wxT("=== begin rbutilFrm::OnBootloaderRemoveBtn(event)"));
443 int index = GetDeviceId();
444 if(index < 0)
445 return;
447 wxString bootloadermethod = gv->plat_bootloadermethod[index];
449 if(!gv->plat_needsbootloader[index])
451 WARN_DIALOG(wxT("This Device doesnt need a Bootloader"),
452 wxT("Bootloader"));
453 return;
456 // really deinstall ?
457 wxMessageDialog msg(this,wxT("Do you really want to deinstall the Bootloader ?"),wxT("Bootloader deinstallation"),wxOK|wxCANCEL);
458 if(msg.ShowModal() != wxID_OK )
459 return;
462 if(bootloadermethod == wxT("ipodpatcher"))
464 wxString bootloadername = wxT("bootloader-");
465 bootloadername.Append(gv->plat_bootloadername[index] );
466 if(ipodpatcher(BOOTLOADER_REM,bootloadername))
468 MESG_DIALOG(wxT("The Bootloader has been uninstalled.") );
470 else
472 MESG_DIALOG(wxT("The Uninstallation failed.") );
475 if(bootloadermethod == wxT("sansapatcher"))
477 if(sansapatcher(BOOTLOADER_REM,gv->plat_bootloadername[index]))
479 MESG_DIALOG(wxT("The Bootloader has been uninstalled.") );
481 else
483 MESG_DIALOG(wxT("The Uninstallation failed.") );
486 else if(bootloadermethod== wxT("gigabeatf"))
489 if(gigabeatf(BOOTLOADER_REM,gv->plat_bootloadername[index],gv->curdestdir))
491 MESG_DIALOG(wxT("The Bootloader has been uninstalled."));
493 else
494 MESG_DIALOG(wxT("The Uninstallation failed.") );
496 else if(bootloadermethod == wxT("iaudio") )
498 MESG_DIALOG(wxT("To uninstall the Bootloader on this Device,\n"
499 "you need to download and install an Original Firmware from the Manufacturer."));
501 else if(bootloadermethod == wxT("fwpatcher"))
503 MESG_DIALOG(wxT("To uninstall the Bootloader on this Device,\n"
504 "you need to download and install an original Firmware from the Manufacturer.\n"
505 "To do this, you need to boot into the original Firmware."));
507 else if(bootloadermethod == wxT("h10"))
509 if(h10(BOOTLOADER_REM,gv->plat_bootloadername[index],gv->curdestdir))
511 MESG_DIALOG(wxT("The Bootloader has been uninstalled."));
513 else
514 MESG_DIALOG(wxT("The Uninstallation failed.") );
516 else
518 MESG_DIALOG(wxT("Unsupported Bootloader Uninstall method.") );
521 wxLogVerbose(wxT("=== end rbutilFrm::OnBootloaderRemoveBtn"));
524 void rbutilFrm::OnBootloaderBtn(wxCommandEvent& event)
526 wxLogVerbose(wxT("=== begin rbutilFrm::OnBootloaderBtn(event)"));
528 int index = GetDeviceId();
529 if(index < 0)
530 return;
532 wxString bootloadermethod = gv->plat_bootloadermethod[index];
534 if(!gv->plat_needsbootloader[index])
536 WARN_DIALOG(wxT("This Device doesnt need a Bootloader"),
537 wxT("Bootloader"));
538 return;
541 // Bootloader dialog
542 if(bootloadermethod != wxT("ipodpatcher") && bootloadermethod != wxT("sansapatcher") )
544 bootloaderInstallDlg dialog(NULL, wxID_ANY,wxT("Bootloader Installation"));
545 if (dialog.ShowModal() != wxID_OK)
546 return;
549 // really install ?
550 wxMessageDialog msg(this,wxT("Do you really want to install the Bootloader ?"),wxT("Bootloader installation"),wxOK|wxCANCEL);
551 if(msg.ShowModal() != wxID_OK )
552 return;
555 if(bootloadermethod == wxT("ipodpatcher"))
557 wxString bootloadername = wxT("bootloader-");
558 bootloadername.Append(gv->plat_bootloadername[index] );
559 if(ipodpatcher(BOOTLOADER_ADD,bootloadername))
561 MESG_DIALOG(wxT("The Bootloader has been installed on your device.") );
563 else
565 MESG_DIALOG(wxT("The installation has failed.") );
568 if(bootloadermethod == wxT("sansapatcher"))
570 if(sansapatcher(BOOTLOADER_ADD,gv->plat_bootloadername[index]))
572 MESG_DIALOG(wxT("The Bootloader has been installed on your device.") );
574 else
576 MESG_DIALOG(wxT("The installation has failed.") );
580 else if(bootloadermethod== wxT("gigabeatf"))
583 if(gigabeatf(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir))
585 MESG_DIALOG(wxT("The Bootloader has been installed on your device."));
587 else
588 MESG_DIALOG(wxT("The installation has failed.") );
590 else if(bootloadermethod == wxT("iaudio") )
592 if(iaudiox5(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir))
594 MESG_DIALOG(wxT("The Bootloader has been installed on your device.\n"
595 "Now turn OFF your Device, unplug USB,and insert Charger\n"
596 "Your Device will automatically upgrade the flash with the Rockbox bootloader"));
598 else
599 MESG_DIALOG(wxT("The installation has failed.") );
601 else if(bootloadermethod == wxT("fwpatcher"))
603 if(fwpatcher(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir,gv->curfirmware))
605 MESG_DIALOG(wxT("The Bootloader has been patched and copied on your device.\n"
606 "Now use the Firmware upgrade option of your Device\n"));
608 else
609 MESG_DIALOG(wxT("The installation has failed.") );
611 else if(bootloadermethod == wxT("h10"))
613 if(h10(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir))
615 MESG_DIALOG(wxT("The Bootloader has been patched and copied on your device.\n"));
617 else
618 MESG_DIALOG(wxT("The installation has failed.") );
620 else
622 MESG_DIALOG(wxT("Unsupported Bootloader Install method.") );
627 wxLogVerbose(wxT("=== end rbutilFrm::OnBootloaderBtn"));
631 void rbutilFrm::OnInstallBtn(wxCommandEvent& event)
633 wxString src, dest, buf;
634 wxDateTime date;
635 wxTimeSpan day(24);
636 wxLogVerbose(wxT("=== begin rbutilFrm::OnInstallBtn(event)"));
637 wxFileSystem fs;
638 wxFileConfig* buildinfo;
639 wxDateSpan oneday;
641 int index = GetDeviceId();
642 if(index < 0)
643 return;
645 // rockbox install dialog
646 rockboxInstallDlg dialog(NULL, wxID_ANY,
647 wxT("Rockbox Installation"));
648 if (dialog.ShowModal() != wxID_OK)
649 return;
651 // really install
652 wxMessageDialog msg(this,wxT("Do you really want to install Rockbox ?"),wxT("rockbox installation"),wxOK|wxCANCEL);
653 if(msg.ShowModal() != wxID_OK )
654 return;
657 switch (gv->curbuild)
659 case BUILD_RELEASE:
660 // This is a URL - don't use PATH_SEP
661 src = gv->download_url + gv->prog_name + wxT("-")
662 + gv->last_release + wxT("-") + gv->curplat + wxT(".zip");
663 dest = gv->stdpaths->GetUserDataDir() + wxT("download" PATH_SEP)
664 + gv->prog_name + wxT("-") + gv->last_release + wxT("-")
665 + gv->curplat + wxT(".zip");
666 break;
667 case BUILD_DAILY:
668 dest = gv->stdpaths->GetUserDataDir()
669 + PATH_SEP + wxT("download") + PATH_SEP + wxT("build-info");
670 if (DownloadURL(gv->server_conf_url, dest)) {
671 WARN_DIALOG(wxT("Unable to download build status."),
672 wxT("Install"));
673 buf = wxT("");
674 } else
676 buildinfo = new wxFileConfig(wxEmptyString,
677 wxEmptyString, dest);
678 buf = buildinfo->Read(wxT("/dailies/date"));
679 buildinfo->DeleteAll();
681 if (buf.Len() != 8) {
682 dest = wxT("Invalid build date: ") + buf;
683 WARN_DIALOG(dest, wxT("Install"));
684 buf = wxT("");
688 if (buf == wxT("")) {
689 WARN_DIALOG(wxT("Can't get date of latest build from "
690 "server. Using yesterday's date."), wxT("Install") );
691 date = wxDateTime::Now();
692 date.Subtract(oneday.Day());
693 buf = date.Format(wxT("%Y%m%d")); // yes, we want UTC
696 src = gv->daily_url + gv->curplat + wxT("/") + gv->prog_name
697 + wxT("-") + gv->curplat + wxT("-") + buf + wxT(".zip");
699 dest = gv->stdpaths->GetUserDataDir() + PATH_SEP wxT("download")
700 + gv->prog_name + wxT("-") + gv->curplat + wxT("-")
701 + buf + wxT(".zip");
702 break;
703 case BUILD_BLEEDING:
704 src = gv->bleeding_url + gv->curplat + wxT("/")
705 + gv->prog_name + wxT(".zip");
706 dest = gv->stdpaths->GetUserDataDir()
707 + PATH_SEP wxT("download") PATH_SEP
708 + gv->prog_name + wxT(".zip");
709 break;
710 default:
711 ERR_DIALOG(wxT("Something seriously odd has happened."),
712 wxT("Install"));
713 return;
714 break;
717 if (gv->nocache || ( ! wxFileExists(dest) ) )
719 if ( DownloadURL(src, dest) )
721 wxRemoveFile(dest);
722 ERR_DIALOG(wxT("Unable to download ")+src, wxT("Install"));
723 return;
727 if ( !UnzipFile(dest, gv->curdestdir, true) )
729 wxMessageDialog* msg = new wxMessageDialog(this, wxT("Rockbox has been installed on your device.")
730 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
731 msg->ShowModal();
732 delete msg;
733 } else
735 wxRemoveFile(dest);
736 ERR_DIALOG(wxT("Unable to unzip ")+dest, wxT("Install"));
740 wxLogVerbose(wxT("=== end rbutilFrm::OnInstallBtn"));
743 void rbutilFrm::OnFontBtn(wxCommandEvent& event)
745 wxString src, dest, buf;
746 wxDateTime date;
747 wxTimeSpan day(24);
748 wxLogVerbose(wxT("=== begin rbutilFrm::OnFontBtn(event)"));
749 wxFileSystem fs;
750 wxFileConfig* buildinfo;
751 wxDateSpan oneday;
753 int index = GetDeviceId();
754 if(index < 0)
755 return;
757 // font install dialog
758 fontInstallDlg dialog(NULL, wxID_ANY,
759 wxT("Font Installation"));
760 if (dialog.ShowModal() != wxID_OK)
761 return;
763 // really install ?
764 wxMessageDialog msg(this,wxT("Do you really want to install the Fonts ?"),wxT("Font installation"),wxOK|wxCANCEL);
765 if(msg.ShowModal() != wxID_OK )
766 return;
769 buf = gv->curdestdir + wxT("" PATH_SEP ".rockbox");
770 if (! wxDirExists(buf) )
772 WARN_DIALOG(wxT("Rockbox is not yet installed on ") + buf
773 + wxT(" - install Rockbox first."),
774 wxT("Can't install fonts") );
775 return;
778 dest = gv->stdpaths->GetUserDataDir()
779 + wxT( "" PATH_SEP "download" PATH_SEP "build-info");
780 if (DownloadURL(gv->server_conf_url, dest))
782 WARN_DIALOG(wxT("Unable to download build status."),
783 wxT("Font Install"));
784 buf = wxT("");
785 } else
787 buildinfo = new wxFileConfig(wxEmptyString,
788 wxEmptyString, dest);
789 buf = buildinfo->Read(wxT("/dailies/date"));
790 buildinfo->DeleteAll();
792 if (buf.Len() != 8) {
793 WARN_DIALOG(wxT("Invalid build date: ") + buf, wxT("Font Install"));
794 buf = wxT("");
798 if (buf == wxT("")) {
799 WARN_DIALOG(wxT("Can't get date of latest build from "
800 "server. Using yesterday's date."),
801 wxT("Font Install") );
802 date = wxDateTime::Now();
803 date.Subtract(oneday.Day());
804 buf = date.Format(wxT("%Y%m%d")); // yes, we want UTC
807 src = gv->font_url + buf + wxT(".zip");
809 dest = gv->stdpaths->GetUserDataDir() + wxT( "" PATH_SEP "download"
810 PATH_SEP "rockbox-fonts-") + buf + wxT(".zip");
812 if ( ! wxFileExists(dest) )
814 if ( DownloadURL(src, dest) )
816 wxRemoveFile(dest);
817 ERR_DIALOG(wxT("Unable to download ") + src, wxT("Font Install"));
818 return;
822 if ( !UnzipFile(dest, gv->curdestdir, true) )
824 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Rockbox fonts have been installed on your device.")
825 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
826 msg->ShowModal();
827 delete msg;
828 } else
830 wxRemoveFile(dest);
831 ERR_DIALOG(wxT("Unable to unzip ") + dest, wxT("Font Install"));
834 wxLogVerbose(wxT("=== end rbutilFrm::OnFontBtn"));
837 void rbutilFrm::OnDoomBtn(wxCommandEvent& event)
839 wxString src, dest, buf;
840 wxLogVerbose(wxT("=== begin rbutilFrm::OnDoomBtn(event)"));
842 int index = GetDeviceId();
843 if(index < 0)
844 return;
846 // font install dialog, reused
847 fontInstallDlg dialog(NULL, wxID_ANY,
848 wxT("Freedoom wad file Installation"));
849 if (dialog.ShowModal() != wxID_OK)
850 return;
852 // really install ?
853 wxMessageDialog msg(this,wxT("Do you really want to install the Freedoom wads ?"),wxT("Freedoom installation"),wxOK|wxCANCEL);
854 if(msg.ShowModal() != wxID_OK )
855 return;
857 buf = gv->curdestdir + wxT("" PATH_SEP ".rockbox");
858 if (! wxDirExists(buf) )
860 WARN_DIALOG(wxT("Rockbox is not yet installed on ") + buf
861 + wxT(" - install Rockbox first."),
862 wxT("Can't install freedoom wads") );
863 return;
866 src = gv->doom_url;
868 dest = gv->stdpaths->GetUserDataDir() + wxT("" PATH_SEP "download" PATH_SEP
869 "rockdoom.zip");
871 if ( ! wxFileExists(dest) )
873 if ( DownloadURL(src, dest) )
875 wxRemoveFile(dest);
876 ERR_DIALOG(wxT("Unable to download ") + src,
877 wxT("Freedoom Install"));
878 return;
882 if ( !UnzipFile(dest, gv->curdestdir, true) )
884 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Freedoom wads have been installed on your device.")
885 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
886 msg->ShowModal();
887 delete msg;
888 } else
890 wxRemoveFile(dest);
891 ERR_DIALOG(wxT("Unable to unzip ") + dest, wxT("Freedoom Install"));
895 wxLogVerbose(wxT("=== end rbutilFrm::OnDoomBtn"));
899 void rbutilFrm::OnThemesBtn(wxCommandEvent& event)
901 wxString src, dest, buf;
902 wxLogVerbose(wxT("=== begin rbutilFrm::OnThemesBtn(event)"));
904 int index = GetDeviceId();
905 if(index < 0)
906 return;
908 // Theme install dialog
909 themesInstallDlg dialog(NULL, wxID_ANY,
910 wxT("Theme Installation"));
911 if (dialog.ShowModal() != wxID_OK)
912 return;
914 // really install ?
915 wxMessageDialog msg(this,wxT("Do you really want to install the selected Themes ?"),wxT("Theme installation"),wxOK|wxCANCEL);
916 if(msg.ShowModal() != wxID_OK )
917 return;
919 bool success=true;
920 for(unsigned int i=0 ;i < gv->themesToInstall.GetCount();i++)
922 if(!InstallTheme(gv->themesToInstall[i]))
924 MESG_DIALOG(wxT("The Themes installation has failed") );
925 success=false;
926 break;
929 if(success)
931 MESG_DIALOG(wxT("The Theme installation completed successfully.") );
935 wxLogVerbose(wxT("=== end rbutilFrm::OnThemesBtn(event)"));
939 void rbutilFrm::OnRemoveBtn(wxCommandEvent& event)
941 wxLogVerbose(wxT("=== begin rbutilFrm::OnRemoveBtn(event)"));
943 int index = GetDeviceId();
944 if(index < 0)
945 return;
947 // Rockbox deinstall dialog
948 rockboxDeInstallDlg dialog(NULL, wxID_ANY,
949 wxT("Rockbox Deinstallation"));
950 if (dialog.ShowModal() != wxID_OK)
951 return;
953 // really install ?
954 wxMessageDialog msg(this,wxT("Do you really want to deinstall Rockbox ?"),wxT("Rockbox deinstallation"),wxOK|wxCANCEL);
955 if(msg.ShowModal() != wxID_OK )
956 return;
959 if (Uninstall(gv->curdestdir, gv->curisfull) )
961 MESG_DIALOG(
962 wxT("The uninstallation wizard was cancelled or completed with "
963 "some errors.") );
964 } else {
965 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The uninstall wizard completed successfully\n"
966 "Depending on which Device you own, you also have to uninstall the Bootloader")
967 ,wxT("Uninstallation"), wxOK |wxICON_INFORMATION);
968 msg->ShowModal();
969 delete msg;
972 wxLogVerbose(wxT("=== end rbutilFrm::OnRemoveBtn"));
975 void rbutilFrm::OnPortableInstall(wxCommandEvent& event)
977 wxString src, dest, buf;
978 wxLogVerbose(wxT("=== begin rbutilFrm::OnPortableInstall(event)"));
979 wxFileSystem fs;
980 wxDateSpan oneday;
982 int index = GetDeviceId();
983 if(index < 0)
984 return;
986 //portable install dialog ( reused font dialog)
987 fontInstallDlg dialog(NULL, wxID_ANY,
988 wxT("Rockbox Utility Portable Installation"));
989 if (dialog.ShowModal() != wxID_OK)
990 return;
992 // really install ?
993 wxMessageDialog msg(this,wxT("Do you really want a portable install of rbutil ?"),wxT("rbutil installation"),wxOK|wxCANCEL);
994 if(msg.ShowModal() != wxID_OK )
995 return;
997 if ( InstallRbutil(gv->curdestdir) )
999 MESG_DIALOG(wxT("The Rockbox Utility has been installed on your device."));
1001 } else
1003 ERR_DIALOG(wxT("Installation failed"), wxT("Portable Install"));
1006 wxLogVerbose(wxT("=== end rbutilFrm::OnUnstallPortable"));
1009 int rbutilFrm::GetDeviceId()
1011 int index = gv->plat_id.Index(gv->curplat);
1012 if(index < 0)
1014 if( wxMessageBox(wxT("No device selected. Do you want to autodetect "
1015 "the device?"),
1016 wxT("Warning"), wxYES_NO ) == wxYES )
1018 myDeviceSelector->AutoDetect();
1019 index = gv->plat_id.Index(gv->curplat);
1020 if(index < 0)
1022 WARN_DIALOG( wxT("Aborting"), wxT("Auto detection failed") );
1023 return index;
1025 else
1027 if( wxMessageBox(wxT("Found ") + gv->plat_name[index] +
1028 wxT(". Do you want to continue?"),
1029 wxT("Device found"), wxYES_NO ) == wxYES )
1030 return index;
1031 else
1032 return -1;
1035 else
1037 return -1;
1040 return index;
1043 AboutDlg::AboutDlg(rbutilFrm* parent)
1044 : wxDialog(parent, -1, wxT("About"), wxDefaultPosition, wxDefaultSize,
1045 wxDEFAULT_DIALOG_STYLE)
1047 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
1048 this->SetSizer(WxBoxSizer1);
1049 this->SetAutoLayout(TRUE);
1051 wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
1053 wxBitmap WxBitmap1 = wxBitmap(rbutilFrm_XPM);
1054 wxStaticBitmap* WxStaticBitmap1 = new wxStaticBitmap(this, wxID_ANY,
1055 WxBitmap1);
1056 WxBoxSizer2->Add(WxStaticBitmap1, 0, wxALL | wxCENTER, 5);
1058 wxStaticText* WxStaticText1 = new wxStaticText(this, wxID_ANY,
1059 wxT(RBUTIL_FULLNAME), wxDefaultPosition, wxDefaultSize,
1060 wxALIGN_CENTER | wxST_NO_AUTORESIZE );
1061 WxBoxSizer2->Add(WxStaticText1, 0, wxALL | wxCENTER, 5);
1062 WxBoxSizer1->Add(WxBoxSizer2, 0, wxALL, 5);
1064 wxStaticText* WxStaticText2 = new wxStaticText(this, wxID_ANY,
1065 wxT(RBUTIL_VERSION "\n" RBUTIL_DESCRIPTION "\n\n" RBUTIL_COPYRIGHT));
1066 WxStaticText2->Wrap(400);
1067 WxBoxSizer1->Add(WxStaticText2, 0, wxALL, 5);
1069 wxHyperlinkCtrl* WxHyperlink1 = new wxHyperlinkCtrl(this, wxID_ANY,
1070 wxT(RBUTIL_WEBSITE), wxT(RBUTIL_WEBSITE) );
1071 WxBoxSizer1->Add(WxHyperlink1, 0, wxALL, 5);
1073 wxStaticBox* WxStaticBox1 = new wxStaticBox(this, wxID_ANY, wxT("Contributors:"));
1074 wxStaticBoxSizer* WxStaticBoxSizer2 = new wxStaticBoxSizer(WxStaticBox1,
1075 wxVERTICAL);
1076 wxTextCtrl* WxTextCtrl1 = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
1077 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY);
1079 long i = 0;
1080 while ( rbutil_developers[i] != wxT(""))
1082 WxTextCtrl1->AppendText(rbutil_developers[i++]);
1083 WxTextCtrl1->AppendText(wxT("\n"));
1086 WxBoxSizer1->Add(WxStaticBoxSizer2, 1, wxGROW | wxALL, 5);
1087 WxStaticBoxSizer2->Add(WxTextCtrl1, 1, wxGROW | wxALL, 0);
1089 wxStdDialogButtonSizer* WxStdDialogButtonSizer1 = new wxStdDialogButtonSizer();
1090 wxButton* WxOKButton = new wxButton(this, wxID_OK);
1091 WxStdDialogButtonSizer1->AddButton(WxOKButton);
1092 WxStdDialogButtonSizer1->Realize();
1094 WxBoxSizer1->Add(WxStdDialogButtonSizer1, 0, wxALL | wxCENTER, 5);
1096 GetSizer()->Fit(this);
1097 GetSizer()->SetSizeHints(this);
1099 //this->Center();
1100 this->Show();
1104 AboutDlg::~AboutDlg()