Added the context everywhere

pull/17/head
Ludovic Marcotte 2014-02-17 10:01:44 -05:00
parent 9218c7f253
commit 8083b41092
20 changed files with 125 additions and 99 deletions

View File

@ -34,11 +34,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@class NSDictionary; @class NSDictionary;
@class NSString; @class NSString;
@class WOContext;
@interface NGVCard (ActiveSync) @interface NGVCard (ActiveSync)
- (NSString *) activeSyncRepresentation; - (NSString *) activeSyncRepresentationInContext: (WOContext *) context;
- (void) takeActiveSyncValues: (NSDictionary *) theValues; - (void) takeActiveSyncValues: (NSDictionary *) theValues
inContext: (WOContext *) context;
@end @end

View File

@ -45,7 +45,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@implementation NGVCard (ActiveSync) @implementation NGVCard (ActiveSync)
- (NSString *) activeSyncRepresentation - (NSString *) activeSyncRepresentationInContext: (WOContext *) context
{ {
CardElement *n, *homeAdr, *workAdr; CardElement *n, *homeAdr, *workAdr;
NSArray *emails, *addresses; NSArray *emails, *addresses;
@ -58,16 +58,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
n = [self n]; n = [self n];
if ((o = [n flattenedValueAtIndex: 0 forKey: @""])) if ((o = [n flattenedValueAtIndex: 0 forKey: @""]))
[s appendFormat: @"<LastName xmlns=\"Contacts:\">%@</LastName>", [o activeSyncRepresentation]]; [s appendFormat: @"<LastName xmlns=\"Contacts:\">%@</LastName>", [o activeSyncRepresentationInContext: context]];
if ((o = [n flattenedValueAtIndex: 1 forKey: @""])) if ((o = [n flattenedValueAtIndex: 1 forKey: @""]))
[s appendFormat: @"<FirstName xmlns=\"Contacts:\">%@</FirstName>", [o activeSyncRepresentation]]; [s appendFormat: @"<FirstName xmlns=\"Contacts:\">%@</FirstName>", [o activeSyncRepresentationInContext: context]];
if ((o = [self workCompany])) if ((o = [self workCompany]))
[s appendFormat: @"<CompanyName xmlns=\"Contacts:\">%@</CompanyName>", [o activeSyncRepresentation]]; [s appendFormat: @"<CompanyName xmlns=\"Contacts:\">%@</CompanyName>", [o activeSyncRepresentationInContext: context]];
if ((o = [self title])) if ((o = [self title]))
[s appendFormat: @"<JobTitle xmlns=\"Contacts:\">%@</JobTitle>", [o activeSyncRepresentation]]; [s appendFormat: @"<JobTitle xmlns=\"Contacts:\">%@</JobTitle>", [o activeSyncRepresentationInContext: context]];
if ((o = [self preferredEMail])) if ((o = [self preferredEMail]))
[s appendFormat: @"<Email1Address xmlns=\"Contacts:\">%@</Email1Address>", o]; [s appendFormat: @"<Email1Address xmlns=\"Contacts:\">%@</Email1Address>", o];
@ -88,19 +88,19 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Telephone numbers // Telephone numbers
if ((o = [self workPhone]) && [o length]) if ((o = [self workPhone]) && [o length])
[s appendFormat: @"<BusinessPhoneNumber xmlns=\"Contacts:\">%@</BusinessPhoneNumber>", [o activeSyncRepresentation]]; [s appendFormat: @"<BusinessPhoneNumber xmlns=\"Contacts:\">%@</BusinessPhoneNumber>", [o activeSyncRepresentationInContext: context]];
if ((o = [self homePhone]) && [o length]) if ((o = [self homePhone]) && [o length])
[s appendFormat: @"<HomePhoneNumber xmlns=\"Contacts:\">%@</HomePhoneNumber>", [o activeSyncRepresentation]]; [s appendFormat: @"<HomePhoneNumber xmlns=\"Contacts:\">%@</HomePhoneNumber>", [o activeSyncRepresentationInContext: context]];
if ((o = [self fax]) && [o length]) if ((o = [self fax]) && [o length])
[s appendFormat: @"<BusinessFaxNumber xmlns=\"Contacts:\">%@</BusinessFaxNumber>", [o activeSyncRepresentation]]; [s appendFormat: @"<BusinessFaxNumber xmlns=\"Contacts:\">%@</BusinessFaxNumber>", [o activeSyncRepresentationInContext: context]];
if ((o = [self mobile]) && [o length]) if ((o = [self mobile]) && [o length])
[s appendFormat: @"<MobilePhoneNumber xmlns=\"Contacts:\">%@</MobilePhoneNumber>", [o activeSyncRepresentation]]; [s appendFormat: @"<MobilePhoneNumber xmlns=\"Contacts:\">%@</MobilePhoneNumber>", [o activeSyncRepresentationInContext: context]];
if ((o = [self pager]) && [o length]) if ((o = [self pager]) && [o length])
[s appendFormat: @"<PagerNumber xmlns=\"Contacts:\">%@</PagerNumber>", [o activeSyncRepresentation]]; [s appendFormat: @"<PagerNumber xmlns=\"Contacts:\">%@</PagerNumber>", [o activeSyncRepresentationInContext: context]];
// Home Address // Home Address
addresses = [self childrenWithTag: @"adr" addresses = [self childrenWithTag: @"adr"
@ -112,19 +112,19 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
homeAdr = [addresses objectAtIndex: 0]; homeAdr = [addresses objectAtIndex: 0];
if ((o = [homeAdr flattenedValueAtIndex: 2 forKey: @""])) if ((o = [homeAdr flattenedValueAtIndex: 2 forKey: @""]))
[s appendFormat: @"<HomeStreet xmlns=\"Contacts:\">%@</HomeStreet>", [o activeSyncRepresentation]]; [s appendFormat: @"<HomeStreet xmlns=\"Contacts:\">%@</HomeStreet>", [o activeSyncRepresentationInContext: context]];
if ((o = [homeAdr flattenedValueAtIndex: 3 forKey: @""])) if ((o = [homeAdr flattenedValueAtIndex: 3 forKey: @""]))
[s appendFormat: @"<HomeCity xmlns=\"Contacts:\">%@</HomeCity>", [o activeSyncRepresentation]]; [s appendFormat: @"<HomeCity xmlns=\"Contacts:\">%@</HomeCity>", [o activeSyncRepresentationInContext: context]];
if ((o = [homeAdr flattenedValueAtIndex: 4 forKey: @""])) if ((o = [homeAdr flattenedValueAtIndex: 4 forKey: @""]))
[s appendFormat: @"<HomeState xmlns=\"Contacts:\">%@</HomeState>", [o activeSyncRepresentation]]; [s appendFormat: @"<HomeState xmlns=\"Contacts:\">%@</HomeState>", [o activeSyncRepresentationInContext: context]];
if ((o = [homeAdr flattenedValueAtIndex: 5 forKey: @""])) if ((o = [homeAdr flattenedValueAtIndex: 5 forKey: @""]))
[s appendFormat: @"<HomePostalCode xmlns=\"Contacts:\">%@</HomePostalCode>", [o activeSyncRepresentation]]; [s appendFormat: @"<HomePostalCode xmlns=\"Contacts:\">%@</HomePostalCode>", [o activeSyncRepresentationInContext: context]];
if ((o = [homeAdr flattenedValueAtIndex: 6 forKey: @""])) if ((o = [homeAdr flattenedValueAtIndex: 6 forKey: @""]))
[s appendFormat: @"<HomeCountry xmlns=\"Contacts:\">%@</HomeCountry>", [o activeSyncRepresentation]]; [s appendFormat: @"<HomeCountry xmlns=\"Contacts:\">%@</HomeCountry>", [o activeSyncRepresentationInContext: context]];
} }
// Work Address // Work Address
@ -137,28 +137,28 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
workAdr = [addresses objectAtIndex: 0]; workAdr = [addresses objectAtIndex: 0];
if ((o = [workAdr flattenedValueAtIndex: 2 forKey: @""])) if ((o = [workAdr flattenedValueAtIndex: 2 forKey: @""]))
[s appendFormat: @"<BusinessStreet xmlns=\"Contacts:\">%@</BusinessStreet>", [o activeSyncRepresentation]]; [s appendFormat: @"<BusinessStreet xmlns=\"Contacts:\">%@</BusinessStreet>", [o activeSyncRepresentationInContext: context]];
if ((o = [workAdr flattenedValueAtIndex: 3 forKey: @""])) if ((o = [workAdr flattenedValueAtIndex: 3 forKey: @""]))
[s appendFormat: @"<BusinessCity xmlns=\"Contacts:\">%@</BusinessCity>", [o activeSyncRepresentation]]; [s appendFormat: @"<BusinessCity xmlns=\"Contacts:\">%@</BusinessCity>", [o activeSyncRepresentationInContext: context]];
if ((o = [workAdr flattenedValueAtIndex: 4 forKey: @""])) if ((o = [workAdr flattenedValueAtIndex: 4 forKey: @""]))
[s appendFormat: @"<BusinessState xmlns=\"Contacts:\">%@</BusinessState>", [o activeSyncRepresentation]]; [s appendFormat: @"<BusinessState xmlns=\"Contacts:\">%@</BusinessState>", [o activeSyncRepresentationInContext: context]];
if ((o = [workAdr flattenedValueAtIndex: 5 forKey: @""])) if ((o = [workAdr flattenedValueAtIndex: 5 forKey: @""]))
[s appendFormat: @"<BusinessPostalCode xmlns=\"Contacts:\">%@</BusinessPostalCode>", [o activeSyncRepresentation]]; [s appendFormat: @"<BusinessPostalCode xmlns=\"Contacts:\">%@</BusinessPostalCode>", [o activeSyncRepresentationInContext: context]];
if ((o = [workAdr flattenedValueAtIndex: 6 forKey: @""])) if ((o = [workAdr flattenedValueAtIndex: 6 forKey: @""]))
[s appendFormat: @"<BusinessCountry xmlns=\"Contacts:\">%@</BusinessCountry>", [o activeSyncRepresentation]]; [s appendFormat: @"<BusinessCountry xmlns=\"Contacts:\">%@</BusinessCountry>", [o activeSyncRepresentationInContext: context]];
} }
// Other, less important fields // Other, less important fields
if ((o = [self birthday])) if ((o = [self birthday]))
[s appendFormat: @"<Birthday xmlns=\"Contacts:\">%@</Birthday>", [o activeSyncRepresentationWithoutSeparators]]; [s appendFormat: @"<Birthday xmlns=\"Contacts:\">%@</Birthday>", [o activeSyncRepresentationWithoutSeparatorsInContext: context]];
if ((o = [self note])) if ((o = [self note]))
{ {
o = [o activeSyncRepresentation]; o = [o activeSyncRepresentationInContext: context];
[s appendString: @"<Body xmlns=\"AirSyncBase:\">"]; [s appendString: @"<Body xmlns=\"AirSyncBase:\">"];
[s appendFormat: @"<Type>%d</Type>", 1]; [s appendFormat: @"<Type>%d</Type>", 1];
[s appendFormat: @"<EstimatedDataSize>%d</EstimatedDataSize>", [o length]]; [s appendFormat: @"<EstimatedDataSize>%d</EstimatedDataSize>", [o length]];
@ -174,6 +174,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// //
// //
- (void) takeActiveSyncValues: (NSDictionary *) theValues - (void) takeActiveSyncValues: (NSDictionary *) theValues
inContext: (WOContext *) context
{ {
CardElement *element; CardElement *element;
id o; id o;

View File

@ -33,10 +33,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/NSData.h> #import <Foundation/NSData.h>
@class NSString; @class NSString;
@class WOContext;
@interface NSData (ActiveSync) @interface NSData (ActiveSync)
- (NSString *) activeSyncRepresentation; - (NSString *) activeSyncRepresentationInContext: (WOContext *) context;
- (NSData *) wbxml2xml; - (NSData *) wbxml2xml;
- (NSData *) xml2wbxml; - (NSData *) xml2wbxml;

View File

@ -54,7 +54,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// //
// Encodes the data in base64 and strip newline characters // Encodes the data in base64 and strip newline characters
// //
- (NSString *) activeSyncRepresentation - (NSString *) activeSyncRepresentationInContext: (WOContext *) context
{ {
return [[self stringByEncodingBase64] stringByReplacingString: @"\n" withString: @""]; return [[self stringByEncodingBase64] stringByReplacingString: @"\n" withString: @""];
} }

View File

@ -33,11 +33,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/NSDate.h> #import <Foundation/NSDate.h>
@class NSString; @class NSString;
@class WOContext;
@interface NSDate (ActiveSync) @interface NSDate (ActiveSync)
- (NSString *) activeSyncRepresentation; - (NSString *) activeSyncRepresentationInContext: (WOContext *) context;
- (NSString *) activeSyncRepresentationWithoutSeparators; - (NSString *) activeSyncRepresentationWithoutSeparatorsInContext: (WOContext *) context;
@end @end

View File

@ -34,7 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@implementation NSDate (ActiveSync) @implementation NSDate (ActiveSync)
- (NSString *) activeSyncRepresentation - (NSString *) activeSyncRepresentationInContext: (WOContext *) context
{ {
return [self descriptionWithCalendarFormat: @"%Y-%m-%d-T%H:%M:%S.%FZ" timeZone: [NSTimeZone timeZoneWithName: @"GMT"] locale: nil]; return [self descriptionWithCalendarFormat: @"%Y-%m-%d-T%H:%M:%S.%FZ" timeZone: [NSTimeZone timeZoneWithName: @"GMT"] locale: nil];
} }
@ -43,7 +43,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// //
// From [MS-ASDTYPE].pdf - section 2.3 "Dates and times in calendar items MUST NOT include punctuation separators." // From [MS-ASDTYPE].pdf - section 2.3 "Dates and times in calendar items MUST NOT include punctuation separators."
// //
- (NSString *) activeSyncRepresentationWithoutSeparators - (NSString *) activeSyncRepresentationWithoutSeparatorsInContext: (WOContext *) context
{ {
return [self descriptionWithCalendarFormat: @"%Y%m%dT%H%M%SZ" timeZone: [NSTimeZone timeZoneWithName: @"GMT"] locale: nil]; return [self descriptionWithCalendarFormat: @"%Y%m%dT%H%M%SZ" timeZone: [NSTimeZone timeZoneWithName: @"GMT"] locale: nil];
} }

View File

@ -36,11 +36,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@class NSCalendarDate; @class NSCalendarDate;
@class NSData; @class NSData;
@class WOContext;
@interface NSString (ActiveSync) @interface NSString (ActiveSync)
- (NSString *) sanitizedServerIdWithType: (SOGoMicrosoftActiveSyncFolderType) folderType; - (NSString *) sanitizedServerIdWithType: (SOGoMicrosoftActiveSyncFolderType) folderType;
- (NSString *) activeSyncRepresentation; - (NSString *) activeSyncRepresentationInContext: (WOContext *) context;
- (int) activeSyncFolderType; - (int) activeSyncFolderType;
- (NSString *) realCollectionIdWithFolderType: (SOGoMicrosoftActiveSyncFolderType *) folderType; - (NSString *) realCollectionIdWithFolderType: (SOGoMicrosoftActiveSyncFolderType *) folderType;
- (NSCalendarDate *) calendarDate; - (NSCalendarDate *) calendarDate;

View File

@ -57,7 +57,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
return self; return self;
} }
- (NSString *) activeSyncRepresentation - (NSString *) activeSyncRepresentationInContext: (WOContext *) context
{ {
NSString *s; NSString *s;

View File

@ -192,9 +192,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
serverId = [allValues objectForKey: @"UID"]; serverId = [allValues objectForKey: @"UID"];
else else
serverId = [theCollection globallyUniqueObjectId]; serverId = [theCollection globallyUniqueObjectId];
[allValues setObject: [[[context activeUser] userDefaults] timeZone] forKey: @"SOGoUserTimeZone"];
sogoObject = [theCollection lookupName: [serverId sanitizedServerIdWithType: theFolderType] sogoObject = [theCollection lookupName: [serverId sanitizedServerIdWithType: theFolderType]
inContext: context inContext: context
acquire: NO]; acquire: NO];
@ -218,7 +216,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
serverId = [NSString stringWithFormat: @"%@.ics", [theCollection globallyUniqueObjectId]]; serverId = [NSString stringWithFormat: @"%@.ics", [theCollection globallyUniqueObjectId]];
sogoObject = [[SOGoTaskObject alloc] initWithName: serverId sogoObject = [[SOGoTaskObject alloc] initWithName: serverId
inContainer: theCollection]; inContainer: theCollection];
[allValues setObject: [[[context activeUser] userDefaults] timeZone] forKey: @"SOGoUserTimeZone"];
o = [sogoObject component: YES secure: NO]; o = [sogoObject component: YES secure: NO];
} }
break; break;
@ -232,7 +229,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
} }
} }
[o takeActiveSyncValues: allValues]; [o takeActiveSyncValues: allValues inContext: context];
[sogoObject setIsNew: is_new]; [sogoObject setIsNew: is_new];
[sogoObject saveComponent: o]; [sogoObject saveComponent: o];
@ -322,7 +319,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
case ActiveSyncContactFolder: case ActiveSyncContactFolder:
{ {
o = [sogoObject vCard]; o = [sogoObject vCard];
[o takeActiveSyncValues: allChanges]; [o takeActiveSyncValues: allChanges inContext: context];
[sogoObject saveComponent: o]; [sogoObject saveComponent: o];
} }
break; break;
@ -330,14 +327,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
case ActiveSyncTaskFolder: case ActiveSyncTaskFolder:
{ {
o = [sogoObject component: NO secure: NO]; o = [sogoObject component: NO secure: NO];
[o takeActiveSyncValues: allChanges]; [o takeActiveSyncValues: allChanges inContext: context];
[sogoObject saveComponent: o]; [sogoObject saveComponent: o];
} }
break; break;
case ActiveSyncMailFolder: case ActiveSyncMailFolder:
default: default:
{ {
[sogoObject takeActiveSyncValues: allChanges]; [sogoObject takeActiveSyncValues: allChanges inContext: context];
} }
} }
@ -425,7 +422,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[theBuffer appendFormat: @"<ServerId>%@</ServerId>", serverId]; [theBuffer appendFormat: @"<ServerId>%@</ServerId>", serverId];
[theBuffer appendFormat: @"<Status>%d</Status>", 1]; [theBuffer appendFormat: @"<Status>%d</Status>", 1];
[theBuffer appendString: @"<ApplicationData>"]; [theBuffer appendString: @"<ApplicationData>"];
[theBuffer appendString: [o activeSyncRepresentation]]; [theBuffer appendString: [o activeSyncRepresentationInContext: context]];
[theBuffer appendString: @"</ApplicationData>"]; [theBuffer appendString: @"</ApplicationData>"];
[theBuffer appendString: @"</Fetch>"]; [theBuffer appendString: @"</Fetch>"];
} }
@ -559,7 +556,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[s appendFormat: @"<ServerId xmlns=\"AirSync:\">%@</ServerId>", uid]; [s appendFormat: @"<ServerId xmlns=\"AirSync:\">%@</ServerId>", uid];
[s appendString: @"<ApplicationData xmlns=\"AirSync:\">"]; [s appendString: @"<ApplicationData xmlns=\"AirSync:\">"];
[s appendString: [componentObject activeSyncRepresentation]]; [s appendString: [componentObject activeSyncRepresentationInContext: context]];
[s appendString: @"</ApplicationData>"]; [s appendString: @"</ApplicationData>"];
@ -618,7 +615,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[s appendFormat: @"<ServerId xmlns=\"AirSync:\">%@</ServerId>", uid]; [s appendFormat: @"<ServerId xmlns=\"AirSync:\">%@</ServerId>", uid];
[s appendString: @"<ApplicationData xmlns=\"AirSync:\">"]; [s appendString: @"<ApplicationData xmlns=\"AirSync:\">"];
[s appendString: [mailObject activeSyncRepresentation]]; [s appendString: [mailObject activeSyncRepresentationInContext: context]];
[s appendString: @"</ApplicationData>"]; [s appendString: @"</ApplicationData>"];
if ([command isEqualToString: @"added"]) if ([command isEqualToString: @"added"])

View File

@ -510,26 +510,26 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[serverId stringByEscapingURL], [serverId stringByEscapingURL],
[parentId stringByEscapingURL], [parentId stringByEscapingURL],
type, type,
[name activeSyncRepresentation]]; [name activeSyncRepresentationInContext: context]];
} }
// We add the personal calendar - events // We add the personal calendar - events
// FIXME: add all calendars // FIXME: add all calendars
currentFolder = [[context activeUser] personalCalendarFolderInContext: context]; currentFolder = [[context activeUser] personalCalendarFolderInContext: context];
name = [NSString stringWithFormat: @"vevent/%@", [currentFolder nameInContainer]]; name = [NSString stringWithFormat: @"vevent/%@", [currentFolder nameInContainer]];
[s appendFormat: @"<Add><ServerId>%@</ServerId><ParentId>%@</ParentId><Type>%d</Type><DisplayName>%@</DisplayName></Add>", name, @"0", 8, [[currentFolder displayName] activeSyncRepresentation]]; [s appendFormat: @"<Add><ServerId>%@</ServerId><ParentId>%@</ParentId><Type>%d</Type><DisplayName>%@</DisplayName></Add>", name, @"0", 8, [[currentFolder displayName] activeSyncRepresentationInContext: context]];
// We add the personal calendar - tasks // We add the personal calendar - tasks
// FIXME: add all calendars // FIXME: add all calendars
currentFolder = [[context activeUser] personalCalendarFolderInContext: context]; currentFolder = [[context activeUser] personalCalendarFolderInContext: context];
name = [NSString stringWithFormat: @"vtodo/%@", [currentFolder nameInContainer]]; name = [NSString stringWithFormat: @"vtodo/%@", [currentFolder nameInContainer]];
[s appendFormat: @"<Add><ServerId>%@</ServerId><ParentId>%@</ParentId><Type>%d</Type><DisplayName>%@</DisplayName></Add>", name, @"0", 7, [[currentFolder displayName] activeSyncRepresentation]]; [s appendFormat: @"<Add><ServerId>%@</ServerId><ParentId>%@</ParentId><Type>%d</Type><DisplayName>%@</DisplayName></Add>", name, @"0", 7, [[currentFolder displayName] activeSyncRepresentationInContext: context]];
// We add the personal address book // We add the personal address book
// FIXME: add all address books // FIXME: add all address books
currentFolder = [[context activeUser] personalContactsFolderInContext: context]; currentFolder = [[context activeUser] personalContactsFolderInContext: context];
name = [NSString stringWithFormat: @"vcard/%@", [currentFolder nameInContainer]]; name = [NSString stringWithFormat: @"vcard/%@", [currentFolder nameInContainer]];
[s appendFormat: @"<Add><ServerId>%@</ServerId><ParentId>%@</ParentId><Type>%d</Type><DisplayName>%@</DisplayName></Add>", name, @"0", 9, [[currentFolder displayName] activeSyncRepresentation]]; [s appendFormat: @"<Add><ServerId>%@</ServerId><ParentId>%@</ParentId><Type>%d</Type><DisplayName>%@</DisplayName></Add>", name, @"0", 9, [[currentFolder displayName] activeSyncRepresentationInContext: context]];
} }
[s appendString: @"</Changes></FolderSync>"]; [s appendString: @"</Changes></FolderSync>"];
@ -702,7 +702,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[s appendString: @"<Properties>"]; [s appendString: @"<Properties>"];
[s appendFormat: @"<ContentType xmlns=\"AirSyncBase:\">%@/%@</ContentType>", [[currentBodyPart partInfo] objectForKey: @"type"], [[currentBodyPart partInfo] objectForKey: @"subtype"]]; [s appendFormat: @"<ContentType xmlns=\"AirSyncBase:\">%@/%@</ContentType>", [[currentBodyPart partInfo] objectForKey: @"type"], [[currentBodyPart partInfo] objectForKey: @"subtype"]];
[s appendFormat: @"<Data>%@</Data>", [[currentBodyPart fetchBLOB] activeSyncRepresentation]]; [s appendFormat: @"<Data>%@</Data>", [[currentBodyPart fetchBLOB] activeSyncRepresentationInContext: context]];
[s appendString: @"</Properties>"]; [s appendString: @"</Properties>"];
[s appendString: @"</Fetch>"]; [s appendString: @"</Fetch>"];

View File

@ -34,12 +34,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@class iCalCalendar; @class iCalCalendar;
@class NSDictionary; @class NSDictionary;
@class WOContext;
@interface SOGoMailObject (ActiveSync) @interface SOGoMailObject (ActiveSync)
- (iCalCalendar *) calendarFromIMIPMessage; - (iCalCalendar *) calendarFromIMIPMessage;
- (NSString *) activeSyncRepresentation; - (NSString *) activeSyncRepresentationInContext: (WOContext *) context;
- (void) takeActiveSyncValues: (NSDictionary *) theValues; - (void) takeActiveSyncValues: (NSDictionary *) theValues
inContext: (WOContext *) context;
@end @end

View File

@ -342,7 +342,7 @@ struct GlobalObjectId {
// //
// //
// //
- (NSString *) activeSyncRepresentation - (NSString *) activeSyncRepresentationInContext: (WOContext *) _context
{ {
NSData *d, *globalObjId; NSData *d, *globalObjId;
NSMutableString *s; NSMutableString *s;
@ -358,25 +358,25 @@ struct GlobalObjectId {
// If there are multiple e-mail addresses, they are separated by commas." // If there are multiple e-mail addresses, they are separated by commas."
value = [self _emailAddressesFrom: [[self envelope] to]]; value = [self _emailAddressesFrom: [[self envelope] to]];
if (value) if (value)
[s appendFormat: @"<To xmlns=\"Email:\">%@</To>", [value activeSyncRepresentation]]; [s appendFormat: @"<To xmlns=\"Email:\">%@</To>", [value activeSyncRepresentationInContext: context]];
// From // From
value = [self _emailAddressesFrom: [[self envelope] from]]; value = [self _emailAddressesFrom: [[self envelope] from]];
if (value) if (value)
[s appendFormat: @"<From xmlns=\"Email:\">%@</From>", [value activeSyncRepresentation]]; [s appendFormat: @"<From xmlns=\"Email:\">%@</From>", [value activeSyncRepresentationInContext: context]];
// Subject // Subject
value = [self decodedSubject]; value = [self decodedSubject];
if (value) if (value)
{ {
[s appendFormat: @"<Subject xmlns=\"Email:\">%@</Subject>", [value activeSyncRepresentation]]; [s appendFormat: @"<Subject xmlns=\"Email:\">%@</Subject>", [value activeSyncRepresentationInContext: context]];
[s appendFormat: @"<ThreadTopic xmlns=\"Email:\">%@</ThreadTopic>", [value activeSyncRepresentation]]; [s appendFormat: @"<ThreadTopic xmlns=\"Email:\">%@</ThreadTopic>", [value activeSyncRepresentationInContext: context]];
} }
// DateReceived // DateReceived
value = [self date]; value = [self date];
if (value) if (value)
[s appendFormat: @"<DateReceived xmlns=\"Email:\">%@</DateReceived>", [value activeSyncRepresentationWithoutSeparators]]; [s appendFormat: @"<DateReceived xmlns=\"Email:\">%@</DateReceived>", [value activeSyncRepresentationWithoutSeparatorsInContext: context]];
// DisplayTo // DisplayTo
[s appendFormat: @"<DisplayTo xmlns=\"Email:\">%@</DisplayTo>", [[context activeUser] login]]; [s appendFormat: @"<DisplayTo xmlns=\"Email:\">%@</DisplayTo>", [[context activeUser] login]];
@ -384,7 +384,7 @@ struct GlobalObjectId {
// Cc - same syntax as the To field // Cc - same syntax as the To field
value = [self _emailAddressesFrom: [[self envelope] cc]]; value = [self _emailAddressesFrom: [[self envelope] cc]];
if (value) if (value)
[s appendFormat: @"<Cc xmlns=\"Email:\">%@</Cc>", [value activeSyncRepresentation]]; [s appendFormat: @"<Cc xmlns=\"Email:\">%@</Cc>", [value activeSyncRepresentationInContext: context]];
// Importance - FIXME // Importance - FIXME
[s appendFormat: @"<Importance xmlns=\"Email:\">%@</Importance>", @"1"]; [s appendFormat: @"<Importance xmlns=\"Email:\">%@</Importance>", @"1"];
@ -447,24 +447,24 @@ struct GlobalObjectId {
// StartTime -- http://msdn.microsoft.com/en-us/library/ee157132(v=exchg.80).aspx // StartTime -- http://msdn.microsoft.com/en-us/library/ee157132(v=exchg.80).aspx
if ([event startDate]) if ([event startDate])
[s appendFormat: @"<StartTime xmlns=\"Email:\">%@</StartTime>", [[event startDate] activeSyncRepresentationWithoutSeparators]]; [s appendFormat: @"<StartTime xmlns=\"Email:\">%@</StartTime>", [[event startDate] activeSyncRepresentationWithoutSeparatorsInContext: context]];
if ([event timeStampAsDate]) if ([event timeStampAsDate])
[s appendFormat: @"<DTStamp xmlns=\"Email:\">%@</DTStamp>", [[event timeStampAsDate] activeSyncRepresentationWithoutSeparators]]; [s appendFormat: @"<DTStamp xmlns=\"Email:\">%@</DTStamp>", [[event timeStampAsDate] activeSyncRepresentationWithoutSeparatorsInContext: context]];
else if ([event created]) else if ([event created])
[s appendFormat: @"<DTStamp xmlns=\"Email:\">%@</DTStamp>", [[event created] activeSyncRepresentationWithoutSeparators]]; [s appendFormat: @"<DTStamp xmlns=\"Email:\">%@</DTStamp>", [[event created] activeSyncRepresentationWithoutSeparatorsInContext: context]];
// EndTime -- http://msdn.microsoft.com/en-us/library/ee157945(v=exchg.80).aspx // EndTime -- http://msdn.microsoft.com/en-us/library/ee157945(v=exchg.80).aspx
if ([event endDate]) if ([event endDate])
[s appendFormat: @"<EndTime xmlns=\"Email:\">%@</EndTime>", [[event endDate] activeSyncRepresentationWithoutSeparators]]; [s appendFormat: @"<EndTime xmlns=\"Email:\">%@</EndTime>", [[event endDate] activeSyncRepresentationWithoutSeparatorsInContext: context]];
[s appendFormat: @"<InstanceType xmlns=\"Email:\">%d</InstanceType>", 0]; [s appendFormat: @"<InstanceType xmlns=\"Email:\">%d</InstanceType>", 0];
// Location // Location
if ([[event location] length]) if ([[event location] length])
[s appendFormat: @"<Location xmlns=\"Email:\">%@</Location>", [[event location] activeSyncRepresentation]]; [s appendFormat: @"<Location xmlns=\"Email:\">%@</Location>", [[event location] activeSyncRepresentationInContext: context]];
[s appendFormat: @"<Organizer xmlns=\"Email:\">%@</Organizer>", [[[event organizer] mailAddress] activeSyncRepresentation]]; [s appendFormat: @"<Organizer xmlns=\"Email:\">%@</Organizer>", [[[event organizer] mailAddress] activeSyncRepresentationInContext: context]];
// This will trigger the SendMail command. We set it to no for email invitations as // This will trigger the SendMail command. We set it to no for email invitations as
// SOGo will send emails when MeetingResponse is called. // SOGo will send emails when MeetingResponse is called.
@ -488,7 +488,7 @@ struct GlobalObjectId {
if (!tz) if (!tz)
tz = [iCalTimeZone timeZoneForName: @"Europe/London"]; tz = [iCalTimeZone timeZoneForName: @"Europe/London"];
[s appendFormat: @"<TimeZone xmlns=\"Email:\">%@</TimeZone>", [tz activeSyncRepresentation]]; [s appendFormat: @"<TimeZone xmlns=\"Email:\">%@</TimeZone>", [tz activeSyncRepresentationInContext: context]];
// We disallow new time proposals // We disallow new time proposals
@ -500,7 +500,7 @@ struct GlobalObjectId {
// object in the Calendar folder have to convert the GlobalObjId element value to a UID element value to make the comparison." // object in the Calendar folder have to convert the GlobalObjId element value to a UID element value to make the comparison."
// //
globalObjId = [self _computeGlobalObjectIdFromEvent: event]; globalObjId = [self _computeGlobalObjectIdFromEvent: event];
[s appendFormat: @"<GlobalObjId xmlns=\"Email:\">%@</GlobalObjId>", [globalObjId activeSyncRepresentation]]; [s appendFormat: @"<GlobalObjId xmlns=\"Email:\">%@</GlobalObjId>", [globalObjId activeSyncRepresentationInContext: context]];
// We set the right message type - we must set AS version to 14.1 for this // We set the right message type - we must set AS version to 14.1 for this
[s appendFormat: @"<MeetingMessageType xmlns=\"Email2:\">%d</MeetingMessageType>", 1]; [s appendFormat: @"<MeetingMessageType xmlns=\"Email2:\">%d</MeetingMessageType>", 1];
@ -545,7 +545,7 @@ struct GlobalObjectId {
AUTORELEASE(content); AUTORELEASE(content);
content = [content activeSyncRepresentation]; content = [content activeSyncRepresentationInContext: context];
truncated = 0; truncated = 0;
len = [content length]; len = [content length];
@ -572,7 +572,7 @@ struct GlobalObjectId {
value = [attachmentKeys objectAtIndex: i]; value = [attachmentKeys objectAtIndex: i];
[s appendString: @"<Attachment>"]; [s appendString: @"<Attachment>"];
[s appendFormat: @"<DisplayName>%@</DisplayName>", [[value objectForKey: @"filename"] activeSyncRepresentation]]; [s appendFormat: @"<DisplayName>%@</DisplayName>", [[value objectForKey: @"filename"] activeSyncRepresentationInContext: context]];
// FileReference must be a unique identifier across the whole store. We use the following structure: // FileReference must be a unique identifier across the whole store. We use the following structure:
// mail/<foldername>/<message UID/<pathofpart> // mail/<foldername>/<message UID/<pathofpart>
@ -612,6 +612,7 @@ struct GlobalObjectId {
// //
// //
- (void) takeActiveSyncValues: (NSDictionary *) theValues - (void) takeActiveSyncValues: (NSDictionary *) theValues
inContext: (WOContext *) _context
{ {
id o; id o;

View File

@ -34,11 +34,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <NGCards/iCalEvent.h> #import <NGCards/iCalEvent.h>
@class NSString; @class NSString;
@class WOContext;
@interface iCalEvent (ActiveSync) @interface iCalEvent (ActiveSync)
- (NSString *) activeSyncRepresentation; - (NSString *) activeSyncRepresentationInContext: (WOContext *) context;
- (void) takeActiveSyncValues: (NSDictionary *) theValues; - (void) takeActiveSyncValues: (NSDictionary *) theValues
inContext: (WOContext *) context;
@end @end

View File

@ -38,11 +38,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/NSTimeZone.h> #import <Foundation/NSTimeZone.h>
#import <NGExtensions/NSString+misc.h> #import <NGExtensions/NSString+misc.h>
#import <NGObjWeb/WOContext.h>
#import <NGObjWeb/WOContext+SoObjects.h>
#import <NGCards/iCalCalendar.h> #import <NGCards/iCalCalendar.h>
#import <NGCards/iCalDateTime.h> #import <NGCards/iCalDateTime.h>
#import <NGCards/iCalPerson.h> #import <NGCards/iCalPerson.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserDefaults.h>
#include "iCalRecurrenceRule+ActiveSync.h" #include "iCalRecurrenceRule+ActiveSync.h"
#include "iCalTimeZone+ActiveSync.h" #include "iCalTimeZone+ActiveSync.h"
#include "NSDate+ActiveSync.h" #include "NSDate+ActiveSync.h"
@ -50,7 +55,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@implementation iCalEvent (ActiveSync) @implementation iCalEvent (ActiveSync)
- (NSString *) activeSyncRepresentation - (NSString *) activeSyncRepresentationInContext: (WOContext *) context
{ {
NSMutableString *s; NSMutableString *s;
NSArray *attendees; NSArray *attendees;
@ -67,17 +72,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// DTStamp -- http://msdn.microsoft.com/en-us/library/ee219470(v=exchg.80).aspx // DTStamp -- http://msdn.microsoft.com/en-us/library/ee219470(v=exchg.80).aspx
if ([self timeStampAsDate]) if ([self timeStampAsDate])
[s appendFormat: @"<DTStamp xmlns=\"Calendar:\">%@</DTStamp>", [[self timeStampAsDate] activeSyncRepresentationWithoutSeparators]]; [s appendFormat: @"<DTStamp xmlns=\"Calendar:\">%@</DTStamp>", [[self timeStampAsDate] activeSyncRepresentationWithoutSeparatorsInContext: context]];
else if ([self created]) else if ([self created])
[s appendFormat: @"<DTStamp xmlns=\"Calendar:\">%@</DTStamp>", [[self created] activeSyncRepresentationWithoutSeparators]]; [s appendFormat: @"<DTStamp xmlns=\"Calendar:\">%@</DTStamp>", [[self created] activeSyncRepresentationWithoutSeparatorsInContext: context]];
// StartTime -- http://msdn.microsoft.com/en-us/library/ee157132(v=exchg.80).aspx // StartTime -- http://msdn.microsoft.com/en-us/library/ee157132(v=exchg.80).aspx
if ([self startDate]) if ([self startDate])
[s appendFormat: @"<StartTime xmlns=\"Calendar:\">%@</StartTime>", [[self startDate] activeSyncRepresentationWithoutSeparators]]; [s appendFormat: @"<StartTime xmlns=\"Calendar:\">%@</StartTime>", [[self startDate] activeSyncRepresentationWithoutSeparatorsInContext: context]];
// EndTime -- http://msdn.microsoft.com/en-us/library/ee157945(v=exchg.80).aspx // EndTime -- http://msdn.microsoft.com/en-us/library/ee157945(v=exchg.80).aspx
if ([self endDate]) if ([self endDate])
[s appendFormat: @"<EndTime xmlns=\"Calendar:\">%@</EndTime>", [[self endDate] activeSyncRepresentationWithoutSeparators]]; [s appendFormat: @"<EndTime xmlns=\"Calendar:\">%@</EndTime>", [[self endDate] activeSyncRepresentationWithoutSeparatorsInContext: context]];
// Timezone // Timezone
tz = [(iCalDateTime *)[self firstChildWithTag: @"dtstart"] timeZone]; tz = [(iCalDateTime *)[self firstChildWithTag: @"dtstart"] timeZone];
@ -85,7 +90,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if (!tz) if (!tz)
tz = [iCalTimeZone timeZoneForName: @"Europe/London"]; tz = [iCalTimeZone timeZoneForName: @"Europe/London"];
[s appendFormat: @"<TimeZone xmlns=\"Calendar:\">%@</TimeZone>", [tz activeSyncRepresentation]]; [s appendFormat: @"<TimeZone xmlns=\"Calendar:\">%@</TimeZone>", [tz activeSyncRepresentationInContext: context]];
// Organizer and other invitations related properties // Organizer and other invitations related properties
if ((organizer = [self organizer])) if ((organizer = [self organizer]))
@ -153,11 +158,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Subject -- http://msdn.microsoft.com/en-us/library/ee157192(v=exchg.80).aspx // Subject -- http://msdn.microsoft.com/en-us/library/ee157192(v=exchg.80).aspx
if ([[self summary] length]) if ([[self summary] length])
[s appendFormat: @"<Subject xmlns=\"Calendar:\">%@</Subject>", [[self summary] activeSyncRepresentation]]; [s appendFormat: @"<Subject xmlns=\"Calendar:\">%@</Subject>", [[self summary] activeSyncRepresentationInContext: context]];
// Location // Location
if ([[self location] length]) if ([[self location] length])
[s appendFormat: @"<Location xmlns=\"Calendar:\">%@</Location>", [[self location] activeSyncRepresentation]]; [s appendFormat: @"<Location xmlns=\"Calendar:\">%@</Location>", [[self location] activeSyncRepresentationInContext: context]];
// Importance - NOT SUPPORTED - DO NOT ENABLE // Importance - NOT SUPPORTED - DO NOT ENABLE
//o = [self priority]; //o = [self priority];
@ -189,14 +194,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Recurrence rules // Recurrence rules
if ([self isRecurrent]) if ([self isRecurrent])
{ {
[s appendString: [[[self recurrenceRules] lastObject] activeSyncRepresentation]]; [s appendString: [[[self recurrenceRules] lastObject] activeSyncRepresentationInContext: context]];
} }
// Comment // Comment
o = [self comment]; o = [self comment];
if ([o length]) if ([o length])
{ {
o = [o activeSyncRepresentation]; o = [o activeSyncRepresentationInContext: context];
[s appendString: @"<Body xmlns=\"AirSyncBase:\">"]; [s appendString: @"<Body xmlns=\"AirSyncBase:\">"];
[s appendFormat: @"<Type>%d</Type>", 1]; [s appendFormat: @"<Type>%d</Type>", 1];
[s appendFormat: @"<EstimatedDataSize>%d</EstimatedDataSize>", [o length]]; [s appendFormat: @"<EstimatedDataSize>%d</EstimatedDataSize>", [o length]];
@ -249,6 +254,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// </Change> // </Change>
// //
- (void) takeActiveSyncValues: (NSDictionary *) theValues - (void) takeActiveSyncValues: (NSDictionary *) theValues
inContext: (WOContext *) context
{ {
iCalDateTime *start, *end; iCalDateTime *start, *end;
NSTimeZone *userTimeZone; NSTimeZone *userTimeZone;
@ -310,7 +316,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if ((o = [theValues objectForKey: @"TimeZone"])) if ((o = [theValues objectForKey: @"TimeZone"]))
{ {
// Ugh, we ignore it for now. // Ugh, we ignore it for now.
userTimeZone = [theValues objectForKey: @"SOGoUserTimeZone"]; userTimeZone = [[[context activeUser] userDefaults] timeZone];
tz = [iCalTimeZone timeZoneForName: [userTimeZone name]]; tz = [iCalTimeZone timeZoneForName: [userTimeZone name]];
[(iCalCalendar *) parent addTimeZone: tz]; [(iCalCalendar *) parent addTimeZone: tz];
} }
@ -373,7 +379,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[self setRecurrenceRules: [NSArray arrayWithObject: rule]]; [self setRecurrenceRules: [NSArray arrayWithObject: rule]];
RELEASE(rule); RELEASE(rule);
[rule takeActiveSyncValues: o]; [rule takeActiveSyncValues: o inContext: context];
} }
// Organizer // Organizer

View File

@ -35,11 +35,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@class NSDictionary; @class NSDictionary;
@class NSString; @class NSString;
@class WOContext;
@interface iCalRecurrenceRule (ActiveSync) @interface iCalRecurrenceRule (ActiveSync)
- (NSString *) activeSyncRepresentation; - (NSString *) activeSyncRepresentationInContext:(WOContext *) context;
- (void) takeActiveSyncValues: (NSDictionary *) theValues; - (void) takeActiveSyncValues: (NSDictionary *) theValues
inContext: (WOContext *) context;
@end @end

View File

@ -41,7 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@implementation iCalRecurrenceRule (ActiveSync) @implementation iCalRecurrenceRule (ActiveSync)
- (NSString *) activeSyncRepresentation - (NSString *) activeSyncRepresentationInContext: (WOContext *) context
{ {
NSMutableString *s; NSMutableString *s;
int type; int type;
@ -180,7 +180,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//[date setTimeZone: [ud timeZone]]; //[date setTimeZone: [ud timeZone]];
[s appendFormat: @"<Recurrence_Until xmlns=\"Calendar:\">%@</Recurrence_Until>", [s appendFormat: @"<Recurrence_Until xmlns=\"Calendar:\">%@</Recurrence_Until>",
[date activeSyncRepresentationWithoutSeparators]]; [date activeSyncRepresentationWithoutSeparatorsInContext: context]];
} }
@ -242,6 +242,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// //
// //
- (void) takeActiveSyncValues: (NSDictionary *) theValues - (void) takeActiveSyncValues: (NSDictionary *) theValues
inContext: (WOContext *) context
{ {
id o; id o;

View File

@ -33,10 +33,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <NGCards/iCalTimeZone.h> #import <NGCards/iCalTimeZone.h>
@class NSString; @class NSString;
@class WOContext;
@interface iCalTimeZone (ActiveSync) @interface iCalTimeZone (ActiveSync)
- (NSString *) activeSyncRepresentation; - (NSString *) activeSyncRepresentationInContext: (WOContext *) context;
@end @end

View File

@ -115,7 +115,7 @@ struct SYSTEMTIME {
} }
- (NSString *) activeSyncRepresentation - (NSString *) activeSyncRepresentationInContext: (WOContext *) context
{ {
iCalTimeZonePeriod *period; iCalTimeZonePeriod *period;
NSMutableData *bytes; NSMutableData *bytes;
@ -159,7 +159,7 @@ struct SYSTEMTIME {
[bytes appendBytes: &stDaylightDate length: 16]; [bytes appendBytes: &stDaylightDate length: 16];
[bytes appendBytes: &lDaylightBias length: 4]; [bytes appendBytes: &lDaylightBias length: 4];
return [bytes activeSyncRepresentation]; return [bytes activeSyncRepresentationInContext: context];
} }
@end @end

View File

@ -33,11 +33,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <NGCards/iCalToDo.h> #import <NGCards/iCalToDo.h>
@class NSString; @class NSString;
@class WOContext;
@interface iCalToDo (ActiveSync) @interface iCalToDo (ActiveSync)
- (NSString *) activeSyncRepresentation; - (NSString *) activeSyncRepresentationInContext: (WOContext *) context;
- (void) takeActiveSyncValues: (NSDictionary *) theValues; - (void) takeActiveSyncValues: (NSDictionary *) theValues
inContext: (WOContext *) context;
@end @end

View File

@ -36,6 +36,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <Foundation/NSTimeZone.h> #import <Foundation/NSTimeZone.h>
#import <NGExtensions/NSString+misc.h> #import <NGExtensions/NSString+misc.h>
#import <NGObjWeb/WOContext.h>
#import <NGObjWeb/WOContext+SoObjects.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserDefaults.h>
#import <NGCards/iCalCalendar.h> #import <NGCards/iCalCalendar.h>
#import <NGCards/iCalDateTime.h> #import <NGCards/iCalDateTime.h>
@ -46,7 +51,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@implementation iCalToDo (ActiveSync) @implementation iCalToDo (ActiveSync)
- (NSString *) activeSyncRepresentation - (NSString *) activeSyncRepresentationInContext: (WOContext *) context
{ {
NSMutableString *s; NSMutableString *s;
id o; id o;
@ -61,21 +66,21 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// DateCompleted // DateCompleted
if (o) if (o)
[s appendFormat: @"<DateCompleted xmlns=\"Tasks:\">%@</DateCompleted>", [o activeSyncRepresentation]]; [s appendFormat: @"<DateCompleted xmlns=\"Tasks:\">%@</DateCompleted>", [o activeSyncRepresentationInContext: context]];
// Start date // Start date
if ((o = [self startDate])) if ((o = [self startDate]))
{ {
[s appendFormat: @"<StartDate xmlns=\"Tasks:\">%@</StartDate>", [o activeSyncRepresentation]]; [s appendFormat: @"<StartDate xmlns=\"Tasks:\">%@</StartDate>", [o activeSyncRepresentationInContext: context]];
[s appendFormat: @"<UTCStartDate xmlns=\"Tasks:\">%@</UTCStartDate>", [o activeSyncRepresentation]]; [s appendFormat: @"<UTCStartDate xmlns=\"Tasks:\">%@</UTCStartDate>", [o activeSyncRepresentationInContext: context]];
} }
// Due date // Due date
if ((o = [self due])) if ((o = [self due]))
{ {
[s appendFormat: @"<DueDate xmlns=\"Tasks:\">%@</DueDate>", [o activeSyncRepresentation]]; [s appendFormat: @"<DueDate xmlns=\"Tasks:\">%@</DueDate>", [o activeSyncRepresentationInContext: context]];
[s appendFormat: @"<UTCDueDate xmlns=\"Tasks:\">%@</UTCDueDate>", [o activeSyncRepresentation]]; [s appendFormat: @"<UTCDueDate xmlns=\"Tasks:\">%@</UTCDueDate>", [o activeSyncRepresentationInContext: context]];
} }
// Importance // Importance
@ -97,11 +102,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Subject // Subject
o = [self summary]; o = [self summary];
if ([o length]) if ([o length])
[s appendFormat: @"<Subject xmlns=\"Tasks:\">%@</Subject>", [[self summary] activeSyncRepresentation]]; [s appendFormat: @"<Subject xmlns=\"Tasks:\">%@</Subject>", [[self summary] activeSyncRepresentationInContext: context]];
if ((o = [self comment])) if ((o = [self comment]))
{ {
o = [o activeSyncRepresentation]; o = [o activeSyncRepresentationInContext: context];
[s appendString: @"<Body xmlns=\"AirSyncBase:\">"]; [s appendString: @"<Body xmlns=\"AirSyncBase:\">"];
[s appendFormat: @"<Type>%d</Type>", 1]; [s appendFormat: @"<Type>%d</Type>", 1];
[s appendFormat: @"<EstimatedDataSize>%d</EstimatedDataSize>", [o length]]; [s appendFormat: @"<EstimatedDataSize>%d</EstimatedDataSize>", [o length]];
@ -114,6 +119,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
} }
- (void) takeActiveSyncValues: (NSDictionary *) theValues - (void) takeActiveSyncValues: (NSDictionary *) theValues
inContext: (WOContext *) context
{ {
NSTimeZone *userTimeZone; NSTimeZone *userTimeZone;
iCalTimeZone *tz; iCalTimeZone *tz;
@ -121,7 +127,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NSInteger tzOffset; NSInteger tzOffset;
userTimeZone = [theValues objectForKey: @"SOGoUserTimeZone"]; userTimeZone = [[[context activeUser] userDefaults] timeZone];
tz = [iCalTimeZone timeZoneForName: [userTimeZone name]]; tz = [iCalTimeZone timeZoneForName: [userTimeZone name]];
[(iCalCalendar *) parent addTimeZone: tz]; [(iCalCalendar *) parent addTimeZone: tz];