2 * Copyright (c) 2000-2001 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.
22 Contains: Code that communicates with processes that install a callback
23 with the Keychain Manager to receive keychain events.
25 Written by: Sari Harrison, Craig Mortensen
27 Copyright: © 1998-2000 by Apple Computer, Inc., all rights reserved.
29 Change History (most recent first):
34 #ifndef __CCALLBACKMGR__
35 #define __CCALLBACKMGR__
37 #include <Security/SecKeychainAPI.h>
38 #include <Security/KCEventObserver.h>
39 #include <Security/KCEventNotifier.h>
40 #include <Security/Keychains.h>
46 namespace KeychainCore
57 CallbackInfo(SecKeychainCallbackProcPtr inCallbackFunction
,SecKeychainEventMask inEventMask
,void *inContext
);
59 bool operator ==(const CallbackInfo
& other
) const;
60 bool operator !=(const CallbackInfo
& other
) const;
62 SecKeychainCallbackProcPtr mCallback
;
63 SecKeychainEventMask mEventMask
;
68 typedef CallbackInfo
*CallbackInfoPtr
;
69 typedef CallbackInfo
const *ConstCallbackInfoPtr
;
71 typedef list
<CallbackInfo
>::iterator CallbackInfoListIterator
;
72 typedef list
<CallbackInfo
>::const_iterator ConstCallbackInfoListIterator
;
74 #ifdef _CPP_CCALLBACKMGR
79 class CCallbackMgr
: Observer
86 static CCallbackMgr
& Instance();
88 static void AddCallback( SecKeychainCallbackProcPtr inCallbackFunction
, SecKeychainEventMask inEventMask
, void* inContext
);
89 //static void AddCallbackUPP(KCCallbackUPP inCallbackFunction, KCEventMask inEventMask, void* inContext);
91 static void RemoveCallback( SecKeychainCallbackProcPtr inCallbackFunction
);
92 //static void RemoveCallbackUPP(KCCallbackUPP inCallbackFunction);
93 static bool HasCallbacks() { return CCallbackMgr::Instance().mEventCallbacks
.size() > 0; };
94 static bool ThisProcessUsesSystemEvtCallback();
95 static bool ThisProcessCanDisplayUI();
97 static void AlertClients( SecKeychainEvent inEvent
, bool inOKToAllocateMemory
);
104 virtual void Event ( CFNotificationCenterRef center
,
107 CFDictionaryRef userInfo
);
109 static void AlertClients( SecKeychainEvent inEvent
, const Keychain
& inKeychain
,
110 const Item
&inItem
, bool inOKToAllocateMemory
= true);
112 list
<CallbackInfo
> mEventCallbacks
;
113 static CCallbackMgr
* mCCallbackMgr
;
116 } // end namespace KeychainCore
118 } // end namespace Security
120 #endif // __CCALLBACKMGR__