Esempio n. 1
0
void
InfoForm::GetProduct(int index)
{
	result r = E_SUCCESS;
	String samsungapps;
	// get appId of Samsung Apps
	r = SystemInfo::GetValue("SamsungAppsAppId", samsungapps);
	AppLog("SamsungAppsAppId %s", r);

	ArrayList *pArrayList = new ArrayList();
	pArrayList->Construct();
	String *uri= new String();
	uri->Append(L"samsungapps://ProductDetail/"+*__pProducts[index][0]);
	pArrayList->Add(*uri);

	AppManager *pAppManager = AppManager::GetInstance();
	// Launch Samsung Apps with uri
	pAppManager->LaunchApplication(samsungapps, pArrayList, AppManager::LAUNCH_OPTION_DEFAULT);
}
result VKUServiceProxy::Construct(const AppId& appId, const String& remotePortName) {
	result r = E_FAILURE;

	this->appId = appId;

	AppManager* pAppManager = AppManager::GetInstance();
	TryReturn(pAppManager != null, E_FAILURE, "VKU : Fail to get AppManager instance.");

	AppLog("VKU : Checking service status for time out 5 sec...");

	for (int i = 0; i < 5; ++i) {
		if (pAppManager->IsRunning(appId)) {
			AppLog("VKU : Service is ready");
			break;
		} else {
			AppLog("VKU : Service is not ready. try to launch.");
			r = pAppManager->LaunchApplication(appId, null);
			TryReturn(!IsFailed(r), r, "VKU : [%s]", GetErrorMessage(r));
			Thread::Sleep(CHECK_INTERVAL);
		}
	}

	TryReturn(pAppManager->IsRunning(appId), E_FAILURE, "VKU : The service is not working.");

	pLocalMessagePort = MessagePortManager::RequestLocalMessagePort(LOCAL_MESSAGE_PORT_NAME);
	TryReturn(pLocalMessagePort != null, E_FAILURE, "[E_FAILURE] Failed to get LocalMessagePort instance.");

	pLocalMessagePort->AddMessagePortListener(*this);

	pRemoteMessagePort = MessagePortManager::RequestRemoteMessagePort(appId, remotePortName);
	TryReturn(pRemoteMessagePort != null, E_FAILURE, "[E_FAILURE] Failed to get LocalMessagePort instance.");

	AppLog("LocalMessagePort(\"%ls\") is ready", pLocalMessagePort->GetName().GetPointer());

	// send connect request
	HashMap *pMap =	new HashMap(SingleObjectDeleter);
	pMap->Construct();
	pMap->Add(new String(L"request"), new String(L"connect"));
	r = SendMessage(pMap);
	delete pMap;

	return E_SUCCESS;
}