[2/2] dpnet: Partial Implement IDirectPlay8Peer SetPeerInfo

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Fri Jan 10 01:18:46 CST 2014


Hi,


Changelog:
     dpnet: Partial Implement IDirectPlay8Peer SetPeerInfo


Best Regards
  Alistair Leslie-Hughes
-------------- next part --------------
>From 6fe03b2f5fedd0ac3daa0d2a26247436236f4153 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Fri, 10 Jan 2014 11:10:40 +1100
Subject: [PATCH] Partial Implement IDirectPlay8Peer SetPeerInfo
To: wine-patches <wine-patches at winehq.org>

---
 dlls/dpnet/peer.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/dlls/dpnet/peer.c b/dlls/dpnet/peer.c
index 1b287dd..b6c00da 100644
--- a/dlls/dpnet/peer.c
+++ b/dlls/dpnet/peer.c
@@ -43,6 +43,10 @@ typedef struct IDirectPlay8PeerImpl
 {
     IDirectPlay8Peer IDirectPlay8Peer_iface;
     LONG ref;
+
+    PWSTR peername;
+    void* data;
+    int datasize;
 } IDirectPlay8PeerImpl;
 
 static inline IDirectPlay8PeerImpl *impl_from_IDirectPlay8Peer(IDirectPlay8Peer *iface)
@@ -86,7 +90,14 @@ static ULONG WINAPI IDirectPlay8PeerImpl_Release(IDirectPlay8Peer *iface)
     TRACE("(%p) ref=%d\n", This, RefCount);
 
     if(!RefCount)
+    {
+        if(This->peername)
+            HeapFree(GetProcessHeap(), 0, This->peername);
+        if(This->data)
+            HeapFree(GetProcessHeap(), 0, This->data);
+
         HeapFree(GetProcessHeap(), 0, This);
+    }
 
     return RefCount;
 }
@@ -292,9 +303,31 @@ static HRESULT WINAPI IDirectPlay8PeerImpl_SetPeerInfo(IDirectPlay8Peer *iface,
         const DPN_PLAYER_INFO * const pdpnPlayerInfo, void * const pvAsyncContext,
         DPNHANDLE * const phAsyncHandle, const DWORD dwFlags)
 {
-    FIXME("(%p)->(%p,%p,%p,%x): stub\n", iface, pdpnPlayerInfo, pvAsyncContext, phAsyncHandle, dwFlags);
+    IDirectPlay8PeerImpl* This = impl_from_IDirectPlay8Peer(iface);
 
-    return DPNERR_GENERIC;
+    TRACE("(%p)->(%p,%p,%p,%x)\n", This, pdpnPlayerInfo, pvAsyncContext, phAsyncHandle, dwFlags);
+
+    if(pdpnPlayerInfo->dwInfoFlags & DPNINFO_NAME)
+    {
+        int len;
+
+        if(This->peername)
+            HeapFree(GetProcessHeap(), 0, This->peername);
+        len = lstrlenW(pdpnPlayerInfo->pwszName);
+        This->peername = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
+        memcpy(This->peername, pdpnPlayerInfo->pwszName, len * sizeof(WCHAR));
+    }
+
+    if(pdpnPlayerInfo->dwInfoFlags & DPNINFO_DATA)
+    {
+        if(This->data)
+            HeapFree(GetProcessHeap(), 0, This->data);
+
+        This->data = HeapAlloc(GetProcessHeap(), 0, pdpnPlayerInfo->dwDataSize);
+        memcpy(This->data, pdpnPlayerInfo->pvData, pdpnPlayerInfo->dwDataSize);
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI IDirectPlay8PeerImpl_GetPeerInfo(IDirectPlay8Peer *iface, const DPNID dpnid,
@@ -502,6 +535,9 @@ HRESULT DPNET_CreateDirectPlay8Peer(IClassFactory *iface, IUnknown *pUnkOuter, R
 
     Client->IDirectPlay8Peer_iface.lpVtbl = &DirectPlay8Peer_Vtbl;
     Client->ref = 1;
+    Client->peername = NULL;
+    Client->data = NULL;
+    Client->datasize = 0;
 
     ret = IDirectPlay8Peer_QueryInterface(&Client->IDirectPlay8Peer_iface, riid, ppobj);
     IDirectPlay8Peer_Release(&Client->IDirectPlay8Peer_iface);
-- 
1.8.3.2



More information about the wine-patches mailing list