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 widget_install_to_external.cpp
18 * @author Soyoung Kim (sy037.kim@smasung.com)
20 #include "widget_install_to_external.h"
22 #include <dpl/singleton_safe_impl.h>
23 #include <dpl/assert.h>
24 #include <dpl/log/log.h>
26 IMPLEMENT_SAFE_SINGLETON(WidgetInstallToExt)
28 WidgetInstallToExt::WidgetInstallToExt() :
34 WidgetInstallToExt::~WidgetInstallToExt()
38 void WidgetInstallToExt::initialize(std::string appId)
40 LogDebug("WidgetInstallToExt::initialize()");
43 m_handle = app2ext_init(APP2EXT_SD_CARD);
44 if (NULL == m_handle) {
45 ThrowMsg(Exception::ErrorInstallToExt, "initialize failed");
49 void WidgetInstallToExt::deinitialize()
51 LogDebug("WidgetInstallToExt::deinitialize()");
52 if (NULL != m_handle) {
53 if ( 0 < app2ext_deinit(m_handle)) {
54 ThrowMsg(Exception::ErrorInstallToExt, "app2ext deinitialize \
60 void WidgetInstallToExt::preInstallation(GList *dirList, int dSize)
62 LogDebug("WidgetInstallToExt::preInstallation()");
65 int ret = m_handle->interface.pre_install(m_appId.c_str(), dirList, dSize);
67 if (APP2EXT_SUCCESS == ret ) {
68 LogDebug("App2Ext pre install success");
70 postInstallation(false);
71 ThrowMsg(Exception::ErrorInstallToExt, "pre-install failed");
75 void WidgetInstallToExt::postInstallation(bool status)
77 LogDebug("WidgetInstallToExt::postInstallation()");
81 m_handle->interface.post_install(m_appId.c_str(),
82 APP2EXT_STATUS_SUCCESS);
84 m_handle->interface.post_install(m_appId.c_str(),
85 APP2EXT_STATUS_FAILED);
89 void WidgetInstallToExt::preUpgrade(GList *dirList, int dSize)
91 LogDebug("WidgetInstallToExt::preUpgrade()");
94 int ret = m_handle->interface.pre_upgrade(m_appId.c_str(), dirList, dSize);
95 if (APP2EXT_SUCCESS == ret ) {
96 LogDebug("App2Ext pre-upgrade success");
99 ThrowMsg(Exception::ErrorInstallToExt, "pre-upgrade failed");
103 void WidgetInstallToExt::postUpgrade(bool status)
105 LogDebug("WidgetInstallToExt::postUpgrade()");
109 m_handle->interface.post_upgrade(m_appId.c_str(),
110 APP2EXT_STATUS_SUCCESS);
112 m_handle->interface.post_upgrade(m_appId.c_str(),
113 APP2EXT_STATUS_FAILED);
117 void WidgetInstallToExt::uninstallation()
119 LogDebug("WidgetInstallToExt::uninstallation()");
123 int ret = m_handle->interface.pre_uninstall(m_appId.c_str());
124 if (APP2EXT_SUCCESS == ret ) {
125 if (APP2EXT_SUCCESS ==
126 m_handle->interface.post_uninstall(m_appId.c_str())) {
127 LogDebug("App2Ext pre-uninstall success");
129 ThrowMsg(Exception::ErrorInstallToExt, "post-uninstall failed");
132 ThrowMsg(Exception::ErrorInstallToExt, "pre-uninstall failed");