#ifndef __ServerControl_h__
#define __ServerControl_h__ 1
#include <mach/port.h>
#define USE_SYSTEMCONFIGURATION_PUBLIC_APIS
#include <SystemConfiguration/SystemConfiguration.h>
#include <SystemConfiguration/SCDynamicStorePrivate.h>
#include "PrivateTypes.h"
#include "DSSemaphore.h"
const uInt32 kMaxHandlerThreads = 4; const uInt32 kMaxCheckpwHandlerThreads = 1; const uInt32 kMaxInternalHandlerThreads = 10;
#define kDSDefaultListenPort 625 //TODO need final port number
class CListener;
class DSTCPListener;
class CHandlerThread;
class CNodeList;
class CPlugInList;
extern CNodeList *gNodeList;
extern CPlugInList *gPlugins;
class ServerControl
{
public:
ServerControl ( void );
virtual ~ServerControl ( void );
virtual sInt32 StartUpServer ( void );
virtual sInt32 ShutDownServer ( void );
sInt32 StartAHandler ( const FourCharCode inThreadSignature );
sInt32 StopAHandler ( const FourCharCode inThreadSignature, uInt32 iThread, CHandlerThread *inThread );
void WakeAHandler ( const FourCharCode inThreadSignature );
void SleepAHandler ( const FourCharCode inThreadSignature, uInt32 waitTime );
uInt32 GetHandlerCount ( const FourCharCode inThreadSignature );
sInt32 StartTCPListener ( uInt32 inPort );
sInt32 StopTCPListener ( void );
sInt32 HandleNetworkTransition
( void );
sInt32 SetUpPeriodicTask ( void );
protected:
sInt32 StartListener ( void );
sInt32 RegisterForSystemPower ( void );
sInt32 UnRegisterForSystemPower ( void );
sInt32 RegisterForNetworkChange ( void );
sInt32 UnRegisterForNetworkChange ( void );
private:
uInt32 fTCPHandlerThreadsCnt;
uInt32 fHandlerThreadsCnt;
uInt32 fInternalHandlerThreadsCnt;
uInt32 fCheckpwHandlerThreadsCnt;
CListener *fListener;
DSTCPListener *fTCPListener;
CHandlerThread *fTCPHandlers[ kMaxHandlerThreads ];
CHandlerThread *fHandlers[ kMaxHandlerThreads ];
CHandlerThread *fInternalHandlers[ kMaxInternalHandlerThreads ];
CHandlerThread *fCheckpwHandlers[ kMaxCheckpwHandlerThreads ];
DSSemaphore *fTCPHandlerSemaphore;
DSSemaphore *fHandlerSemaphore;
DSSemaphore *fInternalHandlerSemaphore;
DSSemaphore *fCheckpwHandlerSemaphore;
SCDynamicStoreRef fSCDStore;
};
extern ServerControl *gSrvrCntl;
#endif