docs/SQL lib/ext

Aleksander Machniak machniak at kolabsys.com
Tue Oct 8 11:42:51 CEST 2013


 docs/SQL/mysql.initial.sql                           |    1 
 docs/SQL/mysql/2013100800.sql                        |    1 
 lib/ext/Syncroton/Backend/ABackend.php               |    6 +-
 lib/ext/Syncroton/Backend/Device.php                 |    7 +--
 lib/ext/Syncroton/Backend/IBackend.php               |    7 +--
 lib/ext/Syncroton/Backend/IDevice.php                |    7 +--
 lib/ext/Syncroton/Backend/Policy.php                 |    7 +--
 lib/ext/Syncroton/Command/Ping.php                   |   36 +++++++++++------
 lib/ext/Syncroton/Command/Sync.php                   |    2 
 lib/ext/Syncroton/Data/AData.php                     |    7 +--
 lib/ext/Syncroton/Data/Calendar.php                  |    6 +-
 lib/ext/Syncroton/Data/Contacts.php                  |    6 +-
 lib/ext/Syncroton/Data/Email.php                     |    3 -
 lib/ext/Syncroton/Data/Factory.php                   |    7 +--
 lib/ext/Syncroton/Data/IData.php                     |    8 +--
 lib/ext/Syncroton/Data/IDataCalendar.php             |    6 +-
 lib/ext/Syncroton/Data/IDataEmail.php                |    6 +-
 lib/ext/Syncroton/Data/IDataSearch.php               |    7 +--
 lib/ext/Syncroton/Data/Tasks.php                     |    7 +--
 lib/ext/Syncroton/Model/Device.php                   |   19 ++++++---
 lib/ext/Syncroton/Model/DeviceInformation.php        |    6 +-
 lib/ext/Syncroton/Model/Email.php                    |    6 +-
 lib/ext/Syncroton/Model/EmailAttachment.php          |    6 +-
 lib/ext/Syncroton/Model/EmailBody.php                |    6 +-
 lib/ext/Syncroton/Model/EmailFlag.php                |    6 +-
 lib/ext/Syncroton/Model/Event.php                    |    6 +-
 lib/ext/Syncroton/Model/EventAttendee.php            |    6 +-
 lib/ext/Syncroton/Model/EventException.php           |    6 +-
 lib/ext/Syncroton/Model/EventRecurrence.php          |    6 +-
 lib/ext/Syncroton/Model/FileReference.php            |    6 +-
 lib/ext/Syncroton/Model/Folder.php                   |    7 +--
 lib/ext/Syncroton/Model/IContent.php                 |    8 +--
 lib/ext/Syncroton/Model/IDevice.php                  |    9 ++--
 lib/ext/Syncroton/Model/IEntry.php                   |    7 +--
 lib/ext/Syncroton/Model/IFolder.php                  |    9 +---
 lib/ext/Syncroton/Model/IPolicy.php                  |    8 +--
 lib/ext/Syncroton/Model/ISyncState.php               |    7 +--
 lib/ext/Syncroton/Model/IXMLEntry.php                |    7 +--
 lib/ext/Syncroton/Model/MeetingResponse.php          |    7 +--
 lib/ext/Syncroton/Model/Policy.php                   |    7 +--
 lib/ext/Syncroton/Model/SendMail.php                 |    3 -
 lib/ext/Syncroton/Model/SmartForward.php             |    3 -
 lib/ext/Syncroton/Model/SmartReply.php               |    3 -
 lib/ext/Syncroton/Model/StoreRequest.php             |    6 +-
 lib/ext/Syncroton/Model/StoreResponseResult.php      |    3 -
 lib/ext/Syncroton/Model/SyncCollection.php           |    6 +-
 lib/ext/Syncroton/Model/SyncState.php                |    8 +--
 lib/ext/Syncroton/Model/Task.php                     |    6 +-
 lib/ext/Syncroton/Model/TaskRecurrence.php           |    7 +--
 lib/ext/Syncroton/Registry.php                       |    6 --
 lib/ext/Syncroton/Server.php                         |   40 ++++++++++++++++---
 lib/ext/Syncroton/Wbxml/Abstract.php                 |    3 -
 lib/ext/Syncroton/Wbxml/Decoder.php                  |   21 +++++----
 lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage0.php |    2 
 lib/ext/Syncroton/Wbxml/Encoder.php                  |   24 ++++++++---
 55 files changed, 278 insertions(+), 155 deletions(-)

New commits:
commit d1db8639b4e62dd6bafe1bedbf48098d6c78459f
Author: Aleksander Machniak <alec at alec.pl>
Date:   Tue Oct 8 11:42:12 2013 +0200

    Update Syncroton with fix for encoder memory issue (Bug #2032)

diff --git a/docs/SQL/mysql.initial.sql b/docs/SQL/mysql.initial.sql
index bbaa2c7..e131845 100644
--- a/docs/SQL/mysql.initial.sql
+++ b/docs/SQL/mysql.initial.sql
@@ -26,6 +26,7 @@ CREATE TABLE IF NOT EXISTS `syncroton_device` (
     `remotewipe` int(11) DEFAULT '0',
     `pingfolder` longblob,
     `lastsynccollection` longblob DEFAULT NULL,
+    `lastping` datetime DEFAULT NULL,
     `contactsfilter_id` varchar(40) DEFAULT NULL,
     `calendarfilter_id` varchar(40) DEFAULT NULL,
     `tasksfilter_id` varchar(40) DEFAULT NULL,
diff --git a/docs/SQL/mysql/2013100800.sql b/docs/SQL/mysql/2013100800.sql
new file mode 100644
index 0000000..3f00df5
--- /dev/null
+++ b/docs/SQL/mysql/2013100800.sql
@@ -0,0 +1 @@
+ALTER TABLE `syncroton_device` ADD `lastping` datetime DEFAULT NULL;
diff --git a/lib/ext/Syncroton/Backend/ABackend.php b/lib/ext/Syncroton/Backend/ABackend.php
index 6c50e1c..00869e4 100644
--- a/lib/ext/Syncroton/Backend/ABackend.php
+++ b/lib/ext/Syncroton/Backend/ABackend.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Command
+ * @package     Syncroton
+ * @subpackage  Backend
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Backend
+ * @package     Syncroton
+ * @subpackage  Backend
  */
 abstract class Syncroton_Backend_ABackend implements Syncroton_Backend_IBackend
 {
diff --git a/lib/ext/Syncroton/Backend/Device.php b/lib/ext/Syncroton/Backend/Device.php
index f7646b9..a782d07 100644
--- a/lib/ext/Syncroton/Backend/Device.php
+++ b/lib/ext/Syncroton/Backend/Device.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Command
+ * @package     Syncroton
+ * @subpackage  Backend
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,9 +12,9 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Backend
+ * @package     Syncroton
+ * @subpackage  Backend
  */
- 
 class Syncroton_Backend_Device extends Syncroton_Backend_ABackend implements Syncroton_Backend_IDevice
 {
     protected $_tableName = 'device';
diff --git a/lib/ext/Syncroton/Backend/IBackend.php b/lib/ext/Syncroton/Backend/IBackend.php
index 56979fb..00e83af 100644
--- a/lib/ext/Syncroton/Backend/IBackend.php
+++ b/lib/ext/Syncroton/Backend/IBackend.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Command
+ * @package     Syncroton
+ * @subpackage  Backend
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,9 +12,9 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Backend
+ * @package     Syncroton
+ * @subpackage  Backend
  */
- 
 interface Syncroton_Backend_IBackend
 {
     /**
diff --git a/lib/ext/Syncroton/Backend/IDevice.php b/lib/ext/Syncroton/Backend/IDevice.php
index 27a3a55..01e76e4 100644
--- a/lib/ext/Syncroton/Backend/IDevice.php
+++ b/lib/ext/Syncroton/Backend/IDevice.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Command
+ * @package     Syncroton
+ * @subpackage  Backend
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,9 +12,9 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Backend
+ * @package     Syncroton
+ * @subpackage  Backend
  */
- 
 interface Syncroton_Backend_IDevice extends Syncroton_Backend_IBackend
 {
     /**
diff --git a/lib/ext/Syncroton/Backend/Policy.php b/lib/ext/Syncroton/Backend/Policy.php
index bb62e6d..7322fad 100644
--- a/lib/ext/Syncroton/Backend/Policy.php
+++ b/lib/ext/Syncroton/Backend/Policy.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Command
+ * @package     Syncroton
+ * @subpackage  Backend
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,9 +12,9 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Backend
+ * @package     Syncroton
+ * @subpackage  Backend
  */
- 
 class Syncroton_Backend_Policy extends Syncroton_Backend_ABackend #implements Syncroton_Backend_IDevice
 {
     protected $_tableName = 'policy';
diff --git a/lib/ext/Syncroton/Command/Ping.php b/lib/ext/Syncroton/Command/Ping.php
index dc06215..08ad41f 100644
--- a/lib/ext/Syncroton/Command/Ping.php
+++ b/lib/ext/Syncroton/Command/Ping.php
@@ -78,10 +78,12 @@ class Syncroton_Command_Ping extends Syncroton_Command_Wbxml
                 }
                 $this->_device->pingfolder = serialize(array_keys($folders));
             }
+        }
 
-            if ($this->_device->isDirty() && $status == self::STATUS_NO_CHANGES_FOUND) {
-                $this->_device = $this->_deviceBackend->update($this->_device);
-            }
+        $this->_device->lastping = new DateTime('now', new DateTimeZone('utc'));
+
+        if ($status == self::STATUS_NO_CHANGES_FOUND) {
+            $this->_device = $this->_deviceBackend->update($this->_device);
         }
         
         $lifeTime = $this->_device->pinglifetime;
@@ -106,36 +108,48 @@ class Syncroton_Command_Ping extends Syncroton_Command_Wbxml
             do {
                 // take a break to save battery lifetime
                 sleep(Syncroton_Registry::getPingTimeout());
-                
+
+                // if another Ping command updated lastping property, we can stop processing this Ping command request
+                $device = $this->_deviceBackend->get($this->_device->id);
+                if ((isset($device->lastping) && $device->lastping instanceof DateTime) &&
+                    $device->pingfolder === $this->_device->pingfolder &&
+                    $device->lastping->getTimestamp() > $this->_device->lastping->getTimestamp() ) {
+                    break;
+                }
+
                 $now = new DateTime('now', new DateTimeZone('utc'));
                 
                 foreach ($folders as $folderId) {
                     try {
                         $folder         = $this->_folderBackend->get($folderId);
                         $dataController = Syncroton_Data_Factory::factory($folder->class, $this->_device, $this->_syncTimeStamp);
+                        
                     } catch (Syncroton_Exception_NotFound $e) {
                         if ($this->_logger instanceof Zend_Log)
                             $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " " . $e->getMessage());
                         $status = self::STATUS_FOLDER_NOT_FOUND;
+                        
                         break;
+                        
                     } catch (Exception $e) {
                         if ($this->_logger instanceof Zend_Log)
                             $this->_logger->err(__METHOD__ . '::' . __LINE__ . " " . $e->getMessage());
+                        
                         // do nothing, maybe temporal issue, should we stop?
                         continue;
                     }
 
                     try {
                         $syncState = $this->_syncStateBackend->getSyncState($this->_device, $folder);
-                        
-                        // another process synchronized data of this folder already. let's skip it
-                        if ($syncState->lastsync > $this->_syncTimeStamp) {
+                        
+                        // another process synchronized data of this folder already. let's skip it
+                        if ($syncState->lastsync > $this->_syncTimeStamp) {
                             continue;
                         }
-                        
-                        // safe battery time by skipping folders which got synchronied less than Syncroton_Registry::getQuietTime() seconds ago
-                        if (($now->getTimestamp() - $syncState->lastsync->getTimestamp()) < Syncroton_Registry::getQuietTime()) {
-                            continue;
+                        
+                        // safe battery time by skipping folders which got synchronied less than Syncroton_Registry::getQuietTime() seconds ago
+                        if (($now->getTimestamp() - $syncState->lastsync->getTimestamp()) < Syncroton_Registry::getQuietTime()) {
+                            continue;
                         }
                         
                         $foundChanges = $dataController->hasChanges($this->_contentStateBackend, $folder, $syncState);
diff --git a/lib/ext/Syncroton/Command/Sync.php b/lib/ext/Syncroton/Command/Sync.php
index 40ff6df..45ac895 100644
--- a/lib/ext/Syncroton/Command/Sync.php
+++ b/lib/ext/Syncroton/Command/Sync.php
@@ -777,6 +777,8 @@ class Syncroton_Command_Sync extends Syncroton_Command_Wbxml
                     } catch (Exception $e) {
                         if ($this->_logger instanceof Zend_Log)
                             $this->_logger->warn(__METHOD__ . '::' . __LINE__ . " unable to convert entry to xml: " . $e->getMessage());
+                        if ($this->_logger instanceof Zend_Log)
+                            $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " unable to convert entry to xml: " . $e->getTraceAsString());
                     }
                     
                     // mark as sent to the client, even the conversion to xml might have failed 
diff --git a/lib/ext/Syncroton/Data/AData.php b/lib/ext/Syncroton/Data/AData.php
index 1a76021..447d138 100644
--- a/lib/ext/Syncroton/Data/AData.php
+++ b/lib/ext/Syncroton/Data/AData.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,9 +12,9 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  */
-
 abstract class Syncroton_Data_AData implements Syncroton_Data_IData
 {
     const LONGID_DELIMITER = "\xe2\x87\x94"; # UTF8 ⇔
diff --git a/lib/ext/Syncroton/Data/Calendar.php b/lib/ext/Syncroton/Data/Calendar.php
index 66c8d25..04f3529 100644
--- a/lib/ext/Syncroton/Data/Calendar.php
+++ b/lib/ext/Syncroton/Data/Calendar.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  */
 class Syncroton_Data_Calendar extends Syncroton_Data_AData implements Syncroton_Data_IDataCalendar
 {
diff --git a/lib/ext/Syncroton/Data/Contacts.php b/lib/ext/Syncroton/Data/Contacts.php
index a9b8d58..86258a0 100644
--- a/lib/ext/Syncroton/Data/Contacts.php
+++ b/lib/ext/Syncroton/Data/Contacts.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  */
 
 class Syncroton_Data_Contacts extends Syncroton_Data_AData implements Syncroton_Data_IDataSearch
diff --git a/lib/ext/Syncroton/Data/Email.php b/lib/ext/Syncroton/Data/Email.php
index 5005c97..b55f9e8 100644
--- a/lib/ext/Syncroton/Data/Email.php
+++ b/lib/ext/Syncroton/Data/Email.php
@@ -12,7 +12,8 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  */
 class Syncroton_Data_Email extends Syncroton_Data_AData implements Syncroton_Data_IDataEmail
 {
diff --git a/lib/ext/Syncroton/Data/Factory.php b/lib/ext/Syncroton/Data/Factory.php
index 1be6946..2904b28 100644
--- a/lib/ext/Syncroton/Data/Factory.php
+++ b/lib/ext/Syncroton/Data/Factory.php
@@ -1,9 +1,9 @@
 <?php
-
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -12,7 +12,8 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  */
 
 class Syncroton_Data_Factory
diff --git a/lib/ext/Syncroton/Data/IData.php b/lib/ext/Syncroton/Data/IData.php
index 2d26335..a7e05b4 100644
--- a/lib/ext/Syncroton/Data/IData.php
+++ b/lib/ext/Syncroton/Data/IData.php
@@ -1,9 +1,9 @@
 <?php
-
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -12,9 +12,9 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  */
-
 interface Syncroton_Data_IData
 {
     /**
diff --git a/lib/ext/Syncroton/Data/IDataCalendar.php b/lib/ext/Syncroton/Data/IDataCalendar.php
index 2ea6831..da04671 100644
--- a/lib/ext/Syncroton/Data/IDataCalendar.php
+++ b/lib/ext/Syncroton/Data/IDataCalendar.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * interface for extended calendar backend
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  */
 interface Syncroton_Data_IDataCalendar
 {
diff --git a/lib/ext/Syncroton/Data/IDataEmail.php b/lib/ext/Syncroton/Data/IDataEmail.php
index bca70b9..ed067d2 100644
--- a/lib/ext/Syncroton/Data/IDataEmail.php
+++ b/lib/ext/Syncroton/Data/IDataEmail.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * interface for extended email backend
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  */
 interface Syncroton_Data_IDataEmail
 {
diff --git a/lib/ext/Syncroton/Data/IDataSearch.php b/lib/ext/Syncroton/Data/IDataSearch.php
index 5546f8d..987faa4 100644
--- a/lib/ext/Syncroton/Data/IDataSearch.php
+++ b/lib/ext/Syncroton/Data/IDataSearch.php
@@ -1,9 +1,9 @@
 <?php
-
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @copyright   Copyright (c) 2012 Kolab SYstems AG (http://www.kolabsys.com)
@@ -14,7 +14,8 @@
 /**
  * class to handle ActiveSync Search command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  */
 interface Syncroton_Data_IDataSearch
 {
diff --git a/lib/ext/Syncroton/Data/Tasks.php b/lib/ext/Syncroton/Data/Tasks.php
index a0c4756..e44feaf 100644
--- a/lib/ext/Syncroton/Data/Tasks.php
+++ b/lib/ext/Syncroton/Data/Tasks.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,9 +12,9 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Data
  */
-
 class Syncroton_Data_Tasks extends Syncroton_Data_AData
 {
     protected $_supportedFolderTypes = array(
diff --git a/lib/ext/Syncroton/Model/Device.php b/lib/ext/Syncroton/Model/Device.php
index a46ef2d..342c1fa 100644
--- a/lib/ext/Syncroton/Model/Device.php
+++ b/lib/ext/Syncroton/Model/Device.php
@@ -1,9 +1,9 @@
 <?php
-
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -12,7 +12,8 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  */
 class Syncroton_Model_Device extends Syncroton_Model_AEntry implements Syncroton_Model_IDevice
 {
@@ -21,6 +22,7 @@ class Syncroton_Model_Device extends Syncroton_Model_AEntry implements Syncroton
     const TYPE_ANDROID         = 'android';
     const TYPE_ANDROID_40      = 'android40';
     const TYPE_SMASUNGGALAXYS2 = 'samsunggti9100'; // Samsung Galaxy S-3
+    const TYPE_BLACKBERRY      = 'blackberry';
     
     /**
      * Returns major firmware version of this device
@@ -29,15 +31,20 @@ class Syncroton_Model_Device extends Syncroton_Model_AEntry implements Syncroton
      */
     public function getMajorVersion()
     {
-        switch ($this->devicetype) {
+        switch (strtolower($this->devicetype)) {
+            case Syncroton_Model_Device::TYPE_BLACKBERRY:
+                if (preg_match('/(.+)\/(.+)/', $this->useragent, $matches)) {
+                    list(, $name, $version) = $matches;
+                    return $version;
+                }
+                break;
+                
             case Syncroton_Model_Device::TYPE_IPHONE:
                 if (preg_match('/(.+)\/(\d+)\.(\d+)/', $this->useragent, $matches)) {
                     list(, $name, $majorVersion, $minorVersion) = $matches;
                     return $majorVersion;
                 }
                 break;
-            default:
-                break;
         }
         
         return 0;
diff --git a/lib/ext/Syncroton/Model/DeviceInformation.php b/lib/ext/Syncroton/Model/DeviceInformation.php
index 0a5c516..d1c8fff 100644
--- a/lib/ext/Syncroton/Model/DeviceInformation.php
+++ b/lib/ext/Syncroton/Model/DeviceInformation.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync device information
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string  friendlyName
  * @property    string  iMEI
  * @property    string  mobileOperator
diff --git a/lib/ext/Syncroton/Model/Email.php b/lib/ext/Syncroton/Model/Email.php
index 29fd495..cd448c8 100644
--- a/lib/ext/Syncroton/Model/Email.php
+++ b/lib/ext/Syncroton/Model/Email.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync email
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    array     attachments
  * @property    string    contentType
  * @property    array     flag
diff --git a/lib/ext/Syncroton/Model/EmailAttachment.php b/lib/ext/Syncroton/Model/EmailAttachment.php
index 48d9866..bea0c1e 100644
--- a/lib/ext/Syncroton/Model/EmailAttachment.php
+++ b/lib/ext/Syncroton/Model/EmailAttachment.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync event
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string  class
  * @property    string  collectionId
  * @property    bool    deletesAsMoves
diff --git a/lib/ext/Syncroton/Model/EmailBody.php b/lib/ext/Syncroton/Model/EmailBody.php
index 3d465b8..b4d29ab 100644
--- a/lib/ext/Syncroton/Model/EmailBody.php
+++ b/lib/ext/Syncroton/Model/EmailBody.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle AirSyncBase:Body
  *
- * @package    Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property   int     EstimatedDataSize
  * @property   string  Data
  * @property   string  Part
diff --git a/lib/ext/Syncroton/Model/EmailFlag.php b/lib/ext/Syncroton/Model/EmailFlag.php
index 258fd46..685623e 100644
--- a/lib/ext/Syncroton/Model/EmailFlag.php
+++ b/lib/ext/Syncroton/Model/EmailFlag.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @copyright   Copyright (c) 2012-2012 Kolab Systems AG (http://www.kolabsys.com)
@@ -13,7 +14,8 @@
 /**
  * class to handle ActiveSync Flag element
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    DateTime  CompleteTime
  * @property    DateTime  DateCompleted
  * @property    DateTime  DueDate
diff --git a/lib/ext/Syncroton/Model/Event.php b/lib/ext/Syncroton/Model/Event.php
index 0fccd2a..79686a9 100644
--- a/lib/ext/Syncroton/Model/Event.php
+++ b/lib/ext/Syncroton/Model/Event.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync event
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string  class
  * @property    string  collectionId
  * @property    bool    deletesAsMoves
diff --git a/lib/ext/Syncroton/Model/EventAttendee.php b/lib/ext/Syncroton/Model/EventAttendee.php
index 82257db..8803427 100644
--- a/lib/ext/Syncroton/Model/EventAttendee.php
+++ b/lib/ext/Syncroton/Model/EventAttendee.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync event
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string  class
  * @property    string  collectionId
  * @property    bool    deletesAsMoves
diff --git a/lib/ext/Syncroton/Model/EventException.php b/lib/ext/Syncroton/Model/EventException.php
index 63ae15e..06aece9 100644
--- a/lib/ext/Syncroton/Model/EventException.php
+++ b/lib/ext/Syncroton/Model/EventException.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync event
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string  class
  * @property    string  collectionId
  * @property    bool    deletesAsMoves
diff --git a/lib/ext/Syncroton/Model/EventRecurrence.php b/lib/ext/Syncroton/Model/EventRecurrence.php
index 3fe0c94..ac53984 100644
--- a/lib/ext/Syncroton/Model/EventRecurrence.php
+++ b/lib/ext/Syncroton/Model/EventRecurrence.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync event
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    int       CalendarType
  * @property    int       DayOfMonth
  * @property    int       DayOfWeek
diff --git a/lib/ext/Syncroton/Model/FileReference.php b/lib/ext/Syncroton/Model/FileReference.php
index b54bb7d..a34d37c 100644
--- a/lib/ext/Syncroton/Model/FileReference.php
+++ b/lib/ext/Syncroton/Model/FileReference.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync event
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string  ContentType
  * @property    string  Data
  */
diff --git a/lib/ext/Syncroton/Model/Folder.php b/lib/ext/Syncroton/Model/Folder.php
index 9655f9a..4da0a97 100644
--- a/lib/ext/Syncroton/Model/Folder.php
+++ b/lib/ext/Syncroton/Model/Folder.php
@@ -3,7 +3,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -12,9 +13,9 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  */
-
 class Syncroton_Model_Folder extends Syncroton_Model_AXMLEntry implements Syncroton_Model_IFolder
 {
     protected $_xmlBaseElement = array('FolderUpdate', 'FolderCreate');
diff --git a/lib/ext/Syncroton/Model/IContent.php b/lib/ext/Syncroton/Model/IContent.php
index 2ce315a..62eab66 100644
--- a/lib/ext/Syncroton/Model/IContent.php
+++ b/lib/ext/Syncroton/Model/IContent.php
@@ -1,9 +1,9 @@
 <?php
-
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -12,7 +12,8 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string    id
  * @property    string    device_id
  * @property    string    folder_id
@@ -21,7 +22,6 @@
  * @property    string    creation_synckey
  * @property    string    is_deleted
  */
-
 interface Syncroton_Model_IContent
 {
 }
diff --git a/lib/ext/Syncroton/Model/IDevice.php b/lib/ext/Syncroton/Model/IDevice.php
index 944a1f7..9765345 100644
--- a/lib/ext/Syncroton/Model/IDevice.php
+++ b/lib/ext/Syncroton/Model/IDevice.php
@@ -1,9 +1,9 @@
 <?php
-
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -12,7 +12,8 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string   id
  * @property    string   deviceid
  * @property    string   devicetype
@@ -37,6 +38,7 @@
  * @property    string   tasksfilter_id
  * @property    string   emailfilter_id
  * @property    string   lastsynccollection
+ * @property    DateTime lastping
  */
 interface Syncroton_Model_IDevice extends Syncroton_Model_IEntry
 {
@@ -46,6 +48,5 @@ interface Syncroton_Model_IDevice extends Syncroton_Model_IEntry
      * @return int/string
      */
     public function getMajorVersion();
-    
 }
 
diff --git a/lib/ext/Syncroton/Model/IEntry.php b/lib/ext/Syncroton/Model/IEntry.php
index c2c9ce7..158f389 100644
--- a/lib/ext/Syncroton/Model/IEntry.php
+++ b/lib/ext/Syncroton/Model/IEntry.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync contact
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string  class
  * @property    string  collectionId
  * @property    bool    deletesAsMoves
@@ -19,7 +21,6 @@
  * @property    string  syncKey
  * @property    int     windowSize
  */
-
 interface Syncroton_Model_IEntry
 {
     /**
diff --git a/lib/ext/Syncroton/Model/IFolder.php b/lib/ext/Syncroton/Model/IFolder.php
index f27f523..113887d 100644
--- a/lib/ext/Syncroton/Model/IFolder.php
+++ b/lib/ext/Syncroton/Model/IFolder.php
@@ -1,9 +1,9 @@
 <?php
-
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -12,7 +12,8 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string   id
  * @property    string   deviceId
  * @property    string   class
@@ -23,9 +24,7 @@
  * @property    string   lastfiltertype
  * @property    string   type
  */
-
 interface Syncroton_Model_IFolder
 {
-    
 }
 
diff --git a/lib/ext/Syncroton/Model/IPolicy.php b/lib/ext/Syncroton/Model/IPolicy.php
index b6929d3..999ecc5 100644
--- a/lib/ext/Syncroton/Model/IPolicy.php
+++ b/lib/ext/Syncroton/Model/IPolicy.php
@@ -1,9 +1,9 @@
 <?php
-
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -12,7 +12,8 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string   id
  * @property    string   deviceid
  * @property    string   devicetype
@@ -25,7 +26,6 @@
  * @property    string   remotewipe
  * @property    string   useragent
  */
-
 interface Syncroton_Model_IPolicy
 {
 }
diff --git a/lib/ext/Syncroton/Model/ISyncState.php b/lib/ext/Syncroton/Model/ISyncState.php
index cd1fc2a..133af6c 100644
--- a/lib/ext/Syncroton/Model/ISyncState.php
+++ b/lib/ext/Syncroton/Model/ISyncState.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,14 +12,14 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string    device_id
  * @property    string    type
  * @property    string    counter
  * @property    DateTime  lastsync
  * @property    string    pendingdata
  */
-
 interface Syncroton_Model_ISyncState
 {
 }
diff --git a/lib/ext/Syncroton/Model/IXMLEntry.php b/lib/ext/Syncroton/Model/IXMLEntry.php
index 7b3ad0f..adc18cd 100644
--- a/lib/ext/Syncroton/Model/IXMLEntry.php
+++ b/lib/ext/Syncroton/Model/IXMLEntry.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2013 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,9 +12,9 @@
 /**
  * class to handle ActiveSync contact
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  */
-
 interface Syncroton_Model_IXMLEntry extends Syncroton_Model_IEntry
 {
     /**
diff --git a/lib/ext/Syncroton/Model/MeetingResponse.php b/lib/ext/Syncroton/Model/MeetingResponse.php
index fded62d..0a8d321 100644
--- a/lib/ext/Syncroton/Model/MeetingResponse.php
+++ b/lib/ext/Syncroton/Model/MeetingResponse.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle MeetingResponse request
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    int     userResponse
  * @property    string  collectionId
  * @property    string  calendarId
@@ -19,7 +21,6 @@
  * @property    string  instanceId
  * @property    string  longId
  */
-
 class Syncroton_Model_MeetingResponse extends Syncroton_Model_AXMLEntry
 {
     protected $_xmlBaseElement = 'Request';
diff --git a/lib/ext/Syncroton/Model/Policy.php b/lib/ext/Syncroton/Model/Policy.php
index 9031d51..41ae331 100644
--- a/lib/ext/Syncroton/Model/Policy.php
+++ b/lib/ext/Syncroton/Model/Policy.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,9 +12,9 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  */
-
 class Syncroton_Model_Policy extends Syncroton_Model_AXMLEntry implements Syncroton_Model_IPolicy
 {
     protected $_xmlBaseElement = 'EASProvisionDoc';
diff --git a/lib/ext/Syncroton/Model/SendMail.php b/lib/ext/Syncroton/Model/SendMail.php
index f8641fd..337a7be 100644
--- a/lib/ext/Syncroton/Model/SendMail.php
+++ b/lib/ext/Syncroton/Model/SendMail.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @copyright   Copyright (c) 2012-2012 Kolab SYstems AG (http://www.kolabsys.com)
diff --git a/lib/ext/Syncroton/Model/SmartForward.php b/lib/ext/Syncroton/Model/SmartForward.php
index 5d34c9e..a403824 100644
--- a/lib/ext/Syncroton/Model/SmartForward.php
+++ b/lib/ext/Syncroton/Model/SmartForward.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @copyright   Copyright (c) 2012-2012 KolabSYstems AG (http://www.kolabsys.com)
diff --git a/lib/ext/Syncroton/Model/SmartReply.php b/lib/ext/Syncroton/Model/SmartReply.php
index 856872c..f8493a5 100644
--- a/lib/ext/Syncroton/Model/SmartReply.php
+++ b/lib/ext/Syncroton/Model/SmartReply.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @copyright   Copyright (c) 2012-2012 Kolab Systems AG (http://www.kolabsys.com)
diff --git a/lib/ext/Syncroton/Model/StoreRequest.php b/lib/ext/Syncroton/Model/StoreRequest.php
index f013b33..c6a158f 100644
--- a/lib/ext/Syncroton/Model/StoreRequest.php
+++ b/lib/ext/Syncroton/Model/StoreRequest.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @copyright   Copyright (c) 2012 Kolab Systems AG (http://kolabsys.com)
@@ -13,7 +14,8 @@
 /**
  * class to handle ActiveSync Search Store request
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string  name
  * @property    array   options
  * @property    array   query
diff --git a/lib/ext/Syncroton/Model/StoreResponseResult.php b/lib/ext/Syncroton/Model/StoreResponseResult.php
index e2deb91..2405d54 100644
--- a/lib/ext/Syncroton/Model/StoreResponseResult.php
+++ b/lib/ext/Syncroton/Model/StoreResponseResult.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
diff --git a/lib/ext/Syncroton/Model/SyncCollection.php b/lib/ext/Syncroton/Model/SyncCollection.php
index 5976b02..1eaaa07 100644
--- a/lib/ext/Syncroton/Model/SyncCollection.php
+++ b/lib/ext/Syncroton/Model/SyncCollection.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync Sync collection
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string  class
  * @property    string  collectionId
  * @property    bool    deletesAsMoves
diff --git a/lib/ext/Syncroton/Model/SyncState.php b/lib/ext/Syncroton/Model/SyncState.php
index 398f3a7..41e64fb 100644
--- a/lib/ext/Syncroton/Model/SyncState.php
+++ b/lib/ext/Syncroton/Model/SyncState.php
@@ -1,9 +1,9 @@
 <?php
-
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2009-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -12,9 +12,9 @@
 /**
  * class to handle ActiveSync Sync command
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  */
-
 class Syncroton_Model_SyncState extends Syncroton_Model_AEntry implements Syncroton_Model_ISyncState
 {
 }
diff --git a/lib/ext/Syncroton/Model/Task.php b/lib/ext/Syncroton/Model/Task.php
index 8ab473f..b70f569 100644
--- a/lib/ext/Syncroton/Model/Task.php
+++ b/lib/ext/Syncroton/Model/Task.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync task
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string  class
  * @property    string  collectionId
  * @property    bool    deletesAsMoves
diff --git a/lib/ext/Syncroton/Model/TaskRecurrence.php b/lib/ext/Syncroton/Model/TaskRecurrence.php
index 116ce14..0361b72 100644
--- a/lib/ext/Syncroton/Model/TaskRecurrence.php
+++ b/lib/ext/Syncroton/Model/TaskRecurrence.php
@@ -2,7 +2,8 @@
 /**
  * Syncroton
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @license     http://www.tine20.org/licenses/lgpl.html LGPL Version 3
  * @copyright   Copyright (c) 2012-2012 Metaways Infosystems GmbH (http://www.metaways.de)
  * @author      Lars Kneschke <l.kneschke at metaways.de>
@@ -11,7 +12,8 @@
 /**
  * class to handle ActiveSync event
  *
- * @package     Model
+ * @package     Syncroton
+ * @subpackage  Model
  * @property    string  class
  * @property    string  collectionId
  * @property    bool    deletesAsMoves
@@ -19,7 +21,6 @@
  * @property    string  syncKey
  * @property    int     windowSize
  */
-
 class Syncroton_Model_TaskRecurrence extends Syncroton_Model_AXMLEntry
 {
     protected $_xmlBaseElement = 'Recurrence';
diff --git a/lib/ext/Syncroton/Registry.php b/lib/ext/Syncroton/Registry.php
index 1495f8f..5f9ac46 100644
--- a/lib/ext/Syncroton/Registry.php
+++ b/lib/ext/Syncroton/Registry.php
@@ -12,8 +12,7 @@
  * obtain it through the world-wide-web, please send an email
  * to license at zend.com so we can send you a copy immediately.
  *
- * @category   Syncroton
- * @package    Syncroton_Registry
+ * @package    Syncroton
  * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  * @version    $Id: Registry.php 10020 2009-08-18 14:34:09Z j.fischer at metaways.de $
@@ -22,8 +21,7 @@
 /**
  * Generic storage class helps to manage global data.
  *
- * @category   Syncroton
- * @package    Syncroton_Registry
+ * @package    Syncroton
  * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
diff --git a/lib/ext/Syncroton/Server.php b/lib/ext/Syncroton/Server.php
index 7b681a0..114db4d 100644
--- a/lib/ext/Syncroton/Server.php
+++ b/lib/ext/Syncroton/Server.php
@@ -172,9 +172,7 @@ class Syncroton_Server
         
         if ($response instanceof DOMDocument) {
             if ($this->_logger instanceof Zend_Log) {
-                $response->formatOutput = true;
-                $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " xml response:\n" . $response->saveXML());
-                $response->formatOutput = false;
+                $this->_logDomDocument(Zend_Log::DEBUG, $response, __METHOD__, __LINE__);
             }
             
             if (isset($command) && $command instanceof Syncroton_Command_ICommand) {
@@ -190,7 +188,7 @@ class Syncroton_Server
             } catch (Syncroton_Wbxml_Exception $swe) {
                 if ($this->_logger instanceof Zend_Log) {
                     $this->_logger->err(__METHOD__ . '::' . __LINE__ . " Could not encode output: " . $swe);
-                    $this->_logger->err(__METHOD__ . '::' . __LINE__ . " xml response:\n" . $response->saveXML());
+                    $this->_logDomDocument(Zend_Log::ERR, $response, __METHOD__, __LINE__);
                 }
                 
                 header("HTTP/1.1 500 Internal server error");
@@ -227,7 +225,7 @@ class Syncroton_Server
                 
                 echo $header;
             }
-                        
+            
             // output body
             rewind($outputStream);
             fpassthru($outputStream);
@@ -240,7 +238,37 @@ class Syncroton_Server
                 }
             }
         }
-    }    
+    }
+    
+    /**
+     * write (possible big) DOMDocument in smaller chunks to log file
+     * 
+     * @param unknown     $priority
+     * @param DOMDocument $dom
+     * @param string      $method
+     * @param string      $method
+     */
+    protected function _logDomDocument($priority, DOMDocument $dom, $method, $method)
+    {
+        $loops = 0;
+        
+        $tempStream = fopen('php://temp/maxmemory:5242880', 'r+');
+                
+        $dom->formatOutput = true;
+        fwrite($tempStream, $dom->saveXML());
+        $dom->formatOutput = false;
+        
+        rewind($tempStream);
+        
+        // log data in 1MByte chunks
+        while (!feof($tempStream)) {
+            $this->_logger->log($method . '::' . $method . " xml response($loops):\n" . fread($tempStream, 1048576), $priority);
+            
+            $loops++;
+        }
+        
+        fclose($tempStream);
+    }
     
     /**
      * return request params
diff --git a/lib/ext/Syncroton/Wbxml/Abstract.php b/lib/ext/Syncroton/Wbxml/Abstract.php
index bec61f1..1ffa640 100644
--- a/lib/ext/Syncroton/Wbxml/Abstract.php
+++ b/lib/ext/Syncroton/Wbxml/Abstract.php
@@ -166,7 +166,8 @@ abstract class Syncroton_Wbxml_Abstract
                 $string .= $chunk;
                 $_length -= $len;
             }
-            else if (feof($this->_stream)) {
+            
+            if (feof($this->_stream)) {
                 break;
             }
         }
diff --git a/lib/ext/Syncroton/Wbxml/Decoder.php b/lib/ext/Syncroton/Wbxml/Decoder.php
index 130d84f..8b845e4 100644
--- a/lib/ext/Syncroton/Wbxml/Decoder.php
+++ b/lib/ext/Syncroton/Wbxml/Decoder.php
@@ -129,8 +129,6 @@ class Syncroton_Wbxml_Decoder extends Syncroton_Wbxml_Abstract
                 case Syncroton_Wbxml_Abstract::OPAQUE:
                     $length = $this->_getMultibyteUInt();
                     if($length > 0) {
-                        // @TODO: handle big data with streams
-                        // E.g. in SendMail command "opaqued" <Mime> contains full email body
                         $opaque = $this->_getOpaque($length);
                         try {
                             // let see if we can decode it. maybe the opaque data is wbxml encoded content
@@ -173,28 +171,33 @@ class Syncroton_Wbxml_Decoder extends Syncroton_Wbxml_Abstract
                     // get rid of bit 7+8
                     $tagHexCode         = $byte & 0x3F;
 
-                    $tag        = $this->_codePage->getTag($tagHexCode);
-                    $nameSpace  = $this->_codePage->getNameSpace();
+                    try {
+                        $tag = $this->_codePage->getTag($tagHexCode);
+                    } catch (Syncroton_Wbxml_Exception $swe) {
+                        // tag can not be converted to ASCII name
+                        $tag = sprintf('unknown tag 0x%x', $tagHexCode);
+                    }
+                    $nameSpace    = $this->_codePage->getNameSpace();
                     $codePageName = $this->_codePage->getCodePageName();
                     
                     #echo "Tag: $nameSpace:$tag\n";
                     
-                    if($node === NULL) {
+                    if ($node === NULL) {
                         // create the domdocument
-                        $node = $this->_createDomDocument($nameSpace, $tag);
+                        $node    = $this->_createDomDocument($nameSpace, $tag);
                         $newNode = $node->documentElement;
                     } else {
-                        if(!$this->_dom->isDefaultNamespace($nameSpace)) {
+                        if (!$this->_dom->isDefaultNamespace($nameSpace)) {
                             $this->_dom->documentElement->setAttribute('xmlns:' . $codePageName, $nameSpace);
                         }
                         $newNode = $node->appendChild($this->_dom->createElementNS('uri:' . $codePageName, $tag));
                     }
                     
-                    if($tagHasAttributes) {
+                    if ($tagHasAttributes) {
                         $attributes = $this->_getAttributes();
                     }
                     
-                    if($tagHasContent == true) {
+                    if ($tagHasContent == true) {
                         $node = $newNode;
                         $openTags++;
                     }
diff --git a/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage0.php b/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage0.php
index 263ff52..e039cee 100644
--- a/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage0.php
+++ b/lib/ext/Syncroton/Wbxml/Dtd/ActiveSync/CodePage0.php
@@ -22,7 +22,7 @@ class Syncroton_Wbxml_Dtd_ActiveSync_CodePage0 extends Syncroton_Wbxml_Dtd_Activ
     
     protected $_codePageName    = 'AirSync';
     
-    protected $_tags = array(     
+    protected $_tags = array(
         'Sync'              => 0x05,
         'Responses'         => 0x06,
         'Add'               => 0x07,
diff --git a/lib/ext/Syncroton/Wbxml/Encoder.php b/lib/ext/Syncroton/Wbxml/Encoder.php
index 746ea67..f17db83 100644
--- a/lib/ext/Syncroton/Wbxml/Encoder.php
+++ b/lib/ext/Syncroton/Wbxml/Encoder.php
@@ -151,6 +151,10 @@ class Syncroton_Wbxml_Encoder extends Syncroton_Wbxml_Abstract
     {
         $_dom->formatOutput = false;
         
+        $tempStream = fopen('php://temp/maxmemory:5242880', 'r+');
+        fwrite($tempStream, $_dom->saveXML());
+        rewind($tempStream);
+        
         $this->_initialize($_dom);
         
         $parser = xml_parser_create_ns($this->_charSet, ';');
@@ -159,14 +163,22 @@ class Syncroton_Wbxml_Encoder extends Syncroton_Wbxml_Abstract
         xml_set_character_data_handler($parser, '_handleCharacters');
         xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
         
-        if (!xml_parse($parser, $_dom->saveXML())) {
-            #file_put_contents(tempnam(sys_get_temp_dir(), "xmlerrors"), $_dom->saveXML());
-            throw new Syncroton_Wbxml_Exception(sprintf('XML error: %s at line %d',
-                xml_error_string(xml_get_error_code($parser)),
-                xml_get_current_line_number($parser)
-            ));
+        while (!feof($tempStream)) {
+            if (!xml_parse($parser, fread($tempStream, 1048576), feof($tempStream))) {
+                // uncomment to write xml document to file
+                #rewind($tempStream);
+                #$xmlStream = fopen(tempnam(sys_get_temp_dir(), "xmlerrors"), 'r+');
+                #stream_copy_to_stream($tempStream, $xmlStream);
+                #fclose($xmlStream);
+                
+                throw new Syncroton_Wbxml_Exception(sprintf('XML error: %s at line %d',
+                    xml_error_string(xml_get_error_code($parser)),
+                    xml_get_current_line_number($parser)
+                ));
+            }
         }
 
+        fclose($tempStream);
         xml_parser_free($parser);
     }
 




More information about the commits mailing list