2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef WRT_PLUGINS_TIZEN_JS_MESSAGING_SERVICE_H_
19 #define WRT_PLUGINS_TIZEN_JS_MESSAGING_SERVICE_H_
21 #include <JavaScriptCore/JavaScript.h>
22 #include <CommonsJavaScript/PrivateObject.h>
24 #include "IMessagingService.h"
29 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<DeviceAPI::Messaging::IMessagingServicePtr>::Type JSMessagingServicePrivObject;
31 class JSMessagingServicePriv :
32 public JSMessagingServicePrivObject,
33 public DeviceAPI::Common::SecurityAccessor
36 JSMessagingServicePriv(JSContextRef context, IMessagingServicePtr messagingService) :
37 JSMessagingServicePrivObject(context, messagingService),
38 DeviceAPI::Common::SecurityAccessor()
42 virtual ~JSMessagingServicePriv()
47 class JSMessagingService {
50 static const JSClassDefinition* getClassInfo();
51 static const JSClassRef getClassRef();
53 static JSObjectRef createJSObject(JSContextRef context, const IMessagingServicePtr &messagingService, const DeviceAPI::Common::SecurityAccessor *securityAccessor);
58 * The callback invoked when an object is first created.
60 static void initialize(JSContextRef context, JSObjectRef object);
63 * The callback invoked when an object is finalized.
65 static void finalize(JSObjectRef object);
68 * The callback invoked when an object is used as the target of an 'instanceof' expression.
70 static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
73 * The callback invoked when determining whether an object has a property.
75 static bool hasProperty(JSContextRef context,
77 JSStringRef propertyName);
80 * The callback invoked when getting a property's value.
82 static JSValueRef getProperty(JSContextRef context,
84 JSStringRef propertyName,
85 JSValueRef* exception);
88 * The callback invoked when setting a property's value.
90 static bool setProperty(JSContextRef context,
92 JSStringRef propertyName,
94 JSValueRef* exception);
97 * The callback invoked when collecting the names of an object's properties.
99 static void getPropertyNames(JSContextRef context,
101 JSPropertyNameAccumulatorRef propertyNames);
105 * The callback invoked when create message
107 static JSValueRef createMessage(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
108 size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
111 static JSValueRef sendMessage(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
112 size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
114 static JSValueRef loadMessageBody(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
115 size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
117 static JSValueRef loadMessageAttachment(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
118 size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
120 static JSValueRef sync(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
121 size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
123 static JSValueRef syncFolder(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
124 size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
127 static JSValueRef cancelOperation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
128 size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
131 static JSValueRef stopSync(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
132 size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
135 * This structure contains properties and callbacks that define a type of object.
137 static JSClassDefinition m_classInfo;
139 static JSStaticFunction m_function[];
140 static JSStaticValue m_property[];
141 static JSClassRef m_jsClassRef;
143 }; //JSMessagingService
149 #endif //WRT_PLUGINS_TIZEN_JS_MESSAGING_SERVICE_H_