1: <?php
2: /**
3: * The Horde_SyncMl_Device_Sync4JMozilla:: class provides functionality that is
4: * specific to the Sync4JMozilla Plugin. See
5: * http://sourceforge.net/projects/sync4jmozilla/
6: *
7: * Copyright 2007-2012 Horde LLC (http://www.horde.org/)
8: *
9: * See the enclosed file COPYING for license information (LGPL). If you
10: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
11: *
12: * @author Karsten Fourmont <karsten@horde.org>
13: * @package SyncMl
14: */
15: class Horde_SyncMl_Device_Sync4JMozilla extends Horde_SyncMl_Device
16: {
17: /**
18: * Converts the content from the backend to a format suitable for the
19: * client device.
20: *
21: * Strips the uid (primary key) information as client and server might use
22: * different ones.
23: *
24: * @param string $content The content to convert
25: * @param string $contentType The content type of content as returned
26: * from the backend
27: * @param string $database The server database URI.
28: *
29: * @return array Three-element array with the converted content, the
30: * (possibly changed) new content type, and encoding type
31: * (like b64 as used by Funambol).
32: */
33: public function convertServer2Client($content, $contentType, $database)
34: {
35: list($content, $contentType, $encodingType) =
36: parent::convertServer2Client($content, $contentType, $database);
37:
38:
39: /* The plugin does currently not handle lines that are both folded
40: * and QUOTED-PRINTABLE encoded. Like this one with a note "abc":
41: * NOTE;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:=
42: * a=
43: * bc
44: */
45:
46: if (preg_match_all('/\r\n[^:]*ENCODING=QUOTED-PRINTABLE[^:]*:.*?=\r\n.*?[^=](?=\r\n)/mis', $content, $m)) {
47: foreach($m[0] as $v) {
48: /* Remove line folding */
49: $content = str_replace($v,str_replace("=\r\n", '', $v), $content);
50: }
51: }
52: $l = "\noutput converted for client ($contentType):\n" . $content . "\n";
53: $GLOBALS['backend']->logFile(Horde_SyncMl_Backend::LOGFILE_DATA, $l);
54:
55: return array($content, $contentType, $encodingType);
56: }
57: }
58: