diff --git a/Documentation/SOGoInstallationGuide.asciidoc b/Documentation/SOGoInstallationGuide.asciidoc index d2a6bf5af..758196c79 100644 --- a/Documentation/SOGoInstallationGuide.asciidoc +++ b/Documentation/SOGoInstallationGuide.asciidoc @@ -1630,6 +1630,16 @@ Defaults to `Trash` when unset. Use a `/` as a hierarchy separator if referring to an IMAP subfolder. For example: `INBOX/Trash`. +|U |SOGoJunkFolderName +|Parameter used to set the IMAP folder name used to store junk +messages. + +Defaults to `Junk` when unset. + +Use a `/` as a hierarchy separator if referring to an IMAP subfolder. +For example: `INBOX/Junk`. Also see the SOGoMailJunkSettings for +more options regarding junk/not-junk actions. + |D |SOGoIMAPCASServiceName |Parameter used to set the CAS service name (URL) of the imap service. This is useful if SOGo is connecting to the IMAP service through a @@ -2084,7 +2094,17 @@ Defaults to `%{FolderName} (%{UserName} <%{Email}>)` when unset. the template named `UIxAdditionalPreferences.wox`. This template should be put under `~sogo/GNUstep/Library/SOGo/Templates/PreferencesUI/`. -Defaults to `NO` when unset. +|D |SOGoMailJunkSettings +|Parameter used to enable email junk settings. The value is a dictionary +and the follow keys are supported: `vendor` (which must be set to "generic" +for now), `junkEmailAddress` which sets the email address to whom SOGo will +send junk mails to, `notJunkEmailAddress` which sets the email address to +whome SOGo will send non-junk mails to and `limit`, which is an integer value +and sets the maximum number of mails that will be attached to a +junk/not junk report sent by SOGo. Example: `SOGoMailJunkSettings = { +vendor = "generic"; junkEmailAddress = "spam@foo.com"; +notJunkEmailAddress = "ham@foo.com"; limit = 10; +};` |======================================================================= SOGo Configuration Summary @@ -2113,6 +2133,7 @@ like this: SOGoDraftsFolderName = Drafts; SOGoSentFolderName = Sent; SOGoTrashFolderName = Trash; + SOGoJunkFolderName = Junk; SOGoMailingMechanism = smtp; SOGoSMTPServer = 127.0.0.1; SOGoUserSources = ( diff --git a/NEWS b/NEWS index 2d02d5718..9f86f3ded 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +2.3.7 (2016-01-XX) +------------------ + +New features + - new junk/not junk capability with generic SMTP integration + 2.3.6 (2016-01-18) ------------------ diff --git a/SoObjects/Mailer/GNUmakefile b/SoObjects/Mailer/GNUmakefile index f25e20edd..d217816c2 100644 --- a/SoObjects/Mailer/GNUmakefile +++ b/SoObjects/Mailer/GNUmakefile @@ -23,6 +23,7 @@ Mailer_OBJC_FILES += \ SOGoSentFolder.m \ SOGoDraftsFolder.m \ SOGoTrashFolder.m \ + SOGoJunkFolder.m \ \ SOGoMailBodyPart.m \ SOGoHTMLMailBodyPart.m \ diff --git a/SoObjects/Mailer/SOGoJunkFolder.h b/SoObjects/Mailer/SOGoJunkFolder.h new file mode 100644 index 000000000..5825af96c --- /dev/null +++ b/SoObjects/Mailer/SOGoJunkFolder.h @@ -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__ */ diff --git a/SoObjects/Mailer/SOGoJunkFolder.m b/SoObjects/Mailer/SOGoJunkFolder.m new file mode 100644 index 000000000..6e8fad318 --- /dev/null +++ b/SoObjects/Mailer/SOGoJunkFolder.m @@ -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 */ diff --git a/SoObjects/Mailer/SOGoMailAccount.h b/SoObjects/Mailer/SOGoMailAccount.h index 7bff26e6f..b60f274bb 100644 --- a/SoObjects/Mailer/SOGoMailAccount.h +++ b/SoObjects/Mailer/SOGoMailAccount.h @@ -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 */ diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index 2b167b472..656dd9a1a 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -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]; @@ -408,6 +412,8 @@ static NSString *inboxFolderName = @"INBOX"; folderType = @"sent"; else if ([folderName isEqualToString: [NSString stringWithFormat: @"/%@", [self trashFolderNameInContext: context]]]) folderType = @"trash"; + else if ([folderName isEqualToString: [NSString stringWithFormat: @"/%@", [self junkFolderNameInContext: context]]]) + folderType = @"junk"; else folderType = @"folder"; @@ -678,6 +684,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], @@ -773,6 +780,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]; @@ -837,6 +847,11 @@ static NSString *inboxFolderName = @"INBOX"; return [self _userFolderNameWithPurpose: @"Trash"]; } +- (NSString *) junkFolderNameInContext: (id)_ctx +{ + return [self _userFolderNameWithPurpose: @"Junk"]; +} + - (NSString *) otherUsersFolderNameInContext: (id)_ctx { return otherUsersFolderName; @@ -935,6 +950,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 { diff --git a/SoObjects/Mailer/SOGoMailBaseObject.h b/SoObjects/Mailer/SOGoMailBaseObject.h index e7878b73d..dcddaf876 100644 --- a/SoObjects/Mailer/SOGoMailBaseObject.h +++ b/SoObjects/Mailer/SOGoMailBaseObject.h @@ -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. diff --git a/SoObjects/Mailer/SOGoMailFolder.h b/SoObjects/Mailer/SOGoMailFolder.h index 8ea595344..c68adc65c 100644 --- a/SoObjects/Mailer/SOGoMailFolder.h +++ b/SoObjects/Mailer/SOGoMailFolder.h @@ -77,6 +77,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 diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index 529a138e7..072f9041e 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -35,6 +35,8 @@ #import #import #import +#import +#import #import #import @@ -42,12 +44,20 @@ #import +#import +#import +#import +#import +#import + #import #import #import #import #import +#import +#import #import #import #import @@ -60,6 +70,7 @@ #import #import #import +#import #import "EOQualifier+MailDAV.h" #import "SOGoMailObject.h" @@ -67,6 +78,8 @@ #import "SOGoMailManager.h" #import "SOGoMailFolder.h" #import "SOGoTrashFolder.h" +#import "SOGoMailObject+Draft.h" + #define XMLNS_INVERSEDAV @"urn:inverse:params:xml:ns:inverse-dav" @@ -783,6 +796,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 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; @@ -1931,6 +2053,11 @@ _compareFetchResultsByMODSEQ (id entry1, id entry2, void *data) return response; } +- (NSString *) className +{ + return NSStringFromClass([self class]); +} + - (id) PUTAction: (WOContext *) _ctx { WORequest *rq; diff --git a/SoObjects/Mailer/SOGoTrashFolder.h b/SoObjects/Mailer/SOGoTrashFolder.h index 5d14947f1..1c3097c31 100644 --- a/SoObjects/Mailer/SOGoTrashFolder.h +++ b/SoObjects/Mailer/SOGoTrashFolder.h @@ -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. diff --git a/SoObjects/Mailer/SOGoTrashFolder.m b/SoObjects/Mailer/SOGoTrashFolder.m index e0e224af0..93efec53c 100644 --- a/SoObjects/Mailer/SOGoTrashFolder.m +++ b/SoObjects/Mailer/SOGoTrashFolder.m @@ -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 - #import "SOGoTrashFolder.h" @implementation SOGoTrashFolder diff --git a/SoObjects/SOGo/SOGoDefaults.plist b/SoObjects/SOGo/SOGoDefaults.plist index 614959f75..e0bc3623e 100644 --- a/SoObjects/SOGo/SOGoDefaults.plist +++ b/SoObjects/SOGo/SOGoDefaults.plist @@ -67,6 +67,7 @@ SOGoSentFolderName = "Sent"; SOGoDraftsFolderName = "Drafts"; SOGoTrashFolderName = "Trash"; + SOGoJunkFolderName = "Junk"; SOGoMailAutoSave = "5"; diff --git a/SoObjects/SOGo/SOGoDomainDefaults.h b/SoObjects/SOGo/SOGoDomainDefaults.h index 7dea88121..b8cc6f30b 100644 --- a/SoObjects/SOGo/SOGoDomainDefaults.h +++ b/SoObjects/SOGo/SOGoDomainDefaults.h @@ -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 */ diff --git a/SoObjects/SOGo/SOGoDomainDefaults.m b/SoObjects/SOGo/SOGoDomainDefaults.m index 4c7541b19..763eb6033 100644 --- a/SoObjects/SOGo/SOGoDomainDefaults.m +++ b/SoObjects/SOGo/SOGoDomainDefaults.m @@ -361,4 +361,9 @@ return [self boolForKey: @"SOGoNotifyOnExternalModifications"]; } +- (NSDictionary *) mailJunkSettings +{ + return [self objectForKey: @"SOGoMailJunkSettings"]; +} + @end diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 6f8028603..b0b8d0f7b 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -797,6 +797,8 @@ forKey: @"Sent"]; [mailboxes setObject: [_defaults trashFolderName] forKey: @"Trash"]; + [mailboxes setObject: [_defaults junkFolderName] + forKey: @"Junk"]; [mailAccount setObject: mailboxes forKey: @"mailboxes"]; [mailboxes release]; diff --git a/SoObjects/SOGo/SOGoUserDefaults.h b/SoObjects/SOGo/SOGoUserDefaults.h index 7d59bf42d..6fa0283ad 100644 --- a/SoObjects/SOGo/SOGoUserDefaults.h +++ b/SoObjects/SOGo/SOGoUserDefaults.h @@ -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; diff --git a/SoObjects/SOGo/SOGoUserDefaults.m b/SoObjects/SOGo/SOGoUserDefaults.m index d8c6194ef..c1784aec9 100644 --- a/SoObjects/SOGo/SOGoUserDefaults.m +++ b/SoObjects/SOGo/SOGoUserDefaults.m @@ -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"]; diff --git a/UI/MailerUI/English.lproj/Localizable.strings b/UI/MailerUI/English.lproj/Localizable.strings index fb1381578..71b0a5d03 100644 --- a/UI/MailerUI/English.lproj/Localizable.strings +++ b/UI/MailerUI/English.lproj/Localizable.strings @@ -140,6 +140,7 @@ "TrashFolderName" = "Trash"; "InboxFolderName" = "Inbox"; "DraftsFolderName" = "Drafts"; +"JunkFolderName" = "Junk"; "SieveFolderName" = "Filters"; "Folders" = "Folders"; /* title line */ /* MailMoveToPopUp */ @@ -171,6 +172,7 @@ "Sent Messages" = "Sent Messages"; "Drafts" = "Drafts"; "Deleted Messages" = "Deleted Messages"; +"Junk Messages" = "Junk Messages"; /* Message list popup menu */ "Open Message In New Window" = "Open Message In New Window"; "Reply to Sender Only" = "Reply to Sender Only"; @@ -186,6 +188,8 @@ "Print..." = "Print..."; "Delete Message" = "Delete Message"; "Delete Selected Messages" = "Delete Selected Messages"; +"Mark the selected messages as junk" = "Mark the selected messages as junk"; +"Mark the selected messages as not junk" = "Mark the selected messages as not junk"; /* Number of selected messages in list */ "selected" = "selected"; "This Folder" = "This Folder"; diff --git a/UI/MailerUI/UIxMailFolderActions.h b/UI/MailerUI/UIxMailFolderActions.h index ad82797f1..a43db8b59 100644 --- a/UI/MailerUI/UIxMailFolderActions.h +++ b/UI/MailerUI/UIxMailFolderActions.h @@ -1,8 +1,6 @@ /* UIxMailFolderActions.h - this file is part of SOGo * - * Copyright (C) 2007 Inverse inc. - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2007-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 diff --git a/UI/MailerUI/UIxMailFolderActions.m b/UI/MailerUI/UIxMailFolderActions.m index 3c7c1edb4..7b068b863 100644 --- a/UI/MailerUI/UIxMailFolderActions.m +++ b/UI/MailerUI/UIxMailFolderActions.m @@ -1,6 +1,6 @@ /* UIxMailFolderActions.m - this file is part of SOGo * - * Copyright (C) 2007-2013 Inverse inc. + * Copyright (C) 2007-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 @@ -544,6 +544,11 @@ return [self _setFolderPurpose: @"Trash"]; } +- (WOResponse *) setAsJunkFolderAction +{ + return [self _setFolderPurpose: @"Junk"]; +} + - (WOResponse *) expungeAction { NSException *error; @@ -778,5 +783,36 @@ return response; } +- (WOResponse *) _markMessagesAsJunkOrNotJunk: (BOOL) isJunk +{ + NSDictionary *content; + WOResponse *response; + WORequest *request; + SOGoMailFolder *co; + NSArray *uids; + + request = [context request]; + content = [[request contentAsString] objectFromJSONString]; + uids = [NSArray arrayWithArray: [content objectForKey:@"uids"]]; + + co = [self clientObject]; + + if ([co markMessagesAsJunkOrNotJunk: uids junk: isJunk]) + response = [self responseWithStatus: 500]; + else + response = [self responseWith204]; + + return response; +} + +- (WOResponse *) markMessagesAsJunkAction +{ + return [self _markMessagesAsJunkOrNotJunk: YES]; +} + +- (WOResponse *) markMessagesAsNotJunkAction +{ + return [self _markMessagesAsJunkOrNotJunk: NO]; +} @end diff --git a/UI/MailerUI/product.plist b/UI/MailerUI/product.plist index 4ef063eca..75c8533b3 100644 --- a/UI/MailerUI/product.plist +++ b/UI/MailerUI/product.plist @@ -167,6 +167,21 @@ actionClass = "UIxMailFolderActions"; actionName = "setAsTrashFolder"; }; + setAsJunkFolder = { + protectedBy = "View"; + actionClass = "UIxMailFolderActions"; + actionName = "setAsJunkFolder"; + }; + markMessagesAsJunk = { + protectedBy = "View"; + actionClass = "UIxMailFolderActions"; + actionName = "markMessagesAsJunk"; + }; + markMessagesAsNotJunk = { + protectedBy = "View"; + actionClass = "UIxMailFolderActions"; + actionName = "markMessagesAsNotJunk"; + }; userRights = { protectedBy = "ReadAcls"; pageName = "UIxMailUserRightsEditor";