Update wrt-plugins-common_0.3.60
[platform/framework/web/wrt-plugins-common.git] / src / plugins-installer / 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 {
24
25 InstallerController::InstallerController()
26 {
27 }
28
29 //void InstallerController::OnEventReceived(
30 //        const InstallerControllerEvents::InstallWidgetEvent &event)
31 //{
32 //    std::string fileName = event.GetArg0();
33 //    WidgetInstallationStruct installerStruct = event.GetArg1();
34 //    Jobs::JobHandle handle =
35 //        m_installerLogic.InstallWidget(fileName, installerStruct);
36 //
37 //    //TODO return handle to API
38 //    (void)handle;
39 //}
40
41 void InstallerController::OnEventReceived(
42         const InstallerControllerEvents::InstallPluginEvent &event)
43 {
44     std::string dirName = event.GetArg0();
45     PluginInstallerStruct installerStruct = event.GetArg1();
46
47     Jobs::JobHandle handle =
48         m_installerLogic.InstallPlugin(dirName, installerStruct);
49
50     //TODO return handle to API
51     (void)handle;
52 }
53
54 //void InstallerController::OnEventReceived(
55 //        const InstallerControllerEvents::UninstallWidgetEvent &event)
56 //{
57 //    WidgetHandle widgetHandle = event.GetArg0();
58 //    WidgetUninstallationStruct uninstallerStruct = event.GetArg1();
59 //    Jobs::JobHandle handle =
60 //        m_installerLogic.UninstallWidget(widgetHandle, uninstallerStruct);
61 //
62 //    //TODO return handle to API
63 //    (void)handle;
64 //}
65
66 Eina_Bool InstallerController::AddNextStep(void *data)
67 {
68     Jobs::Job* model = static_cast<Jobs::Job *>(data);
69     CONTROLLER_POST_EVENT(InstallerController,
70             InstallerControllerEvents::NextStepEvent(model));
71
72     return ECORE_CALLBACK_CANCEL;
73 }
74
75 void InstallerController::OnEventReceived(
76         const InstallerControllerEvents::NextStepEvent &event)
77 {
78     Jobs::Job* model = event.GetArg0();
79     Assert(model != NULL);
80
81     if (m_installerLogic.NextStep(model)) {
82         ecore_idler_add(AddNextStep, model);
83     }
84 }
85
86 //void InstallerController::OnEventReceived(
87 //        const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent &
88 //        event)
89 //{
90 //    (void)event;
91 //    m_installerLogic.InstallDeferredWidgetPackages();
92 //}
93
94 void InstallerController::OnEventReceived(
95         const InstallerControllerEvents::InitializeEvent & /*event*/)
96 {
97     m_installerLogic.Initialize();
98 }
99
100 void InstallerController::OnEventReceived(
101         const InstallerControllerEvents::TerminateEvent & /*event*/)
102 {
103     m_installerLogic.Terminate();
104 }
105
106 } //Logic
107