From 04f4e2acfbc82946ca3def654214c08071a87359 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 20 Jun 2015 13:55:58 +0000 Subject: xml api became a set of functions git-svn-id: http://svn.miranda-ng.org/main/trunk@14288 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Actman/iac_chain.pas | 27 +- plugins/Actman/iac_contact.pas | 29 +- plugins/Actman/iac_dbrw.pas | 89 ++---- plugins/Actman/iac_global.pas | 71 ++--- plugins/Actman/iac_inout.pas | 50 ++-- plugins/Actman/iac_jump.pas | 122 +++----- plugins/Actman/iac_messagebox.pas | 23 +- plugins/Actman/iac_program.pas | 37 ++- plugins/Actman/iac_service.pas | 109 +++----- plugins/Actman/iac_storage.pas | 9 +- plugins/Actman/iac_text.pas | 18 +- plugins/Actman/inoutxml.pas | 134 ++++----- plugins/Actman/ua/i_inoutjson.inc | 2 +- plugins/Actman/ua/i_inoutxm.inc | 389 ++++++++++++-------------- plugins/ImportTXT/BICQ5IP.inc | 47 +--- plugins/New_GPG/src/init.cpp | 3 +- plugins/New_GPG/src/utilities.cpp | 46 +-- plugins/NewsAggregator/Src/CheckFeed.cpp | 234 ++++++++-------- plugins/NewsAggregator/Src/Common.h | 105 +++---- plugins/NewsAggregator/Src/ExportImport.cpp | 138 ++++----- plugins/NewsAggregator/Src/NewsAggregator.cpp | 2 - plugins/NewsAggregator/Src/Options.cpp | 7 +- plugins/PasteIt/src/PasteIt.cpp | 2 - plugins/PasteIt/src/PasteToWeb2.cpp | 32 +-- plugins/Quotes/src/ModuleInfo.cpp | 3 - plugins/Quotes/src/XMLEngineMI.cpp | 26 +- plugins/Watrack/lastfm/i_last_api.inc | 343 +++++++++++------------ 27 files changed, 902 insertions(+), 1195 deletions(-) (limited to 'plugins') diff --git a/plugins/Actman/iac_chain.pas b/plugins/Actman/iac_chain.pas index 48b187259f..5be20d6d8c 100644 --- a/plugins/Actman/iac_chain.pas +++ b/plugins/Actman/iac_chain.pas @@ -141,37 +141,18 @@ begin end; 1: begin - with xmlparser do - begin - StrDupW(actname,getText(HXML(node))); - flags:=flags or ACF_BYNAME; - - if StrToInt(getAttrValue(HXML(node),ioNoWait))=1 then - flags:=flags or ACF_NOWAIT; - - if StrToInt(getAttrValue(HXML(node),ioKeepOld))=1 then - flags:=flags or ACF_KEEPOLD; - - if StrToInt(getAttrValue(HXML(node),ioSameThread))=1 then - flags:=flags or ACF_SAMETHREAD; - end; - end; -{ - 2: begin - - UF8ToWide(GetParamSectionStr(node,'name',nil),actname); + StrDupW(actname,xmlGetText(HXML(node))); flags:=flags or ACF_BYNAME; - if GetParamSectionInt(node,ioNoWait)=1 then + if StrToInt(xmlGetAttrValue(HXML(node),ioNoWait))=1 then flags:=flags or ACF_NOWAIT; - if GetParamSectionInt(node,ioKeepOld)=1 then + if StrToInt(xmlGetAttrValue(HXML(node),ioKeepOld))=1 then flags:=flags or ACF_KEEPOLD; - if GetParamSectionInt(node,ioSameThread)=1 then + if StrToInt(xmlGetAttrValue(HXML(node),ioSameThread))=1 then flags:=flags or ACF_SAMETHREAD; end; -} end; end; diff --git a/plugins/Actman/iac_contact.pas b/plugins/Actman/iac_contact.pas index 7c17334f15..561c8840fa 100644 --- a/plugins/Actman/iac_contact.pas +++ b/plugins/Actman/iac_contact.pas @@ -84,25 +84,12 @@ begin contact:=LoadContact(DBBranch,node); 1: begin - with xmlparser do - begin - contact:=ImportContact(HXML(node)); - if StrToInt(getAttrValue(HXML(node),ioKeepOnly))=1 then - flags:=flags or ACF_KEEPONLY; - if StrToInt(getAttrValue(HXML(node),ioWindow))=1 then - flags:=flags or ACF_GETACTIVE; - end; - end; -{ - 2: begin - contact:=ImportContactINI(node); - - if GetParamSectionInt(node,ioKeepOnly)=1 then + contact:=ImportContact(HXML(node)); + if StrToInt(xmlGetAttrValue(HXML(node),ioKeepOnly))=1 then flags:=flags or ACF_KEEPONLY; - if GetParamSectionInt(node,ioWindow)=1 then + if StrToInt(xmlGetAttrValue(HXML(node),ioWindow))=1 then flags:=flags or ACF_GETACTIVE; end; -} end; end; @@ -112,7 +99,6 @@ var cws:TDBVARIANT; p1:pAnsiChar; p:pWideChar; -// tmpbuf:array [0..63] of WideChar; is_chat:boolean; begin result:=0; @@ -168,14 +154,7 @@ begin case fmt of 0: if (flags and ACF_GETACTIVE)=0 then SaveContact(contact,DBBranch,node); -{ - 1: begin - sub:=AddChild(actnode,ioContactWindow,nil); - ExportContact(sub,contact); -// AddAttrInt(sub,ioNumber,0); // contact - if (flags and ACF_KEEPONLY)<>0 then AddAttrInt(sub,ioKeepOnly,1); - end; -} + 13: begin tTextExport(node).AddFlag('keeponly' ,(flags or ACF_KEEPONLY )<>0); tTextExport(node).AddFlag('getactive',(flags or ACF_GETACTIVE)<>0); diff --git a/plugins/Actman/iac_dbrw.pas b/plugins/Actman/iac_dbrw.pas index f9faa18293..dffd5ca233 100644 --- a/plugins/Actman/iac_dbrw.pas +++ b/plugins/Actman/iac_dbrw.pas @@ -389,79 +389,40 @@ begin end; 1: begin - with xmlparser do + tmp:=xmlGetAttrValue(HXML(node),ioOper); + if lstrcmpiw(tmp,ioDelete)=0 then flags:=flags or ACF_DBDELETE + else if lstrcmpiw(tmp,ioWrite )=0 then flags:=flags or ACF_DBWRITE; + tmp:=xmlGetAttrValue(HXML(node),ioContact); + if lstrcmpiw(tmp,ioCurrent)=0 then flags:=flags or ACF_CURRENT + else if lstrcmpiw(tmp,ioResult )=0 then flags:=flags or ACF_RESULT + else if lstrcmpiw(tmp,ioParam )=0 then flags:=flags or ACF_PARAM + else if lstrcmpiw(tmp,ioContact)=0 then begin - tmp:=getAttrValue(HXML(node),ioOper); - if lstrcmpiw(tmp,ioDelete)=0 then flags:=flags or ACF_DBDELETE - else if lstrcmpiw(tmp,ioWrite )=0 then flags:=flags or ACF_DBWRITE; - // else if lstrcmpiw(tmp,ioRead)=0 then ; - tmp:=getAttrValue(HXML(node),ioContact); - if lstrcmpiw(tmp,ioCurrent)=0 then flags:=flags or ACF_CURRENT - else if lstrcmpiw(tmp,ioResult )=0 then flags:=flags or ACF_RESULT - else if lstrcmpiw(tmp,ioParam )=0 then flags:=flags or ACF_PARAM - else if lstrcmpiw(tmp,ioContact)=0 then - begin - dbcontact:=ImportContact(HXML(node)); - end; - - StrDupW(dbmodule ,getAttrValue(HXML(node),ioModule)); - StrDupW(dbsetting,getAttrValue(HXML(node),ioSetting)); - - if StrToInt(getAttrValue(HXML(node),ioFileVariable))=1 then flags:=flags or ACF_RW_MODULE; - if StrToInt(getAttrValue(HXML(node),ioArgVariable ))=1 then flags:=flags or ACF_RW_SETTING; - if StrToInt(getAttrValue(HXML(node),ioVariables ))=1 then flags:=flags or ACF_RW_VALUE; - - tmp:=getAttrValue(HXML(node),ioType); - if lstrcmpiw(tmp,ioByte )=0 then flags:=flags or ACF_DBBYTE - else if lstrcmpiw(tmp,ioWord )=0 then flags:=flags or ACF_DBWORD - else if lstrcmpiw(tmp,ioDword)=0 then - else if lstrcmpiw(tmp,ioAnsi )=0 then flags:=flags or ACF_DBANSI - else flags:=flags or ACF_DBUTEXT; - - if StrToInt(getAttrValue(HXML(node),ioSaveValue))=1 then - flags:=flags or ACF_SAVE; - - if StrToInt(getAttrValue(HXML(node),ioLast))=1 then - flags:=flags or ACF_LAST - else - StrDupW(dbvalue,getText(HXML(node))); - end; - end; -{ - 2: begin - pc:=GetParamSectionStr(node,ioOper); - if lstrcmpi(pc,ioDelete)=0 then flags:=flags or ACF_DBDELETE - else if lstrcmpi(pc,ioWrite )=0 then flags:=flags or ACF_DBWRITE; -// else if lstrcmpiw(tmp,ioRead)=0 then ; - pc:=GetParamSectionStr(node,ioContact); - if lstrcmpi(pc,ioCurrent)=0 then flags:=flags or ACF_CURRENT - else if lstrcmpi(pc,ioResult )=0 then flags:=flags or ACF_RESULT - else if lstrcmpi(pc,ioParam )=0 then flags:=flags or ACF_PARAM - else if lstrcmpi(pc,ioContact)=0 then - begin - dbcontact:=ImportContactINI(node); + dbcontact:=ImportContact(HXML(node)); end; - UF8ToWide(GetParamSectionStr(node,ioModule ),dbmodule); - UF8ToWide(GetParamSectionStr(node,ioSetting),dbsetting); + StrDupW(dbmodule ,xmlGetAttrValue(HXML(node),ioModule)); + StrDupW(dbsetting,xmlGetAttrValue(HXML(node),ioSetting)); - if GetParamSectionInt(node,ioFileVariable)=1 then flags:=flags or ACF_RW_MODULE; - if GetParamSectionInt(node,ioArgVariable )=1 then flags:=flags or ACF_RW_SETTING; - if GetParamSectionInt(node,ioVariables )=1 then flags:=flags or ACF_RW_VALUE; + if StrToInt(xmlGetAttrValue(HXML(node),ioFileVariable))=1 then flags:=flags or ACF_RW_MODULE; + if StrToInt(xmlGetAttrValue(HXML(node),ioArgVariable ))=1 then flags:=flags or ACF_RW_SETTING; + if StrToInt(xmlGetAttrValue(HXML(node),ioVariables ))=1 then flags:=flags or ACF_RW_VALUE; + + tmp:=xmlGetAttrValue(HXML(node),ioType); + if lstrcmpiw(tmp,ioByte )=0 then flags:=flags or ACF_DBBYTE + else if lstrcmpiw(tmp,ioWord )=0 then flags:=flags or ACF_DBWORD + else if lstrcmpiw(tmp,ioDword)=0 then + else if lstrcmpiw(tmp,ioAnsi )=0 then flags:=flags or ACF_DBANSI + else flags:=flags or ACF_DBUTEXT; - pc:=GetParamSectionStr(node,ioType); - if lstrcmpi(pc,ioByte )=0 then flags:=flags or ACF_DBBYTE - else if lstrcmpi(pc,ioWord )=0 then flags:=flags or ACF_DBWORD - else if lstrcmpi(pc,ioDword)=0 then - else if lstrcmpi(pc,ioAnsi )=0 then flags:=flags or ACF_DBANSI - else flags:=flags or ACF_DBUTEXT; + if StrToInt(xmlGetAttrValue(HXML(node),ioSaveValue))=1 then + flags:=flags or ACF_SAVE; - if GetParamSectionInt(node,ioLast))=1 then + if StrToInt(xmlGetAttrValue(HXML(node),ioLast))=1 then flags:=flags or ACF_LAST else - UF8ToWide(GetParamSectionStr(node,'value'),dbvalue); //!! + StrDupW(dbvalue,xmlGetText(HXML(node))); end; -} end; end; diff --git a/plugins/Actman/iac_global.pas b/plugins/Actman/iac_global.pas index aee55d1bfb..aa5b9bb87c 100644 --- a/plugins/Actman/iac_global.pas +++ b/plugins/Actman/iac_global.pas @@ -14,9 +14,6 @@ const rtAnsi = 3; rtUTF8 = 4; -var - xmlparser:TXML_API_W; - const IcoLibPrefix = 'action_type_'; const @@ -175,22 +172,11 @@ begin end; 1: begin - with xmlparser do - begin - if StrToInt(getAttrValue(HXML(node),ioDisabled))=1 then - flags:=flags or ACF_DISABLED; - - StrDupW(ActionDescr,getAttrValue(HXML(node),ioName)); - end; - end; -{ - 2: begin - if GetParamSectionInt(node,ioDisabled))=1 then + if StrToInt(xmlGetAttrValue(HXML(node),ioDisabled))=1 then flags:=flags or ACF_DISABLED; - UF8ToWide(GetParamSectionStr(node,ioName),ActionDescr); + StrDupW(ActionDescr,xmlGetAttrValue(HXML(node),ioName)); end; -} end; end; @@ -335,36 +321,33 @@ var is_chat:boolean; bufLen:int; begin - with xmlparser do + proto:=FastWideToAnsiBuf(xmlGetAttrValue(node,ioCProto),tmpbuf); + if (proto=nil) or (proto^=#0) then begin - proto:=FastWideToAnsiBuf(getAttrValue(node,ioCProto),tmpbuf); - if (proto=nil) or (proto^=#0) then - begin - result:=0; - exit; - end; - is_chat:=StrToInt(getAttrValue(node,ioIsChat))<>0; + result:=0; + exit; + end; + is_chat:=StrToInt(xmlGetAttrValue(node,ioIsChat))<>0; - tmp:=getAttrValue(node,ioCUID); - if is_chat then - begin - dbv.szVal.W:=tmp; - end - else - begin - FillChar(dbv,SizeOf(TDBVARIANT),0); - dbv._type:=StrToInt(getAttrValue(node,ioCUIDType)); - case dbv._type of - DBVT_BYTE : dbv.bVal:=StrToInt(tmp); - DBVT_WORD : dbv.wVal:=StrToInt(tmp); - DBVT_DWORD : dbv.dVal:=StrToInt(tmp); - DBVT_ASCIIZ: FastWideToAnsi(tmp,dbv.szVal.A); - DBVT_UTF8 : WideToUTF8(tmp,dbv.szVal.A); - DBVT_WCHAR : dbv.szVal.W:=tmp; - DBVT_BLOB : begin - dbv.pbVal := mir_base64_decode(FastWideToAnsi(tmp,pAnsiChar(dbv.pbVal)),bufLen); - dbv.cpbVal := bufLen; - end; + tmp:=xmlGetAttrValue(node,ioCUID); + if is_chat then + begin + dbv.szVal.W:=tmp; + end + else + begin + FillChar(dbv,SizeOf(TDBVARIANT),0); + dbv._type:=StrToInt(xmlGetAttrValue(node,ioCUIDType)); + case dbv._type of + DBVT_BYTE : dbv.bVal:=StrToInt(tmp); + DBVT_WORD : dbv.wVal:=StrToInt(tmp); + DBVT_DWORD : dbv.dVal:=StrToInt(tmp); + DBVT_ASCIIZ: FastWideToAnsi(tmp,dbv.szVal.A); + DBVT_UTF8 : WideToUTF8(tmp,dbv.szVal.A); + DBVT_WCHAR : dbv.szVal.W:=tmp; + DBVT_BLOB : begin + dbv.pbVal := mir_base64_decode(FastWideToAnsi(tmp,pAnsiChar(dbv.pbVal)),bufLen); + dbv.cpbVal := bufLen; end; end; end; diff --git a/plugins/Actman/iac_inout.pas b/plugins/Actman/iac_inout.pas index 5ae7a1cedf..b5fcbb466a 100644 --- a/plugins/Actman/iac_inout.pas +++ b/plugins/Actman/iac_inout.pas @@ -327,36 +327,32 @@ begin end; 1: begin - with xmlparser do + tmp:=xmlGetAttrValue(HXML(node),ioObject); + if lstrcmpiw(tmp,ioClipboard)=0 then begin - tmp:=getAttrValue(HXML(node),ioObject); - if lstrcmpiw(tmp,ioClipboard)=0 then - begin - flags:=flags or ACF_CLIPBRD; - tmp:=getAttrValue(HXML(node),ioOper); - if lstrcmpiw(tmp,ioCopy)=0 then flags:=flags or ACF_COPYTO; - // else if lstrcmpiw(tmp,'paste')=0 then ; - end - else + flags:=flags or ACF_CLIPBRD; + tmp:=xmlGetAttrValue(HXML(node),ioOper); + if lstrcmpiw(tmp,ioCopy)=0 then flags:=flags or ACF_COPYTO; + end + else + begin + if lstrcmpiw(tmp,ioFile)=0 then begin - if lstrcmpiw(tmp,ioFile)=0 then - begin - if StrToInt(getAttrValue(HXML(node),ioFileVariable))=1 then - flags:=flags or ACF_FILE_PATH; - - flags:=flags or ACF_FILE; - StrDupW(tfile,getAttrValue(HXML(node),ioFile)); - tmp:=getAttrValue(HXML(node),ioOper); - if lstrcmpiw(tmp,ioWrite )=0 then flags:=flags or ACF_FWRITE - else if lstrcmpiw(tmp,ioAppend)=0 then flags:=flags or ACF_FAPPEND; - case StrToInt(getAttrValue(HXML(node),ioEnc)) of - 0: flags:=flags or ACF_ANSI; - 1: flags:=flags or ACF_UTF8; - 2: flags:=flags or ACF_UTF8 or ACF_SIGN; - 3: flags:=flags or 0; - 4: flags:=flags or ACF_SIGN; - end; + if StrToInt(xmlGetAttrValue(HXML(node),ioFileVariable))=1 then + flags:=flags or ACF_FILE_PATH; + + flags:=flags or ACF_FILE; + StrDupW(tfile,xmlGetAttrValue(HXML(node),ioFile)); + tmp:=xmlGetAttrValue(HXML(node),ioOper); + if lstrcmpiw(tmp,ioWrite )=0 then flags:=flags or ACF_FWRITE + else if lstrcmpiw(tmp,ioAppend)=0 then flags:=flags or ACF_FAPPEND; + case StrToInt(xmlGetAttrValue(HXML(node),ioEnc)) of + 0: flags:=flags or ACF_ANSI; + 1: flags:=flags or ACF_UTF8; + 2: flags:=flags or ACF_UTF8 or ACF_SIGN; + 3: flags:=flags or 0; + 4: flags:=flags or ACF_SIGN; end; end; end; diff --git a/plugins/Actman/iac_jump.pas b/plugins/Actman/iac_jump.pas index 4ac0473405..8e2bba787c 100644 --- a/plugins/Actman/iac_jump.pas +++ b/plugins/Actman/iac_jump.pas @@ -293,100 +293,54 @@ begin end; 1: begin - with xmlparser do + sub:=xmlGetNthChild(HXML(node),ioIf,0); + if sub<>0 then begin - sub:=getNthChild(HXML(node),ioIf,0); - if sub<>0 then - begin - tmp:=getAttrValue(sub,ioOper); - if lstrcmpiw(tmp,'math')=0 then flags:=flags or ACF_MATH - else if lstrcmpiw(tmp,ioNop )=0 then flags:=flags or ACF_NOP; + tmp:=xmlGetAttrValue(sub,ioOper); + if lstrcmpiw(tmp,'math')=0 then flags:=flags or ACF_MATH + else if lstrcmpiw(tmp,ioNop )=0 then flags:=flags or ACF_NOP; - tmp:=getAttrValue(sub,ioCond); - if lstrcmpiw(tmp,ioNop)=0 then flags:=flags or ACF_NOP // compatibility - else if (flags and ACF_NOP)=0 then + tmp:=xmlGetAttrValue(sub,ioCond); + if lstrcmpiw(tmp,ioNop)=0 then flags:=flags or ACF_NOP // compatibility + else if (flags and ACF_NOP)=0 then + begin + if flags and ACF_MATH<>0 then begin - if flags and ACF_MATH<>0 then - begin - if lstrcmpiw(tmp,'gt' )=0 then condition:=aeGT - else if lstrcmpiw(tmp,'lt' )=0 then condition:=aeLT - else if lstrcmpiw(tmp,'eq' )=0 then condition:=aeEQ - else if lstrcmpiw(tmp,'xor')=0 then condition:=aeXR - else if lstrcmpiw(tmp,'and')=0 then condition:=aeND; - end - else - begin - if lstrcmpiw(tmp,'empty')=0 then condition:=aeEMP - else if lstrcmpiw(tmp,'eq' )=0 then condition:=aeEQU - else if lstrcmpiw(tmp,'cont' )=0 then condition:=aeCON - else if lstrcmpiw(tmp,'start')=0 then condition:=aeSTR - else if lstrcmpiw(tmp,'ends' )=0 then condition:=aeEND; - - if StrToInt(getAttrValue(sub,ioCase))=1 then - flags:=flags or ACF_CASE; - if StrToInt(getAttrValue(sub,ioBack))=1 then - flags:=flags or ACF_BACK; - end; - if StrToInt(getAttrValue(sub,ioNot))=1 then - flags:=flags or ACF_NOT; - - if ((flags and ACF_MATH)<>0) or (condition<>aeEMP) then - StrDupW(value,getAttrValue(sub,ioValue)); + if lstrcmpiw(tmp,'gt' )=0 then condition:=aeGT + else if lstrcmpiw(tmp,'lt' )=0 then condition:=aeLT + else if lstrcmpiw(tmp,'eq' )=0 then condition:=aeEQ + else if lstrcmpiw(tmp,'xor')=0 then condition:=aeXR + else if lstrcmpiw(tmp,'and')=0 then condition:=aeND; + end + else + begin + if lstrcmpiw(tmp,'empty')=0 then condition:=aeEMP + else if lstrcmpiw(tmp,'eq' )=0 then condition:=aeEQU + else if lstrcmpiw(tmp,'cont' )=0 then condition:=aeCON + else if lstrcmpiw(tmp,'start')=0 then condition:=aeSTR + else if lstrcmpiw(tmp,'ends' )=0 then condition:=aeEND; + + if StrToInt(xmlGetAttrValue(sub,ioCase))=1 then + flags:=flags or ACF_CASE; + if StrToInt(xmlGetAttrValue(sub,ioBack))=1 then + flags:=flags or ACF_BACK; end; - end; + if StrToInt(xmlGetAttrValue(sub,ioNot))=1 then + flags:=flags or ACF_NOT; - sub:=getNthChild(HXML(node),ioPost,0); - if sub<>0 then - begin - tmp:=getAttrValue(sub,ioOper); - if lstrcmpiw(tmp,ioBreak)=0 then flags:=flags or ACF_BREAK - else if lstrcmpiw(tmp,ioJump )=0 then StrDupW(actlabel,getAttrValue(sub,ioValue)); + if ((flags and ACF_MATH)<>0) or (condition<>aeEMP) then + StrDupW(value,xmlGetAttrValue(sub,ioValue)); end; end; - end; -{ - 2: begin - pc:=GetParamSectionStr(node,ioOper); - if lstrcmpi(pc,'math')=0 then flags:=flags or ACF_MATH - else if lstrcmpi(pc,ioNop )=0 then flags:=flags or ACF_NOP; - - pc:=GetParamSectionStr(node,ioCond); - if lstrcmpi(pc,ioNop)=0 then flags:=flags or ACF_NOP // compatibility - else if (flags and ACF_NOP)=0 then - begin - if flags and ACF_MATH<>0 then - begin - if lstrcmpi(pc,'gt' )=0 then condition:=aeGT - else if lstrcmpi(pc,'lt' )=0 then condition:=aeLT - else if lstrcmpi(pc,'eq' )=0 then condition:=aeEQ - else if lstrcmpi(pc,'xor')=0 then condition:=aeXR - else if lstrcmpi(pc,'and')=0 then condition:=aeND; - end - else - begin - if lstrcmpi(pc,'empty')=0 then condition:=aeEMP - else if lstrcmpi(pc,'eq' )=0 then condition:=aeEQU - else if lstrcmpi(pc,'cont' )=0 then condition:=aeCON - else if lstrcmpi(pc,'start')=0 then condition:=aeSTR - else if lstrcmpi(pc,'ends' )=0 then condition:=aeEND; - - if GetParamSectionInt(node,ioCase)=1 then - flags:=flags or ACF_CASE; - if GetParamSectionInt(node,ioBack)=1 then - flags:=flags or ACF_BACK; - end; - if GetParamSectionInt(node,ioNot)=1 then - flags:=flags or ACF_NOT; - if ((flags and ACF_MATH)<>0) or (condition<>aeEMP) then - UTF8ToWide(GetParamSectionStr(node,ioValue),value); + sub:=xmlGetNthChild(HXML(node),ioPost,0); + if sub<>0 then + begin + tmp:=xmlGetAttrValue(sub,ioOper); + if lstrcmpiw(tmp,ioBreak)=0 then flags:=flags or ACF_BREAK + else if lstrcmpiw(tmp,ioJump )=0 then StrDupW(actlabel,xmlGetAttrValue(sub,ioValue)); end; - - pc:=GetParamSectionStr(node,ioAction); - if lstrcmpi(pc,ioBreak)=0 then flags:=flags or ACF_BREAK - else if lstrcmpi(pc,ioJump )=0 then UTF8ToWide(GetParamSectionStr(node,ioLabel),actlabel); end; -} end; end; diff --git a/plugins/Actman/iac_messagebox.pas b/plugins/Actman/iac_messagebox.pas index 41a1068ab2..78320e1cd5 100644 --- a/plugins/Actman/iac_messagebox.pas +++ b/plugins/Actman/iac_messagebox.pas @@ -147,26 +147,13 @@ begin end; 1: begin - with xmlparser do - begin - StrDupW(msgtitle,getAttrValue(HXML(node),ioTitle)); - StrDupW(msgtext,getText(HXML(node))); - boxopts:=StrToInt(getAttrValue(HXML(node),ioType)); - - if StrToInt(getAttrValue(HXML(node),ioArgVariable))=1 then flags:=flags or ACF_MSG_TXT; - if StrToInt(getAttrValue(HXML(node),ioVariables ))=1 then flags:=flags or ACF_MSG_TTL; - end; - end; -{ - 2: begin - UTF8ToWide(GetParamSectionInt(node,ioTitle),msgtitle); - UTF8ToWide(GetParamSectionInt(node,ioText ),msgtext); - boxopts:=GetParamSectionInt(node,ioType); + StrDupW(msgtitle,xmlGetAttrValue(HXML(node),ioTitle)); + StrDupW(msgtext,xmlGetText(HXML(node))); + boxopts:=StrToInt(xmlGetAttrValue(HXML(node),ioType)); - if GetParamSectionInt(node,ioArgVariable)=1 then flags:=flags or ACF_MSG_TXT; - if GetParamSectionInt(node,ioVariables )=1 then flags:=flags or ACF_MSG_TTL; + if StrToInt(xmlGetAttrValue(HXML(node),ioArgVariable))=1 then flags:=flags or ACF_MSG_TXT; + if StrToInt(xmlGetAttrValue(HXML(node),ioVariables ))=1 then flags:=flags or ACF_MSG_TTL; end; -} end; end; diff --git a/plugins/Actman/iac_program.pas b/plugins/Actman/iac_program.pas index 33924c4279..d16c356019 100644 --- a/plugins/Actman/iac_program.pas +++ b/plugins/Actman/iac_program.pas @@ -244,30 +244,27 @@ begin end; 1: begin - with xmlparser do - begin - StrDupW(prgname,getText(HXML(node))); - StrDupW(args,getAttrValue(HXML(node),ioArgs)); - if StrToInt(getAttrValue(HXML(node),ioCurrent))=1 then - flags:=flags or ACF_CURPATH; + StrDupW(prgname,xmlGetText(HXML(node))); + StrDupW(args,xmlGetAttrValue(HXML(node),ioArgs)); + if StrToInt(xmlGetAttrValue(HXML(node),ioCurrent))=1 then + flags:=flags or ACF_CURPATH; - if StrToInt(getAttrValue(HXML(node),ioParallel))=1 then - flags:=flags or ACF_PRTHREAD - else - time:=StrToInt(getAttrValue(HXML(node),ioWait)); + if StrToInt(xmlGetAttrValue(HXML(node),ioParallel))=1 then + flags:=flags or ACF_PRTHREAD + else + time:=StrToInt(xmlGetAttrValue(HXML(node),ioWait)); - if StrToInt(getAttrValue(HXML(node),ioFileVariable))=1 then - flags:=flags or ACF_PRG_PRG; + if StrToInt(xmlGetAttrValue(HXML(node),ioFileVariable))=1 then + flags:=flags or ACF_PRG_PRG; - if StrToInt(getAttrValue(HXML(node),ioArgVariable))=1 then - flags:=flags or ACF_PRG_ARG; + if StrToInt(xmlGetAttrValue(HXML(node),ioArgVariable))=1 then + flags:=flags or ACF_PRG_ARG; - tmp:=getAttrValue(HXML(node),ioWindow); - if lstrcmpiw(tmp,ioHidden )=0 then show:=SW_HIDE - else if lstrcmpiw(tmp,ioMinimized)=0 then show:=SW_SHOWMINIMIZED - else if lstrcmpiw(tmp,ioMaximized)=0 then show:=SW_SHOWMAXIMIZED - else show:=SW_SHOWNORMAL; - end; + tmp:=xmlGetAttrValue(HXML(node),ioWindow); + if lstrcmpiw(tmp,ioHidden )=0 then show:=SW_HIDE + else if lstrcmpiw(tmp,ioMinimized)=0 then show:=SW_SHOWMINIMIZED + else if lstrcmpiw(tmp,ioMaximized)=0 then show:=SW_SHOWMAXIMIZED + else show:=SW_SHOWNORMAL; end; { 2: begin diff --git a/plugins/Actman/iac_service.pas b/plugins/Actman/iac_service.pas index cfeb456191..1868b89214 100644 --- a/plugins/Actman/iac_service.pas +++ b/plugins/Actman/iac_service.pas @@ -174,25 +174,22 @@ begin result:=ACF_TYPE_NUMBER; if act=0 then exit; - with xmlparser do + + tmp:=xmlGetAttrValue(act,ioType); + if lstrcmpiw(tmp,ioCurrent)=0 then result:=ACF_TYPE_CURRENT + else if lstrcmpiw(tmp,ioResult )=0 then result:=ACF_TYPE_RESULT + else if lstrcmpiw(tmp,ioParam )=0 then result:=ACF_TYPE_PARAM + else if lstrcmpiw(tmp,ioStruct )=0 then begin - tmp:=getAttrValue(act,ioType); - if lstrcmpiw(tmp,ioCurrent)=0 then result:=ACF_TYPE_CURRENT - else if lstrcmpiw(tmp,ioResult )=0 then result:=ACF_TYPE_RESULT - else if lstrcmpiw(tmp,ioParam )=0 then result:=ACF_TYPE_PARAM - else if lstrcmpiw(tmp,ioStruct )=0 then - begin - result:=ACF_TYPE_STRUCT; -//!!!! param:=ReadStruct(act); - end - else - begin - StrDupW(pWideChar(param),getAttrValue(act,ioValue)); - - if lstrcmpiw(tmp,ioNumber )=0 then result:=ACF_TYPE_NUMBER - else if lstrcmpiw(tmp,ioUnicode)=0 then result:=ACF_TYPE_UNICODE - else if lstrcmpiw(tmp,ioAnsi )=0 then result:=ACF_TYPE_STRING; - end; + result:=ACF_TYPE_STRUCT; + end + else + begin + StrDupW(pWideChar(param),xmlGetAttrValue(act,ioValue)); + + if lstrcmpiw(tmp,ioNumber )=0 then result:=ACF_TYPE_NUMBER + else if lstrcmpiw(tmp,ioUnicode)=0 then result:=ACF_TYPE_UNICODE + else if lstrcmpiw(tmp,ioAnsi )=0 then result:=ACF_TYPE_STRING; end; end; { @@ -329,60 +326,32 @@ begin service.w_flags:=0; service.l_flags:=0; - with xmlparser do - begin - FastWideToAnsi(getAttrValue(HXML(node),ioService),service.service); -//!!!! StrDupW(service,getAttrValue(HXML(node),ioService)); - if StrToInt(getAttrValue(HXML(node),ioVariables))=1 then - service.flags:=service.flags or ACF_FLAG_SCRIPT; + FastWideToAnsi(xmlGetAttrValue(HXML(node),ioService),service.service); + if StrToInt(xmlGetAttrValue(HXML(node),ioVariables))=1 then + service.flags:=service.flags or ACF_FLAG_SCRIPT; - sub:=getNthChild(HXML(node),ioWParam,0); - if StrToInt(getAttrValue(sub,ioVariables))=1 then - service.w_flags:=service.w_flags or ACF_FLAG_SCRIPT; - service.w_flags:=service.w_flags or - ReadParam(sub,PWideChar(service.wparam),(service.w_flags and ACF_FLAG_SCRIPT)<>0); - - sub:=getNthChild(HXML(node),ioLParam,0); - if StrToInt(getAttrValue(sub,ioVariables))=1 then - service.l_flags:=service.l_flags or ACF_FLAG_SCRIPT; - service.l_flags:=service.l_flags or - ReadParam(sub,PWideChar(service.lparam),(service.l_flags and ACF_FLAG_SCRIPT)<>0); - - sub:=getNthChild(HXML(node),ioOutput,0); - if StrToInt(getAttrValue(sub,ioFree))=1 then - service.flags:=service.flags or ACF_FLAG_FREEMEM; - - tmp:=getAttrValue(sub,ioType); - if lstrcmpiw(tmp,ioUnicode)=0 then service.flags:=service.flags or ACF_TYPE_UNICODE - else if lstrcmpiw(tmp,ioAnsi )=0 then service.flags:=service.flags or ACF_TYPE_STRING - else if lstrcmpiw(tmp,ioStruct )=0 then service.flags:=service.flags or ACF_TYPE_STRUCT - else if lstrcmpiw(tmp,ioInt )=0 then service.flags:=service.flags or ACF_TYPE_NUMBER; - end; - end; -{ - 2: begin - StrDup(service,GetParamSectionStr(node,ioService)); -//!!!! UTF8ToWide(GetParamSectionStr(node,ioService),service); - if GetParamSectionInt(node,ioVariables)=1 then - flags:=flags or ACF_SCRIPT_SERVICE; - - if GetParamSectionInt(node,ioWParam+'.'+ioVariables))=1 then - flags:=flags or ACF_SCRIPT_PARAM; - flags:=flags or ReadParamINI(node,ioWParam+'.',wparam,(flags and ACF_SCRIPT_PARAM)<>0); - - if GetParamSectionInt(node,ioLParam+'.'+ioVariables))=1 then - flags2:=flags2 or ACF_SCRIPT_PARAM; - flags2:=flags2 or ReadParamINI(node,ioLParam+'.',lparam,(flags2 and ACF_SCRIPT_PARAM)<>0); - - if GetParamSectionInt(node,ioFree)=1 then flags:=flags or ACF_RFREEMEM; - - pc:=GetParamSectionStr(node,ioType); - if lstrcmpi(pñ,ioUnicode)=0 then flags:=flags or ACF_RUNICODE - else if lstrcmpi(pñ,ioAnsi )=0 then flags:=flags or ACF_RSTRING - else if lstrcmpi(pñ,ioStruct )=0 then flags:=flags or ACF_RSTRUCT -// else if lstrcmpi(pñ,ioInt )=0 then ; + sub:=xmlGetNthChild(HXML(node),ioWParam,0); + if StrToInt(xmlGetAttrValue(sub,ioVariables))=1 then + service.w_flags:=service.w_flags or ACF_FLAG_SCRIPT; + service.w_flags:=service.w_flags or + ReadParam(sub,PWideChar(service.wparam),(service.w_flags and ACF_FLAG_SCRIPT)<>0); + + sub:=xmlGetNthChild(HXML(node),ioLParam,0); + if StrToInt(xmlGetAttrValue(sub,ioVariables))=1 then + service.l_flags:=service.l_flags or ACF_FLAG_SCRIPT; + service.l_flags:=service.l_flags or + ReadParam(sub,PWideChar(service.lparam),(service.l_flags and ACF_FLAG_SCRIPT)<>0); + + sub:=xmlGetNthChild(HXML(node),ioOutput,0); + if StrToInt(xmlGetAttrValue(sub,ioFree))=1 then + service.flags:=service.flags or ACF_FLAG_FREEMEM; + + tmp:=xmlGetAttrValue(sub,ioType); + if lstrcmpiw(tmp,ioUnicode)=0 then service.flags:=service.flags or ACF_TYPE_UNICODE + else if lstrcmpiw(tmp,ioAnsi )=0 then service.flags:=service.flags or ACF_TYPE_STRING + else if lstrcmpiw(tmp,ioStruct )=0 then service.flags:=service.flags or ACF_TYPE_STRUCT + else if lstrcmpiw(tmp,ioInt )=0 then service.flags:=service.flags or ACF_TYPE_NUMBER; end; -} end; end; diff --git a/plugins/Actman/iac_storage.pas b/plugins/Actman/iac_storage.pas index 500d366334..186e88240a 100644 --- a/plugins/Actman/iac_storage.pas +++ b/plugins/Actman/iac_storage.pas @@ -155,12 +155,9 @@ begin end; 1: begin - with xmlparser do - begin - if lstrcmpiw(getAttrValue(HXML(node),ioOper),ioCopy)=1 then - flags:=flags or ACF_COPYFROM; - Number:=StrToInt(getAttrValue(HXML(node),ioNumber)); - end; + if lstrcmpiw(xmlGetAttrValue(HXML(node),ioOper),ioCopy)=1 then + flags:=flags or ACF_COPYFROM; + Number:=StrToInt(xmlGetAttrValue(HXML(node),ioNumber)); end; end; end; diff --git a/plugins/Actman/iac_text.pas b/plugins/Actman/iac_text.pas index 68f9acf7ba..8614d6430e 100644 --- a/plugins/Actman/iac_text.pas +++ b/plugins/Actman/iac_text.pas @@ -361,22 +361,12 @@ begin end; 1: begin - with xmlparser do - begin - StrDupW(text,getText(HXML(node))); - if StrToInt(getAttrValue(HXML(node),ioVariables))=1 then - flags:=flags or ACF_TEXTSCRIPT; - if StrToInt(getAttrValue(HXML(node),ioPost))=1 then - flags:=flags or ACF_POSTPROCESS; - end; - end; -{ - 2: begin - UTF8ToWide(GetParamSectionInt(node,ioText),text); - if GetParamSectionInt(node,ioVariables)=1 then + StrDupW(text,xmlGetText(HXML(node))); + if StrToInt(xmlGetAttrValue(HXML(node),ioVariables))=1 then flags:=flags or ACF_TEXTSCRIPT; + if StrToInt(xmlGetAttrValue(HXML(node),ioPost))=1 then + flags:=flags or ACF_POSTPROCESS; end; -} end; end; diff --git a/plugins/Actman/inoutxml.pas b/plugins/Actman/inoutxml.pas index cd11c1a963..bcf91222bf 100644 --- a/plugins/Actman/inoutxml.pas +++ b/plugins/Actman/inoutxml.pas @@ -31,17 +31,14 @@ var begin result:=nil; if actnode=0 then exit; - with xmlparser do + pa:=GetLinkByName(FastWideToAnsiBuf(xmlGetAttrValue(actnode,ioClass),buf)); + if pa<>nil then begin - pa:=GetLinkByName(FastWideToAnsiBuf(getAttrValue(actnode,ioClass),buf)); - if pa<>nil then - begin - result:=pa.Create; - result.Load(pointer(actnode),1); - end - else - result:=tBaseAction(1); - end; + result:=pa.Create; + result.Load(pointer(actnode),1); + end + else + result:=tBaseAction(1); end; function Import(list:tMacroList;fname:PWideChar;aflags:dword):integer; @@ -76,79 +73,72 @@ begin BlockRead(f,res^,i); CloseHandle(f); -//MessageBoxW(0,res,'SRC',0); - xmlparser.cbSize:=SizeOf(TXML_API_W); - CallService(MS_SYSTEM_GET_XI,0,lparam(@xmlparser)); - with xmlparser do - begin - root:=parseString(ChangeUnicode(res),@i,nil); - nodenum:=0; - impact:=imp_yes; - repeat - actnode:=getNthChild(root,ioAction,nodenum); - if actnode=0 then break; -//?? if StrCmpW(getName(actnode),ioAction)<>0 then break; - tmp:=getAttrValue(actnode,ioName); - if tmp<>nil then //!! + root:=xmlParseString(ChangeUnicode(res),@i,nil); + nodenum:=0; + impact:=imp_yes; + repeat + actnode:=xmlGetNthChild(root,ioAction,nodenum); + if actnode=0 then break; + tmp:=xmlGetAttrValue(actnode,ioName); + if tmp<>nil then //!! + begin + p:=list.GetMacro(tmp); + oldid:=$FFFFFFFF; + if p<>nil then begin - p:=list.GetMacro(tmp); - oldid:=$FFFFFFFF; - if p<>nil then + if (impact<>imp_yesall) and (impact<>imp_noall) then begin - if (impact<>imp_yesall) and (impact<>imp_noall) then - begin - StrCopyW(buf,TranslateW('Action "$" exists, do you want to rewrite it?')); - impact:=ShowQuestion(StrReplaceW(buf,'$',tmp)); - end; - if (impact=imp_yesall) or (impact=imp_yes) then - begin - oldid:=p^.id; - FreeMacro(p); - end; + StrCopyW(buf,TranslateW('Action "$" exists, do you want to rewrite it?')); + impact:=ShowQuestion(StrReplaceW(buf,'$',tmp)); end; - // if new or overwriting then read macro details/actions - if (p=nil) or (impact=imp_yesall) or (impact=imp_yes) or (impact=imp_append) then + if (impact=imp_yesall) or (impact=imp_yes) then begin - with List[list.NewMacro()]^ do + oldid:=p^.id; + FreeMacro(p); + end; + end; + // if new or overwriting then read macro details/actions + if (p=nil) or (impact=imp_yesall) or (impact=imp_yes) or (impact=imp_append) then + begin + with List[list.NewMacro()]^ do + begin + if (p<>nil) and (oldid<>$FFFFFFFF) then // set old id to keep UseAction setting begin - if (p<>nil) and (oldid<>$FFFFFFFF) then // set old id to keep UseAction setting - begin - flags:=flags or ACF_IMPORT or ACF_OVERLOAD; - id:=oldid; - end - else - flags:=flags or ACF_IMPORT; - if StrToInt(getAttrValue(actnode,ioVolatile))=1 then flags:=flags or ACF_VOLATILE; - StrCopyW(descr,tmp,MacroNameLen-1); + flags:=flags or ACF_IMPORT or ACF_OVERLOAD; + id:=oldid; + end + else + flags:=flags or ACF_IMPORT; + if StrToInt(xmlGetAttrValue(actnode,ioVolatile))=1 then flags:=flags or ACF_VOLATILE; + StrCopyW(descr,tmp,MacroNameLen-1); - // reading actions - actcnt:=0; // count in file - ActionCount:=0; // amount of loaded - repeat - act:=ImportAction(getChild(actnode,actcnt)); - if act=nil then - break; - if uint_ptr(act)<>1 then - begin - arr[ActionCount]:=act; - inc(ActionCount); - end; - inc(actcnt); - until false; - // moving actions to their place - if Actioncount>0 then + // reading actions + actcnt:=0; // count in file + ActionCount:=0; // amount of loaded + repeat + act:=ImportAction(xmlGetChild(actnode,actcnt)); + if act=nil then + break; + if uint_ptr(act)<>1 then begin - GetMem(ActionList,SizeOf(tBaseAction)*ActionCount); - move(arr,ActionList^,SizeOf(tBaseAction)*ActionCount); + arr[ActionCount]:=act; + inc(ActionCount); end; - inc(result); + inc(actcnt); + until false; + // moving actions to their place + if Actioncount>0 then + begin + GetMem(ActionList,SizeOf(tBaseAction)*ActionCount); + move(arr,ActionList^,SizeOf(tBaseAction)*ActionCount); end; + inc(result); end; end; - inc(nodenum); - until false; - destroyNode(root); - end; + end; + inc(nodenum); + until false; + xmlDestroyNode(root); mFreeMem(res); end; diff --git a/plugins/Actman/ua/i_inoutjson.inc b/plugins/Actman/ua/i_inoutjson.inc index b560e99fb1..95f793e9f2 100644 --- a/plugins/Actman/ua/i_inoutjson.inc +++ b/plugins/Actman/ua/i_inoutjson.inc @@ -342,7 +342,7 @@ begin f:=Rewrite(fname); BlockWrite(f,res^,i*SizeOf(WideChar)); CloseHandle(f); - xmlparser.FreeMem(res); + FreeMem(res); DestroyNode(root); end; result:=1; diff --git a/plugins/Actman/ua/i_inoutxm.inc b/plugins/Actman/ua/i_inoutxm.inc index bf53ff954a..4a539a8275 100644 --- a/plugins/Actman/ua/i_inoutxm.inc +++ b/plugins/Actman/ua/i_inoutxm.inc @@ -1,6 +1,4 @@ {} -var - xmlparser:TXML_API_W; const ioAction :PWideChar = 'Action'; @@ -32,27 +30,24 @@ function ImportMenuItems(node:HXML;var MenuItem:tUAMenuItem):integer; begin result:=0; - with xmlparser do + with MenuItem do begin - with MenuItem do - begin - menu_opt:=0; - // popup - StrDupW(szMenuPopup,getAttrValue(node,ioMenuPopup)); - // name - StrDupW(szMenuNameVars,getAttrValue(node,ioMenuName)); - // show - StrDupW(szMenuShowWhenVars,getAttrValue(node,ioMenuShow)); - // used - if StrToInt(getAttrValue(node,ioMenuUsed))<>0 then - menu_opt:=menu_opt or UAF_MENUUSE; - // separated - if StrToInt(getAttrValue(node,ioMenuSeparated))<>0 then - menu_opt:=menu_opt or UAF_MENUSEP; - // no translate - if StrToInt(getAttrValue(node,ioNoTranslate))<>0 then - menu_opt:=menu_opt or UAF_NOTRANS; - end; + menu_opt:=0; + // popup + StrDupW(szMenuPopup,xmlGetAttrValue(node,ioMenuPopup)); + // name + StrDupW(szMenuNameVars,xmlGetAttrValue(node,ioMenuName)); + // show + StrDupW(szMenuShowWhenVars,xmlGetAttrValue(node,ioMenuShow)); + // used + if StrToInt(xmlGetAttrValue(node,ioMenuUsed))<>0 then + menu_opt:=menu_opt or UAF_MENUUSE; + // separated + if StrToInt(xmlGetAttrValue(node,ioMenuSeparated))<>0 then + menu_opt:=menu_opt or UAF_MENUSEP; + // no translate + if StrToInt(xmlGetAttrValue(node,ioNoTranslate))<>0 then + menu_opt:=menu_opt or UAF_NOTRANS; end; end; @@ -64,52 +59,44 @@ begin result:=0; if actnode=0 then exit; - with xmlparser do - begin - // we don't need that node as is, just it's child for UA -// actnode:=GetNthChild(actnode,ioUA,0); - - UA.flags:=0; - // ----- Common ----- - if StrToInt(getAttrValue(actnode,ioTwoState))<>0 then - UA.flags:=UA.flags or UAF_2STATE; - - if StrToInt(getAttrValue(actnode,ioSaveState))<>0 then - UA.flags:=UA.flags or UAF_SAVESTATE; - - // sub:=AddChild(actnode,ioRegister,nil); - if StrToInt(getAttrValue(actnode,ioHotkey))<>0 then - UA.flags:=UA.flags or UAF_REGHOTKEY; - if StrToInt(getAttrValue(actnode,ioToolbar))<>0 then - UA.flags:=UA.flags or UAF_REGTTBB; - if StrToInt(getAttrValue(actnode,ioTabSRMM))<>0 then - UA.flags:=UA.flags or UAF_REGTABB; - - // ----- Hotkey ----- - // nothing - - // ----- Modern CList toolbar ----- - // source - ANSI text - sub:=GetNthChild(actnode,ioToolbar,0); - WideToAnsi(GetAttrValue(sub,ioTooltip ),UA.szTTBTooltip ,MirandaCP); - WideToAnsi(GetAttrValue(sub,ioTooltipPressed),UA.szTTBTooltipPressed,MirandaCP); - - // ----- TabSRMM toolbar ----- - sub:=GetNthChild(actnode,ioTabSRMM,0); - StrDupW(UA.szTabBTooltip ,getAttrValue(sub,ioTooltip)); - StrDupW(UA.szTabBTooltipPressed,getAttrValue(sub,ioTooltipPressed)); - - // ----- Menus ----- - num:=0; - repeat - sub:=getNextChild(actnode,ioMenuItem,@num); - if sub=0 then break; - - i:=StrToInt(getAttrValue(sub,ioType)); - ImportMenuItems(sub, - UA.UAMenuItem[tMenuType(i)]); - until false; - end; + UA.flags:=0; + // ----- Common ----- + if StrToInt(xmlGetAttrValue(actnode,ioTwoState))<>0 then + UA.flags:=UA.flags or UAF_2STATE; + + if StrToInt(xmlGetAttrValue(actnode,ioSaveState))<>0 then + UA.flags:=UA.flags or UAF_SAVESTATE; + + if StrToInt(xmlGetAttrValue(actnode,ioHotkey))<>0 then + UA.flags:=UA.flags or UAF_REGHOTKEY; + if StrToInt(xmlGetAttrValue(actnode,ioToolbar))<>0 then + UA.flags:=UA.flags or UAF_REGTTBB; + if StrToInt(xmlGetAttrValue(actnode,ioTabSRMM))<>0 then + UA.flags:=UA.flags or UAF_REGTABB; + + // ----- Hotkey ----- + // nothing + + // ----- Modern CList toolbar ----- + // source - ANSI text + sub:=xmlGetNthChild(actnode,ioToolbar,0); + WideToAnsi(xmlGetAttrValue(sub,ioTooltip ),UA.szTTBTooltip ,MirandaCP); + WideToAnsi(xmlGetAttrValue(sub,ioTooltipPressed),UA.szTTBTooltipPressed,MirandaCP); + + // ----- TabSRMM toolbar ----- + sub:=xmlGetNthChild(actnode,ioTabSRMM,0); + StrDupW(UA.szTabBTooltip ,xmlGetAttrValue(sub,ioTooltip)); + StrDupW(UA.szTabBTooltipPressed,xmlGetAttrValue(sub,ioTooltipPressed)); + + // ----- Menus ----- + num:=0; + repeat + sub:=xmlGetNextChild(actnode,ioMenuItem,@num); + if sub=0 then break; + + i:=StrToInt(xmlGetAttrValue(sub,ioType)); + ImportMenuItems(sub,UA.UAMenuItem[tMenuType(i)]); + until false; end; function Import(fname:PWideChar;aflags:dword):integer; @@ -139,50 +126,45 @@ begin BlockRead(f,res^,i); CloseHandle(f); - xmlparser.cbSize:={XML_API_SIZEOF_V1;//}SizeOf(TXML_API_W); - CallService(MS_SYSTEM_GET_XI,0,lparam(@xmlparser)); - with xmlparser do - begin - root:=parseString(ChangeUnicode(res),@i,nil); - j:=0; - repeat - actnode:=getNthChild(root,ioAction,j); - if actnode=0 then break; - // search id by name? - pcw:=GetAttrValue(actnode,ioName); - ptr:=ptr1; - inc(pbyte(ptr),4); - for i:=0 to num-1 do + root:=xmlParseString(ChangeUnicode(res),@i,nil); + j:=0; + repeat + actnode:=xmlGetNthChild(root,ioAction,j); + if actnode=0 then break; + // search id by name? + pcw:=xmlGetAttrValue(actnode,ioName); + ptr:=ptr1; + inc(pbyte(ptr),4); + for i:=0 to num-1 do + begin + if (ptr.flags and ACF_SELECTED)<>0 then begin - if (ptr.flags and ACF_SELECTED)<>0 then + if StrCmpw(pcw,ptr.descr)=0 then begin - if StrCmpw(pcw,ptr.descr)=0 then + // delete old UA for overwrited actions + if (ptr.flags and ACF_OVERLOAD)<>0 then begin - // delete old UA for overwrited actions - if (ptr.flags and ACF_OVERLOAD)<>0 then + for act:=0 to HIGH(UActionList) do begin - for act:=0 to HIGH(UActionList) do + if ptr.id=UActionList[act].dwActID then begin - if ptr.id=UActionList[act].dwActID then - begin - DeleteUAction(act,true); - break; - end; + DeleteUAction(act,true); + break; end; end; - num1:=AddUAction(-1,ptr); - ImportUAction(getNthChild(actnode,ioUA,0),UActionList[num1]); - break; end; + num1:=AddUAction(-1,ptr); + ImportUAction(xmlGetNthChild(actnode,ioUA,0),UActionList[num1]); + break; end; - inc(ptr); end; - - inc(j); - until false; + inc(ptr); + end; + + inc(j); + until false; + xmlDestroyNode(root); - DestroyNode(root); - end; CallService(MS_ACT_FREELIST,0,LPARAM(ptr1)); mFreeMem(res); result:=1; @@ -197,27 +179,24 @@ end; function ExportMenuItems(node:HXML;const MenuItem:tUAMenuItem):HXML; begin - with xmlparser do + result:=xmlAddChild(node,ioMenuItem,nil); + with MenuItem do begin - result:=AddChild(node,ioMenuItem,nil); - with MenuItem do - begin - // popup - if (szMenuPopup<>nil) and (szMenuPopup^<>#0) then - AddAttr(result,ioMenuPopup,szMenuPopup); - // name - if (szMenuNameVars<>nil) and (szMenuNameVars^<>#0) then - AddAttr(result,ioMenuName,szMenuNameVars); - // show - if (szMenuShowWhenVars<>nil) and (szMenuShowWhenVars^<>#0) then - AddAttr(result,ioMenuShow,szMenuShowWhenVars); - // used - AddAttrInt(result,ioMenuUsed,ord((menu_opt AND UAF_MENUUSE)<>0)); - // separated - AddAttrInt(result,ioMenuSeparated,ord((menu_opt AND UAF_MENUSEP)<>0)); - // no translate - AddAttrInt(result,ioNoTranslate,ord((menu_opt AND UAF_NOTRANS)<>0)); - end; + // popup + if (szMenuPopup<>nil) and (szMenuPopup^<>#0) then + xmlAddAttr(result,ioMenuPopup,szMenuPopup); + // name + if (szMenuNameVars<>nil) and (szMenuNameVars^<>#0) then + xmlAddAttr(result,ioMenuName,szMenuNameVars); + // show + if (szMenuShowWhenVars<>nil) and (szMenuShowWhenVars^<>#0) then + xmlAddAttr(result,ioMenuShow,szMenuShowWhenVars); + // used + xmlAddAttrInt(result,ioMenuUsed,ord((menu_opt AND UAF_MENUUSE)<>0)); + // separated + xmlAddAttrInt(result,ioMenuSeparated,ord((menu_opt AND UAF_MENUSEP)<>0)); + // no translate + xmlAddAttrInt(result,ioNoTranslate,ord((menu_opt AND UAF_NOTRANS)<>0)); end; end; @@ -229,70 +208,66 @@ var actnode,sub:HXML; UA:pMyActionItem; begin - with xmlparser do + for i:=0 to HIGH(UActionList) do begin - for i:=0 to HIGH(UActionList) do + if UActionList[i].dwActID=id then begin - if UActionList[i].dwActID=id then + UA:=@UActionList[i]; + actnode:=xmlGetChildByAttrValue(root,ioAction,ioName,name); + if actnode=0 then break; + // we don't need that node as is, just it's child for UA + actnode:=xmlAddChild(actnode,ioUA,nil); + + // ----- Common ----- + xmlAddAttrInt(actnode,ioTwoState ,ORD((UA.flags and UAF_2STATE )<>0)); + xmlAddAttrInt(actnode,ioSaveState,ORD((UA.flags and UAF_SAVESTATE)<>0)); + + xmlAddAttrInt(actnode,ioHotkey ,ORD((UA.flags and UAF_REGHOTKEY)<>0)); + xmlAddAttrInt(actnode,ioToolbar,ORD((UA.flags and UAF_REGTTBB )<>0)); + xmlAddAttrInt(actnode,ioTabSRMM,ORD((UA.flags and UAF_REGTABB )<>0)); + + // ----- Hotkey ----- + // nothing + + // ----- Modern CList toolbar ----- + // source - ANSI text + if ((UA.szTTBTooltip <>nil) and (UA.szTTBTooltip^ <>#0)) or + ((UA.szTTBTooltipPressed<>nil) and (UA.szTTBTooltipPressed^<>#0)) then begin - UA:=@UActionList[i]; - actnode:=getChildByAttrValue(root,ioAction,ioName,name); - if actnode=0 then break; - // we don't need that node as is, just it's child for UA - actnode:=addChild(actnode,ioUA,nil); - - // ----- Common ----- - AddAttrInt(actnode,ioTwoState ,ORD((UA.flags and UAF_2STATE )<>0)); - AddAttrInt(actnode,ioSaveState,ORD((UA.flags and UAF_SAVESTATE)<>0)); - - // sub:=AddChild(actnode,ioRegister,nil); - AddAttrInt(actnode,ioHotkey ,ORD((UA.flags and UAF_REGHOTKEY)<>0)); - AddAttrInt(actnode,ioToolbar,ORD((UA.flags and UAF_REGTTBB )<>0)); - AddAttrInt(actnode,ioTabSRMM,ORD((UA.flags and UAF_REGTABB )<>0)); - - // ----- Hotkey ----- - // nothing - - // ----- Modern CList toolbar ----- - // source - ANSI text - if ((UA.szTTBTooltip <>nil) and (UA.szTTBTooltip^ <>#0)) or - ((UA.szTTBTooltipPressed<>nil) and (UA.szTTBTooltipPressed^<>#0)) then + sub:=xmlAddChild(actnode,ioToolbar,nil); + if (UA.szTTBTooltip<>nil) and (UA.szTTBTooltip^<>#0) then begin - sub:=AddChild(actnode,ioToolbar,nil); - if (UA.szTTBTooltip<>nil) and (UA.szTTBTooltip^<>#0) then - begin - AnsiToWide(UA.szTTBTooltip,pc,MirandaCP); - AddAttr(sub,ioTooltip,pc); - mFreeMem(pc); - end; - if (UA.szTTBTooltipPressed<>nil) and (UA.szTTBTooltipPressed^<>#0) then - begin - AnsiToWide(UA.szTTBTooltipPressed,pc,MirandaCP); - AddAttr(sub,ioTooltipPressed,pc); - mFreeMem(pc); - end; + AnsiToWide(UA.szTTBTooltip,pc,MirandaCP); + xmlAddAttr(sub,ioTooltip,pc); + mFreeMem(pc); end; - - // ----- TabSRMM toolbar ----- - if ((UA.szTabBTooltip <>nil) and (UA.szTabBTooltip^ <>#0)) or - ((UA.szTabBTooltipPressed<>nil) and (UA.szTabBTooltipPressed^<>#0)) then + if (UA.szTTBTooltipPressed<>nil) and (UA.szTTBTooltipPressed^<>#0) then begin - sub:=AddChild(actnode,ioTabSRMM,nil); - if (UA.szTabBTooltip<>nil) and (UA.szTabBTooltip^<>#0) then - AddAttr(sub,ioTooltip,UA.szTabBTooltip); - if (UA.szTabBTooltipPressed<>nil) and (UA.szTabBTooltipPressed^<>#0) then - AddAttr(sub,ioTooltipPressed,UA.szTabBTooltipPressed); + AnsiToWide(UA.szTTBTooltipPressed,pc,MirandaCP); + xmlAddAttr(sub,ioTooltipPressed,pc); + mFreeMem(pc); end; + end; - // ----- Menus ----- - for lmenu:=main_menu to HIGH(tMenuType) do - begin - sub:=ExportMenuItems(actnode,UA.UAMenuItem[lmenu]); - AddAttrInt(sub,ioType,ORD(lmenu)); - end; + // ----- TabSRMM toolbar ----- + if ((UA.szTabBTooltip <>nil) and (UA.szTabBTooltip^ <>#0)) or + ((UA.szTabBTooltipPressed<>nil) and (UA.szTabBTooltipPressed^<>#0)) then + begin + sub:=xmlAddChild(actnode,ioTabSRMM,nil); + if (UA.szTabBTooltip<>nil) and (UA.szTabBTooltip^<>#0) then + xmlAddAttr(sub,ioTooltip,UA.szTabBTooltip); + if (UA.szTabBTooltipPressed<>nil) and (UA.szTabBTooltipPressed^<>#0) then + xmlAddAttr(sub,ioTooltipPressed,UA.szTabBTooltipPressed); + end; - break; + // ----- Menus ----- + for lmenu:=main_menu to HIGH(tMenuType) do + begin + sub:=ExportMenuItems(actnode,UA.UAMenuItem[lmenu]); + xmlAddAttrInt(sub,ioType,ORD(lmenu)); end; + + break; end; end; end; @@ -306,47 +281,43 @@ var ptr,ptr1:pChain; begin result:=0; - xmlparser.cbSize:={XML_API_SIZEOF_V1;//}SizeOf(TXML_API_W); - CallService(MS_SYSTEM_GET_XI,0,lparam(@xmlparser)); - with xmlparser do + + // we need append file, not rewrite + i:=GetFSize(fname); + if i=0 then exit; + + mGetMem (res ,i+SizeOf(WideChar)); + FillChar(res^,i+SizeOf(WideChar),0); + f:=Reset(fname); + BlockRead(f,res^,i); + CloseHandle(f); + root:=xmlParseString(res,@i,nil); + mFreeMem(res); + + num:=CallService(MS_ACT_GETLIST,0,LPARAM(@ptr)); + if num>0 then begin - // we need append file, not rewrite - i:=GetFSize(fname); - if i=0 then exit; - - mGetMem (res ,i+SizeOf(WideChar)); - FillChar(res^,i+SizeOf(WideChar),0); - f:=Reset(fname); - BlockRead(f,res^,i); - CloseHandle(f); - root:=parseString(res,@i,nil); - mFreeMem(res); - - num:=CallService(MS_ACT_GETLIST,0,LPARAM(@ptr)); - if num>0 then + ptr1:=ptr; + inc(pbyte(ptr),4); + for i:=0 to num-1 do begin - ptr1:=ptr; - inc(pbyte(ptr),4); - for i:=0 to num-1 do + if ((aflags and ACIO_SELECTED)=0) or + ((ptr.flags and ACCF_EXPORT)<>0) then begin - if ((aflags and ACIO_SELECTED)=0) or - ((ptr.flags and ACCF_EXPORT)<>0) then - begin - WriteUAction(root,ptr.id,ptr.descr); - end; - inc(ptr); + WriteUAction(root,ptr.id,ptr.descr); end; - CallService(MS_ACT_FREELIST,0,LPARAM(ptr1)); + inc(ptr); end; + CallService(MS_ACT_FREELIST,0,LPARAM(ptr1)); + end; - res:=toString(root,@i); + res:=xmlToString(root,@i); - f:=Rewrite(fname); - BlockWrite(f,res^,i*SizeOf(WideChar)); - CloseHandle(f); - xmlparser.FreeMem(res); - DestroyNode(root); - end; + f:=Rewrite(fname); + BlockWrite(f,res^,i*SizeOf(WideChar)); + CloseHandle(f); + xmlFree(res); + xmlDestroyNode(root); result:=1; end; diff --git a/plugins/ImportTXT/BICQ5IP.inc b/plugins/ImportTXT/BICQ5IP.inc index 9f9a2e3f3c..1df28964b0 100644 --- a/plugins/ImportTXT/BICQ5IP.inc +++ b/plugins/ImportTXT/BICQ5IP.inc @@ -1,7 +1,6 @@ {$IFDEF BIN_IMPORT_} var - XI: TXML_API_W; rhxml: HXML; curxml: HXML; chldxml: HXML; @@ -13,28 +12,6 @@ var {$ELSE} begin - If ServiceExists(MS_SYSTEM_GET_XI) > 0 then - begin - XI.cbSize := SizeOf(TXML_API_W); - res := LongBool(CallService(MS_SYSTEM_GET_XI, 0, int(@XI))); - if not res then - begin - XI.cbSize := SizeOf(TXML_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, 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, 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; @@ -47,40 +24,40 @@ begin try ptxt := UTF8toWide(pFileText, ptxt, SizeOf(WideChar) * FileLen + 2); ptxt[FileLen + 1] := #0000; - rhxml := XI.parseString(ptxt, @txtlen, 'root'); + rhxml := xmlparseString(ptxt, @txtlen, 'root'); finally 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 + DoMessage(ITXT_THREAD_MAXPROGRESS, 0, xmlgetChildCount(rhxml)); + chldxml := xmlgetFirstChild(rhxml); + if xmlgetName(chldxml) = 'version' then begin ic := 0; - curxml := XI.getNextChild(rhxml, 'event', @ic); + curxml := xmlgetNextChild(rhxml, 'event', @ic); while (curxml <> 0) do begin fillchar(dbei, SizeOf(dbei), 0); dbei.cbSize := SizeOf(dbei); dbei.szModule := PAnsiChar(proto); - if TryStrToInt(XI.getText(XI.getChildByPath(curxml, 'time', false)), tm) + if TryStrToInt(xmlgetText(xmlgetChildByPath(curxml, 'time', false)), tm) then dbei.timestamp := tm; - if XI.getText(XI.getChildByPath(curxml, 'incoming', false)) = 'Yes' then + if xmlgetText(xmlgetChildByPath(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 + if xmlgetText(xmlgetChildByPath(curxml, 'type', false))^ = '2' then begin - s := XI.getText(XI.getChildByPath(curxml, 'text', false)) + ': ' + - XI.getText(XI.getChildByPath(curxml, 'data', false)); + s := xmlgetText(xmlgetChildByPath(curxml, 'text', false)) + ': ' + + xmlgetText(xmlgetChildByPath(curxml, 'data', false)); dbei.eventType := EVENTTYPE_URL; end else begin - s := XI.getText(XI.getChildByPath(curxml, 'text', false)); + s := xmlgetText(xmlgetChildByPath(curxml, 'text', false)); dbei.eventType := EVENTTYPE_MESSAGE; end; try @@ -102,7 +79,7 @@ begin finally freemem(tempstr); - curxml := XI.getNextChild(rhxml, 'event', @ic); + curxml := xmlgetNextChild(rhxml, 'event', @ic); DoMessage(ITXT_THREAD_PROGRESS, ic, 0); end; end; diff --git a/plugins/New_GPG/src/init.cpp b/plugins/New_GPG/src/init.cpp index 7e06f1040c..9cb03cc152 100644 --- a/plugins/New_GPG/src/init.cpp +++ b/plugins/New_GPG/src/init.cpp @@ -27,7 +27,7 @@ HFONT bold_font = NULL; HANDLE hLoadPubKey = NULL, g_hCLIcon = NULL, hExportGpgKeys = NULL, hImportGpgKeys = NULL; HGENMENU hSendKey = NULL, hToggleEncryption = NULL; RECT key_from_keyserver_rect = {0}, firstrun_rect = {0}, new_key_rect = {0}, key_gen_rect = {0}, load_key_rect = {0}, import_key_rect = {0}, key_password_rect = {0}, load_existing_key_rect = {0}; -XML_API xi = {0}; + int hLangpack = 0; logtofile debuglog; bool gpg_valid = false, gpg_keyexist = false; @@ -168,7 +168,6 @@ static int OnModulesLoaded(WPARAM wParam,LPARAM lParam) extern "C" int __declspec(dllexport) Load() { HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); - mir_getXI(&xi); //TODO: check if we have access to api mir_getLP(&pluginInfo); init_vars(); CreateServiceFunction("/LoadPubKey",LoadKey); diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index 711fbadf95..df16fde641 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -706,11 +706,11 @@ int GetJabberInterface(WPARAM w, LPARAM l) //get interface for all jabber accoun static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pUserData) { HXML local_node = node; - for(int n = 0; n <= xi.getChildCount(node); n++) + for(int n = 0; n <= xmlGetChildCount(node); n++) { - LPCTSTR str = xi.getText(local_node); - LPCTSTR nodename = xi.getName(local_node); - LPCTSTR attr = xi.getAttrValue(local_node, _T("to")); + LPCTSTR str = xmlGetText(local_node); + LPCTSTR nodename = xmlGetName(local_node); + LPCTSTR attr = xmlGetAttrValue(local_node, _T("to")); if(attr) { MCONTACT hContact = ji->ContactFromJID(attr); @@ -723,7 +723,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU if(_tcsstr(str, _T("-----BEGIN PGP MESSAGE-----")) && _tcsstr(str, _T("-----END PGP MESSAGE-----"))) { wstring data = str; - xi.setText(local_node, _T("This message is encrypted.")); + xmlSetText(local_node, _T("This message is encrypted.")); wstring::size_type p1 = data.find(_T("-----BEGIN PGP MESSAGE-----")) + mir_tstrlen(_T("-----BEGIN PGP MESSAGE-----")); while(data.find(_T("Version: "), p1) != wstring::npos) { @@ -744,8 +744,8 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU wstring::size_type p2 = data.find(_T("-----END PGP MESSAGE-----")); wstring data2 = data.substr(p1, p2-p1-2); strip_line_term(data2); - HXML encrypted_data = xi.addChild(node, _T("x"), data2.c_str()); - xi.addAttr(encrypted_data, _T("xmlns"), _T("jabber:x:encrypted")); + HXML encrypted_data = xmlAddChild(node, _T("x"), data2.c_str()); + xmlAddAttr(encrypted_data, _T("xmlns"), _T("jabber:x:encrypted")); return FALSE; } } @@ -892,15 +892,15 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU { std::wstring tmp = data.substr(p1, p2-p1); strip_line_term(tmp); - HXML encrypted_data = xi.addChild(node, _T("x"), tmp.c_str()); - xi.addAttr(encrypted_data, _T("xmlns"), _T("jabber:x:signed")); + HXML encrypted_data = xmlAddChild(node, _T("x"), tmp.c_str()); + xmlAddAttr(encrypted_data, _T("xmlns"), _T("jabber:x:signed")); } } return FALSE; } } } - local_node = xi.getChild(node, n); + local_node = xmlGetChild(node, n); } return FALSE; } @@ -910,35 +910,35 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU static JABBER_HANDLER_FUNC PrescenseHandler(IJabberInterface *ji, HXML node, void *pUserData) { HXML local_node = node; - for(int n = 0; n <= xi.getChildCount(node); n++) + for(int n = 0; n <= xmlGetChildCount(node); n++) { - LPCTSTR str = xi.getText(local_node); - LPCTSTR nodename = xi.getName(local_node); + LPCTSTR str = xmlGetText(local_node); + LPCTSTR nodename = xmlGetName(local_node); if(nodename) { if(_tcsstr(nodename, _T("x"))) { - for(int n = 0; n < xi.getAttrCount(local_node); n++) + for(int n = 0; n < xmlGetAttrCount(local_node); n++) { - LPCTSTR name = xi.getAttrName(local_node, n); - LPCTSTR value = xi.getAttrValue(local_node, name); + LPCTSTR name = xmlGetAttrName(local_node, n); + LPCTSTR value = xmlGetAttrValue(local_node, name); if(_tcsstr(value, _T("jabber:x:signed"))) { std::wstring status_str; HXML local_node2 = node; - for(int n = 0; n <= xi.getChildCount(node); n++) + for(int n = 0; n <= xmlGetChildCount(node); n++) { - LPCTSTR nodename2 = xi.getName(local_node2); + LPCTSTR nodename2 = xmlGetName(local_node2); if(_tcsstr(nodename2, _T("status"))) { - LPCTSTR status = xi.getText(local_node2); + LPCTSTR status = xmlGetText(local_node2); if(status) status_str = status; break; } - local_node2 = xi.getChild(node, n); + local_node2 = xmlGetChild(node, n); } - LPCTSTR data = xi.getText(local_node); + LPCTSTR data = xmlGetText(local_node); wstring sign = _T("-----BEGIN PGP SIGNATURE-----\n\n"); wstring file = toUTF16(get_random(10)), status_file = toUTF16(get_random(10)); sign += data; @@ -1010,7 +1010,7 @@ static JABBER_HANDLER_FUNC PrescenseHandler(IJabberInterface *ji, HXML node, voi { if(!(*p)) break; - hContact = (*p)->getJabberInterface()->ContactFromJID(xi.getAttrValue(node, _T("from"))); + hContact = (*p)->getJabberInterface()->ContactFromJID(xmlGetAttrValue(node, _T("from"))); if(hContact) hcontact_data[hContact].key_in_prescense = out.substr(p1, p2-p1-1).c_str(); } @@ -1023,7 +1023,7 @@ static JABBER_HANDLER_FUNC PrescenseHandler(IJabberInterface *ji, HXML node, voi } } } - local_node = xi.getChild(node, n); + local_node = xmlGetChild(node, n); } return FALSE; } diff --git a/plugins/NewsAggregator/Src/CheckFeed.cpp b/plugins/NewsAggregator/Src/CheckFeed.cpp index 9e156a3162..3ea2a0f3d9 100644 --- a/plugins/NewsAggregator/Src/CheckFeed.cpp +++ b/plugins/NewsAggregator/Src/CheckFeed.cpp @@ -19,7 +19,7 @@ Boston, MA 02111-1307, USA. #include "common.h" -TCHAR* CheckFeed(TCHAR *tszURL, HWND hwndDlg) +LPCTSTR CheckFeed(TCHAR *tszURL, HWND hwndDlg) { Netlib_LogfT(hNetlibUser, _T("Started validating feed %s."), tszURL); char *szData = NULL; @@ -29,47 +29,45 @@ TCHAR* CheckFeed(TCHAR *tszURL, HWND hwndDlg) if (!tszData) tszData = mir_a2t(szData); int bytesParsed = 0; - HXML hXml = xi.parseString(tszData, &bytesParsed, NULL); + HXML hXml = xmlParseString(tszData, &bytesParsed, NULL); mir_free(tszData); mir_free(szData); if (hXml != NULL) { int childcount = 0; HXML node; - if (!mir_tstrcmpi(xi.getName(hXml), _T("xml"))) - node = xi.getChild(hXml, childcount); + if (!mir_tstrcmpi(xmlGetName(hXml), _T("xml"))) + node = xmlGetChild(hXml, childcount); else node = hXml; while (node) { - LPCTSTR szNodeName = xi.getName(node); + LPCTSTR szNodeName = xmlGetName(node); if (!mir_tstrcmpi(szNodeName, _T("rss")) || !mir_tstrcmpi(szNodeName, _T("rdf"))) { - HXML chan = xi.getChild(node, 0); - for (int j = 0; j < xi.getChildCount(chan); j++) { - HXML child = xi.getChild(chan, j); - if (!mir_tstrcmpi(xi.getName(child), _T("title"))) { + HXML chan = xmlGetChild(node, 0); + for (int j = 0; j < xmlGetChildCount(chan); j++) { + HXML child = xmlGetChild(chan, j); + if (!mir_tstrcmpi(xmlGetName(child), _T("title"))) { TCHAR mes[MAX_PATH]; mir_sntprintf(mes, _countof(mes), TranslateT("%s\nis a valid feed's address."), tszURL); MessageBox(hwndDlg, mes, TranslateT("News Aggregator"), MB_OK | MB_ICONINFORMATION); - TCHAR *tszTitle = (TCHAR *)xi.getText(child); - return tszTitle; + return xmlGetText(child); } } } else if (!mir_tstrcmpi(szNodeName, _T("feed"))) { - for (int j = 0; j < xi.getChildCount(node); j++) { - HXML child = xi.getChild(node, j); - if (!mir_tstrcmpi(xi.getName(child), _T("title"))) { + for (int j = 0; j < xmlGetChildCount(node); j++) { + HXML child = xmlGetChild(node, j); + if (!mir_tstrcmpi(xmlGetName(child), _T("title"))) { TCHAR mes[MAX_PATH]; mir_sntprintf(mes, _countof(mes), TranslateT("%s\nis a valid feed's address."), tszURL); MessageBox(hwndDlg, mes, TranslateT("News Aggregator"), MB_OK | MB_ICONINFORMATION); - TCHAR *tszTitle = (TCHAR *)xi.getText(child); - return tszTitle; + return xmlGetText(child); } } } - node = xi.getChild(hXml, ++childcount); + node = xmlGetChild(hXml, ++childcount); } } - xi.destroyNode(hXml); + xmlDestroyNode(hXml); } Netlib_LogfT(hNetlibUser, _T("%s is not a valid feed's address."), tszURL); TCHAR mes[MAX_PATH]; @@ -178,7 +176,7 @@ void CheckCurrentFeed(MCONTACT hContact) if (!tszData) tszData = mir_a2t(szData); int bytesParsed = 0; - HXML hXml = xi.parseString(tszData, &bytesParsed, NULL); + HXML hXml = xmlParseString(tszData, &bytesParsed, NULL); mir_free(tszData); mir_free(szData); @@ -186,20 +184,20 @@ void CheckCurrentFeed(MCONTACT hContact) if (hXml != NULL) { int childcount = 0; HXML node; - if (!mir_tstrcmpi(xi.getName(hXml), _T("xml"))) - node = xi.getChild(hXml, childcount); + if (!mir_tstrcmpi(xmlGetName(hXml), _T("xml"))) + node = xmlGetChild(hXml, childcount); else node = hXml; while (node) { - LPCTSTR szNodeName = xi.getName(node); + LPCTSTR szNodeName = xmlGetName(node); bool isRSS = !mir_tstrcmpi(szNodeName, _T("rss")), isAtom = !mir_tstrcmpi(szNodeName, _T("rdf")); if (isRSS || isAtom) { if (isRSS) { - for (int i = 0; i < xi.getAttrCount(node); i++) { - LPCTSTR szAttrName = xi.getAttrName(node, i); + for (int i = 0; i < xmlGetAttrCount(node); i++) { + LPCTSTR szAttrName = xmlGetAttrName(node, i); if (!mir_tstrcmpi(szAttrName, _T("version"))) { TCHAR ver[MAX_PATH]; - mir_sntprintf(ver, _countof(ver), _T("RSS %s"), xi.getAttrValue(node, szAttrName)); + mir_sntprintf(ver, _countof(ver), _T("RSS %s"), xmlGetAttrValue(node, szAttrName)); db_set_ts(hContact, MODULE, "MirVer", ver); break; } @@ -208,22 +206,22 @@ void CheckCurrentFeed(MCONTACT hContact) else if (isAtom) db_set_ts(hContact, MODULE, "MirVer", _T("RSS 1.0")); - HXML chan = xi.getChild(node, 0); - for (int j = 0; j < xi.getChildCount(chan); j++) { - HXML child = xi.getChild(chan, j); - LPCTSTR childName = xi.getName(child); + HXML chan = xmlGetChild(node, 0); + for (int j = 0; j < xmlGetChildCount(chan); j++) { + HXML child = xmlGetChild(chan, j); + LPCTSTR childName = xmlGetName(child); if (!mir_tstrcmpi(childName, _T("title"))) { - LPCTSTR szChildText = xi.getText(child); + LPCTSTR szChildText = xmlGetText(child); if (szChildText) db_set_ts(hContact, MODULE, "FirstName", ClearText(szValue, szChildText)); } else if (!mir_tstrcmpi(childName, _T("link"))) { - LPCTSTR szChildText = xi.getText(child); + LPCTSTR szChildText = xmlGetText(child); if (szChildText) db_set_ts(hContact, MODULE, "Homepage", ClearText(szValue, szChildText)); } else if (!mir_tstrcmpi(childName, _T("description"))) { - LPCTSTR szChildText = xi.getText(child); + LPCTSTR szChildText = xmlGetText(child); if (szChildText) { ClearText(szValue, szChildText); db_set_ts(hContact, MODULE, "About", szValue); @@ -231,30 +229,30 @@ void CheckCurrentFeed(MCONTACT hContact) } } else if (!mir_tstrcmpi(childName, _T("language"))) { - LPCTSTR szChildText = xi.getText(child); + LPCTSTR szChildText = xmlGetText(child); if (szChildText) db_set_ts(hContact, MODULE, "Language1", ClearText(szValue, szChildText)); } else if (!mir_tstrcmpi(childName, _T("managingEditor"))) { - LPCTSTR szChildText = xi.getText(child); + LPCTSTR szChildText = xmlGetText(child); if (szChildText) db_set_ts(hContact, MODULE, "e-mail", ClearText(szValue, szChildText)); } else if (!mir_tstrcmpi(childName, _T("category"))) { - LPCTSTR szChildText = xi.getText(child); + LPCTSTR szChildText = xmlGetText(child); if (szChildText) db_set_ts(hContact, MODULE, "Interest0Text", ClearText(szValue, szChildText)); } else if (!mir_tstrcmpi(childName, _T("copyright"))) { - LPCTSTR szChildText = xi.getText(child); + LPCTSTR szChildText = xmlGetText(child); if (szChildText) db_set_s(hContact, "UserInfo", "MyNotes", _T2A(ClearText(szValue, szChildText))); } else if (!mir_tstrcmpi(childName, _T("image"))) { - for (int x = 0; x < xi.getChildCount(child); x++) { - HXML imageval = xi.getChild(child, x); - if (!mir_tstrcmpi(xi.getName(imageval), _T("url"))) { - LPCTSTR url = xi.getText(imageval); + for (int x = 0; x < xmlGetChildCount(child); x++) { + HXML imageval = xmlGetChild(child, x); + if (!mir_tstrcmpi(xmlGetName(imageval), _T("url"))) { + LPCTSTR url = xmlGetText(imageval); db_set_ts(hContact, MODULE, "ImageURL", url); PROTO_AVATAR_INFORMATION ai = { 0 }; @@ -281,15 +279,15 @@ void CheckCurrentFeed(MCONTACT hContact) } } else if (!mir_tstrcmpi(childName, _T("lastBuildDate"))) { - LPCTSTR szChildText = xi.getText(child); + LPCTSTR szChildText = xmlGetText(child); if (szChildText) { - TCHAR *lastupdtime = (TCHAR *)xi.getText(child); + TCHAR *lastupdtime = (TCHAR *)xmlGetText(child); time_t stamp = DateToUnixTime(lastupdtime, 0); double deltaupd = difftime(time(NULL), stamp); double deltacheck = difftime(time(NULL), (time_t)db_get_dw(hContact, MODULE, "LastCheck", 0)); if (deltaupd - deltacheck >= 0) { db_set_dw(hContact, MODULE, "LastCheck", (DWORD)time(NULL)); - xi.destroyNode(hXml); + xmlDestroyNode(hXml); return; } } @@ -297,34 +295,34 @@ void CheckCurrentFeed(MCONTACT hContact) else if (!mir_tstrcmpi(childName, _T("item"))) { CMString title, link, descr, author, comments, guid, category; time_t stamp = 0; - for (int z = 0; z < xi.getChildCount(child); z++) { - HXML itemval = xi.getChild(child, z); - LPCTSTR itemName = xi.getName(itemval); + for (int z = 0; z < xmlGetChildCount(child); z++) { + HXML itemval = xmlGetChild(child, z); + LPCTSTR itemName = xmlGetName(itemval); // We only use the first tag for now and ignore the rest. if (!mir_tstrcmpi(itemName, _T("title"))) - ClearText(title, xi.getText(itemval)); + ClearText(title, xmlGetText(itemval)); else if (!mir_tstrcmpi(itemName, _T("link"))) - ClearText(link, xi.getText(itemval)); + ClearText(link, xmlGetText(itemval)); else if (!mir_tstrcmpi(itemName, _T("pubDate")) || !mir_tstrcmpi(itemName, _T("date"))) { if (stamp == 0) - stamp = DateToUnixTime(xi.getText(itemval), 0); + stamp = DateToUnixTime(xmlGetText(itemval), 0); } else if (!mir_tstrcmpi(itemName, _T("description")) || !mir_tstrcmpi(itemName, _T("encoded"))) - ClearText(descr, xi.getText(itemval)); + ClearText(descr, xmlGetText(itemval)); else if (!mir_tstrcmpi(itemName, _T("author")) || !mir_tstrcmpi(itemName, _T("creator"))) - ClearText(author, xi.getText(itemval)); + ClearText(author, xmlGetText(itemval)); else if (!mir_tstrcmpi(itemName, _T("comments"))) - ClearText(comments, xi.getText(itemval)); + ClearText(comments, xmlGetText(itemval)); else if (!mir_tstrcmpi(itemName, _T("guid"))) - ClearText(guid, xi.getText(itemval)); + ClearText(guid, xmlGetText(itemval)); else if (!mir_tstrcmpi(itemName, _T("category"))) - ClearText(category, xi.getText(itemval)); + ClearText(category, xmlGetText(itemval)); } XmlToMsg(hContact, title, link, descr, author, comments, guid, category, stamp); @@ -333,26 +331,26 @@ void CheckCurrentFeed(MCONTACT hContact) } else if (!mir_tstrcmpi(szNodeName, _T("feed"))) { db_set_ts(hContact, MODULE, "MirVer", _T("Atom 3")); - for (int j = 0; j < xi.getChildCount(node); j++) { - HXML child = xi.getChild(node, j); - LPCTSTR szChildName = xi.getName(child); + for (int j = 0; j < xmlGetChildCount(node); j++) { + HXML child = xmlGetChild(node, j); + LPCTSTR szChildName = xmlGetName(child); if (!mir_tstrcmpi(szChildName, _T("title"))) { - LPCTSTR szChildText = xi.getText(child); + LPCTSTR szChildText = xmlGetText(child); if (szChildText) db_set_ts(hContact, MODULE, "FirstName", ClearText(szValue, szChildText)); } else if (!mir_tstrcmpi(szChildName, _T("link"))) { - for (int x = 0; x < xi.getAttrCount(child); x++) { - if (!mir_tstrcmpi(xi.getAttrName(child, x), _T("rel"))) - if (!mir_tstrcmpi(xi.getAttrValue(child, xi.getAttrName(child, x)), _T("self"))) + for (int x = 0; x < xmlGetAttrCount(child); x++) { + if (!mir_tstrcmpi(xmlGetAttrName(child, x), _T("rel"))) + if (!mir_tstrcmpi(xmlGetAttrValue(child, xmlGetAttrName(child, x)), _T("self"))) break; - if (!mir_tstrcmpi(xi.getAttrName(child, x), _T("href"))) - db_set_ts(hContact, MODULE, "Homepage", xi.getAttrValue(child, xi.getAttrName(child, x))); + if (!mir_tstrcmpi(xmlGetAttrName(child, x), _T("href"))) + db_set_ts(hContact, MODULE, "Homepage", xmlGetAttrValue(child, xmlGetAttrName(child, x))); } } else if (!mir_tstrcmpi(szChildName, _T("subtitle"))) { - LPCTSTR szChildText = xi.getText(child); + LPCTSTR szChildText = xmlGetText(child); if (szChildText) { ClearText(szValue, szChildText); db_set_ts(hContact, MODULE, "About", szValue); @@ -360,29 +358,29 @@ void CheckCurrentFeed(MCONTACT hContact) } } else if (!mir_tstrcmpi(szChildName, _T("language"))) { - LPCTSTR szChildText = xi.getText(child); + LPCTSTR szChildText = xmlGetText(child); if (szChildText) db_set_ts(hContact, MODULE, "Language1", ClearText(szValue, szChildText)); } else if (!mir_tstrcmpi(szChildName, _T("author"))) { - for (int x = 0; x < xi.getChildCount(child); x++) { - HXML authorval = xi.getChild(child, x); - if (!mir_tstrcmpi(xi.getName(authorval), _T("email"))) { - db_set_ts(hContact, MODULE, "e-mail", xi.getText(authorval)); + for (int x = 0; x < xmlGetChildCount(child); x++) { + HXML authorval = xmlGetChild(child, x); + if (!mir_tstrcmpi(xmlGetName(authorval), _T("email"))) { + db_set_ts(hContact, MODULE, "e-mail", xmlGetText(authorval)); break; } } } else if (!mir_tstrcmpi(szChildName, _T("category"))) { - LPCTSTR szChildText = xi.getText(child); + LPCTSTR szChildText = xmlGetText(child); if (szChildText) db_set_ts(hContact, MODULE, "Interest0Text", ClearText(szValue, szChildText)); } else if (!mir_tstrcmpi(szChildName, _T("icon"))) { - for (int x = 0; x < xi.getChildCount(child); x++) { - HXML imageval = xi.getChild(child, x); - if (!mir_tstrcmpi(xi.getName(imageval), _T("url"))) { - LPCTSTR url = xi.getText(imageval); + for (int x = 0; x < xmlGetChildCount(child); x++) { + HXML imageval = xmlGetChild(child, x); + if (!mir_tstrcmpi(xmlGetName(imageval), _T("url"))) { + LPCTSTR url = xmlGetText(imageval); db_set_ts(hContact, MODULE, "ImageURL", url); ptrT szNick(db_get_tsa(hContact, MODULE, "Nick")); @@ -405,7 +403,7 @@ void CheckCurrentFeed(MCONTACT hContact) } } else if (!mir_tstrcmpi(szChildName, _T("updated"))) { - LPCTSTR szChildText = xi.getText(child); + LPCTSTR szChildText = xmlGetText(child); if (szChildText) { TCHAR *lastupdtime = (TCHAR *)szChildText; time_t stamp = DateToUnixTime(lastupdtime, 1); @@ -413,7 +411,7 @@ void CheckCurrentFeed(MCONTACT hContact) double deltacheck = difftime(time(NULL), (time_t)db_get_dw(hContact, MODULE, "LastCheck", 0)); if (deltaupd - deltacheck >= 0) { db_set_dw(hContact, MODULE, "LastCheck", (DWORD)time(NULL)); - xi.destroyNode(hXml); + xmlDestroyNode(hXml); return; } } @@ -421,55 +419,55 @@ void CheckCurrentFeed(MCONTACT hContact) else if (!mir_tstrcmpi(szChildName, _T("entry"))) { CMString title, link, descr, author, comments, guid, category; time_t stamp = 0; - for (int z = 0; z < xi.getChildCount(child); z++) { - HXML itemval = xi.getChild(child, z); - LPCTSTR szItemName = xi.getName(itemval); + for (int z = 0; z < xmlGetChildCount(child); z++) { + HXML itemval = xmlGetChild(child, z); + LPCTSTR szItemName = xmlGetName(itemval); if (!mir_tstrcmpi(szItemName, _T("title"))) { - LPCTSTR szItemText = xi.getText(itemval); + LPCTSTR szItemText = xmlGetText(itemval); if (szItemText) ClearText(title, szItemText); } else if (!mir_tstrcmpi(szItemName, _T("link"))) { - for (int x = 0; x < xi.getAttrCount(itemval); x++) { - if (!mir_tstrcmpi(xi.getAttrName(itemval, x), _T("href"))) { - ClearText(link, xi.getAttrValue(itemval, xi.getAttrName(itemval, x))); + for (int x = 0; x < xmlGetAttrCount(itemval); x++) { + if (!mir_tstrcmpi(xmlGetAttrName(itemval, x), _T("href"))) { + ClearText(link, xmlGetAttrValue(itemval, xmlGetAttrName(itemval, x))); break; } } } else if (!mir_tstrcmpi(szItemName, _T("updated"))) { if (stamp == 0) - stamp = DateToUnixTime(xi.getText(itemval), 0); + stamp = DateToUnixTime(xmlGetText(itemval), 0); } else if (!mir_tstrcmpi(szItemName, _T("summary")) || !mir_tstrcmpi(szItemName, _T("content"))) { - LPCTSTR szItemText = xi.getText(itemval); + LPCTSTR szItemText = xmlGetText(itemval); if (szItemText) ClearText(descr, szItemText); } else if (!mir_tstrcmpi(szItemName, _T("author"))) { - for (int x = 0; x < xi.getChildCount(itemval); x++) { - HXML authorval = xi.getChild(itemval, x); - if (!mir_tstrcmpi(xi.getName(authorval), _T("name")) && xi.getText(authorval)) { - ClearText(author, xi.getText(authorval)); + for (int x = 0; x < xmlGetChildCount(itemval); x++) { + HXML authorval = xmlGetChild(itemval, x); + if (!mir_tstrcmpi(xmlGetName(authorval), _T("name")) && xmlGetText(authorval)) { + ClearText(author, xmlGetText(authorval)); break; } } } else if (!mir_tstrcmpi(szItemName, _T("comments"))) { - LPCTSTR szItemText = xi.getText(itemval); + LPCTSTR szItemText = xmlGetText(itemval); if (szItemText) ClearText(comments, szItemText); } else if (!mir_tstrcmpi(szItemName, _T("id"))) { - LPCTSTR szItemText = xi.getText(itemval); + LPCTSTR szItemText = xmlGetText(itemval); if (szItemText) - ClearText(guid, xi.getText(itemval)); + ClearText(guid, xmlGetText(itemval)); } else if (!mir_tstrcmpi(szItemName, _T("category"))) { - for (int x = 0; x < xi.getAttrCount(itemval); x++) { - LPCTSTR szAttrName = xi.getAttrName(itemval, x); - if (!mir_tstrcmpi(szAttrName, _T("term")) && xi.getText(itemval)) { - ClearText(category, xi.getAttrValue(itemval, szAttrName)); + for (int x = 0; x < xmlGetAttrCount(itemval); x++) { + LPCTSTR szAttrName = xmlGetAttrName(itemval, x); + if (!mir_tstrcmpi(szAttrName, _T("term")) && xmlGetText(itemval)) { + ClearText(category, xmlGetAttrValue(itemval, szAttrName)); break; } } @@ -480,9 +478,9 @@ void CheckCurrentFeed(MCONTACT hContact) } } } - node = xi.getChild(hXml, ++childcount); + node = xmlGetChild(hXml, ++childcount); } - xi.destroyNode(hXml); + xmlDestroyNode(hXml); } } db_set_dw(hContact, MODULE, "LastCheck", (DWORD)time(NULL)); @@ -508,25 +506,25 @@ void CheckCurrentFeedAvatar(MCONTACT hContact) if (!tszData) tszData = mir_a2t(szData); int bytesParsed = 0; - HXML hXml = xi.parseString(tszData, &bytesParsed, NULL); + HXML hXml = xmlParseString(tszData, &bytesParsed, NULL); mir_free(tszData); mir_free(szData); if (hXml == NULL) return; int childcount = 0; - HXML node = xi.getChild(hXml, childcount); + HXML node = xmlGetChild(hXml, childcount); while (node) { - LPCTSTR szNodeName = xi.getName(node); + LPCTSTR szNodeName = xmlGetName(node); if (!mir_tstrcmpi(szNodeName, _T("rss")) || !mir_tstrcmpi(szNodeName, _T("rdf"))) { - HXML chan = xi.getChild(node, 0); - for (int j = 0; j < xi.getChildCount(chan); j++) { - HXML child = xi.getChild(chan, j); - if (!mir_tstrcmpi(xi.getName(child), _T("image"))) { - for (int x = 0; x < xi.getChildCount(child); x++) { - HXML imageval = xi.getChild(child, x); - if (!mir_tstrcmpi(xi.getName(imageval), _T("url"))) { - LPCTSTR url = xi.getText(imageval); + HXML chan = xmlGetChild(node, 0); + for (int j = 0; j < xmlGetChildCount(chan); j++) { + HXML child = xmlGetChild(chan, j); + if (!mir_tstrcmpi(xmlGetName(child), _T("image"))) { + for (int x = 0; x < xmlGetChildCount(child); x++) { + HXML imageval = xmlGetChild(child, x); + if (!mir_tstrcmpi(xmlGetName(imageval), _T("url"))) { + LPCTSTR url = xmlGetText(imageval); db_set_ts(hContact, MODULE, "ImageURL", url); PROTO_AVATAR_INFORMATION ai = { 0 }; @@ -553,13 +551,13 @@ void CheckCurrentFeedAvatar(MCONTACT hContact) } } else if (!mir_tstrcmpi(szNodeName, _T("feed"))) { - for (int j = 0; j < xi.getChildCount(node); j++) { - HXML child = xi.getChild(node, j); - if (!mir_tstrcmpi(xi.getName(child), _T("icon"))) { - for (int x = 0; x < xi.getChildCount(child); x++) { - HXML imageval = xi.getChild(child, x); - if (!mir_tstrcmpi(xi.getName(imageval), _T("url"))) { - LPCTSTR url = xi.getText(imageval); + for (int j = 0; j < xmlGetChildCount(node); j++) { + HXML child = xmlGetChild(node, j); + if (!mir_tstrcmpi(xmlGetName(child), _T("icon"))) { + for (int x = 0; x < xmlGetChildCount(child); x++) { + HXML imageval = xmlGetChild(child, x); + if (!mir_tstrcmpi(xmlGetName(imageval), _T("url"))) { + LPCTSTR url = xmlGetText(imageval); db_set_ts(hContact, MODULE, "ImageURL", url); ptrT szNick(db_get_tsa(hContact, MODULE, "Nick")); @@ -584,7 +582,7 @@ void CheckCurrentFeedAvatar(MCONTACT hContact) } } } - node = xi.getChild(hXml, ++childcount); + node = xmlGetChild(hXml, ++childcount); } - xi.destroyNode(hXml); + xmlDestroyNode(hXml); } diff --git a/plugins/NewsAggregator/Src/Common.h b/plugins/NewsAggregator/Src/Common.h index 7a2c424978..6e84892346 100644 --- a/plugins/NewsAggregator/Src/Common.h +++ b/plugins/NewsAggregator/Src/Common.h @@ -88,58 +88,59 @@ void UpdateListAdd(MCONTACT hContact); void UpdateThreadProc(LPVOID AvatarCheck); void DestroyUpdateList(void); -extern HANDLE hUpdateMutex; -extern HGENMENU hService2[7]; - -int NewsAggrInit(WPARAM wParam,LPARAM lParam); -int OptInit(WPARAM wParam, LPARAM lParam); -int NewsAggrPreShutdown(WPARAM wParam,LPARAM lParam); -void NetlibInit(); -void NetlibUnInit(); -void InitMenu(); -void InitIcons(); -HICON LoadIconEx(const char* name, bool big); -HANDLE GetIconHandle(const char* name); -INT_PTR NewsAggrGetName(WPARAM wParam, LPARAM lParam); -INT_PTR NewsAggrGetCaps(WPARAM wp, LPARAM lp); -INT_PTR NewsAggrSetStatus(WPARAM wp, LPARAM /*lp*/); -INT_PTR NewsAggrGetStatus(WPARAM/* wp*/, LPARAM/* lp*/); -INT_PTR NewsAggrLoadIcon(WPARAM wParam, LPARAM lParam); -INT_PTR NewsAggrGetInfo(WPARAM wParam, LPARAM lParam); -INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam, LPARAM lParam); -INT_PTR NewsAggrRecvMessage(WPARAM wParam, LPARAM lParam); - -INT_PTR CheckAllFeeds(WPARAM wParam, LPARAM lParam); -INT_PTR AddFeed(WPARAM wParam, LPARAM lParam); -INT_PTR ChangeFeed(WPARAM wParam, LPARAM lParam); -INT_PTR ImportFeeds(WPARAM wParam, LPARAM lParam); -INT_PTR ExportFeeds(WPARAM wParam, LPARAM lParam); -INT_PTR CheckFeed(WPARAM wParam, LPARAM lParam); -INT_PTR EnableDisable(WPARAM wParam, LPARAM lParam); -int OnToolbarLoaded(WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -void CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime); -void CALLBACK timerProc2(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime); - -bool IsMyContact(MCONTACT hContact); -void GetNewsData(TCHAR *szUrl, char **szData, MCONTACT hContact, HWND hwndDlg); -void CreateList(HWND hwndList); -void UpdateList(HWND hwndList); -void DeleteAllItems(HWND hwndList); -time_t __stdcall DateToUnixTime(const TCHAR *stamp, bool FeedType); -void CheckCurrentFeed(MCONTACT hContact); -void CheckCurrentFeedAvatar(MCONTACT hContact); -TCHAR* CheckFeed(TCHAR* tszURL, HWND hwndDlg); -void UpdateMenu(bool State); -int ImportFeedsDialog(); -LPCTSTR ClearText(CMString &value, const TCHAR *message); -bool DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal); -void CreateAuthString(char *auth, MCONTACT hContact, HWND hwndDlg); -INT_PTR CALLBACK AuthenticationProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK DlgProcExportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +extern HANDLE hUpdateMutex; +extern HGENMENU hService2[7]; + +int NewsAggrInit(WPARAM wParam,LPARAM lParam); +int OptInit(WPARAM wParam, LPARAM lParam); +int NewsAggrPreShutdown(WPARAM wParam,LPARAM lParam); +void NetlibInit(); +void NetlibUnInit(); +void InitMenu(); +void InitIcons(); +HICON LoadIconEx(const char* name, bool big); +HANDLE GetIconHandle(const char* name); + +INT_PTR NewsAggrGetName(WPARAM wParam, LPARAM lParam); +INT_PTR NewsAggrGetCaps(WPARAM wp, LPARAM lp); +INT_PTR NewsAggrSetStatus(WPARAM wp, LPARAM /*lp*/); +INT_PTR NewsAggrGetStatus(WPARAM/* wp*/, LPARAM/* lp*/); +INT_PTR NewsAggrLoadIcon(WPARAM wParam, LPARAM lParam); +INT_PTR NewsAggrGetInfo(WPARAM wParam, LPARAM lParam); +INT_PTR NewsAggrGetAvatarInfo(WPARAM wParam, LPARAM lParam); +INT_PTR NewsAggrRecvMessage(WPARAM wParam, LPARAM lParam); + +INT_PTR CheckAllFeeds(WPARAM wParam, LPARAM lParam); +INT_PTR AddFeed(WPARAM wParam, LPARAM lParam); +INT_PTR ChangeFeed(WPARAM wParam, LPARAM lParam); +INT_PTR ImportFeeds(WPARAM wParam, LPARAM lParam); +INT_PTR ExportFeeds(WPARAM wParam, LPARAM lParam); +INT_PTR CheckFeed(WPARAM wParam, LPARAM lParam); +INT_PTR EnableDisable(WPARAM wParam, LPARAM lParam); +int OnToolbarLoaded(WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +void CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime); +void CALLBACK timerProc2(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime); + +bool IsMyContact(MCONTACT hContact); +void GetNewsData(TCHAR *szUrl, char **szData, MCONTACT hContact, HWND hwndDlg); +void CreateList(HWND hwndList); +void UpdateList(HWND hwndList); +void DeleteAllItems(HWND hwndList); +time_t __stdcall DateToUnixTime(const TCHAR *stamp, bool FeedType); +void CheckCurrentFeed(MCONTACT hContact); +void CheckCurrentFeedAvatar(MCONTACT hContact); +LPCTSTR CheckFeed(TCHAR* tszURL, HWND hwndDlg); +void UpdateMenu(bool State); +int ImportFeedsDialog(); +LPCTSTR ClearText(CMString &value, const TCHAR *message); +bool DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal); +void CreateAuthString(char *auth, MCONTACT hContact, HWND hwndDlg); +INT_PTR CALLBACK AuthenticationProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); +INT_PTR CALLBACK DlgProcExportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); MCONTACT GetContactByNick(const TCHAR *nick); MCONTACT GetContactByURL(const TCHAR *url); diff --git a/plugins/NewsAggregator/Src/ExportImport.cpp b/plugins/NewsAggregator/Src/ExportImport.cpp index fe6e512c29..d62d9b6f39 100644 --- a/plugins/NewsAggregator/Src/ExportImport.cpp +++ b/plugins/NewsAggregator/Src/ExportImport.cpp @@ -43,45 +43,45 @@ INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM TCHAR FileName[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_IMPORTFILEPATH, FileName, _countof(FileName)); int bytesParsed = 0; - HXML hXml = xi.parseFile(FileName, &bytesParsed, NULL); + HXML hXml = xmlParseFile(FileName, &bytesParsed, NULL); if(hXml != NULL) { HWND hwndList = (HWND)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); bool isTextUTF = false, isURLUTF = false, isSiteURLUTF = false, isGroupUTF = false; - HXML node = xi.getChildByPath(hXml, _T("opml/body/outline"), 0); + HXML node = xmlGetChildByPath(hXml, _T("opml/body/outline"), 0); if ( !node) - node = xi.getChildByPath(hXml, _T("body/outline"), 0); + node = xmlGetChildByPath(hXml, _T("body/outline"), 0); int count = (int)SendMessage(FeedsImportList, LB_GETCOUNT, 0, 0); int DUPES = 0; if (node) { while (node) { - int outlineAttr = xi.getAttrCount(node); - int outlineChildsCount = xi.getChildCount(node); - TCHAR *xmlUrl = (TCHAR *)xi.getAttrValue(node, _T("xmlUrl")); + int outlineAttr = xmlGetAttrCount(node); + int outlineChildsCount = xmlGetChildCount(node); + TCHAR *xmlUrl = (TCHAR *)xmlGetAttrValue(node, _T("xmlUrl")); if (!xmlUrl && !outlineChildsCount) { HXML tmpnode = node; - node = xi.getNextNode(node); + node = xmlGetNextNode(node); if ( !node) { do { node = tmpnode; - node = xi.getParent(node); + node = xmlGetParent(node); tmpnode = node; - node = xi.getNextNode(node); + node = xmlGetNextNode(node); if (node) break; - } while (mir_tstrcmpi(xi.getName(node), _T("body"))); + } while (mir_tstrcmpi(xmlGetName(node), _T("body"))); } } else if (!xmlUrl && outlineChildsCount) - node = xi.getFirstChild(node); + node = xmlGetFirstChild(node); else if (xmlUrl) { TCHAR *text = NULL, *url = NULL, *siteurl = NULL, *group = NULL; BYTE NeedToImport = FALSE; for (int i = 0; i < outlineAttr; i++) { - if (!mir_tstrcmpi(xi.getAttrName(node, i), _T("text"))) { - text = mir_utf8decodeT(_T2A(xi.getAttrValue(node, xi.getAttrName(node, i)))); + if (!mir_tstrcmpi(xmlGetAttrName(node, i), _T("text"))) { + text = mir_utf8decodeT(_T2A(xmlGetAttrValue(node, xmlGetAttrName(node, i)))); if (!text) { isTextUTF = 0; - text = (TCHAR *)xi.getAttrValue(node, xi.getAttrName(node, i)); + text = (TCHAR *)xmlGetAttrValue(node, xmlGetAttrName(node, i)); } else isTextUTF = 1; @@ -95,11 +95,11 @@ INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM } continue; } - if (!mir_tstrcmpi(xi.getAttrName(node, i), _T("xmlUrl"))) { - url = mir_utf8decodeT(_T2A(xi.getAttrValue(node, xi.getAttrName(node, i)))); + if (!mir_tstrcmpi(xmlGetAttrName(node, i), _T("xmlUrl"))) { + url = mir_utf8decodeT(_T2A(xmlGetAttrValue(node, xmlGetAttrName(node, i)))); if ( !url) { isURLUTF = false; - url = (TCHAR *)xi.getAttrValue(node, xi.getAttrName(node, i)); + url = (TCHAR *)xmlGetAttrValue(node, xmlGetAttrName(node, i)); } else isURLUTF = true; if (GetContactByURL(url) && NeedToImport) { @@ -108,11 +108,11 @@ INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM } continue; } - if (!mir_tstrcmpi(xi.getAttrName(node, i), _T("htmlUrl"))) { - siteurl = mir_utf8decodeT(_T2A(xi.getAttrValue(node, xi.getAttrName(node, i)))); + if (!mir_tstrcmpi(xmlGetAttrName(node, i), _T("htmlUrl"))) { + siteurl = mir_utf8decodeT(_T2A(xmlGetAttrValue(node, xmlGetAttrName(node, i)))); if ( !siteurl) { isSiteURLUTF = false; - siteurl = (TCHAR *)xi.getAttrValue(node, xi.getAttrName(node, i)); + siteurl = (TCHAR *)xmlGetAttrValue(node, xmlGetAttrName(node, i)); } else isSiteURLUTF = true; continue; @@ -122,21 +122,21 @@ INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM } if (NeedToImport) { - HXML parent = xi.getParent(node); + HXML parent = xmlGetParent(node); TCHAR tmpgroup[1024]; - while (mir_tstrcmpi(xi.getName(parent), _T("body"))) { - for (int i = 0; i < xi.getAttrCount(parent); i++) { - if (!mir_tstrcmpi(xi.getAttrName(parent, i), _T("text"))) { + while (mir_tstrcmpi(xmlGetName(parent), _T("body"))) { + for (int i = 0; i < xmlGetAttrCount(parent); i++) { + if (!mir_tstrcmpi(xmlGetAttrName(parent, i), _T("text"))) { if ( !group) - group = (TCHAR *)xi.getAttrValue(parent, xi.getAttrName(parent, i)); + group = (TCHAR *)xmlGetAttrValue(parent, xmlGetAttrName(parent, i)); else { - mir_sntprintf(tmpgroup, _countof(tmpgroup), _T("%s\\%s"), xi.getAttrValue(parent, xi.getAttrName(parent, i)), group); + mir_sntprintf(tmpgroup, _countof(tmpgroup), _T("%s\\%s"), xmlGetAttrValue(parent, xmlGetAttrName(parent, i)), group); group = tmpgroup; } break; } } - parent = xi.getParent(parent); + parent = xmlGetParent(parent); } TCHAR *utfgroup = NULL; @@ -187,22 +187,22 @@ INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM mir_free(siteurl); HXML tmpnode = node; - node = xi.getNextNode(node); + node = xmlGetNextNode(node); if ( !node) { do { node = tmpnode; - node = xi.getParent(node); + node = xmlGetParent(node); tmpnode = node; - node = xi.getNextNode(node); + node = xmlGetNextNode(node); if (node) break; } - while (mir_tstrcmpi(xi.getName(tmpnode), _T("body"))); + while (mir_tstrcmpi(xmlGetName(tmpnode), _T("body"))); } } } } - xi.destroyNode(hXml); + xmlDestroyNode(hXml); if (hwndList) { DeleteAllItems(hwndList); UpdateList(hwndList); @@ -241,40 +241,40 @@ INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if (GetOpenFileName(&ofn)) { int bytesParsed = 0; - HXML hXml = xi.parseFile(FileName, &bytesParsed, NULL); + HXML hXml = xmlParseFile(FileName, &bytesParsed, NULL); if(hXml != NULL) { - HXML node = xi.getChildByPath(hXml, _T("opml/body/outline"), 0); + HXML node = xmlGetChildByPath(hXml, _T("opml/body/outline"), 0); if ( !node) - node = xi.getChildByPath(hXml, _T("body/outline"), 0); + node = xmlGetChildByPath(hXml, _T("body/outline"), 0); if (node) { while (node) { - int outlineAttr = xi.getAttrCount(node); - int outlineChildsCount = xi.getChildCount(node); - TCHAR *xmlUrl = (TCHAR *)xi.getAttrValue(node, _T("xmlUrl")); + int outlineAttr = xmlGetAttrCount(node); + int outlineChildsCount = xmlGetChildCount(node); + TCHAR *xmlUrl = (TCHAR *)xmlGetAttrValue(node, _T("xmlUrl")); if (!xmlUrl && !outlineChildsCount) { HXML tmpnode = node; - node = xi.getNextNode(node); + node = xmlGetNextNode(node); if ( !node) { do { node = tmpnode; - node = xi.getParent(node); + node = xmlGetParent(node); tmpnode = node; - node = xi.getNextNode(node); + node = xmlGetNextNode(node); if (node) break; - } while (mir_tstrcmpi(xi.getName(node), _T("body"))); + } while (mir_tstrcmpi(xmlGetName(node), _T("body"))); } } else if (!xmlUrl && outlineChildsCount) - node = xi.getFirstChild(node); + node = xmlGetFirstChild(node); else if (xmlUrl) { for (int i = 0; i < outlineAttr; i++) { - if (!mir_tstrcmpi(xi.getAttrName(node, i), _T("text"))) { - TCHAR *text = mir_utf8decodeT(_T2A(xi.getAttrValue(node, xi.getAttrName(node, i)))); + if (!mir_tstrcmpi(xmlGetAttrName(node, i), _T("text"))) { + TCHAR *text = mir_utf8decodeT(_T2A(xmlGetAttrValue(node, xmlGetAttrName(node, i)))); bool isTextUTF; if (!text) { isTextUTF = false; - text = (TCHAR *)xi.getAttrValue(node, xi.getAttrName(node, i)); + text = (TCHAR *)xmlGetAttrValue(node, xmlGetAttrName(node, i)); } else isTextUTF = true; SendMessage(FeedsList, LB_ADDSTRING, 0, (LPARAM)text); @@ -287,23 +287,23 @@ INT_PTR CALLBACK DlgProcImportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM HXML tmpnode = node; - node = xi.getNextNode(node); + node = xmlGetNextNode(node); if ( !node) { do { node = tmpnode; - node = xi.getParent(node); + node = xmlGetParent(node); tmpnode = node; - node = xi.getNextNode(node); + node = xmlGetNextNode(node); if (node) break; - } while (mir_tstrcmpi(xi.getName(tmpnode), _T("body"))); + } while (mir_tstrcmpi(xmlGetName(tmpnode), _T("body"))); } } } } else MessageBox(hwndDlg, TranslateT("Not valid import file."), TranslateT("Error"), MB_OK | MB_ICONERROR); - xi.destroyNode(hXml); + xmlDestroyNode(hXml); SetDlgItemText(hwndDlg, IDC_IMPORTFILEPATH, FileName); } else @@ -503,11 +503,11 @@ INT_PTR CALLBACK DlgProcExportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM ofn.lpstrDefExt = _T(""); if (GetSaveFileName(&ofn)) { - HXML hXml = xi.createNode(_T("opml"), NULL, FALSE); - xi.addAttr(hXml, _T("version"), _T("1.0")); - HXML header = xi.addChild(hXml, _T("head"), NULL); - xi.addChild(header, _T("title"), _T("Miranda NG NewsAggregator plugin export")); - header = xi.addChild(hXml, _T("body"), NULL); + HXML hXml = xmlCreateNode(_T("opml"), NULL, FALSE); + xmlAddAttr(hXml, _T("version"), _T("1.0")); + HXML header = xmlAddChild(hXml, _T("head"), NULL); + xmlAddChild(header, _T("title"), _T("Miranda NG NewsAggregator plugin export")); + header = xmlAddChild(hXml, _T("body"), NULL); int count = (int)SendMessage(FeedsExportList, LB_GETCOUNT, 0, 0); for (int i = 0; i < count; i++) { @@ -526,34 +526,34 @@ INT_PTR CALLBACK DlgProcExportOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM TCHAR *section = _tcstok(group, _T("\\")); while (section != NULL) { - HXML existgroup = xi.getChildByAttrValue(header, _T("outline"), _T("title"), section); + HXML existgroup = xmlGetChildByAttrValue(header, _T("outline"), _T("title"), section); if ( !existgroup) { - elem = xi.addChild(elem, _T("outline"), NULL); - xi.addAttr(elem, _T("title"), section); - xi.addAttr(elem, _T("text"), section); + elem = xmlAddChild(elem, _T("outline"), NULL); + xmlAddAttr(elem, _T("title"), section); + xmlAddAttr(elem, _T("text"), section); } else { elem = existgroup; } section = _tcstok(NULL, _T("\\")); } - elem = xi.addChild(elem, _T("outline"), NULL); + elem = xmlAddChild(elem, _T("outline"), NULL); } else - elem = xi.addChild(elem, _T("outline"), NULL); - xi.addAttr(elem, _T("text"), title); - xi.addAttr(elem, _T("title"), title); - xi.addAttr(elem, _T("type"), _T("rss")); - xi.addAttr(elem, _T("xmlUrl"), url); - xi.addAttr(elem, _T("htmlUrl"), siteurl); + elem = xmlAddChild(elem, _T("outline"), NULL); + xmlAddAttr(elem, _T("text"), title); + xmlAddAttr(elem, _T("title"), title); + xmlAddAttr(elem, _T("type"), _T("rss")); + xmlAddAttr(elem, _T("xmlUrl"), url); + xmlAddAttr(elem, _T("htmlUrl"), siteurl); mir_free(title); mir_free(url); mir_free(siteurl); mir_free(group); } - xi.toFile(hXml, FileName, 1); - xi.destroyNode(hXml); + xmlToFile(hXml, FileName, 1); + xmlDestroyNode(hXml); } } diff --git a/plugins/NewsAggregator/Src/NewsAggregator.cpp b/plugins/NewsAggregator/Src/NewsAggregator.cpp index fc40b58c16..279a69ea5a 100644 --- a/plugins/NewsAggregator/Src/NewsAggregator.cpp +++ b/plugins/NewsAggregator/Src/NewsAggregator.cpp @@ -25,7 +25,6 @@ int hLangpack; HANDLE hPrebuildMenuHook = NULL; HWND hAddFeedDlg; MWindowList hChangeFeedDlgList = NULL; -XML_API xi = {0}; TCHAR tszRoot[MAX_PATH] = {0}; HANDLE hUpdateMutex; @@ -57,7 +56,6 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) extern "C" __declspec(dllexport) int Load(void) { mir_getLP(&pluginInfoEx); - mir_getXI(&xi); // Add options hook HookEvent(ME_OPT_INITIALISE, OptInit); diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp index 66006753ff..7dac335b90 100644 --- a/plugins/NewsAggregator/Src/Options.cpp +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -114,7 +114,8 @@ INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case IDC_DISCOVERY: EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE); SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait...")); - TCHAR tszURL[MAX_PATH] = { 0 }, *tszTitle = NULL; + TCHAR tszURL[MAX_PATH] = { 0 }; + const TCHAR *tszTitle = NULL; if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, _countof(tszURL)) || mir_tstrcmp(tszURL, _T("http://")) != 0) tszTitle = CheckFeed(tszURL, hwndDlg); else @@ -281,7 +282,7 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, _countof(tszURL)) || mir_tstrcmp(tszURL, _T("http://")) != 0) { EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE); SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait...")); - TCHAR *tszTitle = CheckFeed(tszURL, hwndDlg); + const TCHAR *tszTitle = CheckFeed(tszURL, hwndDlg); SetDlgItemText(hwndDlg, IDC_FEEDTITLE, tszTitle); EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), TRUE); SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Check Feed")); @@ -436,7 +437,7 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (GetDlgItemText(hwndDlg, IDC_FEEDURL, tszURL, _countof(tszURL)) || mir_tstrcmp(tszURL, _T("http://")) != 0) { EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), FALSE); SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Wait...")); - TCHAR *tszTitle = CheckFeed(tszURL, hwndDlg); + const TCHAR *tszTitle = CheckFeed(tszURL, hwndDlg); SetDlgItemText(hwndDlg, IDC_FEEDTITLE, tszTitle); EnableWindow(GetDlgItem(hwndDlg, IDC_DISCOVERY), TRUE); SetDlgItemText(hwndDlg, IDC_DISCOVERY, TranslateT("Check Feed")); diff --git a/plugins/PasteIt/src/PasteIt.cpp b/plugins/PasteIt/src/PasteIt.cpp index fce900c8dc..925b22dc34 100644 --- a/plugins/PasteIt/src/PasteIt.cpp +++ b/plugins/PasteIt/src/PasteIt.cpp @@ -53,7 +53,6 @@ PLUGININFOEX pluginInfo = { static IconItem icon = { LPGEN("Paste It"), "PasteIt_main", IDI_MENU }; -XML_API xi = { 0 }; int hLangpack = 0; BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) @@ -402,7 +401,6 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) extern "C" int __declspec(dllexport) Load(void) { - mir_getXI(&xi); mir_getLP(&pluginInfo); Icon_Register(hInst, LPGEN("Paste It"), &icon, 1); diff --git a/plugins/PasteIt/src/PasteToWeb2.cpp b/plugins/PasteIt/src/PasteToWeb2.cpp index e14db0a966..36e168a922 100644 --- a/plugins/PasteIt/src/PasteToWeb2.cpp +++ b/plugins/PasteIt/src/PasteToWeb2.cpp @@ -105,22 +105,22 @@ void PasteToWeb2::SendToServer(std::wstring str, std::wstring fileName, std::wst error = TranslateT("Error during sending text to web page"); if (resCont != NULL) { - HXML hXml = xi.parseString(resCont, NULL, _T("methodResponse")); + HXML hXml = xmlParseString(resCont, NULL, _T("methodResponse")); if (hXml != NULL) { - HXML node = xi.getChildByPath(hXml, _T("params/param/value/array/data/value/int"), 0); - if (node != NULL && !mir_tstrcmp(xi.getText(node), _T("1"))) + HXML node = xmlGetChildByPath(hXml, _T("params/param/value/array/data/value/int"), 0); + if (node != NULL && !mir_tstrcmp(xmlGetText(node), _T("1"))) { - node = xi.getChildByPath(hXml, _T("params/param/value/array/data"), 0); + node = xmlGetChildByPath(hXml, _T("params/param/value/array/data"), 0); if (node != NULL) { - node = xi.getNthChild(node, _T("value"), 1); + node = xmlGetNthChild(node, _T("value"), 1); if (node != NULL) { - node = xi.getChildByPath(node, _T("string"), 0); + node = xmlGetChildByPath(node, _T("string"), 0); if (node != NULL) { - char* s = mir_t2a_cp(xi.getText(node), CP_ACP); + char* s = mir_t2a_cp(xmlGetText(node), CP_ACP); mir_strncpy(szFileLink, s, _countof(szFileLink)); mir_free(s); error = NULL; @@ -128,7 +128,7 @@ void PasteToWeb2::SendToServer(std::wstring str, std::wstring fileName, std::wst } } } - xi.destroyNode(hXml); + xmlDestroyNode(hXml); } mir_free(resCont); } @@ -145,22 +145,22 @@ std::list PasteToWeb2::GetFormats() wchar_t* resCont = SendToWeb("http://wklej.to/api/", headers, content); if (resCont != NULL) { - HXML hXml = xi.parseString(resCont, NULL, _T("methodResponse")); + HXML hXml = xmlParseString(resCont, NULL, _T("methodResponse")); if (hXml != NULL) { - HXML node = xi.getChildByPath(hXml, _T("params/param/value/array/data/value/int"), 0); - if (node != NULL && !mir_tstrcmp(xi.getText(node), _T("1"))) + HXML node = xmlGetChildByPath(hXml, _T("params/param/value/array/data/value/int"), 0); + if (node != NULL && !mir_tstrcmp(xmlGetText(node), _T("1"))) { - node = xi.getChildByPath(hXml, _T("params/param/value/array/data"), 0); + node = xmlGetChildByPath(hXml, _T("params/param/value/array/data"), 0); if (node != NULL) { - node = xi.getNthChild(node, _T("value"), 1); + node = xmlGetNthChild(node, _T("value"), 1); if (node != NULL) { - node = xi.getChildByPath(node, _T("string"), 0); + node = xmlGetChildByPath(node, _T("string"), 0); if (node != NULL) { - std::wstring str = xi.getText(node); + std::wstring str = xmlGetText(node); std::wstring::size_type pos = str.find(L'\n'); if (pos < str.length()) { @@ -225,7 +225,7 @@ std::list PasteToWeb2::GetFormats() } } } - xi.destroyNode(hXml); + xmlDestroyNode(hXml); } mir_free(resCont); } diff --git a/plugins/Quotes/src/ModuleInfo.cpp b/plugins/Quotes/src/ModuleInfo.cpp index 65d2593482..2b137a6258 100644 --- a/plugins/Quotes/src/ModuleInfo.cpp +++ b/plugins/Quotes/src/ModuleInfo.cpp @@ -60,10 +60,7 @@ CModuleInfo::TXMLEnginePtr CModuleInfo::GetXMLEnginePtr() { mir_cslock lck(g_lmParsers); if (!g_pXMLEngine) - { - mir_getXI(&xi); g_pXMLEngine = TXMLEnginePtr(new CXMLEngineMI); - } } return g_pXMLEngine; diff --git a/plugins/Quotes/src/XMLEngineMI.cpp b/plugins/Quotes/src/XMLEngineMI.cpp index 871cc2ed4f..6cd1ca5863 100644 --- a/plugins/Quotes/src/XMLEngineMI.cpp +++ b/plugins/Quotes/src/XMLEngineMI.cpp @@ -1,7 +1,5 @@ #include "StdAfx.h" -XML_API xi; - namespace { class CXMLNodeMI : public IXMLNode, @@ -20,18 +18,18 @@ namespace { if (m_bDestroy) { - xi.destroyNode(m_hXML); + xmlDestroyNode(m_hXML); } } virtual size_t GetChildCount()const { - return xi.getChildCount(m_hXML); + return xmlGetChildCount(m_hXML); } virtual TXMLNodePtr GetChildNode(size_t nIndex)const { - HXML h = xi.getChild(m_hXML, (int)nIndex); + HXML h = xmlGetChild(m_hXML, (int)nIndex); if (h) { return TXMLNodePtr(new CXMLNodeMI(h)); @@ -45,7 +43,7 @@ namespace virtual tstring GetText()const { tstring sResult; - LPCTSTR psz = xi.getText(m_hXML); + LPCTSTR psz = xmlGetText(m_hXML); if (psz) { sResult = psz; @@ -57,7 +55,7 @@ namespace virtual tstring GetName()const { tstring sResult; - LPCTSTR psz = xi.getName(m_hXML); + LPCTSTR psz = xmlGetName(m_hXML); if (psz) { sResult = psz; @@ -71,7 +69,7 @@ namespace CXMLNodeMI* pXML = dynamic_cast(pNode.get()); if (pXML) { - xi.addChild2(pXML->m_hXML, m_hXML); + xmlAddChild2(pXML->m_hXML, m_hXML); pXML->m_bDestroy = false; return true; } @@ -83,13 +81,13 @@ namespace virtual bool AddAttribute(const tstring& rsName, const tstring& rsValue) { - xi.addAttr(m_hXML, rsName.c_str(), rsValue.c_str()); + xmlAddAttr(m_hXML, rsName.c_str(), rsValue.c_str()); return true; } virtual tstring GetAttributeValue(const tstring& rsAttrName) { - LPCTSTR pszValue = xi.getAttrValue(m_hXML, rsAttrName.c_str()); + LPCTSTR pszValue = xmlGetAttrValue(m_hXML, rsAttrName.c_str()); return ((NULL != pszValue) ? tstring(pszValue) : tstring()); } @@ -98,7 +96,7 @@ namespace // struct safe_string // { // safe_string(LPTSTR p):m_p(p){} - // ~safe_string(){xi.freeMem(m_p);} + // ~safe_string(){xmlFree(m_p);} // // LPTSTR m_p; // }; @@ -112,7 +110,7 @@ namespace // }; - safe_string ss(xi.toString(m_hXML, NULL)); + safe_string ss(xmlToString(m_hXML, NULL)); if (ss.m_p) o << (char*)T2Utf(ss.m_p); } @@ -160,7 +158,7 @@ IXMLNode::TXMLNodePtr CXMLEngineMI::LoadFile(const tstring& rsFileName)const mir_safe_string ss(mir_utf8decodeT(pBuffer)); if (ss.m_p) { - HXML h = xi.parseString(ss.m_p, &nLen, NULL); + HXML h = xmlParseString(ss.m_p, &nLen, NULL); if (h) { pResult = IXMLNode::TXMLNodePtr(new CXMLNodeMI(h, true)); @@ -179,7 +177,7 @@ namespace IXMLNode::TXMLNodePtr create_node(const tstring& rsName, const tstring& rsText, bool bIsDecl) { IXMLNode::TXMLNodePtr pResult; - HXML h = xi.createNode(rsName.c_str(), rsText.c_str(), bIsDecl); + HXML h = xmlCreateNode(rsName.c_str(), rsText.c_str(), bIsDecl); if (h) { pResult = IXMLNode::TXMLNodePtr(new CXMLNodeMI(h, true)); diff --git a/plugins/Watrack/lastfm/i_last_api.inc b/plugins/Watrack/lastfm/i_last_api.inc index e67b8854af..a5be3d3111 100644 --- a/plugins/Watrack/lastfm/i_last_api.inc +++ b/plugins/Watrack/lastfm/i_last_api.inc @@ -223,9 +223,6 @@ begin result:=dst; end; -var - xmlparser:TXML_API_W; - function FixInfo(Info:pWideChar):pWideChar; var pc,ppc:pWideChar; @@ -301,77 +298,73 @@ begin begin UTF8ToWide(res,pcw); mFreeMem(res); - xmlparser.cbSize:={XML_API_SIZEOF_V1;//}SizeOf(TXML_API_W); - CallService(MS_SYSTEM_GET_XI,0,lparam(@xmlparser)); - with xmlparser do - begin - i:=StrLenW(pcw)*SizeOf(WideChar); - root:=parseString(pcw,@i,nil); - - actnode:=getChild(getChild(root,0),0); // "artist" - - if data.artist=nil then - StrDupW(data.artist,getText(GetNthChild(actnode,'name',0))); - - i:=0; - repeat - node:=GetNthChild(actnode,'image',i); - if node=0 then break; - if StrCmpW(GetAttrValue(node,'size'),'medium')=0 then - begin - WideToUTF8(GetText(node),data.image); - break; - end; - inc(i); - until false; - - // bio - p:=StrPosW(pcw,'nil then + + i:=StrLenW(pcw)*SizeOf(WideChar); + root:=xmlParseString(pcw,@i,nil); + + actnode:=xmlGetChild(xmlGetChild(root,0),0); // "artist" + + if data.artist=nil then + StrDupW(data.artist,xmlGetText(xmlGetNthChild(actnode,'name',0))); + + i:=0; + repeat + node:=xmlGetNthChild(actnode,'image',i); + if node=0 then break; + if StrCmpW(xmlGetAttrValue(node,'size'),'medium')=0 then begin - inc(p,18); - pp:=StrPosW(p,']]'); - if pp<> nil then pp^:=#0; - data.info:=FixInfo(p); + WideToUTF8(xmlGetText(node),data.image); + break; end; + inc(i); + until false; - // similar - i:=0; - pcw:=pWideChar(@request); pcw^:=#0; - node:=GetNthChild(actnode,'similar',0); - repeat - nnode:=GetNthChild(GetNthChild(node,'artist',i),'name',0); - if nnode=0 then break; - if pcw<>@request then - begin - pcw^:=','; inc(pcw); - pcw^:=' '; inc(pcw); - end; - pcw:=StrCopyEW(pcw,GetText(nnode)); - inc(i); - until false; - pcw:=#0; - StrDupW(data.similar,pWideChar(@request)); - - // tags - i:=0; - pcw:=pWideChar(@request); pcw^:=#0; - node:=GetNthChild(actnode,'tags',0); - repeat - nnode:=GetNthChild(GetNthChild(node,'tag',i),'name',0); - if nnode=0 then break; - if pcw<>@request then - begin - pcw^:=','; inc(pcw); - pcw^:=' '; inc(pcw); - end; - pcw:=StrCopyEW(pcw,GetText(nnode)); - inc(i); - until false; - pcw:=#0; - StrDupW(data.tags,pWideChar(@request)); - DestroyNode(root); + // bio + p:=StrPosW(pcw,'nil then + begin + inc(p,18); + pp:=StrPosW(p,']]'); + if pp<> nil then pp^:=#0; + data.info:=FixInfo(p); end; + + // similar + i:=0; + pcw:=pWideChar(@request); pcw^:=#0; + node:=xmlGetNthChild(actnode,'similar',0); + repeat + nnode:=xmlGetNthChild(xmlGetNthChild(node,'artist',i),'name',0); + if nnode=0 then break; + if pcw<>@request then + begin + pcw^:=','; inc(pcw); + pcw^:=' '; inc(pcw); + end; + pcw:=StrCopyEW(pcw,xmlGetText(nnode)); + inc(i); + until false; + pcw:=#0; + StrDupW(data.similar,pWideChar(@request)); + + // tags + i:=0; + pcw:=pWideChar(@request); pcw^:=#0; + node:=xmlGetNthChild(actnode,'tags',0); + repeat + nnode:=xmlGetNthChild(xmlGetNthChild(node,'tag',i),'name',0); + if nnode=0 then break; + if pcw<>@request then + begin + pcw^:=','; inc(pcw); + pcw^:=' '; inc(pcw); + end; + pcw:=StrCopyEW(pcw,xmlGetText(nnode)); + inc(i); + until false; + pcw:=#0; + StrDupW(data.tags,pWideChar(@request)); + xmlDestroyNode(root); end; end; @@ -424,62 +417,58 @@ begin begin UTF8ToWide(res,pcw); mFreeMem(res); - xmlparser.cbSize:={XML_API_SIZEOF_V1;//}SizeOf(TXML_API_W); - CallService(MS_SYSTEM_GET_XI,0,lparam(@xmlparser)); - with xmlparser do - begin - i:=StrLenW(pcw)*SizeOf(WideChar); - root:=parseString(pcw,@i,nil); - - actnode:=getChild(getChild(root,0),0); // "album" - - if data.album=nil then - StrDupW(data.album,getText(GetNthChild(actnode,'name',0))); - StrDupW(data.release,getText(GetNthChild(actnode,'releasedate',0))); - if data.artist=nil then - StrDupW(data.artist,getText(GetNthChild(actnode,'artist',0))); - - i:=0; - repeat - node:=GetNthChild(actnode,'image',i); - if node=0 then break; - if StrCmpW(GetAttrValue(node,'size'),'medium')=0 then - begin - WideToUTF8(GetText(node),data.image); - break; - end; - inc(i); - until false; - - p:=StrPosW(pcw,'nil then + + i:=StrLenW(pcw)*SizeOf(WideChar); + root:=xmlParseString(pcw,@i,nil); + + actnode:=xmlGetChild(xmlGetChild(root,0),0); // "album" + + if data.album=nil then + StrDupW(data.album,xmlGetText(xmlGetNthChild(actnode,'name',0))); + StrDupW(data.release,xmlGetText(xmlGetNthChild(actnode,'releasedate',0))); + if data.artist=nil then + StrDupW(data.artist,xmlGetText(xmlGetNthChild(actnode,'artist',0))); + + i:=0; + repeat + node:=xmlGetNthChild(actnode,'image',i); + if node=0 then break; + if StrCmpW(xmlGetAttrValue(node,'size'),'medium')=0 then begin - inc(p,18); - pp:=StrPosW(p,']]'); - if pp<> nil then pp^:=#0; - data.info:=FixInfo(p); + WideToUTF8(xmlGetText(node),data.image); + break; end; + inc(i); + until false; - // tags - i:=0; - pcw:=pWideChar(@request); pcw^:=#0; - node:=GetNthChild(actnode,'toptags',0); - repeat - nnode:=GetNthChild(GetNthChild(node,'tag',i),'name',0); - if nnode=0 then break; - if pcw<>@request then - begin - pcw^:=','; inc(pcw); - pcw^:=' '; inc(pcw); - end; - pcw:=StrCopyEW(pcw,GetText(nnode)); - inc(i); - until false; - pcw:=#0; - StrDupW(data.tags,pWideChar(@request)); - - DestroyNode(root); + p:=StrPosW(pcw,'nil then + begin + inc(p,18); + pp:=StrPosW(p,']]'); + if pp<> nil then pp^:=#0; + data.info:=FixInfo(p); end; + + // tags + i:=0; + pcw:=pWideChar(@request); pcw^:=#0; + node:=xmlGetNthChild(actnode,'toptags',0); + repeat + nnode:=xmlGetNthChild(xmlGetNthChild(node,'tag',i),'name',0); + if nnode=0 then break; + if pcw<>@request then + begin + pcw^:=','; inc(pcw); + pcw^:=' '; inc(pcw); + end; + pcw:=StrCopyEW(pcw,xmlGetText(nnode)); + inc(i); + until false; + pcw:=#0; + StrDupW(data.tags,pWideChar(@request)); + + xmlDestroyNode(root); end; end; @@ -532,66 +521,62 @@ begin begin UTF8ToWide(res,pcw); mFreeMem(res); - xmlparser.cbSize:={XML_API_SIZEOF_V1;//}SizeOf(TXML_API_W); - CallService(MS_SYSTEM_GET_XI,0,lparam(@xmlparser)); - with xmlparser do - begin - i:=StrLenW(pcw)*SizeOf(WideChar); - root:=parseString(pcw,@i,nil); - - actnode:=getChild(getChild(root,0),0); // "track" - if data.artist=nil then - StrDupW(data.artist,getText(GetNthChild(GetNthChild(actnode,'artist',0),'name',0))); - - anode:=GetNthChild(actnode,'album',i); - - if data.album=nil then - StrDupW(data.album,getText(GetNthChild(anode,'title',0))); - - data.trknum:=StrToInt(getAttrValue(anode,'position')); - if data.title=nil then - StrDupW(data.title,getText(GetNthChild(actnode,'name',0))); - - i:=0; - repeat - node:=GetNthChild(anode,'image',i); - if node=0 then break; - if StrCmpW(GetAttrValue(node,'size'),'medium')=0 then - begin - WideToUTF8(GetText(node),data.image); - break; - end; - inc(i); - until false; - - p:=StrPosW(pcw,'nil then + + i:=StrLenW(pcw)*SizeOf(WideChar); + root:=xmlParseString(pcw,@i,nil); + + actnode:=xmlGetChild(xmlGetChild(root,0),0); // "track" + if data.artist=nil then + StrDupW(data.artist,xmlGetText(xmlGetNthChild(xmlGetNthChild(actnode,'artist',0),'name',0))); + + anode:=xmlGetNthChild(actnode,'album',i); + + if data.album=nil then + StrDupW(data.album,xmlGetText(xmlGetNthChild(anode,'title',0))); + + data.trknum:=StrToInt(xmlGetAttrValue(anode,'position')); + if data.title=nil then + StrDupW(data.title,xmlGetText(xmlGetNthChild(actnode,'name',0))); + + i:=0; + repeat + node:=xmlGetNthChild(anode,'image',i); + if node=0 then break; + if StrCmpW(xmlGetAttrValue(node,'size'),'medium')=0 then begin - inc(p,18); - pp:=StrPosW(p,']]'); - if pp<> nil then pp^:=#0; - data.info:=FixInfo(p); + WideToUTF8(xmlGetText(node),data.image); + break; end; + inc(i); + until false; - // tags - i:=0; - pcw:=pWideChar(@request); pcw^:=#0; - node:=GetNthChild(actnode,'toptags',0); - repeat - anode:=GetNthChild(GetNthChild(node,'tag',i),'name',0); - if anode=0 then break; - if pcw<>@request then - begin - pcw^:=','; inc(pcw); - pcw^:=' '; inc(pcw); - end; - pcw:=StrCopyEW(pcw,GetText(anode)); - inc(i); - until false; - pcw:=#0; - StrDupW(data.tags,pWideChar(@request)); - - DestroyNode(root); + p:=StrPosW(pcw,'nil then + begin + inc(p,18); + pp:=StrPosW(p,']]'); + if pp<> nil then pp^:=#0; + data.info:=FixInfo(p); end; + + // tags + i:=0; + pcw:=pWideChar(@request); pcw^:=#0; + node:=xmlGetNthChild(actnode,'toptags',0); + repeat + anode:=xmlGetNthChild(xmlGetNthChild(node,'tag',i),'name',0); + if anode=0 then break; + if pcw<>@request then + begin + pcw^:=','; inc(pcw); + pcw^:=' '; inc(pcw); + end; + pcw:=StrCopyEW(pcw,xmlGetText(anode)); + inc(i); + until false; + pcw:=#0; + StrDupW(data.tags,pWideChar(@request)); + + xmlDestroyNode(root); end; end; -- cgit v1.2.3