Extended GetItemEstimate to GCS collections

pull/17/head
Ludovic Marcotte 2014-02-05 16:12:08 -05:00
parent 1a7fc2a0e9
commit b8610b3eca
1 changed files with 32 additions and 23 deletions

View File

@ -568,20 +568,17 @@ 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; NSString *collectionId, *realCollectionId;
EOAndQualifier *qualifier;
NSCalendarDate *filter;
id currentCollection; id currentCollection;
NSMutableString *s; NSMutableString *s;
NSArray *uids;
NSData *d; NSData *d;
SOGoMicrosoftActiveSyncFolderType folderType; SOGoMicrosoftActiveSyncFolderType folderType;
int status; int status, count;
s = [NSMutableString string]; s = [NSMutableString string];
status = 1; status = 1;
count = 0;
collectionId = [[(id)[theDocumentElement getElementsByTagName: @"CollectionId"] lastObject] textValue]; collectionId = [[(id)[theDocumentElement getElementsByTagName: @"CollectionId"] lastObject] textValue];
realCollectionId = [collectionId realCollectionIdWithFolderType: &folderType]; realCollectionId = [collectionId realCollectionIdWithFolderType: &folderType];
@ -594,29 +591,41 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// * SORT 124576 124577 124579 124578 // * SORT 124576 124577 124579 124578
// . OK Completed (4 msgs in 0.000 secs) // . OK Completed (4 msgs in 0.000 secs)
// //
filter = [NSCalendarDate dateFromFilterType: [[(id)[theDocumentElement getElementsByTagName: @"FilterType"] lastObject] textValue]]; if (folderType == ActiveSyncMailFolder)
{
notDeletedQualifier = [EOQualifier qualifierWithQualifierFormat: EOQualifier *notDeletedQualifier, *sinceDateQualifier;
@"(not (flags = %@))", EOAndQualifier *qualifier;
@"deleted"]; NSCalendarDate *filter;
sinceDateQualifier = [EOQualifier qualifierWithQualifierFormat: NSArray *uids;
@"(DATE >= %@)", filter];
filter = [NSCalendarDate dateFromFilterType: [[(id)[theDocumentElement getElementsByTagName: @"FilterType"] lastObject] textValue]];
qualifier = [[EOAndQualifier alloc] initWithQualifiers: notDeletedQualifier, sinceDateQualifier,
nil]; notDeletedQualifier = [EOQualifier qualifierWithQualifierFormat:
AUTORELEASE(qualifier); @"(not (flags = %@))",
@"deleted"];
uids = [currentCollection fetchUIDsMatchingQualifier: qualifier sinceDateQualifier = [EOQualifier qualifierWithQualifierFormat:
sortOrdering: @"REVERSE ARRIVAL" @"(DATE >= %@)", filter];
threaded: NO];
qualifier = [[EOAndQualifier alloc] initWithQualifiers: notDeletedQualifier, sinceDateQualifier,
nil];
AUTORELEASE(qualifier);
uids = [currentCollection fetchUIDsMatchingQualifier: qualifier
sortOrdering: @"REVERSE ARRIVAL"
threaded: NO];
count = [uids count];
}
else
{
count = [[currentCollection toOneRelationshipKeys] count];
}
[s appendString: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"]; [s appendString: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"];
[s appendString: @"<!DOCTYPE ActiveSync PUBLIC \"-//MICROSOFT//DTD ActiveSync//EN\" \"http://www.microsoft.com/\">"]; [s appendString: @"<!DOCTYPE ActiveSync PUBLIC \"-//MICROSOFT//DTD ActiveSync//EN\" \"http://www.microsoft.com/\">"];
[s appendFormat: @"<GetItemEstimate xmlns=\"GetItemEstimate:\"><Response><Status>%d</Status><Collection>", status]; [s appendFormat: @"<GetItemEstimate xmlns=\"GetItemEstimate:\"><Response><Status>%d</Status><Collection>", status];
[s appendFormat: @"<CollectionId>%@</CollectionId>", collectionId]; [s appendFormat: @"<CollectionId>%@</CollectionId>", collectionId];
[s appendFormat: @"<Estimate>%d</Estimate>", [uids count]]; [s appendFormat: @"<Estimate>%d</Estimate>", count];
[s appendString: @"</Collection></Response></GetItemEstimate>"]; [s appendString: @"</Collection></Response></GetItemEstimate>"];