[iphone/ZXingWidget] added support for non standard ORG attribute in MECARD format

git-svn-id: https://zxing.googlecode.com/svn/trunk@1694 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
rpechayr 2010-12-30 12:56:08 +00:00
parent 5e5ac2153e
commit 79381116c1
5 changed files with 30 additions and 3 deletions

View file

@ -30,6 +30,7 @@
NSString *email;
NSString *urlString;
NSString *address;
NSString *organization;
UIViewController *viewController;
}
@ -40,12 +41,14 @@
@property (nonatomic, copy) NSString *email;
@property (nonatomic, copy) NSString *urlString;
@property (nonatomic, copy) NSString *address;
@property (nonatomic, copy) NSString *organization;
+ (id)actionWithName:(NSString *)n
phoneNumbers:(NSArray *)nums
email:(NSString *)em
url:(NSString *)us
address:(NSString *)ad
note:(NSString *)nt;
note:(NSString *)nt
organization:(NSString *)org;
@end

View file

@ -31,13 +31,15 @@
@synthesize email;
@synthesize urlString;
@synthesize address;
@synthesize organization;
+ (id)actionWithName:(NSString *)n
phoneNumbers:(NSArray *)nums
email:(NSString *)em
url:(NSString *)us
address:(NSString *)ad
note:(NSString *)nt {
note:(NSString *)nt
organization:(NSString *)org {
AddContactAction *aca = [[[self alloc] init] autorelease];
aca.name = n;
aca.phoneNumbers = nums;
@ -45,6 +47,7 @@
aca.urlString = us;
aca.address = ad;
aca.note = nt;
aca.organization = org;
return aca;
}
@ -89,6 +92,10 @@
ABRecordSetValue(person, kABPersonNoteProperty, self.note, error);
}
if (self.organization) {
ABRecordSetValue(person, kABPersonOrganizationProperty, (CFStringRef)self.organization, error);
}
if (self.phoneNumbers && self.phoneNumbers.count > 0) {
// multi-values: nultiple phone numbers
ABMutableMultiValueRef phoneNumberMultiValue =
@ -221,4 +228,14 @@
[self performSelector:@selector(dismissUnknownPersonViewController:) withObject:unknownPersonViewController afterDelay:0.0];
}
}
- (void)dealloc {
[name release];
[phoneNumbers release];
[note release];
[email release];
[urlString release];
[address release];
[organization release];
}
@end

View file

@ -29,6 +29,7 @@
NSString *email;
NSString *urlString;
NSString *address;
NSString *organization;
}
@property (nonatomic, copy) NSString *name;
@ -37,5 +38,6 @@
@property (nonatomic, copy) NSString *email;
@property (nonatomic, copy) NSString *urlString;
@property (nonatomic, copy) NSString *address;
@property (nonatomic, copy) NSString *organization;
@end

View file

@ -30,9 +30,11 @@
@synthesize email;
@synthesize urlString;
@synthesize address;
@synthesize organization;
- (NSString *)stringForDisplay {
NSMutableString *result = [NSMutableString stringWithString:self.name];
if (self.organization) [result appendFormat:@"\n%@",self.organization];
if (self.phoneNumbers) {
for (NSString *number in self.phoneNumbers) {
[result appendFormat:@"\n%@", number];
@ -60,7 +62,8 @@
email:self.email
url:self.urlString
address:self.address
note:self.note]];
note:self.note
organization:self.organization]];
}
- (void) dealloc {
@ -70,6 +73,7 @@
[urlString release];
[address release];
[note release];
[organization release];
[super dealloc];
}

View file

@ -46,6 +46,7 @@
result.note = [s fieldWithPrefix:@"NOTE:"];
result.urlString = [s fieldWithPrefix:@"URL:"];
result.address = [s fieldWithPrefix:@"ADR:"];
result.organization = [s fieldWithPrefix:@"ORG:"];
return [result autorelease];
}