]> err.no Git - scalable-opengroupware.org/blobdiff - UI/MailerUI/UIxMailView.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1158 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / MailerUI / UIxMailView.m
index de312aa8d6e818a9027052f77f439f3493569bd4..1eb40bc79b8ad0dc7744929a4e657daa63648e9f 100644 (file)
 */
 
 #import <Foundation/NSException.h>
+#import <Foundation/NSUserDefaults.h>
+#import <NGObjWeb/NSException+HTTP.h>
+#import <NGObjWeb/WORequest.h>
+#import <NGObjWeb/WOResponse.h>
 #import <NGExtensions/NSException+misc.h>
+#import <NGExtensions/NSString+misc.h>
+#import <NGImap4/NGImap4Envelope.h>
+#import <NGImap4/NGImap4EnvelopeAddress.h>
+#import <SoObjects/Mailer/SOGoMailObject.h>
+#import <SoObjects/Mailer/SOGoMailAccount.h>
+#import <SoObjects/Mailer/SOGoMailFolder.h>
+#import <SOGoUI/UIxComponent.h>
+#import <MailPartViewers/UIxMailRenderingContext.h> // cyclic
 
-#include <SOGoUI/UIxComponent.h>
+#import "WOContext+UIxMailer.h"
 
 @interface UIxMailView : UIxComponent
 {
 
 @end
 
-#include <UI/MailPartViewers/UIxMailRenderingContext.h> // cyclic
-#include "WOContext+UIxMailer.h"
-#include <SoObjects/Mailer/SOGoMailObject.h>
-#include <SoObjects/Mailer/SOGoMailAccount.h>
-#include <SoObjects/Mailer/SOGoMailFolder.h>
-#include <NGImap4/NGImap4Envelope.h>
-#include <NGImap4/NGImap4EnvelopeAddress.h>
-#include "common.h"
-
 @implementation UIxMailView
 
 static NSString *mailETag = nil;
@@ -99,33 +102,39 @@ static NSString *mailETag = nil;
 
 /* links (DUP to UIxMailPartViewer!) */
 
-- (NSString *)linkToEnvelopeAddress:(NGImap4EnvelopeAddress *)_address {
+- (NSString *) linkToEnvelopeAddress: (NGImap4EnvelopeAddress *) _address
+{
   // TODO: make some web-link, eg open a new compose panel?
-  return [@"mailto:" stringByAppendingString:[_address baseEMail]];
+  return [NSString stringWithFormat: @"mailto: %@", [_address baseEMail]];
 }
 
-- (NSString *)currentAddressLink {
+- (NSString *) currentAddressLink
+{
   return [self linkToEnvelopeAddress:[self currentAddress]];
 }
 
 /* fetching */
 
-- (id)message {
+- (id) message
+{
   return [[self clientObject] fetchCoreInfos];
 }
 
-- (BOOL)hasCC {
+- (BOOL) hasCC
+{
   return [[[self clientObject] ccEnvelopeAddresses] count] > 0 ? YES : NO;
 }
 
 /* viewers */
 
-- (id)contentViewerComponent {
+- (id) contentViewerComponent
+{
   // TODO: I would prefer to flatten the body structure prior rendering,
   //       using some delegate to decide which parts to select for alternative.
   id info;
   
   info = [[self clientObject] bodyStructure];
+
   return [[context mailRenderingContext] viewerForBodyInfo:info];
 }
 
@@ -168,21 +177,32 @@ static NSString *mailETag = nil;
   return self;
 }
 
-- (BOOL)isDeletableClientObject {
-  return [[self clientObject] respondsToSelector:@selector(delete)];
+- (BOOL) isDeletableClientObject
+{
+  return [[self clientObject] respondsToSelector: @selector (delete)];
 }
-- (BOOL)isInlineViewer {
+
+- (BOOL) isInlineViewer
+{
   return NO;
 }
 
-- (id)redirectToParentFolder {
+- (BOOL) mailIsDraft
+{
+  return [[self clientObject] isInDraftsFolder];
+}
+
+- (id) redirectToParentFolder
+{
   id url;
   
-  url = [[[self clientObject] container] baseURLInContext:context];
-  return [self redirectToLocation:url];
+  url = [[[self clientObject] container] baseURLInContext: context];
+
+  return [self redirectToLocation: url];
 }
 
-- (id)deleteAction {
+- (id) deleteAction
+{
   NSException *ex;
   
   if (![self isDeletableClientObject]) {
@@ -217,7 +237,8 @@ static NSString *mailETag = nil;
   return [self redirectToParentFolder];
 }
 
-- (id)trashAction {
+- (id) trashAction
+{
   NSException *ex;
   
   if ([self isInvokedBySafeMethod]) {
@@ -295,18 +316,21 @@ static NSString *mailETag = nil;
 
 /* generating response */
 
-- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
+- (void) appendToResponse: (WOResponse *) _response
+               inContext: (WOContext *) _ctx
+{
   UIxMailRenderingContext *mctx;
 
   if (mailETag != nil)
     [[_ctx response] setHeader:mailETag forKey:@"etag"];
 
-  mctx = [[NSClassFromString(@"UIxMailRenderingContext")
-                           alloc] initWithViewer:self context:_ctx];
-  [_ctx pushMailRenderingContext:mctx];
+  mctx = [[UIxMailRenderingContext alloc] initWithViewer: self
+                                         context: _ctx];
+
+  [_ctx pushMailRenderingContext: mctx];
   [mctx release];
-  
-  [super appendToResponse:_response inContext:_ctx];
+
+  [super appendToResponse: _response inContext: _ctx];
   
   [[_ctx popMailRenderingContext] reset];
 }