wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / Application / ApplicationController.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 #ifndef _TIZEN_APPLICATION_APPLICATION_CONTROLLER_H_
19 #define _TIZEN_APPLICATION_APPLICATION_CONTROLLER_H_
20
21 #include <dpl/shared_ptr.h>
22 #include <Commons/EventReceiver.h>
23 #include <Commons/EventListener.h>
24 #include <CommonsJavaScript/PrivateObject.h>
25 #include <CommonsJavaScript/JSPendingOperationPrivateObject.h>
26 #include <CommonsJavaScript/JSPendingOperation.h>
27 #include "IApplicationManager.h"
28
29 namespace DeviceAPI {
30 namespace Application {
31
32 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<IApplicationManagerPtr,
33                                                            WrtDeviceApis::CommonsJavaScript::NoOwnership> ApplicationPrivObject;
34
35 typedef WrtDeviceApis::Commons::EventAnswerReceiver<EventApplicationLaunch>
36                 EventApplicationLaunchEventAnswerReceiver;
37 typedef WrtDeviceApis::Commons::EventAnswerReceiver<EventApplicationKill>
38                 EventApplicationKillEventAnswerReceiver;
39 typedef WrtDeviceApis::Commons::EventAnswerReceiver<EventApplicationLaunchAppControl>
40                 EventApplicationLaunchAppControlEventAnswerReceiver;
41 typedef WrtDeviceApis::Commons::EventAnswerReceiver<EventApplicationLaunchAppControlReply>
42                 EventApplicationLaunchAppControlReplyEventAnswerReceiver;
43 typedef WrtDeviceApis::Commons::EventAnswerReceiver<EventApplicationFindAppControl>
44                 EventApplicationFindAppControlEventAnswerReceiver;
45 typedef WrtDeviceApis::Commons::EventAnswerReceiver<EventApplicationGetAppsContext>
46                 EventApplicationGetAppsContextEventAnswerReceiver;
47 typedef WrtDeviceApis::Commons::EventAnswerReceiver<EventApplicationGetAppsInfo>
48                 EventApplicationGetAppsInfoEventAnswerReceiver;
49 typedef WrtDeviceApis::Commons::EventListener<EventApplicationAppInfoEventListener>
50                 EventApplicationAppInfoEventListenerListener;
51
52 class ApplicationController :
53         public EventApplicationLaunchEventAnswerReceiver,
54         public EventApplicationKillEventAnswerReceiver,
55         public EventApplicationLaunchAppControlEventAnswerReceiver,
56         public EventApplicationLaunchAppControlReplyEventAnswerReceiver,
57         public EventApplicationFindAppControlEventAnswerReceiver,
58         public EventApplicationGetAppsContextEventAnswerReceiver,
59         public EventApplicationGetAppsInfoEventAnswerReceiver,
60         public EventApplicationAppInfoEventListenerListener,
61         public ApplicationPrivObject
62 {
63 public:
64         ApplicationController(JSContextRef context,
65                         IApplicationManagerPtr application);
66         virtual ~ApplicationController();
67 protected:
68         void     OnAnswerReceived(const EventApplicationLaunchPtr &event);
69         void     OnAnswerReceived(const EventApplicationKillPtr &event);
70         void     OnAnswerReceived(const EventApplicationLaunchAppControlPtr &event);
71         void     OnAnswerReceived(const EventApplicationLaunchAppControlReplyPtr &event);
72         void     OnAnswerReceived(const EventApplicationFindAppControlPtr &event);
73         void     OnAnswerReceived(const EventApplicationGetAppsContextPtr &event);
74         void     OnAnswerReceived(const EventApplicationGetAppsInfoPtr &event);
75         void     onAnswerReceived(const EventApplicationAppInfoEventListenerPtr &event);
76 };
77
78 typedef DPL::SharedPtr<ApplicationController> ApplicationControllerPtr;
79
80 //common part
81 class ApplicationAsyncAnswerHandler
82 {
83 public:
84         static void launch(const EventApplicationLaunchPtr &event);
85         static void kill(const EventApplicationKillPtr &event);
86         static void launchAppControl(const EventApplicationLaunchAppControlPtr &event);
87         static void launchAppControlReply(const EventApplicationLaunchAppControlReplyPtr &event);
88         static void findAppControl(const EventApplicationFindAppControlPtr &event);
89         static void getAppsContext(const EventApplicationGetAppsContextPtr &event);
90         static void getAppsInfo(const EventApplicationGetAppsInfoPtr &event);
91         static void eventListener(const EventApplicationAppInfoEventListenerPtr &event);
92 };
93
94 } // Application
95 } // DeviceAPI
96
97 #endif // _TIZEN_APPLICATION_APPLICATION_CONTROLLER_H_