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 <afsconfig.h>
15 #include <afs/param.h>
20 #include <WINNT/afsclass.h>
25 * DEFINITIONS ________________________________________________________________
29 #define cREALLOC_NOTIFY 4 // allocate space for 4 notifies at once
33 * VARIABLES __________________________________________________________________
37 size_t NOTIFYCALLBACK::nNotifyList = 0;
38 LPNOTIFYCALLBACK *NOTIFYCALLBACK::aNotifyList = NULL;
42 * PROTOTYPES _________________________________________________________________
48 * ROUTINES ___________________________________________________________________
52 NOTIFYCALLBACK::NOTIFYCALLBACK (NOTIFYCALLBACKPROC procUser, LPARAM lpUser)
54 procSupplied = procUser;
58 for (iNotify = 0; iNotify < nNotifyList; ++iNotify)
60 if (aNotifyList[ iNotify ] == NULL)
64 if (iNotify >= nNotifyList)
66 REALLOC (aNotifyList, nNotifyList, 1+iNotify, cREALLOC_NOTIFY );
69 if (iNotify < nNotifyList)
71 aNotifyList[ iNotify ] = this;
76 NOTIFYCALLBACK::~NOTIFYCALLBACK (void)
78 for (size_t iNotify = 0; iNotify < nNotifyList; ++iNotify)
80 if (aNotifyList[ iNotify ] == this)
81 aNotifyList[ iNotify ] = NULL;
86 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, ULONG status)
88 return SendNotificationToAll (evt, NULL, NULL, NULL, NULL, 0, status);
91 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPIDENT lpi1, ULONG status)
93 return SendNotificationToAll (evt, lpi1, NULL, NULL, NULL, 0, status);
96 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPTSTR psz1, ULONG status)
98 return SendNotificationToAll (evt, NULL, NULL, psz1, NULL, 0, status);
101 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPIDENT lpi1, LPTSTR psz1, ULONG status)
103 return SendNotificationToAll (evt, lpi1, NULL, psz1, NULL, 0, status);
106 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPIDENT lpi1, LPIDENT lpi2, LPTSTR psz1, LPTSTR psz2, DWORD dw1, ULONG status)
111 memset (&Params, 0x00, sizeof(Params));
114 lstrcpy (Params.sz1, (psz1) ? psz1 : TEXT(""));
115 lstrcpy (Params.sz2, (psz2) ? psz2 : TEXT(""));
117 Params.status = status;
119 for (size_t iNotify = 0; iNotify < nNotifyList; ++iNotify)
121 if (aNotifyList[ iNotify ] != NULL)
123 Params.lpUser = aNotifyList[ iNotify ]->lpSupplied;
124 if (!aNotifyList[ iNotify ]->SendNotification (evt, &Params))
133 BOOL NOTIFYCALLBACK::SendNotification (NOTIFYEVENT evt, PNOTIFYPARAMS pParams)
137 if (procSupplied != NULL) {
139 if (!(*procSupplied)( evt, pParams ))
142 // whoops--never trust a callback.