From 5f7961a471c1027e32297099de33769a4247a60d Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Thu, 30 Apr 2015 18:47:31 +0000 Subject: git-svn-id: http://svn.miranda-ng.org/main/trunk@13301 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/common.h | 2 +- protocols/SkypeWeb/src/skype_proto.h | 5 ++ protocols/SkypeWeb/src/skype_utils.cpp | 101 ++++++++++++++++++++++++++++++++- 3 files changed, 106 insertions(+), 2 deletions(-) (limited to 'protocols/SkypeWeb/src') diff --git a/protocols/SkypeWeb/src/common.h b/protocols/SkypeWeb/src/common.h index d7d18ed018..6306328ee8 100644 --- a/protocols/SkypeWeb/src/common.h +++ b/protocols/SkypeWeb/src/common.h @@ -21,7 +21,7 @@ along with this program. If not, see . #include #include #include - +#include #include #include #include diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index bc5ac7bafc..659ee8880a 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -20,6 +20,7 @@ along with this program. If not, see . typedef void(CSkypeProto::*SkypeResponseCallback)(const NETLIBHTTPREQUEST *response); typedef void(CSkypeProto::*SkypeResponseWithArgCallback)(const NETLIBHTTPREQUEST *response, void *arg); +typedef HRESULT(MarkupCallback)(IHTMLDocument3 *, BSTR &message); struct CSkypeProto : public PROTO < CSkypeProto > { @@ -291,6 +292,10 @@ private: char *SelfUrlToName (const char *url); char *GetServerFromUrl (const char *url); + LPCTSTR ClearText(CMString &result, const TCHAR *message); + HRESULT TestDocumentText(IHTMLDocument3 *pHtmlDoc, BSTR &message); + HRESULT TestMarkupServices(BSTR bstrHtml, MarkupCallback *pCallback, BSTR &message); + //services INT_PTR __cdecl OnIncomingCallCLE (WPARAM wParam, LPARAM lParam); INT_PTR __cdecl OnIncomingCallPP (WPARAM wParam, LPARAM lParam); diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp index d029be8cc3..514baf4e34 100644 --- a/protocols/SkypeWeb/src/skype_utils.cpp +++ b/protocols/SkypeWeb/src/skype_utils.cpp @@ -585,4 +585,103 @@ INT_PTR CSkypeProto::GlobalParseSkypeUriService(WPARAM wParam, LPARAM lParam) return Accounts[i]->ParseSkypeUriService(wParam, lParam); return 1; -} \ No newline at end of file +} +/* +LPCTSTR CSkypeProto::ClearText(CMString &result, const TCHAR *message) +{ + BSTR bstrHtml = SysAllocString(message), bstrRes = SysAllocString(_T("")); + HRESULT hr = TestMarkupServices(bstrHtml, &TestDocumentText, bstrRes); + if (SUCCEEDED(hr)) + result = bstrRes; + else + result = message; + SysFreeString(bstrHtml); + SysFreeString(bstrRes); + + return result; +} + +HRESULT CSkypeProto::TestDocumentText(IHTMLDocument3 *pHtmlDoc, BSTR &message) +{ + IHTMLDocument2 *pDoc = NULL; + IHTMLElement *pElem = NULL; + BSTR bstrId = SysAllocString(L"test"); + + HRESULT hr = pHtmlDoc->QueryInterface(IID_PPV_ARGS(&pDoc)); + if (SUCCEEDED(hr) && pDoc) { + hr = pDoc->get_body(&pElem); + if (SUCCEEDED(hr) && pElem) { + BSTR bstrText = NULL; + pElem->get_innerText(&bstrText); + message = SysAllocString(bstrText); + SysFreeString(bstrText); + pElem->Release(); + } + + pDoc->Release(); + } + + SysFreeString(bstrId); + return hr; +} + + + +HRESULT CSkypeProto::TestMarkupServices(BSTR bstrHtml, MarkupCallback *pCallback, BSTR &message) +{ + IHTMLDocument3 *pHtmlDocRoot = NULL; + + // Create the root document -- a "workspace" for parsing. + HRESULT hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pHtmlDocRoot)); + if (SUCCEEDED(hr) && pHtmlDocRoot) { + IPersistStreamInit *pPersistStreamInit = NULL; + + HRESULT hr = pHtmlDocRoot->QueryInterface(IID_PPV_ARGS(&pPersistStreamInit)); + if (SUCCEEDED(hr)) { + // Initialize the root document to a default state -- ready for parsing. + pPersistStreamInit->InitNew(); + + IMarkupServices *pMarkupServices = NULL; + hr = pHtmlDocRoot->QueryInterface(IID_PPV_ARGS(&pMarkupServices)); + if (SUCCEEDED(hr)) { + IMarkupPointer *pMarkupBegin = NULL; + IMarkupPointer *pMarkupEnd = NULL; + + // These markup pointers indicate the insertion point. + hr = pMarkupServices->CreateMarkupPointer(&pMarkupBegin); + if (SUCCEEDED(hr)) + hr = pMarkupServices->CreateMarkupPointer(&pMarkupEnd); + + if (SUCCEEDED(hr) && pMarkupBegin && pMarkupEnd) { + IMarkupContainer *pMarkupContainer = NULL; + + // Parse the string -- the markup container contains the parsed HTML. + // Markup pointers are updated to point to begining and end of new container. + hr = pMarkupServices->ParseString(bstrHtml, 0, &pMarkupContainer, pMarkupBegin, pMarkupEnd); + if (SUCCEEDED(hr) && pMarkupContainer) { + IHTMLDocument3 *pHtmlDoc = NULL; + + // Retrieve the document interface to the markup container. + hr = pMarkupContainer->QueryInterface(IID_PPV_ARGS(&pHtmlDoc)); + if (SUCCEEDED(hr) && pHtmlDoc) { + // Invoke the user-defined action for this new fragment. + hr = pCallback(pHtmlDoc, message); + + // Clean up. + pHtmlDoc->Release(); + } + pMarkupContainer->Release(); + } + pMarkupEnd->Release(); + } + if (pMarkupBegin) + pMarkupBegin->Release(); + pMarkupServices->Release(); + } + pPersistStreamInit->Release(); + } + pHtmlDocRoot->Release(); + } + return hr; +} +*/ \ No newline at end of file -- cgit v1.2.3