summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSebastien Braun2010-08-04 17:28:45 +0200
committerSebastien Braun2010-08-04 17:28:45 +0200
commitf8e6e94b25a092d51acdec600465074b4eb32cb8 (patch)
tree8251b788b2a63abba5cf0d9e046102471cce1e59 /src
parentFix a bug where transfer IDs would linger in the pvs daemon's data structures... (diff)
downloadpvs-f8e6e94b25a092d51acdec600465074b4eb32cb8.tar.gz
pvs-f8e6e94b25a092d51acdec600465074b4eb32cb8.tar.xz
pvs-f8e6e94b25a092d51acdec600465074b4eb32cb8.zip
Make PGM interface configurable
Diffstat (limited to 'src')
-rw-r--r--src/gui/clientConfigDialog.cpp61
-rw-r--r--src/gui/clientConfigDialog.h2
-rw-r--r--src/gui/ui/clientConfigDialog.ui64
-rw-r--r--src/pvs.cpp7
-rw-r--r--src/pvs.h2
-rw-r--r--src/pvsgui.cpp3
6 files changed, 134 insertions, 5 deletions
diff --git a/src/gui/clientConfigDialog.cpp b/src/gui/clientConfigDialog.cpp
index 76b4f5e..3867118 100644
--- a/src/gui/clientConfigDialog.cpp
+++ b/src/gui/clientConfigDialog.cpp
@@ -16,15 +16,32 @@
# -----------------------------------------------------------------------------
*/
+#include <QtDebug>
#include "clientConfigDialog.h"
+#include <cerrno>
+#include <cstdlib>
+#include <cstring>
+
+// For getting the network interface list:
+#ifdef __linux
+# include <sys/ioctl.h>
+# include <net/if.h>
+#endif
+
+using namespace std;
ClientConfigDialog::ClientConfigDialog(QWidget *parent) :
- QDialog(parent)
+ QDialog(parent),
+ _interfaceListModel(0)
{
setupUi(this);
connect(this, SIGNAL(accepted()), this, SLOT(writeSettings()));
connect(radioButtonOtherRO, SIGNAL(clicked()), this,
SLOT(checkPermissions()));
+ connect(reloadInterfaceListButton, SIGNAL(clicked()), this, SLOT(reloadNetworkInterfaceList()));
+ reloadNetworkInterfaceList();
+ interfaceList->setModel(_interfaceListModel);
+ interfaceList->setModelColumn(0);
}
@@ -66,6 +83,9 @@ void ClientConfigDialog::readSettings()
checkBoxAllowFiletransfer->setChecked(_settings.value(
"Permissions/allow_filetransfer").toBool());
+ if(!_settings.value("Muticast/interface").isNull())
+ interfaceList->setEditText(_settings.value("Multicast/interface").toString());
+
qDebug("[%s] Setting read from: '%s'", metaObject()->className(),
qPrintable(_settings.fileName()));
}
@@ -88,6 +108,7 @@ void ClientConfigDialog::writeSettings()
_settings.setValue("Permissions/allow_chat", checkBoxAllowChat->isChecked());
_settings.setValue("Permissions/allow_filetransfer",
checkBoxAllowFiletransfer->isChecked());
+ _settings.setValue("Multicast/interface", interfaceList->currentText());
_settings.sync();
emit configChanged();
@@ -103,3 +124,41 @@ void ClientConfigDialog::checkPermissions()
if (radioButtonLecturerNO->isChecked() && radioButtonOtherRO->isChecked())
radioButtonLecturerRO->setChecked(true);
}
+
+void ClientConfigDialog::reloadNetworkInterfaceList()
+{
+#ifdef __linux
+ static struct ifreq ifreqs[20];
+ ifconf ifconfigs;
+ memset(&ifconfigs, 0, sizeof(ifconfigs));
+ ifconfigs.ifc_len = sizeof(ifreqs);
+ ifconfigs.ifc_buf = (char*)&ifreqs;
+
+ int nosock = socket(AF_INET, SOCK_STREAM, 0);
+ if (nosock < 0)
+ {
+ qWarning() << "Could not get a socket descriptor:" << strerror(errno);
+ }
+ int retval;
+ if ((retval = ioctl(nosock, SIOCGIFCONF, (char*)(&ifconfigs))) < 0)
+ {
+ qWarning() << "Could not get the list of interfaces:" << strerror(errno);
+ return;
+ }
+
+ QStringList interfaces;
+ for(int i = 0; i < ifconfigs.ifc_len/sizeof(struct ifreq); i++)
+ {
+ char ifname[IFNAMSIZ + 1];
+ strncpy(ifname, ifreqs[i].ifr_name, IFNAMSIZ);
+ ifname[IFNAMSIZ] = '\0';
+ interfaces << QString::fromLocal8Bit(ifname);
+ }
+ if(!_interfaceListModel)
+ _interfaceListModel = new QStringListModel(interfaces, this);
+ else
+ _interfaceListModel->setStringList(interfaces);
+#else
+# warning "We have no way to get your system's network interface list. Some porting may be required."
+#endif
+}
diff --git a/src/gui/clientConfigDialog.h b/src/gui/clientConfigDialog.h
index 706bd8a..803f2c8 100644
--- a/src/gui/clientConfigDialog.h
+++ b/src/gui/clientConfigDialog.h
@@ -35,9 +35,11 @@ Q_SIGNALS:
private Q_SLOTS:
void checkPermissions();
+ void reloadNetworkInterfaceList();
private:
QSettings _settings;
+ QStringListModel* _interfaceListModel;
};
diff --git a/src/gui/ui/clientConfigDialog.ui b/src/gui/ui/clientConfigDialog.ui
index 3262b6b..bb4bdc9 100644
--- a/src/gui/ui/clientConfigDialog.ui
+++ b/src/gui/ui/clientConfigDialog.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>438</width>
- <height>257</height>
+ <width>445</width>
+ <height>266</height>
</rect>
</property>
<property name="windowTitle">
@@ -27,7 +27,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
- <number>0</number>
+ <number>2</number>
</property>
<widget class="QWidget" name="tabPermissions">
<attribute name="title">
@@ -197,6 +197,64 @@
</item>
</layout>
</widget>
+ <widget class="QWidget" name="networkTab">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <attribute name="title">
+ <string>Network</string>
+ </attribute>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="2" column="1">
+ <widget class="QComboBox" name="interfaceList">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="insertPolicy">
+ <enum>QComboBox::NoInsert</enum>
+ </property>
+ <property name="frame">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Network Interface</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QPushButton" name="reloadInterfaceListButton">
+ <property name="text">
+ <string>Reload List</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
<item>
diff --git a/src/pvs.cpp b/src/pvs.cpp
index 202aa32..c217d52 100644
--- a/src/pvs.cpp
+++ b/src/pvs.cpp
@@ -728,6 +728,13 @@ void PVS::cancelIncomingMulticastTransfer(qulonglong transferID)
}
}
+void PVS::setMulticastInterface(QString const& interfaceName)
+{
+ QSettings settings;
+ settings.setValue("multicast/interface", interfaceName);
+ settings.sync();
+}
+
void PVS::onIncomingMulticastTransfer(QString const& sender, qulonglong transferID,
QString const& basename, qulonglong size, ushort port)
{
diff --git a/src/pvs.h b/src/pvs.h
index ef6454e..4c61ffd 100644
--- a/src/pvs.h
+++ b/src/pvs.h
@@ -87,7 +87,7 @@ public Q_SLOTS:
bool createMulticastTransfer(QString const& objectPath, quint64& transferID, QString& errorReason);
void cancelOutgoingMulticastTransfer(quint64 transferID);
void cancelIncomingMulticastTransfer(qulonglong transferID);
-
+ void setMulticastInterface(QString const& interfaceName);
Q_SIGNALS:
void project(QString host, int port, QString passwd, bool fullscreen,
diff --git a/src/pvsgui.cpp b/src/pvsgui.cpp
index e949d5b..40112b4 100644
--- a/src/pvsgui.cpp
+++ b/src/pvsgui.cpp
@@ -143,6 +143,9 @@ void PVSGUI::updateConfig()
setLocation(POSITION_TOP_CENTER);
else
setLocation(_settings.value("Display/location").toInt());
+
+ if (!_settings.value("Multicast/interface").isNull())
+ _ifaceDBus->setMulticastInterface(_settings.value("Multicast/interface").toString());
}
////////////////////////////////////////////////////////////////////////////////