(feat) new junk/not junk capability with generic SMTP integration

Conflicts:

	NEWS
	SoObjects/Mailer/SOGoMailAccount.m
	SoObjects/SOGo/SOGoDefaults.plist
	SoObjects/SOGo/SOGoUser.m
	UI/MailerUI/UIxMailFolderActions.h
	UI/MailerUI/UIxMailFolderActions.m
	UI/MailerUI/product.plist
This commit is contained in:
Ludovic Marcotte committed 2016-01-22 13:58:45 -05:00
1 parent 88207d27c4
commit 30377c0fd6
21 files changed
+338 -16

No files matched your search

+1
View File
@@ -23,6 +23,7 @@ Mailer_OBJC_FILES += \
SOGoSentFolder.m \
SOGoDraftsFolder.m \
SOGoTrashFolder.m \
SOGoJunkFolder.m \
\
SOGoMailBodyPart.m \
SOGoHTMLMailBodyPart.m \
+30
View File
@@ -0,0 +1,30 @@
/*
Copyright (C) 2007-2016 Inverse inc.
This file is part of SOGo.
SOGo 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.
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with OGo; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
#ifndef __Mailer_SOGoJunkFolder_H__
#define __Mailer_SOGoJunkFolder_H__
#import "SOGoMailFolder.h"
@interface SOGoJunkFolder : SOGoSpecialMailFolder
@end
#endif /* __Mailer_SOGoJunkFolder_H__ */
+26
View File
@@ -0,0 +1,26 @@
/*
Copyright (C) 2007-2016 Inverse inc.
This file is part of SOGo.
SOGo 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.
SOGo 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.
*/
#import "SOGoJunkFolder.h"
@implementation SOGoJunkFolder
@end /* SOGoJunkFolder */
+4
View File
@@ -42,6 +42,7 @@
@class SOGoDraftsFolder;
@class SOGoSentFolder;
@class SOGoTrashFolder;
@class SOGoJunkFolder;
typedef enum {
undefined = -1,
@@ -55,6 +56,7 @@ typedef enum {
SOGoDraftsFolder *draftsFolder;
SOGoSentFolder *sentFolder;
SOGoTrashFolder *trashFolder;
SOGoJunkFolder *junkFolder;
SOGoIMAPAclStyle imapAclStyle;
NSMutableArray *identities;
NSString *otherUsersFolderName;
@@ -95,11 +97,13 @@ typedef enum {
- (NSString *) trashFolderNameInContext: (id)_ctx;
- (NSString *) otherUsersFolderNameInContext: (id)_ctx;
- (NSString *) sharedFoldersNameInContext: (id)_ctx;
- (NSString *) junkFolderNameInContext: (id)_ctx;
- (SOGoMailFolder *) inboxFolderInContext: (id)_ctx;
- (SOGoDraftsFolder *) draftsFolderInContext: (id)_ctx;
- (SOGoSentFolder *) sentFolderInContext: (id)_ctx;
- (SOGoTrashFolder *) trashFolderInContext: (id)_ctx;
- (SOGoJunkFolder *) junkFolderInContext: (id)_ctx;
/* namespaces */
+29 -1
View File
@@ -1,6 +1,6 @@
/*
Copyright (C) 2004-2005 SKYRIX Software AG
Copyright (C) 2007-2014 Inverse inc.
Copyright (C) 2007-2016 Inverse inc.
This file is part of SOGo.
@@ -58,6 +58,7 @@
#import "SOGoMailNamespace.h"
#import "SOGoSentFolder.h"
#import "SOGoTrashFolder.h"
#import "SOGoJunkFolder.h"
#import "SOGoUser+Mailer.h"
#import "SOGoMailAccount.h"
@@ -78,6 +79,7 @@ static NSString *inboxFolderName = @"INBOX";
draftsFolder = nil;
sentFolder = nil;
trashFolder = nil;
junkFolder = nil;
imapAclStyle = undefined;
identities = nil;
otherUsersFolderName = nil;
@@ -93,6 +95,7 @@ static NSString *inboxFolderName = @"INBOX";
[draftsFolder release];
[sentFolder release];
[trashFolder release];
[junkFolder release];
[identities release];
[otherUsersFolderName release];
[sharedFoldersName release];
@@ -366,6 +369,7 @@ static NSString *inboxFolderName = @"INBOX";
[self draftsFolderNameInContext: context],
[self sentFolderNameInContext: context],
[self trashFolderNameInContext: context],
[self junkFolderNameInContext: context],
nil] stringsWithFormat: @"/%@"];
folders = [[self imap4Connection] allFoldersForURL: [self imap4URL]
onlySubscribedFolders: subscribedOnly];
@@ -412,6 +416,8 @@ static NSString *inboxFolderName = @"INBOX";
folderType = @"otherUsers";
else if ([folderName isEqualToString: sharedFoldersName])
folderType = @"shared";
else if ([folderName isEqualToString: [self junkFolderNameInContext: context]])
folderType = @"junk";
else
folderType = @"folder";
@@ -724,6 +730,7 @@ static NSString *inboxFolderName = @"INBOX";
ud = [[context activeUser] userDefaults];
// We skip the Junk folder here, as EAS doesn't know about this
if ([ud synchronizeOnlyDefaultMailFolders])
folderList = [[NSArray arrayWithObjects:
[self inboxFolderNameInContext: context],
@@ -819,6 +826,9 @@ static NSString *inboxFolderName = @"INBOX";
else if ([folderName
isEqualToString: [self trashFolderNameInContext: _ctx]])
klazz = [SOGoTrashFolder class];
else if ([folderName
isEqualToString: [self junkFolderNameInContext: _ctx]])
klazz = [SOGoJunkFolder class];
else
klazz = [SOGoMailFolder class];
@@ -883,6 +893,11 @@ static NSString *inboxFolderName = @"INBOX";
return [self _userFolderNameWithPurpose: @"Trash"];
}
- (NSString *) junkFolderNameInContext: (id)_ctx
{
return [self _userFolderNameWithPurpose: @"Junk"];
}
- (NSString *) otherUsersFolderNameInContext: (id)_ctx
{
return otherUsersFolderName;
@@ -981,6 +996,19 @@ static NSString *inboxFolderName = @"INBOX";
return trashFolder;
}
- (SOGoJunkFolder *) junkFolderInContext: (id) _ctx
{
if (!junkFolder)
{
junkFolder
= [self folderWithTraversal: [self junkFolderNameInContext: _ctx]
andClassName: @"SOGoJunkFolder"];
[trashFolder retain];
}
return junkFolder;
}
/* account delegation */
- (NSArray *) delegates
{
+4 -3
View File
@@ -1,14 +1,15 @@
/*
Copyright (C) 2004-2005 SKYRIX Software AG
Copyright (C) 2009-2016 Inverse inc.
This file is part of OpenGroupware.org.
This file is part of SOGo.
OGo is free software; you can redistribute it and/or modify it under
SOGo 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
SOGo 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.
+5
View File
@@ -78,6 +78,9 @@
toFolder: (NSString *) destinationFolder
inContext: (id) localContext;
- (WOResponse *) markMessagesAsJunkOrNotJunk: (NSArray *) uids
junk: (BOOL) isJunk;
- (NSException *) postData: (NSData *) _data flags: (id) _flags;
- (void) markForExpunge;
@@ -120,6 +123,8 @@
- (id) appendMessage: (NSData *) message
usingId: (int *) imap4id;
- (NSString *) className;
@end
@interface SOGoSpecialMailFolder : SOGoMailFolder
+127
View File
@@ -35,6 +35,8 @@
#import <NGExtensions/NSObject+Logs.h>
#import <NGExtensions/NSString+misc.h>
#import <NGExtensions/NSFileManager+Extensions.h>
#import <NGExtensions/NGHashMap.h>
#import <NGExtensions/NSCalendarDate+misc.h>
#import <DOM/DOMElement.h>
#import <DOM/DOMProtocols.h>
@@ -42,12 +44,20 @@
#import <EOControl/EOSortOrdering.h>
#import <NGMime/NGMimeBodyPart.h>
#import <NGMime/NGMimeFileData.h>
#import <NGMime/NGMimeMultipartBody.h>
#import <NGMail/NGMimeMessage.h>
#import <NGMail/NGMimeMessageGenerator.h>
#import <NGImap4/NGImap4Connection.h>
#import <NGImap4/NGImap4Client.h>
#import <NGImap4/NSString+Imap4.h>
#import <SOGo/DOMNode+SOGo.h>
#import <SOGo/NSArray+Utilities.h>
#import <SOGo/NSCalendarDate+SOGo.h>
#import <SOGo/SOGoDAVAuthenticator.h>
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/NSString+Utilities.h>
#import <SOGo/NSString+DAV.h>
@@ -61,6 +71,7 @@
#import <SOGo/SOGoUserSettings.h>
#import <SOGo/WORequest+SOGo.h>
#import <SOGo/WOResponse+SOGo.h>
#import <SOGo/SOGoMailer.h>
#import "EOQualifier+MailDAV.h"
#import "SOGoMailObject.h"
@@ -69,6 +80,8 @@
#import "SOGoMailManager.h"
#import "SOGoMailFolder.h"
#import "SOGoTrashFolder.h"
#import "SOGoMailObject+Draft.h"
#define XMLNS_INVERSEDAV @"urn:inverse:params:xml:ns:inverse-dav"
@@ -785,6 +798,115 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data)
return result;
}
- (WOResponse *) markMessagesAsJunkOrNotJunk: (NSArray *) uids
junk: (BOOL) isJunk
{
NSDictionary *junkSettings;
NSString *recipient;
NSException *error;
unsigned int limit;
junkSettings = [[[context activeUser] domainDefaults] mailJunkSettings];
error = nil;
if ([[junkSettings objectForKey: @"vendor"] caseInsensitiveCompare: @"generic"] == NSOrderedSame)
{
if (isJunk)
recipient = [junkSettings objectForKey: @"junkEmailAddress"];
else
recipient = [junkSettings objectForKey: @"notJunkEmailAddress"];
limit = [[junkSettings objectForKey: @"limit"] intValue];
// If no limit is set, we only attach one mail at the time
// to reports sent by SOGo.
if (!limit)
limit = 1;
if ([recipient length])
{
NGMimeMessage *messageToSend;
SOGoMailObject *mailObject;
NGMimeBodyPart *bodyPart;
NGMutableHashMap *map;
NGMimeFileData *fdata;
NSArray *identities;
NSData *data;
id body;
int i;
identities = [[self mailAccountFolder] identities];
for (i = 0; i < [uids count]; i++)
{
// If we are starting or reaching the limit, we create
// a new mail message
if ((i%limit) == 0)
{
map = [NGMutableHashMap hashMapWithCapacity: 5];
#warning SOPE is just plain stupid here - if you change the case of keys, it will break the encoding of fields
[map setObject: @"multipart/mixed" forKey: @"content-type"];
[map setObject: @"1.0" forKey: @"MIME-Version"];
[map setObject: [[identities objectAtIndex: 0] objectForKey: @"email"] forKey: @"from"];
[map setObject: recipient forKey: @"to"];
[map setObject: [[NSCalendarDate date] rfc822DateString] forKey: @"date"];
messageToSend = [[[NGMimeMessage alloc] initWithHeader: map] autorelease];
body = [[[NGMimeMultipartBody alloc] initWithPart: messageToSend] autorelease];
}
mailObject = [self lookupName: [uids objectAtIndex: i] inContext: context acquire: NO];
// We skip emails that might have disappeared before we were able
// to perform the action
if ([mailObject isKindOfClass: [NSException class]])
continue;
map = [[[NGMutableHashMap alloc] initWithCapacity: 1] autorelease];
[map setObject: @"message/rfc822" forKey: @"content-type"];
[map setObject: @"8bit" forKey: @"content-transfer-encoding"];
[map addObject: [NSString stringWithFormat: @"attachment; filename=\"%@\"", [mailObject filenameForForward]] forKey: @"content-disposition"];
bodyPart = [[[NGMimeBodyPart alloc] initWithHeader: map] autorelease];
data = [mailObject content];
fdata = [[NGMimeFileData alloc] initWithBytes: [data bytes] length: [data length]];
[bodyPart setBody: fdata];
RELEASE(fdata);
[body addBodyPart: bodyPart];
// We reached the limit or the end of the array
if ((i%limit) == 0 || i == [uids count]-1)
{
id <SOGoAuthenticator> authenticator;
NGMimeMessageGenerator *generator;
[messageToSend setBody: body];
generator = [[[NGMimeMessageGenerator alloc] init] autorelease];
data = [generator generateMimeFromPart: messageToSend];
authenticator = [SOGoDAVAuthenticator sharedSOGoDAVAuthenticator];
error = [[SOGoMailer mailerWithDomainDefaults: [[context activeUser] domainDefaults]]
sendMailData: data
toRecipients: [NSArray arrayWithObject: recipient]
sender: [[identities objectAtIndex: 0] objectForKey: @"email"]
withAuthenticator: authenticator
inContext: context];
if (error)
break;
}
}
}
}
return error;
}
- (NSDictionary *) statusForFlags: (NSArray *) flags
{
NGImap4Client *client;
@@ -1960,6 +2082,11 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data)
return response;
}
- (NSString *) className
{
return NSStringFromClass([self class]);
}
- (id) PUTAction: (WOContext *) _ctx
{
WORequest *rq;
+4 -3
View File
@@ -1,14 +1,15 @@
/*
Copyright (C) 2005 SKYRIX Software AG
Copyright (C) 2007-2016 Inverse inc.
This file is part of OpenGroupware.org.
This file is part of SOGo
OGo is free software; you can redistribute it and/or modify it under
SOGo 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
SOGo 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.
+4 -5
View File
@@ -1,14 +1,15 @@
/*
Copyright (C) 2005 SKYRIX Software AG
Copyright (C) 2007-2016 Inverse inc.
This file is part of OpenGroupware.org.
This file is part of SOGo.
OGo is free software; you can redistribute it and/or modify it under
SOGo 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
SOGo 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.
@@ -19,8 +20,6 @@
02111-1307, USA.
*/
#import <Foundation/NSString.h>
#import "SOGoTrashFolder.h"
@implementation SOGoTrashFolder
+1
View File
@@ -70,6 +70,7 @@
SOGoSentFolderName = "Sent";
SOGoDraftsFolderName = "Drafts";
SOGoTrashFolderName = "Trash";
SOGoJunkFolderName = "Junk";
SOGoMailComposeMessageType = "html";
SOGoMailDisplayRemoteInlineImages = "never";
+3 -1
View File
@@ -1,6 +1,6 @@
/* SOGoDomainDefaults.h - this file is part of SOGo
*
* Copyright (C) 2009-2015 Inverse inc.
* Copyright (C) 2009-2016 Inverse inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -81,6 +81,8 @@
- (BOOL) notifyOnPersonalModifications;
- (BOOL) notifyOnExternalModifications;
- (NSDictionary *) mailJunkSettings;
@end
#endif /* SOGODOMAINDEFAULTS_H */
+5
View File
@@ -361,4 +361,9 @@
return [self boolForKey: @"SOGoNotifyOnExternalModifications"];
}
- (NSDictionary *) mailJunkSettings
{
return [self objectForKey: @"SOGoMailJunkSettings"];
}
@end
+2
View File
@@ -830,6 +830,8 @@
forKey: @"Sent"];
[mailboxes setObject: [_defaults trashFolderName]
forKey: @"Trash"];
[mailboxes setObject: [_defaults junkFolderName]
forKey: @"Junk"];
[mailAccount setObject: mailboxes forKey: @"specialMailboxes"];
[mailboxes release];
+3
View File
@@ -108,6 +108,9 @@ extern NSString *SOGoWeekStartFirstFullWeek;
- (void) setTrashFolderName: (NSString *) newValue;
- (NSString *) trashFolderName;
- (void) setJunkFolderName: (NSString *) newValue;
- (NSString *) junkFolderName;
- (void) setFirstDayOfWeek: (int) newValue;
- (int) firstDayOfWeek;
+11
View File
@@ -458,6 +458,17 @@ NSString *SOGoWeekStartFirstFullWeek = @"FirstFullWeek";
stringByEncodingImap4FolderName];
}
- (void) setJunkFolderName: (NSString *) newValue
{
[self setObject: newValue forKey: @"SOGoJunkFolderName"];
}
- (NSString *) junkFolderName
{
return [[self stringForKey: @"SOGoJunkFolderName"]
stringByEncodingImap4FolderName];
}
- (void) setFirstDayOfWeek: (int) newValue
{
[self setInteger: newValue forKey: @"SOGoFirstDayOfWeek"];