Исправления:

- сброс поля пароля после удачного соединения с RDP
    - обязательное заполнения полей компьютера и пользователя
Обновление:
    - флаг компиляции WITH_COLOR_BUTTONS для цветных кнопок
This commit is contained in:
Alexander Zhirov 2023-02-02 08:47:23 +03:00
parent d500b341ab
commit c6471e47f9
4 changed files with 66 additions and 11 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
/Debug /Debug
/.settings /.settings
/.vscode
.project .project
.cproject .cproject

View File

@ -34,7 +34,6 @@ target_link_libraries(xfree
X11 X11
Xrandr Xrandr
m m
dl dl
pthread pthread
@ -42,3 +41,7 @@ target_link_libraries(xfree
/root/SQLite/sqlite3.a /root/SQLite/sqlite3.a
) )
#target_link_libraries(xfree iup X11 Xrandr m sqlite3 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lX11 -lXrandr -lm) #target_link_libraries(xfree iup X11 Xrandr m sqlite3 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lX11 -lXrandr -lm)
if(WITH_COLOR_BUTTONS)
add_definitions(-DWITH_COLOR_BUTTONS)
endif()

65
gui.c
View File

@ -25,14 +25,48 @@ static int guiExit(Ihandle *self)
return IUP_CLOSE; return IUP_CLOSE;
} }
int isEmptyFieldServerUser(Ihandle *self)
{
char *name = IupGetAttribute(self, "NAME");
if (!strcmp(name, "SERVER"))
return !strcmp(IupGetAttribute(IupGetDialogChild(self, "USER"), "LINEVALUE"), "\0");
else
return !strcmp(IupGetAttribute(IupGetDialogChild(self, "SERVER"), "VALUE"), "\0");
}
static int activeBtnConnect(Ihandle *self, int c, char *value)
{
if (!strcmp(value, "\0") || isEmptyFieldServerUser(self))
{
IupSetInt(IupGetDialogChild(self, "CONNECT"), "ACTIVE", 0);
#ifdef WITH_COLOR_BUTTONS
IupSetAttribute(IupGetDialogChild(self, "CONNECT"), "BGCOLOR", "49 54 61");
IupSetAttribute(IupGetDialogChild(self, "CONNECT"), "FGCOLOR", "238 238 238");
#endif
}
else
{
IupSetInt(IupGetDialogChild(self, "CONNECT"), "ACTIVE", 1);
#ifdef WITH_COLOR_BUTTONS
IupSetAttribute(IupGetDialogChild(self, "CONNECT"), "BGCOLOR", "0 179 0");
IupSetAttribute(IupGetDialogChild(self, "CONNECT"), "FGCOLOR", "255 255 255");
#endif
}
return IUP_DEFAULT;
}
static int guiConnect(Ihandle *self) static int guiConnect(Ihandle *self)
{ {
char *host = IupGetAttribute(IupGetDialogChild(self, "SERVER"), "VALUE"); char *host = IupGetAttribute(IupGetDialogChild(self, "SERVER"), "VALUE");
char *login = IupGetAttribute(IupGetDialogChild(self, "USER"), "LINEVALUE");
char *result = getHostIP(host); char *result = getHostIP(host);
if (!result) if (!result)
return IUP_DEFAULT; return IUP_IGNORE;
char *login = IupGetAttribute(IupGetDialogChild(self, "USER"), "LINEVALUE");
if (!strcmp(login, "\0"))
return IUP_IGNORE;
setParameterValue(PARAMETER_SERVER, VALUE_SERVER, result); setParameterValue(PARAMETER_SERVER, VALUE_SERVER, result);
setParameterValue(PARAMETER_USERNAME, VALUE_USERNAME, login); setParameterValue(PARAMETER_USERNAME, VALUE_USERNAME, login);
@ -45,16 +79,19 @@ static int guiConnect(Ihandle *self)
printf("%s\n", args.argv[i]); printf("%s\n", args.argv[i]);
} }
// if (free_rdp_connect(args.argc, args.argv) != XF_EXIT_DNS_NAME_NOT_FOUND) enum XF_EXIT_CODE xCode = free_rdp_connect(args.argc, args.argv);
// {
if (!(xCode == XF_EXIT_DNS_NAME_NOT_FOUND || xCode == XF_EXIT_CONNECT_FAILED || xCode == XF_EXIT_TLS_CONNECT_FAILED))
{
IupSetAttribute(IupGetDialogChild(self, "PASSWORD"), "VALUE", "");
if (!dbAddServer(result, host)) if (!dbAddServer(result, host))
{ {
dbInsertHistory(login, host);
IupSetAttribute(IupGetDialogChild(self, "SERVER"), "APPENDITEM", host); IupSetAttribute(IupGetDialogChild(self, "SERVER"), "APPENDITEM", host);
} }
dbInsertHistory(login, host);
dbSetUserNameCurrent(login); dbSetUserNameCurrent(login);
// } }
freeArguments(&args); freeArguments(&args);
@ -110,11 +147,13 @@ Ihandle* guiStart()
inputServer = IupList(NULL); inputServer = IupList(NULL);
IupSetAttribute(inputServer, "NAME", "SERVER"); IupSetAttribute(inputServer, "NAME", "SERVER");
IupSetAttribute(inputServer, "TIP", "IP-адрес или имя удаленного сервера (обязательно)"); IupSetAttribute(inputServer, "TIP", "IP-адрес или имя удаленного сервера\n(обязательное для заполнения поле)");
createHostsList(inputServer); createHostsList(inputServer);
IupSetAttribute(inputServer, "SIZE", "100"); IupSetAttribute(inputServer, "SIZE", "100");
IupSetAttribute(inputServer, "EDITBOX", "YES"); IupSetAttribute(inputServer, "EDITBOX", "YES");
IupSetAttribute(inputServer, "DROPDOWN", "YES"); IupSetAttribute(inputServer, "DROPDOWN", "YES");
IupSetAttribute(inputServer, "MASK", "[A-Za-z0-9/./-]*");
IupSetCallback(inputServer, "EDIT_CB", (Icallback) activeBtnConnect);
hBoxServer = IupHbox(labelServer, inputServer, NULL); hBoxServer = IupHbox(labelServer, inputServer, NULL);
IupSetAttribute(hBoxServer, "MARGIN", "10x10"); IupSetAttribute(hBoxServer, "MARGIN", "10x10");
@ -124,9 +163,11 @@ Ihandle* guiStart()
IupSetAttribute(labelUser, "PADDING", "5"); IupSetAttribute(labelUser, "PADDING", "5");
inputUser = IupText(NULL); inputUser = IupText(NULL);
IupSetAttribute(inputUser, "NAME", "USER"); IupSetAttribute(inputUser, "NAME", "USER");
IupSetAttribute(inputUser, "TIP", "<домен>\\<имя пользователя> (обязательно)"); IupSetAttribute(inputUser, "TIP", "<домен>\\<имя пользователя>\n<имя пользователя>@<домен>\n(обязательное для заполнения поле)")
IupSetAttribute(inputUser, "VALUE", getSetValueCurrent(PARAMETER_USERNAME)); IupSetAttribute(inputUser, "VALUE", getSetValueCurrent(PARAMETER_USERNAME));
IupSetAttribute(inputUser, "SIZE", "100"); IupSetAttribute(inputUser, "SIZE", "100");
IupSetAttribute(inputUser, "MASK", "(/w|[/./\\/@/-])*");
IupSetCallback(inputUser, "ACTION", (Icallback) activeBtnConnect);
hBoxUser = IupHbox(labelUser, inputUser, NULL); hBoxUser = IupHbox(labelUser, inputUser, NULL);
IupSetAttribute(hBoxUser, "MARGIN", "10x0"); IupSetAttribute(hBoxUser, "MARGIN", "10x0");
@ -147,21 +188,27 @@ Ihandle* guiStart()
IupSetHandle("CONNECT", btnConnect); IupSetHandle("CONNECT", btnConnect);
IupSetAttribute(btnConnect, "NAME", "CONNECT"); IupSetAttribute(btnConnect, "NAME", "CONNECT");
IupSetAttribute(btnConnect, "TIP", "Выполнить подключение"); IupSetAttribute(btnConnect, "TIP", "Выполнить подключение");
#ifdef WITH_COLOR_BUTTONS
IupSetAttribute(btnConnect, "BGCOLOR", "0 179 0"); IupSetAttribute(btnConnect, "BGCOLOR", "0 179 0");
IupSetAttribute(btnConnect, "FGCOLOR", "255 255 255"); IupSetAttribute(btnConnect, "FGCOLOR", "255 255 255");
#endif
btnClose = IupButton("Закрыть", NULL); btnClose = IupButton("Закрыть", NULL);
IupSetHandle("CLOSE", btnClose); IupSetHandle("CLOSE", btnClose);
IupSetAttribute(btnClose, "NAME", "CLOSE"); IupSetAttribute(btnClose, "NAME", "CLOSE");
IupSetAttribute(btnClose, "TIP", "Закрыть FreeRDP"); IupSetAttribute(btnClose, "TIP", "Закрыть FreeRDP");
#ifdef WITH_COLOR_BUTTONS
IupSetAttribute(btnClose, "BGCOLOR", "204 0 0"); IupSetAttribute(btnClose, "BGCOLOR", "204 0 0");
IupSetAttribute(btnClose, "FGCOLOR", "255 255 255"); IupSetAttribute(btnClose, "FGCOLOR", "255 255 255");
#endif
btnSettings = IupButton("Настройки", NULL); btnSettings = IupButton("Настройки", NULL);
IupSetAttribute(btnSettings, "NAME", "SETTINGS"); IupSetAttribute(btnSettings, "NAME", "SETTINGS");
IupSetAttribute(btnSettings, "TIP", "Перейти в настройки"); IupSetAttribute(btnSettings, "TIP", "Перейти в настройки");
#ifdef WITH_COLOR_BUTTONS
IupSetAttribute(btnSettings, "BGCOLOR", "0 136 204"); IupSetAttribute(btnSettings, "BGCOLOR", "0 136 204");
IupSetAttribute(btnSettings, "FGCOLOR", "255 255 255"); IupSetAttribute(btnSettings, "FGCOLOR", "255 255 255");
#endif
hBoxButtons = IupHbox(IupFill(), btnSettings, btnConnect, btnClose, IupFill(), NULL); hBoxButtons = IupHbox(IupFill(), btnSettings, btnConnect, btnClose, IupFill(), NULL);
IupSetAttribute(hBoxButtons, "ALIGNMENT", "ACENTER:ACENTER"); IupSetAttribute(hBoxButtons, "ALIGNMENT", "ACENTER:ACENTER");

View File

@ -368,14 +368,18 @@ static Ihandle* settingsHorizontalBoxButtons()
btnSave = IupButton("Сохранить", NULL); btnSave = IupButton("Сохранить", NULL);
IupSetAttribute(btnSave, "NAME", "SETTIGS_BTN_SAVE"); IupSetAttribute(btnSave, "NAME", "SETTIGS_BTN_SAVE");
IupSetAttribute(btnSave, "TIP", "Сохранить настройки"); IupSetAttribute(btnSave, "TIP", "Сохранить настройки");
#ifdef WITH_COLOR_BUTTONS
IupSetAttribute(btnSave, "BGCOLOR", "0 179 0"); IupSetAttribute(btnSave, "BGCOLOR", "0 179 0");
IupSetAttribute(btnSave, "FGCOLOR", "255 255 255"); IupSetAttribute(btnSave, "FGCOLOR", "255 255 255");
#endif
btnClose = IupButton("Закрыть", NULL); btnClose = IupButton("Закрыть", NULL);
IupSetAttribute(btnClose, "NAME", "SETTIGS_BTN_CLOSE"); IupSetAttribute(btnClose, "NAME", "SETTIGS_BTN_CLOSE");
IupSetAttribute(btnClose, "TIP", "Отменить изменения"); IupSetAttribute(btnClose, "TIP", "Отменить изменения");
#ifdef WITH_COLOR_BUTTONS
IupSetAttribute(btnClose, "BGCOLOR", "204 0 0"); IupSetAttribute(btnClose, "BGCOLOR", "204 0 0");
IupSetAttribute(btnClose, "FGCOLOR", "255 255 255"); IupSetAttribute(btnClose, "FGCOLOR", "255 255 255");
#endif
IupSetHandle("btnClosePointer", btnClose); IupSetHandle("btnClosePointer", btnClose);