phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] syncml syncml.php inc/class.sochannel.inc.php i...


From: Johan Gunnarsson
Subject: [Phpgroupware-cvs] syncml syncml.php inc/class.sochannel.inc.php i...
Date: Sun, 05 Aug 2007 17:15:41 +0000

CVSROOT:        /sources/phpgroupware
Module name:    syncml
Changes by:     Johan Gunnarsson <johang>       07/08/05 17:15:41

Modified files:
        .              : syncml.php 
        inc            : class.sochannel.inc.php 
                         class.sodatabase.inc.php 
                         class.somappings.inc.php 
                         class.sosession.inc.php 
                         class.syncml_auth_md5.inc.php 
                         class.syncml_command_add.inc.php 
                         class.syncml_command_alert.inc.php 
                         class.syncml_command_delete.inc.php 
                         class.syncml_command_map.inc.php 
                         class.syncml_command_replace.inc.php 
                         class.syncml_command_status.inc.php 
                         class.syncml_database.inc.php 
                         class.syncml_message.inc.php 
                         class.syncml_session.inc.php functions.inc.php 
        setup          : setup.inc.php tables_current.inc.php 
Added files:
        inc            : class.syncml_xml_parser.inc.php 
        setup          : tables_baseline.inc.php tables_update.php 
Removed files:
        inc            : xml_functions.inc.php 

Log message:
        * Changes in table structure.
        * Changes made from PHPGW UI are now noticed by sync code.
        * Version bump to .002.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/syncml/syncml.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.sochannel.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.sodatabase.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.somappings.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.sosession.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_auth_md5.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_command_add.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_command_alert.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_command_delete.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_command_map.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_command_replace.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_command_status.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_database.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_message.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_session.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/functions.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/class.syncml_xml_parser.inc.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/syncml/inc/xml_functions.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/syncml/setup/setup.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/setup/tables_current.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/syncml/setup/tables_baseline.inc.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/syncml/setup/tables_update.php?cvsroot=phpgroupware&rev=1.1

Patches:
Index: syncml.php
===================================================================
RCS file: /sources/phpgroupware/syncml/syncml.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- syncml.php  30 Jul 2007 21:07:49 -0000      1.2
+++ syncml.php  5 Aug 2007 17:15:39 -0000       1.3
@@ -7,12 +7,13 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: syncml.php,v 1.2 2007/07/30 21:07:49 johang Exp $
+        * @version   $Id: syncml.php,v 1.3 2007/08/05 17:15:39 johang Exp $
         */
 
        ob_start();
 
        error_reporting(E_ALL);
+       // error_reporting(0);
 
        $phpgw_info = array();
 
@@ -25,65 +26,62 @@
 
        require('../header.inc.php');
 
-       // this is a ugly, ugly hack
-       //$GLOBALS['phpgw']->db->query('TRUNCATE phpgw_access_log');
+       require_once 'inc/class.syncml_xml_parser.inc.php';
+       require_once 'inc/class.xml_offset_mapper.inc.php';
 
-       require 'inc/xml_functions.inc.php';
-       require 'inc/class.xml_offset_mapper.inc.php';
+       require_once 'inc/class.syncml_response.inc.php';
+       require_once 'inc/class.syncml_message.inc.php';
 
-       require 'inc/class.syncml_message.inc.php';
+       // this is a ugly, ugly hack
+       $GLOBALS['phpgw']->db->query('TRUNCATE phpgw_access_log');
 
        if(!isset($_SERVER['CONTENT_TYPE']) ||
                $_SERVER['REQUEST_METHOD'] != 'POST')
        {
                exit('I\'m a SyncML server (1)');
-               //$_SERVER['CONTENT_TYPE'] = '';
        }
 
+       $GLOBALS['HTTP_RAW_POST_DATA'] = implode("\r\n", file('php://input'));
+
        switch($_SERVER['CONTENT_TYPE'])
        {
                case 'application/vnd.syncml+xml':
-                       $GLOBALS['HTTP_RAW_POST_DATA'] =
-                               implode("\r\n", file('php://input'));
+                       $parser = new syncml_xml_parser();
+                       $response = new syncml_response();
                        break;
+               /*
                case 'application/vnd.syncml+wbxml':
-                       $GLOBALS['HTTP_RAW_POST_DATA'] = wbxml_decode(
-                               implode("\r\n", file('php://input')));
+                       $parser = new syncml_wbxml_parser();
+                       $response = new syncml_wbxml_response();
                        break;
+               */
                default:
                        exit('I\'m a SyncML server (2)');
-                       //$GLOBALS['HTTP_RAW_POST_DATA'] = '';
        }
 
        $message = new syncml_message();
 
        // the header
-       $header = parse_xml($GLOBALS['HTTP_RAW_POST_DATA'],
+       $header = $parser->parse($GLOBALS['HTTP_RAW_POST_DATA'],
                new xml_offset_mapper(array('SYNCML', 'SYNCHDR')));
        $message->process_header($header);
 
        unset($header);
 
        // the body
-       $body = parse_xml($GLOBALS['HTTP_RAW_POST_DATA'],
+       $body = $parser->parse($GLOBALS['HTTP_RAW_POST_DATA'],
                new xml_offset_mapper(array('SYNCML', 'SYNCBODY')));
        $message->process_body($body);
 
        unset($body, $GLOBALS['HTTP_RAW_POST_DATA']);
 
        // execute everything
-       $response = $message->execute();
+       $message->execute($response);
+
+       // print response
        $response->print_response();
 
-       switch($_SERVER['CONTENT_TYPE'])
-       {
-               case 'application/vnd.syncml+wbxml':
-                       echo wbxml_encode(ob_get_clean());
-                       ob_start();
-               case 'application/vnd.syncml+xml':
                        header('Content-Type: ' . $_SERVER['CONTENT_TYPE']);
-       }
-
        header('Content-Length: ' . ob_get_length());
 
        ob_end_flush();

Index: inc/class.sochannel.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.sochannel.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.sochannel.inc.php 30 Jul 2007 13:04:39 -0000      1.1.1.1
+++ inc/class.sochannel.inc.php 5 Aug 2007 17:15:39 -0000       1.2
@@ -7,7 +7,7 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: class.sochannel.inc.php,v 1.1.1.1 2007/07/30 
13:04:39 johang Exp $
+        * @version   $Id: class.sochannel.inc.php,v 1.2 2007/08/05 17:15:39 
johang Exp $
         */
 
        class syncml_sochannel
@@ -15,7 +15,7 @@
                function insert_channel($database_id, $device_uri)
                {
                        $GLOBALS['phpgw']->db->query(sprintf('
-                               INSERT phpgw_syncml_channel(
+                               INSERT phpgw_syncml_channels(
                                        database_id, device_uri)
                                VALUES(
                                        \'%d\', \'%s\')',
@@ -26,10 +26,20 @@
                                'phpgw_syncml_channel', 'channel_id');
                }
 
+               function update_last_merge($channel_id)
+               {
+                       $GLOBALS['phpgw']->db->query(sprintf('
+                               UPDATE phpgw_syncml_channels
+                               SET last_merge = %d
+                               WHERE channel_id = %d',
+                               time(), $channel_id),
+                               __LINE__, __FILE__);
+               }
+
                function update_anchors($channel_id, $device_next, $phpgw_next)
                {
                        $GLOBALS['phpgw']->db->query('
-                               UPDATE phpgw_syncml_channel
+                               UPDATE phpgw_syncml_channels
                                SET' .
                                        (is_null($device_next) ?
                                                'device_anchor_last = \'' . 
$device_next . '\',' : '') .
@@ -48,8 +58,9 @@
                                SELECT
                                        c.device_anchor_last,
                                        c.phpgw_anchor_last,
-                                       c.database_id
-                               FROM phpgw_syncml_channel c
+                                       c.database_id,
+                                       c.last_merge
+                               FROM phpgw_syncml_channels c
                                WHERE
                                        c.channel_id = %d',
                                $channel_id),
@@ -61,6 +72,7 @@
                                $GLOBALS['phpgw']->db->f('database_id'),
                                $GLOBALS['phpgw']->db->f('device_anchor_last'),
                                $GLOBALS['phpgw']->db->f('phpgw_anchor_last'),
+                               $GLOBALS['phpgw']->db->f('last_merge')
                        );
                }
 
@@ -71,8 +83,8 @@
                                        c.channel_id,
                                        c.device_anchor_last,
                                        c.phpgw_anchor_last
-                               FROM phpgw_syncml_channel c
-                               JOIN phpgw_syncml_database d ON
+                               FROM phpgw_syncml_channels c
+                               JOIN phpgw_syncml_databases d ON
                                        d.database_id = c.database_id AND
                                        d.database_uri = '%s'
                                WHERE c.device_uri = '%s'",
@@ -92,7 +104,7 @@
                function set_anchors($channel_id, $device_next, $phpgw_next)
                {
                        $GLOBALS['phpgw']->db->query("
-                               UPDATE phpgw_syncml_channel
+                               UPDATE phpgw_syncml_channels
                                SET " .
                                        ($device_next ?
                                                "device_anchor_last = '" . 
$device_next . "'," : "") .

Index: inc/class.sodatabase.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.sodatabase.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.sodatabase.inc.php        30 Jul 2007 13:04:39 -0000      1.1.1.1
+++ inc/class.sodatabase.inc.php        5 Aug 2007 17:15:40 -0000       1.2
@@ -7,7 +7,7 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: class.sodatabase.inc.php,v 1.1.1.1 2007/07/30 
13:04:39 johang Exp $
+        * @version   $Id: class.sodatabase.inc.php,v 1.2 2007/08/05 17:15:40 
johang Exp $
         */
 
        /**
@@ -18,7 +18,7 @@
                function remove_database($database_id, $database_uri)
                {
                        $GLOBALS['phpgw']->db->query("
-                               DELETE FROM phpgw_syncml_database
+                               DELETE FROM phpgw_syncml_databases
                                WHERE ' .
                                        (!is_null($database_id) ?
                                                'database_id = \'' . 
$database_id . '\' AND ' : '') .
@@ -31,7 +31,7 @@
                function insert_database($database_id, $database_uri)
                {
                        $GLOBALS['phpgw']->db->query(sprintf("
-                               INSERT INTO phpgw_syncml_database(
+                               INSERT INTO phpgw_syncml_databases(
                                        database_uri, source_id, 
credential_required,
                                        credential_hash, account_id)
                                VALUES('%s', '%d', '%d', '%s', '%d')",
@@ -40,16 +40,18 @@
                                __LINE__, __FILE__);
                }
 
-               function get_database($database_id, $account_id)
+               function get_database($database_id, $account_id, $database_uri)
                {
                        $GLOBALS['phpgw']->db->query('
                                SELECT *
-                               FROM phpgw_syncml_database m
+                               FROM phpgw_syncml_databases m
                                WHERE ' .
                                        (!is_null($database_id) ?
                                                'database_id = \'' . 
$database_id . '\' AND ' : '') .
                                        (!is_null($account_id) ?
                                                'account_id = \'' . $account_id 
. '\' AND ' : '') .
+                                       (!is_null($database_uri) ?
+                                               'database_uri = \'' . 
$database_uri . '\' AND ' : '') .
                                        '1 = 1',
                                __LINE__, __FILE__);
 

Index: inc/class.somappings.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.somappings.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.somappings.inc.php        30 Jul 2007 13:04:38 -0000      1.1.1.1
+++ inc/class.somappings.inc.php        5 Aug 2007 17:15:40 -0000       1.2
@@ -7,7 +7,7 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: class.somappings.inc.php,v 1.1.1.1 2007/07/30 
13:04:38 johang Exp $
+        * @version   $Id: class.somappings.inc.php,v 1.2 2007/08/05 17:15:40 
johang Exp $
         */
 
        /**
@@ -16,24 +16,9 @@
        class syncml_somappings
        {
                /**
-                * Replace a mapping. Deletes any current mapping before 
inserting
-                * new.
-                *
-                * @param $channel_id Channel ID of mapping. NULL to include 
all.
-                * @param $luid       LUID of mapping. NULL to include all.
-                * @param $guid       GUID of mapping. NULL to include all.
-                * @param $flag       Flag of mapping. Optional. Defaults to 0.
-                */
-               function replace_mapping($channel_id, $luid, $guid, $flag = 0)
-               {
-                       $this->delete_mapping($channel_id, NULL, $guid, NULL);
-                       $this->insert_mapping($channel_id, $luid, $guid, $flag);
-               }
-
-               /**
                 * Get a mapping.
                 *
-                * @param $channel_id Channel ID of mapping. NULL to include 
all.
+                * @param $ch_id  Channel ID of mapping. NULL to include all.
                 * @param $luid       LUID of mapping. NULL to include all.
                 * @param $guid       GUID of mapping. NULL to include all.
                 * @param $flag       Flag of mapping. NULL to include all.
@@ -75,12 +60,12 @@
                /**
                 * Get all mapped LUIDs in this database.
                 *
+                * @param $ch_id Channel ID. NULL to include all.
                 * @return array List of LUID numbers of mappings to this 
channel.
                 */
-               function get_all_mapped_luids($channel_id)
+               function get_all_mapped_luids($ch_id)
                {
-                       $mappings = $this->get_mapping(
-                               $channel_id, NULL, NULL, NULL);
+                       $mappings = $this->get_mapping($ch_id, NULL, NULL, 
NULL);
 
                        $all_mapped_luids = array();
 
@@ -95,7 +80,7 @@
                /**
                 * Delete a mapping.
                 *
-                * @param $channel_id Channel ID of mapping. NULL to include 
all.
+                * @param $ch_id  Channel ID of mapping. NULL to include all.
                 * @param $luid       LUID of mapping. NULL to include all.
                 * @param $guid       GUID of mapping. NULL to include all.
                 * @param $flag       Flag of mapping. NULL to include all.
@@ -114,36 +99,31 @@
                                        '1 = 1',
                                __LINE__, __FILE__);
 
-                       // return $GLOBALS['phpgw']->db->affected_rows();
-               }
-               
-               function delete_all_mappings()
-               {
-                       return $this->delete_mapping(NULL, NULL, NULL, NULL);
+                       return $GLOBALS['phpgw']->db->affected_rows();
                }
 
                /**
                 * Insert a mapping.
                 *
-                * @param $channel_id Channel ID of mapping. NULL to include 
all.
+                * @param $ch_id  Channel ID of mapping. NULL to include all.
                 * @param $luid       LUID of mapping. NULL to include all.
                 * @param $guid       GUID of mapping. NULL to include all.
                 * @param $flag       Flag of mapping. Optional. Defaults to 0.
                 */
-               function insert_mapping($channel_id, $luid, $guid, $flag = 0)
+               function insert_mapping($ch_id, $luid, $guid, $flag = 0)
                {
                        $GLOBALS['phpgw']->db->query(sprintf("
                                INSERT INTO phpgw_syncml_mappings(
                                        channel_id, luid, guid, dirty)
                                VALUES('%d', '%s', '%s', '%d')",
-                               $channel_id, $luid, $guid, $flag),
+                               $ch_id, $luid, $guid, $flag),
                                __LINE__, __FILE__);
                }
 
                /**
-                * Updates a mapping.
+                * Update a mapping.
                 *
-                * @param $channel_id Channel ID of mapping. NULL to include 
all.
+                * @param $ch_id  Channel ID of mapping. NULL to include all.
                 * @param $luid       LUID of mapping. NULL to include all.
                 * @param $guid       GUID of mapping. NULL to include all.
                 * @return int        Number of mappings updated.
@@ -161,6 +141,6 @@
                                        '1 = 1',
                                __LINE__, __FILE__);
 
-                       // return $GLOBALS['phpgw']->db->affected_rows();
+                       return $GLOBALS['phpgw']->db->affected_rows();
                }
        }

Index: inc/class.sosession.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.sosession.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- inc/class.sosession.inc.php 30 Jul 2007 21:07:50 -0000      1.2
+++ inc/class.sosession.inc.php 5 Aug 2007 17:15:40 -0000       1.3
@@ -7,7 +7,7 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: class.sosession.inc.php,v 1.2 2007/07/30 21:07:50 
johang Exp $
+        * @version   $Id: class.sosession.inc.php,v 1.3 2007/08/05 17:15:40 
johang Exp $
         */
 
        /**
@@ -21,7 +21,7 @@
                function clean_session_mappings()
                {
                        $GLOBALS['phpgw']->db->query(sprintf('
-                               DELETE FROM phpgw_syncml_session
+                               DELETE FROM phpgw_syncml_sessions
                                WHERE
                                        session_dla < %d',
                                time() - 10),
@@ -57,7 +57,7 @@
                        $this->clean_session_mappings();
                        
                        $GLOBALS['phpgw']->db->query(sprintf('
-                               UPDATE phpgw_syncml_session
+                               UPDATE phpgw_syncml_sessions
                                SET session_dla = %d
                                WHERE syncml_hash = \'%s\'',
                                time(), $syncml_hash),
@@ -65,7 +65,7 @@
                        
                        $GLOBALS['phpgw']->db->query(sprintf("
                                SELECT phpgw_sid
-                               FROM phpgw_syncml_session
+                               FROM phpgw_syncml_sessions
                                WHERE
                                        syncml_hash = '%s'",
                                
$GLOBALS["phpgw"]->db->db_addslashes($syncml_hash)),
@@ -95,7 +95,7 @@
                        $syncml_hash = $this->generate_session_hash($header);
                        
                        $GLOBALS['phpgw']->db->query(sprintf("
-                               DELETE FROM phpgw_syncml_session
+                               DELETE FROM phpgw_syncml_sessions
                                WHERE
                                        syncml_hash = '%s'",
                                
$GLOBALS["phpgw"]->db->db_addslashes($syncml_hash)),
@@ -114,14 +114,14 @@
                        $syncml_hash = $this->generate_session_hash($header);
                                                
                        $GLOBALS['phpgw']->db->query(sprintf("
-                               DELETE FROM phpgw_syncml_session
+                               DELETE FROM phpgw_syncml_sessions
                                WHERE
                                        syncml_hash = '%s'",
                                
$GLOBALS["phpgw"]->db->db_addslashes($syncml_hash)),
                                __LINE__, __FILE__);
                                
                        $GLOBALS['phpgw']->db->query(sprintf("
-                               INSERT INTO phpgw_syncml_session(
+                               INSERT INTO phpgw_syncml_sessions(
                                        syncml_hash, phpgw_sid, session_dla)
                                VALUES('%s', '%s', '%d')",
                                
$GLOBALS["phpgw"]->db->db_addslashes($syncml_hash), 

Index: inc/class.syncml_auth_md5.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.syncml_auth_md5.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.syncml_auth_md5.inc.php   30 Jul 2007 13:04:39 -0000      1.1.1.1
+++ inc/class.syncml_auth_md5.inc.php   5 Aug 2007 17:15:40 -0000       1.2
@@ -7,7 +7,7 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: class.syncml_auth_md5.inc.php,v 1.1.1.1 2007/07/30 
13:04:39 johang Exp $
+        * @version   $Id: class.syncml_auth_md5.inc.php,v 1.2 2007/08/05 
17:15:40 johang Exp $
         */
 
        /**
@@ -37,7 +37,7 @@
                                SELECT
                                        a.account_pwd,
                                        a.account_lid
-                               FROM phpgw_syncml_hash h
+                               FROM phpgw_syncml_hashes h
                                JOIN phpgw_accounts     a ON
                                        a.account_id = h.account_id
                                WHERE

Index: inc/class.syncml_command_add.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.syncml_command_add.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- inc/class.syncml_command_add.inc.php        30 Jul 2007 21:07:50 -0000      
1.2
+++ inc/class.syncml_command_add.inc.php        5 Aug 2007 17:15:40 -0000       
1.3
@@ -7,7 +7,7 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: class.syncml_command_add.inc.php,v 1.2 2007/07/30 
21:07:50 johang Exp $
+        * @version   $Id: class.syncml_command_add.inc.php,v 1.3 2007/08/05 
17:15:40 johang Exp $
         */
 
        require_once 'inc/constants.inc.php';
@@ -74,13 +74,16 @@
                                                        $data = 
$session->get_var(SYNCML_ITEMBUFFER);
                                                        $type = 
$session->get_var(SYNCML_ITEMTYPE);
 
-                                                       $code = 
$database->add_item(
+                                                       list($code, $guid) = 
$database->add_item(
                                                                
$item['source']['locuri'], $data, $type);
 
                                                        
$session->save_modified_luid(
                                                                
$database->channel_id,
                                                                
$item['source']['locuri']);
 
+                                                       
$session->save_modified_guid(
+                                                               
$database->channel_id, $guid);
+
                                                        // reset all chunking 
stuff when we're done
                                                        
$this->reset_chunking($session);
                                        }

Index: inc/class.syncml_command_alert.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.syncml_command_alert.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.syncml_command_alert.inc.php      30 Jul 2007 13:04:39 -0000      
1.1.1.1
+++ inc/class.syncml_command_alert.inc.php      5 Aug 2007 17:15:40 -0000       
1.2
@@ -7,7 +7,7 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: class.syncml_command_alert.inc.php,v 1.1.1.1 
2007/07/30 13:04:39 johang Exp $
+        * @version   $Id: class.syncml_command_alert.inc.php,v 1.2 2007/08/05 
17:15:40 johang Exp $
         */
 
        require_once 'inc/class.sochannel.inc.php';
@@ -107,6 +107,10 @@
                                                $database_id, 
$session->get_var('device_uri'));
                                }
 
+                               $database = new syncml_database($channel_id);
+                               $database->merge_changes();
+                               unset($database);
+
                                // todo: make iso 8601 instead.
                                $phpgw_next = time();
 

Index: inc/class.syncml_command_delete.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.syncml_command_delete.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.syncml_command_delete.inc.php     30 Jul 2007 13:04:39 -0000      
1.1.1.1
+++ inc/class.syncml_command_delete.inc.php     5 Aug 2007 17:15:40 -0000       
1.2
@@ -7,7 +7,7 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: class.syncml_command_delete.inc.php,v 1.1.1.1 
2007/07/30 13:04:39 johang Exp $
+        * @version   $Id: class.syncml_command_delete.inc.php,v 1.2 2007/08/05 
17:15:40 johang Exp $
         */
 
        require_once 'inc/class.syncml_command.inc.php';
@@ -40,7 +40,9 @@
                        {
                                foreach($this->item as $item)
                                {
-                                       
if($database->delete_item($item['source']['locuri']))
+                                       $h = 
$database->delete_item($item['source']['locuri']);
+                                       
+                                       if($h[0])
                                        {
                                                $response->add_status(
                                                        $this->cmdid, 
$session->msgid, 'Delete',

Index: inc/class.syncml_command_map.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.syncml_command_map.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.syncml_command_map.inc.php        30 Jul 2007 13:04:39 -0000      
1.1.1.1
+++ inc/class.syncml_command_map.inc.php        5 Aug 2007 17:15:40 -0000       
1.2
@@ -7,7 +7,7 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: class.syncml_command_map.inc.php,v 1.1.1.1 
2007/07/30 13:04:39 johang Exp $
+        * @version   $Id: class.syncml_command_map.inc.php,v 1.2 2007/08/05 
17:15:40 johang Exp $
         */
 
        require_once 'inc/class.syncml_command.inc.php';
@@ -46,10 +46,13 @@
 
                        foreach($this->mapitem as $item)
                        {
-                               $somappings->replace_mapping(
+                               $somappings->delete_mapping(
                                        $open_channel['channel_id'],
-                                       $item['source']['locuri'],
-                                       $item['target']['locuri']);
+                                       NULL, $item['target']['locuri'], NULL);
+
+                               $somappings->insert_mapping(
+                                       $open_channel['channel_id'],
+                                       $item['source']['locuri'], 
$item['target']['locuri'], 0);
                        }
 
                        if(isset($this->noresp) && $this->noresp)

Index: inc/class.syncml_command_replace.inc.php
===================================================================
RCS file: 
/sources/phpgroupware/syncml/inc/class.syncml_command_replace.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- inc/class.syncml_command_replace.inc.php    30 Jul 2007 21:07:50 -0000      
1.2
+++ inc/class.syncml_command_replace.inc.php    5 Aug 2007 17:15:40 -0000       
1.3
@@ -7,7 +7,7 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: class.syncml_command_replace.inc.php,v 1.2 
2007/07/30 21:07:50 johang Exp $
+        * @version   $Id: class.syncml_command_replace.inc.php,v 1.3 
2007/08/05 17:15:40 johang Exp $
         */
 
        require_once 'inc/constants.inc.php';
@@ -74,13 +74,16 @@
                                                        $data = 
$session->get_var(SYNCML_ITEMBUFFER);
                                                        $type = 
$session->get_var(SYNCML_ITEMTYPE);
 
-                                                       $code = 
$database->replace_item(
+                                                       list($code, $guid) = 
$database->replace_item(
                                                                
$item['source']['locuri'], $data, $type);
 
                                                        
$session->save_modified_luid(
                                                                
$database->channel_id,
                                                                
$item['source']['locuri']);
 
+                                                       
$session->save_modified_guid(
+                                                               
$database->channel_id, $guid);
+
                                                        // reset all chunking 
stuff when we're done
                                                        
$this->reset_chunking($session);
                                        }

Index: inc/class.syncml_command_status.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.syncml_command_status.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.syncml_command_status.inc.php     30 Jul 2007 13:04:39 -0000      
1.1.1.1
+++ inc/class.syncml_command_status.inc.php     5 Aug 2007 17:15:40 -0000       
1.2
@@ -7,7 +7,7 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: class.syncml_command_status.inc.php,v 1.1.1.1 
2007/07/30 13:04:39 johang Exp $
+        * @version   $Id: class.syncml_command_status.inc.php,v 1.2 2007/08/05 
17:15:40 johang Exp $
         */
 
        require_once 'inc/class.syncml_command.inc.php';
@@ -48,7 +48,7 @@
                        switch($this->data)
                        {
                                case SYNCML_STATUS_OK:
-                                       // insert a temp mapping so we don't 
sent this item
+                                       // insert a temp mapping so we don't 
send this item
                                        // again if client caches the MAP 
commands
                                        $somappings->insert_mapping(
                                                $channel_id,  NULL, 
$this->sourceref, 0);

Index: inc/class.syncml_database.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.syncml_database.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.syncml_database.inc.php   30 Jul 2007 13:04:39 -0000      1.1.1.1
+++ inc/class.syncml_database.inc.php   5 Aug 2007 17:15:40 -0000       1.2
@@ -7,11 +7,13 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: class.syncml_database.inc.php,v 1.1.1.1 2007/07/30 
13:04:39 johang Exp $
+        * @version   $Id: class.syncml_database.inc.php,v 1.2 2007/08/05 
17:15:40 johang Exp $
         */
 
        require_once 'inc/class.somappings.inc.php';
 
+       require_once 'inc/class.sochannel.inc.php';
+
        /**
         * Represents a SyncML database. This class wraps calls to the IPC 
classes
         * in each source/app.
@@ -81,8 +83,8 @@
                                        s.mimeversion as mineversion
                                FROM
                                        phpgw_syncml_sources s,
-                                       phpgw_syncml_channel c,
-                                       phpgw_syncml_database d
+                                       phpgw_syncml_channels c,
+                                       phpgw_syncml_databases d
                                WHERE
                                        c.channel_id = %d AND
                                        c.database_id = d.database_id AND
@@ -120,6 +122,35 @@
                }
 
                /**
+                * Merge information about changes from phpgw to the mappings 
table.
+                *
+                * @param $except_list Array of GUIDs not to merge.
+                * @return int         Number of changes merged.
+                */
+               function merge_changes($except_list = array())
+               {
+                       if(!$this->ipc)
+                       {
+                               return 0;
+                       }
+
+                       $sochannel = new syncml_sochannel();
+
+                       list(, , , $last_merge) = 
$sochannel->get_channel($this->channel_id);
+
+                       $changed_guids = array_diff(
+                               $this->ipc->getIdList($last_merge), 
$except_list);
+
+                       foreach($changed_guids as $guid)
+                       {
+                               $this->somappings->update_mapping(
+                                       $this->channel_id, NULL, $guid, 1);
+                       }
+
+                       $sochannel->update_last_merge($this->channel_id);
+               }
+
+               /**
                 * Get item from database.
                 *
                 * @param string  GUID of item to get.
@@ -141,13 +172,16 @@
                 */
                function add_item($luid, $data, $type, $override = FALSE)
                {
-                       switch($this->replace_item($luid, $data, $type, 
$override))
+                       $h = $this->replace_item($luid, $data, $type, 
$override);
+
+                       switch($h[0])
                        {
                                case SYNCML_STATUS_OK:
                                case SYNCML_STATUS_ITEMADDED:
-                                       return SYNCML_STATUS_ITEMADDED;
+                                       return array(SYNCML_STATUS_ITEMADDED, 
$h[1]);
                                case 
SYNCML_STATUS_CONFLICTRESOLVEDWITHDUPLICATE:
-                                       return 
SYNCML_STATUS_CONFLICTRESOLVEDWITHDUPLICATE;
+                                       return array(
+                                               
SYNCML_STATUS_CONFLICTRESOLVEDWITHDUPLICATE, $h[1]);
                        }
                }
 
@@ -182,9 +216,6 @@
 
                        if($dirty)
                        {
-                               // conflict. solve by duplication.
-
-                               // add this new item.
                                $new_guid = $this->ipc->adddata($data, $type);
 
                                // we want to add the old item to our client, by
@@ -196,29 +227,26 @@
                                $this->somappings->insert_mapping(
                                        $this->channel_id, $luid, $new_guid, 0);
 
-                               return 
SYNCML_STATUS_CONFLICTRESOLVEDWITHDUPLICATE;
+                               return 
array(SYNCML_STATUS_CONFLICTRESOLVEDWITHDUPLICATE,
+                                       $guid);
                        }
                        else if($guid)
                        {
-                               // regular REPLACE
-
                                $this->ipc->replacedata($guid, $data, $type);
 
                                $this->somappings->update_mapping(
-                                       $this->channel_id, $guid, NULL, 1);
+                                       $this->channel_id, $guid, NULL, 0);
 
-                               return SYNCML_STATUS_OK;
+                               return array(SYNCML_STATUS_OK, $guid);
                        }
                        else
                        {
-                               // this REPLACE behaves like ADD
-
                                $guid = $this->ipc->adddata($data, $type);
 
                                $this->somappings->insert_mapping(
                                        $this->channel_id, $luid, $guid, 0);
 
-                               return SYNCML_STATUS_ITEMADDED;
+                               return array(SYNCML_STATUS_ITEMADDED, $guid);
                        }
                }
 
@@ -246,10 +274,10 @@
                                $this->somappings->delete_mapping(
                                        $this->channel_id, $luid, NULL, NULL);
 
-                               return $deletes > 0;
+                               return array($deletes > 0, $guid);
                        }
 
-                       return FALSE;
+                       return array(0, NULL);
                }
 
                /**
@@ -266,8 +294,6 @@
                        $mappings = $this->somappings->get_mapping(
                                $this->channel_id, NULL, NULL, NULL);
 
-                       // replace luid-guid-dirty array with guid only
-
                        $mapped_guids = array();
 
                        foreach($mappings as $m)
@@ -471,17 +497,15 @@
                 * @param $data         Data to chunk.
                 * @param $session      Session object.
                 * @param $maxchunksize Max size of this chunk.
-                * @return string       A chunk of data.
+                * @return array        The chunk of data (string), weather 
this is
+                *                      first chunk (bool), weather this is last
+                *                      chunk (bool).
                 */
                function get_chunk($data, &$session, $maxchunksize)
                {
                        if(!$session->get_var(SYNCML_SUPPORTLARGEOBJS))
                        {
-                               return array(
-                                       $data,
-                                       true,
-                                       true
-                               );
+                               return array($data, true, true);
                        }
 
                        // offset is start of this chunk
@@ -497,16 +521,14 @@
                        {
                                return array(
                                        substr($data, $offset, $maxchunksize),
-                                       $offset == 0,
-                                       $next_offset == 0
+                                       $offset == 0, $next_offset == 0
                                );
                        }
                        else
                        {
                                return array(
                                        substr($data, $offset),
-                                       $offset == 0,
-                                       $next_offset == 0
+                                       $offset == 0, $next_offset == 0
                                );
                        }
                }

Index: inc/class.syncml_message.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.syncml_message.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.syncml_message.inc.php    30 Jul 2007 13:04:39 -0000      1.1.1.1
+++ inc/class.syncml_message.inc.php    5 Aug 2007 17:15:40 -0000       1.2
@@ -7,7 +7,7 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: class.syncml_message.inc.php,v 1.1.1.1 2007/07/30 
13:04:39 johang Exp $
+        * @version   $Id: class.syncml_message.inc.php,v 1.2 2007/08/05 
17:15:40 johang Exp $
         */
 
        require_once 'inc/class.syncml_command_final.inc.php';
@@ -29,6 +29,11 @@
                        $this->commands[] = new syncml_command_synchdr($header);
                }
 
+               /**
+                * Build and save command objects from XML array.
+                *
+                * @param $body XML array of BODY element.
+                */
                function process_body($body)
                {
                        if(isset($body['FINAL'][0]))
@@ -60,9 +65,8 @@
                        }
                }
 
-               function execute()
+               function execute($response)
                {
-                       $response = new syncml_response();
                        $session = new syncml_session();
 
                        // process every command in message
@@ -83,12 +87,28 @@
 
                                foreach($open_channels as $open_channel)
                                {
+                                       $database = new syncml_database(
+                                               $open_channel['channel_id']);
+                                       
                                        
if(!$open_channel['server_modifications_sent'])
                                        {
+                                               /*
+                                                       This code is run 
*after* all modifications from
+                                                       client are sent and 
*before* any modfifications
+                                                       are sent by the server.
+                                               */
+
                                                // LUIDs modified by the 
*client* during this session
                                                $all_modified_luids = 
$session->get_all_modified_luids(
                                                        
$open_channel['channel_id']);
 
+                                               // GUIDs modified by the 
*client* during this session
+                                               $all_modified_guids = 
$session->get_all_modified_guids(
+                                                       
$open_channel['channel_id']);
+
+                                               // Bring all changed items from 
phpgw
+                                               
$database->merge_changes($all_modified_guids);
+
                                                switch($open_channel['type'])
                                                {
                                                        case 
SYNCML_ALERT_SLOWSYNC:
@@ -114,7 +134,7 @@
                                        
if(!$open_channel['all_server_modifications_sent'])
                                        {
                                                $more_to_send = 
$this->_send_modifications(
-                                                       $response, $session, 
$open_channel);
+                                                       $response, $session, 
$open_channel, $database);
 
                                                
$session->set_open_channel_property(
                                                        
$open_channel['source'], $open_channel['target'],
@@ -122,6 +142,9 @@
 
                                                if($more_to_send)
                                                {
+                                                       // there's more to send 
from this channel. we
+                                                       // continue with that 
in next message.
+                                                       
                                                        
$response->set_final(FALSE);
                                                        break;
                                                }
@@ -163,10 +186,9 @@
                 * @return bool Returns true if there are more modifications to 
send
                 *              that didn't fit in this message.
                 */
-               function _send_modifications(&$response, &$session, 
$open_channel)
+               function _send_modifications(&$response, &$session, 
$open_channel,
+                       $database)
                {
-                       $database = new 
syncml_database($open_channel['channel_id']);
-
                        switch($open_channel['type'])
                        {
                                case SYNCML_ALERT_SLOWSYNC:
@@ -188,7 +210,12 @@
                }
 
                /**
-                * Do some work before we can finish the slow sync.
+                * Remove mappings for items not touched by the client so they 
can
+                * be sent like regular ADDs during next phase of the session.
+                *
+                * @param $channel_id                ID of channel to prepare 
the slow
+                *                                   sync for.
+                * @param $all_client_modified_luids All LUIDs client modified.
                 */
                function prepare_slowsync($channel_id, 
$all_client_modified_luids)
                {
@@ -202,11 +229,19 @@
                        // remove mappings not modified by client
                        foreach($luids_to_kill as $luid)
                        {
-                               $somappings->delete_mapping(
-                                       $channel_id, $luid, NULL, NULL);
+                               $somappings->delete_mapping($channel_id, $luid, 
NULL, NULL);
                        }
                }
 
+               /**
+                * Remove items not touched by the client.
+                * 
+                * @param $channel_id                ID of channel to prepare 
the slow
+                *                                   sync for.
+                * @param $all_client_modified_luids All LUIDs client modified.
+                * @param $database                  Database involved in this
+                *                                   session.
+                */
                function finish_client_refresh($channel_id, 
$all_client_modified_luids,
                        $database)
                {
@@ -223,6 +258,14 @@
                        }
                }
 
+               /**
+                * Fetch modifications and insert a SYNC command.
+                * 
+                * @param $response     Response object to write SYNC command 
to.
+                * @param $session      Session object.
+                * @param $database     Database object to pull changes from.
+                * @param $open_channel Channel involved in this SYNC command.
+                */
                function _send_sync(&$response, &$session, $database, 
$open_channel)
                {
                        $commands = array();

Index: inc/class.syncml_session.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/class.syncml_session.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/class.syncml_session.inc.php    30 Jul 2007 13:04:39 -0000      1.1.1.1
+++ inc/class.syncml_session.inc.php    5 Aug 2007 17:15:41 -0000       1.2
@@ -7,7 +7,7 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: class.syncml_session.inc.php,v 1.1.1.1 2007/07/30 
13:04:39 johang Exp $
+        * @version   $Id: class.syncml_session.inc.php,v 1.2 2007/08/05 
17:15:41 johang Exp $
         */
 
        require_once 'inc/constants.inc.php';
@@ -131,6 +131,26 @@
                        return 
$this->session_data['modified_luids'][$channel_id];
                }
 
+               function save_modified_guid($channel_id, $guid)
+               {
+                       if(!isset($this->session_data['modified_guids']))
+                       {
+                               $this->session_data['modified_guids'] = array();
+                       }
+                       
+                       $this->session_data['modified_guids'][$channel_id][] = 
$guid;
+               }
+
+               function get_all_modified_guids($channel_id)
+               {
+                       
if(!isset($this->session_data['modified_guids'][$channel_id]))
+                       {
+                               return array();
+                       }
+                       
+                       return 
$this->session_data['modified_guids'][$channel_id];
+               }
+
                /**
                 * Returns array with open channels and their channel ID, sync 
type,
                 * source database and target database.

Index: inc/functions.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/inc/functions.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/functions.inc.php       30 Jul 2007 13:04:39 -0000      1.1.1.1
+++ inc/functions.inc.php       5 Aug 2007 17:15:41 -0000       1.2
@@ -7,7 +7,7 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License 3 or later
         * @package   syncml
-        * @version   $Id: functions.inc.php,v 1.1.1.1 2007/07/30 13:04:39 
johang Exp $
+        * @version   $Id: functions.inc.php,v 1.2 2007/08/05 17:15:41 johang 
Exp $
         */
 
        /**
@@ -20,14 +20,14 @@
        function syncml_update_hash($account_id, $account_lid, $password)
        {
                $GLOBALS["phpgw"]->db->query(sprintf("
-                       DELETE FROM phpgw_syncml_hash
+                       DELETE FROM phpgw_syncml_hashes
                        WHERE
                                account_id = '%d'",
                        $account_id
                ));
 
                $GLOBALS["phpgw"]->db->query(sprintf("
-                       INSERT INTO phpgw_syncml_hash(
+                       INSERT INTO phpgw_syncml_hashes(
                                account_id, hash)
                        VALUES('%d', '%s')",
                        $account_id,
@@ -49,4 +49,20 @@
                        base64_encode(md5($username . ':' . $password, true)). 
':' . $nonce
                ));
        }
+
+       /**
+        * Parse the XML definition and look for encoding attribute.
+        *
+        * @param $data XML string.
+        * @return string Found encoding or NULL of no encoding found. 
+        */
+       function syncml_parse_encoding($data)
+       {
+               if(preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $data, 
$m))
+               {
+                       return strtoupper($m[1]);
+               }
+               
+               return NULL;
+       }
 ?>

Index: setup/setup.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/setup/setup.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- setup/setup.inc.php 30 Jul 2007 13:04:38 -0000      1.1.1.1
+++ setup/setup.inc.php 5 Aug 2007 17:15:41 -0000       1.2
@@ -7,12 +7,12 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License
         * @package   syncml
-        * @version   $Id: setup.inc.php,v 1.1.1.1 2007/07/30 13:04:38 johang 
Exp $
+        * @version   $Id: setup.inc.php,v 1.2 2007/08/05 17:15:41 johang Exp $
         */
        
        $setup_info['syncml']['name'] = 'syncml';
        $setup_info['syncml']['title'] = 'SyncML Synchronization';
-       $setup_info['syncml']['version'] = '0.9.17.001';
+       $setup_info['syncml']['version'] = '0.9.17.002';
        $setup_info['syncml']['license']  = 'GNU General Public License';
        
        $setup_info['syncml']['app_order'] = 10;
@@ -20,12 +20,12 @@
        
        $setup_info['syncml']['tables'] = array
        (
-               'phpgw_syncml_session',
-               'phpgw_syncml_hash',
+               'phpgw_syncml_sessions',
+               'phpgw_syncml_hashes',
                'phpgw_syncml_sources',
                'phpgw_syncml_mappings',
-               'phpgw_syncml_channel',
-               'phpgw_syncml_database'
+               'phpgw_syncml_channels',
+               'phpgw_syncml_databases'
        );
        
        $setup_info['syncml']['hooks'] = array

Index: setup/tables_current.inc.php
===================================================================
RCS file: /sources/phpgroupware/syncml/setup/tables_current.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- setup/tables_current.inc.php        30 Jul 2007 13:04:38 -0000      1.1.1.1
+++ setup/tables_current.inc.php        5 Aug 2007 17:15:41 -0000       1.2
@@ -7,16 +7,14 @@
         * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
         * @license   GNU General Public License
         * @package   syncml
-        * @version   $Id: tables_current.inc.php,v 1.1.1.1 2007/07/30 13:04:38 
johang Exp $
+        * @version   $Id: tables_current.inc.php,v 1.2 2007/08/05 17:15:41 
johang Exp $
         */
        
-       // todo: table names should be plural.
-       
        $phpgw_baseline = array(
                /**
-                * syncml session <-> phpgw sessions.
+                * Maps SyncML sessions to phpgw sessions.
                 */
-               'phpgw_syncml_session' => array(
+               'phpgw_syncml_sessions' => array(
                        'fd' => array(
                                'phpgw_sid' => array(
                                        'type' => 'varchar', 'precision' => 
'32', 
@@ -37,7 +35,7 @@
                 * Just a way to keep precalculated hashes of users' names and
                 * passwords.
                 */
-               'phpgw_syncml_hash' => array(
+               'phpgw_syncml_hashes' => array(
                        'fd' => array(
                                'account_id' => array(
                                        'type' => 'int', 'precision' => 4),
@@ -51,9 +49,9 @@
                        'uc' => array()
                ),
                /**
-                * Every device has one channel to each database to sync.
+                * Every device has one channel to each database.
                 */
-               'phpgw_syncml_channel' => array(
+               'phpgw_syncml_channels' => array(
                        'fd' => array(
                                'channel_id' => array(
                                        'type' => 'auto', 'nullable' => False),
@@ -67,7 +65,9 @@
                                'device_anchor_last' => array(
                                        'type' => 'varchar', 'precision' => 
'16'),
                                'devinf_cache' => array(
-                                       'type' => 'text', 'default' => '')
+                                       'type' => 'text', 'default' => ''),
+                               'last_merge' => array(
+                                       'type' => 'int', 'precision' => '8', 
'nullable' => False)
                        ),
                        'pk' => array('channel_id'),
                        'fk' => array(),
@@ -75,11 +75,9 @@
                        'uc' => array()
                ),
                /**
-                * Each user has databases that are synchable.
-                *
-                * database_uri + account_id is unique.
+                * Each user has synchable databases.
                 */
-               'phpgw_syncml_database' => array(
+               'phpgw_syncml_databases' => array(
                        'fd' => array(
                                'database_id' => array(
                                        'type' => 'auto', 'nullable' => False),
@@ -104,7 +102,7 @@
                        'uc' => array()
                ),
                /**
-                * meh
+                * Maps ID numbers on client devices to ID numbers in phpgw.
                 */
                'phpgw_syncml_mappings' => array(
                        'fd' => array(
@@ -129,7 +127,7 @@
                        'uc' => array()
                ),
                /**
-                * meh
+                * Data sources that databases can use.
                 */
                'phpgw_syncml_sources' => array(
                        'fd' => array(

Index: inc/class.syncml_xml_parser.inc.php
===================================================================
RCS file: inc/class.syncml_xml_parser.inc.php
diff -N inc/class.syncml_xml_parser.inc.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ inc/class.syncml_xml_parser.inc.php 5 Aug 2007 17:15:41 -0000       1.1
@@ -0,0 +1,44 @@
+<?php
+       /**
+        * phpGroupWare (http://phpgroupware.org/)
+        * SyncML interface
+        *
+        * @author    Johan Gunnarsson <address@hidden>
+        * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+        * @license   GNU General Public License
+        * @package   syncml
+        * @version   $ $
+        */
+
+       require_once 'inc/functions.inc.php';
+
+       class syncml_xml_parser
+       {
+               function parse($data, $mapper)
+               {
+                       $encoding = syncml_parse_encoding($data);
+
+                       if($encoding)
+                       {
+                               $parser = xml_parser_create($encoding);
+                       }
+                       else
+                       {
+                               $parser = xml_parser_create();
+                       }
+
+                       xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 
0);
+                       xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 
1);
+
+                       xml_set_object($parser, $mapper);
+
+                       xml_set_element_handler($parser, 'start_tag', 
'end_tag');
+                       xml_set_character_data_handler($parser, 'data');
+
+                       xml_parse($parser, $data);
+                       xml_parser_free($parser);
+
+                       return $mapper->structure;
+               }
+       }
+?>

Index: setup/tables_baseline.inc.php
===================================================================
RCS file: setup/tables_baseline.inc.php
diff -N setup/tables_baseline.inc.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ setup/tables_baseline.inc.php       5 Aug 2007 17:15:41 -0000       1.1
@@ -0,0 +1,134 @@
+<?php
+       /**
+        * phpGroupWare (http://phpgroupware.org/)
+        * SyncML interface
+        *
+        * @author    Johan Gunnarsson <address@hidden>
+        * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+        * @license   GNU General Public License
+        * @package   syncml
+        * @version   $Id: tables_baseline.inc.php,v 1.1 2007/08/05 17:15:41 
johang Exp $
+        */
+
+       $phpgw_baseline = array(
+               'phpgw_syncml_session' => array(
+                       'fd' => array(
+                               'phpgw_sid' => array(
+                                       'type' => 'varchar', 'precision' => 
'32',
+                                       'nullable' => False),
+                               'syncml_hash' => array(
+                                       'type' => 'varchar', 'precision' => 
'32',
+                                       'nullable' => False),
+                               'session_dla' => array(
+                                       'type' => 'int', 'precision' => '8',
+                                       'nullable' => False)
+                       ),
+                       'pk' => array('syncml_hash'),
+                       'fk' => array(),
+                       'ix' => array(),
+                       'uc' => array()
+               ),
+               'phpgw_syncml_hash' => array(
+                       'fd' => array(
+                               'account_id' => array(
+                                       'type' => 'int', 'precision' => 4),
+                               'hash' => array(
+                                       'type' => 'varchar', 'precision' => 32,
+                                       'nullable' => False)
+                       ),
+                       'pk' => array('account_id'),
+                       'fk' => array(),
+                       'ix' => array(),
+                       'uc' => array()
+               ),
+               'phpgw_syncml_channel' => array(
+                       'fd' => array(
+                               'channel_id' => array(
+                                       'type' => 'auto', 'nullable' => False),
+                               'device_uri' => array(
+                                       'type' => 'varchar', 'precision' => 
'255',
+                                       'nullable' => False),
+                               'database_id' => array(
+                                       'type' => 'int', 'precision' => '4', 
'nullable' => False),
+                               'phpgw_anchor_last' => array(
+                                       'type' => 'varchar', 'precision' => 
'16'),
+                               'device_anchor_last' => array(
+                                       'type' => 'varchar', 'precision' => 
'16'),
+                               'devinf_cache' => array(
+                                       'type' => 'text', 'default' => '')
+                       ),
+                       'pk' => array('channel_id'),
+                       'fk' => array(),
+                       'ix' => array('device_uri', 'database_id'),
+                       'uc' => array()
+               ),
+               'phpgw_syncml_database' => array(
+                       'fd' => array(
+                               'database_id' => array(
+                                       'type' => 'auto', 'nullable' => False),
+                               'database_uri' => array(
+                                       'type' => 'varchar', 'precision' => 
'255',
+                                       'nullable' => False),
+                               'source_id' => array(
+                                       'type' => 'int', 'precision' => '4',
+                                       'nullable' => False),
+                               'credential_required' => array(
+                                       'type' => 'int', 'precision' => '2',
+                                       'nullable' => False),
+                               'credential_hash' => array(
+                                       'type' => 'varchar', 'precision' => 
'32',
+                                       'nullable' => False),
+                               'account_id' => array(
+                                       'type' => 'int', 'precision' => '4', 
'nullable' => False)
+                       ),
+                       'pk' => array('database_id'),
+                       'fk' => array(),
+                       'ix' => array('database_uri'),
+                       'uc' => array()
+               ),
+               'phpgw_syncml_mappings' => array(
+                       'fd' => array(
+                               'mapping_id' => array(
+                                       'type' => 'auto', 'nullable' => False),
+                               'channel_id' => array(
+                                       'type' => 'int', 'precision' => '4',
+                                       'nullable' => False),
+                               'luid' => array(
+                                       'type' => 'varchar', 'precision' => 
'255',
+                                       'nullable' => True),
+                               'guid' => array(
+                                       'type' => 'varchar', 'precision' => 
'255',
+                                       'nullable' => True),
+                               'dirty' => array(
+                                       'type' => 'int', 'precision' => '2',
+                                       'nullable' => False)
+                       ),
+                       'pk' => array('mapping_id'),
+                       'fk' => array(),
+                       'ix' => array('channel_id'),
+                       'uc' => array()
+               ),
+               'phpgw_syncml_sources' => array(
+                       'fd' => array(
+                               'source_id' => array(
+                                       'type' => 'auto', 'nullable' => False),
+                               'name' => array(
+                                       'type' => 'varchar', 'precision' => 
'50',
+                                       'nullable' => False),
+                               'modulename' => array(
+                                       'type' => 'varchar', 'precision' => 
'25',
+                                       'nullable' => False),
+                               'mimetype' => array(
+                                       'type' => 'varchar', 'precision' => 
'255',
+                                       'nullable' => False),
+                               'mimeversion' => array(
+                                       'type' => 'varchar', 'precision' => '8',
+                                       'nullable' => False)
+                       ),
+                       'pk' => array('source_id'),
+                       'fk' => array(),
+                       'ix' => array(),
+                       'uc' => array()
+               ),
+       );
+?>

Index: setup/tables_update.php
===================================================================
RCS file: setup/tables_update.php
diff -N setup/tables_update.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ setup/tables_update.php     5 Aug 2007 17:15:41 -0000       1.1
@@ -0,0 +1,41 @@
+<?php
+       /**
+        * phpGroupWare (http://phpgroupware.org/)
+        * SyncML interface
+        *
+        * @author    Johan Gunnarsson <address@hidden>
+        * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+        * @license   GNU General Public License
+        * @package   syncml
+        * @version   $ $
+        */
+
+       $test[] = '0.9.17.001';
+
+       function notes_upgrade0.9.17.001()
+       {
+               $GLOBALS['phpgw_setup']->oProc->RenameTable(
+                       'phpgw_syncml_channel', 'phpgw_syncml_channels'
+               );
+
+               $GLOBALS['phpgw_setup']->oProc->RenameTable(
+                       'phpgw_syncml_database', 'phpgw_syncml_databases'
+               );
+
+               $GLOBALS['phpgw_setup']->oProc->RenameTable(
+                       'phpgw_syncml_hash', 'phpgw_syncml_hashes'
+               );
+
+               $GLOBALS['phpgw_setup']->oProc->RenameTable(
+                       'phpgw_syncml_session', 'phpgw_syncml_sessions'
+               );
+
+               $GLOBALS['phpgw_setup']->oProc->AddColumn(
+                       'phpgw_syncml_channels', 'last_merge', array(
+                               'type' => 'int', 'precision' => 8, 'nullable' 
=> False)
+               );
+
+               $GLOBALS['setup_info']['syncml']['currentver'] = '0.9.17.002';
+               return $GLOBALS['setup_info']['syncml']['currentver'];
+       }
+?>

Index: inc/xml_functions.inc.php
===================================================================
RCS file: inc/xml_functions.inc.php
diff -N inc/xml_functions.inc.php
--- inc/xml_functions.inc.php   30 Jul 2007 13:04:39 -0000      1.1.1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,51 +0,0 @@
-<?php
-       /**
-        * phpGroupWare (http://phpgroupware.org/)
-        * SyncML interface
-        *
-        * @author    Johan Gunnarsson <address@hidden>
-        * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
-        * @license   GNU General Public License
-        * @package   syncml
-        * @version   $Id: xml_functions.inc.php,v 1.1.1.1 2007/07/30 13:04:39 
johang Exp $
-        */
-       
-       function parse_encoding($data)
-       {
-               if(preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $data, 
$m))
-               {
-                       return strtoupper($m[1]);
-               }
-               return NULL;
-       }
-       
-       function parse_xml($data, $mapper = null)
-       {
-               if(!is_null($encoding = parse_encoding($data)))
-               {
-                       $parser = xml_parser_create($encoding);
-               }
-               else
-               {
-                       $parser = xml_parser_create();
-               }
-               
-               if(is_null($mapper))
-               {
-                       $mapper = new xml_mapper();
-               }
-               
-               xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
-               xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 1);
-               
-               xml_set_object($parser, $mapper);
-               
-               xml_set_element_handler($parser, 'start_tag', 'end_tag');
-               xml_set_character_data_handler($parser, 'data');
-               
-               xml_parse($parser, $data);
-               xml_parser_free($parser);
-               
-               return $mapper->structure;
-       }
-?>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]