summaryrefslogtreecommitdiffstats
path: root/rbutil
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/credits.h22
-rw-r--r--rbutil/rbutil.cpp102
-rw-r--r--rbutil/rbutil.h49
-rw-r--r--rbutil/rbutilApp.cpp78
-rw-r--r--rbutil/rbutilFrm.cpp81
-rw-r--r--rbutil/rbutilFrm.h29
6 files changed, 305 insertions, 56 deletions
diff --git a/rbutil/credits.h b/rbutil/credits.h
index 9e91675793..fe9bdb18f5 100644
--- a/rbutil/credits.h
+++ b/rbutil/credits.h
@@ -1,8 +1,28 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * Module: rbutil
+ * File: credits.h
+ *
+ * Copyright (C) 2006 Christi Alice Scarborough
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
#ifndef CREDITS_H_INCLUDED
#define CREDITS_H_INCLUDED
#define RBUTIL_FULLNAME "The Rockbox Utility"
-#define RBUTIL_VERSION "Version 0.2.0.0"
+#define RBUTIL_VERSION "Version 0.2.1.0"
static char* rbutil_developers[] = {
"Christi Alice Scarborough",
diff --git a/rbutil/rbutil.cpp b/rbutil/rbutil.cpp
index 332bb0a0ae..4344690d01 100644
--- a/rbutil/rbutil.cpp
+++ b/rbutil/rbutil.cpp
@@ -1,10 +1,22 @@
-//---------------------------------------------------------------------------
-//
-// Name: rbutil.cpp
-// Author: Christi Scarborough
-// Created: 06-12-05 04:08
-//
-//---------------------------------------------------------------------------
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * Module: rbutil
+ * File: rbutil.cpp
+ *
+ * Copyright (C) 2005 Christi Alice Scarborough
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
#include "rbutil.h"
@@ -526,6 +538,82 @@ wxString stream_err_str(int errnum)
return out;
}
+bool InstallRbutil(wxString dest)
+{
+ wxArrayString filestocopy;
+ wxString str, buf, dstr, destdir;
+ unsigned int i;
+ wxDir dir;
+ bool copied_exe = false;
+
+ destdir.Printf(wxT("%s" PATH_SEP "RockboxUtility"), dest.c_str());
+ if (! wxDirExists(destdir) )
+ {
+ if (! wxMkdir(destdir) )
+ {
+ buf.Printf(wxT("%s (%s)"),
+ _("Unable to create directory for installer"), destdir.c_str());
+ WARN_DIALOG(buf , _("Portable install") );
+ return false;
+ }
+ }
+
+ dir.GetAllFiles(gv->ResourceDir, &filestocopy, wxT("*"),
+ wxDIR_FILES);
+ if (filestocopy.GetCount() < 1)
+ {
+ WARN_DIALOG(_("No files to copy"), _("Portable install") );
+ return false;
+ }
+
+ // Copy the contents of the program directory
+ for (i = 0; i < filestocopy.GetCount(); i++)
+ {
+ if (filestocopy[i].AfterLast(PATH_SEP_CHR) == EXE_NAME)
+ {
+ copied_exe = true;
+ }
+
+ dstr.Printf(wxT("%s" PATH_SEP "%s"), destdir.c_str(),
+ filestocopy[i].AfterLast(PATH_SEP_CHR).c_str());
+ if (! wxCopyFile(filestocopy[i], dstr) )
+ {
+ buf.Printf(wxT("%s (%s -> %s)"),
+ _("Error copying file"), filestocopy[i].c_str(), dstr.c_str());
+ WARN_DIALOG(buf, _("Portable Install") );
+ return false;
+ }
+ }
+
+ if (! copied_exe)
+ {
+ str.Printf(wxT("%s" PATH_SEP EXE_NAME), gv->AppDir.c_str());
+ dstr.Printf(wxT("%s" PATH_SEP EXE_NAME), destdir.c_str(),
+ filestocopy[i].AfterLast(PATH_SEP_CHR).c_str());
+ if (! wxCopyFile(str, dstr) )
+ {
+ buf.Printf(wxT("Can't copy program binary %s -> %s"),
+ str.c_str(), dstr.c_str() );
+ WARN_DIALOG(buf, _("Portable Install") );
+ return false;
+ }
+ }
+
+ // Copy the local ini file so that it knows that it's a portable copy
+ gv->UserConfig->Flush();
+ dstr.Printf(wxT("%s" PATH_SEP "RockboxUtility.cfg"), destdir.c_str());
+ if (! wxCopyFile(gv->UserConfigFile, dstr) )
+ {
+ buf.Printf(wxT("%s (%s -> %s)"),
+ _("Unable to install user config file"), gv->UserConfigFile.c_str(),
+ dstr.c_str() );
+ WARN_DIALOG(buf, _("Portable Install") );
+ return false;
+ }
+
+ return true;
+}
+
bool rm_rf(wxString file)
{
wxLogVerbose(_("=== begin rm-rf(%s)"), file.c_str() );
diff --git a/rbutil/rbutil.h b/rbutil/rbutil.h
index 66e3392b77..fe8a8aaee8 100644
--- a/rbutil/rbutil.h
+++ b/rbutil/rbutil.h
@@ -1,10 +1,22 @@
-//---------------------------------------------------------------------------
-//
-// Name: rbutil.h
-// Author: Christi Scarborough
-// Created: 03/12/2005 00:35:02
-//
-//---------------------------------------------------------------------------
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * Module: rbutil
+ * File: rbutil.h
+ *
+ * Copyright (C) 2005 Christi Alice Scarborough
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
#include <wx/wxprec.h>
#ifdef __BORLANDC__
@@ -43,8 +55,12 @@
#ifdef __WXMSW__
#define PATH_SEP "\\"
+#define PATH_SEP_CHR '\\'
+#define EXE_NAME "rbutil.exe"
#else
#define PATH_SEP "/"
+#define PATH_SEP_CHR '/'
+#define EXE_NAME "rbutil"
#endif
#define UNINSTALL_FILE ".rockbox" PATH_SEP ".rbutil_install_data"
@@ -60,6 +76,11 @@ public:
// Program configuration data (rbutil.ini and environment)
wxFileConfig* GlobalConfig;
wxFileConfig* UserConfig;
+ wxString UserConfigFile;
+ wxString GlobalConfigFile;
+ wxString AppDir;
+ wxString ResourceDir;
+
wxString* ErrStr;
wxStandardPaths* stdpaths;
wxArrayString plat_id;
@@ -74,12 +95,13 @@ public:
wxString prog_name;
// User configuration data.
- wxString curplat;
- unsigned int curplatnum;
- wxString curdestdir;
- unsigned int curbuild;
- bool curisfull;
- bool nocache;
+ wxString curplat;
+ unsigned int curplatnum;
+ wxString curdestdir;
+ unsigned int curbuild;
+ bool curisfull;
+ bool nocache;
+ bool portable;
// Global system variables
wxFFile* logfile;
@@ -95,6 +117,7 @@ wxString wxFindAppPath(const wxString& argv0, const wxString& cwd,
int DownloadURL(wxString src, wxString dest);
int UnzipFile(wxString src, wxString destdir, bool isInstall = false);
int Uninstall(const wxString dir, bool isFullUninstall = false);
+bool InstallRbutil(wxString dest);
wxString stream_err_str(int errnum);
bool rm_rf(wxString file);
diff --git a/rbutil/rbutilApp.cpp b/rbutil/rbutilApp.cpp
index 971d2f428f..ef18af0d53 100644
--- a/rbutil/rbutilApp.cpp
+++ b/rbutil/rbutilApp.cpp
@@ -1,10 +1,22 @@
-//---------------------------------------------------------------------------
-//
-// Name: rbutilApp.cpp
-// Author: Christi Scarborough
-// Created: 03/12/2005 00:35:02
-//
-//---------------------------------------------------------------------------
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * Module: rbutil
+ * File: rbutilApp.cpp
+ *
+ * Copyright (C) 2005 Christi Alice Scarborough
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
#include "rbutilApp.h"
@@ -19,6 +31,15 @@ bool rbutilFrmApp::OnInit()
wxLogVerbose(wxT("=== begin rbutilFrmApp::Oninit()"));
gv->stdpaths = new wxStandardPaths();
+
+ // Get application directory
+ // DANGER! GetDataDir() doesn't portably return the application directory
+ // We want to use the form below instead, but not until wxWidgets 2.8 is
+ // released.
+ // gv->AppDir = gv->stdpaths->GetExecutablePath()->BeforeLast(&pathsep);
+ buf = gv->stdpaths->GetDataDir(); buf.Append(PATH_SEP);
+ gv->AppDir = buf.BeforeLast(PATH_SEP_CHR).c_str();
+
buf = gv->stdpaths->GetUserDataDir();
if (! wxDirExists(buf) )
{
@@ -48,17 +69,15 @@ bool rbutilFrmApp::OnInit()
wxFileSystem::AddHandler(new wxInternetFSHandler);
wxFileSystem::AddHandler(new wxZipFSHandler);
- rbutilFrm *myFrame = new rbutilFrm(NULL);
- SetTopWindow(myFrame);
-
- if (!ReadGlobalConfig(myFrame))
+ if (!ReadGlobalConfig(NULL))
{
ERR_DIALOG(gv->ErrStr->GetData(), _("Rockbox Utility"));
return FALSE;
}
-
ReadUserConfig();
+ rbutilFrm *myFrame = new rbutilFrm(NULL);
+ SetTopWindow(myFrame);
myFrame->Show(TRUE);
wxLogVerbose(wxT("=== end rbUtilFrmApp::OnInit()"));
@@ -96,8 +115,21 @@ bool rbutilFrmApp::ReadGlobalConfig(rbutilFrm* myFrame)
wxLogVerbose(wxT("=== begin rbutilFrmApp::ReadGlobalConfig(%p)"),
(void*) myFrame);
- buf.Printf(wxT("%s" PATH_SEP "rbutil.ini"),
- gv->stdpaths->GetDataDir().c_str() );
+ // Cross-platform compatibility: look for rbutil.ini in the same dir as the
+ // executable before trying the standard data directory. On Windows these
+ // are of course the same directory.
+ buf.Printf(wxT("%s" PATH_SEP "rbutil.ini"), gv->AppDir.c_str() );
+
+ if (! wxFileExists(buf) )
+ {
+ gv->ResourceDir = gv->stdpaths->GetResourcesDir();
+ buf.Printf(wxT("%s" PATH_SEP "rbutil.ini"),
+ gv->ResourceDir.c_str() );
+ } else
+ {
+ gv->ResourceDir = gv->AppDir;
+ }
+
wxFileInputStream* cfgis = new wxFileInputStream(buf);
if (!cfgis->CanRead()) {
@@ -106,6 +138,7 @@ bool rbutilFrmApp::ReadGlobalConfig(rbutilFrm* myFrame)
}
gv->GlobalConfig = new wxFileConfig(*cfgis);
+ gv->GlobalConfigFile = buf;
unsigned int i = 0;
@@ -167,9 +200,22 @@ void rbutilFrmApp::ReadUserConfig()
{
wxString buf, str, stack;
- buf.Printf(wxT("%s" PATH_SEP "%s"), gv->stdpaths->GetUserDataDir().c_str(),
- wxT("RockboxUtility.cfg"));
+ buf.Printf(wxT("%s" PATH_SEP "RockboxUtility.cfg"),
+ gv->AppDir.c_str());
+
+ if (wxFileExists(buf) )
+ {
+ gv->portable = true;
+ }
+ else
+ {
+ gv->portable = false;
+ buf.Printf(wxT("%s" PATH_SEP "%s"),
+ gv->stdpaths->GetUserDataDir().c_str(), wxT("RockboxUtility.cfg"));
+ }
+
gv->UserConfig = new wxFileConfig(wxEmptyString, wxEmptyString, buf);
+ gv->UserConfigFile = buf;
stack = gv->UserConfig->GetPath();
gv->UserConfig->SetPath(wxT("/defaults"));
diff --git a/rbutil/rbutilFrm.cpp b/rbutil/rbutilFrm.cpp
index 81798fe552..09e94a04b3 100644
--- a/rbutil/rbutilFrm.cpp
+++ b/rbutil/rbutilFrm.cpp
@@ -1,10 +1,22 @@
-//---------------------------------------------------------------------------
-//
-// Name: rbutilFrm.cpp
-// Author: Christi Scarborough
-// Created: 03/12/2005 00:35:02
-//
-//---------------------------------------------------------------------------
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * Module: rbutil
+ * File: rbutilFrm.cpp
+ *
+ * Copyright (C) 2005 Christi Alice Scarborough
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
#include "rbutilFrm.h"
#include "credits.h"
@@ -32,6 +44,7 @@ BEGIN_EVENT_TABLE(rbutilFrm,wxFrame)
EVT_MENU(ID_FILE_EXIT, rbutilFrm::OnFileExit)
EVT_MENU(ID_FILE_ABOUT, rbutilFrm::OnFileAbout)
EVT_MENU(ID_FILE_WIPECACHE, rbutilFrm::OnFileWipeCache)
+ EVT_MENU(ID_PORTABLE_INSTALL, rbutilFrm::OnPortableInstall)
END_EVENT_TABLE()
rbutilFrm::rbutilFrm( wxWindow *parent, wxWindowID id, const wxString &title,
@@ -77,7 +90,7 @@ void rbutilFrm::CreateGUIControls(void)
wxBitmap BootloaderInstallButton (tools2_3d_xpm);
WxBitmapButton4 = new wxBitmapButton(WxPanel1, ID_BOOTLOADER_BTN,
- BootloaderInstallButton, wxPoint(0,50), wxSize(60,50),
+ BootloaderInstallButton, wxPoint(0,0), wxSize(64,54),
wxRAISED_BORDER | wxBU_AUTODRAW);
WxBitmapButton4->SetToolTip(_("Instructions for installing the "
"Rockbox bootloader on your audio device"));
@@ -95,7 +108,7 @@ void rbutilFrm::CreateGUIControls(void)
wxBitmap WxBitmapButton1_BITMAP (install_3d_xpm);
WxBitmapButton1 = new wxBitmapButton(WxPanel1, ID_INSTALL_BTN,
- WxBitmapButton1_BITMAP, wxPoint(0,0), wxSize(60,50),
+ WxBitmapButton1_BITMAP, wxPoint(0,0), wxSize(64,54),
wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
wxT("WxBitmapButton1"));
WxBitmapButton1->SetToolTip(_("Install Rockbox"));
@@ -110,7 +123,7 @@ void rbutilFrm::CreateGUIControls(void)
wxBitmap FontInstallButton (fonts_3d_xpm);
WxBitmapButton3 = new wxBitmapButton(WxPanel1, ID_FONT_BTN,
- FontInstallButton, wxPoint(0,50), wxSize(60,50),
+ FontInstallButton, wxPoint(0,0), wxSize(64,54),
wxRAISED_BORDER | wxBU_AUTODRAW);
WxBitmapButton3->SetToolTip(_("Download the most up to date "
"Rockbox fonts."));
@@ -128,7 +141,7 @@ void rbutilFrm::CreateGUIControls(void)
wxBitmap WxBitmapButton2_BITMAP (uninstall_3d_xpm);
WxBitmapButton2 = new wxBitmapButton(WxPanel1, ID_REMOVE_BTN,
- WxBitmapButton2_BITMAP, wxPoint(0,50), wxSize(60,50),
+ WxBitmapButton2_BITMAP, wxPoint(0,0), wxSize(64,54),
wxRAISED_BORDER | wxBU_AUTODRAW, wxDefaultValidator,
wxT("WxBitmapButton2"));
WxBitmapButton2->SetToolTip(_("Uninstall Rockbox"));
@@ -147,6 +160,11 @@ void rbutilFrm::CreateGUIControls(void)
ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_WIPECACHE,
_("&Empty local download cache"), wxT(""), wxITEM_NORMAL);
+ if (! gv->portable )
+ {
+ ID_FILE_MENU_Mnu_Obj->Append(ID_PORTABLE_INSTALL,
+ _("&Install Rockbox Utility on device"), wxT(""), wxITEM_NORMAL);
+ }
ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_ABOUT, _("&About"), wxT(""),
wxITEM_NORMAL);
ID_FILE_MENU_Mnu_Obj->Append(ID_FILE_EXIT, _("E&xit\tCtrl+X"), wxT(""),
@@ -156,7 +174,13 @@ void rbutilFrm::CreateGUIControls(void)
GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this);
- this->SetTitle(wxT("Rockbox Utility"));
+ if (gv->portable)
+ {
+ this->SetTitle(_("Rockbox Utility (portable)"));
+ } else
+ {
+ this->SetTitle(_("Rockbox Utility"));
+ }
this->Center();
wxIcon rbutilFrm_ICON (rbutilFrm_XPM);
this->SetIcon(rbutilFrm_XPM);
@@ -490,6 +514,39 @@ void rbutilFrm::OnRemoveBtn(wxCommandEvent& event)
wxLogVerbose("=== end rbutilFrm::OnRemoveBtn");
}
+void rbutilFrm::OnPortableInstall(wxCommandEvent& event)
+{
+ wxString src, dest, buf;
+ wxLogVerbose("=== begin rbutilFrm::OnPortableInstall(event)");
+ wxFileSystem fs;
+ wxFileConfig* buildinfo;
+ wxDateSpan oneday;
+
+ wxWizard *wizard = new wxWizard(this, wxID_ANY,
+ _("Rockbox Utility Portable Installation Wizard"),
+ wxBitmap(wizard_xpm),
+ wxDefaultPosition,
+ wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
+ wxLocationPage* page1 = new wxLocationPage(wizard);
+
+ wizard->GetPageAreaSizer()->Add(page1);
+
+ if (wizard->RunWizard(page1) )
+ {
+ if ( InstallRbutil(gv->curdestdir) )
+ {
+ MESG_DIALOG(_("The Rockbox Utility has been installed on your device.") );
+ } else
+ {
+ ERR_DIALOG(_("Installation failed"), _("Portable Install"));
+ }
+ } else
+ {
+ MESG_DIALOG(_("The portable installation wizard was cancelled") );
+ }
+
+ wxLogVerbose("=== end rbutilFrm::OnUnstallPortable");
+}
AboutDlg::AboutDlg(rbutilFrm* parent)
: wxDialog(parent, -1, _("About"), wxDefaultPosition, wxDefaultSize,
diff --git a/rbutil/rbutilFrm.h b/rbutil/rbutilFrm.h
index 7759e70f5e..8ba7361c84 100644
--- a/rbutil/rbutilFrm.h
+++ b/rbutil/rbutilFrm.h
@@ -1,10 +1,23 @@
-//---------------------------------------------------------------------------
-//
-// Name: rbutilFrm.h
-// Author: Christi Scarborough
-// Created: 03/12/2005 00:35:02
-//
-//---------------------------------------------------------------------------
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * Module: rbutil
+ * File: rbutilFrm.h
+ *
+ * Copyright (C) 2005 Christi Alice Scarborough
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
#ifndef __rbutilFrm_HPP_
#define __rbutilFrm_HPP_
@@ -60,6 +73,7 @@ public:
ID_FILE_EXIT = 1034,
ID_FILE_ABOUT = 1035,
ID_FILE_WIPECACHE = 1036,
+ ID_PORTABLE_INSTALL = 1037,
ID_WXSTATICTEXT3 = 1032,
ID_REMOVE_BTN = 1031,
@@ -83,6 +97,7 @@ public:
void OnRemoveBtn(wxCommandEvent& event);
void OnFontBtn(wxCommandEvent& event);
void OnBootloaderBtn(wxCommandEvent& event);
+ void OnPortableInstall(wxCommandEvent& event);
};