mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-04 12:58:50 +00:00
Monotone-Parent: af2ea31f45eb560c291dfec4c44ae6e1ad120ccb
Monotone-Revision: d54b0a4d8b7cb99ddb2be62efc4a25eece49e483 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-02-24T20:34:10 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
2011-02-24 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* OpenChange/MAPIStoreAttachment.m: new super class, derived from
|
||||
MAPIStoreObject and used for MAPI attachment objects.
|
||||
|
||||
* 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
|
||||
|
||||
38
OpenChange/MAPIStoreAttachment.h
Normal file
38
OpenChange/MAPIStoreAttachment.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* MAPIStoreAttachment.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 MAPISTOREATTACHMENT_H
|
||||
#define MAPISTOREATTACHMENT_H
|
||||
|
||||
#import "MAPIStoreObject.h"
|
||||
|
||||
@interface MAPIStoreAttachment : MAPIStoreObject
|
||||
{
|
||||
uint32_t aid;
|
||||
}
|
||||
|
||||
- (void) setAID: (uint32_t) newAID;
|
||||
- (uint32_t) AID;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* MAPISTOREATTACHMENT_H */
|
||||
47
OpenChange/MAPIStoreAttachment.m
Normal file
47
OpenChange/MAPIStoreAttachment.m
Normal file
@@ -0,0 +1,47 @@
|
||||
/* MAPIStoreAttachment.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 "MAPIStoreAttachment.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <gen_ndr/exchange.h>
|
||||
#include <mapistore/mapistore_errors.h>
|
||||
|
||||
@implementation MAPIStoreAttachment
|
||||
|
||||
- (void) setAID: (uint32_t) newAID
|
||||
{
|
||||
aid = newAID;
|
||||
}
|
||||
|
||||
- (uint32_t) AID
|
||||
{
|
||||
return aid;
|
||||
}
|
||||
|
||||
- (int) getProperty: (void **) data
|
||||
withTag: (enum MAPITAGS) propTag
|
||||
{
|
||||
return MAPISTORE_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
@end
|
||||
31
OpenChange/MAPIStoreDraftsAttachment.h
Normal file
31
OpenChange/MAPIStoreDraftsAttachment.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/* MAPIStoreDraftsAttachment.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 MAPISTOREDRAFTSATTACHMENT_H
|
||||
#define MAPISTOREDRAFTSATTACHMENT_H
|
||||
|
||||
#import "MAPIStoreAttachment.h"
|
||||
|
||||
@interface MAPIStoreDraftsAttachment : MAPIStoreAttachment
|
||||
@end
|
||||
|
||||
#endif /* MAPISTOREDRAFTSATTACHMENT_H */
|
||||
27
OpenChange/MAPIStoreDraftsAttachment.m
Normal file
27
OpenChange/MAPIStoreDraftsAttachment.m
Normal file
@@ -0,0 +1,27 @@
|
||||
/* MAPIStoreDraftsAttachment.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 "MAPIStoreDraftsAttachment.h"
|
||||
|
||||
@implementation MAPIStoreDraftsAttachment
|
||||
|
||||
@end
|
||||
39
OpenChange/MAPIStoreMailAttachment.h
Normal file
39
OpenChange/MAPIStoreMailAttachment.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/* MAPIStoreMailAttachment.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 MAPISTOREMAILATTACHMENT_H
|
||||
#define MAPISTOREMAILATTACHMENT_H
|
||||
|
||||
#import "MAPIStoreAttachment.h"
|
||||
|
||||
@class NSDictionary;
|
||||
|
||||
@interface MAPIStoreMailAttachment : MAPIStoreAttachment
|
||||
{
|
||||
NSDictionary *bodyInfo;
|
||||
}
|
||||
|
||||
- (void) setBodyInfo: (NSDictionary *) newBodyInfo;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* MAPISTOREMAILATTACHMENT_H */
|
||||
177
OpenChange/MAPIStoreMailAttachment.m
Normal file
177
OpenChange/MAPIStoreMailAttachment.m
Normal file
@@ -0,0 +1,177 @@
|
||||
/* MAPIStoreMailAttachment.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/NSData.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
#import <SOGo/NSArray+Utilities.h>
|
||||
#import <Mailer/SOGoMailBodyPart.h>
|
||||
#import <Mailer/SOGoMailObject.h>
|
||||
|
||||
#import "MAPIStoreTypes.h"
|
||||
#import "MAPIStoreMailMessage.h"
|
||||
#import "NSCalendarDate+MAPIStore.h"
|
||||
#import "NSData+MAPIStore.h"
|
||||
#import "NSString+MAPIStore.h"
|
||||
|
||||
#import "MAPIStoreMailAttachment.h"
|
||||
|
||||
#undef DEBUG
|
||||
#include <stdbool.h>
|
||||
#include <gen_ndr/exchange.h>
|
||||
#include <mapistore/mapistore.h>
|
||||
#include <mapistore/mapistore_errors.h>
|
||||
|
||||
@implementation MAPIStoreMailAttachment
|
||||
|
||||
- (id) init
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
bodyInfo = nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[bodyInfo release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setBodyInfo: (NSDictionary *) newBodyInfo
|
||||
{
|
||||
ASSIGN (bodyInfo, newBodyInfo);
|
||||
}
|
||||
|
||||
- (int) getProperty: (void **) data
|
||||
withTag: (enum MAPITAGS) propTag
|
||||
{
|
||||
static char tagBytes[] = {0x2a, 0x86, 0x48, 0x86, 0xf7, 0x14, 0x03, 0x0a,
|
||||
0x04}; /* MIME */
|
||||
static char recordBytes[] = {0xd9, 0xd8, 0x11, 0xa3, 0xe2, 0x90, 0x18, 0x41,
|
||||
0x9e, 0x04, 0x58, 0x46, 0x9d, 0x6d, 0x1b, 0x68};
|
||||
uint32_t longValue;
|
||||
NSString *stringValue;
|
||||
NSCalendarDate *date;
|
||||
NSDictionary *parameters;
|
||||
int rc;
|
||||
|
||||
rc = MAPISTORE_SUCCESS;
|
||||
switch (propTag)
|
||||
{
|
||||
case PR_MID:
|
||||
*data = MAPILongLongValue (memCtx, [container objectId]);
|
||||
break;
|
||||
case PR_ATTACH_NUM:
|
||||
*data = MAPILongValue (memCtx, aid);
|
||||
break;
|
||||
case PR_ATTACH_METHOD:
|
||||
*data = MAPILongValue (memCtx, 1);
|
||||
break;
|
||||
case PR_ATTACH_TAG:
|
||||
*data = [[NSData dataWithBytes: tagBytes length: 9]
|
||||
asShortBinaryInMemCtx: memCtx];
|
||||
break;
|
||||
case PR_ATTACH_SIZE:
|
||||
longValue = [[bodyInfo objectForKey: @"size"] longValue];
|
||||
*data = MAPILongValue (memCtx, longValue);
|
||||
break;
|
||||
|
||||
case PR_RENDERING_POSITION:
|
||||
*data = MAPILongValue (memCtx, 0xffffffff);
|
||||
break;
|
||||
|
||||
case PR_RECORD_KEY:
|
||||
*data = [[NSData dataWithBytes: recordBytes length: 16]
|
||||
asShortBinaryInMemCtx: memCtx];
|
||||
break;
|
||||
|
||||
// PR_RECORD_KEY (0xFF90102) D9 D8 11 A3 E2 90 18 41 9E 04 58 46 9D 6D 1B 68
|
||||
|
||||
case PR_ATTACH_LONG_FILENAME_UNICODE:
|
||||
case PR_ATTACH_FILENAME_UNICODE:
|
||||
stringValue = [[bodyInfo objectForKey: @"parameterList"]
|
||||
objectForKey: @"name"];
|
||||
if (!stringValue)
|
||||
{
|
||||
parameters = [[bodyInfo objectForKey: @"disposition"]
|
||||
objectForKey: @"parameterList"];
|
||||
stringValue = [parameters objectForKey: @"filename"];
|
||||
}
|
||||
|
||||
if (propTag == PR_ATTACH_FILENAME_UNICODE)
|
||||
{
|
||||
NSString *baseName, *ext;
|
||||
|
||||
baseName = [stringValue stringByDeletingPathExtension];
|
||||
if ([baseName length] > 8)
|
||||
baseName = [baseName substringToIndex: 8];
|
||||
|
||||
ext = [stringValue pathExtension];
|
||||
if ([ext length] > 3)
|
||||
ext = [ext substringToIndex: 3];
|
||||
stringValue = [NSString stringWithFormat: @"%@.%@", baseName, ext];
|
||||
}
|
||||
|
||||
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
||||
break;
|
||||
|
||||
case PR_DISPLAY_NAME_UNICODE: /* TODO: check if description ? */
|
||||
stringValue = [bodyInfo objectForKey: @"description"];
|
||||
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
||||
break;
|
||||
|
||||
case PR_ATTACH_CONTENT_ID_UNICODE:
|
||||
stringValue = [bodyInfo objectForKey: @"bodyId"];
|
||||
*data = [stringValue asUnicodeInMemCtx: memCtx];
|
||||
break;
|
||||
|
||||
case PR_ATTACH_MIME_TAG_UNICODE:
|
||||
stringValue = [NSString stringWithFormat: @"%@/%@",
|
||||
[bodyInfo objectForKey: @"type"],
|
||||
[bodyInfo objectForKey: @"subtype"]];
|
||||
*data = [[stringValue lowercaseString] asUnicodeInMemCtx: memCtx];
|
||||
break;
|
||||
|
||||
case PR_CREATION_TIME:
|
||||
case PR_LAST_MODIFICATION_TIME:
|
||||
date = [[container sogoObject] date];
|
||||
*data = [date asFileTimeInMemCtx: memCtx];
|
||||
break;
|
||||
|
||||
case PR_ATTACH_DATA_BIN:
|
||||
*data = [[sogoObject fetchBLOB] asShortBinaryInMemCtx: memCtx];
|
||||
break;
|
||||
|
||||
default:
|
||||
rc = [super getProperty: data withTag: propTag];
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user