summaryrefslogtreecommitdiffstats
path: root/tests/nfcsymbianbackend/nfctestserviceprovider2
diff options
context:
space:
mode:
Diffstat (limited to 'tests/nfcsymbianbackend/nfctestserviceprovider2')
-rw-r--r--tests/nfcsymbianbackend/nfctestserviceprovider2/main.cpp170
-rw-r--r--tests/nfcsymbianbackend/nfctestserviceprovider2/makesis.bat48
-rw-r--r--tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.cpp53
-rw-r--r--tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.h60
-rw-r--r--tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.pro50
-rw-r--r--tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.ui31
-rw-r--r--tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.xml15
7 files changed, 427 insertions, 0 deletions
diff --git a/tests/nfcsymbianbackend/nfctestserviceprovider2/main.cpp b/tests/nfcsymbianbackend/nfctestserviceprovider2/main.cpp
new file mode 100644
index 00000000..9dc4e1b1
--- /dev/null
+++ b/tests/nfcsymbianbackend/nfctestserviceprovider2/main.cpp
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "nfctestserviceprovider2.h"
+
+#include <QtGui>
+#include <QApplication>
+#include <qremoteserviceregister.h>
+#include <qservicemanager.h>
+
+#include <QDebug>
+#include <qnearfieldmanager.h>
+#include <qndefmessage.h>
+#include <qnearfieldtarget.h>
+
+#include <iostream>
+#include <fstream>
+
+using namespace std;
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+void MyOutputHandler(QtMsgType type, const char *msg) {
+ static int fd = -1;
+ if (fd == -1)
+ fd = ::open("E:\\nfctestserviceprovider2.log", O_WRONLY | O_CREAT);
+
+ ::write(fd, msg, strlen(msg));
+ ::write(fd, "\n", 1);
+ ::fsync(fd);
+
+ switch (type) {
+ case QtFatalMsg:
+ abort();
+ }
+}
+
+nfctestserviceprovider2* w;
+
+class MyContentHandler : public QObject
+{
+ Q_OBJECT
+
+
+signals:
+ void userHandleMessage(const QNdefMessage& msg, QNearFieldTarget* target);
+
+public slots:
+ void handleMessage(const QNdefMessage& msg, QNearFieldTarget* target)
+ {
+ QFile m_file("E:\\testserviceprovider2.dat");
+ m_file.open(QIODevice::ReadWrite | QIODevice::Append);
+ QDataStream m_dataStream(&m_file);
+ QByteArray msgArray = msg.toByteArray();
+ m_dataStream << msgArray;
+
+ w->close();
+ }
+
+public:
+ MyContentHandler(QObject* parent = 0)
+ : QObject(parent)
+ {
+ qDebug() << " MyContentHandler constructed !!!!!" << endl;
+ connect(this, SIGNAL(userHandleMessage(const QNdefMessage& , QNearFieldTarget* )),
+ this, SLOT(handleMessage(const QNdefMessage& , QNearFieldTarget* )));
+ }
+
+};
+
+void unregisterExampleService()
+{
+ QServiceManager m;
+ m.removeService("nfctestserviceprovider2");
+}
+
+void registerExampleService()
+{
+ unregisterExampleService();
+ QServiceManager m;
+ const QString path = QCoreApplication::applicationDirPath() + "/xmldata/nfctestserviceprovider2.xml";
+ qWarning() << "xml path:" << path;
+ if (!m.addService(path))
+ {
+ qWarning() << "Cannot register service provider" << path;
+ }
+ else
+ {
+ qDebug() << " Register ok" << endl;
+ }
+}
+
+Q_DECLARE_METATYPE(QMetaType::Type);
+
+
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ w = new nfctestserviceprovider2();
+ w->setWindowTitle( "nfc test service provider 2" );
+ w->showMaximized();
+
+ qInstallMsgHandler(MyOutputHandler);
+
+ qRegisterMetaType<QNearFieldTarget*>("QNearFieldTarget*");
+ qRegisterMetaType<QNdefMessage>("QNdefMessage");
+
+ registerExampleService();
+
+ MyContentHandler handler;
+ QNearFieldManager manager;
+
+ int handle = manager.registerNdefMessageHandler(&handler, SIGNAL(userHandleMessage(QNdefMessage, QNearFieldTarget*)));
+
+ QFile m_file("E:\\testserviceprovider2.dat");
+ m_file.open(QIODevice::ReadWrite | QIODevice::Append);
+ QTextStream m_textStream(&m_file);
+ m_textStream << "register handle return " << QString::number(handle);
+
+ int ret = app.exec();
+
+ manager.unregisterNdefMessageHandler(handle);
+ delete w;
+ return ret;
+}
+
+#include "main.moc"
diff --git a/tests/nfcsymbianbackend/nfctestserviceprovider2/makesis.bat b/tests/nfcsymbianbackend/nfctestserviceprovider2/makesis.bat
new file mode 100644
index 00000000..7e57ddc8
--- /dev/null
+++ b/tests/nfcsymbianbackend/nfctestserviceprovider2/makesis.bat
@@ -0,0 +1,48 @@
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+::
+:: Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+:: All rights reserved.
+:: Contact: Nokia Corporation (qt-info@nokia.com)
+::
+:: This file is part of the Qt Mobility Components.
+::
+:: $QT_BEGIN_LICENSE:LGPL$
+:: GNU Lesser General Public License Usage
+:: 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, Nokia gives you certain additional
+:: rights. These rights are described in the Nokia 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.
+::
+:: Other Usage
+:: Alternatively, this file may be used in accordance with the terms and
+:: conditions contained in a signed written agreement between you and Nokia.
+::
+::
+::
+::
+::
+:: $QT_END_LICENSE$
+::
+:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+set EPOC_TOOLS_ROOT=\epoc32\tools
+set CERTIFICATE_PATH=\\begrp101\groups6\PCCONN\Tools\RnD_certs
+
+%EPOC_TOOLS_ROOT%\makesis nfctestserviceprovider2_template.pkg nfctestserviceprovider2_unsigned.sis
+
+%EPOC_TOOLS_ROOT%\signsis -s nfctestserviceprovider2_unsigned.sis nfctestserviceprovider2.sisx %CERTIFICATE_PATH%\Nokia_RnDCert_02.der %CERTIFICATE_PATH%\Nokia_RnDCert_02.key
+
+del nfctestserviceprovider2_unsigned.sis
diff --git a/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.cpp b/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.cpp
new file mode 100644
index 00000000..8b1d34ec
--- /dev/null
+++ b/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "nfctestserviceprovider2.h"
+
+nfctestserviceprovider2::nfctestserviceprovider2(QWidget *parent)
+ : QMainWindow(parent)
+{
+ ui.setupUi(this);
+}
+
+nfctestserviceprovider2::~nfctestserviceprovider2()
+{
+
+}
diff --git a/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.h b/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.h
new file mode 100644
index 00000000..50c05f94
--- /dev/null
+++ b/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia 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.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef nfctestserviceprovider2_H
+#define nfctestserviceprovider2_H
+
+#include <QtGui/QMainWindow>
+#include "ui_nfctestserviceprovider2.h"
+
+class nfctestserviceprovider2 : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ nfctestserviceprovider2(QWidget *parent = 0);
+ ~nfctestserviceprovider2();
+
+private:
+ Ui::nfctestserviceprovider2 ui;
+};
+
+#endif // nfctestserviceprovider2_H
diff --git a/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.pro b/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.pro
new file mode 100644
index 00000000..82161c33
--- /dev/null
+++ b/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.pro
@@ -0,0 +1,50 @@
+TEMPLATE = app
+TARGET = nfctestserviceprovider2
+
+QT += core gui serviceframework
+
+CONFIG += no_icon
+
+INCLUDEPATH += ../../../src/connectivity/nfc
+DEPENDPATH += ../../../src/connectivity/nfc
+INCLUDEPATH += ../common
+DEPENDPATH += ../common
+
+INCLUDEPATH += ../../../src/global
+DEPENDPATH += ../../../src/global
+
+QMAKE_LIBDIR += $$QT_MOBILITY_BUILD_TREE/lib
+
+HEADERS += nfctestserviceprovider2.h
+SOURCES += nfctestserviceprovider2_reg.rss \
+ main.cpp \
+ nfctestserviceprovider2.cpp
+FORMS += nfctestserviceprovider2.ui
+RESOURCES +=
+
+
+
+wince*|symbian*: {
+ addFiles.sources = nfctestserviceprovider2.xml
+ addFiles.path = xmldata
+ addFiles2.sources = nfctestserviceprovider2.xml
+ addFiles2.path = /private/2002AC7F/import/
+ DEPLOYMENT += addFiles addFiles2
+}
+
+symbian {
+ TARGET.UID3 = 0xe347d950
+ TARGET.CAPABILITY = LocalServices
+ }
+
+
+wince* {
+ DEFINES+= TESTDATA_DIR=\\\".\\\"
+} else:!symbian {
+ DEFINES += TESTDATA_DIR=\\\"$$PWD/\\\"
+}
+
+xml.path = $$QT_MOBILITY_EXAMPLES/xmldata
+xml.files = nfctestserviceprovider2.xml
+INSTALLS += xml
+
diff --git a/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.ui b/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.ui
new file mode 100644
index 00000000..516affe0
--- /dev/null
+++ b/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.ui
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>nfctestserviceprovider2</class>
+ <widget class="QMainWindow" name="nfctestserviceprovider2">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>nfctestserviceprovider</string>
+ </property>
+ <widget class="QWidget" name="centralwidget"/>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>26</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.xml b/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.xml
new file mode 100644
index 00000000..9d22644b
--- /dev/null
+++ b/tests/nfcsymbianbackend/nfctestserviceprovider2/nfctestserviceprovider2.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SFW version="1.1">
+<service>
+ <name>nfctestserviceprovider3</name>
+ <ipcaddress>nfctestserviceprovider2</ipcaddress>
+ <description>NFC serive provider</description>
+ <interface>
+ <name>com.nokia.qt.nfc.NdefMessageHandler</name>
+ <version>1.0</version>
+ <description>nfc service provider</description>
+ <capabilities></capabilities>
+ <customproperty key="datatype">urn:nfc:ext:S||abc</customproperty>
+ </interface>
+</service>
+</SFW>