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>
19 #include <WINNT/afsclass.h>
24 * DEFINITIONS ________________________________________________________________
28 #define cREALLOC_NOTIFY 4 // allocate space for 4 notifies at once
32 * VARIABLES __________________________________________________________________
36 size_t NOTIFYCALLBACK::nNotifyList
= 0;
37 LPNOTIFYCALLBACK
*NOTIFYCALLBACK::aNotifyList
= NULL
;
41 * PROTOTYPES _________________________________________________________________
47 * ROUTINES ___________________________________________________________________
51 NOTIFYCALLBACK::NOTIFYCALLBACK (NOTIFYCALLBACKPROC procUser
, LPARAM lpUser
)
53 procSupplied
= procUser
;
57 for (iNotify
= 0; iNotify
< nNotifyList
; ++iNotify
)
59 if (aNotifyList
[ iNotify
] == NULL
)
63 if (iNotify
>= nNotifyList
)
65 REALLOC (aNotifyList
, nNotifyList
, 1+iNotify
, cREALLOC_NOTIFY
);
68 if (iNotify
< nNotifyList
)
70 aNotifyList
[ iNotify
] = this;
75 NOTIFYCALLBACK::~NOTIFYCALLBACK (void)
77 for (size_t iNotify
= 0; iNotify
< nNotifyList
; ++iNotify
)
79 if (aNotifyList
[ iNotify
] == this)
80 aNotifyList
[ iNotify
] = NULL
;
85 BOOL
NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt
, ULONG status
)
87 return SendNotificationToAll (evt
, NULL
, NULL
, NULL
, NULL
, 0, status
);
90 BOOL
NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt
, LPIDENT lpi1
, ULONG status
)
92 return SendNotificationToAll (evt
, lpi1
, NULL
, NULL
, NULL
, 0, status
);
95 BOOL
NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt
, LPTSTR psz1
, ULONG status
)
97 return SendNotificationToAll (evt
, NULL
, NULL
, psz1
, NULL
, 0, status
);
100 BOOL
NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt
, LPIDENT lpi1
, LPTSTR psz1
, ULONG status
)
102 return SendNotificationToAll (evt
, lpi1
, NULL
, psz1
, NULL
, 0, status
);
105 BOOL
NOTIFYCALLBACK::SendNotificationToAll (NOTIFYEVENT evt
, LPIDENT lpi1
, LPIDENT lpi2
, LPTSTR psz1
, LPTSTR psz2
, DWORD dw1
, ULONG status
)
110 memset (&Params
, 0x00, sizeof(Params
));
113 lstrcpy (Params
.sz1
, (psz1
) ? psz1
: TEXT(""));
114 lstrcpy (Params
.sz2
, (psz2
) ? psz2
: TEXT(""));
116 Params
.status
= status
;
118 for (size_t iNotify
= 0; iNotify
< nNotifyList
; ++iNotify
)
120 if (aNotifyList
[ iNotify
] != NULL
)
122 Params
.lpUser
= aNotifyList
[ iNotify
]->lpSupplied
;
123 if (!aNotifyList
[ iNotify
]->SendNotification (evt
, &Params
))
132 BOOL
NOTIFYCALLBACK::SendNotification (NOTIFYEVENT evt
, PNOTIFYPARAMS pParams
)
136 if (procSupplied
!= NULL
) {
138 if (!(*procSupplied
)( evt
, pParams
))
141 // whoops--never trust a callback.