From 94d8bccac15ff07bcbc2453a0220983495891f52 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 28 Jun 2017 13:43:27 +0300 Subject: fixes #786 (Importing mContacts history causes a crash and damages the user profile) --- plugins/HistoryPlusPlus/HistoryForm.pas | 96 ++-------------------------- plugins/HistoryPlusPlus/hpp_externalgrid.pas | 5 -- plugins/HistoryPlusPlus/hpp_global.pas | 5 ++ 3 files changed, 10 insertions(+), 96 deletions(-) (limited to 'plugins/HistoryPlusPlus') diff --git a/plugins/HistoryPlusPlus/HistoryForm.pas b/plugins/HistoryPlusPlus/HistoryForm.pas index eed0d360f1..f8426f80c3 100644 --- a/plugins/HistoryPlusPlus/HistoryForm.pas +++ b/plugins/HistoryPlusPlus/HistoryForm.pas @@ -478,92 +478,6 @@ begin Result := X end; -{ function ParseUrlItem(Item: THistoryItem; out Url,Mes: WideString): Boolean; - var - tmp1,tmp2: WideString; - n: Integer; - begin - Url := ''; - Mes := ''; - Result := False; - if not (mtUrl in Item.MessageType) then exit; - tmp1 := Item.Text; - if tmp1 = '' then exit; - Result := True; - - n := Pos(#10,tmp1); - if n <> 0 then begin - tmp2 := Copy(tmp1,1,n-2); - Delete(tmp1,1,n); - end else begin - tmp2 := tmp1; - tmp1 := ''; - end; - - Mes := tmp1; - - n := Pos(':',tmp2); - if n <> 0 then begin - tmp2 := Copy(tmp2,n+2,Length(tmp2)); - end else begin - Result := False; - tmp2 := ''; - end; - - url := tmp2; - end; } - -{ function ParseFileItem(Item: THistoryItem; out FileName,Mes: WideString): Boolean; - var - tmp1,tmp2: AnsiString; - n: Integer; - begin - Result := False; - FileName := ''; - Mes := ''; - if not (mtFile in Item.MessageType) then exit; - tmp1 := Item.Text; - - n := Pos(#10,tmp1); - if n <> 0 then begin - Delete(tmp1,1,n) - end else - exit; - - Result := True; - - n := Pos(#10,tmp1); - if n <> 0 then begin - tmp2 := tmp1; - tmp1 := Copy(tmp2,1,n-2); - Delete(tmp2,1,n); - end; - - Mes := tmp2; - FileName := tmp1; - end; } - -{ function GetEventInfo(hDBEvent: DWord): TDBEVENTINFO; - var - BlobSize:Integer; - begin - ZeroMemory(@Result,SizeOf(Result)); - Result.cbSize:=SizeOf(Result); - Result.pBlob:=nil; - BlobSize:=CallService(MS_DB_EVENT_GETBLOBSIZE,hDBEvent,0); - - GetMem(Result.pBlob,BlobSize); - Result.cbBlob:=BlobSize; - - CallService(MS_DB_EVENT_GET,hDBEvent,LPARAM(@Result)); - end; } - -(* - This function gets only name of the file - and tries to make it FAT-happy, so we trim out and - ":"-s, "\"-s and so on... -*) - procedure THistoryFrm.LoadHistory(Sender: TObject); // Load the History from the Database and Display it in the grid procedure FastLoadHandles; @@ -3905,7 +3819,7 @@ end; procedure THistoryFrm.hgMCData(Sender: TObject; Index: Integer; var Item: TMCItem; Stage: TSaveStage); var - DBEventInfo: TDBEventInfo; + DBEventInfo: TOldDbEventInfo; hDBEvent: THandle; DataOffset: PAnsiChar; begin @@ -3915,16 +3829,16 @@ begin hDBEvent := History[GridIndexToHistory(Index)]; if hDBEvent <> 0 then begin - DBEventInfo := GetEventInfo(hDBEvent); - DBEventInfo.szModule := nil; - Item.Size := sizeof(DBEventInfo) + Cardinal(DBEventInfo.cbBlob); + DBEventInfo.d := GetEventInfo(hDBEvent); + DBEventInfo.d.szModule := nil; + Item.Size := sizeof(DBEventInfo) + Cardinal(DBEventInfo.d.cbBlob); end; if Item.Size > 0 then begin GetMem(Item.Buffer, Item.Size); DataOffset := PAnsiChar(Item.Buffer) + sizeof(DBEventInfo); Move(DBEventInfo, Item.Buffer^, sizeof(DBEventInfo)); - Move(DBEventInfo.pBlob^, DataOffset^, DBEventInfo.cbBlob); + Move(DBEventInfo.d.pBlob^, DataOffset^, DBEventInfo.d.cbBlob); end; end else if Stage = ssDone then diff --git a/plugins/HistoryPlusPlus/hpp_externalgrid.pas b/plugins/HistoryPlusPlus/hpp_externalgrid.pas index 32c08d37e3..c97891746d 100644 --- a/plugins/HistoryPlusPlus/hpp_externalgrid.pas +++ b/plugins/HistoryPlusPlus/hpp_externalgrid.pas @@ -33,11 +33,6 @@ type PExtCustomItem = ^TExtCustomItem; - TOldDBEventInfo = record - cbSize : dword; - d : TDBEventInfo; - end; - TExtCustomItem = record Nick: String; Text: String; diff --git a/plugins/HistoryPlusPlus/hpp_global.pas b/plugins/HistoryPlusPlus/hpp_global.pas index c549f5b9c4..f4deebe2c0 100644 --- a/plugins/HistoryPlusPlus/hpp_global.pas +++ b/plugins/HistoryPlusPlus/hpp_global.pas @@ -73,6 +73,11 @@ type TRTLMode = (hppRTLDefault,hppRTLEnable,hppRTLDisable); + TOldDBEventInfo = record + cbSize : dword; + d : TDBEventInfo; + end; + PHistoryItem = ^THistoryItem; THistoryItem = record Time: DWord; -- cgit v1.2.3