(fix) many OCS (non-standard) fixes

pull/229/merge
Ludovic Marcotte 2018-09-21 13:06:15 -04:00
parent ba9960b97a
commit 3d9fe30373
4 changed files with 39 additions and 15 deletions

View File

@ -172,10 +172,9 @@ static BOOL debugLeaks;
bundle = [bm bundleWithName: @"MainUI" type: @"SOGo"];
length = [tableType length] - 3;
tableFile = [tableType substringToIndex: length];
descFile
= [bundle pathForResource: [NSString stringWithFormat: @"%@-%@",
tableFile, fileSuffix]
ofType: @"sql"];
descFile = [bundle pathForResource: [NSString stringWithFormat: @"%@-%@",
tableFile, fileSuffix]
ofType: @"sql"];
if (!descFile)
descFile = [bundle pathForResource: tableFile ofType: @"sql"];
@ -224,24 +223,22 @@ static BOOL debugLeaks;
withCm: (GCSChannelManager *) cm
tableURL: (NSString *) url
{
NSString *tableName, *sql, *driver;
EOAdaptorChannel *channel;
NSString *tableName, *sql;
GCSFolderType *type;
NSException *ex;
channel = [cm acquireOpenChannelForURL: [NSURL URLWithString: url]];
tableName = [NSString stringWithFormat: @"sogo_quick_%@", typeName];
driver = [url substringToIndex: [url rangeOfString: @":"].location];
sql = [NSString stringWithFormat: @"SELECT count(*) FROM %@",
tableName];
if ([channel evaluateExpressionX: sql])
{
type = [GCSFolderType folderTypeWithName: typeName];
type = [GCSFolderType folderTypeWithName: typeName driver: driver];
if (type)
{
// We re-acquire the channel in case it was abruptly closed between statements
if (![channel isOpen])
channel = [cm acquireOpenChannelForURL: [NSURL URLWithString: url]];
sql = [type sqlQuickCreateWithTableName: tableName];
if (!(ex = [channel evaluateExpressionX: sql]))
[self logWithFormat: @"sogo quick table '%@' successfully created!",

View File

@ -190,7 +190,7 @@ static BOOL _singleStoreMode = NO;
return fm;
}
- (NSDictionary *) loadDefaultFolderTypes
- (NSDictionary *) loadDefaultFolderTypes: (NSString *) driver
{
NSMutableDictionary *typeMap;
NSArray *types;
@ -212,7 +212,15 @@ static BOOL _singleStoreMode = NO;
GCSFolderType *typeObject;
type = [[types objectAtIndex:i] stringByDeletingPathExtension];
typeObject = [GCSFolderType folderTypeWithName: type];
// We skip type files associated to drivers directly, since
// [GCSFolderType folderTypeWithName:driver] will handle the
// mojo directly
if ([type rangeOfString: [NSString stringWithFormat: @"-%@", driver]].length)
continue;
typeObject = [GCSFolderType folderTypeWithName: type
driver: driver];
[self debugWithFormat:@" %@: %s",
type, [typeObject isNotNull] ? "OK" : "FAIL"];
@ -302,7 +310,7 @@ static BOOL _singleStoreMode = NO;
}
/* register default folder types */
nameToType = [[self loadDefaultFolderTypes] copy];
nameToType = [[self loadDefaultFolderTypes: [_infoUrl scheme]] copy];
}
return self;
}

View File

@ -52,6 +52,7 @@
}
+ (id)folderTypeWithName:(NSString *)_type;
+ (id)folderTypeWithName:(NSString *)_type driver:(NSString *)_driver;
- (id)initWithPropertyList:(id)_plist;
- (id)initWithContentsOfFile:(NSString *)_path;

View File

@ -38,14 +38,26 @@
@implementation GCSFolderType
+ (id) folderTypeWithName: (NSString *) _typeName
+ (id)folderTypeWithName:(NSString *)_typeName driver:(NSString *)_driver
{
NSString *filename, *path;
GCSFolderType *folderType;
filename = nil;
// TODO: fix me, GCS instead of OCS
filename = [_typeName stringByAppendingPathExtension:@"ocs"];
path = [[self resourceLocator] lookupFileWithName: filename];
if (_driver)
{
filename = [NSString stringWithFormat: @"%@-%@.ocs", _typeName, _driver];
if (!(path = [[self resourceLocator] lookupFileWithName: filename]))
filename = nil;
}
if (!filename)
{
filename = [_typeName stringByAppendingPathExtension:@"ocs"];
path = [[self resourceLocator] lookupFileWithName: filename];
}
if (path)
{
@ -62,6 +74,12 @@
return folderType;
}
+ (id) folderTypeWithName: (NSString *) _typeName
{
return [self folderTypeWithName: _typeName driver: nil];
}
- (id) initWithPropertyList: (id) _plist
{
NSDictionary *plist = _plist;