Skip to content

Commit 95d6911

Browse files
committed
Merge to 2.2.4
2 parents 48f98ef + dace143 commit 95d6911

File tree

252 files changed

+10143
-3900
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

252 files changed

+10143
-3900
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
config.make
22
tags
3+
*._*
34
*/obj/
5+
*._*
46
*/*/obj/
57
*/*/*/obj/
68
*/*/*.SOGo/
@@ -11,3 +13,4 @@ SoObjects/SOGo/SOGo.framework/
1113
SoObjects/SOGo/derived_src/
1214
Tests/*/config.py
1315
*.pyc
16+
._*

ActiveSync/GNUmakefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@ ActiveSync_OBJC_FILES = \
1414
iCalRecurrenceRule+ActiveSync.m \
1515
iCalTimeZone+ActiveSync.m \
1616
iCalToDo+ActiveSync.m \
17-
NSCalendarDate+ActiveSync.m \
17+
NSCalendarDate+ActiveSync.m \
1818
NSData+ActiveSync.m \
1919
NSDate+ActiveSync.m \
2020
NGDOMElement+ActiveSync.m \
2121
NGMimeMessage+ActiveSync.m \
2222
NGVCard+ActiveSync.m \
23+
NSArray+SyncCache.m \
2324
NSString+ActiveSync.m \
2425
SOGoActiveSyncDispatcher.m \
2526
SOGoActiveSyncDispatcher+Sync.m \
26-
SOGoMailObject+ActiveSync.m \
27+
SOGoMailObject+ActiveSync.m \
28+
SOGoSyncCacheObject.m \
2729
SoObjectWebDAVDispatcher+ActiveSync.m
2830

2931
ActiveSync_RESOURCE_FILES += \

ActiveSync/NGDOMElement+ActiveSync.m

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,28 @@
3737

3838
@implementation NGDOMElement (ActiveSync)
3939

40+
- (BOOL) isTextNode
41+
{
42+
id <DOMNodeList> children;
43+
id <DOMElement> element;
44+
int i;
45+
46+
if ([self nodeType] == DOM_TEXT_NODE)
47+
return YES;
48+
49+
children = [self childNodes];
50+
51+
for (i = 0; i < [children length]; i++)
52+
{
53+
element = [children objectAtIndex: i];
54+
55+
if ([element nodeType] != DOM_TEXT_NODE)
56+
return NO;
57+
}
58+
59+
return YES;
60+
}
61+
4062
//
4163
// We must handle "inner data" like this:
4264
//
@@ -79,7 +101,7 @@ - (NSDictionary *) applicationData
79101
int i, count;
80102

81103
if (!asElementArray)
82-
asElementArray = [[NSArray alloc] initWithObjects: @"Attendee", nil];
104+
asElementArray = [[NSArray alloc] initWithObjects: @"Attendee", @"Category", nil];
83105

84106
data = [NSMutableDictionary dictionary];
85107

@@ -96,9 +118,17 @@ - (NSDictionary *) applicationData
96118

97119
tag = [element tagName];
98120
count = [(NSArray *)[element childNodes] count];
99-
121+
122+
// We check if the node is a text one or if all its
123+
// children are text nodes. This is important to avoid side-effects
124+
// in SOPE where "foo & bar" would result into 3 childnodes instead
125+
// of just one.
126+
if ([(id)element isTextNode])
127+
{
128+
value = [(id)element textValue];
129+
}
100130
// Handle inner data - see above for samples
101-
if (count > 2)
131+
else
102132
{
103133
NSMutableArray *innerElements;
104134
id <DOMElement> innerElement;
@@ -123,7 +153,10 @@ - (NSDictionary *) applicationData
123153

124154
if ([innerTag isEqualToString: [innerElement tagName]])
125155
{
126-
[innerElements addObject: [(NGDOMElement *)innerElement applicationData]];
156+
if ([(id)innerElement isTextNode])
157+
[innerElements addObject: [(NGDOMElement *)innerElement textValue]];
158+
else
159+
[innerElements addObject: [(NGDOMElement *)innerElement applicationData]];
127160
}
128161
else
129162
{
@@ -144,12 +177,11 @@ - (NSDictionary *) applicationData
144177
value = nil;
145178
}
146179
}
147-
else
148-
value = [[element firstChild] textValue];
149180

150181
if (value && tag)
151182
[data setObject: value forKey: tag];
152-
}
183+
184+
} // if ([element nodeType] == DOM_ELEMENT_NODE)
153185
}
154186

155187
return data;

ActiveSync/NGVCard+ActiveSync.m

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ @implementation NGVCard (ActiveSync)
4747

4848
- (NSString *) activeSyncRepresentationInContext: (WOContext *) context
4949
{
50+
NSArray *emails, *addresses, *categories, *elements;
5051
CardElement *n, *homeAdr, *workAdr;
51-
NSArray *emails, *addresses;
5252
NSMutableString *s;
53+
NSString *url;
5354
id o;
5455

5556
int i;
@@ -65,10 +66,42 @@ - (NSString *) activeSyncRepresentationInContext: (WOContext *) context
6566

6667
if ((o = [self workCompany]))
6768
[s appendFormat: @"<CompanyName xmlns=\"Contacts:\">%@</CompanyName>", [o activeSyncRepresentationInContext: context]];
69+
70+
if ((o = [[self org] flattenedValueAtIndex: 1 forKey: @""]))
71+
[s appendFormat: @"<Department xmlns=\"Contacts:\">%@</Department>", [o activeSyncRepresentationInContext: context]];
72+
73+
categories = [self categories];
74+
75+
if ([categories count])
76+
{
77+
[s appendFormat: @"<Categories xmlns=\"Contacts:\">"];
78+
for (i = 0; i < [categories count]; i++)
79+
{
80+
[s appendFormat: @"<Category xmlns=\"Contacts:\">%@</Category>", [[categories objectAtIndex: i] activeSyncRepresentationInContext: context]];
81+
}
82+
[s appendFormat: @"</Categories>"];
83+
}
84+
85+
elements = [self childrenWithTag: @"url"
86+
andAttribute: @"type"
87+
havingValue: @"work"];
88+
if ([elements count] > 0)
89+
{
90+
url = [[elements objectAtIndex: 0] flattenedValuesForKey: @""];
91+
[s appendFormat: @"<WebPage xmlns=\"Contacts:\">%@</WebPage>", [url activeSyncRepresentationInContext: context]];
92+
}
93+
94+
95+
if ((o = [[self uniqueChildWithTag: @"x-aim"] flattenedValuesForKey: @""]))
96+
[s appendFormat: @"<IMAddress xmlns=\"Contacts:\">%@</IMAddress>", [o activeSyncRepresentationInContext: context]];
97+
98+
if ((o = [self nickname]))
99+
[s appendFormat: @"<NickName xmlns=\"Contacts:\">%@</NickName>", [o activeSyncRepresentationInContext: context]];
100+
68101

69102
if ((o = [self title]))
70103
[s appendFormat: @"<JobTitle xmlns=\"Contacts:\">%@</JobTitle>", [o activeSyncRepresentationInContext: context]];
71-
104+
72105
if ((o = [self preferredEMail]))
73106
[s appendFormat: @"<Email1Address xmlns=\"Contacts:\">%@</Email1Address>", o];
74107

@@ -154,7 +187,7 @@ - (NSString *) activeSyncRepresentationInContext: (WOContext *) context
154187

155188
// Other, less important fields
156189
if ((o = [self birthday]))
157-
[s appendFormat: @"<Birthday xmlns=\"Contacts:\">%@</Birthday>", [o activeSyncRepresentationWithoutSeparatorsInContext: context]];
190+
[s appendFormat: @"<Birthday xmlns=\"Contacts:\">%@</Birthday>", [o activeSyncRepresentationInContext: context]];
158191

159192
if ((o = [self note]))
160193
{
@@ -183,6 +216,10 @@ - (void) takeActiveSyncValues: (NSDictionary *) theValues
183216
if ((o = [[theValues objectForKey: @"Body"] objectForKey: @"Data"]))
184217
[self setNote: o];
185218

219+
// Categories
220+
if ((o = [theValues objectForKey: @"Categories"]))
221+
[self setCategories: o];
222+
186223
// Birthday
187224
if ((o = [theValues objectForKey: @"Birthday"]))
188225
{
@@ -238,24 +275,31 @@ - (void) takeActiveSyncValues: (NSDictionary *) theValues
238275

239276
// Company's name
240277
if ((o = [theValues objectForKey: @"CompanyName"]))
241-
{
242-
[self setOrg: o units: nil];
243-
}
278+
[self setOrg: o units: nil];
279+
280+
// Department
281+
if ((o = [theValues objectForKey: @"Department"]))
282+
[self setOrg: nil units: [NSArray arrayWithObjects:o,nil]];
244283

245284
// Email addresses
246285
if ((o = [theValues objectForKey: @"Email1Address"]))
247286
{
248-
[self addEmail: o types: [NSArray arrayWithObject: @"pref"]];
287+
element = [self elementWithTag: @"email" ofType: @"work"];
288+
[element setSingleValue: o forKey: @""];
249289
}
250290

251291
if ((o = [theValues objectForKey: @"Email2Address"]))
252292
{
253-
[self addEmail: o types: nil];
293+
element = [self elementWithTag: @"email" ofType: @"home"];
294+
[element setSingleValue: o forKey: @""];
254295
}
255296

297+
// SOGo currently only supports 2 email addresses ... but AS clients might send 3
298+
// FIXME: revise this when the GUI revamp is done in SOGo
256299
if ((o = [theValues objectForKey: @"Email3Address"]))
257300
{
258-
[self addEmail: o types: nil];
301+
element = [self elementWithTag: @"email" ofType: @"three"];
302+
[element setSingleValue: o forKey: @""];
259303
}
260304

261305
// Formatted name
@@ -293,16 +337,15 @@ - (void) takeActiveSyncValues: (NSDictionary *) theValues
293337

294338
// Job's title
295339
if ((o = [theValues objectForKey: @"JobTitle"]))
296-
{
297-
[self setTitle: o];
298-
}
340+
[self setTitle: o];
299341

300342
// WebPage (work)
301343
if ((o = [theValues objectForKey: @"WebPage"]))
302-
{
303-
[[self elementWithTag: @"url" ofType: @"work"]
344+
[[self elementWithTag: @"url" ofType: @"work"]
304345
setSingleValue: o forKey: @""];
305-
}
346+
347+
if ((o = [theValues objectForKey: @"NickName"]))
348+
[self setNickname: o];
306349
}
307350

308351
@end

ActiveSync/NSArray+SyncCache.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
3+
Copyright (c) 2014, Inverse inc.
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright
10+
notice, this list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above copyright
12+
notice, this list of conditions and the following disclaimer in the
13+
documentation and/or other materials provided with the distribution.
14+
* Neither the name of the Inverse inc. nor the
15+
names of its contributors may be used to endorse or promote products
16+
derived from this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
22+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
29+
*/
30+
#ifndef __NSARRAYSYNCCACHE_H__
31+
#define __NSARRAYSYNCCACHE_H__
32+
33+
#import <Foundation/NSArray.h>
34+
35+
@class NSDictionary;
36+
37+
@interface NSMutableArray (SyncCache)
38+
39+
- (id) initWithDictionary: (NSDictionary *) theDictionary;
40+
41+
@end
42+
43+
@interface NSArray (SyncCache)
44+
45+
- (NSDictionary *) dictionaryValue;
46+
47+
@end
48+
49+
#endif

ActiveSync/NSArray+SyncCache.m

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
3+
Copyright (c) 2014, Inverse inc.
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
* Redistributions of source code must retain the above copyright
10+
notice, this list of conditions and the following disclaimer.
11+
* Redistributions in binary form must reproduce the above copyright
12+
notice, this list of conditions and the following disclaimer in the
13+
documentation and/or other materials provided with the distribution.
14+
* Neither the name of the Inverse inc. nor the
15+
names of its contributors may be used to endorse or promote products
16+
derived from this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
22+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
29+
*/
30+
#import "NSArray+SyncCache.h"
31+
32+
#import <Foundation/NSDictionary.h>
33+
34+
#include "SOGoSyncCacheObject.h"
35+
36+
@implementation NSMutableArray (SyncCache)
37+
38+
- (id) initWithDictionary: (NSDictionary *) theDictionary
39+
{
40+
SOGoSyncCacheObject *o;
41+
NSArray *allKeys;
42+
id key;
43+
int i;
44+
45+
self = [self initWithCapacity: [theDictionary count]];
46+
47+
allKeys = [theDictionary allKeys];
48+
49+
for (i = 0; i < [allKeys count]; i++)
50+
{
51+
key = [allKeys objectAtIndex: i];
52+
o = [SOGoSyncCacheObject syncCacheObjectWithUID: key
53+
sequence: [theDictionary objectForKey: key]];
54+
[self addObject: o];
55+
}
56+
57+
return self;
58+
}
59+
60+
@end
61+
62+
//
63+
//
64+
//
65+
@implementation NSArray (SyncCache)
66+
67+
- (NSDictionary *) dictionaryValue
68+
{
69+
NSMutableDictionary *d;
70+
SOGoSyncCacheObject *o;
71+
int i;
72+
73+
d = [NSMutableDictionary dictionary];
74+
75+
for (i = 0; i < [self count]; i++)
76+
{
77+
o = [self objectAtIndex: i];
78+
[d setObject: [o sequence] forKey: [o uid]];
79+
}
80+
81+
return d;
82+
}
83+
84+
@end

0 commit comments

Comments
 (0)