2 Copyright (C) 2004-2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "UIxMailEditorAction.h"
24 @interface UIxMailForwardAction : UIxMailEditorAction
27 #include <SoObjects/Mailer/SOGoMailObject.h>
28 #include <SoObjects/Mailer/SOGoDraftObject.h>
31 @implementation UIxMailForwardAction
33 - (NSString *)getAttachmentNameForSubject:(NSString *)_subject {
34 /* SOGoDraftObject disallows some strings - anything else required? */
35 static NSString *sescape[] = {
36 @"/", @"..", @"~", @"\"", @"'", @" ", @".", nil
38 static int maxFilenameLength = 64;
42 if (![_subject isNotNull] || [_subject length] == 0)
46 if ([s length] > maxFilenameLength)
47 s = [s substringToIndex:maxFilenameLength];
49 for (i = 0; sescape[i] != nil; i++)
50 s = [s stringByReplacingString:sescape[i] withString:@"_"];
52 return [s stringByAppendingString:@".mail"];
55 - (NSString *)forwardSubject:(NSString *)_subject {
56 if (![_subject isNotNull] || [_subject length] == 0)
59 /* Note: this is how Thunderbird 1.0 creates the subject */
60 _subject = [@"[Fwd: " stringByAppendingString:_subject];
61 _subject = [_subject stringByAppendingString:@"]"];
73 if ((content = [[self clientObject] content]) == nil)
74 return [self didNotFindMailError];
75 if ([content isKindOfClass:[NSException class]])
80 if ((error = [self _setupNewDraft]) != nil)
83 /* set subject (do we need to set anything else?) */
85 info = [NSDictionary dictionaryWithObjectsAndKeys:
86 [self forwardSubject:[[self clientObject] subject]],
89 if ((error = [self->newDraft storeInfo:info]) != nil)
94 // TODO: use subject for filename?
95 error = [self->newDraft saveAttachment:content withName:@"forward.mail"];
99 // TODO: we might want to pass the original URL to the editor for a final
100 // redirect back to the message?
101 result = [self redirectToEditNewDraft];
106 @end /* UIxMailForwardAction */