Monotone-Parent: 5bdd362f0346da09b105a6a7054e67410a0dcee5
Monotone-Revision: 53f6a0a8eb5d41aa85332c3cc20b7eeca0bb9da7 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2011-08-08T19:02:49 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
parent
8b8f079992
commit
cec8d052af
|
@ -1,5 +1,9 @@
|
||||||
2011-08-08 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2011-08-08 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* OpenChange/MAPIStoreCalendarMessage.m (-save): fixed attendees
|
||||||
|
handling (only change the attendee partstat) and avoid saving the
|
||||||
|
event when the newpartstat is "undefined".
|
||||||
|
|
||||||
* OpenChange/MAPIStoreAppointmentWrapper.m
|
* OpenChange/MAPIStoreAppointmentWrapper.m
|
||||||
(-getPrOwnerApptId:inMemCtx:): properly reimplemented the method
|
(-getPrOwnerApptId:inMemCtx:): properly reimplemented the method
|
||||||
following the spec.
|
following the spec.
|
||||||
|
|
|
@ -113,12 +113,24 @@
|
||||||
return [[self appointmentWrapper] getPrMessageClass: data inMemCtx: memCtx];
|
return [[self appointmentWrapper] getPrMessageClass: data inMemCtx: memCtx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (int) getPrOwnerApptId: (void **) data
|
||||||
|
inMemCtx: (TALLOC_CTX *) memCtx
|
||||||
|
{
|
||||||
|
return [[self appointmentWrapper] getPrOwnerApptId: data inMemCtx: memCtx];
|
||||||
|
}
|
||||||
|
|
||||||
- (int) getPrStartDate: (void **) data
|
- (int) getPrStartDate: (void **) data
|
||||||
inMemCtx: (TALLOC_CTX *) memCtx
|
inMemCtx: (TALLOC_CTX *) memCtx
|
||||||
{
|
{
|
||||||
return [[self appointmentWrapper] getPrStartDate: data inMemCtx: memCtx];
|
return [[self appointmentWrapper] getPrStartDate: data inMemCtx: memCtx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (int) getPidLidAppointmentStateFlags: (void **) data
|
||||||
|
inMemCtx: (TALLOC_CTX *) memCtx
|
||||||
|
{
|
||||||
|
return [[self appointmentWrapper] getPidLidAppointmentStateFlags: data inMemCtx: memCtx];
|
||||||
|
}
|
||||||
|
|
||||||
- (int) getPidLidAppointmentStartWhole: (void **) data
|
- (int) getPidLidAppointmentStartWhole: (void **) data
|
||||||
inMemCtx: (TALLOC_CTX *) memCtx
|
inMemCtx: (TALLOC_CTX *) memCtx
|
||||||
{
|
{
|
||||||
|
@ -313,19 +325,22 @@
|
||||||
|
|
||||||
- (void) save
|
- (void) save
|
||||||
{
|
{
|
||||||
WOContext *woContext;
|
|
||||||
iCalCalendar *vCalendar;
|
iCalCalendar *vCalendar;
|
||||||
iCalDateTime *start, *end;
|
iCalDateTime *start, *end;
|
||||||
iCalTimeZone *tz;
|
iCalTimeZone *tz;
|
||||||
NSCalendarDate *now;
|
NSCalendarDate *now;
|
||||||
NSString *content, *tzName;
|
NSString *content, *tzName;
|
||||||
iCalEvent *newEvent;
|
iCalEvent *newEvent;
|
||||||
|
iCalPerson *userPerson;
|
||||||
NSUInteger responseStatus = 0;
|
NSUInteger responseStatus = 0;
|
||||||
|
SOGoUser *activeUser;
|
||||||
id value;
|
id value;
|
||||||
|
|
||||||
[self logWithFormat: @"-save, event props:"];
|
[self logWithFormat: @"-save, event props:"];
|
||||||
// MAPIStoreDumpMessageProperties (newProperties);
|
// MAPIStoreDumpMessageProperties (newProperties);
|
||||||
|
|
||||||
|
now = [NSCalendarDate date];
|
||||||
|
|
||||||
content = [sogoObject contentAsString];
|
content = [sogoObject contentAsString];
|
||||||
if (![content length])
|
if (![content length])
|
||||||
{
|
{
|
||||||
|
@ -333,64 +348,108 @@
|
||||||
vCalendar = [newEvent parent];
|
vCalendar = [newEvent parent];
|
||||||
[vCalendar setProdID: @"-//Inverse inc.//OpenChange+SOGo//EN"];
|
[vCalendar setProdID: @"-//Inverse inc.//OpenChange+SOGo//EN"];
|
||||||
content = [vCalendar versitString];
|
content = [vCalendar versitString];
|
||||||
|
[newEvent setCreated: now];
|
||||||
}
|
}
|
||||||
|
|
||||||
vCalendar = [iCalCalendar parseSingleFromSource: content];
|
vCalendar = [iCalCalendar parseSingleFromSource: content];
|
||||||
newEvent = [[vCalendar events] objectAtIndex: 0];
|
newEvent = [[vCalendar events] objectAtIndex: 0];
|
||||||
|
|
||||||
// summary
|
activeUser = [[self context] activeUser];
|
||||||
value = [newProperties
|
userPerson = [newEvent userAsAttendee: activeUser];
|
||||||
objectForKey: MAPIPropertyKey (PR_NORMALIZED_SUBJECT_UNICODE)];
|
|
||||||
if (value)
|
|
||||||
[newEvent setSummary: value];
|
|
||||||
|
|
||||||
// Location
|
|
||||||
value = [newProperties objectForKey: MAPIPropertyKey (PidLidLocation)];
|
|
||||||
if (value)
|
|
||||||
[newEvent setLocation: value];
|
|
||||||
|
|
||||||
tzName = [[self ownerTimeZone] name];
|
|
||||||
tz = [iCalTimeZone timeZoneForName: tzName];
|
|
||||||
[vCalendar addTimeZone: tz];
|
|
||||||
|
|
||||||
// start
|
|
||||||
value = [newProperties objectForKey: MAPIPropertyKey (PR_START_DATE)];
|
|
||||||
if (!value)
|
|
||||||
value = [newProperties objectForKey: MAPIPropertyKey (PidLidAppointmentStartWhole)];
|
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
start = (iCalDateTime *) [newEvent uniqueChildWithTag: @"dtstart"];
|
|
||||||
[start setTimeZone: tz];
|
|
||||||
[start setDateTime: value];
|
|
||||||
}
|
|
||||||
|
|
||||||
// end
|
|
||||||
value = [newProperties objectForKey: MAPIPropertyKey (PR_END_DATE)];
|
|
||||||
if (!value)
|
|
||||||
value = [newProperties objectForKey: MAPIPropertyKey (PidLidAppointmentEndWhole)];
|
|
||||||
if (value)
|
|
||||||
{
|
|
||||||
end = (iCalDateTime *) [newEvent uniqueChildWithTag: @"dtend"];
|
|
||||||
[end setTimeZone: tz];
|
|
||||||
[end setDateTime: value];
|
|
||||||
}
|
|
||||||
|
|
||||||
now = [NSCalendarDate date];
|
|
||||||
if ([sogoObject isNew])
|
|
||||||
{
|
|
||||||
[newEvent setCreated: now];
|
|
||||||
}
|
|
||||||
[newEvent setTimeStampAsDate: now];
|
[newEvent setTimeStampAsDate: now];
|
||||||
|
|
||||||
// Organizer and attendees
|
if (userPerson)
|
||||||
value
|
|
||||||
= [newProperties objectForKey: MAPIPropertyKey (PidLidResponseStatus)];
|
|
||||||
if (value)
|
|
||||||
responseStatus = [value unsignedLongValue];
|
|
||||||
|
|
||||||
woContext = [[self context] woContext];
|
|
||||||
if (responseStatus == 0)
|
|
||||||
{
|
{
|
||||||
|
// iCalPersonPartStat newPartStat;
|
||||||
|
NSString *newPartStat;
|
||||||
|
|
||||||
|
value
|
||||||
|
= [newProperties objectForKey: MAPIPropertyKey (PidLidResponseStatus)];
|
||||||
|
if (value)
|
||||||
|
responseStatus = [value unsignedLongValue];
|
||||||
|
|
||||||
|
switch (responseStatus)
|
||||||
|
{
|
||||||
|
case 0x02: /* respTentative */
|
||||||
|
// newPartStat = iCalPersonPartStatTentative;
|
||||||
|
newPartStat = @"TENTATIVE";
|
||||||
|
break;
|
||||||
|
case 0x03: /* respAccepted */
|
||||||
|
// newPartStat = iCalPersonPartStatAccepted;
|
||||||
|
newPartStat = @"ACCEPTED";
|
||||||
|
break;
|
||||||
|
case 0x04: /* respDeclined */
|
||||||
|
// newPartStat = iCalPersonPartStatDeclined;
|
||||||
|
newPartStat = @"DECLINED";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
newPartStat = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newPartStat // != iCalPersonPartStatUndefined
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// iCalPerson *participant;
|
||||||
|
|
||||||
|
// participant = [newEvent userAsAttendee: activeUser];
|
||||||
|
// [participant setParticipationStatus: newPartStat];
|
||||||
|
// [sogoObject saveComponent: newEvent];
|
||||||
|
|
||||||
|
[sogoObject changeParticipationStatus: newPartStat
|
||||||
|
withDelegate: nil];
|
||||||
|
// [[self context] tearDownRequest];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[newEvent setLastModified: now];
|
||||||
|
|
||||||
|
// summary
|
||||||
|
value = [newProperties
|
||||||
|
objectForKey: MAPIPropertyKey (PR_NORMALIZED_SUBJECT_UNICODE)];
|
||||||
|
if (value)
|
||||||
|
[newEvent setSummary: value];
|
||||||
|
|
||||||
|
// Location
|
||||||
|
value = [newProperties objectForKey: MAPIPropertyKey (PidLidLocation)];
|
||||||
|
if (value)
|
||||||
|
[newEvent setLocation: value];
|
||||||
|
|
||||||
|
tzName = [[self ownerTimeZone] name];
|
||||||
|
tz = [iCalTimeZone timeZoneForName: tzName];
|
||||||
|
[vCalendar addTimeZone: tz];
|
||||||
|
|
||||||
|
// start
|
||||||
|
value = [newProperties objectForKey: MAPIPropertyKey (PR_START_DATE)];
|
||||||
|
if (!value)
|
||||||
|
value = [newProperties
|
||||||
|
objectForKey: MAPIPropertyKey (PidLidAppointmentStartWhole)];
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
start = (iCalDateTime *) [newEvent uniqueChildWithTag: @"dtstart"];
|
||||||
|
[start setTimeZone: tz];
|
||||||
|
[start setDateTime: value];
|
||||||
|
}
|
||||||
|
|
||||||
|
// end
|
||||||
|
value = [newProperties objectForKey: MAPIPropertyKey (PR_END_DATE)];
|
||||||
|
if (!value)
|
||||||
|
value = [newProperties objectForKey: MAPIPropertyKey (PidLidAppointmentEndWhole)];
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
end = (iCalDateTime *) [newEvent uniqueChildWithTag: @"dtend"];
|
||||||
|
[end setTimeZone: tz];
|
||||||
|
[end setDateTime: value];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* recurrence */
|
||||||
|
value = [newProperties
|
||||||
|
objectForKey: MAPIPropertyKey (PidLidAppointmentRecur)];
|
||||||
|
if (value)
|
||||||
|
[self _setupRecurrenceInCalendar: vCalendar
|
||||||
|
fromData: value];
|
||||||
|
|
||||||
|
// Organizer
|
||||||
value = [newProperties objectForKey: @"recipients"];
|
value = [newProperties objectForKey: @"recipients"];
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
|
@ -399,7 +458,7 @@
|
||||||
iCalPerson *person;
|
iCalPerson *person;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
dict = [[woContext activeUser] primaryIdentity];
|
dict = [activeUser primaryIdentity];
|
||||||
person = [iCalPerson new];
|
person = [iCalPerson new];
|
||||||
[person setCn: [dict objectForKey: @"fullName"]];
|
[person setCn: [dict objectForKey: @"fullName"]];
|
||||||
[person setEmail: [dict objectForKey: @"email"]];
|
[person setEmail: [dict objectForKey: @"email"]];
|
||||||
|
@ -422,48 +481,13 @@
|
||||||
// FIXME: We must NOT always rely on this
|
// FIXME: We must NOT always rely on this
|
||||||
if (![newEvent isAttendee: [person rfc822Email]])
|
if (![newEvent isAttendee: [person rfc822Email]])
|
||||||
[newEvent addToAttendees: person];
|
[newEvent addToAttendees: person];
|
||||||
|
|
||||||
[person release];
|
[person release];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[sogoObject saveComponent: newEvent];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
iCalPersonPartStat newPartStat;
|
|
||||||
|
|
||||||
switch (responseStatus)
|
|
||||||
{
|
|
||||||
case 0x02: /* respTentative */
|
|
||||||
newPartStat = iCalPersonPartStatTentative;
|
|
||||||
break;
|
|
||||||
case 0x03: /* respAccepted */
|
|
||||||
newPartStat = iCalPersonPartStatAccepted;
|
|
||||||
break;
|
|
||||||
case 0x04: /* respDeclined */
|
|
||||||
newPartStat = iCalPersonPartStatDeclined;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
newPartStat = iCalPersonPartStatUndefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newPartStat != iCalPersonPartStatUndefined)
|
|
||||||
{
|
|
||||||
iCalPerson *participant;
|
|
||||||
|
|
||||||
participant = [newEvent userAsAttendee: [woContext activeUser]];
|
|
||||||
[participant setParticipationStatus: newPartStat];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* recurrence */
|
|
||||||
value = [newProperties
|
|
||||||
objectForKey: MAPIPropertyKey (PidLidAppointmentRecur)];
|
|
||||||
if (value)
|
|
||||||
[self _setupRecurrenceInCalendar: vCalendar
|
|
||||||
fromData: value];
|
|
||||||
|
|
||||||
// [sogoObject saveContentString: [vCalendar versitString]];
|
|
||||||
[sogoObject saveComponent: newEvent];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) lookupAttachment: (NSString *) childKey
|
- (id) lookupAttachment: (NSString *) childKey
|
||||||
|
|
Loading…
Reference in a new issue