From b7323afa010afdba3ba9a2b2e5e0ea99fc68b697 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 6 Mar 2012 19:46:14 +0000 Subject: [PATCH 1/2] Monotone-Parent: 2db05edf03ab8974bf7e72c13532434b264cff3d Monotone-Revision: 5c16103ef3144005637a40e62d21cf1830441cea Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-03-06T19:46:14 --- ChangeLog | 7 ++++ SoObjects/Contacts/NGVCard+SOGo.m | 54 +++++++++++++++---------------- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5179e5f8b..db56264e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2012-03-06 Wolfgang Sourdeau + + * SoObjects/Contacts/NGVCard+SOGo.m + (-_setupEmailFieldsInLDIFRecord:): simplified code and fixed a bug + where the home mail would be taken for both first and second email + fields when no work mail was present. + 2012-03-02 Jean Raby * Scripts/sogo-backup.sh: new script to automate backups. diff --git a/SoObjects/Contacts/NGVCard+SOGo.m b/SoObjects/Contacts/NGVCard+SOGo.m index da86be3fa..250dc7e1a 100644 --- a/SoObjects/Contacts/NGVCard+SOGo.m +++ b/SoObjects/Contacts/NGVCard+SOGo.m @@ -351,40 +351,38 @@ convention: - (void) _setupEmailFieldsInLDIFRecord: (NSMutableDictionary *) ldifRecord { NSArray *elements; - NSString *workMail, *homeMail, *potential; - unsigned int max; + NSString *workMail, *homeMail, *mail, *secondEmail; + NSUInteger max; elements = [self childrenWithTag: @"email"]; - max = [elements count]; - workMail = [self _simpleValueForType: @"work" - inArray: elements excluding: nil]; - homeMail = [self _simpleValueForType: @"home" - inArray: elements excluding: nil]; + max = [elements count]; if (max > 0) { - potential = [[elements objectAtIndex: 0] flattenedValuesForKey: @""]; - if (!workMail) - { - if (homeMail && homeMail == potential) - { - if (max > 1) - workMail = [[elements objectAtIndex: 1] flattenedValuesForKey: @""]; - } - else - workMail = potential; - } - if (!homeMail && max > 1) - { - if (workMail && workMail == potential) - homeMail = [[elements objectAtIndex: 1] flattenedValuesForKey: @""]; - else - homeMail = potential; - } - } + workMail = [self _simpleValueForType: @"work" + inArray: elements excluding: nil]; + homeMail = [self _simpleValueForType: @"home" + inArray: elements excluding: nil]; - [self _setValue: @"mail" to: workMail inLDIFRecord: ldifRecord]; - [self _setValue: @"mozillasecondemail" to: homeMail inLDIFRecord: ldifRecord]; + mail = workMail; + if (mail) + secondEmail = homeMail; + else + { + secondEmail = nil; + mail = homeMail; + } + + if (!mail) + { + mail = [elements objectAtIndex: 0]; + if (max > 1) /* we know secondEmail is not set here either... */ + secondEmail = [elements objectAtIndex: 1]; + } + + [self _setValue: @"mail" to: mail inLDIFRecord: ldifRecord]; + [self _setValue: @"mozillasecondemail" to: secondEmail inLDIFRecord: ldifRecord]; + } [self _setValue: @"mozillausehtmlmail" to: [[self uniqueChildWithTag: @"x-mozilla-html"] From 165dd26ec508fd301dcb630fcd3a9f0afd097301 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 6 Mar 2012 20:32:20 +0000 Subject: [PATCH 2/2] Monotone-Parent: 5c16103ef3144005637a40e62d21cf1830441cea Monotone-Revision: bbb9fd8c5076db6a340935f8f7dba98b04c5b353 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-03-06T20:32:20 --- ChangeLog | 4 ++++ SoObjects/Mailer/SOGoMailFolder.m | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index db56264e0..6e9bf3eba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2012-03-06 Wolfgang Sourdeau + * SoObjects/Mailer/SOGoMailFolder.m + (-archiveUIDs:inArchiveNamed:inContext:): output filename is now + escaped without its extension. + * SoObjects/Contacts/NGVCard+SOGo.m (-_setupEmailFieldsInLDIFRecord:): simplified code and fixed a bug where the home mail would be taken for both first and second email diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index 87cece7d8..a1c3b5e3d 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -468,7 +468,7 @@ static NSString *defaultUserID = @"anyone"; { NSException *error; NSFileManager *fm; - NSString *spoolPath, *fileName, *zipPath, *qpFileName; + NSString *spoolPath, *fileName, *baseName, *extension, *zipPath, *qpFileName; NSDictionary *msgs; NSArray *messages; NSData *content, *zipContent; @@ -533,7 +533,17 @@ static NSString *defaultUserID = @"anyone"; } response = [context response]; - qpFileName = [archiveName asQPSubjectString: @"utf-8"]; + + baseName = [archiveName stringByDeletingPathExtension]; + extension = [archiveName pathExtension]; + if ([extension length] > 0) + extension = [@"." stringByAppendingString: extension]; + else + extension = @""; + + qpFileName = [NSString stringWithFormat: @"%@%@", + [baseName asQPSubjectString: @"utf-8"], + extension]; [response setHeader: [NSString stringWithFormat: @"application/zip;" @" name=\"%@\"", qpFileName]