From 7f9634050daddc9dd833e3a14ce91320664a05fe Mon Sep 17 00:00:00 2001 From: Jinkun Jang Date: Sun, 17 Mar 2013 13:38:35 +0900 Subject: [PATCH] sync with master --- inc/NfcMessageRegisterService.h | 2 ++ src/ConnectivityService.cpp | 4 ++-- src/NfcConnectivityIpcStub.cpp | 12 ++++++------ src/NfcMessagePushDelegate.cpp | 6 +++++- src/NfcMessageRegisterService.cpp | 33 ++++++++++++++++++++++++--------- 5 files changed, 39 insertions(+), 18 deletions(-) diff --git a/inc/NfcMessageRegisterService.h b/inc/NfcMessageRegisterService.h index d4f3212..079db62 100644 --- a/inc/NfcMessageRegisterService.h +++ b/inc/NfcMessageRegisterService.h @@ -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; diff --git a/src/ConnectivityService.cpp b/src/ConnectivityService.cpp index 9cfd4d0..155c66d 100644 --- a/src/ConnectivityService.cpp +++ b/src/ConnectivityService.cpp @@ -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 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 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."); diff --git a/src/NfcConnectivityIpcStub.cpp b/src/NfcConnectivityIpcStub.cpp index 40feed8..7a4e5ae 100644 --- a/src/NfcConnectivityIpcStub.cpp +++ b/src/NfcConnectivityIpcStub.cpp @@ -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; } diff --git a/src/NfcMessagePushDelegate.cpp b/src/NfcMessagePushDelegate.cpp index a88f794..6e20251 100644 --- a/src/NfcMessagePushDelegate.cpp +++ b/src/NfcMessagePushDelegate.cpp @@ -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 diff --git a/src/NfcMessageRegisterService.cpp b/src/NfcMessageRegisterService.cpp index 0f8d213..33351e8 100644 --- a/src/NfcMessageRegisterService.cpp +++ b/src/NfcMessageRegisterService.cpp @@ -28,10 +28,12 @@ #include #include #include +#include #include #include #include #include +#include #include #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 pInsertStmt; unique_ptr pInsertEnum; - PackageInfo* pPackageInfo = null; + unique_ptr pPackageInfo; + unique_ptr 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 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 -- 2.7.4