1 /* UIxMailActions.m - this file is part of SOGo
3 * Copyright (C) 2007 Inverse groupe conseil
5 * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
7 * This file is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This file is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #import <Foundation/NSString.h>
25 #import <NGObjWeb/WOContext.h>
26 #import <NGObjWeb/WORequest.h>
27 #import <NGObjWeb/WOResponse.h>
28 #import <SoObjects/Mailer/SOGoDraftObject.h>
29 #import <SoObjects/Mailer/SOGoDraftsFolder.h>
30 #import <SoObjects/Mailer/SOGoMailAccount.h>
31 #import <SoObjects/Mailer/SOGoMailObject.h>
33 #import "../Common/WODirectAction+SOGo.h"
35 #import "UIxMailActions.h"
37 @implementation UIxMailActions
39 - (WOResponse *) editAction
41 SOGoMailAccount *account;
43 SOGoDraftsFolder *folder;
44 SOGoDraftObject *newMail;
45 NSString *newLocation;
47 co = [self clientObject];
48 account = [co mailAccountFolder];
49 folder = [account draftsFolderInContext: context];
50 newMail = [folder newDraft];
51 [newMail fetchMailForEditing: co];
54 newLocation = [NSString stringWithFormat: @"%@/edit",
55 [newMail baseURLInContext: context]];
57 return [self redirectToLocation: newLocation];
60 - (WOResponse *) replyToAll: (BOOL) toAll
62 SOGoMailAccount *account;
64 SOGoDraftsFolder *folder;
65 SOGoDraftObject *newMail;
66 NSString *newLocation;
68 co = [self clientObject];
69 account = [co mailAccountFolder];
70 folder = [account draftsFolderInContext: context];
71 newMail = [folder newDraft];
72 [newMail fetchMailForReplying: co toAll: toAll];
74 newLocation = [NSString stringWithFormat: @"%@/edit",
75 [newMail baseURLInContext: context]];
77 return [self redirectToLocation: newLocation];
80 - (WOResponse *) replyAction
82 return [self replyToAll: NO];
85 - (WOResponse *) replyToAllAction
87 return [self replyToAll: NO];
90 - (WOResponse *) forwardAction
92 SOGoMailAccount *account;
94 SOGoDraftsFolder *folder;
95 SOGoDraftObject *newMail;
96 NSString *newLocation;
98 co = [self clientObject];
99 account = [co mailAccountFolder];
100 folder = [account draftsFolderInContext: context];
101 newMail = [folder newDraft];
102 [newMail fetchMailForForwarding: co];
104 newLocation = [NSString stringWithFormat: @"%@/edit",
105 [newMail baseURLInContext: context]];
107 return [self redirectToLocation: newLocation];
110 /* SOGoDraftObject */
113 SOGoDraftObject *draft;
117 draft = [self clientObject];
118 error = [draft delete];
123 response = [context response];
124 [response setStatus: 204];
130 - (WOResponse *) deleteAttachmentAction
132 WOResponse *response;
135 response = [context response];
137 filename = [[context request] formValueForKey: @"filename"];
138 if ([filename length] > 0)
140 [[self clientObject] deleteAttachmentWithName: filename];
141 [response setStatus: 204];
145 [response setStatus: 500];
146 [response appendContentString: @"How did you end up here?"];