2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file PhnCallInfo.cpp
19 * @brief Call Information class
21 #include "PhnAppUtility.h"
22 #include "PhnCallInfo.h"
25 using namespace Tizen::Base;
26 using namespace Tizen::Base::Collection;
27 using namespace Tizen::Graphics;
28 using namespace Tizen::Media;
29 using namespace Tizen::Social;
31 CallInfo::CallInfo(void)
33 //by Default, neither a conference call nor emergency call
35 __isEmergency = false;
36 __callType = VOICE_CALL;
38 __callConnectTime = 0;
39 __callNotificationTime = 0;
41 __pEndCallCause = null;
42 __pParticipantCallHandles = null;
46 CallInfo::~CallInfo(void)
55 delete __pEndCallCause;
58 if (__pParticipantCallHandles)
60 delete __pParticipantCallHandles;
61 __pParticipantCallHandles = null;
63 if (__pContact != null)
70 CallInfo::GetCallHandle(void)
76 CallInfo::SetCallHandle(unsigned int handle)
78 if (__pCallHandle != null)
82 __pCallHandle = new (std::nothrow) Long(handle);
86 CallInfo::IsConferenceCall(void)
92 CallInfo::SetConference(bool isConferenceCall)
94 __isConfCall = isConferenceCall;
98 CallInfo::IsEmergency(void)
100 return __isEmergency;
104 CallInfo::SetEmergency(bool isEmergency)
106 __isEmergency = isEmergency;
110 CallInfo::GetContactNumber(void)
112 return __contactNumber;
116 CallInfo::SetContactNumber(String& contactNumber)
118 if (__isConfCall == false)
120 __contactNumber = contactNumber;
125 CallInfo::SetContactInfo(const Contact& contact)
127 if (__pContact != null)
132 __pContact = new (std::nothrow) Contact(contact);
136 CallInfo::IsOnHold(void)
142 CallInfo::SetOnHold(bool onHold)
148 CallInfo::GetCallConnectTime(void)
150 return __callConnectTime;
154 CallInfo::SetCallConnectTime(long long connectTime)
156 __callConnectTime = connectTime;
160 CallInfo::GetCallNotificationTime(void)
162 return __callNotificationTime;
166 CallInfo::SetCallNotificationTime(long long callNotificationTime)
168 __callNotificationTime = callNotificationTime;
172 CallInfo::GetEndCallCause(void)
174 return *(__pEndCallCause);
178 CallInfo::SetEndCallCause(String& pEndCause)
180 if (__pEndCallCause != null)
182 delete __pEndCallCause;
184 __pEndCallCause = new (std::nothrow) String(pEndCause);
188 CallInfo::GetCallerList(void)
190 return __pParticipantCallHandles;
194 CallInfo::GetCallerListCount(void)
196 if (__pParticipantCallHandles != null)
198 return __pParticipantCallHandles->GetCount();
204 CallInfo::AddCallToCallerList(CallInfo& callInfo)
206 if (__pParticipantCallHandles == NULL)
208 __pParticipantCallHandles = new (std::nothrow) ArrayListT<CallInfo>();
210 result r = E_FAILURE;
211 CallInfo* pNewCallInfo = new (std::nothrow) CallInfo();
212 *pNewCallInfo = callInfo;
213 r = __pParticipantCallHandles->Add(*pNewCallInfo);
219 CallInfo::RemoveCallFromCallerList(int index)
221 result r = E_FAILURE;
222 if (__pParticipantCallHandles == NULL)
226 r = __pParticipantCallHandles->RemoveAt(index);
231 CallInfo::SetCalllogType(CallLogType callLogType)
233 __calllogType = callLogType;
237 CallInfo::GetCalllogType(void)
239 return __calllogType;
243 CallInfo::operator ==(const CallInfo& rhs) const
245 return (this->__pCallHandle->Equals(*(rhs.__pCallHandle)));
249 CallInfo::operator !=(const CallInfo& rhs) const
251 return (!(this->__pCallHandle->Equals(*(rhs.__pCallHandle))));
255 CallInfo::operator =(const CallInfo& rhs)
259 this->__isConfCall = rhs.__isConfCall;
260 this->__callType = rhs.__callType;
261 this->__isEmergency = rhs.__isEmergency;
262 this->__contactNumber = rhs.__contactNumber;
263 this->__isOnHold = rhs.__isOnHold;
264 //call connected time
265 this->__callConnectTime = rhs.__callConnectTime;
266 //call notification time
267 this->__callNotificationTime = rhs.__callNotificationTime;
268 this->__calllogType = rhs.__calllogType;
269 //copy call handle, if exist
270 if (this->__pCallHandle != null)
272 delete this->__pCallHandle;
273 this->__pCallHandle = null;
275 if (rhs.__pCallHandle != null)
277 this->__pCallHandle = new (std::nothrow) Long(*(rhs.__pCallHandle));
280 //copy end call cause, if any exist
281 if (this->__pEndCallCause != null)
283 delete this->__pEndCallCause;
284 this->__pEndCallCause = null;
286 if (rhs.__pEndCallCause)
288 this->__pEndCallCause = new (std::nothrow) String(*(rhs.__pEndCallCause));
291 //Add participant call list
292 if (this->__pParticipantCallHandles != null)
294 delete this->__pParticipantCallHandles;
295 this->__pParticipantCallHandles = null;
297 if (rhs.__pParticipantCallHandles != null)
299 this->__pParticipantCallHandles = new (std::nothrow) ArrayListT<CallInfo>();
300 this->__pParticipantCallHandles->Construct(*(rhs.__pParticipantCallHandles));
302 if (this->__pContact != null)
304 delete this->__pContact;
305 this->__pContact = null;
307 if (rhs.__pContact != null)
309 this->__pContact = new (std::nothrow) Contact(*(rhs.__pContact));
317 CallInfo::FetchCallerNameN(void)
319 String displayName(L"");
321 //get caller name from already fetched or newly fetched contact info
322 if (__pContact != null)
324 //fetch name to be displayed
325 __pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, displayName);
326 if (displayName.IsEmpty())
328 String firstName(L"");
329 String lastName(L"");
330 __pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName);
331 __pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName);
332 displayName.Append(firstName + " " + lastName);
336 return new (std::nothrow) String(displayName);
340 CallInfo::FetchCallerPhotoN(void)
342 if (__pContact != null)
344 return __pContact->GetThumbnailN();
350 CallInfo::IsNumberPresent(void)
352 if (__pContact != null)