├── debian ├── docs ├── compat ├── README.Debian ├── control ├── changelog ├── copyright └── rules ├── .gitignore ├── po ├── ar.mo ├── bg.mo ├── bn.mo ├── cs.mo ├── de.mo ├── es.mo ├── fo.mo ├── fr.mo ├── he.mo ├── hi.mo ├── hu.mo ├── id.mo ├── it.mo ├── ja.mo ├── ko.mo ├── lv.mo ├── ms.mo ├── nl.mo ├── pl.mo ├── ru.mo ├── sv.mo ├── tr.mo ├── uk.mo ├── ur.mo ├── pt_BR.mo ├── buildmo.sh ├── CMakeLists.txt └── updatepo.sh ├── mac ├── background.png └── create_dmg ├── resources ├── RipStop │ ├── logo │ │ └── about.png │ ├── menubar │ │ ├── new.png │ │ ├── about.png │ │ ├── error.png │ │ ├── find.png │ │ ├── graph.png │ │ ├── help.png │ │ ├── pause.png │ │ ├── quit.png │ │ ├── remove.png │ │ ├── start.png │ │ ├── stop.png │ │ ├── copydata.png │ │ ├── copyurl.png │ │ ├── details.png │ │ ├── options.png │ │ ├── pasteurl.png │ │ ├── schedule.png │ │ ├── startall.png │ │ ├── stopall.png │ │ ├── completed.png │ │ ├── downloading.png │ │ ├── progressbar.png │ │ ├── properties.png │ │ └── scheduled.png │ ├── icon │ │ ├── wxdfast.icns │ │ ├── wxdfast.ico │ │ ├── wxdfast.png │ │ └── wxdfast.svg │ ├── toolbar │ │ ├── download_info.png │ │ ├── download_new.png │ │ ├── download_stop.png │ │ ├── download_move_up.png │ │ ├── download_remove.png │ │ ├── download_start.png │ │ ├── download_move_down.png │ │ ├── download_schedule.png │ │ ├── download_start_all.png │ │ └── download_stop_all.png │ ├── readme.txt │ └── license.txt ├── extensionid ├── wxdfast.desktop ├── CMakeLists.txt └── Info.plist ├── AUTHORS ├── config.h.cmake ├── extension ├── remove_config.bat └── add_config.bat ├── ChangeLog ├── README.md ├── src ├── IpcDefs.h ├── wxjson │ ├── CMakeLists.txt │ └── include │ │ └── wx │ │ ├── jsonwriter.h │ │ ├── jsonreader.h │ │ └── json_defs.h ├── widgets │ ├── dxtoolbar.h │ ├── dxtoolbar.cpp │ ├── dxlistctrl.h │ └── dxlistctrl.cpp ├── hash │ ├── hash.h │ └── hash.cpp ├── Graph.h ├── Progress.h ├── resource.rc ├── ScheduleException.h ├── UtilFunctions.h ├── Icons.h ├── BatchDialog.h ├── Defs.h ├── NewDialog.h ├── OptionsDialog.h ├── Progress.cpp ├── FileInfo.h ├── Engine.h ├── Graph.cpp ├── Icons.cpp ├── Options.h ├── wxDFast.h ├── BatchDialog.cpp ├── UtilFunctions.cpp ├── FileInfo.cpp └── Engine.cpp ├── cmake └── uninstall.cmake.in ├── win ├── installwxdfast └── wxdfast.iss ├── wxdfast.spec ├── integrator └── CMakeLists.txt └── CMakeLists.txt /debian/docs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /po/ar.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/ar.mo -------------------------------------------------------------------------------- /po/bg.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/bg.mo -------------------------------------------------------------------------------- /po/bn.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/bn.mo -------------------------------------------------------------------------------- /po/cs.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/cs.mo -------------------------------------------------------------------------------- /po/de.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/de.mo -------------------------------------------------------------------------------- /po/es.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/es.mo -------------------------------------------------------------------------------- /po/fo.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/fo.mo -------------------------------------------------------------------------------- /po/fr.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/fr.mo -------------------------------------------------------------------------------- /po/he.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/he.mo -------------------------------------------------------------------------------- /po/hi.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/hi.mo -------------------------------------------------------------------------------- /po/hu.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/hu.mo -------------------------------------------------------------------------------- /po/id.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/id.mo -------------------------------------------------------------------------------- /po/it.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/it.mo -------------------------------------------------------------------------------- /po/ja.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/ja.mo -------------------------------------------------------------------------------- /po/ko.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/ko.mo -------------------------------------------------------------------------------- /po/lv.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/lv.mo -------------------------------------------------------------------------------- /po/ms.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/ms.mo -------------------------------------------------------------------------------- /po/nl.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/nl.mo -------------------------------------------------------------------------------- /po/pl.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/pl.mo -------------------------------------------------------------------------------- /po/ru.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/ru.mo -------------------------------------------------------------------------------- /po/sv.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/sv.mo -------------------------------------------------------------------------------- /po/tr.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/tr.mo -------------------------------------------------------------------------------- /po/uk.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/uk.mo -------------------------------------------------------------------------------- /po/ur.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/ur.mo -------------------------------------------------------------------------------- /po/pt_BR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/po/pt_BR.mo -------------------------------------------------------------------------------- /mac/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/mac/background.png -------------------------------------------------------------------------------- /resources/RipStop/logo/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/logo/about.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/new.png -------------------------------------------------------------------------------- /resources/RipStop/icon/wxdfast.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/icon/wxdfast.icns -------------------------------------------------------------------------------- /resources/RipStop/icon/wxdfast.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/icon/wxdfast.ico -------------------------------------------------------------------------------- /resources/RipStop/icon/wxdfast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/icon/wxdfast.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/about.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/error.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/find.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/graph.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/help.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/pause.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/quit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/quit.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/remove.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/start.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/stop.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/copydata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/copydata.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/copyurl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/copyurl.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/details.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/details.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/options.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/pasteurl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/pasteurl.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/schedule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/schedule.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/startall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/startall.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/stopall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/stopall.png -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | AUTHORS 2 | ------- 3 | 4 | Max Magalhães Velasques 5 | David Vachulka -------------------------------------------------------------------------------- /resources/RipStop/menubar/completed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/completed.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/downloading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/downloading.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/progressbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/progressbar.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/properties.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/properties.png -------------------------------------------------------------------------------- /resources/RipStop/menubar/scheduled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/menubar/scheduled.png -------------------------------------------------------------------------------- /resources/extensionid: -------------------------------------------------------------------------------- 1 | blddhoccpjdmfjhoedgoopccicopnjbc 2 | kpijmhekjhfhdngjfhcgjoleekefmomb 3 | dncifgibkggaiflipilmikckmfkjonle 4 | -------------------------------------------------------------------------------- /resources/RipStop/toolbar/download_info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/toolbar/download_info.png -------------------------------------------------------------------------------- /resources/RipStop/toolbar/download_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/toolbar/download_new.png -------------------------------------------------------------------------------- /resources/RipStop/toolbar/download_stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/toolbar/download_stop.png -------------------------------------------------------------------------------- /resources/RipStop/toolbar/download_move_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/toolbar/download_move_up.png -------------------------------------------------------------------------------- /resources/RipStop/toolbar/download_remove.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/toolbar/download_remove.png -------------------------------------------------------------------------------- /resources/RipStop/toolbar/download_start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/toolbar/download_start.png -------------------------------------------------------------------------------- /resources/RipStop/toolbar/download_move_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/toolbar/download_move_down.png -------------------------------------------------------------------------------- /resources/RipStop/toolbar/download_schedule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/toolbar/download_schedule.png -------------------------------------------------------------------------------- /resources/RipStop/toolbar/download_start_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/toolbar/download_start_all.png -------------------------------------------------------------------------------- /resources/RipStop/toolbar/download_stop_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archdvx/wxdfast/HEAD/resources/RipStop/toolbar/download_stop_all.png -------------------------------------------------------------------------------- /po/buildmo.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | for i in *.po 4 | do 5 | echo "Generating ${i%.po}.mo ..." 6 | rm ${i%.po}.mo 7 | msgfmt $i -o ${i%.po}.mo 8 | done 9 | -------------------------------------------------------------------------------- /resources/RipStop/readme.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2006, by Erno Szabados chromecat@freemail.hu 2 | See license.txt for conditions on usage. 3 | This is the "Ripstop" icon set for wxdownloads, version 0.2 released at 20061101. 4 | See http://dfast.sourceforge.net 5 | -------------------------------------------------------------------------------- /po/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 3.7) 2 | 3 | foreach(lang ${LANGS}) 4 | install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/${lang}.mo" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/locale/${lang}/LC_MESSAGES" RENAME "wxdfast.mo") 5 | endforeach(lang) 6 | 7 | -------------------------------------------------------------------------------- /config.h.cmake: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_H 2 | #define CONFIG_H 3 | 4 | #define PROGRAM_NAME "wxDownload Fast" 5 | #define PACKAGE "wxdfast" 6 | #define VERSION "${PROJECT_VERSION}" 7 | #define GTKV "${GTK_VERSION}" 8 | #define ARIA2V "${LIBARIA2_VERSION}" 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /debian/README.Debian: -------------------------------------------------------------------------------- 1 | wxdfast for Debian 2 | ----------------- 3 | 4 | Caution : this is NOT an official Debian package! 5 | This package is just released to provide the last wxdfast version. 6 | 7 | -- David Vachulka Sun, 1 August 2021 13:13:13 +0200 8 | -------------------------------------------------------------------------------- /resources/wxdfast.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Encoding=UTF-8 4 | Name=wxDownload Fast 5 | GenericName=wxDFast 6 | Comment=Multithreaded Download Manager 7 | Exec=wxdfast 8 | TryExec=wxdfast 9 | Icon=wxdfast 10 | Terminal=false 11 | Type=Application 12 | Categories=Network;FileTransfer; 13 | -------------------------------------------------------------------------------- /extension/remove_config.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | :: Delete JSON config files 4 | DEL com.wxdfast.chrome.json 5 | DEL com.wxdfast.firefox.json 6 | 7 | :: Delete registry entries 8 | REG DELETE HKCU\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.wxdfast.chrome /f 9 | REG DELETE HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\com.wxdfast.firefox /f -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | Version 0.70.4 (released 05-29-2022) 2 | - Fixed issue #103 3 | - Fixed OSSL_DEPRECATEDIN_3_0 4 | 5 | Version 0.70.3 (released 09-18-2021) 6 | - Fixed issue #102 7 | 8 | Version 0.70.2 (released 09-14-2021) 9 | - Fixed issue #101 10 | 11 | Version 0.70.1 (released 08-24-2021) 12 | - File hashes now calculated by openssl 13 | 14 | Version 0.70.0 (released 08-21-2021) 15 | - Program rewritten with Aria2 as download backend 16 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: wxdfast 2 | Section: net 3 | Priority: extra 4 | Maintainer: David Vachulka 5 | Build-Depends: debhelper (>= 9), cmake, pkg-config, libwxgtk3.0-dev, libaria2-0-dev 6 | Standards-Version: 3.8.4 7 | Homepage: https://wxdfast.dxsolutions.org 8 | 9 | Package: wxdfast 10 | Architecture: any 11 | Depends: ${shlibs:Depends}, ${misc:Depends} 12 | Description: Multithreaded download manager. 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **wxDownload Fast** is multithreaded download manager written in C++ using [wxWidgets](https://wxwidgets.org/) and [Aria2](https://aria2.github.io/). It supports **HTTP/HTTPS, FTP, SFTP** and **Metalink**. 2 | 3 | This is continue/fork of old [program](http://dfast.sourceforge.net/). 4 | 5 | More [information](https://wxdfast.dxsolutions.org). 6 | 7 | For Linux binaries visit [our repository](https://build.opensuse.org/project/show/home:dvx13) 8 | 9 | -------------------------------------------------------------------------------- /src/IpcDefs.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: IpcDefs.h 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2021 5 | * License: GPL2 6 | **************************************************************/ 7 | 8 | #ifndef IPCDEFS_H 9 | #define IPCDEFS_H 10 | 11 | #define IPC_SERVICE 24242 12 | #define ICP_SERVICE_STR "24242" 13 | #define MAX_BUFF_LEN 1024 14 | 15 | #endif // IPCDEFS_H 16 | -------------------------------------------------------------------------------- /mac/create_dmg: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | test -f ../../wxDownloadFast-0.70.4.dmg && rm ../../wxDownloadFast-0.70.4.dmg 3 | create-dmg \ 4 | --window-size 500 300 \ 5 | --background ./background.png \ 6 | --text-size 14 \ 7 | --icon-size 128 \ 8 | --volname wxDownloadFast-0.70.4 \ 9 | --volicon ../resources/RipStop/icon/wxdfast.icns \ 10 | --icon wxDownloadFast.app 125 150 \ 11 | --app-drop-link 385 150 \ 12 | ../../wxDownloadFast-0.70.4.dmg \ 13 | ../build-release 14 | -------------------------------------------------------------------------------- /po/updatepo.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | INPUT=`find ../src -type f -name *.cpp` 4 | 5 | xgettext -C --from-code=UTF-8 --msgid-bugs-address=archdvx@dxsolutions.org --package-name=wxdfast\ 6 | --package-version=0.70.3 --copyright-holder="David Vachulka" --keyword=_ --keyword=N_ --keyword=_n:1,2\ 7 | --keyword=wxPLURAL:1,2 -o wxdfast.pot $INPUT 8 | 9 | for i in *.po 10 | do 11 | echo "Updating $i ..." 12 | msgmerge --update --backup=off $i wxdfast.pot 13 | done 14 | find . -name '*.po' -print0 | while read -d '' -r file; do msgattrib --output-file="$file" --no-obsolete "$file"; done 15 | -------------------------------------------------------------------------------- /src/wxjson/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 3.7) 2 | project(wxjson) 3 | 4 | set(wxjson_SOURCES 5 | src/jsonreader.cpp 6 | src/jsonval.cpp 7 | src/jsonwriter.cpp 8 | ) 9 | 10 | add_library(wxjson STATIC ${wxjson_SOURCES}) 11 | target_include_directories(wxjson SYSTEM PUBLIC include) 12 | target_link_libraries(wxjson PUBLIC ${wxWidgets_LIBRARIES}) 13 | 14 | include_directories( 15 | ./include 16 | ) 17 | 18 | get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) 19 | set(WXJSON_LIBRARIES wxjson CACHE INTERNAL "") 20 | set(WXJSON_INCLUDE_DIRS ${dirs} CACHE INTERNAL "") 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/widgets/dxtoolbar.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: dxtoolbar.h 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2021 5 | * License: GPL3 6 | **************************************************************/ 7 | 8 | #ifndef DXTOOLBAR_H 9 | #define DXTOOLBAR_H 10 | 11 | #ifndef WX_PRECOMP 12 | #include 13 | #endif 14 | 15 | class dxToolBar: public wxToolBar 16 | { 17 | public: 18 | dxToolBar(wxWindow *parent); 19 | 20 | private: 21 | #if defined (__WXMAC__) 22 | void OnToolbarPaint(wxPaintEvent& event); 23 | #endif 24 | }; 25 | 26 | #endif /* DXTOOLBAR_H */ 27 | 28 | -------------------------------------------------------------------------------- /src/hash/hash.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: hash.h 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2021 5 | * License: GPL2 6 | **************************************************************/ 7 | 8 | #ifndef WX_PRECOMP 9 | #include 10 | #endif 11 | #include 12 | 13 | #ifndef MHASH_H 14 | #define MHASH_H 15 | 16 | 17 | class mHash 18 | { 19 | public: 20 | mHash(); 21 | 22 | static wxString MD5(const wxString &path); 23 | static wxString SHA1(const wxString &path); 24 | static wxString SHA256(const wxString &path); 25 | }; 26 | 27 | #endif // MHASH_H 28 | -------------------------------------------------------------------------------- /resources/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 3.7) 2 | 3 | if(NOT WIN32 AND NOT APPLE) 4 | install(FILES wxdfast.desktop DESTINATION share/applications) 5 | endif(NOT WIN32 AND NOT APPLE) 6 | install(FILES RipStop/icon/wxdfast.png DESTINATION share/icons/hicolor/48x48/apps) 7 | install(FILES RipStop/icon/wxdfast.svg DESTINATION share/icons/hicolor/scalable/apps) 8 | install(FILES RipStop/icon/wxdfast.png DESTINATION share/wxdfast/icons) 9 | install(FILES extensionid DESTINATION share/wxdfast) 10 | install(DIRECTORY RipStop/logo/ DESTINATION share/wxdfast/icons/logo FILES_MATCHING PATTERN "*.png") 11 | install(DIRECTORY RipStop/menubar/ DESTINATION share/wxdfast/icons/menubar FILES_MATCHING PATTERN "*.png") 12 | install(DIRECTORY RipStop/toolbar/ DESTINATION share/wxdfast/icons/toolbar FILES_MATCHING PATTERN "*.png") 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | wxdfast (0.70.4-1) unstable; urgency=low 2 | 3 | * Development release 4 | 5 | -- David Vachulka Sat, 29 May 2022 13:13:13 +0100 6 | 7 | wxdfast (0.70.3-1) unstable; urgency=low 8 | 9 | * Development release 10 | 11 | -- David Vachulka Sat, 18 Sep 2021 13:13:13 +0100 12 | 13 | wxdfast (0.70.2-1) unstable; urgency=low 14 | 15 | * Development release 16 | 17 | -- David Vachulka Tue, 14 Sep 2021 13:13:13 +0100 18 | 19 | wxdfast (0.70.1-1) unstable; urgency=low 20 | 21 | * Development release 22 | 23 | -- David Vachulka Tue, 24 Aug 2021 13:13:13 +0100 24 | 25 | wxdfast (0.70.0-1) unstable; urgency=low 26 | 27 | * Development release 28 | 29 | -- David Vachulka Sun, 1 Aug 2021 13:13:13 +0100 30 | -------------------------------------------------------------------------------- /src/Graph.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: Graph.h 3 | * Author: Max Magalhães Velasques (maxvelasques@gmail.com) 4 | * David Vachulka (archdvx@dxsolutions.org) 5 | * Copyright: 2006 6 | * License: GPL2 7 | **************************************************************/ 8 | 9 | #ifndef WX_PRECOMP 10 | #include 11 | #endif 12 | #include 13 | 14 | #ifndef MGRAPH_H 15 | #define MGRAPH_H 16 | 17 | class mGraph : public wxPanel 18 | { 19 | DECLARE_DYNAMIC_CLASS(mGraph) 20 | DECLARE_EVENT_TABLE() 21 | public: 22 | mGraph() : wxPanel(nullptr) {} 23 | explicit mGraph(wxWindow *parent); 24 | 25 | void OnPaint(wxPaintEvent &event); 26 | void AddDownloadPoint(int point); 27 | void AddUploadPoint(int point); 28 | private: 29 | std::vector m_downloadpoints; 30 | std::vector m_uploadpoints; 31 | }; 32 | 33 | #endif // MGRAPH_H 34 | -------------------------------------------------------------------------------- /src/widgets/dxtoolbar.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: dxtoolbar.cpp 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2021 5 | * License: GPL3 6 | **************************************************************/ 7 | 8 | #include "dxtoolbar.h" 9 | 10 | dxToolBar::dxToolBar(wxWindow *parent) 11 | : wxToolBar(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL|wxTB_FLAT|wxTB_NODIVIDER|wxTB_TEXT) 12 | { 13 | #if defined (__WXMAC__) 14 | Connect(wxEVT_PAINT, wxPaintEventHandler(dxToolBar::OnToolbarPaint), nullptr, this); 15 | #endif 16 | } 17 | 18 | #if defined (__WXMAC__) 19 | void dxToolBar::OnToolbarPaint(wxPaintEvent &event) 20 | { 21 | wxWindow* pWnd = (wxWindow*)event.GetEventObject(); 22 | wxPaintDC dc(pWnd); 23 | wxBrush brush(pWnd->GetParent()->GetBackgroundColour()); 24 | dc.SetBackground(brush); 25 | dc.Clear(); 26 | } 27 | #endif 28 | -------------------------------------------------------------------------------- /src/Progress.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: Progress.h 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2021 5 | * License: GPL2 6 | **************************************************************/ 7 | 8 | #ifndef WX_PRECOMP 9 | #include 10 | #endif 11 | 12 | #ifndef MPROGRESS_H 13 | #define MPROGRESS_H 14 | 15 | class mProgress : public wxPanel 16 | { 17 | DECLARE_DYNAMIC_CLASS(mGraph) 18 | DECLARE_EVENT_TABLE() 19 | public: 20 | mProgress() : wxPanel(nullptr) {} 21 | explicit mProgress(wxWindow *parent); 22 | 23 | void OnPaint(wxPaintEvent &event); 24 | std::string bitfield() const; 25 | void setBitfield(const std::string &bitfield); 26 | int numpieces() const; 27 | void setNumpieces(int numpieces); 28 | bool finished() const; 29 | void setFinished(bool finished); 30 | private: 31 | std::string m_bitfield; 32 | int m_numpieces; 33 | bool m_finished; 34 | }; 35 | 36 | #endif // MPROGRESS_H 37 | -------------------------------------------------------------------------------- /src/resource.rc: -------------------------------------------------------------------------------- 1 | dxde ICON "../resources/RipStop/icon/wxdfast.ico" 2 | 3 | #include "wx/msw/wx.rc" 4 | 5 | VS_VERSION_INFO VERSIONINFO 6 | FILEVERSION 0,70,4,0 7 | PRODUCTVERSION 0,70,4,0 8 | FILEFLAGSMASK 0x17L 9 | FILEFLAGS 0x0L 10 | FILEOS 0x4L 11 | FILETYPE 0x1L 12 | FILESUBTYPE 0x0L 13 | BEGIN 14 | BLOCK "StringFileInfo" 15 | BEGIN 16 | BLOCK "000004b0" 17 | BEGIN 18 | VALUE "Comments", "Version 0.70.4" 19 | VALUE "CompanyName", "dxSolutions" 20 | VALUE "FileDescription", "Multithread download manager" 21 | VALUE "FileVersion", "0.70.4" 22 | VALUE "InternalName", "wxDFast" 23 | VALUE "LegalCopyright", "Max Velasques, David Vachulka" 24 | VALUE "OriginalFilename", "wxdfast.exe" 25 | VALUE "ProductName", "wxDownload Fast" 26 | VALUE "ProductVersion", "0.70.4" 27 | END 28 | END 29 | BLOCK "VarFileInfo" 30 | BEGIN 31 | VALUE "Translation", 0x0, 1200 32 | END 33 | END 34 | -------------------------------------------------------------------------------- /extension/add_config.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | @setlocal enableextensions 4 | @cd /d "%~dp0" 5 | 6 | SET "current_path=%~dp0wxdfast-integrator.exe" 7 | SET "current_path=%current_path:\=\\%" 8 | 9 | :: Create JSON config files 10 | @echo {"name":"com.wxdfast.chrome","description":"Integrate wxDownload Fast with Google Chrome and similar","path":"%current_path%","type":"stdio","allowed_origins":["chrome-extension://blddhoccpjdmfjhoedgoopccicopnjbc/","chrome-extension://kpijmhekjhfhdngjfhcgjoleekefmomb/","chrome-extension://dncifgibkggaiflipilmikckmfkjonle/"]}> com.wxdfast.chrome.json 11 | 12 | @echo {"name":"com.wxdfast.firefox","description":"Integrate wxDownload Fast with Mozilla Firefox","path":"%current_path%","type":"stdio","allowed_extensions":["wxdfast@archdvx"]}> com.wxdfast.firefox.json 13 | 14 | :: Create required registry entries 15 | REG ADD HKCU\SOFTWARE\Google\Chrome\NativeMessagingHosts\com.wxdfast.chrome /f /ve /t REG_SZ /d "%~dp0com.wxdfast.chrome.json" 16 | REG ADD HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\com.wxdfast.firefox /f /ve /t REG_SZ /d "%~dp0com.wxdfast.firefox.json" -------------------------------------------------------------------------------- /cmake/uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | message("Uninstall the project...") 4 | 5 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 6 | message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") 7 | endif() 8 | 9 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 10 | string(REGEX REPLACE "\n" ";" files "${files}") 11 | list(REVERSE files) 12 | foreach (file ${files}) 13 | message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 14 | if(EXISTS "$ENV{DESTDIR}${file}") 15 | execute_process( 16 | COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" 17 | OUTPUT_VARIABLE rm_out 18 | RESULT_VARIABLE rm_retval 19 | ) 20 | if(NOT ${rm_retval} EQUAL 0) 21 | message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") 22 | endif (NOT ${rm_retval} EQUAL 0) 23 | else(EXISTS "$ENV{DESTDIR}${file}") 24 | message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") 25 | endif() 26 | endforeach(file) 27 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | This work was packaged for Debian by: 2 | 3 | David Vachulka on Sun, 1 August 2021 13:13:13 +0200 4 | 5 | It was downloaded from https:://wxdfast.dxsolutions.org 6 | 7 | Upstream Author(s): 8 | 9 | David Vachulka 10 | 11 | Copyright: 12 | 13 | Copyright (C) 2021 David Vachulka 14 | 15 | License: 16 | 17 | GPL 18 | 19 | The Debian packaging is: 20 | 21 | Copyright (C) 2021 David Vachulka 22 | 23 | # Please chose a license for your packaging work. If the program you package 24 | # uses a mainstream license, using the same license is the safest choice. 25 | # Please avoid to pick license terms that are more restrictive than the 26 | # packaged work, as it may make Debian's contributions unacceptable upstream. 27 | # If you just want it to be GPL version 2, leave the following lines in. 28 | 29 | and is licensed under the GPL version 2, 30 | see `/usr/share/common-licenses/GPL-2'. 31 | 32 | # Please also look if there are files or directories which have a 33 | # different copyright/license attached and list them here. 34 | -------------------------------------------------------------------------------- /src/ScheduleException.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: wxDFast.h 3 | * Author: Max Magalhães Velasques (maxvelasques@gmail.com) 4 | * David Vachulka (archdvx@dxsolutions.org) 5 | * Copyright: 2006 6 | * License: GPL2 7 | **************************************************************/ 8 | 9 | #ifndef SCHEDULEEXCEPTION_H 10 | #define SCHEDULEEXCEPTION_H 11 | 12 | #include 13 | #include "UtilFunctions.h" 14 | 15 | class mScheduleException 16 | { 17 | public: 18 | bool isactive; 19 | wxUint16 day; 20 | wxUint16 startHour; 21 | wxUint16 startMinute; 22 | wxUint16 finishHour; 23 | wxUint16 finishMinute; 24 | 25 | wxString ToWxstring() 26 | { 27 | wxString string; 28 | string << MyUtilFunctions::IntToWxstr(startHour,2) << ":" << MyUtilFunctions::IntToWxstr(startMinute,2) << " | "; 29 | string << MyUtilFunctions::IntToWxstr(finishHour,2) << ":" << MyUtilFunctions::IntToWxstr(finishMinute,2) << " | "; 30 | string << wxDateTime::GetWeekDayName(static_cast(day)); 31 | return string; 32 | } 33 | }; 34 | 35 | #endif // SCHEDULEEXCEPTION_H 36 | -------------------------------------------------------------------------------- /win/installwxdfast: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -z "$1" ]; then 3 | echo "Syntax: $0 " 1>&2 4 | exit 1 5 | fi 6 | 7 | TARGET=$1 8 | 9 | mkdir -p "$TARGET" 10 | 11 | rm -rfv "$TARGET"/* 12 | 13 | cp ../COPYING "$TARGET" 14 | 15 | cp ../extension/add_config.bat "$TARGET" 16 | cp ../extension/remove_config.bat "$TARGET" 17 | 18 | echo "Copying icons started" 19 | mkdir -p "$TARGET/icons" 20 | cp ../resources/RipStop/icon/wxdfast.png "$TARGET/icons" 21 | cp -r ../resources/RipStop/logo/ "$TARGET/icons/logo/" 22 | cp -r ../resources/RipStop/menubar/ "$TARGET/icons/menubar/" 23 | cp -r ../resources/RipStop/toolbar/ "$TARGET/icons/toolbar/" 24 | echo "Copying icons ended" 25 | 26 | echo "Copying translations started" 27 | cd ../po 28 | for i in *.po 29 | do 30 | mkdir -p "$TARGET/locale/${i%.po}/LC_MESSAGES" 31 | cp ../po/${i%.po}.mo "$TARGET/locale/${i%.po}/LC_MESSAGES/wxdfast.mo" 32 | rsync -a -m --include '*/' --include 'wx*' --exclude '*' ${MINGW_PREFIX}/share/locale/${i%.po}/LC_MESSAGES "$TARGET/locale/${i%.po}" 33 | done 34 | cd ../win 35 | echo "Copying translations ended" 36 | 37 | echo "Copying ca-certs started" 38 | mkdir -p "$TARGET/ca-certs" 39 | cp ${MINGW_PREFIX}/etc/ssl/cert.pem "$TARGET/ca-certs" 40 | echo "Copying ca-certs ended" 41 | 42 | installapp ../build "$TARGET" 43 | -------------------------------------------------------------------------------- /src/widgets/dxlistctrl.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: dxlistctrl.h 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2014 5 | * License: GPL3 6 | **************************************************************/ 7 | 8 | #ifndef DXLISTCTRL_H 9 | #define DXLISTCTRL_H 10 | 11 | #ifndef WX_PRECOMP 12 | #include 13 | #endif 14 | #include 15 | 16 | class dxListCtrl: public wxListCtrl 17 | { 18 | DECLARE_EVENT_TABLE() 19 | public: 20 | dxListCtrl(wxWindow *parent, const wxWindowID id, bool virt = true, bool resize = true); 21 | 22 | int resizeColumn() const; 23 | void setResizeColumn(int resizeColumn); 24 | int resizeColumnMinWidth() const; 25 | void setResizeColumnMinWidth(int resizeColumnMinWidth); 26 | void SetColumnHeaderFiltered(int column, bool filtered); 27 | void ClearSelection(); 28 | private: 29 | int m_resizeColumn; 30 | int m_resizeColumnMinWidth; 31 | bool m_resize; 32 | 33 | virtual wxString OnGetItemText(long item, long column) const; 34 | virtual int OnGetItemColumnImage(long item, long column) const; 35 | virtual wxListItemAttr *OnGetItemAttr(long item) const; 36 | void OnResize(wxSizeEvent& event); 37 | void resize(); 38 | }; 39 | 40 | #endif /* DXLISTCTRL_H */ 41 | 42 | -------------------------------------------------------------------------------- /resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | wxDownloadFast 9 | CFBundleGetInfoString 10 | wxDownload Fast version ${PROJECT_VERSION}, (c) 2004-2007 Max Velasques, (c) 2021 David Vachulka 11 | CFBundleIconFile 12 | wxdfast.icns 13 | CFBundleIdentifier 14 | org.wxdownloadfast.wxDownloadFast 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleLocalizations 18 | 19 | pt_BR 20 | en 21 | 22 | CFBundleLongVersionString 23 | ${PROJECT_VERSION}, (c) 2004-2007 Max Velasques, (c) 2021 David Vachulka 24 | CFBundleName 25 | wxDownloadFast 26 | CFBundlePackageType 27 | APPL 28 | CFBundleShortVersionString 29 | ${PROJECT_VERSION} 30 | CFBundleSignature 31 | ???? 32 | CFBundleVersion 33 | ${PROJECT_VERSION} 34 | CSResourcesFileMapped 35 | 36 | NSHumanReadableCopyright 37 | Copyright 2004-2007 Max Velasques, 2021 David Vachulka 38 | 39 | 40 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | # Uncomment this to turn on verbose mode. 4 | #export DH_VERBOSE=1 5 | 6 | ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) 7 | CFLAGS += -O0 8 | else 9 | CFLAGS += -O2 10 | endif 11 | 12 | builddir/Makefile: 13 | dh_testdir 14 | mkdir -p builddir 15 | # Add here commands to configure the package. 16 | cd builddir && cmake .. -DCMAKE_INSTALL_PREFIX=/usr 17 | 18 | build-arch: build 19 | build-indep: build 20 | build: build-stamp 21 | 22 | build-stamp: builddir/Makefile 23 | dh_testdir 24 | # Add here commands to compile the package. 25 | cd builddir && $(MAKE) 26 | touch $@ 27 | 28 | clean: 29 | dh_testdir 30 | dh_testroot 31 | rm -f build-stamp 32 | rm -rf builddir 33 | dh_clean 34 | 35 | install: build 36 | dh_testdir 37 | dh_testroot 38 | dh_clean -k 39 | dh_installdirs 40 | # Add here commands to install the package into debian/. 41 | cd builddir && $(MAKE) DESTDIR=$(CURDIR)/debian/wxdfast install 42 | 43 | # Build architecture-independent files here. 44 | binary-indep: build install 45 | # We have nothing to do by default. 46 | 47 | # Build architecture-dependent files here. 48 | binary-arch: build install 49 | dh_testdir 50 | dh_testroot 51 | dh_installdocs 52 | dh_installchangelogs 53 | dh_install --sourcedir=debian/wxdfast/ 54 | dh_lintian 55 | dh_link 56 | dh_compress 57 | dh_fixperms 58 | dh_shlibdeps -a 59 | dh_installdeb 60 | dh_gencontrol 61 | dh_md5sums 62 | dh_builddeb 63 | 64 | binary: binary-indep binary-arch 65 | .PHONY: build clean binary-indep binary-arch binary install configure 66 | -------------------------------------------------------------------------------- /src/UtilFunctions.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: UtilFunctions.h 3 | * Author: Max Magalhães Velasques (maxvelasques@gmail.com) 4 | * David Vachulka (archdvx@dxsolutions.org) 5 | * Copyright: 2006 6 | * License: GPL2 7 | **************************************************************/ 8 | 9 | #ifndef WX_PRECOMP 10 | #include 11 | #endif 12 | #include 13 | #include 14 | 15 | #ifndef MYUTILFUNCTIONS_H 16 | #define MYUTILFUNCTIONS_H 17 | 18 | class MyUtilFunctions 19 | { 20 | public: 21 | static wxString TimespanToWxstr(const uint64_t &span); 22 | static wxString IntToWxstr(long value,int format = 0); 23 | /** 24 | * @brief SpeedText 25 | * @param speed in bytes 26 | * @param down, true = download 27 | * @param showPrefix, true = "D: " or "U: " 28 | * @return 29 | */ 30 | static wxString SpeedText(int speed, bool down, bool showPrefix=true); 31 | static wxString FromStdString(const std::string &str); 32 | static std::string ToStdString(const wxString &str); 33 | static wxString SizeText(int64_t size); 34 | static std::vector ArrayStringToVector(const wxArrayString &array); 35 | static wxString ArrayStringTowxString(const wxArrayString &array); 36 | static wxString MimeType(const wxString &fname); 37 | /** 38 | * @brief BrowserIntegration 39 | * @param path - where is wxdfast, wdfast-integrator is on same path 40 | */ 41 | static void BrowserIntegration(const wxString &path); 42 | static void CheckBrowser(const wxString &browserpath, const wxString &integratorpath, bool firefox, wxArrayString ids); 43 | static void CreateFirefoxJson(const wxString &jsonpath, const wxString &integratorpath); 44 | static void CreateChromeJson(const wxString &jsonpath, const wxString &integratorpath, wxArrayString ids); 45 | }; 46 | #endif //MYUTILFUNCTIONS_H 47 | -------------------------------------------------------------------------------- /wxdfast.spec: -------------------------------------------------------------------------------- 1 | %define name wxdfast 2 | %define version 0.70.4 3 | 4 | %define is_mageia %(test -e /etc/mageia-release && echo 1 || echo 0) 5 | %define is_suse %(test -e /etc/SuSE-release && echo 1 || echo 0) 6 | %define is_fedora %(test -e /etc/fedora-release && echo 1 || echo 0) 7 | 8 | %if %is_fedora 9 | %define distr %(cat /etc/fedora-release) 10 | %endif 11 | %if %is_suse 12 | %define distr %(head -1 /etc/SuSE-release) 13 | %endif 14 | %if %is_mageia 15 | %define distr %(cat /etc/mageia-release) 16 | %endif 17 | 18 | Name: %{name} 19 | Version: %{version} 20 | Summary: Multithreaded download manager 21 | Release: 1 22 | License: GPL 23 | Group: Accessories 24 | %if %is_mageia 25 | BuildRequires: wxgtk3.0-devel aria2-devel 26 | %endif 27 | %if %is_fedora 28 | BuildRequires: wxGTK3-devel aria2-devel 29 | %endif 30 | %if %is_suse 31 | BuildRequires: wxWidgets-devel >= 3 aria2-devel 32 | %endif 33 | Source: %{name}-%{version}.tar.gz 34 | Packager: David Vachulka 35 | BuildRoot: %{_tmppath}/%{name}-buildroot 36 | BuildRequires: cmake pkgconfig 37 | 38 | %description 39 | Multithreaded download manager. wxDownload Fast is desktop independent and is written with the wxWidgets toolkit and Aria2. 40 | 41 | %global debug_package %{nil} 42 | 43 | %prep 44 | %setup -q 45 | 46 | %build 47 | mkdir build 48 | pushd build 49 | %if %is_fedora 50 | cmake \ 51 | -DCMAKE_INSTALL_PREFIX=%{_prefix} \ 52 | -DDX_WX_CONFIG=wx-config-3.0 \ 53 | .. 54 | %else 55 | cmake \ 56 | -DCMAKE_INSTALL_PREFIX=%{_prefix} \ 57 | .. 58 | %endif 59 | make 60 | popd #build 61 | 62 | %install 63 | pushd build 64 | %make_install 65 | popd #build 66 | 67 | %clean 68 | rm -rf $RPM_BUILD_ROOT 69 | 70 | %files 71 | %defattr(-,root,root) 72 | %doc COPYING 73 | %{_bindir}/%{name} 74 | %{_bindir}/wxdfast-integrator 75 | %{_datadir}/icons/* 76 | %{_datadir}/applications/%{name}.desktop 77 | %{_datadir}/locale/* 78 | %{_datadir}/wxdfast/icons/* 79 | %{_datadir}/wxdfast/extensionid 80 | -------------------------------------------------------------------------------- /src/Icons.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: Icons.h 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2021 5 | * License: GPL2 6 | **************************************************************/ 7 | 8 | #ifndef ICONS_H 9 | #define ICONS_H 10 | 11 | wxIcon makeIcon(const wxString &path, const wxString &name); 12 | wxIcon makeGreyedIcon(const wxString &path, const wxString &name); 13 | wxIcon makeScaledIcon(const wxString& path, int max=16); 14 | void makeAllIcons(const wxString &path); 15 | 16 | extern wxIcon ICO_ICON; 17 | extern wxIcon ICO_TRAY; 18 | extern wxIcon ICO_LOGO; 19 | extern wxIcon ICO_ABOUT; 20 | extern wxIcon ICO_COMPLETED; 21 | extern wxIcon ICO_COPYDATA; 22 | extern wxIcon ICO_COPYURL; 23 | extern wxIcon ICO_DETAILS; 24 | extern wxIcon ICO_DOWNLOADING; 25 | extern wxIcon ICO_ERROR; 26 | extern wxIcon ICO_FIND; 27 | extern wxIcon ICO_GRAPH; 28 | extern wxIcon ICO_HELP; 29 | extern wxIcon ICO_NEW; 30 | extern wxIcon ICO_OPTIONS; 31 | extern wxIcon ICO_PASTEURL; 32 | extern wxIcon ICO_PAUSE; 33 | extern wxIcon ICO_PROGRESSBAR; 34 | extern wxIcon ICO_PROPERTIES; 35 | extern wxIcon ICO_QUIT; 36 | extern wxIcon ICO_REMOVE; 37 | extern wxIcon ICO_SCHEDULE; 38 | extern wxIcon ICO_SCHEDULED; 39 | extern wxIcon ICO_START; 40 | extern wxIcon ICO_STARTALL; 41 | extern wxIcon ICO_STOP; 42 | extern wxIcon ICO_STOPALL; 43 | extern wxIcon ICO_DOWNLOAD_INFO; 44 | extern wxIcon ICO_DOWNLOAD_MOVE_DOWN; 45 | extern wxIcon ICO_DOWNLOAD_MOVE_UP; 46 | extern wxIcon ICO_DOWNLOAD_NEW; 47 | extern wxIcon ICO_DOWNLOAD_REMOVE; 48 | extern wxIcon ICO_DOWNLOAD_SCHEDULE; 49 | extern wxIcon ICO_DOWNLOAD_START; 50 | extern wxIcon ICO_DOWNLOAD_START_ALL; 51 | extern wxIcon ICO_DOWNLOAD_STOP; 52 | extern wxIcon ICO_DOWNLOAD_STOP_ALL; 53 | extern wxIcon ICO_GDOWNLOAD_INFO; 54 | extern wxIcon ICO_GDOWNLOAD_MOVE_DOWN; 55 | extern wxIcon ICO_GDOWNLOAD_MOVE_UP; 56 | extern wxIcon ICO_GDOWNLOAD_NEW; 57 | extern wxIcon ICO_GDOWNLOAD_REMOVE; 58 | extern wxIcon ICO_GDOWNLOAD_SCHEDULE; 59 | extern wxIcon ICO_GDOWNLOAD_START; 60 | extern wxIcon ICO_GDOWNLOAD_START_ALL; 61 | extern wxIcon ICO_GDOWNLOAD_STOP; 62 | extern wxIcon ICO_GDOWNLOAD_STOP_ALL; 63 | 64 | #endif // ICONS_H 65 | -------------------------------------------------------------------------------- /integrator/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 3.7) 2 | project(wxdfast-integrator) 3 | set(PROJECT_VERSION "1.0.0") 4 | 5 | if(MSVC_VERSION LESS "1900") 6 | message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.") 7 | return() 8 | endif() 9 | 10 | if(NOT MSVC) 11 | include(CheckCXXCompilerFlag) 12 | CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) 13 | if(COMPILER_SUPPORTS_CXX14) 14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 15 | else() 16 | message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.") 17 | return() 18 | endif() 19 | endif() 20 | 21 | set(INTEGRATOR_LIBS "") 22 | set(INTEGRATOR_INCLUDE_DIRS "") 23 | 24 | include(CheckFunctionExists) 25 | CHECK_FUNCTION_EXISTS("inet_ntop" HAVE_INET_NTOP_EXISTS) 26 | if(HAVE_INET_NTOP_EXISTS) 27 | set(HAVE_INET_NTOP 1) 28 | endif() 29 | CHECK_FUNCTION_EXISTS("inet_pton" HAVE_INET_PTON_EXISTS) 30 | if(HAVE_INET_PTON_EXISTS) 31 | set(HAVE_INET_PTON 1) 32 | endif() 33 | if(WIN32) 34 | CHECK_FUNCTION_EXISTS("strncasecmp" HAVE_STRNCASECMP_EXISTS) 35 | if(HAVE_STRNCASECMP_EXISTS) 36 | set(HAVE_STRNCASECMP 1) 37 | endif() 38 | endif(WIN32) 39 | include(CheckIncludeFiles) 40 | CHECK_INCLUDE_FILES(sys/param.h HAVE_SYS_PARAM_H) 41 | CHECK_INCLUDE_FILES(sys/socket.h HAVE_SYS_SOCKET_H) 42 | CHECK_INCLUDE_FILES(netinet/in.h HAVE_NETINET_IN_H) 43 | CHECK_INCLUDE_FILES(arpa/inet.h HAVE_ARPA_INET_H) 44 | 45 | list(APPEND INTEGRATOR_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}) 46 | 47 | set(SOURCES 48 | wxdfast-integrator.cpp 49 | ) 50 | 51 | if(CMAKE_BUILD_TYPE MATCHES Debug) 52 | add_definitions(-DDEBUG) 53 | endif(CMAKE_BUILD_TYPE MATCHES Debug) 54 | 55 | include_directories(${INTEGRATOR_INCLUDE_DIRS} 56 | ${CMAKE_CURRENT_SOURCE_DIR} 57 | ${CMAKE_CURRENT_BINARY_DIR} 58 | ${CMAKE_BINARY_DIR} 59 | ) 60 | 61 | if(WIN32) 62 | list(APPEND INTEGRATOR_LIBS ws2_32) 63 | endif(WIN32) 64 | 65 | ADD_EXECUTABLE(wxdfast-integrator ${SOURCES}) 66 | if(WIN32) 67 | TARGET_LINK_LIBRARIES(wxdfast-integrator "-Wl,--subsystem,console -mwindows" ${INTEGRATOR_LIBS}) 68 | else(WIN32) 69 | TARGET_LINK_LIBRARIES(wxdfast-integrator ${INTEGRATOR_LIBS}) 70 | endif(WIN32) 71 | 72 | INSTALL(TARGETS wxdfast-integrator DESTINATION bin) 73 | 74 | -------------------------------------------------------------------------------- /src/BatchDialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: BatchDialog.h 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2021 5 | * License: GPL2 6 | **************************************************************/ 7 | 8 | #ifndef MBATCHDIALOG_H 9 | #define MBATCHDIALOG_H 10 | 11 | #ifndef WX_PRECOMP 12 | #include 13 | #endif 14 | #include 15 | 16 | class mBatchDialog : public wxDialog 17 | { 18 | DECLARE_DYNAMIC_CLASS(mBatchDialog) 19 | DECLARE_EVENT_TABLE() 20 | public: 21 | mBatchDialog() {} 22 | mBatchDialog(wxWindow *parent); 23 | 24 | void SetDestination(const wxString &destination); 25 | void SetNumberOfParts(int numberofparts); 26 | void SetStartOption(int startoption); 27 | void SetCommand(const wxString &command); 28 | void SetBandwidth(int bandwidth); 29 | void SetUrls(const wxArrayString &urls); 30 | void SetUser(const wxString &user); 31 | void SetPassword(const wxString &password); 32 | void SetComment(const wxString &comment); 33 | void SetReferenceURL(const wxString &url); 34 | wxString GetDestination() const; 35 | int GetNumberOfParts() const; 36 | int GetStartOption() const; 37 | wxString GetCommand() const; 38 | int GetBandwidth() const; 39 | wxArrayString GetUrls(); 40 | wxString GetUser() const; 41 | wxString GetPassword() const; 42 | wxString GetComment() const; 43 | wxString GetReferenceURL() const; 44 | void ReLayout(); 45 | void EnableAdresslist(bool enable); 46 | void EnableUser(bool enable); 47 | void EnablePassword(bool enable); 48 | void EnableManual(bool enable); 49 | void EnableNow(bool enable); 50 | void EnableSchedule(bool enable); 51 | void EnableSplit(bool enable); 52 | void EnableComment(bool enable); 53 | void EnableBandwidth(bool enable); 54 | void EnableReferenceurl(bool enable); 55 | void EnableCommand(bool enable); 56 | private: 57 | wxBoxSizer *m_mainSizer; 58 | wxTextCtrl *m_destination; 59 | wxCheckListBox *m_adresslist; 60 | wxTextCtrl *m_user; 61 | wxTextCtrl *m_password; 62 | wxRadioButton *m_manual; 63 | wxRadioButton *m_now; 64 | wxRadioButton *m_schedule; 65 | wxSpinCtrl *m_split; 66 | wxTextCtrl *m_comment; 67 | wxSpinCtrl *m_bandwidth; 68 | wxTextCtrl *m_referenceurl; 69 | wxTextCtrl *m_command; 70 | 71 | void OnOk(wxCommandEvent& event); 72 | void OnCancel(wxCommandEvent& event); 73 | void OnDir(wxCommandEvent& event); 74 | }; 75 | 76 | #endif // MBATCHDIALOG_H 77 | -------------------------------------------------------------------------------- /src/Defs.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: Defs.h 3 | * Author: Max Magalhães Velasques (maxvelasques@gmail.com) 4 | * David Vachulka (archdvx@dxsolutions.org) 5 | * Copyright: 2006 6 | * License: GPL2 7 | **************************************************************/ 8 | 9 | #ifndef DEFS_H 10 | #define DEFS_H 11 | 12 | #include 13 | 14 | #define MANUAL 0 15 | #define NOW 1 16 | #define SCHEDULE 2 17 | 18 | #define MAX_SCHEDULE_EXCEPTIONS 9 19 | 20 | #define STATUS_STOPED 0 21 | #define STATUS_ACTIVE 1 22 | #define STATUS_FINISHED 2 23 | #define STATUS_ERROR 3 24 | #define STATUS_QUEUE 4 25 | #define STATUS_SCHEDULE_QUEUE 5 26 | #define STATUS_SCHEDULE_ACTIVE 6 27 | 28 | #define IPC_SERVICE 24242 29 | #define MAX_BUFF_LEN 1024 30 | 31 | enum 32 | { 33 | ID_MENU_HIDE = wxID_HIGHEST+1, 34 | ID_MENU_NEW, 35 | ID_MENU_OFF, 36 | ID_MENU_ON, 37 | ID_MENU_PERDOWNLOAD, 38 | ID_MENU_REMOVE, 39 | ID_MENU_SCHEDULE, 40 | ID_MENU_START, 41 | ID_MENU_STOP, 42 | ID_MENU_STARTALL, 43 | ID_MENU_STOPALL, 44 | ID_MENU_UP, 45 | ID_MENU_DOWN, 46 | ID_MENU_INFO, 47 | ID_MENU_PASTEURL, 48 | ID_MENU_COPYURL, 49 | ID_MENU_COPYDOWNLOADDATA, 50 | ID_MENU_REMOVEALL, 51 | ID_MENU_FIND, 52 | ID_MENU_SHOWGRAPH, 53 | ID_MENU_DETAILS, 54 | ID_MENU_SITE, 55 | ID_MENU_BUG, 56 | ID_MENU_DONATE, 57 | ID_MENU_MOVE, 58 | ID_MENU_MD5, 59 | ID_MENU_OPENDESTINATION, 60 | ID_MENU_AGAIN, 61 | ID_MENU_EXPORT, 62 | ID_MENU_IMPORT, 63 | ID_MENU_SHUTDOWN, 64 | ID_MENU_DISCONNECT, 65 | ID_NOTEBOOK, 66 | ID_LIST_PROGRESS, 67 | ID_LIST_FINISHED, 68 | ID_OPTIONS_DESTINATION, 69 | ID_OPTIONS_FILEMANAGERPATH, 70 | ID_DATE_SELECT, 71 | ID_DATE_CALENDAR, 72 | ID_TIME_SELECT, 73 | ID_TIME_HOURS, 74 | ID_TIME_MINUTES, 75 | ID_TIME_SECONDS, 76 | ID_OPTIONS_STARTDATE, 77 | ID_OPTIONS_STARTTIME, 78 | ID_OPTIONS_FINISHDATE, 79 | ID_OPTIONS_FINISHTIME, 80 | ID_OPTIONS_EXCEPTION_ADD, 81 | ID_OPTIONS_EXCEPTION_REMOVE, 82 | ID_OPTIONS_NOTIFY, 83 | ID_ENGINE_GLOBAL, 84 | ID_ENGINE_DOWNLOAD, 85 | ID_ENGINE_VERSION, 86 | ID_ENGINE_REMOVED, 87 | ID_ENGINE_STARTED, 88 | ID_NEW_DIRECTORY, 89 | ID_NEW_ADD, 90 | ID_NEW_EDIT, 91 | ID_IPC, 92 | ID_IPC_SOCKET, 93 | ID_BATCH_DIRECTORY, 94 | ID_TIMER 95 | }; 96 | 97 | #endif // DEFS_H 98 | -------------------------------------------------------------------------------- /src/NewDialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: NewDialog.h 3 | * Author: Max Magalhães Velasques (maxvelasques@gmail.com) 4 | * David Vachulka (archdvx@dxsolutions.org) 5 | * Copyright: 2006 6 | * License: GPL2 7 | **************************************************************/ 8 | 9 | #ifndef MNEWDIALOG_H 10 | #define MNEWDIALOG_H 11 | 12 | #ifndef WX_PRECOMP 13 | #include 14 | #endif 15 | #include 16 | #include 17 | 18 | class mNewDialog : public wxDialog 19 | { 20 | DECLARE_DYNAMIC_CLASS(mNewDialog) 21 | DECLARE_EVENT_TABLE() 22 | public: 23 | mNewDialog() {} 24 | mNewDialog(wxWindow *parent); 25 | 26 | void SetDestination(const wxString &destination); 27 | void SetNumberOfConnections(int numberofconnections); 28 | void SetStartOption(int startoption); 29 | void SetCommand(const wxString &command); 30 | void SetOnTop(bool ontop); 31 | void SetBandwidth(int bandwidth); 32 | void SetUrls(const wxArrayString &urls); 33 | void SetUrl(const wxString &url); 34 | void SetUser(const wxString &user); 35 | void SetPassword(const wxString &password); 36 | void SetComment(const wxString &comment); 37 | void SetReferenceURL(const wxString &url); 38 | wxString GetDestination() const; 39 | int GetNumberOfConnections() const; 40 | int GetStartOption() const; 41 | wxString GetCommand() const; 42 | bool GetOnTop() const; 43 | int GetBandwidth() const; 44 | wxArrayString GetUrls(); 45 | wxString GetUser() const; 46 | wxString GetPassword() const; 47 | wxString GetComment() const; 48 | wxString GetReferenceURL() const; 49 | void ReLayout(); 50 | void EnableDestination(bool enable); 51 | void EnableDirectory(bool enable); 52 | void EnableAdd(bool enable); 53 | void EnableEdit(bool enable); 54 | void EnableAdresslist(bool enable); 55 | void EnableOntop(bool enable); 56 | void EnableUser(bool enable); 57 | void EnablePassword(bool enable); 58 | void EnableManual(bool enable); 59 | void EnableNow(bool enable); 60 | void EnableSchedule(bool enable); 61 | void EnableSplit(bool enable); 62 | void EnableComment(bool enable); 63 | void EnableBandwidth(bool enable); 64 | void EnableReferenceurl(bool enable); 65 | void EnableCommand(bool enable); 66 | void EnableUrl(bool enable); 67 | private: 68 | wxBoxSizer *m_mainSizer; 69 | wxTextCtrl *m_destination; 70 | wxButton *m_directory; 71 | wxTextCtrl *m_url; 72 | wxButton *m_add; 73 | wxCheckListBox *m_adresslist; 74 | wxButton *m_edit; 75 | wxCheckBox *m_addontop; 76 | wxTextCtrl *m_user; 77 | wxTextCtrl *m_password; 78 | wxRadioButton *m_manual; 79 | wxRadioButton *m_now; 80 | wxRadioButton *m_schedule; 81 | wxSpinCtrl *m_split; 82 | wxTextCtrl *m_comment; 83 | wxSpinCtrl *m_bandwidth; 84 | wxTextCtrl *m_referenceurl; 85 | wxTextCtrl *m_command; 86 | 87 | void OnOk(wxCommandEvent& event); 88 | void OnCancel(wxCommandEvent& event); 89 | void OnDir(wxCommandEvent& event); 90 | void OnAdd(wxCommandEvent& event); 91 | void OnEdit(wxCommandEvent& event); 92 | int CheckURI(wxString uritxt); 93 | }; 94 | 95 | #endif // MNEWDIALOG_H 96 | -------------------------------------------------------------------------------- /win/wxdfast.iss: -------------------------------------------------------------------------------- 1 | #define AppName "wxDownloadFast" 2 | #define AppVersion "0.70.4" 3 | #define AppPublisher "David Vachulka" 4 | #define AppURL "https://wxdfast.dxsolutions.org/" 5 | #define AppExeName "wxdfast.exe" 6 | 7 | [Setup] 8 | ; NOTE: The value of AppId uniquely identifies this application. 9 | ; Do not use the same AppId value in installers for other applications. 10 | ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) 11 | AppId={{FB3FC57A-D68D-4CC7-87D7-ED0B20741F67} 12 | AppName={#AppName} 13 | AppVersion={#AppVersion} 14 | AppVerName={#AppName} {#AppVersion} 15 | AppPublisher={#AppPublisher} 16 | AppPublisherURL={#AppURL} 17 | AppSupportURL={#AppURL} 18 | AppUpdatesURL={#AppURL} 19 | DefaultDirName={pf}\{#AppName} 20 | DefaultGroupName={#AppName} 21 | OutputBaseFilename={#AppName}-{#AppVersion}-setup 22 | LicenseFile=COPYING 23 | Compression=lzma 24 | SolidCompression=yes 25 | 26 | [Languages] 27 | Name: "english"; MessagesFile: "compiler:Default.isl" 28 | Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl" 29 | Name: "german"; MessagesFile: "compiler:Languages\German.isl" 30 | Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl" 31 | Name: "french"; MessagesFile: "compiler:Languages\French.isl" 32 | Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl" 33 | Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl" 34 | Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl" 35 | Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl" 36 | Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl" 37 | Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl" 38 | Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl" 39 | Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl" 40 | 41 | [Tasks] 42 | Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked 43 | Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1 44 | 45 | [Files] 46 | Source: "{#AppExeName}"; DestDir: "{app}"; Flags: ignoreversion 47 | Source: "wxdfast-integrator.exe"; DestDir: "{app}"; Flags: ignoreversion 48 | Source: "*.bat"; DestDir: "{app}"; Flags: ignoreversion 49 | Source: "*.dll"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs 50 | Source: "COPYING"; DestDir: "{app}"; Flags: ignoreversion 51 | Source: "locale\*.mo"; DestDir: "{app}\locale"; Flags: recursesubdirs 52 | Source: "icons\*.*"; DestDir: "{app}\icons"; Flags: recursesubdirs 53 | Source: "ca-certs\*.*"; DestDir: "{app}\ca-certs"; Flags: recursesubdirs 54 | ; NOTE: Don't use "Flags: ignoreversion" on any shared system files 55 | 56 | [Icons] 57 | Name: "{group}\{#AppName}"; Filename: "{app}\{#AppExeName}" 58 | Name: "{group}\{cm:ProgramOnTheWeb,{#AppName}}"; Filename: "{#AppURL}" 59 | Name: "{group}\{cm:UninstallProgram,{#AppName}}"; Filename: "{uninstallexe}" 60 | Name: "{commondesktop}\{#AppName}"; Filename: "{app}\{#AppExeName}"; Tasks: desktopicon 61 | Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#AppName}"; Filename: "{app}\{#AppExeName}"; Tasks: quicklaunchicon 62 | 63 | [Run] 64 | Filename: "{app}\add_config.bat"; Parameters: "install"; Flags: runhidden 65 | 66 | [UninstallRun] 67 | Filename: "{app}\remove_config.bat"; Parameters: "install"; Flags: runhidden; RunOnceId: "DelService" 68 | -------------------------------------------------------------------------------- /src/widgets/dxlistctrl.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: dxlistctrl.cpp 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2014 5 | * License: GPL3 6 | **************************************************************/ 7 | 8 | #include "dxlistctrl.h" 9 | 10 | BEGIN_EVENT_TABLE(dxListCtrl, wxListCtrl) 11 | EVT_SIZE(dxListCtrl::OnResize) 12 | END_EVENT_TABLE() 13 | 14 | dxListCtrl::dxListCtrl(wxWindow *parent, const wxWindowID id, bool virt, bool resize) 15 | : wxListCtrl(parent, id, wxDefaultPosition, wxDefaultSize, 16 | virt ? wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_VIRTUAL | wxLC_SINGLE_SEL : wxLC_REPORT | wxLC_HRULES | wxLC_VRULES | wxLC_SINGLE_SEL), 17 | m_resizeColumn(0), m_resizeColumnMinWidth(80), m_resize(resize) 18 | { 19 | Connect(wxEVT_LIST_COL_END_DRAG, wxSizeEventHandler(dxListCtrl::OnResize), nullptr, this); 20 | } 21 | 22 | int dxListCtrl::resizeColumn() const 23 | { 24 | return m_resizeColumn; 25 | } 26 | 27 | void dxListCtrl::setResizeColumn(int resizeColumn) 28 | { 29 | m_resizeColumn = resizeColumn; 30 | } 31 | 32 | int dxListCtrl::resizeColumnMinWidth() const 33 | { 34 | return m_resizeColumnMinWidth; 35 | } 36 | 37 | void dxListCtrl::setResizeColumnMinWidth(int resizeColumnMinWidth) 38 | { 39 | m_resizeColumnMinWidth = resizeColumnMinWidth; 40 | } 41 | 42 | void dxListCtrl::SetColumnHeaderFiltered(int column, bool filtered) 43 | { 44 | wxListItem item; 45 | item.SetMask(wxLIST_MASK_TEXT); 46 | GetColumn(column, item); 47 | if(filtered && item.GetText().Right(1) != "*") 48 | { 49 | item.SetText(item.GetText()+"*"); 50 | } 51 | if(!filtered && item.GetText().Right(1) == "*") 52 | { 53 | item.SetText(item.GetText().Left(item.GetText().Len()-1)); 54 | } 55 | SetColumn(column, item); 56 | } 57 | 58 | void dxListCtrl::ClearSelection() 59 | { 60 | long item = -1; 61 | for(;;) 62 | { 63 | item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); 64 | if(item == -1) 65 | break; 66 | SetItemState(item, 0, wxLIST_STATE_SELECTED); 67 | } 68 | } 69 | 70 | void dxListCtrl::OnResize(wxSizeEvent &event) 71 | { 72 | if(m_resize) 73 | { 74 | #ifdef __WXGTK__ 75 | resize(); 76 | #else 77 | CallAfter(&dxListCtrl::resize); 78 | #endif 79 | } 80 | event.Skip(); 81 | } 82 | 83 | void dxListCtrl::resize() 84 | { 85 | if(GetSize().y < 32) return; //avoid an endless update bug when the height is small 86 | int listWidth = GetClientSize().x; 87 | #ifndef __WXMSW__ 88 | if(GetItemCount() > GetCountPerPage()) 89 | { 90 | int scrollWidth = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); 91 | listWidth = listWidth - scrollWidth; 92 | } 93 | #endif 94 | int columnsWidth = 0; 95 | int columns = GetColumnCount(); 96 | if(!columns) return; //nothing to resize 97 | for(int i=0; ilistWidth) 103 | { 104 | SetColumnWidth(m_resizeColumn, m_resizeColumnMinWidth); 105 | return; 106 | } 107 | SetColumnWidth(m_resizeColumn, listWidth-columnsWidth); 108 | } 109 | 110 | wxString dxListCtrl::OnGetItemText(long /*item*/, long /*column*/) const 111 | { 112 | return ""; 113 | } 114 | 115 | int dxListCtrl::OnGetItemColumnImage(long /*item*/, long /*column*/) const 116 | { 117 | return 0; 118 | } 119 | 120 | wxListItemAttr *dxListCtrl::OnGetItemAttr(long /*item*/) const 121 | { 122 | return nullptr; 123 | } 124 | 125 | -------------------------------------------------------------------------------- /src/OptionsDialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: OptionsDialog.h 3 | * Author: Max Magalhães Velasques (maxvelasques@gmail.com) 4 | * David Vachulka (archdvx@dxsolutions.org) 5 | * Copyright: 2006 6 | * License: GPL2 7 | **************************************************************/ 8 | 9 | #ifndef MOPTIONSDIALOG_H 10 | #define MOPTIONSDIALOG_H 11 | 12 | #ifndef WX_PRECOMP 13 | #include 14 | #endif 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include "Options.h" 23 | 24 | class mOptionsDialog: public wxDialog 25 | { 26 | DECLARE_DYNAMIC_CLASS(OptionsDialog) 27 | DECLARE_EVENT_TABLE() 28 | public: 29 | mOptionsDialog() {} 30 | mOptionsDialog(wxWindow *parent); 31 | private: 32 | wxSpinCtrl *m_attempts; 33 | wxSpinCtrl *m_attemptstime; 34 | wxSpinCtrl *m_simultaneous; 35 | wxCheckBox *m_rememberboxnewoptions; 36 | wxCheckBox *m_shutdown; 37 | wxCheckBox *m_disconnect; 38 | wxCheckBox *m_closedialog; 39 | wxSpinCtrl *m_timerupdateinterval; 40 | wxCheckBox *m_restoremainframe; 41 | wxCheckBox *m_hidemainframe; 42 | wxCheckBox *m_checkforupdates; 43 | wxTextCtrl *m_destination; 44 | wxButton *m_destinationSelect; 45 | wxTextCtrl *m_filemanagerpath; 46 | wxButton *m_filemanagerpathSelect; 47 | wxTextCtrl *m_shutdowncmd; 48 | wxTextCtrl *m_disconnectcmd; 49 | wxCheckBox *m_proxy; 50 | wxTextCtrl *m_proxyServer; 51 | wxTextCtrl *m_proxyPort; 52 | wxTextCtrl *m_proxyUsername; 53 | wxTextCtrl *m_proxyAuthstring; 54 | wxCheckBox *m_graphshow; 55 | wxSpinCtrl *m_graphrefreshtime; 56 | wxChoice *m_graphscale; 57 | wxSpinCtrl *m_graphtextarea; 58 | wxSpinCtrl *m_graphheight; 59 | wxSpinCtrl *m_graphspeedfontsize; 60 | wxSpinCtrl *m_graphlinewidth; 61 | wxColourPickerCtrl *m_graphbackcolor; 62 | wxColourPickerCtrl *m_graphgridcolor; 63 | wxColourPickerCtrl *m_graphlinecolor; 64 | wxColourPickerCtrl *m_graphuploadcolor; 65 | wxColourPickerCtrl *m_graphfontcolor; 66 | wxCheckBox *m_activatescheduling; 67 | wxDatePickerCtrl *m_startdatetimeDate; 68 | wxTimePickerCtrl *m_startdatetimeTime; 69 | wxDatePickerCtrl *m_finishdatetimeDate; 70 | wxTimePickerCtrl *m_finishdatetimeTime; 71 | wxChoice *m_exceptionday; 72 | wxTimePickerCtrl *m_exceptionstart; 73 | wxTimePickerCtrl *m_exceptionfinish; 74 | wxButton *m_exceptionadd; 75 | std::vector m_exceptions; 76 | wxListBox *m_exceptionsList; 77 | wxButton *m_exceptionremove; 78 | wxRadioButton *m_bandwidthunlimited; 79 | wxRadioButton *m_bandwidthindependently; 80 | wxRadioButton *m_bandwidthcustom; 81 | wxSpinCtrl *m_bandwidthcustomSpin; 82 | wxColourPickerCtrl *m_finishedpiece; 83 | wxColourPickerCtrl *m_unfinishedpiece; 84 | wxCheckBox *m_shownotify; 85 | wxButton *m_shownotifyTest; 86 | wxCheckBox *m_md5; 87 | wxCheckBox *m_sha1; 88 | wxCheckBox *m_sha256; 89 | 90 | void OnOk(wxCommandEvent& event); 91 | void OnCancel(wxCommandEvent& event); 92 | void OnDestination(wxCommandEvent& event); 93 | void OnFilemanager(wxCommandEvent& event); 94 | void OnStartDate(wxDateEvent& event); 95 | void OnStartTime(wxDateEvent& event); 96 | void OnFinishDate(wxDateEvent& event); 97 | void OnFinishTime(wxDateEvent& event); 98 | void OnAddException(wxCommandEvent& event); 99 | void OnRemoveException(wxCommandEvent& event); 100 | void OnShowNotify(wxCommandEvent& event); 101 | wxDateTime GetStart(); 102 | wxDateTime GetFinish(); 103 | }; 104 | 105 | #endif // MOPTIONSDIALOG_H 106 | -------------------------------------------------------------------------------- /src/hash/hash.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: hash.cpp 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2021 5 | * License: GPL2 6 | **************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "hash.h" 16 | #include "UtilFunctions.h" 17 | 18 | mHash::mHash() 19 | { 20 | } 21 | 22 | wxString mHash::MD5(const wxString &path) 23 | { 24 | if(!wxFileExists(path)) 25 | { 26 | return ""; 27 | } 28 | wxBeginBusyCursor(); 29 | std::ifstream fp(path.mb_str(), std::ios::in | std::ios::binary); 30 | constexpr const std::size_t buffer_size { 1 << 12 }; 31 | char buffer[buffer_size]; 32 | unsigned char *hash; 33 | unsigned int hash_len = EVP_MD_size(EVP_md5()); 34 | EVP_MD_CTX *ctx; 35 | ctx = EVP_MD_CTX_new(); 36 | EVP_DigestInit_ex(ctx, EVP_md5(), NULL); 37 | while(fp.good()) 38 | { 39 | fp.read(buffer, buffer_size); 40 | EVP_DigestUpdate(ctx, buffer, fp.gcount()); 41 | } 42 | hash = (unsigned char *)OPENSSL_malloc(hash_len); 43 | EVP_DigestFinal_ex(ctx, hash, &hash_len); 44 | EVP_MD_CTX_free(ctx); 45 | fp.close(); 46 | std::ostringstream os; 47 | os << std::hex << std::setfill('0'); 48 | for(unsigned int i = 0; i < hash_len; ++i) 49 | { 50 | os << std::setw(2) << static_cast(hash[i]); 51 | } 52 | wxEndBusyCursor(); 53 | return MyUtilFunctions::FromStdString(os.str()); 54 | } 55 | 56 | wxString mHash::SHA1(const wxString &path) 57 | { 58 | if(!wxFileExists(path)) 59 | { 60 | return ""; 61 | } 62 | wxBeginBusyCursor(); 63 | std::ifstream fp(path.mb_str(), std::ios::in | std::ios::binary); 64 | constexpr const std::size_t buffer_size { 1 << 12 }; 65 | char buffer[buffer_size]; 66 | unsigned char *hash; 67 | unsigned int hash_len = EVP_MD_size(EVP_sha1()); 68 | EVP_MD_CTX *ctx; 69 | ctx = EVP_MD_CTX_new(); 70 | EVP_DigestInit_ex(ctx, EVP_sha1(), NULL); 71 | while(fp.good()) 72 | { 73 | fp.read(buffer, buffer_size); 74 | EVP_DigestUpdate(ctx, buffer, fp.gcount()); 75 | } 76 | hash = (unsigned char *)OPENSSL_malloc(hash_len); 77 | EVP_DigestFinal_ex(ctx, hash, &hash_len); 78 | EVP_MD_CTX_free(ctx); 79 | fp.close(); 80 | std::ostringstream os; 81 | os << std::hex << std::setfill('0'); 82 | for(unsigned int i = 0; i < hash_len; ++i) 83 | { 84 | os << std::setw(2) << static_cast(hash[i]); 85 | } 86 | wxEndBusyCursor(); 87 | return MyUtilFunctions::FromStdString(os.str()); 88 | } 89 | 90 | wxString mHash::SHA256(const wxString &path) 91 | { 92 | if(!wxFileExists(path)) 93 | { 94 | return ""; 95 | } 96 | wxBeginBusyCursor(); 97 | std::ifstream fp(path.mb_str(), std::ios::in | std::ios::binary); 98 | constexpr const std::size_t buffer_size { 1 << 12 }; 99 | char buffer[buffer_size]; 100 | unsigned char *hash; 101 | unsigned int hash_len = EVP_MD_size(EVP_sha256()); 102 | EVP_MD_CTX *ctx; 103 | ctx = EVP_MD_CTX_new(); 104 | EVP_DigestInit_ex(ctx, EVP_sha256(), NULL); 105 | while(fp.good()) 106 | { 107 | fp.read(buffer, buffer_size); 108 | EVP_DigestUpdate(ctx, buffer, fp.gcount()); 109 | } 110 | hash = (unsigned char *)OPENSSL_malloc(hash_len); 111 | EVP_DigestFinal_ex(ctx, hash, &hash_len); 112 | EVP_MD_CTX_free(ctx); 113 | fp.close(); 114 | std::ostringstream os; 115 | os << std::hex << std::setfill('0'); 116 | for(unsigned int i = 0; i < hash_len; ++i) 117 | { 118 | os << std::setw(2) << static_cast(hash[i]); 119 | } 120 | wxEndBusyCursor(); 121 | return MyUtilFunctions::FromStdString(os.str()); 122 | } 123 | -------------------------------------------------------------------------------- /src/Progress.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: Progress.cpp 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2021 5 | * License: GPL2 6 | **************************************************************/ 7 | 8 | #include 9 | #include "Progress.h" 10 | #include "Options.h" 11 | 12 | #define PIECE_WIDTH 10 13 | #define PIECE_HEIGHT 14 14 | #define PIECE_SPACE 1 15 | 16 | IMPLEMENT_DYNAMIC_CLASS(mProgress, wxPanel) 17 | 18 | BEGIN_EVENT_TABLE(mProgress, wxPanel) 19 | EVT_PAINT(mProgress::OnPaint) 20 | END_EVENT_TABLE() 21 | 22 | mProgress::mProgress(wxWindow *parent) 23 | : wxPanel(parent), m_bitfield(""), m_numpieces(0), m_finished(false) 24 | { 25 | SetBackgroundStyle(wxBG_STYLE_PAINT); 26 | } 27 | 28 | void mProgress::OnPaint(wxPaintEvent &/*event*/) 29 | { 30 | wxBufferedPaintDC dc(this); 31 | int w, h; 32 | this->GetSize(&w,&h); 33 | 34 | //CLEAR THE PROGRESS AREA 35 | dc.Clear(); 36 | if(!m_numpieces) 37 | return; 38 | 39 | int x = PIECE_SPACE, y = PIECE_SPACE; 40 | if(m_finished) 41 | { 42 | dc.SetBrush(wxBrush(moptions.finishedpiece())); 43 | dc.SetPen(*wxBLACK_PEN); 44 | for(int i=0; i < m_numpieces; i++) 45 | { 46 | dc.DrawRectangle(x,y,PIECE_WIDTH,PIECE_HEIGHT); 47 | if(x+2*(PIECE_WIDTH+PIECE_SPACE) > w) 48 | { 49 | y += PIECE_HEIGHT+2*PIECE_SPACE; 50 | x = PIECE_SPACE; 51 | } 52 | else 53 | { 54 | x += PIECE_WIDTH+2*PIECE_SPACE; 55 | } 56 | } 57 | return; 58 | } 59 | if(m_bitfield.length()) //something downloaded 60 | { 61 | //wxBrush for downloaded piece 62 | wxBrush d(wxBrush(moptions.finishedpiece())); 63 | //wxBrush for non-downloaded piece 64 | wxBrush nd(wxBrush(moptions.unfinishedpiece())); 65 | dc.SetPen(*wxBLACK_PEN); 66 | int piecesProcessed = 0; 67 | for(size_t i = 0; i < m_bitfield.length(); ++i) 68 | { 69 | unsigned char byte = static_cast(m_bitfield[i]); 70 | for(int n = 7; n >= 0; n--) 71 | { 72 | int bit = (byte >> n) & 1; 73 | if(bit) dc.SetBrush(d); 74 | else dc.SetBrush(nd); 75 | dc.DrawRectangle(x,y,PIECE_WIDTH,PIECE_HEIGHT); 76 | if(x+2*(PIECE_WIDTH+PIECE_SPACE) > w) 77 | { 78 | y += PIECE_HEIGHT+2*PIECE_SPACE; 79 | x = PIECE_SPACE; 80 | } 81 | else 82 | { 83 | x += PIECE_WIDTH+2*PIECE_SPACE; 84 | } 85 | piecesProcessed++; 86 | if(piecesProcessed == m_numpieces) 87 | { 88 | break; 89 | } 90 | } 91 | } 92 | } 93 | else 94 | { 95 | dc.SetBrush(wxBrush(moptions.unfinishedpiece())); 96 | dc.SetPen(*wxBLACK_PEN); 97 | for(int i=0; i < m_numpieces; i++) 98 | { 99 | dc.DrawRectangle(x,y,PIECE_WIDTH,PIECE_HEIGHT); 100 | if(x+2*(PIECE_WIDTH+PIECE_SPACE) > w) 101 | { 102 | y += PIECE_HEIGHT+2*PIECE_SPACE; 103 | x = PIECE_SPACE; 104 | } 105 | else 106 | { 107 | x += PIECE_WIDTH+2*PIECE_SPACE; 108 | } 109 | } 110 | } 111 | } 112 | 113 | std::string mProgress::bitfield() const 114 | { 115 | return m_bitfield; 116 | } 117 | 118 | void mProgress::setBitfield(const std::string &bitfield) 119 | { 120 | m_bitfield = bitfield; 121 | } 122 | 123 | int mProgress::numpieces() const 124 | { 125 | return m_numpieces; 126 | } 127 | 128 | void mProgress::setNumpieces(int numpieces) 129 | { 130 | m_numpieces = numpieces; 131 | } 132 | 133 | bool mProgress::finished() const 134 | { 135 | return m_finished; 136 | } 137 | 138 | void mProgress::setFinished(bool finished) 139 | { 140 | m_finished = finished; 141 | } 142 | -------------------------------------------------------------------------------- /src/wxjson/include/wx/jsonwriter.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Name: jsonwriter.h 3 | // Purpose: the generator of JSON text from a JSON value 4 | // Author: Luciano Cattani 5 | // Created: 2007/09/15 6 | // RCS-ID: $Id: jsonwriter.h,v 1.4 2008/03/03 19:05:45 luccat Exp $ 7 | // Copyright: (c) 2007 Luciano Cattani 8 | // Licence: wxWidgets licence 9 | ///////////////////////////////////////////////////////////////////////////// 10 | 11 | #if !defined( _WX_JSONWRITER_H ) 12 | #define _WX_JSONWRITER_H 13 | 14 | #ifdef __GNUG__ 15 | #pragma interface "jsonwriter.h" 16 | #endif 17 | 18 | // For compilers that support precompilation, includes "wx/wx.h". 19 | #include "wx/wxprec.h" 20 | 21 | #ifdef __BORLANDC__ 22 | #pragma hdrstop 23 | #endif 24 | 25 | // for all others, include the necessary headers (this file is usually all you 26 | // need because it includes almost all "standard" wxWidgets headers) 27 | #ifndef WX_PRECOMP 28 | #include 29 | #include 30 | #endif 31 | 32 | #include "json_defs.h" 33 | #include "jsonval.h" 34 | 35 | enum { 36 | wxJSONWRITER_NONE = 0, 37 | wxJSONWRITER_STYLED = 1, 38 | wxJSONWRITER_WRITE_COMMENTS = 2, 39 | wxJSONWRITER_COMMENTS_BEFORE = 4, 40 | wxJSONWRITER_COMMENTS_AFTER = 8, 41 | wxJSONWRITER_SPLIT_STRING = 16, 42 | wxJSONWRITER_NO_LINEFEEDS = 32, 43 | wxJSONWRITER_ESCAPE_SOLIDUS = 64, 44 | wxJSONWRITER_MULTILINE_STRING = 128, 45 | wxJSONWRITER_RECOGNIZE_UNSIGNED = 256, 46 | wxJSONWRITER_TAB_INDENT = 512, 47 | wxJSONWRITER_NO_INDENTATION = 1024, 48 | wxJSONWRITER_NOUTF8_STREAM = 2048, 49 | wxJSONWRITER_MEMORYBUFF = 4096 50 | }; 51 | 52 | // class declaration 53 | 54 | class WXDLLIMPEXP_JSON wxJSONWriter 55 | { 56 | public: 57 | wxJSONWriter( int style = wxJSONWRITER_STYLED, int indent = 0, int step = 3 ); 58 | ~wxJSONWriter(); 59 | 60 | void Write( const wxJSONValue& value, wxString& str ); 61 | void Write( const wxJSONValue& value, wxOutputStream& os ); 62 | void SetDoubleFmtString( const char* fmt ); 63 | 64 | protected: 65 | 66 | int DoWrite( wxOutputStream& os, const wxJSONValue& value, const wxString* key, bool comma ); 67 | int WriteIndent( wxOutputStream& os ); 68 | int WriteIndent( wxOutputStream& os, int num ); 69 | bool IsSpace( wxChar ch ); 70 | bool IsPunctuation( wxChar ch ); 71 | 72 | int WriteString( wxOutputStream& os, const wxString& str ); 73 | int WriteStringValue( wxOutputStream& os, const wxString& str ); 74 | int WriteNullValue( wxOutputStream& os ); 75 | int WriteIntValue( wxOutputStream& os, const wxJSONValue& v ); 76 | int WriteUIntValue( wxOutputStream& os, const wxJSONValue& v ); 77 | int WriteBoolValue( wxOutputStream& os, const wxJSONValue& v ); 78 | int WriteDoubleValue( wxOutputStream& os, const wxJSONValue& v ); 79 | int WriteMemoryBuff( wxOutputStream& os, const wxMemoryBuffer& buff ); 80 | 81 | int WriteInvalid( wxOutputStream& os ); 82 | int WriteSeparator( wxOutputStream& os ); 83 | 84 | int WriteKey( wxOutputStream& os, const wxString& key ); 85 | int WriteComment( wxOutputStream& os, const wxJSONValue& value, bool indent ); 86 | 87 | int WriteError( const wxString& err ); 88 | 89 | private: 90 | //! The style flag is a combination of wxJSONWRITER_(something) constants. 91 | int m_style; 92 | 93 | //! The initial indentation value, in number of spaces. 94 | int m_indent; 95 | 96 | //! The indentation increment, in number of spaces. 97 | int m_step; 98 | 99 | //! JSON value objects can be nested; this is the level of annidation (used internally). 100 | int m_level; 101 | 102 | // The line number when printing JSON text output (not yet used) 103 | int m_lineNo; 104 | 105 | // The column number when printing JSON text output 106 | int m_colNo; 107 | 108 | // Flag used in ANSI mode that controls UTF-8 conversion 109 | bool m_noUtf8; 110 | 111 | // The format string for printing doubles 112 | char* m_fmt; 113 | }; 114 | 115 | 116 | #endif // not defined _WX_JSONWRITER_H 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /src/FileInfo.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: FileInfo.h 3 | * Author: Max Magalhães Velasques (maxvelasques@gmail.com) 4 | * David Vachulka (archdvx@dxsolutions.org) 5 | * Copyright: 2006 6 | * License: GPL2 7 | **************************************************************/ 8 | 9 | #ifndef MFILEINFO_H 10 | #define MFILEINFO_H 11 | 12 | #ifndef WX_PRECOMP 13 | #include 14 | #endif 15 | #include 16 | #include 17 | 18 | class mFileInfo 19 | { 20 | public: 21 | mFileInfo(); 22 | 23 | wxXmlNode *createXmlNode(); 24 | bool fromXmlNode(const wxXmlNode* node); 25 | int index() const; 26 | void setIndex(int index); 27 | aria2::A2Gid gid() const; 28 | void setGid(const aria2::A2Gid &gid); 29 | int status() const; 30 | void setStatus(int status); 31 | void setStatusFromAriastatus(aria2::DownloadStatus status); 32 | wxString name() const; 33 | void setName(const wxString &name); 34 | wxString destination() const; 35 | void setDestination(const wxString &destination); 36 | wxArrayString urls() const; 37 | void setUrls(const wxArrayString &urls); 38 | void addUrl(const wxString &url); 39 | wxString user() const; 40 | void setUser(const wxString &user); 41 | wxString password() const; 42 | void setPassword(const wxString &password); 43 | wxString MD5() const; 44 | void setMD5(const wxString &MD5); 45 | int connections() const; 46 | void setConnections(int connections); 47 | int bandwidth() const; 48 | void setBandwidth(int bandwidth); 49 | wxString comment() const; 50 | void setComment(const wxString &comment); 51 | wxString link() const; 52 | void setLink(const wxString &link); 53 | wxString command() const; 54 | void setCommand(const wxString &command); 55 | int64_t totalLength() const; 56 | void setTotalLength(const int64_t &totalLength); 57 | int64_t downloadLength() const; 58 | void setDownloadLength(const int64_t &downloadLength); 59 | int64_t uploadLength() const; 60 | void setUploadLength(const int64_t &uploadLength); 61 | std::string bitfield() const; 62 | void setBitfield(const std::string &bitfield); 63 | int downloadSpeed() const; 64 | void setDownloadSpeed(int downloadSpeed); 65 | int uploadSpeed() const; 66 | void setUploadSpeed(int uploadSpeed); 67 | aria2::A2Gid parent() const; 68 | void setParent(const aria2::A2Gid &parent); 69 | int numPieces() const; 70 | void setNumPieces(int numPieces); 71 | int numConnections() const; 72 | void setNumConnections(int numConnections); 73 | wxDateTime startTime() const; 74 | void setStartTime(const wxDateTime &startTime); 75 | wxDateTime endTime() const; 76 | void setEndTime(const wxDateTime &endTime); 77 | uint64_t timepassed() const; 78 | void addTimepassed(int milliseconds); 79 | void clearTimepassed(); 80 | wxString log() const; 81 | void appendLogLine(const wxString &line); 82 | void clearLog(); 83 | int attempts() const; 84 | void setAttempts(int newAttempts); 85 | void addAttempt(); 86 | uint64_t laststat() const; 87 | void setLaststat(const uint64_t &newLaststat); 88 | const wxString &SHA1() const; 89 | void setSHA1(const wxString &newSHA1); 90 | const wxString &SHA256() const; 91 | void setSHA256(const wxString &newSHA256); 92 | 93 | private: 94 | int m_index; 95 | aria2::A2Gid m_gid; 96 | int m_status; 97 | wxString m_name; 98 | wxString m_destination; 99 | wxArrayString m_urls; 100 | wxString m_user; 101 | wxString m_password; 102 | wxString m_MD5; 103 | wxString m_SHA1; 104 | wxString m_SHA256; 105 | int m_connections; 106 | int m_bandwidth; 107 | wxString m_comment; 108 | wxString m_link; 109 | wxString m_command; 110 | int64_t m_totalLength; 111 | int64_t m_downloadLength; 112 | int64_t m_uploadLength; 113 | std::string m_bitfield; 114 | int m_downloadSpeed; 115 | int m_uploadSpeed; 116 | aria2::A2Gid m_parent; 117 | int m_numPieces; 118 | int m_numConnections; 119 | wxDateTime m_startTime; 120 | wxDateTime m_endTime; 121 | uint64_t m_timepassed; 122 | wxString m_log; 123 | int m_attempts; 124 | uint64_t m_laststat; 125 | //NOTE torrent values - next release 126 | }; 127 | 128 | #endif // MFILEINFO_H 129 | -------------------------------------------------------------------------------- /src/Engine.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: Engine.h 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2021 5 | * License: GPL2 6 | **************************************************************/ 7 | 8 | #ifndef ENGINE_H 9 | #define ENGINE_H 10 | 11 | #ifndef WX_PRECOMP 12 | #include 13 | #endif 14 | #include 15 | #include 16 | #include 17 | #include "FileInfo.h" 18 | 19 | class mMainFrame; 20 | 21 | class GlobalEvent : public wxThreadEvent 22 | { 23 | public: 24 | GlobalEvent(int winid, int downloadSpeed, int uploadSpeed, int numActive, int numWaiting, int numStopped) 25 | : wxThreadEvent(wxEVT_THREAD, winid), 26 | m_downloadSpeed(downloadSpeed), m_uploadSpeed(uploadSpeed), m_numActive(numActive), m_numWaiting(numWaiting), 27 | m_numStopped(numStopped) 28 | {} 29 | int GetDownloadSpeed() const { return m_downloadSpeed; } 30 | int GetUploadSpeed() const { return m_uploadSpeed; } 31 | int GetNumActive() const { return m_numActive; } 32 | int GetNumWaiting() const { return m_numWaiting; } 33 | int GetNumStopped() const { return m_numStopped; } 34 | // implement the base class pure virtual 35 | virtual wxEvent *Clone() const { return new GlobalEvent(*this); } 36 | private: 37 | //Overall download speed (byte/sec) 38 | int m_downloadSpeed; 39 | //Overall upload speed(byte/sec) 40 | int m_uploadSpeed; 41 | //The number of active downloads 42 | int m_numActive; 43 | //The number of waiting downloads 44 | int m_numWaiting; 45 | //The number of stopped downloads 46 | int m_numStopped; 47 | }; 48 | 49 | class DownloadEvent : public wxThreadEvent 50 | { 51 | public: 52 | DownloadEvent(int winid, aria2::A2Gid gid, aria2::DownloadStatus status, int64_t totalLength, int64_t completedLength, 53 | int64_t uploadLength, std::string bitfield, int downloadSpeed, int uploadSpeed, size_t pieceLength, 54 | int numPieces) 55 | : wxThreadEvent(wxEVT_THREAD, winid), 56 | m_gid(gid), m_status(status), m_totalLength(totalLength), m_completedLength(completedLength), m_uploadLength(uploadLength), 57 | m_bitfield(bitfield), m_downloadSpeed(downloadSpeed), m_uploadSpeed(uploadSpeed), m_pieceLength(pieceLength), m_numPieces(numPieces) 58 | {} 59 | aria2::A2Gid GetGid() const { return m_gid; } 60 | aria2::DownloadStatus GetStatus() const { return m_status; } 61 | int64_t GetTotalLegth() const { return m_totalLength; } 62 | int64_t GetCompletedLegth() const { return m_completedLength; } 63 | int64_t GetUploadLegth() const { return m_uploadLength; } 64 | std::string GetBitfield() const { return m_bitfield; } 65 | int GetDownloadSpeed() const { return m_downloadSpeed; } 66 | int GetUploadSpeed() const { return m_uploadSpeed; } 67 | int GetPieceLength() const { return m_pieceLength; } 68 | int GetNumPieces() const { return m_numPieces; } 69 | // implement the base class pure virtual 70 | virtual wxEvent *Clone() const { return new DownloadEvent(*this); } 71 | private: 72 | //download GID 73 | aria2::A2Gid m_gid; 74 | //status of this download 75 | aria2::DownloadStatus m_status; 76 | //the total length of this download in bytes 77 | int64_t m_totalLength; 78 | //the completed length of this download in bytes 79 | int64_t m_completedLength; 80 | //the uploaded length of this download in bytes 81 | int64_t m_uploadLength; 82 | //the download progress in byte-string. The highest bit corresponds to piece index 0. The set bits indicate the piece is available and unset bits indicate the piece is missing. 83 | //The spare bits at the end are set to zero. 84 | //When download has not started yet, returns empty string. 85 | std::string m_bitfield; 86 | //download speed of this download measured in bytes/sec 87 | int m_downloadSpeed; 88 | //upload speed of this download measured in bytes/sec 89 | int m_uploadSpeed; 90 | //piece length in bytes 91 | size_t m_pieceLength; 92 | //the number of pieces 93 | int m_numPieces; 94 | }; 95 | 96 | class mEngine : public wxThread 97 | { 98 | public: 99 | mEngine(mMainFrame *frame); 100 | ~mEngine(); 101 | 102 | virtual void *Entry(); 103 | virtual void OnExit(); 104 | aria2::A2Gid CheckVersion(); 105 | mFileInfo FillInfo(aria2::A2Gid gid); 106 | void AddFileInfo(const mFileInfo &info); 107 | void AddGid(aria2::A2Gid gid); 108 | bool HasGid(aria2::A2Gid gid); 109 | bool IsActive(aria2::A2Gid gid); 110 | void PauseDownload(aria2::A2Gid gid); 111 | void ResumeDownload(aria2::A2Gid gid, const wxString &destination, int connections, int bandwidth); 112 | bool RemoveDownload(aria2::A2Gid gid); 113 | wxString RealFileName(aria2::A2Gid gid); 114 | void SetGlobalBandwith(); 115 | void SetDownloadBandwith(aria2::A2Gid gid, int bandwidth); 116 | void UpdateOptions(); 117 | protected: 118 | mMainFrame *m_frame; 119 | private: 120 | aria2::Session *m_session; 121 | std::vector m_gids; 122 | aria2::A2Gid m_versionGid; 123 | bool m_checkversion; 124 | bool m_started; 125 | }; 126 | 127 | #endif // ENGINE_H 128 | -------------------------------------------------------------------------------- /src/wxjson/include/wx/jsonreader.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Name: jsonreader.h 3 | // Purpose: the parser of JSON text 4 | // Author: Luciano Cattani 5 | // Created: 2007/09/15 6 | // RCS-ID: $Id: jsonreader.h,v 1.3 2008/03/03 19:05:45 luccat Exp $ 7 | // Copyright: (c) 2007 Luciano Cattani 8 | // Licence: wxWidgets licence 9 | ///////////////////////////////////////////////////////////////////////////// 10 | 11 | #if !defined( _WX_JSONREADER_H ) 12 | #define _WX_JSONREADER_H 13 | 14 | #ifdef __GNUG__ 15 | #pragma interface "jsonreader.h" 16 | #endif 17 | 18 | // For compilers that support precompilation, includes "wx/wx.h". 19 | #include "wx/wxprec.h" 20 | 21 | #ifdef __BORLANDC__ 22 | #pragma hdrstop 23 | #endif 24 | 25 | // for all others, include the necessary headers (this file is usually all you 26 | // need because it includes almost all "standard" wxWidgets headers) 27 | #ifndef WX_PRECOMP 28 | #include 29 | #include 30 | #include 31 | #endif 32 | 33 | 34 | #include "json_defs.h" 35 | #include "jsonval.h" 36 | 37 | // The flags of the parser 38 | enum { 39 | wxJSONREADER_STRICT = 0, 40 | wxJSONREADER_ALLOW_COMMENTS = 1, 41 | wxJSONREADER_STORE_COMMENTS = 2, 42 | wxJSONREADER_CASE = 4, 43 | wxJSONREADER_MISSING = 8, 44 | wxJSONREADER_MULTISTRING = 16, 45 | wxJSONREADER_COMMENTS_AFTER = 32, 46 | wxJSONREADER_NOUTF8_STREAM = 64, 47 | wxJSONREADER_MEMORYBUFF = 128, 48 | 49 | wxJSONREADER_TOLERANT = wxJSONREADER_ALLOW_COMMENTS | wxJSONREADER_CASE | 50 | wxJSONREADER_MISSING | wxJSONREADER_MULTISTRING, 51 | wxJSONREADER_COMMENTS_BEFORE = wxJSONREADER_ALLOW_COMMENTS | wxJSONREADER_STORE_COMMENTS 52 | }; 53 | 54 | 55 | class WXDLLIMPEXP_JSON wxJSONReader 56 | { 57 | public: 58 | wxJSONReader( int flags = wxJSONREADER_TOLERANT, int maxErrors = 30 ); 59 | virtual ~wxJSONReader(); 60 | 61 | int Parse( const wxString& doc, wxJSONValue* val ); 62 | int Parse( wxInputStream& doc, wxJSONValue* val ); 63 | 64 | int GetDepth() const; 65 | int GetErrorCount() const; 66 | int GetWarningCount() const; 67 | const wxArrayString& GetErrors() const; 68 | const wxArrayString& GetWarnings() const; 69 | 70 | static int UTF8NumBytes( char ch ); 71 | 72 | #if defined( wxJSON_64BIT_INT ) 73 | static bool Strtoll( const wxString& str, wxInt64* i64 ); 74 | static bool Strtoull( const wxString& str, wxUint64* ui64 ); 75 | static bool DoStrto_ll( const wxString& str, wxUint64* ui64, wxChar* sign ); 76 | #endif 77 | 78 | protected: 79 | 80 | int DoRead( wxInputStream& doc, wxJSONValue& val ); 81 | void AddError( const wxString& descr ); 82 | void AddError( const wxString& fmt, const wxString& str ); 83 | void AddError( const wxString& fmt, wxChar ch ); 84 | void AddWarning( int type, const wxString& descr ); 85 | int GetStart( wxInputStream& is ); 86 | int ReadChar( wxInputStream& is ); 87 | int PeekChar( wxInputStream& is ); 88 | void StoreValue( int ch, const wxString& key, wxJSONValue& value, wxJSONValue& parent ); 89 | int SkipWhiteSpace( wxInputStream& is ); 90 | int SkipComment( wxInputStream& is ); 91 | void StoreComment( const wxJSONValue* parent ); 92 | int ReadString( wxInputStream& is, wxJSONValue& val ); 93 | int ReadToken( wxInputStream& is, int ch, wxString& s ); 94 | int ReadValue( wxInputStream& is, int ch, wxJSONValue& val ); 95 | int ReadUES( wxInputStream& is, char* uesBuffer ); 96 | int AppendUES( wxMemoryBuffer& utf8Buff, const char* uesBuffer ); 97 | int NumBytes( char ch ); 98 | int ConvertCharByChar( wxString& s, const wxMemoryBuffer& utf8Buffer ); 99 | int ReadMemoryBuff( wxInputStream& is, wxJSONValue& val ); 100 | 101 | //! Flag that control the parser behaviour, 102 | int m_flags; 103 | 104 | //! Maximum number of errors stored in the error's array 105 | int m_maxErrors; 106 | 107 | //! The current line number (start at 1). 108 | int m_lineNo; 109 | 110 | //! The current column number (start at 1). 111 | int m_colNo; 112 | 113 | //! The current level of object/array annidation (start at ZERO). 114 | int m_level; 115 | 116 | //! The depth level of the read JSON text 117 | int m_depth; 118 | 119 | //! The pointer to the value object that is being read. 120 | wxJSONValue* m_current; 121 | 122 | //! The pointer to the value object that was last stored. 123 | wxJSONValue* m_lastStored; 124 | 125 | //! The pointer to the value object that will be read. 126 | wxJSONValue* m_next; 127 | 128 | //! The comment string read by SkipComment(). 129 | wxString m_comment; 130 | 131 | //! The starting line of the comment string. 132 | int m_commentLine; 133 | 134 | //! The array of error messages. 135 | wxArrayString m_errors; 136 | 137 | //! The array of warning messages. 138 | wxArrayString m_warnings; 139 | 140 | //! The character read by the PeekChar() function (-1 none) 141 | int m_peekChar; 142 | 143 | //! ANSI: do not convert UTF-8 strings 144 | bool m_noUtf8; 145 | }; 146 | 147 | 148 | #endif // not defined _WX_JSONREADER_H 149 | 150 | 151 | -------------------------------------------------------------------------------- /src/Graph.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: Graph.cpp 3 | * Author: Max Magalhães Velasques (maxvelasques@gmail.com) 4 | * David Vachulka (archdvx@dxsolutions.org) 5 | * Copyright: 2006 6 | * License: GPL2 7 | **************************************************************/ 8 | 9 | #include 10 | #include 11 | #include "Graph.h" 12 | #include "Options.h" 13 | #include "UtilFunctions.h" 14 | 15 | IMPLEMENT_DYNAMIC_CLASS(mGraph, wxPanel) 16 | 17 | BEGIN_EVENT_TABLE(mGraph, wxPanel) 18 | EVT_PAINT(mGraph::OnPaint) 19 | END_EVENT_TABLE() 20 | 21 | #define DX 3.0 22 | 23 | mGraph::mGraph(wxWindow *parent) 24 | : wxPanel(parent) 25 | { 26 | } 27 | 28 | void mGraph::OnPaint(wxPaintEvent &/*event*/) 29 | { 30 | wxBufferedPaintDC dc(this); 31 | int x, y, lastx, lasty, count; 32 | float dx, dy; 33 | 34 | //DEFINE PARAMETERS 35 | int scale = moptions.graphscale()*1024.; //graphscale at KB/S, values at B/S 36 | int textarea = moptions.graphtextarea(); 37 | wxFont bigfont; 38 | bigfont.SetPointSize(moptions.graphspeedfontsize()); 39 | 40 | //SET THE BACKGROUND COLOR 41 | wxBrush b(moptions.graphbackcolor(), wxBRUSHSTYLE_SOLID); 42 | dc.SetBackground(b); 43 | dc.Clear(); 44 | 45 | //GET THE LIMITS OF THE WINDOW 46 | this->GetSize(&x,&y); 47 | dx = DX; 48 | dy = ((float) y)/((float) scale); 49 | 50 | //DRAW A GRID FOR THE GRAPH 51 | wxPen gridpen(moptions.graphgridcolor()); 52 | dc.SetPen(gridpen); 53 | int grid = y/5; 54 | count = 1; 55 | while (y >= (grid*count)) 56 | { 57 | dc.DrawLine(textarea,y-grid*count ,x-((int)dx),y-grid*count); 58 | count++; 59 | } 60 | dc.DrawLine(textarea,0 ,textarea,y); 61 | 62 | //DRAW THE DOWNLOAD GRAPH 63 | wxPen linepen(moptions.graphlinecolor()); 64 | linepen.SetWidth(moptions.graphlinewidth()); 65 | dc.SetPen(linepen); 66 | if(m_downloadpoints.size()) 67 | { 68 | int current = *m_downloadpoints.begin(); 69 | count = 0; 70 | 71 | //CALCULATE THE STARTPOINT 72 | int xstart = x - textarea-5; 73 | int nitens = m_downloadpoints.size(); 74 | int startitem = 0; 75 | if(xstart > (int)(nitens*dx)) 76 | { 77 | xstart = x-(int)(nitens*dx); 78 | } 79 | else 80 | { 81 | startitem = (int)(((nitens*dx)-((float)xstart))/dx); 82 | xstart = textarea+5; 83 | } 84 | 85 | lastx = xstart+((int)dx*count); 86 | lasty = y-((int)(dy*current)); 87 | for(const auto &node : m_downloadpoints) 88 | { 89 | current = node; 90 | count++; 91 | if(startitem <= count) 92 | dc.DrawLine(lastx,lasty,xstart+((int)dx)*(count-startitem),y-((int)(dy*(current>scale?scale:current)))); 93 | 94 | lastx = xstart+((int)dx*(count-startitem)); 95 | lasty = y-((int)(dy*current)); 96 | 97 | //DON'T DRAW THE GRAPH AFTER THE END OF THE WINDOW 98 | if (lastx >= x) 99 | break; 100 | } 101 | //WRITE THE CURRENT DOWNLOAD SPEED 102 | dc.SetTextForeground(moptions.graphfontcolor()); 103 | dc.SetFont(bigfont); 104 | wxCoord speedh; 105 | dc.GetTextExtent(MyUtilFunctions::SpeedText(current,true), nullptr, &speedh); 106 | dc.DrawText(MyUtilFunctions::SpeedText(current,true),5,y/2-speedh/2); 107 | } 108 | else 109 | { 110 | //WRITE THE DEFAULT DOWNLOAD SPEED 111 | dc.SetTextForeground(moptions.graphfontcolor()); 112 | dc.SetFont(bigfont); 113 | wxCoord speedh; 114 | dc.GetTextExtent(MyUtilFunctions::SpeedText(0,true), nullptr, &speedh); 115 | dc.DrawText(MyUtilFunctions::SpeedText(0,true),5,y/2-speedh/2); 116 | } 117 | /* NOTE 0.7.0 will not work as BT downloader/uploader 118 | //DRAW THE UPLOAD GRAPH 119 | linepen.SetColour(moptions.graphuploadcolor()); 120 | dc.SetPen(linepen); 121 | if(m_uploadpoints.size()) 122 | { 123 | int current = *m_uploadpoints.begin(); 124 | count = 0; 125 | 126 | //CALCULATE THE STARTPOINT 127 | int xstart = x - textarea-5; 128 | int nitens = m_uploadpoints.size(); 129 | int startitem = 0; 130 | if(xstart > (int)(nitens*dx)) 131 | { 132 | xstart = x-(int)(nitens*dx); 133 | } 134 | else 135 | { 136 | startitem = (int)(((nitens*dx)-((float)xstart))/dx); 137 | xstart = textarea+5; 138 | } 139 | 140 | lastx = xstart+((int)dx*count); 141 | lasty = y-((int)(dy*current)); 142 | for(const auto &node : m_uploadpoints) 143 | { 144 | current = node; 145 | count++; 146 | if(startitem <= count) 147 | dc.DrawLine(lastx,lasty ,xstart+((int)dx)*(count-startitem),y-((int)(dy*(current>scale?scale:current)))); 148 | 149 | lastx = xstart+((int)dx*(count-startitem)); 150 | lasty = y-((int)(dy*current)); 151 | 152 | //DON'T DRAW THE GRAPH AFTER THE END OF THE WINDOW 153 | if(lastx >= x) 154 | break; 155 | } 156 | //WRITE THE CURRENT UPLOAD SPEED 157 | dc.SetTextForeground(moptions.graphfontcolor()); 158 | dc.SetFont(bigfont); 159 | dc.DrawText(MyUtilFunctions::SpeedText(current,false),5,y/2+5); 160 | } 161 | else 162 | { 163 | //WRITE THE DEFAULT UPLOAD SPEED 164 | dc.SetTextForeground(moptions.graphfontcolor()); 165 | dc.SetFont(bigfont); 166 | dc.DrawText(MyUtilFunctions::SpeedText(0,false),5,y/2+5); 167 | } 168 | */ 169 | } 170 | 171 | void mGraph::AddDownloadPoint(int point) 172 | { 173 | if(m_downloadpoints.size() && (int)(m_downloadpoints.size()*DX) > this->GetSize().GetWidth()-moptions.graphtextarea()) 174 | { 175 | m_downloadpoints.erase(m_downloadpoints.begin()); 176 | } 177 | m_downloadpoints.push_back(point); 178 | } 179 | 180 | void mGraph::AddUploadPoint(int /*point*/) 181 | { 182 | /* NOTE 0.7.0 will not work as BT downloader/uploader 183 | if(m_uploadpoints.size() && (int)(m_uploadpoints.size()*DX) > this->GetSize().GetWidth()-moptions.graphtextarea()) 184 | { 185 | m_uploadpoints.erase(m_uploadpoints.begin()); 186 | } 187 | m_uploadpoints.push_back(point); 188 | */ 189 | } 190 | -------------------------------------------------------------------------------- /src/wxjson/include/wx/json_defs.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////// 2 | // Name: json_defs.h 3 | // Purpose: shared build defines 4 | // Author: Luciano Cattani 5 | // Created: 2007/10/20 6 | // RCS-ID: $Id: json_defs.h,v 1.6 2008/03/12 10:48:19 luccat Exp $ 7 | // Copyright: (c) 2007 Luciano Cattani 8 | // Licence: wxWidgets licence 9 | ///////////////////////////////////////////////////////////////////////////// 10 | 11 | 12 | #ifndef _WX_JSON_DEFS_H_ 13 | #define _WX_JSON_DEFS_H_ 14 | 15 | // Defines for component version. 16 | // The following symbols should be updated for each new component release 17 | // since some kind of tests, like those of AM_WXCODE_CHECKFOR_COMPONENT_VERSION() 18 | // for "configure" scripts under unix, use them. 19 | #define wxJSON_MAJOR 1 20 | #define wxJSON_MINOR 2 21 | #define wxJSON_RELEASE 1 22 | 23 | // For non-Unix systems (i.e. when building without a configure script), 24 | // users of this component can use the following macro to check if the 25 | // current version is at least major.minor.release 26 | #define wxCHECK_JSON_VERSION(major,minor,release) \ 27 | (wxJSON_MAJOR > (major) || \ 28 | (wxJSON_MAJOR == (major) && wxJSON_MINOR > (minor)) || \ 29 | (wxJSON_MAJOR == (major) && wxJSON_MINOR == (minor) && wxJSON_RELEASE >= (release))) 30 | 31 | 32 | // Defines for shared builds. 33 | // Simple reference for using these macros and for writin components 34 | // which support shared builds: 35 | // 36 | // 1) use the WXDLLIMPEXP_MYCOMP in each class declaration: 37 | // class WXDLLIMPEXP_MYCOMP myCompClass { [...] }; 38 | // 39 | // 2) use the WXDLLIMPEXP_MYCOMP in the declaration of each global function: 40 | // WXDLLIMPEXP_MYCOMP int myGlobalFunc(); 41 | // 42 | // 3) use the WXDLLIMPEXP_DATA_MYCOMP() in the declaration of each global 43 | // variable: 44 | // WXDLLIMPEXP_DATA_MYCOMP(int) myGlobalIntVar; 45 | // 46 | //#ifdef WXMAKINGDLL_JSON 47 | // #define WXDLLIMPEXP_JSON WXEXPORT 48 | // #define WXDLLIMPEXP_DATA_JSON(type) WXEXPORT type 49 | //#elif defined(WXUSINGDLL) 50 | // #define WXDLLIMPEXP_JSON WXIMPORT 51 | // #define WXDLLIMPEXP_DATA_JSON(type) WXIMPORT type 52 | //#else // not making nor using DLL 53 | #define WXDLLIMPEXP_JSON 54 | #define WXDLLIMPEXP_DATA_JSON(type) type 55 | //#endif 56 | 57 | // the __PRETTY_FUNCTION__ macro expands to the full class's 58 | // member name in the GNU GCC. 59 | // For other compilers we use the standard __wxFUNCTION__ macro 60 | #if !defined( __GNUC__ ) 61 | #define __PRETTY_FUNCTION__ __WXFUNCTION__ 62 | #endif 63 | 64 | 65 | 66 | // define wxJSON_USE_UNICODE if wxWidgets was built with 67 | // unicode support 68 | #if defined( wxJSON_USE_UNICODE ) 69 | #undef wxJSON_USE_UNICODE 70 | #endif 71 | // do not modify the following lines 72 | #if wxUSE_UNICODE == 1 73 | #define wxJSON_USE_UNICODE 74 | #endif 75 | 76 | // the following macro, if defined, cause the wxJSONValue to store 77 | // pointers to C-strings as pointers to statically allocated 78 | // C-strings. By default this macro is not defined 79 | // #define wxJSON_USE_CSTRING 80 | 81 | 82 | // the following macro, if defined, cause the wxJSONvalue and its 83 | // referenced data structure to store and increment a static 84 | // progressive counter in the ctor. 85 | // this is only usefull for debugging purposes 86 | // #define WXJSON_USE_VALUE_COUNTER 87 | 88 | 89 | // the following macro is used by wxJSON internally and you should not 90 | // modify it. If the platform seems to support 64-bits integers, 91 | // the following lines define the 'wxJSON_64BIT_INT' macro 92 | #if defined( wxLongLong_t ) 93 | #define wxJSON_64BIT_INT 94 | #endif 95 | 96 | 97 | // 98 | // the following macro, if defined, cause the wxJSON library to 99 | // always use 32-bits integers also when the platform seems to 100 | // have native 64-bits support: by default the macro if not defined 101 | // 102 | // #define wxJSON_NO_64BIT_INT 103 | // 104 | #if defined( wxJSON_NO_64BIT_INT ) && defined( wxJSON_64BIT_INT ) 105 | #undef wxJSON_64BIT_INT 106 | #endif 107 | 108 | // 109 | // it seems that some compilers do not define 'long long int' limits 110 | // constants. For example, this is the output of the Borland BCC 5.5 111 | // compiler when I tried to compile wxJSON with 64-bits integer support: 112 | // Error E2451 ..\src\jsonreader.cpp 1737: Undefined symbol 'LLONG_MAX' 113 | // in function wxJSONReader::Strtoll(const wxString &,__int64 *) 114 | // *** 1 errors in Compile *** 115 | // so, if the constants are not defined, I define them by myself 116 | #if !defined( LLONG_MAX ) 117 | #define LLONG_MAX 9223372036854775807 118 | #endif 119 | 120 | #if !defined( ULLONG_MAX ) 121 | #define ULLONG_MAX 18446744073709551615 122 | #endif 123 | 124 | #if !defined( LLONG_MIN ) 125 | #define LLONG_MIN -9223372036854775808 126 | #endif 127 | 128 | 129 | 130 | // the same applies for all other integer constants 131 | #if !defined( INT_MIN ) 132 | #define INT_MIN -32768 133 | #endif 134 | #if !defined( INT_MAX ) 135 | #define INT_MAX 32767 136 | #endif 137 | #if !defined( UINT_MAX ) 138 | #define UINT_MAX 65535 139 | #endif 140 | #if !defined( LONG_MIN ) 141 | #define LONG_MIN -2147483648 142 | #endif 143 | #if !defined( LONG_MAX ) 144 | #define LONG_MAX 2147483647 145 | #endif 146 | #if !defined( ULONG_MAX ) 147 | #define ULONG_MAX 4294967295 148 | #endif 149 | #if !defined( SHORT_MAX ) 150 | #define SHORT_MAX 32767 151 | #endif 152 | #if !defined( SHORT_MIN ) 153 | #define SHORT_MIN -32768 154 | #endif 155 | #if !defined( USHORT_MAX ) 156 | #define USHORT_MAX 65535 157 | #endif 158 | 159 | 160 | 161 | // 162 | // define the wxJSON_ASSERT() macro to expand to wxASSERT() 163 | // unless the wxJSON_NOABORT_ASSERT is defined 164 | // #define wxJSON_NOABORT_ASSERT 165 | #if defined( wxJSON_NOABORT_ASSERT ) 166 | #define wxJSON_ASSERT( cond ) 167 | #else 168 | #define wxJSON_ASSERT( cond ) wxASSERT( cond ); 169 | #endif 170 | 171 | 172 | // 173 | // the following macros are used by the wxJSONWriter::WriteStringValues() 174 | // when the wxJSONWRITER_SPLIT_STRING flag is set 175 | #define wxJSONWRITER_LAST_COL 50 176 | #define wxJSONWRITER_SPLIT_COL 75 177 | #define wxJSONWRITER_MIN_LENGTH 15 178 | #define wxJSONWRITER_TAB_LENGTH 4 179 | 180 | 181 | // 182 | // some compilers (i.e. MSVC++) defines their own 'snprintf' function 183 | // so if it is not defined, define it in the following lines 184 | // please note that we cannot use the wxWidget's counterpart 'wxSnprintf' 185 | // because the latter uses 'wxChar' but wxJSON only use 'char' 186 | #if !defined(snprintf) && defined(_MSC_VER) 187 | #define snprintf _snprintf 188 | #endif 189 | 190 | 191 | // 192 | // check if wxWidgets is compiled using --enable-stl in which case 193 | // we have to use different aproaches when declaring the array and 194 | // key/value containers (see the docs: wxJSON internals: array and hash_map 195 | #undef wxJSON_USE_STL 196 | #if defined( wxUSE_STL ) && wxUSE_STL == 1 197 | #define wxJSON_USE_STL 198 | #endif 199 | 200 | // 201 | // defines the MIN and MAX macro for numeric arguments 202 | // note that the safest way to define such functions is using templates 203 | #define MIN(a,b) a < b ? a : b 204 | #define MAX(a,b) a > b ? a : b 205 | 206 | 207 | #endif // _WX_JSON_DEFS_H_ 208 | 209 | 210 | -------------------------------------------------------------------------------- /src/Icons.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: Icons.cpp 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2021 5 | * License: GPL2 6 | **************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "Icons.h" 15 | 16 | static const char *const empty[] = { 17 | "16 16 11 1", 18 | " c None", 19 | ". c #000000", 20 | "+ c #FFFFFF", 21 | "@ c #FDE4E4", 22 | "# c #F45C5C", 23 | "$ c #EF0B0B", 24 | "% c #F12727", 25 | "& c #F67878", 26 | "* c #FAAEAE", 27 | "= c #FBC9C9", 28 | "- c #F89393", 29 | "................", 30 | ". .", 31 | ". .", 32 | ". @#$$%& .", 33 | ". @%$$$$$& .", 34 | ". &$$#*%$$ .", 35 | ". =-#+@%$% .", 36 | ". @%$$* .", 37 | ". %$%@ .", 38 | ". *$$* .", 39 | ". @**@ .", 40 | ". *$$* .", 41 | ". *$$* .", 42 | ". @**@ .", 43 | ". .", 44 | "................"}; 45 | 46 | wxIcon ICO_ICON, 47 | ICO_TRAY, 48 | ICO_LOGO, 49 | ICO_ABOUT, 50 | ICO_COMPLETED, 51 | ICO_COPYDATA, 52 | ICO_COPYURL, 53 | ICO_DETAILS, 54 | ICO_DOWNLOADING, 55 | ICO_ERROR, 56 | ICO_FIND, 57 | ICO_GRAPH, 58 | ICO_HELP, 59 | ICO_NEW, 60 | ICO_OPTIONS, 61 | ICO_PASTEURL, 62 | ICO_PAUSE, 63 | ICO_PROGRESSBAR, 64 | ICO_PROPERTIES, 65 | ICO_QUIT, 66 | ICO_REMOVE, 67 | ICO_SCHEDULE, 68 | ICO_SCHEDULED, 69 | ICO_START, 70 | ICO_STARTALL, 71 | ICO_STOP, 72 | ICO_STOPALL, 73 | ICO_DOWNLOAD_INFO, 74 | ICO_DOWNLOAD_MOVE_DOWN, 75 | ICO_DOWNLOAD_MOVE_UP, 76 | ICO_DOWNLOAD_NEW, 77 | ICO_DOWNLOAD_REMOVE, 78 | ICO_DOWNLOAD_SCHEDULE, 79 | ICO_DOWNLOAD_START, 80 | ICO_DOWNLOAD_START_ALL, 81 | ICO_DOWNLOAD_STOP, 82 | ICO_DOWNLOAD_STOP_ALL, 83 | ICO_GDOWNLOAD_INFO, 84 | ICO_GDOWNLOAD_MOVE_DOWN, 85 | ICO_GDOWNLOAD_MOVE_UP, 86 | ICO_GDOWNLOAD_NEW, 87 | ICO_GDOWNLOAD_REMOVE, 88 | ICO_GDOWNLOAD_SCHEDULE, 89 | ICO_GDOWNLOAD_START, 90 | ICO_GDOWNLOAD_START_ALL, 91 | ICO_GDOWNLOAD_STOP, 92 | ICO_GDOWNLOAD_STOP_ALL; 93 | 94 | wxIcon makeIcon(const wxString &path, const wxString &name) 95 | { 96 | if(wxFileExists(path+wxFILE_SEP_PATH+name)) 97 | { 98 | return wxIcon(path+wxFILE_SEP_PATH+name, wxBITMAP_TYPE_PNG); 99 | } 100 | else 101 | { 102 | wxIcon icon(empty); 103 | return icon; 104 | } 105 | } 106 | 107 | wxIcon makeGreyedIcon(const wxString &path, const wxString &name) 108 | { 109 | if(wxFileExists(path+wxFILE_SEP_PATH+name)) 110 | { 111 | wxImage img(path+wxFILE_SEP_PATH+name, wxBITMAP_TYPE_PNG); 112 | wxIcon icon; 113 | icon.CopyFromBitmap(wxBitmap(img.ConvertToGreyscale())); 114 | return icon; 115 | } 116 | wxImage img(empty); 117 | wxIcon icon; 118 | icon.CopyFromBitmap(wxBitmap(img.ConvertToGreyscale())); 119 | return icon; 120 | } 121 | 122 | wxIcon makeScaledIcon(const wxString &path, int max) 123 | { 124 | if(wxFileExists(path)) 125 | { 126 | wxImage img(path); 127 | int w = img.GetWidth(); 128 | int h = img.GetHeight(); 129 | if(w>max || h>max) 130 | { 131 | if(w>h) 132 | img = img.Scale(max, (max*h)/w); 133 | else 134 | img = img.Scale((max*w)/h, max); 135 | } 136 | wxIcon icon; 137 | icon.CopyFromBitmap(wxBitmap(img)); 138 | return icon; 139 | } 140 | return wxIcon(empty); 141 | } 142 | 143 | void makeAllIcons(const wxString &path) 144 | { 145 | wxString themepath; 146 | if(path == "default") 147 | { 148 | #if defined (__WXMAC__) 149 | themepath = wxStandardPaths::Get().GetResourcesDir()+"/icons"; 150 | #else 151 | themepath = wxString(WXDFAST_DATADIR)+wxFILE_SEP_PATH+"icons"; 152 | #endif 153 | } 154 | else 155 | { 156 | themepath = path; 157 | } 158 | ICO_ICON = makeIcon(themepath, "wxdfast.png"); 159 | ICO_TRAY = makeIcon(themepath, "wxdfast.png"); 160 | ICO_LOGO = makeIcon(themepath+wxFILE_SEP_PATH+"logo", "about.png"); 161 | ICO_ABOUT = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "about.png"); 162 | ICO_COMPLETED = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "completed.png"); 163 | ICO_COPYDATA = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "copydata.png"); 164 | ICO_COPYURL = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "copyurl.png"); 165 | ICO_DETAILS = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "details.png"); 166 | ICO_DOWNLOADING = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "downloading.png"); 167 | ICO_ERROR = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "error.png"); 168 | ICO_FIND = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "find.png"); 169 | ICO_GRAPH = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "graph.png"); 170 | ICO_HELP = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "help.png"); 171 | ICO_NEW = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "new.png"); 172 | ICO_OPTIONS = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "options.png"); 173 | ICO_PASTEURL = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "pasteurl.png"); 174 | ICO_PAUSE = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "pause.png"); 175 | ICO_PROGRESSBAR = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "progressbar.png"); 176 | ICO_PROPERTIES = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "properties.png"); 177 | ICO_QUIT = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "quit.png"); 178 | ICO_REMOVE = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "remove.png"); 179 | ICO_SCHEDULE = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "schedule.png"); 180 | ICO_SCHEDULED = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "scheduled.png"); 181 | ICO_START = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "start.png"); 182 | ICO_STARTALL = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "startall.png"); 183 | ICO_STOP = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "stop.png"); 184 | ICO_STOPALL = makeIcon(themepath+wxFILE_SEP_PATH+"menubar", "stopall.png"); 185 | ICO_DOWNLOAD_INFO = makeIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_info.png"); 186 | ICO_DOWNLOAD_MOVE_DOWN = makeIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_move_down.png"); 187 | ICO_DOWNLOAD_MOVE_UP = makeIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_move_up.png"); 188 | ICO_DOWNLOAD_NEW = makeIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_new.png"); 189 | ICO_DOWNLOAD_REMOVE = makeIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_remove.png"); 190 | ICO_DOWNLOAD_SCHEDULE = makeIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_schedule.png"); 191 | ICO_DOWNLOAD_START = makeIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_start.png"); 192 | ICO_DOWNLOAD_START_ALL = makeIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_start_all.png"); 193 | ICO_DOWNLOAD_STOP = makeIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_stop.png"); 194 | ICO_DOWNLOAD_STOP_ALL = makeIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_stop_all.png"); 195 | ICO_GDOWNLOAD_INFO = makeGreyedIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_info.png"); 196 | ICO_GDOWNLOAD_MOVE_DOWN = makeGreyedIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_move_down.png"); 197 | ICO_GDOWNLOAD_MOVE_UP = makeGreyedIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_move_up.png"); 198 | ICO_GDOWNLOAD_NEW = makeGreyedIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_new.png"); 199 | ICO_GDOWNLOAD_REMOVE = makeGreyedIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_remove.png"); 200 | ICO_GDOWNLOAD_SCHEDULE = makeGreyedIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_schedule.png"); 201 | ICO_GDOWNLOAD_START = makeGreyedIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_start.png"); 202 | ICO_GDOWNLOAD_START_ALL = makeGreyedIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_start_all.png"); 203 | ICO_GDOWNLOAD_STOP = makeGreyedIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_stop.png"); 204 | ICO_GDOWNLOAD_STOP_ALL = makeGreyedIcon(themepath+wxFILE_SEP_PATH+"toolbar", "download_stop_all.png"); 205 | } 206 | -------------------------------------------------------------------------------- /src/Options.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: Options.h 3 | * Author: Max Magalhães Velasques (maxvelasques@gmail.com) 4 | * David Vachulka (archdvx@dxsolutions.org) 5 | * Copyright: 2006 6 | * License: GPL2 7 | **************************************************************/ 8 | 9 | #ifndef MOPTIONS_H 10 | #define MOPTIONS_H 11 | 12 | #ifndef WX_PRECOMP 13 | #include 14 | #endif 15 | #include "Defs.h" 16 | #include "ScheduleException.h" 17 | 18 | #define moptions mOptions::instance() 19 | 20 | class mOptions 21 | { 22 | public: 23 | mOptions(); 24 | ~mOptions(); 25 | 26 | static mOptions &instance(); 27 | void load(const wxString &path=""); 28 | void save(); 29 | wxDateTime lastnewreleasecheck() const; 30 | void setLastnewreleasecheck(const wxDateTime &lastnewreleasecheck); 31 | int attempts() const; 32 | void setAttempts(int attempts); 33 | bool closedialog() const; 34 | void setClosedialog(bool closedialog); 35 | int simultaneous() const; 36 | void setSimultaneous(int simultaneous); 37 | int attemptstime() const; 38 | void setAttemptstime(int attemptstime); 39 | bool shutdown() const; 40 | void setShutdown(bool shutdown); 41 | bool disconnect() const; 42 | void setDisconnect(bool disconnect); 43 | bool alwaysshutdown() const; 44 | void setAlwaysshutdown(bool alwaysshutdown); 45 | bool alwaysdisconnect() const; 46 | void setAlwaysdisconnect(bool alwaysdisconnect); 47 | int timerupdateinterval() const; 48 | void setTimerupdateinterval(int timerupdateinterval); 49 | bool restoremainframe() const; 50 | void setRestoremainframe(bool restoremainframe); 51 | bool hidemainframe() const; 52 | void setHidemainframe(bool hidemainframe); 53 | bool checkforupdates() const; 54 | void setCheckforupdates(bool checkforupdates); 55 | bool graphshow() const; 56 | void setGraphshow(bool graphshow); 57 | int graphhowmanyvalues() const; 58 | void setGraphhowmanyvalues(int graphhowmanyvalues); 59 | int graphrefreshtime() const; 60 | void setGraphrefreshtime(int graphrefreshtime); 61 | int graphscale() const; 62 | void setGraphscale(int graphscale); 63 | int graphtextarea() const; 64 | void setGraphtextarea(int graphtextarea); 65 | int graphheight() const; 66 | void setGraphheight(int graphheight); 67 | int graphspeedfontsize() const; 68 | void setGraphspeedfontsize(int graphspeedfontsize); 69 | wxColour graphbackcolor() const; 70 | void setGraphbackcolor(const wxColour &graphbackcolor); 71 | wxColour graphgridcolor() const; 72 | void setGraphgridcolor(const wxColour &graphgridcolor); 73 | wxColour graphlinecolor() const; 74 | void setGraphlinecolor(const wxColour &graphlinecolor); 75 | wxColour graphuploadcolor() const; 76 | void setGraphuploadcolor(const wxColour &graphuploadcolor); 77 | int graphlinewidth() const; 78 | void setGraphlinewidth(int graphlinewidth); 79 | wxColour graphfontcolor() const; 80 | void setGraphfontcolor(const wxColour &graphfontcolor); 81 | wxString shutdowncmd() const; 82 | void setShutdowncmd(const wxString &shutdowncmd); 83 | wxString disconnectcmd() const; 84 | void setDisconnectcmd(const wxString &disconnectcmd); 85 | wxString destination() const; 86 | void setDestination(const wxString &destination); 87 | wxString filemanagerpath() const; 88 | void setFilemanagerpath(const wxString &filemanagerpath); 89 | bool activatescheduling() const; 90 | void setActivatescheduling(bool activatescheduling); 91 | wxDateTime startdatetime() const; 92 | void setStartdatetime(const wxDateTime &startdatetime); 93 | wxDateTime finishdatetime() const; 94 | void setFinishdatetime(const wxDateTime &finishdatetime); 95 | int bandwidthoption() const; 96 | void setBandwidthoption(int bandwidthoption); 97 | long bandwidth() const; 98 | void setBandwidth(long bandwidth); 99 | bool proxy() const; 100 | void setProxy(bool proxy); 101 | wxString proxyServer() const; 102 | void setProxyServer(const wxString &proxyServer); 103 | wxString proxyPort() const; 104 | void setProxyPort(const wxString &proxyPort); 105 | wxString proxyUsername() const; 106 | void setProxyUsername(const wxString &proxyUsername); 107 | wxString proxyAuthstring() const; 108 | void setProxyAuthstring(const wxString &proxyAuthstring); 109 | bool rememberboxnewoptions() const; 110 | void setRememberboxnewoptions(bool rememberboxnewoptions); 111 | int x() const; 112 | void setX(int x); 113 | int y() const; 114 | void setY(int y); 115 | int w() const; 116 | void setW(int w); 117 | int h() const; 118 | void setH(int h); 119 | mScheduleException scheduleException(size_t index) const; 120 | void setScheduleException(size_t index, const mScheduleException &exception); 121 | void clearScheduleExceptions(); 122 | bool IsTimeForSchedule(); 123 | wxColour finishedpiece() const; 124 | void setFinishedpiece(const wxColour &finishedpiece); 125 | wxColour unfinishedpiece() const; 126 | void setUnfinishedpiece(const wxColour &unfinishedpiece); 127 | int lastx() const; 128 | void setLastx(int lastx); 129 | int lasty() const; 130 | void setLasty(int lasty); 131 | int lastnumberofconnections() const; 132 | void setLastnumberofconnections(int lastnumberofconnections); 133 | int laststartoption() const; 134 | void setLaststartoption(int laststartoption); 135 | wxString lastdestination() const; 136 | void setLastdestination(const wxString &lastdestination); 137 | wxString lastcommand() const; 138 | void setLastcommand(const wxString &lastcommand); 139 | bool lastontopoption() const; 140 | void setLastontopoption(bool lastontopoption); 141 | int lastbandwidth() const; 142 | void setLastbandwidth(int lastbandwidth); 143 | bool shownotify() const; 144 | void setShownotify(bool newShownotify); 145 | int livebandwidthoption() const; 146 | void setLivebandwidthoption(int newLivebandwidthoption); 147 | int separator1() const; 148 | void setSeparator1(int newSeparator1); 149 | int separator2() const; 150 | void setSeparator2(int newSeparator2); 151 | bool md5() const; 152 | void setMd5(bool newMd5); 153 | bool sha1() const; 154 | void setSha1(bool newSha1); 155 | bool sha256() const; 156 | void setSha256(bool newSha256); 157 | 158 | private: 159 | //GUI 160 | int m_x; 161 | int m_y; 162 | int m_w; 163 | int m_h; 164 | int m_separator1; 165 | int m_separator2; 166 | //General 167 | wxDateTime m_lastnewreleasecheck; 168 | int m_attempts; //number of attempts 169 | bool m_closedialog; //show the close dialog 170 | int m_simultaneous; //number of simultaneous downloads 171 | int m_attemptstime; //time between the attempts in seconds 172 | bool m_shutdown; 173 | bool m_disconnect; 174 | bool m_alwaysshutdown; 175 | bool m_alwaysdisconnect; 176 | int m_timerupdateinterval; //time between the timer refreshs in milliseconds 177 | bool m_restoremainframe; //Restore the mainframe when all downloads are finished 178 | bool m_hidemainframe; //Hide the mainframe when the user start a download 179 | bool m_checkforupdates; 180 | bool m_rememberboxnewoptions; 181 | bool m_shownotify; 182 | bool m_md5; 183 | bool m_sha1; 184 | bool m_sha256; 185 | //Graph 186 | bool m_graphshow; 187 | int m_graphrefreshtime; //time between the graph refreshs in milliseconds 188 | int m_graphscale; //max value showed in the graph 189 | int m_graphtextarea; //size the area reserved for the speed value 190 | int m_graphheight; 191 | int m_graphspeedfontsize; 192 | wxColour m_graphbackcolor; 193 | wxColour m_graphgridcolor; 194 | wxColour m_graphlinecolor; 195 | wxColour m_graphuploadcolor; 196 | int m_graphlinewidth; 197 | wxColour m_graphfontcolor; 198 | //Path 199 | wxString m_shutdowncmd; 200 | wxString m_disconnectcmd; 201 | wxString m_destination; 202 | wxString m_filemanagerpath; 203 | //Schedule 204 | bool m_activatescheduling; 205 | wxDateTime m_startdatetime; 206 | wxDateTime m_finishdatetime; 207 | mScheduleException m_scheduleexceptions[MAX_SCHEDULE_EXCEPTIONS]; 208 | //Bandwidth 209 | int m_bandwidthoption; 210 | int m_livebandwidthoption; 211 | long m_bandwidth; 212 | //Proxy 213 | bool m_proxy; 214 | wxString m_proxyServer; 215 | wxString m_proxyPort; 216 | wxString m_proxyUsername; 217 | wxString m_proxyAuthstring; 218 | //Progress 219 | wxColour m_finishedpiece; 220 | wxColour m_unfinishedpiece; 221 | //NewDialog 222 | int m_lastx; 223 | int m_lasty; 224 | int m_lastnumberofconnections; 225 | int m_laststartoption; 226 | wxString m_lastdestination; 227 | wxString m_lastcommand; 228 | bool m_lastontopoption; 229 | int m_lastbandwidth; 230 | }; 231 | 232 | #endif // MOPTIONS_H 233 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | set(CMAKE_OSX_DEPLOYMENT_TARGET "13" CACHE STRING "Minimum OS X deployment version") 3 | project(wxdfast) 4 | set(PROJECT_VERSION "0.70.4") 5 | 6 | set(WXDFAST_INCLUDE_DIRS "") 7 | set(WXDFAST_LIBS "") 8 | 9 | if(MSVC_VERSION LESS "1900") 10 | message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") 11 | return() 12 | endif() 13 | 14 | if(NOT MSVC) 15 | include(CheckCXXCompilerFlag) 16 | CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) 17 | if(COMPILER_SUPPORTS_CXX14) 18 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 19 | else() 20 | message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.") 21 | return() 22 | endif() 23 | endif() 24 | 25 | set(LANGS 26 | ar 27 | bg 28 | bn 29 | cs 30 | de 31 | es 32 | fo 33 | fr 34 | he 35 | hi 36 | hu 37 | id 38 | it 39 | ja 40 | ko 41 | lv 42 | ms 43 | nl 44 | pl 45 | pt_BR 46 | ru 47 | sv 48 | tr 49 | uk 50 | ur 51 | ) 52 | 53 | set(DX_WX_CONFIG wx-config CACHE STRING "wx-config executable") 54 | if(MSYS) 55 | set(wxWidgets_FIND_STYLE "unix") 56 | endif(MSYS) 57 | if(UNIX) 58 | execute_process(COMMAND which ${DX_WX_CONFIG} OUTPUT_VARIABLE WX_TOOL OUTPUT_STRIP_TRAILING_WHITESPACE) 59 | if(NOT WX_TOOL) 60 | message(FATAL_ERROR "\nNo functional wx_config script was found in your PATH.\nIs the wxWidgets development package installed?") 61 | else() 62 | execute_process(COMMAND sh ${WX_TOOL} --version OUTPUT_VARIABLE WX_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) 63 | string(SUBSTRING "${WX_VERSION}" "0" "1" wxMAJOR_VERSION) 64 | string(SUBSTRING "${WX_VERSION}" "2" "1" wxMINOR_VERSION) 65 | string(SUBSTRING "${WX_VERSION}" "4" "1" wxRELEASE_NUMBER) 66 | if(wxMAJOR_VERSION LESS 3) 67 | message(FATAL_ERROR "\nI'm afraid your wxWidgets version is too old.\nBuilding wxdfast requires at least wxWidgets-3.0.0") 68 | endif() 69 | endif() 70 | message("-- wx-config used is: ${WX_TOOL}") 71 | message("-- wxWidgets version is: ${WX_VERSION}") 72 | if(NOT APPLE AND NOT MINGW) 73 | # Is the wx we are using built on gtk2 or 3? 74 | execute_process(COMMAND ${WX_TOOL} --selected_config OUTPUT_VARIABLE WX_GTK_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) 75 | string(SUBSTRING "${WX_GTK_VERSION}" "3" "1" GTK_VERSION) 76 | message("-- gtk version is: ${GTK_VERSION}") 77 | endif() 78 | set(wxWidgets_CONFIG_EXECUTABLE ${WX_TOOL}) 79 | endif(UNIX) 80 | 81 | set(wxWidgets_USE_LIBS) 82 | option(WX_MONOLITHIC "Use wx monolithic build" FALSE) 83 | if(WX_MONOLITHIC) 84 | find_package(wxWidgets COMPONENTS mono) 85 | else(WX_MONOLITHIC) 86 | find_package(wxWidgets COMPONENTS core base adv net xml) 87 | endif(WX_MONOLITHIC) 88 | if(wxWidgets_FOUND) 89 | include("${wxWidgets_USE_FILE}") 90 | else(wxWidgets_FOUND) 91 | # For convenience. When we cannot continue, inform the user 92 | message("wxWidgets not found!") 93 | endif(wxWidgets_FOUND) 94 | 95 | find_package(PkgConfig) 96 | if(PKG_CONFIG_FOUND) 97 | pkg_check_modules(LIBARIA2 libaria2) 98 | list(APPEND WXDFAST_INCLUDE_DIRS ${LIBARIA2_INCLUDE_DIRS}) 99 | list(APPEND WXDFAST_LIBS ${LIBARIA2_LIBRARIES}) 100 | endif(PKG_CONFIG_FOUND) 101 | 102 | if(NOT LIBARIA2_FOUND) 103 | message(FATAL_ERROR "Aria2 library not found. Can't build wxDownload Fast") 104 | endif() 105 | 106 | find_package(OpenSSL REQUIRED) 107 | if(OPENSSL_FOUND) 108 | list(APPEND WXDFAST_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) 109 | list(APPEND WXDFAST_LIBS ${OPENSSL_LIBRARIES}) 110 | else() 111 | message(FATAL_ERROR "OpenSSL library not found. Can't build wxDownload Fast") 112 | endif() 113 | 114 | if(NOT WIN32) 115 | # Source distribution 116 | set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}) 117 | add_custom_target(dist COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR} && 118 | rm -rf ${ARCHIVE_NAME} && 119 | mkdir -p ${ARCHIVE_NAME} && 120 | git archive origin | tar -x -C ${ARCHIVE_NAME} && 121 | tar czf ${ARCHIVE_NAME}.tar.gz ${ARCHIVE_NAME} && 122 | rm -rf ${ARCHIVE_NAME} 123 | ) 124 | endif(NOT WIN32) 125 | 126 | add_subdirectory(po) 127 | add_subdirectory(resources) 128 | add_subdirectory(src/wxjson) 129 | add_subdirectory(integrator) 130 | 131 | set(SRCS 132 | src/widgets/dxlistctrl.cpp 133 | src/widgets/dxtoolbar.cpp 134 | src/Icons.cpp 135 | src/wxDFast.cpp 136 | src/Options.cpp 137 | src/Graph.cpp 138 | src/UtilFunctions.cpp 139 | src/OptionsDialog.cpp 140 | src/Progress.cpp 141 | src/Engine.cpp 142 | src/FileInfo.cpp 143 | src/hash/hash.cpp 144 | src/NewDialog.cpp 145 | src/BatchDialog.cpp 146 | ) 147 | 148 | if(WIN32) 149 | set(SRCS ${SRCS} src/resource.rc) 150 | endif(WIN32) 151 | 152 | if(NOT WIN32) 153 | if(APPLE) 154 | add_definitions(-DLOCALEDIR="../Resources") 155 | add_definitions(-DWXDFAST_DATADIR="../Resources") 156 | else() 157 | add_definitions(-DDESKTOPDIR="${CMAKE_INSTALL_PREFIX}/share/applications") 158 | add_definitions(-DLOCALEDIR="${CMAKE_INSTALL_PREFIX}/share/locale") 159 | add_definitions(-DWXDFAST_DATADIR="${CMAKE_INSTALL_PREFIX}/share/wxdfast") 160 | endif(APPLE) 161 | else() 162 | add_definitions(-DLOCALEDIR="./locale") 163 | add_definitions(-DWXDFAST_DATADIR=".") 164 | endif(NOT WIN32) 165 | 166 | if(CMAKE_BUILD_TYPE MATCHES Debug) 167 | add_definitions(-DDEBUG) 168 | endif(CMAKE_BUILD_TYPE MATCHES Debug) 169 | 170 | configure_file(config.h.cmake 171 | ${CMAKE_CURRENT_BINARY_DIR}/config.h 172 | ) 173 | 174 | include_directories(${CMAKE_CURRENT_BINARY_DIR} 175 | ${CMAKE_CURRENT_SOURCE_DIR} 176 | ${CMAKE_CURRENT_SOURCE_DIR}/src 177 | ${CMAKE_BINARY_DIR} 178 | ${WXJSON_INCLUDE_DIRS} 179 | ${WXDFAST_INCLUDE_DIRS} 180 | ) 181 | 182 | if(APPLE) 183 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/resources/Info.plist ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) 184 | set(PROGNAME wxDownloadFast) 185 | add_executable(wxDownloadFast MACOSX_BUNDLE ${SRCS}) 186 | SET_TARGET_PROPERTIES(wxDownloadFast PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) 187 | set(SOURCES ${SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/RipStop/icon/wxdfast.icns) 188 | set(wxdfast_RESOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/wxDownloadFast.app/Contents/Resources) 189 | ADD_CUSTOM_COMMAND(TARGET wxDownloadFast POST_BUILD 190 | COMMAND mkdir ARGS -p ${wxdfast_RESOURCE_DIR} 191 | COMMAND mkdir ARGS -p ${wxdfast_RESOURCE_DIR}/icons 192 | COMMAND mkdir ARGS -p ${wxdfast_RESOURCE_DIR}/icons/logo 193 | COMMAND mkdir ARGS -p ${wxdfast_RESOURCE_DIR}/icons/menubar 194 | COMMAND mkdir ARGS -p ${wxdfast_RESOURCE_DIR}/icons/toolbar 195 | COMMAND cp ARGS -f ${CMAKE_CURRENT_SOURCE_DIR}/resources/RipStop/icon/wxdfast.icns ${wxdfast_RESOURCE_DIR} 196 | COMMAND cp ARGS -f ${CMAKE_CURRENT_SOURCE_DIR}/resources/extensionid ${wxdfast_RESOURCE_DIR} 197 | COMMAND cp ARGS -f ${CMAKE_CURRENT_SOURCE_DIR}/resources/RipStop/icon/wxdfast.png ${wxdfast_RESOURCE_DIR}/icons 198 | COMMAND cp ARGS -f ${CMAKE_CURRENT_SOURCE_DIR}/resources/RipStop/logo/*.png ${wxdfast_RESOURCE_DIR}/icons/logo 199 | COMMAND cp ARGS -f ${CMAKE_CURRENT_SOURCE_DIR}/resources/RipStop/menubar/*.png ${wxdfast_RESOURCE_DIR}/icons/menubar 200 | COMMAND cp ARGS -f ${CMAKE_CURRENT_SOURCE_DIR}/resources/RipStop/toolbar/*.png ${wxdfast_RESOURCE_DIR}/icons/toolbar 201 | COMMAND cp ARGS -f ${CMAKE_CURRENT_BINARY_DIR}/integrator/wxdfast-integrator ${CMAKE_CURRENT_BINARY_DIR}/wxDownloadFast.app/Contents/MacOS 202 | COMMENT Setting up resources) 203 | foreach(lang ${LANGS}) 204 | ADD_CUSTOM_COMMAND(TARGET wxDownloadFast POST_BUILD 205 | COMMAND mkdir ARGS -p ${wxdfast_RESOURCE_DIR}/${lang}.lproj 206 | COMMAND cp ARGS -f ${CMAKE_CURRENT_SOURCE_DIR}/po/${lang}.mo ${wxdfast_RESOURCE_DIR}/${lang}.lproj/wxdfast.mo 207 | COMMENT Setting up translations) 208 | endforeach(lang) 209 | target_link_libraries(wxDownloadFast ${wxWidgets_LIBRARIES} ${WXJSON_LIBRARIES} ${WXDFAST_LIBS}) 210 | install(TARGETS wxDownloadFast DESTINATION bin) 211 | else() 212 | add_executable(wxdfast WIN32 ${SRCS}) 213 | target_link_libraries(wxdfast ${wxWidgets_LIBRARIES} ${WXJSON_LIBRARIES} ${WXDFAST_LIBS}) 214 | install(TARGETS wxdfast DESTINATION bin) 215 | endif(APPLE) 216 | 217 | 218 | 219 | # uninstall target 220 | configure_file( 221 | ${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake.in 222 | ${CMAKE_CURRENT_BINARY_DIR}/cmake/uninstall.cmake 223 | IMMEDIATE @ONLY) 224 | add_custom_target(uninstall 225 | ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake/uninstall.cmake) 226 | 227 | message(STATUS "wxDownload Fast") 228 | message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") 229 | message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") 230 | message(STATUS "wxWidgets version: ${WX_VERSION}") 231 | if(NOT APPLE AND NOT MINGW) 232 | message(STATUS " gtk version: ${GTK_VERSION}") 233 | endif() 234 | message(STATUS "LibAria2 version: ${LIBARIA2_VERSION}") 235 | message(STATUS "OpenSSL version: ${OPENSSL_VERSION}") 236 | -------------------------------------------------------------------------------- /resources/RipStop/icon/wxdfast.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 20 | 22 | 32 | 34 | 38 | 42 | 43 | 53 | 64 | 66 | 70 | 74 | 75 | 84 | 85 | 103 | 105 | 106 | 108 | image/svg+xml 109 | 111 | 112 | 113 | 114 | 115 | 120 | 123 | 130 | 133 | 142 | 151 | 160 | 165 | 170 | 171 | 172 | 173 | 174 | -------------------------------------------------------------------------------- /src/wxDFast.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: wxDFast.h 3 | * Author: Max Magalhães Velasques (maxvelasques@gmail.com) 4 | * David Vachulka (archdvx@dxsolutions.org) 5 | * Copyright: 2006 6 | * License: GPL2 7 | **************************************************************/ 8 | 9 | #ifndef WX_PRECOMP 10 | #include 11 | #endif 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #if wxUSE_FINDREPLDLG 19 | #include 20 | #endif // wxUSE_FINDREPLDLG 21 | #include "widgets/dxtoolbar.h" 22 | #include "widgets/dxlistctrl.h" 23 | #include "Graph.h" 24 | #include "Progress.h" 25 | #include "FileInfo.h" 26 | 27 | class mApp : public wxApp 28 | { 29 | public: 30 | virtual bool OnInit(); 31 | virtual int OnExit(); 32 | protected: 33 | wxSingleInstanceChecker *m_checker; 34 | wxLocale *m_Locale; 35 | }; 36 | 37 | class mTaskBarIcon: public wxTaskBarIcon 38 | { 39 | DECLARE_EVENT_TABLE() 40 | public: 41 | #if defined(__WXCOCOA__) 42 | mTaskBarIcon(wxTaskBarIconType iconType = DEFAULT_TYPE) : wxTaskBarIcon(iconType) 43 | #else 44 | mTaskBarIcon() 45 | #endif 46 | {} 47 | ~mTaskBarIcon() {} 48 | 49 | virtual wxMenu *CreatePopupMenu(); 50 | private: 51 | void OnLeftButtonDClick(wxTaskBarIconEvent& event); 52 | void OnClose(wxCommandEvent& event); 53 | void OnHide(wxCommandEvent& event); 54 | void OnNew(wxCommandEvent& event); 55 | void OnBandUnlimited(wxCommandEvent& event); 56 | void OnBandControlOn(wxCommandEvent& event); 57 | void OnBandControlPerDownload(wxCommandEvent& event); 58 | }; 59 | 60 | class mMainFrame; 61 | 62 | class ProgressCtrl: public dxListCtrl 63 | { 64 | public: 65 | ProgressCtrl(mMainFrame *frame, wxWindow *parent, const wxWindowID id) 66 | : dxListCtrl(parent, id), m_frame(frame) {} 67 | 68 | void CreateColumns(); 69 | private: 70 | mMainFrame *m_frame; 71 | 72 | virtual wxString OnGetItemText(long item, long column) const; 73 | virtual int OnGetItemColumnImage(long item, long column) const; 74 | virtual wxListItemAttr *OnGetItemAttr(long item) const; 75 | }; 76 | 77 | class FinishedCtrl: public dxListCtrl 78 | { 79 | public: 80 | FinishedCtrl(mMainFrame *frame, wxWindow *parent, const wxWindowID id) 81 | : dxListCtrl(parent, id), m_frame(frame) {} 82 | 83 | void CreateColumns(); 84 | private: 85 | mMainFrame *m_frame; 86 | 87 | virtual wxString OnGetItemText(long item, long column) const; 88 | virtual int OnGetItemColumnImage(long item, long column) const; 89 | virtual wxListItemAttr *OnGetItemAttr(long item) const; 90 | }; 91 | 92 | class FinishedInfoCtrl: public dxListCtrl 93 | { 94 | public: 95 | FinishedInfoCtrl(mMainFrame *frame, wxWindow *parent, const wxWindowID id) 96 | : dxListCtrl(parent, id), m_frame(frame) {} 97 | 98 | void CreateColumns(); 99 | private: 100 | mMainFrame *m_frame; 101 | 102 | virtual wxString OnGetItemText(long item, long column) const; 103 | virtual int OnGetItemColumnImage(long item, long column) const; 104 | virtual wxListItemAttr *OnGetItemAttr(long item) const; 105 | }; 106 | 107 | class mEngine; 108 | 109 | class mMainFrame: public wxFrame 110 | { 111 | DECLARE_EVENT_TABLE() 112 | friend class mEngine; 113 | public: 114 | mMainFrame(); 115 | ~mMainFrame(); 116 | 117 | wxString GetDownloadItemText(long item, long column); 118 | int GetDownloadItemColumnImage(long item, long column); 119 | wxString GetFinishItemText(long item, long column); 120 | int GetFinishItemColumnImage(long item, long column); 121 | wxString GetFinishInfoItemText(long item, long column); 122 | wxString GetTaskTooltip(); 123 | void AddDownload(const wxString &destination, const wxString &comment, const wxString &reference, wxArrayString urls); 124 | protected: 125 | mEngine *m_engine; 126 | wxCriticalSection m_engineCS; 127 | private: 128 | wxBoxSizer *m_sizer; 129 | dxToolBar *m_bar; 130 | mTaskBarIcon *m_taskbaricon; 131 | wxMenuItem *m_menunew; 132 | wxMenuItem *m_menuremove; 133 | wxMenuItem *m_menuschedule; 134 | wxMenuItem *m_menustart; 135 | wxMenuItem *m_menustop; 136 | wxMenuItem *m_menustartall; 137 | wxMenuItem *m_menustopall; 138 | wxMenuItem *m_menupaste; 139 | wxMenuItem *m_menucopyurl; 140 | wxMenuItem *m_menucopydownloaddata; 141 | wxMenuItem *m_menuremoveall; 142 | wxMenuItem *m_menufind; 143 | wxMenuItem *m_menushowgraph; 144 | wxMenuItem *m_menudetails; 145 | wxMenuItem *m_menusite; 146 | wxMenuItem *m_menuproperties; 147 | wxMenuItem *m_menumove; 148 | wxMenuItem *m_menumd5; 149 | wxMenuItem *m_menuopendestination; 150 | wxMenuItem *m_menuagain; 151 | wxMenuItem *m_menuexport; 152 | wxMenuItem *m_menuimport; 153 | wxMenuItem *m_menushutdown; 154 | wxMenuItem *m_menudisconnect; 155 | wxNotebook *m_book; 156 | mGraph *m_graph; 157 | ProgressCtrl *m_progresslistctrl; 158 | FinishedCtrl *m_finishedlistctrl; 159 | FinishedInfoCtrl *m_finishedinfoctrl; 160 | wxSplitterWindow *m_progresssplitter; 161 | wxSplitterWindow *m_finishedsplitter; 162 | wxListbook *m_lbook; 163 | mProgress *m_progress; 164 | wxTextCtrl *m_detail; 165 | std::vector m_progressList; 166 | std::vector m_finishedList; 167 | wxScopedPtr m_imagelist; 168 | long m_selectedProgress; 169 | long m_selectedFinished; 170 | wxTimer m_timer; 171 | bool m_havenotify; 172 | wxSocketServer *m_server; 173 | wxString m_ipcString; 174 | #if wxUSE_FINDREPLDLG 175 | wxFindReplaceDialog *m_dlgFind; 176 | #endif // wxUSE_FINDREPLDLG 177 | 178 | void OnClose(wxCloseEvent& event); 179 | void OnQuit(wxCommandEvent& event); 180 | void OnAbout(wxCommandEvent& event); 181 | void OnSite(wxCommandEvent& event); 182 | void OnNew(wxCommandEvent& event); 183 | void OnRemove(wxCommandEvent& event); 184 | void OnSchedule(wxCommandEvent& event); 185 | void OnStart(wxCommandEvent& event); 186 | void OnStop(wxCommandEvent& event); 187 | void OnStartAll(wxCommandEvent& event); 188 | void OnStopAll(wxCommandEvent& event); 189 | void OnBug(wxCommandEvent& event); 190 | void OnDonate(wxCommandEvent& event); 191 | void OnShowGraph(wxCommandEvent& event); 192 | void OnDetails(wxCommandEvent& event); 193 | void OnPasteURL(wxCommandEvent& event); 194 | void OnOptions(wxCommandEvent& event); 195 | void OnProperties(wxCommandEvent& event); 196 | void OnRemoveAll(wxCommandEvent& event); 197 | void OnFind(wxCommandEvent& event); 198 | void OnDownloadAgain(wxCommandEvent& event); 199 | void OnMove(wxCommandEvent& event); 200 | void OnCheckMD5(wxCommandEvent& event); 201 | void OnOpenDestination(wxCommandEvent& event); 202 | void OnCopyURL(wxCommandEvent& event); 203 | void OnCopyDownloadData(wxCommandEvent& event); 204 | void OnExportConf(wxCommandEvent& event); 205 | void OnImportConf(wxCommandEvent& event); 206 | void OnShutdown(wxCommandEvent& event); 207 | void OnDisconnect(wxCommandEvent& event); 208 | void OnUp(wxCommandEvent& event); 209 | void OnDown(wxCommandEvent& event); 210 | void OnProgressRightClick(wxListEvent& event); 211 | void OnProgressActivated(wxListEvent& event); 212 | void OnProgressSelected(wxListEvent& event); 213 | void OnProgressDeselected(wxListEvent& event); 214 | void OnFinishedRightClick(wxListEvent& event); 215 | void OnFinishedActivated(wxListEvent& event); 216 | void OnFinishedSelected(wxListEvent& event); 217 | void OnFinishedDeselected(wxListEvent& event); 218 | void OnPageChanged(wxBookCtrlEvent& event); 219 | void OnGlobalStat(wxThreadEvent& event); 220 | void OnDownloadStat(wxThreadEvent& event); 221 | void OnCheckVersion(wxThreadEvent& event); 222 | void OnDownloadRemoved(wxThreadEvent& event); 223 | void OnEngineStarted(wxThreadEvent& event); 224 | void OnTimer(wxTimerEvent& event); 225 | void OnBandUnlimited(wxCommandEvent& event); 226 | void OnBandControlOn(wxCommandEvent& event); 227 | void OnBandControlPerDownload(wxCommandEvent& event); 228 | void OnServerEvent(wxSocketEvent& event); 229 | void OnSocketEvent(wxSocketEvent& event); 230 | #if wxUSE_FINDREPLDLG 231 | void OnFindDialog(wxFindDialogEvent& event); 232 | #endif // wxUSE_FINDREPLDLG 233 | 234 | void SetBandwidth(); 235 | void SetStatusBandwidth(); 236 | void SetStatusSpeed(int down, int up); 237 | void ShowHideResizeGraph(); 238 | void UpdateProgressList(); 239 | void UpdateFinishedList(); 240 | void EnableTools(); 241 | bool EnableStartAll(); 242 | bool SomeProcessActive(); 243 | bool SomeProcessOnDownload(); 244 | int LastIndex(); 245 | void StartDownload(size_t item); 246 | void PauseDownload(size_t item); 247 | bool ReadProgressList(wxString dir=""); 248 | bool ReadFinishedList(wxString dir=""); 249 | bool SaveProgressList(); 250 | bool SaveFinishedList(); 251 | std::string CreateGID(); 252 | bool HasGID(aria2::A2Gid gid); 253 | aria2::A2Gid GenerateGID(); 254 | bool ExportConf(wxString dir); 255 | void LogAfterFirstStart(size_t item); 256 | void UpdateDetail(); 257 | void ShowNotify(const wxString &title, const wxString &message); 258 | void ShutDownOrDisconnect(); 259 | void ParseReceived(const wxString &text); 260 | int CurrentSimultaneous(); 261 | void RemoveFromProgressList(size_t item); 262 | void RemoveFromFinishedList(size_t item, bool removefile); 263 | void SelectProgressByIndex(int index); 264 | }; 265 | -------------------------------------------------------------------------------- /src/BatchDialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: BatchDialog.cpp 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2021 5 | * License: GPL2 6 | **************************************************************/ 7 | 8 | #include 9 | #include 10 | #include "BatchDialog.h" 11 | #include "Defs.h" 12 | #include "UtilFunctions.h" 13 | #include "Options.h" 14 | 15 | IMPLEMENT_DYNAMIC_CLASS(mBatchDialog, wxDialog) 16 | 17 | BEGIN_EVENT_TABLE(mBatchDialog, wxDialog) 18 | EVT_BUTTON(wxID_OK, mBatchDialog::OnOk) 19 | EVT_BUTTON(wxID_CANCEL, mBatchDialog::OnCancel) 20 | EVT_BUTTON(ID_BATCH_DIRECTORY, mBatchDialog::OnDir) 21 | END_EVENT_TABLE() 22 | 23 | mBatchDialog::mBatchDialog(wxWindow *parent) 24 | : wxDialog(parent, wxID_ANY, _("Add new downloads")) 25 | { 26 | int i =0; 27 | m_mainSizer = new wxBoxSizer(wxVERTICAL); 28 | wxGridBagSizer *gridSizer = new wxGridBagSizer(5, 5); 29 | gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Save to:")), wxGBPosition(i,0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); 30 | m_destination = new wxTextCtrl(this, wxID_ANY, moptions.destination()); 31 | m_destination->SetMinSize(wxSize(222,-1)); 32 | m_destination->SetToolTip(moptions.destination()); 33 | gridSizer->Add(m_destination, wxGBPosition(i,1), wxDefaultSpan, wxEXPAND); 34 | gridSizer->Add(new wxButton(this, ID_BATCH_DIRECTORY, _("Directory")), wxGBPosition(i,2), wxDefaultSpan, wxEXPAND); 35 | i++; 36 | gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Address List:")), wxGBPosition(i,0), wxGBSpan(1,2)); 37 | i++; 38 | m_adresslist = new wxCheckListBox(this, wxID_ANY); 39 | m_adresslist->SetToolTip(_("Only the selected addresses will be downloaded")); 40 | m_adresslist->SetMaxClientSize(wxSize(450,-1)); 41 | gridSizer->Add(m_adresslist, wxGBPosition(i,0), wxGBSpan(1,2), wxEXPAND); 42 | i++; 43 | wxStaticBoxSizer *sbox1 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Server Permission")); 44 | wxGridBagSizer *gridSizer1 = new wxGridBagSizer(5, 5); 45 | gridSizer1->Add(new wxStaticText(this, wxID_ANY, _("User:")), wxGBPosition(0,0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); 46 | m_user = new wxTextCtrl(this, wxID_ANY); 47 | m_user->SetMinSize(wxSize(222,-1)); 48 | gridSizer1->Add(m_user, wxGBPosition(0,1), wxDefaultSpan, wxALL|wxEXPAND); 49 | gridSizer1->Add(new wxStaticText(this, wxID_ANY, _("Password:")), wxGBPosition(1,0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); 50 | m_password = new wxTextCtrl(this, wxID_ANY); 51 | gridSizer1->Add(m_password, wxGBPosition(1,1), wxDefaultSpan, wxALL|wxEXPAND); 52 | sbox1->Add(gridSizer1); 53 | gridSizer->Add(sbox1, wxGBPosition(i,0), wxGBSpan(1,2), wxEXPAND); 54 | wxStaticBoxSizer *sbox2 = new wxStaticBoxSizer(wxVERTICAL, this, _("Start Download")); 55 | m_manual = new wxRadioButton(this, wxID_ANY, _("Manual")); 56 | sbox2->Add(m_manual, 0); 57 | m_now = new wxRadioButton(this, wxID_ANY, _("Now")); 58 | m_now->SetValue(true); 59 | sbox2->Add(m_now, 0); 60 | m_schedule = new wxRadioButton(this, wxID_ANY, _("Schedule")); 61 | sbox2->Add(m_schedule, 0); 62 | gridSizer->Add(sbox2, wxGBPosition(i,2), wxGBSpan(1,2), wxEXPAND); 63 | i++; 64 | wxStaticBoxSizer *sbox3 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Segmented download")); 65 | wxGridBagSizer *gridSizer3 = new wxGridBagSizer(5, 5); 66 | gridSizer3->Add(new wxStaticText(this, wxID_ANY, _("Split download into how many\npieces?")), wxGBPosition(0,0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); 67 | m_split = new wxSpinCtrl(this, wxID_ANY, "5"); 68 | m_split->SetRange(1,30); 69 | gridSizer3->Add(m_split, wxGBPosition(1,0), wxDefaultSpan, wxALL|wxEXPAND); 70 | sbox3->Add(gridSizer3); 71 | gridSizer->Add(sbox3, wxGBPosition(i,0), wxGBSpan(1,2), wxEXPAND); 72 | wxStaticBoxSizer *sbox4 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Comments")); 73 | wxGridBagSizer *gridSizer4 = new wxGridBagSizer(5, 5); 74 | m_comment = new wxTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); 75 | m_comment->SetMinClientSize(wxSize(200,80)); 76 | gridSizer4->Add(m_comment, wxGBPosition(0,0), wxDefaultSpan, wxALL|wxEXPAND); 77 | sbox4->Add(gridSizer4); 78 | gridSizer->Add(sbox4, wxGBPosition(i,2), wxGBSpan(1,2), wxEXPAND); 79 | i++; 80 | wxStaticBoxSizer *sbox5 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Download bandwidth (in KB/s)")); 81 | m_bandwidth = new wxSpinCtrl(this, wxID_ANY); 82 | m_bandwidth->SetRange(0,5*1024); 83 | m_bandwidth->SetToolTip(_("Set band width limit for this download.\nSet \"0\" to unlimited.")); 84 | sbox5->Add(m_bandwidth); 85 | gridSizer->Add(sbox5, wxGBPosition(i,0), wxGBSpan(1,2)); 86 | i++; 87 | wxStaticBoxSizer *sbox6 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Reference URL")); 88 | m_referenceurl = new wxTextCtrl(this, wxID_ANY); 89 | sbox6->Add(m_referenceurl, 1, wxEXPAND, 5); 90 | gridSizer->Add(sbox6, wxGBPosition(i,0), wxGBSpan(1,4), wxEXPAND); 91 | i++; 92 | wxStaticBoxSizer *sbox7 = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Execute the following command after download completes")); 93 | m_command = new wxTextCtrl(this, wxID_ANY); 94 | sbox7->Add(m_command, 1, wxEXPAND, 5); 95 | gridSizer->Add(sbox7, wxGBPosition(i,0), wxGBSpan(1,4), wxEXPAND); 96 | m_mainSizer->Add(gridSizer, 1, wxEXPAND|wxALL, 5); 97 | 98 | wxStdDialogButtonSizer *btnSizer = new wxStdDialogButtonSizer(); 99 | wxButton* okButton = new wxButton(this, wxID_OK, "", wxDefaultPosition, wxDefaultSize, 0); 100 | btnSizer->AddButton(okButton); 101 | wxButton* cancelButton = new wxButton(this, wxID_CANCEL, "", wxDefaultPosition, wxDefaultSize, 0); 102 | btnSizer->AddButton(cancelButton); 103 | btnSizer->Realize(); 104 | m_mainSizer->Add(btnSizer, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5); 105 | 106 | this->SetSizer(m_mainSizer); 107 | m_mainSizer->Fit(this); 108 | m_mainSizer->SetSizeHints(this); 109 | } 110 | 111 | void mBatchDialog::SetDestination(const wxString &destination) 112 | { 113 | m_destination->SetValue(destination); 114 | } 115 | 116 | void mBatchDialog::SetNumberOfParts(int numberofparts) 117 | { 118 | m_split->SetValue(numberofparts); 119 | } 120 | 121 | void mBatchDialog::SetStartOption(int startoption) 122 | { 123 | if(startoption == 0) 124 | m_manual->SetValue(true); 125 | else if(startoption == 1) 126 | m_now->SetValue(true); 127 | else 128 | m_schedule->SetValue(true); 129 | } 130 | 131 | void mBatchDialog::SetCommand(const wxString &command) 132 | { 133 | m_command->SetValue(command); 134 | } 135 | 136 | void mBatchDialog::SetBandwidth(int bandwidth) 137 | { 138 | m_bandwidth->SetValue(bandwidth); 139 | } 140 | 141 | void mBatchDialog::SetUrls(const wxArrayString &urls) 142 | { 143 | m_adresslist->Clear(); 144 | m_adresslist->Append(urls); 145 | for(unsigned int i=0; i < m_adresslist->GetCount(); i++) 146 | { 147 | m_adresslist->Check(i); 148 | } 149 | } 150 | 151 | void mBatchDialog::SetUser(const wxString &user) 152 | { 153 | m_user->SetValue(user); 154 | } 155 | 156 | void mBatchDialog::SetPassword(const wxString &password) 157 | { 158 | m_password->SetValue(password); 159 | } 160 | 161 | void mBatchDialog::SetComment(const wxString &comment) 162 | { 163 | m_comment->SetValue(comment); 164 | } 165 | 166 | void mBatchDialog::SetReferenceURL(const wxString &url) 167 | { 168 | m_referenceurl->SetValue(url); 169 | } 170 | 171 | wxString mBatchDialog::GetDestination() const 172 | { 173 | return m_destination->GetValue(); 174 | } 175 | 176 | int mBatchDialog::GetNumberOfParts() const 177 | { 178 | return m_split->GetValue(); 179 | } 180 | 181 | int mBatchDialog::GetStartOption() const 182 | { 183 | if(m_manual->GetValue()) 184 | return 0; 185 | if(m_now->GetValue()) 186 | return 1; 187 | return 2; 188 | } 189 | 190 | wxString mBatchDialog::GetCommand() const 191 | { 192 | return m_command->GetValue(); 193 | } 194 | 195 | int mBatchDialog::GetBandwidth() const 196 | { 197 | return m_bandwidth->GetValue(); 198 | } 199 | 200 | wxArrayString mBatchDialog::GetUrls() 201 | { 202 | wxArrayString urls; 203 | for(unsigned int i=0; i < m_adresslist->GetCount(); i++) 204 | { 205 | if(m_adresslist->IsChecked(i)) 206 | urls.Add(m_adresslist->GetString(i)); 207 | } 208 | return urls; 209 | } 210 | 211 | wxString mBatchDialog::GetUser() const 212 | { 213 | return m_user->GetValue(); 214 | } 215 | 216 | wxString mBatchDialog::GetPassword() const 217 | { 218 | return m_password->GetValue(); 219 | } 220 | 221 | wxString mBatchDialog::GetComment() const 222 | { 223 | return m_comment->GetValue(); 224 | } 225 | 226 | wxString mBatchDialog::GetReferenceURL() const 227 | { 228 | return m_referenceurl->GetValue(); 229 | } 230 | 231 | void mBatchDialog::ReLayout() 232 | { 233 | m_mainSizer->Layout(); 234 | m_mainSizer->Fit(this); 235 | } 236 | 237 | void mBatchDialog::EnableAdresslist(bool enable) 238 | { 239 | m_adresslist->Enable(enable); 240 | } 241 | 242 | void mBatchDialog::EnableUser(bool enable) 243 | { 244 | m_user->Enable(enable); 245 | } 246 | 247 | void mBatchDialog::EnablePassword(bool enable) 248 | { 249 | m_password->Enable(enable); 250 | } 251 | 252 | void mBatchDialog::EnableManual(bool enable) 253 | { 254 | m_manual->Enable(enable); 255 | } 256 | 257 | void mBatchDialog::EnableNow(bool enable) 258 | { 259 | m_now->Enable(enable); 260 | } 261 | 262 | void mBatchDialog::EnableSchedule(bool enable) 263 | { 264 | m_schedule->Enable(enable); 265 | } 266 | 267 | void mBatchDialog::EnableSplit(bool enable) 268 | { 269 | m_split->Enable(enable); 270 | } 271 | 272 | void mBatchDialog::EnableComment(bool enable) 273 | { 274 | m_comment->Enable(enable); 275 | } 276 | 277 | void mBatchDialog::EnableBandwidth(bool enable) 278 | { 279 | m_bandwidth->Enable(enable); 280 | } 281 | 282 | void mBatchDialog::EnableReferenceurl(bool enable) 283 | { 284 | m_referenceurl->Enable(enable); 285 | } 286 | 287 | void mBatchDialog::EnableCommand(bool enable) 288 | { 289 | m_command->Enable(enable); 290 | } 291 | 292 | void mBatchDialog::OnOk(wxCommandEvent &/*event*/) 293 | { 294 | if(!GetUrls().GetCount()) 295 | { 296 | wxMessageBox(_("The URLs are empty"), _("Warning..."), wxOK|wxICON_WARNING, this); 297 | m_adresslist->SetFocus(); 298 | return; 299 | } 300 | if(!wxDirExists(m_destination->GetValue())) 301 | { 302 | wxMessageBox(_("The destination doesn't exist"), _("Warning..."), wxOK|wxICON_WARNING, this); 303 | wxCommandEvent event(wxEVT_BUTTON, ID_NEW_DIRECTORY); 304 | wxPostEvent(this, event); 305 | return; 306 | } 307 | EndModal(wxID_OK); 308 | } 309 | 310 | void mBatchDialog::OnCancel(wxCommandEvent &/*event*/) 311 | { 312 | EndModal(wxID_CANCEL); 313 | } 314 | 315 | void mBatchDialog::OnDir(wxCommandEvent &/*event*/) 316 | { 317 | wxString dir = wxDirSelector(_("Select the directory:"), m_destination->GetValue()); 318 | if(!dir.IsEmpty()) 319 | { 320 | m_destination->SetValue(dir); 321 | m_destination->SetToolTip(dir); 322 | } 323 | } 324 | -------------------------------------------------------------------------------- /src/UtilFunctions.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: UtilFunctions.h 3 | * Author: Max Magalhães Velasques (maxvelasques@gmail.com) 4 | * David Vachulka (archdvx@dxsolutions.org) 5 | * Copyright: 2006 6 | * License: GPL2 7 | **************************************************************/ 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "wxjson/include/wx/jsonreader.h" 15 | #include "wxjson/include/wx/jsonval.h" 16 | #include "UtilFunctions.h" 17 | 18 | wxString MyUtilFunctions::TimespanToWxstr(const uint64_t &span) 19 | { 20 | uint64_t time = span/1000; //round to seconds 21 | int hour = static_cast(time/3600); 22 | time -= hour*3600; 23 | int min = static_cast(time/60); 24 | int sec = static_cast(time%60); 25 | return wxString::Format("%02d:%02d:%02d", hour, min, sec); 26 | } 27 | 28 | wxString MyUtilFunctions::IntToWxstr(long value,int format) 29 | { 30 | wxString string; 31 | string << "%0" << format << "ld"; 32 | return wxString::Format(string,value); 33 | } 34 | 35 | wxString MyUtilFunctions::SpeedText(int speed, bool down, bool showPrefix) 36 | { 37 | if(speed >= 1024. * 1024. * 1024.) 38 | { 39 | if(showPrefix) return wxString::Format("%s %.2f GB/s", down?"D:":"U:", speed/1024./1024./1024.); 40 | else return wxString::Format("%.2f GB/s", speed/1024./1024./1024.); 41 | } 42 | else if(speed >= 1024. * 1024.) 43 | { 44 | if(showPrefix) return wxString::Format("%s %.2f MB/s", down?"D:":"U:", speed/1024./1024.); 45 | else return wxString::Format("%.2f MB/s", speed/1024./1024.); 46 | } 47 | else if(speed >= 1024.) 48 | { 49 | if(showPrefix) return wxString::Format("%s %.2f KB/s", down?"D:":"U:", speed/1024.); 50 | else return wxString::Format("%.2f KB/s", speed/1024.); 51 | } 52 | else 53 | { 54 | if(showPrefix) return wxString::Format("%s %.2f B/s", down?"D:":"U:", static_cast(speed)); 55 | else return wxString::Format("%.2f B/s", static_cast(speed)); 56 | } 57 | } 58 | 59 | wxString MyUtilFunctions::FromStdString(const std::string &str) 60 | { 61 | if(str.empty()) return ""; 62 | return wxString::FromUTF8(str.c_str()); 63 | } 64 | 65 | std::string MyUtilFunctions::ToStdString(const wxString &str) 66 | { 67 | if(str.empty()) return ""; 68 | return str.ToStdString(); 69 | } 70 | 71 | wxString MyUtilFunctions::SizeText(int64_t size) 72 | { 73 | if(size >= 1024. * 1024. * 1024.) 74 | { 75 | return wxString::Format("%.2f GB", size/1024./1024./1024.); 76 | } 77 | else if(size >= 1024. * 1024.) 78 | { 79 | return wxString::Format("%.2f MB", size/1024./1024.); 80 | } 81 | else if(size >= 1024.) 82 | { 83 | return wxString::Format("%.2f KB", size/1024.); 84 | } 85 | else 86 | { 87 | return wxString::Format("%lld B", size); 88 | } 89 | } 90 | 91 | std::vector MyUtilFunctions::ArrayStringToVector(const wxArrayString &array) 92 | { 93 | std::vector vector; 94 | for(size_t i=0; i < array.GetCount(); i++) 95 | { 96 | vector.push_back(ToStdString(array.Item(i))); 97 | } 98 | return vector; 99 | } 100 | 101 | wxString MyUtilFunctions::ArrayStringTowxString(const wxArrayString &array) 102 | { 103 | wxString result; 104 | for(size_t i=0; i < array.GetCount(); i++) 105 | { 106 | result << array.Item(i); 107 | if(i+1 != array.GetCount()) result << wxPATH_SEP; 108 | } 109 | return result; 110 | } 111 | 112 | wxString MyUtilFunctions::MimeType(const wxString &fname) 113 | { 114 | wxString type = ""; 115 | if(!wxFileName(fname).GetExt().IsEmpty()) 116 | { 117 | wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(wxFileName(fname).GetExt()); 118 | if(ft) 119 | { 120 | ft->GetMimeType(&type); 121 | delete ft; 122 | } 123 | } 124 | return type; 125 | } 126 | 127 | void MyUtilFunctions::BrowserIntegration(const wxString &path) 128 | { 129 | #ifdef __UNIX__ 130 | wxString integrator; 131 | if(!wxFileExists(path+wxFILE_SEP_PATH+"wxdfast-integrator")) //wxdfast run from build folder 132 | { 133 | integrator = path+wxFILE_SEP_PATH+"integrator/wxdfast-integrator"; 134 | } 135 | else 136 | { 137 | integrator = path+wxFILE_SEP_PATH+"wxdfast-integrator"; 138 | } 139 | wxArrayString ids; 140 | #ifdef __WXMAC__ 141 | wxString idpath = wxStandardPaths::Get().GetResourcesDir()+"/extensionid"; 142 | #else 143 | wxString idpath = wxString(WXDFAST_DATADIR)+wxFILE_SEP_PATH+"extensionid"; 144 | #endif 145 | if(wxFileExists(idpath)) 146 | { 147 | wxFile source(idpath, wxFile::read); 148 | source.Open(idpath); 149 | wxString text; 150 | source.ReadAll(&text); 151 | while(text.Find('\n') != wxNOT_FOUND) 152 | { 153 | ids.Add(text.BeforeFirst('\n')); 154 | text = text.AfterFirst('\n'); 155 | } 156 | source.Close(); 157 | } 158 | #ifdef __WXMAC__ 159 | //Firefox path 160 | CheckBrowser(wxGetHomeDir()+"/Library/Application Support/Mozilla", integrator, true, ids); 161 | //Chrome 162 | CheckBrowser(wxGetHomeDir()+"/Library/Application Support/Google/Chrome", integrator, false, ids); 163 | //Chromium 164 | CheckBrowser(wxGetHomeDir()+"/Library/Application Support/Chromium", integrator, false, ids); 165 | //Vivaldi 166 | CheckBrowser(wxGetHomeDir()+"/Library/Application Support/Vivaldi", integrator, false, ids); 167 | //Opera 168 | CheckBrowser(wxGetHomeDir()+"/Library/Application Support/Opera", integrator, false, ids); 169 | //Brave Bowser 170 | CheckBrowser(wxGetHomeDir()+"/Library/Application Support/BraveSoftware/Brave-Browser", integrator, false, ids); 171 | #else 172 | //Firefox path 173 | CheckBrowser(wxGetHomeDir()+"/.mozilla", integrator, true, ids); 174 | //Chrome 175 | CheckBrowser(wxGetHomeDir()+"/.config/google-chrome", integrator, false, ids); 176 | //Chromium 177 | CheckBrowser(wxGetHomeDir()+"/.config/chromium", integrator, false, ids); 178 | //Vivaldi 179 | CheckBrowser(wxGetHomeDir()+"/.config/vivaldi", integrator, false, ids); 180 | //Opera 181 | CheckBrowser(wxGetHomeDir()+"/.config/opera", integrator, false, ids); 182 | //Brave Bowser 183 | CheckBrowser(wxGetHomeDir()+"/.config/BraveSoftware/Brave-Browser", integrator, false, ids); 184 | #endif 185 | #endif 186 | } 187 | 188 | void MyUtilFunctions::CheckBrowser(const wxString &browserpath, const wxString &integratorpath, bool firefox, wxArrayString ids) 189 | { 190 | if(firefox) 191 | { 192 | #ifdef __WXMAC__ 193 | wxString host = "/NativeMessagingHosts"; 194 | #else 195 | wxString host = "/native-messaging-hosts"; 196 | #endif 197 | if(wxDirExists(browserpath)) 198 | { 199 | if(!wxDirExists(browserpath+host)) 200 | { 201 | wxMkdir(browserpath+host); 202 | } 203 | if(wxFileExists(browserpath+host+"/com.wxdfast.firefox.json")) //check path 204 | { 205 | wxJSONValue root; 206 | wxJSONReader reader; 207 | wxFFileInputStream stream(browserpath+host+"/com.wxdfast.firefox.json"); 208 | reader.Parse(stream, &root); 209 | if(!root.HasMember("path")) 210 | { 211 | wxRemoveFile(browserpath+host+"/com.wxdfast.firefox.json"); 212 | CreateFirefoxJson(browserpath+host+"/com.wxdfast.firefox.json", integratorpath); 213 | } 214 | else 215 | { 216 | if(root["path"].AsString() != integratorpath) 217 | { 218 | wxRemoveFile(browserpath+host+"/com.wxdfast.firefox.json"); 219 | CreateFirefoxJson(browserpath+host+"/com.wxdfast.firefox.json", integratorpath); 220 | } 221 | } 222 | } 223 | else //create new json 224 | { 225 | CreateFirefoxJson(browserpath+host+"/com.wxdfast.firefox.json", integratorpath); 226 | } 227 | } 228 | } 229 | else 230 | { 231 | if(wxDirExists(browserpath)) 232 | { 233 | if(!wxDirExists(browserpath+"/NativeMessagingHosts")) 234 | { 235 | wxMkdir(browserpath+"/NativeMessagingHosts"); 236 | } 237 | if(wxFileExists(browserpath+"/NativeMessagingHosts/com.wxdfast.chrome.json")) //check path 238 | { 239 | wxJSONValue root; 240 | wxJSONReader reader; 241 | wxFFileInputStream stream(browserpath+"/NativeMessagingHosts/com.wxdfast.chrome.json"); 242 | reader.Parse(stream, &root); 243 | if(!root.HasMember("path")) 244 | { 245 | wxRemoveFile(browserpath+"/NativeMessagingHosts/com.wxdfast.chrome.json"); 246 | CreateChromeJson(browserpath+"/NativeMessagingHosts/com.wxdfast.chrome.json", integratorpath, ids); 247 | } 248 | else 249 | { 250 | if(root["path"].AsString() != integratorpath) 251 | { 252 | wxRemoveFile(browserpath+"/NativeMessagingHosts/com.wxdfast.chrome.json"); 253 | CreateChromeJson(browserpath+"/NativeMessagingHosts/com.wxdfast.chrome.json", integratorpath, ids); 254 | } 255 | } 256 | if(!root.HasMember("allowed_origins")) 257 | { 258 | wxRemoveFile(browserpath+"/NativeMessagingHosts/com.wxdfast.chrome.json"); 259 | CreateChromeJson(browserpath+"/NativeMessagingHosts/com.wxdfast.chrome.json", integratorpath, ids); 260 | } 261 | else 262 | { 263 | wxString exts = root["allowed_origins"].AsString(); 264 | for(size_t i=0; i < ids.GetCount(); i++) 265 | { 266 | if(exts.Find(ids[i]) == wxNOT_FOUND) 267 | { 268 | wxRemoveFile(browserpath+"/NativeMessagingHosts/com.wxdfast.chrome.json"); 269 | CreateChromeJson(browserpath+"/NativeMessagingHosts/com.wxdfast.chrome.json", integratorpath, ids); 270 | break; 271 | } 272 | } 273 | } 274 | } 275 | else //create new json 276 | { 277 | CreateChromeJson(browserpath+"/NativeMessagingHosts/com.wxdfast.chrome.json", integratorpath, ids); 278 | } 279 | } 280 | } 281 | } 282 | 283 | void MyUtilFunctions::CreateFirefoxJson(const wxString &jsonpath, const wxString &integratorpath) 284 | { 285 | std::ofstream *json = new std::ofstream(jsonpath.ToStdString(), std::ios::out|std::ios::app); 286 | *json << "{\"name\":\"com.wxdfast.firefox\",\"description\":\"Integrate wxDownload Fast with Mozilla Firefox\",\"path\":"; 287 | *json << "\""; 288 | *json << integratorpath.ToStdString(); 289 | *json << "\","; 290 | *json << "\"type\":\"stdio\","; 291 | *json << "\"allowed_extensions\":[\"wxdfast@archdvx\"]}"; 292 | *json << std::endl; 293 | json->close(); 294 | delete json; 295 | } 296 | 297 | void MyUtilFunctions::CreateChromeJson(const wxString &jsonpath, const wxString &integratorpath, wxArrayString ids) 298 | { 299 | std::ofstream *json = new std::ofstream(jsonpath.ToStdString(), std::ios::out|std::ios::app); 300 | *json << "{\"name\":\"com.wxdfast.chrome\",\"description\":\"Integrate wxDownload Fast with Google Chrome and similar\",\"path\":"; 301 | *json << "\""; 302 | *json << integratorpath.ToStdString(); 303 | *json << "\","; 304 | *json << "\"type\":\"stdio\",\"allowed_origins\":["; 305 | for(size_t i=0; i < ids.GetCount(); i++) 306 | { 307 | *json << "\"chrome-extension://" << ids[i] << "/\""; 308 | if(ids.GetCount() > 1 && i+1 != ids.GetCount()) *json << ","; 309 | } 310 | *json << "]}"; 311 | *json << std::endl; 312 | json->close(); 313 | delete json; 314 | } 315 | -------------------------------------------------------------------------------- /resources/RipStop/license.txt: -------------------------------------------------------------------------------- 1 | License 2 | 3 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 4 | 5 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 6 | 7 | 1. Definitions 8 | 9 | 1. "Collective Work" means a work, such as a periodical issue, anthology or encyclopedia, in which the Work in its entirety in unmodified form, along with a number of other contributions, constituting separate and independent works in themselves, are assembled into a collective whole. A work that constitutes a Collective Work will not be considered a Derivative Work (as defined below) for the purposes of this License. 10 | 2. "Derivative Work" means a work based upon the Work or upon the Work and other pre-existing works, such as a translation, musical arrangement, dramatization, fictionalization, motion picture version, sound recording, art reproduction, abridgment, condensation, or any other form in which the Work may be recast, transformed, or adapted, except that a work that constitutes a Collective Work will not be considered a Derivative Work for the purpose of this License. For the avoidance of doubt, where the Work is a musical composition or sound recording, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered a Derivative Work for the purpose of this License. 11 | 3. "Licensor" means the individual or entity that offers the Work under the terms of this License. 12 | 4. "Original Author" means the individual or entity who created the Work. 13 | 5. "Work" means the copyrightable work of authorship offered under the terms of this License. 14 | 6. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. 15 | 7. "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike. 16 | 17 | 2. Fair Use Rights. Nothing in this license is intended to reduce, limit, or restrict any rights arising from fair use, first sale or other limitations on the exclusive rights of the copyright owner under copyright law or other applicable laws. 18 | 19 | 3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: 20 | 21 | 1. to reproduce the Work, to incorporate the Work into one or more Collective Works, and to reproduce the Work as incorporated in the Collective Works; 22 | 2. to create and reproduce Derivative Works; 23 | 3. to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission the Work including as incorporated in Collective Works; 24 | 4. to distribute copies or phonorecords of, display publicly, perform publicly, and perform publicly by means of a digital audio transmission Derivative Works. 25 | 5. 26 | 27 | For the avoidance of doubt, where the work is a musical composition: 28 | 1. Performance Royalties Under Blanket Licenses. Licensor waives the exclusive right to collect, whether individually or via a performance rights society (e.g. ASCAP, BMI, SESAC), royalties for the public performance or public digital performance (e.g. webcast) of the Work. 29 | 2. Mechanical Rights and Statutory Royalties. Licensor waives the exclusive right to collect, whether individually or via a music rights society or designated agent (e.g. Harry Fox Agency), royalties for any phonorecord You create from the Work ("cover version") and distribute, subject to the compulsory license created by 17 USC Section 115 of the US Copyright Act (or the equivalent in other jurisdictions). 30 | 6. Webcasting Rights and Statutory Royalties. For the avoidance of doubt, where the Work is a sound recording, Licensor waives the exclusive right to collect, whether individually or via a performance-rights society (e.g. SoundExchange), royalties for the public digital performance (e.g. webcast) of the Work, subject to the compulsory license created by 17 USC Section 114 of the US Copyright Act (or the equivalent in other jurisdictions). 31 | 32 | The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. All rights not expressly granted by Licensor are hereby reserved. 33 | 34 | 4. Restrictions.The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: 35 | 36 | 1. You may distribute, publicly display, publicly perform, or publicly digitally perform the Work only under the terms of this License, and You must include a copy of, or the Uniform Resource Identifier for, this License with every copy or phonorecord of the Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Work that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Work itself to be made subject to the terms of this License. If You create a Collective Work, upon notice from any Licensor You must, to the extent practicable, remove from the Collective Work any credit as required by clause 4(c), as requested. If You create a Derivative Work, upon notice from any Licensor You must, to the extent practicable, remove from the Derivative Work any credit as required by clause 4(c), as requested. 37 | 2. You may distribute, publicly display, publicly perform, or publicly digitally perform a Derivative Work only under the terms of this License, a later version of this License with the same License Elements as this License, or a Creative Commons iCommons license that contains the same License Elements as this License (e.g. Attribution-ShareAlike 2.5 Japan). You must include a copy of, or the Uniform Resource Identifier for, this License or other license specified in the previous sentence with every copy or phonorecord of each Derivative Work You distribute, publicly display, publicly perform, or publicly digitally perform. You may not offer or impose any terms on the Derivative Works that alter or restrict the terms of this License or the recipients' exercise of the rights granted hereunder, and You must keep intact all notices that refer to this License and to the disclaimer of warranties. You may not distribute, publicly display, publicly perform, or publicly digitally perform the Derivative Work with any technological measures that control access or use of the Work in a manner inconsistent with the terms of this License Agreement. The above applies to the Derivative Work as incorporated in a Collective Work, but this does not require the Collective Work apart from the Derivative Work itself to be made subject to the terms of this License. 38 | 3. If you distribute, publicly display, publicly perform, or publicly digitally perform the Work or any Derivative Works or Collective Works, You must keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or (ii) if the Original Author and/or Licensor designate another party or parties (e.g. a sponsor institute, publishing entity, journal) for attribution in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; the title of the Work if supplied; to the extent reasonably practicable, the Uniform Resource Identifier, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and in the case of a Derivative Work, a credit identifying the use of the Work in the Derivative Work (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). Such credit may be implemented in any reasonable manner; provided, however, that in the case of a Derivative Work or Collective Work, at a minimum such credit will appear where any other comparable authorship credit appears and in a manner at least as prominent as such other comparable authorship credit. 39 | 40 | 5. Representations, Warranties and Disclaimer 41 | 42 | UNLESS OTHERWISE AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE MATERIALS, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 43 | 44 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 45 | 46 | 7. Termination 47 | 48 | 1. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Derivative Works or Collective Works from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. 49 | 2. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 50 | 51 | 8. Miscellaneous 52 | 53 | 1. Each time You distribute or publicly digitally perform the Work or a Collective Work, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. 54 | 2. Each time You distribute or publicly digitally perform a Derivative Work, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. 55 | 3. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 56 | 4. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. 57 | 5. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. 58 | -------------------------------------------------------------------------------- /src/FileInfo.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: FileInfo.cpp 3 | * Author: Max Magalhães Velasques (maxvelasques@gmail.com) 4 | * David Vachulka (archdvx@dxsolutions.org) 5 | * Copyright: 2006 6 | * License: GPL2 7 | **************************************************************/ 8 | 9 | #include "FileInfo.h" 10 | #include "UtilFunctions.h" 11 | #include "Options.h" 12 | 13 | mFileInfo::mFileInfo() 14 | { 15 | m_gid = 0; 16 | m_name = wxEmptyString; 17 | m_totalLength = 0; 18 | m_downloadLength = 0; 19 | m_uploadLength = 0; 20 | m_downloadSpeed = 0; 21 | m_uploadSpeed = 0; 22 | m_numPieces = 0; 23 | m_timepassed = 0; 24 | m_status = STATUS_QUEUE; 25 | m_destination = moptions.destination(); 26 | m_index = -1; 27 | m_user = wxEmptyString; 28 | m_password = wxEmptyString; 29 | m_MD5 = wxEmptyString; 30 | m_SHA1 = wxEmptyString; 31 | m_SHA256 = wxEmptyString; 32 | m_connections = 0; 33 | m_bandwidth = 0; 34 | m_comment = wxEmptyString; 35 | m_link = wxEmptyString; 36 | m_command = wxEmptyString; 37 | m_bitfield = ""; 38 | m_parent = 0; 39 | m_numConnections = 0; 40 | m_startTime = wxDateTime::Now(); 41 | m_endTime = wxDateTime::Now(); 42 | m_attempts = 0; 43 | m_laststat = 0; 44 | } 45 | 46 | wxXmlNode *mFileInfo::createXmlNode() 47 | { 48 | wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, "File"); 49 | node->AddAttribute("index", wxString::Format("%d",m_index)); 50 | node->AddAttribute("gid", MyUtilFunctions::FromStdString(aria2::gidToHex(m_gid))); 51 | node->AddAttribute("status", wxString::Format("%d",m_status)); 52 | node->AddAttribute("name", m_name); 53 | node->AddAttribute("destination", m_destination); 54 | wxXmlNode *urls = new wxXmlNode(wxXML_ELEMENT_NODE, "URLs"); 55 | for(size_t i=0; i < m_urls.GetCount(); i++) 56 | { 57 | wxXmlNode *url = new wxXmlNode(wxXML_ELEMENT_NODE, "URL"); 58 | url->AddAttribute("value", m_urls[i]); 59 | urls->AddChild(url); 60 | } 61 | node->AddChild(urls); 62 | node->AddAttribute("user", m_user); 63 | node->AddAttribute("password", m_password); 64 | node->AddAttribute("md5", m_MD5); 65 | node->AddAttribute("sha1", m_SHA1); 66 | node->AddAttribute("sha256", m_SHA256); 67 | node->AddAttribute("connections", wxString::Format("%d",m_connections)); 68 | node->AddAttribute("bandwith", wxString::Format("%d",m_bandwidth)); 69 | node->AddAttribute("comment", m_comment); 70 | node->AddAttribute("link", m_link); 71 | node->AddAttribute("command", m_command); 72 | node->AddAttribute("totalLength", wxString::Format("%lld",m_totalLength)); 73 | node->AddAttribute("startTime", m_startTime.FormatISOCombined()); 74 | node->AddAttribute("endTime", m_endTime.FormatISOCombined()); 75 | node->AddAttribute("timepassed", wxString::Format("%llu",m_timepassed)); 76 | node->AddAttribute("log", m_log); 77 | node->AddAttribute("attempts", wxString::Format("%d",m_attempts)); 78 | return node; 79 | } 80 | 81 | bool mFileInfo::fromXmlNode(const wxXmlNode *node) 82 | { 83 | if(!node) return false; 84 | if(node->GetName() != "File") return false; 85 | m_index = wxAtoi(node->GetAttribute("index","-1")); 86 | m_gid = aria2::hexToGid(MyUtilFunctions::ToStdString(node->GetAttribute("gid","0000000000000000"))); 87 | m_status = wxAtoi(node->GetAttribute("status",wxString::Format("%d",STATUS_ERROR))); 88 | if(m_status < STATUS_STOPED || m_status > STATUS_SCHEDULE_ACTIVE) 89 | { 90 | m_status = STATUS_ERROR; 91 | } 92 | m_name = node->GetAttribute("name"); 93 | m_destination = node->GetAttribute("destination",moptions.destination()); 94 | m_urls.clear(); 95 | wxXmlNode *urlsNode = node->GetChildren(); 96 | wxXmlNode *urlNode = urlsNode->GetChildren(); 97 | while(urlNode) 98 | { 99 | m_urls.push_back(urlNode->GetAttribute("value")); 100 | urlNode = urlNode->GetNext(); 101 | } 102 | m_user = node->GetAttribute("user"); 103 | m_password = node->GetAttribute("password"); 104 | m_MD5 = node->GetAttribute("md5"); 105 | m_SHA1 = node->GetAttribute("sha1"); 106 | m_SHA256 = node->GetAttribute("sha256"); 107 | m_connections = wxAtoi(node->GetAttribute("connections", "1")); 108 | if(m_connections < 1 || m_connections > 16) 109 | { 110 | m_connections = 1; 111 | } 112 | m_bandwidth = wxAtoi(node->GetAttribute("bandwith", "0")); 113 | m_comment = node->GetAttribute("comment"); 114 | m_link = node->GetAttribute("link"); 115 | m_command = node->GetAttribute("command"); 116 | m_totalLength = static_cast(wxAtof(node->GetAttribute("totalLength", "0.0"))); 117 | m_startTime.ParseISOCombined(node->GetAttribute("startTime", wxDateTime::Now().FormatISOCombined())); 118 | m_endTime.ParseISOCombined(node->GetAttribute("endTime", wxDateTime::Now().FormatISOCombined())); 119 | m_timepassed = static_cast(wxAtof(node->GetAttribute("timepassed", "0.0"))); 120 | m_log = node->GetAttribute("log"); 121 | m_attempts = wxAtoi(node->GetAttribute("attempts","0")); 122 | return m_index != -1; 123 | } 124 | 125 | int mFileInfo::index() const 126 | { 127 | return m_index; 128 | } 129 | 130 | void mFileInfo::setIndex(int index) 131 | { 132 | m_index = index; 133 | } 134 | 135 | aria2::A2Gid mFileInfo::gid() const 136 | { 137 | return m_gid; 138 | } 139 | 140 | void mFileInfo::setGid(const aria2::A2Gid &gid) 141 | { 142 | m_gid = gid; 143 | } 144 | 145 | int mFileInfo::status() const 146 | { 147 | return m_status; 148 | } 149 | 150 | void mFileInfo::setStatus(int status) 151 | { 152 | m_status = status; 153 | } 154 | 155 | void mFileInfo::setStatusFromAriastatus(aria2::DownloadStatus status) 156 | { 157 | if(m_status == STATUS_SCHEDULE_ACTIVE || m_status == STATUS_SCHEDULE_QUEUE) 158 | { 159 | if(status == aria2::DOWNLOAD_ACTIVE) m_status = STATUS_SCHEDULE_ACTIVE; 160 | if(status == aria2::DOWNLOAD_COMPLETE) m_status = STATUS_FINISHED; 161 | if(status == aria2::DOWNLOAD_ERROR) m_status = STATUS_ERROR; 162 | return; 163 | } 164 | switch(status) { 165 | case aria2::DOWNLOAD_ACTIVE: m_status = STATUS_ACTIVE; break; 166 | case aria2::DOWNLOAD_WAITING: m_status = STATUS_STOPED; break; 167 | case aria2::DOWNLOAD_PAUSED: m_status = STATUS_QUEUE; break; 168 | case aria2::DOWNLOAD_COMPLETE: m_status = STATUS_FINISHED; break; 169 | case aria2::DOWNLOAD_ERROR: m_status = STATUS_ERROR; break; 170 | default: m_status = STATUS_STOPED; 171 | } 172 | } 173 | 174 | wxString mFileInfo::name() const 175 | { 176 | return m_name; 177 | } 178 | 179 | void mFileInfo::setName(const wxString &name) 180 | { 181 | m_name = name; 182 | } 183 | 184 | wxString mFileInfo::destination() const 185 | { 186 | return m_destination; 187 | } 188 | 189 | void mFileInfo::setDestination(const wxString &destination) 190 | { 191 | m_destination = destination; 192 | } 193 | 194 | wxArrayString mFileInfo::urls() const 195 | { 196 | return m_urls; 197 | } 198 | 199 | void mFileInfo::setUrls(const wxArrayString &urls) 200 | { 201 | m_urls = urls; 202 | } 203 | 204 | void mFileInfo::addUrl(const wxString &url) 205 | { 206 | m_urls.Add(url); 207 | } 208 | 209 | wxString mFileInfo::user() const 210 | { 211 | return m_user; 212 | } 213 | 214 | void mFileInfo::setUser(const wxString &user) 215 | { 216 | m_user = user; 217 | } 218 | 219 | wxString mFileInfo::password() const 220 | { 221 | return m_password; 222 | } 223 | 224 | void mFileInfo::setPassword(const wxString &password) 225 | { 226 | m_password = password; 227 | } 228 | 229 | wxString mFileInfo::MD5() const 230 | { 231 | return m_MD5; 232 | } 233 | 234 | void mFileInfo::setMD5(const wxString &MD5) 235 | { 236 | m_MD5 = MD5; 237 | } 238 | 239 | int mFileInfo::connections() const 240 | { 241 | return m_connections; 242 | } 243 | 244 | void mFileInfo::setConnections(int connections) 245 | { 246 | m_connections = connections; 247 | } 248 | 249 | int mFileInfo::bandwidth() const 250 | { 251 | return m_bandwidth; 252 | } 253 | 254 | void mFileInfo::setBandwidth(int bandwidth) 255 | { 256 | m_bandwidth = bandwidth; 257 | } 258 | 259 | wxString mFileInfo::comment() const 260 | { 261 | return m_comment; 262 | } 263 | 264 | void mFileInfo::setComment(const wxString &comment) 265 | { 266 | m_comment = comment; 267 | } 268 | 269 | wxString mFileInfo::link() const 270 | { 271 | return m_link; 272 | } 273 | 274 | void mFileInfo::setLink(const wxString &link) 275 | { 276 | m_link = link; 277 | } 278 | 279 | wxString mFileInfo::command() const 280 | { 281 | return m_command; 282 | } 283 | 284 | void mFileInfo::setCommand(const wxString &command) 285 | { 286 | m_command = command; 287 | } 288 | 289 | int64_t mFileInfo::totalLength() const 290 | { 291 | return m_totalLength; 292 | } 293 | 294 | void mFileInfo::setTotalLength(const int64_t &totalLength) 295 | { 296 | m_totalLength = totalLength; 297 | } 298 | 299 | int64_t mFileInfo::downloadLength() const 300 | { 301 | return m_downloadLength; 302 | } 303 | 304 | void mFileInfo::setDownloadLength(const int64_t &downloadLength) 305 | { 306 | m_downloadLength = downloadLength; 307 | } 308 | 309 | int64_t mFileInfo::uploadLength() const 310 | { 311 | return m_uploadLength; 312 | } 313 | 314 | void mFileInfo::setUploadLength(const int64_t &uploadLength) 315 | { 316 | m_uploadLength = uploadLength; 317 | } 318 | 319 | std::string mFileInfo::bitfield() const 320 | { 321 | return m_bitfield; 322 | } 323 | 324 | void mFileInfo::setBitfield(const std::string &bitfield) 325 | { 326 | m_bitfield = bitfield; 327 | } 328 | 329 | int mFileInfo::downloadSpeed() const 330 | { 331 | return m_downloadSpeed; 332 | } 333 | 334 | void mFileInfo::setDownloadSpeed(int downloadSpeed) 335 | { 336 | m_downloadSpeed = downloadSpeed; 337 | } 338 | 339 | int mFileInfo::uploadSpeed() const 340 | { 341 | return m_uploadSpeed; 342 | } 343 | 344 | void mFileInfo::setUploadSpeed(int uploadSpeed) 345 | { 346 | m_uploadSpeed = uploadSpeed; 347 | } 348 | 349 | aria2::A2Gid mFileInfo::parent() const 350 | { 351 | return m_parent; 352 | } 353 | 354 | void mFileInfo::setParent(const aria2::A2Gid &parent) 355 | { 356 | m_parent = parent; 357 | } 358 | 359 | int mFileInfo::numPieces() const 360 | { 361 | if(!totalLength()) return 0; 362 | return m_numPieces; 363 | } 364 | 365 | void mFileInfo::setNumPieces(int numPieces) 366 | { 367 | m_numPieces = numPieces; 368 | } 369 | 370 | int mFileInfo::numConnections() const 371 | { 372 | return m_numConnections; 373 | } 374 | 375 | void mFileInfo::setNumConnections(int numConnections) 376 | { 377 | m_numConnections = numConnections; 378 | } 379 | 380 | wxDateTime mFileInfo::startTime() const 381 | { 382 | return m_startTime; 383 | } 384 | 385 | void mFileInfo::setStartTime(const wxDateTime &startTime) 386 | { 387 | m_startTime = startTime; 388 | } 389 | 390 | wxDateTime mFileInfo::endTime() const 391 | { 392 | return m_endTime; 393 | } 394 | 395 | void mFileInfo::setEndTime(const wxDateTime &endTime) 396 | { 397 | m_endTime = endTime; 398 | } 399 | 400 | uint64_t mFileInfo::timepassed() const 401 | { 402 | return m_timepassed; 403 | } 404 | 405 | void mFileInfo::addTimepassed(int milliseconds) 406 | { 407 | m_timepassed += milliseconds; 408 | } 409 | 410 | void mFileInfo::clearTimepassed() 411 | { 412 | m_timepassed = 0; 413 | } 414 | 415 | wxString mFileInfo::log() const 416 | { 417 | return m_log; 418 | } 419 | 420 | void mFileInfo::appendLogLine(const wxString &line) 421 | { 422 | m_log << line << "\n"; 423 | } 424 | 425 | void mFileInfo::clearLog() 426 | { 427 | m_log = ""; 428 | } 429 | 430 | int mFileInfo::attempts() const 431 | { 432 | return m_attempts; 433 | } 434 | 435 | void mFileInfo::setAttempts(int newAttempts) 436 | { 437 | m_attempts = newAttempts; 438 | } 439 | 440 | void mFileInfo::addAttempt() 441 | { 442 | m_attempts++; 443 | } 444 | 445 | uint64_t mFileInfo::laststat() const 446 | { 447 | return m_laststat; 448 | } 449 | 450 | void mFileInfo::setLaststat(const uint64_t &newLaststat) 451 | { 452 | m_laststat = newLaststat; 453 | } 454 | 455 | const wxString &mFileInfo::SHA1() const 456 | { 457 | return m_SHA1; 458 | } 459 | 460 | void mFileInfo::setSHA1(const wxString &newSHA1) 461 | { 462 | m_SHA1 = newSHA1; 463 | } 464 | 465 | const wxString &mFileInfo::SHA256() const 466 | { 467 | return m_SHA256; 468 | } 469 | 470 | void mFileInfo::setSHA256(const wxString &newSHA256) 471 | { 472 | m_SHA256 = newSHA256; 473 | } 474 | -------------------------------------------------------------------------------- /src/Engine.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | * Name: Engine.cpp 3 | * Author: David Vachulka (archdvx@dxsolutions.org) 4 | * Copyright: 2021 5 | * License: GPL2 6 | **************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include "Engine.h" 12 | #include "wxDFast.h" 13 | #include "Options.h" 14 | #include "Defs.h" 15 | #include "UtilFunctions.h" 16 | 17 | mEngine::mEngine(mMainFrame *frame) 18 | : wxThread(wxTHREAD_DETACHED) 19 | { 20 | m_frame = frame; 21 | m_versionGid = 0; 22 | m_checkversion = false; 23 | m_started = false; 24 | } 25 | 26 | mEngine::~mEngine() 27 | { 28 | wxCriticalSectionLocker enter(m_frame->m_engineCS); 29 | m_frame->m_engine = nullptr; 30 | } 31 | 32 | void *mEngine::Entry() 33 | { 34 | aria2::SessionConfig config; 35 | config.keepRunning = true; 36 | aria2::KeyVals options; 37 | //NOTE 0.70.x will not work as BT downloader/uploader 38 | options.push_back(std::make_pair("follow-torrent","false")); 39 | options.push_back(std::make_pair("max-overall-download-limit",moptions.livebandwidthoption()==2?std::to_string(moptions.bandwidth())+"K":"0")); 40 | if(moptions.proxy()) 41 | { 42 | if(moptions.proxyPort().IsEmpty()) options.push_back(std::make_pair("all-proxy",MyUtilFunctions::ToStdString(moptions.proxyServer()))); 43 | else options.push_back(std::make_pair("all-proxy",MyUtilFunctions::ToStdString(moptions.proxyServer()+":"+moptions.proxyPort()))); 44 | options.push_back(std::make_pair("all-proxy-passwd",MyUtilFunctions::ToStdString(moptions.proxyAuthstring()))); 45 | options.push_back(std::make_pair("all-proxy-user",MyUtilFunctions::ToStdString(moptions.proxyUsername()))); 46 | } 47 | #ifdef __WXMSW__ 48 | options.push_back(std::make_pair("ca-certificate",MyUtilFunctions::ToStdString(wxString(WXDFAST_DATADIR)+wxFILE_SEP_PATH+"ca-certs"+wxFILE_SEP_PATH+"cert.pem"))); 49 | #endif 50 | m_session = aria2::sessionNew(options, config); 51 | auto graph = std::chrono::steady_clock::now(); 52 | auto update = graph; 53 | while(!TestDestroy()) 54 | { 55 | int rv = aria2::run(m_session, aria2::RUN_ONCE); 56 | if(rv != 1) 57 | { 58 | break; 59 | } 60 | if(!m_started) 61 | { 62 | m_started = true; 63 | wxThreadEvent event(wxEVT_THREAD, ID_ENGINE_STARTED); 64 | wxQueueEvent(m_frame, event.Clone()); 65 | } 66 | auto now = std::chrono::steady_clock::now(); 67 | auto count = std::chrono::duration_cast(now - graph).count(); 68 | if(count >= moptions.graphrefreshtime()) 69 | { 70 | graph = now; 71 | aria2::GlobalStat st = aria2::getGlobalStat(m_session); 72 | GlobalEvent event(ID_ENGINE_GLOBAL, st.downloadSpeed, st.uploadSpeed, st.numActive, st.numWaiting, st.numStopped); 73 | wxQueueEvent(m_frame, event.Clone()); 74 | } 75 | count = std::chrono::duration_cast(now - update).count(); 76 | if(count >= moptions.timerupdateinterval()) 77 | { 78 | update = now; 79 | std::vector gids = aria2::getActiveDownload(m_session); 80 | for(const auto &gid : gids) 81 | { 82 | if(gid != 0 && gid != m_versionGid && std::find(m_gids.begin(), m_gids.end(), gid) == m_gids.end()) 83 | m_gids.push_back(gid); 84 | } 85 | for(auto it = m_gids.begin(); it != m_gids.end();) 86 | { 87 | aria2::DownloadHandle* dh = aria2::getDownloadHandle(m_session, (*it)); 88 | if(dh) 89 | { 90 | if(dh->getStatus() == aria2::DOWNLOAD_REMOVED) 91 | { 92 | DownloadEvent event(ID_ENGINE_REMOVED, (*it), dh->getStatus(), 0, 0, 0, "", 0, 0, 0, 0); 93 | wxQueueEvent(m_frame, event.Clone()); 94 | aria2::deleteDownloadHandle(dh); 95 | it = m_gids.erase(it); 96 | continue; 97 | } 98 | if(dh->getStatus() == aria2::DOWNLOAD_COMPLETE || dh->getStatus() == aria2::DOWNLOAD_ERROR) 99 | { 100 | DownloadEvent event(ID_ENGINE_DOWNLOAD, (*it), dh->getStatus(), dh->getTotalLength(), dh->getCompletedLength(), dh->getUploadLength(), 101 | dh->getBitfield(), dh->getDownloadSpeed(), dh->getUploadSpeed(), dh->getPieceLength(), dh->getNumPieces()); 102 | wxQueueEvent(m_frame, event.Clone()); 103 | aria2::deleteDownloadHandle(dh); 104 | it = m_gids.erase(it); 105 | continue; 106 | } 107 | DownloadEvent event(ID_ENGINE_DOWNLOAD, (*it), dh->getStatus(), dh->getTotalLength(), dh->getCompletedLength(), dh->getUploadLength(), 108 | dh->getBitfield(), dh->getDownloadSpeed(), dh->getUploadSpeed(), dh->getPieceLength(), dh->getNumPieces()); 109 | wxQueueEvent(m_frame, event.Clone()); 110 | aria2::deleteDownloadHandle(dh); 111 | } 112 | ++it; 113 | } 114 | if(m_checkversion && m_versionGid) 115 | { 116 | aria2::DownloadHandle* dh = aria2::getDownloadHandle(m_session, m_versionGid); 117 | if(dh && (dh->getStatus() == aria2::DOWNLOAD_COMPLETE || dh->getStatus() == aria2::DOWNLOAD_ERROR)) 118 | { 119 | m_versionGid = 0; 120 | m_checkversion = false; 121 | wxThreadEvent event(wxEVT_THREAD, ID_ENGINE_VERSION); 122 | wxQueueEvent(m_frame, event.Clone()); 123 | aria2::deleteDownloadHandle(dh); 124 | } 125 | } 126 | } 127 | } 128 | aria2::shutdown(m_session, true); 129 | return (wxThread::ExitCode)0; 130 | } 131 | 132 | void mEngine::OnExit() 133 | { 134 | } 135 | 136 | aria2::A2Gid mEngine::CheckVersion() 137 | { 138 | m_versionGid = 0; 139 | std::vector uris; 140 | uris.push_back("https://dxsolutions.org/wxdfast-version"); 141 | aria2::KeyVals options; 142 | options.push_back(std::make_pair("dir",MyUtilFunctions::ToStdString(wxStandardPaths::Get().GetUserDataDir()))); 143 | int rv = aria2::addUri(m_session, &m_versionGid, uris, options); 144 | if(rv < 0) 145 | { 146 | std::cerr << "Failed to check version" << std::endl; 147 | } 148 | else 149 | { 150 | m_checkversion = true; 151 | } 152 | return m_versionGid; 153 | } 154 | 155 | mFileInfo mEngine::FillInfo(aria2::A2Gid gid) 156 | { 157 | mFileInfo info; 158 | aria2::DownloadHandle* dh = aria2::getDownloadHandle(m_session, gid); 159 | if(dh) 160 | { 161 | info.setGid(gid); 162 | info.setStatus(dh->getStatus()); 163 | info.setName(wxFileNameFromPath(MyUtilFunctions::FromStdString(dh->getFile(1).path))); 164 | info.setDestination(MyUtilFunctions::FromStdString(dh->getDir())); 165 | info.setTotalLength(dh->getTotalLength()); 166 | info.setParent(dh->getBelongsTo()); 167 | std::vector uris = dh->getFile(1).uris; 168 | wxArrayString urls; 169 | for(const auto &uri : uris) 170 | { 171 | urls.push_back(MyUtilFunctions::FromStdString(uri.uri)); 172 | } 173 | info.setUrls(urls); 174 | info.setNumPieces(dh->getNumPieces()); 175 | aria2::deleteDownloadHandle(dh); 176 | } 177 | return info; 178 | } 179 | 180 | void mEngine::AddFileInfo(const mFileInfo &info) 181 | { 182 | AddGid(info.gid()); 183 | aria2::KeyVals options; 184 | options.push_back(std::make_pair("dir",MyUtilFunctions::ToStdString(info.destination()))); 185 | options.push_back(std::make_pair("split",std::to_string(info.connections()))); 186 | options.push_back(std::make_pair("max-connection-per-server",std::to_string(info.connections()))); 187 | options.push_back(std::make_pair("max-download-limit",moptions.livebandwidthoption()==1?std::to_string(info.bandwidth())+"K":"0")); 188 | options.push_back(std::make_pair("max-tries",std::to_string(moptions.attempts()))); 189 | options.push_back(std::make_pair("retry-wait",std::to_string(moptions.attemptstime()))); 190 | options.push_back(std::make_pair("gid",aria2::gidToHex(info.gid()))); 191 | if(!info.user().IsEmpty()) 192 | { 193 | options.push_back(std::make_pair("http-user",MyUtilFunctions::ToStdString(info.user()))); 194 | options.push_back(std::make_pair("ftp-user",MyUtilFunctions::ToStdString(info.user()))); 195 | } 196 | if(!info.password().IsEmpty()) 197 | { 198 | options.push_back(std::make_pair("http-passwd",MyUtilFunctions::ToStdString(info.password()))); 199 | options.push_back(std::make_pair("ftp-passwd",MyUtilFunctions::ToStdString(info.password()))); 200 | } 201 | aria2::addUri(m_session, nullptr, MyUtilFunctions::ArrayStringToVector(info.urls()), options); 202 | } 203 | 204 | void mEngine::AddGid(aria2::A2Gid gid) 205 | { 206 | if(std::find(m_gids.begin(), m_gids.end(), gid) != m_gids.end()) 207 | return; 208 | m_gids.push_back(gid); 209 | } 210 | 211 | bool mEngine::HasGid(aria2::A2Gid gid) 212 | { 213 | if(std::find(m_gids.begin(), m_gids.end(), gid) != m_gids.end()) 214 | return true; 215 | return false; 216 | } 217 | 218 | bool mEngine::IsActive(aria2::A2Gid gid) 219 | { 220 | std::vector gids = aria2::getActiveDownload(m_session); 221 | if(std::find(gids.begin(), gids.end(), gid) != gids.end()) 222 | return true; 223 | return false; 224 | } 225 | 226 | void mEngine::PauseDownload(aria2::A2Gid gid) 227 | { 228 | if(aria2::isNull(gid)) 229 | return; 230 | aria2::pauseDownload(m_session, gid); 231 | } 232 | 233 | void mEngine::ResumeDownload(aria2::A2Gid gid, const wxString &destination, int connections, int bandwidth) 234 | { 235 | if(aria2::isNull(gid)) 236 | return; 237 | aria2::KeyVals options; 238 | options.push_back(std::make_pair("dir",MyUtilFunctions::ToStdString(destination))); 239 | options.push_back(std::make_pair("split",std::to_string(connections))); 240 | options.push_back(std::make_pair("max-connection-per-server",std::to_string(connections))); 241 | options.push_back(std::make_pair("max-download-limit",moptions.livebandwidthoption()==1?std::to_string(bandwidth)+"K":"0")); 242 | options.push_back(std::make_pair("max-tries",std::to_string(moptions.attempts()))); 243 | options.push_back(std::make_pair("retry-wait",std::to_string(moptions.attemptstime()))); 244 | aria2::changeOption(m_session, gid, options); 245 | aria2::unpauseDownload(m_session, gid); 246 | } 247 | 248 | bool mEngine::RemoveDownload(aria2::A2Gid gid) 249 | { 250 | if(aria2::isNull(gid)) 251 | return false; 252 | if(aria2::removeDownload(m_session, gid) < 0) 253 | return false; 254 | return true; 255 | } 256 | 257 | wxString mEngine::RealFileName(aria2::A2Gid gid) 258 | { 259 | wxString name = ""; 260 | if(aria2::isNull(gid)) 261 | return name; 262 | aria2::DownloadHandle* dh = aria2::getDownloadHandle(m_session, gid); 263 | if(dh) 264 | { 265 | name = wxFileNameFromPath(MyUtilFunctions::FromStdString(dh->getFile(1).path)); 266 | aria2::deleteDownloadHandle(dh); 267 | } 268 | return name; 269 | } 270 | 271 | void mEngine::SetGlobalBandwith() 272 | { 273 | if(moptions.livebandwidthoption() == 2) 274 | { 275 | aria2::KeyVals options; 276 | options.push_back(std::make_pair("max-overall-download-limit",std::to_string(moptions.bandwidth())+"K")); 277 | aria2::changeGlobalOption(m_session, options); 278 | } 279 | else 280 | { 281 | aria2::KeyVals options; 282 | options.push_back(std::make_pair("max-overall-download-limit","0")); 283 | aria2::changeGlobalOption(m_session, options); 284 | } 285 | } 286 | 287 | void mEngine::SetDownloadBandwith(aria2::A2Gid gid, int bandwidth) 288 | { 289 | if(aria2::isNull(gid)) 290 | return; 291 | aria2::KeyVals options; 292 | options.push_back(std::make_pair("max-download-limit",moptions.livebandwidthoption()==1?std::to_string(bandwidth)+"K":"0")); 293 | aria2::changeOption(m_session, gid, options); 294 | } 295 | 296 | void mEngine::UpdateOptions() 297 | { 298 | if(moptions.proxy()) 299 | { 300 | aria2::KeyVals options; 301 | if(moptions.proxyPort().IsEmpty()) options.push_back(std::make_pair("all-proxy",MyUtilFunctions::ToStdString(moptions.proxyServer()))); 302 | else options.push_back(std::make_pair("all-proxy",MyUtilFunctions::ToStdString(moptions.proxyServer()+":"+moptions.proxyPort()))); 303 | options.push_back(std::make_pair("all-proxy-passwd",MyUtilFunctions::ToStdString(moptions.proxyAuthstring()))); 304 | options.push_back(std::make_pair("all-proxy-user",MyUtilFunctions::ToStdString(moptions.proxyUsername()))); 305 | aria2::changeGlobalOption(m_session, options); 306 | } 307 | else 308 | { 309 | aria2::KeyVals options; 310 | options.push_back(std::make_pair("all-proxy","")); 311 | aria2::changeGlobalOption(m_session, options); 312 | } 313 | for(const auto &gid : m_gids) 314 | { 315 | if(!aria2::isNull(gid)) 316 | { 317 | aria2::KeyVals options; 318 | options.push_back(std::make_pair("max-tries",std::to_string(moptions.attempts()))); 319 | options.push_back(std::make_pair("retry-wait",std::to_string(moptions.attemptstime()))); 320 | aria2::changeOption(m_session, gid, options); 321 | } 322 | } 323 | } 324 | --------------------------------------------------------------------------------