summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfaceinformationimp.h12
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.h12
-rw-r--r--noncore/settings/networksettings/module.h77
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp2
4 files changed, 88 insertions, 15 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.h b/noncore/settings/networksettings/interfaces/interfaceinformationimp.h
index 9c93d1d..03da736 100644
--- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.h
+++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.h
@@ -1,28 +1,32 @@
1#ifndef INTERFACEINFORMATIONIMP_H 1#ifndef INTERFACEINFORMATIONIMP_H
2#define INTERFACEINFORMATIONIMP_H 2#define INTERFACEINFORMATIONIMP_H
3 3
4#include "interfaceinformation.h" 4#include "interfaceinformation.h"
5#include "interface.h" 5#include "interface.h"
6 6
7/**
8 * This widget just shows some generic information about the
9 * given Interface. IP Addresses and such will be shown.
10 */
7class InterfaceInformationImp : public InterfaceInformation { 11class InterfaceInformationImp : public InterfaceInformation {
8 12
9Q_OBJECT 13Q_OBJECT
10 14
11public: 15public:
12 InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0); 16 InterfaceInformationImp(QWidget *parent=0, const char *name=0, Interface *i=0, WFlags f=0);
13 ~InterfaceInformationImp(); 17 ~InterfaceInformationImp();
14 18
15private slots: 19private slots:
16 void advanced(); 20 void advanced();
17 void updateInterface(Interface *i); 21 void updateInterface(Interface *i);
18 void showMessage(const QString &message); 22 void showMessage(const QString &message);
19 23
20private: 24private:
21 Interface *interface; 25 Interface *interface;
22 26
23}; 27};
24 28
25#endif 29#endif
26 30
27// addserviceimp.h 31// addserviceimp.h
28 32
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.h b/noncore/settings/networksettings/interfaces/interfacesetupimp.h
index 172da6a..f38fba5 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.h
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.h
@@ -1,58 +1,64 @@
1#ifndef INTERFACESETUPIMP_H 1#ifndef INTERFACESETUPIMP_H
2#define INTERFACESETUPIMP_H 2#define INTERFACESETUPIMP_H
3 3
4#include "interfacesetup.h" 4#include "interfacesetup.h"
5#include "interfaces.h" 5#include "interfaces.h"
6#include <qdialog.h> 6#include <qdialog.h>
7 7
8class Interface; 8class Interface;
9 9
10/**
11 * A default implementation for setting up basic
12 * network config. Like DHCP, IP and other information.
13 * You can use it in a tab or in any other way*
14 * On saveChanges() it'll save the changes to Interfaces.
15 */
10class InterfaceSetupImp : public InterfaceSetup { 16class InterfaceSetupImp : public InterfaceSetup {
11 Q_OBJECT 17 Q_OBJECT
12 18
13public: 19public:
14 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i = 0, Interfaces *j = 0, WFlags fl = 0); 20 InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i = 0, Interfaces *j = 0, WFlags fl = 0);
15 ~InterfaceSetupImp(); 21 ~InterfaceSetupImp();
16 bool saveChanges(); 22 bool saveChanges();
17 23
18public slots: 24public slots:
19 void setProfile(const QString &profile); 25 void setProfile(const QString &profile);
20 bool saveSettings(); 26 bool saveSettings();
21 27
22private: 28private:
23 Interfaces *interfaces; 29 Interfaces *interfaces;
24 Interface *interface; 30 Interface *interface;
25 31
26 bool delInterfaces; 32 bool delInterfaces;
27}; 33};
28 34
29 35
30#include <qlayout.h> 36#include <qlayout.h>
31 37
32class InterfaceSetupImpDialog : public QDialog { 38class InterfaceSetupImpDialog : public QDialog {
33Q_OBJECT 39Q_OBJECT
34 40
35public: 41public:
36 InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){ 42 InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){
37 QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this ); 43 QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this );
38 setCaption("Interface Setup"); 44 setCaption("Interface Setup");
39 interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i); 45 interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i);
40 InterfaceSetupLayout->addWidget( interfaceSetup ); 46 InterfaceSetupLayout->addWidget( interfaceSetup );
41 }; 47 };
42 void setProfile(QString &profile){ interfaceSetup->setProfile(profile);}; 48 void setProfile(QString &profile){ interfaceSetup->setProfile(profile);};
43 49
44private: 50private:
45 InterfaceSetupImp *interfaceSetup; 51 InterfaceSetupImp *interfaceSetup;
46 52
47protected slots: 53protected slots:
48 void accept(){ 54 void accept(){
49 if(interfaceSetup->saveChanges()) 55 if(interfaceSetup->saveChanges())
50 QDialog::accept(); 56 QDialog::accept();
51 }; 57 };
52 58
53}; 59};
54 60
55#endif 61#endif
56 62
57// interfacesetupimp.h 63// interfacesetupimp.h
58 64
diff --git a/noncore/settings/networksettings/module.h b/noncore/settings/networksettings/module.h
index 5cc82cd..3ef823c 100644
--- a/noncore/settings/networksettings/module.h
+++ b/noncore/settings/networksettings/module.h
@@ -1,113 +1,176 @@
1#ifndef NETCONF_MODULE_H 1#ifndef NETCONF_MODULE_H
2#define NETCONF_MODULE_H 2#define NETCONF_MODULE_H
3 3
4#include <qobject.h> 4#include <qobject.h>
5#if QT_VERSION < 300 5#if QT_VERSION < 300
6#include <qlist.h> 6#include <qlist.h>
7#else 7#else
8#include <qptrlist.h> 8#include <qptrlist.h>
9#endif 9#endif
10#include <qmap.h> 10#include <qmap.h>
11#include "interface.h" 11#include "interface.h"
12 12
13class QWidget; 13class QWidget;
14class QTabWidget; 14class QTabWidget;
15 15
16class Module : QObject{ 16
17/**
18 * \brief The basis of all plugins
19 *
20 * This is the way to extend networksettings with
21 * extra functionality.
22 *
23 *
24 * Networksettings in the 1.0 release does not use QCOM
25 * for activation. You need to provide the following function yourself.
26 *
27 * A module needs to provide Name, Images, and methods for
28 * claiming interfaces. For example you can claim physicla
29 * interfaces like wlan0, ppp0 or virtual like a VPN
30 * connection and hide the real ppp device or ethernet device
31 * behind your VPN plugin.
32 *
33 * During start up. The main application searches for network devices
34 * and then looks for an owner under the plugins for them.
35 * For example the WLAN Plugin looks if there is a WLAN Extension
36 * on that interface and then claims it by returning true from isOwner()
37 *
38 * \code
39 * extern "C"
40 * {
41 * void* create_plugin() {
42 * return new WLANModule();
43 * }
44 * };
45 * \endcode
46 * @see isOwner(Interface*)
47 */
48class Module : private QObject{
17 49
18signals: 50signals:
51/**
52 * Emit this Signal once you change the Interface
53 * you're operating on
54 *
55 * @param i The Interface
56 */
19 void updateInterface(Interface *i); 57 void updateInterface(Interface *i);
20 58
21 59
22public: 60public:
23 Module(){}; 61 Module(){};
24 62
25 /** 63 /**
26 * The type of the plugin 64 * The type of the plugin
27 * and the name of the dcop call 65 * and the name of the qcop call
28 */ 66 */
29 virtual const QString type() = 0; 67 virtual const QString type() = 0;
30 68
31 /** 69 /**
32 * The current profile has been changed and the module should do any 70 * The current profile has been changed and the module should do any
33 * neccesary changes also. 71 * neccesary changes also.
72 * As of Opie1.0 profiles are disabled.
73 *
34 * @param newProfile what the profile should be changed to. 74 * @param newProfile what the profile should be changed to.
35 */ 75 */
36 virtual void setProfile(const QString &newProfile) = 0; 76 virtual void setProfile(const QString &newProfile) = 0;
37 77
38 /** 78 /**
39 * get the icon name for this device. 79 * get the icon name for this device.
40 * @param Interface* can be used in determining the icon. 80 * @param Interface* can be used in determining the icon.
41 * @return QString the icon name (minus .png, .gif etc) 81 * @return QString the icon name (minus .png, .gif etc)
42 */ 82 */
43 virtual QString getPixmapName(Interface *) = 0; 83 virtual QString getPixmapName(Interface *) = 0;
44 84
45 /** 85 /**
46 * Check to see if the interface i is owned by this module. 86 * Check to see if the interface i is owned by this module.
87 * See if you can handle it. And if you can claim ownership
88 * by returning true.
47 * @param Interface* interface to check against 89 * @param Interface* interface to check against
48 * @return bool true if i is owned by this module, false otherwise. 90 * @return bool true if i is owned by this module, false otherwise.
49 */ 91 */
50 virtual bool isOwner(Interface *){ return false; }; 92 virtual bool isOwner(Interface *){ return false; };
51 93
52 /** 94 /**
53 * Create and return the WLANConfigure Module 95 * Create and return the Configure Module
54 * @param Interface *i the interface to configure. 96 * @param Interface *i the interface to configure.
55 * @return QWidget* pointer to this modules configure. 97 * @return QWidget* pointer to this modules configure.
98 *
99 * @see InterfaceSetupImp
56 */ 100 */
57 virtual QWidget *configure(Interface *){ return NULL; } ; 101 virtual QWidget *configure(Interface *){ return NULL; } ;
58 102
59 /** 103 /**
60 * Create, and return the Information Module 104 * Create, and return the Information Module.
105 *
106 * An default Implementation is InterfaceInformationImp
107 *
61 * @param Interface *i the interface to get info on. 108 * @param Interface *i the interface to get info on.
62 * @return QWidget* pointer to this modules info. 109 * @return QWidget* pointer to this modules info.
110 *
111 * @see InterfaceInformationImp
112 *
63 */ 113 */
64 virtual QWidget *information(Interface *){ return NULL; }; 114 virtual QWidget *information(Interface *){ return NULL; };
65 115
66 /** 116 /**
67 * Get all active (up or down) interfaces 117 * Get all active (up or down) interfaces managed by this
118 * module.
68 * @return QList<Interface> A list of interfaces that exsist that havn't 119 * @return QList<Interface> A list of interfaces that exsist that havn't
69 * been called by isOwner() 120 * been called by isOwner()
70 */ 121 */
71 virtual QList<Interface> getInterfaces() = 0; 122 virtual QList<Interface> getInterfaces() = 0;
72 123
73 /** 124 /**
74 * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp), 125 * Adds possible new interfaces to the list (Example: usb(ppp), ir(ppp),
75 * modem ppp) 126 * modem ppp)
127 * Both strings need to be translated. The first string is a Shortcut
128 * like PPP and the second argument is a description.
129 *
130 * <code>
131 * list.insert(
132 *
133 * </code>
134 *
135 * @param list A reference to the list of supported additionns.
76 */ 136 */
77 virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0; 137 virtual void possibleNewInterfaces(QMap<QString, QString> &list) = 0;
78 138
79 /** 139 /**
80 * Attempts to create a new interface from name 140 * Attempts to create a new interface from name you gave
141 * possibleNewInterfaces()
81 * @return Interface* NULL if it was unable to be created. 142 * @return Interface* NULL if it was unable to be created.
82 * @param name the type of interface to create 143 * @param name the type of interface to create
144 *
145 * @see possibleNewInterfaces
83 */ 146 */
84 virtual Interface *addNewInterface(const QString &name) = 0; 147 virtual Interface *addNewInterface(const QString &name) = 0;
85 148
86 /** 149 /**
87 * Attempts to remove the interface, doesn't delete i 150 * Attempts to remove the interface, doesn't delete i
88 * @return bool true if successful, false otherwise. 151 * @return bool true if successful, false otherwise.
89 */ 152 */
90 virtual bool remove(Interface* i) = 0; 153 virtual bool remove(Interface* i) = 0;
91 154
92 /** 155 /**
93 * get dcop calls 156 * get dcop calls
94 */ 157 */
95 virtual void receive(const QCString &msg, const QByteArray &arg) = 0; 158 virtual void receive(const QCString &msg, const QByteArray &arg) = 0;
96 159
97 QStringList handledInterfaceNames()const { return m_inter; } 160 QStringList handledInterfaceNames()const { return m_inter; }
98protected: 161protected:
99 /** 162 /**
100 * set which interfaceNames should not be shown cause they're handled 163 * set which interfaceNames should not be shown cause they're handled
101 * internally of this module.. An already running ppp link or 164 * internally of this module.. An already running ppp link or
102 * a tunnel... 165 * a tunnel... VPN an such
103 */ 166 */
104 void setHandledInterfaceNames( const QStringList& in) { m_inter = in; } 167 void setHandledInterfaceNames( const QStringList& in) { m_inter = in; }
105 168
106private: 169private:
107 QStringList m_inter; 170 QStringList m_inter;
108}; 171};
109 172
110#endif 173#endif
111 174
112// module.h 175// module.h
113 176
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index 2462fa4..f7dacf6 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -2,249 +2,249 @@
2#include <signal.h> 2#include <signal.h>
3 3
4 4
5#include <qpe/config.h> 5#include <qpe/config.h>
6 6
7#include "modem.h" 7#include "modem.h"
8#include "pppconfig.h" 8#include "pppconfig.h"
9#include "pppmodule.h" 9#include "pppmodule.h"
10#include "pppdata.h" 10#include "pppdata.h"
11#include "interfaceinformationppp.h" 11#include "interfaceinformationppp.h"
12#include "interfaceppp.h" 12#include "interfaceppp.h"
13 13
14// don't polute global namespace 14// don't polute global namespace
15namespace { 15namespace {
16 /* 16 /*
17 * If network settings is qutting and we've ppp 17 * If network settings is qutting and we've ppp
18 * devices open we need to save the pid_t the PPData 18 * devices open we need to save the pid_t the PPData
19 * and the interface number 19 * and the interface number
20 */ 20 */
21 struct Connection { 21 struct Connection {
22 pid_t pid; 22 pid_t pid;
23 QString device; 23 QString device;
24 QString name; 24 QString name;
25 }; 25 };
26 class InterfaceKeeper { 26 class InterfaceKeeper {
27 public: 27 public:
28 InterfaceKeeper(); 28 InterfaceKeeper();
29 ~InterfaceKeeper(); 29 ~InterfaceKeeper();
30 30
31 void addInterface( pid_t, const QString& pppDev, const QString& name ); 31 void addInterface( pid_t, const QString& pppDev, const QString& name );
32 QMap<QString, Connection> interfaces()const; // will check if still available 32 QMap<QString, Connection> interfaces()const; // will check if still available
33 private: 33 private:
34 bool isAvailable( pid_t )const; 34 bool isAvailable( pid_t )const;
35 QMap<QString, Connection> m_interfaces; 35 QMap<QString, Connection> m_interfaces;
36 }; 36 };
37} 37}
38 38
39 39
40/** 40/**
41 * Constructor, find all of the possible interfaces 41 * Constructor, find all of the possible interfaces
42 * We also need to restore the state.. it could be that 42 * We also need to restore the state.. it could be that
43 * an interface was up while closing the application 43 * an interface was up while closing the application
44 * we need to be able to shut it down... 44 * we need to be able to shut it down...
45 */ 45 */
46PPPModule::PPPModule() : Module() 46PPPModule::PPPModule() : Module()
47{ 47{
48 InterfaceKeeper inFace; 48 InterfaceKeeper inFace;
49 QMap<QString,Connection> running = inFace.interfaces(); 49 QMap<QString,Connection> running = inFace.interfaces();
50 QStringList handledInterfaceNames; 50 QStringList handledInterfaceNames;
51 51
52 QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); 52 QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces();
53 QMap<QString,QString>::Iterator it; 53 QMap<QString,QString>::Iterator it;
54 InterfacePPP *iface; 54 InterfacePPP *iface;
55 qDebug("getting interfaces"); 55 qDebug("getting interfaces");
56 for( it = ifaces.begin(); it != ifaces.end(); ++it ){ 56 for( it = ifaces.begin(); it != ifaces.end(); ++it ){
57 qDebug("ifaces %s %s", it.key().latin1(), it.data().latin1() ); 57 qDebug("ifaces %s %s", it.key().latin1(), it.data().latin1() );
58 iface = new InterfacePPP( 0, it.key() ); 58 iface = new InterfacePPP( 0, it.key() );
59 iface->setHardwareName( it.data() ); 59 iface->setHardwareName( it.data() );
60 list.append( (Interface*)iface ); 60 list.append( (Interface*)iface );
61 61
62 // check if (*it) is one of the running ifaces 62 // check if (*it) is one of the running ifaces
63 if ( running.contains( it.data() ) ) { 63 if ( running.contains( it.data() ) ) {
64 qDebug("iface is running %s", it.key().latin1() ); 64 qDebug("iface is running %s", it.key().latin1() );
65 handledInterfaceNames << running[it.data()].device; 65 handledInterfaceNames << running[it.data()].device;
66 iface->setStatus( true ); 66 iface->setStatus( true );
67 iface->setPPPDpid( running[it.data()].pid ); 67 iface->setPPPDpid( running[it.data()].pid );
68 iface->modem()->setPPPDevice( running[it.data()].device ); 68 iface->modem()->setPPPDevice( running[it.data()].device );
69 iface->refresh(); 69 iface->refresh();
70 } 70 }
71 } 71 }
72 72
73 setHandledInterfaceNames( handledInterfaceNames ); 73 setHandledInterfaceNames( handledInterfaceNames );
74} 74}
75 75
76/** 76/**
77 * Delete any interfaces that we own. 77 * Delete any interfaces that we own.
78 */ 78 */
79PPPModule::~PPPModule(){ 79PPPModule::~PPPModule(){
80 qDebug("PPPModule::~PPPModule() " ); 80 qDebug("PPPModule::~PPPModule() " );
81 QMap<QString,QString> ifaces; 81 QMap<QString,QString> ifaces;
82 InterfaceKeeper keeper; 82 InterfaceKeeper keeper;
83 Interface *i; 83 Interface *i;
84 for ( i=list.first(); i != 0; i=list.next() ){ 84 for ( i=list.first(); i != 0; i=list.next() ){
85 /* if online save the state */ 85 /* if online save the state */
86 if ( i->getStatus() ) { 86 if ( i->getStatus() ) {
87 qDebug("Iface %s is still up", i->getHardwareName().latin1() ); 87 qDebug("Iface %s is still up", i->getHardwareName().latin1() );
88 InterfacePPP* ppp = static_cast<InterfacePPP*>(i); 88 InterfacePPP* ppp = static_cast<InterfacePPP*>(i);
89 keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); 89 keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() );
90 } 90 }
91 ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); 91 ifaces.insert( i->getInterfaceName(), i->getHardwareName() );
92 delete i; 92 delete i;
93 } 93 }
94 PPPData::setConfiguredInterfaces( ifaces ); 94 PPPData::setConfiguredInterfaces( ifaces );
95} 95}
96 96
97/** 97/**
98 * Change the current profile 98 * Change the current profile
99 */ 99 */
100void PPPModule::setProfile(const QString &newProfile){ 100void PPPModule::setProfile(const QString &newProfile){
101 profile = newProfile; 101 profile = newProfile;
102} 102}
103 103
104/** 104/**
105 * get the icon name for this device. 105 * get the icon name for this device.
106 * @param Interface* can be used in determining the icon. 106 * @param Interface* can be used in determining the icon.
107 * @return QString the icon name (minus .png, .gif etc) 107 * @return QString the icon name (minus .png, .gif etc)
108 */ 108 */
109QString PPPModule::getPixmapName(Interface* ){ 109QString PPPModule::getPixmapName(Interface* ){
110 return "ppp"; 110 return "ppp";
111} 111}
112 112
113/** 113/**
114 * Check to see if the interface i is owned by this module. 114 * Check to see if the interface i is owned by this module.
115 * @param Interface* interface to check against 115 * @param Interface* interface to check against
116 * @return bool true if i is owned by this module, false otherwise. 116 * @return bool true if i is owned by this module, false otherwise.
117 */ 117 */
118bool PPPModule::isOwner(Interface *i){ 118bool PPPModule::isOwner(Interface *i){
119 return list.find( i ) != -1; 119 return list.find( i ) != -1;
120} 120}
121 121
122/** 122/**
123 * Create, and return the WLANConfigure Module 123 * Create, and return the WLANConfigure Module
124 * @return QWidget* pointer to this modules configure. 124 * @return QWidget* pointer to this modules configure.
125 */ 125 */
126QWidget *PPPModule::configure(Interface *i){ 126QWidget *PPPModule::configure(Interface *i){
127 qDebug("return ModemWidget"); 127 qDebug("return ModemWidget");
128 PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, 128 PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i,
129 0, "PPPConfig", false, 129 0, "PPPConfig", false,
130 Qt::WDestructiveClose | Qt::WStyle_ContextHelp); 130 (Qt::WDestructiveClose | Qt::WStyle_ContextHelp));
131 return pppconfig; 131 return pppconfig;
132} 132}
133 133
134/** 134/**
135 * Create, and return the Information Module 135 * Create, and return the Information Module
136 * @return QWidget* pointer to this modules info. 136 * @return QWidget* pointer to this modules info.
137 */ 137 */
138QWidget *PPPModule::information(Interface *i){ 138QWidget *PPPModule::information(Interface *i){
139 // We don't have any advanced pppd information widget yet :-D 139 // We don't have any advanced pppd information widget yet :-D
140 // TODO ^ 140 // TODO ^
141 141
142 return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); 142 return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i );
143} 143}
144 144
145/** 145/**
146 * Get all active (up or down) interfaces 146 * Get all active (up or down) interfaces
147 * @return QList<Interface> A list of interfaces that exsist that havn't 147 * @return QList<Interface> A list of interfaces that exsist that havn't
148 * been called by isOwner() 148 * been called by isOwner()
149 */ 149 */
150QList<Interface> PPPModule::getInterfaces(){ 150QList<Interface> PPPModule::getInterfaces(){
151 // List all of the files in the peer directory 151 // List all of the files in the peer directory
152 qDebug("PPPModule::getInterfaces"); 152 qDebug("PPPModule::getInterfaces");
153 return list; 153 return list;
154} 154}
155 155
156/** 156/**
157 * Attempt to add a new interface as defined by name 157 * Attempt to add a new interface as defined by name
158 * @param name the name of the type of interface that should be created given 158 * @param name the name of the type of interface that should be created given
159 * by possibleNewInterfaces(); 159 * by possibleNewInterfaces();
160 * @return Interface* NULL if it was unable to be created. 160 * @return Interface* NULL if it was unable to be created.
161 */ 161 */
162Interface *PPPModule::addNewInterface(const QString &newInterface){ 162Interface *PPPModule::addNewInterface(const QString &newInterface){
163 163
164 InterfacePPP *ifaceppp; 164 InterfacePPP *ifaceppp;
165 Interface *iface; 165 Interface *iface;
166 ifaceppp = new InterfacePPP(); 166 ifaceppp = new InterfacePPP();
167 PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); 167 PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true);
168 imp.showMaximized(); 168 imp.showMaximized();
169 if(imp.exec() == QDialog::Accepted ){ 169 if(imp.exec() == QDialog::Accepted ){
170 iface = (InterfacePPP*) ifaceppp; 170 iface = (InterfacePPP*) ifaceppp;
171 iface->setModuleOwner( this ); 171 iface->setModuleOwner( this );
172 list.append( iface ); 172 list.append( iface );
173 return iface; 173 return iface;
174 }else { 174 }else {
175 delete ifaceppp; 175 delete ifaceppp;
176 iface = NULL; 176 iface = NULL;
177 } 177 }
178 return iface; 178 return iface;
179} 179}
180 180
181/** 181/**
182 * Attempts to remove the interface, doesn't delete i 182 * Attempts to remove the interface, doesn't delete i
183 * @return bool true if successful, false otherwise. 183 * @return bool true if successful, false otherwise.
184 */ 184 */
185bool PPPModule::remove(Interface *i){ 185bool PPPModule::remove(Interface *i){
186 return list.remove(i); 186 return list.remove(i);
187} 187}
188 188
189void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) 189void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces)
190{ 190{
191 newIfaces.insert(QObject::tr("PPP") , 191 newIfaces.insert(QObject::tr("PPP") ,
192 QObject::tr("generic ppp device")); 192 QObject::tr("generic ppp device"));
193} 193}
194 194
195 195
196 196
197namespace { 197namespace {
198 InterfaceKeeper::InterfaceKeeper( ) { 198 InterfaceKeeper::InterfaceKeeper( ) {
199 } 199 }
200 InterfaceKeeper::~InterfaceKeeper() { 200 InterfaceKeeper::~InterfaceKeeper() {
201 Config cfg("ppp_plugin_keeper"); 201 Config cfg("ppp_plugin_keeper");
202 QStringList lst = cfg.groupList(); 202 QStringList lst = cfg.groupList();
203 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { 203 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
204 Connection con; 204 Connection con;
205 cfg.setGroup( (*it) ); 205 cfg.setGroup( (*it) );
206 cfg.clearGroup(); 206 cfg.clearGroup();
207 } 207 }
208 208
209 for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it ) { 209 for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it ) {
210 Connection con = it.data(); 210 Connection con = it.data();
211 cfg.setGroup( con.name ); 211 cfg.setGroup( con.name );
212 cfg.writeEntry( "pid", con.pid ); 212 cfg.writeEntry( "pid", con.pid );
213 cfg.writeEntry( "device", con.device ); 213 cfg.writeEntry( "device", con.device );
214 } 214 }
215 } 215 }
216 void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) { 216 void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) {
217 Connection con; 217 Connection con;
218 con.pid = pid; 218 con.pid = pid;
219 con.device = dev; 219 con.device = dev;
220 con.name = name; 220 con.name = name;
221 m_interfaces.insert( name, con ); 221 m_interfaces.insert( name, con );
222 } 222 }
223 QMap<QString, Connection> InterfaceKeeper::interfaces()const { 223 QMap<QString, Connection> InterfaceKeeper::interfaces()const {
224 Config cfg("ppp_plugin_keeper"); 224 Config cfg("ppp_plugin_keeper");
225 QMap<QString, Connection> ifaces; 225 QMap<QString, Connection> ifaces;
226 QStringList lst = cfg.groupList(); 226 QStringList lst = cfg.groupList();
227 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { 227 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
228 Connection con; 228 Connection con;
229 cfg.setGroup( (*it) ); 229 cfg.setGroup( (*it) );
230 con.name = (*it); 230 con.name = (*it);
231 con.pid = cfg.readNumEntry("pid"); 231 con.pid = cfg.readNumEntry("pid");
232 con.device = cfg.readEntry("device"); 232 con.device = cfg.readEntry("device");
233 qDebug(" %s %s %d", con.name.latin1(), con.device.latin1(), con.pid ); 233 qDebug(" %s %s %d", con.name.latin1(), con.device.latin1(), con.pid );
234 234
235 if ( con.pid != -1 && isAvailable( con.pid ) ) 235 if ( con.pid != -1 && isAvailable( con.pid ) )
236 ifaces.insert( con.name, con ); 236 ifaces.insert( con.name, con );
237 } 237 }
238 return ifaces; 238 return ifaces;
239 } 239 }
240 bool InterfaceKeeper::isAvailable( pid_t p)const { 240 bool InterfaceKeeper::isAvailable( pid_t p)const {
241 if (::kill(p, 0 ) == 0 || errno != ESRCH ) { 241 if (::kill(p, 0 ) == 0 || errno != ESRCH ) {
242 qDebug("isAvailable %d", p); 242 qDebug("isAvailable %d", p);
243 return true; 243 return true;
244 } 244 }
245 245
246 qDebug("notAvailable %d", p); 246 qDebug("notAvailable %d", p);
247 return false; 247 return false;
248 } 248 }
249 249
250} 250}