syncevo-dbus-server: StatusChanged "idle" was not sent
All sessions started in m_syncStatus = SYNC_IDLE state. The transition from m_active = FALSE (= queueing) to m_active = TRUE (= real "idle") was not announced via a "StatusChanged" signal. Added a new SYNC_QUEUEING state. m_syncStatus starts in that state and changes to idle together with sending the signal when the session gets activated. I kept the m_active/setActive() part because it is somewhat orthogonal to the state transitions and m_active is easier to check than different states.
This commit is contained in:
parent
bd6687bc9b
commit
f3b339ef00
|
@ -799,7 +799,8 @@ class Session : public DBusObjectHelper,
|
|||
* the sync status for session
|
||||
*/
|
||||
enum SyncStatus {
|
||||
SYNC_IDLE = 0, ///< session is initiated but sync not started
|
||||
SYNC_QUEUEING, ///< waiting to become ready for use
|
||||
SYNC_IDLE, ///< ready, session is initiated but sync not started
|
||||
SYNC_RUNNING, ///< sync is running
|
||||
SYNC_ABORT, ///< sync is aborting
|
||||
SYNC_SUSPEND, ///< sync is suspending
|
||||
|
@ -1560,12 +1561,7 @@ void Session::getStatus(std::string &status,
|
|||
uint32_t &error,
|
||||
SourceStatuses_t &sources)
|
||||
{
|
||||
if (!m_active) {
|
||||
status = (m_syncStatus == SYNC_DONE) ?
|
||||
syncStatusToString(m_syncStatus) : "queueing";
|
||||
} else {
|
||||
status = syncStatusToString(m_syncStatus);
|
||||
}
|
||||
status = syncStatusToString(m_syncStatus);
|
||||
// TODO: append ";processing" or ";waiting"
|
||||
|
||||
error = m_error;
|
||||
|
@ -1612,6 +1608,8 @@ void Session::fireProgress(bool flush)
|
|||
string Session::syncStatusToString(SyncStatus state)
|
||||
{
|
||||
switch(state) {
|
||||
case SYNC_QUEUEING:
|
||||
return "queueing";
|
||||
case SYNC_IDLE:
|
||||
return "idle";
|
||||
case SYNC_RUNNING:
|
||||
|
@ -1641,7 +1639,7 @@ Session::Session(DBusServer &server,
|
|||
m_serverMode(false),
|
||||
m_useConnection(false),
|
||||
m_active(false),
|
||||
m_syncStatus(SYNC_IDLE),
|
||||
m_syncStatus(SYNC_QUEUEING),
|
||||
m_priority(PRI_DEFAULT),
|
||||
m_progress(0),
|
||||
m_progData(m_progress),
|
||||
|
@ -1677,6 +1675,11 @@ void Session::setActive(bool active)
|
|||
{
|
||||
m_active = active;
|
||||
if (active) {
|
||||
if (m_syncStatus == SYNC_QUEUEING) {
|
||||
m_syncStatus = SYNC_IDLE;
|
||||
fireStatus(true);
|
||||
}
|
||||
|
||||
boost::shared_ptr<Connection> c = m_connection.lock();
|
||||
if (c) {
|
||||
c->ready();
|
||||
|
|
|
@ -529,6 +529,22 @@ class TestDBusSession(unittest.TestCase, DBusUtil):
|
|||
None,
|
||||
byte_arrays=True,
|
||||
utf8_strings=True)
|
||||
|
||||
def status(*args):
|
||||
if self.running:
|
||||
DBusUtil.events.append(("status", args))
|
||||
if args[0] == "idle":
|
||||
DBusUtil.quit_events.append("session " + sessionpath + " idle")
|
||||
loop.quit()
|
||||
|
||||
bus.add_signal_receiver(status,
|
||||
'StatusChanged',
|
||||
'org.syncevolution.Session',
|
||||
'org.syncevolution',
|
||||
sessionpath,
|
||||
byte_arrays=True,
|
||||
utf8_strings=True)
|
||||
|
||||
session = dbus.Interface(bus.get_object('org.syncevolution',
|
||||
sessionpath),
|
||||
'org.syncevolution.Session')
|
||||
|
@ -543,10 +559,15 @@ class TestDBusSession(unittest.TestCase, DBusUtil):
|
|||
# session 1 done
|
||||
loop.run()
|
||||
self.failUnless(callback_called)
|
||||
# session 2 ready
|
||||
# session 2 ready and idle
|
||||
loop.run()
|
||||
self.failUnlessEqual(DBusUtil.quit_events, ["session " + self.sessionpath + " done",
|
||||
"session " + sessionpath + " ready"])
|
||||
loop.run()
|
||||
expected = ["session " + self.sessionpath + " done",
|
||||
"session " + sessionpath + " idle",
|
||||
"session " + sessionpath + " ready"]
|
||||
expected.sort()
|
||||
DBusUtil.quit_events.sort()
|
||||
self.failUnlessEqual(DBusUtil.quit_events, expected)
|
||||
status, error, sources = session.GetStatus(utf8_strings=True)
|
||||
self.failUnlessEqual(status, "idle")
|
||||
self.removeTimeout(t1)
|
||||
|
|
Loading…
Reference in New Issue