2011-02-24 21:30:01 +01:00
|
|
|
/* MAPIStoreMailMessage.m - this file is part of SOGo
|
|
|
|
*
|
2012-08-17 21:04:57 +02:00
|
|
|
* Copyright (C) 2011-2012 Inverse inc
|
2011-02-24 21:30:01 +01:00
|
|
|
*
|
|
|
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2011-09-14 20:33:44 +02:00
|
|
|
* Ludovic Marcotte <lmarcotte@inverse.ca>
|
2011-02-24 21:30:01 +01:00
|
|
|
*
|
|
|
|
* 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
|
2011-08-12 17:02:01 +02:00
|
|
|
* the Free Software Foundation; either version 3, or (at your option)
|
2011-02-24 21:30:01 +01: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/NSArray.h>
|
2011-10-14 21:42:16 +02:00
|
|
|
#import <Foundation/NSCalendarDate.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSException.h>
|
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2012-10-09 22:39:24 +02:00
|
|
|
#import <NGExtensions/NSObject+Values.h>
|
2011-09-14 20:33:44 +02:00
|
|
|
#import <NGImap4/NGImap4Client.h>
|
|
|
|
#import <NGImap4/NGImap4Connection.h>
|
2011-07-21 17:05:17 +02:00
|
|
|
#import <NGImap4/NGImap4EnvelopeAddress.h>
|
2011-10-03 22:55:02 +02:00
|
|
|
#import <NGMail/NGMailAddress.h>
|
|
|
|
#import <NGMail/NGMailAddressParser.h>
|
2015-03-24 18:05:58 +01:00
|
|
|
#import <NGMail/NGMimeMessageGenerator.h>
|
2011-07-21 17:05:17 +02:00
|
|
|
#import <NGCards/iCalCalendar.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <SOGo/NSArray+Utilities.h>
|
2011-07-19 23:31:16 +02:00
|
|
|
#import <SOGo/NSString+Utilities.h>
|
2011-09-30 22:01:50 +02:00
|
|
|
#import <SOGo/SOGoUserManager.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <Mailer/NSData+Mail.h>
|
|
|
|
#import <Mailer/SOGoMailBodyPart.h>
|
|
|
|
#import <Mailer/SOGoMailObject.h>
|
2015-09-08 15:37:33 +02:00
|
|
|
#import <Mailer/NSDictionary+Mail.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2014-10-02 17:40:12 +02:00
|
|
|
#import "Codepages.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
#import "NSData+MAPIStore.h"
|
2011-07-20 20:28:37 +02:00
|
|
|
#import "NSObject+MAPIStore.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
#import "NSString+MAPIStore.h"
|
2011-07-21 17:05:17 +02:00
|
|
|
#import "MAPIStoreAppointmentWrapper.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
#import "MAPIStoreContext.h"
|
|
|
|
#import "MAPIStoreFolder.h"
|
2011-07-21 17:05:17 +02:00
|
|
|
#import "MAPIStoreMailAttachment.h"
|
2011-04-13 21:59:04 +02:00
|
|
|
#import "MAPIStoreMailFolder.h"
|
2011-09-14 20:33:44 +02:00
|
|
|
#import "MAPIStoreMapping.h"
|
2011-11-17 19:39:42 +01:00
|
|
|
#import "MAPIStoreSamDBUtils.h"
|
2015-03-02 23:41:04 +01:00
|
|
|
#import "MAPIStoreSharingMessage.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
#import "MAPIStoreTypes.h"
|
2012-06-01 17:15:30 +02:00
|
|
|
#import "MAPIStoreUserContext.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
|
|
|
|
#import "MAPIStoreMailMessage.h"
|
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <gen_ndr/exchange.h>
|
|
|
|
#include <mapistore/mapistore.h>
|
2011-03-07 20:15:16 +01:00
|
|
|
#include <mapistore/mapistore_errors.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
@class iCalCalendar, iCalEvent;
|
|
|
|
|
2015-03-18 23:57:33 +01:00
|
|
|
static Class NSExceptionK, MAPIStoreSharingMessageK;
|
2011-02-24 21:30:01 +01:00
|
|
|
|
|
|
|
@interface NSString (MAPIStoreMIME)
|
|
|
|
|
|
|
|
- (NSString *) _strippedBodyKey;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSString (MAPIStoreMIME)
|
|
|
|
|
|
|
|
- (NSString *) _strippedBodyKey
|
|
|
|
{
|
|
|
|
NSRange bodyRange;
|
|
|
|
NSString *strippedKey;
|
|
|
|
|
2011-10-31 20:29:37 +01:00
|
|
|
bodyRange = [self rangeOfString: @"body.peek["];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (bodyRange.length > 0)
|
|
|
|
{
|
|
|
|
strippedKey = [self substringFromIndex: NSMaxRange (bodyRange)];
|
|
|
|
strippedKey = [strippedKey substringToIndex: [strippedKey length] - 1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strippedKey = nil;
|
|
|
|
|
|
|
|
return strippedKey;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2011-09-23 17:36:49 +02:00
|
|
|
@implementation SOGoMailObject (MAPIStoreExtension)
|
|
|
|
|
|
|
|
- (Class) mapistoreMessageClass
|
|
|
|
{
|
|
|
|
return [MAPIStoreMailMessage class];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
@implementation MAPIStoreMailMessage
|
|
|
|
|
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
NSExceptionK = [NSException class];
|
2015-03-18 23:57:33 +01:00
|
|
|
MAPIStoreSharingMessageK = [MAPIStoreSharingMessage class];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
2011-07-15 22:22:27 +02:00
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
2011-07-19 23:31:16 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
mimeKey = nil;
|
|
|
|
mailIsEvent = NO;
|
2015-05-06 16:22:06 +02:00
|
|
|
mailIsMeetingRequest = NO;
|
2015-03-02 23:41:04 +01:00
|
|
|
mailIsSharingObject = NO;
|
2011-07-21 17:05:17 +02:00
|
|
|
headerCharset = nil;
|
|
|
|
headerEncoding = nil;
|
|
|
|
headerMimeType = nil;
|
|
|
|
headerSetup = NO;
|
2011-07-19 23:31:16 +02:00
|
|
|
bodyContent = nil;
|
2011-07-21 17:05:17 +02:00
|
|
|
bodySetup = NO;
|
|
|
|
appointmentWrapper = nil;
|
2011-07-19 23:31:16 +02:00
|
|
|
}
|
2011-07-15 22:22:27 +02:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2011-07-19 23:31:16 +02:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
[mimeKey release];
|
2011-07-19 23:31:16 +02:00
|
|
|
[bodyContent release];
|
2011-07-21 17:05:17 +02:00
|
|
|
[headerMimeType release];
|
|
|
|
[headerCharset release];
|
2015-01-21 00:27:14 +01:00
|
|
|
[headerEncoding release];
|
2011-07-21 17:05:17 +02:00
|
|
|
[appointmentWrapper release];
|
2011-07-19 23:31:16 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
- (NSString *) subject
|
|
|
|
{
|
|
|
|
return [sogoObject decodedSubject];
|
|
|
|
}
|
|
|
|
|
2011-10-14 21:42:16 +02:00
|
|
|
- (NSDate *) creationTime
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
|
|
|
return [sogoObject date];
|
|
|
|
}
|
|
|
|
|
2011-10-14 21:42:16 +02:00
|
|
|
- (NSDate *) lastModificationTime
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
|
|
|
return [sogoObject date];
|
|
|
|
}
|
|
|
|
|
2015-03-05 00:02:19 +01:00
|
|
|
- (enum mapistore_error) getAvailableProperties: (struct SPropTagArray **) propertiesP
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
BOOL listedProperties[65536];
|
|
|
|
NSUInteger count;
|
|
|
|
uint16_t propId;
|
|
|
|
|
|
|
|
if (mailIsSharingObject)
|
|
|
|
{
|
|
|
|
memset (listedProperties, NO, 65536 * sizeof (BOOL));
|
|
|
|
[super getAvailableProperties: propertiesP inMemCtx: memCtx];
|
|
|
|
for (count = 0; count < (*propertiesP)->cValues; count++)
|
|
|
|
{
|
|
|
|
propId = ((*propertiesP)->aulPropTag[count] >> 16) & 0xffff;
|
|
|
|
listedProperties[propId] = YES;
|
|
|
|
}
|
|
|
|
[MAPIStoreSharingMessage fillAvailableProperties: *propertiesP
|
|
|
|
withExclusions: listedProperties];
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return [super getAvailableProperties: propertiesP inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
static NSComparisonResult
|
|
|
|
_compareBodyKeysByPriority (id entry1, id entry2, void *data)
|
|
|
|
{
|
|
|
|
NSComparisonResult result;
|
|
|
|
NSArray *keys;
|
|
|
|
NSString *data1, *data2;
|
|
|
|
NSUInteger count1, count2;
|
|
|
|
|
|
|
|
keys = data;
|
|
|
|
|
|
|
|
data1 = [entry1 objectForKey: @"mimeType"];
|
|
|
|
count1 = [keys indexOfObject: data1];
|
|
|
|
data2 = [entry2 objectForKey: @"mimeType"];
|
|
|
|
count2 = [keys indexOfObject: data2];
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
if (count1 == count2)
|
|
|
|
{
|
|
|
|
data1 = [entry1 objectForKey: @"key"];
|
|
|
|
count1 = [data1 countOccurrencesOfString: @"."];
|
|
|
|
data2 = [entry2 objectForKey: @"key"];
|
|
|
|
count2 = [data2 countOccurrencesOfString: @"."];
|
|
|
|
if (count1 == count2)
|
|
|
|
{
|
|
|
|
data1 = [data1 _strippedBodyKey];
|
|
|
|
count1 = [data1 intValue];
|
|
|
|
data2 = [data2 _strippedBodyKey];
|
|
|
|
count2 = [data2 intValue];
|
|
|
|
if (count1 == count2)
|
|
|
|
result = NSOrderedSame;
|
|
|
|
else if (count1 < count2)
|
|
|
|
result = NSOrderedAscending;
|
|
|
|
else
|
|
|
|
result = NSOrderedDescending;
|
|
|
|
}
|
|
|
|
else if (count1 < count2)
|
|
|
|
result = NSOrderedAscending;
|
|
|
|
else
|
|
|
|
result = NSOrderedDescending;
|
|
|
|
}
|
|
|
|
else if (count1 < count2)
|
|
|
|
result = NSOrderedAscending;
|
|
|
|
else
|
|
|
|
result = NSOrderedDescending;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _fetchHeaderData
|
|
|
|
{
|
2015-03-02 23:41:04 +01:00
|
|
|
MAPIStoreSharingMessage *sharingMessage;
|
2011-07-21 17:05:17 +02:00
|
|
|
NSMutableArray *keys;
|
|
|
|
NSArray *acceptedTypes;
|
|
|
|
NSDictionary *messageData, *partHeaderData, *parameters;
|
2015-03-02 23:41:04 +01:00
|
|
|
NSString *sharingHeader;
|
2011-07-21 17:05:17 +02:00
|
|
|
|
|
|
|
acceptedTypes = [NSArray arrayWithObjects: @"text/calendar",
|
|
|
|
@"application/ics",
|
|
|
|
@"text/html",
|
|
|
|
@"text/plain", nil];
|
|
|
|
keys = [NSMutableArray array];
|
|
|
|
[sogoObject addRequiredKeysOfStructure: [sogoObject bodyStructure]
|
|
|
|
path: @"" toArray: keys
|
2011-10-31 20:29:37 +01:00
|
|
|
acceptedTypes: acceptedTypes
|
|
|
|
withPeek: YES];
|
2011-07-21 17:05:17 +02:00
|
|
|
[keys sortUsingFunction: _compareBodyKeysByPriority context: acceptedTypes];
|
|
|
|
if ([keys count] > 0)
|
|
|
|
{
|
|
|
|
messageData = [keys objectAtIndex: 0];
|
|
|
|
ASSIGN (mimeKey, [messageData objectForKey: @"key"]);
|
|
|
|
ASSIGN (headerMimeType, [messageData objectForKey: @"mimeType"]);
|
|
|
|
partHeaderData
|
|
|
|
= [sogoObject lookupInfoForBodyPart: [mimeKey _strippedBodyKey]];
|
|
|
|
ASSIGN (headerEncoding, [partHeaderData objectForKey: @"encoding"]);
|
|
|
|
parameters = [partHeaderData objectForKey: @"parameterList"];
|
|
|
|
ASSIGN (headerCharset, [parameters objectForKey: @"charset"]);
|
|
|
|
if ([headerMimeType isEqualToString: @"text/calendar"]
|
|
|
|
|| [headerMimeType isEqualToString: @"application/ics"])
|
2015-05-06 16:22:06 +02:00
|
|
|
{
|
2011-10-11 23:16:57 +02:00
|
|
|
mailIsEvent = YES;
|
2015-05-06 16:22:06 +02:00
|
|
|
if ([[parameters objectForKey: @"method"] isEqualToString: @"REQUEST"])
|
|
|
|
mailIsMeetingRequest = YES;
|
|
|
|
}
|
2015-03-02 23:41:04 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sharingHeader = [[sogoObject mailHeaders] objectForKey: @"x-ms-sharing-localtype"];
|
|
|
|
if (sharingHeader)
|
|
|
|
{
|
|
|
|
mailIsSharingObject = YES;
|
|
|
|
/* It is difficult to subclass this in folder class, that's why
|
|
|
|
a sharing object is a proxy in a mail message */
|
|
|
|
sharingMessage = [[MAPIStoreSharingMessage alloc]
|
|
|
|
initWithMailHeaders: [sogoObject mailHeaders]
|
2015-03-18 23:57:33 +01:00
|
|
|
andConnectionInfo: [[self context] connectionInfo]
|
|
|
|
fromMessage: self];
|
2015-03-02 23:41:04 +01:00
|
|
|
[self addProxy: sharingMessage];
|
|
|
|
[sharingMessage release];
|
|
|
|
}
|
|
|
|
}
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
headerSetup = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _fetchBodyData
|
|
|
|
{
|
|
|
|
NSData *rawContent;
|
2011-10-31 20:29:37 +01:00
|
|
|
NSString *resultKey;
|
2011-07-21 17:05:17 +02:00
|
|
|
id result;
|
|
|
|
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
2012-10-06 19:02:39 +02:00
|
|
|
if (!bodyContent && mimeKey)
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
|
|
|
result = [sogoObject fetchParts: [NSArray arrayWithObject: mimeKey]];
|
|
|
|
result = [[result valueForKey: @"RawResponse"] objectForKey: @"fetch"];
|
2011-10-31 20:29:37 +01:00
|
|
|
if ([mimeKey hasPrefix: @"body.peek"])
|
|
|
|
resultKey = [NSString stringWithFormat: @"body[%@]",
|
|
|
|
[mimeKey _strippedBodyKey]];
|
|
|
|
else
|
|
|
|
resultKey = mimeKey;
|
|
|
|
rawContent = [[result objectForKey: resultKey] objectForKey: @"data"];
|
2011-07-21 17:05:17 +02:00
|
|
|
ASSIGN (bodyContent, [rawContent bodyDataFromEncoding: headerEncoding]);
|
|
|
|
}
|
|
|
|
|
|
|
|
bodySetup = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (MAPIStoreAppointmentWrapper *) _appointmentWrapper
|
|
|
|
{
|
2011-10-12 22:00:46 +02:00
|
|
|
NSArray *events, *from;
|
2011-07-21 17:05:17 +02:00
|
|
|
iCalCalendar *calendar;
|
|
|
|
iCalEvent *event;
|
2011-10-12 22:00:46 +02:00
|
|
|
NSString *stringValue, *senderEmail;
|
2011-11-17 17:15:38 +01:00
|
|
|
MAPIStoreContext *context;
|
2011-07-21 17:05:17 +02:00
|
|
|
|
|
|
|
if (!appointmentWrapper)
|
|
|
|
{
|
|
|
|
if (!bodySetup)
|
|
|
|
[self _fetchBodyData];
|
|
|
|
|
|
|
|
stringValue = [bodyContent bodyStringFromCharset: headerCharset];
|
|
|
|
calendar = [iCalCalendar parseSingleFromSource: stringValue];
|
|
|
|
events = [calendar events];
|
|
|
|
if ([events count] > 0)
|
|
|
|
{
|
|
|
|
event = [events objectAtIndex: 0];
|
2011-10-12 22:00:46 +02:00
|
|
|
from = [sogoObject fromEnvelopeAddresses];
|
|
|
|
if ([from count] > 0)
|
|
|
|
senderEmail = [[from objectAtIndex: 0] email];
|
|
|
|
else
|
|
|
|
senderEmail = nil;
|
2011-11-17 17:15:38 +01:00
|
|
|
context = [self context];
|
2011-07-21 17:05:17 +02:00
|
|
|
appointmentWrapper = [MAPIStoreAppointmentWrapper
|
|
|
|
wrapperWithICalEvent: event
|
2011-11-17 17:15:38 +01:00
|
|
|
andUser: [context activeUser]
|
2011-10-12 22:00:46 +02:00
|
|
|
andSenderEmail: senderEmail
|
2012-03-30 17:33:47 +02:00
|
|
|
inTimeZone: [[self userContext] timeZone]
|
2011-11-17 17:15:38 +01:00
|
|
|
withConnectionInfo: [context connectionInfo]];
|
2011-07-21 17:05:17 +02:00
|
|
|
[appointmentWrapper retain];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return appointmentWrapper;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagChangeKey: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-20 21:37:03 +02:00
|
|
|
{
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
NSData *changeKey;
|
2011-09-23 21:27:21 +02:00
|
|
|
MAPIStoreMailFolder *parentFolder;
|
|
|
|
NSString *nameInContainer;
|
2011-09-20 21:37:03 +02:00
|
|
|
|
|
|
|
if (isNew)
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
else
|
|
|
|
{
|
2011-09-23 21:27:21 +02:00
|
|
|
parentFolder = (MAPIStoreMailFolder *)[self container];
|
|
|
|
nameInContainer = [self nameInContainer];
|
|
|
|
changeKey = [parentFolder changeKeyForMessageWithKey: nameInContainer];
|
|
|
|
if (!changeKey)
|
|
|
|
{
|
2011-09-24 02:13:06 +02:00
|
|
|
[self warnWithFormat: @"attempting to get change key"
|
|
|
|
@" by synchronising folder..."];
|
|
|
|
[(MAPIStoreMailFolder *) container synchroniseCache];
|
2011-09-23 21:27:21 +02:00
|
|
|
[parentFolder synchroniseCache];
|
|
|
|
changeKey = [parentFolder changeKeyForMessageWithKey: nameInContainer];
|
2011-09-24 02:13:06 +02:00
|
|
|
if (changeKey)
|
|
|
|
[self logWithFormat: @"got one"];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self errorWithFormat: @"still nothing. We crash!"];
|
|
|
|
abort ();
|
|
|
|
}
|
2011-09-23 21:27:21 +02:00
|
|
|
}
|
2011-09-20 21:37:03 +02:00
|
|
|
*data = [changeKey asBinaryInMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagPredecessorChangeList: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-09-20 21:37:03 +02:00
|
|
|
{
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
NSData *changeList;
|
|
|
|
|
|
|
|
if (isNew)
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
changeList = [(MAPIStoreMailFolder *)[self container]
|
2012-03-02 21:44:24 +01:00
|
|
|
predecessorChangeListForMessageWithKey: [self nameInContainer]];
|
2011-09-20 21:37:03 +02:00
|
|
|
if (!changeList)
|
2011-09-24 02:13:06 +02:00
|
|
|
{
|
|
|
|
[self warnWithFormat: @"attempting to get predecessor change list"
|
|
|
|
@" by synchronising folder..."];
|
|
|
|
[(MAPIStoreMailFolder *) container synchroniseCache];
|
|
|
|
changeList = [(MAPIStoreMailFolder *)[self container]
|
2012-03-02 21:44:24 +01:00
|
|
|
predecessorChangeListForMessageWithKey: [self nameInContainer]];
|
2011-09-24 02:13:06 +02:00
|
|
|
if (changeList)
|
|
|
|
[self logWithFormat: @"got one"];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self errorWithFormat: @"still nothing. We crash!"];
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
}
|
2011-09-20 21:37:03 +02:00
|
|
|
*data = [changeList asBinaryInMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-07-28 02:52:38 +02:00
|
|
|
- (uint64_t) objectVersion
|
|
|
|
{
|
2011-10-07 20:30:15 +02:00
|
|
|
uint64_t version = ULLONG_MAX;
|
2012-10-09 22:39:24 +02:00
|
|
|
NSString *uid, *changeNumber;
|
2014-11-19 00:23:16 +01:00
|
|
|
BOOL synced;
|
2011-07-28 02:52:38 +02:00
|
|
|
|
|
|
|
uid = [(MAPIStoreMailFolder *)
|
|
|
|
container messageUIDFromMessageKey: [self nameInContainer]];
|
|
|
|
if (uid)
|
|
|
|
{
|
2011-08-15 21:10:00 +02:00
|
|
|
changeNumber = [(MAPIStoreMailFolder *) container
|
2012-10-09 22:39:24 +02:00
|
|
|
changeNumberForMessageUID: uid];
|
2011-08-15 21:10:00 +02:00
|
|
|
if (!changeNumber)
|
|
|
|
{
|
|
|
|
[self warnWithFormat: @"attempting to get change number"
|
|
|
|
@" by synchronising folder..."];
|
|
|
|
[(MAPIStoreMailFolder *) container synchroniseCache];
|
|
|
|
changeNumber = [(MAPIStoreMailFolder *) container
|
2012-10-09 22:39:24 +02:00
|
|
|
changeNumberForMessageUID: uid];
|
2011-08-15 21:10:00 +02:00
|
|
|
if (changeNumber)
|
|
|
|
[self logWithFormat: @"got one"];
|
|
|
|
else
|
|
|
|
{
|
2014-11-19 00:23:16 +01:00
|
|
|
[self warnWithFormat: @"attempting to get change number"
|
|
|
|
@" by synchronising this specific message..."];
|
|
|
|
synced = [(MAPIStoreMailFolder *) container synchroniseCacheForUID: uid];
|
|
|
|
if (synced)
|
|
|
|
{
|
|
|
|
changeNumber = [(MAPIStoreMailFolder *) container
|
|
|
|
changeNumberForMessageUID: uid];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self errorWithFormat: @"still nothing. We crash!"];
|
|
|
|
abort();
|
|
|
|
}
|
2011-08-15 21:10:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
version = [changeNumber unsignedLongLongValue] >> 16;
|
2011-07-28 02:52:38 +02:00
|
|
|
}
|
|
|
|
else
|
2011-09-14 20:33:44 +02:00
|
|
|
abort();
|
2011-07-28 02:52:38 +02:00
|
|
|
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagIconIndex: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
2011-04-13 21:59:04 +02:00
|
|
|
uint32_t longValue;
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
2011-10-11 23:16:57 +02:00
|
|
|
if (mailIsEvent)
|
2012-03-02 21:44:24 +01:00
|
|
|
[[self _appointmentWrapper] getPidTagIconIndex: data inMemCtx: memCtx];
|
2011-10-11 23:16:57 +02:00
|
|
|
else
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
2011-10-11 23:16:57 +02:00
|
|
|
/* see http://msdn.microsoft.com/en-us/library/cc815472.aspx */
|
|
|
|
if ([sogoObject isNewMail])
|
|
|
|
longValue = 0xffffffff;
|
|
|
|
else if ([sogoObject replied])
|
|
|
|
longValue = 0x105;
|
|
|
|
else if ([sogoObject forwarded])
|
|
|
|
longValue = 0x106;
|
|
|
|
else if ([sogoObject read])
|
|
|
|
longValue = 0x100;
|
2011-07-21 17:05:17 +02:00
|
|
|
else
|
2011-10-11 23:16:57 +02:00
|
|
|
longValue = 0x101;
|
|
|
|
*data = MAPILongValue (memCtx, longValue);
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (int) getPidLidResponseStatus: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
*data = MAPILongValue (memCtx, 0);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
- (int) getPidLidImapDeleted: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
uint32_t longValue;
|
|
|
|
|
|
|
|
if ([sogoObject deleted])
|
|
|
|
longValue = 1;
|
|
|
|
else
|
|
|
|
longValue = 0;
|
|
|
|
*data = MAPILongValue (memCtx, longValue);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSubjectPrefix: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSString *subject;
|
|
|
|
NSUInteger colIdx;
|
|
|
|
NSString *stringValue;
|
|
|
|
|
2011-07-20 20:30:05 +02:00
|
|
|
subject = [self subject];
|
2011-04-13 21:59:04 +02:00
|
|
|
colIdx = [subject rangeOfString: @":"].location;
|
|
|
|
if (colIdx != NSNotFound && colIdx < 4)
|
|
|
|
stringValue = [NSString stringWithFormat: @"%@: ",
|
2012-03-02 21:44:24 +01:00
|
|
|
[subject substringToIndex: colIdx]];
|
2011-04-13 21:59:04 +02:00
|
|
|
else
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagNormalizedSubject: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSString *subject;
|
|
|
|
NSUInteger colIdx;
|
|
|
|
NSString *stringValue;
|
|
|
|
|
2011-07-20 20:30:05 +02:00
|
|
|
subject = [self subject];
|
2011-04-13 21:59:04 +02:00
|
|
|
colIdx = [subject rangeOfString: @":"].location;
|
|
|
|
if (colIdx != NSNotFound && colIdx < 4)
|
|
|
|
stringValue = [[subject substringFromIndex: colIdx + 1]
|
|
|
|
stringByTrimmingLeadSpaces];
|
|
|
|
else
|
|
|
|
stringValue = subject;
|
|
|
|
if (!stringValue)
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (int) getPidLidFInvited: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self getYes: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMessageClass: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
if (mailIsEvent)
|
2012-03-02 21:44:24 +01:00
|
|
|
[[self _appointmentWrapper] getPidTagMessageClass: data
|
|
|
|
inMemCtx: memCtx];
|
2015-03-02 23:41:04 +01:00
|
|
|
else if (mailIsSharingObject)
|
|
|
|
*data = talloc_strdup (memCtx, "IPM.Sharing");
|
2011-07-21 17:05:17 +02:00
|
|
|
else
|
2011-10-11 23:16:57 +02:00
|
|
|
*data = talloc_strdup (memCtx, "IPM.Note");
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-05-06 16:22:06 +02:00
|
|
|
- (int) getPidTagReplyRequested: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-08-08 21:01:24 +02:00
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
2015-05-06 16:22:06 +02:00
|
|
|
return (mailIsMeetingRequest
|
|
|
|
? [self getYes: data inMemCtx: memCtx]
|
2011-08-08 21:01:24 +02:00
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2015-05-06 16:22:06 +02:00
|
|
|
- (int) getPidTagResponseRequested: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self getPidTagReplyRequested: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagLatestDeliveryTime: (void **) data // DOUBT
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagCreationTime: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagOriginalSubmitTime: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagCreationTime: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagClientSubmitTime: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagCreationTime: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMessageDeliveryTime: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagCreationTime: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMessageFlags: (void **) data // TODO
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSDictionary *coreInfos;
|
|
|
|
NSArray *flags;
|
|
|
|
unsigned int v = 0;
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
coreInfos = [sogoObject fetchCoreInfos];
|
|
|
|
flags = [coreInfos objectForKey: @"flags"];
|
|
|
|
|
2012-01-29 20:55:21 +01:00
|
|
|
// if ([container isKindOfClass: MAPIStoreSentItemsFolderK]
|
|
|
|
// || [container isKindOfClass: MAPIStoreDraftsFolderK])
|
|
|
|
// v |= MSGFLAG_FROMME;
|
2011-04-13 21:59:04 +02:00
|
|
|
if ([flags containsObject: @"seen"])
|
|
|
|
v |= MSGFLAG_READ;
|
2011-07-26 22:13:10 +02:00
|
|
|
if ([[self attachmentKeys]
|
|
|
|
count] > 0)
|
2011-04-13 21:59:04 +02:00
|
|
|
v |= MSGFLAG_HASATTACH;
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
*data = MAPILongValue (memCtx, v);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagFlagStatus: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSDictionary *coreInfos;
|
|
|
|
NSArray *flags;
|
|
|
|
unsigned int v;
|
|
|
|
|
|
|
|
coreInfos = [sogoObject fetchCoreInfos];
|
|
|
|
|
|
|
|
flags = [coreInfos objectForKey: @"flags"];
|
|
|
|
if ([flags containsObject: @"flagged"])
|
|
|
|
v = 2;
|
|
|
|
else
|
|
|
|
v = 0;
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
*data = MAPILongValue (memCtx, v);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagFollowupIcon: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSDictionary *coreInfos;
|
|
|
|
NSArray *flags;
|
|
|
|
unsigned int v;
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
coreInfos = [sogoObject fetchCoreInfos];
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
flags = [coreInfos objectForKey: @"flags"];
|
|
|
|
if ([flags containsObject: @"flagged"])
|
|
|
|
v = 6;
|
|
|
|
else
|
|
|
|
v = 0;
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
*data = MAPILongValue (memCtx, v);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSensitivity: (void **) data // TODO
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getLongZero: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagOriginalSensitivity: (void **) data // TODO
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagSensitivity: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSentRepresentingAddressType: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getSMTPAddrType: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagReceivedRepresentingAddressType: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getSMTPAddrType: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagReceivedByAddressType: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getSMTPAddrType: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSenderAddressType: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getSMTPAddrType: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (int) _getEmailAddressFromEmail: (NSString *) fullMail
|
|
|
|
inData: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-10-03 22:55:02 +02:00
|
|
|
NGMailAddress *ngAddress;
|
|
|
|
NSString *email;
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
if (!fullMail)
|
|
|
|
fullMail = @"";
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
ngAddress = [[NGMailAddressParser mailAddressParserWithString: fullMail]
|
|
|
|
parse];
|
|
|
|
if ([ngAddress isKindOfClass: [NGMailAddress class]])
|
|
|
|
email = [ngAddress address];
|
|
|
|
else
|
|
|
|
email = @"";
|
|
|
|
|
|
|
|
*data = [email asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) _getCNFromEmail: (NSString *) fullMail
|
|
|
|
inData: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
NGMailAddress *ngAddress;
|
|
|
|
NSString *cn;
|
|
|
|
|
|
|
|
if (!fullMail)
|
|
|
|
fullMail = @"";
|
|
|
|
|
|
|
|
ngAddress = [[NGMailAddressParser mailAddressParserWithString: fullMail]
|
|
|
|
parse];
|
|
|
|
if ([ngAddress isKindOfClass: [NGMailAddress class]])
|
2013-06-20 15:10:09 +02:00
|
|
|
{
|
|
|
|
cn = [ngAddress displayName];
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2013-06-20 15:10:09 +02:00
|
|
|
// If we don't have a displayName, we use the email address instead. This
|
|
|
|
// avoid bug #2119 - where Outlook won't display anything in the "From" field,
|
|
|
|
// nor in the recipient field if we reply to the email.
|
|
|
|
if (![cn length])
|
|
|
|
cn = [ngAddress address];
|
|
|
|
}
|
2011-10-03 22:55:02 +02:00
|
|
|
else
|
|
|
|
cn = @"";
|
|
|
|
|
|
|
|
*data = [cn asUnicodeInMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (int) _getEntryIdFromEmail: (NSString *) fullMail
|
|
|
|
inData: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
NSString *username, *cn, *email;
|
|
|
|
SOGoUserManager *mgr;
|
|
|
|
NSDictionary *contactInfos;
|
|
|
|
NGMailAddress *ngAddress;
|
|
|
|
NSData *entryId;
|
2011-11-17 17:15:38 +01:00
|
|
|
struct ldb_context *samCtx;
|
2011-10-03 22:55:02 +02:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (fullMail)
|
|
|
|
{
|
|
|
|
ngAddress = [[NGMailAddressParser mailAddressParserWithString: fullMail]
|
|
|
|
parse];
|
|
|
|
if ([ngAddress isKindOfClass: [NGMailAddress class]])
|
|
|
|
{
|
|
|
|
email = [ngAddress address];
|
|
|
|
cn = [ngAddress displayName];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
email = fullMail;
|
|
|
|
cn = @"";
|
|
|
|
}
|
|
|
|
|
|
|
|
mgr = [SOGoUserManager sharedUserManager];
|
|
|
|
contactInfos = [mgr contactInfosForUserWithUIDorEmail: email];
|
|
|
|
if (contactInfos)
|
|
|
|
{
|
2015-04-15 18:52:55 +02:00
|
|
|
username = [contactInfos objectForKey: @"sAMAccountName"];
|
2011-11-17 17:15:38 +01:00
|
|
|
samCtx = [[self context] connectionInfo]->sam_ctx;
|
|
|
|
entryId = MAPIStoreInternalEntryId (samCtx, username);
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
entryId = MAPIStoreExternalEntryId (cn, email);
|
|
|
|
|
|
|
|
*data = [entryId asBinaryInMemCtx: memCtx];
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
rc = MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSenderEmailAddress: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
|
|
|
return [self _getEmailAddressFromEmail: [sogoObject from]
|
|
|
|
inData: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSenderName: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-10-03 22:55:02 +02:00
|
|
|
return [self _getCNFromEmail: [sogoObject from]
|
|
|
|
inData: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSenderEntryId: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
|
|
|
return [self _getEntryIdFromEmail: [sogoObject from]
|
|
|
|
inData: data
|
|
|
|
inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagOriginalAuthorName: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagSenderEmailAddress: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSentRepresentingEmailAddress: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagSenderEmailAddress: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSentRepresentingName: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagSenderName: data inMemCtx: memCtx];
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSentRepresentingEntryId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagSenderEntryId: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagReceivedByEmailAddress: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-10-03 22:55:02 +02:00
|
|
|
return [self _getEmailAddressFromEmail: [sogoObject to]
|
|
|
|
inData: data
|
|
|
|
inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagReceivedByName: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-10-03 22:55:02 +02:00
|
|
|
return [self _getCNFromEmail: [sogoObject to]
|
|
|
|
inData: data
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagReceivedByEntryId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
|
|
|
return [self _getEntryIdFromEmail: [sogoObject to]
|
|
|
|
inData: data
|
|
|
|
inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagReceivedRepresentingName: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagReceivedByName: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagReceivedRepresentingEmailAddress: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagReceivedByEmailAddress: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagReceivedRepresentingEntryId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagReceivedByEntryId: data inMemCtx: memCtx];
|
2011-10-03 22:55:02 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagDisplayTo: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-10-03 22:55:02 +02:00
|
|
|
*data = [[sogoObject to] asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagOriginalDisplayTo: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagDisplayTo: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagDisplayCc: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
|
|
|
|
stringValue = [sogoObject cc];
|
|
|
|
if (!stringValue)
|
|
|
|
stringValue = @"";
|
|
|
|
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagOriginalDisplayCc: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagDisplayCc: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagDisplayBcc: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getEmptyString: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagOriginalDisplayBcc: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagDisplayBcc: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidNameContentType: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = [@"message/rfc822" asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagImportance: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
uint32_t v;
|
|
|
|
NSString *s;
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
s = [[sogoObject mailHeaders] objectForKey: @"x-priority"];
|
|
|
|
v = 0x1;
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
if ([s hasPrefix: @"1"]) v = 0x2;
|
|
|
|
else if ([s hasPrefix: @"2"]) v = 0x2;
|
|
|
|
else if ([s hasPrefix: @"4"]) v = 0x0;
|
|
|
|
else if ([s hasPrefix: @"5"]) v = 0x0;
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
*data = MAPILongValue (memCtx, v);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagInternetCodepage: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2014-10-02 17:40:12 +02:00
|
|
|
NSNumber *codepage;
|
|
|
|
|
|
|
|
codepage = [Codepages getCodepageFromName: headerCharset];
|
|
|
|
if (!codepage)
|
2015-01-15 13:50:26 +01:00
|
|
|
{
|
|
|
|
[self warnWithFormat: @"Couldn't find codepage from `%@`. "
|
|
|
|
@"Using UTF-8 by default", headerCharset];
|
|
|
|
codepage = [Codepages getCodepageFromName: @"utf-8"];
|
|
|
|
}
|
2014-10-02 17:40:12 +02:00
|
|
|
|
|
|
|
*data = MAPILongValue(memCtx, [codepage intValue]);
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagBody: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-07-19 23:31:16 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
|
|
|
|
if (!bodySetup)
|
2011-07-21 17:05:17 +02:00
|
|
|
[self _fetchBodyData];
|
2011-07-19 23:31:16 +02:00
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
if ([headerMimeType isEqualToString: @"text/plain"])
|
2011-07-19 23:31:16 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
stringValue = [bodyContent bodyStringFromCharset: headerCharset];
|
2011-07-19 23:31:16 +02:00
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
}
|
2011-07-21 17:05:17 +02:00
|
|
|
else if (mailIsEvent)
|
2012-03-02 21:44:24 +01:00
|
|
|
rc = [[self _appointmentWrapper] getPidTagBody: data
|
|
|
|
inMemCtx: memCtx];
|
2011-07-19 23:31:16 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*data = NULL;
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagHtml: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-07-19 23:31:16 +02:00
|
|
|
{
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
|
|
|
|
if (!bodySetup)
|
2011-07-21 17:05:17 +02:00
|
|
|
[self _fetchBodyData];
|
2011-07-19 23:31:16 +02:00
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
if ([headerMimeType isEqualToString: @"text/html"])
|
2011-07-19 23:31:16 +02:00
|
|
|
*data = [bodyContent asBinaryInMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
else
|
|
|
|
{
|
2011-02-24 21:30:01 +01:00
|
|
|
*data = NULL;
|
2011-03-07 20:15:16 +01:00
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
2011-07-19 23:31:16 +02:00
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagRtfCompressed: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = NULL;
|
|
|
|
|
|
|
|
return MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagRtfInSync: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getNo: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagInternetMessageId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = [[sogoObject messageId] asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagReadReceiptRequested: (void **) data // TODO
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getNo: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
- (int) getPidLidGlobalObjectId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidGlobalObjectId: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidCleanGlobalObjectId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidCleanGlobalObjectId: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (int) getPidLidServerProcessed: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidServerProcessed: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
- (int) getPidLidServerProcessingActions: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidServerProcessingActions: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagProcessed: (void **) data inMemCtx: (TALLOC_CTX *) memCtx
|
2011-10-03 22:55:02 +02:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
if (mailIsEvent)
|
|
|
|
rc = [self getYes: data inMemCtx: memCtx];
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - (int) getPidLidServerProcessed: (void **) data
|
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// if (!headerSetup)
|
|
|
|
// [self _fetchHeaderData];
|
|
|
|
|
|
|
|
// return (mailIsEvent
|
|
|
|
// ? [[self _appointmentWrapper] getPidLidServerProcessed: data
|
|
|
|
// inMemCtx: memCtx]
|
|
|
|
// : MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
// }
|
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
- (int) getPidLidPrivate: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-21 17:05:17 +02:00
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidPrivate: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: [self getNo: data inMemCtx: memCtx]);
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMessageEditorFormat: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
uint32_t format;
|
2011-07-21 17:05:17 +02:00
|
|
|
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
if ([headerMimeType isEqualToString: @"text/plain"])
|
2011-04-13 21:59:04 +02:00
|
|
|
format = EDITOR_FORMAT_PLAINTEXT;
|
2011-07-21 17:05:17 +02:00
|
|
|
else if ([headerMimeType isEqualToString: @"text/html"])
|
2011-04-13 21:59:04 +02:00
|
|
|
format = EDITOR_FORMAT_HTML;
|
2011-07-21 17:05:17 +02:00
|
|
|
else
|
|
|
|
format = 0; /* EDITOR_FORMAT_DONTKNOW */
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
*data = MAPILongValue (memCtx, format);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidReminderSet: (void **) data // TODO
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getNo: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidUseTnef: (void **) data // TODO
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getNo: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidRemoteStatus: (void **) data // TODO
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getLongZero: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAgingDontAgeMe: (void **) data // TODO
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getYes: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2011-07-21 17:05:17 +02:00
|
|
|
/* event getters */
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagStartDate: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
2012-03-02 21:44:24 +01:00
|
|
|
? [[self _appointmentWrapper] getPidTagStartDate: data inMemCtx: memCtx]
|
2011-07-21 17:05:17 +02:00
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAppointmentMessageClass: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
if (mailIsEvent)
|
|
|
|
*data = talloc_strdup (memCtx, "IPM.Appointment");
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAppointmentStartWhole: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidAppointmentStartWhole: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidCommonStart: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidCommonStart: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagEndDate: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
2012-03-02 21:44:24 +01:00
|
|
|
? [[self _appointmentWrapper] getPidTagEndDate: data inMemCtx: memCtx]
|
2011-07-21 17:05:17 +02:00
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAppointmentEndWhole: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidAppointmentEndWhole: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidCommonEnd: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidCommonEnd: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAppointmentDuration: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidAppointmentDuration: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAppointmentSubType: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidAppointmentSubType: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidBusyStatus: (void **) data // TODO
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidBusyStatus: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidLocation: (void **) data // LOCATION
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidLocation: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidIsRecurring: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidIsRecurring: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidRecurring: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidRecurring: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAppointmentRecur: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidAppointmentRecur: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagOwnerAppointmentId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-07-21 17:05:17 +02:00
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
2011-08-08 21:01:24 +02:00
|
|
|
return (mailIsEvent
|
2012-03-02 21:44:24 +01:00
|
|
|
? [[self _appointmentWrapper] getPidTagOwnerAppointmentId: data
|
|
|
|
inMemCtx: memCtx]
|
2011-08-08 21:01:24 +02:00
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
|
|
|
}
|
2011-07-21 17:05:17 +02:00
|
|
|
|
2011-08-08 21:01:24 +02:00
|
|
|
- (int) getPidLidMeetingType: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [[self _appointmentWrapper] getPidLidMeetingType: data
|
|
|
|
inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
2011-07-21 17:05:17 +02:00
|
|
|
}
|
|
|
|
|
2015-03-24 18:05:58 +01:00
|
|
|
- (int) getPidTagTransportMessageHeaders: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
NSDictionary *mailHeaders;
|
|
|
|
NSEnumerator *keyEnumerator;
|
|
|
|
NSMutableArray *headers;
|
|
|
|
NGMimeMessageGenerator *g;
|
|
|
|
NSString *headerKey, *fullHeader, *headerGenerated;
|
|
|
|
id headerValue;
|
|
|
|
NSData *headerData;
|
|
|
|
|
|
|
|
/* Let's encode each mail header and put them on 'headers' array */
|
|
|
|
mailHeaders = [sogoObject mailHeaders];
|
|
|
|
headers = [NSMutableArray arrayWithCapacity: [mailHeaders count]];
|
|
|
|
|
|
|
|
g = [[NGMimeMessageGenerator alloc] init];
|
|
|
|
keyEnumerator = [mailHeaders keyEnumerator];
|
|
|
|
while ((headerKey = [keyEnumerator nextObject]))
|
|
|
|
{
|
|
|
|
headerValue = [mailHeaders objectForKey: headerKey];
|
|
|
|
|
|
|
|
headerData = [g generateDataForHeaderField: headerKey value: headerValue];
|
|
|
|
headerGenerated = [[NSString alloc] initWithData: headerData encoding:NSUTF8StringEncoding];
|
|
|
|
fullHeader = [NSString stringWithFormat:@"%@: %@", headerKey, headerGenerated];
|
|
|
|
[headerGenerated release];
|
|
|
|
|
|
|
|
[headers addObject: fullHeader];
|
|
|
|
}
|
|
|
|
[g release];
|
|
|
|
|
|
|
|
*data = [[headers componentsJoinedByString:@"\n"] asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
- (void) getMessageData: (struct mapistore_message **) dataPtr
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
2012-09-05 22:07:17 +02:00
|
|
|
NSArray *addresses;
|
|
|
|
NSString *addressMethods[] = { @"fromEnvelopeAddresses",
|
|
|
|
@"toEnvelopeAddresses",
|
|
|
|
@"ccEnvelopeAddresses",
|
|
|
|
@"bccEnvelopeAddresses" };
|
|
|
|
enum ulRecipClass addressTypes[] = { MAPI_ORIG, MAPI_TO,
|
|
|
|
MAPI_CC, MAPI_BCC };
|
|
|
|
NSUInteger arrayCount, count, recipientStart, max, p;
|
2011-02-24 21:30:01 +01:00
|
|
|
NGImap4EnvelopeAddress *currentAddress;
|
2011-09-30 22:01:50 +02:00
|
|
|
NSString *username, *cn, *email;
|
|
|
|
NSData *entryId;
|
|
|
|
NSDictionary *contactInfos;
|
|
|
|
SOGoUserManager *mgr;
|
2011-11-17 17:15:38 +01:00
|
|
|
struct ldb_context *samCtx;
|
2011-07-13 23:41:58 +02:00
|
|
|
struct mapistore_message *msgData;
|
2011-09-30 22:01:50 +02:00
|
|
|
struct mapistore_message_recipient *recipient;
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-11-17 17:15:38 +01:00
|
|
|
samCtx = [[self context] connectionInfo]->sam_ctx;
|
2011-07-13 23:41:58 +02:00
|
|
|
[super getMessageData: &msgData inMemCtx: memCtx];
|
2011-09-30 22:01:50 +02:00
|
|
|
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
if (mailIsEvent)
|
|
|
|
[[self _appointmentWrapper] fillMessageData: msgData
|
|
|
|
inMemCtx: memCtx];
|
|
|
|
else
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
2012-09-05 22:07:17 +02:00
|
|
|
mgr = [SOGoUserManager sharedUserManager];
|
|
|
|
|
2011-09-30 22:01:50 +02:00
|
|
|
/* Retrieve recipients from the message */
|
|
|
|
|
|
|
|
msgData->columns = set_SPropTagArray (msgData, 9,
|
|
|
|
PR_OBJECT_TYPE,
|
|
|
|
PR_DISPLAY_TYPE,
|
|
|
|
PR_7BIT_DISPLAY_NAME_UNICODE,
|
|
|
|
PR_SMTP_ADDRESS_UNICODE,
|
|
|
|
PR_SEND_INTERNET_ENCODING,
|
|
|
|
PR_RECIPIENT_DISPLAY_NAME_UNICODE,
|
|
|
|
PR_RECIPIENT_FLAGS,
|
|
|
|
PR_RECIPIENT_ENTRYID,
|
|
|
|
PR_RECIPIENT_TRACKSTATUS);
|
|
|
|
|
2012-09-05 22:07:17 +02:00
|
|
|
msgData->recipients_count = 0;
|
|
|
|
msgData->recipients = NULL;
|
|
|
|
|
|
|
|
recipientStart = 0;
|
|
|
|
|
|
|
|
for (arrayCount = 0; arrayCount < 4; arrayCount++)
|
2011-06-07 02:17:46 +02:00
|
|
|
{
|
2012-09-05 22:07:17 +02:00
|
|
|
addresses = [sogoObject performSelector: NSSelectorFromString (addressMethods[arrayCount])];
|
|
|
|
max = [addresses count];
|
|
|
|
if (max > 0)
|
2011-09-30 22:01:50 +02:00
|
|
|
{
|
2012-09-05 22:07:17 +02:00
|
|
|
msgData->recipients_count += max;
|
|
|
|
msgData->recipients = talloc_realloc (msgData, msgData->recipients, struct mapistore_message_recipient, msgData->recipients_count);
|
2011-09-30 22:01:50 +02:00
|
|
|
|
2012-09-05 22:07:17 +02:00
|
|
|
for (count = 0; count < max; count++)
|
2011-10-28 15:10:47 +02:00
|
|
|
{
|
2012-09-05 22:07:17 +02:00
|
|
|
recipient = msgData->recipients + recipientStart;
|
|
|
|
currentAddress = [addresses objectAtIndex: count];
|
|
|
|
cn = [currentAddress personalName];
|
|
|
|
email = [currentAddress baseEMail];
|
|
|
|
if ([cn length] == 0)
|
|
|
|
cn = email;
|
|
|
|
contactInfos = [mgr contactInfosForUserWithUIDorEmail: email];
|
2015-04-15 18:52:55 +02:00
|
|
|
|
2012-09-05 22:07:17 +02:00
|
|
|
if (contactInfos)
|
|
|
|
{
|
2015-04-15 18:52:55 +02:00
|
|
|
username = [contactInfos objectForKey: @"sAMAccountName"];
|
2012-09-05 22:07:17 +02:00
|
|
|
recipient->username = [username asUnicodeInMemCtx: msgData];
|
|
|
|
entryId = MAPIStoreInternalEntryId (samCtx, username);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
recipient->username = NULL;
|
|
|
|
entryId = MAPIStoreExternalEntryId (cn, email);
|
|
|
|
}
|
|
|
|
recipient->type = addressTypes[arrayCount];
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
p = 0;
|
|
|
|
recipient->data = talloc_array (msgData, void *, msgData->columns->cValues);
|
|
|
|
memset (recipient->data, 0, msgData->columns->cValues * sizeof (void *));
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2012-09-05 22:07:17 +02:00
|
|
|
// PR_OBJECT_TYPE = MAPI_MAILUSER (see MAPI_OBJTYPE)
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, MAPI_MAILUSER);
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_DISPLAY_TYPE = DT_MAILUSER (see MS-NSPI)
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, 0);
|
|
|
|
p++;
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2012-09-05 22:07:17 +02:00
|
|
|
// PR_7BIT_DISPLAY_NAME_UNICODE
|
|
|
|
recipient->data[p] = [cn asUnicodeInMemCtx: msgData];
|
|
|
|
p++;
|
2011-09-30 22:01:50 +02:00
|
|
|
|
2012-09-05 22:07:17 +02:00
|
|
|
// PR_SMTP_ADDRESS_UNICODE
|
|
|
|
recipient->data[p] = [email asUnicodeInMemCtx: msgData];
|
|
|
|
p++;
|
2015-09-08 15:37:33 +02:00
|
|
|
|
2012-09-05 22:07:17 +02:00
|
|
|
// PR_SEND_INTERNET_ENCODING = 0x00060000 (plain text, see OXCMAIL)
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, 0x00060000);
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_RECIPIENT_DISPLAY_NAME_UNICODE
|
|
|
|
recipient->data[p] = [cn asUnicodeInMemCtx: msgData];
|
|
|
|
p++;
|
2011-09-30 22:01:50 +02:00
|
|
|
|
2012-09-05 22:07:17 +02:00
|
|
|
// PR_RECIPIENT_FLAGS
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, 0x01);
|
|
|
|
p++;
|
2011-09-30 22:01:50 +02:00
|
|
|
|
2012-09-05 22:07:17 +02:00
|
|
|
// PR_RECIPIENT_ENTRYID
|
|
|
|
recipient->data[p] = [entryId asBinaryInMemCtx: msgData];
|
|
|
|
p++;
|
2011-09-30 22:01:50 +02:00
|
|
|
|
2012-09-05 22:07:17 +02:00
|
|
|
// PR_RECIPIENT_TRACKSTATUS
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, 0x00);
|
|
|
|
p++;
|
2011-09-30 22:01:50 +02:00
|
|
|
|
2012-09-05 22:07:17 +02:00
|
|
|
recipientStart++;
|
|
|
|
}
|
2011-09-30 22:01:50 +02:00
|
|
|
}
|
2011-06-07 02:17:46 +02:00
|
|
|
}
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
2011-07-13 23:41:58 +02:00
|
|
|
*dataPtr = msgData;
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _fetchAttachmentPartsInBodyInfo: (NSDictionary *) bodyInfo
|
|
|
|
withPrefix: (NSString *) keyPrefix
|
|
|
|
{
|
|
|
|
NSArray *parts;
|
|
|
|
NSUInteger count, max;
|
|
|
|
|
2015-08-19 18:56:15 +02:00
|
|
|
if ([[bodyInfo filename] length] > 0)
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
|
|
|
if ([keyPrefix length] == 0)
|
|
|
|
keyPrefix = @"0";
|
|
|
|
[attachmentParts setObject: bodyInfo
|
|
|
|
forKey: keyPrefix];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ([keyPrefix length] > 0)
|
|
|
|
keyPrefix = [NSString stringWithFormat: @"%@/", keyPrefix];
|
|
|
|
parts = [bodyInfo objectForKey: @"parts"];
|
|
|
|
max = [parts count];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
[self _fetchAttachmentPartsInBodyInfo: [parts objectAtIndex: count]
|
|
|
|
withPrefix: [NSString stringWithFormat: @"%@%d",
|
|
|
|
keyPrefix, count + 1]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-28 02:52:38 +02:00
|
|
|
- (NSArray *) attachmentKeysMatchingQualifier: (EOQualifier *) qualifier
|
|
|
|
andSortOrderings: (NSArray *) sortOrderings
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
2011-07-26 22:13:10 +02:00
|
|
|
[self _fetchAttachmentPartsInBodyInfo: [sogoObject bodyStructure]
|
|
|
|
withPrefix: @""];
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-07-26 22:13:10 +02:00
|
|
|
return [super attachmentKeysMatchingQualifier: qualifier
|
|
|
|
andSortOrderings: sortOrderings];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
2011-07-26 21:02:45 +02:00
|
|
|
- (id) lookupAttachment: (NSString *) childKey
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
|
|
|
MAPIStoreMailAttachment *attachment;
|
|
|
|
SOGoMailBodyPart *currentPart;
|
|
|
|
NSArray *keyParts;
|
|
|
|
NSUInteger count, max;
|
|
|
|
|
|
|
|
attachment = nil;
|
|
|
|
|
|
|
|
keyParts = [childKey componentsSeparatedByString: @"/"];
|
|
|
|
max = [keyParts count];
|
|
|
|
if (max > 0)
|
|
|
|
{
|
2015-07-14 17:17:51 +02:00
|
|
|
[[self userContext] activate];
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
currentPart = [sogoObject lookupName: [keyParts objectAtIndex: 0]
|
|
|
|
inContext: nil
|
|
|
|
acquire: NO];
|
|
|
|
if ([currentPart isKindOfClass: NSExceptionK])
|
|
|
|
currentPart = nil;
|
|
|
|
|
|
|
|
for (count = 1; currentPart && count < max; count++)
|
|
|
|
{
|
|
|
|
[parentContainersBag addObject: currentPart];
|
|
|
|
currentPart = [currentPart lookupName: [keyParts objectAtIndex: count]
|
|
|
|
inContext: nil
|
|
|
|
acquire: NO];
|
|
|
|
if ([currentPart isKindOfClass: NSExceptionK])
|
|
|
|
currentPart = nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentPart)
|
|
|
|
{
|
|
|
|
attachment = [MAPIStoreMailAttachment
|
2012-06-29 19:59:38 +02:00
|
|
|
mapiStoreObjectInContainer: self];
|
|
|
|
[attachment setBodyPart: currentPart];
|
2011-02-24 21:30:01 +01:00
|
|
|
[attachment setBodyInfo: [attachmentParts objectForKey: childKey]];
|
2011-07-26 22:13:10 +02:00
|
|
|
[attachment setAID: [[self attachmentKeys] indexOfObject: childKey]];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return attachment;
|
|
|
|
}
|
|
|
|
|
2015-09-04 16:15:05 +02:00
|
|
|
- (enum mapistore_error) setReadFlag: (uint8_t) flag
|
2011-11-01 02:00:33 +01:00
|
|
|
{
|
2015-08-10 18:38:39 +02:00
|
|
|
BOOL modified = NO;
|
|
|
|
BOOL alreadyRead = NO;
|
2011-11-01 15:30:20 +01:00
|
|
|
NSString *imapFlag = @"\\Seen";
|
|
|
|
|
2015-08-10 18:38:39 +02:00
|
|
|
alreadyRead = [[[sogoObject fetchCoreInfos] objectForKey: @"flags"]
|
|
|
|
containsObject: @"seen"];
|
|
|
|
|
2011-11-01 15:30:20 +01:00
|
|
|
/* TODO: notifications should probably be emitted from here */
|
|
|
|
if (flag & CLEAR_READ_FLAG)
|
2015-08-10 18:38:39 +02:00
|
|
|
{
|
|
|
|
[sogoObject removeFlags: imapFlag];
|
|
|
|
modified = alreadyRead;
|
|
|
|
}
|
2011-11-01 15:30:20 +01:00
|
|
|
else
|
2015-08-10 18:38:39 +02:00
|
|
|
{
|
|
|
|
[sogoObject addFlags: imapFlag];
|
|
|
|
modified = !alreadyRead;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (modified)
|
|
|
|
[(MAPIStoreMailFolder *)[self container] synchroniseCache];
|
2011-11-01 15:30:20 +01:00
|
|
|
|
2011-11-01 02:00:33 +01:00
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-10-06 19:02:39 +02:00
|
|
|
- (NSString *) bodyContentPartKey
|
|
|
|
{
|
|
|
|
NSString *bodyPartKey;
|
|
|
|
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
2015-03-13 09:34:21 +01:00
|
|
|
bodyPartKey = mimeKey;
|
2012-10-06 19:02:39 +02:00
|
|
|
|
|
|
|
return bodyPartKey;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setBodyContentFromRawData: (NSData *) rawContent
|
|
|
|
{
|
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
ASSIGN (bodyContent, [rawContent bodyDataFromEncoding: headerEncoding]);
|
|
|
|
bodySetup = YES;
|
|
|
|
}
|
|
|
|
|
2015-03-18 23:57:33 +01:00
|
|
|
- (MAPIStoreSharingMessage *) _sharingObject
|
|
|
|
{
|
|
|
|
/* Get the sharing object if available */
|
|
|
|
NSUInteger i, max;
|
|
|
|
id proxy;
|
|
|
|
|
|
|
|
max = [proxies count];
|
|
|
|
for (i = 0; i < max; i++) {
|
|
|
|
proxy = [proxies objectAtIndex: i];
|
|
|
|
if ([proxy isKindOfClass: MAPIStoreSharingMessageK])
|
|
|
|
return proxy;
|
|
|
|
}
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2015-09-08 15:37:33 +02:00
|
|
|
- (void) save: (TALLOC_CTX *) memCtx
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
|
|
|
NSNumber *value;
|
|
|
|
|
2011-10-26 17:15:17 +02:00
|
|
|
value = [properties objectForKey: MAPIPropertyKey (PR_FLAG_STATUS)];
|
2011-02-24 21:30:01 +01:00
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
/* We don't handle the concept of "Follow Up" */
|
|
|
|
if ([value intValue] == 2)
|
|
|
|
[sogoObject addFlags: @"\\Flagged"];
|
|
|
|
else /* 0: unflagged, 1: follow up complete */
|
|
|
|
[sogoObject removeFlags: @"\\Flagged"];
|
|
|
|
}
|
2015-03-18 23:57:33 +01:00
|
|
|
|
|
|
|
if (mailIsSharingObject)
|
|
|
|
[[self _sharingObject] saveWithMessage: self
|
|
|
|
andSOGoObject: sogoObject];
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|