summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/pppmodule.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/ppp/pppmodule.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index af05eb7..2462fa4 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -87,164 +87,164 @@ PPPModule::~PPPModule(){
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 successfull, 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}