diff --git a/bazaar/Updater/Updater.cpp b/bazaar/Updater/Updater.cpp index 038bb0223..e5ba79b89 100644 --- a/bazaar/Updater/Updater.cpp +++ b/bazaar/Updater/Updater.cpp @@ -9,7 +9,10 @@ #define IMAGEFILE #include -NAMESPACE_UPP +#define TFILE +#include + + NAMESPACE_UPP // gets platform root folder String Updater::GetPlatformRoot(void) @@ -90,6 +93,11 @@ Updater::Updater() // no desktop icon installation by default desktopIcon = false; + + // setup default user choices on errors + installBehaviour = AbortExecution; + noInstallBehaviour = AbortExecution; + updateBehaviour = AskUser; } // sets applicaton name (defaults with current executable title if not used) @@ -233,7 +241,7 @@ bool Updater::START_Updater(String const &operation) // returns true if app must continue execution, false otherwise bool Updater::START_Uninstall(void) { - if(confirmUninstall && !PromptYesNo(t_("This will remove '") + appName + t_("' application&Continue ?"))) + if(confirmUninstall && !PromptYesNo(Format(t_("This will remove '%s' application&Continue ?"), appName))) { state = UninstallAborted; return true; @@ -250,7 +258,7 @@ bool Updater::START_Uninstall(void) // returns true if app must continue execution, false otherwise bool Updater::START_Install(void) { - if(confirmInstall && !PromptYesNo(t_("Install '") + appName + t_("' application?"))) + if(confirmInstall && !PromptYesNo(Format(t_("Install '%s' application?"), appName))) { state = InstallAborted; return true; @@ -311,7 +319,7 @@ bool Updater::DO_NormalRun(void) // if we want manual updates, just ask if(updateMode == "ASK") - if(!PromptYesNo(t_("New version ") + maxVer.ToString() + t_(" is available&Install it ?"))) + if(!PromptYesNo(Format(t_("New version '%s' is available&Install it ?"), maxVer.ToString()))) return true; // updater enabled, start it @@ -685,30 +693,72 @@ bool Updater::DefaultPrompts(void) switch(GetState()) { case UninstallFailed: - Exclamation(t_("Uninstall of '") + appName + t_("' failed&Press OK to quit")); + Exclamation(Format(t_("Uninstall of '%s' failed&Press OK to quit"), appName)); return false; case UninstallSucceeded: - PromptOK(t_("Uninstall of '") + appName + t_("' complete&Press OK to quit")); + PromptOK(Format(t_("Uninstall of '%s' complete&Press OK to quit"), appName)); return false; case UninstallAborted: return false ; - case InstallFailed: - if(!PromptYesNo(t_("Install of '") + appName + t_("' failed&Run without installing?"))) - return false; + case InstallFailed: + switch(installBehaviour) + { + case AskUser : + if(!PromptYesNo(Format(t_("Install of '%s' failed&Run without installing?"), appName))) + return false; + break; + case AbortExecution: + Exclamation(Format(t_("Install of '%s' failed"), appName)); + return false; + case ContinueExecution: + Exclamation(Format(t_("Install of '%s' failed&press OK to run uninstalled"), appName)); + return true; + default: + return false; + } return true; case InstallSucceeded: return true; case InstallAborted: - return false; + switch(installBehaviour) + { + case AskUser : + if(!PromptYesNo(Format(t_("Install of '%s' aborted&Run without installing?"), appName))) + return false; + break; + case AbortExecution: + Exclamation(Format(t_("Install of '%s' aborted"), appName)); + return false; + case ContinueExecution: + Exclamation(Format(t_("Install of '%s' aborted&press OK to run uninstalled"), appName)); + return true; + default: + return false; + } + return true; + case UpdateFailed: - if(!PromptYesNo(t_("Update of '") + appName + t_("' failed&Run anyways?"))) - return false; + switch(updateBehaviour) + { + case AskUser: + if(!PromptYesNo(Format(t_("Update of '%s' failed&Run current version?"), appName))) + return false; + break; + case AbortExecution: + Exclamation(Format(t_("Update of '%s' failed"), appName)); + return false; + case ContinueExecution: + Exclamation(Format(t_("Update of '%s' failed&press OK to run current version"), appName)); + return true; + default: + return true; + } return true; case UpdateSucceeded: diff --git a/bazaar/Updater/Updater.h b/bazaar/Updater/Updater.h index 69c74cb6e..2efdca3b3 100644 --- a/bazaar/Updater/Updater.h +++ b/bazaar/Updater/Updater.h @@ -21,6 +21,9 @@ class Updater UninstallSucceeded, InstallSucceeded, UpdateSucceeded, UninstallAborted, InstallAborted } UpdaterState; + + // choices on error conditions + typedef enum { AbortExecution, AskUser, ContinueExecution } ErrorBehaviours; private: // state of updater engine @@ -125,6 +128,11 @@ class Updater // flag for desktop icon install bool desktopIcon; + // user's choices on how to handle error contidions + ErrorBehaviours installBehaviour; + ErrorBehaviours noInstallBehaviour; + ErrorBehaviours updateBehaviour; + #ifdef PLATFORM_POSIX // scans for theme folders on which put/delete the mimetype icons // that's needed because if themed icons aren't available, the system @@ -239,6 +247,11 @@ class Updater // desktop icon Updater &DesktopIcon(void) { desktopIcon = true; return *this; } Updater &NoDesktopIcon(void) { desktopIcon = false; return *this; } + + // sets behaviours on failures + Updater &SetInstallBehaviour(ErrorBehaviours b) { installBehaviour = b; return *this; } + Updater &SetNoInstallBehaviour(ErrorBehaviours b) { noInstallBehaviour = b; return *this; } + Updater &SetUpdateBehaviour(ErrorBehaviours b) { updateBehaviour = b; return *this; } }; diff --git a/bazaar/Updater/Updater.t b/bazaar/Updater/Updater.t new file mode 100644 index 000000000..7a53e9ff0 --- /dev/null +++ b/bazaar/Updater/Updater.t @@ -0,0 +1,54 @@ +#ifdef _MSC_VER +#pragma setlocale("C") +#endif +// Updater.cpp + +T_("This will remove '%s' application&Continue ?") +itIT("L'applicazione '%s' verr\303\240 rimossa&Continuare ?") + +T_("Install '%s' application?") +itIT("Installare l'applicazione '%s' ^") + +T_("New version '%s' is available&Install it ?") +itIT("E' disponibile la nuova versione '%s'&Eseguire l'aggiornamento?") + +T_("Downloading application.... please wait") +itIT("Scaricamento applicazione in corso....attendere prego") + +T_("Uninstall of '%s' failed&Press OK to quit") +itIT("Rimozione di '%s' fallita&Premere OK per uscire") + +T_("Uninstall of '%s' complete&Press OK to quit") +itIT("Rimozione di '%s' completata&Premere OK per uscire") + +T_("Install of '%s' failed&Run without installing?") +itIT("Installazione di '%s' fallita&Continuare l'esecuzione senza installare" + "?") + +T_("Install of '%s' failed") +itIT("Installazione di '%s' fallita") + +T_("Install of '%s' failed&press OK to run uninstalled") +itIT("Installazione di '%s' fallita&Premere OK per eseguire l'applicazione s" + "enza installare") + +T_("Install of '%s' aborted&Run without installing?") +itIT("Installazione di '%s' annullata&Continuare l'esecuzione senza installa" + "re?") + +T_("Install of '%s' aborted") +itIT("Installazione di '%s' annullata") + +T_("Install of '%s' aborted&press OK to run uninstalled") +itIT("Installazione di '%s' annullata&Premere OK per eseguire l'applicazione" + " senza installare") + +T_("Update of '%s' failed&Run current version?") +itIT("Aggiornamento di '%s' fallito&Eseguire la versione attuale?") + +T_("Update of '%s' failed") +itIT("Aggiornamento di '%s' fallito") + +T_("Update of '%s' failed&press OK to run current version") +itIT("Aggiornamento di '%s' fallito&Premere OK per eseguire la versione attu" + "ale") diff --git a/bazaar/Updater/Updater.upp b/bazaar/Updater/Updater.upp index f93cef428..3a8f18b80 100644 --- a/bazaar/Updater/Updater.upp +++ b/bazaar/Updater/Updater.upp @@ -8,6 +8,7 @@ uses ProductVersion; file + Updater.t, Updater.iml, Windows.cpp, Posix.cpp,