Commit 8abf7a8c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Rename nsChannel::content to content_type and clean up its handling.

parent 1caf73be
......@@ -241,7 +241,7 @@ typedef struct {
nsIInterfaceRequestor *notif_callback;
nsLoadFlags load_flags;
nsIURI *original_uri;
char *content;
char *content_type;
char *charset;
} nsChannel;
......@@ -568,6 +568,21 @@ static inline LPWSTR heap_strdupW(LPCWSTR str)
return ret;
}
static inline char *heap_strdupA(const char *str)
{
char *ret = NULL;
if(str) {
DWORD size;
size = strlen(str)+1;
ret = heap_alloc(size);
memcpy(ret, str, size);
}
return ret;
}
static inline WCHAR *heap_strdupAtoW(const char *str)
{
LPWSTR ret = NULL;
......@@ -583,6 +598,19 @@ static inline WCHAR *heap_strdupAtoW(const char *str)
return ret;
}
static inline char *heap_strdupWtoA(LPCWSTR str)
{
char *ret = NULL;
if(str) {
DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
ret = heap_alloc(size);
WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
}
return ret;
}
HINSTANCE get_shdoclc(void);
extern HINSTANCE hInst;
......@@ -884,17 +884,12 @@ static HRESULT nsChannelBSC_on_progress(BSCallback *bsc, ULONG status_code, LPCW
nsChannelBSC *This = NSCHANNELBSC_THIS(bsc);
switch(status_code) {
case BINDSTATUS_MIMETYPEAVAILABLE: {
int len;
case BINDSTATUS_MIMETYPEAVAILABLE:
if(!This->nschannel)
return S_OK;
heap_free(This->nschannel->content);
len = WideCharToMultiByte(CP_ACP, 0, status_text, -1, NULL, 0, NULL, NULL);
This->nschannel->content = heap_alloc(len*sizeof(WCHAR));
WideCharToMultiByte(CP_ACP, 0, status_text, -1, This->nschannel->content, -1, NULL, NULL);
}
heap_free(This->nschannel->content_type);
This->nschannel->content_type = heap_strdupWtoA(status_text);
}
return S_OK;
......@@ -958,10 +953,8 @@ HRESULT channelbsc_load_stream(nsChannelBSC *bscallback, IStream *stream)
add_nsrequest(bscallback);
if(bscallback->nschannel) {
bscallback->nschannel->content = heap_alloc(sizeof(text_html));
memcpy(bscallback->nschannel->content, text_html, sizeof(text_html));
}
if(bscallback->nschannel)
bscallback->nschannel->content_type = heap_strdupA(text_html);
hres = read_stream_data(bscallback, stream);
IBindStatusCallback_OnStopBinding(STATUSCLB(&bscallback->bsc), hres, ERROR_SUCCESS);
......
......@@ -209,7 +209,7 @@ static nsrefcnt NSAPI nsChannel_Release(nsIHttpChannel *iface)
nsIInterfaceRequestor_Release(This->notif_callback);
if(This->original_uri)
nsIURI_Release(This->original_uri);
heap_free(This->content);
heap_free(This->content_type);
heap_free(This->charset);
heap_free(This);
}
......@@ -468,8 +468,8 @@ static nsresult NSAPI nsChannel_GetContentType(nsIHttpChannel *iface, nsACString
TRACE("(%p)->(%p)\n", This, aContentType);
if(This->content) {
nsACString_SetData(aContentType, This->content);
if(This->content_type) {
nsACString_SetData(aContentType, This->content_type);
return S_OK;
}
......@@ -688,13 +688,8 @@ static nsresult async_open_doc_uri(nsChannel *This, NSContainer *container,
channelbsc_set_channel(container->bscallback, This, listener, context);
if(container->doc && container->doc->mime) {
DWORD len;
heap_free(This->content);
len = WideCharToMultiByte(CP_ACP, 0, container->doc->mime, -1, NULL, 0, NULL, NULL);
This->content = heap_alloc(len);
WideCharToMultiByte(CP_ACP, 0, container->doc->mime, -1, This->content, -1, NULL, NULL);
heap_free(This->content_type);
This->content_type = heap_strdupWtoA(container->doc->mime);
}
if(do_load_from_moniker_hack(This))
......@@ -2155,20 +2150,13 @@ static nsresult NSAPI nsIOService_NewChannelFromURI(nsIIOService *iface, nsIURI
return channel ? NS_OK : NS_ERROR_UNEXPECTED;
}
ret = heap_alloc(sizeof(nsChannel));
ret = heap_alloc_zero(sizeof(nsChannel));
ret->lpHttpChannelVtbl = &nsChannelVtbl;
ret->lpUploadChannelVtbl = &nsUploadChannelVtbl;
ret->ref = 1;
ret->channel = channel;
ret->http_channel = NULL;
ret->uri = wine_uri;
ret->post_data_stream = NULL;
ret->load_group = NULL;
ret->notif_callback = NULL;
ret->load_flags = 0;
ret->content = NULL;
ret->charset = NULL;
nsIURI_AddRef(aURI);
ret->original_uri = aURI;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment