Monotone-Parent: 17790db0c2368364683e4074a491e7107c6cf071
Monotone-Revision: 96b5a2580e3b0b6ba57af91d0fed6f513f8e13f0 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-02-24T20:32:27 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
62819158a2
commit
dd0bea0dc9
|
@ -1,6 +1,11 @@
|
|||
2011-02-24 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* OpenChange/MAPIStoreMessage.m: new super class used as for
|
||||
* OpenChange/MAPIStoreFolder.m: new super class used as wrapper
|
||||
around SOGoFolder objects, by decoupling the code previously found
|
||||
in the SOGo*Context classes and which implement basic and uniform
|
||||
content key facilities.
|
||||
|
||||
* OpenChange/MAPIStoreMessage.m: new super class used for
|
||||
wrapper objects replacing the category modules on the SOGoObject.
|
||||
|
||||
* OpenChange/MAPIStoreObject.m: new super class used as base the
|
||||
|
|
|
@ -20,31 +20,12 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
|
||||
#import <Appointments/SOGoAppointmentFolder.h>
|
||||
#import <Appointments/SOGoAppointmentFolders.h>
|
||||
#import <Appointments/SOGoAppointmentObject.h>
|
||||
|
||||
#import <NGCards/iCalPerson.h>
|
||||
|
||||
#import "MAPIApplication.h"
|
||||
#import "MAPIStoreAuthenticator.h"
|
||||
#import "MAPIStoreCalendarMessageTable.h"
|
||||
#import "MAPIStoreMapping.h"
|
||||
#import "MAPIStoreTypes.h"
|
||||
#import "SOGoGCSFolder+MAPIStore.h"
|
||||
#import "MAPIStoreCalendarFolder.h"
|
||||
|
||||
#import "MAPIStoreCalendarContext.h"
|
||||
#import "NSString+MAPIStore.h"
|
||||
|
||||
#undef DEBUG
|
||||
#include <mapistore/mapistore.h>
|
||||
#include <mapistore/mapistore_nameid.h>
|
||||
|
||||
@implementation MAPIStoreCalendarContext
|
||||
|
||||
|
@ -59,107 +40,19 @@
|
|||
withID: 0x190001];
|
||||
}
|
||||
|
||||
- (void) setupModuleFolder
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoAppointmentFolders *parentFolder;
|
||||
|
||||
userFolder = [SOGoUserFolder objectWithName: [authenticator username]
|
||||
inContainer: MAPIApp];
|
||||
[parentFoldersBag addObject: userFolder];
|
||||
[woContext setClientObject: userFolder];
|
||||
|
||||
parentFolder = [userFolder lookupName: @"Calendar"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentFoldersBag addObject: parentFolder];
|
||||
[woContext setClientObject: parentFolder];
|
||||
|
||||
moduleFolder = [parentFolder lookupName: @"personal"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[moduleFolder retain];
|
||||
baseFolder = [MAPIStoreCalendarFolder baseFolderWithURL: newURL
|
||||
inContext: self];
|
||||
[baseFolder retain];
|
||||
}
|
||||
|
||||
- (id) createMessageOfClass: (NSString *) messageClass
|
||||
inFolderAtURL: (NSString *) folderURL;
|
||||
|
||||
- (int) readCount: (uint32_t *) rowCount
|
||||
ofTableType: (uint8_t) tableType
|
||||
inFID: (uint64_t) fid
|
||||
{
|
||||
SOGoAppointmentFolder *parentFolder;
|
||||
SOGoAppointmentObject *newEntry;
|
||||
NSString *name;
|
||||
|
||||
parentFolder = [self lookupObject: folderURL];
|
||||
name = [NSString stringWithFormat: @"%@.ics",
|
||||
[SOGoObject globallyUniqueObjectId]];
|
||||
newEntry = [SOGoAppointmentObject objectWithName: name
|
||||
inContainer: parentFolder];
|
||||
[newEntry setIsNew: YES];
|
||||
|
||||
return newEntry;
|
||||
}
|
||||
|
||||
- (Class) messageTableClass
|
||||
{
|
||||
return [MAPIStoreCalendarMessageTable class];
|
||||
}
|
||||
|
||||
- (int) openMessage: (struct mapistore_message *) msg
|
||||
forKey: (NSString *) childKey
|
||||
inTable: (MAPIStoreTable *) table
|
||||
{
|
||||
NSString *name, *email;
|
||||
NSArray *attendees;
|
||||
iCalPerson *person;
|
||||
id event;
|
||||
struct SRowSet *recipients;
|
||||
int count, max, rc;
|
||||
|
||||
rc = [super openMessage: msg forKey: childKey inTable: table];
|
||||
|
||||
if (rc == MAPI_E_SUCCESS && table == messageTable)
|
||||
{
|
||||
event = [[table lookupChild: childKey] component: NO secure: NO];
|
||||
attendees = [event attendees];
|
||||
max = [attendees count];
|
||||
|
||||
recipients = msg->recipients;
|
||||
recipients->cRows = max;
|
||||
recipients->aRow = talloc_array (recipients, struct SRow, max);
|
||||
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
recipients->aRow[count].ulAdrEntryPad = 0;
|
||||
recipients->aRow[count].cValues = 3;
|
||||
recipients->aRow[count].lpProps = talloc_array (recipients->aRow,
|
||||
struct SPropValue,
|
||||
3);
|
||||
|
||||
// TODO (0x01 = primary recipient)
|
||||
set_SPropValue_proptag (&(recipients->aRow[count].lpProps[0]),
|
||||
PR_RECIPIENT_TYPE,
|
||||
MAPILongValue (memCtx, 0x01));
|
||||
|
||||
person = [attendees objectAtIndex: count];
|
||||
|
||||
name = [person cn];
|
||||
if (!name)
|
||||
name = @"";
|
||||
|
||||
email = [person email];
|
||||
if (!email)
|
||||
email = @"";
|
||||
|
||||
set_SPropValue_proptag (&(recipients->aRow[count].lpProps[1]),
|
||||
PR_DISPLAY_NAME,
|
||||
[name asUnicodeInMemCtx: recipients->aRow[count].lpProps]);
|
||||
set_SPropValue_proptag (&(recipients->aRow[count].lpProps[2]),
|
||||
PR_EMAIL_ADDRESS,
|
||||
[email asUnicodeInMemCtx: recipients->aRow[count].lpProps]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
return [super readCount: rowCount ofTableType: tableType inFID: fid];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/* MAPIStoreCalendarFolder.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 MAPISTORECALENDARFOLDER_H
|
||||
#define MAPISTORECALENDARFOLDER_H
|
||||
|
||||
#import "MAPIStoreGCSFolder.h"
|
||||
|
||||
@interface MAPIStoreCalendarFolder : MAPIStoreGCSFolder
|
||||
|
||||
@end
|
||||
|
||||
#endif /* MAPISTORECALENDARFOLDER_H */
|
|
@ -0,0 +1,124 @@
|
|||
/* MAPIStoreCalendarFolder.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 <Foundation/NSArray.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
#import <EOControl/EOQualifier.h>
|
||||
#import <Appointments/SOGoAppointmentFolder.h>
|
||||
#import <Appointments/SOGoAppointmentFolders.h>
|
||||
#import <Appointments/SOGoAppointmentObject.h>
|
||||
|
||||
#import "MAPIApplication.h"
|
||||
#import "MAPIStoreCalendarContext.h"
|
||||
#import "MAPIStoreCalendarMessage.h"
|
||||
#import "MAPIStoreCalendarMessageTable.h"
|
||||
|
||||
#import "MAPIStoreCalendarFolder.h"
|
||||
|
||||
static Class MAPIStoreCalendarMessageK;
|
||||
|
||||
@implementation MAPIStoreCalendarFolder
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
MAPIStoreCalendarMessageK = [MAPIStoreCalendarMessage class];
|
||||
}
|
||||
|
||||
- (id) initWithURL: (NSURL *) newURL
|
||||
inContext: (MAPIStoreContext *) newContext
|
||||
{
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoAppointmentFolders *parentFolder;
|
||||
WOContext *woContext;
|
||||
|
||||
if ((self = [super initWithURL: newURL
|
||||
inContext: newContext]))
|
||||
{
|
||||
woContext = [newContext woContext];
|
||||
userFolder = [SOGoUserFolder objectWithName: [newURL user]
|
||||
inContainer: MAPIApp];
|
||||
[parentContainersBag addObject: userFolder];
|
||||
[woContext setClientObject: userFolder];
|
||||
|
||||
parentFolder = [userFolder lookupName: @"Calendar"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentContainersBag addObject: parentFolder];
|
||||
[woContext setClientObject: parentFolder];
|
||||
|
||||
sogoObject = [parentFolder lookupName: @"personal"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[sogoObject retain];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (Class) messageClass
|
||||
{
|
||||
return MAPIStoreCalendarMessageK;
|
||||
}
|
||||
|
||||
- (MAPIStoreMessageTable *) messageTable
|
||||
{
|
||||
if (!messageTable)
|
||||
ASSIGN (messageTable,
|
||||
[MAPIStoreCalendarMessageTable tableForContainer: self]);
|
||||
|
||||
return messageTable;
|
||||
}
|
||||
|
||||
- (EOQualifier *) componentQualifier
|
||||
{
|
||||
static EOQualifier *componentQualifier = nil;
|
||||
|
||||
if (!componentQualifier)
|
||||
componentQualifier
|
||||
= [[EOKeyValueQualifier alloc] initWithKey: @"c_component"
|
||||
operatorSelector: EOQualifierOperatorEqual
|
||||
value: @"vevent"];
|
||||
|
||||
return componentQualifier;
|
||||
}
|
||||
|
||||
- (MAPIStoreMessage *) createMessage
|
||||
{
|
||||
MAPIStoreMessage *newMessage;
|
||||
SOGoAppointmentObject *newEntry;
|
||||
NSString *name;
|
||||
|
||||
name = [NSString stringWithFormat: @"%@.ics",
|
||||
[SOGoObject globallyUniqueObjectId]];
|
||||
newEntry = [SOGoAppointmentObject objectWithName: name
|
||||
inContainer: sogoObject];
|
||||
[newEntry setIsNew: YES];
|
||||
newMessage = [MAPIStoreCalendarMessage mapiStoreObjectWithSOGoObject: newEntry
|
||||
inContainer: self];
|
||||
|
||||
|
||||
return newMessage;
|
||||
}
|
||||
|
||||
@end
|
|
@ -22,15 +22,7 @@
|
|||
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
|
||||
#import <Contacts/SOGoContactGCSEntry.h>
|
||||
#import <Contacts/SOGoContactGCSFolder.h>
|
||||
#import <Contacts/SOGoContactFolders.h>
|
||||
|
||||
#import "MAPIApplication.h"
|
||||
#import "MAPIStoreAuthenticator.h"
|
||||
#import "MAPIStoreContactsMessageTable.h"
|
||||
#import "MAPIStoreContactsFolder.h"
|
||||
#import "MAPIStoreMapping.h"
|
||||
|
||||
#import "MAPIStoreContactsContext.h"
|
||||
|
@ -48,48 +40,11 @@
|
|||
withID: 0x1a0001];
|
||||
}
|
||||
|
||||
- (void) setupModuleFolder
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoContactFolders *parentFolder;
|
||||
|
||||
userFolder = [SOGoUserFolder objectWithName: [authenticator username]
|
||||
inContainer: MAPIApp];
|
||||
[parentFoldersBag addObject: userFolder];
|
||||
[woContext setClientObject: userFolder];
|
||||
|
||||
parentFolder = [userFolder lookupName: @"Contacts"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentFoldersBag addObject: parentFolder];
|
||||
[woContext setClientObject: parentFolder];
|
||||
|
||||
moduleFolder = [parentFolder lookupName: @"personal"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[moduleFolder retain];
|
||||
}
|
||||
|
||||
- (Class) messageTableClass
|
||||
{
|
||||
return [MAPIStoreContactsMessageTable class];
|
||||
}
|
||||
|
||||
- (id) createMessageOfClass: (NSString *) messageClass
|
||||
inFolderAtURL: (NSString *) folderURL;
|
||||
{
|
||||
SOGoContactGCSFolder *parentFolder;
|
||||
SOGoContactGCSEntry *newEntry;
|
||||
NSString *name;
|
||||
|
||||
parentFolder = [self lookupObject: folderURL];
|
||||
name = [NSString stringWithFormat: @"%@.vcf",
|
||||
[SOGoObject globallyUniqueObjectId]];
|
||||
newEntry = [SOGoContactGCSEntry objectWithName: name
|
||||
inContainer: parentFolder];
|
||||
[newEntry setIsNew: YES];
|
||||
|
||||
return newEntry;
|
||||
baseFolder = [MAPIStoreContactsFolder baseFolderWithURL: newURL
|
||||
inContext: self];
|
||||
[baseFolder retain];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/* MAPIStoreContactsFolder.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 MAPISTORECONTACTSFOLDER_H
|
||||
#define MAPISTORECONTACTSFOLDER_H
|
||||
|
||||
#import "MAPIStoreGCSFolder.h"
|
||||
|
||||
@interface MAPIStoreContactsFolder : MAPIStoreGCSFolder
|
||||
|
||||
@end
|
||||
|
||||
#endif /* MAPISTORECONTACTSFOLDER_H */
|
|
@ -0,0 +1,126 @@
|
|||
/* MAPIStoreContactsFolder.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 <Foundation/NSURL.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
#import <EOControl/EOQualifier.h>
|
||||
#import <Contacts/SOGoContactGCSEntry.h>
|
||||
#import <Contacts/SOGoContactFolders.h>
|
||||
|
||||
#import "MAPIApplication.h"
|
||||
#import "MAPIStoreContactsContext.h"
|
||||
#import "MAPIStoreContactsMessage.h"
|
||||
#import "MAPIStoreContactsMessageTable.h"
|
||||
|
||||
#import "MAPIStoreContactsFolder.h"
|
||||
|
||||
static Class MAPIStoreContactsMessageK;
|
||||
|
||||
@implementation MAPIStoreContactsFolder
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
MAPIStoreContactsMessageK = [MAPIStoreContactsMessage class];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) initWithURL: (NSURL *) newURL
|
||||
inContext: (MAPIStoreContext *) newContext
|
||||
{
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoContactFolders *parentFolder;
|
||||
WOContext *woContext;
|
||||
|
||||
if ((self = [super initWithURL: newURL
|
||||
inContext: newContext]))
|
||||
{
|
||||
woContext = [newContext woContext];
|
||||
userFolder = [SOGoUserFolder objectWithName: [newURL user]
|
||||
inContainer: MAPIApp];
|
||||
[parentContainersBag addObject: userFolder];
|
||||
[woContext setClientObject: userFolder];
|
||||
|
||||
parentFolder = [userFolder lookupName: @"Contacts"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentContainersBag addObject: parentFolder];
|
||||
[woContext setClientObject: parentFolder];
|
||||
|
||||
sogoObject = [parentFolder lookupName: @"personal"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[sogoObject retain];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (Class) messageClass
|
||||
{
|
||||
return MAPIStoreContactsMessageK;
|
||||
}
|
||||
|
||||
- (MAPIStoreMessageTable *) messageTable
|
||||
{
|
||||
if (!messageTable)
|
||||
ASSIGN (messageTable,
|
||||
[MAPIStoreContactsMessageTable tableForContainer: self]);
|
||||
|
||||
return messageTable;
|
||||
}
|
||||
|
||||
- (EOQualifier *) componentQualifier
|
||||
{
|
||||
static EOQualifier *componentQualifier = nil;
|
||||
|
||||
/* TODO: we need to support vlist as well */
|
||||
if (!componentQualifier)
|
||||
componentQualifier
|
||||
= [[EOKeyValueQualifier alloc] initWithKey: @"c_component"
|
||||
operatorSelector: EOQualifierOperatorEqual
|
||||
value: @"vcard"];
|
||||
|
||||
return componentQualifier;
|
||||
}
|
||||
|
||||
- (MAPIStoreMessage *) createMessage
|
||||
{
|
||||
MAPIStoreMessage *newMessage;
|
||||
SOGoContactGCSEntry *newEntry;
|
||||
NSString *name;
|
||||
|
||||
name = [NSString stringWithFormat: @"%@.vcf",
|
||||
[SOGoObject globallyUniqueObjectId]];
|
||||
newEntry = [SOGoContactGCSEntry objectWithName: name
|
||||
inContainer: sogoObject];
|
||||
[newEntry setIsNew: YES];
|
||||
newMessage = [MAPIStoreContactsMessage mapiStoreObjectWithSOGoObject: newEntry
|
||||
inContainer: self];
|
||||
|
||||
return newMessage;
|
||||
}
|
||||
|
||||
@end
|
|
@ -30,6 +30,7 @@
|
|||
@class NSMutableArray;
|
||||
@class NSMutableDictionary;
|
||||
@class NSString;
|
||||
@class NSURL;
|
||||
|
||||
@class EOQualifier;
|
||||
|
||||
|
@ -40,6 +41,7 @@
|
|||
@class SOGoObject;
|
||||
|
||||
@class MAPIStoreAuthenticator;
|
||||
@class MAPIStoreFolder;
|
||||
@class MAPIStoreMapping;
|
||||
@class MAPIStoreTable;
|
||||
|
||||
|
@ -49,17 +51,10 @@
|
|||
|
||||
NSString *uri;
|
||||
|
||||
NSMutableArray *parentFoldersBag;
|
||||
|
||||
MAPIStoreAuthenticator *authenticator;
|
||||
WOContext *woContext;
|
||||
|
||||
id moduleFolder;
|
||||
SOGoMAPIFSFolder *faiModuleFolder;
|
||||
|
||||
MAPIStoreTable *folderTable;
|
||||
MAPIStoreTable *messageTable;
|
||||
MAPIStoreTable *faiTable;
|
||||
MAPIStoreFolder *baseFolder;
|
||||
|
||||
/* for active messages (NSDictionary instances) */
|
||||
NSMutableDictionary *messages;
|
||||
|
@ -71,15 +66,15 @@
|
|||
- (void) setURI: (NSString *) newUri
|
||||
andMemCtx: (struct mapistore_context *) newMemCtx;
|
||||
|
||||
- (void) setupModuleFolder;
|
||||
|
||||
- (void) setAuthenticator: (MAPIStoreAuthenticator *) newAuthenticator;
|
||||
- (MAPIStoreAuthenticator *) authenticator;
|
||||
|
||||
- (WOContext *) woContext;
|
||||
|
||||
- (void) setupRequest;
|
||||
- (void) tearDownRequest;
|
||||
|
||||
- (id) lookupObject: (NSString *) objectURLString;
|
||||
// - (id) lookupObject: (NSString *) objectURLString;
|
||||
|
||||
/* backend methods */
|
||||
- (int) getPath: (char **) path
|
||||
|
@ -119,9 +114,9 @@
|
|||
- (int) openMessage: (struct mapistore_message *) msg
|
||||
withMID: (uint64_t) mid
|
||||
inFID: (uint64_t) fid;
|
||||
- (int) createMessagePropertiesWithMID: (uint64_t) mid
|
||||
inFID: (uint64_t) fid
|
||||
isAssociated: (BOOL) isAssociated;
|
||||
- (int) createMessageWithMID: (uint64_t) mid
|
||||
inFID: (uint64_t) fid
|
||||
isAssociated: (BOOL) isAssociated;
|
||||
- (int) saveChangesInMessageWithMID: (uint64_t) mid
|
||||
andFlags: (uint8_t) flags;
|
||||
- (int) submitMessageWithMID: (uint64_t) mid
|
||||
|
@ -152,28 +147,30 @@
|
|||
- (int) getFoldersList: (struct indexing_folders_list **) folders_list
|
||||
withFMID: (uint64_t) fmid;
|
||||
|
||||
|
||||
/* util methods */
|
||||
- (NSString *) extractChildNameFromURL: (NSString *) childURL
|
||||
andFolderURLAt: (NSString **) folderURL;
|
||||
|
||||
- (void) registerValue: (id) value
|
||||
asProperty: (enum MAPITAGS) property
|
||||
forURL: (NSString *) url;
|
||||
- (uint64_t) idForObjectWithKey: (NSString *) key
|
||||
inFolderURL: (NSString *) folderURL;
|
||||
|
||||
/* subclass methods */
|
||||
+ (NSString *) MAPIModuleName;
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) storeMapping;
|
||||
- (void) setupBaseFolder: (NSURL *) newURL;
|
||||
|
||||
- (Class) messageTableClass;
|
||||
- (Class) folderTableClass;
|
||||
/* proof of concept */
|
||||
- (int) getAttachmentTable: (void **) table
|
||||
andRowCount: (uint32_t *) count
|
||||
withMID: (uint64_t) mid;
|
||||
- (int) getAttachment: (void **) attachment
|
||||
withAID: (uint32_t) aid
|
||||
inMID: (uint64_t) mid;
|
||||
|
||||
- (id) createMessageOfClass: (NSString *) messageClass
|
||||
inFolderAtURL: (NSString *) folderURL;
|
||||
|
||||
- (int) openMessage: (struct mapistore_message *) msg
|
||||
forKey: (NSString *) childKey
|
||||
inTable: (MAPIStoreTable *) table;
|
||||
- (int) createAttachment: (void **) attachmentPtr
|
||||
inAID: (uint32_t *) aid
|
||||
withMessage: (uint64_t) mid;
|
||||
|
||||
@end
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -23,9 +23,9 @@
|
|||
#ifndef MAPISTOREDELETEDITEMSCONTEXT_H
|
||||
#define MAPISTOREDELETEDITEMSCONTEXT_H
|
||||
|
||||
#import "MAPIStoreMailContext.h"
|
||||
#import "MAPIStoreMailBaseContext.h"
|
||||
|
||||
@interface MAPIStoreDeletedItemsContext : MAPIStoreMailContext
|
||||
@interface MAPIStoreDeletedItemsContext : MAPIStoreMailBaseContext
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -22,15 +22,9 @@
|
|||
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
|
||||
#import "MAPIStoreMailFolder.h"
|
||||
#import "MAPIStoreMapping.h"
|
||||
|
||||
#import <Mailer/SOGoMailAccount.h>
|
||||
|
||||
#import "MAPIApplication.h"
|
||||
#import "MAPIStoreAuthenticator.h"
|
||||
|
||||
#import "MAPIStoreDeletedItemsContext.h"
|
||||
|
||||
@implementation MAPIStoreDeletedItemsContext
|
||||
|
@ -46,40 +40,11 @@
|
|||
withID: 0x170001];
|
||||
}
|
||||
|
||||
- (void) setupModuleFolder
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoMailAccounts *accountsFolder;
|
||||
SOGoMailAccount *accountFolder;
|
||||
SOGoFolder *currentContainer;
|
||||
|
||||
userFolder = [SOGoUserFolder objectWithName: [authenticator username]
|
||||
inContainer: MAPIApp];
|
||||
[parentFoldersBag addObject: userFolder];
|
||||
// [self logWithFormat: @"userFolder: %@", userFolder];
|
||||
[woContext setClientObject: userFolder];
|
||||
|
||||
accountsFolder = [userFolder lookupName: @"Mail"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentFoldersBag addObject: accountsFolder];
|
||||
// [self logWithFormat: @"accountsFolder: %@", accountsFolder];
|
||||
[woContext setClientObject: accountsFolder];
|
||||
|
||||
accountFolder = [accountsFolder lookupName: @"0"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentFoldersBag addObject: accountFolder];
|
||||
[woContext setClientObject: accountFolder];
|
||||
|
||||
moduleFolder = [accountFolder trashFolderInContext: nil];
|
||||
[moduleFolder retain];
|
||||
currentContainer = [moduleFolder container];
|
||||
while (currentContainer != (SOGoFolder *) accountFolder)
|
||||
{
|
||||
[parentFoldersBag addObject: currentContainer];
|
||||
currentContainer = [currentContainer container];
|
||||
}
|
||||
baseFolder = [MAPIStoreDeletedItemsFolder baseFolderWithURL: newURL
|
||||
inContext: self];
|
||||
[baseFolder retain];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
#ifndef MAPISTOREDRAFTSCONTEXT_H
|
||||
#define MAPISTOREDRAFTSCONTEXT_H
|
||||
|
||||
#import "MAPIStoreMailContext.h"
|
||||
#import "MAPIStoreMailBaseContext.h"
|
||||
|
||||
@interface MAPIStoreDraftsContext : MAPIStoreMailContext
|
||||
@interface MAPIStoreDraftsContext : MAPIStoreMailBaseContext
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -22,16 +22,9 @@
|
|||
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
|
||||
#import "MAPIStoreMailFolder.h"
|
||||
#import "MAPIStoreMapping.h"
|
||||
|
||||
#import <Mailer/SOGoDraftsFolder.h>
|
||||
#import <Mailer/SOGoMailAccount.h>
|
||||
|
||||
#import "MAPIApplication.h"
|
||||
#import "MAPIStoreAuthenticator.h"
|
||||
|
||||
#import "MAPIStoreDraftsContext.h"
|
||||
|
||||
@implementation MAPIStoreDraftsContext
|
||||
|
@ -43,50 +36,15 @@
|
|||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@drafts/"
|
||||
withID: 0x1e0001];
|
||||
[mapping registerURL: @"sogo://openchange:openchange@inbox/"
|
||||
withID: 0x1e0001];
|
||||
}
|
||||
|
||||
- (void) setupModuleFolder
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoMailAccounts *accountsFolder;
|
||||
SOGoMailAccount *accountFolder;
|
||||
SOGoFolder *currentContainer;
|
||||
|
||||
userFolder = [SOGoUserFolder objectWithName: [authenticator username]
|
||||
inContainer: MAPIApp];
|
||||
[parentFoldersBag addObject: userFolder];
|
||||
// [self logWithFormat: @"userFolder: %@", userFolder];
|
||||
[woContext setClientObject: userFolder];
|
||||
|
||||
accountsFolder = [userFolder lookupName: @"Mail"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentFoldersBag addObject: accountsFolder];
|
||||
// [self logWithFormat: @"accountsFolder: %@", accountsFolder];
|
||||
[woContext setClientObject: accountsFolder];
|
||||
|
||||
accountFolder = [accountsFolder lookupName: @"0"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentFoldersBag addObject: accountFolder];
|
||||
[woContext setClientObject: accountFolder];
|
||||
|
||||
moduleFolder = [accountFolder draftsFolderInContext: nil];
|
||||
[moduleFolder retain];
|
||||
currentContainer = [moduleFolder container];
|
||||
while (currentContainer != (SOGoFolder *) accountFolder)
|
||||
{
|
||||
[parentFoldersBag addObject: currentContainer];
|
||||
currentContainer = [currentContainer container];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) createMessageOfClass: (NSString *) messageClass
|
||||
inFolderAtURL: (NSString *) folderURL;
|
||||
{
|
||||
return [moduleFolder newDraft];
|
||||
baseFolder = [MAPIStoreDraftsFolder baseFolderWithURL: newURL
|
||||
inContext: self];
|
||||
[baseFolder retain];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
|
||||
#import "MAPIStoreFSMessageTable.h"
|
||||
#import "MAPIStoreFSFolder.h"
|
||||
#import "MAPIStoreMapping.h"
|
||||
#import "SOGoMAPIFSFolder.h"
|
||||
|
||||
|
@ -37,34 +37,26 @@
|
|||
#undef DEBUG
|
||||
#include <mapistore/mapistore.h>
|
||||
|
||||
static Class MAPIStoreFSFolderK;
|
||||
|
||||
@implementation MAPIStoreFSBaseContext
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
MAPIStoreFSFolderK = [MAPIStoreFSFolder class];
|
||||
}
|
||||
|
||||
+ (NSString *) MAPIModuleName
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) setupModuleFolder
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
[self logWithFormat: @"invoked %s", __PRETTY_FUNCTION__];
|
||||
moduleFolder = [SOGoMAPIFSFolder folderWithURL: [NSURL URLWithString: uri]
|
||||
andTableType: MAPISTORE_MESSAGE_TABLE];
|
||||
[moduleFolder retain];
|
||||
}
|
||||
|
||||
- (Class) messageTableClass
|
||||
{
|
||||
return [MAPIStoreFSMessageTable class];
|
||||
}
|
||||
|
||||
- (id) createMessageOfClass: (NSString *) messageClass
|
||||
inFolderAtURL: (NSString *) folderURL;
|
||||
{
|
||||
SOGoMAPIFSFolder *parentFolder;
|
||||
|
||||
parentFolder = [self lookupObject: folderURL];
|
||||
|
||||
return [parentFolder newMessage];
|
||||
baseFolder = [MAPIStoreFSFolderK baseFolderWithURL: newURL
|
||||
inContext: self];
|
||||
[baseFolder retain];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/* MAPIStoreFSFolder.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 MAPISTOREFSFOLDER_H
|
||||
#define MAPISTOREFSFOLDER_H
|
||||
|
||||
#import "MAPIStoreFolder.h"
|
||||
|
||||
@interface MAPIStoreFSFolder : MAPIStoreFolder
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#endif /* MAPISTOREFSFOLDER_H */
|
|
@ -0,0 +1,128 @@
|
|||
/* MAPIStoreFSFolder.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 <Foundation/NSArray.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
|
||||
#import "EOQualifier+MAPIFS.h"
|
||||
#import "MAPIStoreFSMessage.h"
|
||||
#import "SOGoMAPIFSFolder.h"
|
||||
#import "SOGoMAPIFSMessage.h"
|
||||
|
||||
#import "MAPIStoreFSFolder.h"
|
||||
|
||||
#undef DEBUG
|
||||
#include <mapistore/mapistore.h>
|
||||
// #include <mapistore/mapistore_errors.h>
|
||||
// #include <libmapiproxy.h>
|
||||
// #include <param.h>
|
||||
|
||||
static Class MAPIStoreFSMessageK;
|
||||
|
||||
@implementation MAPIStoreFSFolder
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
MAPIStoreFSMessageK = [MAPIStoreFSMessage class];
|
||||
}
|
||||
|
||||
- (id) initWithURL: (NSURL *) newURL
|
||||
inContext: (MAPIStoreContext *) newContext
|
||||
{
|
||||
if ((self = [super initWithURL: newURL
|
||||
inContext: newContext]))
|
||||
{
|
||||
sogoObject = [SOGoMAPIFSFolder folderWithURL: newURL
|
||||
andTableType: MAPISTORE_MESSAGE_TABLE];
|
||||
[sogoObject retain];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (MAPIStoreMessageTable *) messageTable
|
||||
{
|
||||
if (!messageTable)
|
||||
ASSIGN (messageTable,
|
||||
[MAPIStoreFSMessageTable tableForContainer: self]);
|
||||
|
||||
return messageTable;
|
||||
}
|
||||
|
||||
- (Class) messageClass
|
||||
{
|
||||
return MAPIStoreFSMessageK;
|
||||
}
|
||||
|
||||
- (MAPIStoreMessage *) createMessage
|
||||
{
|
||||
MAPIStoreMessage *newMessage;
|
||||
SOGoMAPIFSMessage *fsObject;
|
||||
NSString *newKey;
|
||||
|
||||
newKey = [NSString stringWithFormat: @"%@.plist",
|
||||
[SOGoObject globallyUniqueObjectId]];
|
||||
fsObject = [SOGoMAPIFSMessage objectWithName: newKey inContainer: faiFolder];
|
||||
newMessage = [MAPIStoreFSMessage mapiStoreObjectWithSOGoObject: fsObject
|
||||
inContainer: self];
|
||||
|
||||
|
||||
return newMessage;
|
||||
}
|
||||
|
||||
- (NSArray *) childKeysMatchingQualifier: (EOQualifier *) qualifier
|
||||
andSortOrderings: (NSArray *) sortOrderings
|
||||
{
|
||||
NSArray *allKeys;
|
||||
NSMutableArray *keys;
|
||||
NSUInteger count, max;
|
||||
NSString *messageKey;
|
||||
SOGoMAPIFSMessage *message;
|
||||
|
||||
if (sortOrderings)
|
||||
[self warnWithFormat: @"sorting is not handled yet"];
|
||||
|
||||
allKeys = [sogoObject toOneRelationshipKeys];
|
||||
if (qualifier)
|
||||
{
|
||||
[self logWithFormat: @"%s: getting restricted keys", __PRETTY_FUNCTION__];
|
||||
max = [allKeys count];
|
||||
keys = [NSMutableArray arrayWithCapacity: max];
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
messageKey = [allKeys objectAtIndex: count];
|
||||
message = [sogoObject lookupName: messageKey
|
||||
inContext: nil
|
||||
acquire: NO];
|
||||
if ([qualifier evaluateMAPIFSMessage: message])
|
||||
[keys addObject: messageKey];
|
||||
}
|
||||
[self logWithFormat: @" resulting keys: $$$%@$$$", keys];
|
||||
}
|
||||
else
|
||||
keys = (NSMutableArray *) allKeys;
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,84 @@
|
|||
/* MAPIStoreFolder.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 MAPISTOREFOLDER_H
|
||||
#define MAPISTOREFOLDER_H
|
||||
|
||||
#import <Foundation/NSObject.h>
|
||||
|
||||
#import "MAPIStoreTable.h"
|
||||
|
||||
@class NSMutableArray;
|
||||
@class NSURL;
|
||||
|
||||
@class EOQualifier;
|
||||
|
||||
@class MAPIStoreContext;
|
||||
@class MAPIStoreMessage;
|
||||
@class MAPIStoreFSMessageTable;
|
||||
@class MAPIStoreFolderTable;
|
||||
@class MAPIStoreMessageTable;
|
||||
@class SOGoMAPIFSFolder;
|
||||
|
||||
#import "MAPIStoreObject.h"
|
||||
|
||||
@interface MAPIStoreFolder : MAPIStoreObject
|
||||
{
|
||||
NSURL *folderURL;
|
||||
MAPIStoreContext *context;
|
||||
MAPIStoreMessageTable *messageTable;
|
||||
NSArray *messageKeys;
|
||||
MAPIStoreFSMessageTable *faiMessageTable;
|
||||
NSArray *faiMessageKeys;
|
||||
MAPIStoreFolderTable *folderTable;
|
||||
NSMutableArray *folderKeys;
|
||||
|
||||
SOGoMAPIFSFolder *faiFolder;
|
||||
}
|
||||
|
||||
+ (id) baseFolderWithURL: (NSURL *) newURL
|
||||
inContext: (MAPIStoreContext *) newContext;
|
||||
- (id) initWithURL: (NSURL *) newURL
|
||||
inContext: (MAPIStoreContext *) newContext;
|
||||
|
||||
- (MAPIStoreMessageTable *) messageTable;
|
||||
- (NSArray *) messageKeys;
|
||||
|
||||
- (MAPIStoreFSMessageTable *) faiMessageTable;
|
||||
- (NSArray *) faiMessageKeys;
|
||||
|
||||
- (MAPIStoreFolderTable *) folderTable;
|
||||
- (NSArray *) folderKeys;
|
||||
|
||||
- (MAPIStoreMessage *) createMessage: (BOOL) isAssociated;
|
||||
- (NSString *) createFolder: (struct SRow *) aRow;
|
||||
|
||||
/* helpers */
|
||||
- (uint64_t) idForObjectWithKey: (NSString *) childKey;
|
||||
|
||||
/* subclasses */
|
||||
- (Class) messageClass;
|
||||
- (MAPIStoreMessage *) createMessage;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* MAPISTOREFOLDER_H */
|
|
@ -0,0 +1,356 @@
|
|||
/* MAPIStoreFolder.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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.
|
||||
*/
|
||||
|
||||
/* TODO: main key arrays must be initialized */
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
#import <SOGo/SOGoFolder.h>
|
||||
|
||||
#import "MAPIStoreContext.h"
|
||||
#import "MAPIStoreFSMessage.h"
|
||||
#import "MAPIStoreFSMessageTable.h"
|
||||
#import "MAPIStoreFolder.h"
|
||||
#import "MAPIStoreMessage.h"
|
||||
#import "MAPIStoreTypes.h"
|
||||
#import "NSString+MAPIStore.h"
|
||||
#import "SOGoMAPIFSFolder.h"
|
||||
#import "SOGoMAPIFSMessage.h"
|
||||
|
||||
#include <gen_ndr/exchange.h>
|
||||
|
||||
#undef DEBUG
|
||||
#include <mapistore/mapistore.h>
|
||||
#include <mapistore/mapistore_nameid.h>
|
||||
// #include <mapistore/mapistore_errors.h>
|
||||
|
||||
Class NSExceptionK;
|
||||
|
||||
@implementation MAPIStoreFolder
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
NSExceptionK = [NSException class];
|
||||
}
|
||||
|
||||
+ (id) baseFolderWithURL: (NSURL *) newURL
|
||||
inContext: (MAPIStoreContext *) newContext
|
||||
{
|
||||
id newFolder;
|
||||
|
||||
newFolder = [[self alloc] initWithURL: newURL inContext: newContext];
|
||||
[newFolder autorelease];
|
||||
|
||||
return newFolder;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
messageTable = nil;
|
||||
messageKeys = nil;
|
||||
faiMessageTable = nil;
|
||||
faiMessageKeys = nil;
|
||||
folderTable = nil;
|
||||
folderKeys = nil;
|
||||
faiFolder = nil;
|
||||
folderURL = nil;
|
||||
context = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithURL: (NSURL *) newURL
|
||||
inContext: (MAPIStoreContext *) newContext
|
||||
{
|
||||
if ((self = [self init]))
|
||||
{
|
||||
context = newContext;
|
||||
ASSIGN (folderURL, newURL);
|
||||
ASSIGN (faiFolder,
|
||||
[SOGoMAPIFSFolder folderWithURL: newURL
|
||||
andTableType: MAPISTORE_FAI_TABLE]);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[folderURL release];
|
||||
[messageTable release];
|
||||
[messageKeys release];
|
||||
[faiMessageTable release];
|
||||
[faiMessageKeys release];
|
||||
[folderTable release];
|
||||
[folderKeys release];
|
||||
[faiFolder release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (MAPIStoreContext *) context
|
||||
{
|
||||
if (!context)
|
||||
context = [container context];
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
- (NSArray *) messageKeys
|
||||
{
|
||||
if (!messageKeys)
|
||||
{
|
||||
messageKeys = [self childKeysMatchingQualifier: nil
|
||||
andSortOrderings: nil];
|
||||
[messageKeys retain];
|
||||
}
|
||||
|
||||
return messageKeys;
|
||||
}
|
||||
|
||||
- (MAPIStoreFSMessageTable *) faiMessageTable
|
||||
{
|
||||
if (!faiMessageTable)
|
||||
{
|
||||
faiMessageTable = [MAPIStoreFSMessageTable tableForContainer: self];
|
||||
[faiMessageTable retain];
|
||||
}
|
||||
|
||||
return faiMessageTable;
|
||||
}
|
||||
|
||||
- (NSArray *) faiMessageKeys
|
||||
{
|
||||
if (!faiMessageKeys)
|
||||
{
|
||||
faiMessageKeys = [faiFolder toOneRelationshipKeys];
|
||||
[faiMessageKeys retain];
|
||||
}
|
||||
|
||||
return faiMessageKeys;
|
||||
}
|
||||
|
||||
- (MAPIStoreFolderTable *) folderTable
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray *) folderKeys
|
||||
{
|
||||
if (!faiMessageKeys)
|
||||
faiMessageKeys = [NSArray new];
|
||||
|
||||
return faiMessageKeys;
|
||||
}
|
||||
|
||||
- (void) cleanupCaches
|
||||
{
|
||||
[faiMessageTable cleanupCaches];
|
||||
[faiMessageKeys release];
|
||||
faiMessageKeys = nil;
|
||||
[messageTable cleanupCaches];
|
||||
[messageKeys release];
|
||||
messageKeys = nil;
|
||||
[folderTable cleanupCaches];
|
||||
[folderKeys release];
|
||||
folderKeys = nil;
|
||||
}
|
||||
|
||||
- (id) lookupChild: (NSString *) childKey
|
||||
{
|
||||
MAPIStoreObject *newChild;
|
||||
SOGoObject *msgObject;
|
||||
|
||||
if (childKey)
|
||||
{
|
||||
[self faiMessageKeys];
|
||||
if ([faiMessageKeys containsObject: childKey])
|
||||
{
|
||||
msgObject = [faiFolder lookupName: childKey
|
||||
inContext: nil
|
||||
acquire: NO];
|
||||
newChild
|
||||
= [MAPIStoreFSMessage mapiStoreObjectWithSOGoObject: msgObject
|
||||
inContainer: self];
|
||||
}
|
||||
else
|
||||
{
|
||||
msgObject = [sogoObject lookupName: childKey
|
||||
inContext: nil
|
||||
acquire: NO];
|
||||
if ([msgObject isKindOfClass: NSExceptionK])
|
||||
msgObject = nil;
|
||||
|
||||
if (msgObject)
|
||||
newChild
|
||||
= [[self messageClass] mapiStoreObjectWithSOGoObject: msgObject
|
||||
inContainer: self];
|
||||
else
|
||||
newChild = nil;
|
||||
}
|
||||
}
|
||||
else
|
||||
newChild = nil;
|
||||
|
||||
return newChild;
|
||||
}
|
||||
|
||||
- (enum MAPISTATUS) getProperty: (void **) data
|
||||
withTag: (enum MAPITAGS) propTag
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = MAPI_E_SUCCESS;
|
||||
switch (propTag)
|
||||
{
|
||||
case PR_FID:
|
||||
/* TODO: incomplete */
|
||||
*data = MAPILongValue (memCtx, [self objectId]);
|
||||
break;
|
||||
case PR_ACCESS: // TODO
|
||||
*data = MAPILongValue (memCtx, 0x63);
|
||||
break;
|
||||
case PR_ACCESS_LEVEL: // TODO
|
||||
*data = MAPILongValue (memCtx, 0x01);
|
||||
break;
|
||||
case PR_PARENT_FID:
|
||||
*data = MAPILongLongValue (memCtx, [container objectId]);
|
||||
break;
|
||||
case PR_ATTR_HIDDEN:
|
||||
case PR_ATTR_SYSTEM:
|
||||
case PR_ATTR_READONLY:
|
||||
*data = MAPIBoolValue (memCtx, NO);
|
||||
break;
|
||||
case PR_SUBFOLDERS:
|
||||
*data = MAPIBoolValue (memCtx, [folderKeys count]);
|
||||
// [[child toManyRelationshipKeys] count] > 0);
|
||||
break;
|
||||
case PR_CONTENT_COUNT:
|
||||
*data = MAPILongValue (memCtx, [messageKeys count]);
|
||||
break;
|
||||
// case PR_EXTENDED_FOLDER_FLAGS: // TODO: DOUBT: how to indicate the
|
||||
// // number of subresponses ?
|
||||
// binaryValue = talloc_zero(memCtx, struct Binary_r);
|
||||
// *data = binaryValue;
|
||||
// break;
|
||||
default:
|
||||
rc = [super getProperty: data
|
||||
withTag: propTag];
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
- (MAPIStoreMessage *) _createAssociatedMessage
|
||||
{
|
||||
MAPIStoreMessage *newMessage;
|
||||
SOGoMAPIFSMessage *fsObject;
|
||||
NSString *newKey;
|
||||
|
||||
newKey = [NSString stringWithFormat: @"%@.plist",
|
||||
[SOGoObject globallyUniqueObjectId]];
|
||||
fsObject = [SOGoMAPIFSMessage objectWithName: newKey inContainer: faiFolder];
|
||||
newMessage = [MAPIStoreFSMessage mapiStoreObjectWithSOGoObject: fsObject
|
||||
inContainer: self];
|
||||
|
||||
|
||||
return newMessage;
|
||||
}
|
||||
|
||||
- (MAPIStoreMessage *) createMessage: (BOOL) isAssociated
|
||||
{
|
||||
MAPIStoreMessage *newMessage;
|
||||
|
||||
if (isAssociated)
|
||||
newMessage = [self _createAssociatedMessage];
|
||||
else
|
||||
newMessage = [self createMessage];
|
||||
|
||||
return newMessage;
|
||||
}
|
||||
|
||||
- (NSString *) createFolder: (struct SRow *) aRow
|
||||
{
|
||||
[self errorWithFormat: @"new folders cannot be created in this context"];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
/* helpers */
|
||||
|
||||
- (NSString *) url
|
||||
{
|
||||
NSString *url;
|
||||
|
||||
if (folderURL)
|
||||
url = [folderURL absoluteString];
|
||||
else
|
||||
url = [NSString stringWithFormat: @"%@/", [super url]];
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
- (uint64_t) objectId
|
||||
{
|
||||
uint64_t objectId;
|
||||
|
||||
if (folderURL)
|
||||
objectId = [self idForObjectWithKey: nil];
|
||||
else
|
||||
objectId = [super objectId];
|
||||
|
||||
return objectId;
|
||||
}
|
||||
|
||||
- (uint64_t) idForObjectWithKey: (NSString *) childKey
|
||||
{
|
||||
return [[self context] idForObjectWithKey: childKey
|
||||
inFolderURL: [self url]];
|
||||
}
|
||||
|
||||
/* subclasses */
|
||||
|
||||
- (MAPIStoreMessageTable *) messageTable
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (Class) messageClass
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
||||
return Nil;
|
||||
}
|
||||
|
||||
- (MAPIStoreMessage *) createMessage
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
|
@ -43,19 +43,19 @@
|
|||
withID: 0x70001];
|
||||
}
|
||||
|
||||
- (void) setupModuleFolder
|
||||
{
|
||||
SOGoUserFolder *userFolder;
|
||||
// - (void) setupModuleFolder
|
||||
// {
|
||||
// SOGoUserFolder *userFolder;
|
||||
|
||||
userFolder = [SOGoUserFolder objectWithName: [authenticator username]
|
||||
inContainer: MAPIApp];
|
||||
[parentFoldersBag addObject: userFolder];
|
||||
[woContext setClientObject: userFolder];
|
||||
// userFolder = [SOGoUserFolder objectWithName: [authenticator username]
|
||||
// inContainer: MAPIApp];
|
||||
// [parentFoldersBag addObject: userFolder];
|
||||
// [woContext setClientObject: userFolder];
|
||||
|
||||
moduleFolder = [userFolder lookupName: @"Calendar"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[moduleFolder retain];
|
||||
}
|
||||
// moduleFolder = [userFolder lookupName: @"Calendar"
|
||||
// inContext: woContext
|
||||
// acquire: NO];
|
||||
// [moduleFolder retain];
|
||||
// }
|
||||
|
||||
@end
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/* MAPIStoreGCSFolder.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 MAPISTOREGCSFOLDER_H
|
||||
#define MAPISTOREGCSFOLDER_H
|
||||
|
||||
#import "MAPIStoreFolder.h"
|
||||
|
||||
@interface MAPIStoreGCSFolder : MAPIStoreFolder
|
||||
|
||||
/* subclasses */
|
||||
- (EOQualifier *) componentQualifier;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* MAPISTOREGCSFOLDER_H */
|
|
@ -0,0 +1,82 @@
|
|||
/* MAPIStoreGCSFolder.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 <Foundation/NSString.h>
|
||||
#import <EOControl/EOQualifier.h>
|
||||
#import <EOControl/EOFetchSpecification.h>
|
||||
#import <GDLContentStore/GCSFolder.h>
|
||||
#import <SOGo/NSArray+Utilities.h>
|
||||
#import <SOGo/SOGoGCSFolder.h>
|
||||
|
||||
#import "MAPIStoreGCSFolder.h"
|
||||
|
||||
@implementation MAPIStoreGCSFolder
|
||||
|
||||
- (NSArray *) childKeysMatchingQualifier: (EOQualifier *) qualifier
|
||||
andSortOrderings: (NSArray *) sortOrderings
|
||||
{
|
||||
static NSArray *fields = nil;
|
||||
NSArray *records;
|
||||
EOQualifier *componentQualifier, *fetchQualifier;
|
||||
GCSFolder *ocsFolder;
|
||||
EOFetchSpecification *fs;
|
||||
NSArray *keys;
|
||||
|
||||
if (!fields)
|
||||
fields = [[NSArray alloc]
|
||||
initWithObjects: @"c_name", @"c_version", nil];
|
||||
|
||||
componentQualifier = [self componentQualifier];
|
||||
if (qualifier)
|
||||
{
|
||||
fetchQualifier = [[EOAndQualifier alloc]
|
||||
initWithQualifiers:
|
||||
componentQualifier,
|
||||
qualifier,
|
||||
nil];
|
||||
[fetchQualifier autorelease];
|
||||
}
|
||||
else
|
||||
fetchQualifier = componentQualifier;
|
||||
|
||||
ocsFolder = [sogoObject ocsFolder];
|
||||
fs = [EOFetchSpecification
|
||||
fetchSpecificationWithEntityName: [ocsFolder folderName]
|
||||
qualifier: fetchQualifier
|
||||
sortOrderings: sortOrderings];
|
||||
records = [ocsFolder fetchFields: fields fetchSpecification: fs];
|
||||
keys = [records objectsForKey: @"c_name"
|
||||
notFoundMarker: nil];
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
/* subclasses */
|
||||
|
||||
- (EOQualifier *) componentQualifier
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,32 @@
|
|||
/* MAPIStoreInboxContext.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 MAPISTOREINBOXCONTEXT_H
|
||||
#define MAPISTOREINBOXCONTEXT_H
|
||||
|
||||
#import "MAPIStoreMailBaseContext.h"
|
||||
|
||||
@interface MAPIStoreInboxContext : MAPIStoreMailBaseContext
|
||||
|
||||
@end
|
||||
|
||||
#endif /* MAPISTOREINBOXCONTEXT_H */
|
|
@ -0,0 +1,50 @@
|
|||
/* MAPIStoreInboxContext.m - this file is part of $PROJECT_NAME_HERE$
|
||||
*
|
||||
* Copyright (C) 2011 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 <Foundation/NSString.h>
|
||||
|
||||
#import "MAPIStoreMailFolder.h"
|
||||
#import "MAPIStoreMapping.h"
|
||||
|
||||
#import "MAPIStoreInboxContext.h"
|
||||
|
||||
@implementation MAPIStoreInboxContext
|
||||
|
||||
+ (NSString *) MAPIModuleName
|
||||
{
|
||||
return @"inbox";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@inbox/"
|
||||
withID: 0x160001];
|
||||
}
|
||||
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
baseFolder = [MAPIStoreInboxFolder baseFolderWithURL: newURL
|
||||
inContext: self];
|
||||
[baseFolder retain];
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,4 +1,4 @@
|
|||
/* MAPIStoreMailContext.h - this file is part of SOGo
|
||||
/* MAPIStoreMailBaseContext.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2010 Inverse inc.
|
||||
*
|
||||
|
@ -25,7 +25,7 @@
|
|||
|
||||
#import "MAPIStoreContext.h"
|
||||
|
||||
@interface MAPIStoreMailContext : MAPIStoreContext
|
||||
@interface MAPIStoreMailBaseContext : MAPIStoreContext
|
||||
|
||||
@end
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/* MAPIStoreMailBaseContext.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 3, 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 "MAPIStoreMailBaseContext.h"
|
||||
|
||||
@implementation MAPIStoreMailBaseContext
|
||||
|
||||
+ (NSString *) MAPIModuleName
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,159 +0,0 @@
|
|||
/* MAPIStoreMailContext.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 3, 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 <NGObjWeb/WOContext+SoObjects.h>
|
||||
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
|
||||
#import <NGImap4/NGImap4EnvelopeAddress.h>
|
||||
|
||||
#import <Mailer/SOGoMailAccount.h>
|
||||
#import <Mailer/SOGoMailFolder.h>
|
||||
#import <Mailer/SOGoMailObject.h>
|
||||
|
||||
#import <SOGo/NSArray+Utilities.h>
|
||||
|
||||
#import "MAPIApplication.h"
|
||||
#import "MAPIStoreAuthenticator.h"
|
||||
#import "MAPIStoreMailFolderTable.h"
|
||||
#import "MAPIStoreMailMessageTable.h"
|
||||
#import "MAPIStoreMapping.h"
|
||||
#import "MAPIStoreTypes.h"
|
||||
#import "NSString+MAPIStore.h"
|
||||
|
||||
#import "MAPIStoreMailContext.h"
|
||||
|
||||
#undef DEBUG
|
||||
#include <mapistore/mapistore.h>
|
||||
|
||||
@implementation MAPIStoreMailContext
|
||||
|
||||
+ (NSString *) MAPIModuleName
|
||||
{
|
||||
return @"inbox";
|
||||
}
|
||||
|
||||
+ (void) registerFixedMappings: (MAPIStoreMapping *) mapping
|
||||
{
|
||||
[mapping registerURL: @"sogo://openchange:openchange@inbox/"
|
||||
withID: 0x160001];
|
||||
}
|
||||
|
||||
- (void) setupModuleFolder
|
||||
{
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoMailAccounts *accountsFolder;
|
||||
SOGoMailAccount *accountFolder;
|
||||
SOGoFolder *currentContainer;
|
||||
|
||||
userFolder = [SOGoUserFolder objectWithName: [authenticator username]
|
||||
inContainer: MAPIApp];
|
||||
[parentFoldersBag addObject: userFolder];
|
||||
[woContext setClientObject: userFolder];
|
||||
|
||||
accountsFolder = [userFolder lookupName: @"Mail"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentFoldersBag addObject: accountsFolder];
|
||||
[woContext setClientObject: accountsFolder];
|
||||
|
||||
accountFolder = [accountsFolder lookupName: @"0"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentFoldersBag addObject: accountFolder];
|
||||
[woContext setClientObject: accountFolder];
|
||||
|
||||
moduleFolder = [accountFolder inboxFolderInContext: nil];
|
||||
[moduleFolder retain];
|
||||
currentContainer = [moduleFolder container];
|
||||
while (currentContainer != (SOGoFolder *) accountFolder)
|
||||
{
|
||||
[parentFoldersBag addObject: currentContainer];
|
||||
currentContainer = [currentContainer container];
|
||||
}
|
||||
|
||||
[self logWithFormat: @"moduleFolder: %@", moduleFolder];
|
||||
}
|
||||
|
||||
- (Class) messageTableClass
|
||||
{
|
||||
return [MAPIStoreMailMessageTable class];
|
||||
}
|
||||
|
||||
- (Class) folderTableClass
|
||||
{
|
||||
return [MAPIStoreMailFolderTable class];
|
||||
}
|
||||
|
||||
- (int) openMessage: (struct mapistore_message *) msg
|
||||
forKey: (NSString *) childKey
|
||||
inTable: (MAPIStoreTable *) table
|
||||
{
|
||||
SOGoMailObject *child;
|
||||
int rc;
|
||||
struct SRowSet *recipients;
|
||||
NSArray *to;
|
||||
NSInteger count, max;
|
||||
NGImap4EnvelopeAddress *currentAddress;
|
||||
NSString *name;
|
||||
|
||||
rc = [super openMessage: msg forKey: childKey inTable: table];
|
||||
|
||||
if (rc == MAPI_E_SUCCESS && table == messageTable)
|
||||
{
|
||||
child = [[table folder] lookupName: childKey inContext: nil acquire: NO];
|
||||
/* Retrieve recipients from the message */
|
||||
to = [child toEnvelopeAddresses];
|
||||
max = [to count];
|
||||
recipients = talloc_zero (memCtx, struct SRowSet);
|
||||
recipients->cRows = max;
|
||||
recipients->aRow = talloc_array (recipients, struct SRow, max);
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
recipients->aRow[count].ulAdrEntryPad = 0;
|
||||
recipients->aRow[count].cValues = 2;
|
||||
recipients->aRow[count].lpProps = talloc_array (recipients->aRow,
|
||||
struct SPropValue,
|
||||
2);
|
||||
|
||||
// TODO (0x01 = primary recipient)
|
||||
set_SPropValue_proptag (&(recipients->aRow[count].lpProps[0]),
|
||||
PR_RECIPIENT_TYPE,
|
||||
MAPILongValue (memCtx, 0x01));
|
||||
|
||||
currentAddress = [to objectAtIndex: count];
|
||||
// name = [currentAddress personalName];
|
||||
// if (![name length])
|
||||
name = [currentAddress baseEMail];
|
||||
if (!name)
|
||||
name = @"";
|
||||
set_SPropValue_proptag (&(recipients->aRow[count].lpProps[1]),
|
||||
PR_DISPLAY_NAME,
|
||||
[name asUnicodeInMemCtx: recipients->aRow[count].lpProps]);
|
||||
}
|
||||
msg->recipients = recipients;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,57 @@
|
|||
/* MAPIStoreMailFolder.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 MAPISTOREMAILFOLDER_H
|
||||
#define MAPISTOREMAILFOLDER_H
|
||||
|
||||
#import "MAPIStoreFolder.h"
|
||||
|
||||
@class WOContext;
|
||||
|
||||
@class SOGoMailAccount;
|
||||
@class SOGoMailFolder;
|
||||
|
||||
@interface MAPIStoreMailFolder : MAPIStoreFolder
|
||||
|
||||
/* subclasses */
|
||||
- (SOGoMailFolder *) specialFolderFromAccount: (SOGoMailAccount *) account
|
||||
inContext: (WOContext *) woContext;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@interface MAPIStoreInboxFolder : MAPIStoreMailFolder
|
||||
@end
|
||||
|
||||
@interface MAPIStoreSentItemsFolder : MAPIStoreMailFolder
|
||||
@end
|
||||
|
||||
@interface MAPIStoreDraftsFolder : MAPIStoreMailFolder
|
||||
@end
|
||||
|
||||
@interface MAPIStoreDeletedItemsFolder : MAPIStoreMailFolder
|
||||
@end
|
||||
|
||||
@interface MAPIStoreOutboxFolder : MAPIStoreMailFolder
|
||||
@end
|
||||
|
||||
#endif /* MAPISTOREMAILFOLDER_H */
|
|
@ -0,0 +1,306 @@
|
|||
/* MAPIStoreMailFolder.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 <Foundation/NSArray.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
#import <EOControl/EOQualifier.h>
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
#import <Mailer/SOGoDraftsFolder.h>
|
||||
#import <Mailer/SOGoMailAccount.h>
|
||||
#import <Mailer/SOGoMailAccounts.h>
|
||||
#import <Mailer/SOGoMailFolder.h>
|
||||
#import <Mailer/SOGoSentFolder.h>
|
||||
#import <Mailer/SOGoTrashFolder.h>
|
||||
#import <SOGo/NSArray+Utilities.h>
|
||||
|
||||
#import "MAPIApplication.h"
|
||||
#import "MAPIStoreContext.h"
|
||||
#import "MAPIStoreDraftsMessage.h"
|
||||
#import "MAPIStoreMailMessage.h"
|
||||
#import "MAPIStoreMailMessageTable.h"
|
||||
#import "MAPIStoreMailFolderTable.h"
|
||||
#import "MAPIStoreTypes.h"
|
||||
#import "NSString+MAPIStore.h"
|
||||
|
||||
#import "MAPIStoreMailFolder.h"
|
||||
|
||||
static Class MAPIStoreDraftsMessageK;
|
||||
static Class MAPIStoreMailMessageK;
|
||||
|
||||
@implementation MAPIStoreMailFolder
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
MAPIStoreMailMessageK = [MAPIStoreMailMessage class];
|
||||
}
|
||||
|
||||
- (id) initWithURL: (NSURL *) newURL
|
||||
inContext: (MAPIStoreContext *) newContext
|
||||
{
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoMailAccounts *accountsFolder;
|
||||
SOGoMailAccount *accountFolder;
|
||||
SOGoFolder *currentContainer;
|
||||
WOContext *woContext;
|
||||
|
||||
if ((self = [super initWithURL: newURL
|
||||
inContext: newContext]))
|
||||
{
|
||||
woContext = [newContext woContext];
|
||||
userFolder = [SOGoUserFolder objectWithName: [newURL user]
|
||||
inContainer: MAPIApp];
|
||||
[parentContainersBag addObject: userFolder];
|
||||
[woContext setClientObject: userFolder];
|
||||
|
||||
accountsFolder = [userFolder lookupName: @"Mail"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentContainersBag addObject: accountsFolder];
|
||||
[woContext setClientObject: accountsFolder];
|
||||
|
||||
accountFolder = [accountsFolder lookupName: @"0"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentContainersBag addObject: accountFolder];
|
||||
[woContext setClientObject: accountFolder];
|
||||
|
||||
sogoObject = [self specialFolderFromAccount: accountFolder
|
||||
inContext: woContext];
|
||||
[sogoObject retain];
|
||||
currentContainer = [sogoObject container];
|
||||
while (currentContainer != (SOGoFolder *) accountFolder)
|
||||
{
|
||||
[parentContainersBag addObject: currentContainer];
|
||||
currentContainer = [currentContainer container];
|
||||
}
|
||||
|
||||
[self logWithFormat: @"sogoObject: %@", sogoObject];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (SOGoMailFolder *) specialFolderFromAccount: (SOGoMailAccount *) accountFolder
|
||||
inContext: (WOContext *) woContext
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (MAPIStoreMessageTable *) messageTable
|
||||
{
|
||||
if (!messageTable)
|
||||
ASSIGN (messageTable,
|
||||
[MAPIStoreMailMessageTable tableForContainer: self]);
|
||||
|
||||
return messageTable;
|
||||
}
|
||||
|
||||
- (Class) messageClass
|
||||
{
|
||||
return MAPIStoreMailMessageK;
|
||||
}
|
||||
|
||||
- (NSString *) createFolder: (struct SRow *) aRow
|
||||
{
|
||||
return nil;
|
||||
// NSString *newFolderURL;
|
||||
// NSString *folderName, *nameInContainer;
|
||||
// SOGoFolder *parentFolder, *newFolder;
|
||||
// int i;
|
||||
|
||||
// newFolderURL = nil;
|
||||
|
||||
// folderName = nil;
|
||||
// for (i = 0; !folderName && i < aRow->cValues; i++)
|
||||
// {
|
||||
// if (aRow->lpProps[i].ulPropTag == PR_DISPLAY_NAME_UNICODE)
|
||||
// folderName = [NSString stringWithUTF8String: aRow->lpProps[i].value.lpszW];
|
||||
// else if (aRow->lpProps[i].ulPropTag == PR_DISPLAY_NAME)
|
||||
// folderName = [NSString stringWithUTF8String: aRow->lpProps[i].value.lpszA];
|
||||
// }
|
||||
|
||||
// if (folderName)
|
||||
// {
|
||||
// parentFolder = [self lookupObject: parentFolderURL];
|
||||
// if (parentFolder)
|
||||
// {
|
||||
// if ([parentFolder isKindOfClass: SOGoMailAccountK]
|
||||
// || [parentFolder isKindOfClass: SOGoMailFolderK])
|
||||
// {
|
||||
// nameInContainer = [NSString stringWithFormat: @"folder%@",
|
||||
// [folderName asCSSIdentifier]];
|
||||
// newFolder = [SOGoMailFolderK objectWithName: nameInContainer
|
||||
// inContainer: parentFolder];
|
||||
// if ([newFolder create])
|
||||
// newFolderURL = [NSString stringWithFormat: @"%@/%@",
|
||||
// parentFolderURL,
|
||||
// [nameInContainer stringByEscapingURL]];
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return newFolderURL;
|
||||
}
|
||||
|
||||
- (enum MAPISTATUS) getProperty: (void **) data
|
||||
withTag: (enum MAPITAGS) propTag
|
||||
{
|
||||
enum MAPISTATUS rc;
|
||||
EOQualifier *searchQualifier;
|
||||
uint32_t intValue;
|
||||
|
||||
rc = MAPI_E_SUCCESS;
|
||||
switch (propTag)
|
||||
{
|
||||
case PR_CONTENT_UNREAD:
|
||||
searchQualifier
|
||||
= [EOQualifier qualifierWithQualifierFormat: @"flags = %@", @"unseen"];
|
||||
intValue = [[sogoObject fetchUIDsMatchingQualifier: searchQualifier
|
||||
sortOrdering: nil] count];
|
||||
*data = MAPILongValue (memCtx, intValue);
|
||||
break;
|
||||
case PR_CONTAINER_CLASS_UNICODE:
|
||||
*data = [@"IPF.Note" asUnicodeInMemCtx: memCtx];
|
||||
break;
|
||||
default:
|
||||
rc = [super getProperty: data withTag: propTag];
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
- (NSArray *) childKeysMatchingQualifier: (EOQualifier *) qualifier
|
||||
andSortOrderings: (NSArray *) sortOrderings
|
||||
{
|
||||
NSArray *uidKeys;
|
||||
EOQualifier *fetchQualifier, *deletedQualifier;
|
||||
static EOQualifier *nonDeletedQualifier = nil;
|
||||
|
||||
if (!nonDeletedQualifier)
|
||||
{
|
||||
deletedQualifier
|
||||
= [[EOKeyValueQualifier alloc]
|
||||
initWithKey: @"FLAGS"
|
||||
operatorSelector: EOQualifierOperatorContains
|
||||
value: [NSArray arrayWithObject: @"Deleted"]];
|
||||
nonDeletedQualifier = [[EONotQualifier alloc]
|
||||
initWithQualifier: deletedQualifier];
|
||||
[deletedQualifier release];
|
||||
}
|
||||
|
||||
if (!sortOrderings)
|
||||
sortOrderings = [NSArray arrayWithObject: @"ARRIVAL"];
|
||||
|
||||
if (qualifier)
|
||||
{
|
||||
fetchQualifier = [[EOAndQualifier alloc]
|
||||
initWithQualifiers: nonDeletedQualifier, qualifier,
|
||||
nil];
|
||||
[fetchQualifier autorelease];
|
||||
}
|
||||
else
|
||||
fetchQualifier = nonDeletedQualifier;
|
||||
|
||||
uidKeys = [sogoObject fetchUIDsMatchingQualifier: fetchQualifier
|
||||
sortOrdering: sortOrderings];
|
||||
return [uidKeys stringsWithFormat: @"%@.eml"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MAPIStoreInboxFolder : MAPIStoreMailFolder
|
||||
|
||||
- (SOGoMailFolder *) specialFolderFromAccount: (SOGoMailAccount *) accountFolder
|
||||
inContext: (WOContext *) woContext
|
||||
{
|
||||
return [accountFolder inboxFolderInContext: woContext];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MAPIStoreSentItemsFolder : MAPIStoreMailFolder
|
||||
|
||||
- (SOGoMailFolder *) specialFolderFromAccount: (SOGoMailAccount *) accountFolder
|
||||
inContext: (WOContext *) woContext
|
||||
{
|
||||
return [accountFolder sentFolderInContext: woContext];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MAPIStoreDraftsFolder : MAPIStoreMailFolder
|
||||
|
||||
- (SOGoMailFolder *) specialFolderFromAccount: (SOGoMailAccount *) accountFolder
|
||||
inContext: (WOContext *) woContext
|
||||
{
|
||||
return [accountFolder draftsFolderInContext: woContext];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MAPIStoreDeletedItemsFolder : MAPIStoreMailFolder
|
||||
|
||||
- (SOGoMailFolder *) specialFolderFromAccount: (SOGoMailAccount *) accountFolder
|
||||
inContext: (WOContext *) woContext
|
||||
{
|
||||
return [accountFolder trashFolderInContext: woContext];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MAPIStoreOutboxFolder : MAPIStoreMailFolder
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
MAPIStoreDraftsMessageK = [MAPIStoreDraftsMessage class];
|
||||
}
|
||||
|
||||
- (SOGoMailFolder *) specialFolderFromAccount: (SOGoMailAccount *) accountFolder
|
||||
inContext: (WOContext *) woContext
|
||||
{
|
||||
return [accountFolder draftsFolderInContext: woContext];
|
||||
}
|
||||
|
||||
- (Class) messageClass
|
||||
{
|
||||
return MAPIStoreDraftsMessageK;
|
||||
}
|
||||
|
||||
- (MAPIStoreMessage *) createMessage
|
||||
{
|
||||
MAPIStoreDraftsMessage *newMessage;
|
||||
SOGoDraftObject *newDraft;
|
||||
|
||||
newDraft = [sogoObject newDraft];
|
||||
newMessage
|
||||
= [MAPIStoreDraftsMessage mapiStoreObjectWithSOGoObject: newDraft
|
||||
inContainer: self];
|
||||
|
||||
|
||||
return newMessage;
|
||||
}
|
||||
|
||||
@end
|
|
@ -22,10 +22,10 @@
|
|||
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import "MAPIStoreNotesFolder.h"
|
||||
#import "MAPIStoreMapping.h"
|
||||
|
||||
#import "MAPIStoreNotesContext.h"
|
||||
#import "MAPIStoreNotesMessageTable.h"
|
||||
|
||||
@implementation MAPIStoreNotesContext
|
||||
|
||||
|
@ -40,9 +40,11 @@
|
|||
withID: 0x1c0001];
|
||||
}
|
||||
|
||||
- (Class) messageTableClass
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
return [MAPIStoreNotesMessageTable class];
|
||||
baseFolder = [MAPIStoreNotesFolder baseFolderWithURL: newURL
|
||||
inContext: self];
|
||||
[baseFolder retain];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/* MAPIStoreNotesFolder.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 MAPISTORENOTESFOLDER_H
|
||||
#define MAPISTORENOTESFOLDER_H
|
||||
|
||||
#import "MAPIStoreFSFolder.h"
|
||||
|
||||
@interface MAPIStoreNotesFolder : MAPIStoreFSFolder
|
||||
@end
|
||||
|
||||
#endif /* MAPISTORENOTESFOLDER_H */
|
|
@ -0,0 +1,43 @@
|
|||
/* MAPIStoreNotesFolder.m - this file is part of $PROJECT_NAME_HERE$
|
||||
*
|
||||
* Copyright (C) 2011 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 "MAPIStoreNotesFolder.h"
|
||||
|
||||
#import "MAPIStoreNotesMessage.h"
|
||||
|
||||
#import "MAPIStoreNotesFolder.h"
|
||||
|
||||
static Class MAPIStoreNotesMessageK;
|
||||
|
||||
@implementation MAPIStoreNotesFolder
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
MAPIStoreNotesMessageK = [MAPIStoreNotesMessage class];
|
||||
}
|
||||
|
||||
- (Class) messageClass
|
||||
{
|
||||
return MAPIStoreNotesMessageK;
|
||||
}
|
||||
|
||||
@end
|
|
@ -23,9 +23,9 @@
|
|||
#ifndef MAPISTOREOUTBOXCONTEXT_H
|
||||
#define MAPISTOREOUTBOXCONTEXT_H
|
||||
|
||||
#import "MAPIStoreMailContext.h"
|
||||
#import "MAPIStoreMailBaseContext.h"
|
||||
|
||||
@interface MAPIStoreOutboxContext : MAPIStoreMailContext
|
||||
@interface MAPIStoreOutboxContext : MAPIStoreMailBaseContext
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -22,14 +22,7 @@
|
|||
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
|
||||
#import <Mailer/SOGoDraftsFolder.h>
|
||||
#import <Mailer/SOGoMailAccount.h>
|
||||
#import <Mailer/SOGoMailFolder.h>
|
||||
|
||||
#import "MAPIApplication.h"
|
||||
#import "MAPIStoreAuthenticator.h"
|
||||
#import "MAPIStoreMailFolder.h"
|
||||
#import "MAPIStoreMapping.h"
|
||||
|
||||
#import "MAPIStoreOutboxContext.h"
|
||||
|
@ -47,44 +40,53 @@
|
|||
withID: 0x150001];
|
||||
}
|
||||
|
||||
- (void) setupModuleFolder
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoMailAccounts *accountsFolder;
|
||||
SOGoMailAccount *accountFolder;
|
||||
id currentContainer;
|
||||
|
||||
userFolder = [SOGoUserFolder objectWithName: [authenticator username]
|
||||
inContainer: MAPIApp];
|
||||
[parentFoldersBag addObject: userFolder];
|
||||
[woContext setClientObject: userFolder];
|
||||
|
||||
accountsFolder = [userFolder lookupName: @"Mail"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentFoldersBag addObject: accountsFolder];
|
||||
[woContext setClientObject: accountsFolder];
|
||||
|
||||
accountFolder = [accountsFolder lookupName: @"0"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentFoldersBag addObject: accountFolder];
|
||||
[woContext setClientObject: accountFolder];
|
||||
|
||||
moduleFolder = [accountFolder draftsFolderInContext: nil];
|
||||
[moduleFolder retain];
|
||||
currentContainer = [moduleFolder container];
|
||||
while (currentContainer != accountFolder)
|
||||
{
|
||||
[parentFoldersBag addObject: currentContainer];
|
||||
currentContainer = [currentContainer container];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) createMessageOfClass: (NSString *) messageClass
|
||||
inFolderAtURL: (NSString *) folderURL;
|
||||
{
|
||||
return [moduleFolder newDraft];
|
||||
baseFolder = [MAPIStoreOutboxFolder baseFolderWithURL: newURL
|
||||
inContext: self];
|
||||
[baseFolder retain];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// - (void) setupModuleFolder
|
||||
// {
|
||||
// SOGoUserFolder *userFolder;
|
||||
// SOGoMailAccounts *accountsFolder;
|
||||
// SOGoMailAccount *accountFolder;
|
||||
// id currentContainer;
|
||||
|
||||
// userFolder = [SOGoUserFolder objectWithName: [authenticator username]
|
||||
// inContainer: MAPIApp];
|
||||
// [parentFoldersBag addObject: userFolder];
|
||||
// [woContext setClientObject: userFolder];
|
||||
|
||||
// accountsFolder = [userFolder lookupName: @"Mail"
|
||||
// inContext: woContext
|
||||
// acquire: NO];
|
||||
// [parentFoldersBag addObject: accountsFolder];
|
||||
// [woContext setClientObject: accountsFolder];
|
||||
|
||||
// accountFolder = [accountsFolder lookupName: @"0"
|
||||
// inContext: woContext
|
||||
// acquire: NO];
|
||||
// [parentFoldersBag addObject: accountFolder];
|
||||
// [woContext setClientObject: accountFolder];
|
||||
|
||||
// moduleFolder = [accountFolder draftsFolderInContext: nil];
|
||||
// [moduleFolder retain];
|
||||
// currentContainer = [moduleFolder container];
|
||||
// while (currentContainer != accountFolder)
|
||||
// {
|
||||
// [parentFoldersBag addObject: currentContainer];
|
||||
// currentContainer = [currentContainer container];
|
||||
// }
|
||||
// }
|
||||
|
||||
// - (id) createMessageOfClass: (NSString *) messageClass
|
||||
// inFolderAtURL: (NSString *) folderURL;
|
||||
// {
|
||||
// return [moduleFolder newDraft];
|
||||
// }
|
||||
|
||||
// @end
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
#ifndef MAPISTORESEARCHCONTEXT_H
|
||||
#define MAPISTORESEARCHCONTEXT_H
|
||||
|
||||
#import "MAPIStoreMailContext.h"
|
||||
#import "MAPIStoreMailBaseContext.h"
|
||||
|
||||
@interface MAPIStoreSentItemsContext : MAPIStoreMailContext
|
||||
@interface MAPIStoreSentItemsContext : MAPIStoreMailBaseContext
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -22,15 +22,7 @@
|
|||
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
|
||||
#import <Mailer/SOGoMailAccount.h>
|
||||
|
||||
#import "MAPIApplication.h"
|
||||
#import "MAPIStoreAuthenticator.h"
|
||||
|
||||
#import "MAPIStoreMailFolder.h"
|
||||
#import "MAPIStoreMapping.h"
|
||||
|
||||
#import "MAPIStoreSentItemsContext.h"
|
||||
|
@ -48,40 +40,11 @@
|
|||
withID: 0x140001];
|
||||
}
|
||||
|
||||
- (void) setupModuleFolder
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoMailAccounts *accountsFolder;
|
||||
SOGoMailAccount *accountFolder;
|
||||
SOGoFolder *currentContainer;
|
||||
|
||||
userFolder = [SOGoUserFolder objectWithName: [authenticator username]
|
||||
inContainer: MAPIApp];
|
||||
[parentFoldersBag addObject: userFolder];
|
||||
// [self logWithFormat: @"userFolder: %@", userFolder];
|
||||
[woContext setClientObject: userFolder];
|
||||
|
||||
accountsFolder = [userFolder lookupName: @"Mail"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentFoldersBag addObject: accountsFolder];
|
||||
// [self logWithFormat: @"accountsFolder: %@", accountsFolder];
|
||||
[woContext setClientObject: accountsFolder];
|
||||
|
||||
accountFolder = [accountsFolder lookupName: @"0"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentFoldersBag addObject: accountFolder];
|
||||
[woContext setClientObject: accountFolder];
|
||||
|
||||
moduleFolder = [accountFolder sentFolderInContext: nil];
|
||||
[moduleFolder retain];
|
||||
currentContainer = [moduleFolder container];
|
||||
while (currentContainer != (SOGoFolder *) accountFolder)
|
||||
{
|
||||
[parentFoldersBag addObject: currentContainer];
|
||||
currentContainer = [currentContainer container];
|
||||
}
|
||||
baseFolder = [MAPIStoreSentItemsFolder baseFolderWithURL: newURL
|
||||
inContext: self];
|
||||
[baseFolder retain];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -20,33 +20,13 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
|
||||
#import <EOControl/EOQualifier.h>
|
||||
|
||||
#import <NGCards/iCalToDo.h>
|
||||
#import <Appointments/SOGoAppointmentFolder.h>
|
||||
#import <Appointments/SOGoAppointmentFolders.h>
|
||||
#import <Appointments/SOGoTaskObject.h>
|
||||
|
||||
#import "MAPIApplication.h"
|
||||
#import "MAPIStoreAuthenticator.h"
|
||||
#import "MAPIStoreTasksFolder.h"
|
||||
#import "MAPIStoreMapping.h"
|
||||
#import "MAPIStoreTasksMessageTable.h"
|
||||
#import "MAPIStoreTypes.h"
|
||||
#import "NSCalendarDate+MAPIStore.h"
|
||||
#import "NSString+MAPIStore.h"
|
||||
#import "SOGoGCSFolder+MAPIStore.h"
|
||||
|
||||
#import "MAPIStoreTasksContext.h"
|
||||
|
||||
#undef DEBUG
|
||||
#include <gen_ndr/exchange.h>
|
||||
#include <mapistore/mapistore.h>
|
||||
#include <mapistore/mapistore_nameid.h>
|
||||
|
||||
@implementation MAPIStoreTasksContext
|
||||
|
||||
+ (NSString *) MAPIModuleName
|
||||
|
@ -60,48 +40,11 @@
|
|||
withID: 0x1d0001];
|
||||
}
|
||||
|
||||
- (void) setupModuleFolder
|
||||
- (void) setupBaseFolder: (NSURL *) newURL
|
||||
{
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoAppointmentFolders *parentFolder;
|
||||
|
||||
userFolder = [SOGoUserFolder objectWithName: [authenticator username]
|
||||
inContainer: MAPIApp];
|
||||
[parentFoldersBag addObject: userFolder];
|
||||
[woContext setClientObject: userFolder];
|
||||
|
||||
parentFolder = [userFolder lookupName: @"Calendar"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentFoldersBag addObject: parentFolder];
|
||||
[woContext setClientObject: parentFolder];
|
||||
|
||||
moduleFolder = [parentFolder lookupName: @"personal"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[moduleFolder retain];
|
||||
}
|
||||
|
||||
- (Class) messageTableClass
|
||||
{
|
||||
return [MAPIStoreTasksMessageTable class];
|
||||
}
|
||||
|
||||
- (id) createMessageOfClass: (NSString *) messageClass
|
||||
inFolderAtURL: (NSString *) folderURL;
|
||||
{
|
||||
SOGoAppointmentFolder *parentFolder;
|
||||
SOGoTaskObject *newEntry;
|
||||
NSString *name;
|
||||
|
||||
parentFolder = [self lookupObject: folderURL];
|
||||
name = [NSString stringWithFormat: @"%@.ics",
|
||||
[SOGoObject globallyUniqueObjectId]];
|
||||
newEntry = [SOGoTaskObject objectWithName: name
|
||||
inContainer: parentFolder];
|
||||
[newEntry setIsNew: YES];
|
||||
|
||||
return newEntry;
|
||||
baseFolder = [MAPIStoreTasksFolder baseFolderWithURL: newURL
|
||||
inContext: self];
|
||||
[baseFolder retain];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/* MAPIStoreTasksFolder.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 MAPISTORETASKSFOLDER_H
|
||||
#define MAPISTORETASKSFOLDER_H
|
||||
|
||||
#import "MAPIStoreGCSFolder.h"
|
||||
|
||||
@interface MAPIStoreTasksFolder : MAPIStoreGCSFolder
|
||||
|
||||
@end
|
||||
|
||||
#endif /* MAPISTORETASKSFOLDER_H */
|
|
@ -0,0 +1,125 @@
|
|||
/* MAPIStoreTasksFolder.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2011 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 <Foundation/NSArray.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
#import <EOControl/EOQualifier.h>
|
||||
#import <Appointments/SOGoAppointmentFolder.h>
|
||||
#import <Appointments/SOGoAppointmentFolders.h>
|
||||
#import <Appointments/SOGoTaskObject.h>
|
||||
|
||||
#import "MAPIApplication.h"
|
||||
#import "MAPIStoreTasksContext.h"
|
||||
#import "MAPIStoreTasksMessage.h"
|
||||
#import "MAPIStoreTasksMessageTable.h"
|
||||
|
||||
#import "MAPIStoreTasksFolder.h"
|
||||
|
||||
static Class MAPIStoreTasksMessageK;
|
||||
|
||||
@implementation MAPIStoreTasksFolder
|
||||
|
||||
+ (void) initialize
|
||||
{
|
||||
MAPIStoreTasksMessageK = [MAPIStoreTasksMessage class];
|
||||
}
|
||||
|
||||
- (id) initWithURL: (NSURL *) newURL
|
||||
inContext: (MAPIStoreContext *) newContext
|
||||
{
|
||||
SOGoUserFolder *userFolder;
|
||||
SOGoAppointmentFolders *parentFolder;
|
||||
WOContext *woContext;
|
||||
|
||||
if ((self = [super initWithURL: newURL
|
||||
inContext: newContext]))
|
||||
{
|
||||
woContext = [newContext woContext];
|
||||
userFolder = [SOGoUserFolder objectWithName: [newURL user]
|
||||
inContainer: MAPIApp];
|
||||
[parentContainersBag addObject: userFolder];
|
||||
[woContext setClientObject: userFolder];
|
||||
|
||||
parentFolder = [userFolder lookupName: @"Calendar"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[parentContainersBag addObject: parentFolder];
|
||||
[woContext setClientObject: parentFolder];
|
||||
|
||||
sogoObject = [parentFolder lookupName: @"personal"
|
||||
inContext: woContext
|
||||
acquire: NO];
|
||||
[sogoObject retain];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (Class) messageClass
|
||||
{
|
||||
return MAPIStoreTasksMessageK;
|
||||
}
|
||||
|
||||
- (MAPIStoreMessageTable *) messageTable
|
||||
{
|
||||
if (!messageTable)
|
||||
ASSIGN (messageTable,
|
||||
[MAPIStoreTasksMessageTable tableForContainer: self]);
|
||||
|
||||
return messageTable;
|
||||
}
|
||||
|
||||
- (EOQualifier *) componentQualifier
|
||||
{
|
||||
static EOQualifier *componentQualifier = nil;
|
||||
|
||||
/* TODO: we need to support vlist as well */
|
||||
if (!componentQualifier)
|
||||
componentQualifier
|
||||
= [[EOKeyValueQualifier alloc] initWithKey: @"c_component"
|
||||
operatorSelector: EOQualifierOperatorEqual
|
||||
value: @"vtodo"];
|
||||
|
||||
return componentQualifier;
|
||||
}
|
||||
|
||||
- (MAPIStoreMessage *) createMessage
|
||||
{
|
||||
MAPIStoreMessage *newMessage;
|
||||
SOGoTaskObject *newEntry;
|
||||
NSString *name;
|
||||
|
||||
name = [NSString stringWithFormat: @"%@.ics",
|
||||
[SOGoObject globallyUniqueObjectId]];
|
||||
newEntry = [SOGoTaskObject objectWithName: name
|
||||
inContainer: sogoObject];
|
||||
[newEntry setIsNew: YES];
|
||||
newMessage = [MAPIStoreTasksMessage mapiStoreObjectWithSOGoObject: newEntry
|
||||
inContainer: self];
|
||||
|
||||
|
||||
return newMessage;
|
||||
}
|
||||
|
||||
@end
|
Loading…
Reference in New Issue