Monotone-Parent: b9ef4467c8539893214db9196096daa10370d0a6
Monotone-Revision: f75e6976fca1f78ba386ba4306bd6b4439f1de17 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-07-16T19:28:57 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
4500f4ad2d
commit
bb19a2ab6b
|
@ -1,3 +1,8 @@
|
||||||
|
2010-07-16 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* NGVCardPhoto.[hm]: new class module that implement facilities
|
||||||
|
for handling "PHOTO" tags in vcards.
|
||||||
|
|
||||||
2010-06-08 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2010-06-08 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
* iCalXMLRenderer.m (-[CardGroup xmlRender]): don't append empty
|
* iCalXMLRenderer.m (-[CardGroup xmlRender]): don't append empty
|
||||||
|
|
|
@ -57,6 +57,7 @@ libNGCards_HEADER_FILES = \
|
||||||
\
|
\
|
||||||
NGVCard.h \
|
NGVCard.h \
|
||||||
NGVList.h \
|
NGVList.h \
|
||||||
|
NGVCardPhoto.h \
|
||||||
NGVCardReference.h \
|
NGVCardReference.h \
|
||||||
# NGVCardAddress.h \
|
# NGVCardAddress.h \
|
||||||
# NGVCardStrArrayValue.h \
|
# NGVCardStrArrayValue.h \
|
||||||
|
@ -110,6 +111,7 @@ libNGCards_OBJC_FILES = \
|
||||||
\
|
\
|
||||||
NGVCard.m \
|
NGVCard.m \
|
||||||
NGVList.m \
|
NGVList.m \
|
||||||
|
NGVCardPhoto.m \
|
||||||
NGVCardReference.m \
|
NGVCardReference.m \
|
||||||
NGCardsSaxHandler.m \
|
NGCardsSaxHandler.m \
|
||||||
# IcalElements.m
|
# IcalElements.m
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
#import "NSArray+NGCards.h"
|
#import "NSArray+NGCards.h"
|
||||||
|
|
||||||
|
#import "NGVCardPhoto.h"
|
||||||
|
|
||||||
#import "NGVCard.h"
|
#import "NGVCard.h"
|
||||||
|
|
||||||
@implementation NGVCard
|
@implementation NGVCard
|
||||||
|
@ -79,6 +81,8 @@
|
||||||
|| [classTag isEqualToString: @"TITLE"]
|
|| [classTag isEqualToString: @"TITLE"]
|
||||||
|| [classTag isEqualToString: @"VERSION"])
|
|| [classTag isEqualToString: @"VERSION"])
|
||||||
tagClass = [CardElement class];
|
tagClass = [CardElement class];
|
||||||
|
else if ([classTag isEqualToString: @"PHOTO"])
|
||||||
|
tagClass = [NGVCardPhoto class];
|
||||||
else
|
else
|
||||||
tagClass = [super classForTag: classTag];
|
tagClass = [super classForTag: classTag];
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
/* NGVCardPhoto.h - this file is part of NGCards
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Inverse inc.
|
||||||
|
*
|
||||||
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
*
|
||||||
|
* NGCards 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.
|
||||||
|
*
|
||||||
|
* NGCards 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.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with NGCards; see the file COPYING. If not, write to the
|
||||||
|
* Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NGVCARDPHOTO_H
|
||||||
|
#define NGVCARDPHOTO_H
|
||||||
|
|
||||||
|
#import "CardElement.h"
|
||||||
|
|
||||||
|
@class NSData;
|
||||||
|
@class NSString;
|
||||||
|
|
||||||
|
@interface NGVCardPhoto : CardElement
|
||||||
|
|
||||||
|
- (BOOL) isInline;
|
||||||
|
|
||||||
|
- (NSString *) type;
|
||||||
|
|
||||||
|
- (NSData *) decodedContent;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif /* NGVCARDPHOTO_H */
|
|
@ -0,0 +1,78 @@
|
||||||
|
/* NGVCardPhoto.m - this file is part of NGCards
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Inverse inc.
|
||||||
|
*
|
||||||
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
*
|
||||||
|
* NGCards 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.
|
||||||
|
*
|
||||||
|
* NGCards 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.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with NGCards; see the file COPYING. If not, write to the
|
||||||
|
* Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||||
|
* 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#import <Foundation/NSArray.h>
|
||||||
|
#import <Foundation/NSString.h>
|
||||||
|
|
||||||
|
#import <NGExtensions/NGBase64Coding.h>
|
||||||
|
#import <NGExtensions/NSObject+Logs.h>
|
||||||
|
|
||||||
|
#import "NGVCardPhoto.h"
|
||||||
|
|
||||||
|
@implementation NGVCardPhoto
|
||||||
|
|
||||||
|
- (BOOL) isInline
|
||||||
|
{
|
||||||
|
return ![[self value: 0 ofAttribute: @"value"] isEqualToString: @"uri"];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) type
|
||||||
|
{
|
||||||
|
return [[self value: 0 ofAttribute: @"type"] uppercaseString];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSData *) decodedContent
|
||||||
|
{
|
||||||
|
NSString *encoding, *value;
|
||||||
|
NSData *decodedContent;
|
||||||
|
|
||||||
|
decodedContent = nil;
|
||||||
|
|
||||||
|
if ([self isInline])
|
||||||
|
{
|
||||||
|
encoding = [[self value: 0 ofAttribute: @"encoding"] uppercaseString];
|
||||||
|
if ([encoding isEqualToString: @"B"]
|
||||||
|
|| [encoding isEqualToString: @"BASE64"])
|
||||||
|
{
|
||||||
|
/* We bypass -[values:] because we want to obtain the undecoded
|
||||||
|
value first. */
|
||||||
|
if ([values count] > 0)
|
||||||
|
{
|
||||||
|
value = [values objectAtIndex: 0];
|
||||||
|
decodedContent = [value dataByDecodingBase64];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[self errorWithFormat: @"attempt to decode empty value"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[self errorWithFormat:
|
||||||
|
@"decoded content requested with an unknown encoding: '%@'",
|
||||||
|
encoding];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[self errorWithFormat:
|
||||||
|
@"decoded content requested on a PHOTO of type 'uri'"];
|
||||||
|
|
||||||
|
return decodedContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
Loading…
Reference in New Issue