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
33 #include "wine/debug.h"
36 #include "dpnet_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(dpnet);
40 /* IDirectPlay8Address IUnknown parts follow: */
41 static HRESULT WINAPI IDirectPlay8AddressImpl_QueryInterface(PDIRECTPLAY8ADDRESS iface, REFIID riid, LPVOID *ppobj)
43 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
45 if (IsEqualGUID(riid, &IID_IUnknown)
46 || IsEqualGUID(riid, &IID_IDirectPlay8Address)) {
47 IUnknown_AddRef(iface);
52 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
56 static ULONG WINAPI IDirectPlay8AddressImpl_AddRef(PDIRECTPLAY8ADDRESS iface) {
57 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
58 ULONG refCount = InterlockedIncrement(&This->ref);
60 TRACE("(%p)->(ref before=%u)\n", This, refCount - 1);
65 static ULONG WINAPI IDirectPlay8AddressImpl_Release(PDIRECTPLAY8ADDRESS iface) {
66 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
67 ULONG refCount = InterlockedDecrement(&This->ref);
69 TRACE("(%p)->(ref before=%u)\n", This, refCount + 1);
72 HeapFree(GetProcessHeap(), 0, This);
77 /* IDirectPlay8Address Interface follow: */
79 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLW(PDIRECTPLAY8ADDRESS iface, WCHAR* pwszSourceURL) {
80 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
81 TRACE("(%p, %s): stub\n", This, debugstr_w(pwszSourceURL));
85 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLA(PDIRECTPLAY8ADDRESS iface, CHAR* pszSourceURL) {
86 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
87 TRACE("(%p, %s): stub\n", This, pszSourceURL);
91 static HRESULT WINAPI IDirectPlay8AddressImpl_Duplicate(PDIRECTPLAY8ADDRESS iface, PDIRECTPLAY8ADDRESS* ppdpaNewAddress) {
92 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
93 TRACE("(%p, %p): stub\n", This, ppdpaNewAddress);
97 static HRESULT WINAPI IDirectPlay8AddressImpl_SetEqual(PDIRECTPLAY8ADDRESS iface, PDIRECTPLAY8ADDRESS pdpaAddress) {
98 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
99 TRACE("(%p, %p): stub\n", This, pdpaAddress);
103 static HRESULT WINAPI IDirectPlay8AddressImpl_IsEqual(PDIRECTPLAY8ADDRESS iface, PDIRECTPLAY8ADDRESS pdpaAddress) {
104 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
105 TRACE("(%p, %p): stub\n", This, pdpaAddress);
109 static HRESULT WINAPI IDirectPlay8AddressImpl_Clear(PDIRECTPLAY8ADDRESS iface) {
110 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
111 TRACE("(%p): stub\n", This);
115 static HRESULT WINAPI IDirectPlay8AddressImpl_GetURLW(PDIRECTPLAY8ADDRESS iface, WCHAR* pwszURL, PDWORD pdwNumChars) {
116 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
117 TRACE("(%p): stub\n", This);
121 static HRESULT WINAPI IDirectPlay8AddressImpl_GetURLA(PDIRECTPLAY8ADDRESS iface, CHAR* pszURL, PDWORD pdwNumChars) {
122 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
123 TRACE("(%p): stub\n", This);
127 static HRESULT WINAPI IDirectPlay8AddressImpl_GetSP(PDIRECTPLAY8ADDRESS iface, GUID* pguidSP) {
128 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
129 TRACE("(%p, %p)\n", iface, pguidSP);
130 memcpy(pguidSP, &This->SP_guid, sizeof(GUID));
134 static HRESULT WINAPI IDirectPlay8AddressImpl_GetUserData(PDIRECTPLAY8ADDRESS iface, LPVOID pvUserData, PDWORD pdwBufferSize) {
135 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
136 TRACE("(%p): stub\n", This);
140 static HRESULT WINAPI IDirectPlay8AddressImpl_SetSP(PDIRECTPLAY8ADDRESS iface, CONST GUID* CONST pguidSP) {
141 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
142 TRACE("(%p, %s)\n", iface, debugstr_SP(pguidSP));
143 memcpy(&This->SP_guid, pguidSP, sizeof(GUID));
147 static HRESULT WINAPI IDirectPlay8AddressImpl_SetUserData(PDIRECTPLAY8ADDRESS iface, CONST void* CONST pvUserData, CONST DWORD dwDataSize) {
148 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
149 TRACE("(%p): stub\n", This);
153 static HRESULT WINAPI IDirectPlay8AddressImpl_GetNumComponents(PDIRECTPLAY8ADDRESS iface, PDWORD pdwNumComponents) {
154 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
155 TRACE("(%p): stub\n", This);
159 static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByName(PDIRECTPLAY8ADDRESS iface, CONST WCHAR* CONST pwszName, LPVOID pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType) {
160 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
161 TRACE("(%p): stub\n", This);
165 static HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByIndex(PDIRECTPLAY8ADDRESS iface, CONST DWORD dwComponentID, WCHAR* pwszName,
166 PDWORD pdwNameLen, void* pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType) {
167 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
168 TRACE("(%p): stub\n", This);
172 static HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(PDIRECTPLAY8ADDRESS iface, CONST WCHAR* CONST pwszName,
173 CONST void* CONST lpvData, CONST DWORD dwDataSize, CONST DWORD dwDataType) {
174 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
175 TRACE("(%p, %s, %p, %u, %x): stub\n", This, debugstr_w(pwszName), lpvData, dwDataSize, dwDataType);
177 if (NULL == lpvData) return DPNERR_INVALIDPOINTER;
178 switch (dwDataType) {
179 case DPNA_DATATYPE_DWORD:
180 if (sizeof(DWORD) != dwDataSize) return DPNERR_INVALIDPARAM;
181 TRACE("(%p, %u): DWORD Type -> %u\n", lpvData, dwDataSize, *(const DWORD*) lpvData);
183 case DPNA_DATATYPE_GUID:
184 if (sizeof(GUID) != dwDataSize) return DPNERR_INVALIDPARAM;
185 TRACE("(%p, %u): GUID Type -> %s\n", lpvData, dwDataSize, debugstr_guid((const GUID*) lpvData));
187 case DPNA_DATATYPE_STRING:
188 TRACE("(%p, %u): STRING Type -> %s\n", lpvData, dwDataSize, (const CHAR*) lpvData);
190 case DPNA_DATATYPE_BINARY:
191 TRACE("(%p, %u): BINARY Type\n", lpvData, dwDataSize);
198 static HRESULT WINAPI IDirectPlay8AddressImpl_GetDevice(PDIRECTPLAY8ADDRESS iface, GUID* pDevGuid) {
199 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
200 TRACE("(%p): stub\n", This);
204 static HRESULT WINAPI IDirectPlay8AddressImpl_SetDevice(PDIRECTPLAY8ADDRESS iface, CONST GUID* CONST devGuid) {
205 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
206 TRACE("(%p, %s): stub\n", This, debugstr_guid(devGuid));
210 static HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromDirectPlay4Address(PDIRECTPLAY8ADDRESS iface, LPVOID pvAddress, DWORD dwDataSize) {
211 IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
212 TRACE("(%p): stub\n", This);
216 static const IDirectPlay8AddressVtbl DirectPlay8Address_Vtbl =
218 IDirectPlay8AddressImpl_QueryInterface,
219 IDirectPlay8AddressImpl_AddRef,
220 IDirectPlay8AddressImpl_Release,
221 IDirectPlay8AddressImpl_BuildFromURLW,
222 IDirectPlay8AddressImpl_BuildFromURLA,
223 IDirectPlay8AddressImpl_Duplicate,
224 IDirectPlay8AddressImpl_SetEqual,
225 IDirectPlay8AddressImpl_IsEqual,
226 IDirectPlay8AddressImpl_Clear,
227 IDirectPlay8AddressImpl_GetURLW,
228 IDirectPlay8AddressImpl_GetURLA,
229 IDirectPlay8AddressImpl_GetSP,
230 IDirectPlay8AddressImpl_GetUserData,
231 IDirectPlay8AddressImpl_SetSP,
232 IDirectPlay8AddressImpl_SetUserData,
233 IDirectPlay8AddressImpl_GetNumComponents,
234 IDirectPlay8AddressImpl_GetComponentByName,
235 IDirectPlay8AddressImpl_GetComponentByIndex,
236 IDirectPlay8AddressImpl_AddComponent,
237 IDirectPlay8AddressImpl_GetDevice,
238 IDirectPlay8AddressImpl_SetDevice,
239 IDirectPlay8AddressImpl_BuildFromDirectPlay4Address
242 HRESULT DPNET_CreateDirectPlay8Address(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
243 IDirectPlay8AddressImpl* client;
245 TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
247 client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8AddressImpl));
248 if (NULL == client) {
250 return E_OUTOFMEMORY;
252 client->lpVtbl = &DirectPlay8Address_Vtbl;
253 client->ref = 0; /* will be inited with QueryInterface */
254 return IDirectPlay8AddressImpl_QueryInterface ((PDIRECTPLAY8ADDRESS)client, riid, ppobj);
257 /* returns name of given GUID */
258 const char *debugstr_SP(const GUID *id) {
259 static const guid_info guids[] = {
262 GE(CLSID_DP8SP_TCPIP),
263 GE(CLSID_DP8SP_SERIAL),
264 GE(CLSID_DP8SP_MODEM)
268 if (!id) return "(null)";
270 for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
271 if (IsEqualGUID(id, &guids[i].guid))
272 return guids[i].name;
274 /* if we didn't find it, act like standard debugstr_guid */
275 return debugstr_guid(id);