-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
984 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
qv2ray/ui/widgets/editors/w_JsonEditor.hpp → ...ay/v2/ui/widgets/editors/w_JsonEditor.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "GeositeReader.hpp" | ||
|
||
#include "qv2ray/wrapper.hpp" | ||
#include "picoproto.hpp" | ||
|
||
#include <QFile> | ||
#include <QMap> | ||
|
||
namespace Qv2ray::components::GeositeReader { | ||
QMap<QString, QStringList> GeositeEntries; | ||
|
||
QStringList ReadGeoSiteFromFile(const QString &filepath, bool allowCache) { | ||
if (GeositeEntries.contains(filepath) && allowCache) | ||
return GeositeEntries.value(filepath); | ||
|
||
QStringList list; | ||
qInfo() << "Reading geosites from:" << filepath; | ||
QFile f(filepath); | ||
bool opened = f.open(QFile::OpenModeFlag::ReadOnly); | ||
|
||
if (!opened) { | ||
qInfo() << "File cannot be opened:" << filepath; | ||
return list; | ||
} | ||
|
||
const auto content = f.readAll(); | ||
f.close(); | ||
{ | ||
picoproto::Message root; | ||
root.ParseFromBytes((unsigned char *) content.data(), content.size()); | ||
|
||
list.reserve(root.GetMessageArray(1).size()); | ||
for (const auto &geosite: root.GetMessageArray(1)) | ||
list << QString::fromStdString(geosite->GetString(1)); | ||
} | ||
|
||
qInfo() << "Loaded" << list.count() << "geosite entries from data file."; | ||
list.sort(); | ||
GeositeEntries[filepath] = list; | ||
return list; | ||
} | ||
} // namespace Qv2ray::components::geosite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
#include <QString> | ||
|
||
namespace Qv2ray::components::GeositeReader { | ||
QStringList ReadGeoSiteFromFile(const QString &filepath, bool allowCache = true); | ||
} // namespace Qv2ray::components::GeositeReader |
Oops, something went wrong.