1999-12-06 08:53:02 +03:00
|
|
|
/*
|
1999-10-07 12:47:16 +04:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Ben Goodger (30/09/99)
|
1999-12-06 08:53:02 +03:00
|
|
|
*/
|
1999-10-07 01:36:59 +04:00
|
|
|
|
|
|
|
// The WIZARD of GORE
|
|
|
|
|
1999-10-07 10:57:38 +04:00
|
|
|
var profile = Components.classes["component://netscape/profile/manager"].createInstance();
|
1999-12-06 08:53:02 +03:00
|
|
|
profile = profile.QueryInterface(Components.interfaces.nsIProfile);
|
1999-09-28 23:13:50 +04:00
|
|
|
|
1999-12-06 08:53:02 +03:00
|
|
|
// Navigation Set for pages contained in wizard
|
|
|
|
var wizardMap = {
|
|
|
|
newProfile1_1: { previous: null, next: "newProfile1_2", finish: false },
|
|
|
|
newProfile1_2: { previous: "newProfile1_1", next: null, finish: true },
|
1999-09-29 02:50:50 +04:00
|
|
|
}
|
1999-09-28 23:13:50 +04:00
|
|
|
|
1999-12-06 08:53:02 +03:00
|
|
|
// page specific variables
|
|
|
|
var profName = "";
|
|
|
|
var profDir = "";
|
|
|
|
var wizardManager = null;
|
1999-09-28 23:13:50 +04:00
|
|
|
|
1999-12-06 08:53:02 +03:00
|
|
|
// startup procedure
|
|
|
|
function Startup( startPage, frame_id )
|
1999-09-28 23:13:50 +04:00
|
|
|
{
|
1999-12-06 08:53:02 +03:00
|
|
|
if( frame_id == "" ) {
|
|
|
|
dump("Please supply a content_frame ID!");
|
|
|
|
return false;
|
1999-10-07 01:36:59 +04:00
|
|
|
}
|
1999-12-06 08:53:02 +03:00
|
|
|
|
|
|
|
// instantiate the Wizard Manager
|
|
|
|
wizardManager = new WizardManager( frame_id, null, null, wizardMap );
|
|
|
|
wizardManager.URL_PagePrefix = "chrome://profile/content/";
|
|
|
|
wizardManager.URL_PagePostfix = ".xul";
|
|
|
|
|
|
|
|
// set the button handler functions
|
|
|
|
wizardManager.SetHandlers( null, null, onFinish, onCancel, null, null );
|
|
|
|
// load the start page
|
|
|
|
dump("calling loadpage...\n");
|
|
|
|
dump("startPage:: " + startPage + "\n");
|
|
|
|
wizardManager.LoadPage( startPage, false );
|
2000-01-13 07:21:25 +03:00
|
|
|
// move to center of screen if no opener, otherwise, to center of opener
|
|
|
|
if( window.opener )
|
|
|
|
moveToAlertPosition();
|
|
|
|
else
|
|
|
|
centerWindowOnScreen();
|
1999-09-28 23:13:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function onCancel()
|
|
|
|
{
|
1999-12-06 08:53:02 +03:00
|
|
|
if( top.window.opener )
|
1999-10-07 01:36:59 +04:00
|
|
|
window.close();
|
1999-12-06 08:53:02 +03:00
|
|
|
else {
|
1999-10-07 10:57:38 +04:00
|
|
|
try {
|
1999-12-06 08:53:02 +03:00
|
|
|
profile.forgetCurrentProfile();
|
1999-10-07 10:57:38 +04:00
|
|
|
}
|
|
|
|
catch (ex) {
|
1999-12-06 08:53:02 +03:00
|
|
|
dump("failed to forget current profile.\n");
|
1999-10-07 10:57:38 +04:00
|
|
|
}
|
|
|
|
ExitApp();
|
|
|
|
}
|
1999-09-28 23:13:50 +04:00
|
|
|
}
|
|
|
|
|
1999-12-06 08:53:02 +03:00
|
|
|
function onFinish()
|
1999-09-28 23:13:50 +04:00
|
|
|
{
|
2000-01-13 07:21:25 +03:00
|
|
|
dump("*** IN ONFINISH\n");
|
1999-12-06 08:53:02 +03:00
|
|
|
// check if we're at final stage
|
|
|
|
if( !wizardManager.wizardMap[wizardManager.currentPageTag].finish )
|
1999-10-07 13:03:07 +04:00
|
|
|
return;
|
|
|
|
|
1999-12-06 08:53:02 +03:00
|
|
|
var tag = wizardManager.WSM.GetTagFromURL( wizardManager.content_frame.src, "/", ".xul" );
|
|
|
|
wizardManager.WSM.SavePageData( tag, null, null, null );
|
2000-01-13 07:21:25 +03:00
|
|
|
|
|
|
|
var profName = wizardManager.WSM.PageData["newProfile1_2"].ProfileName.value;
|
|
|
|
dump("**** profName: "+ profName + "\n");
|
|
|
|
var profDir = wizardManager.WSM.PageData["newProfile1_2"].ProfileDir.value;
|
|
|
|
proceed = processCreateProfileData( profName, profDir );
|
1999-12-06 08:53:02 +03:00
|
|
|
if( proceed ) {
|
|
|
|
if( window.opener ) {
|
2000-01-13 07:21:25 +03:00
|
|
|
window.opener.CreateProfile( profName, profDir );
|
1999-12-06 08:53:02 +03:00
|
|
|
window.close();
|
|
|
|
}
|
2000-01-13 07:21:25 +03:00
|
|
|
else {
|
|
|
|
profile.startApprunner( profName );
|
1999-12-06 08:53:02 +03:00
|
|
|
ExitApp();
|
2000-01-13 07:21:25 +03:00
|
|
|
}
|
1999-12-06 08:53:02 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return;
|
1999-09-28 23:13:50 +04:00
|
|
|
}
|
|
|
|
|
1999-12-06 08:53:02 +03:00
|
|
|
/** void processCreateProfileData( void ) ;
|
|
|
|
* - purpose:
|
|
|
|
* - in: nothing
|
|
|
|
* - out: nothing
|
|
|
|
**/
|
2000-01-13 07:21:25 +03:00
|
|
|
function processCreateProfileData( aProfName, aProfDir )
|
1999-09-28 23:13:50 +04:00
|
|
|
{
|
1999-11-28 09:37:13 +03:00
|
|
|
try {
|
1999-12-06 08:53:02 +03:00
|
|
|
// note: deleted check for empty profName string here as this should be
|
|
|
|
// done by panel. -bmg (31/10/99)
|
|
|
|
// todo: move this check into the panel itself, activated ontyping :P
|
|
|
|
// this should definetly be moved to that page.. but how about providing
|
|
|
|
// user with some feedback about what's wrong. .. TOOLTIP! o_O
|
|
|
|
// or.. some sort of onblur notification. like a dialog then, or a
|
|
|
|
// dropout layery thing. yeah. something like that to tell them when
|
|
|
|
// it happens, not when the whole wizard is complete. blah.
|
2000-01-13 07:21:25 +03:00
|
|
|
if( profile.profileExists( aProfName ) ) {
|
2000-01-14 03:44:44 +03:00
|
|
|
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();
|
1999-12-06 08:53:02 +03:00
|
|
|
return false;
|
|
|
|
}
|
2000-01-13 07:21:25 +03:00
|
|
|
profile.createNewProfile( aProfName, aProfDir );
|
1999-12-06 08:53:02 +03:00
|
|
|
return true;
|
1999-11-28 09:37:13 +03:00
|
|
|
}
|
1999-12-06 08:53:02 +03:00
|
|
|
catch(e) {
|
|
|
|
dump("*** Failed to create a profile\n");
|
1999-11-28 09:37:13 +03:00
|
|
|
}
|
1999-09-29 02:50:50 +04:00
|
|
|
}
|
1999-09-28 23:13:50 +04:00
|
|
|
|
1999-12-06 08:53:02 +03:00
|
|
|
/** void ExitApp( void ) ;
|
|
|
|
* - purpose: quits the application properly and finally, stops event loop
|
|
|
|
* - in: nothing
|
|
|
|
* - out: nothing
|
|
|
|
**/
|
1999-09-29 02:50:50 +04:00
|
|
|
function ExitApp()
|
|
|
|
{
|
1999-10-07 01:36:59 +04:00
|
|
|
// Need to call this to stop the event loop
|
|
|
|
var appShell = Components.classes['component://netscape/appshell/appShellService'].getService();
|
|
|
|
appShell = appShell.QueryInterface( Components.interfaces.nsIAppShellService);
|
|
|
|
appShell.Quit();
|
1999-09-29 02:50:50 +04:00
|
|
|
}
|
1999-09-28 23:13:50 +04:00
|
|
|
|
1999-12-06 08:53:02 +03:00
|
|
|
// load string bundle
|
1999-10-07 01:36:59 +04:00
|
|
|
var bundle = srGetStrBundle("chrome://profile/locale/createProfileWizard.properties");
|
1999-12-06 08:53:02 +03:00
|
|
|
|