diff options
-rw-r--r-- | lib/neardal.c | 99 | ||||
-rw-r--r-- | lib/neardal.h | 18 | ||||
-rw-r--r-- | lib/neardal_adapter.c | 5 | ||||
-rw-r--r-- | lib/neardal_adapter.h | 1 | ||||
-rw-r--r-- | lib/neardal_agent.c | 70 | ||||
-rw-r--r-- | lib/neardal_agent.h | 6 | ||||
-rw-r--r-- | lib/neardal_device.h | 1 | ||||
-rw-r--r-- | lib/neardal_errors.h | 6 | ||||
-rw-r--r-- | lib/neardal_manager.c | 2 | ||||
-rw-r--r-- | lib/neardal_manager.h | 1 | ||||
-rw-r--r-- | lib/neardal_prv.h | 6 | ||||
-rw-r--r-- | lib/neardal_record.c | 15 | ||||
-rw-r--r-- | lib/neardal_record.h | 4 | ||||
-rw-r--r-- | lib/neardal_tag.c | 4 | ||||
-rw-r--r-- | lib/neardal_tag.h | 3 | ||||
-rw-r--r-- | lib/neardal_tools.c | 10 | ||||
-rw-r--r-- | lib/neardal_tools.h | 5 | ||||
-rw-r--r-- | ncl/ncl.c | 2 | ||||
-rw-r--r-- | ncl/ncl_cmd.c | 6 |
19 files changed, 132 insertions, 132 deletions
diff --git a/lib/neardal.c b/lib/neardal.c index fe50ce3..1340417 100644 --- a/lib/neardal.c +++ b/lib/neardal.c @@ -82,7 +82,6 @@ void neardal_prv_construct(errorCode_t *ec) /* No Neard daemon, destroying neardal object... */ if (err != NEARDAL_SUCCESS) goto exit; - } else { NEARDAL_TRACE_ERR("Unable to connect to dbus: %s\n", @@ -96,7 +95,7 @@ exit: *ec = err; neardal_tools_prv_free_gerror(&neardalMgr.gerror); - + NEARDAL_TRACEF("Exit\n"); return; } @@ -157,7 +156,7 @@ errorCode_t neardal_set_cb_adapter_removed(adapter_cb cb_adp_removed, * cb_mgr_adp_property_changed = NULL to remove actual callback. ****************************************************************************/ errorCode_t neardal_set_cb_adapter_property_changed( - adapter_prop_cb cb_adp_property_changed, + adapter_prop_cb cb_adp_property_changed, void *user_data) { neardalMgr.cb.adp_prop_changed = cb_adp_property_changed; @@ -382,28 +381,28 @@ errorCode_t neardal_get_adapters(char ***array, int *len) void neardal_free_adapter(neardal_adapter *adapter) { int ct = 0; /* counter */ - + if (adapter == NULL) { NEARDAL_TRACE_ERR("Adapter provided is NULL!\n"); return; } - // Freeing adapter name + /* Freeing adapter name */ g_free(adapter->name); - - // Freeing protocols list + + /* Freeing protocols list */ ct = 0; - while (ct < adapter->nbProtocols) { + while (ct < adapter->nbProtocols) g_free(adapter->protocols[ct++]); - } g_free(adapter->protocols); - // Freeing tags list + + /* Freeing tags list */ ct = 0; - while (ct < adapter->nbTags) { + while (ct < adapter->nbTags) g_free(adapter->tags[ct++]); - } g_free(adapter->tags); - // Freeing adapter struct + + /* Freeing adapter struct */ g_free(adapter); } @@ -484,7 +483,7 @@ exit: if (adapter != NULL) *adapter = NULL; } - + return err; } @@ -570,7 +569,7 @@ errorCode_t neardal_start_poll_loop(char *adpName, int mode) err = NEARDAL_ERROR_POLLING_ALREADY_ACTIVE; goto exit; } - + if (mode == NEARD_ADP_MODE_INITIATOR) org_neard_adp__call_start_poll_loop_sync(adpProp->proxy, ADP_MODE_INITIATOR, @@ -585,10 +584,11 @@ errorCode_t neardal_start_poll_loop(char *adpName, int mode) ADP_MODE_DUAL, NULL, &neardalMgr.gerror); else - org_neard_adp__call_start_poll_loop_sync(adpProp->proxy, - ADP_MODE_INITIATOR, NULL, + org_neard_adp__call_start_poll_loop_sync(adpProp->proxy + , ADP_MODE_INITIATOR + , NULL, &neardalMgr.gerror); - + if (neardalMgr.gerror != NULL) { NEARDAL_TRACE_ERR( "Error with neard dbus method (err:%d:'%s')\n" @@ -706,25 +706,23 @@ void neardal_free_tag(neardal_tag *tag) return; } - // Freeing tag name/type + /* Freeing tag name/type */ g_free((gpointer) tag->name); g_free((gpointer) tag->type); - // Freeing records list + /* Freeing records list */ ct = 0; - while (ct < tag->nbRecords) { + while (ct < tag->nbRecords) g_free(tag->records[ct++]); - } g_free(tag->records); - // Freeing tag type list + /* Freeing tag type list */ ct = 0; - while (ct < tag->nbTagTypes) { + while (ct < tag->nbTagTypes) g_free(tag->tagType[ct++]); - } g_free(tag->tagType); - // Freeing adapter struct + /* Freeing adapter struct */ g_free(tag); } @@ -781,7 +779,8 @@ errorCode_t neardal_get_tag_properties(const char *tagName, while (ct < tagClient->nbRecords) { record = g_list_nth_data(tagProp->rcdList, ct); if (record != NULL) - tagClient->records[ct++] = g_strdup(record->name); + tagClient->records[ct] = g_strdup(record->name); + ct++; } err = NEARDAL_SUCCESS; } @@ -921,17 +920,16 @@ void neardal_free_device(neardal_dev *dev) return; } - // Freeing dev name/type + /* Freeing dev name/type */ g_free((gpointer) dev->name); - // Freeing records list + /* Freeing records list */ ct = 0; - while (ct < dev->nbRecords) { + while (ct < dev->nbRecords) g_free(dev->records[ct++]); - } g_free(dev->records); - // Freeing adapter struct + /* Freeing adapter struct */ g_free(dev); } @@ -985,7 +983,8 @@ errorCode_t neardal_get_dev_properties(const char *devName, while (ct < devClient->nbRecords) { record = g_list_nth_data(devProp->rcdList, ct); if (record != NULL) - devClient->records[ct++] = g_strdup(record->name); + devClient->records[ct++] = g_strdup( + record->name); } err = NEARDAL_SUCCESS; } @@ -1110,7 +1109,7 @@ void neardal_free_record(neardal_record *record) return; } - // Freeing record properties + /* Freeing record properties */ g_free((gpointer) record->name); g_free((gpointer) record->encoding); g_free((gpointer) record->language); @@ -1119,11 +1118,11 @@ void neardal_free_record(neardal_record *record) g_free((gpointer) record->representation); g_free((gpointer) record->uri); g_free((gpointer) record->mime); - - // Freeing record struct + + /* Freeing record struct */ g_free(record); } - + /***************************************************************************** * neardal_get_record_properties: Get values of a specific tag record ****************************************************************************/ @@ -1165,7 +1164,7 @@ errorCode_t neardal_get_record_properties(const char *recordName, goto exit; } *record = rcdClient; - + rcdClient->name = g_strdup(rcdProp->name); rcdClient->encoding = g_strdup(rcdProp->encoding); rcdClient->language = g_strdup(rcdProp->language); @@ -1183,7 +1182,7 @@ exit: if (record != NULL) *record = NULL; } - + return err; } @@ -1205,11 +1204,11 @@ errorCode_t neardal_agent_set_NDEF_cb(char *tagType, agent_cb cb_agent if (tagType == NULL) goto exit; err = NEARDAL_ERROR_NO_MEMORY; - + agent.cb_agent = cb_agent; agent.pid = getpid(); agent.tagType = g_strdup(tagType); - { // replace ':' with '_' + { /* replace ':' with '_' */ int len = strlen(agent.tagType); while (len > 0) { if (agent.tagType[len] == ':') @@ -1219,29 +1218,29 @@ errorCode_t neardal_agent_set_NDEF_cb(char *tagType, agent_cb cb_agent } agent.user_data = user_data; agent.objPath = NULL; - agent.objPath = g_strdup_printf("%s/%s/%d", NEARDAL_AGENT_PREFIX + agent.objPath = g_strdup_printf("%s/%s/%d", AGENT_PREFIX , agent.tagType, agent.pid); - + if (agent.objPath == NULL) goto exit; - + err = neardal_ndefagent_prv_manage(agent); if (err != NEARDAL_SUCCESS) goto exit; if (cb_agent != NULL) - // RegisterNDEFAgent + /* RegisterNDEFAgent */ org_neard_mgr__call_register_ndefagent_sync(neardalMgr.proxy , agent.objPath , tagType, NULL , &neardalMgr.gerror); else - // UnregisterNDEFAgent + /* UnregisterNDEFAgent */ org_neard_mgr__call_unregister_ndefagent_sync(neardalMgr.proxy , agent.objPath , tagType, NULL , &neardalMgr.gerror); - + if (neardalMgr.gerror != NULL) { NEARDAL_TRACE_ERR( @@ -1253,12 +1252,10 @@ errorCode_t neardal_agent_set_NDEF_cb(char *tagType, agent_cb cb_agent } exit: - if (err != NEARDAL_SUCCESS) { + if (err != NEARDAL_SUCCESS) neardal_tools_prv_free_gerror(&neardalMgr.gerror); - } g_free(agent.objPath); g_free(agent.tagType); - + return err; } - diff --git a/lib/neardal.h b/lib/neardal.h index d8776ae..52a82c5 100644 --- a/lib/neardal.h +++ b/lib/neardal.h @@ -75,7 +75,7 @@ typedef struct { /*! @brief Number of records in tag */ int nbRecords; -/*! @brief tag records list to free) */ +/*! @brief tag records list */ char **records; /*! @brief Number of supported 'types' in tag */ int nbTagTypes; @@ -187,7 +187,7 @@ typedef void (*record_cb) (const char *rcdName, void *user_data); * * @param rcdArray array of records path (as identifier=dbus object path) * @param rcdLen number of records path in rcdArray - * @param ndefArray array of raw NDEF data + * @param ndefArray array of raw NDEF data * @param ndefLen number of bytes in ndefArray * @param user_data Client user data **/ @@ -219,8 +219,6 @@ void neardal_destroy(); #define NEARD_ADP_MODE_INITIATOR 0 #define NEARD_ADP_MODE_TARGET 1 #define NEARD_ADP_MODE_DUAL 2 - - /* @}*/ @@ -228,7 +226,7 @@ void neardal_destroy(); * \brief Request Neard to start polling on specific NEARDAL adapter with * specific mode * \param adpName : DBus interface adapter name (as identifier=dbus object -* path) +* path) * \param mode : Polling mode (see NEARD_ADP_MODE_...) * @return errorCode_t error code */ @@ -252,9 +250,9 @@ errorCode_t neardal_stop_poll(char *adpName); /*! \fn errorCode_t neardal_get_adapters(char ***array, int *len) * @brief get an array of NEARDAL adapters present - * + * * @param array array of DBus interface adapter name (as identifier=dbus - * object path). use @link neardal_free_adapter @endlink(& ) to free + * object path). release with @link neardal_free_adapter @endlink(& ) * @param len (optional), number of adapters * @return errorCode_t error code **/ @@ -266,7 +264,7 @@ errorCode_t neardal_get_adapters(char ***array, int *len); * @param adpName adapter name (identifier) on which devices list must be * retrieve * @param array array of DBus interface device name (as identifier=dbus object - * path), use @link neardal_free_device @endlink(& ) to free + * path), release with @link neardal_free_device @endlink(& ) * @param len (optional), number of devs * @return errorCode_t error code **/ @@ -279,7 +277,7 @@ errorCode_t neardal_get_devices(char *adpName, char ***array, int *len); * @param adpName adapter name (identifier) on which tags list must be * retrieve * @param array array of DBus interface tag name (as identifier=dbus object - * path), use @link neardal_free_tag @endlink(& ) to free + * path), release with @link neardal_free_tag @endlink(& ) * @param len (optional), number of tags * @return errorCode_t error code **/ @@ -291,7 +289,7 @@ errorCode_t neardal_get_tags(char *adpName, char ***array, int *len); * @param tagName tag name (identifier) on which records list must be * retrieve * @param array array of DBus interface record name (as identifier=dbus object - * path), use @link neardal_free_record @endlink(& ) to free + * path), release with @link neardal_free_record @endlink(& ) * @param len (optional), number of records * @return errorCode_t error code **/ diff --git a/lib/neardal_adapter.c b/lib/neardal_adapter.c index 4a4d927..59c91cc 100644 --- a/lib/neardal_adapter.c +++ b/lib/neardal_adapter.c @@ -563,7 +563,7 @@ errorCode_t neardal_adp_add(gchar *adapterName) TagProp *tagProp; gsize len; - // Check if adapter already exist in list... + /* Check if adapter already exist in list... */ err = neardal_mgr_prv_get_adapter(adapterName, NULL); if (err != NEARDAL_SUCCESS) { NEARDAL_TRACEF("Adding adapter:%s\n", adapterName); @@ -596,7 +596,7 @@ errorCode_t neardal_adp_add(gchar *adapterName) } } else NEARDAL_TRACEF("Adapter '%s' already added\n", adapterName); - + return err; } @@ -627,4 +627,3 @@ errorCode_t neardal_adp_remove(AdpProp *adpProp) return NEARDAL_SUCCESS; } - diff --git a/lib/neardal_adapter.h b/lib/neardal_adapter.h index 4f857f5..e74e17e 100644 --- a/lib/neardal_adapter.h +++ b/lib/neardal_adapter.h @@ -29,7 +29,6 @@ extern "C" { #endif /* __cplusplus */ -#define NEARD_ADP_IF_NAME "org.neard.Adapter" #define NEARD_ADP_SIG_PROPCHANGED "property-changed" #define NEARD_ADP_SIG_TAG_FOUND "tag-found" #define NEARD_ADP_SIG_TAG_LOST "tag-lost" diff --git a/lib/neardal_agent.c b/lib/neardal_agent.c index 9b3004d..51c09ff 100644 --- a/lib/neardal_agent.c +++ b/lib/neardal_agent.c @@ -29,7 +29,7 @@ static gboolean neardal_agent_prv_remove(gchar *objPath) { g_assert(objPath != NULL); - + NEARDAL_TRACEIN(); return g_dbus_object_manager_server_unexport(neardalMgr.agentMgr , objPath); @@ -49,11 +49,10 @@ static gboolean on_get_ndef(neardalNDEFAgent *ndefAgent (void) ndefAgent; /* Avoid warning */ (void) invocation; /* Avoid warning */ - + NEARDAL_TRACEIN(); NEARDAL_TRACEF("%s\n", g_variant_print(out, TRUE)); - if (agent_data != NULL) { NEARDAL_TRACEF("ndefAgent pid=%d, obj path is : %s\n" , agent_data->pid @@ -66,7 +65,7 @@ static gboolean on_get_ndef(neardalNDEFAgent *ndefAgent if (tmpOut != NULL) { rcdArray = (gchar**) g_variant_dup_strv(tmpOut , &rcdLen); - + if (rcdLen == 0) { g_strfreev(rcdArray); rcdArray = NULL; @@ -93,8 +92,7 @@ static gboolean on_get_ndef(neardalNDEFAgent *ndefAgent , agent_data->user_data); } } - -// neardal_ndefagent_complete_get_ndef(ndefAgent, invocation, out); + return TRUE; } @@ -127,30 +125,30 @@ static void on_object_removed( GDBusObjectManager *manager , gpointer user_data) { NEARDAL_TRACEIN(); - (void) manager; // avoid warning + (void) manager; /* avoid warning */ on_release( NEARDAL_NDEFAGENT(object), NULL, user_data); } static void -on_name_acquired (GDBusConnection *connection, - const gchar *name, - gpointer user_data) +on_name_acquired (GDBusConnection *connection + , const gchar *name + , gpointer user_data) { - (void) connection; // avoid warning - (void) name; // avoid warning - (void) user_data; // avoid warning + (void) connection; /* avoid warning */ + (void) name; /* avoid warning */ + (void) user_data; /* avoid warning */ NEARDAL_TRACEIN(); NEARDAL_TRACE_LOG(":%s\n", name); } static void -on_name_lost (GDBusConnection *connection, - const gchar *name, - gpointer user_data) +on_name_lost(GDBusConnection *connection + , const gchar *name + , gpointer user_data) { - (void) connection; // avoid warning - (void) name; // avoid warning - (void) user_data; // avoid warning + (void) connection; /* avoid warning */ + (void) name; /* avoid warning */ + (void) user_data; /* avoid warning */ NEARDAL_TRACEIN(); NEARDAL_TRACE_LOG(":%s\n", name); } @@ -183,11 +181,12 @@ errorCode_t neardal_ndefagent_prv_manage(neardal_agent_t agentData) ndefAgent = neardal_ndefagent_skeleton_new(); neardal_object_skeleton_set_ndefagent(objSkel, ndefAgent); - /* Handle Poke() D-Bus method invocations on the .Animal interface */ + /* Handle GetNDEF D-Bus method invocations */ g_signal_connect ( ndefAgent, "handle-get-ndef" , G_CALLBACK (on_get_ndef) , data); + /* Handle Release D-Bus method invocations */ g_signal_connect ( ndefAgent, "handle-release" , G_CALLBACK (on_release), data); @@ -195,7 +194,7 @@ errorCode_t neardal_ndefagent_prv_manage(neardal_agent_t agentData) , G_CALLBACK (on_object_removed), data); g_object_unref (ndefAgent); - /* Export the object (@manager takes its own reference to @object) */ + /* Export the object */ g_dbus_object_manager_server_export (neardalMgr.agentMgr , G_DBUS_OBJECT_SKELETON (objSkel)); g_object_unref (objSkel); @@ -222,7 +221,7 @@ errorCode_t neardal_ndefagent_prv_release(gchar *objPath) NEARDAL_TRACE("removed\n"); else NEARDAL_TRACE("not removed!\n"); - + return err; } @@ -242,32 +241,33 @@ errorCode_t neardal_agent_acquire_dbus_name(void) , NEARDAL_DBUS_WELLKNOWN_NAME , G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT | G_BUS_NAME_OWNER_FLAGS_REPLACE - , on_name_acquired // on_name_acquired - , on_name_lost // on_name_lost - , NULL // user data - , NULL); // freeing user_data func - + , on_name_acquired /* on_name_acquired */ + , on_name_lost /* on_name_lost */ + , NULL /* user data */ + , NULL); /* freeing user_data func */ + if (neardalMgr.OwnerId == 0) { err = NEARDAL_ERROR_DBUS; goto exit; } - - /* Create a new org.freedesktop.DBus.ObjectManager rooted at /example/Animals */ - neardalMgr.agentMgr = g_dbus_object_manager_server_new (NEARDAL_AGENT_PREFIX); + + /* Create a new org.neardal.ObjectManager rooted at /neardal */ + neardalMgr.agentMgr = g_dbus_object_manager_server_new(AGENT_PREFIX); if (neardalMgr.agentMgr == NULL) { err = NEARDAL_ERROR_DBUS; goto exit; } - + /* Export all objects */ - g_dbus_object_manager_server_set_connection (neardalMgr.agentMgr, neardalMgr.conn); - + g_dbus_object_manager_server_set_connection (neardalMgr.agentMgr + , neardalMgr.conn); + exit: if (err != NEARDAL_SUCCESS) NEARDAL_TRACE_ERR("(%d:%s)\n", err , neardal_error_get_text(err)); - + return err; } @@ -280,5 +280,5 @@ void neardal_agent_stop_owning_dbus_name(void) if (neardalMgr.OwnerId > 0) g_bus_unown_name (neardalMgr.OwnerId); neardalMgr.OwnerId = 0; - + } diff --git a/lib/neardal_agent.h b/lib/neardal_agent.h index 7f00b3a..edfba0c 100644 --- a/lib/neardal_agent.h +++ b/lib/neardal_agent.h @@ -27,12 +27,12 @@ extern "C" { #endif /* __cplusplus */ -#define NEARDAL_AGENT_PREFIX "/neardal" +#define AGENT_PREFIX "/neardal" typedef struct { - gchar *objPath; // agent object path - gchar *tagType; // tag Type to register + gchar *objPath; /* agent object path */ + gchar *tagType; /* tag Type to register */ gint pid; agent_cb cb_agent; gpointer user_data; diff --git a/lib/neardal_device.h b/lib/neardal_device.h index fa8aff3..87b854d 100644 --- a/lib/neardal_device.h +++ b/lib/neardal_device.h @@ -28,7 +28,6 @@ extern "C" { #endif /* __cplusplus */ -#define NEARD_DEVS_IF_NAME "org.neard.Dev" #define NEARD_DEV_SIG_PROPCHANGED "property-changed" /* NEARDAL Dev Properties */ diff --git a/lib/neardal_errors.h b/lib/neardal_errors.h index 9a59116..d03ef19 100644 --- a/lib/neardal_errors.h +++ b/lib/neardal_errors.h @@ -65,11 +65,13 @@ typedef int errorCode_t; #define NEARDAL_ERROR_NO_TAG ((errorCode_t) -9) /*! @brief Neard service, no NEARDAL record present */ #define NEARDAL_ERROR_NO_RECORD ((errorCode_t) -10) +/*! @brief Invalid record format */ +#define NEARDAL_ERROR_INVALID_RECORD ((errorCode_t) -11) /*! @brief Neard service, no NEARDAL device present */ -#define NEARDAL_ERROR_NO_DEV ((errorCode_t) -11) +#define NEARDAL_ERROR_NO_DEV ((errorCode_t) -12) /*! @brief Neard service, Error while invoking error */ -#define NEARDAL_ERROR_DBUS_INVOKE_METHOD_ERROR ((errorCode_t) -12) +#define NEARDAL_ERROR_DBUS_INVOKE_METHOD_ERROR ((errorCode_t) -13) /* @}*/ diff --git a/lib/neardal_manager.c b/lib/neardal_manager.c index 750d920..4862f59 100644 --- a/lib/neardal_manager.c +++ b/lib/neardal_manager.c @@ -124,7 +124,7 @@ static errorCode_t neardal_mgr_prv_get_all_adapters(gchar ***adpArray, NEARDAL_TRACEF("Reading:\n%s\n", g_variant_print(tmp, TRUE)); NEARDAL_TRACEF("Parsing neard adapters...\n"); - tmpOut = g_variant_lookup_value(tmp, "Adapters", + tmpOut = g_variant_lookup_value(tmp, NEARD_MGR_SECTION_ADAPTERS, G_VARIANT_TYPE_ARRAY); if (tmpOut != NULL) { *adpArray = g_variant_dup_objv(tmpOut, len); diff --git a/lib/neardal_manager.h b/lib/neardal_manager.h index e2854f3..be74992 100644 --- a/lib/neardal_manager.h +++ b/lib/neardal_manager.h @@ -29,7 +29,6 @@ extern "C" { #define NEARD_DBUS_SERVICE "org.neard" #define NEARD_MGR_PATH "/" -#define NEARD_MGR_IF_NAME "org.neard.Manager" #define NEARD_MGR_SECTION_ADAPTERS "Adapters" #define NEARD_MGR_SIG_PROPCHANGED "property-changed" #define NEARD_MGR_SIG_ADP_ADDED "adapter-added" diff --git a/lib/neardal_prv.h b/lib/neardal_prv.h index 41c6cbd..02d1aaa 100644 --- a/lib/neardal_prv.h +++ b/lib/neardal_prv.h @@ -98,10 +98,10 @@ typedef struct { extern neardalCtx neardalMgr; -// DBUS TYPE +/* DBUS TYPE */ #define NEARDAL_DBUS_TYPE G_BUS_TYPE_SYSTEM -// The well-known name to own +/* The well-known name to own */ #define NEARDAL_DBUS_WELLKNOWN_NAME "org.neardal" /*! \fn neardal_t neardal_prv_construct(errorCode_t *ec) @@ -112,8 +112,6 @@ extern neardalCtx neardalMgr; */ void neardal_prv_construct(errorCode_t *ec); - - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/lib/neardal_record.c b/lib/neardal_record.c index b474d64..ad875bb 100644 --- a/lib/neardal_record.c +++ b/lib/neardal_record.c @@ -58,6 +58,8 @@ static errorCode_t neardal_rcd_prv_read_properties(RcdProp *rcd) tmpOut = g_variant_lookup_value(tmp, "Type", G_VARIANT_TYPE_STRING); if (tmpOut != NULL) rcd->type = g_variant_dup_string(tmpOut, NULL); + else + goto error; tmpOut = g_variant_lookup_value(tmp, "Representation", G_VARIANT_TYPE_STRING); @@ -84,6 +86,9 @@ static errorCode_t neardal_rcd_prv_read_properties(RcdProp *rcd) rcd->uri = g_variant_dup_string(tmpOut, NULL); return err; +error: + /* due to error, record content will be destroyed later */ + return NEARDAL_ERROR_INVALID_RECORD; } /***************************************************************************** @@ -156,13 +161,15 @@ errorCode_t neardal_rcd_prv_format(GVariantBuilder *builder, RcdProp *rcd) /* Encoding */ if (rcd->encoding != NULL) - neardal_tools_prv_add_dict_entry(builder, "Encoding", rcd->encoding, - (int) G_TYPE_STRING); + neardal_tools_prv_add_dict_entry(builder, "Encoding" + , rcd->encoding + , (int) G_TYPE_STRING); /* Language */ if (rcd->language != NULL) - neardal_tools_prv_add_dict_entry(builder, "Language", rcd->language, - (int) G_TYPE_STRING); + neardal_tools_prv_add_dict_entry(builder, "Language" + , rcd->language + , (int) G_TYPE_STRING); /* Representation */ if (rcd->representation != NULL) diff --git a/lib/neardal_record.h b/lib/neardal_record.h index 15a56c3..2e8f1c1 100644 --- a/lib/neardal_record.h +++ b/lib/neardal_record.h @@ -27,8 +27,6 @@ extern "C" { #endif /* __cplusplus */ -#define NEARD_RECORDS_IF_NAME "org.neard.Record" - /* NEARDAL Record Properties */ typedef struct { orgNeardRcd *proxy; /* proxy to Neard NFC Record interface */ @@ -63,7 +61,7 @@ void neardal_rcd_remove(RcdProp *rcdProp); /***************************************************************************** * neardal_rcd_prv_format: Insert key/value in a GHashTable *****************************************************************************/ -errorCode_t neardal_rcd_prv_format(GVariantBuilder *builder, RcdProp *rcdProp); +errorCode_t neardal_rcd_prv_format(GVariantBuilder *builder, RcdProp *rcd); #ifdef __cplusplus } diff --git a/lib/neardal_tag.c b/lib/neardal_tag.c index e45cbce..f3fef1e 100644 --- a/lib/neardal_tag.c +++ b/lib/neardal_tag.c @@ -261,8 +261,8 @@ void neardal_tag_notify_tag_found(TagProp *tagProp) } /***************************************************************************** - * neardal_tag_prv_write: Creates and write NDEF record to be written to - * an NFC tag + * neardal_tag_prv_write: Creates and write NDEF record to be written to a NFC + * tag ****************************************************************************/ errorCode_t neardal_tag_prv_write(TagProp *tagProp, RcdProp *rcd) { diff --git a/lib/neardal_tag.h b/lib/neardal_tag.h index 5adf852..29cb2b0 100644 --- a/lib/neardal_tag.h +++ b/lib/neardal_tag.h @@ -28,7 +28,6 @@ extern "C" { #endif /* __cplusplus */ -#define NEARD_TAGS_IF_NAME "org.neard.Tag" #define NEARD_TAG_SIG_PROPCHANGED "property-changed" /* NEARDAL Tag Properties */ @@ -61,7 +60,7 @@ void neardal_tag_notify_tag_found(TagProp *tagProp); errorCode_t neardal_tag_prv_add(gchar *tagName, void *parent); /****************************************************************************** - * neardal_tag_remove: remove NEARDAL tag, unref DBus Proxy connection, + * neardal_tag_prv_remove: remove NEARDAL tag, unref DBus Proxy connection, * unregister tag signal *****************************************************************************/ void neardal_tag_prv_remove(TagProp *tagProp); diff --git a/lib/neardal_tools.c b/lib/neardal_tools.c index d2db671..14abfb6 100644 --- a/lib/neardal_tools.c +++ b/lib/neardal_tools.c @@ -88,10 +88,12 @@ GHashTable *neardal_tools_prv_create_dict(void) /***************************************************************************** * neardal_tools_prv_add_dict_entry: add an entry in a dictionnary ****************************************************************************/ -errorCode_t neardal_tools_prv_add_dict_entry(GVariantBuilder *builder, gchar *key, - void *value, int gVariantType) +errorCode_t neardal_tools_prv_add_dict_entry(GVariantBuilder *builder + , gchar *key, void *value + , int gVariantType) { - GVariant *tmp; + GVariant *tmp = NULL; + g_assert(builder != NULL); switch (gVariantType) { @@ -101,6 +103,8 @@ errorCode_t neardal_tools_prv_add_dict_entry(GVariantBuilder *builder, gchar *ke case G_TYPE_UINT: tmp = g_variant_new_uint32((guint32) value); break; + case G_TYPE_VARIANT: + tmp = (GVariant *) value; } g_variant_builder_add(builder, "{sv}", key, tmp); diff --git a/lib/neardal_tools.h b/lib/neardal_tools.h index 9c66507..3037b04 100644 --- a/lib/neardal_tools.h +++ b/lib/neardal_tools.h @@ -45,8 +45,9 @@ GHashTable *neardal_tools_prv_create_dict(void); /****************************************************************************** * neardal_tools_prv_add_dict_entry: add an entry in a dictionnary *****************************************************************************/ -errorCode_t neardal_tools_prv_add_dict_entry(GVariantBuilder *builder, gchar *key, - void *value, int gVariantType); +errorCode_t neardal_tools_prv_add_dict_entry(GVariantBuilder *builder + , gchar *key, void *value + , int gVariantType); #ifdef __cplusplus } @@ -192,7 +192,7 @@ static ncl_cmd_func ncl_prv_find_func(char *cmd) int nbClCmd; it = ncl_cmd_get_list(&nbClCmd); - if (it == NULL) + if (it == NULL || cmd == NULL) return NULL; for (index = 0; index < nbClCmd; index++) diff --git a/ncl/ncl_cmd.c b/ncl/ncl_cmd.c index 764aeda..575bd7c 100644 --- a/ncl/ncl_cmd.c +++ b/ncl/ncl_cmd.c @@ -755,8 +755,8 @@ static NCLError ncl_cmd_get_record_properties(int argc, char *argv[]) * ncl_cmd_get_record_properties : END ****************************************************************************/ /***************************************************************************** - * ncl_cmd_write : BEGIN - * write NDEF record to tag + * ncl_cmd_push : BEGIN + * Push NDEF record to device ****************************************************************************/ static NCLError ncl_cmd_push(int argc, char *argv[]) { @@ -847,7 +847,7 @@ exit: return nclErr; } /***************************************************************************** - * ncl_cmd_write : END + * ncl_cmd_push : END ****************************************************************************/ /***************************************************************************** |