Monotone-Parent: fb3ae1be0d4c0ad6fd7491bea70eefa829243ad4
Monotone-Revision: ae1a7958cd81c59ed7bbcddc2a53188885222d07 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-06-04T00:11:43 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
parent
41076b397f
commit
33ae25f6be
|
@ -1,5 +1,12 @@
|
||||||
2011-06-03 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2011-06-03 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* OpenChange/SOGoMAPIFSMessage.m (-completeFilename): new method
|
||||||
|
that returns the full filename for the property list file.
|
||||||
|
(-appendProperties:) simplified method.
|
||||||
|
(-save) removed obsolete hack.
|
||||||
|
(-creationTime, -lastModificationTime): new self-explicit
|
||||||
|
accessors.
|
||||||
|
|
||||||
* OpenChange/MAPIStoreSOGo.m (sogo_op_opendir): op_opendir no
|
* OpenChange/MAPIStoreSOGo.m (sogo_op_opendir): op_opendir no
|
||||||
longer takes the parent fid as parameter.
|
longer takes the parent fid as parameter.
|
||||||
|
|
||||||
|
|
|
@ -31,12 +31,18 @@
|
||||||
@interface SOGoMAPIFSMessage : SOGoObject
|
@interface SOGoMAPIFSMessage : SOGoObject
|
||||||
{
|
{
|
||||||
NSMutableDictionary *properties;
|
NSMutableDictionary *properties;
|
||||||
|
NSString *completeFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDictionary *) properties;
|
- (NSDictionary *) properties;
|
||||||
- (void) appendProperties: (NSDictionary *) newProperties;
|
- (void) appendProperties: (NSDictionary *) newProperties;
|
||||||
- (void) save;
|
- (void) save;
|
||||||
|
|
||||||
|
- (NSString *) completeFilename;
|
||||||
|
|
||||||
|
- (NSCalendarDate *) creationTime;
|
||||||
|
- (NSCalendarDate *) lastModificationTime;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif /* SOGOMAPIFSMESSAGE_H */
|
#endif /* SOGOMAPIFSMESSAGE_H */
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
{
|
{
|
||||||
properties = nil;
|
properties = nil;
|
||||||
|
completeFilename = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -47,19 +48,28 @@
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[properties release];
|
[properties release];
|
||||||
|
[completeFilename release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *) completeFilename
|
||||||
|
{
|
||||||
|
if (!completeFilename)
|
||||||
|
{
|
||||||
|
completeFilename = [[container directory]
|
||||||
|
stringByAppendingPathComponent: nameInContainer];
|
||||||
|
[completeFilename retain];
|
||||||
|
}
|
||||||
|
|
||||||
|
return completeFilename;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSDictionary *) properties
|
- (NSDictionary *) properties
|
||||||
{
|
{
|
||||||
NSString *filePath;
|
|
||||||
|
|
||||||
if (!properties)
|
if (!properties)
|
||||||
{
|
{
|
||||||
filePath = [[container directory]
|
|
||||||
stringByAppendingPathComponent: nameInContainer];
|
|
||||||
properties = [[NSMutableDictionary alloc]
|
properties = [[NSMutableDictionary alloc]
|
||||||
initWithContentsOfFile: filePath];
|
initWithContentsOfFile: [self completeFilename]];
|
||||||
if (!properties)
|
if (!properties)
|
||||||
properties = [NSMutableDictionary new];
|
properties = [NSMutableDictionary new];
|
||||||
}
|
}
|
||||||
|
@ -69,82 +79,63 @@
|
||||||
|
|
||||||
- (void) appendProperties: (NSDictionary *) newProperties
|
- (void) appendProperties: (NSDictionary *) newProperties
|
||||||
{
|
{
|
||||||
NSArray *keys;
|
|
||||||
NSString *key;
|
|
||||||
int i, count;
|
|
||||||
|
|
||||||
// We ensure the current properties are loaded
|
// We ensure the current properties are loaded
|
||||||
[self properties];
|
[self properties];
|
||||||
|
|
||||||
// We merge the changes
|
// We merge the changes
|
||||||
keys = [newProperties allKeys];
|
[properties addEntriesFromDictionary: newProperties];
|
||||||
count = [keys count];
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
key = [keys objectAtIndex: i];
|
|
||||||
[properties setObject: [newProperties objectForKey: key]
|
|
||||||
forKey: key];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) save
|
- (void) save
|
||||||
{
|
{
|
||||||
NSArray *pathComponents;
|
|
||||||
NSString *filePath;
|
|
||||||
|
|
||||||
[self logWithFormat: @"-save"];
|
|
||||||
|
|
||||||
[container ensureDirectory];
|
[container ensureDirectory];
|
||||||
|
|
||||||
filePath = [[container directory]
|
if (![properties writeToFile: [self completeFilename] atomically: YES])
|
||||||
stringByAppendingPathComponent: nameInContainer];
|
|
||||||
|
|
||||||
// FIXME
|
|
||||||
// We do NOT save the FAI data for the Inbox, as upon the
|
|
||||||
// next Outlook restart, when restoring those saved properties,
|
|
||||||
// Outlook will crash.
|
|
||||||
pathComponents = [filePath pathComponents];
|
|
||||||
if ([[pathComponents objectAtIndex: [pathComponents count]-2] isEqualToString: @"inbox"])
|
|
||||||
{
|
|
||||||
[self logWithFormat: @"-MAPISave - skipping FAI at path %@", filePath];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (![properties writeToFile: filePath atomically: YES])
|
|
||||||
[NSException raise: @"MAPIStoreIOException"
|
[NSException raise: @"MAPIStoreIOException"
|
||||||
format: @"could not save message"];
|
format: @"could not save message"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) davEntityTag
|
- (NSString *) davEntityTag
|
||||||
{
|
{
|
||||||
NSDictionary *attributes;
|
NSCalendarDate *lm;
|
||||||
NSFileManager *fm;
|
|
||||||
NSString *filePath;
|
|
||||||
|
|
||||||
fm = [NSFileManager defaultManager];
|
lm = [self lastModificationTime];
|
||||||
|
|
||||||
filePath = [[container directory]
|
return [NSString stringWithFormat: @"%d", (int) [lm timeIntervalSince1970]];
|
||||||
stringByAppendingPathComponent: nameInContainer];
|
|
||||||
attributes = [fm fileAttributesAtPath: filePath traverseLink: NO];
|
|
||||||
|
|
||||||
return [NSString stringWithFormat: @"%p", attributes];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSException *) delete
|
- (NSException *) delete
|
||||||
{
|
{
|
||||||
NSFileManager *fm;
|
NSFileManager *fm;
|
||||||
NSString *filePath;
|
|
||||||
|
|
||||||
fm = [NSFileManager defaultManager];
|
fm = [NSFileManager defaultManager];
|
||||||
|
|
||||||
filePath = [[container directory]
|
if (![fm removeFileAtPath: [self completeFilename] handler: NULL])
|
||||||
stringByAppendingPathComponent: nameInContainer];
|
|
||||||
|
|
||||||
if (![fm removeFileAtPath: filePath handler: NULL])
|
|
||||||
[NSException raise: @"MAPIStoreIOException"
|
[NSException raise: @"MAPIStoreIOException"
|
||||||
format: @"could not delete message"];
|
format: @"could not delete message"];
|
||||||
|
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) _fileAttributeForKey: (NSString *) key
|
||||||
|
{
|
||||||
|
NSDictionary *attributes;
|
||||||
|
|
||||||
|
attributes = [[NSFileManager defaultManager]
|
||||||
|
fileAttributesAtPath: [self completeFilename]
|
||||||
|
traverseLink: NO];
|
||||||
|
|
||||||
|
return [attributes objectForKey: key];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSCalendarDate *) creationTime
|
||||||
|
{
|
||||||
|
return [self _fileAttributeForKey: NSFileCreationDate];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSCalendarDate *) lastModificationTime
|
||||||
|
{
|
||||||
|
return [self _fileAttributeForKey: NSFileModificationDate];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue