+static gboolean context_added(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ const char *path = dbus_message_get_path(message);
+ const char *network_path;
+ struct modem_data *modem;
+ DBusMessageIter iter, properties;
+
+ DBG("path %s", path);
+
+ modem = g_hash_table_lookup(modem_hash, path);
+ if (modem == NULL || modem->device == NULL)
+ return TRUE;
+
+ if (dbus_message_iter_init(message, &iter) == FALSE)
+ return TRUE;
+
+ dbus_message_iter_get_basic(&iter, &network_path);
+
+ dbus_message_iter_next(&iter);
+ dbus_message_iter_recurse(&iter, &properties);
+
+ add_network(modem->device, network_path, &properties);
+
+ return TRUE;
+}
+
+static gboolean context_removed(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ const char *path = dbus_message_get_path(message);
+ const char *network_path, *identifier;
+ struct modem_data *modem;
+ struct connman_network *network;
+ DBusMessageIter iter;
+
+ DBG("path %s", path);
+
+ modem = g_hash_table_lookup(modem_hash, path);
+ if (modem == NULL || modem->device == NULL)
+ return TRUE;
+
+ if (dbus_message_iter_init(message, &iter) == FALSE)
+ return TRUE;
+
+ dbus_message_iter_get_basic(&iter, &network_path);
+
+ network = g_hash_table_lookup(network_hash, network_path);
+ if (network == NULL)
+ return TRUE;
+
+ identifier = connman_network_get_identifier(network);
+ connman_device_remove_network(modem->device, identifier);
+
+ return TRUE;
+}
+