Update change log and spec for wrt-plugins-tizen_0.4.70
[framework/web/wrt-plugins-tizen.git] / src / Contact / JSPerson.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file        JSPerson.h
20  * @author      Kisub Song (kisubs.song@samsung.com)
21  * @version     0.1
22  * @brief       Declaration of the JSPerson class
23  */
24
25 #ifndef _TIZEN_CONTACT_JS_PERSON_H_
26 #define _TIZEN_CONTACT_JS_PERSON_H_
27
28 #include <JavaScriptCore/JavaScript.h>
29 #include <dpl/shared_ptr.h>
30 #include <CommonsJavaScript/PrivateObject.h>
31 #include <Commons/IEvent.h>
32 #include <Security.h>
33 #include "IPerson.h"
34
35 namespace DeviceAPI {
36 namespace Contact {
37
38 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<PersonPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSPersonPrivObject;
39
40 class JSPersonPriv :
41         public DeviceAPI::Common::SecurityAccessor,
42         public JSPersonPrivObject
43 {
44 public:
45         JSPersonPriv(JSContextRef context, PersonPtr person) :
46                 DeviceAPI::Common::SecurityAccessor(),
47                 JSPersonPrivObject(context, person)
48         {
49         }
50
51         virtual ~JSPersonPriv()
52         {
53         }
54 };
55
56 class JSPerson {
57 public:
58         /*
59         * This initializes this JS class in the JS Engine.
60         */
61         static JSClassRef getClassRef();
62
63         static bool isObjectOfClass(JSContextRef context, JSValueRef value);
64
65         static PersonPtr getPerson(JSContextRef context, JSValueRef value);
66
67 private:
68    /**
69         * The callback invoked when an object is first created.
70         */
71         static void Initialize(JSContextRef context, JSObjectRef object);
72
73    /**
74         * The callback invoked when an object is finalized.
75         */
76         static void Finalize(JSObjectRef object);
77
78    /**
79         * This structure contains properties and callbacks that define a type of object.
80         */
81         static JSClassDefinition m_classInfo;
82
83    /**
84         * This structure describes a statically declared function property.
85         */
86         static JSStaticFunction m_functions[];
87
88         /**
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
91          */
92         static JSStaticValue m_property[];
93
94         static JSClassRef m_classRef;
95
96         static JSObjectRef createJSObject(JSContextRef context, PersonPtr person);
97
98         static PersonPtr getPrivData(JSObjectRef object);
99
100         static bool hasInstance(JSContextRef context,
101                         JSObjectRef constructor,
102                         JSValueRef possibleInstance,
103                         JSValueRef* exception);
104
105         static JSValueRef getId(JSContextRef context,
106                         JSObjectRef object,
107                         JSStringRef propertyName,
108                         JSValueRef* exception);
109
110         static JSValueRef getDisplayName(JSContextRef context,
111                         JSObjectRef object,
112                         JSStringRef propertyName,
113                         JSValueRef* exception);
114
115         static JSValueRef getContactCount(JSContextRef context,
116                         JSObjectRef object,
117                         JSStringRef propertyName,
118                         JSValueRef* exception);
119
120         static JSValueRef getHasPhoneNumber(JSContextRef context,
121                         JSObjectRef object,
122                         JSStringRef propertyName,
123                         JSValueRef* exception);
124
125         static JSValueRef getHasEmail(JSContextRef context,
126                         JSObjectRef object,
127                         JSStringRef propertyName,
128                         JSValueRef* exception);
129
130         static JSValueRef getIsFavorite(JSContextRef context,
131                         JSObjectRef object,
132                         JSStringRef propertyName,
133                         JSValueRef* exception);
134
135         static bool setIsFavorite(JSContextRef context,
136                         JSObjectRef object,
137                         JSStringRef propertyName,
138                         JSValueRef value,
139                         JSValueRef* exception);
140
141         static JSValueRef getPhotoURI(JSContextRef context,
142                         JSObjectRef object,
143                         JSStringRef propertyName,
144                         JSValueRef* exception);
145
146         static bool setPhotoURI(JSContextRef context,
147                         JSObjectRef object,
148                         JSStringRef propertyName,
149                         JSValueRef value,
150                         JSValueRef* exception);
151
152         static JSValueRef getRingtoneURI(JSContextRef context,
153                         JSObjectRef object,
154                         JSStringRef propertyName,
155                         JSValueRef* exception);
156
157         static bool setRingtoneURI(JSContextRef context,
158                         JSObjectRef object,
159                         JSStringRef propertyName,
160                         JSValueRef value,
161                         JSValueRef* exception);
162
163         static JSValueRef getDisplayContactId(JSContextRef context,
164                         JSObjectRef object,
165                         JSStringRef propertyName,
166                         JSValueRef* exception);
167
168         static bool setDisplayContactId(JSContextRef context,
169                         JSObjectRef object,
170                         JSStringRef propertyName,
171                         JSValueRef value,
172                         JSValueRef* exception);
173
174         static JSValueRef link(JSContextRef context,
175                         JSObjectRef object,
176                         JSObjectRef thisObject,
177                         size_t argumentCount,
178                         const JSValueRef arguments[],
179                         JSValueRef* exception);
180
181         static JSValueRef unlink(JSContextRef context,
182                         JSObjectRef object,
183                         JSObjectRef thisObject,
184                         size_t argumentCount,
185                         const JSValueRef arguments[],
186                         JSValueRef* exception);
187 };
188
189 } // Contact
190 } // DeviceAPI
191
192 #endif // _TIZEN_CONTACT_JS_PERSON_H_