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 #import <Foundation/NSUserDefaults.h>
23 #import <NGObjWeb/WOContext.h>
24 #import <NGObjWeb/WORequest.h>
25 #import <NGObjWeb/SoComponent.h>
26 #import <NGExtensions/NSString+misc.h>
28 #import <SoObjects/Mailer/SOGoMailObject.h>
29 #import <SoObjects/Mailer/SOGoMailAccounts.h>
30 #import <SoObjects/SOGo/NSDictionary+URL.h>
31 #import <SoObjects/SOGo/NSArray+Utilities.h>
32 #import <SoObjects/SOGo/SOGoUser.h>
33 #import <SOGoUI/UIxComponent.h>
35 #import "UIxMailMainFrame.h"
37 @implementation UIxMailMainFrame
40 - (NSString *) mailAccounts
42 NSArray *accounts, *accountNames;
44 accounts = [[context activeUser] mailAccounts];
45 accountNames = [accounts objectsForKey: @"name"];
47 return [accountNames jsonRepresentation];
50 - (NSString *) pageFormURL
55 u = [[[self context] request] uri];
56 if ((r = [u rangeOfString:@"?"]).length > 0) {
57 /* has query parameters */
58 // TODO: this is ugly, create reusable link facility in SOPE
59 // TODO: remove 'search' and 'filterpopup', preserve sorting
64 qp = [[u substringFromIndex:(r.location + r.length)]
65 componentsSeparatedByString:@"&"];
67 ms = [NSMutableString stringWithCapacity:count * 12];
69 for (i = 0; i < count; i++) {
72 s = [qp objectAtIndex:i];
75 if ([s hasPrefix:@"search="]) continue;
76 if ([s hasPrefix:@"filterpopup="]) continue;
78 if ([ms length] > 0) [ms appendString:@"&"];
82 if ([ms length] == 0) {
83 /* no other query params */
84 u = [u substringToIndex:r.location];
87 u = [u substringToIndex:r.location + r.length];
88 u = [u stringByAppendingString:ms];
92 return [u hasSuffix:@"/"] ? @"view" : @"#";
95 - (id <WOActionResults>) composeAction
98 NSString *firstAccount, *newLocation;
100 NSDictionary *formValues;
102 co = [self clientObject];
103 accounts = [[context activeUser] mailAccounts];
104 firstAccount = [[accounts objectsForKey: @"name"] objectAtIndex: 0];
105 formValues = [[context request] formValues];
106 newLocation = [NSString stringWithFormat: @"%@/%@/compose%@",
107 [co baseURLInContext: context],
109 [formValues asURLParameters]];
111 return [self redirectToLocation: newLocation];
114 @end /* UIxMailMainFrame */