tizen beta release
[framework/web/wrt-installer.git] / src / logic / installer_controller.cpp
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 #include "installer_controller.h"
17 #include <dpl/log/log.h>
18 #include <dpl/singleton_impl.h>
19 IMPLEMENT_SINGLETON(InstallerController)
20
21 InstallerController::InstallerController()
22 {
23 }
24
25 void InstallerController::OnEventReceived(
26         const InstallerControllerEvents::InstallWidgetEvent &event)
27 {
28     std::string zipFileName = event.GetArg0();
29     WidgetInstallationStruct installerStruct = event.GetArg1();
30     Jobs::JobHandle handle =
31         m_installerLogic.InstallWidget(zipFileName, installerStruct);
32
33     //TODO return handle to API
34     (void)handle;
35 }
36
37 void InstallerController::OnEventReceived(
38         const InstallerControllerEvents::InstallPluginEvent &event)
39 {
40     std::string dirName = event.GetArg0();
41     PluginInstallerStruct installerStruct = event.GetArg1();
42
43     Jobs::JobHandle handle =
44         m_installerLogic.InstallPlugin(dirName, installerStruct);
45
46     //TODO return handle to API
47     (void)handle;
48 }
49
50 void InstallerController::OnEventReceived(const InstallerControllerEvents::
51             InstallPluginGeolocationEvent &event)
52 {
53     PluginInstallerStruct installerStruct = event.GetArg0();
54
55     InstallerLogic::InstallPluginGeolocation(installerStruct);
56 }
57
58 void InstallerController::OnEventReceived(
59         const InstallerControllerEvents::UninstallWidgetEvent &event)
60 {
61     WidgetHandle widgetHandle = event.GetArg0();
62     WidgetUninstallationStruct uninstallerStruct = event.GetArg1();
63     Jobs::JobHandle handle =
64         m_installerLogic.UninstallWidget(widgetHandle, uninstallerStruct);
65
66     //TODO return handle to API
67     (void)handle;
68 }
69
70 Eina_Bool InstallerController::AddNextStep(void *data)
71 {
72     Jobs::Job* model = static_cast<Jobs::Job *>(data);
73     CONTROLLER_POST_EVENT(InstallerController,
74             InstallerControllerEvents::NextStepEvent(model));
75
76     return ECORE_CALLBACK_CANCEL;
77 }
78
79 void InstallerController::OnEventReceived(
80         const InstallerControllerEvents::NextStepEvent &event)
81 {
82     Jobs::Job* model = event.GetArg0();
83     Assert(model != NULL);
84
85     if (m_installerLogic.NextStep(model)) {
86         ecore_idler_add(AddNextStep, model);
87     }
88 }
89
90 void InstallerController::OnEventReceived(
91         const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent &
92         event)
93 {
94     (void)event;
95     m_installerLogic.InstallDeferredWidgetPackages();
96 }
97
98 void InstallerController::OnEventReceived(
99         const InstallerControllerEvents::InitializeEvent & /*event*/)
100 {
101     m_installerLogic.Initialize();
102 }
103
104 void InstallerController::OnEventReceived(
105         const InstallerControllerEvents::TerminateEvent & /*event*/)
106 {
107     m_installerLogic.Terminate();
108 }