2010-10-01 20:54:30 +02:00
|
|
|
/* MAPIStoreMailContext.m - this file is part of SOGo
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Inverse inc.
|
|
|
|
*
|
|
|
|
* Author: Wolfgang Sourdeau <wsourdeau@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
|
2010-10-18 14:57:31 +02:00
|
|
|
* the Free Software Foundation; either version 3, or (at your option)
|
2010-10-01 20:54:30 +02:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2010-11-06 00:21:09 +01:00
|
|
|
#import <Foundation/NSCalendarDate.h>
|
|
|
|
|
2010-10-01 20:54:30 +02:00
|
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
|
|
|
|
2010-10-14 15:23:46 +02:00
|
|
|
#import <NGImap4/NGImap4EnvelopeAddress.h>
|
|
|
|
|
2010-10-01 20:54:30 +02:00
|
|
|
#import <Mailer/SOGoMailFolder.h>
|
|
|
|
#import <Mailer/SOGoMailObject.h>
|
|
|
|
|
2010-10-14 18:39:52 +02:00
|
|
|
#import <SOGo/NSArray+Utilities.h>
|
|
|
|
#import <SOGo/SOGoUserFolder.h>
|
|
|
|
|
2010-10-01 20:54:30 +02:00
|
|
|
#import "MAPIApplication.h"
|
|
|
|
#import "MAPIStoreAuthenticator.h"
|
2010-11-22 17:03:30 +01:00
|
|
|
#import "MAPIStoreMapping.h"
|
2010-11-22 17:12:41 +01:00
|
|
|
#import "MAPIStoreTypes.h"
|
2010-10-14 18:39:52 +02:00
|
|
|
#import "NSData+MAPIStore.h"
|
2010-11-19 21:58:42 +01:00
|
|
|
#import "NSCalendarDate+MAPIStore.h"
|
2010-10-01 20:54:30 +02:00
|
|
|
#import "NSString+MAPIStore.h"
|
|
|
|
|
|
|
|
#import "MAPIStoreMailContext.h"
|
|
|
|
|
|
|
|
#undef DEBUG
|
2010-10-14 18:39:52 +02:00
|
|
|
#include <stdbool.h>
|
2010-10-14 15:23:46 +02:00
|
|
|
#include <gen_ndr/exchange.h>
|
2010-10-01 20:54:30 +02:00
|
|
|
#include <mapistore/mapistore.h>
|
2010-10-14 15:23:46 +02:00
|
|
|
#include <mapistore/mapistore_errors.h>
|
2010-10-01 20:54:30 +02:00
|
|
|
|
|
|
|
@implementation MAPIStoreMailContext
|
|
|
|
|
2010-11-22 22:33:02 +01:00
|
|
|
+ (NSString *) MAPIModuleName
|
|
|
|
{
|
|
|
|
return @"mail";
|
|
|
|
}
|
|
|
|
|
2010-11-22 17:03:30 +01:00
|
|
|
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
|
|
|
{
|
|
|
|
[mapping registerURL: @"sogo://openchange:openchange@mail/folderINBOX"
|
|
|
|
withID: 0x160001];
|
|
|
|
[mapping registerURL: @"sogo://openchange:openchange@mail/folderxxxc0001"
|
|
|
|
withID: 0x0c0001];
|
|
|
|
}
|
|
|
|
|
2010-10-01 20:54:30 +02:00
|
|
|
- (void) setupModuleFolder
|
|
|
|
{
|
2010-10-01 22:35:29 +02:00
|
|
|
id userFolder, accountsFolder;
|
|
|
|
|
2010-11-18 23:29:01 +01:00
|
|
|
userFolder = [SOGoUserFolder objectWithName: [authenticator username]
|
|
|
|
inContainer: MAPIApp];
|
2010-12-01 17:34:41 +01:00
|
|
|
[parentFoldersBag addObject: userFolder];
|
2010-10-01 22:35:29 +02:00
|
|
|
[woContext setClientObject: userFolder];
|
|
|
|
|
|
|
|
accountsFolder = [userFolder lookupName: @"Mail"
|
|
|
|
inContext: woContext
|
|
|
|
acquire: NO];
|
2010-12-01 17:34:41 +01:00
|
|
|
[parentFoldersBag addObject: accountsFolder];
|
2010-10-01 22:35:29 +02:00
|
|
|
[woContext setClientObject: accountsFolder];
|
|
|
|
|
|
|
|
moduleFolder = [accountsFolder lookupName: @"0"
|
|
|
|
inContext: woContext
|
|
|
|
acquire: NO];
|
|
|
|
[moduleFolder retain];
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|
|
|
|
|
2010-10-01 23:24:15 +02:00
|
|
|
- (NSArray *) getFolderMessageKeys: (SOGoFolder *) folder
|
|
|
|
{
|
|
|
|
return [(SOGoMailFolder *) folder toOneRelationshipKeys];
|
|
|
|
}
|
|
|
|
|
2010-11-30 17:17:50 +01:00
|
|
|
// - (enum MAPISTATUS) getCommonTableChildproperty: (void **) data
|
2010-10-01 20:54:30 +02:00
|
|
|
// atURL: (NSString *) childURL
|
2010-11-30 17:17:50 +01:00
|
|
|
// withTag: (enum MAPITAGS) proptag
|
2010-10-01 20:54:30 +02:00
|
|
|
// inFolder: (SOGoFolder *) folder
|
|
|
|
// withFID: (uint64_t) fid
|
|
|
|
// {
|
|
|
|
// int rc;
|
|
|
|
|
|
|
|
// rc = MAPI_E_SUCCESS;
|
|
|
|
// switch (proptag) {
|
|
|
|
// default:
|
|
|
|
// rc = [super getCommonTableChildproperty: data
|
|
|
|
// atURL: childURL
|
|
|
|
// withTag: proptag
|
|
|
|
// inFolder: folder
|
|
|
|
// withFID: fid];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return rc;
|
|
|
|
// }
|
|
|
|
|
2010-11-30 17:17:50 +01:00
|
|
|
- (enum MAPISTATUS) getMessageTableChildproperty: (void **) data
|
|
|
|
atURL: (NSString *) childURL
|
|
|
|
withTag: (enum MAPITAGS) proptag
|
|
|
|
inFolder: (SOGoFolder *) folder
|
|
|
|
withFID: (uint64_t) fid
|
2010-10-01 20:54:30 +02:00
|
|
|
{
|
2010-10-14 15:23:46 +02:00
|
|
|
id child;
|
2010-11-19 21:58:42 +01:00
|
|
|
NSCalendarDate *offsetDate;
|
2010-11-30 17:17:50 +01:00
|
|
|
enum MAPISTATUS rc;
|
2010-10-01 22:35:29 +02:00
|
|
|
|
|
|
|
rc = MAPI_E_SUCCESS;
|
|
|
|
switch (proptag)
|
|
|
|
{
|
|
|
|
case PR_ICON_INDEX: // TODO
|
2010-10-06 16:27:09 +02:00
|
|
|
/* read mail, see http://msdn.microsoft.com/en-us/library/cc815472.aspx */
|
|
|
|
*data = MAPILongValue (memCtx, 0x00000100);
|
2010-10-01 22:35:29 +02:00
|
|
|
break;
|
2010-10-13 17:45:36 +02:00
|
|
|
case PR_CONVERSATION_TOPIC:
|
2010-10-14 18:55:09 +02:00
|
|
|
case PR_CONVERSATION_TOPIC_UNICODE:
|
|
|
|
case PR_SUBJECT:
|
2010-10-01 22:35:29 +02:00
|
|
|
case PR_SUBJECT_UNICODE:
|
|
|
|
child = [self lookupObject: childURL];
|
|
|
|
*data = [[child decodedSubject] asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
|
|
|
case PR_MESSAGE_CLASS_UNICODE:
|
2010-10-06 16:27:09 +02:00
|
|
|
*data = talloc_strdup (memCtx, "IPM.Note");
|
2010-10-01 22:35:29 +02:00
|
|
|
break;
|
2010-10-06 16:27:09 +02:00
|
|
|
case PR_HASATTACH: // TODO
|
|
|
|
*data = MAPIBoolValue (memCtx, NO);
|
2010-10-01 22:35:29 +02:00
|
|
|
break;
|
2010-10-14 23:37:39 +02:00
|
|
|
case PR_CREATION_TIME: // DOUBT
|
|
|
|
case PR_LAST_MODIFICATION_TIME: // DOUBT
|
|
|
|
case PR_LATEST_DELIVERY_TIME: // DOUBT
|
2010-10-01 22:35:29 +02:00
|
|
|
case PR_MESSAGE_DELIVERY_TIME:
|
|
|
|
child = [self lookupObject: childURL];
|
|
|
|
offsetDate = [[child date] addYear: -1 month: 0 day: 0
|
|
|
|
hour: 0 minute: 0 second: 0];
|
|
|
|
*data = [offsetDate asFileTimeInMemCtx: memCtx];
|
2010-10-13 17:45:36 +02:00
|
|
|
// *data = [[child date] asFileTimeInMemCtx: memCtx];
|
2010-10-01 22:35:29 +02:00
|
|
|
break;
|
|
|
|
case PR_MESSAGE_FLAGS: // TODO
|
2010-10-13 17:45:36 +02:00
|
|
|
// NSDictionary *coreInfos;
|
|
|
|
// NSArray *flags;
|
|
|
|
// child = [self lookupObject: childURL];
|
|
|
|
// coreInfos = [child fetchCoreInfos];
|
|
|
|
// flags = [coreInfos objectForKey: @"flags"];
|
|
|
|
*data = MAPILongValue (memCtx, 0x02 | 0x20); // fromme + unmodified
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PR_FLAG_STATUS: // TODO
|
2010-10-01 22:35:29 +02:00
|
|
|
case PR_SENSITIVITY: // TODO
|
2010-10-14 23:37:39 +02:00
|
|
|
case PR_ORIGINAL_SENSITIVITY: // TODO
|
2010-10-13 17:45:36 +02:00
|
|
|
case PR_FOLLOWUP_ICON: // TODO
|
2010-10-06 16:27:09 +02:00
|
|
|
*data = MAPILongValue (memCtx, 0);
|
2010-10-01 22:35:29 +02:00
|
|
|
break;
|
2010-10-13 17:45:36 +02:00
|
|
|
|
|
|
|
case PR_EXPIRY_TIME: // TODO
|
|
|
|
case PR_REPLY_TIME:
|
2010-11-19 21:58:42 +01:00
|
|
|
*data = [[NSCalendarDate date] asFileTimeInMemCtx: memCtx];
|
2010-10-01 22:35:29 +02:00
|
|
|
break;
|
2010-10-14 18:39:52 +02:00
|
|
|
|
|
|
|
case PR_BODY:
|
2010-10-14 18:52:11 +02:00
|
|
|
case PR_BODY_UNICODE:
|
2010-10-14 18:39:52 +02:00
|
|
|
{
|
|
|
|
NSMutableArray *keys;
|
|
|
|
NSArray *acceptedTypes;
|
|
|
|
|
|
|
|
child = [self lookupObject: childURL];
|
2010-10-14 23:37:39 +02:00
|
|
|
|
|
|
|
acceptedTypes = [NSArray arrayWithObjects: @"text/plain",
|
|
|
|
@"text/html", nil];
|
2010-10-14 18:39:52 +02:00
|
|
|
keys = [NSMutableArray array];
|
|
|
|
[child addRequiredKeysOfStructure: [child bodyStructure]
|
|
|
|
path: @"" toArray: keys
|
|
|
|
acceptedTypes: acceptedTypes];
|
2010-10-14 23:37:39 +02:00
|
|
|
if ([keys count] == 0 || [keys count] == 2)
|
2010-10-14 18:39:52 +02:00
|
|
|
{
|
2010-10-14 23:37:39 +02:00
|
|
|
*data = NULL;
|
2010-10-15 19:24:09 +02:00
|
|
|
rc = MAPI_E_NOT_FOUND;
|
2010-10-14 18:39:52 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-14 23:37:39 +02:00
|
|
|
acceptedTypes = [NSArray arrayWithObject: @"text/plain"];
|
|
|
|
[keys removeAllObjects];
|
|
|
|
[child addRequiredKeysOfStructure: [child bodyStructure]
|
|
|
|
path: @"" toArray: keys
|
|
|
|
acceptedTypes: acceptedTypes];
|
|
|
|
if ([keys count] > 0)
|
|
|
|
{
|
|
|
|
id result;
|
|
|
|
NSData *content;
|
|
|
|
NSString *key, *stringContent;
|
|
|
|
|
|
|
|
result = [child fetchParts: [keys objectsForKey: @"key"
|
|
|
|
notFoundMarker: nil]];
|
|
|
|
result = [[result valueForKey: @"RawResponse"] objectForKey: @"fetch"];
|
|
|
|
key = [[keys objectAtIndex: 0] objectForKey: @"key"];
|
|
|
|
content = [[result objectForKey: key] objectForKey: @"data"];
|
2010-11-30 22:07:59 +01:00
|
|
|
if ([content length] > 3999)
|
|
|
|
{
|
|
|
|
[self registerValue: content
|
|
|
|
asProperty: proptag
|
|
|
|
forURL: childURL];
|
|
|
|
*data = NULL;
|
|
|
|
rc = MAPI_E_NOT_ENOUGH_MEMORY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stringContent = [[NSString alloc] initWithData: content
|
|
|
|
encoding: NSISOLatin1StringEncoding];
|
2010-10-14 23:37:39 +02:00
|
|
|
|
2010-11-30 22:07:59 +01:00
|
|
|
// *data = NULL;
|
|
|
|
// rc = MAPI_E_NOT_FOUND;
|
|
|
|
*data = [stringContent asUnicodeInMemCtx: memCtx];
|
|
|
|
}
|
2010-10-14 23:37:39 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-10-15 19:24:09 +02:00
|
|
|
rc = MAPI_E_NOT_FOUND;
|
2010-10-14 23:37:39 +02:00
|
|
|
}
|
2010-10-14 18:39:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2010-10-13 17:45:36 +02:00
|
|
|
|
2010-10-14 18:39:52 +02:00
|
|
|
case PR_HTML:
|
|
|
|
{
|
|
|
|
NSMutableArray *keys;
|
|
|
|
NSArray *acceptedTypes;
|
|
|
|
|
|
|
|
child = [self lookupObject: childURL];
|
|
|
|
|
|
|
|
acceptedTypes = [NSArray arrayWithObject: @"text/html"];
|
|
|
|
keys = [NSMutableArray array];
|
|
|
|
[child addRequiredKeysOfStructure: [child bodyStructure]
|
|
|
|
path: @"" toArray: keys acceptedTypes: acceptedTypes];
|
|
|
|
if ([keys count] > 0)
|
|
|
|
{
|
|
|
|
id result;
|
|
|
|
NSString *key;
|
|
|
|
NSData *content;
|
|
|
|
|
|
|
|
result = [child fetchParts: [keys objectsForKey: @"key"
|
|
|
|
notFoundMarker: nil]];
|
|
|
|
result = [[result valueForKey: @"RawResponse"] objectForKey:
|
|
|
|
@"fetch"];
|
|
|
|
key = [[keys objectAtIndex: 0] objectForKey: @"key"];
|
|
|
|
content = [[result objectForKey: key] objectForKey: @"data"];
|
2010-11-30 17:17:50 +01:00
|
|
|
if ([content length] > 3999)
|
|
|
|
{
|
2010-11-30 22:07:59 +01:00
|
|
|
[self registerValue: content
|
|
|
|
asProperty: proptag
|
|
|
|
forURL: childURL];
|
2010-11-30 17:17:50 +01:00
|
|
|
*data = NULL;
|
2010-11-30 22:07:59 +01:00
|
|
|
rc = MAPI_E_NOT_ENOUGH_MEMORY;
|
2010-11-30 17:17:50 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
*data = [content asBinaryInMemCtx: memCtx];
|
2010-10-14 18:39:52 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*data = NULL;
|
2010-10-15 19:24:09 +02:00
|
|
|
rc = MAPI_E_NOT_FOUND;
|
2010-10-14 18:39:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// *data = NULL;
|
2010-10-15 19:24:09 +02:00
|
|
|
// rc = MAPI_E_NOT_FOUND;
|
2010-10-14 18:39:52 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* We don't handle any RTF content. */
|
|
|
|
case PR_RTF_COMPRESSED:
|
2010-11-30 22:07:59 +01:00
|
|
|
rc = MAPI_E_NOT_ENOUGH_MEMORY;
|
2010-10-14 18:39:52 +02:00
|
|
|
break;
|
2010-10-14 23:37:39 +02:00
|
|
|
case PR_RTF_IN_SYNC:
|
|
|
|
*data = MAPIBoolValue (memCtx, NO);
|
|
|
|
break;
|
2010-10-14 18:39:52 +02:00
|
|
|
|
2010-10-13 17:45:36 +02:00
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
// #define PR_ITEM_TEMPORARY_FLAGS PROP_TAG(PT_LONG , 0x1097) /* 0x10970003 */
|
|
|
|
|
2010-10-13 17:45:36 +02:00
|
|
|
// 36030003 - PR_CONTENT_UNREAD
|
|
|
|
// 36020003 - PR_CONTENT_COUNT
|
|
|
|
// 10970003 -
|
|
|
|
// 81f80003
|
|
|
|
// 10950003
|
|
|
|
// 819d0003
|
|
|
|
// 300b0102
|
|
|
|
// 81fa000b
|
|
|
|
// 00300040
|
|
|
|
// 00150040
|
|
|
|
|
|
|
|
case PR_RECEIVED_BY_NAME:
|
|
|
|
child = [self lookupObject: childURL];
|
|
|
|
*data = [[child to] asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
2010-10-01 22:35:29 +02:00
|
|
|
|
|
|
|
case PR_SENT_REPRESENTING_NAME_UNICODE:
|
|
|
|
child = [self lookupObject: childURL];
|
|
|
|
*data = [[child from] asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
2010-11-30 17:17:50 +01:00
|
|
|
case PR_INTERNET_MESSAGE_ID:
|
2010-10-01 22:35:29 +02:00
|
|
|
case PR_INTERNET_MESSAGE_ID_UNICODE:
|
|
|
|
child = [self lookupObject: childURL];
|
|
|
|
*data = [[child messageId] asUnicodeInMemCtx: memCtx];
|
|
|
|
break;
|
2010-10-13 17:45:36 +02:00
|
|
|
|
|
|
|
case PR_READ_RECEIPT_REQUESTED: // TODO
|
|
|
|
*data = MAPIBoolValue (memCtx, NO);
|
2010-10-14 17:13:51 +02:00
|
|
|
break;
|
2010-10-14 23:37:39 +02:00
|
|
|
|
|
|
|
/* BOOL */
|
|
|
|
case PR_ALTERNATE_RECIPIENT_ALLOWED:
|
|
|
|
case PR_AUTO_FORWARDED:
|
|
|
|
case PR_DL_EXPANSION_PROHIBITED:
|
|
|
|
case PR_RESPONSE_REQUESTED:
|
|
|
|
case PR_REPLY_REQUESTED:
|
|
|
|
case PR_DELETE_AFTER_SUBMIT:
|
|
|
|
case PR_PROCESSED:
|
|
|
|
case PR_ORIGINATOR_DELIVERY_REPORT_REQUESTED:
|
|
|
|
case PR_RECIPIENT_REASSIGNMENT_PROHIBITED:
|
2010-10-15 19:24:09 +02:00
|
|
|
rc = MAPI_E_NOT_FOUND;
|
2010-10-14 23:37:39 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* PT_SYSTIME */
|
|
|
|
case PR_START_DATE:
|
|
|
|
case PR_END_DATE:
|
|
|
|
case PR_ACTION_DATE:
|
|
|
|
case PR_FLAG_COMPLETE:
|
|
|
|
case PR_DEFERRED_DELIVERY_TIME:
|
|
|
|
case PR_REPORT_TIME:
|
|
|
|
case PR_CLIENT_SUBMIT_TIME:
|
|
|
|
case PR_DEFERRED_SEND_TIME:
|
|
|
|
case PR_ORIGINAL_SUBMIT_TIME:
|
2010-10-15 19:24:09 +02:00
|
|
|
rc = MAPI_E_NOT_FOUND;
|
|
|
|
break;
|
2010-10-14 23:37:39 +02:00
|
|
|
|
|
|
|
/* PT_BINARY */
|
|
|
|
case PR_CONVERSATION_KEY:
|
|
|
|
case PR_ORIGINALLY_INTENDED_RECIPIENT_NAME:
|
|
|
|
case PR_PARENT_KEY:
|
|
|
|
case PR_REPORT_TAG:
|
|
|
|
case PR_SENT_REPRESENTING_SEARCH_KEY:
|
|
|
|
case PR_RECEIVED_BY_ENTRYID:
|
|
|
|
case PR_SENT_REPRESENTING_ENTRYID:
|
|
|
|
case PR_RCVD_REPRESENTING_ENTRYID:
|
|
|
|
case PR_ORIGINAL_AUTHOR_ENTRYID:
|
|
|
|
case PR_REPLY_RECIPIENT_ENTRIES:
|
|
|
|
case PR_RECEIVED_BY_SEARCH_KEY:
|
|
|
|
case PR_RCVD_REPRESENTING_SEARCH_KEY:
|
|
|
|
case PR_SEARCH_KEY:
|
|
|
|
case PR_CHANGE_KEY:
|
2010-10-15 19:24:09 +02:00
|
|
|
case PR_ORIGINAL_AUTHOR_SEARCH_KEY:
|
2010-10-14 23:37:39 +02:00
|
|
|
case PR_CONVERSATION_INDEX:
|
|
|
|
case PR_SENDER_ENTRYID:
|
|
|
|
case PR_SENDER_SEARCH_KEY:
|
2010-10-15 19:24:09 +02:00
|
|
|
rc = MAPI_E_NOT_FOUND;
|
|
|
|
break;
|
2010-10-14 23:37:39 +02:00
|
|
|
|
|
|
|
/* PT_SVREID*/
|
|
|
|
case PR_SENT_MAILSVR_EID:
|
2010-10-15 19:24:09 +02:00
|
|
|
rc = MAPI_E_NOT_FOUND;
|
2010-10-14 23:37:39 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* PR_LONG */
|
|
|
|
case PR_OWNER_APPT_ID:
|
|
|
|
case PR_ACTION_FLAG:
|
|
|
|
case PR_INTERNET_CPID:
|
|
|
|
case PR_INET_MAIL_OVERRIDE_FORMAT:
|
2010-10-15 19:24:09 +02:00
|
|
|
rc = MAPI_E_NOT_FOUND;
|
2010-10-14 23:37:39 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PR_MSG_EDITOR_FORMAT:
|
|
|
|
{
|
|
|
|
NSMutableArray *keys;
|
|
|
|
NSArray *acceptedTypes;
|
|
|
|
uint32_t format;
|
|
|
|
|
|
|
|
child = [self lookupObject: childURL];
|
|
|
|
|
|
|
|
format = 0; /* EDITOR_FORMAT_DONTKNOW */
|
|
|
|
|
|
|
|
acceptedTypes = [NSArray arrayWithObject: @"text/plain"];
|
|
|
|
keys = [NSMutableArray array];
|
|
|
|
[child addRequiredKeysOfStructure: [child bodyStructure]
|
|
|
|
path: @"" toArray: keys
|
|
|
|
acceptedTypes: acceptedTypes];
|
|
|
|
if ([keys count] == 1)
|
|
|
|
format = EDITOR_FORMAT_PLAINTEXT;
|
|
|
|
|
|
|
|
acceptedTypes = [NSArray arrayWithObject: @"text/html"];
|
|
|
|
[keys removeAllObjects];
|
|
|
|
[child addRequiredKeysOfStructure: [child bodyStructure]
|
|
|
|
path: @"" toArray: keys
|
|
|
|
acceptedTypes: acceptedTypes];
|
|
|
|
if ([keys count] == 1)
|
|
|
|
format = EDITOR_FORMAT_HTML;
|
|
|
|
|
|
|
|
*data = MAPILongValue (memCtx, format);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
default:
|
|
|
|
rc = [super getMessageTableChildproperty: data
|
|
|
|
atURL: childURL
|
|
|
|
withTag: proptag
|
|
|
|
inFolder: folder
|
|
|
|
withFID: fid];
|
|
|
|
}
|
2010-11-22 22:33:02 +01:00
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
return rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|
|
|
|
|
2010-11-30 17:17:50 +01:00
|
|
|
- (enum MAPISTATUS) getFolderTableChildproperty: (void **) data
|
|
|
|
atURL: (NSString *) childURL
|
|
|
|
withTag: (enum MAPITAGS) proptag
|
|
|
|
inFolder: (SOGoFolder *) folder
|
|
|
|
withFID: (uint64_t) fid
|
2010-10-01 20:54:30 +02:00
|
|
|
{
|
2010-11-30 17:17:50 +01:00
|
|
|
enum MAPISTATUS rc;
|
2010-10-01 22:35:29 +02:00
|
|
|
|
|
|
|
rc = MAPI_E_SUCCESS;
|
|
|
|
switch (proptag)
|
|
|
|
{
|
|
|
|
case PR_CONTENT_UNREAD:
|
2010-10-06 16:27:09 +02:00
|
|
|
*data = MAPILongValue (memCtx, 0);
|
2010-10-01 22:35:29 +02:00
|
|
|
break;
|
|
|
|
case PR_CONTAINER_CLASS_UNICODE:
|
2010-10-06 16:27:09 +02:00
|
|
|
*data = talloc_strdup (memCtx, "IPF.Note");
|
2010-10-01 22:35:29 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rc = [super getFolderTableChildproperty: data
|
|
|
|
atURL: childURL
|
|
|
|
withTag: proptag
|
|
|
|
inFolder: folder
|
|
|
|
withFID: fid];
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|
|
|
|
|
2010-10-14 15:23:46 +02:00
|
|
|
- (int) openMessage: (struct mapistore_message *) msg
|
|
|
|
atURL: (NSString *) childURL
|
|
|
|
{
|
|
|
|
id child;
|
|
|
|
int rc;
|
|
|
|
struct SRowSet *recipients;
|
|
|
|
struct SRow *properties;
|
|
|
|
NSArray *to;
|
|
|
|
NSInteger count, max;
|
2010-10-14 17:23:01 +02:00
|
|
|
NGImap4EnvelopeAddress *currentAddress;
|
2010-10-14 15:23:46 +02:00
|
|
|
NSString *name;
|
|
|
|
uint32_t tags[] = { PR_SUBJECT_UNICODE, PR_HASATTACH,
|
|
|
|
PR_MESSAGE_DELIVERY_TIME, PR_MESSAGE_FLAGS,
|
|
|
|
PR_FLAG_STATUS, PR_SENSITIVITY,
|
|
|
|
PR_SENT_REPRESENTING_NAME_UNICODE,
|
|
|
|
PR_INTERNET_MESSAGE_ID_UNICODE,
|
|
|
|
PR_READ_RECEIPT_REQUESTED };
|
2010-10-14 16:46:34 +02:00
|
|
|
void *propValue;
|
2010-10-14 15:23:46 +02:00
|
|
|
|
|
|
|
child = [self lookupObject: childURL];
|
|
|
|
if (child)
|
|
|
|
{
|
|
|
|
/* Retrieve recipients from the message */
|
|
|
|
to = [child toEnvelopeAddresses];
|
|
|
|
max = [to count];
|
|
|
|
recipients = talloc_zero (memCtx, struct SRowSet);
|
|
|
|
recipients->cRows = max;
|
|
|
|
recipients->aRow = talloc_array (recipients, struct SRow, max);
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
recipients->aRow[count].ulAdrEntryPad = 0;
|
|
|
|
recipients->aRow[count].cValues = 2;
|
|
|
|
recipients->aRow[count].lpProps = talloc_array (recipients->aRow,
|
|
|
|
struct SPropValue,
|
|
|
|
2);
|
2010-10-14 17:13:51 +02:00
|
|
|
|
2010-10-14 15:23:46 +02:00
|
|
|
// TODO (0x01 = primary recipient)
|
2010-10-14 17:13:51 +02:00
|
|
|
set_SPropValue_proptag (&(recipients->aRow[count].lpProps[0]),
|
|
|
|
PR_RECIPIENT_TYPE,
|
|
|
|
MAPILongValue (memCtx, 0x01));
|
|
|
|
|
2010-10-14 17:23:01 +02:00
|
|
|
currentAddress = [to objectAtIndex: count];
|
2010-10-14 17:23:19 +02:00
|
|
|
// name = [currentAddress personalName];
|
|
|
|
// if (![name length])
|
|
|
|
name = [currentAddress baseEMail];
|
2010-10-14 17:13:51 +02:00
|
|
|
set_SPropValue_proptag (&(recipients->aRow[count].lpProps[1]),
|
|
|
|
PR_DISPLAY_NAME,
|
|
|
|
[name asUnicodeInMemCtx: recipients->aRow[count].lpProps]);
|
2010-10-14 15:23:46 +02:00
|
|
|
}
|
|
|
|
msg->recipients = recipients;
|
|
|
|
|
|
|
|
max = 9;
|
|
|
|
|
|
|
|
properties = talloc_zero (memCtx, struct SRow);
|
2010-10-14 16:46:34 +02:00
|
|
|
properties->cValues = 0;
|
2010-10-14 15:23:46 +02:00
|
|
|
properties->ulAdrEntryPad = 0;
|
|
|
|
properties->lpProps = talloc_array (properties, struct SPropValue, max);
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
2010-10-14 16:46:34 +02:00
|
|
|
if ([self getMessageTableChildproperty: &propValue
|
2010-10-14 15:23:46 +02:00
|
|
|
atURL: childURL
|
|
|
|
withTag: tags[count]
|
|
|
|
inFolder: nil
|
|
|
|
withFID: 0]
|
|
|
|
== MAPI_E_SUCCESS)
|
|
|
|
{
|
2010-10-14 16:46:34 +02:00
|
|
|
set_SPropValue_proptag (&(properties->lpProps[properties->cValues]),
|
|
|
|
tags[count],
|
|
|
|
propValue);
|
|
|
|
properties->cValues++;
|
|
|
|
// talloc_free (propValue);
|
2010-10-14 15:23:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msg->properties = properties;
|
|
|
|
|
|
|
|
rc = MAPI_E_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
2010-10-15 19:24:09 +02:00
|
|
|
rc = MAPI_E_NOT_FOUND;
|
2010-10-14 15:23:46 +02:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-10-01 20:54:30 +02:00
|
|
|
@end
|