#include "pcscdserver.h"
#include <mach/mach_error.h>
using namespace Security;
using namespace MachPlusPlus;
namespace PCSCD {
Server::Server(const char *bootstrapName) : MachServer(bootstrapName),
mBootstrapName(bootstrapName)
{
add(sleepWatcher);
}
Server::~Server()
{
}
void Server::run()
{
MachServer::run(0x10000,
MACH_RCV_TRAILER_TYPE(MACH_MSG_TRAILER_FORMAT_0) |
MACH_RCV_TRAILER_ELEMENTS(MACH_RCV_TRAILER_AUDIT));
}
void Server::threadLimitReached(UInt32 limit)
{
}
void Server::notifyDeadName(Port port)
{
StLock<Mutex> _(mLock);
secdebug("SSports", "port %d is dead", port.port());
secdebug("server", "spurious dead port notification for port %d", port.port());
}
void Server::notifyNoSenders(Port port, mach_port_mscount_t)
{
secdebug("SSports", "port %d no senders", port.port());
}
void Server::notifyIfDead(MachPlusPlus::Port port, bool doNotify) const
{
secdebug("SSports", "port %d is dead", port.port());
MachServer::notifyIfDead(port, doNotify);
}
void Server::notifyIfUnused(MachPlusPlus::Port port, bool doNotify) const
{
secdebug("SSports", "port %d is dead", port.port());
MachServer::notifyIfUnused(port, doNotify);
}
void Server::SleepWatcher::systemWillSleep()
{
secdebug("SS", "sleep notification received");
secdebug("server", "distributing sleep event to %ld clients", mPowerClients.size());
for (set<PowerWatcher *>::const_iterator it = mPowerClients.begin(); it != mPowerClients.end(); it++)
(*it)->systemWillSleep();
}
void Server::SleepWatcher::systemIsWaking()
{
secdebug("server", "distributing wakeup event to %ld clients", mPowerClients.size());
for (set<PowerWatcher *>::const_iterator it = mPowerClients.begin(); it != mPowerClients.end(); it++)
(*it)->systemIsWaking();
}
void Server::SleepWatcher::add(PowerWatcher *client)
{
assert(mPowerClients.find(client) == mPowerClients.end());
mPowerClients.insert(client);
}
void Server::SleepWatcher::remove(PowerWatcher *client)
{
assert(mPowerClients.find(client) != mPowerClients.end());
mPowerClients.erase(client);
}
boolean_t Server::handle(mach_msg_header_t *in, mach_msg_header_t *out)
{
secdebug("SSreq", "Server::handle(mach_msg_header_t *in, mach_msg_header_t *out)");
return false;
}
}