List of addresses in the About dialog
This commit is contained in:
+32
-12
@@ -5,6 +5,7 @@ import Typography from '@mui/material/Typography';
|
||||
import { PiPedalModel, PiPedalModelFactory, State } from './PiPedalModel';
|
||||
import AppBar from '@mui/material/AppBar';
|
||||
import Toolbar from '@mui/material/Toolbar';
|
||||
import Divider from '@mui/material/Divider';
|
||||
import ArrowBackIcon from '@mui/icons-material//ArrowBack';
|
||||
|
||||
import JackHostStatus from './JackHostStatus';
|
||||
@@ -138,22 +139,17 @@ const AboutDialog = withStyles(styles, { withTheme: true })(
|
||||
}
|
||||
}
|
||||
|
||||
startFossRequest()
|
||||
{
|
||||
if (this.state.openSourceNotices === "")
|
||||
{
|
||||
startFossRequest() {
|
||||
if (this.state.openSourceNotices === "") {
|
||||
fetch("var/notices.txt")
|
||||
.then((request)=>
|
||||
{
|
||||
if (!request.ok)
|
||||
{
|
||||
.then((request) => {
|
||||
if (!request.ok) {
|
||||
throw new PiPedalError("notices request failed.");
|
||||
}
|
||||
return request.text();
|
||||
})
|
||||
.then((text) => {
|
||||
if (this.mounted)
|
||||
{
|
||||
if (this.mounted) {
|
||||
this.setState({ openSourceNotices: text });
|
||||
}
|
||||
|
||||
@@ -221,15 +217,39 @@ const AboutDialog = withStyles(styles, { withTheme: true })(
|
||||
<Typography display="block" variant="body2" style={{ marginBottom: 12 }} >
|
||||
Copyright © 2022 Robin Davies.
|
||||
</Typography>
|
||||
<Typography display="block" variant="body2" style={{marginBottom: 12}} >
|
||||
{this.model.isAndroidHosted() && (
|
||||
<Typography display="block" variant="body2" style={{ marginBottom: 0 }} >
|
||||
{this.model.getAndroidHostVersion()}
|
||||
</Typography>
|
||||
)}
|
||||
|
||||
{this.model.isAndroidHosted() && (
|
||||
<Typography display="block" variant="body2" style={{ marginBottom: 12 }} >
|
||||
Copyright © 2022 Robin Davies.
|
||||
</Typography>
|
||||
)}
|
||||
<Divider />
|
||||
<Typography display="block" variant="caption" >
|
||||
ADDRESSES
|
||||
</Typography>
|
||||
<div style={{marginBottom: 16}}>
|
||||
{
|
||||
this.model.serverVersion?.webAddresses.map((address) =>
|
||||
(
|
||||
<Typography display="block" variant="body2" style={{ marginBottom: 0, marginLeft: 24 }} >
|
||||
{address}
|
||||
</Typography>
|
||||
))
|
||||
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
<Divider />
|
||||
<Typography display="block" variant="caption" >
|
||||
LEGAL NOTICES
|
||||
</Typography>
|
||||
<div dangerouslySetInnerHTML={{__html: this.state.openSourceNotices}} style={{fontSize: "0.8em" }}>
|
||||
<div dangerouslySetInnerHTML={{ __html: this.state.openSourceNotices }} style={{ fontSize: "0.8em",maxWidth: 400 }}>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
+10
-2
@@ -576,6 +576,13 @@ const AppThemed = withStyles(appStyles)(class extends ResizeResponsiveComponent<
|
||||
}
|
||||
return result;
|
||||
}
|
||||
handleReload() {
|
||||
if (this.model_.isAndroidHosted()) {
|
||||
this.model_.chooseNewDevice();
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
render() {
|
||||
|
||||
const { classes } = this.props;
|
||||
@@ -787,7 +794,8 @@ const AppThemed = withStyles(appStyles)(class extends ResizeResponsiveComponent<
|
||||
<JackStatusView />
|
||||
<div className={classes.errorContent} style={{
|
||||
display: (this.state.displayState === State.Reconnecting || this.state.displayState === State.ApplyingChanges)
|
||||
? "block" : "none" }}
|
||||
? "block" : "none"
|
||||
}}
|
||||
>
|
||||
<div className={classes.errorContentMask} />
|
||||
|
||||
@@ -816,7 +824,7 @@ const AppThemed = withStyles(appStyles)(class extends ResizeResponsiveComponent<
|
||||
</div>
|
||||
<div style={{ paddingTop: 50, paddingLeft: 36, textAlign: "left" }}>
|
||||
<Button variant='contained' color="primary" component='button'
|
||||
onClick={() => window.location.reload()} >
|
||||
onClick={() => this.handleReload()} >
|
||||
Reload
|
||||
</Button>
|
||||
|
||||
|
||||
@@ -159,6 +159,7 @@ export type PiPedalVersion = {
|
||||
operatingSystem: string;
|
||||
osVersion: string;
|
||||
debug: boolean;
|
||||
webAddresses: string[];
|
||||
};
|
||||
|
||||
export class PresetIndexEntry {
|
||||
|
||||
+15
-4
@@ -100,7 +100,9 @@ bool pipedal::ParseHttpAddress(const std::string address,
|
||||
*pUser = address.substr(0, start);
|
||||
}
|
||||
start = start + 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
start = 0;
|
||||
if (pUser)
|
||||
{
|
||||
@@ -130,7 +132,9 @@ bool pipedal::ParseHttpAddress(const std::string address,
|
||||
if (*p >= '0' && *p <= '9')
|
||||
{
|
||||
portNumber = portNumber * 10 + *p - '0';
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -354,7 +358,7 @@ static std::string GetLinkLocalAddressForIp4Interface(const std::string&name)
|
||||
struct ifaddrs *ifap = nullptr;
|
||||
if (getifaddrs(&ifap) != 0)
|
||||
return "";
|
||||
std::string result = "notlocalsubnet.error";
|
||||
std::string result = "";
|
||||
for (ifaddrs *p = ifap; p != nullptr; p = p->ifa_next)
|
||||
{
|
||||
if (p->ifa_addr->sa_family == AF_INET && p->ifa_addr != nullptr && p->ifa_netmask != nullptr)
|
||||
@@ -427,7 +431,9 @@ std::string pipedal::GetLinkLocalAddress(const std::string fromAddress)
|
||||
uint32_t remoteAddress = htonl(*(int32_t *)(pAddr + 12));
|
||||
std::string interfaceName = GetInterfaceForIp4Address(remoteAddress);
|
||||
result = GetLinkLocalAddressForIp4Interface(interfaceName);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
std::string interfaceName;
|
||||
if (IsIpv4MappedAddress(inetAddr6))
|
||||
@@ -449,3 +455,8 @@ std::string pipedal::GetLinkLocalAddress(const std::string fromAddress)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string pipedal::GetInterfaceIpv4Address(const std::string& interfaceName)
|
||||
{
|
||||
return GetLinkLocalAddressForIp4Interface(interfaceName);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
namespace pipedal {
|
||||
|
||||
|
||||
std::string GetInterfaceIpv4Address(const std::string& interfaceName);
|
||||
|
||||
|
||||
std::string GetLinkLocalAddress(const std::string fromAddress);
|
||||
|
||||
bool IsOnLocalSubnet(const std::string&fromAddress);
|
||||
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
PiPedalModel();
|
||||
virtual ~PiPedalModel();
|
||||
|
||||
|
||||
uint16_t GetWebPort() const { return webPort; }
|
||||
void Close();
|
||||
|
||||
void UpdateDnsSd();
|
||||
|
||||
@@ -926,7 +926,7 @@ public:
|
||||
}
|
||||
else if (message == "version")
|
||||
{
|
||||
PiPedalVersion version;
|
||||
PiPedalVersion version(this->model);
|
||||
|
||||
Reply(replyTo, "version", version);
|
||||
}
|
||||
|
||||
+42
-1
@@ -18,8 +18,10 @@
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include "pch.h"
|
||||
#include "PiPedalModel.hpp"
|
||||
#include "config.hpp"
|
||||
#include "PiPedalVersion.hpp"
|
||||
#include "Ipv6Helpers.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "windows.h"
|
||||
@@ -36,9 +38,21 @@ JSON_MAP_BEGIN(PiPedalVersion)
|
||||
JSON_MAP_REFERENCE(PiPedalVersion,operatingSystem)
|
||||
JSON_MAP_REFERENCE(PiPedalVersion,osVersion)
|
||||
JSON_MAP_REFERENCE(PiPedalVersion,debug)
|
||||
JSON_MAP_REFERENCE(PiPedalVersion,webAddresses)
|
||||
JSON_MAP_END()
|
||||
|
||||
PiPedalVersion::PiPedalVersion()
|
||||
|
||||
static std::string MakeWebAddress(const std::string &address, uint16_t port)
|
||||
{
|
||||
if (port == 80)
|
||||
{
|
||||
return SS("http://" << address << '/');
|
||||
} else {
|
||||
return SS("http://" << address << ':' << port << '/');
|
||||
}
|
||||
}
|
||||
|
||||
PiPedalVersion::PiPedalVersion(PiPedalModel&model)
|
||||
{
|
||||
server_ = "PiPedal Server";
|
||||
// defined on build command line.
|
||||
@@ -71,4 +85,31 @@ PiPedalVersion::PiPedalVersion()
|
||||
#else
|
||||
debug_ = false;
|
||||
#endif
|
||||
|
||||
uint16_t port = model.GetWebPort();
|
||||
|
||||
char hostName[512];
|
||||
gethostname(hostName,sizeof(hostName));
|
||||
|
||||
this->webAddresses_.push_back(MakeWebAddress(SS(hostName << ".local"),port));
|
||||
|
||||
std::string ethAddr = GetInterfaceIpv4Address("eth0");
|
||||
if (ethAddr.length() != 0)
|
||||
{
|
||||
this->webAddresses_.push_back(MakeWebAddress(ethAddr,port));
|
||||
}
|
||||
std::string wlanAddr = GetInterfaceIpv4Address("wlan0");
|
||||
if (wlanAddr.length() != 0)
|
||||
{
|
||||
this->webAddresses_.push_back(MakeWebAddress(wlanAddr,port));
|
||||
|
||||
}
|
||||
std::string p2pAddr = GetInterfaceIpv4Address("p2p-wlan0-0");
|
||||
if (p2pAddr.length() != 0)
|
||||
{
|
||||
this->webAddresses_.push_back(MakeWebAddress(p2pAddr,port));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,16 +22,19 @@
|
||||
|
||||
namespace pipedal {
|
||||
|
||||
class PiPedalModel;
|
||||
|
||||
class PiPedalVersion {
|
||||
private:
|
||||
std::string server_;
|
||||
std::string serverVersion_;
|
||||
std::string operatingSystem_;
|
||||
std::string osVersion_;
|
||||
std::vector<std::string> webAddresses_;
|
||||
bool debug_;
|
||||
|
||||
public:
|
||||
PiPedalVersion();
|
||||
PiPedalVersion(PiPedalModel&model);
|
||||
~PiPedalVersion() = default;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user