Diffstat (limited to 'noncore/settings/networksettings/ppp/pppmodule.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/pppmodule.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index a7caffe..2291e8a 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp | |||
@@ -39,157 +39,157 @@ namespace | |||
39 | void addInterface( pid_t, const QString& pppDev, const QString& name ); | 39 | void addInterface( pid_t, const QString& pppDev, const QString& name ); |
40 | QMap<QString, Connection> interfaces()const; // will check if still available | 40 | QMap<QString, Connection> interfaces()const; // will check if still available |
41 | private: | 41 | private: |
42 | bool isAvailable( pid_t )const; | 42 | bool isAvailable( pid_t )const; |
43 | QMap<QString, Connection> m_interfaces; | 43 | QMap<QString, Connection> m_interfaces; |
44 | }; | 44 | }; |
45 | } | 45 | } |
46 | 46 | ||
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Constructor, find all of the possible interfaces | 49 | * Constructor, find all of the possible interfaces |
50 | * We also need to restore the state.. it could be that | 50 | * We also need to restore the state.. it could be that |
51 | * an interface was up while closing the application | 51 | * an interface was up while closing the application |
52 | * we need to be able to shut it down... | 52 | * we need to be able to shut it down... |
53 | */ | 53 | */ |
54 | PPPModule::PPPModule() : Module() | 54 | PPPModule::PPPModule() : Module() |
55 | { | 55 | { |
56 | InterfaceKeeper inFace; | 56 | InterfaceKeeper inFace; |
57 | QMap<QString,Connection> running = inFace.interfaces(); | 57 | QMap<QString,Connection> running = inFace.interfaces(); |
58 | QStringList handledInterfaceNames; | 58 | QStringList handledInterfaceNames; |
59 | 59 | ||
60 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); | 60 | QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); |
61 | QMap<QString,QString>::Iterator it; | 61 | QMap<QString,QString>::Iterator it; |
62 | InterfacePPP *iface; | 62 | InterfacePPP *iface; |
63 | qDebug("getting interfaces"); | 63 | odebug << "getting interfaces" << oendl; |
64 | for( it = ifaces.begin(); it != ifaces.end(); ++it ) | 64 | for( it = ifaces.begin(); it != ifaces.end(); ++it ) |
65 | { | 65 | { |
66 | qDebug("ifaces %s %s", it.key().latin1(), it.data().latin1() ); | 66 | odebug << "ifaces " << it.key().latin1() << " " << it.data().latin1() << "" << oendl; |
67 | iface = new InterfacePPP( 0, it.key() ); | 67 | iface = new InterfacePPP( 0, it.key() ); |
68 | iface->setHardwareName( it.data() ); | 68 | iface->setHardwareName( it.data() ); |
69 | list.append( (Interface*)iface ); | 69 | list.append( (Interface*)iface ); |
70 | 70 | ||
71 | // check if (*it) is one of the running ifaces | 71 | // check if (*it) is one of the running ifaces |
72 | if ( running.contains( it.data() ) ) | 72 | if ( running.contains( it.data() ) ) |
73 | { | 73 | { |
74 | qDebug("iface is running %s", it.key().latin1() ); | 74 | odebug << "iface is running " << it.key().latin1() << "" << oendl; |
75 | handledInterfaceNames << running[it.data()].device; | 75 | handledInterfaceNames << running[it.data()].device; |
76 | iface->setStatus( true ); | 76 | iface->setStatus( true ); |
77 | iface->setPPPDpid( running[it.data()].pid ); | 77 | iface->setPPPDpid( running[it.data()].pid ); |
78 | iface->modem()->setPPPDevice( running[it.data()].device ); | 78 | iface->modem()->setPPPDevice( running[it.data()].device ); |
79 | iface->refresh(); | 79 | iface->refresh(); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | setHandledInterfaceNames( handledInterfaceNames ); | 83 | setHandledInterfaceNames( handledInterfaceNames ); |
84 | } | 84 | } |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * Delete any interfaces that we own. | 87 | * Delete any interfaces that we own. |
88 | */ | 88 | */ |
89 | PPPModule::~PPPModule() | 89 | PPPModule::~PPPModule() |
90 | { | 90 | { |
91 | qDebug("PPPModule::~PPPModule() " ); | 91 | odebug << "PPPModule::~PPPModule() " << oendl; |
92 | QMap<QString,QString> ifaces; | 92 | QMap<QString,QString> ifaces; |
93 | InterfaceKeeper keeper; | 93 | InterfaceKeeper keeper; |
94 | Interface *i; | 94 | Interface *i; |
95 | for ( i=list.first(); i != 0; i=list.next() ) | 95 | for ( i=list.first(); i != 0; i=list.next() ) |
96 | { | 96 | { |
97 | /* if online save the state */ | 97 | /* if online save the state */ |
98 | if ( i->getStatus() ) | 98 | if ( i->getStatus() ) |
99 | { | 99 | { |
100 | qDebug("Iface %s is still up", i->getHardwareName().latin1() ); | 100 | odebug << "Iface " << i->getHardwareName().latin1() << " is still up" << oendl; |
101 | InterfacePPP* ppp = static_cast<InterfacePPP*>(i); | 101 | InterfacePPP* ppp = static_cast<InterfacePPP*>(i); |
102 | keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); | 102 | keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); |
103 | } | 103 | } |
104 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); | 104 | ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); |
105 | delete i; | 105 | delete i; |
106 | } | 106 | } |
107 | PPPData::setConfiguredInterfaces( ifaces ); | 107 | PPPData::setConfiguredInterfaces( ifaces ); |
108 | } | 108 | } |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * Change the current profile | 111 | * Change the current profile |
112 | */ | 112 | */ |
113 | void PPPModule::setProfile(const QString &newProfile) | 113 | void PPPModule::setProfile(const QString &newProfile) |
114 | { | 114 | { |
115 | profile = newProfile; | 115 | profile = newProfile; |
116 | } | 116 | } |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * get the icon name for this device. | 119 | * get the icon name for this device. |
120 | * @param Interface* can be used in determining the icon. | 120 | * @param Interface* can be used in determining the icon. |
121 | * @return QString the icon name (minus .png, .gif etc) | 121 | * @return QString the icon name (minus .png, .gif etc) |
122 | */ | 122 | */ |
123 | QString PPPModule::getPixmapName(Interface* ) | 123 | QString PPPModule::getPixmapName(Interface* ) |
124 | { | 124 | { |
125 | return "ppp"; | 125 | return "ppp"; |
126 | } | 126 | } |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * Check to see if the interface i is owned by this module. | 129 | * Check to see if the interface i is owned by this module. |
130 | * @param Interface* interface to check against | 130 | * @param Interface* interface to check against |
131 | * @return bool true if i is owned by this module, false otherwise. | 131 | * @return bool true if i is owned by this module, false otherwise. |
132 | */ | 132 | */ |
133 | bool PPPModule::isOwner(Interface *i) | 133 | bool PPPModule::isOwner(Interface *i) |
134 | { | 134 | { |
135 | return list.find( i ) != -1; | 135 | return list.find( i ) != -1; |
136 | } | 136 | } |
137 | 137 | ||
138 | /** | 138 | /** |
139 | * Create, and return the WLANConfigure Module | 139 | * Create, and return the WLANConfigure Module |
140 | * @return QWidget* pointer to this modules configure. | 140 | * @return QWidget* pointer to this modules configure. |
141 | */ | 141 | */ |
142 | QWidget *PPPModule::configure(Interface *i) | 142 | QWidget *PPPModule::configure(Interface *i) |
143 | { | 143 | { |
144 | qDebug("return ModemWidget"); | 144 | odebug << "return ModemWidget" << oendl; |
145 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, | 145 | PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, |
146 | 0, "PPPConfig", false, | 146 | 0, "PPPConfig", false, |
147 | (Qt::WDestructiveClose | Qt::WStyle_ContextHelp)); | 147 | (Qt::WDestructiveClose | Qt::WStyle_ContextHelp)); |
148 | return pppconfig; | 148 | return pppconfig; |
149 | } | 149 | } |
150 | 150 | ||
151 | /** | 151 | /** |
152 | * Create, and return the Information Module | 152 | * Create, and return the Information Module |
153 | * @return QWidget* pointer to this modules info. | 153 | * @return QWidget* pointer to this modules info. |
154 | */ | 154 | */ |
155 | QWidget *PPPModule::information(Interface *i) | 155 | QWidget *PPPModule::information(Interface *i) |
156 | { | 156 | { |
157 | // We don't have any advanced pppd information widget yet :-D | 157 | // We don't have any advanced pppd information widget yet :-D |
158 | // TODO ^ | 158 | // TODO ^ |
159 | 159 | ||
160 | return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); | 160 | return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); |
161 | } | 161 | } |
162 | 162 | ||
163 | /** | 163 | /** |
164 | * Get all active (up or down) interfaces | 164 | * Get all active (up or down) interfaces |
165 | * @return QList<Interface> A list of interfaces that exsist that havn't | 165 | * @return QList<Interface> A list of interfaces that exsist that havn't |
166 | * been called by isOwner() | 166 | * been called by isOwner() |
167 | */ | 167 | */ |
168 | QList<Interface> PPPModule::getInterfaces() | 168 | QList<Interface> PPPModule::getInterfaces() |
169 | { | 169 | { |
170 | // List all of the files in the peer directory | 170 | // List all of the files in the peer directory |
171 | qDebug("PPPModule::getInterfaces"); | 171 | odebug << "PPPModule::getInterfaces" << oendl; |
172 | return list; | 172 | return list; |
173 | } | 173 | } |
174 | 174 | ||
175 | /** | 175 | /** |
176 | * Attempt to add a new interface as defined by name | 176 | * Attempt to add a new interface as defined by name |
177 | * @param name the name of the type of interface that should be created given | 177 | * @param name the name of the type of interface that should be created given |
178 | * by possibleNewInterfaces(); | 178 | * by possibleNewInterfaces(); |
179 | * @return Interface* NULL if it was unable to be created. | 179 | * @return Interface* NULL if it was unable to be created. |
180 | */ | 180 | */ |
181 | Interface *PPPModule::addNewInterface(const QString &newInterface) | 181 | Interface *PPPModule::addNewInterface(const QString &newInterface) |
182 | { | 182 | { |
183 | 183 | ||
184 | InterfacePPP *ifaceppp; | 184 | InterfacePPP *ifaceppp; |
185 | Interface *iface; | 185 | Interface *iface; |
186 | ifaceppp = new InterfacePPP(); | 186 | ifaceppp = new InterfacePPP(); |
187 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); | 187 | PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); |
188 | 188 | ||
189 | if( QPEApplication::execDialog( &imp ) == QDialog::Accepted ) | 189 | if( QPEApplication::execDialog( &imp ) == QDialog::Accepted ) |
190 | { | 190 | { |
191 | iface = (InterfacePPP*) ifaceppp; | 191 | iface = (InterfacePPP*) ifaceppp; |
192 | iface->setModuleOwner( this ); | 192 | iface->setModuleOwner( this ); |
193 | list.append( iface ); | 193 | list.append( iface ); |
194 | return iface; | 194 | return iface; |
195 | } | 195 | } |
@@ -240,44 +240,44 @@ namespace | |||
240 | cfg.writeEntry( "pid", con.pid ); | 240 | cfg.writeEntry( "pid", con.pid ); |
241 | cfg.writeEntry( "device", con.device ); | 241 | cfg.writeEntry( "device", con.device ); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 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 | { | 245 | { |
246 | Connection con; | 246 | Connection con; |
247 | con.pid = pid; | 247 | con.pid = pid; |
248 | con.device = dev; | 248 | con.device = dev; |
249 | con.name = name; | 249 | con.name = name; |
250 | m_interfaces.insert( name, con ); | 250 | m_interfaces.insert( name, con ); |
251 | } | 251 | } |
252 | QMap<QString, Connection> InterfaceKeeper::interfaces()const | 252 | QMap<QString, Connection> InterfaceKeeper::interfaces()const |
253 | { | 253 | { |
254 | Config cfg("ppp_plugin_keeper"); | 254 | Config cfg("ppp_plugin_keeper"); |
255 | QMap<QString, Connection> ifaces; | 255 | QMap<QString, Connection> ifaces; |
256 | QStringList lst = cfg.groupList(); | 256 | QStringList lst = cfg.groupList(); |
257 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) | 257 | for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) |
258 | { | 258 | { |
259 | Connection con; | 259 | Connection con; |
260 | cfg.setGroup( (*it) ); | 260 | cfg.setGroup( (*it) ); |
261 | con.name = (*it); | 261 | con.name = (*it); |
262 | con.pid = cfg.readNumEntry("pid"); | 262 | con.pid = cfg.readNumEntry("pid"); |
263 | con.device = cfg.readEntry("device"); | 263 | con.device = cfg.readEntry("device"); |
264 | qDebug(" %s %s %d", con.name.latin1(), con.device.latin1(), con.pid ); | 264 | odebug << " " << con.name.latin1() << " " << con.device.latin1() << " " << con.pid << "" << oendl; |
265 | 265 | ||
266 | if ( con.pid != -1 && isAvailable( con.pid ) ) | 266 | if ( con.pid != -1 && isAvailable( con.pid ) ) |
267 | ifaces.insert( con.name, con ); | 267 | ifaces.insert( con.name, con ); |
268 | } | 268 | } |
269 | return ifaces; | 269 | return ifaces; |
270 | } | 270 | } |
271 | bool InterfaceKeeper::isAvailable( pid_t p)const | 271 | bool InterfaceKeeper::isAvailable( pid_t p)const |
272 | { | 272 | { |
273 | if (::kill(p, 0 ) == 0 || errno != ESRCH ) | 273 | if (::kill(p, 0 ) == 0 || errno != ESRCH ) |
274 | { | 274 | { |
275 | qDebug("isAvailable %d", p); | 275 | odebug << "isAvailable " << p << "" << oendl; |
276 | return true; | 276 | return true; |
277 | } | 277 | } |
278 | 278 | ||
279 | qDebug("notAvailable %d", p); | 279 | odebug << "notAvailable " << p << "" << oendl; |
280 | return false; | 280 | return false; |
281 | } | 281 | } |
282 | 282 | ||
283 | } | 283 | } |