Exemplo n.º 1
0
void
ShareMenu::OnAppControlCompleted(const Osp::Base::String& appControlId, const Osp::Base::String& operationId, const Osp::Base::Collection::IList* pResultList)
{
	Osp::Base::String* pBTResult = null;
	if(appControlId.Equals(APPCONTROL_PROVIDER_BLUETOOTH)
			&& operationId.Equals(APPCONTROL_OPERATION_PICK))
	{
		pBTResult = (Osp::Base::String*)pResultList->GetAt(0);
		if(pBTResult->Equals(String(APPCONTROL_RESULT_SUCCEEDED)))
		{
			BluetoothDevice* pBTDevice = BluetoothDevice::GetInstanceFromAppControlResultN(*pResultList);

			if(pBTDevice)
			{

				if(!__pBTOppClient)
					__pBTOppClient = new BluetoothOppClient();

				result res = E_SUCCESS;
				String filePath(__shareContent);

				if(__isLink == true)
				{

					filePath = L"/Home/";
					filePath.Append(Application::GetInstance()->GetAppName());
					filePath.Append(".txt");

					File tempFile;
					tempFile.Construct(filePath, L"w+", true);
					tempFile.Write(__shareContent);

				}

				__pBTOppClient->Construct(*this);
				res = __pBTOppClient->PushFile(*pBTDevice, filePath);
				if(res != E_SUCCESS)
				{
					AppLog("PushFile FAILED");
				}
			}
			else
			{
				AppLog("No Device from BT AppControl");
			}
		}
		else if(pBTResult->Equals(String(APPCONTROL_RESULT_FAILED)))
		{
			AppLog("Bluetooth list failed.");
		}
	}
}