summaryrefslogtreecommitdiff
path: root/plugins/ImportTXT/BRMSIP.inc
blob: 552a98af3bd1ffd915fa677c75b8bf1128b3c69d (plain)
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
{$ifdef BIN_IMPORT_}
var rsz:integer;

{$else}
begin
 pt:=integer(pFileText);
 i:=0;
 if FileLen>=$30 then
 if (StrLComp(PChar(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 i<fsz do
       begin
        with dbei do
         begin
          fillchar(dbei,sizeof(dbei),0);
          cbSize:=sizeof(dbei);
          szModule:=PChar(proto);
          rsz:= RLInteger(pt+i+$08);
          if PByte(pt+i+$10)^=$00 then flags:=0
                                  else flags:=DBEF_SENT;
          flags:=flags or DBEF_READ or DBEF_UTF; //â ôàéëàõ ëåæàò â utf8 è èìïîðòèðóþòñÿ áåç èçìåíåíèé
          eventType:= EVENTTYPE_MESSAGE;
          cbBlob:=RLWord(pt+i+$13+RLWord(pt+i+$11));
          pBlob:=Pointer(pt+i+$13+RLWord(pt+i+$11)+$2);
          timestamp:=StrToTimeStamp(pointer(pt+i+$13+RLWord(pt+i+$11)+$4+cbBlob),RLWord(pt+i+$13+RLWord(pt+i+$11)+$2+cbBlob));
          inc(cbBlob);
         end;
        try
        if not IsDuplicateEvent(DContact.hContact,dbei) then
         if pluginLink^.CallService(MS_DB_EVENT_ADD, wParam(DContact.hContact), lParam(@dbei))<>0 then Inc(AddedMessages)
                                                                                      else begin
                                                          s:= 'Error adding message to DB';
                                                          DoMessage(ITXT_THREAD_ERROR,integer(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,integer(PWideChar(s)),0);
     end;
    end
        else
    begin
     s:=WideFormat(TranslateWideString('Its not %s file'),['midp-rms']);
     DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
    end
        else //file len

end;
{$endif}