summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/interface.cpp2
-rw-r--r--noncore/net/networksetup/interfaceinformationimp.h2
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp15
-rw-r--r--noncore/net/networksetup/mainwindowimp.h9
-rw-r--r--noncore/settings/networksettings/interface.cpp2
-rw-r--r--noncore/settings/networksettings/interfaceinformationimp.h2
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp15
-rw-r--r--noncore/settings/networksettings/mainwindowimp.h9
8 files changed, 42 insertions, 14 deletions
diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp
index b9b09ad..f6eed00 100644
--- a/noncore/net/networksetup/interface.cpp
+++ b/noncore/net/networksetup/interface.cpp
@@ -182,33 +182,33 @@ bool Interface::refresh(){
// Get the start running time of the deamon
fileName = (QString("/proc/%1/stat").arg(pid));
file.setName(fileName);
stream.setDevice( &file );
if (!file.open(IO_ReadOnly)){
qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
return false;
}
while ( !stream.eof() ) {
line = stream.readLine();
}
file.close();
long time = 0;
// Grab the start time
// pid com state ppid pgrp session tty_nr tpgid flags
- int r = sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
+ sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
// minflt cminflt majflt cmajflt utime stime cutime cstime priority
"%*u %*u %*u %*u %*u %*u %*d %*d %*d "
// nice 0 itrealvalue starttime
"%*d %*d %*d %lu", (long*) &time);
time = time/100;
QDateTime datetime(QDateTime::currentDateTime());
// Get the uptime of the computer.
QFile f("/proc/uptime");
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
int sec = 0;
t >> sec;
datetime = datetime.addSecs((-1*sec));
f.close();
diff --git a/noncore/net/networksetup/interfaceinformationimp.h b/noncore/net/networksetup/interfaceinformationimp.h
index 6fc2384..c8a478e 100644
--- a/noncore/net/networksetup/interfaceinformationimp.h
+++ b/noncore/net/networksetup/interfaceinformationimp.h
@@ -5,27 +5,27 @@
#include "interface.h"
class InterfaceInformationImp : public InterfaceInformation {
Q_OBJECT
public:
InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0);
~InterfaceInformationImp(){};
private slots:
void start();
void stop();
void refresh();
void restart();
void advanced();
- Interface *interface;
private:
+ Interface *interface;
void updateInterface();
};
#endif
// addserviceimp.h
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 3c13143..ad9362f 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -1,20 +1,23 @@
#include "mainwindowimp.h"
#include "addserviceimp.h"
#include "interfaceinformationimp.h"
#include "interfacesetupimp.h"
+#include "interface.h"
+#include "kprocess.h"
+#include "module.h"
#include <qpushbutton.h>
#include <qdir.h>
#include <qtabwidget.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qlistbox.h>
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
#include <qlist.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qlistview.h>
#include <qheader.h>
@@ -37,38 +40,46 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
// Make sure we have a plugin directory to scan.
QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
QDir pluginDir( DirStr );
pluginDir.mkdir( DirStr );
pluginDir.mkdir( ( DirStr + "plugins/" ) );
QString path = DirStr + "plugins";
pluginDir.setPath(path);
if(!pluginDir.exists()){
qDebug(QString("MainWindowImp: ERROR: %1 %2").arg(__FILE__).arg(__LINE__).latin1());
return;
}
// Load any saved services.
loadModules(path);
getInterfaceList();
serviceList->header()->hide();
+
+
+ Config cfg("NetworkSetup");
+ profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
}
/**
- * Deconstructor. Unload libraries and save.
+ * Deconstructor. Unload libraries and save profile list.
*/
MainWindowImp::~MainWindowImp(){
+ if(profiles.count() > 1){
+ Config cfg("NetworkSetup");
+ cfg.writeEntry("Profiles", profiles.join(" "));
+ }
}
void MainWindowImp::loadModules(QString path){
}
/**
* Attempt to load a function and resolve a function.
* @param pluginFileName - the name of the file in which to attempt to load
* @param resolveString - function pointer to resolve
* @return pointer to the function with name resolveString or NULL
*/
Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
//qDebug(pluginFileName.latin1());
QLibrary *lib = new QLibrary(pluginFileName);
void *functionPointer = lib->resolve(resolveString);
if( !functionPointer ){
@@ -239,33 +250,33 @@ void MainWindowImp::jobDone(KProcess *process){
}
else{
i = interfaceNames[interfaceName];
if(fileName != TEMP_ALL)
i->setStatus(true);
}
i->setAttached(true);
i->setInterfaceName(interfaceName);
QString hardName = "Ethernet";
int hardwareName = line.find("Link encap:");
int macAddress = line.find("HWaddr");
if(macAddress == -1)
macAddress = line.length();
if(hardwareName != -1)
- i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)));
+ i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
// We have found an interface
//qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
}
}
file.close();
QFile::remove(fileName);
}
void MainWindowImp::updateInterface(Interface *i){
QListViewItem *item = NULL;
// See if we already have it
if(items.find(i) == items.end()){
item = new QListViewItem(serviceList, "", "", "");
diff --git a/noncore/net/networksetup/mainwindowimp.h b/noncore/net/networksetup/mainwindowimp.h
index 95ec2a1..0618dd2 100644
--- a/noncore/net/networksetup/mainwindowimp.h
+++ b/noncore/net/networksetup/mainwindowimp.h
@@ -1,26 +1,27 @@
#ifndef MAINWINOWIMP_H
#define MAINWINOWIMP_H
#include "mainwindow.h"
-#include "module.h"
-#include "interface.h"
-#include "kprocess.h"
#include <qmap.h>
+#include <qstringlist.h>
+class Module;
+class Interface;
class QLibrary;
+class KProcess;
class MainWindowImp : public MainWindow {
Q_OBJECT
public:
MainWindowImp(QWidget *parent=0, const char *name=0);
~MainWindowImp();
private slots:
void addClicked();
void removeClicked();
void configureClicked();
void informationClicked();
void jobDone(KProcess *process);
void getInterfaceList();
@@ -32,22 +33,24 @@ private slots:
private:
void loadModules(QString path);
Module* loadPlugin(QString pluginFileName,
QString resolveString = "create_plugin");
// For our local list of names
QMap<QString, Interface*> interfaceNames;
QMap<Module*, QLibrary*> libraries;
QMap<Interface*, Module*> modules;
QMap<Interface*, QListViewItem*> items;
QMap<QListViewItem*, Interface*> interfaceItems;
QMap<KProcess*, QString> threads;
+ QStringList profiles;
+
};
#endif
// mainwindowimp.h
diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp
index b9b09ad..f6eed00 100644
--- a/noncore/settings/networksettings/interface.cpp
+++ b/noncore/settings/networksettings/interface.cpp
@@ -182,33 +182,33 @@ bool Interface::refresh(){
// Get the start running time of the deamon
fileName = (QString("/proc/%1/stat").arg(pid));
file.setName(fileName);
stream.setDevice( &file );
if (!file.open(IO_ReadOnly)){
qDebug(QString("Interface: Can't open file: %1").arg(fileName).latin1());
return false;
}
while ( !stream.eof() ) {
line = stream.readLine();
}
file.close();
long time = 0;
// Grab the start time
// pid com state ppid pgrp session tty_nr tpgid flags
- int r = sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
+ sscanf(line.latin1(), "%*d %*s %*c %*d %*d %*d %*d %*d %*u "
// minflt cminflt majflt cmajflt utime stime cutime cstime priority
"%*u %*u %*u %*u %*u %*u %*d %*d %*d "
// nice 0 itrealvalue starttime
"%*d %*d %*d %lu", (long*) &time);
time = time/100;
QDateTime datetime(QDateTime::currentDateTime());
// Get the uptime of the computer.
QFile f("/proc/uptime");
if ( f.open(IO_ReadOnly) ) { // file opened successfully
QTextStream t( &f ); // use a text stream
int sec = 0;
t >> sec;
datetime = datetime.addSecs((-1*sec));
f.close();
diff --git a/noncore/settings/networksettings/interfaceinformationimp.h b/noncore/settings/networksettings/interfaceinformationimp.h
index 6fc2384..c8a478e 100644
--- a/noncore/settings/networksettings/interfaceinformationimp.h
+++ b/noncore/settings/networksettings/interfaceinformationimp.h
@@ -5,27 +5,27 @@
#include "interface.h"
class InterfaceInformationImp : public InterfaceInformation {
Q_OBJECT
public:
InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0);
~InterfaceInformationImp(){};
private slots:
void start();
void stop();
void refresh();
void restart();
void advanced();
- Interface *interface;
private:
+ Interface *interface;
void updateInterface();
};
#endif
// addserviceimp.h
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 3c13143..ad9362f 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,20 +1,23 @@
#include "mainwindowimp.h"
#include "addserviceimp.h"
#include "interfaceinformationimp.h"
#include "interfacesetupimp.h"
+#include "interface.h"
+#include "kprocess.h"
+#include "module.h"
#include <qpushbutton.h>
#include <qdir.h>
#include <qtabwidget.h>
#include <qmainwindow.h>
#include <qmessagebox.h>
#include <qlistbox.h>
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
#include <qlist.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qlistview.h>
#include <qheader.h>
@@ -37,38 +40,46 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
// Make sure we have a plugin directory to scan.
QString DirStr = QDir::homeDirPath() + "/.networksetup/" ;
QDir pluginDir( DirStr );
pluginDir.mkdir( DirStr );
pluginDir.mkdir( ( DirStr + "plugins/" ) );
QString path = DirStr + "plugins";
pluginDir.setPath(path);
if(!pluginDir.exists()){
qDebug(QString("MainWindowImp: ERROR: %1 %2").arg(__FILE__).arg(__LINE__).latin1());
return;
}
// Load any saved services.
loadModules(path);
getInterfaceList();
serviceList->header()->hide();
+
+
+ Config cfg("NetworkSetup");
+ profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
}
/**
- * Deconstructor. Unload libraries and save.
+ * Deconstructor. Unload libraries and save profile list.
*/
MainWindowImp::~MainWindowImp(){
+ if(profiles.count() > 1){
+ Config cfg("NetworkSetup");
+ cfg.writeEntry("Profiles", profiles.join(" "));
+ }
}
void MainWindowImp::loadModules(QString path){
}
/**
* Attempt to load a function and resolve a function.
* @param pluginFileName - the name of the file in which to attempt to load
* @param resolveString - function pointer to resolve
* @return pointer to the function with name resolveString or NULL
*/
Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
//qDebug(pluginFileName.latin1());
QLibrary *lib = new QLibrary(pluginFileName);
void *functionPointer = lib->resolve(resolveString);
if( !functionPointer ){
@@ -239,33 +250,33 @@ void MainWindowImp::jobDone(KProcess *process){
}
else{
i = interfaceNames[interfaceName];
if(fileName != TEMP_ALL)
i->setStatus(true);
}
i->setAttached(true);
i->setInterfaceName(interfaceName);
QString hardName = "Ethernet";
int hardwareName = line.find("Link encap:");
int macAddress = line.find("HWaddr");
if(macAddress == -1)
macAddress = line.length();
if(hardwareName != -1)
- i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)));
+ i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) + QString(" (%1)").arg(i->getInterfaceName()));
// We have found an interface
//qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1());
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
}
}
file.close();
QFile::remove(fileName);
}
void MainWindowImp::updateInterface(Interface *i){
QListViewItem *item = NULL;
// See if we already have it
if(items.find(i) == items.end()){
item = new QListViewItem(serviceList, "", "", "");
diff --git a/noncore/settings/networksettings/mainwindowimp.h b/noncore/settings/networksettings/mainwindowimp.h
index 95ec2a1..0618dd2 100644
--- a/noncore/settings/networksettings/mainwindowimp.h
+++ b/noncore/settings/networksettings/mainwindowimp.h
@@ -1,26 +1,27 @@
#ifndef MAINWINOWIMP_H
#define MAINWINOWIMP_H
#include "mainwindow.h"
-#include "module.h"
-#include "interface.h"
-#include "kprocess.h"
#include <qmap.h>
+#include <qstringlist.h>
+class Module;
+class Interface;
class QLibrary;
+class KProcess;
class MainWindowImp : public MainWindow {
Q_OBJECT
public:
MainWindowImp(QWidget *parent=0, const char *name=0);
~MainWindowImp();
private slots:
void addClicked();
void removeClicked();
void configureClicked();
void informationClicked();
void jobDone(KProcess *process);
void getInterfaceList();
@@ -32,22 +33,24 @@ private slots:
private:
void loadModules(QString path);
Module* loadPlugin(QString pluginFileName,
QString resolveString = "create_plugin");
// For our local list of names
QMap<QString, Interface*> interfaceNames;
QMap<Module*, QLibrary*> libraries;
QMap<Interface*, Module*> modules;
QMap<Interface*, QListViewItem*> items;
QMap<QListViewItem*, Interface*> interfaceItems;
QMap<KProcess*, QString> threads;
+ QStringList profiles;
+
};
#endif
// mainwindowimp.h