summaryrefslogtreecommitdiffstats
path: root/src/nfc
diff options
context:
space:
mode:
authorSze Howe Koh <szehowe.koh@gmail.com>2013-09-09 11:33:48 +0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-09 11:43:07 +0200
commita589ae4f2f525686efa9f031a82390433b0e606d (patch)
tree3b63f67555864b5a0b1d69ee64177e79515599e0 /src/nfc
parent4384387f9ec995fdcc7b2e2f4a2cd7e56142930e (diff)
Move qNfcChecksum() definition into a .cpp file
The function is public; doesn't make sense to implement it in a private header. This patch also resolves the multiply-defined-symbols issue when trying to build some Qt NFC autotests without the "QtNfc" namespace. Change-Id: I4ba1dc31d93bb66454c7dcd043c18f81dc2ad680 Reviewed-by: Aaron McCarthy <mccarthy.aaron@gmail.com>
Diffstat (limited to 'src/nfc')
-rw-r--r--src/nfc/checksum_p.h68
-rw-r--r--src/nfc/nfc.pro1
-rw-r--r--src/nfc/qnearfieldtarget.cpp25
-rw-r--r--src/nfc/targetemulator.cpp2
4 files changed, 24 insertions, 72 deletions
diff --git a/src/nfc/checksum_p.h b/src/nfc/checksum_p.h
deleted file mode 100644
index 3b8304dd..00000000
--- a/src/nfc/checksum_p.h
+++ /dev/null
@@ -1,68 +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 CHECKSUM_P_H
-#define CHECKSUM_P_H
-
-// Copied from qbytearray.cpp
-// Modified to initialise the crc with 0x6363 instead of 0xffff and to not invert the final result.
-static const quint16 crc_tbl[16] = {
- 0x0000, 0x1081, 0x2102, 0x3183,
- 0x4204, 0x5285, 0x6306, 0x7387,
- 0x8408, 0x9489, 0xa50a, 0xb58b,
- 0xc60c, 0xd68d, 0xe70e, 0xf78f
-};
-
-quint16 qNfcChecksum(const char *data, uint len)
-{
- register quint16 crc = 0x6363;
- uchar c;
- const uchar *p = reinterpret_cast<const uchar *>(data);
- while (len--) {
- c = *p++;
- crc = ((crc >> 4) & 0x0fff) ^ crc_tbl[((crc ^ c) & 15)];
- c >>= 4;
- crc = ((crc >> 4) & 0x0fff) ^ crc_tbl[((crc ^ c) & 15)];
- }
- return crc;
-}
-
-#endif // CHECKSUM_P_H
diff --git a/src/nfc/nfc.pro b/src/nfc/nfc.pro
index b0c261a8..fcc4e6a4 100644
--- a/src/nfc/nfc.pro
+++ b/src/nfc/nfc.pro
@@ -29,7 +29,6 @@ PRIVATE_HEADERS += \
qnearfieldtagtype3_p.h \
qnearfieldtagtype4_p.h \
qtlv_p.h \
- checksum_p.h \
qndefnfcsmartposterrecord_p.h
SOURCES += \
diff --git a/src/nfc/qnearfieldtarget.cpp b/src/nfc/qnearfieldtarget.cpp
index f95d2ee1..542b66fe 100644
--- a/src/nfc/qnearfieldtarget.cpp
+++ b/src/nfc/qnearfieldtarget.cpp
@@ -130,13 +130,34 @@ QT_BEGIN_NAMESPACE_NFC
*/
/*!
- \fn qNfcChecksum(const char *data, uint len)
+ \fn quint16 qNfcChecksum(const char *data, uint len)
\relates QNearFieldTarget
Returns the NFC checksum of the first \a len bytes of \a data.
*/
-#include "checksum_p.h"
+// Copied from qbytearray.cpp
+// Modified to initialize the crc with 0x6363 instead of 0xffff and to not invert the final result.
+static const quint16 crc_tbl[16] = {
+ 0x0000, 0x1081, 0x2102, 0x3183,
+ 0x4204, 0x5285, 0x6306, 0x7387,
+ 0x8408, 0x9489, 0xa50a, 0xb58b,
+ 0xc60c, 0xd68d, 0xe70e, 0xf78f
+};
+
+quint16 qNfcChecksum(const char *data, uint len)
+{
+ register quint16 crc = 0x6363;
+ uchar c;
+ const uchar *p = reinterpret_cast<const uchar *>(data);
+ while (len--) {
+ c = *p++;
+ crc = ((crc >> 4) & 0x0fff) ^ crc_tbl[((crc ^ c) & 15)];
+ c >>= 4;
+ crc = ((crc >> 4) & 0x0fff) ^ crc_tbl[((crc ^ c) & 15)];
+ }
+ return crc;
+}
/*!
\fn void QNearFieldTarget::disconnected()
diff --git a/src/nfc/targetemulator.cpp b/src/nfc/targetemulator.cpp
index cfaaf28c..b607b760 100644
--- a/src/nfc/targetemulator.cpp
+++ b/src/nfc/targetemulator.cpp
@@ -47,7 +47,7 @@
#include <QtCore/QDebug>
// Implementation of qNfcChecksum
-#include "checksum_p.h"
+#include "qnearfieldtarget.h"
QT_BEGIN_NAMESPACE_NFC