Beispiel #1
0
void Firefox::reloadConfiguration()
{
    KConfigGroup config(KSharedConfig::openConfig("kdeglobals"), QLatin1String("General") );
    if (QSqlDatabase::isDriverAvailable("QSQLITE")) {
        KConfigGroup grp = config;
        /* This allows the user to specify a profile database */
        m_dbFile = grp.readEntry<QString>("dbfile", "");
        if (m_dbFile.isEmpty() || QFile::exists(m_dbFile)) {
            //Try to get the right database file, the default profile is used
            KConfig firefoxProfile(QDir::homePath() + "/.mozilla/firefox/profiles.ini",
                                   KConfig::SimpleConfig);
            QStringList profilesList = firefoxProfile.groupList();
            profilesList = profilesList.filter(QRegExp("^Profile\\d+$"));
            int size = profilesList.size();

            QString profilePath;
            if (size == 1) {
                // There is only 1 profile so we select it
                KConfigGroup fGrp = firefoxProfile.group(profilesList.first());
                profilePath = fGrp.readEntry("Path", "");
            } else {
                // There are multiple profiles, find the default one
                foreach(const QString & profileName, profilesList) {
                    KConfigGroup fGrp = firefoxProfile.group(profileName);
                    if (fGrp.readEntry<int>("Default", 0)) {
                        profilePath = fGrp.readEntry("Path", "");
                        break;
                    }
                }
            }
void BookmarksRunner::reloadConfiguration()
{
    if (m_browser == Firefox) {
        if (QSqlDatabase::isDriverAvailable("QSQLITE")) {
            KConfigGroup grp = config();
            /* This allows the user to specify a profile database */
            m_dbFile = grp.readEntry<QString>("dbfile", "");
            if (m_dbFile.isEmpty() || QFile::exists(m_dbFile)) {
                //Try to get the right database file, the default profile is used
                KConfig firefoxProfile(QDir::homePath() + "/.mozilla/firefox/profiles.ini",
                                       KConfig::SimpleConfig);
                QStringList profilesList = firefoxProfile.groupList();
                profilesList = profilesList.filter(QRegExp("^Profile\\d+$"));
                int size = profilesList.size();

                QString profilePath;
                if (size == 1) {
                    // There is only 1 profile so we select it
                    KConfigGroup fGrp = firefoxProfile.group(profilesList.first());
                    profilePath = fGrp.readEntry("Path", "");
                } else {
                    // There are multiple profiles, find the default one
                    foreach(const QString & profileName, profilesList) {
                        KConfigGroup fGrp = firefoxProfile.group(profileName);
                        if (fGrp.readEntry<int>("Default", 0)) {
                            profilePath = fGrp.readEntry("Path", "");
                            break;
                        }
                    }
                }

                if (profilePath.isEmpty()) {
                    kDebug() << "No default firefox profile found";
                    m_db = QSqlDatabase();
                    return;
                }

                profilePath.prepend(QString("%1/.mozilla/firefox/").arg(QDir::homePath()));
                m_dbFile = profilePath + "/places.sqlite";
                grp.writeEntry("dbfile", m_dbFile);
            }