]> err.no Git - scalable-opengroupware.org/blobdiff - UI/MailerUI/UIxMailMainFrame.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1305 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / MailerUI / UIxMailMainFrame.m
index 9ad78fb1ed240a4b4e96bb6fbf8b108a417f7faa..e45d9d3016b36d8a37b3902ed8628b868131d44a 100644 (file)
 */
 
 #import <Foundation/NSUserDefaults.h>
+
+#import <NGObjWeb/WOContext.h>
 #import <NGObjWeb/WORequest.h>
+#import <NGObjWeb/WOResponse.h>
 #import <NGObjWeb/SoComponent.h>
 #import <NGExtensions/NSString+misc.h>
 
 #import <SoObjects/Mailer/SOGoMailObject.h>
 #import <SoObjects/Mailer/SOGoMailAccounts.h>
+#import <SoObjects/SOGo/NSDictionary+URL.h>
 #import <SoObjects/SOGo/NSArray+Utilities.h>
 #import <SoObjects/SOGo/SOGoUser.h>
 #import <SOGoUI/UIxComponent.h>
 
 @implementation UIxMailMainFrame
 
+- (void) _setupContext
+{
+  SOGoUser *activeUser;
+  NSString *login, *module;
+  SOGoMailAccounts *clientObject;
+
+  activeUser = [context activeUser];
+  login = [activeUser login];
+  clientObject = [self clientObject];
+
+  module = [clientObject nameInContainer];
+
+  ud = [activeUser userSettings];
+  moduleSettings = [ud objectForKey: module];
+  if (!moduleSettings)
+    {
+      moduleSettings = [NSMutableDictionary new];
+      [moduleSettings autorelease];
+    }
+  [ud setObject: moduleSettings forKey: module];
+}
+
 /* accessors */
 - (NSString *) mailAccounts
 {
   return [u hasSuffix:@"/"] ? @"view" : @"#";
 }
 
+- (id <WOActionResults>) composeAction
+{
+  NSArray *accounts;
+  NSString *firstAccount, *newLocation, *parameters;
+  SOGoMailAccounts *co;
+  NSDictionary *formValues;
+
+  co = [self clientObject];
+  accounts = [[context activeUser] mailAccounts];
+  firstAccount = [[accounts objectsForKey: @"name"] objectAtIndex: 0];
+  formValues = [[context request] formValues];
+  parameters = [formValues count] > 0 ? [formValues asURLParameters] : @"?mailto=";
+  newLocation = [NSString stringWithFormat: @"%@/%@/compose%@",
+                         [co baseURLInContext: context],
+                         firstAccount,
+                         parameters];
+
+  return [self redirectToLocation: newLocation];
+}
+
+- (WOResponse *) getFoldersStateAction
+{
+  NSString *expandedFolders;
+
+  [self _setupContext];
+  expandedFolders = [moduleSettings objectForKey: @"ExpandedFolders"];
+
+  return [self responseWithStatus: 200 andString: expandedFolders];
+}
+
+- (WOResponse *) saveFoldersStateAction
+{
+  WORequest *request;
+  NSString *expandedFolders;
+  
+  [self _setupContext];
+  request = [context request];
+  expandedFolders = [request formValueForKey: @"expandedFolders"];
+
+  [moduleSettings setObject: expandedFolders
+                 forKey: @"ExpandedFolders"];
+
+  [ud synchronize];
+
+  return [self responseWithStatus: 204];
+}
+
 @end /* UIxMailMainFrame */