Refactored the code and added support for FilterType
parent
07d4b2bae2
commit
046a645119
|
@ -12,6 +12,7 @@ ActiveSync_OBJC_FILES = \
|
||||||
iCalEvent+ActiveSync.m \
|
iCalEvent+ActiveSync.m \
|
||||||
iCalTimeZone+ActiveSync.m \
|
iCalTimeZone+ActiveSync.m \
|
||||||
iCalToDo+ActiveSync.m \
|
iCalToDo+ActiveSync.m \
|
||||||
|
NSCalendarDate+ActiveSync.m \
|
||||||
NSData+ActiveSync.m \
|
NSData+ActiveSync.m \
|
||||||
NSDate+ActiveSync.m \
|
NSDate+ActiveSync.m \
|
||||||
NGDOMElement+ActiveSync.m \
|
NGDOMElement+ActiveSync.m \
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2014, Inverse inc.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the Inverse inc. nor the
|
||||||
|
names of its contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
#ifndef __NSCALENDARDATEACTIVESYNC_H__
|
||||||
|
#define __NSCALENDARDATEACTIVESYNC_H__
|
||||||
|
|
||||||
|
#import <Foundation/NSCalendarDate.h>
|
||||||
|
|
||||||
|
@class NSString;
|
||||||
|
|
||||||
|
@interface NSCalendarDate (ActiveSync)
|
||||||
|
|
||||||
|
+ (NSCalendarDate *) dateFromFilterType: (NSString *) theFilterType;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2014, Inverse inc.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the Inverse inc. nor the
|
||||||
|
names of its contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
#import "NSCalendarDate+ActiveSync.h"
|
||||||
|
|
||||||
|
#import <Foundation/NSString.h>
|
||||||
|
#import <Foundation/NSTimeZone.h>
|
||||||
|
|
||||||
|
#define ONE_DAY 86400
|
||||||
|
|
||||||
|
@implementation NSCalendarDate (ActiveSync)
|
||||||
|
|
||||||
|
//
|
||||||
|
// See http://msdn.microsoft.com/en-us/library/gg709713(v=exchg.80).aspx for available types
|
||||||
|
//
|
||||||
|
+ (NSCalendarDate *) dateFromFilterType: (NSString *) theFilterType
|
||||||
|
{
|
||||||
|
NSCalendarDate *d;
|
||||||
|
|
||||||
|
d = [NSCalendarDate calendarDate];
|
||||||
|
|
||||||
|
if (d)
|
||||||
|
{
|
||||||
|
int value;
|
||||||
|
|
||||||
|
switch ([theFilterType intValue])
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
value = ONE_DAY;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
value = 3 * ONE_DAY;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
value = 7 * ONE_DAY;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
value = 14 * ONE_DAY;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
value = 30 * ONE_DAY;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
value = 90 * ONE_DAY;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
value = 180 * ONE_DAY;
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
case 8:
|
||||||
|
default:
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [d initWithTimeIntervalSinceNow: -value];
|
||||||
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -35,7 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <wbxml/wbxml_conv.h>
|
#include <wbxml/wbxml_conv.h>
|
||||||
#include <wbxml/wbxml_errors.h>
|
#include <wbxml/wbxml_errors.h>
|
||||||
|
|
||||||
#define WBXMLDEBUG 0
|
#define WBXMLDEBUG 1
|
||||||
|
|
||||||
@implementation NSData (ActiveSync)
|
@implementation NSData (ActiveSync)
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "iCalToDo+ActiveSync.h"
|
#include "iCalToDo+ActiveSync.h"
|
||||||
#include "NGDOMElement+ActiveSync.h"
|
#include "NGDOMElement+ActiveSync.h"
|
||||||
#include "NGVCard+ActiveSync.h"
|
#include "NGVCard+ActiveSync.h"
|
||||||
|
#include "NSCalendarDate+ActiveSync.h"
|
||||||
#include "NSDate+ActiveSync.h"
|
#include "NSDate+ActiveSync.h"
|
||||||
#include "NSData+ActiveSync.h"
|
#include "NSData+ActiveSync.h"
|
||||||
#include "NSString+ActiveSync.h"
|
#include "NSString+ActiveSync.h"
|
||||||
|
@ -447,7 +448,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
inCollection: (id) theCollection
|
inCollection: (id) theCollection
|
||||||
withSyncKey: (NSString *) theSyncKey
|
withSyncKey: (NSString *) theSyncKey
|
||||||
withFolderType: (SOGoMicrosoftActiveSyncFolderType) theFolderType
|
withFolderType: (SOGoMicrosoftActiveSyncFolderType) theFolderType
|
||||||
withFilterType: (NSDate *) theFilterType
|
withFilterType: (NSCalendarDate *) theFilterType
|
||||||
inBuffer: (NSMutableString *) theBuffer
|
inBuffer: (NSMutableString *) theBuffer
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -463,97 +464,37 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
switch (theFolderType)
|
switch (theFolderType)
|
||||||
{
|
{
|
||||||
|
// Handle all the GCS components
|
||||||
case ActiveSyncContactFolder:
|
case ActiveSyncContactFolder:
|
||||||
{
|
|
||||||
NSArray *allContacts;
|
|
||||||
NGVCard *card;
|
|
||||||
id contact;
|
|
||||||
|
|
||||||
allContacts = [theCollection syncTokenFieldsWithProperties: nil matchingSyncToken: theSyncKey];
|
|
||||||
|
|
||||||
for (i = 0; i < [allContacts count]; i++)
|
|
||||||
{
|
|
||||||
contact = [theCollection lookupName: [[allContacts objectAtIndex: i] objectForKey: @"c_name"]
|
|
||||||
inContext: context
|
|
||||||
acquire: NO];
|
|
||||||
|
|
||||||
if (![[[allContacts objectAtIndex: i] objectForKey: @"c_component"] isEqualToString: @"vcard"])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// FIXME: we skip list right now
|
|
||||||
if ([contact respondsToSelector: @selector (vCard)])
|
|
||||||
{
|
|
||||||
card = [contact vCard];
|
|
||||||
|
|
||||||
[theBuffer appendString: @"<Add xmlns=\"AirSync:\">"];
|
|
||||||
[theBuffer appendFormat: @"<ServerId xmlns=\"AirSync:\">%@</ServerId>", [contact nameInContainer]];
|
|
||||||
[theBuffer appendString: @"<ApplicationData xmlns=\"AirSync:\">"];
|
|
||||||
|
|
||||||
[theBuffer appendString: [card activeSyncRepresentation]];
|
|
||||||
|
|
||||||
[theBuffer appendString: @"</ApplicationData>"];
|
|
||||||
[theBuffer appendString: @"</Add>"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ActiveSyncEventFolder:
|
case ActiveSyncEventFolder:
|
||||||
{
|
|
||||||
NSArray *allEvents;
|
|
||||||
NSDictionary *d;
|
|
||||||
id eventObject;
|
|
||||||
|
|
||||||
allEvents = [theCollection syncTokenFieldsWithProperties: nil matchingSyncToken: theSyncKey];
|
|
||||||
|
|
||||||
for (i = 0; i < [allEvents count]; i++)
|
|
||||||
{
|
|
||||||
NSString *serverId;
|
|
||||||
iCalEvent *event;
|
|
||||||
|
|
||||||
d = [allEvents objectAtIndex: i];
|
|
||||||
|
|
||||||
if (![[d objectForKey: @"c_component"] isEqualToString: @"vevent"])
|
|
||||||
continue;
|
|
||||||
|
|
||||||
serverId = [d objectForKey: @"c_name"];
|
|
||||||
|
|
||||||
[theBuffer appendString: @"<Add xmlns=\"AirSync:\">"];
|
|
||||||
[theBuffer appendFormat: @"<ServerId xmlns=\"AirSync:\">%@</ServerId>", serverId];
|
|
||||||
[theBuffer appendString: @"<ApplicationData xmlns=\"AirSync:\">"];
|
|
||||||
|
|
||||||
eventObject = [theCollection lookupName: serverId inContext: self->context acquire: 0];
|
|
||||||
|
|
||||||
event = [eventObject component: NO secure: NO];
|
|
||||||
|
|
||||||
[theBuffer appendString: [event activeSyncRepresentation]];
|
|
||||||
|
|
||||||
[theBuffer appendString: @"</ApplicationData>"];
|
|
||||||
[theBuffer appendString: @"</Add>"];
|
|
||||||
|
|
||||||
} // for (i = 0; i < [allEvents count]; i++)
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ActiveSyncTaskFolder:
|
case ActiveSyncTaskFolder:
|
||||||
{
|
{
|
||||||
NSArray *allTasks;
|
id sogoObject, componentObject;
|
||||||
NSDictionary *task;
|
NSString *uid, *component_name;
|
||||||
id taskObject;
|
NSDictionary *component;
|
||||||
|
NSArray *allComponents;
|
||||||
|
|
||||||
allTasks = [theCollection syncTokenFieldsWithProperties: nil matchingSyncToken: theSyncKey];
|
BOOL updated;
|
||||||
|
|
||||||
for (i = 0; i < [allTasks count]; i++)
|
|
||||||
|
|
||||||
{
|
|
||||||
int deleted;
|
int deleted;
|
||||||
|
|
||||||
task = [allTasks objectAtIndex: i];
|
if (theFolderType == ActiveSyncContactFolder)
|
||||||
deleted = [[task objectForKey: @"c_deleted"] intValue];
|
component_name = @"vcard";
|
||||||
|
else if (theFolderType == ActiveSyncEventFolder)
|
||||||
|
component_name = @"vevent";
|
||||||
|
else
|
||||||
|
component_name = @"vtodo";
|
||||||
|
|
||||||
if (!deleted && ![[task objectForKey: @"c_component"] isEqualToString: @"vtodo"])
|
allComponents = [theCollection syncTokenFieldsWithProperties: nil matchingSyncToken: theSyncKey fromDate: theFilterType];
|
||||||
|
|
||||||
|
for (i = 0; i < [allComponents count]; i++)
|
||||||
|
{
|
||||||
|
component = [allComponents objectAtIndex: i];
|
||||||
|
deleted = [[component objectForKey: @"c_deleted"] intValue];
|
||||||
|
|
||||||
|
if (!deleted && ![[component objectForKey: @"c_component"] isEqualToString: component_name])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
NSString *uid;
|
uid = [component objectForKey: @"c_name"];
|
||||||
uid = [task objectForKey: @"c_name"];
|
|
||||||
|
|
||||||
if (deleted)
|
if (deleted)
|
||||||
{
|
{
|
||||||
|
@ -563,12 +504,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iCalToDo *todo;
|
|
||||||
BOOL updated;
|
|
||||||
|
|
||||||
updated = YES;
|
updated = YES;
|
||||||
|
|
||||||
if ([[task objectForKey: @"c_creationdate"] intValue] > [theSyncKey intValue])
|
if ([[component objectForKey: @"c_creationdate"] intValue] > [theSyncKey intValue])
|
||||||
updated = NO;
|
updated = NO;
|
||||||
|
|
||||||
if (updated)
|
if (updated)
|
||||||
|
@ -579,11 +517,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
[theBuffer appendFormat: @"<ServerId xmlns=\"AirSync:\">%@</ServerId>", uid];
|
[theBuffer appendFormat: @"<ServerId xmlns=\"AirSync:\">%@</ServerId>", uid];
|
||||||
[theBuffer appendString: @"<ApplicationData xmlns=\"AirSync:\">"];
|
[theBuffer appendString: @"<ApplicationData xmlns=\"AirSync:\">"];
|
||||||
|
|
||||||
taskObject = [theCollection lookupName: uid inContext: self->context acquire: 0];
|
sogoObject = [theCollection lookupName: uid
|
||||||
|
inContext: context
|
||||||
|
acquire: 0];
|
||||||
|
|
||||||
todo = [taskObject component: NO secure: NO];
|
if (theFolderType == ActiveSyncContactFolder)
|
||||||
|
componentObject = [sogoObject vCard];
|
||||||
|
else
|
||||||
|
componentObject = [sogoObject component: NO secure: NO];
|
||||||
|
|
||||||
[theBuffer appendString: [todo activeSyncRepresentation]];
|
[theBuffer appendString: [componentObject activeSyncRepresentation]];
|
||||||
|
|
||||||
[theBuffer appendString: @"</ApplicationData>"];
|
[theBuffer appendString: @"</ApplicationData>"];
|
||||||
|
|
||||||
|
@ -598,12 +541,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
case ActiveSyncMailFolder:
|
case ActiveSyncMailFolder:
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
SOGoMailObject *mailObject;
|
||||||
|
NSString *uid, *command;
|
||||||
NSDictionary *aMessage;
|
NSDictionary *aMessage;
|
||||||
NSArray *allMessages;
|
NSArray *allMessages;
|
||||||
NSString *uid, *command;
|
|
||||||
SOGoMailObject *mailObject;
|
|
||||||
|
|
||||||
allMessages = [theCollection syncTokenFieldsWithProperties: nil matchingSyncToken: theSyncKey];
|
allMessages = [theCollection syncTokenFieldsWithProperties: nil matchingSyncToken: theSyncKey fromDate: theFilterType];
|
||||||
|
|
||||||
for (i = 0; i < [allMessages count]; i++)
|
for (i = 0; i < [allMessages count]; i++)
|
||||||
{
|
{
|
||||||
|
@ -779,7 +722,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
inCollection: collection
|
inCollection: collection
|
||||||
withSyncKey: syncKey
|
withSyncKey: syncKey
|
||||||
withFolderType: folderType
|
withFolderType: folderType
|
||||||
withFilterType: [NSDate dateFromFilterType: [[(id)[theDocumentElement getElementsByTagName: @"FilterType"] lastObject] textValue]]
|
withFilterType: [NSCalendarDate dateFromFilterType: [[(id)[theDocumentElement getElementsByTagName: @"FilterType"] lastObject] textValue]]
|
||||||
inBuffer: theBuffer];
|
inBuffer: theBuffer];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "iCalToDo+ActiveSync.h"
|
#include "iCalToDo+ActiveSync.h"
|
||||||
#include "NGMimeMessage+ActiveSync.h"
|
#include "NGMimeMessage+ActiveSync.h"
|
||||||
#include "NGVCard+ActiveSync.h"
|
#include "NGVCard+ActiveSync.h"
|
||||||
|
#include "NSCalendarDate+ActiveSync.h"
|
||||||
#include "NSData+ActiveSync.h"
|
#include "NSData+ActiveSync.h"
|
||||||
|
#include "NSDate+ActiveSync.h"
|
||||||
#include "NSString+ActiveSync.h"
|
#include "NSString+ActiveSync.h"
|
||||||
#include "SOGoActiveSyncConstants.h"
|
#include "SOGoActiveSyncConstants.h"
|
||||||
#include "SOGoMailObject+ActiveSync.h"
|
#include "SOGoMailObject+ActiveSync.h"
|
||||||
|
@ -516,12 +518,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
- (void) processGetItemEstimate: (id <DOMElement>) theDocumentElement
|
- (void) processGetItemEstimate: (id <DOMElement>) theDocumentElement
|
||||||
inResponse: (WOResponse *) theResponse
|
inResponse: (WOResponse *) theResponse
|
||||||
{
|
{
|
||||||
|
EOQualifier *notDeletedQualifier, *sinceDateQualifier;
|
||||||
|
NSString *collectionId, *realCollectionId;
|
||||||
|
id currentFolder, currentCollection;
|
||||||
SOGoMailAccounts *accountsFolder;
|
SOGoMailAccounts *accountsFolder;
|
||||||
SOGoUserFolder *userFolder;
|
SOGoUserFolder *userFolder;
|
||||||
id currentFolder, currentCollection;
|
EOAndQualifier *qualifier;
|
||||||
|
NSCalendarDate *filter;
|
||||||
NSString *collectionId, *realCollectionId;
|
|
||||||
NSMutableString *s;
|
NSMutableString *s;
|
||||||
|
NSArray *uids;
|
||||||
NSData *d;
|
NSData *d;
|
||||||
|
|
||||||
SOGoMicrosoftActiveSyncFolderType folderType;
|
SOGoMicrosoftActiveSyncFolderType folderType;
|
||||||
|
@ -541,11 +546,27 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
currentCollection = [currentFolder lookupName: [NSString stringWithFormat: @"folder%@", realCollectionId]
|
currentCollection = [currentFolder lookupName: [NSString stringWithFormat: @"folder%@", realCollectionId]
|
||||||
inContext: context
|
inContext: context
|
||||||
acquire: NO];
|
acquire: NO];
|
||||||
|
//
|
||||||
|
// For IMAP, we simply build a request like this:
|
||||||
|
//
|
||||||
|
// . UID SORT (SUBJECT) UTF-8 SINCE 1-Jan-2014 NOT DELETED
|
||||||
|
// * SORT 124576 124577 124579 124578
|
||||||
|
// . OK Completed (4 msgs in 0.000 secs)
|
||||||
|
//
|
||||||
|
filter = [NSCalendarDate dateFromFilterType: [[(id)[theDocumentElement getElementsByTagName: @"FilterType"] lastObject] textValue]];
|
||||||
|
|
||||||
// FIXME: we ignore FilterType for now
|
notDeletedQualifier = [EOQualifier qualifierWithQualifierFormat:
|
||||||
NSArray *uids = [currentCollection fetchUIDsMatchingQualifier: [EOQualifier qualifierWithQualifierFormat:
|
|
||||||
@"(not (flags = %@))",
|
@"(not (flags = %@))",
|
||||||
@"deleted"]
|
@"deleted"];
|
||||||
|
sinceDateQualifier = [EOQualifier qualifierWithQualifierFormat:
|
||||||
|
@"(DATE >= %@)", filter];
|
||||||
|
|
||||||
|
|
||||||
|
qualifier = [[EOAndQualifier alloc] initWithQualifiers: notDeletedQualifier, sinceDateQualifier,
|
||||||
|
nil];
|
||||||
|
AUTORELEASE(qualifier);
|
||||||
|
|
||||||
|
uids = [currentCollection fetchUIDsMatchingQualifier: qualifier
|
||||||
sortOrdering: @"REVERSE ARRIVAL"
|
sortOrdering: @"REVERSE ARRIVAL"
|
||||||
threaded: NO];
|
threaded: NO];
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,10 @@
|
||||||
|
|
||||||
- (NSString *) davCollectionTag;
|
- (NSString *) davCollectionTag;
|
||||||
|
|
||||||
|
- (NSArray *) syncTokenFieldsWithProperties: (NSDictionary *) properties
|
||||||
|
matchingSyncToken: (NSString *) syncToken
|
||||||
|
fromDate: (NSCalendarDate *) theStartDate;
|
||||||
|
|
||||||
/* flags */
|
/* flags */
|
||||||
|
|
||||||
- (NSException *) addFlagsToAllMessages: (id) _f;
|
- (NSException *) addFlagsToAllMessages: (id) _f;
|
||||||
|
|
|
@ -1992,6 +1992,7 @@ static NSString *defaultUserID = @"anyone";
|
||||||
//
|
//
|
||||||
- (NSArray *) syncTokenFieldsWithProperties: (NSArray *) theProperties
|
- (NSArray *) syncTokenFieldsWithProperties: (NSArray *) theProperties
|
||||||
matchingSyncToken: (NSString *) theSyncToken
|
matchingSyncToken: (NSString *) theSyncToken
|
||||||
|
fromDate: (NSCalendarDate *) theStartDate
|
||||||
{
|
{
|
||||||
EOQualifier *searchQualifier;
|
EOQualifier *searchQualifier;
|
||||||
NSMutableArray *allTokens;
|
NSMutableArray *allTokens;
|
||||||
|
@ -2001,9 +2002,17 @@ static NSString *defaultUserID = @"anyone";
|
||||||
int uidnext, highestmodseq, i;
|
int uidnext, highestmodseq, i;
|
||||||
|
|
||||||
allTokens = [NSMutableArray array];
|
allTokens = [NSMutableArray array];
|
||||||
|
|
||||||
|
if ([theSyncToken isEqualToString: @"-1"])
|
||||||
|
{
|
||||||
|
uidnext = highestmodseq = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
a = [theSyncToken componentsSeparatedByString: @"-"];
|
a = [theSyncToken componentsSeparatedByString: @"-"];
|
||||||
uidnext = [[a objectAtIndex: 0] intValue];
|
uidnext = [[a objectAtIndex: 0] intValue];
|
||||||
highestmodseq = [[a objectAtIndex: 1] intValue];
|
highestmodseq = [[a objectAtIndex: 1] intValue];
|
||||||
|
}
|
||||||
|
|
||||||
// We first make sure QRESYNC is enabled
|
// We first make sure QRESYNC is enabled
|
||||||
[[self imap4Connection] enableExtensions: [NSArray arrayWithObject: @"QRESYNC"]];
|
[[self imap4Connection] enableExtensions: [NSArray arrayWithObject: @"QRESYNC"]];
|
||||||
|
@ -2031,6 +2040,17 @@ static NSString *defaultUserID = @"anyone";
|
||||||
searchQualifier = [self _nonDeletedQualifier];
|
searchQualifier = [self _nonDeletedQualifier];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (theStartDate)
|
||||||
|
{
|
||||||
|
EOQualifier *sinceDateQualifier = [EOQualifier qualifierWithQualifierFormat:
|
||||||
|
@"(DATE >= %@)", theStartDate];
|
||||||
|
|
||||||
|
searchQualifier = [[EOAndQualifier alloc] initWithQualifiers: searchQualifier, sinceDateQualifier,
|
||||||
|
nil];
|
||||||
|
[searchQualifier autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// we fetch modified or added uids
|
// we fetch modified or added uids
|
||||||
uids = [self fetchUIDsMatchingQualifier: searchQualifier
|
uids = [self fetchUIDsMatchingQualifier: searchQualifier
|
||||||
sortOrdering: nil];
|
sortOrdering: nil];
|
||||||
|
|
|
@ -126,7 +126,9 @@
|
||||||
- (NSString *) davCollectionTag;
|
- (NSString *) davCollectionTag;
|
||||||
|
|
||||||
- (NSArray *) syncTokenFieldsWithProperties: (NSDictionary *) properties
|
- (NSArray *) syncTokenFieldsWithProperties: (NSDictionary *) properties
|
||||||
matchingSyncToken: (NSString *) syncToken;
|
matchingSyncToken: (NSString *) syncToken
|
||||||
|
fromDate: (NSCalendarDate *) theStartDate;
|
||||||
|
|
||||||
|
|
||||||
/* multiget helper */
|
/* multiget helper */
|
||||||
- (WOResponse *) performMultigetInContext: (WOContext *) queryContext
|
- (WOResponse *) performMultigetInContext: (WOContext *) queryContext
|
||||||
|
|
|
@ -1101,6 +1101,7 @@ static NSArray *childRecordFields = nil;
|
||||||
//
|
//
|
||||||
- (NSArray *) syncTokenFieldsWithProperties: (NSDictionary *) properties
|
- (NSArray *) syncTokenFieldsWithProperties: (NSDictionary *) properties
|
||||||
matchingSyncToken: (NSString *) syncToken
|
matchingSyncToken: (NSString *) syncToken
|
||||||
|
fromDate: (NSCalendarDate *) theStartDate
|
||||||
{
|
{
|
||||||
/* TODO:
|
/* TODO:
|
||||||
- validation:
|
- validation:
|
||||||
|
@ -1124,8 +1125,20 @@ static NSArray *childRecordFields = nil;
|
||||||
if ([syncToken length])
|
if ([syncToken length])
|
||||||
{
|
{
|
||||||
syncTokenInt = [syncToken intValue];
|
syncTokenInt = [syncToken intValue];
|
||||||
|
|
||||||
qualifier = [EOQualifier qualifierWithQualifierFormat:
|
qualifier = [EOQualifier qualifierWithQualifierFormat:
|
||||||
@"c_lastmodified > %d", syncTokenInt];
|
@"c_lastmodified > %d", syncTokenInt];
|
||||||
|
|
||||||
|
if (theStartDate)
|
||||||
|
{
|
||||||
|
EOQualifier *sinceDateQualifier = [EOQualifier qualifierWithQualifierFormat:
|
||||||
|
@"c_creationdate > %d", (int)[theStartDate timeIntervalSince1970]];
|
||||||
|
|
||||||
|
qualifier = [[EOAndQualifier alloc] initWithQualifiers: sinceDateQualifier, qualifier,
|
||||||
|
nil];
|
||||||
|
[qualifier autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
mRecords = [NSMutableArray arrayWithArray: [self _fetchFields: fields
|
mRecords = [NSMutableArray arrayWithArray: [self _fetchFields: fields
|
||||||
withQualifier: qualifier
|
withQualifier: qualifier
|
||||||
ignoreDeleted: YES]];
|
ignoreDeleted: YES]];
|
||||||
|
@ -1145,10 +1158,24 @@ static NSArray *childRecordFields = nil;
|
||||||
qualifier = [EOQualifier qualifierWithQualifierFormat: filter];
|
qualifier = [EOQualifier qualifierWithQualifierFormat: filter];
|
||||||
else
|
else
|
||||||
qualifier = nil;
|
qualifier = nil;
|
||||||
records = [self _fetchFields: fields withQualifier: qualifier
|
|
||||||
|
if (theStartDate)
|
||||||
|
{
|
||||||
|
EOQualifier *sinceDateQualifier = [EOQualifier qualifierWithQualifierFormat:
|
||||||
|
@"c_creationdate > %d", (int)[theStartDate timeIntervalSince1970]];
|
||||||
|
|
||||||
|
qualifier = [[EOAndQualifier alloc] initWithQualifiers: sinceDateQualifier, qualifier,
|
||||||
|
nil];
|
||||||
|
[qualifier autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
|
records = [self _fetchFields: fields
|
||||||
|
withQualifier: qualifier
|
||||||
ignoreDeleted: YES];
|
ignoreDeleted: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return records;
|
return records;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1407,7 +1434,8 @@ static NSArray *childRecordFields = nil;
|
||||||
firstElementWithTag: @"prop" inNamespace: XMLNS_WEBDAV];
|
firstElementWithTag: @"prop" inNamespace: XMLNS_WEBDAV];
|
||||||
properties = [self parseDAVRequestedProperties: propElement];
|
properties = [self parseDAVRequestedProperties: propElement];
|
||||||
records = [self syncTokenFieldsWithProperties: properties
|
records = [self syncTokenFieldsWithProperties: properties
|
||||||
matchingSyncToken: syncToken];
|
matchingSyncToken: syncToken
|
||||||
|
fromDate: nil];
|
||||||
[self _appendComponentProperties: [properties allKeys]
|
[self _appendComponentProperties: [properties allKeys]
|
||||||
fromRecords: records
|
fromRecords: records
|
||||||
matchingSyncToken: [syncToken intValue]
|
matchingSyncToken: [syncToken intValue]
|
||||||
|
|
Loading…
Reference in New Issue