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>
18 #include <WINNT/afsclass.h>
23 * DEFINITIONS ________________________________________________________________
27 #define cREALLOC_NOTIFY 4 // allocate space for 4 notifies at once
31 * VARIABLES __________________________________________________________________
35 size_t NOTIFYCALLBACK::nNotifyList = 0;
36 LPNOTIFYCALLBACK *NOTIFYCALLBACK::aNotifyList = NULL;
40 * PROTOTYPES _________________________________________________________________
46 * ROUTINES ___________________________________________________________________
50 NOTIFYCALLBACK::NOTIFYCALLBACK (NOTIFYCALLBACKPROC procUser, LPARAM lpUser)
52 procSupplied = procUser;
56 for (iNotify = 0; iNotify < nNotifyList; ++iNotify)
58 if (aNotifyList[ iNotify ] == NULL)
62 if (iNotify >= nNotifyList)
64 REALLOC (aNotifyList, nNotifyList, 1+iNotify, cREALLOC_NOTIFY );
67 if (iNotify < nNotifyList)
69 aNotifyList[ iNotify ] = this;
74 NOTIFYCALLBACK::~NOTIFYCALLBACK (void)
76 for (size_t iNotify = 0; iNotify < nNotifyList; ++iNotify)
78 if (aNotifyList[ iNotify ] == this)
79 aNotifyList[ iNotify ] = NULL;
84 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, ULONG status)
86 return SendNotificationToAll (evt, NULL, NULL, NULL, NULL, 0, status);
89 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPIDENT lpi1, ULONG status)
91 return SendNotificationToAll (evt, lpi1, NULL, NULL, NULL, 0, status);
94 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPTSTR psz1, ULONG status)
96 return SendNotificationToAll (evt, NULL, NULL, psz1, NULL, 0, status);
99 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPIDENT lpi1, LPTSTR psz1, ULONG status)
101 return SendNotificationToAll (evt, lpi1, NULL, psz1, NULL, 0, status);
104 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPIDENT lpi1, LPIDENT lpi2, LPTSTR psz1, LPTSTR psz2, DWORD dw1, ULONG status)
109 memset (&Params, 0x00, sizeof(Params));
112 lstrcpy (Params.sz1, (psz1) ? psz1 : TEXT(""));
113 lstrcpy (Params.sz2, (psz2) ? psz2 : TEXT(""));
115 Params.status = status;
117 for (size_t iNotify = 0; iNotify < nNotifyList; ++iNotify)
119 if (aNotifyList[ iNotify ] != NULL)
121 Params.lpUser = aNotifyList[ iNotify ]->lpSupplied;
122 if (!aNotifyList[ iNotify ]->SendNotification (evt, &Params))
131 BOOL NOTIFYCALLBACK::SendNotification (NOTIFYEVENT evt, PNOTIFYPARAMS pParams)
135 if (procSupplied != NULL) {
137 if (!(*procSupplied)( evt, pParams ))
140 // whoops--never trust a callback.