From: helge Date: Tue, 19 Jul 2005 08:54:48 +0000 (+0000) Subject: improved stability with failed IMAP4 logins X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58d0588e41ae0646900518fa4170bf823640137a;p=scalable-opengroupware.org improved stability with failed IMAP4 logins git-svn-id: http://svn.opengroupware.org/SOGo/trunk@816 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index bec74cc5..3684ff08 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,3 +1,12 @@ +2005-07-19 Helge Hess + + * v0.9.109 + + * added fragile base class version checks to most classes + + * SOGoMailBaseObject.m: cache failed login attempts (+ connection) to + improve failed-login behaviour + 2005-07-18 Helge Hess * SOGoDraftObject.m: send text/* attachments with disposition 'attach' diff --git a/SOGo/SoObjects/Mailer/README b/SOGo/SoObjects/Mailer/README index 440c0632..2be7a9bb 100644 --- a/SOGo/SoObjects/Mailer/README +++ b/SOGo/SoObjects/Mailer/README @@ -24,11 +24,8 @@ Class Hierarchy SOGoMailFolder SOGoSharedInboxFolder SOGoMailObject - SOGoMailConnectionEntry [EODataSource] SOGoMailFolderDataSource - SOGoMailManager - SOGoMailboxInfo Defaults ======== diff --git a/SOGo/SoObjects/Mailer/SOGoCalendarMailBodyPart.m b/SOGo/SoObjects/Mailer/SOGoCalendarMailBodyPart.m index 50d0a28e..b001b8b7 100644 --- a/SOGo/SoObjects/Mailer/SOGoCalendarMailBodyPart.m +++ b/SOGo/SoObjects/Mailer/SOGoCalendarMailBodyPart.m @@ -39,4 +39,15 @@ #include "common.h" @implementation SOGoCalendarMailBodyPart + ++ (int)version { + return [super version] + 0 /* v1 */; +} + ++ (void)initialize { + NSAssert2([super version] == 1, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); +} + @end /* SOGoCalendarMailBodyPart */ diff --git a/SOGo/SoObjects/Mailer/SOGoDraftObject.m b/SOGo/SoObjects/Mailer/SOGoDraftObject.m index 02fe48d1..60d417ba 100644 --- a/SOGo/SoObjects/Mailer/SOGoDraftObject.m +++ b/SOGo/SoObjects/Mailer/SOGoDraftObject.m @@ -41,8 +41,16 @@ static BOOL draftDeleteDisabled = NO; // for debugging static BOOL debugOn = NO; static BOOL showTextAttachmentsInline = NO; ++ (int)version { + return [super version] + 0 /* v1 */; +} + + (void)initialize { NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + + NSAssert2([super version] == 1, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); /* Note: be aware of the charset issues before enabling this! */ showTextAttachmentsInline = [ud boolForKey:@"SOGoShowTextAttachmentsInline"]; diff --git a/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m b/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m index 0f10cd21..00195374 100644 --- a/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m +++ b/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m @@ -30,8 +30,16 @@ static NSString *spoolFolder = nil; ++ (int)version { + return [super version] + 0 /* v1 */; +} + + (void)initialize { NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + + NSAssert2([super version] == 1, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); spoolFolder = [[ud stringForKey:@"SOGoMailSpoolPath"] copy]; if ([spoolFolder length] < 3) diff --git a/SOGo/SoObjects/Mailer/SOGoImageMailBodyPart.m b/SOGo/SoObjects/Mailer/SOGoImageMailBodyPart.m index 3a4f1a51..b2b94ff2 100644 --- a/SOGo/SoObjects/Mailer/SOGoImageMailBodyPart.m +++ b/SOGo/SoObjects/Mailer/SOGoImageMailBodyPart.m @@ -39,4 +39,15 @@ #include "common.h" @implementation SOGoImageMailBodyPart + ++ (int)version { + return [super version] + 0 /* v1 */; +} + ++ (void)initialize { + NSAssert2([super version] == 1, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); +} + @end /* SOGoImageMailBodyPart */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccount.m b/SOGo/SoObjects/Mailer/SOGoMailAccount.m index a20b518c..b6479a92 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccount.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccount.m @@ -36,8 +36,16 @@ static NSString *sharedFolderName = @""; // TODO: add English default static NSString *otherUsersFolderName = @""; // TODO: add English default static BOOL useAltNamespace = NO; ++ (int)version { + return [super version] + 0 /* v1 */; +} + + (void)initialize { NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + + NSAssert2([super version] == 1, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); useAltNamespace = [ud boolForKey:@"SOGoSpecialFoldersInRoot"]; diff --git a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.h b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.h index 924052f0..cc0de820 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.h +++ b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.h @@ -44,7 +44,8 @@ @interface SOGoMailBaseObject : SOGoObject { - NSURL *imap4URL; + NSURL *imap4URL; + NGImap4Connection *imap4; } - (id)initWithImap4URL:(NSURL *)_url inContainer:(id)_container; diff --git a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m index 836f534c..ecd1a45f 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailBaseObject.m @@ -28,6 +28,15 @@ @implementation SOGoMailBaseObject ++ (int)version { + return [super version] + 1 /* v1 */; +} ++ (void)initialize { + NSAssert2([super version] == 0, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); +} + #if 0 static BOOL debugOn = YES; #endif @@ -65,8 +74,15 @@ static BOOL debugOn = YES; return [NGImap4ConnectionManager defaultConnectionManager]; } - (NGImap4Connection *)imap4Connection { - return [[self mailManager] connectionForURL:[self imap4URL] - password:[self imap4Password]]; + if (self->imap4 == nil) { + self->imap4 = [[[self mailManager] connectionForURL:[self imap4URL] + password:[self imap4Password]] retain]; + if (self->imap4 == nil) { + [self errorWithFormat:@"Could not connect IMAP4."]; + self->imap4 = [[NSNull null] retain]; + } + } + return [self->imap4 isNotNull] ? self->imap4 : nil; } - (NSString *)relativeImap4Name { diff --git a/SOGo/SoObjects/Mailer/SOGoMailBodyPart.m b/SOGo/SoObjects/Mailer/SOGoMailBodyPart.m index b9884fb5..f13feabd 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailBodyPart.m +++ b/SOGo/SoObjects/Mailer/SOGoMailBodyPart.m @@ -28,6 +28,16 @@ static BOOL debugOn = NO; ++ (int)version { + return [super version] + 0 /* v1 */; +} + ++ (void)initialize { + NSAssert2([super version] == 1, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); +} + - (void)dealloc { [self->partInfo release]; [self->identifier release]; diff --git a/SOGo/SoObjects/Mailer/SOGoMailFolder.m b/SOGo/SoObjects/Mailer/SOGoMailFolder.m index c8009fef..60b300ae 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailFolder.m +++ b/SOGo/SoObjects/Mailer/SOGoMailFolder.m @@ -29,6 +29,16 @@ @implementation SOGoMailFolder ++ (int)version { + return [super version] + 0 /* v1 */; +} + ++ (void)initialize { + NSAssert2([super version] == 1, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); +} + - (void)dealloc { [self->selectInfo release]; [self->filenames release]; diff --git a/SOGo/SoObjects/Mailer/SOGoMailObject.m b/SOGo/SoObjects/Mailer/SOGoMailObject.m index 6cbfc51a..713a1e9f 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailObject.m @@ -36,7 +36,15 @@ static BOOL debugOn = NO; static BOOL debugBodyStructure = NO; static BOOL debugSoParts = NO; ++ (int)version { + return [super version] + 0 /* v1 */; +} + + (void)initialize { + NSAssert2([super version] == 1, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); + /* Note: see SOGoMailManager.m for allowed IMAP4 keys */ /* Note: "BODY" actually returns the structure! */ coreInfoKeys = [[NSArray alloc] initWithObjects: diff --git a/SOGo/SoObjects/Mailer/SOGoMessageMailBodyPart.m b/SOGo/SoObjects/Mailer/SOGoMessageMailBodyPart.m index cfc5ad29..32e2da9a 100644 --- a/SOGo/SoObjects/Mailer/SOGoMessageMailBodyPart.m +++ b/SOGo/SoObjects/Mailer/SOGoMessageMailBodyPart.m @@ -41,4 +41,15 @@ #include "common.h" @implementation SOGoMessageMailBodyPart + ++ (int)version { + return [super version] + 0 /* v1 */; +} + ++ (void)initialize { + NSAssert2([super version] == 1, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); +} + @end /* SOGoMessageMailBodyPart */ diff --git a/SOGo/SoObjects/Mailer/SOGoSharedInboxFolder.m b/SOGo/SoObjects/Mailer/SOGoSharedInboxFolder.m index d5e444bf..85a98f47 100644 --- a/SOGo/SoObjects/Mailer/SOGoSharedInboxFolder.m +++ b/SOGo/SoObjects/Mailer/SOGoSharedInboxFolder.m @@ -24,6 +24,16 @@ @implementation SOGoSharedInboxFolder ++ (int)version { + return [super version] + 0 /* v1 */; +} + ++ (void)initialize { + NSAssert2([super version] == 1, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); +} + /* listing available folders */ - (NSArray *)toManyRelationshipKeys { diff --git a/SOGo/SoObjects/Mailer/SOGoSharedMailAccount.m b/SOGo/SoObjects/Mailer/SOGoSharedMailAccount.m index 9aa194c5..08969d73 100644 --- a/SOGo/SoObjects/Mailer/SOGoSharedMailAccount.m +++ b/SOGo/SoObjects/Mailer/SOGoSharedMailAccount.m @@ -35,8 +35,16 @@ static NSString *otherUsersFolderName = @""; // TODO: add English default ++ (int)version { + return [super version] + 0 /* v1 */; +} + + (void)initialize { NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + + NSAssert2([super version] == 1, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); otherUsersFolderName = [ud stringForKey:@"SOGoOtherUsersFolderName"]; NSLog(@"Note: using other-users-folders name: '%@'", otherUsersFolderName); diff --git a/SOGo/SoObjects/Mailer/SOGoVCardMailBodyPart.m b/SOGo/SoObjects/Mailer/SOGoVCardMailBodyPart.m index 8dabfc86..13ce2231 100644 --- a/SOGo/SoObjects/Mailer/SOGoVCardMailBodyPart.m +++ b/SOGo/SoObjects/Mailer/SOGoVCardMailBodyPart.m @@ -39,4 +39,15 @@ #include "common.h" @implementation SOGoVCardMailBodyPart + ++ (int)version { + return [super version] + 0 /* v1 */; +} + ++ (void)initialize { + NSAssert2([super version] == 1, + @"invalid superclass (%@) version %i !", + NSStringFromClass([self superclass]), [super version]); +} + @end /* SOGoVCardMailBodyPart */ diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 0c2f875c..5443d466 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=108 +SUBMINOR_VERSION:=109 # v0.9.96 requires libNGMime v4.5.223 # v0.9.91 requires libNGMime v4.5.222