fix: fixed #257 prevent using manual function Stringify

This commit is contained in:
Qv2ray Bot 2020-01-18 10:54:55 +08:00
parent 69a9c23100
commit e5d87ed052
8 changed files with 23 additions and 53 deletions

View File

@ -1 +1 @@
2866 2871

View File

@ -37,7 +37,7 @@ namespace Qv2ray
vmessUriRoot["host"] = realHost; vmessUriRoot["host"] = realHost;
vmessUriRoot["path"] = transfer.wsSettings.path; vmessUriRoot["path"] = transfer.wsSettings.path;
} else if (transfer.network == "h2" || transfer.network == "http") { } else if (transfer.network == "h2" || transfer.network == "http") {
vmessUriRoot["host"] = Stringify(transfer.httpSettings.host, ","); vmessUriRoot["host"] = transfer.httpSettings.host.join(",");
vmessUriRoot["path"] = transfer.httpSettings.path; vmessUriRoot["path"] = transfer.httpSettings.path;
} }
@ -206,7 +206,7 @@ namespace Qv2ray
} else{\ } else{\
*errMessage = QObject::tr(#key " does not exist."); \ *errMessage = QObject::tr(#key " does not exist."); \
LOG(MODULE_IMPORT, "Cannot process \"" #key "\" since it's not included in the json object." ) \ LOG(MODULE_IMPORT, "Cannot process \"" #key "\" since it's not included in the json object." ) \
LOG(MODULE_IMPORT, " --> values: " + Stringify(val) ) \ LOG(MODULE_IMPORT, " --> values: " + val.join(";")) \
LOG(MODULE_IMPORT, " --> PS: " + ps) \ LOG(MODULE_IMPORT, " --> PS: " + ps) \
}\ }\
} }

View File

@ -77,7 +77,7 @@ namespace Qv2ray
} }
QString output = QString(proc.readAllStandardOutput()); QString output = QString(proc.readAllStandardOutput());
LOG(MODULE_VCORE, "V2ray output: " + Stringify(SplitLines(output))) LOG(MODULE_VCORE, "V2ray output: " + SplitLines(output).join(";"))
*message = SplitLines(output).first(); *message = SplitLines(output).first();
return true; return true;
} }
@ -144,7 +144,7 @@ namespace Qv2ray
inboundTags.append(tag); inboundTags.append(tag);
} }
DEBUG(MODULE_VCORE, "Found Inbound Tags: " + Stringify(inboundTags)) DEBUG(MODULE_VCORE, "Found Inbound Tags: " + inboundTags.join(";"))
QString json = JsonToString(root); QString json = JsonToString(root);
// Write the final configuration to the disk. // Write the final configuration to the disk.
StringToFile(&json, new QFile(QV2RAY_GENERATED_FILE_PATH)); StringToFile(&json, new QFile(QV2RAY_GENERATED_FILE_PATH));

View File

@ -164,7 +164,7 @@ bool initialiseQv2ray()
// Even the last folder failed to pass the check. // Even the last folder failed to pass the check.
LOG(MODULE_INIT, "FATAL") LOG(MODULE_INIT, "FATAL")
LOG(MODULE_INIT, " ---> CANNOT find a proper place to store Qv2ray config files.") LOG(MODULE_INIT, " ---> CANNOT find a proper place to store Qv2ray config files.")
QString searchPath = Stringify(configFilePaths, NEWLINE); QString searchPath = configFilePaths.join(NEWLINE);
QvMessageBoxWarn(nullptr, QObject::tr("Cannot Start Qv2ray"), QvMessageBoxWarn(nullptr, QObject::tr("Cannot Start Qv2ray"),
QObject::tr("Cannot find a place to store config files.") + NEWLINE + QObject::tr("Cannot find a place to store config files.") + NEWLINE +
QObject::tr("Qv2ray has searched these paths below:") + QObject::tr("Qv2ray has searched these paths below:") +

View File

@ -241,7 +241,7 @@ void MainWindow::CheckSubscriptionsUpdate()
if (!updateList.isEmpty()) { if (!updateList.isEmpty()) {
QvMessageBoxWarn(this, tr("Update Subscriptions"), QvMessageBoxWarn(this, tr("Update Subscriptions"),
tr("There are subscriptions need to be updated, please go to subscriptions window to update them.") + NEWLINE + NEWLINE + tr("There are subscriptions need to be updated, please go to subscriptions window to update them.") + NEWLINE + NEWLINE +
tr("These subscriptions are out-of-date: ") + NEWLINE + Stringify(updateList)); tr("These subscriptions are out-of-date: ") + NEWLINE + updateList.join(";"));
on_subsButton_clicked(); on_subsButton_clicked();
} }
} }

View File

@ -373,19 +373,19 @@ void RouteEditor::ShowCurrentRuleDetail()
routePortTxt->setText(CurrentRule.port); routePortTxt->setText(CurrentRule.port);
// //
// Users // Users
QString users = Stringify(CurrentRule.user, NEWLINE); QString users = CurrentRule.user.join(NEWLINE);
routeUserTxt->setPlainText(users); routeUserTxt->setPlainText(users);
// //
// Incoming Sources // Incoming Sources
QString sources = Stringify(CurrentRule.source, NEWLINE); QString sources = CurrentRule.source.join(NEWLINE);
sourceIPList->setPlainText(sources); sourceIPList->setPlainText(sources);
// //
// Domains // Domains
QString domains = Stringify(CurrentRule.domain, NEWLINE); QString domains = CurrentRule.domain.join(NEWLINE);
hostList->setPlainText(domains); hostList->setPlainText(domains);
// //
// Outcoming IPs // Outcoming IPs
QString ips = Stringify(CurrentRule.ip, NEWLINE); QString ips = CurrentRule.ip.join(NEWLINE);
ipList->setPlainText(ips); ipList->setPlainText(ips);
LOAD_FLAG_END LOAD_FLAG_END
} }
@ -410,7 +410,7 @@ void RouteEditor::on_routeProtocolHTTPCB_stateChanged(int arg1)
if (routeProtocolBTCB->isChecked()) protocols.push_back("bittorrent"); if (routeProtocolBTCB->isChecked()) protocols.push_back("bittorrent");
CurrentRule.protocol = protocols; CurrentRule.protocol = protocols;
statusLabel->setText(tr("Protocol list changed: ") + Stringify(protocols)); statusLabel->setText(tr("Protocol list changed: ") + protocols.join(";"));
} }
void RouteEditor::on_routeProtocolTLSCB_stateChanged(int arg1) void RouteEditor::on_routeProtocolTLSCB_stateChanged(int arg1)
{ {
@ -424,7 +424,7 @@ void RouteEditor::on_routeProtocolTLSCB_stateChanged(int arg1)
if (routeProtocolBTCB->isChecked()) protocols.push_back("bittorrent"); if (routeProtocolBTCB->isChecked()) protocols.push_back("bittorrent");
CurrentRule.protocol = protocols; CurrentRule.protocol = protocols;
statusLabel->setText(tr("Protocol list changed: ") + Stringify(protocols)); statusLabel->setText(tr("Protocol list changed: ") + protocols.join(";"));
} }
void RouteEditor::on_routeProtocolBTCB_stateChanged(int arg1) void RouteEditor::on_routeProtocolBTCB_stateChanged(int arg1)
{ {
@ -438,7 +438,7 @@ void RouteEditor::on_routeProtocolBTCB_stateChanged(int arg1)
if (routeProtocolTLSCB->isChecked()) protocols.push_back("tls"); if (routeProtocolTLSCB->isChecked()) protocols.push_back("tls");
CurrentRule.protocol = protocols; CurrentRule.protocol = protocols;
statusLabel->setText(tr("Protocol list changed: ") + Stringify(protocols)); statusLabel->setText(tr("Protocol list changed: ") + protocols.join(";"));
} }
void RouteEditor::on_balancerAddBtn_clicked() void RouteEditor::on_balancerAddBtn_clicked()
{ {

View File

@ -47,36 +47,6 @@ namespace Qv2ray
return randomString; return randomString;
} }
QString Stringify(list<string> list, QString saperator)
{
QString out;
for (auto item : list) {
out.append(QString::fromStdString(item));
out.append(saperator);
}
if (out.length() >= 1)
out = out.remove(out.length() - 1, 1);
return out;
}
QString Stringify(QList<QString> list, QString saperator)
{
QString out;
for (auto item : list) {
out.append(item);
out.append(saperator);
}
if (out.length() >= 1)
out = out.remove(out.length() - 1, 1);
return out;
}
QString StringFromFile(QFile *source) QString StringFromFile(QFile *source)
{ {
source->open(QFile::ReadOnly); source->open(QFile::ReadOnly);

View File

@ -30,8 +30,8 @@ namespace Qv2ray
QString JsonToString(QJsonObject json, QJsonDocument::JsonFormat format = QJsonDocument::JsonFormat::Indented); QString JsonToString(QJsonObject json, QJsonDocument::JsonFormat format = QJsonDocument::JsonFormat::Indented);
QString JsonToString(QJsonArray array, QJsonDocument::JsonFormat format = QJsonDocument::JsonFormat::Indented); QString JsonToString(QJsonArray array, QJsonDocument::JsonFormat format = QJsonDocument::JsonFormat::Indented);
QString VerifyJsonString(const QString &source); QString VerifyJsonString(const QString &source);
QString Stringify(list<string> list, QString saperator = ";"); //QString Stringify(list<string> list, QString saperator = ";");
QString Stringify(QList<QString> list, QString saperator = ";"); //QString Stringify(QList<QString> list, QString saperator = ";");
QString FormatBytes(long long bytes); QString FormatBytes(long long bytes);
void DeducePossibleFileName(const QString &baseDir, QString *fileName, const QString &extension); void DeducePossibleFileName(const QString &baseDir, QString *fileName, const QString &extension);
QString ConvertGFWToPAC(const QString &rawContent, const QString &customProxyString); QString ConvertGFWToPAC(const QString &rawContent, const QString &customProxyString);