From 7cffd286083f91d94eada125cd4e19cf91fdb656 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 8 Jul 2008 15:40:07 +0000 Subject: [PATCH 1/4] Monotone-Parent: 10716bba581bb0dd4ad881e814040b2adb37ba10 Monotone-Revision: 54264028f33a54d13b69aeb1d296454517d33171 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-07-08T15:40:07 Monotone-Branch: ca.inverse.sogo --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 522a6f85f..1e6861d82 100755 --- a/configure +++ b/configure @@ -268,7 +268,7 @@ genConfigMake() { cfgwrite "" UNAME=`uname` if [ "X${UNAME}" = "XLinux" ];then - UNAME=`uname -p` + UNAME=`uname -m` if [ ${UNAME} = x86_64 -o ${UNAME} = sparc64 -o ${UNAME} = ppc64 ];then cfgwrite "CGS_LIBDIR_NAME:=lib64" else From 1aa527535b885ace3836779c1b188f330cd8dd58 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 8 Jul 2008 15:40:47 +0000 Subject: [PATCH 2/4] Monotone-Parent: 54264028f33a54d13b69aeb1d296454517d33171 Monotone-Revision: 2e93af5446f533d239d1daf98838f4049e3256a0 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-07-08T15:40:47 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 7 +++++++ SoObjects/Appointments/SOGoCalendarComponent.m | 16 +++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79deaa84c..e78b9f2a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-07-08 Wolfgang Sourdeau + + * SoObjects/Appointments/SOGoCalendarComponent.m + ([SOGoCalendarComponent + -sendEMailUsingTemplateNamed:_pageNameforOldObject:_oldObjectandNewObject:_newObjecttoAttendees:_attendees]): + take the current user as originator rather than the object's owner. + 2008-07-04 Wolfgang Sourdeau * SoObjects/SOGo/SOGoObject.m ([SOGoObject diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index 636193bb0..813a1c5af 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -256,8 +256,7 @@ static BOOL sendEMailNotifications = NO; toAttendees: (NSArray *) _attendees { NSString *pageName; - iCalPerson *organizer; - NSString *email, *sender, *iCalString; + NSString *senderEmail, *shortSenderEmail, *email, *iCalString; WOApplication *app; unsigned i, count; iCalPerson *attendee; @@ -268,6 +267,7 @@ static BOOL sendEMailNotifications = NO; NGMimeMessage *msg; NGMimeBodyPart *bodyPart; NGMimeMultipartBody *body; + SOGoUser *currentUser; if (sendEMailNotifications && [_newObject isStillRelevant]) @@ -276,11 +276,13 @@ static BOOL sendEMailNotifications = NO; if (count) { /* sender */ - organizer = [_newObject organizer]; - sender = [organizer mailAddress]; + currentUser = [context activeUser]; + shortSenderEmail = [[currentUser allEmails] objectAtIndex: 0]; + senderEmail = [NSString stringWithFormat: @"%@ <%@>", + [currentUser cn], shortSenderEmail]; NSLog (@"sending '%@' from %@", - [(iCalCalendar *) [_newObject parent] method], organizer); + [(iCalCalendar *) [_newObject parent] method], senderEmail); /* generate iCalString once */ iCalString = [[_newObject parent] versitString]; @@ -324,7 +326,7 @@ static BOOL sendEMailNotifications = NO; * so we'll stick with multipart/mixed for the time being. */ [headerMap setObject: @"multipart/mixed" forKey: @"content-type"]; - [headerMap setObject: sender forKey: @"from"]; + [headerMap setObject: senderEmail forKey: @"from"]; [headerMap setObject: recipient forKey: @"to"]; mailDate = [[NSCalendarDate date] rfc822DateString]; [headerMap setObject: mailDate forKey: @"date"]; @@ -364,7 +366,7 @@ static BOOL sendEMailNotifications = NO; [[SOGoMailer sharedMailer] sendMimePart: msg toRecipients: [NSArray arrayWithObject: email] - sender: [organizer rfc822Email]]; + sender: shortSenderEmail]; } } } From 804c05e92df0fed955eb141bba3a29fffeb264c2 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 8 Jul 2008 15:42:40 +0000 Subject: [PATCH 3/4] Monotone-Parent: 2e93af5446f533d239d1daf98838f4049e3256a0 Monotone-Revision: a12bd5b03a0fa8ed21ec4b06e2b7b59ddf2c3ca2 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-07-08T15:42:40 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 + .../Appointments/SOGoAppointmentObject.h | 5 + .../Appointments/SOGoAppointmentObject.m | 109 ++++++++++++++---- 3 files changed, 96 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index e78b9f2a7..e9288f130 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2008-07-08 Wolfgang Sourdeau + * SoObjects/Appointments/SOGoAppointmentObject.m + ([SOGoAppointmentObject -postCalDAVEventReplyTo:recipients]): new + method that handle CalDAV REPLY posts by updating the event in the + table of the SOGo users and send the reply by email as well. + * SoObjects/Appointments/SOGoCalendarComponent.m ([SOGoCalendarComponent -sendEMailUsingTemplateNamed:_pageNameforOldObject:_oldObjectandNewObject:_newObjecttoAttendees:_attendees]): diff --git a/SoObjects/Appointments/SOGoAppointmentObject.h b/SoObjects/Appointments/SOGoAppointmentObject.h index 7b3b23795..90f720f98 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.h +++ b/SoObjects/Appointments/SOGoAppointmentObject.h @@ -48,6 +48,11 @@ - (NSException *) changeParticipationStatus: (NSString *) _status; +- (void) takeAttendeeStatus: (iCalPerson *) attendee; + +- (NSArray *) postCalDAVEventRequestTo: (NSArray *) recipients; +- (NSArray *) postCalDAVEventReplyTo: (NSArray *) recipients; + /* "iCal multifolder saves" */ // - (NSException *) saveContentString: (NSString *) _iCal diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index 324ca8d76..e106ceb06 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -415,31 +415,94 @@ event = [self component: NO secure: NO]; recipientsEnum = [recipients objectEnumerator]; while ((recipient = [recipientsEnum nextObject])) - { - if ([[recipient lowercaseString] hasPrefix: @"mailto:"]) - { - person = [iCalPerson new]; - [person setValue: 0 to: recipient]; - uid = [person uid]; - if (uid) - [self _addOrUpdateEvent: event forUID: uid]; + if ([[recipient lowercaseString] hasPrefix: @"mailto:"]) + { + person = [iCalPerson new]; + [person setValue: 0 to: recipient]; + uid = [person uid]; + if (uid) + [self _addOrUpdateEvent: event forUID: uid]; #warning fix this when sendEmailUsing blabla has been cleaned up - [self sendEMailUsingTemplateNamed: @"Invitation" - forOldObject: nil - andNewObject: event - toAttendees: [NSArray arrayWithObject: person]]; - [person release]; - element = [NSMutableArray new]; - [element addObject: davElementWithContent (@"recipient", XMLNS_CALDAV, - recipient)]; - [element addObject: davElementWithContent (@"request-status", - XMLNS_CALDAV, - @"2.0;Success")]; - [elements addObject: davElementWithContent (@"response", XMLNS_CALDAV, - element)]; - [element release]; - } + [self sendEMailUsingTemplateNamed: @"Invitation" + forOldObject: nil andNewObject: event + toAttendees: [NSArray arrayWithObject: person]]; + [person release]; + element = [NSMutableArray new]; + [element addObject: davElementWithContent (@"recipient", XMLNS_CALDAV, + recipient)]; + [element addObject: davElementWithContent (@"request-status", + XMLNS_CALDAV, + @"2.0;Success")]; + [elements addObject: davElementWithContent (@"response", XMLNS_CALDAV, + element)]; + [element release]; + } + + return elements; +} + +- (void) takeAttendeeStatus: (iCalPerson *) attendee +{ + iCalPerson *localAttendee; + iCalEvent *event; + + event = [self component: NO secure: NO]; + localAttendee = [event findParticipantWithEmail: [attendee rfc822Email]]; + if (localAttendee) + { + [localAttendee setPartStat: [attendee partStat]]; + [self saveComponent: event]; } + else + [self errorWithFormat: @"attendee not found: '%@'", attendee]; +} + +- (NSArray *) postCalDAVEventReplyTo: (NSArray *) recipients +{ + NSMutableArray *elements, *element; + NSEnumerator *recipientsEnum; + NSString *recipient, *uid, *eventUID; + iCalEvent *event; + iCalPerson *attendee, *person; + SOGoAppointmentObject *recipientEvent; + SOGoUser *ownerUser; + + elements = [NSMutableArray array]; + event = [self component: NO secure: NO]; + ownerUser = [SOGoUser userWithLogin: owner roles: nil]; + attendee = [event findParticipant: ownerUser]; + eventUID = [event uid]; + + recipientsEnum = [recipients objectEnumerator]; + while ((recipient = [recipientsEnum nextObject])) + if ([[recipient lowercaseString] hasPrefix: @"mailto:"]) + { + person = [iCalPerson new]; + [person setValue: 0 to: recipient]; + uid = [person uid]; + if (uid) + { + recipientEvent = [self _lookupEvent: eventUID forUID: uid]; + if ([recipientEvent isNew]) + [recipientEvent saveComponent: event]; + else + [recipientEvent takeAttendeeStatus: attendee]; + } +#warning fix this when sendEmailUsing blabla has been cleaned up + [self sendEMailUsingTemplateNamed: @"ICalReply" + forOldObject: nil andNewObject: event + toAttendees: [NSArray arrayWithObject: person]]; + [person release]; + element = [NSMutableArray new]; + [element addObject: davElementWithContent (@"recipient", XMLNS_CALDAV, + recipient)]; + [element addObject: davElementWithContent (@"request-status", + XMLNS_CALDAV, + @"2.0;Success")]; + [elements addObject: davElementWithContent (@"response", XMLNS_CALDAV, + element)]; + [element release]; + } return elements; } From ed9611678b22e80e272d11f1b73c8e63b605e0f5 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 8 Jul 2008 15:44:50 +0000 Subject: [PATCH 4/4] Monotone-Parent: a12bd5b03a0fa8ed21ec4b06e2b7b59ddf2c3ca2 Monotone-Revision: 4919aeeff629dcb3750bd1e1f28cf06348a5da02 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-07-08T15:44:50 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 ++ .../Appointments/SOGoAppointmentFolder.m | 89 ++++--------------- 2 files changed, 21 insertions(+), 73 deletions(-) diff --git a/ChangeLog b/ChangeLog index e9288f130..26d43123b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2008-07-08 Wolfgang Sourdeau + * SoObjects/Appointments/SOGoAppointmentFolder.m + ([SOGoAppointmentFolder + -caldavEventRequest:eventwithContent:iCalStringfrom:originatorto:recipients]): + simplified method since REPLY and REQUEST posts are very similar. + * SoObjects/Appointments/SOGoAppointmentObject.m ([SOGoAppointmentObject -postCalDAVEventReplyTo:recipients]): new method that handle CalDAV REPLY posts by updating the event in the diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 1ec40a0fc..658cd6a52 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -1732,89 +1732,32 @@ _selectorForProperty (NSString *property) return responseElement; } -- (NSDictionary *) _postCalDAVEventRequest: (NSString *) iCalString - withUID: (NSString *) uid - to: (NSArray *) recipients -{ - NSString *filename; - SOGoAppointmentObject *apt; - NSDictionary *responseElement; - NSMutableArray *elements; - - filename = [NSString stringWithFormat: @"%@.ics", uid]; - apt = [SOGoAppointmentObject objectWithName: filename - andContent: iCalString - inContainer: self]; - elements = [apt postCalDAVEventRequestTo: recipients]; - responseElement = davElementWithContent (@"schedule-response", - XMLNS_CALDAV, elements); - - return responseElement; -} - -- (NSDictionary *) _postCalDAVEventReply: (iCalEvent *) event - from: (NSString *) originator -{ - NSDictionary *responseElement, *attendeeCode; - NSMutableArray *content; - iCalPerson *attendee; - NSException *ex; - SOGoAppointmentObject *apt; - - /* this is a fake success status */ - apt = [self lookupComponentByUID: [event uid]]; - if ([apt isKindOfClass: [SOGoAppointmentObject class]]) - { - content = [NSMutableArray new]; - [content addObject: davElementWithContent (@"recipient", XMLNS_CALDAV, - originator)]; - -#warning cleanup: add a method to POST replies from CalDAV from SOGoAppointmentObject - attendee = [event findParticipant: [context activeUser]]; - if (attendee) - { - ex = [apt changeParticipationStatus: [attendee partStat]]; - if (ex) - attendeeCode = davElementWithContent (@"request-status", XMLNS_CALDAV, - @"3.1;Invalid property value"); - else - attendeeCode = davElementWithContent (@"request-status", XMLNS_CALDAV, - @"2.0;Success"); - } - else - attendeeCode = davElementWithContent (@"request-status", XMLNS_CALDAV, - @"3.7;Invalid Calendar User"); - [content addObject: attendeeCode]; - - responseElement - = davElementWithContent (@"schedule-response", XMLNS_CALDAV, - davElementWithContent (@"response", XMLNS_CALDAV, - content)); - [content release]; - } - else - responseElement = nil; - - return responseElement; -} - +#warning we should merge this code with the code from the iTIP interpreter in MailPartViewer - (NSDictionary *) caldavEventRequest: (iCalEvent *) event withContent: (NSString *) iCalString from: (NSString *) originator to: (NSArray *) recipients { NSDictionary *responseElement; - NSString *method; + NSArray *elements; + NSString *method, *filename; + SOGoAppointmentObject *apt; + filename = [NSString stringWithFormat: @"%@.ics", [event uid]]; + apt = [SOGoAppointmentObject objectWithName: filename + andContent: iCalString + inContainer: self]; method = [[event parent] method]; if ([method isEqualToString: @"REQUEST"]) - responseElement = [self _postCalDAVEventRequest: iCalString - withUID: [event uid] - to: recipients]; + elements = [apt postCalDAVEventRequestTo: recipients]; else if ([method isEqualToString: @"REPLY"]) - responseElement = [self _postCalDAVEventReply: event - withUID: [event uid] - from: originator]; + elements = [apt postCalDAVEventReplyTo: recipients]; + else + elements = nil; + + if (elements) + responseElement = davElementWithContent (@"schedule-response", + XMLNS_CALDAV, elements); else responseElement = nil;