Skip to content

Commit

Permalink
Improvement: proxy support
Browse files Browse the repository at this point in the history
  • Loading branch information
r57zone committed Mar 3, 2022
1 parent 158faf1 commit ccc1701
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 49 deletions.
12 changes: 6 additions & 6 deletions Source/Languages/English.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@ ID_PODCASTS_NOT_FOUND=New podcasts not found
ID_DOWNLOAD_ERROR=Download error, downloaded podcasts: %d of %d
ID_NEW_FEED_QUESTION=After adding a new feed is recommended to\nskip downloading all new podcasts.\n\nSkip the download podcasts (Yes) or\ndownload all podcasts of new feed (No)?

;Remove old links
# Remove old links
ID_STAGE_1=Preparing the common list
ID_STAGE_2=Checking links in list
ID_REMOVED_LINKS=Removed outdated links:
ID_FAILED_GET_RSS=Error, feed "%s" not available.\nIf it ceased to exist, then simply remove it and try again.

;About
[About]
ID_ABOUT_TITLE=About...
ID_LAST_UPDATE=Last update:

;Other
ID_UPLOADED_PODCASTS_TO_DEVICE=All podcasts downloaded to device

[Settings]
ID_SETTINGS_TITLE=Settings
ID_COMMON=Common
Expand All @@ -34,10 +31,13 @@ ID_CHOOSE_DIR_ERROR=Folder not chosen
ID_DOWNLOAD_PODCASTS=Download podcasts
ID_IMPORT=Import
ID_EXPORT=Export
ID_PROXY=Proxy
ID_ADDRESS=Address
ID_PORT=Port
ID_OPML_FILE_SAVED=OPML file was successfully saved
ID_ADDED_OPML_FEED=Added RSS feeds:
ID_DOWNLOADED_PODCASTS=Downloaded podcasts
ID_DOWNLOADED_PODCASTS_DESCRIPTION=Once every 3-4 months, is desirable to clean database links\nto find new podcasts are not slowed down.
ID_DOWNLOADED_PODCASTS_DESCRIPTION=Once every 3-4 months, is desirable to clean\ndatabase links to find new podcasts are not\nslowed down.
ID_REMOVE_OLD_LINKS=Clear
ID_OK=OK
ID_CANCEL=Cancel
12 changes: 6 additions & 6 deletions Source/Languages/Russian.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@ ID_PODCASTS_NOT_FOUND=
ID_DOWNLOAD_ERROR=Ошибка загрузки, загружено подкастов: %d из %d
ID_NEW_FEED_QUESTION=После добавления новой ленты рекомендуется\nпропустить загрузку всех подкастов.\n\nПропустить загрузку подкастов (Да)\nили загрузить все подкасты новой ленты (Нет)?

;Remove old links
# Remove old links
ID_STAGE_1=Подготовка общего списка
ID_STAGE_2=Проверка ссылок в списке
ID_REMOVED_LINKS=Удалено устаревших ссылок:
ID_FAILED_GET_RSS=Ошибка, лента "%s" недоступна.\nЕсли она перестала существовать, то просто удалите ее и\nповторите попытку.

;About
[About]
ID_ABOUT_TITLE=О программе...
ID_LAST_UPDATE=Последнее обновление:

;Other
ID_UPLOADED_PODCASTS_TO_DEVICE=Все подкасты загружены на устройство

[Settings]
ID_SETTINGS_TITLE=Настройки
ID_COMMON=Общие
Expand All @@ -34,10 +31,13 @@ ID_CHOOSE_DIR_ERROR=
ID_DOWNLOAD_PODCASTS=Загружать подкасты
ID_IMPORT=Импорт
ID_EXPORT=Экспорт
ID_PROXY=Прокси
ID_ADDRESS=Адрес
ID_PORT=Порт
ID_OPML_FILE_SAVED=OPML файл успешно сохранен
ID_ADDED_OPML_FEED=Добавлено RSS лент:
ID_DOWNLOADED_PODCASTS=Загруженные подкасты
ID_DOWNLOADED_PODCASTS_DESCRIPTION=Раз в 3-4 месяца желательно очищать базу ссылок,\nчтобы поиск новых подкастов не замедлялся.
ID_DOWNLOADED_PODCASTS_DESCRIPTION=Раз в 3-4 месяца желательно очищать\nбазу ссылок, чтобы поиск новых подкастов\nне замедлялся.
ID_REMOVE_OLD_LINKS=Очистить
ID_OK=ОК
ID_CANCEL=Отмена
7 changes: 5 additions & 2 deletions Source/Setup.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[Main]
;https://github.com/r57zone/Standard-modular-program
ModuleWndID=
Path=

[Proxy]
Address=
Port=
33 changes: 25 additions & 8 deletions Source/Unit1.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, WinInet, XPMan, ComCtrls, IniFiles, ShellAPI, ExtCtrls,
Buttons, RegExpr;
Buttons, RegExpr, UrlMon;

type
TMain = class(TForm)
Expand Down Expand Up @@ -40,6 +40,7 @@ TMain = class(TForm)
var
Main: TMain;
DownloadPath, LangFile: string;
ProxyAddress, ProxyPort: string;
StopDownload, DownloadPodcasts, RssChanged: boolean;

//Ïåðåâîä / Translate
Expand All @@ -54,9 +55,6 @@ TMain = class(TForm)

ID_GUIDE: string;

//StandartModularProgram
ID_UPLOADED_PODCASTS_TO_DEVICE: string;

implementation

uses Unit2;
Expand Down Expand Up @@ -345,7 +343,7 @@ procedure TMain.RefreshBtnClick(Sender: TObject);

end;

RefreshBtn.Visible:=false;
//RefreshBtn.Visible:=false;
CancelBtn.Visible:=true;
Main.Refresh;

Expand Down Expand Up @@ -395,12 +393,27 @@ procedure TMain.RefreshBtnClick(Sender: TObject);
RssListMemo.ReadOnly:=false;
SettingsBtn.Enabled:=true;

RefreshBtn.Refresh;
OpenFolderBtn.Refresh;

Download.Free;
GetRss.Free;
Downloaded.Free;
RegExp.Free;
end;

procedure ProxyInit(ProxyAddress, ProxyPort: string);
var
PIInfo: PInternetProxyInfo;
begin
New(PIInfo);
PIInfo^.dwAccessType:=INTERNET_OPEN_TYPE_PROXY;
PIInfo^.lpszProxy:=PChar(ProxyAddress + ':' + ProxyPort);
PIInfo^.lpszProxyBypass:=PChar('');
UrlMkSetSessionOption(INTERNET_OPTION_PROXY, PIInfo, SizeOf(Internet_Proxy_Info), 0);
Dispose(PIInfo);
end;

procedure TMain.FormCreate(Sender: TObject);
var
Ini: TIniFile;
Expand All @@ -412,8 +425,13 @@ procedure TMain.FormCreate(Sender: TObject);
DownloadPath:=Ini.ReadString('Main', 'Path', '');
if Trim(DownloadPath) = '' then
DownloadPath:=GetEnvironmentVariable('USERPROFILE') + '\Desktop\';
ProxyAddress:=Ini.ReadString('Proxy', 'Address', '');
ProxyPort:=Ini.ReadString('Proxy', 'Port', '');
Ini.Free;

if (ProxyAddress <> '') and (ProxyPort <> '') then
ProxyInit(ProxyAddress, ProxyPort);

Application.Title:=Caption;

if FileExists(ExtractFilePath(ParamStr(0)) + 'RSS.txt') then
Expand Down Expand Up @@ -441,15 +459,14 @@ procedure TMain.FormCreate(Sender: TObject);
ID_PODCASTS_NOT_FOUND:=Ini.ReadString('Main', 'ID_PODCASTS_NOT_FOUND', '');
ID_DOWNLOAD_ERROR:=Ini.ReadString('Main', 'ID_DOWNLOAD_ERROR', '');

ID_ABOUT_TITLE:=Ini.ReadString('Main', 'ID_ABOUT_TITLE', '');
ID_LAST_UPDATE:=Ini.ReadString('Main', 'ID_LAST_UPDATE', '');
ID_ABOUT_TITLE:=Ini.ReadString('About', 'ID_ABOUT_TITLE', '');
ID_LAST_UPDATE:=Ini.ReadString('About', 'ID_LAST_UPDATE', '');

ID_STAGE_1:=Ini.ReadString('Main', 'ID_STAGE_1', '');
ID_STAGE_2:=Ini.ReadString('Main', 'ID_STAGE_2', '');
ID_REMOVED_LINKS:=Ini.ReadString('Main', 'ID_REMOVED_LINKS', '');
ID_FAILED_GET_RSS:=StringReplace(Ini.ReadString('Main', 'ID_FAILED_GET_RSS', ''), '\n', #13#10, [rfReplaceAll]);

ID_UPLOADED_PODCASTS_TO_DEVICE:=Ini.ReadString('Main', 'ID_UPLOADED_PODCASTS_TO_DEVICE', '');
Ini.Free;
end;

Expand Down
94 changes: 70 additions & 24 deletions Source/Unit2.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object Settings: TSettings
BorderIcons = [biSystemMenu]
BorderStyle = bsSingle
Caption = #1053#1072#1089#1090#1088#1086#1081#1082#1080
ClientHeight = 244
ClientHeight = 250
ClientWidth = 376
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Expand All @@ -19,22 +19,29 @@ object Settings: TSettings
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object StatusLbl: TLabel
Left = 168
Top = 225
Width = 169
Height = 13
Alignment = taCenter
end
object OkBtn: TButton
Left = 8
Top = 211
Top = 219
Width = 75
Height = 25
Caption = #1054#1082
TabOrder = 3
TabOrder = 4
OnClick = OkBtnClick
end
object CancelBtn: TButton
Left = 88
Top = 211
Top = 219
Width = 75
Height = 25
Caption = #1054#1090#1084#1077#1085#1072
TabOrder = 4
TabOrder = 5
OnClick = CancelBtnClick
end
object OPMLGB: TGroupBox
Expand Down Expand Up @@ -72,14 +79,14 @@ object Settings: TSettings
TabOrder = 0
object DownloadsPathLbl: TLabel
Left = 8
Top = 24
Top = 19
Width = 153
Height = 13
Caption = #1055#1091#1090#1100' '#1076#1083#1103' '#1079#1072#1075#1088#1091#1079#1082#1080' '#1087#1086#1076#1082#1072#1089#1090#1086#1074':'
end
object EditPath: TEdit
Left = 7
Top = 40
Top = 36
Width = 170
Height = 21
ReadOnly = True
Expand All @@ -88,7 +95,7 @@ object Settings: TSettings
end
object ChooseBtn: TButton
Left = 182
Top = 39
Top = 34
Width = 75
Height = 23
Caption = #1042#1099#1073#1088#1072#1090#1100
Expand All @@ -109,26 +116,20 @@ object Settings: TSettings
object DownloadedPodcastsGB: TGroupBox
Left = 8
Top = 104
Width = 361
Height = 100
Width = 249
Height = 105
Caption = #1047#1072#1075#1088#1091#1078#1077#1085#1085#1099#1077' '#1087#1086#1076#1082#1072#1089#1090#1099' '
TabOrder = 1
object DownloadedPodcastsDescLbl: TLabel
Left = 8
Top = 24
Width = 342
Height = 13
Caption = #1056#1072#1079' '#1074' 3-4 '#1084#1077#1089#1103#1094#1072' '#1078#1077#1083#1072#1090#1077#1083#1100#1085#1086' '#1086#1095#1080#1097#1072#1090#1100' '#1073#1072#1079#1091' '#1089#1089#1099#1083#1086#1082', '#1095#1090#1086#1073#1099' '#1087#1086#1080#1089#1082'...'
end
object StatusLbl: TLabel
Left = 192
Top = 69
Width = 3
Height = 13
Top = 21
Width = 197
Height = 26
Caption = #1056#1072#1079' '#1074' 3-4 '#1084#1077#1089#1103#1094#1072' '#1078#1077#1083#1072#1090#1077#1083#1100#1085#1086' '#1086#1095#1080#1097#1072#1090#1100#13#10#1073#1072#1079#1091' '#1089#1089#1099#1083#1086#1082', '#1095#1090#1086#1073#1099' '#1087#1086#1080#1089#1082'...'
end
object RemLinksBtn: TButton
Left = 8
Top = 63
Top = 69
Width = 75
Height = 26
Caption = #1054#1095#1080#1089#1090#1080#1090#1100
Expand All @@ -137,7 +138,7 @@ object Settings: TSettings
end
object ProgressBar: TProgressBar
Left = 88
Top = 63
Top = 69
Width = 97
Height = 26
TabOrder = 1
Expand All @@ -146,13 +147,58 @@ object Settings: TSettings
end
object AboutBtn: TButton
Left = 344
Top = 211
Top = 219
Width = 25
Height = 25
Caption = '?'
TabOrder = 5
TabOrder = 6
OnClick = AboutBtnClick
end
object ProxyGB: TGroupBox
Left = 264
Top = 104
Width = 105
Height = 105
Caption = #1055#1088#1086#1082#1089#1080
TabOrder = 3
object AddressLbl: TLabel
Left = 8
Top = 19
Width = 34
Height = 13
Caption = #1040#1076#1088#1077#1089':'
end
object PortLbl: TLabel
Left = 8
Top = 62
Width = 28
Height = 13
Caption = #1055#1086#1088#1090':'
end
object AddressEdt: TEdit
Left = 8
Top = 35
Width = 89
Height = 21
TabOrder = 0
end
object PortEdt: TEdit
Left = 8
Top = 77
Width = 89
Height = 21
TabOrder = 1
end
object ProxyClrBtn: TButton
Left = 82
Top = 16
Width = 15
Height = 15
Caption = '-'
TabOrder = 2
OnClick = ProxyClrBtnClick
end
end
object OpenDialog: TOpenDialog
Filter = 'OPML '#1092#1072#1081#1083#1099'|*.opml'
Left = 144
Expand Down
Loading

0 comments on commit ccc1701

Please sign in to comment.