diff options
Diffstat (limited to 'src/gui/clientConfigDialog.cpp')
| -rw-r--r-- | src/gui/clientConfigDialog.cpp | 52 |
1 files changed, 5 insertions, 47 deletions
diff --git a/src/gui/clientConfigDialog.cpp b/src/gui/clientConfigDialog.cpp index 3867118..70d38fc 100644 --- a/src/gui/clientConfigDialog.cpp +++ b/src/gui/clientConfigDialog.cpp @@ -17,16 +17,13 @@ */ #include <QtDebug> +#include <QNetworkInterface> +#include <QStandardItemModel> #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 +#include <src/net/pvsNetworkInterfaceListModel.h> using namespace std; @@ -38,11 +35,10 @@ ClientConfigDialog::ClientConfigDialog(QWidget *parent) : connect(this, SIGNAL(accepted()), this, SLOT(writeSettings())); connect(radioButtonOtherRO, SIGNAL(clicked()), this, SLOT(checkPermissions())); - connect(reloadInterfaceListButton, SIGNAL(clicked()), this, SLOT(reloadNetworkInterfaceList())); - reloadNetworkInterfaceList(); + _interfaceListModel = new PVSNetworkInterfaceListModel(this); interfaceList->setModel(_interfaceListModel); interfaceList->setModelColumn(0); - + connect(reloadInterfaceListButton, SIGNAL(clicked()), _interfaceListModel, SLOT(reloadInterfaceList())); } ClientConfigDialog::~ClientConfigDialog() @@ -124,41 +120,3 @@ 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 -} |
