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
14 #include <afs/param.h>
22 #include "svr_general.h"
23 #include "svr_window.h"
25 #include "svr_syncvldb.h"
26 #include "svr_salvage.h"
27 #include "svr_install.h"
28 #include "svr_uninstall.h"
29 #include "svr_prune.h"
30 #include "svr_getdates.h"
31 #include "svr_execute.h"
32 #include "svr_security.h"
33 #include "svr_address.h"
35 #include "svc_create.h"
36 #include "svc_general.h"
37 #include "svc_startstop.h"
38 #include "svc_viewlog.h"
39 #include "agg_general.h"
41 #include "set_create.h"
42 #include "set_delete.h"
45 #include "set_general.h"
46 #include "set_quota.h"
47 #include "set_repprop.h"
48 #include "set_createrep.h"
49 #include "set_rename.h"
50 #include "set_release.h"
51 #include "set_clone.h"
53 #include "set_restore.h"
64 // As an additional debugging measure, you may want to enable the
65 // definition below--doing so causes the tool to ensure that
66 // AFSCLASS's critical section (accessed via AfsClass_Enter()/Leave()) is
67 // not leaking during tasks: for instance, if AfsClass_MoveFileset()
68 // calls AfsClass_Enter() three times but Leave() only twice, then an
69 // assertion will trigger in Task_Perform() (at which point it is
70 // not too late to easily determine which task leaked the critsec).
71 // Unfortunately, this has a side-effect: enabling the definition
72 // below prevents the AFSCLASS library from entirely exiting the
73 // critical section during its work--which means that only one
74 // AfsClass_* function can ever be run at once. So, enable this
75 // definition if you see a lockup--and disable it when you're done.
83 * PROTOTYPES _________________________________________________________________
88 void Task_ExportCell (LPTASKPACKET ptp);
90 void Task_OpenCell (LPTASKPACKET ptp);
91 void Task_OpenedCell (LPTASKPACKET ptp);
92 void Task_ClosedCell (LPTASKPACKET ptp);
93 void Task_Refresh (LPTASKPACKET ptp, BOOL fNewCreds);
94 void Task_Subset_To_List (LPTASKPACKET ptp);
95 void Task_Apply_Subset (LPTASKPACKET ptp);
96 void Task_Svr_Prop_Init (LPTASKPACKET ptp);
97 void Task_Svr_Scout_Init (LPTASKPACKET ptp);
98 void Task_Svr_Scout_Apply (LPTASKPACKET ptp);
99 void Task_Svr_Enum_To_ComboBox (LPTASKPACKET ptp);
100 void Task_Svr_GetWindowPos (LPTASKPACKET ptp);
101 void Task_Svr_SetWindowPos (LPTASKPACKET ptp);
102 void Task_Svr_SyncVLDB (LPTASKPACKET ptp);
103 void Task_Svr_Salvage (LPTASKPACKET ptp);
104 void Task_Svr_Install (LPTASKPACKET ptp);
105 void Task_Svr_Uninstall (LPTASKPACKET ptp);
106 void Task_Svr_Prune (LPTASKPACKET ptp);
107 void Task_Svr_GetDates (LPTASKPACKET ptp);
108 void Task_Svr_Execute (LPTASKPACKET ptp);
109 void Task_Svr_SetAuth (LPTASKPACKET ptp);
110 void Task_Svr_AdmList_Open (LPTASKPACKET ptp);
111 void Task_Svr_AdmList_Save (LPTASKPACKET ptp);
112 void Task_Svr_KeyList_Open (LPTASKPACKET ptp);
113 void Task_Svr_Key_Create (LPTASKPACKET ptp);
114 void Task_Svr_Key_Delete (LPTASKPACKET ptp);
115 void Task_Svr_HostList_Open (LPTASKPACKET ptp);
116 void Task_Svr_HostList_Save (LPTASKPACKET ptp);
117 void Task_Svr_GetRandomKey (LPTASKPACKET ptp);
118 void Task_Svr_Monitor_OnOff (LPTASKPACKET ptp);
119 void Task_Svr_ChangeAddr (LPTASKPACKET ptp);
120 void Task_Svc_Menu (LPTASKPACKET ptp);
121 void Task_Svc_Prop_Init (LPTASKPACKET ptp);
122 void Task_Svc_Prop_Apply (LPTASKPACKET ptp);
123 void Task_Svc_Start (LPTASKPACKET ptp);
124 void Task_Svc_Stop (LPTASKPACKET ptp);
125 void Task_Svc_Restart (LPTASKPACKET ptp);
126 void Task_Svc_FindLog (LPTASKPACKET ptp);
127 void Task_Svc_ViewLog (LPTASKPACKET ptp);
128 void Task_Svc_Create (LPTASKPACKET ptp);
129 void Task_Svc_Delete (LPTASKPACKET ptp);
130 void Task_Svc_GetRestartTimes (LPTASKPACKET ptp);
131 void Task_Svc_SetRestartTimes (LPTASKPACKET ptp);
132 void Task_Agg_Prop_Init (LPTASKPACKET ptp);
133 void Task_Agg_Prop_Apply (LPTASKPACKET ptp);
134 void Task_Agg_Find_Quota_Limits (LPTASKPACKET ptp);
135 void Task_Agg_Enum_To_ListView (LPTASKPACKET ptp);
136 void Task_Agg_Enum_To_ComboBox (LPTASKPACKET ptp);
137 void Task_Agg_Find_Ghost (LPTASKPACKET ptp);
138 void Task_Set_Enum_To_ComboBox (LPTASKPACKET ptp);
139 void Task_Set_Find_Ghost (LPTASKPACKET ptp);
140 void Task_Set_Create (LPTASKPACKET ptp);
141 void Task_Set_Delete (LPTASKPACKET ptp);
142 void Task_Set_Move (LPTASKPACKET ptp);
143 void Task_Set_MoveTo_Init (LPTASKPACKET ptp);
144 void Task_Set_Prop_Init (LPTASKPACKET ptp);
145 void Task_Set_Prop_Apply (LPTASKPACKET ptp);
146 void Task_Set_SetQuota_Init (LPTASKPACKET ptp);
147 void Task_Set_SetQuota_Apply (LPTASKPACKET ptp);
148 void Task_Set_RepProp_Init (LPTASKPACKET ptp);
149 void Task_Set_Select (LPTASKPACKET ptp);
150 void Task_Set_BeginDrag (LPTASKPACKET ptp);
151 void Task_Set_DragMenu (LPTASKPACKET ptp);
152 void Task_Set_Menu (LPTASKPACKET ptp);
153 void Task_Set_Lock (LPTASKPACKET ptp);
154 void Task_Set_Unlock (LPTASKPACKET ptp);
155 void Task_Set_CreateRep (LPTASKPACKET ptp);
156 void Task_Set_Rename_Init (LPTASKPACKET ptp);
157 void Task_Set_Rename_Apply (LPTASKPACKET ptp);
158 void Task_Set_Release (LPTASKPACKET ptp);
159 void Task_Set_Clone (LPTASKPACKET ptp);
160 void Task_Set_Clonesys (LPTASKPACKET ptp);
161 void Task_Set_Dump (LPTASKPACKET ptp);
162 void Task_Set_Restore (LPTASKPACKET ptp);
163 void Task_Set_Lookup (LPTASKPACKET ptp);
164 void Task_Expired_Creds (LPTASKPACKET ptp);
168 * ROUTINES ___________________________________________________________________
172 LPTASKPACKET CreateTaskPacket (int idTask, HWND hReply, PVOID lpUser)
176 if ((ptp = New (TASKPACKET)) != NULL)
178 memset (ptp, 0x00, sizeof(TASKPACKET));
180 ptp->idTask = idTask;
181 ptp->hReply = hReply;
182 ptp->lpUser = lpUser;
187 if ((ptp->pReturn = New (TASKPACKETDATA)) != NULL)
189 memset (ptp->pReturn, 0x00, sizeof(TASKPACKETDATA));
197 void FreeTaskPacket (LPTASKPACKET ptp)
203 if (TASKDATA(ptp)->pszText1)
204 FreeString (TASKDATA(ptp)->pszText1);
205 if (TASKDATA(ptp)->pszText2)
206 FreeString (TASKDATA(ptp)->pszText2);
207 if (TASKDATA(ptp)->pszText3)
208 FreeString (TASKDATA(ptp)->pszText3);
209 Delete (ptp->pReturn);
217 void PerformTask (LPTASKPACKET ptp)
221 ASSERT( AfsClass_GetEnterCount() == 1 );
228 Task_ExportCell (ptp);
237 Task_OpenedCell (ptp);
241 Task_ClosedCell (ptp);
245 Task_Refresh (ptp, FALSE);
248 case taskREFRESH_CREDS:
249 Task_Refresh (ptp, TRUE);
252 case taskSUBSET_TO_LIST:
253 Task_Subset_To_List (ptp);
256 case taskAPPLY_SUBSET:
257 Task_Apply_Subset (ptp);
260 case taskSVR_PROP_INIT:
261 Task_Svr_Prop_Init (ptp);
264 case taskSVR_SCOUT_INIT:
265 Task_Svr_Scout_Init (ptp);
268 case taskSVR_SCOUT_APPLY:
269 Task_Svr_Scout_Apply (ptp);
272 case taskSVR_ENUM_TO_COMBOBOX:
273 Task_Svr_Enum_To_ComboBox (ptp);
276 case taskSVR_GETWINDOWPOS:
277 Task_Svr_GetWindowPos (ptp);
280 case taskSVR_SETWINDOWPOS:
281 Task_Svr_SetWindowPos (ptp);
284 case taskSVR_SYNCVLDB:
285 Task_Svr_SyncVLDB (ptp);
288 case taskSVR_SALVAGE:
289 Task_Svr_Salvage (ptp);
292 case taskSVR_INSTALL:
293 Task_Svr_Install (ptp);
296 case taskSVR_UNINSTALL:
297 Task_Svr_Uninstall (ptp);
301 Task_Svr_Prune (ptp);
304 case taskSVR_GETDATES:
305 Task_Svr_GetDates (ptp);
308 case taskSVR_EXECUTE:
309 Task_Svr_Execute (ptp);
312 case taskSVR_SETAUTH:
313 Task_Svr_SetAuth (ptp);
316 case taskSVR_ADMLIST_OPEN:
317 Task_Svr_AdmList_Open (ptp);
320 case taskSVR_ADMLIST_SAVE:
321 Task_Svr_AdmList_Save (ptp);
324 case taskSVR_KEYLIST_OPEN:
325 Task_Svr_KeyList_Open (ptp);
328 case taskSVR_KEY_CREATE:
329 Task_Svr_Key_Create (ptp);
332 case taskSVR_KEY_DELETE:
333 Task_Svr_Key_Delete (ptp);
336 case taskSVR_GETRANDOMKEY:
337 Task_Svr_GetRandomKey (ptp);
340 case taskSVR_HOSTLIST_OPEN:
341 Task_Svr_HostList_Open (ptp);
344 case taskSVR_HOSTLIST_SAVE:
345 Task_Svr_HostList_Save (ptp);
348 case taskSVR_MONITOR_ONOFF:
349 Task_Svr_Monitor_OnOff (ptp);
352 case taskSVR_CHANGEADDR:
353 Task_Svr_ChangeAddr (ptp);
360 case taskSVC_PROP_INIT:
361 Task_Svc_Prop_Init (ptp);
364 case taskSVC_PROP_APPLY:
365 Task_Svc_Prop_Apply (ptp);
369 Task_Svc_Start (ptp);
376 case taskSVC_RESTART:
377 Task_Svc_Restart (ptp);
380 case taskSVC_FINDLOG:
381 Task_Svc_FindLog (ptp);
384 case taskSVC_VIEWLOG:
385 Task_Svc_ViewLog (ptp);
389 Task_Svc_Create (ptp);
393 Task_Svc_Delete (ptp);
396 case taskSVC_GETRESTARTTIMES:
397 Task_Svc_GetRestartTimes (ptp);
400 case taskSVC_SETRESTARTTIMES:
401 Task_Svc_SetRestartTimes (ptp);
404 case taskAGG_PROP_INIT:
405 Task_Agg_Prop_Init (ptp);
408 case taskAGG_PROP_APPLY:
409 Task_Agg_Prop_Apply (ptp);
412 case taskAGG_FIND_QUOTA_LIMITS:
413 Task_Agg_Find_Quota_Limits (ptp);
416 case taskAGG_ENUM_TO_LISTVIEW:
417 Task_Agg_Enum_To_ListView (ptp);
420 case taskAGG_ENUM_TO_COMBOBOX:
421 Task_Agg_Enum_To_ComboBox (ptp);
424 case taskAGG_FIND_GHOST:
425 Task_Agg_Find_Ghost (ptp);
428 case taskSET_ENUM_TO_COMBOBOX:
429 Task_Set_Enum_To_ComboBox (ptp);
432 case taskSET_FIND_GHOST:
433 Task_Set_Find_Ghost (ptp);
437 Task_Set_Create (ptp);
441 Task_Set_Delete (ptp);
448 case taskSET_MOVETO_INIT:
449 Task_Set_MoveTo_Init (ptp);
452 case taskSET_PROP_INIT:
453 Task_Set_Prop_Init (ptp);
456 case taskSET_PROP_APPLY:
457 Task_Set_Prop_Apply (ptp);
460 case taskSET_SETQUOTA_INIT:
461 Task_Set_SetQuota_Init (ptp);
464 case taskSET_SETQUOTA_APPLY:
465 Task_Set_SetQuota_Apply (ptp);
468 case taskSET_REPPROP_INIT:
469 Task_Set_RepProp_Init (ptp);
473 Task_Set_Select (ptp);
476 case taskSET_BEGINDRAG:
477 Task_Set_BeginDrag (ptp);
480 case taskSET_DRAGMENU:
481 Task_Set_DragMenu (ptp);
493 Task_Set_Unlock (ptp);
496 case taskSET_CREATEREP:
497 Task_Set_CreateRep (ptp);
500 case taskSET_RENAME_INIT:
501 Task_Set_Rename_Init (ptp);
504 case taskSET_RENAME_APPLY:
505 Task_Set_Rename_Apply (ptp);
508 case taskSET_RELEASE:
509 Task_Set_Release (ptp);
513 Task_Set_Clone (ptp);
516 case taskSET_CLONESYS:
517 Task_Set_Clonesys (ptp);
524 case taskSET_RESTORE:
525 Task_Set_Restore (ptp);
529 Task_Set_Lookup (ptp);
532 case taskEXPIRED_CREDS:
533 Task_Expired_Creds (ptp);
538 ptp->status = ERROR_INVALID_FUNCTION;
543 ASSERT( AfsClass_GetEnterCount() == 1 );
549 void CoverServerList (LPIDENT lpiCell, ULONG status)
551 TCHAR szName[ cchRESOURCE ];
552 lpiCell->GetCellName (szName);
558 case ERROR_NOT_AUTHENTICATED:
559 idsButton = IDS_ALERT_BUTTON_GETCREDS;
562 idsButton = IDS_ALERT_BUTTON_TRYAGAIN;
567 LPTSTR pszCover = FormatString (IDS_ERROR_REFRESH_CELLSERVERS, TEXT("%s%e"), szName, status);
568 LPTSTR pszButton = FormatString (idsButton);
570 AfsAppLib_CoverWindow (GetDlgItem (g.hMain, IDC_SERVERS), pszCover, pszButton);
572 FreeString (pszButton);
573 FreeString (pszCover);
578 ULONG SystemTimeToUnixTime (SYSTEMTIME *pst)
587 if (!SystemTimeToFileTime (&st, &ft))
591 now.HighPart = (LONG)ft.dwHighDateTime;
592 now.LowPart = (ULONG)ft.dwLowDateTime;
594 LARGE_INTEGER offset;
595 offset.HighPart = 0x019db1de;
596 offset.LowPart = 0xd53e8000;
598 LARGE_INTEGER result;
599 result.QuadPart = (now.QuadPart - offset.QuadPart) / 10000000;
600 return (ULONG)result.LowPart;
603 static size_t nExportLevels = 0;
604 void Task_ExportCell_Spacing (LPTSTR pszSpacing)
606 wsprintf (pszSpacing, TEXT("%99s"), TEXT(""));
607 pszSpacing[ nExportLevels *3 ] = TEXT('\0');
610 #define chLBRC TEXT('{')
611 #define chRBRC TEXT('}')
613 void Task_ExportCell_Begin (HANDLE fh, LPTSTR eck, LPTSTR pszName)
615 TCHAR szSpacing[ 256 ];
616 Task_ExportCell_Spacing (szSpacing);
618 wsprintf (szLine, TEXT("\r\n%s%s %s %c\r\n"), szSpacing, eck, pszName, chLBRC);
620 WriteFile (fh, szLine, lstrlen(szLine), &cbWrote, NULL);
624 void Task_ExportCell_End (HANDLE fh)
627 TCHAR szSpacing[ 256 ];
628 Task_ExportCell_Spacing (szSpacing);
630 wsprintf (szLine, TEXT("%s%c\r\n"), szSpacing, chRBRC);
632 WriteFile (fh, szLine, lstrlen(szLine), &cbWrote, NULL);
635 void Task_ExportCell_Line (HANDLE fh, LPTSTR eck, LPTSTR pszRHS)
637 TCHAR szSpacing[ 256 ];
638 Task_ExportCell_Spacing (szSpacing);
640 wsprintf (szLine, TEXT("%s%s = \"%s\"\r\n"), szSpacing, eck, pszRHS);
642 WriteFile (fh, szLine, lstrlen(szLine), &cbWrote, NULL);
645 void Task_ExportCell_LineAddr (HANDLE fh, LPTSTR eck, SOCKADDR_IN *pAddr)
647 LPSTR pszLine = FormatString (TEXT("%1"), TEXT("%a"), pAddr);
648 Task_ExportCell_Line (fh, eck, pszLine);
649 FreeString (pszLine);
652 void Task_ExportCell_LineInt (HANDLE fh, LPTSTR eck, size_t dw)
655 wsprintf (szLine, TEXT("%lu"), dw);
656 Task_ExportCell_Line (fh, eck, szLine);
659 void Task_ExportCell_LineLarge (HANDLE fh, LPTSTR eck, LARGE_INTEGER *pldw)
662 wsprintf (szLine, TEXT("%lu,,%lu"), pldw->HighPart, pldw->LowPart);
663 Task_ExportCell_Line (fh, eck, szLine);
666 void Task_ExportCell_LineDate (HANDLE fh, LPTSTR eck, SYSTEMTIME *pst)
668 Task_ExportCell_LineInt (fh, eck, SystemTimeToUnixTime(pst));
671 void Task_ExportService (HANDLE fh, LPSERVICE lpService)
673 TCHAR szName[ cchNAME ];
674 lpService->GetName (szName);
675 Task_ExportCell_Begin (fh, eckSERVICE, szName);
678 if (lpService->GetStatus (&ss))
680 Task_ExportCell_LineInt (fh, eckRUNNING, (ss.state == SERVICESTATE_RUNNING));
681 Task_ExportCell_LineInt (fh, eckSTATE, ss.state);
682 Task_ExportCell_LineInt (fh, eckNSTARTS, ss.nStarts);
683 Task_ExportCell_LineInt (fh, eckERRLAST, ss.dwErrLast);
684 Task_ExportCell_LineInt (fh, eckSIGLAST, ss.dwSigLast);
685 Task_ExportCell_Line (fh, eckPARAMS, ss.szParams);
686 Task_ExportCell_Line (fh, eckNOTIFIER, ss.szNotifier);
687 Task_ExportCell_LineDate (fh, eckSTARTTIME, &ss.timeLastStart);
688 Task_ExportCell_LineDate (fh, eckSTOPTIME, &ss.timeLastStop);
689 Task_ExportCell_LineDate (fh, eckERRORTIME, &ss.timeLastFail);
691 if (ss.type == SERVICETYPE_SIMPLE)
692 Task_ExportCell_Line (fh, eckTYPE, eckSIMPLE);
693 else if (ss.type == SERVICETYPE_CRON)
694 Task_ExportCell_Line (fh, eckTYPE, eckCRON);
695 else // (ss.type == SERVICETYPE_FS)
696 Task_ExportCell_Line (fh, eckTYPE, eckFS);
699 Task_ExportCell_End (fh);
702 void Task_ExportFileset (HANDLE fh, LPFILESET lpFileset)
704 TCHAR szName[ cchNAME ];
705 lpFileset->GetName (szName);
706 Task_ExportCell_Begin (fh, eckFILESET, szName);
709 if (lpFileset->GetStatus (&fs))
711 Task_ExportCell_LineInt (fh, eckID, fs.id);
712 Task_ExportCell_LineInt (fh, eckID_RW, fs.idReadWrite);
713 Task_ExportCell_LineInt (fh, eckID_BK, fs.idClone);
714 Task_ExportCell_LineInt (fh, eckUSED, fs.ckUsed);
715 Task_ExportCell_LineInt (fh, eckQUOTA, fs.ckQuota);
716 Task_ExportCell_LineDate (fh, eckCREATETIME, &fs.timeCreation);
717 Task_ExportCell_LineDate (fh, eckUPDATETIME, &fs.timeLastUpdate);
718 Task_ExportCell_LineDate (fh, eckACCESSTIME, &fs.timeLastAccess);
719 Task_ExportCell_LineDate (fh, eckBACKUPTIME, &fs.timeLastBackup);
722 Task_ExportCell_End (fh);
725 void Task_ExportAggregate (HANDLE fh, LPAGGREGATE lpAggregate)
727 TCHAR szName[ cchNAME ];
728 lpAggregate->GetName (szName);
729 Task_ExportCell_Begin (fh, eckAGGREGATE, szName);
731 lpAggregate->GetDevice (szName);
732 Task_ExportCell_Line (fh, eckDEVICE, szName);
735 if (lpAggregate->GetStatus (&as))
737 Task_ExportCell_LineInt (fh, eckID, (int)as.dwID);
738 Task_ExportCell_LineInt (fh, eckTOTAL, (int)as.ckStorageTotal);
739 Task_ExportCell_LineInt (fh, eckFREECUR, (int)as.ckStorageFree);
743 for (LPFILESET lpFileset = lpAggregate->FilesetFindFirst (&hEnum); lpFileset; lpFileset = lpAggregate->FilesetFindNext (&hEnum))
745 Task_ExportFileset (fh, lpFileset);
749 Task_ExportCell_End (fh);
752 void Task_ExportServer (HANDLE fh, LPSERVER lpServer)
754 TCHAR szName[ cchNAME ];
755 lpServer->GetLongName (szName);
756 Task_ExportCell_Begin (fh, eckSERVER, szName);
758 // First, properties of the server
761 if (lpServer->GetStatus (&ss))
763 for (size_t iAddr = 0; iAddr < ss.nAddresses; ++iAddr)
764 Task_ExportCell_LineAddr (fh, eckADDRESS, &ss.aAddresses[ iAddr ]);
767 // Then, services on the server
770 for (LPSERVICE lpService = lpServer->ServiceFindFirst (&hEnum); lpService; lpService = lpServer->ServiceFindNext (&hEnum))
772 Task_ExportService (fh, lpService);
776 // Then, aggregates and filesets on the server
778 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&hEnum); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&hEnum))
780 Task_ExportAggregate (fh, lpAggregate);
781 lpAggregate->Close();
784 Task_ExportCell_End (fh);
787 void Task_ExportCell (LPTASKPACKET ptp)
789 LPTSTR pszFilename = (LPTSTR)(ptp->lpUser);
792 fh = CreateFile (pszFilename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL);
793 if (fh != INVALID_HANDLE_VALUE)
795 TCHAR szName[ cchNAME ];
796 g.lpiCell->GetCellName (szName);
797 Task_ExportCell_Begin (fh, eckCELL, szName);
800 if ((lpCell = g.lpiCell->OpenCell()) != NULL)
803 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
805 Task_ExportServer (fh, lpServer);
812 Task_ExportCell_End (fh);
816 Delete (pszFilename);
817 ptp->lpUser = 0; // we freed this; don't let the caller use it again
822 void Task_OpenCell (LPTASKPACKET ptp)
824 LPOPENCELL_PACKET lpp = (LPOPENCELL_PACKET)(ptp->lpUser);
826 LPSUBSET subOld = g.sub;
829 if ((TASKDATA(ptp)->lpiCell = CELL::OpenCell (lpp->szCell, (PVOID)lpp->hCreds, &ptp->status)) == NULL)
835 Subsets_FreeSubset (lpp->sub);
839 Subsets_FreeSubset (subOld);
844 PostMessage (g.hMain, WM_SHOW_YOURSELF, 0, 1);
847 PostMessage (g.hMain, WM_OPEN_ACTIONS, 0, 0);
849 else if (lpp->fCloseAppOnFail)
851 FatalErrorDialog (ptp->status, IDS_ERROR_CANT_OPEN_CELL, TEXT("%s"), lpp->szCell);
855 ptp->lpUser = 0; // we freed this; don't let the caller use it again
859 void Task_OpenedCell (LPTASKPACKET ptp)
861 LPIDENT lpiCell = (LPIDENT)(ptp->lpUser);
863 if (lpiCell && lpiCell->fIsCell())
867 DontNotifyMeEver (g.hMain);
868 NotifyMe (WHEN_CELL_OPENED, NULL, g.hMain, 0);
869 NotifyMe (WHEN_OBJECT_CHANGES, lpiCell, g.hMain, 0);
870 NotifyMe (WHEN_SVRS_CHANGE, lpiCell, g.hMain, 0);
872 if (g.lpiCell != NULL)
874 CELL::CloseCell (g.lpiCell);
878 UpdateDisplay_Cell (TRUE);
880 TCHAR szName[ cchRESOURCE ];
881 lpiCell->GetCellName (szName);
883 LPTSTR pszCover = FormatString (IDS_SEARCHING_FOR_SERVERS, TEXT("%s"), szName);
884 AfsAppLib_CoverWindow (GetDlgItem (g.hMain, IDC_SERVERS), pszCover);
885 FreeString (pszCover);
888 if ((lpCell = g.lpiCell->OpenCell (&ptp->status)) == NULL)
890 CoverServerList (g.lpiCell, ptp->status);
894 lpCell->Invalidate();
895 if ((ptp->rc = lpCell->RefreshAll (&ptp->status)) != TRUE)
897 CoverServerList (g.lpiCell, ptp->status);
902 PostMessage (g.hMain, WM_OPEN_SERVERS, 0, 0);
910 void Task_ClosedCell (LPTASKPACKET ptp)
912 LPIDENT lpiCell = (LPIDENT)(ptp->lpUser);
914 if (lpiCell && lpiCell->fIsCell())
918 if (g.lpiCell == lpiCell)
921 if ((lpCellTest = g.lpiCell->OpenCell()) != NULL)
923 // the user must have opened a cell, then opened it again.
924 // this is a bogus request to close the old copy of the
930 Server_CloseAll (FALSE);
932 Main_Redraw_ThreadProc ((PVOID)FALSE);
941 void Task_Refresh (LPTASKPACKET ptp, BOOL fNewCreds)
943 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
946 if (lpi && lpi->fIsCell())
948 AfsAppLib_Uncover (GetDlgItem (g.hMain, IDC_SERVERS));
951 if ((lpCell = lpi->OpenCell (&ptp->status)) == NULL)
953 CoverServerList (lpi, ptp->status);
958 lpCell->SetCurrentCredentials ((PVOID)g.hCreds);
960 lpCell->Invalidate();
961 if ((ptp->rc = lpCell->RefreshAll (&ptp->status)) != TRUE)
963 CoverServerList (lpi, ptp->status);
968 else if (lpi && lpi->GetServer())
970 BOOL fWasMonitored = TRUE;
973 if ((lpServer = lpi->OpenServer()) != NULL)
975 if ((fWasMonitored = lpServer->fIsMonitored()) == FALSE)
976 lpServer->SetMonitor (TRUE);
980 if (fWasMonitored) // if it was already monitored, we didn't just refresh
982 if (lpi && lpi->fIsServer())
984 if ((lpServer = lpi->OpenServer()) != NULL)
986 lpServer->Invalidate();
987 lpServer->RefreshAll();
991 else if (lpi && lpi->fIsService())
994 if ((lpService = lpi->OpenService()) != NULL)
996 lpService->Invalidate();
997 lpService->RefreshStatus();
1001 else if (lpi && lpi->fIsAggregate())
1003 LPAGGREGATE lpAggregate;
1004 if ((lpAggregate = lpi->OpenAggregate()) != NULL)
1006 // if we implied this aggregate from fileset VLDB entries,
1007 // refresh its parent server, not this aggregate.
1009 if (!(lpAggregate->GetGhostStatus() & GHOST_HAS_SERVER_ENTRY))
1011 lpAggregate->Close();
1014 if ((lpServer = lpi->OpenServer()) != NULL)
1016 lpServer->Invalidate();
1017 lpServer->RefreshAll();
1023 lpAggregate->Invalidate();
1024 lpAggregate->RefreshStatus();
1025 lpAggregate->RefreshFilesets();
1026 lpAggregate->Close();
1029 if ((lpCell = lpi->OpenCell()) != NULL)
1031 lpCell->RefreshVLDB (lpi);
1037 else if (lpi && lpi->fIsFileset())
1039 LPFILESET lpFileset;
1040 if ((lpFileset = lpi->OpenFileset()) != NULL)
1042 lpFileset->Invalidate();
1043 lpFileset->RefreshStatus();
1047 if ((lpCell = lpi->OpenCell()) != NULL)
1049 lpCell->RefreshVLDB (lpi);
1056 Alert_Scout_QueueCheckServer (lpi);
1063 void Task_Subset_To_List (LPTASKPACKET ptp)
1065 LPSUBSET_TO_LIST_PACKET lpp = (LPSUBSET_TO_LIST_PACKET)( ptp->lpUser );
1067 LB_StartChange (lpp->hList, TRUE);
1069 LPCELL lpCell = NULL;
1071 lpCell = g.lpiCell->OpenCell();
1075 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
1077 LPIDENT lpiServer = lpServer->GetIdentifier();
1078 TCHAR szServer[ cchNAME ];
1079 lpServer->GetName (szServer);
1082 BOOL fMonitor = Subsets_fMonitorServer (lpp->sub, lpiServer);
1084 LB_AddItem (lpp->hList, szServer, (LPARAM)fMonitor);
1090 LB_EndChange (lpp->hList);
1093 ptp->lpUser = 0; // we freed this; don't let anyone use it.
1097 void Task_Apply_Subset (LPTASKPACKET ptp)
1099 LPSUBSET sub = (LPSUBSET)( ptp->lpUser );
1101 LPCELL lpCell = NULL;
1103 lpCell = g.lpiCell->OpenCell();
1107 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
1109 LPIDENT lpiServer = lpServer->GetIdentifier();
1110 TCHAR szServer[ cchNAME ];
1111 lpServer->GetName (szServer);
1113 BOOL fMonitor = Subsets_fMonitorServer (sub, lpiServer);
1114 lpServer->SetMonitor (fMonitor);
1125 void Task_Svr_Prop_Init (LPTASKPACKET ptp)
1127 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1130 if ((lpServer = lpiServer->OpenServer (&ptp->status)) == NULL)
1134 if (!lpServer->GetStatus (&TASKDATA(ptp)->ss, TRUE, &ptp->status))
1141 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&hEnum); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&hEnum))
1144 if (lpAggregate->GetStatus (&as))
1146 TASKDATA(ptp)->ckCapacity += as.ckStorageTotal;
1147 TASKDATA(ptp)->ckAllocation += as.ckStorageAllocated;
1150 TASKDATA(ptp)->nAggr++;
1151 lpAggregate->Close();
1160 void Task_Svr_Scout_Init (LPTASKPACKET ptp)
1162 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1164 if ((TASKDATA(ptp)->lpsp = (LPSERVER_PREF)lpiServer->GetUserParam()) == NULL)
1167 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1172 void Task_Svr_Scout_Apply (LPTASKPACKET ptp)
1174 LPSVR_SCOUT_APPLY_PACKET lpp = (LPSVR_SCOUT_APPLY_PACKET)(ptp->lpUser);
1176 BOOL fRefreshVLDB = FALSE;
1178 LPSERVER_PREF lpsp = NULL;
1179 if ((lpsp = (LPSERVER_PREF)lpp->lpiServer->GetUserParam()) == NULL)
1182 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1186 if (!lpp->fIDC_SVR_WARN_AGGFULL)
1187 lpsp->perWarnAggFull = 0;
1189 lpsp->perWarnAggFull = lpp->wIDC_SVR_WARN_AGGFULL_PERCENT;
1191 if (!lpp->fIDC_SVR_WARN_SETFULL)
1192 lpsp->perWarnSetFull = 0;
1194 lpsp->perWarnSetFull = lpp->wIDC_SVR_WARN_SETFULL_PERCENT;
1196 DWORD fOldWarnSet = (lpsp->fWarnSetNoVLDB << 1) | lpsp->fWarnSetNoServ;
1198 lpsp->fWarnAggAlloc = lpp->fIDC_SVR_WARN_AGGALLOC;
1199 lpsp->fWarnSvcStop = lpp->fIDC_SVR_WARN_SVCSTOP;
1200 lpsp->fWarnSvrTimeout = lpp->fIDC_SVR_WARN_TIMEOUT;
1201 lpsp->fWarnSetNoVLDB = lpp->fIDC_SVR_WARN_SETNOVLDB;
1202 lpsp->fWarnSetNoServ = lpp->fIDC_SVR_WARN_SETNOSERV;
1203 lpsp->fWarnAggNoServ = lpp->fIDC_SVR_WARN_AGGNOSERV;
1205 DWORD fNewWarnSet = (lpsp->fWarnSetNoVLDB << 1) | lpsp->fWarnSetNoServ;
1207 if (fNewWarnSet != fOldWarnSet)
1208 fRefreshVLDB = TRUE;
1210 if (!lpp->fIDC_SVR_AUTOREFRESH)
1211 lpsp->oa.cTickRefresh = 0;
1213 lpsp->oa.cTickRefresh = (DWORD)(cmsec1MINUTE * lpp->dwIDC_SVR_AUTOREFRESH_MINUTES);
1215 if (!Server_SavePreferences (lpp->lpiServer))
1218 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1225 if ((lpCell = lpp->lpiServer->OpenCell()) != NULL)
1227 lpCell->RefreshVLDB (NULL);
1232 (void)Alert_Scout_QueueCheckServer (lpp->lpiServer);
1235 ptp->lpUser = 0; // we freed this; don't let anyone use it.
1239 void Task_Svr_Enum_To_ComboBox (LPTASKPACKET ptp)
1241 LPSVR_ENUM_TO_COMBOBOX_PACKET lpp = (LPSVR_ENUM_TO_COMBOBOX_PACKET)(ptp->lpUser);
1243 // Fill in the Servers combobox, and select the default server
1244 // (if one was specified, either as a server or as a fileset).
1246 CB_StartChange (lpp->hCombo, TRUE);
1249 if ((lpCell = g.lpiCell->OpenCell (&ptp->status)) == NULL)
1254 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
1256 TCHAR szName[ cchNAME ];
1257 lpServer->GetName (szName);
1258 CB_AddItem (lpp->hCombo, szName, (LPARAM)lpServer->GetIdentifier());
1264 if (lpp->lpiSelect && lpp->lpiSelect->GetServer())
1265 CB_EndChange (lpp->hCombo, (LPARAM)(lpp->lpiSelect->GetServer()));
1268 CB_EndChange (lpp->hCombo, 0);
1269 CB_SetSelected (lpp->hCombo, 0);
1273 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
1277 void Task_Svr_GetWindowPos (LPTASKPACKET ptp)
1279 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1281 SetRectEmpty (&TASKDATA(ptp)->rWindow);
1285 LPSERVER_PREF lpsp = (LPSERVER_PREF)lpi->GetUserParam();
1287 if (lpsp != NULL && (lpsp->rLast.right != 0))
1289 TASKDATA(ptp)->rWindow = lpsp->rLast;
1295 void Task_Svr_SetWindowPos (LPTASKPACKET ptp)
1297 LPSVR_SETWINDOWPOS_PARAMS lpp = (LPSVR_SETWINDOWPOS_PARAMS)(ptp->lpUser);
1301 LPSERVER_PREF lpsp = (LPSERVER_PREF)(lpp->lpi->GetUserParam());
1305 lpsp->rLast = lpp->rWindow;
1306 lpsp->fOpen = lpp->fOpen;
1308 StorePreferences (lpp->lpi, lpsp, sizeof(SERVER_PREF));
1313 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
1317 void Task_Svr_SyncVLDB (LPTASKPACKET ptp)
1319 LPSVR_SYNCVLDB_PARAMS lpp = (LPSVR_SYNCVLDB_PARAMS)(ptp->lpUser);
1321 if (!AfsClass_SyncVLDB (lpp->lpi, lpp->fForce, &ptp->status))
1324 if (!ptp->rc && !IsWindow (ptp->hReply))
1326 ErrorDialog (ptp->status, IDS_ERROR_CANT_SYNCVLDB);
1330 ptp->lpUser = 0; // we freed this; don't let anyone use it.
1334 void Task_Svr_Salvage (LPTASKPACKET ptp)
1336 LPSVR_SALVAGE_PARAMS lpp = (LPSVR_SALVAGE_PARAMS)(ptp->lpUser);
1338 LPTSTR pszTempDir = (lpp->szTempDir[0] != TEXT('\0')) ? lpp->szTempDir : NULL;
1339 LPTSTR pszLogFile = (lpp->szLogFile[0] != TEXT('\0')) ? lpp->szLogFile : NULL;
1341 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))
1345 ptp->lpUser = 0; // we freed this; don't let anyone use it.
1349 void Task_Svr_Install (LPTASKPACKET ptp)
1351 LPSVR_INSTALL_PARAMS lpp = (LPSVR_INSTALL_PARAMS)(ptp->lpUser);
1353 ptp->rc = AfsClass_InstallFile (lpp->lpiServer, lpp->szTarget, lpp->szSource, &ptp->status);
1355 if (!ptp->rc && !ptp->hReply)
1357 TCHAR szFilename[ MAX_PATH ];
1358 TCHAR szSvrName[ cchRESOURCE ];
1359 lpp->lpiServer->GetServerName (szSvrName);
1360 CopyBaseFileName (szFilename, lpp->szSource);
1361 ErrorDialog (ptp->status, IDS_ERROR_CANT_INSTALL_FILE, TEXT("%s%s"), szSvrName, szFilename);
1365 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1369 void Task_Svr_Uninstall (LPTASKPACKET ptp)
1371 LPSVR_UNINSTALL_PARAMS lpp = (LPSVR_UNINSTALL_PARAMS)(ptp->lpUser);
1373 ptp->rc = AfsClass_UninstallFile (lpp->lpiServer, lpp->szUninstall, &ptp->status);
1375 if (!ptp->rc && !ptp->hReply)
1377 TCHAR szFilename[ MAX_PATH ];
1378 TCHAR szSvrName[ cchRESOURCE ];
1379 lpp->lpiServer->GetServerName (szSvrName);
1380 CopyBaseFileName (szFilename, lpp->szUninstall);
1381 ErrorDialog (ptp->status, IDS_ERROR_CANT_UNINSTALL_FILE, TEXT("%s%s"), szSvrName, szFilename);
1385 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1389 void Task_Svr_Prune (LPTASKPACKET ptp)
1391 LPSVR_PRUNE_PARAMS lpp = (LPSVR_PRUNE_PARAMS)(ptp->lpUser);
1393 ptp->rc = AfsClass_PruneOldFiles (lpp->lpiServer, lpp->fBAK, lpp->fOLD, lpp->fCore, &ptp->status);
1395 if (!ptp->rc && !ptp->hReply)
1397 TCHAR szSvrName[ cchRESOURCE ];
1398 lpp->lpiServer->GetServerName (szSvrName);
1399 ErrorDialog (ptp->status, IDS_ERROR_CANT_PRUNE_FILES, TEXT("%s"), szSvrName);
1403 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1407 void Task_Svr_GetDates (LPTASKPACKET ptp)
1409 LPSVR_GETDATES_PARAMS lpp = (LPSVR_GETDATES_PARAMS)(ptp->lpUser);
1415 ptp->rc = AfsClass_GetFileDates (lpp->lpiServer, lpp->szFilename, &stFile, &stBAK, &stOLD, &ptp->status);
1419 TCHAR szText[ cchRESOURCE ];
1420 if (FormatTime (szText, TEXT("%s"), &stFile))
1421 TASKDATA(ptp)->pszText1 = CloneString (szText);
1423 if (FormatTime (szText, TEXT("%s"), &stBAK))
1424 TASKDATA(ptp)->pszText2 = CloneString (szText);
1426 if (FormatTime (szText, TEXT("%s"), &stOLD))
1427 TASKDATA(ptp)->pszText3 = CloneString (szText);
1431 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1435 void Task_Svr_Execute (LPTASKPACKET ptp)
1437 LPSVR_EXECUTE_PARAMS lpp = (LPSVR_EXECUTE_PARAMS)(ptp->lpUser);
1439 ptp->rc = AfsClass_ExecuteCommand (lpp->lpiServer, lpp->szCommand, &ptp->status);
1443 TCHAR szServer[ cchNAME ];
1444 lpp->lpiServer->GetServerName (szServer);
1445 ErrorDialog (ptp->status, IDS_ERROR_CANT_EXECUTE_COMMAND, TEXT("%s%s"), szServer, lpp->szCommand);
1449 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1453 void Task_Svr_SetAuth (LPTASKPACKET ptp)
1455 LPSVR_SETAUTH_PARAMS lpp = (LPSVR_SETAUTH_PARAMS)(ptp->lpUser);
1457 ptp->rc = AfsClass_SetServerAuth (lpp->lpiServer, lpp->fEnableAuth, &ptp->status);
1461 TCHAR szServer[ cchNAME ];
1462 lpp->lpiServer->GetServerName (szServer);
1463 ErrorDialog (ptp->status, (lpp->fEnableAuth) ? IDS_ERROR_CANT_AUTH_ON : IDS_ERROR_CANT_AUTH_OFF, TEXT("%s"), szServer);
1467 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1471 void Task_Svr_AdmList_Open (LPTASKPACKET ptp)
1473 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1475 if ((TASKDATA(ptp)->lpAdmList = AfsClass_AdminList_Load (lpiServer, &ptp->status)) == NULL)
1479 TCHAR szServer[ cchNAME ];
1480 lpiServer->GetServerName (szServer);
1481 ErrorDialog (ptp->status, IDS_ERROR_CANT_LOAD_ADMLIST, TEXT("%s"), szServer);
1486 void Task_Svr_AdmList_Save (LPTASKPACKET ptp)
1488 LPADMINLIST lpAdmList = (LPADMINLIST)(ptp->lpUser);
1490 // Increment the reference counter on this admin list before handing
1491 // it off to the Save routine, as that routine will be posting
1492 // notifications using its handle. When our notification handler
1493 // receives the End notification, it will attempt to free the list--
1494 // which will decrement the counter again, and actually free the list
1495 // if the counter hits zero.
1497 InterlockedIncrement (&lpAdmList->cRef);
1499 ptp->rc = AfsClass_AdminList_Save (lpAdmList, &ptp->status);
1503 TCHAR szServer[ cchNAME ];
1504 lpAdmList->lpiServer->GetServerName (szServer);
1505 ErrorDialog (ptp->status, IDS_ERROR_CANT_SAVE_ADMLIST, TEXT("%s"), szServer);
1508 AfsClass_AdminList_Free (lpAdmList);
1509 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1513 void Task_Svr_KeyList_Open (LPTASKPACKET ptp)
1515 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1517 if ((TASKDATA(ptp)->lpKeyList = AfsClass_KeyList_Load (lpiServer, &ptp->status)) == NULL)
1521 TCHAR szServer[ cchNAME ];
1522 lpiServer->GetServerName (szServer);
1523 ErrorDialog (ptp->status, IDS_ERROR_CANT_LOAD_KEYLIST, TEXT("%s"), szServer);
1528 void Task_Svr_Key_Create (LPTASKPACKET ptp)
1530 LPKEY_CREATE_PARAMS lpp = (LPKEY_CREATE_PARAMS)(ptp->lpUser);
1532 if (lpp->szString[0])
1533 ptp->rc = AfsClass_AddKey (lpp->lpiServer, lpp->keyVersion, lpp->szString, &ptp->status);
1535 ptp->rc = AfsClass_AddKey (lpp->lpiServer, lpp->keyVersion, &lpp->key, &ptp->status);
1537 if ((TASKDATA(ptp)->lpKeyList = AfsClass_KeyList_Load (lpp->lpiServer, &ptp->status)) == NULL)
1541 TCHAR szServer[ cchNAME ];
1542 lpp->lpiServer->GetServerName (szServer);
1543 ErrorDialog (ptp->status, IDS_ERROR_CANT_CREATE_KEY, TEXT("%s"), szServer);
1547 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1551 void Task_Svr_Key_Delete (LPTASKPACKET ptp)
1553 LPKEY_DELETE_PARAMS lpp = (LPKEY_DELETE_PARAMS)(ptp->lpUser);
1555 if (!AfsClass_DeleteKey (lpp->lpiServer, lpp->keyVersion, &ptp->status))
1559 TCHAR szServer[ cchNAME ];
1560 lpp->lpiServer->GetServerName (szServer);
1561 ErrorDialog (ptp->status, IDS_ERROR_CANT_DELETE_KEY, TEXT("%s%lu"), szServer, lpp->keyVersion);
1565 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1569 void Task_Svr_GetRandomKey (LPTASKPACKET ptp)
1571 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1573 if (!AfsClass_GetRandomKey (lpiServer, &TASKDATA(ptp)->key, &ptp->status))
1577 TCHAR szServer[ cchNAME ];
1578 lpiServer->GetServerName (szServer);
1579 ErrorDialog (ptp->status, IDS_ERROR_CANT_GETRANDOMKEY, TEXT("%s"), szServer);
1584 void Task_Svr_HostList_Open (LPTASKPACKET ptp)
1586 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1588 if ((TASKDATA(ptp)->lpHostList = AfsClass_HostList_Load (lpiServer, &ptp->status)) == NULL)
1592 TCHAR szServer[ cchNAME ];
1593 lpiServer->GetServerName (szServer);
1594 ErrorDialog (ptp->status, IDS_ERROR_CANT_LOAD_HOSTLIST, TEXT("%s"), szServer);
1599 void Task_Svr_HostList_Save (LPTASKPACKET ptp)
1601 LPHOSTLIST lpHostList = (LPHOSTLIST)(ptp->lpUser);
1603 // Increment the reference counter on this admin list before handing
1604 // it off to the Save routine, as that routine will be posting
1605 // notifications using its handle. When our notification handler
1606 // receives the End notification, it will attempt to free the list--
1607 // which will decrement the counter again, and actually free the list
1608 // if the counter hits zero.
1610 InterlockedIncrement (&lpHostList->cRef);
1612 ptp->rc = AfsClass_HostList_Save (lpHostList, &ptp->status);
1616 TCHAR szServer[ cchNAME ];
1617 lpHostList->lpiServer->GetServerName (szServer);
1618 ErrorDialog (ptp->status, IDS_ERROR_CANT_SAVE_HOSTLIST, TEXT("%s"), szServer);
1621 AfsClass_HostList_Free (lpHostList);
1622 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1626 void Task_Svr_Monitor_OnOff (LPTASKPACKET ptp)
1628 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1631 if ((lpServer = lpiServer->OpenServer()) != NULL)
1633 BOOL fMonitored = lpServer->fIsMonitored();
1635 g.sub = Subsets_SetMonitor (g.sub, lpiServer, !fMonitored);
1637 lpServer->SetMonitor (!fMonitored);
1644 void Task_Svr_ChangeAddr (LPTASKPACKET ptp)
1646 LPSVR_CHANGEADDR_PARAMS lpp = (LPSVR_CHANGEADDR_PARAMS)(ptp->lpUser);
1648 if ((ptp->rc = AfsClass_ChangeAddress (lpp->lpiServer, &lpp->ssOld, &lpp->ssNew, &ptp->status)) == FALSE)
1650 TCHAR szName[ cchRESOURCE ];
1651 lpp->lpiServer->GetServerName (szName);
1652 ErrorDialog (ptp->status, IDS_ERROR_CANT_CHANGEADDR, TEXT("%s"), szName);
1656 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1660 void Task_Svc_Menu (LPTASKPACKET ptp)
1662 TASKDATA(ptp)->mt = *(LPMENUTASK)(ptp->lpUser);
1663 Delete ((LPMENUTASK)(ptp->lpUser));
1664 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
1666 if (TASKDATA(ptp)->mt.lpi && TASKDATA(ptp)->mt.lpi->fIsService())
1668 LPSERVICE lpService;
1669 if ((lpService = TASKDATA(ptp)->mt.lpi->OpenService (&ptp->status)) == NULL)
1673 if (!lpService->GetStatus (&TASKDATA(ptp)->cs, FALSE, &ptp->status))
1681 void Task_Svc_Prop_Init (LPTASKPACKET ptp)
1683 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1685 LPSERVICE lpService;
1686 if ((lpService = lpi->OpenService (&ptp->status)) == NULL)
1690 if (!lpService->GetStatus (&TASKDATA(ptp)->cs, TRUE, &ptp->status))
1694 else if ((TASKDATA(ptp)->lpcp = (LPSERVICE_PREF)lpi->GetUserParam()) == NULL)
1697 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1704 if ((TASKDATA(ptp)->lpsp = (LPSERVER_PREF)lpi->GetServer()->GetUserParam()) == NULL)
1707 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1713 void Task_Svc_Prop_Apply (LPTASKPACKET ptp)
1715 LPSVC_PROP_APPLY_PACKET lpp = (LPSVC_PROP_APPLY_PACKET)(ptp->lpUser);
1717 LPSERVICE lpService;
1718 if ((lpService = lpp->lpi->OpenService (&ptp->status)) == NULL)
1722 LPSERVICE_PREF lpcp = NULL;
1723 if ((lpcp = (LPSERVICE_PREF)lpp->lpi->GetUserParam()) == NULL)
1726 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1731 if ((lpiServer = lpp->lpi->GetServer()) != NULL)
1734 if ((lpsp = (LPSERVER_PREF)lpiServer->GetUserParam()) != NULL)
1736 if (lpsp->fWarnSvcStop)
1737 lpcp->fWarnSvcStop = lpp->fIDC_SVC_WARNSTOP;
1741 if (!Services_SavePreferences (lpp->lpi))
1744 ptp->status = GetLastError();
1751 (void)Alert_Scout_QueueCheckServer (lpp->lpi);
1754 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1758 void Task_Svc_Start (LPTASKPACKET ptp)
1760 LPSVC_START_PARAMS lpp = (LPSVC_START_PARAMS)(ptp->lpUser);
1762 if (!AfsClass_StartService (lpp->lpiStart, lpp->fTemporary, &ptp->status))
1765 if (!ptp->rc && !ptp->hReply)
1767 TCHAR szSvrName[ cchRESOURCE ];
1768 TCHAR szSvcName[ cchRESOURCE ];
1769 lpp->lpiStart->GetServerName (szSvrName);
1770 lpp->lpiStart->GetServiceName (szSvcName);
1771 ErrorDialog (ptp->status, IDS_ERROR_CANT_START_SERVICE, TEXT("%s%s"), szSvrName, szSvcName);
1775 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1779 void Task_Svc_Stop (LPTASKPACKET ptp)
1781 LPSVC_STOP_PARAMS lpp = (LPSVC_STOP_PARAMS)(ptp->lpUser);
1783 if (!AfsClass_StopService (lpp->lpiStop, lpp->fTemporary, TRUE, &ptp->status))
1786 if (!ptp->rc && !ptp->hReply)
1788 TCHAR szSvrName[ cchRESOURCE ];
1789 TCHAR szSvcName[ cchRESOURCE ];
1790 lpp->lpiStop->GetServerName (szSvrName);
1791 lpp->lpiStop->GetServiceName (szSvcName);
1792 ErrorDialog (ptp->status, IDS_ERROR_CANT_STOP_SERVICE, TEXT("%s%s"), szSvrName, szSvcName);
1796 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1800 void Task_Svc_Restart (LPTASKPACKET ptp)
1802 LPIDENT lpiService = (LPIDENT)(ptp->lpUser);
1804 if (!AfsClass_RestartService (lpiService, &ptp->status))
1807 if (!ptp->rc && !ptp->hReply)
1809 TCHAR szSvrName[ cchRESOURCE ];
1810 TCHAR szSvcName[ cchRESOURCE ];
1811 lpiService->GetServerName (szSvrName);
1812 lpiService->GetServiceName (szSvcName);
1813 ErrorDialog (ptp->status, IDS_ERROR_CANT_RESTART_SERVICE, TEXT("%s%s"), szSvrName, szSvcName);
1818 void Task_Svc_FindLog (LPTASKPACKET ptp)
1820 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1822 if ((TASKDATA(ptp)->lpcp = (LPSERVICE_PREF)lpi->GetUserParam()) == NULL)
1825 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1830 if (TASKDATA(ptp)->lpcp->szLogFile[0] == TEXT('\0'))
1833 ptp->status = ERROR_FILE_NOT_FOUND;
1839 if ((TASKDATA(ptp)->pszText1 = CloneString (TASKDATA(ptp)->lpcp->szLogFile)) == NULL)
1842 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1848 void Task_Svc_ViewLog (LPTASKPACKET ptp)
1850 LPSVC_VIEWLOG_PACKET lpp = (LPSVC_VIEWLOG_PACKET)(ptp->lpUser);
1852 TCHAR szTempPath[ MAX_PATH ];
1853 GetTempPath (MAX_PATH, szTempPath);
1855 TCHAR szFilename[ MAX_PATH ];
1856 GetTempFileName (szTempPath, TEXT("log"), 0, szFilename);
1858 if (!AfsClass_GetServerLogFile (lpp->lpiServer, szFilename, lpp->szRemote, &ptp->status))
1860 DeleteFile (szFilename);
1866 if ((TASKDATA(ptp)->pszText1 = CloneString (szFilename)) == NULL)
1869 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1874 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1878 void Task_Svc_Create (LPTASKPACKET ptp)
1880 LPSVC_CREATE_PARAMS lpp = (LPSVC_CREATE_PARAMS)(ptp->lpUser);
1883 if ((lpiService = AfsClass_CreateService (lpp->lpiServer, lpp->szService, lpp->szCommand, lpp->szParams, lpp->szNotifier, lpp->type, &lpp->stIfCron, &ptp->status)) == NULL)
1890 // Start it if necessary
1892 if ((lpp->type == SERVICETYPE_SIMPLE) && (lpp->fRunNow))
1894 if (!AfsClass_StartService (lpiService, FALSE, &ptp->status))
1901 if (ptp->rc && lpp->szLogFile[0])
1903 LPSERVICE_PREF lpsp;
1904 if ((lpsp = (LPSERVICE_PREF)lpiService->GetUserParam()) != NULL)
1906 lstrcpy (lpsp->szLogFile, lpp->szLogFile);
1908 if (!Services_SavePreferences (lpiService))
1911 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1918 TCHAR szServer[ cchNAME ];
1919 lpp->lpiServer->GetServerName (szServer);
1920 ErrorDialog (ptp->status, IDS_ERROR_CANT_CREATE_SERVICE, TEXT("%s%s"), szServer, lpp->szService);
1924 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1928 void Task_Svc_Delete (LPTASKPACKET ptp)
1930 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1932 ptp->rc = AfsClass_DeleteService (lpi, &ptp->status);
1936 TCHAR szServer[ cchNAME ];
1937 TCHAR szService[ cchNAME ];
1938 lpi->GetServerName (szServer);
1939 lpi->GetServiceName (szService);
1940 ErrorDialog (ptp->status, IDS_ERROR_CANT_DELETE_SERVICE, TEXT("%s%s"), szServer, szService);
1945 void Task_Svc_GetRestartTimes (LPTASKPACKET ptp)
1947 LPSVC_RESTARTTIMES_PARAMS lpp = (LPSVC_RESTARTTIMES_PARAMS)(ptp->lpUser);
1949 ptp->rc = AfsClass_GetRestartTimes (lpp->lpi, &lpp->fGeneral, &lpp->stGeneral, &lpp->fNewBinary, &lpp->stNewBinary, &ptp->status);
1953 lpp->fGeneral = FALSE;
1954 lpp->fNewBinary = FALSE;
1956 TCHAR szSvrName[ cchNAME ];
1957 lpp->lpi->GetServerName (szSvrName);
1958 ErrorDialog (ptp->status, IDS_ERROR_REFRESH_SERVICE_STATUS, TEXT("%s%s"), szSvrName, TEXT("BOS"));
1964 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1969 void Task_Svc_SetRestartTimes (LPTASKPACKET ptp)
1971 LPSVC_RESTARTTIMES_PARAMS lpp = (LPSVC_RESTARTTIMES_PARAMS)(ptp->lpUser);
1973 ptp->rc = AfsClass_SetRestartTimes (lpp->lpi, ((lpp->fGeneral) ? &lpp->stGeneral : NULL), ((lpp->fNewBinary) ? &lpp->stNewBinary : NULL), &ptp->status);
1977 TCHAR szSvrName[ cchNAME ];
1978 lpp->lpi->GetServerName (szSvrName);
1979 ErrorDialog (ptp->status, IDS_ERROR_CANT_SET_RESTART_TIMES, TEXT("%s"), szSvrName);
1985 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1990 void Task_Agg_Prop_Init (LPTASKPACKET ptp)
1992 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1994 LPAGGREGATE lpAggregate;
1995 if ((lpAggregate = lpi->OpenAggregate (&ptp->status)) == NULL)
1999 if (!lpAggregate->GetStatus (&TASKDATA(ptp)->as, TRUE, &ptp->status))
2004 if ((TASKDATA(ptp)->lpap = (LPAGGREGATE_PREF)lpAggregate->GetUserParam()) == NULL)
2006 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2010 TCHAR szText[ cchRESOURCE ];
2011 lpAggregate->GetDevice (szText);
2012 TASKDATA(ptp)->pszText1 = CloneString (szText);
2016 TASKDATA(ptp)->nFilesets = 0;
2019 for (LPFILESET lpFileset = lpAggregate->FilesetFindFirst (&hEnum); lpFileset; lpFileset = lpAggregate->FilesetFindNext (&hEnum))
2021 (TASKDATA(ptp)->nFilesets)++;
2026 lpAggregate->Close();
2031 if ((TASKDATA(ptp)->lpsp = (LPSERVER_PREF)lpi->GetServer()->GetUserParam()) == NULL)
2033 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2040 void Task_Agg_Prop_Apply (LPTASKPACKET ptp)
2042 LPAGG_PROP_APPLY_PACKET lpp = (LPAGG_PROP_APPLY_PACKET)(ptp->lpUser);
2044 LPAGGREGATE_PREF lpap;
2045 if ((lpap = (LPAGGREGATE_PREF)lpp->lpi->GetAggregate()->GetUserParam()) == NULL)
2047 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2053 if ((lpiServer = lpp->lpi->GetServer()) != NULL)
2056 if ((lpsp = (LPSERVER_PREF)lpiServer->GetUserParam()) != NULL)
2058 if (lpsp->fWarnAggAlloc)
2059 lpap->fWarnAggAlloc = lpp->fIDC_AGG_WARNALLOC;
2063 if (!lpp->fIDC_AGG_WARN)
2064 lpap->perWarnAggFull = 0;
2065 else if (lpp->fIDC_AGG_WARN_AGGFULL_DEF)
2066 lpap->perWarnAggFull = -1;
2068 lpap->perWarnAggFull = lpp->wIDC_AGG_WARN_AGGFULL_PERCENT;
2070 if (!Aggregates_SavePreferences (lpp->lpi))
2072 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2076 (void)Alert_Scout_QueueCheckServer (lpp->lpi);
2080 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2084 void Task_Agg_Find_Quota_Limits (LPTASKPACKET ptp)
2086 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2088 TASKDATA(ptp)->ckMin = ckQUOTA_MINIMUM;
2089 TASKDATA(ptp)->ckMax = ckQUOTA_MAXIMUM;
2091 if (lpi && (lpi->fIsAggregate() || lpi->fIsFileset()))
2093 LPAGGREGATE lpAggregate;
2094 if ((lpAggregate = lpi->OpenAggregate (&ptp->status)) == NULL)
2099 if (!lpAggregate->GetStatus (&as, TRUE, &ptp->status))
2103 TASKDATA(ptp)->ckMax = max( 1L, as.ckStorageTotal );
2105 lpAggregate->Close();
2111 void Task_Agg_Enum_To_ListView (LPTASKPACKET ptp)
2113 LPAGG_ENUM_TO_LISTVIEW_PACKET lpp = (LPAGG_ENUM_TO_LISTVIEW_PACKET)(ptp->lpUser);
2115 UpdateDisplay_Aggregates (TRUE, lpp->hList, NULL, 0, lpp->lpiServer, lpp->lpiSelect, lpp->lpvi);
2118 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2122 void Task_Agg_Enum_To_ComboBox (LPTASKPACKET ptp)
2124 LPAGG_ENUM_TO_COMBOBOX_PACKET lpp = (LPAGG_ENUM_TO_COMBOBOX_PACKET)(ptp->lpUser);
2126 UpdateDisplay_Aggregates (TRUE, lpp->hCombo, NULL, 0, lpp->lpiServer, lpp->lpiSelect, NULL);
2129 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2133 void Task_Agg_Find_Ghost (LPTASKPACKET ptp)
2135 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2137 LPAGGREGATE lpAggregate;
2138 if ((lpAggregate = lpi->OpenAggregate (&ptp->status)) == NULL)
2142 TASKDATA(ptp)->wGhost = lpAggregate->GetGhostStatus();
2143 lpAggregate->Close();
2148 void Task_Set_Enum_To_ComboBox (LPTASKPACKET ptp)
2150 LPSET_ENUM_TO_COMBOBOX_PACKET lpp = (LPSET_ENUM_TO_COMBOBOX_PACKET)(ptp->lpUser);
2152 UpdateDisplay_Filesets (TRUE, lpp->hCombo, NULL, 0, lpp->lpiServer, lpp->lpiAggregate, lpp->lpiSelect);
2155 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2159 void Task_Set_Find_Ghost (LPTASKPACKET ptp)
2161 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2163 LPFILESET lpFileset;
2164 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2168 TASKDATA(ptp)->wGhost = lpFileset->GetGhostStatus();
2169 TASKDATA(ptp)->fHasReplicas = FALSE;
2171 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs))
2173 TASKDATA(ptp)->fs.Type = ftREADWRITE;
2175 else if (TASKDATA(ptp)->fs.Type == ftREADWRITE)
2178 for (LPIDENT lpiSearch = IDENT::FindFirst (&hEnum, &TASKDATA(ptp)->fs.idReplica); lpiSearch; lpiSearch = IDENT::FindNext (&hEnum))
2180 LPFILESET lpReplica;
2181 if ((lpReplica = lpiSearch->OpenFileset()) != NULL)
2184 TASKDATA(ptp)->fHasReplicas = TRUE;
2188 IDENT::FindClose (&hEnum);
2196 void Task_Set_Create (LPTASKPACKET ptp)
2198 LPSET_CREATE_PARAMS lpp = (LPSET_CREATE_PARAMS)(ptp->lpUser);
2201 if ((lpiFileset = AfsClass_CreateFileset (lpp->lpiParent, lpp->szName, (ULONG)lpp->ckQuota, &ptp->status)) == NULL)
2204 if (ptp->rc && lpp->fCreateClone)
2206 ptp->rc = AfsClass_Clone (lpiFileset, &ptp->status);
2211 TASKDATA(ptp)->lpi = lpiFileset;
2215 TCHAR szServer[ cchNAME ];
2216 TCHAR szAggregate[ cchNAME ];
2217 lpp->lpiParent->GetServerName (szServer);
2218 lpp->lpiParent->GetAggregateName (szAggregate);
2219 ErrorDialog (ptp->status, IDS_ERROR_CANT_CREATE_FILESET, TEXT("%s%s%s"), szServer, szAggregate, lpp->szName);
2223 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2227 void Task_Set_Delete (LPTASKPACKET ptp)
2229 LPSET_DELETE_PARAMS lpp = (LPSET_DELETE_PARAMS)(ptp->lpUser);
2231 // First, what kind of fileset are we deleting here?
2233 LPIDENT lpiClone = NULL;
2234 FILESETTYPE setType = ftREADWRITE;
2235 LPFILESET lpFileset;
2236 if ((lpFileset = lpp->lpiFileset->OpenFileset (&ptp->status)) == NULL)
2240 lpiClone = lpFileset->GetCloneIdentifier();
2242 if (lpFileset->GetStatus (&TASKDATA(ptp)->fs))
2243 setType = TASKDATA(ptp)->fs.Type;
2248 // Delete the fileset in whichever way is appropriate
2250 if (setType == ftREADWRITE)
2252 if (lpp->fVLDB && lpiClone)
2255 if ((lpClone = lpiClone->OpenFileset()) != NULL) // clone really there?
2259 if (!AfsClass_DeleteClone (lpiClone, &ptp->status))
2265 if (!AfsClass_DeleteFileset (lpp->lpiFileset, lpp->fVLDB, lpp->fServer, &ptp->status))
2269 else if (setType == ftREPLICA)
2271 if (!AfsClass_DeleteReplica (lpp->lpiFileset, &ptp->status))
2274 else if (setType == ftCLONE)
2276 if (!AfsClass_DeleteClone (lpp->lpiFileset, &ptp->status))
2283 (!lpp->fVLDB && (lpp->wGhost & GHOST_HAS_VLDB_ENTRY)) ||
2284 (!lpp->fServer && (lpp->wGhost & GHOST_HAS_SERVER_ENTRY)) )
2286 Alert_Scout_QueueCheckServer (lpp->lpiFileset->GetServer());
2291 TCHAR szServer[ cchNAME ];
2292 TCHAR szAggregate[ cchNAME ];
2293 TCHAR szFileset[ cchNAME ];
2294 lpp->lpiFileset->GetServerName (szServer);
2295 lpp->lpiFileset->GetAggregateName (szAggregate);
2296 lpp->lpiFileset->GetFilesetName (szFileset);
2297 ErrorDialog (ptp->status, IDS_ERROR_CANT_DELETE_FILESET, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2301 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2305 void Task_Set_Move (LPTASKPACKET ptp)
2307 LPSET_MOVE_PARAMS lpp = (LPSET_MOVE_PARAMS)(ptp->lpUser);
2309 BOOL fIsReplica = FALSE;
2311 LPFILESET lpFileset;
2312 if ((lpFileset = lpp->lpiSource->OpenFileset (&ptp->status)) == NULL)
2317 if (!lpFileset->GetStatus (&fs, TRUE, &ptp->status))
2321 if (fs.Type == ftREPLICA)
2331 if (!AfsClass_MoveReplica (lpp->lpiSource, lpp->lpiTarget, &ptp->status))
2336 if (!AfsClass_MoveFileset (lpp->lpiSource, lpp->lpiTarget, &ptp->status))
2343 TCHAR szServerSource[ cchNAME ];
2344 TCHAR szServerTarget[ cchNAME ];
2345 TCHAR szAggregateSource[ cchNAME ];
2346 TCHAR szAggregateTarget[ cchNAME ];
2347 TCHAR szFileset[ cchNAME ];
2348 lpp->lpiSource->GetServerName (szServerSource);
2349 lpp->lpiSource->GetAggregateName (szAggregateSource);
2350 lpp->lpiSource->GetFilesetName (szFileset);
2351 lpp->lpiTarget->GetServerName (szServerTarget);
2352 lpp->lpiTarget->GetAggregateName (szAggregateTarget);
2353 ErrorDialog (ptp->status, IDS_ERROR_MOVE_FILESET, TEXT("%s%s%s%s%s"), szServerSource, szAggregateSource, szFileset, szServerTarget, szAggregateTarget);
2357 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2361 void Task_Set_MoveTo_Init (LPTASKPACKET ptp)
2363 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2365 LPFILESET lpFileset;
2366 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2370 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2377 void Task_Set_Prop_Init (LPTASKPACKET ptp)
2379 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2381 LPFILESET lpFileset;
2382 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2386 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2388 else if ((TASKDATA(ptp)->lpfp = (LPFILESET_PREF)lpFileset->GetUserParam()) == NULL)
2391 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2398 if ((TASKDATA(ptp)->lpsp = (LPSERVER_PREF)lpi->GetServer()->GetUserParam()) == NULL)
2401 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2407 void Task_Set_Prop_Apply (LPTASKPACKET ptp)
2409 LPSET_PROP_APPLY_PARAMS lpp = (LPSET_PROP_APPLY_PARAMS)(ptp->lpUser);
2411 LPFILESET_PREF lpfp = NULL;
2412 if ((lpfp = (LPFILESET_PREF)lpp->lpi->GetUserParam()) == NULL)
2415 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2419 if (!lpp->fIDC_SET_WARN)
2420 lpfp->perWarnSetFull = 0;
2421 else if (lpp->fIDC_SET_WARN_SETFULL_DEF)
2422 lpfp->perWarnSetFull = -1;
2424 lpfp->perWarnSetFull = lpp->wIDC_SET_WARN_SETFULL_PERCENT;
2426 if (!Filesets_SavePreferences (lpp->lpi))
2429 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2433 Alert_Scout_QueueCheckServer (lpp->lpi);
2436 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2440 void Task_Set_SetQuota_Init (LPTASKPACKET ptp)
2442 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2444 LPFILESET lpFileset;
2445 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2449 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2457 Task_Agg_Find_Quota_Limits (ptp);
2462 void Task_Set_SetQuota_Apply (LPTASKPACKET ptp)
2464 LPSET_SETQUOTA_APPLY_PARAMS lpp = (LPSET_SETQUOTA_APPLY_PARAMS)(ptp->lpUser);
2466 if (!AfsClass_SetFilesetQuota (lpp->lpiFileset, lpp->ckQuota, &ptp->status))
2471 TCHAR szServer[ cchNAME ];
2472 TCHAR szAggregate[ cchNAME ];
2473 TCHAR szFileset[ cchNAME ];
2474 lpp->lpiFileset->GetServerName (szServer);
2475 lpp->lpiFileset->GetAggregateName (szAggregate);
2476 lpp->lpiFileset->GetFilesetName (szFileset);
2477 ErrorDialog (ptp->status, IDS_ERROR_CANT_SET_FILESET_QUOTA, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2481 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2485 void Task_Set_RepProp_Init (LPTASKPACKET ptp)
2487 LPSET_REPPROP_INIT_PARAMS lpp = (LPSET_REPPROP_INIT_PARAMS)(ptp->lpUser);
2489 LPFILESET lpFileset;
2490 if ((lpFileset = lpp->lpiReq->OpenFileset (&ptp->status)) == NULL)
2494 if ((lpp->lpiRW = lpFileset->GetReadWriteIdentifier (&ptp->status)) == NULL)
2496 else if (!lpFileset->GetStatus (&lpp->fs, TRUE, &ptp->status))
2501 // don't delete this packet (ptp->lpUser)! the caller will free it.
2505 void Task_Set_Select (LPTASKPACKET ptp)
2507 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2509 LPFILESET lpFileset;
2510 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2514 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2522 void Task_Set_BeginDrag (LPTASKPACKET ptp)
2524 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2526 LPFILESET lpFileset;
2527 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2531 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2538 void Task_Set_DragMenu (LPTASKPACKET ptp)
2540 TASKDATA(ptp)->mt = *(LPMENUTASK)(ptp->lpUser);
2541 Delete ((LPMENUTASK)(ptp->lpUser));
2542 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2544 if (TASKDATA(ptp)->mt.lpi && TASKDATA(ptp)->mt.lpi->fIsFileset())
2546 LPFILESET lpFileset;
2547 if ((lpFileset = TASKDATA(ptp)->mt.lpi->OpenFileset (&ptp->status)) == NULL)
2551 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2559 void Task_Set_Menu (LPTASKPACKET ptp)
2561 TASKDATA(ptp)->mt = *(LPMENUTASK)(ptp->lpUser);
2562 Delete ((LPMENUTASK)(ptp->lpUser));
2563 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2565 if (TASKDATA(ptp)->mt.lpi && TASKDATA(ptp)->mt.lpi->fIsFileset())
2567 LPFILESET lpFileset;
2568 if ((lpFileset = TASKDATA(ptp)->mt.lpi->OpenFileset (&ptp->status)) == NULL)
2572 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2581 void Task_Set_Lock (LPTASKPACKET ptp)
2583 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2584 ptp->rc = AfsClass_LockFileset (lpi, &ptp->status);
2588 void Task_Set_Unlock (LPTASKPACKET ptp)
2590 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2592 if (lpi->fIsFileset())
2593 ptp->rc = AfsClass_UnlockFileset (lpi, &ptp->status);
2595 ptp->rc = AfsClass_UnlockAllFilesets (lpi, &ptp->status);
2599 void Task_Set_CreateRep (LPTASKPACKET ptp)
2601 LPSET_CREATEREP_PARAMS lpp = (LPSET_CREATEREP_PARAMS)(ptp->lpUser);
2604 if ((lpiReplica = AfsClass_CreateReplica (lpp->lpiSource, lpp->lpiTarget, &ptp->status)) == NULL)
2609 TASKDATA(ptp)->lpi = lpiReplica;
2613 TCHAR szServer[ cchNAME ];
2614 TCHAR szAggregate[ cchNAME ];
2615 TCHAR szFileset[ cchNAME ];
2616 lpp->lpiTarget->GetServerName (szServer);
2617 lpp->lpiTarget->GetAggregateName (szAggregate);
2618 lpp->lpiSource->GetFilesetName (szFileset);
2619 ErrorDialog (ptp->status, IDS_ERROR_CANT_CREATE_REPLICA, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2623 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2627 void Task_Set_Rename_Init (LPTASKPACKET ptp)
2629 LPSET_RENAME_INIT_PARAMS lpp = (LPSET_RENAME_INIT_PARAMS)(ptp->lpUser);
2631 LPFILESET lpFileset;
2632 if ((lpFileset = lpp->lpiReq->OpenFileset (&ptp->status)) == NULL)
2636 if ((lpp->lpiRW = lpFileset->GetReadWriteIdentifier (&ptp->status)) == NULL)
2641 // don't delete this packet (ptp->lpUser)! the caller will free it.
2645 void Task_Set_Rename_Apply (LPTASKPACKET ptp)
2647 LPSET_RENAME_APPLY_PARAMS lpp = (LPSET_RENAME_APPLY_PARAMS)(ptp->lpUser);
2649 ptp->rc = AfsClass_RenameFileset (lpp->lpiFileset, lpp->szNewName, &ptp->status);
2653 TCHAR szFileset[ cchNAME ];
2654 lpp->lpiFileset->GetFilesetName (szFileset);
2655 ErrorDialog (ptp->status, IDS_ERROR_CANT_RENAME_FILESET, TEXT("%s%s"), szFileset, lpp->szNewName);
2659 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2663 void Task_Set_Release (LPTASKPACKET ptp)
2665 LPSET_RELEASE_PARAMS lpp = (LPSET_RELEASE_PARAMS)(ptp->lpUser);
2667 ptp->rc = AfsClass_ReleaseFileset (lpp->lpiRW, lpp->fForce, &ptp->status);
2671 TCHAR szServer[ cchNAME ];
2672 TCHAR szAggregate[ cchNAME ];
2673 TCHAR szFileset[ cchNAME ];
2674 lpp->lpiRW->GetServerName (szServer);
2675 lpp->lpiRW->GetAggregateName (szAggregate);
2676 lpp->lpiRW->GetFilesetName (szFileset);
2677 ErrorDialog (ptp->status, IDS_ERROR_CANT_RELEASE_FILESET, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2681 ptp->lpUser = 0; // we freed this; don't let anyone use it.
2685 void Task_Set_Clone (LPTASKPACKET ptp)
2687 LPIDENT lpiRW = (LPIDENT)(ptp->lpUser);
2689 ptp->rc = AfsClass_Clone (lpiRW, &ptp->status);
2693 TCHAR szServer[ cchNAME ];
2694 TCHAR szAggregate[ cchNAME ];
2695 TCHAR szFileset[ cchNAME ];
2696 lpiRW->GetServerName (szServer);
2697 lpiRW->GetAggregateName (szAggregate);
2698 lpiRW->GetFilesetName (szFileset);
2699 ErrorDialog (ptp->status, IDS_ERROR_CANT_CLONE, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2704 void Task_Set_Clonesys (LPTASKPACKET ptp)
2706 LPSET_CLONESYS_PARAMS lpp = (LPSET_CLONESYS_PARAMS)(ptp->lpUser);
2708 LPTSTR pszPrefix = (lpp->fUsePrefix) ? lpp->szPrefix : NULL;
2709 if (!AfsClass_CloneMultiple (lpp->lpi, pszPrefix, lpp->fExcludePrefix, &ptp->status))
2712 if (!ptp->rc && !IsWindow (ptp->hReply))
2714 ErrorDialog (ptp->status, IDS_ERROR_CANT_CLONESYS);
2718 ptp->lpUser = 0; // we freed this; don't let anyone use it.
2722 void Task_Set_Dump (LPTASKPACKET ptp)
2724 LPSET_DUMP_PARAMS lpp = (LPSET_DUMP_PARAMS)(ptp->lpUser);
2726 ptp->rc = AfsClass_DumpFileset (lpp->lpi, lpp->szFilename,
2727 (lpp->fDumpByDate) ? &lpp->stDump : NULL,
2732 TCHAR szServer[ cchNAME ];
2733 TCHAR szAggregate[ cchNAME ];
2734 TCHAR szFileset[ cchNAME ];
2735 lpp->lpi->GetServerName (szServer);
2736 lpp->lpi->GetAggregateName (szAggregate);
2737 lpp->lpi->GetFilesetName (szFileset);
2738 ErrorDialog (ptp->status, IDS_ERROR_CANT_DUMP_FILESET, TEXT("%s%s%s%s"), szServer, szAggregate, szFileset, lpp->szFilename);
2742 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2746 void Task_Set_Restore (LPTASKPACKET ptp)
2748 LPSET_RESTORE_PARAMS lpp = (LPSET_RESTORE_PARAMS)(ptp->lpUser);
2750 ptp->rc = AfsClass_RestoreFileset (lpp->lpi, lpp->szFileset, lpp->szFilename, lpp->fIncremental, &ptp->status);
2754 TCHAR szServer[ cchNAME ];
2755 TCHAR szAggregate[ cchNAME ];
2756 lpp->lpi->GetServerName (szServer);
2757 lpp->lpi->GetAggregateName (szAggregate);
2758 ErrorDialog (ptp->status, IDS_ERROR_CANT_RESTORE_FILESET, TEXT("%s%s%s%s"), szServer, szAggregate, lpp->szFileset, lpp->szFilename);
2762 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2766 void Task_Set_Lookup (LPTASKPACKET ptp)
2768 LPSET_LOOKUP_PACKET lpp = (LPSET_LOOKUP_PACKET)(ptp->lpUser);
2770 if ((TASKDATA(ptp)->lpi = IDENT::FindFileset (g.lpiCell, lpp->szFileset)) != NULL)
2772 LPFILESET lpFileset;
2773 if ((lpFileset = TASKDATA(ptp)->lpi->OpenFileset()) == NULL)
2774 TASKDATA(ptp)->lpi = NULL; // fileset was probably deleted earlier
2780 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2784 void Task_Expired_Creds (LPTASKPACKET ptp)
2788 CheckForExpiredCredentials();