void Alert_RemoveSecondary (LPIDENT lpiChild) { BOOL fChangedAlerts = FALSE; LPOBJECTALERTS lpoa; if ((lpoa = Alert_GetObjectAlerts (lpiChild, TRUE)) != NULL) { size_t iAlert; for (iAlert = 0; iAlert < lpoa->nAlerts; ) { if ( (lpoa->aAlerts[ iAlert ].alert == alertSECONDARY) && (lpoa->aAlerts[ iAlert ].aiSECONDARY.lpiSecondary == lpiChild) ) { Alert_RemoveFunc (lpoa, iAlert); fChangedAlerts = TRUE; } else { ++iAlert; } } BOOL fNeedBadCredsWarning = FALSE; for (iAlert = 0; iAlert < lpoa->nAlerts; ++iAlert) { if (lpoa->aAlerts[ iAlert ].alert == alertSECONDARY) { ALERT alert = Alert_GetAlert (lpoa->aAlerts[ iAlert ].aiSECONDARY.lpiSecondary, lpoa->aAlerts[ iAlert ].aiSECONDARY.iSecondary); if (alert == alertNO_SVRENT) fNeedBadCredsWarning = TRUE; } } if ( (!fNeedBadCredsWarning) && (lpoa->nAlerts && (lpoa->aAlerts[ 0 ].alert == alertBADCREDS)) ) { Alert_RemoveFunc (lpoa, 0); fChangedAlerts = TRUE; } } if (fChangedAlerts) { PostNotification (evtAlertsChanged, lpiChild->GetServer()); PostNotification (evtAlertsChanged, lpiChild); } }
void Server_Salvage_OnEndTask_EnumAggregates (HWND hDlg, LPIDENT lpi, LPTASKPACKET ptp) { // We'll refill the Aggregates list any time the user selected a new server; // and whenever it gets filled, we must next fill the filesets list. // LPIDENT lpiServer; if ((lpiServer = (LPIDENT)CB_GetSelectedData (GetDlgItem (hDlg, IDC_SERVER))) != NULL) { LPIDENT lpiAggregate; if ((lpiAggregate = (LPIDENT)CB_GetSelectedData (GetDlgItem (hDlg, IDC_AGGREGATE))) != NULL) { LPSET_ENUM_TO_COMBOBOX_PACKET lpp = New (SET_ENUM_TO_COMBOBOX_PACKET); memset (lpp, 0x00, sizeof(SET_ENUM_TO_COMBOBOX_PACKET)); lpp->hCombo = GetDlgItem (hDlg, IDC_FILESET); lpp->lpiServer = lpiServer; lpp->lpiAggregate = lpiAggregate; lpp->lpiSelect = ((lpiServer == lpi->GetServer()) && (lpi->fIsFileset())) ? (lpi) : NULL; StartTask (taskSET_ENUM_TO_COMBOBOX, hDlg, lpp); } } }
void Server_Salvage_OnInitDialog (HWND hDlg, LPIDENT lpi) { CheckDlgButton (hDlg, IDC_AGGREGATE_ALL, (lpi->fIsServer()) ? TRUE : FALSE); CheckDlgButton (hDlg, IDC_FILESET_ALL, (lpi->fIsFileset()) ? FALSE : TRUE); EnableWindow (GetDlgItem (hDlg, IDC_SERVER), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_AGGREGATE), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_AGGREGATE_ALL), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_FILESET), FALSE); EnableWindow (GetDlgItem (hDlg, IDC_FILESET_ALL), FALSE); EnableWindow (GetDlgItem (hDlg, IDOK), FALSE); LPSVR_ENUM_TO_COMBOBOX_PACKET lpp = New (SVR_ENUM_TO_COMBOBOX_PACKET); memset (lpp, 0x00, sizeof(SVR_ENUM_TO_COMBOBOX_PACKET)); lpp->hCombo = GetDlgItem (hDlg, IDC_SERVER); lpp->lpiSelect = lpi->GetServer(); StartTask (taskSVR_ENUM_TO_COMBOBOX, hDlg, lpp); CheckDlgButton (hDlg, IDC_SALVAGE_SIMUL, TRUE); CreateSpinner (GetDlgItem(hDlg,IDC_SALVAGE_NUM), 10, FALSE, 2, 4, 12); }
LPOBJECTALERTS Alert_GetObjectAlerts (LPIDENT lpi, BOOL fAlwaysServer, ULONG *pStatus) { LPOBJECTALERTS lpoa = NULL; if (fAlwaysServer || lpi->fIsServer()) { LPSERVER_PREF lpsp; if ((lpsp = (LPSERVER_PREF)lpi->GetServer()->GetUserParam()) != NULL) { lpoa = &lpsp->oa; } } else if (lpi->fIsService()) { LPSERVICE_PREF lpsp; if ((lpsp = (LPSERVICE_PREF)lpi->GetUserParam()) != NULL) { lpoa = &lpsp->oa; } } else if (lpi->fIsAggregate()) { LPAGGREGATE_PREF lpap; if ((lpap = (LPAGGREGATE_PREF)lpi->GetUserParam()) != NULL) { lpoa = &lpap->oa; } } else if (lpi->fIsFileset()) { LPFILESET_PREF lpfp; if ((lpfp = (LPFILESET_PREF)lpi->GetUserParam()) != NULL) { lpoa = &lpfp->oa; } } return lpoa; }
void DispatchNotification_MainThread (NOTIFYEVENT evt, PNOTIFYPARAMS pParams) { LPIDENT lpiEvt = pParams->lpi1; // There are several notifications which are sent when beginning or ending // lengthy operations. These "actions" each get a window indicating // progress, and get added to our ongoing list of actions-in-progress. // ActionNotification_MainThread (evt, pParams); // The real reason for this routine is as a dispatcher for the AFSClass's // notifications: various windows throughout the app register themselves // with this dispatcher, and thereby get a message whenever a particular // event of interest to that window happens. Just what notifications // are "of interest" is specified by the window when it registers with // this dispatcher. // for (size_t iDispatch = 0; iDispatch < nDispatchList; ++iDispatch) { if (!aDispatchList[ iDispatch ].hWnd) continue; BOOL fDispatch = FALSE; // WHEN_CELL_OPENED + NULL -> notify if any new cell is opened // WHEN_OBJECT_CHANGES + NULL -> notify if anything at all changes // WHEN_OBJECT_CHANGES + lpi -> notify if this object changes // WHEN_SVCS(etc)_CHANGE + NULL -> notify if any service at all changes // WHEN_SVCS(etc)_CHANGE + lpi -> notify if any svc on this svr changes switch (aDispatchList[ iDispatch ].when) { case WHEN_CELL_OPENED: if (evt == evtCreate && lpiEvt->fIsCell()) fDispatch = TRUE; break; case WHEN_OBJECT_CHANGES: if ( (aDispatchList[ iDispatch ].lpiObject == lpiEvt) || (aDispatchList[ iDispatch ].lpiObject == NULL) ) { if (evt != evtCreate) fDispatch = TRUE; } break; case WHEN_SVRS_CHANGE: switch (evt) { case evtInvalidate: case evtRefreshServersBegin: case evtRefreshServersEnd: if ( (lpiEvt && lpiEvt->fIsCell()) || (aDispatchList[ iDispatch ].lpiObject == lpiEvt) || (aDispatchList[ iDispatch ].lpiObject == NULL) ) { if (lpiEvt && lpiEvt->fIsCell()) fDispatch = TRUE; } break; case evtCreate: case evtDestroy: case evtRefreshStatusBegin: case evtRefreshStatusEnd: case evtAlertsChanged: if (lpiEvt && lpiEvt->fIsServer()) { if (aDispatchList[ iDispatch ].lpiObject == NULL) fDispatch = TRUE; else { LPIDENT lpiEvtCell = lpiEvt->GetCell(); if (aDispatchList[ iDispatch ].lpiObject == lpiEvtCell) fDispatch = TRUE; } } break; } break; case WHEN_SETS_CHANGE: switch (evt) { case evtInvalidate: case evtRefreshFilesetsBegin: case evtRefreshFilesetsEnd: { LPIDENT lpiEvtSvr = NULL; if (lpiEvt && !lpiEvt->fIsCell()) lpiEvtSvr = lpiEvt->GetServer(); if ( (lpiEvt && lpiEvt->fIsCell()) || (aDispatchList[ iDispatch ].lpiObject == lpiEvt) || (aDispatchList[ iDispatch ].lpiObject == lpiEvtSvr) || (aDispatchList[ iDispatch ].lpiObject == NULL) ) { if (lpiEvt && (lpiEvt->fIsCell() || lpiEvt->fIsServer() || lpiEvt->fIsAggregate())) fDispatch = TRUE; } } break; case evtCreate: case evtDestroy: case evtRefreshStatusBegin: case evtRefreshStatusEnd: case evtAlertsChanged: if (lpiEvt && lpiEvt->fIsFileset()) { if (aDispatchList[ iDispatch ].lpiObject == NULL) fDispatch = TRUE; else { LPIDENT lpiEvtAgg = lpiEvt->GetAggregate(); LPIDENT lpiEvtSvr = lpiEvt->GetServer(); if (aDispatchList[ iDispatch ].lpiObject == lpiEvtAgg) fDispatch = TRUE; if (aDispatchList[ iDispatch ].lpiObject == lpiEvtSvr) fDispatch = TRUE; } } break; } break; case WHEN_AGGS_CHANGE: switch (evt) { case evtRefreshAggregatesBegin: case evtRefreshAggregatesEnd: if ( (lpiEvt && lpiEvt->fIsCell()) || (aDispatchList[ iDispatch ].lpiObject == lpiEvt) || (aDispatchList[ iDispatch ].lpiObject == NULL) ) { if (lpiEvt && (lpiEvt->fIsCell() || lpiEvt->fIsServer())) fDispatch = TRUE; } break; case evtCreate: case evtDestroy: case evtRefreshStatusBegin: case evtRefreshStatusEnd: case evtAlertsChanged: if (lpiEvt && lpiEvt->fIsAggregate()) { if (aDispatchList[ iDispatch ].lpiObject == NULL) fDispatch = TRUE; else { LPIDENT lpiEvtSvr = lpiEvt->GetServer(); if (aDispatchList[ iDispatch ].lpiObject == lpiEvtSvr) fDispatch = TRUE; } } break; } break; case WHEN_SVCS_CHANGE: switch (evt) { case evtRefreshServicesBegin: case evtRefreshServicesEnd: if ( (lpiEvt && lpiEvt->fIsCell()) || (aDispatchList[ iDispatch ].lpiObject == lpiEvt) || (aDispatchList[ iDispatch ].lpiObject == NULL) ) { if (lpiEvt && (lpiEvt->fIsCell() || lpiEvt->fIsServer())) fDispatch = TRUE; } break; case evtCreate: case evtDestroy: case evtRefreshStatusBegin: case evtRefreshStatusEnd: case evtAlertsChanged: if (lpiEvt && lpiEvt->fIsService()) { if (aDispatchList[ iDispatch ].lpiObject == NULL) fDispatch = TRUE; else { LPIDENT lpiEvtSvr = lpiEvt->GetServer(); if (aDispatchList[ iDispatch ].lpiObject == lpiEvtSvr) fDispatch = TRUE; } } break; } break; } if (fDispatch) { LPNOTIFYSTRUCT lpns = New (NOTIFYSTRUCT); lpns->hwndTarget = aDispatchList[ iDispatch ].hWnd; lpns->evt = evt; memcpy (&lpns->Params, pParams, sizeof(NOTIFYPARAMS)); lpns->Params.lpUser = aDispatchList[ iDispatch ].lpUser; PostMessage (aDispatchList[ iDispatch ].hWnd, WM_NOTIFY_FROM_DISPATCH, (WPARAM)0, (LPARAM)lpns); } } }
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; } }
void Server_Salvage_OnEndTask_EnumServers (HWND hDlg, LPIDENT lpi, LPTASKPACKET ptp) { // We'll only fill the Servers list once, and that during initialization. // When the filling completes, find out what server is currently selected // (it should already be the one the user chose earlier), and fill the // aggregates list for it. We won't enable anything yet. // LPIDENT lpiServer; if ((lpiServer = (LPIDENT)CB_GetSelectedData (GetDlgItem (hDlg, IDC_SERVER))) != NULL) { LPAGG_ENUM_TO_COMBOBOX_PACKET lpp = New (AGG_ENUM_TO_COMBOBOX_PACKET); memset (lpp, 0x00, sizeof(AGG_ENUM_TO_COMBOBOX_PACKET)); lpp->hCombo = GetDlgItem (hDlg, IDC_AGGREGATE); lpp->lpiServer = lpiServer; lpp->lpiSelect = (lpi && (!lpi->fIsCell()) && (!lpi->fIsServer()) && (lpiServer == lpi->GetServer())) ? (lpi->GetAggregate()) : NULL; StartTask (taskAGG_ENUM_TO_COMBOBOX, hDlg, lpp); } }
void Server_Salvage_OnServer (HWND hDlg, LPIDENT lpi) { LPIDENT lpiServer; if ((lpiServer = (LPIDENT)CB_GetSelectedData (GetDlgItem (hDlg, IDC_SERVER))) != NULL) { LPAGG_ENUM_TO_COMBOBOX_PACKET lpp = New (AGG_ENUM_TO_COMBOBOX_PACKET); memset (lpp, 0x00, sizeof(AGG_ENUM_TO_COMBOBOX_PACKET)); lpp->hCombo = GetDlgItem (hDlg, IDC_AGGREGATE); lpp->lpiServer = lpiServer; lpp->lpiSelect = (lpi && (!lpi->fIsCell()) && (!lpi->fIsServer()) && (lpiServer == lpi->GetServer())) ? (lpi->GetAggregate()) : NULL; StartTask (taskAGG_ENUM_TO_COMBOBOX, hDlg, lpp); } }
LPTSTR Filesets_GetColumnText (LPIDENT lpi, FILESETCOLUMN setcol, BOOL fShowServerName) { static TCHAR aszBuffer[ nFILESETCOLUMNS ][ cchRESOURCE ]; static size_t iBufferNext = 0; LPTSTR pszBuffer = aszBuffer[ iBufferNext++ ]; if (iBufferNext == nFILESETCOLUMNS) iBufferNext = 0; *pszBuffer = TEXT('\0'); LPFILESETSTATUS lpfs = NULL; LPIDENT lpiRW = NULL; LPFILESET_PREF lpfp; if ((lpfp = (LPFILESET_PREF)lpi->GetUserParam()) != NULL) { lpfs = &lpfp->fsLast; lpiRW = lpfp->lpiRW; } switch (setcol) { case setcolNAME: lpi->GetFilesetName (pszBuffer); break; case setcolAGGREGATE: if (!fShowServerName) lpi->GetAggregateName (pszBuffer); else { TCHAR szNameSvr[ cchNAME ]; TCHAR szNameAgg[ cchNAME ]; lpi->GetServerName (szNameSvr); lpi->GetAggregateName (szNameAgg); LPTSTR pszName = FormatString (IDS_SERVER_AGGREGATE, TEXT("%s%s"), szNameSvr, szNameAgg); lstrcpy (pszBuffer, pszName); FreeString (pszName); } break; case setcolTYPE: if (lpfs) { switch (lpfs->Type) { case ftREADWRITE: GetString (pszBuffer, IDS_FILESETTYPE_RW); break; case ftCLONE: GetString (pszBuffer, IDS_FILESETTYPE_CLONE); break; case ftREPLICA: if (lpiRW == NULL) GetString (pszBuffer, IDS_FILESETTYPE_RO); else if (lpiRW->GetServer() != lpi->GetServer()) GetString (pszBuffer, IDS_FILESETTYPE_RO); else GetString (pszBuffer, IDS_FILESETTYPE_RO_STAGE); break; } } break; case setcolDATE_CREATE: if (lpfs) { if (!FormatTime (pszBuffer, TEXT("%s"), &lpfs->timeCreation)) pszBuffer[0] = TEXT('\0'); } break; case setcolDATE_UPDATE: if (lpfs) { if (!FormatTime (pszBuffer, TEXT("%s"), &lpfs->timeLastUpdate)) pszBuffer[0] = TEXT('\0'); } break; case setcolDATE_ACCESS: if (lpfs) { if (!FormatTime (pszBuffer, TEXT("%s"), &lpfs->timeLastAccess)) pszBuffer[0] = TEXT('\0'); } break; case setcolDATE_BACKUP: if (lpfs) { if (!FormatTime (pszBuffer, TEXT("%s"), &lpfs->timeLastBackup)) pszBuffer[0] = TEXT('\0'); } break; case setcolQUOTA_USED: if (lpfs) { LPTSTR psz = FormatString (TEXT("%1"), TEXT("%.1B"), 1024.0 * lpfs->ckUsed); lstrcpy (pszBuffer, psz); FreeString (psz); } break; case setcolQUOTA_USED_PER: if (lpfs && lpfs->Type == ftREADWRITE) { DWORD dwPer = 100; if (lpfs->ckQuota != 0) dwPer = (DWORD)( 100.0 * lpfs->ckUsed / lpfs->ckQuota ); dwPer = max( 0, dwPer ); LPTSTR psz = FormatString (IDS_PERCENTAGE, TEXT("%lu"), dwPer); lstrcpy (pszBuffer, psz); FreeString (psz); } break; case setcolQUOTA_FREE: if (lpfs && lpfs->Type == ftREADWRITE) { LPTSTR psz = FormatString (TEXT("%1"), TEXT("%.1B"), 1024.0 * (lpfs->ckQuota - lpfs->ckUsed)); lstrcpy (pszBuffer, psz); FreeString (psz); } break; case setcolQUOTA_TOTAL: if (lpfs && lpfs->Type == ftREADWRITE) { LPTSTR psz = FormatString (TEXT("%1"), TEXT("%.1B"), 1024.0 * lpfs->ckQuota); lstrcpy (pszBuffer, psz); FreeString (psz); } break; case setcolSTATUS: LPTSTR pszDesc; if ((pszDesc = Alert_GetQuickDescription (lpi)) != NULL) { lstrcpy (pszBuffer,pszDesc); FreeString (pszDesc); } else if (!lpfs) { GetString (pszBuffer, IDS_STATUS_NOALERTS); } else { if (lpfs->State & fsBUSY) GetString (pszBuffer, IDS_SETSTATUS_BUSY); else if (lpfs->State & fsSALVAGE) GetString (pszBuffer, IDS_SETSTATUS_SALVAGE); else if (lpfs->State & fsMOVED) GetString (pszBuffer, IDS_SETSTATUS_MOVED); else if (lpfs->State & fsLOCKED) GetString (pszBuffer, IDS_SETSTATUS_LOCKED); else if (lpfs->State & fsNO_VOL) GetString (pszBuffer, IDS_SETSTATUS_NO_VOL); else GetString (pszBuffer, IDS_STATUS_NOALERTS); } break; case setcolID: if (lpfs) { LPTSTR psz = FormatString (TEXT("%1"), TEXT("%ld"), lpfs->id); lstrcpy (pszBuffer, psz); FreeString (psz); } break; case setcolFILES: if (lpfs) { LPTSTR psz = FormatString (TEXT("%1"), TEXT("%ld"), lpfs->nFiles); lstrcpy (pszBuffer, psz); FreeString (psz); } break; } return pszBuffer; }