--interface-prefix org.neard.Adapter \
$<
-neard_target_proxy.h: interface/org.neard.Target.xml
- gdbus-codegen --generate-c-code neard_target_proxy \
- --c-namespace orgNeardTgt \
- --interface-prefix org.neard.Target \
+neard_tag_proxy.h: interface/org.neard.Tag.xml
+ gdbus-codegen --generate-c-code neard_tag_proxy \
+ --c-namespace orgNeardTag \
+ --interface-prefix org.neard.Tag \
$<
neard_record_proxy.h: interface/org.neard.Record.xml
BUILT_SOURCES = neard_manager_proxy.h \
neard_adapter_proxy.h \
- neard_target_proxy.h \
+ neard_tag_proxy.h \
neard_record_proxy.h
neardal_PRV_HDR = \
neardal_manager.h \
neardal_prv.h \
neardal_record.h \
- neardal_target.h \
+ neardal_tag.h \
neardal_traces_prv.h \
neardal_tools.h
neard_manager_proxy.c \
neardal_record.c \
neard_record_proxy.c \
- neardal_target.c \
- neard_target_proxy.c \
+ neardal_tag.c \
+ neard_tag_proxy.c \
neardal_tools.c \
neardal_traces.c
</method>
<method name="StartPoll"/>
<method name="StopPoll"/>
- <method name="Publish">
- <arg type="a{sv}" direction="in"/>
- </method>
<signal name="PropertyChanged">
<arg type="s"/>
<arg type="v"/>
</signal>
- <signal name="TargetFound">
+ <signal name="TagFound">
<arg type="o"/>
</signal>
- <signal name="TargetLost">
+ <signal name="TagLost">
<arg type="o"/>
</signal>
</interface>
+ <node name="tag0"/>
</node>
<node>
<interface name="org.neard.Record">
<method name="GetProperties">
- <arg type="a{sv}" direction="out"/>
+ <arg type="a{sv}" direction="out"/>
</method>
</interface>
</node>
-
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
- <interface name="org.neard.Target">
+ <interface name="org.neard.Tag">
<method name="GetProperties">
- <arg type="a{sv}" direction="out"/>
+ <arg type="a{sv}" direction="out"/>
</method>
<method name="SetProperty">
<arg type="s" direction="in"/>
<arg type="v" direction="in"/>
</method>
+ <method name="Write">
+ <arg type="a{sv}" direction="in"/>
+ </method>
<signal name="PropertyChanged">
<arg type="s"/>
<arg type="v"/>
</signal>
</interface>
+ <node name="record0"/>
</node>
-
#include "neardal.h"
#include "neardal_prv.h"
-#include <glib-2.0/glib/glist.h>
-#include <glib-2.0/glib/gerror.h>
-
neardalCtx neardalMgr = {NULL, NULL, {NULL}, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL};
* 'NEARDAL adapter added'.
* cb_adp_added = NULL to remove actual callback.
*****************************************************************************/
-errorCode_t neardal_set_cb_target_found(target_cb cb_tgt_found,
+errorCode_t neardal_set_cb_tag_found(tag_cb cb_tag_found,
void *user_data)
{
- neardalMgr.cb_tgt_found = cb_tgt_found;
- neardalMgr.cb_tgt_found_ud = user_data;
+ neardalMgr.cb_tag_found = cb_tag_found;
+ neardalMgr.cb_tag_found_ud = user_data;
return NEARDAL_SUCCESS;
}
* 'NEARDAL adapter added'.
* cb_adp_removed = NULL to remove actual callback.
*****************************************************************************/
-errorCode_t neardal_set_cb_target_lost(target_cb cb_tgt_lost,
+errorCode_t neardal_set_cb_tag_lost(tag_cb cb_tag_lost,
void *user_data)
{
- neardalMgr.cb_tgt_lost = cb_tgt_lost;
- neardalMgr.cb_tgt_lost_ud = user_data;
+ neardalMgr.cb_tag_lost = cb_tag_lost;
+ neardalMgr.cb_tag_lost_ud = user_data;
return NEARDAL_SUCCESS;
}
/******************************************************************************
* neardal_set_cb_record_found: setup a client callback for
- * 'NEARDAL target record found'.
+ * 'NEARDAL tag record found'.
* cb_rcd_found = NULL to remove actual callback.
*****************************************************************************/
errorCode_t neardal_set_cb_record_found(record_cb cb_rcd_found,
}
/******************************************************************************
- * neardal_free_array: free adapters array, targets array or records array
+ * neardal_free_array: free adapters array, tags array or records array
*****************************************************************************/
errorCode_t neardal_free_array(char ***array)
{
{
errorCode_t err = NEARDAL_SUCCESS;
AdpProp *adpProp = NULL;
- TgtProp *target = NULL;
+ TagProp *tag = NULL;
int ct = 0; /* counter */
gsize size;
}
}
- adapter->nbTargets = (int) adpProp->tgtNb;
- adapter->targets = NULL;
- if (adapter->nbTargets <= 0)
+ adapter->nbTags = (int) adpProp->tagNb;
+ adapter->tags = NULL;
+ if (adapter->nbTags <= 0)
goto exit;
err = NEARDAL_ERROR_NO_MEMORY;
- size = (adapter->nbTargets + 1) * sizeof(char *);
- adapter->targets = g_try_malloc0(size);
- if (adapter->targets == NULL)
+ size = (adapter->nbTags + 1) * sizeof(char *);
+ adapter->tags = g_try_malloc0(size);
+ if (adapter->tags == NULL)
goto exit;
ct = 0;
- while (ct < adapter->nbTargets) {
- target = g_list_nth_data(adpProp->tgtList, ct);
- if (target != NULL)
- adapter->targets[ct++] = g_strdup(target->name);
+ while (ct < adapter->nbTags) {
+ tag = g_list_nth_data(adpProp->tagList, ct);
+ if (tag != NULL)
+ adapter->tags[ct++] = g_strdup(tag->name);
}
err = NEARDAL_SUCCESS;
/******************************************************************************
* neardal_get_adapter_properties: Get properties of a specific NEARDAL adapter
*****************************************************************************/
-errorCode_t neardal_get_target_properties(const char *tgtName,
- neardal_target *target)
+errorCode_t neardal_get_tag_properties(const char *tagName,
+ neardal_tag *tag)
{
errorCode_t err = NEARDAL_SUCCESS;
AdpProp *adpProp = NULL;
- TgtProp *tgtProp = NULL;
+ TagProp *tagProp = NULL;
int ct = 0; /* counter */
RcdProp *record = NULL;
gsize size;
if (neardalMgr.proxy == NULL)
neardal_prv_construct(&err);
- if (err != NEARDAL_SUCCESS || tgtName == NULL || target == NULL)
+ if (err != NEARDAL_SUCCESS || tagName == NULL || tag == NULL)
goto exit;
- target->records = NULL;
- target->tagType = NULL;
- err = neardal_mgr_prv_get_adapter((gchar *) tgtName, &adpProp);
+ tag->records = NULL;
+ tag->tagType = NULL;
+ err = neardal_mgr_prv_get_adapter((gchar *) tagName, &adpProp);
if (err != NEARDAL_SUCCESS)
goto exit;
- err = neardal_mgr_prv_get_target(adpProp, (gchar *) tgtName, &tgtProp);
+ err = neardal_mgr_prv_get_tag(adpProp, (gchar *) tagName, &tagProp);
if (err != NEARDAL_SUCCESS)
goto exit;
- target->name = (const char *) tgtProp->name;
- target->type = (const char *) tgtProp->type;
- target->readOnly = (short) tgtProp->readOnly;
- target->nbRecords = (int) tgtProp->rcdLen;
- if (target->nbRecords > 0) {
+ tag->name = (const char *) tagProp->name;
+ tag->type = (const char *) tagProp->type;
+ tag->readOnly = (short) tagProp->readOnly;
+ tag->nbRecords = (int) tagProp->rcdLen;
+ if (tag->nbRecords > 0) {
err = NEARDAL_ERROR_NO_MEMORY;
- size = (target->nbRecords + 1) * sizeof(char *);
- target->records = g_try_malloc0(size);
- if (target->records == NULL)
+ size = (tag->nbRecords + 1) * sizeof(char *);
+ tag->records = g_try_malloc0(size);
+ if (tag->records == NULL)
goto exit;
ct = 0;
- while (ct < target->nbRecords) {
- record = g_list_nth_data(tgtProp->rcdList, ct);
+ while (ct < tag->nbRecords) {
+ record = g_list_nth_data(tagProp->rcdList, ct);
if (record != NULL)
- target->records[ct++] = g_strdup(record->name);
+ tag->records[ct++] = g_strdup(record->name);
}
err = NEARDAL_SUCCESS;
}
- target->nbTagTypes = 0;
- target->tagType = NULL;
+ tag->nbTagTypes = 0;
+ tag->tagType = NULL;
/* Count TagTypes */
- target->nbTagTypes = (int) tgtProp->tagTypeLen;
+ tag->nbTagTypes = (int) tagProp->tagTypeLen;
- if (target->nbTagTypes <= 0)
+ if (tag->nbTagTypes <= 0)
goto exit;
err = NEARDAL_ERROR_NO_MEMORY;
- size = (target->nbTagTypes + 1) * sizeof(char *);
- target->tagType = g_try_malloc0(size);
- if (target->tagType == NULL)
+ size = (tag->nbTagTypes + 1) * sizeof(char *);
+ tag->tagType = g_try_malloc0(size);
+ if (tag->tagType == NULL)
goto exit;
ct = 0;
- while (ct < target->nbTagTypes) {
- target->tagType[ct] = g_strdup(tgtProp->tagType[ct]);
+ while (ct < tag->nbTagTypes) {
+ tag->tagType[ct] = g_strdup(tagProp->tagType[ct]);
ct++;
}
err = NEARDAL_SUCCESS;
}
/******************************************************************************
- * neardal_get_record_properties: Get values of a specific target record
+ * neardal_get_record_properties: Get values of a specific tag record
*****************************************************************************/
errorCode_t neardal_get_record_properties(const char *recordName,
neardal_record *record)
{
errorCode_t err = NEARDAL_SUCCESS;
AdpProp *adpProp = NULL;
- TgtProp *tgtProp = NULL;
+ TagProp *tagProp = NULL;
RcdProp *rcdProp = NULL;
if (recordName == NULL || record == NULL)
if (err != NEARDAL_SUCCESS)
goto exit;
- err = neardal_mgr_prv_get_target(adpProp, (gchar *) recordName,
- &tgtProp);
+ err = neardal_mgr_prv_get_tag(adpProp, (gchar *) recordName,
+ &tagProp);
if (err != NEARDAL_SUCCESS)
goto exit;
- err = neardal_mgr_prv_get_record(tgtProp, (gchar *) recordName,
+ err = neardal_mgr_prv_get_record(tagProp, (gchar *) recordName,
&rcdProp);
if (err != NEARDAL_SUCCESS)
goto exit;
/*! \brief Neard adapter supported protocols list (use @link
* neardal_free_array @endlink(& ) to free) */
char **protocols;
-/*! \brief Number of targets managed by this adapter */
- int nbTargets;
-/*! \brief Neard adapter targets list (use @link neardal_free_array @endlink
+/*! \brief Number of tags managed by this adapter */
+ int nbTags;
+/*! \brief Neard adapter tags list (use @link neardal_free_array @endlink
*(& ) to free) */
- char **targets;
+ char **tags;
} neardal_adapter;
/*!
- * @brief NEARDAL Target client properties.
+ * @brief NEARDAL Tag client properties.
*/
typedef struct {
-/*! @brief DBus interface target name (as identifier) */
+/*! @brief DBus interface tag name (as identifier) */
const char *name;
-/*! @brief Number of records in target */
+/*! @brief Number of records in tag */
int nbRecords;
-/*! @brief target records list (use @link neardal_free_array @endlink (& ) to
+/*! @brief tag records list (use @link neardal_free_array @endlink (& ) to
* free) */
char **records;
-/*! @brief Number of supported 'types' in target */
+/*! @brief Number of supported 'types' in tag */
int nbTagTypes;
/*! @brief types list (use @link neardal_free_array @endlink(& ) to free) */
char **tagType;
-/*! @brief target type */
+/*! @brief tag type */
const char *type;
-/*! @brief Read-Only flag (is target writable?) */
+/*! @brief Read-Only flag (is tag writable?) */
short readOnly;
-} neardal_target;
+} neardal_tag;
/*!
* @brief NEARDAL Record client properties.
typedef void (*adapter_prop_cb) (char *adpName, char *propName, void * value,
void *user_data);
-/** @brief NEARDAL Target Callbacks (TargetFound/Lost)
+/** @brief NEARDAL Tag Callbacks (TagFound/Lost)
*/
/**
- * @brief Callback prototype for 'NEARDAL target found/lost'
+ * @brief Callback prototype for 'NEARDAL tag found/lost'
*
- * @param tgtName DBus interface target name (as identifier)
+ * @param tagName DBus interface tag name (as identifier)
* @param user_data Client user data
**/
-typedef void (*target_cb) (const char *tgtName, void *user_data);
+typedef void (*tag_cb) (const char *tagName, void *user_data);
/** @brief NEARDAL Record Callbacks ('RecordFound')
*/
**/
errorCode_t neardal_get_adapters(char ***array, int *len);
-/*! \fn errorCode_t neardal_get_targets(char *adpName, char ***array, int *len)
- * @brief get an array of NEARDAL targets present
+/*! \fn errorCode_t neardal_get_tags(char *adpName, char ***array, int *len)
+ * @brief get an array of NEARDAL tags present
*
- * @param adpName adapter name (identifier) on which targets list must be
+ * @param adpName adapter name (identifier) on which tags list must be
* retrieve
- * @param array array of DBus interface target name (as identifier), use @link
+ * @param array array of DBus interface tag name (as identifier), use @link
* neardal_free_array @endlink(& ) to free
- * @param len (optional), number of targets
+ * @param len (optional), number of tags
* @return errorCode_t error code
**/
-errorCode_t neardal_get_targets(char *adpName, char ***array, int *len);
+errorCode_t neardal_get_tags(char *adpName, char ***array, int *len);
-/*! \fn errorCode_t neardal_get_records(char *tgtName, char ***array, int *len)
+/*! \fn errorCode_t neardal_get_records(char *tagName, char ***array, int *len)
* @brief get an array of NEARDAL records present
*
- * @param tgtName target name (identifier) on which records list must be
+ * @param tagName tag name (identifier) on which records list must be
* retrieve
* @param array array of DBus interface record name (as identifier), use @link
* neardal_free_array @endlink(& ) to free
* @param len (optional), number of records
* @return errorCode_t error code
**/
-errorCode_t neardal_get_records(char *tgtName, char ***array, int *len);
+errorCode_t neardal_get_records(char *tagName, char ***array, int *len);
/*! @fn errorCode_t neardal_free_array(char ***array)
*
- * @brief free memory used for adapters array, targets array or records array
+ * @brief free memory used for adapters array, tags array or records array
*
- * @param array adapters array, targets array or records array
+ * @param array adapters array, tags array or records array
* @return errorCode_t error code
*
**/
adapter_prop_cb cb_adp_property_changed,
void *user_data);
-/*! \fn errorCode_t neardal_get_target_properties(const char* tgtName,
- * neardal_target *target)
- * @brief Get properties of a specific NEARDAL target
+/*! \fn errorCode_t neardal_get_tag_properties(const char* tagName,
+ * neardal_tag *tag)
+ * @brief Get properties of a specific NEARDAL tag
*
- * @param tgtName target name (identifier) on which properties must be retrieve
- * @param target Pointer on client target struct to store datas
+ * @param tagName tag name (identifier) on which properties must be retrieve
+ * @param tag Pointer on client tag struct to store datas
* @return errorCode_t error code
**/
-errorCode_t neardal_get_target_properties(const char *tgtName,
- neardal_target *target);
+errorCode_t neardal_get_tag_properties(const char *tagName,
+ neardal_tag *tag);
-/*! \fn errorCode_t neardal_set_cb_target_found(target_cb cb_tgt_found,
+/*! \fn errorCode_t neardal_set_cb_tag_found(tag_cb cb_tag_found,
* void * user_data)
- * @brief setup a client callback for 'NEARDAL target found'.
- * cb_tgt_found = NULL to remove actual callback.
+ * @brief setup a client callback for 'NEARDAL tag found'.
+ * cb_tag_found = NULL to remove actual callback.
*
- * @param cb_tgt_found Client callback 'target found'
+ * @param cb_tag_found Client callback 'tag found'
* @param user_data Client user data
* @return errorCode_t error code
**/
-errorCode_t neardal_set_cb_target_found(target_cb cb_tgt_found,
+errorCode_t neardal_set_cb_tag_found(tag_cb cb_tag_found,
void *user_data);
-/*! \fn errorCode_t neardal_set_cb_target_lost(target_cb cb_tgt_lost,
+/*! \fn errorCode_t neardal_set_cb_tag_lost(tag_cb cb_tag_lost,
* void * user_data)
- * @brief setup a client callback for 'NEARDAL target lost'.
- * cb_tgt_lost = NULL to remove actual callback.
+ * @brief setup a client callback for 'NEARDAL tag lost'.
+ * cb_tag_lost = NULL to remove actual callback.
*
- * @param cb_tgt_lost Client callback 'target lost'
+ * @param cb_tag_lost Client callback 'tag lost'
* @param user_data Client user data
* @return errorCode_t error code
**/
-errorCode_t neardal_set_cb_target_lost(target_cb cb_tgt_lost,
+errorCode_t neardal_set_cb_tag_lost(tag_cb cb_tag_lost,
void *user_data);
/*! \fn errorCode_t neardal_get_record_properties(const char *recordName,
* neardal_record *record)
- * @brief Get properties of a specific NEARDAL target record
+ * @brief Get properties of a specific NEARDAL tag record
*
* @param recordName DBus interface record name (as identifier)
* @param record Pointer on client record struct to store datas
/*! \fn errorCode_t neardal_set_cb_record_found( record_cb cb_rcd_found,
* void * user_data)
- * @brief Setup a client callback for 'NEARDAL target record found'.
+ * @brief Setup a client callback for 'NEARDAL tag record found'.
* cb_rcd_found = NULL to remove actual callback
*
* @param cb_rcd_found Client callback 'record found'
#include "neardal.h"
#include "neardal_prv.h"
-#include <glib-2.0/glib/gerror.h>
-#include <glib-2.0/glib/glist.h>
-#include <glib-2.0/glib/gvariant.h>
/******************************************************************************
- * neardal_adp_prv_cb_target_found: Callback called when a NFC target is
+ * neardal_adp_prv_cb_tag_found: Callback called when a NFC tag is
* found
*****************************************************************************/
-static void neardal_adp_prv_cb_target_found(orgNeardTgt *proxy,
+static void neardal_adp_prv_cb_tag_found(orgNeardTag *proxy,
const gchar *arg_unnamed_arg0,
void *user_data)
{
AdpProp *adpProp = user_data;
errorCode_t err;
- TgtProp *tgtProp;
+ TagProp *tagProp;
NEARDAL_TRACEIN();
(void) proxy; /* remove warning */
g_assert(arg_unnamed_arg0 != NULL);
g_assert(adpProp != NULL);
- NEARDAL_TRACEF("Adding target '%s'\n", arg_unnamed_arg0);
- /* Invoking Callback 'Target Found' before adding it (otherwise
+ NEARDAL_TRACEF("Adding tag '%s'\n", arg_unnamed_arg0);
+ /* Invoking Callback 'Tag Found' before adding it (otherwise
* callback 'Record Found' would be called before ) */
- err = neardal_tgt_add((char *) arg_unnamed_arg0, adpProp);
+ err = neardal_tag_add((char *) arg_unnamed_arg0, adpProp);
if (err == NEARDAL_SUCCESS) {
- tgtProp = g_list_nth_data(adpProp->tgtList, 0);
- neardal_tgt_notify_target_found(tgtProp);
+ tagProp = g_list_nth_data(adpProp->tagList, 0);
+ neardal_tag_notify_tag_found(tagProp);
}
- NEARDAL_TRACEF("NEARDAL LIB targetList contains %d elements\n",
- g_list_length(adpProp->tgtList));
+ NEARDAL_TRACEF("NEARDAL LIB tagList contains %d elements\n",
+ g_list_length(adpProp->tagList));
}
/******************************************************************************
- * neardal_adp_prv_cb_target_lost: Callback called when a NFC target is
+ * neardal_adp_prv_cb_tag_lost: Callback called when a NFC tag is
* lost (removed)
*****************************************************************************/
-static void neardal_adp_prv_cb_target_lost(orgNeardTgt *proxy,
+static void neardal_adp_prv_cb_tag_lost(orgNeardTag *proxy,
const gchar *arg_unnamed_arg0,
void *user_data)
{
AdpProp *adpProp = user_data;
- TgtProp *tgtProp = NULL;
+ TagProp *tagProp = NULL;
errorCode_t errCode;
NEARDAL_TRACEIN();
neardal_mgr_prv_get_adapter((char *) arg_unnamed_arg0, &adpProp);
- NEARDAL_TRACEF("Removing target '%s'\n", arg_unnamed_arg0);
- /* Invoking Callback 'Target Found' before adding it (otherwise
+ NEARDAL_TRACEF("Removing tag '%s'\n", arg_unnamed_arg0);
+ /* Invoking Callback 'Tag Found' before adding it (otherwise
* callback 'Record Found' would be called before ) */
- errCode = neardal_mgr_prv_get_target(adpProp, (char *) arg_unnamed_arg0,
- &tgtProp);
+ errCode = neardal_mgr_prv_get_tag(adpProp, (char *) arg_unnamed_arg0,
+ &tagProp);
if (errCode == NEARDAL_SUCCESS) {
- if (neardalMgr.cb_tgt_lost != NULL)
- (neardalMgr.cb_tgt_lost)((char *) arg_unnamed_arg0,
- neardalMgr.cb_tgt_lost_ud);
- neardal_tgt_remove(tgtProp);
- NEARDAL_TRACEF("NEARDAL LIB targetList contains %d elements\n",
- g_list_length(adpProp->tgtList));
+ if (neardalMgr.cb_tag_lost != NULL)
+ (neardalMgr.cb_tag_lost)((char *) arg_unnamed_arg0,
+ neardalMgr.cb_tag_lost_ud);
+ neardal_tag_remove(tagProp);
+ NEARDAL_TRACEF("NEARDAL LIB tagList contains %d elements\n",
+ g_list_length(adpProp->tagList));
}
}
/******************************************************************************
- * neardal_adp_prv_cb_property_changed: Callback called when a NFC target
+ * neardal_adp_prv_cb_property_changed: Callback called when a NFC tag
* is found
*****************************************************************************/
static void neardal_adp_prv_cb_property_changed(orgNeardAdp *proxy,
{
AdpProp *adpProp = NULL;
errorCode_t errCode = NEARDAL_ERROR_NO_TARGET;
- char *tgtName = NULL;
+ char *tagName = NULL;
void *clientValue = NULL;
- TgtProp *tgtProp = NULL;
+ TagProp *tagProp = NULL;
GVariant *tmp = NULL;
- gchar **tgtArray = NULL;
+ gchar **tagArray = NULL;
(void) proxy; /* remove warning */
(void) user_data; /* remove warning */
NEARDAL_TRACEF("neardalMgr.polling=%d\n", adpProp->polling);
}
- if (!strcmp(arg_unnamed_arg0, "Targets")) {
+ if (!strcmp(arg_unnamed_arg0, "Tags")) {
guint tmpLen;
- tgtArray = g_variant_dup_objv(tmp, &tmpLen);
- adpProp->tgtNb = tmpLen;
+ tagArray = g_variant_dup_objv(tmp, &tmpLen);
+ adpProp->tagNb = tmpLen;
if (tmpLen == 0) {
NEARDAL_TRACEF(
- "Target array empty! Removing all targets\n");
- while (tmpLen < g_list_length(adpProp->tgtList)) {
- tgtProp = g_list_nth_data(adpProp->tgtList,
+ "Tag array empty! Removing all tags\n");
+ while (tmpLen < g_list_length(adpProp->tagList)) {
+ tagProp = g_list_nth_data(adpProp->tagList,
tmpLen++);
- neardal_adp_prv_cb_target_lost(tgtProp->proxy,
- tgtProp->name,
- tgtProp->parent);
+ neardal_adp_prv_cb_tag_lost(tagProp->proxy,
+ tagProp->name,
+ tagProp->parent);
}
- g_strfreev(tgtArray);
+ g_strfreev(tagArray);
errCode = NEARDAL_SUCCESS;
goto exit;
}
- /* Extract the targets arrays List from the GValue */
+ /* Extract the tags arrays List from the GValue */
errCode = NEARDAL_ERROR_NO_ADAPTER;
tmpLen = 0;
- while (tmpLen < adpProp->tgtNb) {
- /* Getting last target (targets list not updated with
- * targets lost */
- tgtName = g_strdup(tgtArray[tmpLen++]);
+ while (tmpLen < adpProp->tagNb) {
+ /* Getting last tag (tags list not updated with
+ * tags lost */
+ tagName = g_strdup(tagArray[tmpLen++]);
- /* TODO : for Neard Workaround, emulate 'TargetFound'
+ /* TODO : for Neard Workaround, emulate 'TagFound'
* signals */
- errCode = neardal_mgr_prv_get_target(adpProp,
- tgtName,
- &tgtProp);
+ errCode = neardal_mgr_prv_get_tag(adpProp,
+ tagName,
+ &tagProp);
if (errCode == NEARDAL_ERROR_NO_TARGET) {
- neardal_adp_prv_cb_target_found(NULL,
- tgtName,
+ neardal_adp_prv_cb_tag_found(NULL,
+ tagName,
adpProp);
errCode = NEARDAL_SUCCESS;
}
}
- g_strfreev(tgtArray);
+ g_strfreev(tagArray);
}
if (neardalMgr.cb_adp_prop_changed != NULL)
GError *gerror = NULL;
GVariant *tmp = NULL;
GVariant *tmpOut = NULL;
- gchar **tgtArray = NULL;
+ gchar **tagArray = NULL;
gsize len;
NEARDAL_TRACEIN();
}
NEARDAL_TRACE_LOG("Reading:\n%s\n", g_variant_print(tmp, TRUE));
- tmpOut = g_variant_lookup_value(tmp, "Targets", G_VARIANT_TYPE_ARRAY);
+ tmpOut = g_variant_lookup_value(tmp, "Tags", G_VARIANT_TYPE_ARRAY);
if (tmpOut != NULL) {
- tgtArray = g_variant_dup_objv(tmpOut, &len);
- adpProp->tgtNb = len;
+ tagArray = g_variant_dup_objv(tmpOut, &len);
+ adpProp->tagNb = len;
if (len == 0) {
- g_strfreev(tgtArray);
- tgtArray = NULL;
+ g_strfreev(tagArray);
+ tagArray = NULL;
} else {
guint len = 0;
- char *tgtName;
+ char *tagName;
- while (len < adpProp->tgtNb &&
+ while (len < adpProp->tagNb &&
errCode == NEARDAL_SUCCESS) {
- tgtName = tgtArray[len++];
- errCode = neardal_tgt_add(tgtName, adpProp);
+ tagName = tagArray[len++];
+ errCode = neardal_tag_add(tagName, adpProp);
}
}
}
}
/******************************************************************************
- * neardal_adp_prv_get_current_target: Get current NFC target
+ * neardal_adp_prv_get_current_tag: Get current NFC tag
*****************************************************************************/
-errorCode_t neardal_adp_prv_get_target(AdpProp *adpProp, gchar *tgtName,
- TgtProp **tgtProp)
+errorCode_t neardal_adp_prv_get_tag(AdpProp *adpProp, gchar *tagName,
+ TagProp **tagProp)
{
errorCode_t errCode = NEARDAL_ERROR_NO_TARGET;
guint len = 0;
- TgtProp *tgt;
+ TagProp *tag;
g_assert(adpProp != NULL);
- g_assert(tgtProp != NULL);
+ g_assert(tagProp != NULL);
- while (len < g_list_length(adpProp->tgtList)) {
- tgt = g_list_nth_data(adpProp->tgtList, len);
- if (tgt != NULL) {
- if (!strncmp(tgt->name, tgtName, strlen(tgt->name))) {
- *tgtProp = tgt;
+ while (len < g_list_length(adpProp->tagList)) {
+ tag = g_list_nth_data(adpProp->tagList, len);
+ if (tag != NULL) {
+ if (!strncmp(tag->name, tagName, strlen(tag->name))) {
+ *tagProp = tag;
errCode = NEARDAL_SUCCESS;
break;
}
G_CALLBACK(neardal_adp_prv_cb_property_changed),
NULL);
g_signal_handlers_disconnect_by_func(adpProp->proxy,
- G_CALLBACK(neardal_adp_prv_cb_target_found),
+ G_CALLBACK(neardal_adp_prv_cb_tag_found),
NULL);
g_signal_handlers_disconnect_by_func(adpProp->proxy,
- G_CALLBACK(neardal_adp_prv_cb_target_lost),
+ G_CALLBACK(neardal_adp_prv_cb_tag_lost),
NULL);
g_object_unref(adpProp->proxy);
}
G_CALLBACK(neardal_adp_prv_cb_property_changed),
NULL);
- /* Register 'TargetFound', 'TargetLost' */
+ /* Register 'TagFound', 'TagLost' */
NEARDAL_TRACEF("Register Neard-Adapter Signal ");
- NEARDAL_TRACE("'TargetFound'\n");
+ NEARDAL_TRACE("'TagFound'\n");
g_signal_connect(adpProp->proxy, NEARD_ADP_SIG_TGT_FOUND,
- G_CALLBACK(neardal_adp_prv_cb_target_found),
+ G_CALLBACK(neardal_adp_prv_cb_tag_found),
adpProp);
NEARDAL_TRACEF("Register Neard-Adapter Signal ");
- NEARDAL_TRACE("'TargetLost'\n");
+ NEARDAL_TRACE("'TagLost'\n");
g_signal_connect(adpProp->proxy, NEARD_ADP_SIG_TGT_LOST,
- G_CALLBACK(neardal_adp_prv_cb_target_lost),
+ G_CALLBACK(neardal_adp_prv_cb_tag_lost),
adpProp);
return errCode;
G_CALLBACK(neardal_adp_prv_cb_property_changed),
NULL);
g_signal_handlers_disconnect_by_func((*adpProp)->proxy,
- G_CALLBACK(neardal_adp_prv_cb_target_found),
+ G_CALLBACK(neardal_adp_prv_cb_tag_found),
NULL);
g_signal_handlers_disconnect_by_func((*adpProp)->proxy,
- G_CALLBACK(neardal_adp_prv_cb_target_lost),
+ G_CALLBACK(neardal_adp_prv_cb_tag_lost),
NULL);
g_object_unref((*adpProp)->proxy);
(*adpProp)->proxy = NULL;
errorCode_t errCode = NEARDAL_SUCCESS;
AdpProp *adpProp = NULL;
GList **adpList;
- TgtProp *tgtProp;
+ TagProp *tagProp;
gsize len;
NEARDAL_TRACEF("Adding adapter:%s\n", adapterName);
(neardalMgr.cb_adp_added)((char *) adapterName,
neardalMgr.cb_adp_added_ud);
- /* Notify 'Target Found' */
+ /* Notify 'Tag Found' */
len = 0;
- while (len < g_list_length(adpProp->tgtList)) {
- tgtProp = g_list_nth_data(adpProp->tgtList, len++);
- neardal_tgt_notify_target_found(tgtProp);
+ while (len < g_list_length(adpProp->tagList)) {
+ tagProp = g_list_nth_data(adpProp->tagList, len++);
+ neardal_tag_notify_tag_found(tagProp);
len++;
}
return errCode;
*****************************************************************************/
errorCode_t neardal_adp_remove(AdpProp *adpProp)
{
- TgtProp *tgtProp;
+ TagProp *tagProp;
GList *node = NULL;
GList **adpList;
NEARDAL_TRACEF("Removing adapter:%s\n", adpProp->name);
- /* Remove all targets */
- while (g_list_length(adpProp->tgtList)) {
- node = g_list_first(adpProp->tgtList);
- tgtProp = (TgtProp *) node->data;
- neardal_tgt_remove(tgtProp);
+ /* Remove all tags */
+ while (g_list_length(adpProp->tagList)) {
+ node = g_list_first(adpProp->tagList);
+ tagProp = (TagProp *) node->data;
+ neardal_tag_remove(tagProp);
}
adpList = &neardalMgr.prop.adpList;
in = g_variant_builder_end(builder);
NEARDAL_TRACE_LOG("Sending:\n%s\n", g_variant_print(in, TRUE));
- org_neard_adp__call_publish_sync(adpProp->proxy, in, NULL, &gerror);
+ org_neard_tag__call_write_sync(adpProp->proxy, in, NULL, &gerror);
exit:
if (gerror != NULL) {
#define __NEARDAL_ADAPTER_H
#include "neard_adapter_proxy.h"
-#include "neardal_target.h"
+#include "neardal_tag.h"
#ifdef __cplusplus
extern "C" {
#define NEARD_ADP_IF_NAME "org.neard.Adapter"
#define NEARD_ADP_SIG_PROPCHANGED "property-changed"
-#define NEARD_ADP_SIG_TGT_FOUND "target-found"
-#define NEARD_ADP_SIG_TGT_LOST "target-lost"
+#define NEARD_ADP_SIG_TGT_FOUND "tag-found"
+#define NEARD_ADP_SIG_TGT_LOST "tag-lost"
/* NEARDAL Adapter Properties */
typedef struct {
gboolean powered; /* adapter powered ? */
gchar **protocols; /* protocols list */
gsize lenProtocols;
- gsize tgtNb;
- GList *tgtList; /* Neard adapter targets list
+ gsize tagNb;
+ GList *tagList; /* Neard adapter tags list
available */
} AdpProp;
/******************************************************************************
- * neardal_adp_prv_get_target: Get NEARDAL target from name
+ * neardal_adp_prv_get_tag: Get NEARDAL tag from name
*****************************************************************************/
-errorCode_t neardal_adp_prv_get_target(AdpProp *adpProp, gchar *tgtName,
- TgtProp **tgtProp);
+errorCode_t neardal_adp_prv_get_tag(AdpProp *adpProp, gchar *tagName,
+ TagProp **tagProp);
/******************************************************************************
* neardal_adp_add: add new NEARDAL adapter, initialize DBus Proxy
*
*/
-#include <glib/gtypes.h>
+#include <glib.h>
#include <neardal_errors.h>
char *neardal_error_get_text(errorCode_t ec)
return "No NFC adapter found...";
case NEARDAL_ERROR_NO_TARGET:
- return "No NFC target found...";
+ return "No NFC tag found...";
case NEARDAL_ERROR_NO_RECORD:
- return "No target record found...";
+ return "No tag record found...";
case NEARDAL_ERROR_POLLING_ALREADY_ACTIVE:
return "Polling already active";
#define NEARDAL_ERROR_NO_ADAPTER ((errorCode_t) -7)
/*! @brief Neard service, polling already active */
#define NEARDAL_ERROR_POLLING_ALREADY_ACTIVE ((errorCode_t) -8)
-/*! @brief Neard service, no NEARDAL target present */
+/*! @brief Neard service, no NEARDAL tag present */
#define NEARDAL_ERROR_NO_TARGET ((errorCode_t) -9)
/*! @brief Neard service, no NEARDAL record present */
#define NEARDAL_ERROR_NO_RECORD ((errorCode_t) -10)
#include "neardal.h"
#include "neardal_prv.h"
-#include <glib-2.0/glib/glist.h>
-#include <glib-2.0/glib/garray.h>
-#include <glib-2.0/glib/galloca.h>
/******************************************************************************
* neardal_mgr_prv_cb_property_changed: Callback called when a NFC Manager
}
/******************************************************************************
- * neardal_mgr_prv_get_target: Get specific target from adapter
+ * neardal_mgr_prv_get_tag: Get specific tag from adapter
*****************************************************************************/
-errorCode_t neardal_mgr_prv_get_target(AdpProp *adpProp, gchar *tgtName,
- TgtProp **tgtProp)
+errorCode_t neardal_mgr_prv_get_tag(AdpProp *adpProp, gchar *tagName,
+ TagProp **tagProp)
{
errorCode_t errCode = NEARDAL_ERROR_NO_TARGET;
guint len;
- TgtProp *tgt = NULL;
+ TagProp *tag = NULL;
GList *tmpList;
g_assert(adpProp != NULL);
- g_assert(tgtName != NULL);
- g_assert(tgtProp != NULL);
+ g_assert(tagName != NULL);
+ g_assert(tagProp != NULL);
len = 0;
- tmpList = adpProp->tgtList;
+ tmpList = adpProp->tagList;
while (len < g_list_length(tmpList)) {
- tgt = g_list_nth_data(tmpList, len);
- if (neardal_tools_prv_cmp_path(tgt->name, tgtName)) {
- *tgtProp = tgt;
+ tag = g_list_nth_data(tmpList, len);
+ if (neardal_tools_prv_cmp_path(tag->name, tagName)) {
+ *tagProp = tag;
errCode = NEARDAL_SUCCESS;
break;
}
}
/******************************************************************************
- * neardal_mgr_prv_get_record: Get specific record from target
+ * neardal_mgr_prv_get_record: Get specific record from tag
*****************************************************************************/
-errorCode_t neardal_mgr_prv_get_record(TgtProp *tgtProp, gchar *rcdName,
+errorCode_t neardal_mgr_prv_get_record(TagProp *tagProp, gchar *rcdName,
RcdProp **rcdProp)
{
errorCode_t errCode = NEARDAL_ERROR_NO_RECORD;
guint len;
RcdProp *rcd = NULL;
- g_assert(tgtProp != NULL);
+ g_assert(tagProp != NULL);
g_assert(rcdName != NULL);
g_assert(rcdProp != NULL);
len = 0;
- while (len < g_list_length(tgtProp->rcdList)) {
- rcd = g_list_nth_data(tgtProp->rcdList, len);
+ while (len < g_list_length(tagProp->rcdList)) {
+ rcd = g_list_nth_data(tagProp->rcdList, len);
if (neardal_tools_prv_cmp_path(rcd->name, rcdName)) {
*rcdProp = rcd;
errCode = NEARDAL_SUCCESS;
AdpProp **adpProp);
/******************************************************************************
- * neardal_mgr_prv_get_target: Get specific target from adapter
+ * neardal_mgr_prv_get_tag: Get specific tag from adapter
*****************************************************************************/
-errorCode_t neardal_mgr_prv_get_target(AdpProp *adpProp, gchar *tgtName,
- TgtProp **tgtProp);
+errorCode_t neardal_mgr_prv_get_tag(AdpProp *adpProp, gchar *tagName,
+ TagProp **tagProp);
/******************************************************************************
- * neardal_mgr_prv_get_record: Get specific record from target
+ * neardal_mgr_prv_get_record: Get specific record from tag
*****************************************************************************/
-errorCode_t neardal_mgr_prv_get_record(TgtProp *tgtProp, gchar *rcdName,
+errorCode_t neardal_mgr_prv_get_record(TagProp *tagProp, gchar *rcdName,
RcdProp **rcdProp);
/******************************************************************************
client callback
'adapter property changed' */
- target_cb cb_tgt_found; /* Client callback for
- 'target found' */
- void *cb_tgt_found_ud; /* User data for
+ tag_cb cb_tag_found; /* Client callback for
+ 'tag found' */
+ void *cb_tag_found_ud; /* User data for
client callback
- 'target found' */
- target_cb cb_tgt_lost; /* Client callback for
- 'target lost' */
- void *cb_tgt_lost_ud; /* User data for
+ 'tag found' */
+ tag_cb cb_tag_lost; /* Client callback for
+ 'tag lost' */
+ void *cb_tag_lost_ud; /* User data for
client callback
- 'target lost' */
+ 'tag lost' */
record_cb cb_rcd_found; /* Client callback for
- ' 'target record found'*/
+ ' 'tag record found'*/
void *cb_rcd_found_ud; /* User data for
client callback
- 'target record found'*/
+ 'tag record found'*/
errorCode_t ec; /* Lastest NEARDAL error */
GError *gerror; /* Lastest GError if available */
#include "neardal.h"
#include "neardal_prv.h"
-#include <glib-2.0/glib/gerror.h>
-#include <glib-2.0/glib/glist.h>
/******************************************************************************
/******************************************************************************
- * neardal_get_records: get an array of target records
+ * neardal_get_records: get an array of tag records
*****************************************************************************/
-errorCode_t neardal_get_records(char *tgtName, char ***array, int *len)
+errorCode_t neardal_get_records(char *tagName, char ***array, int *len)
{
errorCode_t err = NEARDAL_SUCCESS;
AdpProp *adpProp = NULL;
- TgtProp *tgtProp = NULL;
+ TagProp *tagProp = NULL;
int rcdLen = 0;
int ct = 0; /* counter */
char **rcds = NULL;
if (neardalMgr.proxy == NULL)
neardal_prv_construct(&err);
- if (err != NEARDAL_SUCCESS || tgtName == NULL || array == NULL)
+ if (err != NEARDAL_SUCCESS || tagName == NULL || array == NULL)
return NEARDAL_ERROR_INVALID_PARAMETER;
- err = neardal_mgr_prv_get_adapter(tgtName, &adpProp);
+ err = neardal_mgr_prv_get_adapter(tagName, &adpProp);
if (err != NEARDAL_SUCCESS)
goto exit;
- err = neardal_adp_prv_get_target(adpProp, tgtName, &tgtProp);
+ err = neardal_adp_prv_get_tag(adpProp, tagName, &tagProp);
if (err != NEARDAL_SUCCESS)
goto exit;
err = NEARDAL_ERROR_NO_RECORD;
- rcdLen = g_list_length(tgtProp->rcdList);
+ rcdLen = g_list_length(tagProp->rcdList);
if (rcdLen <= 0)
goto exit;
goto exit;
while (ct < rcdLen) {
- rcd = g_list_nth_data(tgtProp->rcdList, ct);
+ rcd = g_list_nth_data(tagProp->rcdList, ct);
if (rcd != NULL)
rcds[ct++] = g_strdup(rcd->name);
}
{
errorCode_t errCode = NEARDAL_ERROR_NO_MEMORY;
RcdProp *rcd = NULL;
- TgtProp *tgtProp = parent;
+ TagProp *tagProp = parent;
g_assert(rcdName != NULL);
g_assert(parent != NULL);
if (rcd->name == NULL)
goto exit;
- rcd->parent = tgtProp;
+ rcd->parent = tagProp;
- tgtProp->rcdList = g_list_prepend(tgtProp->rcdList, (gpointer) rcd);
+ tagProp->rcdList = g_list_prepend(tagProp->rcdList, (gpointer) rcd);
errCode = neardal_rcd_prv_init(rcd);
if (errCode != NEARDAL_SUCCESS)
goto exit;
NEARDAL_TRACEF("NEARDAL LIB recordList contains %d elements\n",
- g_list_length(tgtProp->rcdList));
+ g_list_length(tagProp->rcdList));
errCode = NEARDAL_SUCCESS;
exit:
if (errCode != NEARDAL_SUCCESS) {
- tgtProp->rcdList = g_list_remove(tgtProp->rcdList,
+ tagProp->rcdList = g_list_remove(tagProp->rcdList,
(gpointer) rcd);
neardal_rcd_prv_free(&rcd);
}
*****************************************************************************/
void neardal_rcd_remove(RcdProp *rcd)
{
- TgtProp *tgtProp;
+ TagProp *tagProp;
NEARDAL_TRACEIN();
g_assert(rcd != NULL);
- tgtProp = rcd->parent;
+ tagProp = rcd->parent;
NEARDAL_TRACEF("Removing record:%s\n", rcd->name);
- tgtProp->rcdList = g_list_remove(tgtProp->rcdList,
+ tagProp->rcdList = g_list_remove(tagProp->rcdList,
(gconstpointer) rcd);
/* Remove all records */
neardal_rcd_prv_free(&rcd);
typedef struct {
orgNeardRcd *proxy; /* proxy to Neard NFC Record interface */
gchar *name; /* DBus interface name (as identifier) */
- void *parent; /* parent (target) */
+ void *parent; /* parent (tag) */
gboolean notified; /* Already notified to client? */
gchar *encoding;
#include <glib.h>
#include <glib-object.h>
-#include "neard_target_proxy.h"
+#include "neard_tag_proxy.h"
#include "neardal.h"
#include "neardal_prv.h"
-#include <glib-2.0/glib/gerror.h>
-#include <glib-2.0/glib/glist.h>
-#include <glib-2.0/glib/garray.h>
/******************************************************************************
- * neardal_tgt_prv_cb_property_changed: Callback called when a NFC target
+ * neardal_tag_prv_cb_property_changed: Callback called when a NFC tag
* property is changed
*****************************************************************************/
-static void neardal_tgt_prv_cb_property_changed(orgNeardTgt *proxy,
+static void neardal_tag_prv_cb_property_changed(orgNeardTag *proxy,
const gchar *arg_unnamed_arg0,
GVariant *arg_unnamed_arg1,
void *user_data)
{
errorCode_t errCode = NEARDAL_SUCCESS;
- TgtProp *tgtProp = user_data;
+ TagProp *tagProp = user_data;
(void) proxy; /* remove warning */
(void) arg_unnamed_arg1; /* remove warning */
NEARDAL_TRACEIN();
- if (tgtProp == NULL || arg_unnamed_arg0 == NULL)
+ if (tagProp == NULL || arg_unnamed_arg0 == NULL)
return;
NEARDAL_TRACEF("str0='%s'\n", arg_unnamed_arg0);
}
/******************************************************************************
- * neardal_tgt_prv_read_properties: Get Neard Target Properties
+ * neardal_tag_prv_read_properties: Get Neard Tag Properties
*****************************************************************************/
-static errorCode_t neardal_tgt_prv_read_properties(TgtProp *tgtProp)
+static errorCode_t neardal_tag_prv_read_properties(TagProp *tagProp)
{
errorCode_t errCode = NEARDAL_SUCCESS;
GError *gerror = NULL;
gchar **rcdArray = NULL;
NEARDAL_TRACEIN();
- g_assert(tgtProp != NULL);
- g_assert(tgtProp->proxy != NULL);
+ g_assert(tagProp != NULL);
+ g_assert(tagProp->proxy != NULL);
- org_neard_tgt__call_get_properties_sync(tgtProp->proxy, &tmp, NULL,
+ org_neard_tag__call_get_properties_sync(tagProp->proxy, &tmp, NULL,
&gerror);
if (gerror != NULL) {
errCode = NEARDAL_ERROR_DBUS_CANNOT_INVOKE_METHOD;
NEARDAL_TRACE_ERR(
- "Unable to read target's properties (%d:%s)\n",
+ "Unable to read tag's properties (%d:%s)\n",
gerror->code, gerror->message);
g_error_free(gerror);
goto exit;
tmpOut = g_variant_lookup_value(tmp, "Records", G_VARIANT_TYPE_ARRAY);
if (tmpOut != NULL) {
rcdArray = g_variant_dup_objv(tmpOut, &len);
- tgtProp->rcdLen = len;
+ tagProp->rcdLen = len;
if (len == 0) {
g_strfreev(rcdArray);
rcdArray = NULL;
guint len = 0;
char *rcdName;
- while (len < tgtProp->rcdLen &&
+ while (len < tagProp->rcdLen &&
errCode == NEARDAL_SUCCESS) {
rcdName = rcdArray[len++];
- errCode = neardal_rcd_add(rcdName, tgtProp);
+ errCode = neardal_rcd_add(rcdName, tagProp);
}
}
}
tmpOut = g_variant_lookup_value(tmp, "TagType", G_VARIANT_TYPE_ARRAY);
if (tmpOut != NULL) {
- tgtProp->tagType = g_variant_dup_strv(tmpOut, &len);
- tgtProp->tagTypeLen = len;
+ tagProp->tagType = g_variant_dup_strv(tmpOut, &len);
+ tagProp->tagTypeLen = len;
if (len == 0) {
- g_strfreev(tgtProp->tagType);
- tgtProp->tagType = NULL;
+ g_strfreev(tagProp->tagType);
+ tagProp->tagType = NULL;
}
}
tmpOut = g_variant_lookup_value(tmp, "Type", G_VARIANT_TYPE_STRING);
if (tmpOut != NULL)
- tgtProp->type = g_variant_dup_string(tmpOut, NULL);
+ tagProp->type = g_variant_dup_string(tmpOut, NULL);
tmpOut = g_variant_lookup_value(tmp, "ReadOnly",
G_VARIANT_TYPE_BOOLEAN);
if (tmpOut != NULL)
- tgtProp->readOnly = g_variant_get_boolean(tmpOut);
+ tagProp->readOnly = g_variant_get_boolean(tmpOut);
exit:
return errCode;
}
/******************************************************************************
- * neardal_tgt_init: Get Neard Manager Properties = NFC Targets list.
- * Create a DBus proxy for the first one NFC target if present
+ * neardal_tag_init: Get Neard Manager Properties = NFC Tags list.
+ * Create a DBus proxy for the first one NFC tag if present
* Register Neard Manager signals ('PropertyChanged')
*****************************************************************************/
-static errorCode_t neardal_tgt_prv_init(TgtProp *tgtProp)
+static errorCode_t neardal_tag_prv_init(TagProp *tagProp)
{
errorCode_t errCode = NEARDAL_SUCCESS;
NEARDAL_TRACEIN();
- g_assert(tgtProp != NULL);
+ g_assert(tagProp != NULL);
- if (tgtProp->proxy != NULL) {
- g_signal_handlers_disconnect_by_func(tgtProp->proxy,
- G_CALLBACK(neardal_tgt_prv_cb_property_changed),
+ if (tagProp->proxy != NULL) {
+ g_signal_handlers_disconnect_by_func(tagProp->proxy,
+ G_CALLBACK(neardal_tag_prv_cb_property_changed),
NULL);
- g_object_unref(tgtProp->proxy);
- tgtProp->proxy = NULL;
+ g_object_unref(tagProp->proxy);
+ tagProp->proxy = NULL;
}
- tgtProp->proxy = NULL;
+ tagProp->proxy = NULL;
- tgtProp->proxy = org_neard_tgt__proxy_new_sync(neardalMgr.conn,
+ tagProp->proxy = org_neard_tag__proxy_new_sync(neardalMgr.conn,
G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
NEARD_DBUS_SERVICE,
- tgtProp->name,
+ tagProp->name,
NULL, /* GCancellable */
&neardalMgr.gerror);
if (neardalMgr.gerror != NULL) {
NEARDAL_TRACE_ERR(
- "Unable to create Neard Target Proxy (%d:%s)\n",
+ "Unable to create Neard Tag Proxy (%d:%s)\n",
neardalMgr.gerror->code,
neardalMgr.gerror->message);
neardal_tools_prv_free_gerror(&neardalMgr);
return NEARDAL_ERROR_DBUS_CANNOT_CREATE_PROXY;
}
- /* Populate Target datas... */
- errCode = neardal_tgt_prv_read_properties(tgtProp);
+ /* Populate Tag datas... */
+ errCode = neardal_tag_prv_read_properties(tagProp);
if (errCode != NEARDAL_SUCCESS)
return errCode;
- NEARDAL_TRACEF("Register Neard-Target Signal 'PropertyChanged'\n");
- g_signal_connect(tgtProp->proxy, NEARD_TGT_SIG_PROPCHANGED,
- G_CALLBACK(neardal_tgt_prv_cb_property_changed),
- tgtProp);
+ NEARDAL_TRACEF("Register Neard-Tag Signal 'PropertyChanged'\n");
+ g_signal_connect(tagProp->proxy, NEARD_TGT_SIG_PROPCHANGED,
+ G_CALLBACK(neardal_tag_prv_cb_property_changed),
+ tagProp);
return errCode;
}
/******************************************************************************
- * neardal_tgt_prv_free: unref DBus proxy, disconnect Neard Target signals
+ * neardal_tag_prv_free: unref DBus proxy, disconnect Neard Tag signals
*****************************************************************************/
-static void neardal_tgt_prv_free(TgtProp **tgtProp)
+static void neardal_tag_prv_free(TagProp **tagProp)
{
NEARDAL_TRACEIN();
- if ((*tgtProp)->proxy != NULL) {
- g_signal_handlers_disconnect_by_func((*tgtProp)->proxy,
- G_CALLBACK(neardal_tgt_prv_cb_property_changed),
+ if ((*tagProp)->proxy != NULL) {
+ g_signal_handlers_disconnect_by_func((*tagProp)->proxy,
+ G_CALLBACK(neardal_tag_prv_cb_property_changed),
NULL);
- g_object_unref((*tgtProp)->proxy);
- (*tgtProp)->proxy = NULL;
+ g_object_unref((*tagProp)->proxy);
+ (*tagProp)->proxy = NULL;
}
- g_free((*tgtProp)->name);
- g_free((*tgtProp)->type);
- g_strfreev((*tgtProp)->tagType);
- g_free((*tgtProp));
- (*tgtProp) = NULL;
+ g_free((*tagProp)->name);
+ g_free((*tagProp)->type);
+ g_strfreev((*tagProp)->tagType);
+ g_free((*tagProp));
+ (*tagProp) = NULL;
}
/******************************************************************************
- * neardal_tgt_notify_target_found: Invoke client callback for 'record found'
- * if present, and 'target found' (if not already nofied)
+ * neardal_tag_notify_tag_found: Invoke client callback for 'record found'
+ * if present, and 'tag found' (if not already nofied)
*****************************************************************************/
-void neardal_tgt_notify_target_found(TgtProp *tgtProp)
+void neardal_tag_notify_tag_found(TagProp *tagProp)
{
RcdProp *rcdProp;
gsize len;
- g_assert(tgtProp != NULL);
+ g_assert(tagProp != NULL);
- if (tgtProp->notified == FALSE && neardalMgr.cb_tgt_found != NULL) {
- (neardalMgr.cb_tgt_found)(tgtProp->name,
- neardalMgr.cb_tgt_found_ud);
- tgtProp->notified = TRUE;
+ if (tagProp->notified == FALSE && neardalMgr.cb_tag_found != NULL) {
+ (neardalMgr.cb_tag_found)(tagProp->name,
+ neardalMgr.cb_tag_found_ud);
+ tagProp->notified = TRUE;
}
len = 0;
if (neardalMgr.cb_rcd_found != NULL)
- while (len < g_list_length(tgtProp->rcdList)) {
- rcdProp = g_list_nth_data(tgtProp->rcdList, len++);
+ while (len < g_list_length(tagProp->rcdList)) {
+ rcdProp = g_list_nth_data(tagProp->rcdList, len++);
if (rcdProp->notified == FALSE) {
(neardalMgr.cb_rcd_found)(rcdProp->name,
neardalMgr.cb_rcd_found_ud);
}
}
/******************************************************************************
- * neardal_get_targets: get an array of NFC targets present
+ * neardal_get_tags: get an array of NFC tags present
*****************************************************************************/
-errorCode_t neardal_get_targets(char *adpName, char ***array, int *len)
+errorCode_t neardal_get_tags(char *adpName, char ***array, int *len)
{
errorCode_t err = NEARDAL_SUCCESS;
AdpProp *adpProp = NULL;
- int tgtNb = 0;
+ int tagNb = 0;
int ct = 0; /* counter */
- char **tgts = NULL;
- TgtProp *target = NULL;
+ char **tags = NULL;
+ TagProp *tag = NULL;
if (neardalMgr.proxy == NULL)
if (err != NEARDAL_SUCCESS)
return err;
- tgtNb = g_list_length(adpProp->tgtList);
- if (tgtNb <= 0)
+ tagNb = g_list_length(adpProp->tagList);
+ if (tagNb <= 0)
return NEARDAL_ERROR_NO_TARGET;
err = NEARDAL_ERROR_NO_MEMORY;
- tgts = g_try_malloc0((tgtNb + 1) * sizeof(char *));
+ tags = g_try_malloc0((tagNb + 1) * sizeof(char *));
- if (tgts == NULL)
+ if (tags == NULL)
return NEARDAL_ERROR_NO_MEMORY;
- while (ct < tgtNb) {
- target = g_list_nth_data(adpProp->tgtList, ct);
- if (target != NULL)
- tgts[ct++] = g_strdup(target->name);
+ while (ct < tagNb) {
+ tag = g_list_nth_data(adpProp->tagList, ct);
+ if (tag != NULL)
+ tags[ct++] = g_strdup(tag->name);
}
err = NEARDAL_SUCCESS;
if (len != NULL)
- *len = tgtNb;
- *array = tgts;
+ *len = tagNb;
+ *array = tags;
return err;
}
/******************************************************************************
- * neardal_tgt_add: add new NFC target, initialize DBus Proxy connection,
- * register target signal
+ * neardal_tag_add: add new NFC tag, initialize DBus Proxy connection,
+ * register tag signal
*****************************************************************************/
-errorCode_t neardal_tgt_add(gchar *tgtName, void * parent)
+errorCode_t neardal_tag_add(gchar *tagName, void * parent)
{
errorCode_t errCode = NEARDAL_ERROR_NO_MEMORY;
- TgtProp *tgtProp = NULL;
+ TagProp *tagProp = NULL;
AdpProp *adpProp = parent;
- g_assert(tgtName != NULL);
+ g_assert(tagName != NULL);
- NEARDAL_TRACEF("Adding target:%s\n", tgtName);
- tgtProp = g_try_malloc0(sizeof(TgtProp));
- if (tgtProp == NULL)
+ NEARDAL_TRACEF("Adding tag:%s\n", tagName);
+ tagProp = g_try_malloc0(sizeof(TagProp));
+ if (tagProp == NULL)
goto error;
- tgtProp->name = g_strdup(tgtName);
- tgtProp->parent = adpProp;
+ tagProp->name = g_strdup(tagName);
+ tagProp->parent = adpProp;
- adpProp->tgtList = g_list_prepend(adpProp->tgtList, tgtProp);
- errCode = neardal_tgt_prv_init(tgtProp);
+ adpProp->tagList = g_list_prepend(adpProp->tagList, tagProp);
+ errCode = neardal_tag_prv_init(tagProp);
- NEARDAL_TRACEF("NEARDAL LIB targetList contains %d elements\n",
- g_list_length(adpProp->tgtList));
+ NEARDAL_TRACEF("NEARDAL LIB tagList contains %d elements\n",
+ g_list_length(adpProp->tagList));
return errCode;
error:
- if (tgtProp->name != NULL)
- g_free(tgtProp->name);
- if (tgtProp != NULL)
- g_free(tgtProp);
+ if (tagProp->name != NULL)
+ g_free(tagProp->name);
+ if (tagProp != NULL)
+ g_free(tagProp);
return errCode;
}
/******************************************************************************
- * neardal_tgt_remove: remove one NFC target, unref DBus Proxy connection,
- * unregister target signal
+ * neardal_tag_remove: remove one NFC tag, unref DBus Proxy connection,
+ * unregister tag signal
*****************************************************************************/
-void neardal_tgt_remove(TgtProp *tgtProp)
+void neardal_tag_remove(TagProp *tagProp)
{
RcdProp *rcdProp = NULL;
GList *node;
AdpProp *adpProp;
- g_assert(tgtProp != NULL);
+ g_assert(tagProp != NULL);
- NEARDAL_TRACEF("Removing target:%s\n", tgtProp->name);
- /* Remove all targets */
- while (g_list_length(tgtProp->rcdList)) {
- node = g_list_first(tgtProp->rcdList);
+ NEARDAL_TRACEF("Removing tag:%s\n", tagProp->name);
+ /* Remove all tags */
+ while (g_list_length(tagProp->rcdList)) {
+ node = g_list_first(tagProp->rcdList);
rcdProp = (RcdProp *) node->data;
neardal_rcd_remove(rcdProp);
}
- adpProp = tgtProp->parent;
- adpProp->tgtList = g_list_remove(adpProp->tgtList,
- (gconstpointer) tgtProp);
+ adpProp = tagProp->parent;
+ adpProp->tagList = g_list_remove(adpProp->tagList,
+ (gconstpointer) tagProp);
- neardal_tgt_prv_free(&tgtProp);
+ neardal_tag_prv_free(&tagProp);
}
#ifndef __NEARDAL_TARGET_H
#define __NEARDAL_TARGET_H
-#include "neard_target_proxy.h"
+#include "neard_tag_proxy.h"
#include "neardal_record.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-#define NEARD_TARGETS_IF_NAME "org.neard.Target"
+#define NEARD_TARGETS_IF_NAME "org.neard.Tag"
#define NEARD_TGT_SIG_PROPCHANGED "property-changed"
-/* NEARDAL Target Properties */
+/* NEARDAL Tag Properties */
typedef struct {
- orgNeardTgt *proxy; /* proxy to Neard NEARDAL Target interface */
+ orgNeardTag *proxy; /* proxy to Neard NEARDAL Tag interface */
gchar *name; /* DBus interface name (as identifier) */
void *parent; /* parent (adapter ) */
gboolean notified; /* Already notified to client? */
gchar *type;
gsize rcdLen;
- GList *rcdList; /* target's records paths */
+ GList *rcdList; /* tag's records paths */
gchar **tagType; /* array of tag types */
gsize tagTypeLen;
gboolean readOnly; /* Read-Only flag */
-} TgtProp;
+} TagProp;
/******************************************************************************
- * neardal_tgt_notify_target_found: Invoke client callback for 'record found'
- * if present, and 'target found' (if not already nofied)
+ * neardal_tag_notify_tag_found: Invoke client callback for 'record found'
+ * if present, and 'tag found' (if not already nofied)
*****************************************************************************/
-void neardal_tgt_notify_target_found(TgtProp *tgtProp);
+void neardal_tag_notify_tag_found(TagProp *tagProp);
/******************************************************************************
- * neardal_tgt_add: add new NEARDAL target, initialize DBus Proxy connection,
- * register target signal
+ * neardal_tag_add: add new NEARDAL tag, initialize DBus Proxy connection,
+ * register tag signal
*****************************************************************************/
-errorCode_t neardal_tgt_add(gchar *tgtName, void * parent);
+errorCode_t neardal_tag_add(gchar *tagName, void * parent);
/******************************************************************************
- * neardal_tgt_remove: remove NEARDAL target, unref DBus Proxy connection,
- * unregister target signal
+ * neardal_tag_remove: remove NEARDAL tag, unref DBus Proxy connection,
+ * unregister tag signal
*****************************************************************************/
-void neardal_tgt_remove(TgtProp *tgtProp);
+void neardal_tag_remove(TagProp *tagProp);
#ifdef __cplusplus
#include "neardal.h"
#include "neardal_prv.h"
-#include <glib-2.0/glib/gvariant.h>
/******************************************************************************
#include "ncl.h"
#include "ncl_cmd.h"
-#include <glib-2.0/glib/gstrfuncs.h>
#define PROMPT_PREFIX "NCL> "
#define NB_MAX_PARAMETERS 20 /* Max number of parameters in a
#include "ncl.h"
#include "ncl_cmd.h"
#include <lib/neardal.h>
-#include <glib-2.0/glib/goption.h>
static NCLCmdContext sNclCmdCtx;
static void ncl_cmd_prv_dump_adapter(neardal_adapter adapter)
{
char **protocols;
- char **targets;
+ char **tags;
NCL_CMD_PRINT("Adapter\n");
NCL_CMD_PRINT(".. Name:\t\t'%s'\n", adapter.name);
NCL_CMD_PRINT(".. Powered:\t\t'%s'\n",
adapter.powered ? "TRUE" : "FALSE");
- targets = adapter.targets;
- NCL_CMD_PRINT(".. Number of targets:\t%d\n", adapter.nbTargets);
- NCL_CMD_PRINT(".. Targets[]:\t\t");
- if (adapter.nbTargets > 0) {
- while ((*targets) != NULL) {
- NCL_CMD_PRINT("'%s', ", *targets);
- targets++;
+ tags = adapter.tags;
+ NCL_CMD_PRINT(".. Number of tags:\t%d\n", adapter.nbTags);
+ NCL_CMD_PRINT(".. Tags[]:\t\t");
+ if (adapter.nbTags > 0) {
+ while ((*tags) != NULL) {
+ NCL_CMD_PRINT("'%s', ", *tags);
+ tags++;
}
- neardal_free_array(&adapter.targets);
+ neardal_free_array(&adapter.tags);
} else
- NCL_CMD_PRINT("No targets!");
+ NCL_CMD_PRINT("No tags!");
NCL_CMD_PRINT("\n");
protocols = adapter.protocols;
}
/******************************************************************************
- * Dump properties of a target
+ * Dump properties of a tag
*****************************************************************************/
-static void ncl_cmd_prv_dump_target(neardal_target target)
+static void ncl_cmd_prv_dump_tag(neardal_tag tag)
{
char **records;
char **tagTypes;
- NCL_CMD_PRINT("Target:\n");
- NCL_CMD_PRINT(".. Name:\t\t'%s'\n", target.name);
+ NCL_CMD_PRINT("Tag:\n");
+ NCL_CMD_PRINT(".. Name:\t\t'%s'\n", tag.name);
- NCL_CMD_PRINT(".. Type:\t\t'%s'\n", target.type);
+ NCL_CMD_PRINT(".. Type:\t\t'%s'\n", tag.type);
- NCL_CMD_PRINT(".. Number of 'Tag Type':%d\n", target.nbTagTypes);
- tagTypes = target.tagType;
- if (target.nbTagTypes > 0) {
+ NCL_CMD_PRINT(".. Number of 'Tag Type':%d\n", tag.nbTagTypes);
+ tagTypes = tag.tagType;
+ if (tag.nbTagTypes > 0) {
NCL_CMD_PRINT(".. Tags type[]:\t\t");
while ((*tagTypes) != NULL) {
NCL_CMD_PRINT("'%s', ", *tagTypes);
tagTypes++;
}
NCL_CMD_PRINT("\n");
- neardal_free_array(&target.tagType);
+ neardal_free_array(&tag.tagType);
}
- records = target.records;
- NCL_CMD_PRINT(".. Number of records:\t%d\n", target.nbRecords);
+ records = tag.records;
+ NCL_CMD_PRINT(".. Number of records:\t%d\n", tag.nbRecords);
NCL_CMD_PRINT(".. Records[]:\t\t");
if (records != NULL) {
while ((*records) != NULL) {
NCL_CMD_PRINT("'%s', ", *records);
records++;
}
- neardal_free_array(&target.records);
+ neardal_free_array(&tag.records);
} else
NCL_CMD_PRINT("No records!");
NCL_CMD_PRINT("\n");
NCL_CMD_PRINT(".. ReadOnly:\t\t%s\n" ,
- target.readOnly ? "TRUE" : "FALSE");
+ tag.readOnly ? "TRUE" : "FALSE");
}
/******************************************************************************
NCL_CMD_PRINT("\n");
}
-static void ncl_cmd_cb_target_found(const char *tgtName, void *user_data)
+static void ncl_cmd_cb_tag_found(const char *tagName, void *user_data)
{
- neardal_target target;
+ neardal_tag tag;
errorCode_t ec;
(void) user_data; /* remove warning */
- NCL_CMD_PRINTF("NFC Target found (%s)\n", tgtName);
+ NCL_CMD_PRINTF("NFC Tag found (%s)\n", tagName);
- ec = neardal_get_target_properties(tgtName, &target);
+ ec = neardal_get_tag_properties(tagName, &tag);
if (ec == NEARDAL_SUCCESS)
- ncl_cmd_prv_dump_target(target);
+ ncl_cmd_prv_dump_tag(tag);
else
NCL_CMD_PRINTF(
- "Unable to read target properties. (error:%d='%s'). exit...\n",
+ "Unable to read tag properties. (error:%d='%s'). exit...\n",
ec, neardal_error_get_text(ec));
return;
}
-static void ncl_cmd_cb_target_lost(const char *tgtName, void *user_data)
+static void ncl_cmd_cb_tag_lost(const char *tagName, void *user_data)
{
(void) user_data; /* remove warning */
- NCL_CMD_PRINTF("NFC Target lost (%s)\n", tgtName);
+ NCL_CMD_PRINTF("NFC Tag lost (%s)\n", tagName);
}
static void ncl_cmd_cb_record_found(const char *rcdName, void *user_data)
(void) user_data; /* remove warning */
- NCL_CMD_PRINTF("Target Record found (%s)\n", rcdName);
+ NCL_CMD_PRINTF("Tag Record found (%s)\n", rcdName);
ec = neardal_get_record_properties(rcdName, &record);
if (ec == NEARDAL_SUCCESS) {
ncl_cmd_prv_dump_record(record);
neardal_set_cb_adapter_property_changed(ncl_cmd_cb_adapter_prop_changed,
NULL);
NCL_CMD_PRINTF("NFC adapter callback registered\n");
- neardal_set_cb_target_found(ncl_cmd_cb_target_found, NULL);
- neardal_set_cb_target_lost(ncl_cmd_cb_target_lost, NULL);
- NCL_CMD_PRINTF("NFC target registered\n");
+ neardal_set_cb_tag_found(ncl_cmd_cb_tag_found, NULL);
+ neardal_set_cb_tag_lost(ncl_cmd_cb_tag_lost, NULL);
+ NCL_CMD_PRINTF("NFC tag registered\n");
neardal_set_cb_record_found(ncl_cmd_cb_record_found, NULL);
NCL_CMD_PRINTF("NFC record callback registered\n");
sNclCmdCtx.cb_initialized = true;
*****************************************************************************/
/******************************************************************************
- * neardal_get_targets : BEGIN
- * Get targets List
+ * neardal_get_tags : BEGIN
+ * Get tags List
*****************************************************************************/
-static NCLError ncl_cmd_neardal_get_targets(int argc, char *argv[])
+static NCLError ncl_cmd_neardal_get_tags(int argc, char *argv[])
{
errorCode_t ec;
NCLError nclErr;
- char **tgtArray = NULL;
- int tgtLen;
- int tgtOff;
+ char **tagArray = NULL;
+ int tagLen;
+ int tagOff;
if (argc <= 1)
return NCLERR_PARSING_PARAMETERS;
if (sNclCmdCtx.cb_initialized == false)
ncl_cmd_install_callback();
- ec = neardal_get_targets(argv[1], &tgtArray, &tgtLen);
+ ec = neardal_get_tags(argv[1], &tagArray, &tagLen);
if (ec == NEARDAL_SUCCESS) {
- tgtOff = 0;
- /* For each target */
- while (tgtArray[tgtOff] != NULL)
- NCL_CMD_PRINT(".. Target '%s'\n",
- tgtArray[tgtOff++]);
+ tagOff = 0;
+ /* For each tag */
+ while (tagArray[tagOff] != NULL)
+ NCL_CMD_PRINT(".. Tag '%s'\n",
+ tagArray[tagOff++]);
- neardal_free_array(&tgtArray);
+ neardal_free_array(&tagArray);
} else
- NCL_CMD_PRINTF("No target\n");
+ NCL_CMD_PRINTF("No tag\n");
NCL_CMD_PRINT("\nExit with error code %d:%s\n", ec,
neardal_error_get_text(ec));
return nclErr;
}
/******************************************************************************
- * neardal_get_targets : END
+ * neardal_get_tags : END
*****************************************************************************/
/******************************************************************************
- * ncl_cmd_neardal_get_target_properties : BEGIN
- * Read target properties
+ * ncl_cmd_neardal_get_tag_properties : BEGIN
+ * Read tag properties
*****************************************************************************/
-static NCLError ncl_cmd_neardal_get_target_properties(int argc, char *argv[])
+static NCLError ncl_cmd_neardal_get_tag_properties(int argc, char *argv[])
{
errorCode_t ec;
- char *targetName = NULL;
- neardal_target target;
+ char *tagName = NULL;
+ neardal_tag tag;
if (argc <= 1)
return NCLERR_PARSING_PARAMETERS;
if (sNclCmdCtx.cb_initialized == false)
ncl_cmd_install_callback();
- targetName = argv[1];
- ec = neardal_get_target_properties(targetName, &target);
+ tagName = argv[1];
+ ec = neardal_get_tag_properties(tagName, &tag);
if (ec == NEARDAL_SUCCESS)
- ncl_cmd_prv_dump_target(target);
+ ncl_cmd_prv_dump_tag(tag);
else {
- NCL_CMD_PRINTF("Read target properties error:%d='%s'.\n", ec,
+ NCL_CMD_PRINTF("Read tag properties error:%d='%s'.\n", ec,
neardal_error_get_text(ec));
return NCLERR_LIB_ERROR;
}
return NCLERR_NOERROR;
}
/******************************************************************************
- * ncl_cmd_neardal_get_target_properties : END
+ * ncl_cmd_neardal_get_tag_properties : END
*****************************************************************************/
/******************************************************************************
/******************************************************************************
* ncl_cmd_neardal_get_record_properties : BEGIN
- * Read a specific target
+ * Read a specific tag
*****************************************************************************/
static NCLError ncl_cmd_neardal_get_record_properties(int argc, char *argv[])
{
{ "get_records",
ncl_cmd_neardal_get_records,
- "Get records list (1st parameter is target name)"},
+ "Get records list (1st parameter is tag name)"},
{ "get_record_properties",
ncl_cmd_neardal_get_record_properties,
"Read a specific record. (1st parameter is record name)"},
- { "get_targets",
- ncl_cmd_neardal_get_targets,
- "Get targets list (1st parameter is adapter name)"},
+ { "get_tags",
+ ncl_cmd_neardal_get_tags,
+ "Get tags list (1st parameter is adapter name)"},
- { "get_target_properties",
- ncl_cmd_neardal_get_target_properties,
- "Get target properties (1st parameter is target name)"},
+ { "get_tag_properties",
+ ncl_cmd_neardal_get_tag_properties,
+ "Get tag properties (1st parameter is tag name)"},
{ LISTCMD_NAME,
ncl_cmd_list,