fix for #18118. if the pref "profile.confirm_automigration" is true,

we put up a dialog before we auto migrate.  (the mozilla build does this.)
if that pref is false, we just automigrate.  (the ns build does this.)
r=bienvenu
This commit is contained in:
sspitzer%netscape.com 1999-12-23 20:05:59 +00:00
Родитель 69a1d9162a
Коммит e9b7b34cca
13 изменённых файлов: 97 добавлений и 111 удалений

Просмотреть файл

@ -90,6 +90,8 @@ interface nsIProfile : nsISupports {
void migrateAllProfiles();
void cloneProfile(in string profileName);
void forgetCurrentProfile();
attribute boolean automigrate;
};
#endif /* nsIProfile_h__ */

Просмотреть файл

@ -11,3 +11,5 @@ profileManager.xul
renameProfile.xul
profileSelection.js
profileSelection.xul
confirmMigration.xul
confirmMigration.js

Просмотреть файл

@ -41,6 +41,8 @@ FILES = \
newProfile1_2.js \
profileSelection.xul \
profileSelection.js \
confirmMigration.xul \
confirmMigration.js \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -17,19 +17,20 @@
<html:script language="javascript" src="chrome://profile/content/confirmMigration.js"/>
<box align="horizontal" flex="100%">
<html:div>
<html:img src="chrome://global/skin/question-icon.gif"/>
</html:div>
<spring style="height: 4em;"/>
<box align="vertical" flex="100%">
<html:div>
&confirmMigrationPart1.label;
</html:div>
<html:div>
&confirmMigrationPart2.label;
</html:div>
<html:div>
&confirmMigrationPart3.label;
</html:div>
<html:center>
<html:div> &confirmMigrationPart1.label; </html:div>
<html:div> &confirmMigrationPart2.label; </html:div>
<html:div> &confirmMigrationPart3.label; </html:div>
<html:div> &confirmMigrationPart4.label; </html:div>
</html:center>
</box>
</box>
<spring style="height: 1em;"/>
<box id="okCancelButtons"/>
<spring style="height: 1em;"/>
</window>

Просмотреть файл

@ -38,6 +38,8 @@ FILES=\
renameProfile.xul \
profileSelection.xul \
profileSelection.js \
confirmMigration.xul \
confirmMigration.js \
$(NULL)
install::

Просмотреть файл

@ -1,77 +0,0 @@
<?xml version="1.0"?> <!-- -*- Mode: SGML; indent-tabs-mode: nil; -*- -->
<!--
The contents of this file are subject to the Netscape Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is mozilla.org code.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998 Netscape Communications Corporation. All
Rights Reserved.
Contributor(s):
-->
<?xml-stylesheet href="chrome://profile/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://profile/skin/profileManager.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://profile/locale/profileManager.dtd" >
<window xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
class="dialog"
title="&windowtitle.label;"
onload="loadElements();"
align="vertical">
<!--don't add overall window margins here, this will be added later via class=dialog mechanism
once window padding works!-->
<html:script language="javascript" src="profileManager.js"/>
<html:div id="dialoginfo">&intro;</html:div>
<spring style="height: 1em;"/>
<html:div>&intro.new;</html:div>
<html:div>&intro.delete;</html:div>
<html:div>&intro.rename;</html:div>
<spring style="height: 1em;"/>
<box id="table-box" align="horizontal">
<html:div id="table-housing" flex="100%">
<tree id="tree" onclick="return showSelection(event.target.parentNode);">
<treecol style="width: 25%"/>
<treecol style="width: 50%"/>
<treehead>
<treerow>
<treecell value="&migration.label;"/>
<treecell value="&user.label;"/>
</treerow>
</treehead>
<treechildren id="theTreeBody">
</treechildren>
</tree>
</html:div>
<box align="vertical" id="buttons-box">
<titledbutton class="dialog push" value="&newCmd.label;" onclick="openCreateProfile();" />
<titledbutton class="dialog push" id="rename" disabled="true" value="&renameCmd.label;" onclick="openRename();" />
<titledbutton class="dialog push" id="delete" disabled="true" value="&deleteCmd.label;" onclick="ConfirmDelete();" />
<spring style="height: 1em;"/>
<titledbutton class="dialog push" id="start" disabled="true" value="&startCmd.label;" onclick="onStart();" />
<titledbutton class="dialog push" value="&exitCmd.label;" onclick="onExit();" />
</box>
</box>
</window>

Просмотреть файл

@ -8,3 +8,4 @@ profileManagerRename.dtd
createProfileWizard.properties
newProfile1_2.properties
profileSelection.dtd
confirmMigration.dtd

Просмотреть файл

@ -38,6 +38,7 @@ FILES = \
createProfileWizard.properties \
newProfile1_2.properties \
profileSelection.dtd \
confirmMigration.dtd \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,4 +1,5 @@
<!ENTITY window.title "Confirm Migration">
<!ENTITY confirmMigrationPart1.label "You are about to migrate your 4.x profile.">
<!ENTITY confirmMigrationPart2.label "Are you sure you want to do this?">
<!ENTITY confirmMigrationPart3.label "(If you click no, you can always do it later.)">
<!ENTITY confirmMigrationPart1.label "You are about to create a 5.0 profile based on your 4.x Netscape profile.">
<!ENTITY confirmMigrationPart2.label "This will copy some of your Netscape 4.x files.">
<!ENTITY confirmMigrationPart3.label "Click OK if you want to proceed with automigration.">
<!ENTITY confirmMigrationPart4.label "(If you click Cancel, you can always do it later.)">

Просмотреть файл

@ -35,6 +35,7 @@ FILES=\
createProfileWizard.properties \
newProfile1_2.properties \
profileSelection.dtd \
confirmMigration.dtd \
$(NULL)
install::

Просмотреть файл

@ -1,15 +0,0 @@
<!-- extracted from pm.xul -->
<!ENTITY reg.gif "reg.gif">
<!ENTITY intro "Mozilla stores information about your settings, preferences, bookmarks, and stored messages in your personal Mozilla Name.">
<!ENTITY intro.new "Click New to create a new Mozilla Name.">
<!ENTITY intro.delete "Click Delete to remove a selected Mozilla Name.">
<!ENTITY intro.rename "Click Rename to change the name of a selected Mozilla Name.">
<!ENTITY migration.label "Migration">
<!ENTITY user.label "User Name">
<!ENTITY newCmd.label "New...">
<!ENTITY renameCmd.label "Rename...">
<!ENTITY deleteCmd.label "Delete">
<!ENTITY startCmd.label "Start">
<!ENTITY exitCmd.label "Exit">
<!ENTITY windowtitle.label "Profiles and Migration">

Просмотреть файл

@ -85,11 +85,14 @@
#define PROFILE_MANAGER_URL "chrome://profile/content/profileManager.xul"
#define PROFILE_MANAGER_CMD_LINE_ARG "-ProfileManager"
#define PROFILE_WIZARD_URL "chrome://profile/content/createProfileWizard.xul"
#define CONFIRM_AUTOMIGRATE_URL "chrome://profile/content/confirmMigration.xul"
#define PROFILE_WIZARD_CMD_LINE_ARG "-ProfileWizard"
#define INSTALLER_CMD_LINE_ARG "-installer"
#define CREATE_PROFILE_CMD_LINE_ARG "-CreateProfile"
#define PROFILE_CMD_LINE_ARG "-P"
#define PREF_CONFIRM_AUTOMIGRATION "profile.confirm_automigration"
#if defined(DEBUG_sspitzer) || defined(DEBUG_seth)
#define DEBUG_profile_ 1
#endif
@ -140,6 +143,8 @@ nsresult GetStringFromSpec(nsFileSpec inSpec, char **string)
*/
nsProfile::nsProfile()
{
mAutomigrate = PR_FALSE;
if(!gProfileDataAccess)
gProfileDataAccess = new nsProfileAccess();
@ -177,6 +182,20 @@ NS_IMETHODIMP nsProfile::Startup(const char *filename)
return NS_OK;
}
NS_IMETHODIMP
nsProfile::GetAutomigrate(PRBool *aAutomigrate)
{
if (!aAutomigrate) return NS_ERROR_NULL_POINTER;
*aAutomigrate = mAutomigrate;
return NS_OK;
}
NS_IMETHODIMP
nsProfile::SetAutomigrate(PRBool aAutomigrate)
{
mAutomigrate = aAutomigrate;
return NS_OK;
}
NS_IMETHODIMP
nsProfile::StartupWithArgs(nsICmdLineService *cmdLineArgs)
{
@ -278,6 +297,30 @@ nsProfile::LoadDefaultProfileDir(nsCString & profileURLStr)
rv = profAppShell->Run();
}
PRBool confirmAutomigration = PR_FALSE;
if (NS_SUCCEEDED(rv) && prefs) {
rv = prefs->GetBoolPref(PREF_CONFIRM_AUTOMIGRATION, &confirmAutomigration);
if (NS_FAILED(rv)) confirmAutomigration = PR_FALSE;
}
if (confirmAutomigration) {
if (profileURLStr == (const char *)(CONFIRM_AUTOMIGRATE_URL)) {
PRBool automigrate = PR_FALSE;
rv = GetAutomigrate(&automigrate);
if (NS_SUCCEEDED(rv) && automigrate) {
AutoMigrate();
}
else {
// the user hit cancel.
// so they don't want to automatically migrate
// so call this again with the profile manager ui
nsCString profileManagerUrl(PROFILE_MANAGER_URL);
rv = LoadDefaultProfileDir(profileManagerUrl);
return rv;
}
}
}
// if we get here, and we don't have a current profile,
// return a failure so we will exit
// this can happen, if the user hits Exit in the profile manager dialog
@ -298,6 +341,16 @@ nsProfile::LoadDefaultProfileDir(nsCString & profileURLStr)
return rv;
}
nsresult
nsProfile::AutoMigrate()
{
// automatically migrate the one 4.x profile
MigrateAllProfiles();
gProfileDataAccess->UpdateRegistry();
return NS_OK;
}
nsresult
nsProfile::ProcessArgs(nsICmdLineService *cmdLineArgs,
PRBool* profileDirSet,
@ -425,12 +478,21 @@ nsProfile::ProcessArgs(nsICmdLineService *cmdLineArgs,
profileURLStr = PROFILE_WIZARD_URL;
}
else if (num4xProfiles == 1 && numProfiles == 0) {
// automatically migrate the one 4.x profile
MigrateAllProfiles();
gProfileDataAccess->UpdateRegistry();
}
PRBool confirmAutomigration = PR_FALSE;
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv)
if (NS_SUCCEEDED(rv) && prefs) {
rv = prefs->GetBoolPref(PREF_CONFIRM_AUTOMIGRATION, &confirmAutomigration);
if (NS_FAILED(rv)) confirmAutomigration = PR_FALSE;
}
if (confirmAutomigration) {
profileURLStr = CONFIRM_AUTOMIGRATE_URL;
}
else {
AutoMigrate();
}
}
else {
// show the profile manager
// show the profile manager
profileURLStr = PROFILE_MANAGER_URL;
}
}

Просмотреть файл

@ -41,6 +41,7 @@ private:
PRBool *profileDirSet,
nsCString & profileURLStr);
nsresult LoadDefaultProfileDir(nsCString & profileURLStr);
PRBool mAutomigrate;
public:
nsProfile();
@ -59,5 +60,7 @@ public:
// Routine that frees the memory allocated to temp profile struct
void FreeProfileStruct(ProfileStruct* aProfile);
nsresult AutoMigrate();
};