Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Application / JSApplicationService.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_H_
18 #define TIZENAPIS_TIZEN_JS_APPLICATION_SERVICE_H_
19
20 #include <JavaScriptCore/JavaScript.h>
21 #include <CommonsJavaScript/PrivateObject.h>
22 #include <API/Application/ApplicationService.h>
23 #include "JSApplicationServiceData.h"
24
25 namespace TizenApis {
26 namespace Tizen1_0 {
27 namespace Application {
28
29 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Application::ApplicationServicePtr>::Type JSApplicationServicePriv;
30
31 class JSApplicationService {
32 public:
33         static const JSClassDefinition* getClassInfo();
34
35         static const JSClassRef getClassRef();
36
37         /**
38           * create an JSObject for callback function(onAnswerReceived).
39           */
40         static JSObjectRef createJSObject(JSContextRef context,
41                            const Api::Application::ApplicationServicePtr &appsvc);
42
43         /**
44          * The Constructor of ApplicationService
45          */
46         static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
47
48
49         static bool isObjectOfClass(JSContextRef context, JSValueRef value);
50
51         static Api::Application::ApplicationServicePtr getApplicationService(JSContextRef context, JSValueRef value);
52         /**
53           * return private data
54           */
55         static Api::Application::ApplicationServicePtr getPrivateData(JSObjectRef object);
56
57         /**
58          * Send Success Result
59          */
60         static JSValueRef replyResult(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
61                         const JSValueRef arguments[], JSValueRef* exception);
62
63         /**
64          * Send Failure Result
65          */
66         static JSValueRef replyFailure(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
67                         const JSValueRef arguments[], JSValueRef* exception);
68
69 private:
70         /**
71          * The callback invoked when an object is first created.
72          */
73         static void initialize(JSContextRef context, JSObjectRef object);
74
75    /**
76          * The callback invoked when an object is finalized.
77          */
78         static void finalize(JSObjectRef object);
79
80   /**
81      * The callback invoked when getting a property's value.
82      */
83     static JSValueRef getProperty(JSContextRef context,
84             JSObjectRef object,
85             JSStringRef propertyName,
86             JSValueRef* exception);
87
88   /**
89      * The callback invoked when an object is used as the target of an 'instanceof' expression.
90      */
91     static bool hasInstance(JSContextRef context,
92             JSObjectRef constructor,
93             JSValueRef possibleInstance,
94             JSValueRef* exception);
95
96   /**
97      * This structure contains properties and callbacks that define a type of object.
98      */
99     static JSClassDefinition m_classInfo;
100
101   /**
102      * This structure describes a statically declared value property.
103      */
104     static JSStaticValue m_property[];
105
106     static JSClassRef m_jsClassRef;
107
108 };
109
110 } //
111 } //TizenApis
112 }
113 #endif