From: helge Date: Fri, 15 Jul 2005 14:59:04 +0000 (+0000) Subject: work on calendar mail part actions X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59b77e206d6d2a2caabd346752b4d638d08d59f5;p=scalable-opengroupware.org work on calendar mail part actions git-svn-id: http://svn.opengroupware.org/SOGo/trunk@779 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/UI/MailPartViewers/ChangeLog b/SOGo/UI/MailPartViewers/ChangeLog index 01a7f0b6..b3090541 100644 --- a/SOGo/UI/MailPartViewers/ChangeLog +++ b/SOGo/UI/MailPartViewers/ChangeLog @@ -1,16 +1,25 @@ 2005-07-15 Helge Hess + * v0.9.11 + + * added UIxMailPartICalAction for calendar part related link actions + (no actions implemented yet) + + * UIxMailPartViewer.m: added preferred extensions for iCalendar and + vCard mime types, moved in -pathToAttachment from + UIxMailPartLinkViewer (returns a nice download-link), added + -pathToAttachmentObject method (returns a plain link to the part + SoObject) + + * UIxMailPartLinkViewer.m: moved -pathToAttachment method to baseclass + * UIxMailPartICalViewer.m: added method to retrieve the authorative event (DB before mail), added a method to return an organizer display name (with appropriate fallbacks) (v0.9.10) -2005-07-15 Helge Hess - * UIxMailPartICalViewer.m: rewrote not to use SOGoAppointment and to use iCalCalendar instead (v0.9.9) -2005-07-15 Helge Hess - * UIxMailSizeFormatter.m, UIxMailPartMixedViewer.m, UIxMailPartICalViewer.m, UIxMailPartAlternativeViewer.m, UIxMailPartViewer.m: fixed gcc 4.0 warnings (v0.9.8) diff --git a/SOGo/UI/MailPartViewers/GNUmakefile b/SOGo/UI/MailPartViewers/GNUmakefile index 5582b818..abf0961c 100644 --- a/SOGo/UI/MailPartViewers/GNUmakefile +++ b/SOGo/UI/MailPartViewers/GNUmakefile @@ -23,6 +23,8 @@ MailPartViewers_OBJC_FILES += \ UIxMailPartMessageViewer.m \ UIxMailPartICalViewer.m \ UIxMailPartHTMLViewer.m \ + \ + UIxMailPartICalAction.m \ MailPartViewers_RESOURCE_FILES += \ Version \ diff --git a/SOGo/UI/MailPartViewers/UIxMailPartICalAction.m b/SOGo/UI/MailPartViewers/UIxMailPartICalAction.m new file mode 100644 index 00000000..196549d2 --- /dev/null +++ b/SOGo/UI/MailPartViewers/UIxMailPartICalAction.m @@ -0,0 +1,73 @@ +/* + Copyright (C) 2005 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 + +@interface UIxMailPartICalAction : WODirectAction +@end + +#include "common.h" + +@implementation UIxMailPartICalAction + +- (id)redirectToViewerWithError:(NSString *)_error { + WOResponse *r; + NSString *viewURL; + id mail; + + mail = [[self clientObject] valueForKey:@"mailObject"]; + [self logWithFormat:@"MAIL: %@", mail]; + + viewURL = [mail baseURLInContext:[self context]]; + [self logWithFormat:@" url: %@", viewURL]; + + viewURL = [viewURL stringByAppendingString: + [viewURL hasSuffix:@"/"] ? @"view" : @"/view"]; + + if ([_error isNotNull] && [_error length] > 0) { + viewURL = [viewURL stringByAppendingString:@"?error="]; + viewURL = [viewURL stringByAppendingString: + [_error stringByEscapingURL]]; + } + + r = [[self context] response]; + [r setStatus:302 /* moved */]; + [r setHeader:viewURL forKey:@"location"]; + return r; +} + +- (id)changePartStatusAction:(NSString *)_newStatus { + [self logWithFormat:@"TODO: should %@: %@", _newStatus, [self clientObject]]; + return [self redirectToViewerWithError: + [_newStatus stringByAppendingString:@" not implemented!"]]; +} + +- (id)markAcceptedAction { + return [self changePartStatusAction:@"ACCEPTED"]; +} +- (id)markDeclinedAction { + return [self changePartStatusAction:@"DECLINED"]; +} +- (id)markTentativeAction { + return [self changePartStatusAction:@"TENTATIVE"]; +} + +@end /* UIxMailPartICalAction */ diff --git a/SOGo/UI/MailPartViewers/UIxMailPartICalViewer.m b/SOGo/UI/MailPartViewers/UIxMailPartICalViewer.m index 81d842d8..c380e787 100644 --- a/SOGo/UI/MailPartViewers/UIxMailPartICalViewer.m +++ b/SOGo/UI/MailPartViewers/UIxMailPartICalViewer.m @@ -268,4 +268,16 @@ return @"[todo: no organizer set, use 'from']"; } +/* action URLs */ + +- (id)acceptLink { + return [[self pathToAttachmentObject] stringByAppendingString:@"/accept"]; +} +- (id)declineLink { + return [[self pathToAttachmentObject] stringByAppendingString:@"/decline"]; +} +- (id)tentativeLink { + return [[self pathToAttachmentObject] stringByAppendingString:@"/tentative"]; +} + @end /* UIxMailPartICalViewer */ diff --git a/SOGo/UI/MailPartViewers/UIxMailPartLinkViewer.m b/SOGo/UI/MailPartViewers/UIxMailPartLinkViewer.m index 7842fb3f..d9ce05d4 100644 --- a/SOGo/UI/MailPartViewers/UIxMailPartLinkViewer.m +++ b/SOGo/UI/MailPartViewers/UIxMailPartLinkViewer.m @@ -24,47 +24,5 @@ @implementation UIxMailPartLinkViewer -/* URLs */ - -- (NSString *)pathToAttachment { - NSString *url, *n, *pext; - - pext = [self preferredPathExtension]; - - /* path to mail controller object */ - - url = [[self clientObject] baseURLInContext:[self context]]; - if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"]; - - /* mail relative path to body-part */ - - if ([(n = [[self partPath] componentsJoinedByString:@"/"]) isNotNull]) { - /* eg this was nil for a draft containing an HTML message */ - url = [url stringByAppendingString:n]; - } - - if ([pext isNotNull] && [pext length] > 0) { - /* attach extension */ - url = [url stringByAppendingString:@"."]; - url = [url stringByAppendingString:pext]; - } - - /* - If we have an attachment name, we attach it, this is properly handled by - SOGoMailBodyPart. - */ - - n = [self filenameForDisplay]; - if ([n isNotNull] && [n length] > 0) { - url = [url stringByAppendingString:@"/"]; - if (isdigit([n characterAtIndex:0])) - url = [url stringByAppendingString:@"fn-"]; - url = [url stringByAppendingString:[n stringByEscapingURL]]; - - // TODO: should we check for a proper extension? - } - - return url; -} @end /* UIxMailPartLinkViewer */ diff --git a/SOGo/UI/MailPartViewers/UIxMailPartViewer.h b/SOGo/UI/MailPartViewers/UIxMailPartViewer.h index 03a6b073..b539dae2 100644 --- a/SOGo/UI/MailPartViewers/UIxMailPartViewer.h +++ b/SOGo/UI/MailPartViewers/UIxMailPartViewer.h @@ -65,6 +65,11 @@ - (void)resetPathCaches; - (void)resetBodyInfoCaches; +/* part URLs */ + +- (NSString *)pathToAttachmentObject; /* link to SoObject */ +- (NSString *)pathToAttachment; /* download link */ + @end #endif /* __Mailer_UIxMailPartViewer_H__ */ diff --git a/SOGo/UI/MailPartViewers/UIxMailPartViewer.m b/SOGo/UI/MailPartViewers/UIxMailPartViewer.m index 0308ff8f..71442f6a 100644 --- a/SOGo/UI/MailPartViewers/UIxMailPartViewer.m +++ b/SOGo/UI/MailPartViewers/UIxMailPartViewer.m @@ -157,8 +157,10 @@ if ([_st isEqualToString:@"png"]) return @"png"; } else if ([_mt isEqualToString:@"text"]) { - if ([_st isEqualToString:@"plain"]) return @"txt"; - if ([_st isEqualToString:@"xml"]) return @"xml"; + if ([_st isEqualToString:@"plain"]) return @"txt"; + if ([_st isEqualToString:@"xml"]) return @"xml"; + if ([_st isEqualToString:@"calendar"]) return @"ics"; + if ([_st isEqualToString:@"x-vcard"]) return @"vcf"; } else if ([_mt isEqualToString:@"message"]) { if ([_st isEqualToString:@"rfc822"]) return @"mail"; @@ -195,13 +197,79 @@ if ((s = [self filename]) != nil) return s; - + s = [[self partPath] componentsJoinedByString:@"-"]; - return [@"untitled-" stringByAppendingString:s]; + return ([s length] > 0) + ? [@"untitled-" stringByAppendingString:s] + : @"untitled"; } - (NSFormatter *)sizeFormatter { return [UIxMailSizeFormatter sharedMailSizeFormatter]; } +/* URL generation */ + +- (NSString *)pathToAttachmentObject { + /* this points to the SoObject representing the part, no modifications */ + NSString *url, *n, *pext; + + /* path to mail controller object */ + + url = [[self clientObject] baseURLInContext:[self context]]; + if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"]; + + /* mail relative path to body-part */ + + if ([(n = [[self partPath] componentsJoinedByString:@"/"]) isNotNull]) { + /* eg this was nil for a draft containing an HTML message */ + url = [url stringByAppendingString:n]; + } + + /* we currently NEED the extension for SoObject lookup (should be fixed) */ + + pext = [self preferredPathExtension]; + if ([pext isNotNull] && [pext length] > 0) { + /* attach extension */ + if ([url hasSuffix:@"/"]) { + /* this happens if the part is the root-content of the mail */ + url = [url substringToIndex:([url length] - 1)]; + } + url = [url stringByAppendingString:@"."]; + url = [url stringByAppendingString:pext]; + } + + return url; +} + +- (NSString *)pathToAttachment { + /* this generates a more beautiful 'download' URL for a part */ + NSString *url, *fn; + + fn = [self filename]; + + if (![fn isNotNull] || ([fn length] == 0)) + fn = nil; + + /* get basic URL */ + + url = [self pathToAttachmentObject]; + + /* + If we have an attachment name, we attach it, this is properly handled by + SOGoMailBodyPart. + */ + + if (fn != nil) { + if (![url hasSuffix:@"/"]) url = [url stringByAppendingString:@"/"]; + if (isdigit([fn characterAtIndex:0])) + url = [url stringByAppendingString:@"fn-"]; + url = [url stringByAppendingString:[fn stringByEscapingURL]]; + + // TODO: should we check for a proper extension? + } + + return url; +} + @end /* UIxMailPartViewer */ diff --git a/SOGo/UI/MailPartViewers/Version b/SOGo/UI/MailPartViewers/Version index 68132b8f..68e2d82e 100644 --- a/SOGo/UI/MailPartViewers/Version +++ b/SOGo/UI/MailPartViewers/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=10 +SUBMINOR_VERSION:=11 # v0.9.0 requires libNGiCal v4.5.53 # v0.9.1 requires libNGMime v4.5.213 diff --git a/SOGo/UI/MailPartViewers/product.plist b/SOGo/UI/MailPartViewers/product.plist index a5002200..7bebf273 100644 --- a/SOGo/UI/MailPartViewers/product.plist +++ b/SOGo/UI/MailPartViewers/product.plist @@ -8,5 +8,24 @@ }; categories = { + SOGoCalendarMailBodyPart = { + methods = { + accept = { + protectedBy = "View"; + actionClass = "UIxMailPartICalAction"; + actionName = "markAccepted"; + }; + decline = { + protectedBy = "View"; + actionClass = "UIxMailPartICalAction"; + actionName = "markDeclined"; + }; + tentative = { + protectedBy = "View"; + actionClass = "UIxMailPartICalAction"; + actionName = "markTentative"; + }; + }; + }; }; } diff --git a/SOGo/UI/Templates/MailPartViewers/UIxMailPartICalViewer.wox b/SOGo/UI/Templates/MailPartViewers/UIxMailPartICalViewer.wox index f11e0dff..00494e4f 100644 --- a/SOGo/UI/Templates/MailPartViewers/UIxMailPartICalViewer.wox +++ b/SOGo/UI/Templates/MailPartViewers/UIxMailPartICalViewer.wox @@ -20,13 +20,33 @@ () + +

+ accept | + decline | + tentative +

+ + + +

+ The event is not in your primary calendar: + add to calendar. +

+
+

- Organizer + Organizer + invites you to participate in a meeting.

@@ -34,7 +54,9 @@

- Organizer + Organizer + is proposing a meeting to the attendees. You receive this mail as a notification, you are not scheduled as a participant.

@@ -45,7 +67,7 @@

- iMIP 'DELETE' requests are not yet supported by SOGo. + iMIP 'REPLY' requests are not yet supported by SOGo.

@@ -71,22 +93,8 @@ - - TODO: Storage: - - - - - - - - - - - -
- +