Update change log and spec for wrt-plugins-tizen_0.4.9
[platform/framework/web/wrt-plugins-tizen.git] / src / Application / JSApplication.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_H_
20 #define TIZENAPIS_TIZEN_JS_APPLICATION_H_
21
22 #include <JavaScriptCore/JavaScript.h>
23 #include <CommonsJavaScript/PrivateObject.h>
24 #include <dpl/shared_ptr.h>
25 #include "Application.h"
26
27 namespace DeviceAPI {
28 namespace Application {
29
30 #define TIZEN_INTERFACE_APPLICATION "Application"
31
32 #define TIZEN_APPLICATION_APP_INFO "appInfo"
33 #define TIZEN_APPLICATION_APP_CONTEXT_ID "contextId"
34
35 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<ApplicationPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSApplicationPriv;
36
37 class JSApplication {
38 public:
39         /*
40         * This initializes this JS class in the JS Engine.
41         */
42         static JSClassRef getClassRef();
43
44 /*
45         static JSValueRef createJSObject(JSContextRef context,
46                         const std::string &name,
47                         const std::string &package,
48                         const std::string &iconPath,
49                         const std::string &version,
50                         const bool &show,
51                         const std::vector<std::string> &categories,
52                         const time_t &installDate,
53                         const long &installSize);
54 */
55         static bool isObjectOfClass(JSContextRef context, JSValueRef value);
56
57 /*
58         static ApplicationInformationPtr 
59                 getApplicationInformation(JSContextRef context, JSValueRef value);
60 */
61         /**
62          * hide the application based on application context.
63          */
64         static JSValueRef hide(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
65                         const JSValueRef arguments[], JSValueRef* exception);
66
67         /**
68          * exit current application
69          */
70         static JSValueRef exit(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
71                         const JSValueRef arguments[], JSValueRef* exception);
72
73         /**
74          * get request application control
75          */
76         static JSValueRef getRequestedAppControl(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
77                         const JSValueRef arguments[], JSValueRef* exception);
78
79 private:
80    /**
81         * The callback invoked when an object is first created.
82         */
83         static void initialize(JSContextRef context, JSObjectRef object);
84
85    /**
86         * The callback invoked when an object is finalized.
87         */
88         static void finalize(JSObjectRef object);
89
90    /**
91         * This structure contains properties and callbacks that define a type of object.
92         */
93         static JSClassDefinition m_classInfo;
94
95    /**
96         * This structure describes a statically declared function property.
97         */
98         static JSStaticFunction m_functions[];
99
100         /**
101          * This member variable contains the initialization values for the static properties of this class.
102          * The values are given according to the data structure JSPropertySpec
103          */
104         static JSStaticValue m_property[];
105
106         /**
107          * This structure describes a statically declared function property.
108          */
109         static JSStaticFunction m_function[];   
110
111         static JSClassRef m_classRef;
112
113         static ApplicationPtr getPrivData(JSObjectRef object);
114
115         static JSValueRef getProperty(JSContextRef context,
116                 JSObjectRef object,
117                 JSStringRef propertyName,
118                 JSValueRef* exception);
119
120 };
121
122 }
123 }
124 #endif  //TIZENAPIS_TIZEN_JS_APPLICATION_H_