2004-10-27 Helge Hess <helge.hess@opengroupware.org>
+ * v0.9.42
+
+ * SOGoDraftObject.m: implements some SOGoMailObject methods
+
+ * SOGoDraftsFolder.m: implemented some draft folder listing
+
* SOGoDraftObject.m: added mail send functionality (v0.9.41)
* SOGoDraftObject.m: added ability to create NGMime objects from draft
*/
@class NSString, NSArray, NSDictionary, NSData, NSException;
-@class NGMimeMessage;
+@class NGMimeMessage, NGImap4Envelope;
@interface SOGoDraftObject : SOGoMailBaseObject
{
- NSString *path;
- NSDictionary *info; /* stores the envelope information */
+ NSString *path;
+ NSDictionary *info; /* stores the envelope information */
+ NGImap4Envelope *envelope;
}
/* contents */
- (NSException *)delete;
+/* fake being a SOGoMailObject */
+
+- (id)fetchParts:(NSArray *)_parts;
+
@end
#endif /* __Mailer_SOGoDraftObject_H__ */
#include <NGMime/NGMimeFileData.h>
#include <NGMime/NGMimeMultipartBody.h>
#include <NGMime/NGMimeType.h>
+#include <NGImap4/NGImap4Envelope.h>
+#include <NGImap4/NGImap4EnvelopeAddress.h>
#include <NGExtensions/NSFileManager+Extensions.h>
#include "common.h"
}
- (void)dealloc {
+ [self->envelope release];
[self->info release];
[self->path release];
[super dealloc];
return [NSNumber numberWithBool:YES]; /* delete worked out ... */
}
+/* fake being a SOGoMailObject */
+
+- (id)fetchParts:(NSArray *)_parts {
+ return [NSDictionary dictionaryWithObject:self forKey:@"fetch"];
+}
+
+- (NSString *)uid {
+ return [self nameInContainer];
+}
+- (NSArray *)flags {
+ static NSArray *seenFlags = nil;
+ seenFlags = [[NSArray alloc] initWithObjects:@"seen", nil];
+ return seenFlags;
+}
+- (unsigned)size {
+ return 0;
+}
+
+- (NSArray *)imap4EnvelopeAddressesForStrings:(NSArray *)_emails {
+ NSMutableArray *ma;
+ unsigned i, count;
+
+ if (_emails == nil)
+ return nil;
+ if ((count = [_emails count]) == 0)
+ return [NSArray array];
+
+ ma = [NSMutableArray arrayWithCapacity:count];
+ for (i = 0; i < count; i++) {
+ NGImap4EnvelopeAddress *envaddr;
+
+ envaddr = [[NGImap4EnvelopeAddress alloc]
+ initWithString:[_emails objectAtIndex:i]];
+ if ([envaddr isNotNull])
+ [ma addObject:envaddr];
+ [envaddr release];
+ }
+ return ma;
+}
+
+- (NGImap4Envelope *)envelope {
+ NSDictionary *lInfo;
+ NSString *tmp;
+
+ if (self->envelope != nil)
+ return self->envelope;
+ if ((lInfo = [self fetchInfo]) == nil)
+ return nil;
+
+ self->envelope = [[NGImap4Envelope alloc] init];
+
+ self->envelope->msgId = [[self nameInContainer] copy];
+ self->envelope->subject = [[lInfo objectForKey:@"subject"] copy];
+
+ self->envelope->from =
+ [[NGImap4EnvelopeAddress alloc] initWithString:[self sender]];
+
+ if ([(tmp = [lInfo objectForKey:@"replyTo"]) length] > 0) {
+ self->envelope->replyTo =
+ [[NGImap4EnvelopeAddress alloc] initWithString:tmp];
+ }
+
+ self->envelope->to = [[self imap4EnvelopeAddressesForStrings:
+ [lInfo objectForKey:@"to"]] copy];
+ self->envelope->cc = [[self imap4EnvelopeAddressesForStrings:
+ [lInfo objectForKey:@"cc"]] copy];
+ self->envelope->bcc = [[self imap4EnvelopeAddressesForStrings:
+ [lInfo objectForKey:@"bcc"]] copy];
+ return self->envelope;
+}
+
/* debugging */
- (BOOL)isDebuggingEnabled {
return allUids;
}
- (NSArray *)fetchUIDs:(NSArray *)_uids parts:(NSArray *)_parts {
- [self logWithFormat:@"TODO: fetch uids (parts=%@): %@", _parts, _uids];
- return [NSArray array];
+ /* FLAGS, ENVELOPE, RFC822.SIZE */
+ NSMutableArray *drafts;
+ unsigned i, count;
+
+ if (_uids == nil)
+ return nil;
+ if ((count = [_uids count]) == 0)
+ return [NSArray array];
+
+ drafts = [NSMutableArray arrayWithCapacity:count];
+ for (i = 0; i < count; i++) {
+ SOGoDraftObject *draft;
+ id parts;
+
+ draft = [self lookupName:[_uids objectAtIndex:i] inContext:nil acquire:NO];
+ if (![draft isNotNull] || [draft isKindOfClass:[NSException class]])
+ continue;
+
+ parts = [draft fetchParts:_parts];
+ if ([parts isNotNull])
+ [drafts addObject:parts];
+ }
+
+ return drafts;
}
/* name lookup */
# Version file
-SUBMINOR_VERSION:=41
+SUBMINOR_VERSION:=42
# v0.9.51 requires NGMime v4.3.190
# v0.9.35 requires SOGoLogic v0.9.24
2004-10-27 Helge Hess <helge.hess@opengroupware.org>
- * v0.9.49
+ * UIxMailEditor.m: default method returns a redirect to 'edit', added
+ 'delete' action and button (v0.9.51)
+
+ * v0.9.50
* UIxMailEditor.m: send mail using draft object
reason:@"failed to store draft object on server!"];
}
+- (id)defaultAction {
+ return [self redirectToLocation:@"edit"];
+}
+
- (id)editAction {
[self logWithFormat:@"edit action, load content from: %@",
[self clientObject]];
- (id)sendAction {
NSException *error;
+ NSString *mailPath;
/* first, save form data */
if (![self _saveFormInfo])
return [self failedToSaveFormResponse];
+ /* save mail to file (so that we can upload the mail to Cyrus */
+
+ mailPath = [[self clientObject] saveMimeMessageToTemporaryFile];
+
/* then, send mail */
- if ((error = [[self clientObject] sendMail]) != nil) {
+ if ((error = [[self clientObject] sendMimeMessageAtPath:mailPath]) != nil) {
// TODO: improve error handling
+ [[NSFileManager defaultManager] removeFileAtPath:mailPath handler:nil];
return error;
}
/* finally store in Sent */
- [self logWithFormat:@"TODO: store mail in Sent folder ..."];
+ [self logWithFormat:@"TODO: store mail in Sent folder: %@", mailPath];
+#if 0
+ [[NSFileManager defaultManager] removeFileAtPath:mailPath handler:nil];
+#endif
+ mailPath = nil;
/* delete draft */
return self;
}
+- (id)deleteAction {
+ NSException *error;
+
+ if ((error = [[self clientObject] delete]) != nil)
+ return error;
+
+ return nil;
+}
+
@end /* UIxMailEditor */
return true;
}
+function clickedEditorDelete(sender) {
+ document.pageform.action="delete";
+ document.pageform.submit();
+ window.close();
+ return true;
+}
+
/* addressbook helpers */
function openAnais(sender) {
{ link = "#";
onclick = "clickedEditorSave(this);return false;";
cssClass = "tbicon_save"; label = "Save"; },
+ { link = "#";
+ onclick = "clickedEditorDelete(this);return false;";
+ cssClass = "tbicon_delete"; label = "Delete"; },
)
);
};
pageName = "UIxMailEditor";
actionName = "save";
};
+ delete = {
+ protectedBy = "View";
+ pageName = "UIxMailEditor";
+ actionName = "delete";
+ };
viewAttachments = {
protectedBy = "View";