Clear the last result when GetSimState() is successful.
[platform/framework/native/telephony.git] / src / FTelNetworkInfo.cpp
index 6551d82..32137a8 100644 (file)
 #include <FTelNetworkInfo.h>
 #include <FBaseSysLog.h>
 #include <FSec_AccessController.h>
+#include <FSys_SystemInfoImpl.h>
 #include "FTel_NetworkInfoImpl.h"
 
 
 using namespace Tizen::Base;
 using namespace Tizen::Security;
+using namespace Tizen::System;
 
 
 namespace Tizen { namespace Telephony
@@ -67,7 +69,7 @@ NetworkInfo::GetMnc(void) const
        ClearLastResult();
 
        int mnc = -1;
-       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
+       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
 
        SysTryReturn(NID_TEL, r == E_SUCCESS, mnc, E_PRIVILEGE_DENIED,
             "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
@@ -83,7 +85,7 @@ NetworkInfo::GetMcc(void) const
        ClearLastResult();
 
        int mcc = -1;
-       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
+       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
 
        SysTryReturn(NID_TEL, r == E_SUCCESS, mcc, E_PRIVILEGE_DENIED,
                    "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
@@ -99,7 +101,7 @@ NetworkInfo::GetPlmn(void) const
        ClearLastResult();
 
        String plmn;
-       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
+       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
 
        SysTryReturn(NID_TEL, r == E_SUCCESS, plmn, E_PRIVILEGE_DENIED,
                    "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
@@ -115,7 +117,7 @@ NetworkInfo::GetCellId(void) const
        ClearLastResult();
 
        int cellId = -1;
-       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
+       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
 
        SysTryReturn(NID_TEL, r == E_SUCCESS, cellId, E_PRIVILEGE_DENIED,
                "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
@@ -131,7 +133,7 @@ NetworkInfo::GetLac(void) const
        ClearLastResult();
 
        int lac = -1;
-       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
+       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
 
        SysTryReturn(NID_TEL, r == E_SUCCESS, lac, E_PRIVILEGE_DENIED,
                "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
@@ -147,7 +149,7 @@ NetworkInfo::GetOperatorName(void) const
     ClearLastResult();
 
     String operatorName;
-    result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
+    result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
 
     SysTryReturn(NID_TEL, r == E_SUCCESS, operatorName, E_PRIVILEGE_DENIED,
                 "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
@@ -184,13 +186,20 @@ NetworkInfo::GetHashCode(void) const
 int
 NetworkInfo::GetRssi(void)
 {
+       static const wchar_t _TELEPHONY[] = L"http://tizen.org/feature/network.telephony";
+
        ClearLastResult();
 
        int rssi = -1;
-       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
-
+       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
        SysTryReturn(NID_TEL, r == E_SUCCESS, rssi, E_PRIVILEGE_DENIED,
-                   "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+                       "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+
+       bool isTelephonySupported = false;
+
+    r = _SystemInfoImpl::GetSysInfo(_TELEPHONY, isTelephonySupported);
+    SysTryReturn(NID_TEL, r == E_SUCCESS && isTelephonySupported, rssi, E_UNSUPPORTED_OPERATION,
+               "[%s] Telephony is not supported.", GetErrorMessage(E_UNSUPPORTED_OPERATION));
 
        rssi = _NetworkInfoImpl::GetRssi();