From 5407f5a618b5dc5476083052c08b91c90ddf347a Mon Sep 17 00:00:00 2001 From: riderkick Date: Mon, 13 Apr 2015 04:31:31 +0800 Subject: [PATCH] Enable update FMD and bunch of fix Test to update FMD with github release page. Added changelog form, needed translation. Bunch of fix to ensure thread safety. There is still memory leaks, or bad pointer. --- baseunits/uBaseUnit.pas | 163 +- baseunits/uData.pas | 2 +- baseunits/uDownloadsManager.pas | 5 +- baseunits/uGetMangaInfosThread.pas | 4 +- baseunits/uMisc.pas | 12 +- baseunits/uPacker.pas | 4 +- baseunits/uSubThread.pas | 185 +- baseunits/uUpdateDBThread.pas | 6 +- baseunits/uUpdateThread.pas | 7 +- bin/readme.rtf | 2 +- changelog.txt | 13 +- mangadownloader/forms/frmMain.lfm | 48 +- mangadownloader/forms/frmMain.pas | 39 +- mangadownloader/forms/frmupdatedialog.lfm | 133 ++ mangadownloader/forms/frmupdatedialog.pas | 48 + mangadownloader/md.lpi | 30 +- mangadownloader/md.lpr | 3 +- mangadownloader/md.lps | 1918 +++++++++++---------- mangadownloader/md.res | Bin 2932 -> 2932 bytes update | 4 +- updater/uMain.pas | 78 +- updater/updater.lps | 22 +- 22 files changed, 1508 insertions(+), 1218 deletions(-) create mode 100644 mangadownloader/forms/frmupdatedialog.lfm create mode 100644 mangadownloader/forms/frmupdatedialog.pas diff --git a/baseunits/uBaseUnit.pas b/baseunits/uBaseUnit.pas index f67ed2e45..9b36d746b 100644 --- a/baseunits/uBaseUnit.pas +++ b/baseunits/uBaseUnit.pas @@ -13,9 +13,8 @@ interface uses - SysUtils, Classes, Graphics, strutils, zstream, fgl, - HTTPSend, Synautil, blcksock, ssl_openssl, - uFMDThread, GZIPUtils; + SysUtils, Classes, Graphics, Forms, strutils, fileinfo, fgl, + uFMDThread, synautil, httpsend, blcksock, ssl_openssl, GZIPUtils; const FMD_REVISION = '$WCREV$'; @@ -238,7 +237,7 @@ interface TwoDigitYearCenturyWindow :50; ); - SOCKHEARTBEATRATE = 300; + SOCKHEARTBEATRATE = 500; ANIMEA_ID = 0; MANGAHERE_ID = 1; @@ -331,6 +330,8 @@ interface MANGASEE_ID = 88; var + FMD_VERSION_NUMBER: String = ''; + Genre: array [0..37] of String; // cbOptionLetFMDDoItemIndex @@ -617,7 +618,7 @@ interface MANGAHOST_BROWSER: String = '/mangas'; //------------------------------------------ - UPDATE_URL: String = 'http://jaist.dl.sourceforge.net/project/fmd/FMD/updates/'; + UPDATE_URL: String = 'https://github.com/riderkick/FMD/raw/master/'; OptionAutoCheckMinutes, OptionCustomRename, // dialog messages @@ -736,6 +737,9 @@ TDownloadPageThread = class(TThread) constructor Create(CreateSuspended: Boolean); end; +// Get current binary version +function GetCurrentBinVersion: String; +// Remove Unicode function UnicodeRemove(const S: String): String; // Check a directory to see if it's empty (return TRUE) or not function IsDirectoryEmpty(const ADir: String): Boolean; @@ -965,6 +969,43 @@ function NTSetPrivilege(sPrivilege: String; bEnabled: Boolean): Boolean; {$ENDIF} +function GetCurrentBinVersion: String; +var + AppVerInfo: TStringList; + i: Integer; +begin + Result := ''; + AppVerInfo := TStringList.Create; + with TFileVersionInfo.Create(nil) do + try + try + FileName := ParamStrUTF8(0); + if FileName = '' then + FileName := Application.ExeName; + {$IF FPC_FULLVERSION >= 20701} + ReadFileInfo; + {$ENDIF} + if VersionStrings.Count > 0 then + begin + {$IF FPC_FULLVERSION >= 20701} + AppVerInfo.Assign(VersionStrings); + {$ELSE} + for i := 0 to VersionStrings.Count - 1 do + AppVerInfo.Add(VersionCategories.Strings[i] + '=' + + VersionStrings.Strings[i]); + {$ENDIF} + for i := 0 to AppVerInfo.Count - 1 do + AppVerInfo.Strings[i] := LowerCase(AppVerInfo.Names[i]) + '=' + AppVerInfo.ValueFromIndex[i]; + Result := AppVerInfo.Values['fileversion']; + end; + except + end; + finally + Free; + AppVerInfo.Free; + end; +end; + function UnicodeRemove(const S: String): String; var i: Cardinal; @@ -2286,6 +2327,17 @@ function GetPage(const AOwner: TObject; const AHTTP: THTTPSend; HTTP.Free; end; + function checkTerminate: boolean; + begin + Result := False; + if HTTP.Sock.Tag = 1 then // terminated via OnHeartBeat + begin + Result := True; + HTTP.Sock.Tag := 0; + preTerminate; + end; + end; + label globReturn; @@ -2306,13 +2358,6 @@ function GetPage(const AOwner: TObject; const AHTTP: THTTPSend; globReturn: - //Site that require HTTPS request should define here - if Pos('https://', URL) <> 0 then - begin - HTTP.Sock.CreateWithSSL(TSSLOpenSSL); - HTTP.Sock.SSLDoConnect; - end; - if ProxyType = 'HTTP' then begin HTTP.ProxyHost := Host; @@ -2400,14 +2445,7 @@ function GetPage(const AOwner: TObject; const AHTTP: THTTPSend; (HTTP.ResultCode >= 500) or (HTTP.ResultCode = 451) do begin - if (AOwner <> nil) and (AOwner is TFMDThread) then - begin - if TFMDThread(AOwner).IsTerminated then - begin - preTerminate; - Exit; - end; - end; + if checkTerminate then Exit; if (Reconnect <> 0) and (Reconnect <= counter) then begin preTerminate; @@ -2427,15 +2465,7 @@ function GetPage(const AOwner: TObject; const AHTTP: THTTPSend; counter := 0; while (HTTP.ResultCode = 302) or (HTTP.ResultCode = 301) do begin - if (AOwner <> nil) and (AOwner is TFMDThread) then - begin - if TFMDThread(AOwner).IsTerminated then - begin - preTerminate; - Exit; - end; - end; - + if checkTerminate then Exit; s := GetHeaderValue(HTTP.Headers, 'location'); s := TrimLeftChar(s, ['/', ':']); if s <> '' then @@ -2454,14 +2484,7 @@ function GetPage(const AOwner: TObject; const AHTTP: THTTPSend; while (not HTTP.HTTPMethod('GET', URL)) or (HTTP.ResultCode > 500) do //500 for abort begin - if (AOwner <> nil) and (AOwner is TFMDThread) then - begin - if TFMDThread(AOwner).IsTerminated then - begin - preTerminate; - Exit; - end; - end; + if checkTerminate then Exit; if (Reconnect <> 0) and (Reconnect <= counter) then begin preTerminate; @@ -2595,6 +2618,17 @@ function SaveImage(const AOwner: TObject; const AHTTP: THTTPSend; HTTPHeader.Free; end; + function checkTerminate: boolean; + begin + Result := False; + if HTTP.Sock.Tag = 1 then // terminated via OnHeartBeat + begin + Result := True; + HTTP.Sock.Tag := 0; + preTerminate; + end; + end; + begin s := Path + '/' + Name; // Check to see if a file with similar name was already exist. If so then we @@ -2622,12 +2656,6 @@ function SaveImage(const AOwner: TObject; const AHTTP: THTTPSend; HTTP.Headers.Add('DNT: 1'); URL := FixURL(URL); - // Site that require HTTPS request should define here - if Pos('https://', URL) <> 0 then - begin - HTTP.Sock.CreateWithSSL(TSSLOpenSSL); - HTTP.Sock.SSLDoConnect; - end; if ProxyType = 'HTTP' then begin @@ -2678,14 +2706,7 @@ function SaveImage(const AOwner: TObject; const AHTTP: THTTPSend; end; {$IFDEF DOWNLOADER} - if (AOwner <> nil) and (AOwner is TFMDThread) then - begin - if TFMDThread(AOwner).IsTerminated then - begin - preTerminate; - Exit; - end; - end; + if checkTerminate then Exit; {$ENDIF} counter := 0; while (not HTTP.HTTPMethod('GET', URL)) or @@ -2693,14 +2714,7 @@ function SaveImage(const AOwner: TObject; const AHTTP: THTTPSend; (HTTP.ResultCode = 403) do begin {$IFDEF DOWNLOADER} - if (AOwner <> nil) and (AOwner is TFMDThread) then - begin - if TFMDThread(AOwner).IsTerminated then - begin - preTerminate; - Exit; - end; - end; + if checkTerminate then Exit; {$ENDIF} if (Reconnect <> 0) and (Reconnect <= counter) then begin @@ -2717,14 +2731,7 @@ function SaveImage(const AOwner: TObject; const AHTTP: THTTPSend; while (HTTP.ResultCode = 302) or (HTTP.ResultCode = 301) do begin {$IFDEF DOWNLOADER} - if (AOwner <> nil) and (AOwner is TFMDThread) then - begin - if TFMDThread(AOwner).IsTerminated then - begin - preTerminate; - Exit; - end; - end; + if checkTerminate then Exit; {$ENDIF} s := GetHeaderValue(HTTP.Headers, 'location'); @@ -2750,14 +2757,7 @@ function SaveImage(const AOwner: TObject; const AHTTP: THTTPSend; (HTTP.ResultCode = 403) do begin {$IFDEF DOWNLOADER} - if (AOwner <> nil) and (AOwner is TFMDThread) then - begin - if TFMDThread(AOwner).IsTerminated then - begin - preTerminate; - Exit; - end; - end; + if checkTerminate then Exit; {$ENDIF} if (Reconnect <> 0) and (Reconnect <= counter) then begin @@ -2796,14 +2796,7 @@ function SaveImage(const AOwner: TObject; const AHTTP: THTTPSend; repeat try {$IFDEF DOWNLOADER} - if (AOwner <> nil) and (AOwner is TFMDThread) then - begin - if TFMDThread(AOwner).IsTerminated then - begin - preTerminate; - Exit; - end; - end; + if checkTerminate then Exit; {$ENDIF} lpath := CorrectPathSys(Path); if not DirectoryExistsUTF8(lpath) then @@ -2828,7 +2821,7 @@ function SaveImage(const AOwner: TObject; const AHTTP: THTTPSend; except on E: Exception do begin - putLog('SaveImage: ' + E.Message + LineEnding + (CorrectPathSys(Path) + + WriteLog('SaveImage: ' + E.Message + LineEnding + (CorrectPathSys(Path) + '/' + Name + prefix + ext), LOG_error); {$IFDEF DOWNLOADER} if (AOwner <> nil) and (AOwner is TFMDThread) then @@ -2853,7 +2846,7 @@ function SaveImage(const AOwner: TObject; const AHTTP: THTTPSend; end else begin - putLog('SaveImage.ExtEmpty URL:' + URL); + WriteLog('SaveImage.ExtEmpty URL:' + URL); end; preTerminate; end; diff --git a/baseunits/uData.pas b/baseunits/uData.pas index ea81c0cbc..79b61c7e1 100644 --- a/baseunits/uData.pas +++ b/baseunits/uData.pas @@ -14,7 +14,7 @@ interface uses - Classes, SysUtils, uBaseUnit, HTTPSend; + Classes, SysUtils, uBaseUnit, httpsend; type TDataProcess = class(TObject) diff --git a/baseunits/uDownloadsManager.pas b/baseunits/uDownloadsManager.pas index 5ff108a6b..536429ca9 100644 --- a/baseunits/uDownloadsManager.pas +++ b/baseunits/uDownloadsManager.pas @@ -12,7 +12,7 @@ interface uses Classes, SysUtils, Dialogs, ExtCtrls, IniFiles, fgl, typinfo, syncobjs, - HTTPSend, blcksock, + httpsend, blcksock, uBaseUnit, uPacker, uFMDThread, uMisc, frmShutdownCounter; @@ -264,8 +264,9 @@ destructor TDownloadThread.Destroy; procedure TDownloadThread.SockOnHeartBeat(Sender: TObject); begin - if Self.Terminated and (TBlockSocket(Sender).StopFlag = False) then + if Terminated then begin + TBlockSocket(Sender).Tag := 1; TBlockSocket(Sender).StopFlag := True; TBlockSocket(Sender).AbortSocket; end; diff --git a/baseunits/uGetMangaInfosThread.pas b/baseunits/uGetMangaInfosThread.pas index 6385ee178..e439aa627 100644 --- a/baseunits/uGetMangaInfosThread.pas +++ b/baseunits/uGetMangaInfosThread.pas @@ -163,8 +163,9 @@ procedure TGetMangaInfosThread.DoGetInfos; procedure TGetMangaInfosThread.SockOnHeartBeat(Sender: TObject); begin - if Self.Terminated and (TBlockSocket(Sender).StopFlag = False) then + if Terminated then begin + TBlockSocket(Sender).Tag := 1; TBlockSocket(Sender).StopFlag := True; TBlockSocket(Sender).AbortSocket; end; @@ -256,6 +257,7 @@ constructor TGetMangaInfosThread.Create; inherited Create(True); FIsFlushed := False; FInfo := TMangaInformation.Create; + FInfo.FOwner := Self; FInfo.FHTTP.Sock.OnHeartbeat := SockOnHeartBeat; FInfo.FHTTP.Sock.HeartbeatRate := SOCKHEARTBEATRATE; FCover := MainForm.mangaCover; diff --git a/baseunits/uMisc.pas b/baseunits/uMisc.pas index 306a0974c..dd3373bb0 100644 --- a/baseunits/uMisc.pas +++ b/baseunits/uMisc.pas @@ -43,8 +43,8 @@ procedure QuickSortNaturalPart(var Alist: TStringList; Separator: String; function MangaFoxRemoveWatermarks(const Filename: String): Boolean; //Logging -procedure putLog(msg: String; logType: TLogType = LOG_debug); -procedure putOtherLog(msg: String); +procedure WriteLog(msg: String; logType: TLogType = LOG_debug); +procedure WriteOtherLog(msg: String); //Searching function FindStrLinear(aList: TStrings; aValue: String): Boolean; @@ -119,7 +119,7 @@ procedure TIniFileR.Reload; { uMisc } -procedure putLog(msg: String; logType: TLogType = LOG_debug); +procedure WriteLog(msg: String; logType: TLogType = LOG_debug); {$IFDEF LOGACTIVE} var s: String; @@ -143,7 +143,7 @@ procedure putLog(msg: String; logType: TLogType = LOG_debug); {$ENDIF} end; -procedure putOtherLog(msg: String); +procedure WriteOtherLog(msg: String); {$IFDEF LOGACTIVE} var s: String; @@ -654,11 +654,11 @@ initialization {$IFDEF LOGACTIVE} fLog := TFileStream.Create(fLogFile, fmCreate or fmShareDenyNone); fOtherLog := TFileStream.Create(fOtherLogFile, fmCreate or fmShareDenyNone); - putLog('Starting FMD', LOG_Info); + WriteLog('Starting FMD', LOG_Info); {$ENDIF} finalization - putLog('FMD exit normally', LOG_Info); + WriteLog('FMD exit normally', LOG_Info); {$IFDEF LOGACTIVE} FreeAndNil(fLog); FreeAndNil(fOtherLog); diff --git a/baseunits/uPacker.pas b/baseunits/uPacker.pas index bfc656d83..6e9587e10 100644 --- a/baseunits/uPacker.pas +++ b/baseunits/uPacker.pas @@ -94,7 +94,7 @@ procedure TPacker.DoZipCbz; except on E: Exception do begin - putLog('DoZipCbz.E:' + E.ClassName + '=' + E.Message, LOG_error); + WriteLog('DoZipCbz.E:' + E.ClassName + '=' + E.Message, LOG_error); //MainForm.ExceptLogMain.ExceptionHandler(Self, E); end; end; @@ -149,7 +149,7 @@ procedure TPacker.DoPdf; except on E: Exception do begin - putLog('DoPdf.E:' + E.ClassName + '=' + E.Message, LOG_error); + WriteLog('DoPdf.E:' + E.ClassName + '=' + E.Message, LOG_error); //MainForm.ExceptLogMain.ExceptionHandler(nil, E); end; end; diff --git a/baseunits/uSubThread.pas b/baseunits/uSubThread.pas index 4814893f5..14ba53a9f 100644 --- a/baseunits/uSubThread.pas +++ b/baseunits/uSubThread.pas @@ -6,13 +6,16 @@ unit uSubThread; -{$mode delphi} +{$ifdef fpc} + {$mode objfpc} +{$endif} +{$H+} interface uses - Classes, SysUtils, Dialogs, Controls, lclintf, - uBaseUnit, uFMDThread; + Classes, SysUtils, Controls, Forms, uBaseUnit, uFMDThread, + httpsend, blcksock; type { Tasks will be done by this thread: @@ -26,38 +29,28 @@ interface TSubThread = class(TFMDThread) protected FIsLoaded: Integer; - FURL: String; - + FBtnCheckCaption: String; procedure Execute; override; - - procedure MainThreadShowLog; procedure MainThreadUpdate; - procedure MainThreadUpdateRequire; - procedure MainThreadImportant; - procedure MainThreadLatestVer; procedure MainThreadSetButton; procedure MainThreadPopSilentThreadQueue; procedure DoTerminate; override; + procedure SockOnHeartBeat(Sender: TObject); public updateCounter: Cardinal; isCheckForLatestVer: Boolean; isCanStop: Boolean; fNote, fNoteForThisRevision, fImportant: String; + fNewVersionNumber, fUpdateURL, fChangelog: String; constructor Create; end; implementation uses - FileUtil, - frmMain, frmLog, + frmMain, frmUpdateDialog, uSilentThread; -var - LRequireRevision: Cardinal = 1; - LRevision: Cardinal; - LVersion: String; - // ----- Public methods ----- constructor TSubThread.Create; @@ -71,54 +64,34 @@ constructor TSubThread.Create; // ----- Protected methods ----- -procedure TSubThread.MainThreadShowLog; -begin - Log := TLog.Create(MainForm); - Log.ShowModal; - Log.Free; -end; - procedure TSubThread.MainThreadUpdate; begin - if MessageDlg('', Format(stDlgNewVersion + #10#13#10#13 + fNote, - [LVersion, LRevision]), - mtInformation, [mbYes, mbNo], 0) = mrYes then + UpdateDialogForm.Caption := Application.Title + ' - New version found!'; + with UpdateDialogForm.mmLog.Lines do begin - CopyFile(fmdDirectory + 'updater.exe', fmdDirectory + 'old_updater.exe'); - CopyFile(fmdDirectory + CONFIG_FOLDER + CONFIG_FILE, - fmdDirectory + CONFIG_FOLDER + CONFIG_FILE + '.tmp'); - MainForm.CloseNow; - fmdRunAsAdmin(fmdDirectory + 'old_updater.exe', '1', False); - Halt; + BeginUpdate; + try + Clear; + Add('Current Version : ' + FMD_VERSION_NUMBER); + Add('New Version : ' + fNewVersionNumber + LineEnding); + AddText(fChangelog); + finally + EndUpdate; + end; + end; + if UpdateDialogForm.ShowModal = mrYes then + begin + MainForm.DoUpdateFMD := True; + MainForm.FUpdateURL := fUpdateURL; + MainForm.itMonitor.Enabled := True; end else MainForm.btCheckVersion.Caption := stUpdaterCheck; end; -procedure TSubThread.MainThreadUpdateRequire; -begin - if MessageDlg('', Format(stDlgUpdaterVersionRequire, [LRequireRevision]), - mtInformation, [mbYes, mbNo], 0) = mrYes then - begin - OpenURL('http://akarink.wordpress.com/'); - end; -end; - -procedure TSubThread.MainThreadImportant; -begin - MessageDlg('', fImportant, mtInformation, [mbYes], 0); - // MainForm.CloseNow; - // Halt; -end; - -procedure TSubThread.MainThreadLatestVer; -begin - MessageDlg('', stDlgLatestVersion, mtInformation, [mbYes], 0); -end; - procedure TSubThread.MainThreadSetButton; begin - MainForm.btCheckVersion.Caption := stUpdaterCheck; + MainForm.btCheckVersion.Caption := FBtnCheckCaption; end; procedure TSubThread.MainThreadPopSilentThreadQueue; @@ -141,17 +114,24 @@ procedure TSubThread.DoTerminate; inherited DoTerminate; end; +procedure TSubThread.SockOnHeartBeat(Sender: TObject); +begin + if Terminated then + begin + TBlockSocket(Sender).Tag := 1; + TBlockSocket(Sender).StopFlag := True; + TBlockSocket(Sender).AbortSocket; + end; +end; + procedure TSubThread.Execute; var l: TStringList; - i: Cardinal; - s: String; + FHTTP: THTTPSend; + updateFound: Boolean = False; begin MainForm.isSubthread := True; - LRevision := 0; try - if FileExists(WORK_FOLDER + LOG_FILE) then - Synchronize(MainThreadShowLog); if FileExists(fmdDirectory + 'old_updater.exe') then DeleteFile(fmdDirectory + 'old_updater.exe'); @@ -167,73 +147,52 @@ procedure TSubThread.Execute; if (MainForm.silentThreadCount > 0) and (MainForm.currentActiveSilentThreadCount < maxActiveSilentThread) then begin - Synchronize(MainThreadPopSilentThreadQueue); + Synchronize(@MainThreadPopSilentThreadQueue); end; - isCheckForLatestVer := False; - { TODO -oCholif : Temporary disable latest version check } - if isCheckForLatestVer then begin - Sleep(2000); + FBtnCheckCaption := stFavoritesChecking; + Synchronize(@MainThreadSetButton); l := TStringList.Create; - - l.NameValueSeparator := '='; - case Random(2) of - 0: - s := UPDATE_URL + 'updates.i'; - 1: - s := SourceForgeURL( - 'http://sourceforge.net/projects/fmd/files/FMD/updates/updates.i/download'); - end; - if (GetPage(TObject(l), s, 0)) and (l.Count > 0) then - begin - fNote := ''; - fNoteForThisRevision := ''; - for i := 0 to l.Count - 1 do - begin - if l.Names[i] = IntToStr(Revision) then - fNoteForThisRevision := l.ValueFromIndex[i]; - if l.Names[i] = 'Note' then - fNote := l.ValueFromIndex[i]; - if l.Names[i] = 'Revision' then - LRevision := StrToInt(l.ValueFromIndex[i]); - if l.Names[i] = 'RequireRevision' then - LRequireRevision := StrToInt(l.ValueFromIndex[i]); - if l.Names[i] = 'Version' then - LVersion := l.ValueFromIndex[i]; - if l.Names[i] = 'Important' then - begin - fImportant := l.ValueFromIndex[i]; - Synchronize(MainThreadImportant); - end; - end; - - if LRequireRevision > Revision then - Synchronize(MainThreadUpdateRequire) - else - if LRevision > Revision then - begin - Synchronize(MainThreadUpdate); - end - else - begin - if updateCounter > 0 then + FHTTP := THTTPSend.Create; + FHTTP.Sock.OnHeartbeat := @SockOnHeartBeat; + FHTTP.Sock.HeartbeatRate := SOCKHEARTBEATRATE; + try + if not Terminated and + GetPage(Self, FHTTP, TObject(l), UPDATE_URL + 'update', 3, False) then + if l.Count > 1 then begin - Synchronize(MainThreadLatestVer); - end; - Synchronize(MainThreadSetButton); + l[0] := Trim(l[0]); + l[1] := Trim(l[1]); + if l[0] <> FMD_VERSION_NUMBER then + begin + fNewVersionNumber := l[0]; + fUpdateURL := l[1]; + FHTTP.Clear; + l.Clear; + if not Terminated and + GetPage(Self, FHTTP, TObject(l), UPDATE_URL + 'changelog.txt', 3, False) then + fChangelog := l.Text; + updateFound := True; + end; + FBtnCheckCaption := stUpdaterCheck; + Synchronize(@MainThreadSetButton); end; + finally + FHTTP.Free; + l.Free; end; - Inc(updateCounter); + if not Terminated and updateFound then + Synchronize(@MainThreadUpdate); + Inc(updateCounter); isCheckForLatestVer := False; - l.Free; end; isCanStop := False; isCanStop := True; - Sleep(400); + Sleep(700); end; except on E: Exception do diff --git a/baseunits/uUpdateDBThread.pas b/baseunits/uUpdateDBThread.pas index b6dd331bc..5414e1deb 100644 --- a/baseunits/uUpdateDBThread.pas +++ b/baseunits/uUpdateDBThread.pas @@ -99,16 +99,14 @@ procedure TUpdateDBThread.Execute; begin try Synchronize(MainThreadShowGetting); - fmdRunAsAdmin('updater.exe', 'data ' + GetMangaDatabaseURL(websiteName) + - ' 5', True); - // if SavePage(GetMangaDatabaseURL(websiteName), fmdDirectory + DATA_FOLDER, websiteName + '.zip', 10) then + fmdRunAsAdmin(fmdDirectory + 'updater.exe', '-d ' + GetMangaDatabaseURL(websiteName) + + ' -x -r 5', True); if FileExists(fmdDirectory + DATA_FOLDER + websiteName + '.dat') then begin Synchronize(MainThreadRefreshList); end else begin - Synchronize(MainThreadCannotConnectToServer); Synchronize(MainThreadShowEndGetting); end; except diff --git a/baseunits/uUpdateThread.pas b/baseunits/uUpdateThread.pas index 833d06684..e2f8ffa2e 100644 --- a/baseunits/uUpdateThread.pas +++ b/baseunits/uUpdateThread.pas @@ -105,8 +105,9 @@ destructor TUpdateMangaThread.Destroy; procedure TUpdateMangaThread.SockOnHeartBeat(Sender: TObject); begin - if Self.Terminated and (TBlockSocket(Sender).StopFlag = False) then + if Terminated then begin + TBlockSocket(Sender).Tag := 1; TBlockSocket(Sender).StopFlag := True; TBlockSocket(Sender).AbortSocket; end; @@ -557,8 +558,8 @@ procedure TUpdateMangaManagerThread.Execute; Inc(websitePtr); FStatus := 'Getting list for ' + website + ' ...'; Synchronize(MainThreadShowGetting); - fmdRunAsAdmin('updater.exe', 'data ' + GetMangaDatabaseURL(website) + - ' 5', True); + fmdRunAsAdmin(fmdDirectory + 'updater.exe', '-d ' + GetMangaDatabaseURL(website) + + ' -x -r 5 -q', True); Synchronize(RefreshList); end; end diff --git a/bin/readme.rtf b/bin/readme.rtf index 2a3f3bb5f..79d884d00 100644 --- a/bin/readme.rtf +++ b/bin/readme.rtf @@ -3,7 +3,7 @@ {\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\nowidctlpar\sa200\sl276\slmult1\tx1260\lang9\b\f0\fs22 Project\tab :\b0 \tab Free Manga Downloader\par \b Project Page\tab : \b0 \tab{\field{\*\fldinst{HYPERLINK "http://sourceforge.net/projects/fmd/"}}{\fldrslt{\ul\cf1 http://sourceforge.net/projects/fmd/}}}\f0\fs22\par \tab\tab{\field{\*\fldinst{HYPERLINK "https://github.com/riderkick/FMD/"}}{\fldrslt{\ul\cf1 https://github.com/riderkick/FMD/}}}\f0\fs22\par -\b Version\tab : \b0 0.9.7.1\par +\b Version\tab : \b0 0.9.8.0\par \pard\tx1260\b License\tab : \b0 GPLv2 {\field{\*\fldinst{HYPERLINK "http://www.gnu.org/licenses/gpl-2.0.html"}}{\fldrslt{\ul\cf1 http://www.gnu.org/licenses/gpl-2.0.html}}}\f0\fs22\par \pard\par \b Current developer(s):\par diff --git a/changelog.txt b/changelog.txt index 394b57824..a91857537 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,9 +1,18 @@ -Unofficial build of Free Manga Downloader -https://www.mediafire.com/folder/3ccy2c7g36hp3/Fmd +Free Manga Downloader +Project page: https://github.com/riderkick/FMD +For list data check: https://www.mediafire.com/folder/3ccy2c7g36hp3/Fmd Changelog: (! = Important, + = Addition, - = Removal, * = Bug fix/Change/Edit, ? = Require feedback) +0.9.8.0 (12-04-2015) +[+?] Updater: add support for update FMD (experimental) +[*?] Enable FMD update (test using github release page) +[*] Various changes +[!] From now on only 32-bit version will be released, + there is no much benefit of using 64-bit version and to save my bandwith, + I will reconsider to provide it later + 0.9.7.1 (04-04-2015) [*] MyReadingMangaInfo: Add multi pages/chapter support, fix mangainfo diff --git a/mangadownloader/forms/frmMain.lfm b/mangadownloader/forms/frmMain.lfm index 2d7504af8..d74ea0a1d 100644 --- a/mangadownloader/forms/frmMain.lfm +++ b/mangadownloader/forms/frmMain.lfm @@ -142,8 +142,8 @@ object MainForm: TMainForm Height = 456 Top = 0 Width = 606 - HorzScrollBar.Page = 294 - VertScrollBar.Page = 295 + HorzScrollBar.Page = 311 + VertScrollBar.Page = 317 Align = alClient BorderStyle = bsNone ClientHeight = 456 @@ -172,6 +172,7 @@ object MainForm: TMainForm ReadOnly = True ScrollBars = ssVertical TabOrder = 0 + ZoomFactor = 1 end object edURL: TEdit Left = 4 @@ -596,8 +597,8 @@ object MainForm: TMainForm Height = 456 Top = 0 Width = 606 - HorzScrollBar.Page = 509 - VertScrollBar.Page = 423 + HorzScrollBar.Page = 526 + VertScrollBar.Page = 440 Align = alClient BorderStyle = bsNone ClientHeight = 456 @@ -1680,8 +1681,8 @@ object MainForm: TMainForm Height = 351 Top = 0 Width = 579 - HorzScrollBar.Page = 445 - VertScrollBar.Page = 130 + HorzScrollBar.Page = 462 + VertScrollBar.Page = 147 Align = alClient BorderStyle = bsNone ClientHeight = 351 @@ -2434,6 +2435,7 @@ object MainForm: TMainForm ReadOnly = True ScrollBars = ssVertical TabOrder = 0 + ZoomFactor = 1 end object btCheckVersion: TBitBtn Left = 25 @@ -2606,7 +2608,7 @@ object MainForm: TMainForm end object edSearch: TEdit Left = 3 - Height = 27 + Height = 23 Top = 36 Width = 157 Anchors = [akTop, akLeft, akRight] @@ -3581,12 +3583,6 @@ object MainForm: TMainForm OnClick = miHighlightNewMangaClick end end - object tmBackup: TTimer - Interval = 60000 - OnTimer = tmBackupTimer - left = 616 - top = 200 - end object TrayIcon: TTrayIcon BalloonFlags = bfInfo BalloonTimeout = 5000 @@ -3631,14 +3627,14 @@ object MainForm: TMainForm Enabled = False Interval = 600000 OnTimer = itCheckForChaptersTimer - left = 672 - top = 256 + left = 728 + top = 264 end object itRefreshForm: TIdleTimer Interval = 300 OnTimer = itRefreshFormTimer - left = 616 - top = 256 + left = 672 + top = 264 end object IconList: TImageList left = 24 @@ -4165,12 +4161,6 @@ object MainForm: TMainForm left = 728 top = 200 end - object itSaveJobList: TIdleTimer - Interval = 60000 - OnTimer = itSaveJobListTimer - left = 672 - top = 200 - end object IconDL: TImageList left = 24 top = 184 @@ -5384,4 +5374,16 @@ object MainForm: TMainForm left = 239 top = 276 end + object tmBackup: TIdleTimer + Interval = 60000 + OnTimer = tmBackupTimer + left = 672 + top = 200 + end + object itMonitor: TIdleTimer + Enabled = False + OnTimer = itMonitorTimer + left = 728 + top = 328 + end end diff --git a/mangadownloader/forms/frmMain.pas b/mangadownloader/forms/frmMain.pas index 98ebfc92c..a502e3435 100644 --- a/mangadownloader/forms/frmMain.pas +++ b/mangadownloader/forms/frmMain.pas @@ -61,8 +61,8 @@ TMainForm = class(TForm) IconList2: TImageList; IconMed: TImageList; IconSmall: TImageList; + itMonitor: TIdleTimer; itStartup: TIdleTimer; - itSaveJobList: TIdleTimer; lbOptionProxyType: TLabel; lbOptionRenameDigits: TLabel; lbFilterHint: TLabel; @@ -269,6 +269,7 @@ TMainForm = class(TForm) spMainSplitter: TSplitter; sbMain: TStatusBar; sbUpdateList: TStatusBar; + tmBackup: TIdleTimer; tvDownloadFilter: TTreeView; tsDownloadFilter: TTabSheet; tsMangaList: TTabSheet; @@ -277,7 +278,6 @@ TMainForm = class(TForm) tsAbout: TTabSheet; tsWebsites: TTabSheet; tsDialogs: TTabSheet; - tmBackup: TTimer; TrayIcon: TTrayIcon; tsGeneral: TTabSheet; tsFavorites: TTabSheet; @@ -346,6 +346,7 @@ TMainForm = class(TForm) procedure FormWindowStateChange(Sender: TObject); procedure itAnimateTimer(Sender: TObject); procedure itCheckForChaptersTimer(Sender: TObject); + procedure itMonitorTimer(Sender: TObject); procedure itRefreshFormTimer(Sender: TObject); procedure itSaveDownloadedListTimer(Sender: TObject); procedure itSaveJobListTimer(Sender: TObject); @@ -525,6 +526,10 @@ TMainForm = class(TForm) GetInfosThread: TGetMangaInfosThread; isGetMangaInfos: Boolean; + // update fmd through main thread + DoUpdateFMD: Boolean; + FUpdateURL: String; + //Instance FMDInstance: TSimpleIPCServer; @@ -626,9 +631,11 @@ procedure TMainForm.FormCreate(Sender: TObject); isExiting := False; isSubthread := False; isGetMangaInfos := False; + DoUpdateFMD := False; fmdDirectory := CorrectFilePath(GetCurrentDirUTF8); Application.HintHidePause := 10000; sbUpdateList.DoubleBuffered := True; + FMD_VERSION_NUMBER := GetCurrentBinVersion; // TrayIcon TrayIcon.Icon.Assign(Application.Icon); @@ -771,11 +778,11 @@ procedure TMainForm.CloseNow; begin tmBackup.Enabled := False; itSaveDownloadedList.Enabled := False; - itSaveJobList.Enabled := False; itRefreshForm.Enabled := False; itCheckForChapters.Enabled := False; itAnimate.Enabled := False; itStartup.Enabled := False; + itMonitor.Enabled := False; //Terminating all threads and wait for it DLManager.StopAllDownloadTasksForExit; @@ -881,6 +888,22 @@ procedure TMainForm.itCheckForChaptersTimer(Sender: TObject); favorites.Run; end; +procedure TMainForm.itMonitorTimer(Sender: TObject); +begin + if DoUpdateFMD then + begin + if FileExistsUTF8(fmdDirectory + 'updater.exe') then + CopyFile(fmdDirectory + 'updater.exe', fmdDirectory + 'old_updater.exe'); + if FileExistsUTF8(fmdDirectory + 'old_updater.exe') then + begin + CloseNow; + fmdRunAsAdmin(fmdDirectory + 'old_updater.exe', + '-a ' + FUpdateURL + ' -x -r 5', False); + Application.Terminate; + end; + end; +end; + procedure TMainForm.itRefreshFormTimer(Sender: TObject); begin if isCanRefreshForm then @@ -897,7 +920,7 @@ procedure TMainForm.itSaveDownloadedListTimer(Sender: TObject); procedure TMainForm.itSaveJobListTimer(Sender: TObject); begin - DLManager.SaveJobList; + end; procedure TMainForm.itStartupTimer(Sender: TObject); @@ -1602,8 +1625,6 @@ procedure TMainForm.btSearchClearClick(Sender: TObject); procedure TMainForm.btCheckVersionClick(Sender: TObject); begin - { TODO 1 -oCholif -cG : Check update is temporary disabled } - Exit; if subthread.isCheckForLatestVer then MessageDlg('', stDlgUpdaterIsRunning, mtInformation, [mbYes], 0) else @@ -4948,9 +4969,9 @@ procedure TMainForm.ExceptionHandler(Sender: TObject; E: Exception); procedure TMainForm.tmBackupTimer(Sender: TObject); begin - if DLManager.isRunningBackup then - Exit; - DLManager.Backup; + DLManager.SaveJobList; + if not DLManager.isRunningBackup then + DLManager.Backup; end; procedure TMainForm.vtOptionMangaSiteSelectionChange(Sender : TBaseVirtualTree; diff --git a/mangadownloader/forms/frmupdatedialog.lfm b/mangadownloader/forms/frmupdatedialog.lfm new file mode 100644 index 000000000..3eb2a27e0 --- /dev/null +++ b/mangadownloader/forms/frmupdatedialog.lfm @@ -0,0 +1,133 @@ +object UpdateDialogForm: TUpdateDialogForm + Left = 420 + Height = 420 + Top = 191 + Width = 488 + BorderIcons = [biSystemMenu] + Caption = 'New Version Found' + ClientHeight = 420 + ClientWidth = 488 + FormStyle = fsStayOnTop + Position = poOwnerFormCenter + LCLVersion = '1.5' + object mmLog: TMemo + Left = 8 + Height = 328 + Top = 48 + Width = 470 + Anchors = [akTop, akLeft, akRight, akBottom] + Font.CharSet = ANSI_CHARSET + Font.Height = -13 + Font.Name = 'Courier New' + Font.Pitch = fpFixed + Font.Quality = fqDraft + Lines.Strings = ( + 'Changelog:' + ) + ParentFont = False + ReadOnly = True + ScrollBars = ssAutoBoth + TabOrder = 0 + WordWrap = False + end + object btnUpdate: TBitBtn + Left = 96 + Height = 30 + Top = 384 + Width = 75 + Anchors = [akLeft, akBottom] + Caption = 'Update' + Glyph.Data = { + 36040000424D3604000000000000360000002800000010000000100000000100 + 2000000000000004000064000000640000000000000000000000FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000 + 00010000000800000010000000170000001A0000001900000017000000150000 + 00110000000D0000000A000000060000000300000001FFFFFF00FFFFFF000000 + 00020000000F0000001F0000002D02330066025F00CC012B0055000000290000 + 00220000001A000000130000000C0000000600000001FFFFFF00FFFFFF000000 + 0000000000000320000006570048077200CC16A60AE8087601C406570029021E + 00000000000000000000000000000000000000000000FFFFFF00FFFFFF000747 + 00000A6500000B8300480B8200CC2AC01BF424CD13FF1DB60EEF0C8301BB0C85 + 001B0745000000000000000000000000000000000000FFFFFF00FFFFFF000E8D + 00000D8800480D8700CC43CA33F629C318FF39CC28FF28C217FF1EAA0FEA0D87 + 00AE0D8A00100F8F0000084A00000000000000000000FFFFFF00FFFFFF000E8E + 00480E8D00CC5FD94FF933BC22FF50D040F80E8D00CC2AB21AF32CB81BFF1EA2 + 0FE40E8D009E0F8F00081094000010950000084B0000FFFFFF00FFFFFF000F92 + 00CC6DE55CFA59D048FF69E158FC0F9200CC0F92006D139504CB34B423F832B2 + 21FF1F9F0FDF0F92008C109400021095000010950000FFFFFF00FFFFFF001196 + 0048119700CC73EA62FD119700CC119600480F9300001196004C189D08D33DB6 + 2CFB37AF26FE1FA00EDA1197007B11980000129B0000FFFFFF00FFFFFF001197 + 0000129B0048129B00CC129B0048119700000F93000011970000129B006924AA + 13D857CF46FE55CD44FD21A710D6129C006313A00000FFFFFF00FFFFFF001197 + 0000129B0000129C0000129B00001197000011990000129F0000129F000113A0 + 008533B820DE61D850FF5CD54BFA1EA80CD213A1004CFFFFFF00FFFFFF001197 + 0000129B0000129C0000129B00001197000011990000129F0000129F000013A2 + 000614A3009E43C631E56BE25AFF70E95FFB14A300CCFFFFFF00FFFFFF001197 + 0000129B0000129C0000129B00001197000011990000129F0000129F000013A2 + 000014A5001014A700B077EE66FF14A700CC14A70048FFFFFF00FFFFFF001197 + 0000129B0000129C0000129B00001197000013A2000014A5000014A5000014A6 + 000015A8000015A9001F15AA00CC15AA004814A70000FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00 + } + OnClick = btnUpdateClick + TabOrder = 1 + end + object btnLater: TBitBtn + Left = 8 + Height = 30 + Top = 384 + Width = 75 + Anchors = [akLeft, akBottom] + Caption = 'Later' + Glyph.Data = { + 36040000424D3604000000000000360000002800000010000000100000000100 + 2000000000000004000064000000640000000000000000000000000000090000 + 00160000001A0000001A0000001A0000001A0000001A0000001A0000001A0000 + 001A0000001A0000001A0000001A0000001A0000001600000009000000120000 + 0E3300004A8300005DBC00005DCC00005DCC00005DCC00005DCC00005DCC0000 + 5DCC00005DCC00005DCC00005DBC00004A8300000E330000001200001D000000 + 6D73080893DD1010CCF91111D9FF1111D9FF1111D9FF1111D9FF1111D9FF1111 + D9FF1111D9FF1111D9FF0F0FCCF9070792DD00006D7300001D0000007D000000 + 7DBA1616CBF91111D1FF1111D1FF1111B6FF1111D1FF1111D1FF1111D1FF1111 + D1FF1111B6FF1111D1FF1111D1FF0F0FC8F900007DBA00007D00000084000000 + 84CC1C1CCEFF1111C8FF1111B2FFDCDCDCFF1111B2FF1111C8FF1111C8FF1111 + B2FFEEEEEEFF1111B2FF1111C8FF1111C8FF000084CC00008400000089000000 + 89CC2222C8FF1111BEFFD1D1D1FFD6D6D6FFDCDCDCFF1111ADFF1111ADFFEAEA + EAFFEEEEEEFFEEEEEEFF1111BEFF1212BEFF000089CC0000890000008D000000 + 8DCC3434C7FF1212B4FF1111B4FFD1D1D1FFD6D6D6FFDCDCDCFFE2E2E2FFE6E6 + E6FFEAEAEAFF1111B4FF1111B4FF1414B6FF00008DCC00008D00000092000000 + 92CC4646CEFF2626B5FF1414ABFF1111AAFFD1D1D1FFD6D6D6FFDCDCDCFFE2E2 + E2FF1111AAFF1111AAFF1111AAFF1818B0FF000092CC00009200000096000000 + 96CC4A4AD2FF3333BBFF2E2EB8FF13139FFFCECECEFFD1D1D1FFD6D6D6FFDCDC + DCFF11119EFF1111A1FF1111A1FF1D1DACFF000096CC0000960000009A000000 + 9ACC5050D8FF3737BFFF2323ABFFFFFFFFFFF7F7F7FFE8E8E8FFDEDEDEFFDBDB + DBFFDDDDDDFF11119BFF1616A0FF2B2BB5FF00009ACC00009A0000009E000000 + 9ECC5A5AE2FF4242CAFFFFFFFFFFFFFFFFFFFFFFFFFF4242CAFF4242CAFFFFFF + FFFFFFFFFFFFFFFFFFFF4242CAFF4E4ED6FF00009ECC00009E000000A2000000 + A2CC6262EAFF4F4FD7FF4F4FD7FFFFFFFFFF4F4FD7FF4F4FD7FF4F4FD7FF4F4F + D7FFFFFFFFFF4F4FD7FF4F4FD7FF5A5AE2FF0000A2CC0000A2000000A5000000 + A5BA6060ECF95B5BE3FF5B5BE3FF5B5BE3FF5B5BE3FF5B5BE3FF5B5BE3FF5B5B + E3FF5B5BE3FF5B5BE3FF5B5BE3FF5B5BE7F90000A5BA0000A5000000A8000000 + A8732A2AC7DD6363EFF96D6DF5FF6D6DF5FF6D6DF5FF6D6DF5FF6D6DF5FF6D6D + F5FF6D6DF5FF6C6CF4FF6262EEF92929C5DD0000A8730000A8000000A8000000 + A90C0000AA730000AABA0000AACC0000AACC0000AACC0000AACC0000AACC0000 + AACC0000AACC0000AACC0000AABA0000AA730000A90C0000A800FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00 + } + OnClick = btnLaterClick + TabOrder = 2 + end + object lbMessage: TLabel + Left = 8 + Height = 30 + Top = 8 + Width = 258 + Caption = 'New version found! Do you want to update now?'#13#10'FMD will be close to finish the update.' + ParentColor = False + end +end diff --git a/mangadownloader/forms/frmupdatedialog.pas b/mangadownloader/forms/frmupdatedialog.pas new file mode 100644 index 000000000..6acb1d1c5 --- /dev/null +++ b/mangadownloader/forms/frmupdatedialog.pas @@ -0,0 +1,48 @@ +unit frmUpdateDialog; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, + Buttons; + +type + + { TUpdateDialogForm } + + TUpdateDialogForm = class(TForm) + btnLater: TBitBtn; + btnUpdate: TBitBtn; + lbMessage: TLabel; + mmLog: TMemo; + procedure btnLaterClick(Sender: TObject); + procedure btnUpdateClick(Sender: TObject); + private + { private declarations } + public + { public declarations } + end; + +var + UpdateDialogForm: TUpdateDialogForm; + +implementation + +{$R *.lfm} + +{ TUpdateDialogForm } + +procedure TUpdateDialogForm.btnLaterClick(Sender: TObject); +begin + ModalResult := mrCancel; +end; + +procedure TUpdateDialogForm.btnUpdateClick(Sender: TObject); +begin + ModalResult := mrYes; +end; + +end. + diff --git a/mangadownloader/md.lpi b/mangadownloader/md.lpi index 4b6769d67..1c1096474 100644 --- a/mangadownloader/md.lpi +++ b/mangadownloader/md.lpi @@ -20,8 +20,7 @@ - - + @@ -35,7 +34,7 @@ - + @@ -79,7 +78,7 @@ - + @@ -126,7 +125,7 @@ - + @@ -170,7 +169,7 @@ - + @@ -238,7 +237,7 @@ - + @@ -246,6 +245,7 @@ + @@ -254,10 +254,12 @@ + + @@ -313,10 +315,12 @@ + + @@ -325,9 +329,10 @@ + - + @@ -337,13 +342,20 @@ + + + + + + + - + diff --git a/mangadownloader/md.lpr b/mangadownloader/md.lpr index 97aff1483..d8bdef321 100644 --- a/mangadownloader/md.lpr +++ b/mangadownloader/md.lpr @@ -18,7 +18,7 @@ richmemopackage, Forms, FileUtil, uBaseUnit, frmMain, frmImportList, - simpleipc, IniFiles, frmShutdownCounter; + simpleipc, IniFiles, frmShutdownCounter, frmUpdateDialog; var CheckInstance: Boolean = True; @@ -63,6 +63,7 @@ Application.CreateForm(TMainForm, MainForm); Application.CreateForm(TImportList, ImportList); Application.CreateForm(TShutdownCounterForm, ShutdownCounterForm); + Application.CreateForm(TUpdateDialogForm, UpdateDialogForm); Application.Run; end; end. diff --git a/mangadownloader/md.lps b/mangadownloader/md.lps index 2063b0556..1c3b5f784 100644 --- a/mangadownloader/md.lps +++ b/mangadownloader/md.lps @@ -3,71 +3,72 @@ - - + + - - + + + - - + + - - + - - - + + - - + + + - - + + + - - + + - - + + - - + + @@ -99,7 +100,8 @@ - + + @@ -110,8 +112,7 @@ - - + @@ -131,60 +132,60 @@ - + + - - + + + - - + + + - - + + - - - - - - + + + - - + + - - + + - + @@ -198,1281 +199,1292 @@ - + - - + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - + - + - + - + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - - - + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - + - + - + - + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - + + - - - + - + - + - + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -1480,34 +1492,34 @@ - - + + - - + + - - + + - - + + - - + + @@ -1515,19 +1527,19 @@ - - + + - - + + - - + + @@ -1535,75 +1547,75 @@ - - + + - - + + - - + + - - - - - - - + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -1611,1211 +1623,1270 @@ - - + + - - + + - - + + - - + + - - - - - + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - - + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - + + + + + + - - + + - - + + - - + + - - + + - - - - - - - + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - - + + - + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2828,11 +2899,6 @@ - - - - - - + diff --git a/mangadownloader/md.res b/mangadownloader/md.res index 8ceeea9101af0988b040419df3a33ad3ed5b101b..5d7d6d46322f0ab04c2d99d92da853d2885dd5f0 100644 GIT binary patch delta 35 qcmew&_C;*N7G`D!29C|!nddVy8#5S9j%4j-wP4U=FxdPO$N~V#hYCah delta 35 qcmew&_C;*N7G`Ef2KLR{nddVyn=zP7j%4j-HD}OcFx>nS$N~V#+X_hl diff --git a/update b/update index 60ed096d1..e4c7a8273 100644 --- a/update +++ b/update @@ -1,2 +1,2 @@ -0.9.7.1 -https://github.com/riderkick/FMD/releases/download/0.9.7/fmd-0.9.7.1.7z +0.9.8.0 +https://github.com/riderkick/FMD/releases/download/0.9.8/fmd-0.9.8.0.7z diff --git a/updater/uMain.pas b/updater/uMain.pas index 1621e7765..c4fdb48e1 100644 --- a/updater/uMain.pas +++ b/updater/uMain.pas @@ -10,8 +10,8 @@ interface cmem, {$endif} Classes, windows, SysUtils, zipper, ShellApi, FileUtil, Forms, - Dialogs, ComCtrls, StdCtrls, Clipbrd, ExtCtrls, USimpleException, httpsend, - blcksock, ssl_openssl; + Dialogs, ComCtrls, StdCtrls, Clipbrd, ExtCtrls, RegExpr, IniFiles, + USimpleException, httpsend, blcksock, ssl_openssl; type @@ -85,7 +85,6 @@ function HeaderByName(const AHeaders :TStrings; const HeaderName :string) :strin _URL :string = ''; _MaxRetry :cardinal = 1; - ProxyType :string; ProxyHost :string; ProxyPort :string; @@ -93,6 +92,9 @@ function HeaderByName(const AHeaders :TStrings; const HeaderName :string) :strin ProxyPass :string; const + Symbols: array [0..10] of Char = + ('\', '/', ':', '*', '?', '"', '<', '>', '|', #9, ';'); + mf_data_link = 'https://www.mediafire.com/folder/fwa8eomz80uk1/Data'; resourcestring @@ -122,10 +124,28 @@ function HeaderByName(const AHeaders :TStrings; const HeaderName :string) :strin implementation -uses RegExpr, IniFiles, uMessage; +uses uMessage; {$R *.lfm} +function RemoveSymbols(const input: String): String; +var + i: Integer; +begin + Result := input; + for i := Low(Symbols) to High(Symbols) do + begin + if Pos(Symbols[i], Result) > 0 then + Result := StringReplace(Result, Symbols[i], '', [rfReplaceAll]); + end; + + if (Length(Result) > 0) and + (Result[Length(Result)] = '.') then + begin + Result[Length(Result)] := '-'; + end; +end; + function RunAsAdmin(path, params: String; showWindow: Integer = SW_SHOWNORMAL; isPersistent: Boolean = False): Boolean; var @@ -197,6 +217,9 @@ function FormatByteSize(const bytes :longint) :string; else if bytes > KB then Result := FormatFloat('#.## KB', bytes / KB) + else + if bytes = 0 then + Result := '0 bytes' else Result := FormatFloat('#.## bytes', bytes); end; @@ -209,6 +232,7 @@ constructor TDownloadThread.Create; isDownload := True; FreeOnTerminate := True; FHTTP := THTTPSend.Create; + FHTTP.Sock.OnStatus := @SockOnStatus; FHTTP.Sock.OnHeartbeat := @SockOnHeartBeat; FHTTP.Sock.HeartbeatRate := 500; FTotalSize := 0; @@ -247,25 +271,37 @@ procedure TDownloadThread.ShowErrorMessage(AMessage: string); procedure TDownloadThread.SockOnHeartBeat(Sender :TObject); begin if Self.Terminated then - (Sender as TBlockSocket).AbortSocket; + begin + TBlockSocket(Sender).StopFlag := True; + TBlockSocket(Sender).AbortSocket; + end; end; procedure TDownloadThread.MainThreadUpdateProgress; +var + barPos: Integer; + prgText: string; begin - if (FCurrentSize > 0) and (FTotalSize > 0) then + if FCurrentSize > 0then begin - try - frmMain.pbDownload.Position := Round(1000 * (FCurrentSize / FTotalSize)); - finally - frmMain.lbProgress.Caption := - FormatByteSize(FCurrentSize) + ' / ' + FormatByteSize(FTotalSize); + if FTotalSize > 0 then + begin + barPos := Round(1000 * (FCurrentSize / FTotalSize)); + prgText := FormatByteSize(FCurrentSize) + ' / ' + FormatByteSize(FTotalSize); + end + else + begin + barPos := 0; + prgText := FormatByteSize(FCurrentSize); end; end else begin - frmMain.pbDownload.Position := 0; - frmMain.lbProgress.Caption := '0 / 0'; + barPos := 0; + prgText := '0 / 0'; end; + frmMain.pbDownload.Position := barPos; + frmMain.lbProgress.Caption := prgText; end; procedure TDownloadThread.MainThreadErrorGetting; @@ -278,12 +314,9 @@ procedure TDownloadThread.MainThreadErrorGetting; procedure TDownloadThread.SockOnStatus(Sender :TObject; Reason :THookSocketReason; const Value :string); begin + if Pos('Content-Length: ', FHTTP.Headers.Text) > 0 then + FTotalSize := StrToIntDef(HeaderByName(FHTTP.Headers, 'Content-Length'), 0);; case Reason of - HR_CanRead: - begin - if FHTTP.Headers.Count > 0 then - FTotalSize := StrToIntDef(HeaderByName(FHTTP.Headers, 'Content-Length'), 0); - end; HR_Connect :FCurrentSize := 0; HR_ReadCount :Inc(FCurrentSize, StrToIntDef(Value, 0)); end; @@ -442,7 +475,6 @@ procedure TDownloadThread.Execute; end; end; UpdateStatus(ST_Download + ' [' + FileName + ']...'); - FHTTP.Sock.OnStatus := @SockOnStatus; ctry := 0; FHTTP.Clear; @@ -482,7 +514,13 @@ procedure TDownloadThread.Execute; end; end; - fname := DirPath + DirectorySeparator + FileName; + fname := FileName; + regx.Expression := '^.*filename=(.+)$'; + fname := regx.Replace(fname, '$1', True); + regx.Expression := '(\.\w+)[\?\&].*$'; + fname := regx.Replace(fname, '$1', True); + fname := RemoveSymbols(fname); + fname := DirPath + DirectorySeparator + fname; if FileExistsUTF8(fname) then DeleteFileUTF8(fname); diff --git a/updater/updater.lps b/updater/updater.lps index 6cbc35c91..a88611579 100644 --- a/updater/updater.lps +++ b/updater/updater.lps @@ -4,12 +4,12 @@ - + - + @@ -20,9 +20,9 @@ - - - + + + @@ -32,7 +32,7 @@ - + @@ -72,8 +72,8 @@ - - + + @@ -204,6 +204,12 @@ + + + + + +