| 1 |
/* |
| 2 |
* FeliCa2Money |
| 3 |
* |
| 4 |
* Copyright (C) 2001-2007 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 |
//--------------------------------------------------------------------------- |
| 22 |
|
| 23 |
#include <vcl.h> |
| 24 |
#pragma hdrstop |
| 25 |
#include <Registry.hpp> |
| 26 |
#include <ShellApi.h> |
| 27 |
|
| 28 |
#include "MainForm.h" |
| 29 |
#include "Convert.h" |
| 30 |
#include "Card.h" |
| 31 |
#include "SfcPeep.h" |
| 32 |
|
| 33 |
#include "Edy.h" |
| 34 |
#include "Suica.h" |
| 35 |
#include "Nanaco.h" |
| 36 |
|
| 37 |
//--------------------------------------------------------------------------- |
| 38 |
#pragma package(smart_init) |
| 39 |
#pragma resource "*.dfm" |
| 40 |
TMForm *MForm; |
| 41 |
//--------------------------------------------------------------------------- |
| 42 |
__fastcall TMForm::TMForm(TComponent* Owner) |
| 43 |
: TForm(Owner) |
| 44 |
{ |
| 45 |
} |
| 46 |
//--------------------------------------------------------------------------- |
| 47 |
void __fastcall TMForm::FormShow(TObject *Sender) |
| 48 |
{ |
| 49 |
SfcPeep = new SFCPeep; |
| 50 |
|
| 51 |
LoadRegistry(); |
| 52 |
} |
| 53 |
//--------------------------------------------------------------------------- |
| 54 |
/** |
| 55 |
@brief �R���o�[�g���s |
| 56 |
@param[in] card Card �N���X |
| 57 |
|
| 58 |
Convert::Convert �������o���A�J�[�h���������AOFX �t�@�C�������A |
| 59 |
Money �N�������s���� |
| 60 |
*/ |
| 61 |
void TMForm::doConvert(Card *card) |
| 62 |
{ |
| 63 |
char tmppath[1024]; |
| 64 |
GetTempPath(sizeof(tmppath), tmppath); |
| 65 |
|
| 66 |
AnsiString t = tmppath; |
| 67 |
AnsiString ofxfile = t + "FeliCa2Money.ofx"; |
| 68 |
AnsiString tmpfile = t + "FeliCa2Money.csv"; |
| 69 |
|
| 70 |
SfcPeep->SetSfcPeepPath(SFCPeepPath); |
| 71 |
SfcPeep->SetTempFile(tmpfile); |
| 72 |
|
| 73 |
Converter c; |
| 74 |
c.Convert(card, ofxfile); |
| 75 |
|
| 76 |
delete card; |
| 77 |
} |
| 78 |
//--------------------------------------------------------------------------- |
| 79 |
/// Edy �{�^���N���b�N |
| 80 |
void __fastcall TMForm::ButtonConvertEdyClick(TObject *Sender) |
| 81 |
{ |
| 82 |
doConvert(new EdyCard); |
| 83 |
} |
| 84 |
|
| 85 |
//--------------------------------------------------------------------------- |
| 86 |
/// Suica �{�^���N���b�N |
| 87 |
void __fastcall TMForm::ButtonConvertSuicaClick(TObject *Sender) |
| 88 |
{ |
| 89 |
doConvert(new SuicaCard); |
| 90 |
} |
| 91 |
//--------------------------------------------------------------------------- |
| 92 |
|
| 93 |
void __fastcall TMForm::BtnConvertNanacoClick(TObject *Sender) |
| 94 |
{ |
| 95 |
doConvert(new NanacoCard); |
| 96 |
} |
| 97 |
//--------------------------------------------------------------------------- |
| 98 |
/// �I���{�^���N���b�N |
| 99 |
void __fastcall TMForm::ButtonQuitClick(TObject *Sender) |
| 100 |
{ |
| 101 |
Application->Terminate(); |
| 102 |
} |
| 103 |
//--------------------------------------------------------------------------- |
| 104 |
/** |
| 105 |
@brief ���W�X�g�������������� |
| 106 |
|
| 107 |
�������� (SFCPeep���p�X��)���������� |
| 108 |
*/ |
| 109 |
void TMForm::LoadRegistry(void) |
| 110 |
{ |
| 111 |
// ���W�X�g�������������������� |
| 112 |
TRegistry *reg = new TRegistry(); |
| 113 |
|
| 114 |
reg->RootKey = HKEY_CURRENT_USER; |
| 115 |
reg->OpenKey("\\Software\\Takuya Murakami\\FeliCa2Money", true); |
| 116 |
|
| 117 |
SFCPeepPath = reg->ReadString("SFCPeepPath"); |
| 118 |
if (SFCPeepPath.IsEmpty()) { |
| 119 |
SFCPeepPath = "c:\\Program Files\\DENNO NET\\SFCPeep\\SFCPeep.exe"; |
| 120 |
} |
| 121 |
} |
| 122 |
//--------------------------------------------------------------------------- |
| 123 |
/** |
| 124 |
@brief ���W�X�g���������� |
| 125 |
|
| 126 |
�������� (SFCPeep���p�X��)�����W�X�g������������ |
| 127 |
*/ |
| 128 |
void TMForm::SaveRegistry(void) |
| 129 |
{ |
| 130 |
TRegIniFile *ini; |
| 131 |
|
| 132 |
// ���W�X�g�������������� |
| 133 |
TRegistry *reg = new TRegistry(); |
| 134 |
|
| 135 |
reg->RootKey = HKEY_CURRENT_USER; |
| 136 |
reg->OpenKey("\\Software\\Takuya Murakami\\FeliCa2Money", true); |
| 137 |
|
| 138 |
reg->WriteString("SFCPeepPath", SFCPeepPath); |
| 139 |
} |
| 140 |
|
| 141 |
//--------------------------------------------------------------------------- |
| 142 |
/// �w���v�\�� |
| 143 |
void __fastcall TMForm::ButtonHelpClick(TObject *Sender) |
| 144 |
{ |
| 145 |
AnsiString doc = ExtractFilePath(Application->ExeName) + |
| 146 |
"Felica2Money.html"; |
| 147 |
|
| 148 |
ShellExecute(NULL, "open", doc.c_str(), |
| 149 |
NULL, NULL, SW_SHOWDEFAULT); |
| 150 |
} |
| 151 |
//--------------------------------------------------------------------------- |
| 152 |
/// �����{�^���N���b�N |
| 153 |
void __fastcall TMForm::ButtonConfigClick(TObject *Sender) |
| 154 |
{ |
| 155 |
OpenDialog->FileName = SFCPeepPath; |
| 156 |
if (OpenDialog->Execute()) { |
| 157 |
SFCPeepPath = OpenDialog->FileName; |
| 158 |
SaveRegistry(); |
| 159 |
} |
| 160 |
} |
| 161 |
//--------------------------------------------------------------------------- |