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 <Commons/IEvent.h>
25 #include "JSPendingOperation.h"
26 #include "JSPendingOperationPrivateObject.h"
28 namespace WrtDeviceApis {
29 namespace CommonsJavaScript {
31 const char* PLUGIN_NAME = "PendingOperation";
34 JSClassRef JSPendingOperation::m_classRef = NULL;
36 JSClassDefinition JSPendingOperation::m_classInfo = {
38 kJSClassAttributeNone,
48 NULL, //DeleteProperty,
49 NULL, //getPropertyNames,
53 NULL, //ConvertToType,
56 JSStaticFunction JSPendingOperation::m_functions[] = {
57 { "cancel", cancel, kJSPropertyAttributeNone },
61 JSClassRef JSPendingOperation::getClassRef()
64 m_classRef = JSClassCreate(&m_classInfo);
69 void JSPendingOperation::initialize(JSContextRef /*context*/,
72 Assert(NULL != JSObjectGetPrivate(object));
75 void JSPendingOperation::finalize(JSObjectRef object)
77 delete static_cast<IJSPendingOperationPrivateObject *>(
78 JSObjectGetPrivate(object));
81 JSValueRef JSPendingOperation::cancel(JSContextRef context,
83 JSObjectRef thisObject,
85 const JSValueRef arguments[],
86 JSValueRef* exception)
92 LogDebug(__FUNCTION__);
93 IJSPendingOperationPrivateObject *priv =
94 static_cast<IJSPendingOperationPrivateObject *>(
95 JSObjectGetPrivate(thisObject));
97 bool cancelResult = priv->cancel();
98 LogDebug("cancel result : " << cancelResult);
99 return JSValueMakeBoolean(context, cancelResult);
101 } // CommonsJavaScript