~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/toolkit/mozapps/installer/windows/wizard/uninstall/uninstall.c

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
2
/*
 
3
 * The contents of this file are subject to the Netscape Public
 
4
 * License Version 1.1 (the "License"); you may not use this file
 
5
 * except in compliance with the License. You may obtain a copy of
 
6
 * the License at http://www.mozilla.org/NPL/
 
7
 *
 
8
 * Software distributed under the License is distributed on an "AS
 
9
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
10
 * implied. See the License for the specific language governing
 
11
 * rights and limitations under the License.
 
12
 *
 
13
 * The Original Code is Mozilla Communicator client code,
 
14
 * released March 31, 1998.
 
15
 *
 
16
 * The Initial Developer of the Original Code is Netscape Communications
 
17
 * Corporation.  Portions created by Netscape are
 
18
 * Copyright (C) 1998 Netscape Communications Corporation. All
 
19
 * Rights Reserved.
 
20
 *
 
21
 * Contributor(s): 
 
22
 *     Sean Su <ssu@netscape.com>
 
23
 */
 
24
 
 
25
#include "uninstall.h"
 
26
#include "extra.h"
 
27
#include "dialogs.h"
 
28
#include "ifuncns.h"
 
29
 
 
30
/* global variables */
 
31
HINSTANCE       hInst;
 
32
 
 
33
HANDLE          hAccelTable;
 
34
 
 
35
HWND            hDlgUninstall;
 
36
HWND            hDlgMessage;
 
37
HWND            hWndMain;
 
38
 
 
39
LPSTR           szEGlobalAlloc;
 
40
LPSTR           szEStringLoad;
 
41
LPSTR           szEDllLoad;
 
42
LPSTR           szEStringNull;
 
43
 
 
44
LPSTR           szClassName;
 
45
LPSTR           szUninstallDir;
 
46
LPSTR           szTempDir;
 
47
LPSTR           szOSTempDir;
 
48
LPSTR           szFileIniUninstall;
 
49
LPSTR           szFileIniDefaultsInfo;
 
50
LPSTR           gszSharedFilename;
 
51
 
 
52
ULONG           ulOSType;
 
53
DWORD           dwScreenX;
 
54
DWORD           dwScreenY;
 
55
 
 
56
DWORD           gdwWhatToDo;
 
57
 
 
58
BOOL            gbAllowMultipleInstalls = FALSE;
 
59
 
 
60
uninstallGen    ugUninstall;
 
61
diU             diUninstall;
 
62
 
 
63
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
 
64
{
 
65
  /***********************************************************************/
 
66
  /* HANDLE hInstance;       handle for this instance                    */
 
67
  /* HANDLE hPrevInstance;   handle for possible previous instances      */
 
68
  /* LPSTR  lpszCmdLine;     long pointer to exec command line           */
 
69
  /* int    nCmdShow;        Show code for main window display           */
 
70
  /***********************************************************************/
 
71
 
 
72
  MSG   msg;
 
73
  char  szBuf[MAX_BUF];
 
74
  int   iRv = WIZ_OK;
 
75
  HWND  hwndFW;
 
76
 
 
77
  if(!hPrevInstance)
 
78
  {
 
79
    hInst = GetModuleHandle(NULL);
 
80
    if(InitUninstallGeneral())
 
81
      PostQuitMessage(1);
 
82
    else if(ParseCommandLine(lpszCmdLine))
 
83
      PostQuitMessage(1);
 
84
    else if((hwndFW = FindWindow(CLASS_NAME_UNINSTALL_DLG, NULL)) != NULL && !gbAllowMultipleInstalls)
 
85
    {
 
86
    /* Allow only one instance of setup to run.
 
87
     * Detect a previous instance of setup, bring it to the 
 
88
     * foreground, and quit current instance */
 
89
 
 
90
      ShowWindow(hwndFW, SW_RESTORE);
 
91
      SetForegroundWindow(hwndFW);
 
92
      iRv = WIZ_SETUP_ALREADY_RUNNING;
 
93
      PostQuitMessage(1);
 
94
    }
 
95
    else if(Initialize(hInst))
 
96
    {
 
97
      PostQuitMessage(1);
 
98
    }
 
99
    else if(!InitApplication(hInst))
 
100
    {
 
101
      char szEFailed[MAX_BUF];
 
102
 
 
103
      if(NS_LoadString(hInst, IDS_ERROR_FAILED, szEFailed, MAX_BUF) == WIZ_OK)
 
104
      {
 
105
        wsprintf(szBuf, szEFailed, "InitApplication().");
 
106
        PrintError(szBuf, ERROR_CODE_SHOW);
 
107
      }
 
108
      PostQuitMessage(1);
 
109
    }
 
110
    else if(ParseUninstallIni())
 
111
    {
 
112
      PostQuitMessage(1);
 
113
    }
 
114
    else if(ugUninstall.bUninstallFiles == TRUE)
 
115
    {
 
116
      if(diUninstall.bShowDialog == TRUE)
 
117
        hDlgUninstall = InstantiateDialog(hWndMain, DLG_UNINSTALL, diUninstall.szTitle, DlgProcUninstall);
 
118
      // Assumes that SHOWICONS, HIDEICONS, and SETDEFAULT never show dialogs
 
119
      else if((ugUninstall.mode == SHOWICONS) || (ugUninstall.mode == HIDEICONS))
 
120
        ParseDefaultsInfo();
 
121
      else if(ugUninstall.mode == SETDEFAULT)
 
122
        SetDefault();
 
123
      else
 
124
        ParseAllUninstallLogs();
 
125
    }
 
126
  }
 
127
 
 
128
  if((ugUninstall.bUninstallFiles == TRUE) && (diUninstall.bShowDialog == TRUE))
 
129
  {
 
130
    while(GetMessage(&msg, NULL, 0, 0))
 
131
    {
 
132
      if((!IsDialogMessage(hDlgUninstall, &msg)) && (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)))
 
133
      {
 
134
        TranslateMessage(&msg);
 
135
        DispatchMessage(&msg);
 
136
      }
 
137
    }
 
138
  }
 
139
 
 
140
  /* garbage collection */
 
141
  DeInitUninstallGeneral();
 
142
  if(iRv != WIZ_SETUP_ALREADY_RUNNING)
 
143
    /* Do clean up before exiting from the application */
 
144
    DeInitialize();
 
145
 
 
146
  return(msg.wParam);
 
147
} /*  End of WinMain */
 
148