Monotone-Parent: b4fb8a5b2019af495e57ab7338a4ee3204d34e25
Monotone-Revision: 90d0bb9c9e2993df03892b4e1648345dbbc8d83f Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-08-02T19:54:02 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
parent
bc733caf4b
commit
01edf54a1a
|
@ -1,3 +1,10 @@
|
||||||
|
2006-08-02 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* SoObjects/Contacts/NSDictionary+Contact.m
|
||||||
|
([NSDictionary -vcardContentFromSOGoContactRecord]): extension
|
||||||
|
method to convert the dictionary returned with the user submission
|
||||||
|
to a record in VCARD format to be stored in the database.
|
||||||
|
|
||||||
2006-08-01 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2006-08-01 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
* UI/WebServerResources/MailerUI.js: when opening the context menu
|
* UI/WebServerResources/MailerUI.js: when opening the context menu
|
||||||
|
|
|
@ -11,6 +11,8 @@ Contacts_OBJC_FILES = \
|
||||||
\
|
\
|
||||||
SOGoContactObject.m \
|
SOGoContactObject.m \
|
||||||
SOGoContactFolder.m \
|
SOGoContactFolder.m \
|
||||||
|
\
|
||||||
|
NSDictionary+Contact.m
|
||||||
|
|
||||||
Contacts_RESOURCE_FILES += \
|
Contacts_RESOURCE_FILES += \
|
||||||
Version \
|
Version \
|
||||||
|
|
36
SoObjects/Contacts/NSDictionary+Contact.h
Normal file
36
SoObjects/Contacts/NSDictionary+Contact.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/* NSDictionary+Contact.h - this file is part of $PROJECT_NAME_HERE$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Inverse groupe conseil
|
||||||
|
*
|
||||||
|
* 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 NSDICTIONARY_CONTACT_H
|
||||||
|
#define NSDICTIONARY_CONTACT_H
|
||||||
|
|
||||||
|
#import <Foundation/NSDictionary.h>
|
||||||
|
|
||||||
|
@class NSString;
|
||||||
|
|
||||||
|
@interface NSDictionary (SOGoContact)
|
||||||
|
|
||||||
|
- (NSString *) vcardContentFromSOGoContactRecord;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif /* NSDICTIONARY_CONTACT_H */
|
111
SoObjects/Contacts/NSDictionary+Contact.m
Normal file
111
SoObjects/Contacts/NSDictionary+Contact.m
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
/* NSDictionary+Contact.m - this file is part of SOGo
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 Inverse groupe conseil
|
||||||
|
*
|
||||||
|
* 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/NSString.h>
|
||||||
|
|
||||||
|
#import "NSDictionary+Contact.h"
|
||||||
|
|
||||||
|
@implementation NSDictionary (SOGoContact)
|
||||||
|
|
||||||
|
- (void) _appendSingleVCardValue: (NSString *) value
|
||||||
|
withFormat: (NSString *) format
|
||||||
|
toVCard: (NSMutableString *) vCard
|
||||||
|
{
|
||||||
|
NSString *info;
|
||||||
|
|
||||||
|
info = [self objectForKey: value];
|
||||||
|
if (info && [info length] > 0)
|
||||||
|
[vCard appendFormat: format, info];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString *) vcardContentFromSOGoContactRecord
|
||||||
|
{
|
||||||
|
NSMutableString *newVCard;
|
||||||
|
NSString *info, *info2;
|
||||||
|
|
||||||
|
newVCard = [NSMutableString new];
|
||||||
|
[newVCard autorelease];
|
||||||
|
|
||||||
|
[newVCard appendString: @"BEGIN:VCARD\r\n"
|
||||||
|
"VERSION:3.0\r\n"
|
||||||
|
"PRODID:-//OpenGroupware.org//LSAddress v5.3.85\r\n"
|
||||||
|
"PROFILE:vCard\r\n"];
|
||||||
|
|
||||||
|
[self _appendSingleVCardValue: @"cn"
|
||||||
|
withFormat: @"FN:%@"
|
||||||
|
toVCard: newVCard];
|
||||||
|
|
||||||
|
info = [self objectForKey: @"givenName"];
|
||||||
|
if (!info || [info length] < 1)
|
||||||
|
info = @"";
|
||||||
|
info2 = [self objectForKey: @"sn"];
|
||||||
|
if (!info2 || [info2 length] < 1)
|
||||||
|
info2 = @"";
|
||||||
|
[newVCard appendFormat: @"N:%@;%@;;;\r\n",
|
||||||
|
info2, info];
|
||||||
|
|
||||||
|
[self _appendSingleVCardValue: @"telephoneNumber"
|
||||||
|
withFormat: @"TEL;TYPE=work,voice,pref:%@"
|
||||||
|
toVCard: newVCard];
|
||||||
|
[self _appendSingleVCardValue: @"facsimileTelephoneNumber"
|
||||||
|
withFormat: @"TEL;TYPE=work,fax:%@"
|
||||||
|
toVCard: newVCard];
|
||||||
|
[self _appendSingleVCardValue: @"homeTelephoneNumber"
|
||||||
|
withFormat: @"TEL;TYPE=home,voice:%@"
|
||||||
|
toVCard: newVCard];
|
||||||
|
[self _appendSingleVCardValue: @"mobile"
|
||||||
|
withFormat: @"TEL;TYPE=cell,voice:%@"
|
||||||
|
toVCard: newVCard];
|
||||||
|
|
||||||
|
info = [self objectForKey: @"l"];
|
||||||
|
if (!info || [info length] < 1)
|
||||||
|
info = @"";
|
||||||
|
info2 = [self objectForKey: @"departmentNumber"];
|
||||||
|
if (!info2 || [info2 length] < 1)
|
||||||
|
info2 = @"";
|
||||||
|
[newVCard appendFormat: @"ORG:%@;%@\r\n",
|
||||||
|
info, info2];
|
||||||
|
|
||||||
|
[newVCard appendString: @"END:VCARD\r\n"];
|
||||||
|
|
||||||
|
info = [[self objectForKey: @"postalAddress"]
|
||||||
|
stringByReplacingString: @"\r\n"
|
||||||
|
withString: @";"];
|
||||||
|
if (info && [info length] > 0)
|
||||||
|
[newVCard appendFormat: @"ADR:TYPE=work,postal:%@", info];
|
||||||
|
info = [[self objectForKey: @"homePostalAddress"]
|
||||||
|
stringByReplacingString: @"\r\n"
|
||||||
|
withString: @";"];
|
||||||
|
if (info && [info length] > 0)
|
||||||
|
[newVCard appendFormat: @"ADR:TYPE=home,postal:%@", info];
|
||||||
|
|
||||||
|
[self _appendSingleVCardValue: @"mail"
|
||||||
|
withFormat: @"EMAIL;TYPE=internet,pref:%@"
|
||||||
|
toVCard: newVCard];
|
||||||
|
[self _appendSingleVCardValue: @"labelledURI"
|
||||||
|
withFormat: @"URL:%@"
|
||||||
|
toVCard: newVCard];
|
||||||
|
|
||||||
|
return newVCard;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -19,9 +19,11 @@
|
||||||
02111-1307, USA.
|
02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "SOGoContactObject.h"
|
#import <NGiCal/NGVCard.h>
|
||||||
#include <NGiCal/NGVCard.h>
|
|
||||||
#include "common.h"
|
#import "common.h"
|
||||||
|
#import "SOGoContactObject.h"
|
||||||
|
#import "NSDictionary+Contact.h"
|
||||||
|
|
||||||
@implementation SOGoContactObject
|
@implementation SOGoContactObject
|
||||||
|
|
||||||
|
@ -92,14 +94,17 @@
|
||||||
|
|
||||||
/* specialized actions */
|
/* specialized actions */
|
||||||
|
|
||||||
- (NSException *)saveRecord:(id)_record {
|
- (NSException *) saveRecord: (id) _record
|
||||||
|
{
|
||||||
if ([_record isKindOfClass:[NGVCard class]]) {
|
if ([_record isKindOfClass:[NGVCard class]]) {
|
||||||
// TODO: implement a vCard generator
|
// TODO: implement a vCard generator
|
||||||
return [NSException exceptionWithHTTPStatus:501 /* Not Implemented */
|
return [NSException exceptionWithHTTPStatus:501 /* Not Implemented */
|
||||||
reason:@"Saving vCards is not supported yet."];
|
reason:@"Saving vCards is not supported yet."];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [self saveContentString:[_record description]];
|
// return [self saveContentString: [_record description]];
|
||||||
|
return
|
||||||
|
[self saveContentString: [_record vcardContentFromSOGoContactRecord]];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSException *)patchField:(NSString *)_fname value:(NSString *)_value
|
- (NSException *)patchField:(NSString *)_fname value:(NSString *)_value
|
||||||
|
|
Loading…
Reference in a new issue