We now order correctly CardGroups - especially for calendars.

This is to avoid a bug in BlackBerry devices where the METHOD
must be placed BEFORE any vevent/vtimezone objects, otherwise
the invitation objects are never recognized, and rather shown
as a "application/x-rimdevicecalendar" attachment.
pull/7/head
Ludovic Marcotte 2012-11-13 13:58:05 -05:00
parent 48b6cbcf0c
commit 51192dd533
8 changed files with 43 additions and 25 deletions

View File

@ -1,6 +1,6 @@
/* CardElement.h - this file is part of SOPE /* CardElement.h - this file is part of SOPE
* *
* Copyright (C) 2006 Inverse inc. * Copyright (C) 2006-2012 Inverse inc.
* *
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca> * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *

View File

@ -1,6 +1,6 @@
/* CardElement.m - this file is part of SOPE /* CardElement.m - this file is part of SOPE
* *
* Copyright (C) 2006 Inverse inc. * Copyright (C) 2006-2012 Inverse inc.
* *
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca> * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *

View File

@ -75,6 +75,8 @@
- (void) replaceThisElement: (CardElement *) oldElement - (void) replaceThisElement: (CardElement *) oldElement
withThisOne: (CardElement *) newElement; withThisOne: (CardElement *) newElement;
- (NSArray *) orderOfElements;
@end @end
#endif /* CARDGROUP_H */ #endif /* CARDGROUP_H */

View File

@ -1,6 +1,6 @@
/* CardGroup.m - this file is part of SOPE /* CardGroup.m - this file is part of SOPE
* *
* Copyright (C) 2006 Inverse inc. * Copyright (C) 2006-2012 Inverse inc.
* *
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca> * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *
@ -454,4 +454,9 @@ static NGCardsSaxHandler *sax = nil;
return new; return new;
} }
- (NSArray *) orderOfElements
{
return nil;
}
@end @end

View File

@ -1,6 +1,6 @@
/* CardVersitRenderer.m - this file is part of SOPE /* CardVersitRenderer.m - this file is part of SOPE
* *
* Copyright (C) 2006 Inverse inc. * Copyright (C) 2006-2012 Inverse inc.
* *
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca> * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
* *
@ -107,6 +107,7 @@
CardElement *currentChild; CardElement *currentChild;
NSMutableString *rendering; NSMutableString *rendering;
NSString *groupTag; NSString *groupTag;
NSArray *order;
rendering = [NSMutableString string]; rendering = [NSMutableString string];
@ -120,7 +121,30 @@
groupTag = [groupTag uppercaseString]; groupTag = [groupTag uppercaseString];
[rendering appendFormat: @"BEGIN:%@\r\n", groupTag]; [rendering appendFormat: @"BEGIN:%@\r\n", groupTag];
children = [[aGroup children] objectEnumerator];
// We reorder the group elemments, if necessary
order = [aGroup orderOfElements];
if (order)
{
NSMutableArray *orderedElements;
int i, c;
orderedElements = [NSMutableArray array];
c = [order count];
for (i = 0; i < c; i++)
{
[orderedElements addObjectsFromArray: [aGroup childrenWithTag: [order objectAtIndex: i]]];
}
children = [orderedElements objectEnumerator];
}
else
{
children = [[aGroup children] objectEnumerator];
}
while ((currentChild = [children nextObject])) while ((currentChild = [children nextObject]))
[rendering appendString: [self render: currentChild]]; [rendering appendString: [self render: currentChild]];
[rendering appendFormat: @"END:%@\r\n", groupTag]; [rendering appendFormat: @"END:%@\r\n", groupTag];

View File

@ -38,18 +38,6 @@
@class iCalTimeZone; @class iCalTimeZone;
@interface iCalCalendar : CardGroup @interface iCalCalendar : CardGroup
// {
// NSString *version;
// NSString *calscale;
// NSString *prodId;
// NSString *method;
// NSMutableArray *todos;
// NSMutableArray *events;
// NSMutableArray *journals;
// NSMutableArray *freeBusys;
// NSMutableDictionary *timezones;
// }
/* accessors */ /* accessors */

View File

@ -210,6 +210,13 @@
return [super versitString]; return [super versitString];
} }
- (NSArray *) orderOfElements
{
return [NSArray arrayWithObjects: @"prodid", @"version", @"method", @"calscale",
@"vtimezone", @"vevent", @"vtodo", @"vjournal", @"vfreebusy", nil];
}
/* ical typing */ /* ical typing */
- (NSString *) entityName - (NSString *) entityName

View File

@ -410,14 +410,6 @@
previousObject: oldEvent previousObject: oldEvent
toAttendees: updateAttendees toAttendees: updateAttendees
withType: @"calendar:invitation-update"]; withType: @"calendar:invitation-update"];
#if 0
// DELETE CODE
[self sendReceiptEmailForObject: newEvent
addedAttendees: nil
deletedAttendees: nil
updatedAttendees: updateAttendees];
#endif
} }
// //