[PATCH 2/4] Use Windows's built-in UUID generator



---
 configure.ac             |    2 ++
 libgupnp/gupnp-service.c |   16 +++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4b84271..af4569d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,8 @@ if test "x$os_win32" = "xno"; then
                         [--with-context-manager=@<:@network-manager/unix@:>@],
                         [Context Manager backend to use]),,
             [with_context_manager="unix"])
+else
+    LIBGUPNP_LIBS="$LIBGUPNP_LIBS -lrpcrt4"
 fi
 
 AC_MSG_CHECKING([Context Manager backend to use])
diff --git a/libgupnp/gupnp-service.c b/libgupnp/gupnp-service.c
index 146d609..e48a1d6 100644
--- a/libgupnp/gupnp-service.c
+++ b/libgupnp/gupnp-service.c
@@ -31,6 +31,7 @@
 #include <gmodule.h>
 #include <libsoup/soup-date.h>
 #ifdef G_OS_WIN32
+#include <rpc.h>
 #else
 #include <uuid/uuid.h>
 #endif
@@ -1073,7 +1074,20 @@ static char *
 generate_sid (void)
 {
 #ifdef G_OS_WIN32
-        return NULL;
+        char *ret = NULL;
+        UUID uuid;
+        RPC_STATUS stat;
+        stat = UuidCreate(&uuid);
+        if (stat == RPC_S_OK) {
+                unsigned char* uuidStr = NULL;
+                stat = UuidToString(&uuid, &uuidStr);
+                if (stat == RPC_S_OK) {
+                        ret = g_strdup_printf("uuid:%s", uuidStr);
+                        RpcStringFree(&uuidStr);
+                }
+        }
+
+        return ret;
 #else
         uuid_t id;
         char out[39];
-- 
1.7.5.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]