+2005-07-22 Helge Hess <helge.hess@opengroupware.org>
+
+ * v0.9.120
+
+ * SOGoMailBaseObject.m: added a method to locate the mail accounts
+ folderby traversing the container hierarchy
+
+ * SOGoMailIdentity.m: include sent folder in -description
+
+ * SOGoMailAccounts.m: added method to fetch just the identities with
+ emitter permissions
+
+ * SOGoUser+Mail.m: properly create mail identity objects
+
2005-07-21 Helge Hess <helge.hess@opengroupware.org>
* v0.9.119
ud = [NSUserDefaults standardUserDefaults];
s = [[ud stringForKey:@"SOGoSentFolderName"] copy];
if ([s length] == 0) s = @"Sent";
- NSLog(@"Note: using SOGoSentFolderName: '%@'", s);
+ [self logWithFormat:@"Note: using SOGoSentFolderName: '%@'", s];
}
return s;
}
}
- (NSArray *)fetchAllIdentities;
+- (NSArray *)fetchIdentitiesWithEmitterPermissions;
@end
: [account arrayByAddingObjectsFromArray:shares];
}
-- (NSArray *)fetchAllIdentities {
+- (NSArray *)fetchIdentitiesWithOnlyEmitterAccess:(BOOL)_flag {
WOContext *ctx;
if ((ctx = [[WOApplication application] context]) == nil) {
if ([self isInternetRequest]) { /* only show primary mailbox in Internet */
// just return the primary identity
- return [[ctx activeUser] primaryMailIdentity];
+ id identity;
+
+ identity = [[ctx activeUser] primaryMailIdentity];
+ return [identity isNotNull] ? [NSArray arrayWithObject:identity] : nil;
}
- return [[ctx activeUser] fetchAllMailIdentitiesWithOnlyEmitterAccess:NO];
+ return [[ctx activeUser] fetchAllMailIdentitiesWithOnlyEmitterAccess:_flag];
+}
+- (NSArray *)fetchAllIdentities {
+ return [self fetchIdentitiesWithOnlyEmitterAccess:NO];
+}
+- (NSArray *)fetchIdentitiesWithEmitterPermissions {
+ return [self fetchIdentitiesWithOnlyEmitterAccess:YES];
}
/* name lookup */
@class NSString, NSArray, NSURL;
@class NGImap4ConnectionManager, NGImap4Connection;
-@class SOGoMailAccount;
+@class SOGoMailAccount, SOGoMailAccounts;
@interface SOGoMailBaseObject : SOGoObject
{
/* hierarchy */
- (SOGoMailAccount *)mailAccountFolder;
+- (SOGoMailAccounts *)mailAccountsFolder;
/* IMAP4 */
return [[self container] mailAccountFolder];
}
+- (SOGoMailAccounts *)mailAccountsFolder {
+ id o;
+
+ for (o = [self container]; [o isNotNull]; o = [o container]) {
+ if ([o isKindOfClass:NSClassFromString(@"SOGoMailAccounts")])
+ return o;;
+ }
+ return nil;
+}
+
/* IMAP4 */
- (NGImap4ConnectionManager *)mailManager {
if (self->name != nil) [ms appendFormat:@" name='%@'", self->name];
if (self->email != nil) [ms appendFormat:@" email='%@'", self->email];
+ if (self->sentFolderName != nil)
+ [ms appendFormat:@" sent='%@'", self->sentFolderName];
+
if ([self->sentBCC length] > 0) [ms appendString:@" sent-bcc"];
if ([self->vCard length] > 0) [ms appendString:@" vcard"];
@implementation SOGoUser(Mail)
+- (NSString *)agenorSentFolderName {
+ /* Note: specialty: the Sent folder is called the same in all accounts */
+ static NSString *s = nil;
+ if (s == nil) {
+ NSUserDefaults *ud;
+
+ ud = [NSUserDefaults standardUserDefaults];
+ s = [[ud stringForKey:@"SOGoSentFolderName"] copy];
+ if (![s isNotEmpty]) s = @"Sent";
+ [self logWithFormat:@"Note: using SOGoSentFolderName: '%@'", s];
+ }
+ return s;
+}
+
+- (NSString *)agenorSentFolderForAccount:(NSString *)_account {
+ // TODO: support different locations for shares!
+ NSString *p;
+
+ if (![_account isNotEmpty])
+ return nil;
+
+ // if ([_account rangeOfString:@".-."].length == 0)
+ // TODO: check whether we need special handling for shares!
+ p = [_account stringByAppendingString:@"/"];
+ p = [p stringByAppendingString:[self agenorSentFolderName]];
+ return p;
+}
+
- (SOGoMailIdentity *)primaryMailIdentity {
+ SOGoMailIdentity *identity;
NSString *account;
-
+
account = [self valueForKey:@"primaryIMAP4AccountString"];
-#warning IMPLEMENT ME
- return nil;
+ identity = [[[SOGoMailIdentity alloc] init] autorelease];
+ [identity setName:[self cn]];
+ [identity setEmail:[self email]];
+ [identity setSentFolderName:[self agenorSentFolderForAccount:account]];
+ return identity;
}
- (SOGoMailIdentity *)mailIdentityForAccount:(NSString *)_account
emitter:(NSString *)_em
{
-#warning IMPLEMENT ME
- return nil;
+ SOGoMailIdentity *identity;
+
+ identity = [[[SOGoMailIdentity alloc] init] autorelease];
+ [identity setName:[self cn]]; // TODO: should we use something else?
+ if ([_em isNotEmpty]) [identity setName:_em];
+ [identity setSentFolderName:[self agenorSentFolderForAccount:_account]];
+ return identity;
}
- (NSArray *)fetchAllMailIdentitiesWithOnlyEmitterAccess:(BOOL)_onlyGC {
[identities addObject:identity];
}
- [self logWithFormat:@"TODO: WORK ON IDENTITIES: %@", shares];
- return nil;
+ return identities;
}
@end /* SOGoUser(Mail) */
# Version file
-SUBMINOR_VERSION:=119
+SUBMINOR_VERSION:=120
# v0.9.114 requires libNGMime v4.5.229
# v0.9.114 requires libNGExtensions v4.5.165