mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-31 08:04:54 +00:00
merge of '517b4606eb0bf70ff837ab032cd258dfcca1e292'
and '77c7a08939b557080f47653bfa1203e557eb14d2' Monotone-Parent: 517b4606eb0bf70ff837ab032cd258dfcca1e292 Monotone-Parent: 77c7a08939b557080f47653bfa1203e557eb14d2 Monotone-Revision: 9cb63fedb848baac983ef94694d11b7e242eef67 Monotone-Author: flachapelle@inverse.ca Monotone-Date: 2010-06-23T15:47:50 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
2010-06-23 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/SOGoGCSFolder.m (-_lastModified): new method that
|
||||
returns the last modified timestamp of the folder. Taken from
|
||||
previous implementation of davCollectionTag.
|
||||
(-davCollectionTag): make use of the new method above.
|
||||
(_isValidSyncToken:): new method that perform a real validation of
|
||||
the sync token passed as parameter.
|
||||
(-davSyncCollection): make use of the new method above.
|
||||
|
||||
2010-06-22 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/SOGoDAVAuthenticator.m (-checkLogin:andPassword:)
|
||||
we save the CAS session information to the cache after a
|
||||
successful authentication/validation.
|
||||
|
||||
2010-06-18 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/SOGoDAVAuthenticator.m (-checkLogin:andPassword:)
|
||||
|
||||
Binary file not shown.
@@ -72,8 +72,9 @@
|
||||
/* CAS authentication for DAV requires using a proxy */
|
||||
session = [SOGoCASSession CASSessionWithTicket: _pwd
|
||||
fromProxy: YES];
|
||||
if (session)
|
||||
rc = [[session login] isEqualToString: _login];
|
||||
rc = [[session login] isEqualToString: _login];
|
||||
if (rc)
|
||||
[session updateCache];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -776,14 +776,14 @@ static NSArray *childRecordFields = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *) davCollectionTag
|
||||
- (int) _lastModified
|
||||
{
|
||||
NSArray *records;
|
||||
GCSFolder *folder;
|
||||
EOFetchSpecification *cTagSpec;
|
||||
EOSortOrdering *ordering;
|
||||
NSNumber *lastModified;
|
||||
NSString *cTag;
|
||||
int value;
|
||||
|
||||
folder = [self ocsFolder];
|
||||
ordering = [EOSortOrdering sortOrderingWithKey: @"c_lastmodified"
|
||||
@@ -800,12 +800,17 @@ static NSArray *childRecordFields = nil;
|
||||
{
|
||||
lastModified = [[records objectAtIndex: 0]
|
||||
objectForKey: @"c_lastmodified"];
|
||||
cTag = [lastModified stringValue];
|
||||
value = [lastModified intValue];
|
||||
}
|
||||
else
|
||||
cTag = @"-1";
|
||||
value = -1;
|
||||
|
||||
return cTag;
|
||||
return value;
|
||||
}
|
||||
|
||||
- (NSString *) davCollectionTag
|
||||
{
|
||||
return [NSString stringWithFormat: @"%d", [self _lastModified]];
|
||||
}
|
||||
|
||||
- (BOOL) userIsSubscriber: (NSString *) subscribingUser
|
||||
@@ -1207,7 +1212,7 @@ static NSArray *childRecordFields = nil;
|
||||
SEL *selectors;
|
||||
|
||||
max = [properties count];
|
||||
selectors = NSZoneMalloc (NULL, sizeof (max * sizeof (SEL)));
|
||||
selectors = NSZoneMalloc (NULL, max * sizeof (SEL));
|
||||
for (count = 0; count < max; count++)
|
||||
selectors[count]
|
||||
= SOGoSelectorForPropertyGetter ([properties objectAtIndex: count]);
|
||||
@@ -1254,6 +1259,43 @@ static NSArray *childRecordFields = nil;
|
||||
appendContentString: [multistatus asWebDavStringWithNamespaces: nil]];
|
||||
}
|
||||
|
||||
- (BOOL) _isValidSyncToken: (NSString *) syncToken
|
||||
{
|
||||
unichar *characters;
|
||||
int count, max, value;
|
||||
BOOL valid;
|
||||
|
||||
max = [syncToken length];
|
||||
if (max > 0)
|
||||
{
|
||||
characters = NSZoneMalloc (NULL, max * sizeof (unichar));
|
||||
[syncToken getCharacters: characters];
|
||||
if (max == 2
|
||||
&& characters[0] == '-'
|
||||
&& characters[1] == '1')
|
||||
valid = YES;
|
||||
else
|
||||
{
|
||||
valid = YES;
|
||||
value = 0;
|
||||
for (count = 0; valid && count < max; count++)
|
||||
{
|
||||
if (characters[count] < '0'
|
||||
|| characters[count] > '9')
|
||||
valid = NO;
|
||||
else
|
||||
value = value * 10 + characters[count] - '0';
|
||||
}
|
||||
valid |= (value <= [self _lastModified]);
|
||||
}
|
||||
NSZoneFree (NULL, characters);
|
||||
}
|
||||
else
|
||||
valid = YES;
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
- (WOResponse *) davSyncCollection: (WOContext *) localContext
|
||||
{
|
||||
WOResponse *r;
|
||||
@@ -1270,17 +1312,18 @@ static NSArray *childRecordFields = nil;
|
||||
documentElement = (DOMElement *) [document documentElement];
|
||||
syncToken = [[documentElement firstElementWithTag: @"sync-token"
|
||||
inNamespace: XMLNS_WEBDAV] textValue];
|
||||
|
||||
propElement = [documentElement firstElementWithTag: @"prop"
|
||||
inNamespace: XMLNS_WEBDAV];
|
||||
properties = [self parseDAVRequestedProperties: propElement];
|
||||
records = [self _fetchSyncTokenFields: properties
|
||||
matchingSyncToken: syncToken];
|
||||
if (![syncToken length] || [records count])
|
||||
[self _appendComponentProperties: [properties allKeys]
|
||||
fromRecords: records
|
||||
matchingSyncToken: [syncToken intValue]
|
||||
toResponse: r];
|
||||
if ([self _isValidSyncToken: syncToken])
|
||||
{
|
||||
propElement = [documentElement firstElementWithTag: @"prop"
|
||||
inNamespace: XMLNS_WEBDAV];
|
||||
properties = [self parseDAVRequestedProperties: propElement];
|
||||
records = [self _fetchSyncTokenFields: properties
|
||||
matchingSyncToken: syncToken];
|
||||
[self _appendComponentProperties: [properties allKeys]
|
||||
fromRecords: records
|
||||
matchingSyncToken: [syncToken intValue]
|
||||
toResponse: r];
|
||||
}
|
||||
else
|
||||
[r appendDAVError: davElement (@"valid-sync-token", XMLNS_WEBDAV)];
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* SOGoToolBackup.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2009 Inverse inc.
|
||||
* Copyright (C) 2009-2010 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
@@ -91,8 +91,9 @@
|
||||
- (void) usage
|
||||
{
|
||||
fprintf (stderr, "backup directory ALL|user1 [user2] ...\n\n"
|
||||
" folder the folder where backup files will be stored\n"
|
||||
" user the user of whom to save the data\n");
|
||||
" directory the target directory where backup files will be stored\n"
|
||||
" user the user of whom to save the data or ALL for everybody\n\n"
|
||||
"Example: sogo-tool backup /tmp/foo ALL\n");
|
||||
}
|
||||
|
||||
- (BOOL) checkDirectory
|
||||
|
||||
+10
-4
@@ -1,6 +1,6 @@
|
||||
/* SOGoToolRestore.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2009 Inverse inc.
|
||||
* Copyright (C) 2009-2010 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
@@ -104,9 +104,15 @@ typedef enum SOGoToolRestoreMode {
|
||||
|
||||
- (void) usage
|
||||
{
|
||||
fprintf (stderr, "restore [-l|-f/-F folder/ALL|-p] directory user\n\n"
|
||||
" folder the folder where backup files will be stored\n"
|
||||
" user the user of whom to save the data\n");
|
||||
fprintf (stderr, "restore [-l|-p|-f/-F folder/ALL|-p] directory user\n\n"
|
||||
" directory the directory where backup files were initially stored\n"
|
||||
" user the user of whom to restore the data\n"
|
||||
" -l flag used to list folders to restore\n"
|
||||
" -p flag used to restore only the user's preferences\n"
|
||||
" -f/-F flag used to specify which folder to restore, ALL for everything\n\n"
|
||||
"Examples: sogo-tool restore -l /tmp/foo bob\n"
|
||||
" sogo-tool restore -f Contacts/personal /tmp/foo bob\n"
|
||||
" sogo-tool restore -p /tmp/foo bob\n");
|
||||
}
|
||||
|
||||
- (BOOL) checkDirectory
|
||||
|
||||
Reference in New Issue
Block a user