| 1 |
/* |
| 2 |
* FeliCa2Money |
| 3 |
* |
| 4 |
* Copyright (C) 2001-2008 Takuya Murakami |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; either version 2 of the License, or |
| 9 |
* (at your option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU General Public License |
| 17 |
* along with this program; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
using System; |
| 22 |
using System.Collections.Generic; |
| 23 |
using System.Text; |
| 24 |
using FelicaLib; |
| 25 |
|
| 26 |
namespace FeliCa2Money |
| 27 |
{ |
| 28 |
class Nanaco : CardWithFelicaLib |
| 29 |
{ |
| 30 |
public Nanaco() |
| 31 |
{ |
| 32 |
org = "Nanaco"; |
| 33 |
cardName = "Nanaco"; |
| 34 |
|
| 35 |
systemCode = (int)SystemCode.Common; |
| 36 |
serviceCode = 0x564f; |
| 37 |
needReverse = true; |
| 38 |
} |
| 39 |
|
| 40 |
public override void analyzeCardId(Felica f) |
| 41 |
{ |
| 42 |
byte[] data = f.ReadWithoutEncryption(0x558b, 0); |
| 43 |
if (data == null) |
| 44 |
{ |
| 45 |
throw new Exception("nanaco������������������������������"); |
| 46 |
} |
| 47 |
|
| 48 |
accountId = ""; |
| 49 |
for (int i = 0; i < 8; i++) { |
| 50 |
accountId += data[i].ToString("X2"); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
public override bool analyzeTransaction(Transaction t, byte[] data) |
| 55 |
{ |
| 56 |
// ������ |
| 57 |
int value = (data[9] << 24) + (data[10] << 16) + (data[11] << 8) + data[12]; |
| 58 |
int year = (value >> 21) + 2000; |
| 59 |
int month = (value >> 17) & 0xf; |
| 60 |
int date = (value >> 12) & 0x1f; |
| 61 |
int hour = (value >> 6) & 0x3f; |
| 62 |
int min = value & 0x3f; |
| 63 |
t.date = new DateTime(year, month, date, hour, min, 0); |
| 64 |
|
| 65 |
// ������ |
| 66 |
value = (data[1] << 24) + (data[2] << 16) + (data[3] << 8) + data[4]; |
| 67 |
|
| 68 |
// ������ |
| 69 |
t.type = TransType.DirectDep; |
| 70 |
t.value = value; |
| 71 |
|
| 72 |
switch (data[0]) |
| 73 |
{ |
| 74 |
default: |
| 75 |
case 0x47: |
| 76 |
t.type = TransType.Debit; // ��������� |
| 77 |
t.desc = "nanaco������"; |
| 78 |
t.value = - value; |
| 79 |
break; |
| 80 |
|
| 81 |
case 0x35: |
| 82 |
t.desc = "������"; |
| 83 |
break; |
| 84 |
|
| 85 |
case 0x6f: |
| 86 |
case 0x70: |
| 87 |
t.desc = "nanaco������������"; |
| 88 |
break; |
| 89 |
|
| 90 |
case 0x83: |
| 91 |
t.desc = "nanaco������������������"; |
| 92 |
break; |
| 93 |
} |
| 94 |
t.memo = ""; |
| 95 |
|
| 96 |
// ������ |
| 97 |
value = (data[5] << 24) + (data[6] << 16) + (data[7] << 8) + data[8]; |
| 98 |
t.balance = value; |
| 99 |
|
| 100 |
// ������ |
| 101 |
value = (data[13] << 8) + data[14]; |
| 102 |
t.id = value; |
| 103 |
|
| 104 |
return true; |
| 105 |
} |
| 106 |
} |
| 107 |
} |