Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Contact / JSContactName.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * @file        JSContactName.h
19  * @author      Kisub Song (kisubs.song@samsung.com)
20  * @version     0.1
21  * @brief       Declaration of the JSContactName class
22  */
23
24 #ifndef _TIZEN_CONTACT_JS_CONTACT_NAME_H_
25 #define _TIZEN_CONTACT_JS_CONTACT_NAME_H_
26
27 #include <JavaScriptCore/JavaScript.h>
28 #include <dpl/shared_ptr.h>
29 #include <CommonsJavaScript/PrivateObject.h>
30 #include <Commons/IEvent.h>
31 #include <API/Contact/ContactName.h>
32
33 namespace TizenApis {
34 namespace Tizen1_0 {
35 namespace Contact {
36
37 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Contact::ContactNamePtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSContactNamePriv;
38
39 class JSContactName {
40 public:
41         /*
42         * This initializes this JS class in the JS Engine.
43         */
44         static JSClassRef getClassRef();
45
46         static JSValueRef createJSObject(JSContextRef context,
47                         const std::string& prefix,
48                         const std::string& firstName,
49                         const std::string& middleName,
50                         const std::string& lastName,
51                         const TizenApis::Api::Contact::StringArrayPtr& nicknames,
52                         const std::string& phoneticName,
53                         const std::string& displayName);
54
55         static bool isObjectOfClass(JSContextRef context, JSValueRef value);
56
57         static TizenApis::Api::Contact::ContactNamePtr getContactName(JSContextRef context, JSValueRef value);
58
59 private:
60    /**
61         * The callback invoked when an object is first created.
62         */
63         static void Initialize(JSContextRef context, JSObjectRef object);
64
65    /**
66         * The callback invoked when an object is finalized.
67         */
68         static void Finalize(JSObjectRef object);
69
70    /**
71         * This structure contains properties and callbacks that define a type of object.
72         */
73         static JSClassDefinition m_classInfo;
74
75    /**
76         * This structure describes a statically declared function property.
77         */
78         static JSStaticFunction m_functions[];
79
80         /**
81          * This member variable contains the initialization values for the static properties of this class.
82          * The values are given according to the data structure JSPropertySpec
83          */
84         static JSStaticValue m_property[];
85
86         static JSClassRef m_classRef;
87
88         static TizenApis::Api::Contact::ContactNamePtr getPrivData(JSObjectRef object);
89
90         static JSValueRef getPrefix(JSContextRef context,
91                         JSObjectRef object,
92                         JSStringRef propertyName,
93                         JSValueRef* exception);
94
95         static bool setPrefix(JSContextRef context,
96                         JSObjectRef object,
97                         JSStringRef propertyName,
98                         JSValueRef value,
99                         JSValueRef* exception);
100
101         static JSValueRef getFirstName(JSContextRef context,
102                         JSObjectRef object,
103                         JSStringRef propertyName,
104                         JSValueRef* exception);
105
106         static bool setFirstName(JSContextRef context,
107                         JSObjectRef object,
108                         JSStringRef propertyName,
109                         JSValueRef value,
110                         JSValueRef* exception);
111
112         static JSValueRef getMiddleName(JSContextRef context,
113                         JSObjectRef object,
114                         JSStringRef propertyName,
115                         JSValueRef* exception);
116
117         static bool setMiddleName(JSContextRef context,
118                         JSObjectRef object,
119                         JSStringRef propertyName,
120                         JSValueRef value,
121                         JSValueRef* exception);
122
123         static JSValueRef getLastName(JSContextRef context,
124                         JSObjectRef object,
125                         JSStringRef propertyName,
126                         JSValueRef* exception);
127
128         static bool setLastName(JSContextRef context,
129                         JSObjectRef object,
130                         JSStringRef propertyName,
131                         JSValueRef value,
132                         JSValueRef* exception);
133
134         static JSValueRef getNicknames(JSContextRef context,
135                         JSObjectRef object,
136                         JSStringRef propertyName,
137                         JSValueRef* exception);
138
139         static bool setNicknames(JSContextRef context,
140                         JSObjectRef object,
141                         JSStringRef propertyName,
142                         JSValueRef value,
143                         JSValueRef* exception);
144
145         static JSValueRef getPhoneticName(JSContextRef context,
146                         JSObjectRef object,
147                         JSStringRef propertyName,
148                         JSValueRef* exception);
149
150         static bool setPhoneticName(JSContextRef context,
151                         JSObjectRef object,
152                         JSStringRef propertyName,
153                         JSValueRef value,
154                         JSValueRef* exception);
155
156         static JSValueRef getDisplayName(JSContextRef context,
157                         JSObjectRef object,
158                         JSStringRef propertyName,
159                         JSValueRef* exception);
160
161         static bool setDisplayName(JSContextRef context,
162                         JSObjectRef object,
163                         JSStringRef propertyName,
164                         JSValueRef value,
165                         JSValueRef* exception);
166
167 };
168
169 } // Contact
170 } // Tizen1_0
171 } // TizenApis
172
173 #endif // _TIZEN_CONTACT_JS_CONTACT_NAME_H_