Restore multitenancy changes for OpenChange

pull/69/head
Carlos Pérez-Aradros Herce 2015-01-19 19:04:06 +01:00
parent f9550b9181
commit 00cef845b7
5 changed files with 35 additions and 10 deletions

View File

@ -55,7 +55,10 @@
NSString *baseURL, *url, *name; NSString *baseURL, *url, *name;
MAPIStoreUserContext *userContext; MAPIStoreUserContext *userContext;
baseURL = [NSString stringWithFormat: @"sogo://%@@fallback/", userName]; baseURL = [NSString stringWithFormat: @"sogo://%@@fallback/",
[userName stringByReplacingOccurrencesOfString: @"@"
withString: @"%40"]];
context = talloc_zero (memCtx, struct mapistore_contexts_list); context = talloc_zero (memCtx, struct mapistore_contexts_list);
context->url = [baseURL asUnicodeInMemCtx: context]; context->url = [baseURL asUnicodeInMemCtx: context];
@ -99,7 +102,10 @@
forUser: (NSString *) userName forUser: (NSString *) userName
{ {
return [NSString stringWithFormat: @"sogo://%@@fallback/0x%.16"PRIx64"/", return [NSString stringWithFormat: @"sogo://%@@fallback/0x%.16"PRIx64"/",
userName, (unsigned long long) fid]; [userName stringByReplacingOccurrencesOfString: @"@"
withString: @"%40"],
(unsigned long long) fid];
} }
@end @end

View File

@ -82,7 +82,9 @@
andTDBIndexing: indexing]; andTDBIndexing: indexing];
parentFolder = [[userContext rootFolders] objectForKey: moduleName]; parentFolder = [[userContext rootFolders] objectForKey: moduleName];
baseUrl = [NSString stringWithFormat: @"sogo://%@@%@/", baseUrl = [NSString stringWithFormat: @"sogo://%@@%@/",
userName, moduleName]; [userName stringByReplacingOccurrencesOfString: @"@"
withString: @"%40"],
moduleName];
subfolders = [parentFolder subFolders]; subfolders = [parentFolder subFolders];
max = [subfolders count]; max = [subfolders count];
@ -127,7 +129,9 @@
if (![parentFolder newFolderWithName: folderName if (![parentFolder newFolderWithName: folderName
nameInContainer: &nameInContainer]) nameInContainer: &nameInContainer])
mapistoreURI = [NSString stringWithFormat: @"sogo://%@@%@/%@/", mapistoreURI = [NSString stringWithFormat: @"sogo://%@@%@/%@/",
userName, moduleName, nameInContainer]; [userName stringByReplacingOccurrencesOfString: @"@"
withString: @"%40"],
moduleName, nameInContainer];
else else
mapistoreURI = nil; mapistoreURI = nil;
[MAPIApp setUserContext: nil]; [MAPIApp setUserContext: nil];

View File

@ -126,7 +126,11 @@ MakeDisplayFolderName (NSString *folderName)
trashName = [NSString stringWithFormat: @"folder%@", trashName = [NSString stringWithFormat: @"folder%@",
[unprefixedFolders componentsJoinedByString: @"/folder"]]; [unprefixedFolders componentsJoinedByString: @"/folder"]];
urlBase = [NSString stringWithFormat: @"sogo://%@:%@@mail/", userName, userName]; urlBase = [NSString stringWithFormat: @"sogo://%@:%@@mail/",
[userName stringByReplacingOccurrencesOfString: @"@"
withString: @"%40"],
[userName stringByReplacingOccurrencesOfString: @"@"
withString: @"%40"]];
for (count = 0; count < 3; count++) for (count = 0; count < 3; count++)
{ {
context = talloc_zero (memCtx, struct mapistore_contexts_list); context = talloc_zero (memCtx, struct mapistore_contexts_list);
@ -199,7 +203,10 @@ MakeDisplayFolderName (NSString *folderName)
inContainer: accountFolder]; inContainer: accountFolder];
if ([newFolder create]) if ([newFolder create])
mapistoreURI = [NSString stringWithFormat: @"sogo://%@:%@@mail/%@/", mapistoreURI = [NSString stringWithFormat: @"sogo://%@:%@@mail/%@/",
userName, userName, [userName stringByReplacingOccurrencesOfString: @"@"
withString: @"%40"],
[userName stringByReplacingOccurrencesOfString: @"@"
withString: @"%40"],
[[folderName stringByEncodingImap4FolderName] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]]; [[folderName stringByEncodingImap4FolderName] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]];
else else
mapistoreURI = nil; mapistoreURI = nil;
@ -275,8 +282,12 @@ MakeDisplayFolderName (NSString *folderName)
componentsSeparatedByString: @"/"]; componentsSeparatedByString: @"/"];
folderName = [NSString stringWithFormat: @"folder%@", folderName = [NSString stringWithFormat: @"folder%@",
[unprefixedFolders componentsJoinedByString: @"/folder"]]; [unprefixedFolders componentsJoinedByString: @"/folder"]];
url = [NSString stringWithFormat: @"sogo://%@:%@@outbox/%@", userName, url = [NSString stringWithFormat: @"sogo://%@:%@@outbox/%@",
userName, folderName]; [userName stringByReplacingOccurrencesOfString: @"@"
withString: @"%40"],
[userName stringByReplacingOccurrencesOfString: @"@"
withString: @"%40"],
folderName];
context = talloc_zero (memCtx, struct mapistore_contexts_list); context = talloc_zero (memCtx, struct mapistore_contexts_list);
context->url = [url asUnicodeInMemCtx: context]; context->url = [url asUnicodeInMemCtx: context];

View File

@ -45,7 +45,8 @@
context = talloc_zero(memCtx, struct mapistore_contexts_list); context = talloc_zero(memCtx, struct mapistore_contexts_list);
context->url = talloc_asprintf (context, "sogo://%s@notes/", context->url = talloc_asprintf (context, "sogo://%s@notes/",
[userName UTF8String]); [[userName stringByReplacingOccurrencesOfString: @"@"
withString: @"%40"] UTF8String]);
// context->name = "Notes personnelles"; // context->name = "Notes personnelles";
context->main_folder = true; context->main_folder = true;
context->role = MAPISTORE_NOTES_ROLE; context->role = MAPISTORE_NOTES_ROLE;

View File

@ -1693,7 +1693,10 @@ sogo_manager_generate_uri (TALLOC_CTX *mem_ctx,
username = [NSString stringWithUTF8String: (user ? user : "*")]; username = [NSString stringWithUTF8String: (user ? user : "*")];
/* Do proper directory lookup here */ /* Do proper directory lookup here */
directory = [NSString stringWithUTF8String: (folder ? folder : "*")]; directory = [NSString stringWithUTF8String: (folder ? folder : "*")];
partialURLString = [NSString stringWithFormat: @"sogo://%@:*@%@", username, directory]; partialURLString = [NSString stringWithFormat: @"sogo://%@:*@%@",
[username stringByReplacingOccurrencesOfString: @"@"
withString: @"%40"],
directory];
} }
if (![partialURLString hasSuffix: @"/"]) if (![partialURLString hasSuffix: @"/"])
partialURLString = [partialURLString stringByAppendingString: @"/"]; partialURLString = [partialURLString stringByAppendingString: @"/"];