diff --git a/ChangeLog b/ChangeLog index 02f18e068..9fe041d04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2010-10-01 Wolfgang Sourdeau + * OpenChange/MAPIStoreTasksContext.[hm]: new mapi context class + for tasks. + * OpenChange/SOGoGCSFolder+MAPIStore.m (-componentKeysWithType:): new method that return the keys of components corresponding to the type passed as parameter. diff --git a/OpenChange/GNUmakefile b/OpenChange/GNUmakefile index d59135ca5..0884887a7 100644 --- a/OpenChange/GNUmakefile +++ b/OpenChange/GNUmakefile @@ -24,6 +24,7 @@ $(MAPISTORESOGO)_OBJC_FILES += \ MAPIStoreCalendarContext.m \ MAPIStoreContactsContext.m \ MAPIStoreMailContext.m \ + MAPIStoreTasksContext.m \ \ SOGoGCSFolder+MAPIStore.m \ \ diff --git a/OpenChange/MAPIStoreContext.m b/OpenChange/MAPIStoreContext.m index 5564c0e2d..29ffdcc9b 100644 --- a/OpenChange/MAPIStoreContext.m +++ b/OpenChange/MAPIStoreContext.m @@ -116,6 +116,8 @@ static MAPIStoreMapping *mapping = nil; contextClass = @"MAPIStoreContactsContext"; else if ([module isEqualToString: @"calendar"]) contextClass = @"MAPIStoreCalendarContext"; + else if ([module isEqualToString: @"tasks"]) + contextClass = @"MAPIStoreTasksContext"; else { NSLog (@"ERROR: unrecognized module name '%@'", module); diff --git a/OpenChange/MAPIStoreMapping.m b/OpenChange/MAPIStoreMapping.m index 8d652cff9..873691715 100644 --- a/OpenChange/MAPIStoreMapping.m +++ b/OpenChange/MAPIStoreMapping.m @@ -132,6 +132,13 @@ static uint64_t idCounter = 0x200001; [self errorWithFormat: @"Unable to register root folder: %@", urlString]; } + else if ([urlString isEqualToString: @"sogo://openchange:openchange@tasks/personal"]) + { + idNbr = 0x1d0001; + if (![self registerURL: urlString withID: idNbr]) + [self errorWithFormat: @"Unable to register root folder: %@", + urlString]; + } else { idCounter += idIncrement; diff --git a/OpenChange/MAPIStoreTasksContext.h b/OpenChange/MAPIStoreTasksContext.h new file mode 100644 index 000000000..1de37fa48 --- /dev/null +++ b/OpenChange/MAPIStoreTasksContext.h @@ -0,0 +1,32 @@ +/* MAPIStoreTasksContext.h - this file is part of SOGo + * + * Copyright (C) 2010 Inverse inc. + * + * Author: Wolfgang Sourdeau + * + * 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 MAPISTORETASKSCONTEXT_H +#define MAPISTORETASKSCONTEXT_H + +#import "MAPIStoreContext.h" + +@interface MAPIStoreTasksContext : MAPIStoreContext + +@end + +#endif /* MAPISTORETASKSCONTEXT_H */ diff --git a/OpenChange/MAPIStoreTasksContext.m b/OpenChange/MAPIStoreTasksContext.m new file mode 100644 index 000000000..72d7d2600 --- /dev/null +++ b/OpenChange/MAPIStoreTasksContext.m @@ -0,0 +1,108 @@ +/* MAPIStoreTasksContext.m - this file is part of SOGo + * + * Copyright (C) 2010 Inverse inc. + * + * Author: Wolfgang Sourdeau + * + * 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 + +#import +#import + +#import "MAPIApplication.h" +#import "MAPIStoreAuthenticator.h" +#import "NSCalendarDate+MAPIStore.h" +#import "NSString+MAPIStore.h" +#import "SOGoGCSFolder+MAPIStore.h" + +#import "MAPIStoreTasksContext.h" + +#undef DEBUG +#include + +static Class SOGoUserFolderK; + +@implementation MAPIStoreTasksContext + ++ (void) initialize +{ + SOGoUserFolderK = [SOGoUserFolder class]; +} + +- (void) setupModuleFolder +{ + id userFolder; + + userFolder = [SOGoUserFolderK objectWithName: [authenticator username] + inContainer: MAPIApp]; + [woContext setClientObject: userFolder]; + [userFolder retain]; // LEAK + + moduleFolder = [userFolder lookupName: @"Calendar" + inContext: woContext + acquire: NO]; + [moduleFolder retain]; +} + +- (NSArray *) getFolderMessageKeys: (SOGoFolder *) folder +{ + return [(SOGoGCSFolder *) folder componentKeysWithType: @"vtodo"]; +} + +- (int) getMessageTableChildproperty: (void **) data + atURL: (NSString *) childURL + withTag: (uint32_t) proptag + inFolder: (SOGoFolder *) folder + withFID: (uint64_t) fid +{ + uint32_t *longValue; + // uint8_t *boolValue; + // id child; + // id task; + int rc; + + rc = MAPI_E_SUCCESS; + switch (proptag) + { + case PR_ICON_INDEX: // TODO + longValue = talloc_zero(memCtx, uint32_t); + *longValue = 0x00000500; /* see http://msdn.microsoft.com/en-us/library/cc815472.aspx */ + // Unassigned recurring task 0x00000501 + // Assignee's task 0x00000502 + // Assigner's task 0x00000503 + // Task request 0x00000504 + // Task acceptance 0x00000505 + // Task rejection 0x00000506 + *data = longValue; + break; + case PR_MESSAGE_CLASS_UNICODE: + *data = talloc_strdup(memCtx, "IPM.Task"); + break; + default: + rc = [super getMessageTableChildproperty: data + atURL: childURL + withTag: proptag + inFolder: folder + withFID: fid]; + } + + return rc; +} + +@end