Monotone-Parent: 2180e9f83acd350f77772f161695cca6bff102ec
Monotone-Revision: c24e0fd5407c5155f41caca1fbb44c9686e3bc0f Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-08-15T19:00:38 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
3f2cfd97e4
commit
abe8de11aa
|
@ -1,5 +1,9 @@
|
||||||
2012-08-15 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2012-08-15 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* OpenChange/SOGoMAPIDBObject.m (-setNameInContainer): update the
|
||||||
|
object record in the database to reflect the change of folder
|
||||||
|
name.
|
||||||
|
|
||||||
* OpenChange/MAPIStoreMailContext.m (-updateURLWithFolderName):
|
* OpenChange/MAPIStoreMailContext.m (-updateURLWithFolderName):
|
||||||
change the folder name used in the context url to use the new
|
change the folder name used in the context url to use the new
|
||||||
folder name after a rename operation, so that further invocations
|
folder name after a rename operation, so that further invocations
|
||||||
|
|
|
@ -215,6 +215,56 @@ Class SOGoMAPIDBObjectK = Nil;
|
||||||
andSortOrderings: nil];
|
andSortOrderings: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setNameInContainer: (NSString *) newName
|
||||||
|
{
|
||||||
|
NSMutableString *sql;
|
||||||
|
NSString *oldPath, *newPath, *path, *parentPath;
|
||||||
|
NSMutableArray *queries;
|
||||||
|
NSArray *records;
|
||||||
|
NSDictionary *record;
|
||||||
|
NSUInteger count, max;
|
||||||
|
|
||||||
|
/* change the paths in children records */
|
||||||
|
if (nameInContainer)
|
||||||
|
oldPath = [self path];
|
||||||
|
|
||||||
|
[super setNameInContainer: newName];
|
||||||
|
|
||||||
|
if (nameInContainer)
|
||||||
|
{
|
||||||
|
newPath = [self path];
|
||||||
|
|
||||||
|
sql = [NSMutableString stringWithFormat:
|
||||||
|
@"SELECT c_path, c_parent_path FROM %@"
|
||||||
|
@" WHERE c_path LIKE '%@/%%'",
|
||||||
|
[self tableName], oldPath];
|
||||||
|
records = [self performSQLQuery: sql];
|
||||||
|
max = [records count];
|
||||||
|
queries = [NSMutableArray arrayWithCapacity: max + 1];
|
||||||
|
if (max > 0)
|
||||||
|
{
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
{
|
||||||
|
record = [records objectAtIndex: count];
|
||||||
|
path = [record objectForKey: @"c_path"];
|
||||||
|
sql = [NSMutableString stringWithFormat: @"UPDATE %@"
|
||||||
|
@" SET c_path = '%@'",
|
||||||
|
[self tableName],
|
||||||
|
[path stringByReplacingPrefix: oldPath
|
||||||
|
withPrefix: newPath]];
|
||||||
|
parentPath = [record objectForKey: @"c_parent_path"];
|
||||||
|
if ([parentPath isNotNull])
|
||||||
|
[sql appendFormat: @", c_parent_path = '%@'",
|
||||||
|
[parentPath stringByReplacingPrefix: oldPath
|
||||||
|
withPrefix: newPath]];
|
||||||
|
[sql appendFormat: @" WHERE c_path = '%@'", path];
|
||||||
|
[queries addObject: sql];
|
||||||
|
}
|
||||||
|
[self performBatchSQLQueries: queries];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void) changePathTo: (NSString *) newPath
|
- (void) changePathTo: (NSString *) newPath
|
||||||
{
|
{
|
||||||
NSMutableString *sql// , *qualifierClause
|
NSMutableString *sql// , *qualifierClause
|
||||||
|
|
|
@ -260,6 +260,29 @@ static EOAttribute *textColumn = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* actions */
|
/* actions */
|
||||||
|
- (void) setNameInContainer: (NSString *) newNameInContainer
|
||||||
|
{
|
||||||
|
NSMutableString *sql;
|
||||||
|
NSString *oldPath, *newPath;
|
||||||
|
|
||||||
|
if (nameInContainer)
|
||||||
|
oldPath = [self path];
|
||||||
|
|
||||||
|
[super setNameInContainer: newNameInContainer];
|
||||||
|
|
||||||
|
if (nameInContainer)
|
||||||
|
{
|
||||||
|
newPath = [self path];
|
||||||
|
|
||||||
|
sql = [NSMutableString stringWithFormat: @"UPDATE %@"
|
||||||
|
@" SET c_path = '%@'",
|
||||||
|
[self tableName],
|
||||||
|
newPath];
|
||||||
|
[sql appendFormat: @" WHERE c_path = '%@'", oldPath];
|
||||||
|
[self performBatchSQLQueries: [NSArray arrayWithObject: sql]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void) changePathTo: (NSString *) newPath
|
- (void) changePathTo: (NSString *) newPath
|
||||||
{
|
{
|
||||||
NSMutableString *sql;
|
NSMutableString *sql;
|
||||||
|
|
Loading…
Reference in New Issue