+#include "dummy.h"
+
+static
+void destroy_private_dummy_data(struct dummy *dummy)
+{
+ if (dummy->iterators) {
+ g_ptr_array_free(dummy->iterators, TRUE);
+ }
+ g_free(dummy);
+}
+
+void dummy_destroy(struct bt_component *component)
+{
+ struct dummy *dummy;
+
+ assert(component);
+ dummy = bt_component_get_private_data(component);
+ assert(dummy);
+ destroy_private_dummy_data(dummy);
+}
+
+enum bt_component_status dummy_init(struct bt_component *component,
+ struct bt_value *params, UNUSED_VAR void *init_method_data)
+{
+ enum bt_component_status ret;
+ struct dummy *dummy = g_new0(struct dummy, 1);
+
+ if (!dummy) {
+ ret = BT_COMPONENT_STATUS_NOMEM;
+ goto end;
+ }
+
+ dummy->iterators = g_ptr_array_new_with_free_func(
+ (GDestroyNotify) bt_put);
+ if (!dummy->iterators) {
+ ret = BT_COMPONENT_STATUS_NOMEM;
+ goto end;
+ }
+
+ ret = bt_component_set_private_data(component, dummy);
+ if (ret != BT_COMPONENT_STATUS_OK) {
+ goto error;
+ }
+end:
+ return ret;
+error:
+ destroy_private_dummy_data(dummy);
+ return ret;
+}
+
+enum bt_component_status dummy_new_connection(struct bt_port *own_port,
+ struct bt_connection *connection)
+{
+ enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
+ struct bt_component *component;
+ struct dummy *dummy;
+ struct bt_notification_iterator *iterator;
+
+ component = bt_port_get_component(own_port);
+ assert(component);
+
+ dummy = bt_component_get_private_data(component);
+ assert(dummy);
+
+ iterator = bt_connection_create_notification_iterator(connection);
+ if (!iterator) {
+ ret = BT_COMPONENT_STATUS_ERROR;
+ goto end;
+ }
+
+ g_ptr_array_add(dummy->iterators, iterator);
+end:
+ bt_put(component);
+ return ret;
+}