#
_working_dir="/opt/usr/media/Downloads/.preinstallWidgets"
-_widget_temp="/opt/share/widget/*";
+_widget_temp="/opt/share/widget/*"
+
+#Reinstall widget during booting
+_temp_widget_path="/opt/share/widget/temp_info"
install_widgets() {
_wgt_list=`find $_working_dir -name '*.wgt'`
fi
done
-
-#Reinstall widget during booting
-_temp_widget_path=/opt/share/widget/temp_info
-
FILE_LIST=`ls $_temp_widget_path`
if [ -n "$FILE_LIST" ]; then
line=`cat $FILE_NAME`
echo "----------------------------------------------------------------"
echo "UnInstalling widget : $line ..."
- wrt-installer -up $line
- echo "Installing widget : $line ..."
- wrt-installer -i $line
+ return_string=`wrt-installer -up $line 2>&1 | grep -v plugin`
+ echo "Result $return_string"
done
else
echo "There is no reinstall widget."
#Plugin installation is temporary code for window SDK
/usr/bin/wrt-installer -p
-if [ ! -d $_working_dir ]; then
- echo "There is no preinstall widget directory - $_working_dir"
+RECOVER_WIDGETS=`ls $_temp_widget_path`
+if [ -n "$RECOVER_WIDGETS" ]; then
+ echo "Start Recover"
restore_widget
- exit 1
fi
install_widgets
*/
#include <regex.h>
+#include <sys/stat.h>
#include <widget_uninstall/job_widget_uninstall.h>
#include <widget_uninstall/widget_uninstall_errors.h>
#include <widget_uninstall/task_check.h>
#include <widget_uninstall/task_smack.h>
#include <widget_uninstall/task_uninstall_ospsvc.h>
#include <widget_uninstall/task_delete_certificates.h>
+#include <dpl/wrt-dao-ro/global_config.h>
#include <pkg-manager/pkgmgr_signal.h>
#include <app2ext_interface.h>
namespace { //anonymous
const char* REG_TIZEN_PKGID_PATTERN = "^[a-zA-Z0-9]{10}$";
+const int PKGID_LENTH = 10;
+
+bool checkDirectoryExist(const std::string& pkgId)
+{
+ std::string installPath =
+ std::string(GlobalConfig::GetUserInstalledWidgetPath()) +
+ "/" + pkgId;
+
+ struct stat dirStat;
+ if ((stat(installPath.c_str(), &dirStat) == 0)) {
+ return true;
+ }
+ return false;
+}
+
class UninstallerTaskFail :
public DPL::TaskDecl<UninstallerTaskFail>
{
using namespace PackageManager;
m_context.removeStarted = false;
m_context.removeFinished = false;
+ m_context.removeAbnormal = false;
m_context.uninstallStep = UninstallerContext::UNINSTALL_START;
m_context.job = this;
m_context.isExternalWidget = getExternalWidgetFlag();
Try
{
- regex_t regx;
- if(regcomp(®x, REG_TIZEN_PKGID_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){
- LogDebug("Regcomp failed");
+ WidgetStatus status = getWidgetStatus(tizenAppId);
+
+ if (WidgetStatus::Ok == status) {
+ WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(m_context.tzAppid));
+ m_context.tzPkgid = DPL::ToUTF8String(dao.getTizenPkgId());
+ m_context.locations = WidgetLocation(m_context.tzPkgid);
+ m_context.locations->registerAppid(m_context.tzAppid);
+
+ LogInfo("Widget model exists. App id : " << m_context.tzAppid);
+
+ AddTask(new TaskSmack(m_context));
+ AddTask(new TaskCheck(m_context));
+
+ if (dao.getPackagingType() == PKG_TYPE_HYBRID_WEB_APP) {
+ AddTask(new TaskUninstallOspsvc(m_context));
+ }
+ AddTask(new TaskRemoveFiles(m_context));
+ AddTask(new TaskDbUpdate(m_context));
+ AddTask(new TaskRemoveCustomHandlers(m_context));
+ AddTask(new TaskDeleteCertificates(m_context));
+
+ // send start signal of pkgmgr
+ if (getInstallerStruct().pkgmgrInterface->setPkgname(m_context.tzPkgid))
+ {
+ getInstallerStruct().pkgmgrInterface->sendSignal(
+ PKGMGR_START_KEY,
+ PKGMGR_START_UNINSTALL);
+ }
+ } else if (WidgetStatus::NOT_INSTALLED == status) {
+ AddTask(new UninstallerTaskFail(true));
+ } else if (WidgetStatus::ABNORMAL == status) {
+ m_context.locations = WidgetLocation(m_context.tzPkgid);
+ m_context.removeAbnormal = true;
+ AddTask(new TaskRemoveFiles(m_context));
+ } else {
+ AddTask(new UninstallerTaskFail(false));
}
+ } Catch(WidgetDAOReadOnly::Exception::Base) {
+ AddTask(new UninstallerTaskFail(false));
+ }
+}
+
+JobWidgetUninstall::WidgetStatus JobWidgetUninstall::getWidgetStatus(const std::string &id)
+{
+ regex_t regx;
+ if(regcomp(®x, REG_TIZEN_PKGID_PATTERN, REG_NOSUB | REG_EXTENDED)!=0){
+ LogDebug("Regcomp failed");
+ }
+ std::string pkgId;
- if ((regexec(®x, tizenAppId.c_str(),
+ Try {
+ if ((regexec(®x, id.c_str(),
static_cast<size_t>(0), NULL, 0) == REG_NOERROR)) {
+ pkgId = id;
+
TizenAppId appid =
WrtDB::WidgetDAOReadOnly::getTzAppId(
- DPL::FromUTF8String(tizenAppId));
+ DPL::FromUTF8String(id));
LogDebug("Get appid from pkgid : " << appid);
m_context.tzAppid = DPL::ToUTF8String(appid);
} else {
- m_context.tzAppid = tizenAppId;
- }
- WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(m_context.tzAppid));
- m_context.tzPkgid = DPL::ToUTF8String(dao.getTizenPkgId());
- m_context.locations = WidgetLocation(m_context.tzPkgid);
- m_context.locations->registerAppid(m_context.tzAppid);
-
- LogInfo("Widget model exists. App id : " << m_context.tzAppid);
-
- AddTask(new TaskSmack(m_context));
- AddTask(new TaskCheck(m_context));
-
- if (dao.getPackagingType() == PKG_TYPE_HYBRID_WEB_APP) {
- AddTask(new TaskUninstallOspsvc(m_context));
- }
- AddTask(new TaskRemoveFiles(m_context));
- AddTask(new TaskDbUpdate(m_context));
- AddTask(new TaskRemoveCustomHandlers(m_context));
- AddTask(new TaskDeleteCertificates(m_context));
-
- // send start signal of pkgmgr
- if (getInstallerStruct().pkgmgrInterface->setPkgname(m_context.tzPkgid))
- {
- getInstallerStruct().pkgmgrInterface->sendSignal(
- PKGMGR_START_KEY,
- PKGMGR_START_UNINSTALL);
+ pkgId = id.substr(0, PKGID_LENTH);
+ WrtDB::WidgetDAOReadOnly dao(DPL::FromUTF8String(id));
+ m_context.tzAppid = id;
}
} Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
- AddTask(new UninstallerTaskFail(true));
- } Catch(WidgetDAOReadOnly::Exception::Base) {
- AddTask(new UninstallerTaskFail(false));
+ LogDebug("package id : " << pkgId);
+ m_context.tzPkgid = pkgId;
+ if (!pkgId.empty()) {
+ if(checkDirectoryExist(pkgId)) {
+ LogError("installed widget status is abnormal");
+ return WidgetStatus::ABNORMAL;
+ }
+ }
+ return WidgetStatus::NOT_INSTALLED;
}
+ return WidgetStatus::Ok;
}
std::string JobWidgetUninstall::getRemovedTizenId() const
bool getRemoveFinishedFlag() const;
bool getExternalWidgetFlag() const;
+ enum class WidgetStatus
+ {
+ Ok, NOT_INSTALLED, ABNORMAL
+ };
+
+ WidgetStatus getWidgetStatus(const std::string &appId);
+
void SendProgress();
void SendFinishedSuccess();
void SendFinishedFailure();
} else {
AddStep(&TaskRemoveFiles::StepRemoveExternalWidget);
}
- //AddStep(&TaskRemoveFiles::StepRemoveDesktop);
AddStep(&TaskRemoveFiles::StepRemoveManifest);
AddStep(&TaskRemoveFiles::StepRemoveExternalLocations);
AddStep(&TaskRemoveFiles::StepRemoveVconf);
"Widget remove steps Finished");
}
-void TaskRemoveFiles::StepRemoveDesktop()
-{
- std::ostringstream desktopFile;
-
- desktopFile << GlobalConfig::GetUserWidgetDesktopPath() << "/";
- desktopFile << m_context.tzAppid << ".desktop";
-
- unlink(desktopFile.str().c_str());
-
- ail_appinfo_h ai = NULL;
- ail_error_e ret;
-
- const char* package = m_context.tzAppid.c_str();
- LogDebug("ail delete : " << package);
-
- ret = ail_get_appinfo(package, &ai);
- if (ai) {
- ail_destroy_appinfo(ai);
- }
-
- if (AIL_ERROR_OK == ret) {
- if (0 > ail_desktop_remove(package)) {
- LogWarning("Failed to remove ail information : " << package);
- }
- }
-
- m_context.job->UpdateProgress(
- UninstallerContext::UNINSTALL_REMOVE_DESKTOP,
- "Widget remove desktop Finished");
-}
-
void TaskRemoveFiles::StepRemoveManifest()
{
std::ostringstream manifest_name;
void TaskRemoveFiles::StepRemoveExternalLocations()
{
- WidgetDAO dao(DPL::FromUTF8String(m_context.tzAppid));
- LogDebug("Removing external locations:");
- WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations();
- FOREACH(path, externalPaths)
- {
- if (WrtUtilFileExists(*path)) {
- LogDebug(" -> " << *path);
- int ret = remove(path->c_str());
- if (ret != 0) {
- LogError(
- "Failed to remove the file: " << path->c_str() <<
- " with error: " << strerror(errno));
+ if (!m_context.removeAbnormal) {
+ WidgetDAO dao(DPL::FromUTF8String(m_context.tzAppid));
+ LogDebug("Removing external locations:");
+ WrtDB::ExternalLocationList externalPaths = dao.getWidgetExternalLocations();
+ FOREACH(path, externalPaths)
+ {
+ if (WrtUtilFileExists(*path)) {
+ LogDebug(" -> " << *path);
+ int ret = remove(path->c_str());
+ if (ret != 0) {
+ LogError(
+ "Failed to remove the file: " << path->c_str() <<
+ " with error: " << strerror(errno));
+ }
+ } else if (WrtUtilDirExists(*path)) {
+ LogDebug(" -> " << *path);
+ if (!WrtUtilRemove(*path)) {
+ Throw(
+ Jobs::WidgetUninstall::TaskRemoveFiles::Exception::
+ RemoveFilesFailed);
+ }
+ } else {
+ LogWarning(" -> " << *path << "(no such a path)");
}
- } else if (WrtUtilDirExists(*path)) {
- LogDebug(" -> " << *path);
- if (!WrtUtilRemove(*path)) {
- Throw(
- Jobs::WidgetUninstall::TaskRemoveFiles::Exception::
- RemoveFilesFailed);
- }
- } else {
- LogWarning(" -> " << *path << "(no such a path)");
}
+ dao.unregisterAllExternalLocations();
}
- dao.unregisterAllExternalLocations();
}
void TaskRemoveFiles::StepRemoveVconf()
{
- std::string key =
- WrtDB::VconfConfig::GetVconfKeyRootPath(DPL::FromUTF8String(m_context.
- tzAppid));
- if (vconf_unset_recursive(key.c_str())) {
- LogError("Fail to unset vconf file");
- } else {
- LogDebug("vconf file is removed");
+ if (!m_context.removeAbnormal) {
+ std::string key =
+ WrtDB::VconfConfig::GetVconfKeyRootPath(DPL::FromUTF8String(m_context.
+ tzAppid));
+ if (vconf_unset_recursive(key.c_str())) {
+ LogError("Fail to unset vconf file");
+ } else {
+ LogDebug("vconf file is removed");
+ }
}
}
std::string tzAppid;
std::string tzPkgid;
bool isExternalWidget;
+ bool removeAbnormal;
};
#endif // WRT_SRC_INSTALLER_CORE_UNINSTALLER_TASKS_UNINSTALLER_CONTEXT_H_
const double BASE_LAYOUT_H = 1280.0f;
const char * const CONFIG_XML = "config.xml";
+const char * const HYBRID_CONFIG_XML = "res/wgt/config.xml";
struct free_deleter
{
// Open zip file
std::unique_ptr<DPL::ZipInput> zipFile(
new DPL::ZipInput(m_packagePath));
+ std::unique_ptr<DPL::ZipInput::File> configFile;
- // Open config.xml file
- std::unique_ptr<DPL::ZipInput::File> configFile(
- zipFile->OpenFile(CONFIG_XML));
+ Try {
+ // Open config.xml file
+ configFile.reset(zipFile->OpenFile(CONFIG_XML));
+ }
+ Catch(DPL::ZipInput::Exception::OpenFileFailed)
+ {
+ // Open config.xml file for hybrid
+ configFile.reset(zipFile->OpenFile(HYBRID_CONFIG_XML));
+ }
// Extract config
DPL::BinaryQueue buffer;
DPL::FromUTF32String(
L"widget"))));
- DPL::OptionalString widgetGUID = configInfo.widget_id;
-
- std::string guid = DPL::ToUTF8String(*widgetGUID);
-
- std::string appid;
- WrtErrStatus status = wrt_get_widget_by_guid(appid, guid);
- if (status == WRT_SUCCESS) {
- LogDebug("Appid from packagePath : " << appid);
+ DPL::OptionalString pkgId = configInfo.tizenPkgId;
+ if (!pkgId.IsNull()) {
+ LogDebug("Pkgid from packagePath : " << pkgId);
wrt_uninstall_widget(
- appid.c_str(), this, &staticWrtStatusCallback,
+ DPL::ToUTF8String(*pkgId).c_str(), this, &staticWrtStatusCallback,
!m_quiet ? &staticWrtUninstallProgressCallback
: NULL,
pkgmgrSignalInterface);