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.
16 #include <widget_uninstall/job_widget_uninstall.h>
17 #include <widget_uninstall/task_check.h>
18 #include <widget_uninstall/task_db_update.h>
19 #include <widget_uninstall/task_remove_files.h>
20 #include <widget_uninstall/task_smack.h>
22 using namespace WrtDB;
25 namespace WidgetUninstall {
26 JobWidgetUninstall::JobWidgetUninstall(WidgetHandle widgetHandle,
27 const WidgetUninstallationStruct &uninstallerStruct) :
29 JobContextBase<WidgetUninstallationStruct>(uninstallerStruct)
31 WidgetDAO dao(widgetHandle);
33 m_context.widgetHandle = widgetHandle;
34 m_context.removeStarted = false;
35 m_context.removeFinished = false;
36 m_context.uninstallStep = UninstallerContext::UNINSTALL_START;
39 AddTask(new TaskSmack(m_context));
40 AddTask(new TaskCheck(m_context));
41 AddTask(new TaskRemoveFiles(m_context));
42 AddTask(new TaskDbUpdate(m_context));
45 WidgetHandle JobWidgetUninstall::getRemovedWidgetHandle() const
47 return m_context.widgetHandle;
50 bool JobWidgetUninstall::getRemoveStartedFlag() const
52 return m_context.removeStarted;
55 bool JobWidgetUninstall::getRemoveFinishedFlag() const
57 return m_context.removeFinished;
60 void JobWidgetUninstall::SendProgress()
62 if (!getRemoveStartedFlag() ||
63 (getRemoveStartedFlag() && getRemoveFinishedFlag())) {
64 if (NULL != getInstallerStruct().progressCallback) {
65 LogDebug("Call widget uninstall progressCallback");
66 getInstallerStruct().progressCallback(
67 getInstallerStruct().userParam,
68 GetProgressPercent(), GetProgressDescription());
73 void JobWidgetUninstall::SendFinishedSuccess()
75 LogDebug("Call widget uninstall success finishedCallback");
76 getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
77 getRemovedWidgetHandle(),Exceptions::Success);
80 void JobWidgetUninstall::SendFinishedFailure()
82 LogError("Error in uninstallation step: " << m_exceptionCaught);
83 LogError("Message: " << m_exceptionMessage);
85 LogDebug("Call widget uninstall failure finishedCallback");
86 getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
87 getRemovedWidgetHandle(), m_exceptionCaught); //TODO
88 LogDebug("[JobWidgetUninstall] Asynchronous failure callback status sent");
91 void JobWidgetUninstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
93 m_exceptionCaught = static_cast<Exceptions::Type>(e.getParam());
94 m_exceptionMessage = e.GetMessage();
96 } //namespace WidgetUninstall