sogo/OpenChange/SOGoDraftObject+MAPIStore.m
Wolfgang Sourdeau 8caad635f5 Monotone-Parent: 88dbd2a21bc32921ce7ccfe80336f902eb022b0e
Monotone-Revision: 17b50baf79da6da49bc8ce0e951e73f58eaa2cab

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-11-24T19:28:45
Monotone-Branch: ca.inverse.sogo
2010-11-24 19:28:45 +00:00

114 lines
3.2 KiB
Objective-C

/* SOGoDraftObject+MAPIStore.m - this file is part of SOGo
*
* Copyright (C) 2010 Wolfgang Sourdeau
*
* Author: Wolfgang Sourdeau <root@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSString.h>
#import <NGObjWeb/WOContext+SoObjects.h>
#import <SOGo/NSArray+Utilities.h>
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/SOGoUser.h>
#import "MAPIStoreTypes.h"
#import "SOGoDraftObject+MAPIStore.h"
@implementation SOGoDraftObject (MAPIStoreMessage)
- (void) setMAPIProperties: (NSDictionary *) properties
{
static NSString *recIds[] = { @"to", @"cc", @"bcc" };
NSArray *list;
NSDictionary *recipients, *identity;
NSMutableDictionary *newHeaders;
NSString *recId, *body;
NSUInteger count;
id value;
// MAPIStoreDumpMessageProperties (properties);
newHeaders = [NSMutableDictionary dictionaryWithCapacity: 6];
recipients = [properties objectForKey: @"recipients"];
for (count = 0; count < 3; count++)
{
recId = recIds[count];
list = [recipients objectForKey: recId];
if ([list count] > 0)
[newHeaders setObject: [list objectsForKey: @"email"
notFoundMarker: nil]
forKey: recId];
}
/*
message properties (20):
recipients: {to = ({email = "wsourdeau@inverse.ca"; fullName = "wsourdeau@inverse.ca"; }); }
0x1000001f (PR_BODY_UNICODE): text body (GSCBufferString)
0x0037001f (PR_SUBJECT_UNICODE): Test without (GSCBufferString)
0x30070040 (PR_CREATION_TIME): 2010-11-24 13:45:38 -0500 (NSCalendarDate)
e)
2010-11-24 13:45:38.715 samba[25685] 0x0e62000b (PR_URL_COMP_NAME_SET):
0 (NSIntNumber) */
value = [properties objectForKey: MAPIPropertyNumber (PR_SUBJECT_UNICODE)];
if (value)
[newHeaders setObject: value forKey: @"subject"];
identity = [[context activeUser] primaryIdentity];
[newHeaders setObject: [identity keysWithFormat: @"%{fullName} <%{email}>"]
forKey: @"from"];
[self setHeaders: newHeaders];
value = [properties objectForKey: MAPIPropertyNumber (PR_HTML)];
if (value)
{
[self setIsHTML: YES];
// TODO: encoding
body = [[NSString alloc] initWithData: value
encoding: NSUTF8StringEncoding];
[self setText: body];
[body release];
}
else
{
value = [properties objectForKey: MAPIPropertyNumber (PR_BODY_UNICODE)];
if (value)
{
[self setIsHTML: NO];
[self setText: value];
}
}
}
- (void) MAPISubmit
{
[self sendMail];
}
- (void) MAPISave
{
[self save];
}
@end