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 /* IDirectPlay8Address IUnknown parts follow: */
40 static HRESULT WINAPI IDirectPlay8AddressImpl_QueryInterface(PDIRECTPLAY8ADDRESS iface, REFIID riid, LPVOID *ppobj)
42 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
44 if (IsEqualGUID(riid, &IID_IUnknown)
45 || IsEqualGUID(riid, &IID_IDirectPlay8Address)) {
46 IUnknown_AddRef(iface);
51 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
55 static ULONG WINAPI IDirectPlay8AddressImpl_AddRef(PDIRECTPLAY8ADDRESS iface) {
56 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
57 ULONG refCount = InterlockedIncrement(&This->ref);
59 TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
64 static ULONG WINAPI IDirectPlay8AddressImpl_Release(PDIRECTPLAY8ADDRESS iface) {
65 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
66 ULONG refCount = InterlockedDecrement(&This->ref);
68 TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
71 HeapFree(GetProcessHeap(), 0, This);
76 /* IDirectPlay8Address Interface follow: */
78 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLW(PDIRECTPLAY8ADDRESS iface, WCHAR* pwszSourceURL) {
79 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
80 TRACE("(%p, %s): stub\n", This, debugstr_w(pwszSourceURL));
84 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLA(PDIRECTPLAY8ADDRESS iface, CHAR* pszSourceURL) {
85 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
86 TRACE("(%p, %s): stub\n", This, pszSourceURL);
90 static HRESULT WINAPI IDirectPlay8AddressImpl_Duplicate(PDIRECTPLAY8ADDRESS iface, PDIRECTPLAY8ADDRESS* ppdpaNewAddress) {
91 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
92 TRACE("(%p, %p): stub\n", This, ppdpaNewAddress);
96 static HRESULT WINAPI IDirectPlay8AddressImpl_SetEqual(PDIRECTPLAY8ADDRESS iface, PDIRECTPLAY8ADDRESS pdpaAddress) {
97 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
98 TRACE("(%p, %p): stub\n", This, pdpaAddress);
102 static HRESULT WINAPI IDirectPlay8AddressImpl_IsEqual(PDIRECTPLAY8ADDRESS iface, PDIRECTPLAY8ADDRESS pdpaAddress) {
103 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
104 TRACE("(%p, %p): stub\n", This, pdpaAddress);
108 static HRESULT WINAPI IDirectPlay8AddressImpl_Clear(PDIRECTPLAY8ADDRESS iface) {
109 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
110 TRACE("(%p): stub\n", This);
114 static HRESULT WINAPI IDirectPlay8AddressImpl_GetURLW(PDIRECTPLAY8ADDRESS iface, WCHAR* pwszURL, PDWORD pdwNumChars) {
115 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
116 TRACE("(%p): stub\n", This);
120 static HRESULT WINAPI IDirectPlay8AddressImpl_GetURLA(PDIRECTPLAY8ADDRESS iface, CHAR* pszURL, PDWORD pdwNumChars) {
121 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
122 TRACE("(%p): stub\n", This);
126 static HRESULT WINAPI IDirectPlay8AddressImpl_GetSP(PDIRECTPLAY8ADDRESS iface, GUID* pguidSP) {
127 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
128 TRACE("(%p, %p)\n", iface, pguidSP);
129 memcpy(pguidSP, &This->SP_guid, sizeof(GUID));
133 static HRESULT WINAPI IDirectPlay8AddressImpl_GetUserData(PDIRECTPLAY8ADDRESS iface, LPVOID pvUserData, PDWORD pdwBufferSize) {
134 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
135 TRACE("(%p): stub\n", This);
139 static HRESULT WINAPI IDirectPlay8AddressImpl_SetSP(PDIRECTPLAY8ADDRESS iface, CONST GUID* CONST pguidSP) {
140 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
141 TRACE("(%p, %s)\n", iface, debugstr_SP(pguidSP));
142 memcpy(&This->SP_guid, pguidSP, sizeof(GUID));
146 static HRESULT WINAPI IDirectPlay8AddressImpl_SetUserData(PDIRECTPLAY8ADDRESS iface, CONST void* CONST pvUserData, CONST DWORD dwDataSize) {
147 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
148 TRACE("(%p): stub\n", This);
152 static HRESULT WINAPI IDirectPlay8AddressImpl_GetNumComponents(PDIRECTPLAY8ADDRESS iface, PDWORD pdwNumComponents) {
153 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
154 TRACE("(%p): stub\n", This);
158 static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByName(PDIRECTPLAY8ADDRESS iface, CONST WCHAR* CONST pwszName, LPVOID pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType) {
159 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
160 TRACE("(%p): stub\n", This);
164 static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByIndex(PDIRECTPLAY8ADDRESS iface, CONST DWORD dwComponentID, WCHAR* pwszName,
165 PDWORD pdwNameLen, void* pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType) {
166 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
167 TRACE("(%p): stub\n", This);
171 static HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(PDIRECTPLAY8ADDRESS iface, CONST WCHAR* CONST pwszName,
172 CONST void* CONST lpvData, CONST DWORD dwDataSize, CONST DWORD dwDataType) {
173 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
174 TRACE("(%p, %s, %p, %u, %x): stub\n", This, debugstr_w(pwszName), lpvData, dwDataSize, dwDataType);
176 if (NULL == lpvData) return DPNERR_INVALIDPOINTER;
177 switch (dwDataType) {
178 case DPNA_DATATYPE_DWORD:
179 if (sizeof(DWORD) != dwDataSize) return DPNERR_INVALIDPARAM;
180 TRACE("(%p, %u): DWORD Type -> %u\n", lpvData, dwDataSize, *(const DWORD*) lpvData);
182 case DPNA_DATATYPE_GUID:
183 if (sizeof(GUID) != dwDataSize) return DPNERR_INVALIDPARAM;
184 TRACE("(%p, %u): GUID Type -> %s\n", lpvData, dwDataSize, debugstr_guid((const GUID*) lpvData));
186 case DPNA_DATATYPE_STRING:
187 TRACE("(%p, %u): STRING Type -> %s\n", lpvData, dwDataSize, (const CHAR*) lpvData);
189 case DPNA_DATATYPE_BINARY:
190 TRACE("(%p, %u): BINARY Type\n", lpvData, dwDataSize);
197 static HRESULT WINAPI IDirectPlay8AddressImpl_GetDevice(PDIRECTPLAY8ADDRESS iface, GUID* pDevGuid) {
198 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
199 TRACE("(%p): stub\n", This);
203 static HRESULT WINAPI IDirectPlay8AddressImpl_SetDevice(PDIRECTPLAY8ADDRESS iface, CONST GUID* CONST devGuid) {
204 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
205 TRACE("(%p, %s): stub\n", This, debugstr_guid(devGuid));
209 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromDirectPlay4Address(PDIRECTPLAY8ADDRESS iface, LPVOID pvAddress, DWORD dwDataSize) {
210 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
211 TRACE("(%p): stub\n", This);
215 static const IDirectPlay8AddressVtbl DirectPlay8Address_Vtbl =
217 IDirectPlay8AddressImpl_QueryInterface,
218 IDirectPlay8AddressImpl_AddRef,
219 IDirectPlay8AddressImpl_Release,
220 IDirectPlay8AddressImpl_BuildFromURLW,
221 IDirectPlay8AddressImpl_BuildFromURLA,
222 IDirectPlay8AddressImpl_Duplicate,
223 IDirectPlay8AddressImpl_SetEqual,
224 IDirectPlay8AddressImpl_IsEqual,
225 IDirectPlay8AddressImpl_Clear,
226 IDirectPlay8AddressImpl_GetURLW,
227 IDirectPlay8AddressImpl_GetURLA,
228 IDirectPlay8AddressImpl_GetSP,
229 IDirectPlay8AddressImpl_GetUserData,
230 IDirectPlay8AddressImpl_SetSP,
231 IDirectPlay8AddressImpl_SetUserData,
232 IDirectPlay8AddressImpl_GetNumComponents,
233 IDirectPlay8AddressImpl_GetComponentByName,
234 IDirectPlay8AddressImpl_GetComponentByIndex,
235 IDirectPlay8AddressImpl_AddComponent,
236 IDirectPlay8AddressImpl_GetDevice,
237 IDirectPlay8AddressImpl_SetDevice,
238 IDirectPlay8AddressImpl_BuildFromDirectPlay4Address
241 HRESULT DPNET_CreateDirectPlay8Address(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
242 IDirectPlay8AddressImpl* client;
244 TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
246 client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8AddressImpl));
247 if (NULL == client) {
249 return E_OUTOFMEMORY;
251 client->lpVtbl = &DirectPlay8Address_Vtbl;
252 client->ref = 0; /* will be inited with QueryInterface */
253 return IDirectPlay8AddressImpl_QueryInterface ((PDIRECTPLAY8ADDRESS)client, riid, ppobj);
256 /* returns name of given GUID */
257 const char *debugstr_SP(const GUID *id) {
258 static const guid_info guids[] = {
261 GE(CLSID_DP8SP_TCPIP),
262 GE(CLSID_DP8SP_SERIAL),
263 GE(CLSID_DP8SP_MODEM)
267 if (!id) return "(null)";
269 for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
270 if (IsEqualGUID(id, guids[i].guid))
271 return guids[i].name;
273 /* if we didn't find it, act like standard debugstr_guid */
274 return debugstr_guid(id);