Revert change 13001, since it causes the metadata to be re-read for partially buffere...
[kugel-rb.git] / rbutil / rbutilFrm.cpp
blobf41d2906337c4ef138f3d64138248ab39aa524cd
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"
35 #include "wizard.xpm"
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 END_EVENT_TABLE()
56 rbutilFrm::rbutilFrm( wxWindow *parent, wxWindowID id, const wxString &title,
57 const wxPoint &position, const wxSize& size, long style )
58 : wxFrame( parent, id, title, position, size, style)
60 wxLogVerbose(wxT("=== begin rbutilFrm::rbutilFrm(...)"));
61 CreateGUIControls();
62 wxLogVerbose(wxT("=== end rbutilFrm::rbutilFrm"));
65 rbutilFrm::~rbutilFrm() {}
67 void rbutilFrm::CreateGUIControls(void)
69 wxLogVerbose(wxT("=== begin rbutilFrm::CreateGUIControls()"));
71 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
72 this->SetSizer(WxBoxSizer1);
73 this->SetAutoLayout(TRUE);
75 WxPanel1 = new wxPanel(this, ID_WXPANEL1, wxPoint(0,0), wxSize(400,600));
76 WxBoxSizer1->Add(WxPanel1,1,wxGROW | wxALL,0);
78 wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxVERTICAL);
79 WxPanel1->SetSizer(WxBoxSizer2);
80 WxPanel1->SetAutoLayout(TRUE);
82 wxBitmap WxStaticBitmap1_BITMAP(rblogo_xpm);
83 WxStaticBitmap1 = new wxStaticBitmap(WxPanel1, ID_WXSTATICBITMAP1,
84 WxStaticBitmap1_BITMAP, wxPoint(0,0), wxSize(400,123));
85 WxStaticBitmap1->Enable(false);
86 WxBoxSizer2->Add(WxStaticBitmap1,0,wxALIGN_CENTER_HORIZONTAL | wxALL,5);
88 wxStaticBox* WxStaticBoxSizer3_StaticBoxObj = new wxStaticBox(WxPanel1,
89 wxID_ANY, wxT("Please choose an option"));
90 wxStaticBoxSizer* WxStaticBoxSizer3 =
91 new wxStaticBoxSizer(WxStaticBoxSizer3_StaticBoxObj,wxHORIZONTAL);
92 WxBoxSizer2->Add(WxStaticBoxSizer3,1,wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
94 wxFlexGridSizer* WxFlexGridSizer1 = new wxFlexGridSizer(2,2,0,0);
95 WxStaticBoxSizer3->Add(WxFlexGridSizer1,0,wxGROW | wxALL,0);
97 wxBitmap BootloaderInstallButton (tools2_3d_xpm);
98 WxBitmapButton4 = new wxBitmapButton(WxPanel1, ID_BOOTLOADER_BTN,
99 BootloaderInstallButton, wxPoint(0,0), wxSize(64,54),
100 wxRAISED_BORDER | wxBU_AUTODRAW);
101 WxBitmapButton4->SetToolTip(wxT("Instructions for installing the "
102 "Rockbox bootloader on your audio device"));
103 WxFlexGridSizer1->Add(WxBitmapButton4, 0,
104 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
106 wxStaticText* WxStaticText5 = new wxStaticText(WxPanel1, wxID_ANY,
107 wxT("Bootloader installation instructions\n\n"
108 "Before Rockbox can be installed on your audio player, you "
109 "may have to\ninstall a bootloader. This can not currently "
110 "be done automatically, but is\nonly necessary the first time "
111 "Rockbox is installed."));
112 WxFlexGridSizer1->Add(WxStaticText5, 0,
113 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
115 wxBitmap WxBitmapButton1_BITMAP (install_3d_xpm);
116 WxBitmapButton1 = new wxBitmapButton(WxPanel1, ID_INSTALL_BTN,
117 WxBitmapButton1_BITMAP, wxPoint(0,0), wxSize(64,54),
118 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
119 wxT("WxBitmapButton1"));
120 WxBitmapButton1->SetToolTip(wxT("Install Rockbox"));
121 WxFlexGridSizer1->Add(WxBitmapButton1,0,
122 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
124 WxStaticText2 = new wxStaticText(WxPanel1, ID_WXSTATICTEXT2,
125 wxT("Install Rockbox on your audio player"));
126 WxFlexGridSizer1->Add(WxStaticText2,0,
127 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
129 wxBitmap FontInstallButton (fonts_3d_xpm);
130 WxBitmapButton3 = new wxBitmapButton(WxPanel1, ID_FONT_BTN,
131 FontInstallButton, wxPoint(0,0), wxSize(64,54),
132 wxRAISED_BORDER | wxBU_AUTODRAW);
133 WxBitmapButton3->SetToolTip(wxT("Download the most up to date "
134 "Rockbox fonts."));
135 WxFlexGridSizer1->Add(WxBitmapButton3, 0,
136 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
138 wxStaticText* WxStaticText4 = new wxStaticText(WxPanel1, wxID_ANY,
139 wxT("Install the Rockbox fonts package\n\n"
140 "This step is only needed if you have installed "
141 "a daily build and want\nthe full set of Rockbox fonts. You "
142 "will not need to download these\nagain unless you uninstall "
143 "Rockbox."));
144 WxFlexGridSizer1->Add(WxStaticText4, 0,
145 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
148 wxBitmap ThemesInstallButton (themes_3d_xpm);
149 WxBitmapButton5 = new wxBitmapButton(WxPanel1, ID_THEMES_BTN,
150 ThemesInstallButton, wxPoint(0,0), wxSize(64,54),
151 wxRAISED_BORDER | wxBU_AUTODRAW);
152 WxBitmapButton5->SetToolTip(wxT("Download other Themes for Rockbox."));
153 WxFlexGridSizer1->Add(WxBitmapButton5, 0,
154 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
156 wxStaticText* WxStaticText6 = new wxStaticText(WxPanel1, wxID_ANY,
157 wxT("Install more Themes for Rockbox.\n\n"));
158 WxFlexGridSizer1->Add(WxStaticText6, 0,
159 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
161 wxBitmap WxBitmapButton2_BITMAP (uninstall_3d_xpm);
162 WxBitmapButton2 = new wxBitmapButton(WxPanel1, ID_REMOVE_BTN,
163 WxBitmapButton2_BITMAP, wxPoint(0,0), wxSize(64,54),
164 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
165 wxT("WxBitmapButton2"));
166 WxBitmapButton2->SetToolTip(wxT("Uninstall Rockbox"));
167 WxFlexGridSizer1->Add(WxBitmapButton2,0,
168 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
170 WxStaticText3 = new wxStaticText(WxPanel1, ID_WXSTATICTEXT3,
171 wxT("Remove Rockbox from your audio player"));
172 WxFlexGridSizer1->Add(WxStaticText3,0,
173 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
175 wxBitmap WxBitmapButton4_BITMAP (untools2_3d_xpm);
176 WxBitmapButton4 = new wxBitmapButton(WxPanel1, ID_BOOTLOADERREMOVE_BTN,
177 WxBitmapButton4_BITMAP, wxPoint(0,0), wxSize(64,54),
178 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
179 wxT("WxBitmapButton4"));
180 WxBitmapButton4->SetToolTip(wxT("Uninstall Bootloader"));
181 WxFlexGridSizer1->Add(WxBitmapButton4,0,
182 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
184 WxStaticText4 = new wxStaticText(WxPanel1, ID_WXSTATICTEXT4,
185 wxT("Remove Rockbox Bootloader from your audio player"));
186 WxFlexGridSizer1->Add(WxStaticText4,0,
187 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
189 WxMenuBar1 = new wxMenuBar();
190 wxMenu *ID_FILE_MENU_Mnu_Obj = new wxMenu(0);
191 WxMenuBar1->Append(ID_FILE_MENU_Mnu_Obj, wxT("&File"));
193 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_WIPECACHE,
194 wxT("&Empty local download cache"), wxT(""), wxITEM_NORMAL);
195 if (! gv->portable )
197 ID_FILE_MENU_Mnu_Obj->Append(ID_PORTABLE_INSTALL,
198 wxT("&Install Rockbox Utility on device"), wxT(""), wxITEM_NORMAL);
200 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_ABOUT, wxT("&About"), wxT(""),
201 wxITEM_NORMAL);
202 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_EXIT, wxT("E&xit\tCtrl+X"), wxT(""),
203 wxITEM_NORMAL);
205 this->SetMenuBar(WxMenuBar1);
207 GetSizer()->Fit(this);
208 GetSizer()->SetSizeHints(this);
209 if (gv->portable)
211 this->SetTitle(wxT("Rockbox Utility (portable)"));
212 } else
214 this->SetTitle(wxT("Rockbox Utility"));
216 this->Center();
217 wxIcon rbutilFrm_ICON (rbutilFrm_XPM);
218 this->SetIcon(rbutilFrm_XPM);
219 this->SetToolTip(wxT("Install Rockbox"));
221 wxLogVerbose(wxT("=== end rbutilFrm::CreateGUIControls"));
224 void rbutilFrm::rbutilFrmClose(wxCloseEvent& event)
226 wxLogVerbose(wxT("=== begin rbutilFrm::rbutilFrmClose(event)"));
227 Destroy();
228 wxLogVerbose(wxT("=== end rbutilFrm::rbutilFrmClose"));
233 * OnFileExit
235 void rbutilFrm::OnFileExit(wxCommandEvent& event)
237 wxLogVerbose(wxT("=== begin rbutilFrm::OnFileExit(event)"));
238 Close();
239 wxLogVerbose(wxT("=== end rbutilFrm::OnFileExit"));
242 // The routines this code uses are in the wxWidgets documentation, but
243 // not yet the library (2.7.0-1). This code can be re-enabled later.
245 void rbutilFrm::OnFileAbout(wxCommandEvent& event)
248 wxAboutDialogInfo *info = new wxAboutDialogInfo();
250 info->SetName(wxT(RBUTIL_FULLNAME));
251 info->SetVersion(wxT(RBUTIL_VERSION));
252 info->SetCopyright(wxT(RBUTIL_COPYRIGHT));
253 info->SetDescription(wxT(RBUTIL_DESCRIPTION));
254 info->SetWebSite(wxT(RBUTIL_WEBSITE));
256 long i = 0;
257 while (rbutil_developers[i] != "")
259 info->AddDeveloper(wxT(rbutil_developers[i++]));
262 wxAboutBox(*info);
263 delete info;
266 AboutDlg(this).ShowModal();
269 void rbutilFrm::OnFileWipeCache(wxCommandEvent& event)
271 wxString cacheloc, datadir;
273 datadir = gv->stdpaths->GetUserDataDir();
274 if (datadir == wxT(""))
276 ERR_DIALOG(wxT("Can't locate user data directory. Unable to delete "
277 "cache."), wxT("Delete download cache.") );
278 return;
281 cacheloc.Printf(wxT("%s" PATH_SEP "download"),
282 datadir.c_str());
284 if (! rm_rf(cacheloc) )
286 wxMessageDialog* msg = new wxMessageDialog(this, wxT("Local download cache has been deleted.")
287 , wxT("Cache deletion"), wxOK |wxICON_INFORMATION);
288 msg->ShowModal();
289 delete msg;
291 else {
292 MESG_DIALOG(wxT("Errors occured deleting the local download cache."));
295 wxMkdir(cacheloc, 0777);
298 void rbutilFrm::OnBootloaderRemoveBtn(wxCommandEvent& event)
300 wxLogVerbose(wxT("=== begin rbutilFrm::OnBootloaderRemoveBtn(event)"));
302 wxWizard *wizard = new wxWizard(this, wxID_ANY,
303 wxT("Rockbox Bootloader Uninstallation Wizard"),
304 wxBitmap(wizard_xpm),
305 wxDefaultPosition,
306 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
307 wxBootPlatformPage* page1 = new wxBootPlatformPage(wizard);
308 wxBootLocationPage* page2 = new wxBootLocationPage(wizard); // Only one of these pages are shown
309 wxIpodLocationPage* page3 = new wxIpodLocationPage(wizard); // depending on Device selected
311 page1->SetNext(page2);
312 page2->SetPrev(page1);
313 page2->SetNext(page3);
314 page3->SetPrev(page2);
316 wizard->GetPageAreaSizer()->Add(page1);
319 if (wizard->RunWizard(page1) )
321 // uninstall the bootloader
322 if(gv->curbootloadermethod == wxT("ipodpatcher"))
325 if(ipodpatcher(BOOTLOADER_REM))
327 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Bootloader has been uninstalled.")
328 ,wxT("Uninstallation"), wxOK |wxICON_INFORMATION);
329 msg->ShowModal();
330 delete msg;
332 else
334 MESG_DIALOG(wxT("The Uninstallation has failed.") );
337 else if(gv->curbootloadermethod == wxT("gigabeatf"))
340 if(gigabeatf(BOOTLOADER_REM))
342 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Bootloader has been uninstalled.")
343 ,wxT("Uninstallation"), wxOK |wxICON_INFORMATION);
344 msg->ShowModal();
345 delete msg;
347 else
348 MESG_DIALOG(wxT("The Uninstallation has failed.") );
350 else if(gv->curbootloadermethod == wxT("h10"))
352 if(h10(BOOTLOADER_REM))
354 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Bootloader has been uninstalled.")
355 ,wxT("Uninstallation"), wxOK |wxICON_INFORMATION);
356 msg->ShowModal();
357 delete msg;
359 else
360 MESG_DIALOG(wxT("The Uninstallation has failed.") );
363 else if(gv->curbootloadermethod == wxT("iaudio") )
365 wxMessageDialog* msg = new wxMessageDialog(this, wxT("To uninstall the Bootloader on this Device,\n"
366 "you need to download and install an Original Firmware from the Manufacturer.")
367 ,wxT("Uninstallation"), wxOK |wxICON_INFORMATION);
368 msg->ShowModal();
369 delete msg;
371 else if(gv->curbootloadermethod == wxT("fwpatcher") )
373 wxMessageDialog* msg = new wxMessageDialog(this, wxT("To uninstall the Bootloader on this Device,\n"
374 "you need to download and install an original Firmware from the Manufacturer.\n"
375 "To do this, you need to boot into the original Firmware.")
376 ,wxT("Uninstallation"), wxOK |wxICON_INFORMATION);
377 msg->ShowModal();
378 delete msg;
380 else
382 MESG_DIALOG(wxT("Unsupported Bootloader Method") );
385 else
387 MESG_DIALOG(wxT("The bootloader Uninstallation wizard was cancelled") );
390 wxLogVerbose(wxT("=== end rbutilFrm::OnBootloaderRemoveBtn"));
393 void rbutilFrm::OnBootloaderBtn(wxCommandEvent& event)
395 wxLogVerbose(wxT("=== begin rbutilFrm::OnBootloaderBtn(event)"));
397 wxWizard *wizard = new wxWizard(this, wxID_ANY,
398 wxT("Rockbox Installation Wizard"),
399 wxBitmap(wizard_xpm),
400 wxDefaultPosition,
401 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
402 wxBootPlatformPage* page1 = new wxBootPlatformPage(wizard);
403 wxFirmwareLocationPage* page2 = new wxFirmwareLocationPage(wizard); //this page is optional
404 wxBootLocationPage* page3 = new wxBootLocationPage(wizard); // Only one of these pages are shown
405 wxIpodLocationPage* page4 = new wxIpodLocationPage(wizard); // depending on Device selected
407 page1->SetNext(page2);
408 page2->SetPrev(page1);
409 page2->SetNext(page3);
410 page3->SetPrev(page2);
411 page3->SetNext(page4);
412 page4->SetPrev(page3);
414 wizard->GetPageAreaSizer()->Add(page1);
416 if (wizard->RunWizard(page1) )
418 // start installation depending on player
419 if(gv->curbootloadermethod == wxT("ipodpatcher"))
422 if(ipodpatcher(BOOTLOADER_ADD))
424 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Bootloader has been installed on your device.")
425 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
426 msg->ShowModal();
427 delete msg;
429 else
431 MESG_DIALOG(wxT("The installation has failed.") );
434 else if(gv->curbootloadermethod == wxT("gigabeatf"))
437 if(gigabeatf(BOOTLOADER_ADD))
439 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Bootloader has been installed on your device.")
440 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
441 msg->ShowModal();
442 delete msg;
444 else
445 MESG_DIALOG(wxT("The installation has failed.") );
447 else if(gv->curbootloadermethod == wxT("iaudio") )
449 if(iaudiox5(BOOTLOADER_ADD))
451 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Bootloader has been installed on your device.\n"
452 "Now turn OFF your Device, unplug USB,and insert Charger\n"
453 "Your Device will automatically upgrade the flash with the Rockbox bootloader")
454 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
455 msg->ShowModal();
456 delete msg;
458 else
459 MESG_DIALOG(wxT("The installation has failed.") );
461 else if(gv->curbootloadermethod == wxT("fwpatcher"))
463 if(fwpatcher(BOOTLOADER_ADD))
465 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Bootloader has been patched and copied on your device.\n"
466 "Now use the Firmware upgrade option of your Device\n")
467 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
468 msg->ShowModal();
469 delete msg;
471 else
472 MESG_DIALOG(wxT("The installation has failed.") );
474 else if(gv->curbootloadermethod == wxT("h10"))
476 if(h10(BOOTLOADER_ADD))
478 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Bootloader has been patched and copied on your device.\n")
479 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
480 msg->ShowModal();
481 delete msg;
483 else
484 MESG_DIALOG(wxT("The installation has failed.") );
486 else
488 MESG_DIALOG(wxT("Unsupported Bootloader Method") );
491 else
493 MESG_DIALOG(wxT("The bootloader installation wizard was cancelled") );
496 wxLogVerbose(wxT("=== end rbutilFrm::OnBootloaderBtn"));
500 void rbutilFrm::OnInstallBtn(wxCommandEvent& event)
502 wxString src, dest, buf;
503 wxDateTime date;
504 wxTimeSpan day(24);
505 wxLogVerbose(wxT("=== begin rbutilFrm::OnInstallBtn(event)"));
506 wxFileSystem fs;
507 wxFileConfig* buildinfo;
508 wxDateSpan oneday;
510 wxWizard *wizard = new wxWizard(this, wxID_ANY,
511 wxT("Rockbox Installation Wizard"),
512 wxBitmap(wizard_xpm),
513 wxDefaultPosition,
514 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
515 wxPlatformPage* page1 = new wxPlatformPage(wizard);
516 wxLocationPage* page2 = new wxLocationPage(wizard);
517 wxBuildPage* page3 = new wxBuildPage(wizard);
518 page1->SetNext(page2);
519 page2->SetPrev(page1);
520 page2->SetNext(page3);
521 page3->SetPrev(page2);
523 wizard->GetPageAreaSizer()->Add(page1);
525 if (wizard->RunWizard(page1) )
527 switch (gv->curbuild)
529 case BUILD_RELEASE:
530 // This is a URL - don't use PATH_SEP
531 src.Printf(wxT("%s%s-%s-%s.zip"),
532 gv->download_url.c_str(), gv->prog_name.c_str(),
533 gv->last_release.c_str(), gv->curplat.c_str());
534 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s-%s-%s.zip"),
535 gv->stdpaths->GetUserDataDir().c_str(),
536 gv->prog_name.c_str(), gv->last_release.c_str(),
537 gv->curplat.c_str());
538 break;
539 case BUILD_DAILY:
540 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "build-info"),
541 gv->stdpaths->GetUserDataDir().c_str());
542 if (DownloadURL(gv->server_conf_url, dest)) {
543 WARN_DIALOG(wxT("Unable to download build status."),
544 wxT("Install"));
545 buf = wxT("");
546 } else
548 buildinfo = new wxFileConfig(wxEmptyString,
549 wxEmptyString, dest);
550 buf = buildinfo->Read(wxT("/dailies/date"));
551 buildinfo->DeleteAll();
553 if (buf.Len() != 8) {
554 dest.Printf(wxT("Invalid build date: %s"), buf.c_str());
555 WARN_DIALOG(dest, wxT("Install"));
556 buf = wxT("");
560 if (buf == wxT("")) {
561 WARN_DIALOG(wxT("Can't get date of latest build from "
562 "server. Using yesterday's date."), wxT("Install") );
563 date = wxDateTime::Now();
564 date.Subtract(oneday.Day());
565 buf = date.Format(wxT("%Y%m%d")); // yes, we want UTC
568 src.Printf(wxT("%s%s/%s-%s-%s.zip"),
569 gv->daily_url.c_str(), gv->curplat.c_str(),
570 gv->prog_name.c_str(), gv->curplat.c_str(),
571 buf.c_str() );
573 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s-%s-%s.zip"),
574 gv->stdpaths->GetUserDataDir().c_str(),
575 gv->prog_name.c_str(),
576 gv->curplat.c_str(), buf.c_str() );
577 break;
578 case BUILD_BLEEDING:
579 src.Printf(wxT("%s%s/%s.zip"),
580 gv->bleeding_url.c_str(), gv->curplat.c_str(),
581 gv->prog_name.c_str() );
582 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s.zip"),
583 gv->stdpaths->GetUserDataDir().c_str(),
584 gv->prog_name.c_str() );
585 break;
586 default:
587 ERR_DIALOG(wxT("Something seriously odd has happened."),
588 wxT("Install"));
589 return;
590 break;
593 if (gv->nocache || ( ! wxFileExists(dest) ) )
595 if ( DownloadURL(src, dest) )
597 wxRemoveFile(dest);
598 buf.Printf(wxT("Unable to download %s"), src.c_str() );
599 ERR_DIALOG(buf, wxT("Install"));
600 return;
604 if ( !UnzipFile(dest, gv->curdestdir, true) )
606 wxMessageDialog* msg = new wxMessageDialog(this, wxT("Rockbox has been installed on your device.")
607 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
608 msg->ShowModal();
609 delete msg;
610 } else
612 wxRemoveFile(dest);
613 buf.Printf(wxT("Unable to unzip %s"), dest.c_str() );
614 ERR_DIALOG(buf, wxT("Install"));
616 } else
618 MESG_DIALOG(wxT("The installation wizard was cancelled") );
621 wxLogVerbose(wxT("=== end rbutilFrm::OnInstallBtn"));
624 void rbutilFrm::OnFontBtn(wxCommandEvent& event)
626 wxString src, dest, buf;
627 wxDateTime date;
628 wxTimeSpan day(24);
629 wxLogVerbose(wxT("=== begin rbutilFrm::OnFontBtn(event)"));
630 wxFileSystem fs;
631 wxFileConfig* buildinfo;
632 wxDateSpan oneday;
634 wxWizard *wizard = new wxWizard(this, wxID_ANY,
635 wxT("Rockbox Font Installation Wizard"),
636 wxBitmap(wizard_xpm),
637 wxDefaultPosition,
638 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
639 wxLocationPage* page1 = new wxLocationPage(wizard);
641 wizard->GetPageAreaSizer()->Add(page1);
643 if (wizard->RunWizard(page1) )
645 buf.Printf(wxT("%s" PATH_SEP ".rockbox"), gv->curdestdir.c_str()) ;
646 if (! wxDirExists(buf) )
648 buf.Printf(wxT("Rockbox is not yet installed on %s - install "
649 "Rockbox first."), buf.c_str() );
650 WARN_DIALOG(buf, wxT("Can't install fonts") );
651 return;
654 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "build-info"),
655 gv->stdpaths->GetUserDataDir().c_str());
656 if (DownloadURL(gv->server_conf_url, dest))
658 WARN_DIALOG(wxT("Unable to download build status."),
659 wxT("Font Install"));
660 buf = wxT("");
661 } else
663 buildinfo = new wxFileConfig(wxEmptyString,
664 wxEmptyString, dest);
665 buf = buildinfo->Read(wxT("/dailies/date"));
666 buildinfo->DeleteAll();
668 if (buf.Len() != 8) {
669 dest.Printf(wxT("Invalid build date: %s"), buf.c_str());
670 WARN_DIALOG(dest, wxT("Font Install"));
671 buf = wxT("");
675 if (buf == wxT("")) {
676 WARN_DIALOG(wxT("Can't get date of latest build from "
677 "server. Using yesterday's date."),
678 wxT("Font Install") );
679 date = wxDateTime::Now();
680 date.Subtract(oneday.Day());
681 buf = date.Format(wxT("%Y%m%d")); // yes, we want UTC
684 src.Printf(wxT("%s%s.zip"), gv->font_url.c_str(), buf.c_str() );
686 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP
687 "rockbox-fonts-%s.zip"), gv->stdpaths->GetUserDataDir().c_str(),
688 buf.c_str() );
690 if ( ! wxFileExists(dest) )
692 if ( DownloadURL(src, dest) )
694 wxRemoveFile(dest);
695 buf.Printf(wxT("Unable to download %s"), src.c_str() );
696 ERR_DIALOG(buf, wxT("Font Install"));
697 return;
701 if ( !UnzipFile(dest, gv->curdestdir, true) )
703 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Rockbox fonts have been installed on your device.")
704 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
705 msg->ShowModal();
706 delete msg;
707 } else
709 wxRemoveFile(dest);
710 buf.Printf(wxT("Unable to unzip %s"), dest.c_str() );
711 ERR_DIALOG(buf, wxT("Font Install"));
713 } else
715 MESG_DIALOG(wxT("The font installation wizard was cancelled") );
718 wxLogVerbose(wxT("=== end rbutilFrm::OnFontBtn"));
722 void rbutilFrm::OnThemesBtn(wxCommandEvent& event)
724 wxString src, dest, buf;
725 wxTimeSpan day(24);
726 wxLogVerbose(wxT("=== begin rbutilFrm::OnThemesBtn(event)"));
728 wxWizard *wizard = new wxWizard(this, wxID_ANY,
729 wxT("Rockbox Themes Installation Wizard"),
730 wxBitmap(wizard_xpm),
731 wxDefaultPosition,
732 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
733 wxPlatformPage* page1 = new wxPlatformPage(wizard);
734 wxLocationPage* page2 = new wxLocationPage(wizard);
735 wxThemesPage* page3 = new wxThemesPage(wizard);
736 page1->SetNext(page2);
737 page2->SetPrev(page1);
738 page2->SetNext(page3);
739 page3->SetPrev(page2);
741 wizard->GetPageAreaSizer()->Add(page1);
743 if (wizard->RunWizard(page1) )
745 bool success=true;
746 for(unsigned int i=0 ;i < gv->themesToInstall.GetCount();i++)
748 if(!InstallTheme(gv->themesToInstall[i]))
750 MESG_DIALOG(wxT("The Themes installation has failed") );
751 success=false;
752 break;
755 if(success)
757 MESG_DIALOG(wxT("The Theme installation completed successfully.") );
762 else
764 MESG_DIALOG(wxT("The Themes installation wizard was cancelled") );
767 wxLogVerbose(wxT("=== end rbutilFrm::OnThemesBtn(event)"));
771 void rbutilFrm::OnRemoveBtn(wxCommandEvent& event)
773 wxLogVerbose(wxT("=== begin rbutilFrm::OnRemoveBtn(event)"));
775 wxWizard *wizard = new wxWizard(this, wxID_ANY,
776 wxT("Rockbox Uninstallation Wizard"),
777 wxBitmap(wizard_xpm),
778 wxDefaultPosition,
779 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
780 wxLocationPage* page1 = new wxLocationPage(wizard);
781 wxFullUninstallPage *page2 = new wxFullUninstallPage(wizard);
782 page1->SetNext(page2);
783 page2->SetPrev(page1);
785 wizard->GetPageAreaSizer()->Add(page1);
787 if (wizard->RunWizard(page1) )
789 if (Uninstall(gv->curdestdir, gv->curisfull) )
791 MESG_DIALOG(
792 wxT("The uninstallation wizard was cancelled or completed with "
793 "some errors.") );
794 } else {
795 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The uninstall wizard completed successfully\n"
796 "Depending on which Device you own, you also have to uninstall the Bootloader")
797 ,wxT("Uninstallation"), wxOK |wxICON_INFORMATION);
798 msg->ShowModal();
799 delete msg;
801 } else
803 MESG_DIALOG(wxT("The uninstallation wizard was cancelled.") );
806 wxLogVerbose(wxT("=== end rbutilFrm::OnRemoveBtn"));
809 void rbutilFrm::OnPortableInstall(wxCommandEvent& event)
811 wxString src, dest, buf;
812 wxLogVerbose(wxT("=== begin rbutilFrm::OnPortableInstall(event)"));
813 wxFileSystem fs;
814 wxDateSpan oneday;
816 wxWizard *wizard = new wxWizard(this, wxID_ANY,
817 wxT("Rockbox Utility Portable Installation Wizard"),
818 wxBitmap(wizard_xpm),
819 wxDefaultPosition,
820 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
821 wxLocationPage* page1 = new wxLocationPage(wizard);
823 wizard->GetPageAreaSizer()->Add(page1);
825 if (wizard->RunWizard(page1) )
827 if ( InstallRbutil(gv->curdestdir) )
829 wxMessageDialog* msg = new wxMessageDialog(this, wxT("The Rockbox Utility has been installed on your device.")
830 ,wxT("Installation"), wxOK |wxICON_INFORMATION);
831 msg->ShowModal();
832 delete msg;
833 } else
835 ERR_DIALOG(wxT("Installation failed"), wxT("Portable Install"));
837 } else
839 MESG_DIALOG(wxT("The portable installation wizard was cancelled") );
842 wxLogVerbose(wxT("=== end rbutilFrm::OnUnstallPortable"));
845 AboutDlg::AboutDlg(rbutilFrm* parent)
846 : wxDialog(parent, -1, wxT("About"), wxDefaultPosition, wxDefaultSize,
847 wxDEFAULT_DIALOG_STYLE)
849 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
850 this->SetSizer(WxBoxSizer1);
851 this->SetAutoLayout(TRUE);
853 wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
855 wxBitmap WxBitmap1 = wxBitmap(rbutilFrm_XPM);
856 wxStaticBitmap* WxStaticBitmap1 = new wxStaticBitmap(this, wxID_ANY,
857 WxBitmap1);
858 WxBoxSizer2->Add(WxStaticBitmap1, 0, wxALL | wxCENTER, 5);
860 wxStaticText* WxStaticText1 = new wxStaticText(this, wxID_ANY,
861 wxT(RBUTIL_FULLNAME), wxDefaultPosition, wxDefaultSize,
862 wxALIGN_CENTER | wxST_NO_AUTORESIZE );
863 WxBoxSizer2->Add(WxStaticText1, 0, wxALL | wxCENTER, 5);
864 WxBoxSizer1->Add(WxBoxSizer2, 0, wxALL, 5);
866 wxStaticText* WxStaticText2 = new wxStaticText(this, wxID_ANY,
867 wxT(RBUTIL_VERSION "\n" RBUTIL_DESCRIPTION "\n\n" RBUTIL_COPYRIGHT));
868 WxStaticText2->Wrap(400);
869 WxBoxSizer1->Add(WxStaticText2, 0, wxALL, 5);
871 wxHyperlinkCtrl* WxHyperlink1 = new wxHyperlinkCtrl(this, wxID_ANY,
872 wxT(RBUTIL_WEBSITE), wxT(RBUTIL_WEBSITE) );
873 WxBoxSizer1->Add(WxHyperlink1, 0, wxALL, 5);
875 wxStaticBox* WxStaticBox1 = new wxStaticBox(this, wxID_ANY, wxT("Contributors:"));
876 wxStaticBoxSizer* WxStaticBoxSizer2 = new wxStaticBoxSizer(WxStaticBox1,
877 wxVERTICAL);
878 wxTextCtrl* WxTextCtrl1 = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
879 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY);
881 long i = 0;
882 while ( rbutil_developers[i] != wxT(""))
884 WxTextCtrl1->AppendText(rbutil_developers[i++]);
885 WxTextCtrl1->AppendText(wxT("\n"));
888 WxBoxSizer1->Add(WxStaticBoxSizer2, 1, wxGROW | wxALL, 5);
889 WxStaticBoxSizer2->Add(WxTextCtrl1, 1, wxGROW | wxALL, 0);
891 wxStdDialogButtonSizer* WxStdDialogButtonSizer1 = new wxStdDialogButtonSizer();
892 wxButton* WxOKButton = new wxButton(this, wxID_OK);
893 WxStdDialogButtonSizer1->AddButton(WxOKButton);
894 WxStdDialogButtonSizer1->Realize();
896 WxBoxSizer1->Add(WxStdDialogButtonSizer1, 0, wxALL | wxCENTER, 5);
898 GetSizer()->Fit(this);
899 GetSizer()->SetSizeHints(this);
901 //this->Center();
902 this->Show();
906 AboutDlg::~AboutDlg()