Esempio n. 1
0
QStringList Uninstaller::getAllSections()
{
    QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
    QStringList allSections = installlog.childGroups();
    allSections.removeAt(allSections.lastIndexOf("Bootloader"));
    return allSections;
}
Esempio n. 2
0
//! \brief copys Talkfiles from the temp dir to the target. Progress and installlog is handled inside
//!
//! \param errString Pointer to a QString where the error cause is written.
//! \returns true on success, false on error or user abort
bool TalkFileCreator::copyTalkFiles(QString* errString)
{
    int progressMax = m_talkList.size();
    int m_progress = 0;
    emit logProgress(m_progress,progressMax);

    QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
    installlog.beginGroup("talkfiles");

    for(int i=0; i < m_talkList.size(); i++)
    {
        if(m_abort)
        {
            *errString = tr("File copy aborted");
            return false;
        }

        // skip not encoded files
        if(m_talkList[i].encoded == false)
        {
            emit logProgress(++m_progress,progressMax);
            continue; // this file was skipped in one of the previous steps
        }
        // remove target if it exists, and if we should overwrite it
        if(QFile::exists(m_talkList[i].target))
            QFile::remove(m_talkList[i].target);

        // copying
        qDebug() << "[TalkFileCreator] copying" << m_talkList[i].talkfilename
                 << "to" << m_talkList[i].target;
        if(!QFile::copy(m_talkList[i].talkfilename,m_talkList[i].target))
        {
            *errString = tr("Copying of %1 to %2 failed").arg(m_talkList[i].talkfilename).arg(m_talkList[i].target);
            return false;
        }

        // add to installlog
        QString now = QDate::currentDate().toString("yyyyMMdd");
        installlog.setValue(m_talkList[i].target.remove(0,m_mountpoint.length()),now);

        emit logProgress(++m_progress,progressMax);
        QCoreApplication::processEvents();
    }
    installlog.endGroup();
    installlog.sync();
    return true;
}
Esempio n. 3
0
void Uninstaller::uninstall(ProgressloggerInterface* dp)
{
    m_dp = dp;
    m_dp->setProgressMax(0);
    m_dp->addItem(tr("Starting Uninstallation"),LOGINFO);

    QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, this);

    for(int i=0; i< uninstallSections.size() ; i++)
    {
        m_dp->addItem(tr("Uninstalling %1...").arg(uninstallSections.at(i)), LOGINFO);
        QCoreApplication::processEvents();
        // create list of all other install sections
        QStringList sections = installlog.childGroups();
        sections.removeAt(sections.indexOf(uninstallSections.at(i)));
        installlog.beginGroup(uninstallSections.at(i));
        QStringList toDeleteList = installlog.allKeys();
        QStringList dirList;
        installlog.endGroup();

        // iterate over all entries
        for(int j =0; j < toDeleteList.size(); j++ )
        {
            // check if current file is in use by another section
            bool deleteFile = true;
            for(int s = 0; s < sections.size(); s++)
            {
                installlog.beginGroup(sections.at(s));
                if(installlog.contains(toDeleteList.at(j)))
                {
                    deleteFile = false;
                    qDebug() << "file still in use:" << toDeleteList.at(j);
                }
                installlog.endGroup();
            }

            installlog.beginGroup(uninstallSections.at(i));
            QFileInfo toDelete(m_mountpoint + "/" + toDeleteList.at(j));
            if(toDelete.isFile())  // if it is a file remove it
            {
                if(deleteFile && !QFile::remove(toDelete.filePath()))
                    m_dp->addItem(tr("Could not delete %1")
                          .arg(toDelete.filePath()),LOGWARNING);
                installlog.remove(toDeleteList.at(j));
                qDebug() << "deleted: " << toDelete.filePath() ;
            }
            else  // if it is a dir, remember it for later deletion
            {
                // no need to keep track on folders still in use -- only empty
                // folders will be rm'ed.
                dirList << toDeleteList.at(j);
            }
            installlog.endGroup();
            QCoreApplication::processEvents();
        }
        // delete the dirs
        installlog.beginGroup(uninstallSections.at(i));
        for(int j=0; j < dirList.size(); j++ )
        {
            installlog.remove(dirList.at(j));
            QDir dir(m_mountpoint);
            dir.rmdir(dirList.at(j)); // rm works only on empty folders
        }

        installlog.endGroup();
        //installlog.removeGroup(uninstallSections.at(i))
    }
    uninstallSections.clear();
    installlog.sync();
    m_dp->setProgressMax(1);
    m_dp->setProgressValue(1);
    m_dp->addItem(tr("Uninstallation finished"),LOGOK);
    m_dp->setFinished();
}