Add support for setting remember state
authorMarcel Holtmann <marcel@holtmann.org>
Wed, 7 Jan 2009 01:21:23 +0000 (02:21 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Wed, 7 Jan 2009 01:21:23 +0000 (02:21 +0100)
include/network.h
src/network.c

index 5c62502..7f32c3c 100644 (file)
@@ -71,6 +71,8 @@ extern int connman_network_set_available(struct connman_network *network,
                                                connman_bool_t available);
 extern int connman_network_set_connected(struct connman_network *network,
                                                connman_bool_t connected);
+extern int connman_network_set_remember(struct connman_network *network,
+                                               connman_bool_t remember);
 extern connman_bool_t connman_network_get_remember(struct connman_network *network);
 
 extern int connman_network_connect(struct connman_network *network);
index 59c3e47..e918b7a 100644 (file)
@@ -648,6 +648,49 @@ int connman_network_set_connected(struct connman_network *network,
 }
 
 /**
+ * connman_network_set_remember:
+ * @network: network structure
+ * @remember: remember state
+ *
+ * Change remember state of network (known networks)
+ */
+int connman_network_set_remember(struct connman_network *network,
+                                               connman_bool_t remember)
+{
+       DBusMessage *signal;
+       DBusMessageIter entry, value;
+       const char *key = "Remember";
+
+       DBG("network %p remember %d", network, remember);
+
+       if (network->remember == remember)
+               return -EALREADY;
+
+       network->remember = remember;
+
+       if (network->registered == FALSE)
+               return 0;
+
+       signal = dbus_message_new_signal(network->element.path,
+                               CONNMAN_NETWORK_INTERFACE, "PropertyChanged");
+       if (signal == NULL)
+               return 0;
+
+       dbus_message_iter_init_append(signal, &entry);
+
+       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &key);
+
+       dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
+                                       DBUS_TYPE_BOOLEAN_AS_STRING, &value);
+       dbus_message_iter_append_basic(&value, DBUS_TYPE_BOOLEAN, &remember);
+       dbus_message_iter_close_container(&entry, &value);
+
+       g_dbus_send_message(connection, signal);
+
+       return 0;
+}
+
+/**
  * connman_network_get_remember:
  * @network: network structure
  *