Diffstat (limited to 'noncore/settings/networksettings/ppp/pppmodule.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/pppmodule.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index fb279ee..dec0177 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp | |||
@@ -54,62 +54,62 @@ namespace | |||
54 | * an interface was up while closing the application | 54 | * an interface was up while closing the application |
55 | * we need to be able to shut it down... | 55 | * we need to be able to shut it down... |
56 | */ | 56 | */ |
57 | PPPModule::PPPModule() : Module() | 57 | PPPModule::PPPModule() : Module() |
58 | { | 58 | { |
59 | InterfaceKeeper inFace; | 59 | InterfaceKeeper inFace; |
60 | QMap<QString,Connection> running = inFace.interfaces(); | 60 | QMap<QString,Connection> running = inFace.interfaces(); |
61 | QStringList handledInterfaceNames; | 61 | QStringList handledInterfaceNames; |
62 | 62 | ||
63 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); | 63 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); |
64 | QMap<QString,QString>::Iterator it; | 64 | QMap<QString,QString>::Iterator it; |
65 | InterfacePPP *iface; | 65 | InterfacePPP *iface; |
66 | odebug << "getting interfaces" << oendl; | 66 | odebug << "getting interfaces" << oendl; |
67 | for( it = ifaces.begin(); it != ifaces.end(); ++it ) | 67 | for( it = ifaces.begin(); it != ifaces.end(); ++it ) |
68 | { | 68 | { |
69 | odebug << "ifaces " << it.key().latin1() << " " << it.data().latin1() << "" << oendl; | 69 | odebug << "ifaces " << it.key().latin1() << " " << it.data().latin1() << "" << oendl; |
70 | iface = new InterfacePPP( 0, it.key() ); | 70 | iface = new InterfacePPP( 0, it.key() ); |
71 | iface->setHardwareName( it.data() ); | 71 | iface->setHardwareName( it.data() ); |
72 | list.append( (Interface*)iface ); | 72 | list.append( (Interface*)iface ); |
73 | 73 | ||
74 | // check if (*it) is one of the running ifaces | 74 | // check if (*it) is one of the running ifaces |
75 | if ( running.contains( it.data() ) ) | 75 | if ( running.contains( it.data() ) ) |
76 | { | 76 | { |
77 | odebug << "iface is running " << it.key().latin1() << "" << oendl; | 77 | odebug << "iface is running " << it.key().latin1() << "" << oendl; |
78 | handledInterfaceNames << running[it.data()].device; | 78 | handledInterfaceNames << running[it.data()].device; |
79 | iface->setStatus( true ); | 79 | iface->setStatus( true ); |
80 | iface->setPPPDpid( running[it.data()].pid ); | 80 | iface->setPPPDpid( running[it.data()].pid ); |
81 | iface->modem()->setPPPDevice( running[it.data()].device ); | 81 | iface->modem()->setPPPDevice( running[it.data()].device ); |
82 | iface->refresh(); | 82 | iface->refresh(); |
83 | } | 83 | } |
84 | } | 84 | } |
85 | 85 | ||
86 | setHandledInterfaceNames( handledInterfaceNames ); | 86 | setHandledInterfaceNames( handledInterfaceNames ); |
87 | } | 87 | } |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Delete any interfaces that we own. | 90 | * Delete any interfaces that we own. |
91 | */ | 91 | */ |
92 | PPPModule::~PPPModule() | 92 | PPPModule::~PPPModule() |
93 | { | 93 | { |
94 | odebug << "PPPModule::~PPPModule() " << oendl; | 94 | odebug << "PPPModule::~PPPModule() " << oendl; |
95 | QMap<QString,QString> ifaces; | 95 | QMap<QString,QString> ifaces; |
96 | InterfaceKeeper keeper; | 96 | InterfaceKeeper keeper; |
97 | Interface *i; | 97 | Interface *i; |
98 | for ( i=list.first(); i != 0; i=list.next() ) | 98 | for ( i=list.first(); i != 0; i=list.next() ) |
99 | { | 99 | { |
100 | /* if online save the state */ | 100 | /* if online save the state */ |
101 | if ( i->getStatus() ) | 101 | if ( i->getStatus() ) |
102 | { | 102 | { |
103 | odebug << "Iface " << i->getHardwareName().latin1() << " is still up" << oendl; | 103 | odebug << "Iface " << i->getHardwareName().latin1() << " is still up" << oendl; |
104 | InterfacePPP* ppp = static_cast<InterfacePPP*>(i); | 104 | InterfacePPP* ppp = static_cast<InterfacePPP*>(i); |
105 | keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); | 105 | keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); |
106 | } | 106 | } |
107 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); | 107 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); |
108 | delete i; | 108 | delete i; |
109 | } | 109 | } |
110 | PPPData::setConfiguredInterfaces( ifaces ); | 110 | PPPData::setConfiguredInterfaces( ifaces ); |
111 | } | 111 | } |
112 | 112 | ||
113 | /** | 113 | /** |
114 | * Change the current profile | 114 | * Change the current profile |
115 | */ | 115 | */ |
@@ -135,25 +135,25 @@ QString PPPModule::getPixmapName(Interface* ) | |||
135 | */ | 135 | */ |
136 | bool PPPModule::isOwner(Interface *i) | 136 | bool PPPModule::isOwner(Interface *i) |
137 | { | 137 | { |
138 | return list.find( i ) != -1; | 138 | return list.find( i ) != -1; |
139 | } | 139 | } |
140 | 140 | ||
141 | /** | 141 | /** |
142 | * Create, and return the WLANConfigure Module | 142 | * Create, and return the WLANConfigure Module |
143 | * @return QWidget* pointer to this modules configure. | 143 | * @return QWidget* pointer to this modules configure. |
144 | */ | 144 | */ |
145 | QWidget *PPPModule::configure(Interface *i) | 145 | QWidget *PPPModule::configure(Interface *i) |
146 | { | 146 | { |
147 | odebug << "return ModemWidget" << oendl; | 147 | odebug << "return ModemWidget" << oendl; |
148 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, | 148 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, |
149 | 0, "PPPConfig", false, | 149 | 0, "PPPConfig", false, |
150 | ::Qt::WDestructiveClose | ::Qt::WStyle_ContextHelp); | 150 | ::Qt::WDestructiveClose | ::Qt::WStyle_ContextHelp); |
151 | return pppconfig; | 151 | return pppconfig; |
152 | } | 152 | } |
153 | 153 | ||
154 | /** | 154 | /** |
155 | * Create, and return the Information Module | 155 | * Create, and return the Information Module |
156 | * @return QWidget* pointer to this modules info. | 156 | * @return QWidget* pointer to this modules info. |
157 | */ | 157 | */ |
158 | QWidget *PPPModule::information(Interface *i) | 158 | QWidget *PPPModule::information(Interface *i) |
159 | { | 159 | { |
@@ -162,36 +162,37 @@ QWidget *PPPModule::information(Interface *i) | |||
162 | 162 | ||
163 | return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); | 163 | return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); |
164 | } | 164 | } |
165 | 165 | ||
166 | /** | 166 | /** |
167 | * Get all active (up or down) interfaces | 167 | * Get all active (up or down) interfaces |
168 | * @return QList<Interface> A list of interfaces that exsist that havn't | 168 | * @return QList<Interface> A list of interfaces that exsist that havn't |
169 | * been called by isOwner() | 169 | * been called by isOwner() |
170 | */ | 170 | */ |
171 | QList<Interface> PPPModule::getInterfaces() | 171 | QList<Interface> PPPModule::getInterfaces() |
172 | { | 172 | { |
173 | // List all of the files in the peer directory | 173 | // List all of the files in the peer directory |
174 | odebug << "PPPModule::getInterfaces" << oendl; | 174 | odebug << "PPPModule::getInterfaces" << oendl; |
175 | return list; | 175 | return list; |
176 | } | 176 | } |
177 | 177 | ||
178 | /** | 178 | /** |
179 | * Attempt to add a new interface as defined by name | 179 | * Attempt to add a new interface as defined by name |
180 | * @param name the name of the type of interface that should be created given | 180 | * @param newInterface the name of the type of interface that should be created given |
181 | * by possibleNewInterfaces(); | 181 | * by possibleNewInterfaces(); |
182 | * @return Interface* NULL if it was unable to be created. | 182 | * @return Interface* NULL if it was unable to be created. |
183 | */ | 183 | */ |
184 | Interface *PPPModule::addNewInterface(const QString &newInterface) | 184 | Interface *PPPModule::addNewInterface(const QString &newInterface) |
185 | { | 185 | { |
186 | Q_CONST_UNUSED( newInterface ) | ||
186 | 187 | ||
187 | InterfacePPP *ifaceppp; | 188 | InterfacePPP *ifaceppp; |
188 | Interface *iface; | 189 | Interface *iface; |
189 | ifaceppp = new InterfacePPP(); | 190 | ifaceppp = new InterfacePPP(); |
190 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); | 191 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); |
191 | 192 | ||
192 | if( QPEApplication::execDialog( &imp ) == QDialog::Accepted ) | 193 | if( QPEApplication::execDialog( &imp ) == QDialog::Accepted ) |
193 | { | 194 | { |
194 | iface = (InterfacePPP*) ifaceppp; | 195 | iface = (InterfacePPP*) ifaceppp; |
195 | iface->setModuleOwner( this ); | 196 | iface->setModuleOwner( this ); |
196 | list.append( iface ); | 197 | list.append( iface ); |
197 | return iface; | 198 | return iface; |
@@ -255,32 +256,32 @@ namespace | |||
255 | QMap<QString, Connection> InterfaceKeeper::interfaces()const | 256 | QMap<QString, Connection> InterfaceKeeper::interfaces()const |
256 | { | 257 | { |
257 | Config cfg("ppp_plugin_keeper"); | 258 | Config cfg("ppp_plugin_keeper"); |
258 | QMap<QString, Connection> ifaces; | 259 | QMap<QString, Connection> ifaces; |
259 | QStringList lst = cfg.groupList(); | 260 | QStringList lst = cfg.groupList(); |
260 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) | 261 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) |
261 | { | 262 | { |
262 | Connection con; | 263 | Connection con; |
263 | cfg.setGroup( (*it) ); | 264 | cfg.setGroup( (*it) ); |
264 | con.name = (*it); | 265 | con.name = (*it); |
265 | con.pid = cfg.readNumEntry("pid"); | 266 | con.pid = cfg.readNumEntry("pid"); |
266 | con.device = cfg.readEntry("device"); | 267 | con.device = cfg.readEntry("device"); |
267 | odebug << " " << con.name.latin1() << " " << con.device.latin1() << " " << con.pid << "" << oendl; | 268 | odebug << " " << con.name.latin1() << " " << con.device.latin1() << " " << con.pid << "" << oendl; |
268 | 269 | ||
269 | if ( con.pid != -1 && isAvailable( con.pid ) ) | 270 | if ( con.pid != -1 && isAvailable( con.pid ) ) |
270 | ifaces.insert( con.name, con ); | 271 | ifaces.insert( con.name, con ); |
271 | } | 272 | } |
272 | return ifaces; | 273 | return ifaces; |
273 | } | 274 | } |
274 | bool InterfaceKeeper::isAvailable( pid_t p)const | 275 | bool InterfaceKeeper::isAvailable( pid_t p)const |
275 | { | 276 | { |
276 | if (::kill(p, 0 ) == 0 || errno != ESRCH ) | 277 | if (::kill(p, 0 ) == 0 || errno != ESRCH ) |
277 | { | 278 | { |
278 | odebug << "isAvailable " << p << "" << oendl; | 279 | odebug << "isAvailable " << p << "" << oendl; |
279 | return true; | 280 | return true; |
280 | } | 281 | } |
281 | 282 | ||
282 | odebug << "notAvailable " << p << "" << oendl; | 283 | odebug << "notAvailable " << p << "" << oendl; |
283 | return false; | 284 | return false; |
284 | } | 285 | } |
285 | 286 | ||
286 | } | 287 | } |