* [PATCH] network: Add NetworkRegistration.OperatorsChanged signal
@ 2014-12-31 13:24 Slava Monich
2015-01-13 5:29 ` Denis Kenzior
0 siblings, 1 reply; 2+ messages in thread
From: Slava Monich @ 2014-12-31 13:24 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3687 bytes --]
This signal gets emitted when operator list has changed.
It contains the current list of operators.
---
doc/network-api.txt | 5 +++++
src/network.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/doc/network-api.txt b/doc/network-api.txt
index 83a2bc0..d635ba7 100644
--- a/doc/network-api.txt
+++ b/doc/network-api.txt
@@ -57,6 +57,11 @@ Signals PropertyChanged(string property, variant value)
This signal indicates a changed value of the given
property.
+ OperatorsChanged(array{object,dict})
+
+ Signal that gets emitted when operator list has
+ changed. It contains the current list of operators.
+
Properties string Mode [readonly]
The current registration mode. The default of this
diff --git a/src/network.c b/src/network.c
index d1bfca6..1b8b759 100644
--- a/src/network.c
+++ b/src/network.c
@@ -934,6 +934,40 @@ static void append_operator_struct_list(struct ofono_netreg *netreg,
dbus_free_string_array(children);
}
+static void network_signal_operators_changed(struct ofono_netreg *netreg)
+{
+ const char *path = __ofono_atom_get_path(netreg->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+ DBusMessage *signal;
+ DBusMessageIter iter;
+ DBusMessageIter array;
+
+ signal = dbus_message_new_signal(path,
+ OFONO_NETWORK_REGISTRATION_INTERFACE, "OperatorsChanged");
+ if (signal == NULL) {
+ ofono_error("Unable to allocate new "
+ OFONO_NETWORK_REGISTRATION_INTERFACE
+ ".OperatorsChanged signal");
+ return;
+ }
+
+ dbus_message_iter_init_append(signal, &iter);
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ DBUS_STRUCT_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_OBJECT_PATH_AS_STRING
+ DBUS_TYPE_ARRAY_AS_STRING
+ DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+ DBUS_TYPE_STRING_AS_STRING
+ DBUS_TYPE_VARIANT_AS_STRING
+ DBUS_DICT_ENTRY_END_CHAR_AS_STRING
+ DBUS_STRUCT_END_CHAR_AS_STRING,
+ &array);
+ append_operator_struct_list(netreg, &array);
+ dbus_message_iter_close_container(&iter, &array);
+
+ g_dbus_send_message(conn, signal);
+}
+
static void operator_list_callback(const struct ofono_error *error, int total,
const struct ofono_network_operator *list,
void *data)
@@ -942,6 +976,7 @@ static void operator_list_callback(const struct ofono_error *error, int total,
DBusMessage *reply;
DBusMessageIter iter;
DBusMessageIter array;
+ gboolean changed;
if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
DBG("Error occurred during operator list");
@@ -950,7 +985,7 @@ static void operator_list_callback(const struct ofono_error *error, int total,
return;
}
- update_operator_list(netreg, total, list);
+ changed = update_operator_list(netreg, total, list);
reply = dbus_message_new_method_return(netreg->pending);
@@ -970,6 +1005,11 @@ static void operator_list_callback(const struct ofono_error *error, int total,
dbus_message_iter_close_container(&iter, &array);
__ofono_dbus_pending_reply(&netreg->pending, reply);
+
+ DBG("operator list %schanged", changed ? "" : "not ");
+
+ if (changed)
+ network_signal_operators_changed(netreg);
}
static DBusMessage *network_scan(DBusConnection *conn,
@@ -1041,6 +1081,8 @@ static const GDBusMethodTable network_registration_methods[] = {
static const GDBusSignalTable network_registration_signals[] = {
{ GDBUS_SIGNAL("PropertyChanged",
GDBUS_ARGS({ "name", "s" }, { "value", "v" })) },
+ { GDBUS_SIGNAL("OperatorsChanged",
+ GDBUS_ARGS({ "operators", "a(oa{sv})"})) },
{ }
};
--
1.8.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] network: Add NetworkRegistration.OperatorsChanged signal
2014-12-31 13:24 [PATCH] network: Add NetworkRegistration.OperatorsChanged signal Slava Monich
@ 2015-01-13 5:29 ` Denis Kenzior
0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2015-01-13 5:29 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1656 bytes --]
Hi Slava,
On 12/31/2014 07:24 AM, Slava Monich wrote:
> This signal gets emitted when operator list has changed.
> It contains the current list of operators.
> ---
> doc/network-api.txt | 5 +++++
> src/network.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
> 2 files changed, 48 insertions(+), 1 deletion(-)
>
Please refer to HACKING, 'Submitting patches' section, item 3.
3) Split your patch according to the top-level directories. E.g.: if you
added
a feature that touches files under 'include/', 'src/' and 'drivers/'
directories, split in three separated patches, taking care not to
break compilation.
> diff --git a/doc/network-api.txt b/doc/network-api.txt
> index 83a2bc0..d635ba7 100644
> --- a/doc/network-api.txt
> +++ b/doc/network-api.txt
> @@ -57,6 +57,11 @@ Signals PropertyChanged(string property, variant value)
> This signal indicates a changed value of the given
> property.
>
> + OperatorsChanged(array{object,dict})
> +
> + Signal that gets emitted when operator list has
> + changed. It contains the current list of operators.
> +
I support the spirit of this change. However, it is really not
consistent with the other APIs of this sort. For example:
Manager.ModemAdded, Manager.ModemRemoved
MessageManager.MessageAdded, MessageManager.MessageRemoved
ConnectionManager.ContextAdded, ConnectionManager.ContextRemoved
The name is also a bit misleading, since certain attribute changes are
not tracked by update_operator_list...
I think it would be better if we introduced OperatorAdded and
OperatorRemoved signals instead.
Regards,
-Denis
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-13 5:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-31 13:24 [PATCH] network: Add NetworkRegistration.OperatorsChanged signal Slava Monich
2015-01-13 5:29 ` Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.