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 _TIZEN_APPLICATION_JS_APPLICATION_EVENT_CALLBACK_MANAGER_H_
19 #define _TIZEN_APPLICATION_JS_APPLICATION_EVENT_CALLBACK_MANAGER_H_
21 #include <dpl/shared_ptr.h>
22 #include <Commons/IEvent.h>
23 #include <JavaScriptCore/JavaScript.h>
27 namespace Application {
29 class JSApplicationEventCallbackManager;
30 typedef DPL::SharedPtr<JSApplicationEventCallbackManager> JSApplicationEventCallbackManagerPtr;
32 class JSApplicationEventCallbackManager :
33 public WrtDeviceApis::Commons::IEventPrivateData,
34 public DeviceAPI::Common::SecurityAccessor
37 JSApplicationEventCallbackManager() {}
38 JSApplicationEventCallbackManager( JSContextRef context,
39 JSObjectRef onInstalled = NULL,
40 JSObjectRef onUpdated = NULL,
41 JSObjectRef onUninstalled = NULL,
42 JSObjectRef onError = NULL );
45 static JSApplicationEventCallbackManagerPtr createObject(JSContextRef context);
47 virtual ~JSApplicationEventCallbackManager();
49 void setContext( JSContextRef context );
50 JSContextRef getContext() const { return m_context; }
52 void setOnInstalled( JSValueRef onInstalled );
53 JSValueRef getOnInstalled() const;
54 void setOnUpdated( JSValueRef onUpdated );
55 JSValueRef getOnUpdated() const;
56 void setOnUninstalled( JSValueRef onUninstalled );
57 JSValueRef getOnUninstalled() const;
58 void setOnError( JSValueRef onError );
59 JSValueRef getOnError() const;
60 void setObject( JSObjectRef object );
61 JSObjectRef getObject() const;
63 void callOnInstalled( JSValueRef contacts );
64 void callOnUpdated( JSValueRef contacts );
65 void callOnUninstalled( JSValueRef contactIds );
66 void callOnError( JSValueRef error );
69 void makeCallback(JSContextRef context,
76 JSObjectRef m_onInstalled;
77 JSObjectRef m_onUpdated;
78 JSObjectRef m_onUninstalled;
79 JSObjectRef m_onError;
80 JSContextRef m_context;
87 #endif // _TIZEN_APPLICATION_JS_APPLICATION_EVENT_CALLBACK_MANAGER_H_