2 * Copyright 2007 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "hlink_private.h"
21 #include "wine/debug.h"
22 #include "wine/unicode.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(hlink
);
26 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
29 const IUnknownVtbl
*lpIUnknownVtbl
;
30 const IAuthenticateVtbl
*lpIAuthenticateVtbl
;
40 #define EXTSERVUNK(x) ((IUnknown*) &(x)->lpIUnknownVtbl)
41 #define AUTHENTICATE(x) ((IAuthenticate*) &(x)->lpIAuthenticateVtbl)
43 #define EXTSERVUNK_THIS(iface) DEFINE_THIS(ExtensionService, IUnknown, iface)
45 static HRESULT WINAPI
ExtServUnk_QueryInterface(IUnknown
*iface
, REFIID riid
, void **ppv
)
47 ExtensionService
*This
= EXTSERVUNK_THIS(iface
);
51 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
52 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
53 *ppv
= EXTSERVUNK(This
);
54 }else if(IsEqualGUID(&IID_IAuthenticate
, riid
)) {
55 TRACE("(%p)->(IID_IAuthenticate %p)\n", This
, ppv
);
56 *ppv
= AUTHENTICATE(This
);
60 IUnknown_AddRef(EXTSERVUNK(This
));
64 FIXME("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
68 static ULONG WINAPI
ExtServUnk_AddRef(IUnknown
*iface
)
70 ExtensionService
*This
= EXTSERVUNK_THIS(iface
);
71 LONG ref
= InterlockedIncrement(&This
->ref
);
73 TRACE("(%p) ref=%d\n", This
, ref
);
78 static ULONG WINAPI
ExtServUnk_Release(IUnknown
*iface
)
80 ExtensionService
*This
= EXTSERVUNK_THIS(iface
);
81 LONG ref
= InterlockedDecrement(&This
->ref
);
83 TRACE("(%p) ref=%d\n", This
, ref
);
86 hlink_free(This
->username
);
87 hlink_free(This
->password
);
94 #undef EXTSERVUNK_THIS
96 static const IUnknownVtbl ExtServUnkVtbl
= {
97 ExtServUnk_QueryInterface
,
102 #define AUTHENTICATE_THIS(iface) DEFINE_THIS(ExtensionService, IAuthenticate, iface)
104 static HRESULT WINAPI
Authenticate_QueryInterface(IAuthenticate
*iface
, REFIID riid
, void **ppv
)
106 ExtensionService
*This
= AUTHENTICATE_THIS(iface
);
107 return IUnknown_QueryInterface(This
->outer
, riid
, ppv
);
110 static ULONG WINAPI
Authenticate_AddRef(IAuthenticate
*iface
)
112 ExtensionService
*This
= AUTHENTICATE_THIS(iface
);
113 return IUnknown_AddRef(This
->outer
);
116 static ULONG WINAPI
Authenticate_Release(IAuthenticate
*iface
)
118 ExtensionService
*This
= AUTHENTICATE_THIS(iface
);
119 return IUnknown_Release(This
->outer
);
122 static HRESULT WINAPI
Authenticate_Authenticate(IAuthenticate
*iface
,
123 HWND
*phwnd
, LPWSTR
*pszUsername
, LPWSTR
*pszPassword
)
125 ExtensionService
*This
= AUTHENTICATE_THIS(iface
);
127 TRACE("(%p)->(%p %p %p)\n", This
, phwnd
, pszUsername
, pszPassword
);
129 if(!phwnd
|| !pszUsername
|| !pszPassword
)
133 *pszUsername
= hlink_co_strdupW(This
->username
);
134 *pszPassword
= hlink_co_strdupW(This
->password
);
139 #undef AUTHENTICATE_THIS
141 static const IAuthenticateVtbl AuthenticateVtbl
= {
142 Authenticate_QueryInterface
,
144 Authenticate_Release
,
145 Authenticate_Authenticate
148 HRESULT WINAPI
HlinkCreateExtensionServices(LPCWSTR pwzAdditionalHeaders
,
149 HWND phwnd
, LPCWSTR pszUsername
, LPCWSTR pszPassword
,
150 IUnknown
*punkOuter
, REFIID riid
, void** ppv
)
152 ExtensionService
*ret
;
155 TRACE("%s %p %s %s %p %s %p\n",debugstr_w(pwzAdditionalHeaders
),
156 phwnd
, debugstr_w(pszUsername
), debugstr_w(pszPassword
),
157 punkOuter
, debugstr_guid(riid
), ppv
);
159 if(pwzAdditionalHeaders
)
160 FIXME("Unsupported pwzAdditionalHeaders\n");
162 ret
= hlink_alloc(sizeof(*ret
));
164 ret
->lpIUnknownVtbl
= &ExtServUnkVtbl
;
165 ret
->lpIAuthenticateVtbl
= &AuthenticateVtbl
;
168 ret
->username
= hlink_strdupW(pszUsername
);
169 ret
->password
= hlink_strdupW(pszPassword
);
173 ret
->outer
= EXTSERVUNK(ret
);
174 hres
= IUnknown_QueryInterface(EXTSERVUNK(ret
), riid
, ppv
);
175 IUnknown_Release(EXTSERVUNK(ret
));
176 }else if(IsEqualGUID(&IID_IUnknown
, riid
)) {
177 ret
->outer
= punkOuter
;
178 *ppv
= EXTSERVUNK(ret
);
180 IUnknown_Release(EXTSERVUNK(ret
));