Monotone-Parent: f75e6976fca1f78ba386ba4306bd6b4439f1de17

Monotone-Revision: 33c9bbe67c54b7e2a222ee34969604fb76e91600

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2010-07-16T19:35:25
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2010-07-16 19:35:25 +00:00
parent bb19a2ab6b
commit 0f991b582f
24 changed files with 318 additions and 11 deletions

View File

@ -1,5 +1,21 @@
2010-07-16 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* UI/Contacts/UIxContactEditor.m (-photosURL): copy of the method
below.
* UI/Contacts/UIxContactView.m (-photosURL): new access that
returns the URL to the photos contained in the VCARD, whether
inline or not.
(-tabSelection): removed unused method.
* SoObjects/Contacts/SOGoContactGCSEntry.m
(-lookupName:inContext:acquire:): new overriden method to handle
"photoX" lookups and return the corrsponding SOGoContactEntryPhoto
instance, if exists.
* SoObjects/Contacts/SOGoContactEntryPhoto.[hm]: new controller
class for VCARD PHOTO objects.
* SoObjects/SOGo/SOGoContentObject.m (-davContentLength): fixed a
crash occurring with certain versions of GNUstep by using
NSISOLatin1StringEncoding instead of UTF8. This is actually the

View File

@ -19,6 +19,7 @@ Contacts_OBJC_FILES = \
SOGoContactLDIFEntry.m \
SOGoContactSourceFolder.m \
SOGoUserFolder+Contacts.m \
SOGoContactEntryPhoto.m \
Contacts_RESOURCE_FILES += \
Version \

View File

@ -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 */

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

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;

View File

@ -2,6 +2,7 @@
"Contact" = "Contact";
"Address" = "Address";
"Photos" = "Photos";
"Other" = "Other";
"Address Books" = "Addressbooks";

View File

@ -2,6 +2,7 @@
"Contact" = "Kontakt";
"Address" = "Adresa";
"Photos" = "Photos";
"Other" = "Ostatní";
"Address Books" = "Složky kontaktů";

View File

@ -2,6 +2,7 @@
"Contact" = "Contactpersoon";
"Address" = "Adres";
"Photos" = "Fotos";
"Other" = "Overige";
"Address Books" = "Addressbooks";

View File

@ -2,6 +2,7 @@
"Contact" = "Contact";
"Address" = "Address";
"Photos" = "Photos";
"Other" = "Other";
"Address Books" = "Address Books";

View File

@ -2,6 +2,7 @@
"Contact" = "Contact";
"Address" = "Adresses";
"Photos" = "Photos";
"Other" = "Informations complémentaires";
"Address Books" = "Carnet d'adresses";

View File

@ -2,6 +2,7 @@
"Contact" = "Kontakt";
"Address" = "Adresse";
"Photos" = "Fotos";
"Other" = "Sonstiges";
"Address Books" = "Adressbücher";

View File

@ -2,6 +2,7 @@
"Contact" = "Contact";
"Address" = "Address";
"Photos" = "Photos";
"Other" = "Other";
"Address Books" = "Addressbooks";

View File

@ -2,6 +2,7 @@
"Contact" = "Contatto";
"Address" = "Indirizzo";
"Photos" = "Photos";
"Other" = "Altro";
"Address Books" = "Rubrica";

View File

@ -1,5 +1,10 @@
/* this file is in UTF-8 format! */
"Contact" = "Contact";
"Address" = "Address";
"Photos" = "Photos";
"Other" = "Other";
"Addressbook" = "Адресная книга";
"Addresses" = "Адреса";
"Update" = "Обновить";

View File

@ -2,6 +2,7 @@
"Contact" = "Contacto";
"Address" = "Dirección";
"Photos" = "Photos";
"Other" = "Otros datos";
"Address Books" = "Libretas de direcciones";

View File

@ -2,6 +2,7 @@
"Contact" = "Kontakt";
"Address" = "Adress";
"Photos" = "Photos";
"Other" = "Annat";
"Address Books" = "Adressböcker";

View File

@ -37,6 +37,7 @@
NSString *preferredEmail;
NSString *item;
NGVCard *card;
NSMutableArray *photosURL;
NSMutableDictionary *snapshot; /* contains the values for editing */
SOGoContactFolder *componentAddressBook;
}

View File

@ -22,6 +22,7 @@
#import <Foundation/NSDictionary.h>
#import <Foundation/NSString.h>
#import <Foundation/NSURL.h>
#import <Foundation/NSEnumerator.h>
#import <NGObjWeb/NSException+HTTP.h>
@ -33,6 +34,7 @@
#import <NGExtensions/NSNull+misc.h>
#import <NGCards/NGVCard.h>
#import <NGCards/NGVCardPhoto.h>
#import <NGCards/NSArray+NGCards.h>
#import <Contacts/SOGoContactFolder.h>
@ -51,6 +53,7 @@
{
snapshot = [[NSMutableDictionary alloc] initWithCapacity: 16];
preferredEmail = nil;
photosURL = nil;
}
return self;
@ -60,6 +63,7 @@
{
[snapshot release];
[preferredEmail release];
[photosURL release];
[super dealloc];
}
@ -573,6 +577,36 @@
&& [super canCreateOrModify]);
}
- (NSArray *) photosURL
{
NSArray *photoElements;
NSURL *soURL;
NSString *baseInlineURL, *photoURL;
NGVCardPhoto *photo;
int count, max;
if (!photosURL)
{
soURL = [[self clientObject] soURL];
baseInlineURL = [soURL absoluteString];
photoElements = [card childrenWithTag: @"photo"];
max = [photoElements count];
photosURL = [[NSMutableArray alloc] initWithCapacity: max];
for (count = 0; count < max; count++)
{
photo = [photoElements objectAtIndex: count];
if ([photo isInline])
photoURL = [NSString stringWithFormat: @"%@/photo%d",
baseInlineURL, count];
else
photoURL = [photo value: 0];
[photosURL addObject: photoURL];
}
}
return photosURL;
}
- (CardElement *) _elementWithTag: (NSString *) tag
ofType: (NSString *) type
{

View File

@ -32,6 +32,7 @@
NSArray *phones;
CardElement *homeAdr;
CardElement *workAdr;
NSMutableArray *photosURL;
}
- (NSString *) fullName;

View File

@ -20,30 +20,40 @@
02111-1307, USA.
*/
#import <Foundation/NSURL.h>
#import <NGObjWeb/NSException+HTTP.h>
#import <NGObjWeb/WOResponse.h>
#import <NGCards/NGVCard.h>
#import <NGCards/NGVCardPhoto.h>
#import <NGCards/CardElement.h>
#import <NGCards/NSArray+NGCards.h>
#import <NGExtensions/NSString+Ext.h>
#import <SoObjects/Contacts/SOGoContactObject.h>
#import <Contacts/SOGoContactObject.h>
#import "UIxContactView.h"
@implementation UIxContactView
/* accessors */
- (id) init
{
if ((self = [super init]))
{
photosURL = nil;
}
- (NSString *)tabSelection {
NSString *selection;
selection = [self queryParameterForKey:@"tab"];
if (selection == nil)
selection = @"attributes";
return selection;
return self;
}
- (void) dealloc
{
[photosURL release];
[super dealloc];
}
/* accessors */
- (NSString *) _cardStringWithLabel: (NSString *) label
value: (NSString *) value
{
@ -630,4 +640,34 @@
return self;
}
- (NSArray *) photosURL
{
NSArray *photoElements;
NSURL *soURL;
NSString *baseInlineURL, *photoURL;
NGVCardPhoto *photo;
int count, max;
if (!photosURL)
{
soURL = [[self clientObject] soURL];
baseInlineURL = [soURL absoluteString];
photoElements = [card childrenWithTag: @"photo"];
max = [photoElements count];
photosURL = [[NSMutableArray alloc] initWithCapacity: max];
for (count = 0; count < max; count++)
{
photo = [photoElements objectAtIndex: count];
if ([photo isInline])
photoURL = [NSString stringWithFormat: @"%@/photo%d",
baseInlineURL, count];
else
photoURL = [photo value: 0];
[photosURL addObject: photoURL];
}
}
return photosURL;
}
@end /* UIxContactView */

View File

@ -2,6 +2,7 @@
"Contact" = "Контакт";
"Address" = "Адреса";
"Photos" = "Photos";
"Other" = "Інше";
"Address Books" = "Адресні книги";

View File

@ -1,5 +1,10 @@
/* this file is in UTF-8 format! */
"Contact" = "Contact";
"Address" = "Address";
"Photos" = "Photos";
"Other" = "Other";
"Addressbook" = "Llyfr cyfeiriadau";
"Addresses" = "Cyfeiriadau";
"Update" = "Diweddaru";

View File

@ -29,6 +29,8 @@
</li>
<li target="addressesInfos">
<span><var:string label:value="Address" /></span></li>
<li target="photos">
<span><var:string label:value="Photos" /></span></li>
<li target="otherInfos">
<span><var:string label:value="Other" /></span></li>
</ul>
@ -332,6 +334,12 @@
</table>
</div>
<div id="photos" class="tab">
<var:foreach list="photosURL" item="currentPhotoURL">
<img var:src="currentPhotoURL" class="contactPhoto"/><br
/></var:foreach>
</div>
<div id="otherInfos" class="tab">
<table class="framenocaption">
<tr>

View File

@ -18,8 +18,10 @@
/><var:string value="secondaryEmail" escapeHTML="NO"
/><var:string value="screenName" escapeHTML="NO"
/><var:string value="preferredAddress" escapeHTML="NO"
/></div
/><var:foreach list="photosURL" item="currentPhotoURL"
><br/><img var:src="currentPhotoURL" class="contactPhoto"/>
</var:foreach></div
><var:if condition="hasHomeInfos"
><div id="homeInfos"
><h4><var:string label:value="Home" /></h4