target: Remove target layer
authorSamuel Ortiz <sameo@linux.intel.com>
Thu, 19 Apr 2012 11:29:43 +0000 (13:29 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 19 Apr 2012 11:29:43 +0000 (13:29 +0200)
17 files changed:
Makefile.am
doc/target-api.txt [deleted file]
include/tag.h
include/target.h [deleted file]
plugins/handover.c
plugins/mifare.c
plugins/nfctype1.c
plugins/nfctype2.c
plugins/nfctype3.c
plugins/nfctype4.c
plugins/npp.c
plugins/p2p.c
plugins/snep.c
src/main.c
src/near.h
src/target.c [deleted file]
test/dump-target [deleted file]

index 3f01b2f..88a9c80 100644 (file)
@@ -5,7 +5,7 @@ includedir = @includedir@/near
 
 include_HEADERS = include/types.h include/log.h include/plugin.h \
                        include/tag.h include/adapter.h include/ndef.h \
-                       include/target.h include/tlv.h include/setting.h
+                       include/tlv.h include/setting.h
 
 nodist_include_HEADERS = include/version.h
 
@@ -30,7 +30,7 @@ libexec_PROGRAMS = src/neard
 
 src_neard_SOURCES = $(gdbus_sources) $(gweb_sources) $(builtin_sources) \
                        src/main.c src/error.c src/near.h src/log.c \
-                       src/dbus.c src/manager.c src/adapter.c src/target.c \
+                       src/dbus.c src/manager.c src/adapter.c \
                        src/tag.c src/plugin.c src/netlink.c src/ndef.c \
                        src/tlv.c src/bluetooth.c
 
@@ -59,7 +59,7 @@ else
 build_plugindir = $(plugindir)
 endif
 
-doc_files = doc/manager-api.txt doc/target-api.txt doc/adapter-api.txt
+doc_files = doc/manager-api.txt doc/tag-api.txt doc/adapter-api.txt
 
 EXTRA_DIST = src/genbuiltin $(doc_files)
 
diff --git a/doc/target-api.txt b/doc/target-api.txt
deleted file mode 100644 (file)
index aa10039..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-Target hierarchy
-================
-
-Service                org.neard
-Interface      org.neard.Target
-Object path    [variable prefix]/{nfc0}/{target0, target1...}
-
-Method         dict GetProperties()
-
-                       Returns all properties for the device. See the
-                       properties section for available properties.
-
-                       Possible Errors: org.neard.Error.DoesNotExist
-
-               void SetProperty(string name, variant value)
-
-                       Changes the value of the specified property. Only
-                       properties that are listed a read-write are changeable.
-                       On success this will emit a PropertyChanged signal.
-
-                       Possible Errors: org.neard.Error.DoesNotExist
-                                        org.neard.Error.InvalidArguments
-
-
-Signals                PropertyChanged(string name, variant value)
-
-                       This signal indicates a changed value of the given
-                       property.
-
-
-Properties     string Type [readonly]
-
-                       The NFC target type.
-
-                       Valid types are "tag" and "device".
-
-               array{string} Protocols [readonly]
-
-                       The target supported protocols.
-                       Possible values are "Felica", "MIFARE", "Jewel",
-                       "ISO-DEP" and "NFC-DEP".
-
-               array{string} TagType [readonly]
-
-                       The tag type.
-                       Possible values are "Type 1", "Type 2", "Type 3",
-                       "Type 4" and "NFC-DEP"
-                       This is only valid for tag type targets.
-
-               array{object} Records [readonly]
-
-                       List of NDEF records object paths.
-                       This is only valid for tag type targets.
-
-               boolean ReadOnly [readonly]
-
-                       Give the current status of tag's read mode
-                       This is valid for tag type and device targets
-
-
-Record hierarchy
-================
-
-Service                org.neard
-Interface      org.neard.Record
-Object path    [variable prefix]/{nfc0}/{target0}/{record0,record1,...}
-
-Method         dict GetProperties()
-
-                       Returns all properties for the record. Each record
-                        has it's type and properties.
-
-                        If type has "Text", possible properties are "Encoding",
-                        "Language" and "Representation".
-
-                        See the properties section for available properties.
-
-                       Possible Errors: org.neard.Error.DoesNotExist
-
-Properties     string Type [readonly]
-
-                       The NDEF record type name.
-
-                       Possible values are "SmartPoster", "Text", "URI",
-                       "HandoverRequest", "HandoverSelect", "HandoverCarrier".
-
-                string Encoding [readonly]
-
-                       The character encoding.
-
-                       Possible values are "UTF-8" or "UTF-16".
-                       This property is only valid for Text and SmartPoster's
-                       title records.
-
-                string Language [readonly]
-
-                       The ISO/IANA language code (For example "en" or "jp").
-
-                       This property is only valid for Text and SmartPoster's
-                       title records.
-
-                string Representation [readonly]
-
-                       The human readable representation of a text or
-                       title record.
-
-                       This property is only valid for Text and SmartPoster's
-                       title records.
-
-               string URI [readonly]
-
-                       The record URI (for example https://nfc-forum.org).
-
-                       This is the complete URI, including the scheme and
-                       the resource.
-                       This property is only valid for SmartPoster's URI records.
-
-               string MIMEType [readonly]
-
-                       The URI object MIME type.
-
-                       This is a description of the MIME type of the object
-                       the URI points at.
-                       This is not a mandatory field and is only valid for
-                       Smart Posters carrying a URI record.
-
-               uint32 Size [readonly]
-
-                       The URI object size.
-
-                       This is the size of the object the URI points at.
-                       It should be used by applications to decide if they can
-                       afford to fetch the object or not.
-                       This is not a mandatory field and is only valid for
-                       Smart Posters carrying a URI record.
-
-               string Action [readonly]
-
-                       The suggested course of action.
-
-                       This one is only valid for Smart Posters and is a
-                       suggestion only. It can be ignored, and the possible
-                       values are "Do" (for example launch the browser),
-                       "Save" (for example save the URI in the bookmarks folder,
-                       or "Edit" (for example open the URI in an URI editor for
-                       the user to modify it.
index ba532f1..cd10276 100644 (file)
@@ -28,6 +28,8 @@
 
 #define NFC_HEADER_SIZE 1
 
+#define NFC_MAX_NFCID1_LEN 10
+
 enum near_tag_sub_type {
        NEAR_TAG_NFC_T2_MIFARE_ULTRALIGHT = 0,  // SAK 0x00
        NEAR_TAG_NFC_T2_MIFARE_CLASSIC_1K,      // SAK:0x08
diff --git a/include/target.h b/include/target.h
deleted file mode 100644 (file)
index 94d70e9..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *
- *  neard - Near Field Communication manager
- *
- *  Copyright (C) 2011  Intel Corporation. All rights reserved.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 2 as
- *  published by the Free Software Foundation.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#ifndef __NEAR_TARGET_H
-#define __NEAR_TARGET_H
-
-#include <stdint.h>
-
-#include <glib.h>
-
-#include <near/tag.h>
-
-#define NFC_MAX_NFCID1_LEN 10
-
-struct near_tag *near_target_add_tag(uint32_t adapter_idx, uint32_t target_idx,
-                                       uint8_t *data, size_t data_length);
-struct near_tag *near_target_get_tag(uint32_t adapter_idx, uint32_t target_idx);
-
-enum near_tag_sub_type near_target_get_subtype(uint32_t adapter_idx,
-                               uint32_t target_idx);
-uint8_t *near_target_get_nfcid(uint32_t adapter_idx, uint32_t target_idx,
-                               uint8_t *nfcid_len);
-
-#endif
index 9a00104..98a303b 100644 (file)
@@ -34,7 +34,6 @@
 #include <near/log.h>
 #include <near/types.h>
 #include <near/adapter.h>
-#include <near/target.h>
 #include <near/tag.h>
 #include <near/ndef.h>
 #include <near/tlv.h>
index a9e5a3e..ff0b05f 100644 (file)
@@ -35,7 +35,6 @@
 #include <near/log.h>
 #include <near/types.h>
 #include <near/adapter.h>
-#include <near/target.h>
 #include <near/tag.h>
 #include <near/ndef.h>
 #include <near/tlv.h>
index 3fa1193..de21da4 100644 (file)
@@ -35,7 +35,6 @@
 #include <near/log.h>
 #include <near/types.h>
 #include <near/adapter.h>
-#include <near/target.h>
 #include <near/tag.h>
 #include <near/ndef.h>
 #include <near/tlv.h>
index dade247..ba83091 100644 (file)
@@ -35,7 +35,6 @@
 #include <near/log.h>
 #include <near/types.h>
 #include <near/adapter.h>
-#include <near/target.h>
 #include <near/tag.h>
 #include <near/ndef.h>
 #include <near/tlv.h>
index 7929de6..0f5f0b8 100644 (file)
@@ -35,7 +35,6 @@
 #include <near/log.h>
 #include <near/types.h>
 #include <near/adapter.h>
-#include <near/target.h>
 #include <near/tag.h>
 #include <near/ndef.h>
 #include <near/tlv.h>
index 9b9f8b1..c48ec39 100644 (file)
@@ -36,7 +36,6 @@
 #include <near/log.h>
 #include <near/types.h>
 #include <near/adapter.h>
-#include <near/target.h>
 #include <near/tag.h>
 #include <near/ndef.h>
 #include <near/tlv.h>
index c03fdfa..f342bc9 100644 (file)
@@ -35,7 +35,6 @@
 #include <near/log.h>
 #include <near/types.h>
 #include <near/adapter.h>
-#include <near/target.h>
 #include <near/tag.h>
 #include <near/ndef.h>
 #include <near/tlv.h>
@@ -119,8 +118,12 @@ static near_bool_t npp_read(int client_fd,
 
        DBG("Total NDEF length %d", total_ndef_length);
 
-       tag = near_target_add_tag(adapter_idx, target_idx,
+       err = near_tag_add_data(adapter_idx, target_idx,
                                        ndefs, total_ndef_length);
+       if (err < 0)
+               return FALSE;
+
+       tag = near_tag_get_tag(adapter_idx, target_idx);
        if (tag == NULL) {
                g_free(ndefs);
                return -ENOMEM;
index 6d280c8..e1e07e2 100644 (file)
@@ -35,7 +35,7 @@
 #include <near/plugin.h>
 #include <near/log.h>
 #include <near/types.h>
-#include <near/target.h>
+#include <near/tag.h>
 #include <near/adapter.h>
 #include <near/tlv.h>
 
index a31c127..8746390 100644 (file)
@@ -35,7 +35,6 @@
 #include <near/log.h>
 #include <near/types.h>
 #include <near/adapter.h>
-#include <near/target.h>
 #include <near/tag.h>
 #include <near/ndef.h>
 #include <near/tlv.h>
@@ -157,9 +156,12 @@ static near_bool_t snep_read_ndef(int client_fd,
        }
 
        snep_response_noinfo(client_fd, SNEP_RESP_SUCCESS);
-       tag = near_target_add_tag(snep_data->adapter_idx, snep_data->target_idx,
+       if (near_tag_add_data(snep_data->adapter_idx, snep_data->target_idx,
                                        snep_data->nfc_data,
-                                       snep_data->nfc_data_length);
+                                       snep_data->nfc_data_length) < 0)
+               goto out;
+
+       tag = near_tag_get_tag(snep_data->adapter_idx, snep_data->target_idx);
        if (tag == NULL)
                goto out;
 
index b354587..447036c 100644 (file)
@@ -204,7 +204,6 @@ int main(int argc, char *argv[])
 
        __near_netlink_init();
        __near_tag_init();
-       __near_target_init();
        __near_adapter_init();
        __near_ndef_init();
        __near_manager_init(conn);
@@ -226,7 +225,6 @@ int main(int argc, char *argv[])
        __near_ndef_cleanup();
        __near_adapter_cleanup();
        __near_tag_cleanup();
-       __near_target_cleanup();
        __near_netlink_cleanup();
 
        __near_dbus_cleanup();
index 54eada3..f8391c7 100644 (file)
@@ -30,7 +30,6 @@
 #include <near/types.h>
 
 struct near_adapter;
-struct near_target;
 
 #include <near/log.h>
 
@@ -69,25 +68,6 @@ void __near_manager_adapter_remove(uint32_t idx);
 int __near_manager_init(DBusConnection *conn);
 void __near_manager_cleanup(void);
 
-#include <near/target.h>
-
-enum near_target_type {
-       NEAR_TARGET_TYPE_TAG = 0,
-       NEAR_TARGET_TYPE_DEVICE = 1,
-};
-
-const char *__near_target_get_path(struct near_target *target);
-uint16_t __near_target_get_tag_type(struct near_target *target);
-uint32_t __near_target_get_idx(struct near_target *target);
-uint32_t __near_target_get_adapter_idx(struct near_target *target);
-uint32_t __near_target_get_protocols(struct near_target *target);
-struct near_target * __near_target_add(uint32_t adapter_idx, uint32_t target_idx,
-                       uint32_t protocols, uint16_t sens_res, uint8_t sel_res,
-                       uint8_t *nfcid, uint8_t nfcid_len);
-void __near_target_remove(struct near_target *target);
-int __near_target_init(void);
-void __near_target_cleanup(void);
-
 #include <near/adapter.h>
 
 struct near_adapter * __near_adapter_create(uint32_t idx,
diff --git a/src/target.c b/src/target.c
deleted file mode 100644 (file)
index c1a7443..0000000
+++ /dev/null
@@ -1,543 +0,0 @@
-/*
- *
- *  neard - Near Field Communication manager
- *
- *  Copyright (C) 2011  Intel Corporation. All rights reserved.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License version 2 as
- *  published by the Free Software Foundation.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <string.h>
-
-#include <glib.h>
-
-#include <gdbus.h>
-
-#include "near.h"
-
-struct near_target {
-       char *path;
-
-       uint32_t idx;
-       uint32_t adapter_idx;
-       uint32_t protocols;
-       enum near_target_type type;
-       enum near_tag_sub_type sub_type;
-       uint8_t nfcid[NFC_MAX_NFCID1_LEN];
-       uint8_t nfcid_len;
-
-       uint16_t tag_type;
-       struct near_tag *tag;
-};
-
-static DBusConnection *connection = NULL;
-
-static GHashTable *target_hash;
-
-static void free_target(gpointer data)
-{
-       struct near_target *target = data;
-
-       DBG("");
-
-       if (target->tag != NULL)
-               __near_tag_free(target->tag);
-       g_free(target);
-}
-
-const char *__near_target_get_path(struct near_target *target)
-
-{
-       DBG("");
-
-       if (target == NULL)
-               return NULL;
-
-       return target->path;
-}
-
-uint16_t __near_target_get_tag_type(struct near_target *target)
-{
-       return target->tag_type;
-}
-
-uint32_t __near_target_get_idx(struct near_target *target)
-{
-       return target->idx;
-}
-
-uint32_t __near_target_get_adapter_idx(struct near_target *target)
-{
-       return target->adapter_idx;
-}
-
-uint32_t __near_target_get_protocols(struct near_target *target)
-{
-       return target->protocols;
-}
-
-static void append_protocols(DBusMessageIter *iter, void *user_data)
-{
-       struct near_target *target = user_data;
-       const char *str;
-
-       DBG("protocols 0x%x", target->protocols);
-
-       if (target->protocols & NFC_PROTO_FELICA_MASK) {
-               str = "Felica";
-
-               dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_STRING, &str);
-       }
-
-       if (target->protocols & NFC_PROTO_MIFARE_MASK) {
-               str = "MIFARE";
-
-               dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_STRING, &str);
-       }
-
-       if (target->protocols & NFC_PROTO_JEWEL_MASK) {
-               str = "Jewel";
-
-               dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_STRING, &str);
-       }
-
-       if (target->protocols & NFC_PROTO_ISO14443_MASK) {
-               str = "ISO-DEP";
-
-               dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_STRING, &str);
-       }
-
-       if (target->protocols & NFC_PROTO_NFC_DEP_MASK) {
-               str = "NFC-DEP";
-
-               dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_STRING, &str);
-       }
-}
-
-static void append_tag_type(DBusMessageIter *iter, void *user_data)
-{
-       struct near_target *target = user_data;
-       const char *str;
-
-       DBG("tag 0x%x", target->tag_type);
-
-       switch (target->tag_type) {
-       case NFC_PROTO_JEWEL:
-               str = "Type 1";
-
-               dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_STRING, &str);
-
-               break;
-
-       case NFC_PROTO_MIFARE:
-               str = "Type 2";
-
-               dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_STRING, &str);
-
-               break;
-
-       case NFC_PROTO_FELICA:
-               str = "Type 3";
-
-               dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_STRING, &str);
-
-               break;
-
-       case NFC_PROTO_ISO14443:
-               str = "Type 4";
-
-               dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_STRING, &str);
-
-               break;
-
-       case NFC_PROTO_NFC_DEP:
-               str = "NFC-DEP";
-
-               dbus_message_iter_append_basic(iter,
-                               DBUS_TYPE_STRING, &str);
-               break;
-       }
-}
-
-static const char *type2string(enum near_target_type type)
-{
-       DBG("");
-
-       switch (type) {
-       case NEAR_TARGET_TYPE_TAG:
-               return "Tag";
-       case NEAR_TARGET_TYPE_DEVICE:
-               return "Device";
-       }
-
-       return NULL;
-}
-
-static void append_records(DBusMessageIter *iter, void *user_data)
-{
-       struct near_target *target = user_data;
-
-       DBG("");
-
-       if (target->tag == NULL)
-               return;
-
-       __near_tag_append_records(target->tag, iter);
-}
-
-static DBusMessage *get_properties(DBusConnection *conn,
-                                       DBusMessage *msg, void *data)
-{
-       struct near_target *target = data;
-       DBusMessage *reply;
-       DBusMessageIter array, dict;
-       near_bool_t ronly;
-       const char *type;
-
-       DBG("conn %p", conn);
-
-       reply = dbus_message_new_method_return(msg);
-       if (reply == NULL)
-               return NULL;
-
-       type = type2string(target->type);
-
-       dbus_message_iter_init_append(reply, &array);
-
-       near_dbus_dict_open(&array, &dict);
-
-       near_dbus_dict_append_basic(&dict, "Type",
-                                   DBUS_TYPE_STRING, &type);
-
-       if (target->type == NEAR_TARGET_TYPE_DEVICE)
-               near_dbus_dict_append_array(&dict, "Protocols",
-                               DBUS_TYPE_STRING, append_protocols, target);
-
-       if (target->type == NEAR_TARGET_TYPE_TAG ||
-                       (target->type == NEAR_TARGET_TYPE_DEVICE &&
-                                       target->tag != NULL)) {
-               near_dbus_dict_append_array(&dict, "TagType",
-                               DBUS_TYPE_STRING, append_tag_type, target);
-
-               near_dbus_dict_append_array(&dict, "Records",
-                               DBUS_TYPE_OBJECT_PATH, append_records, target);
-
-               if (target->tag != NULL) {
-                       ronly = near_tag_get_ro(target->tag);
-                       near_dbus_dict_append_basic(&dict, "ReadOnly",
-                                       DBUS_TYPE_BOOLEAN, &ronly);
-               }
-       }
-
-       near_dbus_dict_close(&array, &dict);
-
-       return reply;
-}
-
-static DBusMessage *set_property(DBusConnection *conn,
-                                       DBusMessage *msg, void *data)
-{
-       DBG("conn %p", conn);
-
-       return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
-}
-
-static GDBusMethodTable target_methods[] = {
-       { "GetProperties",     "",      "a{sv}", get_properties     },
-       { "SetProperty",       "sv",    "",      set_property       },
-       { },
-};
-
-static GDBusSignalTable target_signals[] = {
-       { "PropertyChanged",            "sv"    },
-       { }
-};
-
-#define NFC_TAG_A (NFC_PROTO_ISO14443_MASK | NFC_PROTO_NFC_DEP_MASK | \
-                               NFC_PROTO_JEWEL_MASK | NFC_PROTO_MIFARE_MASK)
-#define NFC_TAG_A_TYPE2      0x00
-#define NFC_TAG_A_TYPE4      0x01
-#define NFC_TAG_A_NFC_DEP    0x02
-#define NFC_TAG_A_TYPE4_DEP  0x03
-
-#define NFC_TAG_A_SENS_RES_SSD_JEWEL      0x00
-#define NFC_TAG_A_SENS_RES_PLATCONF_JEWEL 0x0c
-
-#define NFC_TAG_A_SEL_PROT(sel_res) (((sel_res) & 0x60) >> 5)
-#define NFC_TAG_A_SEL_CASCADE(sel_res) (((sel_res) & 0x04) >> 2)
-#define NFC_TAG_A_SENS_RES_SSD(sens_res) ((sens_res) & 0x001f)
-#define NFC_TAG_A_SENS_RES_PLATCONF(sens_res) (((sens_res) & 0x0f00) >> 8)
-
-static enum near_tag_sub_type get_tag_type2_sub_type(uint8_t sel_res)
-{
-       switch(sel_res) {
-       case 0x00 :
-               return NEAR_TAG_NFC_T2_MIFARE_ULTRALIGHT;
-       case 0x08:
-               return NEAR_TAG_NFC_T2_MIFARE_CLASSIC_1K;
-       case 0x09:
-               return NEAR_TAG_NFC_T2_MIFARE_MINI;
-       case 0x18:
-               return NEAR_TAG_NFC_T2_MIFARE_CLASSIC_4K;
-       case 0x20:
-               return NEAR_TAG_NFC_T2_MIFARE_DESFIRE;
-       case 0x28 :
-               return NEAR_TAG_NFC_T2_JCOP30;
-       case 0x38:
-               return NEAR_TAG_NFC_T2_MIFARE_4K_EMUL;
-       case 0x88:
-               return NEAR_TAG_NFC_T2_MIFARE_1K_INFINEON;
-       case 0x98:
-               return NEAR_TAG_NFC_T2_MPCOS;
-       }
-
-       return NEAR_TAG_NFC_SUBTYPE_UNKNOWN;
-}
-
-static void find_tag_type(struct near_target *target,
-                               uint16_t sens_res, uint8_t sel_res)
-{
-       DBG("protocols 0x%x sens_res 0x%x sel_res 0x%x", target->protocols,
-                                                       sens_res, sel_res);
-
-       if (target->protocols & NFC_PROTO_NFC_DEP_MASK) {
-               target->tag_type = NFC_PROTO_NFC_DEP;
-       } else if (target->protocols & NFC_PROTO_JEWEL_MASK) {
-               uint8_t platconf = NFC_TAG_A_SENS_RES_PLATCONF(sens_res);
-               uint8_t ssd = NFC_TAG_A_SENS_RES_SSD(sens_res);
-
-               DBG("Jewel");
-
-               if ((ssd == NFC_TAG_A_SENS_RES_SSD_JEWEL) &&
-                               (platconf == NFC_TAG_A_SENS_RES_PLATCONF_JEWEL))
-                       target->tag_type = NFC_PROTO_JEWEL;
-       } else if (target->protocols & NFC_TAG_A) {
-               uint8_t proto = NFC_TAG_A_SEL_PROT(sel_res);
-
-               DBG("proto 0x%x", proto);
-
-               switch(proto) {
-               case NFC_TAG_A_TYPE2:
-                       target->tag_type = NFC_PROTO_MIFARE;
-                       target->sub_type = get_tag_type2_sub_type(sel_res);
-                       break;
-               case NFC_TAG_A_TYPE4:
-                       target->tag_type = NFC_PROTO_ISO14443;
-                       break;
-               case NFC_TAG_A_TYPE4_DEP:
-                       target->tag_type = NFC_PROTO_NFC_DEP;
-                       break;
-               }
-
-       } else if (target->protocols & NFC_PROTO_FELICA_MASK) {
-               target->tag_type = NFC_PROTO_FELICA;
-       } else {
-               target->tag_type = NFC_PROTO_MAX;
-       }
-
-       if (target->tag_type == NFC_PROTO_NFC_DEP)
-               target->type = NEAR_TARGET_TYPE_DEVICE;
-       else
-               target->type = NEAR_TARGET_TYPE_TAG;
-
-       DBG("tag type 0x%x", target->tag_type);
-}
-
-struct near_target *__near_target_add(uint32_t adapter_idx, uint32_t target_idx,
-                       uint32_t protocols, uint16_t sens_res, uint8_t sel_res,
-                       uint8_t *nfcid, uint8_t nfcid_len)
-{
-       struct near_target *target;
-       char *path;
-
-       path = g_strdup_printf("%s/nfc%d/target%d", NFC_PATH,
-                                       adapter_idx, target_idx);
-
-       if (path == NULL)
-               return NULL;
-
-       if (g_hash_table_lookup(target_hash, path) != NULL)
-               return NULL;
-
-       target = g_try_malloc0(sizeof(struct near_target));
-       if (target == NULL)
-               return NULL;
-
-       target->path = path;
-       target->idx = target_idx;
-       target->adapter_idx = adapter_idx;
-       target->protocols = protocols;
-       if (nfcid_len <= NFC_MAX_NFCID1_LEN) {
-               target->nfcid_len = nfcid_len;
-               memcpy(target->nfcid, nfcid, nfcid_len);
-       }
-
-       find_tag_type(target, sens_res, sel_res);
-
-       g_hash_table_insert(target_hash, path, target);
-
-       DBG("connection %p", connection);
-
-       g_dbus_register_interface(connection, target->path,
-                                       NFC_TARGET_INTERFACE,
-                                       target_methods, target_signals,
-                                                       NULL, target, NULL);
-
-       return target;
-}
-
-void __near_target_remove(struct near_target *target)
-{
-       if (g_hash_table_lookup(target_hash, target->path) == NULL)
-               return;
-
-       g_dbus_unregister_interface(connection, target->path,
-                                               NFC_TARGET_INTERFACE);
-
-       g_hash_table_remove(target_hash, target->path);
-}
-
-enum near_tag_sub_type near_target_get_subtype(uint32_t adapter_idx,
-                               uint32_t target_idx)
-
-{
-       struct near_target *target;
-       char *path;
-
-       path = g_strdup_printf("%s/nfc%d/target%d", NFC_PATH,
-                                       adapter_idx, target_idx);
-       if (path == NULL)
-               return NEAR_TAG_NFC_SUBTYPE_UNKNOWN;
-
-       target = g_hash_table_lookup(target_hash, path);
-       g_free(path);
-       if (target == NULL)
-               return NEAR_TAG_NFC_SUBTYPE_UNKNOWN;
-
-       return target->sub_type;
-}
-
-uint8_t *near_target_get_nfcid(uint32_t adapter_idx, uint32_t target_idx,
-                               uint8_t *nfcid_len)
-{
-       struct near_target *target;
-       char *path;
-       uint8_t *nfcid;
-
-       path = g_strdup_printf("%s/nfc%d/target%d", NFC_PATH,
-                                       adapter_idx, target_idx);
-       if (path == NULL)
-               goto fail;
-
-       target = g_hash_table_lookup(target_hash, path);
-       g_free(path);
-       if (target == NULL)
-               goto fail;
-
-       nfcid = g_try_malloc0(target->nfcid_len);
-       if (nfcid == NULL)
-               goto fail;
-
-       memcpy(nfcid, target->nfcid, target->nfcid_len);
-       *nfcid_len = target->nfcid_len;
-
-       return nfcid;
-
-fail:
-       *nfcid_len = 0;
-       return NULL;
-}
-
-struct near_tag *near_target_get_tag(uint32_t adapter_idx, uint32_t target_idx)
-{
-       struct near_target *target;
-       char *path;
-
-       path = g_strdup_printf("%s/nfc%d/target%d", NFC_PATH,
-                                       adapter_idx, target_idx);
-       if (path == NULL)
-               return NULL;
-
-       target = g_hash_table_lookup(target_hash, path);
-       g_free(path);
-       if (target == NULL)
-               return NULL;
-
-       return target->tag;
-}
-
-struct near_tag *near_target_add_tag(uint32_t adapter_idx, uint32_t target_idx,
-                                       uint8_t *data, size_t data_length)
-{
-       struct near_target *target;
-       char *path;
-
-       path = g_strdup_printf("%s/nfc%d/target%d", NFC_PATH,
-                                       adapter_idx, target_idx);
-       if (path == NULL)
-               return NULL;
-
-       target = g_hash_table_lookup(target_hash, path);
-       g_free(path);
-       if (target == NULL)
-               return NULL;
-
-       if (target->tag != NULL)
-               return target->tag;
-
-       target->tag = __near_tag_new(target->adapter_idx, target_idx,
-                                                       data, data_length);
-       if (target->tag == NULL)
-               return NULL;
-
-       /* TODO reference the tag, or add tag reference count API */
-       return target->tag;
-}
-
-int __near_target_init(void)
-{
-       DBG("");
-
-       connection = near_dbus_get_connection();
-
-       target_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
-                                               g_free, free_target);
-
-       return 0;
-}
-
-void __near_target_cleanup(void)
-{
-       DBG("");
-
-       g_hash_table_destroy(target_hash);
-       target_hash = NULL;
-}
diff --git a/test/dump-target b/test/dump-target
deleted file mode 100755 (executable)
index 1242636..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import dbus
-
-bus = dbus.SystemBus()
-
-def extract_list(list):
-       val = "["
-       for i in list:
-               val += " " + str(i)
-       val += " ]"
-       
-       return val
-
-def extract_record(key, list):
-       for i in list:
-               record = dbus.Interface(bus.get_object("org.neard", i),
-                                               "org.neard.Record")
-
-               properties = record.GetProperties()
-               print "        Record = [ %s ]" % (str(i))
-
-               for key in properties.keys():
-                       val = str(properties[key])
-                       print "              %s = %s" % (key, val)
-
-target = dbus.Interface(bus.get_object("org.neard", sys.argv[1]),
-                                               "org.neard.Target")
-
-properties = target.GetProperties()
-
-print "[ %s ]" % (sys.argv[1])
-
-for key in properties.keys():
-    if key in ["TagType"]:
-        val = extract_list(properties[key])
-       print "        %s = %s" % (key, val)
-    elif key in ["Type"]:
-       val = str(properties[key])
-       print "        %s = %s" % (key, val)
-
-    if key in ["Records"]:
-        extract_record(key, properties[key])
-
-