Add app list version number to the AppStateChanged signal and check it

This commit is contained in:
Nedko Arnaudov 2010-09-03 01:49:11 +03:00
parent 6dbf026ba2
commit 7a5ba755e9
2 changed files with 16 additions and 2 deletions

View File

@ -157,12 +157,15 @@ void emit_app_state_changed(struct ladish_app_supervisor * supervisor_ptr, struc
running = app_ptr->pid != 0;
terminal = app_ptr->terminal;
supervisor_ptr->version++;
dbus_signal_emit(
g_dbus_connection,
supervisor_ptr->opath,
IFACE_APP_SUPERVISOR,
"AppStateChanged",
"tsbby",
"ttsbby",
&supervisor_ptr->version,
&app_ptr->id,
&app_ptr->name,
&running,
@ -1078,6 +1081,7 @@ SIGNAL_ARGS_BEGIN(AppRemoved, "")
SIGNAL_ARGS_END
SIGNAL_ARGS_BEGIN(AppStateChanged, "")
SIGNAL_ARG_DESCRIBE("new_list_version", DBUS_TYPE_UINT64_AS_STRING, "")
SIGNAL_ARG_DESCRIBE("id", DBUS_TYPE_UINT64_AS_STRING, "")
SIGNAL_ARG_DESCRIBE("name", DBUS_TYPE_STRING_AS_STRING, "")
SIGNAL_ARG_DESCRIBE("running", DBUS_TYPE_BOOLEAN_AS_STRING, "")

View File

@ -108,6 +108,7 @@ static void on_app_removed(void * context, DBusMessage * message_ptr)
static void on_app_state_changed(void * context, DBusMessage * message_ptr)
{
uint64_t new_list_version;
uint64_t id;
const char * name;
dbus_bool_t running;
@ -117,6 +118,7 @@ static void on_app_state_changed(void * context, DBusMessage * message_ptr)
if (!dbus_message_get_args(
message_ptr,
&g_dbus_error,
DBUS_TYPE_UINT64, &new_list_version,
DBUS_TYPE_UINT64, &id,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_BOOLEAN, &running,
@ -130,7 +132,15 @@ static void on_app_state_changed(void * context, DBusMessage * message_ptr)
}
//log_info("AppStateChanged signal received");
proxy_ptr->app_state_changed(proxy_ptr->context, id, name, running, terminal, level);
//log_info("AppRemoved signal received, id=%"PRIu64, id);
if (new_list_version <= proxy_ptr->version)
{
log_info("Ignoring signal for older version of the app list");
}
else
{
proxy_ptr->app_state_changed(proxy_ptr->context, id, name, running, terminal, level);
}
}
#undef proxy_ptr