};
struct near_adapter * __near_adapter_create(uint32_t idx,
- const char *name, uint32_t protocols)
+ const char *name, uint32_t protocols, near_bool_t powered)
{
struct near_adapter *adapter;
}
adapter->idx = idx;
adapter->protocols = protocols;
- adapter->powered = TRUE;
+ adapter->powered = powered;
adapter->targets = g_hash_table_new_full(g_direct_hash, g_direct_equal,
NULL, free_target);
adapter->sock = -1;
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
-int __near_manager_adapter_add(uint32_t idx, const char *name, uint32_t protocols)
+int __near_manager_adapter_add(uint32_t idx, const char *name,
+ uint32_t protocols, near_bool_t powered)
{
struct near_adapter *adapter;
const char *path;
DBG("idx %d", idx);
- adapter = __near_adapter_create(idx, name, protocols);
+ adapter = __near_adapter_create(idx, name, protocols, powered);
if (adapter == NULL)
return -ENOMEM;
DBusMessage *__near_error_invalid_service(DBusMessage *msg);
DBusMessage *__near_error_invalid_property(DBusMessage *msg);
-int __near_manager_adapter_add(uint32_t idx, const char *name, uint32_t protocols);
+int __near_manager_adapter_add(uint32_t idx, const char *name,
+ uint32_t protocols, near_bool_t powered);
void __near_manager_adapter_remove(uint32_t idx);
int __near_manager_init(DBusConnection *conn);
void __near_manager_cleanup(void);
#include <near/adapter.h>
struct near_adapter * __near_adapter_create(uint32_t idx,
- const char *name, uint32_t protocols);
+ const char *name, uint32_t protocols, near_bool_t powered);
void __near_adapter_destroy(struct near_adapter *adapter);
const char *__near_adapter_get_path(struct near_adapter *adapter);
struct near_adapter *__near_adapter_get(uint32_t idx);
struct nlattr *attrs[NFC_ATTR_MAX + 1];
char *name;
uint32_t idx, protocols;
+ near_bool_t powered;
DBG("");
return NL_STOP;
}
+
idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]);
name = nla_get_string(attrs[NFC_ATTR_DEVICE_NAME]);
protocols = nla_get_u32(attrs[NFC_ATTR_PROTOCOLS]);
- __near_manager_adapter_add(idx, name, protocols);
+ if (attrs[NFC_ATTR_DEVICE_INDEX] == NULL)
+ powered = FALSE;
+ else
+ powered = nla_get_u8(attrs[NFC_ATTR_DEVICE_POWERED]);
+
+ __near_manager_adapter_add(idx, name, protocols, powered);
return NL_SKIP;
}
if (add == TRUE) {
char *name;
uint32_t protocols;
+ near_bool_t powered;
name = nla_get_string(attrs[NFC_ATTR_DEVICE_NAME]);
protocols = nla_get_u32(attrs[NFC_ATTR_PROTOCOLS]);
+ if (attrs[NFC_ATTR_DEVICE_POWERED] == NULL)
+ powered = FALSE;
+ else
+ powered = nla_get_u8(attrs[NFC_ATTR_DEVICE_POWERED]);
- return __near_manager_adapter_add(idx, name, protocols);
+ return __near_manager_adapter_add(idx, name,
+ protocols, powered);
} else {
__near_manager_adapter_remove(idx);
}