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 "plugin_objects.h"
25 #include <wrt_common_types.h>
26 #include <dpl/log/secure_log.h>
29 namespace PluginInstall {
30 JobPluginInstall::JobPluginInstall(PluginPath const &pluginPath,
31 const PluginInstallerStruct &installerStruct)
33 Job(PluginInstallation),
34 JobContextBase<PluginInstallerStruct>(installerStruct),
35 m_exceptionCaught(Jobs::Exceptions::Success)
38 // Init installer context
40 m_context.pluginFilePath = pluginPath;
41 m_context.pluginHandle = INVALID_HANDLE;
42 m_context.installationCompleted = false;
44 m_context.installerTask = this;
46 // Create main installation tasks
48 AddTask(new PluginInstallTask(&m_context));
51 void JobPluginInstall::SendProgress()
53 if (GetProgressFlag() && GetInstallerStruct().progressCallback != NULL) {
54 _D("Call Plugin install progressCallback");
55 GetInstallerStruct().progressCallback(GetInstallerStruct().userParam,
57 GetProgressDescription());
61 void JobPluginInstall::SendFinishedSuccess()
63 PluginHandle handle = getNewPluginHandle();
65 if (handle != Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE &&
68 _D("Call Plugin install success finishedCallback");
69 GetInstallerStruct().finishedCallback(GetInstallerStruct().userParam,
70 Jobs::Exceptions::Success);
72 _D("Call Plugin install waiting finishedCallback");
73 GetInstallerStruct().finishedCallback(GetInstallerStruct().userParam,
74 Jobs::Exceptions::ErrorPluginInstallationFailed);
76 _D("Installation: %s NOT possible", getFilePath().c_str());
80 void JobPluginInstall::SendFinishedFailure()
82 LOGE("Error in plugin installation step: %d", m_exceptionCaught);
83 LOGE("Message: %s", m_exceptionMessage.c_str());
84 fprintf(stderr, "[Err:%d] %s", m_exceptionCaught, m_exceptionMessage.c_str());
86 _D("Call Plugin install failure finishedCallback");
87 GetInstallerStruct().finishedCallback(GetInstallerStruct().userParam,
91 void JobPluginInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
93 m_exceptionCaught = static_cast<Jobs::Exceptions::Type>(e.getParam());
94 m_exceptionMessage = e.GetMessage();
97 } //namespace PluginInstall