00001
00002 #include "interfaceinformationimp.h"
00003 #include "interfaceadvanced.h"
00004
00005
00006 #include <qpe/config.h>
00007 #include <qpe/qpeapplication.h>
00008
00009
00010 #include <qcheckbox.h>
00011 #include <qpushbutton.h>
00012 #include <qlabel.h>
00013 #include <qgroupbox.h>
00014 #include <qmessagebox.h>
00015
00016
00017 #ifdef QWS
00018 #else
00019 #define showMaximized show
00020 #endif
00021
00026 InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i)
00027 {
00028 connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*)));
00029 connect(i, SIGNAL(updateMessage(const QString&)), this, SLOT(showMessage(const QString&)));
00030 updateInterface(interface);
00031 connect(startButton, SIGNAL(clicked()), interface, SLOT(start()));
00032 connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop()));
00033 connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart()));
00034 connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh()));
00035 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced()));
00036 Config cfg("networksettings", Config::User);
00037 cfg.setGroup("interface");
00038 CheckBoxSilent->setChecked( cfg.readBoolEntry("silent", false) );
00039 }
00040
00041 InterfaceInformationImp::~InterfaceInformationImp()
00042 {
00043 Config cfg("networksettings", Config::User);
00044 cfg.setGroup("interface");
00045 cfg.writeEntry("silent", CheckBoxSilent->isChecked() );
00046 }
00047
00053 void InterfaceInformationImp::updateInterface(Interface *)
00054 {
00055 if(interface->getStatus())
00056 {
00057 startButton->setEnabled(false);
00058 stopButton->setEnabled(true);
00059 restartButton->setEnabled(true);
00060 }
00061 else
00062 {
00063 startButton->setEnabled(true);
00064 stopButton->setEnabled(false);
00065 restartButton->setEnabled(false);
00066 }
00067 macAddressLabel->setText(interface->getMacAddress());
00068 ipAddressLabel->setText(interface->getIp());
00069 subnetMaskLabel->setText(interface->getSubnetMask());
00070 broadcastLabel->setText(interface->getBroadcast());
00071 }
00072
00077 void InterfaceInformationImp::advanced()
00078 {
00079 InterfaceAdvanced *a = new InterfaceAdvanced(this, "InterfaceAdvanced", Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog);
00080 a->interfaceName->setText(interface->getInterfaceName());
00081 a->macAddressLabel->setText(interface->getMacAddress());
00082 a->ipAddressLabel->setText(interface->getIp());
00083 a->subnetMaskLabel->setText(interface->getSubnetMask());
00084 a->broadcastLabel->setText(interface->getBroadcast());
00085 a->dhcpServerLabel->setText(interface->getDhcpServerIp());
00086 a->leaseObtainedLabel->setText(interface->getLeaseObtained());
00087 a->leaseExpiresLabel->setText(interface->getLeaseExpires());
00088 a->dhcpInformation->setEnabled(interface->isDhcp());
00089 QPEApplication::showWidget( a );
00090 }
00091
00097 void InterfaceInformationImp::showMessage(const QString &message)
00098 {
00099 if (CheckBoxSilent->isChecked()) return;
00100 QMessageBox::information(this, "Message", message, QMessageBox::Ok);
00101 }
00102
00103
00104