mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-14 18:57:07 -07:00
Parse Regist Response
This commit is contained in:
parent
03e56f7fdf
commit
875e8b413e
11 changed files with 292 additions and 13 deletions
|
@ -40,7 +40,9 @@ add_executable(chiaki
|
|||
include/settings.h
|
||||
src/settings.cpp
|
||||
include/registdialog.h
|
||||
src/registdialog.cpp)
|
||||
src/registdialog.cpp
|
||||
include/host.h
|
||||
src/host.cpp)
|
||||
target_include_directories(chiaki PRIVATE include)
|
||||
|
||||
target_link_libraries(chiaki chiaki-lib chiaki-cli-lib)
|
||||
|
|
61
gui/include/host.h
Normal file
61
gui/include/host.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* This file is part of Chiaki.
|
||||
*
|
||||
* Chiaki is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Chiaki is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Chiaki. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CHIAKI_HOST_H
|
||||
#define CHIAKI_HOST_H
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
#include <chiaki/regist.h>
|
||||
|
||||
class HostMAC
|
||||
{
|
||||
private:
|
||||
uint8_t mac[6];
|
||||
|
||||
public:
|
||||
HostMAC() { memset(mac, 0, sizeof(mac)); }
|
||||
explicit HostMAC(const uint8_t mac[6]) { memcpy(this->mac, mac, sizeof(this->mac)); }
|
||||
const uint8_t *GetMAC() const { return mac; }
|
||||
};
|
||||
|
||||
static bool operator==(const HostMAC &a, const HostMAC &b) { return memcmp(a.GetMAC(), b.GetMAC(), 6) == 0; }
|
||||
|
||||
class RegisteredHost
|
||||
{
|
||||
private:
|
||||
QString ap_ssid;
|
||||
QString ap_bssid;
|
||||
QString ap_key;
|
||||
QString ap_name;
|
||||
HostMAC ps4_mac;
|
||||
QString ps4_nickname;
|
||||
char rp_regist_key[CHIAKI_SESSION_AUTH_SIZE];
|
||||
uint32_t rp_key_type;
|
||||
uint8_t rp_key[0x10];
|
||||
|
||||
public:
|
||||
RegisteredHost();
|
||||
RegisteredHost(const ChiakiRegisteredHost &chiaki_host);
|
||||
|
||||
const QString &GetPS4Nickname() const { return ps4_nickname; }
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(RegisteredHost)
|
||||
|
||||
#endif //CHIAKI_HOST_H
|
|
@ -18,6 +18,8 @@
|
|||
#ifndef CHIAKI_REGISTDIALOG_H
|
||||
#define CHIAKI_REGISTDIALOG_H
|
||||
|
||||
#include "host.h"
|
||||
|
||||
#include <chiaki/regist.h>
|
||||
|
||||
#include <QDialog>
|
||||
|
@ -69,7 +71,7 @@ class RegistExecuteDialog: public QDialog
|
|||
|
||||
private slots:
|
||||
void Log(ChiakiLogLevel level, QString msg);
|
||||
void Success();
|
||||
void Success(RegisteredHost host);
|
||||
void Failed();
|
||||
|
||||
public:
|
||||
|
|
37
gui/src/host.cpp
Normal file
37
gui/src/host.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* This file is part of Chiaki.
|
||||
*
|
||||
* Chiaki is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Chiaki is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Chiaki. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <host.h>
|
||||
|
||||
RegisteredHost::RegisteredHost()
|
||||
{
|
||||
memset(rp_regist_key, 0, sizeof(rp_regist_key));
|
||||
memset(rp_key, 0, sizeof(rp_key));
|
||||
}
|
||||
|
||||
RegisteredHost::RegisteredHost(const ChiakiRegisteredHost &chiaki_host)
|
||||
: ps4_mac(chiaki_host.ps4_mac)
|
||||
{
|
||||
ap_ssid = chiaki_host.ap_ssid;
|
||||
ap_bssid = chiaki_host.ap_bssid;
|
||||
ap_key = chiaki_host.ap_key;
|
||||
ap_name = chiaki_host.ap_name;
|
||||
ps4_nickname = chiaki_host.ps4_nickname;
|
||||
memcpy(rp_regist_key, chiaki_host.rp_regist_key, sizeof(rp_regist_key));
|
||||
rp_key_type = chiaki_host.rp_key_type;
|
||||
memcpy(rp_key, chiaki_host.rp_key, sizeof(rp_key));
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
#include <streamsession.h>
|
||||
#include <settings.h>
|
||||
#include <registdialog.h>
|
||||
#include <host.h>
|
||||
|
||||
#include <chiaki-cli.h>
|
||||
|
||||
|
@ -38,6 +39,7 @@ int RunMain(QApplication &app, Settings *settings);
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
qRegisterMetaType<DiscoveryHost>();
|
||||
qRegisterMetaType<RegisteredHost>();
|
||||
qRegisterMetaType<ChiakiQuitReason>();
|
||||
qRegisterMetaType<ChiakiRegistEventType>();
|
||||
qRegisterMetaType<ChiakiLogLevel>();
|
||||
|
|
|
@ -141,9 +141,9 @@ void RegistExecuteDialog::Finished()
|
|||
button_box->addButton(QDialogButtonBox::Close);
|
||||
}
|
||||
|
||||
void RegistExecuteDialog::Success()
|
||||
void RegistExecuteDialog::Success(RegisteredHost host)
|
||||
{
|
||||
printf("finished\n");
|
||||
CHIAKI_LOGI(&log, "Successfully registered %s", host.GetPS4Nickname().toLocal8Bit().constData());
|
||||
Finished();
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ class RegistExecuteDialogPrivate
|
|||
switch(event->type)
|
||||
{
|
||||
case CHIAKI_REGIST_EVENT_TYPE_FINISHED_SUCCESS:
|
||||
QMetaObject::invokeMethod(dialog, "Success", Qt::ConnectionType::QueuedConnection);
|
||||
QMetaObject::invokeMethod(dialog, "Success", Qt::ConnectionType::QueuedConnection, Q_ARG(RegisteredHost, *event->registered_host));
|
||||
break;
|
||||
case CHIAKI_REGIST_EVENT_TYPE_FINISHED_FAILED:
|
||||
QMetaObject::invokeMethod(dialog, "Failed", Qt::ConnectionType::QueuedConnection);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue