aboutsummaryrefslogtreecommitdiff
path: root/src/TcpTasks/SyncClient/updatesyncedserver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/TcpTasks/SyncClient/updatesyncedserver.cpp')
-rw-r--r--src/TcpTasks/SyncClient/updatesyncedserver.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/TcpTasks/SyncClient/updatesyncedserver.cpp b/src/TcpTasks/SyncClient/updatesyncedserver.cpp
new file mode 100644
index 0000000..354c6a5
--- /dev/null
+++ b/src/TcpTasks/SyncClient/updatesyncedserver.cpp
@@ -0,0 +1,27 @@
+#include "syncclient.h"
+
+bool SyncClient::updateSyncedServer(const QString &serverAddress,
+ const unsigned short &serverPort)
+{
+ // update existing entry, but do not insert.
+ QSqlQuery q;
+ QString updateString;
+
+ // update with available values
+ updateString = "UPDATE serverlist SET "
+ "dt_sync = :timestamp "
+ "WHERE ip = :ip "
+ "AND queryport = :queryport";
+
+ // bind values and execute
+ q.prepare(updateString);
+ q.bindValue(":ip", serverAddress);
+ q.bindValue(":queryport", serverPort);
+ q.bindValue(":timestamp", QDateTime::currentSecsSinceEpoch() );
+
+ if ( ! q.exec() )
+ return reportQuery(q);
+
+ // was a row updated?
+ return (q.numRowsAffected() > 0);
+}