mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-19 21:53:19 +00:00
Monotone-Parent: 66f9ab1d22f9d44794e9868fe8705ef4777e0012
Monotone-Revision: e16807404ac6ea20632ee7e0e21ae2db34830540 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-08-12T20:51:10 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSURL.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
#import <NGObjWeb/WOContext.h>
|
||||
#import <NGObjWeb/WOContext+SoObjects.h>
|
||||
@@ -31,6 +32,7 @@
|
||||
#import <NGObjWeb/WORequest.h>
|
||||
#import <NGImap4/NGImap4Connection.h>
|
||||
#import <NGImap4/NGImap4Client.h>
|
||||
#import <EOControl/EOQualifier.h>
|
||||
|
||||
#import <Mailer/SOGoMailAccount.h>
|
||||
#import <Mailer/SOGoMailFolder.h>
|
||||
@@ -585,4 +587,51 @@
|
||||
return response;
|
||||
}
|
||||
|
||||
- (NSDictionary *) _unseenCount
|
||||
{
|
||||
EOQualifier *searchQualifier;
|
||||
NSArray *searchResult;
|
||||
NSDictionary *imapResult;
|
||||
NGImap4Connection *connection;
|
||||
NGImap4Client *client;
|
||||
int unseen;
|
||||
SOGoMailFolder *folder;
|
||||
|
||||
folder = [self clientObject];
|
||||
|
||||
connection = [folder imap4Connection];
|
||||
client = [connection client];
|
||||
|
||||
if ([connection selectFolder: [folder imap4URL]])
|
||||
{
|
||||
searchQualifier
|
||||
= [EOQualifier qualifierWithQualifierFormat: @"flags = %@ AND not flags = %@",
|
||||
@"unseen", @"deleted"];
|
||||
imapResult = [client searchWithQualifier: searchQualifier];
|
||||
searchResult = [[imapResult objectForKey: @"RawResponse"] objectForKey: @"search"];
|
||||
unseen = [searchResult count];
|
||||
}
|
||||
else
|
||||
unseen = 0;
|
||||
|
||||
return [NSDictionary
|
||||
dictionaryWithObject: [NSNumber numberWithInt: unseen]
|
||||
forKey: @"unseen"];
|
||||
}
|
||||
|
||||
- (WOResponse *) unseenCountAction
|
||||
{
|
||||
WOResponse *response;
|
||||
NSDictionary *data;
|
||||
|
||||
response = [self responseWithStatus: 200];
|
||||
data = [self _unseenCount];
|
||||
|
||||
[response setHeader: @"text/plain; charset=utf-8"
|
||||
forKey: @"content-type"];
|
||||
[response appendContentString: [data jsonRepresentation]];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user