diff --git a/profile/resources/content/createProfileWizard.js b/profile/resources/content/createProfileWizard.js
index 9bd531cbd57..9e2bb080738 100644
--- a/profile/resources/content/createProfileWizard.js
+++ b/profile/resources/content/createProfileWizard.js
@@ -124,18 +124,26 @@ function processCreateProfileData( aProfName, aProfDir )
// dropout layery thing. yeah. something like that to tell them when
// it happens, not when the whole wizard is complete. blah.
if( profile.profileExists( aProfName ) ) {
- try {
- alert( bundle.GetStringFromName( "profileExists" ) );
- }
- catch(e) {
- // mac stringbundle failure. put up a ridiculous hard coded message.
- alert( "Oh Yah, the profile name you chose already exists, yah!");
- }
+ alert( bundle.GetStringFromName( "profileExists" ) );
// this is a bad but probably acceptable solution for now.
// when we add more panels, we will want a better solution.
window.frames["content"].document.getElementById("ProfileName").focus();
return false;
}
+ var invalidChars = ["/", "\\", "*", ":"];
+ for( var i = 0; i < invalidChars.length; i++ )
+ {
+ if( aProfName.indexOf( invalidChars[i] ) != -1 ) {
+ var aString = pmbundle.GetStringFromName("invalidCharA");
+ var bString = pmbundle.GetStringFromName("invalidCharB");
+ bString = bString.replace(/\s*/g,"\n");
+ var lString = aString + invalidChars[i] + bString;
+ alert( lString );
+ window.frames["content"].document.getElementById("ProfileName").focus();
+ return false;
+ }
+ }
+
profile.createNewProfile( aProfName, aProfDir );
return true;
}
@@ -159,4 +167,4 @@ function ExitApp()
// load string bundle
var bundle = srGetStrBundle("chrome://profile/locale/createProfileWizard.properties");
-
+var pmbundle = srGetStrBundle("chrome://profile/locale/profileManager.properties");
diff --git a/profile/resources/content/profileManager.js b/profile/resources/content/profileManager.js
index 16d8c107636..cc1c03bf9e4 100644
--- a/profile/resources/content/profileManager.js
+++ b/profile/resources/content/profileManager.js
@@ -28,13 +28,14 @@ var set = null;
function CreateProfileWizard()
{
// Need to call CreateNewProfile xuls
- window.openDialog('chrome://profile/content/createProfileWizard.xul', 'CPW', 'chrome');
+ window.openDialog('chrome://profile/content/createProfileWizard.xul', 'CPW', 'chrome,modal=yes');
}
// update the display to show the additional profile
function CreateProfile( aProfName, aProfDir )
{
- AddItem( "profilekids", aProfName, aProfName );
+ var profile = new Profile( aProfName, aProfDir, "yes" );
+ AddItem( "profilekids", profile );
}
// rename the selected profile
@@ -54,8 +55,8 @@ function RenameProfile()
}
else {
var selected = profileTree.selectedItems[0];
- if( selected.getAttribute("rowMigrate") == "true" ) {
- // auto migrate if the user wants to
+ if( selected.getAttribute("rowMigrate") == "no" ) {
+ // migrate if the user wants to
var lString = bundle.GetStringFromName("migratebeforerename");
lString = lString.replace(/\s*/g,"\n");
if( confirm( lString ) )
@@ -66,8 +67,21 @@ function RenameProfile()
else {
var oldName = selected.getAttribute("rowName");
var newName = prompt( bundle.GetStringFromName("renameprofilepromptA") + oldName + bundle.GetStringFromName("renameprofilepromptB"), "" );
+ dump("*** newName = |" + newName + "|\n");
if( newName == "" || !newName )
return false;
+ var invalidChars = ["/", "\\", "*", ":"];
+ for( var i = 0; i < invalidChars.length; i++ )
+ {
+ if( newName.indexOf( invalidChars[i] ) != -1 ) {
+ var aString = bundle.GetStringFromName("invalidCharA");
+ var bString = bundle.GetStringFromName("invalidCharB");
+ bString = bString.replace(/\s*/g,"\n");
+ var lString = aString + invalidChars[i] + bString;
+ alert( lString );
+ return false;
+ }
+ }
var migrate = selected.getAttribute("rowMigrate");
dump("*** oldName = "+ oldName+ ", newName = "+ newName+ ", migrate = "+ migrate+ "\n");
@@ -77,9 +91,8 @@ function RenameProfile()
selected.setAttribute( "rowName", newName );
selected.setAttribute( "profile_name", newName );
}
- catch (ex) {
- var lString = bundle.GetStringFromName("renamefailed");
- lString = lString.replace(/\s*/g,"\n");
+ catch(e) {
+ var lString = bundle.GetStringFromName("profileExists");
alert( lString );
}
}
@@ -107,7 +120,7 @@ function ConfirmDelete()
var selected = profileTree.selectedItems[0];
var name = selected.getAttribute("rowName");
- if( selected.getAttribute("rowMigrate") == "true" ) {
+ if( selected.getAttribute("rowMigrate") == "no" ) {
// auto migrate if the user wants to. THIS IS REALLY REALLY DUMB PLEASE FIX THE BACK END.
var lString = bundle.GetStringFromName("migratebeforedelete");
lString = lString.replace(/\s*/g,"\n");
@@ -171,7 +184,6 @@ function SwitchProfileManagerMode()
var manageParent = manage.parentNode;
manageParent.removeChild( manage );
profileManagerMode = "manager"; // swap the mode
- PersistAndLoadElements( selItems ); // save the selection and load elements
}
else {
prattleIndex = 0;
@@ -182,7 +194,6 @@ function SwitchProfileManagerMode()
}
buttonDisplay = "display: none;";
profileManagerMode = "selection";
- PersistAndLoadElements( selItems );
}
// swap deck
@@ -203,28 +214,6 @@ function SwitchProfileManagerMode()
set = true;
}
-// save which elements are selected in this mode and load elements into other mode,
-// then reselect selected elements
-function PersistAndLoadElements( aSelItems )
-{
- // persist the profiles that are selected;
- var profileTree = document.getElementById("profiles");
- var selItemNodes = profileTree.selectedItems;
- for( var i = 0; i < selItemNodes.length; i++ )
- {
- aSelItems[i] = selItemNodes[i].getAttribute("profile_name");
- }
- loadElements(); // reload list of profiles
- for( var i = 0; i < aSelItems.length; i++ )
- {
- var item = document.getElementsByAttribute("profile_name", aSelItems[i]);
- if( item.length ) {
- var item = item[0];
- profileTree.addItemToSelection( item );
- }
- }
-}
-
// change the title of the profile manager/selection window.
function ChangeCaption( aCaption )
{
diff --git a/profile/resources/content/profileSelection.js b/profile/resources/content/profileSelection.js
index 65f7860e9b0..efc6ea52259 100644
--- a/profile/resources/content/profileSelection.js
+++ b/profile/resources/content/profileSelection.js
@@ -30,6 +30,14 @@ if (profile)
profile = profile.QueryInterface(Components.interfaces.nsIProfile);
var unset = true;
+var RDF = Components.classes['component://netscape/rdf/rdf-service'].getService();
+RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
+
+var Registry;
+var REGISTRY_NAMESPACE_URI = 'urn:mozilla-registry:'
+var REGISTRY_VALUE_PREFIX = REGISTRY_NAMESPACE_URI + 'value:';
+var kRegistry_Subkeys = RDF.GetResource(REGISTRY_NAMESPACE_URI + 'subkeys');
+
function StartUp()
{
SetUpOKCancelButtons();
@@ -37,6 +45,11 @@ function StartUp()
if(window.location && window.location.search && window.location.search == "?manage=true" )
SwitchProfileManagerMode();
+ Registry = Components.classes['component://netscape/registry-viewer'].createInstance();
+ Registry = Registry.QueryInterface(Components.interfaces.nsIRegistryDataSource);
+ Registry.openDefaultRegistry();
+ Registry = Registry.QueryInterface(Components.interfaces.nsIRDFDataSource);
+
loadElements();
highlightCurrentProfile();
DoEnabling();
@@ -60,64 +73,75 @@ function highlightCurrentProfile()
// function : ::AddItem();
// purpose : utility function for adding items to a tree.
-function AddItem( aChildren, aCells, aIdfier, aMigrate)
+function AddItem( aChildren, aProfileObject )
{
var kids = document.getElementById(aChildren);
var item = document.createElement("treeitem");
var row = document.createElement("treerow");
var cell = document.createElement("treecell");
- cell.setAttribute("value",aCells);
+ cell.setAttribute("value", aProfileObject.mName );
cell.setAttribute("align","left");
- if( aMigrate )
- cell.setAttribute("class", "dimmed-lowcontrast" );
row.appendChild(cell);
item.appendChild(row);
- item.setAttribute("profile_name", aIdfier);
- item.setAttribute("rowName", aIdfier);
- item.setAttribute("id", ( "profileName_" + aIdfier ) );
- if( aMigrate )
- item.setAttribute("rowMigrate", "true");
+ item.setAttribute("profile_name", aProfileObject.mName );
+ item.setAttribute("rowName", aProfileObject.mName );
+ item.setAttribute("id", ( "profileName_" + aProfileObject.mName ) );
+ item.setAttribute("rowMigrate", aProfileObject.mMigrated );
+ item.setAttribute("directory", aProfileObject.mDir );
// 23/10/99 - no roaming access yet!
// var roaming = document.getElementById("roamingitem");
// kids.insertBefore(item,roaming);
kids.appendChild(item);
}
+function Profile ( aName, aDir, aMigrated )
+{
+ this.mName = aName ? aName : null;
+ this.mDir = aDir ? aDir : null;
+ this.mMigrated = aMigrated ? aMigrated : null;
+}
+
// function : ::loadElements();
// purpose : load profiles into tree
function loadElements()
{
- var profileList = "";
- profileList = profile.getProfileList();
- profileList = profileList.split(",");
-
- try {
- currProfile = profile.currentProfile;
- }
- catch (ex) {
- if (profileList != "")
- currProfile = profileList;
- }
-
- dump("profile list = " + profileList + "\n");
-
- // remove existing nodes...
- var profilekids = document.getElementById( "profilekids" );
- while( profilekids.hasChildNodes() )
+ var profileSRC = RDF.GetResource( "urn:mozilla-registry:key:/Profiles" );
+ var profileProperty = RDF.GetResource( "urn:mozilla-registry:subkeys" );
+ var profiles = Registry.GetTargets( profileSRC, profileProperty, true );
+ if( profiles )
+ profiles = profiles.QueryInterface( Components.interfaces.nsISimpleEnumerator );
+ while( profiles.HasMoreElements() )
{
- profilekids.removeChild( profilekids.firstChild );
- }
-
- for (var i = 0; i < profileList.length; i++) {
- var pvals = profileList[i].split(" - ");
- // only add profiles that have been migrated
- if( profileManagerMode == "selection" && pvals[1] != "migrate" ) {
- AddItem( "profilekids", pvals[0], pvals[0], false );
+ var currProfile = profiles.GetNext().QueryInterface( Components.interfaces.nsIRDFResource );
+ // begin BAD BAD BAD BAD BAD BAD HACK {{
+ var profileName = currProfile.Value.substring( currProfile.Value.lastIndexOf("/") + 1 );
+ // }} end BAD BAD BAD BAD BAD BAD HACK
+ var arcs = Registry.ArcLabelsOut( currProfile )
+ if( arcs )
+ arcs = arcs.QueryInterface( Components.interfaces.nsISimpleEnumerator );
+ while( arcs.HasMoreElements() )
+ {
+ var property = arcs.GetNext().QueryInterface( Components.interfaces.nsIRDFResource );
+ if( property == kRegistry_Subkeys )
+ continue;
+ var propstr = property.Value.substring( REGISTRY_VALUE_PREFIX.length );
+ var target = Registry.GetTarget( currProfile, property, true );
+ var literal = target.QueryInterface( Components.interfaces.nsIRDFLiteral );
+ if( literal )
+ var targetstr = literal.Value;
+ else {
+ literal = target.QueryInterface( Components.interfaces.nsIRDFInt )
+ if( literal )
+ var targetstr = literal.Value;
+ }
+ if( propstr == "migrated" )
+ var migrated = targetstr;
+ else if( propstr == "directory" )
+ var directory = targetstr;
}
- else if( profileManagerMode == "manager" ){
- AddItem( "profilekids", pvals[0], pvals[0], ( pvals[1] == "migrate" ) );
- }
- }
+ var profile = new Profile( profileName, directory, migrated );
+ AddItem( "profilekids", profile );
+ }
}
// function : ::onStart();
@@ -133,7 +157,7 @@ function onStart()
var selected = profileTree.selectedItems[0];
var profilename = selected.getAttribute("profile_name");
- if( selected.getAttribute("rowMigrate") == "true" ) {
+ if( selected.getAttribute("rowMigrate") == "no" ) {
var lString = bundle.GetStringFromName("migratebeforestart");
lString = lString.replace(/\s*/g,"\n");
if( confirm( lString ) )
diff --git a/profile/resources/content/profileSelection.xul b/profile/resources/content/profileSelection.xul
index 19c6a30c738..750161ee082 100644
--- a/profile/resources/content/profileSelection.xul
+++ b/profile/resources/content/profileSelection.xul
@@ -44,7 +44,6 @@
-
@@ -58,8 +57,7 @@
-
-
+
@@ -127,7 +125,6 @@
-
diff --git a/profile/resources/locale/en-US/profileManager.properties b/profile/resources/locale/en-US/profileManager.properties
index f13806f51c4..2d131fe2fde 100644
--- a/profile/resources/locale/en-US/profileManager.properties
+++ b/profile/resources/locale/en-US/profileManager.properties
@@ -23,3 +23,8 @@ exitButton=Exit
deleteFiles=Delete Files
dontDeleteFiles=Don't Delete Files
cancel=Cancel
+
+invalidCharA=You cannot create or rename a profile to a name containing the character: "
+invalidCharB="Please choose a different name for the profile.
+
+profileExists=A profile with this name already exists. Please choose another name.
diff --git a/profile/resources/locale/en-US/profileManagerDelete.dtd b/profile/resources/locale/en-US/profileManagerDelete.dtd
index 45da462b7e5..3e3a6744ff4 100644
--- a/profile/resources/locale/en-US/profileManagerDelete.dtd
+++ b/profile/resources/locale/en-US/profileManagerDelete.dtd
@@ -1,5 +1,5 @@
-
+
diff --git a/profile/resources/skin/profile.css b/profile/resources/skin/profile.css
index f023470dc8a..a98396cb3f7 100644
--- a/profile/resources/skin/profile.css
+++ b/profile/resources/skin/profile.css
@@ -1,3 +1,28 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * 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 Communicator client code, released
+ * March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998-1999 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributors:
+ * Chris Nelson
+ *
+ */
+
@import url(chrome://global/skin/);
toolbar.header {
@@ -25,14 +50,18 @@ titledbutton.unMigratedProfile {
.dimmed-highcontrast {
color: #99cccc ! important;
}
-.dimmed-lowcontrast {
- color: graytext ;
+treeitem[rowMigrate="no"] > treerow > treecell {
+ color: #8F8F8F;
}
-treeitem[selected="true"] > treerow > treecell {
- color: highlighttext;
+/** icon courtesy of chris nelson, chrisn@statecollege.com **/
+treeitem[rowMigrate="no"] > treerow > treecell > .tree-icon {
+ list-style-image: url("chrome://profile/skin/migrate.gif");
}
+treeitem[rowMigrate="no"][selected="true"] > treerow > treecell {
+ color: #FFFFFF;
+}
div.headertext {
color: white;
@@ -65,9 +94,9 @@ div.separator {
}
/* display area */
-box#contentsink {
- border-top: 2px groove threedface;
- border-bottom: 2px groove threedface;
+box#contentarea {
+ border-top: 2px groove #CCCCCC;
+ border-bottom: 2px groove #CCCCCC;
padding: 7px;
}
@@ -124,4 +153,8 @@ box#okCancelButtons.Button1 > spring#Button3Spring {
}
spring#Button3Spring {
width: 5px;
+}
+
+box.selection {
+ margin-top: 4px;
}
\ No newline at end of file