#ifndef __CCALLBACKMGR__
#define __CCALLBACKMGR__
#include <Security/SecKeychainAPI.h>
#include <Security/KCEventObserver.h>
#include <Security/KCEventNotifier.h>
#include <Security/Keychains.h>
#include <list>
namespace Security
{
namespace KeychainCore
{
class CallbackInfo;
class CCallbackMgr;
class CallbackInfo
{
public:
~CallbackInfo();
CallbackInfo();
CallbackInfo(SecKeychainCallbackProcPtr inCallbackFunction,SecKeychainEventMask inEventMask,void *inContext);
bool operator ==(const CallbackInfo& other) const;
bool operator !=(const CallbackInfo& other) const;
SecKeychainCallbackProcPtr mCallback;
SecKeychainEventMask mEventMask;
void *mContext;
};
typedef CallbackInfo *CallbackInfoPtr;
typedef CallbackInfo const *ConstCallbackInfoPtr;
typedef list<CallbackInfo>::iterator CallbackInfoListIterator;
typedef list<CallbackInfo>::const_iterator ConstCallbackInfoListIterator;
#ifdef _CPP_CCALLBACKMGR
# pragma export on
#endif
class CCallbackMgr : Observer
{
public:
CCallbackMgr();
~CCallbackMgr();
static CCallbackMgr& Instance();
static void AddCallback( SecKeychainCallbackProcPtr inCallbackFunction, SecKeychainEventMask inEventMask, void* inContext);
static void RemoveCallback( SecKeychainCallbackProcPtr inCallbackFunction );
static bool HasCallbacks() { return CCallbackMgr::Instance().mEventCallbacks.size() > 0; };
static bool ThisProcessUsesSystemEvtCallback();
static bool ThisProcessCanDisplayUI();
static void AlertClients( SecKeychainEvent inEvent, bool inOKToAllocateMemory);
#if 0
static void Idle();
#endif
private:
virtual void Event ( CFNotificationCenterRef center,
CFStringRef name,
const void* object,
CFDictionaryRef userInfo );
static void AlertClients( SecKeychainEvent inEvent, const Keychain& inKeychain,
const Item &inItem, bool inOKToAllocateMemory = true);
list<CallbackInfo> mEventCallbacks;
static CCallbackMgr* mCCallbackMgr;
};
}
}
#endif // __CCALLBACKMGR__