hlink: Implement IExtensionServices.

This commit is contained in:
Aric Stewart 2008-04-28 13:44:16 -05:00 committed by Alexandre Julliard
parent f4625d1ae1
commit 09af64cb83
3 changed files with 123 additions and 18 deletions

View File

@ -29,6 +29,7 @@ typedef struct {
const IUnknownVtbl *lpIUnknownVtbl; const IUnknownVtbl *lpIUnknownVtbl;
const IAuthenticateVtbl *lpIAuthenticateVtbl; const IAuthenticateVtbl *lpIAuthenticateVtbl;
const IHttpNegotiateVtbl *lpIHttpNegotiateVtbl; const IHttpNegotiateVtbl *lpIHttpNegotiateVtbl;
const IExtensionServicesVtbl *lpIExtensionServicesVtbl;
LONG ref; LONG ref;
IUnknown *outer; IUnknown *outer;
@ -42,6 +43,7 @@ typedef struct {
#define EXTSERVUNK(x) ((IUnknown*) &(x)->lpIUnknownVtbl) #define EXTSERVUNK(x) ((IUnknown*) &(x)->lpIUnknownVtbl)
#define AUTHENTICATE(x) ((IAuthenticate*) &(x)->lpIAuthenticateVtbl) #define AUTHENTICATE(x) ((IAuthenticate*) &(x)->lpIAuthenticateVtbl)
#define HTTPNEGOTIATE(x) ((IHttpNegotiate*) &(x)->lpIHttpNegotiateVtbl) #define HTTPNEGOTIATE(x) ((IHttpNegotiate*) &(x)->lpIHttpNegotiateVtbl)
#define EXTENSIONSERVICES(x) ((IExtensionServices*) &(x)->lpIExtensionServicesVtbl)
#define EXTSERVUNK_THIS(iface) DEFINE_THIS(ExtensionService, IUnknown, iface) #define EXTSERVUNK_THIS(iface) DEFINE_THIS(ExtensionService, IUnknown, iface)
@ -60,6 +62,9 @@ static HRESULT WINAPI ExtServUnk_QueryInterface(IUnknown *iface, REFIID riid, vo
}else if(IsEqualGUID(&IID_IHttpNegotiate, riid)) { }else if(IsEqualGUID(&IID_IHttpNegotiate, riid)) {
TRACE("(%p)->(IID_IHttpNegotiate %p)\n", This, ppv); TRACE("(%p)->(IID_IHttpNegotiate %p)\n", This, ppv);
*ppv = HTTPNEGOTIATE(This); *ppv = HTTPNEGOTIATE(This);
}else if(IsEqualGUID(&IID_IExtensionServices, riid)) {
TRACE("(%p)->(IID_IExtensionServices %p)\n", This, ppv);
*ppv = EXTENSIONSERVICES(This);
} }
if(*ppv) { if(*ppv) {
@ -209,6 +214,90 @@ static const IHttpNegotiateVtbl HttpNegotiateVtbl = {
HttpNegotiate_OnResponse HttpNegotiate_OnResponse
}; };
#define EXTENSIONSERVICES_THIS(iface) DEFINE_THIS(ExtensionService, IExtensionServices, iface)
static HRESULT WINAPI ExtServ_QueryInterface(IExtensionServices *iface, REFIID riid, void **ppv)
{
ExtensionService *This = EXTENSIONSERVICES_THIS(iface);
return IUnknown_QueryInterface(This->outer, riid, ppv);
}
static ULONG WINAPI ExtServ_AddRef(IExtensionServices *iface)
{
ExtensionService *This = EXTENSIONSERVICES_THIS(iface);
return IUnknown_AddRef(This->outer);
}
static ULONG WINAPI ExtServ_Release(IExtensionServices *iface)
{
ExtensionService *This = EXTENSIONSERVICES_THIS(iface);
return IUnknown_Release(This->outer);
}
static HRESULT ExtServ_ImplSetAdditionalHeaders(ExtensionService* This, LPCWSTR pwzAdditionalHeaders)
{
int len = 0;
heap_free(This->headers);
This->headers = NULL;
if (!pwzAdditionalHeaders)
return S_OK;
len = strlenW(pwzAdditionalHeaders);
if(len && pwzAdditionalHeaders[len-1] != '\n' && pwzAdditionalHeaders[len-1] != '\r') {
static const WCHAR endlW[] = {'\r','\n',0};
This->headers = heap_alloc(len*sizeof(WCHAR) + sizeof(endlW));
memcpy(This->headers, pwzAdditionalHeaders, len*sizeof(WCHAR));
memcpy(This->headers+len, endlW, sizeof(endlW));
}else {
This->headers = hlink_strdupW(pwzAdditionalHeaders);
}
return S_OK;
}
static HRESULT WINAPI ExtServ_SetAdditionalHeaders(IExtensionServices* iface, LPCWSTR pwzAdditionalHeaders)
{
ExtensionService *This = EXTENSIONSERVICES_THIS(iface);
TRACE("(%p)->(%s)\n", This, debugstr_w(pwzAdditionalHeaders));
return ExtServ_ImplSetAdditionalHeaders(This,pwzAdditionalHeaders);
}
static HRESULT ExtServ_ImplSetAuthenticateData(ExtensionService* This, HWND phwnd, LPCWSTR pwzUsername, LPCWSTR pwzPassword)
{
heap_free(This->username);
heap_free(This->password);
This->hwnd = phwnd;
This->username = hlink_strdupW(pwzUsername);
This->password = hlink_strdupW(pwzPassword);
return S_OK;
}
static HRESULT WINAPI ExtServ_SetAuthenticateData(IExtensionServices* iface, HWND phwnd, LPCWSTR pwzUsername, LPCWSTR pwzPassword)
{
ExtensionService *This = EXTENSIONSERVICES_THIS(iface);
TRACE("(%p)->(%p %s %s)\n", This, phwnd, debugstr_w(pwzUsername), debugstr_w(pwzPassword));
return ExtServ_ImplSetAuthenticateData(This, phwnd, pwzUsername, pwzPassword);
}
#undef EXTENSIONSERVICES_THIS
static const IExtensionServicesVtbl ExtServVtbl = {
ExtServ_QueryInterface,
ExtServ_AddRef,
ExtServ_Release,
ExtServ_SetAdditionalHeaders,
ExtServ_SetAuthenticateData
};
/*********************************************************************** /***********************************************************************
* HlinkCreateExtensionServices (HLINK.@) * HlinkCreateExtensionServices (HLINK.@)
*/ */
@ -217,7 +306,6 @@ HRESULT WINAPI HlinkCreateExtensionServices(LPCWSTR pwzAdditionalHeaders,
IUnknown *punkOuter, REFIID riid, void** ppv) IUnknown *punkOuter, REFIID riid, void** ppv)
{ {
ExtensionService *ret; ExtensionService *ret;
int len = 0;
HRESULT hres = S_OK; HRESULT hres = S_OK;
TRACE("%s %p %s %s %p %s %p\n",debugstr_w(pwzAdditionalHeaders), TRACE("%s %p %s %s %p %s %p\n",debugstr_w(pwzAdditionalHeaders),
@ -229,22 +317,15 @@ HRESULT WINAPI HlinkCreateExtensionServices(LPCWSTR pwzAdditionalHeaders,
ret->lpIUnknownVtbl = &ExtServUnkVtbl; ret->lpIUnknownVtbl = &ExtServUnkVtbl;
ret->lpIAuthenticateVtbl = &AuthenticateVtbl; ret->lpIAuthenticateVtbl = &AuthenticateVtbl;
ret->lpIHttpNegotiateVtbl = &HttpNegotiateVtbl; ret->lpIHttpNegotiateVtbl = &HttpNegotiateVtbl;
ret->lpIExtensionServicesVtbl= &ExtServVtbl;
ret->ref = 1; ret->ref = 1;
ret->hwnd = phwnd; ret->headers = NULL;
ret->username = hlink_strdupW(pszUsername); ret->hwnd = NULL;
ret->password = hlink_strdupW(pszPassword); ret->username = NULL;
ret->password = NULL;
if(pwzAdditionalHeaders) ExtServ_ImplSetAuthenticateData(ret, phwnd, pszUsername, pszPassword);
len = strlenW(pwzAdditionalHeaders); ExtServ_ImplSetAdditionalHeaders(ret, pwzAdditionalHeaders);
if(len && pwzAdditionalHeaders[len-1] != '\n' && pwzAdditionalHeaders[len-1] != '\r') {
static const WCHAR endlW[] = {'\r','\n',0};
ret->headers = heap_alloc(len*sizeof(WCHAR) + sizeof(endlW));
memcpy(ret->headers, pwzAdditionalHeaders, len*sizeof(WCHAR));
memcpy(ret->headers+len, endlW, sizeof(endlW));
}else {
ret->headers = hlink_strdupW(pwzAdditionalHeaders);
}
if(!punkOuter) { if(!punkOuter) {
ret->outer = EXTSERVUNK(ret); ret->outer = EXTSERVUNK(ret);

View File

@ -25,5 +25,7 @@ DEFINE_GUID(CLSID_StdHlink,
0x79eac9d0, 0xbaf9, 0x11ce, 0x8c, 0x82, 0x00, 0xaa,0x00,0x4b,0xa9,0x0b); 0x79eac9d0, 0xbaf9, 0x11ce, 0x8c, 0x82, 0x00, 0xaa,0x00,0x4b,0xa9,0x0b);
DEFINE_GUID(CLSID_StdHlinkBrowseContext, DEFINE_GUID(CLSID_StdHlinkBrowseContext,
0x79eac9d1, 0xbaf9, 0x11ce, 0x8c, 0x82, 0x00, 0xaa,0x00,0x4b,0xa9,0x0b); 0x79eac9d1, 0xbaf9, 0x11ce, 0x8c, 0x82, 0x00, 0xaa,0x00,0x4b,0xa9,0x0b);
DEFINE_GUID(CLSID_IID_IExtensionServices,
0x79eac9cb, 0xbaf9, 0x11ce, 0x8c, 0x82, 0x00, 0xaa,0x00,0x4b,0xa9,0x0b);
#endif #endif

View File

@ -416,3 +416,25 @@ interface IHlinkFrame : IUnknown
[in, unique] LPCWSTR pwzLocation, [in, unique] LPCWSTR pwzLocation,
[in, unique] LPCWSTR pwzFriendlyName); [in, unique] LPCWSTR pwzFriendlyName);
} }
/*****************************************************************************
* IExtensionServices interface
*/
[
object,
uuid(79eac9cb-baf9-11ce-8c82-00aa004ba90b),
pointer_default(unique)
]
interface IExtensionServices: IUnknown
{
typedef IExtensionServices *LPEXTENSIONSERVICES;
HRESULT SetAdditionalHeaders(
[in] LPCWSTR pwzAdditionalHeaders);
HRESULT SetAuthenticateData(
[in] HWND phwnd,
[in] LPCWSTR pwzUsername,
[in] LPCWSTR pwzPassword);
}