#ifndef _SECURITY_CCALLBACKMGR_H_
#define _SECURITY_CCALLBACKMGR_H_
#include <security_keychain/Keychains.h>
#include <security_utilities/cfmach++.h>
#include <securityd_client/ssnotify.h>
#include <securityd_client/dictionary.h>
#include <securityd_client/eventlistener.h>
#include <list>
#include "KCEventNotifier.h"
namespace Security
{
namespace KeychainCore
{
class CallbackInfo;
class CCallbackMgr;
class CallbackInfo
{
public:
~CallbackInfo();
CallbackInfo();
CallbackInfo(SecKeychainCallback inCallbackFunction,SecKeychainEventMask inEventMask,void *inContext);
bool operator ==(const CallbackInfo& other) const;
bool operator !=(const CallbackInfo& other) const;
SecKeychainCallback mCallback;
SecKeychainEventMask mEventMask;
void *mContext;
};
typedef CallbackInfo *CallbackInfoPtr;
typedef CallbackInfo const *ConstCallbackInfoPtr;
typedef list<CallbackInfo>::iterator CallbackInfoListIterator;
typedef list<CallbackInfo>::const_iterator ConstCallbackInfoListIterator;
class CCallbackMgr : public SecurityServer::EventListener
{
public:
CCallbackMgr();
~CCallbackMgr();
static CCallbackMgr& Instance();
static void AddCallback( SecKeychainCallback inCallbackFunction, SecKeychainEventMask inEventMask, void* inContext);
static void RemoveCallback( SecKeychainCallback inCallbackFunction );
static bool HasCallbacks()
{ return CCallbackMgr::Instance().mEventCallbacks.size() > 0; };
private:
void consume (SecurityServer::NotificationDomain domain, SecurityServer::NotificationEvent whichEvent,
const CssmData &data);
static void AlertClients(const list<CallbackInfo> &eventCallbacks, SecKeychainEvent inEvent, pid_t inPid,
const Keychain& inKeychain, const Item &inItem);
list<CallbackInfo> mEventCallbacks;
};
}
}
#endif // !_SECURITY_CCALLBACKMGR_H_