From 0176350dbcffbc1205148fae29706ca0b36ac01a Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 27 May 2010 17:09:02 +0000 Subject: [PATCH] See ChangeLog. Monotone-Parent: fdc663e746cda0a1106c97d2d9af95b6eb0d1b40 Monotone-Revision: 56738c967d1f191a027f45f12a017405441e69ca Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2010-05-27T17:09:02 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 +++- UI/Common/WODirectAction+SOGo.h | 5 ++- UI/Common/WODirectAction+SOGo.m | 52 ++++++++++++++++++++++++++++++++ UI/MailerUI/UIxMailListActions.h | 8 +++-- UI/MailerUI/UIxMailListActions.m | 10 +++--- UI/MailerUI/product.plist | 6 ++-- 6 files changed, 76 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f730a5a6..02ddef494 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,12 +7,16 @@ 2010-05-27 Francis Lachapelle * UI/MailerUI/UIxMailListActions.m: renamed from - UIxMailListview.m. Associated .wox was removed. + UIxMailListview.m. Associated .wox was removed and converted to a + WODirectAction. (-getSortedUIDsAction): new method that returns a JSON array with all the messages UIDs of the mailbox, sorted as requested. (-getHeadersAction): new method that returns a JSON dictionary of the headers of requested messages UIDs. + * UI/Common/WODirectAction+SOGo.m (-pageResourceManager, + -urlForResourceFilename): methods copied from UIxComponent. + * UI/WebServerResources/SOGoDataTable.js: new interface to add "live loading" to a table. diff --git a/UI/Common/WODirectAction+SOGo.h b/UI/Common/WODirectAction+SOGo.h index e11f91f99..a2e90cb32 100644 --- a/UI/Common/WODirectAction+SOGo.h +++ b/UI/Common/WODirectAction+SOGo.h @@ -26,7 +26,7 @@ #import @class NSString; -@class WOResponse; +@class WOResponse, WOResourceManager; @interface WODirectAction (SOGoExtension) @@ -40,6 +40,9 @@ - (NSString *) labelForKey: (NSString *) _str; +- (WOResourceManager *) pageResourceManager; +- (NSString *) urlForResourceFilename: (NSString *) filename; + @end #endif /* WODIRECTACTION_SOGO_H */ diff --git a/UI/Common/WODirectAction+SOGo.m b/UI/Common/WODirectAction+SOGo.m index 8eec9cd75..a135ca641 100644 --- a/UI/Common/WODirectAction+SOGo.m +++ b/UI/Common/WODirectAction+SOGo.m @@ -22,11 +22,13 @@ #import +#import #import #import #import #import +#import #import #import @@ -119,4 +121,54 @@ return label; } + +- (WOResourceManager *) pageResourceManager +{ + WOResourceManager *rm; + + if ((rm = [[context page] resourceManager]) == nil) + rm = [[WOApplication application] resourceManager]; + + return rm; +} + +- (NSString *) urlForResourceFilename: (NSString *) filename +{ + static NSMutableDictionary *pageToURL = nil; + NSString *url; + WOComponent *page; + WOResourceManager *rm; + NSBundle *pageBundle; + + if (filename) + { + if (!pageToURL) + pageToURL = [[NSMutableDictionary alloc] initWithCapacity: 32]; + + url = [pageToURL objectForKey: filename]; + if (!url) + { + rm = [self pageResourceManager]; + page = [context page]; + pageBundle = [NSBundle bundleForClass: [page class]]; + url = [rm urlForResourceNamed: filename + inFramework: [pageBundle bundlePath] + languages: nil + request: [context request]]; + if (!url) + url = @""; + else + if ([url hasPrefix: @"http"]) + url = [url hostlessURL]; + [pageToURL setObject: url forKey: filename]; + } + +// NSLog (@"url for '%@': '%@'", filename, url); + } + else + url = @""; + + return url; +} + @end diff --git a/UI/MailerUI/UIxMailListActions.h b/UI/MailerUI/UIxMailListActions.h index dbe4be6af..9feab0835 100644 --- a/UI/MailerUI/UIxMailListActions.h +++ b/UI/MailerUI/UIxMailListActions.h @@ -22,13 +22,13 @@ #ifndef UIXMAILLISTACTIONS_H #define UIXMAILLISTACTIONS_H -#import +#import @class NSDictionary; @class EOQualifier; @class SOGoDateFormatter; -@interface UIxMailListActions : UIxComponent +@interface UIxMailListActions : WODirectAction { NSArray *sortedUIDs; /* we always need to retrieve all anyway! */ NSArray *messages; @@ -45,6 +45,10 @@ - (EOQualifier *) searchQualifier; - (NSString *) msgLabels; +- (id) getMailAction; +- (id ) getSortedUIDsAction; +- (id ) getHeadersAction; + @end #endif /* UIXMAILLISTACTIONS_H */ diff --git a/UI/MailerUI/UIxMailListActions.m b/UI/MailerUI/UIxMailListActions.m index b732f9c40..bfa6914cb 100644 --- a/UI/MailerUI/UIxMailListActions.m +++ b/UI/MailerUI/UIxMailListActions.m @@ -34,6 +34,7 @@ #import #import +#import #import #import #import @@ -56,19 +57,20 @@ #import #import -#import "WOContext+UIxMailer.h" +#import +#import "WOContext+UIxMailer.h" #import "UIxMailListActions.h" @implementation UIxMailListActions -- (id) init +- (id) initWithRequest: (WORequest *) newRequest { SOGoUser *user; - if ((self = [super init])) + if ((self = [super initWithRequest: newRequest])) { - user = [context activeUser]; + user = [[self context] activeUser]; ASSIGN (dateFormatter, [user dateFormatterInContext: context]); ASSIGN (userTimeZone, [[user userDefaults] timeZone]); folderType = 0; diff --git a/UI/MailerUI/product.plist b/UI/MailerUI/product.plist index 67d3abe96..21a9a4e66 100644 --- a/UI/MailerUI/product.plist +++ b/UI/MailerUI/product.plist @@ -79,17 +79,17 @@ methods = { getMail = { protectedBy = "View"; - pageName = "UIxMailListActions"; + actionClass = "UIxMailListActions"; actionName = "getMail"; }; uids = { protectedBy = ""; - pageName = "UIxMailListActions"; + actionClass = "UIxMailListActions"; actionName = "getSortedUIDs"; }; headers = { protectedBy = ""; - pageName = "UIxMailListActions"; + actionClass = "UIxMailListActions"; actionName = "getHeaders"; }; subscribe = {