Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Application / JSApplicationInformation.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_INFORMATION_H_
18 #define TIZENAPIS_TIZEN_JS_APPLICATION_INFORMATION_H_
19
20 #include <JavaScriptCore/JavaScript.h>
21 #include <CommonsJavaScript/PrivateObject.h>
22 #include <dpl/shared_ptr.h>
23 #include <API/Application/ApplicationInformation.h>
24
25 namespace TizenApis {
26 namespace Tizen1_0 {
27 namespace Application {
28
29 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<Api::Application::ApplicationInformationPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSApplicationInformationPriv;
30
31 class JSApplicationInformation {
32 public:
33         /*
34         * This initializes this JS class in the JS Engine.
35         */
36         static JSClassRef getClassRef();
37
38         static JSValueRef createJSObject(JSContextRef context,
39                         const std::string &name,
40                         const std::string &package,
41                         const std::string &iconPath,
42                         const std::string &version);
43
44         static bool isObjectOfClass(JSContextRef context, JSValueRef value);
45
46         static Api::Application::ApplicationInformationPtr 
47                 getApplicationInformation(JSContextRef context, JSValueRef value);
48
49 private:
50    /**
51         * The callback invoked when an object is first created.
52         */
53         static void initialize(JSContextRef context, JSObjectRef object);
54
55    /**
56         * The callback invoked when an object is finalized.
57         */
58         static void finalize(JSObjectRef object);
59
60    /**
61         * This structure contains properties and callbacks that define a type of object.
62         */
63         static JSClassDefinition m_classInfo;
64
65    /**
66         * This structure describes a statically declared function property.
67         */
68         static JSStaticFunction m_functions[];
69
70         /**
71          * This member variable contains the initialization values for the static properties of this class.
72          * The values are given according to the data structure JSPropertySpec
73          */
74         static JSStaticValue m_property[];
75
76         static JSClassRef m_classRef;
77
78         static Api::Application::ApplicationInformationPtr getPrivData(JSObjectRef object);
79
80         static JSValueRef getName(JSContextRef context,
81                         JSObjectRef object,
82                         JSStringRef propertyName,
83                         JSValueRef* exception);
84
85         static bool setName(JSContextRef context,
86                         JSObjectRef object,
87                         JSStringRef propertyName,
88                         JSValueRef name,
89                         JSValueRef* exception);
90
91         static JSValueRef getAppId(JSContextRef context,
92                         JSObjectRef object,
93                         JSStringRef propertyName,
94                         JSValueRef* exception);
95
96         static bool setAppId(JSContextRef context,
97                         JSObjectRef object,
98                         JSStringRef propertyName,
99                         JSValueRef appId,
100                         JSValueRef* exception);
101
102 static JSValueRef getIconPath(JSContextRef context,
103                 JSObjectRef object,
104                 JSStringRef propertyName,
105                 JSValueRef* exception);
106
107 static bool setIconPath(JSContextRef context,
108                 JSObjectRef object,
109                 JSStringRef propertyName,
110                 JSValueRef iconPath,
111                 JSValueRef* exception);
112
113 static JSValueRef getVersion(JSContextRef context,
114                 JSObjectRef object,
115                 JSStringRef propertyName,
116                 JSValueRef* exception);
117
118 static bool setVersion(JSContextRef context,
119                 JSObjectRef object,
120                 JSStringRef propertyName,
121                 JSValueRef version,
122                 JSValueRef* exception);
123
124 };
125
126 }
127 }
128 }
129 #endif