summaryrefslogtreecommitdiff
path: root/plugins/ImportTXT/BICQ5IP.inc
diff options
context:
space:
mode:
authorAlexey Kulakov <panda75@bk.ru>2012-07-03 07:22:09 +0000
committerAlexey Kulakov <panda75@bk.ru>2012-07-03 07:22:09 +0000
commit8b8845c8e142c2e70bc0c2785ddf3a91ad3f84bd (patch)
tree58d80918e28651c678069aa2ee768f801eca74db /plugins/ImportTXT/BICQ5IP.inc
parent980bcaff693a86971750d6e9ffc8ba1e561b8b3a (diff)
New core adaptation (Delphi 7 normal compilation)
API headers update git-svn-id: http://svn.miranda-ng.org/main/trunk@731 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/ImportTXT/BICQ5IP.inc')
-rw-r--r--plugins/ImportTXT/BICQ5IP.inc200
1 files changed, 105 insertions, 95 deletions
diff --git a/plugins/ImportTXT/BICQ5IP.inc b/plugins/ImportTXT/BICQ5IP.inc
index 581085ece6..f86762451b 100644
--- a/plugins/ImportTXT/BICQ5IP.inc
+++ b/plugins/ImportTXT/BICQ5IP.inc
@@ -1,112 +1,122 @@
-{$ifdef BIN_IMPORT_}
+{$IFDEF BIN_IMPORT_}
+
var
- XI:XML_API_W;
- rhxml:HXML;
- curxml:HXML;
- chldxml:HXML;
- ptxt:PWideChar;
- txtlen:int;
- ic,tm:integer;
- res:LongBool;
+ XI: XML_API_W;
+ rhxml: HXML;
+ curxml: HXML;
+ chldxml: HXML;
+ ptxt: PWideChar;
+ txtlen: int;
+ ic, tm: integer;
+ res: LongBool;
+
+{$ELSE}
-{$else}
begin
- If pluginLink^.ServiceExists(MS_SYSTEM_GET_XI)>0 then
- begin
- XI.cbSize:=SizeOf(XML_API_W);
- res:=longbool(pluginLink^.CallService(MS_SYSTEM_GET_XI,0,Int(@XI)));
+ If ServiceExists(MS_SYSTEM_GET_XI) > 0 then
+ begin
+ XI.cbSize := SizeOf(XML_API_W);
+ res := LongBool(CallService(MS_SYSTEM_GET_XI, 0, int(@XI)));
if not res then
- begin
- XI.cbSize:=SizeOf(XML_API_W)-4;
- res:=longbool(pluginLink^.CallService(MS_SYSTEM_GET_XI,0,Int(@XI)));
+ begin
+ XI.cbSize := SizeOf(XML_API_W) - 4;
+ res := LongBool(CallService(MS_SYSTEM_GET_XI, 0, int(@XI)));
if not res then
- begin
- s:=TranslateWideString('Error at initialization XML parser');
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
+ begin
+ s := TranslateWideString('Error at initialization XML parser');
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
exit;
- end;
- end;
- end
- else
- begin
- s:=TranslateWideString('Your version of Miranda don''t support XML parsing');
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),0);
+ end;
+ end;
+ end
+ else
+ begin
+ s := TranslateWideString('Your version of Miranda don''t support XML parsing');
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
exit;
- 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);
- GetMem(ptxt,SizeOf(WideChar)*FileLen+2);
+ 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);
+ GetMem(ptxt, SizeOf(WideChar) * FileLen + 2);
try
- ptxt:=UTF8toWide(pFileText,ptxt,SizeOf(WideChar)*FileLen+2);
- ptxt[FileLen+1]:=#0000;
- rhxml:=XI.parseString(ptxt,@txtlen,'root');
+ ptxt := UTF8toWide(pFileText, ptxt, SizeOf(WideChar) * FileLen + 2);
+ ptxt[FileLen + 1] := #0000;
+ rhxml := XI.parseString(ptxt, @txtlen, 'root');
finally
- freemem(ptxt);
+ freemem(ptxt);
end;
- if (rhxml=0) then exit;
- DoMessage(ITXT_THREAD_MAXPROGRESS,0,xi.getChildCount(rhxml));
- chldxml:=xi.getFirstChild(rhxml);
- if xi.getName(chldxml)='version' then
+ if (rhxml = 0) then
+ exit;
+ DoMessage(ITXT_THREAD_MAXPROGRESS, 0, XI.getChildCount(rhxml));
+ chldxml := XI.getFirstChild(rhxml);
+ if XI.getName(chldxml) = 'version' then
+ begin
+ ic := 0;
+ curxml := XI.getNextChild(rhxml, 'event', @ic);
+ while (curxml <> 0) do
begin
- ic:=0;
- curxml:=xi.getNextChild(rhxml,'event',@ic);
- while (curxml<>0) do
- begin
- fillchar(dbei,sizeof(dbei),0);
- dbei.cbSize:=sizeof(dbei);
- dbei.szModule:=PChar(proto);
- if TryStrToInt(xi.getText(xi.getChildByPath(curxml,'time',false)),tm) then dbei.timestamp:=tm;
- if xi.getText(xi.getChildByPath(curxml,'incoming',false))='Yes' then dbei.flags:=DBEF_READ
- else dbei.flags:=DBEF_SENT or DBEF_READ;
- if isMirandaUnicode then dbei.flags:=dbei.flags or DBEF_UTF;
+ fillchar(dbei, SizeOf(dbei), 0);
+ dbei.cbSize := SizeOf(dbei);
+ dbei.szModule := PAnsiChar(proto);
+ if TryStrToInt(XI.getText(XI.getChildByPath(curxml, 'time', false)), tm)
+ then
+ dbei.timestamp := tm;
+ if XI.getText(XI.getChildByPath(curxml, 'incoming', false)) = 'Yes' then
+ dbei.flags := DBEF_READ or DBEF_UTF
+ else
+ dbei.flags := DBEF_READ or DBEF_UTF or DBEF_SENT;
- if xi.getText(xi.getChildByPath(curxml,'type',false))^='2' then
- begin
- s:=xi.getText(xi.getChildByPath(curxml,'text',false))+': '+
- xi.getText(xi.getChildByPath(curxml,'data',false));
- dbei.eventType:= EVENTTYPE_URL;
- end
- else
- begin
- s:=xi.getText(xi.getChildByPath(curxml,'text',false));
- dbei.eventType:= EVENTTYPE_MESSAGE;
- end;
- try
- if IsMirandaUnicode then tempstr:=WidetoUTF8(PWideChar(s),tempstr)
- else tempstr:=WideToANSI(PWideChar(s),tempstr,cp);
- dbei.cbBlob:=lstrlen(tempstr)+1;
- dbei.pBlob:=PByte(tempstr);
- 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
+ if XI.getText(XI.getChildByPath(curxml, 'type', false))^ = '2' then
+ begin
+ s := XI.getText(XI.getChildByPath(curxml, 'text', false)) + ': ' +
+ XI.getText(XI.getChildByPath(curxml, 'data', false));
+ dbei.eventType := EVENTTYPE_URL;
+ end
+ else
+ begin
+ s := XI.getText(XI.getChildByPath(curxml, 'text', false));
+ dbei.eventType := EVENTTYPE_MESSAGE;
+ end;
+ try
+ tempstr := WidetoUTF8(PWideChar(s), tempstr);
+ dbei.cbBlob := lstrlena(tempstr) + 1;
+ dbei.pBlob := PByte(tempstr);
+ if not IsDuplicateEvent(DContact.hContact, dbei) then
+ if 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, wparam(PWideChar(s)), 0);
+ break;
+ end
- else Inc(Duplicates);
+ else
+ Inc(Duplicates);
- finally
- FreeMem(tempstr);
- curxml:=xi.getNextChild(rhxml,'event',@ic);
- DoMessage(ITXT_THREAD_PROGRESS,ic,0);
- end;
+ finally
+ freemem(tempstr);
+ curxml := XI.getNextChild(rhxml, 'event', @ic);
+ DoMessage(ITXT_THREAD_PROGRESS, ic, 0);
end;
- end
- else
- begin
- s:=WideFormat(TranslateWideString('Its not %s file'),['ICQ5']);
- DoMessage(ITXT_THREAD_ERROR,integer(PWideChar(s)),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'), ['ICQ5']);
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ end;
+ end
+ else
+ begin
+ s := TranslateWideString('Can''t determine destination contact');
+ DoMessage(ITXT_THREAD_ERROR, wparam(PWideChar(s)), 0);
+ end;
end;
-{$endif} \ No newline at end of file
+{$ENDIF}