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 CtContactPresentationModel.cpp
19 * @brief This is the implementation file for the ContactPresentationModel class.
22 #include <FGraphics.h>
24 #include "CtContactPresentationModel.h"
25 #include "CtIContactEventListener.h"
26 #include "CtResourceManager.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Io;
32 using namespace Tizen::Locales;
33 using namespace Tizen::Social;
35 static const wchar_t* IDB_ACCOUNT_ICON_ICQ = L"C02_Icon_ICQ.png";
36 static const wchar_t* IDB_ACCOUNT_ICON_YAHOO = L"C02_Icon_yahoo.png";
37 static const wchar_t* IDB_ACCOUNT_ICON_MSN = L"C02_Icon_windows_live.png";
38 static const wchar_t* IDB_ACCOUNT_ICON_OTHERS = L"C02_Icon_others.png";
40 static const wchar_t* CHARACTER_HYPHEN = L"-";
41 static const wchar_t* CHARACTER_EMPTY = L"";
43 ContactPresentationModel::ContactPresentationModel(void)
44 : __pAssignedCategoryList(null)
45 , __pContactListenerList(null)
47 , __pAddressbook(null)
48 , __defaultNumberIndex(0)
49 , __lastRemovedContactIndex(-1)
50 , __lastRemovedEmailIndex(-1)
56 ContactPresentationModel::~ContactPresentationModel(void)
58 delete __pAddressbook;
61 if (__pContactListenerList != null)
63 __pContactListenerList->RemoveAll(true);
64 delete __pContactListenerList;
67 if (__pAssignedCategoryList != null)
69 __pAssignedCategoryList->RemoveAll(true);
70 delete __pAssignedCategoryList;
75 ContactPresentationModel::Construct(void)
79 AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
81 __pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID);
82 if (__pAddressbook == null)
87 r = __pAddressbook->SetAddressbookChangeEventListener(this);
88 TryCatch(r == E_SUCCESS, , "[%s] Unable to set event listener", GetErrorMessage(r));
90 __pContactListenerList = new (std::nothrow) ArrayList();
91 __pContactListenerList->Construct();
93 __pAssignedCategoryList = new (std::nothrow) ArrayList();
94 __pAssignedCategoryList->Construct();
99 delete __pAddressbook;
100 __pAddressbook = null;
102 __pContactListenerList->RemoveAll();
103 delete __pContactListenerList;
104 __pContactListenerList = null;
106 __pAssignedCategoryList->RemoveAll();
107 delete __pAssignedCategoryList;
108 __pAssignedCategoryList = null;
114 ContactPresentationModel::PrepareNewContact(void)
116 __pContact = new (std::nothrow) Contact();
124 ContactPresentationModel::SetContactId(const Tizen::Social::RecordId contactId, bool isEditing)
126 result r = E_SUCCESS;
129 __pContact = __pAddressbook->GetContactN(contactId);
132 TryReturn(__pContact != null && r == E_SUCCESS, r, "[%s] selected Contact is invalid", GetErrorMessage(r));
134 IList* pList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS);
140 Person* pPerson = AddressbookManager::GetInstance()->GetPersonN(__pContact->GetPersonId());
143 pList->RemoveAll(true);
149 PhoneNumber defaultNumber = pPerson->GetPrimaryPhoneNumber();
151 for (int i = 0; i < pList->GetCount(); i++)
153 PhoneNumber* pPhoneNumber = static_cast<PhoneNumber*>(pList->GetAt(i));
154 if (pPhoneNumber != null && pPhoneNumber->Equals(defaultNumber))
156 __defaultNumberIndex = i;
163 __isEditing = isEditing;
165 IList* pAssignedCategoriesList = __pAddressbook->GetCategoriesByContactN(__pContact->GetRecordId());
166 if (pAssignedCategoriesList == null)
170 IEnumerator* pEnum = pAssignedCategoriesList->GetEnumeratorN();
176 for (int index = 0; pEnum->MoveNext() == E_SUCCESS; index++)
178 Category* pCategory = static_cast<Category *>(pEnum->GetCurrent());
180 if (pCategory != null)
182 AddContactToCategory(pCategory->GetRecordId());
186 pAssignedCategoriesList->RemoveAll(true);
187 delete pAssignedCategoriesList;
191 pList->RemoveAll(true);
199 ContactPresentationModel::SetVcfPath(const Tizen::Base::String& filePath, bool isNewContact)
201 __vcfPath = filePath;
202 __newMode = isNewContact;
204 IList* pPhoneNumberList = null;
205 IList* pList = AddressbookManager::GetInstance()->ParseContactsFromVcardN(filePath);
206 result r = GetLastResult();
207 TryCatch(r == E_SUCCESS && pList != null && pList->GetCount() > 0, r = E_FAILURE, "[%s] ParseContactsFromVcardN() failed", GetErrorMessage(r));
209 __pContact = static_cast<Contact*>(pList->GetAt(0));
210 TryCatch(__pContact != null, r = E_FAILURE, "[E_FAILURE] Unable to cast Contact");
212 pPhoneNumberList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS);
214 if (pPhoneNumberList != null)
216 PhoneNumber* pPhoneNumber = static_cast<PhoneNumber*>(pPhoneNumberList->GetAt(0));
217 if (pPhoneNumber != null)
219 Person* pPerson = AddressbookManager::GetInstance()->GetPersonN(__pContact->GetPersonId());
222 pPerson->SetAsPrimaryPhoneNumber(*pPhoneNumber);
227 delete pPhoneNumberList;
237 ContactPresentationModel::GetVcfPath(void)
243 ContactPresentationModel::GetContactId(void)
245 return __pContact->GetRecordId();
249 ContactPresentationModel::AddContactToCategory(Tizen::Social::RecordId categoryId)
251 result r = E_SUCCESS;
253 if (__newMode || __isEditing)
255 String* pCategoryStringId = new (std::nothrow) String();
257 pCategoryStringId->Append(categoryId);
259 r = __pAssignedCategoryList->Add(*pCategoryStringId);
263 r = AddressbookManager::GetInstance()->AddMemberToCategory(categoryId, __pContact->GetRecordId());
270 ContactPresentationModel::RemoveContactFromAllCategories(void)
272 result r = E_SUCCESS;
274 if (__newMode || __isEditing)
276 if (__pAssignedCategoryList != null)
278 __pAssignedCategoryList->RemoveAll(true);
283 TryReturn(__pContact != null, E_FAILURE, "[E_FAILURE] The contact is invalid.");
285 IList* pCategoryList = __pAddressbook->GetCategoriesByContactN(__pContact->GetRecordId());
286 TryReturn(pCategoryList != null, E_FAILURE, "Unable to get category list");
288 IEnumerator* pEnum = pCategoryList->GetEnumeratorN();
289 while (pEnum->MoveNext() == E_SUCCESS)
291 Category* pCategory = static_cast<Category*>(pEnum->GetCurrent());
292 if (pCategory != null)
294 AddressbookManager::GetInstance()->RemoveMemberFromCategory(pCategory->GetRecordId(), __pContact->GetRecordId());
299 pCategoryList->RemoveAll(true);
300 delete pCategoryList;
307 ContactPresentationModel::RemoveContact(void)
309 return __pAddressbook->RemoveContact(__pContact->GetRecordId());
313 ContactPresentationModel::IsContactRemoved(void)
315 return (__pContact ? false : true);
319 ContactPresentationModel::AddContact(void)
321 return __pAddressbook->AddContact(*__pContact);
325 ContactPresentationModel::UpdateContact(void)
327 return __pAddressbook->UpdateContact(*__pContact);
331 ContactPresentationModel::GetValue(DetailProperty id, int index)
336 TryReturn(__pContact != null, String(), "[E_FAILURE] The contact is invalid.");
340 case DETAIL_PROPERTY_GROUP:
341 returnString = GetCategory();
343 case DETAIL_PROPERTY_RINGTONE:
344 returnString = GetRingtone();
346 case DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER:
348 DetailPhoneNumberType type;
349 returnString = GetDefaultNumber(type);
352 case DETAIL_PROPERTY_PHONE_NUMBER:
354 DetailPhoneNumberType type;
355 returnString = GetPhoneNumber(index, type);
358 case DETAIL_PROPERTY_EMAIL:
360 DetailEmailType type;
361 returnString = GetEmail(index, type);
364 case DETAIL_PROPERTY_IM_ADDRESS:
366 DetailImAddressType type;
367 returnString = GetImAddress(index, type);
370 case DETAIL_PROPERTY_ADDRESS: //fall through
371 case DETAIL_PROPERTY_ADDRESS_POSTAL_CODE: //fall through
372 case DETAIL_PROPERTY_ADDRESS_COUNTRY: //fall through
373 case DETAIL_PROPERTY_ADDRESS_PROVINCE: //fall through
374 case DETAIL_PROPERTY_ADDRESS_CITY: //fall through
375 case DETAIL_PROPERTY_ADDRESS_STREET:
377 DetailAddressType type;
378 returnString = GetAddress(id, index, type);
381 case DETAIL_PROPERTY_BIRTHDAY:
383 returnString = GetDateTime(id);
386 case DETAIL_PROPERTY_URL:
389 returnString = GetUrl(index, type);
392 case DETAIL_PROPERTY_NOTE:
394 IList* pList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_NOTES);
401 String* pNote = static_cast<String *>(pList->GetAt(0));
407 returnString = *pNote;
410 case DETAIL_PROPERTY_DISPLAY_NAME:
412 __pContact->GetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, returnString);
415 case DETAIL_PROPERTY_FIRST_NAME:
417 __pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, returnString);
420 case DETAIL_PROPERTY_LAST_NAME:
422 __pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, returnString);
425 case DETAIL_PROPERTY_MIDDLE_NAME:
427 __pContact->GetValue(CONTACT_PROPERTY_ID_MIDDLE_NAME, returnString);
430 case DETAIL_PROPERTY_NICK_NAME:
432 pList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_NICKNAMES);
439 String* pNickName = static_cast<String *>(pList->GetAt(0));
440 if (pNickName == null)
445 returnString = *pNickName;
448 case DETAIL_PROPERTY_NAME_SUFFIX:
450 __pContact->GetValue(CONTACT_PROPERTY_ID_NAME_SUFFIX, returnString);
453 case DETAIL_PROPERTY_JOB_TITLE:
455 pList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_ORGANIZATIONS);
462 Organization* pOrganization = static_cast<Organization *>(pList->GetAt(0));
463 if (pOrganization == null)
468 returnString = pOrganization->GetJobTitle();
471 case DETAIL_PROPERTY_DEPARTMENT:
473 pList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_ORGANIZATIONS);
480 Organization* pOrganization = static_cast<Organization *>(pList->GetAt(0));
481 if (pOrganization == null)
486 returnString = pOrganization->GetDepartment();
489 case DETAIL_PROPERTY_COMPANY:
491 pList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_ORGANIZATIONS);
498 Organization* pOrganization = static_cast<Organization *>(pList->GetAt(0));
499 if (pOrganization == null)
504 returnString = pOrganization->GetName();
507 case DETAIL_PROPERTY_THUMBNAIL:
509 returnString = __pContact->GetThumbnailPath();
518 pList->RemoveAll(true);
526 ContactPresentationModel::GetDisplayName(Tizen::Base::String& name)
528 result r = E_SUCCESS;
531 TryReturn(__pContact != null, E_FAILURE, "[E_FAILURE] The contact is invalid.");
533 if (__vcfPath.IsEmpty() == true)
535 Person* pPerson = AddressbookManager::GetInstance()->GetPersonN(__pContact->GetPersonId());
536 TryReturn(pPerson != null, E_FAILURE, "[E_FAILURE] The contact is invalid.");
538 name = pPerson->GetDisplayName();
542 String firstName = GetValue(DETAIL_PROPERTY_FIRST_NAME);
543 String middleName = GetValue(DETAIL_PROPERTY_MIDDLE_NAME);
544 String lastName = GetValue(DETAIL_PROPERTY_LAST_NAME);
545 String suffix = GetValue(DETAIL_PROPERTY_NAME_SUFFIX);
547 if (firstName.IsEmpty() == false)
551 if (middleName.IsEmpty() == false)
553 if (name.IsEmpty() == false)
555 name += CHARACTER_SPACE;
557 name += (middleName);
559 if (lastName.IsEmpty() == false)
561 if (name.IsEmpty() == false)
563 name += CHARACTER_SPACE;
567 if (suffix.IsEmpty() == false)
569 if (name.IsEmpty() == false)
571 name += DELIMITER_COMMA;
572 name += CHARACTER_SPACE;
582 ContactPresentationModel::GetBirthday(Tizen::Base::DateTime& value)
584 result r = E_SUCCESS;
586 TryReturn(__pContact != null, E_FAILURE, "[E_FAILURE] The contact is invalid.");
588 IList* pEventList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_EVENTS);
589 if (pEventList == null)
594 ContactEvent* pBirthday = static_cast<ContactEvent *>(pEventList->GetAt(0));
595 if (pBirthday == null)
600 value = pBirthday->GetDate();
602 pEventList->RemoveAll(true);
609 ContactPresentationModel::GetType(DetailProperty id, int index)
616 case DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER:
618 DetailPhoneNumberType type;
620 value = GetDefaultNumber(type);
621 returnString = GetPhoneNumberTypeString(type);
624 case DETAIL_PROPERTY_PHONE_NUMBER:
626 DetailPhoneNumberType type;
628 value = GetPhoneNumber(index, type);
629 returnString = GetPhoneNumberTypeString(type);
632 case DETAIL_PROPERTY_EMAIL:
634 DetailEmailType type;
636 value = GetEmail(index, type);
637 returnString = GetEmailTypeString(type);
640 case DETAIL_PROPERTY_IM_ADDRESS:
642 DetailImAddressType type;
644 value = GetImAddress(index, type);
645 returnString = GetImAddressTypeString(type);
648 case DETAIL_PROPERTY_ADDRESS:
650 DetailAddressType type;
652 value = GetAddress(id, index, type);
653 returnString = GetAddressTypeString(type);
656 case DETAIL_PROPERTY_URL:
660 value = GetUrl(index, type);
661 returnString = GetUrlTypeString(type);
671 Tizen::Graphics::Bitmap*
672 ContactPresentationModel::GetThumbnailN(void)
674 TryReturn(__pContact != null, null, "[E_FAILURE] The contact is invalid.");
676 return __pContact->GetThumbnailN();
679 Tizen::Graphics::Bitmap*
680 ContactPresentationModel::GetAccountIconN(const Tizen::Base::String& account)
682 if (account.Equals(IM_ADDRESS_YAHOO, true))
684 return ResourceManager::GetBitmapN(IDB_ACCOUNT_ICON_YAHOO);
686 else if (account.Equals(IM_ADDRESS_MSN, true))
688 return ResourceManager::GetBitmapN(IDB_ACCOUNT_ICON_MSN);
690 else if (account.Equals(IM_ADDRESS_ICQ, true))
692 return ResourceManager::GetBitmapN(IDB_ACCOUNT_ICON_ICQ);
694 // else if (account.Equals(IM_ADDRESS_AIM, true))
698 // else if (account.Equals(IM_ADDRESS_SKYPE, true))
702 // else if (account.Equals(IM_ADDRESS_QQ, true))
706 // else if (account.Equals(IM_ADDRESS_GOOGLE_TALK, true))
710 // else if (account.Equals(IM_ADDRESS_JABBER, true))
716 return ResourceManager::GetBitmapN(IDB_ACCOUNT_ICON_OTHERS);
723 ContactPresentationModel::GetMultiValuesCount(DetailProperty id)
728 TryReturn(__pContact != null, returnValue, "[E_FAILURE] The contact is invalid.");
732 case DETAIL_PROPERTY_PHONE_NUMBER:
734 pList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS);
737 returnValue = pList->GetCount();
741 case DETAIL_PROPERTY_EMAIL:
743 pList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_EMAILS);
746 returnValue = pList->GetCount();
750 case DETAIL_PROPERTY_IM_ADDRESS:
752 pList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_IMADDRESSES);
755 returnValue = pList->GetCount();
759 case DETAIL_PROPERTY_ADDRESS:
761 pList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_ADDRESSES);
764 returnValue = pList->GetCount();
768 case DETAIL_PROPERTY_URL:
770 pList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_URLS);
773 returnValue = pList->GetCount();
783 pList->RemoveAll(true);
791 ContactPresentationModel::GetCategoryCount(void)
793 return __pAddressbook->GetCategoryCount();
796 Tizen::Base::Collection::IList*
797 ContactPresentationModel::GetAssignedCategoryIdListN(void)
799 IEnumerator* pEnum = null;
800 ArrayList* pCategoryList = new (std::nothrow) ArrayList();
801 pCategoryList->Construct();
803 if (__newMode || __isEditing)
805 pEnum = __pAssignedCategoryList->GetEnumeratorN();
807 for (int index = 0; pEnum->MoveNext() == E_SUCCESS; index++)
809 String* pCategoryStringId = static_cast<String *>(pEnum->GetCurrent());
811 if (pCategoryStringId != null)
813 String* pRetrunCategoryStringId = new (std::nothrow) String(*pCategoryStringId);
815 pCategoryList->Add(*pRetrunCategoryStringId);
821 return pCategoryList;
825 IList* pList = __pAddressbook->GetCategoriesByContactN(__pContact->GetRecordId());
829 pEnum = pList->GetEnumeratorN();
831 for (int index = 0; pEnum->MoveNext() == E_SUCCESS; index++)
833 Category* pCategory = static_cast<Category *>(pEnum->GetCurrent());
835 if (pCategory != null)
837 String* pRetrunCategoryStringId = new (std::nothrow) String();
839 pRetrunCategoryStringId->Append(pCategory->GetRecordId());
840 pCategoryList->Add(*pRetrunCategoryStringId);
844 pList->RemoveAll(true);
849 return pCategoryList;
854 ContactPresentationModel::GetCategory(void)
858 TryReturn(__pContact != null, String(), "[E_FAILURE] The contact is invalid.");
860 if (__newMode || __isEditing)
862 IEnumerator* pEnum = __pAssignedCategoryList->GetEnumeratorN();
863 Category* pCategory = null;
864 String* pCategoryStringId = null;
867 for (int index = 0; pEnum->MoveNext() == E_SUCCESS; index++)
869 pCategoryStringId = static_cast<String*>(pEnum->GetCurrent());
871 if (pCategoryStringId != null)
873 Integer::Parse(*pCategoryStringId, categoryId);
874 pCategory = __pAddressbook->GetCategoryN(categoryId);
877 if (pCategory != null)
879 categoryName = pCategory->GetName();
883 returnString = categoryName;
887 returnString += L", ";
888 returnString += categoryName;
898 Category* pCategory = null;
899 IList* pCategoryList = __pAddressbook->GetCategoriesByContactN(__pContact->GetRecordId());
900 if (pCategoryList == null)
905 IEnumerator* pEnum = pCategoryList->GetEnumeratorN();
906 for (int index = 0; pEnum->MoveNext() == E_SUCCESS; index++)
908 pCategory = static_cast<Category*>(pEnum->GetCurrent());
911 if (pCategory != null)
913 categoryName = pCategory->GetName();
917 returnString = categoryName;
921 returnString += L", ";
922 returnString += categoryName;
928 pCategoryList->RemoveAll(true);
929 delete pCategoryList;
936 ContactPresentationModel::GetDefaultCategoryName(Tizen::Base::String& categoryName)
938 if (categoryName.Equals(DEFAULT_GROUP_FAMILY, true))
940 categoryName.Clear();
941 categoryName = ResourceManager::GetString(L"IDS_PB_BODY_DEFAULT_GROUP_FAMILY");
943 else if (categoryName.Equals(DEFAULT_GROUP_FRIENDS, true))
945 categoryName.Clear();
946 categoryName = ResourceManager::GetString(L"IDS_PB_BODY_DEFAULT_GROUP_FRIENDS");
948 else if (categoryName.Equals(DEFAULT_GROUP_COWORKERS, true))
950 categoryName.Clear();
951 categoryName = ResourceManager::GetString(L"IDS_PB_BODY_CO_WORKERS");
958 ContactPresentationModel::GetRingtone(void)
961 TryReturn(__pContact != null, String(), "[E_FAILURE] The contact is invalid.");
963 result r = __pContact->GetValue(CONTACT_PROPERTY_ID_RINGTONE, returnString);
964 TryReturn(r == E_SUCCESS, String(), "[E_FAILURE] Unable to get value");
966 if (returnString.IsEmpty())
968 returnString = ResourceManager::GetString(L"IDS_PB_BODY_DEFAULT");
974 isFileExisting = file.IsFileExist(returnString);
977 SetValue(DETAIL_PROPERTY_RINGTONE, String());
979 returnString = ResourceManager::GetString(L"IDS_PB_BODY_DEFAULT");
987 ContactPresentationModel::GetDefaultNumber(DetailPhoneNumberType& type)
989 TryReturn(__pContact != null, String(), "[E_FAILURE] The contact is invalid.");
993 IList* pList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS);
994 TryReturn(pList != null, String(), "[E_FAILURE] The contact doesn't have a phone number at least.");
996 PhoneNumber* pPhoneNumber = static_cast<PhoneNumber*>(pList->GetAt(__defaultNumberIndex));
997 if (pPhoneNumber != null)
999 returnString = pPhoneNumber->GetPhoneNumber();
1000 if (returnString.Contains(CHARACTER_HYPHEN))
1002 returnString.Replace(CHARACTER_HYPHEN, CHARACTER_EMPTY);
1004 type = (DetailPhoneNumberType)pPhoneNumber->GetType();
1007 pList->RemoveAll(true);
1010 return returnString;
1014 ContactPresentationModel::GetDefaultNumberIndex(void)
1016 return __defaultNumberIndex;
1020 ContactPresentationModel::GetPhoneNumber(int index, DetailPhoneNumberType& type)
1022 String returnString;
1024 TryReturn(__pContact != null, String(), "[E_FAILURE] The contact is invalid.");
1028 return returnString;
1031 IList* pPhoneNumberList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS);
1032 AppAssert(pPhoneNumberList);
1034 PhoneNumber* pNumber = static_cast<PhoneNumber *>(pPhoneNumberList->GetAt(index));
1035 if (pNumber != null)
1037 returnString = pNumber->GetPhoneNumber();
1039 if (returnString.Contains(CHARACTER_HYPHEN))
1041 returnString.Replace(CHARACTER_HYPHEN, CHARACTER_EMPTY);
1043 type = (DetailPhoneNumberType)pNumber->GetType();
1046 pPhoneNumberList->RemoveAll(true);
1047 delete pPhoneNumberList;
1049 return returnString;
1053 ContactPresentationModel::GetEmail(int index, DetailEmailType& type)
1055 String returnString;
1057 TryReturn(__pContact != null, String(), "[E_FAILURE] The contact is invalid.");
1061 return returnString;
1064 IList* pEmailList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_EMAILS);
1065 AppAssert(pEmailList);
1067 Email* pEmail = static_cast<Email *>(pEmailList->GetAt(index));
1070 returnString = pEmail->GetEmail();
1071 type = (DetailEmailType)pEmail->GetType();
1074 pEmailList->RemoveAll(true);
1077 return returnString;
1081 ContactPresentationModel::GetImAddress(int index, DetailImAddressType& type)
1083 String returnString;
1085 TryReturn(__pContact != null, String(), "[E_FAILURE] The contact is invalid.");
1089 return returnString;
1092 IList* pImAddressList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_IMADDRESSES);
1093 AppAssert(pImAddressList);
1095 ImAddress* pImAddress = static_cast<ImAddress *>(pImAddressList->GetAt(index));
1096 if (pImAddress != null)
1098 returnString = pImAddress->GetImAddress();
1100 String typeString = pImAddress->GetServiceProviderName();
1102 if (typeString.Equals(IM_ADDRESS_AIM, true))
1104 type = DETAIL_IM_ADDRESS_TYPE_AIM;
1106 else if (typeString.Equals(IM_ADDRESS_MSN, true))
1108 type = DETAIL_IM_ADDRESS_TYPE_MSN;
1110 else if (typeString.Equals(IM_ADDRESS_YAHOO, true))
1112 type = DETAIL_IM_ADDRESS_TYPE_YAHOO;
1114 else if (typeString.Equals(IM_ADDRESS_SKYPE, true))
1116 type = DETAIL_IM_ADDRESS_TYPE_SKYPE;
1118 else if (typeString.Equals(IM_ADDRESS_QQ, true))
1120 type = DETAIL_IM_ADDRESS_TYPE_QQ;
1122 else if (typeString.Equals(IM_ADDRESS_GOOGLE_TALK, true))
1124 type = DETAIL_IM_ADDRESS_TYPE_GOOGLE_TALK;
1126 else if (typeString.Equals(IM_ADDRESS_ICQ, true))
1128 type = DETAIL_IM_ADDRESS_TYPE_ICQ;
1130 else if (typeString.Equals(IM_ADDRESS_JABBER, true))
1132 type = DETAIL_IM_ADDRESS_TYPE_JABBER;
1136 type = DETAIL_IM_ADDRESS_TYPE_OTHER;
1140 pImAddressList->RemoveAll(true);
1141 delete pImAddressList;
1143 return returnString;
1147 ContactPresentationModel::GetAddress(DetailProperty id, int index, DetailAddressType& type)
1149 String returnString;
1151 TryReturn(__pContact != null, String(), "[E_FAILURE] The contact is invalid.");
1155 return returnString;
1158 IList* pAddressList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_ADDRESSES);
1159 AppAssert(pAddressList);
1161 Address* pAddress = static_cast<Address *>(pAddressList->GetAt(index));
1162 if (pAddress != null)
1164 String street = pAddress->GetStreet();
1165 String city = pAddress->GetCity();
1166 String state = pAddress->GetState();
1167 String country = pAddress->GetCountry();
1168 String postalCode = pAddress->GetPostalCode();
1172 case DETAIL_PROPERTY_ADDRESS_POSTAL_CODE:
1173 returnString = postalCode;
1175 case DETAIL_PROPERTY_ADDRESS_COUNTRY:
1176 returnString = country;
1178 case DETAIL_PROPERTY_ADDRESS_PROVINCE:
1179 returnString = state;
1181 case DETAIL_PROPERTY_ADDRESS_CITY:
1182 returnString = city;
1184 case DETAIL_PROPERTY_ADDRESS_STREET:
1185 returnString = street;
1187 case DETAIL_PROPERTY_ADDRESS:
1188 if (postalCode.IsEmpty() == false)
1190 returnString.Append(postalCode);
1191 returnString.Append(CHARACTER_SPACE);
1193 if (country.IsEmpty() == false)
1195 returnString.Append(country);
1196 returnString.Append(CHARACTER_SPACE);
1198 if (state.IsEmpty() == false)
1200 returnString.Append(state);
1201 returnString.Append(CHARACTER_SPACE);
1203 if (city.IsEmpty() == false)
1205 returnString.Append(city);
1206 returnString.Append(CHARACTER_SPACE);
1208 if (street.IsEmpty() == false)
1210 returnString.Append(street);
1217 type = (DetailAddressType)pAddress->GetType();
1220 pAddressList->RemoveAll(true);
1221 delete pAddressList;
1223 return returnString;
1227 ContactPresentationModel::GetDateTime(DetailProperty id)
1229 result r = E_SUCCESS;
1230 String returnString;
1234 DateTimeSymbols dateTimeSymbols;
1236 r = dateTimeSymbols.Construct(CALENDAR_GREGORIAN);
1237 TryReturn(r == E_SUCCESS, String(), "[E_FAILURE] Given locale is not supported.");
1238 const IList* pMonthList = dateTimeSymbols.GetShortMonths();
1240 TryReturn(__pContact != null, String(), "[E_FAILURE] The contact is invalid.");
1242 DateTime* pDateTime = new (std::nothrow) DateTime();
1244 if (id == DETAIL_PROPERTY_BIRTHDAY)
1246 const Object* pGettingMonth = null;
1248 r = GetBirthday(*pDateTime);
1249 TryCatch(r == E_SUCCESS, , "[%s] Unable to get value", GetErrorMessage(r));
1251 day = pDateTime->GetDay();
1252 year = pDateTime->GetYear();
1254 pGettingMonth = pMonthList->GetAt(pDateTime->GetMonth() - 1);
1255 TryCatch(pGettingMonth != null, , "[E_FAILURE] Unable to get a month", GetErrorMessage(r));
1257 month.Append(*static_cast<String*>(const_cast<Object*>(pGettingMonth)));
1259 returnString.Append(day);
1260 returnString.Append(CHARACTER_SPACE);
1261 returnString.Append(month);
1262 returnString.Append(CHARACTER_SPACE);
1263 returnString.Append(year);
1269 return returnString;
1273 ContactPresentationModel::GetUrl(int index, DetailUrlType& type)
1275 String returnString;
1277 TryReturn(__pContact != null, String(), "[E_FAILURE] The contact is invalid.");
1279 IList* pUrlList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_URLS);
1280 if (pUrlList == null)
1282 return returnString;
1285 Url* pUrl = static_cast<Url*>(pUrlList->GetAt(index));
1288 returnString = pUrl->GetUrl();
1289 type = (DetailUrlType)pUrl->GetType();
1292 pUrlList->RemoveAll(true);
1295 return returnString;
1299 ContactPresentationModel::AddContactChangeListener(const IContactEventListener& listener)
1301 __pContactListenerList->Add(listener);
1305 ContactPresentationModel::RemoveContactChangeListener(const IContactEventListener& listener)
1307 __pContactListenerList->Remove(listener, false);
1311 ContactPresentationModel::OnContactsChanged(const Tizen::Base::Collection::IList& contactChangeInfoList)
1313 if (__newMode == false && __isEditing == false)
1315 if (__pContact != null)
1317 SetContactId(__pContact->GetRecordId());
1320 else if (__isEditing)
1322 IEnumerator* pEnum = contactChangeInfoList.GetEnumeratorN();
1324 if (pEnum != null && __pContact != null)
1326 while (pEnum->MoveNext() == E_SUCCESS)
1328 const ContactChangeInfo* pChangeInfo = static_cast<const ContactChangeInfo *>(pEnum->GetCurrent());
1330 if (pChangeInfo != null && pChangeInfo->GetChangeType() == RECORD_CHANGE_TYPE_REMOVED && __pContact->GetRecordId() == pChangeInfo->GetContactId())
1332 SetContactId(INVALID_RECORD_ID);
1340 IContactEventListener* pInterface = null;
1341 IEnumerator* pEnum = __pContactListenerList->GetEnumeratorN();
1342 while(pEnum->MoveNext() == E_SUCCESS)
1344 pInterface = static_cast<IContactEventListener*>(pEnum->GetCurrent());
1345 if (pInterface == null)
1350 pInterface->OnContactsChanged();
1357 ContactPresentationModel::OnCategoriesChanged(const Tizen::Base::Collection::IList& categoryChangeInfoList)
1359 IEnumerator* pEnumCategory = categoryChangeInfoList.GetEnumeratorN();
1361 if (pEnumCategory != null && __pContact != null && __pAssignedCategoryList != null)
1363 while (pEnumCategory->MoveNext() == E_SUCCESS)
1365 const CategoryChangeInfo* pChangeInfo = static_cast<const CategoryChangeInfo *>(pEnumCategory->GetCurrent());
1367 if (pChangeInfo != null && pChangeInfo->GetChangeType() == RECORD_CHANGE_TYPE_REMOVED)
1369 RecordId id = pChangeInfo->GetCategoryId();
1371 String* pcurCategoryStringId = new (std::nothrow) String();
1373 pcurCategoryStringId->Append(id);
1375 IEnumerator* pEnum = __pAssignedCategoryList->GetEnumeratorN();
1377 for (int index = 0; pEnum->MoveNext() == E_SUCCESS; index++)
1379 String* pCategoryStringId = static_cast<String*>(pEnum->GetCurrent());
1381 if (pCategoryStringId != null)
1383 if (pcurCategoryStringId->Equals(*pCategoryStringId, false) == true)
1385 __pAssignedCategoryList->Remove(*pCategoryStringId, true);
1394 delete pEnumCategory;
1397 IContactEventListener* pInterface = null;
1398 IEnumerator* pEnum = __pContactListenerList->GetEnumeratorN();
1399 while(pEnum->MoveNext() == E_SUCCESS)
1401 pInterface = static_cast<IContactEventListener*>(pEnum->GetCurrent());
1402 if (pInterface == null)
1407 pInterface->OnCategoriesChanged();
1414 ContactPresentationModel::SetValue(DetailProperty id, const Tizen::Base::String& value, int index)
1416 result r = E_SUCCESS;
1418 TryReturn(__pContact != null, E_FAILURE, "[E_FAILURE] The contact is invalid.");
1420 String trimmedString(value);
1421 trimmedString.Trim();
1423 Email email = Email();
1424 ImAddress imAddress = ImAddress();
1426 PhoneNumber phoneNumber = PhoneNumber();
1430 case DETAIL_PROPERTY_RINGTONE:
1432 r = __pContact->SetValue(CONTACT_PROPERTY_ID_RINGTONE, trimmedString);
1435 case DETAIL_PROPERTY_DEFAULT_PHONE_NUMBER:
1437 __defaultNumberIndex = index;
1440 case DETAIL_PROPERTY_PHONE_NUMBER:
1442 r = SetPhoneNumber(DETAIL_PHONENUMBER_TYPE_MOBILE, trimmedString, index);
1445 case DETAIL_PROPERTY_EMAIL:
1447 r = SetEmail(DETAIL_EMAIL_TYPE_HOME, trimmedString, index);
1450 case DETAIL_PROPERTY_IM_ADDRESS:
1452 r = SetImAddress(DETAIL_IM_ADDRESS_TYPE_MSN, trimmedString, index);
1455 case DETAIL_PROPERTY_ADDRESS: //fall through
1456 case DETAIL_PROPERTY_ADDRESS_POSTAL_CODE: //fall through
1457 case DETAIL_PROPERTY_ADDRESS_COUNTRY: //fall through
1458 case DETAIL_PROPERTY_ADDRESS_PROVINCE: //fall through
1459 case DETAIL_PROPERTY_ADDRESS_CITY: //fall through
1460 case DETAIL_PROPERTY_ADDRESS_STREET:
1462 SetAddress(id, trimmedString);
1463 __pContact->RemoveAt(CONTACT_MPROPERTY_ID_ADDRESSES, index);
1464 r = __pContact->SetAddressAt(index, __address);
1467 r = __pContact->AddAddress(__address);
1471 case DETAIL_PROPERTY_URL:
1473 SetUrl(DETAIL_URL_TYPE_HOME, trimmedString, index);
1476 case DETAIL_PROPERTY_NOTE:
1478 if (value.IsEmpty() == true)
1480 r = __pContact->RemoveAt(CONTACT_MPROPERTY_ID_NOTES, index);
1485 r = __pContact->SetNoteAt(index, value);
1488 r = __pContact->AddNote(value);
1492 case DETAIL_PROPERTY_DISPLAY_NAME:
1494 r = __pContact->SetValue(CONTACT_PROPERTY_ID_DISPLAY_NAME, trimmedString);
1497 case DETAIL_PROPERTY_FIRST_NAME:
1499 r = __pContact->SetValue(CONTACT_PROPERTY_ID_FIRST_NAME, trimmedString);
1502 case DETAIL_PROPERTY_LAST_NAME:
1504 r = __pContact->SetValue(CONTACT_PROPERTY_ID_LAST_NAME, trimmedString);
1507 case DETAIL_PROPERTY_MIDDLE_NAME:
1509 r = __pContact->SetValue(CONTACT_PROPERTY_ID_MIDDLE_NAME, trimmedString);
1512 case DETAIL_PROPERTY_NICK_NAME:
1514 if (trimmedString.IsEmpty() == true)
1516 r = __pContact->RemoveAt(CONTACT_MPROPERTY_ID_NICKNAMES, index);
1521 r = __pContact->SetNicknameAt(index, trimmedString);
1524 r = __pContact->AddNickname(trimmedString);
1528 case DETAIL_PROPERTY_NAME_SUFFIX:
1530 r = __pContact->SetValue(CONTACT_PROPERTY_ID_NAME_SUFFIX, trimmedString);
1533 case DETAIL_PROPERTY_JOB_TITLE:
1535 r = SetOrganization(DETAIL_PROPERTY_JOB_TITLE, trimmedString);
1538 case DETAIL_PROPERTY_DEPARTMENT:
1540 r = SetOrganization(DETAIL_PROPERTY_DEPARTMENT, trimmedString);
1543 case DETAIL_PROPERTY_COMPANY:
1545 r = SetOrganization(DETAIL_PROPERTY_COMPANY, trimmedString);
1556 ContactPresentationModel::AddAddressBook(void)
1558 result r = E_SUCCESS;
1560 if (__newMode == true)
1564 RecordId newPersonId;
1565 AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
1566 IList* pList = pAddressbookManager->GetContactsByPersonN(__pContact->GetPersonId());
1568 if (pList != null && pList->GetCount() > 1)
1570 r = pAddressbookManager->UnlinkContact(__pContact->GetPersonId(), __pContact->GetRecordId(), newPersonId);
1577 r = UpdateContact();
1582 IList* pList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS);
1583 TryReturn(pList != null, r, "[E_FAILURE] The contact doesn't have a phone number at least.");
1585 PhoneNumber* pPhoneNumber = static_cast<PhoneNumber*>(pList->GetAt(__defaultNumberIndex));
1586 if (pPhoneNumber != null)
1588 Person* pPerson = AddressbookManager::GetInstance()->GetPersonN(__pContact->GetPersonId());
1589 if (pPerson != null)
1591 pPerson->SetAsPrimaryPhoneNumber(*pPhoneNumber);
1597 pList->RemoveAll(true);
1601 if (__newMode || __isEditing)
1603 if (__isEditing == true)
1605 __isEditing = false;
1606 RemoveContactFromAllCategories();
1610 IEnumerator* pEnum = __pAssignedCategoryList->GetEnumeratorN();
1611 String* pCategoryStringId = null;
1612 RecordId categoryId;
1614 while (pEnum->MoveNext() == E_SUCCESS)
1616 pCategoryStringId = static_cast<String*>(pEnum->GetCurrent());
1618 if (pCategoryStringId != null)
1620 Integer::Parse(*pCategoryStringId, categoryId);
1621 r = __pAddressbook->AddMemberToCategory(categoryId, __pContact->GetRecordId());
1631 ContactPresentationModel::SetAddress(DetailProperty id, const Tizen::Base::String& value)
1633 result r = E_SUCCESS;
1637 case DETAIL_PROPERTY_ADDRESS_POSTAL_CODE:
1638 r = __address.SetPostalCode(value);
1640 case DETAIL_PROPERTY_ADDRESS_COUNTRY:
1641 r = __address.SetCountry(value);
1643 case DETAIL_PROPERTY_ADDRESS_PROVINCE:
1644 r = __address.SetState(value);
1646 case DETAIL_PROPERTY_ADDRESS_CITY:
1647 r = __address.SetCity(value);
1649 case DETAIL_PROPERTY_ADDRESS_STREET:
1650 r = __address.SetStreet(value);
1660 ContactPresentationModel::SetBirthday(const Tizen::Base::DateTime& value)
1662 result r = E_SUCCESS;
1664 TryReturn(__pContact != null, E_FAILURE, "[E_FAILURE] The contact is invalid.");
1666 ContactEvent birthday;
1667 birthday.SetDate(value);
1669 r = __pContact->SetEventAt(0, birthday);
1672 r = __pContact->AddEvent(birthday);
1679 ContactPresentationModel::RemoveBirthday(void)
1681 result r = E_SUCCESS;
1683 TryReturn(__pContact != null, E_FAILURE, "[E_FAILURE] The contact is invalid.");
1684 r = __pContact->RemoveAt(CONTACT_MPROPERTY_ID_EVENTS, 0);
1690 ContactPresentationModel::SetPhoneNumber(DetailPhoneNumberType type, const Tizen::Base::String& value, int index)
1692 result r = E_SUCCESS;
1696 __lastRemovedContactIndex=-1;
1699 if (value.IsEmpty() == true)
1701 r = __pContact->RemoveAt(CONTACT_MPROPERTY_ID_PHONE_NUMBERS, index);
1702 __lastRemovedContactIndex=index;
1707 PhoneNumber phoneNumber;
1708 phoneNumber.SetPhoneNumber(value);
1709 phoneNumber.SetType((PhoneNumberType)type);
1711 if(__lastRemovedContactIndex!=-1 && index>__lastRemovedContactIndex)
1713 r = __pContact->SetPhoneNumberAt(index-1, phoneNumber);
1717 r = __pContact->SetPhoneNumberAt(index, phoneNumber);
1722 r = __pContact->AddPhoneNumber(phoneNumber);
1729 ContactPresentationModel::SetEmail(DetailEmailType type, const Tizen::Base::String& value, int index)
1731 result r = E_SUCCESS;
1735 __lastRemovedEmailIndex = -1;
1738 if (value.IsEmpty() == true)
1740 r = __pContact->RemoveAt(CONTACT_MPROPERTY_ID_EMAILS, index);
1741 __lastRemovedEmailIndex = index;
1747 email.SetEmail(value);
1748 email.SetType((EmailType)type);
1751 if (__lastRemovedEmailIndex >= 0 && __lastRemovedEmailIndex < index)
1753 r = __pContact->SetEmailAt(index - 1, email);
1757 r = __pContact->SetEmailAt(index, email);
1763 r = __pContact->AddEmail(email);
1770 ContactPresentationModel::SetAddress(DetailAddressType type, const Tizen::Base::String& value, int index, DetailProperty property)
1772 result r = E_SUCCESS;
1774 if (value.IsEmpty() == true)
1776 r = __pContact->RemoveAt(CONTACT_MPROPERTY_ID_ADDRESSES, index);
1782 address.SetType((AddressType)type);
1786 case DETAIL_PROPERTY_ADDRESS_POSTAL_CODE:
1787 address.SetPostalCode(value);
1789 case DETAIL_PROPERTY_ADDRESS_COUNTRY:
1790 address.SetCountry(value);
1792 case DETAIL_PROPERTY_ADDRESS_PROVINCE:
1793 address.SetState(value);
1795 case DETAIL_PROPERTY_ADDRESS_CITY:
1796 address.SetCity(value);
1798 case DETAIL_PROPERTY_ADDRESS_STREET:
1799 address.SetStreet(value);
1806 r = __pContact->SetAddressAt(index, address);
1809 r = __pContact->AddAddress(address);
1816 ContactPresentationModel::SetUrl(DetailUrlType type, const Tizen::Base::String& value, int index)
1818 result r = E_SUCCESS;
1820 if (value.IsEmpty() == true)
1822 r = __pContact->RemoveAt(CONTACT_MPROPERTY_ID_URLS, index);
1828 url.SetType(UrlType(type));
1831 r = __pContact->SetUrlAt(index, url);
1834 r = __pContact->AddUrl(url);
1841 ContactPresentationModel::SetImAddress(DetailImAddressType type, const Tizen::Base::String& value, int index)
1843 result r = E_SUCCESS;
1845 if (value.IsEmpty() == true)
1847 r = __pContact->RemoveAt(CONTACT_MPROPERTY_ID_IMADDRESSES, index);
1852 ImAddress imAddress;
1853 imAddress.SetImAddress(value);
1854 imAddress.SetServiceProviderName(GetImAddressTypeString(type));
1855 r = __pContact->SetImAddressAt(index, imAddress);
1859 r = __pContact->AddImAddress(imAddress);
1866 ContactPresentationModel::SetThumbnail(const Tizen::Base::String& filePath)
1868 result r = E_SUCCESS;
1870 TryReturn(__pContact != null, E_FAILURE, "[E_FAILURE] The contact is invalid.");
1872 r = __pContact->SetThumbnail(filePath);
1878 ContactPresentationModel::SetOrganization(DetailProperty id, const Tizen::Base::String& value)
1880 TryReturn((id >= DETAIL_PROPERTY_JOB_TITLE && id <= DETAIL_PROPERTY_COMPANY), E_FAILURE, "[E_FAILURE] Unable to set the specific id");
1882 result r = E_SUCCESS;
1884 IList* pList = __pContact->GetValuesN(CONTACT_MPROPERTY_ID_ORGANIZATIONS);
1891 if (pList->GetCount() == 0)
1893 if (value.IsEmpty())
1898 Organization organization;
1902 case DETAIL_PROPERTY_JOB_TITLE:
1904 organization.SetJobTitle(value);
1907 case DETAIL_PROPERTY_DEPARTMENT:
1909 organization.SetDepartment(value);
1912 case DETAIL_PROPERTY_COMPANY:
1914 organization.SetName(value);
1919 r = __pContact->AddOrganization(organization);
1923 Organization* pOrganization = static_cast<Organization *>(pList->GetAt(0));
1924 if (pOrganization == null)
1931 case DETAIL_PROPERTY_JOB_TITLE:
1933 pOrganization->SetJobTitle(value);
1936 case DETAIL_PROPERTY_DEPARTMENT:
1938 pOrganization->SetDepartment(value);
1941 case DETAIL_PROPERTY_COMPANY:
1943 pOrganization->SetName(value);
1948 if (pOrganization->GetJobTitle().IsEmpty() && pOrganization->GetDepartment().IsEmpty() && pOrganization->GetName().IsEmpty())
1950 r = __pContact->RemoveAt(CONTACT_MPROPERTY_ID_ORGANIZATIONS, 0);
1954 if (value.IsEmpty())
1956 r = __pContact->RemoveAt(CONTACT_MPROPERTY_ID_ORGANIZATIONS, 0);
1960 r = __pContact->AddOrganization(*pOrganization);
1965 r = __pContact->SetOrganizationAt(0, *pOrganization);
1970 pList->RemoveAll(true);
1977 ContactPresentationModel::GetPhoneNumberTypeString(DetailPhoneNumberType type)
1979 String returnString;
1983 case DETAIL_PHONENUMBER_TYPE_HOME:
1985 returnString = ResourceManager::GetString(L"IDS_PB_BODY_HOME");
1988 case DETAIL_PHONENUMBER_TYPE_WORK:
1990 returnString = ResourceManager::GetString(L"IDS_PB_BODY_WORK");
1993 case DETAIL_PHONENUMBER_TYPE_MOBILE:
1995 returnString = ResourceManager::GetString(L"IDS_PB_BODY_MOBILE");
1998 case DETAIL_PHONENUMBER_TYPE_HOME_FAX:
2000 returnString = ResourceManager::GetString(L"IDS_PB_BODY_FAX_HHOME");
2003 case DETAIL_PHONENUMBER_TYPE_WORK_FAX:
2005 returnString = ResourceManager::GetString(L"IDS_PB_BODY_FAX_HWORK");
2008 case DETAIL_PHONENUMBER_TYPE_PAGER:
2010 returnString = ResourceManager::GetString(L"IDS_PB_BODY_PAGER");
2013 case DETAIL_PHONENUMBER_TYPE_OTHER:
2015 returnString = ResourceManager::GetString(L"IDS_PB_BODY_OTHER");
2020 return returnString;
2024 ContactPresentationModel::GetEmailTypeString(DetailEmailType type)
2026 String returnString;
2030 case DETAIL_EMAIL_TYPE_HOME:
2032 returnString = ResourceManager::GetString(L"IDS_PB_BODY_HOME");
2035 case DETAIL_EMAIL_TYPE_WORK:
2037 returnString = ResourceManager::GetString(L"IDS_PB_BODY_WORK");
2040 case DETAIL_EMAIL_TYPE_OTHER:
2042 returnString = ResourceManager::GetString(L"IDS_PB_BODY_OTHER");
2047 return returnString;
2051 ContactPresentationModel::GetAddressTypeString(DetailAddressType type)
2053 String returnString;
2057 case DETAIL_ADDRESS_TYPE_HOME:
2059 returnString = ResourceManager::GetString(L"IDS_PB_BODY_HOME");
2062 case DETAIL_ADDRESS_TYPE_WORK:
2064 returnString = ResourceManager::GetString(L"IDS_PB_BODY_WORK");
2067 case DETAIL_ADDRESS_TYPE_OTHER:
2069 returnString = ResourceManager::GetString(L"IDS_PB_BODY_OTHER");
2074 return returnString;
2078 ContactPresentationModel::GetUrlTypeString(DetailUrlType type)
2080 String returnString;
2084 case DETAIL_URL_TYPE_HOME:
2086 returnString = ResourceManager::GetString(L"IDS_PB_BODY_HOME");
2089 case DETAIL_URL_TYPE_WORK:
2091 returnString = ResourceManager::GetString(L"IDS_PB_BODY_WORK");
2094 case DETAIL_URL_TYPE_OTHER:
2096 returnString = ResourceManager::GetString(L"IDS_PB_BODY_OTHER");
2101 return returnString;
2105 ContactPresentationModel::GetImAddressTypeString(DetailImAddressType type)
2107 String returnString;
2111 case DETAIL_IM_ADDRESS_TYPE_AIM:
2113 returnString = IM_ADDRESS_AIM;
2116 case DETAIL_IM_ADDRESS_TYPE_MSN:
2118 returnString = IM_ADDRESS_MSN;
2121 case DETAIL_IM_ADDRESS_TYPE_YAHOO:
2123 returnString = IM_ADDRESS_YAHOO;
2126 case DETAIL_IM_ADDRESS_TYPE_SKYPE:
2128 returnString = IM_ADDRESS_SKYPE;
2131 case DETAIL_IM_ADDRESS_TYPE_QQ:
2133 returnString = IM_ADDRESS_QQ;
2136 case DETAIL_IM_ADDRESS_TYPE_GOOGLE_TALK:
2138 returnString = IM_ADDRESS_GOOGLE_TALK;
2141 case DETAIL_IM_ADDRESS_TYPE_ICQ:
2143 returnString = IM_ADDRESS_ICQ;
2146 case DETAIL_IM_ADDRESS_TYPE_JABBER:
2148 returnString = IM_ADDRESS_JABBER;
2151 case DETAIL_IM_ADDRESS_TYPE_OTHER:
2153 returnString = ResourceManager::GetString(L"IDS_PB_BODY_OTHER");
2158 return returnString;
2161 DetailPhoneNumberType
2162 ContactPresentationModel::GetPhoneNumberType(int index)
2164 DetailPhoneNumberType type;
2167 value = GetPhoneNumber(index, type);
2173 ContactPresentationModel::GetEmailType(int index)
2175 DetailEmailType type;
2178 value = GetEmail(index, type);
2184 ContactPresentationModel::GetAddressType(DetailProperty id, int index)
2186 DetailAddressType type;
2189 value = GetAddress(id, index, type);
2195 ContactPresentationModel::GetUrlType(int index)
2200 value = GetUrl(index, type);
2206 ContactPresentationModel::GetImAddressType(int index)
2208 DetailImAddressType type;
2211 value = GetImAddress(index, type);
2217 ContactPresentationModel::SetAsFavorite(bool isFavorite)
2219 AddressbookManager::GetInstance()->SetPersonAsFavorite(__pContact->GetPersonId(), isFavorite);
2223 ContactPresentationModel::IsFavorite(void)
2225 bool isFavorite = false;
2226 PersonId personId = __pContact->GetPersonId();
2228 Person* pPerson = AddressbookManager::GetInstance()->GetPersonN(personId);
2229 if (pPerson == null)
2234 isFavorite = pPerson->IsFavorite();