cf3f6b221dbfdf5034a49ad337bae9bec9d30c90
[platform/framework/native/telephony.git] / src / FTelCallInfo.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file        FTelCallInfo.cpp
19  * @brief       This is the implementation file for CallInfo class.
20  */
21
22 #include <FTelCallInfo.h>
23 #include <FBaseSysLog.h>
24 #include "FTel_CallInfoImpl.h"
25
26
27 using namespace Tizen::Base;
28
29 namespace Tizen { namespace Telephony
30 {
31 CallInfo::CallInfo(void)
32         : __pCallInfoImpl(null)
33 {
34         __pCallInfoImpl = new (std::nothrow) _CallInfoImpl();
35         SysTryReturnVoidResult(NID_TEL, __pCallInfoImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
36 }
37
38 CallInfo::CallInfo(const CallInfo& callInfo)
39         : __pCallInfoImpl(null)
40 {
41         __pCallInfoImpl = new (std::nothrow) _CallInfoImpl(*callInfo.__pCallInfoImpl);
42         SysTryReturnVoidResult(NID_TEL, __pCallInfoImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
43 }
44
45 CallInfo::~CallInfo(void)
46 {
47         delete __pCallInfoImpl;
48 }
49
50 CallInfo&
51 CallInfo::operator=(const CallInfo& rhs)
52 {
53         if (this != &rhs)
54         {
55         *__pCallInfoImpl = *(rhs.__pCallInfoImpl);
56         }
57
58         return *this;
59 }
60
61 CallType
62 CallInfo::GetCallType(void) const
63 {
64         return __pCallInfoImpl->GetCallType();
65 }
66
67 String
68 CallInfo::GetNumber(void) const
69 {
70         return __pCallInfoImpl->GetNumber();
71 }
72
73 bool
74 CallInfo::Equals(const Object& obj) const
75 {
76         const CallInfo* pOther = dynamic_cast<const CallInfo*>(&obj);
77
78         if (pOther == null)
79         {
80         return false;
81         }
82
83         if (pOther == this)
84         {
85         return true;
86         }
87
88         return __pCallInfoImpl->Equals(*pOther->__pCallInfoImpl);
89 }
90
91 int
92 CallInfo::GetHashCode(void) const
93 {
94         return __pCallInfoImpl->GetHashCode();
95 }
96
97 CallInfo::CallInfo(CallType type, const String& number)
98 {
99         SysLog(NID_TEL,"The CallType is %d and the number is %ls", type, number.GetPointer());
100
101         __pCallInfoImpl = new (std::nothrow) _CallInfoImpl(type, number);
102         SysTryReturnVoidResult(NID_TEL, __pCallInfoImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
103 }
104
105 }} // Tizen::Telephony