Merge pull request #29 from alexcloutier/feat/1496

New feature : 1496

Don't forget to fix the typo.
This commit is contained in:
extrafu committed 2014-04-07 19:42:31 -04:00
commit bf64076b87
19 files changed
+430 -127

No files matched your search

+6
View File
@@ -51,4 +51,10 @@ typedef enum
EventUpdated = 2,
} SOGoEventOperation;
typedef enum
{
SOGoPersonalFolder = 0,
SOGoCollectedFolder = 1,
} SOGoFolderType;
#endif /* _SOGOCONSTANTS_H_ */
+1
View File
@@ -54,6 +54,7 @@
SOGoIMAPServer = "localhost";
SOGoMailDomain = "localhost";
SOGoSelectedAddressBook = "collected";
SOGoMailMessageCheck = "manually";
SOGoMailMessageForwarding = "inline";
SOGoMailReplyPlacement = "below";
+2
View File
@@ -22,6 +22,7 @@
#define SOGOPARENTFOLDERS_H
#import "SOGoFolder.h"
#import "SOGoConstants.h"
@class NSMutableDictionary;
@class NSString;
@@ -39,6 +40,7 @@
+ (Class) subFolderClass;
- (NSString *) defaultFolderName;
- (NSString *) collectedFolderName;
- (NSException *) appendPersonalSources;
- (void) removeSubFolder: (NSString *) subfolderName;
+73 -47
View File
@@ -38,7 +38,7 @@
#import <DOM/DOMElement.h>
#import <DOM/DOMProtocols.h>
#import <SaxObjC/XMLNamespaces.h>
#import <SOGo/SOGoUserDefaults.h>
#import <SOGo/SOGoUserSettings.h>
#import "NSObject+DAV.h"
@@ -153,9 +153,15 @@ static SoSecurityManager *sm = nil;
return @"Personal";
}
- (void) _createPersonalFolder
- (NSString *) collectedFolderName
{
return @"Collected";
}
- (void) createSpecialFolder: (SOGoFolderType) folderType
{
NSArray *roles;
NSString *folderName;
SOGoGCSFolder *folder;
SOGoUser *folderOwner;
@@ -165,50 +171,70 @@ static SoSecurityManager *sm = nil;
// We autocreate the calendars if the user is the owner, a superuser or
// if it's a resource as we won't necessarily want to login as a resource
// in order to create its database tables.
// FolderType is an enum where 0 = Personal and 1 = collected
if ([roles containsObject: SoRole_Owner] ||
(folderOwner && [folderOwner isResource]))
{
folder = [subFolderClass objectWithName: @"personal" inContainer: self];
[folder setDisplayName: [self defaultFolderName]];
[folder
setOCSPath: [NSString stringWithFormat: @"%@/personal", OCSPath]];
if (folderType == SOGoPersonalFolder)
{
folderName = @"personal";
folder = [subFolderClass objectWithName: folderName inContainer: self];
[folder setDisplayName: [self defaultFolderName]];
}
else if (folderType == SOGoCollectedFolder)
{
folderName = @"collected";
folder = [subFolderClass objectWithName: folderName inContainer: self];
[folder setDisplayName: [self collectedFolderName]];
}
[folder setOCSPath: [NSString stringWithFormat: @"%@/%@", OCSPath, folderName]];
if ([folder create])
[subFolders setObject: folder forKey: @"personal"];
[subFolders setObject: folder forKey: folderName];
}
}
- (NSException *) _fetchPersonalFolders: (NSString *) sql
withChannel: (EOAdaptorChannel *) fc
- (NSException *) fetchSpecialFolders: (NSString *) sql
withChannel: (EOAdaptorChannel *) fc
andFolderType: (SOGoFolderType) folderType
{
NSArray *attrs;
NSDictionary *row;
SOGoGCSFolder *folder;
NSString *key;
NSException *error;
SOGoUserDefaults *ud;
ud = [[context activeUser] userDefaults];
if (!subFolderClass)
subFolderClass = [[self class] subFolderClass];
error = [fc evaluateExpressionX: sql];
if (!error)
{
attrs = [fc describeResults: NO];
while ((row = [fc fetchAttributes: attrs withZone: NULL]))
{
attrs = [fc describeResults: NO];
while ((row = [fc fetchAttributes: attrs withZone: NULL]))
{
key = [row objectForKey: @"c_path4"];
if ([key isKindOfClass: [NSString class]])
{
folder = [subFolderClass objectWithName: key inContainer: self];
[folder setOCSPath: [NSString stringWithFormat: @"%@/%@",
OCSPath, key]];
[subFolders setObject: folder forKey: key];
}
}
if (![subFolders objectForKey: @"personal"])
[self _createPersonalFolder];
key = [row objectForKey: @"c_path4"];
if ([key isKindOfClass: [NSString class]])
{
folder = [subFolderClass objectWithName: key inContainer: self];
[folder setOCSPath: [NSString stringWithFormat: @"%@/%@", OCSPath, key]];
[subFolders setObject: folder forKey: key];
}
}
if (folderType == SOGoPersonalFolder)
{
if (![subFolders objectForKey: @"personal"])
[self createSpecialFolder: SOGoPersonalFolder];
}
else if (folderType == SOGoCollectedFolder)
{
if (![subFolders objectForKey: @"collected"])
if ([[ud selectedAddressBook] isEqualToString:@"collected"])
[self createSpecialFolder: SOGoCollectedFolder];
}
}
return error;
}
@@ -221,25 +247,21 @@ static SoSecurityManager *sm = nil;
NSException *error;
cm = [GCSChannelManager defaultChannelManager];
folderLocation
= [[GCSFolderManager defaultFolderManager] folderInfoLocation];
folderLocation = [[GCSFolderManager defaultFolderManager] folderInfoLocation];
fc = [cm acquireOpenChannelForURL: folderLocation];
if ([fc isOpen])
{
gcsFolderType = [[self class] gcsFolderType];
sql
= [NSString stringWithFormat: (@"SELECT c_path4 FROM %@"
@" WHERE c_path2 = '%@'"
@" AND c_folder_type = '%@'"),
[folderLocation gcsTableName],
owner,
gcsFolderType];
error = [self _fetchPersonalFolders: sql withChannel: fc];
[cm releaseChannel: fc];
// sql = [sql stringByAppendingFormat:@" WHERE %@ = '%@'",
// uidColumnName, [self uid]];
}
{
gcsFolderType = [[self class] gcsFolderType];
sql = [NSString stringWithFormat: (@"SELECT c_path4 FROM %@"
@" WHERE c_path2 = '%@'"
@" AND c_folder_type = '%@'"),
[folderLocation gcsTableName], owner, gcsFolderType];
error = [self fetchSpecialFolders: sql withChannel: fc andFolderType: SOGoPersonalFolder];
[cm releaseChannel: fc];
}
else
error = [NSException exceptionWithName: @"SOGoDBException"
reason: @"database connection could not be open"
@@ -248,6 +270,7 @@ static SoSecurityManager *sm = nil;
return error;
}
- (NSException *) appendSystemSources
{
return nil;
@@ -388,12 +411,15 @@ static SoSecurityManager *sm = nil;
subFolders = [NSMutableDictionary new];
error = [self appendPersonalSources];
if (!error)
error = [self appendSystemSources];
if ([self respondsToSelector:@selector(appendCollectedSources)])
error = [self appendCollectedSources];
if (!error)
error = [self appendSystemSources]; // TODO : Not really a testcase, see function
if (error)
{
[subFolders release];
subFolders = nil;
}
{
[subFolders release];
subFolders = nil;
}
}
else
error = nil;
+6
View File
@@ -87,6 +87,9 @@ extern NSString *SOGoWeekStartFirstFullWeek;
- (NSString *) language;
/* mail */
- (void) setMailAddOutgoingAddresses: (BOOL) newValue;
- (BOOL) mailAddOutgoingAddresses;
- (void) setMailShowSubscribedFoldersOnly: (BOOL) newValue;
- (BOOL) mailShowSubscribedFoldersOnly;
@@ -111,6 +114,9 @@ extern NSString *SOGoWeekStartFirstFullWeek;
- (void) setMailListViewColumnsOrder: (NSArray *) newValue;
- (NSArray *) mailListViewColumnsOrder;
- (void) setSelectedAddressBook: (NSString *) newValue;
- (NSString *) selectedAddressBook;
- (void) setMailMessageCheck: (NSString *) newValue;
- (NSString *) mailMessageCheck;
+23 -2
View File
@@ -185,8 +185,8 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
{
migratedKeys
= [NSDictionary dictionaryWithObjectsAndKeys:
@"SOGoLoginModule", @"SOGoUIxDefaultModule",
@"SOGoLoginModule", @"SOGoDefaultModule",
@"SOGoLoginModule", @"SOGoUIxDefaultModule",
@"SOGoLoginModule", @"SOGoDefaultModule",
@"SOGoTimeFormat", @"TimeFormat",
@"SOGoShortDateFormat", @"ShortDateFormat",
@"SOGoLongDateFormat", @"LongDateFormat",
@@ -197,6 +197,7 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
@"SOGoLanguage", @"SOGoDefaultLanguage",
@"SOGoLanguage", @"Language",
@"SOGoMailComposeMessageType", @"ComposeMessagesType",
@"SOGoSelectedAddressBook", @"SelectedAddressBook",
@"SOGoMailMessageCheck", @"MessageCheck",
@"SOGoMailMessageForwarding", @"MessageForwarding",
@"SOGoMailSignature", @"MailSignature",
@@ -384,6 +385,16 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
return userLanguage;
}
- (void) setMailAddOutgoingAddresses: (BOOL) newValue
{
[self setBool: newValue forKey: @"SOGoMailAddOutgoingAddresses"];
}
- (BOOL) mailAddOutgoingAddresses
{
return [self boolForKey: @"SOGoMailAddOutgoingAddresses"];
}
- (void) setMailShowSubscribedFoldersOnly: (BOOL) newValue
{
[self setBool: newValue forKey: @"SOGoMailShowSubscribedFoldersOnly"];
@@ -467,6 +478,16 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
return [self stringArrayForKey: @"SOGoMailListViewColumnsOrder"];
}
- (void) setSelectedAddressBook:(NSString *) newValue
{
[self setObject: newValue forKey: @"SOGoSelectedAddressBook"];
}
- (NSString *) selectedAddressBook
{
return [self stringForKey: @"SOGoSelectedAddressBook"];
}
- (void) setMailMessageCheck: (NSString *) newValue
{
[self setObject: newValue forKey: @"SOGoMailMessageCheck"];