2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file JSPendingOperation.cpp
18 * @author Pete Cole (peter.cole@partner.samsung.com)
20 * 0.2 k.majewski@samsung.com
21 * @brief Implementation of the JSPendingOperation class
24 #include <dpl/shared_ptr.h>
25 #include <Commons/IEvent.h>
26 #include "JSPendingOperation.h"
27 #include "JSPendingOperationPrivateObject.h"
29 namespace WrtDeviceApis {
30 namespace CommonsJavaScript {
32 const char* PLUGIN_NAME = "PendingOperation";
35 JSClassRef JSPendingOperation::m_classRef = NULL;
37 JSClassDefinition JSPendingOperation::m_classInfo = {
39 kJSClassAttributeNone,
49 NULL, //DeleteProperty,
50 NULL, //getPropertyNames,
54 NULL, //ConvertToType,
57 JSStaticFunction JSPendingOperation::m_functions[] = {
58 { "cancel", cancel, kJSPropertyAttributeNone },
62 JSClassRef JSPendingOperation::getClassRef()
65 m_classRef = JSClassCreate(&m_classInfo);
70 void JSPendingOperation::initialize(JSContextRef /*context*/,
73 assert(NULL != JSObjectGetPrivate(object));
76 void JSPendingOperation::finalize(JSObjectRef object)
78 delete static_cast<IJSPendingOperationPrivateObject *>(
79 JSObjectGetPrivate(object));
82 JSValueRef JSPendingOperation::cancel(JSContextRef context,
84 JSObjectRef thisObject,
86 const JSValueRef arguments[],
87 JSValueRef* exception)
93 LogDebug(__FUNCTION__);
94 IJSPendingOperationPrivateObject *priv =
95 static_cast<IJSPendingOperationPrivateObject *>(
96 JSObjectGetPrivate(thisObject));
98 bool cancelResult = priv->cancel();
99 LogDebug("cancel result : " << cancelResult);
100 return JSValueMakeBoolean(context, cancelResult);
102 } // CommonsJavaScript