2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
19 * @author Lukasz Marek (l.marek@samsung.com)
26 namespace WrtDeviceApis {
33 m_fullNameIsSet(false),
34 m_firstNameIsSet(false),
35 m_lastNameIsSet(false),
36 m_phoneticNameIsSet(false),
37 m_companyIsSet(false),
39 m_photoUriIsSet(false),
40 m_ringTonePathIsSet(false)
47 //nothing to do in destructor
51 int Contact::getId() const
53 //return id of contact
57 void Contact::setId(int value)
59 //set new id of contact
63 std::string Contact::getFullName() const
66 //when fullname is not set then return concatendation of first name and last name
67 return m_fullName.empty() ? m_firstName + " " + m_lastName : m_fullName;
70 void Contact::setFullName(const std::string &value)
74 //mark full name as set
75 m_fullNameIsSet = true;
78 std::string Contact::getFirstName() const
84 void Contact::setFirstName(const std::string &value)
88 //mark first name as set
89 m_firstNameIsSet = true;
92 std::string Contact::getLastName() const
98 void Contact::setLastName(const std::string &value)
102 //mark last name as set
103 m_lastNameIsSet = true;
106 const std::vector<std::string> &Contact::getNickNames() const
108 //returns nicknames array
112 void Contact::setNickNames(const std::vector<std::string> &value)
118 std::string Contact::getPhoneticName() const
120 //return phoneticName
121 return m_phoneticName;
124 void Contact::setPhoneticName(const std::string &value)
126 //set new phoneticName
127 m_phoneticName = value;
128 m_phoneticNameIsSet = true;
131 const std::vector<ContactAddressPtr> &Contact::getAddresses() const
133 //return addresses array
137 void Contact::setAddresses(const std::vector<ContactAddressPtr> &value)
143 std::string Contact::getPhotoUri() const
149 void Contact::setPhotoUri(const std::string &value)
153 //mark photo uri as set
154 m_photoUriIsSet = true;
157 std::string Contact::getRingTonePath() const
160 return m_ringTonePath;
163 void Contact::setRingTonePath(const std::string &value)
166 m_ringTonePath = value;
167 //mark ringtone as set
168 m_ringTonePathIsSet = true;
171 const std::vector<ContactPhoneNumberPtr> &Contact::getPhoneNumbers() const
173 //return phone numbers
174 return m_phoneNumbers;
177 void Contact::setPhoneNumbers(const std::vector<ContactPhoneNumberPtr> &value)
179 //set new phone numbers
180 m_phoneNumbers = value;
183 const std::vector<ContactEmailPtr> &Contact::getEmails() const
189 void Contact::setEmails(const std::vector<ContactEmailPtr> &value)
195 std::string Contact::getCompany() const
201 void Contact::setCompany(const std::string &value)
205 //mark company as set
206 m_companyIsSet = true;
209 std::string Contact::getTitle() const
215 void Contact::setTitle(const std::string &value)
223 const std::vector<std::string> &Contact::getGroups() const
229 void Contact::setGroups(const std::vector<std::string> &value)
235 bool Contact::getIdIsSet() const
237 //return true when id is set
241 bool Contact::getFullNameIsSet() const
243 //return true when fullname is set
244 return m_fullNameIsSet;
247 bool Contact::getFirstNameIsSet() const
249 //return true when first name is set
250 return m_firstNameIsSet;
253 bool Contact::getLastNameIsSet() const
255 //return true when last name is set
256 return m_lastNameIsSet;
259 bool Contact::getCompanyIsSet() const
261 //return true when company is set
262 return m_companyIsSet;
265 bool Contact::getTitleIsSet() const
267 //return true when title is set
271 bool Contact::getPhotoIsSet() const
273 //return true when photo uri is set
274 return m_photoUriIsSet;
277 bool Contact::getRingPathIsSet() const
279 //return true when ring tone is set
280 return m_ringTonePathIsSet;
283 bool Contact::getNicknameIsSet() const
285 //return true when nicknames is set
286 return m_nicknames.size() != 0;
289 bool Contact::getPhoneticIsSet() const
291 //return true when phoneticName is set
292 return m_phoneticNameIsSet;
295 bool Contact::getAddressIsSet() const
297 //return true when addressess are set
298 return m_addresses.size() != 0;
301 bool Contact::getPhoneNumberIsSet() const
303 //return true when phone numbers are set
304 return m_phoneNumbers.size() != 0;
307 bool Contact::getEmailIsSet() const
309 //return true when emails are set
310 return m_emails.size() != 0;
313 void Contact::clear()
324 m_phoneNumbers.clear();
329 //mark fields as not set
330 m_fullNameIsSet = false;
331 m_firstNameIsSet = false;
332 m_lastNameIsSet = false;
333 m_phoneticNameIsSet = false;
334 m_companyIsSet = false;
335 m_titleIsSet = false;
336 m_photoUriIsSet = false;
337 m_ringTonePathIsSet = false;
340 ContactPtr Contact::clone()
343 //use defaul copy constructor
344 ContactPtr result(new Contact(*this));
345 std::vector<ContactAddressPtr> addresses;
346 std::vector<ContactPhoneNumberPtr> phoneNumbers;
347 std::vector<ContactEmailPtr> emails;
348 //clone internal representation of addresses
349 for (std::size_t i = 0; i < m_addresses.size(); ++i) {
350 addresses.push_back(m_addresses[i]->clone());
352 result->setAddresses(addresses);
353 //clone internal representation of phone numbers
354 for (std::size_t i = 0; i < m_phoneNumbers.size(); ++i) {
355 phoneNumbers.push_back(m_phoneNumbers[i]->clone());
357 result->setPhoneNumbers(phoneNumbers);
358 //clone internal representation of emails
359 for (std::size_t i = 0; i < m_emails.size(); ++i) {
360 emails.push_back(m_emails[i]->clone());
362 result->setEmails(emails);