Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Application / JSApplicationServiceData.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef TIZENAPIS_TIZEN_JS_APPLICATION_SERVICE_DATA_H_
18 #define TIZENAPIS_TIZEN_JS_APPLICATION_SERVICE_DATA_H_
19
20 #include <JavaScriptCore/JavaScript.h>
21 #include <dpl/shared_ptr.h>
22 #include <CommonsJavaScript/PrivateObject.h>
23 #include <Commons/IEvent.h>
24 #include <API/Application/ApplicationServiceData.h>
25
26 namespace TizenApis {
27 namespace Tizen1_0 {
28 namespace Application {
29
30 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<Api::Application::ApplicationServiceDataPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSApplicationServiceDataPriv;
31
32 class JSApplicationServiceData {
33 public:
34         /*
35         * This initializes this JS class in the JS Engine.
36         */
37         static JSClassRef getClassRef();
38
39         static JSValueRef createJSObject(JSContextRef context,
40                         const std::string &key,
41                         const std::vector<std::string> &value);
42
43         static JSObjectRef constructor(JSContextRef ctx, 
44                         JSObjectRef constructor, 
45                         size_t argumentCount, 
46                         const JSValueRef arguments[], 
47                         JSValueRef* exception);
48
49         static bool isObjectOfClass(JSContextRef context, JSValueRef value);
50
51         static Api::Application::ApplicationServiceDataPtr 
52                 getApplicationServiceData(JSContextRef context, JSValueRef value);
53
54 private:
55    /**
56         * The callback invoked when an object is first created.
57         */
58         static void initialize(JSContextRef context, JSObjectRef object);
59
60    /**
61         * The callback invoked when an object is finalized.
62         */
63         static void finalize(JSObjectRef object);
64
65    /**
66         * This structure contains properties and callbacks that define a type of object.
67         */
68         static JSClassDefinition m_classInfo;
69
70    /**
71         * This structure describes a statically declared function property.
72         */
73         static JSStaticFunction m_functions[];
74
75         /**
76          * This member variable contains the initialization values for the static properties of this class.
77          * The values are given according to the data structure JSPropertySpec
78          */
79         static JSStaticValue m_property[];
80
81         static JSClassRef m_classRef;
82
83         static Api::Application::ApplicationServiceDataPtr getPrivData(JSObjectRef object);
84
85         static JSValueRef getDataKey(JSContextRef context,
86                         JSObjectRef object,
87                         JSStringRef propertyName,
88                         JSValueRef* exception);
89
90         static bool setDataKey(JSContextRef context,
91                         JSObjectRef object,
92                         JSStringRef propertyName,
93                         JSValueRef key,
94                         JSValueRef* exception);
95
96         static JSValueRef getDataValue(JSContextRef context,
97                         JSObjectRef object,
98                         JSStringRef propertyName,
99                         JSValueRef* exception);
100
101         static bool setDataValue(JSContextRef context,
102                         JSObjectRef object,
103                         JSStringRef propertyName,
104                         JSValueRef value,
105                         JSValueRef* exception);
106
107 };
108
109 }
110
111 }
112 #endif
113