]> err.no Git - scalable-opengroupware.org/blob - UI/MailPartViewers/UIxMailPartICalAction.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1154 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / MailPartViewers / UIxMailPartICalAction.m
1 /*
2   Copyright (C) 2005 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21
22 #import <NGObjWeb/SoObject.h>
23 #import <NGObjWeb/WOContext.h>
24 #import <NGObjWeb/WOResponse.h>
25 #import <NGObjWeb/WODirectAction.h>
26 #import <NGExtensions/NSNull+misc.h>
27 #import <NGExtensions/NSString+misc.h>
28
29 @interface UIxMailPartICalAction : WODirectAction
30 @end
31
32 @implementation UIxMailPartICalAction
33
34 - (id)redirectToViewerWithError:(NSString *)_error {
35   WOResponse *r;
36   NSString *viewURL;
37   id mail;
38   
39   mail = [[self clientObject] valueForKey:@"mailObject"];
40   [self logWithFormat:@"MAIL: %@", mail];
41   
42   viewURL = [mail baseURLInContext:[self context]];
43   [self logWithFormat:@"  url: %@", viewURL];
44   
45   viewURL = [viewURL stringByAppendingString:
46                        [viewURL hasSuffix:@"/"] ? @"view" : @"/view"];
47
48   if ([_error isNotNull] && [_error length] > 0) {
49     viewURL = [viewURL stringByAppendingString:@"?error="];
50     viewURL = [viewURL stringByAppendingString:
51                          [_error stringByEscapingURL]];
52   }
53   
54   r = [[self context] response];
55   [r setStatus:302 /* moved */];
56   [r setHeader:viewURL forKey:@"location"];
57   return r;
58 }
59
60 - (id)changePartStatusAction:(NSString *)_newStatus {
61   [self logWithFormat:@"TODO: should %@: %@", _newStatus, [self clientObject]];
62   return [self redirectToViewerWithError:
63                  [_newStatus stringByAppendingString:@" not implemented!"]];
64 }
65
66 - (id)markAcceptedAction {
67   return [self changePartStatusAction:@"ACCEPTED"];
68 }
69 - (id)markDeclinedAction {
70   return [self changePartStatusAction:@"DECLINED"];
71 }
72 - (id)markTentativeAction {
73   return [self changePartStatusAction:@"TENTATIVE"];
74 }
75
76 @end /* UIxMailPartICalAction */