diff --git a/Makefile b/Makefile index 70b5bf8..65d11d6 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # Generated by qmake (3.1) (Qt 5.15.7) # Project: RsyncUI.pro # Template: app -# Command: /usr/lib64/qt5/bin/qmake -o Makefile RsyncUI.pro -spec linux-g++ +# Command: /usr/bin/qmake-qt5 -o Makefile RsyncUI.pro ############################################################################# MAKEFILE = Makefile @@ -14,11 +14,11 @@ EQ = = CC = gcc CXX = g++ -DEFINES = -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_XML_LIB -DQT_DBUS_LIB -DQT_CORE_LIB +DEFINES = -DQT_DISABLE_DEPRECATED_BEFORE=0x060000 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB CFLAGS = -pipe -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fno-strict-aliasing -DPIC -fPIC -Wall -Wextra -D_REENTRANT -fPIC $(DEFINES) CXXFLAGS = -pipe -std=gnu++0x -O2 -g -pipe -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -fasynchronous-unwind-tables -fno-strict-aliasing -DPIC -fPIC -std=gnu++1z -Wall -Wextra -D_REENTRANT -fPIC $(DEFINES) -INCPATH = -I. -I/usr/include/KF5 -I/usr/include/qt5keychain -I/usr/include/KF5/KItemViews -I/usr/include/KF5/KCompletion -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/KF5/KConfigGui -I/usr/include/qt5/QtGui -I/usr/include/KF5/KConfig -I/usr/include/KF5/KConfigCore -I/usr/include/qt5/QtXml -I/usr/include/KF5/KCoreAddons -I/usr/include/KF5/KDBusAddons -I/usr/include/qt5/QtDBus -I/usr/include/qt5/QtCore -I. -I. -I/usr/lib64/qt5/mkspecs/linux-g++ -QMAKE = /usr/lib64/qt5/bin/qmake +INCPATH = -I. -I/usr/include/KF5 -I/usr/include/qt5keychain -I/usr/include/KF5/KItemViews -I/usr/include/KF5/KCompletion -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I. -I. -I/usr/lib64/qt5/mkspecs/linux-g++ +QMAKE = /usr/bin/qmake-qt5 DEL_FILE = rm -f CHK_DIR_EXISTS= test -d MKDIR = mkdir -p @@ -28,8 +28,8 @@ COPY_DIR = cp -f -R INSTALL_FILE = install -m 644 -p INSTALL_PROGRAM = install -m 755 -p INSTALL_DIR = cp -f -R -QINSTALL = /usr/lib64/qt5/bin/qmake -install qinstall -QINSTALL_PROGRAM = /usr/lib64/qt5/bin/qmake -install qinstall -exe +QINSTALL = /usr/bin/qmake-qt5 -install qinstall +QINSTALL_PROGRAM = /usr/bin/qmake-qt5 -install qinstall -exe DEL_FILE = rm -f SYMLINK = ln -f -s DEL_DIR = rmdir @@ -40,7 +40,7 @@ DISTNAME = RsyncUI1.0.0 DISTDIR = /home/daniel/develop/RsyncUI/.tmp/RsyncUI1.0.0 LINK = g++ LFLAGS = -Wl,-O1 -LIBS = $(SUBLIBS) -lqt5keychain /usr/lib64/libKF5ItemViews.so /usr/lib64/libKF5Completion.so /usr/lib64/libQt5Widgets.so /usr/lib64/libKF5ConfigGui.so /usr/lib64/libQt5Gui.so /usr/lib64/libKF5ConfigCore.so /usr/lib64/libQt5Xml.so /usr/lib64/libKF5CoreAddons.so /usr/lib64/libKF5DBusAddons.so /usr/lib64/libQt5DBus.so /usr/lib64/libQt5Core.so -lGL -lpthread +LIBS = $(SUBLIBS) -lqt5keychain /usr/lib64/libKF5ItemViews.so /usr/lib64/libKF5Completion.so /usr/lib64/libQt5Widgets.so /usr/lib64/libQt5Gui.so /usr/lib64/libQt5Core.so -lGL -lpthread AR = ar cqs RANLIB = SED = sed @@ -148,10 +148,6 @@ DIST = RsyncUI.desktop \ /usr/lib64/qt5/mkspecs/modules/qt_lib_opengl_private.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_openglextensions.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_pdf.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_pdf_private.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_pdfwidgets.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_pdfwidgets_private.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_platformcompositor_support_private.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_positioning.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_positioning_private.pri \ @@ -190,13 +186,6 @@ DIST = RsyncUI.desktop \ /usr/lib64/qt5/mkspecs/modules/qt_lib_waylandcompositor_private.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_webchannel.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_webchannel_private.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_webengine.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_webengine_private.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_webenginecore.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_webenginecore_private.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_webenginecoreheaders_private.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_webenginewidgets.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_webenginewidgets_private.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_widgets.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_widgets_private.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_x11extras.pri \ @@ -227,9 +216,6 @@ DIST = RsyncUI.desktop \ /usr/lib64/qt5/mkspecs/features/resources_functions.prf \ /usr/lib64/qt5/mkspecs/features/resources.prf \ /usr/lib64/qt5/mkspecs/features/moc.prf \ - /usr/lib64/qt5/mkspecs/features/dbuscommon.pri \ - /usr/lib64/qt5/mkspecs/features/dbusinterfaces.prf \ - /usr/lib64/qt5/mkspecs/features/dbusadaptors.prf \ /usr/lib64/qt5/mkspecs/features/unix/opengl.prf \ /usr/lib64/qt5/mkspecs/features/uic.prf \ /usr/lib64/qt5/mkspecs/features/unix/thread.prf \ @@ -341,10 +327,6 @@ Makefile: RsyncUI.pro /usr/lib64/qt5/mkspecs/linux-g++/qmake.conf /usr/lib64/qt5 /usr/lib64/qt5/mkspecs/modules/qt_lib_opengl_private.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_openglextensions.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_pdf.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_pdf_private.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_pdfwidgets.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_pdfwidgets_private.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_platformcompositor_support_private.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_positioning.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_positioning_private.pri \ @@ -383,13 +365,6 @@ Makefile: RsyncUI.pro /usr/lib64/qt5/mkspecs/linux-g++/qmake.conf /usr/lib64/qt5 /usr/lib64/qt5/mkspecs/modules/qt_lib_waylandcompositor_private.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_webchannel.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_webchannel_private.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_webengine.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_webengine_private.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_webenginecore.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_webenginecore_private.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_webenginecoreheaders_private.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_webenginewidgets.pri \ - /usr/lib64/qt5/mkspecs/modules/qt_lib_webenginewidgets_private.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_widgets.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_widgets_private.pri \ /usr/lib64/qt5/mkspecs/modules/qt_lib_x11extras.pri \ @@ -420,9 +395,6 @@ Makefile: RsyncUI.pro /usr/lib64/qt5/mkspecs/linux-g++/qmake.conf /usr/lib64/qt5 /usr/lib64/qt5/mkspecs/features/resources_functions.prf \ /usr/lib64/qt5/mkspecs/features/resources.prf \ /usr/lib64/qt5/mkspecs/features/moc.prf \ - /usr/lib64/qt5/mkspecs/features/dbuscommon.pri \ - /usr/lib64/qt5/mkspecs/features/dbusinterfaces.prf \ - /usr/lib64/qt5/mkspecs/features/dbusadaptors.prf \ /usr/lib64/qt5/mkspecs/features/unix/opengl.prf \ /usr/lib64/qt5/mkspecs/features/uic.prf \ /usr/lib64/qt5/mkspecs/features/unix/thread.prf \ @@ -433,7 +405,7 @@ Makefile: RsyncUI.pro /usr/lib64/qt5/mkspecs/linux-g++/qmake.conf /usr/lib64/qt5 /usr/lib64/qt5/mkspecs/features/yacc.prf \ /usr/lib64/qt5/mkspecs/features/lex.prf \ RsyncUI.pro - $(QMAKE) -o Makefile RsyncUI.pro -spec linux-g++ + $(QMAKE) -o Makefile RsyncUI.pro /usr/lib64/qt5/mkspecs/features/spec_pre.prf: /usr/lib64/qt5/mkspecs/common/unix.conf: /usr/lib64/qt5/mkspecs/common/linux.conf: @@ -516,10 +488,6 @@ Makefile: RsyncUI.pro /usr/lib64/qt5/mkspecs/linux-g++/qmake.conf /usr/lib64/qt5 /usr/lib64/qt5/mkspecs/modules/qt_lib_opengl_private.pri: /usr/lib64/qt5/mkspecs/modules/qt_lib_openglextensions.pri: /usr/lib64/qt5/mkspecs/modules/qt_lib_openglextensions_private.pri: -/usr/lib64/qt5/mkspecs/modules/qt_lib_pdf.pri: -/usr/lib64/qt5/mkspecs/modules/qt_lib_pdf_private.pri: -/usr/lib64/qt5/mkspecs/modules/qt_lib_pdfwidgets.pri: -/usr/lib64/qt5/mkspecs/modules/qt_lib_pdfwidgets_private.pri: /usr/lib64/qt5/mkspecs/modules/qt_lib_platformcompositor_support_private.pri: /usr/lib64/qt5/mkspecs/modules/qt_lib_positioning.pri: /usr/lib64/qt5/mkspecs/modules/qt_lib_positioning_private.pri: @@ -558,13 +526,6 @@ Makefile: RsyncUI.pro /usr/lib64/qt5/mkspecs/linux-g++/qmake.conf /usr/lib64/qt5 /usr/lib64/qt5/mkspecs/modules/qt_lib_waylandcompositor_private.pri: /usr/lib64/qt5/mkspecs/modules/qt_lib_webchannel.pri: /usr/lib64/qt5/mkspecs/modules/qt_lib_webchannel_private.pri: -/usr/lib64/qt5/mkspecs/modules/qt_lib_webengine.pri: -/usr/lib64/qt5/mkspecs/modules/qt_lib_webengine_private.pri: -/usr/lib64/qt5/mkspecs/modules/qt_lib_webenginecore.pri: -/usr/lib64/qt5/mkspecs/modules/qt_lib_webenginecore_private.pri: -/usr/lib64/qt5/mkspecs/modules/qt_lib_webenginecoreheaders_private.pri: -/usr/lib64/qt5/mkspecs/modules/qt_lib_webenginewidgets.pri: -/usr/lib64/qt5/mkspecs/modules/qt_lib_webenginewidgets_private.pri: /usr/lib64/qt5/mkspecs/modules/qt_lib_widgets.pri: /usr/lib64/qt5/mkspecs/modules/qt_lib_widgets_private.pri: /usr/lib64/qt5/mkspecs/modules/qt_lib_x11extras.pri: @@ -595,9 +556,6 @@ Makefile: RsyncUI.pro /usr/lib64/qt5/mkspecs/linux-g++/qmake.conf /usr/lib64/qt5 /usr/lib64/qt5/mkspecs/features/resources_functions.prf: /usr/lib64/qt5/mkspecs/features/resources.prf: /usr/lib64/qt5/mkspecs/features/moc.prf: -/usr/lib64/qt5/mkspecs/features/dbuscommon.pri: -/usr/lib64/qt5/mkspecs/features/dbusinterfaces.prf: -/usr/lib64/qt5/mkspecs/features/dbusadaptors.prf: /usr/lib64/qt5/mkspecs/features/unix/opengl.prf: /usr/lib64/qt5/mkspecs/features/uic.prf: /usr/lib64/qt5/mkspecs/features/unix/thread.prf: @@ -609,7 +567,7 @@ Makefile: RsyncUI.pro /usr/lib64/qt5/mkspecs/linux-g++/qmake.conf /usr/lib64/qt5 /usr/lib64/qt5/mkspecs/features/lex.prf: RsyncUI.pro: qmake: FORCE - @$(QMAKE) -o Makefile RsyncUI.pro -spec linux-g++ + @$(QMAKE) -o Makefile RsyncUI.pro qmake_all: FORCE @@ -664,19 +622,15 @@ compiler_moc_header_clean: moc_downloadfile.cpp: downloadfile.h \ moc_predefs.h \ /usr/lib64/qt5/bin/moc - /usr/lib64/qt5/bin/moc $(DEFINES) --include /home/daniel/develop/RsyncUI/moc_predefs.h -I/usr/lib64/qt5/mkspecs/linux-g++ -I/home/daniel/develop/RsyncUI -I/usr/include/KF5 -I/usr/include/qt5keychain -I/usr/include/KF5/KItemViews -I/usr/include/KF5/KCompletion -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/KF5/KConfigGui -I/usr/include/qt5/QtGui -I/usr/include/KF5/KConfig -I/usr/include/KF5/KConfigCore -I/usr/include/qt5/QtXml -I/usr/include/KF5/KCoreAddons -I/usr/include/KF5/KDBusAddons -I/usr/include/qt5/QtDBus -I/usr/include/qt5/QtCore -I/usr/include/c++/12 -I/usr/include/c++/12/x86_64-mageia-linux -I/usr/include/c++/12/backward -I/usr/lib/gcc/x86_64-mageia-linux/12/include -I/usr/local/include -I/usr/include downloadfile.h -o moc_downloadfile.cpp + /usr/lib64/qt5/bin/moc $(DEFINES) --include /home/daniel/develop/RsyncUI/moc_predefs.h -I/usr/lib64/qt5/mkspecs/linux-g++ -I/home/daniel/develop/RsyncUI -I/usr/include/KF5 -I/usr/include/qt5keychain -I/usr/include/KF5/KItemViews -I/usr/include/KF5/KCompletion -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I/usr/include/c++/12 -I/usr/include/c++/12/x86_64-mageia-linux -I/usr/include/c++/12/backward -I/usr/lib/gcc/x86_64-mageia-linux/12/include -I/usr/local/include -I/usr/include downloadfile.h -o moc_downloadfile.cpp moc_mainwindow.cpp: mainwindow.h \ ui_mainwindow.h \ ui_configuration.h \ ui_about.h \ - downloadfile.h \ - tools.h \ - password.h \ - mainwindow.h \ moc_predefs.h \ /usr/lib64/qt5/bin/moc - /usr/lib64/qt5/bin/moc $(DEFINES) --include /home/daniel/develop/RsyncUI/moc_predefs.h -I/usr/lib64/qt5/mkspecs/linux-g++ -I/home/daniel/develop/RsyncUI -I/usr/include/KF5 -I/usr/include/qt5keychain -I/usr/include/KF5/KItemViews -I/usr/include/KF5/KCompletion -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/KF5/KConfigGui -I/usr/include/qt5/QtGui -I/usr/include/KF5/KConfig -I/usr/include/KF5/KConfigCore -I/usr/include/qt5/QtXml -I/usr/include/KF5/KCoreAddons -I/usr/include/KF5/KDBusAddons -I/usr/include/qt5/QtDBus -I/usr/include/qt5/QtCore -I/usr/include/c++/12 -I/usr/include/c++/12/x86_64-mageia-linux -I/usr/include/c++/12/backward -I/usr/lib/gcc/x86_64-mageia-linux/12/include -I/usr/local/include -I/usr/include mainwindow.h -o moc_mainwindow.cpp + /usr/lib64/qt5/bin/moc $(DEFINES) --include /home/daniel/develop/RsyncUI/moc_predefs.h -I/usr/lib64/qt5/mkspecs/linux-g++ -I/home/daniel/develop/RsyncUI -I/usr/include/KF5 -I/usr/include/qt5keychain -I/usr/include/KF5/KItemViews -I/usr/include/KF5/KCompletion -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I/usr/include/c++/12 -I/usr/include/c++/12/x86_64-mageia-linux -I/usr/include/c++/12/backward -I/usr/lib/gcc/x86_64-mageia-linux/12/include -I/usr/local/include -I/usr/include mainwindow.h -o moc_mainwindow.cpp compiler_moc_objc_header_make_all: compiler_moc_objc_header_clean: @@ -711,48 +665,42 @@ compiler_clean: compiler_moc_predefs_clean compiler_moc_header_clean compiler_ui ####### Compile -downloadfile.o: downloadfile.cpp mainwindow.h \ +downloadfile.o: downloadfile.cpp downloadfile.h \ + tools.h \ + mainwindow.h \ ui_mainwindow.h \ ui_configuration.h \ - ui_about.h \ - downloadfile.h \ - tools.h \ - password.h + ui_about.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o downloadfile.o downloadfile.cpp main.o: main.cpp mainwindow.h \ ui_mainwindow.h \ ui_configuration.h \ ui_about.h \ - downloadfile.h \ - tools.h \ - password.h + tools.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp mainwindow.o: mainwindow.cpp mainwindow.h \ ui_mainwindow.h \ ui_configuration.h \ ui_about.h \ - downloadfile.h \ + version.h \ tools.h \ - password.h \ - version.h + password.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwindow.o mainwindow.cpp password.o: password.cpp password.h \ + tools.h \ mainwindow.h \ ui_mainwindow.h \ ui_configuration.h \ - ui_about.h \ - downloadfile.h \ - tools.h + ui_about.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o password.o password.cpp tools.o: tools.cpp mainwindow.h \ ui_mainwindow.h \ ui_configuration.h \ ui_about.h \ - downloadfile.h \ tools.h \ password.h $(CXX) -c $(CXXFLAGS) $(INCPATH) -o tools.o tools.cpp diff --git a/README_FR.md b/README_FR.md index 95f6e4d..eb8518e 100644 --- a/README_FR.md +++ b/README_FR.md @@ -32,8 +32,10 @@ Cliquez sur un fichier pour le supprimer de la file et une fenêtre de confirmat 1er icône: Changer le dossier de destination - Permet de changer le dossier de téléchargement par défaut pour chaque service de chaque serveur. - -2ème icône: Paramètres de l'application +2éme icône: Services cachés + - Permet de configurer un service caché. + Il faut donner le nom du service et le mot de passe si besoin. +3ème icône: Paramètres de l'application - Limite de bande passante Permet de limiter le débit de téléchargement en Ko, Mo, Go, To et Po. Si la valeur est 0 alors pas de limite de la vitesse de téléchargement. diff --git a/RsyncUI b/RsyncUI new file mode 100755 index 0000000..6b9b451 Binary files /dev/null and b/RsyncUI differ diff --git a/RsyncUI.pro b/RsyncUI.pro index 4936592..6f095af 100644 --- a/RsyncUI.pro +++ b/RsyncUI.pro @@ -2,9 +2,6 @@ QT += core gui QT += KItemViews QT += KCompletion QT += widgets -QT += KConfigCore KConfigGui -QT += KCoreAddons -QT += KDBusAddons LIBS += -lqt5keychain @@ -14,7 +11,7 @@ CONFIG += c++17 # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ downloadfile.cpp \ diff --git a/RsyncUI.pro.user b/RsyncUI.pro.user index 61d2292..b2e3ace 100644 --- a/RsyncUI.pro.user +++ b/RsyncUI.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {a3117c94-e673-4dca-aa4c-050bbea034fe} + {db2284ae-177e-4753-8e1e-1e0e73c52ae1} ProjectExplorer.Project.ActiveTarget @@ -71,37 +71,32 @@ 0 true - - true - Builtin.Questionable true true Builtin.DefaultTidyAndClazy - 2 + 1 true - - true - ProjectExplorer.Project.Target.0 Desktop - Qt 5.15.7 (qt5) - Qt 5.15.7 (qt5) - {a8a6d767-5e05-45c7-b70b-532f99112b6a} + Qt 5.15.7 (Système) + Qt 5.15.7 (Système) + {5228be4d-4434-412e-a9f4-ec733d887ed1} 0 0 0 - /home/daniel/develop/RsyncUI - /home/daniel/develop/RsyncUI + 0 + /home/daniel/develop/RsyncUI/../build-RsyncUI-Qt_5_15_7_Syst_me_temporaire-Debug + /home/daniel/develop/build-RsyncUI-Qt_5_15_7_Syst_me_temporaire-Debug true @@ -134,11 +129,93 @@ false + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /home/daniel/develop/RsyncUI/../build-RsyncUI-Qt_5_15_7_Syst_me_temporaire-Release + /home/daniel/develop/build-RsyncUI-Qt_5_15_7_Syst_me_temporaire-Release + + + true + QtProjectManager.QMakeBuildStep + true + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + Release Qt4ProjectManager.Qt4BuildConfiguration 0 + 0 - 1 + + 0 + /home/daniel/develop/RsyncUI/../build-RsyncUI-Qt_5_15_7_Syst_me_temporaire-Profile + /home/daniel/develop/build-RsyncUI-Qt_5_15_7_Syst_me_temporaire-Profile + + + true + QtProjectManager.QMakeBuildStep + true + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 0 @@ -159,7 +236,6 @@ 2 - RsyncUI Qt4ProjectManager.Qt4RunConfiguration:/home/daniel/develop/RsyncUI/RsyncUI.pro /home/daniel/develop/RsyncUI/RsyncUI.pro false @@ -167,7 +243,7 @@ true false true - /home/daniel/develop/RsyncUI + /home/daniel/develop/build-RsyncUI-Qt_5_15_7_Syst_me_temporaire-Debug 1 @@ -178,7 +254,7 @@ Desktop Desktop Desktop - {893f9ca6-0efa-4c08-a4a6-5a818f60a8a0} + {96ba01cf-98b6-46f1-b1a8-6cf5d7804e77} 0 0 0 @@ -190,7 +266,7 @@ true QtProjectManager.QMakeBuildStep - false + true @@ -229,7 +305,7 @@ true QtProjectManager.QMakeBuildStep - false + true @@ -270,7 +346,7 @@ true QtProjectManager.QMakeBuildStep - false + true @@ -335,9 +411,89 @@ 1 + + ProjectExplorer.Project.Target.2 + + Desktop + Qt 5.15.7 in PATH (qt5) + Qt 5.15.7 in PATH (qt5) + {7fe200c1-f5ad-4deb-a8be-7d9bd4e961d5} + 0 + 0 + 0 + + /home/daniel/develop/RsyncUI + /home/daniel/develop/RsyncUI + + + true + QtProjectManager.QMakeBuildStep + true + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 1 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + false + true + + 1 + + ProjectExplorer.Project.TargetCount - 2 + 3 ProjectExplorer.Project.Updater.FileVersion diff --git a/RsyncUI.pro.user.a3117c9 b/RsyncUI.pro.user.a3117c9 new file mode 100644 index 0000000..55ac8c1 --- /dev/null +++ b/RsyncUI.pro.user.a3117c9 @@ -0,0 +1,350 @@ + + + + + + EnvironmentId + {a3117c94-e673-4dca-aa4c-050bbea034fe} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + true + Builtin.Questionable + + true + true + Builtin.DefaultTidyAndClazy + 2 + + + + true + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Qt 5.15.7 (qt5) + Qt 5.15.7 (qt5) + {a8a6d767-5e05-45c7-b70b-532f99112b6a} + 0 + 0 + 0 + + /home/daniel/develop/RsyncUI + /home/daniel/develop/RsyncUI + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 1 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + RsyncUI + Qt4ProjectManager.Qt4RunConfiguration:/home/daniel/develop/RsyncUI/RsyncUI.pro + /home/daniel/develop/RsyncUI/RsyncUI.pro + false + true + true + false + true + /home/daniel/develop/RsyncUI + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop + Desktop + Desktop + {893f9ca6-0efa-4c08-a4a6-5a818f60a8a0} + 0 + 0 + 0 + + 0 + /home/daniel/develop/RsyncUI/../build-RsyncUI-Desktop-Debug + /home/daniel/develop/build-RsyncUI-Desktop-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /home/daniel/develop/RsyncUI/../build-RsyncUI-Desktop-Release + /home/daniel/develop/build-RsyncUI-Desktop-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + /home/daniel/develop/RsyncUI/../build-RsyncUI-Desktop-Profile + /home/daniel/develop/build-RsyncUI-Desktop-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/RsyncUI_fr_FR.qm b/RsyncUI_fr_FR.qm index 62ee40e..6dd971c 100644 Binary files a/RsyncUI_fr_FR.qm and b/RsyncUI_fr_FR.qm differ diff --git a/RsyncUI_fr_FR.ts b/RsyncUI_fr_FR.ts index 1c865b7..9cabc4b 100644 --- a/RsyncUI_fr_FR.ts +++ b/RsyncUI_fr_FR.ts @@ -58,12 +58,13 @@ Automatic saving of download queue - Enregistrement automatique de la file de téléchargement + Enregistrement automatique de l +a file de téléchargement Auto save download queue - Enregistrement automatique de la file de téléchargement + Enregistrement automatique de la file de téléchargement @@ -216,32 +217,32 @@ Paramètres - + KB Ko - + MB Mo - + GB Go - + TB To - + PB Po - + You click on file to enqueue it, and RyncUI Download one file a time Client for rsync server<br><br>You click on file to enqueue it, and RyncUI Download one file a time <h3>Utilisation</h3> @@ -259,7 +260,10 @@ Cliquez sur un fichier pour le supprimer de la file et une fenêtre de confirmat <h3>Barre d'outils</h3> <b>1er icône: Changer le dossier de destination</b><br> Permet de changer le dossier de téléchargement par défaut pour chaque service de chaque serveur.<br> -<b>2ème icône: Paramètres de l'application</b><br> +<b>2ème icône: Services cachés</b><br> + - Permet de configurer un service caché.<br> + Il faut donner le nom du service et le mot de passe si besoin.<br> +<b>3ème icône: Paramètres de l'application</b><br> Limite de bande passante: permet de limiter le débit de téléchargement en Ko, Mo, Go, To et Po.<br> Si la valeur est 0 alors pas de limite de la vitesse de téléchargement.<br> - Affichage de la barre d'outils<br> @@ -274,97 +278,101 @@ Cliquez sur un fichier pour le supprimer de la file et une fenêtre de confirmat Permet de quitter le programme - + Path Chemin - + Size Taille - + Type Type - + Date Date - + KB/s Ko/s - + MB/s Mo/s - + GB/s Go/s - + TB/s To/s - + PB/s Po/s - + A list of interrupted downloads exists, do you want to continue downloading ? if not the list will be cleared Une liste de téléchargement existe, voulez-vous utiliser cette liste ? si non, elle sera effacée - + + Delete + Effacer + + + &Quit &Quitter - + Clicking Save button, You can save the list of downloads Vous pouvez enregistrer la liste des téléchargements en cliquant sur "enregister" - + Exiting will stop downloading, and will clear the download queue. Do you want to exit ? Si vous sortez, les téléchargements seront arrêter. Voulez-vous vraiment sortir ? - + The program will keep running in the system tray. To terminate the program, choose <b>Quit</b> in the context menu of the system tray entry. Le programme continue dans la boîte à miniatures. Pour quitter le programme cliquez sur l'icône <b>Quitter</b> ou dans les menu contextuel. - + Authentication failed Mauvais mot de passe ou utilisateur - + The processus does'nt respond: Le processus ne répond pas: - server does not exists - Le serveur n'existe pas + Le serveur n'existe pas - - + + Dir dossier @@ -373,51 +381,51 @@ Voulez-vous vraiment sortir ? Doc - + File is partially downloaded. Do you want to resume download ? if no, the file will be deleted from destination directory Le document est déjà partiellement téléchargé. Voulez vous continuer le téléchargemnt ? Si non, il sera supprimer du dossier de destination - + File is already downloaded. Do you want to reload it ? The old file will be deleted Le document est déjà téléchargé. Voulez-vous le télécharger à nouveau ? L'ancien fichier sera effacé - + File is already downloading Le document est déjà en téléchargement - + Starting downloading Démarrage du téléchargement - + finished Terminé - + Rsync process crashed Le processus rsync à planté - + stopped by user stoppé par l'utilisateur - + Do you want to retry? Voulez-vous ré-essayer? - + Download Téléchargement @@ -426,108 +434,108 @@ Voulez-vous ré-essayer? Requête RsyncUI - + Hidden service name Nom du servcice caché - + Version Version - + <h2>Client for rsync server</h2> <h2>Client pour serveur rsync</h2> - + Licence License - + Author Auteur - + EMail Courriel - + Source code Code source - + Select the user you want to connect with or enter a new one Choisissez l'utilisateur avec lequel vous voulez vous connecter ou entrez en un nouveau - - + + Request Requête de mot de passe - + Enter password Entrez votre mot de passe - + Since the save path is linked to service, you need to select a service before you can select a folder Vous devez sélectionnez un service pour pouvoir sélectionnez un dossier par défaut - + Choose folder where to save file Choisissez un dossier où enregistrer le document - + Do you want to stop downloading and delete this file from download queue ? Voulez-vous arrêter le téléchargement et enlever ce fichier de la file de téléchargement ? - + Do you want to delete this file from download queue ? Voulez-vous enlever ce fichier de la file de téléchargement ? - + B o - + The process failed to start. Either the invoked program is missing, or you may have insufficient permissions or resources to invoke the program. Le processus échoué, soit le programme est manquant, soit vous n'avez pas l'autorisation de l'exécuter. - + The process crashed some time after starting successfully. Le processus à planté après avoir démarré avec succès. - + The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again. La fonction waitFor...() a dépassé la limite de temps, you pouvez essayer de la relancer. - + An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel. Une erreur est survenue lors de l'envoi des données vers le processus. Le processus est peut être arrté ou il a fermé son canal d'entrée. - + An error occurred when attempting to read from the process. For example, the process may not be running. Une erreur est survenue lors de la lecturee de données, le processus est probablement arrêté. - + An unknown error occurred. This is the default return value of error(). Une erreur inconnue est survenue. C'est la valeur de retour par défaut de error(). @@ -535,90 +543,103 @@ Voulez-vous ré-essayer? QTranslator - + Success. The rsync command completed successfully without any errors. Succès. La command rsync s'est terminée sans erreurs. - + Syntax or usage error. There was a problem with the syntax of the rsync command or with the options specified. Erreur de syntaxe ou d'usage. il y a un problème avec la synaxe de rsync ou avec les paramètres spécifiés. - + Protocol incompatibility. There was a problem with the protocol version or negotiation between the rsync client and server. Incompatibilité de protocole. Il y a eu un problème avec la version du protocole ou la négotiation avec le serveur rsync. - + Errors selecting input/output files, dirs. There was a problem with the source or destination file or directory specified in the rsync command. Erreurs dans la sélection des fichiers ou dossiers. il y a eu une problème avec le fichier/dossier source ou destination spécifié. - + Requested action not supported: An attempt was made to use an unsupported action or option. Action non suportée. Une tentative d'utiliser une action, ou une option, non supportée à été faite. - + Error starting client-server protocol. There was an error starting the client-server protocol. Erreur de démarrage du protocole client-seveur. Il ya eu une erreur en démarrant le protocole slient-serveur. - + Daemon unable to append to log-file. The rsync daemon was unable to write to its log file. Le démon rsyncd n'arrive pas écrire dans son fichier de log. - + Error in socket I/O. There was an error with the socket input/output. Erreur d'entrée/sortie socket. Il y a eu une erreur d'entrée/sortie sur le socket. - + Error in file I/O. There was an error reading or writing to a file. Erreur de 'entrée/sortie. Il y a eu une erreur de lecture/écriture sur un fichier. - + Error in rsync protocol data stream. There was an error in the rsync protocol data stream. Erreur dans le protocole de flux de données de rsync. - + Errors with program diagnostics. There was an error generating program diagnostics. Erreur avec les diagnostiques du programme. - + Error in IPC code. There was an error in the inter-process communication (IPC) code. Erreur dans le code IPC. IL y a eu une erreur dans la communication inter-processus. - + Received SIGUSR1 or SIGINT. The rsync process was interrupted by a signal. Reçu les signaux SIGUSR1 ou SIGINT. Le processus rsync a été interrompu par un signal. - + Some error returned by waitpid(). An error occurred while waiting for a child process to complete. Erreurs retournées par waitpid().Une erreur est survenue pendant l'attente de la complétion du processus fils. - + Error allocating core memory buffers. There was an error allocating memory buffers. Erreur d'allocation des buffers mémoire. - + Partial transfer due to error. The rsync command completed with an error, but some files may have been transferred successfully. Transfert partiel due à une erreur. La command rsync s'est terminée avec une erreur, mais des fichiers on été transférés avec succès. - + Partial transfer due to vanished source files. Some source files disappeared before they could be transferred. Transfert partiel dû à la disparition des fichiers source. Des fichiers source ont disparu avec d'avoir été transférés. + + + + Rsync error: + + Erreur rsync: + + + + + Error + Erreur + windowAbout diff --git a/downloadfile.cpp b/downloadfile.cpp index 7c87702..9b9a06a 100644 --- a/downloadfile.cpp +++ b/downloadfile.cpp @@ -1,5 +1,3 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" #include "downloadfile.h" #include "tools.h" #include @@ -10,7 +8,6 @@ #include #include #include -//#include #include #include #include @@ -29,10 +26,12 @@ void MainWindow::cancelled(QProcess * process) { bool n = 0; + info(DEBUGMACRO, "cancelled() => download cancelled: Terminating process"); process->terminate(); n = process->waitForFinished(30000); if (n == false) { + info(DEBUGMACRO, "Process does not terminate after 30s, closing process"); process->close(); } } @@ -44,10 +43,14 @@ void MainWindow::download() QStringList param; QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QString server = downloading.server; + uint ipversion; + + info(DEBUGMACRO, "download() => launch a rsync processus to download a file"); this->downloading.process = new QProcess(this); if (!this->downloading.user.isEmpty()) { + info(DEBUGMACRO, "Adding user to server (user@server"); this->downloading.user = this->connexion.user; server = this->connexion.user + "@" + this->downloading.server; env.insert("RSYNC_PASSWORD", this->downloading.password); // Add an environment variable @@ -57,19 +60,23 @@ void MainWindow::download() cmd = "rsync"; if (this->connexion.bandwidthLimit != 0) { + info(DEBUGMACRO, "Adding download speed limit"); param << "--bwlimit=" + QString::number(this->connexion.bandwidthLimit) + bwUnitChar[this->connexion.bandwidthLimitUnit]; } + ipversion = validateServer(server); + if (downloading.ipversion == 4 || downloading.ipversion == 6) { - param << "-" + QString::number(downloading.ipversion); + info(DEBUGMACRO, "Adding ip version parameter"); + param << "-" + QString::number(ipversion).trimmed(); } - param << "--port" << QString::number(this->downloading.port); - param << "-aXP "; - param << server + "::" + this->downloading.service + "/" + this->downloading.path << this->downloading.savePath + "/"; + param << "--port" << QString::number(this->downloading.port).trimmed(); + param << "-aXP"; + param << "[" + server + "]::" + this->downloading.service.trimmed() + "/" + this->downloading.path.trimmed() << this->downloading.savePath.trimmed() + "/"; - qInfo("%s %s", cmd.toStdString().c_str(), param.join(" ").toStdString().c_str() ); + info(DEBUGMACRO, cmd + " " + param.join(" ")); this->downloading.process->start(cmd, param); @@ -82,7 +89,6 @@ void MainWindow::download() void MainWindow::readRsyncOutput() { QString line; - bool flag = false; int value; int pos; static QString dlSpeed; @@ -91,13 +97,13 @@ void MainWindow::readRsyncOutput() int i; int listSize; - while(!flag) + info(DEBUGMACRO, "readRsyncOutput()"); + while(1) { list.clear(); line = QString::fromUtf8(this->downloading.process->readLine()); if (line.isEmpty()) { - flag = true; break; }else { @@ -112,13 +118,8 @@ void MainWindow::readRsyncOutput() value = list.at(i *4 + 1).chopped(1).toInt(); dlSpeed = list.at(i * 4 + 2); - /*line.resize(pos); - pos = line.lastIndexOf(' '); - if (pos != -1) - { - line.remove(0, pos); - value = line.toInt();*/ // sending progress to Main window + info (DEBUGMACRO, "sending progress to Main window"); emit progressSignal(value); emit fileName(filename + " %p%" + "\t " + dlSpeed); } diff --git a/languages/fr_FR/LC_MESSAGES/RsyncUI_fr_FR.qm b/languages/fr_FR/LC_MESSAGES/RsyncUI_fr_FR.qm index 6dcffe0..6dd971c 100644 Binary files a/languages/fr_FR/LC_MESSAGES/RsyncUI_fr_FR.qm and b/languages/fr_FR/LC_MESSAGES/RsyncUI_fr_FR.qm differ diff --git a/main.cpp b/main.cpp index eabf92c..35f2d25 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,5 @@ #include "mainwindow.h" - +#include "tools.h" #include int main(int argc, char *argv[]) @@ -27,8 +27,7 @@ int main(int argc, char *argv[]) static const QString appName = "RsyncUI"; //Password passwdJob; MainWindow w; - qInfo("RsyncUI begining"); + info(DEBUGMACRO, "RsyncUI begining"); w.show(); - w.init(); return a.exec(); } diff --git a/mainwindow.cpp b/mainwindow.cpp index cdde908..92dd886 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,7 +1,18 @@ #include "mainwindow.h" -#include +#include +//#include #include +#include "ui_configuration.h" #include "version.h" +#include "tools.h" +#include "password.h" +#include + +/* +#include +#include +#include +*/ using namespace std; @@ -30,10 +41,9 @@ QMap rsyncErrorStrings { {24, QTranslator::tr("Partial transfer due to vanished source files. Some source files disappeared before they could be transferred.")} }; - MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) +: QMainWindow(parent) +, ui(new Ui::MainWindow) { ui->setupUi(this); @@ -53,50 +63,31 @@ MainWindow::MainWindow(QWidget *parent) // text of About this->about.version = version; QString aboutText = tr("

Client for rsync server

") + - "" + tr("Version") + ": " + version + "
" + - "" + tr("Licence") + ": " + this->about.licence + "
" + - "" + tr("Author") + ": " + this->about.author + "
" + - "" + tr("EMail") + ": " + this->about.email + "
" + - "" + tr("Source code") + ": " + this->about.git + "
" + - tr("You click on file to enqueue it, and RyncUI Download one file a time"); + "" + tr("Version") + ": " + version + "
" + + "" + tr("Licence") + ": " + this->about.licence + "
" + + "" + tr("Author") + ": " + this->about.author + "
" + + "" + tr("EMail") + ": " + this->about.email + "
" + + "" + tr("Source code") + ": " + this->about.git + "
" + + tr("You click on file to enqueue it, and RyncUI Download one file a time"); AboutW.TextAbout->setHtml(aboutText); +// initialization = true; - // connectors - connect(this, &MainWindow::fileName, ui->progressBar, &QProgressBar::setFormat); - connect(this, &MainWindow::progressSignal, ui->progressBar, &QProgressBar::setValue); - connect(this, &MainWindow::stopDownloading, this, &MainWindow::cancelled); - connect(config.buttonBox, SIGNAL(accepted()), this, SLOT(on_buttonBox_accepted())); - connect(config.comboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &MainWindow::on_comboBox_currentIndexChanged); - - loadSettings(); - + info(DEBUGMACRO, "Initialization of widgets"); // init of widgets ui->ktreewidgetsearchline->setTreeWidget(ui->treeWidget); // attach search widget to treewidget ui->ktreewidgetsearchline->setCaseSensitivity(Qt::CaseInsensitive); // and set it case insensitive ui->treeWidget->setHeaderLabels({tr("Path"), tr("Type"), tr("Size"), tr("Date"), "fullSize"} ); // set header of columns of tree widget - //ui->treeWidget->header()->setContextMenuPolicy(); + // setting arrowcursor for treeWidget, listWidget and listDownload to arrow ui->treeWidget->setCursor(Qt::ArrowCursor); ui->listWidget->setCursor(Qt::ArrowCursor); ui->listDownload->setCursor(Qt::ArrowCursor); + info(DEBUGMACRO, "Hiding progress bar"); // Hiding progress bar ui->progressBar->hide(); - - // if last server exists in settings - if (this->settings.contains("connexion/lastServer")) - { - // set window to precedent server/port configuration - ui->portEdit->setText(this->settings.value("connexion/port").toString()); - ui->khistorycombobox->setCurrentText(this->settings.value("connexion/lastServer").toString()); - }else - { - ui->portEdit->setText(QString::number(this->connexion.port)); - ui->khistorycombobox->clear(); - } - //setting configuration window config.comboBox->setCurrentIndex(ui->toolBar->toolButtonStyle()); // setting combobox to saved settings @@ -106,7 +97,33 @@ MainWindow::MainWindow(QWidget *parent) // hide fullsize column of treeview ui->treeWidget->setColumnHidden(4, true); + loadSettings(); initSystemTrayIcon(); + init(); + + // if last server exists in settings + if (this->settings.contains("connexion/lastServer")) + { + info(DEBUGMACRO, "Setting previous server"); + // set window to previous server/port configuration + ui->portEdit->setText(this->settings.value("connexion/lastPort").toString()); + ui->khistorycombobox->setCurrentText(this->settings.value("connexion/lastServer").toString()); + }else + { + info(DEBUGMACRO, "No previous server, so setting only default port"); + ui->portEdit->setText(QString::number(this->connexion.port)); + ui->khistorycombobox->clear(); + } + + // connectors + connect(this, &MainWindow::fileName, ui->progressBar, &QProgressBar::setFormat); + connect(this, &MainWindow::progressSignal, ui->progressBar, &QProgressBar::setValue); + connect(this, &MainWindow::stopDownloading, this, &MainWindow::cancelled); + connect(config.buttonBox, SIGNAL(accepted()), this, SLOT(on_buttonBox_accepted())); + connect(config.comboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &MainWindow::on_comboBox_currentIndexChanged); + connect(ui->khistorycombobox, QOverload::of(&KComboBox::returnPressed), this, &MainWindow::on_return_pressed); + populateList(ui->khistorycombobox->currentText(), ui->portEdit->text().toUInt()); + initialization = false; } void MainWindow::init() @@ -117,25 +134,29 @@ void MainWindow::init() //if exists list of donwloads in saved settings if (this->settings.value("Downloads/rows").toInt() != 0) { - // asking if we load the list and continue downloading - msgBox.setWindowTitle(a.applicationName()); - msgBox.setInformativeText(tr("A list of interrupted downloads exists, do you want to continue downloading ? if not the list will be cleared" )); + // asking if we load the list and continue downloading + msgBox.setWindowTitle(a.applicationName()); + msgBox.setInformativeText(tr("A list of interrupted downloads exists, do you want to continue downloading ? if not the list will be cleared" )); - QPushButton *yes = msgBox.addButton(QMessageBox::Yes); - msgBox.addButton(QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); + QPushButton *deleteButton = msgBox.addButton(tr("Delete"), QMessageBox::ActionRole); + msgBox.addButton(QMessageBox::No); + QPushButton *yes = msgBox.addButton(QMessageBox::Yes); + msgBox.setDefaultButton(QMessageBox::Yes); - msgBox.exec(); - reply = msgBox.clickedButton(); - - // if response is yes then loading list - if(reply == yes) - { - loadDownloadList(); - } + msgBox.exec(); + reply = msgBox.clickedButton(); + info(DEBUGMACRO, "Response => " + reply->text()); + // if response is yes then loading list + info(DEBUGMACRO, "reply text is : " + reply->text()); + if(reply == yes) + { + loadDownloadList(); + }else if (reply == deleteButton) + { + // delete saved download list + deleteDownloadList(); + } } - // load list of services - populateList(ui->khistorycombobox->currentIndex()); } void MainWindow::initSystemTrayIcon() @@ -144,6 +165,7 @@ void MainWindow::initSystemTrayIcon() QAction * quitAction; QIcon icon; + info(DEBUGMACRO, "initSystemTrayIcon"); icon.addFile(this->icon); this->trayIcon = new QSystemTrayIcon; this->trayIcon->setIcon(icon); @@ -155,36 +177,42 @@ void MainWindow::initSystemTrayIcon() trayIconMenu->addAction(quitAction); trayIcon->setContextMenu(trayIconMenu); + info(DEBUGMACRO, "Connecting signal of trayIcon"); connect(this->trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_trayIcon_clicked(QSystemTrayIcon::ActivationReason))); this->trayIcon->show(); } void MainWindow::on_trayIcon_clicked(QSystemTrayIcon::ActivationReason reason) { + info(DEBUGMACRO, "on_trayIcon_clicked"); if (reason == QSystemTrayIcon::Trigger) { - if (this->isHidden()) - { - this->show(); - }else - { - this->hide(); - } + info(DEBUGMACRO, "trayIcon is clicked"); + if (this->isHidden()) + { + this->show(); + }else + { + this->hide(); + } } } void MainWindow::hideWindow() { + info(DEBUGMACRO, "hideWindow()\n Hiding window"); this->hide(); } void MainWindow::showWindow() { + info(DEBUGMACRO, "showWindow()\n showing window"); this->show(); } MainWindow::~MainWindow() { + info(DEBUGMACRO, "Exiting application"); delete ui; QCoreApplication::quit(); } @@ -195,45 +223,50 @@ void MainWindow::quitApp() QMessageBox::StandardButtons param; QString displayText; + info(DEBUGMACRO, "Exiting application"); + // saving settings saveSettings(); if (ui->listDownload->count() != 0) // some downloads waiting { - // Asking for stopping or continuing - param = QMessageBox::Yes|QMessageBox::No; - if (config.autosaveCheckbox->checkState() != Qt::Checked) - { - param |= QMessageBox::Save; - displayText = tr("Clicking Save button, You can save the list of downloads\n"); - } - reply = QMessageBox::question( - this, - a.applicationName(), - tr("Exiting will stop downloading, and will clear the download queue.\nDo you want to exit ?") + displayText, - param, - QMessageBox::No); - this->downloading.quit = true; - if(reply == QMessageBox::Yes) - { - if (this->downloading.process->state() != QProcess::NotRunning) - { - // emission of signal to downloading thread and stopping - emit (stopDownloading(this->downloading.process)); - } - }else if (reply == QMessageBox::Save) - { - if (config.autosaveCheckbox->checkState() == Qt::Unchecked) - { + info(DEBUGMACRO, "Asking confirmation to exit"); + // Asking for stopping or continuing + param = QMessageBox::Yes|QMessageBox::No; + if (config.autosaveCheckbox->checkState() != Qt::Checked) + { + param |= QMessageBox::Save; + displayText = tr("Clicking Save button, You can save the list of downloads\n"); + } - //saveDownloadList(); - emit (stopDownloading(this->downloading.process)); - } - }else if (reply == QMessageBox::No) - { - return; - } + reply = QMessageBox::question( + this, + a.applicationName(), + tr("Exiting will stop downloading, and will clear the download queue.\nDo you want to exit ?") + displayText, + param, + QMessageBox::No); + this->downloading.quit = true; + if(reply == QMessageBox::Yes) + { + info(DEBUGMACRO,"Stopping downloads"); + if (this->downloading.process->state() != QProcess::NotRunning) + { + // emission of signal to downloading thread and stopping + emit (stopDownloading(this->downloading.process)); + } + }else if (reply == QMessageBox::Save) + { + if (config.autosaveCheckbox->checkState() == Qt::Unchecked) + { + info(DEBUGMACRO, "Saving download list"); + //saveDownloadList(); + emit (stopDownloading(this->downloading.process)); + } + }else if (reply == QMessageBox::No) + { + return; + } } QCoreApplication::quit(); } @@ -244,34 +277,34 @@ void MainWindow::closeEvent (QCloseEvent *event) QMessageBox msgBox; QCheckBox *cb; + info(DEBUGMACRO, "closeEvent() => Closing window to systray"); + if (!event->spontaneous() || !isVisible()) - return; + return; if (trayIcon->isVisible() and this->settings.value("CloseCheckbox").toBool() == false) { - cb = new QCheckBox("Don't show this again ?"); - msgBox.setWindowTitle(a.applicationName()); - msgBox.setInformativeText(tr("The program will keep running in the " - "system tray. To terminate the program, " - "choose Quit in the context menu " - "of the system tray entry.")); + cb = new QCheckBox("Don't show this again ?"); + msgBox.setWindowTitle(a.applicationName()); + msgBox.setInformativeText(tr("The program will keep running in the " + "system tray. To terminate the program, " + "choose Quit in the context menu " + "of the system tray entry.")); - msgBox.addButton(QMessageBox::Ok); - //msgBox.addButton(QMessageBox::No); - // msgBox.setDefaultButton(QMessageBox::Yes); - msgBox.setCheckBox(cb); - msgBox.exec(); - msgBox.clickedButton(); + msgBox.addButton(QMessageBox::Ok); + msgBox.setCheckBox(cb); + msgBox.exec(); + msgBox.clickedButton(); - // if response is yes then loading list - if (cb->isChecked()) - { - this->settings.setValue("CloseCheckbox", true); - } - hide(); + // if response is yes then loading list + if (cb->isChecked()) + { + this->settings.setValue("CloseCheckbox", true); + } + hide(); - //event->accept(); - event->ignore(); + //event->accept(); + event->ignore(); } } @@ -280,110 +313,145 @@ void MainWindow::populateTree() { QString path; + info(DEBUGMACRO, "populateTree() =>Populating listview"); + // Clear treewidget ui->treeWidget->clear(); if (!this->connexion.server.isEmpty() and this->connexion.port > 0 and this->connexion.port < 65536) { - // setting cursor to "Wait" - QGuiApplication::setOverrideCursor(Qt::WaitCursor); + // setting cursor to "Wait" + QGuiApplication::setOverrideCursor(Qt::WaitCursor); - // validating server's address - if (validateServer(this->connexion.server)) - { - // server is validated, scanning directory - path = this->connexion.service + "/"; - while (this->rescan) - { - scanDir(this->connexion.server, this->connexion.port, nullptr, path); - } - } - // Restoring cursor - QGuiApplication::restoreOverrideCursor(); + info(DEBUGMACRO, "Validating server"); + // validating server's address + this->connexion.ipversion = validateServer(this->connexion.server); + if (this->connexion.ipversion != 0) + { + // server is validated, scanning directory + path = this->connexion.service + "/"; + while (this->rescan) + { + scanDir(&this->connexion, nullptr, path); + } + } + // Restoring cursor + QGuiApplication::restoreOverrideCursor(); } + } // Populate Listview with list of services -void MainWindow::populateList(int item) +void MainWindow::populateList(QString server, uint port) { - QString server; QString service; QStringList hidden; - int port; int i; + bool ok = false; - if (item == -1) + info(DEBUGMACRO, "populateList() => Populating list of services"); + + info(DEBUGMACRO, "port: " + QString::number(port) + " - server: " + server); + if (server.isEmpty()) { - server = ui->khistorycombobox->currentText(); + ui->listWidget->clear(); + ui->treeWidget->clear(); + return; + } + if ((server != this->connexion.server)) + { + // Determine version of Ip Protocol + info(DEBUGMACRO, "Server changed"); + + this->connexion.server = server; + if (port != false) + { + this->connexion.port = port; + } + // setting cursor to "Wait" + QGuiApplication::setOverrideCursor(Qt::WaitCursor); + + // verify if server is in history + this->settings.beginGroup("connexion/server"); + if (this->settings.contains(server)) + { + info(DEBUGMACRO, "Server configuration exists in settings"); + + // server is in history => setting port value + port = this->settings.value(server).toUInt(); + this->connexion.ipversion = this->settings.value("ipversion").toUInt(); + ui->portEdit->setText(QString::number(port)); + this->connexion.port = port; + + ok = true; + //display list of services + //listServices(); // TODO clear in listServices + } + this->settings.endGroup(); + } + if (port != this->connexion.port) + { + info(DEBUGMACRO, "Port changed"); + + this->connexion.port = port; + ok = true; + //listServices(); // TODO clear in listServices + } + + if (ok == true) + { + if (this->connexion.ipversion == 0) + { + this->connexion.ipversion = validateServer(server); + info(DEBUGMACRO, QString::number(this->connexion.ipversion)); + } + + if (this->connexion.ipversion != 0) + { + info(DEBUGMACRO, QString::number(this->connexion.ipversion)); + info(DEBUGMACRO, "server: " + server); + info(DEBUGMACRO,"Saving server configuration in settings"); + + // storing serverURL and port in settings + this->settings.setValue(server, port); + this->settings.setValue(server, this->connexion.ipversion); + this->settings.sync(); + this->downloading.server = server; + this->downloading.ipversion = this->connexion.ipversion; + + // storing in history of combobox + ui->khistorycombobox->addToHistory(server); + + // load and display rsync services of the rsync server + + } }else { - server = ui->khistorycombobox->itemText(item); + info(DEBUGMACRO, "Error server not changed"); } - port = ui->portEdit->text().toUInt(); - if ((server != this->connexion.server) or (port != this->connexion.port)) + listServices(); + + this->settings.beginGroup("Hidden/" + server); + hidden = this->settings.allKeys(); + if (hidden.count() > 0) { - // clearing listwidget - ui->listWidget->clear(); - - this->connexion.server = server; - this->connexion.port = port; - - // setting cursor to "Wait" - QGuiApplication::setOverrideCursor(Qt::WaitCursor); - - // verify if server is in history - this->settings.beginGroup("connexion/server"); - if (this->settings.contains(server) and this->connexion.comboboxChanged) - { - // server is in history => setting port value - port = this->settings.value(server).toUInt(); - ui->portEdit->setText(QString::number(port)); - this->connexion.port = port; - - //display list of services - listServices(); - }else - { - if (!server.isEmpty() and (port > 0 and port < 65536)) - { - if (validateServer(server)) - { - cout << server.toStdString() << endl; - - // storing serverURL and port in settings - this->settings.setValue(server, port); - this->settings.sync(); - this->downloading.server = server; - - // storing in history of combobox - ui->khistorycombobox->addToHistory(server); - - // load and display rsync services of the rsync server - listServices(); - } - } - } - this->settings.endGroup(); - this->settings.beginGroup("Hidden/" + server); - hidden = this->settings.allKeys(); - if (hidden.count() > 0) - { - for (i = 0; i < hidden.size(); i++) - { - service = hidden[i]; - //TODO detect if service is already present - if (testServicePresence(service, false)) - { - ui->listWidget->addItem(service + "\n\t"); - } - } - } - this->settings.endGroup(); - QGuiApplication::restoreOverrideCursor(); //setting cursor to default + for (i = 0; i < hidden.size(); i++) + { + service = hidden[i]; + //TODO detect if service is already present + if (testServerPresence(service, false)) + { + ui->listWidget->addItem(service + "\n\t"); + } + } } + this->settings.endGroup(); + // clearing listview + ui->treeWidget->clear(); + QGuiApplication::restoreOverrideCursor(); //setting cursor to default } // Test if service is already present on the server -bool MainWindow::testServicePresence(QString service, bool askPassword) +bool MainWindow::testServerPresence(QString service, bool askPassword) { QString cmd; QStringList param; @@ -395,38 +463,45 @@ bool MainWindow::testServicePresence(QString service, bool askPassword) int loop =0; bool r = false; + info(DEBUGMACRO, "testServerPresence() => Test of rsync server"); + info(DEBUGMACRO, "ipversion = " + QString::number(this->connexion.ipversion )); cmd = "/usr/bin/rsync"; - param << "--contimeout=10" << "-nq" << "--port=" + QString::number(this->connexion.port) << this->connexion.server + "::" + service; + + + if (this->connexion.ipversion == 4 || this->connexion.ipversion ==6) + { + param << "-" + QString::number(this->connexion.ipversion); + } + param << "--contimeout=10" << "-nq" << "--port=" + QString::number(this->connexion.port) << + "[" + this->connexion.server + "]::" + service; myProcess = new QProcess(this); myProcess->setProcessChannelMode(QProcess::MergedChannels); myProcess->start(cmd, param); myProcess->waitForStarted(); myProcess->write("\n"); - //myProcess->waitForFinished(12000); while(myProcess->waitForReadyRead(10000)) { - while(1) - { - // line empty then buffer is empty so returning to wait new datas - line = QString::fromUtf8(myProcess->readLine()); - if (line.isEmpty()) - { - break; - } - if (line.contains("auth failed")) - { - if (askPassword == true and loop >=2 and r == true) - { - r = getUserPassword(&this->connexion); - loop++; - } - returnValue = true; - } - } + while(1) + { + // line empty then buffer is empty so returning to wait new datas + line = QString::fromUtf8(myProcess->readLine()); + if (line.isEmpty()) + { + break; + } + if (line.contains("auth failed")) + { + if (askPassword == true and loop >=2 and r == true) + { + r = getUserPassword(&this->connexion); + loop++; + } + returnValue = true; + } + } } if (myProcess->exitCode() == 0) { - returnValue = true; + returnValue = true; } myProcess->close(); return returnValue; @@ -441,46 +516,73 @@ void MainWindow::listServices() QString errorRsync; QStringList v; QString service; + QString server; QProcess *myProcess; bool flag = false; + info(DEBUGMACRO, "listServices() => Listing services offered by server"); + + // clearing listwidget + ui->listWidget->clear(); + cmd = "/usr/bin/rsync"; - param << "--contimeout=20" << "--port=" + QString::number(this->connexion.port) << this->connexion.server + "::"; + if (this->connexion.ipversion == 0) + { + this->connexion.ipversion = whatIpVersion(this->connexion.server); + } + + if (this->connexion.ipversion == 4) + { + param << "-" + QString::number(this->connexion.ipversion).trimmed(); + server = this->connexion.server.trimmed(); + }else if (this->connexion.ipversion == 6) + { + param << "-" + QString::number(this->connexion.ipversion).trimmed(); + server = "[" + this->connexion.server + "]"; + } + param << "--contimeout=20" << "--port=" + QString::number(this->connexion.port) << server + "::"; myProcess = new QProcess(this); + + info(DEBUGMACRO, cmd + " " + param.join(" ")); + myProcess->start(cmd, param); // waiting for response of the server with a timeout of 10 seconds while(myProcess->waitForReadyRead(10000)) { - while(!flag) - { - line = QString::fromUtf8(myProcess->readLine()); - // line empty then buffer is empty so returning to wait new datas - if (line.isEmpty()) - { - flag = true; - break; - } - // extracting name and comment of the service - v = line.split("\t"); - v[0].replace(" ", ""); - v[1].replace("\n", ""); - service = v[0] + "\n\t" + v[1]; - - // adding to list of services - ui->listWidget->addItem(service); - } - // buffer empty go to waiting new datas - flag =false; + info(DEBUGMACRO, "Reading"); + while(!flag) + { + line = QString::fromUtf8(myProcess->readLine()); + // line empty then buffer is empty so returning to wait new datas + info(DEBUGMACRO, "line: #" + line + "#"); + if (line.isEmpty()) + { + info(DEBUGMACRO, "line is empty"); + flag = true; + break; + } + info(DEBUGMACRO, "extracting services inforamtions"); + // extracting name and comment of the service + v = line.split("\t"); + v[0].replace(" ", ""); + v[1].replace("\n", ""); + service = v[0] + "\n\t" + v[1]; + info(DEBUGMACRO, "service is:" + service); + info(DEBUGMACRO, "adding to list widget of services"); + ui->listWidget->addItem(service); + } + // buffer empty go to waiting new datas + flag = false; } - // verifying error code testRsyncReturn(this, myProcess); myProcess->close(); + info(DEBUGMACRO, "listServices finished"); } // connect to rsync server to get list of files -bool MainWindow::scanDir(QString server, int portN, QTreeWidgetItem *parent, QString path) +bool MainWindow::scanDir(Connexion * connexion, QTreeWidgetItem *parent, QString path) { QString cmd; QStringList param; @@ -501,269 +603,274 @@ bool MainWindow::scanDir(QString server, int portN, QTreeWidgetItem *parent, QSt int nChild = 0; static uint looping; QStringList dirs; + QString server = connexion->server; + + info(DEBUGMACRO, "scandir() => connect to rsync server to get list of files"); myProcess = new QProcess(this); myProcess->setProcessChannelMode(QProcess::MergedChannels); if (parent != nullptr) { - nChild = parent->childCount(); + nChild = parent->childCount(); } if (nChild == 0) { - if (!this->connexion.user.isEmpty()) - { - server.prepend(this->connexion.user + "@"); - env.insert("RSYNC_PASSWORD", this->connexion.password); // Add an environment variable - }else - { - server.prepend("anonymous@"); - env.insert("RSYNC_PASSWORD", "anonymous"); // Add an environment variable - } - myProcess->setProcessEnvironment(env); - cmd = "rsync"; - param << "--contimeout=20" << "--port=" + QString::number(portN) << server + "::" + path; + if (!connexion->user.isEmpty()) + { + server.prepend(connexion->user + "@"); + env.insert("RSYNC_PASSWORD", connexion->password); // Add an environment variable + }else + { + server.prepend("anonymous@"); + env.insert("RSYNC_PASSWORD", "anonymous"); // Add an environment variable + } + myProcess->setProcessEnvironment(env); + info(DEBUGMACRO, "ipversion => " + QString::number(connexion->ipversion)); + cmd = "rsync"; + if(this->connexion.ipversion == 4 || this->connexion.ipversion == 6) + { + param << "-" + QString::number(connexion->ipversion).trimmed(); + } + param << "--contimeout=20" << "--port=" + QString::number(connexion->port) << "[" + server + "]::" + path; - myProcess->start(cmd, param); - this->rescan = true; + info(DEBUGMACRO, cmd + " " + param.join(" ")); - // waiting for response of the server with a timeout of 10 seconds - do - { - readOk = myProcess->waitForReadyRead(10000); - if (readOk) - { - while (!flag) - { - line = QString::fromUtf8(myProcess->readLine()); - // line empty then buffer is empty so returning to wait new datas - if (line.isEmpty()) - { - flag = true; - break; - } - if (line.contains("auth failed")) - { - myProcess->readAllStandardOutput(); - getUserPassword(&this->connexion); - if (looping <= 1) - { - this->rescan = true; - looping++; - }else - { - this->rescan = false; - looping = 0; - QMessageBox::warning( - this, - a.applicationName(), - tr("Authentication failed" ) - ); - } - return false; - } + myProcess->start(cmd, param); + this->rescan = true; - // extracting name, size and is dir/file - line = line.simplified(); - filename = line.section(" ", 4); - if (filename != '.') - { - size = line.section(" ", 1, 1); - fullsize = size; - fullsize.remove(","); - sizeA = size.split(','); - if (sizeA.count() <= 1) - { - size = sizeA.at(0) + " " + UnitText[0] + " "; - }else - { - myProcess->setProcessEnvironment(env); - size = sizeA.at(0) + "," + sizeA.at(1).left(2) + " " + UnitText[sizeA.count()-1] + " "; - } + info(DEBUGMACRO, "Waiting server response"); + // waiting for response of the server with a timeout of 10 seconds + do + { + readOk = myProcess->waitForReadyRead(10000); + if (readOk) + { + while (!flag) + { + line = QString::fromUtf8(myProcess->readLine()); + // line empty then buffer is empty so returning to wait new datas + if (line.isEmpty()) + { + flag = true; + break; + } + if (line.contains("auth failed")) + { + myProcess->readAllStandardOutput(); + getUserPassword(connexion); + if (looping <= 1) + { + this->rescan = true; + looping++; + }else + { + this->rescan = false; + looping = 0; + warning(tr("Authentication failed" )); + } + return false; + } - if (line[0] == "d") - { - isDir = true; - }else - { - isDir = false; - } + // extracting name, size and is dir/file + line = line.simplified(); + filename = line.section(" ", 4); + if (filename != '.') + { + size = line.section(" ", 1, 1); + fullsize = size; + fullsize.remove(","); + sizeA = size.split(','); + if (sizeA.count() <= 1) + { + size = sizeA.at(0) + " " + UnitText[0] + " "; + }else + { + myProcess->setProcessEnvironment(env); + size = sizeA.at(0) + "," + sizeA.at(1).left(2) + " " + UnitText[sizeA.count()-1] + " "; + } - date = line.section(' ', 2, 2); - fileType = getFileType(filename); - if (!path.isEmpty()) - { - if (path.endsWith('/')) - { - path.chop(1); - } - dirs = path.split('/'); - dirName = dirs[dirs.size()-1]; - } - addTreeItem(filename, size, fullsize, fileType, date, isDir, dirName, parent); - if (passwdOk == false and !this->connexion.password.isEmpty()) - { - this->settings.setValue("Passwords/" + this->connexion.server + "/" + this->connexion.service + "/" + this->connexion.user, true); - setPassword(this->connexion.user, this->connexion.password); - this->settings.sync(); - } - this->rescan = false; - } - } - flag = false; - }else - { - if (myProcess->state() == QProcess::Running) - { - if (myProcess->waitForFinished(10000) == 0) - { - QMessageBox::warning( - this, - a.applicationName(), - tr("The processus does'nt respond: ") + myProcess->errorString()); - } - } - } - }while(readOk); - // buffer empty go to waiting new datas + if (line[0] == "d") + { + isDir = true; + }else + { + isDir = false; + } - testRsyncReturn(this, myProcess); - myProcess->close(); + date = line.section(' ', 2, 2); + fileType = getFileType(filename); + if (!path.isEmpty()) + { + if (path.endsWith('/')) + { + path.chop(1); + } + dirs = path.split('/'); + dirName = dirs[dirs.size()-1]; + } + addTreeItem(filename, size, fullsize, fileType, date, isDir, dirName, parent); + if (passwdOk == false and !connexion->password.isEmpty()) + { + this->settings.setValue("Passwords/" + connexion->server + "/" + connexion->service + "/" + connexion->user, true); + setPassword(connexion->user, connexion->password); + this->settings.sync(); + } + this->rescan = false; + } + } + flag = false; + }else + { + if (myProcess->state() == QProcess::Running) + { + if (myProcess->waitForFinished(10000) == 0) + { + warning(tr("The processus does'nt respond: ") + myProcess->errorString()); + } + } + } + }while(readOk); + // buffer empty go to waiting new datas + + testRsyncReturn(this, myProcess); + myProcess->close(); } return false; } -// Verify if server address is IP address -bool MainWindow::isIpAddress(QString server) -{ - QStringList r; - int elementN; - bool ok; - - r = server.split('.'); - if (r.size() == 4) - { - for (auto element : r) - { - elementN = element.toInt(&ok); - if ((elementN < 0) or (elementN > 255) or ok == false) - { - return false; - } - } - return true; - }else - { - return false; - } -} - // validate address server -bool MainWindow::validateServer(QString server) +uint MainWindow::validateServer(QString server) { QString cmd; QStringList param; QString line; QProcess * myProcess; - bool flag = false; - bool bflag = false; + QStringList responseList; - cmd = "dig"; - param << server; + uint ipversion; + int answerFound = 0; + int queryPos = 0; - myProcess = new QProcess(this); - myProcess->start(cmd, param); + info(DEBUGMACRO, "ValidateServer() => Validating server address"); - // maiking a dig on the server's address - while(myProcess->waitForReadyRead()) + ipversion = whatIpVersion(server); + + if (ipversion == 0) // not an Ip address, perhaps a server name { - while (!bflag) - { - line = QString::fromUtf8(myProcess->readAllStandardOutput()); - // line empty then buffer is empty so returning to wait new datas - if (line.isEmpty()) - { - bflag = true; - break; - }else if (line.indexOf(";; ANSWER SECTION:") != -1) - { - flag = true; - } - } - bflag = false; - } + info(DEBUGMACRO, "Digging server name"); - //testRsyncReturn(myProcess); + cmd = "dig"; + param << "-t A"; // IP V4 query + param << "-t AAAA"; // IP V6 query + param << server.trimmed() ; - if ( flag == false) - { - //server's address is not valid testing if ip address is valid - flag = isIpAddress(server); - } - if ( flag == false) - { - // server-s address not valid - QMessageBox::warning( - this, - a.applicationName(), - tr("server does not exists" ) - ); - } - myProcess->close(); - return flag; -} + info(DEBUGMACRO, cmd + " " + param.join(" ")); -// slot activated when combobox is changed -void MainWindow::on_khistorycombobox_currentIndexChanged(int item) -{ - this->connexion.comboboxChanged = true; - populateList(item); + myProcess = new QProcess(this); + myProcess->start(cmd, param); + + // making a dig on the server's address + while(myProcess->waitForReadyRead()) + { + while (1) //!bflag) + { + line = QString::fromUtf8(myProcess->readAllStandardOutput()); + info(DEBUGMACRO, line); + // line empty then buffer is empty so returning to wait new datas + if (line.isEmpty()) + { + break; + }else + { + answerFound = line.indexOf(";; ANSWER SECTION:") +19; + info(DEBUGMACRO, "Position of answer line is : " + QString::number(answerFound)); + + if (answerFound != -1) + { + info(DEBUGMACRO, "Serching IP address"); + queryPos = line.indexOf(";; Query"); + info(DEBUGMACRO, "Position of Query line is : " + QString::number(queryPos)); + if (answerFound < queryPos) + { + line = line.mid(answerFound, queryPos - answerFound); + info(DEBUGMACRO, "line is:\n" + line); + responseList = line.split(QRegExp("\\s+")); + info(DEBUGMACRO, "ip Address is => " + responseList.at(4)); + if(responseList.at(3) == "A") + { + return 4; + }else if(responseList.at(3) == "AAAA") + { + return 6; + } + } + } + } + } + } + myProcess->close(); + } + info(DEBUGMACRO, "Returning ip version: " + QString::number(ipversion)); + return ipversion; + + return 0; } // slot activated when button connection is clicked void MainWindow::on_connectButton_clicked() { - populateList(ui->khistorycombobox->currentIndex()); + QString server; + uint port; + + info(DEBUGMACRO, "on_connectButton_clicked() => Connexion button clicked"); + + server = ui->khistorycombobox->currentText(); + port = ui->portEdit->text().toUInt(); + populateList(server, port); } // add parent in treeview void MainWindow::addTreeItem(QString name, QString fileSize, QString fullsize, QString type, QString date, bool isDir=false, QString dirName="", QTreeWidgetItem *parent=nullptr) { QFont font; - QTreeWidgetItem *treeItem; + + info(DEBUGMACRO, "addTreeItem() => adding item to treeview"); + if (parent != nullptr) { - treeItem = new QTreeWidgetItem(); + treeItem = new QTreeWidgetItem(); }else { - treeItem = new QTreeWidgetItem(ui->treeWidget); + treeItem = new QTreeWidgetItem(ui->treeWidget); } // item is a file if (QFile::exists(this->downloading.savePath + "/" + name) or QFile::exists(this->downloading.savePath + "/" + dirName + "/" + name)) { - QBrush b (Qt::green); - treeItem->setForeground(0, b); - treeItem->setFont(0, font); + QBrush b (Qt::green); + treeItem->setForeground(0, b); + treeItem->setFont(0, font); }else if (this->settings.contains(name)) { - QBrush b (Qt::red); - treeItem->setForeground(0, b); - treeItem->setFont(0, font); + QBrush b (Qt::red); + treeItem->setForeground(0, b); + treeItem->setFont(0, font); } if (isDir == true) { - // item is a dir - treeItem->setText(1, tr("Dir")); - treeItem->setIcon(0, QIcon::fromTheme("folder")); + // item is a dir + treeItem->setText(1, tr("Dir")); + treeItem->setIcon(0, QIcon::fromTheme("folder")); }else { - this->settings.beginGroup("Downloaded/"); - this->settings.endGroup(); - treeItem->setText(1,type); + // item is a file + this->settings.beginGroup("Downloaded/"); + this->settings.endGroup(); + treeItem->setText(1,type); } treeItem->setText(0, name); treeItem->setText(2, fileSize); @@ -774,14 +881,15 @@ void MainWindow::addTreeItem(QString name, QString fileSize, QString fullsize, Q if (parent != nullptr) { - // QTreeWidgetItem::addChild(QTreeWidgetItem * child) - parent->addChild(treeItem); + parent->addChild(treeItem); } } // Slot activated when a service in the list is clicked void MainWindow::on_listWidget_clicked() { + info(DEBUGMACRO, "on_listWidget_clicked() => Slot activated when a service in the list is clicked"); + this->connexion.service = ui->listWidget->currentItem()->text().section("\n", 0 ,0); ui->treeWidget->clear(); preparePopulateTree(); @@ -792,19 +900,18 @@ void MainWindow::preparePopulateTree() QString str; QStringList logins; + info(DEBUGMACRO, "preparePopulateTree()"); this->rescan = true; this->connexion.user = nullptr; this->connexion.password = nullptr; str = "Folder/" + this->connexion.server + "/" + this->connexion.service; + // if service exists in settings for this server if (this->settings.contains(str)) { - // setting savePath from settings - this->downloading.savePath = this->settings.value(str).toString(); + // setting savePath from settings + this->downloading.savePath = this->settings.value(str).toString(); } - - //getUserPassword(&this->connexion); - populateTree(); } @@ -820,6 +927,7 @@ bool MainWindow::getUserPassword(Connexion * object) QString service; int c; + info(DEBUGMACRO, "getUserPassword() => get password and user login"); bool returnValue = false; bool ok = false; @@ -834,44 +942,44 @@ bool MainWindow::getUserPassword(Connexion * object) c = logins.count(); if ( c != 1) { - //choose login in case of multiples logins - login = QInputDialog::getItem(this, - "RsincUI", - tr("Select the user you want to connect with or enter a new one"), - logins, - 0, - true, - &ok, - Qt::Popup, - Qt::ImhNoPredictiveText - ); - if (ok and !login.isEmpty()) - { - if (!logins.contains(login)) - { - password = QInputDialog::getText(this, - a.applicationName() + tr(" Request"), - tr("Enter password"), QLineEdit::Password, - "", &ok, Qt::Popup, - Qt::ImhNoPredictiveText); - if (!ok or password.isEmpty()) - { - password = ""; - returnValue = false; - } - }else - { - password = getPassword(login); - returnValue = true; - } - object->user = login; - object->password = password; - } + //choose login in case of multiples logins + login = QInputDialog::getItem(this, + "RsincUI", + tr("Select the user you want to connect with or enter a new one"), + logins, + 0, + true, + &ok, + Qt::Popup, + Qt::ImhNoPredictiveText + ); + if (ok and !login.isEmpty()) + { + if (!logins.contains(login)) + { + password = QInputDialog::getText(this, + a.applicationName() + tr(" Request"), + tr("Enter password"), QLineEdit::Password, + "", &ok, Qt::Popup, + Qt::ImhNoPredictiveText); + if (!ok or password.isEmpty()) + { + password = ""; + returnValue = false; + } + }else + { + password = getPassword(login); + returnValue = true; + } + object->user = login; + object->password = password; + } }else { - object->user = logins.at(0); - object->password = getPassword(object->user); - returnValue = true; + object->user = logins.at(0); + object->password = getPassword(object->user); + returnValue = true; } this->settings.endGroup(); return returnValue; @@ -880,19 +988,20 @@ bool MainWindow::getUserPassword(Connexion * object) //Slot activated when a file is clicked in the treeview void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadDir) { - //#QFileDialog dialog; QTreeWidgetItem * itemR; QString path; QString str; QMessageBox::StandardButton reply; int sizeFromRsync; - if (treeviewClicked == true) + info(DEBUGMACRO, "on_treeWidget_itemClicked() => Slot activated when a file is clicked in the treeview"); + + if (this->treeviewClicked == true) { - return; + return; } - treeviewClicked = true; + this->treeviewClicked = true; itemR = item; this->rescan = true; @@ -902,122 +1011,124 @@ void MainWindow::on_treeWidget_itemClicked(QTreeWidgetItem *item, bool downloadD while(itemR->parent() != NULL) { - itemR = itemR->parent(); - // concatening parent to path - path.prepend(itemR->text(0) + "/"); + itemR = itemR->parent(); + // concatening parent to path + path.prepend(itemR->text(0) + "/"); }; cout << item->text(1).toStdString() <text(1) != tr("Dir") or downloadDir == true) { - // exists saving path in settings ? - str = "Folder/" + this->connexion.server + "/" + this->connexion.service; - if(!this->settings.contains(str)) - { - // saving path do not exists, asking for it - if(!on_DefaultSaveFolder_triggered()) - { - cout << "no directory selectioned, ignoring download request" << endl; - return; - } - }else - { - this->downloading.savePath = this->settings.value(str).toString(); - } + // exists saving path in settings ? + str = "Folder/" + this->connexion.server + "/" + this->connexion.service; + if(!this->settings.contains(str)) + { + // saving path do not exists, asking for it + if(!on_DefaultSaveFolder_triggered()) + { + cout << "no directory selectioned, ignoring download request" << endl; + this->treeviewClicked = false; + return; + } + }else + { + this->downloading.savePath = this->settings.value(str).toString(); + } - // Item is a file - // searching if file exists in savepath - if (QFile::exists(this->downloading.savePath + "/" + path)) - { + // Item is a file + // searching if file exists in savepath + if (QFile::exists(this->downloading.savePath + "/" + path)) + { - QFileInfo info(this->downloading.savePath + "/" + path); - if (info.size() < sizeFromRsync) - { - reply = QMessageBox::question( - this, - a.applicationName(), - tr("File is partially downloaded. Do you want to resume download ? if no, the file will be deleted from destination directory"), - QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, - QMessageBox::Cancel); + QFileInfo fileinfo(this->downloading.savePath + "/" + path); + if (fileinfo.size() < sizeFromRsync) + { + reply = QMessageBox::question( + this, + a.applicationName(), + tr("File is partially downloaded. Do you want to resume download ? if no, the file will be deleted from destination directory"), + QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel, + QMessageBox::Cancel); - if (reply == QMessageBox::Cancel) - { - return; - }else if(reply == QMessageBox::No) - { - QFile::remove(this->downloading.savePath + "/" + path); - return; - } - }else - { - reply = QMessageBox::question( - this, - a.applicationName(), - tr("File is already downloaded. Do you want to reload it ? The old file will be deleted"), - QMessageBox::Yes|QMessageBox::No, - QMessageBox::No); + if (reply == QMessageBox::Cancel) + { + this->treeviewClicked = false; + return; + }else if(reply == QMessageBox::No) + { + QFile::remove(this->downloading.savePath + "/" + path); + this->treeviewClicked = false; + return; + } + }else + { + reply = QMessageBox::question( + this, + a.applicationName(), + tr("File is already downloaded. Do you want to reload it ? The old file will be deleted"), + QMessageBox::Yes|QMessageBox::No, + QMessageBox::No); - if (reply == QMessageBox::No) - { - return; - }else - { - QFile::remove(this->downloading.savePath + "/" + path); - } - } - } + if (reply == QMessageBox::No) + { + this->treeviewClicked = false; + return; + }else + { + QFile::remove(this->downloading.savePath + "/" + path); + } + } + } - if(ui->listDownload->findItems(path, Qt::MatchStartsWith).empty()) - { - // is there a downloading process ? - if (this->downloading.process == nullptr) - { - // no downloading process launching it - this->downloading.path = path; - this->downloading.server = this->connexion.server; - this->downloading.port = this->connexion.port; - this->downloading.service = this->connexion.service; - startDownloading(); - // wait 1 second to process start - //sleep(1); - } + if(ui->listDownload->findItems(path, Qt::MatchStartsWith).empty()) + { + // is there a downloading process ? + if (this->downloading.process == nullptr) + { + // no downloading process launching it + this->downloading.path = path; + this->downloading.server = this->connexion.server; + this->downloading.port = this->connexion.port; + this->downloading.service = this->connexion.service; + startDownloading(); + // wait 1 second to process start + //sleep(1); + } - // Adding download in download list - str = path + " => " + this->connexion.server + "/" + this->connexion.service; - ui->listDownload->addItem(str); - }else - { - QMessageBox::warning( - this, - a.applicationName(), - tr("File is already downloading" ) - ); - } + // Adding download in download list + str = path + " => " + this->connexion.server + "/" + this->connexion.service; + ui->listDownload->addItem(str); + }else + { + warning(tr("File is already downloading" )); + } }else { - //Item is a Directory - if (item->isExpanded() == false) - { - while (this->rescan) - { + //Item is a Directory + if (item->isExpanded() == false) + { + while (this->rescan) + { - scanDir(this->connexion.server, this->connexion.port, item, this->connexion.service + "/" + path +"/"); - item->setExpanded(true); - } - } + scanDir(&this->connexion, item, this->connexion.service + "/" + path +"/"); + item->setExpanded(true); + } + } } if (config.autosaveCheckbox->checkState() == Qt::Checked) { - saveDownloadList(); + saveDownloadList(); } - treeviewClicked = false; + this->treeviewClicked = false; } // Launch the thread which download the file void MainWindow::startDownloading() { + info(DEBUGMACRO, "startDownloading() => Launch the thread which download the file"); + ui->progressBar->setValue(0); ui->progressBar->show(); //getUserPassword(); @@ -1030,6 +1141,8 @@ void MainWindow::startDownloading() // Slot stopping download void MainWindow::stoppingDownload() { + info(DEBUGMACRO, "stoppingDownload"); + emit (stopDownloading(this->downloading.process)); } @@ -1043,37 +1156,41 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus) QMessageBox::StandardButton reply; bool retry = false; + info(DEBUGMACRO, "downloadFinished() => when download is finished, launch download of next file in queue"); + info(DEBUGMACRO, "Download finished with status " + QString::number(exitCode)); + // test if process crashed if (exitStatus == QProcess::CrashExit) { - QMessageBox::warning( - NULL, - a.applicationName(), - tr("Rsync process crashed")); + warning(tr("Rsync process crashed")); } //test result code of command (if 20 then command stopped by user) if (exitCode != 0 and this->stopDlAsked != true) { - if (exitCode == 20) - { - aborted = tr("stopped by user"); - }else if (exitCode == 5) // password asked - { - getUserPassword(&this->downloading); - retry = true; - } + if (exitCode == 20) + { + if (this->exiting) + { + return; + } + aborted = tr("stopped by user"); + }else if (exitCode == 5) // password asked + { + getUserPassword(&this->downloading); + retry = true; + } - // displaying warning with exit code - reply = QMessageBox::warning( - this, - a.applicationName(), - rsyncErrorStrings[exitCode] + tr("\nDo you want to retry?"), - QMessageBox::Yes|QMessageBox::No, - QMessageBox::Yes); - if (reply == QMessageBox::Yes) - { - retry = true; - } + // displaying warning with exit code + reply = QMessageBox::warning( + this, + a.applicationName(), + tr(rsyncErrorStrings[exitCode].toStdString().c_str()) + tr("\nDo you want to retry?"), + QMessageBox::Yes|QMessageBox::No, + QMessageBox::Yes); + if (reply == QMessageBox::Yes) + { + retry = true; + } } this->stopDlAsked = false; this->trayIcon->showMessage(a.applicationName(), tr("Download ") + aborted + "\n" + this->downloading.path, QSystemTrayIcon::Information); @@ -1087,52 +1204,51 @@ void MainWindow::downloadFinished(int exitCode, QProcess::ExitStatus exitStatus) if (retry == false) { - QString filename = ui->listDownload->item(0)->text(); - pos = filename.contains(" => "); - filename.resize(pos); - this->settings.setValue("Downloaded/" + ui->listDownload->item(0)->text(), true); - delete ui->listDownload->takeItem(0); + QString filename = ui->listDownload->item(0)->text(); + pos = filename.contains(" => "); + filename.resize(pos); + delete ui->listDownload->takeItem(0); } this->downloading.clear(); // Some downloads staying in queue if (ui->listDownload->count() != 0) { - // initializing download - path = ui->listDownload->item(0)->text(); - pos = path.lastIndexOf("/"); - this->downloading.service = path.midRef(pos+1).toString(); - path.resize(pos); - pos = path.lastIndexOf(" => "); - this->downloading.server = path.midRef(pos+4).toString(); - path.resize(pos); - this->downloading.port = this->settings.value("connexion/server/" + this->downloading.server).toInt(); - this->downloading.path = path; + // initializing download + path = ui->listDownload->item(0)->text(); + pos = path.lastIndexOf("/"); + this->downloading.service = path.midRef(pos+1).toString(); + path.resize(pos); + pos = path.lastIndexOf(" => "); + this->downloading.server = path.midRef(pos+4).toString(); + path.resize(pos); + this->downloading.port = this->settings.value("connexion/server/" + this->downloading.server).toInt(); + this->downloading.path = path; - //getUserPassword(true); - testServicePresence(this->downloading.service, true); + //getUserPassword(true); + testServerPresence(this->downloading.service, true); - // savepath exists in settings ? - str = "Folder/" + this->downloading.server + "/" + this->downloading.service; - if (this->settings.contains(str)) - { - // setting savepath from saved settings - this->downloading.savePath = this->settings.value(str).toString(); - sleep(2); - startDownloading(); - }else - { - // no save path - if(!on_DefaultSaveFolder_triggered()) - { - cout << "Error no save path so removing download"; - return; - } - } + // savepath exists in settings ? + str = "Folder/" + this->downloading.server + "/" + this->downloading.service; + if (this->settings.contains(str)) + { + // setting savepath from saved settings + this->downloading.savePath = this->settings.value(str).toString(); + sleep(2); + startDownloading(); + }else + { + // no save path + if(!on_DefaultSaveFolder_triggered()) + { + cout << "Error no save path so removing download"; + return; + } + } } if(config.autosaveCheckbox->checkState() == Qt::Checked and this->downloading.quit == false) { - saveDownloadList(); + saveDownloadList(); } } @@ -1142,47 +1258,50 @@ void MainWindow::on_listDownload_itemClicked(QListWidgetItem *item) { QMessageBox::StandardButton reply; + info(DEBUGMACRO, "on_listDownload_itemClicked() => Slot activated when a line is clicked in queue list"); + if (item->listWidget()->row(item) == 0) { - // first line clicked on download list - reply = QMessageBox::question( - this, - a.applicationName(), - tr("Do you want to stop downloading and delete this file from download queue ?"), - QMessageBox::Yes|QMessageBox::No, - QMessageBox::No); - if (reply == QMessageBox::Yes) - { - // stopping download - this->stopDlAsked = true; - emit (stopDownloading(this->downloading.process)); - } + // first line clicked on download list + reply = QMessageBox::question( + this, + a.applicationName(), + tr("Do you want to stop downloading and delete this file from download queue ?"), + QMessageBox::Yes|QMessageBox::No, + QMessageBox::No); + if (reply == QMessageBox::Yes) + { + // stopping download + this->stopDlAsked = true; + emit (stopDownloading(this->downloading.process)); + } }else { - // not first line on download list - reply = QMessageBox::question( - this, - a.applicationName(), - tr("Do you want to delete this file from download queue ?"), - QMessageBox::Yes|QMessageBox::No, - QMessageBox::No); - if (reply == QMessageBox::Yes) - { - // removing line from download list - ui->listDownload->removeItemWidget(item); - delete item; - } + // not first line on download list + reply = QMessageBox::question( + this, + a.applicationName(), + tr("Do you want to delete this file from download queue ?"), + QMessageBox::Yes|QMessageBox::No, + QMessageBox::No); + if (reply == QMessageBox::Yes) + { + // removing line from download list + ui->listDownload->removeItemWidget(item); + delete item; + } } if (config.autosaveCheckbox->checkState() == Qt::Checked) { - // autosave acivated,so saving download list - saveDownloadList(); + // autosave acivated,so saving download list + saveDownloadList(); } } // load settings void MainWindow::loadSettings() { + info(DEBUGMACRO, "loadSettings() => restoring geometry and state of window and widgets"); // restoring geometry and state of window and widgets this->restoreGeometry(this->settings.value("window/geometry").toByteArray()); this->restoreState(this->settings.value("window/state").toByteArray()); @@ -1192,17 +1311,15 @@ void MainWindow::loadSettings() ui->toolBar->setToolButtonStyle((Qt::ToolButtonStyle)this->settings.value("toolbar/state").toInt()); if (this->settings.value("Autosave").toInt() == Qt::Checked) { - this->config.autosaveCheckbox->setChecked(true); + this->config.autosaveCheckbox->setChecked(true); } // loading connexion settings // loading servers history + info(DEBUGMACRO, "Restoring server combobox history"); this->settings.beginGroup("connexion/server"); QStringList servers = this->settings.allKeys(); this->settings.endGroup(); - for( const QString &server : servers ) - { - ui->khistorycombobox->addToHistory(server); - } + ui->khistorycombobox->insertItems(1,this->settings.value("kHistoryComboBox").toStringList()); // loading save path this->downloading.savePath = this->settings.value("Folder").toString(); @@ -1215,6 +1332,8 @@ void MainWindow::loadSettings() // save settings void MainWindow::saveSettings() { + info(DEBUGMACRO, "saveSettings() => Saving settings"); + this->settings.setValue("window/geometry", saveGeometry()); this->settings.setValue("window/state", saveState()); this->settings.setValue("treeWidget/state", ui->treeWidget->header()->saveState()); @@ -1222,62 +1341,69 @@ void MainWindow::saveSettings() this->settings.setValue("splitter2/state", ui->splitter_2->saveState()); this->settings.setValue("connexion/lastServer", this->connexion.server); this->settings.setValue("connexion/lastPort", QString::number(this->connexion.port)); + this->settings.setValue("connexion/lastIpversion", QString::number(this->connexion.ipversion)); this->settings.setValue("toolbar/state", ui->toolBar->toolButtonStyle()); this->settings.setValue("Autosave", this->config.autosaveCheckbox->checkState()); + this->settings.setValue("kHistoryComboBox", ui->khistorycombobox->historyItems()); this->settings.sync(); } // About void MainWindow::on_actionAbout_triggered() { + info(DEBUGMACRO, "on_actionAbout_triggered() => display about informations"); + aboutDialog.show(); } // About QT void MainWindow::on_actionAbout_Qt_triggered() { + info(DEBUGMACRO, "on_actionAbout_Qt_triggered() => display QT about information"); + QMessageBox::aboutQt(this); } // Activated when menu "change folder" is clicked bool MainWindow::on_DefaultSaveFolder_triggered() { - QFileDialog dialog; - QString folder; - QString path; + QFileDialog dialog; + QString folder; + QString path; - // if service not selected display a message - if (this->connexion.service.isEmpty()) - { - QMessageBox::warning( - NULL, - a.applicationName(), - tr("Since the save path is linked to service, you need to select a service before you can select a folder")); - return false; - } + info(DEBUGMACRO, "on_DefaultSaveFolder_triggered() => Activated when menu 'change folder' is clicked"); - // Asking for directory to save files - path = dialog.getExistingDirectory(this, tr("Choose folder where to save file"), QDir::homePath(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); - if (!path.isEmpty()) - { - this->downloading.savePath = path; - if (!this->connexion.service.isEmpty() and !this->connexion.server.isEmpty()) - { - // saving save path in settings - folder = "Folder/" + this->connexion.server + "/" + this->connexion.service; - this->settings.setValue(folder, this->downloading.savePath); - this->settings.sync(); - } - }else - { - return false; - } - return true; + // if service not selected display a message + if (this->connexion.service.isEmpty()) + { + warning(tr("Since the save path is linked to service, you need to select a service before you can select a folder")); + return false; + } + + // Asking for directory to save files + path = dialog.getExistingDirectory(this, tr("Choose folder where to save file"), QDir::homePath(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + if (!path.isEmpty()) + { + this->downloading.savePath = path; + if (!this->connexion.service.isEmpty() and !this->connexion.server.isEmpty()) + { + // saving save path in settings + folder = "Folder/" + this->connexion.server + "/" + this->connexion.service; + this->settings.setValue(folder, this->downloading.savePath); + this->settings.sync(); + } + }else + { + return false; + } + return true; } // Activated when menu "settings" is clicked void MainWindow::on_action_Settings_triggered() { + info(DEBUGMACRO, "on_action_Settings_triggered() => Activated when menu 'settings' is clicked"); + config.UnitCombobox->setCurrentIndex(this->connexion.bandwidthLimitUnit); config.spinBox->setValue(this->connexion.bandwidthLimit); Configuration.show(); @@ -1289,16 +1415,18 @@ void MainWindow::on_buttonBox_accepted() QString unit; QString bw; + info(DEBUGMACRO, "on_buttonBox_accepted() => Acivated when 'Ok' is clicked in Configuration window"); + bw = config.spinBox->text(); if (bw.toInt() == 0) { - // bandwidth = 0 - this->connexion.bandwidthLimit = 0; - this->connexion.bandwidthLimitUnit = 0; + // bandwidth = 0 + this->connexion.bandwidthLimit = 0; + this->connexion.bandwidthLimitUnit = 0; }else { - this->connexion.bandwidthLimit = config.spinBox->value(); - this->connexion.bandwidthLimitUnit = config.UnitCombobox->currentIndex(); + this->connexion.bandwidthLimit = config.spinBox->value(); + this->connexion.bandwidthLimitUnit = config.UnitCombobox->currentIndex(); } this->settings.setValue("bandwidthlimit", this->connexion.bandwidthLimit); this->settings.setValue("bandwidthlimitunit", this->connexion.bandwidthLimitUnit); @@ -1314,6 +1442,7 @@ void MainWindow::saveDownloadList() { int nRows; + info(DEBUGMACRO, "saveDownloadList() => Saving download list"); // remove list of downloads this->settings.remove("Downloads/"); @@ -1323,7 +1452,7 @@ void MainWindow::saveDownloadList() this->settings.setValue("rows", nRows); for (int i = 0; i < nRows; i++) { - this->settings.setValue(QString::number(i), ui->listDownload->item(i)->text()); + this->settings.setValue(QString::number(i), ui->listDownload->item(i)->text()); } this->settings.endGroup(); this->settings.sync(); @@ -1336,12 +1465,14 @@ void MainWindow::loadDownloadList() QString str; int pos; + info(DEBUGMACRO, "loadDownloadList() => loading download list"); + this->settings.sync(); this->settings.beginGroup("Downloads"); int size = this->settings.value("rows").toInt(); for (int i = 0; i < size; ++i) { - ui->listDownload->addItem(this->settings.value(QString::number(i)).toString()); + ui->listDownload->addItem(this->settings.value(QString::number(i)).toString()); } this->settings.endGroup(); @@ -1357,14 +1488,23 @@ void MainWindow::loadDownloadList() str = "Folder/" + this->downloading.server + "/" + this->downloading.service; if (this->settings.contains(str)) { - this->downloading.savePath = this->settings.value(str).toString(); + this->downloading.savePath = this->settings.value(str).toString(); } startDownloading(); } +// Deleting download list +void MainWindow::deleteDownloadList() +{ + info(DEBUGMACRO, "deleteDownloadList() => Deleting existing download list"); + this->settings.remove("Downloads"); +} + // clear object downloading void Connexion::clear() { + info(DEBUGMACRO, "clear() => clear object 'downloading'"); + this->path.clear(); this->server.clear(); this->savePath.clear(); @@ -1385,30 +1525,26 @@ void MainWindow::on_actionDownload_triggered() on_treeWidget_itemClicked(item, true); } -/*void MainWindow::downloadingErrorSlot(QString errorString) -{ - QMessageBox::warning( - this, - a.applicationName(), - errorString, - QMessageBox::Ok, - QMessageBox::Ok); -} -*/ - // Change toolbar style void MainWindow::on_comboBox_currentIndexChanged(int index) { + info(DEBUGMACRO, "on_comboBox_currentIndexChanged()"); + ui->toolBar->setToolButtonStyle((Qt::ToolButtonStyle)index); } void MainWindow::on_actionExit_triggered() { + info(DEBUGMACRO, "on_actionExit_triggered() => slot activated when button exit clicked"); + + this->exiting = true; quitApp(); } void MainWindow::setDlSpeed(QString speed) { + info(DEBUGMACRO, "setDlSpeed(= => setting download speed"); + speed.squeeze(); } @@ -1416,22 +1552,41 @@ void MainWindow::on_actionHiddenService_triggered() { QInputDialog hiddenFolderDialog; + info(DEBUGMACRO, "on_actionHiddenService_triggered() => activated when the 'hidden service' button"); + bool ok; QString text = QInputDialog::getText(this, a.applicationName() + tr(" Request"), - tr("Hidden service name"), QLineEdit::Normal, - "test", &ok); + tr("Hidden service name"), QLineEdit::Normal, + "test", &ok); if (ok && !text.isEmpty()) { - this->connexion.service = text; - this->settings.setValue("Hidden/" + this->connexion.server + '/' + text, true); - ui->listWidget->addItem(text + "\n\t"); - preparePopulateTree(); + this->connexion.service = text; + this->settings.setValue("Hidden/" + this->connexion.server + '/' + text, true); + ui->listWidget->addItem(text + "\n\t"); + preparePopulateTree(); } } - -void MainWindow::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) +void MainWindow::on_khistorycombobox_currentTextChanged(const QString &server) { - cout << "double-clicked" << endl; + /*info(DEBUGMACRO, "on_khistorycombobox_currenTextChanged() => Starting connexion to new server"); + if (this->initialization == false) + { + populateList(server, connexion.port); + }*/ } + +void MainWindow::on_khistorycombobox_editTextChanged(const QString &server) +{ + /*info(DEBUGMACRO, "on_khistorycombobox_currenTextChanged() => Starting connexion to new server"); + if (this->initialization == false) + { + populateList(server, connexion.port); + }*/ +} + +void MainWindow::on_return_pressed(const QString &server) +{ + info(DEBUGMACRO, "On_return_pressed"); +} diff --git a/mainwindow.h b/mainwindow.h index 392208e..2d05a8c 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -51,9 +51,9 @@ extern QMap rsyncErrorStrings; class Connexion { - public: - int bandwidthLimit = 0; - int bandwidthLimitUnit; + public: + int bandwidthLimit = 0; + int bandwidthLimitUnit; int contimeout = 20; QString server; QString service; @@ -70,9 +70,9 @@ class Connexion class Downloading { - public: - QString server; - QString service; + public: + QString server; + QString service; QString path; QString savePath; QString user; @@ -86,9 +86,9 @@ class Downloading class About { - public: - QString version; - QString author = "Daniel TARTAVEL-JEANNOT"; + public: + QString version; + QString author = "Daniel TARTAVEL-JEANNOT"; QString licence = "GPL_V3"; QString description; QString email = "dtux@free.fr"; @@ -99,9 +99,9 @@ class MainWindow : public QMainWindow { Q_OBJECT - public: - Ui::MainWindow *ui; - MainWindow(QWidget *parent = nullptr); + public: + Ui::MainWindow *ui; + MainWindow(QWidget *parent = nullptr); ~MainWindow(); // passwdManager; QProgressDialog *progress; @@ -124,30 +124,30 @@ class MainWindow : public QMainWindow QList UnitText { - tr("B"), - tr("KB"), - tr("MB"), - tr("GB"), - tr("TB"), - tr("PB") + tr("B"), + tr("KB"), + tr("MB"), + tr("GB"), + tr("TB"), + tr("PB") }; QList bwUnitChar { - 'K', - 'M', - 'T', - 'G', - 'P' + 'K', + 'M', + 'T', + 'G', + 'P' }; QVector downloadProcessErrorString = { - tr("The process failed to start. Either the invoked program is missing, or you may have insufficient permissions or resources to invoke the program."), - tr("The process crashed some time after starting successfully."), - tr("The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again."), - tr("An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel."), - tr("An error occurred when attempting to read from the process. For example, the process may not be running."), - tr("An unknown error occurred. This is the default return value of error().") + tr("The process failed to start. Either the invoked program is missing, or you may have insufficient permissions or resources to invoke the program."), + tr("The process crashed some time after starting successfully."), + tr("The last waitFor...() function timed out. The state of QProcess is unchanged, and you can try calling waitFor...() again."), + tr("An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel."), + tr("An error occurred when attempting to read from the process. For example, the process may not be running."), + tr("An unknown error occurred. This is the default return value of error().") }; void displayTree(); @@ -175,7 +175,7 @@ class MainWindow : public QMainWindow void passwordStore (QString account, QString password); QString passwordGet (QString account); - private slots: + private slots: void on_listWidget_clicked(); @@ -223,7 +223,11 @@ class MainWindow : public QMainWindow void on_khistorycombobox_currentTextChanged(const QString &arg1); -signals: + void on_khistorycombobox_editTextChanged(const QString &arg1); + + void on_return_pressed(const QString &server); + + signals: void stopDownloading(QProcess *); void progressSignal(int); void speed(QString); diff --git a/password.cpp b/password.cpp index beb6cf5..8f2fde3 100644 --- a/password.cpp +++ b/password.cpp @@ -3,6 +3,7 @@ #include #include #include +#include "tools.h" using namespace std; extern QApplication a; @@ -13,43 +14,40 @@ static QSettings sett{appName, appName}; void setPassword(QString account, QString pass) { - QKeychain::WritePasswordJob write(appName); - write.setSettings(&sett); - // write.setAutoDelete(false); - write.setKey(account); - write.setTextData(pass); + QKeychain::WritePasswordJob write(appName); + write.setSettings(&sett); + write.setKey(account); + write.setTextData(pass); - QEventLoop loop; - write.connect(&write, &QKeychain::WritePasswordJob::finished, &loop, &QEventLoop::quit); + QEventLoop loop; + write.connect(&write, &QKeychain::WritePasswordJob::finished, &loop, &QEventLoop::quit); - write.start(); - loop.exec(); + write.start(); + loop.exec(); - if(write.error()) - cout << "Error writing key1. Error: " << write.errorString().toStdString(); + if(write.error()) + info(DEBUGMACRO, "Error writing key1. Error: " + write.errorString()); } QString getPassword(const QString& name) { - QKeychain::ReadPasswordJob readPass(appName); - readPass.setSettings(&sett); - // readPass.setAutoDelete(false); - readPass.setKey(name); + QKeychain::ReadPasswordJob readPass(appName); + readPass.setSettings(&sett); + readPass.setKey(name); - QEventLoop loop; - readPass.connect(&readPass, &QKeychain::ReadPasswordJob::finished, &loop, &QEventLoop::quit); + QEventLoop loop; + readPass.connect(&readPass, &QKeychain::ReadPasswordJob::finished, &loop, &QEventLoop::quit); - readPass.start(); - loop.exec(); + readPass.start(); + loop.exec(); - if(readPass.error()) - { - cout << "KeyHandler~Error reading decrypt Pass. Error: " + readPass.errorString() . toStdString() << endl; - return ""; - } - else - { - QString data = readPass.textData(); - return data; - } + if(readPass.error()) + { + info(DEBUGMACRO, "KeyHandler~Error reading decrypt Pass. Error: " + readPass.errorString()); + return ""; + }else + { + QString data = readPass.textData(); + return data; + } } diff --git a/password.h b/password.h index db45a69..de19d4a 100644 --- a/password.h +++ b/password.h @@ -1,7 +1,8 @@ #ifndef PASSWORD_H #define PASSWORD_H -#include "mainwindow.h" +//#include "mainwindow.h" +#include "qapplication.h" #include #include diff --git a/tools.cpp b/tools.cpp index 6690291..55afc9f 100644 --- a/tools.cpp +++ b/tools.cpp @@ -1,4 +1,6 @@ #include "mainwindow.h" +#include "tools.h" +#include "password.h" using namespace std; @@ -12,18 +14,33 @@ extern QApplication a; // return true in case of error bool testRsyncReturn(MainWindow * w, QProcess * myProcess) { + info(DEBUGMACRO, "testRsyncReturn()"); + info(DEBUGMACRO, "Exit status: " + QString::number(myProcess->exitStatus())); + info(DEBUGMACRO, "Exit code: " + QString::number(myProcess->exitCode())); + if (myProcess->exitStatus() != 0 and w->stopDlAsked != true) { - qInfo("rsync error %i : %s ", + myProcess->error(), myProcess->errorString().toStdString().c_str()); + info(DEBUGMACRO, "rsync error " + myProcess->errorString()); QMessageBox::warning( w, a.applicationName(), - rsyncErrorStrings[myProcess->error()], + QTranslator::tr("Rsync error:\n") + rsyncErrorStrings[myProcess->error()], //myProcess->errorString(), QMessageBox::Ok, QMessageBox::Ok); return true; } + if(myProcess->exitCode() != 0) + { + info(DEBUGMACRO, "rsync error " + myProcess->errorString()); + QMessageBox::warning( + w, + a.applicationName(), + QTranslator::tr("Rsync error:\n") + rsyncErrorStrings[myProcess->exitCode()], + QMessageBox::Ok, + QMessageBox::Ok); + return true; + } w->stopDlAsked = false; return false; } @@ -42,7 +59,7 @@ int whatIpVersion(QString ipAddress) ulong field; uint i; - qInfo("ipVersion %s", ipAddress.toStdString().c_str()); + info(DEBUGMACRO, "ipVersion of server at " + ipAddress); fieldList = ipAddress.split(":"); if (fieldList.count() == 8) @@ -55,7 +72,7 @@ int whatIpVersion(QString ipAddress) return 0; } } - qInfo("Address is Ip V6"); + info(DEBUGMACRO, "Address is Ip V6"); return 6; } fieldList = ipAddress.split("."); @@ -69,8 +86,35 @@ int whatIpVersion(QString ipAddress) return 0; } } - qInfo("Address is ip V4"); + info(DEBUGMACRO, "Address is ip V4"); return 4; } return 0; } + +void warning(QString message) +{ + QMessageBox::warning( + NULL, + a.applicationName() + "", + message, + QMessageBox::Ok, + QMessageBox::Ok); +} + +void error(QString message) +{ + QMessageBox::warning( + NULL, + a.applicationName() + ":" + QTranslator::tr("Error"), + message, + QMessageBox::Ok, + QMessageBox::Ok); +} + +void info(QString debugHeader, QString message) +{ + qInfo("%s %s", debugHeader.toStdString().c_str(), message.toStdString().c_str()); +} + +//void error() diff --git a/tools.h b/tools.h index dc8e25d..6feca4a 100644 --- a/tools.h +++ b/tools.h @@ -1,6 +1,8 @@ #ifndef TOOLS_H #define TOOLS_H +#define DEBUGMACRO QString(__FILE__) + "->" + QString(Q_FUNC_INFO) + ": " + QString::number(__LINE__) + " -" + #include #include #include @@ -10,15 +12,15 @@ #include #include #include +#include "mainwindow.h" using namespace std; -FILE * popen2(array argv, string type, int & pid); - -int pclose2(FILE * fp, pid_t pid); - bool testRsyncReturn(MainWindow *, QProcess *); -QString getFileType(QString finename); -int whatIpVersion(QString); +QString getFileType(QString filename); +int whatIpVersion(QString server); +void warning(QString message); +void error(QString message); +void info(QString debugHeader, QString message); #endif // TOOLS_H