Skip to content

Commit aa6b939

Browse files
committed
A small patch
Support specifying client working directory Clean all compile warnings
1 parent 7f96c06 commit aa6b939

13 files changed

+312
-197
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Great thanks to him.
7272
+ Support configuring environment variables by script
7373
(Useful when the client requires specific environment variables)
7474
+ All functions are compatible with Iceman/RRG repo(tested on v4.9237)
75+
+ Support specifying client working directory
7576
+ Fix some bugs
7677

7778
### V0.1.3

Diff for: README/doc/README_zh_CN.md

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ release页面中有含客户端的GUI。这个GUI也可以搭配你自己的客
7171
+ 可通过外部脚本配置环境变量
7272
(在客户端需要配置环境变量时很有用)
7373
+ 全功能兼容冰人版(在v4.9237上测试通过)
74+
+ 支持指定客户端工作路径
7475
+ 修复部分bug
7576

7677
### V0.1.3

Diff for: common/pm3process.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ void PM3Process::connectPM3(const QString& path, const QString& port, const QStr
5555
result = result.left(result.indexOf("\r\n"));
5656
result = result.mid(3, result.lastIndexOf(" ") - 3);
5757
emit PM3StatedChanged(true, result);
58-
setSerialListener(port, true);
58+
59+
// if the arguments don't contain <port>, then disable the port listener
60+
// useful when using offline sniff
61+
if(args.indexOf(port) != -1)
62+
setSerialListener(port, true);
5963
}
6064
else
6165
kill();
@@ -132,5 +136,11 @@ void PM3Process::setProcEnv(const QStringList* env)
132136
{
133137
// qDebug() << "passed Env List" << *env;
134138
this->setEnvironment(*env);
135-
// qDebug() << "final Env List" << processEnvironment().toStringList();
139+
// qDebug() << "final Env List" << processEnvironment().toStringList();
140+
}
141+
142+
void PM3Process::setWorkingDir(const QString& dir)
143+
{
144+
// the working directory cannot be the default, or the client will failed to load the dll
145+
this->setWorkingDirectory(dir);
136146
}

Diff for: common/pm3process.h

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <QtSerialPort/QSerialPortInfo>
1010
#include <QtSerialPort/QSerialPort>
1111
#include <QProcessEnvironment>
12+
#include <QDir>
1213

1314
#include "util.h"
1415

@@ -27,6 +28,7 @@ public slots:
2728
qint64 write(QString data);
2829
void reconnectPM3();
2930
void setProcEnv(const QStringList* env);
31+
void setWorkingDir(const QString& dir);
3032
private slots:
3133
void onTimeout();
3234
void onReadyRead();

Diff for: lang/en_US.ts

+111-94
Large diffs are not rendered by default.

Diff for: lang/zh_CN.qm

418 Bytes
Binary file not shown.

Diff for: lang/zh_CN.ts

+112-94
Large diffs are not rendered by default.

Diff for: module/mifare.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,14 @@ QString Mifare::info(bool isRequiringOutput)
102102
end = result.indexOf("\n", end);
103103
return result.mid(begin, end - begin + 1);
104104
}
105-
else
106-
return "";
107105
}
108106
else
109107
{
110108
util->execCMD("hf 14a info");
111109
ui->funcTab->setCurrentIndex(Util::rawTabIndex);
112-
return "";
113110
}
114111
}
112+
return "";
115113
}
116114

117115
void Mifare::chk()
@@ -629,6 +627,7 @@ bool Mifare::_writeblk(int blockId, KeyType keyType, const QString& key, const Q
629627
return true;
630628
}
631629
}
630+
return false;
632631
}
633632

634633
void Mifare::writeOne(TargetType targetType)

Diff for: ui/mainwindow.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ MainWindow::MainWindow(QWidget *parent):
2828
pm3 = new PM3Process(pm3Thread);
2929
pm3Thread->start();
3030
pm3state = false;
31+
clientWorkingDir = new QDir;
3132

3233
util = new Util(this);
3334
mifare = new Mifare(ui, util, this);
@@ -94,6 +95,7 @@ void MainWindow::on_PM3_connectButton_clicked()
9495
{
9596
QStringList args = ui->Set_Client_startArgsEdit->text().replace("<port>", port).split(' ');
9697
saveClientPath(ui->PM3_pathEdit->text());
98+
9799
QProcess envSetProcess;
98100
QFileInfo envScriptPath(ui->Set_Client_envScriptEdit->text());
99101
if(envScriptPath.exists())
@@ -113,6 +115,15 @@ void MainWindow::on_PM3_connectButton_clicked()
113115
else
114116
clientEnv.clear();
115117
emit setProcEnv(&clientEnv);
118+
119+
clientWorkingDir->setPath(QApplication::applicationDirPath());
120+
qDebug() << clientWorkingDir->absolutePath();
121+
clientWorkingDir->mkpath(ui->Set_Client_workingDirEdit->text());
122+
qDebug() << clientWorkingDir->absolutePath();
123+
clientWorkingDir->cd(ui->Set_Client_workingDirEdit->text());
124+
qDebug() << clientWorkingDir->absolutePath();
125+
emit setWorkingDir(clientWorkingDir->absolutePath());
126+
116127
emit connectPM3(ui->PM3_pathEdit->text(), port, args);
117128
}
118129
}
@@ -976,6 +987,7 @@ void MainWindow::uiInit()
976987

977988
settings->beginGroup("Client_Env");
978989
ui->Set_Client_envScriptEdit->setText(settings->value("scriptPath").toString());
990+
ui->Set_Client_workingDirEdit->setText(settings->value("workingDir", "../data").toString());
979991
settings->endGroup();
980992

981993
ui->MF_RW_keyTypeBox->addItem("A", Mifare::KEY_A);
@@ -996,6 +1008,7 @@ void MainWindow::signalInit()
9961008
connect(pm3, &PM3Process::PM3StatedChanged, util, &Util::setRunningState);
9971009
connect(this, &MainWindow::killPM3, pm3, &PM3Process::kill);
9981010
connect(this, &MainWindow::setProcEnv, pm3, &PM3Process::setProcEnv);
1011+
connect(this, &MainWindow::setWorkingDir, pm3, &PM3Process::setWorkingDir);
9991012

10001013
connect(util, &Util::write, pm3, &PM3Process::write);
10011014

@@ -1160,3 +1173,10 @@ void MainWindow::on_Set_Client_envScriptEdit_editingFinished()
11601173
settings->setValue("scriptPath", ui->Set_Client_envScriptEdit->text());
11611174
settings->endGroup();
11621175
}
1176+
1177+
void MainWindow::on_Set_Client_saveWorkingDirButton_clicked()
1178+
{
1179+
settings->beginGroup("Client_Env");
1180+
settings->setValue("workingDir", ui->Set_Client_workingDirEdit->text());
1181+
settings->endGroup();
1182+
}

Diff for: ui/mainwindow.h

+4
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ private slots:
173173

174174
void on_Set_Client_envScriptEdit_editingFinished();
175175

176+
void on_Set_Client_saveWorkingDirButton_clicked();
177+
176178
private:
177179
Ui::MainWindow* ui;
178180
QButtonGroup* MFCardTypeBtnGroup;
@@ -199,6 +201,7 @@ private slots:
199201
QTimer* portSearchTimer;
200202
QStringList portList;
201203
QStringList clientEnv;
204+
QDir* clientWorkingDir;
202205

203206
Mifare* mifare;
204207
Util* util;
@@ -217,5 +220,6 @@ private slots:
217220
void killPM3();
218221
void setSerialListener(const QString& name, bool state);
219222
void setProcEnv(const QStringList *env);
223+
void setWorkingDir(const QString& dir);
220224
};
221225
#endif // MAINWINDOW_H

Diff for: ui/mainwindow.ui

+45-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
</sizepolicy>
131131
</property>
132132
<property name="currentIndex">
133-
<number>0</number>
133+
<number>4</number>
134134
</property>
135135
<widget class="QWidget" name="mifareTab">
136136
<attribute name="title">
@@ -1538,7 +1538,7 @@
15381538
<attribute name="title">
15391539
<string>Settings</string>
15401540
</attribute>
1541-
<layout class="QHBoxLayout" name="horizontalLayout_15">
1541+
<layout class="QHBoxLayout" name="horizontalLayout_18">
15421542
<item>
15431543
<layout class="QVBoxLayout" name="verticalLayout_12">
15441544
<item>
@@ -1573,6 +1573,49 @@ then put the path of the script there</string>
15731573
</property>
15741574
</widget>
15751575
</item>
1576+
<item>
1577+
<widget class="Line" name="line_4">
1578+
<property name="orientation">
1579+
<enum>Qt::Horizontal</enum>
1580+
</property>
1581+
</widget>
1582+
</item>
1583+
<item>
1584+
<widget class="QLabel" name="label_19">
1585+
<property name="text">
1586+
<string>Client working directory:</string>
1587+
</property>
1588+
</widget>
1589+
</item>
1590+
<item>
1591+
<layout class="QHBoxLayout" name="horizontalLayout_15">
1592+
<item>
1593+
<widget class="QLineEdit" name="Set_Client_workingDirEdit">
1594+
<property name="text">
1595+
<string>../data</string>
1596+
</property>
1597+
</widget>
1598+
</item>
1599+
<item>
1600+
<widget class="QPushButton" name="Set_Client_saveWorkingDirButton">
1601+
<property name="text">
1602+
<string>Save</string>
1603+
</property>
1604+
</widget>
1605+
</item>
1606+
</layout>
1607+
</item>
1608+
<item>
1609+
<widget class="QLabel" name="label_20">
1610+
<property name="text">
1611+
<string>Note:
1612+
On Windows, the client working directory should not be identical to the path of GUI, otherwise the client will use the wrong .dll file.</string>
1613+
</property>
1614+
<property name="wordWrap">
1615+
<bool>true</bool>
1616+
</property>
1617+
</widget>
1618+
</item>
15761619
<item>
15771620
<widget class="Line" name="line">
15781621
<property name="orientation">

Diff for: ui/mf_trailerdecoderdialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void MF_trailerDecoderDialog::setTableItem(QTableWidget* widget, int row, int co
123123
widget->item(row, column)->setText(text);
124124
}
125125

126-
void MF_trailerDecoderDialog::on_boxChanged(int arg1)
126+
void MF_trailerDecoderDialog::on_boxChanged()
127127
{
128128
quint8 ACBits[4];
129129
ACBits[0] = ui->C0Box->value();

Diff for: ui/mf_trailerdecoderdialog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private slots:
2727

2828
void on_blockSizeChanged(int id, bool st);
2929

30-
void on_boxChanged(int arg1);
30+
void on_boxChanged();
3131
private:
3232
Ui::MF_trailerDecoderDialog *ui;
3333
QRegularExpressionValidator* validator;

0 commit comments

Comments
 (0)