shared_ptr<Book> BooksDBUtil::getBook(const std::string &filePath, bool checkFile) {
	const std::string physicalFilePath = ZLFile(filePath).physicalFilePath();

	ZLFile file(physicalFilePath);
	if (checkFile && !file.exists()) {
		return 0;
	}

	if (!checkFile || checkInfo(file)) {
		shared_ptr<Book> book = loadFromDB(filePath);
		if (!book.isNull() && isBookFull(*book)) {
			return book;
		}
	} else {
		if (physicalFilePath != filePath) {
			resetZipInfo(file);
		}
		saveInfo(file);
	}

	shared_ptr<Book> book = Book::loadFromFile(filePath);
	if (book.isNull()) {
		return 0;
	}
	BooksDB::Instance().saveBook(book);
	return book;
}
示例#2
0
void Antispam::loadConfig()
{
    loadFromDB(); // temporary solution for reload from game

    m_enabled = sAcConfig.getConfig(CONFIG_BOOL_AC_ANTISPAM_ENABLED);
    m_restrictionLevel = sAcConfig.getConfig(CONFIG_UINT32_AC_ANTISPAM_MAX_RESTRICTION_LEVEL);
    m_originalNormalizeMask = sAcConfig.getConfig(CONFIG_UINT32_AC_ANTISPAM_ORIGINAL_NORMALIZE_MASK);
    m_fullyNormalizeMask = sAcConfig.getConfig(CONFIG_UINT32_AC_ANTISPAM_FULLY_NORMALIZE_MASK);
    m_threshold = sAcConfig.getConfig(CONFIG_UINT32_AC_ANTISPAM_SCORE_THRESHOLD);
    m_mutetime = sAcConfig.getConfig(CONFIG_UINT32_AC_ANTISPAM_MUTETIME);
    m_chatMask = sAcConfig.getConfig(CONFIG_UINT32_AC_ANTISPAM_CHAT_MASK);

    m_mergeAllWhispers = sAcConfig.getConfig(CONFIG_BOOL_AC_ANTISPAM_MERGE_ALL_WHISPERS);
    m_banEnabled = sAcConfig.getConfig(CONFIG_BOOL_AC_ANTISPAM_BAN_ENABLED);
    m_detectThreshold = sAcConfig.getConfig(CONFIG_UINT32_AC_ANTISPAM_DETECT_THRESHOLD);
    m_messageRepeatCount = sAcConfig.getConfig(CONFIG_UINT32_AC_ANTISPAM_REPEAT_COUNT);
    m_updateTimer = sAcConfig.getConfig(CONFIG_UINT32_AC_ANTISPAM_UPDATE_TIMER);
    m_messageBlockSize = sAcConfig.getConfig(CONFIG_UINT32_AC_ANTISPAM_MESSAGE_BLOCK_SIZE);
    m_frequencyTime = sAcConfig.getConfig(CONFIG_UINT32_AC_ANTISPAM_FREQUENCY_TIME);
    m_frequencyCount = sAcConfig.getConfig(CONFIG_UINT32_AC_ANTISPAM_FREQUENCY_COUNT);
    m_frequencyCoeff = m_frequencyCount / m_frequencyTime;

    if (!m_worker)
        m_worker = new ACE_Based::Thread(new AntispamAsyncWorker(this));
}
int MirandaSkinnedDialog::compile()
{
	int ret = SkinnedDialog::compile();

	if (ret == 2)
	{
		SkinOptions * opts = getOpts();
		_ASSERT(opts != NULL);
		
		for(unsigned int i = 0; i < opts->getNumOptions(); ++i)
		{
			SkinOption *opt = opts->getOption(i);
			loadFromDB(opt);
			opt->setOnChangeCallback(&staticOnOptionChange, this);
		}

		for(unsigned int i = 0; i < getFieldCount(); ++i)
		{
			MirandaField *field = dynamic_cast<MirandaField *>(getField(i));
			field->configure();
		}

		fireOnSkinChanged();
	}

	return ret;
}
示例#4
0
void SourceDirTableModel::addSourceDir(QString dirpath, int pattern, int customPattern = 0)
{
    layoutAboutToBeChanged();
    QSqlQuery query;
    query.exec("INSERT INTO sourceDirs (path,pattern,custompattern) VALUES('" + dirpath + "'," + QString::number(pattern) + "," + QString::number(customPattern) + ")");
    loadFromDB();
    layoutChanged();
}
示例#5
0
void SourceDirTableModel::delSourceDir(int index)
{
    int dbid = mydata->at(index)->getIndex();
    QSqlQuery query;
    query.exec("DELETE FROM sourceDirs WHERE ROWID == " + QString::number(dbid));
    layoutAboutToBeChanged();
    loadFromDB();
    layoutChanged();
}
示例#6
0
CustomPatternsModel::CustomPatternsModel(QObject *parent)
    : QAbstractTableModel(parent)
{
    loadFromDB();
}