Sychronized tizen_2.1 branch with master
authorJaehwan Lee <jh8379.lee@samsung.com>
Wed, 20 Mar 2013 05:53:01 +0000 (14:53 +0900)
committerJaehwan Lee <jh8379.lee@samsung.com>
Wed, 20 Mar 2013 05:53:01 +0000 (14:53 +0900)
Change-Id: I1fcc11f78b502d21612665b8a8947758620f021b
Signed-off-by: Jaehwan Lee <jh8379.lee@samsung.com>
inc/NfcMessageRegisterService.h
src/ConnectivityService.cpp
src/NfcConnectivityIpcStub.cpp
src/NfcMessagePushDelegate.cpp
src/NfcMessageRegisterService.cpp

index d4f3212..079db62 100644 (file)
@@ -73,8 +73,10 @@ public:
 
 private:
        result InitializeAppIdList(void);
+       result SetSelectedMessageAppId(const Tizen::Base::String& appId);
 
 public:
+       static const wchar_t* _SELECTED_APP_ID_NONE;
        static const wchar_t* _META_DATA_DB_NAME;
        static const wchar_t* _PUSH_MESSAGE_DIRECTORY;
        static const wchar_t* _PUSH_MESSAGE_EXT_NAME;
index 9cfd4d0..155c66d 100644 (file)
@@ -63,7 +63,7 @@ ConnectivityService::OnAppInitializing(Tizen::App::AppRegistry& appRegistry)
        SysTryReturn(NID_NET, pNetIpcStub != null, false, E_OUT_OF_MEMORY, "The memory is insufficient.");
 
        unique_ptr<WifiConnectivityIpcStub> pWifiIpcStub(new (std::nothrow) WifiConnectivityIpcStub);
-       SysTryReturn(NID_NET, pWifiIpcStub != null, false, E_OUT_OF_MEMORY, "The memory is insufficient.");
+       SysTryReturn(NID_NET_WIFI, pWifiIpcStub != null, false, E_OUT_OF_MEMORY, "The memory is insufficient.");
 
        unique_ptr<NfcConnectivityIpcStub> pNfcIpcStub(new (std::nothrow) NfcConnectivityIpcStub);
        SysTryReturn(NID_NET_NFC, pNfcIpcStub != null, false, E_OUT_OF_MEMORY, "The memory is insufficient.");
@@ -78,7 +78,7 @@ ConnectivityService::OnAppInitializing(Tizen::App::AppRegistry& appRegistry)
        SysTryReturn(NID_NET, r == E_SUCCESS, false, r, "Construction of NetConnectivityIpcStub has failed.");
 
        r = pWifiIpcStub->Construct();
-       SysTryReturn(NID_NET, r == E_SUCCESS, false, r, "Construction of WifiConnectivityIpcStub has failed.");
+       SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, false, r, "Construction of WifiConnectivityIpcStub has failed.");
 
        r = pNfcIpcStub->Construct();
        SysTryReturn(NID_NET_NFC, r == E_SUCCESS, false, r, "Construction of NfcConnectivityIpcStub has failed.");
index 40feed8..7a4e5ae 100644 (file)
@@ -207,7 +207,7 @@ NfcConnectivityIpcStub::OnActivateReservedPush(unsigned long* pResult)
        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);
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_NFCMANAGER);
 
        if (*pResult != E_SUCCESS)
        {
@@ -215,7 +215,7 @@ NfcConnectivityIpcStub::OnActivateReservedPush(unsigned long* pResult)
                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)
+       else if (__pNfcService == null)
        {
                *pResult = E_SYSTEM;
        }
@@ -233,7 +233,7 @@ NfcConnectivityIpcStub::OnDeactivateReservedPush(unsigned long* pResult)
        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);
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_NFCMANAGER);
 
        if (*pResult != E_SUCCESS)
        {
@@ -241,7 +241,7 @@ NfcConnectivityIpcStub::OnDeactivateReservedPush(unsigned long* pResult)
                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)
+       else if (__pNfcService == null)
        {
                *pResult = E_SYSTEM;
        }
@@ -291,7 +291,7 @@ NfcConnectivityIpcStub::OnPickReservedPushMessage(const Tizen::Base::String& app
        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);
+       *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_NFCMANAGER);
 
        if (*pResult != E_SUCCESS)
        {
@@ -299,7 +299,7 @@ NfcConnectivityIpcStub::OnPickReservedPushMessage(const Tizen::Base::String& app
                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)
+       else if (__pNfcService == null)
        {
                *pResult = E_SYSTEM;
        }
index a88f794..6e20251 100644 (file)
@@ -255,7 +255,11 @@ NfcMessagePushDelegate::GetSelectedMessageAppId(void)
        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
+       String selectedAppId(pAppIdStr.get());
+       SysTryReturn(NID_NET_NFC, selectedAppId != String(NfcMessageRegisterService::_SELECTED_APP_ID_NONE), L"", E_OBJ_NOT_FOUND,
+                       "[E_OBJ_NOT_FOUND] No element in the candidate list.");
+
+       return selectedAppId;
 }
 
 result
index 0f8d213..33351e8 100644 (file)
 #include <FBaseRtMutexGuard.h>
 #include <FBaseColHashMap.h>
 #include <FAppPkgPackageInfo.h>
+#include <FAppPkgPackageAppInfo.h>
 #include <FIoFile.h>
 #include <FIoDbStatement.h>
 #include <FIoDbEnumerator.h>
 #include <FAppPkg_PackageManagerImpl.h>
+#include <FAppPkg_PackageAppInfoImpl.h>
 #include <FBase_StringConverter.h>
 #include "NfcMessageRegisterService.h"
 
@@ -43,6 +45,7 @@ using namespace Tizen::App;
 using namespace Tizen::App::Package;
 using namespace Tizen::Io;
 
+const wchar_t* NfcMessageRegisterService::_SELECTED_APP_ID_NONE = L"None";
 const wchar_t* NfcMessageRegisterService::_META_DATA_DB_NAME = L"/opt/usr/dbspace/.net-nfcpush.db";
 const wchar_t* NfcMessageRegisterService::_PUSH_MESSAGE_DIRECTORY = L"/opt/usr/share/nfcpush/";
 const wchar_t* NfcMessageRegisterService::_PUSH_MESSAGE_EXT_NAME = L".ndef";
@@ -97,7 +100,8 @@ NfcMessageRegisterService::RegisterPushMessage(const Tizen::Base::String& appPkg
        String msgFilePath;
        unique_ptr<DbStatement> pInsertStmt;
        unique_ptr<DbEnumerator> pInsertEnum;
-    PackageInfo* pPackageInfo = null;
+       unique_ptr<PackageInfo> pPackageInfo;
+       unique_ptr<PackageAppInfo> pPackageAppInfo;
     String appName;
     String appIconPath;
 
@@ -105,13 +109,14 @@ NfcMessageRegisterService::RegisterPushMessage(const Tizen::Base::String& appPkg
        msgFilePath = _PUSH_MESSAGE_DIRECTORY + appPkgId + _PUSH_MESSAGE_EXT_NAME;
 
        // get the app name and icon path from the package manager
-       pPackageInfo = _PackageManagerImpl::GetInstance()->GetPackageInfoN(appPkgId);
+       pPackageInfo.reset(_PackageManagerImpl::GetInstance()->GetPackageInfoN(appPkgId));
        SysTryReturnResult(NID_NET_NFC, pPackageInfo != null, E_SYSTEM, "Getting package information has failed.");
 
-       appName = pPackageInfo->GetDisplayName();
-       //appIconPath = packageInfo.GetAppIconPath();
+       pPackageAppInfo.reset(pPackageInfo->GetPackageAppInfoN(pPackageInfo->GetMainAppId()));
+       SysTryReturnResult(NID_NET_NFC, pPackageInfo != null, E_SYSTEM, "Getting package app information has failed.");
 
-       delete pPackageInfo;
+       appName = pPackageInfo->GetDisplayName();
+       appIconPath = _PackageAppInfoImpl::GetInstance(pPackageAppInfo.get())->GetAppMenuIconPath();
 
        MutexGuard locked(__listMutex);
 
@@ -150,7 +155,7 @@ NfcMessageRegisterService::RegisterPushMessage(const Tizen::Base::String& appPkg
                // Modify vconf - the selected item - value if the new message (appPkgId) becomes the first element of the list
                if (__reserverList.GetCount() == 1)
                {
-                       r = PickReservedPushMessage(appPkgId);
+                       r = SetSelectedMessageAppId(appPkgId);
                        SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
                }
        }
@@ -213,7 +218,7 @@ NfcMessageRegisterService::UnregisterPushMessage(const Tizen::Base::String& appP
 
                if (appPkgId.Equals(String(pSelectedAppIdStr.get())))
                {
-                       String newAppId(L"None"); // Especially, if no more element in the list, set the value by "None"
+                       String newAppId(_SELECTED_APP_ID_NONE); // Especially, if no more element in the list, set the default value
 
                        if (__reserverList.GetCount() > 0)
                        {
@@ -221,7 +226,7 @@ NfcMessageRegisterService::UnregisterPushMessage(const Tizen::Base::String& appP
                                __reserverList.GetAt(0, newAppId); // Ignore the result
                        }
 
-                       r = PickReservedPushMessage(newAppId);
+                       r = SetSelectedMessageAppId(newAppId);
                        SysTryReturnResult(NID_NET_NFC, r == E_SUCCESS, r, "Propagating.");
                }
        }
@@ -269,10 +274,20 @@ NfcMessageRegisterService::GetReservedPushCandidates(Tizen::Base::Collection::Ha
 result
 NfcMessageRegisterService::PickReservedPushMessage(const Tizen::Base::String& ownerAppId)
 {
+       // check the owner application ID exists in the candidate list
+       SysTryReturnResult(NID_NET_NFC, __reserverList.Contains(ownerAppId) == true, E_OBJ_NOT_FOUND,
+                       "The specified application ID is not found in the candidate list.");
+
+       return SetSelectedMessageAppId(ownerAppId);
+}
+
+result
+NfcMessageRegisterService::SetSelectedMessageAppId(const Tizen::Base::String& appId)
+{
        int vconfRes = -1;
        unique_ptr<char, _CharDeleter> pAppIdStr;
 
-       pAppIdStr.reset(_StringConverter::CopyToCharArrayN(ownerAppId));
+       pAppIdStr.reset(_StringConverter::CopyToCharArrayN(appId));
        SysTryReturnResult(NID_NET_NFC, pAppIdStr != null, E_SYSTEM, "Failed to set the selected App ID to vconf.");
 
        // set the value for the predefined item