mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-25 21:35:23 +00:00
Monotone-Parent: da7301d3c0a55520b84d234529b84e3741006bf0
Monotone-Revision: f0d1b16bd7d62ae794114e9df5377a901fba1a74 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-11-19T20:56:11 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
2010-11-19 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* OpenChange/MAPIStoreTypes.m: new helper module designed to
|
||||
handle type conversion between MAPI types and NS types.
|
||||
|
||||
* OpenChange/NSDate+MAPIStore: renamed back to
|
||||
NSCalendarDate+MAPIStore.
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/* MAPIStoreTypes.h - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2010 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef MAPISTORETYPES_H
|
||||
#define MAPISTORETYPES_H
|
||||
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <gen_ndr/exchange.h>
|
||||
|
||||
@class NSDictionary;
|
||||
|
||||
uint8_t *MAPIBoolValue (void *memCtx, BOOL value);
|
||||
uint32_t *MAPILongValue (void *memCtx, uint32_t value);
|
||||
uint64_t *MAPILongLongValue (void *memCtx, uint64_t value);
|
||||
|
||||
id NSObjectFromSPropValue (const struct SPropValue *);
|
||||
|
||||
#if (GS_SIZEOF_LONG == 4)
|
||||
static inline NSNumber *
|
||||
MAPIPropertyNumber (unsigned long propTag)
|
||||
{
|
||||
return [NSNumber numberWithUnsignedLong: propTag];
|
||||
}
|
||||
#elif (GS_SIZEOF_INT == 4)
|
||||
static inline NSNumber *
|
||||
MAPIPropertyNumber (unsigned int propTag)
|
||||
{
|
||||
return [NSNumber numberWithUnsignedInt: propTag];
|
||||
}
|
||||
#else
|
||||
#error No suitable type for 4 bytes integers
|
||||
#endif
|
||||
|
||||
void MAPIStoreDumpMessageProperties (NSDictionary *properties);
|
||||
|
||||
#endif /* MAPISTORETYPES_H */
|
||||
@@ -0,0 +1,153 @@
|
||||
/* MAPIStoreTypes.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2010 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#undef DEBUG
|
||||
#include <talloc.h>
|
||||
#include <mapistore/mapistore.h>
|
||||
#include <mapistore/mapistore_errors.h>
|
||||
#include <libmapi/libmapi.h>
|
||||
#include <libmapiproxy.h>
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSNull.h>
|
||||
#import <Foundation/NSString.h>
|
||||
|
||||
#import "NSCalendarDate+MAPIStore.h"
|
||||
|
||||
#import "MAPIStoreTypes.h"
|
||||
|
||||
uint8_t *
|
||||
MAPIBoolValue (void *memCtx, BOOL value)
|
||||
{
|
||||
uint8_t *boolValue;
|
||||
|
||||
boolValue = talloc_zero (memCtx, uint8_t);
|
||||
*boolValue = value;
|
||||
|
||||
return boolValue;
|
||||
}
|
||||
|
||||
uint32_t *
|
||||
MAPILongValue (void *memCtx, uint32_t value)
|
||||
{
|
||||
uint32_t *longValue;
|
||||
|
||||
longValue = talloc_zero (memCtx, uint32_t);
|
||||
*longValue = value;
|
||||
|
||||
return longValue;
|
||||
}
|
||||
|
||||
uint64_t *
|
||||
MAPILongLongValue (void *memCtx, uint64_t value)
|
||||
{
|
||||
uint64_t *llongValue;
|
||||
|
||||
llongValue = talloc_zero (memCtx, uint64_t);
|
||||
*llongValue = value;
|
||||
|
||||
return llongValue;
|
||||
}
|
||||
|
||||
id
|
||||
NSObjectFromSPropValue (const struct SPropValue *value)
|
||||
{
|
||||
short int valueType;
|
||||
id result;
|
||||
|
||||
valueType = (value->ulPropTag & 0xffff);
|
||||
switch (valueType)
|
||||
{
|
||||
case PT_NULL:
|
||||
result = [NSNull null];
|
||||
break;
|
||||
case PT_SHORT:
|
||||
result = [NSNumber numberWithShort: value->value.i];
|
||||
break;
|
||||
case PT_LONG:
|
||||
result = [NSNumber numberWithLong: value->value.l];
|
||||
break;
|
||||
case PT_BOOLEAN:
|
||||
result = [NSNumber numberWithBool: value->value.b];
|
||||
break;
|
||||
case PT_DOUBLE:
|
||||
result = [NSNumber numberWithDouble: value->value.dbl];
|
||||
break;
|
||||
case PT_UNICODE:
|
||||
result = [NSString stringWithUTF8String: value->value.lpszW];
|
||||
break;
|
||||
case PT_STRING8:
|
||||
result = [NSString stringWithUTF8String: value->value.lpszA];
|
||||
break;
|
||||
case PT_SYSTIME:
|
||||
result = [NSCalendarDate dateFromFileTime: &(value->value.ft)];
|
||||
break;
|
||||
default:
|
||||
// #define PT_UNSPECIFIED 0x0
|
||||
// #define PT_I2 0x2
|
||||
// #define PT_CURRENCY 0x6
|
||||
// #define PT_APPTIME 0x7
|
||||
// #define PT_ERROR 0xa
|
||||
// #define PT_OBJECT 0xd
|
||||
// #define PT_I8 0x14
|
||||
// #define PT_CLSID 0x48
|
||||
// #define PT_SVREID 0xFB
|
||||
// #define PT_SRESTRICT 0xFD
|
||||
// #define PT_ACTIONS 0xFE
|
||||
// #define PT_BINARY 0x102
|
||||
result = [NSNull null];
|
||||
NSLog (@"object type not handled: %d", valueType);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
MAPIStoreDumpMessageProperties (NSDictionary *properties)
|
||||
{
|
||||
NSNumber *key;
|
||||
NSArray *allKeys;
|
||||
NSUInteger keyAsInt, count, max;
|
||||
const char *name;
|
||||
id value;
|
||||
|
||||
allKeys = [properties allKeys];
|
||||
max = [allKeys count];
|
||||
|
||||
NSLog (@"message properties (%d):", max);
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
key = [allKeys objectAtIndex: count];
|
||||
if ([key isKindOfClass: [NSNumber class]])
|
||||
{
|
||||
keyAsInt = [key intValue];
|
||||
value = [properties objectForKey: key];
|
||||
name = get_proptag_name (keyAsInt);
|
||||
if (!name)
|
||||
name = "unknown";
|
||||
NSLog (@" 0x%.8x (%s): %@ (%@)",
|
||||
keyAsInt, name,
|
||||
value, NSStringFromClass ([value class]));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user