2011-02-24 21:30:01 +01:00
|
|
|
/* MAPIStoreMessage.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>
|
|
|
|
*
|
|
|
|
* 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-11-09 16:02:04 +01:00
|
|
|
#import <Foundation/NSBundle.h>
|
2011-09-30 22:01:50 +02:00
|
|
|
#import <Foundation/NSData.h>
|
2011-07-13 23:41:58 +02:00
|
|
|
#import <Foundation/NSDictionary.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <Foundation/NSString.h>
|
2011-04-13 21:59:04 +02:00
|
|
|
#import <Foundation/NSURL.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
|
|
|
#import <SOGo/SOGoObject.h>
|
2011-12-01 22:13:09 +01:00
|
|
|
#import <SOGo/SOGoPermissions.h>
|
2011-07-13 23:41:58 +02:00
|
|
|
#import <SOGo/SOGoUser.h>
|
2011-02-24 21:30:01 +01:00
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
#import "MAPIStoreActiveTables.h"
|
|
|
|
#import "MAPIStoreAttachment.h"
|
2011-04-20 00:26:47 +02:00
|
|
|
#import "MAPIStoreAttachmentTable.h"
|
2011-04-13 21:59:04 +02:00
|
|
|
#import "MAPIStoreContext.h"
|
2012-09-19 22:05:52 +02:00
|
|
|
#import "MAPIStoreEmbeddedMessage.h"
|
2011-07-13 23:41:58 +02:00
|
|
|
#import "MAPIStoreFolder.h"
|
2012-06-29 19:59:38 +02:00
|
|
|
#import "MAPIStoreMessageTable.h"
|
2011-09-30 22:01:50 +02:00
|
|
|
#import "MAPIStorePropertySelectors.h"
|
2011-11-17 19:39:42 +01:00
|
|
|
#import "MAPIStoreSamDBUtils.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
#import "MAPIStoreTypes.h"
|
2012-01-29 20:55:21 +01:00
|
|
|
#import "MAPIStoreUserContext.h"
|
2011-09-30 22:01:50 +02: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"
|
2013-03-27 00:32:08 +01:00
|
|
|
#import "RTFHandler.h"
|
2011-02-24 21:30:01 +01:00
|
|
|
|
|
|
|
#import "MAPIStoreMessage.h"
|
|
|
|
|
|
|
|
#undef DEBUG
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <gen_ndr/exchange.h>
|
|
|
|
#include <mapistore/mapistore.h>
|
|
|
|
#include <mapistore/mapistore_errors.h>
|
|
|
|
|
2012-09-19 22:05:52 +02:00
|
|
|
static Class MAPIStoreFolderK, MAPIStoreEmbeddedMessageK;
|
|
|
|
|
2011-11-09 16:02:04 +01:00
|
|
|
static NSString *resourcesDir = nil;
|
|
|
|
|
|
|
|
static NSData *
|
|
|
|
uncompressRTF (NSData *compressedRTF)
|
|
|
|
{
|
|
|
|
NSData *rtfData = nil;
|
|
|
|
DATA_BLOB *rtf;
|
|
|
|
TALLOC_CTX *mem_ctx;
|
|
|
|
|
|
|
|
mem_ctx = talloc_zero (NULL, TALLOC_CTX);
|
|
|
|
rtf = talloc_zero (mem_ctx, DATA_BLOB);
|
|
|
|
|
|
|
|
if (uncompress_rtf (mem_ctx,
|
|
|
|
(uint8_t *) [compressedRTF bytes], [compressedRTF length],
|
|
|
|
rtf)
|
|
|
|
== MAPI_E_SUCCESS)
|
|
|
|
rtfData = [NSData dataWithBytes: rtf->data length: rtf->length];
|
|
|
|
|
|
|
|
talloc_free (mem_ctx);
|
|
|
|
|
|
|
|
return rtfData;
|
|
|
|
}
|
|
|
|
|
|
|
|
static NSData *
|
|
|
|
rtf2html (NSData *compressedRTF)
|
|
|
|
{
|
|
|
|
NSData *rtf;
|
|
|
|
NSMutableData *html = nil;
|
|
|
|
|
|
|
|
rtf = uncompressRTF (compressedRTF);
|
|
|
|
if (rtf)
|
|
|
|
{
|
2013-03-27 00:32:08 +01:00
|
|
|
//html = [NSMutableData data];
|
|
|
|
RTFHandler *handler;
|
|
|
|
|
|
|
|
handler = [[RTFHandler alloc] initWithData: rtf];
|
|
|
|
AUTORELEASE(handler);
|
|
|
|
|
|
|
|
html = [handler parse];
|
2011-11-09 16:02:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return html;
|
|
|
|
}
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
@interface SOGoObject (MAPIStoreProtocol)
|
|
|
|
|
|
|
|
- (NSString *) davContentLength;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation MAPIStoreMessage
|
|
|
|
|
2011-11-09 16:02:04 +01:00
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
if (!resourcesDir)
|
|
|
|
{
|
|
|
|
resourcesDir = [[NSBundle bundleForClass: self] resourcePath];
|
|
|
|
[resourcesDir retain];
|
|
|
|
}
|
2012-07-20 17:44:25 +02:00
|
|
|
MAPIStoreFolderK = [MAPIStoreFolder class];
|
2012-09-19 22:05:52 +02:00
|
|
|
MAPIStoreEmbeddedMessageK = [MAPIStoreEmbeddedMessage class];
|
2011-11-09 16:02:04 +01:00
|
|
|
}
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
- (id) init
|
|
|
|
{
|
2013-03-13 20:04:11 +01:00
|
|
|
//[self logWithFormat: @"METHOD '%s' (%d) (%d)", __FUNCTION__, __LINE__, self];
|
2012-12-03 15:18:17 +01:00
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
2011-07-15 22:22:27 +02:00
|
|
|
attachmentParts = [NSMutableDictionary new];
|
2011-03-07 20:15:16 +01:00
|
|
|
activeTables = [NSMutableArray new];
|
2011-12-01 22:13:09 +01:00
|
|
|
activeUserRoles = nil;
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
2013-03-13 20:04:11 +01:00
|
|
|
//[self logWithFormat: @"METHOD '%s' (%d) (%d)", __FUNCTION__, __LINE__, self];
|
2011-12-01 22:13:09 +01:00
|
|
|
[activeUserRoles release];
|
2011-02-24 21:30:01 +01:00
|
|
|
[attachmentKeys release];
|
|
|
|
[attachmentParts release];
|
2011-03-07 20:15:16 +01:00
|
|
|
[activeTables release];
|
2011-02-24 21:30:01 +01:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
void *propValue;
|
2011-07-13 23:41:58 +02:00
|
|
|
struct mapistore_message *msgData;
|
2011-02-24 21:30:01 +01:00
|
|
|
|
|
|
|
// [self logWithFormat: @"INCOMPLETE METHOD '%s' (%d): no recipient handling",
|
|
|
|
// __FUNCTION__, __LINE__];
|
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
msgData = talloc_zero (memCtx, struct mapistore_message);
|
2012-03-02 21:44:24 +01:00
|
|
|
|
|
|
|
if ([self getPidTagSubjectPrefix: &propValue
|
|
|
|
inMemCtx: msgData] == MAPISTORE_SUCCESS
|
2011-09-30 22:01:50 +02:00
|
|
|
&& propValue)
|
|
|
|
msgData->subject_prefix = propValue;
|
|
|
|
else
|
|
|
|
msgData->subject_prefix = "";
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
if ([self getPidTagNormalizedSubject: &propValue
|
|
|
|
inMemCtx: msgData] == MAPISTORE_SUCCESS
|
2011-09-30 22:01:50 +02:00
|
|
|
&& propValue)
|
|
|
|
msgData->normalized_subject = propValue;
|
|
|
|
else
|
|
|
|
msgData->normalized_subject = "";
|
|
|
|
|
|
|
|
msgData->columns = talloc_zero(msgData, struct SPropTagArray);
|
|
|
|
msgData->recipients_count = 0;
|
2011-07-13 23:41:58 +02:00
|
|
|
*dataPtr = msgData;
|
|
|
|
}
|
|
|
|
|
2011-10-28 15:10:47 +02:00
|
|
|
- (NSDictionary *) _convertRecipient: (struct mapistore_message_recipient *) recipient
|
|
|
|
andColumns: (struct SPropTagArray *) columns
|
2011-07-13 23:41:58 +02:00
|
|
|
{
|
2011-10-28 15:10:47 +02:00
|
|
|
NSMutableDictionary *recipientProperties;
|
2015-03-03 17:03:29 +01:00
|
|
|
enum MAPITAGS prop_tag;
|
|
|
|
char *displayName = NULL;
|
|
|
|
char *email = NULL;
|
|
|
|
enum MAPI_OBJTYPE object_type = 0;
|
|
|
|
char *smtpAddress = NULL;
|
2011-07-13 23:41:58 +02:00
|
|
|
SOGoUser *recipientUser;
|
2011-10-28 15:10:47 +02:00
|
|
|
NSUInteger count;
|
2015-03-03 17:03:29 +01:00
|
|
|
NSString *recipientEmail = nil;
|
|
|
|
NSString *recipientFullName = nil;
|
2011-10-03 22:53:56 +02:00
|
|
|
id value;
|
2011-07-13 23:41:58 +02:00
|
|
|
|
2011-10-28 15:10:47 +02:00
|
|
|
recipientProperties = [NSMutableDictionary dictionaryWithCapacity: columns->cValues + 2];
|
2011-07-13 23:41:58 +02:00
|
|
|
|
2015-03-03 17:03:29 +01:00
|
|
|
for (count = 0; count < columns->cValues; count++)
|
|
|
|
{
|
|
|
|
prop_tag = columns->aulPropTag[count];
|
|
|
|
switch(prop_tag) {
|
|
|
|
case PidTagDisplayName:
|
|
|
|
displayName = recipient->data[count];
|
|
|
|
break;
|
|
|
|
case PidTagEmailAddress:
|
|
|
|
email = recipient->data[count];
|
|
|
|
break;
|
|
|
|
case PidTagObjectType:
|
|
|
|
object_type = *((uint8_t*) recipient->data[count]);
|
|
|
|
break;
|
|
|
|
case PidTagSmtpAddress:
|
|
|
|
smtpAddress = recipient->data[count];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (recipient->data[count])
|
|
|
|
{
|
|
|
|
value = NSObjectFromValuePointer (prop_tag,
|
|
|
|
recipient->data[count]);
|
|
|
|
if (value)
|
|
|
|
[recipientProperties setObject: value
|
|
|
|
forKey: MAPIPropertyKey (prop_tag)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-28 15:10:47 +02:00
|
|
|
if (recipient->username)
|
2011-07-13 23:41:58 +02:00
|
|
|
{
|
2011-10-28 15:10:47 +02:00
|
|
|
value = [NSString stringWithUTF8String: recipient->username];
|
|
|
|
[recipientProperties setObject: value forKey: @"x500dn"];
|
2015-03-03 17:03:29 +01:00
|
|
|
}
|
2011-07-13 23:41:58 +02:00
|
|
|
|
2015-03-03 17:03:29 +01:00
|
|
|
if (object_type == MAPI_MAILUSER && recipient->username)
|
|
|
|
{
|
|
|
|
/* values from user object have priority uppon the data passed for the client */
|
2011-07-13 23:41:58 +02:00
|
|
|
recipientUser = [SOGoUser userWithLogin: [value lowercaseString]];
|
|
|
|
if (recipientUser)
|
|
|
|
{
|
|
|
|
value = [recipientUser cn];
|
|
|
|
if ([value length] > 0)
|
2015-03-03 17:03:29 +01:00
|
|
|
recipientFullName = value;
|
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
value = [[recipientUser allEmails] objectAtIndex: 0];
|
|
|
|
if ([value length] > 0)
|
2015-03-03 17:03:29 +01:00
|
|
|
recipientEmail = value;
|
|
|
|
}
|
2011-07-13 23:41:58 +02:00
|
|
|
}
|
2015-03-03 17:03:29 +01:00
|
|
|
|
|
|
|
/* If we do not have values from the user object we try to get them from the parameters */
|
|
|
|
if (!recipientFullName && displayName)
|
2011-07-13 23:41:58 +02:00
|
|
|
{
|
2015-03-03 17:03:29 +01:00
|
|
|
value = [NSString stringWithUTF8String: displayName];
|
|
|
|
if ([value length] > 0)
|
|
|
|
recipientFullName = value;
|
2011-07-13 23:41:58 +02:00
|
|
|
}
|
|
|
|
|
2015-03-03 17:03:29 +01:00
|
|
|
if (!recipientEmail && email)
|
2011-10-03 22:53:56 +02:00
|
|
|
{
|
2015-03-03 17:03:29 +01:00
|
|
|
value = [NSString stringWithUTF8String: email];
|
|
|
|
if ([value length] > 0)
|
|
|
|
recipientEmail = value;
|
2011-10-03 22:53:56 +02:00
|
|
|
}
|
|
|
|
|
2015-03-03 17:03:29 +01:00
|
|
|
if (!recipientEmail && smtpAddress)
|
|
|
|
{
|
|
|
|
value = [NSString stringWithUTF8String: smtpAddress];
|
|
|
|
if ([value length] > 0)
|
|
|
|
recipientEmail = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now we can set the properties if we have them */
|
|
|
|
if (recipientFullName)
|
|
|
|
[recipientProperties setObject: recipientFullName forKey: @"fullName"];
|
|
|
|
|
|
|
|
if (recipientEmail)
|
|
|
|
[recipientProperties setObject: recipientEmail forKey: @"email"];
|
|
|
|
|
2011-10-28 15:10:47 +02:00
|
|
|
return recipientProperties;
|
2011-07-13 23:41:58 +02:00
|
|
|
}
|
|
|
|
|
2011-10-28 15:10:47 +02:00
|
|
|
- (int) modifyRecipientsWithRecipients: (struct mapistore_message_recipient *) newRecipients
|
|
|
|
andCount: (NSUInteger) max
|
|
|
|
andColumns: (struct SPropTagArray *) columns;
|
2011-07-13 23:41:58 +02:00
|
|
|
{
|
|
|
|
static NSString *recTypes[] = { @"orig", @"to", @"cc", @"bcc" };
|
|
|
|
NSDictionary *recipientProperties;
|
|
|
|
NSMutableDictionary *recipients;
|
|
|
|
NSMutableArray *list;
|
|
|
|
NSString *recType;
|
2011-10-28 15:10:47 +02:00
|
|
|
struct mapistore_message_recipient *recipient;
|
2011-07-13 23:41:58 +02:00
|
|
|
NSUInteger count;
|
|
|
|
|
2013-03-13 20:04:11 +01:00
|
|
|
//[self logWithFormat: @"METHOD '%s'", __FUNCTION__];
|
2011-07-13 23:41:58 +02:00
|
|
|
|
|
|
|
recipients = [NSMutableDictionary new];
|
|
|
|
recipientProperties = [NSDictionary dictionaryWithObject: recipients
|
|
|
|
forKey: @"recipients"];
|
|
|
|
[recipients release];
|
|
|
|
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
2011-10-28 15:10:47 +02:00
|
|
|
recipient = newRecipients + count;
|
2011-07-13 23:41:58 +02:00
|
|
|
|
2011-10-28 15:10:47 +02:00
|
|
|
if (recipient->type >= MAPI_ORIG && recipient->type <= MAPI_BCC)
|
2011-07-13 23:41:58 +02:00
|
|
|
{
|
2011-10-28 15:10:47 +02:00
|
|
|
recType = recTypes[recipient->type];
|
2011-07-13 23:41:58 +02:00
|
|
|
list = [recipients objectForKey: recType];
|
|
|
|
if (!list)
|
|
|
|
{
|
|
|
|
list = [NSMutableArray new];
|
|
|
|
[recipients setObject: list forKey: recType];
|
|
|
|
[list release];
|
|
|
|
}
|
2011-10-03 22:53:56 +02:00
|
|
|
[list addObject:
|
2011-10-28 15:10:47 +02:00
|
|
|
[self _convertRecipient: recipient andColumns: columns]];
|
2011-07-13 23:41:58 +02:00
|
|
|
}
|
|
|
|
}
|
2011-10-26 17:15:17 +02:00
|
|
|
[self addProperties: recipientProperties];
|
2011-07-13 23:41:58 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-12-01 23:36:35 +01:00
|
|
|
- (int) addPropertiesFromRow: (struct SRow *) aRow
|
|
|
|
{
|
|
|
|
enum mapistore_error rc;
|
|
|
|
MAPIStoreContext *context;
|
2012-01-29 20:55:21 +01:00
|
|
|
SOGoUser *ownerUser;
|
2012-09-24 16:24:46 +02:00
|
|
|
BOOL userIsOwner;
|
|
|
|
MAPIStoreMessage *mainMessage;
|
2011-12-01 23:36:35 +01:00
|
|
|
|
|
|
|
context = [self context];
|
2012-01-29 20:55:21 +01:00
|
|
|
ownerUser = [[self userContext] sogoUser];
|
2012-09-24 16:24:46 +02:00
|
|
|
userIsOwner = [[context activeUser] isEqual: ownerUser];
|
|
|
|
if (userIsOwner)
|
|
|
|
mainMessage = nil;
|
|
|
|
else if ([self isKindOfClass: MAPIStoreEmbeddedMessageK])
|
|
|
|
mainMessage = (MAPIStoreMessage *) [[self container] container];
|
|
|
|
else
|
|
|
|
mainMessage = self;
|
|
|
|
|
|
|
|
if (userIsOwner || [mainMessage subscriberCanModifyMessage])
|
2011-12-01 23:36:35 +01:00
|
|
|
rc = [super addPropertiesFromRow: aRow];
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_DENIED;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-11-09 16:02:04 +01:00
|
|
|
- (void) addProperties: (NSDictionary *) newNewProperties
|
|
|
|
{
|
|
|
|
NSData *htmlData, *rtfData;
|
|
|
|
static NSNumber *htmlKey = nil, *rtfKey = nil;
|
|
|
|
|
2012-06-29 19:59:38 +02:00
|
|
|
/* we intercept any RTF content and convert it to HTML */
|
2011-11-09 16:02:04 +01:00
|
|
|
[super addProperties: newNewProperties];
|
|
|
|
|
|
|
|
if (!htmlKey)
|
|
|
|
{
|
|
|
|
htmlKey = MAPIPropertyKey (PR_HTML);
|
|
|
|
[htmlKey retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rtfKey)
|
|
|
|
{
|
|
|
|
rtfKey = MAPIPropertyKey (PR_RTF_COMPRESSED);
|
|
|
|
[rtfKey retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (![properties objectForKey: htmlKey])
|
|
|
|
{
|
|
|
|
rtfData = [properties objectForKey: rtfKey];
|
|
|
|
if (rtfData)
|
|
|
|
{
|
|
|
|
htmlData = rtf2html (rtfData);
|
|
|
|
[properties setObject: htmlData forKey: htmlKey];
|
|
|
|
[properties removeObjectForKey: rtfKey];
|
|
|
|
[properties removeObjectForKey: MAPIPropertyKey (PR_RTF_IN_SYNC)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-15 22:22:27 +02:00
|
|
|
- (MAPIStoreAttachment *) createAttachment
|
|
|
|
{
|
|
|
|
MAPIStoreAttachment *newAttachment;
|
|
|
|
uint32_t newAid;
|
|
|
|
NSString *newKey;
|
|
|
|
|
2011-07-26 22:13:10 +02:00
|
|
|
newAid = [[self attachmentKeys] count];
|
2011-07-15 22:22:27 +02:00
|
|
|
|
2012-06-29 19:59:38 +02:00
|
|
|
newAttachment = [MAPIStoreAttachment mapiStoreObjectInContainer: self];
|
|
|
|
// [newAttachment setIsNew: YES];
|
2011-07-15 22:22:27 +02:00
|
|
|
[newAttachment setAID: newAid];
|
|
|
|
newKey = [NSString stringWithFormat: @"%ul", newAid];
|
|
|
|
[attachmentParts setObject: newAttachment
|
|
|
|
forKey: newKey];
|
2011-07-26 22:13:10 +02:00
|
|
|
[attachmentKeys release];
|
|
|
|
attachmentKeys = nil;
|
2011-07-15 22:22:27 +02:00
|
|
|
|
|
|
|
return newAttachment;
|
|
|
|
}
|
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
- (int) createAttachment: (MAPIStoreAttachment **) attachmentPtr
|
|
|
|
inAID: (uint32_t *) aidPtr
|
|
|
|
{
|
|
|
|
MAPIStoreAttachment *attachment;
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
|
|
|
|
attachment = [self createAttachment];
|
|
|
|
if (attachment)
|
|
|
|
{
|
|
|
|
*attachmentPtr = attachment;
|
|
|
|
*aidPtr = [attachment AID];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-07-26 21:02:45 +02:00
|
|
|
- (id) lookupAttachment: (NSString *) childKey
|
|
|
|
{
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
- (int) getAttachment: (MAPIStoreAttachment **) attachmentPtr
|
|
|
|
withAID: (uint32_t) aid
|
|
|
|
{
|
|
|
|
MAPIStoreAttachment *attachment;
|
|
|
|
NSArray *keys;
|
|
|
|
int rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
2011-07-26 22:13:10 +02:00
|
|
|
keys = [self attachmentKeys];
|
2011-07-13 23:41:58 +02:00
|
|
|
if (aid < [keys count])
|
|
|
|
{
|
2011-07-26 21:02:45 +02:00
|
|
|
attachment = [self lookupAttachment: [keys objectAtIndex: aid]];
|
2011-07-13 23:41:58 +02:00
|
|
|
if (attachment)
|
|
|
|
{
|
|
|
|
*attachmentPtr = attachment;
|
|
|
|
rc = MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getAttachmentTable: (MAPIStoreAttachmentTable **) tablePtr
|
|
|
|
andRowCount: (uint32_t *) countPtr
|
|
|
|
{
|
|
|
|
MAPIStoreAttachmentTable *attTable;
|
|
|
|
int rc = MAPISTORE_SUCCESS;
|
|
|
|
|
|
|
|
attTable = [self attachmentTable];
|
|
|
|
if (attTable)
|
|
|
|
{
|
|
|
|
*tablePtr = attTable;
|
2011-07-26 22:13:10 +02:00
|
|
|
*countPtr = [[attTable childKeys] count];
|
2011-07-13 23:41:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) activeContainerMessageTables
|
|
|
|
{
|
|
|
|
return [[MAPIStoreActiveTables activeTables]
|
2012-03-02 21:44:24 +01:00
|
|
|
activeTablesForFMID: [container objectId]
|
|
|
|
andType: MAPISTORE_MESSAGE_TABLE];
|
2011-07-13 23:41:58 +02:00
|
|
|
}
|
|
|
|
|
2012-12-03 15:18:17 +01:00
|
|
|
- (void) copyToMessage: (MAPIStoreMessage *) newMessage inMemCtx: (TALLOC_CTX *) memCtx;
|
2012-08-15 03:02:08 +02:00
|
|
|
|
|
|
|
{
|
2012-12-03 15:18:17 +01:00
|
|
|
//TALLOC_CTX *memCtx;
|
2012-08-15 03:02:08 +02:00
|
|
|
struct mapistore_message *messageData;
|
|
|
|
NSArray *keys;
|
|
|
|
NSUInteger count, max;
|
|
|
|
NSString *key;
|
|
|
|
MAPIStoreAttachment *attachment, *newAttachment;
|
|
|
|
|
2013-03-13 20:04:11 +01:00
|
|
|
//[self logWithFormat: @"METHOD '%s' (%d) (%d)", __FUNCTION__, __LINE__, self];
|
2012-12-03 15:18:17 +01:00
|
|
|
|
|
|
|
//memCtx = talloc_zero (NULL, TALLOC_CTX);
|
2012-08-15 03:02:08 +02:00
|
|
|
|
|
|
|
/* message headers and recipients */
|
|
|
|
[self getMessageData: &messageData inMemCtx: memCtx];
|
|
|
|
[newMessage modifyRecipientsWithRecipients: messageData->recipients
|
|
|
|
andCount: messageData->recipients_count
|
|
|
|
andColumns: messageData->columns];
|
|
|
|
|
|
|
|
/* properties */
|
2012-12-03 15:18:17 +01:00
|
|
|
[self copyPropertiesToObject: newMessage inMemCtx: memCtx];
|
2012-08-15 03:02:08 +02:00
|
|
|
|
|
|
|
/* attachments */
|
|
|
|
keys = [self attachmentKeys];
|
|
|
|
max = [keys count];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
key = [keys objectAtIndex: count];
|
|
|
|
attachment = [self lookupAttachment: key];
|
|
|
|
newAttachment = [newMessage createAttachment];
|
2012-12-03 15:18:17 +01:00
|
|
|
[attachment copyToAttachment: newAttachment inMemCtx: memCtx];
|
2012-08-15 03:02:08 +02:00
|
|
|
}
|
|
|
|
|
2012-12-03 15:18:17 +01:00
|
|
|
//talloc_free (memCtx);
|
2012-08-15 03:02:08 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 20:04:11 +01:00
|
|
|
- (enum mapistore_error) saveMessage: (TALLOC_CTX *) memCtx
|
2011-07-13 23:41:58 +02:00
|
|
|
{
|
2011-12-01 23:36:35 +01:00
|
|
|
enum mapistore_error rc;
|
2011-07-13 23:41:58 +02:00
|
|
|
NSArray *containerTables;
|
|
|
|
NSUInteger count, max;
|
2011-12-01 23:36:35 +01:00
|
|
|
MAPIStoreContext *context;
|
2012-01-29 20:55:21 +01:00
|
|
|
SOGoUser *ownerUser;
|
2012-09-24 16:24:46 +02:00
|
|
|
BOOL userIsOwner;
|
|
|
|
MAPIStoreMessage *mainMessage;
|
2011-07-13 23:41:58 +02:00
|
|
|
|
2013-03-13 20:04:11 +01:00
|
|
|
//[self logWithFormat: @"METHOD '%s' (%d)", __FUNCTION__, __LINE__];
|
2015-01-19 15:35:44 +01:00
|
|
|
|
|
|
|
containerTables = nil;
|
|
|
|
max = 0;
|
2011-12-01 23:36:35 +01:00
|
|
|
context = [self context];
|
2012-01-29 20:55:21 +01:00
|
|
|
ownerUser = [[self userContext] sogoUser];
|
2012-09-24 16:24:46 +02:00
|
|
|
userIsOwner = [[context activeUser] isEqual: ownerUser];
|
|
|
|
if (userIsOwner)
|
|
|
|
mainMessage = nil;
|
|
|
|
else if ([self isKindOfClass: MAPIStoreEmbeddedMessageK])
|
|
|
|
mainMessage = (MAPIStoreMessage *) [[self container] container];
|
|
|
|
else
|
|
|
|
mainMessage = self;
|
|
|
|
|
|
|
|
if (userIsOwner
|
|
|
|
|| ([self isKindOfClass: MAPIStoreEmbeddedMessageK]
|
|
|
|
&& [mainMessage subscriberCanModifyMessage])
|
|
|
|
|| (![self isKindOfClass: MAPIStoreEmbeddedMessageK]
|
|
|
|
&& ((isNew
|
|
|
|
&& [(MAPIStoreFolder *) container subscriberCanCreateMessages])
|
|
|
|
|| (!isNew && [self subscriberCanModifyMessage]))))
|
2011-07-13 23:41:58 +02:00
|
|
|
{
|
2011-12-01 23:36:35 +01:00
|
|
|
/* notifications */
|
2012-07-20 17:44:25 +02:00
|
|
|
if ([container isKindOfClass: MAPIStoreFolderK])
|
2011-12-01 23:36:35 +01:00
|
|
|
{
|
2012-07-20 17:44:25 +02:00
|
|
|
/* we ensure the table caches are loaded so that old and new state
|
|
|
|
can be compared */
|
|
|
|
containerTables = [self activeContainerMessageTables];
|
|
|
|
max = [containerTables count];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
[[containerTables objectAtIndex: count] restrictedChildKeys];
|
|
|
|
}
|
2011-12-01 23:36:35 +01:00
|
|
|
|
2013-03-13 20:04:11 +01:00
|
|
|
[self save: memCtx];
|
2012-08-08 21:09:22 +02:00
|
|
|
/* We make sure that any change-related properties are removes from the
|
|
|
|
properties dictionary, to make sure that related methods will be
|
|
|
|
invoked the next time they are requested. */
|
|
|
|
[properties removeObjectForKey: MAPIPropertyKey (PidTagChangeKey)];
|
|
|
|
[properties removeObjectForKey: MAPIPropertyKey (PidTagChangeNumber)];
|
2011-12-01 23:36:35 +01:00
|
|
|
|
2012-07-20 17:44:25 +02:00
|
|
|
if ([container isKindOfClass: MAPIStoreFolderK])
|
|
|
|
{
|
|
|
|
/* table modified */
|
|
|
|
for (count = 0; count < max; count++)
|
2012-09-12 16:42:24 +02:00
|
|
|
{
|
|
|
|
id table;
|
|
|
|
|
|
|
|
table = [containerTables objectAtIndex: count];
|
|
|
|
|
|
|
|
/* Safety check here as we could have MAPIStorePermissionsTable instances
|
|
|
|
in our containerTables array. This code might need to be reworked later */
|
|
|
|
if ([table respondsToSelector: @selector(notifyChangesForChild:)])
|
|
|
|
[table notifyChangesForChild: self];
|
|
|
|
}
|
2012-07-20 17:44:25 +02:00
|
|
|
[container cleanupCaches];
|
|
|
|
}
|
2011-12-01 23:36:35 +01:00
|
|
|
[self setIsNew: NO];
|
|
|
|
rc = MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERR_DENIED;
|
2011-07-13 23:41:58 +02:00
|
|
|
|
2011-12-01 23:36:35 +01:00
|
|
|
return rc;
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
/* getters */
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagInstID: (void **) data // TODO: DOUBT
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
/* we return a unique id based on the key */
|
|
|
|
*data = MAPILongLongValue (memCtx, [[sogoObject nameInContainer] hash]);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagInstanceNum: (void **) data // TODO: DOUBT
|
|
|
|
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) getPidTagRowType: (void **) data // TODO: DOUBT
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = MAPILongValue (memCtx, TBL_LEAF_ROW);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagDepth: (void **) data // TODO: DOUBT
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = MAPILongLongValue (memCtx, 0);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-12-02 18:16:02 +01:00
|
|
|
/*
|
|
|
|
Possible values are:
|
|
|
|
|
|
|
|
0x00000001 Modify
|
|
|
|
0x00000002 Read
|
|
|
|
0x00000004 Delete
|
|
|
|
0x00000008 Create Hierarchy Table
|
|
|
|
0x00000010 Create Contents Table
|
|
|
|
0x00000020 Create Associated Contents Table
|
|
|
|
*/
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagAccess: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-12-02 18:16:02 +01:00
|
|
|
uint32_t access = 0;
|
|
|
|
BOOL userIsOwner;
|
|
|
|
MAPIStoreContext *context;
|
2012-01-29 20:55:21 +01:00
|
|
|
SOGoUser *ownerUser;
|
2012-09-24 16:24:46 +02:00
|
|
|
MAPIStoreMessage *mainMessage;
|
2011-12-02 18:16:02 +01:00
|
|
|
|
|
|
|
context = [self context];
|
2012-01-29 20:55:21 +01:00
|
|
|
ownerUser = [[self userContext] sogoUser];
|
|
|
|
userIsOwner = [[context activeUser] isEqual: ownerUser];
|
2012-09-24 16:24:46 +02:00
|
|
|
if (userIsOwner)
|
|
|
|
mainMessage = nil;
|
|
|
|
else if ([self isKindOfClass: MAPIStoreEmbeddedMessageK])
|
|
|
|
mainMessage = (MAPIStoreMessage *) [[self container] container];
|
|
|
|
else
|
|
|
|
mainMessage = self;
|
|
|
|
|
|
|
|
if (userIsOwner || [mainMessage subscriberCanModifyMessage])
|
2011-12-02 18:16:02 +01:00
|
|
|
access |= 0x01;
|
2012-09-24 16:24:46 +02:00
|
|
|
if (userIsOwner || [mainMessage subscriberCanReadMessage])
|
2011-12-02 18:16:02 +01:00
|
|
|
access |= 0x02;
|
2012-09-24 16:24:46 +02:00
|
|
|
if (userIsOwner
|
|
|
|
|| ([self isKindOfClass: MAPIStoreEmbeddedMessageK]
|
|
|
|
&& [mainMessage subscriberCanModifyMessage])
|
|
|
|
|| [(MAPIStoreFolder *)
|
|
|
|
[mainMessage container] subscriberCanDeleteMessages])
|
2011-12-02 18:16:02 +01:00
|
|
|
access |= 0x04;
|
|
|
|
|
|
|
|
*data = MAPILongValue (memCtx, access);
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-12-02 18:16:02 +01:00
|
|
|
/*
|
|
|
|
Possible values are:
|
|
|
|
|
|
|
|
0x00000000 Read-Only
|
|
|
|
0x00000001 Modify
|
|
|
|
*/
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagAccessLevel: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2011-12-02 18:16:02 +01:00
|
|
|
uint32_t access = 0;
|
|
|
|
BOOL userIsOwner;
|
|
|
|
MAPIStoreContext *context;
|
2012-01-29 20:55:21 +01:00
|
|
|
SOGoUser *ownerUser;
|
2011-12-02 18:16:02 +01:00
|
|
|
|
|
|
|
context = [self context];
|
2012-01-29 20:55:21 +01:00
|
|
|
ownerUser = [[self userContext] sogoUser];
|
|
|
|
userIsOwner = [[context activeUser] isEqual: ownerUser];
|
2011-12-02 18:16:02 +01:00
|
|
|
if (userIsOwner || [self subscriberCanModifyMessage])
|
|
|
|
access = 0x01;
|
|
|
|
else
|
|
|
|
access = 0;
|
|
|
|
*data = MAPILongValue (memCtx, access);
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-09-19 22:06:27 +02:00
|
|
|
- (int ) getPidTagHasNamedProperties: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self getYes: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
2011-04-13 21:59:04 +02:00
|
|
|
- (int) getPidLidSideEffects: (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) getPidLidCurrentVersion: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-08-06 21:16:12 +02:00
|
|
|
// *data = MAPILongValue (memCtx, 115608); // Outlook 11.5608
|
|
|
|
*data = MAPILongValue (memCtx, 0x1ce3a); // Outlook 11.8330
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidCurrentVersionName: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = [@"11.0" asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) getPidLidAutoProcessState: (void **) data
|
2011-07-11 23:40:47 +02:00
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = MAPILongValue (memCtx, 0x00000000);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagFolderId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = MAPILongLongValue (memCtx, [container objectId]);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMid: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-07-20 17:44:25 +02:00
|
|
|
int rc;
|
|
|
|
uint64_t obId;
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2012-07-20 17:44:25 +02:00
|
|
|
obId = [self objectId];
|
|
|
|
if (obId == ULLONG_MAX)
|
|
|
|
rc = MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*data = MAPILongLongValue (memCtx, obId);
|
|
|
|
rc = MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMessageLocaleId: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = MAPILongValue (memCtx, 0x0409);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
*data = MAPILongValue (memCtx, MSGFLAG_FROMME | MSGFLAG_READ | MSGFLAG_UNMODIFIED);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMessageSize: (void **) data // TODO
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
/* TODO: choose another name in SOGo for that method */
|
|
|
|
*data = MAPILongValue (memCtx, [[sogoObject davContentLength] intValue]);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagImportance: (void **) data // TODO -> subclass?
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = MAPILongValue (memCtx, 1);
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagPriority: (void **) data // TODO -> subclass?
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-02-15 18:44:47 +01:00
|
|
|
- (int) getPidTagSensitivity: (void **) data
|
2012-03-02 21:44:24 +01: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
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSubject: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-07-20 16:13:50 +02:00
|
|
|
int rc;
|
|
|
|
TALLOC_CTX *localMemCtx;
|
|
|
|
char *prefix, *normalizedSubject;
|
|
|
|
|
2014-11-26 09:20:45 +01:00
|
|
|
localMemCtx = talloc_zero (memCtx, TALLOC_CTX);
|
2012-07-20 16:13:50 +02:00
|
|
|
if ([self getProperty: (void **) &prefix
|
|
|
|
withTag: PidTagSubjectPrefix
|
|
|
|
inMemCtx: localMemCtx]
|
|
|
|
!= MAPISTORE_SUCCESS)
|
|
|
|
prefix = "";
|
|
|
|
rc = [self getProperty: (void **) &normalizedSubject
|
|
|
|
withTag: PidTagNormalizedSubject
|
|
|
|
inMemCtx: localMemCtx];
|
|
|
|
if (rc == MAPISTORE_SUCCESS)
|
|
|
|
*data = talloc_asprintf (memCtx, "%s%s", prefix, normalizedSubject);
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2014-11-26 09:20:45 +01:00
|
|
|
talloc_free(localMemCtx);
|
|
|
|
|
2012-07-20 16:13:50 +02:00
|
|
|
return rc;
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagNormalizedSubject: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-07-20 16:13:50 +02:00
|
|
|
return MAPISTORE_ERR_NOT_FOUND;
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagOriginalSubject: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-07-20 16:13:50 +02:00
|
|
|
return [self getPidTagSubject: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagConversationTopic: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-03-02 21:44:24 +01:00
|
|
|
return [self getPidTagNormalizedSubject: data inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagSubjectPrefix: (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-08-21 22:38:43 +02:00
|
|
|
- (int) getPidTagDeleteAfterSubmit: (void **) data // TODO
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
|
|
|
{
|
|
|
|
return [self getNo: data inMemCtx: memCtx];
|
|
|
|
}
|
|
|
|
|
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-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) getPidTagDisplayCc: (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) 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) getPidTagOriginalDisplayTo: (void **) data
|
2011-06-07 02:17:46 +02:00
|
|
|
// {
|
2012-03-02 21:44:24 +01:00
|
|
|
// return [self getPidTagDisplayTo: data];
|
2011-06-07 02:17:46 +02:00
|
|
|
// }
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
// - (int) getPidTagOriginalDisplayCc: (void **) data
|
2011-06-07 02:17:46 +02:00
|
|
|
// {
|
2012-03-02 21:44:24 +01:00
|
|
|
// return [self getPidTagDisplayCc: data];
|
2011-06-07 02:17:46 +02:00
|
|
|
// }
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
// - (int) getPidTagOriginalDisplayBcc: (void **) data
|
2011-06-07 02:17:46 +02:00
|
|
|
// {
|
2012-03-02 21:44:24 +01:00
|
|
|
// return [self getPidTagDisplayBcc: data];
|
2011-06-07 02:17:46 +02:00
|
|
|
// }
|
2011-04-13 21:59:04 +02:00
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagLastModifierName: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
NSURL *contextUrl;
|
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
contextUrl = (NSURL *) [[self context] url];
|
2011-04-13 21:59:04 +02:00
|
|
|
*data = [[contextUrl user] asUnicodeInMemCtx: memCtx];
|
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagMessageClass: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
|
|
|
|
return MAPISTORE_ERR_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagOriginalMessageClass: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
2012-06-29 19:59:38 +02:00
|
|
|
return [self getProperty: data withTag: PidTagMessageClass inMemCtx: memCtx];
|
2011-04-13 21:59:04 +02:00
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagHasAttachments: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-04-13 21:59:04 +02:00
|
|
|
{
|
|
|
|
*data = MAPIBoolValue (memCtx,
|
2011-07-26 22:13:10 +02:00
|
|
|
[[self attachmentKeys] count] > 0);
|
2011-04-13 21:59:04 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-03-02 21:44:24 +01:00
|
|
|
- (int) getPidTagAssociated: (void **) data
|
|
|
|
inMemCtx: (TALLOC_CTX *) memCtx
|
2011-06-07 02:17:46 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
return [self getNo: data inMemCtx: memCtx];;
|
2011-11-01 02:00:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (int) setReadFlag: (uint8_t) flag
|
|
|
|
{
|
2011-11-02 21:28:42 +01:00
|
|
|
// [self subclassResponsibility: _cmd];
|
2011-11-01 02:00:33 +01:00
|
|
|
|
|
|
|
return MAPISTORE_ERROR;
|
2011-06-07 02:17:46 +02:00
|
|
|
}
|
|
|
|
|
2013-03-13 20:04:11 +01:00
|
|
|
- (void) save: (TALLOC_CTX *) memCtx
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
|
|
|
[self subclassResponsibility: _cmd];
|
|
|
|
}
|
|
|
|
|
2011-07-26 22:13:10 +02:00
|
|
|
- (NSArray *) attachmentKeys
|
|
|
|
{
|
|
|
|
if (!attachmentKeys)
|
|
|
|
{
|
|
|
|
attachmentKeys = [self attachmentKeysMatchingQualifier: nil
|
|
|
|
andSortOrderings: nil];
|
|
|
|
[attachmentKeys retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return attachmentKeys;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) attachmentKeysMatchingQualifier: (EOQualifier *) qualifier
|
|
|
|
andSortOrderings: (NSArray *) sortOrderings
|
2011-02-24 21:30:01 +01:00
|
|
|
{
|
2011-07-15 22:22:27 +02:00
|
|
|
if (qualifier)
|
|
|
|
[self errorWithFormat: @"qualifier is not used for attachments"];
|
|
|
|
if (sortOrderings)
|
|
|
|
[self errorWithFormat: @"sort orderings are not used for attachments"];
|
|
|
|
|
2011-07-26 22:13:10 +02:00
|
|
|
return [attachmentParts allKeys];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (MAPIStoreAttachmentTable *) attachmentTable
|
|
|
|
{
|
2011-04-20 00:26:47 +02:00
|
|
|
return [MAPIStoreAttachmentTable tableForContainer: self];
|
2011-02-24 21:30:01 +01:00
|
|
|
}
|
|
|
|
|
2011-03-07 20:15:16 +01:00
|
|
|
- (void) addActiveTable: (MAPIStoreTable *) activeTable
|
|
|
|
{
|
|
|
|
[activeTables addObject: activeTable];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) removeActiveTable: (MAPIStoreTable *) activeTable
|
|
|
|
{
|
|
|
|
[activeTables removeObject: activeTable];
|
|
|
|
}
|
|
|
|
|
2011-12-01 22:13:09 +01:00
|
|
|
- (NSArray *) activeUserRoles
|
|
|
|
{
|
|
|
|
MAPIStoreContext *context;
|
2012-01-29 20:55:21 +01:00
|
|
|
MAPIStoreUserContext *userContext;
|
2011-12-01 22:13:09 +01:00
|
|
|
|
|
|
|
if (!activeUserRoles)
|
|
|
|
{
|
|
|
|
context = [self context];
|
2012-01-29 20:55:21 +01:00
|
|
|
userContext = [self userContext];
|
2011-12-01 22:13:09 +01:00
|
|
|
activeUserRoles = [[context activeUser]
|
|
|
|
rolesForObject: sogoObject
|
2012-01-29 20:55:21 +01:00
|
|
|
inContext: [userContext woContext]];
|
2011-12-01 22:13:09 +01:00
|
|
|
[activeUserRoles retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return activeUserRoles;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) subscriberCanReadMessage
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) subscriberCanModifyMessage
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2011-02-24 21:30:01 +01:00
|
|
|
@end
|