зеркало из https://github.com/mozilla/pjs.git
Bug #379070--> remove nsCRT methods from mail\components.
r=prasad
This commit is contained in:
Родитель
39f36b97ec
Коммит
b9eebc2032
|
@ -38,7 +38,6 @@
|
|||
// this file is mostly a copy of nsPrefMigration.cpp.
|
||||
|
||||
#include "nsMailProfileMigratorUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPasswordManagerInternal.h"
|
||||
|
@ -1641,34 +1640,31 @@ nsresult nsDogbertProfileMigrator::RenameAndMove4xImapFilterFile(nsILocalFile *
|
|||
nsresult nsDogbertProfileMigrator::RenameAndMove4xImapFilterFiles(nsILocalFile * profilePath)
|
||||
{
|
||||
nsresult rv;
|
||||
char *hostList=nsnull;
|
||||
nsCString hostList
|
||||
|
||||
rv = mPrefs->GetCharPref(PREF_4X_NETWORK_HOSTS_IMAP_SERVER, &hostList);
|
||||
rv = mPrefs->GetCharPref(PREF_4X_NETWORK_HOSTS_IMAP_SERVER, getter_Copies(hostList));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!hostList || !*hostList) return NS_OK;
|
||||
if (hostList.IsEmpty()) return NS_OK;
|
||||
|
||||
char *token = nsnull;
|
||||
char *rest = hostList;
|
||||
char *rest = hostList.BeginWriting();
|
||||
nsCAutoString str;
|
||||
|
||||
token = nsCRT::strtok(rest, ",", &rest);
|
||||
token = NS_strtok(",", &rest);
|
||||
while (token && *token) {
|
||||
str = token;
|
||||
str.StripWhitespace();
|
||||
|
||||
if (!str.IsEmpty()) {
|
||||
// str is the hostname
|
||||
rv = RenameAndMove4xImapFilterFile(profilePath,str.get());
|
||||
rv = RenameAndMove4xImapFilterFile(profilePath, str.get());
|
||||
if (NS_FAILED(rv)) {
|
||||
// failed to migrate. bail.
|
||||
return rv;
|
||||
}
|
||||
str = "";
|
||||
}
|
||||
token = nsCRT::strtok(rest, ",", &rest);
|
||||
token = NS_strtok(",", &rest);
|
||||
}
|
||||
PR_FREEIF(hostList);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif /* IMAP_MAIL_FILTER_FILE_NAME_FORMAT_IN_4x */
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsMailProfileMigratorUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
|
|
|
@ -43,18 +43,17 @@
|
|||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsXPCOMCID.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
void SetProxyPref(const nsACString& aHostPort, const char* aPref,
|
||||
const char* aPortPref, nsIPrefBranch* aPrefs)
|
||||
void SetProxyPref(const nsACString& aHostPort, const char* aPref,
|
||||
const char* aPortPref, nsIPrefBranch* aPrefs)
|
||||
{
|
||||
nsCAutoString hostPort(aHostPort);
|
||||
nsCAutoString hostPort(aHostPort);
|
||||
PRInt32 portDelimOffset = hostPort.RFindChar(':');
|
||||
if (portDelimOffset > 0) {
|
||||
nsCAutoString host(Substring(hostPort, 0, portDelimOffset));
|
||||
nsCAutoString port(Substring(hostPort, portDelimOffset + 1,
|
||||
nsCAutoString port(Substring(hostPort, portDelimOffset + 1,
|
||||
hostPort.Length() - (portDelimOffset + 1)));
|
||||
|
||||
|
||||
aPrefs->SetCharPref(aPref, host.get());
|
||||
PRInt32 stringErr;
|
||||
PRInt32 portValue = port.ToInteger(&stringErr);
|
||||
|
@ -67,14 +66,14 @@ void SetProxyPref(const nsACString& aHostPort, const char* aPref,
|
|||
void ParseOverrideServers(const char* aServers, nsIPrefBranch* aBranch)
|
||||
{
|
||||
// Windows (and Opera) formats its proxy override list in the form:
|
||||
// server;server;server where server is a server name or ip address,
|
||||
// server;server;server where server is a server name or ip address,
|
||||
// or "<local>". Mozilla's format is server,server,server, and <local>
|
||||
// must be translated to "localhost,127.0.0.1"
|
||||
nsCAutoString override(aServers);
|
||||
PRInt32 left = 0, right = 0;
|
||||
for (;;) {
|
||||
right = override.FindChar(';', right);
|
||||
const nsACString& host = Substring(override, left,
|
||||
const nsACString& host = Substring(override, left,
|
||||
(right < 0 ? override.Length() : right) - left);
|
||||
if (host.Equals("<local>"))
|
||||
override.Replace(left, 7, NS_LITERAL_CSTRING("localhost,127.0.0.1"));
|
||||
|
@ -86,16 +85,16 @@ void ParseOverrideServers(const char* aServers, nsIPrefBranch* aBranch)
|
|||
aBranch->SetCharPref("network.proxy.no_proxies_on", override.get());
|
||||
}
|
||||
|
||||
void GetMigrateDataFromArray(MigrationData* aDataArray, PRInt32 aDataArrayLength,
|
||||
PRBool aReplace, nsIFile* aSourceProfile,
|
||||
void GetMigrateDataFromArray(MigrationData* aDataArray, PRInt32 aDataArrayLength,
|
||||
PRBool aReplace, nsIFile* aSourceProfile,
|
||||
PRUint16* aResult)
|
||||
{
|
||||
nsCOMPtr<nsIFile> sourceFile;
|
||||
nsCOMPtr<nsIFile> sourceFile;
|
||||
PRBool exists;
|
||||
MigrationData* cursor;
|
||||
MigrationData* end = aDataArray + aDataArrayLength;
|
||||
for (cursor = aDataArray; cursor < end && cursor->fileName; ++cursor) {
|
||||
// When in replace mode, all items can be imported.
|
||||
// When in replace mode, all items can be imported.
|
||||
// When in non-replace mode, only items that do not require file replacement
|
||||
// can be imported.
|
||||
if (aReplace || !cursor->replaceOnly) {
|
||||
|
@ -105,7 +104,7 @@ void GetMigrateDataFromArray(MigrationData* aDataArray, PRInt32 aDataArrayLength
|
|||
if (exists)
|
||||
*aResult |= cursor->sourceFlag;
|
||||
}
|
||||
nsCRT::free(cursor->fileName);
|
||||
NS_Free(cursor->fileName);
|
||||
cursor->fileName = nsnull;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsILineInputStream.h"
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
#include "nsProfileMigrator.h"
|
||||
#include "nsMailMigrationCID.h"
|
||||
|
||||
#include "nsCRT.h"
|
||||
#include "NSReg.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsString.h"
|
||||
|
@ -87,7 +86,7 @@ nsProfileMigrator::Migrate(nsIProfileStartup* aStartup)
|
|||
cstr->SetData(key);
|
||||
|
||||
// By opening the Migration FE with a supplied mailMigrator, it will automatically
|
||||
// migrate from it.
|
||||
// migrate from it.
|
||||
nsCOMPtr<nsIWindowWatcher> ww (do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
nsCOMPtr<nsISupportsArray> params;
|
||||
NS_NewISupportsArray(getter_AddRefs(params));
|
||||
|
@ -98,7 +97,7 @@ nsProfileMigrator::Migrate(nsIProfileStartup* aStartup)
|
|||
params->AppendElement(aStartup);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> migrateWizard;
|
||||
return ww->OpenWindow(nsnull,
|
||||
return ww->OpenWindow(nsnull,
|
||||
MIGRATION_WIZARD_FE_URL,
|
||||
"_blank",
|
||||
MIGRATION_WIZARD_FE_FEATURES,
|
||||
|
@ -178,7 +177,7 @@ nsProfileMigrator::GetDefaultMailMigratorKey(nsACString& aKey, nsCOMPtr<nsIMailP
|
|||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
|
@ -236,7 +235,7 @@ nsProfileMigrator::ImportRegistryProfiles(const nsACString& aAppName)
|
|||
nsCAutoString dotAppName;
|
||||
ToLowerCase(aAppName, dotAppName);
|
||||
dotAppName.Insert('.', 0);
|
||||
|
||||
|
||||
regFile->AppendNative(dotAppName);
|
||||
regFile->AppendNative(NS_LITERAL_CSTRING("appreg"));
|
||||
#endif
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsMailProfileMigratorUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPasswordManagerInternal.h"
|
||||
|
@ -63,17 +62,17 @@ nsProfileMigratorBase::nsProfileMigratorBase()
|
|||
}
|
||||
|
||||
nsProfileMigratorBase::~nsProfileMigratorBase()
|
||||
{
|
||||
{
|
||||
if (mFileIOTimer)
|
||||
mFileIOTimer->Cancel();
|
||||
}
|
||||
|
||||
nsresult nsProfileMigratorBase::ImportSettings(nsIImportModule * aImportModule)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsAutoString index;
|
||||
index.AppendInt(nsIMailProfileMigrator::ACCOUNT_SETTINGS);
|
||||
index.AppendInt(nsIMailProfileMigrator::ACCOUNT_SETTINGS);
|
||||
NOTIFY_OBSERVERS(MIGRATION_ITEMBEFOREMIGRATE, index.get());
|
||||
|
||||
nsCOMPtr<nsIImportSettings> importSettings;
|
||||
|
@ -90,11 +89,11 @@ nsresult nsProfileMigratorBase::ImportSettings(nsIImportModule * aImportModule)
|
|||
}
|
||||
|
||||
nsresult nsProfileMigratorBase::ImportAddressBook(nsIImportModule * aImportModule)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsAutoString index;
|
||||
index.AppendInt(nsIMailProfileMigrator::ADDRESSBOOK_DATA);
|
||||
index.AppendInt(nsIMailProfileMigrator::ADDRESSBOOK_DATA);
|
||||
NOTIFY_OBSERVERS(MIGRATION_ITEMBEFOREMIGRATE, index.get());
|
||||
|
||||
rv = aImportModule->GetImportInterface(NS_IMPORT_ADDRESS_STR, getter_AddRefs(mGenericImporter));
|
||||
|
@ -123,7 +122,7 @@ nsresult nsProfileMigratorBase::ImportAddressBook(nsIImportModule * aImportModul
|
|||
nsresult nsProfileMigratorBase::FinishCopyingAddressBookData()
|
||||
{
|
||||
nsAutoString index;
|
||||
index.AppendInt(nsIMailProfileMigrator::ADDRESSBOOK_DATA);
|
||||
index.AppendInt(nsIMailProfileMigrator::ADDRESSBOOK_DATA);
|
||||
NOTIFY_OBSERVERS(MIGRATION_ITEMAFTERMIGRATE, index.get());
|
||||
|
||||
// now kick off the mail migration code
|
||||
|
@ -134,10 +133,10 @@ nsresult nsProfileMigratorBase::FinishCopyingAddressBookData()
|
|||
|
||||
nsresult nsProfileMigratorBase::ImportMailData(nsIImportModule * aImportModule)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsAutoString index;
|
||||
index.AppendInt(nsIMailProfileMigrator::MAILDATA);
|
||||
index.AppendInt(nsIMailProfileMigrator::MAILDATA);
|
||||
NOTIFY_OBSERVERS(MIGRATION_ITEMBEFOREMIGRATE, index.get());
|
||||
|
||||
rv = aImportModule->GetImportInterface(NS_IMPORT_MAIL_STR, getter_AddRefs(mGenericImporter));
|
||||
|
@ -169,7 +168,7 @@ nsresult nsProfileMigratorBase::ImportMailData(nsIImportModule * aImportModule)
|
|||
nsresult nsProfileMigratorBase::FinishCopyingMailFolders()
|
||||
{
|
||||
nsAutoString index;
|
||||
index.AppendInt(nsIMailProfileMigrator::MAILDATA);
|
||||
index.AppendInt(nsIMailProfileMigrator::MAILDATA);
|
||||
NOTIFY_OBSERVERS(MIGRATION_ITEMAFTERMIGRATE, index.get());
|
||||
|
||||
// migration is now done...notify the UI.
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsMailProfileMigratorUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPasswordManagerInternal.h"
|
||||
|
@ -53,6 +52,7 @@
|
|||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "prprf.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "msgCore.h"
|
||||
|
||||
static PRUint32 StringHash(const char *ubuf);
|
||||
nsresult NS_MsgHashIfNecessary(nsCString &name);
|
||||
|
@ -98,7 +98,7 @@ nsSeamonkeyProfileMigrator::nsSeamonkeyProfileMigrator()
|
|||
}
|
||||
|
||||
nsSeamonkeyProfileMigrator::~nsSeamonkeyProfileMigrator()
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -111,7 +111,7 @@ nsSeamonkeyProfileMigrator::Notify(nsITimer *timer)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsSeamonkeyProfileMigrator::CopyNextFolder()
|
||||
void nsSeamonkeyProfileMigrator::CopyNextFolder()
|
||||
{
|
||||
if (mFileCopyTransactionIndex < mFileCopyTransactions->Count())
|
||||
{
|
||||
|
@ -130,31 +130,31 @@ void nsSeamonkeyProfileMigrator::CopyNextFolder()
|
|||
LL_MUL(percentDone, mCurrentProgress, 100);
|
||||
|
||||
LL_DIV(percentDone, percentDone, mMaxProgress);
|
||||
|
||||
|
||||
LL_L2UI(percentage, percentDone);
|
||||
|
||||
nsAutoString index;
|
||||
index.AppendInt( percentage );
|
||||
index.AppendInt( percentage );
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_PROGRESS, index.get());
|
||||
}
|
||||
// fire a timer to handle the next one.
|
||||
// fire a timer to handle the next one.
|
||||
mFileIOTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
if (mFileIOTimer)
|
||||
mFileIOTimer->InitWithCallback(NS_STATIC_CAST(nsITimerCallback *, this), percentage == 100 ? 500 : 0, nsITimer::TYPE_ONE_SHOT);
|
||||
} else
|
||||
EndCopyFolders();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void nsSeamonkeyProfileMigrator::EndCopyFolders()
|
||||
void nsSeamonkeyProfileMigrator::EndCopyFolders()
|
||||
{
|
||||
// clear out the file transaction array
|
||||
if (mFileCopyTransactions)
|
||||
{
|
||||
PRUint32 count = mFileCopyTransactions->Count();
|
||||
for (PRUint32 i = 0; i < count; ++i)
|
||||
for (PRUint32 i = 0; i < count; ++i)
|
||||
{
|
||||
fileTransactionEntry* fileTransaction = (fileTransactionEntry*) mFileCopyTransactions->ElementAt(i);
|
||||
if (fileTransaction)
|
||||
|
@ -164,14 +164,14 @@ void nsSeamonkeyProfileMigrator::EndCopyFolders()
|
|||
delete fileTransaction;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mFileCopyTransactions->Clear();
|
||||
delete mFileCopyTransactions;
|
||||
}
|
||||
|
||||
// notify the UI that we are done with the migration process
|
||||
nsAutoString index;
|
||||
index.AppendInt(nsIMailProfileMigrator::MAILDATA);
|
||||
index.AppendInt(nsIMailProfileMigrator::MAILDATA);
|
||||
NOTIFY_OBSERVERS(MIGRATION_ITEMAFTERMIGRATE, index.get());
|
||||
|
||||
NOTIFY_OBSERVERS(MIGRATION_ENDED, nsnull);
|
||||
|
@ -198,7 +198,7 @@ nsSeamonkeyProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup
|
|||
COPY_DATA(CopyPreferences, aReplace, nsIMailProfileMigrator::SETTINGS);
|
||||
|
||||
// fake notifications for things we've already imported as part of CopyPreferences
|
||||
COPY_DATA(DummyCopyRoutine, aReplace, nsIMailProfileMigrator::ACCOUNT_SETTINGS);
|
||||
COPY_DATA(DummyCopyRoutine, aReplace, nsIMailProfileMigrator::ACCOUNT_SETTINGS);
|
||||
COPY_DATA(DummyCopyRoutine, aReplace, nsIMailProfileMigrator::NEWSDATA);
|
||||
|
||||
// copy junk mail training file
|
||||
|
@ -206,21 +206,21 @@ nsSeamonkeyProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup
|
|||
COPY_DATA(CopyPasswords, aReplace, nsIMailProfileMigrator::PASSWORDS);
|
||||
|
||||
// the last thing to do is to actually copy over any mail folders we have marked for copying
|
||||
// we want to do this last and it will be asynchronous so the UI doesn't freeze up while we perform
|
||||
// this potentially very long operation.
|
||||
|
||||
// we want to do this last and it will be asynchronous so the UI doesn't freeze up while we perform
|
||||
// this potentially very long operation.
|
||||
|
||||
nsAutoString index;
|
||||
index.AppendInt(nsIMailProfileMigrator::MAILDATA);
|
||||
index.AppendInt(nsIMailProfileMigrator::MAILDATA);
|
||||
NOTIFY_OBSERVERS(MIGRATION_ITEMBEFOREMIGRATE, index.get());
|
||||
|
||||
// Generate the max progress value now that we know all of the files we need to copy
|
||||
PRUint32 count = mFileCopyTransactions->Count();
|
||||
for (PRUint32 i = 0; i < count; ++i)
|
||||
for (PRUint32 i = 0; i < count; ++i)
|
||||
{
|
||||
fileTransactionEntry* fileTransaction = (fileTransactionEntry*) mFileCopyTransactions->ElementAt(i);
|
||||
if (fileTransaction)
|
||||
{
|
||||
PRInt64 fileSize;
|
||||
PRInt64 fileSize;
|
||||
fileTransaction->srcFile->GetFileSize(&fileSize);
|
||||
LL_ADD(mMaxProgress, mMaxProgress, fileSize);
|
||||
}
|
||||
|
@ -232,8 +232,8 @@ nsSeamonkeyProfileMigrator::Migrate(PRUint16 aItems, nsIProfileStartup* aStartup
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSeamonkeyProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
||||
PRBool aReplace,
|
||||
nsSeamonkeyProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
||||
PRBool aReplace,
|
||||
PRUint16* aResult)
|
||||
{
|
||||
*aResult = 0;
|
||||
|
@ -251,9 +251,9 @@ nsSeamonkeyProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
|||
nsIMailProfileMigrator::JUNKTRAINING,
|
||||
PR_TRUE },
|
||||
};
|
||||
|
||||
|
||||
// Frees file name strings allocated above.
|
||||
GetMigrateDataFromArray(data, sizeof(data)/sizeof(MigrationData),
|
||||
GetMigrateDataFromArray(data, sizeof(data)/sizeof(MigrationData),
|
||||
aReplace, mSourceProfile, aResult);
|
||||
|
||||
// Now locate passwords
|
||||
|
@ -266,7 +266,7 @@ nsSeamonkeyProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
|||
nsCOMPtr<nsIFile> sourcePasswordsFile;
|
||||
mSourceProfile->Clone(getter_AddRefs(sourcePasswordsFile));
|
||||
sourcePasswordsFile->Append(fileName);
|
||||
|
||||
|
||||
PRBool exists;
|
||||
sourcePasswordsFile->Exists(&exists);
|
||||
if (exists)
|
||||
|
@ -274,8 +274,8 @@ nsSeamonkeyProfileMigrator::GetMigrateData(const PRUnichar* aProfile,
|
|||
}
|
||||
|
||||
// add some extra migration fields for things we also migrate
|
||||
*aResult |= nsIMailProfileMigrator::ACCOUNT_SETTINGS
|
||||
| nsIMailProfileMigrator::MAILDATA
|
||||
*aResult |= nsIMailProfileMigrator::ACCOUNT_SETTINGS
|
||||
| nsIMailProfileMigrator::MAILDATA
|
||||
| nsIMailProfileMigrator::NEWSDATA
|
||||
| nsIMailProfileMigrator::ADDRESSBOOK_DATA;
|
||||
|
||||
|
@ -288,7 +288,7 @@ nsSeamonkeyProfileMigrator::GetSourceExists(PRBool* aResult)
|
|||
nsCOMPtr<nsISupportsArray> profiles;
|
||||
GetSourceProfiles(getter_AddRefs(profiles));
|
||||
|
||||
if (profiles) {
|
||||
if (profiles) {
|
||||
PRUint32 count;
|
||||
profiles->Count(&count);
|
||||
*aResult = count > 0;
|
||||
|
@ -329,7 +329,7 @@ nsSeamonkeyProfileMigrator::GetSourceProfiles(nsISupportsArray** aResult)
|
|||
// Fills mProfileNames and mProfileLocations
|
||||
FillProfileDataFromSeamonkeyRegistry();
|
||||
}
|
||||
|
||||
|
||||
NS_IF_ADDREF(*aResult = mProfileNames);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -370,19 +370,19 @@ nsSeamonkeyProfileMigrator::FillProfileDataFromSeamonkeyRegistry()
|
|||
#elif defined(XP_MACOSX)
|
||||
fileLocator->Get(NS_MAC_USER_LIB_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(seamonkeyRegistry));
|
||||
NS_ENSURE_TRUE(seamonkeyRegistry, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
seamonkeyRegistry->Append(NS_LITERAL_STRING("Mozilla"));
|
||||
seamonkeyRegistry->Append(NS_LITERAL_STRING("Application Registry"));
|
||||
#elif defined(XP_UNIX)
|
||||
fileLocator->Get(NS_UNIX_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(seamonkeyRegistry));
|
||||
NS_ENSURE_TRUE(seamonkeyRegistry, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
seamonkeyRegistry->Append(NS_LITERAL_STRING(".mozilla"));
|
||||
seamonkeyRegistry->Append(NS_LITERAL_STRING("appreg"));
|
||||
#elif defined(XP_OS2)
|
||||
fileLocator->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(seamonkeyRegistry));
|
||||
NS_ENSURE_TRUE(seamonkeyRegistry, NS_ERROR_FAILURE);
|
||||
|
||||
|
||||
seamonkeyRegistry->Append(NS_LITERAL_STRING("Mozilla"));
|
||||
seamonkeyRegistry->Append(NS_LITERAL_STRING("registry.dat"));
|
||||
#endif
|
||||
|
@ -399,14 +399,14 @@ nsSeamonkeyProfileMigrator::FillProfileDataFromSeamonkeyRegistry()
|
|||
{ pref, 0, F(Get##method), F(Set##method), PR_FALSE, -1 }
|
||||
|
||||
|
||||
static
|
||||
static
|
||||
nsSeamonkeyProfileMigrator::PrefTransform gTransforms[] = {
|
||||
|
||||
|
||||
MAKESAMETYPEPREFTRANSFORM("signon.SignonFileName", String),
|
||||
MAKESAMETYPEPREFTRANSFORM("mailnews.headers.showUserAgent", Bool),
|
||||
MAKESAMETYPEPREFTRANSFORM("mailnews.headers.showOrganization", Bool),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.collect_addressbook", String),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.collect_addressbook", String),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.collect_email_address_outgoing", Bool),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.wrap_long_lines", Bool),
|
||||
MAKESAMETYPEPREFTRANSFORM("news.wrap_long_lines", Bool),
|
||||
|
@ -417,8 +417,8 @@ nsSeamonkeyProfileMigrator::PrefTransform gTransforms[] = {
|
|||
MAKESAMETYPEPREFTRANSFORM("mail.warn_on_send_accel_key", Bool),
|
||||
MAKESAMETYPEPREFTRANSFORM("mailnews.html_domains", String),
|
||||
MAKESAMETYPEPREFTRANSFORM("mailnews.plaintext_domains", String),
|
||||
MAKESAMETYPEPREFTRANSFORM("mailnews.headers.showUserAgent", Bool),
|
||||
MAKESAMETYPEPREFTRANSFORM("mailnews.headers.showOrganization", Bool),
|
||||
MAKESAMETYPEPREFTRANSFORM("mailnews.headers.showUserAgent", Bool),
|
||||
MAKESAMETYPEPREFTRANSFORM("mailnews.headers.showOrganization", Bool),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.biff.play_sound", Bool),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.biff.play_sound.type", Int),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.biff.play_sound.url", String),
|
||||
|
@ -439,7 +439,7 @@ nsSeamonkeyProfileMigrator::PrefTransform gTransforms[] = {
|
|||
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.accountmanager.accounts", String),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.accountmanager.defaultaccount", String),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.accountmanager.localfoldersserver", String),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.accountmanager.localfoldersserver", String),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.smtp.defaultserver", String),
|
||||
MAKESAMETYPEPREFTRANSFORM("mail.smtpservers", String),
|
||||
|
||||
|
@ -472,7 +472,7 @@ nsSeamonkeyProfileMigrator::TransformPreferences(const nsAString& aSourcePrefFil
|
|||
for (transform = gTransforms; transform < end; ++transform)
|
||||
transform->prefGetterFunc(transform, branch);
|
||||
|
||||
// read in the various pref branch trees for accounts, identities, servers, etc.
|
||||
// read in the various pref branch trees for accounts, identities, servers, etc.
|
||||
|
||||
nsVoidArray* accounts = new nsVoidArray();
|
||||
nsVoidArray* identities = new nsVoidArray();
|
||||
|
@ -483,7 +483,7 @@ nsSeamonkeyProfileMigrator::TransformPreferences(const nsAString& aSourcePrefFil
|
|||
|
||||
if (!accounts || !identities || !servers || !smtpservers || !ldapservers)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
||||
ReadBranch("mail.account.", psvc, accounts);
|
||||
ReadBranch("mail.identity.", psvc, identities);
|
||||
ReadBranch("mail.server.", psvc, servers);
|
||||
|
@ -534,11 +534,11 @@ nsresult nsSeamonkeyProfileMigrator::CopyAddressBookDirectories(nsVoidArray* aLd
|
|||
// each server has a pref ending with .filename. The value of that pref points to a profile which we
|
||||
// need to migrate.
|
||||
nsAutoString index;
|
||||
index.AppendInt(nsIMailProfileMigrator::ADDRESSBOOK_DATA);
|
||||
index.AppendInt(nsIMailProfileMigrator::ADDRESSBOOK_DATA);
|
||||
NOTIFY_OBSERVERS(MIGRATION_ITEMBEFOREMIGRATE, index.get());
|
||||
|
||||
PRUint32 count = aLdapServers->Count();
|
||||
for (PRUint32 i = 0; i < count; ++i)
|
||||
for (PRUint32 i = 0; i < count; ++i)
|
||||
{
|
||||
PrefBranchStruct* pref = (PrefBranchStruct*) aLdapServers->ElementAt(i);
|
||||
nsDependentCString prefName (pref->prefName);
|
||||
|
@ -546,7 +546,7 @@ nsresult nsSeamonkeyProfileMigrator::CopyAddressBookDirectories(nsVoidArray* aLd
|
|||
if (StringEndsWith(prefName, nsDependentCString(".filename")))
|
||||
{
|
||||
// should we be assuming utf-8 or ascii here?
|
||||
CopyFile(NS_ConvertUTF8toUTF16(pref->stringValue), NS_ConvertUTF8toUTF16(pref->stringValue));
|
||||
CopyFile(NS_ConvertUTF8toUTF16(pref->stringValue), NS_ConvertUTF8toUTF16(pref->stringValue));
|
||||
}
|
||||
|
||||
// we don't need to do anything to the fileName pref itself
|
||||
|
@ -563,14 +563,14 @@ nsresult nsSeamonkeyProfileMigrator::CopySignatureFiles(nsVoidArray* aIdentities
|
|||
nsresult rv = NS_OK;
|
||||
|
||||
PRUint32 count = aIdentities->Count();
|
||||
for (PRUint32 i = 0; i < count; ++i)
|
||||
for (PRUint32 i = 0; i < count; ++i)
|
||||
{
|
||||
PrefBranchStruct* pref = (PrefBranchStruct*)aIdentities->ElementAt(i);
|
||||
nsDependentCString prefName (pref->prefName);
|
||||
|
||||
// a partial fix for bug #255043
|
||||
// if the user's signature file from seamonkey lives in the
|
||||
// seamonkey profile root, we'll copy it over to the new
|
||||
// if the user's signature file from seamonkey lives in the
|
||||
// seamonkey profile root, we'll copy it over to the new
|
||||
// thunderbird profile root and thenn set the pref to the new value
|
||||
// note, this doesn't work for multiple signatures that live
|
||||
// below the seamonkey profile root
|
||||
|
@ -582,10 +582,10 @@ nsresult nsSeamonkeyProfileMigrator::CopySignatureFiles(nsVoidArray* aIdentities
|
|||
|
||||
nsCOMPtr<nsIFile> targetSigFile;
|
||||
rv = mTargetProfile->Clone(getter_AddRefs(targetSigFile));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// now make the copy
|
||||
PRBool exists;
|
||||
PRBool exists;
|
||||
srcSigFile->Exists(&exists);
|
||||
if (exists)
|
||||
{
|
||||
|
@ -598,9 +598,9 @@ nsresult nsSeamonkeyProfileMigrator::CopySignatureFiles(nsVoidArray* aIdentities
|
|||
nsCAutoString descriptorString;
|
||||
nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(targetSigFile);
|
||||
localFile->GetPersistentDescriptor(descriptorString);
|
||||
nsCRT::free(pref->stringValue);
|
||||
NS_Free(pref->stringValue);
|
||||
pref->stringValue = ToNewCString(descriptorString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
|
@ -616,7 +616,7 @@ nsresult nsSeamonkeyProfileMigrator::CopyMailFolders(nsVoidArray* aMailServers,
|
|||
nsresult rv = NS_OK;
|
||||
|
||||
PRUint32 count = aMailServers->Count();
|
||||
for (PRUint32 i = 0; i < count; ++i)
|
||||
for (PRUint32 i = 0; i < count; ++i)
|
||||
{
|
||||
PrefBranchStruct* pref = (PrefBranchStruct*)aMailServers->ElementAt(i);
|
||||
nsDependentCString prefName (pref->prefName);
|
||||
|
@ -647,7 +647,7 @@ nsresult nsSeamonkeyProfileMigrator::CopyMailFolders(nsVoidArray* aMailServers,
|
|||
if (!serverBranch)
|
||||
break; // should we clear out this server pref from aMailServers?
|
||||
|
||||
nsCString serverType;
|
||||
nsCString serverType;
|
||||
serverBranch->GetCharPref("type", getter_Copies(serverType));
|
||||
|
||||
nsCOMPtr<nsILocalFile> sourceMailFolder;
|
||||
|
@ -658,9 +658,9 @@ nsresult nsSeamonkeyProfileMigrator::CopyMailFolders(nsVoidArray* aMailServers,
|
|||
if (serverType.Equals("imap"))
|
||||
{
|
||||
mTargetProfile->Clone(getter_AddRefs(targetMailFolder));
|
||||
targetMailFolder->Append(IMAP_MAIL_DIR_50_NAME);
|
||||
targetMailFolder->Append(IMAP_MAIL_DIR_50_NAME);
|
||||
}
|
||||
else if (serverType.Equals("none") || serverType.Equals("pop3"))
|
||||
else if (serverType.Equals("none") || serverType.Equals("pop3"))
|
||||
{
|
||||
// local folders and POP3 servers go under <profile>\Mail
|
||||
mTargetProfile->Clone(getter_AddRefs(targetMailFolder));
|
||||
|
@ -669,7 +669,7 @@ nsresult nsSeamonkeyProfileMigrator::CopyMailFolders(nsVoidArray* aMailServers,
|
|||
else if (serverType.Equals("nntp"))
|
||||
{
|
||||
mTargetProfile->Clone(getter_AddRefs(targetMailFolder));
|
||||
targetMailFolder->Append(NEWS_DIR_50_NAME);
|
||||
targetMailFolder->Append(NEWS_DIR_50_NAME);
|
||||
}
|
||||
|
||||
if (targetMailFolder)
|
||||
|
@ -679,7 +679,7 @@ nsresult nsSeamonkeyProfileMigrator::CopyMailFolders(nsVoidArray* aMailServers,
|
|||
serverBranch->GetCharPref("hostname", getter_Copies(hostName));
|
||||
targetMailFolder->Append(NS_ConvertASCIItoUTF16(hostName));
|
||||
|
||||
// we should make sure the host name based directory we are going to migrate
|
||||
// we should make sure the host name based directory we are going to migrate
|
||||
// the accounts into is unique. This protects against the case where the user
|
||||
// has multiple servers with the same host name.
|
||||
targetMailFolder->CreateUnique(nsIFile::DIRECTORY_TYPE, 0777);
|
||||
|
@ -691,7 +691,7 @@ nsresult nsSeamonkeyProfileMigrator::CopyMailFolders(nsVoidArray* aMailServers,
|
|||
nsCAutoString descriptorString;
|
||||
nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(targetMailFolder);
|
||||
localFile->GetPersistentDescriptor(descriptorString);
|
||||
nsCRT::free(pref->stringValue);
|
||||
NS_Free(pref->stringValue);
|
||||
pref->stringValue = ToNewCString(descriptorString);
|
||||
}
|
||||
}
|
||||
|
@ -699,17 +699,17 @@ nsresult nsSeamonkeyProfileMigrator::CopyMailFolders(nsVoidArray* aMailServers,
|
|||
{
|
||||
// copy the news RC file into \News. this won't work if the user has different newsrc files for each account
|
||||
// I don't know what to do in that situation.
|
||||
|
||||
|
||||
nsCOMPtr<nsIFile> targetNewsRCFile;
|
||||
mTargetProfile->Clone(getter_AddRefs(targetNewsRCFile));
|
||||
targetNewsRCFile->Append(NEWS_DIR_50_NAME);
|
||||
targetNewsRCFile->Append(NEWS_DIR_50_NAME);
|
||||
|
||||
// turn the pref into a nsILocalFile
|
||||
nsCOMPtr<nsILocalFile> srcNewsRCFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
|
||||
srcNewsRCFile->SetPersistentDescriptor(nsDependentCString(pref->stringValue));
|
||||
|
||||
// now make the copy
|
||||
PRBool exists;
|
||||
PRBool exists;
|
||||
srcNewsRCFile->Exists(&exists);
|
||||
if (exists)
|
||||
{
|
||||
|
@ -722,9 +722,9 @@ nsresult nsSeamonkeyProfileMigrator::CopyMailFolders(nsVoidArray* aMailServers,
|
|||
nsCAutoString descriptorString;
|
||||
nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(targetNewsRCFile);
|
||||
localFile->GetPersistentDescriptor(descriptorString);
|
||||
nsCRT::free(pref->stringValue);
|
||||
NS_Free(pref->stringValue);
|
||||
pref->stringValue = ToNewCString(descriptorString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -738,7 +738,7 @@ nsSeamonkeyProfileMigrator::CopyPreferences(PRBool aReplace)
|
|||
if (!aReplace)
|
||||
return rv;
|
||||
|
||||
rv |= TransformPreferences(FILE_NAME_PREFS, FILE_NAME_PREFS);
|
||||
rv |= TransformPreferences(FILE_NAME_PREFS, FILE_NAME_PREFS);
|
||||
rv |= CopyFile(FILE_NAME_USER_PREFS, FILE_NAME_USER_PREFS);
|
||||
|
||||
// Security Stuff
|
||||
|
@ -753,7 +753,7 @@ nsSeamonkeyProfileMigrator::CopyPreferences(PRBool aReplace)
|
|||
return rv;
|
||||
}
|
||||
|
||||
void nsSeamonkeyProfileMigrator::ReadBranch(const char * branchName, nsIPrefService* aPrefService,
|
||||
void nsSeamonkeyProfileMigrator::ReadBranch(const char * branchName, nsIPrefService* aPrefService,
|
||||
nsVoidArray* aPrefs)
|
||||
{
|
||||
// Enumerate the branch
|
||||
|
@ -786,8 +786,8 @@ void nsSeamonkeyProfileMigrator::ReadBranch(const char * branchName, nsIPrefServ
|
|||
case nsIPrefBranch::PREF_INVALID:
|
||||
{
|
||||
nsCOMPtr<nsIPrefLocalizedString> str;
|
||||
rv = branch->GetComplexValue(currPref,
|
||||
NS_GET_IID(nsIPrefLocalizedString),
|
||||
rv = branch->GetComplexValue(currPref,
|
||||
NS_GET_IID(nsIPrefLocalizedString),
|
||||
getter_AddRefs(str));
|
||||
if (NS_SUCCEEDED(rv) && str)
|
||||
str->ToString(&pref->wstringValue);
|
||||
|
@ -816,7 +816,7 @@ nsSeamonkeyProfileMigrator::WriteBranch(const char * branchName, nsIPrefService*
|
|||
switch (pref->type) {
|
||||
case nsIPrefBranch::PREF_STRING:
|
||||
rv = branch->SetCharPref(pref->prefName, pref->stringValue);
|
||||
nsCRT::free(pref->stringValue);
|
||||
NS_Free(pref->stringValue);
|
||||
pref->stringValue = nsnull;
|
||||
break;
|
||||
case nsIPrefBranch::PREF_BOOL:
|
||||
|
@ -828,14 +828,14 @@ nsSeamonkeyProfileMigrator::WriteBranch(const char * branchName, nsIPrefService*
|
|||
case nsIPrefBranch::PREF_INVALID:
|
||||
nsCOMPtr<nsIPrefLocalizedString> pls(do_CreateInstance("@mozilla.org/pref-localizedstring;1"));
|
||||
pls->SetData(pref->wstringValue);
|
||||
rv = branch->SetComplexValue(pref->prefName,
|
||||
rv = branch->SetComplexValue(pref->prefName,
|
||||
NS_GET_IID(nsIPrefLocalizedString),
|
||||
pls);
|
||||
nsCRT::free(pref->wstringValue);
|
||||
NS_Free(pref->wstringValue);
|
||||
pref->wstringValue = nsnull;
|
||||
break;
|
||||
}
|
||||
nsCRT::free(pref->prefName);
|
||||
NS_Free(pref->prefName);
|
||||
pref->prefName = nsnull;
|
||||
delete pref;
|
||||
pref = nsnull;
|
||||
|
@ -903,15 +903,15 @@ nsresult NS_MsgHashIfNecessary(nsCString &name)
|
|||
nsCAutoString str(name);
|
||||
|
||||
// Given a filename, make it safe for filesystem
|
||||
// certain filenames require hashing because they
|
||||
// certain filenames require hashing because they
|
||||
// are too long or contain illegal characters
|
||||
PRInt32 illegalCharacterIndex = str.FindCharInSet(illegalChars);
|
||||
char hashedname[MAX_LEN + 1];
|
||||
if (illegalCharacterIndex == kNotFound)
|
||||
if (illegalCharacterIndex == kNotFound)
|
||||
{
|
||||
// no illegal chars, it's just too long
|
||||
// keep the initial part of the string, but hash to make it fit
|
||||
if (str.Length() > MAX_LEN)
|
||||
if (str.Length() > MAX_LEN)
|
||||
{
|
||||
PL_strncpy(hashedname, str.get(), MAX_LEN + 1);
|
||||
PR_snprintf(hashedname + MAX_LEN - 8, 9, "%08lx",
|
||||
|
@ -919,7 +919,7 @@ nsresult NS_MsgHashIfNecessary(nsCString &name)
|
|||
name = hashedname;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
// found illegal chars, hash the whole thing
|
||||
// if we do substitution, then hash, two strings
|
||||
|
@ -931,6 +931,6 @@ nsresult NS_MsgHashIfNecessary(nsCString &name)
|
|||
(unsigned long) StringHash(str.get()));
|
||||
name = hashedname;
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "nsMailWinIntegration.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsNativeCharsetUtils.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
@ -66,17 +65,17 @@ OpenUserKeyForReading(HKEY aStartKey, const char* aKeyName, HKEY* aKey)
|
|||
{
|
||||
DWORD result = ::RegOpenKeyEx(aStartKey, aKeyName, 0, KEY_READ, aKey);
|
||||
|
||||
switch (result)
|
||||
switch (result)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
break;
|
||||
case ERROR_ACCESS_DENIED:
|
||||
return NS_ERROR_FILE_ACCESS_DENIED;
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
if (aStartKey == HKEY_LOCAL_MACHINE)
|
||||
if (aStartKey == HKEY_LOCAL_MACHINE)
|
||||
{
|
||||
// prevent infinite recursion on the second pass through here if
|
||||
// ::RegOpenKeyEx fails in the all-users case.
|
||||
// prevent infinite recursion on the second pass through here if
|
||||
// ::RegOpenKeyEx fails in the all-users case.
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
return OpenUserKeyForReading(HKEY_LOCAL_MACHINE, aKeyName, aKey);
|
||||
|
@ -94,7 +93,7 @@ static nsresult OpenKeyForWriting(HKEY aStartKey, const char* aKeyName, HKEY* aK
|
|||
DWORD rv = ::RegCreateKeyEx(aStartKey, aKeyName, 0, NULL, 0,
|
||||
KEY_READ | KEY_WRITE, NULL, aKey, &dwDisp);
|
||||
|
||||
switch (rv)
|
||||
switch (rv)
|
||||
{
|
||||
case ERROR_SUCCESS:
|
||||
break;
|
||||
|
@ -108,9 +107,9 @@ static nsresult OpenKeyForWriting(HKEY aStartKey, const char* aKeyName, HKEY* aK
|
|||
rv = ::RegCreateKey(aStartKey, aKeyName, aKey);
|
||||
if (rv != ERROR_SUCCESS)
|
||||
{
|
||||
if (aHKLMOnly || aStartKey == HKEY_CURRENT_USER)
|
||||
if (aHKLMOnly || aStartKey == HKEY_CURRENT_USER)
|
||||
{
|
||||
// prevent infinite recursion on the second pass through here if
|
||||
// prevent infinite recursion on the second pass through here if
|
||||
// ::RegCreateKey fails in the current user case.
|
||||
return NS_ERROR_FILE_ACCESS_DENIED;
|
||||
}
|
||||
|
@ -139,7 +138,7 @@ typedef enum { NO_SUBSTITUTION = 0x00,
|
|||
#define MOZ_CLIENT_MAIL_KEY "Software\\Clients\\Mail"
|
||||
#define MOZ_CLIENT_NEWS_KEY "Software\\Clients\\News"
|
||||
#define DI "\\DefaultIcon"
|
||||
#define II "\\InstallInfo"
|
||||
#define II "\\InstallInfo"
|
||||
|
||||
// APP_REG_NAME_MAIL and APP_REG_NAME_NEWS should be kept in synch with
|
||||
// AppRegNameMail and AppRegNameNews in the installer file: defines.nsi.in
|
||||
|
@ -176,15 +175,15 @@ static SETTING gMailSettings[] = {
|
|||
// Protocol Handler Class - for Vista and above
|
||||
{ MAKE_KEY_NAME2(CLS, CLS_MAILTOURL, DI), "", VAL_ICON, APP_PATH_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(CLS, CLS_MAILTOURL, SOP), "", "\"%APPPATH%\" -compose \"%1\"", APP_PATH_SUBSTITUTION },
|
||||
|
||||
|
||||
// Protocol Handlers
|
||||
{ MAKE_KEY_NAME2(CLS, "mailto", DI), "", VAL_ICON, APP_PATH_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(CLS, "mailto", SOP), "", "\"%APPPATH%\" -compose \"%1\"", APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST},
|
||||
{ MAKE_KEY_NAME2(CLS, "mailto", SOP), "", "\"%APPPATH%\" -compose \"%1\"", APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST},
|
||||
|
||||
// Mail Client Keys
|
||||
{ MAKE_KEY_NAME1(MAILCLIENTS, "%APPNAME%"),
|
||||
"DLLPath",
|
||||
"%MAPIDLLPATH%",
|
||||
{ MAKE_KEY_NAME1(MAILCLIENTS, "%APPNAME%"),
|
||||
"DLLPath",
|
||||
"%MAPIDLLPATH%",
|
||||
MAPIDLL_PATH_SUBSTITUTION | HKLM_ONLY | APPNAME_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%", II),
|
||||
"HideIconsCommand",
|
||||
|
@ -198,17 +197,17 @@ static SETTING gMailSettings[] = {
|
|||
"ShowIconsCommand",
|
||||
"\"%UNINSTPATH%\" /ShowShortcuts",
|
||||
UNINST_PATH_SUBSTITUTION | APPNAME_SUBSTITUTION | HKLM_ONLY },
|
||||
{ MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%", DI),
|
||||
"",
|
||||
"%APPPATH%,0",
|
||||
{ MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%", DI),
|
||||
"",
|
||||
"%APPPATH%,0",
|
||||
APP_PATH_SUBSTITUTION | APPNAME_SUBSTITUTION | HKLM_ONLY },
|
||||
{ MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%", SOP),
|
||||
"",
|
||||
"\"%APPPATH%\" -mail",
|
||||
{ MAKE_KEY_NAME2(MAILCLIENTS, "%APPNAME%", SOP),
|
||||
"",
|
||||
"\"%APPPATH%\" -mail",
|
||||
APP_PATH_SUBSTITUTION | APPNAME_SUBSTITUTION | HKLM_ONLY },
|
||||
{ MAKE_KEY_NAME1(MAILCLIENTS, "%APPNAME%\\shell\\properties\\command"),
|
||||
"",
|
||||
"\"%APPPATH%\" -options",
|
||||
"",
|
||||
"\"%APPPATH%\" -options",
|
||||
APP_PATH_SUBSTITUTION | APPNAME_SUBSTITUTION | HKLM_ONLY },
|
||||
};
|
||||
|
||||
|
@ -221,22 +220,22 @@ static SETTING gNewsSettings[] = {
|
|||
{ MAKE_KEY_NAME2(CLS, "news", DI), "", VAL_ICON, APP_PATH_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(CLS, "news", SOP), "", "\"%APPPATH%\" -mail \"%1\"", APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST},
|
||||
{ MAKE_KEY_NAME2(CLS, "nntp", DI), "", VAL_ICON, APP_PATH_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(CLS, "nntp", SOP), "", "\"%APPPATH%\" -mail \"%1\"", APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST},
|
||||
{ MAKE_KEY_NAME2(CLS, "nntp", SOP), "", "\"%APPPATH%\" -mail \"%1\"", APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST},
|
||||
{ MAKE_KEY_NAME2(CLS, "snews", DI), "", VAL_ICON, APP_PATH_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(CLS, "snews", SOP), "", "\"%APPPATH%\" -mail \"%1\"", APP_PATH_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(CLS, "snews", SOP), "", "\"%APPPATH%\" -mail \"%1\"", APP_PATH_SUBSTITUTION},
|
||||
|
||||
// News Client Keys
|
||||
{ MAKE_KEY_NAME1(NEWSCLIENTS, "%APPNAME%"),
|
||||
"DLLPath",
|
||||
"%MAPIDLLPATH%",
|
||||
{ MAKE_KEY_NAME1(NEWSCLIENTS, "%APPNAME%"),
|
||||
"DLLPath",
|
||||
"%MAPIDLLPATH%",
|
||||
MAPIDLL_PATH_SUBSTITUTION | APPNAME_SUBSTITUTION | HKLM_ONLY },
|
||||
{ MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%", DI),
|
||||
"",
|
||||
"%APPPATH%,0",
|
||||
{ MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%", DI),
|
||||
"",
|
||||
"%APPPATH%,0",
|
||||
APP_PATH_SUBSTITUTION | APPNAME_SUBSTITUTION | HKLM_ONLY },
|
||||
{ MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%", SOP),
|
||||
"",
|
||||
"\"%APPPATH%\" -mail",
|
||||
{ MAKE_KEY_NAME2(NEWSCLIENTS, "%APPNAME%", SOP),
|
||||
"",
|
||||
"\"%APPPATH%\" -mail",
|
||||
APP_PATH_SUBSTITUTION | APPNAME_SUBSTITUTION | HKLM_ONLY },
|
||||
};
|
||||
|
||||
|
@ -244,7 +243,7 @@ static SETTING gFeedSettings[] = {
|
|||
// Protocol Handler Class - for Vista and above
|
||||
{ MAKE_KEY_NAME2(CLS, CLS_FEEDURL, DI), "", VAL_ICON, APP_PATH_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(CLS, CLS_FEEDURL, SOP), "", VAL_OPEN, APP_PATH_SUBSTITUTION },
|
||||
|
||||
|
||||
// Protocol Handlers
|
||||
{ MAKE_KEY_NAME2(CLS, "feed", DI), "", VAL_ICON, APP_PATH_SUBSTITUTION},
|
||||
{ MAKE_KEY_NAME2(CLS, "feed", SOP), "", "\"%APPPATH%\" -mail \"%1\"", APP_PATH_SUBSTITUTION | USE_FOR_DEFAULT_TEST},
|
||||
|
@ -256,7 +255,7 @@ nsresult nsWindowsShellService::Init()
|
|||
|
||||
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
||||
nsCOMPtr<nsIStringBundle> bundle, brandBundle;
|
||||
rv = bundleService->CreateBundle("chrome://branding/locale/brand.properties", getter_AddRefs(brandBundle));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -313,7 +312,7 @@ nsWindowsShellService::IsDefaultClient(PRBool aStartupCheck, PRUint16 aApps, PRB
|
|||
|
||||
*aIsDefaultClient = PR_TRUE;
|
||||
|
||||
// for each type,
|
||||
// for each type,
|
||||
if (aApps & nsIShellService::MAIL)
|
||||
*aIsDefaultClient &= TestForDefault(gMailSettings, sizeof(gMailSettings)/sizeof(SETTING));
|
||||
if (aApps & nsIShellService::NEWS)
|
||||
|
@ -322,7 +321,7 @@ nsWindowsShellService::IsDefaultClient(PRBool aStartupCheck, PRUint16 aApps, PRB
|
|||
*aIsDefaultClient &= TestForDefault(gFeedSettings, sizeof(gFeedSettings)/sizeof(SETTING));
|
||||
|
||||
// If this is the first mail window, maintain internal state that we've
|
||||
// checked this session (so that subsequent window opens don't show the
|
||||
// checked this session (so that subsequent window opens don't show the
|
||||
// default client dialog).
|
||||
if (aStartupCheck)
|
||||
mCheckedThisSession = PR_TRUE;
|
||||
|
@ -383,7 +382,7 @@ nsWindowsShellService::SetDefaultClient(PRBool aForAllUsers, PRUint16 aApps)
|
|||
rv |= setDefaultNews();
|
||||
|
||||
if (aApps & nsIShellService::RSS)
|
||||
setKeysForSettings(gFeedSettings, sizeof(gFeedSettings)/sizeof(SETTING),
|
||||
setKeysForSettings(gFeedSettings, sizeof(gFeedSettings)/sizeof(SETTING),
|
||||
NS_ConvertUTF16toUTF8(mBrandFullName).get());
|
||||
|
||||
// Refresh the Shell
|
||||
|
@ -394,7 +393,7 @@ nsWindowsShellService::SetDefaultClient(PRBool aForAllUsers, PRUint16 aApps)
|
|||
NS_IMETHODIMP
|
||||
nsWindowsShellService::GetShouldCheckDefaultClient(PRBool* aResult)
|
||||
{
|
||||
if (mCheckedThisSession)
|
||||
if (mCheckedThisSession)
|
||||
{
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
|
@ -418,7 +417,7 @@ nsWindowsShellService::setDefaultMail()
|
|||
NS_ConvertUTF16toUTF8 appName(mBrandFullName);
|
||||
setKeysForSettings(gMailSettings, sizeof(gMailSettings)/sizeof(SETTING), appName.get());
|
||||
|
||||
// at least for now, this key needs to be written to HKLM instead of HKCU
|
||||
// at least for now, this key needs to be written to HKLM instead of HKCU
|
||||
// which is where the windows operating system looks (at least on Win XP and earlier)
|
||||
SetRegKey(NS_LITERAL_CSTRING(MOZ_CLIENT_MAIL_KEY).get(), "", appName.get(), PR_TRUE);
|
||||
|
||||
|
@ -468,7 +467,7 @@ nsWindowsShellService::setDefaultNews()
|
|||
NS_ConvertUTF16toUTF8 appName(mBrandFullName);
|
||||
setKeysForSettings(gNewsSettings, sizeof(gNewsSettings)/sizeof(SETTING), appName.get());
|
||||
|
||||
// at least for now, this key needs to be written to HKLM instead of HKCU
|
||||
// at least for now, this key needs to be written to HKLM instead of HKCU
|
||||
// which is where the windows operating system looks (at least on Win XP and earlier)
|
||||
SetRegKey(NS_LITERAL_CSTRING(MOZ_CLIENT_NEWS_KEY).get(), "", appName.get(), PR_TRUE);
|
||||
|
||||
|
@ -486,7 +485,7 @@ nsWindowsShellService::setDefaultNews()
|
|||
DWORD
|
||||
nsWindowsShellService::DeleteRegKey(HKEY baseKey, const char *keyName)
|
||||
{
|
||||
// Make sure input subkey isn't null.
|
||||
// Make sure input subkey isn't null.
|
||||
if (!keyName || !::strlen(keyName))
|
||||
return ERROR_BADKEY;
|
||||
|
||||
|
@ -494,9 +493,9 @@ nsWindowsShellService::DeleteRegKey(HKEY baseKey, const char *keyName)
|
|||
// Open subkey.
|
||||
HKEY key;
|
||||
rc = ::RegOpenKeyEx(baseKey, keyName, 0, KEY_ENUMERATE_SUB_KEYS | DELETE, &key);
|
||||
|
||||
|
||||
// Continue till we get an error or are done.
|
||||
while (rc == ERROR_SUCCESS)
|
||||
while (rc == ERROR_SUCCESS)
|
||||
{
|
||||
char subkeyName[_MAX_PATH];
|
||||
DWORD len = sizeof subkeyName;
|
||||
|
@ -504,26 +503,26 @@ nsWindowsShellService::DeleteRegKey(HKEY baseKey, const char *keyName)
|
|||
// first one, then delete it. So we need to get
|
||||
// the first one next time, also.
|
||||
rc = ::RegEnumKeyEx(key, 0, subkeyName, &len, 0, 0, 0, 0);
|
||||
if (rc == ERROR_NO_MORE_ITEMS)
|
||||
if (rc == ERROR_NO_MORE_ITEMS)
|
||||
{
|
||||
// No more subkeys. Delete the main one.
|
||||
rc = ::RegDeleteKey(baseKey, keyName);
|
||||
break;
|
||||
}
|
||||
if (rc == ERROR_SUCCESS)
|
||||
}
|
||||
if (rc == ERROR_SUCCESS)
|
||||
{
|
||||
// Another subkey, delete it, recursively.
|
||||
rc = DeleteRegKey(key, subkeyName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Close the key we opened.
|
||||
::RegCloseKey(key);
|
||||
return rc;
|
||||
}
|
||||
|
||||
void
|
||||
nsWindowsShellService::SetRegKey(const char* aKeyName, const char* aValueName,
|
||||
nsWindowsShellService::SetRegKey(const char* aKeyName, const char* aValueName,
|
||||
const char* aValue, PRBool aHKLMOnly)
|
||||
{
|
||||
char buf[MAX_BUF];
|
||||
|
@ -539,16 +538,16 @@ nsWindowsShellService::SetRegKey(const char* aKeyName, const char* aValueName,
|
|||
|
||||
// Set the new value
|
||||
if (REG_FAILED(result) || strcmp(buf, aValue) != 0)
|
||||
::RegSetValueEx(theKey, aValueName, 0, REG_SZ,
|
||||
::RegSetValueEx(theKey, aValueName, 0, REG_SZ,
|
||||
(LPBYTE)aValue, nsDependentCString(aValue).Length());
|
||||
|
||||
|
||||
// Close the key we opened.
|
||||
::RegCloseKey(theKey);
|
||||
}
|
||||
|
||||
/* helper routine. Iterate over the passed in settings object,
|
||||
testing each key with the USE_FOR_DEFAULT_TEST to see if
|
||||
we are handling it.
|
||||
testing each key with the USE_FOR_DEFAULT_TEST to see if
|
||||
we are handling it.
|
||||
*/
|
||||
PRBool
|
||||
nsWindowsShellService::TestForDefault(SETTING aSettings[], PRInt32 aSize)
|
||||
|
@ -557,7 +556,7 @@ nsWindowsShellService::TestForDefault(SETTING aSettings[], PRInt32 aSize)
|
|||
NS_ConvertUTF16toUTF8 appName(mBrandFullName);
|
||||
char currValue[MAX_BUF];
|
||||
SETTING* end = aSettings + aSize;
|
||||
for (SETTING * settings = aSettings; settings < end; ++settings)
|
||||
for (SETTING * settings = aSettings; settings < end; ++settings)
|
||||
{
|
||||
if (settings->flags & USE_FOR_DEFAULT_TEST)
|
||||
{
|
||||
|
@ -573,9 +572,9 @@ nsWindowsShellService::TestForDefault(SETTING aSettings[], PRInt32 aSize)
|
|||
else
|
||||
dataShortPath.Replace(offset, 9, mAppShortPath);
|
||||
}
|
||||
|
||||
|
||||
nsCAutoString key(settings->keyName);
|
||||
if (settings->flags & APPNAME_SUBSTITUTION)
|
||||
if (settings->flags & APPNAME_SUBSTITUTION)
|
||||
{
|
||||
PRInt32 offset = key.Find("%APPNAME%");
|
||||
key.Replace(offset, 9, appName);
|
||||
|
@ -584,7 +583,7 @@ nsWindowsShellService::TestForDefault(SETTING aSettings[], PRInt32 aSize)
|
|||
::ZeroMemory(currValue, sizeof(currValue));
|
||||
HKEY theKey;
|
||||
nsresult rv = OpenUserKeyForReading(HKEY_CURRENT_USER, key.get(), &theKey);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
DWORD len = sizeof currValue;
|
||||
DWORD result = ::RegQueryValueEx(theKey, settings->valueName, NULL, NULL, (LPBYTE)currValue, &len);
|
||||
|
@ -608,35 +607,35 @@ nsWindowsShellService::TestForDefault(SETTING aSettings[], PRInt32 aSize)
|
|||
* in the windows registry.
|
||||
*/
|
||||
|
||||
void
|
||||
void
|
||||
nsWindowsShellService::setKeysForSettings(SETTING aSettings[], PRInt32 aSize, const char * aAppName)
|
||||
{
|
||||
SETTING* settings;
|
||||
SETTING* end = aSettings + aSize;
|
||||
PRInt32 offset;
|
||||
|
||||
for (settings = aSettings; settings < end; ++settings)
|
||||
for (settings = aSettings; settings < end; ++settings)
|
||||
{
|
||||
nsCAutoString data(settings->valueData);
|
||||
nsCAutoString key(settings->keyName);
|
||||
if (settings->flags & APP_PATH_SUBSTITUTION)
|
||||
if (settings->flags & APP_PATH_SUBSTITUTION)
|
||||
{
|
||||
offset = data.Find("%APPPATH%");
|
||||
data.Replace(offset, 9, mAppLongPath);
|
||||
}
|
||||
if (settings->flags & MAPIDLL_PATH_SUBSTITUTION)
|
||||
if (settings->flags & MAPIDLL_PATH_SUBSTITUTION)
|
||||
{
|
||||
offset = data.Find("%MAPIDLLPATH%");
|
||||
data.Replace(offset, 13, mMapiDLLPath);
|
||||
}
|
||||
if (settings->flags & APPNAME_SUBSTITUTION)
|
||||
if (settings->flags & APPNAME_SUBSTITUTION)
|
||||
{
|
||||
offset = key.Find("%APPNAME%");
|
||||
key.Replace(offset, 9, aAppName);
|
||||
}
|
||||
if (settings->flags & UNINST_PATH_SUBSTITUTION)
|
||||
if (settings->flags & UNINST_PATH_SUBSTITUTION)
|
||||
{
|
||||
offset = data.Find("%UNINSTPATH%");
|
||||
offset = data.Find("%UNINSTPATH%");
|
||||
data.Replace(offset, 12, mUninstallPath);
|
||||
}
|
||||
|
||||
|
@ -644,7 +643,7 @@ nsWindowsShellService::setKeysForSettings(SETTING aSettings[], PRInt32 aSize, co
|
|||
}
|
||||
}
|
||||
|
||||
// Support for versions of shlobj.h that don't include the Vista API's
|
||||
// Support for versions of shlobj.h that don't include the Vista API's
|
||||
#if !defined(IApplicationAssociationRegistration)
|
||||
|
||||
typedef enum tagASSOCIATIONLEVEL
|
||||
|
@ -699,7 +698,7 @@ nsWindowsShellService::IsDefaultClientVista(PRBool aStartupCheck, PRUint16 aApps
|
|||
CLSCTX_INPROC,
|
||||
IID_IApplicationAssociationReg,
|
||||
(void**)&pAAR);
|
||||
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
PRBool isDefaultMail = PR_TRUE;
|
||||
|
@ -709,18 +708,18 @@ nsWindowsShellService::IsDefaultClientVista(PRBool aStartupCheck, PRUint16 aApps
|
|||
if (aApps & nsIShellService::NEWS)
|
||||
pAAR->QueryAppIsDefaultAll(AL_EFFECTIVE, APP_REG_NAME_NEWS, &isDefaultNews);
|
||||
|
||||
*aIsDefaultClient = isDefaultNews && isDefaultMail;
|
||||
|
||||
*aIsDefaultClient = isDefaultNews && isDefaultMail;
|
||||
|
||||
// If this is the first mail window, maintain internal state that we've
|
||||
// checked this session (so that subsequent window opens don't show the
|
||||
// checked this session (so that subsequent window opens don't show the
|
||||
// default browser dialog).
|
||||
if (aStartupCheck)
|
||||
mCheckedThisSession = PR_TRUE;
|
||||
|
||||
|
||||
pAAR->Release();
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
@ -734,17 +733,17 @@ nsWindowsShellService::SetDefaultClientVista(PRUint16 aApps)
|
|||
CLSCTX_INPROC,
|
||||
IID_IApplicationAssociationReg,
|
||||
(void**)&pAAR);
|
||||
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
if (aApps & nsIShellService::MAIL)
|
||||
hr = pAAR->SetAppAsDefaultAll(APP_REG_NAME_MAIL);
|
||||
if (aApps & nsIShellService::NEWS)
|
||||
hr = pAAR->SetAppAsDefaultAll(APP_REG_NAME_NEWS);
|
||||
|
||||
hr = pAAR->SetAppAsDefaultAll(APP_REG_NAME_NEWS);
|
||||
|
||||
pAAR->Release();
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче