VBRfix description: No need to tell OndioSP owners about files they recorded with...
[kugel-rb.git] / rbutil / rbutilFrm.cpp
blob913e22df143e4e3153ec9d61e438dc756c273e81
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"
33 #include "bootloaders.h"
34 #include "install_dialogs.h"
37 //----------------------------------------------------------------------------
38 // rbutilFrm
39 //----------------------------------------------------------------------------
41 BEGIN_EVENT_TABLE(rbutilFrm,wxFrame)
42 EVT_BUTTON (ID_INSTALL_BTN, rbutilFrm::OnInstallBtn)
43 EVT_BUTTON (ID_REMOVE_BTN, rbutilFrm::OnRemoveBtn)
44 EVT_BUTTON (ID_FONT_BTN, rbutilFrm::OnFontBtn)
45 EVT_BUTTON (ID_THEMES_BTN, rbutilFrm::OnThemesBtn)
46 EVT_BUTTON (ID_BOOTLOADER_BTN, rbutilFrm::OnBootloaderBtn)
47 EVT_BUTTON (ID_BOOTLOADERREMOVE_BTN, rbutilFrm::OnBootloaderRemoveBtn)
49 EVT_CLOSE(rbutilFrm::rbutilFrmClose)
50 EVT_MENU(ID_FILE_EXIT, rbutilFrm::OnFileExit)
51 EVT_MENU(ID_FILE_ABOUT, rbutilFrm::OnFileAbout)
52 EVT_MENU(ID_FILE_WIPECACHE, rbutilFrm::OnFileWipeCache)
53 EVT_MENU(ID_PORTABLE_INSTALL, rbutilFrm::OnPortableInstall)
54 EVT_MENU(ID_FILE_PROXY, rbutilFrm::OnFileProxy)
56 EVT_UPDATE_UI (ID_MANUAL, rbutilFrm::OnManualUpdate)
58 END_EVENT_TABLE()
60 rbutilFrm::rbutilFrm( wxWindow *parent, wxWindowID id, const wxString &title,
61 const wxPoint &position, const wxSize& size, long style )
62 : wxFrame( parent, id, title, position, size, style)
64 wxLogVerbose(wxT("=== begin rbutilFrm::rbutilFrm(...)"));
65 CreateGUIControls();
66 wxLogVerbose(wxT("=== end rbutilFrm::rbutilFrm"));
69 rbutilFrm::~rbutilFrm() {}
71 void rbutilFrm::CreateGUIControls(void)
73 wxLogVerbose(wxT("=== begin rbutilFrm::CreateGUIControls()"));
75 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
76 this->SetSizer(WxBoxSizer1);
77 this->SetAutoLayout(TRUE);
79 wxPanel* mainPanel = new wxPanel(this,wxID_ANY);
80 WxBoxSizer1->Add(mainPanel,0,wxALL,0);
81 wxBoxSizer* WxBoxSizer0 = new wxBoxSizer(wxVERTICAL);
82 mainPanel->SetSizer(WxBoxSizer0);
83 mainPanel->SetAutoLayout(TRUE);
85 wxBitmap rockboxbmp(rblogo_xpm);
86 ImageCtrl* rockboxbmpCtrl = new ImageCtrl(mainPanel,wxID_ANY);
87 rockboxbmpCtrl->SetBitmap(rockboxbmp);
88 WxBoxSizer0->Add(rockboxbmpCtrl,0,wxALIGN_CENTER_HORIZONTAL | wxALL,5);
90 myDeviceSelector = new DeviceSelectorCtrl(mainPanel,wxID_ANY);
91 myDeviceSelector->setDefault();
92 WxBoxSizer0->Add(myDeviceSelector,0,wxALL,5);
94 wxNotebook* tabwindow = new wxNotebook(mainPanel,wxID_ANY);
95 WxBoxSizer0->Add(tabwindow,0,wxALL,5);
97 wxPanel* installpage = new wxPanel(tabwindow,wxID_ANY);
98 wxPanel* themepage = new wxPanel(tabwindow,wxID_ANY);
99 wxPanel* uninstallpage = new wxPanel(tabwindow,wxID_ANY);
100 wxPanel* manualpage = new wxPanel(tabwindow,wxID_ANY);
101 tabwindow->AddPage(installpage,wxT("Installation"),true);
102 tabwindow->AddPage(themepage,wxT("Themes"));
103 tabwindow->AddPage(uninstallpage,wxT("Uninstallation"));
104 tabwindow->AddPage(manualpage,wxT("Manual"));
106 /*********************
107 Install Page
108 ***********************/
110 wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxVERTICAL);
111 installpage->SetSizer(WxBoxSizer2);
112 installpage->SetAutoLayout(TRUE);
114 wxStaticBox* WxStaticBoxSizer3_StaticBoxObj = new wxStaticBox(installpage,
115 wxID_ANY, wxT("Please choose an option"));
116 wxStaticBoxSizer* WxStaticBoxSizer3 =
117 new wxStaticBoxSizer(WxStaticBoxSizer3_StaticBoxObj,wxHORIZONTAL);
118 WxBoxSizer2->Add(WxStaticBoxSizer3,1,wxALIGN_CENTER_HORIZONTAL|wxGROW | wxALL, 5);
120 wxFlexGridSizer* WxFlexGridSizer1 = new wxFlexGridSizer(2,2,0,0);
121 WxStaticBoxSizer3->Add(WxFlexGridSizer1,0,wxGROW | wxALL,0);
123 wxBitmap BootloaderInstallButton (tools2_3d_xpm);
124 WxBitmapButton4 = new wxBitmapButton(installpage, ID_BOOTLOADER_BTN,
125 BootloaderInstallButton, wxPoint(0,0), wxSize(64,54),
126 wxRAISED_BORDER | wxBU_AUTODRAW);
127 WxBitmapButton4->SetToolTip(wxT("Instructions for installing the "
128 "Rockbox bootloader on your audio device"));
129 WxFlexGridSizer1->Add(WxBitmapButton4, 0,
130 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
132 wxStaticText* WxStaticText5 = new wxStaticText(installpage, wxID_ANY,
133 wxT("Bootloader installation instructions\n\n"
134 "Before Rockbox can be installed on your audio player, you "
135 "may have to\ninstall a bootloader. This can not currently "
136 "be done automatically, but is\nonly necessary the first time "
137 "Rockbox is installed."));
138 WxFlexGridSizer1->Add(WxStaticText5, 0,
139 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
141 wxBitmap WxBitmapButton1_BITMAP (install_3d_xpm);
142 WxBitmapButton1 = new wxBitmapButton(installpage, ID_INSTALL_BTN,
143 WxBitmapButton1_BITMAP, wxPoint(0,0), wxSize(64,54),
144 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
145 wxT("WxBitmapButton1"));
146 WxBitmapButton1->SetToolTip(wxT("Install Rockbox"));
147 WxFlexGridSizer1->Add(WxBitmapButton1,0,
148 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
150 WxStaticText2 = new wxStaticText(installpage, ID_WXSTATICTEXT2,
151 wxT("Install Rockbox on your audio player"));
152 WxFlexGridSizer1->Add(WxStaticText2,0,
153 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
155 /*********************+
156 Theme Page
157 ***********************/
159 wxBoxSizer* WxBoxSizer3 = new wxBoxSizer(wxVERTICAL);
160 themepage->SetSizer(WxBoxSizer3);
161 themepage->SetAutoLayout(TRUE);
163 wxStaticBox* WxStaticBoxSizer4_StaticBoxObj = new wxStaticBox(themepage,
164 wxID_ANY, wxT("Please choose an option"));
165 wxStaticBoxSizer* WxStaticBoxSizer4 =
166 new wxStaticBoxSizer(WxStaticBoxSizer4_StaticBoxObj,wxHORIZONTAL);
167 WxBoxSizer3->Add(WxStaticBoxSizer4,1,wxALIGN_CENTER_HORIZONTAL |wxGROW| wxALL, 5);
169 wxFlexGridSizer* WxFlexGridSizer2 = new wxFlexGridSizer(2,2,0,0);
170 WxStaticBoxSizer4->Add(WxFlexGridSizer2,0,wxGROW | wxALL,0);
172 wxBitmap FontInstallButton (fonts_3d_xpm);
173 WxBitmapButton3 = new wxBitmapButton(themepage, ID_FONT_BTN,
174 FontInstallButton, wxPoint(0,0), wxSize(64,54),
175 wxRAISED_BORDER | wxBU_AUTODRAW);
176 WxBitmapButton3->SetToolTip(wxT("Download the most up to date "
177 "Rockbox fonts."));
178 WxFlexGridSizer2->Add(WxBitmapButton3, 0,
179 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
181 wxStaticText* WxStaticText4 = new wxStaticText(themepage, wxID_ANY,
182 wxT("Install the Rockbox fonts package\n\n"
183 "This step is only needed if you have installed "
184 "a daily build and want\nthe full set of Rockbox fonts. You "
185 "will not need to download these\nagain unless you uninstall "
186 "Rockbox."));
187 WxFlexGridSizer2->Add(WxStaticText4, 0,
188 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
190 wxBitmap ThemesInstallButton (themes_3d_xpm);
191 WxBitmapButton5 = new wxBitmapButton(themepage, ID_THEMES_BTN,
192 ThemesInstallButton, wxPoint(0,0), wxSize(64,54),
193 wxRAISED_BORDER | wxBU_AUTODRAW);
194 WxBitmapButton5->SetToolTip(wxT("Download other Themes for Rockbox."));
195 WxFlexGridSizer2->Add(WxBitmapButton5, 0,
196 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
198 wxStaticText* WxStaticText6 = new wxStaticText(themepage, wxID_ANY,
199 wxT("Install more Themes for Rockbox.\n\n"));
200 WxFlexGridSizer2->Add(WxStaticText6, 0,
201 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
203 /*********************+
204 Uninstall Page
205 ***********************/
207 wxBoxSizer* WxBoxSizer4 = new wxBoxSizer(wxVERTICAL);
208 uninstallpage->SetSizer(WxBoxSizer4);
209 uninstallpage->SetAutoLayout(TRUE);
211 wxStaticBox* WxStaticBoxSizer5_StaticBoxObj = new wxStaticBox(uninstallpage,
212 wxID_ANY, wxT("Please choose an option"));
213 wxStaticBoxSizer* WxStaticBoxSizer5 =
214 new wxStaticBoxSizer(WxStaticBoxSizer5_StaticBoxObj,wxHORIZONTAL);
215 WxBoxSizer4->Add(WxStaticBoxSizer5,1,wxALIGN_CENTER_HORIZONTAL|wxGROW | wxALL, 5);
217 wxFlexGridSizer* WxFlexGridSizer3 = new wxFlexGridSizer(2,2,0,0);
218 WxStaticBoxSizer5->Add(WxFlexGridSizer3,0,wxGROW | wxALL,0);
220 wxBitmap WxBitmapButton2_BITMAP (uninstall_3d_xpm);
221 WxBitmapButton2 = new wxBitmapButton(uninstallpage, ID_REMOVE_BTN,
222 WxBitmapButton2_BITMAP, wxPoint(0,0), wxSize(64,54),
223 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
224 wxT("WxBitmapButton2"));
225 WxBitmapButton2->SetToolTip(wxT("Uninstall Rockbox"));
226 WxFlexGridSizer3->Add(WxBitmapButton2,0,
227 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
229 WxStaticText3 = new wxStaticText(uninstallpage, ID_WXSTATICTEXT3,
230 wxT("Remove Rockbox from your audio player"));
231 WxFlexGridSizer3->Add(WxStaticText3,0,
232 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
234 wxBitmap WxBitmapButton4_BITMAP (untools2_3d_xpm);
235 WxBitmapButton4 = new wxBitmapButton(uninstallpage, ID_BOOTLOADERREMOVE_BTN,
236 WxBitmapButton4_BITMAP, wxPoint(0,0), wxSize(64,54),
237 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
238 wxT("WxBitmapButton4"));
239 WxBitmapButton4->SetToolTip(wxT("Uninstall Bootloader"));
240 WxFlexGridSizer3->Add(WxBitmapButton4,0,
241 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
243 WxStaticText4 = new wxStaticText(uninstallpage, ID_WXSTATICTEXT4,
244 wxT("Remove Rockbox Bootloader from your audio player"));
245 WxFlexGridSizer3->Add(WxStaticText4,0,
246 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
249 /*****************
250 * Manual Page
251 ******************/
253 wxBoxSizer* WxBoxSizer5 = new wxBoxSizer(wxVERTICAL);
254 manualpage->SetSizer(WxBoxSizer5);
255 manualpage->SetAutoLayout(TRUE);
257 manuallink = new wxHyperlinkCtrl(manualpage,wxID_ANY,wxT("Rockbox PDF Manual"),wxT("http://www.rockbox.org"));
258 WxBoxSizer5->Add(manuallink,1,wxGROW | wxALL, 5);
260 manual =new wxHtmlWindow(manualpage,ID_MANUAL);
261 WxBoxSizer5->Add(manual,10,wxGROW | wxALL, 5);
264 /**********
265 ** rest of the controls
266 **********/
268 WxMenuBar1 = new wxMenuBar();
269 wxMenu *ID_FILE_MENU_Mnu_Obj = new wxMenu(0);
270 WxMenuBar1->Append(ID_FILE_MENU_Mnu_Obj, wxT("&File"));
272 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_WIPECACHE,
273 wxT("&Empty local download cache"), wxT(""), wxITEM_NORMAL);
274 if (! gv->portable )
276 ID_FILE_MENU_Mnu_Obj->Append(ID_PORTABLE_INSTALL,
277 wxT("&Install Rockbox Utility on device"), wxT(""), wxITEM_NORMAL);
279 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_PROXY, wxT("Set &Proxy"), wxT(""),
280 wxITEM_NORMAL);
281 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_ABOUT, wxT("&About"), wxT(""),
282 wxITEM_NORMAL);
283 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_EXIT, wxT("E&xit\tCtrl+X"), wxT(""),
284 wxITEM_NORMAL);
286 this->SetMenuBar(WxMenuBar1);
287 Layout();
288 GetSizer()->Fit(this);
289 GetSizer()->SetSizeHints(this);
290 if (gv->portable)
292 this->SetTitle(wxT("Rockbox Utility (portable)"));
293 } else
295 this->SetTitle(wxT("Rockbox Utility"));
297 this->Center();
298 wxIcon rbutilFrm_ICON (rbutilFrm_XPM);
299 this->SetIcon(rbutilFrm_XPM);
300 this->SetToolTip(wxT("Install Rockbox"));
302 wxLogVerbose(wxT("=== end rbutilFrm::CreateGUIControls"));
306 void rbutilFrm::OnManualUpdate(wxUpdateUIEvent& event)
308 wxString tmp = gv->curplat;
310 if(tmp == wxT("h120")) tmp = wxT("h100"); //h120 has the h100 manual
312 if( tmp == curManualDevice)
313 return;
315 curManualDevice = tmp;
317 // construct link to pdf
318 wxString pdflink;
319 pdflink.Printf(wxT("%s%s.pdf"),gv->manual_url.c_str(),curManualDevice.c_str());
320 manuallink->SetURL(pdflink);
322 // construct link to html
323 wxString htmllink;
324 htmllink.Printf(wxT("%s%s/rockbox-build.html"),gv->manual_url.c_str(),curManualDevice.c_str());
325 if(!manual->LoadPage(htmllink))
326 manual->SetPage(wxT("<p>unable to display manual -- please use the PDF link above</p>"));
332 void rbutilFrm::OnFileProxy(wxCommandEvent& event)
335 wxTextEntryDialog proxydlg(this,wxT("Please enter your Proxy in the Format: URL:PORT"),wxT("Proxy Configuration"));
337 if(proxydlg.ShowModal() == wxID_OK)
339 gv->proxy_url = proxydlg.GetValue();
345 void rbutilFrm::rbutilFrmClose(wxCloseEvent& event)
347 wxLogVerbose(wxT("=== begin rbutilFrm::rbutilFrmClose(event)"));
348 Destroy();
349 wxLogVerbose(wxT("=== end rbutilFrm::rbutilFrmClose"));
355 * OnFileExit
357 void rbutilFrm::OnFileExit(wxCommandEvent& event)
359 wxLogVerbose(wxT("=== begin rbutilFrm::OnFileExit(event)"));
360 Close();
361 wxLogVerbose(wxT("=== end rbutilFrm::OnFileExit"));
364 // The routines this code uses are in the wxWidgets documentation, but
365 // not yet the library (2.7.0-1). This code can be re-enabled later.
367 void rbutilFrm::OnFileAbout(wxCommandEvent& event)
370 wxAboutDialogInfo *info = new wxAboutDialogInfo();
372 info->SetName(wxT(RBUTIL_FULLNAME));
373 info->SetVersion(wxT(RBUTIL_VERSION));
374 info->SetCopyright(wxT(RBUTIL_COPYRIGHT));
375 info->SetDescription(wxT(RBUTIL_DESCRIPTION));
376 info->SetWebSite(wxT(RBUTIL_WEBSITE));
378 long i = 0;
379 while (rbutil_developers[i] != "")
381 info->AddDeveloper(wxT(rbutil_developers[i++]));
384 wxAboutBox(*info);
385 delete info;
388 AboutDlg(this).ShowModal();
391 void rbutilFrm::OnFileWipeCache(wxCommandEvent& event)
393 wxString cacheloc, datadir;
395 datadir = gv->stdpaths->GetUserDataDir();
396 if (datadir == wxT(""))
398 ERR_DIALOG(wxT("Can't locate user data directory. Unable to delete "
399 "cache."), wxT("Delete download cache.") );
400 return;
403 cacheloc.Printf(wxT("%s" PATH_SEP "download"),
404 datadir.c_str());
406 if (! rm_rf(cacheloc) )
408 wxMessageDialog* msg = new wxMessageDialog(this, wxT("Local download cache has been deleted.")
409 , wxT("Cache deletion"), wxOK |wxICON_INFORMATION);
410 msg->ShowModal();
411 delete msg;
413 else {
414 MESG_DIALOG(wxT("Errors occured deleting the local download cache."));
417 wxMkdir(cacheloc, 0777);
420 void rbutilFrm::OnBootloaderRemoveBtn(wxCommandEvent& event)
422 wxLogVerbose(wxT("=== begin rbutilFrm::OnBootloaderRemoveBtn(event)"));
424 int index = gv->plat_id.Index(gv->curplat);
425 wxString bootloadermethod = gv->plat_bootloadermethod[index];
427 if(!gv->plat_needsbootloader[index])
429 WARN_DIALOG(wxT("This Device doesnt need a Bootloader"),
430 wxT("Bootloader"));
431 return;
434 // really deinstall ?
435 wxMessageDialog msg(this,wxT("Do you really want to deinstall the Bootloader ?"),wxT("Bootloader deinstallation"),wxOK|wxCANCEL);
436 if(msg.ShowModal() != wxID_OK )
437 return;
440 if(bootloadermethod == wxT("ipodpatcher"))
442 wxString bootloadername = wxT("bootloader-");
443 bootloadername.Append(gv->plat_bootloadername[index] );
444 if(ipodpatcher(BOOTLOADER_REM,bootloadername))
446 MESG_DIALOG(wxT("The Bootloader has been uninstalled.") );
448 else
450 MESG_DIALOG(wxT("The Uninstallation failed.") );
453 if(bootloadermethod == wxT("sansapatcher"))
455 if(sansapatcher(BOOTLOADER_REM,gv->plat_bootloadername[index]))
457 MESG_DIALOG(wxT("The Bootloader has been uninstalled.") );
459 else
461 MESG_DIALOG(wxT("The Uninstallation failed.") );
464 else if(bootloadermethod== wxT("gigabeatf"))
467 if(gigabeatf(BOOTLOADER_REM,gv->plat_bootloadername[index],gv->curdestdir))
469 MESG_DIALOG(wxT("The Bootloader has been uninstalled."));
471 else
472 MESG_DIALOG(wxT("The Uninstallation failed.") );
474 else if(bootloadermethod == wxT("iaudio") )
476 MESG_DIALOG(wxT("To uninstall the Bootloader on this Device,\n"
477 "you need to download and install an Original Firmware from the Manufacturer."));
479 else if(bootloadermethod == wxT("fwpatcher"))
481 MESG_DIALOG(wxT("To uninstall the Bootloader on this Device,\n"
482 "you need to download and install an original Firmware from the Manufacturer.\n"
483 "To do this, you need to boot into the original Firmware."));
485 else if(bootloadermethod == wxT("h10"))
487 if(h10(BOOTLOADER_REM,gv->plat_bootloadername[index],gv->curdestdir))
489 MESG_DIALOG(wxT("The Bootloader has been uninstalled."));
491 else
492 MESG_DIALOG(wxT("The Uninstallation failed.") );
494 else
496 MESG_DIALOG(wxT("Unsupported Bootloader Uninstall method.") );
499 wxLogVerbose(wxT("=== end rbutilFrm::OnBootloaderRemoveBtn"));
502 void rbutilFrm::OnBootloaderBtn(wxCommandEvent& event)
504 wxLogVerbose(wxT("=== begin rbutilFrm::OnBootloaderBtn(event)"));
506 int index = gv->plat_id.Index(gv->curplat);
507 wxString bootloadermethod = gv->plat_bootloadermethod[index];
509 if(!gv->plat_needsbootloader[index])
511 WARN_DIALOG(wxT("This Device doesnt need a Bootloader"),
512 wxT("Bootloader"));
513 return;
516 // Bootloader dialog
517 if(bootloadermethod != wxT("ipodpatcher") && bootloadermethod != wxT("sansapatcher") )
519 bootloaderInstallDlg dialog(NULL, wxID_ANY,wxT("Bootloader Installation"));
520 if (dialog.ShowModal() != wxID_OK)
521 return;
524 // really install ?
525 wxMessageDialog msg(this,wxT("Do you really want to install the Bootloader ?"),wxT("Bootloader installation"),wxOK|wxCANCEL);
526 if(msg.ShowModal() != wxID_OK )
527 return;
530 if(bootloadermethod == wxT("ipodpatcher"))
532 wxString bootloadername = wxT("bootloader-");
533 bootloadername.Append(gv->plat_bootloadername[index] );
534 if(ipodpatcher(BOOTLOADER_ADD,bootloadername))
536 MESG_DIALOG(wxT("The Bootloader has been installed on your device.") );
538 else
540 MESG_DIALOG(wxT("The installation has failed.") );
543 if(bootloadermethod == wxT("sansapatcher"))
545 if(sansapatcher(BOOTLOADER_ADD,gv->plat_bootloadername[index]))
547 MESG_DIALOG(wxT("The Bootloader has been installed on your device.") );
549 else
551 MESG_DIALOG(wxT("The installation has failed.") );
555 else if(bootloadermethod== wxT("gigabeatf"))
558 if(gigabeatf(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir))
560 MESG_DIALOG(wxT("The Bootloader has been installed on your device."));
562 else
563 MESG_DIALOG(wxT("The installation has failed.") );
565 else if(bootloadermethod == wxT("iaudio") )
567 if(iaudiox5(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir))
569 MESG_DIALOG(wxT("The Bootloader has been installed on your device.\n"
570 "Now turn OFF your Device, unplug USB,and insert Charger\n"
571 "Your Device will automatically upgrade the flash with the Rockbox bootloader"));
573 else
574 MESG_DIALOG(wxT("The installation has failed.") );
576 else if(bootloadermethod == wxT("fwpatcher"))
578 if(fwpatcher(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir,gv->curfirmware))
580 MESG_DIALOG(wxT("The Bootloader has been patched and copied on your device.\n"
581 "Now use the Firmware upgrade option of your Device\n"));
583 else
584 MESG_DIALOG(wxT("The installation has failed.") );
586 else if(bootloadermethod == wxT("h10"))
588 if(h10(BOOTLOADER_ADD,gv->plat_bootloadername[index],gv->curdestdir))
590 MESG_DIALOG(wxT("The Bootloader has been patched and copied on your device.\n"));
592 else
593 MESG_DIALOG(wxT("The installation has failed.") );
595 else
597 MESG_DIALOG(wxT("Unsupported Bootloader Install method.") );
602 wxLogVerbose(wxT("=== end rbutilFrm::OnBootloaderBtn"));
606 void rbutilFrm::OnInstallBtn(wxCommandEvent& event)
608 wxString src, dest, buf;
609 wxDateTime date;
610 wxTimeSpan day(24);
611 wxLogVerbose(wxT("=== begin rbutilFrm::OnInstallBtn(event)"));
612 wxFileSystem fs;
613 wxFileConfig* buildinfo;
614 wxDateSpan oneday;
616 // rockbox install dialog
617 rockboxInstallDlg dialog(NULL, wxID_ANY,
618 wxT("Rockbox Installation"));
619 if (dialog.ShowModal() != wxID_OK)
620 return;
622 // really install
623 wxMessageDialog msg(this,wxT("Do you really want to install Rockbox ?"),wxT("rockbox installation"),wxOK|wxCANCEL);
624 if(msg.ShowModal() != wxID_OK )
625 return;
628 switch (gv->curbuild)
630 case BUILD_RELEASE:
631 // This is a URL - don't use PATH_SEP
632 src.Printf(wxT("%s%s-%s-%s.zip"),
633 gv->download_url.c_str(), gv->prog_name.c_str(),
634 gv->last_release.c_str(), gv->curplat.c_str());
635 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s-%s-%s.zip"),
636 gv->stdpaths->GetUserDataDir().c_str(),
637 gv->prog_name.c_str(), gv->last_release.c_str(),
638 gv->curplat.c_str());
639 break;
640 case BUILD_DAILY:
641 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "build-info"),
642 gv->stdpaths->GetUserDataDir().c_str());
643 if (DownloadURL(gv->server_conf_url, dest)) {
644 WARN_DIALOG(wxT("Unable to download build status."),
645 wxT("Install"));
646 buf = wxT("");
647 } else
649 buildinfo = new wxFileConfig(wxEmptyString,
650 wxEmptyString, dest);
651 buf = buildinfo->Read(wxT("/dailies/date"));
652 buildinfo->DeleteAll();
654 if (buf.Len() != 8) {
655 dest.Printf(wxT("Invalid build date: %s"), buf.c_str());
656 WARN_DIALOG(dest, wxT("Install"));
657 buf = wxT("");
661 if (buf == wxT("")) {
662 WARN_DIALOG(wxT("Can't get date of latest build from "
663 "server. Using yesterday's date."), wxT("Install") );
664 date = wxDateTime::Now();
665 date.Subtract(oneday.Day());
666 buf = date.Format(wxT("%Y%m%d")); // yes, we want UTC
669 src.Printf(wxT("%s%s/%s-%s-%s.zip"),
670 gv->daily_url.c_str(), gv->curplat.c_str(),
671 gv->prog_name.c_str(), gv->curplat.c_str(),
672 buf.c_str() );
674 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s-%s-%s.zip"),
675 gv->stdpaths->GetUserDataDir().c_str(),
676 gv->prog_name.c_str(),
677 gv->curplat.c_str(), buf.c_str() );
678 break;
679 case BUILD_BLEEDING:
680 src.Printf(wxT("%s%s/%s.zip"),
681 gv->bleeding_url.c_str(), gv->curplat.c_str(),
682 gv->prog_name.c_str() );
683 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s.zip"),
684 gv->stdpaths->GetUserDataDir().c_str(),
685 gv->prog_name.c_str() );
686 break;
687 default:
688 ERR_DIALOG(wxT("Something seriously odd has happened."),
689 wxT("Install"));
690 return;
691 break;
694 if (gv->nocache || ( ! wxFileExists(dest) ) )
696 if ( DownloadURL(src, dest) )
698 wxRemoveFile(dest);
699 buf.Printf(wxT("Unable to download %s"), src.c_str() );
700 ERR_DIALOG(buf, wxT("Install"));
701 return;
705 if ( !UnzipFile(dest, gv->curdestdir, true) )
707 wxMessageDialog* msg = new wxMessageDialog(this, wxT("Rockbox has been installed on your device.")
708 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
709 msg->ShowModal();
710 delete msg;
711 } else
713 wxRemoveFile(dest);
714 buf.Printf(wxT("Unable to unzip %s"), dest.c_str() );
715 ERR_DIALOG(buf, wxT("Install"));
719 wxLogVerbose(wxT("=== end rbutilFrm::OnInstallBtn"));
722 void rbutilFrm::OnFontBtn(wxCommandEvent& event)
724 wxString src, dest, buf;
725 wxDateTime date;
726 wxTimeSpan day(24);
727 wxLogVerbose(wxT("=== begin rbutilFrm::OnFontBtn(event)"));
728 wxFileSystem fs;
729 wxFileConfig* buildinfo;
730 wxDateSpan oneday;
732 // font install dialog
733 fontInstallDlg dialog(NULL, wxID_ANY,
734 wxT("Font Installation"));
735 if (dialog.ShowModal() != wxID_OK)
736 return;
738 // really install ?
739 wxMessageDialog msg(this,wxT("Do you really want to install the Fonts ?"),wxT("Font installation"),wxOK|wxCANCEL);
740 if(msg.ShowModal() != wxID_OK )
741 return;
744 buf.Printf(wxT("%s" PATH_SEP ".rockbox"), gv->curdestdir.c_str()) ;
745 if (! wxDirExists(buf) )
747 buf.Printf(wxT("Rockbox is not yet installed on %s - install "
748 "Rockbox first."), buf.c_str() );
749 WARN_DIALOG(buf, wxT("Can't install fonts") );
750 return;
753 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "build-info"),
754 gv->stdpaths->GetUserDataDir().c_str());
755 if (DownloadURL(gv->server_conf_url, dest))
757 WARN_DIALOG(wxT("Unable to download build status."),
758 wxT("Font Install"));
759 buf = wxT("");
760 } else
762 buildinfo = new wxFileConfig(wxEmptyString,
763 wxEmptyString, dest);
764 buf = buildinfo->Read(wxT("/dailies/date"));
765 buildinfo->DeleteAll();
767 if (buf.Len() != 8) {
768 dest.Printf(wxT("Invalid build date: %s"), buf.c_str());
769 WARN_DIALOG(dest, wxT("Font Install"));
770 buf = wxT("");
774 if (buf == wxT("")) {
775 WARN_DIALOG(wxT("Can't get date of latest build from "
776 "server. Using yesterday's date."),
777 wxT("Font Install") );
778 date = wxDateTime::Now();
779 date.Subtract(oneday.Day());
780 buf = date.Format(wxT("%Y%m%d")); // yes, we want UTC
783 src.Printf(wxT("%s%s.zip"), gv->font_url.c_str(), buf.c_str() );
785 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP
786 "rockbox-fonts-%s.zip"), gv->stdpaths->GetUserDataDir().c_str(),
787 buf.c_str() );
789 if ( ! wxFileExists(dest) )
791 if ( DownloadURL(src, dest) )
793 wxRemoveFile(dest);
794 buf.Printf(wxT("Unable to download %s"), src.c_str() );
795 ERR_DIALOG(buf, wxT("Font Install"));
796 return;
800 if ( !UnzipFile(dest, gv->curdestdir, true) )
802 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Rockbox fonts have been installed on your device.")
803 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
804 msg->ShowModal();
805 delete msg;
806 } else
808 wxRemoveFile(dest);
809 buf.Printf(wxT("Unable to unzip %s"), dest.c_str() );
810 ERR_DIALOG(buf, wxT("Font Install"));
813 wxLogVerbose(wxT("=== end rbutilFrm::OnFontBtn"));
817 void rbutilFrm::OnThemesBtn(wxCommandEvent& event)
819 wxString src, dest, buf;
820 wxLogVerbose(wxT("=== begin rbutilFrm::OnThemesBtn(event)"));
822 // Theme install dialog
823 themesInstallDlg dialog(NULL, wxID_ANY,
824 wxT("Theme Installation"));
825 if (dialog.ShowModal() != wxID_OK)
826 return;
828 // really install ?
829 wxMessageDialog msg(this,wxT("Do you really want to install the selected Themes ?"),wxT("Theme installation"),wxOK|wxCANCEL);
830 if(msg.ShowModal() != wxID_OK )
831 return;
833 bool success=true;
834 for(unsigned int i=0 ;i < gv->themesToInstall.GetCount();i++)
836 if(!InstallTheme(gv->themesToInstall[i]))
838 MESG_DIALOG(wxT("The Themes installation has failed") );
839 success=false;
840 break;
843 if(success)
845 MESG_DIALOG(wxT("The Theme installation completed successfully.") );
849 wxLogVerbose(wxT("=== end rbutilFrm::OnThemesBtn(event)"));
853 void rbutilFrm::OnRemoveBtn(wxCommandEvent& event)
855 wxLogVerbose(wxT("=== begin rbutilFrm::OnRemoveBtn(event)"));
857 // Rockbox deinstall dialog
858 rockboxDeInstallDlg dialog(NULL, wxID_ANY,
859 wxT("Rockbox Deinstallation"));
860 if (dialog.ShowModal() != wxID_OK)
861 return;
863 // really install ?
864 wxMessageDialog msg(this,wxT("Do you really want to deinstall Rockbox ?"),wxT("Rockbox deinstallation"),wxOK|wxCANCEL);
865 if(msg.ShowModal() != wxID_OK )
866 return;
869 if (Uninstall(gv->curdestdir, gv->curisfull) )
871 MESG_DIALOG(
872 wxT("The uninstallation wizard was cancelled or completed with "
873 "some errors.") );
874 } else {
875 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The uninstall wizard completed successfully\n"
876 "Depending on which Device you own, you also have to uninstall the Bootloader")
877 ,wxT("Uninstallation"), wxOK |wxICON_INFORMATION);
878 msg->ShowModal();
879 delete msg;
882 wxLogVerbose(wxT("=== end rbutilFrm::OnRemoveBtn"));
885 void rbutilFrm::OnPortableInstall(wxCommandEvent& event)
887 wxString src, dest, buf;
888 wxLogVerbose(wxT("=== begin rbutilFrm::OnPortableInstall(event)"));
889 wxFileSystem fs;
890 wxDateSpan oneday;
892 //portable install dialog ( reused font dialog)
893 fontInstallDlg dialog(NULL, wxID_ANY,
894 wxT("Rockbox Utility Portable Installation"));
895 if (dialog.ShowModal() != wxID_OK)
896 return;
898 // really install ?
899 wxMessageDialog msg(this,wxT("Do you really want a portable install of rbutil ?"),wxT("rbutil installation"),wxOK|wxCANCEL);
900 if(msg.ShowModal() != wxID_OK )
901 return;
903 if ( InstallRbutil(gv->curdestdir) )
905 MESG_DIALOG(wxT("The Rockbox Utility has been installed on your device."));
907 } else
909 ERR_DIALOG(wxT("Installation failed"), wxT("Portable Install"));
912 wxLogVerbose(wxT("=== end rbutilFrm::OnUnstallPortable"));
915 AboutDlg::AboutDlg(rbutilFrm* parent)
916 : wxDialog(parent, -1, wxT("About"), wxDefaultPosition, wxDefaultSize,
917 wxDEFAULT_DIALOG_STYLE)
919 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
920 this->SetSizer(WxBoxSizer1);
921 this->SetAutoLayout(TRUE);
923 wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
925 wxBitmap WxBitmap1 = wxBitmap(rbutilFrm_XPM);
926 wxStaticBitmap* WxStaticBitmap1 = new wxStaticBitmap(this, wxID_ANY,
927 WxBitmap1);
928 WxBoxSizer2->Add(WxStaticBitmap1, 0, wxALL | wxCENTER, 5);
930 wxStaticText* WxStaticText1 = new wxStaticText(this, wxID_ANY,
931 wxT(RBUTIL_FULLNAME), wxDefaultPosition, wxDefaultSize,
932 wxALIGN_CENTER | wxST_NO_AUTORESIZE );
933 WxBoxSizer2->Add(WxStaticText1, 0, wxALL | wxCENTER, 5);
934 WxBoxSizer1->Add(WxBoxSizer2, 0, wxALL, 5);
936 wxStaticText* WxStaticText2 = new wxStaticText(this, wxID_ANY,
937 wxT(RBUTIL_VERSION "\n" RBUTIL_DESCRIPTION "\n\n" RBUTIL_COPYRIGHT));
938 WxStaticText2->Wrap(400);
939 WxBoxSizer1->Add(WxStaticText2, 0, wxALL, 5);
941 wxHyperlinkCtrl* WxHyperlink1 = new wxHyperlinkCtrl(this, wxID_ANY,
942 wxT(RBUTIL_WEBSITE), wxT(RBUTIL_WEBSITE) );
943 WxBoxSizer1->Add(WxHyperlink1, 0, wxALL, 5);
945 wxStaticBox* WxStaticBox1 = new wxStaticBox(this, wxID_ANY, wxT("Contributors:"));
946 wxStaticBoxSizer* WxStaticBoxSizer2 = new wxStaticBoxSizer(WxStaticBox1,
947 wxVERTICAL);
948 wxTextCtrl* WxTextCtrl1 = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
949 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY);
951 long i = 0;
952 while ( rbutil_developers[i] != wxT(""))
954 WxTextCtrl1->AppendText(rbutil_developers[i++]);
955 WxTextCtrl1->AppendText(wxT("\n"));
958 WxBoxSizer1->Add(WxStaticBoxSizer2, 1, wxGROW | wxALL, 5);
959 WxStaticBoxSizer2->Add(WxTextCtrl1, 1, wxGROW | wxALL, 0);
961 wxStdDialogButtonSizer* WxStdDialogButtonSizer1 = new wxStdDialogButtonSizer();
962 wxButton* WxOKButton = new wxButton(this, wxID_OK);
963 WxStdDialogButtonSizer1->AddButton(WxOKButton);
964 WxStdDialogButtonSizer1->Realize();
966 WxBoxSizer1->Add(WxStdDialogButtonSizer1, 0, wxALL | wxCENTER, 5);
968 GetSizer()->Fit(this);
969 GetSizer()->SetSizeHints(this);
971 //this->Center();
972 this->Show();
976 AboutDlg::~AboutDlg()