tizen 2.3 release
[framework/web/wearable/wrt-plugins-tizen.git] / src / Application / JSApplicationControlData.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 #ifndef TIZENAPIS_TIZEN_JS_APPLICATION_CONTROL_DATA_H_
19 #define TIZENAPIS_TIZEN_JS_APPLICATION_CONTROL_DATA_H_
20
21 #include <JavaScriptCore/JavaScript.h>
22 #include <dpl/shared_ptr.h>
23 #include <CommonsJavaScript/PrivateObject.h>
24 #include <Commons/IEvent.h>
25 #include "ApplicationControlData.h"
26
27 namespace DeviceAPI {
28 namespace Application {
29
30 #define TIZEN_INTERFACE_APPLICATION_CONTROL_DATA "ApplicationControlData"
31
32 #define TIZEN_APPLICATION_CONTROL_DATA_KEY "key"
33 #define TIZEN_APPLICATION_CONTROL_DATA_VALUE "value"
34 #define TIZEN_APPLICATION_CONTROL_DATA_VALUE_INTERNAL "__tizen_value"
35
36 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<ApplicationControlDataPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSApplicationControlDataPriv;
37
38 class JSApplicationControlData {
39 public:
40     /*
41     * This initializes this JS class in the JS Engine.
42     */
43     static JSClassRef getClassRef();
44
45     static JSObjectRef createJSObject(JSContextRef context,
46             const ApplicationControlDataPtr &appdata,
47             JSValueRef jsValueValue);
48
49     static JSObjectRef constructor(JSContextRef ctx,
50             JSObjectRef constructor,
51             size_t argumentCount,
52             const JSValueRef arguments[],
53             JSValueRef* exception);
54
55     static bool isObjectOfClass(JSContextRef context, JSValueRef value);
56
57     static ApplicationControlDataPtr
58         getApplicationControlData(JSContextRef context, JSValueRef value);
59
60 private:
61    /**
62     * The callback invoked when an object is first created.
63     */
64     static void initialize(JSContextRef context, JSObjectRef object);
65
66    /**
67     * The callback invoked when an object is finalized.
68     */
69     static void finalize(JSObjectRef object);
70
71    /**
72     * This structure contains properties and callbacks that define a type of object.
73     */
74     static JSClassDefinition m_classInfo;
75
76    /**
77     * This structure describes a statically declared function property.
78     */
79     static JSStaticFunction m_functions[];
80
81     /**
82      * This member variable contains the initialization values
83      * for the static properties of this class.
84      * The values are given according to the data structure JSPropertySpec
85      */
86     static JSStaticValue m_property[];
87
88     static JSClassRef m_classRef;
89
90     static ApplicationControlDataPtr getPrivData(JSObjectRef object);
91
92     static JSValueRef getProperty(JSContextRef context,
93             JSObjectRef object,
94             JSStringRef propertyName,
95             JSValueRef* exception);
96
97     static bool setProperty(JSContextRef context,
98             JSObjectRef object,
99             JSStringRef propertyName,
100             JSValueRef value,
101             JSValueRef* exception);
102
103 };
104
105 }
106 }
107
108 #endif