From: znek Date: Wed, 30 Jun 2004 12:37:48 +0000 (+0000) Subject: unique id generation X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dd138a177365b2cc7623e6246d25e86fe780a919;p=scalable-opengroupware.org unique id generation git-svn-id: http://svn.opengroupware.org/SOGo/trunk@120 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h index 945f4d1c..08907a0f 100644 --- a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h +++ b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.h @@ -29,6 +29,8 @@ { } ++ (NSString *)globallyUniqueObjectId; + @end #endif /* __Appointments_SOGoAppointmentFolder_H__ */ diff --git a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m index 83162aca..47f00f06 100644 --- a/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SOGo/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -22,9 +22,36 @@ #include "SOGoAppointmentFolder.h" #include "common.h" +#include +#include + @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]; }