Click here to Skip to main content
11,437,680 members (29,792 online)
Click here to Skip to main content
Add your own
alternative version

An Asynchronous Pluggable Protocol Handler for data: URLs

, 28 Jan 2006 CPOL
This article describes an asynchronous pluggable protocol implementation to support the data: protocol, as described in RFC 2397, in Internet Explorer.
dataprotocol_src.zip
DataProtocol
DataPluggableProtocol.rgs
DataProtocol.def
DataProtocol.rgs
DataProtocol.vcproj.CCC.ramakrishna.user
DataProtocolps.def
DataProtocolPS.vcproj.CCC.ramakrishna.user
// DataPluggableProtocol.h : Declaration of the CDataPluggableProtocol

#pragma once
#include "resource.h"       // main symbols

#include "DataProtocol.h"


#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif

// CDataPluggableProtocol

class ATL_NO_VTABLE CDataPluggableProtocol :
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CDataPluggableProtocol, &CLSID_DataPluggableProtocol>,
	public IInternetProtocol,
	public IInternetProtocolInfo
{
public:
	CDataPluggableProtocol()
		: m_dwPos(0)
	{
	}

DECLARE_REGISTRY_RESOURCEID(IDR_DATAPLUGGABLEPROTOCOL)


BEGIN_COM_MAP(CDataPluggableProtocol)
	COM_INTERFACE_ENTRY(IInternetProtocolInfo)
	COM_INTERFACE_ENTRY(IInternetProtocol)
	COM_INTERFACE_ENTRY(IInternetProtocolRoot)
END_COM_MAP()

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

// IInternetProtocol interface
public:
    STDMETHOD(Start)(
            LPCWSTR szUrl,
            IInternetProtocolSink *pIProtSink,
            IInternetBindInfo *pIBindInfo,
            DWORD grfSTI,
            DWORD dwReserved);
    STDMETHOD(Continue)(PROTOCOLDATA *pStateInfo);
    STDMETHOD(Abort)(HRESULT hrReason,DWORD dwOptions);
    STDMETHOD(Terminate)(DWORD dwOptions);
    STDMETHOD(Suspend)();
    STDMETHOD(Resume)();
    STDMETHOD(Read)(void *pv,ULONG cb,ULONG *pcbRead);
    STDMETHOD(Seek)(
            LARGE_INTEGER dlibMove,
            DWORD dwOrigin,
            ULARGE_INTEGER *plibNewPosition);
    STDMETHOD(LockRequest)(DWORD dwOptions);
    STDMETHOD(UnlockRequest)();

// IInternetProtocolInfo interface
public:
	STDMETHOD(CombineUrl)(LPCWSTR pwzBaseUrl, LPCWSTR pwzRelativeUrl, DWORD dwCombineFlags,
		LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved);
	STDMETHOD(CompareUrl)(LPCWSTR pwzUrl1, LPCWSTR pwzUrl2, DWORD dwCompareFlags);
	STDMETHOD(ParseUrl)(LPCWSTR pwzUrl, PARSEACTION ParseAction, DWORD dwParseFlags,
		LPWSTR pwzResult, DWORD cchResult, DWORD *pcchResult, DWORD dwReserved);
	STDMETHOD(QueryInfo)( LPCWSTR pwzUrl, QUERYOPTION QueryOption, DWORD dwQueryFlags,
		LPVOID pBuffer, DWORD cbBuffer, DWORD *pcbBuf, DWORD dwReserved);

private:
	CComPtr<IInternetProtocolSink> m_spSink;
	CComPtr<IInternetBindInfo> m_spBindInfo;
	CDataURL m_url;
	DWORD m_dwPos;
};

OBJECT_ENTRY_AUTO(__uuidof(DataPluggableProtocol), CDataPluggableProtocol)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Rama Krishna Vavilala
Architect
United States United States
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150506.1 | Last Updated 28 Jan 2006
Article Copyright 2006 by Rama Krishna Vavilala
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid