Skip to content

Commit

Permalink
fix some bugs and add file name option
Browse files Browse the repository at this point in the history
  • Loading branch information
13584452567 committed Jan 21, 2023
1 parent 8342372 commit 0694f11
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
3 changes: 2 additions & 1 deletion DiagProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ bool ConnectDevice(DiagInfo &info)
{
return false;
}
if (!SetSIMDual(info,true))

if (!SetSIMDual(info,(ReadIMEI(info,0) == ReadIMEI(info,1))))
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion QCNTool.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 9.0.1, 2023-01-17T18:45:20. -->
<!-- Written by QtCreator 9.0.1, 2023-01-21T12:50:55. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
24 changes: 19 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int main(int argc, char *argv[])
QCoreApplication a(argc, argv);
//添加命令行参数
QCoreApplication::setApplicationName("QCNTool");
QCoreApplication::setApplicationVersion("1.2");
QCoreApplication::setApplicationVersion("1.4.5");
QCommandLineParser parser;
parser.setApplicationDescription("a tool to download/flash qcn from/to your phone");
parser.addHelpOption();
Expand All @@ -39,13 +39,18 @@ int main(int argc, char *argv[])
QCommandLineOption targetpath(QStringList() << "f" << "file",
"qcn file path",
"string");
QCommandLineOption targetname(QStringList() << "n" << "name",
"qcn file name",
"string");
parser.addOption(targetport);
parser.addOption(targetpath);
parser.addOption(targetname);
parser.addOption(writeqcn);
parser.addOption(readqcn);
parser.process(a);
int cport= parser.value(targetport).toInt();
QString cpath = parser.value(targetpath);
QString cname = parser.value(targetname);
DiagInfo info;
info.portnum = cport;

Expand All @@ -63,7 +68,7 @@ int main(int argc, char *argv[])
return 1;
}

std::cout << "a small free tool to flash qcn into your phone\n"
std::cout << "a small free tool to flash/backup qcn into/from your phone\n"
<< "Modified by Zi_Cai\n";

if (!ConnectDevice(info))
Expand Down Expand Up @@ -95,6 +100,8 @@ int main(int argc, char *argv[])
if (!QLIB_NV_WriteNVsToMobile(info.hndl,&res2))
{
std::cout << " error";
QLIB_DisconnectServer(info.hndl);
return 1;
}else{
std::cout << " OK";
}
Expand All @@ -103,25 +110,32 @@ int main(int argc, char *argv[])
}
if (parser.isSet(readqcn))
{
QString path;
if (cpath == "")
{
cpath = QDir().currentPath();
}
std::cout << "\nReading QCN from phone...";
int renas2;
if (cname == "")
{
QDateTime dteNow = QDateTime::currentDateTime();
QString fnl = dteNow.toString("smh_d_M_yyyy").replace(" ","_").replace(":","_");
QString path = cpath +"/QCN_"+fnl+".qcn";
cname = "/QCN_"+fnl+".qcn";
}
path = cpath + cname;
int renas2;
std::cout << "\nReading QCN from phone...";
if (!QLIB_BackupNVFromMobileToQCN(info.hndl,path.toLocal8Bit().data(),&renas2))
{
std::cout <<" error";
QLIB_DisconnectServer(info.hndl);
return 1;
}
else
{
std::cout <<" OK";
std::cout <<"\nBackup file : ";
std::cout <<path.toStdString().data();
std::cout <<"\n";
}
}
QLIB_DisconnectServer(info.hndl);
Expand Down

0 comments on commit 0694f11

Please sign in to comment.