diff options
author | Dominik Wenger <domonoky@googlemail.com> | 2007-03-15 18:02:15 +0000 |
---|---|---|
committer | Dominik Wenger <domonoky@googlemail.com> | 2007-03-15 18:02:15 +0000 |
commit | c9cafd846fbc43fba9eb559cb86160a94f7f97a1 (patch) | |
tree | 80ca1998e0eee7176f7115026d29852bdd67a335 | |
parent | 410af8955f89ee5ff9498448bcc185988869bdb3 (diff) |
more Unicode fixes for rutil, thanx to preglow. Also made Theme Preview window modeless
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12785 a1c6a512-1295-4272-9138-f99709370657
-rwxr-xr-x | rbutil/bootloaders.cpp | 11 | ||||
-rw-r--r-- | rbutil/credits.h | 18 | ||||
-rw-r--r-- | rbutil/installlog.cpp | 20 | ||||
-rwxr-xr-x | rbutil/irivertools.cpp | 10 | ||||
-rwxr-xr-x | rbutil/irivertools.h | 2 | ||||
-rwxr-xr-x | rbutil/md5sum.cpp | 8 | ||||
-rwxr-xr-x | rbutil/md5sum.h | 2 | ||||
-rw-r--r-- | rbutil/rbutil.cpp | 6 | ||||
-rw-r--r-- | rbutil/rbutilApp.cpp | 4 | ||||
-rw-r--r-- | rbutil/rbutilFrm.cpp | 16 | ||||
-rw-r--r-- | rbutil/wizard_pages.cpp | 76 | ||||
-rw-r--r-- | rbutil/wizard_pages.h | 3 |
12 files changed, 114 insertions, 62 deletions
diff --git a/rbutil/bootloaders.cpp b/rbutil/bootloaders.cpp index c2303beacc..3d2734b6b9 100755 --- a/rbutil/bootloaders.cpp +++ b/rbutil/bootloaders.cpp @@ -368,10 +368,11 @@ bool fwpatcher(int mode) { if(mode == BOOTLOADER_ADD) { - wxString md5sum_str,src,dest,err; + char md5sum_str[32]; + wxString src,dest,err; int series,table_entry; - if (!FileMD5(gv->curfirmware, &md5sum_str)) { + if (!FileMD5(gv->curfirmware, md5sum_str)) { ERR_DIALOG(wxT("Could not open firmware"), wxT("Open Firmware")); return false; } @@ -426,11 +427,11 @@ bool fwpatcher(int mode) src.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "new.hex"), gv->stdpaths->GetUserDataDir().c_str()); - if(gv->curplat == "h100") + if(gv->curplat == wxT("h100")) dest.Printf(wxT("%s" PATH_SEP "ihp_100.hex"),gv->curdestdir.c_str()); - else if(gv->curplat == "h120") + else if(gv->curplat == wxT("h120")) dest.Printf(wxT("%s" PATH_SEP "ihp_120.hex"),gv->curdestdir.c_str()); - else if(gv->curplat == "h300") + else if(gv->curplat == wxT("h300")) dest.Printf(wxT("%s" PATH_SEP "H300.hex"),gv->curdestdir.c_str()); if(!wxRenameFile(src,dest)) diff --git a/rbutil/credits.h b/rbutil/credits.h index c01bb69dc5..afd506a03a 100644 --- a/rbutil/credits.h +++ b/rbutil/credits.h @@ -24,18 +24,18 @@ #define RBUTIL_FULLNAME "The Rockbox Utility" #define RBUTIL_VERSION "Version 0.3.0.0" -static const char* rbutil_developers[] = { - "Christi Alice Scarborough", - "Dave Chapman", - "Dominik Wenger", - "" +static const wxString rbutil_developers[] = { + wxT("Christi Alice Scarborough"), + wxT("Dave Chapman"), + wxT("Dominik Wenger"), + wxT("") }; #define RBUTIL_WEBSITE "http://www.rockbox.org/" -#define RBUTIL_COPYRIGHT "(C) 2005-6 The Rockbox Team\n" \ - "released under the GNU Public License v2" -#define RBUTIL_DESCRIPTION "Installer and housekeeping utility for " \ - "the Rockbox open source digital audio player firmware." +#define RBUTIL_COPYRIGHT wxT("(C) 2005-7 The Rockbox Team\n" \ + "released under the GNU Public License v2") +#define RBUTIL_DESCRIPTION wxT("Installer and housekeeping utility for " \ + "the Rockbox open source digital audio player firmware.") class AboutDlg: public wxDialog diff --git a/rbutil/installlog.cpp b/rbutil/installlog.cpp index e9dad794cb..4be4a97352 100644 --- a/rbutil/installlog.cpp +++ b/rbutil/installlog.cpp @@ -38,9 +38,9 @@ InstallLog::InstallLog(wxString logname, bool CreateLog) return; } - logfile->SetPath("/InstallLog"); - if (logfile->Exists("Version") && - logfile->Read("Version", 0l) != LOGFILE_VERSION ) + logfile->SetPath(wxT("/InstallLog")); + if (logfile->Exists(wxT("Version")) && + logfile->Read(wxT("Version"), 0l) != LOGFILE_VERSION ) { buf.Printf(_("Logfile version mismatch: %s"), logname.c_str() ); wxLogWarning(buf); @@ -48,7 +48,7 @@ InstallLog::InstallLog(wxString logname, bool CreateLog) return; } - logfile->Write("Version", LOGFILE_VERSION); + logfile->Write(wxT("Version"), LOGFILE_VERSION); dirtyflag = false; } @@ -105,12 +105,12 @@ unsigned int InstallLog::WriteFile(wxArrayString filepaths) wxArrayString* InstallLog::GetInstalledFiles() { - wxString curdir = ""; + wxString curdir = wxT(""); if (dirtyflag) return NULL; workingAS.Clear(); - EnumerateCurDir(""); + EnumerateCurDir(wxT("")); wxArrayString* out = new wxArrayString(workingAS); return out; @@ -129,8 +129,8 @@ void InstallLog::EnumerateCurDir(wxString curdir) contflag = logfile->GetFirstGroup(curname, dummy); while (contflag) { - buf.Printf("%s/%s", curdir.c_str(), curname.c_str() ); - buf2 = buf; buf2.Replace(wxT("/"), wxT(PATH_SEP)); + buf.Printf(wxT("%s/%s"), curdir.c_str(), curname.c_str() ); + buf2 = buf; buf2.Replace(wxT("/"), PATH_SEP); workingAS.Add(buf2); EnumerateCurDir(buf); contflag = logfile->GetNextGroup(curname, dummy); @@ -141,8 +141,8 @@ void InstallLog::EnumerateCurDir(wxString curdir) { if (curname != wxT(DIRECTORY_KLUDGE) ) { - buf.Printf("%s/%s", curdir.c_str(), curname.c_str() ); - buf2 = buf; buf2.Replace(wxT("/"), wxT(PATH_SEP)); + buf.Printf(wxT("%s/%s"), curdir.c_str(), curname.c_str() ); + buf2 = buf; buf2.Replace(wxT("/"), PATH_SEP); workingAS.Add(buf2); } contflag = logfile->GetNextEntry(curname, dummy); diff --git a/rbutil/irivertools.cpp b/rbutil/irivertools.cpp index a1c83ebd39..f993ce5e0a 100755 --- a/rbutil/irivertools.cpp +++ b/rbutil/irivertools.cpp @@ -170,11 +170,11 @@ bool mkboot(wxString infile, wxString outfile,wxString bootloader,int origin) /* end mkboot.c excerpt */ -int intable(wxString md5, struct sumpairs *table, int len) +int intable(char *md5, struct sumpairs *table, int len) { int i; for (i = 0; i < len; i++) { - if (md5.Cmp(table[i].unpatched) == 0) { + if (strncmp(md5, table[i].unpatched, 32) == 0) { return i; } } @@ -544,7 +544,7 @@ bool PatchFirmware(wxString firmware,wxString bootloader,int series, int table_e { wxString name1, name2, name3; - wxString md5sum_str; + char md5sum_str[32]; int i; struct sumpairs *sums; int origin; @@ -595,14 +595,14 @@ bool PatchFirmware(wxString firmware,wxString bootloader,int series, int table_e return false; } /* now md5sum it */ - if (!FileMD5(name3, &md5sum_str)) { + if (!FileMD5(name3, md5sum_str)) { ERR_DIALOG(wxT("Error in checksumming"),wxT("Checksumming Firmware")); wxRemoveFile(name1); wxRemoveFile(name2); wxRemoveFile(name3); return false; } - if (strncmp(sums[table_entry].patched, md5sum_str.c_str(), 32) == 0) { + if (strncmp(sums[table_entry].patched, md5sum_str, 32) == 0) { /* delete temp files */ wxRemoveFile(name1); wxRemoveFile(name2); diff --git a/rbutil/irivertools.h b/rbutil/irivertools.h index deae3f4006..9718f92d00 100755 --- a/rbutil/irivertools.h +++ b/rbutil/irivertools.h @@ -57,7 +57,7 @@ enum striptype /* protos for iriver.c */ -int intable(wxString md5, struct sumpairs *table, int len); +int intable(char *md5, struct sumpairs *table, int len); bool PatchFirmware(wxString firmware,wxString bootloader,int series, int table_entry); diff --git a/rbutil/md5sum.cpp b/rbutil/md5sum.cpp index 9c253beed2..e1c23c9867 100755 --- a/rbutil/md5sum.cpp +++ b/rbutil/md5sum.cpp @@ -268,20 +268,19 @@ void md5_finish( md5_context *ctx, uint8 digest[16] ) PUT_UINT32( ctx->state[3], digest, 12 ); } -int FileMD5(wxString name,wxString *md5) +int FileMD5(wxString name, char *md5) { int i, read; md5_context ctx; unsigned char md5sum[16]; unsigned char block[32768]; - char temp[255]; wxFile file; file.Open(name); if (!file.IsOpened()) { - ERR_DIALOG("Could not open patched firmware for checksum check", _("Open Firmware")); + ERR_DIALOG(wxT("Could not open patched firmware for checksum check"), wxT("Open Firmware")); return 0; } md5_starts(&ctx); @@ -293,8 +292,7 @@ int FileMD5(wxString name,wxString *md5) md5_finish(&ctx, md5sum); for (i = 0; i < 16; ++i) { - sprintf(temp + 2*i, "%02x", md5sum[i]); + sprintf(md5 + 2*i, "%02x", md5sum[i]); } - md5->Append(temp); return 1; } diff --git a/rbutil/md5sum.h b/rbutil/md5sum.h index 5cc894c0ea..f7ea439b6f 100755 --- a/rbutil/md5sum.h +++ b/rbutil/md5sum.h @@ -46,6 +46,6 @@ void md5_starts( md5_context *ctx ); void md5_update( md5_context *ctx, uint8 *input, uint32 length ); void md5_finish( md5_context *ctx, uint8 digest[16] ); -int FileMD5(wxString name,wxString *md5); +int FileMD5(wxString name, char *md5); #endif // MD5SUM_H_INCLUDED diff --git a/rbutil/rbutil.cpp b/rbutil/rbutil.cpp index 78203ad67f..1663725fbb 100644 --- a/rbutil/rbutil.cpp +++ b/rbutil/rbutil.cpp @@ -488,14 +488,14 @@ int Uninstall(const wxString dir, bool isFullUninstall) { // If we're running on the device, let's not delete our own // installation, eh? if (gv->portable && - FilesToRemove->Item(i).StartsWith(wxT(PATH_SEP - "RockboxUtility")) ) + FilesToRemove->Item(i).StartsWith(PATH_SEP + wxT("RockboxUtility")) ) { continue; } wxString* buf2 = new wxString; - buf.Printf("%s%s", dir.c_str() , FilesToRemove->Item(i).c_str() ); + buf.Printf(wxT("%s%s"), dir.c_str() , FilesToRemove->Item(i).c_str() ); buf2->Format(wxT("Deleting %s"), buf.c_str()); if (! progress->Update((i + 1) * 100 / totalfiles, *buf2) ) diff --git a/rbutil/rbutilApp.cpp b/rbutil/rbutilApp.cpp index 436e4ca0cb..091dbafbe6 100644 --- a/rbutil/rbutilApp.cpp +++ b/rbutil/rbutilApp.cpp @@ -53,8 +53,8 @@ bool rbutilFrmApp::OnInit() } } - buf += wxT(PATH_SEP "rbutil.log"); - gv->logfile = new wxFFile(buf, "w"); + buf += PATH_SEP wxT("rbutil.log"); + gv->logfile = new wxFFile(buf, wxT("w")); if (! gv->logfile->IsOpened() ) wxLogFatalError(wxT("Unable to open log file")); diff --git a/rbutil/rbutilFrm.cpp b/rbutil/rbutilFrm.cpp index 35c34e8dc2..fe92f2bb60 100644 --- a/rbutil/rbutilFrm.cpp +++ b/rbutil/rbutilFrm.cpp @@ -271,7 +271,7 @@ void rbutilFrm::OnFileWipeCache(wxCommandEvent& event) wxString cacheloc, datadir; datadir = gv->stdpaths->GetUserDataDir(); - if (datadir == "") + if (datadir == wxT("")) { ERR_DIALOG(wxT("Can't locate user data directory. Unable to delete " "cache."), wxT("Delete download cache.") ); @@ -284,7 +284,7 @@ void rbutilFrm::OnFileWipeCache(wxCommandEvent& event) if (! rm_rf(cacheloc) ) { wxMessageDialog* msg = new wxMessageDialog(this, wxT("Local download cache has been deleted.") - ,"Cache deletion", wxOK |wxICON_INFORMATION); + , wxT("Cache deletion"), wxOK |wxICON_INFORMATION); msg->ShowModal(); delete msg; } @@ -542,7 +542,7 @@ void rbutilFrm::OnInstallBtn(wxCommandEvent& event) if (DownloadURL(gv->server_conf_url, dest)) { WARN_DIALOG(wxT("Unable to download build status."), wxT("Install")); - buf = ""; + buf = wxT(""); } else { buildinfo = new wxFileConfig(wxEmptyString, @@ -557,7 +557,7 @@ void rbutilFrm::OnInstallBtn(wxCommandEvent& event) } } - if (buf == "") { + if (buf == wxT("")) { WARN_DIALOG(wxT("Can't get date of latest build from " "server. Using yesterday's date."), wxT("Install") ); date = wxDateTime::Now(); @@ -657,7 +657,7 @@ void rbutilFrm::OnFontBtn(wxCommandEvent& event) { WARN_DIALOG(wxT("Unable to download build status."), wxT("Font Install")); - buf = ""; + buf = wxT(""); } else { buildinfo = new wxFileConfig(wxEmptyString, @@ -668,11 +668,11 @@ void rbutilFrm::OnFontBtn(wxCommandEvent& event) if (buf.Len() != 8) { dest.Printf(wxT("Invalid build date: %s"), buf.c_str()); WARN_DIALOG(dest, wxT("Font Install")); - buf = ""; + buf = wxT(""); } } - if (buf == "") { + if (buf == wxT("")) { WARN_DIALOG(wxT("Can't get date of latest build from " "server. Using yesterday's date."), wxT("Font Install") ); @@ -880,7 +880,7 @@ AboutDlg::AboutDlg(rbutilFrm* parent) wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY); long i = 0; - while ( rbutil_developers[i] != "") + while ( rbutil_developers[i] != wxT("")) { WxTextCtrl1->AppendText(rbutil_developers[i++]); WxTextCtrl1->AppendText(wxT("\n")); diff --git a/rbutil/wizard_pages.cpp b/rbutil/wizard_pages.cpp index 4ef463a2ec..10a511de47 100644 --- a/rbutil/wizard_pages.cpp +++ b/rbutil/wizard_pages.cpp @@ -145,6 +145,7 @@ bool wxPlatformPage::TransferDataFromWindow() //////////////// ThemeImage Dialog ///////////////// BEGIN_EVENT_TABLE(wxThemeImageDialog,wxDialog) EVT_PAINT(wxThemeImageDialog::OnPaint) + EVT_CLOSE(wxThemeImageDialog::OnClose) END_EVENT_TABLE(); wxThemeImageDialog::wxThemeImageDialog(wxWindow* parent,wxWindowID id,wxString title,wxBitmap bmp) : wxDialog(parent, id, title) @@ -152,7 +153,7 @@ wxThemeImageDialog::wxThemeImageDialog(wxWindow* parent,wxWindowID id,wxString t wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL); m_bitmap = bmp; - sizerTop->SetMinSize(m_bitmap.GetWidth(),m_bitmap.GetHeight()); + sizerTop->SetMinSize(64,64); SetSizer(sizerTop); @@ -161,6 +162,21 @@ wxThemeImageDialog::wxThemeImageDialog(wxWindow* parent,wxWindowID id,wxString t } +void wxThemeImageDialog::OnClose(wxCloseEvent& event) +{ + event.Veto(); + this->Show(false); +} + +void wxThemeImageDialog::SetImage(wxBitmap bmp) +{ + m_bitmap = bmp; + this->GetSizer()->SetMinSize(m_bitmap.GetWidth(),m_bitmap.GetHeight()); + this->GetSizer()->Fit(this); + Layout(); + Refresh(); +} + void wxThemeImageDialog::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc( this ); @@ -179,6 +195,10 @@ END_EVENT_TABLE(); wxThemesPage::wxThemesPage(wxWizard *parent) : wxWizardPageSimple(parent) { m_parent = parent; + + myImageDialog = new wxThemeImageDialog(this,wxID_ANY,wxT("Preview"),NULL); + myImageDialog->Show(false); + wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL); wxStaticText* WxStaticText1 = new wxStaticText(this, wxID_ANY, @@ -189,7 +209,7 @@ wxThemesPage::wxThemesPage(wxWizard *parent) : wxWizardPageSimple(parent) // create theme listbox wxArrayString list; for(int i = 0; i< 35;i++) - list.Add(""); + list.Add(wxT("")); ThemesListBox= new wxListBox(this, ID_LISTBOX, wxDefaultPosition, wxDefaultSize,list, wxLB_SINGLE); mainSizer->Add(ThemesListBox,10,wxGROW | wxALL,5); @@ -289,6 +309,35 @@ void wxThemesPage::OnListBox(wxCommandEvent& event) this->GetSizer()->Layout(); + if(myImageDialog->IsShown()) + { + wxString src,dest; + + int pos = m_Themes_image[index].Find('/',true); + wxString filename = m_Themes_image[index](pos+1,m_Themes_image[index].Length()); + + dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s"), + gv->stdpaths->GetUserDataDir().c_str(),gv->curresolution.c_str()); + + if(!wxDirExists(dest)) + wxMkdir(dest); + + //this is a URL no PATH_SEP + src.Printf("%s/data/%s/%s",gv->themes_url.c_str(),gv->curresolution.c_str(),filename.c_str()); + dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s" PATH_SEP "%s"), + gv->stdpaths->GetUserDataDir().c_str(),gv->curresolution.c_str(),filename.c_str()); + + if(DownloadURL(src, dest)) + { + MESG_DIALOG(wxT("Unable to download image.")); + return; + } + + wxBitmap bmp; + bmp.LoadFile(dest,wxBITMAP_TYPE_PNG); + myImageDialog->SetImage(bmp); + } + } void wxThemesPage::OnPreviewBtn(wxCommandEvent& event) @@ -310,7 +359,7 @@ void wxThemesPage::OnPreviewBtn(wxCommandEvent& event) wxMkdir(dest); //this is a URL no PATH_SEP - src.Printf("%s/data/%s/%s",gv->themes_url.c_str(),gv->curresolution.c_str(),filename.c_str()); + src.Printf(wxT("%s/data/%s/%s"),gv->themes_url.c_str(),gv->curresolution.c_str(),filename.c_str()); dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s" PATH_SEP "%s"), gv->stdpaths->GetUserDataDir().c_str(),gv->curresolution.c_str(),filename.c_str()); @@ -323,8 +372,9 @@ void wxThemesPage::OnPreviewBtn(wxCommandEvent& event) wxBitmap bmp; bmp.LoadFile(dest,wxBITMAP_TYPE_PNG); - wxThemeImageDialog dlg(this,wxID_ANY,wxT("Preview"),bmp); - dlg.ShowModal(); + myImageDialog->SetImage(bmp); + + myImageDialog->Show(true); } @@ -344,7 +394,7 @@ void wxThemesPage::OnPageShown(wxWizardEvent& event) //get correct Themes list wxString src,dest,err; - src.Printf("%srbutil.php?res=%s",gv->themes_url.c_str(),gv->curresolution.c_str()); + src.Printf(wxT("%srbutil.php?res=%s"),gv->themes_url.c_str(),gv->curresolution.c_str()); dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s.list"), gv->stdpaths->GetUserDataDir().c_str(),gv->curresolution.c_str()); @@ -419,7 +469,7 @@ wxIpodLocationPage::wxIpodLocationPage(wxWizard* parent) : wxWizardPageSimple(pa WxBoxSizer1->Add(WxBoxSizer3,0, wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 5); - IpodLocationText = new wxStaticText(this, wxID_ANY, "", + IpodLocationText = new wxStaticText(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT); WxBoxSizer3->Add(IpodLocationText,1, wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 5); @@ -477,8 +527,8 @@ void wxIpodLocationPage::OnIpodLocationBtn(wxCommandEvent& event) else if( n==1) { gv->curbootloader=wxT("bootloader-"); - gv->curbootloader.Append(ipod.targetname); - IpodLocationText->SetLabel(ipod.modelstr); + gv->curbootloader.Append(wxString(ipod.targetname, wxConvUTF8)); + IpodLocationText->SetLabel(wxString(ipod.modelstr, wxConvUTF8)); } else IpodLocationText->SetLabel(wxT("More than 1 Ipod found")); @@ -571,7 +621,7 @@ void wxBootLocationPage::OnPageShown(wxWizardEvent& event) } else { - BootLocationInfo->SetLabel(""); + BootLocationInfo->SetLabel(wxT("")); } } @@ -667,7 +717,7 @@ void wxFirmwareLocationPage::OnWizardPageChanging(wxWizardEvent& event) void wxFirmwareLocationPage::OnFirmwareFilenameBtn(wxCommandEvent& event) { wxString temp = wxFileSelector( - wxT("Please select the location of the original Firmware"), gv->curdestdir,"","","*.hex"); + wxT("Please select the location of the original Firmware"), gv->curdestdir,wxT(""),wxT(""),wxT("*.hex")); wxLogVerbose(wxT("=== begin wxFirmwareLocationPage::OnFirmwareFilenameBtn(event)")); if (!temp.empty()) { @@ -675,7 +725,7 @@ void wxFirmwareLocationPage::OnFirmwareFilenameBtn(wxCommandEvent& event) if(temp.Length() > 30) { temp.Remove(0, temp.Length()-30); - temp.Prepend("..."); + temp.Prepend(wxT("...")); } FirmwareLocationFilename->SetLabel(temp); } @@ -737,7 +787,7 @@ void wxLocationPage::OnPageShown(wxWizardEvent& event) } else { - LocationInfo->SetLabel(""); + LocationInfo->SetLabel(wxT("")); } diff --git a/rbutil/wizard_pages.h b/rbutil/wizard_pages.h index 70041bd2f7..f08d29d315 100644 --- a/rbutil/wizard_pages.h +++ b/rbutil/wizard_pages.h @@ -34,6 +34,8 @@ private: public: wxThemeImageDialog(wxWindow* parent,wxWindowID id,wxString title,wxBitmap bmp); void OnPaint(wxPaintEvent& WXUNUSED(event)); + void SetImage(wxBitmap bmp); + void OnClose(wxCloseEvent& event); private: wxBitmap m_bitmap; @@ -68,6 +70,7 @@ public: wxStaticText* m_desc; wxStaticText* m_size; wxCheckBox* m_InstallCheckBox; + wxThemeImageDialog* myImageDialog; wxArrayString m_Themes; wxArrayString m_Themes_path; |