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_APPLICATION_CONTROLLER_H_
19 #define _TIZEN_APPLICATION_APPLICATION_CONTROLLER_H_
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"
30 namespace Application {
32 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<IApplicationManagerPtr,
33 WrtDeviceApis::CommonsJavaScript::NoOwnership> ApplicationPrivObject;
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;
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
64 ApplicationController(JSContextRef context,
65 IApplicationManagerPtr application);
66 virtual ~ApplicationController();
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);
78 typedef DPL::SharedPtr<ApplicationController> ApplicationControllerPtr;
81 class ApplicationAsyncAnswerHandler
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);
97 #endif // _TIZEN_APPLICATION_APPLICATION_CONTROLLER_H_