Clientside QoS option

This commit is contained in:
Thorvald Natvig 2009-11-03 13:05:14 +01:00
parent 26d77a21f6
commit 2ea8eded44
5 changed files with 39 additions and 15 deletions

View File

@ -59,6 +59,7 @@ QIcon NetworkConfig::icon() const {
void NetworkConfig::load(const Settings &r) {
loadCheckBox(qcbTcpMode, s.bTCPCompat);
loadCheckBox(qcbQoS, s.bQoS);
loadCheckBox(qcbAutoReconnect, s.bReconnect);
loadCheckBox(qcbSuppressIdentity, s.bSuppressIdentity);
loadComboBox(qcbType, s.ptProxyType);
@ -84,6 +85,7 @@ void NetworkConfig::load(const Settings &r) {
void NetworkConfig::save() const {
s.bTCPCompat = qcbTcpMode->isChecked();
s.bQoS = qcbQoS->isChecked();
s.bReconnect = qcbAutoReconnect->isChecked();
s.bSuppressIdentity = qcbSuppressIdentity->isChecked();
@ -152,6 +154,7 @@ void NetworkConfig::accept() const {
bool NetworkConfig::expert(bool b) {
qcbTcpMode->setVisible(b);
qcbQoS->setVisible(b);
qgbProxy->setVisible(b);
qcbUsage->setVisible(b);

View File

@ -39,6 +39,19 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="qcbQoS">
<property name="toolTip">
<string>Enable QoS to prioritize packets</string>
</property>
<property name="whatsThis">
<string>This will enable QoS, which will attempt to prioritize voice packets over other traffic.</string>
</property>
<property name="text">
<string>Use Quality of Service</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="qcbAutoReconnect">
<property name="toolTip">

View File

@ -403,7 +403,8 @@ void ServerHandler::serverConnectionClosed(const QString &reason) {
}
void ServerHandler::serverConnectionConnected() {
cConnection->setToS();
if (g.s.bQoS)
cConnection->setToS();
qscCert = cConnection->peerCertificateChain();
qscCipher = cConnection->sessionCipher();
@ -457,24 +458,26 @@ void ServerHandler::serverConnectionConnected() {
connect(qusUdp, SIGNAL(readyRead()), this, SLOT(udpReady()));
if (g.s.bQoS) {
#if defined(Q_OS_UNIX)
int val = 0xe0;
if (setsockopt(qusUdp->socketDescriptor(), IPPROTO_IP, IP_TOS, &val, sizeof(val)))
qWarning("ServerHandler: Failed to set TOS for UDP Socket");
int val = 0xe0;
if (setsockopt(qusUdp->socketDescriptor(), IPPROTO_IP, IP_TOS, &val, sizeof(val)))
qWarning("ServerHandler: Failed to set TOS for UDP Socket");
#elif defined(Q_OS_WIN)
if (hQoS != NULL) {
struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(usPort);
addr.sin_addr.s_addr = htonl(qhaRemote.toIPv4Address());
if (hQoS != NULL) {
struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_port = htons(usPort);
addr.sin_addr.s_addr = htonl(qhaRemote.toIPv4Address());
dwFlowUDP = 0;
if (! QOSAddSocketToFlow(hQoS, qusUdp->socketDescriptor(), reinterpret_cast<sockaddr *>(&addr), QOSTrafficTypeVoice, QOS_NON_ADAPTIVE_FLOW, &dwFlowUDP))
qWarning("ServerHandler: Failed to add UDP to QOS");
}
dwFlowUDP = 0;
if (! QOSAddSocketToFlow(hQoS, qusUdp->socketDescriptor(), reinterpret_cast<sockaddr *>(&addr), QOSTrafficTypeVoice, QOS_NON_ADAPTIVE_FLOW, &dwFlowUDP))
qWarning("ServerHandler: Failed to add UDP to QOS");
}
#endif
}
}
emit connected();

View File

@ -218,6 +218,7 @@ Settings::Settings() {
// Network settings
bTCPCompat = false;
bQoS = true;
bReconnect = true;
ptProxyType = NoProxy;
usProxyPort = 0;
@ -367,6 +368,7 @@ void Settings::load() {
// Network settings
SAVELOAD(bTCPCompat, "net/tcponly");
SAVELOAD(bQoS, "net/qos");
SAVELOAD(bReconnect, "net/reconnect");
SAVELOAD(bSuppressIdentity, "net/suppress");
LOADENUM(ptProxyType, "net/proxytype");
@ -541,6 +543,7 @@ void Settings::save() {
// Network settings
SAVELOAD(bTCPCompat, "net/tcponly");
SAVELOAD(bQoS, "net/qos");
SAVELOAD(bReconnect, "net/reconnect");
SAVELOAD(ptProxyType, "net/proxytype");
SAVELOAD(qsProxyHost, "net/proxyhost");

View File

@ -182,7 +182,9 @@ struct Settings {
// Network settings
enum ProxyType { NoProxy, HttpProxy, Socks5Proxy };
bool bTCPCompat, bReconnect;
bool bTCPCompat;
bool bReconnect;
bool bQoS;
ProxyType ptProxyType;
QString qsProxyHost, qsProxyUsername, qsProxyPassword;
unsigned short usProxyPort;