From d113e427853cf467da92e0fb3101d8903f17d478 Mon Sep 17 00:00:00 2001 From: micio Date: Wed, 26 Jan 2011 15:14:59 +0000 Subject: [PATCH] Bazaar/Updater : allow setting of installed application name Now it can be different from installer executable name git-svn-id: svn://ultimatepp.org/upp/trunk@3104 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- bazaar/Updater/Updater.cpp | 49 ++++++++++++++++++++++++-------------- bazaar/Updater/Updater.h | 5 ++++ 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/bazaar/Updater/Updater.cpp b/bazaar/Updater/Updater.cpp index 23238008f..b9aef0943 100644 --- a/bazaar/Updater/Updater.cpp +++ b/bazaar/Updater/Updater.cpp @@ -81,6 +81,24 @@ Updater::Updater() else appName = GetExeTitle(); // fallout -- should NEVER get here + // setup appName depending fields + SetAppName(appName); + + // sets default confirm for install and uninstall + confirmInstall = true; + confirmUninstall = true; + + // no desktop icon installation by default + desktopIcon = false; +} + +// sets applicaton name (defaults with current executable title if not used) +// allows easy separation of installer from main application code +// if you want to deploy a small installer +Updater &Updater::SetAppName(String const &_appName) +{ + appName = _appName; + // gets app's user config path #ifdef PLATFORM_POSIX userConfigPath = "/home/" + user + "/." + appName + "/"; @@ -110,21 +128,9 @@ Updater::Updater() if(verStr != "") installedVersion = verStr; } + + return *this; - // create user config path only on normal run - if(state == NormalRun) - RealizePath(userConfigPath); - - // creates system config path on superuser mode - if(state == InsideUpdater) - RealizePath(systemConfigPath); - - // sets default confirm for install and uninstall - confirmInstall = true; - confirmUninstall = true; - - // no desktop icon installation by default - desktopIcon = false; } /////////////////////////////////////////////////////////////////////////////////////// @@ -299,13 +305,13 @@ bool Updater::DO_NormalRun(void) return true; // if we don't have a new version available, just do nothing - double maxVer; + ProgramVersion maxVer; if( (maxVer = FetchMaxValidVersion(acceptDevelVersions)) <= installedVersion) return true; // if we want manual updates, just ask if(updateMode == "ASK") - if(!PromptYesNo(t_("New version ") + FormatDoubleFix(maxVer, 2, FD_ZERO) + t_(" is available&Install it ?"))) + if(!PromptYesNo(t_("New version ") + maxVer.ToString() + t_(" is available&Install it ?"))) return true; // updater enabled, start it @@ -600,8 +606,7 @@ bool Updater::FetchApp(ProgramVersion ver, bool devel) #endif // stores current version inside system config path - String verStr = FormatDoubleFix(ver, 2, FD_ZERO); - if(!SaveFile(systemConfigPath + "version", verStr)) + if(!SaveFile(systemConfigPath + "version", ver.ToString())) return false; installedVersion = ver; @@ -616,6 +621,14 @@ bool Updater::FetchApp(ProgramVersion ver, bool devel) // te SELF_UPDATE() macro does all what is needed bool Updater::Run() { + // create user config path only on normal run + if(state == NormalRun) + RealizePath(userConfigPath); + + // creates system config path on superuser mode + if(state == InsideUpdater) + RealizePath(systemConfigPath); + switch(state) { case NormalRun : diff --git a/bazaar/Updater/Updater.h b/bazaar/Updater/Updater.h index 265e6fac5..69089c79f 100644 --- a/bazaar/Updater/Updater.h +++ b/bazaar/Updater/Updater.h @@ -258,6 +258,11 @@ class Updater // default icon Image DefaultIcon(void); + // sets applicaton name (defaults with current executable title if not used) + // allows easy separation of installer from main application code + // if you want to deploy a small installer + Updater &SetAppName(String const &appName); + // setup application icon Updater &SetIcon(Image const &i) { icon = i; return *this; }