From cb4a46e7fbe62d788e66ed6121c717a2d22a4d7c Mon Sep 17 00:00:00 2001 From: watcherhd Date: Thu, 21 Apr 2011 14:14:52 +0000 Subject: svn.miranda.im is moving to a new home! git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@7 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- importtxt/BqhfIP.inc | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 importtxt/BqhfIP.inc (limited to 'importtxt/BqhfIP.inc') diff --git a/importtxt/BqhfIP.inc b/importtxt/BqhfIP.inc new file mode 100644 index 0000000..236a37d --- /dev/null +++ b/importtxt/BqhfIP.inc @@ -0,0 +1,131 @@ +{$ifdef BIN_IMPORT_} +var + qhfver:byte; + szMsgHd:word; + UIDstr:UTF8String; + UIDLen,NickLen:word; + NickStr:UTF8String; + +function DecodeQHFMsg(ver:byte; adr:integer; cSize:word):string; + +function get1(c: char): byte; +begin + if ShortInt(c)>=0 then Result:=Byte(c) + else Result := Byte(c)+256; +end; + +function get2(b:byte): char; +begin + if b<128 then result:=Char(b) + else result:=Char(b-256); +end; + +var i:integer; +begin + SetLength(Result,cSize); + for i:=1 to cSize do + begin + Result[i]:=PChar(adr+i-1)^; + if ver<>$01 then + begin + inc(Result[i],i); + Result[i]:=get2(255-get1(Result[i])); + end + end; +end; + +{$else} +begin + pt:=integer(pFileText); + if FileLen>=$2E then + if (PChar(pt)^='Q') and (PChar(pt+1)^='H') and (PChar(pt+2)^='F') then + begin + qhfver:=PByte(pt+3)^; + if qhfver>=$03 then szMsgHd:=$23 + else szMsgHd:=$21; + fsz:=RLInteger(pt+$04); + UIDLen:=RLWord(pt+$2C); + SetLength(UIDstr,UIDLen); + if qhfver<=2 then lstrcpynA(PChar(UIDstr),PChar(pt+$2E),UIDLen) + else lstrcpynA(PChar(UIDstr),PChar(pt+$2E),UIDLen+1); + NickLen:=RLWord(pt+$2E+UIDLen); + SetLength(NickStr,NickLen); + if qhfver<=2 then lstrcpynA(PChar(NickStr),PChar(pt+$2E+UIDLen+2),UIDLen) + else lstrcpynA(PChar(NickStr),PChar(pt+$2E+UIDLen+2),UIDLen+1); + inc(pt,$2E+UIDLen+2+NickLen); + if fsz<>FileLen-($2E+UIDLen+2+NickLen) then fsz:= FileLen-($2E+UIDLen+2+NickLen); + if (DContact.hContact=0) or (DContact.hContact=INVALID_HANDLE_VALUE) then + begin + if IsMirandaUnicode then DContact.ContactUID:=UIDstr + else + begin + tempstr:=UTF8ToANSI(PChar(UIDstr),tempstr,cp); + DContact.ContactUID:=tempstr; + FreeMem(tempstr); + end; + if IsMirandaUnicode then DContact.ContactNick:=NickStr + else + begin + tempstr:=UTF8ToANSI(PChar(NickStr),tempstr,cp); + DContact.ContactNick:=tempstr; + FreeMem(tempstr); + end; + TryDetermContact(DContact); + 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); + i:=0; + while i0 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,szMsgHd+dbei.cbBlob-1); + FreeMem(dbei.pBlob); + 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'),['QHF']); + DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0); + end + else //file len +end; +{$endif} \ No newline at end of file -- cgit v1.2.3