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 the GNU General Public License Version 2 or later (the "GPL"), or
00028  * 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 HWND            hWizardWnd;
00061 
00062 LPSTR           szEGlobalAlloc;
00063 LPSTR           szEStringLoad;
00064 LPSTR           szEDllLoad;
00065 LPSTR           szEStringNull;
00066 LPSTR           szTempSetupPath;
00067 LPSTR           szEOutOfMemory;
00068 
00069 LPSTR           szSetupDir;
00070 LPSTR           szTempDir;
00071 LPSTR           szOSTempDir;
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 diSIP           diSelectInstallPath;
00107 diU             diUpgrade;
00108 diSC            diSelectAdditionalComponents;
00109 diWI            diWindowsIntegration;
00110 diPF            diProgramFolder;
00111 diDO            diAdditionalOptions;
00112 diAS            diAdvancedSettings;
00113 diSI            diStartInstall;
00114 diDL            diDownloading;
00115 diI             diInstalling;
00116 diIS            diInstallSuccessful;
00117 diD             diDownload;
00118 diR             diReboot;
00119 siSD            siSDObject;
00120 siCF            siCFXpcomFile;
00121 siC             *siComponents;
00122 ssi             *ssiSiteSelector;
00123 installGui      sgInstallGui;
00124 sems            gErrorMessageStream;
00125 sysinfo         gSystemInfo;
00126 dsN             *gdsnComponentDSRequirement = NULL;
00127 
00128 
00129 /* do not add setup.exe to the list because we figure out the filename
00130  * by calling GetModuleFileName() */
00131 char *SetupFileList[] = {"setuprsc.dll",
00132                          "config.ini",
00133                          "setup.ini",
00134                          "install.ini",
00135                          "license.txt",
00136                          ""};
00137 
00138 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
00139 {
00140   /***********************************************************************/
00141   /* HANDLE hInstance;       handle for this instance                    */
00142   /* HANDLE hPrevInstance;   handle for possible previous instances      */
00143   /* LPSTR  lpszCmdLine;     long pointer to exec command line           */
00144   /* int    nCmdShow;        Show code for main window display           */
00145   /***********************************************************************/
00146 
00147   MSG   msg;
00148   char  szBuf[MAX_BUF];
00149   int   iRv = WIZ_OK;
00150   HWND  hwndFW;
00151 
00152   if(!hPrevInstance)
00153   {
00154     if(InitSetupGeneral())
00155       PostQuitMessage(1);
00156     else if(ParseForStartupOptions(lpszCmdLine))
00157       PostQuitMessage(1);
00158     else if(((hwndFW = FindWindow(CLASS_NAME_SETUP_DLG, NULL)) != NULL ||
00159             ((hwndFW = FindWindow(CLASS_NAME_SETUP, NULL)) != NULL)) &&
00160               !gbAllowMultipleInstalls)
00161     {
00162     /* Allow only one instance of setup to run.
00163      * Detect a previous instance of setup, bring it to the 
00164      * foreground, and quit current instance */
00165 
00166       ShowWindow(hwndFW, SW_RESTORE);
00167       SetForegroundWindow(hwndFW);
00168       iRv = WIZ_SETUP_ALREADY_RUNNING;
00169       PostQuitMessage(1);
00170     }
00171     else if(Initialize(hInstance))
00172       PostQuitMessage(1);
00173     else if(!InitApplication(hInstance, hSetupRscInst))
00174     {
00175       char szEFailed[MAX_BUF];
00176 
00177       if(GetPrivateProfileString("Messages", "ERROR_FAILED", "", szEFailed, sizeof(szEFailed), szFileIniInstall))
00178       {
00179         wsprintf(szBuf, szEFailed, "InitApplication().");
00180         PrintError(szBuf, ERROR_CODE_SHOW);
00181       }
00182       PostQuitMessage(1);
00183     }
00184     else if(!InitInstance(hInstance, nCmdShow))
00185     {
00186       char szEFailed[MAX_BUF];
00187 
00188       if(GetPrivateProfileString("Messages", "ERROR_FAILED", "", szEFailed, sizeof(szEFailed), szFileIniInstall))
00189       {
00190         wsprintf(szBuf, szEFailed, "InitInstance().");
00191         PrintError(szBuf, ERROR_CODE_SHOW);
00192       }
00193       PostQuitMessage(1);
00194     }
00195     else if(GetInstallIni())
00196     {
00197       PostQuitMessage(1);
00198     }
00199     else if(ParseInstallIni())
00200     {
00201       PostQuitMessage(1);
00202     }
00203     else if(GetConfigIni())
00204     {
00205       PostQuitMessage(1);
00206     }
00207     else if(ParseConfigIni(lpszCmdLine))
00208     {
00209       PostQuitMessage(1);
00210     }
00211     else
00212     {
00213       InitSequence(hInstance);
00214     }
00215   }
00216 
00217 #if 0
00218   while(GetMessage(&msg, NULL, 0, 0))
00219   {
00220     if((!IsDialogMessage(hDlgCurrent, &msg)) && (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)))
00221     {
00222       TranslateMessage(&msg);
00223       DispatchMessage(&msg);
00224     }
00225   }
00226 
00227   if(iRv != WIZ_SETUP_ALREADY_RUNNING)
00228     /* Do clean up before exiting from the application */
00229     DeInitialize();
00230 
00231   /* garbage collection */
00232   DeInitSetupGeneral();
00233 
00234   return(msg.wParam);
00235 #endif
00236 
00237   return 0;
00238 }