Diffstat (limited to 'noncore/settings/networksettings/ppp/pppmodule.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/pppmodule.cpp | 103 |
1 files changed, 68 insertions, 35 deletions
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index f7dacf6..a7caffe 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp | |||
@@ -1,6 +1 @@ | |||
1 | #include <errno.h> | ||
2 | #include <signal.h> | ||
3 | |||
4 | |||
5 | #include <qpe/config.h> | ||
6 | |||
@@ -13,4 +8,15 @@ | |||
13 | 8 | ||
9 | /* OPIE */ | ||
10 | #include <qpe/config.h> | ||
11 | #include <qpe/qpeapplication.h> | ||
12 | |||
13 | /* QT */ | ||
14 | |||
15 | /* STD */ | ||
16 | #include <errno.h> | ||
17 | #include <signal.h> | ||
18 | |||
14 | // don't polute global namespace | 19 | // don't polute global namespace |
15 | namespace { | 20 | namespace |
21 | { | ||
16 | /* | 22 | /* |
@@ -20,3 +26,4 @@ namespace { | |||
20 | */ | 26 | */ |
21 | struct Connection { | 27 | struct Connection |
28 | { | ||
22 | pid_t pid; | 29 | pid_t pid; |
@@ -25,3 +32,4 @@ namespace { | |||
25 | }; | 32 | }; |
26 | class InterfaceKeeper { | 33 | class InterfaceKeeper |
34 | { | ||
27 | public: | 35 | public: |
@@ -55,3 +63,4 @@ PPPModule::PPPModule() : Module() | |||
55 | qDebug("getting interfaces"); | 63 | qDebug("getting interfaces"); |
56 | for( it = ifaces.begin(); it != ifaces.end(); ++it ){ | 64 | for( it = ifaces.begin(); it != ifaces.end(); ++it ) |
65 | { | ||
57 | qDebug("ifaces %s %s", it.key().latin1(), it.data().latin1() ); | 66 | qDebug("ifaces %s %s", it.key().latin1(), it.data().latin1() ); |
@@ -62,3 +71,4 @@ PPPModule::PPPModule() : Module() | |||
62 | // check if (*it) is one of the running ifaces | 71 | // check if (*it) is one of the running ifaces |
63 | if ( running.contains( it.data() ) ) { | 72 | if ( running.contains( it.data() ) ) |
73 | { | ||
64 | qDebug("iface is running %s", it.key().latin1() ); | 74 | qDebug("iface is running %s", it.key().latin1() ); |
@@ -78,3 +88,4 @@ PPPModule::PPPModule() : Module() | |||
78 | */ | 88 | */ |
79 | PPPModule::~PPPModule(){ | 89 | PPPModule::~PPPModule() |
90 | { | ||
80 | qDebug("PPPModule::~PPPModule() " ); | 91 | qDebug("PPPModule::~PPPModule() " ); |
@@ -83,5 +94,7 @@ PPPModule::~PPPModule(){ | |||
83 | Interface *i; | 94 | Interface *i; |
84 | for ( i=list.first(); i != 0; i=list.next() ){ | 95 | for ( i=list.first(); i != 0; i=list.next() ) |
96 | { | ||
85 | /* if online save the state */ | 97 | /* if online save the state */ |
86 | if ( i->getStatus() ) { | 98 | if ( i->getStatus() ) |
99 | { | ||
87 | qDebug("Iface %s is still up", i->getHardwareName().latin1() ); | 100 | qDebug("Iface %s is still up", i->getHardwareName().latin1() ); |
@@ -99,3 +112,4 @@ PPPModule::~PPPModule(){ | |||
99 | */ | 112 | */ |
100 | void PPPModule::setProfile(const QString &newProfile){ | 113 | void PPPModule::setProfile(const QString &newProfile) |
114 | { | ||
101 | profile = newProfile; | 115 | profile = newProfile; |
@@ -108,3 +122,4 @@ void PPPModule::setProfile(const QString &newProfile){ | |||
108 | */ | 122 | */ |
109 | QString PPPModule::getPixmapName(Interface* ){ | 123 | QString PPPModule::getPixmapName(Interface* ) |
124 | { | ||
110 | return "ppp"; | 125 | return "ppp"; |
@@ -117,3 +132,4 @@ QString PPPModule::getPixmapName(Interface* ){ | |||
117 | */ | 132 | */ |
118 | bool PPPModule::isOwner(Interface *i){ | 133 | bool PPPModule::isOwner(Interface *i) |
134 | { | ||
119 | return list.find( i ) != -1; | 135 | return list.find( i ) != -1; |
@@ -125,3 +141,4 @@ bool PPPModule::isOwner(Interface *i){ | |||
125 | */ | 141 | */ |
126 | QWidget *PPPModule::configure(Interface *i){ | 142 | QWidget *PPPModule::configure(Interface *i) |
143 | { | ||
127 | qDebug("return ModemWidget"); | 144 | qDebug("return ModemWidget"); |
@@ -137,3 +154,4 @@ QWidget *PPPModule::configure(Interface *i){ | |||
137 | */ | 154 | */ |
138 | QWidget *PPPModule::information(Interface *i){ | 155 | QWidget *PPPModule::information(Interface *i) |
156 | { | ||
139 | // We don't have any advanced pppd information widget yet :-D | 157 | // We don't have any advanced pppd information widget yet :-D |
@@ -149,3 +167,4 @@ QWidget *PPPModule::information(Interface *i){ | |||
149 | */ | 167 | */ |
150 | QList<Interface> PPPModule::getInterfaces(){ | 168 | QList<Interface> PPPModule::getInterfaces() |
169 | { | ||
151 | // List all of the files in the peer directory | 170 | // List all of the files in the peer directory |
@@ -161,3 +180,4 @@ QList<Interface> PPPModule::getInterfaces(){ | |||
161 | */ | 180 | */ |
162 | Interface *PPPModule::addNewInterface(const QString &newInterface){ | 181 | Interface *PPPModule::addNewInterface(const QString &newInterface) |
182 | { | ||
163 | 183 | ||
@@ -167,4 +187,5 @@ Interface *PPPModule::addNewInterface(const QString &newInterface){ | |||
167 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); | 187 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); |
168 | imp.showMaximized(); | 188 | |
169 | if(imp.exec() == QDialog::Accepted ){ | 189 | if( QPEApplication::execDialog( &imp ) == QDialog::Accepted ) |
190 | { | ||
170 | iface = (InterfacePPP*) ifaceppp; | 191 | iface = (InterfacePPP*) ifaceppp; |
@@ -173,3 +194,5 @@ Interface *PPPModule::addNewInterface(const QString &newInterface){ | |||
173 | return iface; | 194 | return iface; |
174 | }else { | 195 | } |
196 | else | ||
197 | { | ||
175 | delete ifaceppp; | 198 | delete ifaceppp; |
@@ -184,3 +207,4 @@ Interface *PPPModule::addNewInterface(const QString &newInterface){ | |||
184 | */ | 207 | */ |
185 | bool PPPModule::remove(Interface *i){ | 208 | bool PPPModule::remove(Interface *i) |
209 | { | ||
186 | return list.remove(i); | 210 | return list.remove(i); |
@@ -196,9 +220,12 @@ void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) | |||
196 | 220 | ||
197 | namespace { | 221 | namespace |
198 | InterfaceKeeper::InterfaceKeeper( ) { | 222 | { |
199 | } | 223 | InterfaceKeeper::InterfaceKeeper( ) |
200 | InterfaceKeeper::~InterfaceKeeper() { | 224 | {} |
225 | InterfaceKeeper::~InterfaceKeeper() | ||
226 | { | ||
201 | Config cfg("ppp_plugin_keeper"); | 227 | Config cfg("ppp_plugin_keeper"); |
202 | QStringList lst = cfg.groupList(); | 228 | QStringList lst = cfg.groupList(); |
203 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 229 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) |
230 | { | ||
204 | Connection con; | 231 | Connection con; |
@@ -208,3 +235,4 @@ namespace { | |||
208 | 235 | ||
209 | for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it ) { | 236 | for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it ) |
237 | { | ||
210 | Connection con = it.data(); | 238 | Connection con = it.data(); |
@@ -215,3 +243,4 @@ namespace { | |||
215 | } | 243 | } |
216 | void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) { | 244 | void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) |
245 | { | ||
217 | Connection con; | 246 | Connection con; |
@@ -222,3 +251,4 @@ namespace { | |||
222 | } | 251 | } |
223 | QMap<QString, Connection> InterfaceKeeper::interfaces()const { | 252 | QMap<QString, Connection> InterfaceKeeper::interfaces()const |
253 | { | ||
224 | Config cfg("ppp_plugin_keeper"); | 254 | Config cfg("ppp_plugin_keeper"); |
@@ -226,3 +256,4 @@ namespace { | |||
226 | QStringList lst = cfg.groupList(); | 256 | QStringList lst = cfg.groupList(); |
227 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { | 257 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) |
258 | { | ||
228 | Connection con; | 259 | Connection con; |
@@ -239,4 +270,6 @@ namespace { | |||
239 | } | 270 | } |
240 | bool InterfaceKeeper::isAvailable( pid_t p)const { | 271 | bool InterfaceKeeper::isAvailable( pid_t p)const |
241 | if (::kill(p, 0 ) == 0 || errno != ESRCH ) { | 272 | { |
273 | if (::kill(p, 0 ) == 0 || errno != ESRCH ) | ||
274 | { | ||
242 | qDebug("isAvailable %d", p); | 275 | qDebug("isAvailable %d", p); |