/usr/include/osp/security
/usr/include/osp/net
/usr/include/osp/telephony
+ /usr/include/osp/server
/usr/include/chromium
/usr/include/vconf
/usr/include/appfw
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
+SET(CMAKE_SKIP_BUILD_RPATH FALSE)
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
+SET(CMAKE_INSTALL_RPATH "/usr/lib/osp-server")
+SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
+
## Create Library
ADD_EXECUTABLE (${this_target} ${${this_target}_SOURCE_FILES})
TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker --as-needed -pie)
TARGET_LINK_LIBRARIES(${this_target} -Xlinker --version-script=${CMAKE_CURRENT_SOURCE_DIR}/system-service-export.ver)
TARGET_LINK_LIBRARIES(${this_target} -L/usr/lib/osp -losp-appfw -losp-net -losp-wifi -lchromium -lcapi-network-wifi -lcapi-network-bluetooth -lcapi-network-connection -lcapi-network-nfc -lwifi-direct -lvconf -lcapi-telephony-sim -lSLP-tapi -lecore_x -lcapi-appfw-app-manager)
+TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp-server -losp-appfw-server")
## Cory additional info
INSTALL(TARGETS ${this_target} DESTINATION ../usr/apps/${APPID}/bin)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/manifest.xml DESTINATION ../usr/apps/${APPID}/info)
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data DESTINATION ../usr/apps/${APPID})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${this_target}.rule DESTINATION /etc/smack/accesses2.d)
+
* @class BluetoothConnectivityIpcStub
* @brief This class represents an IPC stub for the Connectivity daemon service.
*
- * @since 2.1
+ * @since 2.0
*
* This class represents an IPC stub for the Connectivity daemon service.
*/
#include <bluetooth.h>
#include <FBaseString.h>
-#include <FApp_IAppManagerEventListener.h>
/**
* @class BluetoothService
* @brief This class represents %Bluetooth service of the Connectivity service daemon.
*
- * @since 2.1
+ * @since 2.0
*
* This class represents %Bluetooth service of the Connectivity service daemon.
*/
class BluetoothService
- : public Tizen::App::_IAppManagerEventListener
{
public:
BluetoothService(void);
result Construct(void);
result GetLocalDeviceName(Tizen::Base::String* pLocalName);
- result SetLocalDeviceName(const Tizen::Base::String& clientAppId, const Tizen::Base::String& localName);
+ result SetLocalDeviceName(const Tizen::Base::String& clientPkgId, const Tizen::Base::String& localName);
result SetDiscoverableMode(int mode, int seconds);
- // From _IAppManagerEventListener;
- virtual void OnApplicationLaunched(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
- virtual void OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
+ // Process application termination cases such that an IPC client is disconnected.
+ void ProcessAppTermination(const Tizen::Base::String& clientPkgId);
+
// Callback used by SLP BT F/W to notify that %Bluetooth is activated on the device.
- static void OnBluetoothAdapterStateChanged(int result, bt_adapter_state_e adapterState, void* pUserData);
+ static void OnBluetoothAdapterStateChanged(int result, bt_adapter_state_e adapterState, void* pUserData);
+
private:
result UpdateLocalDeviceName(const Tizen::Base::String& name);
void OnSetNetAccountId(int netAccountId, int* pNetAccountId2, unsigned long* pResult);
void OnUpdateSystemNetAccount(const Tizen::Base::String& profileName, const Tizen::Net::NetAccountInfo& netAccountInfo,
int bearerType, unsigned long* pResult);
+ void OnResetNetStatistics(int bearerType, int statType, unsigned long* pResult);
+ void OnResetAllNetStatistics(int bearerType, unsigned long* pResult);
private:
NetService* __pNetService;
result GetAppNetAccountId(const Tizen::Base::String& profileName, int& netAccountId);
result SetNetAccountId(int netAccountId, int& netAccountId2);
result UpdateSystemNetAccount(const Tizen::Base::String& profileName, const Tizen::Net::NetAccountInfo& netAccountInfo, int bearerType);
+ result ResetNetStatistics(int bearerType, int statType);
+ result ResetAllNetStatistics(int bearerType);
private:
void* GetPsProfileHandleN(const Tizen::Base::String& profileName);
* @class NfcConnectivityIpcStub
* @brief This class represents an IPC stub for the Connectivity daemon service.
*
- * @since 2.1
+ * @since 2.0
*
* This class represents an IPC stub for the Connectivity daemon service.
*/
void OnRegisterNfcPushMessage(const Tizen::Base::ByteBuffer& pushMessageBuffer, const Tizen::Base::String& description,
unsigned long* pResult);
void OnUnregisterNfcPushMessage(unsigned long* pResult);
+ void OnActivateReservedPush(unsigned long* pResult);
+ void OnDeactivateReservedPush(unsigned long* pResult);
+ void OnIsReservedPushActivated(bool* pIsActivated);
+ void OnGetReservedPushCandidates(Tizen::Base::Collection::HashMap* pCandidates, unsigned long* pResult);
+ void OnPickReservedPushMessage(const Tizen::Base::String& appId, unsigned long* pResult);
+ void OnGetPickedReservedPushMessage(Tizen::Base::String* pAppId, unsigned long* pResult);
private:
NfcService* __pNfcService;
#include <nfc.h>
#include <FBaseResult.h>
#include <FBaseString.h>
-#include <FAppIAppControlEventListener.h>
+#include <FBaseRtMutex.h>
+#include <FAppIAppControlResponseListener.h>
/**
* @class NfcMessagePushDelegate
* This class represents NFC service of the Connectivity service daemon.
*/
class NfcMessagePushDelegate
- : public Tizen::App::IAppControlEventListener
+ : public Tizen::App::IAppControlResponseListener
{
public:
NfcMessagePushDelegate(void);
void Initialize(void);
void Deinitialize(void);
+ result SetReservedPushEnabled(bool isEnabled);
+ bool IsReservedPushEnabled(void);
+ Tizen::Base::String GetSelectedMessageAppId(void);
- void InvokeNfcPushUiAppControl(const Tizen::Base::String& iconPath, const Tizen::Base::String& appName, const Tizen::Base::String& description);
-
- // IAppControlEventListener
- virtual void OnAppControlCompleted(const Tizen::Base::String& providerId, const Tizen::Base::String& operationId, const Tizen::Base::Collection::IList* pResultList);
+ //IAppControlResponseListener
+ virtual void OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId,
+ Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData);
+ virtual void OnAppControlStartResponseReceived (const Tizen::App::AppId& appId,
+ const Tizen::Base::String& operationId, result r);
static void OnNfcDeviceDiscovered(nfc_discovered_type_e type, nfc_p2p_target_h target, void* pUserData);
static void OnNfcReservedPushStateChanged(keynode_t* pKeyNode, void* pUserData);
static void OnNdefMessageSent(nfc_error_e res, void* pUserData);
private:
- void UpdatePushEnabled(void);
+ void RefreshReservedPushEnabled(void);
bool IsHomeScreenAtTopmost(void);
void SendReservedMessage(nfc_p2p_target_h targetH);
+ result GetSelectedMessageMetadata(Tizen::Base::String& iconPath, Tizen::Base::String& appName,
+ Tizen::Base::String& description);
+ void InvokeNfcPushUiAppControl(void);
public:
- static const wchar_t* _NFC_PUSH_UI_AC_PROVIDER_ID;
+ static const wchar_t* _NFC_PUSH_UI_AC_APP_ID;
static const wchar_t* _NFC_PUSH_UI_AC_OPERATION_ID;
private:
bool __isPushEnabled;
+ Tizen::Base::Runtime::Mutex __enabledMutex;
nfc_p2p_target_h __p2pTargetHandle;
};
#include <FIoDatabase.h>
#include <FAppPkgIPackageInstallationEventListener.h>
-// forward declarations
namespace Tizen { namespace Base
{
class ByteBuffer;
} }
+namespace Tizen { namespace Base { namespace Collection
+{
+class HashMap;
+} } }
+
/**
* @class NfcMessageRegisterService
* @brief This class represents NFC service of the Connectivity service daemon.
result Construct(void);
- result RegisterPushMessage(const Tizen::Base::String& appId, const Tizen::Base::ByteBuffer& pushMessageBuffer,
- const Tizen::Base::String& description);
- result UnregisterPushMessage(const Tizen::Base::String& appId);
+ result RegisterPushMessage(const Tizen::Base::String& appPkgId,
+ const Tizen::Base::ByteBuffer& pushMessageBuffer, const Tizen::Base::String& description);
+ result UnregisterPushMessage(const Tizen::Base::String& appPkgId);
+ result GetReservedPushCandidates(Tizen::Base::Collection::HashMap* pCandidates);
+ result PickReservedPushMessage(const Tizen::Base::String& ownerAppId);
// From IPackageInstallationEventListener;
- virtual void OnPackageInstallationCompleted(const Tizen::App::PackageId& packageId, Tizen::App::Package::PackageInstallationResult installationResult) {}
+ virtual void OnPackageInstallationCompleted(const Tizen::App::PackageId& packageId,
+ Tizen::App::Package::PackageInstallationResult installationResult) {}
virtual void OnPackageUninstallationCompleted(const Tizen::App::PackageId& packageId, bool uninstallationResult);
virtual void OnPackageInstallationInProgress(const Tizen::App::PackageId& packageId, int progress) {}
private:
Tizen::Io::Database __rsvdPushDb;
- Tizen::Base::Runtime::Mutex __appIdListMutex;
- Tizen::Base::Collection::LinkedListT<Tizen::Base::String> __reserverAppIdList;
+ Tizen::Base::Runtime::Mutex __listMutex;
+ Tizen::Base::Collection::LinkedListT<Tizen::Base::String> __reserverList;
};
#include <FBaseRtMutex.h>
#include <FBaseString.h>
#include <FBaseColLinkedListT.h>
-#include <FApp_IAppManagerEventListener.h>
-// forward declarations
namespace Tizen { namespace Base
{
class ByteBuffer;
* @class NfcService
* @brief This class represents NFC service of the Connectivity service daemon.
*
- * @since 2.1
+ * @since 2.0
*
* This class represents NFC service of the Connectivity service daemon.
*/
class NfcService
- : public Tizen::App::_IAppManagerEventListener
{
public:
NfcService(void);
virtual ~NfcService(void);
result Construct(void);
- result AddNfcAppId(const Tizen::Base::String& appId);
- result SetLaunchPopupEnabled(const Tizen::Base::String& clientAppId, bool enable);
- result RegisterPushMessage(const Tizen::Base::String& clientAppId, const Tizen::Base::ByteBuffer& pushMessageBuffer,
+ result AddNfcAppId(const Tizen::Base::String& appPkgId);
+ result SetLaunchPopupEnabled(const Tizen::Base::String& clientPkgId, bool enable);
+ result RegisterPushMessage(const Tizen::Base::String& clientPkgId, const Tizen::Base::ByteBuffer& pushMessageBuffer,
const Tizen::Base::String& description);
- result UnregisterPushMessage(const Tizen::Base::String& clientAppId);
+ result UnregisterPushMessage(const Tizen::Base::String& clientPkgId);
+ void RemoveNfcAppId(const Tizen::Base::String& appPkgId);
+ result ActivateReservedPush(void);
+ result DeactivateReservedPush(void);
+ bool IsReservedPushActivated(void);
+ result GetReservedPushCandidates(Tizen::Base::Collection::HashMap* pCandidates);
+ result PickReservedPushMessage(const Tizen::Base::String& appId);
+ result GetPickedReservedPushMessage(Tizen::Base::String& appId);
- void RemoveNfcAppId(const Tizen::Base::String& appId);
-
- // From _IAppManagerEventListener;
- virtual void OnApplicationLaunched(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
- virtual void OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
+ // Process application termination cases such that an IPC client is disconnected.
+ void ProcessAppTermination(const Tizen::Base::String& clientPkgId);
+ // Callback used by SLP NFC F/W to notify that NFC is activated/deactivated on the device.
static void OnNfcActivationChanged(keynode_t* pKeyNode, void* pUserData);
private:
NfcMessagePushDelegate* __pPushDelegate;
Tizen::Base::Runtime::Mutex __enablingMutex;
bool __popupEnabled;
- Tizen::Base::String __serviceDaemonAppId;
+ Tizen::Base::String __serviceDaemonId;
Tizen::Base::String __popupDisablerId;
- Tizen::Base::Runtime::Mutex __appIdListMutex;
- Tizen::Base::Collection::LinkedListT<Tizen::Base::String> __appIdList;
+ Tizen::Base::Runtime::Mutex __listMutex;
+ Tizen::Base::Collection::LinkedListT<Tizen::Base::String> __appPkgIdList;
};
#ifndef _WIFI_CONNECTIVITY_IPC_STUB_H_
#define _WIFI_CONNECTIVITY_IPC_STUB_H_
-#include <unique_ptr.h>
#include <FBaseObject.h>
#include <FIo_IIpcServerEventListener.h>
* @class WifiConnectivityIpcStub
* @brief This class represents an IPC stub for the Connectivity daemon service.
*
- * @since 2.1
+ * @since 2.0
*
* This class represents an IPC stub for the Connectivity daemon service.
*/
void OnIsProximityCheckActivated(bool* pIsActivated, unsigned long* pResult);
private:
- std::unique_ptr<WifiProximityService> __pWifiProximityService;
- std::unique_ptr<WifiService> __pWifiService;
- std::unique_ptr<Tizen::Io::_IpcServer> __pIpcServer;
+ WifiProximityService* __pWifiProximityService;
+ WifiService* __pWifiService;
+ Tizen::Io::_IpcServer* __pIpcServer;
};
result RegisterBssId(const Tizen::Base::String& macAddress, const int clientId);
result UnregisterBssId(const Tizen::Base::String& macAddress, const int clientId);
result UnregisterClient(const int clientId);
- result ActivateProximityCheck(const int clientId);
- result DeactivateProximityCheck(const int clientId);
+ result ActivateProximityCheck(void);
+ result DeactivateProximityCheck(void);
bool IsProximityCheckActivated(void) const;
// from ITimerEventListener
#include <wifi.h>
#include <FBaseString.h>
#include <FBaseRtMutex.h>
-#include <FBaseColLinkedList.h>
-#include <FApp_IAppManagerEventListener.h>
+#include <FBaseColLinkedListT.h>
namespace Tizen { namespace Net { namespace Wifi {
class WifiBssInfo;
* @class WifiService
* @brief This class represents Wi-Fi service of the Connectivity service daemon.
*
- * @since 2.1
+ * @since 2.0
*
* This class represents Wi-Fi service of the Connectivity service daemon.
*/
class WifiService
- : public Tizen::App::_IAppManagerEventListener
{
public:
WifiService(void);
result SetWifiSystemScanMode(int mode);
result UpdateWifiBssInfo(const Tizen::Net::Wifi::WifiBssInfo& bssInfo);
- result Initialize(const Tizen::Base::String& clientAppId);
+ result Initialize(const Tizen::Base::String& clientPkgId);
result GetWifiDirectLocalDeviceName(Tizen::Base::String* pLocalName);
- result SetWifiDirectLocalDeviceName(const Tizen::Base::String& clientAppId, const Tizen::Base::String& localName);
+ result SetWifiDirectLocalDeviceName(const Tizen::Base::String& clientPkgId, const Tizen::Base::String& localName);
+
+ // Process application termination cases such that an IPC client is disconnected.
+ void ProcessAppTermination(const Tizen::Base::String& clientPkgId);
// Callback used by SLP Wi-Fi Direct F/W to notify that Wi-Fi Direct is activated on the device.
void OnWifiDirectActivated(void);
- // From _IAppManagerEventListener;
- virtual void OnApplicationLaunched(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
- virtual void OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen::App::_AppType type);
-
static bool OnWifiEachAccessPointFound(wifi_ap_h apHandle, void* pUserData);
private:
private:
Tizen::Base::String __newWifiDirectName;
Tizen::Base::String __wifiDirectNameChangerId;
- Tizen::Base::Runtime::Mutex __appIdListMutex;
- Tizen::Base::Collection::LinkedList __appIdList;
+ Tizen::Base::Runtime::Mutex __listMutex;
+ Tizen::Base::Collection::LinkedListT<Tizen::Base::String> __appPkgIdList;
};
<Apps>
<ApiVersion>2.1</ApiVersion>
<Secret>42E1041F4B5834A70EE443351DCEC1A9</Secret>
- <Privileges/>
- <ServiceApp AutoRestart="False" Default="True" ExecutableName="osp-connectivity-service" LaunchOnBoot="False">
+ <Privileges>
+ <Privilege>http://tizen.org/privilege/application.launch</Privilege>
+ </Privileges>
+ <ServiceApp SystemService="True" AutoRestart="False" Default="True" ExecutableName="osp-connectivity-service" LaunchOnBoot="False">
<Names>
<Name Locale="eng-GB">osp-connectivity-service</Name>
</Names>
<manifest>
<define>
- <domain name="osp-connectivity-service"/>
+ <domain name="57r43275q7"/>
</define>
<request>
- <domain name="osp-connectivity-service"/>
+ <domain name="57r43275q7"/>
</request>
<assign>
- <filesystem path="/usr/apps/57r43275q7/bin/osp-connectivity-service.exe" label="osp-connectivity-service" exec_label="osp-connectivity-service"/>
<filesystem path="/usr/share/license/osp-connectivity-service" label="_"/>
</assign>
</manifest>
\ No newline at end of file
--- /dev/null
+57r43275q7 resman::db rw
+
/bin/rm -fr /opt/apps/57r43275q7
/usr/etc/package-manager/backend/tpk -i /usr/apps/57r43275q7
-cp -f /usr/lib/osp/osp-system-service-loader /usr/apps/57r43275q7/bin/osp-connectivity-service
if [ -f /usr/lib/rpm-plugins/msm.so ]
then
chsmack -a osp-connectivity-service /usr/apps/57r43275q7/bin/osp-connectivity-service
%files
%manifest osp-connectivity-service.manifest
+/etc/smack/accesses2.d/osp-connectivity-service.rule
/usr/share/license/%{name}
/usr/apps/*
#include "BluetoothConnectivityIpcStub.h"
#include "BluetoothService.h"
+using namespace std;
using namespace Tizen::Base;
using namespace Tizen::Io;
using namespace Tizen::Security;
BluetoothConnectivityIpcStub::Construct(void)
{
result r = E_SUCCESS;
- result retVal = E_SUCCESS;
+ unique_ptr<BluetoothService> pBtService;
+ unique_ptr<_IpcServer> pIpcServer;
- __pBtService = new (std::nothrow) BluetoothService;
- SysTryCatch(NID_NET_BT, __pBtService != null, retVal = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ pBtService.reset(new (std::nothrow) BluetoothService);
+ SysTryReturnResult(NID_NET_BT, pBtService != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
- r = __pBtService->Construct();
+ r = pBtService->Construct();
if (r == E_SUCCESS)
{
SysLog(NID_NET_BT, "BluetoothService is created.");
}
else
{
- // skip Bluetooth service
+ // ignore the failure of creating the Bluetooth service
SysLogException(NID_NET_BT, r, "[%s] Failed to construct BluetoothService.", GetErrorMessage(r));
- delete __pBtService;
- __pBtService = null;
+ pBtService.reset(null);
}
- __pIpcServer = new (std::nothrow) _IpcServer;
- SysTryCatch(NID_NET_BT, __pIpcServer != null, retVal = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ pIpcServer.reset(new (std::nothrow) _IpcServer);
+ SysTryReturnResult(NID_NET_BT, pIpcServer != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
- r = __pIpcServer->Construct(BLUETOOTH_CONNECTIVITY_IPC_SERVER_NAME, *this);
- SysTryCatch(NID_NET_BT, r == E_SUCCESS, retVal = E_SYSTEM, E_SYSTEM,
- "[%s] A system error has been occurred. Failed to construct IpcServer.", GetErrorMessage(E_SYSTEM));
+ r = pIpcServer->Construct(BLUETOOTH_CONNECTIVITY_IPC_SERVER_NAME, *this);
+ SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_SYSTEM, "Failed to construct IpcServer.");
- return E_SUCCESS;
-
-CATCH:
- delete __pIpcServer;
- __pIpcServer = null;
+ __pBtService = pBtService.release();
+ __pIpcServer = pIpcServer.release();
- delete __pBtService;
- __pBtService = null;
-
- return retVal;
+ return E_SUCCESS;
}
void
BluetoothConnectivityIpcStub::OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId)
{
SysLog(NID_NET_BT, "Disconnected with clientId[%d].", clientId);
+
+ if (__pBtService != null)
+ {
+ __pBtService->ProcessAppTermination(__pIpcServer->GetClientAppId());
+ }
}
void
BluetoothConnectivityIpcStub::OnGetBluetoothLocalDeviceName(Tizen::Base::String* pLocalName, unsigned long* pResult)
{
#if !defined (_OSP_EMUL_)
- SysLog(NID_NET_BT, "Received the request of getting the local device name with clientId : %d, AppId : %ls",
+ SysLog(NID_NET_BT, "Received the request of getting the local device name with clientId : %d, AppPkgId : %ls",
__pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
if (__pBtService == null)
BluetoothConnectivityIpcStub::OnSetBluetoothLocalDeviceName(Tizen::Base::String localName, unsigned long* pResult)
{
#if !defined (_OSP_EMUL_)
- SysLog(NID_NET_BT, "Received the request of setting the local device name with clientId : %d, AppId : %ls",
- __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+ String packageId = __pIpcServer->GetClientAppId();
+
+ SysLog(NID_NET_BT, "Received the request of setting the local device name with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), packageId.GetPointer());
if (__pBtService == null)
{
}
else
{
- *pResult = __pBtService->SetLocalDeviceName(__pIpcServer->GetClientAppId(), localName);
+ *pResult = __pBtService->SetLocalDeviceName(packageId, localName);
}
#else
SysLog(NID_NET_BT, "Invalid Operation because Bluetooth is unavailable on the emulator.");
BluetoothConnectivityIpcStub::OnSetBluetoothDiscoverableMode(int mode, int seconds, unsigned long* pResult)
{
#if !defined (_OSP_EMUL_)
- SysLog(NID_NET_BT, "Received the request of setting the discoverable mode with clientId : %d, AppId : %ls",
- __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+ String packageId = __pIpcServer->GetClientAppId();
- String appId = __pIpcServer->GetClientAppId();
+ SysLog(NID_NET_BT, "Received the request of setting the discoverable mode with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), packageId.GetPointer());
- *pResult = _AccessController::CheckSystemPrivilege(appId, _PRV_BLUETOOTHMANAGER);
+ *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_BLUETOOTHMANAGER);
if (*pResult != E_SUCCESS)
{
*pResult = E_PRIVILEGE_DENIED;
SysLogException(NID_NET_BT, E_PRIVILEGE_DENIED,
- "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+ "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
}
else if (__pBtService == null)
{
#include <vconf-keys.h>
#include <FBaseUtilStringUtil.h>
#include <FBaseSysLog.h>
-#include <FApp_AppManagerImpl.h>
#include <FSys_SystemInfoImpl.h>
#include <FBase_StringConverter.h>
#include "BluetoothService.h"
{
(void) bt_deinitialize();
(void) bt_adapter_unset_state_changed_cb();
- (void) _AppManagerImpl::GetInstance()->RemoveEventListener(*this);
}
result
bool isBtSupported = false;
r = Tizen::System::_SystemInfoImpl::GetSysInfo(L"BluetoothSupported", isBtSupported);
- TryReturn((r == E_SUCCESS) && (isBtSupported == true), E_UNSUPPORTED_OPERATION,
- "[E_UNSUPPORTED_OPERATION] Bluetooth is not supported.");
+ SysTryReturnResult(NID_NET_BT, (r == E_SUCCESS) && (isBtSupported == true), E_UNSUPPORTED_OPERATION,
+ "Bluetooth is not supported.");
// No need to unregister the callback method when BluetoothService::Construct() fails
// because BluetoothService instance will be removed instantly
SysTryReturnResult(NID_NET_BT, ret == BT_ERROR_NONE, E_SYSTEM,
"Registration of a Bluetooth callback method has failed.");
- r = _AppManagerImpl::GetInstance()->AddEventListener(*this);
- SysTryReturnResult(NID_NET_BT, r == E_SUCCESS, E_SYSTEM,
- "Registration of an _IAppManagerEventListener has failed.");
-
return E_SUCCESS;
}
}
result
-BluetoothService::SetLocalDeviceName(const Tizen::Base::String& clientAppId, const Tizen::Base::String& localName)
+BluetoothService::SetLocalDeviceName(const Tizen::Base::String& clientPkgId, const Tizen::Base::String& localName)
{
result r = E_SUCCESS;
int ret = 0;
if (!IsFailed(r))
{
__newName = localName;
- __nameChangerId = clientAppId;
+ __nameChangerId = clientPkgId;
}
}
else
{
__newName = localName;
- __nameChangerId = clientAppId;
+ __nameChangerId = clientPkgId;
}
return r;
}
void
-BluetoothService::OnApplicationLaunched(const Tizen::App::AppId& appId, Tizen::App::_AppType type)
-{
- // do nothing.
-}
-
-void
-BluetoothService::OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen::App::_AppType type)
+BluetoothService::ProcessAppTermination(const Tizen::Base::String& clientPkgId)
{
char* phoneName = null;
String convertedName;
int ret = 0;
bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED;
- if (__nameChangerId == appId)
+ if (__nameChangerId == clientPkgId)
{
SysLog(NID_NET_BT, "The application which set the BT local name is terminated.");
IPC_MESSAGE_HANDLER(ConnectivityNetServiceMsg_getAppNetAccountId, OnGetAppNetAccountId, &server)
IPC_MESSAGE_HANDLER(ConnectivityNetServiceMsg_setNetAccountId, OnSetNetAccountId, &server)
IPC_MESSAGE_HANDLER(ConnectivityNetServiceMsg_updateSystemNetAccount, OnUpdateSystemNetAccount, &server)
+ IPC_MESSAGE_HANDLER(ConnectivityNetServiceMsg_resetNetStatistics, OnResetNetStatistics, &server)
+ IPC_MESSAGE_HANDLER(ConnectivityNetServiceMsg_resetAllNetStatistics, OnResetAllNetStatistics, &server)
IPC_END_MESSAGE_MAP()
}
*pResult = __pNetService->UpdateSystemNetAccount(profileName, netAccountInfo, bearerType);
}
}
+
+void
+NetConnectivityIpcStub::OnResetNetStatistics(int bearerType, int statType, unsigned long* pResult)
+{
+ SysLog(NID_NET, "Received to reset network statistics with bearer: %d, statType : %d, clientId : %d, AppId : %ls",
+ bearerType, statType, __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+
+ String appId = __pIpcServer->GetClientAppId();
+
+ *pResult = _AccessController::CheckSystemPrivilege(appId, _PRV_NETSTATISTICSMANAGER);
+
+ if (*pResult != E_SUCCESS)
+ {
+ *pResult = E_PRIVILEGE_DENIED;
+ SysLogException(NID_NET, E_PRIVILEGE_DENIED,
+ "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+ }
+ else
+ {
+ *pResult = __pNetService->ResetNetStatistics(bearerType, statType);
+ }
+}
+
+void
+NetConnectivityIpcStub::OnResetAllNetStatistics(int bearerType, unsigned long* pResult)
+{
+ SysLog(NID_NET, "Received to reset all network statistics with bearer: %d, clientId : %d, AppId : %ls",
+ bearerType, __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+
+ String appId = __pIpcServer->GetClientAppId();
+
+ *pResult = _AccessController::CheckSystemPrivilege(appId, _PRV_NETSTATISTICSMANAGER);
+
+ if (*pResult != E_SUCCESS)
+ {
+ *pResult = E_PRIVILEGE_DENIED;
+ SysLogException(NID_NET, E_PRIVILEGE_DENIED,
+ "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+ }
+ else
+ {
+ *pResult = __pNetService->ResetAllNetStatistics(bearerType);
+ }
+}
NetService::GetAppNetAccountId(const String& profileName, int& netAccountId)
{
result r = E_SUCCESS;
- bool isKnownProfile = false;
- if (profileName.Equals(L"SNS", true))
+ if (profileName.Equals(L"Internet", false))
{
- isKnownProfile = true;
- }
- else if (profileName.Equals(L"EMail", true))
- {
- isKnownProfile = true;
- }
- else if (profileName.Equals(L"Br", true))
- {
- isKnownProfile = true;
- }
- else if (profileName.Equals(L"IM", true))
- {
- isKnownProfile = true;
- }
- else if (profileName.Equals(L"MMS", true))
- {
- isKnownProfile = true;
- }
- else
- {
- isKnownProfile = false;
+ netAccountId = _DEFAULT_PS_ACCOUNT_ID;
}
-
- if (isKnownProfile)
+ else if (profileName.Equals(L"Mms", false))
{
- netAccountId = _DEFAULT_PS_ACCOUNT_ID;
+ netAccountId = _DEFAULT_MMS_ACCOUNT_ID;
}
else
{
return r;
}
+result
+NetService::ResetNetStatistics(int bearerType, int statType)
+{
+ int err = CONNECTION_ERROR_NONE;
+
+ SysTryReturnResult(NID_NET, (bearerType == NET_BEARER_WIFI || bearerType == NET_BEARER_PS),
+ E_INVALID_ARG, "Invalid bearer type. [%d]", bearerType);
+
+ //Reset net statistics info based on type
+ switch (statType)
+ {
+ //supported cases
+ case NET_STAT_RCVD_SIZE:
+ if (bearerType == NET_BEARER_PS)
+ {
+ err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
+ }
+ else
+ {
+ err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
+ }
+
+ break;
+
+ case NET_STAT_SENT_SIZE:
+ if (bearerType == NET_BEARER_PS)
+ {
+ err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
+ }
+ else
+ {
+ err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
+ }
+
+ break;
+
+ case NET_STAT_TOTAL_RCVD_SIZE:
+ if (bearerType == NET_BEARER_PS)
+ {
+ err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
+ }
+ else
+ {
+ err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
+ }
+
+ break;
+
+ case NET_STAT_TOTAL_SENT_SIZE:
+ if (bearerType == NET_BEARER_PS)
+ {
+ err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
+ }
+ else
+ {
+ err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
+ }
+
+ break;
+
+ default:
+ SysTryReturnResult(NID_NET, false, E_INVALID_ARG, "Invalid argument is used.");
+
+ break;
+ }
+
+ SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed. [err:%d]", err);
+
+ return E_SUCCESS;
+}
+
+result
+NetService::ResetAllNetStatistics(int bearerType)
+{
+ int err = CONNECTION_ERROR_NONE;
+
+ SysTryReturnResult(NID_NET, (bearerType == NET_BEARER_WIFI || bearerType == NET_BEARER_PS),
+ E_INVALID_ARG, "Invalid bearer type. [%d]", bearerType);
+
+ //we support only PS and WIFI
+ if (bearerType == NET_BEARER_PS)
+ {
+ err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
+ SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed. [err:%d]", err);
+
+ err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
+ SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed. [err:%d]", err);
+
+ err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
+ SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed. [err:%d]", err);
+
+ err = connection_reset_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
+ SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed. [err:%d]", err);
+
+ }
+ else
+ {
+ err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
+ SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed. [err:%d]", err);
+
+ err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
+ SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed. [err:%d]", err);
+
+ err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
+ SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed. [err:%d]", err);
+
+ err = connection_reset_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
+ SysTryReturnResult(NID_NET, err == CONNECTION_ERROR_NONE, E_SYSTEM, "A system error has been occurred. Operation failed. [err:%d]", err);
+ }
+
+ return E_SUCCESS;
+}
+
void*
NetService::GetPsProfileHandleN(const String& profileName)
{
char* pTempProfileName = null;
String tempProfileName;
- ret = connection_profile_get_name(profileHandle, &pTempProfileName);
+ ret = connection_profile_get_id(profileHandle, &pTempProfileName);
SysTryCatch(NID_NET, ret == CONNECTION_ERROR_NONE, , E_SYSTEM,
- "[%s] A system error has been occurred. The return value from connection_profile_get_name() is %d", GetErrorMessage(E_SYSTEM), ret);
+ "[%s] A system error has been occurred. The return value from connection_profile_get_id() is %d", GetErrorMessage(E_SYSTEM), ret);
tempProfileName = String(pTempProfileName);
free(pTempProfileName);
#include "NfcConnectivityIpcStub.h"
#include "NfcService.h"
+using namespace std;
using namespace Tizen::Base;
using namespace Tizen::Io;
using namespace Tizen::Security;
NfcConnectivityIpcStub::Construct(void)
{
result r = E_SUCCESS;
- result retVal = E_SUCCESS;
+ unique_ptr<NfcService> pNfcService;
+ unique_ptr<_IpcServer> pIpcServer;
- __pNfcService = new (std::nothrow) NfcService;
- SysTryReturnResult(NID_NET_NFC, __pNfcService != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+ pNfcService.reset(new (std::nothrow) NfcService);
+ SysTryReturnResult(NID_NET_NFC, pNfcService != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
- r = __pNfcService->Construct();
+ r = pNfcService->Construct();
if (r == E_SUCCESS)
{
SysLog(NID_NET_NFC, "NfcService is created.");
}
else
{
- // skip NFC service
+ // ignore the failure of creating the NFC service
SysLogException(NID_NET_NFC, r, "[%s] Failed to construct NfcService.", GetErrorMessage(r));
- delete __pNfcService;
- __pNfcService = null;
+ pNfcService.reset(null);
}
- __pIpcServer = new (std::nothrow) _IpcServer;
- SysTryCatch(NID_NET_NFC, __pIpcServer != null, retVal = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ pIpcServer.reset(new (std::nothrow) _IpcServer);
+ SysTryReturnResult(NID_NET_NFC, pIpcServer != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
- r = __pIpcServer->Construct(NFC_CONNECTIVITY_IPC_SERVER_NAME, *this);
- SysTryCatch(NID_NET_NFC, r == E_SUCCESS, retVal = E_SYSTEM, E_SYSTEM,
- "[%s] A system error has been occurred. Failed to construct IpcServer.", GetErrorMessage(E_SYSTEM));
+ r = pIpcServer->Construct(NFC_CONNECTIVITY_IPC_SERVER_NAME, *this);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to construct IpcServer.");
- return E_SUCCESS;
-
-CATCH:
- delete __pIpcServer;
- __pIpcServer = null;
+ __pNfcService = pNfcService.release();
+ __pIpcServer = pIpcServer.release();
- delete __pNfcService;
- __pNfcService = null;
-
- return retVal;
+ return E_SUCCESS;
}
void
NfcConnectivityIpcStub::OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId)
{
SysLog(NID_NET_NFC, "Disconnected with clientId[%d].", clientId);
+
+ if (__pNfcService != null)
+ {
+ __pNfcService->ProcessAppTermination(__pIpcServer->GetClientAppId());
+ }
}
void
IPC_MESSAGE_HANDLER(ConnectivityNfcServiceMsg_setLaunchPopupEnabled, OnSetNfcLaunchPopupEnabled, &server)
IPC_MESSAGE_HANDLER(ConnectivityNfcServiceMsg_registerPushMessage, OnRegisterNfcPushMessage, &server)
IPC_MESSAGE_HANDLER(ConnectivityNfcServiceMsg_unregisterPushMessage, OnUnregisterNfcPushMessage, &server)
+ IPC_MESSAGE_HANDLER(ConnectivityNfcServiceMsg_activateReservedPush, OnActivateReservedPush, &server)
+ IPC_MESSAGE_HANDLER(ConnectivityNfcServiceMsg_deactivateReservedPush, OnDeactivateReservedPush, &server)
+ IPC_MESSAGE_HANDLER(ConnectivityNfcServiceMsg_isReservedPushActivated, OnIsReservedPushActivated, &server)
+ IPC_MESSAGE_HANDLER(ConnectivityNfcServiceMsg_getReservedPushCandidates, OnGetReservedPushCandidates, &server)
+ IPC_MESSAGE_HANDLER(ConnectivityNfcServiceMsg_pickReservedPushMessage, OnPickReservedPushMessage, &server)
+ IPC_MESSAGE_HANDLER(ConnectivityNfcServiceMsg_getPickedReservedPushMessage, OnGetPickedReservedPushMessage, &server)
IPC_END_MESSAGE_MAP()
}
-
void
NfcConnectivityIpcStub::OnInitializeNfc(unsigned long* pResult)
{
- SysLog(NID_NET_NFC, "Received the request of initializing the NFC with clientId : %d, AppId : %ls",
- __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+ String packageId = __pIpcServer->GetClientAppId();
+
+ SysLog(NID_NET_NFC, "Received the request of initializing the NFC with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), packageId.GetPointer());
if (__pNfcService == null)
{
}
else
{
- *pResult = __pNfcService->AddNfcAppId(__pIpcServer->GetClientAppId());
+ *pResult = __pNfcService->AddNfcAppId(packageId);
}
}
void
NfcConnectivityIpcStub::OnSetNfcLaunchPopupEnabled(bool enable, unsigned long* pResult)
{
- SysLog(NID_NET_NFC, "Received the request of setting the launch popup enabled with clientId : %d, AppId : %ls",
- __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+ String packageId = __pIpcServer->GetClientAppId();
+
+ SysLog(NID_NET_NFC, "Received the request of setting the launch popup enabled with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), packageId.GetPointer());
if (__pNfcService == null)
{
}
else
{
- *pResult = __pNfcService->SetLaunchPopupEnabled(__pIpcServer->GetClientAppId(), enable);
+ *pResult = __pNfcService->SetLaunchPopupEnabled(packageId, enable);
}
}
NfcConnectivityIpcStub::OnRegisterNfcPushMessage(const Tizen::Base::ByteBuffer& pushMessageBuffer,
const Tizen::Base::String& description, unsigned long* pResult)
{
- SysLog(NID_NET_NFC, "Received the request of registering the NFC push message with clientId : %d, AppId : %ls",
- __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+ String packageId = __pIpcServer->GetClientAppId();
+
+ SysLog(NID_NET_NFC, "Received the request of registering the NFC push message with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), packageId.GetPointer());
if (__pNfcService == null)
{
}
else
{
- *pResult = __pNfcService->RegisterPushMessage(__pIpcServer->GetClientAppId(), pushMessageBuffer, description);
+ *pResult = __pNfcService->RegisterPushMessage(packageId, pushMessageBuffer, description);
}
}
void
NfcConnectivityIpcStub::OnUnregisterNfcPushMessage(unsigned long* pResult)
{
- SysLog(NID_NET_NFC, "Received the request of unregistering the NFC push message with clientId : %d, AppId : %ls",
+ String packageId = __pIpcServer->GetClientAppId();
+
+ SysLog(NID_NET_NFC, "Received the request of unregistering the NFC push message with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), packageId.GetPointer());
+
+ if (__pNfcService == null)
+ {
+ *pResult = E_SYSTEM;
+ }
+ else
+ {
+ *pResult = __pNfcService->UnregisterPushMessage(packageId);
+ }
+}
+
+void
+NfcConnectivityIpcStub::OnActivateReservedPush(unsigned long* pResult)
+{
+ String packageId = __pIpcServer->GetClientAppId();
+
+ SysLog(NID_NET_NFC, "Received the request of activating the NFC Reserved Push with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), packageId.GetPointer());
+
+/* *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_NFCMANAGER);
+
+ if (*pResult != E_SUCCESS)
+ {
+ *pResult = E_PRIVILEGE_DENIED;
+ SysLogException(NID_NET_NFC, E_PRIVILEGE_DENIED,
+ "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+ }
+ else */if (__pNfcService == null)
+ {
+ *pResult = E_SYSTEM;
+ }
+ else
+ {
+ *pResult = __pNfcService->ActivateReservedPush();
+ }
+}
+
+void
+NfcConnectivityIpcStub::OnDeactivateReservedPush(unsigned long* pResult)
+{
+ String packageId = __pIpcServer->GetClientAppId();
+
+ SysLog(NID_NET_NFC, "Received the request of deactivating the NFC Reserved Push with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), packageId.GetPointer());
+
+/* *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_NFCMANAGER);
+
+ if (*pResult != E_SUCCESS)
+ {
+ *pResult = E_PRIVILEGE_DENIED;
+ SysLogException(NID_NET_NFC, E_PRIVILEGE_DENIED,
+ "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+ }
+ else */if (__pNfcService == null)
+ {
+ *pResult = E_SYSTEM;
+ }
+ else
+ {
+ *pResult = __pNfcService->DeactivateReservedPush();
+ }
+}
+
+void
+NfcConnectivityIpcStub::OnIsReservedPushActivated(bool* pIsActivated)
+{
+ SysLog(NID_NET_NFC, "Received the request of checking the NFC Reserved Push is activated with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+
+ if (__pNfcService == null)
+ {
+ *pIsActivated = false;
+ }
+ else
+ {
+ *pIsActivated = __pNfcService->IsReservedPushActivated();
+ }
+}
+
+void
+NfcConnectivityIpcStub::OnGetReservedPushCandidates(Tizen::Base::Collection::HashMap* pCandidates, unsigned long* pResult)
+{
+ SysLog(NID_NET_NFC, "Received the request of getting the NFC Reserved Push candidate list with clientId : %d, AppPkgId : %ls",
__pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
if (__pNfcService == null)
}
else
{
- *pResult = __pNfcService->UnregisterPushMessage(__pIpcServer->GetClientAppId());
+ *pResult = __pNfcService->GetReservedPushCandidates(pCandidates);
}
}
+void
+NfcConnectivityIpcStub::OnPickReservedPushMessage(const Tizen::Base::String& appId, unsigned long* pResult)
+{
+ String packageId = __pIpcServer->GetClientAppId();
+
+ SysLog(NID_NET_NFC, "Received the request of picking the NFC Reserved Push message with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), packageId.GetPointer());
+
+/* *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_NFCMANAGER);
+
+ if (*pResult != E_SUCCESS)
+ {
+ *pResult = E_PRIVILEGE_DENIED;
+ SysLogException(NID_NET_NFC, E_PRIVILEGE_DENIED,
+ "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
+ }
+ else */if (__pNfcService == null)
+ {
+ *pResult = E_SYSTEM;
+ }
+ else
+ {
+ *pResult = __pNfcService->PickReservedPushMessage(appId);
+ }
+}
+
+void
+NfcConnectivityIpcStub::OnGetPickedReservedPushMessage(Tizen::Base::String* pAppId, unsigned long* pResult)
+{
+ SysLog(NID_NET_NFC, "Received the request of getting the picked Reserved Push message with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+
+ if (__pNfcService == null)
+ {
+ *pResult = E_SYSTEM;
+ }
+ else
+ {
+ *pResult = __pNfcService->GetPickedReservedPushMessage(*pAppId);
+ }
+}
#include <Ecore_Evas.h>
#include <Ecore_X.h>
#include <app_manager.h>
+#include <FAppApp.h>
#include <FAppAppControl.h>
#include <FAppAppManager.h>
#include <FBaseSysLog.h>
#include <FBaseByteBuffer.h>
+#include <FBaseRtMutexGuard.h>
#include <FBaseUtilStringUtil.h>
#include <FBaseColArrayList.h>
#include <FIoFile.h>
#include <FIoFileAttributes.h>
+#include <FIoDatabase.h>
+#include <FIoDbStatement.h>
+#include <FIoDbEnumerator.h>
#include "NfcMessagePushDelegate.h"
#include "NfcMessageRegisterService.h"
using namespace std;
using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
using namespace Tizen::Base::Utility;
using namespace Tizen::App;
using namespace Tizen::Io;
using namespace Tizen::Base::Collection;
-const wchar_t* NfcMessagePushDelegate::_NFC_PUSH_UI_AC_PROVIDER_ID = L"http://tizen.org/appcontrol/provider/nfcpushui";
+const wchar_t* NfcMessagePushDelegate::_NFC_PUSH_UI_AC_APP_ID = L"42KriKjov3.nfc-push-ui-app-control";
const wchar_t* NfcMessagePushDelegate::_NFC_PUSH_UI_AC_OPERATION_ID = L"http://tizen.org/appcontrol/operation/nfc/animation/show";
struct _CharDeleter
NfcMessagePushDelegate::NfcMessagePushDelegate(void)
: __isPushEnabled(false)
+ , __enabledMutex()
, __p2pTargetHandle(null)
{
+ __enabledMutex.Create();
+
// Checks whether the reserved push feature is enabled or disabled
- UpdatePushEnabled();
+ RefreshReservedPushEnabled();
// set vconf callback about the Reserved Push setting
vconf_notify_key_changed(VCONFKEY_NFC_PREDEFINED_ITEM_STATE, OnNfcReservedPushStateChanged, this);
nfc_manager_unset_p2p_target_discovered_cb();
}
+result
+NfcMessagePushDelegate::SetReservedPushEnabled(bool isEnabled)
+{
+ int vconfRes = -1;
+
+ MutexGuard locked(__enabledMutex);
+
+ SysTryReturnResult(NID_NET_NFC, __isPushEnabled != isEnabled, E_INVALID_OPERATION,
+ "Reserved Push is aready %s.", isEnabled ? "activated" : "deactivated");
+
+ // set the value for the predefined item state
+ vconfRes = vconf_set_bool(VCONFKEY_NFC_PREDEFINED_ITEM_STATE, isEnabled ? 1 : 0);
+ SysTryReturnResult(NID_SYS, vconfRes == 0, E_SYSTEM, "Failed to set the vconf - reserved push state - value.");
+
+ __isPushEnabled = isEnabled;
+
+ return E_SUCCESS;
+}
+
+bool
+NfcMessagePushDelegate::IsReservedPushEnabled(void)
+{
+ return __isPushEnabled;
+}
+
void
-NfcMessagePushDelegate::UpdatePushEnabled(void)
+NfcMessagePushDelegate::RefreshReservedPushEnabled(void)
{
int vconfRes = -1;
int isEnabled = 0;
- // get the value for the predefined item
+ MutexGuard locked(__enabledMutex);
+
+ // get the value for the predefined item state
vconfRes = vconf_get_bool(VCONFKEY_NFC_PREDEFINED_ITEM_STATE, &isEnabled);
SysTryReturnVoidResult(NID_NET_NFC, vconfRes == 0, E_SYSTEM,
"[E_SYSTEM] Failed to get the vconf - reserved push state - value.");
FileAttributes msgFileAttr;
String msgFilePath;
nfc_ndef_message_h ndefMessageH = NULL;
- char* pSelectedItem = null;
String selectedItemStr;
- // get the value for the predefined item
- pSelectedItem = vconf_get_str(VCONFKEY_NFC_PREDEFINED_ITEM);
- SysTryReturnVoidResult(NID_NET_NFC, pSelectedItem != null, E_SYSTEM,
- "[E_SYSTEM] Failed to get the selected item among the item list.");
-
- selectedItemStr = String(pSelectedItem);
- free(pSelectedItem);
+ selectedItemStr = GetSelectedMessageAppId();
SysLog(NID_NET_NFC, "Try to send the reserved NDEF message (ID: %ls) to the detected peer device...",
selectedItemStr.GetPointer());
SysLog(NID_NET_NFC, "Sending the reserved NDEF message is successfully started.");
}
+Tizen::Base::String
+NfcMessagePushDelegate::GetSelectedMessageAppId(void)
+{
+ unique_ptr<char, _CharDeleter> pAppIdStr;
+
+ // get the value for the predefined item
+ pAppIdStr.reset(vconf_get_str(VCONFKEY_NFC_PREDEFINED_ITEM));
+ SysTryReturn(NID_NET_NFC, pAppIdStr != null, L"", E_SYSTEM, "[E_SYSTEM] Failed to get the selected app ID from vconf.");
+
+ return String(pAppIdStr.get()); // free 'pSelectedItem' after return
+}
+
+result
+NfcMessagePushDelegate::GetSelectedMessageMetadata(Tizen::Base::String& appName, Tizen::Base::String& iconPath,
+ Tizen::Base::String& description)
+{
+ Database rsvdPushDb;
+ const wchar_t* _QUERY_ITEM_SQL = L"SELECT PkgName, IconPath, MsgDesc FROM NfcPushMsgTable WHERE AppId = ?";
+ result r = E_SUCCESS;
+ unique_ptr<DbStatement> pQueryStmt;
+ unique_ptr<DbEnumerator> pQueryEnum;
+
+ r = rsvdPushDb.Construct(NfcMessageRegisterService::_META_DATA_DB_NAME, true);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Construction of the database has failed.");
+
+ pQueryStmt.reset(rsvdPushDb.CreateStatementN(_QUERY_ITEM_SQL));
+ pQueryStmt->BindString(0, GetSelectedMessageAppId());
+
+ pQueryEnum.reset(rsvdPushDb.ExecuteStatementN(*pQueryStmt));
+ r = GetLastResult();
+ SysTryReturnResult(NID_NET_NFC, (r == E_SUCCESS) && (pQueryEnum != null), E_SYSTEM,
+ "Query to get a row from the DB has failed. It is origianted from [%s].", GetErrorMessage(r));
+
+ String resPkgName;
+ String resIconPath;
+ String resMsgDesc;
+
+ r = pQueryEnum->MoveNext();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM,
+ "Query to get a row from the DB has failed. It is origianted from [%s].", GetErrorMessage(r));
+
+ r = pQueryEnum->GetStringAt(0, resPkgName);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Getting PkgName from DB has failed.");
+
+ r = pQueryEnum->GetStringAt(1, resIconPath);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Getting IconPath from DB has failed.");
+
+ r = pQueryEnum->GetStringAt(2, resMsgDesc);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Getting MsgDesc from DB has failed.");
+
+ appName = resPkgName;
+ iconPath = resIconPath;
+ description = resMsgDesc;
+
+ return E_SUCCESS;
+}
+
void
-NfcMessagePushDelegate::InvokeNfcPushUiAppControl(const String& iconPath, const String& appName, const String& description)
+NfcMessagePushDelegate::InvokeNfcPushUiAppControl(void)
{
result r = E_SUCCESS;
- std::unique_ptr<ArrayList> pDataList;
- std::unique_ptr<String> pData1;
- std::unique_ptr<String> pData2;
- std::unique_ptr<String> pData3;
std::unique_ptr<AppControl> pAc;
+ String iconPath;
+ String appName;
+ String description;
- // array list for args
- pDataList.reset(new (std::nothrow) ArrayList());
- SysTryReturnVoidResult(NID_NET_NFC, pDataList != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
- r = pDataList->Construct();
- SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r, "[%s] An unexpected error has occurred.", GetErrorMessage(r));
+ r = GetSelectedMessageMetadata(appName, iconPath, description);
+ SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
- // iconPath
- pData1.reset(new (std::nothrow) String(L"iconPath:"));
- SysTryReturnVoidResult(NID_NET_NFC, pData1 != null, E_OUT_OF_MEMORY, "Insufficient memory.");
- r = pData1->Append(iconPath);
- SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r,
- "[%s] exception occurred. Failed to make a parameter for icon path.", GetErrorMessage(r));
- r = pDataList->Add(*pData1);
- SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r,
- "[%s] exception occurred. Failed to make a parameter for icon path.", GetErrorMessage(r));
+ HashMap map(SingleObjectDeleter);
- // appName
- pData2.reset(new (std::nothrow) String(L"appName:"));
- SysTryReturnVoidResult(NID_NET_NFC, pData2 != null, E_OUT_OF_MEMORY, "[%s] Insufficient memory.", GetErrorMessage(r));
- r = pData2->Append(appName);
- SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r,
- "[%s] exception occurred. Failed to make a parameter for app name.", GetErrorMessage(r));
- r = pDataList->Add(*pData2);
- SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r,
- "[%s] exception occurred. Failed to make a parameter for app name.", GetErrorMessage(r));
+ // hash map
+ r = map.Construct();
+ SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r, "[%s] Failed to construct a hash map.", GetErrorMessage(r));
+
+ // iconPath
+ r = map.Add(new String(L"iconPath"), new String(iconPath));
+ SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r, "[%s] Failed to add a icon path to the hash map.", GetErrorMessage(r));
// description
- pData3.reset(new (std::nothrow) String(L"description:"));
- SysTryReturnVoidResult(NID_NET_NFC, pData3 != null, r = E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
- r = pData3->Append(description);
- SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r,
- "[%s] exception occurred. Failed to make a parameter for description.", GetErrorMessage(r));
- r = pDataList->Add(*pData3);
- SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r,
- "[%s] exception occurred. Failed to make a parameter for description.", GetErrorMessage(r));
+ r = map.Add(new String(L"description"), new String(description));
+ SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r, "[%s] Failed to add a description to the hash map.", GetErrorMessage(r));
// find app control
- pAc.reset(AppManager::FindAppControlN(_NFC_PUSH_UI_AC_PROVIDER_ID, _NFC_PUSH_UI_AC_OPERATION_ID));
+ pAc.reset(AppManager::FindAppControlN(_NFC_PUSH_UI_AC_APP_ID, _NFC_PUSH_UI_AC_OPERATION_ID));
SysTryReturnVoidResult(NID_NET_NFC, pAc != null, GetLastResult(),
"[%s] exception occurred. Failed to find app control.", GetErrorMessage(GetLastResult()));
// start app control
- r = pAc->Start(pDataList.get(), this);
+ r = pAc->Start(null, null, &map, this);
SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r,
"[%s] exception occurred. Failed to start app control", GetErrorMessage(r));
// set p2p target handle
pDelegate->__p2pTargetHandle = target;
- ////////////////////////////////////////////////////////////////////////////////
- // TODO. invoke app control. This should uncommented soon.
- ////////////////////////////////////////////////////////////////////////////////
- // SysLog(NID_NET_NFC, "invoking app control...");
- // pDelegate->InvokeNfcPushUiAppControl(L"temporary/icon/path/", L"app name", L"this is app description.");
- ////////////////////////////////////////////////////////////////////////////////
+ // invoking nfc-push-ui-app-control
+ pDelegate->InvokeNfcPushUiAppControl();
}
}
else if (type == NFC_DISCOVERED_TYPE_DETACHED)
"[E_SYSTEM] the vconf key name is not about the state for Reserved Push.");
pDelegate = static_cast<NfcMessagePushDelegate*>(pUserData);
- pDelegate->UpdatePushEnabled();
+ pDelegate->RefreshReservedPushEnabled();
}
void
}
void
-NfcMessagePushDelegate::OnAppControlCompleted(const Tizen::Base::String& providerId, const Tizen::Base::String& operationId, const Tizen::Base::Collection::IList* pResultList)
+NfcMessagePushDelegate::OnAppControlCompleteResponseReceived(const AppId& appId, const Tizen::Base::String& operationId,
+ AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
{
- result r = E_SUCCESS;
- String* pAppControlResult = null;
-
- if (providerId == _NFC_PUSH_UI_AC_PROVIDER_ID && operationId == _NFC_PUSH_UI_AC_OPERATION_ID)
+ if (operationId == _NFC_PUSH_UI_AC_OPERATION_ID)
{
- SysTryReturnVoidResult(NID_NET_NFC, pResultList != null, E_OPERATION_FAILED,
- "[E_OPERATION_FAILED] NfcPushUi app control completed. But no result come.");
-
- pAppControlResult = (Tizen::Base::String*)(pResultList->GetAt(0));
- SysTryReturnVoidResult(NID_NET_NFC, pAppControlResult != null, E_OPERATION_FAILED,
- "[E_OPERATION_FAILED] There is no result in the array list.");
-
// check the app control result
- if (pAppControlResult->Equals(APPCONTROL_RESULT_SUCCEEDED))
+ if (appControlResult == APP_CTRL_RESULT_SUCCEEDED)
{
- SysLog(NID_NET_NFC, "APPCONTROL_RESULT_SUCCEEDED was come.");
+ SysLog(NID_NET_NFC, "Succeeded to launch nfc-push-ui-app-control.");
+
SysTryReturnVoidResult(NID_NET_NFC, __p2pTargetHandle != null, E_OPERATION_FAILED,
- "[E_OPERATION_FAILED] There is no attached device.");
+ "But there is no attached device.");
// send reserved NDEF message
SendReservedMessage(__p2pTargetHandle);
- r = GetLastResult();
+ result r = GetLastResult();
SysTryReturnVoidResult(NID_NET_NFC, r == E_SUCCESS, r,
- "[%s] Sending of the reserved push message file has failed.", GetErrorMessage(r));
- }
- else if (pAppControlResult->Equals(APPCONTROL_RESULT_CANCELED))
- {
- SysLog(NID_NET_NFC, "APPCONTROL_RESULT_CANCELED was come.");
- }
- else if (pAppControlResult->Equals(APPCONTROL_RESULT_FAILED))
- {
- SysLog(NID_NET_NFC, "APPCONTROL_RESULT_FAILED was come.");
+ "[%s] Failed to send the reserved push message file.", GetErrorMessage(r));
}
+ // ignore other cases
}
}
+
+void
+NfcMessagePushDelegate::OnAppControlStartResponseReceived(const AppId& appId, const Tizen::Base::String& operationId, result r)
+{
+}
#include <FBaseSysLog.h>
#include <FBaseByteBuffer.h>
#include <FBaseRtMutexGuard.h>
+#include <FBaseColHashMap.h>
#include <FAppPkgPackageInfo.h>
#include <FIoFile.h>
#include <FIoDbStatement.h>
const wchar_t* NfcMessageRegisterService::_PUSH_MESSAGE_DIRECTORY = L"/opt/usr/share/nfcpush/";
const wchar_t* NfcMessageRegisterService::_PUSH_MESSAGE_EXT_NAME = L".ndef";
+struct _CharDeleter
+{
+ void operator()(char* pChar)
+ {
+ free(pChar);
+ }
+};
+
NfcMessageRegisterService::NfcMessageRegisterService(void)
: __rsvdPushDb()
- , __appIdListMutex()
- , __reserverAppIdList()
+ , __listMutex()
+ , __reserverList()
{
}
{
result r = E_SUCCESS;
- r = __appIdListMutex.Create();
+ r = __listMutex.Create();
SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to create a mutex.");
r = InitializeAppIdList();
}
result
-NfcMessageRegisterService::RegisterPushMessage(const Tizen::Base::String& appId, const Tizen::Base::ByteBuffer& pushMessageBuffer,
- const Tizen::Base::String& description)
+NfcMessageRegisterService::RegisterPushMessage(const Tizen::Base::String& appPkgId,
+ const Tizen::Base::ByteBuffer& pushMessageBuffer, const Tizen::Base::String& description)
{
// SQL to insert if the appid exists in the table or replace otherwise.
const wchar_t* _INSERT_ROW_SQL = L"INSERT OR REPLACE INTO NfcPushMsgTable \
PackageInfo* pPackageInfo = null;
String appName;
String appIconPath;
- char* pAppIdStr = null;
- int vconfRes = -1;
- // make the push message file path which consists of the directory path, appId as the name, and "ndef" as the extension.
- msgFilePath = _PUSH_MESSAGE_DIRECTORY + appId + _PUSH_MESSAGE_EXT_NAME;
+ // make the push message file path which consists of the directory path, appPkgId as the name, and "ndef" as the extension.
+ msgFilePath = _PUSH_MESSAGE_DIRECTORY + appPkgId + _PUSH_MESSAGE_EXT_NAME;
// get the app name and icon path from the package manager
- pPackageInfo = _PackageManagerImpl::GetInstance()->GetPackageInfoN(appId);
+ pPackageInfo = _PackageManagerImpl::GetInstance()->GetPackageInfoN(appPkgId);
SysTryReturnResult(NID_NET_NFC, pPackageInfo != null, E_SYSTEM, "Getting package information has failed.");
appName = pPackageInfo->GetDisplayName();
delete pPackageInfo;
- MutexGuard locked(__appIdListMutex);
+ MutexGuard locked(__listMutex);
// If the push message of the specified app already exists, it is updated by the new message.
// Otherwise, a new push message file is created.
__rsvdPushDb.BeginTransaction();
pInsertStmt.reset(__rsvdPushDb.CreateStatementN(_INSERT_ROW_SQL));
- pInsertStmt->BindString(0, appId);
+ pInsertStmt->BindString(0, appPkgId);
pInsertStmt->BindString(1, appName);
pInsertStmt->BindString(2, appIconPath);
pInsertStmt->BindString(3, description);
pInsertEnum.reset(__rsvdPushDb.ExecuteStatementN(*pInsertStmt));
r = GetLastResult();
SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM,
- "[E_SYSTEM] derived from [%s]. Insertion a new row to the DB has failed.", GetErrorMessage(r));
+ "Insertion a new row to the DB has failed. It is origianted from [%s].", GetErrorMessage(r));
__rsvdPushDb.CommitTransaction();
// The application ID is added to the list
- if (!__reserverAppIdList.Contains(appId))
+ if (!__reserverList.Contains(appPkgId))
{
- r = __reserverAppIdList.Add(appId);
+ r = __reserverList.Add(appPkgId);
SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Insertion a new app ID to the list has failed.");
- // Modify vconf - the selected item - value if the new message (appId) becomes the first element of the list
- if (__reserverAppIdList.GetCount() == 1)
+ // Modify vconf - the selected item - value if the new message (appPkgId) becomes the first element of the list
+ if (__reserverList.GetCount() == 1)
{
- pAppIdStr = _StringConverter::CopyToCharArrayN(appId);
- SysTryReturnResult(NID_NET_NFC, pAppIdStr != null, E_SYSTEM, "Failed set the Predefined Item value (vconf).");
-
- vconfRes = vconf_set_str(VCONFKEY_NFC_PREDEFINED_ITEM, pAppIdStr);
- delete[] pAppIdStr;
- SysTryReturnResult(NID_NET_NFC, vconfRes == 0, E_SYSTEM, "Failed to set the Predefined Item value (vconf).");
- SysLog(NID_NET_NFC, "The NDEF message of (AppId: %ls) is chosen initially for the Reserved Push.",
- appId.GetPointer());
+ r = PickReservedPushMessage(appPkgId);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
}
}
- locked.Unlock();
-
return r;
}
result
-NfcMessageRegisterService::UnregisterPushMessage(const Tizen::Base::String& appId)
+NfcMessageRegisterService::UnregisterPushMessage(const Tizen::Base::String& appPkgId)
{
const wchar_t* _DELETE_ROW_SQL = L"DELETE FROM NfcPushMsgTable WHERE AppId = ?";
result r = E_SUCCESS;
String msgFilePath;
- DbStatement* pDeleteStmt = null;
- DbEnumerator* pDeleteEnum = null;
- char* pCurrentItemStr = null;
- int vconfRes = -1;
+ unique_ptr<DbStatement> pDeleteStmt;
+ unique_ptr<DbEnumerator> pDeleteEnum;
- // make the push message file path which consists of the directory path, appId as the name, and "ndef" as the extension.
- msgFilePath = _PUSH_MESSAGE_DIRECTORY + appId + _PUSH_MESSAGE_EXT_NAME;
+ // make the push message file path which consists of the directory path, appPkgId as the name, and "ndef" as the extension.
+ msgFilePath = _PUSH_MESSAGE_DIRECTORY + appPkgId + _PUSH_MESSAGE_EXT_NAME;
- MutexGuard locked(__appIdListMutex);
+ MutexGuard locked(__listMutex);
// remove the push message file.
if (File::IsFileExist(msgFilePath))
// The application ID and message description is removed from the DB
__rsvdPushDb.BeginTransaction();
- pDeleteStmt = __rsvdPushDb.CreateStatementN(_DELETE_ROW_SQL);
- pDeleteStmt->BindString(0, appId);
+ pDeleteStmt.reset(__rsvdPushDb.CreateStatementN(_DELETE_ROW_SQL));
+ pDeleteStmt->BindString(0, appPkgId);
- pDeleteEnum = __rsvdPushDb.ExecuteStatementN(*pDeleteStmt);
+ pDeleteEnum.reset(__rsvdPushDb.ExecuteStatementN(*pDeleteStmt));
if (pDeleteEnum == null)
{
r = GetLastResult();
__rsvdPushDb.CommitTransaction();
// The application ID is removed from the list
- if (__reserverAppIdList.Contains(appId))
+ if (__reserverList.Contains(appPkgId))
{
- r = __reserverAppIdList.Remove(appId);
+ r = __reserverList.Remove(appPkgId);
SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Removing the specific app ID from the list has failed.");
- // Checks the removed item is the currently selected item.
- pCurrentItemStr = vconf_get_str(VCONFKEY_NFC_PREDEFINED_ITEM);
- SysTryReturnResult(NID_NET_NFC, pCurrentItemStr != null, E_SYSTEM, "Failed to get the Predefined Item value (vconf).");
+ // Checks the removed app ID is the currently selected app ID.
+ unique_ptr<char, _CharDeleter> pSelectedAppIdStr(vconf_get_str(VCONFKEY_NFC_PREDEFINED_ITEM));
+ SysTryReturnResult(NID_NET_NFC, pSelectedAppIdStr != null, E_SYSTEM, "Failed to get the selected App ID from vconf.");
- if (appId.Equals(String(pCurrentItemStr)))
+ if (appPkgId.Equals(String(pSelectedAppIdStr.get())))
{
- if (__reserverAppIdList.GetCount() <= 0)
- {
- // Especially, if no more element in the list, set the value by "None"
- vconfRes = vconf_set_str(VCONFKEY_NFC_PREDEFINED_ITEM, "None");
- SysTryReturnResult(NID_NET_NFC, vconfRes == 0, E_SYSTEM, "Failed set the Predefined Item value (vconf).");
- SysLog(NID_NET_NFC, "The selected NDEF message for the Reserved Push is set to \"None\".");
- }
- else
+ String newAppId(L"None"); // Especially, if no more element in the list, set the value by "None"
+
+ if (__reserverList.GetCount() > 0)
{
// Set the vconf value by the first element of the list if it exists.
- String newItem;
- char* pNewItemStr = null;
- r = __reserverAppIdList.GetAt(0, newItem);
- SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to set the Predefined Item value (vconf).");
-
- pNewItemStr = _StringConverter::CopyToCharArrayN(newItem);
- SysTryReturnResult(NID_NET_NFC, pNewItemStr != null, E_SYSTEM, "Failed set the Predefined Item value (vconf).");
-
- vconfRes = vconf_set_str(VCONFKEY_NFC_PREDEFINED_ITEM, pNewItemStr);
- delete[] pNewItemStr;
- SysTryReturnResult(NID_NET_NFC, vconfRes == 0, E_SYSTEM, "Failed set the Predefined Item value (vconf).");
- SysLog(NID_NET_NFC, "The NDEF message (AppId: %ls) for the Reserved Push is selected.", newItem.GetPointer());
+ __reserverList.GetAt(0, newAppId); // Ignore the result
}
+
+ r = PickReservedPushMessage(newAppId);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
}
+ }
+
+ return r;
+}
+
+result
+NfcMessageRegisterService::GetReservedPushCandidates(Tizen::Base::Collection::HashMap* pCandidates)
+{
+ const wchar_t* _QUERY_ALL_ITEM_SQL = L"SELECT AppId, MsgDesc FROM NfcPushMsgTable";
+ result r = E_SUCCESS;
+ unique_ptr<String> pAppPkgId;
+ unique_ptr<String> pMsgDesc;
+ unique_ptr<DbEnumerator> pQueryEnum;
+
+ pCandidates->Construct();
- free(pCurrentItemStr);
+ pQueryEnum.reset(__rsvdPushDb.QueryN(_QUERY_ALL_ITEM_SQL));
+ r = GetLastResult();
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed get the reserved push candidiates from DB.");
+
+ if (pQueryEnum != null)
+ {
+ while (pQueryEnum->MoveNext() == E_SUCCESS)
+ {
+ pAppPkgId.reset(new (std::nothrow) String());
+ SysTryReturnResult(NID_NET_NFC, pAppPkgId != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+ pMsgDesc.reset(new (std::nothrow) String());
+ SysTryReturnResult(NID_NET_NFC, pMsgDesc != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = pQueryEnum->GetStringAt(0, *pAppPkgId);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed get a reserved push candidate from DB.");
+
+ r = pQueryEnum->GetStringAt(1, *pMsgDesc);
+ SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed get a reserved push candidate from DB.");
+
+ pCandidates->Add(pAppPkgId.release(), pMsgDesc.release());
+ }
}
- delete pDeleteEnum;
- delete pDeleteStmt;
+ return E_SUCCESS;
+}
- locked.Unlock();
+result
+NfcMessageRegisterService::PickReservedPushMessage(const Tizen::Base::String& ownerAppId)
+{
+ int vconfRes = -1;
+ unique_ptr<char, _CharDeleter> pAppIdStr;
- return r;
+ pAppIdStr.reset(_StringConverter::CopyToCharArrayN(ownerAppId));
+ SysTryReturnResult(NID_NET_NFC, pAppIdStr != null, E_SYSTEM, "Failed to set the selected App ID to vconf.");
+
+ // set the value for the predefined item
+ vconfRes = vconf_set_str(VCONFKEY_NFC_PREDEFINED_ITEM, pAppIdStr.get());
+ SysTryReturnResult(NID_NET_NFC, vconfRes == 0, E_SYSTEM, "Failed to set the selected App ID to vconf.");
+
+ SysLog(NID_NET_NFC, "The App ID of the selected Reserved Push message is set to \"%s\".", pAppIdStr.get());
+
+ return E_SUCCESS;
}
void
NfcMessageRegisterService::OnPackageUninstallationCompleted(const Tizen::App::PackageId& packageId, bool uninstallationResult)
{
- if ((__reserverAppIdList.Contains(packageId)) && (uninstallationResult == true))
+ if ((__reserverList.Contains(packageId)) && (uninstallationResult == true))
{
- SysLog(NID_NET_NFC, "The application (ID:%ls) which was reserving the NFC push message is uninstalled.", packageId.GetPointer());
+ SysLog(NID_NET_NFC, "The application (ID:%ls) which was reserving the NFC push message is uninstalled.",
+ packageId.GetPointer());
UnregisterPushMessage(packageId);
}
}
{
const wchar_t* _CREATE_TABLE_SQL =
L"CREATE TABLE IF NOT EXISTS NfcPushMsgTable ( AppId TEXT PRIMARY KEY, PkgName TEXT, IconPath TEXT, MsgDesc TEXT )";
- const wchar_t* _QUERY_ALL_ITEM_SQL = L"SELECT * FROM NfcPushMsgTable";
+ const wchar_t* _QUERY_ALL_ITEM_SQL = L"SELECT AppId FROM NfcPushMsgTable";
result r = E_SUCCESS;
DbEnumerator* pQueryEnum = null;
pQueryEnum = __rsvdPushDb.QueryN(_QUERY_ALL_ITEM_SQL);
if (pQueryEnum != null)
{
- String appId;
+ String appPkgId;
while (pQueryEnum->MoveNext() == E_SUCCESS)
{
- appId.Clear();
- r = pQueryEnum->GetStringAt(0, appId);
+ appPkgId.Clear();
+ r = pQueryEnum->GetStringAt(0, appPkgId);
if (r == E_SUCCESS)
{
- r = __reserverAppIdList.Add(appId);
+ r = __reserverList.Add(appPkgId);
if (r == E_SUCCESS)
{
- SysLog(NID_NET_NFC, "There is a reserved push message for app (ID:%ls)", appId.GetPointer());
+ SysLog(NID_NET_NFC, "There is a reserved push message for app ID (%ls)", appPkgId.GetPointer());
}
else
{
- SysLogException(NID_NET_NFC, E_SYSTEM, "[E_SYSTEM] Insertion a new item to the app ID list has failed.");
+ SysLogException(NID_NET_NFC, E_SYSTEM,
+ "[E_SYSTEM] Insertion a new item to the reserved push candidates has failed.");
// continue
}
}
else
{
- SysLogException(NID_NET_NFC, E_SYSTEM, "[E_SYSTEM] Getting the list of app ID from the DB table has failed.");
+ SysLogException(NID_NET_NFC, E_SYSTEM,
+ "[E_SYSTEM] Getting the reserved push candidates from the DB table has failed.");
// continue
}
}
#include <FBaseSysLog.h>
#include <FBaseRtMutexGuard.h>
#include <FAppApp.h>
-#include <FApp_AppManagerImpl.h>
+#include <FApp_AppInfo.h>
#include <FSys_SystemInfoImpl.h>
#include "NfcService.h"
#include "NfcMessageRegisterService.h"
, __pPushDelegate(null)
, __enablingMutex()
, __popupEnabled(false)
- , __serviceDaemonAppId()
+ , __serviceDaemonId()
, __popupDisablerId()
- , __appIdListMutex()
- , __appIdList()
+ , __listMutex()
+ , __appPkgIdList()
{
- __serviceDaemonAppId = App::GetInstance()->GetAppId();
+ __serviceDaemonId = _AppInfo::GetPackageId();
}
NfcService::~NfcService(void)
{
vconf_ignore_key_changed(VCONFKEY_NFC_STATE, OnNfcActivationChanged);
- (void) _AppManagerImpl::GetInstance()->RemoveEventListener(*this);
delete __pRegisterService;
delete __pPushDelegate;
- if (__appIdList.GetCount() > 0)
+ if (__appPkgIdList.GetCount() > 0)
{
(void) nfc_manager_deinitialize();
}
r = __enablingMutex.Create();
SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to create a mutex.");
- r = __appIdListMutex.Create();
+ r = __listMutex.Create();
SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Failed to create a mutex.");
__pRegisterService = new (std::nothrow) NfcMessageRegisterService();
{
SysLog(NID_NET_NFC, "NFC is currently activated.");
// initialize NFC because NFC is already turned on
- r = AddNfcAppId(__serviceDaemonAppId);
+ r = AddNfcAppId(__serviceDaemonId);
SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
}
- // register AppManager event listener for noticing that the managed applications terminate
- r = _AppManagerImpl::GetInstance()->AddEventListener(*this);
- SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Registration of an _IAppManagerEventListener has failed.");
-
// set vconf callback about the NFC activation mode change
vconf_notify_key_changed(VCONFKEY_NFC_STATE, OnNfcActivationChanged, this);
}
result
-NfcService::AddNfcAppId(const Tizen::Base::String& appId)
+NfcService::AddNfcAppId(const Tizen::Base::String& appPkgId)
{
result r = E_SUCCESS;
int nfcRes = NFC_ERROR_NONE;
- MutexGuard locked(__appIdListMutex);
+ MutexGuard locked(__listMutex);
// Initialize NFC client of osp-connectivity-service if the first application initializes its NFC client.
- if (__appIdList.GetCount() == 0)
+ if (__appPkgIdList.GetCount() == 0)
{
nfcRes = nfc_manager_initialize(null, null);
SysTryReturnResult(NID_NET_NFC, nfcRes == NFC_ERROR_NONE, E_SYSTEM, "Initializing NFC has failed. [0x%x]", nfcRes);
}
// Add the ID of the application which initializes Nfc client to the list.
- if (!__appIdList.Contains(appId))
+ if (!__appPkgIdList.Contains(appPkgId))
{
- r = __appIdList.Add(appId);
+ r = __appPkgIdList.Add(appPkgId);
SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, E_SYSTEM, "Insertion a new item to the app ID list has failed.");
}
}
void
-NfcService::RemoveNfcAppId(const Tizen::Base::String& appId)
+NfcService::RemoveNfcAppId(const Tizen::Base::String& appPkgId)
{
result r = E_SUCCESS;
int nfcRes = NFC_ERROR_NONE;
// Deinitialize NFC client if the last application which initialized the NFC is terminated.
- MutexGuard locked(__appIdListMutex);
+ MutexGuard locked(__listMutex);
- if (__appIdList.Contains(appId))
+ if (__appPkgIdList.Contains(appPkgId))
{
- r = __appIdList.Remove(appId);
+ r = __appPkgIdList.Remove(appPkgId);
- if ((r == E_SUCCESS) && (__appIdList.GetCount() == 0))
+ if ((r == E_SUCCESS) && (__appPkgIdList.GetCount() == 0))
{
nfcRes = nfc_manager_deinitialize();
SysTryReturnVoidResult(NID_NET_NFC, nfcRes == NFC_ERROR_NONE, E_SYSTEM,
}
result
-NfcService::SetLaunchPopupEnabled(const Tizen::Base::String& clientAppId, bool enable)
+NfcService::SetLaunchPopupEnabled(const Tizen::Base::String& clientPkgId, bool enable)
{
result r = E_SUCCESS;
int nfcRes = NFC_ERROR_NONE;
if (nfcRes == NFC_ERROR_NONE)
{
__popupEnabled = false;
- __popupDisablerId = clientAppId;
+ __popupDisablerId = clientPkgId;
SysLog(NID_NET_NFC, "Disabling the launch popup is successful.");
}
}
else
{
- if ((__popupEnabled == false) && (__popupDisablerId == clientAppId))
+ if ((__popupEnabled == false) && (__popupDisablerId == clientPkgId))
{
nfcRes = nfc_manager_set_system_handler_enable(true);
}
result
-NfcService::RegisterPushMessage(const Tizen::Base::String& clientAppId, const Tizen::Base::ByteBuffer& pushMessageBuffer,
+NfcService::RegisterPushMessage(const Tizen::Base::String& clientPkgId, const Tizen::Base::ByteBuffer& pushMessageBuffer,
const Tizen::Base::String& description)
{
- return __pRegisterService->RegisterPushMessage(clientAppId, pushMessageBuffer, description);
+ return __pRegisterService->RegisterPushMessage(clientPkgId, pushMessageBuffer, description);
}
result
-NfcService::UnregisterPushMessage(const Tizen::Base::String& clientAppId)
+NfcService::UnregisterPushMessage(const Tizen::Base::String& clientPkgId)
{
- return __pRegisterService->UnregisterPushMessage(clientAppId);
+ return __pRegisterService->UnregisterPushMessage(clientPkgId);
}
-void
-NfcService::OnApplicationLaunched(const Tizen::App::AppId& appId, Tizen::App::_AppType type)
+result
+NfcService::ActivateReservedPush(void)
+{
+ return __pPushDelegate->SetReservedPushEnabled(true);
+}
+
+result
+NfcService::DeactivateReservedPush(void)
+{
+ return __pPushDelegate->SetReservedPushEnabled(false);
+}
+
+bool
+NfcService::IsReservedPushActivated(void)
{
- // do nothing.
+ return __pPushDelegate->IsReservedPushEnabled();
+}
+
+result
+NfcService::GetReservedPushCandidates(Tizen::Base::Collection::HashMap* pCandidates)
+{
+ return __pRegisterService->GetReservedPushCandidates(pCandidates);
+}
+
+result
+NfcService::PickReservedPushMessage(const Tizen::Base::String& appId)
+{
+ return __pRegisterService->PickReservedPushMessage(appId);
+}
+
+result
+NfcService::GetPickedReservedPushMessage(Tizen::Base::String& appId)
+{
+ appId = __pPushDelegate->GetSelectedMessageAppId();
+
+ return GetLastResult();
}
void
-NfcService::OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen::App::_AppType type)
+NfcService::ProcessAppTermination(const Tizen::Base::String& clientPkgId)
{
int nfcRes = NFC_ERROR_NONE;
MutexGuard locked(__enablingMutex);
- if ((__popupEnabled == false) && (__popupDisablerId == appId))
+ if ((__popupEnabled == false) && (__popupDisablerId == clientPkgId))
{
- SysLog(NID_NET_NFC, "The application (ID:'%S') which disabled the launch popup is terminated.", appId.GetPointer());
+ SysLog(NID_NET_NFC, "The application (ID:'%S') which disabled the launch popup is terminated.", clientPkgId.GetPointer());
nfcRes = nfc_manager_set_system_handler_enable(true);
locked.Unlock();
// Remove appId if it was added to the list.
- RemoveNfcAppId(appId);
+ RemoveNfcAppId(clientPkgId);
}
void
if (nfcState == VCONFKEY_NFC_STATE_ON)
{
- pService->AddNfcAppId(pService->__serviceDaemonAppId);
+ pService->AddNfcAppId(pService->__serviceDaemonId);
}
else if (nfcState == VCONFKEY_NFC_STATE_OFF)
{
- pService->RemoveNfcAppId(pService->__serviceDaemonAppId);
+ pService->RemoveNfcAppId(pService->__serviceDaemonId);
}
// ignore other cases
}
pTempPhoneNumber.reset(_StringConverter::CopyToCharArrayN(phoneNumber));
SysTryReturnResult(NID_TEL, pTempPhoneNumber != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
- strcpy(forwardInfo.szPhoneNumber, pTempPhoneNumber.get());
+ strcpy(reinterpret_cast<char*>(forwardInfo.szPhoneNumber), pTempPhoneNumber.get());
err = tel_set_ss_forward(__pHandle, &forwardInfo, OnCallForwardResponseReceivedCallback, pClientId);
SysLog(NID_TEL, "The forwardInfo.szPhoneNumber is %s and err value is 0x%x", forwardInfo.szPhoneNumber, err);
SysTryReturnResult(NID_TEL, err == TAPI_SS_SUCCESS, E_SYSTEM, "Failed to request a call forwarding.");
String
TelephonyService::MakeNetworkInfoMessage(TelNetworkIdentity_t& info)
{
- SysLog(NID_TEL, "SLP info plmn : %d, networkName : %s, system type : %d", info.plmn_id, info.network_name, info.access_technology);
+ SysLog(NID_TEL, "SLP info plmn : %s, networkName : %s, system type : %d", info.plmn, info.network_name, info.access_technology);
- String plmn;
- plmn.Append(static_cast<int>(info.plmn_id));
+ String plmn(info.plmn);
String networkName;
networkName.Append(info.network_name);
* @brief This is the implementation file for the %WifiConnectivityIpcStub class.
*/
+#include <unique_ptr.h>
#include <FBaseSysLog.h>
#include <FNetWifiWifiBssInfo.h>
#include <FIo_IpcServer.h>
WifiConnectivityIpcStub::~WifiConnectivityIpcStub(void)
{
-
+ delete __pIpcServer;
+ delete __pWifiService;
+ delete __pWifiProximityService;
}
result
WifiConnectivityIpcStub::Construct(void)
{
result r = E_SUCCESS;
+ unique_ptr<WifiService> pWifiService;
+ unique_ptr<_IpcServer> pIpcServer;
+ unique_ptr<WifiProximityService> pWifiProximityService;
- unique_ptr<WifiService> pWifiService(new (std::nothrow) WifiService());
+ pWifiService.reset(new (std::nothrow) WifiService());
SysTryReturnResult(NID_NET_WIFI, pWifiService != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
r = pWifiService->Construct();
-
if (r == E_SUCCESS)
{
- __pWifiService = move(pWifiService);
SysLog(NID_NET_WIFI, "WifiService is created.");
- unique_ptr<WifiProximityService> pWifiProximityService(new (std::nothrow) WifiProximityService());
+ pWifiProximityService.reset(new (std::nothrow) WifiProximityService());
SysTryReturnResult(NID_NET_WIFI, pWifiProximityService != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
r = pWifiProximityService->Construct(this);
-
if (r == E_SUCCESS)
{
- __pWifiProximityService = move(pWifiProximityService);
SysLog(NID_NET_WIFI, "WifiProximityService is created.");
}
else
{
- // skip WifiProximity service
+ // ignore the failure of creating the Wi-Fi Proximity service
SysLogException(NID_NET_WIFI, r, "[%s] Failed to construct WifiProximityService.", GetErrorMessage(r));
+ pWifiProximityService.reset(null);
}
}
else
{
- // skip Wifi/WifiDirect service
+ // ignore the failure of creating the Wi-Fi service
SysLogException(NID_NET_WIFI, r, "[%s] Failed to construct WifiService.", GetErrorMessage(r));
+ pWifiService.reset(null);
}
- unique_ptr<_IpcServer> pIpcServer(new (std::nothrow) _IpcServer());
+ pIpcServer.reset(new (std::nothrow) _IpcServer());
SysTryReturnResult(NID_NET_WIFI, pIpcServer != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
r = pIpcServer->Construct(WIFI_CONNECTIVITY_IPC_SERVER_NAME, *this);
- SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_SYSTEM,
- "[%s] A system error has been occurred. Failed to construct IpcServer.", GetErrorMessage(E_SYSTEM));
+ SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_SYSTEM, "Failed to construct IpcServer.");
- __pIpcServer = move(pIpcServer);
+ __pWifiService = pWifiService.release();
+ __pWifiProximityService = pWifiProximityService.release();
+ __pIpcServer = pIpcServer.release();
return E_SUCCESS;
}
{
SysLog(NID_NET_WIFI, "Disconnected with clientId[%d].", clientId);
+ if (__pWifiService != null)
+ {
+ __pWifiService->ProcessAppTermination(__pIpcServer->GetClientAppId());
+ }
+
if (__pWifiProximityService != null)
{
__pWifiProximityService->UnregisterClient(clientId);
WifiConnectivityIpcStub::OnSetWifiSystemScanMode(int mode, unsigned long* pResult)
{
#if !defined (_OSP_EMUL_)
- SysLog(NID_NET_WIFI, "Received the request of setting the Wi-Fi system scan mode with clientId : %d, AppId : %ls",
- __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+ String packageId = __pIpcServer->GetClientAppId();
+
+ SysLog(NID_NET_WIFI, "Received the request of setting the Wi-Fi system scan mode with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), packageId.GetPointer());
- *pResult = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_WIFIMANAGER);
+ *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_WIFIMANAGER);
if (*pResult != E_SUCCESS)
{
*pResult = E_PRIVILEGE_DENIED;
SysLogException(NID_NET_WIFI, E_PRIVILEGE_DENIED,
- "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+ "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
}
else if (__pWifiService == null)
{
WifiConnectivityIpcStub::OnCheckWifiSystemSettingPrivilege(unsigned long* pResult)
{
#if !defined (_OSP_EMUL_)
- SysLog(NID_NET_WIFI, "Received the request of checking the Wi-Fi system setting privilege with clientId : %d, AppId : %ls",
- __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+ String packageId = __pIpcServer->GetClientAppId();
+
+ SysLog(NID_NET_WIFI, "Received the request of checking the Wi-Fi system setting privilege with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), packageId.GetPointer());
- *pResult = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_WIFIMANAGER);
+ *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_WIFIMANAGER);
if (*pResult != E_SUCCESS)
{
*pResult = E_PRIVILEGE_DENIED;
SysLogException(NID_NET_WIFI, E_PRIVILEGE_DENIED,
- "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+ "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
}
#else
SysLog(NID_NET_WIFI, "Invalid Operation because Wi-Fi is unavailable on the emulator.");
WifiConnectivityIpcStub::OnUpdateWifiBssInfo(const Tizen::Net::Wifi::WifiBssInfo& bssInfo, unsigned long* pResult)
{
#if !defined (_OSP_EMUL_)
- SysLog(NID_NET_WIFI, "Received the request of updating the Wi-Fi BSS info with clientId : %d, AppId : %ls",
- __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+ String packageId = __pIpcServer->GetClientAppId();
+
+ SysLog(NID_NET_WIFI, "Received the request of updating the Wi-Fi BSS info with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), packageId.GetPointer());
- *pResult = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_WIFIMANAGER);
+ *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_WIFIMANAGER);
if (*pResult != E_SUCCESS)
{
*pResult = E_PRIVILEGE_DENIED;
SysLogException(NID_NET_WIFI, E_PRIVILEGE_DENIED,
- "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+ "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
}
else if (__pWifiService == null)
{
WifiConnectivityIpcStub::OnInitializeWifiDirect(unsigned long* pResult)
{
#if !defined (_OSP_EMUL_)
- SysLog(NID_NET_WIFI, "Received the request of initializing the Wi-Fi Direct with clientId : %d, AppId : %ls",
- __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+ String packageId = __pIpcServer->GetClientAppId();
+
+ SysLog(NID_NET_WIFI, "Received the request of initializing the Wi-Fi Direct with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), packageId.GetPointer());
if (__pWifiService == null)
{
}
else
{
- *pResult = __pWifiService->Initialize(__pIpcServer->GetClientAppId());
+ *pResult = __pWifiService->Initialize(packageId);
}
#else
SysLog(NID_NET_WIFI, "Invalid Operation because Wi-Fi Direct is unavailable on the emulator.");
WifiConnectivityIpcStub::OnGetWifiDirectLocalDeviceName(Tizen::Base::String* pLocalName, unsigned long* pResult)
{
#if !defined (_OSP_EMUL_)
- SysLog(NID_NET_WIFI, "Received the request of getting the local device name with clientId : %d, AppId : %ls",
+ SysLog(NID_NET_WIFI, "Received the request of getting the local device name with clientId : %d, AppPkgId : %ls",
__pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
if (__pWifiService == null)
WifiConnectivityIpcStub::OnSetWifiDirectLocalDeviceName(Tizen::Base::String localName, unsigned long* pResult)
{
#if !defined (_OSP_EMUL_)
- SysLog(NID_NET_WIFI, "Received the request of setting the local device name with clientId : %d, AppId : %ls",
- __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+ String packageId = __pIpcServer->GetClientAppId();
+
+ SysLog(NID_NET_WIFI, "Received the request of setting the local device name with clientId : %d, AppPkgId : %ls",
+ __pIpcServer->GetClientId(), packageId.GetPointer());
if (__pWifiService == null)
{
}
else
{
- *pResult = __pWifiService->SetWifiDirectLocalDeviceName(__pIpcServer->GetClientAppId(), localName);
+ *pResult = __pWifiService->SetWifiDirectLocalDeviceName(packageId, localName);
}
#else
SysLog(NID_NET_WIFI, "Invalid Operation because Wi-Fi Direct is unavailable on the emulator.");
WifiConnectivityIpcStub::OnRegisterBssId(const Tizen::Base::String& bssId, unsigned long* pResult)
{
#if !defined (_OSP_EMUL_)
- SysLog(NID_NET_WIFI, "OnRegisterBssId with clientId : %d, AppId : %ls",
- __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+ int clientId = __pIpcServer->GetClientId();
+
+ SysLog(NID_NET_WIFI, "OnRegisterBssId with clientId : %d, AppPkgId : %ls",
+ clientId, __pIpcServer->GetClientAppId().GetPointer());
if (__pWifiService == null)
{
}
else
{
- *pResult = __pWifiProximityService->RegisterBssId(bssId, __pIpcServer->GetClientId());
+ *pResult = __pWifiProximityService->RegisterBssId(bssId, clientId);
}
#else
SysLog(NID_NET_WIFI, "Invalid Operation because Wi-Fi is unavailable on the emulator.");
WifiConnectivityIpcStub::OnUnregisterBssId(const Tizen::Base::String& bssId, unsigned long* pResult)
{
#if !defined (_OSP_EMUL_)
- SysLog(NID_NET_WIFI, "OnUnregisterBssId with clientId : %d, AppId : %ls",
- __pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
+ int clientId = __pIpcServer->GetClientId();
+
+ SysLog(NID_NET_WIFI, "OnUnregisterBssId with clientId : %d, AppPkgId : %ls",
+ clientId, __pIpcServer->GetClientAppId().GetPointer());
if (__pWifiService == null)
{
}
else
{
- *pResult = __pWifiProximityService->UnregisterBssId(bssId, __pIpcServer->GetClientId());
+ *pResult = __pWifiProximityService->UnregisterBssId(bssId, clientId);
}
#else
SysLog(NID_NET_WIFI, "Invalid Operation because Wi-Fi is unavailable on the emulator.");
WifiConnectivityIpcStub::OnProximityCheckActivated(unsigned long* pResult)
{
#if !defined (_OSP_EMUL_)
- SysLog(NID_NET_WIFI, "OnProximityCheckActivated with clientId : %d, AppId : %ls",
+ SysLog(NID_NET_WIFI, "OnProximityCheckActivated with clientId : %d, AppPkgId : %ls",
__pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
if (__pWifiService == null)
}
else
{
- *pResult = __pWifiProximityService->ActivateProximityCheck(__pIpcServer->GetClientId());
+ *pResult = __pWifiProximityService->ActivateProximityCheck();
}
#else
SysLog(NID_NET_WIFI, "Invalid Operation because Wi-Fi is unavailable on the emulator.");
WifiConnectivityIpcStub::OnProximityCheckDeactivated(unsigned long* pResult)
{
#if !defined (_OSP_EMUL_)
- SysLog(NID_NET_WIFI, "OnProximityCheckDeactivated with clientId : %d, AppId : %ls",
+ SysLog(NID_NET_WIFI, "OnProximityCheckDeactivated with clientId : %d, AppPkgId : %ls",
__pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
if (__pWifiService == null)
}
else
{
- *pResult = __pWifiProximityService->DeactivateProximityCheck(__pIpcServer->GetClientId());
+ *pResult = __pWifiProximityService->DeactivateProximityCheck();
}
#else
SysLog(NID_NET_WIFI, "Invalid Operation because Wi-Fi is unavailable on the emulator.");
WifiConnectivityIpcStub::OnIsProximityCheckActivated(bool* isActivated, unsigned long* pResult)
{
#if !defined (_OSP_EMUL_)
- SysLog(NID_NET_WIFI, "OnIsProximityCheckActivated with clientId : %d, AppId : %ls",
+ SysLog(NID_NET_WIFI, "OnIsProximityCheckActivated with clientId : %d, AppPkgId : %ls",
__pIpcServer->GetClientId(), __pIpcServer->GetClientAppId().GetPointer());
if (__pWifiService == null)
result
WifiProximityService::UnregisterBssId(const Tizen::Base::String& bssId, const int clientId)
{
- result r = E_SUCCESS;
bool contains = false;
bool isDefault = false;
}
result
-WifiProximityService::ActivateProximityCheck(const int clientId)
+WifiProximityService::ActivateProximityCheck(void)
{
result r = E_SUCCESS;
}
result
-WifiProximityService::DeactivateProximityCheck(const int clientId)
+WifiProximityService::DeactivateProximityCheck(void)
{
SysTryReturnResult(NID_NET_WIFI, __isProximityCheckActivated == true, E_INVALID_STATE,
"Proximity checking is already activated.");
#include <FNetIp4Address.h>
#include <FNetWifiWifiTypes.h>
#include <FNetWifiWifiBssInfo.h>
-#include <FApp_AppManagerImpl.h>
#include <FSys_SystemInfoImpl.h>
#include <FBase_StringConverter.h>
#include <FNetWifi_WifiBssInfoImpl.h>
WifiService::WifiService(void)
: __newWifiDirectName()
, __wifiDirectNameChangerId()
- , __appIdListMutex()
- , __appIdList()
+ , __listMutex()
+ , __appPkgIdList()
{
}
WifiService::~WifiService(void)
{
- (void) _AppManagerImpl::GetInstance()->RemoveEventListener(*this);
-
- if (__appIdList.GetCount() > 0)
+ if (__appPkgIdList.GetCount() > 0)
{
(void) wifi_direct_unset_device_state_changed_cb();
(void) wifi_direct_deinitialize();
}
-
- (void)__appIdList.RemoveAll(true);
}
result
SysTryReturnResult(NID_NET_WIFI, (r == E_SUCCESS) && (isWifiDirectSupported == true), E_UNSUPPORTED_OPERATION,
"Wi-Fi Direct is not supported.");
- r = __appIdListMutex.Create();
+ r = __listMutex.Create();
SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_SYSTEM, "Failed to create a mutex.");
- r = _AppManagerImpl::GetInstance()->AddEventListener(*this);
- SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, E_SYSTEM,
- "Registration of an _IAppManagerEventListener has failed.");
-
return E_SUCCESS;
}
}
result
-WifiService::Initialize(const Tizen::Base::String& clientAppId)
+WifiService::Initialize(const Tizen::Base::String& clientPkgId)
{
result r = E_SUCCESS;
int ret = WIFI_DIRECT_ERROR_NONE;
- MutexGuard locked(__appIdListMutex);
+ MutexGuard locked(__listMutex);
// Initialize Wi-Fi Direct client of osp-connectivity-service
// if the first application initializes its Wi-Fi Direct client.
- if (__appIdList.GetCount() == 0)
+ if (__appPkgIdList.GetCount() == 0)
{
ret = wifi_direct_initialize();
SysTryReturnResult(NID_NET_WIFI, ret == WIFI_DIRECT_ERROR_NONE, E_SYSTEM,
}
// Add the ID of the application which initializes Wi-Fi Direct client to the list.
- if (!__appIdList.Contains(clientAppId))
+ if (!__appPkgIdList.Contains(clientPkgId))
{
- r = __appIdList.Add(*(new (std::nothrow) String(clientAppId)));
+ r = __appPkgIdList.Add(clientPkgId);
// Ignore the error result of list operation.
SysTryLog(NID_NET_WIFI, r == E_SUCCESS, "Insertion a new item to the app ID list has failed. (%s)", GetErrorMessage(r));
}
}
result
-WifiService::SetWifiDirectLocalDeviceName(const Tizen::Base::String& clientAppId, const Tizen::Base::String& localName)
+WifiService::SetWifiDirectLocalDeviceName(const Tizen::Base::String& clientPkgId, const Tizen::Base::String& localName)
{
result r = E_SUCCESS;
if (!IsFailed(r))
{
__newWifiDirectName = localName;
- __wifiDirectNameChangerId = clientAppId;
+ __wifiDirectNameChangerId = clientPkgId;
}
}
else
{
__newWifiDirectName = localName;
- __wifiDirectNameChangerId = clientAppId;
+ __wifiDirectNameChangerId = clientPkgId;
SysLog(NID_NET_WIFI, "The input name is reserved as the Wi-Fi Direct local name.");
}
}
void
-WifiService::OnWifiDirectActivated(void)
-{
- // Updates the local Wi-Fi Direct name.
- // This is a reserved action.
- if (__newWifiDirectName.GetLength() > 0)
- {
- (void) UpdateWifiDirectLocalDeviceName(__newWifiDirectName);
- }
-}
-
-void
-WifiService::OnApplicationLaunched(const Tizen::App::AppId& appId, Tizen::App::_AppType type)
-{
- // do nothing.
-}
-
-void
-WifiService::OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen::App::_AppType type)
+WifiService::ProcessAppTermination(const Tizen::Base::String& clientPkgId)
{
char* pPhoneName = null;
String convertedName;
result r = E_SUCCESS;
- if (__wifiDirectNameChangerId == appId)
+ if (__wifiDirectNameChangerId == clientPkgId)
{
SysLog(NID_NET_WIFI, "The application which set the Wi-Fi Direct local name is terminated.");
}
// Deinitialize Wi-Fi Direct client if the last application which initialized Wi-Fi Direct is terminated.
- __appIdListMutex.Acquire();
+ __listMutex.Acquire();
- if (__appIdList.Contains(appId))
+ if (__appPkgIdList.Contains(clientPkgId))
{
- (void) __appIdList.Remove(appId, true);
+ r = __appPkgIdList.Remove(clientPkgId);
- if (__appIdList.GetCount() == 0)
+ if ((r == E_SUCCESS) && (__appPkgIdList.GetCount() == 0))
{
(void) wifi_direct_unset_device_state_changed_cb();
(void) wifi_direct_deinitialize();
}
}
- __appIdListMutex.Release();
+ __listMutex.Release();
+}
+
+void
+WifiService::OnWifiDirectActivated(void)
+{
+ // Updates the local Wi-Fi Direct name.
+ // This is a reserved action.
+ if (__newWifiDirectName.GetLength() > 0)
+ {
+ (void) UpdateWifiDirectLocalDeviceName(__newWifiDirectName);
+ }
}
bool