Skip to content

Commit 48f98ef

Browse files
committed
Merge to 2.2.3
2 parents ae0c5ea + 378f2b5 commit 48f98ef

Some content is hidden

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

68 files changed

+1207
-676
lines changed

ActiveSync/GNUmakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ActiveSync_PRINCIPAL_CLASS = ActiveSyncProduct
99

1010
ActiveSync_OBJC_FILES = \
1111
ActiveSyncProduct.m \
12+
iCalAlarm+ActiveSync.m \
1213
iCalEvent+ActiveSync.m \
1314
iCalRecurrenceRule+ActiveSync.m \
1415
iCalTimeZone+ActiveSync.m \
@@ -30,7 +31,7 @@ ActiveSync_RESOURCE_FILES += \
3031

3132
ADDITIONAL_OBJCFLAGS += -Wno-deprecated-declarations
3233
ADDITIONAL_INCLUDE_DIRS += -I../SOPE/ -I../SoObjects/
33-
ADDITIONAL_LIB_DIRS += -L../../SOPE/GDLContentStore/obj/
34+
ADDITIONAL_LIB_DIRS += -L../SOPE/GDLContentStore/obj/ -L../SOPE/NGCards/obj/
3435
ADDITIONAL_INCLUDE_DIRS += -I/usr/include/libwbxml-1.0/
3536
ADDITIONAL_LDFLAGS += -Wl,--no-as-needed -lwbxml2
3637

ActiveSync/SOGoActiveSyncDispatcher.m

Lines changed: 97 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -868,105 +868,116 @@ - (void) processMoveItems: (id <DOMElement>) theDocumentElement
868868
{
869869
NSString *srcMessageId, *srcFolderId, *dstFolderId, *dstMessageId;
870870
SOGoMicrosoftActiveSyncFolderType srcFolderType, dstFolderType;
871+
id <DOMElement> aMoveOperation;
872+
NSArray *moveOperations;
873+
NSMutableString *s;
874+
NSData *d;
875+
int i;
876+
877+
moveOperations = (id)[theDocumentElement getElementsByTagName: @"Move"];
871878

872-
srcMessageId = [[(id)[theDocumentElement getElementsByTagName: @"SrcMsgId"] lastObject] textValue];
873-
srcFolderId = [[[(id)[theDocumentElement getElementsByTagName: @"SrcFldId"] lastObject] textValue] realCollectionIdWithFolderType: &srcFolderType];
874-
dstFolderId = [[[(id)[theDocumentElement getElementsByTagName: @"DstFldId"] lastObject] textValue] realCollectionIdWithFolderType: &dstFolderType];
879+
s = [NSMutableString string];
875880

876-
// FIXME
877-
if (srcFolderType == ActiveSyncMailFolder && dstFolderType == ActiveSyncMailFolder)
878-
{
879-
NGImap4Client *client;
880-
id currentCollection;
881+
[s appendString: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"];
882+
[s appendString: @"<!DOCTYPE ActiveSync PUBLIC \"-//MICROSOFT//DTD ActiveSync//EN\" \"http://www.microsoft.com/\">"];
883+
[s appendString: @"<MoveItems xmlns=\"Move:\">"];
881884

882-
NSDictionary *response;
883-
NSString *v;
885+
for (i = 0; i < [moveOperations count]; i++)
886+
{
887+
aMoveOperation = [moveOperations objectAtIndex: i];
884888

885-
currentCollection = [self collectionFromId: srcFolderId type: srcFolderType];
886-
887-
// [currentFolder lookupName: [NSString stringWithFormat: @"folder%@", srcFolderId]
888-
// inContext: context
889-
// acquire: NO];
890-
891-
client = [[currentCollection imap4Connection] client];
892-
[client select: srcFolderId];
893-
response = [client copyUid: [srcMessageId intValue]
894-
toFolder: [NSString stringWithFormat: @"/%@", dstFolderId]];
895-
896-
// We extract the destionation message id
897-
dstMessageId = nil;
898-
899-
if ([[response objectForKey: @"result"] boolValue]
900-
&& (v = [[[response objectForKey: @"RawResponse"] objectForKey: @"ResponseResult"] objectForKey: @"flag"])
901-
&& [v hasPrefix: @"COPYUID "])
902-
{
903-
dstMessageId = [[v componentsSeparatedByString: @" "] lastObject];
904-
905-
// We mark the original message as deleted
906-
response = [client storeFlags: [NSArray arrayWithObject: @"Deleted"]
907-
forUIDs: [NSArray arrayWithObject: srcMessageId]
908-
addOrRemove: YES];
909-
910-
if ([[response valueForKey: @"result"] boolValue])
911-
[(SOGoMailFolder *)currentCollection expunge];
912-
913-
}
889+
srcMessageId = [[(id)[aMoveOperation getElementsByTagName: @"SrcMsgId"] lastObject] textValue];
890+
srcFolderId = [[[(id)[aMoveOperation getElementsByTagName: @"SrcFldId"] lastObject] textValue] realCollectionIdWithFolderType: &srcFolderType];
891+
dstFolderId = [[[(id)[aMoveOperation getElementsByTagName: @"DstFldId"] lastObject] textValue] realCollectionIdWithFolderType: &dstFolderType];
892+
893+
[s appendString: @"<Response>"];
914894

915-
if (!dstMessageId)
916-
{
917-
[theResponse setStatus: 500];
918-
[theResponse appendContentString: @"Unable to move message"];
919-
}
920-
else
895+
// FIXME - we should support moving events between calendars, for example, or
896+
// or contacts between address books.
897+
if (srcFolderType == ActiveSyncMailFolder && dstFolderType == ActiveSyncMailFolder)
921898
{
922-
NSMutableString *s;
923-
NSData *d;
899+
NGImap4Client *client;
900+
id currentCollection;
924901

925-
//
926-
// If the MoveItems operation is initiated by an Outlook client, we save the "deviceType+dstMessageId" to use it later in order to
927-
// modify the Sync command from "add" to "change" (see SOGoActiveSyncDispatcher+Sync.m: -processSyncGetChanges: ...).
928-
// This is to avoid Outlook creating dupes when moving messages across folfers.
929-
//
930-
if ([[context objectForKey: @"DeviceType"] isEqualToString: @"WindowsOutlook15"])
931-
{
932-
NSString *key;
933-
934-
// The key must be pretty verbose. We use the <uid>+<DeviceType>+<target folder>+<DstMsgId>
935-
key = [NSString stringWithFormat: @"%@+%@+%@+%@",
936-
[[context activeUser] login],
937-
[context objectForKey: @"DeviceType"],
938-
dstFolderId,
939-
dstMessageId];
940-
941-
942-
[[SOGoCache sharedCache] setValue: @"MovedItem"
943-
forKey: key];
944-
}
945-
902+
NSDictionary *response;
903+
NSString *v;
946904

947-
// Everything is alright, lets return the proper response. "Status == 3" means success.
948-
s = [NSMutableString string];
905+
currentCollection = [self collectionFromId: srcFolderId type: srcFolderType];
949906

950-
[s appendString: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"];
951-
[s appendString: @"<!DOCTYPE ActiveSync PUBLIC \"-//MICROSOFT//DTD ActiveSync//EN\" \"http://www.microsoft.com/\">"];
952-
[s appendString: @"<MoveItems xmlns=\"Move:\">"];
953-
[s appendString: @"<Response>"];
954-
[s appendFormat: @"<SrcMsgId>%@</SrcMsgId>", srcMessageId];
955-
[s appendFormat: @"<DstMsgId>%@</DstMsgId>", dstMessageId];
956-
[s appendFormat: @"<Status>%d</Status>", 3];
957-
[s appendString: @"</Response>"];
958-
[s appendString: @"</MoveItems>"];
907+
client = [[currentCollection imap4Connection] client];
908+
[client select: srcFolderId];
909+
response = [client copyUid: [srcMessageId intValue]
910+
toFolder: [NSString stringWithFormat: @"/%@", dstFolderId]];
959911

960-
d = [[s dataUsingEncoding: NSUTF8StringEncoding] xml2wbxml];
912+
// We extract the destionation message id
913+
dstMessageId = nil;
961914

962-
[theResponse setContent: d];
915+
if ([[response objectForKey: @"result"] boolValue]
916+
&& (v = [[[response objectForKey: @"RawResponse"] objectForKey: @"ResponseResult"] objectForKey: @"flag"])
917+
&& [v hasPrefix: @"COPYUID "])
918+
{
919+
dstMessageId = [[v componentsSeparatedByString: @" "] lastObject];
920+
921+
// We mark the original message as deleted
922+
response = [client storeFlags: [NSArray arrayWithObject: @"Deleted"]
923+
forUIDs: [NSArray arrayWithObject: srcMessageId]
924+
addOrRemove: YES];
925+
926+
if ([[response valueForKey: @"result"] boolValue])
927+
[(SOGoMailFolder *)currentCollection expunge];
928+
929+
}
930+
931+
if (!dstMessageId)
932+
{
933+
// FIXME: should we return 1 or 2 here?
934+
[s appendFormat: @"<Status>%d</Status>", 2];
935+
}
936+
else
937+
{
938+
//
939+
// If the MoveItems operation is initiated by an Outlook client, we save the "deviceType+dstMessageId" to use it later in order to
940+
// modify the Sync command from "add" to "change" (see SOGoActiveSyncDispatcher+Sync.m: -processSyncGetChanges: ...).
941+
// This is to avoid Outlook creating dupes when moving messages across folfers.
942+
//
943+
if ([[context objectForKey: @"DeviceType"] isEqualToString: @"WindowsOutlook15"])
944+
{
945+
NSString *key;
946+
947+
// The key must be pretty verbose. We use the <uid>+<DeviceType>+<target folder>+<DstMsgId>
948+
key = [NSString stringWithFormat: @"%@+%@+%@+%@",
949+
[[context activeUser] login],
950+
[context objectForKey: @"DeviceType"],
951+
dstFolderId,
952+
dstMessageId];
953+
954+
955+
[[SOGoCache sharedCache] setValue: @"MovedItem"
956+
forKey: key];
957+
}
958+
959+
// Everything is alright, lets return the proper response. "Status == 3" means success.
960+
[s appendFormat: @"<SrcMsgId>%@</SrcMsgId>", srcMessageId];
961+
[s appendFormat: @"<DstMsgId>%@</DstMsgId>", dstMessageId];
962+
[s appendFormat: @"<Status>%d</Status>", 3];
963+
}
964+
963965
}
966+
else
967+
{
968+
// Non-mail move operations - unsupported for now.
969+
[s appendFormat: @"<Status>%d</Status>", 1];
970+
}
971+
972+
[s appendString: @"</Response>"];
964973
}
965-
else
966-
{
967-
[theResponse setStatus: 500];
968-
[theResponse appendContentString: @"Unsupported move operation"];
969-
}
974+
975+
976+
[s appendString: @"</MoveItems>"];
977+
978+
d = [[s dataUsingEncoding: NSUTF8StringEncoding] xml2wbxml];
979+
980+
[theResponse setContent: d];
970981
}
971982

972983
//

ActiveSync/SOGoMailObject+ActiveSync.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,16 @@ - (NSString *) activeSyncRepresentationInContext: (WOContext *) _context
762762
//
763763
//
764764
//
765+
// Exemple for a message being marked as read:
766+
//
767+
// <Change>
768+
// <ServerId>607</ServerId>
769+
// <ApplicationData>
770+
// <Read xmlns="Email:">1</Read>
771+
// </ApplicationData>
772+
// </Change>
773+
// </Commands>
774+
//
765775
- (void) takeActiveSyncValues: (NSDictionary *) theValues
766776
inContext: (WOContext *) _context
767777
{
@@ -776,6 +786,14 @@ - (void) takeActiveSyncValues: (NSDictionary *) theValues
776786
else
777787
[self removeFlags: @"\\Flagged"];
778788
}
789+
790+
if ((o = [theValues objectForKey: @"Read"]))
791+
{
792+
if ([o intValue])
793+
[self addFlags: @"seen"];
794+
else
795+
[self removeFlags: @"seen"];;
796+
}
779797
}
780798

781799
@end

ActiveSync/common.make

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# common make file for SoObject bundles
2-
31
include ../config.make
42
include $(GNUSTEP_MAKEFILES)/common.make
53
include ../Version
@@ -18,10 +16,10 @@ ADDITIONAL_INCLUDE_DIRS += \
1816
-I../../SOPE
1917

2018
ADDITIONAL_LIB_DIRS += \
21-
-L../SOGo/SOGo.framework/ \
22-
-L../../SOGo/$(GNUSTEP_OBJ_DIR)/ \
23-
-L../../OGoContentStore/$(GNUSTEP_OBJ_DIR)/ \
24-
-L../../SOPE/NGCards/$(GNUSTEP_OBJ_DIR)/ \
19+
-L../SoObjects/SOGo/SOGo.framework/ \
20+
-L../SoObjects/SOGo/$(GNUSTEP_OBJ_DIR)/ \
21+
-L../OGoContentStore/$(GNUSTEP_OBJ_DIR)/ \
22+
-L../SOPE/NGCards/$(GNUSTEP_OBJ_DIR)/ \
2523
-L/usr/local/lib
2624

2725
BUNDLE_LIBS += \

ActiveSync/iCalAlarm+ActiveSync.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 __ICALALARMACTIVESYNC_H__
31+
#define __ICALALARMACTIVESYNC_H__
32+
33+
#import <NGCards/iCalAlarm.h>
34+
35+
@class NSString;
36+
@class WOContext;
37+
38+
@interface iCalAlarm (ActiveSync)
39+
40+
- (NSString *) activeSyncRepresentationInContext: (WOContext *) context;
41+
- (void) takeActiveSyncValues: (NSDictionary *) theValues
42+
inContext: (WOContext *) context;
43+
44+
@end
45+
46+
#endif

0 commit comments

Comments
 (0)