Update change log and spec for wrt-plugins-tizen_0.4.9
[platform/framework/web/wrt-plugins-tizen.git] / src / Application / JSApplicationContext.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_CONTEXT_H_
19 #define TIZENAPIS_TIZEN_JS_APPLICATION_CONTEXT_H_
20
21 #include <JavaScriptCore/JavaScript.h>
22 #include <CommonsJavaScript/PrivateObject.h>
23 #include <dpl/shared_ptr.h>
24 #include "ApplicationContext.h"
25
26 namespace DeviceAPI {
27 namespace Application {
28
29 #define TIZEN_INTERFACE_APPLICATION_CONTEXT "ApplicationContext"
30
31 #define TIZEN_APPLICATION_CONTEXT_ID "id"
32 #define TIZEN_APPLICATION_CONTEXT_APP_ID "appId"
33
34 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<ApplicationContextPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSApplicationContextPriv;
35
36 class JSApplicationContext {
37 public:
38         /*
39         * This initializes this JS class in the JS Engine.
40         */
41         static JSClassRef getClassRef();
42
43         static JSValueRef createJSObject(JSContextRef context,
44                         const std::string &appId,
45                         const std::string &contextId);
46
47         static bool isObjectOfClass(JSContextRef context, JSValueRef value);
48
49         static ApplicationContextPtr getApplicationContext(JSContextRef context, JSValueRef value);
50
51 private:
52    /**
53         * The callback invoked when an object is first created.
54         */
55         static void initialize(JSContextRef context, JSObjectRef object);
56
57    /**
58         * The callback invoked when an object is finalized.
59         */
60         static void finalize(JSObjectRef object);
61
62    /**
63         * This structure contains properties and callbacks that define a type of object.
64         */
65         static JSClassDefinition m_classInfo;
66
67    /**
68         * This structure describes a statically declared function property.
69         */
70         static JSStaticFunction m_functions[];
71
72         /**
73          * This member variable contains the initialization values for the static properties of this class.
74          * The values are given according to the data structure JSPropertySpec
75          */
76         static JSStaticValue m_property[];
77
78         static JSClassRef m_classRef;
79
80         static ApplicationContextPtr getPrivData(JSObjectRef object);
81
82         static JSValueRef getProperty(JSContextRef context,
83                 JSObjectRef object,
84                 JSStringRef propertyName,
85                 JSValueRef* exception);
86
87 };
88
89 }
90 }
91 #endif