correct error definition when to-be-uninstalled widget is running
[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
20 IMPLEMENT_SINGLETON(Logic::InstallerController)
21
22 namespace Logic {
23 InstallerController::InstallerController()
24 {}
25
26 void InstallerController::OnEventReceived(
27     const InstallerControllerEvents::InstallWidgetEvent &event)
28 {
29     std::string fileName = event.GetArg0();
30     WidgetInstallationStruct installerStruct = event.GetArg1();
31     m_installerLogic.InstallWidget(fileName, installerStruct);
32 }
33
34 void InstallerController::OnEventReceived(
35     const InstallerControllerEvents::InstallPluginEvent &event)
36 {
37     std::string dirName = event.GetArg0();
38     PluginInstallerStruct installerStruct = event.GetArg1();
39     m_installerLogic.InstallPlugin(dirName, installerStruct);
40 }
41
42 void InstallerController::OnEventReceived(
43     const InstallerControllerEvents::UninstallWidgetEvent &event)
44 {
45     std::string widgetPkgName = event.GetArg0();
46     WidgetUninstallationStruct uninstallerStruct = event.GetArg1();
47     m_installerLogic.UninstallWidget(widgetPkgName, uninstallerStruct);
48 }
49
50 Eina_Bool InstallerController::AddNextStep(void *data)
51 {
52     Jobs::Job* model = static_cast<Jobs::Job *>(data);
53     CONTROLLER_POST_EVENT(InstallerController,
54                           InstallerControllerEvents::NextStepEvent(model));
55
56     return ECORE_CALLBACK_CANCEL;
57 }
58
59 void InstallerController::OnEventReceived(
60     const InstallerControllerEvents::NextStepEvent &event)
61 {
62     Jobs::Job* model = event.GetArg0();
63     Assert(model != NULL);
64
65     if (m_installerLogic.NextStep(model)) {
66         ecore_idler_add(AddNextStep, model);
67     }
68 }
69
70 void InstallerController::OnEventReceived(
71     const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent &
72     event)
73 {
74     (void)event;
75     m_installerLogic.InstallDeferredWidgetPackages();
76 }
77
78 void InstallerController::OnEventReceived(
79     const InstallerControllerEvents::InitializeEvent & /*event*/)
80 {
81     m_installerLogic.Initialize();
82 }
83
84 void InstallerController::OnEventReceived(
85     const InstallerControllerEvents::TerminateEvent & /*event*/)
86 {
87     m_installerLogic.Terminate();
88 }
89 } //Logic
90