merge with master
authorJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:16:41 +0000 (01:16 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:16:41 +0000 (01:16 +0900)
29 files changed:
CMakeLists.txt
LICENSE.APLv2.0 [changed mode: 0644->0755]
inc/BluetoothConnectivityIpcStub.h
inc/BluetoothService.h
inc/NetConnectivityIpcStub.h
inc/NetService.h
inc/NfcConnectivityIpcStub.h
inc/NfcMessagePushDelegate.h
inc/NfcMessageRegisterService.h
inc/NfcService.h
inc/WifiConnectivityIpcStub.h
inc/WifiProximityService.h
inc/WifiService.h
manifest.xml
osp-connectivity-service.manifest
osp-connectivity-service.rule [new file with mode: 0644]
packaging/osp-connectivity-service.spec
src/BluetoothConnectivityIpcStub.cpp
src/BluetoothService.cpp
src/NetConnectivityIpcStub.cpp
src/NetService.cpp
src/NfcConnectivityIpcStub.cpp
src/NfcMessagePushDelegate.cpp
src/NfcMessageRegisterService.cpp
src/NfcService.cpp
src/TelephonyService.cpp
src/WifiConnectivityIpcStub.cpp
src/WifiProximityService.cpp
src/WifiService.cpp

index b01f87a..72abc9a 100755 (executable)
@@ -17,6 +17,7 @@ INCLUDE_DIRECTORIES (
        /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
@@ -69,6 +70,11 @@ SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_
 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})
 
@@ -76,8 +82,11 @@ 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)
+
old mode 100644 (file)
new mode 100755 (executable)
index b0f6769..bd54f30 100644 (file)
@@ -42,7 +42,7 @@ class BluetoothService;
  * @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.
  */
index 51463cd..9d644e5 100644 (file)
 
 #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);
@@ -46,14 +44,15 @@ public:
        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);
 
index ed47d43..797d549 100644 (file)
@@ -72,6 +72,8 @@ private:
        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;
index e30ef7e..8e016ee 100644 (file)
@@ -47,6 +47,8 @@ public:
     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);
index 7848297..662f24c 100644 (file)
@@ -42,7 +42,7 @@ class NfcService;
  * @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.
  */
@@ -73,6 +73,12 @@ private:
        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;
index c4d1a40..baeabf7 100644 (file)
@@ -29,7 +29,8 @@
 #include <nfc.h>
 #include <FBaseResult.h>
 #include <FBaseString.h>
-#include <FAppIAppControlEventListener.h>
+#include <FBaseRtMutex.h>
+#include <FAppIAppControlResponseListener.h>
 
 /**
  * @class      NfcMessagePushDelegate
@@ -40,7 +41,7 @@
  * This class represents NFC service of the Connectivity service daemon.
  */
 class NfcMessagePushDelegate
-       : public Tizen::App::IAppControlEventListener
+       : public Tizen::App::IAppControlResponseListener
 {
 public:
        NfcMessagePushDelegate(void);
@@ -48,27 +49,35 @@ public:
 
        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;
 };
 
index d5b84ee..d4f3212 100644 (file)
 #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.
@@ -55,12 +59,15 @@ public:
 
        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) {}
 
@@ -74,8 +81,8 @@ public:
 
 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;
 
 };
 
index 0518196..ce5d0a9 100644 (file)
@@ -29,9 +29,7 @@
 #include <FBaseRtMutex.h>
 #include <FBaseString.h>
 #include <FBaseColLinkedListT.h>
-#include <FApp_IAppManagerEventListener.h>
 
-// forward declarations
 namespace Tizen { namespace Base
 {
 class ByteBuffer;
@@ -44,30 +42,34 @@ class NfcMessagePushDelegate;
  * @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:
@@ -75,10 +77,10 @@ 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;
 
 };
 
index bd412be..b5c39f7 100644 (file)
@@ -25,7 +25,6 @@
 #ifndef _WIFI_CONNECTIVITY_IPC_STUB_H_
 #define _WIFI_CONNECTIVITY_IPC_STUB_H_
 
-#include <unique_ptr.h>
 #include <FBaseObject.h>
 #include <FIo_IIpcServerEventListener.h>
 
@@ -48,7 +47,7 @@ class WifiProximityService;
  * @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.
  */
@@ -93,9 +92,9 @@ private:
        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;
 
 };
 
index de3c039..5a4eb86 100644 (file)
@@ -53,8 +53,8 @@ public:
        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
index 2f7ed2e..e4300e3 100644 (file)
@@ -28,8 +28,7 @@
 #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;
@@ -39,12 +38,11 @@ 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);
@@ -53,17 +51,16 @@ public:
 
        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:
@@ -74,8 +71,8 @@ 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;
 
 };
 
index b2d7226..477632c 100644 (file)
     <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>
index 3620fbd..bce4bf8 100644 (file)
@@ -1,12 +1,11 @@
 <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
diff --git a/osp-connectivity-service.rule b/osp-connectivity-service.rule
new file mode 100644 (file)
index 0000000..98185ba
--- /dev/null
@@ -0,0 +1,2 @@
+57r43275q7 resman::db rw
+
index b1e7657..10bf0b5 100755 (executable)
@@ -71,7 +71,6 @@ mkdir -p /opt/usr/share/nfcpush
 /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
@@ -82,5 +81,6 @@ fi
 
 %files
 %manifest osp-connectivity-service.manifest
+/etc/smack/accesses2.d/osp-connectivity-service.rule
 /usr/share/license/%{name}
 /usr/apps/*
index 875f6b1..fd849c9 100644 (file)
@@ -28,6 +28,7 @@
 #include "BluetoothConnectivityIpcStub.h"
 #include "BluetoothService.h"
 
+using namespace std;
 using namespace Tizen::Base;
 using namespace Tizen::Io;
 using namespace Tizen::Security;
@@ -49,43 +50,34 @@ result
 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
@@ -110,6 +102,11 @@ 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
@@ -126,7 +123,7 @@ 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)
@@ -147,8 +144,10 @@ void
 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)
        {
@@ -156,7 +155,7 @@ BluetoothConnectivityIpcStub::OnSetBluetoothLocalDeviceName(Tizen::Base::String
        }
        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.");
@@ -168,18 +167,18 @@ void
 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)
        {
index 53675be..6477170 100644 (file)
@@ -25,7 +25,6 @@
 #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"
@@ -48,7 +47,6 @@ BluetoothService::~BluetoothService(void)
 {
        (void) bt_deinitialize();
        (void) bt_adapter_unset_state_changed_cb();
-       (void) _AppManagerImpl::GetInstance()->RemoveEventListener(*this);
 }
 
 result
@@ -59,8 +57,8 @@ BluetoothService::Construct(void)
        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
@@ -72,10 +70,6 @@ BluetoothService::Construct(void)
        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;
 }
 
@@ -120,7 +114,7 @@ BluetoothService::GetLocalDeviceName(Tizen::Base::String* pLocalName)
 }
 
 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;
@@ -136,13 +130,13 @@ BluetoothService::SetLocalDeviceName(const Tizen::Base::String& clientAppId, con
                if (!IsFailed(r))
                {
                        __newName = localName;
-                       __nameChangerId = clientAppId;
+                       __nameChangerId = clientPkgId;
                }
        }
        else
        {
                __newName = localName;
-               __nameChangerId = clientAppId;
+               __nameChangerId = clientPkgId;
        }
 
        return r;
@@ -206,13 +200,7 @@ BluetoothService::OnBluetoothAdapterStateChanged(int result, bt_adapter_state_e
 }
 
 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;
@@ -220,7 +208,7 @@ BluetoothService::OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen:
        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.");
 
index a60e7fc..d76675c 100644 (file)
@@ -107,6 +107,8 @@ NetConnectivityIpcStub::OnIpcRequestReceived(Tizen::Io::_IpcServer& server, cons
        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()
 }
 
@@ -229,3 +231,47 @@ NetConnectivityIpcStub::OnUpdateSystemNetAccount(const String& profileName, cons
         *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);
+       }
+}
index bcf7243..218267f 100644 (file)
@@ -47,36 +47,14 @@ result
 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
        {
@@ -140,6 +118,119 @@ NetService::UpdateSystemNetAccount(const String& profileName, const NetAccountIn
        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)
 {
@@ -170,9 +261,9 @@ 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);
index 19a3143..40feed8 100644 (file)
@@ -28,6 +28,7 @@
 #include "NfcConnectivityIpcStub.h"
 #include "NfcService.h"
 
+using namespace std;
 using namespace Tizen::Base;
 using namespace Tizen::Io;
 using namespace Tizen::Security;
@@ -49,42 +50,34 @@ result
 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
@@ -109,6 +102,11 @@ 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
@@ -119,15 +117,22 @@ NfcConnectivityIpcStub::OnIpcRequestReceived(Tizen::Io::_IpcServer& server, cons
        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)
        {
@@ -135,15 +140,17 @@ NfcConnectivityIpcStub::OnInitializeNfc(unsigned long* pResult)
        }
        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)
        {
@@ -151,7 +158,7 @@ NfcConnectivityIpcStub::OnSetNfcLaunchPopupEnabled(bool enable, unsigned long* p
        }
        else
        {
-               *pResult = __pNfcService->SetLaunchPopupEnabled(__pIpcServer->GetClientAppId(), enable);
+               *pResult = __pNfcService->SetLaunchPopupEnabled(packageId, enable);
        }
 }
 
@@ -159,8 +166,10 @@ void
 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)
        {
@@ -168,14 +177,100 @@ NfcConnectivityIpcStub::OnRegisterNfcPushMessage(const Tizen::Base::ByteBuffer&
        }
        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)
@@ -184,7 +279,48 @@ NfcConnectivityIpcStub::OnUnregisterNfcPushMessage(unsigned long* pResult)
        }
        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);
+       }
+}
index 68ca4bb..a88f794 100644 (file)
 #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
@@ -58,10 +64,13 @@ 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);
@@ -87,13 +96,40 @@ NfcMessagePushDelegate::Deinitialize(void)
        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.");
@@ -163,16 +199,9 @@ NfcMessagePushDelegate::SendReservedMessage(nfc_p2p_target_h targetH)
        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());
 
@@ -217,59 +246,96 @@ NfcMessagePushDelegate::SendReservedMessage(nfc_p2p_target_h targetH)
        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));
 
@@ -292,12 +358,8 @@ NfcMessagePushDelegate::OnNfcDeviceDiscovered(nfc_discovered_type_e type, nfc_p2
                        // 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)
@@ -326,7 +388,7 @@ NfcMessagePushDelegate::OnNfcReservedPushStateChanged(keynode_t* pKeyNode, void*
                        "[E_SYSTEM] the vconf key name is not about the state for Reserved Push.");
 
        pDelegate = static_cast<NfcMessagePushDelegate*>(pUserData);
-       pDelegate->UpdatePushEnabled();
+       pDelegate->RefreshReservedPushEnabled();
 }
 
 void
@@ -339,40 +401,30 @@ NfcMessagePushDelegate::OnNdefMessageSent(nfc_error_e res, void* pUserData)
 }
 
 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)
+{
+}
index b737d0c..0f8d213 100644 (file)
@@ -26,6 +26,7 @@
 #include <FBaseSysLog.h>
 #include <FBaseByteBuffer.h>
 #include <FBaseRtMutexGuard.h>
+#include <FBaseColHashMap.h>
 #include <FAppPkgPackageInfo.h>
 #include <FIoFile.h>
 #include <FIoDbStatement.h>
@@ -46,10 +47,18 @@ const wchar_t* NfcMessageRegisterService::_META_DATA_DB_NAME = L"/opt/usr/dbspac
 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()
 {
 }
 
@@ -63,7 +72,7 @@ NfcMessageRegisterService::Construct(void)
 {
        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();
@@ -77,8 +86,8 @@ NfcMessageRegisterService::Construct(void)
 }
 
 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 \
@@ -91,14 +100,12 @@ NfcMessageRegisterService::RegisterPushMessage(const Tizen::Base::String& appId,
     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();
@@ -106,7 +113,7 @@ NfcMessageRegisterService::RegisterPushMessage(const Tizen::Base::String& appId,
 
        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.
@@ -122,7 +129,7 @@ NfcMessageRegisterService::RegisterPushMessage(const Tizen::Base::String& appId,
        __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);
@@ -130,50 +137,40 @@ NfcMessageRegisterService::RegisterPushMessage(const Tizen::Base::String& appId,
        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))
@@ -189,10 +186,10 @@ NfcMessageRegisterService::UnregisterPushMessage(const Tizen::Base::String& appI
        // 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();
@@ -205,59 +202,95 @@ NfcMessageRegisterService::UnregisterPushMessage(const Tizen::Base::String& appI
        __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);
        }
 }
@@ -267,7 +300,7 @@ NfcMessageRegisterService::InitializeAppIdList(void)
 {
        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;
 
@@ -281,28 +314,30 @@ NfcMessageRegisterService::InitializeAppIdList(void)
        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
                        }
                }
index 358320f..8a743a4 100644 (file)
@@ -27,7 +27,7 @@
 #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"
@@ -45,24 +45,23 @@ NfcService::NfcService(void)
        , __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();
        }
@@ -83,7 +82,7 @@ NfcService::Construct(void)
        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();
@@ -103,14 +102,10 @@ NfcService::Construct(void)
        {
                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);
 
@@ -118,15 +113,15 @@ NfcService::Construct(void)
 }
 
 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);
@@ -136,9 +131,9 @@ NfcService::AddNfcAppId(const Tizen::Base::String& appId)
        }
 
        // 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.");
        }
 
@@ -148,19 +143,19 @@ NfcService::AddNfcAppId(const Tizen::Base::String& appId)
 }
 
 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,
@@ -175,7 +170,7 @@ NfcService::RemoveNfcAppId(const Tizen::Base::String& appId)
 }
 
 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;
@@ -190,7 +185,7 @@ NfcService::SetLaunchPopupEnabled(const Tizen::Base::String& clientAppId, bool e
                if (nfcRes == NFC_ERROR_NONE)
                {
                        __popupEnabled = false;
-                       __popupDisablerId = clientAppId;
+                       __popupDisablerId = clientPkgId;
 
                        SysLog(NID_NET_NFC, "Disabling the launch popup is successful.");
                }
@@ -202,7 +197,7 @@ NfcService::SetLaunchPopupEnabled(const Tizen::Base::String& clientAppId, bool e
        }
        else
        {
-               if ((__popupEnabled == false) && (__popupDisablerId == clientAppId))
+               if ((__popupEnabled == false) && (__popupDisablerId == clientPkgId))
                {
                        nfcRes = nfc_manager_set_system_handler_enable(true);
 
@@ -227,34 +222,66 @@ NfcService::SetLaunchPopupEnabled(const Tizen::Base::String& clientAppId, bool e
 }
 
 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);
 
@@ -274,7 +301,7 @@ NfcService::OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen::App::
        locked.Unlock();
 
        // Remove appId if it was added to the list.
-       RemoveNfcAppId(appId);
+       RemoveNfcAppId(clientPkgId);
 }
 
 void
@@ -301,11 +328,11 @@ NfcService::OnNfcActivationChanged(keynode_t* pKeyNode, void* pUserData)
 
        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
 }
index 10811db..c958769 100755 (executable)
@@ -216,7 +216,7 @@ TelephonyService::RequestCallForward(int clientId, const Tizen::Base::String& ph
        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.");
@@ -431,10 +431,9 @@ TelephonyService::OnCallForwardStoppedCallback(TapiHandle* pHandle,int err, void
 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);
index da53dc4..052186c 100644 (file)
@@ -20,6 +20,7 @@
  * @brief   This is the implementation file for the %WifiConnectivityIpcStub class.
  */
 
+#include <unique_ptr.h>
 #include <FBaseSysLog.h>
 #include <FNetWifiWifiBssInfo.h>
 #include <FIo_IpcServer.h>
@@ -44,54 +45,58 @@ WifiConnectivityIpcStub::WifiConnectivityIpcStub(void)
 
 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;
 }
@@ -119,6 +124,11 @@ WifiConnectivityIpcStub::OnIpcClientDisconnected(const Tizen::Io::_IpcServer&ser
 {
        SysLog(NID_NET_WIFI, "Disconnected with clientId[%d].", clientId);
 
+       if (__pWifiService != null)
+       {
+               __pWifiService->ProcessAppTermination(__pIpcServer->GetClientAppId());
+       }
+
        if (__pWifiProximityService != null)
        {
                __pWifiProximityService->UnregisterClient(clientId);
@@ -147,16 +157,18 @@ void
 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)
        {
@@ -176,16 +188,18 @@ void
 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.");
@@ -197,16 +211,18 @@ void
 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)
        {
@@ -226,8 +242,10 @@ void
 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)
        {
@@ -235,7 +253,7 @@ WifiConnectivityIpcStub::OnInitializeWifiDirect(unsigned long* pResult)
        }
        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.");
@@ -247,7 +265,7 @@ void
 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)
@@ -268,8 +286,10 @@ void
 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)
        {
@@ -277,7 +297,7 @@ WifiConnectivityIpcStub::OnSetWifiDirectLocalDeviceName(Tizen::Base::String loca
        }
        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.");
@@ -289,8 +309,10 @@ void
 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)
        {
@@ -298,7 +320,7 @@ WifiConnectivityIpcStub::OnRegisterBssId(const Tizen::Base::String& bssId, unsig
        }
        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.");
@@ -310,8 +332,10 @@ void
 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)
        {
@@ -319,7 +343,7 @@ WifiConnectivityIpcStub::OnUnregisterBssId(const Tizen::Base::String& bssId, uns
        }
        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.");
@@ -331,7 +355,7 @@ void
 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)
@@ -340,7 +364,7 @@ WifiConnectivityIpcStub::OnProximityCheckActivated(unsigned long* pResult)
        }
        else
        {
-               *pResult = __pWifiProximityService->ActivateProximityCheck(__pIpcServer->GetClientId());
+               *pResult = __pWifiProximityService->ActivateProximityCheck();
        }
 #else
        SysLog(NID_NET_WIFI, "Invalid Operation because Wi-Fi is unavailable on the emulator.");
@@ -352,7 +376,7 @@ void
 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)
@@ -361,7 +385,7 @@ WifiConnectivityIpcStub::OnProximityCheckDeactivated(unsigned long* pResult)
        }
        else
        {
-               *pResult = __pWifiProximityService->DeactivateProximityCheck(__pIpcServer->GetClientId());
+               *pResult = __pWifiProximityService->DeactivateProximityCheck();
        }
 #else
        SysLog(NID_NET_WIFI, "Invalid Operation because Wi-Fi is unavailable on the emulator.");
@@ -373,7 +397,7 @@ void
 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)
index 4985b3f..0f215e8 100644 (file)
@@ -207,7 +207,6 @@ WifiProximityService::RegisterBssId(const Tizen::Base::String& bssId, const int
 result
 WifiProximityService::UnregisterBssId(const Tizen::Base::String& bssId, const int clientId)
 {
-       result r = E_SUCCESS;
        bool contains = false;
        bool isDefault = false;
 
@@ -301,7 +300,7 @@ WifiProximityService::UnregisterClient(const int clientId)
 }
 
 result
-WifiProximityService::ActivateProximityCheck(const int clientId)
+WifiProximityService::ActivateProximityCheck(void)
 {
        result r = E_SUCCESS;
 
@@ -325,7 +324,7 @@ WifiProximityService::ActivateProximityCheck(const int clientId)
 }
 
 result
-WifiProximityService::DeactivateProximityCheck(const int clientId)
+WifiProximityService::DeactivateProximityCheck(void)
 {
        SysTryReturnResult(NID_NET_WIFI, __isProximityCheckActivated == true, E_INVALID_STATE,
                        "Proximity checking is already activated.");
index 0eb225d..ce40adf 100644 (file)
@@ -31,7 +31,6 @@
 #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>
@@ -60,22 +59,18 @@ struct _WifiBssIdHandlePair
 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
@@ -89,13 +84,9 @@ WifiService::Construct(void)
        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;
 }
 
@@ -242,16 +233,16 @@ WifiService::UpdateWifiBssInfo(const Tizen::Net::Wifi::WifiBssInfo& bssInfo)
 }
 
 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,
@@ -270,9 +261,9 @@ WifiService::Initialize(const Tizen::Base::String& clientAppId)
        }
 
        // 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));
        }
@@ -322,7 +313,7 @@ WifiService::GetWifiDirectLocalDeviceName(Tizen::Base::String* pLocalName)
 }
 
 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;
 
@@ -334,13 +325,13 @@ WifiService::SetWifiDirectLocalDeviceName(const Tizen::Base::String& clientAppId
                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.");
        }
 
@@ -402,30 +393,13 @@ WifiService::GetApHandle(const Tizen::Base::String& bssId)
 }
 
 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.");
 
@@ -453,13 +427,13 @@ WifiService::OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen::App:
        }
 
        // 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();
@@ -467,7 +441,18 @@ WifiService::OnApplicationTerminated(const Tizen::App::AppId& appId, Tizen::App:
                }
        }
 
-       __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