tizen 2.3 release
[framework/web/wearable/wrt-plugins-tizen.git] / src / Application / JSApplicationControl.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 #ifndef TIZENAPIS_TIZEN_JS_APPLICATION_CONTROL_H_
20 #define TIZENAPIS_TIZEN_JS_APPLICATION_CONTROL_H_
21
22 #include <JavaScriptCore/JavaScript.h>
23 #include <CommonsJavaScript/PrivateObject.h>
24 #include "ApplicationControl.h"
25 #include "JSApplicationControlData.h"
26
27 namespace DeviceAPI {
28 namespace Application {
29
30 #define TIZEN_INTERFACE_APPLICATION_CONTROL "ApplicationControl"
31
32 #define TIZEN_APPLICATION_CONTROL_OPERATION "operation"
33 #define TIZEN_APPLICATION_CONTROL_URI "uri"
34 #define TIZEN_APPLICATION_CONTROL_MIME "mime"
35 #define TIZEN_APPLICATION_CONTROL_CATEGORY "category"
36 #define TIZEN_APPLICATION_CONTROL_DATA "data"
37 #define TIZEN_APPLICATION_CONTROL_DATA_INTERNAL "__tizen_data"
38
39 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<ApplicationControlPtr>::Type JSApplicationControlPriv;
40
41 class JSApplicationControl {
42 public:
43     static const JSClassDefinition* getClassInfo();
44
45     static const JSClassRef getClassRef();
46
47     /**
48       * create an JSObject for callback function(onAnswerReceived).
49       */
50     static JSObjectRef createJSObject(JSContextRef context,
51                const ApplicationControlPtr &appsvc,
52                JSValueRef jsValueData);
53
54     /**
55      * The Constructor of ApplicationControl
56      */
57     static JSObjectRef constructor(JSContextRef ctx,
58             JSObjectRef constructor,
59             size_t argumentCount,
60             const JSValueRef arguments[],
61             JSValueRef* exception);
62
63
64     static bool isObjectOfClass(JSContextRef context, JSValueRef value);
65
66     static ApplicationControlPtr getApplicationControl(JSContextRef context,
67             JSValueRef value);
68     /**
69       * return private data
70       */
71     //static ApplicationControlPtr getPrivateData(JSObjectRef object);
72
73
74 private:
75     /**
76      * The callback invoked when an object is first created.
77      */
78     static void initialize(JSContextRef context, JSObjectRef object);
79
80    /**
81      * The callback invoked when an object is finalized.
82      */
83     static void finalize(JSObjectRef object);
84
85     static ApplicationControlPtr getPrivData(JSContextRef context, JSObjectRef object);
86
87   /**
88      * The callback invoked when getting a property's value.
89      */
90     static JSValueRef getProperty(JSContextRef context,
91             JSObjectRef object,
92             JSStringRef propertyName,
93             JSValueRef* exception);
94
95   /**
96      * The callback invoked when setting a property's value.
97      */
98
99     static bool setProperty(JSContextRef context,
100           JSObjectRef object,
101           JSStringRef propertyName,
102           JSValueRef value,
103           JSValueRef* exception);
104
105   /**
106      * This structure contains properties and callbacks that define a type of object.
107      */
108     static JSClassDefinition m_classInfo;
109
110   /**
111      * This structure describes a statically declared value property.
112      */
113     static JSStaticValue m_property[];
114
115     /**
116      * This structure describes a statically declared function property.
117      */
118     static JSStaticFunction m_function[];
119
120
121     static JSClassRef m_jsClassRef;
122
123 };
124
125 } //
126 } //TizenApis
127
128 #endif