[evolution] [win32] Generate UUID on the fly in Windows SENS module



commit 2fabf227bb51ea8eefdb56760103f5b338ba1200
Author: Fridrich Å trba <fridrich strba bluewin ch>
Date:   Thu Mar 25 13:49:48 2010 +0100

    [win32] Generate UUID on the fly in Windows SENS module

 configure.ac                                    |    4 ++--
 modules/windows-sens/evolution-windows-sens.cxx |   21 ++++++++++++++-------
 2 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index cec9257..86ac1b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1154,10 +1154,10 @@ AC_MSG_CHECKING([if Windows SENS support is enabled])
 AC_MSG_RESULT([$enable_sens])
 if test "$enable_sens" = yes; then
 	AC_PROG_CXX
-	AC_CHECK_HEADERS([eventsys.h sensevts.h],[ enable_sens="yes" ],[ enable_sens="no" ])
+	AC_CHECK_HEADERS([eventsys.h sensevts.h rpc.h],[ enable_sens="yes" ],[ enable_sens="no" ])
 fi
 if test "$enable_sens" = yes; then
-	SENS_LIBS="-lole32 -loleaut32 -luuid"
+	SENS_LIBS="-lole32 -loleaut32 -luuid -lrpcrt4"
 	AC_SUBST(HAVE_SENS)
 	AC_SUBST(SENS_LIBS)
 fi
diff --git a/modules/windows-sens/evolution-windows-sens.cxx b/modules/windows-sens/evolution-windows-sens.cxx
index b43e69d..848c893 100644
--- a/modules/windows-sens/evolution-windows-sens.cxx
+++ b/modules/windows-sens/evolution-windows-sens.cxx
@@ -24,9 +24,9 @@ extern "C" {
 #include <windows.h>
 #include <eventsys.h>
 #include <sensevts.h>
+#include <rpc.h>
 #include <stdio.h>
 
-
 #include <shell/e-shell.h>
 #include <e-util/e-extension.h>
 
@@ -194,8 +194,6 @@ windows_sens_constructed (GObject *object)
 	static const char* eventclassid="{D5978620-5B9F-11D1-8DD2-00AA004ABD5E}";
 	static const char* methods[]={"ConnectionMade","ConnectionMadeNoQOCInfo","ConnectionLost","DestinationReachable","DestinationReachableNoQOCInfo"};
 	static const char* names[]={"EWS_ConnectionMade","EWS_ConnectionMadeNoQOCInfo","EWS_ConnectionLost","EWS_DestinationReachable","EWS_DestinationReachableNoQOCInfo"};
-	static const char* subids[]={"{cd1dcbd6-a14d-4823-a0d2-8473afde360f}","{a82f0e80-1305-400c-ba56-375ae04264a1}","{45233130-b6c3-44fb-a6af-487c47cee611}",
-								 "{51377df7-1d29-49eb-af32-4fff77b059fb}","{d16830d3-7a3a-4240-994b-a1fa344385dd}"};
 
 	EWindowsSENS *extension = (E_WINDOWS_SENS (object));
 	static SensNetwork_Listener *pISensNetwork = new SensNetwork_Listener (extension);
@@ -211,15 +209,22 @@ windows_sens_constructed (GObject *object)
 			res=CoCreateInstance (CLSID_CEventSubscription, 0, CLSCTX_SERVER, IID_IEventSubscription, (LPVOID*)&pIEventSubscription);
 
 			if (res == S_OK && pIEventSubscription) {
-				if ((res=pIEventSubscription->put_EventClassID (_mb2wchar (eventclassid))))
+				unsigned char *subid;
+				UUID tmp_uuid;
+				UuidCreate(&tmp_uuid);
+				UuidToString(&tmp_uuid, &subid);
+				if ((res=pIEventSubscription->put_SubscriptionID (_mb2wchar ((char*)subid)))) {
+					RpcStringFree(&subid);
 					break;
-				if ((res=pIEventSubscription->put_SubscriberInterface ((IUnknown*)pISensNetwork)))
+				}
+				RpcStringFree(&subid);
+				if ((res=pIEventSubscription->put_SubscriptionName (_mb2wchar (names[i]))))
 					break;
 				if ((res=pIEventSubscription->put_MethodName (_mb2wchar (methods[i]))))
 					break;
-				if ((res=pIEventSubscription->put_SubscriptionName (_mb2wchar (names[i]))))
+				if ((res=pIEventSubscription->put_EventClassID (_mb2wchar (eventclassid))))
 					break;
-				if ((res=pIEventSubscription->put_SubscriptionID (_mb2wchar (subids[i]))))
+				if ((res=pIEventSubscription->put_SubscriberInterface ((IUnknown*)pISensNetwork)))
 					break;
 				/* Make the subscription receive the event only if the owner of the subscription
 				 * is logged on to the same computer as the publisher. This makes this module
@@ -234,6 +239,8 @@ windows_sens_constructed (GObject *object)
 				pIEventSubscription=0;
 			}
 		}
+		if (pIEventSubscription)
+		pIEventSubscription->Release();
 	}
 	
 	/* Do not try to get initial state when we are sure we will not get system events.



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