1: <?php
2: /**
3: * The Horde_SyncMl_Device_Nokia:: class provides functionality that is
4: * specific to the Nokia SyncML clients.
5: *
6: * Copyright 2005-2012 Horde LLC (http://www.horde.org/)
7: *
8: * See the enclosed file COPYING for license information (LGPL). If you
9: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
10: *
11: * @author Karsten Fourmont <karsten@horde.org>
12: * @package SyncMl
13: */
14: class Horde_SyncMl_Device_Nokia extends Horde_SyncMl_Device
15: {
16: /**
17: * Converts the content received from the client for the backend.
18: *
19: * @param string $content The content to convert.
20: * @param string $contentType The content type of the content.
21: *
22: * @return array Two-element array with the converted content and the
23: * (possibly changed) new content type.
24: */
25: public function convertClient2Server($content, $contentType)
26: {
27: list($content, $contentType) =
28: parent::convertClient2Server($content, $contentType);
29:
30: /* At least the Nokia E series seems to prefix category values with
31: * X-, see bugs #6849 and #7824. */
32: $di = $GLOBALS['backend']->state->deviceInfo;
33: if ($di->Mod[0] == 'E') {
34: $content = preg_replace('/(\r\n|\r|\n)CATEGORIES:X-/',
35: '\1CATEGORIES:', $content, 1);
36: }
37:
38: $GLOBALS['backend']->logFile(
39: Horde_SyncMl_Backend::LOGFILE_DATA,
40: "\nInput converted for server ($contentType):\n$content\n");
41:
42: return array($content, $contentType);
43: }
44:
45: /**
46: * Converts the content from the backend to a format suitable for the
47: * client device.
48: *
49: * Strips the UID (primary key) information as client and server might use
50: * different ones.
51: *
52: * Charset conversions might be added here too.
53: *
54: * @param string $content The content to convert
55: * @param string $contentType The content type of content as returned
56: * from the backend
57: * @param string $database The server database URI.
58: *
59: * @return array Three-element array with the converted content, the
60: * (possibly changed) new content type, and encoding type
61: * (like b64 as used by Funambol).
62: */
63: public function convertServer2Client($content, $contentType, $database)
64: {
65: $database = $GLOBALS['backend']->normalize($database);
66:
67: list($content, $contentType, $encodingType) =
68: parent::convertServer2Client($content, $contentType, $database);
69:
70: $content = preg_replace('/(\r\n|\r|\n)PHOTO;ENCODING=b[^:]*:(.+?)(\r\n|\r|\n)/',
71: '\1PHOTO;ENCODING=BASE64:\1\2\1\1',
72: $content, 1);
73:
74: $GLOBALS['backend']->logFile(
75: Horde_SyncMl_Backend::LOGFILE_DATA,
76: "\nOutput converted for client ($contentType):\n$content\n");
77:
78: return array($content, $contentType, null);
79: }
80:
81: public function handleTasksInCalendar()
82: {
83: return true;
84: }
85:
86: /**
87: * Some devices accept datetimes only in local time format:
88: * DTSTART:20061222T130000
89: * instead of the more robust (and default) UTC time:
90: * DTSTART:20061222T110000Z
91: */
92: public function useLocalTime()
93: {
94: return true;
95: }
96: }
97: