1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
{$IFDEF BIN_IMPORT_}
var
rsz: integer;
{$ELSE}
begin
pt := uint_ptr(pFileText);
i := 0;
if FileLen >= $30 then
if (StrLComp(PAnsiChar(pt), 'midp-rms', 8) = 0) then
begin
if FileLen >= $48 then
if (RLInteger(pt + $40) = $48) then
begin
fsz := RLInteger(pt + $44);
i := $48;
end;
if (RLInteger(pt + $28) = $30) then
begin
fsz := RLInteger(pt + $2C);
i := $30;
end;
if (DContact.hContact = 0) or (DContact.hContact = INVALID_HANDLE_VALUE) then
if (fContact.hContact <> 0) and (fContact.hContact <> INVALID_HANDLE_VALUE) then
DContact := fContact;
if (DContact.hContact <> 0) and (DContact.hContact <> INVALID_HANDLE_VALUE) then
begin
proto := GetContactProto(DContact.hContact);
DoMessage(ITXT_THREAD_DEST_CONTACT, DContact.hContact, 0);
DoMessage(ITXT_THREAD_START, 0, 0);
DoMessage(ITXT_THREAD_MAXPROGRESS, 0, fsz);
while Cardinal(i) < fsz do
begin
fillchar(dbei, sizeof(dbei), 0);
dbei.szModule := PAnsiChar(proto);
rsz := RLInteger(pt + i + $08);
if PByte(pt + i + $10)^ = $00 then
dbei.flags := DBEF_READ or DBEF_UTF
else
dbei.flags := DBEF_READ or DBEF_UTF or DBEF_SENT;
// â ôàéëàõ ëåæàò â utf8 è èìïîðòèðóþòñÿ áåç èçìåíåíèé
dbei.eventType := EVENTTYPE_MESSAGE;
dbei.cbBlob := RLWord(pt + i + $13 + RLWord(pt + i + $11));
dbei.pBlob := Pointer(pt + i + $13 + RLWord(pt + i + $11) + $2);
dbei.timestamp := StrToTimeStamp
(Pointer(uint_ptr(pt + i) + $13 + RLWord(pt + i + $11) + $4 + dbei.cbBlob),
RLWord(uint_ptr(pt + i) + $13 + RLWord(pt + i + $11) + $2 + dbei.cbBlob));
inc(dbei.cbBlob);
try
if not IsDuplicateEvent(DContact.hContact, dbei) then
if db_event_add(DContact.hContact, @dbei) <> 0 then
inc(AddedMessages)
else
begin
s := 'Error adding message to database';
DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
break;
end
else
inc(Duplicates);
finally
inc(i, rsz);
end;
DoMessage(ITXT_THREAD_PROGRESS, i, 0);
end;
end
else
begin
s := TranslateWideString('Can''t determine destination contact');
DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
end;
end
else
begin
s := WideFormat(TranslateWideString('It''s not %s file'), ['midp-rms']);
DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
end
else // file len
end;
{$ENDIF}
|