merge with master
[platform/framework/native/telephony.git] / src / FTelSimInfo.cpp
index 25a619e..ca24fc1 100644 (file)
@@ -34,11 +34,19 @@ SimInfo::SimInfo(void)
 {
 }
 
+SimInfo::SimInfo(const SimInfo& rhs)
+       : __pSimInfoImpl(null)
+{
+       __pSimInfoImpl = new (std::nothrow)_SimInfoImpl(*rhs.__pSimInfoImpl);
+       SysTryReturnVoidResult(NID_TEL, __pSimInfoImpl, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+}
+
 SimInfo::~SimInfo(void)
 {
        delete __pSimInfoImpl;
 }
 
+
 result
 SimInfo::Construct(void)
 {
@@ -70,7 +78,7 @@ SimInfo::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));
@@ -92,7 +100,7 @@ SimInfo::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));
@@ -114,7 +122,7 @@ SimInfo::GetSpn(void) const
        ClearLastResult();
 
        String spn;
-       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
+       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
 
        SysTryReturn(NID_TEL, r == E_SUCCESS, spn, E_PRIVILEGE_DENIED,
                "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
@@ -136,7 +144,7 @@ SimInfo::GetIccId(void) const
        ClearLastResult();
 
        String iccId;
-       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
+       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
 
        SysTryReturn(NID_TEL, r == E_SUCCESS, iccId, E_PRIVILEGE_DENIED,
                "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
@@ -158,7 +166,7 @@ SimInfo::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));
@@ -180,7 +188,7 @@ SimInfo::GetPhoneNumber(void) const
        ClearLastResult();
 
        String phoneNumber;
-       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
+       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
 
        SysTryReturn(NID_TEL, r == E_SUCCESS, phoneNumber, E_PRIVILEGE_DENIED,
                "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
@@ -219,6 +227,20 @@ SimInfo::GetImsi(void) const
        return imsi;
 }
 
+SimType
+SimInfo::GetSimType(void) const
+{
+       SysAssertf(__pSimInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
+
+       ClearLastResult();
+
+       result r = _AccessController::CheckUserPrivilege(_PRV_TELEPHONY);
+       SysTryReturn(NID_TEL, r == E_SUCCESS, SIM_TYPE_UNKNOWN, E_PRIVILEGE_DENIED,
+                       "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
+
+       return __pSimInfoImpl->GetSimType();
+}
+
 bool
 SimInfo::IsAvailable(void) const
 {
@@ -227,7 +249,7 @@ SimInfo::IsAvailable(void) const
        ClearLastResult();
 
        bool isAvailable = false;
-       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO);
+       result r = _AccessController::CheckUserPrivilege(_PRV_SYSTEMINFO, _PRV_TELEPHONY);
 
        SysTryReturn(NID_TEL, r == E_SUCCESS, isAvailable, E_PRIVILEGE_DENIED,
                "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED));
@@ -237,4 +259,41 @@ SimInfo::IsAvailable(void) const
        return isAvailable;
 }
 
+SimInfo&
+SimInfo::operator =(const SimInfo& rhs)
+{
+    if (this != &rhs)
+    {
+        *__pSimInfoImpl = *rhs.__pSimInfoImpl;
+    }
+
+    return *this;
+}
+
+bool
+SimInfo::Equals(const Object& rhs) const
+{
+       const SimInfo* pRhs = dynamic_cast<const SimInfo*>(&rhs);
+
+       if (pRhs == null)
+       {
+               return false;
+       }
+
+       const _SimInfoImpl* pRhsImpl = _SimInfoImpl::GetInstance(*pRhs);
+
+       if (pRhsImpl == null)
+       {
+               return false;
+       }
+
+       return __pSimInfoImpl->Equals(*pRhsImpl);
+}
+
+int
+SimInfo::GetHashCode(void) const
+{
+       return __pSimInfoImpl->GetHashCode();
+}
+
 } } // Tizen::Telephony