2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 #include <afs/param.h>
15 #include "TaAfsUsrMgr.h"
20 #include "usr_create.h"
21 #include "usr_search.h"
23 #include "grp_create.h"
25 #include "mch_create.h"
31 * DEFINITIONS ________________________________________________________________
37 * VARIABLES __________________________________________________________________
46 * PROTOTYPES _________________________________________________________________
50 BOOL InitApplication (HINSTANCE hInst, LPTSTR pszCmdLine, int nCmdShow);
51 void ExitApplication (void);
55 * ROUTINES ___________________________________________________________________
59 extern "C" int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pszCmdLineA, int nCmdShow)
61 LPTSTR pszCmdLine = AnsiToString (pszCmdLineA);
63 if (InitApplication (hInst, pszCmdLine, nCmdShow))
69 FreeString (pszCmdLine, pszCmdLineA);
74 BOOL InitApplication (HINSTANCE hInst, LPTSTR pszCmdLine, int nCmdShow)
76 TaLocale_LoadCorrespondingModule (hInst);
78 memset (&g, 0x00, sizeof(g));
80 g.hAccel = TaLocale_LoadAccelerators (ACCEL_MAIN);
83 TCHAR szTitle[ cchRESOURCE ];
84 GetString (szTitle, IDS_APP_TITLE);
85 if ((hPrevious = FindWindow (TEXT("AFSAccountManagerClass"), szTitle)) != NULL)
88 SendMessage (hPrevious, WM_SHOW_YOURSELF, 0, 0);
92 AfsAppLib_SetAppName(szTitle);
93 AfsAppLib_SetPumpRoutine(PumpMessage);
96 memset (&tqp, 0x00, sizeof(tqp));
98 tqp.fnCreateTaskPacket = CreateTaskPacket;
99 tqp.fnPerformTask = PerformTask;
100 tqp.fnFreeTaskPacket = FreeTaskPacket;
101 AfsAppLib_InitTaskQueue (&tqp);
103 Main_ConfigureHelp();
105 // Determine how the app is supposed to look--that is, remember what it
106 // looked like last time, and if there was no "last time", pick some
109 if (!RestoreSettings (REGSTR_SETTINGS_BASE, REGSTR_SETTINGS_PATH, REGVAL_SETTINGS, &gr, sizeof(gr), wVerGLOBALS_RESTORED))
111 memset (&gr, 0x00, sizeof(gr));
112 SetRectEmpty (&gr.rMain);
113 gr.cminRefreshRate = 60; // 1 hour default refresh rate
115 User_SetDefaultCreateParams (&gr.CreateUser);
116 Group_SetDefaultCreateParams (&gr.CreateGroup);
117 Machine_SetDefaultCreateParams (&gr.CreateMachine);
118 Actions_SetDefaultView (&gr.viewAct);
119 User_SetDefaultView (&gr.viewUsr, &gr.ivUsr);
120 Group_SetDefaultView (&gr.viewGrp, &gr.ivGrp);
121 Machine_SetDefaultView (&gr.viewMch, &gr.ivMch);
122 Users_SetDefaultSearchParams (&gr.SearchUsers);
125 // Create a variation on WC_DIALOG, so we get appropriate icons on
129 GetClassInfo (THIS_HINST, MAKEINTRESOURCE( WC_DIALOG ), &wc);
130 wc.hInstance = THIS_HINST;
131 wc.hIcon = TaLocale_LoadIcon (IDI_MAIN);
132 wc.lpszClassName = TEXT("AFSAccountManagerClass");
133 wc.style |= CS_GLOBALCLASS;
136 // Okay, the big step: create the main window. Note that it doesn't
139 CMDLINEOP op = ParseCommandLine (pszCmdLine);
140 if (op == opCLOSEAPP)
143 // Okay, the big step: create the main window.
144 // Note that it doesn't get shown yet!
146 g.hMain = ModelessDialog (IDD_MAIN, NULL, (DLGPROC)Main_DialogProc);
150 if (op != opNOCELLDIALOG)
152 if (OpenCellDialog() != IDOK)
160 void ExitApplication (void)
166 asc_CellClose (g.idClient, g.idCell, &status);
167 AfsAppLib_CloseAdminServer();
174 if (g.hMain && IsWindow(g.hMain))
177 wpl.length = sizeof(wpl);
178 if (GetWindowPlacement (g.hMain, &wpl))
179 gr.rMain = wpl.rcNormalPosition;
182 StoreSettings (REGSTR_SETTINGS_BASE, REGSTR_SETTINGS_PATH, REGVAL_SETTINGS, &gr, sizeof(gr), wVerGLOBALS_RESTORED);
187 void PumpMessage (MSG *lpm)
189 if (g.hMain && IsWindow (g.hMain))
191 if (GetActiveWindow())
193 if (TranslateAccelerator (GetActiveWindow(), g.hAccel, lpm))
198 if (!IsMemoryManagerMessage (lpm))
200 TranslateMessage (lpm);
201 DispatchMessage (lpm);
206 BOOL cdecl StartThread (DWORD (WINAPI *lpfnStart)(PVOID lp), ...)
209 va_start (arg, lpfnStart);
210 PVOID lp = va_arg (arg, PVOID);
215 if ((hThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)lpfnStart, lp, 0, &dwThreadID)) == NULL)
218 SetThreadPriority (hThread, THREAD_PRIORITY_BELOW_NORMAL);