home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / central / profile.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  7.4 KB  |  230 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #pragma once
  20.  
  21. #include <Files.h>
  22. #include "PascalString.h"
  23. #include "StBlockingDialogHandler.h"
  24.  
  25. const MessageT cmd_SelectProfile = 4000;
  26. const MessageT cmd_NewProfile = 4001;
  27. const MessageT cmd_DeleteProfile = 4002;
  28. const MessageT cmd_RenameProfile = 4003;
  29. const MessageT cmd_QuitProfile = 4004;
  30. const MessageT cmd_EditDialSettings = 4010;
  31. const MessageT cmd_LocationPopup = 4011;
  32.  
  33. enum ProfileErr {
  34.     eUserCancelled = -2,
  35.     eUnknownError = -1,
  36.     eNeedUpgrade = 0,
  37.     eOK = 1,
  38.     eRunAccountSetup = 2,
  39.     eRunMUC = 3,
  40.     eSkipMUC = 4
  41. };
  42.  
  43.  
  44. /*****************************************************************************
  45.  * class CUserProfileDB
  46.  *
  47.  * Wrapper for multi-user profile database file.
  48.  *
  49.  *****************************************************************************/
  50. class CUserProfileDB
  51. {
  52.  
  53. public:
  54.  
  55.                         CUserProfileDB(FSSpec& spec, Boolean createIt = false);
  56.                         
  57.     short                CountProfiles();
  58.     short                GetNextProfileID();
  59.  
  60.     short                GetProfileIDByUsername(const CString& userName);
  61.     short                GetProfileIDByEmail(const CString& emailAddr);
  62.     
  63.     short                GetLastProfileID();
  64.     void                SetLastProfileID(short newUserID);
  65.     
  66.     void                AddNewProfile(short id, const CStr31& profileName,
  67.                             const FSSpec& profileFolder);
  68.     
  69.     Boolean                GetProfileName(short id, CStr31& name);
  70.     void                SetProfileName(short id, const CStr31& name);
  71.     
  72.     void                SetProfileData(short id);
  73.  
  74.     Boolean                GetProfileAlias(short id, FSSpec& profileFolder, Boolean allowUserInteraction = true);                            
  75.     void                DeleteProfile(short selectedID);
  76.     
  77.     LFile *                GetFile() {return &fFile;}
  78.  
  79.  
  80. private:
  81.     LFile                fFile;
  82.     Handle                GetDBResource(ResType theType, short theID);
  83.     
  84.     enum            {    kFirstProfileID = 128    };
  85.  
  86. };
  87.  
  88.  
  89. /*****************************************************************************
  90.  * class CDialogWizardHandler
  91.  *
  92.  * A generic dialog wizard handler.
  93.  *
  94.  *****************************************************************************/
  95. class CDialogWizardHandler
  96. {
  97. public:
  98.                             CDialogWizardHandler( ResIDT dlogID, LArray& paneList );
  99.     void                    AddListener(LListener* st);
  100.     
  101.     Boolean                    DoWizard();
  102.     LWindow*                GetDialog();
  103.     
  104.     void                    GetEditText( PaneIDT paneID, CString& text );
  105.     void                    SetEditText( PaneIDT paneID, const CString& text );
  106.     
  107.     void                     SetCheckboxValue(PaneIDT paneID, const Boolean value);
  108.     Boolean                    GetCheckboxValue(PaneIDT paneID);
  109.  
  110.     PaneIDT                    CurrentPane();
  111.     ArrayIndexT                CurrentPaneNumber();
  112.     ArrayIndexT                TotalPanes();
  113.     void                    EnableNextButton();
  114.     void                    DisableNextButton();
  115.     
  116. protected:
  117.     Boolean                    ShowPane( ArrayIndexT paneNum, LWindow* window );
  118.     
  119.     StBlockingDialogHandler    fDialog;
  120.     LArray                    fPaneList;
  121.     ArrayIndexT                fCurrentPane;
  122.     LListener*                fListener;
  123. };
  124.  
  125. /*****************************************************************************
  126.  * class CUserProfile
  127.  *
  128.  * Launches wizards and file operations for multi-user profile support.
  129.  *
  130.  *****************************************************************************/
  131. class CUserProfile
  132. {
  133.  
  134. public:
  135.     static void            InitUserProfiles();
  136.     
  137.     // Opens the User Profiles registry and puts up a profile-selection
  138.     // dialog if there is more than one profile (or showDialog is true).
  139.     // Returns kNeedUpgrade if User Profiles does not exist (i.e. we need 
  140.     // to call HandleUpgrade); else returns path of selected profile.
  141.     
  142.     static ProfileErr    GetUserProfile( const FSSpec& usersFolder,
  143.                             FSSpec& profileFolder, Boolean showDialog, short fileType );
  144.     
  145.     // Creates a new network profile in the user's folder
  146.     static ProfileErr    CreateNetProfile( FSSpec usersFolder, FSSpec& profileFolder );
  147.     
  148. private:
  149.     static ProfileErr    DoNetProfileDialog();
  150.     static void            DoNetExtendedProfileDialog(LCommander * super);
  151.  
  152. public:
  153.     // Launches upgrade wizard for users who have not run 4.0 before.
  154.     // Creates an initial profile folder and User Profiles file.
  155.     // If oldNetscapeF is non-null, it points to the user's 3.0
  156.     // Netscape ─ folder and the profile "folder" is an alias to it.
  157.     // Returns error code if user cancelled; else returns profile path.
  158.     
  159.     static ProfileErr    HandleUpgrade( FSSpec& profileFolder,
  160.                             const FSSpec* oldNetscapeF = nil );
  161.  
  162.     // Creates a unique profile folder name if necessary
  163.     static void            GetUniqueFolderName(FSSpec& folder);
  164.  
  165.     static short        sCurrentProfileID;
  166.     
  167.     enum              {    kRenamePrompt = 1,
  168.                         kDeletePrompt,
  169.                         kReadError,
  170.                         kCreateError,
  171.                         kDefaultName,
  172.                         kBadAliasError,
  173.                         kQuitLabel,
  174.                         kDoneLabel,
  175.                         kNextLabel,
  176.                         kConfigFileError,
  177.                         kInvalidConfigFile,
  178.                         kRunASLabel,
  179.                         kCreateProfileLabel,
  180.                         kConfigurationFileName    };
  181.     enum            {    kProfileStrings = 900    };
  182.                             
  183. private:
  184.     static ProfileErr    HandleProfileDialog( FSSpec& profileSpec, CUserProfileDB& profileDB,
  185.                             FSSpec& profileFolder, short& newUserID, short lastUserID,
  186.                             Boolean wantsProfileManager );
  187.     static void            PopulateListBox( ListHandle& listHand, CUserProfileDB& profileDB,
  188.                             short defaultID );
  189.     
  190.     enum UpgradeEnum {    eNoUpgrade,            // an additional profile is being created
  191.                         eExistingPrefs,        // first profile, existing Netscape Prefs file
  192.                         eNewInstall        };    // first profile, fresh install
  193.  
  194.     static ProfileErr    NewUserProfile( const FSSpec& profileSpec, FSSpec& profileFolder,
  195.                             CStr31& profileName, UpgradeEnum upgrading = eNoUpgrade,
  196.                             const FSSpec* oldNetscapeF = nil );
  197.     static ProfileErr    NewProfileWizard( UpgradeEnum upgrading, CStr31& profileName,
  198.                             const FSSpec& profileFolder, FSSpec& newProfileFolder,
  199.                             Boolean& userChoseFolder );
  200.                             
  201.     static void            RenameProfile( short selectedID, CUserProfileDB& profileDB,
  202.                             Cell& cell, ListHandle& listHand );
  203.     static void            DeleteProfile( short selectedID, CUserProfileDB& profileDB,
  204.                             ListHandle& listHand );
  205.     
  206.     static void            ReflectToPreferences(const CStr31& profileName,
  207.                             const FSSpec& profileFolder, short numProfiles = 1);
  208.     static void            CreateDefaultProfileFolder(const FSSpec& profileFolder);
  209.     
  210.     static OSErr         MakeDesktopIcons(const CStr31& profileName,
  211.                             const Boolean wantsNavigator, const Boolean wantsInbox);
  212.  
  213.     enum            {    kInvalidProfileID = -1 };
  214.     
  215. protected:
  216.                         // Ñ╩inPrefsFolder is the FSSpec of the users Preferences
  217.                         //        folder╔ we read a file directly below that
  218.     static long            SendMessageToPlugin( long inMessage, void* pb = NULL );
  219.     
  220.     static void*        LoadConfigPlugin();        // really returns PE_PluginFuncType
  221.     static OSErr        CloseConfigPlugin();
  222.     
  223.     static Boolean        DeleteMagicProfile( FSSpec& inSpec );
  224.     
  225.     static CFragConnectionID    mConfigPluginID;
  226.     static Boolean        mHasConfigPlugin;
  227.     static Boolean        mPluginLoaded;
  228. };
  229.  
  230.