[conduit/syncml: 33/244] Gaaah



commit ca164e8ff12594374991d408ed267471116b8cf1
Author: John Carr <john carr unrouted co uk>
Date:   Thu Apr 16 09:07:00 2009 -0700

    Gaaah
---
 conduit/modules/SyncmlModule/SyncmlModule.py |   18 ++++++++++++------
 test/python-tests/TestSyncSyncmlEvents.py    |    8 +++++++-
 test/python-tests/syncml-server.sh           |    1 +
 3 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/conduit/modules/SyncmlModule/SyncmlModule.py b/conduit/modules/SyncmlModule/SyncmlModule.py
index b3f5cff..5a9c5ed 100644
--- a/conduit/modules/SyncmlModule/SyncmlModule.py
+++ b/conduit/modules/SyncmlModule/SyncmlModule.py
@@ -1,3 +1,5 @@
+import conduit
+
 import conduit.utils as Utils
 import conduit.dataproviders.DataProvider as DataProvider
 import conduit.dataproviders.DataProviderCategory as DataProviderCategory
@@ -100,6 +102,11 @@ class SyncmlDataProvider(DataProvider.TwoWay):
             This WILL happen in a different thread to where sync is happening.
         """
         self._changes[uid] = (type, data[:size])
+
+        if self._session_type == enums.SML_SESSION_TYPE_CLIENT:
+            err = pysyncml.Error()
+            self.syncobj.add_mapping(source, uid, uid, pysyncml.byref(err))
+
         return 1
 
     def handle_devinf(self, sync_object, info, userdata, err):
@@ -187,10 +194,10 @@ class SyncmlDataProvider(DataProvider.TwoWay):
 
         if LUID == None:
             self._queue.append((enums.SML_CHANGE_ADD, "", blob))
-            return None
+            return conduit.datatypes.Rid(uid=str(hash(blob)), mtime=None, hash=None)
 
         self._queue.append((enums.SML_CHANGE_REPLACE, uid, blob))
-        return None
+        return conduit.datatypes.Rid(uid=uid, mtime=None, hash=None)
 
     def delete(self, uid):
         self._queue.append((enums.SML_CHANGE_DELETE, uid, ""))
@@ -198,20 +205,19 @@ class SyncmlDataProvider(DataProvider.TwoWay):
     def finish(self, a, b, c):
         self._put_lock.set()
         self._refresh_lock.wait(60)
-
         self._changes = None
         self.syncobj.unref(pysyncml.byref(self.syncobj))
 
-        if self._session_type == enums.SML_SESSION_TYPE_CLIENT:
+        if len(self._queue) > 0 and self._session_type == enums.SML_SESSION_TYPE_CLIENT:
             self._changes = {}
             self._syncml_run()
             self._refresh_lock.wait(60)
             self._refresh_lock.wait(60)
-
             self._changes = None
-            self._queue = None
             self.syncobj.unref(pysyncml.byref(self.syncobj))
 
+        self._queue = None
+
     def get_UID(self):
         return self.address
 
diff --git a/test/python-tests/TestSyncSyncmlEvents.py b/test/python-tests/TestSyncSyncmlEvents.py
index de0a30e..ff25dfa 100644
--- a/test/python-tests/TestSyncSyncmlEvents.py
+++ b/test/python-tests/TestSyncSyncmlEvents.py
@@ -2,6 +2,7 @@ import subprocess
 import signal
 import os
 import time
+import shutil
 
 server = subprocess.Popen(["./syncml-server.sh", "text/x-vcalendar", "Calendar", "calendar"], cwd="test/python-tests")
 
@@ -21,9 +22,14 @@ sinkW = test.get_dataprovider("SyncmlEventsTwoWay")
 test.prepare(sourceW, sinkW)
 test.set_two_way_policy({"conflict":"ask","deleted":"ask"})
 
+#tempdir
+tempdir = Utils.new_tempdir()
+for f in get_files_from_data_dir("*.ical"):
+    shutil.copy(f, tempdir)
+
 #configure the source and sink
 config = {}
-config["folder"] = "file://"+Utils.new_tempdir()
+config["folder"] = "file://" + tempdir
 config["folderGroupName"] = "Tomboy"
 test.configure(source=config)
 
diff --git a/test/python-tests/syncml-server.sh b/test/python-tests/syncml-server.sh
index c9cfcdb..a9bea81 100755
--- a/test/python-tests/syncml-server.sh
+++ b/test/python-tests/syncml-server.sh
@@ -1,3 +1,4 @@
 #! /bin/sh
+killall syncml-ds-tool
 syncml-ds-tool --http-server 1234 --sync $1 $2 $3
 syncml-ds-tool --http-server 1234 --sync $1 $2 $3



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