Huw Davies : sapi: Implement SpObjectTokenEnum::SetAttribs().

Alexandre Julliard julliard at winehq.org
Thu Sep 28 18:36:35 CDT 2017


Module: wine
Branch: master
Commit: 77b7bd19c5a437dd5cf0cff11050ef9ba105eaa5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=77b7bd19c5a437dd5cf0cff11050ef9ba105eaa5

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Sep 28 08:40:49 2017 +0100

sapi: Implement SpObjectTokenEnum::SetAttribs().

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/sapi/sapi_private.h | 17 +++++++++++++++++
 dlls/sapi/token.c        | 36 ++++++++++++++++++++++++++++++++++--
 2 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/dlls/sapi/sapi_private.h b/dlls/sapi/sapi_private.h
index 7a5c14e..0f6ca4a 100644
--- a/dlls/sapi/sapi_private.h
+++ b/dlls/sapi/sapi_private.h
@@ -18,6 +18,8 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  */
 
+#include "wine/unicode.h"
+
 HRESULT data_key_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN;
 HRESULT token_enum_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN;
 
@@ -30,3 +32,18 @@ static inline BOOL heap_free(void *mem)
 {
     return HeapFree(GetProcessHeap(), 0, mem);
 }
+
+static inline LPWSTR heap_strdupW(LPCWSTR str)
+{
+    LPWSTR ret = NULL;
+    DWORD size;
+
+    if (str)
+    {
+        size = (strlenW( str ) + 1) * sizeof(WCHAR);
+        ret = heap_alloc( size );
+        if (ret) memcpy( ret, str, size );
+    }
+
+    return ret;
+}
diff --git a/dlls/sapi/token.c b/dlls/sapi/token.c
index 03ce0a7..8ad13a8 100644
--- a/dlls/sapi/token.c
+++ b/dlls/sapi/token.c
@@ -231,6 +231,9 @@ struct token_enum
 {
     ISpObjectTokenEnumBuilder ISpObjectTokenEnumBuilder_iface;
     LONG ref;
+
+    BOOL init;
+    WCHAR *req, *opt;
 };
 
 struct token_enum *impl_from_ISpObjectTokenEnumBuilder( ISpObjectTokenEnumBuilder *iface )
@@ -276,7 +279,11 @@ static ULONG WINAPI token_enum_Release( ISpObjectTokenEnumBuilder *iface )
     TRACE( "(%p) ref = %u\n", This, ref );
 
     if (!ref)
+    {
+        heap_free( This->req );
+        heap_free( This->opt );
         heap_free( This );
+    }
 
     return ref;
 }
@@ -326,8 +333,30 @@ static HRESULT WINAPI token_enum_GetCount( ISpObjectTokenEnumBuilder *iface,
 static HRESULT WINAPI token_enum_SetAttribs( ISpObjectTokenEnumBuilder *iface,
                                              LPCWSTR req, LPCWSTR opt)
 {
-    FIXME( "stub\n" );
-    return E_NOTIMPL;
+    struct token_enum *This = impl_from_ISpObjectTokenEnumBuilder( iface );
+
+    TRACE( "(%p)->(%s %s)\n", This, debugstr_w( req ), debugstr_w( opt ) );
+
+    if (This->init) return SPERR_ALREADY_INITIALIZED;
+
+    if (req)
+    {
+        This->req = heap_strdupW( req );
+        if (!This->req) goto out_of_mem;
+    }
+
+    if (opt)
+    {
+        This->opt = heap_strdupW( opt );
+        if (!This->opt) goto out_of_mem;
+    }
+
+    This->init = TRUE;
+    return S_OK;
+
+out_of_mem:
+    heap_free( This->req );
+    return E_OUTOFMEMORY;
 }
 
 static HRESULT WINAPI token_enum_AddTokens( ISpObjectTokenEnumBuilder *iface,
@@ -385,6 +414,9 @@ HRESULT token_enum_create( IUnknown *outer, REFIID iid, void **obj )
     if (!This) return E_OUTOFMEMORY;
     This->ISpObjectTokenEnumBuilder_iface.lpVtbl = &token_enum_vtbl;
     This->ref = 1;
+    This->req = NULL;
+    This->opt = NULL;
+    This->init = FALSE;
 
     hr = ISpObjectTokenEnumBuilder_QueryInterface( &This->ISpObjectTokenEnumBuilder_iface, iid, obj );
 




More information about the wine-cvs mailing list