Исправлено дублирвоание для host записей, добавлены CMake-конфиги FreeRDP

This commit is contained in:
Alexander Zhirov 2022-08-05 16:21:27 +03:00
parent a5434746f5
commit 1514150672
2 changed files with 6 additions and 4 deletions

8
db.c
View File

@ -252,10 +252,11 @@ int dbAddServer(char *ip, char *dns)
} }
sqlite3_stmt *res; sqlite3_stmt *res;
char *sql = "SELECT * FROM `hosts` WHERE `ip` = ?"; char *sql = "SELECT * FROM `hosts` WHERE `ip` = ? OR `dns` = ?";
if (sqlite3_prepare_v2(db, sql, -1, &res, 0) == SQLITE_OK) if (sqlite3_prepare_v2(db, sql, -1, &res, 0) == SQLITE_OK)
{ {
sqlite3_bind_text(res, 1, ip, -1, 0); sqlite3_bind_text(res, 1, ip, -1, 0);
sqlite3_bind_text(res, 2, dns, -1, 0);
} }
else else
{ {
@ -272,12 +273,13 @@ int dbAddServer(char *ip, char *dns)
sql = "UPDATE `hosts` set `set` = 0"; sql = "UPDATE `hosts` set `set` = 0";
if (sqlite3_exec(db, sql, NULL, NULL, NULL) == SQLITE_OK) if (sqlite3_exec(db, sql, NULL, NULL, NULL) == SQLITE_OK)
{ {
sql = "UPDATE `hosts` set `dns` = ?, `set` = 1 where id = ?"; sql = "UPDATE `hosts` set `dns` = ?, `ip` = ?, `set` = 1 where id = ?";
if (sqlite3_prepare_v2(db, sql, -1, &res, 0) == SQLITE_OK) if (sqlite3_prepare_v2(db, sql, -1, &res, 0) == SQLITE_OK)
{ {
sqlite3_bind_text(res, 1, dns, -1, 0); sqlite3_bind_text(res, 1, dns, -1, 0);
sqlite3_bind_int(res, 2, id); sqlite3_bind_text(res, 2, ip, -1, 0);
sqlite3_bind_int(res, 3, id);
} }
if (sqlite3_step(res) == SQLITE_BUSY) if (sqlite3_step(res) == SQLITE_BUSY)

2
gui.c
View File

@ -47,9 +47,9 @@ static int guiConnect(Ihandle *self)
// if (free_rdp_connect(args.argc, args.argv) != XF_EXIT_DNS_NAME_NOT_FOUND) // if (free_rdp_connect(args.argc, args.argv) != XF_EXIT_DNS_NAME_NOT_FOUND)
// { // {
dbInsertHistory(login, host);
if (!dbAddServer(result, host)) if (!dbAddServer(result, host))
{ {
dbInsertHistory(login, host);
IupSetAttribute(IupGetDialogChild(self, "SERVER"), "APPENDITEM", host); IupSetAttribute(IupGetDialogChild(self, "SERVER"), "APPENDITEM", host);
} }
dbSetUserNameCurrent(login); dbSetUserNameCurrent(login);