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.
20 * @author Kisub Song (kisubs.song@samsung.com)
22 * @brief Declaration of the JSPerson class
25 #ifndef _TIZEN_CONTACT_JS_PERSON_H_
26 #define _TIZEN_CONTACT_JS_PERSON_H_
28 #include <JavaScriptCore/JavaScript.h>
29 #include <dpl/shared_ptr.h>
30 #include <CommonsJavaScript/PrivateObject.h>
31 #include <Commons/IEvent.h>
38 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<PersonPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSPersonPrivObject;
41 public DeviceAPI::Common::SecurityAccessor,
42 public JSPersonPrivObject
45 JSPersonPriv(JSContextRef context, PersonPtr person) :
46 DeviceAPI::Common::SecurityAccessor(),
47 JSPersonPrivObject(context, person)
51 virtual ~JSPersonPriv()
59 * This initializes this JS class in the JS Engine.
61 static JSClassRef getClassRef();
63 static bool isObjectOfClass(JSContextRef context, JSValueRef value);
65 static PersonPtr getPerson(JSContextRef context, JSValueRef value);
69 * The callback invoked when an object is first created.
71 static void Initialize(JSContextRef context, JSObjectRef object);
74 * The callback invoked when an object is finalized.
76 static void Finalize(JSObjectRef object);
79 * This structure contains properties and callbacks that define a type of object.
81 static JSClassDefinition m_classInfo;
84 * This structure describes a statically declared function property.
86 static JSStaticFunction m_functions[];
89 * This member variable contains the initialization values for the static properties of this class.
90 * The values are given according to the data structure JSPropertySpec
92 static JSStaticValue m_property[];
94 static JSClassRef m_classRef;
96 static JSObjectRef createJSObject(JSContextRef context, PersonPtr person);
98 static PersonPtr getPrivData(JSObjectRef object);
100 static bool hasInstance(JSContextRef context,
101 JSObjectRef constructor,
102 JSValueRef possibleInstance,
103 JSValueRef* exception);
105 static JSValueRef getId(JSContextRef context,
107 JSStringRef propertyName,
108 JSValueRef* exception);
110 static JSValueRef getDisplayName(JSContextRef context,
112 JSStringRef propertyName,
113 JSValueRef* exception);
115 static JSValueRef getContactCount(JSContextRef context,
117 JSStringRef propertyName,
118 JSValueRef* exception);
120 static JSValueRef getHasPhoneNumber(JSContextRef context,
122 JSStringRef propertyName,
123 JSValueRef* exception);
125 static JSValueRef getHasEmail(JSContextRef context,
127 JSStringRef propertyName,
128 JSValueRef* exception);
130 static JSValueRef getIsFavorite(JSContextRef context,
132 JSStringRef propertyName,
133 JSValueRef* exception);
135 static bool setIsFavorite(JSContextRef context,
137 JSStringRef propertyName,
139 JSValueRef* exception);
141 static JSValueRef getPhotoURI(JSContextRef context,
143 JSStringRef propertyName,
144 JSValueRef* exception);
146 static bool setPhotoURI(JSContextRef context,
148 JSStringRef propertyName,
150 JSValueRef* exception);
152 static JSValueRef getRingtoneURI(JSContextRef context,
154 JSStringRef propertyName,
155 JSValueRef* exception);
157 static bool setRingtoneURI(JSContextRef context,
159 JSStringRef propertyName,
161 JSValueRef* exception);
163 static JSValueRef getDisplayContactId(JSContextRef context,
165 JSStringRef propertyName,
166 JSValueRef* exception);
168 static bool setDisplayContactId(JSContextRef context,
170 JSStringRef propertyName,
172 JSValueRef* exception);
174 static JSValueRef link(JSContextRef context,
176 JSObjectRef thisObject,
177 size_t argumentCount,
178 const JSValueRef arguments[],
179 JSValueRef* exception);
181 static JSValueRef unlink(JSContextRef context,
183 JSObjectRef thisObject,
184 size_t argumentCount,
185 const JSValueRef arguments[],
186 JSValueRef* exception);
192 #endif // _TIZEN_CONTACT_JS_PERSON_H_