mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-11-21 23:12:40 +00:00
Moved the folder metadata generation to SoObject and added 'tag based' sync'ing support for IMAP
This commit is contained in:
1 parent
13721b961b
commit
a4a3a735b4
9 files changed
+279
-162
No files matched your search
@@ -24,6 +24,7 @@
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#import <Foundation/NSTask.h>
|
||||
|
||||
#import <NGObjWeb/NSException+HTTP.h>
|
||||
@@ -1924,6 +1925,145 @@ static NSString *defaultUserID = @"anyone";
|
||||
return date;
|
||||
}
|
||||
|
||||
- (NSString *) davCollectionTag
|
||||
{
|
||||
NSString *tag;
|
||||
|
||||
tag = @"-1";
|
||||
|
||||
if ([self imap4Connection])
|
||||
{
|
||||
NSString *folderName;
|
||||
NSDictionary *result;
|
||||
|
||||
folderName = [imap4 imap4FolderNameForURL: [self imap4URL]];
|
||||
|
||||
[[imap4 client] unselect];
|
||||
|
||||
result = [[imap4 client] select: folderName];
|
||||
|
||||
tag = [NSString stringWithFormat: @"%@-%@", [result objectForKey: @"uidnext"], [result objectForKey: @"highestmodseq"]];
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
//
|
||||
// FIXME - see below for code refactoring with MAPIStoreMailFolder.
|
||||
//
|
||||
- (EOQualifier *) _nonDeletedQualifier
|
||||
{
|
||||
static EOQualifier *nonDeletedQualifier = nil;
|
||||
EOQualifier *deletedQualifier;
|
||||
|
||||
if (!nonDeletedQualifier)
|
||||
{
|
||||
deletedQualifier
|
||||
= [[EOKeyValueQualifier alloc]
|
||||
initWithKey: @"FLAGS"
|
||||
operatorSelector: EOQualifierOperatorContains
|
||||
value: [NSArray arrayWithObject: @"Deleted"]];
|
||||
nonDeletedQualifier = [[EONotQualifier alloc]
|
||||
initWithQualifier: deletedQualifier];
|
||||
[deletedQualifier release];
|
||||
}
|
||||
|
||||
return nonDeletedQualifier;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Check updated items
|
||||
//
|
||||
//
|
||||
//
|
||||
// . uid fetch 1:* (FLAGS) (changedsince 171)
|
||||
//
|
||||
// Deleted: "UID FETCH 1:* (UID) (CHANGEDSINCE 171 VANISHED)"
|
||||
|
||||
// fetchUIDsOfVanishedItems ..
|
||||
//
|
||||
// . uid fetch 1:* (FLAGS) (changedsince 176 vanished)
|
||||
// * VANISHED (EARLIER) 36
|
||||
//
|
||||
//
|
||||
// FIXME: refactor MAPIStoreMailFolder.m - synchroniseCache to use this method
|
||||
//
|
||||
- (NSArray *) syncTokenFieldsWithProperties: (NSArray *) theProperties
|
||||
matchingSyncToken: (NSString *) theSyncToken
|
||||
{
|
||||
EOQualifier *searchQualifier;
|
||||
NSMutableArray *allTokens;
|
||||
NSArray *a, *uids;
|
||||
NSDictionary *d;
|
||||
|
||||
int uidnext, highestmodseq, i;
|
||||
|
||||
allTokens = [NSMutableArray array];
|
||||
a = [theSyncToken componentsSeparatedByString: @"-"];
|
||||
uidnext = [[a objectAtIndex: 0] intValue];
|
||||
highestmodseq = [[a objectAtIndex: 1] intValue];
|
||||
|
||||
// We first make sure QRESYNC is enabled
|
||||
[[self imap4Connection] enableExtensions: [NSArray arrayWithObject: @"QRESYNC"]];
|
||||
|
||||
|
||||
// We fetch new messages and modified messages
|
||||
if (highestmodseq)
|
||||
{
|
||||
EOKeyValueQualifier *kvQualifier;
|
||||
NSNumber *nextModseq;
|
||||
|
||||
nextModseq = [NSNumber numberWithUnsignedLongLong: highestmodseq + 1];
|
||||
kvQualifier = [[EOKeyValueQualifier alloc]
|
||||
initWithKey: @"modseq"
|
||||
operatorSelector: EOQualifierOperatorGreaterThanOrEqualTo
|
||||
value: nextModseq];
|
||||
searchQualifier = [[EOAndQualifier alloc]
|
||||
initWithQualifiers:
|
||||
kvQualifier, [self _nonDeletedQualifier], nil];
|
||||
[kvQualifier release];
|
||||
[searchQualifier autorelease];
|
||||
}
|
||||
else
|
||||
{
|
||||
searchQualifier = [self _nonDeletedQualifier];
|
||||
}
|
||||
|
||||
// we fetch modified or added uids
|
||||
uids = [self fetchUIDsMatchingQualifier: searchQualifier
|
||||
sortOrdering: nil];
|
||||
|
||||
for (i = 0; i < [uids count]; i++)
|
||||
{
|
||||
// New messages
|
||||
if ([[uids objectAtIndex: i] intValue] >= uidnext)
|
||||
{
|
||||
d = [NSDictionary dictionaryWithObject: @"added" forKey: [uids objectAtIndex: i]];
|
||||
}
|
||||
// Changed messages
|
||||
else
|
||||
{
|
||||
d = [NSDictionary dictionaryWithObject: @"changed" forKey: [uids objectAtIndex: i]];
|
||||
}
|
||||
|
||||
[allTokens addObject: d];
|
||||
}
|
||||
|
||||
|
||||
// We fetch deleted ones
|
||||
uids = [self fetchUIDsOfVanishedItems: highestmodseq];
|
||||
|
||||
for (i = 0; i < [uids count]; i++)
|
||||
{
|
||||
d = [NSDictionary dictionaryWithObject: @"deleted" forKey: [uids objectAtIndex: i]];
|
||||
[allTokens addObject: d];
|
||||
}
|
||||
|
||||
return allTokens;
|
||||
}
|
||||
|
||||
@end /* SOGoMailFolder */
|
||||
|
||||
@implementation SOGoSpecialMailFolder
|
||||
|
||||
Reference in new issue
Block a user