From: helge Date: Thu, 21 Jul 2005 14:49:08 +0000 (+0000) Subject: work on identities X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5faef9cec5e8dc27860e8398d79608f8e79d9680;p=scalable-opengroupware.org work on identities git-svn-id: http://svn.opengroupware.org/SOGo/trunk@877 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index efb7ac46..654c8260 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,5 +1,13 @@ 2005-07-21 Helge Hess + * v0.9.119 + + * SOGoMailAccounts.m: fetch identities from SoUser + + * added SOGoUser+Mail category for mail specific SoUser fields + + * SOGoMailIdentity.m: added ivars/accessors/description + * v0.9.118 * SOGoMailAccounts.m: reject access to the folder in case the name of diff --git a/SOGo/SoObjects/Mailer/GNUmakefile b/SOGo/SoObjects/Mailer/GNUmakefile index 74104625..39319f4f 100644 --- a/SOGo/SoObjects/Mailer/GNUmakefile +++ b/SOGo/SoObjects/Mailer/GNUmakefile @@ -31,6 +31,7 @@ Mailer_OBJC_FILES += \ SOGoDraftObject.m \ \ SOGoMailIdentity.m \ + SOGoUser+Mail.m \ Mailer_RESOURCE_FILES += \ Version \ diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccounts.m b/SOGo/SoObjects/Mailer/SOGoMailAccounts.m index 2f15df22..fa3eab5a 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccounts.m @@ -20,6 +20,7 @@ */ #include "SOGoMailAccounts.h" +#include "SOGoUser+Mail.h" #include "common.h" #include #include @@ -94,8 +95,20 @@ static NSString *AgenorShareLoginMarker = @".-."; } - (NSArray *)fetchAllIdentities { - [self logWithFormat:@"TODO: implement me: %s", __PRETTY_FUNCTION__]; - return nil; + WOContext *ctx; + + if ((ctx = [[WOApplication application] context]) == nil) { + [self logWithFormat:@"ERROR(%s): cannot procede without context!", + __PRETTY_FUNCTION__]; + return nil; + } + + if ([self isInternetRequest]) { /* only show primary mailbox in Internet */ + // just return the primary identity + return [[ctx activeUser] primaryMailIdentity]; + } + + return [[ctx activeUser] fetchAllMailIdentitiesWithOnlyEmitterAccess:NO]; } /* name lookup */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailIdentity.h b/SOGo/SoObjects/Mailer/SOGoMailIdentity.h index f9df7091..c340fdee 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailIdentity.h +++ b/SOGo/SoObjects/Mailer/SOGoMailIdentity.h @@ -52,10 +52,60 @@ select the quote) */ +@class NSString; + @interface SOGoMailIdentity : NSObject { + NSString *name; + NSString *email; + NSString *replyTo; + NSString *organization; + NSString *signature; + NSString *vCard; + NSString *sentFolderName; + NSString *sentBCC; + NSString *draftsFolderName; + NSString *templatesFolderName; + struct { + int composeHTML:1; + int reserved:31; + } idFlags; } +/* accessors */ + +- (void)setName:(NSString *)_value; +- (NSString *)name; + +- (void)setEmail:(NSString *)_value; +- (NSString *)email; + +- (void)setReplyTo:(NSString *)_value; +- (NSString *)replyTo; + +- (void)setOrganization:(NSString *)_value; +- (NSString *)organization; + +- (void)setSignature:(NSString *)_value; +- (NSString *)signature; +- (BOOL)hasSignature; + +- (void)setVCard:(NSString *)_value; +- (NSString *)vCard; +- (BOOL)hasVCard; + +- (void)setSentFolderName:(NSString *)_value; +- (NSString *)sentFolderName; + +- (void)setSentBCC:(NSString *)_value; +- (NSString *)sentBCC; + +- (void)setDraftsFolderName:(NSString *)_value; +- (NSString *)draftsFolderName; + +- (void)setTemplatesFolderName:(NSString *)_value; +- (NSString *)templatesFolderName; + @end #endif /* __Mailer_SOGoMailIdentity_H__ */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailIdentity.m b/SOGo/SoObjects/Mailer/SOGoMailIdentity.m index bc3b9f75..2debef06 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailIdentity.m +++ b/SOGo/SoObjects/Mailer/SOGoMailIdentity.m @@ -24,4 +24,114 @@ @implementation SOGoMailIdentity +- (void)dealloc { + [self->name release]; + [self->email release]; + [self->replyTo release]; + [self->organization release]; + [self->signature release]; + [self->vCard release]; + [self->sentFolderName release]; + [self->sentBCC release]; + [self->draftsFolderName release]; + [self->templatesFolderName release]; + [super dealloc]; +} + +/* accessors */ + +- (void)setName:(NSString *)_value { + ASSIGNCOPY(self->name, _value); +} +- (NSString *)name { + return self->name; +} + +- (void)setEmail:(NSString *)_value { + ASSIGNCOPY(self->email, _value); +} +- (NSString *)email { + return self->email; +} + +- (void)setReplyTo:(NSString *)_value { + ASSIGNCOPY(self->replyTo, _value); +} +- (NSString *)replyTo { + return self->replyTo; +} + +- (void)setOrganization:(NSString *)_value { + ASSIGNCOPY(self->organization, _value); +} +- (NSString *)organization { + return self->organization; +} + +- (void)setSignature:(NSString *)_value { + ASSIGNCOPY(self->signature, _value); +} +- (NSString *)signature { + return self->signature; +} +- (BOOL)hasSignature { + return [[self signature] isNotEmpty]; +} + +- (void)setVCard:(NSString *)_value { + ASSIGNCOPY(self->vCard, _value); +} +- (NSString *)vCard { + return self->vCard; +} +- (BOOL)hasVCard { + return [[self vCard] isNotEmpty]; +} + +- (void)setSentFolderName:(NSString *)_value { + ASSIGNCOPY(self->sentFolderName, _value); +} +- (NSString *)sentFolderName { + return self->sentFolderName; +} + +- (void)setSentBCC:(NSString *)_value { + ASSIGNCOPY(self->sentBCC, _value); +} +- (NSString *)sentBCC { + return self->sentBCC; +} + +- (void)setDraftsFolderName:(NSString *)_value { + ASSIGNCOPY(self->draftsFolderName, _value); +} +- (NSString *)draftsFolderName { + return self->draftsFolderName; +} + +- (void)setTemplatesFolderName:(NSString *)_value { + ASSIGNCOPY(self->templatesFolderName, _value); +} +- (NSString *)templatesFolderName { + return self->templatesFolderName; +} + +/* description */ + +- (NSString *)description { + NSMutableString *ms; + + ms = [NSMutableString stringWithCapacity:128]; + [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])]; + + if (self->name != nil) [ms appendFormat:@" name='%@'", self->name]; + if (self->email != nil) [ms appendFormat:@" email='%@'", self->email]; + + if ([self->sentBCC length] > 0) [ms appendString:@" sent-bcc"]; + if ([self->vCard length] > 0) [ms appendString:@" vcard"]; + + [ms appendString:@">"]; + return ms; +} + @end /* SOGoMailIdentity */ diff --git a/SOGo/SoObjects/Mailer/SOGoUser+Mail.h b/SOGo/SoObjects/Mailer/SOGoUser+Mail.h new file mode 100644 index 00000000..2442f336 --- /dev/null +++ b/SOGo/SoObjects/Mailer/SOGoUser+Mail.h @@ -0,0 +1,47 @@ +/* + Copyright (C) 2005 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#ifndef __Mailer_SOGoUser_Mail_H__ +#define __Mailer_SOGoUser_Mail_H__ + +#include + +/* + SOGoUser(Mail) + + TODO: document + + This category adds mail related stuff to the SOGo user class. +*/ + +#include + +@class NSArray; +@class SOGoMailIdentity; + +@interface SOGoUser(Mail) + +- (SOGoMailIdentity *)primaryMailIdentity; +- (NSArray *)fetchAllMailIdentitiesWithOnlyEmitterAccess:(BOOL)_onlyGC; + +@end + +#endif /* __Mailer_SOGoUser_Mail_H__ */ diff --git a/SOGo/SoObjects/Mailer/SOGoUser+Mail.m b/SOGo/SoObjects/Mailer/SOGoUser+Mail.m new file mode 100644 index 00000000..0b5d5e2f --- /dev/null +++ b/SOGo/SoObjects/Mailer/SOGoUser+Mail.m @@ -0,0 +1,75 @@ +/* + Copyright (C) 2004-2005 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#include "SOGoUser+Mail.h" +#include "SOGoMailIdentity.h" +#include "common.h" + +@implementation SOGoUser(Mail) + +- (SOGoMailIdentity *)primaryMailIdentity { + NSString *account; + + account = [self valueForKey:@"primaryIMAP4AccountString"]; + +#warning IMPLEMENT ME + return nil; +} + +- (SOGoMailIdentity *)mailIdentityForAccount:(NSString *)_account + emitter:(NSString *)_em +{ +#warning IMPLEMENT ME + return nil; +} + +- (NSArray *)fetchAllMailIdentitiesWithOnlyEmitterAccess:(BOOL)_onlyGC { + NSMutableArray *identities; + NSEnumerator *accounts; + NSDictionary *shares; + NSString *account; + id identity; + + identity = [self primaryMailIdentity]; + shares = [self valueForKey:@"additionalIMAP4AccountsAndEMails"]; + if ([shares count] == 0) + return identity; + + identities = [NSMutableArray arrayWithCapacity:[shares count] + 1]; + if (identity != nil) [identities addObject:identity]; + + accounts = [shares keyEnumerator]; + while ((account = [accounts nextObject]) != nil) { + NSString *emitter; + + emitter = [shares objectForKey:account]; + if (_onlyGC && ![emitter isNotNull]) continue; + + identity = [self mailIdentityForAccount:account emitter:emitter]; + if (identity != nil) + [identities addObject:identity]; + } + + [self logWithFormat:@"TODO: WORK ON IDENTITIES: %@", shares]; + return nil; +} + +@end /* SOGoUser(Mail) */ diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index b22e520a..8a6b1aad 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=118 +SUBMINOR_VERSION:=119 # v0.9.114 requires libNGMime v4.5.229 # v0.9.114 requires libNGExtensions v4.5.165