- Sync comctl32, cryptui, mlang, msctf, netapi32, ole32, urlmon with Wine head

svn path=/trunk/; revision=39900
This commit is contained in:
Dmitry Chapyshev 2009-03-07 08:34:55 +00:00
parent 7db98868de
commit b69eed875d
16 changed files with 368 additions and 804 deletions

View file

@ -762,6 +762,7 @@ STATUSBAR_SetTextT (STATUS_INFO *infoPtr, INT nPart, WORD style,
part->text = (LPWSTR)text; part->text = (LPWSTR)text;
} else { } else {
LPWSTR ntext; LPWSTR ntext;
WCHAR *idx;
if (text && !isW) { if (text && !isW) {
LPCSTR atxt = (LPCSTR)text; LPCSTR atxt = (LPCSTR)text;
@ -775,6 +776,16 @@ STATUSBAR_SetTextT (STATUS_INFO *infoPtr, INT nPart, WORD style,
strcpyW (ntext, text); strcpyW (ntext, text);
} else ntext = 0; } else ntext = 0;
/* replace nonprintable characters with spaces */
if (ntext) {
idx = ntext;
while (*idx) {
if(!isprintW(*idx))
*idx = ' ';
idx++;
}
}
/* check if text is unchanged -> no need to redraw */ /* check if text is unchanged -> no need to redraw */
if (text) { if (text) {
if (!changed && part->text && !lstrcmpW(ntext, part->text)) { if (!changed && part->text && !lstrcmpW(ntext, part->text)) {

View file

@ -2306,11 +2306,13 @@ TREEVIEW_DrawItemLines(const TREEVIEW_INFO *infoPtr, HDC hdc, const TREEVIEW_ITE
& (TVS_LINESATROOT|TVS_HASLINES|TVS_HASBUTTONS)) & (TVS_LINESATROOT|TVS_HASLINES|TVS_HASBUTTONS))
> TVS_LINESATROOT); > TVS_LINESATROOT);
HBRUSH hbr, hbrOld; HBRUSH hbr, hbrOld;
COLORREF clrBk = infoPtr->clrBk == -1 ? GetSysColor(COLOR_WINDOW):
infoPtr->clrBk;
if (!lar && item->iLevel == 0) if (!lar && item->iLevel == 0)
return; return;
hbr = CreateSolidBrush(infoPtr->clrBk); hbr = CreateSolidBrush(clrBk);
hbrOld = SelectObject(hdc, hbr); hbrOld = SelectObject(hdc, hbr);
centerx = (item->linesOffset + item->stateOffset) / 2; centerx = (item->linesOffset + item->stateOffset) / 2;
@ -2423,8 +2425,8 @@ TREEVIEW_DrawItemLines(const TREEVIEW_INFO *infoPtr, HDC hdc, const TREEVIEW_ITE
{ {
Rectangle(hdc, centerx - 1, centery - plussize + 1, Rectangle(hdc, centerx - 1, centery - plussize + 1,
centerx + 2, centery + plussize); centerx + 2, centery + plussize);
SetPixel(hdc, centerx - 1, centery, infoPtr->clrBk); SetPixel(hdc, centerx - 1, centery, clrBk);
SetPixel(hdc, centerx + 1, centery, infoPtr->clrBk); SetPixel(hdc, centerx + 1, centery, clrBk);
} }
} }
} }
@ -2472,7 +2474,8 @@ TREEVIEW_DrawItem(const TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem
} }
else else
{ {
nmcdhdr.clrTextBk = infoPtr->clrBk; nmcdhdr.clrTextBk = infoPtr->clrBk == -1 ? GetSysColor(COLOR_WINDOW):
infoPtr->clrBk;
if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (wineItem == infoPtr->hotItem)) if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (wineItem == infoPtr->hotItem))
nmcdhdr.clrText = comctl32_color.clrHighlight; nmcdhdr.clrText = comctl32_color.clrHighlight;
else if (infoPtr->clrText == -1) else if (infoPtr->clrText == -1)
@ -2782,9 +2785,12 @@ TREEVIEW_UpdateScrollBars(TREEVIEW_INFO *infoPtr)
static LRESULT static LRESULT
TREEVIEW_EraseBackground(const TREEVIEW_INFO *infoPtr, HDC hDC) TREEVIEW_EraseBackground(const TREEVIEW_INFO *infoPtr, HDC hDC)
{ {
HBRUSH hBrush = CreateSolidBrush(infoPtr->clrBk); HBRUSH hBrush;
COLORREF clrBk = infoPtr->clrBk == -1 ? GetSysColor(COLOR_WINDOW):
infoPtr->clrBk;
RECT rect; RECT rect;
hBrush = CreateSolidBrush(clrBk);
GetClientRect(infoPtr->hwnd, &rect); GetClientRect(infoPtr->hwnd, &rect);
FillRect(hDC, &rect, hBrush); FillRect(hDC, &rect, hBrush);
DeleteObject(hBrush); DeleteObject(hBrush);
@ -4942,7 +4948,7 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
infoPtr->scrollX = 0; infoPtr->scrollX = 0;
infoPtr->clrBk = GetSysColor(COLOR_WINDOW); infoPtr->clrBk = -1; /* use system color */
infoPtr->clrText = -1; /* use system color */ infoPtr->clrText = -1; /* use system color */
infoPtr->clrLine = RGB(128, 128, 128); infoPtr->clrLine = RGB(128, 128, 128);
infoPtr->clrInsertMark = GetSysColor(COLOR_BTNTEXT); infoPtr->clrInsertMark = GetSysColor(COLOR_BTNTEXT);

View file

@ -3236,8 +3236,7 @@ static WCHAR *get_cert_property_as_string(PCCERT_CONTEXT cert, DWORD prop)
name = HeapAlloc(GetProcessHeap(), 0, cb); name = HeapAlloc(GetProcessHeap(), 0, cb);
if (name) if (name)
{ {
if (!CertGetCertificateContextProperty(cert, prop, (LPBYTE)name, if (!CertGetCertificateContextProperty(cert, prop, name, &cb))
&cb))
{ {
HeapFree(GetProcessHeap(), 0, name); HeapFree(GetProcessHeap(), 0, name);
name = NULL; name = NULL;
@ -4460,7 +4459,7 @@ static BOOL is_ca_cert(PCCERT_CONTEXT cert, BOOL defaultIfNotSpecified)
if (CryptDecodeObjectEx(X509_ASN_ENCODING, szOID_BASIC_CONSTRAINTS, if (CryptDecodeObjectEx(X509_ASN_ENCODING, szOID_BASIC_CONSTRAINTS,
ext->Value.pbData, ext->Value.cbData, CRYPT_DECODE_ALLOC_FLAG, ext->Value.pbData, ext->Value.cbData, CRYPT_DECODE_ALLOC_FLAG,
NULL, (LPBYTE)&info, &size)) NULL, &info, &size))
{ {
if (info->SubjectType.cbData == 1) if (info->SubjectType.cbData == 1)
isCA = info->SubjectType.pbData[0] & CERT_CA_SUBJECT_FLAG; isCA = info->SubjectType.pbData[0] & CERT_CA_SUBJECT_FLAG;

View file

@ -1495,7 +1495,7 @@ typedef struct tagEnumCodePage_impl
static inline EnumCodePage_impl *impl_from_IEnumCodePage( IEnumCodePage *iface ) static inline EnumCodePage_impl *impl_from_IEnumCodePage( IEnumCodePage *iface )
{ {
return (EnumCodePage_impl *)CONTAINING_RECORD( iface, EnumCodePage_impl, vtbl_IEnumCodePage ); return CONTAINING_RECORD( iface, EnumCodePage_impl, vtbl_IEnumCodePage );
} }
static HRESULT WINAPI fnIEnumCodePage_QueryInterface( static HRESULT WINAPI fnIEnumCodePage_QueryInterface(
@ -1688,7 +1688,7 @@ typedef struct tagEnumScript_impl
static inline EnumScript_impl *impl_from_IEnumScript( IEnumScript *iface ) static inline EnumScript_impl *impl_from_IEnumScript( IEnumScript *iface )
{ {
return (EnumScript_impl *)CONTAINING_RECORD( iface, EnumScript_impl, vtbl_IEnumScript ); return CONTAINING_RECORD( iface, EnumScript_impl, vtbl_IEnumScript );
} }
static HRESULT WINAPI fnIEnumScript_QueryInterface( static HRESULT WINAPI fnIEnumScript_QueryInterface(
@ -1850,7 +1850,7 @@ static HRESULT EnumScript_create( MLang_impl* mlang, DWORD dwFlags,
static inline MLang_impl *impl_from_IMLangFontLink( IMLangFontLink *iface ) static inline MLang_impl *impl_from_IMLangFontLink( IMLangFontLink *iface )
{ {
return (MLang_impl *)CONTAINING_RECORD( iface, MLang_impl, vtbl_IMLangFontLink ); return CONTAINING_RECORD( iface, MLang_impl, vtbl_IMLangFontLink );
} }
static HRESULT WINAPI fnIMLangFontLink_QueryInterface( static HRESULT WINAPI fnIMLangFontLink_QueryInterface(
@ -1954,7 +1954,7 @@ static HRESULT WINAPI fnIMLangFontLink_CodePageToCodePages(
TRACE("(%p) Seeking %u\n",This, uCodePage); TRACE("(%p) Seeking %u\n",This, uCodePage);
rc = TranslateCharsetInfo((DWORD*)uCodePage, &cs, TCI_SRCCODEPAGE); rc = TranslateCharsetInfo((DWORD*)(DWORD_PTR)uCodePage, &cs, TCI_SRCCODEPAGE);
if (rc) if (rc)
{ {
@ -1985,7 +1985,8 @@ static HRESULT WINAPI fnIMLangFontLink_CodePagesToCodePage(
*puCodePage = 0x00000000; *puCodePage = 0x00000000;
rc = TranslateCharsetInfo((DWORD*)uDefaultCodePage, &cs, TCI_SRCCODEPAGE); rc = TranslateCharsetInfo((DWORD*)(DWORD_PTR)uDefaultCodePage, &cs,
TCI_SRCCODEPAGE);
if (rc && (dwCodePages & cs.fs.fsCsb[0])) if (rc && (dwCodePages & cs.fs.fsCsb[0]))
{ {
@ -2087,7 +2088,7 @@ static const IMLangFontLinkVtbl IMLangFontLink_vtbl =
static inline MLang_impl *impl_from_IMultiLanguage( IMultiLanguage *iface ) static inline MLang_impl *impl_from_IMultiLanguage( IMultiLanguage *iface )
{ {
return (MLang_impl *)CONTAINING_RECORD( iface, MLang_impl, vtbl_IMultiLanguage ); return CONTAINING_RECORD( iface, MLang_impl, vtbl_IMultiLanguage );
} }
static HRESULT WINAPI fnIMultiLanguage_QueryInterface( static HRESULT WINAPI fnIMultiLanguage_QueryInterface(
@ -2280,7 +2281,7 @@ typedef struct tagEnumRfc1766_impl
static inline EnumRfc1766_impl *impl_from_IEnumRfc1766( IEnumRfc1766 *iface ) static inline EnumRfc1766_impl *impl_from_IEnumRfc1766( IEnumRfc1766 *iface )
{ {
return (EnumRfc1766_impl *)CONTAINING_RECORD( iface, EnumRfc1766_impl, vtbl_IEnumRfc1766 ); return CONTAINING_RECORD( iface, EnumRfc1766_impl, vtbl_IEnumRfc1766 );
} }
static HRESULT WINAPI fnIEnumRfc1766_QueryInterface( static HRESULT WINAPI fnIEnumRfc1766_QueryInterface(
@ -2550,7 +2551,7 @@ static const IMultiLanguageVtbl IMultiLanguage_vtbl =
static inline MLang_impl *impl_from_IMultiLanguage3( IMultiLanguage3 *iface ) static inline MLang_impl *impl_from_IMultiLanguage3( IMultiLanguage3 *iface )
{ {
return (MLang_impl *)CONTAINING_RECORD( iface, MLang_impl, vtbl_IMultiLanguage3 ); return CONTAINING_RECORD( iface, MLang_impl, vtbl_IMultiLanguage3 );
} }
static HRESULT WINAPI fnIMultiLanguage2_QueryInterface( static HRESULT WINAPI fnIMultiLanguage2_QueryInterface(
@ -2592,7 +2593,8 @@ static void fill_cp_info(const struct mlang_data *ml_data, UINT index, MIMECPINF
{ {
CHARSETINFO csi; CHARSETINFO csi;
if (TranslateCharsetInfo((DWORD *)ml_data->family_codepage, &csi, TCI_SRCCODEPAGE)) if (TranslateCharsetInfo((DWORD*)(DWORD_PTR)ml_data->family_codepage, &csi,
TCI_SRCCODEPAGE))
mime_cp_info->bGDICharset = csi.ciCharset; mime_cp_info->bGDICharset = csi.ciCharset;
else else
mime_cp_info->bGDICharset = DEFAULT_CHARSET; mime_cp_info->bGDICharset = DEFAULT_CHARSET;
@ -3169,7 +3171,7 @@ static const IMultiLanguage3Vtbl IMultiLanguage3_vtbl =
static inline MLang_impl *impl_from_IMLangFontLink2( IMLangFontLink2 *iface ) static inline MLang_impl *impl_from_IMLangFontLink2( IMLangFontLink2 *iface )
{ {
return (MLang_impl *)CONTAINING_RECORD( iface, MLang_impl, vtbl_IMLangFontLink2 ); return CONTAINING_RECORD( iface, MLang_impl, vtbl_IMLangFontLink2 );
} }
static HRESULT WINAPI fnIMLangFontLink2_QueryInterface( static HRESULT WINAPI fnIMLangFontLink2_QueryInterface(
@ -3323,7 +3325,7 @@ static const IMLangFontLink2Vtbl IMLangFontLink2_vtbl =
static inline MLang_impl *impl_from_IMLangLineBreakConsole( IMLangLineBreakConsole *iface ) static inline MLang_impl *impl_from_IMLangLineBreakConsole( IMLangLineBreakConsole *iface )
{ {
return (MLang_impl *)CONTAINING_RECORD( iface, MLang_impl, vtbl_IMLangLineBreakConsole ); return CONTAINING_RECORD( iface, MLang_impl, vtbl_IMLangLineBreakConsole );
} }
static HRESULT WINAPI fnIMLangLineBreakConsole_QueryInterface( static HRESULT WINAPI fnIMLangLineBreakConsole_QueryInterface(

View file

@ -148,7 +148,7 @@ static HRESULT ClassFactory_Constructor(LPFNCONSTRUCTOR ctor, LPVOID *ppvOut)
This->vtbl = &ClassFactoryVtbl; This->vtbl = &ClassFactoryVtbl;
This->ref = 1; This->ref = 1;
This->ctor = ctor; This->ctor = ctor;
*ppvOut = (LPVOID)This; *ppvOut = This;
TRACE("Created class factory %p\n", This); TRACE("Created class factory %p\n", This);
MSCTF_refCount++; MSCTF_refCount++;
return S_OK; return S_OK;
@ -217,7 +217,7 @@ HRESULT WINAPI TF_CreateThreadMgr(ITfThreadMgr **pptim)
HRESULT WINAPI TF_GetThreadMgr(ITfThreadMgr **pptim) HRESULT WINAPI TF_GetThreadMgr(ITfThreadMgr **pptim)
{ {
TRACE("\n"); TRACE("\n");
*pptim = (ITfThreadMgr*)TlsGetValue(tlsIndex); *pptim = TlsGetValue(tlsIndex);
if (*pptim) if (*pptim)
ITfThreadMgr_AddRef(*pptim); ITfThreadMgr_AddRef(*pptim);

View file

@ -658,7 +658,7 @@ NetQueryDisplayInformation(
admin_size - sizeof(NET_DISPLAY_USER) + admin_size - sizeof(NET_DISPLAY_USER) +
guest_size - sizeof(NET_DISPLAY_USER), guest_size - sizeof(NET_DISPLAY_USER),
SortedBuffer); SortedBuffer);
inf = (PNET_DISPLAY_USER) *SortedBuffer; inf = *SortedBuffer;
str = (LPWSTR) ((PBYTE) inf + sizeof(NET_DISPLAY_USER) * records); str = (LPWSTR) ((PBYTE) inf + sizeof(NET_DISPLAY_USER) * records);
inf->usri1_name = str; inf->usri1_name = str;
str = (LPWSTR) ( str = (LPWSTR) (
@ -826,8 +826,7 @@ NET_API_STATUS WINAPI NetUserModalsGet(
} }
umi = (USER_MODALS_INFO_2 *) *pbuffer; umi = (USER_MODALS_INFO_2 *) *pbuffer;
umi->usrmod2_domain_id = (PSID)(*pbuffer + umi->usrmod2_domain_id = *pbuffer + sizeof(USER_MODALS_INFO_2);
sizeof(USER_MODALS_INFO_2));
umi->usrmod2_domain_name = (LPWSTR)(*pbuffer + umi->usrmod2_domain_name = (LPWSTR)(*pbuffer +
sizeof(USER_MODALS_INFO_2) + GetLengthSid(domainIdentifier)); sizeof(USER_MODALS_INFO_2) + GetLengthSid(domainIdentifier));

View file

@ -400,7 +400,7 @@ typedef struct _NetBTNameQueryData {
static BOOL NetBTFindNameAnswerCallback(void *pVoid, WORD answerCount, static BOOL NetBTFindNameAnswerCallback(void *pVoid, WORD answerCount,
WORD answerIndex, PUCHAR rData, WORD rLen) WORD answerIndex, PUCHAR rData, WORD rLen)
{ {
NetBTNameQueryData *queryData = (NetBTNameQueryData *)pVoid; NetBTNameQueryData *queryData = pVoid;
BOOL ret; BOOL ret;
if (queryData) if (queryData)
@ -696,7 +696,7 @@ typedef struct _NetBTNodeQueryData
static BOOL NetBTNodeStatusAnswerCallback(void *pVoid, WORD answerCount, static BOOL NetBTNodeStatusAnswerCallback(void *pVoid, WORD answerCount,
WORD answerIndex, PUCHAR rData, WORD rLen) WORD answerIndex, PUCHAR rData, WORD rLen)
{ {
NetBTNodeQueryData *data = (NetBTNodeQueryData *)pVoid; NetBTNodeQueryData *data = pVoid;
if (data && !data->gotResponse && rData && rLen >= 1) if (data && !data->gotResponse && rData && rLen >= 1)
{ {
@ -811,7 +811,7 @@ static UCHAR NetBTAstatRemote(NetBTAdapter *adapter, PNCB ncb)
static UCHAR NetBTAstat(void *adapt, PNCB ncb) static UCHAR NetBTAstat(void *adapt, PNCB ncb)
{ {
NetBTAdapter *adapter = (NetBTAdapter *)adapt; NetBTAdapter *adapter = adapt;
UCHAR ret; UCHAR ret;
TRACE("adapt %p, NCB %p\n", adapt, ncb); TRACE("adapt %p, NCB %p\n", adapt, ncb);
@ -856,7 +856,7 @@ static UCHAR NetBTAstat(void *adapt, PNCB ncb)
static UCHAR NetBTFindName(void *adapt, PNCB ncb) static UCHAR NetBTFindName(void *adapt, PNCB ncb)
{ {
NetBTAdapter *adapter = (NetBTAdapter *)adapt; NetBTAdapter *adapter = adapt;
UCHAR ret; UCHAR ret;
const NBNameCacheEntry *cacheEntry = NULL; const NBNameCacheEntry *cacheEntry = NULL;
PFIND_NAME_HEADER foundName; PFIND_NAME_HEADER foundName;
@ -973,7 +973,7 @@ static UCHAR NetBTSessionReq(SOCKET fd, const UCHAR *calledName,
static UCHAR NetBTCall(void *adapt, PNCB ncb, void **sess) static UCHAR NetBTCall(void *adapt, PNCB ncb, void **sess)
{ {
NetBTAdapter *adapter = (NetBTAdapter *)adapt; NetBTAdapter *adapter = adapt;
UCHAR ret; UCHAR ret;
const NBNameCacheEntry *cacheEntry = NULL; const NBNameCacheEntry *cacheEntry = NULL;
@ -1074,8 +1074,8 @@ static UCHAR NetBTCall(void *adapt, PNCB ncb, void **sess)
*/ */
static UCHAR NetBTSend(void *adapt, void *sess, PNCB ncb) static UCHAR NetBTSend(void *adapt, void *sess, PNCB ncb)
{ {
NetBTAdapter *adapter = (NetBTAdapter *)adapt; NetBTAdapter *adapter = adapt;
NetBTSession *session = (NetBTSession *)sess; NetBTSession *session = sess;
UCHAR buffer[NBSS_HDRSIZE], ret; UCHAR buffer[NBSS_HDRSIZE], ret;
int r; int r;
WSABUF wsaBufs[2]; WSABUF wsaBufs[2];
@ -1123,8 +1123,8 @@ static UCHAR NetBTSend(void *adapt, void *sess, PNCB ncb)
static UCHAR NetBTRecv(void *adapt, void *sess, PNCB ncb) static UCHAR NetBTRecv(void *adapt, void *sess, PNCB ncb)
{ {
NetBTAdapter *adapter = (NetBTAdapter *)adapt; NetBTAdapter *adapter = adapt;
NetBTSession *session = (NetBTSession *)sess; NetBTSession *session = sess;
UCHAR buffer[NBSS_HDRSIZE], ret; UCHAR buffer[NBSS_HDRSIZE], ret;
int r; int r;
WSABUF wsaBufs[2]; WSABUF wsaBufs[2];
@ -1231,7 +1231,7 @@ error:
static UCHAR NetBTHangup(void *adapt, void *sess) static UCHAR NetBTHangup(void *adapt, void *sess)
{ {
NetBTSession *session = (NetBTSession *)sess; NetBTSession *session = sess;
TRACE("adapt %p, session %p\n", adapt, session); TRACE("adapt %p, session %p\n", adapt, session);
@ -1255,7 +1255,7 @@ static void NetBTCleanupAdapter(void *adapt)
TRACE("adapt %p\n", adapt); TRACE("adapt %p\n", adapt);
if (adapt) if (adapt)
{ {
NetBTAdapter *adapter = (NetBTAdapter *)adapt; NetBTAdapter *adapter = adapt;
if (adapter->nameCache) if (adapter->nameCache)
NBNameCacheDestroy(adapter->nameCache); NBNameCacheDestroy(adapter->nameCache);
@ -1310,7 +1310,7 @@ static BOOL NetBTEnumCallback(UCHAR totalLANAs, UCHAR lanaIndex,
ULONG transport, const NetBIOSAdapterImpl *data, void *closure) ULONG transport, const NetBIOSAdapterImpl *data, void *closure)
{ {
BOOL ret; BOOL ret;
PMIB_IPADDRTABLE table = (PMIB_IPADDRTABLE)closure; PMIB_IPADDRTABLE table = closure;
if (table && data) if (table && data)
{ {
@ -1319,7 +1319,7 @@ static BOOL NetBTEnumCallback(UCHAR totalLANAs, UCHAR lanaIndex,
ret = FALSE; ret = FALSE;
for (ndx = 0; !ret && ndx < table->dwNumEntries; ndx++) for (ndx = 0; !ret && ndx < table->dwNumEntries; ndx++)
{ {
const NetBTAdapter *adapter = (const NetBTAdapter *)data->data; const NetBTAdapter *adapter = data->data;
if (table->table[ndx].dwIndex == adapter->ipr.dwIndex) if (table->table[ndx].dwIndex == adapter->ipr.dwIndex)
{ {

View file

@ -762,7 +762,7 @@ static UCHAR nbDispatch(NetBIOSAdapter *adapter, PNCB ncb)
static DWORD WINAPI nbCmdThread(LPVOID lpVoid) static DWORD WINAPI nbCmdThread(LPVOID lpVoid)
{ {
PNCB ncb = (PNCB)lpVoid; PNCB ncb = lpVoid;
if (ncb) if (ncb)
{ {

View file

@ -157,8 +157,7 @@ static BOOL WkstaEnumAdaptersCallback(UCHAR totalLANAs, UCHAR lanaIndex,
ULONG transport, const NetBIOSAdapterImpl *data, void *closure) ULONG transport, const NetBIOSAdapterImpl *data, void *closure)
{ {
BOOL ret; BOOL ret;
struct WkstaTransportEnumData *enumData = (struct WkstaTransportEnumData *) struct WkstaTransportEnumData *enumData = closure;
closure;
if (enumData && enumData->pbuf) if (enumData && enumData->pbuf)
{ {

View file

@ -2642,6 +2642,7 @@ static inline HRESULT PROPVARIANT_ValidateType(VARTYPE vt)
case VT_BSTR: case VT_BSTR:
case VT_ERROR: case VT_ERROR:
case VT_BOOL: case VT_BOOL:
case VT_DECIMAL:
case VT_UI1: case VT_UI1:
case VT_UI2: case VT_UI2:
case VT_UI4: case VT_UI4:
@ -2712,6 +2713,7 @@ HRESULT WINAPI PropVariantClear(PROPVARIANT * pvar) /* [in/out] */
case VT_DATE: case VT_DATE:
case VT_ERROR: case VT_ERROR:
case VT_BOOL: case VT_BOOL:
case VT_DECIMAL:
case VT_UI1: case VT_UI1:
case VT_UI2: case VT_UI2:
case VT_UI4: case VT_UI4:
@ -2799,7 +2801,7 @@ HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, /* [out] */
ULONG len; ULONG len;
HRESULT hr; HRESULT hr;
TRACE("(%p, %p)\n", pvarDest, pvarSrc); TRACE("(%p, %p vt %04x)\n", pvarDest, pvarSrc, pvarSrc->vt);
hr = PROPVARIANT_ValidateType(pvarSrc->vt); hr = PROPVARIANT_ValidateType(pvarSrc->vt);
if (FAILED(hr)) if (FAILED(hr))
@ -2817,6 +2819,7 @@ HRESULT WINAPI PropVariantCopy(PROPVARIANT *pvarDest, /* [out] */
case VT_I2: case VT_I2:
case VT_UI2: case VT_UI2:
case VT_BOOL: case VT_BOOL:
case VT_DECIMAL:
case VT_I4: case VT_I4:
case VT_UI4: case VT_UI4:
case VT_R4: case VT_R4:

View file

@ -0,0 +1,299 @@
/*
* Copyright 2009 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
*/
#include "urlmon_main.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
typedef struct {
Protocol base;
const IInternetProtocolVtbl *lpInternetProtocolVtbl;
const IInternetPriorityVtbl *lpInternetPriorityVtbl;
LONG ref;
} GopherProtocol;
#define PROTOCOL(x) ((IInternetProtocol*) &(x)->lpInternetProtocolVtbl)
#define PRIORITY(x) ((IInternetPriority*) &(x)->lpInternetPriorityVtbl)
#define ASYNCPROTOCOL_THIS(iface) DEFINE_THIS2(GopherProtocol, base, iface)
static HRESULT GopherProtocol_open_request(Protocol *prot, LPCWSTR url, DWORD request_flags,
IInternetBindInfo *bind_info)
{
GopherProtocol *This = ASYNCPROTOCOL_THIS(prot);
This->base.request = InternetOpenUrlW(This->base.internet, url, NULL, 0,
request_flags, (DWORD_PTR)&This->base);
if (!This->base.request && GetLastError() != ERROR_IO_PENDING) {
WARN("InternetOpenUrl failed: %d\n", GetLastError());
return INET_E_RESOURCE_NOT_FOUND;
}
return S_OK;
}
static HRESULT GopherProtocol_start_downloading(Protocol *prot)
{
return S_OK;
}
static void GopherProtocol_close_connection(Protocol *prot)
{
}
#undef ASYNCPROTOCOL_THIS
static const ProtocolVtbl AsyncProtocolVtbl = {
GopherProtocol_open_request,
GopherProtocol_start_downloading,
GopherProtocol_close_connection
};
#define PROTOCOL_THIS(iface) DEFINE_THIS(GopherProtocol, InternetProtocol, iface)
static HRESULT WINAPI GopherProtocol_QueryInterface(IInternetProtocol *iface, REFIID riid, void **ppv)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = PROTOCOL(This);
}else if(IsEqualGUID(&IID_IInternetProtocolRoot, riid)) {
TRACE("(%p)->(IID_IInternetProtocolRoot %p)\n", This, ppv);
*ppv = PROTOCOL(This);
}else if(IsEqualGUID(&IID_IInternetProtocol, riid)) {
TRACE("(%p)->(IID_IInternetProtocol %p)\n", This, ppv);
*ppv = PROTOCOL(This);
}else if(IsEqualGUID(&IID_IInternetPriority, riid)) {
TRACE("(%p)->(IID_IInternetPriority %p)\n", This, ppv);
*ppv = PRIORITY(This);
}
if(*ppv) {
IInternetProtocol_AddRef(iface);
return S_OK;
}
WARN("not supported interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
static ULONG WINAPI GopherProtocol_AddRef(IInternetProtocol *iface)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
LONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
}
static ULONG WINAPI GopherProtocol_Release(IInternetProtocol *iface)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
LONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
if(!ref) {
heap_free(This);
URLMON_UnlockModule();
}
return ref;
}
static HRESULT WINAPI GopherProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
DWORD grfPI, DWORD dwReserved)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
TRACE("(%p)->(%s %p %p %08x %d)\n", This, debugstr_w(szUrl), pOIProtSink,
pOIBindInfo, grfPI, dwReserved);
return protocol_start(&This->base, PROTOCOL(This), szUrl, pOIProtSink, pOIBindInfo);
}
static HRESULT WINAPI GopherProtocol_Continue(IInternetProtocol *iface, PROTOCOLDATA *pProtocolData)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
TRACE("(%p)->(%p)\n", This, pProtocolData);
return protocol_continue(&This->base, pProtocolData);
}
static HRESULT WINAPI GopherProtocol_Abort(IInternetProtocol *iface, HRESULT hrReason,
DWORD dwOptions)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
FIXME("(%p)->(%08x %08x)\n", This, hrReason, dwOptions);
return E_NOTIMPL;
}
static HRESULT WINAPI GopherProtocol_Terminate(IInternetProtocol *iface, DWORD dwOptions)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
TRACE("(%p)->(%08x)\n", This, dwOptions);
protocol_close_connection(&This->base);
return S_OK;
}
static HRESULT WINAPI GopherProtocol_Suspend(IInternetProtocol *iface)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI GopherProtocol_Resume(IInternetProtocol *iface)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI GopherProtocol_Read(IInternetProtocol *iface, void *pv,
ULONG cb, ULONG *pcbRead)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
TRACE("(%p)->(%p %u %p)\n", This, pv, cb, pcbRead);
return protocol_read(&This->base, pv, cb, pcbRead);
}
static HRESULT WINAPI GopherProtocol_Seek(IInternetProtocol *iface, LARGE_INTEGER dlibMove,
DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
FIXME("(%p)->(%d %d %p)\n", This, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
return E_NOTIMPL;
}
static HRESULT WINAPI GopherProtocol_LockRequest(IInternetProtocol *iface, DWORD dwOptions)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
TRACE("(%p)->(%08x)\n", This, dwOptions);
return protocol_lock_request(&This->base);
}
static HRESULT WINAPI GopherProtocol_UnlockRequest(IInternetProtocol *iface)
{
GopherProtocol *This = PROTOCOL_THIS(iface);
TRACE("(%p)\n", This);
return protocol_unlock_request(&This->base);
}
#undef PROTOCOL_THIS
static const IInternetProtocolVtbl GopherProtocolVtbl = {
GopherProtocol_QueryInterface,
GopherProtocol_AddRef,
GopherProtocol_Release,
GopherProtocol_Start,
GopherProtocol_Continue,
GopherProtocol_Abort,
GopherProtocol_Terminate,
GopherProtocol_Suspend,
GopherProtocol_Resume,
GopherProtocol_Read,
GopherProtocol_Seek,
GopherProtocol_LockRequest,
GopherProtocol_UnlockRequest
};
#define PRIORITY_THIS(iface) DEFINE_THIS(GopherProtocol, InternetPriority, iface)
static HRESULT WINAPI GopherPriority_QueryInterface(IInternetPriority *iface, REFIID riid, void **ppv)
{
GopherProtocol *This = PRIORITY_THIS(iface);
return IInternetProtocol_QueryInterface(PROTOCOL(This), riid, ppv);
}
static ULONG WINAPI GopherPriority_AddRef(IInternetPriority *iface)
{
GopherProtocol *This = PRIORITY_THIS(iface);
return IInternetProtocol_AddRef(PROTOCOL(This));
}
static ULONG WINAPI GopherPriority_Release(IInternetPriority *iface)
{
GopherProtocol *This = PRIORITY_THIS(iface);
return IInternetProtocol_Release(PROTOCOL(This));
}
static HRESULT WINAPI GopherPriority_SetPriority(IInternetPriority *iface, LONG nPriority)
{
GopherProtocol *This = PRIORITY_THIS(iface);
TRACE("(%p)->(%d)\n", This, nPriority);
This->base.priority = nPriority;
return S_OK;
}
static HRESULT WINAPI GopherPriority_GetPriority(IInternetPriority *iface, LONG *pnPriority)
{
GopherProtocol *This = PRIORITY_THIS(iface);
TRACE("(%p)->(%p)\n", This, pnPriority);
*pnPriority = This->base.priority;
return S_OK;
}
#undef PRIORITY_THIS
static const IInternetPriorityVtbl GopherPriorityVtbl = {
GopherPriority_QueryInterface,
GopherPriority_AddRef,
GopherPriority_Release,
GopherPriority_SetPriority,
GopherPriority_GetPriority
};
HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
{
GopherProtocol *ret;
TRACE("(%p %p)\n", pUnkOuter, ppobj);
URLMON_LockModule();
ret = heap_alloc_zero(sizeof(GopherProtocol));
ret->base.vtbl = &AsyncProtocolVtbl;
ret->lpInternetProtocolVtbl = &GopherProtocolVtbl;
ret->lpInternetPriorityVtbl = &GopherPriorityVtbl;
ret->ref = 1;
*ppobj = PROTOCOL(ret);
return S_OK;
}

View file

@ -33,251 +33,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(urlmon); WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
/* native urlmon.dll uses this key, too */
static WCHAR BSCBHolder[] = { '_','B','S','C','B','_','H','o','l','d','e','r','_',0 };
/*static BOOL registered_wndclass = FALSE;*/
typedef struct {
const IBindingVtbl *lpVtbl;
LONG ref;
LPWSTR URLName;
HWND hwndCallback;
IBindCtx *pBC;
HINTERNET hinternet, hconnect, hrequest;
HANDLE hCacheFile;
IUMCacheStream *pstrCache;
IBindStatusCallback *pbscb;
DWORD total_read, expected_size;
} Binding;
static HRESULT WINAPI Binding_QueryInterface(IBinding* iface, REFIID riid, void **ppvObject)
{
Binding *This = (Binding*)iface;
TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
if((This == NULL) || (ppvObject == NULL))
return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, riid) || IsEqualIID(&IID_IBinding, riid)) {
*ppvObject = iface;
IBinding_AddRef(iface);
return S_OK;
}
*ppvObject = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI Binding_AddRef(IBinding* iface)
{
Binding *This = (Binding*)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) ref=%d\n", This, ref);
return ref;
}
static ULONG WINAPI Binding_Release(IBinding* iface)
{
Binding *This = (Binding*)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) ref=%d\n",This, ref);
if(!ref) {
heap_free(This->URLName);
if (This->hCacheFile)
CloseHandle(This->hCacheFile);
if (This->pstrCache)
{
UMCloseCacheFileStream(This->pstrCache);
IStream_Release((IStream *)This->pstrCache);
}
if (This->pbscb)
IBindStatusCallback_Release(This->pbscb);
heap_free(This);
URLMON_UnlockModule();
}
return ref;
}
static HRESULT WINAPI Binding_Abort(IBinding* iface)
{
Binding *This = (Binding*)iface;
FIXME("(%p): stub\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI Binding_GetBindResult(IBinding* iface, CLSID* pclsidProtocol, DWORD* pdwResult, LPOLESTR* pszResult, DWORD* pdwReserved)
{
Binding *This = (Binding*)iface;
FIXME("(%p)->(%p, %p, %p, %p): stub\n", This, pclsidProtocol, pdwResult, pszResult, pdwReserved);
return E_NOTIMPL;
}
static HRESULT WINAPI Binding_GetPriority(IBinding* iface, LONG* pnPriority)
{
Binding *This = (Binding*)iface;
FIXME("(%p)->(%p): stub\n", This, pnPriority);
return E_NOTIMPL;
}
static HRESULT WINAPI Binding_Resume(IBinding* iface)
{
Binding *This = (Binding*)iface;
FIXME("(%p): stub\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI Binding_SetPriority(IBinding* iface, LONG nPriority)
{
Binding *This = (Binding*)iface;
FIXME("(%p)->(%d): stub\n", This, nPriority);
return E_NOTIMPL;
}
static HRESULT WINAPI Binding_Suspend(IBinding* iface)
{
Binding *This = (Binding*)iface;
FIXME("(%p): stub\n", This);
return E_NOTIMPL;
}
static void Binding_CloseCacheDownload(Binding *This)
{
CloseHandle(This->hCacheFile);
This->hCacheFile = 0;
UMCloseCacheFileStream(This->pstrCache);
IStream_Release((IStream *)This->pstrCache);
This->pstrCache = 0;
}
static HRESULT Binding_MoreCacheData(Binding *This, const char *buf, DWORD dwBytes)
{
DWORD written;
if (WriteFile(This->hCacheFile, buf, dwBytes, &written, NULL) && written == dwBytes)
{
HRESULT hr;
This->total_read += written;
hr = IBindStatusCallback_OnProgress(This->pbscb,
This->total_read + written,
This->expected_size,
(This->total_read == written) ?
BINDSTATUS_BEGINDOWNLOADDATA :
BINDSTATUS_DOWNLOADINGDATA,
This->URLName);
if (hr == S_OK)
{
STGMEDIUM stg;
FORMATETC fmt;
fmt.cfFormat = 0;
fmt.ptd = NULL;
fmt.dwAspect = 0;
fmt.lindex = -1;
fmt.tymed = TYMED_ISTREAM;
stg.tymed = TYMED_ISTREAM;
stg.u.pstm = (IStream *)This->pstrCache;
stg.pUnkForRelease = NULL;
hr = IBindStatusCallback_OnDataAvailable(This->pbscb,
(This->total_read == written) ?
BSCF_FIRSTDATANOTIFICATION :
BSCF_INTERMEDIATEDATANOTIFICATION,
This->total_read + written,
&fmt,
&stg);
}
if (written < dwBytes)
return STG_E_MEDIUMFULL;
else
return hr;
}
return HRESULT_FROM_WIN32(GetLastError());
}
static void Binding_FinishedDownload(Binding *This, HRESULT hr)
{
STGMEDIUM stg;
FORMATETC fmt;
fmt.ptd = NULL;
fmt.dwAspect = 0;
fmt.lindex = -1;
fmt.tymed = TYMED_ISTREAM;
stg.tymed = TYMED_ISTREAM;
stg.u.pstm = (IStream *)This->pstrCache;
stg.pUnkForRelease = NULL;
IBindStatusCallback_OnProgress(This->pbscb, This->total_read, This->expected_size,
BINDSTATUS_ENDDOWNLOADDATA, This->URLName);
IBindStatusCallback_OnDataAvailable(This->pbscb, BSCF_LASTDATANOTIFICATION, This->total_read, &fmt, &stg);
if (hr != S_OK)
{
WCHAR *pwchError = 0;
FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL, (DWORD) hr,
0, (LPWSTR) &pwchError,
0, NULL);
if (!pwchError)
{
static const WCHAR achFormat[] = { '%', '0', '8', 'x', 0 };
pwchError =(WCHAR *) LocalAlloc(LMEM_FIXED, sizeof(WCHAR) * 9);
wsprintfW(pwchError, achFormat, hr);
}
IBindStatusCallback_OnStopBinding(This->pbscb, hr, pwchError);
LocalFree(pwchError);
}
else
{
IBindStatusCallback_OnStopBinding(This->pbscb, hr, NULL);
}
IBindStatusCallback_Release(This->pbscb);
This->pbscb = 0;
}
static const IBindingVtbl BindingVtbl =
{
Binding_QueryInterface,
Binding_AddRef,
Binding_Release,
Binding_Abort,
Binding_Suspend,
Binding_Resume,
Binding_SetPriority,
Binding_GetPriority,
Binding_GetBindResult
};
/* filemoniker data structure */
typedef struct { typedef struct {
const IMonikerVtbl* lpvtbl; /* VTable relative to the IMoniker interface.*/ const IMonikerVtbl* lpvtbl; /* VTable relative to the IMoniker interface.*/
@ -493,158 +248,6 @@ static HRESULT WINAPI URLMonikerImpl_BindToObject(IMoniker* iface,
/****************************************************************************** /******************************************************************************
* URLMoniker_BindToStorage * URLMoniker_BindToStorage
******************************************************************************/ ******************************************************************************/
static HRESULT URLMonikerImpl_BindToStorage_hack(LPCWSTR URLName, IBindCtx* pbc, VOID** ppvObject)
{
HRESULT hres;
BINDINFO bi;
DWORD bindf;
WCHAR szFileName[MAX_PATH + 1];
Binding *bind;
int len;
WARN("(%s %p %p)\n", debugstr_w(URLName), pbc, ppvObject);
bind = heap_alloc_zero(sizeof(Binding));
bind->lpVtbl = &BindingVtbl;
bind->ref = 1;
URLMON_LockModule();
len = lstrlenW(URLName)+1;
bind->URLName = heap_alloc(len*sizeof(WCHAR));
memcpy(bind->URLName, URLName, len*sizeof(WCHAR));
hres = UMCreateStreamOnCacheFile(bind->URLName, 0, szFileName, &bind->hCacheFile, &bind->pstrCache);
if(SUCCEEDED(hres)) {
TRACE("Created stream...\n");
*ppvObject = (void *) bind->pstrCache;
IStream_AddRef((IStream *) bind->pstrCache);
hres = IBindCtx_GetObjectParam(pbc, BSCBHolder, (IUnknown**)&bind->pbscb);
if(SUCCEEDED(hres)) {
TRACE("Got IBindStatusCallback...\n");
memset(&bi, 0, sizeof(bi));
bi.cbSize = sizeof(bi);
bindf = 0;
hres = IBindStatusCallback_GetBindInfo(bind->pbscb, &bindf, &bi);
if(SUCCEEDED(hres)) {
URL_COMPONENTSW url;
WCHAR *host, *path, *user, *pass;
TRACE("got bindinfo. bindf = %08x extrainfo = %s bindinfof = %08x bindverb = %08x iid %s\n",
bindf, debugstr_w(bi.szExtraInfo), bi.grfBindInfoF, bi.dwBindVerb, debugstr_guid(&bi.iid));
hres = IBindStatusCallback_OnStartBinding(bind->pbscb, 0, (IBinding*)bind);
TRACE("OnStartBinding rets %08x\n", hres);
bind->expected_size = 0;
bind->total_read = 0;
memset(&url, 0, sizeof(url));
url.dwStructSize = sizeof(url);
url.dwSchemeLength = url.dwHostNameLength = url.dwUrlPathLength = url.dwUserNameLength = url.dwPasswordLength = 1;
InternetCrackUrlW(URLName, 0, ICU_ESCAPE, &url);
host = heap_alloc((url.dwHostNameLength + 1) * sizeof(WCHAR));
memcpy(host, url.lpszHostName, url.dwHostNameLength * sizeof(WCHAR));
host[url.dwHostNameLength] = '\0';
path = heap_alloc((url.dwUrlPathLength + 1) * sizeof(WCHAR));
memcpy(path, url.lpszUrlPath, url.dwUrlPathLength * sizeof(WCHAR));
path[url.dwUrlPathLength] = '\0';
if (url.dwUserNameLength)
{
user = heap_alloc(((url.dwUserNameLength + 1) * sizeof(WCHAR)));
memcpy(user, url.lpszUserName, url.dwUserNameLength * sizeof(WCHAR));
user[url.dwUserNameLength] = 0;
}
else
{
user = 0;
}
if (url.dwPasswordLength)
{
pass = heap_alloc(((url.dwPasswordLength + 1) * sizeof(WCHAR)));
memcpy(pass, url.lpszPassword, url.dwPasswordLength * sizeof(WCHAR));
pass[url.dwPasswordLength] = 0;
}
else
{
pass = 0;
}
do {
bind->hinternet = InternetOpenA("User Agent", 0, NULL, NULL, 0);
if (!bind->hinternet)
{
hres = HRESULT_FROM_WIN32(GetLastError());
break;
}
if (!url.nPort)
url.nPort = INTERNET_DEFAULT_GOPHER_PORT;
bind->hconnect = InternetConnectW(bind->hinternet, host, url.nPort, user, pass,
INTERNET_SERVICE_GOPHER, 0, (DWORD_PTR)bind);
if (!bind->hconnect)
{
hres = HRESULT_FROM_WIN32(GetLastError());
CloseHandle(bind->hinternet);
break;
}
hres = IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, 0x22, NULL);
hres = IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, BINDSTATUS_FINDINGRESOURCE, NULL);
hres = IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, BINDSTATUS_CONNECTING, NULL);
hres = IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, BINDSTATUS_SENDINGREQUEST, NULL);
bind->hrequest = GopherOpenFileW(bind->hconnect,
path,
0,
INTERNET_FLAG_RELOAD,
0);
if (bind->hrequest)
{
TRACE("res = %d gle = %u url len = %d\n", hres, GetLastError(), bind->expected_size);
IBindStatusCallback_OnProgress(bind->pbscb, 0, 0, BINDSTATUS_CACHEFILENAMEAVAILABLE, szFileName);
while(1) {
char buf[4096];
DWORD bufread;
if(InternetReadFile(bind->hrequest, buf, sizeof(buf), &bufread)) {
TRACE("read %d bytes %s...\n", bufread, debugstr_an(buf, 10));
if(bufread == 0) break;
hres = Binding_MoreCacheData(bind, buf, bufread);
} else
break;
}
InternetCloseHandle(bind->hrequest);
hres = S_OK;
}else {
hres = HRESULT_FROM_WIN32(GetLastError());
}
InternetCloseHandle(bind->hconnect);
InternetCloseHandle(bind->hinternet);
} while(0);
Binding_FinishedDownload(bind, hres);
Binding_CloseCacheDownload(bind);
heap_free(user);
heap_free(pass);
heap_free(path);
heap_free(host);
}
}
}
IBinding_Release((IBinding*)bind);
return hres;
}
static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface, static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
IBindCtx* pbc, IBindCtx* pbc,
IMoniker* pmkToLeft, IMoniker* pmkToLeft,
@ -652,26 +255,12 @@ static HRESULT WINAPI URLMonikerImpl_BindToStorage(IMoniker* iface,
VOID** ppvObject) VOID** ppvObject)
{ {
URLMonikerImpl *This = (URLMonikerImpl*)iface; URLMonikerImpl *This = (URLMonikerImpl*)iface;
WCHAR schema[64];
BOOL bret;
URL_COMPONENTSW url = {sizeof(URL_COMPONENTSW), schema, TRACE("(%p)->(%p %p %s %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObject);
sizeof(schema)/sizeof(WCHAR), 0, NULL, 0, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0};
if(pmkToLeft) if(pmkToLeft)
FIXME("Unsupported pmkToLeft\n"); FIXME("Unsupported pmkToLeft\n");
bret = InternetCrackUrlW(This->URLName, 0, ICU_ESCAPE, &url);
if(!bret) {
ERR("InternetCrackUrl failed: %u\n", GetLastError());
return E_FAIL;
}
if(IsEqualGUID(&IID_IStream, riid) && url.nScheme == INTERNET_SCHEME_GOPHER)
return URLMonikerImpl_BindToStorage_hack(This->URLName, pbc, ppvObject);
TRACE("(%p)->(%p %p %s %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObject);
return bind_to_storage(This->URLName, pbc, riid, ppvObject); return bind_to_storage(This->URLName, pbc, riid, ppvObject);
} }

View file

@ -30,342 +30,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(urlmon); WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
static const IStreamVtbl stvt;
HRESULT UMCreateStreamOnCacheFile(LPCWSTR pszURL,
DWORD dwSize,
LPWSTR pszFileName,
HANDLE *phfile,
IUMCacheStream **ppstr)
{
IUMCacheStream* ucstr;
HANDLE handle;
DWORD size;
LPWSTR url, c, ext = NULL;
HRESULT hr;
size = (strlenW(pszURL)+1)*sizeof(WCHAR);
url = heap_alloc(size);
memcpy(url, pszURL, size);
for (c = url; *c && *c != '#' && *c != '?'; ++c)
{
if (*c == '.')
ext = c+1;
else if(*c == '/')
ext = NULL;
}
*c = 0;
if(!CreateUrlCacheEntryW(url, dwSize, ext, pszFileName, 0))
hr = HRESULT_FROM_WIN32(GetLastError());
else
hr = S_OK;
heap_free(url);
if (hr != S_OK)
return hr;
TRACE("Opening %s\n", debugstr_w(pszFileName) );
handle = CreateFileW( pszFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL );
if( handle == INVALID_HANDLE_VALUE )
return HRESULT_FROM_WIN32(GetLastError());
if (phfile)
{
/* Call CreateFileW again because we need a handle with its own file pointer, and DuplicateHandle will return
* a handle that shares its file pointer with the original.
*/
*phfile = CreateFileW( pszFileName, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );
if (*phfile == (HANDLE) HFILE_ERROR)
{
DWORD dwError = GetLastError();
CloseHandle(handle);
return HRESULT_FROM_WIN32(dwError);
}
}
ucstr = heap_alloc_zero(sizeof(IUMCacheStream));
if(ucstr)
{
ucstr->pszURL = heap_alloc_zero(sizeof(WCHAR) * (lstrlenW(pszURL) + 1));
if (ucstr->pszURL)
{
ucstr->pszFileName = heap_alloc_zero(sizeof(WCHAR) * (lstrlenW(pszFileName) + 1));
if (ucstr->pszFileName)
{
ucstr->lpVtbl=&stvt;
ucstr->ref = 1;
ucstr->handle = handle;
ucstr->closed = 0;
lstrcpyW(ucstr->pszURL, pszURL);
lstrcpyW(ucstr->pszFileName, pszFileName);
*ppstr = ucstr;
return S_OK;
}
heap_free(ucstr->pszURL);
}
heap_free(ucstr);
}
CloseHandle(handle);
if (phfile)
CloseHandle(*phfile);
return E_OUTOFMEMORY;
}
void UMCloseCacheFileStream(IUMCacheStream *This)
{
if (!This->closed)
{
FILETIME ftZero;
ftZero.dwLowDateTime = ftZero.dwHighDateTime = 0;
This->closed = 1;
CommitUrlCacheEntryW(This->pszURL,
This->pszFileName,
ftZero,
ftZero,
NORMAL_CACHE_ENTRY,
0,
0,
0,
0);
}
}
/**************************************************************************
* IStream_fnQueryInterface
*/
static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface,
REFIID riid,
LPVOID *ppvObj)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
*ppvObj = NULL;
if(IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_IStream))
{
*ppvObj = This;
}
if(*ppvObj)
{
IStream_AddRef((IStream*)*ppvObj);
TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
return S_OK;
}
TRACE("-- Interface: E_NOINTERFACE\n");
return E_NOINTERFACE;
}
/**************************************************************************
* IStream_fnAddRef
*/
static ULONG WINAPI IStream_fnAddRef(IStream *iface)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
ULONG refCount = InterlockedIncrement(&This->ref);
TRACE("(%p)->(count=%u)\n", This, refCount - 1);
return refCount;
}
/**************************************************************************
* IStream_fnRelease
*/
static ULONG WINAPI IStream_fnRelease(IStream *iface)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
ULONG refCount = InterlockedDecrement(&This->ref);
TRACE("(%p)->(count=%u)\n", This, refCount + 1);
if (!refCount)
{
TRACE(" destroying UMCacheStream (%p)\n",This);
UMCloseCacheFileStream(This);
CloseHandle(This->handle);
heap_free(This->pszFileName);
heap_free(This->pszURL);
heap_free(This);
}
return refCount;
}
static HRESULT WINAPI IStream_fnRead (IStream * iface,
void* pv,
ULONG cb,
ULONG* pcbRead)
{
ULONG dwBytesRead;
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)->(%p,0x%08x,%p)\n",This, pv, cb, pcbRead);
if ( !pv )
return STG_E_INVALIDPOINTER;
if ( !pcbRead)
pcbRead = &dwBytesRead;
if ( ! ReadFile( This->handle, pv, cb, pcbRead, NULL ) )
return S_FALSE;
if (!*pcbRead)
return This->closed ? S_FALSE : E_PENDING;
return S_OK;
}
static HRESULT WINAPI IStream_fnWrite (IStream * iface,
const void* pv,
ULONG cb,
ULONG* pcbWritten)
{
return E_NOTIMPL;
}
static HRESULT WINAPI IStream_fnSeek (IStream * iface,
LARGE_INTEGER dlibMove,
DWORD dwOrigin,
ULARGE_INTEGER* plibNewPosition)
{
LARGE_INTEGER newpos;
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
if (!SetFilePointerEx( This->handle, dlibMove, &newpos, dwOrigin ))
return E_FAIL;
if (plibNewPosition)
plibNewPosition->QuadPart = newpos.QuadPart;
return S_OK;
}
static HRESULT WINAPI IStream_fnSetSize (IStream * iface,
ULARGE_INTEGER libNewSize)
{
LARGE_INTEGER newpos;
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
newpos.QuadPart = libNewSize.QuadPart;
if( ! SetFilePointerEx( This->handle, newpos, NULL, FILE_BEGIN ) )
return E_FAIL;
if( ! SetEndOfFile( This->handle ) )
return E_FAIL;
return S_OK;
}
static HRESULT WINAPI IStream_fnCopyTo (IStream * iface,
IStream* pstm,
ULARGE_INTEGER cb,
ULARGE_INTEGER* pcbRead,
ULARGE_INTEGER* pcbWritten)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI IStream_fnCommit (IStream * iface,
DWORD grfCommitFlags)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI IStream_fnRevert (IStream * iface)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI IStream_fnLockRegion (IStream * iface,
ULARGE_INTEGER libOffset,
ULARGE_INTEGER cb,
DWORD dwLockType)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI IStream_fnUnlockRegion (IStream * iface,
ULARGE_INTEGER libOffset,
ULARGE_INTEGER cb,
DWORD dwLockType)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI IStream_fnStat (IStream * iface,
STATSTG* pstatstg,
DWORD grfStatFlag)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI IStream_fnClone (IStream * iface,
IStream** ppstm)
{
IUMCacheStream *This = (IUMCacheStream *)iface;
TRACE("(%p)\n",This);
return E_NOTIMPL;
}
static const IStreamVtbl stvt =
{
IStream_fnQueryInterface,
IStream_fnAddRef,
IStream_fnRelease,
IStream_fnRead,
IStream_fnWrite,
IStream_fnSeek,
IStream_fnSetSize,
IStream_fnCopyTo,
IStream_fnCommit,
IStream_fnRevert,
IStream_fnLockRegion,
IStream_fnUnlockRegion,
IStream_fnStat,
IStream_fnClone
};
typedef struct ProxyBindStatusCallback typedef struct ProxyBindStatusCallback
{ {
const IBindStatusCallbackVtbl *lpVtbl; const IBindStatusCallbackVtbl *lpVtbl;

View file

@ -15,6 +15,7 @@
<file>file.c</file> <file>file.c</file>
<file>format.c</file> <file>format.c</file>
<file>ftp.c</file> <file>ftp.c</file>
<file>gopher.c</file>
<file>http.c</file> <file>http.c</file>
<file>internet.c</file> <file>internet.c</file>
<file>mk.c</file> <file>mk.c</file>

View file

@ -173,6 +173,8 @@ static const ClassFactory FileProtocolCF =
{ &ClassFactoryVtbl, FileProtocol_Construct}; { &ClassFactoryVtbl, FileProtocol_Construct};
static const ClassFactory FtpProtocolCF = static const ClassFactory FtpProtocolCF =
{ &ClassFactoryVtbl, FtpProtocol_Construct}; { &ClassFactoryVtbl, FtpProtocol_Construct};
static const ClassFactory GopherProtocolCF =
{ &ClassFactoryVtbl, GopherProtocol_Construct};
static const ClassFactory HttpProtocolCF = static const ClassFactory HttpProtocolCF =
{ &ClassFactoryVtbl, HttpProtocol_Construct}; { &ClassFactoryVtbl, HttpProtocol_Construct};
static const ClassFactory HttpSProtocolCF = static const ClassFactory HttpSProtocolCF =
@ -193,6 +195,7 @@ struct object_creation_info
static const WCHAR wszFile[] = {'f','i','l','e',0}; static const WCHAR wszFile[] = {'f','i','l','e',0};
static const WCHAR wszFtp[] = {'f','t','p',0}; static const WCHAR wszFtp[] = {'f','t','p',0};
static const WCHAR wszGopher[] = {'g','o','p','h','e','r',0};
static const WCHAR wszHttp[] = {'h','t','t','p',0}; static const WCHAR wszHttp[] = {'h','t','t','p',0};
static const WCHAR wszHttps[] = {'h','t','t','p','s',0}; static const WCHAR wszHttps[] = {'h','t','t','p','s',0};
static const WCHAR wszMk[] = {'m','k',0}; static const WCHAR wszMk[] = {'m','k',0};
@ -201,6 +204,7 @@ static const struct object_creation_info object_creation[] =
{ {
{ &CLSID_FileProtocol, CLASSFACTORY(&FileProtocolCF), wszFile }, { &CLSID_FileProtocol, CLASSFACTORY(&FileProtocolCF), wszFile },
{ &CLSID_FtpProtocol, CLASSFACTORY(&FtpProtocolCF), wszFtp }, { &CLSID_FtpProtocol, CLASSFACTORY(&FtpProtocolCF), wszFtp },
{ &CLSID_GopherProtocol, CLASSFACTORY(&GopherProtocolCF), wszGopher },
{ &CLSID_HttpProtocol, CLASSFACTORY(&HttpProtocolCF), wszHttp }, { &CLSID_HttpProtocol, CLASSFACTORY(&HttpProtocolCF), wszHttp },
{ &CLSID_HttpSProtocol, CLASSFACTORY(&HttpSProtocolCF), wszHttps }, { &CLSID_HttpSProtocol, CLASSFACTORY(&HttpSProtocolCF), wszHttps },
{ &CLSID_MkProtocol, CLASSFACTORY(&MkProtocolCF), wszMk }, { &CLSID_MkProtocol, CLASSFACTORY(&MkProtocolCF), wszMk },

View file

@ -42,6 +42,7 @@ extern HRESULT FileProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); extern HRESULT HttpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); extern HRESULT HttpSProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); extern HRESULT FtpProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT GopherProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
extern HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); extern HRESULT MkProtocol_Construct(IUnknown *pUnkOuter, LPVOID *ppobj);
/********************************************************************** /**********************************************************************
@ -55,19 +56,6 @@ static inline void URLMON_UnlockModule(void) { InterlockedDecrement( &URLMON_ref
#define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc))) #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
#define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface) #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
typedef struct
{
const IStreamVtbl *lpVtbl;
LONG ref;
HANDLE handle;
BOOL closed;
WCHAR *pszFileName;
WCHAR *pszURL;
} IUMCacheStream;
HRESULT UMCreateStreamOnCacheFile(LPCWSTR pszURL, DWORD dwSize, LPWSTR pszFileName, HANDLE *phfile, IUMCacheStream **ppstr);
void UMCloseCacheFileStream(IUMCacheStream *pstr);
IInternetProtocolInfo *get_protocol_info(LPCWSTR url); IInternetProtocolInfo *get_protocol_info(LPCWSTR url);
HRESULT get_protocol_handler(LPCWSTR url, CLSID *clsid, IClassFactory **ret); HRESULT get_protocol_handler(LPCWSTR url, CLSID *clsid, IClassFactory **ret);
BOOL is_registered_protocol(LPCWSTR); BOOL is_registered_protocol(LPCWSTR);