From: helge Date: Mon, 11 Oct 2004 14:04:30 +0000 (+0000) Subject: work on mailer X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2324351ab576e4ff4586e147029f57ecdfe18ba;p=scalable-opengroupware.org work on mailer git-svn-id: http://svn.opengroupware.org/SOGo/trunk@378 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 2c4f1d7d..f850c375 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,3 +1,7 @@ +2004-10-11 Helge Hess + + * started SOGoDraftObject (v0.9.32) + 2004-10-10 Helge Hess * SOGoDraftsFolder.m: added methods to be compatible with the mail diff --git a/SOGo/SoObjects/Mailer/GNUmakefile b/SOGo/SoObjects/Mailer/GNUmakefile index 89ed10ed..ef4c0b92 100644 --- a/SOGo/SoObjects/Mailer/GNUmakefile +++ b/SOGo/SoObjects/Mailer/GNUmakefile @@ -20,6 +20,7 @@ Mailer_OBJC_FILES += \ SOGoMailBodyPart.m \ \ SOGoDraftsFolder.m \ + SOGoDraftObject.m \ Mailer_RESOURCE_FILES += \ Version \ diff --git a/SOGo/SoObjects/Mailer/SOGoDraftObject.h b/SOGo/SoObjects/Mailer/SOGoDraftObject.h new file mode 100644 index 00000000..20398688 --- /dev/null +++ b/SOGo/SoObjects/Mailer/SOGoDraftObject.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2004 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#ifndef __Mailer_SOGoDraftObject_H__ +#define __Mailer_SOGoDraftObject_H__ + +#include + +/* + SOGoDraftsFolder + Parent object: SOGoDraftsFolder + Child objects: draft attachments? + + The SOGoDraftObject is used for composing new messages. It is necessary + because we can't cache objects in a session. So the contents of the drafts + folder are some kind of "mail creation transaction". +*/ + +@interface SOGoDraftObject : SOGoMailBaseObject +{ +} + +@end + +#endif /* __Mailer_SOGoDraftObject_H__ */ diff --git a/SOGo/SoObjects/Mailer/SOGoDraftObject.m b/SOGo/SoObjects/Mailer/SOGoDraftObject.m new file mode 100644 index 00000000..3e6c967c --- /dev/null +++ b/SOGo/SoObjects/Mailer/SOGoDraftObject.m @@ -0,0 +1,31 @@ +/* + Copyright (C) 2004 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ + +#include "SOGoDraftObject.h" +#include "common.h" + +@implementation SOGoDraftObject + +- (void)dealloc { + [super dealloc]; +} + +@end /* SOGoDraftObject */ diff --git a/SOGo/SoObjects/Mailer/SOGoDraftsFolder.h b/SOGo/SoObjects/Mailer/SOGoDraftsFolder.h index ebd3edf6..9d6ab06c 100644 --- a/SOGo/SoObjects/Mailer/SOGoDraftsFolder.h +++ b/SOGo/SoObjects/Mailer/SOGoDraftsFolder.h @@ -28,7 +28,7 @@ /* SOGoDraftsFolder Parent object: SOGoMailAccount - Child objects: SOGoMailFolder + Child objects: SOGoDraftObject's The SOGoDraftsFolder is used for composing new messages. It is necessary because we can't cache objects in a session. So the contents of the drafts diff --git a/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m b/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m index b2dcf4c4..d15cb76a 100644 --- a/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m +++ b/SOGo/SoObjects/Mailer/SOGoDraftsFolder.m @@ -21,22 +21,106 @@ // $Id$ #include "SOGoDraftsFolder.h" +#include "SOGoDraftObject.h" +#include +#include #include "common.h" @implementation SOGoDraftsFolder +static NSString *spoolFolder = nil; + ++ (void)initialize { + NSUserDefaults *ud = [NSUserDefaults standardUserDefaults]; + + spoolFolder = [[ud stringForKey:@"SOGoMailSpoolPath"] copy]; + if ([spoolFolder length] < 3) + spoolFolder = @"/tmp/"; + + NSLog(@"Note: using SOGo mail spool folder: %@", spoolFolder); +} + +/* draft folder functionality */ + +- (NSFileManager *)spoolFileManager { + return [NSFileManager defaultManager]; +} + +- (NSString *)spoolFolderPath { + return spoolFolder; +} +- (NSString *)userSpoolFolderPath { + NSString *p, *n; + + p = [self spoolFolderPath]; + n = [[self lookupUserFolder] nameInContainer]; + return [p stringByAppendingPathComponent:n]; +} + +- (BOOL)_ensureUserSpoolFolderPath { + NSFileManager *fm; + + if ((fm = [self spoolFileManager]) == nil) { + [self logWithFormat:@"ERROR: missing spool file manager!"]; + return NO; + } + return [fm createDirectoriesAtPath:[self userSpoolFolderPath] + attributes:nil]; +} + +- (NSArray *)fetchMailNames { + NSString *p; + + if ((p = [self userSpoolFolderPath]) == nil) + return nil; + + return [[self spoolFileManager] directoryContentsAtPath:p]; +} + /* folder methods (used by template) */ - (NSArray *)fetchUIDsMatchingQualifier:(id)_q sortOrdering:(id)_so { // TODO: retrieve contained objects - [self logWithFormat:@"TODO: should fetch uids (q=%@,so=%@)", _q, _so]; - return [NSArray array]; + NSArray *allUids; + + allUids = [self fetchMailNames]; + if (![allUids isNotNull]) { + [self logWithFormat:@"Note: no uids in drafts folder: %@", + [self userSpoolFolderPath]]; + return [NSArray array]; + } + + [self logWithFormat:@"TODO: should sort uids (q=%@,so=%@): %@", _q, _so, + allUids]; + return allUids; } - (NSArray *)fetchUIDs:(NSArray *)_uids parts:(NSArray *)_parts { [self logWithFormat:@"TODO: fetch uids (parts=%@): %@", _parts, _uids]; return [NSArray array]; } +/* name lookup */ + +- (id)lookupDraftMessage:(NSString *)_key inContext:(id)_ctx { + // TODO: we might want to check for existence prior controller creation + return [[[SOGoDraftObject alloc] initWithName:_key + inContainer:self] autorelease]; +} + +- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { + id obj; + + /* first check attributes directly bound to the application */ + if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]) != nil) + return obj; + + if ((obj = [self lookupDraftMessage:_key inContext:_ctx]) != nil) + return obj; + + /* return 404 to stop acquisition */ + return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; +} + /* WebDAV */ - (BOOL)davIsCollection { diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 7fd6910f..97a71362 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=31 +SUBMINOR_VERSION:=32 diff --git a/SOGo/SoObjects/Mailer/product.plist b/SOGo/SoObjects/Mailer/product.plist index 2060eae8..26d8c0d2 100644 --- a/SOGo/SoObjects/Mailer/product.plist +++ b/SOGo/SoObjects/Mailer/product.plist @@ -31,5 +31,12 @@ SOGoMailBodyPart = { superclass = "SOGoMailBaseObject"; }; + + SOGoDraftsFolder = { + superclass = "SOGoMailBaseObject"; + }; + SOGoDraftObject = { + superclass = "SOGoMailBaseObject"; + }; }; } diff --git a/SOGo/UI/Mailer/ChangeLog b/SOGo/UI/Mailer/ChangeLog index 11942b8a..e36606c7 100644 --- a/SOGo/UI/Mailer/ChangeLog +++ b/SOGo/UI/Mailer/ChangeLog @@ -1,3 +1,9 @@ +2004-10-11 Helge Hess + + * started UIxMailEditorAction object which will contains all the + redirects from the buttons to the mail editor (working on draft + objects in the drafts folder) (v0.9.28) + 2004-10-10 Helge Hess * product.plist: added some configuration for the drafts folder diff --git a/SOGo/UI/Mailer/GNUmakefile b/SOGo/UI/Mailer/GNUmakefile index 444a7330..bea9bcb5 100644 --- a/SOGo/UI/Mailer/GNUmakefile +++ b/SOGo/UI/Mailer/GNUmakefile @@ -26,6 +26,7 @@ MailerUI_OBJC_FILES += \ UIxMailListView.m \ UIxMailView.m \ UIxMailEditor.m \ + UIxMailEditorAction.m \ \ UIxMailPartViewer.m \ UIxMailPartTextViewer.m \ diff --git a/SOGo/UI/Mailer/UIxMailEditor.m b/SOGo/UI/Mailer/UIxMailEditor.m index d5d3d360..f509e069 100644 --- a/SOGo/UI/Mailer/UIxMailEditor.m +++ b/SOGo/UI/Mailer/UIxMailEditor.m @@ -24,7 +24,6 @@ @interface UIxMailEditor : UIxComponent { - } @end diff --git a/SOGo/UI/Mailer/UIxMailEditorAction.m b/SOGo/UI/Mailer/UIxMailEditorAction.m new file mode 100644 index 00000000..d5aa505f --- /dev/null +++ b/SOGo/UI/Mailer/UIxMailEditorAction.m @@ -0,0 +1,66 @@ +/* + Copyright (C) 2004 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ +// $Id$ + +#include + +/* + UIxMailEditorAction + + This action implements the backend for the various buttons which invoke the + mail editor. The mail editor itself only works on a SOGoDraftObject which + needs to be created in advance. +*/ + +@interface UIxMailEditorAction : WODirectAction +@end + +#include +#include "common.h" + +@implementation UIxMailEditorAction + +/* errors */ + +- (id)didNotFindDraftsError { + // TODO: make a nice page + return [@"did not find drafts folder in object: " + stringByAppendingString:[[self clientObject] description]]; +} + +/* actions */ + +- (id)composeAction { + SOGoDraftsFolder *drafts; + id client; + + client = [self clientObject]; + drafts = [client lookupName:@"Drafts" inContext:[self context] acquire:YES]; + if (![drafts isNotNull]) + return [self didNotFindDraftsError]; + if ([drafts isKindOfClass:[NSException class]]) + return drafts; + + [self logWithFormat:@"compose on %@: %@", client, drafts]; + return nil; +} + +@end /* UIxMailEditorAction */ diff --git a/SOGo/UI/Mailer/Version b/SOGo/UI/Mailer/Version index 9461bed0..42d0a3b8 100644 --- a/SOGo/UI/Mailer/Version +++ b/SOGo/UI/Mailer/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=27 +SUBMINOR_VERSION:=28 diff --git a/SOGo/UI/Mailer/product.plist b/SOGo/UI/Mailer/product.plist index eceea7d2..124b7c93 100644 --- a/SOGo/UI/Mailer/product.plist +++ b/SOGo/UI/Mailer/product.plist @@ -134,7 +134,8 @@ compose = { protectedBy = "View"; - pageName = "UIxMailEditor"; + actionClass = "UIxMailEditorAction"; + actionName = "compose"; }; }; }; @@ -253,8 +254,13 @@ ( /* first group */ { link = "getMail"; cssClass = "tbicon_getmail"; label = "Get Mail"; }, + { + link = "#"; // "compose"; // target = "_blank"; + onclick = "clickedCompose(this);return false;"; + cssClass = "tbicon_compose"; label = "Write"; + }, { link = "addressbook"; target = "addressbook"; - cssClass = "tbicon_addressbook"; label = "Addressbook"; } + cssClass = "tbicon_addressbook"; label = "Addressbook"; }, ) ); }; @@ -264,6 +270,10 @@ protectedBy = "View"; pageName = "UIxMailListView"; }; + compose = { + protectedBy = "View"; + pageName = "UIxMailEditor"; + }; }; }; };