Back to index

lightning-sunbird  0.9+nobinonly
uninstall.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 "uninstall.h"
00041 #include "extra.h"
00042 #include "dialogs.h"
00043 #include "ifuncns.h"
00044 
00045 /* global variables */
00046 HINSTANCE       hInst;
00047 
00048 HANDLE          hAccelTable;
00049 
00050 HWND            hDlgUninstall;
00051 HWND            hDlgMessage;
00052 HWND            hWndMain;
00053 
00054 LPSTR           szEGlobalAlloc;
00055 LPSTR           szEStringLoad;
00056 LPSTR           szEDllLoad;
00057 LPSTR           szEStringNull;
00058 LPSTR           szTempSetupPath;
00059 
00060 LPSTR           szClassName;
00061 LPSTR           szUninstallDir;
00062 LPSTR           szTempDir;
00063 LPSTR           szOSTempDir;
00064 LPSTR           szFileIniUninstall;
00065 LPSTR           szFileIniDefaultsInfo;
00066 LPSTR           gszSharedFilename;
00067 
00068 ULONG           ulOSType;
00069 DWORD           dwScreenX;
00070 DWORD           dwScreenY;
00071 
00072 DWORD           gdwWhatToDo;
00073 
00074 BOOL            gbAllowMultipleInstalls = FALSE;
00075 
00076 uninstallGen    ugUninstall;
00077 diU             diUninstall;
00078 
00079 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
00080 {
00081   /***********************************************************************/
00082   /* HANDLE hInstance;       handle for this instance                    */
00083   /* HANDLE hPrevInstance;   handle for possible previous instances      */
00084   /* LPSTR  lpszCmdLine;     long pointer to exec command line           */
00085   /* int    nCmdShow;        Show code for main window display           */
00086   /***********************************************************************/
00087 
00088   MSG   msg;
00089   char  szBuf[MAX_BUF];
00090   int   iRv = WIZ_OK;
00091   HWND  hwndFW;
00092 
00093   if(!hPrevInstance)
00094   {
00095     hInst = GetModuleHandle(NULL);
00096     if(InitUninstallGeneral())
00097       PostQuitMessage(1);
00098     else if(ParseCommandLine(lpszCmdLine))
00099       PostQuitMessage(1);
00100     else if((hwndFW = FindWindow(CLASS_NAME_UNINSTALL_DLG, NULL)) != NULL && !gbAllowMultipleInstalls)
00101     {
00102     /* Allow only one instance of setup to run.
00103      * Detect a previous instance of setup, bring it to the 
00104      * foreground, and quit current instance */
00105 
00106       ShowWindow(hwndFW, SW_RESTORE);
00107       SetForegroundWindow(hwndFW);
00108       iRv = WIZ_SETUP_ALREADY_RUNNING;
00109       PostQuitMessage(1);
00110     }
00111     else if(Initialize(hInst))
00112     {
00113       PostQuitMessage(1);
00114     }
00115     else if(!InitApplication(hInst))
00116     {
00117       char szEFailed[MAX_BUF];
00118 
00119       if(NS_LoadString(hInst, IDS_ERROR_FAILED, szEFailed, MAX_BUF) == WIZ_OK)
00120       {
00121         wsprintf(szBuf, szEFailed, "InitApplication().");
00122         PrintError(szBuf, ERROR_CODE_SHOW);
00123       }
00124       PostQuitMessage(1);
00125     }
00126     else if(ParseUninstallIni())
00127     {
00128       PostQuitMessage(1);
00129     }
00130     else if(ugUninstall.bUninstallFiles == TRUE)
00131     {
00132       if(diUninstall.bShowDialog == TRUE)
00133         hDlgUninstall = InstantiateDialog(hWndMain, DLG_UNINSTALL, diUninstall.szTitle, DlgProcUninstall);
00134       // Assumes that SHOWICONS, HIDEICONS, and SETDEFAULT never show dialogs
00135       else if((ugUninstall.mode == SHOWICONS) || (ugUninstall.mode == HIDEICONS))
00136         ParseDefaultsInfo();
00137       else if(ugUninstall.mode == SETDEFAULT)
00138         SetDefault();
00139       else
00140         ParseAllUninstallLogs();
00141     }
00142   }
00143 
00144   if((ugUninstall.bUninstallFiles == TRUE) && (diUninstall.bShowDialog == TRUE))
00145   {
00146     while(GetMessage(&msg, NULL, 0, 0))
00147     {
00148       if((!IsDialogMessage(hDlgUninstall, &msg)) && (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)))
00149       {
00150         TranslateMessage(&msg);
00151         DispatchMessage(&msg);
00152       }
00153     }
00154   }
00155 
00156   /* garbage collection */
00157   DeInitUninstallGeneral();
00158   if(iRv != WIZ_SETUP_ALREADY_RUNNING)
00159     /* Do clean up before exiting from the application */
00160     DeInitialize();
00161 
00162   return(msg.wParam);
00163 } /*  End of WinMain */
00164