address.c 9.78 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
/* 
 * DirectPlay8 Address
 * 
 * Copyright 2004 Raphael Junqueira
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#include "config.h"

#include <stdarg.h>

#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winreg.h"
#include "objbase.h"
#include "wine/debug.h"

#include "dplay8.h"
#include "dpnet_private.h"

WINE_DEFAULT_DEBUG_CHANNEL(dpnet);

/* IDirectPlay8Address IUnknown parts follow: */
HRESULT WINAPI IDirectPlay8AddressImpl_QueryInterface(PDIRECTPLAY8ADDRESS iface, REFIID riid, LPVOID *ppobj)
{
42
    IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
43 44 45 46 47 48 49 50 51 52 53 54 55

    if (IsEqualGUID(riid, &IID_IUnknown)
        || IsEqualGUID(riid, &IID_IDirectPlay8Address)) {
        IDirectPlay8AddressImpl_AddRef(iface);
        *ppobj = This;
        return DPN_OK;
    }

    WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
    return E_NOINTERFACE;
}

ULONG WINAPI IDirectPlay8AddressImpl_AddRef(PDIRECTPLAY8ADDRESS iface) {
56
    IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
57 58 59 60 61
    ULONG refCount = InterlockedIncrement(&This->ref);

    TRACE("(%p)->(ref before=%lu)\n", This, refCount - 1);

    return refCount;
62 63 64
}

ULONG WINAPI IDirectPlay8AddressImpl_Release(PDIRECTPLAY8ADDRESS iface) {
65
    IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
66 67 68 69 70
    ULONG refCount = InterlockedDecrement(&This->ref);

    TRACE("(%p)->(ref before=%lu)\n", This, refCount + 1);

    if (!refCount) {
71 72
        HeapFree(GetProcessHeap(), 0, This);
    }
73
    return refCount;
74 75 76 77
}

/* IDirectPlay8Address Interface follow: */

78
HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLW(PDIRECTPLAY8ADDRESS iface, WCHAR* pwszSourceURL) { 
79
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
80 81 82 83 84
  TRACE("(%p, %s): stub\n", This, debugstr_w(pwszSourceURL));
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromURLA(PDIRECTPLAY8ADDRESS iface, CHAR* pszSourceURL) { 
85
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
86 87 88 89 90
  TRACE("(%p, %s): stub\n", This, pszSourceURL);
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_Duplicate(PDIRECTPLAY8ADDRESS iface, PDIRECTPLAY8ADDRESS* ppdpaNewAddress) { 
91
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
92 93 94 95 96
  TRACE("(%p, %p): stub\n", This, ppdpaNewAddress);
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_SetEqual(PDIRECTPLAY8ADDRESS iface, PDIRECTPLAY8ADDRESS pdpaAddress) { 
97
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
98 99 100 101 102
  TRACE("(%p, %p): stub\n", This, pdpaAddress);
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_IsEqual(PDIRECTPLAY8ADDRESS iface, PDIRECTPLAY8ADDRESS pdpaAddress) { 
103
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
104 105 106 107 108
  TRACE("(%p, %p): stub\n", This, pdpaAddress);
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_Clear(PDIRECTPLAY8ADDRESS iface) { 
109
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
110 111 112 113 114
  TRACE("(%p): stub\n", This);
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_GetURLW(PDIRECTPLAY8ADDRESS iface, WCHAR* pwszURL, PDWORD pdwNumChars) { 
115
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
116 117 118 119 120
  TRACE("(%p): stub\n", This);
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_GetURLA(PDIRECTPLAY8ADDRESS iface, CHAR* pszURL, PDWORD pdwNumChars) { 
121
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
122 123 124 125 126
  TRACE("(%p): stub\n", This);
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_GetSP(PDIRECTPLAY8ADDRESS iface, GUID* pguidSP) { 
127
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
128 129 130 131 132 133
  TRACE("(%p, %p)\n", iface, pguidSP);
  memcpy(pguidSP, &This->SP_guid, sizeof(GUID));
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_GetUserData(PDIRECTPLAY8ADDRESS iface, LPVOID pvUserData, PDWORD pdwBufferSize) { 
134
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
135 136 137 138 139
  TRACE("(%p): stub\n", This);
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_SetSP(PDIRECTPLAY8ADDRESS iface, CONST GUID* CONST pguidSP) { 
140
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
141 142 143 144 145 146
  TRACE("(%p, %s)\n", iface, debugstr_SP(pguidSP));
  memcpy(&This->SP_guid, pguidSP, sizeof(GUID));
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_SetUserData(PDIRECTPLAY8ADDRESS iface, CONST void* CONST pvUserData, CONST DWORD dwDataSize) { 
147
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
148 149 150 151 152
  TRACE("(%p): stub\n", This);
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_GetNumComponents(PDIRECTPLAY8ADDRESS iface, PDWORD pdwNumComponents) { 
153
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
154 155 156 157 158
  TRACE("(%p): stub\n", This);
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByName(PDIRECTPLAY8ADDRESS iface, CONST WCHAR* CONST pwszName, LPVOID pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType) { 
159
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
160 161 162 163 164 165
  TRACE("(%p): stub\n", This);
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_GetComponentByIndex(PDIRECTPLAY8ADDRESS iface, CONST DWORD dwComponentID, WCHAR* pwszName, 
							   PDWORD pdwNameLen, void* pvBuffer, PDWORD pdwBufferSize, PDWORD pdwDataType) { 
166
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
167 168 169 170 171 172
  TRACE("(%p): stub\n", This);
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_AddComponent(PDIRECTPLAY8ADDRESS iface, CONST WCHAR* CONST pwszName, 
						    CONST void* CONST lpvData, CONST DWORD dwDataSize, CONST DWORD dwDataType) { 
173
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
174 175 176 177 178 179
  TRACE("(%p, %s, %p, %lu, %lx): stub\n", This, debugstr_w(pwszName), lpvData, dwDataSize, dwDataType);
  
  if (NULL == lpvData) return DPNERR_INVALIDPOINTER;
  switch (dwDataType) {
  case DPNA_DATATYPE_DWORD:
    if (sizeof(DWORD) != dwDataSize) return DPNERR_INVALIDPARAM;
Eric Pouech's avatar
Eric Pouech committed
180
    TRACE("(%p, %lu): DWORD Type -> %lu \n", lpvData, dwDataSize, *(const DWORD*) lpvData);
181 182 183
    break;
  case DPNA_DATATYPE_GUID:
    if (sizeof(GUID) != dwDataSize) return DPNERR_INVALIDPARAM;
Eric Pouech's avatar
Eric Pouech committed
184
    TRACE("(%p, %lu): GUID Type -> %s \n", lpvData, dwDataSize, debugstr_guid((const GUID*) lpvData));
185 186
    break;
  case DPNA_DATATYPE_STRING:
Eric Pouech's avatar
Eric Pouech committed
187
    TRACE("(%p, %lu): STRING Type -> %s \n", lpvData, dwDataSize, (const CHAR*) lpvData);
188 189 190 191 192 193 194 195 196 197
    break;
  case DPNA_DATATYPE_BINARY:
    TRACE("(%p, %lu): BINARY Type\n", lpvData, dwDataSize);
    break;
  }
  
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_GetDevice(PDIRECTPLAY8ADDRESS iface, GUID* pDevGuid) {   
198
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
199 200 201 202 203
  TRACE("(%p): stub\n", This);
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_SetDevice(PDIRECTPLAY8ADDRESS iface, CONST GUID* CONST devGuid) { 
204
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
205 206 207 208 209
  TRACE("(%p, %s): stub\n", This, debugstr_guid(devGuid));
  return DPN_OK; 
}

HRESULT WINAPI IDirectPlay8AddressImpl_BuildFromDirectPlay4Address(PDIRECTPLAY8ADDRESS iface, LPVOID pvAddress, DWORD dwDataSize) { 
210
  IDirectPlay8AddressImpl *This = (IDirectPlay8AddressImpl *)iface;
211 212 213
  TRACE("(%p): stub\n", This);
  return DPN_OK; 
}
214

215
IDirectPlay8AddressVtbl DirectPlay8Address_Vtbl =
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
{
    IDirectPlay8AddressImpl_QueryInterface,
    IDirectPlay8AddressImpl_AddRef,
    IDirectPlay8AddressImpl_Release,
    IDirectPlay8AddressImpl_BuildFromURLW,
    IDirectPlay8AddressImpl_BuildFromURLA,
    IDirectPlay8AddressImpl_Duplicate,
    IDirectPlay8AddressImpl_SetEqual,
    IDirectPlay8AddressImpl_IsEqual,
    IDirectPlay8AddressImpl_Clear,
    IDirectPlay8AddressImpl_GetURLW,
    IDirectPlay8AddressImpl_GetURLA,
    IDirectPlay8AddressImpl_GetSP,
    IDirectPlay8AddressImpl_GetUserData,
    IDirectPlay8AddressImpl_SetSP,
    IDirectPlay8AddressImpl_SetUserData,
    IDirectPlay8AddressImpl_GetNumComponents,
    IDirectPlay8AddressImpl_GetComponentByName,
    IDirectPlay8AddressImpl_GetComponentByIndex,
    IDirectPlay8AddressImpl_AddComponent,
    IDirectPlay8AddressImpl_GetDevice,
    IDirectPlay8AddressImpl_SetDevice,
    IDirectPlay8AddressImpl_BuildFromDirectPlay4Address
};

HRESULT DPNET_CreateDirectPlay8Address(LPCLASSFACTORY iface, LPUNKNOWN punkOuter, REFIID riid, LPVOID *ppobj) {
  IDirectPlay8AddressImpl* client;

  TRACE("(%p, %s, %p)\n", punkOuter, debugstr_guid(riid), ppobj);
  
  client = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectPlay8AddressImpl));
  if (NULL == client) {
    *ppobj = NULL;
    return E_OUTOFMEMORY;
  }
  client->lpVtbl = &DirectPlay8Address_Vtbl;
  client->ref = 0; /* will be inited with QueryInterface */
  return IDirectPlay8AddressImpl_QueryInterface ((PDIRECTPLAY8ADDRESS)client, riid, ppobj);
}
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275

/* returns name of given GUID */
const char *debugstr_SP(const GUID *id) {
  static const guid_info guids[] = {
    /* CLSIDs */
    GE(CLSID_DP8SP_IPX),
    GE(CLSID_DP8SP_TCPIP),
    GE(CLSID_DP8SP_SERIAL),
    GE(CLSID_DP8SP_MODEM)
  };      
  unsigned int i;

  if (!id) return "(null)";
  
  for (i = 0; i < sizeof(guids)/sizeof(guids[0]); i++) {
    if (IsEqualGUID(id, &guids[i].guid))
      return guids[i].name;
  }
  /* if we didn't find it, act like standard debugstr_guid */	
  return debugstr_guid(id);
}