From aac131d35b8b59eb767ca0c934e4fba4e1199494 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Sun, 28 Nov 2010 16:12:23 -0800 Subject: [PATCH 01/32] Update the README to reflect new info --- README | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/README b/README index 9a4b223..28c91cd 100644 --- a/README +++ b/README @@ -1,23 +1,45 @@ MagRead is an application to read magnetic stripe cards. +It was written by myself, Jeffrey Malone as a fun app to demonstrate the mslib +library that decodes the magnetic stripe data itself. +MagRead should be able to read any magnetic stripe that conforms to the +standards defined by the ABA and the IATA. These two formats are by far the +predominant ones found, and the only exceptions I've personally run across are +hotel keys. + Requirements: - A hardware audio dongle to read the cards, such as those provided by Square for their payment service. + - A compatible audio jack on the device. Compatible jacks are ones that have + a pin-out for audio output and input -- typically headset jacks. These are + found on some newer MacBooks and Thinkpads, along with many other devices. - Qt 4.6 or later (including Qt Multimedia plugin) -It may run on any device meeting the above requirements, but has only been -tested on a Linux desktop machine, a Nokia N8 and a Nokia N900. +Confirmed to work on: +Mac OS X 10.6 on a current MacBook Pro +Linux on a Thinkpad W510 +Windows 7 on a Thinkpad W510 +Nokia N8 with Symbian S^3 +Nokia N900 with Maemo 5 PR 1.3 (For Date: Sun, 28 Nov 2010 16:12:38 -0800 Subject: [PATCH 02/32] Disable the Settings button until it does something of actual use --- magread.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/magread.cpp b/magread.cpp index e36ca91..cd7c334 100644 --- a/magread.cpp +++ b/magread.cpp @@ -63,7 +63,8 @@ MagRead::MagRead(QWidget *parent) : QMainWindow(parent) { //Option and Exit selections #ifndef Q_OS_SYMBIAN - settingsAction = new QAction( "&Settings", this ); +// Removed until settings functionality implemented +// settingsAction = new QAction( "&Settings", this ); aboutAction = new QAction( "&About", this ); connect( aboutAction, SIGNAL( triggered() ), this, SLOT( aboutDialogue() ) ); @@ -161,7 +162,8 @@ void MagRead::mainPage() { #ifdef Q_OS_SYMBIAN QHBoxLayout *optionsBox = new QHBoxLayout; - QPushButton *settingsBtn = new QPushButton( "Settings" ); +// Removed until settings functionality implemented +// QPushButton *settingsBtn = new QPushButton( "Settings" ); optionsBox->addWidget( settingsBtn ); QPushButton *aboutBtn = new QPushButton( "About" ); From 176e0d5de943b25b3fca65387a62ebbef6c0261b Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Sun, 28 Nov 2010 16:13:25 -0800 Subject: [PATCH 03/32] . --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e8224b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.*swp From 0e44bf774a541d2e32f10387ef851f80fbb508d1 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Sun, 28 Nov 2010 16:29:53 -0800 Subject: [PATCH 04/32] update issue tracker to list github, as the program is no longer maemo only --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index ec50faa..e656f5c 100644 --- a/debian/control +++ b/debian/control @@ -16,7 +16,7 @@ Description: Reads magnetic stripe cards data and display it in a familiar format. *Requires that you have a hardware dongle, such as those provided by Square.* See http://blog.tehinterweb.com/ for more details -XSBC-Bugtracker: https://garage.maemo.org/tracker/?group_id=1941 +XSBC-Bugtracker: https://github.com/ieatlint/MagRead/issues XB-Maemo-Icon-26: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c 6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0 From d8e5718879905bc10777b84a1dcaaece6cdddef6 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Sun, 28 Nov 2010 16:37:47 -0800 Subject: [PATCH 05/32] Replace the mistakenly lost unix{} section in project file --- MagRead.pro | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/MagRead.pro b/MagRead.pro index 41f6c9c..70ed379 100644 --- a/MagRead.pro +++ b/MagRead.pro @@ -41,3 +41,13 @@ symbian { TARGET.EPOCHEAPSIZE = 0x020000 0x800000 ICON = "magread.svg" } + +unix { + INSTALLS += target desktop icon48 + target.path = /usr/bin/magread + desktop.path = /usr/share/applications/hildon + desktop.files += maemofiles/magread.desktop + icon48.path = /usr/share/icons/hicolor/48x48/hildon + icon48.files += maemofiles/magread.png +} + From 0ba1cacd06533fe0b424f6b50eefd43abe12c212 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Sun, 28 Nov 2010 22:51:06 -0800 Subject: [PATCH 06/32] Adjust platform-specific font sizes --- magread.cpp | 20 ++++++++++++++------ magread.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/magread.cpp b/magread.cpp index cd7c334..2b377f8 100644 --- a/magread.cpp +++ b/magread.cpp @@ -42,6 +42,12 @@ MagRead::MagRead(QWidget *parent) : QMainWindow(parent) { #endif +#ifdef Q_WS_MAEMO_5 + font.setPointSize( 32 ); +#else + font.setPointSize( 16 ); +#endif + // Start/stop/back selections #ifdef Q_OS_SYMBIAN backSoftKey = new QAction( "Start", this ); @@ -74,13 +80,13 @@ MagRead::MagRead(QWidget *parent) : QMainWindow(parent) { #endif #ifdef Q_WS_MAEMO_5 - menuBar()->addAction( settingsAction ); +// menuBar()->addAction( settingsAction ); menuBar()->addAction( aboutAction ); menuBar()->addAction( exitAction ); #elif !defined( Q_OS_SYMBIAN ) QMenu *fileMenu = menuBar()->addMenu( "&File" ); - fileMenu->addAction( settingsAction ); +// fileMenu->addAction( settingsAction ); fileMenu->addAction( aboutAction ); fileMenu->addAction( exitAction ); #endif @@ -150,7 +156,8 @@ void MagRead::mainPage() { widget->setLayout( layout ); QLabel *label; - label = new QLabel( "MagRead" ); + label = new QLabel( "MagRead" ); + label->setFont( font ); layout->addWidget( label, 1, Qt::AlignHCenter ); QCheckBox *cbox = new QCheckBox( "Show Partial Data" ); @@ -164,7 +171,7 @@ void MagRead::mainPage() { // Removed until settings functionality implemented // QPushButton *settingsBtn = new QPushButton( "Settings" ); - optionsBox->addWidget( settingsBtn ); +// optionsBox->addWidget( settingsBtn ); QPushButton *aboutBtn = new QPushButton( "About" ); optionsBox->addWidget( aboutBtn ); @@ -297,10 +304,11 @@ void MagRead::miscPage( bool partial ) { } tmpStr.replace( '|', "|" ); - tmpStr.prepend( "
" ); - tmpStr.append( "
" ); + tmpStr.prepend( "
" ); + tmpStr.append( "
" ); QLabel *label = new QLabel( tmpStr ); + label->setFont( font ); scroll->setWidget( label ); scroll->setWidgetResizable( true ); diff --git a/magread.h b/magread.h index 1972650..04cd892 100644 --- a/magread.h +++ b/magread.h @@ -68,6 +68,7 @@ class MagRead : public QMainWindow { bool captureAudio; bool partialRead; bool onMainPage; + QFont font; void mainPage(); void creditPage(); From 389b73ad40bd3f3852ba6e32871800b680a65899 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Sun, 28 Nov 2010 22:52:56 -0800 Subject: [PATCH 07/32] Adjust auto-rotate code for Symbian and Maemo specifics Adjust font sizes to better fit their platforms --- aamvacard.cpp | 9 +++++++-- accountcard.cpp | 29 ++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/aamvacard.cpp b/aamvacard.cpp index eb7eac8..e25c771 100644 --- a/aamvacard.cpp +++ b/aamvacard.cpp @@ -8,8 +8,13 @@ AAMVACard::AAMVACard( MagCard *_card ) { layout = new QVBoxLayout; setLayout( layout ); +#ifdef Q_WS_MAEMO_5 + smallFont.setPointSize( 32 ); + medFont.setPointSize( 32 ); +#else smallFont.setPointSize( 12 ); medFont.setPointSize( 16 ); +#endif aamvaIssuerName = new QLabel; aamvaIssuerName->setFont( medFont ); @@ -67,8 +72,8 @@ AAMVACard::AAMVACard( MagCard *_card ) { } void AAMVACard::reorient() { -// QSize geometry = size(); - QRect geometry = QApplication::desktop()->screenGeometry(); + QSize geometry = size(); +// QRect geometry = QApplication::desktop()->screenGeometry(); if( geometry.width() > geometry.height() ) { //landscape diff --git a/accountcard.cpp b/accountcard.cpp index 6e11b4f..34e67cd 100644 --- a/accountcard.cpp +++ b/accountcard.cpp @@ -8,16 +8,19 @@ AccountCard::AccountCard( MagCard *_card ) { layout = new QVBoxLayout; setLayout( layout ); - //smallFont.setPointSize( 12 ); - //medFont.setPointSize( 16 ); +#ifdef Q_WS_MAEMO_5 smallFont.setPointSize( 32 ); medFont.setPointSize( 32 ); +#else + smallFont.setPointSize( 12 ); + medFont.setPointSize( 16 ); +#endif accountNumber = new QLabel; layout->addWidget( accountNumber, 1, Qt::AlignHCenter ); accountHolder = new QLabel; - accountHolder->setFont( medFont ); + accountHolder->setFont( smallFont ); layout->addWidget( accountHolder, 1, Qt::AlignHCenter ); label = new QLabel( "Expiration Date" ); @@ -58,18 +61,26 @@ AccountCard::AccountCard( MagCard *_card ) { if( _card ) { card = _card; showData(); - } + }; } void AccountCard::reorient() { -// QSize geometry = size(); +#ifdef Q_OS_SYMBIAN + // for some reason, this works only on symbian, and the else works on everything but symbian QRect geometry = QApplication::desktop()->screenGeometry(); +#else + QSize geometry = size(); +#endif if( geometry.width() > geometry.height() ) { //landscape if( orientation != LANDSCAPE ) { qDebug() << "Landscape Mode"; - accountNumberFont.setPointSize( 48 );//18 +#ifdef Q_WS_MAEMO_5 + accountNumberFont.setPointSize( 48 ); +#else + accountNumberFont.setPointSize( 18 ); +#endif accountNumber->setFont( accountNumberFont ); layout->removeItem( layout->itemAt( 2 ) ); @@ -81,7 +92,11 @@ void AccountCard::reorient() { //portrait if( orientation != PORTRAIT ) { qDebug() << "Portrait Mode"; - accountNumberFont.setPointSize( 32 );//12 +#ifdef Q_WS_MAEMO_5 + accountNumberFont.setPointSize( 32 ); +#else + accountNumberFont.setPointSize( 12 ); +#endif accountNumber->setFont( accountNumberFont ); layout->removeItem( layout->itemAt( 2 ) ); From 7575c86571d1df8f3b1f4e4e3224c485461fc690 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Mon, 29 Nov 2010 00:10:25 -0800 Subject: [PATCH 08/32] Update changelog for 0.1.3 release. Update dependencies for debian control file to reflect the removal of pulseaudio as a dependency, and add libqt4-multimedia as a dependency. --- debian/changelog | 14 ++++++++++++++ debian/control | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index ed50c51..cc72483 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,17 @@ +magread (0.1.3) stable; urgency=low + + * Moved entirely over to Qt. Now requires PR1.3 to successfully read cards. + * Added support for Symbian, Windows, OS X and Linux + * Supports auto-rotate functionality; redraws the screen to suite current + orientation. + * Fixed several bugs + * Added an about dialogue that includes a version number and a link to my + blog. + * Moved all issue tracking from the Maemo Garage to github because it is now + a multiplatform program. + + -- Jeffrey Malone Sun, 28 Nov 2010 22:56:47 -0700 + magread (0.1.1) unstable; urgency=low * Fixed missing icon diff --git a/debian/control b/debian/control index e656f5c..1e07eca 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: magread Section: user/utilities Priority: extra Maintainer: Jeffrey Malone -Build-Depends: debhelper (>= 5), libqt4-dev (>=4.6.1), libpulse-dev +Build-Depends: debhelper (>= 5), libqt4-dev (>=4.6.1), libqt4-multimedia (>=4.6.1) Standards-Version: 3.7.3 Package: magread From a879801068add99547f5537386618e8eff958dbf Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Tue, 30 Nov 2010 09:06:48 -0800 Subject: [PATCH 09/32] Fix a formatting issue for driver licence numbers --- carddetect.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/carddetect.cpp b/carddetect.cpp index 3635dfc..cdc0472 100644 --- a/carddetect.cpp +++ b/carddetect.cpp @@ -187,7 +187,7 @@ void CardDetect::aamvaCardCheck( QString expDate ) { card->accountNumber.remove( iin ); if( card->miscData.length() > 8 ) card->accountNumber.append( card->miscData.mid( 8 ) ); - + //format the id number if applicable if( !issuerInfo.format.isEmpty() ) { for( int i = 0; i < issuerInfo.format.length(); i++ ) { @@ -199,10 +199,14 @@ void CardDetect::aamvaCardCheck( QString expDate ) { card->accountNumber.replace( i, 2, letter ); } else if( issuerInfo.format.at( i ) != 'N' ) { card->accountNumber.insert( i, issuerInfo.format.at( i ) ); + } else if( card->accountNumber.at( i ) == '=' ) { + card->accountNumber.replace( i, 1, '0' ); } } } + card->accountNumber.remove( '=' ); + //set the birthday QString bday = card->miscData.left( 8 ); if( bday.mid( 4, 2 ) > "12" ) { //some (Calif) violate AAMVA standard and switch the exp and bday month values From 8f564afff43922c145803fffe8609ca6a0b9cf87 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Wed, 1 Dec 2010 14:38:36 -0800 Subject: [PATCH 10/32] Move changelog to root dir, and setup a symlink for debian --- ChangeLog | 28 ++++++++++++++++++++++++++++ debian/changelog | 29 +---------------------------- 2 files changed, 29 insertions(+), 28 deletions(-) create mode 100644 ChangeLog mode change 100644 => 120000 debian/changelog diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..cc72483 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,28 @@ +magread (0.1.3) stable; urgency=low + + * Moved entirely over to Qt. Now requires PR1.3 to successfully read cards. + * Added support for Symbian, Windows, OS X and Linux + * Supports auto-rotate functionality; redraws the screen to suite current + orientation. + * Fixed several bugs + * Added an about dialogue that includes a version number and a link to my + blog. + * Moved all issue tracking from the Maemo Garage to github because it is now + a multiplatform program. + + -- Jeffrey Malone Sun, 28 Nov 2010 22:56:47 -0700 + +magread (0.1.1) unstable; urgency=low + + * Fixed missing icon + * Rotated icon 180 degrees + * Fixed a leap year issue for calculating ages that could result in 1 day + age skew. + + -- Jeffrey Malone Sat, 6 Nov 2010 16:06:47 -0700 + +magread (0.1.0) unstable; urgency=low + + * Initial release + + -- Jeffrey Malone Thu, 04 Nov 2010 06:10:14 -0700 diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index cc72483..0000000 --- a/debian/changelog +++ /dev/null @@ -1,28 +0,0 @@ -magread (0.1.3) stable; urgency=low - - * Moved entirely over to Qt. Now requires PR1.3 to successfully read cards. - * Added support for Symbian, Windows, OS X and Linux - * Supports auto-rotate functionality; redraws the screen to suite current - orientation. - * Fixed several bugs - * Added an about dialogue that includes a version number and a link to my - blog. - * Moved all issue tracking from the Maemo Garage to github because it is now - a multiplatform program. - - -- Jeffrey Malone Sun, 28 Nov 2010 22:56:47 -0700 - -magread (0.1.1) unstable; urgency=low - - * Fixed missing icon - * Rotated icon 180 degrees - * Fixed a leap year issue for calculating ages that could result in 1 day - age skew. - - -- Jeffrey Malone Sat, 6 Nov 2010 16:06:47 -0700 - -magread (0.1.0) unstable; urgency=low - - * Initial release - - -- Jeffrey Malone Thu, 04 Nov 2010 06:10:14 -0700 diff --git a/debian/changelog b/debian/changelog new file mode 120000 index 0000000..22ec9b8 --- /dev/null +++ b/debian/changelog @@ -0,0 +1 @@ +../ChangeLog \ No newline at end of file From a7ad30652071aff4e3f784369c78266781f996f7 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Wed, 1 Dec 2010 15:12:52 -0800 Subject: [PATCH 11/32] Hide the accountHolder QLabel for track2 swipes so the formattings looks right --- accountcard.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/accountcard.cpp b/accountcard.cpp index 34e67cd..23d1970 100644 --- a/accountcard.cpp +++ b/accountcard.cpp @@ -138,8 +138,10 @@ void AccountCard::showData() { if( !card->accountHolder.isEmpty() ) accountHolder->setText( card->accountHolder ); - else + else { + accountHolder->hide(); accountHolder->clear(); + } /* Expiration Date */ tmpStr = card->expirationDate.toString( "MMM dd, yyyy" ); From 0237b1e7df299784e5f7884abfb9d28856502bce Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Wed, 1 Dec 2010 15:13:20 -0800 Subject: [PATCH 12/32] Create a timeout so that it doesn't start a bad loop of failed reads --- magdecode.cpp | 10 ++++++++++ magdecode.h | 1 + 2 files changed, 11 insertions(+) diff --git a/magdecode.cpp b/magdecode.cpp index 61a532d..6973726 100644 --- a/magdecode.cpp +++ b/magdecode.cpp @@ -11,6 +11,8 @@ MagDecode::MagDecode(QObject *parent) : QIODevice(parent) { normOffsetFound = false; normOffset = 0; + + timeOut = 0; } void MagDecode::start() { @@ -25,6 +27,11 @@ qint64 MagDecode::writeData( const char *data, qint64 dataLen ) { if( !captureAudio ) return dataLen; + if( timeOut > 0 ) { + timeOut--; + return dataLen; + } + const qint16 *pcmDataBlock = reinterpret_cast( data ); int blockLen = dataLen / sizeof( qint16 ); @@ -68,6 +75,9 @@ qint64 MagDecode::writeData( const char *data, qint64 dataLen ) { void MagDecode::processSwipe() { bool valid; + //Starting off with a simple one of a 10 block timeout + timeOut = 10; + //Normalize the audio based on calculated 0 level for( int i = 0; i < pcmData.count(); i++ ) pcmData[ i ] -= normOffset; diff --git a/magdecode.h b/magdecode.h index d3d2493..0413b04 100644 --- a/magdecode.h +++ b/magdecode.h @@ -22,6 +22,7 @@ class MagDecode : public QIODevice int silenceCount; bool noiseDetected; bool captureAudio; + int timeOut; void processSwipe(); int silenceThreshold; From ad0bf11733a69e9957069ee573f3f182a6c27ba2 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Wed, 1 Dec 2010 15:13:57 -0800 Subject: [PATCH 13/32] Add the pro.user file to the ignore list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9e8224b..67bb9fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +MagRead.pro.user .*swp From 6462b7b673da3e0feb6d2a2a74425da07958a794 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Wed, 1 Dec 2010 15:18:55 -0800 Subject: [PATCH 14/32] Update ChangeLog and version number to 0.1.3-01 for a bugfix release --- ChangeLog | 9 +++++++++ MagRead.pro | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index cc72483..c28f0b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +magread (0.1.3-01) stable; urgency=low + + * Fixed a bug (#1) in displaying driver licence/id numbers from some states + * Fixed a formatting issue (#7) for bank cards read from track 2 + * Fixed a bug (#9) that could cause a bad loop of failed reads that could + prevent the user from easily stopping the process. + + -- Jeffrey Malone Wed, 1 Dec 2010 15:19:00 -0700 + magread (0.1.3) stable; urgency=low * Moved entirely over to Qt. Now requires PR1.3 to successfully read cards. diff --git a/MagRead.pro b/MagRead.pro index 70ed379..09790ca 100644 --- a/MagRead.pro +++ b/MagRead.pro @@ -13,7 +13,7 @@ maemo5 { TARGET = MagRead TEMPLATE = app -VERSION = 0.1.3 +VERSION = 0.1.3-01 DEFINES += APP_VERSION=$$VERSION SOURCES += main.cpp\ From 22d2714e07cc6ad4c465bf4400f5828daa11e6ba Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Thu, 2 Dec 2010 11:11:39 -0800 Subject: [PATCH 15/32] Add clear() method to MagCard --- magcard.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/magcard.h b/magcard.h index d72ceb2..6738bf9 100644 --- a/magcard.h +++ b/magcard.h @@ -66,6 +66,13 @@ class MagCard { swipeValid = false; } + void clear() { + type = CARD_UNSET; + charStream.clear(); + bitStream.clear(); + accountNumber.clear(); + } + }; Q_DECLARE_OPERATORS_FOR_FLAGS( MagCard::Types ) From 2297d56136449dcc26d8dda4e5fcf757a941df07 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Thu, 2 Dec 2010 11:28:44 -0800 Subject: [PATCH 16/32] Add feature as described in issue #6 to desktop and Maemo. Symbian support TBD --- magread.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- magread.h | 6 ++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/magread.cpp b/magread.cpp index 2b377f8..9f3eebd 100644 --- a/magread.cpp +++ b/magread.cpp @@ -77,6 +77,9 @@ MagRead::MagRead(QWidget *parent) : QMainWindow(parent) { exitAction = new QAction( "E&xit", this ); connect( exitAction, SIGNAL( triggered() ), this, SLOT( close() ) ); + + showDataAction = new QAction( "Show &Data", this ); + connect( showDataAction, SIGNAL( triggered() ), this, SLOT( showData() ) ); #endif #ifdef Q_WS_MAEMO_5 @@ -84,7 +87,7 @@ MagRead::MagRead(QWidget *parent) : QMainWindow(parent) { menuBar()->addAction( aboutAction ); menuBar()->addAction( exitAction ); #elif !defined( Q_OS_SYMBIAN ) - QMenu *fileMenu = menuBar()->addMenu( "&File" ); + fileMenu = menuBar()->addMenu( "&File" ); // fileMenu->addAction( settingsAction ); fileMenu->addAction( aboutAction ); @@ -130,6 +133,12 @@ void MagRead::notice( QString msg, int timeout, mboxStatus status ) { } +void MagRead::showData() { + if( !card.charStream.isEmpty() ) { + miscPage(); + } +} + void MagRead::cardRead( const MagCard _card ) { card = _card; cardDetect.setCard( &card ); @@ -188,6 +197,8 @@ void MagRead::mainPage() { mainLayout->insertWidget( 0, widget, 1 ); #endif + removeShowData(); + } void MagRead::aboutDialogue() { @@ -213,6 +224,7 @@ void MagRead::toggleRead() { backStr = "Stop"; captureAudio = true; } else { + card.clear(); backStr = "Start"; mainPage(); } @@ -250,6 +262,26 @@ void MagRead::togglePartialRead( bool _partialRead ) { partialRead = _partialRead; } +void MagRead::addShowData() { +#ifdef Q_WS_MAEMO_5 + if( !menuBar()->actions().contains( showDataAction ) ) + menuBar()->addAction( showDataAction ); +#elif !defined( Q_OS_SYMBIAN ) + if( !fileMenu->actions().contains( showDataAction ) ) + fileMenu->addAction( showDataAction ); +#endif +} + +void MagRead::removeShowData() { +#ifdef Q_WS_MAEMO_5 + if( menuBar()->actions().contains( showDataAction ) ) + menuBar()->removeAction( showDataAction ); +#elif !defined( Q_OS_SYMBIAN ) + if( fileMenu->actions().contains( showDataAction ) ) + fileMenu->removeAction( showDataAction ); +#endif +} + /* Credit Page */ void MagRead::creditPage() { notice( "Successfully Read Credit Card", 750 ); @@ -267,6 +299,9 @@ void MagRead::creditPage() { } mainLayout->insertWidget( 0, accountCard, 1 ); #endif + + addShowData(); + } void MagRead::aamvaPage() { @@ -285,6 +320,8 @@ void MagRead::aamvaPage() { } mainLayout->insertWidget( 0, aamvaCard, 1 ); #endif + + addShowData(); } /* Misc Page */ @@ -323,6 +360,8 @@ void MagRead::miscPage( bool partial ) { } mainLayout->insertWidget( 0, scroll, 1 ); #endif + + removeShowData(); } diff --git a/magread.h b/magread.h index 04cd892..5a7c838 100644 --- a/magread.h +++ b/magread.h @@ -88,7 +88,12 @@ class MagRead : public QMainWindow { QAction *settingsAction; QAction *aboutAction; QAction *exitAction; + QAction *showDataAction; #endif + void addShowData(); + void removeShowData(); + + QMenu *fileMenu; enum mboxStatus { INFORMATION, @@ -102,6 +107,7 @@ class MagRead : public QMainWindow { void toggleRead(); void togglePartialRead( bool _partialRead ); void aboutDialogue(); + void showData(); }; #endif // MAGREAD_H From 0678d35c27daab11ec2c253e3f83c6a8517303dc Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Sat, 4 Dec 2010 18:04:01 -0800 Subject: [PATCH 17/32] Half-implemented system for the settings page --- MagRead.pro | 7 ++- magread.cpp | 31 +++++++++- magread.h | 3 + settingspage.cpp | 152 +++++++++++++++++++++++++++++++++++++++++++++++ settingspage.h | 60 +++++++++++++++++++ 5 files changed, 247 insertions(+), 6 deletions(-) create mode 100644 settingspage.cpp create mode 100644 settingspage.h diff --git a/MagRead.pro b/MagRead.pro index 09790ca..ad6de1c 100644 --- a/MagRead.pro +++ b/MagRead.pro @@ -23,7 +23,8 @@ SOURCES += main.cpp\ mslib.c \ llist.c \ accountcard.cpp \ - aamvacard.cpp + aamvacard.cpp \ + settingspage.cpp HEADERS += magread.h \ carddetect.h \ @@ -32,7 +33,8 @@ HEADERS += magread.h \ llist.h \ magcard.h \ accountcard.h \ - aamvacard.h + aamvacard.h \ + settingspage.h symbian { TARGET.UID3 = 0xe2c961e1 @@ -50,4 +52,3 @@ unix { icon48.path = /usr/share/icons/hicolor/48x48/hildon icon48.files += maemofiles/magread.png } - diff --git a/magread.cpp b/magread.cpp index 9f3eebd..3cad038 100644 --- a/magread.cpp +++ b/magread.cpp @@ -70,7 +70,8 @@ MagRead::MagRead(QWidget *parent) : QMainWindow(parent) { #ifndef Q_OS_SYMBIAN // Removed until settings functionality implemented -// settingsAction = new QAction( "&Settings", this ); + settingsAction = new QAction( "&Settings", this ); + connect( settingsAction, SIGNAL( triggered() ), this, SLOT( settingsPage() ) ); aboutAction = new QAction( "&About", this ); connect( aboutAction, SIGNAL( triggered() ), this, SLOT( aboutDialogue() ) ); @@ -83,13 +84,13 @@ MagRead::MagRead(QWidget *parent) : QMainWindow(parent) { #endif #ifdef Q_WS_MAEMO_5 -// menuBar()->addAction( settingsAction ); + menuBar()->addAction( settingsAction ); menuBar()->addAction( aboutAction ); menuBar()->addAction( exitAction ); #elif !defined( Q_OS_SYMBIAN ) fileMenu = menuBar()->addMenu( "&File" ); -// fileMenu->addAction( settingsAction ); + fileMenu->addAction( settingsAction ); fileMenu->addAction( aboutAction ); fileMenu->addAction( exitAction ); #endif @@ -282,6 +283,30 @@ void MagRead::removeShowData() { #endif } +void MagRead::settingsPage() { + onMainPage = false; + + SettingsPage *settings = new SettingsPage; + +#ifdef Q_OS_SYMBIAN + setCentralWidget( settings ); +#else + if( mainLayout->count() > 1 ) { + mainLayout->itemAt( 0 )->widget()->hide(); + mainLayout->removeItem( mainLayout->itemAt( 0 ) ); + } + mainLayout->insertWidget( 0, settings, 1 ); +#endif + +#ifdef Q_OS_SYMBIAN + backSoftKey->setText( "Back" ); +#else + mainBackBtn->setText( "Back" ); +#endif + + removeShowData(); +} + /* Credit Page */ void MagRead::creditPage() { notice( "Successfully Read Credit Card", 750 ); diff --git a/magread.h b/magread.h index 5a7c838..3977a46 100644 --- a/magread.h +++ b/magread.h @@ -52,6 +52,8 @@ #include "accountcard.h" #include "aamvacard.h" +#include "settingspage.h" + class MagRead : public QMainWindow { Q_OBJECT @@ -108,6 +110,7 @@ class MagRead : public QMainWindow { void togglePartialRead( bool _partialRead ); void aboutDialogue(); void showData(); + void settingsPage(); }; #endif // MAGREAD_H diff --git a/settingspage.cpp b/settingspage.cpp new file mode 100644 index 0000000..f241e34 --- /dev/null +++ b/settingspage.cpp @@ -0,0 +1,152 @@ +#include "settingspage.h" + +SettingsPage::SettingsPage(QObject *parent) { + widget = new QWidget; + + layout = new QVBoxLayout; + widget->setLayout( layout ); + + settings = new QSettings; + + makeGeneralBox(); + makeAudioBox(); + + setWidget( widget ); + setWidgetResizable( true ); +} + +void SettingsPage::makeGeneralBox() { + generalBox = new QGroupBox( "General Settings" ); + + generalLayout = new QVBoxLayout; + + formatCredit = new QCheckBox( "Format Bank Cards" ); + generalLayout->addWidget( formatCredit ); + if( settings->value( "formatCredit" ) == true ) + formatCredit->setCheckState( Qt::Checked ); + connect( formatCredit, SIGNAL( stateChanged( int ) ), this, SLOT( formatCredit_checked( int ) ) ); + + formatAAMVA = new QCheckBox( "Format AAMVA Cards" ); + generalLayout->addWidget( formatAAMVA ); + if( settings->value( "formatAAMVA" ) == true ) + formatCredit->setCheckState( Qt::Checked ); + connect( formatAAMVA, SIGNAL( stateChanged( int ) ), this, SLOT( formatAAMVA_checked( int ) ) ); + +#ifndef Q_OS_SYMBIAN + autoReorient = new QCheckBox( "Auto-reorient Screen" );//not symbian + generalLayout->addWidget( autoReorient ); + if( settings->value( "autoReorient" ) == true ) + autoReorient->setCheckState( Qt::Checked ); + connect( autoReorient, SIGNAL( stateChanged( int ) ), this, SLOT( autoReorient_checked( int ) ) ); +#endif + timeOutLabel = new QLabel( "Timeout: 10" ); + generalLayout->addWidget( timeOutLabel ); + + timeOutSlider = new QSlider( Qt::Horizontal ); + timeOutSlider->setTickInterval( 1 ); + timeOutSlider->setRange( 0, 100 ); + if( settings->contains( "timeOut" ) ) { + timeOutLabel->setText( QString( "Timeout: %1" ).arg( settings->value( "timeOut" ).toInt() ) ); + timeOutSlider->setSliderPosition( settings->value( "timeOut" ).toInt() ); + } else { + timeOutSlider->setSliderPosition( 10 ); + } + + connect( timeOutSlider, SIGNAL( valueChanged( int ) ), this, SLOT( timeOutChanged( int ) ) ); + + generalLayout->addWidget( timeOutSlider ); + + generalBox->setLayout( generalLayout ); + + layout->addWidget( generalBox ); +} + +void SettingsPage::formatCredit_checked( int state ) { + if( state == Qt::Checked ) + settings->setValue( "formatCredit", true ); + else + settings->setValue( "formatCredit", false ); +} + +void SettingsPage::formatAAMVA_checked( int state ) { + if( state == Qt::Checked ) + settings->setValue( "formatAAMVA", true ); + else + settings->setValue( "formatAAMVA", false ); +} + +void SettingsPage::autoReorient_checked( int state ) { + if( state == Qt::Checked ) + settings->setValue( "autoReorient", true ); + else + settings->setValue( "autoReorient", false ); +} + +void SettingsPage::timeOutChanged( int value ) { + timeOutLabel->setText( QString( "Timeout: %1" ).arg( value ) ); + settings->setValue( "timeOut", value ); +} + +void SettingsPage::makeAudioBox() { + audioBox = new QGroupBox( "Audio Settings" ); + + audioLayout = new QVBoxLayout; + + audioLayout->addWidget( new QLabel( "Audio Input:" ) ); + audioSource = new QComboBox; + QList inputDevices = QAudioDeviceInfo::availableDevices( QAudio::AudioInput ); + for( int i = 0; i < inputDevices.size(); i++ ) { + //audioSource->addItem( inputDevices.at( i ).deviceName(), qVariantFromValue( inputDevices.at( i ) ) ); + audioSource->addItem( inputDevices.at( i ).deviceName() ); + } + audioLayout->addWidget( audioSource ); + + normCBox = new QCheckBox( "Auto-Detect Normalzation" ); + normCBox->setCheckState( Qt::Checked ); + audioLayout->addWidget( normCBox ); + connect( normCBox, SIGNAL( stateChanged( int ) ), this, SLOT( normChecked( int ) ) ); + + normLabel = new QLabel( "Normalization: Auto-Detect" ); + audioLayout->addWidget( normLabel ); + + normSlider = new QSlider( Qt::Horizontal ); + normSlider->setTickInterval( 10 ); + normSlider->setRange( -500, 500 ); + normSlider->setSliderPosition( 0 ); + normSlider->setEnabled( false ); + audioLayout->addWidget( normSlider ); + connect( normSlider, SIGNAL( valueChanged( int ) ), this, SLOT( normChanged( int ) ) ); + + silenceLabel = new QLabel( "Silence Theshold: 300" ); + audioLayout->addWidget( silenceLabel ); + + silenceSlider = new QSlider( Qt::Horizontal ); + silenceSlider->setTickInterval( 20 ); + silenceSlider->setRange( 0, 1000 ); + silenceSlider->setSliderPosition( 300 ); + audioLayout->addWidget( silenceSlider ); + connect( silenceSlider, SIGNAL( valueChanged( int ) ), this, SLOT( silenceChanged( int ) ) ); + + audioBox->setLayout( audioLayout ); + + layout->addWidget( audioBox ); +} + +void SettingsPage::normChecked( int state ) { + if( state == Qt::Checked ) { + normSlider->setEnabled( false ); + normLabel->setText( "Normalization: Auto-Detect" ); + } else { + normSlider->setEnabled( true ); + normLabel->setText( QString( "Normalization: %1" ).arg( normSlider->value() ) ); + } +} + +void SettingsPage::silenceChanged( int value ) { + silenceLabel->setText( QString( "Silence Threshold: %1" ).arg( value ) ); +} + +void SettingsPage::normChanged( int value ) { + normLabel->setText( QString( "Normalization: %1" ).arg( value ) ); +} + diff --git a/settingspage.h b/settingspage.h new file mode 100644 index 0000000..b502742 --- /dev/null +++ b/settingspage.h @@ -0,0 +1,60 @@ +#ifndef SETTINGSPAGE_H +#define SETTINGSPAGE_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class SettingsPage : public QScrollArea { + Q_OBJECT + public: + explicit SettingsPage(QObject *parent = 0); + + private: + QSettings *settings; + + QWidget *widget; + QVBoxLayout *layout; + + /* General Settings */ + void makeGeneralBox(); + QGroupBox *generalBox; + QVBoxLayout *generalLayout; + QCheckBox *formatCredit; + QCheckBox *formatAAMVA; + QCheckBox *autoReorient; + QLabel *timeOutLabel; + QSlider *timeOutSlider; + + /* Audio Box */ + void makeAudioBox(); + QGroupBox *audioBox; + QVBoxLayout *audioLayout; + QComboBox *audioSource; + QCheckBox *normCBox; + QLabel *normLabel; + QSlider *normSlider; + QLabel *silenceLabel; + QSlider *silenceSlider; + + signals: + + private slots: + void formatCredit_checked( int state ); + void formatAAMVA_checked( int state ); + void autoReorient_checked( int state ); + + void timeOutChanged( int value ); + void normChanged( int value ); + void silenceChanged( int value ); + void normChecked( int state ); + +}; + +#endif // SETTINGSPAGE_H From 706fdacbd760b4836bd415a6d694b416854a94ad Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Sat, 4 Dec 2010 18:38:01 -0800 Subject: [PATCH 18/32] Finish most of the implementation of the settings page (except audio source) --- settingspage.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++---- settingspage.h | 4 ++++ 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/settingspage.cpp b/settingspage.cpp index f241e34..de2467f 100644 --- a/settingspage.cpp +++ b/settingspage.cpp @@ -7,10 +7,16 @@ SettingsPage::SettingsPage(QObject *parent) { widget->setLayout( layout ); settings = new QSettings; + if( !settings->contains( "formatCredit" ) ) + resetAll( false ); makeGeneralBox(); makeAudioBox(); + resetButton = new QPushButton( "Reset to defaults" ); + layout->addWidget( resetButton ); + connect( resetButton, SIGNAL( clicked() ), this, SLOT( resetAll() ) ); + setWidget( widget ); setWidgetResizable( true ); } @@ -102,21 +108,31 @@ void SettingsPage::makeAudioBox() { audioLayout->addWidget( audioSource ); normCBox = new QCheckBox( "Auto-Detect Normalzation" ); - normCBox->setCheckState( Qt::Checked ); audioLayout->addWidget( normCBox ); connect( normCBox, SIGNAL( stateChanged( int ) ), this, SLOT( normChecked( int ) ) ); - normLabel = new QLabel( "Normalization: Auto-Detect" ); + normLabel = new QLabel; audioLayout->addWidget( normLabel ); normSlider = new QSlider( Qt::Horizontal ); normSlider->setTickInterval( 10 ); normSlider->setRange( -500, 500 ); - normSlider->setSliderPosition( 0 ); - normSlider->setEnabled( false ); audioLayout->addWidget( normSlider ); connect( normSlider, SIGNAL( valueChanged( int ) ), this, SLOT( normChanged( int ) ) ); + if( settings->contains( "norm" ) ) + normSlider->setSliderPosition( settings->value( "norm" ).toInt() ); + else + normSlider->setSliderPosition( 0 ); + + if( !settings->contains( "normAuto" ) || settings->value( "normAuto" ) == true ) { + normCBox->setCheckState( Qt::Checked ); + normSlider->setEnabled( false ); + normLabel->setText( QString( "Normalization: Auto-Detect" ) ); + } else { + normLabel->setText( QString( "Normalization: %1" ).arg( normSlider->value() ) ); + } + silenceLabel = new QLabel( "Silence Theshold: 300" ); audioLayout->addWidget( silenceLabel ); @@ -127,6 +143,14 @@ void SettingsPage::makeAudioBox() { audioLayout->addWidget( silenceSlider ); connect( silenceSlider, SIGNAL( valueChanged( int ) ), this, SLOT( silenceChanged( int ) ) ); + if( settings->contains( "silenceThreshold" ) ) { + silenceSlider->setSliderPosition( settings->value( "silenceThreshold" ).toInt() ); + } else { + silenceSlider->setSliderPosition( 300 ); + } + + silenceLabel->setText( QString( "Silence Threshold: %1" ).arg( silenceSlider->value() ) ); + audioBox->setLayout( audioLayout ); layout->addWidget( audioBox ); @@ -136,17 +160,46 @@ void SettingsPage::normChecked( int state ) { if( state == Qt::Checked ) { normSlider->setEnabled( false ); normLabel->setText( "Normalization: Auto-Detect" ); + settings->setValue( "normAuto", true ); } else { normSlider->setEnabled( true ); normLabel->setText( QString( "Normalization: %1" ).arg( normSlider->value() ) ); + settings->setValue( "normAuto", false ); } } void SettingsPage::silenceChanged( int value ) { silenceLabel->setText( QString( "Silence Threshold: %1" ).arg( value ) ); + settings->setValue( "silenceThreshold", value ); } void SettingsPage::normChanged( int value ) { normLabel->setText( QString( "Normalization: %1" ).arg( value ) ); + settings->setValue( "norm", value ); } + + +void SettingsPage::resetAll( bool updateGui ) { + settings->setValue( "formatCredit", true ); + settings->setValue( "formatAAMVA", true ); + settings->setValue( "autoReorient", true ); + settings->setValue( "timeOut", 10 ); + + settings->setValue( "normAuto", true ); + settings->setValue( "norm", 0 ); + settings->setValue( "silenceThreshold", 300 ); + + if( updateGui ) { + formatCredit->setCheckState( Qt::Checked ); + formatAAMVA->setCheckState( Qt::Checked ); + autoReorient->setCheckState( Qt::Checked ); + timeOutChanged( 10 ); + + normCBox->setCheckState( Qt::Checked ); + normSlider->setSliderPosition( 0 ); + normLabel->setText( "Normalization: Auto-Detect" ); + + silenceChanged( 300 ); + } +} diff --git a/settingspage.h b/settingspage.h index b502742..fce6f52 100644 --- a/settingspage.h +++ b/settingspage.h @@ -10,6 +10,7 @@ #include #include #include +#include class SettingsPage : public QScrollArea { Q_OBJECT @@ -21,6 +22,7 @@ class SettingsPage : public QScrollArea { QWidget *widget; QVBoxLayout *layout; + QPushButton *resetButton; /* General Settings */ void makeGeneralBox(); @@ -55,6 +57,8 @@ class SettingsPage : public QScrollArea { void silenceChanged( int value ); void normChecked( int state ); + void resetAll( bool updateGui = true ); + }; #endif // SETTINGSPAGE_H From 8327b25d9b3413d0a60185f88b69fd05506458fb Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Sat, 4 Dec 2010 18:49:25 -0800 Subject: [PATCH 19/32] Small fix, referenced wrong object --- settingspage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settingspage.cpp b/settingspage.cpp index de2467f..52f839b 100644 --- a/settingspage.cpp +++ b/settingspage.cpp @@ -35,7 +35,7 @@ void SettingsPage::makeGeneralBox() { formatAAMVA = new QCheckBox( "Format AAMVA Cards" ); generalLayout->addWidget( formatAAMVA ); if( settings->value( "formatAAMVA" ) == true ) - formatCredit->setCheckState( Qt::Checked ); + formatAAMVA->setCheckState( Qt::Checked ); connect( formatAAMVA, SIGNAL( stateChanged( int ) ), this, SLOT( formatAAMVA_checked( int ) ) ); #ifndef Q_OS_SYMBIAN From b27b53f9154277c7bddbdb6b4f0a6f234a0b2800 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Sat, 4 Dec 2010 19:30:56 -0800 Subject: [PATCH 20/32] Now enabled the settings for formatting AAMVA/bank cards. Further resolution to issue 6 and 5 --- magread.cpp | 13 +++++++++++-- magread.h | 2 ++ main.cpp | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/magread.cpp b/magread.cpp index 3cad038..ef73146 100644 --- a/magread.cpp +++ b/magread.cpp @@ -36,6 +36,8 @@ MagRead::MagRead(QWidget *parent) : QMainWindow(parent) { qRegisterMetaType( "MagCard" ); + settings = new QSettings; + //Set the auto-rotation for Maemo5 #ifdef Q_WS_MAEMO_5 setAttribute(Qt::WA_Maemo5AutoOrientation, true); @@ -145,9 +147,16 @@ void MagRead::cardRead( const MagCard _card ) { cardDetect.setCard( &card ); if( ( card.type & MagCard::CARD_CC || card.type == MagCard::CARD_AAA ) && card.accountValid ) { - creditPage(); + if( settings->value( "formatCredit" ) == true ) + creditPage(); + else + miscPage(); + } else if( card.type == MagCard::CARD_AAMVA ) { - aamvaPage(); + if( settings->value( "formatAAMVA" ) == true ) + aamvaPage(); + else + miscPage(); } else if( card.swipeValid ) { miscPage(); } else if( partialRead && !card.charStream.isEmpty() ) { diff --git a/magread.h b/magread.h index 3977a46..b16f7d8 100644 --- a/magread.h +++ b/magread.h @@ -72,6 +72,8 @@ class MagRead : public QMainWindow { bool onMainPage; QFont font; + QSettings *settings; + void mainPage(); void creditPage(); void aamvaPage(); diff --git a/main.cpp b/main.cpp index adef377..2aa8102 100644 --- a/main.cpp +++ b/main.cpp @@ -23,11 +23,12 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - MagRead w; a.setApplicationName( "MagRead" ); a.setApplicationVersion( QUOTE( APP_VERSION ) ); a.setOrganizationDomain( "tehinterweb.com" ); a.setOrganizationName( "lint" ); + + MagRead w; #if defined(Q_WS_S60) w.showMaximized(); #else From 1319c7478b02bd7a6a5c544948eefebb2478f7d0 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Sat, 4 Dec 2010 19:57:41 -0800 Subject: [PATCH 21/32] Implement the setting to turn on/off auto-rotation for maemo 5 --- magread.cpp | 17 +++++++++++++---- magread.h | 1 + settingspage.cpp | 11 +++++++++-- settingspage.h | 1 + 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/magread.cpp b/magread.cpp index ef73146..1282aa9 100644 --- a/magread.cpp +++ b/magread.cpp @@ -40,7 +40,9 @@ MagRead::MagRead(QWidget *parent) : QMainWindow(parent) { //Set the auto-rotation for Maemo5 #ifdef Q_WS_MAEMO_5 - setAttribute(Qt::WA_Maemo5AutoOrientation, true); + if( settings->value( "autoReorient" ) == true ) { + setAttribute( Qt::WA_Maemo5AutoOrientation, true ); + } #endif @@ -295,16 +297,17 @@ void MagRead::removeShowData() { void MagRead::settingsPage() { onMainPage = false; - SettingsPage *settings = new SettingsPage; + SettingsPage *settingsWidget = new SettingsPage; + connect( settingsWidget, SIGNAL( autoReorientSig( bool ) ), this, SLOT( autoReorient( bool ) ) ); #ifdef Q_OS_SYMBIAN - setCentralWidget( settings ); + setCentralWidget( settingsWidget ); #else if( mainLayout->count() > 1 ) { mainLayout->itemAt( 0 )->widget()->hide(); mainLayout->removeItem( mainLayout->itemAt( 0 ) ); } - mainLayout->insertWidget( 0, settings, 1 ); + mainLayout->insertWidget( 0, settingsWidget, 1 ); #endif #ifdef Q_OS_SYMBIAN @@ -316,6 +319,12 @@ void MagRead::settingsPage() { removeShowData(); } +void MagRead::autoReorient( bool enabled ) { +#ifdef Q_WS_MAEMO_5 + setAttribute( Qt::WA_Maemo5AutoOrientation, enabled ); +#endif +} + /* Credit Page */ void MagRead::creditPage() { notice( "Successfully Read Credit Card", 750 ); diff --git a/magread.h b/magread.h index b16f7d8..fba0b42 100644 --- a/magread.h +++ b/magread.h @@ -113,6 +113,7 @@ class MagRead : public QMainWindow { void aboutDialogue(); void showData(); void settingsPage(); + void autoReorient( bool enabled ); }; #endif // MAGREAD_H diff --git a/settingspage.cpp b/settingspage.cpp index 52f839b..6547148 100644 --- a/settingspage.cpp +++ b/settingspage.cpp @@ -38,7 +38,7 @@ void SettingsPage::makeGeneralBox() { formatAAMVA->setCheckState( Qt::Checked ); connect( formatAAMVA, SIGNAL( stateChanged( int ) ), this, SLOT( formatAAMVA_checked( int ) ) ); -#ifndef Q_OS_SYMBIAN +#ifdef Q_WS_MAEMO_5 autoReorient = new QCheckBox( "Auto-reorient Screen" );//not symbian generalLayout->addWidget( autoReorient ); if( settings->value( "autoReorient" ) == true ) @@ -85,7 +85,14 @@ void SettingsPage::autoReorient_checked( int state ) { if( state == Qt::Checked ) settings->setValue( "autoReorient", true ); else - settings->setValue( "autoReorient", false ); + settings->setValue( "autoReorient", false ); +#ifdef Q_WS_MAEMO_5 + if( settings->value( "autoReorient" ) == true ) { + emit autoReorientSig( true ); + } else { + emit autoReorientSig( false ); + } +#endif } void SettingsPage::timeOutChanged( int value ) { diff --git a/settingspage.h b/settingspage.h index fce6f52..bda4630 100644 --- a/settingspage.h +++ b/settingspage.h @@ -46,6 +46,7 @@ class SettingsPage : public QScrollArea { QSlider *silenceSlider; signals: + void autoReorientSig( bool ); private slots: void formatCredit_checked( int state ); From 6692911fff9752c883d8c9dc687bfb9be5035071 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Sat, 4 Dec 2010 20:56:51 -0800 Subject: [PATCH 22/32] Change a tag to be slightly more obvious to the user --- settingspage.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/settingspage.cpp b/settingspage.cpp index 6547148..df6f9c4 100644 --- a/settingspage.cpp +++ b/settingspage.cpp @@ -45,14 +45,14 @@ void SettingsPage::makeGeneralBox() { autoReorient->setCheckState( Qt::Checked ); connect( autoReorient, SIGNAL( stateChanged( int ) ), this, SLOT( autoReorient_checked( int ) ) ); #endif - timeOutLabel = new QLabel( "Timeout: 10" ); + timeOutLabel = new QLabel( "Swipe Timeout: 10" ); generalLayout->addWidget( timeOutLabel ); timeOutSlider = new QSlider( Qt::Horizontal ); timeOutSlider->setTickInterval( 1 ); timeOutSlider->setRange( 0, 100 ); if( settings->contains( "timeOut" ) ) { - timeOutLabel->setText( QString( "Timeout: %1" ).arg( settings->value( "timeOut" ).toInt() ) ); + timeOutLabel->setText( QString( "Swipe Timeout: %1" ).arg( settings->value( "timeOut" ).toInt() ) ); timeOutSlider->setSliderPosition( settings->value( "timeOut" ).toInt() ); } else { timeOutSlider->setSliderPosition( 10 ); @@ -96,7 +96,7 @@ void SettingsPage::autoReorient_checked( int state ) { } void SettingsPage::timeOutChanged( int value ) { - timeOutLabel->setText( QString( "Timeout: %1" ).arg( value ) ); + timeOutLabel->setText( QString( "Swipe Timeout: %1" ).arg( value ) ); settings->setValue( "timeOut", value ); } @@ -109,7 +109,6 @@ void SettingsPage::makeAudioBox() { audioSource = new QComboBox; QList inputDevices = QAudioDeviceInfo::availableDevices( QAudio::AudioInput ); for( int i = 0; i < inputDevices.size(); i++ ) { - //audioSource->addItem( inputDevices.at( i ).deviceName(), qVariantFromValue( inputDevices.at( i ) ) ); audioSource->addItem( inputDevices.at( i ).deviceName() ); } audioLayout->addWidget( audioSource ); From 57e8e9239eba1c9da12829440f64b391bf9f9659 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Sat, 4 Dec 2010 20:57:55 -0800 Subject: [PATCH 23/32] update changelog --- ChangeLog | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c28f0b9..940176c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,13 @@ -magread (0.1.3-01) stable; urgency=low +magread (0.1.5) stable; urgency=low * Fixed a bug (#1) in displaying driver licence/id numbers from some states * Fixed a formatting issue (#7) for bank cards read from track 2 * Fixed a bug (#9) that could cause a bad loop of failed reads that could prevent the user from easily stopping the process. + * Create a settings page + * Allow user to turn on/off auto-rotation on Maemo + * Create setting for always formatting or not formatting AAMVA and bank + cards -- Jeffrey Malone Wed, 1 Dec 2010 15:19:00 -0700 From 0d1161498e3b12819e71f5754387423f29bbbed1 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Mon, 6 Dec 2010 00:32:16 -0800 Subject: [PATCH 24/32] Add GPL notice to settingspage files --- settingspage.cpp | 19 +++++++++++++++++++ settingspage.h | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/settingspage.cpp b/settingspage.cpp index df6f9c4..6c601c5 100644 --- a/settingspage.cpp +++ b/settingspage.cpp @@ -1,3 +1,22 @@ +/* + This file is part of MagRead. + + MagRead is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + MagRead is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with MagRead. If not, see . + + Written by Jeffrey Malone + http://blog.tehinterweb.com +*/ #include "settingspage.h" SettingsPage::SettingsPage(QObject *parent) { diff --git a/settingspage.h b/settingspage.h index bda4630..2ea7470 100644 --- a/settingspage.h +++ b/settingspage.h @@ -1,3 +1,22 @@ +/* + This file is part of MagRead. + + MagRead is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + MagRead is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with MagRead. If not, see . + + Written by Jeffrey Malone + http://blog.tehinterweb.com +*/ #ifndef SETTINGSPAGE_H #define SETTINGSPAGE_H From 04e8f79d8e8881280adc1d584e738ddd4727f3d5 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Mon, 6 Dec 2010 00:41:12 -0800 Subject: [PATCH 25/32] Implement the remainder of the settings page functions, except audio source --- magdecode.cpp | 8 ++++++++ magdecode.h | 3 +++ magread.cpp | 8 ++++++++ settingspage.cpp | 2 +- settingspage.h | 2 +- 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/magdecode.cpp b/magdecode.cpp index 6973726..838fa43 100644 --- a/magdecode.cpp +++ b/magdecode.cpp @@ -126,3 +126,11 @@ void MagDecode::setThreshold( int threshold ) { silenceThreshold = threshold; } +void MagDecode::setTimeOut( int _timeOut ) { + timeOut = _timeOut; +} + +void MagDecode::setNorm( int _normOffset ) { + normOffsetFound = true; + normOffset = _normOffset; +} diff --git a/magdecode.h b/magdecode.h index 0413b04..0f42b23 100644 --- a/magdecode.h +++ b/magdecode.h @@ -17,6 +17,9 @@ class MagDecode : public QIODevice void stop(); qint64 writeData( const char *data, qint64 dataLen ); qint64 readData( char *data, qint64 len ); + + void setTimeOut( int _timeOut ); + void setNorm( int _normOffset ); private: int silenceCount; diff --git a/magread.cpp b/magread.cpp index 1282aa9..6f005f2 100644 --- a/magread.cpp +++ b/magread.cpp @@ -253,6 +253,12 @@ void MagRead::captureStart() { connect( magDec, SIGNAL( cardRead( MagCard ) ), this, SLOT( cardRead( MagCard ) ) ); connect( magDec, SIGNAL( errorMsg( QString ) ), this, SLOT( notice( QString ) ) ); + magDec->setThreshold( settings->value( "silenceThreshold" ).toInt() ); + magDec->setTimeOut( settings->value( "timeOut" ).toInt() ); + + if( settings->value( "normAuto" ) == false ) + magDec->setNorm( settings->value( "norm" ).toInt() ); + audioInput = new QAudioInput( audioFormat, this ); magDec->start(); audioInput->start( magDec ); @@ -322,6 +328,8 @@ void MagRead::settingsPage() { void MagRead::autoReorient( bool enabled ) { #ifdef Q_WS_MAEMO_5 setAttribute( Qt::WA_Maemo5AutoOrientation, enabled ); +#else + Q_UNUSED( enabled ); #endif } diff --git a/settingspage.cpp b/settingspage.cpp index 6c601c5..c86839f 100644 --- a/settingspage.cpp +++ b/settingspage.cpp @@ -19,7 +19,7 @@ */ #include "settingspage.h" -SettingsPage::SettingsPage(QObject *parent) { +SettingsPage::SettingsPage() { widget = new QWidget; layout = new QVBoxLayout; diff --git a/settingspage.h b/settingspage.h index 2ea7470..22e7445 100644 --- a/settingspage.h +++ b/settingspage.h @@ -34,7 +34,7 @@ class SettingsPage : public QScrollArea { Q_OBJECT public: - explicit SettingsPage(QObject *parent = 0); + explicit SettingsPage(); private: QSettings *settings; From c501db1069f7e0e265b385c14079530ef0a114c3 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Mon, 6 Dec 2010 01:01:36 -0800 Subject: [PATCH 26/32] Add support for selecting audio source. Fixed a bug on non-maemo platforms with the restore defaults button --- magread.cpp | 14 +++++++++++++- settingspage.cpp | 8 ++++++++ settingspage.h | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/magread.cpp b/magread.cpp index 6f005f2..cdff249 100644 --- a/magread.cpp +++ b/magread.cpp @@ -259,7 +259,19 @@ void MagRead::captureStart() { if( settings->value( "normAuto" ) == false ) magDec->setNorm( settings->value( "norm" ).toInt() ); - audioInput = new QAudioInput( audioFormat, this ); + audioInput = 0; + + QList inputDevices = QAudioDeviceInfo::availableDevices( QAudio::AudioInput ); + for( int i = 0; i < inputDevices.size(); i++ ) { + if( inputDevices.at( i ).deviceName() == settings->value( "audioDevice" ) ) { + audioInput = new QAudioInput( inputDevices.at( i ), audioFormat, this ); + } + } + + if( audioInput == 0 ) + audioInput = new QAudioInput( audioFormat, this ); + + magDec->start(); audioInput->start( magDec ); } diff --git a/settingspage.cpp b/settingspage.cpp index c86839f..d5b3d5a 100644 --- a/settingspage.cpp +++ b/settingspage.cpp @@ -18,6 +18,7 @@ http://blog.tehinterweb.com */ #include "settingspage.h" +#include SettingsPage::SettingsPage() { widget = new QWidget; @@ -131,6 +132,7 @@ void SettingsPage::makeAudioBox() { audioSource->addItem( inputDevices.at( i ).deviceName() ); } audioLayout->addWidget( audioSource ); + connect( audioSource, SIGNAL( currentIndexChanged( QString ) ), this, SLOT( audioDeviceChanged( QString ) ) ); normCBox = new QCheckBox( "Auto-Detect Normalzation" ); audioLayout->addWidget( normCBox ); @@ -181,6 +183,10 @@ void SettingsPage::makeAudioBox() { layout->addWidget( audioBox ); } +void SettingsPage::audioDeviceChanged( QString audioDevice ) { + settings->setValue( "audioDevice", audioDevice ); +} + void SettingsPage::normChecked( int state ) { if( state == Qt::Checked ) { normSlider->setEnabled( false ); @@ -218,7 +224,9 @@ void SettingsPage::resetAll( bool updateGui ) { if( updateGui ) { formatCredit->setCheckState( Qt::Checked ); formatAAMVA->setCheckState( Qt::Checked ); +#ifdef Q_WS_MAEMO5 autoReorient->setCheckState( Qt::Checked ); +#endif timeOutChanged( 10 ); normCBox->setCheckState( Qt::Checked ); diff --git a/settingspage.h b/settingspage.h index 22e7445..0984405 100644 --- a/settingspage.h +++ b/settingspage.h @@ -72,6 +72,7 @@ class SettingsPage : public QScrollArea { void formatAAMVA_checked( int state ); void autoReorient_checked( int state ); + void audioDeviceChanged( QString audioDevice ); void timeOutChanged( int value ); void normChanged( int value ); void silenceChanged( int value ); From 8b4f716746c0e2825257b5a7335bdada77aa091e Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Mon, 6 Dec 2010 01:08:43 -0800 Subject: [PATCH 27/32] Update ChangeLog --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 940176c..e4ae18d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ magread (0.1.5) stable; urgency=low * Allow user to turn on/off auto-rotation on Maemo * Create setting for always formatting or not formatting AAMVA and bank cards + * Add support for setting normalization, silence and timeout variables + * Add support for selecting the input audio device -- Jeffrey Malone Wed, 1 Dec 2010 15:19:00 -0700 From 97b28eabc9b1f16624819669e7529f4961ce4d63 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Mon, 6 Dec 2010 01:11:10 -0800 Subject: [PATCH 28/32] Enabled Settings dialogue for Symbian --- magread.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/magread.cpp b/magread.cpp index cdff249..5f0a933 100644 --- a/magread.cpp +++ b/magread.cpp @@ -73,7 +73,6 @@ MagRead::MagRead(QWidget *parent) : QMainWindow(parent) { //Option and Exit selections #ifndef Q_OS_SYMBIAN -// Removed until settings functionality implemented settingsAction = new QAction( "&Settings", this ); connect( settingsAction, SIGNAL( triggered() ), this, SLOT( settingsPage() ) ); @@ -190,9 +189,9 @@ void MagRead::mainPage() { #ifdef Q_OS_SYMBIAN QHBoxLayout *optionsBox = new QHBoxLayout; -// Removed until settings functionality implemented -// QPushButton *settingsBtn = new QPushButton( "Settings" ); -// optionsBox->addWidget( settingsBtn ); + QPushButton *settingsBtn = new QPushButton( "Settings" ); + optionsBox->addWidget( settingsBtn ); + connect( settingsBtn, SIGNAL( clicked() ), this, SLOT( settingsPage() ) ); QPushButton *aboutBtn = new QPushButton( "About" ); optionsBox->addWidget( aboutBtn ); From 91b5584ed5b1587c4a19e5b81428cfbf7800e93b Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Mon, 24 Jan 2011 12:33:00 -0800 Subject: [PATCH 29/32] Added support for selecting the decoding algorithm (the default, "Walk", should be used for now) Fixed two bugs in the timeout setting. It would use the timeout when first starting, and then revert to a hardcoded default. Reversed this behaviour --- magdecode.cpp | 27 ++++++++++++++++++++++----- magdecode.h | 4 ++++ magread.cpp | 2 ++ settingspage.cpp | 24 ++++++++++++++++++++++++ settingspage.h | 5 +++++ 5 files changed, 57 insertions(+), 5 deletions(-) diff --git a/magdecode.cpp b/magdecode.cpp index 838fa43..db698ff 100644 --- a/magdecode.cpp +++ b/magdecode.cpp @@ -12,7 +12,10 @@ MagDecode::MagDecode(QObject *parent) : QIODevice(parent) { normOffsetFound = false; normOffset = 0; - timeOut = 0; + defaultTimeOut = 10; //default to 10 + timeOut = defaultTimeOut; + + algorithm = "walk"; } void MagDecode::start() { @@ -75,8 +78,7 @@ qint64 MagDecode::writeData( const char *data, qint64 dataLen ) { void MagDecode::processSwipe() { bool valid; - //Starting off with a simple one of a 10 block timeout - timeOut = 10; + timeOut = defaultTimeOut; //Normalize the audio based on calculated 0 level for( int i = 0; i < pcmData.count(); i++ ) @@ -86,7 +88,14 @@ void MagDecode::processSwipe() { ms_set_peakThreshold( ms, silenceThreshold ); - ms_peaks_find_walk( ms ); + if( algorithm == "intersect" ) { + ms_peaks_find( ms ); + qDebug() << "Intersection algorithm used"; + } else { + ms_peaks_find_walk( ms ); + qDebug() << "Walk algorithm used"; + } + ms_peaks_filter_group( ms ); // ms_save( ms, "/tmp/swipe" ); @@ -127,10 +136,18 @@ void MagDecode::setThreshold( int threshold ) { } void MagDecode::setTimeOut( int _timeOut ) { - timeOut = _timeOut; + defaultTimeOut = _timeOut; } void MagDecode::setNorm( int _normOffset ) { normOffsetFound = true; normOffset = _normOffset; } + +void MagDecode::setAlgorithm( QString _algorithm ) { + qDebug() << "Settings algorithm to" << _algorithm; + if( _algorithm == "intersect" ) + algorithm = _algorithm; + else + algorithm = "walk"; +} diff --git a/magdecode.h b/magdecode.h index 0f42b23..a5d0bef 100644 --- a/magdecode.h +++ b/magdecode.h @@ -20,18 +20,22 @@ class MagDecode : public QIODevice void setTimeOut( int _timeOut ); void setNorm( int _normOffset ); + void setAlgorithm( QString _algorithm ); private: int silenceCount; bool noiseDetected; bool captureAudio; int timeOut; + int defaultTimeOut; void processSwipe(); int silenceThreshold; int normOffset; bool normOffsetFound; + QString algorithm; + QVarLengthArray pcmData; signals: diff --git a/magread.cpp b/magread.cpp index 5f0a933..94ffb6d 100644 --- a/magread.cpp +++ b/magread.cpp @@ -257,6 +257,8 @@ void MagRead::captureStart() { if( settings->value( "normAuto" ) == false ) magDec->setNorm( settings->value( "norm" ).toInt() ); + + magDec->setAlgorithm( settings->value( "algorithm" ).toString() ); audioInput = 0; diff --git a/settingspage.cpp b/settingspage.cpp index d5b3d5a..98ad097 100644 --- a/settingspage.cpp +++ b/settingspage.cpp @@ -82,6 +82,22 @@ void SettingsPage::makeGeneralBox() { generalLayout->addWidget( timeOutSlider ); + decodeMethodLabel = new QLabel( "Decoding Algorithm" ); + generalLayout->addWidget( decodeMethodLabel ); + + decodeMethodIntersect = new QRadioButton( "Instersection Algorithm", this ); + connect( decodeMethodIntersect, SIGNAL( toggled( bool ) ), this, SLOT( decodeMethodChanged( bool ) ) ); + generalLayout->addWidget( decodeMethodIntersect ); + + decodeMethodWalk = new QRadioButton( "Walking Algorithm", this ); + connect( decodeMethodWalk, SIGNAL( toggled( bool ) ), this, SLOT( decodeMethodChanged( bool ) ) ); + generalLayout->addWidget( decodeMethodWalk ); + + if( settings->value( "algorithm" ).toString() == "intersect" ) + decodeMethodIntersect->setChecked( true ); + else + decodeMethodWalk->setChecked( true ); + generalBox->setLayout( generalLayout ); layout->addWidget( generalBox ); @@ -120,6 +136,14 @@ void SettingsPage::timeOutChanged( int value ) { settings->setValue( "timeOut", value ); } +void SettingsPage::decodeMethodChanged( bool checked ) { + Q_UNUSED( checked ); + if( decodeMethodIntersect->isChecked() ) + settings->setValue( "algorithm", "intersect" ); + else + settings->setValue( "algorithm", "walk" ); +} + void SettingsPage::makeAudioBox() { audioBox = new QGroupBox( "Audio Settings" ); diff --git a/settingspage.h b/settingspage.h index 0984405..ff87c0d 100644 --- a/settingspage.h +++ b/settingspage.h @@ -30,6 +30,7 @@ #include #include #include +#include class SettingsPage : public QScrollArea { Q_OBJECT @@ -52,6 +53,9 @@ class SettingsPage : public QScrollArea { QCheckBox *autoReorient; QLabel *timeOutLabel; QSlider *timeOutSlider; + QLabel *decodeMethodLabel; + QRadioButton *decodeMethodIntersect; + QRadioButton *decodeMethodWalk; /* Audio Box */ void makeAudioBox(); @@ -74,6 +78,7 @@ class SettingsPage : public QScrollArea { void audioDeviceChanged( QString audioDevice ); void timeOutChanged( int value ); + void decodeMethodChanged( bool checked ); void normChanged( int value ); void silenceChanged( int value ); void normChecked( int state ); From a4851c72a30286970442cf9d7fc043522021873c Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Mon, 24 Jan 2011 12:34:42 -0800 Subject: [PATCH 30/32] Update changelog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index e4ae18d..b85ee96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ magread (0.1.5) stable; urgency=low cards * Add support for setting normalization, silence and timeout variables * Add support for selecting the input audio device + * Add support for choosing a decoding algorithm -- Jeffrey Malone Wed, 1 Dec 2010 15:19:00 -0700 From 946991780013a5028fa763055be6c982f54b6213 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Mon, 24 Jan 2011 13:01:01 -0800 Subject: [PATCH 31/32] Version bump in project file --- MagRead.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MagRead.pro b/MagRead.pro index ad6de1c..acda23f 100644 --- a/MagRead.pro +++ b/MagRead.pro @@ -13,7 +13,7 @@ maemo5 { TARGET = MagRead TEMPLATE = app -VERSION = 0.1.3-01 +VERSION = 0.1.5 DEFINES += APP_VERSION=$$VERSION SOURCES += main.cpp\ From 957ea4e4b73b1892ff706e7fb5960a8905ec2117 Mon Sep 17 00:00:00 2001 From: Jeffrey Malone Date: Mon, 24 Jan 2011 13:56:45 -0800 Subject: [PATCH 32/32] Change comments to C89 style --- llist.c | 2 +- mslib.c | 18 +++++++++--------- mslib.h | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/llist.c b/llist.c index e9dc05b..0630db9 100644 --- a/llist.c +++ b/llist.c @@ -46,7 +46,7 @@ void llist_remove_idx( LListH *list, int idx ) { prev = trav; } - if( trav != NULL ) {//if found + if( trav != NULL ) {/* if found */ if( prev != NULL ) { prev->next = trav->next; } else { diff --git a/mslib.c b/mslib.c index 41bc62b..0cf41eb 100644 --- a/mslib.c +++ b/mslib.c @@ -164,7 +164,7 @@ void ms_peaks_filter_group( msData *ms ) { LList *trav; LListH *groupList; - int pos;//indicates pos/neg (not position) + int pos;/* indicates pos/neg (not position) */ if( !ms || ms->peakList->len < 2 ) return; @@ -345,7 +345,7 @@ int ms_decode_bits( msData *ms ) { validSwipe = 0; bitStream = strchr( ms->bitStream, '1' ); - if( bitStream == NULL ) // if stream contains no 1s, it's bad, just quit + if( bitStream == NULL ) /* if stream contains no 1s, it's bad, just quit */ return 1; bitStreamLen = strlen( bitStream ); @@ -357,7 +357,7 @@ int ms_decode_bits( msData *ms ) { curChar = _ms_decode_bits_char( bitStream + i, LRC, ms->dataType ); charStream[ len ] = curChar; if( curChar == BAD_CHAR ) - badChars++; // count the bad chars + badChars++; /* count the bad chars */ } charStream[ len ] = '\0'; @@ -394,8 +394,8 @@ int ms_decode_bits( msData *ms ) { char _ms_decode_bits_char( char *bitStream, char *LRC, ms_dataType type ) { int parity = 0, i; char out; - int len; // char length not including parity - int offset; // offset to make it ASCII + int len; /* char length not including parity */ + int offset; /* offset to make it ASCII */ if( type == ABA ) { len = ABA_CHAR_LEN - 1; @@ -406,16 +406,16 @@ char _ms_decode_bits_char( char *bitStream, char *LRC, ms_dataType type ) { } for( i = 0, out = 0; i < len; i++ ) { - out |= ( bitStream[ i ] - NUM_ASCII_OFFSET ) << i; // using OR to assign the bits into the char + out |= ( bitStream[ i ] - NUM_ASCII_OFFSET ) << i; /* using OR to assign the bits into the char */ if( bitStream[ i ] == '1' ) { - LRC[ i ] = !LRC[ i ]; // flip the bit in the LRC for all 1 bits in the char - parity++; // count the number of 1 bits for the parity bit + LRC[ i ] = !LRC[ i ]; /* flip the bit in the LRC for all 1 bits in the char */ + parity++; /* count the number of 1 bits for the parity bit */ } } out += offset; if( ( parity & 1 ) == ( bitStream[ len ] - NUM_ASCII_OFFSET ) ) - out = BAD_CHAR; // return the error char if the calculated parity bit doesn't match the recorded one + out = BAD_CHAR; /* return the error char if the calculated parity bit doesn't match the recorded one */ return out; } diff --git a/mslib.h b/mslib.h index 20c8ec8..65b5a9b 100644 --- a/mslib.h +++ b/mslib.h @@ -40,7 +40,7 @@ extern "C" { #define IATA_SS "1010001" #define IATA_ES "1111100" -#define MAX_IATA_LEN 83 // some reports say max len is 79, but AAMVA says 82 ... +#define MAX_IATA_LEN 83 /* some reports say max len is 79, but AAMVA says 82 ... */ #define IATA_CHAR_LEN 7 #define IATA_ASCII_OFFSET 32 @@ -132,7 +132,7 @@ const char *ms_get_bitStream( msData *ms ); const char *ms_get_charStream( msData *ms ); /* Reverses a string in place */ -void ms_strrev( char *str ); +void strrev( char *str );