binding.h 5.39 KB
Newer Older
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
/*
 * Copyright 2011 Jacek Caban for CodeWeavers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

typedef struct nsWineURI nsWineURI;

/* Keep sync with request_method_strings in nsio.c */
typedef enum {
    METHOD_GET,
    METHOD_PUT,
    METHOD_POST
} REQUEST_METHOD;

28 29 30 31 32 33
typedef enum {
    BOM_NONE,
    BOM_UTF8,
    BOM_UTF16
} binding_bom_t;

34 35 36 37 38 39 40 41 42 43 44 45 46
typedef struct {
    nsIHttpChannel         nsIHttpChannel_iface;
    nsIUploadChannel       nsIUploadChannel_iface;
    nsIHttpChannelInternal nsIHttpChannelInternal_iface;

    LONG ref;

    nsWineURI *uri;
    nsIInputStream *post_data_stream;
    BOOL post_data_contains_headers;
    nsILoadGroup *load_group;
    nsIInterfaceRequestor *notif_callback;
    nsISupports *owner;
47
    nsILoadInfo *load_info;
48 49 50 51 52
    nsLoadFlags load_flags;
    nsIURI *original_uri;
    nsIURI *referrer;
    char *content_type;
    char *charset;
53
    UINT32 response_status;
54
    char *response_status_text;
55 56 57
    REQUEST_METHOD request_method;
    struct list response_headers;
    struct list request_headers;
58 59

    nsChannelBSC *binding;
60 61
} nsChannel;

62
typedef struct {
63
    nsIInputStream *post_stream;
64 65 66 67 68
    WCHAR *headers;
    HGLOBAL post_data;
    ULONG post_data_len;
} request_data_t;

69 70 71
typedef struct BSCallbackVtbl BSCallbackVtbl;

struct BSCallback {
72 73 74 75 76
    IBindStatusCallback   IBindStatusCallback_iface;
    IServiceProvider      IServiceProvider_iface;
    IHttpNegotiate2       IHttpNegotiate2_iface;
    IInternetBindInfo     IInternetBindInfo_iface;
    IBindCallbackRedirect IBindCallbackRedirect_iface;
77 78 79 80 81

    const BSCallbackVtbl          *vtbl;

    LONG ref;

82
    request_data_t request_data;
83
    ULONG read;
84
    DWORD bindf;
85
    DWORD bindinfo_options;
86
    BOOL bindinfo_ready;
87
    binding_bom_t bom;
88 89 90 91

    IMoniker *mon;
    IBinding *binding;

92
    HTMLInnerWindow *window;
93 94 95 96 97 98 99 100 101 102 103 104 105

    struct list entry;
};

typedef struct nsProtocolStream nsProtocolStream;

struct nsChannelBSC {
    BSCallback bsc;

    nsChannel *nschannel;
    nsIStreamListener *nslistener;
    nsISupports *nscontext;
    BOOL is_js;
106
    BOOL is_doc_channel;
107
    BOOL response_processed;
108 109 110 111

    nsProtocolStream *nsstream;
};

112 113 114 115 116 117 118 119 120 121 122
struct BSCallbackVtbl {
    void (*destroy)(BSCallback*);
    HRESULT (*init_bindinfo)(BSCallback*);
    HRESULT (*start_binding)(BSCallback*);
    HRESULT (*stop_binding)(BSCallback*,HRESULT);
    HRESULT (*read_data)(BSCallback*,IStream*);
    HRESULT (*on_progress)(BSCallback*,ULONG,LPCWSTR);
    HRESULT (*on_response)(BSCallback*,DWORD,LPCWSTR);
    HRESULT (*beginning_transaction)(BSCallback*,WCHAR**);
};

123 124 125 126 127 128
typedef struct {
    struct list entry;
    WCHAR *header;
    WCHAR *data;
} http_header_t;

129 130
#define BINDING_NAVIGATED    0x0001
#define BINDING_REPLACE      0x0002
131
#define BINDING_FROMHIST     0x0004
132
#define BINDING_REFRESH      0x0008
133
#define BINDING_SUBMIT       0x0010
134
#define BINDING_NOFRAG       0x0020
135

136 137 138 139
HRESULT set_http_header(struct list*,const WCHAR*,int,const WCHAR*,int) DECLSPEC_HIDDEN;
HRESULT create_redirect_nschannel(const WCHAR*,nsChannel*,nsChannel**) DECLSPEC_HIDDEN;

HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsChannel*,DWORD,BOOL*) DECLSPEC_HIDDEN;
140
HRESULT create_doc_uri(IUri*,nsWineURI**) DECLSPEC_HIDDEN;
141
HRESULT load_nsuri(HTMLOuterWindow*,nsWineURI*,nsIInputStream*,nsChannelBSC*,DWORD) DECLSPEC_HIDDEN;
142
HRESULT set_moniker(HTMLOuterWindow*,IMoniker*,IUri*,IBindCtx*,nsChannelBSC*,BOOL) DECLSPEC_HIDDEN;
143 144
void prepare_for_binding(HTMLDocument*,IMoniker*,DWORD) DECLSPEC_HIDDEN;
HRESULT super_navigate(HTMLOuterWindow*,IUri*,DWORD,const WCHAR*,BYTE*,DWORD) DECLSPEC_HIDDEN;
145
HRESULT load_uri(HTMLOuterWindow*,IUri*,DWORD) DECLSPEC_HIDDEN;
146
HRESULT navigate_new_window(HTMLOuterWindow*,IUri*,const WCHAR*,request_data_t*,IHTMLWindow2**) DECLSPEC_HIDDEN;
147
HRESULT navigate_url(HTMLOuterWindow*,const WCHAR*,IUri*,DWORD) DECLSPEC_HIDDEN;
148
HRESULT submit_form(HTMLOuterWindow*,const WCHAR*,IUri*,nsIInputStream*) DECLSPEC_HIDDEN;
149
void process_document_response_headers(HTMLDocumentNode*,IBinding*) DECLSPEC_HIDDEN;
150

151
void init_bscallback(BSCallback*,const BSCallbackVtbl*,IMoniker*,DWORD) DECLSPEC_HIDDEN;
152
HRESULT create_channelbsc(IMoniker*,const WCHAR*,BYTE*,DWORD,BOOL,nsChannelBSC**) DECLSPEC_HIDDEN;
153
HRESULT channelbsc_load_stream(HTMLInnerWindow*,IMoniker*,IStream*) DECLSPEC_HIDDEN;
154
void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*) DECLSPEC_HIDDEN;
155
IUri *nsuri_get_uri(nsWineURI*) DECLSPEC_HIDDEN;
156

157 158
HRESULT read_stream(BSCallback*,IStream*,void*,DWORD,DWORD*) DECLSPEC_HIDDEN;

159 160
HRESULT create_relative_uri(HTMLOuterWindow*,const WCHAR*,IUri**) DECLSPEC_HIDDEN;
HRESULT create_uri(const WCHAR*,DWORD,IUri**) DECLSPEC_HIDDEN;
161 162
IUri *get_uri_nofrag(IUri*) DECLSPEC_HIDDEN;

163 164
void set_current_mon(HTMLOuterWindow*,IMoniker*,DWORD) DECLSPEC_HIDDEN;
void set_current_uri(HTMLOuterWindow*,IUri*) DECLSPEC_HIDDEN;