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.
17 * @file job_plugin_install.cpp
18 * @author Pawel Sikorski (p.sikorski@samgsung.com)
22 #include <plugin_install/job_plugin_install.h>
23 #include <plugin_install/plugin_install_task.h>
24 #include <widget_install/widget_installer_struct.h> //TODO remove
26 //#include <plugin_logic.h>
27 #include "plugin_objects.h"
30 namespace PluginInstall {
31 JobPluginInstall::JobPluginInstall(std::string const &pluginPath,
32 const PluginInstallerStruct &installerStruct) :
33 Job(PluginInstallation),
34 JobContextBase<PluginInstallerStruct>(installerStruct)
37 // Init installer context
39 m_context.pluginFilePath = pluginPath;
40 m_context.pluginHandle = INVALID_HANDLE;
41 m_context.installationCompleted = false;
43 m_context.installerTask = this;
45 // Create main installation tasks
47 AddTask(new PluginInstallTask(&m_context));
50 void JobPluginInstall::SendProgress()
52 if (GetProgressFlag() && getInstallerStruct().progressCallback != NULL) {
53 LogDebug("Call Plugin install progressCallback");
54 getInstallerStruct().progressCallback(getInstallerStruct().userParam,
55 GetProgressPercent(), GetProgressDescription());
59 void JobPluginInstall::SendFinishedSuccess()
61 PluginHandle handle = getNewPluginHandle();
63 if (handle != Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE &&
66 LogDebug("Call Plugin install success finishedCallback");
67 getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
70 LogDebug("Call Plugin install waiting finishedCallback");
71 getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
72 Exceptions::InstallationWaiting);
74 LogInfo("Installation: " << getFilePath() <<
79 void JobPluginInstall::SendFinishedFailure()
81 LogError("Error in plugin installation step: " << m_exceptionCaught);
82 LogError("Message: " << m_exceptionMessage);
84 LogDebug("Call Plugin install failure finishedCallback");
85 getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
89 void JobPluginInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
91 m_exceptionCaught = static_cast<Exceptions::Type>(e.getParam());
92 m_exceptionMessage = e.GetMessage();
95 } //namespace PluginInstall