Fixed the ActiveSync issue marking mails as read when downloading them

pull/30/head
Ludovic Marcotte 2014-03-28 14:18:48 -04:00
parent 6e4f776d4b
commit ba32b95308
5 changed files with 48 additions and 39 deletions

View File

@ -762,6 +762,16 @@ struct GlobalObjectId {
//
//
//
// Exemple for a message being marked as read:
//
// <Change>
// <ServerId>607</ServerId>
// <ApplicationData>
// <Read xmlns="Email:">1</Read>
// </ApplicationData>
// </Change>
// </Commands>
//
- (void) takeActiveSyncValues: (NSDictionary *) theValues
inContext: (WOContext *) _context
{
@ -776,6 +786,14 @@ struct GlobalObjectId {
else
[self removeFlags: @"\\Flagged"];
}
if ((o = [theValues objectForKey: @"Read"]))
{
if ([o intValue])
[self addFlags: @"seen"];
else
[self removeFlags: @"seen"];;
}
}
@end

1
NEWS
View File

@ -5,6 +5,7 @@ Bug fixes
- fixed possible exception when retrieving the default event reminder value on 64bit architectures (#2678)
- fixed calling unescapeHTML on null variables to avoid JavaScript exceptions in Contacts module
- fixed detection of IMAP flags support on the client side (#2664)
- fixed the ActiveSync issue marking all mails as read when downloading them
2.2.2 (2014-03-21)
------------------

View File

@ -1,14 +1,15 @@
/*
Copyright (C) 2007-2014 Inverse inc.
Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of OpenGroupware.org.
This file is part of SOGo.
OGo is free software; you can redistribute it and/or modify it under
SOGo is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2007-2009 Inverse inc.
Copyright (C) 2007-2014 Inverse inc.
Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of SOGo.
@ -434,7 +434,8 @@ static BOOL debugSoParts = NO;
NSData *content;
id result, fullResult;
fullResult = [self fetchParts: [NSArray arrayWithObject: @"RFC822"]];
// We avoid using RFC822 here as the part name as it'll flag the message as Seen
fullResult = [self fetchParts: [NSArray arrayWithObject: @"BODY.PEEK[]"]];
if (fullResult == nil)
return nil;
@ -458,7 +459,7 @@ static BOOL debugSoParts = NO;
/* extract message */
if ((content = [result valueForKey: @"message"]) == nil) {
if ((content = [[result valueForKey: @"body[]"] valueForKey: @"data"]) == nil) {
[self logWithFormat:
@"ERROR: unexpected IMAP4 result (missing 'message'): %@",
result];
@ -504,26 +505,6 @@ static BOOL debugSoParts = NO;
}
/* bulk fetching of plain/text content */
// - (BOOL) shouldFetchPartOfType: (NSString *) _type
// subtype: (NSString *) _subtype
// {
// /*
// This method decides which parts are 'prefetched' for display. Those are
// usually text parts (the set is currently hardcoded in this method ...).
// */
// _type = [_type lowercaseString];
// _subtype = [_subtype lowercaseString];
// return (([_type isEqualToString: @"text"]
// && ([_subtype isEqualToString: @"plain"]
// || [_subtype isEqualToString: @"html"]
// || [_subtype isEqualToString: @"calendar"]))
// || ([_type isEqualToString: @"application"]
// && ([_subtype isEqualToString: @"pgp-signature"]
// || [_subtype hasPrefix: @"x-vnd.kolab."])));
// }
- (void) addRequiredKeysOfStructure: (NSDictionary *) info
path: (NSString *) p
toArray: (NSMutableArray *) keys
@ -623,9 +604,12 @@ static BOOL debugSoParts = NO;
@"text/calendar", @"application/ics",
@"application/pgp-signature", nil];
ma = [NSMutableArray arrayWithCapacity: 4];
[self addRequiredKeysOfStructure: [self bodyStructure]
path: @"" toArray: ma acceptedTypes: types
withPeek: NO];
path: @""
toArray: ma
acceptedTypes: types
withPeek: YES];
return ma;
}
@ -655,6 +639,12 @@ static BOOL debugSoParts = NO;
NSData *data;
key = [[_fetchKeys objectAtIndex:i] objectForKey: @"key"];
// We'll ask for the body.peek[] but SOPE returns us body[] responses
// so the key won't ever be found.
if ([key hasPrefix: @"body.peek["])
key = [NSString stringWithFormat: @"body[%@", [key substringFromIndex: 10]];
data = [(NSDictionary *)[(NSDictionary *)result objectForKey:key]
objectForKey: @"data"];
@ -1345,11 +1335,6 @@ static BOOL debugSoParts = NO;
return mailETag;
}
- (int) zlGenerationCount
{
return 0; /* mails never change */
}
- (NSArray *) aclsForUser: (NSString *) uid
{
return [container aclsForUser: uid];
@ -1533,7 +1518,7 @@ static BOOL debugSoParts = NO;
NSRange range;
rc = nil;
fetch = [self _fetchProperty: @"BODY[HEADER.FIELDS (RECEIVED)]"];
fetch = [self _fetchProperty: @"BODY.PEEK[HEADER.FIELDS (RECEIVED)]"];
if ([fetch count])
{
@ -1568,7 +1553,7 @@ static BOOL debugSoParts = NO;
NSString *value, *rc;
rc = nil;
fetch = [self _fetchProperty: @"BODY[HEADER.FIELDS (REFERENCES)]"];
fetch = [self _fetchProperty: @"BODY.PEEK[HEADER.FIELDS (REFERENCES)]"];
if ([fetch count])
{

View File

@ -245,7 +245,7 @@ function mailListToggleMessageThread(row, cell) {
/* Triggered when clicking on the read/unread dot of a message row or
* through the contextual menu. */
function mailListToggleMessagesRead(row) {
function mailListToggleMessagesRead(row, force_mark_as_read) {
var selectedRowsId = [];
if (row) {
selectedRowsId = [row.id];
@ -265,10 +265,13 @@ function mailListToggleMessagesRead(row) {
action = 'markMessageRead';
markread = true;
}
else {
else if (!force_mark_as_read) {
action = 'markMessageUnread';
markread = false;
}
else {
return;
}
for (var i = 0; i < selectedRowsId.length; i++) {
var msguid = selectedRowsId[i].split('_')[1];
@ -1224,8 +1227,6 @@ function loadMessage(msguid) {
{ 'mailbox': Mailer.currentMailbox,
'msguid': msguid,
'seenStateHasChanged': seenStateHasChanged });
// Warning: We assume the user can set the read/unread flag of the message.
markMailInWindow(window, msguid, true);
}
else {
div.innerHTML = cachedMessage['text'];
@ -1643,6 +1644,9 @@ function loadMessageCallback(http) {
cachedMessage['text'] = http.responseText;
if (cachedMessage['text'].length < 30000)
storeCachedMessage(cachedMessage);
// We mark the mail as read
mailListToggleMessagesRead($("row_" + msguid), true);
}
}
else if (http.status == 404) {