http://bugzilla.moblin.org/show_bug.cgi?id=6378
--- Comment #27 from yongsheng zhu <yongsheng.zhu(a)intel.com> 2010-02-26 01:34:56
PST ---
syncevolution should have a mechanism to detect backends changes, here is a
proposal:
1) Define a new class SyncSourceListener, used to track backends changes. 3
virtual methods are acted as callbacks of change signals.
class SyncSourceListener {
public:
/** itemAdded is a callback when an item is newly added by backend */
virtual void itemAdded(const string &luid, const string &item, bool raw) {};
/** itemRemoved is a callback when an item is newly removed by backend */
virtual void itemRemoved(const string &luid) {};
/** itemChanged is a callback when an item is newly changed by backend */
virtual void itemChanged(const string &luid, const string &item, bool raw) {};
};
2) Add a virtual method in TrackingSyncSource:
class SyncSource {
public:
...
/**
* Register a listener to listen to backend changes
* Each backend can implement this if it has the ability
* to track backend changes.
* If the listener is registered successfully, return true
*/
virtual bool addListener(SyncSourceListener *listener)
{
return false;
}
};
3) how to use:
define its child class based on SyncSourceListener, register it to the
syncsource. Each backend can implement 'addListener' if it can.
class MySourceListener : public SyncSourceListener
{
public:
virtual void itemAdded(const string &luid, const string &item, bool raw)
{
// trigger auto sync tasks possibly
}
private:
bool m_added;
};
class EvolutionContactSource
{
bool addListener(SyncSourceListener *listener) {
// contact to eds and listen its signals, if has signals, call listener's
corresponding callbacks
}
};
The sample code is like:
MySourceListener myListener;
SourceList* list = syncContext.getSourceList();
BOOST_FOREACH(SyncSource *source, list) {
source->addListener(&myListener);
}
--
Configure bugmail:
http://bugzilla.moblin.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching someone on the CC list of the bug.