Skip to content

Commit

Permalink
[plugins] Added org.sailfishos.nfc.Tag.Removed signal
Browse files Browse the repository at this point in the history
It replaces PresentChanged signal which was never issued in the
first place (DBusServiceTag was getting deleted before it had a
chance to issue this signal), so this can't really be considered
an API break. Still, the interface version is bumped, so that
support for the new signal could be determined at runtime by
those clients which depend on it.

The new Removed signal is always issued when DBusServiceTag is
deleted. This way, D-Bus client won't have to watch the adapter
too in order to be notified when the tag is gone.
  • Loading branch information
monich committed Jul 30, 2019
1 parent d3de246 commit f7c2524
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
29 changes: 6 additions & 23 deletions plugins/dbus_service/dbus_service_tag.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2018 Jolla Ltd.
* Copyright (C) 2018 Slava Monich <slava.monich@jolla.com>
* Copyright (C) 2018-2019 Jolla Ltd.
* Copyright (C) 2018-2019 Slava Monich <slava.monich@jolla.com>
*
* You may use this file under the terms of BSD license as follows:
*
Expand All @@ -14,8 +14,8 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Expand Down Expand Up @@ -43,7 +43,6 @@

enum {
EVENT_INITIALIZED,
EVENT_GONE,
EVENT_COUNT
};

Expand Down Expand Up @@ -93,7 +92,7 @@ struct dbus_service_tag {
};

#define NFC_DBUS_TAG_INTERFACE "org.sailfishos.nfc.Tag"
#define NFC_DBUS_TAG_INTERFACE_VERSION (1)
#define NFC_DBUS_TAG_INTERFACE_VERSION (2)

static const char* const dbus_service_tag_default_interfaces[] = {
NFC_DBUS_TAG_INTERFACE, NULL
Expand Down Expand Up @@ -259,18 +258,6 @@ dbus_service_tag_initialized(
dbus_service_tag_complete_pending_calls(self);
}

static
void
dbus_service_tag_gone(
NfcTag* tag,
void* user_data)
{
DBusServiceTag* self = user_data;

GASSERT(!tag->present);
org_sailfishos_nfc_tag_emit_present_changed(self->iface, tag->present);
}

/*==========================================================================*
* D-Bus calls
*==========================================================================*/
Expand Down Expand Up @@ -496,11 +483,6 @@ dbus_service_tag_new(
self->pool = gutil_idle_pool_new();
self->iface = org_sailfishos_nfc_tag_skeleton_new();

/* NfcTag events */
self->event_id[EVENT_GONE] =
nfc_tag_add_gone_handler(tag,
dbus_service_tag_gone, self);

/* D-Bus calls */
self->call_id[CALL_GET_ALL] =
g_signal_connect(self->iface, "handle-get-all",
Expand Down Expand Up @@ -556,6 +538,7 @@ dbus_service_tag_free(
{
if (self) {
GDEBUG("Removing D-Bus object %s", self->path);
org_sailfishos_nfc_tag_emit_removed(self->iface);
g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON
(self->iface));
dbus_service_tag_free_unexported(self);
Expand Down
4 changes: 1 addition & 3 deletions plugins/dbus_service/org.sailfishos.nfc.Tag.xml
Expand Up @@ -54,8 +54,6 @@
</method>
<method name="Deactivate"/>
<!-- Signals -->
<signal name="PresentChanged">
<arg name="present" type="b"/>
</signal>
<signal name="Removed"/>
</interface>
</node>

0 comments on commit f7c2524

Please sign in to comment.