Skip to content

Commit

Permalink
[ril] Cell info consumer can unsubscribe from updates. JB#50608
Browse files Browse the repository at this point in the history
Add a new org.nemomobile.ofono.CellInfo.Unsubscribe method. If it is called
ofono excludes the client from cell info consumers. The updates will be
disabled if no one client left.
  • Loading branch information
d-grigorev committed May 28, 2021
1 parent 297926e commit c01dc63
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ofono/plugins/sailfish_manager/sailfish_cell_info_dbus.c
Expand Up @@ -43,6 +43,7 @@ struct sailfish_cell_info_dbus {
#define CELL_INFO_DBUS_INTERFACE "org.nemomobile.ofono.CellInfo"
#define CELL_INFO_DBUS_CELLS_ADDED_SIGNAL "CellsAdded"
#define CELL_INFO_DBUS_CELLS_REMOVED_SIGNAL "CellsRemoved"
#define CELL_INFO_DBUS_UNSUBSCRIBED_SIGNAL "Unsubscribed"

#define CELL_DBUS_INTERFACE_VERSION (1)
#define CELL_DBUS_INTERFACE "org.nemomobile.ofono.Cell"
Expand Down Expand Up @@ -522,10 +523,32 @@ static DBusMessage *sailfish_cell_info_dbus_get_cells(DBusConnection *conn,
return __ofono_error_access_denied(msg);
}

static DBusMessage *sailfish_cell_info_dbus_unsubscribe(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct sailfish_cell_info_dbus *dbus = data;
struct sailfish_dbus_client *client;

DBG("");
client = sailfish_dbus_clients_lookup_client(dbus->clients, msg);
if (client) {
DBusMessage *signal = dbus_message_new_signal(
dbus_message_get_path(msg),
CELL_INFO_DBUS_INTERFACE,
CELL_INFO_DBUS_UNSUBSCRIBED_SIGNAL);
sailfish_dbus_clients_send_to(client, signal);
sailfish_dbus_clients_remove_client(client);
return dbus_message_new_method_return(msg);
}
return __ofono_error_access_denied(msg);
}

static const GDBusMethodTable sailfish_cell_info_dbus_methods[] = {
{ GDBUS_METHOD("GetCells", NULL,
GDBUS_ARGS({ "paths", "ao" }),
sailfish_cell_info_dbus_get_cells) },
{ GDBUS_METHOD("Unsubscribe", NULL, NULL,
sailfish_cell_info_dbus_unsubscribe) },
{ }
};

Expand Down

0 comments on commit c01dc63

Please sign in to comment.