diff --git a/ChangeLog b/ChangeLog index a5dfc0edd..7650d9006 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-03-12 Ludovic Marcotte + + * Updated the SOPE patchset in order to + fix a bug in NGMimeBodyParser. + 2009-03-11 Ludovic Marcotte * SoObjects/Appointments/SOGoAppointmentFolder.m diff --git a/SOPE/sope-patchset-r1630.diff b/SOPE/sope-patchset-r1630.diff index d952aec4b..2a193301f 100644 --- a/SOPE/sope-patchset-r1630.diff +++ b/SOPE/sope-patchset-r1630.diff @@ -1,3 +1,283 @@ +Index: sope-gdl1/PostgreSQL/PostgreSQL72Channel.m +=================================================================== +--- sope-gdl1/PostgreSQL/PostgreSQL72Channel.m (revision 1632) ++++ sope-gdl1/PostgreSQL/PostgreSQL72Channel.m (working copy) +@@ -713,6 +713,39 @@ + return ms; + } + ++/* GCSEOAdaptorChannel protocol */ ++static NSString *sqlFolderFormat = (@"CREATE TABLE %@ (\n" \ ++ @" c_name VARCHAR (256) NOT NULL PRIMARY KEY,\n" ++ @" c_content VARCHAR (100000) NOT NULL,\n" ++ @" c_creationdate INT4 NOT NULL,\n" ++ @" c_lastmodified INT4 NOT NULL,\n" ++ @" c_version INT4 NOT NULL,\n" ++ @" c_deleted INT4 NULL\n" ++ @")"); ++static NSString *sqlFolderACLFormat = (@"CREATE TABLE %@ (\n" \ ++ @" c_uid VARCHAR (256) NOT NULL,\n" ++ @" c_object VARCHAR (256) NOT NULL,\n" ++ @" c_role VARCHAR (80) NOT NULL\n" ++ @")"); ++ ++- (NSException *) createGCSFolderTableWithName: (NSString *) tableName ++{ ++ NSString *sql; ++ ++ sql = [NSString stringWithFormat: sqlFolderFormat, tableName]; ++ ++ return [self evaluateExpressionX: sql]; ++} ++ ++- (NSException *) createGCSFolderACLTableWithName: (NSString *) tableName ++{ ++ NSString *sql; ++ ++ sql = [NSString stringWithFormat: sqlFolderACLFormat, tableName]; ++ ++ return [self evaluateExpressionX: sql]; ++} ++ + @end /* PostgreSQL72Channel */ + + @implementation PostgreSQL72Channel(PrimaryKeyGeneration) +Index: sope-gdl1/Oracle8/OracleAdaptorChannel.m +=================================================================== +--- sope-gdl1/Oracle8/OracleAdaptorChannel.m (revision 1632) ++++ sope-gdl1/Oracle8/OracleAdaptorChannel.m (working copy) +@@ -1,7 +1,7 @@ + /* + ** OracleAdaptorChannel.m + ** +-** Copyright (c) 2007 Inverse groupe conseil inc. and Ludovic Marcotte ++** Copyright (c) 2007-2009 Inverse inc. and Ludovic Marcotte + ** + ** Author: Ludovic Marcotte + ** +@@ -30,6 +30,7 @@ + + #import + ++static BOOL debugOn = NO; + // + // + // +@@ -41,10 +42,11 @@ + + @implementation OracleAdaptorChannel (Private) + +-- (void) _cleanup ++- (void) _cleanup + { + column_info *info; + int c; ++ sword result; + + [_resultSetProperties removeAllObjects]; + +@@ -58,11 +60,29 @@ + // so we just free the value instead. + if (info->value) + { +- if (OCIDescriptorFree((dvoid *)info->value, (ub4)OCI_DTYPE_LOB) != OCI_SUCCESS) ++ if (info->type == SQLT_CLOB ++ || info->type == SQLT_BLOB ++ || info->type == SQLT_BFILEE ++ || info->type == SQLT_CFILEE) ++ { ++ result = OCIDescriptorFree((dvoid *)info->value, (ub4) OCI_DTYPE_LOB); ++ if (result != OCI_SUCCESS) ++ { ++ NSLog (@"value was not a LOB descriptor"); ++ abort(); ++ } ++ } ++ else + free(info->value); + info->value = NULL; + } +- free(info); ++ else ++ { ++ NSLog (@"trying to free an already freed value!"); ++ abort(); ++ } ++ free(info); ++ + [_row_buffer removeObjectAtIndex: c]; + } + +@@ -78,8 +98,7 @@ + // + @implementation OracleAdaptorChannel + +-static void +-DBTerminate() ++static void DBTerminate() + { + if (OCITerminate(OCI_DEFAULT)) + NSLog(@"FAILED: OCITerminate()"); +@@ -89,6 +108,11 @@ + + + (void) initialize + { ++ NSUserDefaults *ud; ++ ++ ud = [NSUserDefaults standardUserDefaults]; ++ debugOn = [ud boolForKey: @"OracleAdaptorDebug"]; ++ + // We Initialize the OCI process environment. + if (OCIInitialize((ub4)OCI_DEFAULT, (dvoid *)0, + (dvoid * (*)(dvoid *, size_t)) 0, +@@ -156,14 +180,17 @@ + [super closeChannel]; + + // We logoff from the database. +- if (OCILogoff(_oci_ctx, _oci_err)) ++ if (!_oci_ctx || !_oci_err || OCILogoff(_oci_ctx, _oci_err)) + { + NSLog(@"FAILED: OCILogoff()"); + } + ++ if (_oci_ctx) ++ OCIHandleFree(_oci_ctx, OCI_HTYPE_SVCCTX); + +- OCIHandleFree(_oci_ctx, OCI_HTYPE_SVCCTX); +- OCIHandleFree(_oci_err, OCI_HTYPE_ERROR); ++ if (_oci_err) ++ OCIHandleFree(_oci_err, OCI_HTYPE_ERROR); ++ + // OCIHandleFree(_oci_env, OCI_HTYPE_ENV); + + _oci_ctx = (OCISvcCtx *)0; +@@ -177,7 +204,8 @@ + // + - (void) dealloc + { +- //NSLog(@"OracleAdaptorChannel: -dealloc"); ++ if (debugOn) ++ NSLog(@"OracleAdaptorChannel: -dealloc"); + + [self _cleanup]; + +@@ -231,6 +259,9 @@ + + [self _cleanup]; + ++ if (debugOn) ++ [self logWithFormat: @"expression: %@", theExpression]; ++ + if (!theExpression || ![theExpression length]) + { + [NSException raise: @"OracleInvalidExpressionException" +@@ -302,7 +333,9 @@ + // We read the maximum width of a column + info->max_width = 0; + status = OCIAttrGet((dvoid*)param, (ub4)OCI_DTYPE_PARAM, (dvoid*)&(info->max_width), (ub4 *)0, (ub4)OCI_ATTR_DATA_SIZE, (OCIError *)_oci_err); +- ++ ++ if (debugOn) ++ NSLog(@"name: %s, type: %d", cname, info->type); + attribute = [EOAttribute attributeWithOracleType: info->type name: cname length: clen width: info->max_width]; + [_resultSetProperties addObject: attribute]; + +@@ -394,16 +427,17 @@ + return NO; + } + +- + if (OCIEnvInit((OCIEnv **)&_oci_env, (ub4)OCI_DEFAULT, (size_t)0, (dvoid **)0)) + { + NSLog(@"FAILED: OCIEnvInit()"); ++ [self closeChannel]; + return NO; + } + + if (OCIHandleAlloc((dvoid *)_oci_env, (dvoid *)&_oci_err, (ub4)OCI_HTYPE_ERROR, (size_t)0, (dvoid **)0)) + { + NSLog(@"FAILED: OCIHandleAlloc() on errhp"); ++ [self closeChannel]; + return NO; + } + +@@ -422,6 +456,7 @@ + { + NSLog(@"FAILED: OCILogon(). username = %s password = %s" + @" database = %s", username, password, database); ++ [self closeChannel]; + return NO; + } + +@@ -438,6 +473,11 @@ + { + sword status; + ++ // We check if our connection is open prior to trying to fetch any data. OCIStmtFetch2() returns ++ // NO error code if the OCI environment is set up but the OCILogon() has failed. ++ if (![self isOpen]) ++ return nil; ++ + status = OCIStmtFetch2(_current_stm, _oci_err, (ub4)1, (ub4)OCI_FETCH_NEXT, (sb4)0, (ub4)OCI_DEFAULT); + + if (status == OCI_NO_DATA) +@@ -609,7 +649,7 @@ + + /* GCSEOAdaptorChannel protocol */ + static NSString *sqlFolderFormat = (@"CREATE TABLE %@ (\n" \ +- @" c_name VARCHAR2 (256) NOT NULL,\n" ++ @" c_name VARCHAR2 (256) NOT NULL PRIMARY KEY,\n" + @" c_content CLOB NOT NULL,\n" + @" c_creationdate INTEGER NOT NULL,\n" + @" c_lastmodified INTEGER NOT NULL,\n" +Index: sope-gdl1/Oracle8/OracleAdaptorChannelController.m +=================================================================== +--- sope-gdl1/Oracle8/OracleAdaptorChannelController.m (revision 1632) ++++ sope-gdl1/Oracle8/OracleAdaptorChannelController.m (working copy) +@@ -31,6 +31,8 @@ + #import + #import + ++static BOOL debugOn = NO; ++ + // + // + // +@@ -48,6 +50,14 @@ + // + @implementation OracleAdaptorChannelController + +++ (void) initialize ++{ ++ NSUserDefaults *ud; ++ ++ ud = [NSUserDefaults standardUserDefaults]; ++ debugOn = [ud boolForKey: @"OracleAdaptorDebug"]; ++} ++ + - (EODelegateResponse) adaptorChannel: (id) theChannel + willInsertRow: (NSMutableDictionary *) theRow + forEntity: (EOEntity *) theEntity +@@ -56,7 +66,8 @@ + NSArray *keys; + int i, c; + +- NSLog(@"willInsertRow: %@ %@", [theRow description], [theEntity description]); ++ if (debugOn) ++ NSLog(@"willInsertRow: %@ %@", [theRow description], [theEntity description]); + + s = AUTORELEASE([[NSMutableString alloc] init]); + +@@ -101,7 +112,8 @@ + NSArray *keys; + int i, c; + +- NSLog(@"willUpdatetRow: %@ %@", [theRow description], [theQualifier description]); ++ if (debugOn) ++ NSLog(@"willUpdateRow: %@ %@", [theRow description], [theQualifier description]); + + s = AUTORELEASE([[NSMutableString alloc] init]); + Index: sope-mime/NGImap4/NGImap4Client.h =================================================================== --- sope-mime/NGImap4/NGImap4Client.h (revision 1632) @@ -2810,6 +3090,29 @@ Index: sope-mime/NGMime/NGMimeBodyParser.m if (![ctype isKindOfClass:[NGMimeType class]]) ctype = [NGMimeType mimeType:[ctype stringValue]]; +@@ -88,10 +91,20 @@ + NSStringEncoding encoding; + + encoding = [NGMimeType stringEncodingForCharset:charset]; +- ++ ++ // If we nave no encoding here, let's not simply return nil. ++ // We SHOULD try at least UTF-8 and after, Latin1. ++ if (!encoding) ++ encoding = NSUTF8StringEncoding; ++ + body = [[[NSString alloc] +- initWithData:_data ++ initWithData:_data + encoding:encoding] autorelease]; ++ ++ if (!body) ++ body = [[[NSString alloc] initWithData:_data ++ encoding:NSISOLatin1StringEncoding] ++ autorelease]; + } + return body; + } Index: sope-mime/NGMime/NGMimePartParser.h =================================================================== --- sope-mime/NGMime/NGMimePartParser.h (revision 1632) @@ -3079,286 +3382,6 @@ Index: sope-mime/NGMime/NGMimeContentDispositionHeaderFieldGenerator.m } return data; } -Index: sope-gdl1/PostgreSQL/PostgreSQL72Channel.m -=================================================================== ---- sope-gdl1/PostgreSQL/PostgreSQL72Channel.m (revision 1632) -+++ sope-gdl1/PostgreSQL/PostgreSQL72Channel.m (working copy) -@@ -713,6 +713,39 @@ - return ms; - } - -+/* GCSEOAdaptorChannel protocol */ -+static NSString *sqlFolderFormat = (@"CREATE TABLE %@ (\n" \ -+ @" c_name VARCHAR (256) NOT NULL PRIMARY KEY,\n" -+ @" c_content VARCHAR (100000) NOT NULL,\n" -+ @" c_creationdate INT4 NOT NULL,\n" -+ @" c_lastmodified INT4 NOT NULL,\n" -+ @" c_version INT4 NOT NULL,\n" -+ @" c_deleted INT4 NULL\n" -+ @")"); -+static NSString *sqlFolderACLFormat = (@"CREATE TABLE %@ (\n" \ -+ @" c_uid VARCHAR (256) NOT NULL,\n" -+ @" c_object VARCHAR (256) NOT NULL,\n" -+ @" c_role VARCHAR (80) NOT NULL\n" -+ @")"); -+ -+- (NSException *) createGCSFolderTableWithName: (NSString *) tableName -+{ -+ NSString *sql; -+ -+ sql = [NSString stringWithFormat: sqlFolderFormat, tableName]; -+ -+ return [self evaluateExpressionX: sql]; -+} -+ -+- (NSException *) createGCSFolderACLTableWithName: (NSString *) tableName -+{ -+ NSString *sql; -+ -+ sql = [NSString stringWithFormat: sqlFolderACLFormat, tableName]; -+ -+ return [self evaluateExpressionX: sql]; -+} -+ - @end /* PostgreSQL72Channel */ - - @implementation PostgreSQL72Channel(PrimaryKeyGeneration) -Index: sope-gdl1/Oracle8/OracleAdaptorChannel.m -=================================================================== ---- sope-gdl1/Oracle8/OracleAdaptorChannel.m (revision 1632) -+++ sope-gdl1/Oracle8/OracleAdaptorChannel.m (working copy) -@@ -1,7 +1,7 @@ - /* - ** OracleAdaptorChannel.m - ** --** Copyright (c) 2007 Inverse groupe conseil inc. and Ludovic Marcotte -+** Copyright (c) 2007-2009 Inverse inc. and Ludovic Marcotte - ** - ** Author: Ludovic Marcotte - ** -@@ -30,6 +30,7 @@ - - #import - -+static BOOL debugOn = NO; - // - // - // -@@ -41,10 +42,11 @@ - - @implementation OracleAdaptorChannel (Private) - --- (void) _cleanup -+- (void) _cleanup - { - column_info *info; - int c; -+ sword result; - - [_resultSetProperties removeAllObjects]; - -@@ -58,11 +60,29 @@ - // so we just free the value instead. - if (info->value) - { -- if (OCIDescriptorFree((dvoid *)info->value, (ub4)OCI_DTYPE_LOB) != OCI_SUCCESS) -+ if (info->type == SQLT_CLOB -+ || info->type == SQLT_BLOB -+ || info->type == SQLT_BFILEE -+ || info->type == SQLT_CFILEE) -+ { -+ result = OCIDescriptorFree((dvoid *)info->value, (ub4) OCI_DTYPE_LOB); -+ if (result != OCI_SUCCESS) -+ { -+ NSLog (@"value was not a LOB descriptor"); -+ abort(); -+ } -+ } -+ else - free(info->value); - info->value = NULL; - } -- free(info); -+ else -+ { -+ NSLog (@"trying to free an already freed value!"); -+ abort(); -+ } -+ free(info); -+ - [_row_buffer removeObjectAtIndex: c]; - } - -@@ -78,8 +98,7 @@ - // - @implementation OracleAdaptorChannel - --static void --DBTerminate() -+static void DBTerminate() - { - if (OCITerminate(OCI_DEFAULT)) - NSLog(@"FAILED: OCITerminate()"); -@@ -89,6 +108,11 @@ - - + (void) initialize - { -+ NSUserDefaults *ud; -+ -+ ud = [NSUserDefaults standardUserDefaults]; -+ debugOn = [ud boolForKey: @"OracleAdaptorDebug"]; -+ - // We Initialize the OCI process environment. - if (OCIInitialize((ub4)OCI_DEFAULT, (dvoid *)0, - (dvoid * (*)(dvoid *, size_t)) 0, -@@ -156,14 +180,17 @@ - [super closeChannel]; - - // We logoff from the database. -- if (OCILogoff(_oci_ctx, _oci_err)) -+ if (!_oci_ctx || !_oci_err || OCILogoff(_oci_ctx, _oci_err)) - { - NSLog(@"FAILED: OCILogoff()"); - } - -+ if (_oci_ctx) -+ OCIHandleFree(_oci_ctx, OCI_HTYPE_SVCCTX); - -- OCIHandleFree(_oci_ctx, OCI_HTYPE_SVCCTX); -- OCIHandleFree(_oci_err, OCI_HTYPE_ERROR); -+ if (_oci_err) -+ OCIHandleFree(_oci_err, OCI_HTYPE_ERROR); -+ - // OCIHandleFree(_oci_env, OCI_HTYPE_ENV); - - _oci_ctx = (OCISvcCtx *)0; -@@ -177,7 +204,8 @@ - // - - (void) dealloc - { -- //NSLog(@"OracleAdaptorChannel: -dealloc"); -+ if (debugOn) -+ NSLog(@"OracleAdaptorChannel: -dealloc"); - - [self _cleanup]; - -@@ -231,6 +259,9 @@ - - [self _cleanup]; - -+ if (debugOn) -+ [self logWithFormat: @"expression: %@", theExpression]; -+ - if (!theExpression || ![theExpression length]) - { - [NSException raise: @"OracleInvalidExpressionException" -@@ -302,7 +333,9 @@ - // We read the maximum width of a column - info->max_width = 0; - status = OCIAttrGet((dvoid*)param, (ub4)OCI_DTYPE_PARAM, (dvoid*)&(info->max_width), (ub4 *)0, (ub4)OCI_ATTR_DATA_SIZE, (OCIError *)_oci_err); -- -+ -+ if (debugOn) -+ NSLog(@"name: %s, type: %d", cname, info->type); - attribute = [EOAttribute attributeWithOracleType: info->type name: cname length: clen width: info->max_width]; - [_resultSetProperties addObject: attribute]; - -@@ -394,16 +427,17 @@ - return NO; - } - -- - if (OCIEnvInit((OCIEnv **)&_oci_env, (ub4)OCI_DEFAULT, (size_t)0, (dvoid **)0)) - { - NSLog(@"FAILED: OCIEnvInit()"); -+ [self closeChannel]; - return NO; - } - - if (OCIHandleAlloc((dvoid *)_oci_env, (dvoid *)&_oci_err, (ub4)OCI_HTYPE_ERROR, (size_t)0, (dvoid **)0)) - { - NSLog(@"FAILED: OCIHandleAlloc() on errhp"); -+ [self closeChannel]; - return NO; - } - -@@ -422,6 +456,7 @@ - { - NSLog(@"FAILED: OCILogon(). username = %s password = %s" - @" database = %s", username, password, database); -+ [self closeChannel]; - return NO; - } - -@@ -438,6 +473,11 @@ - { - sword status; - -+ // We check if our connection is open prior to trying to fetch any data. OCIStmtFetch2() returns -+ // NO error code if the OCI environment is set up but the OCILogon() has failed. -+ if (![self isOpen]) -+ return nil; -+ - status = OCIStmtFetch2(_current_stm, _oci_err, (ub4)1, (ub4)OCI_FETCH_NEXT, (sb4)0, (ub4)OCI_DEFAULT); - - if (status == OCI_NO_DATA) -@@ -609,7 +649,7 @@ - - /* GCSEOAdaptorChannel protocol */ - static NSString *sqlFolderFormat = (@"CREATE TABLE %@ (\n" \ -- @" c_name VARCHAR2 (256) NOT NULL,\n" -+ @" c_name VARCHAR2 (256) NOT NULL PRIMARY KEY,\n" - @" c_content CLOB NOT NULL,\n" - @" c_creationdate INTEGER NOT NULL,\n" - @" c_lastmodified INTEGER NOT NULL,\n" -Index: sope-gdl1/Oracle8/OracleAdaptorChannelController.m -=================================================================== ---- sope-gdl1/Oracle8/OracleAdaptorChannelController.m (revision 1632) -+++ sope-gdl1/Oracle8/OracleAdaptorChannelController.m (working copy) -@@ -31,6 +31,8 @@ - #import - #import - -+static BOOL debugOn = NO; -+ - // - // - // -@@ -48,6 +50,14 @@ - // - @implementation OracleAdaptorChannelController - -++ (void) initialize -+{ -+ NSUserDefaults *ud; -+ -+ ud = [NSUserDefaults standardUserDefaults]; -+ debugOn = [ud boolForKey: @"OracleAdaptorDebug"]; -+} -+ - - (EODelegateResponse) adaptorChannel: (id) theChannel - willInsertRow: (NSMutableDictionary *) theRow - forEntity: (EOEntity *) theEntity -@@ -56,7 +66,8 @@ - NSArray *keys; - int i, c; - -- NSLog(@"willInsertRow: %@ %@", [theRow description], [theEntity description]); -+ if (debugOn) -+ NSLog(@"willInsertRow: %@ %@", [theRow description], [theEntity description]); - - s = AUTORELEASE([[NSMutableString alloc] init]); - -@@ -101,7 +112,8 @@ - NSArray *keys; - int i, c; - -- NSLog(@"willUpdatetRow: %@ %@", [theRow description], [theQualifier description]); -+ if (debugOn) -+ NSLog(@"willUpdateRow: %@ %@", [theRow description], [theQualifier description]); - - s = AUTORELEASE([[NSMutableString alloc] init]); - Index: sope-core/NGExtensions/NGExtensions/NSString+Ext.h =================================================================== --- sope-core/NGExtensions/NGExtensions/NSString+Ext.h (revision 1632)