[conduit/syncml: 4/244] A bit of boilerplate..
- From: John Carr <johncarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [conduit/syncml: 4/244] A bit of boilerplate..
- Date: Thu, 21 May 2009 05:49:32 -0400 (EDT)
commit 02e09c17dc124f2423a9d23a627ddda7c36b098f
Author: John Carr <john carr unrouted co uk>
Date: Tue Apr 7 02:51:30 2009 -0700
A bit of boilerplate..
---
conduit/modules/SyncmlModule/SyncmlModule.py | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/conduit/modules/SyncmlModule/SyncmlModule.py b/conduit/modules/SyncmlModule/SyncmlModule.py
index 10568d4..1bf242a 100644
--- a/conduit/modules/SyncmlModule/SyncmlModule.py
+++ b/conduit/modules/SyncmlModule/SyncmlModule.py
@@ -6,6 +6,8 @@ import conduit.dataproviders.BluetoothFactory as BluetoothFactory
import logging
log = logging.getLogger("modules.syncml")
+import threading
+
try:
import pysyncml
except ImportError:
@@ -46,6 +48,12 @@ class SyncmlDataProvider(DataProvider.TwoWay):
log.info("Got all alerts")
elif event == enums.SML_DATA_SYNC_EVENT_GOT_ALL_CHANGES:
log.info("Got All Changes")
+ # unlock the Conduit loop - this allows conduit to process the data we just fetched
+ self._refresh_lock.set()
+ # don't exit this callback - we want to inject the changes conduit tells us about
+ # first.
+ #self._put_lock.wait(60)
+ #self.syncobj.send_changes(byref(err))
elif event == enums.SML_DATA_SYNC_EVENT_GOT_ALL_MAPPINGS:
log.info("Got All Mappings")
elif event == enums.SML_DATA_SYNC_EVENT_DISCONNECT:
@@ -71,6 +79,9 @@ class SyncmlDataProvider(DataProvider.TwoWay):
self._handle_change = pysyncml.ChangeCallback(self.handle_change)
self._handle_devinf = pysyncml.HandleRemoteDevInfCallback(self.handle_devinf)
+ self._refresh_lock = threading.Event()
+ self._put_lock = threading.Event()
+
self._changes = None
def refresh(self):
@@ -101,6 +112,11 @@ class SyncmlDataProvider(DataProvider.TwoWay):
log.info("running sync..")
+ # block here. EventCallback will fire in other thread. When we get GOT_ALL_CHANGES we can unblock here..
+ # then we block in the EventCallback until Conduit has queued all its changes. Then we unblock libsyncml.
+ # Cripes. Stab my eyes out. NOW.
+ self._refresh_lock.wait(60)
+
def get_all(self):
return []
@@ -127,7 +143,7 @@ class SyncmlDataProvider(DataProvider.TwoWay):
self.syncobj.add_change(self.source, enums.SML_CHANGE_DELETE, uid, "", 0, null, byref(err))
def finish(self):
- self.syncobj.send_changes()
+ self._put_lock.set()
self._changes = None
def get_UID(self):
@@ -139,6 +155,7 @@ class SyncmlDataProvider(DataProvider.TwoWay):
def _obj_to_blob(self, obj):
raise NotImplementedError
+
class ContactsProvider(SyncmlDataProvider):
_name_ = "Contacts"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]