Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
aac131d
Update the README to reflect new info
ieatlint Nov 29, 2010
ae9ea35
Disable the Settings button until it does something of actual use
ieatlint Nov 29, 2010
176e0d5
.
ieatlint Nov 29, 2010
0e44bf7
update issue tracker to list github, as the program is no longer maem…
ieatlint Nov 29, 2010
d8e5718
Replace the mistakenly lost unix{} section in project file
ieatlint Nov 29, 2010
0ba1cac
Adjust platform-specific font sizes
ieatlint Nov 29, 2010
389b73a
Adjust auto-rotate code for Symbian and Maemo specifics
ieatlint Nov 29, 2010
7575c86
Update changelog for 0.1.3 release.
ieatlint Nov 29, 2010
a879801
Fix a formatting issue for driver licence numbers
ieatlint Nov 30, 2010
8f564af
Move changelog to root dir, and setup a symlink for debian
ieatlint Dec 1, 2010
a7ad306
Hide the accountHolder QLabel for track2 swipes so the formattings lo…
ieatlint Dec 1, 2010
0237b1e
Create a timeout so that it doesn't start a bad loop of failed reads
ieatlint Dec 1, 2010
ad0bf11
Add the pro.user file to the ignore list
ieatlint Dec 1, 2010
6462b7b
Update ChangeLog and version number to 0.1.3-01 for a bugfix release
ieatlint Dec 1, 2010
22d2714
Add clear() method to MagCard
ieatlint Dec 2, 2010
2297d56
Add feature as described in issue #6 to desktop and Maemo. Symbian s…
ieatlint Dec 2, 2010
0678d35
Half-implemented system for the settings page
ieatlint Dec 5, 2010
706fdac
Finish most of the implementation of the settings page (except audio …
ieatlint Dec 5, 2010
8327b25
Small fix, referenced wrong object
ieatlint Dec 5, 2010
b27b53f
Now enabled the settings for formatting AAMVA/bank cards. Further
ieatlint Dec 5, 2010
1319c74
Implement the setting to turn on/off auto-rotation for maemo 5
ieatlint Dec 5, 2010
6692911
Change a tag to be slightly more obvious to the user
ieatlint Dec 5, 2010
57e8e92
update changelog
ieatlint Dec 5, 2010
0d11614
Add GPL notice to settingspage files
ieatlint Dec 6, 2010
04e8f79
Implement the remainder of the settings page functions, except audio …
ieatlint Dec 6, 2010
c501db1
Add support for selecting audio source. Fixed a bug on non-maemo
ieatlint Dec 6, 2010
8b4f716
Update ChangeLog
ieatlint Dec 6, 2010
97b28ea
Enabled Settings dialogue for Symbian
ieatlint Dec 6, 2010
91b5584
Added support for selecting the decoding algorithm (the default, "Walk",
ieatlint Jan 24, 2011
a4851c7
Update changelog
ieatlint Jan 24, 2011
9469917
Version bump in project file
ieatlint Jan 24, 2011
957ea4e
Change comments to C89 style
ieatlint Jan 24, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MagRead.pro.user
.*swp
44 changes: 44 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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
* 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 <ieatlint@tehinterweb.com> 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.
* 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 <ieatlint@tehinterweb.com> 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 <ieatlint@tehinterweb.com> Sat, 6 Nov 2010 16:06:47 -0700

magread (0.1.0) unstable; urgency=low

* Initial release

-- Jeffrey Malone <ieatlint@tehinterweb.com> Thu, 04 Nov 2010 06:10:14 -0700
17 changes: 14 additions & 3 deletions MagRead.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ maemo5 {
TARGET = MagRead
TEMPLATE = app

VERSION = 0.1.3
VERSION = 0.1.5
DEFINES += APP_VERSION=$$VERSION

SOURCES += main.cpp\
Expand All @@ -23,7 +23,8 @@ SOURCES += main.cpp\
mslib.c \
llist.c \
accountcard.cpp \
aamvacard.cpp
aamvacard.cpp \
settingspage.cpp

HEADERS += magread.h \
carddetect.h \
Expand All @@ -32,7 +33,8 @@ HEADERS += magread.h \
llist.h \
magcard.h \
accountcard.h \
aamvacard.h
aamvacard.h \
settingspage.h

symbian {
TARGET.UID3 = 0xe2c961e1
Expand All @@ -41,3 +43,12 @@ 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
}
36 changes: 29 additions & 7 deletions README
Original file line number Diff line number Diff line change
@@ -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 <PR1.3, you must use MagRead 1.1 or older)

To build on the terminal, simply run:
qmake && make

You may also open the project file in Qt Creator to build.


A packaged version of this is currently available on the Maemo extras-devel
repository at:
For Nokia N900 owners, this application is packaged and found in the
extras-devel repository at:
http://maemo.org/packages/view/magread/
Please vote for it so it can eventually ascend to the extras repo.

For Symbian users, at present you must compile this application yourself. I'll
work on getting a dev certificate so that I can sign a sis file soon.

For Linux, Windows and OS X users, binary versions will be available very soon
on my blog. The code however can be compiled yourself now, with Linux
instructions above.


Information on how this program works and screenshots of it in action may be
found on my blog at:
Further information on how this program works and screenshots of it in action
may be found on my blog at:
http://blog.tehinterweb.com/
9 changes: 7 additions & 2 deletions aamvacard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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
Expand Down
33 changes: 25 additions & 8 deletions accountcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down Expand Up @@ -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 ) );
Expand All @@ -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 ) );
Expand Down Expand Up @@ -123,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" );
Expand Down
6 changes: 5 additions & 1 deletion carddetect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++ ) {
Expand All @@ -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
Expand Down
14 changes: 0 additions & 14 deletions debian/changelog

This file was deleted.

1 change: 1 addition & 0 deletions debian/changelog
4 changes: 2 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Source: magread
Section: user/utilities
Priority: extra
Maintainer: Jeffrey Malone <ieatlint@tehinterweb.com>
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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion llist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions magcard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
37 changes: 36 additions & 1 deletion magdecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ MagDecode::MagDecode(QObject *parent) : QIODevice(parent) {

normOffsetFound = false;
normOffset = 0;

defaultTimeOut = 10; //default to 10
timeOut = defaultTimeOut;

algorithm = "walk";
}

void MagDecode::start() {
Expand All @@ -25,6 +30,11 @@ qint64 MagDecode::writeData( const char *data, qint64 dataLen ) {
if( !captureAudio )
return dataLen;

if( timeOut > 0 ) {
timeOut--;
return dataLen;
}

const qint16 *pcmDataBlock = reinterpret_cast<const qint16 *>( data );
int blockLen = dataLen / sizeof( qint16 );

Expand Down Expand Up @@ -68,6 +78,8 @@ qint64 MagDecode::writeData( const char *data, qint64 dataLen ) {
void MagDecode::processSwipe() {
bool valid;

timeOut = defaultTimeOut;

//Normalize the audio based on calculated 0 level
for( int i = 0; i < pcmData.count(); i++ )
pcmData[ i ] -= normOffset;
Expand All @@ -76,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" );
Expand Down Expand Up @@ -116,3 +135,19 @@ void MagDecode::setThreshold( int threshold ) {
silenceThreshold = threshold;
}

void MagDecode::setTimeOut( int _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";
}
Loading