mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-30 02:37:16 +00:00
Monotone-Parent: f6d4ca8944c94273bc0dae0565c60e45be9f2ca1
Monotone-Revision: 98896091d472e0ee7990f69f32f5981f5d1dc546 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-01-16T18:46:32 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -104,11 +104,8 @@
|
||||
- (NSArray *)subFolderNames;
|
||||
- (NSArray *)allSubFolderNames;
|
||||
|
||||
- (NSNumber *)versionOfContentWithName:(NSString *)_name;
|
||||
- (NSCalendarDate *)creationDateOfEntryWithName:(NSString *)_name;
|
||||
- (NSCalendarDate *)lastModificationOfEntryWithName:(NSString *)_name;
|
||||
- (NSDictionary *) recordOfEntryWithName: (NSString *) name;
|
||||
|
||||
- (NSString *)fetchContentWithName:(NSString *)_name;
|
||||
- (NSException *)writeContent:(NSString *)_content toName:(NSString *)_name
|
||||
baseVersion:(unsigned int)_baseVersion;
|
||||
- (NSException *)writeContent:(NSString *)_content toName:(NSString *)_name;
|
||||
|
||||
@@ -251,15 +251,14 @@ static GCSStringFormatter *stringFormatter = nil;
|
||||
recursive:YES];
|
||||
}
|
||||
|
||||
- (id) _fetchValueOfColumn: (NSString *)_col
|
||||
inContentWithName: (NSString *)_name
|
||||
ignoreDeleted: (BOOL) ignoreDeleted
|
||||
- (NSDictionary *) _fetchValueOfColumns: (NSArray *) _cols
|
||||
inContentWithName: (NSString *) _name
|
||||
ignoreDeleted: (BOOL) ignoreDeleted
|
||||
{
|
||||
EOAdaptorChannel *channel;
|
||||
NSException *error;
|
||||
NSDictionary *row;
|
||||
NSArray *attrs;
|
||||
NSString *result;
|
||||
NSMutableString *sql;
|
||||
|
||||
if ((channel = [self acquireStoreChannel]) == nil) {
|
||||
@@ -271,12 +270,13 @@ static GCSStringFormatter *stringFormatter = nil;
|
||||
sql = [NSMutableString stringWithFormat: @"SELECT %@"
|
||||
@" FROM %@"
|
||||
@" WHERE c_name = '%@'",
|
||||
_col, [self storeTableName], _name];
|
||||
[_cols componentsJoinedByString: @","],
|
||||
[self storeTableName], _name];
|
||||
if (ignoreDeleted)
|
||||
[sql appendString: @" AND (c_deleted != 1 OR c_deleted IS NULL)"];
|
||||
|
||||
/* run SQL */
|
||||
|
||||
|
||||
if ((error = [channel evaluateExpressionX:sql]) != nil) {
|
||||
[self errorWithFormat:@"%s: cannot execute SQL '%@': %@",
|
||||
__PRETTY_FUNCTION__, sql, error];
|
||||
@@ -286,51 +286,64 @@ static GCSStringFormatter *stringFormatter = nil;
|
||||
|
||||
/* fetch results */
|
||||
|
||||
result = nil;
|
||||
attrs = [channel describeResults:NO /* do not beautify names */];
|
||||
if ((row = [channel fetchAttributes:attrs withZone:NULL]) != nil) {
|
||||
result = [[[row objectForKey:_col] copy] autorelease];
|
||||
if (![result isNotNull]) result = nil;
|
||||
row = [channel fetchAttributes: attrs withZone: NULL];
|
||||
if (row)
|
||||
[channel cancelFetch];
|
||||
}
|
||||
|
||||
/* release and return result */
|
||||
|
||||
[self releaseChannel:channel];
|
||||
return result;
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
- (NSNumber *)versionOfContentWithName:(NSString *)_name {
|
||||
return [self _fetchValueOfColumn:@"c_version" inContentWithName:_name
|
||||
ignoreDeleted: YES];
|
||||
- (NSDictionary *) recordOfEntryWithName: (NSString *) name
|
||||
{
|
||||
NSDictionary *row;
|
||||
NSMutableDictionary *record;
|
||||
NSArray *columns;
|
||||
NSString *strValue;
|
||||
int intValue;
|
||||
|
||||
columns = [NSArray arrayWithObjects: @"c_content", @"c_version",
|
||||
@"c_creationdate", @"c_lastmodified", nil];
|
||||
row = [self _fetchValueOfColumns: columns
|
||||
inContentWithName: name
|
||||
ignoreDeleted: YES];
|
||||
if (row)
|
||||
{
|
||||
record = [NSMutableDictionary dictionaryWithCapacity: 5];
|
||||
strValue = [row objectForKey: @"c_content"];
|
||||
if (![strValue isNotNull])
|
||||
strValue = @"";
|
||||
[record setObject: strValue forKey: @"c_content"];
|
||||
[record setObject: [row objectForKey: @"c_version"]
|
||||
forKey: @"c_version"];
|
||||
intValue = [[row objectForKey: @"c_creationdate"] intValue];
|
||||
[record
|
||||
setObject: [NSCalendarDate dateWithTimeIntervalSince1970: intValue]
|
||||
forKey: @"c_creationdate"];
|
||||
intValue = [[row objectForKey: @"c_lastmodified"] intValue];
|
||||
[record
|
||||
setObject: [NSCalendarDate dateWithTimeIntervalSince1970: intValue]
|
||||
forKey: @"c_lastmodified"];
|
||||
}
|
||||
else
|
||||
record = nil;
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
- (NSCalendarDate *)creationDateOfEntryWithName:(NSString *)_name {
|
||||
int seconds;
|
||||
- (NSNumber *) deletionOfEntryWithName: (NSString *) name
|
||||
{
|
||||
NSDictionary *row;
|
||||
|
||||
seconds = [[self _fetchValueOfColumn:@"c_creationdate" inContentWithName:_name
|
||||
ignoreDeleted: YES] intValue];
|
||||
row = [self _fetchValueOfColumns: [NSArray arrayWithObject: @"c_deleted"]
|
||||
inContentWithName: name
|
||||
ignoreDeleted: NO];
|
||||
|
||||
return [NSCalendarDate dateWithTimeIntervalSince1970: seconds];
|
||||
}
|
||||
|
||||
- (NSCalendarDate *)lastModificationOfEntryWithName:(NSString *)_name {
|
||||
int seconds;
|
||||
|
||||
seconds = [[self _fetchValueOfColumn:@"c_lastmodified" inContentWithName:_name
|
||||
ignoreDeleted: YES] intValue];
|
||||
|
||||
return [NSCalendarDate dateWithTimeIntervalSince1970: seconds];
|
||||
}
|
||||
|
||||
- (NSNumber *)deletionOfContentWithName:(NSString *)_name {
|
||||
return [self _fetchValueOfColumn:@"c_deleted" inContentWithName:_name
|
||||
ignoreDeleted: NO];
|
||||
}
|
||||
|
||||
- (NSString *)fetchContentWithName:(NSString *)_name {
|
||||
return [self _fetchValueOfColumn:@"c_content" inContentWithName:_name
|
||||
ignoreDeleted: YES];
|
||||
return [row objectForKey: @"c_deleted"];
|
||||
}
|
||||
|
||||
- (NSDictionary *)fetchContentsOfAllFiles {
|
||||
@@ -571,6 +584,7 @@ static GCSStringFormatter *stringFormatter = nil;
|
||||
{
|
||||
EOAdaptorChannel *storeChannel, *quickChannel;
|
||||
NSMutableDictionary *quickRow, *contentRow;
|
||||
NSDictionary *currentRow;
|
||||
GCSFieldExtractor *extractor;
|
||||
NSException *error;
|
||||
NSNumber *storedVersion;
|
||||
@@ -598,19 +612,24 @@ static GCSStringFormatter *stringFormatter = nil;
|
||||
if (doLogStore)
|
||||
[self logWithFormat:@"should store content: '%@'\n%@", _name, _content];
|
||||
|
||||
storedVersion = [self versionOfContentWithName:_name];
|
||||
currentRow = [self _fetchValueOfColumns: [NSArray arrayWithObjects:
|
||||
@"c_version",
|
||||
@"c_deleted", nil]
|
||||
inContentWithName: _name
|
||||
ignoreDeleted: NO];
|
||||
storedVersion = [currentRow objectForKey: @"c_version"];
|
||||
if (doLogStore)
|
||||
[self logWithFormat:@" version: %@", storedVersion];
|
||||
isNewRecord = [storedVersion isNotNull] ? NO : YES;
|
||||
if (!isNewRecord)
|
||||
{
|
||||
if ([[self deletionOfContentWithName:_name] intValue] > 0)
|
||||
if ([[currentRow objectForKey: @"c_deleted"] intValue] > 0)
|
||||
{
|
||||
[self _purgeRecordWithName: _name];
|
||||
isNewRecord = YES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* check whether sequence matches */
|
||||
if (_baseVersion != 0 /* use 0 to override check */) {
|
||||
if (_baseVersion != [storedVersion unsignedIntValue]) {
|
||||
|
||||
@@ -1,3 +1,47 @@
|
||||
Index: sope-gdl1/PostgreSQL/PostgreSQL72Channel.m
|
||||
===================================================================
|
||||
--- sope-gdl1/PostgreSQL/PostgreSQL72Channel.m (révision 1557)
|
||||
+++ sope-gdl1/PostgreSQL/PostgreSQL72Channel.m (copie de travail)
|
||||
@@ -713,6 +713,39 @@
|
||||
return ms;
|
||||
}
|
||||
|
||||
+/* GCSEOAdaptorChannel protocol */
|
||||
+static NSString *sqlFolderFormat = (@"CREATE TABLE %@ (\n" \
|
||||
+ @" c_name VARCHAR (256) NOT NULL,\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-mime/NGImap4/NGImap4Connection.m
|
||||
===================================================================
|
||||
--- sope-mime/NGImap4/NGImap4Connection.m (révision 1557)
|
||||
@@ -470,11 +514,14 @@ Index: sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m
|
||||
===================================================================
|
||||
--- sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m (révision 1557)
|
||||
+++ sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m (copie de travail)
|
||||
@@ -19,88 +19,30 @@
|
||||
@@ -19,88 +19,45 @@
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
+#ifdef HAVE_STRNDUP
|
||||
+#define _GNU_SOURCE 1
|
||||
+#endif
|
||||
+
|
||||
+#include <string.h>
|
||||
+
|
||||
#include "NGMimeHeaderFieldParser.h"
|
||||
@@ -483,6 +530,18 @@ Index: sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m
|
||||
#include "common.h"
|
||||
-#include <string.h>
|
||||
|
||||
+#ifndef HAVE_STRNDUP
|
||||
+char *strndup(const char *str, size_t len)
|
||||
+{
|
||||
+ char *dup = (char *)malloc(len+1);
|
||||
+ if (dup) {
|
||||
+ strncpy(dup,str,len);
|
||||
+ dup[len]= '\0';
|
||||
+ }
|
||||
+ return dup;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
@implementation NGMimeRFC822DateHeaderFieldParser
|
||||
|
||||
-static Class CalDateClass = Nil;
|
||||
@@ -567,7 +626,7 @@ Index: sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -147,162 +89,110 @@
|
||||
@@ -147,162 +104,110 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -815,7 +874,7 @@ Index: sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m
|
||||
/* remove leading chars (skip to first digit, the day of the month) */
|
||||
while (length > 0 && (!isdigit(*bytes))) {
|
||||
bytes++;
|
||||
@@ -312,7 +202,7 @@
|
||||
@@ -312,7 +217,7 @@
|
||||
if (length == 0) {
|
||||
NSLog(@"WARNING(%s): empty value for header field %@ ..",
|
||||
__PRETTY_FUNCTION__, _field);
|
||||
@@ -824,7 +883,7 @@ Index: sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m
|
||||
}
|
||||
|
||||
// TODO: should be a category on NSCalendarDate
|
||||
@@ -435,7 +325,7 @@
|
||||
@@ -435,7 +340,7 @@
|
||||
for (pe = bytes; isalnum(*pe) || *pe == '-' || *pe == '+'; pe++)
|
||||
;
|
||||
*pe = '\0';
|
||||
@@ -833,7 +892,7 @@ Index: sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m
|
||||
[self logWithFormat:
|
||||
@"WARNING: failed to parse RFC822 timezone: '%s' (value='%@')",
|
||||
bytes, _data];
|
||||
@@ -444,9 +334,9 @@
|
||||
@@ -444,9 +349,9 @@
|
||||
|
||||
/* construct and return */
|
||||
finished:
|
||||
@@ -897,6 +956,22 @@ Index: sope-mime/NGMime/NGMimeBodyPart.m
|
||||
}
|
||||
|
||||
- (NSString *)contentId {
|
||||
Index: sope-mime/NGMime/GNUmakefile.preamble
|
||||
===================================================================
|
||||
--- sope-mime/NGMime/GNUmakefile.preamble (révision 1557)
|
||||
+++ sope-mime/NGMime/GNUmakefile.preamble (copie de travail)
|
||||
@@ -5,6 +5,11 @@
|
||||
-DLIBRARY_MINOR_VERSION=${MINOR_VERSION} \
|
||||
-DLIBRARY_SUBMINOR_VERSION=${SUBMINOR_VERSION} \
|
||||
|
||||
+ifeq ($(patsubstr GNU/%,glibc,$(shell uname -o)),glibc)
|
||||
+ADDITIONAL_CPPFLAGS += \
|
||||
+ -DHAVE_STRNDUP
|
||||
+endif
|
||||
+
|
||||
NGMime_INCLUDE_DIRS += \
|
||||
-I.. -I../.. \
|
||||
-I../../sope-core/NGStreams/ \
|
||||
Index: sope-mime/NGMime/NGMimeBodyParser.m
|
||||
===================================================================
|
||||
--- sope-mime/NGMime/NGMimeBodyParser.m (révision 1557)
|
||||
@@ -1127,50 +1202,6 @@ Index: sope-mime/NGMime/NGMimeContentDispositionHeaderFieldGenerator.m
|
||||
}
|
||||
return data;
|
||||
}
|
||||
Index: sope-gdl1/PostgreSQL/PostgreSQL72Channel.m
|
||||
===================================================================
|
||||
--- sope-gdl1/PostgreSQL/PostgreSQL72Channel.m (révision 1557)
|
||||
+++ sope-gdl1/PostgreSQL/PostgreSQL72Channel.m (copie de travail)
|
||||
@@ -713,6 +713,39 @@
|
||||
return ms;
|
||||
}
|
||||
|
||||
+/* GCSEOAdaptorChannel protocol */
|
||||
+static NSString *sqlFolderFormat = (@"CREATE TABLE %@ (\n" \
|
||||
+ @" c_name VARCHAR (256) NOT NULL,\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-core/NGExtensions/FdExt.subproj/NSString+Encoding.m
|
||||
===================================================================
|
||||
--- sope-core/NGExtensions/FdExt.subproj/NSString+Encoding.m (révision 1557)
|
||||
|
||||
Reference in New Issue
Block a user