See ChangeLog
Monotone-Parent: 8260a03656dcb7042c36f5ed015c0e1691560468 Monotone-Revision: 11c5eefb2d127036af170d47dc0f555860e8c38a Monotone-Author: crobert@inverse.ca Monotone-Date: 2009-10-05T19:15:14 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
3e7278ba0e
commit
5e342d5e99
|
@ -1,3 +1,10 @@
|
||||||
|
2009-10-05 Cyril Robert <crobert@inverse.ca>
|
||||||
|
|
||||||
|
* Tests/test-webdavlib.py: Added new tests for the URL parser / regexp.
|
||||||
|
* Tests/webdavlib.py: Fixed errors in the URL regexp.
|
||||||
|
* SoObjects/Mailer/EOQualifier+MailDAV.m: New category to generate IMAP
|
||||||
|
qualifiers from DAV filters. (REPORT)
|
||||||
|
|
||||||
2009-10-04 Ludovic Marcotte <lmarcotte@inverse.ca>
|
2009-10-04 Ludovic Marcotte <lmarcotte@inverse.ca>
|
||||||
|
|
||||||
* Adjusted the Welsh and Dutch templates for
|
* Adjusted the Welsh and Dutch templates for
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
/* EOQualifier+MailDAV.h - this file is part of SOGo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Inverse inc.
|
||||||
|
*
|
||||||
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This file 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EOQUALIFIER_MAILDAV_H
|
||||||
|
#define EOQUALIFIER_MAILDAV_H
|
||||||
|
|
||||||
|
#import <EOControl/EOQualifier.h>
|
||||||
|
#define XMLNS_INVERSEDAV @"urn:inverse:params:xml:ns:inverse-dav"
|
||||||
|
|
||||||
|
@class DOMElement;
|
||||||
|
|
||||||
|
@interface EOQualifier (SOGoMailDAVExtension)
|
||||||
|
|
||||||
|
+ (id) qualifierFromMailDAVMailFilters: (DOMElement *) mailFilters;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif /* EOQUALIFIER_MAILDAV_H */
|
|
@ -0,0 +1,141 @@
|
||||||
|
/* EOQualifier+MailDAV.m - this file is part of SOGo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Inverse inc.
|
||||||
|
*
|
||||||
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This file 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; see the file COPYING. If not, write to
|
||||||
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Foundation/NSString.h>
|
||||||
|
#import <Foundation/NSSet.h>
|
||||||
|
|
||||||
|
#import <DOM/DOMElement.h>
|
||||||
|
#import <DOM/DOMProtocols.h>
|
||||||
|
#import <SaxObjC/XMLNamespaces.h>
|
||||||
|
#import <SOGo/DOMNode+SOGo.h>
|
||||||
|
|
||||||
|
#import <NGCards/NSString+NGCards.h>
|
||||||
|
|
||||||
|
#import "EOQualifier+MailDAV.h"
|
||||||
|
|
||||||
|
@implementation EOQualifier (SOGoMailDAVExtension)
|
||||||
|
|
||||||
|
+ (NSString *) buildQualifierFromFilters: (DOMElement *) mailFilters
|
||||||
|
{
|
||||||
|
NSMutableArray *qualifiers;
|
||||||
|
NSString *qual, *buffer;
|
||||||
|
id <DOMNodeList> list;
|
||||||
|
DOMElement *current;
|
||||||
|
NSCalendarDate *startDate, *endDate;
|
||||||
|
int count, max;
|
||||||
|
|
||||||
|
qualifiers = [NSMutableArray array];
|
||||||
|
qual = nil;
|
||||||
|
|
||||||
|
list = [mailFilters childNodes];
|
||||||
|
if (list)
|
||||||
|
{
|
||||||
|
max = [list length];
|
||||||
|
for (count = 0; count < max; count++)
|
||||||
|
{
|
||||||
|
current = [list objectAtIndex: count];
|
||||||
|
if ([current nodeType] == DOM_ELEMENT_NODE)
|
||||||
|
{
|
||||||
|
// Received date
|
||||||
|
if ([[current tagName] isEqualToString: @"receive-date"])
|
||||||
|
{
|
||||||
|
startDate = [[current attribute: @"from"] asCalendarDate];
|
||||||
|
endDate = [[current attribute: @"to"] asCalendarDate];
|
||||||
|
if (startDate && [startDate isEqual: endDate])
|
||||||
|
[qualifiers addObject:
|
||||||
|
[NSString stringWithFormat: @"(on = '%@')", startDate]];
|
||||||
|
else if (startDate)
|
||||||
|
[qualifiers addObject:
|
||||||
|
[NSString stringWithFormat: @"(since > '%@')", startDate]];
|
||||||
|
if (endDate)
|
||||||
|
[qualifiers addObject:
|
||||||
|
[NSString stringWithFormat: @"(before < '%@')", endDate]];
|
||||||
|
}
|
||||||
|
// Sent date
|
||||||
|
else if ([[current tagName] isEqualToString: @"date"])
|
||||||
|
{
|
||||||
|
startDate = [[current attribute: @"from"] asCalendarDate];
|
||||||
|
endDate = [[current attribute: @"to"] asCalendarDate];
|
||||||
|
if (startDate && [startDate isEqual: endDate])
|
||||||
|
[qualifiers addObject:
|
||||||
|
[NSString stringWithFormat: @"(senton = '%@')", startDate]];
|
||||||
|
else if (startDate)
|
||||||
|
[qualifiers addObject:
|
||||||
|
[NSString stringWithFormat: @"(sentsince > '%@')", startDate]];
|
||||||
|
if (endDate)
|
||||||
|
[qualifiers addObject:
|
||||||
|
[NSString stringWithFormat: @"(sentbefore < '%@')", endDate]];
|
||||||
|
}
|
||||||
|
// Sequence
|
||||||
|
else if ([[current tagName] isEqualToString: @"sequence"])
|
||||||
|
{
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
// UID
|
||||||
|
else if ([[current tagName] isEqualToString: @"uid"])
|
||||||
|
{
|
||||||
|
buffer = [current attribute: @"uid"];
|
||||||
|
if (buffer)
|
||||||
|
[qualifiers addObject:
|
||||||
|
[NSString stringWithFormat: @"(uid = '%@')", buffer]];
|
||||||
|
}
|
||||||
|
// From
|
||||||
|
else if ([[current tagName] isEqualToString: @"from"])
|
||||||
|
{
|
||||||
|
buffer = [current attribute: @"from"];
|
||||||
|
if (buffer)
|
||||||
|
[qualifiers addObject:
|
||||||
|
[NSString stringWithFormat: @"(from = '%@')", buffer]];
|
||||||
|
}
|
||||||
|
// To
|
||||||
|
else if ([[current tagName] isEqualToString: @"to"])
|
||||||
|
{
|
||||||
|
buffer = [current attribute: @"to"];
|
||||||
|
if (buffer)
|
||||||
|
[qualifiers addObject:
|
||||||
|
[NSString stringWithFormat: @"(to = '%@')", buffer]];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([qualifiers count])
|
||||||
|
qual = [qualifiers componentsJoinedByString: @" AND "];
|
||||||
|
|
||||||
|
return qual;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
+ (id) qualifierFromMailDAVMailFilters: (DOMElement *) mailFilters
|
||||||
|
{
|
||||||
|
EOQualifier *newQualifier;
|
||||||
|
NSString *qual;
|
||||||
|
|
||||||
|
qual = [EOQualifier buildQualifierFromFilters: mailFilters];
|
||||||
|
|
||||||
|
newQualifier = [EOQualifier qualifierWithQualifierFormat: qual];
|
||||||
|
|
||||||
|
return newQualifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -32,6 +32,7 @@ Mailer_OBJC_FILES += \
|
||||||
SOGoMailForward.m \
|
SOGoMailForward.m \
|
||||||
SOGoMailReply.m \
|
SOGoMailReply.m \
|
||||||
\
|
\
|
||||||
|
EOQualifier+MailDAV.m \
|
||||||
NSData+Mail.m \
|
NSData+Mail.m \
|
||||||
NSString+Mail.m
|
NSString+Mail.m
|
||||||
|
|
||||||
|
|
|
@ -28,5 +28,23 @@ class HTTPUnparsedURLTest(unittest.TestCase):
|
||||||
self.assertEquals(testURL.port, None)
|
self.assertEquals(testURL.port, None)
|
||||||
self.assertEquals(testURL.path, "/folder/folder/simplereference")
|
self.assertEquals(testURL.path, "/folder/folder/simplereference")
|
||||||
|
|
||||||
|
pathURL = "http://user:secret@bla.com/hooray"
|
||||||
|
testURL = HTTPUnparsedURL(pathURL)
|
||||||
|
self.assertEquals(testURL.protocol, "http")
|
||||||
|
self.assertEquals(testURL.username, "user")
|
||||||
|
self.assertEquals(testURL.password, "secret")
|
||||||
|
self.assertEquals(testURL.hostname, "bla.com")
|
||||||
|
self.assertEquals(testURL.port, None)
|
||||||
|
self.assertEquals(testURL.path, "/hooray")
|
||||||
|
|
||||||
|
pathURL = "http://user@bla.com:80/hooray"
|
||||||
|
testURL = HTTPUnparsedURL(pathURL)
|
||||||
|
self.assertEquals(testURL.protocol, "http")
|
||||||
|
self.assertEquals(testURL.username, "user")
|
||||||
|
self.assertEquals(testURL.password, None)
|
||||||
|
self.assertEquals(testURL.hostname, "bla.com")
|
||||||
|
self.assertEquals(testURL.port, "80")
|
||||||
|
self.assertEquals(testURL.path, "/hooray")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -24,7 +24,7 @@ class HTTPUnparsedURL:
|
||||||
url_parts = url.split("?")
|
url_parts = url.split("?")
|
||||||
alpha_match = "[a-zA-Z0-9%\._-]+"
|
alpha_match = "[a-zA-Z0-9%\._-]+"
|
||||||
num_match = "[0-9]+"
|
num_match = "[0-9]+"
|
||||||
pattern = ("((%s)://(((%s)(:(%s)?)@)?(%s)(:(%s))))?(/.*)"
|
pattern = ("((%s)://(((%s)(:(%s))?@)?(%s)(:(%s))?))?(/.*)"
|
||||||
% (alpha_match, alpha_match, alpha_match,
|
% (alpha_match, alpha_match, alpha_match,
|
||||||
alpha_match, num_match))
|
alpha_match, num_match))
|
||||||
url_re = re.compile(pattern)
|
url_re = re.compile(pattern)
|
||||||
|
|
Loading…
Reference in New Issue