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>
19 #include "svr_general.h"
20 #include "svr_window.h"
22 #include "svr_syncvldb.h"
23 #include "svr_salvage.h"
24 #include "svr_install.h"
25 #include "svr_uninstall.h"
26 #include "svr_prune.h"
27 #include "svr_getdates.h"
28 #include "svr_execute.h"
29 #include "svr_security.h"
30 #include "svr_address.h"
32 #include "svc_create.h"
33 #include "svc_general.h"
34 #include "svc_startstop.h"
35 #include "svc_viewlog.h"
36 #include "agg_general.h"
38 #include "set_create.h"
39 #include "set_delete.h"
42 #include "set_general.h"
43 #include "set_quota.h"
44 #include "set_repprop.h"
45 #include "set_createrep.h"
46 #include "set_rename.h"
47 #include "set_release.h"
48 #include "set_clone.h"
50 #include "set_restore.h"
61 // As an additional debugging measure, you may want to enable the
62 // definition below--doing so causes the tool to ensure that
63 // AFSCLASS's critical section (accessed via AfsClass_Enter()/Leave()) is
64 // not leaking during tasks: for instance, if AfsClass_MoveFileset()
65 // calls AfsClass_Enter() three times but Leave() only twice, then an
66 // assertion will trigger in Task_Perform() (at which point it is
67 // not too late to easily determine which task leaked the critsec).
68 // Unfortunately, this has a side-effect: enabling the definition
69 // below prevents the AFSCLASS library from entirely exiting the
70 // critical section during its work--which means that only one
71 // AfsClass_* function can ever be run at once. So, enable this
72 // definition if you see a lockup--and disable it when you're done.
80 * PROTOTYPES _________________________________________________________________
85 void Task_ExportCell (LPTASKPACKET ptp);
87 void Task_OpenCell (LPTASKPACKET ptp);
88 void Task_OpenedCell (LPTASKPACKET ptp);
89 void Task_ClosedCell (LPTASKPACKET ptp);
90 void Task_Refresh (LPTASKPACKET ptp, BOOL fNewCreds);
91 void Task_Subset_To_List (LPTASKPACKET ptp);
92 void Task_Apply_Subset (LPTASKPACKET ptp);
93 void Task_Svr_Prop_Init (LPTASKPACKET ptp);
94 void Task_Svr_Scout_Init (LPTASKPACKET ptp);
95 void Task_Svr_Scout_Apply (LPTASKPACKET ptp);
96 void Task_Svr_Enum_To_ComboBox (LPTASKPACKET ptp);
97 void Task_Svr_GetWindowPos (LPTASKPACKET ptp);
98 void Task_Svr_SetWindowPos (LPTASKPACKET ptp);
99 void Task_Svr_SyncVLDB (LPTASKPACKET ptp);
100 void Task_Svr_Salvage (LPTASKPACKET ptp);
101 void Task_Svr_Install (LPTASKPACKET ptp);
102 void Task_Svr_Uninstall (LPTASKPACKET ptp);
103 void Task_Svr_Prune (LPTASKPACKET ptp);
104 void Task_Svr_GetDates (LPTASKPACKET ptp);
105 void Task_Svr_Execute (LPTASKPACKET ptp);
106 void Task_Svr_SetAuth (LPTASKPACKET ptp);
107 void Task_Svr_AdmList_Open (LPTASKPACKET ptp);
108 void Task_Svr_AdmList_Save (LPTASKPACKET ptp);
109 void Task_Svr_KeyList_Open (LPTASKPACKET ptp);
110 void Task_Svr_Key_Create (LPTASKPACKET ptp);
111 void Task_Svr_Key_Delete (LPTASKPACKET ptp);
112 void Task_Svr_HostList_Open (LPTASKPACKET ptp);
113 void Task_Svr_HostList_Save (LPTASKPACKET ptp);
114 void Task_Svr_GetRandomKey (LPTASKPACKET ptp);
115 void Task_Svr_Monitor_OnOff (LPTASKPACKET ptp);
116 void Task_Svr_ChangeAddr (LPTASKPACKET ptp);
117 void Task_Svc_Menu (LPTASKPACKET ptp);
118 void Task_Svc_Prop_Init (LPTASKPACKET ptp);
119 void Task_Svc_Prop_Apply (LPTASKPACKET ptp);
120 void Task_Svc_Start (LPTASKPACKET ptp);
121 void Task_Svc_Stop (LPTASKPACKET ptp);
122 void Task_Svc_Restart (LPTASKPACKET ptp);
123 void Task_Svc_FindLog (LPTASKPACKET ptp);
124 void Task_Svc_ViewLog (LPTASKPACKET ptp);
125 void Task_Svc_Create (LPTASKPACKET ptp);
126 void Task_Svc_Delete (LPTASKPACKET ptp);
127 void Task_Svc_GetRestartTimes (LPTASKPACKET ptp);
128 void Task_Svc_SetRestartTimes (LPTASKPACKET ptp);
129 void Task_Agg_Prop_Init (LPTASKPACKET ptp);
130 void Task_Agg_Prop_Apply (LPTASKPACKET ptp);
131 void Task_Agg_Find_Quota_Limits (LPTASKPACKET ptp);
132 void Task_Agg_Enum_To_ListView (LPTASKPACKET ptp);
133 void Task_Agg_Enum_To_ComboBox (LPTASKPACKET ptp);
134 void Task_Agg_Find_Ghost (LPTASKPACKET ptp);
135 void Task_Set_Enum_To_ComboBox (LPTASKPACKET ptp);
136 void Task_Set_Find_Ghost (LPTASKPACKET ptp);
137 void Task_Set_Create (LPTASKPACKET ptp);
138 void Task_Set_Delete (LPTASKPACKET ptp);
139 void Task_Set_Move (LPTASKPACKET ptp);
140 void Task_Set_MoveTo_Init (LPTASKPACKET ptp);
141 void Task_Set_Prop_Init (LPTASKPACKET ptp);
142 void Task_Set_Prop_Apply (LPTASKPACKET ptp);
143 void Task_Set_SetQuota_Init (LPTASKPACKET ptp);
144 void Task_Set_SetQuota_Apply (LPTASKPACKET ptp);
145 void Task_Set_RepProp_Init (LPTASKPACKET ptp);
146 void Task_Set_Select (LPTASKPACKET ptp);
147 void Task_Set_BeginDrag (LPTASKPACKET ptp);
148 void Task_Set_DragMenu (LPTASKPACKET ptp);
149 void Task_Set_Menu (LPTASKPACKET ptp);
150 void Task_Set_Lock (LPTASKPACKET ptp);
151 void Task_Set_Unlock (LPTASKPACKET ptp);
152 void Task_Set_CreateRep (LPTASKPACKET ptp);
153 void Task_Set_Rename_Init (LPTASKPACKET ptp);
154 void Task_Set_Rename_Apply (LPTASKPACKET ptp);
155 void Task_Set_Release (LPTASKPACKET ptp);
156 void Task_Set_Clone (LPTASKPACKET ptp);
157 void Task_Set_Clonesys (LPTASKPACKET ptp);
158 void Task_Set_Dump (LPTASKPACKET ptp);
159 void Task_Set_Restore (LPTASKPACKET ptp);
160 void Task_Set_Lookup (LPTASKPACKET ptp);
161 void Task_Expired_Creds (LPTASKPACKET ptp);
165 * ROUTINES ___________________________________________________________________
169 LPTASKPACKET CreateTaskPacket (int idTask, HWND hReply, PVOID lpUser)
173 if ((ptp = New (TASKPACKET)) != NULL)
175 memset (ptp, 0x00, sizeof(TASKPACKET));
177 ptp->idTask = idTask;
178 ptp->hReply = hReply;
179 ptp->lpUser = lpUser;
184 if ((ptp->pReturn = New (TASKPACKETDATA)) != NULL)
186 memset (ptp->pReturn, 0x00, sizeof(TASKPACKETDATA));
194 void FreeTaskPacket (LPTASKPACKET ptp)
200 if (TASKDATA(ptp)->pszText1)
201 FreeString (TASKDATA(ptp)->pszText1);
202 if (TASKDATA(ptp)->pszText2)
203 FreeString (TASKDATA(ptp)->pszText2);
204 if (TASKDATA(ptp)->pszText3)
205 FreeString (TASKDATA(ptp)->pszText3);
206 Delete (ptp->pReturn);
214 void PerformTask (LPTASKPACKET ptp)
218 ASSERT( AfsClass_GetEnterCount() == 1 );
225 Task_ExportCell (ptp);
234 Task_OpenedCell (ptp);
238 Task_ClosedCell (ptp);
242 Task_Refresh (ptp, FALSE);
245 case taskREFRESH_CREDS:
246 Task_Refresh (ptp, TRUE);
249 case taskSUBSET_TO_LIST:
250 Task_Subset_To_List (ptp);
253 case taskAPPLY_SUBSET:
254 Task_Apply_Subset (ptp);
257 case taskSVR_PROP_INIT:
258 Task_Svr_Prop_Init (ptp);
261 case taskSVR_SCOUT_INIT:
262 Task_Svr_Scout_Init (ptp);
265 case taskSVR_SCOUT_APPLY:
266 Task_Svr_Scout_Apply (ptp);
269 case taskSVR_ENUM_TO_COMBOBOX:
270 Task_Svr_Enum_To_ComboBox (ptp);
273 case taskSVR_GETWINDOWPOS:
274 Task_Svr_GetWindowPos (ptp);
277 case taskSVR_SETWINDOWPOS:
278 Task_Svr_SetWindowPos (ptp);
281 case taskSVR_SYNCVLDB:
282 Task_Svr_SyncVLDB (ptp);
285 case taskSVR_SALVAGE:
286 Task_Svr_Salvage (ptp);
289 case taskSVR_INSTALL:
290 Task_Svr_Install (ptp);
293 case taskSVR_UNINSTALL:
294 Task_Svr_Uninstall (ptp);
298 Task_Svr_Prune (ptp);
301 case taskSVR_GETDATES:
302 Task_Svr_GetDates (ptp);
305 case taskSVR_EXECUTE:
306 Task_Svr_Execute (ptp);
309 case taskSVR_SETAUTH:
310 Task_Svr_SetAuth (ptp);
313 case taskSVR_ADMLIST_OPEN:
314 Task_Svr_AdmList_Open (ptp);
317 case taskSVR_ADMLIST_SAVE:
318 Task_Svr_AdmList_Save (ptp);
321 case taskSVR_KEYLIST_OPEN:
322 Task_Svr_KeyList_Open (ptp);
325 case taskSVR_KEY_CREATE:
326 Task_Svr_Key_Create (ptp);
329 case taskSVR_KEY_DELETE:
330 Task_Svr_Key_Delete (ptp);
333 case taskSVR_GETRANDOMKEY:
334 Task_Svr_GetRandomKey (ptp);
337 case taskSVR_HOSTLIST_OPEN:
338 Task_Svr_HostList_Open (ptp);
341 case taskSVR_HOSTLIST_SAVE:
342 Task_Svr_HostList_Save (ptp);
345 case taskSVR_MONITOR_ONOFF:
346 Task_Svr_Monitor_OnOff (ptp);
349 case taskSVR_CHANGEADDR:
350 Task_Svr_ChangeAddr (ptp);
357 case taskSVC_PROP_INIT:
358 Task_Svc_Prop_Init (ptp);
361 case taskSVC_PROP_APPLY:
362 Task_Svc_Prop_Apply (ptp);
366 Task_Svc_Start (ptp);
373 case taskSVC_RESTART:
374 Task_Svc_Restart (ptp);
377 case taskSVC_FINDLOG:
378 Task_Svc_FindLog (ptp);
381 case taskSVC_VIEWLOG:
382 Task_Svc_ViewLog (ptp);
386 Task_Svc_Create (ptp);
390 Task_Svc_Delete (ptp);
393 case taskSVC_GETRESTARTTIMES:
394 Task_Svc_GetRestartTimes (ptp);
397 case taskSVC_SETRESTARTTIMES:
398 Task_Svc_SetRestartTimes (ptp);
401 case taskAGG_PROP_INIT:
402 Task_Agg_Prop_Init (ptp);
405 case taskAGG_PROP_APPLY:
406 Task_Agg_Prop_Apply (ptp);
409 case taskAGG_FIND_QUOTA_LIMITS:
410 Task_Agg_Find_Quota_Limits (ptp);
413 case taskAGG_ENUM_TO_LISTVIEW:
414 Task_Agg_Enum_To_ListView (ptp);
417 case taskAGG_ENUM_TO_COMBOBOX:
418 Task_Agg_Enum_To_ComboBox (ptp);
421 case taskAGG_FIND_GHOST:
422 Task_Agg_Find_Ghost (ptp);
425 case taskSET_ENUM_TO_COMBOBOX:
426 Task_Set_Enum_To_ComboBox (ptp);
429 case taskSET_FIND_GHOST:
430 Task_Set_Find_Ghost (ptp);
434 Task_Set_Create (ptp);
438 Task_Set_Delete (ptp);
445 case taskSET_MOVETO_INIT:
446 Task_Set_MoveTo_Init (ptp);
449 case taskSET_PROP_INIT:
450 Task_Set_Prop_Init (ptp);
453 case taskSET_PROP_APPLY:
454 Task_Set_Prop_Apply (ptp);
457 case taskSET_SETQUOTA_INIT:
458 Task_Set_SetQuota_Init (ptp);
461 case taskSET_SETQUOTA_APPLY:
462 Task_Set_SetQuota_Apply (ptp);
465 case taskSET_REPPROP_INIT:
466 Task_Set_RepProp_Init (ptp);
470 Task_Set_Select (ptp);
473 case taskSET_BEGINDRAG:
474 Task_Set_BeginDrag (ptp);
477 case taskSET_DRAGMENU:
478 Task_Set_DragMenu (ptp);
490 Task_Set_Unlock (ptp);
493 case taskSET_CREATEREP:
494 Task_Set_CreateRep (ptp);
497 case taskSET_RENAME_INIT:
498 Task_Set_Rename_Init (ptp);
501 case taskSET_RENAME_APPLY:
502 Task_Set_Rename_Apply (ptp);
505 case taskSET_RELEASE:
506 Task_Set_Release (ptp);
510 Task_Set_Clone (ptp);
513 case taskSET_CLONESYS:
514 Task_Set_Clonesys (ptp);
521 case taskSET_RESTORE:
522 Task_Set_Restore (ptp);
526 Task_Set_Lookup (ptp);
529 case taskEXPIRED_CREDS:
530 Task_Expired_Creds (ptp);
535 ptp->status = ERROR_INVALID_FUNCTION;
540 ASSERT( AfsClass_GetEnterCount() == 1 );
546 void CoverServerList (LPIDENT lpiCell, ULONG status)
548 TCHAR szName[ cchRESOURCE ];
549 lpiCell->GetCellName (szName);
555 case ERROR_NOT_AUTHENTICATED:
556 idsButton = IDS_ALERT_BUTTON_GETCREDS;
559 idsButton = IDS_ALERT_BUTTON_TRYAGAIN;
564 LPTSTR pszCover = FormatString (IDS_ERROR_REFRESH_CELLSERVERS, TEXT("%s%e"), szName, status);
565 LPTSTR pszButton = FormatString (idsButton);
567 AfsAppLib_CoverWindow (GetDlgItem (g.hMain, IDC_SERVERS), pszCover, pszButton);
569 FreeString (pszButton);
570 FreeString (pszCover);
575 ULONG SystemTimeToUnixTime (SYSTEMTIME *pst)
584 if (!SystemTimeToFileTime (&st, &ft))
588 now.HighPart = (LONG)ft.dwHighDateTime;
589 now.LowPart = (ULONG)ft.dwLowDateTime;
591 LARGE_INTEGER offset;
592 offset.HighPart = 0x019db1de;
593 offset.LowPart = 0xd53e8000;
595 LARGE_INTEGER result;
596 result.QuadPart = (now.QuadPart - offset.QuadPart) / 10000000;
597 return (ULONG)result.LowPart;
600 static size_t nExportLevels = 0;
601 void Task_ExportCell_Spacing (LPTSTR pszSpacing)
603 wsprintf (pszSpacing, TEXT("%99s"), TEXT(""));
604 pszSpacing[ nExportLevels *3 ] = TEXT('\0');
607 #define chLBRC TEXT('{')
608 #define chRBRC TEXT('}')
610 void Task_ExportCell_Begin (HANDLE fh, LPTSTR eck, LPTSTR pszName)
612 TCHAR szSpacing[ 256 ];
613 Task_ExportCell_Spacing (szSpacing);
615 wsprintf (szLine, TEXT("\r\n%s%s %s %c\r\n"), szSpacing, eck, pszName, chLBRC);
617 WriteFile (fh, szLine, lstrlen(szLine), &cbWrote, NULL);
621 void Task_ExportCell_End (HANDLE fh)
624 TCHAR szSpacing[ 256 ];
625 Task_ExportCell_Spacing (szSpacing);
627 wsprintf (szLine, TEXT("%s%c\r\n"), szSpacing, chRBRC);
629 WriteFile (fh, szLine, lstrlen(szLine), &cbWrote, NULL);
632 void Task_ExportCell_Line (HANDLE fh, LPTSTR eck, LPTSTR pszRHS)
634 TCHAR szSpacing[ 256 ];
635 Task_ExportCell_Spacing (szSpacing);
637 wsprintf (szLine, TEXT("%s%s = \"%s\"\r\n"), szSpacing, eck, pszRHS);
639 WriteFile (fh, szLine, lstrlen(szLine), &cbWrote, NULL);
642 void Task_ExportCell_LineAddr (HANDLE fh, LPTSTR eck, SOCKADDR_IN *pAddr)
644 LPSTR pszLine = FormatString (TEXT("%1"), TEXT("%a"), pAddr);
645 Task_ExportCell_Line (fh, eck, pszLine);
646 FreeString (pszLine);
649 void Task_ExportCell_LineInt (HANDLE fh, LPTSTR eck, int dw)
652 wsprintf (szLine, TEXT("%lu"), dw);
653 Task_ExportCell_Line (fh, eck, szLine);
656 void Task_ExportCell_LineLarge (HANDLE fh, LPTSTR eck, LARGE_INTEGER *pldw)
659 wsprintf (szLine, TEXT("%lu,,%lu"), pldw->HighPart, pldw->LowPart);
660 Task_ExportCell_Line (fh, eck, szLine);
663 void Task_ExportCell_LineDate (HANDLE fh, LPTSTR eck, SYSTEMTIME *pst)
665 Task_ExportCell_LineInt (fh, eck, SystemTimeToUnixTime(pst));
668 void Task_ExportService (HANDLE fh, LPSERVICE lpService)
670 TCHAR szName[ cchNAME ];
671 lpService->GetName (szName);
672 Task_ExportCell_Begin (fh, eckSERVICE, szName);
675 if (lpService->GetStatus (&ss))
677 Task_ExportCell_LineInt (fh, eckRUNNING, (ss.state == SERVICESTATE_RUNNING));
678 Task_ExportCell_LineInt (fh, eckSTATE, ss.state);
679 Task_ExportCell_LineInt (fh, eckNSTARTS, ss.nStarts);
680 Task_ExportCell_LineInt (fh, eckERRLAST, ss.dwErrLast);
681 Task_ExportCell_LineInt (fh, eckSIGLAST, ss.dwSigLast);
682 Task_ExportCell_Line (fh, eckPARAMS, ss.szParams);
683 Task_ExportCell_Line (fh, eckNOTIFIER, ss.szNotifier);
684 Task_ExportCell_LineDate (fh, eckSTARTTIME, &ss.timeLastStart);
685 Task_ExportCell_LineDate (fh, eckSTOPTIME, &ss.timeLastStop);
686 Task_ExportCell_LineDate (fh, eckERRORTIME, &ss.timeLastFail);
688 if (ss.type == SERVICETYPE_SIMPLE)
689 Task_ExportCell_Line (fh, eckTYPE, eckSIMPLE);
690 else if (ss.type == SERVICETYPE_CRON)
691 Task_ExportCell_Line (fh, eckTYPE, eckCRON);
692 else // (ss.type == SERVICETYPE_FS)
693 Task_ExportCell_Line (fh, eckTYPE, eckFS);
696 Task_ExportCell_End (fh);
699 void Task_ExportFileset (HANDLE fh, LPFILESET lpFileset)
701 TCHAR szName[ cchNAME ];
702 lpFileset->GetName (szName);
703 Task_ExportCell_Begin (fh, eckFILESET, szName);
706 if (lpFileset->GetStatus (&fs))
708 Task_ExportCell_LineInt (fh, eckID, fs.id);
709 Task_ExportCell_LineInt (fh, eckID_RW, fs.idReadWrite);
710 Task_ExportCell_LineInt (fh, eckID_BK, fs.idClone);
711 Task_ExportCell_LineInt (fh, eckUSED, fs.ckUsed);
712 Task_ExportCell_LineInt (fh, eckQUOTA, fs.ckQuota);
713 Task_ExportCell_LineDate (fh, eckCREATETIME, &fs.timeCreation);
714 Task_ExportCell_LineDate (fh, eckUPDATETIME, &fs.timeLastUpdate);
715 Task_ExportCell_LineDate (fh, eckACCESSTIME, &fs.timeLastAccess);
716 Task_ExportCell_LineDate (fh, eckBACKUPTIME, &fs.timeLastBackup);
719 Task_ExportCell_End (fh);
722 void Task_ExportAggregate (HANDLE fh, LPAGGREGATE lpAggregate)
724 TCHAR szName[ cchNAME ];
725 lpAggregate->GetName (szName);
726 Task_ExportCell_Begin (fh, eckAGGREGATE, szName);
728 lpAggregate->GetDevice (szName);
729 Task_ExportCell_Line (fh, eckDEVICE, szName);
732 if (lpAggregate->GetStatus (&as))
734 Task_ExportCell_LineInt (fh, eckID, (int)as.dwID);
735 Task_ExportCell_LineInt (fh, eckTOTAL, (int)as.ckStorageTotal);
736 Task_ExportCell_LineInt (fh, eckFREECUR, (int)as.ckStorageFree);
740 for (LPFILESET lpFileset = lpAggregate->FilesetFindFirst (&hEnum); lpFileset; lpFileset = lpAggregate->FilesetFindNext (&hEnum))
742 Task_ExportFileset (fh, lpFileset);
746 Task_ExportCell_End (fh);
749 void Task_ExportServer (HANDLE fh, LPSERVER lpServer)
751 TCHAR szName[ cchNAME ];
752 lpServer->GetLongName (szName);
753 Task_ExportCell_Begin (fh, eckSERVER, szName);
755 // First, properties of the server
758 if (lpServer->GetStatus (&ss))
760 for (size_t iAddr = 0; iAddr < ss.nAddresses; ++iAddr)
761 Task_ExportCell_LineAddr (fh, eckADDRESS, &ss.aAddresses[ iAddr ]);
764 // Then, services on the server
767 for (LPSERVICE lpService = lpServer->ServiceFindFirst (&hEnum); lpService; lpService = lpServer->ServiceFindNext (&hEnum))
769 Task_ExportService (fh, lpService);
773 // Then, aggregates and filesets on the server
775 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&hEnum); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&hEnum))
777 Task_ExportAggregate (fh, lpAggregate);
778 lpAggregate->Close();
781 Task_ExportCell_End (fh);
784 void Task_ExportCell (LPTASKPACKET ptp)
786 LPTSTR pszFilename = (LPTSTR)(ptp->lpUser);
789 fh = CreateFile (pszFilename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL);
790 if (fh != INVALID_HANDLE_VALUE)
792 TCHAR szName[ cchNAME ];
793 g.lpiCell->GetCellName (szName);
794 Task_ExportCell_Begin (fh, eckCELL, szName);
797 if ((lpCell = g.lpiCell->OpenCell()) != NULL)
800 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
802 Task_ExportServer (fh, lpServer);
809 Task_ExportCell_End (fh);
813 Delete (pszFilename);
814 ptp->lpUser = 0; // we freed this; don't let the caller use it again
819 void Task_OpenCell (LPTASKPACKET ptp)
821 LPOPENCELL_PACKET lpp = (LPOPENCELL_PACKET)(ptp->lpUser);
823 LPSUBSET subOld = g.sub;
826 if ((TASKDATA(ptp)->lpiCell = CELL::OpenCell (lpp->szCell, lpp->hCreds, &ptp->status)) == NULL)
832 Subsets_FreeSubset (lpp->sub);
836 Subsets_FreeSubset (subOld);
841 PostMessage (g.hMain, WM_SHOW_YOURSELF, 0, 1);
844 PostMessage (g.hMain, WM_OPEN_ACTIONS, 0, 0);
846 else if (lpp->fCloseAppOnFail)
848 FatalErrorDialog (ptp->status, IDS_ERROR_CANT_OPEN_CELL, TEXT("%s"), lpp->szCell);
852 ptp->lpUser = 0; // we freed this; don't let the caller use it again
856 void Task_OpenedCell (LPTASKPACKET ptp)
858 LPIDENT lpiCell = (LPIDENT)(ptp->lpUser);
860 if (lpiCell && lpiCell->fIsCell())
864 DontNotifyMeEver (g.hMain);
865 NotifyMe (WHEN_CELL_OPENED, NULL, g.hMain, 0);
866 NotifyMe (WHEN_OBJECT_CHANGES, lpiCell, g.hMain, 0);
867 NotifyMe (WHEN_SVRS_CHANGE, lpiCell, g.hMain, 0);
869 if (g.lpiCell != NULL)
871 CELL::CloseCell (g.lpiCell);
875 UpdateDisplay_Cell (TRUE);
877 TCHAR szName[ cchRESOURCE ];
878 lpiCell->GetCellName (szName);
880 LPTSTR pszCover = FormatString (IDS_SEARCHING_FOR_SERVERS, TEXT("%s"), szName);
881 AfsAppLib_CoverWindow (GetDlgItem (g.hMain, IDC_SERVERS), pszCover);
882 FreeString (pszCover);
885 if ((lpCell = g.lpiCell->OpenCell (&ptp->status)) == NULL)
887 CoverServerList (g.lpiCell, ptp->status);
891 lpCell->Invalidate();
892 if ((ptp->rc = lpCell->RefreshAll (&ptp->status)) != TRUE)
894 CoverServerList (g.lpiCell, ptp->status);
899 PostMessage (g.hMain, WM_OPEN_SERVERS, 0, 0);
907 void Task_ClosedCell (LPTASKPACKET ptp)
909 LPIDENT lpiCell = (LPIDENT)(ptp->lpUser);
911 if (lpiCell && lpiCell->fIsCell())
915 if (g.lpiCell == lpiCell)
918 if ((lpCellTest = g.lpiCell->OpenCell()) != NULL)
920 // the user must have opened a cell, then opened it again.
921 // this is a bogus request to close the old copy of the
927 Server_CloseAll (FALSE);
929 Main_Redraw_ThreadProc ((PVOID)FALSE);
938 void Task_Refresh (LPTASKPACKET ptp, BOOL fNewCreds)
940 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
943 if (lpi && lpi->fIsCell())
945 AfsAppLib_Uncover (GetDlgItem (g.hMain, IDC_SERVERS));
948 if ((lpCell = lpi->OpenCell (&ptp->status)) == NULL)
950 CoverServerList (lpi, ptp->status);
955 lpCell->SetCurrentCredentials (g.hCreds);
957 lpCell->Invalidate();
958 if ((ptp->rc = lpCell->RefreshAll (&ptp->status)) != TRUE)
960 CoverServerList (lpi, ptp->status);
965 else if (lpi && lpi->GetServer())
967 BOOL fWasMonitored = TRUE;
970 if ((lpServer = lpi->OpenServer()) != NULL)
972 if ((fWasMonitored = lpServer->fIsMonitored()) == FALSE)
973 lpServer->SetMonitor (TRUE);
977 if (fWasMonitored) // if it was already monitored, we didn't just refresh
979 if (lpi && lpi->fIsServer())
981 if ((lpServer = lpi->OpenServer()) != NULL)
983 lpServer->Invalidate();
984 lpServer->RefreshAll();
988 else if (lpi && lpi->fIsService())
991 if ((lpService = lpi->OpenService()) != NULL)
993 lpService->Invalidate();
994 lpService->RefreshStatus();
998 else if (lpi && lpi->fIsAggregate())
1000 LPAGGREGATE lpAggregate;
1001 if ((lpAggregate = lpi->OpenAggregate()) != NULL)
1003 // if we implied this aggregate from fileset VLDB entries,
1004 // refresh its parent server, not this aggregate.
1006 if (!(lpAggregate->GetGhostStatus() & GHOST_HAS_SERVER_ENTRY))
1008 lpAggregate->Close();
1011 if ((lpServer = lpi->OpenServer()) != NULL)
1013 lpServer->Invalidate();
1014 lpServer->RefreshAll();
1020 lpAggregate->Invalidate();
1021 lpAggregate->RefreshStatus();
1022 lpAggregate->RefreshFilesets();
1023 lpAggregate->Close();
1026 if ((lpCell = lpi->OpenCell()) != NULL)
1028 lpCell->RefreshVLDB (lpi);
1034 else if (lpi && lpi->fIsFileset())
1036 LPFILESET lpFileset;
1037 if ((lpFileset = lpi->OpenFileset()) != NULL)
1039 lpFileset->Invalidate();
1040 lpFileset->RefreshStatus();
1044 if ((lpCell = lpi->OpenCell()) != NULL)
1046 lpCell->RefreshVLDB (lpi);
1053 Alert_Scout_QueueCheckServer (lpi);
1060 void Task_Subset_To_List (LPTASKPACKET ptp)
1062 LPSUBSET_TO_LIST_PACKET lpp = (LPSUBSET_TO_LIST_PACKET)( ptp->lpUser );
1064 LB_StartChange (lpp->hList, TRUE);
1066 LPCELL lpCell = NULL;
1068 lpCell = g.lpiCell->OpenCell();
1072 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
1074 LPIDENT lpiServer = lpServer->GetIdentifier();
1075 TCHAR szServer[ cchNAME ];
1076 lpServer->GetName (szServer);
1079 BOOL fMonitor = Subsets_fMonitorServer (lpp->sub, lpiServer);
1081 LB_AddItem (lpp->hList, szServer, (LPARAM)fMonitor);
1087 LB_EndChange (lpp->hList);
1090 ptp->lpUser = 0; // we freed this; don't let anyone use it.
1094 void Task_Apply_Subset (LPTASKPACKET ptp)
1096 LPSUBSET sub = (LPSUBSET)( ptp->lpUser );
1098 LPCELL lpCell = NULL;
1100 lpCell = g.lpiCell->OpenCell();
1104 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
1106 LPIDENT lpiServer = lpServer->GetIdentifier();
1107 TCHAR szServer[ cchNAME ];
1108 lpServer->GetName (szServer);
1110 BOOL fMonitor = Subsets_fMonitorServer (sub, lpiServer);
1111 lpServer->SetMonitor (fMonitor);
1122 void Task_Svr_Prop_Init (LPTASKPACKET ptp)
1124 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1127 if ((lpServer = lpiServer->OpenServer (&ptp->status)) == NULL)
1131 if (!lpServer->GetStatus (&TASKDATA(ptp)->ss, TRUE, &ptp->status))
1138 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&hEnum); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&hEnum))
1141 if (lpAggregate->GetStatus (&as))
1143 TASKDATA(ptp)->ckCapacity += as.ckStorageTotal;
1144 TASKDATA(ptp)->ckAllocation += as.ckStorageAllocated;
1147 TASKDATA(ptp)->nAggr++;
1148 lpAggregate->Close();
1157 void Task_Svr_Scout_Init (LPTASKPACKET ptp)
1159 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1161 if ((TASKDATA(ptp)->lpsp = (LPSERVER_PREF)lpiServer->GetUserParam()) == NULL)
1164 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1169 void Task_Svr_Scout_Apply (LPTASKPACKET ptp)
1171 LPSVR_SCOUT_APPLY_PACKET lpp = (LPSVR_SCOUT_APPLY_PACKET)(ptp->lpUser);
1173 BOOL fRefreshVLDB = FALSE;
1175 LPSERVER_PREF lpsp = NULL;
1176 if ((lpsp = (LPSERVER_PREF)lpp->lpiServer->GetUserParam()) == NULL)
1179 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1183 if (!lpp->fIDC_SVR_WARN_AGGFULL)
1184 lpsp->perWarnAggFull = 0;
1186 lpsp->perWarnAggFull = lpp->wIDC_SVR_WARN_AGGFULL_PERCENT;
1188 if (!lpp->fIDC_SVR_WARN_SETFULL)
1189 lpsp->perWarnSetFull = 0;
1191 lpsp->perWarnSetFull = lpp->wIDC_SVR_WARN_SETFULL_PERCENT;
1193 DWORD fOldWarnSet = (lpsp->fWarnSetNoVLDB << 1) | lpsp->fWarnSetNoServ;
1195 lpsp->fWarnAggAlloc = lpp->fIDC_SVR_WARN_AGGALLOC;
1196 lpsp->fWarnSvcStop = lpp->fIDC_SVR_WARN_SVCSTOP;
1197 lpsp->fWarnSvrTimeout = lpp->fIDC_SVR_WARN_TIMEOUT;
1198 lpsp->fWarnSetNoVLDB = lpp->fIDC_SVR_WARN_SETNOVLDB;
1199 lpsp->fWarnSetNoServ = lpp->fIDC_SVR_WARN_SETNOSERV;
1200 lpsp->fWarnAggNoServ = lpp->fIDC_SVR_WARN_AGGNOSERV;
1202 DWORD fNewWarnSet = (lpsp->fWarnSetNoVLDB << 1) | lpsp->fWarnSetNoServ;
1204 if (fNewWarnSet != fOldWarnSet)
1205 fRefreshVLDB = TRUE;
1207 if (!lpp->fIDC_SVR_AUTOREFRESH)
1208 lpsp->oa.cTickRefresh = 0;
1210 lpsp->oa.cTickRefresh = cmsec1MINUTE * lpp->dwIDC_SVR_AUTOREFRESH_MINUTES;
1212 if (!Server_SavePreferences (lpp->lpiServer))
1215 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1222 if ((lpCell = lpp->lpiServer->OpenCell()) != NULL)
1224 lpCell->RefreshVLDB (NULL);
1229 (void)Alert_Scout_QueueCheckServer (lpp->lpiServer);
1232 ptp->lpUser = 0; // we freed this; don't let anyone use it.
1236 void Task_Svr_Enum_To_ComboBox (LPTASKPACKET ptp)
1238 LPSVR_ENUM_TO_COMBOBOX_PACKET lpp = (LPSVR_ENUM_TO_COMBOBOX_PACKET)(ptp->lpUser);
1240 // Fill in the Servers combobox, and select the default server
1241 // (if one was specified, either as a server or as a fileset).
1243 CB_StartChange (lpp->hCombo, TRUE);
1246 if ((lpCell = g.lpiCell->OpenCell (&ptp->status)) == NULL)
1251 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
1253 TCHAR szName[ cchNAME ];
1254 lpServer->GetName (szName);
1255 CB_AddItem (lpp->hCombo, szName, (LPARAM)lpServer->GetIdentifier());
1261 if (lpp->lpiSelect && lpp->lpiSelect->GetServer())
1262 CB_EndChange (lpp->hCombo, (LPARAM)(lpp->lpiSelect->GetServer()));
1265 CB_EndChange (lpp->hCombo, 0);
1266 CB_SetSelected (lpp->hCombo, 0);
1270 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
1274 void Task_Svr_GetWindowPos (LPTASKPACKET ptp)
1276 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1278 SetRectEmpty (&TASKDATA(ptp)->rWindow);
1282 LPSERVER_PREF lpsp = (LPSERVER_PREF)lpi->GetUserParam();
1284 if (lpsp != NULL && (lpsp->rLast.right != 0))
1286 TASKDATA(ptp)->rWindow = lpsp->rLast;
1292 void Task_Svr_SetWindowPos (LPTASKPACKET ptp)
1294 LPSVR_SETWINDOWPOS_PARAMS lpp = (LPSVR_SETWINDOWPOS_PARAMS)(ptp->lpUser);
1298 LPSERVER_PREF lpsp = (LPSERVER_PREF)(lpp->lpi->GetUserParam());
1302 lpsp->rLast = lpp->rWindow;
1303 lpsp->fOpen = lpp->fOpen;
1305 StorePreferences (lpp->lpi, lpsp, sizeof(SERVER_PREF));
1310 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
1314 void Task_Svr_SyncVLDB (LPTASKPACKET ptp)
1316 LPSVR_SYNCVLDB_PARAMS lpp = (LPSVR_SYNCVLDB_PARAMS)(ptp->lpUser);
1318 if (!AfsClass_SyncVLDB (lpp->lpi, lpp->fForce, &ptp->status))
1321 if (!ptp->rc && !IsWindow (ptp->hReply))
1323 ErrorDialog (ptp->status, IDS_ERROR_CANT_SYNCVLDB);
1327 ptp->lpUser = 0; // we freed this; don't let anyone use it.
1331 void Task_Svr_Salvage (LPTASKPACKET ptp)
1333 LPSVR_SALVAGE_PARAMS lpp = (LPSVR_SALVAGE_PARAMS)(ptp->lpUser);
1335 LPTSTR pszTempDir = (lpp->szTempDir[0] != TEXT('\0')) ? lpp->szTempDir : NULL;
1336 LPTSTR pszLogFile = (lpp->szLogFile[0] != TEXT('\0')) ? lpp->szLogFile : NULL;
1338 if (!AfsClass_Salvage (lpp->lpiSalvage, &TASKDATA(ptp)->pszText1, lpp->nProcesses, pszTempDir, pszLogFile, lpp->fForce, lpp->fReadonly, lpp->fLogInodes, lpp->fLogRootInodes, lpp->fRebuildDirs, lpp->fReadBlocks, &ptp->status))
1342 ptp->lpUser = 0; // we freed this; don't let anyone use it.
1346 void Task_Svr_Install (LPTASKPACKET ptp)
1348 LPSVR_INSTALL_PARAMS lpp = (LPSVR_INSTALL_PARAMS)(ptp->lpUser);
1350 ptp->rc = AfsClass_InstallFile (lpp->lpiServer, lpp->szTarget, lpp->szSource, &ptp->status);
1352 if (!ptp->rc && !ptp->hReply)
1354 TCHAR szFilename[ MAX_PATH ];
1355 TCHAR szSvrName[ cchRESOURCE ];
1356 lpp->lpiServer->GetServerName (szSvrName);
1357 CopyBaseFileName (szFilename, lpp->szSource);
1358 ErrorDialog (ptp->status, IDS_ERROR_CANT_INSTALL_FILE, TEXT("%s%s"), szSvrName, szFilename);
1362 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1366 void Task_Svr_Uninstall (LPTASKPACKET ptp)
1368 LPSVR_UNINSTALL_PARAMS lpp = (LPSVR_UNINSTALL_PARAMS)(ptp->lpUser);
1370 ptp->rc = AfsClass_UninstallFile (lpp->lpiServer, lpp->szUninstall, &ptp->status);
1372 if (!ptp->rc && !ptp->hReply)
1374 TCHAR szFilename[ MAX_PATH ];
1375 TCHAR szSvrName[ cchRESOURCE ];
1376 lpp->lpiServer->GetServerName (szSvrName);
1377 CopyBaseFileName (szFilename, lpp->szUninstall);
1378 ErrorDialog (ptp->status, IDS_ERROR_CANT_UNINSTALL_FILE, TEXT("%s%s"), szSvrName, szFilename);
1382 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1386 void Task_Svr_Prune (LPTASKPACKET ptp)
1388 LPSVR_PRUNE_PARAMS lpp = (LPSVR_PRUNE_PARAMS)(ptp->lpUser);
1390 ptp->rc = AfsClass_PruneOldFiles (lpp->lpiServer, lpp->fBAK, lpp->fOLD, lpp->fCore, &ptp->status);
1392 if (!ptp->rc && !ptp->hReply)
1394 TCHAR szSvrName[ cchRESOURCE ];
1395 lpp->lpiServer->GetServerName (szSvrName);
1396 ErrorDialog (ptp->status, IDS_ERROR_CANT_PRUNE_FILES, TEXT("%s"), szSvrName);
1400 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1404 void Task_Svr_GetDates (LPTASKPACKET ptp)
1406 LPSVR_GETDATES_PARAMS lpp = (LPSVR_GETDATES_PARAMS)(ptp->lpUser);
1412 ptp->rc = AfsClass_GetFileDates (lpp->lpiServer, lpp->szFilename, &stFile, &stBAK, &stOLD, &ptp->status);
1416 TCHAR szText[ cchRESOURCE ];
1417 if (FormatTime (szText, TEXT("%s"), &stFile))
1418 TASKDATA(ptp)->pszText1 = CloneString (szText);
1420 if (FormatTime (szText, TEXT("%s"), &stBAK))
1421 TASKDATA(ptp)->pszText2 = CloneString (szText);
1423 if (FormatTime (szText, TEXT("%s"), &stOLD))
1424 TASKDATA(ptp)->pszText3 = CloneString (szText);
1428 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1432 void Task_Svr_Execute (LPTASKPACKET ptp)
1434 LPSVR_EXECUTE_PARAMS lpp = (LPSVR_EXECUTE_PARAMS)(ptp->lpUser);
1436 ptp->rc = AfsClass_ExecuteCommand (lpp->lpiServer, lpp->szCommand, &ptp->status);
1440 TCHAR szServer[ cchNAME ];
1441 lpp->lpiServer->GetServerName (szServer);
1442 ErrorDialog (ptp->status, IDS_ERROR_CANT_EXECUTE_COMMAND, TEXT("%s%s"), szServer, lpp->szCommand);
1446 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1450 void Task_Svr_SetAuth (LPTASKPACKET ptp)
1452 LPSVR_SETAUTH_PARAMS lpp = (LPSVR_SETAUTH_PARAMS)(ptp->lpUser);
1454 ptp->rc = AfsClass_SetServerAuth (lpp->lpiServer, lpp->fEnableAuth, &ptp->status);
1458 TCHAR szServer[ cchNAME ];
1459 lpp->lpiServer->GetServerName (szServer);
1460 ErrorDialog (ptp->status, (lpp->fEnableAuth) ? IDS_ERROR_CANT_AUTH_ON : IDS_ERROR_CANT_AUTH_OFF, TEXT("%s"), szServer);
1464 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1468 void Task_Svr_AdmList_Open (LPTASKPACKET ptp)
1470 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1472 if ((TASKDATA(ptp)->lpAdmList = AfsClass_AdminList_Load (lpiServer, &ptp->status)) == NULL)
1476 TCHAR szServer[ cchNAME ];
1477 lpiServer->GetServerName (szServer);
1478 ErrorDialog (ptp->status, IDS_ERROR_CANT_LOAD_ADMLIST, TEXT("%s"), szServer);
1483 void Task_Svr_AdmList_Save (LPTASKPACKET ptp)
1485 LPADMINLIST lpAdmList = (LPADMINLIST)(ptp->lpUser);
1487 // Increment the reference counter on this admin list before handing
1488 // it off to the Save routine, as that routine will be posting
1489 // notifications using its handle. When our notification handler
1490 // receives the End notification, it will attempt to free the list--
1491 // which will decrement the counter again, and actually free the list
1492 // if the counter hits zero.
1494 InterlockedIncrement (&lpAdmList->cRef);
1496 ptp->rc = AfsClass_AdminList_Save (lpAdmList, &ptp->status);
1500 TCHAR szServer[ cchNAME ];
1501 lpAdmList->lpiServer->GetServerName (szServer);
1502 ErrorDialog (ptp->status, IDS_ERROR_CANT_SAVE_ADMLIST, TEXT("%s"), szServer);
1505 AfsClass_AdminList_Free (lpAdmList);
1506 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1510 void Task_Svr_KeyList_Open (LPTASKPACKET ptp)
1512 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1514 if ((TASKDATA(ptp)->lpKeyList = AfsClass_KeyList_Load (lpiServer, &ptp->status)) == NULL)
1518 TCHAR szServer[ cchNAME ];
1519 lpiServer->GetServerName (szServer);
1520 ErrorDialog (ptp->status, IDS_ERROR_CANT_LOAD_KEYLIST, TEXT("%s"), szServer);
1525 void Task_Svr_Key_Create (LPTASKPACKET ptp)
1527 LPKEY_CREATE_PARAMS lpp = (LPKEY_CREATE_PARAMS)(ptp->lpUser);
1529 if (lpp->szString[0])
1530 ptp->rc = AfsClass_AddKey (lpp->lpiServer, lpp->keyVersion, lpp->szString, &ptp->status);
1532 ptp->rc = AfsClass_AddKey (lpp->lpiServer, lpp->keyVersion, &lpp->key, &ptp->status);
1534 if ((TASKDATA(ptp)->lpKeyList = AfsClass_KeyList_Load (lpp->lpiServer, &ptp->status)) == NULL)
1538 TCHAR szServer[ cchNAME ];
1539 lpp->lpiServer->GetServerName (szServer);
1540 ErrorDialog (ptp->status, IDS_ERROR_CANT_CREATE_KEY, TEXT("%s"), szServer);
1544 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1548 void Task_Svr_Key_Delete (LPTASKPACKET ptp)
1550 LPKEY_DELETE_PARAMS lpp = (LPKEY_DELETE_PARAMS)(ptp->lpUser);
1552 if (!AfsClass_DeleteKey (lpp->lpiServer, lpp->keyVersion, &ptp->status))
1556 TCHAR szServer[ cchNAME ];
1557 lpp->lpiServer->GetServerName (szServer);
1558 ErrorDialog (ptp->status, IDS_ERROR_CANT_DELETE_KEY, TEXT("%s%lu"), szServer, lpp->keyVersion);
1562 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1566 void Task_Svr_GetRandomKey (LPTASKPACKET ptp)
1568 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1570 if (!AfsClass_GetRandomKey (lpiServer, &TASKDATA(ptp)->key, &ptp->status))
1574 TCHAR szServer[ cchNAME ];
1575 lpiServer->GetServerName (szServer);
1576 ErrorDialog (ptp->status, IDS_ERROR_CANT_GETRANDOMKEY, TEXT("%s"), szServer);
1581 void Task_Svr_HostList_Open (LPTASKPACKET ptp)
1583 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1585 if ((TASKDATA(ptp)->lpHostList = AfsClass_HostList_Load (lpiServer, &ptp->status)) == NULL)
1589 TCHAR szServer[ cchNAME ];
1590 lpiServer->GetServerName (szServer);
1591 ErrorDialog (ptp->status, IDS_ERROR_CANT_LOAD_HOSTLIST, TEXT("%s"), szServer);
1596 void Task_Svr_HostList_Save (LPTASKPACKET ptp)
1598 LPHOSTLIST lpHostList = (LPHOSTLIST)(ptp->lpUser);
1600 // Increment the reference counter on this admin list before handing
1601 // it off to the Save routine, as that routine will be posting
1602 // notifications using its handle. When our notification handler
1603 // receives the End notification, it will attempt to free the list--
1604 // which will decrement the counter again, and actually free the list
1605 // if the counter hits zero.
1607 InterlockedIncrement (&lpHostList->cRef);
1609 ptp->rc = AfsClass_HostList_Save (lpHostList, &ptp->status);
1613 TCHAR szServer[ cchNAME ];
1614 lpHostList->lpiServer->GetServerName (szServer);
1615 ErrorDialog (ptp->status, IDS_ERROR_CANT_SAVE_HOSTLIST, TEXT("%s"), szServer);
1618 AfsClass_HostList_Free (lpHostList);
1619 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1623 void Task_Svr_Monitor_OnOff (LPTASKPACKET ptp)
1625 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1628 if ((lpServer = lpiServer->OpenServer()) != NULL)
1630 BOOL fMonitored = lpServer->fIsMonitored();
1632 g.sub = Subsets_SetMonitor (g.sub, lpiServer, !fMonitored);
1634 lpServer->SetMonitor (!fMonitored);
1641 void Task_Svr_ChangeAddr (LPTASKPACKET ptp)
1643 LPSVR_CHANGEADDR_PARAMS lpp = (LPSVR_CHANGEADDR_PARAMS)(ptp->lpUser);
1645 if ((ptp->rc = AfsClass_ChangeAddress (lpp->lpiServer, &lpp->ssOld, &lpp->ssNew, &ptp->status)) == FALSE)
1647 TCHAR szName[ cchRESOURCE ];
1648 lpp->lpiServer->GetServerName (szName);
1649 ErrorDialog (ptp->status, IDS_ERROR_CANT_CHANGEADDR, TEXT("%s"), szName);
1653 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1657 void Task_Svc_Menu (LPTASKPACKET ptp)
1659 TASKDATA(ptp)->mt = *(LPMENUTASK)(ptp->lpUser);
1660 Delete ((LPMENUTASK)(ptp->lpUser));
1661 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
1663 if (TASKDATA(ptp)->mt.lpi && TASKDATA(ptp)->mt.lpi->fIsService())
1665 LPSERVICE lpService;
1666 if ((lpService = TASKDATA(ptp)->mt.lpi->OpenService (&ptp->status)) == NULL)
1670 if (!lpService->GetStatus (&TASKDATA(ptp)->cs, FALSE, &ptp->status))
1678 void Task_Svc_Prop_Init (LPTASKPACKET ptp)
1680 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1682 LPSERVICE lpService;
1683 if ((lpService = lpi->OpenService (&ptp->status)) == NULL)
1687 if (!lpService->GetStatus (&TASKDATA(ptp)->cs, TRUE, &ptp->status))
1691 else if ((TASKDATA(ptp)->lpcp = (LPSERVICE_PREF)lpi->GetUserParam()) == NULL)
1694 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1701 if ((TASKDATA(ptp)->lpsp = (LPSERVER_PREF)lpi->GetServer()->GetUserParam()) == NULL)
1704 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1710 void Task_Svc_Prop_Apply (LPTASKPACKET ptp)
1712 LPSVC_PROP_APPLY_PACKET lpp = (LPSVC_PROP_APPLY_PACKET)(ptp->lpUser);
1714 LPSERVICE lpService;
1715 if ((lpService = lpp->lpi->OpenService (&ptp->status)) == NULL)
1719 LPSERVICE_PREF lpcp = NULL;
1720 if ((lpcp = (LPSERVICE_PREF)lpp->lpi->GetUserParam()) == NULL)
1723 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1728 if ((lpiServer = lpp->lpi->GetServer()) != NULL)
1731 if ((lpsp = (LPSERVER_PREF)lpiServer->GetUserParam()) != NULL)
1733 if (lpsp->fWarnSvcStop)
1734 lpcp->fWarnSvcStop = lpp->fIDC_SVC_WARNSTOP;
1738 if (!Services_SavePreferences (lpp->lpi))
1741 ptp->status = GetLastError();
1748 (void)Alert_Scout_QueueCheckServer (lpp->lpi);
1751 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1755 void Task_Svc_Start (LPTASKPACKET ptp)
1757 LPSVC_START_PARAMS lpp = (LPSVC_START_PARAMS)(ptp->lpUser);
1759 if (!AfsClass_StartService (lpp->lpiStart, lpp->fTemporary, &ptp->status))
1762 if (!ptp->rc && !ptp->hReply)
1764 TCHAR szSvrName[ cchRESOURCE ];
1765 TCHAR szSvcName[ cchRESOURCE ];
1766 lpp->lpiStart->GetServerName (szSvrName);
1767 lpp->lpiStart->GetServiceName (szSvcName);
1768 ErrorDialog (ptp->status, IDS_ERROR_CANT_START_SERVICE, TEXT("%s%s"), szSvrName, szSvcName);
1772 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1776 void Task_Svc_Stop (LPTASKPACKET ptp)
1778 LPSVC_STOP_PARAMS lpp = (LPSVC_STOP_PARAMS)(ptp->lpUser);
1780 if (!AfsClass_StopService (lpp->lpiStop, lpp->fTemporary, TRUE, &ptp->status))
1783 if (!ptp->rc && !ptp->hReply)
1785 TCHAR szSvrName[ cchRESOURCE ];
1786 TCHAR szSvcName[ cchRESOURCE ];
1787 lpp->lpiStop->GetServerName (szSvrName);
1788 lpp->lpiStop->GetServiceName (szSvcName);
1789 ErrorDialog (ptp->status, IDS_ERROR_CANT_STOP_SERVICE, TEXT("%s%s"), szSvrName, szSvcName);
1793 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1797 void Task_Svc_Restart (LPTASKPACKET ptp)
1799 LPIDENT lpiService = (LPIDENT)(ptp->lpUser);
1801 if (!AfsClass_RestartService (lpiService, &ptp->status))
1804 if (!ptp->rc && !ptp->hReply)
1806 TCHAR szSvrName[ cchRESOURCE ];
1807 TCHAR szSvcName[ cchRESOURCE ];
1808 lpiService->GetServerName (szSvrName);
1809 lpiService->GetServiceName (szSvcName);
1810 ErrorDialog (ptp->status, IDS_ERROR_CANT_RESTART_SERVICE, TEXT("%s%s"), szSvrName, szSvcName);
1815 void Task_Svc_FindLog (LPTASKPACKET ptp)
1817 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1819 if ((TASKDATA(ptp)->lpcp = (LPSERVICE_PREF)lpi->GetUserParam()) == NULL)
1822 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1827 if (TASKDATA(ptp)->lpcp->szLogFile[0] == TEXT('\0'))
1830 ptp->status = ERROR_FILE_NOT_FOUND;
1836 if ((TASKDATA(ptp)->pszText1 = CloneString (TASKDATA(ptp)->lpcp->szLogFile)) == NULL)
1839 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1845 void Task_Svc_ViewLog (LPTASKPACKET ptp)
1847 LPSVC_VIEWLOG_PACKET lpp = (LPSVC_VIEWLOG_PACKET)(ptp->lpUser);
1849 TCHAR szTempPath[ MAX_PATH ];
1850 GetTempPath (MAX_PATH, szTempPath);
1852 TCHAR szFilename[ MAX_PATH ];
1853 GetTempFileName (szTempPath, TEXT("log"), 0, szFilename);
1855 if (!AfsClass_GetServerLogFile (lpp->lpiServer, szFilename, lpp->szRemote, &ptp->status))
1857 DeleteFile (szFilename);
1863 if ((TASKDATA(ptp)->pszText1 = CloneString (szFilename)) == NULL)
1866 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1871 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1875 void Task_Svc_Create (LPTASKPACKET ptp)
1877 LPSVC_CREATE_PARAMS lpp = (LPSVC_CREATE_PARAMS)(ptp->lpUser);
1880 if ((lpiService = AfsClass_CreateService (lpp->lpiServer, lpp->szService, lpp->szCommand, lpp->szParams, lpp->szNotifier, lpp->type, &lpp->stIfCron, &ptp->status)) == NULL)
1887 // Start it if necessary
1889 if ((lpp->type == SERVICETYPE_SIMPLE) && (lpp->fRunNow))
1891 if (!AfsClass_StartService (lpiService, FALSE, &ptp->status))
1898 if (ptp->rc && lpp->szLogFile[0])
1900 LPSERVICE_PREF lpsp;
1901 if ((lpsp = (LPSERVICE_PREF)lpiService->GetUserParam()) != NULL)
1903 lstrcpy (lpsp->szLogFile, lpp->szLogFile);
1905 if (!Services_SavePreferences (lpiService))
1908 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1915 TCHAR szServer[ cchNAME ];
1916 lpp->lpiServer->GetServerName (szServer);
1917 ErrorDialog (ptp->status, IDS_ERROR_CANT_CREATE_SERVICE, TEXT("%s%s"), szServer, lpp->szService);
1921 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1925 void Task_Svc_Delete (LPTASKPACKET ptp)
1927 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1929 ptp->rc = AfsClass_DeleteService (lpi, &ptp->status);
1933 TCHAR szServer[ cchNAME ];
1934 TCHAR szService[ cchNAME ];
1935 lpi->GetServerName (szServer);
1936 lpi->GetServiceName (szService);
1937 ErrorDialog (ptp->status, IDS_ERROR_CANT_DELETE_SERVICE, TEXT("%s%s"), szServer, szService);
1942 void Task_Svc_GetRestartTimes (LPTASKPACKET ptp)
1944 LPSVC_RESTARTTIMES_PARAMS lpp = (LPSVC_RESTARTTIMES_PARAMS)(ptp->lpUser);
1946 ptp->rc = AfsClass_GetRestartTimes (lpp->lpi, &lpp->fGeneral, &lpp->stGeneral, &lpp->fNewBinary, &lpp->stNewBinary, &ptp->status);
1950 lpp->fGeneral = FALSE;
1951 lpp->fNewBinary = FALSE;
1953 TCHAR szSvrName[ cchNAME ];
1954 lpp->lpi->GetServerName (szSvrName);
1955 ErrorDialog (ptp->status, IDS_ERROR_REFRESH_SERVICE_STATUS, TEXT("%s%s"), szSvrName, TEXT("BOS"));
1961 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1966 void Task_Svc_SetRestartTimes (LPTASKPACKET ptp)
1968 LPSVC_RESTARTTIMES_PARAMS lpp = (LPSVC_RESTARTTIMES_PARAMS)(ptp->lpUser);
1970 ptp->rc = AfsClass_SetRestartTimes (lpp->lpi, ((lpp->fGeneral) ? &lpp->stGeneral : NULL), ((lpp->fNewBinary) ? &lpp->stNewBinary : NULL), &ptp->status);
1974 TCHAR szSvrName[ cchNAME ];
1975 lpp->lpi->GetServerName (szSvrName);
1976 ErrorDialog (ptp->status, IDS_ERROR_CANT_SET_RESTART_TIMES, TEXT("%s"), szSvrName);
1982 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1987 void Task_Agg_Prop_Init (LPTASKPACKET ptp)
1989 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1991 LPAGGREGATE lpAggregate;
1992 if ((lpAggregate = lpi->OpenAggregate (&ptp->status)) == NULL)
1996 if (!lpAggregate->GetStatus (&TASKDATA(ptp)->as, TRUE, &ptp->status))
2001 if ((TASKDATA(ptp)->lpap = (LPAGGREGATE_PREF)lpAggregate->GetUserParam()) == NULL)
2003 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2007 TCHAR szText[ cchRESOURCE ];
2008 lpAggregate->GetDevice (szText);
2009 TASKDATA(ptp)->pszText1 = CloneString (szText);
2013 TASKDATA(ptp)->nFilesets = 0;
2016 for (LPFILESET lpFileset = lpAggregate->FilesetFindFirst (&hEnum); lpFileset; lpFileset = lpAggregate->FilesetFindNext (&hEnum))
2018 (TASKDATA(ptp)->nFilesets)++;
2023 lpAggregate->Close();
2028 if ((TASKDATA(ptp)->lpsp = (LPSERVER_PREF)lpi->GetServer()->GetUserParam()) == NULL)
2030 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2037 void Task_Agg_Prop_Apply (LPTASKPACKET ptp)
2039 LPAGG_PROP_APPLY_PACKET lpp = (LPAGG_PROP_APPLY_PACKET)(ptp->lpUser);
2041 LPAGGREGATE_PREF lpap;
2042 if ((lpap = (LPAGGREGATE_PREF)lpp->lpi->GetAggregate()->GetUserParam()) == NULL)
2044 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2050 if ((lpiServer = lpp->lpi->GetServer()) != NULL)
2053 if ((lpsp = (LPSERVER_PREF)lpiServer->GetUserParam()) != NULL)
2055 if (lpsp->fWarnAggAlloc)
2056 lpap->fWarnAggAlloc = lpp->fIDC_AGG_WARNALLOC;
2060 if (!lpp->fIDC_AGG_WARN)
2061 lpap->perWarnAggFull = 0;
2062 else if (lpp->fIDC_AGG_WARN_AGGFULL_DEF)
2063 lpap->perWarnAggFull = -1;
2065 lpap->perWarnAggFull = lpp->wIDC_AGG_WARN_AGGFULL_PERCENT;
2067 if (!Aggregates_SavePreferences (lpp->lpi))
2069 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2073 (void)Alert_Scout_QueueCheckServer (lpp->lpi);
2077 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2081 void Task_Agg_Find_Quota_Limits (LPTASKPACKET ptp)
2083 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2085 TASKDATA(ptp)->ckMin = ckQUOTA_MINIMUM;
2086 TASKDATA(ptp)->ckMax = ckQUOTA_MAXIMUM;
2088 if (lpi && (lpi->fIsAggregate() || lpi->fIsFileset()))
2090 LPAGGREGATE lpAggregate;
2091 if ((lpAggregate = lpi->OpenAggregate (&ptp->status)) == NULL)
2096 if (!lpAggregate->GetStatus (&as, TRUE, &ptp->status))
2100 TASKDATA(ptp)->ckMax = max( 1L, as.ckStorageTotal );
2102 lpAggregate->Close();
2108 void Task_Agg_Enum_To_ListView (LPTASKPACKET ptp)
2110 LPAGG_ENUM_TO_LISTVIEW_PACKET lpp = (LPAGG_ENUM_TO_LISTVIEW_PACKET)(ptp->lpUser);
2112 UpdateDisplay_Aggregates (TRUE, lpp->hList, NULL, 0, lpp->lpiServer, lpp->lpiSelect, lpp->lpvi);
2115 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2119 void Task_Agg_Enum_To_ComboBox (LPTASKPACKET ptp)
2121 LPAGG_ENUM_TO_COMBOBOX_PACKET lpp = (LPAGG_ENUM_TO_COMBOBOX_PACKET)(ptp->lpUser);
2123 UpdateDisplay_Aggregates (TRUE, lpp->hCombo, NULL, 0, lpp->lpiServer, lpp->lpiSelect, NULL);
2126 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2130 void Task_Agg_Find_Ghost (LPTASKPACKET ptp)
2132 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2134 LPAGGREGATE lpAggregate;
2135 if ((lpAggregate = lpi->OpenAggregate (&ptp->status)) == NULL)
2139 TASKDATA(ptp)->wGhost = lpAggregate->GetGhostStatus();
2140 lpAggregate->Close();
2145 void Task_Set_Enum_To_ComboBox (LPTASKPACKET ptp)
2147 LPSET_ENUM_TO_COMBOBOX_PACKET lpp = (LPSET_ENUM_TO_COMBOBOX_PACKET)(ptp->lpUser);
2149 UpdateDisplay_Filesets (TRUE, lpp->hCombo, NULL, 0, lpp->lpiServer, lpp->lpiAggregate, lpp->lpiSelect);
2152 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2156 void Task_Set_Find_Ghost (LPTASKPACKET ptp)
2158 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2160 LPFILESET lpFileset;
2161 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2165 TASKDATA(ptp)->wGhost = lpFileset->GetGhostStatus();
2166 TASKDATA(ptp)->fHasReplicas = FALSE;
2168 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs))
2170 TASKDATA(ptp)->fs.Type = ftREADWRITE;
2172 else if (TASKDATA(ptp)->fs.Type == ftREADWRITE)
2175 for (LPIDENT lpiSearch = IDENT::FindFirst (&hEnum, &TASKDATA(ptp)->fs.idReplica); lpiSearch; lpiSearch = IDENT::FindNext (&hEnum))
2177 LPFILESET lpReplica;
2178 if ((lpReplica = lpiSearch->OpenFileset()) != NULL)
2181 TASKDATA(ptp)->fHasReplicas = TRUE;
2185 IDENT::FindClose (&hEnum);
2193 void Task_Set_Create (LPTASKPACKET ptp)
2195 LPSET_CREATE_PARAMS lpp = (LPSET_CREATE_PARAMS)(ptp->lpUser);
2198 if ((lpiFileset = AfsClass_CreateFileset (lpp->lpiParent, lpp->szName, lpp->ckQuota, &ptp->status)) == NULL)
2201 if (ptp->rc && lpp->fCreateClone)
2203 ptp->rc = AfsClass_Clone (lpiFileset, &ptp->status);
2208 TASKDATA(ptp)->lpi = lpiFileset;
2212 TCHAR szServer[ cchNAME ];
2213 TCHAR szAggregate[ cchNAME ];
2214 lpp->lpiParent->GetServerName (szServer);
2215 lpp->lpiParent->GetAggregateName (szAggregate);
2216 ErrorDialog (ptp->status, IDS_ERROR_CANT_CREATE_FILESET, TEXT("%s%s%s"), szServer, szAggregate, lpp->szName);
2220 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2224 void Task_Set_Delete (LPTASKPACKET ptp)
2226 LPSET_DELETE_PARAMS lpp = (LPSET_DELETE_PARAMS)(ptp->lpUser);
2228 // First, what kind of fileset are we deleting here?
2230 LPIDENT lpiClone = NULL;
2231 FILESETTYPE setType = ftREADWRITE;
2232 LPFILESET lpFileset;
2233 if ((lpFileset = lpp->lpiFileset->OpenFileset (&ptp->status)) == NULL)
2237 lpiClone = lpFileset->GetCloneIdentifier();
2239 if (lpFileset->GetStatus (&TASKDATA(ptp)->fs))
2240 setType = TASKDATA(ptp)->fs.Type;
2245 // Delete the fileset in whichever way is appropriate
2247 if (setType == ftREADWRITE)
2249 if (lpp->fVLDB && lpiClone)
2252 if ((lpClone = lpiClone->OpenFileset()) != NULL) // clone really there?
2256 if (!AfsClass_DeleteClone (lpiClone, &ptp->status))
2262 if (!AfsClass_DeleteFileset (lpp->lpiFileset, lpp->fVLDB, lpp->fServer, &ptp->status))
2266 else if (setType == ftREPLICA)
2268 if (!AfsClass_DeleteReplica (lpp->lpiFileset, &ptp->status))
2271 else if (setType == ftCLONE)
2273 if (!AfsClass_DeleteClone (lpp->lpiFileset, &ptp->status))
2280 (!lpp->fVLDB && (lpp->wGhost & GHOST_HAS_VLDB_ENTRY)) ||
2281 (!lpp->fServer && (lpp->wGhost & GHOST_HAS_SERVER_ENTRY)) )
2283 Alert_Scout_QueueCheckServer (lpp->lpiFileset->GetServer());
2288 TCHAR szServer[ cchNAME ];
2289 TCHAR szAggregate[ cchNAME ];
2290 TCHAR szFileset[ cchNAME ];
2291 lpp->lpiFileset->GetServerName (szServer);
2292 lpp->lpiFileset->GetAggregateName (szAggregate);
2293 lpp->lpiFileset->GetFilesetName (szFileset);
2294 ErrorDialog (ptp->status, IDS_ERROR_CANT_DELETE_FILESET, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2298 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2302 void Task_Set_Move (LPTASKPACKET ptp)
2304 LPSET_MOVE_PARAMS lpp = (LPSET_MOVE_PARAMS)(ptp->lpUser);
2306 BOOL fIsReplica = FALSE;
2308 LPFILESET lpFileset;
2309 if ((lpFileset = lpp->lpiSource->OpenFileset (&ptp->status)) == NULL)
2314 if (!lpFileset->GetStatus (&fs, TRUE, &ptp->status))
2318 if (fs.Type == ftREPLICA)
2328 if (!AfsClass_MoveReplica (lpp->lpiSource, lpp->lpiTarget, &ptp->status))
2333 if (!AfsClass_MoveFileset (lpp->lpiSource, lpp->lpiTarget, &ptp->status))
2340 TCHAR szServerSource[ cchNAME ];
2341 TCHAR szServerTarget[ cchNAME ];
2342 TCHAR szAggregateSource[ cchNAME ];
2343 TCHAR szAggregateTarget[ cchNAME ];
2344 TCHAR szFileset[ cchNAME ];
2345 lpp->lpiSource->GetServerName (szServerSource);
2346 lpp->lpiSource->GetAggregateName (szAggregateSource);
2347 lpp->lpiSource->GetFilesetName (szFileset);
2348 lpp->lpiTarget->GetServerName (szServerTarget);
2349 lpp->lpiTarget->GetAggregateName (szAggregateTarget);
2350 ErrorDialog (ptp->status, IDS_ERROR_MOVE_FILESET, TEXT("%s%s%s%s%s"), szServerSource, szAggregateSource, szFileset, szServerTarget, szAggregateTarget);
2354 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2358 void Task_Set_MoveTo_Init (LPTASKPACKET ptp)
2360 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2362 LPFILESET lpFileset;
2363 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2367 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2374 void Task_Set_Prop_Init (LPTASKPACKET ptp)
2376 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2378 LPFILESET lpFileset;
2379 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2383 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2385 else if ((TASKDATA(ptp)->lpfp = (LPFILESET_PREF)lpFileset->GetUserParam()) == NULL)
2388 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2395 if ((TASKDATA(ptp)->lpsp = (LPSERVER_PREF)lpi->GetServer()->GetUserParam()) == NULL)
2398 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2404 void Task_Set_Prop_Apply (LPTASKPACKET ptp)
2406 LPSET_PROP_APPLY_PARAMS lpp = (LPSET_PROP_APPLY_PARAMS)(ptp->lpUser);
2408 LPFILESET_PREF lpfp = NULL;
2409 if ((lpfp = (LPFILESET_PREF)lpp->lpi->GetUserParam()) == NULL)
2412 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2416 if (!lpp->fIDC_SET_WARN)
2417 lpfp->perWarnSetFull = 0;
2418 else if (lpp->fIDC_SET_WARN_SETFULL_DEF)
2419 lpfp->perWarnSetFull = -1;
2421 lpfp->perWarnSetFull = lpp->wIDC_SET_WARN_SETFULL_PERCENT;
2423 if (!Filesets_SavePreferences (lpp->lpi))
2426 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2430 Alert_Scout_QueueCheckServer (lpp->lpi);
2433 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2437 void Task_Set_SetQuota_Init (LPTASKPACKET ptp)
2439 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2441 LPFILESET lpFileset;
2442 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2446 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2454 Task_Agg_Find_Quota_Limits (ptp);
2459 void Task_Set_SetQuota_Apply (LPTASKPACKET ptp)
2461 LPSET_SETQUOTA_APPLY_PARAMS lpp = (LPSET_SETQUOTA_APPLY_PARAMS)(ptp->lpUser);
2463 if (!AfsClass_SetFilesetQuota (lpp->lpiFileset, lpp->ckQuota, &ptp->status))
2468 TCHAR szServer[ cchNAME ];
2469 TCHAR szAggregate[ cchNAME ];
2470 TCHAR szFileset[ cchNAME ];
2471 lpp->lpiFileset->GetServerName (szServer);
2472 lpp->lpiFileset->GetAggregateName (szAggregate);
2473 lpp->lpiFileset->GetFilesetName (szFileset);
2474 ErrorDialog (ptp->status, IDS_ERROR_CANT_SET_FILESET_QUOTA, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2478 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2482 void Task_Set_RepProp_Init (LPTASKPACKET ptp)
2484 LPSET_REPPROP_INIT_PARAMS lpp = (LPSET_REPPROP_INIT_PARAMS)(ptp->lpUser);
2486 LPFILESET lpFileset;
2487 if ((lpFileset = lpp->lpiReq->OpenFileset (&ptp->status)) == NULL)
2491 if ((lpp->lpiRW = lpFileset->GetReadWriteIdentifier (&ptp->status)) == NULL)
2493 else if (!lpFileset->GetStatus (&lpp->fs, TRUE, &ptp->status))
2498 // don't delete this packet (ptp->lpUser)! the caller will free it.
2502 void Task_Set_Select (LPTASKPACKET ptp)
2504 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2506 LPFILESET lpFileset;
2507 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2511 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2519 void Task_Set_BeginDrag (LPTASKPACKET ptp)
2521 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2523 LPFILESET lpFileset;
2524 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2528 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2535 void Task_Set_DragMenu (LPTASKPACKET ptp)
2537 TASKDATA(ptp)->mt = *(LPMENUTASK)(ptp->lpUser);
2538 Delete ((LPMENUTASK)(ptp->lpUser));
2539 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2541 if (TASKDATA(ptp)->mt.lpi && TASKDATA(ptp)->mt.lpi->fIsFileset())
2543 LPFILESET lpFileset;
2544 if ((lpFileset = TASKDATA(ptp)->mt.lpi->OpenFileset (&ptp->status)) == NULL)
2548 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2556 void Task_Set_Menu (LPTASKPACKET ptp)
2558 TASKDATA(ptp)->mt = *(LPMENUTASK)(ptp->lpUser);
2559 Delete ((LPMENUTASK)(ptp->lpUser));
2560 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2562 if (TASKDATA(ptp)->mt.lpi && TASKDATA(ptp)->mt.lpi->fIsFileset())
2564 LPFILESET lpFileset;
2565 if ((lpFileset = TASKDATA(ptp)->mt.lpi->OpenFileset (&ptp->status)) == NULL)
2569 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2578 void Task_Set_Lock (LPTASKPACKET ptp)
2580 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2581 ptp->rc = AfsClass_LockFileset (lpi, &ptp->status);
2585 void Task_Set_Unlock (LPTASKPACKET ptp)
2587 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2589 if (lpi->fIsFileset())
2590 ptp->rc = AfsClass_UnlockFileset (lpi, &ptp->status);
2592 ptp->rc = AfsClass_UnlockAllFilesets (lpi, &ptp->status);
2596 void Task_Set_CreateRep (LPTASKPACKET ptp)
2598 LPSET_CREATEREP_PARAMS lpp = (LPSET_CREATEREP_PARAMS)(ptp->lpUser);
2601 if ((lpiReplica = AfsClass_CreateReplica (lpp->lpiSource, lpp->lpiTarget, &ptp->status)) == NULL)
2606 TASKDATA(ptp)->lpi = lpiReplica;
2610 TCHAR szServer[ cchNAME ];
2611 TCHAR szAggregate[ cchNAME ];
2612 TCHAR szFileset[ cchNAME ];
2613 lpp->lpiTarget->GetServerName (szServer);
2614 lpp->lpiTarget->GetAggregateName (szAggregate);
2615 lpp->lpiSource->GetFilesetName (szFileset);
2616 ErrorDialog (ptp->status, IDS_ERROR_CANT_CREATE_REPLICA, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2620 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2624 void Task_Set_Rename_Init (LPTASKPACKET ptp)
2626 LPSET_RENAME_INIT_PARAMS lpp = (LPSET_RENAME_INIT_PARAMS)(ptp->lpUser);
2628 LPFILESET lpFileset;
2629 if ((lpFileset = lpp->lpiReq->OpenFileset (&ptp->status)) == NULL)
2633 if ((lpp->lpiRW = lpFileset->GetReadWriteIdentifier (&ptp->status)) == NULL)
2638 // don't delete this packet (ptp->lpUser)! the caller will free it.
2642 void Task_Set_Rename_Apply (LPTASKPACKET ptp)
2644 LPSET_RENAME_APPLY_PARAMS lpp = (LPSET_RENAME_APPLY_PARAMS)(ptp->lpUser);
2646 ptp->rc = AfsClass_RenameFileset (lpp->lpiFileset, lpp->szNewName, &ptp->status);
2650 TCHAR szFileset[ cchNAME ];
2651 lpp->lpiFileset->GetFilesetName (szFileset);
2652 ErrorDialog (ptp->status, IDS_ERROR_CANT_RENAME_FILESET, TEXT("%s%s"), szFileset, lpp->szNewName);
2656 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2660 void Task_Set_Release (LPTASKPACKET ptp)
2662 LPSET_RELEASE_PARAMS lpp = (LPSET_RELEASE_PARAMS)(ptp->lpUser);
2664 ptp->rc = AfsClass_ReleaseFileset (lpp->lpiRW, lpp->fForce, &ptp->status);
2668 TCHAR szServer[ cchNAME ];
2669 TCHAR szAggregate[ cchNAME ];
2670 TCHAR szFileset[ cchNAME ];
2671 lpp->lpiRW->GetServerName (szServer);
2672 lpp->lpiRW->GetAggregateName (szAggregate);
2673 lpp->lpiRW->GetFilesetName (szFileset);
2674 ErrorDialog (ptp->status, IDS_ERROR_CANT_RELEASE_FILESET, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2678 ptp->lpUser = 0; // we freed this; don't let anyone use it.
2682 void Task_Set_Clone (LPTASKPACKET ptp)
2684 LPIDENT lpiRW = (LPIDENT)(ptp->lpUser);
2686 ptp->rc = AfsClass_Clone (lpiRW, &ptp->status);
2690 TCHAR szServer[ cchNAME ];
2691 TCHAR szAggregate[ cchNAME ];
2692 TCHAR szFileset[ cchNAME ];
2693 lpiRW->GetServerName (szServer);
2694 lpiRW->GetAggregateName (szAggregate);
2695 lpiRW->GetFilesetName (szFileset);
2696 ErrorDialog (ptp->status, IDS_ERROR_CANT_CLONE, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2701 void Task_Set_Clonesys (LPTASKPACKET ptp)
2703 LPSET_CLONESYS_PARAMS lpp = (LPSET_CLONESYS_PARAMS)(ptp->lpUser);
2705 LPTSTR pszPrefix = (lpp->fUsePrefix) ? lpp->szPrefix : NULL;
2706 if (!AfsClass_CloneMultiple (lpp->lpi, pszPrefix, lpp->fExcludePrefix, &ptp->status))
2709 if (!ptp->rc && !IsWindow (ptp->hReply))
2711 ErrorDialog (ptp->status, IDS_ERROR_CANT_CLONESYS);
2715 ptp->lpUser = 0; // we freed this; don't let anyone use it.
2719 void Task_Set_Dump (LPTASKPACKET ptp)
2721 LPSET_DUMP_PARAMS lpp = (LPSET_DUMP_PARAMS)(ptp->lpUser);
2723 ptp->rc = AfsClass_DumpFileset (lpp->lpi, lpp->szFilename,
2724 (lpp->fDumpByDate) ? &lpp->stDump : NULL,
2729 TCHAR szServer[ cchNAME ];
2730 TCHAR szAggregate[ cchNAME ];
2731 TCHAR szFileset[ cchNAME ];
2732 lpp->lpi->GetServerName (szServer);
2733 lpp->lpi->GetAggregateName (szAggregate);
2734 lpp->lpi->GetFilesetName (szFileset);
2735 ErrorDialog (ptp->status, IDS_ERROR_CANT_DUMP_FILESET, TEXT("%s%s%s%s"), szServer, szAggregate, szFileset, lpp->szFilename);
2739 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2743 void Task_Set_Restore (LPTASKPACKET ptp)
2745 LPSET_RESTORE_PARAMS lpp = (LPSET_RESTORE_PARAMS)(ptp->lpUser);
2747 ptp->rc = AfsClass_RestoreFileset (lpp->lpi, lpp->szFileset, lpp->szFilename, lpp->fIncremental, &ptp->status);
2751 TCHAR szServer[ cchNAME ];
2752 TCHAR szAggregate[ cchNAME ];
2753 lpp->lpi->GetServerName (szServer);
2754 lpp->lpi->GetAggregateName (szAggregate);
2755 ErrorDialog (ptp->status, IDS_ERROR_CANT_RESTORE_FILESET, TEXT("%s%s%s%s"), szServer, szAggregate, lpp->szFileset, lpp->szFilename);
2759 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2763 void Task_Set_Lookup (LPTASKPACKET ptp)
2765 LPSET_LOOKUP_PACKET lpp = (LPSET_LOOKUP_PACKET)(ptp->lpUser);
2767 if ((TASKDATA(ptp)->lpi = IDENT::FindFileset (g.lpiCell, lpp->szFileset)) != NULL)
2769 LPFILESET lpFileset;
2770 if ((lpFileset = TASKDATA(ptp)->lpi->OpenFileset()) == NULL)
2771 TASKDATA(ptp)->lpi = NULL; // fileset was probably deleted earlier
2777 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2781 void Task_Expired_Creds (LPTASKPACKET ptp)
2785 CheckForExpiredCredentials();