Skip to content

Commit

Permalink
(feat) added photo support for LDIF import (fixes #1084)
Browse files Browse the repository at this point in the history
  • Loading branch information
extrafu authored and cgx committed Jan 7, 2017
1 parent baa9057 commit 1088b02
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions UI/Contacts/UIxContactFolderActions.m
Expand Up @@ -52,8 +52,17 @@

#import "UIxContactFolderActions.h"

static NSArray *photoTags = nil;

@implementation UIxContactFolderActions

+ (void) initialize
{
if (!photoTags)
{
photoTags = [[NSArray alloc] initWithObjects: @"jpegphoto", @"photo", @"thumbnailphoto", nil];
}
}

/* actions */

Expand Down Expand Up @@ -146,18 +155,20 @@ @implementation UIxContactFolderActions

- (int) importLdifData: (NSString *) ldifData
{
SOGoContactGCSFolder *folder;
NSString *key, *value;
NSArray *ldifContacts, *lines, *components;
SOGoContactGCSFolder *folder;
NSMutableDictionary *entry;
NSString *key, *uid;
NGVCard *vCard;
NSString *uid;
int i,j,count,linesCount;
int rc = 0;
id value;

int i, j, count, linesCount;
int rc;

folder = [self clientObject];
ldifContacts = [ldifData componentsSeparatedByString: @"\ndn"];
count = [ldifContacts count];
rc = 0;

for (i = 0; i < count; i++)
{
Expand Down Expand Up @@ -220,8 +231,16 @@ - (int) importLdifData: (NSString *) ldifData
if ([key hasSuffix: @":"])
{
key = [key substringToIndex: [key length] - 1];
value = [value stringByDecodingBase64];
if ([photoTags containsObject: key])
value = [value dataByDecodingBase64];
else
value = [value stringByDecodingBase64];
}

// Standard key recognized in NGCards
if ([photoTags containsObject: key])
key = @"photo";

[entry setValue: value forKey: key];
}

Expand Down

0 comments on commit 1088b02

Please sign in to comment.