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