예제 #1
0
	WebResponse* StartServiceHandler::Execute(WebRequest* pWebRequest, User* pUser)
	{
		Service* pService = NULL;
		ServiceManager* pServiceManager = NULL;		
		StartServiceRequest* pRequest = static_cast<StartServiceRequest*>(pWebRequest);

		g_uint user_id = pUser->GetID();
		const char* name = pRequest->GetName();
		pServiceManager = augeGetServiceManagerInstance();
		pService = pServiceManager->GetService(user_id, name);
		if(pService==NULL)
		{
			char msg[AUGE_MSG_MAX];
			g_sprintf(msg, "%s does not exists.", name);
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(msg);
			return pExpResponse;
		}

		RESULTCODE rc = pServiceManager->Start(user_id, name);
		if(rc!=AG_SUCCESS)
		{
			GError* pError = augeGetErrorInstance();
			WebExceptionResponse* pExpResponse = augeCreateWebExceptionResponse();
			pExpResponse->SetMessage(pError->GetLastError());
			return pExpResponse;
		}

		WebSuccessResponse* pSusResponse = augeCreateWebSuccessResponse();
		pSusResponse->SetRequest("StartService");
		return pSusResponse;
	}
예제 #2
0
void Firewall::Start()
{
    ServiceManager serviceManager;
    serviceManager.Start( serviceManager.GetService("ipfw") );
}