Added missing functions getClient and IsSieveServerConnected and the changes that comes with it

This commit is contained in:
Alexandre Cloutier 2014-03-10 10:33:27 -04:00
parent f4d189ffc8
commit f5faa60814
2 changed files with 29 additions and 12 deletions

View file

@ -22,6 +22,7 @@
#define UIXPREFERENCES_H #define UIXPREFERENCES_H
#import <SOGoUI/UIxComponent.h> #import <SOGoUI/UIxComponent.h>
#import <NGImap4/NGSieveClient.h>
@class NSString; @class NSString;
@ -32,6 +33,7 @@
{ {
id item; id item;
SOGoUser *user; SOGoUser *user;
NGSieveClient *client;
// Calendar categories // Calendar categories
NSString *category; NSString *category;
@ -58,6 +60,8 @@
} }
- (NSString *) userLongDateFormat; - (NSString *) userLongDateFormat;
- (BOOL) isSieveServerAvailable;
- (id) getClient;
@end @end

View file

@ -114,6 +114,8 @@ static NSArray *reminderValues = nil;
if ((self = [super init])) if ((self = [super init]))
{ {
item = nil; item = nil;
client = [self getClient];
#warning user should be the owner rather than the activeUser #warning user should be the owner rather than the activeUser
ASSIGN (user, [context activeUser]); ASSIGN (user, [context activeUser]);
ASSIGN (today, [NSCalendarDate date]); ASSIGN (today, [NSCalendarDate date]);
@ -174,6 +176,7 @@ static NSArray *reminderValues = nil;
[contactsCategories release]; [contactsCategories release];
[forwardOptions release]; [forwardOptions release];
[daysOfWeek release]; [daysOfWeek release];
[client release];
[super dealloc]; [super dealloc];
} }
@ -840,26 +843,15 @@ static NSArray *reminderValues = nil;
- (NSString *) sieveCapabilities - (NSString *) sieveCapabilities
{ {
#warning sieve caps should be deduced from the server
static NSArray *capabilities = nil; static NSArray *capabilities = nil;
SOGoMailAccounts *folder;
SOGoMailAccount *account;
SOGoSieveManager *manager;
NGSieveClient *client;
if (!capabilities) if (!capabilities)
{ {
folder = [[self clientObject] mailAccountsFolder: @"Mail"
inContext: context];
account = [folder lookupName: @"0" inContext: context acquire: NO];
manager = [SOGoSieveManager sieveManagerForUser: [context activeUser]];
client = [manager clientForAccount: account];
if (client) if (client)
capabilities = [client capabilities]; capabilities = [client capabilities];
else else
capabilities = [NSArray array]; capabilities = [NSArray array];
[capabilities retain]; [capabilities retain];
} }
return [capabilities jsonRepresentation]; return [capabilities jsonRepresentation];
@ -1137,6 +1129,27 @@ static NSArray *reminderValues = nil;
} }
} }
- (id) getClient{
SOGoMailAccount *account;
SOGoMailAccounts *folder;
SOGoSieveManager *manager;
NGSieveClient *realClient;
folder = [[self clientObject] mailAccountsFolder: @"Mail" inContext: context];
account = [folder lookupName: @"0" inContext: context acquire: NO];
manager = [SOGoSieveManager sieveManagerForUser: [context activeUser]];
realClient = [manager clientForAccount: account];
return realClient;
}
- (BOOL) isSieveServerAvailable {
return (([client isConnected])
? true
: false);
}
- (id <WOActionResults>) defaultAction - (id <WOActionResults>) defaultAction
{ {
id <WOActionResults> results; id <WOActionResults> results;