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 PhnDialContactInfo.cpp
19 * @brief Dial Contact Info class
21 #include "PhnDialContactInfo.h"
23 using namespace Tizen::Base;
24 using namespace Tizen::Graphics;
25 using namespace Tizen::Social;
26 using namespace Tizen::Base::Collection;
28 DialContactInfo::DialContactInfo(void) {
29 __pDisplayName = null;
30 __pPhoneNumber = null;
32 __pSearchKeyList = null;
33 //By default, value is '0' - indicates it is not fetched from call logs
38 DialContactInfo::CloneN(void)
40 //Used to create new 'DialContactInfo' object which is clone of 'this' object.
41 //We cant use Copy Contructor, since we will need 2-phase constructor in this case.
44 DialContactInfo* cloneObj = new (std::nothrow) DialContactInfo();
45 cloneObj->__pDisplayName = new (std::nothrow) String(*this->__pDisplayName);
46 cloneObj->__pPhoneNumber = new (std::nothrow) String(*this->__pPhoneNumber);
49 if(this->__pThumbnail != null)
51 Bitmap& pSrcTn = *(this->__pThumbnail);
52 cloneObj->__pThumbnail = new (std::nothrow) Bitmap();
53 r = cloneObj->__pThumbnail->Construct( pSrcTn, Rectangle(0, 0, pSrcTn.GetWidth(), pSrcTn.GetHeight()));
55 TryCatch(r == E_SUCCESS,,"Object Cloning failed");
58 if(this->__pSearchKeyList != null && this->__pSearchKeyList->GetCount() > 0)
60 cloneObj->__pSearchKeyList = new (std::nothrow) ArrayList(SingleObjectDeleter);
61 r = cloneObj->__pSearchKeyList->Construct();
62 TryCatch(r == E_SUCCESS,,"Object Cloning failed");
64 for (int index = 0; index < this->__pSearchKeyList->GetCount(); index++)
66 String* key = static_cast<String*>(this->__pSearchKeyList->GetAt(index));
67 r = cloneObj->__pSearchKeyList->Add(new (std::nothrow) String(*key));
68 TryCatch(r == E_SUCCESS,,"Object Cloning failed");
80 DialContactInfo::~DialContactInfo(void) {
81 if(__pDisplayName != null)
83 delete __pDisplayName;
85 if(__pPhoneNumber != null)
87 delete __pPhoneNumber;
89 if(__pSearchKeyList != null)
91 __pSearchKeyList->RemoveAll();
92 delete __pSearchKeyList;
94 if(__pThumbnail != null)
101 DialContactInfo::Equals(const Object& obj) const
103 DialContactInfo* objInfo = dynamic_cast<DialContactInfo*>(const_cast<Object*>(&obj));
104 if(objInfo != null && __pPhoneNumber->Equals(objInfo->GetPhoneNumber()))
112 DialContactInfo::AddSearchKey(String& pSearchString)
114 if(__pSearchKeyList == null)
116 __pSearchKeyList = new (std::nothrow) ArrayList(SingleObjectDeleter);
117 __pSearchKeyList->Construct();
119 __pSearchKeyList->Add(new (std::nothrow) String(pSearchString));
123 DialContactInfo::RemoveSearchKey(int index)
125 if(__pSearchKeyList != null && index >= 0 && index < __pSearchKeyList->GetCount())
127 __pSearchKeyList->RemoveAt(index);
132 DialContactInfo::ReplaceSearchKey(int index, String& pSearchString)
134 if(__pSearchKeyList != null && (index >= 0 && index < __pSearchKeyList->GetCount()))
136 __pSearchKeyList->RemoveAt(index);
137 __pSearchKeyList->InsertAt(new String(pSearchString),index);
142 DialContactInfo::GetSearchKeyList(void)
144 return __pSearchKeyList;
148 DialContactInfo::GetSearchKey(void)
150 if(__pSearchKeyList != null && __pSearchKeyList->GetCount() > 0)
152 return (static_cast<String*>(__pSearchKeyList->GetAt(0)));
158 DialContactInfo::SetDisplayName(String& pDisplayName)
160 if(__pDisplayName != null)
162 delete __pDisplayName;
164 __pDisplayName = new (std::nothrow) String(pDisplayName);
168 DialContactInfo::GetDisplayName(void) const
170 return *__pDisplayName;
174 DialContactInfo::SetPhoneNumber(String& pPhoneNumber)
176 if(__pPhoneNumber != null)
178 delete __pPhoneNumber;
180 __pPhoneNumber = new (std::nothrow) String(pPhoneNumber);
184 DialContactInfo::GetPhoneNumber(void) const
186 return *__pPhoneNumber;
190 DialContactInfo::SetThumbnail(Bitmap* pBitmap)
192 if(__pThumbnail != null)
200 __pThumbnail = pBitmap;
201 __pThumbnail->SetScalingQuality(BITMAP_SCALING_QUALITY_MID);
202 __pThumbnail->Scale(Dimension(96, 96));
207 DialContactInfo::GetThumbnailN(void) const
209 Bitmap* pThumbnail = null;
210 result r = E_FAILURE;
211 if(__pThumbnail != null)
213 pThumbnail = new (std::nothrow) Bitmap();
214 r = pThumbnail->Construct( *__pThumbnail, Rectangle(0, 0, __pThumbnail->GetWidth(),
215 __pThumbnail->GetHeight()));
216 TryCatch(r == E_SUCCESS,,"[%s] Thumbnail contruction failed", GetErrorMessage(r));
226 DialContactInfo::SetCallLogDbId(int callLogDbId)
228 __callLogDbId = callLogDbId;
232 DialContactInfo::GetCallLogDbId(void)
234 return __callLogDbId;