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
*
* Copyright (C) 2006 Inverse inc.
* Copyright (C) 2006-2012 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*

View File

@ -1,6 +1,6 @@
/* 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>
*

View File

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

View File

@ -1,6 +1,6 @@
/* 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>
*
@ -454,4 +454,9 @@ static NGCardsSaxHandler *sax = nil;
return new;
}
- (NSArray *) orderOfElements
{
return nil;
}
@end

View File

@ -1,6 +1,6 @@
/* 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>
*
@ -107,6 +107,7 @@
CardElement *currentChild;
NSMutableString *rendering;
NSString *groupTag;
NSArray *order;
rendering = [NSMutableString string];
@ -120,7 +121,30 @@
groupTag = [groupTag uppercaseString];
[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]))
[rendering appendString: [self render: currentChild]];
[rendering appendFormat: @"END:%@\r\n", groupTag];

View File

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

View File

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

View File

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