зеркало из https://github.com/mozilla/pjs.git
Failover implemented for i18n strings in XPInstall if the string bundle service is not available, fails, or if the .properties resource file is not avilable. Fixes install wizard logging. Completion of fix for bug 8140. [r=ssu]
This commit is contained in:
Родитель
98394f0040
Коммит
1082968752
|
@ -53,6 +53,7 @@
|
|||
#include "nsInstallExecute.h"
|
||||
#include "nsInstallPatch.h"
|
||||
#include "nsInstallUninstall.h"
|
||||
#include "nsInstallResources.h"
|
||||
#ifdef NECKO
|
||||
#include "nsNeckoUtil.h"
|
||||
#endif
|
||||
|
@ -2239,8 +2240,10 @@ nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedNa
|
|||
if ( nsAppleSingleDecoder::IsAppleSingleFile(&extractedSpec) )
|
||||
{
|
||||
nsAppleSingleDecoder *asd = new nsAppleSingleDecoder(&extractedSpec, &finalSpec);
|
||||
|
||||
OSErr decodeErr = asd->Decode();
|
||||
OSErr decodeErr = fnfErr;
|
||||
|
||||
if (asd)
|
||||
decodeErr = asd->Decode();
|
||||
|
||||
if (decodeErr != noErr)
|
||||
{
|
||||
|
@ -2287,6 +2290,7 @@ char*
|
|||
nsInstall::GetResourcedString(const nsString& aResName)
|
||||
{
|
||||
nsString rscdStr = "";
|
||||
PRBool bStrBdlSuccess = PR_FALSE;
|
||||
|
||||
if (mStringBundle)
|
||||
{
|
||||
|
@ -2294,9 +2298,25 @@ nsInstall::GetResourcedString(const nsString& aResName)
|
|||
PRUnichar *ucRscdStr = nsnull;
|
||||
nsresult rv = mStringBundle->GetStringFromName(ucResName, &ucRscdStr);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
bStrBdlSuccess = PR_TRUE;
|
||||
rscdStr = ucRscdStr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** We don't have a string bundle, the necessary libs, or something went wrong
|
||||
** so we failover to hardcoded english strings so we log something rather
|
||||
** than nothing due to failure above: always the case for the Install Wizards.
|
||||
*/
|
||||
if (!bStrBdlSuccess)
|
||||
{
|
||||
char *cResName = aResName.ToNewCString();
|
||||
rscdStr = nsInstallResources::GetDefaultVal(cResName);
|
||||
if (cResName)
|
||||
Recycle(cResName);
|
||||
}
|
||||
|
||||
return rscdStr.ToNewCString();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,47 +21,32 @@
|
|||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "nscore.h"
|
||||
#include "nsInstallResources.h"
|
||||
|
||||
char* nsInstallResources::GetInstallFileString(void)
|
||||
{
|
||||
return "Installing: %s";
|
||||
}
|
||||
|
||||
char* nsInstallResources::GetReplaceFileString(void)
|
||||
{
|
||||
return "Replacing %s";
|
||||
}
|
||||
|
||||
char* nsInstallResources::GetDeleteFileString(void)
|
||||
{
|
||||
return "Deleting file: %s";
|
||||
}
|
||||
|
||||
char* nsInstallResources::GetDeleteComponentString(void)
|
||||
{
|
||||
return "Deleting component: %s";
|
||||
}
|
||||
|
||||
char* nsInstallResources::GetExecuteString(void)
|
||||
{
|
||||
return "Executing: %s";
|
||||
}
|
||||
|
||||
char* nsInstallResources::GetExecuteWithArgsString(void)
|
||||
{
|
||||
return "Executing: %s with argument: %s";
|
||||
}
|
||||
|
||||
char* nsInstallResources::GetPatchFileString(void)
|
||||
{
|
||||
return "Patching: %s";
|
||||
}
|
||||
|
||||
char* nsInstallResources::GetUninstallString(void)
|
||||
{
|
||||
return "Uninstalling: %s";
|
||||
char*
|
||||
nsInstallResources::GetDefaultVal(const char* aResName)
|
||||
{
|
||||
char *currResName = XPIResTable[0].resName;
|
||||
char *currResVal = nsnull;
|
||||
PRInt32 idx, len = 0;
|
||||
|
||||
for (idx = 0; 0 != strcmp(currResName, NS_XPI_EOT); idx++)
|
||||
{
|
||||
currResName = XPIResTable[idx].resName;
|
||||
len = strlen(currResName);
|
||||
|
||||
if (0 == strncmp(currResName, aResName, len))
|
||||
{
|
||||
currResVal = XPIResTable[idx].defaultString;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return currResVal;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,24 +21,57 @@
|
|||
* Contributors:
|
||||
* Daniel Veditz <dveditz@netscape.com>
|
||||
* Douglas Turner <dougt@netscape.com>
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __NS_INSTALLRESOURCES_H__
|
||||
#define __NS_INSTALLRESOURCES_H__
|
||||
|
||||
#define NS_XPI_EOT "___END_OF_TABLE___"
|
||||
|
||||
typedef struct _nsXPIResourceTableItem
|
||||
{
|
||||
char *resName;
|
||||
char *defaultString;
|
||||
} nsXPIResourceTableItem;
|
||||
|
||||
static nsXPIResourceTableItem XPIResTable[] =
|
||||
{
|
||||
/*---------------------------------------------------------------------*
|
||||
* Install Actions
|
||||
*---------------------------------------------------------------------*/
|
||||
{ "InstallFile", "Installing: %s" },
|
||||
{ "ReplaceFile", "Replacing: %s" },
|
||||
{ "DeleteFile", "Deleting file: %s" },
|
||||
{ "DeleteComponent", "Deleting component: %s" },
|
||||
{ "Execute", "Executing: %s" },
|
||||
{ "ExecuteWithArgs", "Executing: %s with argument: %s" },
|
||||
{ "Patch", "Patching: %s" },
|
||||
{ "Uninstall", "Uninstalling: %s" },
|
||||
|
||||
// XXX FileOp*() action strings
|
||||
// XXX WinReg and WinProfile action strings
|
||||
|
||||
/*---------------------------------------------------------------------*
|
||||
* Dialog Messages
|
||||
*---------------------------------------------------------------------*/
|
||||
{ "ShouldWeInstallMsg", "Attempting to download and install software. Do you feel lucky punk?" },
|
||||
{ "FinishingInstallMsg", "Finishing install... please wait." },
|
||||
|
||||
/*---------------------------------------------------------------------*
|
||||
* Miscellaneous
|
||||
*---------------------------------------------------------------------*/
|
||||
{ "ERROR", "ERROR" },
|
||||
|
||||
{ NS_XPI_EOT, "" }
|
||||
};
|
||||
|
||||
class nsInstallResources
|
||||
{
|
||||
public:
|
||||
|
||||
static char* GetInstallFileString(void);
|
||||
static char* GetReplaceFileString(void);
|
||||
static char* GetDeleteFileString(void);
|
||||
static char* GetDeleteComponentString(void);
|
||||
static char* GetExecuteString(void);
|
||||
static char* GetExecuteWithArgsString(void);
|
||||
static char* GetPatchFileString(void);
|
||||
static char* GetUninstallString(void);
|
||||
|
||||
static char* GetDefaultVal(const char* aResName);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "nsXPITriggerInfo.h"
|
||||
#include "nsXPInstallManager.h"
|
||||
#include "nsInstallProgressDialog.h"
|
||||
#include "nsInstallResources.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsProxyObjectManager.h"
|
||||
|
@ -152,16 +153,35 @@ nsXPInstallManager::InitManager(nsXPITriggerInfo* aTriggers)
|
|||
if ( NS_SUCCEEDED(rv) )
|
||||
{
|
||||
nsCOMPtr<nsIPrompt> prompt( do_QueryInterface(wbwin, &rv) );
|
||||
if ( NS_SUCCEEDED(rv) && prompt && mStringBundle )
|
||||
if ( NS_SUCCEEDED(rv) && prompt )
|
||||
{
|
||||
PRBool bStrBdlSuccess = PR_FALSE;
|
||||
nsString rsrcName = "ShouldWeInstallMsg";
|
||||
const PRUnichar* ucRsrcName = rsrcName.GetUnicode();
|
||||
PRUnichar* ucRsrcVal = nsnull;
|
||||
rv = mStringBundle->GetStringFromName(ucRsrcName, &ucRsrcVal);
|
||||
if (NS_SUCCEEDED(rv) && ucRsrcVal)
|
||||
|
||||
if (mStringBundle)
|
||||
{
|
||||
prompt->Confirm( ucRsrcVal, &OKtoInstall);
|
||||
nsCRT::free(ucRsrcVal);
|
||||
const PRUnichar* ucRsrcName = rsrcName.GetUnicode();
|
||||
PRUnichar* ucRsrcVal = nsnull;
|
||||
rv = mStringBundle->GetStringFromName(ucRsrcName, &ucRsrcVal);
|
||||
if (NS_SUCCEEDED(rv) && ucRsrcVal)
|
||||
{
|
||||
prompt->Confirm( ucRsrcVal, &OKtoInstall);
|
||||
nsCRT::free(ucRsrcVal);
|
||||
bStrBdlSuccess = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* failover to default english strings */
|
||||
if (!bStrBdlSuccess)
|
||||
{
|
||||
char *cResName = rsrcName.ToNewCString();
|
||||
nsString resVal = nsInstallResources::GetDefaultVal(cResName);
|
||||
|
||||
if (!resVal.IsEmpty())
|
||||
prompt->Confirm( resVal.GetUnicode(), &OKtoInstall );
|
||||
|
||||
if (cResName)
|
||||
Recycle(cResName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче