DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Implementation

Untracked file

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
/* 
 * The contents of this file are subject to the Mozilla Public
 * License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 * 
 * The Original Code is the Netscape security libraries.
 * 
 * The Initial Developer of the Original Code is Netscape
 * Communications Corporation.  Portions created by Netscape are 
 * Copyright (C) 1994-2000 Netscape Communications Corporation.  All
 * Rights Reserved.
 * 
 * Contributor(s):
 *
 *   Adam Lock <adamlock@netscape.com> 
 *
 * Alternatively, the contents of this file may be used under the
 * terms of the GNU General Public License Version 2 or later (the
 * "GPL"), in which case the provisions of the GPL are applicable 
 * instead of those above.  If you wish to allow use of your 
 * version of this file only under the terms of the GPL and not to
 * allow others to use your version of this file under the MPL,
 * indicate your decision by deleting the provisions above and
 * replace them with the notice and other provisions required by
 * the GPL.  If you do not delete the provisions above, a recipient
 * may use your version of this file under either the MPL or the
 * GPL.
 */
#ifndef __NSURLDATACALLBACK_H_
#define __NSURLDATACALLBACK_H_

#include "resource.h"       // main symbols

#include <stdio.h>

#include "npapi.h"

class nsPluginHostCtrl;

#define WM_NPP_NEWSTREAM      WM_USER 
#define WM_NPP_DESTROYSTREAM  WM_USER + 1
#define WM_NPP_URLNOTIFY      WM_USER + 2
#define WM_NPP_WRITEREADY     WM_USER + 3
#define WM_NPP_WRITE          WM_USER + 4

#define WM_CLASS_CLEANUP      WM_USER + 10
#define WM_CLASS_CREATEPLUGININSTANCE WM_USER + 11

struct _DestroyStreamData
{
    NPP npp;
    NPStream *stream;
    NPReason reason;
};

struct _UrlNotifyData
{
    NPP npp;
    char *url;
    NPReason reason;
    void *notifydata;
};

struct _NewStreamData
{
    NPP npp;
    char *contenttype;
    NPStream *stream;
    NPBool seekable;
    uint16 *stype;
};

struct _WriteReadyData
{
    NPP npp;
    NPStream *stream;
    int32 result;
};

struct _WriteData
{
    NPP npp;
    NPStream *stream;
    int32 offset;
    int32 len;
    void* buffer;
};

/////////////////////////////////////////////////////////////////////////////
// nsURLDataCallback
class ATL_NO_VTABLE nsURLDataCallback : 
    public CComObjectRootEx<CComMultiThreadModel>,
    public CWindowImpl<nsURLDataCallback, CWindow, CNullTraits>,
    public CComCoClass<nsURLDataCallback, &CLSID_NULL>,
    public IBindStatusCallback,
    public IAuthenticate
{
public:
    nsURLDataCallback();

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(nsURLDataCallback)
    COM_INTERFACE_ENTRY(IBindStatusCallback)
    COM_INTERFACE_ENTRY(IAuthenticate)
END_COM_MAP()

    DECLARE_WND_CLASS(_T("MozStreamWindow"))

BEGIN_MSG_MAP(nsURLDataCallback)
    MESSAGE_HANDLER(WM_NPP_NEWSTREAM, OnNPPNewStream)
    MESSAGE_HANDLER(WM_NPP_DESTROYSTREAM, OnNPPDestroyStream)
    MESSAGE_HANDLER(WM_NPP_URLNOTIFY, OnNPPURLNotify)
    MESSAGE_HANDLER(WM_NPP_WRITEREADY, OnNPPWriteReady)
    MESSAGE_HANDLER(WM_NPP_WRITE, OnNPPWrite)
    MESSAGE_HANDLER(WM_CLASS_CLEANUP, OnClassCleanup)
    MESSAGE_HANDLER(WM_CLASS_CREATEPLUGININSTANCE, OnClassCreatePluginInstance)
END_MSG_MAP()

    LRESULT OnNPPNewStream(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
    LRESULT OnNPPDestroyStream(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
    LRESULT OnNPPURLNotify(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
    LRESULT OnNPPWriteReady(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
    LRESULT OnNPPWrite(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);

    LRESULT OnClassCreatePluginInstance(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
    LRESULT OnClassCleanup(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);

protected:
    virtual ~nsURLDataCallback();

protected:
    nsPluginHostCtrl *m_pOwner;
    void *m_pNotifyData;
    HGLOBAL m_hPostData;

    NPStream m_NPStream;
    unsigned long m_nDataPos;
    unsigned long m_nDataMax;

    char *m_szContentType;
    char *m_szURL;

    BOOL m_bSaveToTempFile;
    BOOL m_bNotifyOnWrite;
    FILE *m_pTempFile;
    char *m_szTempFileName;

    CComPtr<IBinding> m_cpBinding;

    void SetURL(const char *szURL)
    {
        if (m_szURL) { free(m_szURL); m_szURL = NULL; }
        if (szURL) { m_szURL = strdup(szURL); }
    }
    void SetContentType(const char *szContentType)
    {
        if (m_szContentType) { free(m_szContentType); m_szContentType = NULL; }
        if (szContentType) { m_szContentType = strdup(szContentType); }
    }
    void SetPostData(const void *pData, unsigned long nSize);
    void SetOwner(nsPluginHostCtrl *pOwner) { m_pOwner = pOwner; }
    void SetNotifyData(void *pNotifyData)   { m_pNotifyData = pNotifyData; }
    
    static void __cdecl StreamThread(void *pThis);

public:
    static HRESULT OpenURL(nsPluginHostCtrl *pOwner, const TCHAR *szURL, void *pNotifyData, const void *pData, unsigned long nSize);

// IBindStatusCallback
public:
    virtual HRESULT STDMETHODCALLTYPE OnStartBinding( 
        /* [in] */ DWORD dwReserved,
        /* [in] */ IBinding __RPC_FAR *pib);
    
    virtual HRESULT STDMETHODCALLTYPE GetPriority( 
        /* [out] */ LONG __RPC_FAR *pnPriority);
    
    virtual HRESULT STDMETHODCALLTYPE OnLowResource( 
        /* [in] */ DWORD reserved);
    
    virtual HRESULT STDMETHODCALLTYPE OnProgress( 
        /* [in] */ ULONG ulProgress,
        /* [in] */ ULONG ulProgressMax,
        /* [in] */ ULONG ulStatusCode,
        /* [in] */ LPCWSTR szStatusText);
    
    virtual HRESULT STDMETHODCALLTYPE OnStopBinding( 
        /* [in] */ HRESULT hresult,
        /* [unique][in] */ LPCWSTR szError);
    
    virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetBindInfo( 
        /* [out] */ DWORD __RPC_FAR *grfBINDF,
        /* [unique][out][in] */ BINDINFO __RPC_FAR *pbindinfo);
    
    virtual /* [local] */ HRESULT STDMETHODCALLTYPE OnDataAvailable( 
        /* [in] */ DWORD grfBSCF,
        /* [in] */ DWORD dwSize,
        /* [in] */ FORMATETC __RPC_FAR *pformatetc,
        /* [in] */ STGMEDIUM __RPC_FAR *pstgmed);
    
    virtual HRESULT STDMETHODCALLTYPE OnObjectAvailable( 
        /* [in] */ REFIID riid,
        /* [iid_is][in] */ IUnknown __RPC_FAR *punk);

// IAuthenticate
public:
    virtual HRESULT STDMETHODCALLTYPE Authenticate( 
        /* [out] */ HWND __RPC_FAR *phwnd,
        /* [out] */ LPWSTR __RPC_FAR *pszUsername,
        /* [out] */ LPWSTR __RPC_FAR *pszPassword);
};

#endif //__NSURLDATACALLBACK_H_