diff --git a/ChangeLog b/ChangeLog index a7580efe8..bf362ab63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2010-11-05 Wolfgang Sourdeau + * OpenChange/NSDate+MAPIStore.[hm]: this module now implements a + category for NSDate rather than NSCalendarDate. + (+dateFromFileTime): new method that returns an NSDate from a + struct FILETIME + * SoObjects/Appointments/SOGoAptMailReceipt.m (-getSubject) (-getBody): invoked setupValues if values is nil to ensure that the timezone has been set properly. diff --git a/OpenChange/GNUmakefile b/OpenChange/GNUmakefile index bc78f0db3..9732ce94b 100644 --- a/OpenChange/GNUmakefile +++ b/OpenChange/GNUmakefile @@ -41,7 +41,7 @@ $(MAPISTORESOGO)_OBJC_FILES += \ \ NSArray+MAPIStore.m \ NSData+MAPIStore.m \ - NSCalendarDate+MAPIStore.m \ + NSDate+MAPIStore.m \ NSString+MAPIStore.m -include GNUmakefile.preamble diff --git a/OpenChange/MAPIStoreCalendarContext.m b/OpenChange/MAPIStoreCalendarContext.m index 59fd66983..97e7f51d0 100644 --- a/OpenChange/MAPIStoreCalendarContext.m +++ b/OpenChange/MAPIStoreCalendarContext.m @@ -29,7 +29,7 @@ #import "MAPIApplication.h" #import "MAPIStoreAuthenticator.h" -#import "NSCalendarDate+MAPIStore.h" +#import "NSDate+MAPIStore.h" #import "NSString+MAPIStore.h" #import "SOGoGCSFolder+MAPIStore.h" diff --git a/OpenChange/MAPIStoreMailContext.m b/OpenChange/MAPIStoreMailContext.m index a1f834f5a..46c55a67c 100644 --- a/OpenChange/MAPIStoreMailContext.m +++ b/OpenChange/MAPIStoreMailContext.m @@ -20,6 +20,8 @@ * Boston, MA 02111-1307, USA. */ +#import + #import #import @@ -33,7 +35,7 @@ #import "MAPIApplication.h" #import "MAPIStoreAuthenticator.h" #import "NSData+MAPIStore.h" -#import "NSCalendarDate+MAPIStore.h" +#import "NSDate+MAPIStore.h" #import "NSString+MAPIStore.h" #import "MAPIStoreMailContext.h" @@ -116,7 +118,7 @@ static Class SOGoUserFolderK; withFID: (uint64_t) fid { id child; - NSCalendarDate *offsetDate; + NSDate *offsetDate; int rc; rc = MAPI_E_SUCCESS; @@ -167,7 +169,7 @@ static Class SOGoUserFolderK; case PR_EXPIRY_TIME: // TODO case PR_REPLY_TIME: - *data = [[NSCalendarDate date] asFileTimeInMemCtx: memCtx]; + *data = [[NSDate date] asFileTimeInMemCtx: memCtx]; break; case PR_BODY: diff --git a/OpenChange/MAPIStoreTasksContext.m b/OpenChange/MAPIStoreTasksContext.m index c4fb44e9b..28d01c2e6 100644 --- a/OpenChange/MAPIStoreTasksContext.m +++ b/OpenChange/MAPIStoreTasksContext.m @@ -27,7 +27,7 @@ #import "MAPIApplication.h" #import "MAPIStoreAuthenticator.h" -#import "NSCalendarDate+MAPIStore.h" +#import "NSDate+MAPIStore.h" #import "NSString+MAPIStore.h" #import "SOGoGCSFolder+MAPIStore.h" diff --git a/OpenChange/NSCalendarDate+MAPIStore.h b/OpenChange/NSDate+MAPIStore.h similarity index 85% rename from OpenChange/NSCalendarDate+MAPIStore.h rename to OpenChange/NSDate+MAPIStore.h index 65c4387da..6c096ee0f 100644 --- a/OpenChange/NSCalendarDate+MAPIStore.h +++ b/OpenChange/NSDate+MAPIStore.h @@ -1,4 +1,4 @@ -/* NSCalendarDate+MAPIStore.h - this file is part of SOGo +/* NSDate+MAPIStore.h - this file is part of SOGo * * Copyright (C) 2010 Inverse inc. * @@ -23,9 +23,11 @@ #ifndef NSCALENDARDATE_MAPISTORE_H #define NSCALENDARDATE_MAPISTORE_H -#import +#import -@interface NSCalendarDate (MAPIStoreDataTypes) +@interface NSDate (MAPIStoreDataTypes) + ++ (id) dateFromFileTime: (struct FILETIME *) timeValue; - (struct FILETIME *) asFileTimeInMemCtx: (void *) memCtx; diff --git a/OpenChange/NSCalendarDate+MAPIStore.m b/OpenChange/NSDate+MAPIStore.m similarity index 58% rename from OpenChange/NSCalendarDate+MAPIStore.m rename to OpenChange/NSDate+MAPIStore.m index 03a224c23..2fc18ad47 100644 --- a/OpenChange/NSCalendarDate+MAPIStore.m +++ b/OpenChange/NSDate+MAPIStore.m @@ -1,4 +1,4 @@ -/* NSCalendarDate+MAPIStore.m - this file is part of SOGo +/* NSDate+MAPIStore.m - this file is part of SOGo * * Copyright (C) 2010 Inverse inc. * @@ -20,34 +20,60 @@ * Boston, MA 02111-1307, USA. */ +#import #import #import -#import "NSCalendarDate+MAPIStore.h" +#import "NSDate+MAPIStore.h" #undef DEBUG #include #include -@implementation NSCalendarDate (MAPIStoreDataTypes) +static NSDate *refDate = nil; -- (struct FILETIME *) asFileTimeInMemCtx: (void *) memCtx +@implementation NSDate (MAPIStoreDataTypes) + +static void +_setupRefDate() { - static NSCalendarDate *refDate = nil; - struct FILETIME *timeValue; NSTimeZone *utc; + + utc = [NSTimeZone timeZoneWithName: @"UTC"]; + refDate = [NSCalendarDate dateWithYear: 1601 month: 1 day: 1 + hour: 0 minute: 0 second: 0 + timeZone: utc]; + [refDate retain]; +} + ++ (id) dateFromFileTime: (struct FILETIME *) timeValue +{ + NSDate *result; uint64_t interval; if (!refDate) - { - utc = [NSTimeZone timeZoneWithName: @"UTC"]; - refDate = [NSCalendarDate dateWithYear: 1601 month: 1 day: 1 - hour: 0 minute: 0 second: 0 - timeZone: utc]; - [refDate retain]; - } + _setupRefDate (); + + interval = ((uint64_t) timeValue->dwHighDateTime << 32 + | timeValue->dwLowDateTime); + result = [[NSDate alloc] + initWithTimeInterval: (NSTimeInterval) interval / 10000000 + sinceDate: refDate]; + [result autorelease]; + + return result; +} + +- (struct FILETIME *) asFileTimeInMemCtx: (void *) memCtx +{ + struct FILETIME *timeValue; + uint64_t interval; + + if (!refDate) + _setupRefDate (); + interval = (((uint64_t) [self timeIntervalSinceDate: refDate]) * 10000000); - timeValue = talloc_zero(memCtx, struct FILETIME); + timeValue = talloc_zero (memCtx, struct FILETIME); timeValue->dwLowDateTime = (uint32_t) (interval & 0xffffffff); timeValue->dwHighDateTime = (uint32_t) ((interval >> 32) & 0xffffffff);