Skip to content

Commit f3082e4

Browse files
committed
fix unix isAdmin &&
some refactoring
1 parent 85e19c6 commit f3082e4

5 files changed

Lines changed: 33 additions & 35 deletions

File tree

include/api/gRPC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace NekoGui_rpc {
1414

1515
class Client {
1616
public:
17-
explicit Client(std::function<void(const QString &)> onError, const QString &target, const QString &token);
17+
explicit Client(std::function<void(const QString &)> onError, const QString &target);
1818

1919
void Exit();
2020

include/global/NekoGui_DataStore.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ namespace NekoGui {
3030
public:
3131
// Running
3232

33-
QString core_token;
3433
int core_port = 19810;
3534
int started_id = -1919;
3635
bool core_running = false;

src/api/gRPC.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ namespace QtGrpc {
125125
}
126126

127127
public:
128-
Http2GrpcChannelPrivate(const QString &url_, const QString &nekoray_auth_, const QString &serviceName_) {
128+
Http2GrpcChannelPrivate(const QString &url_, const QString &serviceName_) {
129129
url_base = "http://" + url_;
130130
serviceName = serviceName_;
131131
//
@@ -182,8 +182,8 @@ namespace QtGrpc {
182182

183183
namespace NekoGui_rpc {
184184

185-
Client::Client(std::function<void(const QString &)> onError, const QString &target, const QString &token) {
186-
this->make_grpc_channel = [=]() { return std::make_unique<QtGrpc::Http2GrpcChannelPrivate>(target, token, "libcore.LibcoreService"); };
185+
Client::Client(std::function<void(const QString &)> onError, const QString &target) {
186+
this->make_grpc_channel = [=]() { return std::make_unique<QtGrpc::Http2GrpcChannelPrivate>(target, "libcore.LibcoreService"); };
187187
this->default_grpc_channel = make_grpc_channel();
188188
this->onError = std::move(onError);
189189
}

src/ui/mainwindow.cpp

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,33 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
7272
themeManager->ApplyTheme(NekoGui::dataStore->theme);
7373
ui->setupUi(this);
7474

75+
// Prepare core
76+
NekoGui::dataStore->core_port = MkPort();
77+
if (NekoGui::dataStore->core_port <= 0) NekoGui::dataStore->core_port = 19810;
78+
79+
auto core_path = QApplication::applicationDirPath() + "/";
80+
core_path += "nekobox_core";
81+
82+
QStringList args;
83+
args.push_back("nekobox");
84+
args.push_back("-port");
85+
args.push_back(Int2String(NekoGui::dataStore->core_port));
86+
if (NekoGui::dataStore->flag_debug) args.push_back("-debug");
87+
88+
// Start core
89+
runOnUiThread(
90+
[=] {
91+
core_process = new NekoGui_sys::CoreProcess(core_path, args);
92+
// Remember last started
93+
if (NekoGui::dataStore->remember_enable && NekoGui::dataStore->remember_id >= 0) {
94+
core_process->start_profile_when_core_is_up = NekoGui::dataStore->remember_id;
95+
}
96+
// Setup
97+
core_process->Start();
98+
setup_grpc();
99+
},
100+
DS_cores);
101+
75102
if (!NekoGui::dataStore->font.isEmpty()) {
76103
qApp->setFont(NekoGui::dataStore->font);
77104
}
@@ -432,34 +459,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
432459
});
433460
refresh_status();
434461

435-
// Prepare core
436-
NekoGui::dataStore->core_token = GetRandomString(32);
437-
NekoGui::dataStore->core_port = MkPort();
438-
if (NekoGui::dataStore->core_port <= 0) NekoGui::dataStore->core_port = 19810;
439-
440-
auto core_path = QApplication::applicationDirPath() + "/";
441-
core_path += "nekobox_core";
442-
443-
QStringList args;
444-
args.push_back("nekobox");
445-
args.push_back("-port");
446-
args.push_back(Int2String(NekoGui::dataStore->core_port));
447-
if (NekoGui::dataStore->flag_debug) args.push_back("-debug");
448-
449-
// Start core
450-
runOnUiThread(
451-
[=] {
452-
core_process = new NekoGui_sys::CoreProcess(core_path, args);
453-
// Remember last started
454-
if (NekoGui::dataStore->remember_enable && NekoGui::dataStore->remember_id >= 0) {
455-
core_process->start_profile_when_core_is_up = NekoGui::dataStore->remember_id;
456-
}
457-
// Setup
458-
core_process->Start();
459-
setup_grpc();
460-
},
461-
DS_cores);
462-
463462
connect(qApp, &QGuiApplication::commitDataRequest, this, &MainWindow::on_commitDataRequest);
464463

465464
auto t = new QTimer;

src/ui/mainwindow_grpc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ void MainWindow::setup_grpc() {
2020
// Setup Connection
2121
defaultClient = new Client(
2222
[=](const QString &errStr) {
23-
MW_show_log("[Error] gRPC: " + errStr);
23+
MW_show_log("[Error] Core: " + errStr);
2424
},
25-
"127.0.0.1:" + Int2String(NekoGui::dataStore->core_port), NekoGui::dataStore->core_token);
25+
"127.0.0.1:" + Int2String(NekoGui::dataStore->core_port));
2626

2727
// Looper
2828
runOnNewThread([=] { NekoGui_traffic::trafficLooper->Loop(); });

0 commit comments

Comments
 (0)