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 committed Dec 29, 2016
1 parent 5111443 commit 7049519
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions UI/Contacts/UIxContactFolderActions.m
Original file line number Diff line number Diff line change
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 7049519

Please sign in to comment.