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 {
33 const char* PLUGIN_NAME = "PendingOperation";
36 JSClassRef JSPendingOperation::m_classRef = NULL;
38 JSClassDefinition JSPendingOperation::m_classInfo = {
40 kJSClassAttributeNone,
50 NULL, //DeleteProperty,
51 NULL, //getPropertyNames,
55 NULL, //ConvertToType,
58 JSStaticFunction JSPendingOperation::m_functions[] = {
59 { "cancel", cancel, kJSPropertyAttributeNone },
63 JSClassRef JSPendingOperation::getClassRef()
66 m_classRef = JSClassCreate(&m_classInfo);
71 void JSPendingOperation::initialize(JSContextRef /*context*/,
74 assert(NULL != JSObjectGetPrivate(object));
77 void JSPendingOperation::finalize(JSObjectRef object)
79 delete static_cast<IJSPendingOperationPrivateObject *>(
80 JSObjectGetPrivate(object));
83 JSValueRef JSPendingOperation::cancel(JSContextRef context,
85 JSObjectRef thisObject,
87 const JSValueRef arguments[],
88 JSValueRef* exception)
94 LogDebug(__FUNCTION__);
95 IJSPendingOperationPrivateObject *priv =
96 static_cast<IJSPendingOperationPrivateObject *>(
97 JSObjectGetPrivate(thisObject));
99 bool cancelResult = priv->cancel();
100 LogDebug("cancel result : " << cancelResult);
101 return JSValueMakeBoolean(context, cancelResult);
103 } // CommonsJavaScript