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;
52 for (size_t iNotify = 0; iNotify < nNotifyList; ++iNotify)
54 if (aNotifyList[ iNotify ] == NULL)
58 if (iNotify >= nNotifyList)
60 REALLOC (aNotifyList, nNotifyList, 1+iNotify, cREALLOC_NOTIFY );
63 if (iNotify < nNotifyList)
65 aNotifyList[ iNotify ] = this;
70 NOTIFYCALLBACK::~NOTIFYCALLBACK (void)
72 for (size_t iNotify = 0; iNotify < nNotifyList; ++iNotify)
74 if (aNotifyList[ iNotify ] == this)
75 aNotifyList[ iNotify ] = NULL;
80 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, ULONG status)
82 return SendNotificationToAll (evt, NULL, NULL, NULL, NULL, 0, status);
85 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPIDENT lpi1, ULONG status)
87 return SendNotificationToAll (evt, lpi1, NULL, NULL, NULL, 0, status);
90 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPTSTR psz1, ULONG status)
92 return SendNotificationToAll (evt, NULL, NULL, psz1, NULL, 0, status);
95 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPIDENT lpi1, LPTSTR psz1, ULONG status)
97 return SendNotificationToAll (evt, lpi1, NULL, psz1, NULL, 0, status);
100 BOOL NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt, LPIDENT lpi1, LPIDENT lpi2, LPTSTR psz1, LPTSTR psz2, DWORD dw1, ULONG status)
105 memset (&Params, 0x00, sizeof(Params));
108 lstrcpy (Params.sz1, (psz1) ? psz1 : TEXT(""));
109 lstrcpy (Params.sz2, (psz2) ? psz2 : TEXT(""));
111 Params.status = status;
113 for (size_t iNotify = 0; iNotify < nNotifyList; ++iNotify)
115 if (aNotifyList[ iNotify ] != NULL)
117 Params.lpUser = aNotifyList[ iNotify ]->lpSupplied;
118 if (!aNotifyList[ iNotify ]->SendNotification (evt, &Params))
127 BOOL NOTIFYCALLBACK::SendNotification (NOTIFYEVENT evt, PNOTIFYPARAMS pParams)
131 if (procSupplied != NULL) {
133 if (!(*procSupplied)( evt, pParams ))
136 // whoops--never trust a callback.