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>
15 #include <WINNT/afsclass.h>
20 * DEFINITIONS ________________________________________________________________
24 #define cREALLOC_NOTIFY 4 // allocate space for 4 notifies at once
28 * VARIABLES __________________________________________________________________
32 size_t NOTIFYCALLBACK::nNotifyList = 0;
33 LPNOTIFYCALLBACK *NOTIFYCALLBACK::aNotifyList = NULL;
37 * PROTOTYPES _________________________________________________________________
43 * ROUTINES ___________________________________________________________________
47 NOTIFYCALLBACK::NOTIFYCALLBACK (NOTIFYCALLBACKPROC procUser, LPARAM lpUser)
49 procSupplied = procUser;
53 for (iNotify = 0; iNotify < nNotifyList; ++iNotify)
55 if (aNotifyList[ iNotify ] == NULL)
59 if (iNotify >= nNotifyList)
61 REALLOC (aNotifyList, nNotifyList, 1+iNotify, cREALLOC_NOTIFY );
64 if (iNotify < nNotifyList)
66 aNotifyList[ iNotify ] = this;
71 NOTIFYCALLBACK::~NOTIFYCALLBACK (void)
73 for (size_t iNotify = 0; iNotify < nNotifyList; ++iNotify)
75 if (aNotifyList[ iNotify ] == this)
76 aNotifyList[ iNotify ] = NULL;
81 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, ULONG status)
83 return SendNotificationToAll (evt, NULL, NULL, NULL, NULL, 0, status);
86 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPIDENT lpi1, ULONG status)
88 return SendNotificationToAll (evt, lpi1, NULL, NULL, NULL, 0, status);
91 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPTSTR psz1, ULONG status)
93 return SendNotificationToAll (evt, NULL, NULL, psz1, NULL, 0, status);
96 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPIDENT lpi1, LPTSTR psz1, ULONG status)
98 return SendNotificationToAll (evt, lpi1, NULL, psz1, NULL, 0, status);
101 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPIDENT lpi1, LPIDENT lpi2, LPTSTR psz1, LPTSTR psz2, DWORD dw1, ULONG status)
106 memset (&Params, 0x00, sizeof(Params));
109 lstrcpy (Params.sz1, (psz1) ? psz1 : TEXT(""));
110 lstrcpy (Params.sz2, (psz2) ? psz2 : TEXT(""));
112 Params.status = status;
114 for (size_t iNotify = 0; iNotify < nNotifyList; ++iNotify)
116 if (aNotifyList[ iNotify ] != NULL)
118 Params.lpUser = aNotifyList[ iNotify ]->lpSupplied;
119 if (!aNotifyList[ iNotify ]->SendNotification (evt, &Params))
128 BOOL NOTIFYCALLBACK::SendNotification (NOTIFYEVENT evt, PNOTIFYPARAMS pParams)
132 if (procSupplied != NULL) {
134 if (!(*procSupplied)( evt, pParams ))
137 // whoops--never trust a callback.