diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2013-07-24 11:47:04 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-25 14:30:14 +0200 |
commit | b0cca9bdd0acf0865a1a5fcb0c51944d902638b1 (patch) | |
tree | 44f877493c3ee613dcb34dd9d0412d52fa3a41d9 /src/nfc | |
parent | 0f677d485e83abd1e1d6f64b6220948fed421d94 (diff) |
Remove code related to dead or currently unsupported platforms
- Removes the Meego/Maemo backend for QtNfc
- Remove Simulator, WinCE and S60 remnants from the examples
If any of these platforms becomes relevant they can be added back
of course.
Change-Id: I84712ea07f01794b622560ce77e08cee347406e3
Reviewed-by: Michael Zanetti <michael.zanetti@canonical.com>
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Alex <alexander.blasche@digia.com>
Diffstat (limited to 'src/nfc')
32 files changed, 8 insertions, 4215 deletions
diff --git a/src/nfc/maemo6/adapter_interface.cpp b/src/nfc/maemo6/adapter_interface.cpp deleted file mode 100644 index 60a8767b..00000000 --- a/src/nfc/maemo6/adapter_interface.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - * This file was generated by qdbusxml2cpp version 0.7 - * Command line was: qdbusxml2cpp -p adapter_interface_p.h:adapter_interface.cpp com.nokia.nfc.Adapter.xml - * - * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ - -#include "adapter_interface_p.h" - -/* - * Implementation of interface class ComNokiaNfcAdapterInterface - */ - -ComNokiaNfcAdapterInterface::ComNokiaNfcAdapterInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) - : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) -{ -} - -ComNokiaNfcAdapterInterface::~ComNokiaNfcAdapterInterface() -{ -} - diff --git a/src/nfc/maemo6/adapter_interface_p.h b/src/nfc/maemo6/adapter_interface_p.h deleted file mode 100644 index 27fbd252..00000000 --- a/src/nfc/maemo6/adapter_interface_p.h +++ /dev/null @@ -1,192 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - * This file was generated by qdbusxml2cpp version 0.7 and then hand edited - * Command line was: qdbusxml2cpp -p adapter_interface_p.h:adapter_interface.cpp com.nokia.nfc.Adapter.xml - * - * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). - * - */ - -#ifndef ADAPTER_INTERFACE_P_H -#define ADAPTER_INTERFACE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/QObject> -#include <QtCore/QByteArray> -#include <QtCore/QList> -#include <QtCore/QMap> -#include <QtCore/QString> -#include <QtCore/QStringList> -#include <QtCore/QVariant> -#include <QtDBus/QtDBus> - -/* - * Proxy class for interface com.nokia.nfc.Adapter - */ -class ComNokiaNfcAdapterInterface: public QDBusAbstractInterface -{ - Q_OBJECT -public: - static inline const char *staticInterfaceName() - { return "com.nokia.nfc.Adapter"; } - -public: - ComNokiaNfcAdapterInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); - - ~ComNokiaNfcAdapterInterface(); - - Q_PROPERTY(bool Discovering READ discovering) - inline bool discovering() { - QDBusReply<QVariantMap> reply = GetProperties(); - if (!reply.isValid()) - return false; - - return reply.value().value(QLatin1String("Discovering")).toBool(); - } - - Q_PROPERTY(QString State READ state WRITE setState) - inline QString state() { - QDBusReply<QVariantMap> reply = GetProperties(); - if (!reply.isValid()) - return QString(); - - return reply.value().value(QLatin1String("State")).toString(); - } - - inline void setState(const QString &value) - { SetProperty(QLatin1String("State"), QDBusVariant(qVariantFromValue(value))); } - - Q_PROPERTY(QStringList TagTechnologies READ tagTechnologies) - inline QStringList tagTechnologies() - { - QDBusReply<QVariantMap> reply = GetProperties(); - if (!reply.isValid()) - return QStringList(); - - return reply.value().value(QLatin1String("TagTechnologies")).toStringList(); - } - -public Q_SLOTS: // METHODS - inline QDBusPendingReply<> CancelAccessRequest(const QDBusObjectPath &in0, const QString &in1) - { - QList<QVariant> argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); - return asyncCallWithArgumentList(QLatin1String("CancelAccessRequest"), argumentList); - } - - inline QDBusPendingReply<> CancelHandoverRequest(const QString &in0) - { - QList<QVariant> argumentList; - argumentList << QVariant::fromValue(in0); - return asyncCallWithArgumentList(QLatin1String("CancelHandoverRequest"), argumentList); - } - - inline QDBusPendingReply<QVariantMap> GetProperties() - { - QList<QVariant> argumentList; - return asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList); - } - - inline QDBusPendingReply<> RegisterUIAgent(const QDBusObjectPath &in0) - { - QList<QVariant> argumentList; - argumentList << QVariant::fromValue(in0); - return asyncCallWithArgumentList(QLatin1String("RegisterUIAgent"), argumentList); - } - - inline QDBusPendingReply<> RequestAccess(const QDBusObjectPath &in0, const QString &in1) - { - QList<QVariant> argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); - return asyncCallWithArgumentList(QLatin1String("RequestAccess"), argumentList); - } - - inline QDBusPendingReply<> RequestHandover(const QDBusObjectPath &in0, const QString &in1, const QString &in2) - { - QList<QVariant> argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1) << QVariant::fromValue(in2); - return asyncCallWithArgumentList(QLatin1String("RequestHandover"), argumentList); - } - - inline QDBusPendingReply<> SetProperty(const QString &in0, const QDBusVariant &in1) - { - QList<QVariant> argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); - return asyncCallWithArgumentList(QLatin1String("SetProperty"), argumentList); - } - - inline QDBusPendingReply<> UnregisterUIAgent(const QDBusObjectPath &in0) - { - QList<QVariant> argumentList; - argumentList << QVariant::fromValue(in0); - return asyncCallWithArgumentList(QLatin1String("UnregisterUIAgent"), argumentList); - } - -Q_SIGNALS: // SIGNALS - void HandoverCarrierSelected(const QString &in0); - void HandoverCompleted(const QString &in0, const QDBusVariant &in1); - void HandoverFailed(const QString &in0); - void HandoverStarted(); - void PropertyChanged(const QString &in0, const QDBusVariant &in1); - void TargetDetected(const QDBusObjectPath &in0); - void TargetLost(const QDBusObjectPath &in0); -}; - -namespace com { - namespace nokia { - namespace nfc { - typedef ::ComNokiaNfcAdapterInterface Adapter; - } - } -} -#endif diff --git a/src/nfc/maemo6/com.nokia.nfc.AccessRequestor.xml b/src/nfc/maemo6/com.nokia.nfc.AccessRequestor.xml deleted file mode 100644 index 655448d2..00000000 --- a/src/nfc/maemo6/com.nokia.nfc.AccessRequestor.xml +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node name="/foo"> - <interface name="com.nokia.nfc.AccessRequestor"> - <method name="AccessFailed"> - <arg type="o" direction="in"/> - <arg type="s" direction="in"/> - <arg type="s" direction="in"/> - </method> - <method name="AccessGranted"> - <arg type="o" direction="in"/> - <arg type="s" direction="in"/> - </method> - </interface> -</node> diff --git a/src/nfc/maemo6/com.nokia.nfc.Adapter.xml b/src/nfc/maemo6/com.nokia.nfc.Adapter.xml deleted file mode 100644 index 3e3d3c85..00000000 --- a/src/nfc/maemo6/com.nokia.nfc.Adapter.xml +++ /dev/null @@ -1,59 +0,0 @@ -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node name="/com/nokia/nfc/0/nfc0"> - <interface name="com.nokia.nfc.Adapter"> - <method name="GetProperties"> - <arg type="a{sv}" direction="out"/> - <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/> - </method> - <method name="SetProperty"> - <arg type="s" direction="in"/> - <arg type="v" direction="in"/> - </method> - <method name="RequestHandover"> - <arg type="o" direction="in"/> - <arg type="s" direction="in"/> - <arg type="s" direction="in"/> - </method> - <method name="CancelHandoverRequest"> - <arg type="s" direction="in"/> - </method> - <method name="RequestAccess"> - <arg type="o" direction="in"/> - <arg type="s" direction="in"/> - </method> - <method name="CancelAccessRequest"> - <arg type="o" direction="in"/> - <arg type="s" direction="in"/> - </method> - <method name="RegisterUIAgent"> - <arg type="o" direction="in"/> - </method> - <method name="UnregisterUIAgent"> - <arg type="o" direction="in"/> - </method> - <signal name="PropertyChanged"> - <arg type="s"/> - <arg type="v"/> - </signal> - <signal name="TargetDetected"> - <arg type="o"/> - </signal> - <signal name="TargetLost"> - <arg type="o"/> - </signal> - <signal name="HandoverStarted"/> - <signal name="HandoverCarrierSelected"> - <arg type="s"/> - </signal> - <signal name="HandoverCompleted"> - <arg type="s"/> - <arg type="v"/> - </signal> - <signal name="HandoverFailed"> - <arg type="s"/> - </signal> - <property name="State" type="s" access="readwrite"/> - <property name="Discovering" type="b" access="read"/> - <property name="TagTechnologies" type="as" access="read"/> - </interface> -</node> diff --git a/src/nfc/maemo6/com.nokia.nfc.Device.xml b/src/nfc/maemo6/com.nokia.nfc.Device.xml deleted file mode 100644 index 17acc5d0..00000000 --- a/src/nfc/maemo6/com.nokia.nfc.Device.xml +++ /dev/null @@ -1,19 +0,0 @@ -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node name="/com/nokia/nfc/0/nfc0/target_DE_AD_BE_EF"> - <interface name="com.nokia.nfc.Device"> - <method name="GetProperties"> - <arg type="a{sv}" direction="out"/> - <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/> - </method> - <method name="SetProperty"> - <arg type="s" direction="in"/> - <arg type="v" direction="in"/> - </method> - <signal name="PropertyChanged"> - <arg type="s"/> - <arg type="v"/> - </signal> - <property name="UID" type="s" access="read"/> - </interface> -</node> - diff --git a/src/nfc/maemo6/com.nokia.nfc.LLCPRequestor.xml b/src/nfc/maemo6/com.nokia.nfc.LLCPRequestor.xml deleted file mode 100644 index cf4f625a..00000000 --- a/src/nfc/maemo6/com.nokia.nfc.LLCPRequestor.xml +++ /dev/null @@ -1,22 +0,0 @@ -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node name="/foo"> - <interface name="com.nokia.nfc.LLCPRequestor"> - <method name="Accept"> - <arg type="v" direction="in"/> - <arg type="v" direction="in"/> - <arg type="h" direction="in"/> - <arg type="a{sv}" direction="in"/> - </method> - <method name="Connect"> - <arg type="v" direction="in"/> - <arg type="v" direction="in"/> - <arg type="h" direction="in"/> - <arg type="a{sv}" direction="in"/> - </method> - <method name="Socket"> - <arg type="v" direction="in"/> - <arg type="h" direction="in"/> - <arg type="a{sv}" direction="in"/> - </method> - </interface> -</node> diff --git a/src/nfc/maemo6/com.nokia.nfc.Manager.xml b/src/nfc/maemo6/com.nokia.nfc.Manager.xml deleted file mode 100644 index cdc8fae8..00000000 --- a/src/nfc/maemo6/com.nokia.nfc.Manager.xml +++ /dev/null @@ -1,47 +0,0 @@ -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node name="/"> - <interface name="com.nokia.nfc.Manager"> - <method name="GetProperties"> - <arg type="a{sv}" direction="out"/> - <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/> - </method> - <method name="SetProperty"> - <arg type="s" direction="in"/> - <arg type="v" direction="in"/> - </method> - <method name="ListAdapters"> - <arg type="ao" direction="out"/> - </method> - <method name="FindAdapter"> - <arg type="s" direction="in"/> - <arg type="o" direction="out"/> - </method> - <method name="DefaultAdapter"> - <arg type="o" direction="out"/> - </method> - <method name="RegisterNDEFHandler"> - <arg type="s" direction="in"/> - <arg type="s" direction="in"/> - <arg type="o" direction="in"/> - <arg type="s" direction="in"/> - <arg type="s" direction="in"/> - <arg type="s" direction="in"/> - </method> - <method name="UnregisterNDEFHandler"> - <arg type="s" direction="in"/> - <arg type="s" direction="in"/> - <arg type="o" direction="in"/> - </method> - <signal name="AdapterAdded"> - <arg type="o"/> - </signal> - <signal name="AdapterRemoved"> - <arg type="o"/> - </signal> - <signal name="DefaultAdapterChanged"> - <arg type="o"/> - </signal> - <property name="LogLevel" type="s" access="readwrite"/> - </interface> -</node> - diff --git a/src/nfc/maemo6/com.nokia.nfc.NDEFHandler.xml b/src/nfc/maemo6/com.nokia.nfc.NDEFHandler.xml deleted file mode 100644 index 8b4fdd45..00000000 --- a/src/nfc/maemo6/com.nokia.nfc.NDEFHandler.xml +++ /dev/null @@ -1,10 +0,0 @@ -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node name="/foo"> - <interface name="com.nokia.nfc.NDEFHandler"> - <method name="NDEFData"> - <arg type="o" direction="in"/> - <arg type="ay" direction="in"/> - </method> - </interface> -</node> - diff --git a/src/nfc/maemo6/com.nokia.nfc.SecureElement.xml b/src/nfc/maemo6/com.nokia.nfc.SecureElement.xml deleted file mode 100644 index 702f3b2a..00000000 --- a/src/nfc/maemo6/com.nokia.nfc.SecureElement.xml +++ /dev/null @@ -1,34 +0,0 @@ -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node name="/com/nokia/nfc/0/nfc0/se0"> - <interface name="com.nokia.nfc.SecureElement"> - <method name="GetProperties"> - <arg type="a{sv}" direction="out"/> - <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/> - </method> - <method name="RequestAccess"/> - <method name="ReleaseAccess"/> - <method name="Activate"/> - <method name="Deactivate"/> - <method name="SetActivationLevel"> - <arg type="v" direction="in"/> - </method> - <method name="RawRequest"> - <arg type="ay" direction="in"/> - <arg type="ay" direction="out"/> - </method> - <signal name="PropertyChanged"> - <arg type="s"/> - <arg type="v"/> - </signal> - <signal name="TransactionStarted"> - <arg type="s"/> - </signal> - <signal name="TransactionEnded"> - <arg type="s"/> - <arg type="s"/> - </signal> - <property name="State" type="s" access="read"/> - <property name="ActivationLevel" type="s" access="read"/> - </interface> -</node> - diff --git a/src/nfc/maemo6/com.nokia.nfc.Tag.xml b/src/nfc/maemo6/com.nokia.nfc.Tag.xml deleted file mode 100644 index 4d24850f..00000000 --- a/src/nfc/maemo6/com.nokia.nfc.Tag.xml +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node name="/com/nokia/nfc/0/nfc0/target_DE_AD_BE_EF"> - <interface name="com.nokia.nfc.Tag"> - <method name="GetProperties"> - <arg type="a{sv}" direction="out"/> - <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/> - </method> - <method name="SetProperty"> - <arg type="s" direction="in"/> - <arg type="v" direction="in"/> - </method> - <method name="ReadNDEFData"> - <arg type="aay" direction="out"/> - <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QList<QByteArray>"/> - </method> - <method name="WriteNDEFData"> - <arg type="aay" direction="in"/> - <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QList<QByteArray>"/> - </method> - <signal name="PropertyChanged"> - <arg type="s"/> - <arg type="v"/> - </signal> - <property name="UID" type="s" access="read"/> - <property name="Technology" type="s" access="read"/> - </interface> -</node> - diff --git a/src/nfc/maemo6/com.nokia.nfc.Target.xml b/src/nfc/maemo6/com.nokia.nfc.Target.xml deleted file mode 100644 index a5fa2308..00000000 --- a/src/nfc/maemo6/com.nokia.nfc.Target.xml +++ /dev/null @@ -1,20 +0,0 @@ -<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> -<node name="/com/nokia/nfc/0/nfc0/target_DE_AD_BE_EF"> - <interface name="com.nokia.nfc.Target"> - <method name="GetProperties"> - <arg type="a{sv}" direction="out"/> - <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/> - </method> - <method name="SetProperty"> - <arg type="s" direction="in"/> - <arg type="v" direction="in"/> - </method> - <signal name="PropertyChanged"> - <arg type="s"/> - <arg type="v"/> - </signal> - <property name="Type" type="s" access="read"/> - <property name="State" type="s" access="read"/> - </interface> -</node> - diff --git a/src/nfc/maemo6/device_interface.cpp b/src/nfc/maemo6/device_interface.cpp deleted file mode 100644 index ed67eaf5..00000000 --- a/src/nfc/maemo6/device_interface.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - * This file was generated by qdbusxml2cpp version 0.7 - * Command line was: qdbusxml2cpp -p device_interface_p.h:device_interface.cpp com.nokia.nfc.Device.xml - * - * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ - -#include "device_interface_p.h" - -/* - * Implementation of interface class ComNokiaNfcDeviceInterface - */ - -ComNokiaNfcDeviceInterface::ComNokiaNfcDeviceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) - : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) -{ -} - -ComNokiaNfcDeviceInterface::~ComNokiaNfcDeviceInterface() -{ -} - diff --git a/src/nfc/maemo6/device_interface_p.h b/src/nfc/maemo6/device_interface_p.h deleted file mode 100644 index ae02dbbd..00000000 --- a/src/nfc/maemo6/device_interface_p.h +++ /dev/null @@ -1,122 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - * This file was generated by qdbusxml2cpp version 0.7 and then hand edited - * Command line was: qdbusxml2cpp -p device_interface_p.h:device_interface.cpp com.nokia.nfc.Device.xml - * - * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). - * - */ - -#ifndef DEVICE_INTERFACE_P_H -#define DEVICE_INTERFACE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/QObject> -#include <QtCore/QByteArray> -#include <QtCore/QList> -#include <QtCore/QMap> -#include <QtCore/QString> -#include <QtCore/QStringList> -#include <QtCore/QVariant> -#include <QtDBus/QtDBus> - -/* - * Proxy class for interface com.nokia.nfc.Device - */ -class ComNokiaNfcDeviceInterface: public QDBusAbstractInterface -{ - Q_OBJECT -public: - static inline const char *staticInterfaceName() - { return "com.nokia.nfc.Device"; } - -public: - ComNokiaNfcDeviceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); - - ~ComNokiaNfcDeviceInterface(); - - Q_PROPERTY(QString UID READ uID) - inline QString uID() { - QDBusReply<QVariantMap> reply = GetProperties(); - if (!reply.isValid()) - return QString(); - - return reply.value().value(QLatin1String("UID")).toString(); - } - -public Q_SLOTS: // METHODS - inline QDBusPendingReply<QVariantMap> GetProperties() - { - QList<QVariant> argumentList; - return asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList); - } - - inline QDBusPendingReply<> SetProperty(const QString &in0, const QDBusVariant &in1) - { - QList<QVariant> argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); - return asyncCallWithArgumentList(QLatin1String("SetProperty"), argumentList); - } - -Q_SIGNALS: // SIGNALS - void PropertyChanged(const QString &in0, const QDBusVariant &in1); -}; - -namespace com { - namespace nokia { - namespace nfc { - typedef ::ComNokiaNfcDeviceInterface Device; - } - } -} -#endif diff --git a/src/nfc/maemo6/generate b/src/nfc/maemo6/generate deleted file mode 100755 index fa7260d5..00000000 --- a/src/nfc/maemo6/generate +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -qdbusxml2cpp -p adapter_interface_p.h:adapter_interface.cpp com.nokia.nfc.Adapter.xml - -qdbusxml2cpp -p target_interface_p.h:target_interface.cpp com.nokia.nfc.Target.xml -qdbusxml2cpp -p tag_interface_p.h:tag_interface.cpp com.nokia.nfc.Tag.xml -qdbusxml2cpp -p device_interface_p.h:device_interface.cpp com.nokia.nfc.Device.xml - diff --git a/src/nfc/maemo6/socketrequestor.cpp b/src/nfc/maemo6/socketrequestor.cpp deleted file mode 100644 index ea023dc4..00000000 --- a/src/nfc/maemo6/socketrequestor.cpp +++ /dev/null @@ -1,704 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "socketrequestor_p.h" - -#include <QtCore/QMutex> -#include <QtCore/QHash> -#include <QtCore/QSocketNotifier> -#include <QtCore/QStringList> -#include <QtCore/QElapsedTimer> -#include <QtCore/QCoreApplication> -#include <QtDBus/QDBusObjectPath> - -#include <dbus/dbus.h> - -#include <sys/select.h> -#include <errno.h> - -struct WatchNotifier -{ - DBusWatch *watch; - QSocketNotifier *readNotifier; - QSocketNotifier *writeNotifier; -}; - -static QVariant getVariantFromDBusMessage(DBusMessageIter *iter) -{ - dbus_bool_t bool_data; - dbus_int32_t int32_data; - dbus_uint32_t uint32_data; - dbus_int64_t int64_data; - dbus_uint64_t uint64_data; - char *str_data; - char char_data; - int argtype = dbus_message_iter_get_arg_type(iter); - - switch (argtype) { - case DBUS_TYPE_BOOLEAN: { - dbus_message_iter_get_basic(iter, &bool_data); - QVariant variant((bool)bool_data); - return variant; - } - case DBUS_TYPE_ARRAY: { - // Handle all arrays here - int elem_type = dbus_message_iter_get_element_type(iter); - DBusMessageIter array_iter; - - dbus_message_iter_recurse(iter, &array_iter); - - if (elem_type == DBUS_TYPE_BYTE) { - QByteArray byte_array; - do { - dbus_message_iter_get_basic(&array_iter, &char_data); - byte_array.append(char_data); - } while (dbus_message_iter_next(&array_iter)); - QVariant variant(byte_array); - return variant; - } else if (elem_type == DBUS_TYPE_STRING) { - QStringList str_list; - do { - dbus_message_iter_get_basic(&array_iter, &str_data); - str_list.append(str_data); - } while (dbus_message_iter_next(&array_iter)); - QVariant variant(str_list); - return variant; - } else { - QVariantList variantList; - do { - variantList << getVariantFromDBusMessage(&array_iter); - } while (dbus_message_iter_next(&array_iter)); - QVariant variant(variantList); - return variant; - } - break; - } - case DBUS_TYPE_BYTE: { - dbus_message_iter_get_basic(iter, &char_data); - QChar ch(char_data); - QVariant variant(ch); - return variant; - } - case DBUS_TYPE_INT32: { - dbus_message_iter_get_basic(iter, &int32_data); - QVariant variant((int)int32_data); - return variant; - } - case DBUS_TYPE_UINT32: { - dbus_message_iter_get_basic(iter, &uint32_data); - QVariant variant((uint)uint32_data); - return variant; - } - case DBUS_TYPE_OBJECT_PATH: - case DBUS_TYPE_STRING: { - dbus_message_iter_get_basic(iter, &str_data); - QString str(str_data); - QVariant variant(str); - return variant; - } - case DBUS_TYPE_INT64: { - dbus_message_iter_get_basic(iter, &int64_data); - QVariant variant((qlonglong)int64_data); - return variant; - } - case DBUS_TYPE_UINT64: { - dbus_message_iter_get_basic(iter, &uint64_data); - QVariant variant((qulonglong)uint64_data); - return variant; - } - case DBUS_TYPE_DICT_ENTRY: - case DBUS_TYPE_STRUCT: { - // Handle all structs here - DBusMessageIter struct_iter; - dbus_message_iter_recurse(iter, &struct_iter); - - QVariantList variantList; - do { - variantList << getVariantFromDBusMessage(&struct_iter); - } while (dbus_message_iter_next(&struct_iter)); - QVariant variant(variantList); - return variant; - } - case DBUS_TYPE_VARIANT: { - DBusMessageIter variant_iter; - dbus_message_iter_recurse(iter, &variant_iter); - - return getVariantFromDBusMessage(&variant_iter); - } - case DBUS_TYPE_UNIX_FD: { - dbus_message_iter_get_basic(iter, &uint32_data); - QVariant variant((uint)uint32_data); - return variant; - } - - default: - qWarning("Unsupported DBUS type: %d\n", argtype); - } - - return QVariant(); -} - -class SocketRequestorPrivate : public QObject -{ - Q_OBJECT - -public: - SocketRequestorPrivate(); - ~SocketRequestorPrivate(); - - DBusHandlerResult messageFilter(DBusConnection *connection, DBusMessage *message); - void addWatch(DBusWatch *watch); - - void registerObject(const QString &path, SocketRequestor *object); - void unregisterObject(const QString &path); - - Q_INVOKABLE void sendRequestAccess(const QString &adaptor, const QString &path, - const QString &kind); - Q_INVOKABLE void sendCancelAccessRequest(const QString &adaptor, const QString &path, - const QString &kind); - - bool waitForDBusSignal(int msecs); - -private: - bool parseAccessFailed(DBusMessage *message, SocketRequestor *socketRequestor); - bool parseAccessGranted(DBusMessage *message, SocketRequestor *socketRequestor); - bool parseAcceptConnect(DBusMessage *message, SocketRequestor *socketRequestor, - const char *member); - bool parseSocket(DBusMessage *message, SocketRequestor *socketRequestor, const char *member); - bool parseErrorDenied(DBusMessage *message, SocketRequestor *socketRequestor); - -private slots: - void socketRead(); - void socketWrite(); - -private: - QMutex m_mutex; - DBusConnection *m_dbusConnection; - QHash<QString, SocketRequestor *> m_dbusObjects; - QMap<quint32, SocketRequestor *> m_pendingCalls; - QList<WatchNotifier> m_watchNotifiers; -}; - -Q_GLOBAL_STATIC(SocketRequestorPrivate, socketRequestorPrivate) - -static DBusHandlerResult dbusFilter(DBusConnection *connection, DBusMessage *message, - void *userData) -{ - SocketRequestorPrivate *s = static_cast<SocketRequestorPrivate *>(userData); - return s->messageFilter(connection, message); -} - -static dbus_bool_t dbusWatch(DBusWatch *watch, void *data) -{ - SocketRequestorPrivate *s = static_cast<SocketRequestorPrivate *>(data); - s->addWatch(watch); - - return true; -} - -SocketRequestorPrivate::SocketRequestorPrivate() -{ - DBusError error; - dbus_error_init(&error); - m_dbusConnection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error); - dbus_connection_add_filter(m_dbusConnection, &dbusFilter, this, 0); - dbus_connection_set_watch_functions(m_dbusConnection, dbusWatch, 0, 0, this, 0); - dbus_error_free(&error); -} - -SocketRequestorPrivate::~SocketRequestorPrivate() -{ - dbus_connection_close(m_dbusConnection); - dbus_connection_unref(m_dbusConnection); -} - -DBusHandlerResult SocketRequestorPrivate::messageFilter(DBusConnection *connection, - DBusMessage *message) -{ - QMutexLocker locker(&m_mutex); - - foreach (const WatchNotifier &watchNotifier, m_watchNotifiers) - watchNotifier.writeNotifier->setEnabled(true); - - if (connection != m_dbusConnection) - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - - SocketRequestor *socketRequestor; - const QString path = QString::fromUtf8(dbus_message_get_path(message)); - quint32 serial = dbus_message_get_reply_serial(message); - if (!path.isEmpty() && serial == 0) - socketRequestor = m_dbusObjects.value(path); - else if (path.isEmpty() && serial != 0) - socketRequestor = m_pendingCalls.take(serial); - else - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - - enum { - NotHandled, - Handled, - HandledSendReply - } handled; - - if (dbus_message_is_method_call(message, "com.nokia.nfc.AccessRequestor", "AccessFailed")) - handled = parseAccessFailed(message, socketRequestor) ? HandledSendReply : NotHandled; - else if (dbus_message_is_method_call(message, "com.nokia.nfc.AccessRequestor", "AccessGranted")) - handled = parseAccessGranted(message, socketRequestor) ? HandledSendReply : NotHandled; - else if (dbus_message_is_method_call(message, "com.nokia.nfc.LLCPRequestor", "Accept")) - handled = parseAcceptConnect(message, socketRequestor, "accept") ? HandledSendReply : NotHandled; - else if (dbus_message_is_method_call(message, "com.nokia.nfc.LLCPRequestor", "Connect")) - handled = parseAcceptConnect(message, socketRequestor, "connect") ? HandledSendReply : NotHandled; - else if (dbus_message_is_method_call(message, "com.nokia.nfc.LLCPRequestor", "Socket")) - handled = parseSocket(message, socketRequestor, "socket") ? HandledSendReply : NotHandled; - else if (dbus_message_is_error(message, "com.nokia.nfc.Error.Denied")) - handled = parseErrorDenied(message, socketRequestor) ? Handled : NotHandled; - else - handled = NotHandled; - - if (handled == NotHandled) - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - - if (handled == HandledSendReply) { - DBusMessage *reply = dbus_message_new_method_return(message); - quint32 serial; - dbus_connection_send(connection, reply, &serial); - } - - return DBUS_HANDLER_RESULT_HANDLED; -} - -bool SocketRequestorPrivate::parseErrorDenied(DBusMessage *message, - SocketRequestor *socketRequestor) -{ - Q_UNUSED(message); - - QMetaObject::invokeMethod(socketRequestor, "accessFailed", - Q_ARG(QDBusObjectPath, QDBusObjectPath()), - Q_ARG(QString, QLatin1String("")), - Q_ARG(QString, QLatin1String("Access denied"))); - return true; -} - -bool SocketRequestorPrivate::parseAccessFailed(DBusMessage *message, - SocketRequestor *socketRequestor) -{ - Q_UNUSED(message); - - // m_mutex is locked in messageFilter() - - DBusMessageIter args; - - if (!dbus_message_iter_init(message, &args)) - return false; - - // read DBus Object Path - QVariant objectPath = getVariantFromDBusMessage(&args); - - if (!dbus_message_iter_next(&args)) - return false; - - // read DBus kind string - QVariant kind = getVariantFromDBusMessage(&args); - - if (!dbus_message_iter_next(&args)) - return false; - - // read DBus error string - QVariant errorString = getVariantFromDBusMessage(&args); - - QMetaObject::invokeMethod(socketRequestor, "accessFailed", - Q_ARG(QDBusObjectPath, QDBusObjectPath(objectPath.toString())), - Q_ARG(QString, kind.toString()), - Q_ARG(QString, errorString.toString())); - return true; -} - -bool SocketRequestorPrivate::parseAccessGranted(DBusMessage *message, - SocketRequestor *socketRequestor) -{ - Q_UNUSED(message); - - // m_mutex is locked in messageFilter() - - DBusMessageIter args; - - if (!dbus_message_iter_init(message, &args)) - return false; - - // read DBus Object Path - QVariant objectPath = getVariantFromDBusMessage(&args); - - if (!dbus_message_iter_next(&args)) - return false; - - // read access kind - QVariant kind = getVariantFromDBusMessage(&args); - - QMetaObject::invokeMethod(socketRequestor, "accessGranted", - Q_ARG(QDBusObjectPath, QDBusObjectPath(objectPath.toString())), - Q_ARG(QString, kind.toString())); - return true; -} - -bool SocketRequestorPrivate::parseAcceptConnect(DBusMessage *message, - SocketRequestor *socketRequestor, - const char *member) -{ - // m_mutex is locked in messageFilter() - - DBusMessageIter args; - - if (!dbus_message_iter_init(message, &args)) - return false; - - // read DBus Variant (lsap) - QVariant lsap = getVariantFromDBusMessage(&args); - - if (!dbus_message_iter_next(&args)) - return false; - // read DBus Variant (rsap) - QVariant rsap = getVariantFromDBusMessage(&args); - - if (!dbus_message_iter_next(&args)) - return false; - - // read socket fd - QVariant fd = getVariantFromDBusMessage(&args); - - if (!dbus_message_iter_next(&args)) - return false; - - // read DBus a{sv} into QVariantMap - QVariant prop = getVariantFromDBusMessage(&args); - QVariantMap properties; - foreach (const QVariant &v, prop.toList()) { - QVariantList vl = v.toList(); - if (vl.length() != 2) - continue; - - properties.insert(vl.first().toString(), vl.at(1)); - } - - QMetaObject::invokeMethod(socketRequestor, member, Q_ARG(QDBusVariant, QDBusVariant(lsap)), - Q_ARG(QDBusVariant, QDBusVariant(rsap)), - Q_ARG(int, fd.toInt()), Q_ARG(QVariantMap, properties)); - - return true; -} - -bool SocketRequestorPrivate::parseSocket(DBusMessage *message, SocketRequestor *socketRequestor, - const char *member) -{ - // m_mutex is locked in messageFilter() - - DBusMessageIter args; - - if (!dbus_message_iter_init(message, &args)) - return false; - - // read DBus Variant (lsap) - QVariant lsap = getVariantFromDBusMessage(&args); - - if (!dbus_message_iter_next(&args)) - return false; - - // read socket fd - QVariant fd = getVariantFromDBusMessage(&args); - - if (!dbus_message_iter_next(&args)) - return false; - - // read DBus a{sv} into QVariantMap - QVariant prop = getVariantFromDBusMessage(&args); - QVariantMap properties; - foreach (const QVariant &v, prop.toList()) { - QVariantList vl = v.toList(); - if (vl.length() != 2) - continue; - - properties.insert(vl.first().toString(), vl.at(1)); - } - - QMetaObject::invokeMethod(socketRequestor, member, Q_ARG(QDBusVariant, QDBusVariant(lsap)), - Q_ARG(int, fd.toInt()), Q_ARG(QVariantMap, properties)); - - return true; -} - -void SocketRequestorPrivate::addWatch(DBusWatch *watch) -{ - QMutexLocker locker(&m_mutex); - - int fd = dbus_watch_get_unix_fd(watch); - - WatchNotifier watchNotifier; - watchNotifier.watch = watch; - - watchNotifier.readNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); - connect(watchNotifier.readNotifier, SIGNAL(activated(int)), this, SLOT(socketRead())); - watchNotifier.writeNotifier = new QSocketNotifier(fd, QSocketNotifier::Write, this); - connect(watchNotifier.writeNotifier, SIGNAL(activated(int)), this, SLOT(socketWrite())); - - m_watchNotifiers.append(watchNotifier); -} - -void SocketRequestorPrivate::socketRead() -{ - QMutexLocker locker(&m_mutex); - - QList<DBusWatch *> pendingWatches; - - foreach (const WatchNotifier &watchNotifier, m_watchNotifiers) { - if (watchNotifier.readNotifier != sender()) - continue; - - pendingWatches.append(watchNotifier.watch); - } - - DBusConnection *connection = m_dbusConnection; - locker.unlock(); - - foreach (DBusWatch *watch, pendingWatches) - dbus_watch_handle(watch, DBUS_WATCH_READABLE); - - while (dbus_connection_dispatch(connection) == DBUS_DISPATCH_DATA_REMAINS); -} - -void SocketRequestorPrivate::socketWrite() -{ - QMutexLocker locker(&m_mutex); - - QList<DBusWatch *> pendingWatches; - - foreach (const WatchNotifier &watchNotifier, m_watchNotifiers) { - if (watchNotifier.writeNotifier != sender()) - continue; - - watchNotifier.writeNotifier->setEnabled(false); - pendingWatches.append(watchNotifier.watch); - } - - locker.unlock(); - - foreach (DBusWatch *watch, pendingWatches) - dbus_watch_handle(watch, DBUS_WATCH_WRITABLE); -} - -void SocketRequestorPrivate::registerObject(const QString &path, SocketRequestor *object) -{ - QMutexLocker locker(&m_mutex); - - m_dbusObjects.insert(path, object); -} - -void SocketRequestorPrivate::unregisterObject(const QString &path) -{ - QMutexLocker locker(&m_mutex); - - m_dbusObjects.remove(path); -} - -void SocketRequestorPrivate::sendRequestAccess(const QString &adaptor, const QString &path, - const QString &kind) -{ - QMutexLocker locker(&m_mutex); - - foreach (const WatchNotifier &watchNotifier, m_watchNotifiers) - watchNotifier.writeNotifier->setEnabled(true); - - DBusMessage *message; - DBusMessageIter args; - - message = dbus_message_new_method_call("com.nokia.nfc", adaptor.toLocal8Bit(), - "com.nokia.nfc.Adapter", "RequestAccess"); - - if (!message) - return; - - dbus_message_iter_init_append(message, &args); - const QByteArray p = path.toUtf8(); - const char *pData = p.constData(); - if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_OBJECT_PATH, &pData)) { - dbus_message_unref(message); - return; - } - - const QByteArray k = kind.toUtf8(); - const char *kData = k.constData(); - if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &kData)) { - dbus_message_unref(message); - return; - } - - quint32 serial; - dbus_connection_send(m_dbusConnection, message, &serial); - - dbus_message_unref(message); - - m_pendingCalls.insert(serial, m_dbusObjects.value(path)); -} - -void SocketRequestorPrivate::sendCancelAccessRequest(const QString &adaptor, const QString &path, - const QString &kind) -{ - QMutexLocker locker(&m_mutex); - - foreach (const WatchNotifier &watchNotifier, m_watchNotifiers) - watchNotifier.writeNotifier->setEnabled(true); - - DBusMessage *message; - DBusMessageIter args; - - message = dbus_message_new_method_call("com.nokia.nfc", adaptor.toLocal8Bit(), - "com.nokia.nfc.Adapter", "CancelAccessRequest"); - - if (!message) - return; - - dbus_message_iter_init_append(message, &args); - const QByteArray p = path.toUtf8(); - const char *pData = p.constData(); - if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_OBJECT_PATH, &pData)) { - dbus_message_unref(message); - return; - } - - const QByteArray k = kind.toUtf8(); - const char *kData = k.constData(); - if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &kData)) { - dbus_message_unref(message); - return; - } - - quint32 serial; - dbus_connection_send(m_dbusConnection, message, &serial); - - dbus_message_unref(message); -} - -bool SocketRequestorPrivate::waitForDBusSignal(int msecs) -{ - dbus_connection_flush(m_dbusConnection); - - fd_set rfds; - FD_ZERO(&rfds); - - int nfds = -1; - foreach (const WatchNotifier &watchNotifier, m_watchNotifiers) { - FD_SET(watchNotifier.readNotifier->socket(), &rfds); - nfds = qMax(nfds, watchNotifier.readNotifier->socket()); - } - - timeval timeout; - timeout.tv_sec = msecs / 1000; - timeout.tv_usec = (msecs % 1000) * 1000; - - // timeout can not be 0 or else select will return an error - if (msecs == 0) - timeout.tv_usec = 1000; - - int result = -1; - // on Linux timeout will be updated by select, but _not_ on other systems - result = ::select(nfds + 1, &rfds, 0, 0, &timeout); - if (result == -1 && errno != EINTR) - return false; - - foreach (const WatchNotifier &watchNotifier, m_watchNotifiers) { - if (FD_ISSET(watchNotifier.readNotifier->socket(), &rfds)) { - QMetaObject::invokeMethod(watchNotifier.readNotifier, "activated", - Q_ARG(int, watchNotifier.readNotifier->socket())); - } - } - - return true; -} - - -SocketRequestor::SocketRequestor(const QString &adaptor, QObject *parent) -: QObject(parent), m_adaptor(adaptor) -{ - - -} - -SocketRequestor::~SocketRequestor() -{ -} - -void SocketRequestor::requestAccess(const QString &path, const QString &kind) -{ - SocketRequestorPrivate *s = socketRequestorPrivate(); - - s->registerObject(path, this); - - QMetaObject::invokeMethod(s, "sendRequestAccess", Qt::QueuedConnection, - Q_ARG(QString, m_adaptor), Q_ARG(QString, path), - Q_ARG(QString, kind)); -} - -void SocketRequestor::cancelAccessRequest(const QString &path, const QString &kind) -{ - SocketRequestorPrivate *s = socketRequestorPrivate(); - - s->unregisterObject(path); - - QMetaObject::invokeMethod(s, "sendCancelAccessRequest", Qt::QueuedConnection, - Q_ARG(QString, m_adaptor), Q_ARG(QString, path), - Q_ARG(QString, kind)); -} - -bool SocketRequestor::waitForDBusSignal(int msecs) -{ - SocketRequestorPrivate *s = socketRequestorPrivate(); - - // Send queued method calls, i.e. requestAccess() and cancelAccessRequest(). - QCoreApplication::sendPostedEvents(s, QEvent::MetaCall); - - // Wait for DBus signal. - bool result = socketRequestorPrivate()->waitForDBusSignal(msecs); - - // Send queued method calls, i.e. those from DBus. - QCoreApplication::sendPostedEvents(this, QEvent::MetaCall); - - return result; -} - -#include <moc_socketrequestor_p.cpp> -#include <socketrequestor.moc> diff --git a/src/nfc/maemo6/socketrequestor_p.h b/src/nfc/maemo6/socketrequestor_p.h deleted file mode 100644 index 5f4bed8b..00000000 --- a/src/nfc/maemo6/socketrequestor_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - The private API defined in this file is temporary. It should be removed when Qt can handle - passing unix file descriptors over DBus. Most likely in Qt 4.8. -*/ - -#ifndef SOCKETREQUESTOR_P_H -#define SOCKETREQUESTOR_P_H - -#include <qconnectivityglobal.h> - -#include <QtCore/QObject> -#include <QtCore/QVariantMap> - -QT_FORWARD_DECLARE_CLASS(QDBusObjectPath) -QT_FORWARD_DECLARE_CLASS(QDBusVariant) - -class DBusConnection; - -class SocketRequestor : public QObject -{ - Q_OBJECT - -public: - explicit SocketRequestor(const QString &adaptor, QObject *parent = 0); - ~SocketRequestor(); - - void requestAccess(const QString &path, const QString &kind); - void cancelAccessRequest(const QString &path, const QString &kind); - - bool waitForDBusSignal(int msecs); - -signals: - void accessFailed(const QDBusObjectPath &targetPath, const QString &kind, - const QString &error); - void accessGranted(const QDBusObjectPath &targetPath, const QString &accessKind); - - void accept(const QDBusVariant &lsap, const QDBusVariant &rsap, int fd, const QVariantMap &properties); - void connect(const QDBusVariant &lsap, const QDBusVariant &rsap, int fd, const QVariantMap &properties); - void socket(const QDBusVariant &lsap, int fd, const QVariantMap &properties); - -private: - const QString m_adaptor; -}; - -#endif // SOCKETREQUESTOR_P_H diff --git a/src/nfc/maemo6/tag_interface.cpp b/src/nfc/maemo6/tag_interface.cpp deleted file mode 100644 index f604806c..00000000 --- a/src/nfc/maemo6/tag_interface.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - * This file was generated by qdbusxml2cpp version 0.7 - * Command line was: qdbusxml2cpp -p tag_interface_p.h:tag_interface.cpp com.nokia.nfc.Tag.xml - * - * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ - -#include "tag_interface_p.h" - -/* - * Implementation of interface class ComNokiaNfcTagInterface - */ - -ComNokiaNfcTagInterface::ComNokiaNfcTagInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) - : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) -{ -} - -ComNokiaNfcTagInterface::~ComNokiaNfcTagInterface() -{ -} - diff --git a/src/nfc/maemo6/tag_interface_p.h b/src/nfc/maemo6/tag_interface_p.h deleted file mode 100644 index d1db832c..00000000 --- a/src/nfc/maemo6/tag_interface_p.h +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - * This file was generated by qdbusxml2cpp version 0.7 and then hand edited - * Command line was: qdbusxml2cpp -p tag_interface_p.h:tag_interface.cpp com.nokia.nfc.Tag.xml - * - * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). - * - */ - -#ifndef TAG_INTERFACE_P_H -#define TAG_INTERFACE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/QObject> -#include <QtCore/QByteArray> -#include <QtCore/QList> -#include <QtCore/QMap> -#include <QtCore/QString> -#include <QtCore/QStringList> -#include <QtCore/QVariant> -#include <QtDBus/QtDBus> - -Q_DECLARE_METATYPE(QList<QByteArray>) - -/* - * Proxy class for interface com.nokia.nfc.Tag - */ -class ComNokiaNfcTagInterface: public QDBusAbstractInterface -{ - Q_OBJECT -public: - static inline const char *staticInterfaceName() - { return "com.nokia.nfc.Tag"; } - -public: - ComNokiaNfcTagInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); - - ~ComNokiaNfcTagInterface(); - - Q_PROPERTY(uint Size READ size) - inline uint size() - { - QDBusReply<QVariantMap> reply = GetProperties(); - if (!reply.isValid()) - return 0; - - return reply.value().value(QLatin1String("Size")).toUInt(); - } - - Q_PROPERTY(QString Technology READ technology) - inline QString technology() - { - QDBusReply<QVariantMap> reply = GetProperties(); - if (!reply.isValid()) - return QString(); - - return reply.value().value(QLatin1String("Technology")).toString(); - } - - Q_PROPERTY(QString UID READ uID) - inline QString uID() - { - QDBusReply<QVariantMap> reply = GetProperties(); - if (!reply.isValid()) - return QString(); - - return reply.value().value(QLatin1String("UID")).toString(); - } - -public Q_SLOTS: // METHODS - inline QDBusPendingReply<QVariantMap> GetProperties() - { - QList<QVariant> argumentList; - return asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList); - } - - inline QDBusPendingReply<QList<QByteArray> > ReadNDEFData() - { - QList<QVariant> argumentList; - return asyncCallWithArgumentList(QLatin1String("ReadNDEFData"), argumentList); - } - - inline QDBusPendingReply<> SetProperty(const QString &in0, const QDBusVariant &in1) - { - QList<QVariant> argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); - return asyncCallWithArgumentList(QLatin1String("SetProperty"), argumentList); - } - - inline QDBusPendingReply<> WriteNDEFData(const QList<QByteArray> &in0) - { - QList<QVariant> argumentList; - argumentList << QVariant::fromValue(in0); - return asyncCallWithArgumentList(QLatin1String("WriteNDEFData"), argumentList); - } - -Q_SIGNALS: // SIGNALS - void PropertyChanged(const QString &in0, const QDBusVariant &in1); -}; - -namespace com { - namespace nokia { - namespace nfc { - typedef ::ComNokiaNfcTagInterface Tag; - } - } -} -#endif diff --git a/src/nfc/maemo6/target_interface.cpp b/src/nfc/maemo6/target_interface.cpp deleted file mode 100644 index de045412..00000000 --- a/src/nfc/maemo6/target_interface.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - * This file was generated by qdbusxml2cpp version 0.7 - * Command line was: qdbusxml2cpp -p target_interface_p.h:target_interface.cpp com.nokia.nfc.Target.xml - * - * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). - * - * This is an auto-generated file. - * This file may have been hand-edited. Look for HAND-EDIT comments - * before re-generating it. - */ - -#include "target_interface_p.h" - -/* - * Implementation of interface class ComNokiaNfcTargetInterface - */ - -ComNokiaNfcTargetInterface::ComNokiaNfcTargetInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) - : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) -{ -} - -ComNokiaNfcTargetInterface::~ComNokiaNfcTargetInterface() -{ -} - diff --git a/src/nfc/maemo6/target_interface_p.h b/src/nfc/maemo6/target_interface_p.h deleted file mode 100644 index ea8fc28a..00000000 --- a/src/nfc/maemo6/target_interface_p.h +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* - * This file was generated by qdbusxml2cpp version 0.7 and then hand edited - * Command line was: qdbusxml2cpp -p target_interface_p.h:target_interface.cpp com.nokia.nfc.Target.xml - * - * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). - * - */ - -#ifndef TARGET_INTERFACE_P_H -#define TARGET_INTERFACE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtCore/QObject> -#include <QtCore/QByteArray> -#include <QtCore/QList> -#include <QtCore/QMap> -#include <QtCore/QString> -#include <QtCore/QStringList> -#include <QtCore/QVariant> -#include <QtDBus/QtDBus> - -/* - * Proxy class for interface com.nokia.nfc.Target - */ -class ComNokiaNfcTargetInterface: public QDBusAbstractInterface -{ - Q_OBJECT -public: - static inline const char *staticInterfaceName() - { return "com.nokia.nfc.Target"; } - -public: - ComNokiaNfcTargetInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); - - ~ComNokiaNfcTargetInterface(); - - Q_PROPERTY(QString State READ state) - inline QString state() - { - QDBusReply<QVariantMap> reply = GetProperties(); - if (!reply.isValid()) - return QString(); - - return reply.value().value(QLatin1String("State")).toString(); - } - - Q_PROPERTY(QString Type READ type) - inline QString type() - { - QDBusReply<QVariantMap> reply = GetProperties(); - if (!reply.isValid()) - return QString(); - - return reply.value().value(QLatin1String("Type")).toString(); - } - -public Q_SLOTS: // METHODS - inline QDBusPendingReply<QVariantMap> GetProperties() - { - QList<QVariant> argumentList; - return asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList); - } - - inline QDBusPendingReply<> SetProperty(const QString &in0, const QDBusVariant &in1) - { - QList<QVariant> argumentList; - argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); - return asyncCallWithArgumentList(QLatin1String("SetProperty"), argumentList); - } - -Q_SIGNALS: // SIGNALS - void PropertyChanged(const QString &in0, const QDBusVariant &in1); -}; - -namespace com { - namespace nokia { - namespace nfc { - typedef ::ComNokiaNfcTargetInterface Target; - } - } -} -#endif diff --git a/src/nfc/nfc.pro b/src/nfc/nfc.pro index 7313b327..b0c261a8 100644 --- a/src/nfc/nfc.pro +++ b/src/nfc/nfc.pro @@ -50,63 +50,6 @@ SOURCES += \ qdeclarativendefrecord.cpp \ qndefnfcsmartposterrecord.cpp -maemo6|meego { - NFC_BACKEND_AVAILABLE = yes - - QT *= dbus - - DBUS_INTERFACES += \ - maemo6/com.nokia.nfc.Manager.xml - - DBUS_ADAPTORS += \ - maemo6/com.nokia.nfc.AccessRequestor.xml \ - maemo6/com.nokia.nfc.NDEFHandler.xml - - # work around bug in Qt - dbus_interface_source.depends = ${QMAKE_FILE_OUT_BASE}.h - dbus_adaptor_source.depends = ${QMAKE_FILE_OUT_BASE}.h - - # Link against libdbus until Qt has support for passing file descriptors over DBus. - CONFIG += link_pkgconfig - DEFINES += DBUS_API_SUBJECT_TO_CHANGE - PKGCONFIG += dbus-1 - - PRIVATE_HEADERS += \ - qnearfieldmanager_maemo6_p.h \ - qnearfieldtarget_maemo6_p.h \ - qllcpsocket_maemo6_p.h \ - qllcpserver_maemo6_p.h \ - maemo6/adapter_interface_p.h \ - maemo6/target_interface_p.h \ - maemo6/tag_interface_p.h \ - maemo6/device_interface_p.h \ - maemo6/socketrequestor_p.h - - SOURCES += \ - qnearfieldmanager_maemo6.cpp \ - qnearfieldtarget_maemo6.cpp \ - qllcpsocket_maemo6_p.cpp \ - qllcpserver_maemo6_p.cpp \ - maemo6/adapter_interface.cpp \ - maemo6/target_interface.cpp \ - maemo6/tag_interface.cpp \ - maemo6/device_interface.cpp \ - maemo6/socketrequestor.cpp - - OTHER_FILES += \ - $$DBUS_INTERFACES \ - $$DBUS_ADAPTORS \ - maemo6/com.nokia.nfc.Adapter.xml \ - maemo6/com.nokia.nfc.Target.xml \ - maemo6/com.nokia.nfc.Tag.xml \ - maemo6/com.nokia.nfc.Device.xml \ - maemo6/com.nokia.nfc.LLCPRequestor.xml - - # Add OUT_PWD to INCLUDEPATH so that creator picks up headers for generated files - # This is not needed for the build otherwise. - INCLUDEPATH += $$OUT_PWD -} - qnx { NFC_BACKEND_AVAILABLE = yes DEFINES += QNX_NFC #QQNXNFC_DEBUG diff --git a/src/nfc/qllcpserver.cpp b/src/nfc/qllcpserver.cpp index 993fd375..a1041236 100644 --- a/src/nfc/qllcpserver.cpp +++ b/src/nfc/qllcpserver.cpp @@ -43,8 +43,6 @@ #if defined(QT_SIMULATOR) #include "qllcpserver_simulator_p.h" -#elif defined(Q_WS_MAEMO_6) || defined(Q_WS_MEEGO) -#include "qllcpserver_maemo6_p.h" #elif defined(QNX_NFC) #include "qllcpserver_qnx_p.h" #else diff --git a/src/nfc/qllcpserver_maemo6_p.cpp b/src/nfc/qllcpserver_maemo6_p.cpp deleted file mode 100644 index 87cb2d4b..00000000 --- a/src/nfc/qllcpserver_maemo6_p.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qllcpserver_maemo6_p.h" - -#include "manager_interface.h" -#include "maemo6/adapter_interface_p.h" -#include "qllcpsocket_maemo6_p.h" -#include "maemo6/socketrequestor_p.h" - -using namespace com::nokia::nfc; - -QT_BEGIN_NAMESPACE_NFC - -static QAtomicInt requestorId = 0; -static const char * const requestorBasePath = "/com/nokia/nfc/llcpserver/"; - -QLlcpServerPrivate::QLlcpServerPrivate(QLlcpServer *q) -: q_ptr(q), - m_connection(QDBusConnection::connectToBus(QDBusConnection::SystemBus, QUuid::createUuid())), - m_socketRequestor(0) -{ -} - -bool QLlcpServerPrivate::listen(const QString &serviceUri) -{ - if (m_requestorPath.isEmpty()) { - m_requestorPath = QLatin1String(requestorBasePath) + - QString::number(requestorId.fetchAndAddOrdered(1)); - } - - Manager manager(QLatin1String("com.nokia.nfc"), QLatin1String("/"), m_connection); - QDBusObjectPath defaultAdapterPath = manager.DefaultAdapter(); - - if (!m_socketRequestor) { - m_socketRequestor = new SocketRequestor(defaultAdapterPath.path(), this); - - connect(m_socketRequestor, SIGNAL(accessFailed(QDBusObjectPath,QString,QString)), - this, SLOT(AccessFailed(QDBusObjectPath,QString,QString))); - connect(m_socketRequestor, SIGNAL(accessGranted(QDBusObjectPath,QString)), - this, SLOT(AccessGranted(QDBusObjectPath,QString))); - connect(m_socketRequestor, SIGNAL(accept(QDBusVariant,QDBusVariant,int,QVariantMap)), - this, SLOT(Accept(QDBusVariant,QDBusVariant,int,QVariantMap))); - connect(m_socketRequestor, SIGNAL(connect(QDBusVariant,QDBusVariant,int,QVariantMap)), - this, SLOT(Connect(QDBusVariant,QDBusVariant,int,QVariantMap))); - connect(m_socketRequestor, SIGNAL(socket(QDBusVariant,int,QVariantMap)), - this, SLOT(Socket(QDBusVariant,int,QVariantMap))); - } - - if (m_socketRequestor) { - QString accessKind(QLatin1String("device.llcp.co.server:") + serviceUri); - m_socketRequestor->requestAccess(m_requestorPath, accessKind); - - m_serviceUri = serviceUri; - } else { - m_error = QLlcpSocket::SocketResourceError; - - m_serviceUri.clear(); - } - - return !m_serviceUri.isEmpty(); -} - -bool QLlcpServerPrivate::isListening() const -{ - return !m_serviceUri.isEmpty(); -} - -void QLlcpServerPrivate::close() -{ - QString accessKind(QLatin1String("device.llcp.co.server:") + m_serviceUri); - - m_socketRequestor->cancelAccessRequest(m_requestorPath, accessKind); - - m_serviceUri.clear(); -} - -QString QLlcpServerPrivate::serviceUri() const -{ - return m_serviceUri; -} - -quint8 QLlcpServerPrivate::serverPort() const -{ - return 0; -} - -bool QLlcpServerPrivate::hasPendingConnections() const -{ - return !m_pendingSockets.isEmpty(); -} - -QLlcpSocket *QLlcpServerPrivate::nextPendingConnection() -{ - if (m_pendingSockets.isEmpty()) - return 0; - - QPair<int, QVariantMap> parameters = m_pendingSockets.takeFirst(); - - QLlcpSocketPrivate *socketPrivate = - new QLlcpSocketPrivate(m_connection, parameters.first, parameters.second); - - QLlcpSocket *socket = new QLlcpSocket(socketPrivate, 0); - - return socket; -} - -QLlcpSocket::SocketError QLlcpServerPrivate::serverError() const -{ - return QLlcpSocket::UnknownSocketError; -} - -void QLlcpServerPrivate::AccessFailed(const QDBusObjectPath &targetPath, const QString &kind, - const QString &error) -{ - Q_UNUSED(targetPath); - Q_UNUSED(kind); - Q_UNUSED(error); - - m_serviceUri.clear(); - - m_error = QLlcpSocket::SocketAccessError; -} - -void QLlcpServerPrivate::AccessGranted(const QDBusObjectPath &targetPath, - const QString &accessKind) -{ - Q_UNUSED(targetPath); - Q_UNUSED(accessKind); -} - -void QLlcpServerPrivate::Accept(const QDBusVariant &lsap, const QDBusVariant &rsap, - int fd, const QVariantMap &properties) -{ - Q_UNUSED(lsap); - Q_UNUSED(rsap); - Q_UNUSED(properties); - - Q_Q(QLlcpServer); - - m_pendingSockets.append(qMakePair(fd, properties)); - - emit q->newConnection(); -} - -void QLlcpServerPrivate::Connect(const QDBusVariant &lsap, const QDBusVariant &rsap, - int readFd, const QVariantMap &properties) -{ - Q_UNUSED(lsap); - Q_UNUSED(rsap); - Q_UNUSED(readFd); - Q_UNUSED(properties); -} - -void QLlcpServerPrivate::Socket(const QDBusVariant &lsap, int fd, const QVariantMap &properties) -{ - Q_UNUSED(lsap); - Q_UNUSED(fd); - Q_UNUSED(properties); -} - -QT_END_NAMESPACE_NFC diff --git a/src/nfc/qllcpserver_maemo6_p.h b/src/nfc/qllcpserver_maemo6_p.h deleted file mode 100644 index 59727011..00000000 --- a/src/nfc/qllcpserver_maemo6_p.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QLLCPSERVER_MAEMO6_P_H -#define QLLCPSERVER_MAEMO6_P_H - -#include <qconnectivityglobal.h> - -#include "qllcpserver.h" - -#include <QtDBus/QDBusConnection> - -QT_FORWARD_DECLARE_CLASS(QDBusObjectPath) -QT_FORWARD_DECLARE_CLASS(QDBusVariant) - -class AccessRequestorAdaptor; -class LLCPRequestorAdaptor; - -QT_BEGIN_NAMESPACE_NFC - -class SocketRequestor; - -class QLlcpServerPrivate : public QObject -{ - Q_OBJECT - - Q_DECLARE_PUBLIC(QLlcpServer) - -public: - QLlcpServerPrivate(QLlcpServer *q); - - bool listen(const QString &serviceUri); - bool isListening() const; - - void close(); - - QString serviceUri() const; - quint8 serverPort() const; - - bool hasPendingConnections() const; - QLlcpSocket *nextPendingConnection(); - - QLlcpSocket::SocketError serverError() const; - -private slots: - // com.nokia.nfc.AccessRequestor - void AccessFailed(const QDBusObjectPath &targetPath, const QString &kind, - const QString &error); - void AccessGranted(const QDBusObjectPath &targetPath, const QString &accessKind); - - // com.nokia.nfc.LLCPRequestor - void Accept(const QDBusVariant &lsap, const QDBusVariant &rsap, int fd, - const QVariantMap &properties); - void Connect(const QDBusVariant &lsap, const QDBusVariant &rsap, int fd, - const QVariantMap &properties); - void Socket(const QDBusVariant &lsap, int fd, const QVariantMap &properties); - -private: - QLlcpServer *q_ptr; - - QDBusConnection m_connection; - - QString m_serviceUri; - - QString m_requestorPath; - SocketRequestor *m_socketRequestor; - - QList<QPair<int, QVariantMap> > m_pendingSockets; - - QLlcpSocket::SocketError m_error; -}; - -QT_END_NAMESPACE_NFC - -#endif // QLLCPSERVER_MAEMO6_P_H diff --git a/src/nfc/qllcpsocket.cpp b/src/nfc/qllcpsocket.cpp index 5a7cbbed..8626395d 100644 --- a/src/nfc/qllcpsocket.cpp +++ b/src/nfc/qllcpsocket.cpp @@ -43,8 +43,6 @@ #if defined(QT_SIMULATOR) #include "qllcpsocket_simulator_p.h" -#elif defined(Q_WS_MAEMO_6) || defined(Q_WS_MEEGO) -#include "qllcpsocket_maemo6_p.h" #elif defined(QNX_NFC) #include "qllcpsocket_qnx_p.h" #else diff --git a/src/nfc/qllcpsocket_maemo6_p.cpp b/src/nfc/qllcpsocket_maemo6_p.cpp deleted file mode 100644 index 6e20e428..00000000 --- a/src/nfc/qllcpsocket_maemo6_p.cpp +++ /dev/null @@ -1,640 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qllcpsocket_maemo6_p.h" - -#include "manager_interface.h" -#include "maemo6/adapter_interface_p.h" -#include "maemo6/socketrequestor_p.h" - -#include <QtCore/QSocketNotifier> -#include <QtCore/QAtomicInt> - -#include <errno.h> -#include <signal.h> - -using namespace com::nokia::nfc; - -QT_BEGIN_NAMESPACE_NFC - -static QAtomicInt requestorId = 0; -static const char * const requestorBasePath = "/com/nokia/nfc/llcpclient/"; - -QLlcpSocketPrivate::QLlcpSocketPrivate(QLlcpSocket *q) -: q_ptr(q), - m_connection(QDBusConnection::connectToBus(QDBusConnection::SystemBus, QUuid::createUuid())), - m_port(0), m_socketRequestor(0), m_fd(-1), m_readNotifier(0), m_writeNotifier(0), - m_pendingBytes(0), m_state(QLlcpSocket::UnconnectedState), - m_error(QLlcpSocket::UnknownSocketError) -{ -} - -QLlcpSocketPrivate::QLlcpSocketPrivate(const QDBusConnection &connection, int fd, - const QVariantMap &properties) -: q_ptr(0), m_properties(properties), m_connection(connection), m_port(0), m_socketRequestor(0), - m_fd(fd), m_pendingBytes(0), - m_state(QLlcpSocket::ConnectedState), m_error(QLlcpSocket::UnknownSocketError) -{ - m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); - connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(_q_readNotify())); - m_writeNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Write, this); - connect(m_writeNotifier, SIGNAL(activated(int)), this, SLOT(_q_bytesWritten())); -} - -QLlcpSocketPrivate::~QLlcpSocketPrivate() -{ - delete m_readNotifier; - delete m_writeNotifier; -} - -void QLlcpSocketPrivate::connectToService(QNearFieldTarget *target, const QString &serviceUri) -{ - Q_UNUSED(target); - - Q_Q(QLlcpSocket); - - m_state = QLlcpSocket::ConnectingState; - emit q->stateChanged(m_state); - - initializeRequestor(); - - if (m_socketRequestor) { - m_serviceUri = serviceUri; - m_port = 0; - - QString accessKind(QLatin1String("device.llcp.co.client:") + serviceUri); - - m_socketRequestor->requestAccess(m_requestorPath, accessKind); - } else { - setSocketError(QLlcpSocket::SocketResourceError); - - m_state = QLlcpSocket::UnconnectedState; - emit q->stateChanged(m_state); - } -} - -void QLlcpSocketPrivate::disconnectFromService() -{ - Q_Q(QLlcpSocket); - - m_state = QLlcpSocket::ClosingState; - emit q->stateChanged(m_state); - - delete m_readNotifier; - m_readNotifier = 0; - delete m_writeNotifier; - m_writeNotifier = 0; - m_pendingBytes = 0; - ::close(m_fd); - m_fd = -1; - - if (m_socketRequestor) { - QString accessKind(QLatin1String("device.llcp.co.client:") + m_serviceUri); - - Manager manager(QLatin1String("com.nokia.nfc"), QLatin1String("/"), m_connection); - QDBusObjectPath defaultAdapterPath = manager.DefaultAdapter(); - - m_socketRequestor->cancelAccessRequest(m_requestorPath, accessKind); - } - - m_state = QLlcpSocket::UnconnectedState; - q->setOpenMode(QIODevice::NotOpen); - emit q->stateChanged(m_state); - emit q->disconnected(); -} - -bool QLlcpSocketPrivate::bind(quint8 port) -{ - initializeRequestor(); - - if (!m_socketRequestor) - return false; - - m_serviceUri.clear(); - m_port = port; - - const QString accessKind(QLatin1String("device.llcp.cl:") + QString::number(port)); - - m_socketRequestor->requestAccess(m_requestorPath, accessKind); - - return waitForBound(30000); -} - -bool QLlcpSocketPrivate::hasPendingDatagrams() const -{ - return !m_receivedDatagrams.isEmpty(); -} - -qint64 QLlcpSocketPrivate::pendingDatagramSize() const -{ - if (m_receivedDatagrams.isEmpty()) - return -1; - - if (m_state == QLlcpSocket::BoundState) - return m_receivedDatagrams.first().length() - 1; - else - return m_receivedDatagrams.first().length(); -} - -qint64 QLlcpSocketPrivate::writeDatagram(const char *data, qint64 size) -{ - if (m_state != QLlcpSocket::ConnectedState) - return -1; - - return writeData(data, size); -} - -qint64 QLlcpSocketPrivate::writeDatagram(const QByteArray &datagram) -{ - if (m_state != QLlcpSocket::ConnectedState) - return -1; - - if (uint(datagram.length()) > m_properties.value(QLatin1String("RemoteMIU"), 128).toUInt()) - return -1; - - return writeData(datagram.constData(), datagram.size()); -} - -qint64 QLlcpSocketPrivate::readDatagram(char *data, qint64 maxSize, - QNearFieldTarget **target, quint8 *port) -{ - Q_UNUSED(target); - - if (m_state == QLlcpSocket::ConnectedState) { - return readData(data, maxSize); - } else if (m_state == QLlcpSocket::BoundState) { - return readData(data, maxSize, port); - } - - return -1; -} - -qint64 QLlcpSocketPrivate::writeDatagram(const char *data, qint64 size, - QNearFieldTarget *target, quint8 port) -{ - Q_UNUSED(target); - - if (m_state != QLlcpSocket::BoundState) - return -1; - - if (m_properties.value(QLatin1String("RemoteMIU"), 128).toUInt() < size) - return -1; - - if (m_properties.value(QLatin1String("LocalMIU"), 128).toUInt() < size) - return -1; - - QByteArray datagram; - datagram.append(port); - datagram.append(data, size); - - m_pendingBytes += datagram.size() - 1; - m_writeNotifier->setEnabled(true); - - return ::write(m_fd, datagram.constData(), datagram.size()) - 1; -} - -qint64 QLlcpSocketPrivate::writeDatagram(const QByteArray &datagram, - QNearFieldTarget *target, quint8 port) -{ - Q_UNUSED(target); - - if (m_state != QLlcpSocket::BoundState) - return -1; - - if (m_properties.value(QLatin1String("RemoteMIU"), 128).toInt() < datagram.size()) - return -1; - - if (m_properties.value(QLatin1String("LocalMIU"), 128).toInt() < datagram.size()) - return -1; - - QByteArray d; - d.append(port); - d.append(datagram); - - m_pendingBytes += datagram.size() - 1; - m_writeNotifier->setEnabled(true); - - return ::write(m_fd, d.constData(), d.size()) - 1; -} - -QLlcpSocket::SocketError QLlcpSocketPrivate::error() const -{ - return m_error; -} - -QLlcpSocket::SocketState QLlcpSocketPrivate::state() const -{ - return m_state; -} - -qint64 QLlcpSocketPrivate::readData(char *data, qint64 maxlen, quint8 *port) -{ - if (m_receivedDatagrams.isEmpty()) - return 0; - - const QByteArray datagram = m_receivedDatagrams.takeFirst(); - - if (m_state == QLlcpSocket::BoundState) { - if (port) - *port = datagram.at(0); - - qint64 size = qMin(maxlen, qint64(datagram.length() - 1)); - memcpy(data, datagram.constData() + 1, size); - return size; - } else { - if (port) - *port = 0; - - qint64 size = qMin(maxlen, qint64(datagram.length())); - memcpy(data, datagram.constData(), size); - return size; - } -} - -qint64 QLlcpSocketPrivate::writeData(const char *data, qint64 len) -{ - Q_Q(QLlcpSocket); - - qint64 remoteMiu = m_properties.value(QLatin1String("RemoteMIU"), 128).toLongLong(); - qint64 localMiu = m_properties.value(QLatin1String("LocalMIU"), 128).toLongLong(); - qint64 miu = qMin(remoteMiu, localMiu); - - m_writeNotifier->setEnabled(true); - - ssize_t wrote = ::write(m_fd, data, qMin(miu, len)); - if (wrote == -1) { - if (errno == EAGAIN) - return 0; - - setSocketError(QLlcpSocket::RemoteHostClosedError); - q->disconnectFromService(); - return -1; - } - - m_pendingBytes += wrote; - return wrote; -} - -qint64 QLlcpSocketPrivate::bytesAvailable() const -{ - qint64 available = 0; - foreach (const QByteArray &datagram, m_receivedDatagrams) - available += datagram.length(); - - // less source port - if (m_state == QLlcpSocket::BoundState) - available -= m_receivedDatagrams.count(); - - return available; -} - -bool QLlcpSocketPrivate::canReadLine() const -{ - if (m_state == QLlcpSocket::BoundState) - return false; - - foreach (const QByteArray &datagram, m_receivedDatagrams) { - if (datagram.contains('\n')) - return true; - } - - return false; -} - -bool QLlcpSocketPrivate::waitForReadyRead(int msec) -{ - if (bytesAvailable()) - return true; - - fd_set fds; - FD_ZERO(&fds); - FD_SET(m_fd, &fds); - - timeval timeout; - timeout.tv_sec = msec / 1000; - timeout.tv_usec = (msec % 1000) * 1000; - - // timeout can not be 0 or else select will return an error. - if (0 == msec) - timeout.tv_usec = 1000; - - int result = -1; - // on Linux timeout will be updated by select, but _not_ on other systems. - QElapsedTimer timer; - timer.start(); - while (!bytesAvailable() && (-1 == msec || timer.elapsed() < msec)) { - result = ::select(m_fd + 1, &fds, 0, 0, &timeout); - if (result > 0) - _q_readNotify(); - - if (-1 == result && errno != EINTR) { - setSocketError(QLlcpSocket::UnknownSocketError); - break; - } - } - - return bytesAvailable(); -} - -bool QLlcpSocketPrivate::waitForBytesWritten(int msec) -{ - fd_set fds; - FD_ZERO(&fds); - FD_SET(m_fd, &fds); - - timeval timeout; - timeout.tv_sec = msec / 1000; - timeout.tv_usec = (msec % 1000) * 1000; - - // timeout can not be 0 or else select will return an error. - if (0 == msec) - timeout.tv_usec = 1000; - - int result = -1; - // on Linux timeout will be updated by select, but _not_ on other systems. - QElapsedTimer timer; - timer.start(); - while (-1 == msec || timer.elapsed() < msec) { - result = ::select(m_fd + 1, 0, &fds, 0, &timeout); - if (result > 0) - return true; - if (-1 == result && errno != EINTR) { - setSocketError(QLlcpSocket::UnknownSocketError); - return false; - } - } - - // timeout expired - return false; -} - -bool QLlcpSocketPrivate::waitForConnected(int msecs) -{ - if (m_state != QLlcpSocket::ConnectingState) - return m_state == QLlcpSocket::ConnectedState; - - QElapsedTimer timer; - timer.start(); - while (m_state == QLlcpSocket::ConnectingState && (msecs == -1 || timer.elapsed() < msecs)) { - if (!m_socketRequestor->waitForDBusSignal(qMax(msecs - timer.elapsed(), qint64(0)))) { - setSocketError(QLlcpSocket::UnknownSocketError); - break; - } - } - - // Possibly not needed. - QCoreApplication::sendPostedEvents(this, QEvent::MetaCall); - - return m_state == QLlcpSocket::ConnectedState; -} - -bool QLlcpSocketPrivate::waitForDisconnected(int msec) -{ - if (m_state == QLlcpSocket::UnconnectedState) - return true; - - fd_set fds; - FD_ZERO(&fds); - FD_SET(m_fd, &fds); - - timeval timeout; - timeout.tv_sec = msec / 1000; - timeout.tv_usec = (msec % 1000) * 1000; - - // timeout can not be 0 or else select will return an error. - if (0 == msec) - timeout.tv_usec = 1000; - - int result = -1; - // on Linux timeout will be updated by select, but _not_ on other systems. - QElapsedTimer timer; - timer.start(); - while (m_state != QLlcpSocket::UnconnectedState && (-1 == msec || timer.elapsed() < msec)) { - result = ::select(m_fd + 1, &fds, 0, 0, &timeout); - if (result > 0) - _q_readNotify(); - - if (-1 == result && errno != EINTR) { - setSocketError(QLlcpSocket::UnknownSocketError); - break; - } - } - - return m_state == QLlcpSocket::UnconnectedState; -} - -bool QLlcpSocketPrivate::waitForBound(int msecs) -{ - if (m_state == QLlcpSocket::BoundState) - return true; - - QElapsedTimer timer; - timer.start(); - while (m_state != QLlcpSocket::BoundState && (msecs == -1 || timer.elapsed() < msecs)) { - if (!m_socketRequestor->waitForDBusSignal(qMax(msecs - timer.elapsed(), qint64(0)))) - return false; - } - - // Possibly not needed. - QCoreApplication::sendPostedEvents(this, QEvent::MetaCall); - - return m_state == QLlcpSocket::BoundState; -} - -void QLlcpSocketPrivate::AccessFailed(const QDBusObjectPath &targetPath, const QString &kind, - const QString &error) -{ - Q_UNUSED(targetPath); - Q_UNUSED(kind); - Q_UNUSED(error); - - Q_Q(QLlcpSocket); - - setSocketError(QLlcpSocket::SocketAccessError); - - m_state = QLlcpSocket::UnconnectedState; - emit q->stateChanged(m_state); -} - -void QLlcpSocketPrivate::AccessGranted(const QDBusObjectPath &targetPath, - const QString &accessKind) -{ - Q_UNUSED(targetPath); - Q_UNUSED(accessKind); -} - -void QLlcpSocketPrivate::Accept(const QDBusVariant &lsap, const QDBusVariant &rsap, - int fd, const QVariantMap &properties) -{ - Q_UNUSED(lsap); - Q_UNUSED(rsap); - Q_UNUSED(fd); - Q_UNUSED(properties); -} - -void QLlcpSocketPrivate::Connect(const QDBusVariant &lsap, const QDBusVariant &rsap, - int fd, const QVariantMap &properties) -{ - Q_UNUSED(lsap); - Q_UNUSED(rsap); - - m_fd = fd; - - m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); - connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(_q_readNotify())); - m_writeNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Write, this); - connect(m_writeNotifier, SIGNAL(activated(int)), this, SLOT(_q_bytesWritten())); - - m_properties = properties; - - Q_Q(QLlcpSocket); - - q->setOpenMode(QIODevice::ReadWrite); - - m_state = QLlcpSocket::ConnectedState; - emit q->stateChanged(m_state); - emit q->connected(); -} - -void QLlcpSocketPrivate::Socket(const QDBusVariant &lsap, int fd, const QVariantMap &properties) -{ - m_fd = fd; - m_port = lsap.variant().toUInt(); - - m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); - connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(_q_readNotify())); - m_writeNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Write, this); - connect(m_writeNotifier, SIGNAL(activated(int)), this, SLOT(_q_bytesWritten())); - - m_properties = properties; - - Q_Q(QLlcpSocket); - - m_state = QLlcpSocket::BoundState; - emit q->stateChanged(m_state); -} - -void QLlcpSocketPrivate::_q_readNotify() -{ - Q_Q(QLlcpSocket); - - QByteArray datagram; - datagram.resize(m_properties.value(QLatin1String("LocalMIU"), 128).toUInt()); - - int readFromDevice = ::read(m_fd, datagram.data(), datagram.size()); - if (readFromDevice <= 0) { - m_readNotifier->setEnabled(false); - - setSocketError(QLlcpSocket::RemoteHostClosedError); - - q->disconnectFromService(); - q->setOpenMode(QIODevice::NotOpen); - } else { - m_receivedDatagrams.append(datagram.left(readFromDevice)); - emit q->readyRead(); - } -} - -void QLlcpSocketPrivate::_q_bytesWritten() -{ - Q_Q(QLlcpSocket); - - m_writeNotifier->setEnabled(false); - - emit q->bytesWritten(m_pendingBytes); - m_pendingBytes = 0; -} - -void QLlcpSocketPrivate::setSocketError(QLlcpSocket::SocketError socketError) -{ - Q_Q(QLlcpSocket); - - QLatin1String c("QLlcpSocket"); - - m_error = socketError; - switch (socketError) { - case QLlcpSocket::UnknownSocketError: - q->setErrorString(QLlcpSocket::tr("%1: Unknown error %2").arg(c).arg(errno)); - break; - case QLlcpSocket::RemoteHostClosedError: - q->setErrorString(QLlcpSocket::tr("%1: Remote closed").arg(c)); - break; - case QLlcpSocket::SocketAccessError: - q->setErrorString(QLlcpSocket::tr("%1: Socket access error")); - break; - case QLlcpSocket::SocketResourceError: - q->setErrorString(QLlcpSocket::tr("%1: Socket resource error")); - break; - } - - emit q->error(m_error); -} - -void QLlcpSocketPrivate::initializeRequestor() -{ - if (m_socketRequestor) - return; - - if (m_requestorPath.isEmpty()) { - m_requestorPath = QLatin1String(requestorBasePath) + - QString::number(requestorId.fetchAndAddOrdered(1)); - } - - Manager manager(QLatin1String("com.nokia.nfc"), QLatin1String("/"), m_connection); - QDBusObjectPath defaultAdapterPath = manager.DefaultAdapter(); - - if (!m_socketRequestor) { - m_socketRequestor = new SocketRequestor(defaultAdapterPath.path(), this); - - connect(m_socketRequestor, SIGNAL(accessFailed(QDBusObjectPath,QString,QString)), - this, SLOT(AccessFailed(QDBusObjectPath,QString,QString))); - connect(m_socketRequestor, SIGNAL(accessGranted(QDBusObjectPath,QString)), - this, SLOT(AccessGranted(QDBusObjectPath,QString))); - connect(m_socketRequestor, SIGNAL(accept(QDBusVariant,QDBusVariant,int,QVariantMap)), - this, SLOT(Accept(QDBusVariant,QDBusVariant,int,QVariantMap))); - connect(m_socketRequestor, SIGNAL(connect(QDBusVariant,QDBusVariant,int,QVariantMap)), - this, SLOT(Connect(QDBusVariant,QDBusVariant,int,QVariantMap))); - connect(m_socketRequestor, SIGNAL(socket(QDBusVariant,int,QVariantMap)), - this, SLOT(Socket(QDBusVariant,int,QVariantMap))); - } -} - -QT_END_NAMESPACE_NFC diff --git a/src/nfc/qllcpsocket_maemo6_p.h b/src/nfc/qllcpsocket_maemo6_p.h deleted file mode 100644 index bd4d5cf2..00000000 --- a/src/nfc/qllcpsocket_maemo6_p.h +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QLLCPSOCKET_MAEMO6_P_H -#define QLLCPSOCKET_MAEMO6_P_H - -#include <qconnectivityglobal.h> - -#include "qllcpsocket.h" - -#include <QtDBus/QDBusConnection> - -QT_FORWARD_DECLARE_CLASS(QDBusObjectPath) -QT_FORWARD_DECLARE_CLASS(QDBusVariant) -QT_FORWARD_DECLARE_CLASS(QSocketNotifier) - -class AccessRequestorAdaptor; -class LLCPRequestorAdaptor; - -QT_BEGIN_NAMESPACE_NFC - -class SocketRequestor; - -class QLlcpSocketPrivate : public QObject -{ - Q_OBJECT - - Q_DECLARE_PUBLIC(QLlcpSocket) - -public: - QLlcpSocketPrivate(QLlcpSocket *q); - QLlcpSocketPrivate(const QDBusConnection &connection, int fd, const QVariantMap &properties); - ~QLlcpSocketPrivate(); - - void connectToService(QNearFieldTarget *target, const QString &serviceUri); - void disconnectFromService(); - - bool bind(quint8 port); - - bool hasPendingDatagrams() const; - qint64 pendingDatagramSize() const; - - qint64 writeDatagram(const char *data, qint64 size); - qint64 writeDatagram(const QByteArray &datagram); - - qint64 readDatagram(char *data, qint64 maxSize, - QNearFieldTarget **target = 0, quint8 *port = 0); - qint64 writeDatagram(const char *data, qint64 size, - QNearFieldTarget *target, quint8 port); - qint64 writeDatagram(const QByteArray &datagram, QNearFieldTarget *target, quint8 port); - - QLlcpSocket::SocketError error() const; - QLlcpSocket::SocketState state() const; - - qint64 readData(char *data, qint64 maxlex, quint8 *port = 0); - qint64 writeData(const char *data, qint64 len); - - qint64 bytesAvailable() const; - bool canReadLine() const; - - bool waitForReadyRead(int msecs); - bool waitForBytesWritten(int msecs); - bool waitForConnected(int msecs); - bool waitForDisconnected(int msecs); - bool waitForBound(int msecs); - -private slots: - // com.nokia.nfc.AccessRequestor - void AccessFailed(const QDBusObjectPath &targetPath, const QString &kind, - const QString &error); - void AccessGranted(const QDBusObjectPath &targetPath, const QString &accessKind); - - // com.nokia.nfc.LLCPRequestor - void Accept(const QDBusVariant &lsap, const QDBusVariant &rsap, int fd, const QVariantMap &properties); - void Connect(const QDBusVariant &lsap, const QDBusVariant &rsap, int fd, const QVariantMap &properties); - void Socket(const QDBusVariant &lsap, int fd, const QVariantMap &properties); - - void _q_readNotify(); - void _q_bytesWritten(); - -private: - void setSocketError(QLlcpSocket::SocketError socketError); - void initializeRequestor(); - - QLlcpSocket *q_ptr; - QVariantMap m_properties; - QList<QByteArray> m_receivedDatagrams; - - QDBusConnection m_connection; - - QString m_serviceUri; - quint8 m_port; - - QString m_requestorPath; - - SocketRequestor *m_socketRequestor; - - int m_fd; - QSocketNotifier *m_readNotifier; - QSocketNotifier *m_writeNotifier; - qint64 m_pendingBytes; - - QLlcpSocket::SocketState m_state; - QLlcpSocket::SocketError m_error; -}; - -QT_END_NAMESPACE_NFC - -#endif // QLLCPSOCKET_MAEMO6_P_H diff --git a/src/nfc/qnearfieldmanager.cpp b/src/nfc/qnearfieldmanager.cpp index e5cd8e88..d2c5412f 100644 --- a/src/nfc/qnearfieldmanager.cpp +++ b/src/nfc/qnearfieldmanager.cpp @@ -44,8 +44,6 @@ #if defined(QT_SIMULATOR) #include "qnearfieldmanager_simulator_p.h" -#elif defined(Q_WS_MAEMO_6) || defined (Q_WS_MEEGO) -#include "qnearfieldmanager_maemo6_p.h" #elif defined(QNX_NFC) #include "qnearfieldmanager_qnx_p.h" #else @@ -97,39 +95,15 @@ QT_BEGIN_NAMESPACE_NFC \section2 Automatically launching NDEF message handlers - It is possible to pre-register an application to receive NDEF messages matching a given - criteria. This is useful to get the system to automatically launch your application when a - matching NDEF message is received. This removes the need to have the user manually launch NDEF - handling applications, prior to touching a tag, or to have those applications always running - and using system resources. + On some platforms it is possible to pre-register an application to receive NDEF messages + matching a given criteria. This is useful to get the system to automatically launch your + application when a matching NDEF message is received. This removes the need to have the user + manually launch NDEF handling applications, prior to touching a tag, or to have those + applications always running and using system resources. - The process of registering the handler is different on each platform. The platform specifics - are documented in the sections below. QtNfc provides a tool, \c {ndefhandlergen}, to - generate the platform specific registration files. The output of \c {ndefhandlergen -help} is - reproduced here for convenience: - - \code - Generate platform specific NFC message handler registration files. - Usage: nfcxmlgen [options] - - -template TEMPLATE Template to use. - -appname APPNAME Name of the application. - -apppath APPPATH Path to installed application binary. - -datatype DATATYPE URN of the NDEF message type to match. - -match MATCHSTRING Platform specific match string. - - The -datatype and -match options are mutually exclusive. - - Available templates: maemo6 - \endcode - - A typical invocation of the \c ndefhandlergen tool for Maemo6 target: - - \code - ndefhandlergen -template maemo6 -appname myapplication -apppath /usr/bin/myapplication -datatype urn:nfc:ext:com.example:f - \endcode - - Once the application has been registered as an NDEF message handler, the application only needs + The process of registering the handler is different for each platform. Please refer to the + platform documentation on how such a registration may be done. + If the application has been registered as an NDEF message handler, the application only needs to call the registerNdefMessageHandler() function: \code @@ -137,11 +111,6 @@ QT_BEGIN_NAMESPACE_NFC manager->registerNdefMessageHandler(this, SLOT(handleNdefMessage(QNdefMessage,QNearFieldTarget))); \endcode - - \code - <customproperty key="datatype">urn:nfc:wkt:U</customproperty> - \endcode - */ /*! diff --git a/src/nfc/qnearfieldmanager_maemo6.cpp b/src/nfc/qnearfieldmanager_maemo6.cpp deleted file mode 100644 index 81f1266c..00000000 --- a/src/nfc/qnearfieldmanager_maemo6.cpp +++ /dev/null @@ -1,451 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qnearfieldmanager_maemo6_p.h" -#include "qnearfieldtarget_maemo6_p.h" -#include "manager_interface.h" -#include "maemo6/adapter_interface_p.h" -#include "maemo6/target_interface_p.h" -#include "maemo6/tag_interface_p.h" -#include "ndefhandler_adaptor.h" -#include "accessrequestor_adaptor.h" - -#include <qnearfieldtagtype1_p.h> - -#include <QtDBus/QDBusConnection> - -using namespace com::nokia::nfc; - -QT_BEGIN_NAMESPACE_NFC - -static QAtomicInt handlerId = 0; -static const char * const registeredHandlerPath = "/com/nokia/nfc/ndefhandler"; -static const char * const accessRequesterPath = "/com/nokia/nfc/accessRequester/"; -static const char * const connectionUuid = "46a15ee4-b5ce-4395-9d76-c440cc3838c6"; - -static inline bool matchesTarget(QNearFieldTarget::Type type, - const QList<QNearFieldTarget::Type> &types) -{ - return types.contains(type) || types.contains(QNearFieldTarget::AnyTarget); -} - -NdefHandler::NdefHandler(QNearFieldManagerPrivateImpl *manager, const QString &serviceName, - const QString &path, QObject *object, const QMetaMethod &method) -: m_manager(manager), m_adaptor(0), m_object(object), m_method(method), - m_serviceName(serviceName), m_path(path) -{ - QDBusConnection handlerConnection = - QDBusConnection::connectToBus(QDBusConnection::SystemBus, connectionUuid); - if (serviceName != handlerConnection.baseService()) { - handlerConnection = QDBusConnection::connectToBus(QDBusConnection::SystemBus, serviceName); - - if (!handlerConnection.registerService(serviceName)) - return; - } - - m_adaptor = new NDEFHandlerAdaptor(this); - - if (!handlerConnection.registerObject(path, this)) { - delete m_adaptor; - m_adaptor = 0; - } -} - -NdefHandler::~NdefHandler() -{ - delete m_adaptor; -} - -bool NdefHandler::isValid() const -{ - return m_adaptor; -} - -QString NdefHandler::serviceName() const -{ - return m_serviceName; -} - -QString NdefHandler::path() const -{ - return m_path; -} - -void NdefHandler::NDEFData(const QDBusObjectPath &target, const QByteArray &message) -{ - m_method.invoke(m_object, Q_ARG(QNdefMessage, QNdefMessage::fromByteArray(message)), - Q_ARG(QNearFieldTarget *, m_manager->targetForPath(target.path()))); -} - -QNearFieldManagerPrivateImpl::QNearFieldManagerPrivateImpl() -: m_connection(QDBusConnection::connectToBus(QDBusConnection::SystemBus, - QLatin1String(connectionUuid))), - m_accessAgent(0) -{ - qDBusRegisterMetaType<QList<QByteArray> >(); - - m_manager = new Manager(QLatin1String("com.nokia.nfc"), QLatin1String("/"), m_connection); - - QDBusObjectPath defaultAdapterPath = m_manager->DefaultAdapter(); - - m_adapter = new Adapter(QLatin1String("com.nokia.nfc"), defaultAdapterPath.path(), - m_connection); - - if (!m_adapter->isValid()) - return; -} - -QNearFieldManagerPrivateImpl::~QNearFieldManagerPrivateImpl() -{ - foreach (int id, m_registeredHandlers.keys()) - unregisterNdefMessageHandler(id); - - delete m_manager; - delete m_adapter; -} - -bool QNearFieldManagerPrivateImpl::isAvailable() const -{ - return m_manager->isValid(); -} - -bool QNearFieldManagerPrivateImpl::startTargetDetection(const QList<QNearFieldTarget::Type> &targetTypes) -{ - m_detectTargetTypes = targetTypes; - - connect(m_adapter, SIGNAL(TargetDetected(QDBusObjectPath)), - this, SLOT(_q_targetDetected(QDBusObjectPath))); - connect(m_adapter, SIGNAL(TargetLost(QDBusObjectPath)), - this, SLOT(_q_targetLost(QDBusObjectPath))); - - return true; -} - -void QNearFieldManagerPrivateImpl::stopTargetDetection() -{ - m_detectTargetTypes.clear(); - - disconnect(m_adapter, SIGNAL(TargetDetected(QDBusObjectPath)), - this, SLOT(_q_targetDetected(QDBusObjectPath))); - disconnect(m_adapter, SIGNAL(TargetLost(QDBusObjectPath)), - this, SLOT(_q_targetLost(QDBusObjectPath))); -} - -QNearFieldTarget *QNearFieldManagerPrivateImpl::targetForPath(const QString &path) -{ - QNearFieldTarget *nearFieldTarget = m_targets.value(path).data(); - - if (!nearFieldTarget) { - Target *target = new Target(QLatin1String("com.nokia.nfc"), path, m_connection); - - const QString type = target->type(); - - if (type == QLatin1String("tag")) { - Tag *tag = new Tag(QLatin1String("com.nokia.nfc"), path, m_connection); - - const QString tagTechnology = tag->technology(); - if (tagTechnology == QLatin1String("jewel")) - nearFieldTarget = new TagType1(this, target, tag); - else if (tagTechnology == QLatin1String("mifare-ul")) - nearFieldTarget = new TagType2(this, target, tag); - else if (tagTechnology == QLatin1String("felica")) - nearFieldTarget = new TagType3(this, target, tag); - else if (tagTechnology == QLatin1String("iso-4a")) - nearFieldTarget = new TagType4(this, target, tag); - else - nearFieldTarget = new NearFieldTarget<QNearFieldTarget>(this, target, tag); - } else if (type == QLatin1String("device")) { - Device *device = new Device(QLatin1String("com.nokia.nfc"), path, m_connection); - nearFieldTarget = new NearFieldTarget<QNearFieldTarget>(this, target, device); - } - - if (nearFieldTarget) - m_targets.insert(path, nearFieldTarget); - } - - return nearFieldTarget; -} - -int QNearFieldManagerPrivateImpl::registerNdefMessageHandler(const QString &filter, - QObject *object, - const QMetaMethod &method) -{ - int id = handlerId.fetchAndAddOrdered(1); - const QString handlerPath = - QLatin1String(registeredHandlerPath) + QLatin1Char('/') + QString::number(id); - - NdefHandler *handler = new NdefHandler(this, m_connection.baseService(), - handlerPath, object, method); - if (!handler->isValid()) { - delete handler; - return -1; - } - - QDBusPendingReply<> reply = - m_manager->RegisterNDEFHandler(QLatin1String("system"), - m_connection.baseService(), - QDBusObjectPath(handlerPath), - QLatin1String("any"), - filter, - QCoreApplication::applicationName()); - - if (reply.isError()) { - delete handler; - return -1; - } - - m_registeredHandlers[id] = handler; - - return id; -} - -int QNearFieldManagerPrivateImpl::registerNdefMessageHandler(QObject *object, - const QMetaMethod &method) -{ - QFileInfo fi(qApp->applicationFilePath()); - const QString serviceName = QLatin1String("com.nokia.qt.nfc.") + fi.baseName(); - - int id = handlerId.fetchAndAddOrdered(1); - - const QString handlerPath = QLatin1String(registeredHandlerPath); - - NdefHandler *handler = new NdefHandler(this, serviceName, handlerPath, object, method); - if (!handler->isValid()) { - delete handler; - return -1; - } - - m_registeredHandlers[id] = handler; - - return id; -} - -int QNearFieldManagerPrivateImpl::registerNdefMessageHandler(const QNdefFilter &filter, - QObject *object, - const QMetaMethod &method) -{ - QString matchString; - - if (filter.orderMatch()) - matchString += QLatin1String("sequence:"); - else - matchString += QLatin1String("unordered:"); - - for (int i = 0; i < filter.recordCount(); ++i) { - QNdefFilter::Record record = filter.recordAt(i); - - QString type; - - switch (record.typeNameFormat) { - case QNdefRecord::NfcRtd: - type = QLatin1String("urn:nfc:wkt:") + record.type; - break; - case QNdefRecord::ExternalRtd: - type = QLatin1String("urn:nfc:ext:") + record.type; - break; - case QNdefRecord::Mime: - type = record.type; - break; - default: - qWarning("Unsupported filter type"); - return -1; - } - - matchString += QLatin1Char('\'') + type + QLatin1Char('\''); - matchString += QLatin1Char('['); - - if (record.minimum == UINT_MAX) - matchString += QLatin1Char('*'); - else - matchString += QString::number(record.minimum); - - matchString += QLatin1Char(':'); - - if (record.maximum == UINT_MAX) - matchString += QLatin1Char('*'); - else - matchString += QString::number(record.maximum); - - matchString += QLatin1Char(']'); - - if (i == filter.recordCount() - 1) - matchString += QLatin1Char(';'); - else - matchString += QLatin1Char(','); - } - - return registerNdefMessageHandler(matchString, object, method); -} - -bool QNearFieldManagerPrivateImpl::unregisterNdefMessageHandler(int id) -{ - if (id < 0) - return false; - - NdefHandler *handler = m_registeredHandlers.take(id); - - QDBusPendingReply<> reply = m_manager->UnregisterNDEFHandler(QLatin1String("system"), - handler->serviceName(), - QDBusObjectPath(handler->path())); - - delete handler; - - return true; -} - -static QStringList accessModesToKind(QNearFieldManager::TargetAccessModes accessModes) -{ - QStringList kind; - - if (accessModes & QNearFieldManager::NdefReadTargetAccess) - kind.append(QLatin1String("tag.ndef.read")); - - if (accessModes & QNearFieldManager::NdefWriteTargetAccess) - kind.append(QLatin1String("tag.ndef.write")); - - if (accessModes & QNearFieldManager::TagTypeSpecificTargetAccess) - kind.append(QLatin1String("tag.raw")); - - return kind; -} - -void QNearFieldManagerPrivateImpl::requestAccess(QNearFieldManager::TargetAccessModes accessModes) -{ - const QString requesterPath = - QLatin1String(accessRequesterPath) + QString::number(quintptr(this)); - - if (!m_accessAgent) { - m_accessAgent = new AccessRequestorAdaptor(this); - if (!m_connection.registerObject(requesterPath, this)) { - delete m_accessAgent; - m_accessAgent = 0; - return; - } - } - - foreach (const QString &kind, accessModesToKind(accessModes)) - m_adapter->RequestAccess(QDBusObjectPath(requesterPath), kind); - - QNearFieldManagerPrivate::requestAccess(accessModes); -} - -void QNearFieldManagerPrivateImpl::releaseAccess(QNearFieldManager::TargetAccessModes accessModes) -{ - const QString requesterPath = - QLatin1String(accessRequesterPath) + QString::number(quintptr(this)); - - foreach (const QString &kind, accessModesToKind(accessModes)) - m_adapter->CancelAccessRequest(QDBusObjectPath(requesterPath), kind); - - QNearFieldManagerPrivate::releaseAccess(accessModes); -} - -void QNearFieldManagerPrivateImpl::AccessFailed(const QDBusObjectPath &target, const QString &kind, - const QString &error) -{ - qDebug() << "Access for" << target.path() << kind << "failed with error:" << error; -} - -void QNearFieldManagerPrivateImpl::AccessGranted(const QDBusObjectPath &target, - const QString &kind) -{ - Q_UNUSED(kind); - - if (m_pendingDetectedTargets.contains(target.path())) { - m_pendingDetectedTargets[target.path()].stop(); - m_pendingDetectedTargets.remove(target.path()); - } - - emitTargetDetected(target.path()); -} - -void QNearFieldManagerPrivateImpl::timerEvent(QTimerEvent *event) -{ - QMutableMapIterator<QString, QBasicTimer> i(m_pendingDetectedTargets); - while (i.hasNext()) { - i.next(); - - if (i.value().timerId() == event->timerId()) { - i.value().stop(); - - const QString target = i.key(); - - i.remove(); - - emitTargetDetected(target); - - break; - } - } -} - -void QNearFieldManagerPrivateImpl::emitTargetDetected(const QString &targetPath) -{ - QNearFieldTarget *target = targetForPath(targetPath); - if (target && matchesTarget(target->type(), m_detectTargetTypes)) - emit targetDetected(target); -} - -void QNearFieldManagerPrivateImpl::_q_targetDetected(const QDBusObjectPath &targetPath) -{ - if (!m_requestedModes) - emitTargetDetected(targetPath.path()); - else - m_pendingDetectedTargets[targetPath.path()].start(500, this); -} - -void QNearFieldManagerPrivateImpl::_q_targetLost(const QDBusObjectPath &targetPath) -{ - QNearFieldTarget *nearFieldTarget = m_targets.value(targetPath.path()).data(); - - // haven't seen target so just drop this event - if (!nearFieldTarget) { - // We either haven't seen target (started after target was detected by system) or the - // application deleted the target. Remove from map and don't emit anything. - m_targets.remove(targetPath.path()); - return; - } - - if (matchesTarget(nearFieldTarget->type(), m_detectTargetTypes)) - emit targetLost(nearFieldTarget); -} - -QT_END_NAMESPACE_NFC diff --git a/src/nfc/qnearfieldmanager_maemo6_p.h b/src/nfc/qnearfieldmanager_maemo6_p.h deleted file mode 100644 index a40df986..00000000 --- a/src/nfc/qnearfieldmanager_maemo6_p.h +++ /dev/null @@ -1,148 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QNEARFIELDMANAGER_MAEMO6_P_H -#define QNEARFIELDMANAGER_MAEMO6_P_H - -#include "qnearfieldmanager_p.h" -#include "qnearfieldmanager.h" -#include "qnearfieldtarget.h" - -#include <QtCore/QWeakPointer> -#include <QtCore/QMap> -#include <QtCore/QPair> -#include <QtCore/QMetaMethod> -#include <QtCore/QBasicTimer> - -#include <QtDBus/QDBusConnection> - -QT_FORWARD_DECLARE_CLASS(QDBusObjectPath) - -class ComNokiaNfcManagerInterface; -class ComNokiaNfcAdapterInterface; -class NDEFHandlerAdaptor; -class AccessRequestorAdaptor; - -QT_BEGIN_NAMESPACE_NFC - -class QNearFieldManagerPrivateImpl; - -class NdefHandler : public QObject -{ - Q_OBJECT - -public: - NdefHandler(QNearFieldManagerPrivateImpl *manager, const QString &serviceName, - const QString &path, QObject *object, const QMetaMethod &method); - ~NdefHandler(); - - bool isValid() const; - - QString serviceName() const; - QString path() const; - -private: - Q_INVOKABLE void NDEFData(const QDBusObjectPath &target, const QByteArray &message); - - QNearFieldManagerPrivateImpl *m_manager; - NDEFHandlerAdaptor *m_adaptor; - QObject *m_object; - QMetaMethod m_method; - QString m_serviceName; - QString m_path; -}; - -class QNearFieldManagerPrivateImpl : public QNearFieldManagerPrivate -{ - Q_OBJECT - -public: - QNearFieldManagerPrivateImpl(); - ~QNearFieldManagerPrivateImpl(); - - bool isAvailable() const; - - bool startTargetDetection(const QList<QNearFieldTarget::Type> &targetTypes); - void stopTargetDetection(); - - QNearFieldTarget *targetForPath(const QString &path); - - int registerNdefMessageHandler(const QString &filter, - QObject *object, const QMetaMethod &method); - int registerNdefMessageHandler(QObject *object, const QMetaMethod &method); - int registerNdefMessageHandler(const QNdefFilter &filter, - QObject *object, const QMetaMethod &method); - bool unregisterNdefMessageHandler(int handlerId); - - void requestAccess(QNearFieldManager::TargetAccessModes accessModes); - void releaseAccess(QNearFieldManager::TargetAccessModes accessModes); - - // Access Agent Adaptor - Q_INVOKABLE void AccessFailed(const QDBusObjectPath &target, const QString &kind, - const QString &error); - Q_INVOKABLE void AccessGranted(const QDBusObjectPath &target, const QString &kind); - -protected: - void timerEvent(QTimerEvent *event); - -private slots: - void emitTargetDetected(const QString &targetPath); - void _q_targetDetected(const QDBusObjectPath &targetPath); - void _q_targetLost(const QDBusObjectPath &targetPath); - -private: - QDBusConnection m_connection; - ComNokiaNfcManagerInterface *m_manager; - ComNokiaNfcAdapterInterface *m_adapter; - - QList<QNearFieldTarget::Type> m_detectTargetTypes; - QMap<QString, QWeakPointer<QNearFieldTarget> > m_targets; - - AccessRequestorAdaptor *m_accessAgent; - - QMap<int, NdefHandler *> m_registeredHandlers; - - QMap<QString, QBasicTimer> m_pendingDetectedTargets; -}; - -QT_END_NAMESPACE_NFC - -#endif // QNEARFIELDMANAGER_MAEMO6_P_H diff --git a/src/nfc/qnearfieldtarget_maemo6.cpp b/src/nfc/qnearfieldtarget_maemo6.cpp deleted file mode 100644 index 80855fd3..00000000 --- a/src/nfc/qnearfieldtarget_maemo6.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qnearfieldtarget_maemo6_p.h" - -QT_BEGIN_NAMESPACE_NFC - -void PendingCallWatcher::addSendCommand(const QDBusPendingReply<QByteArray> &reply, - const QNearFieldTarget::RequestId &id) -{ - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - this, SLOT(sendCommandFinished(QDBusPendingCallWatcher*))); - - m_pendingCommands.insert(watcher, id); -} - -void PendingCallWatcher::addReadNdefMessages(const QDBusPendingReply<QList<QByteArray> > &reply, - const QNearFieldTarget::RequestId &id) -{ - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - this, SLOT(readNdefMessagesFinished(QDBusPendingCallWatcher*))); - - m_pendingNdefReads.insert(watcher, id); -} - -void PendingCallWatcher::addWriteNdefMessages(const QDBusPendingReply<> &reply, - const QNearFieldTarget::RequestId &id) -{ - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - this, SLOT(writeNdefMessages(QDBusPendingCallWatcher*))); - - m_pendingNdefWrites.insert(watcher, id); -} - -void PendingCallWatcher::sendCommandFinished(QDBusPendingCallWatcher *watcher) -{ - QNearFieldTarget::RequestId id = m_pendingCommands.take(watcher); - - if (!id.isValid()) { - watcher->deleteLater(); - return; - } - - QDBusPendingReply<QByteArray> reply = *watcher; - if (reply.isError()) { - QMetaObject::invokeMethod(parent(), "error", - Q_ARG(QNearFieldTarget::Error, QNearFieldTarget::UnknownError), - Q_ARG(QNearFieldTarget::RequestId, id)); - } else { - const QByteArray data = reply.argumentAt<0>(); - QMetaObject::invokeMethod(parent(), "handleResponse", - Q_ARG(QNearFieldTarget::RequestId, id), - Q_ARG(QByteArray, data)); - } - - watcher->deleteLater(); -} - -void PendingCallWatcher::readNdefMessagesFinished(QDBusPendingCallWatcher *watcher) -{ - QNearFieldTarget::RequestId id = m_pendingNdefReads.take(watcher); - - if (!id.isValid()) { - watcher->deleteLater(); - return; - } - - QDBusPendingReply<QList<QByteArray> > reply = *watcher; - if (reply.isError()) { - QMetaObject::invokeMethod(parent(), "error", - Q_ARG(QNearFieldTarget::Error, QNearFieldTarget::NdefReadError), - Q_ARG(QNearFieldTarget::RequestId, id)); - } else { - const QList<QByteArray> data = reply.argumentAt<0>(); - foreach (const QByteArray &m, data) { - qDebug() << Q_FUNC_INFO << m.toHex(); - const QNdefMessage message = QNdefMessage::fromByteArray(m); - - qDebug() << "record count:" << message.count(); - foreach (const QNdefRecord &record, message) - qDebug() << record.typeNameFormat() << record.type() << record.payload().toHex(); - - QMetaObject::invokeMethod(parent(), "ndefMessageRead", Q_ARG(QNdefMessage, message)); - } - - QMetaObject::invokeMethod(parent(), "requestCompleted", - Q_ARG(QNearFieldTarget::RequestId, id)); - } - - watcher->deleteLater(); -} - -void PendingCallWatcher::writeNdefMessages(QDBusPendingCallWatcher *watcher) -{ - QNearFieldTarget::RequestId id = m_pendingNdefWrites.take(watcher); - - if (!id.isValid()) { - watcher->deleteLater(); - return; - } - - QDBusPendingReply<> reply = *watcher; - if (reply.isError()) { - QMetaObject::invokeMethod(parent(), "error", - Q_ARG(QNearFieldTarget::Error, QNearFieldTarget::NdefWriteError), - Q_ARG(QNearFieldTarget::RequestId, id)); - } else { - QMetaObject::invokeMethod(parent(), "ndefMessagesWritten"); - QMetaObject::invokeMethod(parent(), "requestCompleted", - Q_ARG(QNearFieldTarget::RequestId, id)); - } - - watcher->deleteLater(); -} - -int TagType1::memorySize() const -{ - return m_tag->size(); -} - -int TagType2::memorySize() const -{ - return m_tag->size(); -} - -int TagType3::memorySize() const -{ - return m_tag->size(); -} - -int TagType4::memorySize() const -{ - return m_tag->size(); -} - -#include <moc_qnearfieldtarget_maemo6_p.cpp> - -QT_END_NAMESPACE_NFC diff --git a/src/nfc/qnearfieldtarget_maemo6_p.h b/src/nfc/qnearfieldtarget_maemo6_p.h deleted file mode 100644 index 793b75f5..00000000 --- a/src/nfc/qnearfieldtarget_maemo6_p.h +++ /dev/null @@ -1,313 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtNfc module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QNEARFIELDTARGET_MAEMO6_P_H -#define QNEARFIELDTARGET_MAEMO6_P_H - -#include <qconnectivityglobal.h> - -#include "qnearfieldmanager_maemo6_p.h" - -#include <qnearfieldtarget.h> -#include <qnearfieldtarget_p.h> -#include <qnearfieldtagtype1_p.h> -#include <qnearfieldtagtype2_p.h> -#include <qnearfieldtagtype3_p.h> -#include <qnearfieldtagtype4_p.h> -#include <qndefmessage.h> - -#include "maemo6/adapter_interface_p.h" -#include "maemo6/target_interface_p.h" -#include "maemo6/tag_interface_p.h" -#include "maemo6/device_interface_p.h" - -#include <QtDBus/QDBusPendingReply> - -using namespace com::nokia::nfc; - -QT_BEGIN_NAMESPACE_NFC - -class PendingCallWatcher : public QObject -{ - Q_OBJECT - -public: - PendingCallWatcher(QObject *parent) : QObject(parent) { } - - void addSendCommand(const QDBusPendingReply<QByteArray> &reply, - const QNearFieldTarget::RequestId &id); - void addReadNdefMessages(const QDBusPendingReply<QList<QByteArray> > &reply, - const QNearFieldTarget::RequestId &id); - void addWriteNdefMessages(const QDBusPendingReply<> &reply, - const QNearFieldTarget::RequestId &id); - -private slots: - void sendCommandFinished(QDBusPendingCallWatcher *watcher); - void readNdefMessagesFinished(QDBusPendingCallWatcher *watcher); - void writeNdefMessages(QDBusPendingCallWatcher *watcher); - -private: - QMap<QDBusPendingCallWatcher *, QNearFieldTarget::RequestId> m_pendingCommands; - QMap<QDBusPendingCallWatcher *, QNearFieldTarget::RequestId> m_pendingNdefReads; - QMap<QDBusPendingCallWatcher *, QNearFieldTarget::RequestId> m_pendingNdefWrites; -}; - -template <typename T> -class NearFieldTarget : public T -{ -public: - NearFieldTarget(QNearFieldManagerPrivateImpl *manager, Target *target, Tag *tag) - : T(manager), m_manager(manager), m_target(target), m_tag(tag), m_device(0), - m_callWatcher(new PendingCallWatcher(this)) - { - } - - NearFieldTarget(QNearFieldManagerPrivateImpl *manager, Target *target, Device *device) - : T(manager), m_manager(manager), m_target(target), m_tag(0), m_device(device), - m_callWatcher(new PendingCallWatcher(this)) - { - } - - ~NearFieldTarget() - { - delete m_device; - delete m_tag; - delete m_target; - } - - QByteArray uid() const - { - QStringList fields; - - if (m_tag) - fields = m_tag->uID().split(QLatin1Char(':')); - else if (m_device) - fields = m_device->uID().split(QLatin1Char(':')); - - QByteArray id; - foreach (const QString &f, fields) - id.append(char(f.toUInt(0, 16))); - - return id; - } - - QNearFieldTarget::Type type() const - { - if (m_device) - return QNearFieldTarget::NfcForumDevice; - - if (m_tag) { - const QString tagType = m_tag->technology(); - if (tagType == QLatin1String("jewel")) - return QNearFieldTarget::NfcTagType1; - else if (tagType == QLatin1String("mifare-ul")) - return QNearFieldTarget::NfcTagType2; - else if (tagType == QLatin1String("felica")) - return QNearFieldTarget::NfcTagType3; - else if (tagType == QLatin1String("iso-4a")) - return QNearFieldTarget::NfcTagType4; - else if (tagType == QLatin1String("mifare-1k")) - return QNearFieldTarget::MifareTag; - else - return QNearFieldTarget::ProprietaryTag; - } - - return QNearFieldTarget::ProprietaryTag; - } - - QNearFieldTarget::AccessMethods accessMethods() const - { - QNearFieldTarget::AccessMethods result = QNearFieldTarget::NdefAccess; -#ifdef MAEMO6_TAG_TYPE_SEPECIFIC_ACCESS_SUPPORTED - if (m_tag) - result |= QNearFieldTarget::TagTypeSpecificAccess; -#endif - if (!m_tag) - result |= QNearFieldTarget::LlcpAccess; - - return result; - } - - bool hasNdefMessage() - { - return true; - } - - QNearFieldTarget::RequestId readNdefMessages() - { - if (!m_tag) - return QNearFieldTarget::RequestId(); - - QNearFieldTarget::RequestId id(new QNearFieldTarget::RequestIdPrivate); - - QDBusPendingReply<QList<QByteArray> > reply = m_tag->ReadNDEFData(); - m_callWatcher->addReadNdefMessages(reply, id); - - return id; - } - - QNearFieldTarget::RequestId writeNdefMessages(const QList<QNdefMessage> &messages) - { - if (!m_tag) - return QNearFieldTarget::RequestId(); - - QNearFieldTarget::RequestId id(new QNearFieldTarget::RequestIdPrivate); - QList<QByteArray> rawMessages; - - foreach (const QNdefMessage &message, messages) - rawMessages.append(message.toByteArray()); - - QDBusPendingReply<> reply = m_tag->WriteNDEFData(rawMessages); - m_callWatcher->addWriteNdefMessages(reply, id); - - return id; - } - - QNearFieldTarget::RequestId sendCommand(const QByteArray &command) - { -#if 0 - quint16 crc = qNfcChecksum(command.constData(), command.length()); - - QNearFieldTarget::RequestId id(new QNearFieldTarget::RequestIdPrivate); - - QDBusPendingReply<QByteArray> reply = - m_tag->RawRequest(command + char(crc & 0xff) + char(crc >> 8)); - - m_callWatcher->addSendCommand(reply, id); - - return id; -#else - Q_UNUSED(command); - return QNearFieldTarget::RequestId(); -#endif - } - - QNearFieldTarget::RequestId sendCommands(const QList<QByteArray> &commands) - { -#if 0 - for (int i = 0; i < commandCount; ++i) { - reply[i] = m_tag->RawRequest(commands.at(i)); - } - - QList<QByteArray> results; - for (int i = 0; i < commandCount; ++i) { - reply[i].waitForFinished(); - results.append(reply[i].isError() ? QByteArray() : reply->value()); - } - - return results; -#else - Q_UNUSED(commands); - return QNearFieldTarget::RequestId(); -#endif - } - -protected: - QNearFieldManagerPrivateImpl *m_manager; - Target *m_target; - Tag *m_tag; - Device *m_device; - PendingCallWatcher *m_callWatcher; -}; - -class TagType1 : public NearFieldTarget<QNearFieldTagType1> -{ -public: - TagType1(QNearFieldManagerPrivateImpl *manager, Target *target, Tag *tag) - : NearFieldTarget<QNearFieldTagType1>(manager, target, tag) - { - } - - ~TagType1() - { - } - - int memorySize() const; -}; - -class TagType2 : public NearFieldTarget<QNearFieldTagType2> -{ -public: - TagType2(QNearFieldManagerPrivateImpl *manager, Target *target, Tag *tag) - : NearFieldTarget<QNearFieldTagType2>(manager, target, tag) - { - } - - ~TagType2() - { - } - - int memorySize() const; -}; - -class TagType3 : public NearFieldTarget<QNearFieldTagType3> -{ -public: - TagType3(QNearFieldManagerPrivateImpl *manager, Target *target, Tag *tag) - : NearFieldTarget<QNearFieldTagType3>(manager, target, tag) - { - } - - ~TagType3() - { - } - - int memorySize() const; -}; - -class TagType4 : public NearFieldTarget<QNearFieldTagType4> -{ -public: - TagType4(QNearFieldManagerPrivateImpl *manager, Target *target, Tag *tag) - : NearFieldTarget<QNearFieldTagType4>(manager, target, tag) - { - } - - ~TagType4() - { - } - - int memorySize() const; -}; - -QT_END_NAMESPACE_NFC - -#endif // QNEARFIELDTARGET_MAEMO6_P_H |