mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-22 11:55:24 +00:00
Monotone-Parent: 4a93afea98f2877572c0d1c08dda6d0fecb72919
Monotone-Revision: f72602cc2c82edfe4c16124494afb5a276588e34 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-11-22T21:32:11 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -42,6 +42,11 @@
|
||||
|
||||
@implementation MAPIStoreCalendarContext
|
||||
|
||||
+ (NSString *) MAPIModuleName
|
||||
{
|
||||
return @"calendar";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@calendar/personal"
|
||||
|
||||
@@ -44,6 +44,11 @@
|
||||
|
||||
@implementation MAPIStoreContactsContext
|
||||
|
||||
+ (NSString *) MAPIModuleName
|
||||
{
|
||||
return @"contacts";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@contacts/personal"
|
||||
|
||||
@@ -127,6 +127,7 @@
|
||||
withFlags: (uint8_t) flags;
|
||||
|
||||
/* subclass methods */
|
||||
+ (NSString *) MAPIModuleName;
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) storeMapping;
|
||||
|
||||
- (NSArray *) getFolderMessageKeys: (SOGoFolder *) folder;
|
||||
|
||||
@@ -65,6 +65,8 @@
|
||||
|
||||
- (NSString *) davContentLength;
|
||||
- (void) setMAPIProperties: (NSDictionary *) properties;
|
||||
- (void) MAPISave;
|
||||
- (void) MAPISubmit;
|
||||
|
||||
@end
|
||||
|
||||
@@ -75,67 +77,67 @@
|
||||
static Class SOGoObjectK, SOGoMailAccountK, SOGoMailFolderK;
|
||||
static Class NSArrayK;
|
||||
|
||||
static MAPIStoreMapping *mapping = nil;
|
||||
static MAPIStoreMapping *mapping;
|
||||
static NSMutableDictionary *contextClassMapping;
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
NSArray *classes;
|
||||
Class currentClass;
|
||||
NSUInteger count, max;
|
||||
NSString *moduleName;
|
||||
|
||||
SOGoObjectK = [SOGoObject class];
|
||||
SOGoMailAccountK = [SOGoMailAccount class];
|
||||
SOGoMailFolderK = [SOGoMailFolder class];
|
||||
NSArrayK = [NSArray class];
|
||||
mapping = [MAPIStoreMapping sharedMapping];
|
||||
|
||||
contextClassMapping = [NSMutableDictionary new];
|
||||
classes = GSObjCAllSubclassesOfClass (self);
|
||||
max = [classes count];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
currentClass = [classes objectAtIndex: count];
|
||||
moduleName = [currentClass MAPIModuleName];
|
||||
NSLog (@" registered class '%@' as handler of '%@' contexts",
|
||||
NSStringFromClass (currentClass), moduleName);
|
||||
[contextClassMapping setObject: currentClass
|
||||
forKey: moduleName];
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSString *) MAPIModuleName
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) storeMapping
|
||||
{
|
||||
}
|
||||
|
||||
static inline NSString *
|
||||
_contextClassFromModule (NSString *module)
|
||||
{
|
||||
NSString *contextClass;
|
||||
|
||||
if ([module isEqualToString: @"mail"])
|
||||
contextClass = @"MAPIStoreMailContext";
|
||||
else if ([module isEqualToString: @"contacts"])
|
||||
contextClass = @"MAPIStoreContactsContext";
|
||||
else if ([module isEqualToString: @"calendar"])
|
||||
contextClass = @"MAPIStoreCalendarContext";
|
||||
else if ([module isEqualToString: @"tasks"])
|
||||
contextClass = @"MAPIStoreTasksContext";
|
||||
else if ([module isEqualToString: @"freebusy"])
|
||||
contextClass = @"MAPIStoreFreebusyContext";
|
||||
else
|
||||
{
|
||||
NSLog (@"ERROR: unrecognized module name '%@'", module);
|
||||
contextClass = nil;
|
||||
}
|
||||
|
||||
return contextClass;
|
||||
}
|
||||
|
||||
static inline MAPIStoreContext *
|
||||
_prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
NSString *contextClass, NSString *completeURLString,
|
||||
Class contextClass, NSString *completeURLString,
|
||||
NSString *username, NSString *password)
|
||||
{
|
||||
MAPIStoreContext *context;
|
||||
MAPIStoreAuthenticator *authenticator;
|
||||
static NSMutableDictionary *registration = nil;
|
||||
Class contextK;
|
||||
|
||||
if (!registration)
|
||||
registration = [NSMutableDictionary new];
|
||||
|
||||
contextK = NSClassFromString (contextClass);
|
||||
if (![registration objectForKey: contextClass])
|
||||
{
|
||||
[contextK registerFixedMappings: mapping];
|
||||
[contextClass registerFixedMappings: mapping];
|
||||
[registration setObject: [NSNull null]
|
||||
forKey: contextClass];
|
||||
}
|
||||
|
||||
context = [contextK new];
|
||||
context = [contextClass new];
|
||||
[context setURI: completeURLString andMemCtx: newMemCtx];
|
||||
[context autorelease];
|
||||
|
||||
@@ -156,7 +158,8 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
inMemCtx: (struct mapistore_context *) newMemCtx
|
||||
{
|
||||
MAPIStoreContext *context;
|
||||
NSString *contextClass, *module, *completeURLString, *urlString;
|
||||
Class contextClass;
|
||||
NSString *module, *completeURLString, *urlString;
|
||||
NSURL *baseURL;
|
||||
|
||||
NSLog (@"METHOD '%s' (%d) -- uri: '%s'", __FUNCTION__, __LINE__, newUri);
|
||||
@@ -173,13 +176,15 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
module = [baseURL host];
|
||||
if (module)
|
||||
{
|
||||
contextClass = _contextClassFromModule (module);
|
||||
contextClass = [contextClassMapping objectForKey: module];
|
||||
if (contextClass)
|
||||
context = _prepareContextClass (newMemCtx,
|
||||
contextClass,
|
||||
completeURLString,
|
||||
[baseURL user],
|
||||
[baseURL password]);
|
||||
else
|
||||
NSLog (@"ERROR: unrecognized module name '%@'", module);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -980,21 +985,25 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
if (parentFolder)
|
||||
{
|
||||
message = [self createMessageInFolder: parentFolder];
|
||||
if (![folderURL hasSuffix: @"/"])
|
||||
folderURL = [NSString stringWithFormat: @"%@/", folderURL];
|
||||
messageURL = [NSString stringWithFormat: @"%@%@", folderURL,
|
||||
[message nameInContainer]];
|
||||
[mapping registerURL: messageURL withID: mid];
|
||||
if (message)
|
||||
{
|
||||
if (![folderURL hasSuffix: @"/"])
|
||||
folderURL = [NSString stringWithFormat: @"%@/", folderURL];
|
||||
messageURL = [NSString stringWithFormat: @"%@%@", folderURL,
|
||||
[message nameInContainer]];
|
||||
[mapping registerURL: messageURL withID: mid];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
[self errorWithFormat: @"registered message without a valid fid"];
|
||||
[self errorWithFormat: @"registered message without a valid fid (%.16x)", fid];
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
- (int) saveChangesInMessageWithMID: (uint64_t) mid
|
||||
andFlags: (uint8_t) flags
|
||||
- (int) _saveOrSubmitChangesInMessageWithMID: (uint64_t) mid
|
||||
andFlags: (uint8_t) flags
|
||||
save: (BOOL) isSave
|
||||
{
|
||||
int rc;
|
||||
id message;
|
||||
@@ -1018,6 +1027,10 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
if (message)
|
||||
{
|
||||
[message setMAPIProperties: messageProperties];
|
||||
if (isSave)
|
||||
[message MAPISave];
|
||||
else
|
||||
[message MAPISubmit];
|
||||
rc = MAPISTORE_SUCCESS;
|
||||
}
|
||||
else
|
||||
@@ -1029,12 +1042,20 @@ _prepareContextClass (struct mapistore_context *newMemCtx,
|
||||
return rc;
|
||||
}
|
||||
|
||||
- (int) saveChangesInMessageWithMID: (uint64_t) mid
|
||||
andFlags: (uint8_t) flags
|
||||
{
|
||||
return [self _saveOrSubmitChangesInMessageWithMID: mid
|
||||
andFlags: flags
|
||||
save: YES];
|
||||
}
|
||||
|
||||
- (int) submitMessageWithMID: (uint64_t) mid
|
||||
andFlags: (uint8_t) flags
|
||||
{
|
||||
[self logWithFormat: @"UNIMPLEMENTED METHOD '%s' (%d)", __FUNCTION__, __LINE__];
|
||||
|
||||
return MAPISTORE_ERROR;
|
||||
return [self _saveOrSubmitChangesInMessageWithMID: mid
|
||||
andFlags: flags
|
||||
save: NO];
|
||||
}
|
||||
|
||||
- (int) getProperties: (struct SPropTagArray *) sPropTagArray
|
||||
|
||||
@@ -124,8 +124,7 @@
|
||||
}
|
||||
|
||||
// MAPIStoreDumpMessageProperties (properties);
|
||||
|
||||
[self saveContentString: [vCalendar versitString]];
|
||||
ASSIGN (content, [vCalendar versitString]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
if (value)
|
||||
[newCard addEmail: value types: nil];
|
||||
|
||||
[self save];
|
||||
ASSIGN (content, [newCard versitString]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/* SOGoContentObject+MAPIStore.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2010 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef SOGOCONTENTOBJECT_MAPISTORE_H
|
||||
#define SOGOCONTENTOBJECT_MAPISTORE_H
|
||||
|
||||
#import <SOGo/SOGoContentObject.h>
|
||||
|
||||
@interface SOGoContentObject (MAPIStoreMessage)
|
||||
|
||||
- (void) MAPISave;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#endif /* SOGOCONTENTOBJECT_MAPISTORE_H */
|
||||
@@ -0,0 +1,32 @@
|
||||
/* SOGoContentObject+MAPIStore.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2010 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* 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 "SOGoContentObject+MAPIStore.h"
|
||||
|
||||
@implementation SOGoContentObject (MAPIStoreMessage)
|
||||
|
||||
- (void) MAPISave
|
||||
{
|
||||
[self saveContentString: content];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -209,7 +209,7 @@
|
||||
|
||||
// MAPIStoreDumpMessageProperties (properties);
|
||||
|
||||
[self saveContentString: [vCalendar versitString]];
|
||||
ASSIGN (content, [vCalendar versitString]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user