mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-17 01:15:24 +00:00
reindentation
Monotone-Parent: 215f30784ae8904703b5fa172c7a563bf8f3b464 Monotone-Revision: 2f37714ba202d0c2f6bc3c888440ea82ee601d66 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-10-01T20:35:29 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* MAPIStoreMapping.m - this file is part of $PROJECT_NAME_HERE$
|
||||
/* MAPIStoreMapping.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2010 Inverse inc.
|
||||
*
|
||||
@@ -35,102 +35,111 @@ static uint64_t idCounter = 0x200001;
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
mapping = [NSMutableDictionary new];
|
||||
reverseMapping = [NSMutableDictionary new];
|
||||
}
|
||||
|
||||
return self;
|
||||
if ((self = [super init]))
|
||||
{
|
||||
mapping = [NSMutableDictionary new];
|
||||
reverseMapping = [NSMutableDictionary new];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[mapping release];
|
||||
[reverseMapping release];
|
||||
[super dealloc];
|
||||
[mapping release];
|
||||
[reverseMapping release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString *) urlFromID: (uint64_t) idNbr
|
||||
{
|
||||
NSNumber *key;
|
||||
|
||||
key = [NSNumber numberWithUnsignedLongLong: idNbr];
|
||||
|
||||
return [mapping objectForKey: key];
|
||||
NSNumber *key;
|
||||
|
||||
key = [NSNumber numberWithUnsignedLongLong: idNbr];
|
||||
|
||||
return [mapping objectForKey: key];
|
||||
}
|
||||
|
||||
- (uint64_t) idFromURL: (NSString *) url
|
||||
{
|
||||
NSNumber *idKey;
|
||||
uint64_t idNbr;
|
||||
|
||||
idKey = [reverseMapping objectForKey: url];
|
||||
if (idKey)
|
||||
idNbr = [idKey unsignedLongLongValue];
|
||||
else
|
||||
idNbr = NSNotFound;
|
||||
|
||||
return idNbr;
|
||||
NSNumber *idKey;
|
||||
uint64_t idNbr;
|
||||
|
||||
idKey = [reverseMapping objectForKey: url];
|
||||
if (idKey)
|
||||
idNbr = [idKey unsignedLongLongValue];
|
||||
else
|
||||
idNbr = NSNotFound;
|
||||
|
||||
return idNbr;
|
||||
}
|
||||
|
||||
- (BOOL) registerURL: (NSString *) urlString
|
||||
withID: (uint64_t) idNbr
|
||||
{
|
||||
NSNumber *idKey;
|
||||
BOOL rc;
|
||||
NSNumber *idKey;
|
||||
BOOL rc;
|
||||
|
||||
idKey = [NSNumber numberWithUnsignedLongLong: idNbr];
|
||||
if ([mapping objectForKey: idKey] || [reverseMapping objectForKey: urlString]) {
|
||||
[self errorWithFormat: @"attempt to double register an entry ('%@', %lld)",
|
||||
urlString, idNbr];
|
||||
rc = NO;
|
||||
}
|
||||
else {
|
||||
[mapping setObject: urlString forKey: idKey];
|
||||
[reverseMapping setObject: idKey forKey: urlString];
|
||||
rc = YES;
|
||||
[self logWithFormat: @"registered url '%@' with id %lld (0x%.8x)",
|
||||
urlString, idNbr, (uint32_t) idNbr];
|
||||
}
|
||||
idKey = [NSNumber numberWithUnsignedLongLong: idNbr];
|
||||
if ([mapping objectForKey: idKey]
|
||||
|| [reverseMapping objectForKey: urlString])
|
||||
{
|
||||
[self errorWithFormat: @"attempt to double register an entry ('%@', %lld)",
|
||||
urlString, idNbr];
|
||||
rc = NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
[mapping setObject: urlString forKey: idKey];
|
||||
[reverseMapping setObject: idKey forKey: urlString];
|
||||
rc = YES;
|
||||
[self logWithFormat: @"registered url '%@' with id %lld (0x%.8x)",
|
||||
urlString, idNbr, (uint32_t) idNbr];
|
||||
}
|
||||
|
||||
return rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
- (void) registerURL: (NSString *) urlString
|
||||
{
|
||||
uint64_t idNbr;
|
||||
|
||||
// newID = openchangedb_get_new_folderID();
|
||||
if (![reverseMapping objectForKey: urlString]) {
|
||||
if ([urlString isEqualToString: @"sogo://openchange:openchange@mail/folderINBOX"]) {
|
||||
idNbr = 0x160001;
|
||||
if (![self registerURL: urlString withID: idNbr])
|
||||
[self errorWithFormat: @"Unable to register root folder: %@",
|
||||
urlString];
|
||||
}
|
||||
// else if ([urlString isEqualToString: @"sogo://openchange:openchange@mail/folderSent"]) {
|
||||
// idNbr = 0x140001;
|
||||
// idCounter = idNbr;
|
||||
// }
|
||||
else if ([urlString isEqualToString: @"sogo://openchange:openchange@contacts/personal"]) {
|
||||
idNbr = 0x1a0001;
|
||||
if (![self registerURL: urlString withID: idNbr])
|
||||
[self errorWithFormat: @"Unable to register root folder: %@",
|
||||
urlString];
|
||||
}
|
||||
else if ([urlString isEqualToString: @"sogo://openchange:openchange@calendar/personal"]) {
|
||||
idNbr = 0x190001;
|
||||
if (![self registerURL: urlString withID: idNbr])
|
||||
[self errorWithFormat: @"Unable to register root folder: %@",
|
||||
urlString];
|
||||
}
|
||||
else {
|
||||
idCounter += idIncrement;
|
||||
while (![self registerURL: urlString withID: idCounter])
|
||||
idCounter += idIncrement;
|
||||
}
|
||||
// [self _registerURL: urlString withID: newID];
|
||||
uint64_t idNbr;
|
||||
|
||||
// newID = openchangedb_get_new_folderID();
|
||||
if (![reverseMapping objectForKey: urlString])
|
||||
{
|
||||
if ([urlString isEqualToString: @"sogo://openchange:openchange@mail/folderINBOX"])
|
||||
{
|
||||
idNbr = 0x160001;
|
||||
if (![self registerURL: urlString withID: idNbr])
|
||||
[self errorWithFormat: @"Unable to register root folder: %@",
|
||||
urlString];
|
||||
}
|
||||
// else if ([urlString isEqualToString: @"sogo://openchange:openchange@mail/folderSent"]) {
|
||||
// idNbr = 0x140001;
|
||||
// idCounter = idNbr;
|
||||
// }
|
||||
else if ([urlString isEqualToString: @"sogo://openchange:openchange@contacts/personal"])
|
||||
{
|
||||
idNbr = 0x1a0001;
|
||||
if (![self registerURL: urlString withID: idNbr])
|
||||
[self errorWithFormat: @"Unable to register root folder: %@",
|
||||
urlString];
|
||||
}
|
||||
else if ([urlString isEqualToString: @"sogo://openchange:openchange@calendar/personal"])
|
||||
{
|
||||
idNbr = 0x190001;
|
||||
if (![self registerURL: urlString withID: idNbr])
|
||||
[self errorWithFormat: @"Unable to register root folder: %@",
|
||||
urlString];
|
||||
}
|
||||
else
|
||||
{
|
||||
idCounter += idIncrement;
|
||||
while (![self registerURL: urlString withID: idCounter])
|
||||
idCounter += idIncrement;
|
||||
}
|
||||
// [self _registerURL: urlString withID: newID];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user