tag: ObjectManager conversion
authorSamuel Ortiz <sameo@linux.intel.com>
Sat, 26 Oct 2013 11:28:00 +0000 (13:28 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 10 Nov 2013 16:57:09 +0000 (17:57 +0100)
Set and GetProperties are no longer relevant.
Also, there is no longer any need to update the Tags and Records Adapter
properties.

Makefile.am
doc/tag-api.txt
src/adapter.c
src/near.h
src/tag.c
test/dump-tag [deleted file]
test/neardutils.py
test/test-tag [new file with mode: 0755]
test/write-tag [deleted file]

index 739f5f3..03468de 100644 (file)
@@ -79,10 +79,10 @@ EXTRA_DIST = src/genbuiltin $(doc_files)
 dist_man_MANS = doc/neard.8 doc/neard.conf.5 doc/nfctool.1
 
 test_scripts = test/test-adapter test/test-device \
-               test/dump-tag test/dump-record \
-               test/monitor-near test/write-tag \
-               test/bt-handover test/handover-agent \
-               test/phdc-simple-manager test/neardutils.py
+               test/test-tag test/dump-record \
+               test/monitor-near test/bt-handover \
+               test/handover-agent test/phdc-simple-manager \
+               test/neardutils.py
 
 if TEST
 testdir = $(pkglibdir)/test
index d11bd81..ea81af2 100644 (file)
@@ -5,23 +5,7 @@ Service                org.neard
 Interface      org.neard.Tag
 Object path    [variable prefix]/{nfc0}/{tag0, tag1...}
 
-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
-
-               void Write(dict attributes)
+Method         void Write(dict attributes)
 
                        Creates an NDEF record from the attributes dictionary.
 
@@ -35,12 +19,6 @@ Method               dict GetProperties()
                                         org.neard.Error.InProgress
 
 
-Signals                PropertyChanged(string name, variant value)
-
-                       This signal indicates a changed value of the given
-                       property.
-
-
 Properties     string Type [readonly]
 
                        The NFC tag type.
@@ -53,10 +31,6 @@ Properties   string Type [readonly]
                        Possible values are "Felica", "MIFARE", "Jewel",
                        and "ISO-DEP".
 
-               array{object} Records [readonly]
-
-                       List of NDEF records object paths.
-
                boolean ReadOnly [readonly]
 
                        Give the current status of tag's read mode
index ccef7ba..1e1fd20 100644 (file)
@@ -161,14 +161,12 @@ static int adapter_start_poll(struct near_adapter *adapter)
                DBG("Clearing tags");
 
                g_hash_table_remove_all(adapter->tags);
-               __near_adapter_tags_changed(adapter->idx);
        }
 
        if (g_hash_table_size(adapter->devices) > 0) {
                DBG("Clearing devices");
 
                g_hash_table_remove_all(adapter->devices);
-               __near_adapter_devices_changed(adapter->idx);
        }
 
        DBG("Poll mode 0x%x", adapter->poll_mode);
@@ -211,89 +209,6 @@ void __near_adapter_list(DBusMessageIter *iter, void *user_data)
        g_hash_table_foreach(adapter_hash, append_path, iter);
 }
 
-static void append_tag_path(gpointer key, gpointer value, gpointer user_data)
-{
-       struct near_tag *tag = value;
-       DBusMessageIter *iter = user_data;
-       const char *tag_path;
-
-       tag_path = __near_tag_get_path(tag);
-       if (!tag_path)
-               return;
-
-       DBG("%s", tag_path);
-
-       dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &tag_path);
-}
-
-static void append_tags(DBusMessageIter *iter, void *user_data)
-{
-       struct near_adapter *adapter = user_data;
-
-       DBG("");
-
-       g_hash_table_foreach(adapter->tags, append_tag_path, iter);
-}
-
-static void append_device_path(gpointer key, gpointer value, gpointer user_data)
-{
-       struct near_device *device = value;
-       DBusMessageIter *iter = user_data;
-       const char *device_path;
-
-       device_path = __near_device_get_path(device);
-       if (!device_path)
-               return;
-
-       DBG("%s", device_path);
-
-       dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH,
-                                                       &device_path);
-}
-
-static void append_devices(DBusMessageIter *iter, void *user_data)
-{
-       struct near_adapter *adapter = user_data;
-
-       DBG("");
-
-       g_hash_table_foreach(adapter->devices, append_device_path, iter);
-}
-
-void __near_adapter_tags_changed(uint32_t adapter_idx)
-{
-       struct near_adapter *adapter;
-
-       DBG("");
-
-       adapter = g_hash_table_lookup(adapter_hash,
-                                       GINT_TO_POINTER(adapter_idx));
-       if (!adapter)
-               return;
-
-       near_dbus_property_changed_array(adapter->path,
-                                       NFC_ADAPTER_INTERFACE, "Tags",
-                                       DBUS_TYPE_OBJECT_PATH, append_tags,
-                                       adapter);
-}
-
-void __near_adapter_devices_changed(uint32_t adapter_idx)
-{
-       struct near_adapter *adapter;
-
-       DBG("");
-
-       adapter = g_hash_table_lookup(adapter_hash,
-                                       GINT_TO_POINTER(adapter_idx));
-       if (!adapter)
-               return;
-
-       near_dbus_property_changed_array(adapter->path,
-                                       NFC_ADAPTER_INTERFACE, "Devices",
-                                       DBUS_TYPE_OBJECT_PATH, append_devices,
-                                       adapter);
-}
-
 static gboolean property_get_mode(const GDBusPropertyTable *property,
                                        DBusMessageIter *iter, void *user_data)
 {
@@ -703,8 +618,6 @@ int __near_adapter_set_dep_state(uint32_t idx, bool dep)
        } else {
                if (adapter->dep_timer > 0)
                        g_source_remove(adapter->dep_timer);
-
-               __near_adapter_devices_changed(idx);
        }
 
        return 0;
@@ -757,7 +670,6 @@ void __near_adapter_remove(struct near_adapter *adapter)
 static void tag_read_cb(uint32_t adapter_idx, uint32_t target_idx, int status)
 {
        struct near_adapter *adapter;
-       struct near_tag *tag;
 
        DBG("status %d", status);
 
@@ -774,12 +686,6 @@ static void tag_read_cb(uint32_t adapter_idx, uint32_t target_idx, int status)
                return;
        }
 
-       __near_adapter_tags_changed(adapter_idx);
-
-       tag = g_hash_table_lookup(adapter->tags, GINT_TO_POINTER(target_idx));
-       if (tag)
-               __near_tag_found_signal(adapter, tag);
-
        adapter->presence_timeout =
                g_timeout_add_seconds(CHECK_PRESENCE_PERIOD,
                                        check_presence, adapter);
@@ -920,7 +826,6 @@ int __near_adapter_add_target(uint32_t idx, uint32_t target_idx,
 int __near_adapter_remove_target(uint32_t idx, uint32_t target_idx)
 {
        struct near_adapter *adapter;
-       struct near_tag *tag;
 
        DBG("idx %d", idx);
 
@@ -931,22 +836,11 @@ int __near_adapter_remove_target(uint32_t idx, uint32_t target_idx)
        adapter->rf_mode = NEAR_ADAPTER_RF_MODE_IDLE;
        rf_mode_changed(adapter);
 
-       tag = g_hash_table_lookup(adapter->tags, GINT_TO_POINTER(target_idx));
-       if (tag) {
-               __near_tag_lost_signal(adapter, tag);
-               g_hash_table_remove(adapter->tags, GINT_TO_POINTER(target_idx));
-
-               __near_adapter_tags_changed(idx);
-
+       if (g_hash_table_remove(adapter->tags, GINT_TO_POINTER(target_idx)))
                return 0;
-       }
-
-       if (g_hash_table_remove(adapter->devices,
-                       GINT_TO_POINTER(target_idx))) {
-               __near_adapter_devices_changed(idx);
 
+       if (g_hash_table_remove(adapter->devices, GINT_TO_POINTER(target_idx)))
                return 0;
-       }
 
        return 0;
 }
@@ -972,8 +866,6 @@ int __near_adapter_add_device(uint32_t idx, uint8_t *nfcid, uint8_t nfcid_len)
        if (ret < 0)
                return ret;
 
-       __near_adapter_devices_changed(idx);
-
        return 0;
 }
 
@@ -993,7 +885,6 @@ int __near_adapter_remove_device(uint32_t idx)
 
        adapter->rf_mode = NEAR_ADAPTER_RF_MODE_IDLE;
        rf_mode_changed(adapter);
-       __near_adapter_devices_changed(idx);
 
        adapter->dep_up = false;
 
index 58a3cbe..5d09b4b 100644 (file)
@@ -90,8 +90,6 @@ int __near_adapter_add_device(uint32_t idx, uint8_t *nfcid, uint8_t nfcid_len);
 int __near_adapter_remove_device(uint32_t idx);
 int __near_adapter_set_dep_state(uint32_t idx, bool dep);
 bool __near_adapter_get_dep_state(uint32_t idx);
-void __near_adapter_tags_changed(uint32_t adapter_idx);
-void __near_adapter_devices_changed(uint32_t adapter_idx);
 void __near_adapter_listen(struct near_device_driver *driver);
 void __near_adapter_list(DBusMessageIter *iter, void *user_data);
 void __near_adapter_start_check_presence(uint32_t adapter_idx, uint32_t target_idx);
@@ -136,8 +134,6 @@ int __near_tag_write(struct near_tag *tag,
                                struct near_ndef_message *ndef,
                                near_tag_io_cb cb);
 int __near_tag_check_presence(struct near_tag *tag, near_tag_io_cb cb);
-void __near_tag_found_signal(struct near_adapter *adapter, struct near_tag *tag);
-void __near_tag_lost_signal(struct near_adapter *adapter, struct near_tag *tag);
 
 #include <near/device.h>
 
index 1d07f8b..b36fa23 100644 (file)
--- a/src/tag.c
+++ b/src/tag.c
@@ -181,98 +181,47 @@ static const char *protocol_string(struct near_tag *tag)
        return protocol;
 }
 
-static void append_properties(DBusMessageIter *iter, struct near_tag *tag)
+static gboolean property_get_type(const GDBusPropertyTable *property,
+                                       DBusMessageIter *iter, void *user_data)
 {
-       DBusMessageIter dict;
-       dbus_bool_t readonly;
-       const char *protocol, *type;
-
-       near_dbus_dict_open(iter, &dict);
-
+       struct near_tag *tag = user_data;
+       const char *type;
+       
        type = type_string(tag);
-       if (type)
-               near_dbus_dict_append_basic(&dict, "Type",
-                                       DBUS_TYPE_STRING, &type);
+       if (!type)
+               return FALSE;
 
-       protocol = protocol_string(tag);
-       if (protocol)
-               near_dbus_dict_append_basic(&dict, "Protocol",
-                                       DBUS_TYPE_STRING, &protocol);
+       dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &type);
 
-       readonly = tag->readonly;
-       near_dbus_dict_append_basic(&dict, "ReadOnly",
-                                       DBUS_TYPE_BOOLEAN, &readonly);
-
-       near_dbus_dict_append_array(&dict, "Records",
-                               DBUS_TYPE_OBJECT_PATH, append_records, tag);
-
-       near_dbus_dict_close(iter, &dict);
+       return TRUE;
 }
 
-static DBusMessage *get_properties(DBusConnection *conn,
-                                       DBusMessage *msg, void *data)
+static gboolean property_get_protocol(const GDBusPropertyTable *property,
+                                       DBusMessageIter *iter, void *user_data)
 {
-       struct near_tag *tag = data;
-       DBusMessage *reply;
-       DBusMessageIter array;
-
-       DBG("conn %p", conn);
-
-       reply = dbus_message_new_method_return(msg);
-       if (!reply)
-               return NULL;
-
-       dbus_message_iter_init_append(reply, &array);
-
-       append_properties(&array, tag);
-
-       return reply;
-}
+       struct near_tag *tag = user_data;
+       const char *protocol;
+       
+       protocol = protocol_string(tag);
+       if (!protocol)
+               return FALSE;
 
-static DBusMessage *set_property(DBusConnection *conn,
-                                       DBusMessage *msg, void *data)
-{
-       DBG("conn %p", conn);
+       dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &protocol);
 
-       return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+       return TRUE;
 }
 
-void __near_tag_found_signal(struct near_adapter *adapter,
-                                               struct near_tag *tag)
+static gboolean property_get_readonly(const GDBusPropertyTable *property,
+                                       DBusMessageIter *iter, void *user_data)
 {
-       const char *path;
-       DBusMessage *signal;
-       DBusMessageIter iter;
-
-       path = __near_adapter_get_path(adapter);
-       if (!path)
-               return;
-
-       signal = dbus_message_new_signal(path, NFC_ADAPTER_INTERFACE,
-                                                               "TagFound");
-       if (!signal)
-               return;
-
-       dbus_message_iter_init_append(signal, &iter);
-       dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
-                                                               &tag->path);
-       append_properties(&iter, tag);
-
-       dbus_connection_send(connection, signal, NULL);
-       dbus_message_unref(signal);
-}
+       struct near_tag *tag = user_data;
+       dbus_bool_t readonly;
 
-void __near_tag_lost_signal(struct near_adapter *adapter, struct near_tag *tag)
-{
-       const char *path;
+       readonly = tag->readonly;
 
-       path = __near_adapter_get_path(adapter);
-       if (!path)
-               return;
+       dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &readonly);
 
-       g_dbus_emit_signal(connection, path, NFC_ADAPTER_INTERFACE,
-                       "TagLost", DBUS_TYPE_OBJECT_PATH, &tag->path,
-                       DBUS_TYPE_INVALID);
+       return TRUE;
 }
 
 static void tag_read_cb(uint32_t adapter_idx, uint32_t target_idx, int status)
@@ -290,8 +239,6 @@ static void tag_read_cb(uint32_t adapter_idx, uint32_t target_idx, int status)
        }
 
        __near_adapter_start_check_presence(adapter_idx, target_idx);
-
-       __near_adapter_tags_changed(adapter_idx);
 }
 
 static void write_cb(uint32_t adapter_idx, uint32_t target_idx, int status)
@@ -495,24 +442,19 @@ fail:
 }
 
 static const GDBusMethodTable tag_methods[] = {
-       { GDBUS_METHOD("GetProperties",
-                               NULL, GDBUS_ARGS({"properties", "a{sv}"}),
-                               get_properties) },
-       { GDBUS_METHOD("SetProperty",
-                               GDBUS_ARGS({"name", "s"}, {"value", "v"}),
-                               NULL, set_property) },
        { GDBUS_ASYNC_METHOD("Write", GDBUS_ARGS({"attributes", "a{sv}"}),
                                                        NULL, write_ndef) },
        { },
 };
 
-static const GDBusSignalTable tag_signals[] = {
-       { GDBUS_SIGNAL("PropertyChanged",
-                               GDBUS_ARGS({"name", "s"}, {"value", "v"})) },
+static const GDBusPropertyTable tag_properties[] = {
+       { "Type", "s", property_get_type },
+       { "Protocol", "s", property_get_protocol },
+       { "ReadOnly", "b", property_get_readonly },
+
        { }
 };
 
-
 void __near_tag_append_records(struct near_tag *tag, DBusMessageIter *iter)
 {
        GList *list;
@@ -691,8 +633,8 @@ struct near_tag *__near_tag_add(uint32_t adapter_idx, uint32_t target_idx,
 
        g_dbus_register_interface(connection, tag->path,
                                        NFC_TAG_INTERFACE,
-                                       tag_methods, tag_signals,
-                                                       NULL, tag, NULL);
+                                       tag_methods, NULL,
+                                       tag_properties, tag, NULL);
 
        return tag;
 }
diff --git a/test/dump-tag b/test/dump-tag
deleted file mode 100755 (executable)
index 01652ea..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import dbus
-
-if len(sys.argv) < 2:
-       print "Usage: %s /org/neard/nfcN/tagT" % (sys.argv[0])
-       sys.exit(1)
-
-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():
-                       if key in ["Representation"]:
-                               val = unicode(properties[key])
-                       else:
-                               val = str(properties[key])
-                       print "              %s = %s" % (key, val)
-
-tag = dbus.Interface(bus.get_object("org.neard", sys.argv[1]),
-                                               "org.neard.Tag")
-
-properties = tag.GetProperties()
-
-print "[ %s ]" % (sys.argv[1])
-
-for key in properties.keys():
-    if key in ["Type"]:
-        val = str(properties[key])
-       print "        %s = %s" % (key, val)
-    elif key in ["Protocol"]:
-       val = str(properties[key])
-       print "        %s = %s" % (key, val)
-
-    if key in ["Records"]:
-        extract_record(key, properties[key])
-
index a7b2946..378277a 100644 (file)
@@ -3,6 +3,7 @@ import dbus
 SERVICE_NAME = "org.neard"
 ADAPTER_INTERFACE = SERVICE_NAME + ".Adapter"
 DEVICE_INTERFACE = SERVICE_NAME + ".Device"
+TAG_INTERFACE = SERVICE_NAME + ".Tag"
 RECORD_INTERFACE = SERVICE_NAME + ".Record"
 
 def get_managed_objects():
@@ -37,7 +38,21 @@ def find_device_in_objects(objects, pattern=None):
                if not pattern or path.endswith(pattern):
                        obj = bus.get_object(SERVICE_NAME, path)
                        return dbus.Interface(obj, DEVICE_INTERFACE)
-       raise Exception("NFC adapter not found")
+       raise Exception("NFC device not found")
+
+def find_tag(pattern=None):
+       return find_tag_in_objects(get_managed_objects(), pattern)
+
+def find_tag_in_objects(objects, pattern=None):
+       bus = dbus.SystemBus()
+       for path, ifaces in objects.iteritems():
+               tag = ifaces.get(TAG_INTERFACE)
+               if tag is None:
+                       continue
+               if not pattern or path.endswith(pattern):
+                       obj = bus.get_object(SERVICE_NAME, path)
+                       return dbus.Interface(obj, TAG_INTERFACE)
+       raise Exception("NFC tag not found")
 
 def find_record(pattern=None):
        return find_record_in_objects(get_managed_objects(), pattern)
@@ -51,4 +66,4 @@ def find_record_in_objects(objects, pattern=None):
                if not pattern or path.endswith(pattern):
                        obj = bus.get_object(SERVICE_NAME, path)
                        return dbus.Interface(obj, RECORD_INTERFACE)
-       raise Exception("NFC adapter not found")
+       raise Exception("NFC record not found")
diff --git a/test/test-tag b/test/test-tag
new file mode 100755 (executable)
index 0000000..23bcc3b
--- /dev/null
@@ -0,0 +1,124 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+import neardutils
+
+bus = dbus.SystemBus()
+
+def extract_list(list):
+       val = "["
+       for i in list:
+               val += " " + str(i)
+       val += " ]"
+       return val
+
+def usage():
+       print("Usage: %s <command>" % (sys.argv[0]) )
+       print("")
+       print("  list")
+       print("  dump <tag>")
+       print("  write <tag> <type> <...>")
+       print "         If type is Text, parameters are <encoding> <language> <representation>"
+       print "         If type is URI, parameters are <uri>"
+       print "         If type is SmartPoster, parameters are <uri>"
+       print "         If type is SMS, parameters are <phone number> <text>"
+       print "         If type is E-Mail, parameters are <e-mail address>"
+       print "         If type is MIME, and WiFi AP is passphrase protected"
+       print "            Type is MIME, parameters are wifi_wsc <ssid> <passphrase>"
+       print "         If type is MIME, and WiFi AP is open network"
+       print "            Type is MIME, parameters are wifi_wsc <ssid>"
+       print "e.g. < %s /org/neard/nfc0/tag0 Text UTF-8 en-US hello,NFC! >" % (sys.argv[0])
+       print "e.g. < %s /org/neard/nfc0/tag0 URI http://www.nfc-forum.com >" % (sys.argv[0])
+       print "e.g. < %s /org/neard/nfc0/tag0 SmartPoster http://www.nfc-forum.com >" % (sys.argv[0])
+       print "e.g. < %s /org/neard/nfc0/tag0 SMS 0102030405 YourSMSMessage >" % (sys.argv[0])
+       print "e.g. < %s /org/neard/nfc0/tag0 E-Mail test@test.com >" % (sys.argv[0])
+       print "e.g. < %s /org/neard/nfc0/tag0 MIME wifi_wsc YourAPname passphrase >" % (sys.argv[0])
+       print "e.g. < %s /org/neard/nfc0/tag0 MIME wifi_wsc YourAPname >" % (sys.argv[0])
+
+
+       sys.exit(1)
+
+if (len(sys.argv) < 2):
+       usage()
+
+if (sys.argv[1] == "list"):
+       if (len(sys.argv) < 3):
+               om = dbus.Interface(bus.get_object("org.neard", "/"),
+                                       "org.freedesktop.DBus.ObjectManager")
+               objects = om.GetManagedObjects()
+               for path, interfaces in objects.iteritems():
+                       if "org.neard.Tag" not in interfaces:
+                               continue
+
+                       print(" [ %s ]" % (path))
+
+               sys.exit(0)
+
+if (sys.argv[1] == "dump"):
+       if (len(sys.argv) < 3):
+               usage()
+       else:
+               tag_path = sys.argv[2]
+
+               om = dbus.Interface(bus.get_object("org.neard", "/"),
+                                       "org.freedesktop.DBus.ObjectManager")
+               objects = om.GetManagedObjects()
+               for path, interfaces in objects.iteritems():
+                       if "org.neard.Record" not in interfaces:
+                               continue
+
+                       if path.startswith(tag_path):
+                               print(" [ %s ]" % (path))
+
+               sys.exit(0)
+
+
+if (sys.argv[1] == "write"):
+       if (len(sys.argv) < 5):
+               usage()
+       
+       tag = neardutils.find_tag(sys.argv[2])
+
+       if sys.argv[3] in ["Text"]:
+               tag.Write(({ "Type" : "Text",
+                       "Encoding" : sys.argv[4],
+                       "Language" : sys.argv[5],
+                       "Representation" : sys.argv[6] }))
+
+       elif sys.argv[3] in ["URI"]:
+               tag.Write(({ "Type" : "URI",
+                       "URI" : sys.argv[4] }))
+
+       elif sys.argv[3] in ["SmartPoster"]:
+            tag.Write(({ "Type" : "SmartPoster",
+                       "URI" : sys.argv[4] }))
+
+       elif sys.argv[3] in ["SMS"]:
+             URI = "sms:" + sys.argv[4] + "?body=" + sys.argv[5]
+            tag.Write(({ "Type" : "URI",
+                       "URI" : URI }))
+
+       elif sys.argv[3] in ["E-Mail"]:
+             URI = "mailto:" + sys.argv[4]
+            tag.Write(({ "Type" : "URI",
+                       "URI" : URI }))
+
+       elif sys.argv[3] in ["MIME"]:
+            if len(sys.argv) == 6:
+               if sys.argv[4] in ["wifi_wsc"]:
+                       tag.Write(({ "Type" : "MIME",
+                               "MIME" : "application/vnd.wfa.wsc",
+                               "SSID" : sys.argv[5] }))
+
+            elif len(sys.argv) == 7:
+                if sys.argv[4] in ["wifi_wsc"]:
+                       tag.Write(({ "Type" : "MIME",
+                               "MIME" : "application/vnd.wfa.wsc",
+                               "SSID" : sys.argv[5],
+                               "Passphrase" : sys.argv[6] }))
+       else:
+               usage()
+
+else:
+       usage()
\ No newline at end of file
diff --git a/test/write-tag b/test/write-tag
deleted file mode 100755 (executable)
index 3635ff7..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import dbus
-
-def help_text():
-       print "Usage: %s <tag-path> <record-type> <...>" % (sys.argv[0])
-       print "         If type is Text, parameters are <encoding> <language> <representation>"
-       print "         If type is URI, parameters are <uri>"
-       print "         If type is SmartPoster, parameters are <uri>"
-       print "         If type is SMS, parameters are <phone number> <text>"
-       print "         If type is E-Mail, parameters are <e-mail address>"
-       print "         If type is MIME, and WiFi AP is passphrase protected"
-       print "            Type is MIME, parameters are wifi_wsc <ssid> <passphrase>"
-       print "         If type is MIME, and WiFi AP is open network"
-       print "            Type is MIME, parameters are wifi_wsc <ssid>"
-       print "e.g. < %s /org/neard/nfc0/tag0 Text UTF-8 en-US hello,NFC! >" % (sys.argv[0])
-       print "e.g. < %s /org/neard/nfc0/tag0 URI http://www.nfc-forum.com >" % (sys.argv[0])
-       print "e.g. < %s /org/neard/nfc0/tag0 SmartPoster http://www.nfc-forum.com >" % (sys.argv[0])
-       print "e.g. < %s /org/neard/nfc0/tag0 SMS 0102030405 YourSMSMessage >" % (sys.argv[0])
-       print "e.g. < %s /org/neard/nfc0/tag0 E-Mail test@test.com >" % (sys.argv[0])
-       print "e.g. < %s /org/neard/nfc0/tag0 MIME wifi_wsc YourAPname passphrase >" % (sys.argv[0])
-       print "e.g. < %s /org/neard/nfc0/tag0 MIME wifi_wsc YourAPname >" % (sys.argv[0])
-
-       sys.exit(1)
-
-if len(sys.argv) < 2:
-       help_text()
-
-bus = dbus.SystemBus()
-
-tag = dbus.Interface(bus.get_object("org.neard", sys.argv[1]),
-                                               "org.neard.Tag")
-
-if sys.argv[2] in ["Text"]:
-       tag.Write(({ "Type" : "Text",
-                       "Encoding" : sys.argv[3],
-                       "Language" : sys.argv[4],
-                       "Representation" : sys.argv[5] }))
-
-elif sys.argv[2] in ["URI"]:
-       tag.Write(({ "Type" : "URI",
-                       "URI" : sys.argv[3] }))
-
-elif sys.argv[2] in ["SmartPoster"]:
-       tag.Write(({ "Type" : "SmartPoster",
-                       "URI" : sys.argv[3] }))
-
-elif sys.argv[2] in ["SMS"]:
-        URI = "sms:"+sys.argv[3]+"?body="+sys.argv[4]
-       tag.Write(({ "Type" : "URI",
-                       "URI" : URI }))
-
-elif sys.argv[2] in ["E-Mail"]:
-        URI = "mailto:"+sys.argv[3]
-       tag.Write(({ "Type" : "URI",
-                       "URI" : URI }))
-
-elif sys.argv[2] in ["MIME"]:
-       if len(sys.argv) == 5:
-               if sys.argv[3] in ["wifi_wsc"]:
-                       tag.Write(({ "Type" : "MIME",
-                               "MIME" : "application/vnd.wfa.wsc",
-                               "SSID" : sys.argv[4] }))
-
-       elif len(sys.argv) == 6:
-               if sys.argv[3] in ["wifi_wsc"]:
-                       tag.Write(({ "Type" : "MIME",
-                               "MIME" : "application/vnd.wfa.wsc",
-                               "SSID" : sys.argv[4],
-                               "Passphrase" : sys.argv[5] }))
-       else:
-               help_text()
-
-else:
-       help_text()