-rw-r--r-- | noncore/net/networksetup/mainwindowimp.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index 3b0b7e8..7261c58 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp | |||
@@ -67,194 +67,194 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par | |||
67 | line = line.mid(7, line.length()); | 67 | line = line.mid(7, line.length()); |
68 | currentProfileLabel->setText(line); | 68 | currentProfileLabel->setText(line); |
69 | break; | 69 | break; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | file.close(); | 72 | file.close(); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Deconstructor. Save profiles. Delete loaded libraries. | 77 | * Deconstructor. Save profiles. Delete loaded libraries. |
78 | */ | 78 | */ |
79 | MainWindowImp::~MainWindowImp(){ | 79 | MainWindowImp::~MainWindowImp(){ |
80 | // Save profiles. | 80 | // Save profiles. |
81 | Config cfg("NetworkSetup"); | 81 | Config cfg("NetworkSetup"); |
82 | cfg.setGroup("General"); | 82 | cfg.setGroup("General"); |
83 | cfg.writeEntry("Profiles", profiles.join(" ")); | 83 | cfg.writeEntry("Profiles", profiles.join(" ")); |
84 | 84 | ||
85 | // Delete all interfaces that don't have owners. | 85 | // Delete all interfaces that don't have owners. |
86 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 86 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
87 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ | 87 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ |
88 | if(iIt.key()->getModuleOwner() == NULL) | 88 | if(iIt.key()->getModuleOwner() == NULL) |
89 | delete iIt.key(); | 89 | delete iIt.key(); |
90 | } | 90 | } |
91 | 91 | ||
92 | // Delete Modules and Libraries | 92 | // Delete Modules and Libraries |
93 | QMap<Module*, QLibrary*>::Iterator it; | 93 | QMap<Module*, QLibrary*>::Iterator it; |
94 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 94 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
95 | delete it.key(); | 95 | delete it.key(); |
96 | // I wonder why I can't delete the libraries | 96 | // I wonder why I can't delete the libraries |
97 | // What fucking shit this is. | 97 | // What fucking shit this is. |
98 | //delete it.data(); | 98 | //delete it.data(); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * Load all modules that are found in the path | 103 | * Load all modules that are found in the path |
104 | * @param path a directory that is scaned for any plugins that can be loaded | 104 | * @param path a directory that is scaned for any plugins that can be loaded |
105 | * and attempts to load them | 105 | * and attempts to load them |
106 | */ | 106 | */ |
107 | void MainWindowImp::loadModules(QString path){ | 107 | void MainWindowImp::loadModules(QString path){ |
108 | //qDebug(path.latin1()); | 108 | //qDebug(path.latin1()); |
109 | QDir d(path); | 109 | QDir d(path); |
110 | if(!d.exists()) | 110 | if(!d.exists()) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | // Don't want sym links | 113 | // Don't want sym links |
114 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 114 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
115 | const QFileInfoList *list = d.entryInfoList(); | 115 | const QFileInfoList *list = d.entryInfoList(); |
116 | QFileInfoListIterator it( *list ); | 116 | QFileInfoListIterator it( *list ); |
117 | QFileInfo *fi; | 117 | QFileInfo *fi; |
118 | while ( (fi=it.current()) ) { | 118 | while ( (fi=it.current()) ) { |
119 | if(fi->fileName().contains(".so")){ | 119 | if(fi->fileName().contains(".so")){ |
120 | loadPlugin(path + "/" + fi->fileName()); | 120 | loadPlugin(path + "/" + fi->fileName()); |
121 | } | 121 | } |
122 | ++it; | 122 | ++it; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * Attempt to load a function and resolve a function. | 127 | * Attempt to load a function and resolve a function. |
128 | * @param pluginFileName - the name of the file in which to attempt to load | 128 | * @param pluginFileName - the name of the file in which to attempt to load |
129 | * @param resolveString - function pointer to resolve | 129 | * @param resolveString - function pointer to resolve |
130 | * @return pointer to the function with name resolveString or NULL | 130 | * @return pointer to the function with name resolveString or NULL |
131 | */ | 131 | */ |
132 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ | 132 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ |
133 | //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); | 133 | //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); |
134 | QLibrary *lib = new QLibrary(pluginFileName); | 134 | QLibrary *lib = new QLibrary(pluginFileName); |
135 | void *functionPointer = lib->resolve(resolveString); | 135 | void *functionPointer = lib->resolve(resolveString); |
136 | if( !functionPointer ){ | 136 | if( !functionPointer ){ |
137 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 137 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
138 | delete lib; | 138 | delete lib; |
139 | return NULL; | 139 | return NULL; |
140 | } | 140 | } |
141 | 141 | ||
142 | // Try to get an object. | 142 | // Try to get an object. |
143 | Module *object = ((Module* (*)()) functionPointer)(); | 143 | Module *object = ((Module* (*)()) functionPointer)(); |
144 | if(object == NULL){ | 144 | if(object == NULL){ |
145 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 145 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
146 | delete lib; | 146 | delete lib; |
147 | return NULL; | 147 | return NULL; |
148 | } | 148 | } |
149 | 149 | ||
150 | // Store for deletion later | 150 | // Store for deletion later |
151 | libraries.insert(object, lib); | 151 | libraries.insert(object, lib); |
152 | return object; | 152 | return object; |
153 | } | 153 | } |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 156 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
157 | * load the plugin and append it to the list | 157 | * load the plugin and append it to the list |
158 | */ | 158 | */ |
159 | void MainWindowImp::addClicked(){ | 159 | void MainWindowImp::addClicked(){ |
160 | QMap<Module*, QLibrary*>::Iterator it; | 160 | QMap<Module*, QLibrary*>::Iterator it; |
161 | QMap<QString, QString> list; | 161 | QMap<QString, QString> list; |
162 | QMap<QString, Module*> newInterfaceOwners; | 162 | QMap<QString, Module*> newInterfaceOwners; |
163 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); | 163 | //list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); |
164 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); | 164 | //list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); |
165 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 165 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
166 | if(it.key()){ | 166 | if(it.key()){ |
167 | (it.key())->possibleNewInterfaces(list); | 167 | (it.key())->possibleNewInterfaces(list); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | // See if the list has anything that we can add. | 170 | // See if the list has anything that we can add. |
171 | if(list.count() == 0){ | 171 | if(list.count() == 0){ |
172 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); | 172 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); |
173 | return; | 173 | return; |
174 | } | 174 | } |
175 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 175 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
176 | addNewConnection.addConnections(list); | 176 | addNewConnection.addConnections(list); |
177 | addNewConnection.showMaximized(); | 177 | addNewConnection.showMaximized(); |
178 | if(QDialog::Accepted == addNewConnection.exec()){ | 178 | if(QDialog::Accepted == addNewConnection.exec()){ |
179 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 179 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
180 | if(!item) | 180 | if(!item) |
181 | return; | 181 | return; |
182 | 182 | ||
183 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 183 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
184 | if(it.key()){ | 184 | if(it.key()){ |
185 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 185 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
186 | if(i){ | 186 | if(i){ |
187 | interfaceNames.insert(i->getInterfaceName(), i); | 187 | interfaceNames.insert(i->getInterfaceName(), i); |
188 | updateInterface(i); | 188 | updateInterface(i); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * Prompt the user to see if they really want to do this. | 196 | * Prompt the user to see if they really want to do this. |
197 | * If they do then remove from the list and unload. | 197 | * If they do then remove from the list and unload. |
198 | */ | 198 | */ |
199 | void MainWindowImp::removeClicked(){ | 199 | void MainWindowImp::removeClicked(){ |
200 | QListViewItem *item = connectionList->currentItem(); | 200 | QListViewItem *item = connectionList->currentItem(); |
201 | if(!item) { | 201 | if(!item) { |
202 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 202 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | 205 | ||
206 | Interface *i = interfaceItems[item]; | 206 | Interface *i = interfaceItems[item]; |
207 | if(i->getModuleOwner() == NULL){ | 207 | if(i->getModuleOwner() == NULL){ |
208 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); | 208 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); |
209 | } | 209 | } |
210 | else{ | 210 | else{ |
211 | if(!i->getModuleOwner()->remove(i)) | 211 | if(!i->getModuleOwner()->remove(i)) |
212 | QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok); | 212 | QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok); |
213 | else{ | 213 | else{ |
214 | QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); | 214 | QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); |
215 | // TODO memory managment.... | 215 | // TODO memory managment.... |
216 | // who deletes the interface? | 216 | // who deletes the interface? |
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | /** | 221 | /** |
222 | * Pull up the configure about the currently selected interface. | 222 | * Pull up the configure about the currently selected interface. |
223 | * Report an error if no interface is selected. | 223 | * Report an error if no interface is selected. |
224 | * If the interface has a module owner then request its configure. | 224 | * If the interface has a module owner then request its configure. |
225 | */ | 225 | */ |
226 | void MainWindowImp::configureClicked(){ | 226 | void MainWindowImp::configureClicked(){ |
227 | QListViewItem *item = connectionList->currentItem(); | 227 | QListViewItem *item = connectionList->currentItem(); |
228 | if(!item){ | 228 | if(!item){ |
229 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); | 229 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); |
230 | return; | 230 | return; |
231 | } | 231 | } |
232 | 232 | ||
233 | Interface *i = interfaceItems[item]; | 233 | Interface *i = interfaceItems[item]; |
234 | if(i->getModuleOwner()){ | 234 | if(i->getModuleOwner()){ |
235 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 235 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
236 | if(moduleConfigure != NULL){ | 236 | if(moduleConfigure != NULL){ |
237 | moduleConfigure->showMaximized(); | 237 | moduleConfigure->showMaximized(); |
238 | moduleConfigure->show(); | 238 | moduleConfigure->show(); |
239 | return; | 239 | return; |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose); | 243 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose); |
244 | QString currentProfileText = currentProfileLabel->text(); | 244 | QString currentProfileText = currentProfileLabel->text(); |
245 | if(currentProfileText.upper() == "ALL"); | 245 | if(currentProfileText.upper() == "ALL"); |
246 | currentProfileText = ""; | 246 | currentProfileText = ""; |
247 | configure->setProfile(currentProfileText); | 247 | configure->setProfile(currentProfileText); |
248 | configure->showMaximized(); | 248 | configure->showMaximized(); |
249 | configure->show(); | 249 | configure->show(); |
250 | } | 250 | } |
251 | 251 | ||
252 | /** | 252 | /** |
253 | * Pull up the information about the currently selected interface. | 253 | * Pull up the information about the currently selected interface. |
254 | * Report an error if no interface is selected. | 254 | * Report an error if no interface is selected. |
255 | * If the interface has a module owner then request its configure. | 255 | * If the interface has a module owner then request its configure. |
256 | */ | 256 | */ |
257 | void MainWindowImp::informationClicked(){ | 257 | void MainWindowImp::informationClicked(){ |
258 | QListViewItem *item = connectionList->currentItem(); | 258 | QListViewItem *item = connectionList->currentItem(); |
259 | if(!item){ | 259 | if(!item){ |
260 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 260 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 3b0b7e8..7261c58 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -67,194 +67,194 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par | |||
67 | line = line.mid(7, line.length()); | 67 | line = line.mid(7, line.length()); |
68 | currentProfileLabel->setText(line); | 68 | currentProfileLabel->setText(line); |
69 | break; | 69 | break; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | file.close(); | 72 | file.close(); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Deconstructor. Save profiles. Delete loaded libraries. | 77 | * Deconstructor. Save profiles. Delete loaded libraries. |
78 | */ | 78 | */ |
79 | MainWindowImp::~MainWindowImp(){ | 79 | MainWindowImp::~MainWindowImp(){ |
80 | // Save profiles. | 80 | // Save profiles. |
81 | Config cfg("NetworkSetup"); | 81 | Config cfg("NetworkSetup"); |
82 | cfg.setGroup("General"); | 82 | cfg.setGroup("General"); |
83 | cfg.writeEntry("Profiles", profiles.join(" ")); | 83 | cfg.writeEntry("Profiles", profiles.join(" ")); |
84 | 84 | ||
85 | // Delete all interfaces that don't have owners. | 85 | // Delete all interfaces that don't have owners. |
86 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 86 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
87 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ | 87 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ |
88 | if(iIt.key()->getModuleOwner() == NULL) | 88 | if(iIt.key()->getModuleOwner() == NULL) |
89 | delete iIt.key(); | 89 | delete iIt.key(); |
90 | } | 90 | } |
91 | 91 | ||
92 | // Delete Modules and Libraries | 92 | // Delete Modules and Libraries |
93 | QMap<Module*, QLibrary*>::Iterator it; | 93 | QMap<Module*, QLibrary*>::Iterator it; |
94 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 94 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
95 | delete it.key(); | 95 | delete it.key(); |
96 | // I wonder why I can't delete the libraries | 96 | // I wonder why I can't delete the libraries |
97 | // What fucking shit this is. | 97 | // What fucking shit this is. |
98 | //delete it.data(); | 98 | //delete it.data(); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * Load all modules that are found in the path | 103 | * Load all modules that are found in the path |
104 | * @param path a directory that is scaned for any plugins that can be loaded | 104 | * @param path a directory that is scaned for any plugins that can be loaded |
105 | * and attempts to load them | 105 | * and attempts to load them |
106 | */ | 106 | */ |
107 | void MainWindowImp::loadModules(QString path){ | 107 | void MainWindowImp::loadModules(QString path){ |
108 | //qDebug(path.latin1()); | 108 | //qDebug(path.latin1()); |
109 | QDir d(path); | 109 | QDir d(path); |
110 | if(!d.exists()) | 110 | if(!d.exists()) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | // Don't want sym links | 113 | // Don't want sym links |
114 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 114 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
115 | const QFileInfoList *list = d.entryInfoList(); | 115 | const QFileInfoList *list = d.entryInfoList(); |
116 | QFileInfoListIterator it( *list ); | 116 | QFileInfoListIterator it( *list ); |
117 | QFileInfo *fi; | 117 | QFileInfo *fi; |
118 | while ( (fi=it.current()) ) { | 118 | while ( (fi=it.current()) ) { |
119 | if(fi->fileName().contains(".so")){ | 119 | if(fi->fileName().contains(".so")){ |
120 | loadPlugin(path + "/" + fi->fileName()); | 120 | loadPlugin(path + "/" + fi->fileName()); |
121 | } | 121 | } |
122 | ++it; | 122 | ++it; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * Attempt to load a function and resolve a function. | 127 | * Attempt to load a function and resolve a function. |
128 | * @param pluginFileName - the name of the file in which to attempt to load | 128 | * @param pluginFileName - the name of the file in which to attempt to load |
129 | * @param resolveString - function pointer to resolve | 129 | * @param resolveString - function pointer to resolve |
130 | * @return pointer to the function with name resolveString or NULL | 130 | * @return pointer to the function with name resolveString or NULL |
131 | */ | 131 | */ |
132 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ | 132 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ |
133 | //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); | 133 | //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); |
134 | QLibrary *lib = new QLibrary(pluginFileName); | 134 | QLibrary *lib = new QLibrary(pluginFileName); |
135 | void *functionPointer = lib->resolve(resolveString); | 135 | void *functionPointer = lib->resolve(resolveString); |
136 | if( !functionPointer ){ | 136 | if( !functionPointer ){ |
137 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 137 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
138 | delete lib; | 138 | delete lib; |
139 | return NULL; | 139 | return NULL; |
140 | } | 140 | } |
141 | 141 | ||
142 | // Try to get an object. | 142 | // Try to get an object. |
143 | Module *object = ((Module* (*)()) functionPointer)(); | 143 | Module *object = ((Module* (*)()) functionPointer)(); |
144 | if(object == NULL){ | 144 | if(object == NULL){ |
145 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 145 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
146 | delete lib; | 146 | delete lib; |
147 | return NULL; | 147 | return NULL; |
148 | } | 148 | } |
149 | 149 | ||
150 | // Store for deletion later | 150 | // Store for deletion later |
151 | libraries.insert(object, lib); | 151 | libraries.insert(object, lib); |
152 | return object; | 152 | return object; |
153 | } | 153 | } |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 156 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
157 | * load the plugin and append it to the list | 157 | * load the plugin and append it to the list |
158 | */ | 158 | */ |
159 | void MainWindowImp::addClicked(){ | 159 | void MainWindowImp::addClicked(){ |
160 | QMap<Module*, QLibrary*>::Iterator it; | 160 | QMap<Module*, QLibrary*>::Iterator it; |
161 | QMap<QString, QString> list; | 161 | QMap<QString, QString> list; |
162 | QMap<QString, Module*> newInterfaceOwners; | 162 | QMap<QString, Module*> newInterfaceOwners; |
163 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); | 163 | //list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); |
164 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); | 164 | //list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); |
165 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 165 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
166 | if(it.key()){ | 166 | if(it.key()){ |
167 | (it.key())->possibleNewInterfaces(list); | 167 | (it.key())->possibleNewInterfaces(list); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | // See if the list has anything that we can add. | 170 | // See if the list has anything that we can add. |
171 | if(list.count() == 0){ | 171 | if(list.count() == 0){ |
172 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); | 172 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); |
173 | return; | 173 | return; |
174 | } | 174 | } |
175 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 175 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
176 | addNewConnection.addConnections(list); | 176 | addNewConnection.addConnections(list); |
177 | addNewConnection.showMaximized(); | 177 | addNewConnection.showMaximized(); |
178 | if(QDialog::Accepted == addNewConnection.exec()){ | 178 | if(QDialog::Accepted == addNewConnection.exec()){ |
179 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 179 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
180 | if(!item) | 180 | if(!item) |
181 | return; | 181 | return; |
182 | 182 | ||
183 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 183 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
184 | if(it.key()){ | 184 | if(it.key()){ |
185 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 185 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
186 | if(i){ | 186 | if(i){ |
187 | interfaceNames.insert(i->getInterfaceName(), i); | 187 | interfaceNames.insert(i->getInterfaceName(), i); |
188 | updateInterface(i); | 188 | updateInterface(i); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * Prompt the user to see if they really want to do this. | 196 | * Prompt the user to see if they really want to do this. |
197 | * If they do then remove from the list and unload. | 197 | * If they do then remove from the list and unload. |
198 | */ | 198 | */ |
199 | void MainWindowImp::removeClicked(){ | 199 | void MainWindowImp::removeClicked(){ |
200 | QListViewItem *item = connectionList->currentItem(); | 200 | QListViewItem *item = connectionList->currentItem(); |
201 | if(!item) { | 201 | if(!item) { |
202 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 202 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | 205 | ||
206 | Interface *i = interfaceItems[item]; | 206 | Interface *i = interfaceItems[item]; |
207 | if(i->getModuleOwner() == NULL){ | 207 | if(i->getModuleOwner() == NULL){ |
208 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); | 208 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); |
209 | } | 209 | } |
210 | else{ | 210 | else{ |
211 | if(!i->getModuleOwner()->remove(i)) | 211 | if(!i->getModuleOwner()->remove(i)) |
212 | QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok); | 212 | QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok); |
213 | else{ | 213 | else{ |
214 | QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); | 214 | QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); |
215 | // TODO memory managment.... | 215 | // TODO memory managment.... |
216 | // who deletes the interface? | 216 | // who deletes the interface? |
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | /** | 221 | /** |
222 | * Pull up the configure about the currently selected interface. | 222 | * Pull up the configure about the currently selected interface. |
223 | * Report an error if no interface is selected. | 223 | * Report an error if no interface is selected. |
224 | * If the interface has a module owner then request its configure. | 224 | * If the interface has a module owner then request its configure. |
225 | */ | 225 | */ |
226 | void MainWindowImp::configureClicked(){ | 226 | void MainWindowImp::configureClicked(){ |
227 | QListViewItem *item = connectionList->currentItem(); | 227 | QListViewItem *item = connectionList->currentItem(); |
228 | if(!item){ | 228 | if(!item){ |
229 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); | 229 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); |
230 | return; | 230 | return; |
231 | } | 231 | } |
232 | 232 | ||
233 | Interface *i = interfaceItems[item]; | 233 | Interface *i = interfaceItems[item]; |
234 | if(i->getModuleOwner()){ | 234 | if(i->getModuleOwner()){ |
235 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 235 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
236 | if(moduleConfigure != NULL){ | 236 | if(moduleConfigure != NULL){ |
237 | moduleConfigure->showMaximized(); | 237 | moduleConfigure->showMaximized(); |
238 | moduleConfigure->show(); | 238 | moduleConfigure->show(); |
239 | return; | 239 | return; |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose); | 243 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose); |
244 | QString currentProfileText = currentProfileLabel->text(); | 244 | QString currentProfileText = currentProfileLabel->text(); |
245 | if(currentProfileText.upper() == "ALL"); | 245 | if(currentProfileText.upper() == "ALL"); |
246 | currentProfileText = ""; | 246 | currentProfileText = ""; |
247 | configure->setProfile(currentProfileText); | 247 | configure->setProfile(currentProfileText); |
248 | configure->showMaximized(); | 248 | configure->showMaximized(); |
249 | configure->show(); | 249 | configure->show(); |
250 | } | 250 | } |
251 | 251 | ||
252 | /** | 252 | /** |
253 | * Pull up the information about the currently selected interface. | 253 | * Pull up the information about the currently selected interface. |
254 | * Report an error if no interface is selected. | 254 | * Report an error if no interface is selected. |
255 | * If the interface has a module owner then request its configure. | 255 | * If the interface has a module owner then request its configure. |
256 | */ | 256 | */ |
257 | void MainWindowImp::informationClicked(){ | 257 | void MainWindowImp::informationClicked(){ |
258 | QListViewItem *item = connectionList->currentItem(); | 258 | QListViewItem *item = connectionList->currentItem(); |
259 | if(!item){ | 259 | if(!item){ |
260 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 260 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |