bool Servatrice_DatabaseInterface::activateUser(const QString &userName, const QString &token) { if (!checkSql()) return false; QSqlQuery *activateQuery = prepareQuery("select name from {prefix}_users where active=0 and name=:username and token=:token"); activateQuery->bindValue(":username", userName); activateQuery->bindValue(":token", token); if (!execSqlQuery(activateQuery)) { qDebug() << "Account activation failed: SQL error." << activateQuery->lastError()<< " sql: " << activateQuery->lastQuery(); return false; } if (activateQuery->next()) { const QString name = activateQuery->value(0).toString(); // redundant check if(name == userName) { QSqlQuery *query = prepareQuery("update {prefix}_users set active=1 where name = :userName"); query->bindValue(":userName", userName); if (!execSqlQuery(query)) { qDebug() << "Failed to activate user: "******" sql: " << query->lastQuery(); return false; } return true; } } return false; }
int Library::addCategoriesToDb(const QList<FilePath>& dirs, const QString& tablename, const QString& id_rowname) throw (Exception) { int count = 0; foreach (const FilePath& filepath, dirs) { ElementType element(filepath); QSqlQuery query = prepareQuery( "INSERT INTO " % tablename % " " "(filepath, uuid, version, parent_uuid) VALUES " "(:filepath, :uuid, :version, :parent_uuid)"); query.bindValue(":filepath", filepath.toRelative(mLibPath)); query.bindValue(":uuid", element.getUuid().toStr()); query.bindValue(":version", element.getVersion().toStr()); query.bindValue(":parent_uuid", element.getParentUuid().isNull() ? QVariant(QVariant::String) : element.getParentUuid().toStr()); int id = execQuery(query, true); foreach (const QString& locale, element.getAllAvailableLocales()) { QSqlQuery query = prepareQuery( "INSERT INTO " % tablename % "_tr " "(" % id_rowname % ", locale, name, description, keywords) VALUES " "(:element_id, :locale, :name, :description, :keywords)"); query.bindValue(":element_id", id); query.bindValue(":locale", locale); query.bindValue(":name", element.getNames().value(locale)); query.bindValue(":description", element.getDescriptions().value(locale)); query.bindValue(":keywords", element.getKeywords().value(locale)); execQuery(query, false); } count++; }
bool CChangeJavaFunctionPermissionsAction::ActionPerformed(symbolPtr* pSym) { CImpactAction::ActionPerformed(pSym); Boolean bAbstract = XmToggleButtonGadgetGetState(m_abstractInd); string szAbstract = (bAbstract?"1":"0"); Boolean bStatic = XmToggleButtonGadgetGetState(m_staticInd); string szStatic = (bStatic?"1":"0"); Boolean bFinal = XmToggleButtonGadgetGetState(m_finalInd); string szFinal = (bFinal?"1":"0"); Boolean bNative = XmToggleButtonGadgetGetState(m_nativeInd); string szNative = (bNative?"1":"0"); char strPerm[10]; sprintf(strPerm,"%d", m_nPermission); string command = "Impact:ChangeJavaFunctionDeclaration " + prepareQuery(CEntityInfo::etag(pSym)) + " " + strPerm + " " + szAbstract + " " + szFinal + " " + szStatic + " " + szNative; string szDesc = GetName()+" to "; if(bAbstract) szDesc += " abstract"; if(bFinal) szDesc += " final"; if(bStatic) szDesc += " static"; if(bNative) szDesc += " native"; if(m_nPermission==PUBLIC) szDesc += " public"; else if(m_nPermission==PRIVATE) szDesc += " private"; else if(m_nPermission==PROTECTED) szDesc += " protected"; SetDescription(szDesc); string results; CEntityInfo::exec(command,results); parseResult(results); return true; }
bool Servatrice_DatabaseInterface::checkUserIsIpBanned(const QString &ipAddress, QString &banReason, int &banSecondsRemaining) { QSqlQuery *ipBanQuery = prepareQuery( "select" " timestampdiff(second, now(), date_add(b.time_from, interval b.minutes minute))," " b.minutes <=> 0," " b.visible_reason" " from {prefix}_bans b" " where" " b.time_from = (select max(c.time_from)" " from {prefix}_bans c" " where c.ip_address = :address)" " and b.ip_address = :address2"); ipBanQuery->bindValue(":address", ipAddress); ipBanQuery->bindValue(":address2", ipAddress); if (!execSqlQuery(ipBanQuery)) { qDebug() << "IP ban check failed: SQL error." << ipBanQuery->lastError(); return false; } if (ipBanQuery->next()) { const int secondsLeft = ipBanQuery->value(0).toInt(); const bool permanentBan = ipBanQuery->value(1).toInt(); if ((secondsLeft > 0) || permanentBan) { banReason = ipBanQuery->value(2).toString(); banSecondsRemaining = permanentBan ? 0 : secondsLeft; qDebug() << "User is banned by address" << ipAddress; return true; } } return false; }
void AnagraficaAddDialog::save(void) { //Effettua diversi controlli per verificare che i dati nel dialog //siano stati inseriti, se tutti i controlli vengono passati esegue //la query. qDebug() << "AnagraficaAddDialog::save()"; prepareMap(m_mapPersona, int(modelCols::id)); if (!checkValues()) return; QSqlQuery query = prepareQuery(); if (!query.exec()) { if (m_mapPersona.contains(ph::ID)) showDialogError(this, ERR011, MSG005, query.lastError().text()); //NOTE codice errore 011 else showDialogError(this, ERR025, MSG002, query.lastError().text()); //NOTE codice errore 025 return; } while (query.next()) setId(query.value("id").toString()); this->accept(); }
bool Servatrice_DatabaseInterface::registerUser(const QString &userName, const QString &realName, ServerInfo_User_Gender const &gender, const QString &password, const QString &emailAddress, const QString &country, QString &token, bool active) { if (!checkSql()) return false; QString passwordSha512 = PasswordHasher::computeHash(password, PasswordHasher::generateRandomSalt()); token = active ? QString() : PasswordHasher::generateActivationToken(); QSqlQuery *query = prepareQuery("insert into {prefix}_users " "(name, realname, gender, password_sha512, email, country, registrationDate, active, token) " "values " "(:userName, :realName, :gender, :password_sha512, :email, :country, UTC_TIMESTAMP(), :active, :token)"); query->bindValue(":userName", userName); query->bindValue(":realName", realName); query->bindValue(":gender", getGenderChar(gender)); query->bindValue(":password_sha512", passwordSha512); query->bindValue(":email", emailAddress); query->bindValue(":country", country); query->bindValue(":active", active ? 1 : 0); query->bindValue(":token", token); if (!execSqlQuery(query)) { qDebug() << "Failed to insert user: "******" sql: " << query->lastQuery(); return false; } return true; }
QList<ServerInfo_Warning> Servatrice_DatabaseInterface::getUserWarnHistory(const QString userName) { QList<ServerInfo_Warning> results; ServerInfo_Warning warnDetails; if (!checkSql()) return results; int userID = getUserIdInDB(userName); QSqlQuery *query = prepareQuery("SELECT user_name, mod_name, reason, time_of FROM {prefix}_warnings WHERE user_id = :user_id"); query->bindValue(":user_id", userID); if (!execSqlQuery(query)) { qDebug("Failed to collect warning history information: SQL Error"); return results; } while (query->next()){ warnDetails.set_user_name(QString(query->value(0).toString()).toStdString()); warnDetails.set_admin_name(QString(query->value(1).toString()).toStdString()); warnDetails.set_reason(QString(query->value(2).toString()).toStdString()); warnDetails.set_time_of(QString(query->value(3).toString()).toStdString()); results << warnDetails; } return results; }
bool CChangeCPPFieldPermissionsAction::ActionPerformed(symbolPtr* pSym) { CImpactAction::ActionPerformed(pSym); Boolean bStatic = XmToggleButtonGadgetGetState(m_staticInd); string szStatic = (bStatic?"1":"0"); Boolean bConst = XmToggleButtonGadgetGetState(m_constInd); string szConst = (bConst?"1":"0"); char strPerm[10]; sprintf(strPerm,"%d", m_nPermission); string command = "Impact:ChangeCPPFieldDeclaration " + prepareQuery(CEntityInfo::etag(pSym)) + " " + strPerm + " " + szConst + " " + szStatic; string szDesc = GetName()+" to "; if(bConst) szDesc += " const"; if(bStatic) szDesc += " static"; if(m_nPermission==PUBLIC) szDesc += " public"; else if(m_nPermission==PRIVATE) szDesc += " private"; else if(m_nPermission==PROTECTED) szDesc += " protected"; SetDescription(szDesc); string results; CEntityInfo::exec(command,results); parseResult(results); return true; }
QList<ServerInfo_Ban> Servatrice_DatabaseInterface::getUserBanHistory(const QString userName) { QList<ServerInfo_Ban> results; ServerInfo_Ban banDetails; if (!checkSql()) return results; QSqlQuery *query = prepareQuery("SELECT A.id_admin, A.time_from, A.minutes, A.reason, A.visible_reason, B.name AS name_admin FROM {prefix}_bans A LEFT JOIN {prefix}_users B ON A.id_admin=B.id WHERE A.user_name = :user_name"); query->bindValue(":user_name", userName); if (!execSqlQuery(query)) { qDebug("Failed to collect ban history information: SQL Error"); return results; } while (query->next()){ banDetails.set_admin_id(QString(query->value(0).toString()).toStdString()); banDetails.set_admin_name(QString(query->value(5).toString()).toStdString()); banDetails.set_ban_time(QString(query->value(1).toString()).toStdString()); banDetails.set_ban_length(QString(query->value(2).toString()).toStdString()); banDetails.set_ban_reason(QString(query->value(3).toString()).toStdString()); banDetails.set_visible_reason(QString(query->value(4).toString()).toStdString()); results << banDetails; } return results; }
bool CAddFieldAction::ActionPerformed(symbolPtr* pSym) { CImpactAction::ActionPerformed(pSym); string name; string type; char* text = XmTextGetString(m_nameField); name = text; XtFree(text); text = XmTextGetString(m_typeField); type = text; XtFree(text); string szDesc = GetName(); if(m_nPermission==PUBLIC) szDesc += " public"; else if(m_nPermission==PRIVATE) szDesc += " private"; else if(m_nPermission==PROTECTED) szDesc += " protected"; szDesc = " " + type + " " + name; SetDescription(szDesc); string command = "Impact:AddVariable " + prepareQuery(CEntityInfo::etag(pSym)) + " " + "{" + type + "}" + " " + name + " "; char strPerm[10]; sprintf(strPerm,"%d", m_nPermission); command += strPerm; string results; CEntityInfo::exec(command,results); parseResult(results); return true; }
void Servatrice_DatabaseInterface::clearSessionTables() { lockSessionTables(); QSqlQuery *query = prepareQuery("update {prefix}_sessions set end_time=now() where end_time is null and id_server = :id_server"); query->bindValue(":id_server", server->getServerID()); execSqlQuery(query); unlockSessionTables(); }
bool FaceIDQuery::exec(SQLiteDBConnection *sqlConn) { clear(); stringstream querySStr; prepareQuery(sqlConn,querySStr); _query = querySStr.str(); sqlConn->exec(_query,this); return true; }
void Servatrice_DatabaseInterface::endSession(qint64 sessionId) { if (server->getAuthenticationMethod() == Servatrice::AuthenticationNone) return; if (!checkSql()) return; QSqlQuery *query = prepareQuery("lock tables {prefix}_sessions write"); execSqlQuery(query); query = prepareQuery("update {prefix}_sessions set end_time=NOW() where id = :id_session"); query->bindValue(":id_session", sessionId); execSqlQuery(query); query = prepareQuery("unlock tables"); execSqlQuery(query); }
string CEntityInfo::getRenameCommand(symbolPtr* pSym,string newname) { string command; string selectTag = prepareQuery(etag(pSym)); string permissionCode = "1"; if(IsPublic(pSym)) permissionCode = "0"; else if(IsProtected(pSym)) permissionCode = "2"; else if(IsPrivate(pSym)) permissionCode = "3"; switch(pSym->get_kind()) { case DD_MODULE: command="Impact:ChangeFilename " + selectTag + " {" + newname + "}"; break; case DD_INTERFACE: case DD_CLASS: command = "Impact:ChangeClassname " + selectTag + " {" + newname + "}"; break; case DD_ENUM: case DD_UNION: command = "Impact:ChangeUnionEnumStructName " + selectTag + " {" + newname + "}"; break; case DD_FIELD: command = "Impact:ChangeFieldName " + selectTag + " {" + newname + "} " + permissionCode; break; case DD_FUNC_DECL: command = "Impact:ChangeFunctionName " + selectTag + " {" + newname + "}"; break; case DD_TYPEDEF: command = "Impact:ChangeTypedefName " + selectTag + " {" + newname + "}"; break; case DD_MACRO: command = "Impact:ChangeMacroName " + selectTag + " {" + newname + "}"; break; case DD_TEMPLATE: command = "Impact:ChangeTemplateName " + selectTag + " {" + newname + "}"; break; case DD_VAR_DECL: command = "Impact:ChangeVariableName " + selectTag + " {" + newname + "}"; break; case DD_PACKAGE: command ="Impact:RenamePackage " + selectTag + " { " + newname + "}"; } return command; }
bool Servatrice_DatabaseInterface::userSessionExists(const QString &userName) { // Call only after lockSessionTables(). QSqlQuery *query = prepareQuery("select 1 from {prefix}_sessions where user_name = :user_name and id_server = :id_server and end_time is null"); query->bindValue(":id_server", server->getServerID()); query->bindValue(":user_name", userName); execSqlQuery(query); return query->next(); }
int Servatrice_DatabaseInterface::getNextReplayId() { if (!checkSql()) return -1; QSqlQuery *query = prepareQuery("insert into {prefix}_replays (id_game) values (NULL)"); execSqlQuery(query); return query->lastInsertId().toInt(); }
void AnagraficaAddDialog::save(void) { //Effettua diversi controlli per verificare che i dati nel dialog //siano stati inseriti, se tutti i controlli vengono passati esegue //la query. qDebug() << "AnagraficaAddDialog::save()"; prepareMap(); if (mapPersona[anagrafica::PH_RAG_SOCIALE].isEmpty()) { showDialogError(this, ERR020, MSG016); //NOTE codice errore 020 ui->le_rag_sociale->setStyleSheet(anagrafica::CSS_WARNING_STYLE); return; } else if (mapPersona[anagrafica::PH_CLIENTE] == "n" && mapPersona[anagrafica::PH_FORNITORE] == "n") { showDialogError(this, ERR021, MSG017); //NOTE codice errore 021 ui->cliente_cb->setStyleSheet(anagrafica::CSS_WARNING_STYLE); ui->fornitore_cb->setStyleSheet(anagrafica::CSS_WARNING_STYLE); return; } else if (mapPersona[anagrafica::PH_COD_FISCALE].isEmpty() || mapPersona[anagrafica::PH_PRT_IVA].isEmpty()) { showDialogError(this, ERR022, MSG018); //NOTE codice errore 022 ui->le_cod_fiscale->setStyleSheet(anagrafica::CSS_WARNING_STYLE); ui->le_piva->setStyleSheet(anagrafica::CSS_WARNING_STYLE); return; } if (!controlloPartitaIva(mapPersona[anagrafica::PH_PRT_IVA])) { if (!showDialogWarning(this, ERR023, MSG019)) //NOTE codice errore 023 return; } if (mapPersona[anagrafica::PH_COD_FISCALE] != mapPersona[anagrafica::PH_PRT_IVA]) { if (!controlloCodiceFiscale(mapPersona[anagrafica::PH_COD_FISCALE])) { if (!showDialogWarning(this, ERR024, MSG020)) //NOTE codice errore 024 return; } } QSqlQuery query = prepareQuery(); if (!query.exec()) { if (mapPersona.contains(anagrafica::PH_ID)) { showDialogError(this, ERR011, MSG005, query.lastError().text()); //NOTE codice errore 011 } else { showDialogError(this, ERR025, MSG002, query.lastError().text()); //NOTE codice errore 025 } return; } this->accept(); }
void Servatrice_DatabaseInterface::updateUsersLastLoginData(const QString &userName, const QString &clientVersion) { if (!checkSql()) return; int usersID; QSqlQuery *query = prepareQuery("select id from {prefix}_users where name = :user_name"); query->bindValue(":user_name", userName); if (!execSqlQuery(query)) { qDebug("Failed to locate user id when updating users last login data: SQL Error"); return; } if (query->next()) { usersID = query->value(0).toInt(); } if (usersID) { int userCount; query = prepareQuery("select count(id) from {prefix}_user_analytics where id = :user_id"); query->bindValue(":user_id", usersID); if (!execSqlQuery(query)) return; if (query->next()) { userCount = query->value(0).toInt(); } if (!userCount) { query = prepareQuery("insert into {prefix}_user_analytics (id,client_ver,last_login) values (:user_id,:client_ver,NOW())"); query->bindValue(":user_id", usersID); query->bindValue(":client_ver", clientVersion); execSqlQuery(query); } else { query = prepareQuery("update {prefix}_user_analytics set last_login = NOW(), client_ver = :client_ver where id = :user_id"); query->bindValue(":client_ver", clientVersion); query->bindValue(":user_id", usersID); execSqlQuery(query); } } }
void Servatrice_DatabaseInterface::updateUsersClientID(const QString &userName, const QString &userClientID) { if (!checkSql()) return; QSqlQuery *query = prepareQuery("update {prefix}_users set clientid = :clientid where name = :username"); query->bindValue(":clientid", userClientID); query->bindValue(":username", userName); execSqlQuery(query); }
bool DB::save(const std::string& table,int& pk,const std::vector<VAttr*>& attrs) { const unsigned int size = attrs.size(); if(size > 0) { std::string str_q = "INSERT INTO "+escapeColumn(table)+"("+attrs[0]->column; for(unsigned int i=1;i<size;++i) str_q+=","+attrs[i]->column; str_q+=") "; str_q+="VALUES ((?)"; for(unsigned int i=1;i<size;++i) str_q+=",(?)"; str_q+=");"; #if ORM_DEBUG & ORM_DEBUG_SQL std::cerr<<BLEU<<"[Sql:insert] "<<str_q<<"\nVALUES = ("; #endif Query& q = *prepareQuery(str_q); for(unsigned int i=0;i<size;++i) { //prepare the field attrs[i]->before_save(); #if ORM_DEBUG & ORM_DEBUG_SQL std::cerr<<","<<*attrs[i]; #endif attrs[i]->set(q,i+1); attrs[i]->modify = false; //post save attrs[i]->after_save(); } #if ORM_DEBUG & ORM_DEBUG_SQL std::cerr<<")"<<std::endl; #endif q.execute(); q.next(); delete &q; pk = getLastInsertPk(); #if ORM_DEBUG & ORM_DEBUG_SQL std::cerr<<JAUNE<<"new PK: "<<pk<<" in table "<<table<<BLANC<<std::endl; #endif return true; } return -1; };
bool Servatrice_DatabaseInterface::userExists(const QString &user) { if (server->getAuthenticationMethod() == Servatrice::AuthenticationSql) { checkSql(); QSqlQuery *query = prepareQuery("select 1 from {prefix}_users where name = :name"); query->bindValue(":name", user); if (!execSqlQuery(query)) return false; return query->next(); } return false; }
int Servatrice_DatabaseInterface::getUserIdInDB(const QString &name) { if (server->getAuthenticationMethod() == Servatrice::AuthenticationSql) { QSqlQuery *query = prepareQuery("select id from {prefix}_users where name = :name and active = 1"); query->bindValue(":name", name); if (!execSqlQuery(query)) return -1; if (!query->next()) return -1; return query->value(0).toInt(); } return -1; }
int Servatrice_DatabaseInterface::getNextGameId() { if (!sqlDatabase.isValid()) return server->getNextLocalGameId(); if (!checkSql()) return -1; QSqlQuery *query = prepareQuery("insert into {prefix}_games (time_started) values (now())"); execSqlQuery(query); return query->lastInsertId().toInt(); }
AuthenticationResult Servatrice_DatabaseInterface::checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, const QString &clientId, QString &reasonStr, int &banSecondsLeft) { switch (server->getAuthenticationMethod()) { case Servatrice::AuthenticationNone: return UnknownUser; case Servatrice::AuthenticationPassword: { QString configPassword = settingsCache->value("authentication/password").toString(); if (configPassword == password) return PasswordRight; return NotLoggedIn; } case Servatrice::AuthenticationSql: { if (!checkSql()) return UnknownUser; if (!usernameIsValid(user, reasonStr)) return UsernameInvalid; if (checkUserIsBanned(handler->getAddress(), user, clientId, reasonStr, banSecondsLeft)) return UserIsBanned; QSqlQuery *passwordQuery = prepareQuery("select password_sha512, active from {prefix}_users where name = :name"); passwordQuery->bindValue(":name", user); if (!execSqlQuery(passwordQuery)) { qDebug("Login denied: SQL error"); return NotLoggedIn; } if (passwordQuery->next()) { const QString correctPassword = passwordQuery->value(0).toString(); const bool userIsActive = passwordQuery->value(1).toBool(); if(!userIsActive) { qDebug("Login denied: user not active"); return UserIsInactive; } if (correctPassword == PasswordHasher::computeHash(password, correctPassword.left(16))) { qDebug("Login accepted: password right"); return PasswordRight; } else { qDebug("Login denied: password wrong"); return NotLoggedIn; } } else { qDebug("Login accepted: unknown user"); return UnknownUser; } } } return UnknownUser; }
bool Servatrice_DatabaseInterface::changeUserPassword(const QString &user, const QString &oldPassword, const QString &newPassword) { if(server->getAuthenticationMethod() != Servatrice::AuthenticationSql) return true; if (!checkSql()) return true; QString error; if (!usernameIsValid(user, error)) return true; QSqlQuery *passwordQuery = prepareQuery("select password_sha512 from {prefix}_users where name = :name"); passwordQuery->bindValue(":name", user); if (!execSqlQuery(passwordQuery)) { qDebug("Change password denied: SQL error"); return true; } if (!passwordQuery->next()) return true; const QString correctPassword = passwordQuery->value(0).toString(); if (correctPassword != PasswordHasher::computeHash(oldPassword, correctPassword.left(16))) return true; QString passwordSha512 = PasswordHasher::computeHash(newPassword, PasswordHasher::generateRandomSalt()); passwordQuery = prepareQuery("update {prefix}_users set password_sha512=:password where name = :name"); passwordQuery->bindValue(":password", passwordSha512); passwordQuery->bindValue(":name", user); if (!execSqlQuery(passwordQuery)) { qDebug("Change password denied: SQL error"); return true; } return false; }
bool DB::del(const std::string& table,const int& pk) { std::string str_q = "DELETE FROM "+escapeColumn(table)+" WHERE ("+escapeColumn(table)+"."+escapeColumn("pk")+" = "+std::to_string(pk)+");"; #if ORM_DEBUG & ORM_DEBUG_SQL std::cerr<<COMMENTAIRE<<"[Sql:delete]"<<str_q<<BLANC<<std::endl; #endif Query* q = prepareQuery(str_q); q->execute(); q->next(); delete q; return true; };
DeckList *Servatrice_DatabaseInterface::getDeckFromDatabase(int deckId, int userId) { checkSql(); QSqlQuery *query = prepareQuery("select content from {prefix}_decklist_files where id = :id and id_user = :id_user"); query->bindValue(":id", deckId); query->bindValue(":id_user", userId); execSqlQuery(query); if (!query->next()) throw Response::RespNameNotFound; DeckList *deck = new DeckList; deck->loadFromString_Native(query->value(0).toString()); return deck; }
string CEntityInfo::getChangeBodyCommand(symbolPtr* pSym) { string command; string selectTag = prepareQuery(etag(pSym)); switch(pSym->get_kind()) { case DD_FUNC_DECL: command = "Impact:ChangeFunctionBody " + selectTag; break; case DD_MACRO: command = "Impact:ChangeMacroBody " + selectTag; break; case DD_TEMPLATE: command = "Impact:ChangeTemplateBody " + selectTag; break; } return command; }
// ------------------------------------------------------------------------------------------------- int processSQLQueries(const std::string & query, const aq::Settings & settingsBase, const std::string queryIdent, aq::Base & baseDesc, bool simulateAQEngine, bool keepFiles, bool force) { aq::Logger::getInstance().log(AQ_INFO, "%s\n", query.c_str()); aq::Timer timer; // // Settings aq::Settings settings(settingsBase); // // Load AQ engine aq::AQEngine_Intf * aq_engine; if (simulateAQEngine) { aq::Logger::getInstance().log(AQ_INFO, "Do not use aq engine\n"); aq_engine = new aq::AQEngineSimulate(baseDesc, settings); } else { aq::Logger::getInstance().log(AQ_INFO, "Use aq engine: '%s'\n", settings.aqEngine.c_str()); aq_engine = new aq::AQEngineSystem(baseDesc, settings); } // // prepare and process query std::string answer; if (!((prepareQuery(query, settingsBase, baseDesc, settings, answer, queryIdent, force) == EXIT_SUCCESS) && (processQuery(query, settings, baseDesc, aq_engine, answer, keepFiles) == EXIT_SUCCESS))) { aq::Logger::getInstance().log(AQ_DEBUG, "QUERY FAILED:\n%s\n", query.c_str()); } else { aq::Logger::getInstance().log(AQ_NOTICE, "Query Time elapsed: %s\n", aq::Timer::getString(timer.getTimeElapsed()).c_str()); } return EXIT_SUCCESS; }
bool DataStorage::checkDbVersion() { QSqlQuery query=prepareQuery("SELECT value FROM version WHERE name=? LIMIT 1"); query.addBindValue("dbversion"); if (!query.exec() || !query.next()) { qDebug() << "Unable to query for database version: " << query.lastError().text(); return false; } int version=query.value(0).toInt(); if (version!=GLUXI_DB_VERSION) { qDebug() << "Database version mismatch: this version of GluxiBot require " "version" << GLUXI_DB_VERSION << " however your database version is" << version; return false; } return true; }