View Issue Details

IDProjectCategoryView StatusLast Update
0002807SOGoActiveSyncpublic2014-06-09 13:16
Reportertfu Assigned Toludovic  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Target Version2.2.6Fixed in Version2.2.6 
Summary0002807: Contact photo not synced
Description

Contact photos doesn't get synced yet via activesync.
The attached patch implements the photo sync. It doesn't care about the 48kb limit in EAS specification assuming that a right sized picture is sent by activesync clients.

TagsNo tags attached.

Activities

tfu

tfu

2014-06-07 22:40

reporter  

0002-photo.patch (3,512 bytes)   
From 210209db23e905d9ae8227d7a22ce245a05cbbde Mon Sep 17 00:00:00 2001
From: root <root@example.com>
Date: Sun, 8 Jun 2014 00:16:10 +0200
Subject: [PATCH 2/2] photo

---
 ActiveSync/NGVCard+ActiveSync.m |   15 ++++++++++++---
 SOPE/NGCards/NGVCard.h          |    3 +++
 SOPE/NGCards/NGVCard.m          |   19 +++++++++++++++++++
 3 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/ActiveSync/NGVCard+ActiveSync.m b/ActiveSync/NGVCard+ActiveSync.m
index 9ac4769..bb4f292 100644
--- a/ActiveSync/NGVCard+ActiveSync.m
+++ b/ActiveSync/NGVCard+ActiveSync.m
@@ -40,6 +40,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #import <Contacts/NGVCard+SOGo.h>
 
+#import <SOGo/NSString+Utilities.h>
+
 #include "NSDate+ActiveSync.h"
 #include "NSString+ActiveSync.h"
 
@@ -199,6 +201,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       [s appendFormat: @"<Data>%@</Data>", o];
       [s appendString: @"</Body>"];
     }
+
+  if ((o = [self photo]))
+    [s appendFormat: @"<Picture xmlns=\"Contacts:\">%@</Picture>", o];
   
   return s;
 }
@@ -285,13 +290,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   if ((o = [theValues objectForKey: @"Email1Address"]))
     {
       element = [self elementWithTag: @"email" ofType: @"work"];
-      [element setSingleValue: o forKey: @""];
+      [element setSingleValue: [o pureEMailAddress] forKey: @""];
     }
   
   if ((o = [theValues objectForKey: @"Email2Address"]))
     {
       element = [self elementWithTag: @"email" ofType: @"home"];
-      [element setSingleValue: o  forKey: @""];
+      [element setSingleValue: [o pureEMailAddress] forKey: @""];
     }
   
   // SOGo currently only supports 2 email addresses ... but AS clients might send 3
@@ -299,7 +304,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   if ((o = [theValues objectForKey: @"Email3Address"]))
     {
       element = [self elementWithTag: @"email" ofType: @"three"];
-      [element setSingleValue: o  forKey: @""];
+      [element setSingleValue: [o pureEMailAddress] forKey: @""];
     }
   
   // Formatted name
@@ -346,6 +351,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   
   if ((o = [theValues objectForKey: @"NickName"]))
     [self setNickname: o];
+
+  if ((o = [theValues objectForKey: @"Picture"]))
+    [self setPhoto: o];
+
 }
 
 @end
diff --git a/SOPE/NGCards/NGVCard.h b/SOPE/NGCards/NGVCard.h
index 1d3696c..9553da3 100644
--- a/SOPE/NGCards/NGVCard.h
+++ b/SOPE/NGCards/NGVCard.h
@@ -126,6 +126,9 @@ typedef enum
 
 - (void) setCategories: (NSArray *) newCategories;
 - (NSArray *) categories;
+- (NSString *) photo;
+- (void) setPhoto: (NSString *) _value;
+
 
 // - (void) setN: (NGVCardName *) _v;
 // - (NGVCardName *) n;
diff --git a/SOPE/NGCards/NGVCard.m b/SOPE/NGCards/NGVCard.m
index db3833c..5f8028a 100644
--- a/SOPE/NGCards/NGVCard.m
+++ b/SOPE/NGCards/NGVCard.m
@@ -288,6 +288,25 @@
   return [self uniqueChildWithTag: @"n"];
 }
 
+- (NSString *) photo
+{
+  NGVCardPhoto *photo;
+
+  photo = (NGVCardPhoto *)[self uniqueChildWithTag: @"photo"];
+
+  return [[photo valuesAtIndex: 0 forKey: @""] objectAtIndex: 0];
+}
+
+- (void) setPhoto: (NSString *) _value
+{
+  CardElement *photo;
+  photo = [self uniqueChildWithTag: @"photo"];
+  [photo setValue: 0 ofAttribute: @"encoding" to: @"BASE64"];
+
+  [photo setSingleValue: _value forKey: @""];
+}
+
+
 - (void) setOrg: (NSString *) anOrg
           units: (NSArray *) someUnits
 {
-- 
1.7.9.5

0002-photo.patch (3,512 bytes)   
ludovic

ludovic

2014-06-09 13:16

administrator   ~0007161

Patch applied: https://github.com/inverse-inc/sogo/commit/3f8bbe8c6012e60334002affded0c94151db20e3

Thanks for your great work!

Issue History

Date Modified Username Field Change
2014-06-07 22:40 tfu New Issue
2014-06-07 22:40 tfu File Added: 0002-photo.patch
2014-06-09 13:15 ludovic Target Version => 2.2.5
2014-06-09 13:15 ludovic Target Version 2.2.5 => 2.2.6
2014-06-09 13:16 ludovic Note Added: 0007161
2014-06-09 13:16 ludovic Status new => resolved
2014-06-09 13:16 ludovic Fixed in Version => 2.2.6
2014-06-09 13:16 ludovic Resolution open => fixed
2014-06-09 13:16 ludovic Assigned To => ludovic