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 _________________________________________________________________
84 DWORD WINAPI Task_ThreadProc (PVOID lp);
86 void Task_Perform (LPTASKPACKET ptp);
89 void Task_ExportCell (LPTASKPACKET ptp);
91 void Task_OpenCell (LPTASKPACKET ptp);
92 void Task_OpenedCell (LPTASKPACKET ptp);
93 void Task_ClosedCell (LPTASKPACKET ptp);
94 void Task_Refresh (LPTASKPACKET ptp, BOOL fNewCreds);
95 void Task_Subset_To_List (LPTASKPACKET ptp);
96 void Task_Apply_Subset (LPTASKPACKET ptp);
97 void Task_Svr_Prop_Init (LPTASKPACKET ptp);
98 void Task_Svr_Scout_Init (LPTASKPACKET ptp);
99 void Task_Svr_Scout_Apply (LPTASKPACKET ptp);
100 void Task_Svr_Enum_To_ComboBox (LPTASKPACKET ptp);
101 void Task_Svr_GetWindowPos (LPTASKPACKET ptp);
102 void Task_Svr_SetWindowPos (LPTASKPACKET ptp);
103 void Task_Svr_SyncVLDB (LPTASKPACKET ptp);
104 void Task_Svr_Salvage (LPTASKPACKET ptp);
105 void Task_Svr_Install (LPTASKPACKET ptp);
106 void Task_Svr_Uninstall (LPTASKPACKET ptp);
107 void Task_Svr_Prune (LPTASKPACKET ptp);
108 void Task_Svr_GetDates (LPTASKPACKET ptp);
109 void Task_Svr_Execute (LPTASKPACKET ptp);
110 void Task_Svr_SetAuth (LPTASKPACKET ptp);
111 void Task_Svr_AdmList_Open (LPTASKPACKET ptp);
112 void Task_Svr_AdmList_Save (LPTASKPACKET ptp);
113 void Task_Svr_KeyList_Open (LPTASKPACKET ptp);
114 void Task_Svr_Key_Create (LPTASKPACKET ptp);
115 void Task_Svr_Key_Delete (LPTASKPACKET ptp);
116 void Task_Svr_HostList_Open (LPTASKPACKET ptp);
117 void Task_Svr_HostList_Save (LPTASKPACKET ptp);
118 void Task_Svr_GetRandomKey (LPTASKPACKET ptp);
119 void Task_Svr_Monitor_OnOff (LPTASKPACKET ptp);
120 void Task_Svr_ChangeAddr (LPTASKPACKET ptp);
121 void Task_Svc_Menu (LPTASKPACKET ptp);
122 void Task_Svc_Prop_Init (LPTASKPACKET ptp);
123 void Task_Svc_Prop_Apply (LPTASKPACKET ptp);
124 void Task_Svc_Start (LPTASKPACKET ptp);
125 void Task_Svc_Stop (LPTASKPACKET ptp);
126 void Task_Svc_Restart (LPTASKPACKET ptp);
127 void Task_Svc_FindLog (LPTASKPACKET ptp);
128 void Task_Svc_ViewLog (LPTASKPACKET ptp);
129 void Task_Svc_Create (LPTASKPACKET ptp);
130 void Task_Svc_Delete (LPTASKPACKET ptp);
131 void Task_Svc_GetRestartTimes (LPTASKPACKET ptp);
132 void Task_Svc_SetRestartTimes (LPTASKPACKET ptp);
133 void Task_Agg_Prop_Init (LPTASKPACKET ptp);
134 void Task_Agg_Prop_Apply (LPTASKPACKET ptp);
135 void Task_Agg_Find_Quota_Limits (LPTASKPACKET ptp);
136 void Task_Agg_Enum_To_ListView (LPTASKPACKET ptp);
137 void Task_Agg_Enum_To_ComboBox (LPTASKPACKET ptp);
138 void Task_Agg_Find_Ghost (LPTASKPACKET ptp);
139 void Task_Set_Enum_To_ComboBox (LPTASKPACKET ptp);
140 void Task_Set_Find_Ghost (LPTASKPACKET ptp);
141 void Task_Set_Create (LPTASKPACKET ptp);
142 void Task_Set_Delete (LPTASKPACKET ptp);
143 void Task_Set_Move (LPTASKPACKET ptp);
144 void Task_Set_MoveTo_Init (LPTASKPACKET ptp);
145 void Task_Set_Prop_Init (LPTASKPACKET ptp);
146 void Task_Set_Prop_Apply (LPTASKPACKET ptp);
147 void Task_Set_SetQuota_Init (LPTASKPACKET ptp);
148 void Task_Set_SetQuota_Apply (LPTASKPACKET ptp);
149 void Task_Set_RepProp_Init (LPTASKPACKET ptp);
150 void Task_Set_Select (LPTASKPACKET ptp);
151 void Task_Set_BeginDrag (LPTASKPACKET ptp);
152 void Task_Set_DragMenu (LPTASKPACKET ptp);
153 void Task_Set_Menu (LPTASKPACKET ptp);
154 void Task_Set_Lock (LPTASKPACKET ptp);
155 void Task_Set_Unlock (LPTASKPACKET ptp);
156 void Task_Set_CreateRep (LPTASKPACKET ptp);
157 void Task_Set_Rename_Init (LPTASKPACKET ptp);
158 void Task_Set_Rename_Apply (LPTASKPACKET ptp);
159 void Task_Set_Release (LPTASKPACKET ptp);
160 void Task_Set_Clone (LPTASKPACKET ptp);
161 void Task_Set_Clonesys (LPTASKPACKET ptp);
162 void Task_Set_Dump (LPTASKPACKET ptp);
163 void Task_Set_Restore (LPTASKPACKET ptp);
164 void Task_Set_Lookup (LPTASKPACKET ptp);
165 void Task_Expired_Creds (LPTASKPACKET ptp);
169 * ROUTINES ___________________________________________________________________
173 LPTASKPACKET CreateTaskPacket (int idTask, HWND hReply, PVOID lpUser)
177 if ((ptp = New (TASKPACKET)) != NULL)
179 memset (ptp, 0x00, sizeof(TASKPACKET));
181 ptp->idTask = idTask;
182 ptp->hReply = hReply;
183 ptp->lpUser = lpUser;
188 if ((ptp->pReturn = New (TASKPACKETDATA)) != NULL)
190 memset (ptp->pReturn, 0x00, sizeof(TASKPACKETDATA));
198 void FreeTaskPacket (LPTASKPACKET ptp)
204 if (TASKDATA(ptp)->pszText1)
205 FreeString (TASKDATA(ptp)->pszText1);
206 if (TASKDATA(ptp)->pszText2)
207 FreeString (TASKDATA(ptp)->pszText2);
208 if (TASKDATA(ptp)->pszText3)
209 FreeString (TASKDATA(ptp)->pszText3);
210 Delete (ptp->pReturn);
218 void PerformTask (LPTASKPACKET ptp)
222 ASSERT( AfsClass_GetEnterCount() == 1 );
229 Task_ExportCell (ptp);
238 Task_OpenedCell (ptp);
242 Task_ClosedCell (ptp);
246 Task_Refresh (ptp, FALSE);
249 case taskREFRESH_CREDS:
250 Task_Refresh (ptp, TRUE);
253 case taskSUBSET_TO_LIST:
254 Task_Subset_To_List (ptp);
257 case taskAPPLY_SUBSET:
258 Task_Apply_Subset (ptp);
261 case taskSVR_PROP_INIT:
262 Task_Svr_Prop_Init (ptp);
265 case taskSVR_SCOUT_INIT:
266 Task_Svr_Scout_Init (ptp);
269 case taskSVR_SCOUT_APPLY:
270 Task_Svr_Scout_Apply (ptp);
273 case taskSVR_ENUM_TO_COMBOBOX:
274 Task_Svr_Enum_To_ComboBox (ptp);
277 case taskSVR_GETWINDOWPOS:
278 Task_Svr_GetWindowPos (ptp);
281 case taskSVR_SETWINDOWPOS:
282 Task_Svr_SetWindowPos (ptp);
285 case taskSVR_SYNCVLDB:
286 Task_Svr_SyncVLDB (ptp);
289 case taskSVR_SALVAGE:
290 Task_Svr_Salvage (ptp);
293 case taskSVR_INSTALL:
294 Task_Svr_Install (ptp);
297 case taskSVR_UNINSTALL:
298 Task_Svr_Uninstall (ptp);
302 Task_Svr_Prune (ptp);
305 case taskSVR_GETDATES:
306 Task_Svr_GetDates (ptp);
309 case taskSVR_EXECUTE:
310 Task_Svr_Execute (ptp);
313 case taskSVR_SETAUTH:
314 Task_Svr_SetAuth (ptp);
317 case taskSVR_ADMLIST_OPEN:
318 Task_Svr_AdmList_Open (ptp);
321 case taskSVR_ADMLIST_SAVE:
322 Task_Svr_AdmList_Save (ptp);
325 case taskSVR_KEYLIST_OPEN:
326 Task_Svr_KeyList_Open (ptp);
329 case taskSVR_KEY_CREATE:
330 Task_Svr_Key_Create (ptp);
333 case taskSVR_KEY_DELETE:
334 Task_Svr_Key_Delete (ptp);
337 case taskSVR_GETRANDOMKEY:
338 Task_Svr_GetRandomKey (ptp);
341 case taskSVR_HOSTLIST_OPEN:
342 Task_Svr_HostList_Open (ptp);
345 case taskSVR_HOSTLIST_SAVE:
346 Task_Svr_HostList_Save (ptp);
349 case taskSVR_MONITOR_ONOFF:
350 Task_Svr_Monitor_OnOff (ptp);
353 case taskSVR_CHANGEADDR:
354 Task_Svr_ChangeAddr (ptp);
361 case taskSVC_PROP_INIT:
362 Task_Svc_Prop_Init (ptp);
365 case taskSVC_PROP_APPLY:
366 Task_Svc_Prop_Apply (ptp);
370 Task_Svc_Start (ptp);
377 case taskSVC_RESTART:
378 Task_Svc_Restart (ptp);
381 case taskSVC_FINDLOG:
382 Task_Svc_FindLog (ptp);
385 case taskSVC_VIEWLOG:
386 Task_Svc_ViewLog (ptp);
390 Task_Svc_Create (ptp);
394 Task_Svc_Delete (ptp);
397 case taskSVC_GETRESTARTTIMES:
398 Task_Svc_GetRestartTimes (ptp);
401 case taskSVC_SETRESTARTTIMES:
402 Task_Svc_SetRestartTimes (ptp);
405 case taskAGG_PROP_INIT:
406 Task_Agg_Prop_Init (ptp);
409 case taskAGG_PROP_APPLY:
410 Task_Agg_Prop_Apply (ptp);
413 case taskAGG_FIND_QUOTA_LIMITS:
414 Task_Agg_Find_Quota_Limits (ptp);
417 case taskAGG_ENUM_TO_LISTVIEW:
418 Task_Agg_Enum_To_ListView (ptp);
421 case taskAGG_ENUM_TO_COMBOBOX:
422 Task_Agg_Enum_To_ComboBox (ptp);
425 case taskAGG_FIND_GHOST:
426 Task_Agg_Find_Ghost (ptp);
429 case taskSET_ENUM_TO_COMBOBOX:
430 Task_Set_Enum_To_ComboBox (ptp);
433 case taskSET_FIND_GHOST:
434 Task_Set_Find_Ghost (ptp);
438 Task_Set_Create (ptp);
442 Task_Set_Delete (ptp);
449 case taskSET_MOVETO_INIT:
450 Task_Set_MoveTo_Init (ptp);
453 case taskSET_PROP_INIT:
454 Task_Set_Prop_Init (ptp);
457 case taskSET_PROP_APPLY:
458 Task_Set_Prop_Apply (ptp);
461 case taskSET_SETQUOTA_INIT:
462 Task_Set_SetQuota_Init (ptp);
465 case taskSET_SETQUOTA_APPLY:
466 Task_Set_SetQuota_Apply (ptp);
469 case taskSET_REPPROP_INIT:
470 Task_Set_RepProp_Init (ptp);
474 Task_Set_Select (ptp);
477 case taskSET_BEGINDRAG:
478 Task_Set_BeginDrag (ptp);
481 case taskSET_DRAGMENU:
482 Task_Set_DragMenu (ptp);
494 Task_Set_Unlock (ptp);
497 case taskSET_CREATEREP:
498 Task_Set_CreateRep (ptp);
501 case taskSET_RENAME_INIT:
502 Task_Set_Rename_Init (ptp);
505 case taskSET_RENAME_APPLY:
506 Task_Set_Rename_Apply (ptp);
509 case taskSET_RELEASE:
510 Task_Set_Release (ptp);
514 Task_Set_Clone (ptp);
517 case taskSET_CLONESYS:
518 Task_Set_Clonesys (ptp);
525 case taskSET_RESTORE:
526 Task_Set_Restore (ptp);
530 Task_Set_Lookup (ptp);
533 case taskEXPIRED_CREDS:
534 Task_Expired_Creds (ptp);
539 ptp->status = ERROR_INVALID_FUNCTION;
544 ASSERT( AfsClass_GetEnterCount() == 1 );
550 void CoverServerList (LPIDENT lpiCell, ULONG status)
552 TCHAR szName[ cchRESOURCE ];
553 lpiCell->GetCellName (szName);
559 case ERROR_NOT_AUTHENTICATED:
560 idsButton = IDS_ALERT_BUTTON_GETCREDS;
563 idsButton = IDS_ALERT_BUTTON_TRYAGAIN;
568 LPTSTR pszCover = FormatString (IDS_ERROR_REFRESH_CELLSERVERS, TEXT("%s%e"), szName, status);
569 LPTSTR pszButton = FormatString (idsButton);
571 AfsAppLib_CoverWindow (GetDlgItem (g.hMain, IDC_SERVERS), pszCover, pszButton);
573 FreeString (pszButton);
574 FreeString (pszCover);
579 ULONG SystemTimeToUnixTime (SYSTEMTIME *pst)
588 if (!SystemTimeToFileTime (&st, &ft))
592 now.HighPart = (LONG)ft.dwHighDateTime;
593 now.LowPart = (ULONG)ft.dwLowDateTime;
595 LARGE_INTEGER offset;
596 offset.HighPart = 0x019db1de;
597 offset.LowPart = 0xd53e8000;
599 LARGE_INTEGER result;
600 result.QuadPart = (now.QuadPart - offset.QuadPart) / 10000000;
601 return (ULONG)result.LowPart;
604 static size_t nExportLevels = 0;
605 void Task_ExportCell_Spacing (LPTSTR pszSpacing)
607 wsprintf (pszSpacing, TEXT("%99s"), TEXT(""));
608 pszSpacing[ nExportLevels *3 ] = TEXT('\0');
611 #define chLBRC TEXT('{')
612 #define chRBRC TEXT('}')
614 void Task_ExportCell_Begin (HANDLE fh, LPTSTR eck, LPTSTR pszName)
616 TCHAR szSpacing[ 256 ];
617 Task_ExportCell_Spacing (szSpacing);
619 wsprintf (szLine, TEXT("\r\n%s%s %s %c\r\n"), szSpacing, eck, pszName, chLBRC);
621 WriteFile (fh, szLine, lstrlen(szLine), &cbWrote, NULL);
625 void Task_ExportCell_End (HANDLE fh)
628 TCHAR szSpacing[ 256 ];
629 Task_ExportCell_Spacing (szSpacing);
631 wsprintf (szLine, TEXT("%s%c\r\n"), szSpacing, chRBRC);
633 WriteFile (fh, szLine, lstrlen(szLine), &cbWrote, NULL);
636 void Task_ExportCell_Line (HANDLE fh, LPTSTR eck, LPTSTR pszRHS)
638 TCHAR szSpacing[ 256 ];
639 Task_ExportCell_Spacing (szSpacing);
641 wsprintf (szLine, TEXT("%s%s = \"%s\"\r\n"), szSpacing, eck, pszRHS);
643 WriteFile (fh, szLine, lstrlen(szLine), &cbWrote, NULL);
646 void Task_ExportCell_LineAddr (HANDLE fh, LPTSTR eck, SOCKADDR_IN *pAddr)
648 LPSTR pszLine = FormatString (TEXT("%1"), TEXT("%a"), pAddr);
649 Task_ExportCell_Line (fh, eck, pszLine);
650 FreeString (pszLine);
653 void Task_ExportCell_LineInt (HANDLE fh, LPTSTR eck, int dw)
656 wsprintf (szLine, TEXT("%lu"), dw);
657 Task_ExportCell_Line (fh, eck, szLine);
660 void Task_ExportCell_LineLarge (HANDLE fh, LPTSTR eck, LARGE_INTEGER *pldw)
663 wsprintf (szLine, TEXT("%lu,,%lu"), pldw->HighPart, pldw->LowPart);
664 Task_ExportCell_Line (fh, eck, szLine);
667 void Task_ExportCell_LineDate (HANDLE fh, LPTSTR eck, SYSTEMTIME *pst)
669 Task_ExportCell_LineInt (fh, eck, SystemTimeToUnixTime(pst));
672 void Task_ExportService (HANDLE fh, LPSERVICE lpService)
674 TCHAR szName[ cchNAME ];
675 lpService->GetName (szName);
676 Task_ExportCell_Begin (fh, eckSERVICE, szName);
679 if (lpService->GetStatus (&ss))
681 Task_ExportCell_LineInt (fh, eckRUNNING, (ss.state == SERVICESTATE_RUNNING));
682 Task_ExportCell_LineInt (fh, eckSTATE, ss.state);
683 Task_ExportCell_LineInt (fh, eckNSTARTS, ss.nStarts);
684 Task_ExportCell_LineInt (fh, eckERRLAST, ss.dwErrLast);
685 Task_ExportCell_LineInt (fh, eckSIGLAST, ss.dwSigLast);
686 Task_ExportCell_Line (fh, eckPARAMS, ss.szParams);
687 Task_ExportCell_Line (fh, eckNOTIFIER, ss.szNotifier);
688 Task_ExportCell_LineDate (fh, eckSTARTTIME, &ss.timeLastStart);
689 Task_ExportCell_LineDate (fh, eckSTOPTIME, &ss.timeLastStop);
690 Task_ExportCell_LineDate (fh, eckERRORTIME, &ss.timeLastFail);
692 if (ss.type == SERVICETYPE_SIMPLE)
693 Task_ExportCell_Line (fh, eckTYPE, eckSIMPLE);
694 else if (ss.type == SERVICETYPE_CRON)
695 Task_ExportCell_Line (fh, eckTYPE, eckCRON);
696 else // (ss.type == SERVICETYPE_FS)
697 Task_ExportCell_Line (fh, eckTYPE, eckFS);
700 Task_ExportCell_End (fh);
703 void Task_ExportFileset (HANDLE fh, LPFILESET lpFileset)
705 TCHAR szName[ cchNAME ];
706 lpFileset->GetName (szName);
707 Task_ExportCell_Begin (fh, eckFILESET, szName);
710 if (lpFileset->GetStatus (&fs))
712 Task_ExportCell_LineInt (fh, eckID, fs.id);
713 Task_ExportCell_LineInt (fh, eckID_RW, fs.idReadWrite);
714 Task_ExportCell_LineInt (fh, eckID_BK, fs.idClone);
715 Task_ExportCell_LineInt (fh, eckUSED, fs.ckUsed);
716 Task_ExportCell_LineInt (fh, eckQUOTA, fs.ckQuota);
717 Task_ExportCell_LineDate (fh, eckCREATETIME, &fs.timeCreation);
718 Task_ExportCell_LineDate (fh, eckUPDATETIME, &fs.timeLastUpdate);
719 Task_ExportCell_LineDate (fh, eckACCESSTIME, &fs.timeLastAccess);
720 Task_ExportCell_LineDate (fh, eckBACKUPTIME, &fs.timeLastBackup);
723 Task_ExportCell_End (fh);
726 void Task_ExportAggregate (HANDLE fh, LPAGGREGATE lpAggregate)
728 TCHAR szName[ cchNAME ];
729 lpAggregate->GetName (szName);
730 Task_ExportCell_Begin (fh, eckAGGREGATE, szName);
732 lpAggregate->GetDevice (szName);
733 Task_ExportCell_Line (fh, eckDEVICE, szName);
736 if (lpAggregate->GetStatus (&as))
738 Task_ExportCell_LineInt (fh, eckID, (int)as.dwID);
739 Task_ExportCell_LineInt (fh, eckTOTAL, (int)as.ckStorageTotal);
740 Task_ExportCell_LineInt (fh, eckFREECUR, (int)as.ckStorageFree);
744 for (LPFILESET lpFileset = lpAggregate->FilesetFindFirst (&hEnum); lpFileset; lpFileset = lpAggregate->FilesetFindNext (&hEnum))
746 Task_ExportFileset (fh, lpFileset);
750 Task_ExportCell_End (fh);
753 void Task_ExportServer (HANDLE fh, LPSERVER lpServer)
755 TCHAR szName[ cchNAME ];
756 lpServer->GetLongName (szName);
757 Task_ExportCell_Begin (fh, eckSERVER, szName);
759 // First, properties of the server
762 if (lpServer->GetStatus (&ss))
764 for (size_t iAddr = 0; iAddr < ss.nAddresses; ++iAddr)
765 Task_ExportCell_LineAddr (fh, eckADDRESS, &ss.aAddresses[ iAddr ]);
768 // Then, services on the server
771 for (LPSERVICE lpService = lpServer->ServiceFindFirst (&hEnum); lpService; lpService = lpServer->ServiceFindNext (&hEnum))
773 Task_ExportService (fh, lpService);
777 // Then, aggregates and filesets on the server
779 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&hEnum); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&hEnum))
781 Task_ExportAggregate (fh, lpAggregate);
782 lpAggregate->Close();
785 Task_ExportCell_End (fh);
788 void Task_ExportCell (LPTASKPACKET ptp)
790 LPTSTR pszFilename = (LPTSTR)(ptp->lpUser);
793 fh = CreateFile (pszFilename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL);
794 if (fh != INVALID_HANDLE_VALUE)
796 TCHAR szName[ cchNAME ];
797 g.lpiCell->GetCellName (szName);
798 Task_ExportCell_Begin (fh, eckCELL, szName);
801 if ((lpCell = g.lpiCell->OpenCell()) != NULL)
804 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
806 Task_ExportServer (fh, lpServer);
813 Task_ExportCell_End (fh);
817 Delete (pszFilename);
818 ptp->lpUser = 0; // we freed this; don't let the caller use it again
823 void Task_OpenCell (LPTASKPACKET ptp)
825 LPOPENCELL_PACKET lpp = (LPOPENCELL_PACKET)(ptp->lpUser);
827 LPSUBSET subOld = g.sub;
830 if ((TASKDATA(ptp)->lpiCell = CELL::OpenCell (lpp->szCell, lpp->hCreds, &ptp->status)) == NULL)
836 Subsets_FreeSubset (lpp->sub);
840 Subsets_FreeSubset (subOld);
845 PostMessage (g.hMain, WM_SHOW_YOURSELF, 0, 1);
848 PostMessage (g.hMain, WM_OPEN_ACTIONS, 0, 0);
850 else if (lpp->fCloseAppOnFail)
852 FatalErrorDialog (ptp->status, IDS_ERROR_CANT_OPEN_CELL, TEXT("%s"), lpp->szCell);
856 ptp->lpUser = 0; // we freed this; don't let the caller use it again
860 void Task_OpenedCell (LPTASKPACKET ptp)
862 LPIDENT lpiCell = (LPIDENT)(ptp->lpUser);
864 if (lpiCell && lpiCell->fIsCell())
868 DontNotifyMeEver (g.hMain);
869 NotifyMe (WHEN_CELL_OPENED, NULL, g.hMain, 0);
870 NotifyMe (WHEN_OBJECT_CHANGES, lpiCell, g.hMain, 0);
871 NotifyMe (WHEN_SVRS_CHANGE, lpiCell, g.hMain, 0);
873 if (g.lpiCell != NULL)
875 CELL::CloseCell (g.lpiCell);
879 UpdateDisplay_Cell (TRUE);
881 TCHAR szName[ cchRESOURCE ];
882 lpiCell->GetCellName (szName);
884 LPTSTR pszCover = FormatString (IDS_SEARCHING_FOR_SERVERS, TEXT("%s"), szName);
885 AfsAppLib_CoverWindow (GetDlgItem (g.hMain, IDC_SERVERS), pszCover);
886 FreeString (pszCover);
889 if ((lpCell = g.lpiCell->OpenCell (&ptp->status)) == NULL)
891 CoverServerList (g.lpiCell, ptp->status);
895 lpCell->Invalidate();
896 if ((ptp->rc = lpCell->RefreshAll (&ptp->status)) != TRUE)
898 CoverServerList (g.lpiCell, ptp->status);
903 PostMessage (g.hMain, WM_OPEN_SERVERS, 0, 0);
911 void Task_ClosedCell (LPTASKPACKET ptp)
913 LPIDENT lpiCell = (LPIDENT)(ptp->lpUser);
915 if (lpiCell && lpiCell->fIsCell())
919 if (g.lpiCell == lpiCell)
922 if ((lpCellTest = g.lpiCell->OpenCell()) != NULL)
924 // the user must have opened a cell, then opened it again.
925 // this is a bogus request to close the old copy of the
931 Server_CloseAll (FALSE);
933 Main_Redraw_ThreadProc ((PVOID)FALSE);
942 void Task_Refresh (LPTASKPACKET ptp, BOOL fNewCreds)
944 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
947 if (lpi && lpi->fIsCell())
949 AfsAppLib_Uncover (GetDlgItem (g.hMain, IDC_SERVERS));
952 if ((lpCell = lpi->OpenCell (&ptp->status)) == NULL)
954 CoverServerList (lpi, ptp->status);
959 lpCell->SetCurrentCredentials (g.hCreds);
961 lpCell->Invalidate();
962 if ((ptp->rc = lpCell->RefreshAll (&ptp->status)) != TRUE)
964 CoverServerList (lpi, ptp->status);
969 else if (lpi && lpi->GetServer())
971 BOOL fWasMonitored = TRUE;
974 if ((lpServer = lpi->OpenServer()) != NULL)
976 if ((fWasMonitored = lpServer->fIsMonitored()) == FALSE)
977 lpServer->SetMonitor (TRUE);
981 if (fWasMonitored) // if it was already monitored, we didn't just refresh
983 if (lpi && lpi->fIsServer())
985 if ((lpServer = lpi->OpenServer()) != NULL)
987 lpServer->Invalidate();
988 lpServer->RefreshAll();
992 else if (lpi && lpi->fIsService())
995 if ((lpService = lpi->OpenService()) != NULL)
997 lpService->Invalidate();
998 lpService->RefreshStatus();
1002 else if (lpi && lpi->fIsAggregate())
1004 LPAGGREGATE lpAggregate;
1005 if ((lpAggregate = lpi->OpenAggregate()) != NULL)
1007 // if we implied this aggregate from fileset VLDB entries,
1008 // refresh its parent server, not this aggregate.
1010 if (!(lpAggregate->GetGhostStatus() & GHOST_HAS_SERVER_ENTRY))
1012 lpAggregate->Close();
1015 if ((lpServer = lpi->OpenServer()) != NULL)
1017 lpServer->Invalidate();
1018 lpServer->RefreshAll();
1024 lpAggregate->Invalidate();
1025 lpAggregate->RefreshStatus();
1026 lpAggregate->RefreshFilesets();
1027 lpAggregate->Close();
1030 if ((lpCell = lpi->OpenCell()) != NULL)
1032 lpCell->RefreshVLDB (lpi);
1038 else if (lpi && lpi->fIsFileset())
1040 LPFILESET lpFileset;
1041 if ((lpFileset = lpi->OpenFileset()) != NULL)
1043 lpFileset->Invalidate();
1044 lpFileset->RefreshStatus();
1048 if ((lpCell = lpi->OpenCell()) != NULL)
1050 lpCell->RefreshVLDB (lpi);
1057 Alert_Scout_QueueCheckServer (lpi);
1064 void Task_Subset_To_List (LPTASKPACKET ptp)
1066 LPSUBSET_TO_LIST_PACKET lpp = (LPSUBSET_TO_LIST_PACKET)( ptp->lpUser );
1068 LB_StartChange (lpp->hList, TRUE);
1070 LPCELL lpCell = NULL;
1072 lpCell = g.lpiCell->OpenCell();
1076 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
1078 LPIDENT lpiServer = lpServer->GetIdentifier();
1079 TCHAR szServer[ cchNAME ];
1080 lpServer->GetName (szServer);
1083 BOOL fMonitor = Subsets_fMonitorServer (lpp->sub, lpiServer);
1085 LB_AddItem (lpp->hList, szServer, (LPARAM)fMonitor);
1091 LB_EndChange (lpp->hList);
1094 ptp->lpUser = 0; // we freed this; don't let anyone use it.
1098 void Task_Apply_Subset (LPTASKPACKET ptp)
1100 LPSUBSET sub = (LPSUBSET)( ptp->lpUser );
1102 LPCELL lpCell = NULL;
1104 lpCell = g.lpiCell->OpenCell();
1108 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
1110 LPIDENT lpiServer = lpServer->GetIdentifier();
1111 TCHAR szServer[ cchNAME ];
1112 lpServer->GetName (szServer);
1114 BOOL fMonitor = Subsets_fMonitorServer (sub, lpiServer);
1115 lpServer->SetMonitor (fMonitor);
1126 void Task_Svr_Prop_Init (LPTASKPACKET ptp)
1128 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1131 if ((lpServer = lpiServer->OpenServer (&ptp->status)) == NULL)
1135 if (!lpServer->GetStatus (&TASKDATA(ptp)->ss, TRUE, &ptp->status))
1142 for (LPAGGREGATE lpAggregate = lpServer->AggregateFindFirst (&hEnum); lpAggregate; lpAggregate = lpServer->AggregateFindNext (&hEnum))
1145 if (lpAggregate->GetStatus (&as))
1147 TASKDATA(ptp)->ckCapacity += as.ckStorageTotal;
1148 TASKDATA(ptp)->ckAllocation += as.ckStorageAllocated;
1151 TASKDATA(ptp)->nAggr++;
1152 lpAggregate->Close();
1161 void Task_Svr_Scout_Init (LPTASKPACKET ptp)
1163 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1165 if ((TASKDATA(ptp)->lpsp = (LPSERVER_PREF)lpiServer->GetUserParam()) == NULL)
1168 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1173 void Task_Svr_Scout_Apply (LPTASKPACKET ptp)
1175 LPSVR_SCOUT_APPLY_PACKET lpp = (LPSVR_SCOUT_APPLY_PACKET)(ptp->lpUser);
1177 BOOL fRefreshVLDB = FALSE;
1179 LPSERVER_PREF lpsp = NULL;
1180 if ((lpsp = (LPSERVER_PREF)lpp->lpiServer->GetUserParam()) == NULL)
1183 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1187 if (!lpp->fIDC_SVR_WARN_AGGFULL)
1188 lpsp->perWarnAggFull = 0;
1190 lpsp->perWarnAggFull = lpp->wIDC_SVR_WARN_AGGFULL_PERCENT;
1192 if (!lpp->fIDC_SVR_WARN_SETFULL)
1193 lpsp->perWarnSetFull = 0;
1195 lpsp->perWarnSetFull = lpp->wIDC_SVR_WARN_SETFULL_PERCENT;
1197 DWORD fOldWarnSet = (lpsp->fWarnSetNoVLDB << 1) | lpsp->fWarnSetNoServ;
1199 lpsp->fWarnAggAlloc = lpp->fIDC_SVR_WARN_AGGALLOC;
1200 lpsp->fWarnSvcStop = lpp->fIDC_SVR_WARN_SVCSTOP;
1201 lpsp->fWarnSvrTimeout = lpp->fIDC_SVR_WARN_TIMEOUT;
1202 lpsp->fWarnSetNoVLDB = lpp->fIDC_SVR_WARN_SETNOVLDB;
1203 lpsp->fWarnSetNoServ = lpp->fIDC_SVR_WARN_SETNOSERV;
1204 lpsp->fWarnAggNoServ = lpp->fIDC_SVR_WARN_AGGNOSERV;
1206 DWORD fNewWarnSet = (lpsp->fWarnSetNoVLDB << 1) | lpsp->fWarnSetNoServ;
1208 if (fNewWarnSet != fOldWarnSet)
1209 fRefreshVLDB = TRUE;
1211 if (!lpp->fIDC_SVR_AUTOREFRESH)
1212 lpsp->oa.cTickRefresh = 0;
1214 lpsp->oa.cTickRefresh = cmsec1MINUTE * lpp->dwIDC_SVR_AUTOREFRESH_MINUTES;
1216 if (!Server_SavePreferences (lpp->lpiServer))
1219 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1226 if ((lpCell = lpp->lpiServer->OpenCell()) != NULL)
1228 lpCell->RefreshVLDB (NULL);
1233 (void)Alert_Scout_QueueCheckServer (lpp->lpiServer);
1236 ptp->lpUser = 0; // we freed this; don't let anyone use it.
1240 void Task_Svr_Enum_To_ComboBox (LPTASKPACKET ptp)
1242 LPSVR_ENUM_TO_COMBOBOX_PACKET lpp = (LPSVR_ENUM_TO_COMBOBOX_PACKET)(ptp->lpUser);
1244 // Fill in the Servers combobox, and select the default server
1245 // (if one was specified, either as a server or as a fileset).
1247 CB_StartChange (lpp->hCombo, TRUE);
1250 if ((lpCell = g.lpiCell->OpenCell (&ptp->status)) == NULL)
1255 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
1257 TCHAR szName[ cchNAME ];
1258 lpServer->GetName (szName);
1259 CB_AddItem (lpp->hCombo, szName, (LPARAM)lpServer->GetIdentifier());
1265 if (lpp->lpiSelect && lpp->lpiSelect->GetServer())
1266 CB_EndChange (lpp->hCombo, (LPARAM)(lpp->lpiSelect->GetServer()));
1269 CB_EndChange (lpp->hCombo, 0);
1270 CB_SetSelected (lpp->hCombo, 0);
1274 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
1278 void Task_Svr_GetWindowPos (LPTASKPACKET ptp)
1280 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1282 SetRectEmpty (&TASKDATA(ptp)->rWindow);
1286 LPSERVER_PREF lpsp = (LPSERVER_PREF)lpi->GetUserParam();
1288 if (lpsp != NULL && (lpsp->rLast.right != 0))
1290 TASKDATA(ptp)->rWindow = lpsp->rLast;
1296 void Task_Svr_SetWindowPos (LPTASKPACKET ptp)
1298 LPSVR_SETWINDOWPOS_PARAMS lpp = (LPSVR_SETWINDOWPOS_PARAMS)(ptp->lpUser);
1302 LPSERVER_PREF lpsp = (LPSERVER_PREF)(lpp->lpi->GetUserParam());
1306 lpsp->rLast = lpp->rWindow;
1307 lpsp->fOpen = lpp->fOpen;
1309 StorePreferences (lpp->lpi, lpsp, sizeof(SERVER_PREF));
1314 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
1318 void Task_Svr_SyncVLDB (LPTASKPACKET ptp)
1320 LPSVR_SYNCVLDB_PARAMS lpp = (LPSVR_SYNCVLDB_PARAMS)(ptp->lpUser);
1322 if (!AfsClass_SyncVLDB (lpp->lpi, lpp->fForce, &ptp->status))
1325 if (!ptp->rc && !IsWindow (ptp->hReply))
1327 ErrorDialog (ptp->status, IDS_ERROR_CANT_SYNCVLDB);
1331 ptp->lpUser = 0; // we freed this; don't let anyone use it.
1335 void Task_Svr_Salvage (LPTASKPACKET ptp)
1337 LPSVR_SALVAGE_PARAMS lpp = (LPSVR_SALVAGE_PARAMS)(ptp->lpUser);
1339 LPTSTR pszTempDir = (lpp->szTempDir[0] != TEXT('\0')) ? lpp->szTempDir : NULL;
1340 LPTSTR pszLogFile = (lpp->szLogFile[0] != TEXT('\0')) ? lpp->szLogFile : NULL;
1342 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))
1346 ptp->lpUser = 0; // we freed this; don't let anyone use it.
1350 void Task_Svr_Install (LPTASKPACKET ptp)
1352 LPSVR_INSTALL_PARAMS lpp = (LPSVR_INSTALL_PARAMS)(ptp->lpUser);
1354 ptp->rc = AfsClass_InstallFile (lpp->lpiServer, lpp->szTarget, lpp->szSource, &ptp->status);
1356 if (!ptp->rc && !ptp->hReply)
1358 TCHAR szFilename[ MAX_PATH ];
1359 TCHAR szSvrName[ cchRESOURCE ];
1360 lpp->lpiServer->GetServerName (szSvrName);
1361 CopyBaseFileName (szFilename, lpp->szSource);
1362 ErrorDialog (ptp->status, IDS_ERROR_CANT_INSTALL_FILE, TEXT("%s%s"), szSvrName, szFilename);
1366 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1370 void Task_Svr_Uninstall (LPTASKPACKET ptp)
1372 LPSVR_UNINSTALL_PARAMS lpp = (LPSVR_UNINSTALL_PARAMS)(ptp->lpUser);
1374 ptp->rc = AfsClass_UninstallFile (lpp->lpiServer, lpp->szUninstall, &ptp->status);
1376 if (!ptp->rc && !ptp->hReply)
1378 TCHAR szFilename[ MAX_PATH ];
1379 TCHAR szSvrName[ cchRESOURCE ];
1380 lpp->lpiServer->GetServerName (szSvrName);
1381 CopyBaseFileName (szFilename, lpp->szUninstall);
1382 ErrorDialog (ptp->status, IDS_ERROR_CANT_UNINSTALL_FILE, TEXT("%s%s"), szSvrName, szFilename);
1386 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1390 void Task_Svr_Prune (LPTASKPACKET ptp)
1392 LPSVR_PRUNE_PARAMS lpp = (LPSVR_PRUNE_PARAMS)(ptp->lpUser);
1394 ptp->rc = AfsClass_PruneOldFiles (lpp->lpiServer, lpp->fBAK, lpp->fOLD, lpp->fCore, &ptp->status);
1396 if (!ptp->rc && !ptp->hReply)
1398 TCHAR szSvrName[ cchRESOURCE ];
1399 lpp->lpiServer->GetServerName (szSvrName);
1400 ErrorDialog (ptp->status, IDS_ERROR_CANT_PRUNE_FILES, TEXT("%s"), szSvrName);
1404 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1408 void Task_Svr_GetDates (LPTASKPACKET ptp)
1410 LPSVR_GETDATES_PARAMS lpp = (LPSVR_GETDATES_PARAMS)(ptp->lpUser);
1416 ptp->rc = AfsClass_GetFileDates (lpp->lpiServer, lpp->szFilename, &stFile, &stBAK, &stOLD, &ptp->status);
1420 TCHAR szText[ cchRESOURCE ];
1421 if (FormatTime (szText, TEXT("%s"), &stFile))
1422 TASKDATA(ptp)->pszText1 = CloneString (szText);
1424 if (FormatTime (szText, TEXT("%s"), &stBAK))
1425 TASKDATA(ptp)->pszText2 = CloneString (szText);
1427 if (FormatTime (szText, TEXT("%s"), &stOLD))
1428 TASKDATA(ptp)->pszText3 = CloneString (szText);
1432 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1436 void Task_Svr_Execute (LPTASKPACKET ptp)
1438 LPSVR_EXECUTE_PARAMS lpp = (LPSVR_EXECUTE_PARAMS)(ptp->lpUser);
1440 ptp->rc = AfsClass_ExecuteCommand (lpp->lpiServer, lpp->szCommand, &ptp->status);
1444 TCHAR szServer[ cchNAME ];
1445 lpp->lpiServer->GetServerName (szServer);
1446 ErrorDialog (ptp->status, IDS_ERROR_CANT_EXECUTE_COMMAND, TEXT("%s%s"), szServer, lpp->szCommand);
1450 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1454 void Task_Svr_SetAuth (LPTASKPACKET ptp)
1456 LPSVR_SETAUTH_PARAMS lpp = (LPSVR_SETAUTH_PARAMS)(ptp->lpUser);
1458 ptp->rc = AfsClass_SetServerAuth (lpp->lpiServer, lpp->fEnableAuth, &ptp->status);
1462 TCHAR szServer[ cchNAME ];
1463 lpp->lpiServer->GetServerName (szServer);
1464 ErrorDialog (ptp->status, (lpp->fEnableAuth) ? IDS_ERROR_CANT_AUTH_ON : IDS_ERROR_CANT_AUTH_OFF, TEXT("%s"), szServer);
1468 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1472 void Task_Svr_AdmList_Open (LPTASKPACKET ptp)
1474 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1476 if ((TASKDATA(ptp)->lpAdmList = AfsClass_AdminList_Load (lpiServer, &ptp->status)) == NULL)
1480 TCHAR szServer[ cchNAME ];
1481 lpiServer->GetServerName (szServer);
1482 ErrorDialog (ptp->status, IDS_ERROR_CANT_LOAD_ADMLIST, TEXT("%s"), szServer);
1487 void Task_Svr_AdmList_Save (LPTASKPACKET ptp)
1489 LPADMINLIST lpAdmList = (LPADMINLIST)(ptp->lpUser);
1491 // Increment the reference counter on this admin list before handing
1492 // it off to the Save routine, as that routine will be posting
1493 // notifications using its handle. When our notification handler
1494 // receives the End notification, it will attempt to free the list--
1495 // which will decrement the counter again, and actually free the list
1496 // if the counter hits zero.
1498 InterlockedIncrement (&lpAdmList->cRef);
1500 ptp->rc = AfsClass_AdminList_Save (lpAdmList, &ptp->status);
1504 TCHAR szServer[ cchNAME ];
1505 lpAdmList->lpiServer->GetServerName (szServer);
1506 ErrorDialog (ptp->status, IDS_ERROR_CANT_SAVE_ADMLIST, TEXT("%s"), szServer);
1509 AfsClass_AdminList_Free (lpAdmList);
1510 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1514 void Task_Svr_KeyList_Open (LPTASKPACKET ptp)
1516 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1518 if ((TASKDATA(ptp)->lpKeyList = AfsClass_KeyList_Load (lpiServer, &ptp->status)) == NULL)
1522 TCHAR szServer[ cchNAME ];
1523 lpiServer->GetServerName (szServer);
1524 ErrorDialog (ptp->status, IDS_ERROR_CANT_LOAD_KEYLIST, TEXT("%s"), szServer);
1529 void Task_Svr_Key_Create (LPTASKPACKET ptp)
1531 LPKEY_CREATE_PARAMS lpp = (LPKEY_CREATE_PARAMS)(ptp->lpUser);
1533 if (lpp->szString[0])
1534 ptp->rc = AfsClass_AddKey (lpp->lpiServer, lpp->keyVersion, lpp->szString, &ptp->status);
1536 ptp->rc = AfsClass_AddKey (lpp->lpiServer, lpp->keyVersion, &lpp->key, &ptp->status);
1538 if ((TASKDATA(ptp)->lpKeyList = AfsClass_KeyList_Load (lpp->lpiServer, &ptp->status)) == NULL)
1542 TCHAR szServer[ cchNAME ];
1543 lpp->lpiServer->GetServerName (szServer);
1544 ErrorDialog (ptp->status, IDS_ERROR_CANT_CREATE_KEY, TEXT("%s"), szServer);
1548 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1552 void Task_Svr_Key_Delete (LPTASKPACKET ptp)
1554 LPKEY_DELETE_PARAMS lpp = (LPKEY_DELETE_PARAMS)(ptp->lpUser);
1556 if (!AfsClass_DeleteKey (lpp->lpiServer, lpp->keyVersion, &ptp->status))
1560 TCHAR szServer[ cchNAME ];
1561 lpp->lpiServer->GetServerName (szServer);
1562 ErrorDialog (ptp->status, IDS_ERROR_CANT_DELETE_KEY, TEXT("%s%lu"), szServer, lpp->keyVersion);
1566 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1570 void Task_Svr_GetRandomKey (LPTASKPACKET ptp)
1572 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1574 if (!AfsClass_GetRandomKey (lpiServer, &TASKDATA(ptp)->key, &ptp->status))
1578 TCHAR szServer[ cchNAME ];
1579 lpiServer->GetServerName (szServer);
1580 ErrorDialog (ptp->status, IDS_ERROR_CANT_GETRANDOMKEY, TEXT("%s"), szServer);
1585 void Task_Svr_HostList_Open (LPTASKPACKET ptp)
1587 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1589 if ((TASKDATA(ptp)->lpHostList = AfsClass_HostList_Load (lpiServer, &ptp->status)) == NULL)
1593 TCHAR szServer[ cchNAME ];
1594 lpiServer->GetServerName (szServer);
1595 ErrorDialog (ptp->status, IDS_ERROR_CANT_LOAD_HOSTLIST, TEXT("%s"), szServer);
1600 void Task_Svr_HostList_Save (LPTASKPACKET ptp)
1602 LPHOSTLIST lpHostList = (LPHOSTLIST)(ptp->lpUser);
1604 // Increment the reference counter on this admin list before handing
1605 // it off to the Save routine, as that routine will be posting
1606 // notifications using its handle. When our notification handler
1607 // receives the End notification, it will attempt to free the list--
1608 // which will decrement the counter again, and actually free the list
1609 // if the counter hits zero.
1611 InterlockedIncrement (&lpHostList->cRef);
1613 ptp->rc = AfsClass_HostList_Save (lpHostList, &ptp->status);
1617 TCHAR szServer[ cchNAME ];
1618 lpHostList->lpiServer->GetServerName (szServer);
1619 ErrorDialog (ptp->status, IDS_ERROR_CANT_SAVE_HOSTLIST, TEXT("%s"), szServer);
1622 AfsClass_HostList_Free (lpHostList);
1623 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1627 void Task_Svr_Monitor_OnOff (LPTASKPACKET ptp)
1629 LPIDENT lpiServer = (LPIDENT)(ptp->lpUser);
1632 if ((lpServer = lpiServer->OpenServer()) != NULL)
1634 BOOL fMonitored = lpServer->fIsMonitored();
1636 g.sub = Subsets_SetMonitor (g.sub, lpiServer, !fMonitored);
1638 lpServer->SetMonitor (!fMonitored);
1645 void Task_Svr_ChangeAddr (LPTASKPACKET ptp)
1647 LPSVR_CHANGEADDR_PARAMS lpp = (LPSVR_CHANGEADDR_PARAMS)(ptp->lpUser);
1649 if ((ptp->rc = AfsClass_ChangeAddress (lpp->lpiServer, &lpp->ssOld, &lpp->ssNew, &ptp->status)) == FALSE)
1651 TCHAR szName[ cchRESOURCE ];
1652 lpp->lpiServer->GetServerName (szName);
1653 ErrorDialog (ptp->status, IDS_ERROR_CANT_CHANGEADDR, TEXT("%s"), szName);
1657 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1661 void Task_Svc_Menu (LPTASKPACKET ptp)
1663 TASKDATA(ptp)->mt = *(LPMENUTASK)(ptp->lpUser);
1664 Delete ((LPMENUTASK)(ptp->lpUser));
1665 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
1667 if (TASKDATA(ptp)->mt.lpi && TASKDATA(ptp)->mt.lpi->fIsService())
1669 LPSERVICE lpService;
1670 if ((lpService = TASKDATA(ptp)->mt.lpi->OpenService (&ptp->status)) == NULL)
1674 if (!lpService->GetStatus (&TASKDATA(ptp)->cs, FALSE, &ptp->status))
1682 void Task_Svc_Prop_Init (LPTASKPACKET ptp)
1684 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1686 LPSERVICE lpService;
1687 if ((lpService = lpi->OpenService (&ptp->status)) == NULL)
1691 if (!lpService->GetStatus (&TASKDATA(ptp)->cs, TRUE, &ptp->status))
1695 else if ((TASKDATA(ptp)->lpcp = (LPSERVICE_PREF)lpi->GetUserParam()) == NULL)
1698 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1705 if ((TASKDATA(ptp)->lpsp = (LPSERVER_PREF)lpi->GetServer()->GetUserParam()) == NULL)
1708 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1714 void Task_Svc_Prop_Apply (LPTASKPACKET ptp)
1716 LPSVC_PROP_APPLY_PACKET lpp = (LPSVC_PROP_APPLY_PACKET)(ptp->lpUser);
1718 LPSERVICE lpService;
1719 if ((lpService = lpp->lpi->OpenService (&ptp->status)) == NULL)
1723 LPSERVICE_PREF lpcp = NULL;
1724 if ((lpcp = (LPSERVICE_PREF)lpp->lpi->GetUserParam()) == NULL)
1727 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1732 if ((lpiServer = lpp->lpi->GetServer()) != NULL)
1735 if ((lpsp = (LPSERVER_PREF)lpiServer->GetUserParam()) != NULL)
1737 if (lpsp->fWarnSvcStop)
1738 lpcp->fWarnSvcStop = lpp->fIDC_SVC_WARNSTOP;
1742 if (!Services_SavePreferences (lpp->lpi))
1745 ptp->status = GetLastError();
1752 (void)Alert_Scout_QueueCheckServer (lpp->lpi);
1755 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1759 void Task_Svc_Start (LPTASKPACKET ptp)
1761 LPSVC_START_PARAMS lpp = (LPSVC_START_PARAMS)(ptp->lpUser);
1763 if (!AfsClass_StartService (lpp->lpiStart, lpp->fTemporary, &ptp->status))
1766 if (!ptp->rc && !ptp->hReply)
1768 TCHAR szSvrName[ cchRESOURCE ];
1769 TCHAR szSvcName[ cchRESOURCE ];
1770 lpp->lpiStart->GetServerName (szSvrName);
1771 lpp->lpiStart->GetServiceName (szSvcName);
1772 ErrorDialog (ptp->status, IDS_ERROR_CANT_START_SERVICE, TEXT("%s%s"), szSvrName, szSvcName);
1776 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1780 void Task_Svc_Stop (LPTASKPACKET ptp)
1782 LPSVC_STOP_PARAMS lpp = (LPSVC_STOP_PARAMS)(ptp->lpUser);
1784 if (!AfsClass_StopService (lpp->lpiStop, lpp->fTemporary, TRUE, &ptp->status))
1787 if (!ptp->rc && !ptp->hReply)
1789 TCHAR szSvrName[ cchRESOURCE ];
1790 TCHAR szSvcName[ cchRESOURCE ];
1791 lpp->lpiStop->GetServerName (szSvrName);
1792 lpp->lpiStop->GetServiceName (szSvcName);
1793 ErrorDialog (ptp->status, IDS_ERROR_CANT_STOP_SERVICE, TEXT("%s%s"), szSvrName, szSvcName);
1797 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1801 void Task_Svc_Restart (LPTASKPACKET ptp)
1803 LPIDENT lpiService = (LPIDENT)(ptp->lpUser);
1805 if (!AfsClass_RestartService (lpiService, &ptp->status))
1808 if (!ptp->rc && !ptp->hReply)
1810 TCHAR szSvrName[ cchRESOURCE ];
1811 TCHAR szSvcName[ cchRESOURCE ];
1812 lpiService->GetServerName (szSvrName);
1813 lpiService->GetServiceName (szSvcName);
1814 ErrorDialog (ptp->status, IDS_ERROR_CANT_RESTART_SERVICE, TEXT("%s%s"), szSvrName, szSvcName);
1819 void Task_Svc_FindLog (LPTASKPACKET ptp)
1821 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1823 if ((TASKDATA(ptp)->lpcp = (LPSERVICE_PREF)lpi->GetUserParam()) == NULL)
1826 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1831 if (TASKDATA(ptp)->lpcp->szLogFile[0] == TEXT('\0'))
1834 ptp->status = ERROR_FILE_NOT_FOUND;
1840 if ((TASKDATA(ptp)->pszText1 = CloneString (TASKDATA(ptp)->lpcp->szLogFile)) == NULL)
1843 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1849 void Task_Svc_ViewLog (LPTASKPACKET ptp)
1851 LPSVC_VIEWLOG_PACKET lpp = (LPSVC_VIEWLOG_PACKET)(ptp->lpUser);
1853 TCHAR szTempPath[ MAX_PATH ];
1854 GetTempPath (MAX_PATH, szTempPath);
1856 TCHAR szFilename[ MAX_PATH ];
1857 GetTempFileName (szTempPath, TEXT("log"), 0, szFilename);
1859 if (!AfsClass_GetServerLogFile (lpp->lpiServer, szFilename, lpp->szRemote, &ptp->status))
1861 DeleteFile (szFilename);
1867 if ((TASKDATA(ptp)->pszText1 = CloneString (szFilename)) == NULL)
1870 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1875 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1879 void Task_Svc_Create (LPTASKPACKET ptp)
1881 LPSVC_CREATE_PARAMS lpp = (LPSVC_CREATE_PARAMS)(ptp->lpUser);
1884 if ((lpiService = AfsClass_CreateService (lpp->lpiServer, lpp->szService, lpp->szCommand, lpp->szParams, lpp->szNotifier, lpp->type, &lpp->stIfCron, &ptp->status)) == NULL)
1891 // Start it if necessary
1893 if ((lpp->type == SERVICETYPE_SIMPLE) && (lpp->fRunNow))
1895 if (!AfsClass_StartService (lpiService, FALSE, &ptp->status))
1902 if (ptp->rc && lpp->szLogFile[0])
1904 LPSERVICE_PREF lpsp;
1905 if ((lpsp = (LPSERVICE_PREF)lpiService->GetUserParam()) != NULL)
1907 lstrcpy (lpsp->szLogFile, lpp->szLogFile);
1909 if (!Services_SavePreferences (lpiService))
1912 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
1919 TCHAR szServer[ cchNAME ];
1920 lpp->lpiServer->GetServerName (szServer);
1921 ErrorDialog (ptp->status, IDS_ERROR_CANT_CREATE_SERVICE, TEXT("%s%s"), szServer, lpp->szService);
1925 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1929 void Task_Svc_Delete (LPTASKPACKET ptp)
1931 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1933 ptp->rc = AfsClass_DeleteService (lpi, &ptp->status);
1937 TCHAR szServer[ cchNAME ];
1938 TCHAR szService[ cchNAME ];
1939 lpi->GetServerName (szServer);
1940 lpi->GetServiceName (szService);
1941 ErrorDialog (ptp->status, IDS_ERROR_CANT_DELETE_SERVICE, TEXT("%s%s"), szServer, szService);
1946 void Task_Svc_GetRestartTimes (LPTASKPACKET ptp)
1948 LPSVC_RESTARTTIMES_PARAMS lpp = (LPSVC_RESTARTTIMES_PARAMS)(ptp->lpUser);
1950 ptp->rc = AfsClass_GetRestartTimes (lpp->lpi, &lpp->fGeneral, &lpp->stGeneral, &lpp->fNewBinary, &lpp->stNewBinary, &ptp->status);
1954 lpp->fGeneral = FALSE;
1955 lpp->fNewBinary = FALSE;
1957 TCHAR szSvrName[ cchNAME ];
1958 lpp->lpi->GetServerName (szSvrName);
1959 ErrorDialog (ptp->status, IDS_ERROR_REFRESH_SERVICE_STATUS, TEXT("%s%s"), szSvrName, TEXT("BOS"));
1965 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1970 void Task_Svc_SetRestartTimes (LPTASKPACKET ptp)
1972 LPSVC_RESTARTTIMES_PARAMS lpp = (LPSVC_RESTARTTIMES_PARAMS)(ptp->lpUser);
1974 ptp->rc = AfsClass_SetRestartTimes (lpp->lpi, ((lpp->fGeneral) ? &lpp->stGeneral : NULL), ((lpp->fNewBinary) ? &lpp->stNewBinary : NULL), &ptp->status);
1978 TCHAR szSvrName[ cchNAME ];
1979 lpp->lpi->GetServerName (szSvrName);
1980 ErrorDialog (ptp->status, IDS_ERROR_CANT_SET_RESTART_TIMES, TEXT("%s"), szSvrName);
1986 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
1991 void Task_Agg_Prop_Init (LPTASKPACKET ptp)
1993 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
1995 LPAGGREGATE lpAggregate;
1996 if ((lpAggregate = lpi->OpenAggregate (&ptp->status)) == NULL)
2000 if (!lpAggregate->GetStatus (&TASKDATA(ptp)->as, TRUE, &ptp->status))
2005 if ((TASKDATA(ptp)->lpap = (LPAGGREGATE_PREF)lpAggregate->GetUserParam()) == NULL)
2007 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2011 TCHAR szText[ cchRESOURCE ];
2012 lpAggregate->GetDevice (szText);
2013 TASKDATA(ptp)->pszText1 = CloneString (szText);
2017 TASKDATA(ptp)->nFilesets = 0;
2020 for (LPFILESET lpFileset = lpAggregate->FilesetFindFirst (&hEnum); lpFileset; lpFileset = lpAggregate->FilesetFindNext (&hEnum))
2022 (TASKDATA(ptp)->nFilesets)++;
2027 lpAggregate->Close();
2032 if ((TASKDATA(ptp)->lpsp = (LPSERVER_PREF)lpi->GetServer()->GetUserParam()) == NULL)
2034 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2041 void Task_Agg_Prop_Apply (LPTASKPACKET ptp)
2043 LPAGG_PROP_APPLY_PACKET lpp = (LPAGG_PROP_APPLY_PACKET)(ptp->lpUser);
2045 LPAGGREGATE_PREF lpap;
2046 if ((lpap = (LPAGGREGATE_PREF)lpp->lpi->GetAggregate()->GetUserParam()) == NULL)
2048 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2054 if ((lpiServer = lpp->lpi->GetServer()) != NULL)
2057 if ((lpsp = (LPSERVER_PREF)lpiServer->GetUserParam()) != NULL)
2059 if (lpsp->fWarnAggAlloc)
2060 lpap->fWarnAggAlloc = lpp->fIDC_AGG_WARNALLOC;
2064 if (!lpp->fIDC_AGG_WARN)
2065 lpap->perWarnAggFull = 0;
2066 else if (lpp->fIDC_AGG_WARN_AGGFULL_DEF)
2067 lpap->perWarnAggFull = -1;
2069 lpap->perWarnAggFull = lpp->wIDC_AGG_WARN_AGGFULL_PERCENT;
2071 if (!Aggregates_SavePreferences (lpp->lpi))
2073 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2077 (void)Alert_Scout_QueueCheckServer (lpp->lpi);
2081 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2085 void Task_Agg_Find_Quota_Limits (LPTASKPACKET ptp)
2087 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2089 TASKDATA(ptp)->ckMin = ckQUOTA_MINIMUM;
2090 TASKDATA(ptp)->ckMax = ckQUOTA_MAXIMUM;
2092 if (lpi && (lpi->fIsAggregate() || lpi->fIsFileset()))
2094 LPAGGREGATE lpAggregate;
2095 if ((lpAggregate = lpi->OpenAggregate (&ptp->status)) == NULL)
2100 if (!lpAggregate->GetStatus (&as, TRUE, &ptp->status))
2104 TASKDATA(ptp)->ckMax = max( 1L, as.ckStorageTotal );
2106 lpAggregate->Close();
2112 void Task_Agg_Enum_To_ListView (LPTASKPACKET ptp)
2114 LPAGG_ENUM_TO_LISTVIEW_PACKET lpp = (LPAGG_ENUM_TO_LISTVIEW_PACKET)(ptp->lpUser);
2116 UpdateDisplay_Aggregates (TRUE, lpp->hList, NULL, 0, lpp->lpiServer, lpp->lpiSelect, lpp->lpvi);
2119 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2123 void Task_Agg_Enum_To_ComboBox (LPTASKPACKET ptp)
2125 LPAGG_ENUM_TO_COMBOBOX_PACKET lpp = (LPAGG_ENUM_TO_COMBOBOX_PACKET)(ptp->lpUser);
2127 UpdateDisplay_Aggregates (TRUE, lpp->hCombo, NULL, 0, lpp->lpiServer, lpp->lpiSelect, NULL);
2130 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2134 void Task_Agg_Find_Ghost (LPTASKPACKET ptp)
2136 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2138 LPAGGREGATE lpAggregate;
2139 if ((lpAggregate = lpi->OpenAggregate (&ptp->status)) == NULL)
2143 TASKDATA(ptp)->wGhost = lpAggregate->GetGhostStatus();
2144 lpAggregate->Close();
2149 void Task_Set_Enum_To_ComboBox (LPTASKPACKET ptp)
2151 LPSET_ENUM_TO_COMBOBOX_PACKET lpp = (LPSET_ENUM_TO_COMBOBOX_PACKET)(ptp->lpUser);
2153 UpdateDisplay_Filesets (TRUE, lpp->hCombo, NULL, 0, lpp->lpiServer, lpp->lpiAggregate, lpp->lpiSelect);
2156 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2160 void Task_Set_Find_Ghost (LPTASKPACKET ptp)
2162 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2164 LPFILESET lpFileset;
2165 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2169 TASKDATA(ptp)->wGhost = lpFileset->GetGhostStatus();
2170 TASKDATA(ptp)->fHasReplicas = FALSE;
2172 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs))
2174 TASKDATA(ptp)->fs.Type = ftREADWRITE;
2176 else if (TASKDATA(ptp)->fs.Type == ftREADWRITE)
2179 for (LPIDENT lpiSearch = IDENT::FindFirst (&hEnum, &TASKDATA(ptp)->fs.idReplica); lpiSearch; lpiSearch = IDENT::FindNext (&hEnum))
2181 LPFILESET lpReplica;
2182 if ((lpReplica = lpiSearch->OpenFileset()) != NULL)
2185 TASKDATA(ptp)->fHasReplicas = TRUE;
2189 IDENT::FindClose (&hEnum);
2197 void Task_Set_Create (LPTASKPACKET ptp)
2199 LPSET_CREATE_PARAMS lpp = (LPSET_CREATE_PARAMS)(ptp->lpUser);
2202 if ((lpiFileset = AfsClass_CreateFileset (lpp->lpiParent, lpp->szName, lpp->ckQuota, &ptp->status)) == NULL)
2205 if (ptp->rc && lpp->fCreateClone)
2207 ptp->rc = AfsClass_Clone (lpiFileset, &ptp->status);
2212 TASKDATA(ptp)->lpi = lpiFileset;
2216 TCHAR szServer[ cchNAME ];
2217 TCHAR szAggregate[ cchNAME ];
2218 lpp->lpiParent->GetServerName (szServer);
2219 lpp->lpiParent->GetAggregateName (szAggregate);
2220 ErrorDialog (ptp->status, IDS_ERROR_CANT_CREATE_FILESET, TEXT("%s%s%s"), szServer, szAggregate, lpp->szName);
2224 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2228 void Task_Set_Delete (LPTASKPACKET ptp)
2230 LPSET_DELETE_PARAMS lpp = (LPSET_DELETE_PARAMS)(ptp->lpUser);
2232 // First, what kind of fileset are we deleting here?
2234 LPIDENT lpiClone = NULL;
2235 FILESETTYPE setType = ftREADWRITE;
2236 LPFILESET lpFileset;
2237 if ((lpFileset = lpp->lpiFileset->OpenFileset (&ptp->status)) == NULL)
2241 lpiClone = lpFileset->GetCloneIdentifier();
2243 if (lpFileset->GetStatus (&TASKDATA(ptp)->fs))
2244 setType = TASKDATA(ptp)->fs.Type;
2249 // Delete the fileset in whichever way is appropriate
2251 if (setType == ftREADWRITE)
2253 if (lpp->fVLDB && lpiClone)
2256 if ((lpClone = lpiClone->OpenFileset()) != NULL) // clone really there?
2260 if (!AfsClass_DeleteClone (lpiClone, &ptp->status))
2266 if (!AfsClass_DeleteFileset (lpp->lpiFileset, lpp->fVLDB, lpp->fServer, &ptp->status))
2270 else if (setType == ftREPLICA)
2272 if (!AfsClass_DeleteReplica (lpp->lpiFileset, &ptp->status))
2275 else if (setType == ftCLONE)
2277 if (!AfsClass_DeleteClone (lpp->lpiFileset, &ptp->status))
2284 (!lpp->fVLDB && (lpp->wGhost & GHOST_HAS_VLDB_ENTRY)) ||
2285 (!lpp->fServer && (lpp->wGhost & GHOST_HAS_SERVER_ENTRY)) )
2287 Alert_Scout_QueueCheckServer (lpp->lpiFileset->GetServer());
2292 TCHAR szServer[ cchNAME ];
2293 TCHAR szAggregate[ cchNAME ];
2294 TCHAR szFileset[ cchNAME ];
2295 lpp->lpiFileset->GetServerName (szServer);
2296 lpp->lpiFileset->GetAggregateName (szAggregate);
2297 lpp->lpiFileset->GetFilesetName (szFileset);
2298 ErrorDialog (ptp->status, IDS_ERROR_CANT_DELETE_FILESET, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2302 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2306 void Task_Set_Move (LPTASKPACKET ptp)
2308 LPSET_MOVE_PARAMS lpp = (LPSET_MOVE_PARAMS)(ptp->lpUser);
2310 BOOL fIsReplica = FALSE;
2312 LPFILESET lpFileset;
2313 if ((lpFileset = lpp->lpiSource->OpenFileset (&ptp->status)) == NULL)
2318 if (!lpFileset->GetStatus (&fs, TRUE, &ptp->status))
2322 if (fs.Type == ftREPLICA)
2332 if (!AfsClass_MoveReplica (lpp->lpiSource, lpp->lpiTarget, &ptp->status))
2337 if (!AfsClass_MoveFileset (lpp->lpiSource, lpp->lpiTarget, &ptp->status))
2344 TCHAR szServerSource[ cchNAME ];
2345 TCHAR szServerTarget[ cchNAME ];
2346 TCHAR szAggregateSource[ cchNAME ];
2347 TCHAR szAggregateTarget[ cchNAME ];
2348 TCHAR szFileset[ cchNAME ];
2349 lpp->lpiSource->GetServerName (szServerSource);
2350 lpp->lpiSource->GetAggregateName (szAggregateSource);
2351 lpp->lpiSource->GetFilesetName (szFileset);
2352 lpp->lpiTarget->GetServerName (szServerTarget);
2353 lpp->lpiTarget->GetAggregateName (szAggregateTarget);
2354 ErrorDialog (ptp->status, IDS_ERROR_MOVE_FILESET, TEXT("%s%s%s%s%s"), szServerSource, szAggregateSource, szFileset, szServerTarget, szAggregateTarget);
2358 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2362 void Task_Set_MoveTo_Init (LPTASKPACKET ptp)
2364 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2366 LPFILESET lpFileset;
2367 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2371 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2378 void Task_Set_Prop_Init (LPTASKPACKET ptp)
2380 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2382 LPFILESET lpFileset;
2383 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2387 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2389 else if ((TASKDATA(ptp)->lpfp = (LPFILESET_PREF)lpFileset->GetUserParam()) == NULL)
2392 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2399 if ((TASKDATA(ptp)->lpsp = (LPSERVER_PREF)lpi->GetServer()->GetUserParam()) == NULL)
2402 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2408 void Task_Set_Prop_Apply (LPTASKPACKET ptp)
2410 LPSET_PROP_APPLY_PARAMS lpp = (LPSET_PROP_APPLY_PARAMS)(ptp->lpUser);
2412 LPFILESET_PREF lpfp = NULL;
2413 if ((lpfp = (LPFILESET_PREF)lpp->lpi->GetUserParam()) == NULL)
2416 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2420 if (!lpp->fIDC_SET_WARN)
2421 lpfp->perWarnSetFull = 0;
2422 else if (lpp->fIDC_SET_WARN_SETFULL_DEF)
2423 lpfp->perWarnSetFull = -1;
2425 lpfp->perWarnSetFull = lpp->wIDC_SET_WARN_SETFULL_PERCENT;
2427 if (!Filesets_SavePreferences (lpp->lpi))
2430 ptp->status = ERROR_NOT_ENOUGH_MEMORY;
2434 Alert_Scout_QueueCheckServer (lpp->lpi);
2437 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2441 void Task_Set_SetQuota_Init (LPTASKPACKET ptp)
2443 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2445 LPFILESET lpFileset;
2446 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2450 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2458 Task_Agg_Find_Quota_Limits (ptp);
2463 void Task_Set_SetQuota_Apply (LPTASKPACKET ptp)
2465 LPSET_SETQUOTA_APPLY_PARAMS lpp = (LPSET_SETQUOTA_APPLY_PARAMS)(ptp->lpUser);
2467 if (!AfsClass_SetFilesetQuota (lpp->lpiFileset, lpp->ckQuota, &ptp->status))
2472 TCHAR szServer[ cchNAME ];
2473 TCHAR szAggregate[ cchNAME ];
2474 TCHAR szFileset[ cchNAME ];
2475 lpp->lpiFileset->GetServerName (szServer);
2476 lpp->lpiFileset->GetAggregateName (szAggregate);
2477 lpp->lpiFileset->GetFilesetName (szFileset);
2478 ErrorDialog (ptp->status, IDS_ERROR_CANT_SET_FILESET_QUOTA, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2482 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2486 void Task_Set_RepProp_Init (LPTASKPACKET ptp)
2488 LPSET_REPPROP_INIT_PARAMS lpp = (LPSET_REPPROP_INIT_PARAMS)(ptp->lpUser);
2490 LPFILESET lpFileset;
2491 if ((lpFileset = lpp->lpiReq->OpenFileset (&ptp->status)) == NULL)
2495 if ((lpp->lpiRW = lpFileset->GetReadWriteIdentifier (&ptp->status)) == NULL)
2497 else if (!lpFileset->GetStatus (&lpp->fs, TRUE, &ptp->status))
2502 // don't delete this packet (ptp->lpUser)! the caller will free it.
2506 void Task_Set_Select (LPTASKPACKET ptp)
2508 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2510 LPFILESET lpFileset;
2511 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2515 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2523 void Task_Set_BeginDrag (LPTASKPACKET ptp)
2525 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2527 LPFILESET lpFileset;
2528 if ((lpFileset = lpi->OpenFileset (&ptp->status)) == NULL)
2532 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2539 void Task_Set_DragMenu (LPTASKPACKET ptp)
2541 TASKDATA(ptp)->mt = *(LPMENUTASK)(ptp->lpUser);
2542 Delete ((LPMENUTASK)(ptp->lpUser));
2543 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2545 if (TASKDATA(ptp)->mt.lpi && TASKDATA(ptp)->mt.lpi->fIsFileset())
2547 LPFILESET lpFileset;
2548 if ((lpFileset = TASKDATA(ptp)->mt.lpi->OpenFileset (&ptp->status)) == NULL)
2552 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2560 void Task_Set_Menu (LPTASKPACKET ptp)
2562 TASKDATA(ptp)->mt = *(LPMENUTASK)(ptp->lpUser);
2563 Delete ((LPMENUTASK)(ptp->lpUser));
2564 ptp->lpUser = NULL; // we deleted this; don't let the caller use it again.
2566 if (TASKDATA(ptp)->mt.lpi && TASKDATA(ptp)->mt.lpi->fIsFileset())
2568 LPFILESET lpFileset;
2569 if ((lpFileset = TASKDATA(ptp)->mt.lpi->OpenFileset (&ptp->status)) == NULL)
2573 if (!lpFileset->GetStatus (&TASKDATA(ptp)->fs, TRUE, &ptp->status))
2582 void Task_Set_Lock (LPTASKPACKET ptp)
2584 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2585 ptp->rc = AfsClass_LockFileset (lpi, &ptp->status);
2589 void Task_Set_Unlock (LPTASKPACKET ptp)
2591 LPIDENT lpi = (LPIDENT)(ptp->lpUser);
2593 if (lpi->fIsFileset())
2594 ptp->rc = AfsClass_UnlockFileset (lpi, &ptp->status);
2596 ptp->rc = AfsClass_UnlockAllFilesets (lpi, &ptp->status);
2600 void Task_Set_CreateRep (LPTASKPACKET ptp)
2602 LPSET_CREATEREP_PARAMS lpp = (LPSET_CREATEREP_PARAMS)(ptp->lpUser);
2605 if ((lpiReplica = AfsClass_CreateReplica (lpp->lpiSource, lpp->lpiTarget, &ptp->status)) == NULL)
2610 TASKDATA(ptp)->lpi = lpiReplica;
2614 TCHAR szServer[ cchNAME ];
2615 TCHAR szAggregate[ cchNAME ];
2616 TCHAR szFileset[ cchNAME ];
2617 lpp->lpiTarget->GetServerName (szServer);
2618 lpp->lpiTarget->GetAggregateName (szAggregate);
2619 lpp->lpiSource->GetFilesetName (szFileset);
2620 ErrorDialog (ptp->status, IDS_ERROR_CANT_CREATE_REPLICA, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2624 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2628 void Task_Set_Rename_Init (LPTASKPACKET ptp)
2630 LPSET_RENAME_INIT_PARAMS lpp = (LPSET_RENAME_INIT_PARAMS)(ptp->lpUser);
2632 LPFILESET lpFileset;
2633 if ((lpFileset = lpp->lpiReq->OpenFileset (&ptp->status)) == NULL)
2637 if ((lpp->lpiRW = lpFileset->GetReadWriteIdentifier (&ptp->status)) == NULL)
2642 // don't delete this packet (ptp->lpUser)! the caller will free it.
2646 void Task_Set_Rename_Apply (LPTASKPACKET ptp)
2648 LPSET_RENAME_APPLY_PARAMS lpp = (LPSET_RENAME_APPLY_PARAMS)(ptp->lpUser);
2650 ptp->rc = AfsClass_RenameFileset (lpp->lpiFileset, lpp->szNewName, &ptp->status);
2654 TCHAR szFileset[ cchNAME ];
2655 lpp->lpiFileset->GetFilesetName (szFileset);
2656 ErrorDialog (ptp->status, IDS_ERROR_CANT_RENAME_FILESET, TEXT("%s%s"), szFileset, lpp->szNewName);
2660 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2664 void Task_Set_Release (LPTASKPACKET ptp)
2666 LPSET_RELEASE_PARAMS lpp = (LPSET_RELEASE_PARAMS)(ptp->lpUser);
2668 ptp->rc = AfsClass_ReleaseFileset (lpp->lpiRW, lpp->fForce, &ptp->status);
2672 TCHAR szServer[ cchNAME ];
2673 TCHAR szAggregate[ cchNAME ];
2674 TCHAR szFileset[ cchNAME ];
2675 lpp->lpiRW->GetServerName (szServer);
2676 lpp->lpiRW->GetAggregateName (szAggregate);
2677 lpp->lpiRW->GetFilesetName (szFileset);
2678 ErrorDialog (ptp->status, IDS_ERROR_CANT_RELEASE_FILESET, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2682 ptp->lpUser = 0; // we freed this; don't let anyone use it.
2686 void Task_Set_Clone (LPTASKPACKET ptp)
2688 LPIDENT lpiRW = (LPIDENT)(ptp->lpUser);
2690 ptp->rc = AfsClass_Clone (lpiRW, &ptp->status);
2694 TCHAR szServer[ cchNAME ];
2695 TCHAR szAggregate[ cchNAME ];
2696 TCHAR szFileset[ cchNAME ];
2697 lpiRW->GetServerName (szServer);
2698 lpiRW->GetAggregateName (szAggregate);
2699 lpiRW->GetFilesetName (szFileset);
2700 ErrorDialog (ptp->status, IDS_ERROR_CANT_CLONE, TEXT("%s%s%s"), szServer, szAggregate, szFileset);
2705 void Task_Set_Clonesys (LPTASKPACKET ptp)
2707 LPSET_CLONESYS_PARAMS lpp = (LPSET_CLONESYS_PARAMS)(ptp->lpUser);
2709 LPTSTR pszPrefix = (lpp->fUsePrefix) ? lpp->szPrefix : NULL;
2710 if (!AfsClass_CloneMultiple (lpp->lpi, pszPrefix, lpp->fExcludePrefix, &ptp->status))
2713 if (!ptp->rc && !IsWindow (ptp->hReply))
2715 ErrorDialog (ptp->status, IDS_ERROR_CANT_CLONESYS);
2719 ptp->lpUser = 0; // we freed this; don't let anyone use it.
2723 void Task_Set_Dump (LPTASKPACKET ptp)
2725 LPSET_DUMP_PARAMS lpp = (LPSET_DUMP_PARAMS)(ptp->lpUser);
2727 ptp->rc = AfsClass_DumpFileset (lpp->lpi, lpp->szFilename,
2728 (lpp->fDumpByDate) ? &lpp->stDump : NULL,
2733 TCHAR szServer[ cchNAME ];
2734 TCHAR szAggregate[ cchNAME ];
2735 TCHAR szFileset[ cchNAME ];
2736 lpp->lpi->GetServerName (szServer);
2737 lpp->lpi->GetAggregateName (szAggregate);
2738 lpp->lpi->GetFilesetName (szFileset);
2739 ErrorDialog (ptp->status, IDS_ERROR_CANT_DUMP_FILESET, TEXT("%s%s%s%s"), szServer, szAggregate, szFileset, lpp->szFilename);
2743 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2747 void Task_Set_Restore (LPTASKPACKET ptp)
2749 LPSET_RESTORE_PARAMS lpp = (LPSET_RESTORE_PARAMS)(ptp->lpUser);
2751 ptp->rc = AfsClass_RestoreFileset (lpp->lpi, lpp->szFileset, lpp->szFilename, lpp->fIncremental, &ptp->status);
2755 TCHAR szServer[ cchNAME ];
2756 TCHAR szAggregate[ cchNAME ];
2757 lpp->lpi->GetServerName (szServer);
2758 lpp->lpi->GetAggregateName (szAggregate);
2759 ErrorDialog (ptp->status, IDS_ERROR_CANT_RESTORE_FILESET, TEXT("%s%s%s%s"), szServer, szAggregate, lpp->szFileset, lpp->szFilename);
2763 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2767 void Task_Set_Lookup (LPTASKPACKET ptp)
2769 LPSET_LOOKUP_PACKET lpp = (LPSET_LOOKUP_PACKET)(ptp->lpUser);
2771 if ((TASKDATA(ptp)->lpi = IDENT::FindFileset (g.lpiCell, lpp->szFileset)) != NULL)
2773 LPFILESET lpFileset;
2774 if ((lpFileset = TASKDATA(ptp)->lpi->OpenFileset()) == NULL)
2775 TASKDATA(ptp)->lpi = NULL; // fileset was probably deleted earlier
2781 ptp->lpUser = NULL; // deleted this, so don't let the caller use it.
2785 void Task_Expired_Creds (LPTASKPACKET ptp)
2789 CheckForExpiredCredentials();