2010-10-01 22:35:29 +02:00
|
|
|
/* MAPIStoreSOGo.m - this file is part of SOGo
|
|
|
|
*
|
2012-08-17 21:04:57 +02:00
|
|
|
* Copyright (C) 2010-2012 Inverse inc.
|
2010-10-01 22:35:29 +02: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
|
2010-10-18 14:57:31 +02:00
|
|
|
* the Free Software Foundation; either version 3, or (at your option)
|
2010-10-01 22:35:29 +02:00
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
2010-10-01 20:54:30 +02:00
|
|
|
*/
|
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
/* OpenChange SOGo storage backend */
|
|
|
|
|
2010-10-01 20:54:30 +02:00
|
|
|
#import <Foundation/NSAutoreleasePool.h>
|
2012-03-16 21:53:04 +01:00
|
|
|
#import <Foundation/NSDebug.h>
|
2010-11-26 22:48:52 +01:00
|
|
|
#import <Foundation/NSFileHandle.h>
|
2011-10-18 01:29:13 +02:00
|
|
|
#import <Foundation/NSProcessInfo.h>
|
2010-11-18 23:27:17 +01:00
|
|
|
#import <Foundation/NSUserDefaults.h>
|
2011-10-13 03:03:09 +02:00
|
|
|
#import <Foundation/NSThread.h>
|
2010-11-18 23:27:17 +01:00
|
|
|
#import <NGObjWeb/SoProductRegistry.h>
|
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2011-07-15 22:32:59 +02:00
|
|
|
#import <SOGo/SOGoCache.h>
|
2010-11-18 23:27:17 +01:00
|
|
|
#import <SOGo/SOGoProductLoader.h>
|
|
|
|
#import <SOGo/SOGoSystemDefaults.h>
|
2010-10-01 20:54:30 +02:00
|
|
|
|
|
|
|
#import "MAPIApplication.h"
|
2011-04-01 00:17:50 +02:00
|
|
|
#import "MAPIStoreAttachment.h"
|
2012-06-01 17:15:30 +02:00
|
|
|
#import "MAPIStoreAttachmentTable.h"
|
2010-10-01 20:54:30 +02:00
|
|
|
#import "MAPIStoreContext.h"
|
2012-06-01 17:15:30 +02:00
|
|
|
#import "MAPIStoreEmbeddedMessage.h"
|
2011-07-14 23:35:54 +02:00
|
|
|
#import "MAPIStoreFolder.h"
|
2011-07-13 23:41:58 +02:00
|
|
|
#import "MAPIStoreMessage.h"
|
2011-10-26 23:33:51 +02:00
|
|
|
#import "MAPIStoreMailVolatileMessage.h"
|
2011-02-24 21:36:35 +01:00
|
|
|
#import "MAPIStoreObject.h"
|
|
|
|
#import "MAPIStoreTable.h"
|
2011-07-11 23:40:47 +02:00
|
|
|
#import "NSObject+MAPIStore.h"
|
2012-02-03 16:05:55 +01:00
|
|
|
#import "NSString+MAPIStore.h"
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2015-03-26 23:43:28 +01:00
|
|
|
#include <libmapi/libmapi.h>
|
2011-02-24 21:36:35 +01:00
|
|
|
#include <mapistore/mapistore.h>
|
|
|
|
#include <mapistore/mapistore_errors.h>
|
2014-03-04 16:40:41 +01:00
|
|
|
#include <execinfo.h>
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2012-01-26 20:54:36 +01:00
|
|
|
static Class MAPIStoreContextK = Nil;
|
2012-03-16 21:53:04 +01:00
|
|
|
static BOOL leakDebugging = NO;
|
2014-07-02 10:40:05 +02:00
|
|
|
static BOOL initialization_done = NO;
|
2012-01-26 20:54:36 +01:00
|
|
|
|
2014-06-16 13:20:51 +02:00
|
|
|
#define NS_CURRENT_THREAD_REGISTER() \
|
|
|
|
BOOL __nsrct_thread_registered = GSRegisterCurrentThread(); \
|
2014-07-02 10:40:05 +02:00
|
|
|
if (!initialization_done) { \
|
2015-03-26 23:43:28 +01:00
|
|
|
OC_DEBUG(5, "[SOGo] You should call sogo_backend_init() first. Current thread: %p, pid: %d\n", \
|
|
|
|
GSCurrentThread(), getpid()); \
|
2015-07-14 13:09:09 +02:00
|
|
|
} \
|
|
|
|
OC_DEBUG(5, "[SOGo] --->");
|
|
|
|
|
2014-06-16 13:20:51 +02:00
|
|
|
#define NS_CURRENT_THREAD_TRY_UNREGISTER() \
|
|
|
|
if (__nsrct_thread_registered) { \
|
2014-07-02 10:40:05 +02:00
|
|
|
GSUnregisterCurrentThread(); \
|
2015-07-14 13:09:09 +02:00
|
|
|
} \
|
|
|
|
OC_DEBUG(6, "[SOGo] <---");
|
2014-06-16 13:20:51 +02:00
|
|
|
|
2014-03-04 12:29:13 +01:00
|
|
|
#define TRYCATCH_START @try {
|
2014-03-20 14:36:29 +01:00
|
|
|
#define TRYCATCH_END(pool) \
|
|
|
|
} @catch (NSException * e) { \
|
2014-03-20 16:27:03 +01:00
|
|
|
enum mapistore_error ret = sogo_backend_handle_objc_exception(e, __PRETTY_FUNCTION__, __LINE__); \
|
2015-07-14 16:30:51 +02:00
|
|
|
mapiapp_cleanup(); \
|
2014-03-20 14:36:29 +01:00
|
|
|
[pool release]; \
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER(); \
|
2014-03-20 16:27:03 +01:00
|
|
|
return ret; \
|
2015-07-14 16:30:51 +02:00
|
|
|
} \
|
|
|
|
mapiapp_cleanup();
|
2014-03-04 12:29:13 +01:00
|
|
|
|
2014-06-16 13:20:51 +02:00
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-09-04 18:25:32 +02:00
|
|
|
sogo_backend_unexpected_error()
|
|
|
|
{
|
|
|
|
NSLog (@" UNEXPECTED WEIRDNESS: RECEIVED NO OBJECT");
|
2012-01-29 20:55:21 +01:00
|
|
|
abort();
|
2011-09-04 18:25:32 +02:00
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-02-22 23:01:41 +01:00
|
|
|
static enum mapistore_error
|
|
|
|
sogo_backend_handle_objc_exception(NSException *e, const char *fn_name, const int line_no)
|
|
|
|
{
|
2014-03-20 17:26:44 +01:00
|
|
|
NSString *callStackSymbols = nil;
|
|
|
|
if ([e respondsToSelector:@selector(callStackSymbols)])
|
|
|
|
{
|
|
|
|
callStackSymbols = [[e callStackSymbols] componentsJoinedByString:@"\n\t"];
|
|
|
|
}
|
|
|
|
NSLog(@"[SOGo: %s:%d] - EXCEPTION: %@, reason: %@, backtrace: \n\t%@\n",
|
|
|
|
fn_name, line_no, [e name], [e reason], callStackSymbols);
|
2014-03-20 17:04:11 +01:00
|
|
|
|
|
|
|
// Another point of view on the stack trace
|
|
|
|
{
|
|
|
|
void *frames[128];
|
|
|
|
int i, len = backtrace(frames, 128);
|
|
|
|
char **symbols = backtrace_symbols(frames, len);
|
|
|
|
NSLog(@"Backtrace using execinfo.h:\n");
|
|
|
|
for (i = 0; i < len; ++i)
|
|
|
|
NSLog(@"\t%s", symbols[i]);
|
|
|
|
free(symbols);
|
|
|
|
}
|
|
|
|
|
2014-02-22 23:01:41 +01:00
|
|
|
if ([[e name] isEqual:@"NotImplementedException"])
|
|
|
|
{
|
|
|
|
return MAPISTORE_ERR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
return MAPISTORE_ERROR;
|
|
|
|
}
|
|
|
|
|
2012-03-16 21:53:04 +01:00
|
|
|
static void
|
|
|
|
sogo_backend_atexit (void)
|
|
|
|
{
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
|
2012-05-05 05:01:23 +02:00
|
|
|
GSRegisterCurrentThread ();
|
2012-03-16 21:53:04 +01:00
|
|
|
pool = [NSAutoreleasePool new];
|
2013-03-13 20:04:11 +01:00
|
|
|
//NSLog (@"allocated classes:\n%s", GSDebugAllocationList (YES));
|
2012-03-16 21:53:04 +01:00
|
|
|
[pool release];
|
2012-05-05 05:01:23 +02:00
|
|
|
GSUnregisterCurrentThread ();
|
2012-03-16 21:53:04 +01:00
|
|
|
}
|
|
|
|
|
2014-02-22 23:01:41 +01:00
|
|
|
|
2010-10-01 20:54:30 +02:00
|
|
|
/**
|
|
|
|
\details Initialize sogo mapistore backend
|
|
|
|
|
|
|
|
\return MAPISTORE_SUCCESS on success
|
2010-12-03 23:31:56 +01:00
|
|
|
*/
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 17:56:58 +02:00
|
|
|
sogo_backend_init (void)
|
2010-10-01 20:54:30 +02:00
|
|
|
{
|
2010-10-01 22:35:29 +02:00
|
|
|
NSAutoreleasePool *pool;
|
2010-11-18 23:27:17 +01:00
|
|
|
SOGoProductLoader *loader;
|
|
|
|
Class MAPIApplicationK;
|
|
|
|
NSUserDefaults *ud;
|
|
|
|
SoProductRegistry *registry;
|
2011-10-18 21:47:19 +02:00
|
|
|
char *argv[] = { SAMBA_PREFIX "/sbin/samba", NULL };
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2014-07-02 10:40:05 +02:00
|
|
|
GSRegisterCurrentThread();
|
|
|
|
|
|
|
|
if (initialization_done) {
|
2015-03-26 23:43:28 +01:00
|
|
|
OC_DEBUG(5, "[SOGo] SOGo backend already initialized.\n");
|
2014-06-19 20:41:37 +02:00
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2010-11-18 23:27:17 +01:00
|
|
|
|
|
|
|
/* Here we work around a bug in GNUstep which decodes XML user
|
|
|
|
defaults using the system encoding rather than honouring
|
|
|
|
the encoding specified in the file. */
|
|
|
|
putenv ("GNUSTEP_STRING_ENCODING=NSUTF8StringEncoding");
|
2012-12-03 15:18:17 +01:00
|
|
|
//putenv ("NSZombieEnabled=YES");
|
2010-11-18 23:27:17 +01:00
|
|
|
|
2011-10-18 21:47:19 +02:00
|
|
|
[NSProcessInfo initializeWithArguments: argv
|
2011-10-18 03:13:45 +02:00
|
|
|
count: 1
|
2011-10-18 01:28:40 +02:00
|
|
|
environment: environ];
|
|
|
|
|
2011-06-07 02:03:34 +02:00
|
|
|
[SOGoSystemDefaults sharedSystemDefaults];
|
2010-11-18 23:27:17 +01:00
|
|
|
|
2012-01-26 20:54:36 +01:00
|
|
|
/* We force the plugin to base its configuration on the SOGo tree. */
|
2010-11-18 23:27:17 +01:00
|
|
|
ud = [NSUserDefaults standardUserDefaults];
|
2012-03-16 21:53:04 +01:00
|
|
|
if (!leakDebugging && [ud boolForKey: @"SOGoDebugLeaks"])
|
|
|
|
{
|
|
|
|
NSLog (@" leak debugging on");
|
|
|
|
GSDebugAllocationActive (YES);
|
|
|
|
atexit (sogo_backend_atexit);
|
|
|
|
leakDebugging = YES;
|
|
|
|
}
|
|
|
|
|
2010-11-18 23:27:17 +01:00
|
|
|
registry = [SoProductRegistry sharedProductRegistry];
|
|
|
|
[registry scanForProductsInDirectory: SOGO_BUNDLES_DIR];
|
|
|
|
|
|
|
|
loader = [SOGoProductLoader productLoader];
|
|
|
|
[loader loadProducts: [NSArray arrayWithObject: BACKEND_BUNDLE_NAME]];
|
|
|
|
|
|
|
|
MAPIApplicationK = NSClassFromString (@"MAPIApplication");
|
|
|
|
if (MAPIApplicationK)
|
2011-08-08 20:53:31 +02:00
|
|
|
[[MAPIApplicationK new] activateApplication];
|
2010-11-18 23:27:17 +01:00
|
|
|
|
2011-07-15 22:32:59 +02:00
|
|
|
[[SOGoCache sharedCache] disableRequestsCache];
|
2011-11-18 16:26:03 +01:00
|
|
|
[[SOGoCache sharedCache] disableLocalCache];
|
2011-07-15 22:32:59 +02:00
|
|
|
|
2012-01-26 20:54:36 +01:00
|
|
|
MAPIStoreContextK = NSClassFromString (@"MAPIStoreContext");
|
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
[pool release];
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2015-03-26 23:43:28 +01:00
|
|
|
OC_DEBUG(5, "[SOGo] backend init SUCCESS. Current thread: %p, pid: %d\n", GSCurrentThread(), getpid());
|
2014-07-02 10:40:05 +02:00
|
|
|
initialization_done = YES;
|
2014-06-19 19:57:32 +02:00
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
return MAPISTORE_SUCCESS;
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|
|
|
|
|
2015-07-14 16:30:51 +02:00
|
|
|
/**
|
|
|
|
\details Cleanup operation to execute after an action has been performed
|
|
|
|
so there won't be any conflicts with future calls.
|
|
|
|
In practice this will deactivate the current user context set on MAPIApp
|
|
|
|
(which is the current WOApplication), this means two things: (1) set nil
|
|
|
|
as current user context on MAPIApp and (2) remove woContext from current
|
|
|
|
thread dictionary (this is used on WOContext.m).
|
|
|
|
*/
|
|
|
|
static void mapiapp_cleanup(void)
|
|
|
|
{
|
|
|
|
Class MAPIApplicationK;
|
|
|
|
MAPIApplicationK = NSClassFromString (@"MAPIApplication");
|
|
|
|
if (MAPIApplicationK)
|
|
|
|
[[MAPIApplicationK application] cleanup];
|
|
|
|
}
|
|
|
|
|
2010-10-01 20:54:30 +02:00
|
|
|
/**
|
|
|
|
\details Create a connection context to the sogo backend
|
|
|
|
|
|
|
|
\param mem_ctx pointer to the memory context
|
|
|
|
\param uri pointer to the sogo path
|
2015-07-14 16:30:51 +02:00
|
|
|
\param private_data pointer to the private backend context
|
2010-10-01 22:35:29 +02:00
|
|
|
*/
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 17:56:58 +02:00
|
|
|
sogo_backend_create_context(TALLOC_CTX *mem_ctx,
|
|
|
|
struct mapistore_connection_info *conn_info,
|
2013-11-08 17:02:50 +01:00
|
|
|
struct indexing_context *indexing,
|
2011-07-14 23:35:54 +02:00
|
|
|
const char *uri, void **context_object)
|
2010-10-01 20:54:30 +02:00
|
|
|
{
|
2010-10-01 22:35:29 +02:00
|
|
|
NSAutoreleasePool *pool;
|
2011-07-14 23:35:54 +02:00
|
|
|
MAPIStoreContext *context;
|
2010-11-18 23:27:17 +01:00
|
|
|
int rc;
|
|
|
|
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2010-10-01 22:35:29 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2010-11-18 23:27:17 +01:00
|
|
|
if (MAPIStoreContextK)
|
|
|
|
{
|
2014-03-20 14:24:58 +01:00
|
|
|
TRYCATCH_START
|
2011-07-14 23:35:54 +02:00
|
|
|
rc = [MAPIStoreContextK openContext: &context
|
|
|
|
withURI: uri
|
2011-08-04 16:09:59 +02:00
|
|
|
connectionInfo: conn_info
|
2013-11-08 17:02:50 +01:00
|
|
|
andTDBIndexing: indexing];
|
2011-07-14 23:35:54 +02:00
|
|
|
if (rc == MAPISTORE_SUCCESS)
|
|
|
|
*context_object = [context tallocWrapper: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2010-11-18 23:27:17 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERROR;
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2010-11-18 23:27:17 +01:00
|
|
|
return rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|
|
|
|
|
2012-02-03 16:05:55 +01:00
|
|
|
static enum mapistore_error
|
|
|
|
sogo_backend_create_root_folder (const char *username,
|
|
|
|
enum mapistore_context_role role,
|
|
|
|
uint64_t fid, const char *name,
|
2013-11-08 17:02:50 +01:00
|
|
|
// struct indexing_context *indexing,
|
2012-02-03 16:05:55 +01:00
|
|
|
TALLOC_CTX *mem_ctx, char **mapistore_urip)
|
|
|
|
{
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
NSString *userName, *folderName;
|
|
|
|
NSString *mapistoreUri;
|
|
|
|
int rc;
|
|
|
|
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2012-02-03 16:05:55 +01:00
|
|
|
pool = [NSAutoreleasePool new];
|
|
|
|
|
|
|
|
if (MAPIStoreContextK)
|
|
|
|
{
|
2014-03-20 14:24:58 +01:00
|
|
|
TRYCATCH_START
|
2012-02-03 16:05:55 +01:00
|
|
|
userName = [NSString stringWithUTF8String: username];
|
|
|
|
folderName = [NSString stringWithUTF8String: name];
|
|
|
|
rc = [MAPIStoreContextK createRootFolder: &mapistoreUri
|
|
|
|
withFID: fid
|
|
|
|
andName: folderName
|
|
|
|
forUser: userName
|
2012-02-14 15:47:06 +01:00
|
|
|
withRole: role];
|
2012-02-03 16:05:55 +01:00
|
|
|
if (rc == MAPISTORE_SUCCESS)
|
|
|
|
*mapistore_urip = [mapistoreUri asUnicodeInMemCtx: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2012-02-03 16:05:55 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERROR;
|
|
|
|
|
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2012-02-03 16:05:55 +01:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-01-26 20:54:36 +01:00
|
|
|
static enum mapistore_error
|
2013-11-08 17:02:50 +01:00
|
|
|
sogo_backend_list_contexts(const char *username, struct indexing_context *indexing,
|
2012-01-29 20:55:21 +01:00
|
|
|
TALLOC_CTX *mem_ctx,
|
2012-01-26 20:54:36 +01:00
|
|
|
struct mapistore_contexts_list **contexts_listp)
|
|
|
|
{
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
NSString *userName;
|
|
|
|
int rc;
|
|
|
|
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2012-01-26 20:54:36 +01:00
|
|
|
pool = [NSAutoreleasePool new];
|
|
|
|
|
|
|
|
if (MAPIStoreContextK)
|
|
|
|
{
|
2014-03-20 14:24:58 +01:00
|
|
|
TRYCATCH_START
|
2012-01-26 20:54:36 +01:00
|
|
|
userName = [NSString stringWithUTF8String: username];
|
|
|
|
*contexts_listp = [MAPIStoreContextK listAllContextsForUser: userName
|
2013-11-08 17:02:50 +01:00
|
|
|
withIndexing: indexing
|
2012-01-26 20:54:36 +01:00
|
|
|
inMemCtx: mem_ctx];
|
|
|
|
rc = MAPISTORE_SUCCESS;
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2012-01-26 20:54:36 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = MAPISTORE_ERROR;
|
|
|
|
|
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2012-01-26 20:54:36 +01:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
// andFID: fid
|
|
|
|
// uint64_t fid,
|
|
|
|
// void **private_data)
|
|
|
|
|
2010-10-01 20:54:30 +02:00
|
|
|
/**
|
|
|
|
\details return the mapistore path associated to a given message or
|
|
|
|
folder ID
|
|
|
|
|
|
|
|
\param private_data pointer to the current sogo context
|
|
|
|
\param fmid the folder/message ID to lookup
|
|
|
|
\param type whether it is a folder or message
|
|
|
|
\param path pointer on pointer to the path to return
|
|
|
|
|
|
|
|
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error
|
2010-10-01 22:35:29 +02:00
|
|
|
*/
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 23:35:54 +02:00
|
|
|
sogo_context_get_path(void *backend_object, TALLOC_CTX *mem_ctx,
|
|
|
|
uint64_t fmid, char **path)
|
2010-10-01 20:54:30 +02:00
|
|
|
{
|
2011-07-14 23:35:54 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2010-10-01 22:35:29 +02:00
|
|
|
NSAutoreleasePool *pool;
|
2010-10-13 23:40:50 +02:00
|
|
|
MAPIStoreContext *context;
|
|
|
|
int rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
if (backend_object)
|
|
|
|
{
|
|
|
|
wrapper = backend_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
context = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-14 23:35:54 +02:00
|
|
|
rc = [context getPath: path ofFMID: fmid inMemCtx: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
return rc;
|
|
|
|
}
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 23:35:54 +02:00
|
|
|
sogo_context_get_root_folder(void *backend_object, TALLOC_CTX *mem_ctx,
|
|
|
|
uint64_t fid, void **folder_object)
|
|
|
|
{
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreContext *context;
|
|
|
|
MAPIStoreFolder *folder;
|
|
|
|
int rc;
|
2010-10-13 23:40:50 +02:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
if (backend_object)
|
|
|
|
{
|
|
|
|
wrapper = backend_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
context = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-14 23:35:54 +02:00
|
|
|
rc = [context getRootFolder: &folder withFID: fid];
|
|
|
|
if (rc == MAPISTORE_SUCCESS)
|
|
|
|
*folder_object = [folder tallocWrapper: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2010-10-13 23:40:50 +02:00
|
|
|
return rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-07-14 17:56:58 +02:00
|
|
|
\details Open a folder from the sogo backend
|
2010-10-01 20:54:30 +02:00
|
|
|
|
|
|
|
\param private_data pointer to the current sogo context
|
2011-07-14 17:56:58 +02:00
|
|
|
\param parent_fid the parent folder identifier
|
|
|
|
\param fid the identifier of the colder to open
|
2010-10-01 20:54:30 +02:00
|
|
|
|
|
|
|
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR
|
2010-10-01 22:35:29 +02:00
|
|
|
*/
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 23:35:54 +02:00
|
|
|
sogo_folder_open_folder(void *folder_object, TALLOC_CTX *mem_ctx, uint64_t fid, void **childfolder_object)
|
2010-10-01 20:54:30 +02:00
|
|
|
{
|
2011-07-14 23:35:54 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2010-10-01 22:35:29 +02:00
|
|
|
NSAutoreleasePool *pool;
|
2011-07-14 23:35:54 +02:00
|
|
|
MAPIStoreFolder *folder, *childFolder;
|
2010-10-01 22:35:29 +02:00
|
|
|
int rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
if (folder_object)
|
|
|
|
{
|
|
|
|
wrapper = folder_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
folder = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-14 23:35:54 +02:00
|
|
|
rc = [folder openFolder: &childFolder withFID: fid];
|
|
|
|
if (rc == MAPISTORE_SUCCESS)
|
|
|
|
*childfolder_object = [childFolder tallocWrapper: mem_ctx];
|
|
|
|
// [context tearDownRequest];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
return rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-07-14 17:56:58 +02:00
|
|
|
\details Create a folder in the sogo backend
|
2015-07-14 13:09:09 +02:00
|
|
|
|
2010-10-01 20:54:30 +02:00
|
|
|
\param private_data pointer to the current sogo context
|
|
|
|
|
|
|
|
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR
|
2010-10-01 22:35:29 +02:00
|
|
|
*/
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 23:35:54 +02:00
|
|
|
sogo_folder_create_folder(void *folder_object, TALLOC_CTX *mem_ctx,
|
|
|
|
uint64_t fid, struct SRow *aRow,
|
|
|
|
void **childfolder_object)
|
2010-10-01 20:54:30 +02:00
|
|
|
{
|
2011-07-14 23:35:54 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2010-10-01 22:35:29 +02:00
|
|
|
NSAutoreleasePool *pool;
|
2011-07-14 23:35:54 +02:00
|
|
|
MAPIStoreFolder *folder, *childFolder;
|
2010-10-01 22:35:29 +02:00
|
|
|
int rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
if (folder_object)
|
|
|
|
{
|
|
|
|
wrapper = folder_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
folder = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-14 23:35:54 +02:00
|
|
|
rc = [folder createFolder: &childFolder withRow: aRow andFID: fid];
|
|
|
|
if (rc == MAPISTORE_SUCCESS)
|
|
|
|
*childfolder_object = [childFolder tallocWrapper: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
return rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-07-14 17:56:58 +02:00
|
|
|
\details Delete a folder from the sogo backend
|
2010-10-01 20:54:30 +02:00
|
|
|
|
|
|
|
\param private_data pointer to the current sogo context
|
2011-07-14 17:56:58 +02:00
|
|
|
\param parent_fid the FID for the parent of the folder to delete
|
|
|
|
\param fid the FID for the folder to delete
|
2010-10-01 20:54:30 +02:00
|
|
|
|
|
|
|
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE_ERROR
|
2010-10-01 22:35:29 +02:00
|
|
|
*/
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2012-02-02 02:45:17 +01:00
|
|
|
sogo_folder_delete(void *folder_object)
|
2010-10-01 20:54:30 +02:00
|
|
|
{
|
2011-07-14 23:35:54 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2010-10-01 22:35:29 +02:00
|
|
|
NSAutoreleasePool *pool;
|
2011-07-14 23:35:54 +02:00
|
|
|
MAPIStoreFolder *folder;
|
2010-10-01 22:35:29 +02:00
|
|
|
int rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
if (folder_object)
|
|
|
|
{
|
|
|
|
wrapper = folder_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
folder = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2012-02-02 02:45:17 +01:00
|
|
|
rc = [folder deleteFolder];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
return rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2012-01-16 00:58:26 +01:00
|
|
|
sogo_folder_get_child_count(void *folder_object, enum mapistore_table_type table_type, uint32_t *child_count)
|
2010-10-01 20:54:30 +02:00
|
|
|
{
|
2011-07-14 23:35:54 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2010-10-01 22:35:29 +02:00
|
|
|
NSAutoreleasePool *pool;
|
2011-07-14 23:35:54 +02:00
|
|
|
MAPIStoreFolder *folder;
|
2010-10-01 22:35:29 +02:00
|
|
|
int rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
if (folder_object)
|
|
|
|
{
|
|
|
|
wrapper = folder_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
folder = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-14 23:35:54 +02:00
|
|
|
rc = [folder getChildCount: child_count ofTableType: table_type];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
return rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 23:35:54 +02:00
|
|
|
sogo_folder_open_message(void *folder_object,
|
|
|
|
TALLOC_CTX *mem_ctx,
|
2011-12-01 23:28:12 +01:00
|
|
|
uint64_t mid, bool write_access,
|
2011-10-26 17:00:53 +02:00
|
|
|
void **message_object)
|
2010-10-01 20:54:30 +02:00
|
|
|
{
|
2011-07-14 23:35:54 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2010-10-01 22:35:29 +02:00
|
|
|
NSAutoreleasePool *pool;
|
2011-07-14 23:35:54 +02:00
|
|
|
MAPIStoreFolder *folder;
|
2011-07-13 23:41:58 +02:00
|
|
|
MAPIStoreMessage *message;
|
2010-10-01 22:35:29 +02:00
|
|
|
int rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
if (folder_object)
|
|
|
|
{
|
|
|
|
wrapper = folder_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
folder = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-12-01 23:28:12 +01:00
|
|
|
rc = [folder openMessage: &message
|
|
|
|
withMID: mid
|
|
|
|
forWriting: write_access
|
|
|
|
inMemCtx: mem_ctx];
|
2011-07-14 23:35:54 +02:00
|
|
|
if (rc == MAPISTORE_SUCCESS)
|
|
|
|
*message_object = [message tallocWrapper: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
return rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 23:35:54 +02:00
|
|
|
sogo_folder_create_message(void *folder_object,
|
|
|
|
TALLOC_CTX *mem_ctx,
|
|
|
|
uint64_t mid,
|
|
|
|
uint8_t associated,
|
|
|
|
void **message_object)
|
2010-10-01 20:54:30 +02:00
|
|
|
{
|
2011-07-14 23:35:54 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2010-10-01 22:35:29 +02:00
|
|
|
NSAutoreleasePool *pool;
|
2011-07-14 23:35:54 +02:00
|
|
|
MAPIStoreFolder *folder;
|
2011-07-14 17:56:58 +02:00
|
|
|
MAPIStoreMessage *message;
|
2010-10-01 22:35:29 +02:00
|
|
|
int rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
if (folder_object)
|
|
|
|
{
|
|
|
|
wrapper = folder_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
folder = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-14 23:35:54 +02:00
|
|
|
rc = [folder createMessage: &message
|
2011-09-14 20:33:44 +02:00
|
|
|
withMID: mid
|
2015-07-14 13:15:01 +02:00
|
|
|
isAssociated: associated];
|
2011-07-14 23:35:54 +02:00
|
|
|
if (rc == MAPISTORE_SUCCESS)
|
|
|
|
*message_object = [message tallocWrapper: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
2011-07-14 17:56:58 +02:00
|
|
|
else
|
2011-07-14 23:35:54 +02:00
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
return rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 23:35:54 +02:00
|
|
|
sogo_folder_delete_message(void *folder_object, uint64_t mid, uint8_t flags)
|
2010-10-01 20:54:30 +02:00
|
|
|
{
|
2011-07-14 23:35:54 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2010-10-01 22:35:29 +02:00
|
|
|
NSAutoreleasePool *pool;
|
2011-07-14 23:35:54 +02:00
|
|
|
MAPIStoreFolder *folder;
|
2010-10-01 22:35:29 +02:00
|
|
|
int rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
if (folder_object)
|
|
|
|
{
|
|
|
|
wrapper = folder_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
folder = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-14 23:35:54 +02:00
|
|
|
rc = [folder deleteMessageWithMID: mid andFlags: flags];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-07-14 23:35:54 +02:00
|
|
|
}
|
2010-10-01 20:54:30 +02:00
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
return rc;
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2012-12-05 20:56:29 +01:00
|
|
|
sogo_folder_move_copy_messages(void *folder_object,
|
2011-09-22 15:39:41 +02:00
|
|
|
void *source_folder_object,
|
2012-12-05 20:56:29 +01:00
|
|
|
TALLOC_CTX *mem_ctx,
|
2011-09-22 15:39:41 +02:00
|
|
|
uint32_t mid_count,
|
|
|
|
uint64_t *src_mids, uint64_t *t_mids,
|
2011-09-27 20:26:40 +02:00
|
|
|
struct Binary_r **target_change_keys,
|
2011-09-21 21:33:35 +02:00
|
|
|
uint8_t want_copy)
|
2011-09-14 20:33:44 +02:00
|
|
|
{
|
|
|
|
MAPIStoreFolder *sourceFolder, *targetFolder;
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (folder_object)
|
|
|
|
{
|
|
|
|
wrapper = folder_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
targetFolder = wrapper->instance;
|
2011-09-14 20:33:44 +02:00
|
|
|
|
2011-09-22 15:39:41 +02:00
|
|
|
wrapper = source_folder_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
sourceFolder = wrapper->instance;
|
2011-09-22 15:39:41 +02:00
|
|
|
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-09-14 20:33:44 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-09-22 15:39:41 +02:00
|
|
|
rc = [targetFolder moveCopyMessagesWithMIDs: src_mids
|
2011-09-21 21:33:35 +02:00
|
|
|
andCount: mid_count
|
2011-09-22 15:39:41 +02:00
|
|
|
fromFolder: sourceFolder
|
2011-09-21 21:33:35 +02:00
|
|
|
withMIDs: t_mids
|
2011-09-27 20:26:40 +02:00
|
|
|
andChangeKeys: target_change_keys
|
2012-12-03 15:18:17 +01:00
|
|
|
wantCopy: want_copy
|
|
|
|
inMemCtx: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-09-14 20:33:44 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-09-14 20:33:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rc = sogo_backend_unexpected_error();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-08-09 21:43:17 +02:00
|
|
|
static enum mapistore_error
|
2012-08-10 16:08:40 +02:00
|
|
|
sogo_folder_move_folder(void *folder_object, void *target_folder_object,
|
2012-12-07 19:30:50 +01:00
|
|
|
TALLOC_CTX *mem_ctx, const char *new_folder_name)
|
2012-08-09 21:43:17 +02:00
|
|
|
{
|
|
|
|
NSAutoreleasePool *pool;
|
2012-08-10 16:08:40 +02:00
|
|
|
MAPIStoreFolder *moveFolder, *targetFolder;
|
2012-08-09 21:43:17 +02:00
|
|
|
NSString *newFolderName;
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (folder_object)
|
|
|
|
{
|
|
|
|
wrapper = folder_object;
|
2012-08-10 16:08:40 +02:00
|
|
|
moveFolder = wrapper->instance;
|
2012-08-09 21:43:17 +02:00
|
|
|
|
2012-08-10 16:08:40 +02:00
|
|
|
wrapper = target_folder_object;
|
2012-08-14 22:16:16 +02:00
|
|
|
if (wrapper)
|
|
|
|
targetFolder = wrapper->instance;
|
|
|
|
else
|
|
|
|
targetFolder = nil;
|
2012-08-09 21:43:17 +02:00
|
|
|
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2012-08-09 21:43:17 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
|
|
|
|
2012-08-09 23:34:27 +02:00
|
|
|
if (new_folder_name)
|
|
|
|
newFolderName = [NSString stringWithUTF8String: new_folder_name];
|
|
|
|
else
|
|
|
|
newFolderName = nil;
|
2012-08-09 21:43:17 +02:00
|
|
|
|
2014-03-20 14:24:58 +01:00
|
|
|
TRYCATCH_START
|
2012-08-15 03:02:08 +02:00
|
|
|
rc = [moveFolder moveCopyToFolder: targetFolder
|
|
|
|
withNewName: newFolderName
|
|
|
|
isMove: YES
|
2012-12-07 19:30:50 +01:00
|
|
|
isRecursive: YES
|
|
|
|
inMemCtx: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2012-12-07 19:30:50 +01:00
|
|
|
|
2012-08-09 21:43:17 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2012-08-09 21:43:17 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rc = sogo_backend_unexpected_error();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum mapistore_error
|
2012-12-07 19:30:50 +01:00
|
|
|
sogo_folder_copy_folder(void *folder_object, void *target_folder_object, TALLOC_CTX *mem_ctx,
|
2012-08-10 16:08:40 +02:00
|
|
|
bool recursive, const char *new_folder_name)
|
2012-08-09 21:43:17 +02:00
|
|
|
{
|
|
|
|
NSAutoreleasePool *pool;
|
2012-08-10 16:08:40 +02:00
|
|
|
MAPIStoreFolder *copyFolder, *targetFolder;
|
2012-08-09 21:43:17 +02:00
|
|
|
NSString *newFolderName;
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (folder_object)
|
|
|
|
{
|
|
|
|
wrapper = folder_object;
|
2012-08-10 16:08:40 +02:00
|
|
|
copyFolder = wrapper->instance;
|
2012-08-09 21:43:17 +02:00
|
|
|
|
2012-08-10 16:08:40 +02:00
|
|
|
wrapper = target_folder_object;
|
|
|
|
targetFolder = wrapper->instance;
|
2012-08-09 21:43:17 +02:00
|
|
|
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2012-08-09 21:43:17 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
|
|
|
|
|
|
|
newFolderName = [NSString stringWithUTF8String: new_folder_name];
|
|
|
|
|
2014-03-20 14:24:58 +01:00
|
|
|
TRYCATCH_START
|
2012-08-15 15:13:15 +02:00
|
|
|
rc = [copyFolder moveCopyToFolder: targetFolder
|
|
|
|
withNewName: newFolderName
|
|
|
|
isMove: NO
|
2012-12-07 19:30:50 +01:00
|
|
|
isRecursive: recursive
|
|
|
|
inMemCtx: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2012-08-09 21:43:17 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2012-08-09 21:43:17 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rc = sogo_backend_unexpected_error();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-29 04:13:39 +02:00
|
|
|
sogo_folder_get_deleted_fmids(void *folder_object, TALLOC_CTX *mem_ctx,
|
2012-01-16 00:58:26 +01:00
|
|
|
enum mapistore_table_type table_type, uint64_t change_num,
|
2012-10-05 15:59:45 +02:00
|
|
|
struct UI8Array_r **fmidsp, uint64_t *cnp)
|
2011-07-29 04:13:39 +02:00
|
|
|
{
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreFolder *folder;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (folder_object)
|
|
|
|
{
|
|
|
|
wrapper = folder_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
folder = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-29 04:13:39 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-29 04:13:39 +02:00
|
|
|
rc = [folder getDeletedFMIDs: fmidsp
|
|
|
|
andCN: cnp
|
|
|
|
fromChangeNumber: change_num
|
|
|
|
inTableType: table_type
|
|
|
|
inMemCtx: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-29 04:13:39 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-07-29 04:13:39 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-07-29 04:13:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 23:35:54 +02:00
|
|
|
sogo_folder_open_table(void *folder_object, TALLOC_CTX *mem_ctx,
|
2012-01-16 00:58:26 +01:00
|
|
|
enum mapistore_table_type table_type, uint32_t handle_id,
|
2011-07-14 17:56:58 +02:00
|
|
|
void **table_object, uint32_t *row_count)
|
2011-03-07 20:15:16 +01:00
|
|
|
{
|
2011-07-14 23:35:54 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2011-03-07 20:15:16 +01:00
|
|
|
NSAutoreleasePool *pool;
|
2011-07-14 23:35:54 +02:00
|
|
|
MAPIStoreFolder *folder;
|
2011-07-11 23:40:47 +02:00
|
|
|
MAPIStoreTable *table;
|
2011-03-07 20:15:16 +01:00
|
|
|
int rc;
|
|
|
|
|
2011-07-14 23:35:54 +02:00
|
|
|
if (folder_object)
|
2011-03-07 20:15:16 +01:00
|
|
|
{
|
2011-07-14 23:35:54 +02:00
|
|
|
wrapper = folder_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
folder = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-14 23:35:54 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-14 23:35:54 +02:00
|
|
|
rc = [folder getTable: &table
|
|
|
|
andRowCount: row_count
|
|
|
|
tableType: table_type
|
|
|
|
andHandleId: handle_id];
|
2011-07-11 23:40:47 +02:00
|
|
|
if (rc == MAPISTORE_SUCCESS)
|
|
|
|
*table_object = [table tallocWrapper: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-03-07 20:15:16 +01:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-03-07 20:15:16 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-03-07 20:15:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-11-18 16:26:03 +01:00
|
|
|
sogo_folder_modify_permissions(void *folder_object, uint8_t flags,
|
|
|
|
uint16_t pcount,
|
|
|
|
struct PermissionData *permissions)
|
|
|
|
{
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreFolder *folder;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (folder_object)
|
|
|
|
{
|
|
|
|
wrapper = folder_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
folder = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-11-18 16:26:03 +01:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-11-18 16:26:03 +01:00
|
|
|
rc = [folder modifyPermissions: permissions
|
|
|
|
withCount: pcount
|
|
|
|
andFlags: flags];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-11-18 16:26:03 +01:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-11-18 16:26:03 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rc = sogo_backend_unexpected_error();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-10-05 15:55:01 +02:00
|
|
|
static enum mapistore_error
|
2012-10-10 16:38:25 +02:00
|
|
|
sogo_folder_preload_message_bodies(void *folder_object, enum mapistore_table_type table_type, const struct UI8Array_r *mids)
|
2012-10-05 15:55:01 +02:00
|
|
|
{
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreFolder *folder;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (folder_object)
|
|
|
|
{
|
|
|
|
wrapper = folder_object;
|
|
|
|
folder = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2012-10-05 15:55:01 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2012-10-10 16:38:25 +02:00
|
|
|
rc = [folder preloadMessageBodiesWithMIDs: mids
|
|
|
|
ofTableType: table_type];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2012-10-05 15:55:01 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2012-10-05 15:55:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rc = sogo_backend_unexpected_error();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-10-26 17:00:53 +02:00
|
|
|
sogo_message_get_message_data(void *message_object,
|
|
|
|
TALLOC_CTX *mem_ctx,
|
|
|
|
struct mapistore_message **msg_dataP)
|
|
|
|
{
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreMessage *message;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (message_object)
|
|
|
|
{
|
|
|
|
wrapper = message_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
message = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-10-26 17:00:53 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-10-26 17:00:53 +02:00
|
|
|
[message getMessageData: msg_dataP
|
|
|
|
inMemCtx: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-10-26 17:00:53 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-10-26 17:00:53 +02:00
|
|
|
rc = MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rc = sogo_backend_unexpected_error();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 17:56:58 +02:00
|
|
|
sogo_message_create_attachment (void *message_object, TALLOC_CTX *mem_ctx, void **attachment_object, uint32_t *aidp)
|
2011-02-24 21:36:35 +01:00
|
|
|
{
|
2011-07-13 23:41:58 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2011-02-24 21:36:35 +01:00
|
|
|
NSAutoreleasePool *pool;
|
2011-07-13 23:41:58 +02:00
|
|
|
MAPIStoreMessage *message;
|
|
|
|
MAPIStoreAttachment *attachment;
|
2011-02-24 21:36:35 +01:00
|
|
|
int rc;
|
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
if (message_object)
|
2011-02-24 21:36:35 +01:00
|
|
|
{
|
2011-07-13 23:41:58 +02:00
|
|
|
wrapper = message_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
message = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-13 23:41:58 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-13 23:41:58 +02:00
|
|
|
rc = [message createAttachment: &attachment inAID: aidp];
|
|
|
|
if (rc == MAPISTORE_SUCCESS)
|
|
|
|
*attachment_object = [attachment tallocWrapper: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-02-24 21:36:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-02-24 21:36:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 17:56:58 +02:00
|
|
|
sogo_message_open_attachment (void *message_object, TALLOC_CTX *mem_ctx,
|
|
|
|
uint32_t aid, void **attachment_object)
|
2011-02-24 21:36:35 +01:00
|
|
|
{
|
2011-07-13 23:41:58 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2011-02-24 21:36:35 +01:00
|
|
|
NSAutoreleasePool *pool;
|
2011-07-13 23:41:58 +02:00
|
|
|
MAPIStoreMessage *message;
|
2011-07-11 23:40:47 +02:00
|
|
|
MAPIStoreAttachment *attachment;
|
2011-02-24 21:36:35 +01:00
|
|
|
int rc;
|
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
if (message_object)
|
2011-02-24 21:36:35 +01:00
|
|
|
{
|
2011-07-13 23:41:58 +02:00
|
|
|
wrapper = message_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
message = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-13 23:41:58 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-13 23:41:58 +02:00
|
|
|
rc = [message getAttachment: &attachment withAID: aid];
|
2011-07-11 23:40:47 +02:00
|
|
|
if (rc == MAPISTORE_SUCCESS)
|
|
|
|
*attachment_object = [attachment tallocWrapper: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-02-24 21:36:35 +01:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-02-24 21:36:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-02-24 21:36:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 17:56:58 +02:00
|
|
|
sogo_message_get_attachment_table (void *message_object, TALLOC_CTX *mem_ctx, void **table_object, uint32_t *row_count)
|
2011-02-24 21:36:35 +01:00
|
|
|
{
|
2011-07-13 23:41:58 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2011-02-24 21:36:35 +01:00
|
|
|
NSAutoreleasePool *pool;
|
2011-07-13 23:41:58 +02:00
|
|
|
MAPIStoreMessage *message;
|
|
|
|
MAPIStoreAttachmentTable *table;
|
2011-02-24 21:36:35 +01:00
|
|
|
int rc;
|
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
if (message_object)
|
2011-02-24 21:36:35 +01:00
|
|
|
{
|
2011-07-13 23:41:58 +02:00
|
|
|
wrapper = message_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
message = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-13 23:41:58 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-13 23:41:58 +02:00
|
|
|
rc = [message getAttachmentTable: &table
|
|
|
|
andRowCount: row_count];
|
2011-07-11 23:40:47 +02:00
|
|
|
if (rc == MAPISTORE_SUCCESS)
|
2011-07-13 23:41:58 +02:00
|
|
|
*table_object = [table tallocWrapper: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-02-24 21:36:35 +01:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-02-24 21:36:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-07-13 23:41:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 17:56:58 +02:00
|
|
|
sogo_message_modify_recipients (void *message_object,
|
2011-10-03 22:53:56 +02:00
|
|
|
struct SPropTagArray *columns,
|
2011-10-28 15:10:47 +02:00
|
|
|
uint16_t count,
|
|
|
|
struct mapistore_message_recipient *recipients)
|
2011-07-13 23:41:58 +02:00
|
|
|
{
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreMessage *message;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (message_object)
|
|
|
|
{
|
|
|
|
wrapper = message_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
message = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-13 23:41:58 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-10-28 15:10:47 +02:00
|
|
|
rc = [message modifyRecipientsWithRecipients: recipients
|
|
|
|
andCount: count
|
|
|
|
andColumns: columns];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-07-13 23:41:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-07-13 23:41:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-11-01 02:00:33 +01:00
|
|
|
sogo_message_set_read_flag (void *message_object, uint8_t flag)
|
|
|
|
{
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreMessage *message;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (message_object)
|
|
|
|
{
|
|
|
|
wrapper = message_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
message = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-11-01 02:00:33 +01:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-11-01 02:00:33 +01:00
|
|
|
rc = [message setReadFlag: flag];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-11-01 02:00:33 +01:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-11-01 02:00:33 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rc = sogo_backend_unexpected_error();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2013-03-13 20:04:11 +01:00
|
|
|
sogo_message_save (void *message_object, TALLOC_CTX *mem_ctx)
|
2011-07-13 23:41:58 +02:00
|
|
|
{
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreMessage *message;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (message_object)
|
|
|
|
{
|
|
|
|
wrapper = message_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
message = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-13 23:41:58 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2013-03-13 20:04:11 +01:00
|
|
|
rc = [message saveMessage: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-07-13 23:41:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-07-13 23:41:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 17:56:58 +02:00
|
|
|
sogo_message_submit (void *message_object, enum SubmitFlags flags)
|
2011-07-13 23:41:58 +02:00
|
|
|
{
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
NSAutoreleasePool *pool;
|
2011-10-26 23:33:51 +02:00
|
|
|
MAPIStoreMailVolatileMessage *message;
|
2011-07-13 23:41:58 +02:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (message_object)
|
|
|
|
{
|
|
|
|
wrapper = message_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
message = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-13 23:41:58 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-13 23:41:58 +02:00
|
|
|
rc = [message submitWithFlags: flags];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-13 23:41:58 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-07-13 23:41:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-02-24 21:36:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2012-07-20 17:21:11 +02:00
|
|
|
sogo_message_attachment_open_embedded_message (void *attachment_object,
|
|
|
|
TALLOC_CTX *mem_ctx,
|
|
|
|
void **message_object,
|
|
|
|
uint64_t *midP,
|
|
|
|
struct mapistore_message **msg)
|
2011-04-01 00:17:50 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2011-04-01 00:17:50 +02:00
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreAttachment *attachment;
|
2012-06-01 17:15:30 +02:00
|
|
|
MAPIStoreEmbeddedMessage *message;
|
2011-04-01 00:17:50 +02:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (attachment_object)
|
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
wrapper = attachment_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
attachment = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-04-01 00:17:50 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-11 23:40:47 +02:00
|
|
|
rc = [attachment openEmbeddedMessage: &message
|
2011-07-13 23:41:58 +02:00
|
|
|
withMID: midP
|
|
|
|
withMAPIStoreMsg: msg
|
|
|
|
inMemCtx: mem_ctx];
|
2011-07-11 23:40:47 +02:00
|
|
|
if (rc == MAPISTORE_SUCCESS)
|
|
|
|
*message_object = [message tallocWrapper: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-04-01 00:17:50 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-04-01 00:17:50 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-04-01 00:17:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-07-20 17:21:11 +02:00
|
|
|
static enum mapistore_error
|
|
|
|
sogo_message_attachment_create_embedded_message (void *attachment_object,
|
|
|
|
TALLOC_CTX *mem_ctx,
|
|
|
|
void **message_object,
|
|
|
|
struct mapistore_message **msg)
|
|
|
|
{
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreAttachment *attachment;
|
|
|
|
MAPIStoreEmbeddedMessage *message;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (attachment_object)
|
|
|
|
{
|
|
|
|
wrapper = attachment_object;
|
|
|
|
attachment = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2012-07-20 17:21:11 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2014-02-22 23:01:41 +01:00
|
|
|
rc = [attachment createEmbeddedMessage: &message
|
|
|
|
withMAPIStoreMsg: msg
|
|
|
|
inMemCtx: mem_ctx];
|
|
|
|
if (rc == MAPISTORE_SUCCESS)
|
|
|
|
*message_object = [message tallocWrapper: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2012-07-20 17:21:11 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2012-07-20 17:21:11 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rc = sogo_backend_unexpected_error();
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error sogo_table_get_available_properties(void *table_object,
|
2011-07-14 17:56:58 +02:00
|
|
|
TALLOC_CTX *mem_ctx, struct SPropTagArray **propertiesP)
|
2011-04-19 23:57:52 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2011-04-19 23:57:52 +02:00
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreTable *table;
|
|
|
|
int rc;
|
|
|
|
|
2011-07-11 23:40:47 +02:00
|
|
|
if (table_object)
|
2011-04-19 23:57:52 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
wrapper = table_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
table = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-04-19 23:57:52 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-11 23:40:47 +02:00
|
|
|
rc = [table getAvailableProperties: propertiesP inMemCtx: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-04-19 23:57:52 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-04-19 23:57:52 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-04-19 23:57:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 17:56:58 +02:00
|
|
|
sogo_table_set_columns (void *table_object, uint16_t count, enum MAPITAGS *properties)
|
2011-02-24 21:36:35 +01:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2011-02-24 21:36:35 +01:00
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreTable *table;
|
|
|
|
int rc;
|
|
|
|
|
2011-07-11 23:40:47 +02:00
|
|
|
if (table_object)
|
2011-02-24 21:36:35 +01:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
wrapper = table_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
table = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-02-24 21:36:35 +01:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-02-24 21:36:35 +01:00
|
|
|
rc = [table setColumns: properties
|
|
|
|
withCount: count];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-02-24 21:36:35 +01:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-02-24 21:36:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-02-24 21:36:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 17:56:58 +02:00
|
|
|
sogo_table_set_restrictions (void *table_object, struct mapi_SRestriction *restrictions, uint8_t *table_status)
|
2011-03-07 20:15:16 +01:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2011-03-07 20:15:16 +01:00
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreTable *table;
|
|
|
|
int rc;
|
|
|
|
|
2011-07-11 23:40:47 +02:00
|
|
|
if (table_object)
|
2011-03-07 20:15:16 +01:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
wrapper = table_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
table = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-03-07 20:15:16 +01:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-03-07 20:15:16 +01:00
|
|
|
[table setRestrictions: restrictions];
|
2013-02-14 21:22:48 +01:00
|
|
|
//[table cleanupCaches];
|
2011-03-07 20:15:16 +01:00
|
|
|
rc = MAPISTORE_SUCCESS;
|
|
|
|
*table_status = TBLSTAT_COMPLETE;
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-03-07 20:15:16 +01:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-03-07 20:15:16 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-03-07 20:15:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 17:56:58 +02:00
|
|
|
sogo_table_set_sort_order (void *table_object, struct SSortOrderSet *sort_order, uint8_t *table_status)
|
2011-03-07 20:15:16 +01:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2011-03-07 20:15:16 +01:00
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreTable *table;
|
|
|
|
int rc;
|
|
|
|
|
2011-07-11 23:40:47 +02:00
|
|
|
if (table_object)
|
2011-03-07 20:15:16 +01:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
wrapper = table_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
table = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-03-07 20:15:16 +01:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-03-07 20:15:16 +01:00
|
|
|
[table setSortOrder: sort_order];
|
|
|
|
[table cleanupCaches];
|
|
|
|
rc = MAPISTORE_SUCCESS;
|
|
|
|
*table_status = TBLSTAT_COMPLETE;
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-03-07 20:15:16 +01:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-03-07 20:15:16 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-03-07 20:15:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 17:56:58 +02:00
|
|
|
sogo_table_get_row (void *table_object, TALLOC_CTX *mem_ctx,
|
2012-01-16 00:58:26 +01:00
|
|
|
enum mapistore_query_type query_type, uint32_t row_id,
|
2011-07-14 17:56:58 +02:00
|
|
|
struct mapistore_property_data **data)
|
2011-02-24 21:36:35 +01:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2011-02-24 21:36:35 +01:00
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreTable *table;
|
|
|
|
int rc;
|
|
|
|
|
2011-07-11 23:40:47 +02:00
|
|
|
if (table_object)
|
2011-02-24 21:36:35 +01:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
wrapper = table_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
table = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-02-24 21:36:35 +01:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-11 23:40:47 +02:00
|
|
|
rc = [table getRow: data withRowID: row_id andQueryType: query_type
|
|
|
|
inMemCtx: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-02-24 21:36:35 +01:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-02-24 21:36:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-02-24 21:36:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-22 22:51:05 +02:00
|
|
|
sogo_table_get_row_count (void *table_object,
|
2012-01-16 00:58:26 +01:00
|
|
|
enum mapistore_query_type query_type,
|
2011-07-22 22:51:05 +02:00
|
|
|
uint32_t *row_countp)
|
|
|
|
{
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreTable *table;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (table_object)
|
|
|
|
{
|
|
|
|
wrapper = table_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
table = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-07-22 22:51:05 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-22 22:51:05 +02:00
|
|
|
rc = [table getRowCount: row_countp
|
|
|
|
withQueryType: query_type];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-07-22 22:51:05 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-07-22 22:51:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-07-22 22:51:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-08-12 18:11:49 +02:00
|
|
|
sogo_table_handle_destructor (void *table_object, uint32_t handle_id)
|
|
|
|
{
|
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreTable *table;
|
2011-09-04 18:25:32 +02:00
|
|
|
int rc;
|
2011-08-12 18:11:49 +02:00
|
|
|
|
|
|
|
if (table_object)
|
|
|
|
{
|
|
|
|
wrapper = table_object;
|
2012-06-30 09:30:44 +02:00
|
|
|
table = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-08-12 18:11:49 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-08-12 18:11:49 +02:00
|
|
|
[table destroyHandle: handle_id];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-08-12 18:11:49 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = MAPISTORE_SUCCESS;
|
2011-08-12 18:11:49 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-08-12 18:11:49 +02:00
|
|
|
}
|
|
|
|
|
2011-09-04 18:25:32 +02:00
|
|
|
return rc;
|
2011-08-12 18:11:49 +02:00
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error sogo_properties_get_available_properties(void *object,
|
2011-07-14 17:56:58 +02:00
|
|
|
TALLOC_CTX *mem_ctx,
|
|
|
|
struct SPropTagArray **propertiesP)
|
2011-04-19 23:57:52 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2011-04-19 23:57:52 +02:00
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreObject *propObject;
|
|
|
|
int rc;
|
|
|
|
|
2011-07-11 23:40:47 +02:00
|
|
|
if (object)
|
2011-04-19 23:57:52 +02:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
wrapper = object;
|
2012-06-30 09:30:44 +02:00
|
|
|
propObject = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-04-19 23:57:52 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-11 23:40:47 +02:00
|
|
|
rc = [propObject getAvailableProperties: propertiesP inMemCtx: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-04-19 23:57:52 +02:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-04-19 23:57:52 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-04-19 23:57:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 17:56:58 +02:00
|
|
|
sogo_properties_get_properties (void *object,
|
|
|
|
TALLOC_CTX *mem_ctx,
|
|
|
|
uint16_t count, enum MAPITAGS *properties,
|
|
|
|
struct mapistore_property_data *data)
|
2011-02-24 21:36:35 +01:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2011-02-24 21:36:35 +01:00
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreObject *propObject;
|
|
|
|
int rc;
|
|
|
|
|
2011-07-11 23:40:47 +02:00
|
|
|
if (object)
|
2011-02-24 21:36:35 +01:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
wrapper = object;
|
2012-06-30 09:30:44 +02:00
|
|
|
propObject = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-02-24 21:36:35 +01:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-07-11 23:40:47 +02:00
|
|
|
rc = [propObject getProperties: data withTags: properties
|
|
|
|
andCount: count
|
|
|
|
inMemCtx: mem_ctx];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-02-24 21:36:35 +01:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-02-24 21:36:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-02-24 21:36:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2011-07-14 17:56:58 +02:00
|
|
|
sogo_properties_set_properties (void *object, struct SRow *aRow)
|
2011-02-24 21:36:35 +01:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
struct MAPIStoreTallocWrapper *wrapper;
|
2011-02-24 21:36:35 +01:00
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
MAPIStoreObject *propObject;
|
|
|
|
int rc;
|
|
|
|
|
2011-07-11 23:40:47 +02:00
|
|
|
if (object)
|
2011-02-24 21:36:35 +01:00
|
|
|
{
|
2011-07-11 23:40:47 +02:00
|
|
|
wrapper = object;
|
2012-06-30 09:30:44 +02:00
|
|
|
propObject = wrapper->instance;
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-02-24 21:36:35 +01:00
|
|
|
pool = [NSAutoreleasePool new];
|
2014-03-20 14:24:58 +01:00
|
|
|
|
|
|
|
TRYCATCH_START
|
2011-10-26 17:15:17 +02:00
|
|
|
rc = [propObject addPropertiesFromRow: aRow];
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2014-03-20 14:24:58 +01:00
|
|
|
|
2011-02-24 21:36:35 +01:00
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-02-24 21:36:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-09-04 18:25:32 +02:00
|
|
|
rc = sogo_backend_unexpected_error();
|
2011-02-24 21:36:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2011-12-02 15:35:30 +01:00
|
|
|
static enum mapistore_error
|
2015-07-14 13:15:01 +02:00
|
|
|
sogo_manager_generate_uri (TALLOC_CTX *mem_ctx,
|
|
|
|
const char *user,
|
|
|
|
const char *folder,
|
|
|
|
const char *message,
|
2011-10-13 03:03:09 +02:00
|
|
|
const char *rootURI,
|
|
|
|
char **uri)
|
|
|
|
{
|
|
|
|
NSAutoreleasePool *pool;
|
|
|
|
NSString *partialURLString, *username, *directory;
|
|
|
|
|
|
|
|
if (uri == NULL) return MAPISTORE_ERR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/* This fixes a crash occurring during the instantiation of the
|
|
|
|
NSAutoreleasePool below. */
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_REGISTER();
|
2011-10-13 03:03:09 +02:00
|
|
|
pool = [NSAutoreleasePool new];
|
|
|
|
|
2014-03-20 14:24:58 +01:00
|
|
|
TRYCATCH_START
|
2011-10-13 03:03:09 +02:00
|
|
|
// printf("rootURI = %s\n", rootURI);
|
|
|
|
if (rootURI)
|
|
|
|
partialURLString = [NSString stringWithUTF8String: rootURI];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* sogo uri are of type: sogo://[username]:[password]@[folder type]/folder/id */
|
|
|
|
username = [NSString stringWithUTF8String: (user ? user : "*")];
|
|
|
|
/* Do proper directory lookup here */
|
|
|
|
directory = [NSString stringWithUTF8String: (folder ? folder : "*")];
|
2015-01-19 19:04:06 +01:00
|
|
|
partialURLString = [NSString stringWithFormat: @"sogo://%@:*@%@",
|
|
|
|
[username stringByReplacingOccurrencesOfString: @"@"
|
|
|
|
withString: @"%40"],
|
|
|
|
directory];
|
2011-10-13 03:03:09 +02:00
|
|
|
}
|
|
|
|
if (![partialURLString hasSuffix: @"/"])
|
|
|
|
partialURLString = [partialURLString stringByAppendingString: @"/"];
|
|
|
|
|
|
|
|
if (message)
|
|
|
|
partialURLString = [partialURLString stringByAppendingFormat: @"%s.eml", message];
|
|
|
|
|
|
|
|
// printf("uri = %s\n", [partialURLString UTF8String]);
|
|
|
|
*uri = talloc_strdup (mem_ctx, [partialURLString UTF8String]);
|
2014-03-20 14:36:29 +01:00
|
|
|
TRYCATCH_END(pool)
|
2011-10-13 03:03:09 +02:00
|
|
|
|
|
|
|
[pool release];
|
2014-06-16 13:20:51 +02:00
|
|
|
NS_CURRENT_THREAD_TRY_UNREGISTER();
|
2011-10-13 03:03:09 +02:00
|
|
|
|
|
|
|
return MAPISTORE_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-10-01 20:54:30 +02:00
|
|
|
/**
|
|
|
|
\details Entry point for mapistore SOGO backend
|
|
|
|
|
2011-07-15 21:29:30 +02:00
|
|
|
\return MAPISTORE_SUCCESS on success, otherwise MAPISTORE error
|
2010-10-01 22:35:29 +02:00
|
|
|
*/
|
2010-10-01 20:54:30 +02:00
|
|
|
int mapistore_init_backend(void)
|
|
|
|
{
|
2015-07-14 13:15:01 +02:00
|
|
|
struct mapistore_backend backend;
|
|
|
|
int ret;
|
|
|
|
static BOOL registered = NO;
|
2010-10-01 22:35:29 +02:00
|
|
|
|
|
|
|
if (registered)
|
2011-06-16 20:47:37 +02:00
|
|
|
ret = MAPISTORE_SUCCESS;
|
2010-10-01 22:35:29 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
registered = YES;
|
2011-07-14 17:56:58 +02:00
|
|
|
|
|
|
|
backend.backend.name = "SOGo";
|
|
|
|
backend.backend.description = "mapistore SOGo backend";
|
|
|
|
backend.backend.namespace = "sogo://";
|
|
|
|
backend.backend.init = sogo_backend_init;
|
|
|
|
backend.backend.create_context = sogo_backend_create_context;
|
2012-02-03 16:05:55 +01:00
|
|
|
backend.backend.create_root_folder = sogo_backend_create_root_folder;
|
2012-01-26 20:54:36 +01:00
|
|
|
backend.backend.list_contexts = sogo_backend_list_contexts;
|
2011-07-14 23:35:54 +02:00
|
|
|
backend.context.get_path = sogo_context_get_path;
|
|
|
|
backend.context.get_root_folder = sogo_context_get_root_folder;
|
2011-07-14 17:56:58 +02:00
|
|
|
backend.folder.open_folder = sogo_folder_open_folder;
|
|
|
|
backend.folder.create_folder = sogo_folder_create_folder;
|
2012-02-02 02:45:17 +01:00
|
|
|
backend.folder.delete = sogo_folder_delete;
|
2011-07-14 17:56:58 +02:00
|
|
|
backend.folder.open_message = sogo_folder_open_message;
|
|
|
|
backend.folder.create_message = sogo_folder_create_message;
|
|
|
|
backend.folder.delete_message = sogo_folder_delete_message;
|
2011-09-21 21:33:35 +02:00
|
|
|
backend.folder.move_copy_messages = sogo_folder_move_copy_messages;
|
2012-08-09 21:43:17 +02:00
|
|
|
backend.folder.move_folder = sogo_folder_move_folder;
|
|
|
|
backend.folder.copy_folder = sogo_folder_copy_folder;
|
2011-07-29 04:13:39 +02:00
|
|
|
backend.folder.get_deleted_fmids = sogo_folder_get_deleted_fmids;
|
2011-07-14 17:56:58 +02:00
|
|
|
backend.folder.get_child_count = sogo_folder_get_child_count;
|
|
|
|
backend.folder.open_table = sogo_folder_open_table;
|
2011-11-18 16:26:03 +01:00
|
|
|
backend.folder.modify_permissions = sogo_folder_modify_permissions;
|
2012-10-05 15:55:01 +02:00
|
|
|
backend.folder.preload_message_bodies = sogo_folder_preload_message_bodies;
|
2011-07-14 17:56:58 +02:00
|
|
|
backend.message.create_attachment = sogo_message_create_attachment;
|
|
|
|
backend.message.get_attachment_table = sogo_message_get_attachment_table;
|
|
|
|
backend.message.open_attachment = sogo_message_open_attachment;
|
|
|
|
backend.message.open_embedded_message = sogo_message_attachment_open_embedded_message;
|
2012-07-20 17:21:11 +02:00
|
|
|
backend.message.create_embedded_message = sogo_message_attachment_create_embedded_message;
|
2011-10-26 17:00:53 +02:00
|
|
|
backend.message.get_message_data = sogo_message_get_message_data;
|
2011-07-14 17:56:58 +02:00
|
|
|
backend.message.modify_recipients = sogo_message_modify_recipients;
|
2011-11-01 02:00:33 +01:00
|
|
|
backend.message.set_read_flag = sogo_message_set_read_flag;
|
2011-07-14 17:56:58 +02:00
|
|
|
backend.message.save = sogo_message_save;
|
|
|
|
backend.message.submit = sogo_message_submit;
|
|
|
|
backend.table.get_available_properties = sogo_table_get_available_properties;
|
|
|
|
backend.table.set_restrictions = sogo_table_set_restrictions;
|
|
|
|
backend.table.set_sort_order = sogo_table_set_sort_order;
|
|
|
|
backend.table.set_columns = sogo_table_set_columns;
|
|
|
|
backend.table.get_row = sogo_table_get_row;
|
2011-07-22 22:51:05 +02:00
|
|
|
backend.table.get_row_count = sogo_table_get_row_count;
|
2011-08-12 18:11:49 +02:00
|
|
|
backend.table.handle_destructor = sogo_table_handle_destructor;
|
2011-07-14 17:56:58 +02:00
|
|
|
backend.properties.get_available_properties = sogo_properties_get_available_properties;
|
|
|
|
backend.properties.get_properties = sogo_properties_get_properties;
|
|
|
|
backend.properties.set_properties = sogo_properties_set_properties;
|
2011-10-13 03:03:09 +02:00
|
|
|
backend.manager.generate_uri = sogo_manager_generate_uri;
|
2011-02-24 21:36:35 +01:00
|
|
|
|
2010-10-01 22:35:29 +02:00
|
|
|
/* Register ourselves with the MAPISTORE subsystem */
|
2011-10-13 03:03:09 +02:00
|
|
|
ret = mapistore_backend_register (&backend);
|
|
|
|
if (ret != MAPISTORE_SUCCESS)
|
2015-03-26 23:43:28 +01:00
|
|
|
OC_DEBUG(0, "[SOGo] Failed to register the '%s' mapistore backend!\n", backend.backend.name);
|
2010-10-01 22:35:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2010-10-01 20:54:30 +02:00
|
|
|
}
|