diff --git a/ActiveSync/iCalRecurrenceRule+ActiveSync.m b/ActiveSync/iCalRecurrenceRule+ActiveSync.m index ca17fcff9..5521a2ce7 100644 --- a/ActiveSync/iCalRecurrenceRule+ActiveSync.m +++ b/ActiveSync/iCalRecurrenceRule+ActiveSync.m @@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #import #import +#import #import #import @@ -59,11 +60,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - (NSString *) activeSyncRepresentationInContext: (WOContext *) context { NSMutableString *s; + NSString *t; int type; s = [NSMutableString string]; - - [s appendString: @""]; + + if ([[self parent] isKindOfClass: [iCalToDo class]]) + t = @"Tasks"; + else + t = @"Calendar"; + + [s appendFormat: @"", t]; // 0 -> daily, 1 -> weekly, 2 -> montly, 5 -> yearly type = 0; @@ -75,11 +82,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // 1 -> sunday, 2 -> monday, 4 -> tuesday, 8 -> wednesday, 16 -> thursday, 32 -> friday, 64 -> saturday, 127 -> last day of month (montly or yearl recurrences only) if ([[self byDayMask] isWeekDays]) { - [s appendFormat: @"%d", (2|4|8|16|32)]; + [s appendFormat: @"%d", t, (2|4|8|16|32)]; } else { - [s appendFormat: @"%d", [self repeatInterval]]; + [s appendFormat: @"%d", t, [self repeatInterval]]; } } else if ([self frequency] == iCalRecurrenceFrequenceWeekly) @@ -107,8 +114,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. v = (1 << [[self _adjustedStartDate] dayOfWeek]); } - [s appendFormat: @"%d", v]; - [s appendFormat: @"%d", [self repeatInterval]]; + [s appendFormat: @"%d", t, v]; + [s appendFormat: @"%d", t, [self repeatInterval]]; } else if ([self frequency] == iCalRecurrenceFrequenceMonthly) { @@ -125,8 +132,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if (firstOccurrence < 0) firstOccurrence = 5; - [s appendFormat: @"%d", (1 << [dm firstDay])]; - [s appendFormat: @"%d", firstOccurrence]; + [s appendFormat: @"%d", t, (1 << [dm firstDay])]; + [s appendFormat: @"%d", t, firstOccurrence]; } else if ([[self byMonthDay] count]) { @@ -140,8 +147,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. iCalByDayMask *dm; dm = [self byDayMask]; - [s appendFormat: @"%d", (1 << [dm firstDay])]; - [s appendFormat: @"%d", 5]; + [s appendFormat: @"%d", t, (1 << [dm firstDay])]; + [s appendFormat: @"%d", t, 5]; } else { @@ -153,7 +160,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. { // Simple reccurrence rule of type "Monthly" type = 2; - [s appendFormat: @"%d", [[self _adjustedStartDate] dayOfMonth]]; + [s appendFormat: @"%d", t, [[self _adjustedStartDate] dayOfMonth]]; } } else if ([self frequency] == iCalRecurrenceFrequenceYearly) @@ -172,38 +179,39 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. if (firstOccurrence < 0) firstOccurrence = 5; - [s appendFormat: @"%d", (1 << [dm firstDay])]; - [s appendFormat: @"%d", firstOccurrence]; - [s appendFormat: @"%@", + [s appendFormat: @"%d", t, (1 << [dm firstDay])]; + [s appendFormat: @"%d", t, firstOccurrence]; + [s appendFormat: @"%@", t, [self flattenedValuesForKey: @"bymonth"]]; } else { type = 5; // Yearly - [s appendFormat: @"%@", + [s appendFormat: @"%@", t, [self flattenedValuesForKey: @"bymonthday"]]; - [s appendFormat: @"%@", + [s appendFormat: @"%@", t, [self flattenedValuesForKey: @"bymonth"]]; } } else { type = 5; - [s appendFormat: @"%d", [[self _adjustedStartDate] dayOfMonth]]; - [s appendFormat: @"%d", [[self _adjustedStartDate] monthOfYear]]; - + [s appendFormat: @"%d", t, [[self _adjustedStartDate] dayOfMonth]]; + [s appendFormat: @"%d", t, [[self _adjustedStartDate] monthOfYear]]; } } - [s appendFormat: @"%d", type]; + [s appendFormat: @"%d", t, type]; + + if ([[self parent] isKindOfClass: [iCalToDo class]]) + [s appendFormat: @"%@", t, [[[self parent] startDate] activeSyncRepresentationInContext: context]]; // Occurrences / Until - //[s appendFormat: @"%d", 5]; if ([self repeatCount]) { - [s appendFormat: @"%@", + [s appendFormat: @"%@", t, [self flattenedValuesForKey: @"count"]]; } else if ([self untilDate]) @@ -214,11 +222,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //ud = [[context activeUser] userDefaults]; //[date setTimeZone: [ud timeZone]]; - [s appendFormat: @"%@", + [s appendFormat: @"%@", t, [date activeSyncRepresentationWithoutSeparatorsInContext: context]]; } - [s appendString: @""]; return s; diff --git a/ActiveSync/iCalToDo+ActiveSync.m b/ActiveSync/iCalToDo+ActiveSync.m index 3db426146..41269802d 100644 --- a/ActiveSync/iCalToDo+ActiveSync.m +++ b/ActiveSync/iCalToDo+ActiveSync.m @@ -45,7 +45,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "NSDate+ActiveSync.h" #include "NSString+ActiveSync.h" - +#include "iCalRecurrenceRule+ActiveSync.h" @implementation iCalToDo (ActiveSync) @@ -80,6 +80,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [s appendFormat: @"%@", [o activeSyncRepresentationInContext: context]]; [s appendFormat: @"%@", [o activeSyncRepresentationInContext: context]]; } + + // Recurrence rules + if ([self isRecurrent]) + [s appendString: [[[self recurrenceRules] lastObject] activeSyncRepresentationInContext: context]]; // Importance o = [self priority]; @@ -247,6 +251,29 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. { } + + // Recurrence + if ((o = [theValues objectForKey: @"Recurrence"]) && !([[o objectForKey: @"Recurrence_DeadOccur"] intValue])) + { + iCalRecurrenceRule *rule; + + rule = [[iCalRecurrenceRule alloc] init]; + [self setRecurrenceRules: [NSArray arrayWithObject: rule]]; + RELEASE(rule); + + [rule takeActiveSyncValues: o inContext: context]; + + if (!([theValues objectForKey: @"StartDate"])) + { + iCalDateTime *start; + + start = (iCalDateTime *) [self uniqueChildWithTag: @"dtstart"]; + + [start setTimeZone: tz]; + [start setDate: [[o objectForKey: @"Recurrence_Start"] calendarDate]]; + } + } + } @end