diff --git a/ChangeLog b/ChangeLog index f9f799d1e..4cb6edd32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-02-05 Wolfgang Sourdeau + + * UI/MailPartViewers/UIxMailPartICalActions.m ([UIxMailPartICalActions -acceptAction]) + ([UIxMailPartICalActions -declineAction]): define the organizer of + the event as one of the reply-to or from addresses whenever the + organizer is not specified in those Outlook invitations. + 2008-02-01 Wolfgang Sourdeau * UI/MailerUI/UIxMailMainFrame.m ([UIxMailMainFrame diff --git a/UI/MailPartViewers/UIxMailPartICalActions.m b/UI/MailPartViewers/UIxMailPartICalActions.m index e695de0df..6d91a5fcd 100644 --- a/UI/MailPartViewers/UIxMailPartICalActions.m +++ b/UI/MailPartViewers/UIxMailPartICalActions.m @@ -25,6 +25,9 @@ #import #import +#import +#import + #import #import #import @@ -93,10 +96,46 @@ return [self _eventObjectWithUID: uid forUser: [context activeUser]]; } +- (void) _fixOrganizerInEvent: (iCalEvent *) brokenEvent +{ + iCalPerson *organizer; + SOGoMailObject *mail; + NSArray *addresses; + NGImap4EnvelopeAddress *from; + id value; + + organizer = nil; + + mail = [[self clientObject] mailObject]; + + addresses = [mail replyToEnvelopeAddresses]; + if (![addresses count]) + addresses = [mail fromEnvelopeAddresses]; + if ([addresses count] > 0) + { + from = [addresses objectAtIndex: 0]; + value = [from baseEMail]; + if ([value isNotNull]) + { + organizer = [iCalPerson elementWithTag: @"organizer"]; + [organizer setEmail: value]; + value = [from personalName]; + if ([value isNotNull]) + [organizer setCn: value]; + [brokenEvent setOrganizer: organizer]; + } + } + + if (!organizer) + [self errorWithFormat: @"no organizer could be found, SOGo will crash" + @" if the user replies"]; +} + - (iCalEvent *) _setupChosenEventAndEventObject: (SOGoAppointmentObject **) eventObject { iCalEvent *emailEvent, *calendarEvent, *chosenEvent; + iCalPerson *organizer; emailEvent = [self _emailEvent]; if (emailEvent) @@ -113,6 +152,10 @@ else chosenEvent = calendarEvent; } + + organizer = [chosenEvent organizer]; + if (![[organizer rfc822Email] length]) + [self _fixOrganizerInEvent: chosenEvent]; } else chosenEvent = nil;