6 #include "TaAfsAdmSvrClientInternal.h"
7 #include <WINNT/AfsAppLib.h>
11 * VARIABLES __________________________________________________________________
20 } LISTENER, *LPLISTENER;
24 LPHASHLIST pListeners;
25 LPHASHLISTKEY pListenersKeyObject;
27 HWND *ahActionListeners;
28 size_t chActionListeners;
33 * PROTOTYPES _________________________________________________________________
37 BOOL CALLBACK ListenersKeyObject_Compare (LPHASHLISTKEY pKey, PVOID pObject, PVOID pData);
38 HASHVALUE CALLBACK ListenersKeyObject_HashObject (LPHASHLISTKEY pKey, PVOID pObject);
39 HASHVALUE CALLBACK ListenersKeyObject_HashData (LPHASHLISTKEY pKey, PVOID pData);
43 * ROUTINES ___________________________________________________________________
47 BOOL AddObjectNotification (HWND hNotify, ASID idCell, ASID idObject)
53 l.pListeners = New (HASHLIST);
54 l.pListenersKeyObject = l.pListeners->CreateKey (TEXT("idObject"), ListenersKeyObject_Compare, ListenersKeyObject_HashObject, ListenersKeyObject_HashData);
57 LPLISTENER pl = New (LISTENER);
59 pl->idObject = idObject;
60 pl->hNotify = hNotify;
61 l.pListeners->Add (pl);
68 void ClearObjectNotifications (HWND hNotify)
74 for (LPENUM pEnum = l.pListeners->FindFirst(); pEnum; pEnum = pEnum->FindNext())
76 LPLISTENER pl = (LPLISTENER)( pEnum->GetObject() );
77 if (pl->hNotify == hNotify)
79 l.pListeners->Remove (pl);
89 void TestForNotifications (DWORD idClient, ASID idCell, ASID idObject)
93 // First we'll zip through our list of listeners and
94 // build an ASIDLIST reflecting the objects in this cell
95 // for which we're listening.
97 LPASIDLIST pAsidList = NULL;
98 for (LPENUM pEnum = l.pListeners->FindFirst(); pEnum; pEnum = pEnum->FindNext())
100 LPLISTENER pl = (LPLISTENER)( pEnum->GetObject() );
101 if (pl->idCell != idCell)
103 if (idObject && (pl->idObject != idObject))
108 if (!asc_AsidListCreate (&pAsidList))
111 if (!asc_AsidListAddEntry (&pAsidList, pl->idObject, 0))
115 // Then we'll call one of our cache routines, which in turn will tell
116 // the admin server what version of the properties we have for each
117 // of these objects; if any have newer properties available, we'll
118 // get them back--and that will cause us to send out notifications to
124 (void)RefreshCachedProperties (idClient, idCell, pAsidList, GET_ALL_DATA, &status);
130 void NotifyObjectListeners (ASID idCell, ASID idObject)
132 // If we get here, our cache of information for the specified object
133 // has just been updated. Check for listeners who may be interested
134 // in changes to this object.
138 for (LPENUM pEnum = l.pListenersKeyObject->FindFirst (&idObject); pEnum; pEnum = pEnum->FindNext())
140 LPLISTENER pl = (LPLISTENER)( pEnum->GetObject() );
141 if (pl->idCell != idCell)
144 if (!IsWindow (pl->hNotify))
146 l.pListeners->Remove (pl);
151 PostMessage (pl->hNotify, WM_ASC_NOTIFY_OBJECT, (WPARAM)0, (LPARAM)idObject);
158 * HASHLIST KEYS ______________________________________________________________
162 BOOL CALLBACK ListenersKeyObject_Compare (LPHASHLISTKEY pKey, PVOID pObject, PVOID pData)
164 return (((LPLISTENER)pObject)->idObject == *(ASID*)pData) ? TRUE : FALSE;
167 HASHVALUE CALLBACK ListenersKeyObject_HashObject (LPHASHLISTKEY pKey, PVOID pObject)
169 return ListenersKeyObject_HashData (pKey, &((LPLISTENER)pObject)->idObject);
172 HASHVALUE CALLBACK ListenersKeyObject_HashData (LPHASHLISTKEY pKey, PVOID pData)
174 return (HASHVALUE)*(ASID*)pData;
180 * ACTION NOTIFICATIONS _______________________________________________________
184 BOOL SetActionNotification (HWND hNotify, BOOL fSet)
191 for (size_t ii = 0; ii < l.chActionListeners; ++ii)
193 if (l.ahActionListeners[ ii ] == hNotify)
194 l.ahActionListeners[ ii ] = NULL;
199 for (size_t ii = 0; ii < l.chActionListeners; ++ii)
201 if (l.ahActionListeners[ ii ] == NULL)
204 if (!REALLOC (l.ahActionListeners, l.chActionListeners, 1+ii, 1))
210 l.ahActionListeners[ ii ] = hNotify;
219 void NotifyActionListeners (LPASACTION pAction, BOOL fFinished)
223 for (size_t ii = 0; ii < l.chActionListeners; ++ii)
225 if (IsWindow (l.ahActionListeners[ ii ]))
227 LPASACTION pActionPost = New (ASACTION);
228 memcpy (pActionPost, pAction, sizeof(ASACTION));
229 PostMessage (l.ahActionListeners[ ii ], WM_ASC_NOTIFY_ACTION, (WPARAM)fFinished, (LPARAM)pActionPost);