Back to index

lightning-sunbird  0.9+nobinonly
setup.c
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is Mozilla Communicator client code, released
00016  * March 31, 1998.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1998
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *   Sean Su <ssu@netscape.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #include "setup.h"
00041 #include "extra.h"
00042 #include "dialogs.h"
00043 #include "ifuncns.h"
00044 
00045 /* global variables */
00046 HINSTANCE       hInst;
00047 HINSTANCE       hSetupRscInst;
00048 HINSTANCE       hSDInst;
00049 HINSTANCE       hXPIStubInst;
00050 
00051 HBITMAP         hbmpBoxChecked;
00052 HBITMAP         hbmpBoxCheckedDisabled;
00053 HBITMAP         hbmpBoxUnChecked;
00054 
00055 HANDLE          hAccelTable;
00056 
00057 HWND            hDlgCurrent;
00058 HWND            hDlgMessage;
00059 HWND            hWndMain;
00060 
00061 LPSTR           szEGlobalAlloc;
00062 LPSTR           szEStringLoad;
00063 LPSTR           szEDllLoad;
00064 LPSTR           szEStringNull;
00065 LPSTR           szTempSetupPath;
00066 LPSTR           szEOutOfMemory;
00067 
00068 LPSTR           szSetupDir;
00069 LPSTR           szTempDir;
00070 LPSTR           szOSTempDir;
00071 LPSTR           szFileIniConfig;
00072 LPSTR           szFileIniInstall;
00073 
00074 LPSTR           szSiteSelectorDescription;
00075 
00076 DWORD           dwWizardState;
00077 DWORD           dwSetupType;
00078 
00079 DWORD           dwTempSetupType;
00080 DWORD           gdwUpgradeValue;
00081 DWORD           gdwSiteSelectorStatus;
00082 
00083 BOOL            bSDUserCanceled;
00084 BOOL            bIdiArchivesExists;
00085 BOOL            bCreateDestinationDir;
00086 BOOL            bReboot;
00087 BOOL            gbILUseTemp;
00088 BOOL            gbPreviousUnfinishedDownload;
00089 BOOL            gbPreviousUnfinishedInstallXpi;
00090 BOOL            gbIgnoreRunAppX;
00091 BOOL            gbIgnoreProgramFolderX;
00092 BOOL            gbRestrictedAccess;
00093 BOOL            gbDownloadTriggered;
00094 BOOL            gbAllowMultipleInstalls = FALSE;
00095 BOOL            gbForceInstall = FALSE;
00096 BOOL            gbForceInstallGre = FALSE;
00097 BOOL            gShowBannerImage = TRUE;
00098 
00099 setupGen        sgProduct;
00100 diS             diSetup;
00101 diW             diWelcome;
00102 diL             diLicense;
00103 diQL            diQuickLaunch;
00104 diST            diSetupType;
00105 diSC            diSelectComponents;
00106 diSC            diSelectAdditionalComponents;
00107 diWI            diWindowsIntegration;
00108 diPF            diProgramFolder;
00109 diDO            diAdditionalOptions;
00110 diAS            diAdvancedSettings;
00111 diSI            diStartInstall;
00112 diD             diDownload;
00113 diR             diReboot;
00114 siSD            siSDObject;
00115 siCF            siCFXpcomFile;
00116 siC             *siComponents;
00117 ssi             *ssiSiteSelector;
00118 installGui      sgInstallGui;
00119 sems            gErrorMessageStream;
00120 sysinfo         gSystemInfo;
00121 dsN             *gdsnComponentDSRequirement = NULL;
00122 
00123 
00124 /* do not add setup.exe to the list because we figure out the filename
00125  * by calling GetModuleFileName() */
00126 char *SetupFileList[] = {"setuprsc.dll",
00127                          "config.ini",
00128                          "setup.ini",
00129                          "install.ini",
00130                          "license.txt",
00131                          ""};
00132 
00133 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
00134 {
00135   /***********************************************************************/
00136   /* HANDLE hInstance;       handle for this instance                    */
00137   /* HANDLE hPrevInstance;   handle for possible previous instances      */
00138   /* LPSTR  lpszCmdLine;     long pointer to exec command line           */
00139   /* int    nCmdShow;        Show code for main window display           */
00140   /***********************************************************************/
00141 
00142   MSG   msg;
00143   char  szBuf[MAX_BUF];
00144   int   iRv = WIZ_OK;
00145   HWND  hwndFW;
00146 
00147   if(!hPrevInstance)
00148   {
00149     if(InitSetupGeneral())
00150       PostQuitMessage(1);
00151     else if(ParseForStartupOptions(lpszCmdLine))
00152       PostQuitMessage(1);
00153     else if(((hwndFW = FindWindow(CLASS_NAME_SETUP_DLG, NULL)) != NULL ||
00154             ((hwndFW = FindWindow(CLASS_NAME_SETUP, NULL)) != NULL)) &&
00155               !gbAllowMultipleInstalls)
00156     {
00157     /* Allow only one instance of setup to run.
00158      * Detect a previous instance of setup, bring it to the 
00159      * foreground, and quit current instance */
00160 
00161       ShowWindow(hwndFW, SW_RESTORE);
00162       SetForegroundWindow(hwndFW);
00163       iRv = WIZ_SETUP_ALREADY_RUNNING;
00164       PostQuitMessage(1);
00165     }
00166     else if(Initialize(hInstance))
00167       PostQuitMessage(1);
00168     else if(!InitApplication(hInstance, hSetupRscInst))
00169     {
00170       char szEFailed[MAX_BUF];
00171 
00172       if(GetPrivateProfileString("Messages", "ERROR_FAILED", "", szEFailed, sizeof(szEFailed), szFileIniInstall))
00173       {
00174         wsprintf(szBuf, szEFailed, "InitApplication().");
00175         PrintError(szBuf, ERROR_CODE_SHOW);
00176       }
00177       PostQuitMessage(1);
00178     }
00179     else if(!InitInstance(hInstance, nCmdShow))
00180     {
00181       char szEFailed[MAX_BUF];
00182 
00183       if(GetPrivateProfileString("Messages", "ERROR_FAILED", "", szEFailed, sizeof(szEFailed), szFileIniInstall))
00184       {
00185         wsprintf(szBuf, szEFailed, "InitInstance().");
00186         PrintError(szBuf, ERROR_CODE_SHOW);
00187       }
00188       PostQuitMessage(1);
00189     }
00190     else if(GetInstallIni())
00191     {
00192       PostQuitMessage(1);
00193     }
00194     else if(ParseInstallIni())
00195     {
00196       PostQuitMessage(1);
00197     }
00198     else if(GetConfigIni())
00199     {
00200       PostQuitMessage(1);
00201     }
00202     else if(ParseConfigIni(lpszCmdLine))
00203     {
00204       PostQuitMessage(1);
00205     }
00206     else
00207     {
00208       ShowMessage(NULL, FALSE);
00209       DlgSequence(NEXT_DLG);
00210     }
00211   }
00212 
00213   while(GetMessage(&msg, NULL, 0, 0))
00214   {
00215     if((!IsDialogMessage(hDlgCurrent, &msg)) && (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)))
00216     {
00217       TranslateMessage(&msg);
00218       DispatchMessage(&msg);
00219     }
00220   }
00221 
00222   if(iRv != WIZ_SETUP_ALREADY_RUNNING)
00223     /* Do clean up before exiting from the application */
00224     DeInitialize();
00225 
00226   /* garbage collection */
00227   DeInitSetupGeneral();
00228 
00229   return(msg.wParam);
00230 } /*  End of WinMain */
00231