📄 connectivityinstanceobject.cpp
字号:
/*
Copyright (c) 2008, Intel Corporation.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*///==============================================================================// ConnectivityInstanceObject.cpp // Implementation of the class ConnectivityInstance//==============================================================================#define DllExport //__declspec( dllexport )//#include "../stdafx.h"#include "IntelMobile/Base/base_Exception.h"#include "IntelMobile/Base/base_InstanceObject.h"#include "ConnectivityInstanceObject.h"#include "inc/Base/base_Exception.h"#include "Utility/StringHelper.h"//==============================================================================// C_Tor()//==============================================================================Intel::Mobile::Context::ConnectivityInstance::ConnectivityInstance( void *pImpl ): ContextInstance( pImpl ),IsConnected( *this ),Connected ( Intel::Mobile::Base::Event::eConnected , *this ),Disconnected ( Intel::Mobile::Base::Event::eDisconnected, *this ),IpAddressChanged ( Intel::Mobile::Base::Event::eIpAddressChanged,*this ),RouteTableChanged( Intel::Mobile::Base::Event::eRouteTableChanged, *this ){ if ( m_pImpl != NULL ) { Intel::Mobile::BaseAPI::InstanceObject* pImpl = reinterpret_cast<Intel::Mobile::BaseAPI::InstanceObject*>(m_pImpl); IsConnected.Init( pImpl->GetPropertyByName(IntelMobileText("IsConnected"), IntelMobileText("Bool")) ); }}//==============================================================================// D_Tor()//==============================================================================Intel::Mobile::Context::ConnectivityInstance::~ConnectivityInstance(){ if (m_flag) { if (m_pImpl) { Intel::Mobile::BaseAPI::InstanceObject *pAPI_Instance = reinterpret_cast<Intel::Mobile::BaseAPI::InstanceObject*>(m_pImpl); if (pAPI_Instance) { delete pAPI_Instance; } m_pImpl = NULL; } }}//==============================================================================// GetType()//==============================================================================StringObject Intel::Mobile::Context::ConnectivityInstance::GetType() const{ if (m_pImpl) { Intel::Mobile::BaseAPI::InstanceObject *pAPI_Instance = reinterpret_cast<Intel::Mobile::BaseAPI::InstanceObject*>(m_pImpl); if (pAPI_Instance) { TRYBLOCK { IntelMobileChar* pType = pAPI_Instance->GetType();
Intel::Mobile::Base::StringObject sType( pType );
delete[] pType;
return sType; } CATCHBLOCK } else THROWNE(IntelMobileText("Intel::Mobile::Context::ConnectivityInstance"), IntelMobileText("GetType")); } else THROWNE(IntelMobileText("Intel::Mobile::Context::ConnectivityInstance"), IntelMobileText("GetType"));}//==============================================================================// GetType()//==============================================================================StringObject Intel::Mobile::Context::ConnectivityInstance::GetKey() const{ if (m_pImpl) { Intel::Mobile::BaseAPI::InstanceObject *pAPI_Instance = reinterpret_cast<Intel::Mobile::BaseAPI::InstanceObject*>(m_pImpl); if (pAPI_Instance) { TRYBLOCK {
IntelMobileChar* pKey = pAPI_Instance->GetKey();
Intel::Mobile::Base::StringObject sKey( pKey );
delete[] pKey;
return sKey;
} CATCHBLOCK } else THROWNE(IntelMobileText("Intel::Mobile::Context::ConnectivityInstance"), IntelMobileText("GetKey")); } else THROWNE(IntelMobileText("Intel::Mobile::Context::ConnectivityInstance"), IntelMobileText("GetKey"));}//==============================================================================// IsReachable()//==============================================================================bool Intel::Mobile::Context::ConnectivityInstance::IsReachable( StringObject sUriDestination ){ bool bReachable = false; if (m_pImpl) { Intel::Mobile::BaseAPI::InstanceObject *pAPI_Instance = reinterpret_cast<Intel::Mobile::BaseAPI::InstanceObject *>(m_pImpl); if (pAPI_Instance) { TRYBLOCK { IntelMobileString wsRtn; IntelMobileChar* infoString = pAPI_Instance->InvokeMethod( IntelMobileText("IsReachable"), sUriDestination.GetValue()); wsRtn = infoString; CStringHelper::Str2Param(wsRtn, bReachable); delete []infoString; } CATCHBLOCK } else THROWNE(IntelMobileText("Intel::Mobile::Context::ConnectivityInstance"), IntelMobileText("IsReachable")); } else THROWNE(IntelMobileText("Intel::Mobile::Context::ConnectivityInstance"), IntelMobileText("IsReachable")); return bReachable;} // IsReachable()bool Intel::Mobile::Context::ConnectivityInstance::IsReachable( StringObject sUriDestination, unsigned int sTimeOut, unsigned int sRetryCount){ bool bReachable = false; if (m_pImpl) { Intel::Mobile::BaseAPI::InstanceObject *pAPI_Instance = reinterpret_cast<Intel::Mobile::BaseAPI::InstanceObject *>(m_pImpl); if (pAPI_Instance) { TRYBLOCK { IntelMobileString wsRtn; IntelMobileString wsParams = CStringHelper::Param2Str(sUriDestination.GetValue()); wsParams.append(IntelMobileText(",")); wsParams.append(IntelMobileText("N")); wsParams.append(IntelMobileText(",")); wsParams.append(IntelMobileText("123")); wsParams.append(IntelMobileText(",")); wsParams.append(IntelMobileText("123")); wsParams.append(IntelMobileText(",")); wsParams.append(CStringHelper::Param2Str(sTimeOut)); wsParams.append(IntelMobileText(",")); wsParams.append(CStringHelper::Param2Str(sRetryCount)); IntelMobileChar* infoString = pAPI_Instance->InvokeMethod( IntelMobileText("IsReachableEx"), (IntelMobileChar*)wsParams.c_str()); wsRtn = infoString; CStringHelper::Str2Param(wsRtn, bReachable); delete []infoString; } CATCHBLOCK } else THROWNE(IntelMobileText("Intel::Mobile::Context::ConnectivityInstance"), IntelMobileText("IsReachableEx")); } else THROWNE(IntelMobileText("Intel::Mobile::Context::ConnectivityInstance"), IntelMobileText("IsReachableEx")); return bReachable;} // IsReachable()//==============================================================================// IsReachable() Pass in proxy info. Default timeout values as 1 minute and try only 1 time.//==============================================================================bool Intel::Mobile::Context::ConnectivityInstance::IsReachable( StringObject sUriDestination, StringObject sProxyURL, StringObject sProxyUsername, StringObject sProxyPassword){ bool bReachable = false; if (m_pImpl) { Intel::Mobile::BaseAPI::InstanceObject *pAPI_Instance = reinterpret_cast<Intel::Mobile::BaseAPI::InstanceObject *>(m_pImpl); if (pAPI_Instance) { TRYBLOCK { IntelMobileString wsRtn; IntelMobileString wsParams = CStringHelper::Param2Str(sUriDestination.GetValue()); wsParams.append(IntelMobileText(",")); wsParams.append(CStringHelper::Param2Str(sProxyURL.GetValue())); wsParams.append(IntelMobileText(",")); wsParams.append(CStringHelper::Param2Str(sProxyUsername.GetValue())); wsParams.append(IntelMobileText(",")); wsParams.append(CStringHelper::Param2Str(sProxyPassword.GetValue())); wsParams.append(IntelMobileText(",")); wsParams.append(IntelMobileText("0")); wsParams.append(IntelMobileText(",")); wsParams.append(IntelMobileText("1")); IntelMobileChar* infoString = pAPI_Instance->InvokeMethod( IntelMobileText("IsReachableEx"), (IntelMobileChar*)wsParams.c_str()); wsRtn = infoString; CStringHelper::Str2Param(wsRtn, bReachable); delete []infoString; } CATCHBLOCK } else THROWNE(IntelMobileText("Intel::Mobile::Context::ConnectivityInstance"), IntelMobileText("IsReachableEx")); } else THROWNE(IntelMobileText("Intel::Mobile::Context::ConnectivityInstance"), IntelMobileText("IsReachableEx")); return bReachable;} // IsReachable()//==============================================================================// IsReachable() Pass in proxy and timeout info.//==============================================================================bool Intel::Mobile::Context::ConnectivityInstance::IsReachable( StringObject sUriDestination, StringObject sProxyURL, StringObject sProxyUsername, StringObject sProxyPassword,unsigned int sTimeOut, unsigned int sRetryCount){ bool bReachable = false; if (m_pImpl) { Intel::Mobile::BaseAPI::InstanceObject *pAPI_Instance = reinterpret_cast<Intel::Mobile::BaseAPI::InstanceObject *>(m_pImpl); if (pAPI_Instance) { TRYBLOCK {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -