BOOL InitApplication (HINSTANCE hInst, LPTSTR pszCmdLine, int nCmdShow) { TaLocale_LoadCorrespondingModule (hInst); memset (&g, 0x00, sizeof(g)); g.hInst = hInst; g.hAccel = TaLocale_LoadAccelerators (ACCEL_MAIN); HWND hPrevious; TCHAR szTitle[ cchRESOURCE ]; GetString (szTitle, IDS_APP_TITLE); if ((hPrevious = FindWindow (TEXT("AFSAccountManagerClass"), szTitle)) != NULL) { SetFocus (hPrevious); SendMessage (hPrevious, WM_SHOW_YOURSELF, 0, 0); return FALSE; } AfsAppLib_SetAppName(szTitle); AfsAppLib_SetPumpRoutine(PumpMessage); TASKQUEUE_PARAMS tqp; memset (&tqp, 0x00, sizeof(tqp)); tqp.nThreadsMax = 10; tqp.fnCreateTaskPacket = CreateTaskPacket; tqp.fnPerformTask = PerformTask; tqp.fnFreeTaskPacket = FreeTaskPacket; AfsAppLib_InitTaskQueue (&tqp); Main_ConfigureHelp(); // Determine how the app is supposed to look--that is, remember what it // looked like last time, and if there was no "last time", pick some // decent defaults. // if (!RestoreSettings (REGSTR_SETTINGS_BASE, REGSTR_SETTINGS_PATH, REGVAL_SETTINGS, &gr, sizeof(gr), wVerGLOBALS_RESTORED)) { memset (&gr, 0x00, sizeof(gr)); SetRectEmpty (&gr.rMain); gr.cminRefreshRate = 60; // 1 hour default refresh rate User_SetDefaultCreateParams (&gr.CreateUser); Group_SetDefaultCreateParams (&gr.CreateGroup); Machine_SetDefaultCreateParams (&gr.CreateMachine); Actions_SetDefaultView (&gr.viewAct); User_SetDefaultView (&gr.viewUsr, &gr.ivUsr); Group_SetDefaultView (&gr.viewGrp, &gr.ivGrp); Machine_SetDefaultView (&gr.viewMch, &gr.ivMch); Users_SetDefaultSearchParams (&gr.SearchUsers); } // Create a variation on WC_DIALOG, so we get appropriate icons on // our windows. // WNDCLASS wc; GetClassInfo (THIS_HINST, MAKEINTRESOURCE( WC_DIALOG ), &wc); wc.hInstance = THIS_HINST; wc.hIcon = TaLocale_LoadIcon (IDI_MAIN); wc.lpszClassName = TEXT("AFSAccountManagerClass"); wc.style |= CS_GLOBALCLASS; RegisterClass (&wc); // Okay, the big step: create the main window. Note that it doesn't // get shown yet! // CMDLINEOP op = ParseCommandLine (pszCmdLine); if (op == opCLOSEAPP) return FALSE; // Okay, the big step: create the main window. // Note that it doesn't get shown yet! // g.hMain = ModelessDialog (IDD_MAIN, NULL, (DLGPROC)Main_DialogProc); if (g.hMain == NULL) return FALSE; if (op != opNOCELLDIALOG) { if (OpenCellDialog() != IDOK) return FALSE; } return TRUE; }
void StartContextCommand (HWND hDialog, LPIDENT lpiRepresentedByWindow, LPIDENT lpiChosenByClick, int cmd) { CHILDTAB iTab = Server_GetDisplayedTab (hDialog); LPIDENT lpi = (lpiChosenByClick) ? lpiChosenByClick : lpiRepresentedByWindow; if (lpi && lpi->fIsCell()) lpi = NULL; switch (cmd) { case M_COLUMNS: if (iTab == tabSERVICES) ShowColumnsDialog (hDialog, &gr.viewSvc); else if (iTab == tabAGGREGATES) ShowColumnsDialog (hDialog, &gr.viewAgg); else if (iTab == tabFILESETS) ShowColumnsDialog (hDialog, &gr.viewSet); else ShowColumnsDialog (hDialog, NULL); break; case M_SVR_VIEW_ONEICON: case M_SVR_VIEW_TWOICONS: case M_SVR_VIEW_STATUS: Command_OnIconView (hDialog, TRUE, iTab, cmd); break; case M_VIEW_ONEICON: case M_VIEW_TWOICONS: case M_VIEW_STATUS: Command_OnIconView (hDialog, FALSE, iTab, cmd); break; case M_PROPERTIES: if (lpi) Command_OnProperties (lpi); break; case M_SUBSET: ShowSubsetsDialog(); break; case M_REFRESHALL: if (g.lpiCell) StartTask (taskREFRESH, NULL, g.lpiCell); break; case M_REFRESH: if (lpi) StartTask (taskREFRESH, NULL, lpi); else if (g.lpiCell) StartTask (taskREFRESH, NULL, g.lpiCell); break; case M_SYNCVLDB: if (lpi) Server_SyncVLDB (lpi); break; case M_SALVAGE: if (lpi) Server_Salvage (lpi); break; case M_SET_CREATE: Filesets_Create (lpi); break; case M_SET_REPLICATION: if (lpi && lpi->fIsFileset()) Filesets_ShowReplication (Server_GetWindowForChild (hDialog), lpi); break; case M_SET_DELETE: if (lpi && lpi->fIsFileset()) Filesets_Delete (lpi); break; case M_SET_CLONE: Filesets_Clone (lpi); break; case M_SET_DUMP: if (lpi && lpi->fIsFileset()) Filesets_Dump (lpi); break; case M_SET_RESTORE: Filesets_Restore (lpi); break; case M_SET_RELEASE: if (lpi && lpi->fIsFileset()) Filesets_Release (lpi); break; case M_SET_MOVETO: if (lpi && lpi->fIsFileset()) Filesets_ShowMoveTo (lpi, NULL); break; case M_SET_SETQUOTA: if (lpi && lpi->fIsFileset()) Filesets_SetQuota (lpi); break; case M_SET_LOCK: if (lpi && lpi->fIsFileset()) StartTask (taskSET_LOCK, NULL, lpi); break; case M_SET_UNLOCK: if (lpi && !lpi->fIsService()) StartTask (taskSET_UNLOCK, NULL, lpi); else if (!lpi && g.lpiCell) StartTask (taskSET_UNLOCK, NULL, g.lpiCell); break; case M_SET_RENAME: if (lpi && lpi->fIsFileset()) Filesets_ShowRename (lpi); break; case M_SVR_OPEN: if (lpi && lpi->fIsServer()) StartTask (taskSVR_GETWINDOWPOS, g.hMain, lpi); break; case M_SVR_CLOSE: if (lpi && lpi->fIsServer()) Server_Close (lpi); break; case M_SVR_CLOSEALL: Server_CloseAll (TRUE); break; case M_SVR_SECURITY: Server_Security (lpi); break; case M_SVR_HOSTS: Server_Hosts (lpi); break; case M_SVR_INSTALL: Server_Install (lpi); break; case M_SVR_UNINSTALL: Server_Uninstall (lpi); break; case M_SVR_PRUNE: Server_Prune (lpi); break; case M_SVR_GETDATES: Server_GetDates (lpi); break; case M_EXECUTE: Server_Execute (lpi); break; case M_VIEWLOG: if (lpi && lpi->fIsService()) Services_ShowServiceLog (lpi); else Services_ShowServerLog (lpi); break; case M_SVR_MONITOR: if (lpi && lpi->fIsServer()) StartTask (taskSVR_MONITOR_ONOFF, NULL, lpi); break; case M_SVC_CREATE: if (!lpi) Services_Create (NULL); else Services_Create (lpi->GetServer()); break; case M_SVC_DELETE: if (lpi && lpi->fIsService()) Services_Delete (lpi); break; case M_SVC_START: if (lpi && lpi->fIsService()) Services_Start (lpi); break; case M_SVC_STOP: if (lpi && lpi->fIsService()) Services_Stop (lpi); break; case M_SVC_RESTART: if (lpi && lpi->fIsService()) Services_Restart (lpi); break; case M_CELL_OPEN: OpenCellDialog(); break; case M_CREDENTIALS: NewCredsDialog(); break; case M_OPTIONS: ShowOptionsDialog(); break; case M_HELP: WinHelp (g.hMain, cszHELPFILENAME, HELP_FINDER, 0); break; case M_HELP_FIND: Help_FindCommand(); break; case M_HELP_XLATE: Help_FindError(); break; case M_ABOUT: Help_About(); break; } }
BOOL InitApplication (HINSTANCE hInst, LPTSTR pszCmdLine, int nCmdShow) { TaLocale_LoadCorrespondingModule (hInst); memset (&g, 0x00, sizeof(g)); g.hInst = hInst; g.hAccel = TaLocale_LoadAccelerators (ACCEL_MAIN); HWND hPrevious; TCHAR szTitle[ cchRESOURCE ]; GetString (szTitle, IDS_APP_TITLE); if ((hPrevious = FindWindow (TEXT("AFSManagerClass"), szTitle)) != NULL) { SetFocus (hPrevious); SendMessage (hPrevious, WM_SHOW_YOURSELF, 0, 0); return FALSE; } AfsAppLib_SetAppName(szTitle); AfsAppLib_SetPumpRoutine(PumpMessage); TASKQUEUE_PARAMS tqp; memset (&tqp, 0x00, sizeof(tqp)); tqp.nThreadsMax = 10; tqp.fnCreateTaskPacket = CreateTaskPacket; tqp.fnPerformTask = PerformTask; tqp.fnFreeTaskPacket = FreeTaskPacket; AfsAppLib_InitTaskQueue (&tqp); Main_ConfigureHelp(); // Determine how the app is supposed to look--that is, remember what it // looked like last time, and if there was no "last time", pick some // decent defaults. // if (!RestoreSettings (REGSTR_SETTINGS_BASE, REGSTR_SETTINGS_PATH, REGVAL_SETTINGS, &gr, sizeof(gr), wVerGLOBALS_RESTORED)) { memset (&gr, 0x00, sizeof(gr)); SetRectEmpty (&gr.rMain); SetRectEmpty (&gr.rMainPreview); SetRectEmpty (&gr.rServerLast); SetRectEmpty (&gr.rViewLog); SetRectEmpty (&gr.rActions); gr.fPreview = TRUE; gr.fVert = TRUE; gr.fActions = FALSE; gr.tabLast = tabFILESETS; Server_SetDefaultView_Horz (&gr.diHorz.viewSvr); Server_SetDefaultView_Vert (&gr.diVert.viewSvr); Services_SetDefaultView (&gr.viewSvc); Aggregates_SetDefaultView (&gr.viewAgg); Filesets_SetDefaultView (&gr.viewSet); Replicas_SetDefaultView (&gr.viewRep); Action_SetDefaultView (&gr.viewAct); Server_Key_SetDefaultView (&gr.viewKey); gr.diHorz.cSplitter = -100; gr.diVert.cSplitter = -89; gr.cbQuotaUnits = cb1KB; gr.fOpenMonitors = TRUE; gr.fCloseUnmonitors = TRUE; gr.fServerLongNames = FALSE; gr.fDoubleClickOpens = 2; gr.fWarnBadCreds = TRUE; gr.ivSvr = ivSTATUS; gr.ivAgg = ivSTATUS; gr.ivSet = ivSTATUS; gr.ivSvc = ivSTATUS; } ULONG status; if (!AfsClass_Initialize (&status)) { if (status == ADMCLIENTCANTINITAFSLOCATION) ImmediateErrorDialog (status, IDS_ERROR_CANT_INIT_AFSCLASS_INSTALL); else ImmediateErrorDialog (status, IDS_ERROR_CANT_INIT_AFSCLASS_UNKNOWN); return FALSE; } AfsClass_RequestLongServerNames (gr.fServerLongNames); AfsClass_SpecifyRefreshDomain (AFSCLASS_WANT_VOLUMES); // Create a notification object for the AFSClass library, so that it can // let us know when anything changes. The notification handler we'll // install will take requests from the rest of the SVRMGR package and // forward notifications around to whichever windows are actually // interested. // CreateNotificationDispatch(); // Create a few variations on WC_DIALOG, so we get appropriate icons on // our windows. // WNDCLASS wc; GetClassInfo (THIS_HINST, MAKEINTRESOURCE( WC_DIALOG ), &wc); wc.hInstance = THIS_HINST; wc.hIcon = TaLocale_LoadIcon (IDI_MAIN); wc.lpszClassName = TEXT("AFSManagerClass"); wc.style |= CS_GLOBALCLASS; RegisterClass (&wc); GetClassInfo (THIS_HINST, MAKEINTRESOURCE( WC_DIALOG ), &wc); wc.hInstance = THIS_HINST; wc.hIcon = TaLocale_LoadIcon (IDI_SERVER); wc.lpszClassName = TEXT("ServerWindowClass"); wc.style |= CS_GLOBALCLASS; RegisterClass (&wc); // Okay, the big step: create the main window (ie, the servers list). // Note that it doesn't get shown yet! // CMDLINEOP op = ParseCommandLine (pszCmdLine); if (op == opCLOSEAPP) return FALSE; if (op == opLOOKUPERRORCODE) { Help_FindError(); return FALSE; } g.hMain = ModelessDialog (IDD_MAIN, NULL, (DLGPROC)Main_DialogProc); if (g.hMain == NULL) return FALSE; if (op != opNOCELLDIALOG) { if (OpenCellDialog() != IDOK) return FALSE; } return TRUE; }