2011-02-24 21:30:01 +01:00
|
|
|
/* MAPIStoreMailMessage.m - this file is part of SOGo
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Inverse inc
|
|
|
|
*
|
|
|
|
* 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>
|
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>
|
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>
|
|
|
|
|
|
|
|
#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"
|
2011-02-24 21:30:01 +01:00
|
|
|
#import "MAPIStoreTypes.h"
|
|
|
|
|
|
|
|
#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;
|
|
|
|
|
2012-01-29 20:55:21 +01:00
|
|
|
static Class NSExceptionK;
|
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];
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
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];
|
|
|
|
[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];
|
|
|
|
}
|
|
|
|
|
|
|
|
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];
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
NSMutableArray *keys;
|
|
|
|
NSArray *acceptedTypes;
|
|
|
|
NSDictionary *messageData, *partHeaderData, *parameters;
|
|
|
|
|
|
|
|
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"])
|
2011-10-11 23:16:57 +02:00
|
|
|
mailIsEvent = YES;
|
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];
|
|
|
|
|
|
|
|
if (mimeKey)
|
|
|
|
{
|
|
|
|
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;
|
2011-07-28 02:52:38 +02:00
|
|
|
NSNumber *uid, *changeNumber;
|
|
|
|
|
|
|
|
uid = [(MAPIStoreMailFolder *)
|
|
|
|
container messageUIDFromMessageKey: [self nameInContainer]];
|
|
|
|
if (uid)
|
|
|
|
{
|
2011-08-15 21:10:00 +02:00
|
|
|
changeNumber = [(MAPIStoreMailFolder *) container
|
2012-03-02 21:44:24 +01: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-03-02 21:44:24 +01:00
|
|
|
changeNumberForMessageUID: uid];
|
2011-08-15 21:10:00 +02:00
|
|
|
if (changeNumber)
|
|
|
|
[self logWithFormat: @"got one"];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self errorWithFormat: @"still nothing. We crash!"];
|
2011-09-14 20:33:44 +02:00
|
|
|
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) getPidTagSubject: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSString *stringValue;
|
|
|
|
|
2011-07-20 20:30:05 +02:00
|
|
|
stringValue = [self subject];
|
2011-04-13 21:59:04 +02:00
|
|
|
if (!stringValue)
|
|
|
|
stringValue = @"";
|
|
|
|
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
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];
|
|
|
|
|
|
|
|
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];
|
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;
|
|
|
|
}
|
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
/* Note: this applies to regular mails... */
|
2012-03-02 21:44:24 +01:00
|
|
|
// - (int) getPidTagReplyRequested: (void **) data // TODO
|
2011-08-08 21:01:24 +02:00
|
|
|
// inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
// {
|
|
|
|
// if (!headerSetup)
|
|
|
|
// [self _fetchHeaderData];
|
2011-07-21 17:05:17 +02:00
|
|
|
|
2011-08-08 21:01:24 +02:00
|
|
|
// return (mailIsEvent
|
|
|
|
// ? [self getYes: data inMemCtx: memCtx]
|
|
|
|
// : [self getNo: data inMemCtx: memCtx]);
|
|
|
|
// }
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2011-10-03 22:55:02 +02:00
|
|
|
/* ... while this applies to invitations. */
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagResponseRequested: (void **) data // TODO
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-08-08 21:01:24 +02:00
|
|
|
if (!headerSetup)
|
|
|
|
[self _fetchHeaderData];
|
|
|
|
|
|
|
|
return (mailIsEvent
|
|
|
|
? [self getNo: data inMemCtx: memCtx]
|
|
|
|
: MAPISTORE_ERR_NOT_FOUND);
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
*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;
|
|
|
|
|
|
|
|
*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;
|
|
|
|
|
|
|
|
coreInfos = [sogoObject fetchCoreInfos];
|
|
|
|
|
|
|
|
flags = [coreInfos objectForKey: @"flags"];
|
|
|
|
if ([flags containsObject: @"flagged"])
|
|
|
|
v = 6;
|
|
|
|
else
|
|
|
|
v = 0;
|
|
|
|
|
|
|
|
*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]])
|
|
|
|
cn = [ngAddress address];
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
username = [contactInfos objectForKey: @"c_uid"];
|
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];
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
s = [[sogoObject mailHeaders] objectForKey: @"x-priority"];
|
|
|
|
v = 0x1;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
*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
|
|
|
{
|
|
|
|
/* ref:
|
2012-03-02 21:44:24 +01:00
|
|
|
http://msdn.microsoft.com/en-us/library/dd317756%28v=vs.85%29.aspx
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
minimal list that should be handled:
|
|
|
|
us-ascii: 20127
|
|
|
|
iso-8859-1: 28591
|
|
|
|
iso-8859-15: 28605
|
|
|
|
utf-8: 65001 */
|
2011-04-13 21:59:04 +02:00
|
|
|
*data = MAPILongValue(memCtx, 65001);
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagDeleteAfterSubmit: (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];
|
2011-04-13 21:59:04 +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 */
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
NSArray *to;
|
2011-09-30 22:01:50 +02:00
|
|
|
NSInteger count, 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
|
|
|
{
|
2011-09-30 22:01:50 +02:00
|
|
|
/* Retrieve recipients from the message */
|
|
|
|
to = [sogoObject toEnvelopeAddresses];
|
|
|
|
max = [to count];
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (max > 0)
|
2011-06-07 02:17:46 +02:00
|
|
|
{
|
2011-09-30 22:01:50 +02:00
|
|
|
mgr = [SOGoUserManager sharedUserManager];
|
|
|
|
msgData->recipients_count = max;
|
2011-10-28 15:10:47 +02:00
|
|
|
msgData->recipients = talloc_array (msgData, struct mapistore_message_recipient, max);
|
2011-09-30 22:01:50 +02:00
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
2011-10-28 15:10:47 +02:00
|
|
|
recipient = msgData->recipients + count;
|
2011-09-30 22:01:50 +02:00
|
|
|
|
|
|
|
currentAddress = [to objectAtIndex: count];
|
|
|
|
cn = [currentAddress personalName];
|
|
|
|
email = [currentAddress baseEMail];
|
|
|
|
if ([cn length] == 0)
|
|
|
|
cn = email;
|
|
|
|
contactInfos = [mgr contactInfosForUserWithUIDorEmail: email];
|
|
|
|
|
|
|
|
if (contactInfos)
|
|
|
|
{
|
|
|
|
username = [contactInfos objectForKey: @"c_uid"];
|
2011-10-03 22:55:02 +02:00
|
|
|
recipient->username = [username asUnicodeInMemCtx: msgData];
|
2011-11-17 17:15:38 +01:00
|
|
|
entryId = MAPIStoreInternalEntryId (samCtx, username);
|
2011-09-30 22:01:50 +02:00
|
|
|
}
|
|
|
|
else
|
2011-10-28 15:10:47 +02:00
|
|
|
{
|
|
|
|
recipient->username = NULL;
|
|
|
|
entryId = MAPIStoreExternalEntryId (cn, email);
|
|
|
|
}
|
2011-09-30 22:01:50 +02:00
|
|
|
recipient->type = MAPI_TO;
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
p = 0;
|
|
|
|
recipient->data = talloc_array (msgData, void *, msgData->columns->cValues);
|
|
|
|
memset (recipient->data, 0, msgData->columns->cValues * sizeof (void *));
|
|
|
|
|
|
|
|
// 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++;
|
|
|
|
|
|
|
|
// PR_7BIT_DISPLAY_NAME_UNICODE
|
|
|
|
recipient->data[p] = [cn asUnicodeInMemCtx: msgData];
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_SMTP_ADDRESS_UNICODE
|
|
|
|
recipient->data[p] = [email asUnicodeInMemCtx: msgData];
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// 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++;
|
|
|
|
|
|
|
|
// PR_RECIPIENT_FLAGS
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, 0x01);
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_RECIPIENT_ENTRYID
|
|
|
|
recipient->data[p] = [entryId asBinaryInMemCtx: msgData];
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// PR_RECIPIENT_TRACKSTATUS
|
|
|
|
recipient->data[p] = MAPILongValue (msgData, 0x00);
|
|
|
|
p++;
|
|
|
|
}
|
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;
|
2011-02-24 21:56:44 +01:00
|
|
|
NSDictionary *parameters;
|
2011-02-24 21:30:01 +01:00
|
|
|
NSUInteger count, max;
|
|
|
|
|
2011-02-24 21:56:44 +01:00
|
|
|
parameters = [[bodyInfo objectForKey: @"disposition"]
|
|
|
|
objectForKey: @"parameterList"];
|
|
|
|
if ([[parameters objectForKey: @"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)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
mapiStoreObjectWithSOGoObject: currentPart
|
|
|
|
inContainer: self];
|
|
|
|
[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;
|
|
|
|
}
|
|
|
|
|
2011-11-01 02:00:33 +01:00
|
|
|
- (int) setReadFlag: (uint8_t) flag
|
|
|
|
{
|
2011-11-01 15:30:20 +01:00
|
|
|
NSString *imapFlag = @"\\Seen";
|
|
|
|
|
|
|
|
/* TODO: notifications should probably be emitted from here */
|
|
|
|
if (flag & CLEAR_READ_FLAG)
|
|
|
|
[sogoObject removeFlags: imapFlag];
|
|
|
|
else
|
|
|
|
[sogoObject addFlags: imapFlag];
|
|
|
|
|
2011-11-01 02:00:33 +01:00
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
- (void) save
|
|
|
|
{
|
|
|
|
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"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|