- return NetworkId();
- }
-
- {
- QSqlQuery insertServersQuery(db);
- insertServersQuery.prepare(queryString("insert_server"));
- foreach(Network::Server server, info.serverList) {
- insertServersQuery.bindValue(":userid", user.toInt());
- insertServersQuery.bindValue(":networkid", networkId.toInt());
- bindServerInfo(insertServersQuery, server);
- safeExec(insertServersQuery);
- if(!watchQuery(insertServersQuery)) {
- db.rollback();
- error = true;
- break;
- }
- }
- if(!error)
- db.commit();
- }
- unlock();
- if(error)
- return NetworkId();
- else
- return networkId;
-}
-
-void SqliteStorage::bindNetworkInfo(QSqlQuery &query, const NetworkInfo &info) {
- query.bindValue(":networkname", info.networkName);
- query.bindValue(":identityid", info.identity.toInt());
- query.bindValue(":encodingcodec", QString(info.codecForEncoding));
- query.bindValue(":decodingcodec", QString(info.codecForDecoding));
- query.bindValue(":servercodec", QString(info.codecForServer));
- query.bindValue(":userandomserver", info.useRandomServer ? 1 : 0);
- query.bindValue(":perform", info.perform.join("\n"));
- query.bindValue(":useautoidentify", info.useAutoIdentify ? 1 : 0);
- query.bindValue(":autoidentifyservice", info.autoIdentifyService);
- query.bindValue(":autoidentifypassword", info.autoIdentifyPassword);
- query.bindValue(":usesasl", info.useSasl ? 1 : 0);
- query.bindValue(":saslaccount", info.saslAccount);
- query.bindValue(":saslpassword", info.saslPassword);
- query.bindValue(":useautoreconnect", info.useAutoReconnect ? 1 : 0);
- query.bindValue(":autoreconnectinterval", info.autoReconnectInterval);
- query.bindValue(":autoreconnectretries", info.autoReconnectRetries);
- query.bindValue(":unlimitedconnectretries", info.unlimitedReconnectRetries ? 1 : 0);
- query.bindValue(":rejoinchannels", info.rejoinChannels ? 1 : 0);
- if(info.networkId.isValid())
- query.bindValue(":networkid", info.networkId.toInt());
-}
-
-void SqliteStorage::bindServerInfo(QSqlQuery &query, const Network::Server &server) {
- query.bindValue(":hostname", server.host);
- query.bindValue(":port", server.port);
- query.bindValue(":password", server.password);
- query.bindValue(":ssl", server.useSsl ? 1 : 0);
- query.bindValue(":sslversion", server.sslVersion);
- query.bindValue(":useproxy", server.useProxy ? 1 : 0);
- query.bindValue(":proxytype", server.proxyType);
- query.bindValue(":proxyhost", server.proxyHost);
- query.bindValue(":proxyport", server.proxyPort);
- query.bindValue(":proxyuser", server.proxyUser);
- query.bindValue(":proxypass", server.proxyPass);
-}
-
-bool SqliteStorage::updateNetwork(UserId user, const NetworkInfo &info) {
- QSqlDatabase db = logDb();
- bool error = false;
- db.transaction();
-
- {
- QSqlQuery updateQuery(db);
- updateQuery.prepare(queryString("update_network"));
- updateQuery.bindValue(":userid", user.toInt());
- bindNetworkInfo(updateQuery, info);