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       hSetupRscInst;
00047 HINSTANCE       hXPIStubInst;
00048 
00049 HWND            hDlgCurrent;
00050 HWND            hDlgMessage;
00051 HWND            hWndMain;
00052 
00053 LPSTR           szEGlobalAlloc;
00054 LPSTR           szEStringLoad;
00055 LPSTR           szEDllLoad;
00056 LPSTR           szEStringNull;
00057 LPSTR           szTempSetupPath;
00058 
00059 LPSTR           szSetupDir;
00060 LPSTR           szTempDir;
00061 LPSTR           szOSTempDir;
00062 LPSTR           szFileIniConfig;
00063 LPSTR           szFileIniInstall;
00064 
00065 LPSTR           szSiteSelectorDescription;
00066 
00067 DWORD           ulWizardState;
00068 ULONG           ulSetupType;
00069 LONG            lScreenX;
00070 LONG            lScreenY;
00071 
00072 DWORD           ulTempSetupType;
00073 DWORD           gulUpgradeValue;
00074 DWORD           gulSiteSelectorStatus;
00075 
00076 BOOL            bSDUserCanceled;
00077 BOOL            bIdiArchivesExists;
00078 BOOL            bCreateDestinationDir;
00079 BOOL            bReboot;
00080 BOOL            gbILUseTemp;
00081 BOOL            gbPreviousUnfinishedDownload;
00082 BOOL            gbPreviousUnfinishedInstallXpi;
00083 BOOL            gbIgnoreRunAppX;
00084 BOOL            gbIgnoreProgramFolderX;
00085 BOOL            gbDownloadTriggered;
00086 
00087 setupGen        sgProduct;
00088 diS             diSetup;
00089 diW             diWelcome;
00090 diL             diLicense;
00091 diQL            diQuickLaunch;
00092 diST            diSetupType;
00093 diSC            diSelectComponents;
00094 diSC            diSelectAdditionalComponents;
00095 diOI            diOS2Integration;
00096 diPF            diProgramFolder;
00097 diDO            diAdditionalOptions;
00098 diAS            diAdvancedSettings;
00099 diSI            diStartInstall;
00100 diD             diDownload;
00101 diR             diReboot;
00102 siCF            siCFXpcomFile;
00103 siC             *siComponents;
00104 ssi             *ssiSiteSelector;
00105 installGui      sgInstallGui;
00106 sems            gErrorMessageStream;
00107 sysinfo         gSystemInfo;
00108 dsN             *gdsnComponentDSRequirement = NULL;
00109 
00110 /* do not add setup.exe to the list because we figure out the filename
00111  * by calling GetModuleFileName() */
00112 char *SetupFileList[] = {"setuprsc.dll",
00113                          "config.ini",
00114                          "setup.ini",
00115                          "install.ini",
00116                          "license.txt",
00117                          ""};
00118 
00119 int main(int argc, char *argv[], char *envp[])
00120 {
00121   HAB hab;
00122   HMQ hmq;
00123   QMSG qmsg;
00124   char  szBuf[MAX_BUF];
00125   int   iRv = WIZ_OK;
00126   HWND  hwndFW;
00127   int rc = 0;
00128   ATOM atom;
00129 
00130   hab = WinInitialize( 0 );
00131   hmq = WinCreateMsgQueue( hab, 0 );
00132 
00133   atom = WinAddAtom(WinQuerySystemAtomTable(), CLASS_NAME_SETUP_DLG);
00134 
00135   /* Allow only one instance of setup to run.
00136    * Detect a previous instance of setup, bring it to the 
00137    * foreground, and quit current instance */
00138 
00139   /* Iterate over top level windows searching for one of the required class
00140    * and a matching title.
00141    */
00142   if((hwndFW = FindWindow(CLASS_NAME_SETUP_DLG)) != NULL)
00143   {
00144     WinSetActiveWindow(HWND_DESKTOP, hwndFW);
00145     iRv = WIZ_SETUP_ALREADY_RUNNING;
00146     WinPostQueueMsg(0, WM_QUIT, 1, 0);
00147   }
00148   else if(Initialize(0, argv[0]))
00149     WinPostQueueMsg(0, WM_QUIT, 1, 0);
00150   else if(!InitApplication())
00151   {
00152     char szEFailed[MAX_BUF];
00153 
00154     if(GetPrivateProfileString("Messages", "ERROR_FAILED", "", szEFailed, sizeof(szEFailed), szFileIniInstall))
00155     {
00156       sprintf(szBuf, szEFailed, "InitApplication().");
00157       PrintError(szBuf, ERROR_CODE_SHOW);
00158     }
00159     WinPostQueueMsg(0, WM_QUIT, 1, 0);
00160   }
00161   else if(!InitInstance())
00162   {
00163     char szEFailed[MAX_BUF];
00164 
00165     if(GetPrivateProfileString("Messages", "ERROR_FAILED", "", szEFailed, sizeof(szEFailed), szFileIniInstall))
00166     {
00167       sprintf(szBuf, szEFailed, "InitInstance().");
00168       PrintError(szBuf, ERROR_CODE_SHOW);
00169     }
00170     WinPostQueueMsg(0, WM_QUIT, 1, 0);
00171   }
00172   else if(GetInstallIni())
00173   {
00174     WinPostQueueMsg(0, WM_QUIT, 1, 0);
00175   }
00176   else if(ParseInstallIni())
00177   {
00178     WinPostQueueMsg(0, WM_QUIT, 1, 0);
00179   }
00180   else if(GetConfigIni())
00181   {
00182     WinPostQueueMsg(0, WM_QUIT, 1, 0);
00183   }
00184   else if(ParseConfigIni(argc, argv))
00185   {
00186     WinPostQueueMsg(0, WM_QUIT, 1, 0);
00187   }
00188   else
00189   {
00190     DlgSequence(NEXT_DLG);
00191   }
00192 
00193   while ( WinGetMsg( hab, &qmsg, NULLHANDLE, 0, 0 ) )
00194     WinDispatchMsg( hab, &qmsg );
00195 
00196   if(iRv != WIZ_SETUP_ALREADY_RUNNING)
00197     /* Do clean up before exiting from the application */
00198     DeInitialize();
00199 
00200   WinDeleteAtom(WinQuerySystemAtomTable(), atom);
00201 
00202   WinDestroyMsgQueue( hmq );
00203   WinTerminate( hab ); 
00204 
00205   /* Unset LIBPATHSTRICT just in case it didn't get unset elsewhere */
00206   DosSetExtLIBPATH("F", LIBPATHSTRICT);
00207 }
00208