2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (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;
30 using namespace Tizen::Telephony;
32 AppCallInfo::AppCallInfo(void)
34 //by Default, neither a conference call nor emergency call
36 __isEmergency = false;
37 __callType = VOICE_CALL;
39 __callConnectTime = 0;
40 __callNotificationTime = 0;
42 __pEndCallCause = null;
43 __pParticipantCallHandles = null;
45 __pAddressBook = null;
48 AppCallInfo::~AppCallInfo(void)
57 delete __pEndCallCause;
60 if (__pParticipantCallHandles)
62 delete __pParticipantCallHandles;
63 __pParticipantCallHandles = null;
65 if (__pContact != null)
69 if(__pAddressBook != null)
71 delete __pAddressBook;
76 AppCallInfo::GetCallHandle(void)
82 AppCallInfo::SetCallHandle(unsigned int handle)
84 if (__pCallHandle != null)
88 __pCallHandle = new (std::nothrow) Long(handle);
92 AppCallInfo::IsConferenceCall(void)
98 AppCallInfo::SetConference(bool isConferenceCall)
100 __isConfCall = isConferenceCall;
104 AppCallInfo::IsEmergency(void)
106 return __isEmergency;
110 AppCallInfo::SetEmergency(bool isEmergency)
112 __isEmergency = isEmergency;
116 AppCallInfo::GetContactNumber(void)
118 return __contactNumber;
122 AppCallInfo::SetContactNumber(String& contactNumber)
124 if (__isConfCall == false)
126 __contactNumber = contactNumber;
131 AppCallInfo::SetContactInfo(const Contact& contact)
133 if (__pContact != null)
138 __pContact = new (std::nothrow) Contact(contact);
142 AppCallInfo::IsOnHold(void)
148 AppCallInfo::SetOnHold(bool onHold)
154 AppCallInfo::GetCallConnectTime(void)
156 return __callConnectTime;
160 AppCallInfo::SetCallConnectTime(long long connectTime)
162 __callConnectTime = connectTime;
166 AppCallInfo::GetCallNotificationTime(void)
168 return __callNotificationTime;
172 AppCallInfo::SetCallNotificationTime(long long callNotificationTime)
174 __callNotificationTime = callNotificationTime;
178 AppCallInfo::GetEndCallCause(void)
180 return *(__pEndCallCause);
184 AppCallInfo::SetEndCallCause(String& pEndCause)
186 if (__pEndCallCause != null)
188 delete __pEndCallCause;
190 __pEndCallCause = new (std::nothrow) String(pEndCause);
194 AppCallInfo::GetCallerList(void)
196 return __pParticipantCallHandles;
200 AppCallInfo::GetCallerListCount(void)
202 if (__pParticipantCallHandles != null)
204 return __pParticipantCallHandles->GetCount();
210 AppCallInfo::AddCallToCallerList(AppCallInfo& callInfo)
212 if (__pParticipantCallHandles == NULL)
214 __pParticipantCallHandles = new (std::nothrow) ArrayListT<AppCallInfo>();
216 result r = E_FAILURE;
217 AppCallInfo* pNewCallInfo = new (std::nothrow) AppCallInfo();
218 *pNewCallInfo = callInfo;
219 r = __pParticipantCallHandles->Add(*pNewCallInfo);
225 AppCallInfo::RemoveCallFromCallerList(int index)
227 result r = E_FAILURE;
228 if (__pParticipantCallHandles == NULL)
232 r = __pParticipantCallHandles->RemoveAt(index);
237 AppCallInfo::SetCalllogType(CallLogType callLogType)
239 __calllogType = callLogType;
243 AppCallInfo::GetCalllogType(void)
245 return __calllogType;
249 AppCallInfo::operator ==(const AppCallInfo& rhs) const
251 return (this->__pCallHandle->Equals(*(rhs.__pCallHandle)));
255 AppCallInfo::operator !=(const AppCallInfo& rhs) const
257 return (!(this->__pCallHandle->Equals(*(rhs.__pCallHandle))));
261 AppCallInfo::operator =(const AppCallInfo& rhs)
265 this->__isConfCall = rhs.__isConfCall;
266 this->__callType = rhs.__callType;
267 this->__isEmergency = rhs.__isEmergency;
268 this->__contactNumber = rhs.__contactNumber;
269 this->__isOnHold = rhs.__isOnHold;
270 //call connected time
271 this->__callConnectTime = rhs.__callConnectTime;
272 //call notification time
273 this->__callNotificationTime = rhs.__callNotificationTime;
274 this->__calllogType = rhs.__calllogType;
275 //copy call handle, if exist
276 if (this->__pCallHandle != null)
278 delete this->__pCallHandle;
279 this->__pCallHandle = null;
281 if (rhs.__pCallHandle != null)
283 this->__pCallHandle = new (std::nothrow) Long(*(rhs.__pCallHandle));
286 //copy end call cause, if any exist
287 if (this->__pEndCallCause != null)
289 delete this->__pEndCallCause;
290 this->__pEndCallCause = null;
292 if (rhs.__pEndCallCause)
294 this->__pEndCallCause = new (std::nothrow) String(*(rhs.__pEndCallCause));
297 //Add participant call list
298 if (this->__pParticipantCallHandles != null)
300 delete this->__pParticipantCallHandles;
301 this->__pParticipantCallHandles = null;
303 if (rhs.__pParticipantCallHandles != null)
305 this->__pParticipantCallHandles = new (std::nothrow) ArrayListT<AppCallInfo>();
306 this->__pParticipantCallHandles->Construct(*(rhs.__pParticipantCallHandles));
308 if (this->__pContact != null)
310 delete this->__pContact;
311 this->__pContact = null;
313 if (rhs.__pContact != null)
315 this->__pContact = new (std::nothrow) Contact(*(rhs.__pContact));
323 AppCallInfo::FetchCallerNameN(void)
325 String displayName(L"");
327 //get caller name from already fetched contact info
328 if (__pContact != null)
330 //fetch name to be displayed
331 String firstName(L"");
332 String lastName(L"");
333 String middlename(L"");
334 __pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName);
335 __pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName);
336 __pContact->GetValue(CONTACT_PROPERTY_ID_MIDDLE_NAME, middlename);
337 displayName.Append(firstName + middlename + lastName);
339 if (displayName.IsEmpty() == false)
341 __pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, displayName);
345 return new (std::nothrow) String(displayName);
349 AppCallInfo::FetchCallerPhotoN(void)
352 if (__pContact != null)
354 String thumbnailPath;
355 Bitmap* pThumbnail = null;
356 __pAddressBook = AddressbookManager::GetInstance()->GetAddressbookN();
358 result r = __pContact->GetValue(CONTACT_PROPERTY_ID_THUMBNAIL, thumbnailPath);
359 //Now check if there is a group ring tone
360 if(thumbnailPath.IsEmpty() == true)
362 IList* pCategoryList = __pAddressBook->GetCategoriesByContactN(__pContact->GetRecordId());
363 if(pCategoryList != null && pCategoryList->GetCount() > 0)
365 AppLogDebug("Changes to get thumbnail group photo");
366 Category* pCategory = static_cast<Category*>(pCategoryList->GetAt(0));
367 thumbnailPath = pCategory->GetThumbnailPath();
370 //thumbnailPath = __pContact->GetThumbnailPath();
371 ImageBuffer thumbnailImageBuffer;
372 r = thumbnailImageBuffer.Construct(thumbnailPath);
375 pThumbnail = thumbnailImageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_ARGB8888, BUFFER_SCALING_NONE);
383 AppCallInfo::GetContactInfo(void)