4 * Copyright 2004 Raphael Junqueira
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/debug.h"
35 #include "dpnet_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(dpnet
);
39 static inline IDirectPlay8AddressImpl
*impl_from_IDirectPlay8Address(IDirectPlay8Address
*iface
)
41 return CONTAINING_RECORD(iface
, IDirectPlay8AddressImpl
, IDirectPlay8Address_iface
);
44 /* IDirectPlay8Address IUnknown parts follow: */
45 static HRESULT WINAPI
IDirectPlay8AddressImpl_QueryInterface(IDirectPlay8Address
*iface
,
46 REFIID riid
, void **ppv
)
48 if (IsEqualGUID(riid
, &IID_IUnknown
) || IsEqualGUID(riid
, &IID_IDirectPlay8Address
)) {
49 IUnknown_AddRef(iface
);
54 WARN("(%p)->(%s,%p),not found\n", iface
, debugstr_guid(riid
), ppv
);
58 static ULONG WINAPI
IDirectPlay8AddressImpl_AddRef(IDirectPlay8Address
*iface
)
60 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
61 ULONG ref
= InterlockedIncrement(&This
->ref
);
63 TRACE("(%p) ref=%u\n", This
, ref
);
68 static ULONG WINAPI
IDirectPlay8AddressImpl_Release(IDirectPlay8Address
*iface
)
70 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
71 ULONG ref
= InterlockedDecrement(&This
->ref
);
73 TRACE("(%p) ref=%u\n", This
, ref
);
76 HeapFree(GetProcessHeap(), 0, This
);
81 /* returns name of given GUID */
82 static const char *debugstr_SP(const GUID
*id
) {
83 static const guid_info guids
[] = {
86 GE(CLSID_DP8SP_TCPIP
),
87 GE(CLSID_DP8SP_SERIAL
),
92 if (!id
) return "(null)";
94 for (i
= 0; i
< sizeof(guids
)/sizeof(guids
[0]); i
++) {
95 if (IsEqualGUID(id
, guids
[i
].guid
))
98 /* if we didn't find it, act like standard debugstr_guid */
99 return debugstr_guid(id
);
102 /* IDirectPlay8Address Interface follow: */
104 static HRESULT WINAPI
IDirectPlay8AddressImpl_BuildFromURLW(IDirectPlay8Address
*iface
,
105 WCHAR
*pwszSourceURL
)
107 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
108 TRACE("(%p, %s): stub\n", This
, debugstr_w(pwszSourceURL
));
112 static HRESULT WINAPI
IDirectPlay8AddressImpl_BuildFromURLA(IDirectPlay8Address
*iface
,
115 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
116 TRACE("(%p, %s): stub\n", This
, pszSourceURL
);
120 static HRESULT WINAPI
IDirectPlay8AddressImpl_Duplicate(IDirectPlay8Address
*iface
,
121 IDirectPlay8Address
**ppdpaNewAddress
)
123 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
124 TRACE("(%p, %p): stub\n", This
, ppdpaNewAddress
);
128 static HRESULT WINAPI
IDirectPlay8AddressImpl_SetEqual(IDirectPlay8Address
*iface
,
129 IDirectPlay8Address
*pdpaAddress
)
131 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
132 TRACE("(%p, %p): stub\n", This
, pdpaAddress
);
136 static HRESULT WINAPI
IDirectPlay8AddressImpl_IsEqual(IDirectPlay8Address
*iface
,
137 IDirectPlay8Address
*pdpaAddress
)
139 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
140 TRACE("(%p, %p): stub\n", This
, pdpaAddress
);
144 static HRESULT WINAPI
IDirectPlay8AddressImpl_Clear(IDirectPlay8Address
*iface
)
146 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
147 TRACE("(%p): stub\n", This
);
151 static HRESULT WINAPI
IDirectPlay8AddressImpl_GetURLW(IDirectPlay8Address
*iface
, WCHAR
*pwszURL
,
154 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
155 TRACE("(%p): stub\n", This
);
159 static HRESULT WINAPI
IDirectPlay8AddressImpl_GetURLA(IDirectPlay8Address
*iface
, CHAR
*pszURL
,
162 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
163 TRACE("(%p): stub\n", This
);
167 static HRESULT WINAPI
IDirectPlay8AddressImpl_GetSP(IDirectPlay8Address
*iface
, GUID
*pguidSP
)
169 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
171 TRACE("(%p, %p)\n", iface
, pguidSP
);
174 return DPNERR_INVALIDPOINTER
;
177 return DPNERR_DOESNOTEXIST
;
179 *pguidSP
= This
->SP_guid
;
183 static HRESULT WINAPI
IDirectPlay8AddressImpl_GetUserData(IDirectPlay8Address
*iface
,
184 void *pvUserData
, DWORD
*pdwBufferSize
)
186 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
187 TRACE("(%p): stub\n", This
);
191 static HRESULT WINAPI
IDirectPlay8AddressImpl_SetSP(IDirectPlay8Address
*iface
,
192 const GUID
*const pguidSP
)
194 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
196 TRACE("(%p, %s)\n", iface
, debugstr_SP(pguidSP
));
199 return DPNERR_INVALIDPOINTER
;
202 This
->SP_guid
= *pguidSP
;
206 static HRESULT WINAPI
IDirectPlay8AddressImpl_SetUserData(IDirectPlay8Address
*iface
,
207 const void *const pvUserData
, const DWORD dwDataSize
)
209 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
210 TRACE("(%p): stub\n", This
);
214 static HRESULT WINAPI
IDirectPlay8AddressImpl_GetNumComponents(IDirectPlay8Address
*iface
,
215 DWORD
*pdwNumComponents
)
217 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
218 TRACE("(%p): stub\n", This
);
222 static HRESULT WINAPI
IDirectPlay8AddressImpl_GetComponentByName(IDirectPlay8Address
*iface
,
223 const WCHAR
*const pwszName
, void *pvBuffer
, DWORD
*pdwBufferSize
, DWORD
*pdwDataType
)
225 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
226 TRACE("(%p): stub\n", This
);
230 static HRESULT WINAPI
IDirectPlay8AddressImpl_GetComponentByIndex(IDirectPlay8Address
*iface
,
231 const DWORD dwComponentID
, WCHAR
*pwszName
, DWORD
*pdwNameLen
, void *pvBuffer
,
232 DWORD
*pdwBufferSize
, DWORD
*pdwDataType
)
234 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
235 TRACE("(%p): stub\n", This
);
239 static HRESULT WINAPI
IDirectPlay8AddressImpl_AddComponent(IDirectPlay8Address
*iface
,
240 const WCHAR
*const pwszName
, const void* const lpvData
, const DWORD dwDataSize
,
241 const DWORD dwDataType
)
243 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
244 TRACE("(%p, %s, %p, %u, %x): stub\n", This
, debugstr_w(pwszName
), lpvData
, dwDataSize
, dwDataType
);
246 if (NULL
== lpvData
) return DPNERR_INVALIDPOINTER
;
247 switch (dwDataType
) {
248 case DPNA_DATATYPE_DWORD
:
249 if (sizeof(DWORD
) != dwDataSize
) return DPNERR_INVALIDPARAM
;
250 TRACE("(%p, %u): DWORD Type -> %u\n", lpvData
, dwDataSize
, *(const DWORD
*) lpvData
);
252 case DPNA_DATATYPE_GUID
:
253 if (sizeof(GUID
) != dwDataSize
) return DPNERR_INVALIDPARAM
;
254 TRACE("(%p, %u): GUID Type -> %s\n", lpvData
, dwDataSize
, debugstr_guid(lpvData
));
256 case DPNA_DATATYPE_STRING
:
257 TRACE("(%p, %u): STRING Type -> %s\n", lpvData
, dwDataSize
, (const CHAR
*) lpvData
);
259 case DPNA_DATATYPE_BINARY
:
260 TRACE("(%p, %u): BINARY Type\n", lpvData
, dwDataSize
);
267 static HRESULT WINAPI
IDirectPlay8AddressImpl_GetDevice(IDirectPlay8Address
*iface
, GUID
*pDevGuid
) {
268 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
269 TRACE("(%p): stub\n", This
);
273 static HRESULT WINAPI
IDirectPlay8AddressImpl_SetDevice(IDirectPlay8Address
*iface
,
274 const GUID
*const devGuid
)
276 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
277 TRACE("(%p, %s): stub\n", This
, debugstr_guid(devGuid
));
281 static HRESULT WINAPI
IDirectPlay8AddressImpl_BuildFromDirectPlay4Address(IDirectPlay8Address
*iface
,
282 void *pvAddress
, DWORD dwDataSize
)
284 IDirectPlay8AddressImpl
*This
= impl_from_IDirectPlay8Address(iface
);
285 TRACE("(%p): stub\n", This
);
289 static const IDirectPlay8AddressVtbl DirectPlay8Address_Vtbl
=
291 IDirectPlay8AddressImpl_QueryInterface
,
292 IDirectPlay8AddressImpl_AddRef
,
293 IDirectPlay8AddressImpl_Release
,
294 IDirectPlay8AddressImpl_BuildFromURLW
,
295 IDirectPlay8AddressImpl_BuildFromURLA
,
296 IDirectPlay8AddressImpl_Duplicate
,
297 IDirectPlay8AddressImpl_SetEqual
,
298 IDirectPlay8AddressImpl_IsEqual
,
299 IDirectPlay8AddressImpl_Clear
,
300 IDirectPlay8AddressImpl_GetURLW
,
301 IDirectPlay8AddressImpl_GetURLA
,
302 IDirectPlay8AddressImpl_GetSP
,
303 IDirectPlay8AddressImpl_GetUserData
,
304 IDirectPlay8AddressImpl_SetSP
,
305 IDirectPlay8AddressImpl_SetUserData
,
306 IDirectPlay8AddressImpl_GetNumComponents
,
307 IDirectPlay8AddressImpl_GetComponentByName
,
308 IDirectPlay8AddressImpl_GetComponentByIndex
,
309 IDirectPlay8AddressImpl_AddComponent
,
310 IDirectPlay8AddressImpl_GetDevice
,
311 IDirectPlay8AddressImpl_SetDevice
,
312 IDirectPlay8AddressImpl_BuildFromDirectPlay4Address
315 HRESULT
DPNET_CreateDirectPlay8Address(IClassFactory
*iface
, IUnknown
*pUnkOuter
, REFIID riid
, LPVOID
*ppobj
)
317 IDirectPlay8AddressImpl
* client
;
320 TRACE("(%p, %s, %p)\n", pUnkOuter
, debugstr_guid(riid
), ppobj
);
324 client
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(IDirectPlay8AddressImpl
));
326 return E_OUTOFMEMORY
;
328 client
->IDirectPlay8Address_iface
.lpVtbl
= &DirectPlay8Address_Vtbl
;
331 ret
= IDirectPlay8AddressImpl_QueryInterface(&client
->IDirectPlay8Address_iface
, riid
, ppobj
);
332 IDirectPlay8AddressImpl_Release(&client
->IDirectPlay8Address_iface
);