From: wolfgang Date: Wed, 1 Aug 2007 18:59:27 +0000 (+0000) Subject: git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1131 d1b88da0-ebda-0310... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b96fe190b28e01976dc9973bc2b02cfddc7cf8f8;p=scalable-opengroupware.org git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1131 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/ChangeLog b/ChangeLog index 08cf853e..bad50c6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,58 @@ +2007-08-01 Wolfgang Sourdeau + + * UI/MailPartViewers/UIxMailPartViewer.m ([UIxMailPartViewer + -content]): new method returning the decoded content of the + corresponding attachment as an NSData instance. + ([UIxMailPartViewer -filename]): if the "filename" parameter of + the metadata parameterList is empty, try to find out the filename + from the "disposition" metadata returned with the BODYSTRUCTURE + imap4 tag. + + * UI/MailerUI/UIxMailMainFrame.m ([UIxMailMainFrame + -composeAction]): prefix the INBOX folder with "folder". + + * SoObjects/Mailer/SOGoMailFolder.m ([SOGoMailBaseObject + -relativeImap4Name]): return nameInContainer stripped from its + first 6 characters since all folder names are prefixed with + "folder". + + * SoObjects/Mailer/SOGoMailBaseObject.m ([SOGoMailBaseObject + -imap4URLString]): invoke -relativeImap4Name instead of + "nameInContainer" since the former will return the fixed IMAP4 + foldername and the latter the SoObject name. + + * SoObjects/Mailer/SOGoMailObject.m ([SOGoMailObject + +initialize]): we now fetch the "BODYSTRUCTURE" key instead of "BODY". + + * SoObjects/Mailer/SOGoMailAccount.m ([SOGoMailAccount -inboxFolderNameInContext:]) + ([SOGoMailAccount -draftsFolderNameInContext:_ctx]) + ([SOGoMailAccount -sieveFolderNameInContext:_ctx]) + ([SOGoMailAccount -sentFolderNameInContext:]) + ([SOGoMailAccount -trashFolderNameInContext:]): prefix the folder + names with "folder". + ([SOGoMailAccount -inboxFolderInContext:_ctx]) + ([SOGoMailAccount -sentFolderInContext:_ctx]) + ([SOGoMailAccount -trashFolderInContext:_ctx]): no longer prefix + the folder names with "folder" since they are prefixed earlier. + +2007-07-30 Wolfgang Sourdeau + + * SoObjects/Mailer/SOGoMailAccount.m ([SOGoMailAccount -inboxFolderInContext:_ctx]) + ([-sentFolderInContext:], [-trashFolderInContext:]): folder keys + all starts with "folder". + + * SoObjects/SOGo/SOGoObject.m ([SOGoObject +initialize]): no + longer declare security info from here. + + * SoObjects/Mailer/SOGoMailFolder.m + ([-isMessageKey:_keyinContext:_ctx]): removed useless method. + ([SOGoMailFolder -lookupName:_keyinContext:acquire:_acquire]): + folder names now always start with "folder". + + * SoObjects/Mailer/SOGoMailAccount.m + ([-lookupName:inContext:acquire:]): folder names now always start + with "folder". + 2007-07-27 Wolfgang Sourdeau * UI/MailerUI/UIxMailForwardAction.m ([UIxMailForwardAction diff --git a/NEWS b/NEWS index 281d6d33..0396e560 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ entries whenever a specific one is being requested; - added support for limiting LDAP queries with the SOGoLDAPQueryLimit and the SOGoLDAPSizeLimit settings; +- fixed a bug where folders starting with digits would not be displayed; 0.9.0-20070713 -------------- diff --git a/OGoContentStore/GNUmakefile b/OGoContentStore/GNUmakefile index d8a20b4f..d66c95f2 100644 --- a/OGoContentStore/GNUmakefile +++ b/OGoContentStore/GNUmakefile @@ -22,7 +22,9 @@ libOGoContentStore_OBJC_FILES += \ libOGoContentStore_TYPEMODELS += \ appointment.ocs \ - contact.ocs + contact.ocs \ + appointment-oracle.ocs \ + contact-oracle.ocs test_quick_extract_OBJC_FILES += \ test_quick_extract.m diff --git a/SoObjects/Mailer/SOGoCalendarMailBodyPart.m b/SoObjects/Mailer/SOGoCalendarMailBodyPart.m index 714c0bc4..def0dda8 100644 --- a/SoObjects/Mailer/SOGoCalendarMailBodyPart.m +++ b/SoObjects/Mailer/SOGoCalendarMailBodyPart.m @@ -19,7 +19,7 @@ 02111-1307, USA. */ -#include +#import "SOGoMailBodyPart.h" /* SOGoCalendarMailBodyPart @@ -31,13 +31,8 @@ */ @interface SOGoCalendarMailBodyPart : SOGoMailBodyPart -{ -} - @end -#include "common.h" - @implementation SOGoCalendarMailBodyPart @end /* SOGoCalendarMailBodyPart */ diff --git a/SoObjects/Mailer/SOGoDraftsFolder.m b/SoObjects/Mailer/SOGoDraftsFolder.m index 13655da0..2509ff05 100644 --- a/SoObjects/Mailer/SOGoDraftsFolder.m +++ b/SoObjects/Mailer/SOGoDraftsFolder.m @@ -19,35 +19,51 @@ 02111-1307, USA. */ -#include "SOGoDraftsFolder.h" -#include "SOGoDraftObject.h" -#include -#include -#include "common.h" -#include +#import + +#import +#import + +#import +#import +#import +#import + +#import +#import "SOGoDraftObject.h" + +#import "SOGoDraftsFolder.h" @implementation SOGoDraftsFolder static NSString *spoolFolder = nil; -+ (void)initialize { - NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; ++ (void) initialize +{ + NSUserDefaults *ud;; - spoolFolder = [[ud stringForKey:@"SOGoMailSpoolPath"] copy]; - if ([spoolFolder length] < 3) - spoolFolder = @"/tmp/"; - - NSLog(@"Note: using SOGo mail spool folder: %@", spoolFolder); + if (!spoolFolder) + { + ud = [NSUserDefaults standardUserDefaults]; + spoolFolder = [[ud stringForKey:@"SOGoMailSpoolPath"] copy]; + if ([spoolFolder length] < 3) + spoolFolder = @"/tmp/"; + + NSLog(@"Note: using SOGo mail spool folder: %@", spoolFolder); + } } /* new objects */ -- (NSString *)makeNewObjectNameInContext:(id)_ctx { +- (NSString *) makeNewObjectNameInContext: (id) _ctx +{ static int counter = 1; // THREAD + return [NSString stringWithFormat:@"draft_%08d_%08x", getpid(), counter++]; } -- (NSString *)newObjectBaseURLInContext:(id)_ctx { +- (NSString *) newObjectBaseURLInContext: (id) _ctx +{ NSString *s, *n; n = [self makeNewObjectNameInContext:_ctx]; @@ -59,29 +75,36 @@ static NSString *spoolFolder = nil; return [s stringByAppendingString:n]; } -- (id)newObjectInContext:(id)_ctx { +- (id) newObjectInContext: (id) _ctx +{ return [self lookupName:[self makeNewObjectNameInContext:_ctx] inContext:_ctx acquire:NO]; } /* draft folder functionality */ -- (NSFileManager *)spoolFileManager { +- (NSFileManager *) spoolFileManager +{ return [NSFileManager defaultManager]; } -- (NSString *)spoolFolderPath { +- (NSString *) spoolFolderPath +{ return spoolFolder; } -- (NSString *)userSpoolFolderPath { + +- (NSString *) userSpoolFolderPath +{ NSString *p, *n; p = [self spoolFolderPath]; n = [[self lookupUserFolder] nameInContainer]; + return [p stringByAppendingPathComponent:n]; } -- (BOOL)_ensureUserSpoolFolderPath { +- (BOOL) _ensureUserSpoolFolderPath +{ NSFileManager *fm; if ((fm = [self spoolFileManager]) == nil) { @@ -92,7 +115,8 @@ static NSString *spoolFolder = nil; attributes:nil]; } -- (NSArray *)fetchMailNames { +- (NSArray *) fetchMailNames +{ NSString *p; if ((p = [self userSpoolFolderPath]) == nil) @@ -103,7 +127,9 @@ static NSString *spoolFolder = nil; /* folder methods (used by template) */ -- (NSArray *)fetchUIDsMatchingQualifier:(id)_q sortOrdering:(id)_so { +- (NSArray *) fetchUIDsMatchingQualifier: (id) _q + sortOrdering: (id) _so +{ // TODO: retrieve contained objects NSArray *allUids; @@ -117,7 +143,7 @@ static NSString *spoolFolder = nil; // TODO: should sort uids (q=%@,so=%@): %@", _q, _so, allUids]; return allUids; } -- (NSArray *)fetchUIDs:(NSArray *)_uids parts:(NSArray *)_parts { +- (NSArray *)fetchUIDs: (NSArray *)_uids parts: (NSArray *)_parts { /* FLAGS, ENVELOPE, RFC822.SIZE */ NSMutableArray *drafts; unsigned i, count; @@ -146,13 +172,18 @@ static NSString *spoolFolder = nil; /* name lookup */ -- (id)lookupDraftMessage:(NSString *)_key inContext:(id)_ctx { +- (id) lookupDraftMessage: (NSString *) _key + inContext: (id) _ctx +{ // TODO: we might want to check for existence prior controller creation return [[[SOGoDraftObject alloc] initWithName:_key inContainer:self] autorelease]; } -- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { +- (id) lookupName: (NSString *) _key + inContext: (id) _ctx + acquire: (BOOL) _flag +{ id obj; /* first check attributes directly bound to the application */ @@ -168,17 +199,20 @@ static NSString *spoolFolder = nil; /* WebDAV */ -- (BOOL)davIsCollection { +- (BOOL) davIsCollection +{ return YES; } -- (NSArray *)toOneRelationshipKeys { +- (NSArray *) toOneRelationshipKeys +{ return [self fetchMailNames]; } /* folder type */ -- (NSString *)outlookFolderClass { +- (NSString *) outlookFolderClass +{ return @"IPF.Drafts"; } diff --git a/SoObjects/Mailer/SOGoImageMailBodyPart.m b/SoObjects/Mailer/SOGoImageMailBodyPart.m index 0319ac00..3d967920 100644 --- a/SoObjects/Mailer/SOGoImageMailBodyPart.m +++ b/SoObjects/Mailer/SOGoImageMailBodyPart.m @@ -19,7 +19,7 @@ 02111-1307, USA. */ -#include +#import "SOGoMailBodyPart.h" /* SOGoImageMailBodyPart @@ -36,8 +36,6 @@ @end -#include "common.h" - @implementation SOGoImageMailBodyPart @end /* SOGoImageMailBodyPart */ diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index b82b1451..93927275 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -19,13 +19,25 @@ 02111-1307, USA. */ -#include "SOGoMailAccount.h" -#include "SOGoMailFolder.h" -#include "SOGoMailManager.h" -#include "SOGoDraftsFolder.h" -#include "SOGoUser+Mail.h" -#include -#include "common.h" +#import +#import +#import +#import + +#import +#import +#import +#import +#import +#import +#import + +#import "SOGoMailFolder.h" +#import "SOGoMailManager.h" +#import "SOGoDraftsFolder.h" +#import "SOGoUser+Mail.h" + +#import "SOGoMailAccount.h" @implementation SOGoMailAccount @@ -33,6 +45,8 @@ static NSArray *rootFolderNames = nil; static NSString *inboxFolderName = @"INBOX"; static NSString *draftsFolderName = @"Drafts"; static NSString *sieveFolderName = @"Filters"; +static NSString *sentFolderName = nil; +static NSString *trashFolderName = nil; static NSString *sharedFolderName = @""; // TODO: add English default static NSString *otherUsersFolderName = @""; // TODO: add English default static BOOL useAltNamespace = NO; @@ -43,9 +57,23 @@ static BOOL useAltNamespace = NO; useAltNamespace = [ud boolForKey:@"SOGoSpecialFoldersInRoot"]; - sharedFolderName = [ud stringForKey:@"SOGoSharedFolderName"]; + sharedFolderName = [ud stringForKey:@"SOGoSharedFolderName"]; otherUsersFolderName = [ud stringForKey:@"SOGoOtherUsersFolderName"]; cfgDraftsFolderName = [ud stringForKey:@"SOGoDraftsFolderName"]; + if (!sentFolderName) + { + sentFolderName = [ud stringForKey: @"SOGoSentFolderName"]; + if (!sentFolderName) + sentFolderName = @"Sent"; + [sentFolderName retain]; + } + if (!trashFolderName) + { + trashFolderName = [ud stringForKey: @"SOGoTrashFolderName"]; + if (!trashFolderName) + trashFolderName = @"Trash"; + [trashFolderName retain]; + } if ([cfgDraftsFolderName length] > 0) { ASSIGN (draftsFolderName, cfgDraftsFolderName); @@ -220,7 +248,7 @@ static BOOL useAltNamespace = NO; - (id)lookupImap4Folder:(NSString *)_key inContext:(id)_cx { NSString *s; - s = [_key isEqualToString:[self trashFolderNameInContext:_cx]] + s = [_key isEqualToString: [self trashFolderNameInContext:_cx]] ? @"SOGoTrashFolder" : @"SOGoMailFolder"; return [self lookupFolder:_key ofClassNamed:s inContext:_cx]; @@ -235,127 +263,117 @@ static BOOL useAltNamespace = NO; inContext:_ctx]; } -- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { +- (id) lookupName: (NSString *) _key + inContext: (id)_ctx + acquire: (BOOL) _flag +{ id obj; - - /* first check attributes directly bound to the application */ - if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]) != nil) - return obj; - + + if ([_key hasPrefix: @"folder"]) + { // TODO: those should be product.plist bindings? (can't be class bindings // though because they are 'per-account') - if ([_key isEqualToString: draftsFolderName]) { - if ((obj = [self lookupDraftsFolder:_key inContext:_ctx]) != nil) - return obj; - } - if ([_key isEqualToString: sieveFolderName]) { - if ((obj = [self lookupFiltersFolder:_key inContext:_ctx]) != nil) - return obj; - } - - if ((obj = [self lookupImap4Folder:_key inContext:_ctx]) != nil) - return obj; + if ([_key isEqualToString: [self draftsFolderNameInContext: _ctx]]) + obj = [self lookupDraftsFolder: _key inContext: _ctx]; + else if ([_key isEqualToString: [self sieveFolderNameInContext: _ctx]]) + obj = [self lookupFiltersFolder: _key inContext: _ctx]; + else + obj = [self lookupImap4Folder: _key inContext: _ctx]; + } + else + obj = [super lookupName: _key inContext: _ctx acquire: NO]; /* return 404 to stop acquisition */ - return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; + if (!obj) + obj = [NSException exceptionWithHTTPStatus: 404 /* Not Found */]; + + return obj; } /* special folders */ -- (NSString *)inboxFolderNameInContext:(id)_ctx { - return inboxFolderName; /* cannot be changed in Cyrus ? */ +- (NSString *) inboxFolderNameInContext: (id)_ctx +{ + /* cannot be changed in Cyrus ? */ + return [NSString stringWithFormat: @"folder%@", inboxFolderName]; } -- (NSString *)draftsFolderNameInContext:(id)_ctx { - return draftsFolderName; /* SOGo managed folder */ + +- (NSString *) draftsFolderNameInContext: (id) _ctx +{ + /* SOGo managed folder */ + return [NSString stringWithFormat: @"folder%@", draftsFolderName]; } -- (NSString *)sieveFolderNameInContext:(id)_ctx { - return sieveFolderName; /* SOGo managed folder */ + +- (NSString *) sieveFolderNameInContext: (id) _ctx +{ + return [NSString stringWithFormat: @"folder%@", sieveFolderName]; } -- (NSString *)sentFolderNameInContext:(id)_ctx { - /* OGo issue #1225 */ - static NSString *s = nil; - - if (s == nil) { - NSUserDefaults *ud; - - ud = [NSUserDefaults standardUserDefaults]; - s = [[ud stringForKey:@"SOGoSentFolderName"] copy]; - if ([s length] == 0) s = @"Sent"; - [self logWithFormat:@"Note: using SOGoSentFolderName: '%@'", s]; - } - return s; + +- (NSString *) sentFolderNameInContext: (id)_ctx +{ + return [NSString stringWithFormat: @"folder%@", sentFolderName]; } -- (NSString *)trashFolderNameInContext:(id)_ctx { - /* OGo issue #1225 */ - static NSString *s = nil; - - if (s == nil) { - NSUserDefaults *ud; - - ud = [NSUserDefaults standardUserDefaults]; - s = [[ud stringForKey:@"SOGoTrashFolderName"] copy]; - if ([s length] == 0) s = @"Trash"; - NSLog(@"Note: using SOGoTrashFolderName: '%@'", s); - } - return s; + +- (NSString *) trashFolderNameInContext: (id)_ctx +{ + return [NSString stringWithFormat: @"folder%@", trashFolderName]; } -- (SOGoMailFolder *)inboxFolderInContext:(id)_ctx { +- (SOGoMailFolder *) inboxFolderInContext: (id) _ctx +{ // TODO: use some profile to determine real location, use a -traverse lookup - SOGoMailFolder *folder; - - if (inboxFolder != nil) - return inboxFolder; - - folder = [self lookupName:[self inboxFolderNameInContext:_ctx] - inContext:_ctx acquire:NO]; - if ([folder isKindOfClass:[NSException class]]) return folder; - - return ((inboxFolder = [folder retain])); + if (!inboxFolder) + { + inboxFolder = [self lookupName: [self inboxFolderNameInContext: _ctx] + inContext: _ctx acquire: NO]; + [inboxFolder retain]; + } + + return inboxFolder; } -- (SOGoMailFolder *)sentFolderInContext:(id)_ctx { +- (SOGoMailFolder *) sentFolderInContext: (id) _ctx +{ + SOGoMailFolder *lookupFolder; // TODO: use some profile to determine real location, use a -traverse lookup - SOGoMailFolder *folder; - - if (sentFolder != nil) - return sentFolder; - - folder = useAltNamespace ? (id)self : [self inboxFolderInContext:_ctx]; - if ([folder isKindOfClass:[NSException class]]) return folder; - - folder = [folder lookupName:[self sentFolderNameInContext:_ctx] - inContext:_ctx acquire:NO]; - if ([folder isKindOfClass:[NSException class]]) return folder; - - if (![folder isNotNull]) { - return [NSException exceptionWithHTTPStatus:404 /* not found */ - reason:@"did not find Sent folder!"]; - } - - return ((sentFolder = [folder retain])); + + if (!sentFolder) + { + lookupFolder = (useAltNamespace + ? (id) self + : [self inboxFolderInContext:_ctx]); + if (![lookupFolder isKindOfClass: [NSException class]]) + sentFolder = [lookupFolder lookupName: [self sentFolderNameInContext:_ctx] + inContext: _ctx acquire: NO]; + if (![sentFolder isNotNull]) + sentFolder = [NSException exceptionWithHTTPStatus: 404 /* not found */ + reason: @"did not find Sent folder!"]; + [sentFolder retain]; + } + + return sentFolder; } -- (SOGoMailFolder *)trashFolderInContext:(id)_ctx { - // TODO: use some profile to determine real location - SOGoMailFolder *folder; - - if (trashFolder != nil) - return trashFolder; - - folder = useAltNamespace ? (id)self : [self inboxFolderInContext:_ctx]; - if ([folder isKindOfClass:[NSException class]]) return folder; - - folder = [folder lookupName:[self trashFolderNameInContext:_ctx] - inContext:_ctx acquire:NO]; - if ([folder isKindOfClass:[NSException class]]) return folder; - - if (![folder isNotNull]) { - return [NSException exceptionWithHTTPStatus:404 /* not found */ - reason:@"did not find Trash folder!"]; - } - - return ((trashFolder = [folder retain])); +- (SOGoMailFolder *) trashFolderInContext: (id) _ctx +{ + SOGoMailFolder *lookupFolder; + // TODO: use some profile to determine real location, use a -traverse lookup + + if (!trashFolder) + { + lookupFolder = (useAltNamespace + ? (id) self + : [self inboxFolderInContext:_ctx]); + if (![lookupFolder isKindOfClass: [NSException class]]) + trashFolder = [lookupFolder lookupName: [self trashFolderNameInContext: _ctx] + inContext: _ctx acquire: NO]; + if (![trashFolder isNotNull]) + trashFolder = [NSException exceptionWithHTTPStatus: 404 /* not found */ + reason: @"did not find Trash folder!"]; + [trashFolder retain]; + } + + return trashFolder; } /* WebDAV */ diff --git a/SoObjects/Mailer/SOGoMailAccounts.m b/SoObjects/Mailer/SOGoMailAccounts.m index bb3ac3ba..71d4f0b8 100644 --- a/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SoObjects/Mailer/SOGoMailAccounts.m @@ -19,10 +19,16 @@ 02111-1307, USA. */ -#include "SOGoMailAccounts.h" -#include "SOGoUser+Mail.h" -#include "common.h" -#include +#import + +#import +#import +#import +#import + +#import "SOGoUser+Mail.h" + +#import "SOGoMailAccounts.h" @implementation SOGoMailAccounts @@ -38,7 +44,7 @@ static NSString *AgenorShareLoginMarker = @".-."; - (NSArray *)toManyRelationshipKeys { SOGoUser *user; id account; - NSArray *shares; +// NSArray *shares; NSString *userLogin; /* @@ -63,11 +69,12 @@ static NSString *AgenorShareLoginMarker = @".-."; account = [user primaryIMAP4AccountString]; if ([account isNotNull]) account = [NSArray arrayWithObject:account]; - - shares = [user valueForKey:@"additionalIMAP4AccountStrings"]; - return ([shares count] == 0) - ? account - : [account arrayByAddingObjectsFromArray:shares]; + + return account; +// shares = [user valueForKey:@"additionalIMAP4AccountStrings"] +// return ([shares count] == 0) +// ? account +// : [account arrayByAddingObjectsFromArray:shares]; } - (NSArray *) fetchIdentitiesWithOnlyEmitterAccess: (BOOL) _flag diff --git a/SoObjects/Mailer/SOGoMailBaseObject.m b/SoObjects/Mailer/SOGoMailBaseObject.m index 4ba1c62c..91d3c8d8 100644 --- a/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SoObjects/Mailer/SOGoMailBaseObject.m @@ -142,9 +142,11 @@ static BOOL debugOn = YES; - (NSMutableString *) imap4URLString { NSMutableString *urlString; + NSString *imap4Name; urlString = [container imap4URLString]; - [urlString appendFormat: @"%@/", [nameInContainer stringByEscapingURL]]; + imap4Name = [[self relativeImap4Name] stringByEscapingURL]; + [urlString appendFormat: @"%@/", imap4Name]; return urlString; } @@ -154,9 +156,7 @@ static BOOL debugOn = YES; /* this could probably be handled better from NSURL but it's buggy in GNUstep */ if (!imap4URL) - { - imap4URL = [[NSURL alloc] initWithString: [self imap4URLString]]; - } + imap4URL = [[NSURL alloc] initWithString: [self imap4URLString]]; return imap4URL; } diff --git a/SoObjects/Mailer/SOGoMailBodyPart.h b/SoObjects/Mailer/SOGoMailBodyPart.h index 7a996ebd..bfb30aa2 100644 --- a/SoObjects/Mailer/SOGoMailBodyPart.h +++ b/SoObjects/Mailer/SOGoMailBodyPart.h @@ -22,7 +22,7 @@ #ifndef __Mailer_SOGoMailBodyPart_H__ #define __Mailer_SOGoMailBodyPart_H__ -#include +#import /* SOGoMailBodyPart @@ -45,21 +45,23 @@ /* hierarchy */ -- (SOGoMailObject *)mailObject; +- (SOGoMailObject *) mailObject; /* IMAP4 */ -- (NSString *)bodyPartName; -- (NSArray *)bodyPartPath; -- (NSString *)bodyPartIdentifier; +- (NSString *) bodyPartName; +- (NSArray *) bodyPartPath; +- (NSString *) bodyPartIdentifier; /* part info */ -- (id)partInfo; +- (id) partInfo; +- (NSData *) fetchBLOB; /* factory */ -+ (Class)bodyPartClassForKey:(NSString *)_key inContext:(id)_ctx; ++ (Class) bodyPartClassForKey: (NSString *) _key + inContext: (id) _ctx; @end diff --git a/SoObjects/Mailer/SOGoMailBodyPart.m b/SoObjects/Mailer/SOGoMailBodyPart.m index ec10200f..15bc9dd5 100644 --- a/SoObjects/Mailer/SOGoMailBodyPart.m +++ b/SoObjects/Mailer/SOGoMailBodyPart.m @@ -19,10 +19,25 @@ 02111-1307, USA. */ -#include "SOGoMailBodyPart.h" -#include "SOGoMailObject.h" -#include "SOGoMailManager.h" -#include "common.h" +#import +#import +#import +#import +#import + +#import +#import +#import +#import +#import +#import +#import +#import + +#import "SOGoMailObject.h" +#import "SOGoMailManager.h" + +#import "SOGoMailBodyPart.h" @implementation SOGoMailBodyPart diff --git a/SoObjects/Mailer/SOGoMailFolder.h b/SoObjects/Mailer/SOGoMailFolder.h index f6fd2f53..491734c7 100644 --- a/SoObjects/Mailer/SOGoMailFolder.h +++ b/SoObjects/Mailer/SOGoMailFolder.h @@ -33,13 +33,13 @@ The SOGoMailFolder maps to an IMAP4 folder from NGImap4. */ -@class NSData, NSArray, NSException; +@class NSData, NSArray, NSException, NSMutableArray; @class NGImap4MailboxInfo; @interface SOGoMailFolder : SOGoMailBaseObject { - NSArray *filenames; - NSString *folderType; + NSMutableArray *filenames; + NSString *folderType; } /* messages */ diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index ab951bda..5198482c 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -102,7 +102,7 @@ static BOOL useAltNamespace = NO; - (NSString *) relativeImap4Name { - return nameInContainer; + return [nameInContainer substringFromIndex: 6]; } /* listing the available folders */ @@ -151,34 +151,26 @@ static BOOL useAltNamespace = NO; - (NSArray *) toOneRelationshipKeys { - NSArray *uids; - unsigned count; - - if (filenames != nil) - return [filenames isNotNull] ? filenames : nil; + NSArray *uids; + unsigned int count, max; + NSString *filename; - uids = [self fetchUIDsMatchingQualifier:nil sortOrdering:@"DATE"]; - if ([uids isKindOfClass:[NSException class]]) - return nil; - - if ((count = [uids count]) == 0) { - filenames = [[NSArray alloc] init]; - } - else { - NSMutableArray *keys; - unsigned i; - - keys = [[NSMutableArray alloc] initWithCapacity:count]; - for (i = 0; i < count; i++) { - NSString *k; - - k = [[uids objectAtIndex:i] stringValue]; - k = [k stringByAppendingString:@".mail"]; - [keys addObject:k]; + if (!filenames) + { + filenames = [NSMutableArray new]; + uids = [self fetchUIDsMatchingQualifier: nil sortOrdering: @"DATE"]; + if (![uids isKindOfClass: [NSException class]]) + { + max = [uids count]; + for (count = 0; count < max; count++) + { + filename = [NSString stringWithFormat: @"%@.mail", + [uids objectAtIndex: count]]; + [filenames addObject: filename]; + } + } } - filenames = [keys copy]; - [keys release]; - } + return filenames; } @@ -230,27 +222,6 @@ static BOOL useAltNamespace = NO; /* name lookup */ -- (BOOL) isMessageKey: (NSString *) _key - inContext: (id) _ctx -{ - /* - Every key starting with a digit is consider an IMAP4 message key. This is - not entirely correct since folders could also start with a number. - - If we want to support folders beginning with numbers, we would need to - scan the folder list for the _key, which would make everything quite a bit - slower. - TODO: support this mode using a default. - */ - if ([_key length] == 0) - return NO; - - if (isdigit([_key characterAtIndex:0])) - return YES; - - return NO; -} - - (id) lookupImap4Folder: (NSString *) _key inContext: (id) _ctx { @@ -291,28 +262,22 @@ static BOOL useAltNamespace = NO; acquire: (BOOL) _acquire { id obj; - - if ([self isMessageKey:_key inContext:_ctx]) { - /* - We assume here that _key is a number and methods are not and this is - moved above the super lookup since the super checks the - -toOneRelationshipKeys which in turn loads the message ids. - */ - return [self lookupImap4Message:_key inContext:_ctx]; - } - obj = [self lookupImap4Folder:_key inContext:_ctx]; - if (obj != nil) - return obj; - - /* check attributes directly bound to the app */ - if ((obj = [super lookupName:_key inContext:_ctx acquire:NO])) - return obj; - - /* return 404 to stop acquisition */ - return _acquire - ? [NSException exceptionWithHTTPStatus:404 /* Not Found */] - : nil; /* hack to work with WebDAV move */ + if ([_key hasPrefix: @"folder"]) + obj = [self lookupImap4Folder: [_key substringFromIndex: 6] + inContext: _ctx]; + else + { + if (isdigit ([_key characterAtIndex: 0])) + obj = [self lookupImap4Message: _key inContext: _ctx]; + else + obj = [super lookupName: _key inContext: _ctx acquire: NO]; + } + + if (!obj && _acquire) + obj = [NSException exceptionWithHTTPStatus: 404 /* Not Found */]; + + return obj; } /* WebDAV */ diff --git a/SoObjects/Mailer/SOGoMailFolderDataSource.m b/SoObjects/Mailer/SOGoMailFolderDataSource.m index f9aba487..2dbc71ee 100644 --- a/SoObjects/Mailer/SOGoMailFolderDataSource.m +++ b/SoObjects/Mailer/SOGoMailFolderDataSource.m @@ -19,11 +19,21 @@ 02111-1307, USA. */ -#include "SOGoMailFolderDataSource.h" -#include "SOGoMailManager.h" -#include -#include -#include "common.h" +#import +#import +#import +#import + +#import +#import +#import +#import +#import +#import + +#import "SOGoMailManager.h" + +#import "SOGoMailFolderDataSource.h" @implementation SOGoMailFolderDataSource diff --git a/SoObjects/Mailer/SOGoMailIdentity.m b/SoObjects/Mailer/SOGoMailIdentity.m index a9373dfa..424d0891 100644 --- a/SoObjects/Mailer/SOGoMailIdentity.m +++ b/SoObjects/Mailer/SOGoMailIdentity.m @@ -19,101 +19,104 @@ 02111-1307, USA. */ -#include "SOGoMailIdentity.h" -#include "common.h" +#import + +#import + +#import "SOGoMailIdentity.h" @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]; + [name release]; + [email release]; + [replyTo release]; + [organization release]; + [signature release]; + [vCard release]; + [sentFolderName release]; + [sentBCC release]; + [draftsFolderName release]; + [templatesFolderName release]; [super dealloc]; } /* accessors */ - (void)setName:(NSString *)_value { - ASSIGNCOPY(self->name, _value); + ASSIGNCOPY(name, _value); } - (NSString *)name { - return self->name; + return name; } - (void)setEmail:(NSString *)_value { - ASSIGNCOPY(self->email, _value); + ASSIGNCOPY(email, _value); } - (NSString *)email { - return self->email; + return email; } - (void)setReplyTo:(NSString *)_value { - ASSIGNCOPY(self->replyTo, _value); + ASSIGNCOPY(replyTo, _value); } - (NSString *)replyTo { - return self->replyTo; + return replyTo; } - (void)setOrganization:(NSString *)_value { - ASSIGNCOPY(self->organization, _value); + ASSIGNCOPY(organization, _value); } - (NSString *)organization { - return self->organization; + return organization; } - (void)setSignature:(NSString *)_value { - ASSIGNCOPY(self->signature, _value); + ASSIGNCOPY(signature, _value); } - (NSString *)signature { - return self->signature; + return signature; } - (BOOL)hasSignature { return [[self signature] isNotEmpty]; } - (void)setVCard:(NSString *)_value { - ASSIGNCOPY(self->vCard, _value); + ASSIGNCOPY(vCard, _value); } - (NSString *)vCard { - return self->vCard; + return vCard; } - (BOOL)hasVCard { return [[self vCard] isNotEmpty]; } - (void)setSentFolderName:(NSString *)_value { - ASSIGNCOPY(self->sentFolderName, _value); + ASSIGNCOPY(sentFolderName, _value); } - (NSString *)sentFolderName { - return self->sentFolderName; + return sentFolderName; } - (void)setSentBCC:(NSString *)_value { - ASSIGNCOPY(self->sentBCC, _value); + ASSIGNCOPY(sentBCC, _value); } - (NSString *)sentBCC { - return self->sentBCC; + return sentBCC; } - (void)setDraftsFolderName:(NSString *)_value { - ASSIGNCOPY(self->draftsFolderName, _value); + ASSIGNCOPY(draftsFolderName, _value); } - (NSString *)draftsFolderName { - return self->draftsFolderName; + return draftsFolderName; } - (void)setTemplatesFolderName:(NSString *)_value { - ASSIGNCOPY(self->templatesFolderName, _value); + ASSIGNCOPY(templatesFolderName, _value); } - (NSString *)templatesFolderName { - return self->templatesFolderName; + return templatesFolderName; } /* description */ @@ -124,14 +127,14 @@ 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 (name != nil) [ms appendFormat:@" name='%@'", name]; + if (email != nil) [ms appendFormat:@" email='%@'", email]; - if (self->sentFolderName != nil) - [ms appendFormat:@" sent='%@'", self->sentFolderName]; + if (sentFolderName != nil) + [ms appendFormat:@" sent='%@'", sentFolderName]; - if ([self->sentBCC length] > 0) [ms appendString:@" sent-bcc"]; - if ([self->vCard length] > 0) [ms appendString:@" vcard"]; + if ([sentBCC length] > 0) [ms appendString:@" sent-bcc"]; + if ([vCard length] > 0) [ms appendString:@" vcard"]; [ms appendString:@">"]; return ms; diff --git a/SoObjects/Mailer/SOGoMailManager.m b/SoObjects/Mailer/SOGoMailManager.m index f3e947a3..59c1f4c0 100644 --- a/SoObjects/Mailer/SOGoMailManager.m +++ b/SoObjects/Mailer/SOGoMailManager.m @@ -19,10 +19,14 @@ 02111-1307, USA. */ -#include "SOGoMailManager.h" -#include -#include -#include "common.h" +#import + +#import +#import +#import +#import + +#import "SOGoMailManager.h" /* Could check read-write state: diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index db704eb9..75306461 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -74,7 +74,7 @@ static BOOL debugSoParts = NO; /* Note: "BODY" actually returns the structure! */ if (fetchHeader) { coreInfoKeys = [[NSArray alloc] initWithObjects: - @"FLAGS", @"ENVELOPE", @"BODY", + @"FLAGS", @"ENVELOPE", @"BODYSTRUCTURE", @"RFC822.SIZE", @"RFC822.HEADER", // not yet supported: @"INTERNALDATE", @@ -82,7 +82,7 @@ static BOOL debugSoParts = NO; } else { coreInfoKeys = [[NSArray alloc] initWithObjects: - @"FLAGS", @"ENVELOPE", @"BODY", + @"FLAGS", @"ENVELOPE", @"BODYSTRUCTURE", @"RFC822.SIZE", // not yet supported: @"INTERNALDATE", nil]; @@ -117,9 +117,11 @@ static BOOL debugSoParts = NO; - (NSMutableString *) imap4URLString { NSMutableString *urlString; + NSString *imap4Name; urlString = [container imap4URLString]; - [urlString appendFormat: @"%@", [nameInContainer stringByEscapingURL]]; + imap4Name = [[self relativeImap4Name] stringByEscapingURL]; + [urlString appendFormat: @"%@", imap4Name]; return urlString; } @@ -203,7 +205,7 @@ static BOOL debugSoParts = NO; /* Called by -fetchPlainTextParts: */ - return [[self imap4Connection] fetchURL:[self imap4URL] parts:_parts]; + return [[self imap4Connection] fetchURL: [self imap4URL] parts:_parts]; } /* core infos */ @@ -679,12 +681,12 @@ static BOOL debugSoParts = NO; - (NSException *) addFlags: (id) _flags { - return [[self imap4Connection] addFlags:_flags toURL:[self imap4URL]]; + return [[self imap4Connection] addFlags:_flags toURL: [self imap4URL]]; } - (NSException *) removeFlags: (id) _flags { - return [[self imap4Connection] removeFlags:_flags toURL:[self imap4URL]]; + return [[self imap4Connection] removeFlags:_flags toURL: [self imap4URL]]; } /* permissions */ diff --git a/SoObjects/Mailer/SOGoMessageMailBodyPart.m b/SoObjects/Mailer/SOGoMessageMailBodyPart.m index 4932bf20..0e5fcc5b 100644 --- a/SoObjects/Mailer/SOGoMessageMailBodyPart.m +++ b/SoObjects/Mailer/SOGoMessageMailBodyPart.m @@ -19,7 +19,7 @@ 02111-1307, USA. */ -#include +#import "SOGoMailBodyPart.h" /* SOGoMessageMailBodyPart @@ -33,13 +33,8 @@ */ @interface SOGoMessageMailBodyPart : SOGoMailBodyPart -{ -} - @end -#include "common.h" - @implementation SOGoMessageMailBodyPart @end /* SOGoMessageMailBodyPart */ diff --git a/SoObjects/Mailer/SOGoSharedInboxFolder.h b/SoObjects/Mailer/SOGoSharedInboxFolder.h index 1e597b30..8fc1f417 100644 --- a/SoObjects/Mailer/SOGoSharedInboxFolder.h +++ b/SoObjects/Mailer/SOGoSharedInboxFolder.h @@ -22,7 +22,7 @@ #ifndef __Mailer_SOGoSharedInboxFolder_H__ #define __Mailer_SOGoSharedInboxFolder_H__ -#include +#import /* SOGoSharedInboxFolder diff --git a/SoObjects/Mailer/SOGoSharedInboxFolder.m b/SoObjects/Mailer/SOGoSharedInboxFolder.m index d5e444bf..5399b751 100644 --- a/SoObjects/Mailer/SOGoSharedInboxFolder.m +++ b/SoObjects/Mailer/SOGoSharedInboxFolder.m @@ -19,8 +19,7 @@ 02111-1307, USA. */ -#include "SOGoSharedInboxFolder.h" -#include "common.h" +#import "SOGoSharedInboxFolder.h" @implementation SOGoSharedInboxFolder diff --git a/SoObjects/Mailer/SOGoSharedMailAccount.m b/SoObjects/Mailer/SOGoSharedMailAccount.m index 5b7ba9ec..86922604 100644 --- a/SoObjects/Mailer/SOGoSharedMailAccount.m +++ b/SoObjects/Mailer/SOGoSharedMailAccount.m @@ -19,8 +19,13 @@ 02111-1307, USA. */ -#include "SOGoSharedMailAccount.h" -#include "common.h" +#import +#import +#import + +#import + +#import "SOGoSharedMailAccount.h" @interface SOGoMailAccount(UsedPrivates) diff --git a/SoObjects/Mailer/SOGoTrashFolder.h b/SoObjects/Mailer/SOGoTrashFolder.h index c4089a8a..d097490a 100644 --- a/SoObjects/Mailer/SOGoTrashFolder.h +++ b/SoObjects/Mailer/SOGoTrashFolder.h @@ -22,7 +22,7 @@ #ifndef __Mailer_SOGoTrashFolder_H__ #define __Mailer_SOGoTrashFolder_H__ -#include +#import "SOGoMailFolder.h" @interface SOGoTrashFolder : SOGoMailFolder @end diff --git a/SoObjects/Mailer/SOGoTrashFolder.m b/SoObjects/Mailer/SOGoTrashFolder.m index 01cbd13d..b034bfb1 100644 --- a/SoObjects/Mailer/SOGoTrashFolder.m +++ b/SoObjects/Mailer/SOGoTrashFolder.m @@ -19,8 +19,9 @@ 02111-1307, USA. */ -#include "SOGoTrashFolder.h" -#include "common.h" +#import + +#import "SOGoTrashFolder.h" @implementation SOGoTrashFolder diff --git a/SoObjects/Mailer/SOGoUser+Mail.m b/SoObjects/Mailer/SOGoUser+Mail.m index 00b5561c..2cde8398 100644 --- a/SoObjects/Mailer/SOGoUser+Mail.m +++ b/SoObjects/Mailer/SOGoUser+Mail.m @@ -19,9 +19,16 @@ 02111-1307, USA. */ -#include "SOGoUser+Mail.h" -#include "SOGoMailIdentity.h" -#include "common.h" +#import +#import +#import + +#import +#import + +#import "SOGoMailIdentity.h" + +#import "SOGoUser+Mail.h" @implementation SOGoUser(Mail) diff --git a/SoObjects/Mailer/SOGoVCardMailBodyPart.m b/SoObjects/Mailer/SOGoVCardMailBodyPart.m index 3f24d21a..6299fe54 100644 --- a/SoObjects/Mailer/SOGoVCardMailBodyPart.m +++ b/SoObjects/Mailer/SOGoVCardMailBodyPart.m @@ -19,7 +19,7 @@ 02111-1307, USA. */ -#include +#import "SOGoMailBodyPart.h" /* SOGoVCardMailBodyPart @@ -31,13 +31,7 @@ */ @interface SOGoVCardMailBodyPart : SOGoMailBodyPart -{ -} - @end -#include "common.h" - @implementation SOGoVCardMailBodyPart - @end /* SOGoVCardMailBodyPart */ diff --git a/SoObjects/Mailer/common.h b/SoObjects/Mailer/common.h deleted file mode 100644 index 634e72eb..00000000 --- a/SoObjects/Mailer/common.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2002-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. -*/ - -#warning importing common is baaad - -#import -#import - -#if NeXT_Foundation_LIBRARY || COCOA_Foundation_LIBRARY -# include -# include -#endif - -#include -#include -#include - -#include - -#include - -#warning importing common.h is baaad diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index 8691beff..8d84e928 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -167,10 +167,10 @@ static BOOL kontactGroupDAV = YES; // SoClass security declarations // require View permission to access the root (bound to authenticated ...) - [[self soClassSecurityInfo] declareObjectProtected: SoPerm_View]; +// [[self soClassSecurityInfo] declareObjectProtected: SoPerm_View]; // to allow public access to all contained objects (subkeys) - [[self soClassSecurityInfo] setDefaultAccess: @"allow"]; +// [[self soClassSecurityInfo] setDefaultAccess: @"allow"]; // /* require Authenticated role for View and WebDAV */ // [[self soClassSecurityInfo] declareRole: SoRole_Owner diff --git a/UI/Common/English.lproj/Localizable.strings b/UI/Common/English.lproj/Localizable.strings index bb9c1bf5..9af10007 100644 --- a/UI/Common/English.lproj/Localizable.strings +++ b/UI/Common/English.lproj/Localizable.strings @@ -26,3 +26,9 @@ "Default Roles" = "Default Roles"; "Sorry, the user rights can not be configured for that object." = "Sorry, the user rights can not be configured for that object."; + +/* generic.js */ +"Unable to subscribe to that folder!" = "Unable to subscribe to that folder!"; +"You cannot subscribe to a folder that you own!" = "You cannot subscribe to a folder that you own!"; +"Unable to unsubscribe from that folder!" = "Unable to unsubscribe from that folder!"; +"You cannot unsubscribe from a folder that you own!" = "You cannot unsubscribe from a folder that you own!"; diff --git a/UI/Common/French.lproj/Localizable.strings b/UI/Common/French.lproj/Localizable.strings index 5264f182..18a984d3 100644 --- a/UI/Common/French.lproj/Localizable.strings +++ b/UI/Common/French.lproj/Localizable.strings @@ -27,3 +27,9 @@ "Default Roles" = "Rôles par défaut"; "Sorry, the user rights can not be configured for that object." = "Sorry, the user rights can not be configured for that object."; + +/* generic.js */ +"Unable to subscribe to that folder!" = "Impossible de s'abonner à ce dossier."; +"You cannot subscribe to a folder that you own!" = "Impossible de vous abonner à un dossier qui vous appartient."; +"Unable to unsubscribe from that folder!" = "Impossible de se désabonner de ce dossier."; +"You cannot unsubscribe from a folder that you own!" = "Impossible de vous désabonner d'un dossier qui vous appartient."; diff --git a/UI/MailPartViewers/UIxKolabPartContactViewer.m b/UI/MailPartViewers/UIxKolabPartContactViewer.m index dc8f65d1..4a68368d 100644 --- a/UI/MailPartViewers/UIxKolabPartContactViewer.m +++ b/UI/MailPartViewers/UIxKolabPartContactViewer.m @@ -19,6 +19,9 @@ 02111-1307, USA. */ +@class NSString; +#import + #import #import "UIxKolabPartViewer.h" diff --git a/UI/MailPartViewers/UIxMailPartViewer.m b/UI/MailPartViewers/UIxMailPartViewer.m index 73ff7282..e44980ea 100644 --- a/UI/MailPartViewers/UIxMailPartViewer.m +++ b/UI/MailPartViewers/UIxMailPartViewer.m @@ -19,6 +19,7 @@ 02111-1307, USA. */ +#import #import #import @@ -27,7 +28,9 @@ #import #import #import + #import +#import #import "UI/MailerUI/WOContext+UIxMailer.h" #import "UIxMailRenderingContext.h" @@ -37,68 +40,83 @@ @implementation UIxMailPartViewer -- (void)dealloc { +- (void) dealloc +{ [flatContent release]; - [bodyInfo release]; - [partPath release]; + [bodyInfo release]; + [partPath release]; [super dealloc]; } /* caches */ -- (void)resetPathCaches { +- (void) resetPathCaches +{ /* this is called when -setPartPath: is called */ [flatContent release]; flatContent = nil; } -- (void)resetBodyInfoCaches { + +- (void) resetBodyInfoCaches +{ } /* notifications */ -- (void)sleep { +- (void) sleep +{ [self resetPathCaches]; [self resetBodyInfoCaches]; - [partPath release]; partPath = nil; - [bodyInfo release]; bodyInfo = nil; + [partPath release]; + [bodyInfo release]; + partPath = nil; + bodyInfo = nil; [super sleep]; } /* accessors */ -- (void)setPartPath:(NSArray *)_path { - if ([_path isEqual:partPath]) +- (void) setPartPath: (NSArray *) _path +{ + if ([_path isEqual: partPath]) return; - + ASSIGN(partPath, _path); + [self resetPathCaches]; } -- (NSArray *)partPath { + +- (NSArray *) partPath +{ return partPath; } -- (void)setBodyInfo:(id)_info { +- (void) setBodyInfo: (id) _info +{ ASSIGN(bodyInfo, _info); } -- (id)bodyInfo { + +- (id) bodyInfo +{ return bodyInfo; } -- (NSData *)flatContent { +- (NSData *) flatContent +{ if (flatContent != nil) return [flatContent isNotNull] ? flatContent : nil; flatContent = [[[context mailRenderingContext] flatContentForPartPath: - [self partPath]] retain]; + partPath] retain]; return flatContent; } -- (NSData *)decodedFlatContent { +- (NSData *) decodedFlatContent +{ NSString *enc; - enc = [[(NSDictionary *)[self bodyInfo] - objectForKey:@"encoding"] lowercaseString]; - + enc = [[bodyInfo objectForKey:@"encoding"] lowercaseString]; + if ([enc isEqualToString:@"7bit"]) return [self flatContent]; @@ -112,64 +130,100 @@ return [[self flatContent] dataByDecodingQuotedPrintable]; [self errorWithFormat:@"unsupported MIME encoding: %@", enc]; + return [self flatContent]; } -- (NSStringEncoding)fallbackStringEncoding { +- (NSData *) content +{ + NSData *content; + NSEnumerator *parts; + id currentObject; + NSString *currentPart; + + content = nil; + + currentObject = [self clientObject]; + parts = [partPath objectEnumerator]; + currentPart = [parts nextObject]; + while (currentPart) + { + currentObject = [currentObject lookupName: currentPart + inContext: context + acquire: NO]; + currentPart = [parts nextObject]; + } + + content = [currentObject fetchBLOB]; + + return content; +} + +- (NSStringEncoding) fallbackStringEncoding +{ return 0; } + - (NSString *)flatContentAsString { /* Note: we even have the line count in the body-info! */ NSString *charset; NSString *s; NSData *content; - - if ((content = [self decodedFlatContent]) == nil) { - [self errorWithFormat:@"got no text content: %@", - [[self partPath] componentsJoinedByString:@"."]]; - return nil; - } - - charset = [(NSDictionary *) - [(NSDictionary *)[self bodyInfo] objectForKey:@"parameterList"] - objectForKey:@"charset"]; - charset = [charset lowercaseString]; - // TODO: properly decode charset, might need to handle encoding? - - if ([charset length] > 0) { - s = [NSString stringWithData: content usingEncodingNamed: charset]; - } - else { - s = [[NSString alloc] initWithData: content encoding: NSUTF8StringEncoding]; - s = [s autorelease]; - } + content = [self decodedFlatContent]; + if (content) + { + charset = [[bodyInfo objectForKey:@"parameterList"] + objectForKey: @"charset"]; + + // TODO: properly decode charset, might need to handle encoding? - if (s == nil) { - /* - Note: this can happend with iCalendar invitations sent by Outlook 2002. - It will mark the content as UTF-8 but actually deliver it as + if ([charset length] > 0) + s = [NSString stringWithData: content + usingEncodingNamed: [charset lowercaseString]]; + else + { + s = [[NSString alloc] initWithData: content + encoding: NSUTF8StringEncoding]; + [s autorelease]; + } + + if (!s) + { + /* + Note: this can happend with iCalendar invitations sent by Outlook 2002. + It will mark the content as UTF-8 but actually deliver it as Latin-1 (or Windows encoding?). - */ - [self errorWithFormat:@"could not convert content to text, charset: '%@'", - charset]; - if ([self fallbackStringEncoding] > 0) { - s = [[NSString alloc] initWithData:content - encoding:[self fallbackStringEncoding]]; - s = [s autorelease]; - - if (s == nil) { - [self errorWithFormat: - @" an attempt to use fallback encoding failed to."]; - } + */ + [self errorWithFormat:@"could not convert content to text, charset: '%@'", + charset]; + if ([self fallbackStringEncoding] > 0) + { + s = [[NSString alloc] initWithData:content + encoding: [self fallbackStringEncoding]]; + if (s) + [s autorelease]; + else + [self errorWithFormat: + @"an attempt to use fallback encoding failed to."]; + } + } } - } + else + { + [self errorWithFormat:@"got no text content: %@", + [partPath componentsJoinedByString:@"."]]; + s = nil; + } + return s; } /* path extension */ -- (NSString *)pathExtensionForType:(NSString *)_mt subtype:(NSString *)_st { +- (NSString *) pathExtensionForType: (NSString *) _mt + subtype: (NSString *) _st +{ // TODO: support /etc/mime.types if (![_mt isNotNull] || ![_st isNotNull]) @@ -199,78 +253,88 @@ return nil; } -- (NSString *)preferredPathExtension { - return [self pathExtensionForType:[[self bodyInfo] valueForKey:@"type"] - subtype:[[self bodyInfo] valueForKey:@"subtype"]]; +- (NSString *) preferredPathExtension +{ + return [self pathExtensionForType: [bodyInfo valueForKey:@"type"] + subtype: [bodyInfo valueForKey:@"subtype"]]; } -- (NSString *)filename { - id tmp; - - tmp = [[self bodyInfo] valueForKey:@"parameterList"]; - if (![tmp isNotNull]) - return nil; - - tmp = [tmp valueForKey:@"name"]; - if (![tmp isNotNull]) - return nil; - if ([tmp length] == 0) - return nil; - - return tmp; +- (NSString *) filename +{ + NSDictionary *parameters; + NSString *filename; + + filename = nil; + parameters = [bodyInfo valueForKey: @"parameterList"]; + if (parameters) + filename = [parameters valueForKey: @"name"]; + + if (!filename) + { + parameters = [[bodyInfo valueForKey: @"disposition"] + valueForKey: @"parameterList"]; + filename = [parameters valueForKey: @"filename"]; + } + + return filename; } -- (NSString *)filenameForDisplay { +- (NSString *) filenameForDisplay +{ NSString *s; if ((s = [self filename]) != nil) return s; - s = [[self partPath] componentsJoinedByString:@"-"]; + s = [partPath componentsJoinedByString:@"-"]; return ([s length] > 0) ? [@"untitled-" stringByAppendingString:s] : @"untitled"; } -- (NSFormatter *)sizeFormatter { +- (NSFormatter *) sizeFormatter +{ return [UIxMailSizeFormatter sharedMailSizeFormatter]; } /* URL generation */ -- (NSString *)pathToAttachmentObject { +- (NSString *) pathToAttachmentObject +{ /* this points to the SoObject representing the part, no modifications */ NSString *url, *n, *pext; /* path to mail controller object */ url = [[self clientObject] baseURLInContext:context]; - if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"]; + if (![url hasSuffix: @"/"]) + url = [url stringByAppendingString: @"/"]; /* mail relative path to body-part */ - if ([(n = [[self partPath] componentsJoinedByString:@"/"]) isNotNull]) { - /* eg this was nil for a draft containing an HTML message */ + /* eg this was nil for a draft containing an HTML message */ + if ([(n = [partPath componentsJoinedByString:@"/"]) isNotNull]) url = [url stringByAppendingString:n]; - } /* we currently NEED the extension for SoObject lookup (should be fixed) */ pext = [self preferredPathExtension]; - if ([pext isNotNull] && [pext length] > 0) { - /* attach extension */ - if ([url hasSuffix:@"/"]) { - /* this happens if the part is the root-content of the mail */ - url = [url substringToIndex:([url length] - 1)]; + if ([pext isNotNull] && [pext length] > 0) + { + /* attach extension */ + if ([url hasSuffix:@"/"]) { + /* this happens if the part is the root-content of the mail */ + url = [url substringToIndex:([url length] - 1)]; + } + url = [url stringByAppendingString:@"."]; + url = [url stringByAppendingString:pext]; } - url = [url stringByAppendingString:@"."]; - url = [url stringByAppendingString:pext]; - } return url; } -- (NSString *)pathToAttachment { +- (NSString *) pathToAttachment +{ /* this generates a more beautiful 'download' URL for a part */ NSString *url, *fn; @@ -288,15 +352,17 @@ SOGoMailBodyPart. */ - if (fn != nil) { - if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"]; - if (isdigit([fn characterAtIndex:0])) - url = [url stringByAppendingString:@"fn-"]; - url = [url stringByAppendingString:[fn stringByEscapingURL]]; + if (fn) + { + if (![url hasSuffix: @"/"]) + url = [url stringByAppendingString: @"/"]; + if (isdigit([fn characterAtIndex:0])) + url = [url stringByAppendingString: @"fn-"]; + url = [url stringByAppendingString: [fn stringByEscapingURL]]; // TODO: should we check for a proper extension? - } - + } + return url; } diff --git a/UI/MailPartViewers/UIxMailRenderingContext.h b/UI/MailPartViewers/UIxMailRenderingContext.h index 13c92f53..5817816a 100644 --- a/UI/MailPartViewers/UIxMailRenderingContext.h +++ b/UI/MailPartViewers/UIxMailRenderingContext.h @@ -24,14 +24,19 @@ #import +#include + + /* UIxMailRenderingContext The rendering context is used to track nesting of mail part viewers. */ -@class NSData, NSArray, NSDictionary; -@class WOContext, WOComponent; +@class NSArray; +@class NSData; +@class NSDictionary; +@class WOComponent; @interface UIxMailRenderingContext : NSObject { @@ -47,31 +52,29 @@ WOComponent *htmlViewer; } -- (id)initWithViewer:(WOComponent *)_viewer context:(WOContext *)_ctx; +- (id) initWithViewer: (WOComponent *) _viewer + context: (WOContext *) _ctx; /* state */ -- (void)reset; +- (void) reset; /* fetching */ -- (NSDictionary *)flatContents; -- (NSData *)flatContentForPartPath:(NSArray *)_partPath; +- (NSDictionary *) flatContents; +- (NSData *) flatContentForPartPath: (NSArray *) _partPath; /* viewer components */ -- (WOComponent *)viewerForBodyInfo:(id)_info; +- (WOComponent *) viewerForBodyInfo: (id)_info; @end - -#include - @interface WOContext(UIxMailPart) -- (void)pushMailRenderingContext:(UIxMailRenderingContext *)_mctx; -- (UIxMailRenderingContext *)popMailRenderingContext; -- (UIxMailRenderingContext *)mailRenderingContext; +- (void) pushMailRenderingContext: (UIxMailRenderingContext *) _mctx; +- (UIxMailRenderingContext *) popMailRenderingContext; +- (UIxMailRenderingContext *) mailRenderingContext; @end diff --git a/UI/MailPartViewers/UIxMailRenderingContext.m b/UI/MailPartViewers/UIxMailRenderingContext.m index e2a101ae..e60be0bb 100644 --- a/UI/MailPartViewers/UIxMailRenderingContext.m +++ b/UI/MailPartViewers/UIxMailRenderingContext.m @@ -19,176 +19,236 @@ 02111-1307, USA. */ -#include "UIxMailRenderingContext.h" -#include -#include "common.h" +#import + +#import +#import +#import + +#import + +#import "UIxMailRenderingContext.h" @implementation UIxMailRenderingContext static BOOL showNamedTextAttachmentsInline = NO; -- (id)initWithViewer:(WOComponent *)_viewer context:(WOContext *)_ctx { - if ((self = [super init])) { - self->viewer = _viewer; - self->context = _ctx; - } +- (id) initWithViewer: (WOComponent *) _viewer + context: (WOContext *) _ctx +{ + if ((self = [super init])) + { + viewer = _viewer; + context = _ctx; + } + return self; } -- (id)init { - return [self initWithViewer:nil context:nil]; + +- (id) init +{ + return [self initWithViewer: nil context: nil]; } -- (void)dealloc { - [self->iCalViewer release]; - [self->htmlViewer release]; - [self->textViewer release]; - [self->imageViewer release]; - [self->linkViewer release]; - [self->messageViewer release]; +- (void) dealloc +{ + [flatContents release]; + [iCalViewer release]; + [htmlViewer release]; + [textViewer release]; + [imageViewer release]; + [linkViewer release]; + [messageViewer release]; [super dealloc]; } -/* resetting state */ - -- (void)reset { - [self->flatContents release]; self->flatContents = nil; - [self->textViewer release]; self->textViewer = nil; - [self->htmlViewer release]; self->htmlViewer = nil; - [self->imageViewer release]; self->imageViewer = nil; - [self->linkViewer release]; self->linkViewer = nil; - [self->messageViewer release]; self->messageViewer = nil; - [self->iCalViewer release]; self->iCalViewer = nil; +- (void) reset +{ + [flatContents release]; + [iCalViewer release]; + [htmlViewer release]; + [textViewer release]; + [imageViewer release]; + [linkViewer release]; + [messageViewer release]; + + flatContents = nil; + iCalViewer = nil; + textViewer = nil; + imageViewer = nil; + htmlViewer = nil; + linkViewer = nil; + messageViewer = nil; } /* fetching */ -- (NSDictionary *)flatContents { - if (self->flatContents != nil) - return [self->flatContents isNotNull] ? self->flatContents : nil; - - self->flatContents = - [[[self->viewer clientObject] fetchPlainTextParts] retain]; - [self debugWithFormat:@"CON: %@", self->flatContents]; - return self->flatContents; +- (NSDictionary *) flatContents +{ + if (!flatContents) + { + flatContents = [[viewer clientObject] fetchPlainTextParts]; + [flatContents retain]; +// [self debugWithFormat:@"CON: %@", flatContents]; + } + + return flatContents; } -- (NSData *)flatContentForPartPath:(NSArray *)_partPath { +- (NSData *) flatContentForPartPath: (NSArray *) _partPath +{ NSString *pid; pid = _partPath ? [_partPath componentsJoinedByString:@"."] : @""; + return [[self flatContents] objectForKey:pid]; } /* viewer components */ -- (WOComponent *)mixedViewer { +- (WOComponent *) mixedViewer +{ /* Note: we cannot cache the multipart viewers, because it can be nested */ - return [self->viewer pageWithName:@"UIxMailPartMixedViewer"]; + return [viewer pageWithName: @"UIxMailPartMixedViewer"]; } -- (WOComponent *)signedViewer { +- (WOComponent *) signedViewer +{ /* Note: we cannot cache the multipart viewers, because it can be nested */ // TODO: temporary workaround (treat it like a plain mixed part) + return [self mixedViewer]; } -- (WOComponent *)alternativeViewer { +- (WOComponent *) alternativeViewer +{ /* Note: we cannot cache the multipart viewers, because it can be nested */ - return [self->viewer pageWithName:@"UIxMailPartAlternativeViewer"]; + return [viewer pageWithName: @"UIxMailPartAlternativeViewer"]; } -- (WOComponent *)textViewer { - if (self->textViewer == nil) { - self->textViewer = - [[self->viewer pageWithName:@"UIxMailPartTextViewer"] retain]; - } - return self->textViewer; +- (WOComponent *) textViewer +{ + if (!textViewer) + { + textViewer = [viewer pageWithName: @"UIxMailPartTextViewer"]; + [textViewer retain]; + } + + return textViewer; } -- (WOComponent *)imageViewer { - if (self->imageViewer == nil) { - self->imageViewer = - [[self->viewer pageWithName:@"UIxMailPartImageViewer"] retain]; - } - return self->imageViewer; +- (WOComponent *) imageViewer +{ + if (!imageViewer) + { + imageViewer = [viewer pageWithName: @"UIxMailPartImageViewer"]; + [imageViewer retain]; + } + + return imageViewer; } -- (WOComponent *)linkViewer { - if (self->linkViewer == nil) { - self->linkViewer = - [[self->viewer pageWithName:@"UIxMailPartLinkViewer"] retain]; - } - return self->linkViewer; +- (WOComponent *) linkViewer +{ + if (!linkViewer) + { + linkViewer = [viewer pageWithName: @"UIxMailPartLinkViewer"]; + [linkViewer retain]; + } + + return linkViewer; } -- (WOComponent *)htmlViewer { - if (self->htmlViewer == nil) { - self->htmlViewer = - [[self->viewer pageWithName:@"UIxMailPartHTMLViewer"] retain]; - } - return self->htmlViewer; +- (WOComponent *) htmlViewer +{ + if (!htmlViewer) + { + htmlViewer = [viewer pageWithName: @"UIxMailPartHTMLViewer"]; + [htmlViewer retain]; + } + + return htmlViewer; } -- (WOComponent *)messageViewer { - if (self->messageViewer == nil) { - self->messageViewer = - [[self->viewer pageWithName:@"UIxMailPartMessageViewer"] retain]; - } - return self->messageViewer; +- (WOComponent *) messageViewer +{ + if (!messageViewer) + { + messageViewer = [viewer pageWithName: @"UIxMailPartMessageViewer"]; + [messageViewer retain]; + } + + return messageViewer; } -- (WOComponent *)iCalViewer { - if (self->iCalViewer == nil) { - self->iCalViewer = - [[self->viewer pageWithName:@"UIxMailPartICalViewer"] retain]; - } - return self->iCalViewer; +- (WOComponent *) iCalViewer +{ + if (!iCalViewer) + { + iCalViewer = [viewer pageWithName: @"UIxMailPartICalViewer"]; + [iCalViewer retain]; + } + + return iCalViewer; } /* Kolab viewers */ -- (WOComponent *)kolabContactViewer { - return [self->viewer pageWithName:@"UIxKolabPartContactViewer"]; +- (WOComponent *) kolabContactViewer +{ + return [viewer pageWithName: @"UIxKolabPartContactViewer"]; } -- (WOComponent *)kolabEventViewer { - return [self->viewer pageWithName:@"UIxKolabPartEventViewer"]; + +- (WOComponent *) kolabEventViewer +{ + return [viewer pageWithName: @"UIxKolabPartEventViewer"]; } -- (WOComponent *)kolabTodoViewer { - return [self->viewer pageWithName:@"UIxKolabPartTodoViewer"]; + +- (WOComponent *) kolabTodoViewer +{ + return [viewer pageWithName: @"UIxKolabPartTodoViewer"]; } -- (WOComponent *)kolabNoteViewer { +- (WOComponent *) kolabNoteViewer +{ return [self textViewer]; // TODO } -- (WOComponent *)kolabJournalViewer { + +- (WOComponent *) kolabJournalViewer +{ return [self textViewer]; // TODO } -- (WOComponent *)kolabDistributionListViewer { + +- (WOComponent *) kolabDistributionListViewer +{ return [self textViewer]; // TODO } /* main viewer selection */ -- (WOComponent *)viewerForBodyInfo:(id)_info { +- (WOComponent *) viewerForBodyInfo: (id) _info +{ NSString *mt, *st; - mt = [[_info valueForKey:@"type"] lowercaseString]; + mt = [[_info valueForKey:@"type"] lowercaseString]; st = [[_info valueForKey:@"subtype"] lowercaseString]; - - if ([mt isEqualToString:@"multipart"]) { - if ([st isEqualToString:@"mixed"]) - return [self mixedViewer]; - else if ([st isEqualToString:@"signed"]) - return [self signedViewer]; - else if ([st isEqualToString:@"alternative"] + + if ([mt isEqualToString:@"multipart"]) + { + if ([st isEqualToString:@"mixed"]) + return [self mixedViewer]; + else if ([st isEqualToString:@"signed"]) + return [self signedViewer]; + else if ([st isEqualToString:@"alternative"] || [st isEqualToString:@"related"]) return [self alternativeViewer]; if ([st isEqualToString:@"report"]) /* this is used by mail-delivery reports */ return [self mixedViewer]; - } - else if ([mt isEqualToString:@"text"]) { + } + else if ([mt isEqualToString:@"text"]) + { /* Note: in the _info dictionary we do not get the content-disposition information (inline vs attachment). Our hack is to check for the @@ -236,37 +296,40 @@ static BOOL showNamedTextAttachmentsInline = NO; return [self linkViewer]; } - if ([mt isEqualToString:@"application"]) { - // octet-stream (generate download link?, autodetect type?) + if ([mt isEqualToString:@"application"]) + { + // octet-stream (generate download link?, autodetect type?) - if ([st hasPrefix:@"x-vnd.kolab."]) { - if ([st isEqualToString:@"x-vnd.kolab.contact"]) - return [self kolabContactViewer]; - if ([st isEqualToString:@"x-vnd.kolab.event"]) - return [self kolabEventViewer]; - if ([st isEqualToString:@"x-vnd.kolab.task"]) - return [self kolabTodoViewer]; - if ([st isEqualToString:@"x-vnd.kolab.note"]) - return [self kolabNoteViewer]; - if ([st isEqualToString:@"x-vnd.kolab.journal"]) - return [self kolabJournalViewer]; - if ([st isEqualToString:@"x-vnd.kolab.contact.distlist"]) - return [self kolabDistributionListViewer]; + if ([st hasPrefix:@"x-vnd.kolab."]) + { + if ([st isEqualToString:@"x-vnd.kolab.contact"]) + return [self kolabContactViewer]; + if ([st isEqualToString:@"x-vnd.kolab.event"]) + return [self kolabEventViewer]; + if ([st isEqualToString:@"x-vnd.kolab.task"]) + return [self kolabTodoViewer]; + if ([st isEqualToString:@"x-vnd.kolab.note"]) + return [self kolabNoteViewer]; + if ([st isEqualToString:@"x-vnd.kolab.journal"]) + return [self kolabJournalViewer]; + if ([st isEqualToString:@"x-vnd.kolab.contact.distlist"]) + return [self kolabDistributionListViewer]; - [self errorWithFormat:@"found no viewer for Kolab type: %@/%@", mt, st]; - return [self linkViewer]; - } + [self errorWithFormat:@"found no viewer for Kolab type: %@/%@", mt, st]; + return [self linkViewer]; + } #if 0 /* the link viewer looks better than plain text ;-) */ if ([st isEqualToString:@"pgp-signature"]) // TODO: real PGP viewer return [self textViewer]; #endif - } + } // TODO: always fallback to octet viewer?! #if 1 [self errorWithFormat:@"found no viewer for MIME type: %@/%@", mt, st]; #endif + return [self linkViewer]; } diff --git a/UI/MailPartViewers/product.plist b/UI/MailPartViewers/product.plist index 7bebf273..a042a538 100644 --- a/UI/MailPartViewers/product.plist +++ b/UI/MailPartViewers/product.plist @@ -1,5 +1,5 @@ { - requires = ( MAIN, MailerUI ); + requires = ( MAIN ); publicResources = ( ); diff --git a/UI/MailerUI/UIxMailEditor.m b/UI/MailerUI/UIxMailEditor.m index ffae1214..89d8cd2a 100644 --- a/UI/MailerUI/UIxMailEditor.m +++ b/UI/MailerUI/UIxMailEditor.m @@ -269,13 +269,16 @@ static NSArray *infoKeys = nil; /* requests */ -- (BOOL)shouldTakeValuesFromRequest:(WORequest *)_rq inContext:(WOContext*)_c{ +- (BOOL) shouldTakeValuesFromRequest: (WORequest *) _rq + inContext: (WOContext*) _c +{ return YES; } /* IMAP4 store */ -- (NSException *)patchFlagsInStore { +- (NSException *) patchFlagsInStore +{ /* Flags we should set: if the draft is a reply => [message markAnswered] @@ -286,7 +289,8 @@ static NSArray *infoKeys = nil; return nil; } -- (id)lookupSentFolderUsingAccount { +- (id) lookupSentFolderUsingAccount +{ SOGoMailAccount *account; SOGoMailFolder *folder; @@ -301,7 +305,8 @@ static NSArray *infoKeys = nil; return ((sentFolder = [folder retain])); } -- (void)_presetFromBasedOnAccountsQueryParameter { +- (void) _presetFromBasedOnAccountsQueryParameter +{ /* preset the from field to the primary identity of the given account */ /* Note: The compose action sets the 'accounts' query parameter */ NSString *accountID; @@ -337,7 +342,8 @@ static NSArray *infoKeys = nil; [self setFrom: [identity email]]; } -- (SOGoMailIdentity *)selectedMailIdentity { +- (SOGoMailIdentity *) selectedMailIdentity +{ SOGoMailAccounts *accounts; NSEnumerator *e; SOGoMailIdentity *identity; @@ -360,7 +366,8 @@ static NSArray *infoKeys = nil; return nil; } -- (id)lookupSentFolderUsingFrom { +- (id) lookupSentFolderUsingFrom +{ // TODO: if we have the identity we could also support BCC SOGoMailAccounts *accounts; SOGoMailIdentity *identity; @@ -410,7 +417,8 @@ static NSArray *infoKeys = nil; return sentFolder; } -- (NSException *)storeMailInSentFolder:(NSString *)_path { +- (NSException *) storeMailInSentFolder: (NSString *) _path +{ SOGoMailFolder *folder; NSData *data; id result; @@ -523,7 +531,8 @@ static NSArray *infoKeys = nil; return success; } -- (id)failedToSaveFormResponse { +- (id) failedToSaveFormResponse +{ // TODO: improve error handling return [NSException exceptionWithHTTPStatus:500 /* server error */ reason:@"failed to store draft object on server!"]; @@ -531,7 +540,8 @@ static NSArray *infoKeys = nil; /* attachment helper */ -- (NSArray *)attachmentNames { +- (NSArray *) attachmentNames +{ NSArray *a; if (attachmentNames != nil) @@ -542,7 +552,9 @@ static NSArray *infoKeys = nil; attachmentNames = [a copy]; return attachmentNames; } -- (BOOL)hasAttachments { + +- (BOOL) hasAttachments +{ return [[self attachmentNames] count] > 0 ? YES : NO; } @@ -558,11 +570,13 @@ static NSArray *infoKeys = nil; return self; } -- (id)saveAction { +- (id) saveAction +{ return [self _saveFormInfo] ? self : [self failedToSaveFormResponse]; } -- (NSException *)validateForSend { +- (NSException *) validateForSend +{ // TODO: localize errors if (![self hasOneOrMoreRecipients]) { @@ -646,7 +660,8 @@ static NSArray *infoKeys = nil; return result; } -- (id)deleteAction { +- (id) deleteAction +{ NSException *error; id page; diff --git a/UI/MailerUI/UIxMailEditorAction.m b/UI/MailerUI/UIxMailEditorAction.m index e61b788e..8fd8ed27 100644 --- a/UI/MailerUI/UIxMailEditorAction.m +++ b/UI/MailerUI/UIxMailEditorAction.m @@ -63,8 +63,8 @@ accountFolder = [[self clientObject] mailAccountFolder]; return [accountFolder - lookupName: [accountFolder draftsFolderNameInContext: context] - inContext: context acquire: NO]; + lookupName: [accountFolder draftsFolderNameInContext: context] + inContext: context acquire: NO]; } /* errors */ diff --git a/UI/MailerUI/UIxMailMainFrame.m b/UI/MailerUI/UIxMailMainFrame.m index 4c3e3bf2..95c64ca8 100644 --- a/UI/MailerUI/UIxMailMainFrame.m +++ b/UI/MailerUI/UIxMailMainFrame.m @@ -236,7 +236,7 @@ static NSString *treeRootClassName = nil; if (parameter) [urlParams setObject: parameter forKey: @"mailto"]; - inbox = [NSString stringWithFormat: @"%@/INBOX", + inbox = [NSString stringWithFormat: @"%@/folderINBOX", [c objectAtIndex: 0]]; url = [inbox composeURLWithAction: @"compose" parameters: urlParams diff --git a/UI/MailerUI/UIxMailView.m b/UI/MailerUI/UIxMailView.m index ecd299db..a8c01a0b 100644 --- a/UI/MailerUI/UIxMailView.m +++ b/UI/MailerUI/UIxMailView.m @@ -102,33 +102,39 @@ static NSString *mailETag = nil; /* links (DUP to UIxMailPartViewer!) */ -- (NSString *)linkToEnvelopeAddress:(NGImap4EnvelopeAddress *)_address { +- (NSString *) linkToEnvelopeAddress: (NGImap4EnvelopeAddress *) _address +{ // TODO: make some web-link, eg open a new compose panel? - return [@"mailto:" stringByAppendingString:[_address baseEMail]]; + return [NSString stringWithFormat: @"mailto: %@", [_address baseEMail]]; } -- (NSString *)currentAddressLink { +- (NSString *) currentAddressLink +{ return [self linkToEnvelopeAddress:[self currentAddress]]; } /* fetching */ -- (id)message { +- (id) message +{ return [[self clientObject] fetchCoreInfos]; } -- (BOOL)hasCC { +- (BOOL) hasCC +{ return [[[self clientObject] ccEnvelopeAddresses] count] > 0 ? YES : NO; } /* viewers */ -- (id)contentViewerComponent { +- (id) contentViewerComponent +{ // TODO: I would prefer to flatten the body structure prior rendering, // using some delegate to decide which parts to select for alternative. id info; info = [[self clientObject] bodyStructure]; + return [[context mailRenderingContext] viewerForBodyInfo:info]; } @@ -171,21 +177,27 @@ static NSString *mailETag = nil; return self; } -- (BOOL)isDeletableClientObject { - return [[self clientObject] respondsToSelector:@selector(delete)]; +- (BOOL) isDeletableClientObject +{ + return [[self clientObject] respondsToSelector: @selector (delete)]; } -- (BOOL)isInlineViewer { + +- (BOOL) isInlineViewer +{ return NO; } -- (id)redirectToParentFolder { +- (id) redirectToParentFolder +{ id url; - url = [[[self clientObject] container] baseURLInContext:context]; - return [self redirectToLocation:url]; + url = [[[self clientObject] container] baseURLInContext: context]; + + return [self redirectToLocation: url]; } -- (id)deleteAction { +- (id) deleteAction +{ NSException *ex; if (![self isDeletableClientObject]) { @@ -220,7 +232,8 @@ static NSString *mailETag = nil; return [self redirectToParentFolder]; } -- (id)trashAction { +- (id) trashAction +{ NSException *ex; if ([self isInvokedBySafeMethod]) { @@ -298,18 +311,21 @@ static NSString *mailETag = nil; /* generating response */ -- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { +- (void) appendToResponse: (WOResponse *) _response + inContext: (WOContext *) _ctx +{ UIxMailRenderingContext *mctx; if (mailETag != nil) [[_ctx response] setHeader:mailETag forKey:@"etag"]; - mctx = [[NSClassFromString(@"UIxMailRenderingContext") - alloc] initWithViewer:self context:_ctx]; - [_ctx pushMailRenderingContext:mctx]; + mctx = [[UIxMailRenderingContext alloc] initWithViewer: self + context: _ctx]; + + [_ctx pushMailRenderingContext: mctx]; [mctx release]; - - [super appendToResponse:_response inContext:_ctx]; + + [super appendToResponse: _response inContext: _ctx]; [[_ctx popMailRenderingContext] reset]; } diff --git a/UI/MailerUI/product.plist b/UI/MailerUI/product.plist index d8418c3a..8a3b1331 100644 --- a/UI/MailerUI/product.plist +++ b/UI/MailerUI/product.plist @@ -1,5 +1,5 @@ { /* -*-javascript-*- */ -requires = ( MAIN, MainUI, CommonUI, Mailer ); /* , Sieve */ +requires = ( MAIN, MainUI, CommonUI, Mailer, MailPartViewers ); /* , Sieve */ publicResources = ( "uix.css", diff --git a/UI/Templates/UIxPageFrame.wox b/UI/Templates/UIxPageFrame.wox index f1bd213e..b2b87f6a 100644 --- a/UI/Templates/UIxPageFrame.wox +++ b/UI/Templates/UIxPageFrame.wox @@ -57,6 +57,8 @@ + 0) - alert("Could not delete " + failCount + " messages!"); + if (failCount > 0) + alert("Could not delete " + failCount + " messages!"); - return false; + return false; } function moveMessages(rowIds, folder) { - var failCount = 0; + var failCount = 0; - for (var i = 0; i < rowIds.length; i++) { - var url, http; + for (var i = 0; i < rowIds.length; i++) { + var url, http; - /* send AJAX request (synchronously) */ + /* send AJAX request (synchronously) */ - var messageId = currentMailbox + "/" + rowIds[i]; - url = (ApplicationBaseURL + messageId - + "/move?jsonly=1&tofolder=" + folder); - http = createHTTPClient(); - http.open("GET", url, false /* not async */); - http.send(""); - if (http.status == 200) { - var row = $("row_" + rowIds[i]); - row.parentNode.removeChild(row); - deleteCachedMessage(messageId); - if (currentMessages[currentMailbox] == rowIds[i]) { - var div = $('messageContent'); - div.innerHTML = ""; - currentMessages[currentMailbox] = null; - } + var messageId = currentMailbox + "/" + rowIds[i]; + url = (ApplicationBaseURL + messageId + + "/move?jsonly=1&tofolder=" + folder); + http = createHTTPClient(); + http.open("GET", url, false /* not async */); + http.send(""); + if (http.status == 200) { + var row = $("row_" + rowIds[i]); + row.parentNode.removeChild(row); + deleteCachedMessage(messageId); + if (currentMessages[currentMailbox] == rowIds[i]) { + var div = $('messageContent'); + div.innerHTML = ""; + currentMessages[currentMailbox] = null; } - else /* request failed */ - failCount++; + } + else /* request failed */ + failCount++; - /* remove from page */ + /* remove from page */ - /* line-through would be nicer, but hiding is OK too */ - } + /* line-through would be nicer, but hiding is OK too */ + } - if (failCount > 0) - alert("Could not move " + failCount + " messages!"); + if (failCount > 0) + alert("Could not move " + failCount + " messages!"); - return failCount; + return failCount; } function onMenuDeleteMessage(event) { - uixDeleteSelectedMessages(); - preventDefault(event); + uixDeleteSelectedMessages(); + preventDefault(event); } function onMailboxTreeItemClick(event) { - var topNode = $("mailboxTree"); - var mailbox = this.parentNode.getAttribute("dataname"); - - if (topNode.selectedEntry) - topNode.selectedEntry.deselect(); - this.select(); - topNode.selectedEntry = this; - - search = {}; - sorting = {}; - $("searchValue").value = ""; - initCriteria(); - - var datatype = this.parentNode.getAttribute("datatype"); - if (datatype == "account" || datatype == "additional") { - currentMailbox = mailbox; - $("messageContent").innerHTML = ""; - var body = $("messageList").tBodies[0]; - for (var i = body.rows.length - 1; i > 0; i--) - body.deleteRow(i); - } - else - openMailbox(mailbox); + var topNode = $("mailboxTree"); + var mailbox = this.parentNode.getAttribute("dataname"); + + if (topNode.selectedEntry) + topNode.selectedEntry.deselect(); + this.select(); + topNode.selectedEntry = this; + + search = {}; + sorting = {}; + $("searchValue").value = ""; + initCriteria(); + + var datatype = this.parentNode.getAttribute("datatype"); + if (datatype == "account" || datatype == "additional") { + currentMailbox = mailbox; + $("messageContent").innerHTML = ""; + var body = $("messageList").tBodies[0]; + for (var i = body.rows.length - 1; i > 0; i--) + body.deleteRow(i); + } + else + openMailbox(mailbox); - preventDefault(event); + preventDefault(event); } function onMailboxMenuMove() { - window.alert("unimplemented"); + window.alert("unimplemented"); } function onMailboxMenuCopy() { - window.alert("unimplemented"); + window.alert("unimplemented"); } function refreshMailbox() { - var topWindow = getTopWindow(); - if (topWindow) - topWindow.refreshCurrentFolder(); + var topWindow = getTopWindow(); + if (topWindow) + topWindow.refreshCurrentFolder(); - return false; + return false; } function openMailbox(mailbox, reload, idx) { - if (mailbox != currentMailbox || reload) { - currentMailbox = mailbox; - var url = ApplicationBaseURL + mailbox + "/view?noframe=1"; - var messageContent = $("messageContent"); - messageContent.innerHTML = ''; - - if (currentMessages[mailbox]) { - loadMessage(currentMessages[mailbox]); - url += '&pageforuid=' + currentMessages[mailbox]; - } + if (mailbox != currentMailbox || reload) { + currentMailbox = mailbox; + var url = ApplicationBaseURL + mailbox + "/view?noframe=1"; + var messageContent = $("messageContent"); + messageContent.innerHTML = ''; + + if (currentMessages[mailbox]) { + loadMessage(currentMessages[mailbox]); + url += '&pageforuid=' + currentMessages[mailbox]; + } - var searchValue = search["value"]; - if (searchValue && searchValue.length > 0) - url += ("&search=" + search["criteria"] - + "&value=" + searchValue); - var sortAttribute = sorting["attribute"]; - if (sortAttribute && sortAttribute.length > 0) - url += ("&sort=" + sorting["attribute"] - + "&asc=" + sorting["ascending"]); - if (idx) - url += "&idx=" + idx; - - if (document.messageListAjaxRequest) { - document.messageListAjaxRequest.aborted = true; - document.messageListAjaxRequest.abort(); - } + var searchValue = search["value"]; + if (searchValue && searchValue.length > 0) + url += ("&search=" + search["criteria"] + + "&value=" + searchValue); + var sortAttribute = sorting["attribute"]; + if (sortAttribute && sortAttribute.length > 0) + url += ("&sort=" + sorting["attribute"] + + "&asc=" + sorting["ascending"]); + if (idx) + url += "&idx=" + idx; + + if (document.messageListAjaxRequest) { + document.messageListAjaxRequest.aborted = true; + document.messageListAjaxRequest.abort(); + } - var mailboxContent = $("mailboxContent"); - if (mailboxContent.getStyle('visibility') == "hidden") { - mailboxContent.setStyle({ visibility: "visible" }); - var rightDragHandle = $("rightDragHandle"); - rightDragHandle.setStyle({ visibility: "visible" }); - messageContent.setStyle({ top: (rightDragHandle.offsetTop - + rightDragHandle.offsetHeight - + 'px') }); - } + var mailboxContent = $("mailboxContent"); + if (mailboxContent.getStyle('visibility') == "hidden") { + mailboxContent.setStyle({ visibility: "visible" }); + var rightDragHandle = $("rightDragHandle"); + rightDragHandle.setStyle({ visibility: "visible" }); + messageContent.setStyle({ top: (rightDragHandle.offsetTop + + rightDragHandle.offsetHeight + + 'px') }); + } - document.messageListAjaxRequest - = triggerAjaxRequest(url, messageListCallback, - currentMessages[mailbox]); + document.messageListAjaxRequest + = triggerAjaxRequest(url, messageListCallback, + currentMessages[mailbox]); - var quotasUrl = ApplicationBaseURL + mailbox + "/quotas"; - document.quotasAjaxRequest - = triggerAjaxRequest(quotasUrl, quotasCallback); - } + var quotasUrl = ApplicationBaseURL + mailbox + "/quotas"; + document.quotasAjaxRequest + = triggerAjaxRequest(quotasUrl, quotasCallback); + } } function openMailboxAtIndex(event) { - openMailbox(currentMailbox, true, this.getAttribute("idx")); + openMailbox(currentMailbox, true, this.getAttribute("idx")); - preventDefault(event); + preventDefault(event); } function messageListCallback(http) { - var div = $('mailboxContent'); + var div = $('mailboxContent'); - if (http.readyState == 4 - && http.status == 200) { - document.messageListAjaxRequest = null; - div.innerHTML = http.responseText; - var selected = http.callbackData; - if (selected) { - var row = $("row_" + selected); - if (row) - row.select(); - } - configureMessageListEvents(); - if (sorting["attribute"] && sorting["attribute"].length > 0) { - var sortHeader; - if (sorting["attribute"] == "subject") - sortHeader = $("subjectHeader"); - else if (sorting["attribute"] == "from") - sortHeader = $("fromHeader"); - else if (sorting["attribute"] == "date") - sortHeader = $("dateHeader"); - else - sortHeader = null; - - if (sortHeader) { - var sortImage = createElement("img", "messageSortImage", "sortImage"); - sortHeader.insertBefore(sortImage, sortHeader.firstChild); - if (sorting["ascending"]) - sortImage.src = ResourcesURL + "/title_sortdown_12x12.png"; - else - sortImage.src = ResourcesURL + "/title_sortup_12x12.png"; - } + if (http.readyState == 4 + && http.status == 200) { + document.messageListAjaxRequest = null; + div.innerHTML = http.responseText; + var selected = http.callbackData; + if (selected) { + var row = $("row_" + selected); + if (row) + row.select(); + } + configureMessageListEvents(); + if (sorting["attribute"] && sorting["attribute"].length > 0) { + var sortHeader; + if (sorting["attribute"] == "subject") + sortHeader = $("subjectHeader"); + else if (sorting["attribute"] == "from") + sortHeader = $("fromHeader"); + else if (sorting["attribute"] == "date") + sortHeader = $("dateHeader"); + else + sortHeader = null; + + if (sortHeader) { + var sortImage = createElement("img", "messageSortImage", "sortImage"); + sortHeader.insertBefore(sortImage, sortHeader.firstChild); + if (sorting["ascending"]) + sortImage.src = ResourcesURL + "/title_sortdown_12x12.png"; + else + sortImage.src = ResourcesURL + "/title_sortup_12x12.png"; } - } - else - log("messageListCallback: problem during ajax request (readyState = " + http.readyState + ", status = " + http.status + ")"); + } + } + else + log("messageListCallback: problem during ajax request (readyState = " + http.readyState + ", status = " + http.status + ")"); } function quotasCallback(http) { @@ -482,243 +482,243 @@ function quotasCallback(http) { } function onMessageContextMenu(event) { - var menu = $('messageListMenu'); - Event.observe(menu, "hideMenu", onMessageContextMenuHide); - popupMenu(event, "messageListMenu", this); + var menu = $('messageListMenu'); + Event.observe(menu, "hideMenu", onMessageContextMenuHide); + popupMenu(event, "messageListMenu", this); - var topNode = $('messageList'); - var selectedNodes = topNode.getSelectedRows(); - for (var i = 0; i < selectedNodes.length; i++) - selectedNodes[i].deselect(); - topNode.menuSelectedRows = selectedNodes; - topNode.menuSelectedEntry = this; - this.select(); + var topNode = $('messageList'); + var selectedNodes = topNode.getSelectedRows(); + for (var i = 0; i < selectedNodes.length; i++) + selectedNodes[i].deselect(); + topNode.menuSelectedRows = selectedNodes; + topNode.menuSelectedEntry = this; + this.select(); } function onMessageContextMenuHide(event) { - var topNode = $('messageList'); + var topNode = $('messageList'); - if (topNode.menuSelectedEntry) { - topNode.menuSelectedEntry.deselect(); - topNode.menuSelectedEntry = null; - } - if (topNode.menuSelectedRows) { - var nodes = topNode.menuSelectedRows; - for (var i = 0; i < nodes.length; i++) - nodes[i].select(); - topNode.menuSelectedRows = null; - } + if (topNode.menuSelectedEntry) { + topNode.menuSelectedEntry.deselect(); + topNode.menuSelectedEntry = null; + } + if (topNode.menuSelectedRows) { + var nodes = topNode.menuSelectedRows; + for (var i = 0; i < nodes.length; i++) + nodes[i].select(); + topNode.menuSelectedRows = null; + } } function onFolderMenuClick(event) { - var onhide, menuName; + var onhide, menuName; - var menutype = this.parentNode.getAttribute("datatype"); - if (menutype) { - if (menutype == "inbox") { - menuName = "inboxIconMenu"; - } else if (menutype == "account") { - menuName = "accountIconMenu"; - } else if (menutype == "trash") { - menuName = "trashIconMenu"; - } else { - menuName = "mailboxIconMenu"; - } - } else { + var menutype = this.parentNode.getAttribute("datatype"); + if (menutype) { + if (menutype == "inbox") { + menuName = "inboxIconMenu"; + } else if (menutype == "account") { + menuName = "accountIconMenu"; + } else if (menutype == "trash") { + menuName = "trashIconMenu"; + } else { menuName = "mailboxIconMenu"; - } + } + } else { + menuName = "mailboxIconMenu"; + } - var menu = $(menuName); - Event.observe(menu, "hideMenu", onFolderMenuHide); - popupMenu(event, menuName, this.parentNode); + var menu = $(menuName); + Event.observe(menu, "hideMenu", onFolderMenuHide); + popupMenu(event, menuName, this.parentNode); - var topNode = $("mailboxTree"); - if (topNode.selectedEntry) - topNode.selectedEntry.deselect(); - if (topNode.menuSelectedEntry) - topNode.menuSelectedEntry.deselect(); - topNode.menuSelectedEntry = this; - this.select(); + var topNode = $("mailboxTree"); + if (topNode.selectedEntry) + topNode.selectedEntry.deselect(); + if (topNode.menuSelectedEntry) + topNode.menuSelectedEntry.deselect(); + topNode.menuSelectedEntry = this; + this.select(); - preventDefault(event); + preventDefault(event); } function onFolderMenuHide(event) { - var topNode = $("mailboxTree"); + var topNode = $("mailboxTree"); - if (topNode.menuSelectedEntry) { - topNode.menuSelectedEntry.deselect(); - topNode.menuSelectedEntry = null; - } - if (topNode.selectedEntry) - topNode.selectedEntry.select(); + if (topNode.menuSelectedEntry) { + topNode.menuSelectedEntry.deselect(); + topNode.menuSelectedEntry = null; + } + if (topNode.selectedEntry) + topNode.selectedEntry.select(); } function deleteCachedMessage(messageId) { - var done = false; - var counter = 0; - - while (counter < cachedMessages.length - && !done) - if (cachedMessages[counter] - && cachedMessages[counter]['idx'] == messageId) { - cachedMessages.splice(counter, 1); - done = true; - } - else - counter++; + var done = false; + var counter = 0; + + while (counter < cachedMessages.length + && !done) + if (cachedMessages[counter] + && cachedMessages[counter]['idx'] == messageId) { + cachedMessages.splice(counter, 1); + done = true; + } + else + counter++; } function getCachedMessage(idx) { - var message = null; - var counter = 0; - - while (counter < cachedMessages.length - && message == null) - if (cachedMessages[counter] - && cachedMessages[counter]['idx'] == currentMailbox + '/' + idx) - message = cachedMessages[counter]; - else - counter++; + var message = null; + var counter = 0; + + while (counter < cachedMessages.length + && message == null) + if (cachedMessages[counter] + && cachedMessages[counter]['idx'] == currentMailbox + '/' + idx) + message = cachedMessages[counter]; + else + counter++; - return message; + return message; } function storeCachedMessage(cachedMessage) { - var oldest = -1; - var timeOldest = -1; - var counter = 0; - - if (cachedMessages.length < maxCachedMessages) - oldest = cachedMessages.length; - else { - while (cachedMessages[counter]) { - if (oldest == -1 - || cachedMessages[counter]['time'] < timeOldest) { - oldest = counter; - timeOldest = cachedMessages[counter]['time']; - } - counter++; + var oldest = -1; + var timeOldest = -1; + var counter = 0; + + if (cachedMessages.length < maxCachedMessages) + oldest = cachedMessages.length; + else { + while (cachedMessages[counter]) { + if (oldest == -1 + || cachedMessages[counter]['time'] < timeOldest) { + oldest = counter; + timeOldest = cachedMessages[counter]['time']; } + counter++; + } - if (oldest == -1) - oldest = 0; - } + if (oldest == -1) + oldest = 0; + } - cachedMessages[oldest] = cachedMessage; + cachedMessages[oldest] = cachedMessage; } function onMessageSelectionChange() { - var rows = this.getSelectedRowsId(); + var rows = this.getSelectedRowsId(); - if (rows.length == 1) { - var idx = rows[0].substr(4); + if (rows.length == 1) { + var idx = rows[0].substr(4); - if (currentMessages[currentMailbox] != idx) { - currentMessages[currentMailbox] = idx; - loadMessage(idx); - } - } + if (currentMessages[currentMailbox] != idx) { + currentMessages[currentMailbox] = idx; + loadMessage(idx); + } + } } function loadMessage(idx) { - if (document.messageAjaxRequest) { - document.messageAjaxRequest.aborted = true; - document.messageAjaxRequest.abort(); - } - - var cachedMessage = getCachedMessage(idx); - - if (cachedMessage == null) { - var url = (ApplicationBaseURL + currentMailbox + "/" - + idx + "/view?noframe=1"); - document.messageAjaxRequest - = triggerAjaxRequest(url, messageCallback, idx); - markMailInWindow(window, idx, true); - } else { - var div = $('messageContent'); - div.innerHTML = cachedMessage['text']; - cachedMessage['time'] = (new Date()).getTime(); - document.messageAjaxRequest = null; - configureLinksInMessage(); - } + if (document.messageAjaxRequest) { + document.messageAjaxRequest.aborted = true; + document.messageAjaxRequest.abort(); + } + + var cachedMessage = getCachedMessage(idx); + + if (cachedMessage == null) { + var url = (ApplicationBaseURL + currentMailbox + "/" + + idx + "/view?noframe=1"); + document.messageAjaxRequest + = triggerAjaxRequest(url, messageCallback, idx); + markMailInWindow(window, idx, true); + } else { + var div = $('messageContent'); + div.innerHTML = cachedMessage['text']; + cachedMessage['time'] = (new Date()).getTime(); + document.messageAjaxRequest = null; + configureLinksInMessage(); + } } function configureLinksInMessage() { - var messageDiv = $('messageContent'); - var mailContentDiv = document.getElementsByClassName('mailer_mailcontent', - messageDiv)[0]; - Event.observe(mailContentDiv, "contextmenu", - onMessageContentMenu.bindAsEventListener(mailContentDiv)); - var anchors = messageDiv.getElementsByTagName('a'); - for (var i = 0; i < anchors.length; i++) - if (anchors[i].href.substring(0,7) == "mailto:") { - Event.observe(anchors[i], "click", - onEmailAddressClick.bindAsEventListener(anchors[i])); - Event.observe(anchors[i], "contextmenu", - onEmailAddressClick.bindAsEventListener(anchors[i])); - } - else - Event.observe(anchors[i], "click", - onMessageAnchorClick); + var messageDiv = $('messageContent'); + var mailContentDiv = document.getElementsByClassName('mailer_mailcontent', + messageDiv)[0]; + Event.observe(mailContentDiv, "contextmenu", + onMessageContentMenu.bindAsEventListener(mailContentDiv)); + var anchors = messageDiv.getElementsByTagName('a'); + for (var i = 0; i < anchors.length; i++) + if (anchors[i].href.substring(0,7) == "mailto:") { + Event.observe(anchors[i], "click", + onEmailAddressClick.bindAsEventListener(anchors[i])); + Event.observe(anchors[i], "contextmenu", + onEmailAddressClick.bindAsEventListener(anchors[i])); + } + else + Event.observe(anchors[i], "click", + onMessageAnchorClick); } function onMessageContentMenu(event) { - popupMenu(event, 'messageContentMenu', this); + popupMenu(event, 'messageContentMenu', this); } function onEmailAddressClick(event) { - popupMenu(event, 'addressMenu', this); + popupMenu(event, 'addressMenu', this); } function onMessageAnchorClick (event) { - window.open(this.href); - preventDefault(event); + window.open(this.href); + preventDefault(event); } function messageCallback(http) { - var div = $('messageContent'); + var div = $('messageContent'); - if (http.readyState == 4 - && http.status == 200) { - document.messageAjaxRequest = null; - div.innerHTML = http.responseText; - configureLinksInMessage(); + if (http.readyState == 4 + && http.status == 200) { + document.messageAjaxRequest = null; + div.innerHTML = http.responseText; + configureLinksInMessage(); - if (http.callbackData) { - var cachedMessage = new Array(); - cachedMessage['idx'] = currentMailbox + '/' + http.callbackData; - cachedMessage['time'] = (new Date()).getTime(); - cachedMessage['text'] = http.responseText; - if (cachedMessage['text'].length < 30000) - storeCachedMessage(cachedMessage); - } - } - else - log("messageCallback: problem during ajax request: " + http.status); + if (http.callbackData) { + var cachedMessage = new Array(); + cachedMessage['idx'] = currentMailbox + '/' + http.callbackData; + cachedMessage['time'] = (new Date()).getTime(); + cachedMessage['text'] = http.responseText; + if (cachedMessage['text'].length < 30000) + storeCachedMessage(cachedMessage); + } + } + else + log("messageCallback: problem during ajax request: " + http.status); } function processMailboxMenuAction(mailbox) { - var currentNode, upperNode; - var mailboxName; - var action; + var currentNode, upperNode; + var mailboxName; + var action; - mailboxName = mailbox.getAttribute('mailboxname'); - currentNode = mailbox; - upperNode = null; + mailboxName = mailbox.getAttribute('mailboxname'); + currentNode = mailbox; + upperNode = null; - while (currentNode - && !currentNode.hasAttribute('mailboxaction')) - currentNode = currentNode.parentNode.parentNode.parentMenuItem; + while (currentNode + && !currentNode.hasAttribute('mailboxaction')) + currentNode = currentNode.parentNode.parentNode.parentMenuItem; - if (currentNode) - { + if (currentNode) + { action = currentNode.getAttribute('mailboxaction'); // var rows = collectSelectedRows(); // var rString = rows.join(', '); // alert("performing '" + action + "' on " + rString - // + " to " + mailboxName); - } + // + " to " + mailboxName); + } } var rowSelectionCount = 0; @@ -726,28 +726,28 @@ var rowSelectionCount = 0; validateControls(); function showElement(e, shouldShow) { - e.style.display = shouldShow ? "" : "none"; + e.style.display = shouldShow ? "" : "none"; } function enableElement(e, shouldEnable) { - if(!e) - return; - if(shouldEnable) { - if(e.hasAttribute("disabled")) - e.removeAttribute("disabled"); - } - else { - e.setAttribute("disabled", "1"); - } + if(!e) + return; + if(shouldEnable) { + if(e.hasAttribute("disabled")) + e.removeAttribute("disabled"); + } + else { + e.setAttribute("disabled", "1"); + } } function validateControls() { - var e = $("moveto"); - this.enableElement(e, rowSelectionCount > 0); + var e = $("moveto"); + this.enableElement(e, rowSelectionCount > 0); } function moveTo(uri) { - alert("MoveTo: " + uri); + alert("MoveTo: " + uri); } function deleteSelectedMails() { @@ -755,273 +755,273 @@ function deleteSelectedMails() { /* message menu entries */ function onMenuOpenMessage(event) { - return openMessageWindowsForSelection('popupview'); + return openMessageWindowsForSelection('popupview'); } function onMenuReplyToSender(event) { - return openMessageWindowsForSelection('reply'); + return openMessageWindowsForSelection('reply'); } function onMenuReplyToAll(event) { - return openMessageWindowsForSelection('replyall'); + return openMessageWindowsForSelection('replyall'); } function onMenuForwardMessage(event) { - return openMessageWindowsForSelection('forward'); + return openMessageWindowsForSelection('forward'); } function onMenuViewMessageSource(event) { - var messageList = $("messageList"); - var rows = messageList.getSelectedRowsId(); - - if (rows.length > 0) { - var url = (ApplicationBaseURL + currentMailbox + "/" - + rows[0].substr(4) + "/viewsource"); - window.open(url, "", - "width=680,height=520,resizable=1,scrollbars=1,toolbar=0," - + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); - } + var messageList = $("messageList"); + var rows = messageList.getSelectedRowsId(); + + if (rows.length > 0) { + var url = (ApplicationBaseURL + currentMailbox + "/" + + rows[0].substr(4) + "/viewsource"); + window.open(url, "", + "width=680,height=520,resizable=1,scrollbars=1,toolbar=0," + + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); + } - preventDefault(event); + preventDefault(event); } /* contacts */ function newContactFromEmail(event) { - var mailto = document.menuTarget.innerHTML; + var mailto = document.menuTarget.innerHTML; - var email = extractEmailAddress(mailto); - var c_name = extractEmailName(mailto); - if (email.length > 0) - { + var email = extractEmailAddress(mailto); + var c_name = extractEmailName(mailto); + if (email.length > 0) + { var url = UserFolderURL + "Contacts/new?contactEmail=" + email; if (c_name) - url += "&contactFN=" + c_name; + url += "&contactFN=" + c_name; w = window.open(url, null, "width=546,height=490,resizable=1,scrollbars=1,toolbar=0," + "location=0,directories=0,status=0,menubar=0,copyhistory=0"); w.focus(); - } + } - return false; /* stop following the link */ + return false; /* stop following the link */ } function newEmailTo(sender) { - return openMailTo(document.menuTarget.innerHTML); + return openMailTo(document.menuTarget.innerHTML); } function expandUpperTree(node) { - var currentNode = node.parentNode; - - while (currentNode.className != "dtree") { - if (currentNode.className == 'clip') { - var id = currentNode.getAttribute("id"); - var number = parseInt(id.substr(2)); - if (number > 0) { - var cn = mailboxTree.aNodes[number]; - mailboxTree.nodeStatus(1, number, cn._ls); - } + var currentNode = node.parentNode; + + while (currentNode.className != "dtree") { + if (currentNode.className == 'clip') { + var id = currentNode.getAttribute("id"); + var number = parseInt(id.substr(2)); + if (number > 0) { + var cn = mailboxTree.aNodes[number]; + mailboxTree.nodeStatus(1, number, cn._ls); } - currentNode = currentNode.parentNode; - } + } + currentNode = currentNode.parentNode; + } } function onHeaderClick(event) { - var headerId = this.getAttribute("id"); - var newSortAttribute; - if (headerId == "subjectHeader") - newSortAttribute = "subject"; - else if (headerId == "fromHeader") - newSortAttribute = "from"; - else if (headerId == "dateHeader") - newSortAttribute = "date"; - else - newSortAttribute = "arrival"; - - if (sorting["attribute"] == newSortAttribute) - sorting["ascending"] = !sorting["ascending"]; - else { - sorting["attribute"] = newSortAttribute; - sorting["ascending"] = true; - } + var headerId = this.getAttribute("id"); + var newSortAttribute; + if (headerId == "subjectHeader") + newSortAttribute = "subject"; + else if (headerId == "fromHeader") + newSortAttribute = "from"; + else if (headerId == "dateHeader") + newSortAttribute = "date"; + else + newSortAttribute = "arrival"; + + if (sorting["attribute"] == newSortAttribute) + sorting["ascending"] = !sorting["ascending"]; + else { + sorting["attribute"] = newSortAttribute; + sorting["ascending"] = true; + } - refreshCurrentFolder(); + refreshCurrentFolder(); - preventDefault(event); + preventDefault(event); } function refreshCurrentFolder() { - openMailbox(currentMailbox, true); + openMailbox(currentMailbox, true); } function pouetpouet(event) { - window.alert("pouet pouet"); + window.alert("pouet pouet"); } var mailboxSpanAcceptType = function(type) { - return (type == "mailRow"); + return (type == "mailRow"); } var mailboxSpanEnter = function() { - this.addClassName("_dragOver"); + this.addClassName("_dragOver"); } var mailboxSpanExit = function() { - this.removeClassName("_dragOver"); + this.removeClassName("_dragOver"); } var mailboxSpanDrop = function(data) { - var success = false; - - if (data) { - var folder = this.parentNode.parentNode.getAttribute("dataname"); - if (folder != currentMailbox) - success = (moveMessages(data, folder) == 0); - } - else - success = false; + var success = false; - return success; + if (data) { + var folder = this.parentNode.parentNode.getAttribute("dataname"); + if (folder != currentMailbox) + success = (moveMessages(data, folder) == 0); + } + else + success = false; + + return success; } - + var plusSignEnter = function() { - var nodeNr = parseInt(this.id.substr(2)); - if (!mailboxTree.aNodes[nodeNr]._io) - this.plusSignTimer = setTimeout("openPlusSign('" + nodeNr + "');", 1000); + var nodeNr = parseInt(this.id.substr(2)); + if (!mailboxTree.aNodes[nodeNr]._io) + this.plusSignTimer = setTimeout("openPlusSign('" + nodeNr + "');", 1000); } - + var plusSignExit = function() { - if (this.plusSignTimer) { - clearTimeout(this.plusSignTimer); - this.plusSignTimer = null; - } + if (this.plusSignTimer) { + clearTimeout(this.plusSignTimer); + this.plusSignTimer = null; + } } - + function openPlusSign(nodeNr) { - mailboxTree.nodeStatus(1, nodeNr, mailboxTree.aNodes[nodeNr]._ls); - mailboxTree.aNodes[nodeNr]._io = 1; - this.plusSignTimer = null; + mailboxTree.nodeStatus(1, nodeNr, mailboxTree.aNodes[nodeNr]._ls); + mailboxTree.aNodes[nodeNr]._io = 1; + this.plusSignTimer = null; } var messageListGhost = function () { - var newDiv = document.createElement("div"); - // newDiv.style.width = "25px;"; - // newDiv.style.height = "25px;"; - newDiv.style.backgroundColor = "#aae;"; - newDiv.style.border = "2px solid #a3a;"; - newDiv.style.padding = "5px;"; - newDiv.ghostOffsetX = 10; - newDiv.ghostOffsetY = 5; + var newDiv = document.createElement("div"); + // newDiv.style.width = "25px;"; + // newDiv.style.height = "25px;"; + newDiv.style.backgroundColor = "#aae;"; + newDiv.style.border = "2px solid #a3a;"; + newDiv.style.padding = "5px;"; + newDiv.ghostOffsetX = 10; + newDiv.ghostOffsetY = 5; - var newImg = document.createElement("img"); - newImg.src = ResourcesURL + "/message-mail.png"; + var newImg = document.createElement("img"); + newImg.src = ResourcesURL + "/message-mail.png"; - var list = $("messageList"); - var count = list.getSelectedRows().length; - newDiv.appendChild(newImg); - newDiv.appendChild(document.createElement("br")); - newDiv.appendChild(document.createTextNode(count + " messages...")); + var list = $("messageList"); + var count = list.getSelectedRows().length; + newDiv.appendChild(newImg); + newDiv.appendChild(document.createElement("br")); + newDiv.appendChild(document.createTextNode(count + " messages...")); - return newDiv; + return newDiv; } var messageListData = function(type) { - var rows = this.parentNode.parentNode.getSelectedRowsId(); - var msgIds = new Array(); - for (var i = 0; i < rows.length; i++) - msgIds.push(rows[i].substr(4)); + var rows = this.parentNode.parentNode.getSelectedRowsId(); + var msgIds = new Array(); + for (var i = 0; i < rows.length; i++) + msgIds.push(rows[i].substr(4)); - return msgIds; + return msgIds; } /* a model for a futur refactoring of the sortable table headers mechanism */ function configureMessageListHeaders(cells) { - for (var i = 0; i < cells.length; i++) { - var currentCell = $(cells[i]); - Event.observe(currentCell, "click", - onHeaderClick.bindAsEventListener(currentCell)); - Event.observe(currentCell, "mousedown", listRowMouseDownHandler); - } + for (var i = 0; i < cells.length; i++) { + var currentCell = $(cells[i]); + Event.observe(currentCell, "click", + onHeaderClick.bindAsEventListener(currentCell)); + Event.observe(currentCell, "mousedown", listRowMouseDownHandler); + } } function configureMessageListEvents() { - var messageList = $("messageList"); - if (messageList) { - Event.observe(messageList, "mousedown", - onMessageSelectionChange.bindAsEventListener(messageList)); - - configureMessageListHeaders(messageList.tHead.rows[0].cells); - var cell = messageList.tHead.rows[1].cells[0]; - if ($(cell).hasClassName("tbtv_navcell")) { - var anchors = $(cell).childNodesWithTag("a"); - for (var i = 0; i < anchors.length; i++) - Event.observe(anchors[i], "click", openMailboxAtIndex.bindAsEventListener(anchors[i])); - } + var messageList = $("messageList"); + if (messageList) { + Event.observe(messageList, "mousedown", + onMessageSelectionChange.bindAsEventListener(messageList)); + + configureMessageListHeaders(messageList.tHead.rows[0].cells); + var cell = messageList.tHead.rows[1].cells[0]; + if ($(cell).hasClassName("tbtv_navcell")) { + var anchors = $(cell).childNodesWithTag("a"); + for (var i = 0; i < anchors.length; i++) + Event.observe(anchors[i], "click", openMailboxAtIndex.bindAsEventListener(anchors[i])); + } - rows = messageList.tBodies[0].rows; - for (var i = 0; i < rows.length; i++) { - Event.observe(rows[i], "mousedown", onRowClick); - Event.observe(rows[i], "contextmenu", onMessageContextMenu.bindAsEventListener(rows[i])); + rows = messageList.tBodies[0].rows; + for (var i = 0; i < rows.length; i++) { + Event.observe(rows[i], "mousedown", onRowClick); + Event.observe(rows[i], "contextmenu", onMessageContextMenu.bindAsEventListener(rows[i])); - rows[i].dndTypes = function() { return new Array("mailRow"); }; - rows[i].dndGhost = messageListGhost; - rows[i].dndDataForType = messageListData; - document.DNDManager.registerSource(rows[i]); - - for (var j = 0; j < rows[i].cells.length; j++) { - var cell = rows[i].cells[j]; - Event.observe(cell, "mousedown", listRowMouseDownHandler); - if (j == 2 || j == 3 || j == 5) - Event.observe(cell, "dblclick", onMessageDoubleClick.bindAsEventListener(cell)); - else if (j == 4) { - var img = cell.childNodesWithTag("img")[0]; - Event.observe(img, "click", mailListMarkMessage); - } - } + rows[i].dndTypes = function() { return new Array("mailRow"); }; + rows[i].dndGhost = messageListGhost; + rows[i].dndDataForType = messageListData; + document.DNDManager.registerSource(rows[i]); + + for (var j = 0; j < rows[i].cells.length; j++) { + var cell = rows[i].cells[j]; + Event.observe(cell, "mousedown", listRowMouseDownHandler); + if (j == 2 || j == 3 || j == 5) + Event.observe(cell, "dblclick", onMessageDoubleClick.bindAsEventListener(cell)); + else if (j == 4) { + var img = cell.childNodesWithTag("img")[0]; + Event.observe(img, "click", mailListMarkMessage); + } } - } + } + } } function configureDragHandles() { - var handle = $("verticalDragHandle"); - if (handle) { - handle.addInterface(SOGoDragHandlesInterface); - handle.leftBlock=$("leftPanel"); - handle.rightBlock=$("rightPanel"); - } + var handle = $("verticalDragHandle"); + if (handle) { + handle.addInterface(SOGoDragHandlesInterface); + handle.leftBlock=$("leftPanel"); + handle.rightBlock=$("rightPanel"); + } - handle = $("rightDragHandle"); - if (handle) { - handle.addInterface(SOGoDragHandlesInterface); - handle.upperBlock=$("mailboxContent"); - handle.lowerBlock=$("messageContent"); - } + handle = $("rightDragHandle"); + if (handle) { + handle.addInterface(SOGoDragHandlesInterface); + handle.upperBlock=$("mailboxContent"); + handle.lowerBlock=$("messageContent"); + } } /* dnd */ function initDnd() { - // log("MailerUI initDnd"); - - var tree = $("mailboxTree"); - if (tree) { - var images = tree.getElementsByTagName("img"); - for (var i = 0; i < images.length; i++) { - if (images[i].id[0] == 'j') { - images[i].dndAcceptType = mailboxSpanAcceptType; - images[i].dndEnter = plusSignEnter; - images[i].dndExit = plusSignExit; - document.DNDManager.registerDestination(images[i]); - } - } - var nodes = document.getElementsByClassName("nodeName", tree); - for (var i = 0; i < nodes.length; i++) { - nodes[i].dndAcceptType = mailboxSpanAcceptType; - nodes[i].dndEnter = mailboxSpanEnter; - nodes[i].dndExit = mailboxSpanExit; - nodes[i].dndDrop = mailboxSpanDrop; - document.DNDManager.registerDestination(nodes[i]); + // log("MailerUI initDnd"); + + var tree = $("mailboxTree"); + if (tree) { + var images = tree.getElementsByTagName("img"); + for (var i = 0; i < images.length; i++) { + if (images[i].id[0] == 'j') { + images[i].dndAcceptType = mailboxSpanAcceptType; + images[i].dndEnter = plusSignEnter; + images[i].dndExit = plusSignExit; + document.DNDManager.registerDestination(images[i]); } - } + } + var nodes = document.getElementsByClassName("nodeName", tree); + for (var i = 0; i < nodes.length; i++) { + nodes[i].dndAcceptType = mailboxSpanAcceptType; + nodes[i].dndEnter = mailboxSpanEnter; + nodes[i].dndExit = mailboxSpanExit; + nodes[i].dndDrop = mailboxSpanDrop; + document.DNDManager.registerDestination(nodes[i]); + } + } } /* stub */ @@ -1030,338 +1030,338 @@ function refreshContacts() { } function openInbox(node) { - var done = false; - openMailbox(node.parentNode.getAttribute("dataname")); - var tree = $("mailboxTree"); - tree.selectedEntry = node; - node.select(); - mailboxTree.o(1); + var done = false; + openMailbox(node.parentNode.getAttribute("dataname")); + var tree = $("mailboxTree"); + tree.selectedEntry = node; + node.select(); + mailboxTree.o(1); } function initMailer(event) { - if (!document.body.hasClassName("popup")) { - configureMessageListEvents(); - initDnd(); - currentMailbox = "/" + accounts[0] + "/INBOX"; - initMailboxTree(); - } + if (!document.body.hasClassName("popup")) { + configureMessageListEvents(); + initDnd(); + currentMailbox = "/" + accounts[0] + "/folderINBOX"; + initMailboxTree(); + } } function initMailboxTree() { - mailboxTree = new dTree("mailboxTree"); - mailboxTree.config.folderLinks = true; - mailboxTree.config.hideRoot = true; - - mailboxTree.icon.root = ResourcesURL + "/tbtv_account_17x17.gif"; - mailboxTree.icon.folder = ResourcesURL + "/tbtv_leaf_corner_17x17.gif"; - mailboxTree.icon.folderOpen = ResourcesURL + "/tbtv_leaf_corner_17x17.gif"; - mailboxTree.icon.node = ResourcesURL + "/tbtv_leaf_corner_17x17.gif"; - mailboxTree.icon.line = ResourcesURL + "/tbtv_line_17x17.gif"; - mailboxTree.icon.join = ResourcesURL + "/tbtv_junction_17x17.gif"; - mailboxTree.icon.joinBottom = ResourcesURL + "/tbtv_corner_17x17.gif"; - mailboxTree.icon.plus = ResourcesURL + "/tbtv_plus_17x17.gif"; - mailboxTree.icon.plusBottom = ResourcesURL + "/tbtv_corner_plus_17x17.gif"; - mailboxTree.icon.minus = ResourcesURL + "/tbtv_minus_17x17.gif"; - mailboxTree.icon.minusBottom = ResourcesURL + "/tbtv_corner_minus_17x17.gif"; - mailboxTree.icon.nlPlus = ResourcesURL + "/tbtv_corner_plus_17x17.gif"; - mailboxTree.icon.nlMinus = ResourcesURL + "/tbtv_corner_minus_17x17.gif"; - mailboxTree.icon.empty = ResourcesURL + "/empty.gif"; - - mailboxTree.add(0, -1, ''); - - mailboxTree.pendingRequests = mailAccounts.length; - for (var i = 0; i < mailAccounts.length; i++) { - var url = ApplicationBaseURL + "/" + mailAccounts[i] + "/mailboxes"; - triggerAjaxRequest(url, onLoadMailboxesCallback, mailAccounts[i]); - } + mailboxTree = new dTree("mailboxTree"); + mailboxTree.config.folderLinks = true; + mailboxTree.config.hideRoot = true; + + mailboxTree.icon.root = ResourcesURL + "/tbtv_account_17x17.gif"; + mailboxTree.icon.folder = ResourcesURL + "/tbtv_leaf_corner_17x17.gif"; + mailboxTree.icon.folderOpen = ResourcesURL + "/tbtv_leaf_corner_17x17.gif"; + mailboxTree.icon.node = ResourcesURL + "/tbtv_leaf_corner_17x17.gif"; + mailboxTree.icon.line = ResourcesURL + "/tbtv_line_17x17.gif"; + mailboxTree.icon.join = ResourcesURL + "/tbtv_junction_17x17.gif"; + mailboxTree.icon.joinBottom = ResourcesURL + "/tbtv_corner_17x17.gif"; + mailboxTree.icon.plus = ResourcesURL + "/tbtv_plus_17x17.gif"; + mailboxTree.icon.plusBottom = ResourcesURL + "/tbtv_corner_plus_17x17.gif"; + mailboxTree.icon.minus = ResourcesURL + "/tbtv_minus_17x17.gif"; + mailboxTree.icon.minusBottom = ResourcesURL + "/tbtv_corner_minus_17x17.gif"; + mailboxTree.icon.nlPlus = ResourcesURL + "/tbtv_corner_plus_17x17.gif"; + mailboxTree.icon.nlMinus = ResourcesURL + "/tbtv_corner_minus_17x17.gif"; + mailboxTree.icon.empty = ResourcesURL + "/empty.gif"; + + mailboxTree.add(0, -1, ''); + + mailboxTree.pendingRequests = mailAccounts.length; + for (var i = 0; i < mailAccounts.length; i++) { + var url = ApplicationBaseURL + "/" + mailAccounts[i] + "/mailboxes"; + triggerAjaxRequest(url, onLoadMailboxesCallback, mailAccounts[i]); + } } function updateMailboxTreeInPage() { - $("folderTreeContent").innerHTML = mailboxTree; - - var inboxFound = false; - var tree = $("mailboxTree"); - var nodes = document.getElementsByClassName("node", tree); - for (i = 0; i < nodes.length; i++) { - Event.observe(nodes[i], "click", onMailboxTreeItemClick.bindAsEventListener(nodes[i])); - Event.observe(nodes[i], "contextmenu", onFolderMenuClick.bindAsEventListener(nodes[i])); - if (!inboxFound - && nodes[i].parentNode.getAttribute("datatype") == "inbox") { - openInbox(nodes[i]); - inboxFound = true; - } - } + $("folderTreeContent").innerHTML = mailboxTree; + + var inboxFound = false; + var tree = $("mailboxTree"); + var nodes = document.getElementsByClassName("node", tree); + for (i = 0; i < nodes.length; i++) { + Event.observe(nodes[i], "click", onMailboxTreeItemClick.bindAsEventListener(nodes[i])); + Event.observe(nodes[i], "contextmenu", onFolderMenuClick.bindAsEventListener(nodes[i])); + if (!inboxFound + && nodes[i].parentNode.getAttribute("datatype") == "inbox") { + openInbox(nodes[i]); + inboxFound = true; + } + } } function mailboxMenuNode(type, name) { - var newNode = document.createElement("li"); - var icon = MailerUIdTreeExtension.folderIcons[type]; - if (!icon) - icon = "tbtv_leaf_corner_17x17.gif"; - var image = document.createElement("img"); - image.src = ResourcesURL + "/" + icon; - newNode.appendChild(image); - newNode.appendChild(document.createTextNode(" " + name)); + var newNode = document.createElement("li"); + var icon = MailerUIdTreeExtension.folderIcons[type]; + if (!icon) + icon = "tbtv_leaf_corner_17x17.gif"; + var image = document.createElement("img"); + image.src = ResourcesURL + "/" + icon; + newNode.appendChild(image); + newNode.appendChild(document.createTextNode(" " + name)); - return newNode; + return newNode; } function generateMenuForMailbox(mailbox, prefix, callback) { - var menuDIV = document.createElement("div"); - $(menuDIV).addClassName("menu"); - menuDIV.setAttribute("id", prefix + "Submenu"); - var menu = document.createElement("ul"); - menuDIV.appendChild(menu); - - var callbacks = new Array(); - if (mailbox.type != "account") { - var newNode = document.createElement("li"); - newNode.mailbox = mailbox; - newNode.appendChild(document.createTextNode("coucou")); - menu.appendChild(newNode); - menu.appendChild(document.createElement("li")); + var menuDIV = document.createElement("div"); + $(menuDIV).addClassName("menu"); + menuDIV.setAttribute("id", prefix + "Submenu"); + var menu = document.createElement("ul"); + menuDIV.appendChild(menu); + + var callbacks = new Array(); + if (mailbox.type != "account") { + var newNode = document.createElement("li"); + newNode.mailbox = mailbox; + newNode.appendChild(document.createTextNode("coucou")); + menu.appendChild(newNode); + menu.appendChild(document.createElement("li")); + callbacks.push(callback); + callbacks.push("-"); + } + + var submenuCount = 0; + for (var i = 0; i < mailbox.children.length; i++) { + var child = mailbox.children[i]; + var newNode = mailboxMenuNode(child.type, child.name); + menu.appendChild(newNode); + if (child.children.length > 0) { + var newPrefix = prefix + submenuCount; + var newSubmenu = generateMenuForMailbox(child, + newPrefix, + callback); + document.body.appendChild(newSubmenu); + callbacks.push(newPrefix + "Submenu"); + submenuCount++; + } + else { + newNode.mailbox = child; callbacks.push(callback); - callbacks.push("-"); - } - - var submenuCount = 0; - for (var i = 0; i < mailbox.children.length; i++) { - var child = mailbox.children[i]; - var newNode = mailboxMenuNode(child.type, child.name); - menu.appendChild(newNode); - if (child.children.length > 0) { - var newPrefix = prefix + submenuCount; - var newSubmenu = generateMenuForMailbox(child, - newPrefix, - callback); - document.body.appendChild(newSubmenu); - callbacks.push(newPrefix + "Submenu"); - submenuCount++; - } - else { - newNode.mailbox = child; - callbacks.push(callback); - } - } - initMenu(menuDIV, callbacks); + } + } + initMenu(menuDIV, callbacks); - return menuDIV; + return menuDIV; } function updateMailboxMenus() { - var mailboxActions = { move: onMailboxMenuMove, - copy: onMailboxMenuCopy }; + var mailboxActions = { move: onMailboxMenuMove, + copy: onMailboxMenuCopy }; - for (key in mailboxActions) { - var menuId = key + "MailboxMenu"; - var menuDIV = $(menuId); - if (menuDIV) - menuDIV.parentNode.removeChild(menuDIV); + for (key in mailboxActions) { + var menuId = key + "MailboxMenu"; + var menuDIV = $(menuId); + if (menuDIV) + menuDIV.parentNode.removeChild(menuDIV); - menuDIV = document.createElement("div"); - document.body.appendChild(menuDIV); + menuDIV = document.createElement("div"); + document.body.appendChild(menuDIV); - var menu = document.createElement("ul"); - menuDIV.appendChild(menu); + var menu = document.createElement("ul"); + menuDIV.appendChild(menu); - $(menuDIV).addClassName("menu"); - menuDIV.setAttribute("id", menuId); + $(menuDIV).addClassName("menu"); + menuDIV.setAttribute("id", menuId); - var submenuIds = new Array(); - for (var i = 0; i < mailAccounts.length; i++) { - var menuEntry = mailboxMenuNode("account", mailAccounts[i]); - menu.appendChild(menuEntry); - var mailbox = accounts[mailAccounts[i]]; - var newSubmenu = generateMenuForMailbox(mailbox, - key, mailboxActions[key]); - document.body.appendChild(newSubmenu); - submenuIds.push(newSubmenu.getAttribute("id")); - } - initMenu(menuDIV, submenuIds); - } + var submenuIds = new Array(); + for (var i = 0; i < mailAccounts.length; i++) { + var menuEntry = mailboxMenuNode("account", mailAccounts[i]); + menu.appendChild(menuEntry); + var mailbox = accounts[mailAccounts[i]]; + var newSubmenu = generateMenuForMailbox(mailbox, + key, mailboxActions[key]); + document.body.appendChild(newSubmenu); + submenuIds.push(newSubmenu.getAttribute("id")); + } + initMenu(menuDIV, submenuIds); + } } function onLoadMailboxesCallback(http) { - if (http.readyState == 4 - && http.status == 200) { - var newAccount = buildMailboxes(http.callbackData, - http.responseText); - accounts[http.callbackData] = newAccount; - mailboxTree.addMailAccount(newAccount); - mailboxTree.pendingRequests--; - if (!mailboxTree.pendingRequests) { - updateMailboxTreeInPage(); - updateMailboxMenus(); - } + if (http.readyState == 4 + && http.status == 200) { + var newAccount = buildMailboxes(http.callbackData, + http.responseText); + accounts[http.callbackData] = newAccount; + mailboxTree.addMailAccount(newAccount); + mailboxTree.pendingRequests--; + if (!mailboxTree.pendingRequests) { + updateMailboxTreeInPage(); + updateMailboxMenus(); + } } -// var tree = $("mailboxTree"); -// var treeNodes = document.getElementsByClassName("dTreeNode", tree); -// var i = 0; -// while (i < treeNodes.length -// && treeNodes[i].getAttribute("dataname") != currentMailbox) -// i++; -// if (i < treeNodes.length) { -// // log("found mailbox"); -// var links = document.getElementsByClassName("node", treeNodes[i]); -// if (tree.selectedEntry) -// tree.selectedEntry.deselect(); -// links[0].select(); -// tree.selectedEntry = links[0]; -// expandUpperTree(links[0]); -// } + // var tree = $("mailboxTree"); + // var treeNodes = document.getElementsByClassName("dTreeNode", tree); + // var i = 0; + // while (i < treeNodes.length + // && treeNodes[i].getAttribute("dataname") != currentMailbox) + // i++; + // if (i < treeNodes.length) { + // // log("found mailbox"); + // var links = document.getElementsByClassName("node", treeNodes[i]); + // if (tree.selectedEntry) + // tree.selectedEntry.deselect(); + // links[0].select(); + // tree.selectedEntry = links[0]; + // expandUpperTree(links[0]); + // } } function buildMailboxes(accountName, encoded) { - var account = new Mailbox("account", accountName); - var data = encoded.evalJSON(true); - for (var i = 0; i < data.length; i++) { - var currentNode = account; - var names = data[i].path.split("/"); - for (var j = 1; j < (names.length - 1); j++) { - var node = currentNode.findMailboxByName(names[j]); - if (!node) { - node = new Mailbox("additional", names[j]); - currentNode.addMailbox(node); - } - currentNode = node; + var account = new Mailbox("account", accountName); + var data = encoded.evalJSON(true); + for (var i = 0; i < data.length; i++) { + var currentNode = account; + var names = data[i].path.split("/"); + for (var j = 1; j < (names.length - 1); j++) { + var node = currentNode.findMailboxByName(names[j]); + if (!node) { + node = new Mailbox("additional", names[j]); + currentNode.addMailbox(node); } - var basename = names[names.length-1]; - var leaf = currentNode.findMailboxByName(basename); - if (leaf) - leaf.type = data[i].type; - else { - leaf = new Mailbox(data[i].type, basename); - currentNode.addMailbox(leaf); - } - } + currentNode = node; + } + var basename = names[names.length-1]; + var leaf = currentNode.findMailboxByName(basename); + if (leaf) + leaf.type = data[i].type; + else { + leaf = new Mailbox(data[i].type, basename); + currentNode.addMailbox(leaf); + } + } - return account; + return account; } function onMenuCreateFolder(event) { - var name = window.prompt(labels["Name :"].decodeEntities(), ""); - if (name && name.length > 0) { - var folderID = document.menuTarget.getAttribute("dataname"); - var urlstr = URLForFolderID(folderID) + "/createFolder?name=" + name; - triggerAjaxRequest(urlstr, folderOperationCallback); - } + var name = window.prompt(labels["Name :"].decodeEntities(), ""); + if (name && name.length > 0) { + var folderID = document.menuTarget.getAttribute("dataname"); + var urlstr = URLForFolderID(folderID) + "/createFolder?name=" + name; + triggerAjaxRequest(urlstr, folderOperationCallback); + } } function onMenuRenameFolder(event) { - var name = window.prompt(labels["Enter the new name of your folder :"] - .decodeEntities(), - ""); - if (name && name.length > 0) { - var folderID = document.menuTarget.getAttribute("dataname"); - var urlstr = URLForFolderID(folderID) + "/renameFolder?name=" + name; - triggerAjaxRequest(urlstr, folderOperationCallback); - } + var name = window.prompt(labels["Enter the new name of your folder :"] + .decodeEntities(), + ""); + if (name && name.length > 0) { + var folderID = document.menuTarget.getAttribute("dataname"); + var urlstr = URLForFolderID(folderID) + "/renameFolder?name=" + name; + triggerAjaxRequest(urlstr, folderOperationCallback); + } } function onMenuDeleteFolder(event) { - var answer = window.confirm(labels["Do you really want to move this folder into the trash ?"].decodeEntities()); - if (answer) { - var folderID = document.menuTarget.getAttribute("dataname"); - var urlstr = URLForFolderID(folderID) + "/deleteFolder"; - triggerAjaxRequest(urlstr, folderOperationCallback); - } + var answer = window.confirm(labels["Do you really want to move this folder into the trash ?"].decodeEntities()); + if (answer) { + var folderID = document.menuTarget.getAttribute("dataname"); + var urlstr = URLForFolderID(folderID) + "/deleteFolder"; + triggerAjaxRequest(urlstr, folderOperationCallback); + } } function onMenuEmptyTrash(event) { - var folderID = document.menuTarget.getAttribute("dataname"); - var urlstr = URLForFolderID(folderID) + "/emptyTrash"; - triggerAjaxRequest(urlstr, folderOperationCallback); + var folderID = document.menuTarget.getAttribute("dataname"); + var urlstr = URLForFolderID(folderID) + "/emptyTrash"; + triggerAjaxRequest(urlstr, folderOperationCallback); } function folderOperationCallback(http) { - if (http.readyState == 4 - && http.status == 204) - initMailboxTree(); - else - window.alert(labels["Operation failed"].decodeEntities()); + if (http.readyState == 4 + && http.status == 204) + initMailboxTree(); + else + window.alert(labels["Operation failed"].decodeEntities()); } function getMenus() { - var menus = {} - menus["accountIconMenu"] = new Array(null, null, onMenuCreateFolder, null, - null, null); - menus["inboxIconMenu"] = new Array(null, null, null, "-", null, - onMenuCreateFolder, null, "-", null, - onMenuSharing); - menus["trashIconMenu"] = new Array(null, null, null, "-", null, - onMenuCreateFolder, null, - onMenuEmptyTrash, "-", null, - onMenuSharing); - menus["mailboxIconMenu"] = new Array(null, null, null, "-", null, - onMenuCreateFolder, - onMenuRenameFolder, - null, onMenuDeleteFolder, "-", null, - onMenuSharing); - menus["addressMenu"] = new Array(newContactFromEmail, newEmailTo, null); - menus["messageListMenu"] = new Array(onMenuOpenMessage, "-", - onMenuReplyToSender, - onMenuReplyToAll, - onMenuForwardMessage, null, - "-", "moveMailboxMenu", - "copyMailboxMenu", "label-menu", - "mark-menu", "-", null, - onMenuViewMessageSource, null, - null, onMenuDeleteMessage); - menus["messageContentMenu"] = new Array(onMenuReplyToSender, - onMenuReplyToAll, - onMenuForwardMessage, - null, "moveMailboxMenu", - "copyMailboxMenu", - "-", "label-menu", "mark-menu", - "-", - null, onMenuViewMessageSource, - null, null, - onMenuDeleteMessage); - menus["label-menu"] = new Array(null, "-", null , null, null, null , null, - null); - menus["mark-menu"] = new Array(null, null, null, null, "-", null, "-", - null, null, null); - menus["searchMenu"] = new Array(setSearchCriteria, setSearchCriteria, - setSearchCriteria, setSearchCriteria, - setSearchCriteria); - - return menus; + var menus = {} + menus["accountIconMenu"] = new Array(null, null, onMenuCreateFolder, null, + null, null); + menus["inboxIconMenu"] = new Array(null, null, null, "-", null, + onMenuCreateFolder, null, "-", null, + onMenuSharing); + menus["trashIconMenu"] = new Array(null, null, null, "-", null, + onMenuCreateFolder, null, + onMenuEmptyTrash, "-", null, + onMenuSharing); + menus["mailboxIconMenu"] = new Array(null, null, null, "-", null, + onMenuCreateFolder, + onMenuRenameFolder, + null, onMenuDeleteFolder, "-", null, + onMenuSharing); + menus["addressMenu"] = new Array(newContactFromEmail, newEmailTo, null); + menus["messageListMenu"] = new Array(onMenuOpenMessage, "-", + onMenuReplyToSender, + onMenuReplyToAll, + onMenuForwardMessage, null, + "-", "moveMailboxMenu", + "copyMailboxMenu", "label-menu", + "mark-menu", "-", null, + onMenuViewMessageSource, null, + null, onMenuDeleteMessage); + menus["messageContentMenu"] = new Array(onMenuReplyToSender, + onMenuReplyToAll, + onMenuForwardMessage, + null, "moveMailboxMenu", + "copyMailboxMenu", + "-", "label-menu", "mark-menu", + "-", + null, onMenuViewMessageSource, + null, null, + onMenuDeleteMessage); + menus["label-menu"] = new Array(null, "-", null , null, null, null , null, + null); + menus["mark-menu"] = new Array(null, null, null, null, "-", null, "-", + null, null, null); + menus["searchMenu"] = new Array(setSearchCriteria, setSearchCriteria, + setSearchCriteria, setSearchCriteria, + setSearchCriteria); + + return menus; } addEvent(window, 'load', initMailer); function Mailbox(type, name) { - this.type = type; - this.name = name; - this.parentFolder = null; - this.children = new Array(); - return this; + this.type = type; + this.name = name; + this.parentFolder = null; + this.children = new Array(); + return this; } Mailbox.prototype.dump = function(indent) { - if (!indent) - indent = 0; - log(" ".repeat(indent) + this.name); - for (var i = 0; i < this.children.length; i++) { - this.children[i].dump(indent + 2); - } + if (!indent) + indent = 0; + log(" ".repeat(indent) + this.name); + for (var i = 0; i < this.children.length; i++) { + this.children[i].dump(indent + 2); + } } Mailbox.prototype.findMailboxByName = function(name) { - var mailbox = null; + var mailbox = null; - var i = 0; - while (!mailbox && i 1) { var parentNode = nodes[0]; var userInfos = parentNode.split(":"); @@ -41,7 +41,7 @@ function addLineToTree(tree, parent, line) { offset = nodes.length - 1; } else - window.alert("nope:" + window.userFolderType); + window.alert("nope:" + window.opener.userFolderType); return offset; } @@ -95,19 +95,18 @@ function userFoldersCallback(http) { div.innerHTML = buildTree(http.responseText); var nodes = document.getElementsByClassName("node", $("d")); for (i = 0; i < nodes.length; i++) - nodes[i].addEventListener("click", - onFolderTreeItemClick, false); + Event.observe(nodes[i], "click", onFolderTreeItemClick.bindAsEventListener(nodes[i])); } } } function onConfirmFolderSelection(event) { - var topNode = $("d"); - if (topNode.selectedEntry) { + var topNode = $("d"); + if (topNode.selectedEntry) { var node = topNode.selectedEntry.parentNode; var folder = node.getAttribute("dataname"); var folderName; - if (window.userFolderType == "user") { + if (window.opener.userFolderType == "user") { var spans = document.getElementsByClassName("nodeName", topNode.selectedEntry); var email = spans[0].innerHTML; @@ -125,14 +124,14 @@ function onConfirmFolderSelection(event) { email = email.replace(">", ">"); folderName = spans1[0].innerHTML + ' (' + email + ')'; } - var data = { folderName: folderName, folder: folder }; - window.opener.subscribeToFolder(window.userFolderCallback, data); + var data = { folderName: folderName, folder: folder, window: window }; + window.opener.subscribeToFolder(window.opener.userFolderCallback, data); } } function initUserFoldersWindow() { configureSearchField(); - $("addButton").addEventListener("click", onConfirmFolderSelection, false); + Event.observe($("addButton"), "click", onConfirmFolderSelection); } -window.addEventListener("load", initUserFoldersWindow, false); +addEvent(window, 'load', initUserFoldersWindow); diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index 18845795..7c5aa1bd 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -201,14 +201,14 @@ function sanitizeMailTo(dirtyMailTo) { function openUserFolderSelector(callback, type) { var urlstr = ApplicationBaseURL; - if (urlstr[urlstr.length-1] != '/') + if (! urlstr.endsWith('/')) urlstr += '/'; urlstr += ("../../" + UserLogin + "/Contacts/userFolders"); - var w = window.open(urlstr, "User Selector", + var w = window.open(urlstr, "_blank", "width=322,height=250,resizable=1,scrollbars=0"); w.opener = window; - w.userFolderCallback = callback; - w.userFolderType = type; + window.userFolderCallback = callback; + window.userFolderType = type; w.focus(); } @@ -862,7 +862,7 @@ function onSearchKeyDown(event) { this.timer = setTimeout("onSearchFormSubmit()", 1000); } -function onSearchFormSubmit(event) { +function onSearchFormSubmit(event) { log("generic.onSearchFormSubmit") var searchValue = $("searchValue"); var searchCriteria = $("searchCriteria"); @@ -895,9 +895,9 @@ function popupToolbarMenu(node, menuId) { hideMenu(document.currentPopupMenu); var popup = $(menuId); - var top = node.top + node.offsetHeight - 2; + var top = ($(node).getStyle('top') || 0) + node.offsetHeight - 2; popup.setStyle({ top: top + "px", - left: node.cascadeLeftOffset() + "px", + left: $(node).cascadeLeftOffset() + "px", visibility: "visible" }); document.currentPopupMenu = popup; @@ -913,11 +913,11 @@ function folderSubscriptionCallback(http) { http.callbackData["method"](http.callbackData["data"]); } else - window.alert(labels["Unable to subscribe to that folder!"].decodeEntities()); + window.alert(clabels["Unable to subscribe to that folder!"].decodeEntities()); document.subscriptionAjaxRequest = null; } else - log ("ajax fuckage"); + log ("folderSubscriptionCallback Ajax error"); } function subscribeToFolder(refreshCallback, refreshCallbackData) { @@ -937,7 +937,7 @@ function subscribeToFolder(refreshCallback, refreshCallbackData) { rfCbData); } else - window.alert(labels["You cannot subscribe to a folder that you own!"] + refreshCallbackData["window"].alert(clabels["You cannot subscribe to a folder that you own!"] .decodeEntities()); } @@ -948,7 +948,7 @@ function folderUnsubscriptionCallback(http) { http.callbackData["method"](http.callbackData["data"]); } else - window.alert(labels["Unable to unsubscribe from that folder!"].decodeEntities()); + window.alert(clabels["Unable to unsubscribe from that folder!"].decodeEntities()); document.unsubscriptionAjaxRequest = null; } } @@ -975,7 +975,7 @@ function unsubscribeFromFolder(folder, refreshCallback, refreshCallbackData) { rfCbData); } else - window.alert(labels["You cannot unsubscribe from a folder that you own!"].decodeEntities()); + window.alert(clabels["You cannot unsubscribe from a folder that you own!"].decodeEntities()); } } diff --git a/UI/WebServerResources/prototype.js b/UI/WebServerResources/prototype.js index 5d2100fa..a3f21ac7 100644 --- a/UI/WebServerResources/prototype.js +++ b/UI/WebServerResources/prototype.js @@ -1,4 +1,4 @@ -/* Prototype JavaScript framework, version 1.5.1 +/* Prototype JavaScript framework, version 1.5.1.1 * (c) 2005-2007 Sam Stephenson * * Prototype is freely distributable under the terms of an MIT-style license. @@ -7,7 +7,7 @@ /*--------------------------------------------------------------------------*/ var Prototype = { - Version: '1.5.1', + Version: '1.5.1.1', Browser: { IE: !!(window.attachEvent && !window.opera), @@ -24,8 +24,8 @@ var Prototype = { document.createElement('form').__proto__) }, - ScriptFragment: ']*>([\u0001-\uFFFF]*?)', - JSONFilter: /^\/\*-secure-\s*(.*)\s*\*\/\s*$/, + ScriptFragment: ']*>([\\S\\s]*?)<\/script>', + JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, emptyFunction: function() { }, K: function(x) { return x } @@ -364,11 +364,15 @@ Object.extend(String.prototype, { return this.sub(filter || Prototype.JSONFilter, '#{1}'); }, + isJSON: function() { + var str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); + return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str); + }, + evalJSON: function(sanitize) { var json = this.unfilterJSON(); try { - if (!sanitize || (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(json))) - return eval('(' + json + ')'); + if (!sanitize || json.isJSON()) return eval('(' + json + ')'); } catch (e) { } throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); }, @@ -1270,10 +1274,12 @@ if (Prototype.BrowserFeatures.XPath) { } else document.getElementsByClassName = function(className, parentElement) { var children = ($(parentElement) || document.body).getElementsByTagName('*'); - var elements = [], child; + var elements = [], child, pattern = new RegExp("(^|\\s)" + className + "(\\s|$)"); for (var i = 0, length = children.length; i < length; i++) { child = children[i]; - if (Element.hasClassName(child, className)) + var elementClassName = child.className; + if (elementClassName.length == 0) continue; + if (elementClassName == className || elementClassName.match(pattern)) elements.push(Element.extend(child)); } return elements; diff --git a/UI/WebServerResources/skycalendar.html b/UI/WebServerResources/skycalendar.html index 97e7dd31..265205de 100644 --- a/UI/WebServerResources/skycalendar.html +++ b/UI/WebServerResources/skycalendar.html @@ -20,6 +20,7 @@ modified by Martin Hoerning, mh@skyrix.com, 2002-12-05 +