fix "hide radio menu if no tuner is detected"; wrong constant was used
[Rockbox.git] / rbutil / rbutilFrm.cpp
blob738da27f2a6cf0c804f617b5be602f1688276cfd
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"
31 #include "bootloaders.h"
33 #include "wizard.xpm"
35 //----------------------------------------------------------------------------
36 // rbutilFrm
37 //----------------------------------------------------------------------------
39 BEGIN_EVENT_TABLE(rbutilFrm,wxFrame)
40 EVT_BUTTON (ID_INSTALL_BTN, rbutilFrm::OnInstallBtn)
41 EVT_BUTTON (ID_REMOVE_BTN, rbutilFrm::OnRemoveBtn)
42 EVT_BUTTON (ID_FONT_BTN, rbutilFrm::OnFontBtn)
43 EVT_BUTTON (ID_BOOTLOADER_BTN, rbutilFrm::OnBootloaderBtn)
44 EVT_BUTTON (ID_BOOTLOADERREMOVE_BTN, rbutilFrm::OnBootloaderRemoveBtn)
46 EVT_CLOSE(rbutilFrm::rbutilFrmClose)
47 EVT_MENU(ID_FILE_EXIT, rbutilFrm::OnFileExit)
48 EVT_MENU(ID_FILE_ABOUT, rbutilFrm::OnFileAbout)
49 EVT_MENU(ID_FILE_WIPECACHE, rbutilFrm::OnFileWipeCache)
50 EVT_MENU(ID_PORTABLE_INSTALL, rbutilFrm::OnPortableInstall)
51 END_EVENT_TABLE()
53 rbutilFrm::rbutilFrm( wxWindow *parent, wxWindowID id, const wxString &title,
54 const wxPoint &position, const wxSize& size, long style )
55 : wxFrame( parent, id, title, position, size, style)
57 wxLogVerbose(wxT("=== begin rbutilFrm::rbutilFrm(...)"));
58 CreateGUIControls();
59 wxLogVerbose(wxT("=== end rbutilFrm::rbutilFrm"));
62 rbutilFrm::~rbutilFrm() {}
64 void rbutilFrm::CreateGUIControls(void)
66 wxLogVerbose(wxT("=== begin rbutilFrm::CreateGUIControls()"));
68 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
69 this->SetSizer(WxBoxSizer1);
70 this->SetAutoLayout(TRUE);
72 WxPanel1 = new wxPanel(this, ID_WXPANEL1, wxPoint(0,0), wxSize(400,600));
73 WxBoxSizer1->Add(WxPanel1,1,wxGROW | wxALL,0);
75 wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxVERTICAL);
76 WxPanel1->SetSizer(WxBoxSizer2);
77 WxPanel1->SetAutoLayout(TRUE);
79 wxBitmap WxStaticBitmap1_BITMAP(rblogo_xpm);
80 WxStaticBitmap1 = new wxStaticBitmap(WxPanel1, ID_WXSTATICBITMAP1,
81 WxStaticBitmap1_BITMAP, wxPoint(0,0), wxSize(400,123));
82 WxStaticBitmap1->Enable(false);
83 WxBoxSizer2->Add(WxStaticBitmap1,0,wxALIGN_CENTER_HORIZONTAL | wxALL,5);
85 wxStaticBox* WxStaticBoxSizer3_StaticBoxObj = new wxStaticBox(WxPanel1,
86 wxID_ANY, _("Please choose an option"));
87 wxStaticBoxSizer* WxStaticBoxSizer3 =
88 new wxStaticBoxSizer(WxStaticBoxSizer3_StaticBoxObj,wxHORIZONTAL);
89 WxBoxSizer2->Add(WxStaticBoxSizer3,1,wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
91 wxFlexGridSizer* WxFlexGridSizer1 = new wxFlexGridSizer(2,2,0,0);
92 WxStaticBoxSizer3->Add(WxFlexGridSizer1,0,wxGROW | wxALL,0);
94 wxBitmap BootloaderInstallButton (tools2_3d_xpm);
95 WxBitmapButton4 = new wxBitmapButton(WxPanel1, ID_BOOTLOADER_BTN,
96 BootloaderInstallButton, wxPoint(0,0), wxSize(64,54),
97 wxRAISED_BORDER | wxBU_AUTODRAW);
98 WxBitmapButton4->SetToolTip(_("Instructions for installing the "
99 "Rockbox bootloader on your audio device"));
100 WxFlexGridSizer1->Add(WxBitmapButton4, 0,
101 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
103 wxStaticText* WxStaticText5 = new wxStaticText(WxPanel1, wxID_ANY,
104 _("Bootloader installation instructions\n\n"
105 "Before Rockbox can be installed on your audio player, you "
106 "may have to\ninstall a bootloader. This can not currently "
107 "be done automatically, but is\nonly necessary the first time "
108 "Rockbox is installed."));
109 WxFlexGridSizer1->Add(WxStaticText5, 0,
110 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
112 wxBitmap WxBitmapButton1_BITMAP (install_3d_xpm);
113 WxBitmapButton1 = new wxBitmapButton(WxPanel1, ID_INSTALL_BTN,
114 WxBitmapButton1_BITMAP, wxPoint(0,0), wxSize(64,54),
115 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
116 wxT("WxBitmapButton1"));
117 WxBitmapButton1->SetToolTip(_("Install Rockbox"));
118 WxFlexGridSizer1->Add(WxBitmapButton1,0,
119 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
121 WxStaticText2 = new wxStaticText(WxPanel1, ID_WXSTATICTEXT2,
122 _("Install Rockbox on your audio player"));
123 WxFlexGridSizer1->Add(WxStaticText2,0,
124 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
126 wxBitmap FontInstallButton (fonts_3d_xpm);
127 WxBitmapButton3 = new wxBitmapButton(WxPanel1, ID_FONT_BTN,
128 FontInstallButton, wxPoint(0,0), wxSize(64,54),
129 wxRAISED_BORDER | wxBU_AUTODRAW);
130 WxBitmapButton3->SetToolTip(_("Download the most up to date "
131 "Rockbox fonts."));
132 WxFlexGridSizer1->Add(WxBitmapButton3, 0,
133 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
135 wxStaticText* WxStaticText4 = new wxStaticText(WxPanel1, wxID_ANY,
136 _("Install the Rockbox fonts package\n\n"
137 "This step is only needed if you have installed "
138 "a daily build and want\nthe full set of Rockbox fonts. You "
139 "will not need to download these\nagain unless you uninstall "
140 "Rockbox."));
141 WxFlexGridSizer1->Add(WxStaticText4, 0,
142 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
144 wxBitmap WxBitmapButton2_BITMAP (uninstall_3d_xpm);
145 WxBitmapButton2 = new wxBitmapButton(WxPanel1, ID_REMOVE_BTN,
146 WxBitmapButton2_BITMAP, wxPoint(0,0), wxSize(64,54),
147 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
148 wxT("WxBitmapButton2"));
149 WxBitmapButton2->SetToolTip(_("Uninstall Rockbox"));
150 WxFlexGridSizer1->Add(WxBitmapButton2,0,
151 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
153 WxStaticText3 = new wxStaticText(WxPanel1, ID_WXSTATICTEXT3,
154 _("Remove Rockbox from your audio player"));
155 WxFlexGridSizer1->Add(WxStaticText3,0,
156 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
158 wxBitmap WxBitmapButton4_BITMAP (uninstall_3d_xpm);
159 WxBitmapButton4 = new wxBitmapButton(WxPanel1, ID_BOOTLOADERREMOVE_BTN,
160 WxBitmapButton4_BITMAP, wxPoint(0,0), wxSize(64,54),
161 wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
162 wxT("WxBitmapButton4"));
163 WxBitmapButton4->SetToolTip(_("Uninstall Bootloader"));
164 WxFlexGridSizer1->Add(WxBitmapButton4,0,
165 wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL,5);
167 WxStaticText4 = new wxStaticText(WxPanel1, ID_WXSTATICTEXT4,
168 _("Remove Rockbox Bootloader from your audio player"));
169 WxFlexGridSizer1->Add(WxStaticText4,0,
170 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
172 WxMenuBar1 = new wxMenuBar();
173 wxMenu *ID_FILE_MENU_Mnu_Obj = new wxMenu(0);
174 WxMenuBar1->Append(ID_FILE_MENU_Mnu_Obj, _("&File"));
176 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_WIPECACHE,
177 _("&Empty local download cache"), wxT(""), wxITEM_NORMAL);
178 if (! gv->portable )
180 ID_FILE_MENU_Mnu_Obj->Append(ID_PORTABLE_INSTALL,
181 _("&Install Rockbox Utility on device"), wxT(""), wxITEM_NORMAL);
183 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_ABOUT, _("&About"), wxT(""),
184 wxITEM_NORMAL);
185 ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_EXIT, _("E&xit\tCtrl+X"), wxT(""),
186 wxITEM_NORMAL);
188 this->SetMenuBar(WxMenuBar1);
190 GetSizer()->Fit(this);
191 GetSizer()->SetSizeHints(this);
192 if (gv->portable)
194 this->SetTitle(_("Rockbox Utility (portable)"));
195 } else
197 this->SetTitle(_("Rockbox Utility"));
199 this->Center();
200 wxIcon rbutilFrm_ICON (rbutilFrm_XPM);
201 this->SetIcon(rbutilFrm_XPM);
202 this->SetToolTip(wxT("Install Rockbox"));
204 wxLogVerbose("=== end rbutilFrm::CreateGUIControls");
207 void rbutilFrm::rbutilFrmClose(wxCloseEvent& event)
209 wxLogVerbose("=== begin rbutilFrm::rbutilFrmClose(event)");
210 Destroy();
211 wxLogVerbose("=== end rbutilFrm::rbutilFrmClose");
216 * OnFileExit
218 void rbutilFrm::OnFileExit(wxCommandEvent& event)
220 wxLogVerbose("=== begin rbutilFrm::OnFileExit(event)");
221 Close();
222 wxLogVerbose("=== end rbutilFrm::OnFileExit");
225 // The routines this code uses are in the wxWidgets documentation, but
226 // not yet the library (2.7.0-1). This code can be re-enabled later.
228 void rbutilFrm::OnFileAbout(wxCommandEvent& event)
231 wxAboutDialogInfo *info = new wxAboutDialogInfo();
233 info->SetName(_(RBUTIL_FULLNAME));
234 info->SetVersion(_(RBUTIL_VERSION));
235 info->SetCopyright(_(RBUTIL_COPYRIGHT));
236 info->SetDescription(_(RBUTIL_DESCRIPTION));
237 info->SetWebSite(_(RBUTIL_WEBSITE));
239 long i = 0;
240 while (rbutil_developers[i] != "")
242 info->AddDeveloper(wxT(rbutil_developers[i++]));
245 wxAboutBox(*info);
246 delete info;
249 AboutDlg(this).ShowModal();
252 void rbutilFrm::OnFileWipeCache(wxCommandEvent& event)
254 wxString cacheloc, datadir;
256 datadir = gv->stdpaths->GetUserDataDir();
257 if (datadir == "")
259 ERR_DIALOG(_("Can't locate user data directory. Unable to delete "
260 "cache."), _("Delete download cache.") );
261 return;
264 cacheloc.Printf(wxT("%s" PATH_SEP "download"),
265 datadir.c_str());
267 if (! rm_rf(cacheloc) )
269 wxMessageDialog* msg = new wxMessageDialog(this, _("Local download cache has been deleted.")
270 ,"Cache deletion", wxOK |wxICON_INFORMATION);
271 msg->ShowModal();
272 delete msg;
274 else {
275 MESG_DIALOG(_("Errors occured deleting the local download cache."));
278 wxMkdir(cacheloc, 0777);
281 void rbutilFrm::OnBootloaderRemoveBtn(wxCommandEvent& event)
283 wxLogVerbose("=== begin rbutilFrm::OnBootloaderRemoveBtn(event)");
285 wxWizard *wizard = new wxWizard(this, wxID_ANY,
286 _("Rockbox Bootloader Uninstallation Wizard"),
287 wxBitmap(wizard_xpm),
288 wxDefaultPosition,
289 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
290 wxBootPlatformPage* page1 = new wxBootPlatformPage(wizard);
291 wxBootLocationPage* page2 = new wxBootLocationPage(wizard); // Only one of these pages are shown
292 wxIpodLocationPage* page3 = new wxIpodLocationPage(wizard); // depending on Device selected
294 page1->SetNext(page2);
295 page2->SetPrev(page1);
296 page2->SetNext(page3);
297 page3->SetPrev(page2);
299 wizard->GetPageAreaSizer()->Add(page1);
302 if (wizard->RunWizard(page1) )
304 // uninstall the bootloader
305 if(gv->curbootloadermethod == "ipodpatcher")
308 if(ipodpatcher(BOOTLOADER_REM))
310 wxMessageDialog* msg = new wxMessageDialog(this, _("The Bootloader has been uninstalled.")
311 ,"Uninstallation", wxOK |wxICON_INFORMATION);
312 msg->ShowModal();
313 delete msg;
315 else
317 MESG_DIALOG(_("The Uninstallation has failed.") );
320 else if(gv->curbootloadermethod == "gigabeatf")
323 if(gigabeatf(BOOTLOADER_REM))
325 wxMessageDialog* msg = new wxMessageDialog(this, _("The Bootloader has been uninstalled.")
326 ,"Uninstallation", wxOK |wxICON_INFORMATION);
327 msg->ShowModal();
328 delete msg;
330 else
331 MESG_DIALOG(_("The Uninstallation has failed.") );
333 else if(gv->curbootloadermethod == "h10")
335 if(h10(BOOTLOADER_REM))
337 wxMessageDialog* msg = new wxMessageDialog(this, _("The Bootloader has been uninstalled.")
338 ,"Uninstallation", wxOK |wxICON_INFORMATION);
339 msg->ShowModal();
340 delete msg;
342 else
343 MESG_DIALOG(_("The Uninstallation has failed.") );
346 else if(gv->curbootloadermethod == "iaudio" )
348 wxMessageDialog* msg = new wxMessageDialog(this, _("To uninstall the Bootloader on this Device,\n"
349 "you need to download and install an Original Firmware from the Manufacturer.")
350 ,"Uninstallation", wxOK |wxICON_INFORMATION);
351 msg->ShowModal();
352 delete msg;
354 else if(gv->curbootloadermethod == "fwpatcher" )
356 wxMessageDialog* msg = new wxMessageDialog(this, _("To uninstall the Bootloader on this Device,\n"
357 "you need to download and install an original Firmware from the Manufacturer.\n"
358 "To do this, you need to boot into the original Firmware.")
359 ,"Uninstallation", wxOK |wxICON_INFORMATION);
360 msg->ShowModal();
361 delete msg;
363 else
365 MESG_DIALOG(_("Unsupported Bootloader Method") );
368 else
370 MESG_DIALOG(_("The bootloader Uninstallation wizard was cancelled") );
373 wxLogVerbose("=== end rbutilFrm::OnBootloaderRemoveBtn");
376 void rbutilFrm::OnBootloaderBtn(wxCommandEvent& event)
378 wxLogVerbose("=== begin rbutilFrm::OnBootloaderBtn(event)");
380 wxWizard *wizard = new wxWizard(this, wxID_ANY,
381 _("Rockbox Installation Wizard"),
382 wxBitmap(wizard_xpm),
383 wxDefaultPosition,
384 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
385 wxBootPlatformPage* page1 = new wxBootPlatformPage(wizard);
386 wxFirmwareLocationPage* page2 = new wxFirmwareLocationPage(wizard); //this page is optional
387 wxBootLocationPage* page3 = new wxBootLocationPage(wizard); // Only one of these pages are shown
388 wxIpodLocationPage* page4 = new wxIpodLocationPage(wizard); // depending on Device selected
390 page1->SetNext(page2);
391 page2->SetPrev(page1);
392 page2->SetNext(page3);
393 page3->SetPrev(page2);
394 page3->SetNext(page4);
395 page4->SetPrev(page3);
397 wizard->GetPageAreaSizer()->Add(page1);
399 if (wizard->RunWizard(page1) )
401 // start installation depending on player
402 if(gv->curbootloadermethod == "ipodpatcher")
405 if(ipodpatcher(BOOTLOADER_ADD))
407 wxMessageDialog* msg = new wxMessageDialog(this, _("The Bootloader has been installed on your device.")
408 ,"Installation", wxOK |wxICON_INFORMATION);
409 msg->ShowModal();
410 delete msg;
412 else
414 MESG_DIALOG(_("The installation has failed.") );
417 else if(gv->curbootloadermethod == "gigabeatf")
420 if(gigabeatf(BOOTLOADER_ADD))
422 wxMessageDialog* msg = new wxMessageDialog(this, _("The Bootloader has been installed on your device.")
423 ,"Installation", wxOK |wxICON_INFORMATION);
424 msg->ShowModal();
425 delete msg;
427 else
428 MESG_DIALOG(_("The installation has failed.") );
430 else if(gv->curbootloadermethod == "iaudio" )
432 if(iaudiox5(BOOTLOADER_ADD))
434 wxMessageDialog* msg = new wxMessageDialog(this, _("The Bootloader has been installed on your device.\n"
435 "Now turn OFF your Device, unplug USB,and insert Charger\n"
436 "Your Device will automatically upgrade the flash with the Rockbox bootloader")
437 ,"Installation", wxOK |wxICON_INFORMATION);
438 msg->ShowModal();
439 delete msg;
441 else
442 MESG_DIALOG(_("The installation has failed.") );
444 else if(gv->curbootloadermethod == "fwpatcher")
446 if(fwpatcher(BOOTLOADER_ADD))
448 wxMessageDialog* msg = new wxMessageDialog(this, _("The Bootloader has been patched and copied on your device.\n"
449 "Now use the Firmware upgrade option of your Device\n")
450 ,"Installation", wxOK |wxICON_INFORMATION);
451 msg->ShowModal();
452 delete msg;
454 else
455 MESG_DIALOG(_("The installation has failed.") );
457 else if(gv->curbootloadermethod == "h10")
459 if(h10(BOOTLOADER_ADD))
461 wxMessageDialog* msg = new wxMessageDialog(this, _("The Bootloader has been patched and copied on your device.\n"
462 "Now use the Firmware upgrade option of your Device\n")
463 ,"Installation", wxOK |wxICON_INFORMATION);
464 msg->ShowModal();
465 delete msg;
467 else
468 MESG_DIALOG(_("The installation has failed.") );
470 else
472 MESG_DIALOG(_("Unsupported Bootloader Method") );
475 else
477 MESG_DIALOG(_("The bootloader installation wizard was cancelled") );
480 wxLogVerbose("=== end rbutilFrm::OnBootloaderBtn");
484 void rbutilFrm::OnInstallBtn(wxCommandEvent& event)
486 wxString src, dest, buf;
487 wxDateTime date;
488 wxTimeSpan day(24);
489 wxLogVerbose("=== begin rbutilFrm::OnInstallBtn(event)");
490 wxFileSystem fs;
491 wxFileConfig* buildinfo;
492 wxDateSpan oneday;
494 wxWizard *wizard = new wxWizard(this, wxID_ANY,
495 _("Rockbox Installation Wizard"),
496 wxBitmap(wizard_xpm),
497 wxDefaultPosition,
498 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
499 wxPlatformPage* page1 = new wxPlatformPage(wizard);
500 wxLocationPage* page2 = new wxLocationPage(wizard);
501 wxBuildPage* page3 = new wxBuildPage(wizard);
502 page1->SetNext(page2);
503 page2->SetPrev(page1);
504 page2->SetNext(page3);
505 page3->SetPrev(page2);
507 wizard->GetPageAreaSizer()->Add(page1);
509 if (wizard->RunWizard(page1) )
511 switch (gv->curbuild)
513 case BUILD_RELEASE:
514 // This is a URL - don't use PATH_SEP
515 src.Printf("%s%s-%s-%s.zip",
516 gv->download_url.c_str(), gv->prog_name.c_str(),
517 gv->last_release.c_str(), gv->curplat.c_str());
518 dest.Printf("%s" PATH_SEP "download" PATH_SEP "%s-%s-%s.zip",
519 gv->stdpaths->GetUserDataDir().c_str(),
520 gv->prog_name.c_str(), gv->last_release.c_str(),
521 gv->curplat.c_str());
522 break;
523 case BUILD_DAILY:
524 dest.Printf("%s" PATH_SEP "download" PATH_SEP "build-info",
525 gv->stdpaths->GetUserDataDir().c_str());
526 if (DownloadURL(gv->server_conf_url, dest)) {
527 WARN_DIALOG(_("Unable to download build status."),
528 _("Install"));
529 buf = "";
530 } else
532 buildinfo = new wxFileConfig(wxEmptyString,
533 wxEmptyString, dest);
534 buf = buildinfo->Read(wxT("/dailies/date"));
535 buildinfo->DeleteAll();
537 if (buf.Len() != 8) {
538 dest.Printf(_("Invalid build date: %s"), buf.c_str());
539 WARN_DIALOG(dest, _("Install"));
540 buf = "";
544 if (buf == "") {
545 WARN_DIALOG(_("Can't get date of latest build from "
546 "server. Using yesterday's date."), _("Install") );
547 date = wxDateTime::Now();
548 date.Subtract(oneday.Day());
549 buf = date.Format(wxT("%Y%m%d")); // yes, we want UTC
552 src.Printf("%s%s/%s-%s-%s.zip",
553 gv->daily_url.c_str(), gv->curplat.c_str(),
554 gv->prog_name.c_str(), gv->curplat.c_str(),
555 buf.c_str() );
557 dest.Printf("%s" PATH_SEP "download" PATH_SEP "%s-%s-%s.zip",
558 gv->stdpaths->GetUserDataDir().c_str(),
559 gv->prog_name.c_str(),
560 gv->curplat.c_str(), buf.c_str() );
561 break;
562 case BUILD_BLEEDING:
563 src.Printf("%s%s/%s.zip",
564 gv->bleeding_url.c_str(), gv->curplat.c_str(),
565 gv->prog_name.c_str() );
566 dest.Printf("%s" PATH_SEP "download" PATH_SEP "%s.zip",
567 gv->stdpaths->GetUserDataDir().c_str(),
568 gv->prog_name.c_str() );
569 break;
570 default:
571 ERR_DIALOG(_("Something seriously odd has happened."),
572 _("Install"));
573 return;
574 break;
577 if (gv->nocache || ( ! wxFileExists(dest) ) )
579 if ( DownloadURL(src, dest) )
581 wxRemoveFile(dest);
582 buf.Printf(_("Unable to download %s"), src.c_str() );
583 ERR_DIALOG(buf, _("Install"));
584 return;
588 if ( !UnzipFile(dest, gv->curdestdir, true) )
590 wxMessageDialog* msg = new wxMessageDialog(this, _("Rockbox has been installed on your device.")
591 ,"Installation", wxOK |wxICON_INFORMATION);
592 msg->ShowModal();
593 delete msg;
594 } else
596 wxRemoveFile(dest);
597 buf.Printf(_("Unable to unzip %s"), dest.c_str() );
598 ERR_DIALOG(buf, _("Install"));
600 } else
602 MESG_DIALOG(_("The installation wizard was cancelled") );
605 wxLogVerbose("=== end rbutilFrm::OnInstallBtn");
608 void rbutilFrm::OnFontBtn(wxCommandEvent& event)
610 wxString src, dest, buf;
611 wxDateTime date;
612 wxTimeSpan day(24);
613 wxLogVerbose("=== begin rbutilFrm::OnFontBtn(event)");
614 wxFileSystem fs;
615 wxFileConfig* buildinfo;
616 wxDateSpan oneday;
618 wxWizard *wizard = new wxWizard(this, wxID_ANY,
619 _("Rockbox Font Installation Wizard"),
620 wxBitmap(wizard_xpm),
621 wxDefaultPosition,
622 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
623 wxLocationPage* page1 = new wxLocationPage(wizard);
625 wizard->GetPageAreaSizer()->Add(page1);
627 if (wizard->RunWizard(page1) )
629 buf.Printf(wxT("%s" PATH_SEP ".rockbox"), gv->curdestdir.c_str()) ;
630 if (! wxDirExists(buf) )
632 buf.Printf(_("Rockbox is not yet installed on %s - install "
633 "Rockbox first."), buf.c_str() );
634 WARN_DIALOG(buf, _("Can't install fonts") );
635 return;
638 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "build-info"),
639 gv->stdpaths->GetUserDataDir().c_str());
640 if (DownloadURL(gv->server_conf_url, dest))
642 WARN_DIALOG(_("Unable to download build status."),
643 _("Font Install"));
644 buf = "";
645 } else
647 buildinfo = new wxFileConfig(wxEmptyString,
648 wxEmptyString, dest);
649 buf = buildinfo->Read(wxT("/dailies/date"));
650 buildinfo->DeleteAll();
652 if (buf.Len() != 8) {
653 dest.Printf(_("Invalid build date: %s"), buf.c_str());
654 WARN_DIALOG(dest, _("Font Install"));
655 buf = "";
659 if (buf == "") {
660 WARN_DIALOG(_("Can't get date of latest build from "
661 "server. Using yesterday's date."),
662 _("Font Install") );
663 date = wxDateTime::Now();
664 date.Subtract(oneday.Day());
665 buf = date.Format(wxT("%Y%m%d")); // yes, we want UTC
668 src.Printf("%s%s.zip", gv->font_url.c_str(), buf.c_str() );
670 dest.Printf("%s" PATH_SEP "download" PATH_SEP
671 "rockbox-fonts-%s.zip", gv->stdpaths->GetUserDataDir().c_str(),
672 buf.c_str() );
674 if ( ! wxFileExists(dest) )
676 if ( DownloadURL(src, dest) )
678 wxRemoveFile(dest);
679 buf.Printf(_("Unable to download %s"), src.c_str() );
680 ERR_DIALOG(buf, _("Font Install"));
681 return;
685 if ( !UnzipFile(dest, gv->curdestdir, true) )
687 wxMessageDialog* msg = new wxMessageDialog(this, _("The Rockbox fonts have been installed on your device.")
688 ,"Installation", wxOK |wxICON_INFORMATION);
689 msg->ShowModal();
690 delete msg;
691 } else
693 wxRemoveFile(dest);
694 buf.Printf(_("Unable to unzip %s"), dest.c_str() );
695 ERR_DIALOG(buf, _("Font Install"));
697 } else
699 MESG_DIALOG(_("The font installation wizard was cancelled") );
702 wxLogVerbose("=== end rbutilFrm::OnFontBtn");
705 void rbutilFrm::OnRemoveBtn(wxCommandEvent& event)
707 wxLogVerbose("=== begin rbutilFrm::OnRemoveBtn(event)");
709 wxWizard *wizard = new wxWizard(this, wxID_ANY,
710 _("Rockbox Uninstallation Wizard"),
711 wxBitmap(wizard_xpm),
712 wxDefaultPosition,
713 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
714 wxLocationPage* page1 = new wxLocationPage(wizard);
715 wxFullUninstallPage *page2 = new wxFullUninstallPage(wizard);
716 page1->SetNext(page2);
717 page2->SetPrev(page1);
719 wizard->GetPageAreaSizer()->Add(page1);
721 if (wizard->RunWizard(page1) )
723 if (Uninstall(gv->curdestdir, gv->curisfull) )
725 MESG_DIALOG(
726 _("The uninstallation wizard was cancelled or completed with "
727 "some errors.") );
728 } else {
729 wxMessageDialog* msg = new wxMessageDialog(this, _("The uninstall wizard completed successfully\n"
730 "Depending on which Device you own, you also have to uninstall the Bootloader")
731 ,"Uninstallation", wxOK |wxICON_INFORMATION);
732 msg->ShowModal();
733 delete msg;
735 } else
737 MESG_DIALOG(_("The uninstallation wizard was cancelled.") );
740 wxLogVerbose("=== end rbutilFrm::OnRemoveBtn");
743 void rbutilFrm::OnPortableInstall(wxCommandEvent& event)
745 wxString src, dest, buf;
746 wxLogVerbose("=== begin rbutilFrm::OnPortableInstall(event)");
747 wxFileSystem fs;
748 wxFileConfig* buildinfo;
749 wxDateSpan oneday;
751 wxWizard *wizard = new wxWizard(this, wxID_ANY,
752 _("Rockbox Utility Portable Installation Wizard"),
753 wxBitmap(wizard_xpm),
754 wxDefaultPosition,
755 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
756 wxLocationPage* page1 = new wxLocationPage(wizard);
758 wizard->GetPageAreaSizer()->Add(page1);
760 if (wizard->RunWizard(page1) )
762 if ( InstallRbutil(gv->curdestdir) )
764 wxMessageDialog* msg = new wxMessageDialog(this, _("The Rockbox Utility has been installed on your device.")
765 ,"Installation", wxOK |wxICON_INFORMATION);
766 msg->ShowModal();
767 delete msg;
768 } else
770 ERR_DIALOG(_("Installation failed"), _("Portable Install"));
772 } else
774 MESG_DIALOG(_("The portable installation wizard was cancelled") );
777 wxLogVerbose("=== end rbutilFrm::OnUnstallPortable");
780 AboutDlg::AboutDlg(rbutilFrm* parent)
781 : wxDialog(parent, -1, _("About"), wxDefaultPosition, wxDefaultSize,
782 wxDEFAULT_DIALOG_STYLE)
784 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
785 this->SetSizer(WxBoxSizer1);
786 this->SetAutoLayout(TRUE);
788 wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
790 wxBitmap WxBitmap1 = wxBitmap(rbutilFrm_XPM);
791 wxStaticBitmap* WxStaticBitmap1 = new wxStaticBitmap(this, wxID_ANY,
792 WxBitmap1);
793 WxBoxSizer2->Add(WxStaticBitmap1, 0, wxALL | wxCENTER, 5);
795 wxStaticText* WxStaticText1 = new wxStaticText(this, wxID_ANY,
796 _(RBUTIL_FULLNAME), wxDefaultPosition, wxDefaultSize,
797 wxALIGN_CENTER | wxST_NO_AUTORESIZE );
798 WxBoxSizer2->Add(WxStaticText1, 0, wxALL | wxCENTER, 5);
799 WxBoxSizer1->Add(WxBoxSizer2, 0, wxALL, 5);
801 wxStaticText* WxStaticText2 = new wxStaticText(this, wxID_ANY,
802 _(RBUTIL_VERSION "\n" RBUTIL_DESCRIPTION "\n\n" RBUTIL_COPYRIGHT));
803 WxStaticText2->Wrap(400);
804 WxBoxSizer1->Add(WxStaticText2, 0, wxALL, 5);
806 wxHyperlinkCtrl* WxHyperlink1 = new wxHyperlinkCtrl(this, wxID_ANY,
807 wxT(RBUTIL_WEBSITE), wxT(RBUTIL_WEBSITE) );
808 WxBoxSizer1->Add(WxHyperlink1, 0, wxALL, 5);
810 wxStaticBox* WxStaticBox1 = new wxStaticBox(this, wxID_ANY, _("Contributors:"));
811 wxStaticBoxSizer* WxStaticBoxSizer2 = new wxStaticBoxSizer(WxStaticBox1,
812 wxVERTICAL);
813 wxTextCtrl* WxTextCtrl1 = new wxTextCtrl(this, wxID_ANY, wxEmptyString,
814 wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY);
816 long i = 0;
817 while ( rbutil_developers[i] != "")
819 WxTextCtrl1->AppendText(rbutil_developers[i++]);
820 WxTextCtrl1->AppendText("\n");
823 WxBoxSizer1->Add(WxStaticBoxSizer2, 1, wxGROW | wxALL, 5);
824 WxStaticBoxSizer2->Add(WxTextCtrl1, 1, wxGROW | wxALL, 0);
826 wxStdDialogButtonSizer* WxStdDialogButtonSizer1 = new wxStdDialogButtonSizer();
827 wxButton* WxOKButton = new wxButton(this, wxID_OK);
828 WxStdDialogButtonSizer1->AddButton(WxOKButton);
829 WxStdDialogButtonSizer1->Realize();
831 WxBoxSizer1->Add(WxStdDialogButtonSizer1, 0, wxALL | wxCENTER, 5);
833 GetSizer()->Fit(this);
834 GetSizer()->SetSizeHints(this);
836 //this->Center();
837 this->Show();
841 AboutDlg::~AboutDlg()