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 CallCallInfo.cpp
19 * @brief Call Information class
21 #include "CallAppUtility.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 AppCallInfo::AppCallInfo(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 AppCallInfo::~AppCallInfo(void)
55 delete __pEndCallCause;
58 if (__pParticipantCallHandles)
60 delete __pParticipantCallHandles;
61 __pParticipantCallHandles = null;
63 if (__pContact != null)
70 AppCallInfo::GetCallHandle(void)
76 AppCallInfo::SetCallHandle(unsigned int handle)
78 if (__pCallHandle != null)
82 __pCallHandle = new (std::nothrow) Long(handle);
86 AppCallInfo::IsConferenceCall(void)
92 AppCallInfo::SetConference(bool isConferenceCall)
94 __isConfCall = isConferenceCall;
98 AppCallInfo::IsEmergency(void)
100 return __isEmergency;
104 AppCallInfo::SetEmergency(bool isEmergency)
106 __isEmergency = isEmergency;
110 AppCallInfo::GetContactNumber(void)
112 return __contactNumber;
116 AppCallInfo::SetContactNumber(String& contactNumber)
118 if (__isConfCall == false)
120 __contactNumber = contactNumber;
125 AppCallInfo::SetContactInfo(const Contact& contact)
127 if (__pContact != null)
132 __pContact = new (std::nothrow) Contact(contact);
136 AppCallInfo::IsOnHold(void)
142 AppCallInfo::SetOnHold(bool onHold)
148 AppCallInfo::GetCallConnectTime(void)
150 return __callConnectTime;
154 AppCallInfo::SetCallConnectTime(long long connectTime)
156 __callConnectTime = connectTime;
160 AppCallInfo::GetCallNotificationTime(void)
162 return __callNotificationTime;
166 AppCallInfo::SetCallNotificationTime(long long callNotificationTime)
168 __callNotificationTime = callNotificationTime;
172 AppCallInfo::GetEndCallCause(void)
174 return *(__pEndCallCause);
178 AppCallInfo::SetEndCallCause(String& pEndCause)
180 if (__pEndCallCause != null)
182 delete __pEndCallCause;
184 __pEndCallCause = new (std::nothrow) String(pEndCause);
188 AppCallInfo::GetCallerList(void)
190 return __pParticipantCallHandles;
194 AppCallInfo::GetCallerListCount(void)
196 if (__pParticipantCallHandles != null)
198 return __pParticipantCallHandles->GetCount();
204 AppCallInfo::AddCallToCallerList(AppCallInfo& callInfo)
206 if (__pParticipantCallHandles == NULL)
208 __pParticipantCallHandles = new (std::nothrow) ArrayListT<AppCallInfo>();
210 result r = E_FAILURE;
211 AppCallInfo* pNewCallInfo = new (std::nothrow) AppCallInfo();
212 *pNewCallInfo = callInfo;
213 r = __pParticipantCallHandles->Add(*pNewCallInfo);
219 AppCallInfo::RemoveCallFromCallerList(int index)
221 result r = E_FAILURE;
222 if (__pParticipantCallHandles == NULL)
226 r = __pParticipantCallHandles->RemoveAt(index);
231 AppCallInfo::SetCalllogType(CallLogType callLogType)
233 __calllogType = callLogType;
237 AppCallInfo::GetCalllogType(void)
239 return __calllogType;
243 AppCallInfo::operator ==(const AppCallInfo& rhs) const
245 return (this->__pCallHandle->Equals(*(rhs.__pCallHandle)));
249 AppCallInfo::operator !=(const AppCallInfo& rhs) const
251 return (!(this->__pCallHandle->Equals(*(rhs.__pCallHandle))));
255 AppCallInfo::operator =(const AppCallInfo& 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<AppCallInfo>();
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 AppCallInfo::FetchCallerNameN(void)
319 String displayName(L"");
321 //get caller name from already fetched contact info
322 if (__pContact != null)
324 //fetch name to be displayed
325 String firstName(L"");
326 String lastName(L"");
327 String middlename(L"");
328 __pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName);
329 __pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName);
330 __pContact->GetValue(CONTACT_PROPERTY_ID_MIDDLE_NAME, middlename);
331 displayName.Append(firstName + middlename + lastName);
333 if (displayName.IsEmpty() == false)
335 __pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, displayName);
339 return new (std::nothrow) String(displayName);
343 AppCallInfo::FetchCallerPhotoN(void)
346 if (__pContact != null)
348 String thumbnailPath;
349 Bitmap* pThumbnail = null;
350 // __pContact->GetValue(CONTACT_PROPERTY_ID_THUMBNAIL, thumbnailPath);
351 thumbnailPath = __pContact->GetThumbnailPath();
352 ImageBuffer thumbnailImageBuffer;
353 result r = thumbnailImageBuffer.Construct(thumbnailPath);
356 pThumbnail = thumbnailImageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_ARGB8888, BUFFER_SCALING_NONE);
364 AppCallInfo::GetContactInfo(void)