示例#1
0
// SERVICE START ROUTINE - thread that calls WinVNCAppMain
void ServiceWorkThread(void *arg)
{
	// Save the current thread identifier
	g_servicethread = GetCurrentThreadId();

    // report the status to the service control manager.
    //
    if (!ReportStatus(
        SERVICE_RUNNING,       // service state
        NO_ERROR,              // exit code
        0))                    // wait hint
		return;

	// RUN!
	WinVNCAppMain();

	// Mark that we're no longer running
	g_servicethread = NULL;

	// Tell the service manager that we've stopped.
    ReportStatus(
		SERVICE_STOPPED,
		g_error,
		0);
}
示例#2
0
// SERVICE MAIN ROUTINE
void WINAPI ServiceMain(DWORD argc, char**argv)
{
	// Register the service control handler
    g_hstatus = RegisterServiceCtrlHandler(VNCSERVICENAME, ServiceCtrl);

    if (g_hstatus == 0)
		return;

	// Set up some standard service state values
    g_srvstatus.dwServiceType = SERVICE_WIN32 | SERVICE_INTERACTIVE_PROCESS;
    g_srvstatus.dwServiceSpecificExitCode = 0;

	// Give this status to the SCM
    if (!ReportStatus(
        SERVICE_START_PENDING,	// Service state
        NO_ERROR,				// Exit code type
        15000))					// Hint as to how long WinVNC should have hung before you assume error
	{
        ReportStatus(
			SERVICE_STOPPED,
			g_error,
            0);
		return;
	}

	// Now start the service for real
    omni_thread *workthread = omni_thread::create(ServiceWorkThread);
    return;
}
示例#3
0
void * ReportRestoreStatus(void * ReportMsg)
{
	int persent = 0;
	int Oldpersent = 0;
	int OriginalUsedSize = ((PReStatus)ReportMsg)->OriginalUsedSize;
	int totalSize = ((PReStatus)ReportMsg)->totalsize;
	int CurrentUsdSize = 0;
	ReportStatus("restoring", 0, 0, 0);
	//GetUsbStorage("/data", &OriginalUsedSize, 2);
	while(1)
	{
		sleep(2);
		GetUsbStorage("/data", &CurrentUsdSize, 2);
		if(OriginalUsedSize < CurrentUsdSize)
		{
			persent = ((CurrentUsdSize - OriginalUsedSize) * 100)/totalSize;
			if(persent > 100) persent = 100;
			if(persent > Oldpersent)
			{
				ReportStatus("restoring", CurrentUsdSize - OriginalUsedSize, totalSize, persent);//report the backuping status
				Oldpersent = persent;
			}
		}
	}
	return 0;
}
示例#4
0
void CWinService::Run(DWORD argc, LPTSTR * argv)
{
    ReportStatus(SERVICE_START_PENDING);

    if (!m_pCSysServiceContext->OnRun())
    {
        return;
    }

    ReportStatus(SERVICE_RUNNING);

    MSG Msg = {0};

    //消息循环
    while (WaitForSingleObject(m_hStopEvent, 10) != WAIT_OBJECT_0) 
    {
        if(PeekMessage(&Msg , NULL, 0, 0,  PM_REMOVE))
        {
            TranslateMessage(&Msg); 
            DispatchMessage(&Msg);
        }
    }
    
    ReportStatus(SERVICE_STOP_PENDING, WIN_SERVICE_STOP_PENDING_WAIT_TIME);
    
    m_pCSysServiceContext->OnStop();
    
    ReportStatus(SERVICE_STOPPED);
}
示例#5
0
void WindowsService::RegisterAndRun(DWORD argc, LPTSTR *argv)
{
  statusHandle= ::RegisterServiceCtrlHandler(serviceName, ControlHandler);
  if (statusHandle && ReportStatus(SERVICE_START_PENDING))
    Run(argc, argv);
  ReportStatus(SERVICE_STOPPED);
}
示例#6
0
	void MyserviceSecond::Run()
	{
		ReportStatus(SERVICE_START_PENDING, 2000);

		std::fstream file;
		file.open("C:\\Test1.txt", std::fstream::out | std::fstream::app);

		ReportStatus(SERVICE_RUNNING);

		while(GetFlag() != STOP)
		{
			if(GetFlag() != PAUSE)
			{
				file << "This is some test data to write to the file" << std::endl;
				::Sleep(2000);
			}
			else
			{
				ReportStatus(SERVICE_PAUSED);
				Lock lock(m_mutexNotify);
				m_cond.wait(lock);

				if(GetFlag() != STOP)
				{
					ReportStatus(SERVICE_RUNNING);
				}
			}
		}

		file.close();
		ReportStatus(SERVICE_STOPPED);
	}
// ---------------------------------------------------------
// CT_LbsTestPsy5RequestHandler::SetTPositionInfo
// 
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CT_LbsTestPsy5RequestHandler::SetTPositionInfo(TPositionInfo& aInfo, const TBool& /*aUseCache*/)
	{
	++iRequests;

	if(iRequests==1)
		{
		ReportStatus(
					TPositionModuleStatus::EDeviceInitialising, 
					TPositionModuleStatus::EDataQualityUnknown
					);
		ReportStatus(
					TPositionModuleStatus::EDeviceReady, 
					TPositionModuleStatus::EDataQualityUnknown
					);
		ReportStatus(
					TPositionModuleStatus::EDeviceActive, 
					TPositionModuleStatus::EDataQualityLoss
					);
		
		CT_LbsTestPsyBase::SetTPositionInfo(aInfo);

		ReportStatus(
					TPositionModuleStatus::EDeviceReady, 
					TPositionModuleStatus::EDataQualityUnknown
					);
		}
    else
		{
		CT_LbsTestPsyBase::SetTPositionInfo(aInfo);
		}
	}
示例#8
0
VOID WINAPI controlHandler(DWORD dwCtrlCode)
{

  switch(dwCtrlCode)
    {

    case SERVICE_CONTROL_STOP:
      // Request to stop the service. Report SERVICE_STOP_PENDING
      // to the service control manager before calling ServiceStop()
      // to avoid a "Service did not respond" error.
      ReportStatus(SERVICE_STOP_PENDING, NO_ERROR, 0);
      ServiceStop();
      return;


    case SERVICE_CONTROL_INTERROGATE:
      // This case MUST be processed, even though we are not
      // obligated to do anything substantial in the process.
      break;

    default:
      // Any other cases...
      break;

    }

  // After invocation of this function, we MUST call the SetServiceStatus
  // function, which is accomplished through our ReportStatus function. We
  // must do this even if the current status has not changed.
  ReportStatus(ssStatus.dwCurrentState, NO_ERROR, 0);
}
示例#9
0
//
//  FUNCTION: BOINCServiceMain
//
//  PURPOSE: To perform actual initialization of the service
//
//  PARAMETERS:
//    dwArgc   - number of command line arguments
//    lpszArgv - array of command line arguments
//
//  RETURN VALUE:
//    none
//
//  COMMENTS:
//    This routine performs the service initialization and then calls
//    the user defined main() routine to perform majority
//    of the work.
//
void WINAPI BOINCServiceMain(DWORD /*dwArgc*/, LPTSTR * /*lpszArgv*/) {
    // SERVICE_STATUS members that don't change in example
    //
    ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
    ssStatus.dwControlsAccepted = SERVICE_ACCEPTED_ACTIONS;
    ssStatus.dwServiceSpecificExitCode = 0;


    // register our service control handler:
    //
    sshStatusHandle = RegisterServiceCtrlHandler( TEXT(SZSERVICENAME), BOINCServiceCtrl);
    if (!sshStatusHandle)
        goto cleanup;

    if (!ReportStatus(
        SERVICE_RUNNING,       // service state
        ERROR_SUCCESS,         // exit code
        0))                    // wait hint
        goto cleanup;

    dwErr = boinc_main_loop();

cleanup:

    // try to report the stopped status to the service control manager.
    //
    if (sshStatusHandle) {
        (VOID)ReportStatus(
            SERVICE_STOPPED,
            dwErr,
            0
        );
    }
}
示例#10
0
// The ServiceMain function is the entry point for the service.
void WINAPI serviceMain(DWORD dwArgc, LPTSTR *lpszArgv)
{
  TCHAR szAppParameters[8192];
  LONG lLen = 8192;
  LPTSTR *lpszNewArgv = NULL;
  DWORD dwNewArgc;
  UINT i;
  char szParamKey[1025];

  sprintf(szParamKey,"SYSTEM\\CurrentControlSet\\Services\\%s\\Parameters", lpszArgv[0]);
  // Call RegisterServiceCtrlHandler immediately to register a service control
  // handler function. The returned SERVICE_STATUS_HANDLE is saved with global
  // scope, and used as a service id in calls to SetServiceStatus.
  sshStatusHandle = RegisterServiceCtrlHandler( TEXT(SZSERVICENAME), controlHandler);
  if (!sshStatusHandle)
    goto finally;

  // The global ssStatus SERVICE_STATUS structure contains information about the
  // service, and is used throughout the program in calls made to SetStatus through
  // the ReportStatus function.
  ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
  ssStatus.dwServiceSpecificExitCode = 0;

  // If we could guarantee that all initialization would occur in less than one
  // second, we would not have to report our status to the service control manager.
  // For good measure, we will assign SERVICE_START_PENDING to the current service
  // state and inform the service control manager through our ReportStatus function.
  if (!ReportStatus(SERVICE_START_PENDING, NO_ERROR, 3000))
    goto finally;
  // When we installed this service, we probably saved a list of runtime args
  // in the registry as a subkey of the key for this service. We'll try to get
  // it here...
  if(0 != getStringValue(szAppParameters,(LPDWORD)&lLen, HKEY_LOCAL_MACHINE, szParamKey, SZAPPPARAMS)){
    dwNewArgc = 0;
    lpszNewArgv = NULL;
  } else {
    //If we have an argument string, convert it to a list of argc/argv type...
    lpszNewArgv = convertArgStringToArgList(lpszNewArgv, &dwNewArgc, szAppParameters);
  }
  // Do it! In ServiceStart, we'll send additional status reports to the
  // service control manager, especially the SERVICE_RUNNING report once
  // our JVM is initiallized and ready to be invoked.
  ServiceStart(dwNewArgc, lpszNewArgv);

  // Release the allocated storage used by our arg list. Java programmers
  // might remember this kind of stuff.
  for(i=0; i<dwNewArgc; i++){
    GlobalFree((HGLOBAL)lpszNewArgv[i]);
  }
  if(dwNewArgc > 0)
    GlobalFree((HGLOBAL)lpszNewArgv);
 finally:
  // Report the stopped status to the service control manager, if we have
  // a valid server status handle.
  if (sshStatusHandle)
    (VOID)ReportStatus( SERVICE_STOPPED, dwErr, 0);
}
示例#11
0
void CReloadService::Continue() {
	ReportStatus(SERVICE_CONTINUE_PENDING);

	// TODO: add additional "continue" code here

	if(m_hContinue)
		::SetEvent(m_hContinue);

	ReportStatus(SERVICE_RUNNING);
}
示例#12
0
void CReloadService::Pause() {
	ReportStatus(SERVICE_PAUSE_PENDING);

	if(m_hPause)
		::SetEvent(m_hPause);

	// TODO: add additional "pause" code here

	ReportStatus(SERVICE_PAUSED);
}
示例#13
0
VOID ServiceStart (DWORD dwArgc, LPTSTR *lpszArgv)
{
  pthread_t lprobeThread;
  TCHAR szAppParameters[8192];

  // Let the service control manager know that the service is
  // initializing.
  if (!ReportStatus(SERVICE_START_PENDING,
		    NO_ERROR,
		    3000))
    //goto cleanup;
    return;


  // Create a Stop Event
  hServerStopEvent = CreateEvent(
				 NULL,
				 TRUE,
				 FALSE,
				 NULL);


  if ( hServerStopEvent == NULL)
    goto cleanup;

  if(dwArgc > 0)
    _dwArgc = dwArgc, _lpszArgv = lpszArgv;
  else {
    char *progName = SZSERVICENAME;
    _dwArgc = 1, _lpszArgv = &progName;
  }

  if (!ReportStatus(SERVICE_RUNNING,NO_ERROR,0)){
    goto cleanup;
  }

  // createThread(&lprobeThread, invokelprobe, NULL);
  // J. R. Duarte: Create an argument string from the argument list
  convertArgListToArgString((LPTSTR)szAppParameters,0, dwArgc, lpszArgv);
  if(NULL == szAppParameters){
    _tprintf(TEXT("Could not create AppParameters string.\n"));
  }

  AddToMessageLog(TEXT("About to start lprobe"));
  pthread_create(&lprobeThread, NULL, invokelprobe, (void*)strdup(szAppParameters));
  AddToMessageLog(TEXT("lprobe started"));

  // Wait for the stop event to be signalled.
  WaitForSingleObject(hServerStopEvent,INFINITE);
  AddToMessageLog(TEXT("lprobe terminated"));

 cleanup:
  if (hServerStopEvent)
    CloseHandle(hServerStopEvent);
}
示例#14
0
void
HttpRequest::FetchGravatarForEmail()
{
    unsigned char ehash[MD5LEN];

    {
        char email[1024];
        DWORD d;
        size_t len;

        if (WideCharToMultiByte(CP_UTF8, 0, m_target.c_str(), -1,
                                email, sizeof(email), NULL, NULL) == 0) {
            ReportStatus(KHERR_ERROR,
                         L"Can't convert email address to UTF-8",
                         L"%s", GetLastErrorString().c_str());
            return;
        }

        _strlwr_s(email, sizeof(email));

        if (FAILED(StringCbLengthA(email, sizeof(email), &len))) {
            ReportStatus(KHERR_ERROR,
                         L"UTF-8 email address too long",
                         L"The email address can't be longer than 1024 characters");
            return;
        }

        d = sizeof(ehash);
        if (KHM_FAILED(hash_data((BYTE *) email, (DWORD)len, CALG_MD5, (BYTE *) ehash, &d))) {
            ReportStatus(KHERR_ERROR, L"Failed to hash email address", NULL);
            return;
        }
    }

    {
        wchar_t resource[60];
        wchar_t * tail;
        size_t len;
        int i;
        static const wchar_t hexdigits[] = L"0123456789abcdef";

        StringCbCopyEx(resource, sizeof(resource), L"/avatar/", &tail, &len, STRSAFE_NO_TRUNCATION);

        for (i = 0; i < sizeof(ehash); i++) {
            *tail++ = hexdigits[ehash[i] >> 4];
            *tail++ = hexdigits[ehash[i] & 0xf];
            len -= sizeof(wchar_t) * 2;
        }
        *tail++ = L'\0';

        StringCbCat(resource, sizeof(resource), L".jpg?d=404&s=128");

        FetchResource(L"www.gravatar.com", resource, jpg_mimetypes);
    }
}
示例#15
0
void WINAPI CSerialServerService::ServiceMain( DWORD dwArgc, LPTSTR* lpszArgv ) 
{
	ReportStatus(SERVICE_RUNNING);
	COysterSerialServerApp* pApp = (COysterSerialServerApp*)AfxGetApp();
	TCHAR* pSerialBuffer = new TCHAR(pApp->m_dwSocketBuffer);

	//Report to the event log that the service has started successfully
	m_EventLogSource.Report(EVENTLOG_INFORMATION_TYPE, m_sDisplayName);

	//The tight loop which constitutes the service
	m_bWantStop = FALSE;
	m_bPaused = FALSE;
	LONG bOldPause = m_bPaused;
	while (!m_bWantStop)
	{
		Sleep(500);
		//SCM has requested a Pause / Continue
		if (m_bPaused != bOldPause)
		{
			if (m_bPaused)
			{
				ReportStatus(SERVICE_PAUSED);

				//Report to the event log that the service has paused successfully
				m_EventLogSource.Report(EVENTLOG_INFORMATION_TYPE, m_sDisplayName);
			}
			else
			{
				ReportStatus(SERVICE_RUNNING);

				//Report to the event log that the service has stopped continued
				m_EventLogSource.Report(EVENTLOG_INFORMATION_TYPE, m_sDisplayName);
			}
		}

		bOldPause = m_bPaused;
		if (!m_bPaused)
		{
			if (pApp->m_pSerialPort->BytesWaiting())
			{
				DWORD dwRead = pApp->m_pSerialPort->Read(pSerialBuffer,pApp->m_dwSocketBuffer);
				//pApp->m_pSerialPort->ClearReadBuffer();
				if (dwRead > 0)
				{
					pApp->m_pSocket->Send(pSerialBuffer,dwRead);
				}
			}
		}
	}

	//Report to the event log that the service has stopped successfully
	m_EventLogSource.Report(EVENTLOG_INFORMATION_TYPE, m_sDisplayName);
}
示例#16
0
// ignore parameters in this sample service
void CSpacService :: Run(DWORD, LPTSTR *) {
	if (g_SingleInstanceObj.IsAnotherInstanceRunning()){
		utils_error("Another PMCSpac Daemon instance is already running.\n");
		return;
	}
	
	// report to the SCM that we're about to start
	utils_trace("Starting PMC Serial Port Access Coordinator Version 1.0...\n");
	ReportStatus(SERVICE_START_PENDING);
	
	m_hStop = ::CreateEvent(0, FALSE, FALSE, 0);
	SECURITY_ATTRIBUTES sd;
	ZeroMemory(&sd, sizeof(sd));
	sd.nLength = sizeof(sd);
	m_hRestart = ::CreateEvent(&sd, FALSE, FALSE, SPAC_RESET_EVENT);
	HANDLE handles[2];
	handles[0] = m_hStop;
	handles[1] = m_hRestart;
	// You might do some more initialization here.
	// Parameter processing for instance ...
	utils_trace("PMC Serial Port Access Coordinator Version 1.0 started...\n");
	init();
	// enter main-loop
	// If the Stop() method sets the event, then we will break out of
	// this loop.
	// report SERVICE_RUNNING immediately before you enter the main-loop
	// DON'T FORGET THIS!
	ReportStatus(SERVICE_RUNNING);	
	bool bStop = false;
	while(!bStop){
		switch(MsgWaitForMultipleObjects(2,handles,false,INFINITE,QS_ALLEVENTS) ){
		case WAIT_OBJECT_0:
			bStop = true;
			break;
		case WAIT_OBJECT_0 + 1:
			_restart();
			break;
		case WAIT_OBJECT_0 + 2:
			MSG msg;
			while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){
				TranslateMessage(&msg);
				DispatchMessage(&msg);
				break;
			}
		}
	}
	if( m_hStop )	::CloseHandle(m_hStop);
	uninit();
	ReportStatus(SERVICE_STOPPED);
}
示例#17
0
	bool ServiceStatus::ReportUltimateStatus()
	{
		DWORD dwUltimateState = 0;
		switch(dwCurrentState)
		{
		case SERVICE_CONTINUE_PENDING:
		case SERVICE_START_PENDING:
			dwUltimateState = SERVICE_RUNNING;
			break;
		case SERVICE_PAUSE_PENDING:
			dwUltimateState = SERVICE_PAUSED;
			break;
		case SERVICE_STOP_PENDING:
			dwUltimateState = SERVICE_STOPPED;
			break;
		}
		dwCheckPoint = dwWaitHint = 0;
		bool flag = false;

		if (dwUltimateState != 0) 
		{
			dwCurrentState = dwUltimateState;
			flag = ReportStatus();
		}
		return flag;
	}
示例#18
0
// Service control routine
void WINAPI ServiceCtrl(DWORD ctrlcode)
{
	// What control code have we been sent?
    switch(ctrlcode)
    {

	case SERVICE_CONTROL_STOP:
		// STOP : The service must stop
		g_srvstatus.dwCurrentState = SERVICE_STOP_PENDING;
        ServiceStop();
        break;

    case SERVICE_CONTROL_INTERROGATE:
		// QUERY : Service control manager just wants to know our state
		break;

	default:
		// Control code not recognised
		break;

    }

	// Tell the control manager what we're up to.
    ReportStatus(g_srvstatus.dwCurrentState, NO_ERROR, 0);
}
BOOL DFServiceStatus::ReportUltimateState()
{
    DWORD dwUltimateState = 0;

    switch(dwCurrentState)
    {
    case SERVICE_START_PENDING:
    case SERVICE_CONTINUE_PENDING:
        dwUltimateState = SERVICE_RUNNING;
        break;
    case SERVICE_STOP_PENDING:
        dwUltimateState = SERVICE_STOPPED;
        break;
    case SERVICE_PAUSE_PENDING:
        dwUltimateState = SERVICE_PAUSED;
        break;
    }

    dwCheckPoint = dwWaitHint = 0;

    dwWin32ExitCode = NO_ERROR;
    dwServiceSpecificExitCode = 0;

    BOOL bRet = FALSE;
    if(dwUltimateState != 0)
    {
        dwCurrentState = dwUltimateState;
        bRet = ReportStatus();

        m_Gate.LiftGate();
    }

    return bRet;
}
示例#20
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_sim_EnterPUK
(
    pa_sim_PukType_t   type, ///< [IN] puk type
    const pa_sim_Puk_t puk,  ///< [IN] PUK code
    const pa_sim_Pin_t pin   ///< [IN] new PIN code
)
{
    atcmdsync_ResultRef_t  resRef = NULL;
    char atcommand[ATCOMMAND_SIZE] ;

    atcmdsync_PrepareString(atcommand,ATCOMMAND_SIZE,"at+cpin=%s,%s",puk,pin);

    le_result_t result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                                atcommand,
                                                &resRef,
                                                NULL,
                                                30000);

    if ( result != LE_OK ) {
        le_mem_Release(resRef);
        return result;
    }

    le_sim_States_t simState=LE_SIM_STATE_UNKNOWN;
    char* line = atcmdsync_GetLine(resRef,0);
    if (CheckStatus(line,&simState))
    {
        ReportStatus(NumCard,simState);
    }

    le_mem_Release(resRef); // release atcmdsync_SendCommandDefault
    return LE_OK;
}
示例#21
0
	bool ServiceStatus::SetUltimateStatus(DWORD dwUltimateState, DWORD dwWaitHint)
	{
		DWORD dwPendingState = 0;
		switch(dwUltimateState)
		{
		case SERVICE_RUNNING:
			dwPendingState = (dwCurrentState == SERVICE_PAUSED) 
				? SERVICE_CONTINUE_PENDING : SERVICE_START_PENDING;
			break;
		case SERVICE_PAUSED:
			dwPendingState = SERVICE_PAUSE_PENDING;
			break;
		case SERVICE_STOPPED:
			dwPendingState = SERVICE_STOP_PENDING;
			break;
		}

		dwCheckPoint = 1;
		this->dwWaitHint = dwWaitHint;
		bool flag = false;
		if(dwPendingState)
		{
			dwCurrentState = dwPendingState;
			flag = (dwWaitHint != 0) ? ReportStatus() : ReportUltimateStatus();
		}
		return flag;
	}
示例#22
0
void WindowsService::HandleControlCode(DWORD opcode)
{
  // Handle the requested control code.
  switch(opcode) {
  case SERVICE_CONTROL_STOP:
    // Stop the service.
    status.dwCurrentState= SERVICE_STOP_PENDING;
    Stop();
    break;

  case SERVICE_CONTROL_PAUSE:
    status.dwCurrentState= SERVICE_PAUSE_PENDING;
    Pause();
    break;

  case SERVICE_CONTROL_CONTINUE:
    status.dwCurrentState= SERVICE_CONTINUE_PENDING;
    Continue();
    break;

  case SERVICE_CONTROL_SHUTDOWN:
    Shutdown();
    break;

  case SERVICE_CONTROL_INTERROGATE:
    ReportStatus(status.dwCurrentState);
    break;

  default:
    // invalid control code
    break;
  }
}
// --------------------------------------------------------------------------
// StartMessageManager
//
/// Start the received message processing thread and the device monitoring 
/// thread used by the message manager to send messages to and recieve
/// messages from a device.
///
/// @returns bool - true if the MessageManager started successfully.
// --------------------------------------------------------------------------
bool MessageManager::StartMessageManager()
{
    // start the received message process thread
    m_hProcessThread = 
        ::CreateThread(NULL,0,StartProcessThread,NULL,0,NULL);

    // report if error starting the monitor thread
    if (m_hProcessThread == NULL)
    {
        m_hProcessThread = INVALID_HANDLE_VALUE;
        std::stringstream stream;
        stream << _T("Error: Unable to start received message process thread.") << std::endl
               << std::endl;
        ReportStatus(stream.str(),ST_ERROR);
        return false;
    }

    // start monitoring for removable network adapters
    if(!DeviceMonitor::GetInstance().StartDeviceMonitor())
    {
        return false;
    }

    m_isStarted = true;
    return true;
}
// Destructor
CT_LbsTestPsy5RequestHandler::~CT_LbsTestPsy5RequestHandler()
    {
	 ReportStatus(
				TPositionModuleStatus::EDeviceInactive, 
				TPositionModuleStatus::EDataQualityUnknown
				);
	}
示例#25
0
static void OnWakeup()
{
	Dbg_PrintS("Status\n\r");

	HW_LED_ON();
	ReportStatus();
	HW_LED_OFF();
}
示例#26
0
khm_int32
HttpRequest::ExecuteRequest()
{
    AutoRef<HttpRequest> ref(this, RefCount::TakeOwnership);

    if (!SetTempPath()) {
        ReportStatus(KHERR_ERROR, L"Can't get temporary path",
                     L"The location for temporary files could not be determined.");
        ReportComplete(false);
        return KHM_ERROR_GENERAL;
    }

    std::wstring old_temp_path(m_path);

    switch (m_method) {
    case ByURL:
        FetchImageFromURL();
        break;

    case ByFavIcon:
        FetchFaviconForDomain();
        break;

    case ByGravatar:
        FetchGravatarForEmail();
        break;

    default:
        ReportStatus(KHERR_ERROR, L"Unknown method",
                     L"Internal error.  Method ID=%d", m_method);
    }

    if (old_temp_path != m_path && !old_temp_path.empty())
        DeleteFile(old_temp_path.c_str());

    if (!m_path.empty())
        DeleteFile(m_path.c_str());

    ReportComplete(false);      // Only one completion report goes
                                // through.  If the request succeeded,
                                // then that notification would have
                                // already been sent.

    return KHM_ERROR_SUCCESS;
}
示例#27
0
//--------------------------------------------------------------------------------------------------
static void SIMUnsolHandler(void* reportPtr) {
    atmgr_UnsolResponse_t* unsolPtr = reportPtr;
    le_sim_States_t simState=LE_SIM_STATE_UNKNOWN;

    if (CheckStatus(unsolPtr->line,&simState))
    {
        ReportStatus(NumCard,simState);
    }
}
示例#28
0
//--------------------------------------------------------------------------------
CNTService::~CNTService()
	{
	AFX_MANAGE_STATE_IF_DLL

	ReportStatus(SERVICE_STOPPED);

	g_this = NULL;
	delete[] LPBYTE(m_pUserSID);
	}
示例#29
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_sim_GetIMSI
(
    pa_sim_Imsi_t imsi   ///< [OUT] IMSI value
)
{
    le_result_t result;
    atcmdsync_ResultRef_t  resRef = NULL;
    // IMSI start with 0|1|2|3|4|5|6|7|8|9
    const char* interRespPtr[] = {"0","1","2","3","4","5","6","7","8","9",NULL};

    if (!imsi)
    {
        LE_DEBUG("One parameter is NULL");
        return LE_BAD_PARAMETER;
    }

    result = atcmdsync_SendStandard(atports_GetInterface(ATPORT_COMMAND),
                                    "at+cimi",
                                    &resRef,
                                    interRespPtr,
                                    30000);

    if ( result != LE_OK ) {
        le_mem_Release(resRef);
        return result;
    }

    le_sim_States_t simState=LE_SIM_STATE_UNKNOWN;
    char* line = atcmdsync_GetLine(resRef,0);
    if (CheckStatus(line,&simState))
    {
        ReportStatus(NumCard,simState);
    }

    // If there is more than one line then it mean that the command is OK so the first line is
    // the intermediate one
    if (atcmdsync_GetNumLines(resRef) == 2)
    {
        line = atcmdsync_GetLine(resRef,0);
        // copy just the first line because of '\0'
        atcmd_CopyStringWithoutQuote(imsi,
                                   line,
                                   strlen(line));

        result = LE_OK;
    }
    // it is not expected
    else {
        LE_WARN("this pattern is not expected");
        result=LE_NOT_POSSIBLE;
    }

    le_mem_Release(resRef);     // Release atcmdsync_SendCommandDefaultExt

    return result;
}
BOOL DFServiceStatus::AdvanceState(DWORD dwWaitHintArg, DWORD dwCheckPointArg)
{
    dwCheckPoint = (dwCheckPointArg == 0) ? dwCheckPoint + 1 : dwCheckPoint;
    dwWaitHint = dwWaitHintArg;

    dwWin32ExitCode = NO_ERROR;
    dwServiceSpecificExitCode = 0;

    return (ReportStatus());
}