merge with master
[platform/framework/web/wrt-plugins-tizen.git] / src / Application / JSApplicationManager.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_MANAGER_H_
19 #define TIZENAPIS_TIZEN_JS_APPLICATION_MANAGER_H_
20
21 #include <JavaScriptCore/JavaScript.h>
22 #include <CommonsJavaScript/PrivateObject.h>
23 #include "IApplicationManager.h"
24
25 namespace DeviceAPI {
26 namespace Application {
27
28 #define TIZEN_INTERFACE_APPLICATION_MANAGER "ApplicationManager"
29
30 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject
31                 <IApplicationManagerPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSApplicationManagerPriv;
32
33 class JSApplicationManager {
34 public:
35         static const JSClassDefinition* getClassInfo();
36
37         static const JSClassRef getClassRef();
38
39         static void setTitleProperty(JSContextRef context, std::string propertyValue);
40
41 private:
42         /**
43          * The callback invoked when an object is first created.
44          */
45         static void initialize(JSContextRef context, JSObjectRef object);
46
47         /**
48          * The callback invoked when an object is finalized.
49          */
50         static void finalize(JSObjectRef object);
51
52         /**
53          * The callback invoked when an object is used as the target of an 'instanceof' expression.
54          */
55         static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
56
57         /**
58          * Gets a current application
59          */
60         static JSValueRef getCurrentApplication(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
61                         const JSValueRef arguments[], JSValueRef* exception);
62
63         /**
64          * Launches a application with given application id
65          */
66         static JSValueRef launch(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
67                         const JSValueRef arguments[], JSValueRef* exception);
68
69         /**
70          * Kills the application based on application context.
71          */
72         static JSValueRef kill(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
73                         const JSValueRef arguments[], JSValueRef* exception);
74
75
76         /**
77          * exit current application
78          */
79         static JSValueRef setUserAgent(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
80                         const JSValueRef arguments[], JSValueRef* exception);
81
82         /**
83          * Gets the list of installed packages.
84          */
85         static JSValueRef getAppsInfo(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
86                         const JSValueRef arguments[], JSValueRef* exception);
87
88         /**
89          * Gets the list of running packages.
90          */
91         static JSValueRef getAppsContext(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
92                         const JSValueRef arguments[], JSValueRef* exception);   
93
94         /**
95          * Gets the application information of based on the package name.
96          */
97         static JSValueRef getAppInfo(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
98                         const JSValueRef arguments[], JSValueRef* exception);
99
100         /**
101          * Gets the current application Context
102          */
103         static JSValueRef getAppContext(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
104                         const JSValueRef arguments[], JSValueRef* exception);
105
106         /**
107          * Watch for changes on installed applicaiton.
108          */
109         static JSValueRef addAppInfoEventListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
110                         const JSValueRef arguments[], JSValueRef* exception);
111
112         /**
113          * Unset installed Applications listener
114          */
115         static JSValueRef removeAppInfoEventListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
116                         const JSValueRef arguments[], JSValueRef* exception);
117
118         /**
119          * Launch a application control
120          */
121         static JSValueRef launchAppControl(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
122                         const JSValueRef arguments[], JSValueRef* exception);
123
124         /**
125          * Find application info list with application control
126          */
127         static JSValueRef findAppControl(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
128                         const JSValueRef arguments[], JSValueRef* exception);
129
130         /**
131          * Get certificate information of given application
132          */
133         static JSValueRef getAppCerts(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
134                         const JSValueRef arguments[], JSValueRef* exception);
135
136
137         /**
138          * This structure contains properties and callbacks that define a type of object.
139          */
140         static JSClassDefinition m_classInfo;
141
142         /**
143          * This structure describes a statically declared function property.
144          */
145         static JSStaticFunction m_function[];
146
147         static JSClassRef m_jsClassRef;
148 };
149
150 }
151 }
152 #endif