2004-11-09 Helge Hess <helge.hess@skyrix.com>
+ * added support for toggling mail flags (v0.9.52)
+
* moved all tree navigation code to UIxMailTree (v0.9.51)
* SOGoMailBaseObject.m, SOGoMailAccounts.m: moved tree code to separate
- (NSData *)fetchContentOfBodyPart:(NSString *)_partId
atURL:(NSURL *)_url password:(NSString *)_pwd;
+- (NSException *)addFlags:(id)_f toURL:(NSURL *)_u password:(NSString *)_p;
+- (NSException *)removeFlags:(id)_f toURL:(NSURL *)_u password:(NSString *)_p;
+
/* managing folders */
- (NSException *)createMailbox:(NSString *)_mailbox atURL:(NSURL *)_url
if (![_url isNotNull]) return nil;
-
if ((client = [self imap4ClientForURL:_url password:_pwd]) == nil)
return nil;
return result;
}
+- (NSException *)addOrRemove:(BOOL)_flag flags:(id)_f
+ toURL:(NSURL *)_url password:(NSString *)_p
+{
+ NGImap4Client *client;
+ id result;
+
+ if (![_url isNotNull]) return nil;
+ if (![_f isNotNull]) return nil;
+
+ if ((client = [self imap4ClientForURL:_url password:_p]) == nil)
+ return nil;
+
+ if (![_f isKindOfClass:[NSArray class]])
+ _f = [NSArray arrayWithObjects:&_f count:1];
+
+ result = [client storeUid:[[[_url path] lastPathComponent] intValue]
+ add:[NSNumber numberWithBool:_flag]
+ flags:_f];
+ if (![[result valueForKey:@"result"] boolValue]) {
+ [self logWithFormat:@"DEBUG: fail result %@", result];
+ return [NSException exceptionWithHTTPStatus:500 /* server error */
+ reason:@"failed to add flag to IMAP4 message"];
+ }
+ /* result contains 'fetch' key with the current flags */
+ return nil;
+}
+- (NSException *)addFlags:(id)_f toURL:(NSURL *)_u password:(NSString *)_p {
+ return [self addOrRemove:YES flags:_f toURL:_u password:_p];
+}
+- (NSException *)removeFlags:(id)_f toURL:(NSURL *)_u password:(NSString *)_p {
+ return [self addOrRemove:NO flags:_f toURL:_u password:_p];
+}
+
/* managing folders */
- (BOOL)isPermissionDeniedResult:(id)_result {
would address the MIME part 1.2.3 of the mail 12345 in the folder INBOX.
*/
-@class NSString, NSArray, NSCalendarDate;
+@class NSData, NSString, NSArray, NSCalendarDate, NSException;
@class NGImap4Envelope, NGImap4EnvelopeAddress;
@interface SOGoMailObject : SOGoMailBaseObject
- (id)bodyStructure;
- (id)lookupInfoForBodyPart:(NSArray *)_path;
+/* content */
+
+- (NSData *)content;
+- (NSString *)contentAsString;
+
+/* flags */
+
+- (NSException *)addFlags:(id)_f;
+- (NSException *)removeFlags:(id)_f;
+
@end
#endif /* __Mailer_SOGoMailObject_H__ */
return [info isNotNull] ? info : nil;
}
+/* content */
+
- (NSData *)content {
NSData *content;
id result, fullResult;
return [s autorelease];
}
+/* flags */
+
+- (NSException *)addFlags:(id)_flags {
+ return [[self mailManager] addFlags:_flags toURL:[self imap4URL]
+ password:[self imap4Password]];
+}
+- (NSException *)removeFlags:(id)_flags {
+ return [[self mailManager] removeFlags:_flags toURL:[self imap4URL]
+ password:[self imap4Password]];
+}
+
/* name lookup */
- (BOOL)isBodyPartKey:(NSString *)_key inContext:(id)_ctx {
# Version file
-SUBMINOR_VERSION:=51
+SUBMINOR_VERSION:=52
# v0.9.44 requires NGMime v4.3.194
# v0.9.41 requires NGMime v4.3.190
2004-11-09 Helge Hess <helge.hess@skyrix.com>
+ * UIxMailListView.m: added support for toggling read/unread flags
+ (v0.9.61)
+
* UIxMailTree.m: added tree navigation code from SoObjects (v0.9.60)
* UIxMailTree.m: removed unused code (v0.9.59)
#include "common.h"
#include <NGImap4/NGImap4Client.h>
#include <SOGo/SoObjects/Mailer/SOGoMailFolder.h>
+#include <SOGo/SoObjects/Mailer/SOGoMailObject.h>
@implementation UIxMailListView
return script;
}
+/* active message */
+
+- (SOGoMailObject *)lookupActiveMessage {
+ NSString *uid;
+
+ if ((uid = [[[self context] request] formValueForKey:@"uid"]) == nil)
+ return nil;
+
+ return [[self clientObject] lookupName:uid inContext:[self context]
+ acquire:NO];
+}
+
/* actions */
- (id)defaultAction {
}
- (id)markMessageUnreadAction {
- [self logWithFormat:@"TODO: mark message unread!"];
+ NSException *error;
+
+ if ((error = [[self lookupActiveMessage] removeFlags:@"seen"]) != nil)
+ // TODO: improve error handling
+ return error;
+
return [self redirectToLocation:@"view"];
}
- (id)markMessageReadAction {
- [self logWithFormat:@"TODO: mark message read!"];
+ NSException *error;
+
+ if ((error = [[self lookupActiveMessage] addFlags:@"seen"]) != nil)
+ // TODO: improve error handling
+ return error;
+
return [self redirectToLocation:@"view"];
}
# $Id$
-SUBMINOR_VERSION:=60
+SUBMINOR_VERSION:=61
# v0.9.50 requires NGMime v4.3.190
# v0.9.43 requires NGObjWeb v4.3.73
}
- (NSArray *)participants {
- if (self->participants)
+ if (self->participants != nil)
return self->participants;
self->participants = [[self _filteredAttendeesThinkingOfPersons:YES] retain];