vcard: inline local photo data (BMC #19661)
Use the new READ() script method in libsynthesis to inline local photo data right before sending to a remote peer. Tests were added in combination with SyncEvolution server for inlining a special well-known file (testcases/local.png) and failing to inline (file doesn't exist). In the latter case the URI is sent unchanged.
This commit is contained in:
parent
eeded54cf4
commit
d6d6e8ca39
|
@ -234,6 +234,7 @@ endif
|
|||
CLIENT_LIB_TEST_FILES = \
|
||||
testcases/lcs/file1.txt \
|
||||
testcases/lcs/file2.txt \
|
||||
testcases/local.png \
|
||||
testcases/templates/clients/SyncEvolution.ini \
|
||||
testcases/templates/clients/phone/nokia/S40/7210c.ini \
|
||||
testcases/google_event.ics \
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
]]></incomingscript>
|
||||
<outgoingscript><![CDATA[
|
||||
$VCARD_OUTGOING_ADDREV_SCRIPT
|
||||
$VCARD_OUTGOING_PHOTO_INLINING_SCRIPT
|
||||
$VCARD_OUTGOING_PHOTO_VALUE_SCRIPT
|
||||
]]></outgoingscript>
|
||||
</datatype>
|
||||
|
@ -24,6 +25,7 @@
|
|||
]]></incomingscript>
|
||||
<outgoingscript><![CDATA[
|
||||
$VCARD_OUTGOING_ADDREV_SCRIPT
|
||||
$VCARD_OUTGOING_PHOTO_INLINING_SCRIPT
|
||||
$VCARD_OUTGOING_PHOTO_VALUE_SCRIPT
|
||||
]]></outgoingscript>
|
||||
</datatype>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<macro name="VCARD_OUTGOING_PHOTO_INLINING_SCRIPT"><![CDATA[
|
||||
if (PHOTO_VALUE == "uri" &&
|
||||
SUBSTR(PHOTO, 0, 7) == "file://") {
|
||||
// inline the photo data
|
||||
string data;
|
||||
data = READ(SUBSTR(PHOTO, 7));
|
||||
if (data != UNASSIGNED) {
|
||||
PHOTO = data;
|
||||
PHOTO_VALUE = "binary";
|
||||
}
|
||||
}
|
||||
]]></macro>
|
|
@ -21,6 +21,7 @@ EXTRA_DIST = \
|
|||
testcases/yahoo_contact.vcf \
|
||||
testcases/lcs/file1.txt \
|
||||
testcases/lcs/file2.txt \
|
||||
testcases/local.png \
|
||||
testcases/templates/clients/phone/nokia/S40/7210c.ini \
|
||||
testcases/templates/clients/SyncEvolution.ini \
|
||||
syncevo-http-server.py \
|
||||
|
|
|
@ -223,6 +223,9 @@ sub NormalizeItem {
|
|||
while (s/^PHOTO(.*?): (\S+)[\t ]+(\S+)/PHOTO$1: $2$3/mg) {}
|
||||
}
|
||||
}
|
||||
# special case for the inlining of the local test case PHOTO
|
||||
s!^PHOTO;;VALUE=uri:file://testcases/local.png$!PHOTO;;VALUE=uri:<local.png>!m;
|
||||
s!^PHOTO;ENCODING=B: iVBORw0KGgoAAAANSUh.*UQOVkeH/aKBSLM04QlMqAAFNBTl\+CjN9AAAAAElFTkSuQmCC$!PHOTO;;VALUE=uri:<local.png>!m;
|
||||
# ignore extra day factor in front of weekday
|
||||
s/^RRULE:(.*)BYDAY=\+?1(\D)/RRULE:$1BYDAY=$2/mg;
|
||||
# remove default VALUE=DATE-TIME
|
||||
|
|
|
@ -1,6 +1,26 @@
|
|||
@@ -1,5 +1,15 @@
|
||||
@@ -1,5 +1,35 @@
|
||||
BEGIN:VCARD
|
||||
VERSION:3.0
|
||||
+NICKNAME:user20
|
||||
+NOTE:PHOTO with invalid relative file URI
|
||||
+FN:bad file URI
|
||||
+N:URI;bad file
|
||||
+PHOTO;VALUE=uri;TYPE=PNG:file://testcases/no-such.png
|
||||
+X-EVOLUTION-FILE-AS:URI\, bad file
|
||||
+END:VCARD
|
||||
+
|
||||
+BEGIN:VCARD
|
||||
+VERSION:3.0
|
||||
+NICKNAME:user19
|
||||
+NOTE:PHOTO with relative file URI
|
||||
+FN:file URI
|
||||
+N:URI;file
|
||||
+PHOTO;VALUE=uri;TYPE=PNG:file://testcases/local.png
|
||||
+X-EVOLUTION-FILE-AS:URI\, file
|
||||
+END:VCARD
|
||||
+
|
||||
+BEGIN:VCARD
|
||||
+VERSION:3.0
|
||||
+NICKNAME:user18
|
||||
+NOTE:PHOTO with uri as value
|
||||
+FN:photo URI
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 189 B |
Loading…
Reference in New Issue