Exemplo n.º 1
0
QString Settings::GetInstalledAppVersion(const QString& appName, eAppType type) {
    AppsConfig::AppMap* appMap = m_Config.GetAppMap(type);
    AppsConfig::AppMap::const_iterator appIter = appMap->find(appName);
    if (appIter == appMap->end())
        return "";

    AppsConfig::AppVersion::const_iterator iter = appIter.value().begin();
    if (iter == appIter.value().end())
        return "";

    return iter.value().m_Version;
}
Exemplo n.º 2
0
QString Installer::GetRunPath(const QString& appName, eAppType type) {
    AppsConfig appsConfig = Settings::GetInstance()->GetCurrentConfig();
    AppsConfig::AppMap* appMap = appsConfig.GetAppMap(type);
    if (!appMap) {
        return "";
    }

    AppsConfig::AppMap::const_iterator appIter = appMap->find(appName);
    if (appIter == appMap->end())
        return "";

    AppsConfig::AppVersion::const_iterator iter = appIter.value().begin();
    if (iter == appIter.value().end())
        return "";

    const AppConfig& config = iter.value();
    return GetInstallPath(type) + config.m_RunPath;
}
Exemplo n.º 3
0
bool Installer::Delete(const QString& appName, eAppType type, bool force) {
    Logger::GetInstance()->AddLog(tr("Deleting %1").arg(appName));
    AppsConfig appsConfig = Settings::GetInstance()->GetCurrentConfig();
    AppsConfig::AppMap* appMap = appsConfig.GetAppMap(type);

    AppsConfig::AppMap::const_iterator appIter = appMap->find(appName);
    if (appIter == appMap->end())
        return "";

    AppsConfig::AppVersion::const_iterator iter = appIter.value().begin();
    if (iter == appIter.value().end())
        return "";

    const AppConfig& config = iter.value();

    QString installPath = GetInstallPath(type);
    if (!config.m_RunPath.isEmpty()){
        while (ProcessHelper::IsProcessRuning(installPath + config.m_RunPath)) {
            Logger::GetInstance()->AddLog(tr("%1 app is running.").arg(appName));
            if(force)
            {
                if (1 == QMessageBox::information(NULL,//this,
                                                 tr("Error"),
                                                 tr("%1 app is running please close it.").arg(appName),
                                                 tr("Retry"))) {
                    Logger::GetInstance()->AddLog(tr("Deleting %1 canceled").arg(appName));
                    return false;
                }
            }
            else
            {
                if (1 == QMessageBox::information(NULL,//this,
                                                 tr("Error"),
                                                 tr("%1 app is running please close it.").arg(appName),
                                                 tr("Retry"),
                                                 tr("Cancel"))) {
                    Logger::GetInstance()->AddLog(tr("Deleting %1 canceled").arg(appName));
                    return false;
                }
            }
        }
    }

    bool result = false;
#ifdef Q_OS_WIN
    if (!config.m_InstallCmd.isEmpty() || !config.m_UninstallCmd.isEmpty()) {
        QString path = GetInstallPath(type) + APP_INSTALLER_DIR + "/" + appName + "/";
        if (!config.m_UninstallCmd.isEmpty())
            path += config.m_UninstallCmd;
        else
            path += config.m_InstallCmd;

        QString params = config.m_UninstallParams;

        int nExitCode = RunAndWaitForFinish(path, params);
        if (nExitCode == config.m_nSuccessInstallCode)
            result = true;
    } else {
#endif
        result = true;
        for (int i = 0; i < config.m_InstalledFiles.size(); ++i) {
            QString path = installPath + config.m_InstalledFiles.at(i);

            QFile file(path);
            if (file.exists()) {
                QFileInfo info(file);
                if (info.isDir()) {
                    result &= DirectoryManager::DeleteDir(path);
                } else {
                    result &= QFile().remove(path);
                }
            }
        }
#ifdef Q_OS_WIN
    }
#endif

    if (!result) {
        Logger::GetInstance()->AddLog(tr("Error delete app"));
        return false;
    }

    Logger::GetInstance()->AddLog(tr("%1 deleted").arg(appName));
    appMap->remove(appName);
    Settings::GetInstance()->UpdateConfig(appsConfig);

    UpdateAvailableSoftware();
    return true;
}