2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file ContactPhoneNumber.cpp
20 * @author Kisub Song (kisubs.song@samsung.com)
25 #include "ContactPhoneNumber.h"
32 ContactPhoneNumber::ContactPhoneNumber() :
36 m_types = ContactPhoneNumberTypeArrayPtr(new ContactPhoneNumberTypeArray());
37 is_typesSetJSArray = false;
39 m_typesJsValue = NULL;
43 ContactPhoneNumber::~ContactPhoneNumber()
45 if(IsTypesSetJSArray()){
46 JSContextRef contextRef = getContext();
47 JSObjectRef tempJSObject = getTypesJSObj();
48 JSValueUnprotect(contextRef, tempJSObject);
52 std::string ContactPhoneNumber::getNumber() const
57 void ContactPhoneNumber::setNumber(const std::string &value)
63 void ContactPhoneNumber::unsetNumber()
66 m_numberIsSet = false;
69 bool ContactPhoneNumber::getNumberIsSet() const
74 bool ContactPhoneNumber::getIsDefault() const
79 void ContactPhoneNumber::setIsDefault(const bool &value)
84 ContactPhoneNumberTypeArrayPtr ContactPhoneNumber::getTypes() const
89 void ContactPhoneNumber::setTypes(const ContactPhoneNumberTypeArrayPtr &value)
94 void ContactPhoneNumber::addType(const ContactPhoneNumberType value)
96 m_types->push_back(value);
99 bool ContactPhoneNumber::isTypeOf(const ContactPhoneNumberType value) const
101 return std::find(m_types->begin(), m_types->end(), value) != m_types->end();
104 int ContactPhoneNumber::getTypesNum() const
106 return m_types->size();
109 void ContactPhoneNumber::clear()
112 m_numberIsSet = false;
116 m_types = ContactPhoneNumberTypeArrayPtr(new ContactPhoneNumberTypeArray());
119 ContactPhoneNumberPtr ContactPhoneNumber::clone() const
121 ContactPhoneNumberPtr result(new ContactPhoneNumber());
123 result->m_number = m_number;
124 result->m_numberIsSet = m_numberIsSet;
126 result->m_isDefault = m_isDefault;
128 result->m_types = ContactPhoneNumberTypeArrayPtr(new ContactPhoneNumberTypeArray());
129 ContactPhoneNumberTypeArray::iterator typeIter;
130 for(typeIter = m_types->begin(); typeIter != m_types->end(); typeIter++)
132 ContactPhoneNumberType type = *typeIter;
133 result->m_types->push_back(type);
139 void ContactPhoneNumber::setTypesJSArray(bool value, JSObjectRef initValue)
141 is_typesSetJSArray = value;
142 m_typesObj = initValue;
145 JSObjectRef ContactPhoneNumber::getTypesJSObj()
150 JSValueRef ContactPhoneNumber::getTypesJSArray()
152 return m_typesJsValue;
155 bool ContactPhoneNumber::IsTypesSetJSArray() const
157 return is_typesSetJSArray;
160 void ContactPhoneNumber::resetTypesJSObj()
162 if(IsTypesSetJSArray()){
163 JSContextRef contextRef = getContext();
164 JSObjectRef tempJSObject = getTypesJSObj();
165 JSValueUnprotect(contextRef, tempJSObject);
167 is_typesSetJSArray = false;
169 m_typesJsValue = NULL;
172 void ContactPhoneNumber::setContext(JSContextRef contextRef)
174 if(m_context == NULL)
175 m_context = contextRef;
178 JSContextRef ContactPhoneNumber::getContext()