2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #ifndef WRT_SRC_INSTALLER_CORE_INSTALLER_CONTROLLER_H_
17 #define WRT_SRC_INSTALLER_CORE_INSTALLER_CONTROLLER_H_
19 #include <dpl/singleton.h>
20 #include <dpl/event/controller.h>
21 #include <dpl/generic_event.h>
24 #include <dpl/task_list.h>
26 #include <dpl/type_list.h>
27 #include <widget_install/widget_installer_struct.h>
28 #include <installer_logic.h>
32 * @brief holds events send to InstallControler
34 namespace InstallerControllerEvents {
36 * @brief Event for inicieting instalation process.
38 * This event holds std::string witch should be path to widget package
40 DECLARE_GENERIC_EVENT_2(InstallWidgetEvent,
42 WidgetInstallationStruct) // (zipFileName, installerStruct)
45 * @brief Event for iniciating plugin instalation process.
46 * This event holds std::string witch should be path to plugin directory
47 * and PluginInstallerStruct which contain
48 * StatusCallack, progressCallback and private data for callbacks
50 DECLARE_GENERIC_EVENT_2(InstallPluginEvent, std::string, PluginInstallerStruct)
53 * @brief Event for indiciating W3C Geolocation plugin instalation process.
55 DECLARE_GENERIC_EVENT_1(InstallPluginGeolocationEvent, PluginInstallerStruct) //
58 * @brief Event for inicietig widget uninstallation.
60 * WidgetHandler is used to point witch widget shuld be uninstalled
62 DECLARE_GENERIC_EVENT_2(UninstallWidgetEvent,
64 WidgetUninstallationStruct)
67 * @brief Event for pushing installation process forward.
69 DECLARE_GENERIC_EVENT_1(NextStepEvent, Jobs::Job *)
71 DECLARE_GENERIC_EVENT_0(InstallDeferredWidgetPackagesEvent)
73 DECLARE_GENERIC_EVENT_0(InitializeEvent)
74 DECLARE_GENERIC_EVENT_0(TerminateEvent)
77 * @brief Event for initiating from web widget installation. This event
78 * contains widget url and optionally widget icon url.
80 DECLARE_GENERIC_EVENT_3(InstallWidgetFromBrowserEvent,
83 WidgetInstallationStruct)
85 } // namespace InstallerEvents
88 * @brief Controls Widget installation
90 * Main Controler of wiget installation/uninstallation, this is also used
91 * for pushing forward each of processes.
92 * It waits for three events:
94 * <li>InstallWidgetEvent</li>
95 * <li>UninstallWidgetEvent</li>
96 * <li>NextStepEvent</li>
100 typedef DPL::TypeListDecl<
101 InstallerControllerEvents::InstallWidgetEvent,
102 InstallerControllerEvents::InstallPluginEvent,
103 InstallerControllerEvents::InstallPluginGeolocationEvent,
104 InstallerControllerEvents::UninstallWidgetEvent,
105 InstallerControllerEvents::NextStepEvent,
106 InstallerControllerEvents::InstallDeferredWidgetPackagesEvent,
107 InstallerControllerEvents::InitializeEvent,
108 InstallerControllerEvents::TerminateEvent,
109 InstallerControllerEvents::InstallWidgetFromBrowserEvent>::Type
110 InstallerControllerEventsSet;
112 class InstallerController : public DPL::Event::Controller<InstallerControllerEventsSet>
116 * @brief Executed on InstallWidgetEvent received.
118 virtual void OnEventReceived(
119 const InstallerControllerEvents::InstallWidgetEvent &event);
122 * @brief Executed on InstallPluginEvent received.
124 virtual void OnEventReceived(
125 const InstallerControllerEvents::InstallPluginEvent &event);
128 * @brief Executed on InstallPluginEvent received.
130 virtual void OnEventReceived(
131 const InstallerControllerEvents::InstallPluginGeolocationEvent
135 * @brief Executed on UninstallWidgetEvent received.
137 virtual void OnEventReceived(
138 const InstallerControllerEvents::UninstallWidgetEvent &event);
140 * @brief Executed on NextStepEvent received.
142 virtual void OnEventReceived(
143 const InstallerControllerEvents::NextStepEvent &event);
145 virtual void OnEventReceived(
146 const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent
149 virtual void OnEventReceived(
150 const InstallerControllerEvents::InitializeEvent &event);
151 virtual void OnEventReceived(
152 const InstallerControllerEvents::TerminateEvent &event);
154 virtual void OnEventReceived(
155 const InstallerControllerEvents::InstallWidgetFromBrowserEvent &event);
159 InstallerLogic m_installerLogic;
161 InstallerController();
163 static Eina_Bool AddNextStep(void *data);
165 friend class DPL::Singleton<InstallerController>;
168 typedef DPL::Singleton<InstallerController> InstallerControllerSingleton;
170 #endif // INSTALLER_CONTROLLER_H