]> err.no Git - scalable-opengroupware.org/commitdiff
unique id generation
authorznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 30 Jun 2004 12:37:48 +0000 (12:37 +0000)
committerznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 30 Jun 2004 12:37:48 +0000 (12:37 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@120 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h
SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m

index 945f4d1c03547d4edb96c981b639fd8f8a92dd08..08907a0fb272299716e9caabbb6ff937bd652096 100644 (file)
@@ -29,6 +29,8 @@
 {
 }
 
++ (NSString *)globallyUniqueObjectId;
+
 @end
 
 #endif /* __Appointments_SOGoAppointmentFolder_H__ */
index 83162aca28484331a0284b8c222f0ee0a5596c17..47f00f06c013d6cb1696f23a41efcf7f0df01b4a 100644 (file)
 
 #include "SOGoAppointmentFolder.h"
 #include "common.h"
+#include <unistd.h>
+#include <stdlib.h>
+
 
 @implementation SOGoAppointmentFolder
 
++ (NSString *)globallyUniqueObjectId {
+/*
+4C08AE1A-A808-11D8-AC5A-000393BBAFF6
+ SOGo-Web-28273-18283-288182
+printf( "%x", *(int *) &f);
+ */
+    static int pid = 0;
+    static int sequence = 0;
+    static float rndm = 0;
+    float f;
+
+    if(pid == 0) {
+      pid = getpid();
+      rndm = random();
+    }
+    sequence++;
+    f = [[NSDate date] timeIntervalSince1970];
+    return [NSString stringWithFormat:@"%0X-%0X-%0X-%0X",
+        pid,
+        *(int *)&f,
+        sequence++,
+        random];
+}
+
 - (void)dealloc {
   [super dealloc];
 }