2 * Copyright (c) 1998-2002 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 * CCallbackMgr.h -- Code that communicates with processes that install a callback
21 * with the Keychain Manager to receive keychain events.
23 #ifndef _SECURITY_CCALLBACKMGR_H_
24 #define _SECURITY_CCALLBACKMGR_H_
26 #include <Security/KCEventObserver.h>
27 #include <Security/KCEventNotifier.h>
28 #include <Security/Keychains.h>
34 namespace KeychainCore
45 CallbackInfo(SecKeychainCallback inCallbackFunction
,SecKeychainEventMask inEventMask
,void *inContext
);
47 bool operator ==(const CallbackInfo
& other
) const;
48 bool operator !=(const CallbackInfo
& other
) const;
50 SecKeychainCallback mCallback
;
51 SecKeychainEventMask mEventMask
;
56 typedef CallbackInfo
*CallbackInfoPtr
;
57 typedef CallbackInfo
const *ConstCallbackInfoPtr
;
59 typedef list
<CallbackInfo
>::iterator CallbackInfoListIterator
;
60 typedef list
<CallbackInfo
>::const_iterator ConstCallbackInfoListIterator
;
63 class CCallbackMgr
: private Observer
70 static CCallbackMgr
& Instance();
72 static void AddCallback( SecKeychainCallback inCallbackFunction
, SecKeychainEventMask inEventMask
, void* inContext
);
73 //static void AddCallbackUPP(KCCallbackUPP inCallbackFunction, KCEventMask inEventMask, void* inContext);
75 static void RemoveCallback( SecKeychainCallback inCallbackFunction
);
76 //static void RemoveCallbackUPP(KCCallbackUPP inCallbackFunction);
77 static bool HasCallbacks()
78 { return CCallbackMgr::Instance().mEventCallbacks
.size() > 0; };
82 void Event (Listener::Domain domain
, Listener::Event whichEvent
, NameValueDictionary
&dictionary
);
84 static void AlertClients(const list
<CallbackInfo
> &eventCallbacks
, SecKeychainEvent inEvent
, pid_t inPid
,
85 const Keychain
& inKeychain
, const Item
&inItem
);
87 list
<CallbackInfo
> mEventCallbacks
;
88 static CCallbackMgr
* mCCallbackMgr
;
91 } // end namespace KeychainCore
93 } // end namespace Security
95 #endif // !_SECURITY_CCALLBACKMGR_H_