QList<lastfm::User>
unicorn::Settings::userRoster() const
{
    const_cast<Settings*>(this)->beginGroup( "Users" );
    QList<User> ret;
    foreach( QString child, childGroups()) {
        if( child == "com" || !contains( child + "/SessionKey" )) continue;
        ret << User( child );
    }
    const_cast<Settings*>(this)->endGroup();
    return ret;
}
Exemple #2
0
DatabaseInfo UserSettings::getDatabaseInfo(const QString & id) {
	DatabaseInfo info;
	beginGroup("Database");
	if (!childGroups().contains(id)) {
		return info;
		endGroup();
	}
		beginGroup(id);
		info.id = id;
		info.host = value("host",QString("localhost")).toString();
		info.port = value("port", 5432).toInt();
		info.name = value("name", "daisi").toString();
		info.password = value("password", "18ifaoe184").toString();
		info.user = value("user","daisi").toString();
		endGroup();
	endGroup();
	return info;
}
Exemple #3
0
int settings::load_users()
{
	users_info->clear();
	//	select all groups at users group
	beginGroup("users");
	QStringList users = childGroups();
	endGroup();
	QStringList u_dirs;
	QString tmp_dir;
	user_info tmp_user;
	int pos = 0;
	//	select all data dirs
	for(int i = 0; i < users.size(); i++)
	{
		tmp_dir = value("users/"+users[i]+"/dir", "").toString();
			//	check is dir defined
		if( tmp_dir.size() == 0 )
		{	// delete user (wrong)
			remove( QString("users/"+users[i]) );
			users.removeAt(i);
			continue;
		}
			//	check is dir belong to other user
		if( (pos = u_dirs.indexOf( tmp_dir )) != -1)
		{	//	user with same user dir exists del them
			remove( QString("users/"+users[i]) );
			users.removeAt(i);
			remove( QString("users/"+users[pos]) );
			users.removeAt(pos);
			u_dirs.removeAt(pos);
			continue;
		}
		u_dirs.insert(i, tmp_dir);
			//	add to list
		tmp_user.user = users[i];
		tmp_user.dir = QDir( tmp_dir );
		tmp_user.hash = value("users/"+users[i]+"/password", "").toString();
			//	add
		users_info->push_back(tmp_user);
	}
	return users_info->size();

}
Exemple #4
0
int FolderMan::setupFolders()
{
    unloadAndDeleteAllFolders();

    auto settings = Account::settingsWithGroup(QLatin1String("Accounts"));
    const auto accountsWithSettings = settings->childGroups();
    if (accountsWithSettings.isEmpty()) {
        int r = setupFoldersMigration();
        if (r > 0) {
            AccountManager::instance()->save(false); // don't save credentials, they had not been loaded from keychain
        }
        return r;
    }

    qDebug() << "* Setup folders from settings file";

    foreach (const auto& account, AccountManager::instance()->accounts()) {
        const auto id = account->account()->id();
        if (!accountsWithSettings.contains(id)) {
            continue;
        }
        settings->beginGroup(id);
        settings->beginGroup(QLatin1String("Folders"));
        foreach (const auto& folderAlias, settings->childGroups()) {
            FolderDefinition folderDefinition;
            if (FolderDefinition::load(*settings, folderAlias, &folderDefinition)) {
                Folder* f = addFolderInternal(folderDefinition);
                if (f) {
                    f->setAccountState( account.data() );
                    slotScheduleSync(f);
                    emit folderSyncStateChange(f);
                }
            }
        }
        settings->endGroup(); // Folders
        settings->endGroup(); // <account>
    }

    emit folderListChanged(_folderMap);

    return _folderMap.size();
}
bool AccountManager::restore()
{
    auto settings = Account::settingsWithGroup(QLatin1String(accountsC));

    // If there are no accounts, check the old format.
    if (settings->childGroups().isEmpty()) {
        return restoreFromLegacySettings();
    }

    foreach (const auto& accountId, settings->childGroups()) {
        settings->beginGroup(accountId);
        if (auto acc = load(*settings)) {
            acc->_id = accountId;
            addAccount(acc);
        }
        settings->endGroup();
    }

    return true;
}
Exemple #6
0
int FolderMan::setupFolders()
{
    unloadAndDeleteAllFolders();

    auto settings = ConfigFile::settingsWithGroup(QLatin1String("Accounts"));
    const auto accountsWithSettings = settings->childGroups();
    if (accountsWithSettings.isEmpty()) {
        int r = setupFoldersMigration();
        if (r > 0) {
            AccountManager::instance()->save(false); // don't save credentials, they had not been loaded from keychain
        }
        return r;
    }

    qCInfo(lcFolderMan) << "Setup folders from settings file";

    foreach (const auto &account, AccountManager::instance()->accounts()) {
        const auto id = account->account()->id();
        if (!accountsWithSettings.contains(id)) {
            continue;
        }
        settings->beginGroup(id);

        settings->beginGroup(QLatin1String("Folders"));
        setupFoldersHelper(*settings, account, true);
        settings->endGroup();

        // See Folder::saveToSettings for details about why this exists.
        settings->beginGroup(QLatin1String("Multifolders"));
        setupFoldersHelper(*settings, account, false);
        settings->endGroup();

        settings->endGroup(); // <account>
    }

    emit folderListChanged(_folderMap);

    return _folderMap.size();
}
Exemple #7
0
bool AccountManager::restore()
{
    auto settings = Utility::settingsWithGroup(QLatin1String(accountsC));

    // If there are no accounts, check the old format.
    if (settings->childGroups().isEmpty()
            && !settings->contains(QLatin1String(versionC))) {
        return restoreFromLegacySettings();
    }

    foreach (const auto& accountId, settings->childGroups()) {
        settings->beginGroup(accountId);
        if (auto acc = loadAccountHelper(*settings)) {
            acc->_id = accountId;
            if (auto accState = AccountState::loadFromSettings(acc, *settings)) {
                addAccountState(accState);
            }
        }
        settings->endGroup();
    }

    return true;
}
Exemple #8
0
int BookmarkGroup::childCount() const
{
    //DEBUG_BLOCK
    return childGroups().count() + childBookmarks().count();
}
Exemple #9
0
QStringList UserSettings::getDatabaseList() {
	beginGroup("Database");
	QStringList children = childGroups();
	endGroup();
	return children;
}
Exemple #10
0
void
dvbcut_settings::save_settings() {
  setValue("/version", 2);	// latest config version
  beginGroup("/wheel");
    setValue("/incr_normal", wheel_increments[WHEEL_INCR_NORMAL]);
    setValue("/incr_shift", wheel_increments[WHEEL_INCR_SHIFT]);
    setValue("/incr_ctrl", wheel_increments[WHEEL_INCR_CTRL]);
    setValue("/incr_alt", wheel_increments[WHEEL_INCR_ALT]);
    setValue("/threshold", wheel_threshold);
    setValue("/delta", wheel_delta);
  endGroup();	// wheel
  beginGroup("/slider");
    setValue("/jog_maximum", jog_maximum);
    setValue("/jog_threshold", jog_threshold);
    setValue("/jog_offset", jog_offset);
    setValue("/jog_interval", jog_interval);
    setValue("/lin_interval", lin_interval);
  endGroup();	// slider
  beginGroup("/lastdir");
    setValue("/name", lastdir);
    setValue("/update", lastdir_update);
  endGroup();	// lastdir
  beginGroup("/viewscalefactor");
    setValue("/current", viewscalefactor);
    setValue("/custom", viewscalefactor_custom);
  endGroup();	// viewscalefactor
  setValue("/export_format", export_format);
  beginGroup("/recentfiles");
    // first remove any OLD recentfiles entries to clean the settings file (<revision 108)!!!
    QStringList keys = childKeys();
    for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) 
      remove("/" + *it);
    // then remove ALL new recentfiles entries!!!
    // (otherwise it would be a mess with erased&inserted muliple file entries of different size)
    QStringList subkeys = childGroups();
    for ( QStringList::Iterator its = subkeys.begin(); its != subkeys.end(); ++its ) {
      beginGroup("/" + *its);
      QStringList keys = childKeys();
      endGroup();
      for ( QStringList::Iterator itk = keys.begin(); itk != keys.end(); ++itk ) 
        remove("/"  + *its + "/" + *itk);
    }    
    setValue("/max", int(recentfiles_max));
    // and NOW write the updated list from scratch!!!
    for (unsigned int i = 0; i < recentfiles.size(); ++i) {
      QString key = "/" + QString::number(i);
      beginGroup(key);
        int j=0;
        for(std::list<std::string>::iterator it=settings().recentfiles[i].first.begin();
                                             it!=settings().recentfiles[i].first.end(); it++, j++) 
          setValue("/" + QString::number(j), it->c_str());
        setValue("/idx", recentfiles[i].second.c_str());
      endGroup();	// key
    }
  endGroup();	// recentfiles
  setValue("/start_bof", start_bof);
  setValue("/stop_eof", stop_eof);
  beginGroup("/snapshots");
    setValue("/type", snapshot_type);
    setValue("/quality", snapshot_quality);
    setValue("/prefix", snapshot_prefix);
    setValue("/delimiter", snapshot_delimiter);
    setValue("/first", snapshot_first);
    setValue("/width", snapshot_width);
    setValue("/extension", snapshot_extension);
    setValue("/range", snapshot_range);
    setValue("/samples", snapshot_samples);
  endGroup();	// snapshots
  beginGroup("/pipe");
    for (unsigned int i = 0; i < pipe_command.size(); ++i) {
      QString key = "/" + QString::number(i);
      beginGroup(key);
	setValue("/command", pipe_command[i]);
	setValue("/post", pipe_post[i]);
	setValue("/label", pipe_label[i]);
	setValue("/format", pipe_format[i]);
      endGroup();	// key
    }
  endGroup();	// pipe
  beginGroup("/chapters");
    setValue("/interval", chapter_interval);
    setValue("/tolerance", chapter_tolerance);
    setValue("/threshold", chapter_threshold);
    setValue("/minimum", chapter_minimum);
  endGroup();	// auto chapters
}
Exemple #11
0
void CWizSettings::GetSections(CWizStdStringArray& arrayAction)
{
    QStringList sl = childGroups();
    arrayAction.assign(sl.begin(), sl.end());
}
Exemple #12
0
QStringList ConfigHandler::getDatabaseList() {
    beginGroup("Database");
    QStringList children = childGroups();
    endGroup();
    return children;
}
bool Preferences::_loadOk()
{
    TestMode::Mode testMode;
    quint8 pingsPerHost;
    quint8 pingThreads;
    quint8 pingTimeoutSecs;
    quint8 downloadTestSecs;
    QString hostlistUrl;

    sync();

    if(!childGroups().contains("Preferences"))
    {
        return false;
    }

    beginGroup("Preferences");
    testMode = (TestMode::Mode) value("TestMode", 0).toUInt();

    if(!(testMode == TestMode::Info || testMode == TestMode::Ping || testMode == TestMode::Download || testMode == TestMode::All))
    {
        return false;
    }

    pingsPerHost = value("PingsPerHost", 0).toUInt();

    if(pingsPerHost < 1 || pingsPerHost > 10)
    {
        return false;
    }

    pingThreads = value("PingThreads", 0).toUInt();

    if(pingThreads < 1 || pingThreads > 8)
    {
        return false;
    }

    pingTimeoutSecs = value("PingTimeoutSecs", 0).toUInt();

    if(pingTimeoutSecs < 1 || pingTimeoutSecs > 4)
    {
        return false;
    }

    downloadTestSecs = value("DownloadTestSecs", 0).toUInt();

    if(downloadTestSecs < 5 || downloadTestSecs > 30)
    {
        return false;
    }

    hostlistUrl = value("HostlistUrl", QString("")).toString();

    if(hostlistUrl.isEmpty() || !QUrl(hostlistUrl).isValid())
    {
        return false;
    }

    // At this point, preferences INI file was valid. Load its preferences
    TESTMODE = testMode;
    PINGSPERHOST = pingsPerHost;
    PINGTHREADS = pingThreads;
    PINGTIMEOUTSECS = pingTimeoutSecs;
    DOWNLOADTESTSECS = downloadTestSecs;
    HOSTLISTURL = hostlistUrl;
    emit message(trUtf8("Loaded preferences from") + ' ' + QDir::toNativeSeparators(fileName()));

    return true;
}