Monotone-Parent: f75e6976fca1f78ba386ba4306bd6b4439f1de17

Monotone-Revision: 33c9bbe67c54b7e2a222ee34969604fb76e91600

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-07-16T19:35:25
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau committed 2010-07-16 19:35:25 +00:00
1 parent bb19a2ab6b
commit 0f991b582f
24 files changed
+318 -11

No files matched your search

+1
View File
@@ -19,6 +19,7 @@ Contacts_OBJC_FILES = \
SOGoContactLDIFEntry.m \
SOGoContactSourceFolder.m \
SOGoUserFolder+Contacts.m \
SOGoContactEntryPhoto.m \
Contacts_RESOURCE_FILES += \
Version \
@@ -0,0 +1,42 @@
/* SOGoContactEntryPhoto.h - this file is part of SOGo
*
* Copyright (C) 2010 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 SOGOCONTACTENTRYPHOTO_H
#define SOGOCONTACTENTRYPHOTO_H
#import <SOGo/SOGoObject.h>
@interface SOGoContactEntryPhoto : SOGoObject
{
int photoID;
}
+ (id) entryPhotoWithID: (int) photoId
inContainer: (id) container;
- (void) setPhotoID: (int) newPhotoID;
- (NSString *) davContentType;
@end
#endif /* SOGOCONTACTENTRYPHOTO_H */
+114
View File
@@ -0,0 +1,114 @@
/* SOGoContactEntryPhoto.m - this file is part of SOGo
*
* Copyright (C) 2010 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/NSArray.h>
#import <Foundation/NSString.h>
#import <NGObjWeb/WOContext.h>
#import <NGObjWeb/WOResponse.h>
#import <NGCards/NGVCard.h>
#import <NGCards/NGVCardPhoto.h>
#import "SOGoContactObject.h"
#import "SOGoContactEntryPhoto.h"
@implementation SOGoContactEntryPhoto
+ (id) entryPhotoWithID: (int) photoID
inContainer: (id) container
{
id photo;
photo
= [super objectWithName: [NSString stringWithFormat: @"photo%d", photoID]
inContainer: container];
[photo setPhotoID: photoID];
return photo;
}
- (void) setPhotoID: (int) newPhotoID
{
photoID = newPhotoID;
}
- (NGVCardPhoto *) photo
{
NGVCardPhoto *photo;
NSArray *photoElements;
photoElements = [[container vCard] childrenWithTag: @"photo"];
if ([photoElements count] > photoID)
photo = [photoElements objectAtIndex: photoID];
else
photo = nil;
return photo;
}
- (id) GETAction: (WOContext *) localContext
{
NGVCardPhoto *photo;
NSData *data;
id response;
photo = [self photo];
if ([photo isInline])
data = [photo decodedContent];
else
data = [[photo value: 0] dataUsingEncoding: NSISOLatin1StringEncoding];
if (data)
{
response = [localContext response];
[response setHeader: [self davContentType] forKey: @"content-type"];
[response setHeader: [NSString stringWithFormat:@" %d",
[data length]]
forKey: @"content-length"];
[response setContent: data];
}
else
response = nil;
return response;
}
- (NSString *) davContentType
{
NGVCardPhoto *photo;
NSString *type, *contentType;
photo = [self photo];
if ([photo isInline])
{
type = [[photo type] lowercaseString];
contentType = [NSString stringWithFormat: @"image/%@", type];
}
else
contentType = @"text/plain";
return contentType;
}
@end
+27
View File
@@ -24,6 +24,8 @@
#import <NGCards/NGVCard.h>
#import "SOGoContactEntryPhoto.h"
#import "SOGoContactGCSEntry.h"
@implementation SOGoContactGCSEntry
@@ -62,6 +64,31 @@
/* actions */
- (id) lookupName: (NSString *) lookupName
inContext: (id) localContext
acquire: (BOOL) acquire
{
id obj;
int photoIndex;
NSArray *photoElements;
if ([lookupName hasPrefix: @"photo"])
{
photoElements = [[self vCard] childrenWithTag: @"photo"];
photoIndex = [[lookupName substringFromIndex: 5] intValue];
if (photoIndex > -1 && photoIndex < [photoElements count])
obj = [SOGoContactEntryPhoto entryPhotoWithID: photoIndex
inContainer: self];
else
obj = nil;
}
else
obj = [super lookupName: lookupName inContext: localContext
acquire: acquire];
return obj;
}
- (NSException *) copyToFolder: (SOGoGCSFolder *) newFolder
{
NGVCard *newCard;