wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / MessagePort / LocalMessagePortController.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file        LocalMessagePortController.h
20  * @author      Kisub Song (kisubs.song@samsung.com)
21  * @version     0.1
22  * @brief
23  */
24
25 #ifndef _TIZEN_MESSAGE_PORT_LOCAL_MESSAGE_PORT_CONTROLLER_H_
26 #define _TIZEN_MESSAGE_PORT_LOCAL_MESSAGE_PORT_CONTROLLER_H_
27
28 #include <dpl/shared_ptr.h>
29 #include <Commons/EventReceiver.h>
30 #include <Commons/EventListener.h>
31 #include <CommonsJavaScript/PrivateObject.h>
32 #include <CommonsJavaScript/JSPendingOperationPrivateObject.h>
33 #include <CommonsJavaScript/JSPendingOperation.h>
34 #include "ILocalMessagePort.h"
35
36 namespace DeviceAPI {
37 namespace MessagePort {
38
39 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<LocalMessagePortPtr,
40                                                            WrtDeviceApis::CommonsJavaScript::NoOwnership> LocalMessagePortPrivObject;
41
42 typedef WrtDeviceApis::Commons::EventListener<EventLocalMessagePortListener> EventLocalMessagePortListenerListener;
43
44 class LocalMessagePortController :
45         public EventLocalMessagePortListenerListener,
46         public LocalMessagePortPrivObject
47 {
48 public:
49         LocalMessagePortController(JSContextRef context,
50                         LocalMessagePortPtr localMessagePort);
51         virtual ~LocalMessagePortController();
52 protected:
53         void     onAnswerReceived(const EventLocalMessagePortListenerPtr &event);
54 };
55
56 typedef DPL::SharedPtr<LocalMessagePortController> LocalMessagePortControllerPtr;
57
58 //common part
59 class LocalMessagePortAsyncAnswerHandler
60 {
61 public:
62         static void localMessagePortListener(const EventLocalMessagePortListenerPtr &event);
63 };
64
65 } // MessagePort
66 } // DeviceAPI
67
68 #endif // _TIZEN_MESSAGE_PORT_LOCAL_MESSAGE_PORT_CONTROLLER_H_