author | kergoth <kergoth> | 2002-10-16 02:08:27 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-10-16 02:08:27 (UTC) |
commit | 9eba62fc184260f1a0455a6dd057e2ccebf4bdac (patch) (unidiff) | |
tree | f3cf3c1fa05e2fceba5aa6611222838498462b90 | |
parent | 543e54de7170c606b6883ac4152567e7faf13182 (diff) | |
download | opie-9eba62fc184260f1a0455a6dd057e2ccebf4bdac.zip opie-9eba62fc184260f1a0455a6dd057e2ccebf4bdac.tar.gz opie-9eba62fc184260f1a0455a6dd057e2ccebf4bdac.tar.bz2 |
missing include.. oops :)
-rw-r--r-- | noncore/net/networksetup/mainwindowimp.cpp | 1 | ||||
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index 3715da0..36f12e0 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp | |||
@@ -1,214 +1,215 @@ | |||
1 | #include "mainwindowimp.h" | 1 | #include "mainwindowimp.h" |
2 | #include "addconnectionimp.h" | 2 | #include "addconnectionimp.h" |
3 | #include "interfaceinformationimp.h" | 3 | #include "interfaceinformationimp.h" |
4 | #include "interfacesetupimp.h" | 4 | #include "interfacesetupimp.h" |
5 | #include "module.h" | 5 | #include "module.h" |
6 | 6 | ||
7 | #include "kprocess.h" | 7 | #include "kprocess.h" |
8 | 8 | ||
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qtabwidget.h> | 10 | #include <qtabwidget.h> |
11 | #include <qlistbox.h> | 11 | #include <qlistbox.h> |
12 | #include <qlineedit.h> | 12 | #include <qlineedit.h> |
13 | #include <qlistview.h> | 13 | #include <qlistview.h> |
14 | #include <qheader.h> | 14 | #include <qheader.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | 16 | ||
17 | #include <qmainwindow.h> | 17 | #include <qmainwindow.h> |
18 | #include <qmessagebox.h> | 18 | #include <qmessagebox.h> |
19 | 19 | ||
20 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
21 | #include <qpe/qlibrary.h> | 21 | #include <qpe/qlibrary.h> |
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | #include <qpe/qpeapplication.h> | ||
23 | 24 | ||
24 | #include <qlist.h> | 25 | #include <qlist.h> |
25 | #include <qdir.h> | 26 | #include <qdir.h> |
26 | #include <qfile.h> | 27 | #include <qfile.h> |
27 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
28 | 29 | ||
29 | #define TEMP_ALL "/tmp/ifconfig-a" | 30 | #define TEMP_ALL "/tmp/ifconfig-a" |
30 | #define TEMP_UP "/tmp/ifconfig" | 31 | #define TEMP_UP "/tmp/ifconfig" |
31 | 32 | ||
32 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ | 33 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ |
33 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 34 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
34 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 35 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
35 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 36 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
36 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 37 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); |
37 | 38 | ||
38 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 39 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
39 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 40 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
40 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 41 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
41 | 42 | ||
42 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 43 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
43 | // Load connections. | 44 | // Load connections. |
44 | loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); | 45 | loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); |
45 | getInterfaceList(); | 46 | getInterfaceList(); |
46 | connectionList->header()->hide(); | 47 | connectionList->header()->hide(); |
47 | 48 | ||
48 | 49 | ||
49 | Config cfg("NetworkSetup"); | 50 | Config cfg("NetworkSetup"); |
50 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 51 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
51 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 52 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
52 | profilesList->insertItem((*it)); | 53 | profilesList->insertItem((*it)); |
53 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 54 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
54 | } | 55 | } |
55 | 56 | ||
56 | /** | 57 | /** |
57 | * Deconstructor. Save profiles. Delete loaded libraries. | 58 | * Deconstructor. Save profiles. Delete loaded libraries. |
58 | */ | 59 | */ |
59 | MainWindowImp::~MainWindowImp(){ | 60 | MainWindowImp::~MainWindowImp(){ |
60 | // Save profiles. | 61 | // Save profiles. |
61 | if(profiles.count() > 1){ | 62 | if(profiles.count() > 1){ |
62 | Config cfg("NetworkSetup"); | 63 | Config cfg("NetworkSetup"); |
63 | cfg.setGroup("General"); | 64 | cfg.setGroup("General"); |
64 | cfg.writeEntry("Profiles", profiles.join(" ")); | 65 | cfg.writeEntry("Profiles", profiles.join(" ")); |
65 | } | 66 | } |
66 | // Delete Modules and Libraries | 67 | // Delete Modules and Libraries |
67 | QMap<Module*, QLibrary*>::Iterator it; | 68 | QMap<Module*, QLibrary*>::Iterator it; |
68 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 69 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
69 | delete it.key(); | 70 | delete it.key(); |
70 | delete it.data(); | 71 | delete it.data(); |
71 | } | 72 | } |
72 | } | 73 | } |
73 | 74 | ||
74 | /** | 75 | /** |
75 | * Load all modules that are found in the path | 76 | * Load all modules that are found in the path |
76 | * @param path a directory that is scaned for any plugins that can be loaded | 77 | * @param path a directory that is scaned for any plugins that can be loaded |
77 | * and attempts to load them | 78 | * and attempts to load them |
78 | */ | 79 | */ |
79 | void MainWindowImp::loadModules(QString path){ | 80 | void MainWindowImp::loadModules(QString path){ |
80 | qDebug(path.latin1()); | 81 | qDebug(path.latin1()); |
81 | QDir d(path); | 82 | QDir d(path); |
82 | if(!d.exists()) | 83 | if(!d.exists()) |
83 | return; | 84 | return; |
84 | 85 | ||
85 | // Don't want sym links | 86 | // Don't want sym links |
86 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 87 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
87 | const QFileInfoList *list = d.entryInfoList(); | 88 | const QFileInfoList *list = d.entryInfoList(); |
88 | QFileInfoListIterator it( *list ); | 89 | QFileInfoListIterator it( *list ); |
89 | QFileInfo *fi; | 90 | QFileInfo *fi; |
90 | while ( (fi=it.current()) ) { | 91 | while ( (fi=it.current()) ) { |
91 | if(fi->fileName().contains(".so")){ | 92 | if(fi->fileName().contains(".so")){ |
92 | loadPlugin(path + "/" + fi->fileName()); | 93 | loadPlugin(path + "/" + fi->fileName()); |
93 | } | 94 | } |
94 | ++it; | 95 | ++it; |
95 | } | 96 | } |
96 | } | 97 | } |
97 | 98 | ||
98 | /** | 99 | /** |
99 | * Attempt to load a function and resolve a function. | 100 | * Attempt to load a function and resolve a function. |
100 | * @param pluginFileName - the name of the file in which to attempt to load | 101 | * @param pluginFileName - the name of the file in which to attempt to load |
101 | * @param resolveString - function pointer to resolve | 102 | * @param resolveString - function pointer to resolve |
102 | * @return pointer to the function with name resolveString or NULL | 103 | * @return pointer to the function with name resolveString or NULL |
103 | */ | 104 | */ |
104 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ | 105 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ |
105 | qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); | 106 | qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); |
106 | QLibrary *lib = new QLibrary(pluginFileName); | 107 | QLibrary *lib = new QLibrary(pluginFileName); |
107 | void *functionPointer = lib->resolve(resolveString); | 108 | void *functionPointer = lib->resolve(resolveString); |
108 | if( !functionPointer ){ | 109 | if( !functionPointer ){ |
109 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 110 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
110 | delete lib; | 111 | delete lib; |
111 | return NULL; | 112 | return NULL; |
112 | } | 113 | } |
113 | 114 | ||
114 | // Try to get an object. | 115 | // Try to get an object. |
115 | Module *object = ((Module* (*)()) functionPointer)(); | 116 | Module *object = ((Module* (*)()) functionPointer)(); |
116 | if(object == NULL){ | 117 | if(object == NULL){ |
117 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 118 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
118 | delete lib; | 119 | delete lib; |
119 | return NULL; | 120 | return NULL; |
120 | } | 121 | } |
121 | 122 | ||
122 | // Store for deletion later | 123 | // Store for deletion later |
123 | libraries.insert(object, lib); | 124 | libraries.insert(object, lib); |
124 | return object; | 125 | return object; |
125 | } | 126 | } |
126 | 127 | ||
127 | /** | 128 | /** |
128 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 129 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
129 | * load the plugin and append it to the list | 130 | * load the plugin and append it to the list |
130 | */ | 131 | */ |
131 | void MainWindowImp::addClicked(){ | 132 | void MainWindowImp::addClicked(){ |
132 | QMap<Module*, QLibrary*>::Iterator it; | 133 | QMap<Module*, QLibrary*>::Iterator it; |
133 | QMap<QString, QString> list; | 134 | QMap<QString, QString> list; |
134 | QMap<QString, Module*> newInterfaceOwners; | 135 | QMap<QString, Module*> newInterfaceOwners; |
135 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); | 136 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); |
136 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); | 137 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); |
137 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 138 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
138 | if(it.key()){ | 139 | if(it.key()){ |
139 | (it.key())->possibleNewInterfaces(list); | 140 | (it.key())->possibleNewInterfaces(list); |
140 | } | 141 | } |
141 | } | 142 | } |
142 | // See if the list has anything that we can add. | 143 | // See if the list has anything that we can add. |
143 | if(list.count() == 0){ | 144 | if(list.count() == 0){ |
144 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); | 145 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); |
145 | return; | 146 | return; |
146 | } | 147 | } |
147 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 148 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
148 | addNewConnection.addConnections(list); | 149 | addNewConnection.addConnections(list); |
149 | addNewConnection.showMaximized(); | 150 | addNewConnection.showMaximized(); |
150 | if(QDialog::Accepted == addNewConnection.exec()){ | 151 | if(QDialog::Accepted == addNewConnection.exec()){ |
151 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 152 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
152 | if(!item) | 153 | if(!item) |
153 | return; | 154 | return; |
154 | 155 | ||
155 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 156 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
156 | if(it.key()){ | 157 | if(it.key()){ |
157 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 158 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
158 | if(i){ | 159 | if(i){ |
159 | interfaceNames.insert(i->getInterfaceName(), i); | 160 | interfaceNames.insert(i->getInterfaceName(), i); |
160 | updateInterface(i); | 161 | updateInterface(i); |
161 | } | 162 | } |
162 | } | 163 | } |
163 | } | 164 | } |
164 | } | 165 | } |
165 | } | 166 | } |
166 | 167 | ||
167 | /** | 168 | /** |
168 | * Prompt the user to see if they really want to do this. | 169 | * Prompt the user to see if they really want to do this. |
169 | * If they do then remove from the list and unload. | 170 | * If they do then remove from the list and unload. |
170 | */ | 171 | */ |
171 | void MainWindowImp::removeClicked(){ | 172 | void MainWindowImp::removeClicked(){ |
172 | QListViewItem *item = connectionList->currentItem(); | 173 | QListViewItem *item = connectionList->currentItem(); |
173 | if(!item) { | 174 | if(!item) { |
174 | QMessageBox::information(this, "Error","Please select an interface.", "Ok"); | 175 | QMessageBox::information(this, "Error","Please select an interface.", "Ok"); |
175 | return; | 176 | return; |
176 | } | 177 | } |
177 | 178 | ||
178 | Interface *i = interfaceItems[item]; | 179 | Interface *i = interfaceItems[item]; |
179 | if(i->getModuleOwner() == NULL){ | 180 | if(i->getModuleOwner() == NULL){ |
180 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); | 181 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); |
181 | } | 182 | } |
182 | else{ | 183 | else{ |
183 | if(!i->getModuleOwner()->remove(i)) | 184 | if(!i->getModuleOwner()->remove(i)) |
184 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); | 185 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); |
185 | else{ | 186 | else{ |
186 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); | 187 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); |
187 | // TODO memory managment.... | 188 | // TODO memory managment.... |
188 | // who deletes the interface? | 189 | // who deletes the interface? |
189 | } | 190 | } |
190 | } | 191 | } |
191 | } | 192 | } |
192 | 193 | ||
193 | /** | 194 | /** |
194 | * Pull up the configure about the currently selected interface. | 195 | * Pull up the configure about the currently selected interface. |
195 | * Report an error if no interface is selected. | 196 | * Report an error if no interface is selected. |
196 | * If the interface has a module owner then request its configure with a empty | 197 | * If the interface has a module owner then request its configure with a empty |
197 | * tab. If tab is !NULL then append the interfaces setup widget to it. | 198 | * tab. If tab is !NULL then append the interfaces setup widget to it. |
198 | */ | 199 | */ |
199 | void MainWindowImp::configureClicked(){ | 200 | void MainWindowImp::configureClicked(){ |
200 | QListViewItem *item = connectionList->currentItem(); | 201 | QListViewItem *item = connectionList->currentItem(); |
201 | if(!item){ | 202 | if(!item){ |
202 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); | 203 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); |
203 | return; | 204 | return; |
204 | } | 205 | } |
205 | 206 | ||
206 | Interface *i = interfaceItems[item]; | 207 | Interface *i = interfaceItems[item]; |
207 | if(i->getModuleOwner()){ | 208 | if(i->getModuleOwner()){ |
208 | QTabWidget *tabWidget = NULL; | 209 | QTabWidget *tabWidget = NULL; |
209 | QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); | 210 | QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); |
210 | if(moduleConfigure != NULL){ | 211 | if(moduleConfigure != NULL){ |
211 | if(tabWidget != NULL){ | 212 | if(tabWidget != NULL){ |
212 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); | 213 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); |
213 | tabWidget->insertTab(configure, "TCP/IP"); | 214 | tabWidget->insertTab(configure, "TCP/IP"); |
214 | } | 215 | } |
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 3715da0..36f12e0 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -1,214 +1,215 @@ | |||
1 | #include "mainwindowimp.h" | 1 | #include "mainwindowimp.h" |
2 | #include "addconnectionimp.h" | 2 | #include "addconnectionimp.h" |
3 | #include "interfaceinformationimp.h" | 3 | #include "interfaceinformationimp.h" |
4 | #include "interfacesetupimp.h" | 4 | #include "interfacesetupimp.h" |
5 | #include "module.h" | 5 | #include "module.h" |
6 | 6 | ||
7 | #include "kprocess.h" | 7 | #include "kprocess.h" |
8 | 8 | ||
9 | #include <qpushbutton.h> | 9 | #include <qpushbutton.h> |
10 | #include <qtabwidget.h> | 10 | #include <qtabwidget.h> |
11 | #include <qlistbox.h> | 11 | #include <qlistbox.h> |
12 | #include <qlineedit.h> | 12 | #include <qlineedit.h> |
13 | #include <qlistview.h> | 13 | #include <qlistview.h> |
14 | #include <qheader.h> | 14 | #include <qheader.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | 16 | ||
17 | #include <qmainwindow.h> | 17 | #include <qmainwindow.h> |
18 | #include <qmessagebox.h> | 18 | #include <qmessagebox.h> |
19 | 19 | ||
20 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
21 | #include <qpe/qlibrary.h> | 21 | #include <qpe/qlibrary.h> |
22 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
23 | #include <qpe/qpeapplication.h> | ||
23 | 24 | ||
24 | #include <qlist.h> | 25 | #include <qlist.h> |
25 | #include <qdir.h> | 26 | #include <qdir.h> |
26 | #include <qfile.h> | 27 | #include <qfile.h> |
27 | #include <qtextstream.h> | 28 | #include <qtextstream.h> |
28 | 29 | ||
29 | #define TEMP_ALL "/tmp/ifconfig-a" | 30 | #define TEMP_ALL "/tmp/ifconfig-a" |
30 | #define TEMP_UP "/tmp/ifconfig" | 31 | #define TEMP_UP "/tmp/ifconfig" |
31 | 32 | ||
32 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ | 33 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ |
33 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 34 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
34 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 35 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
35 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 36 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
36 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 37 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); |
37 | 38 | ||
38 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 39 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
39 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 40 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
40 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 41 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
41 | 42 | ||
42 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 43 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
43 | // Load connections. | 44 | // Load connections. |
44 | loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); | 45 | loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); |
45 | getInterfaceList(); | 46 | getInterfaceList(); |
46 | connectionList->header()->hide(); | 47 | connectionList->header()->hide(); |
47 | 48 | ||
48 | 49 | ||
49 | Config cfg("NetworkSetup"); | 50 | Config cfg("NetworkSetup"); |
50 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 51 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
51 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 52 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
52 | profilesList->insertItem((*it)); | 53 | profilesList->insertItem((*it)); |
53 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 54 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
54 | } | 55 | } |
55 | 56 | ||
56 | /** | 57 | /** |
57 | * Deconstructor. Save profiles. Delete loaded libraries. | 58 | * Deconstructor. Save profiles. Delete loaded libraries. |
58 | */ | 59 | */ |
59 | MainWindowImp::~MainWindowImp(){ | 60 | MainWindowImp::~MainWindowImp(){ |
60 | // Save profiles. | 61 | // Save profiles. |
61 | if(profiles.count() > 1){ | 62 | if(profiles.count() > 1){ |
62 | Config cfg("NetworkSetup"); | 63 | Config cfg("NetworkSetup"); |
63 | cfg.setGroup("General"); | 64 | cfg.setGroup("General"); |
64 | cfg.writeEntry("Profiles", profiles.join(" ")); | 65 | cfg.writeEntry("Profiles", profiles.join(" ")); |
65 | } | 66 | } |
66 | // Delete Modules and Libraries | 67 | // Delete Modules and Libraries |
67 | QMap<Module*, QLibrary*>::Iterator it; | 68 | QMap<Module*, QLibrary*>::Iterator it; |
68 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 69 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
69 | delete it.key(); | 70 | delete it.key(); |
70 | delete it.data(); | 71 | delete it.data(); |
71 | } | 72 | } |
72 | } | 73 | } |
73 | 74 | ||
74 | /** | 75 | /** |
75 | * Load all modules that are found in the path | 76 | * Load all modules that are found in the path |
76 | * @param path a directory that is scaned for any plugins that can be loaded | 77 | * @param path a directory that is scaned for any plugins that can be loaded |
77 | * and attempts to load them | 78 | * and attempts to load them |
78 | */ | 79 | */ |
79 | void MainWindowImp::loadModules(QString path){ | 80 | void MainWindowImp::loadModules(QString path){ |
80 | qDebug(path.latin1()); | 81 | qDebug(path.latin1()); |
81 | QDir d(path); | 82 | QDir d(path); |
82 | if(!d.exists()) | 83 | if(!d.exists()) |
83 | return; | 84 | return; |
84 | 85 | ||
85 | // Don't want sym links | 86 | // Don't want sym links |
86 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 87 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
87 | const QFileInfoList *list = d.entryInfoList(); | 88 | const QFileInfoList *list = d.entryInfoList(); |
88 | QFileInfoListIterator it( *list ); | 89 | QFileInfoListIterator it( *list ); |
89 | QFileInfo *fi; | 90 | QFileInfo *fi; |
90 | while ( (fi=it.current()) ) { | 91 | while ( (fi=it.current()) ) { |
91 | if(fi->fileName().contains(".so")){ | 92 | if(fi->fileName().contains(".so")){ |
92 | loadPlugin(path + "/" + fi->fileName()); | 93 | loadPlugin(path + "/" + fi->fileName()); |
93 | } | 94 | } |
94 | ++it; | 95 | ++it; |
95 | } | 96 | } |
96 | } | 97 | } |
97 | 98 | ||
98 | /** | 99 | /** |
99 | * Attempt to load a function and resolve a function. | 100 | * Attempt to load a function and resolve a function. |
100 | * @param pluginFileName - the name of the file in which to attempt to load | 101 | * @param pluginFileName - the name of the file in which to attempt to load |
101 | * @param resolveString - function pointer to resolve | 102 | * @param resolveString - function pointer to resolve |
102 | * @return pointer to the function with name resolveString or NULL | 103 | * @return pointer to the function with name resolveString or NULL |
103 | */ | 104 | */ |
104 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ | 105 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ |
105 | qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); | 106 | qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); |
106 | QLibrary *lib = new QLibrary(pluginFileName); | 107 | QLibrary *lib = new QLibrary(pluginFileName); |
107 | void *functionPointer = lib->resolve(resolveString); | 108 | void *functionPointer = lib->resolve(resolveString); |
108 | if( !functionPointer ){ | 109 | if( !functionPointer ){ |
109 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 110 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
110 | delete lib; | 111 | delete lib; |
111 | return NULL; | 112 | return NULL; |
112 | } | 113 | } |
113 | 114 | ||
114 | // Try to get an object. | 115 | // Try to get an object. |
115 | Module *object = ((Module* (*)()) functionPointer)(); | 116 | Module *object = ((Module* (*)()) functionPointer)(); |
116 | if(object == NULL){ | 117 | if(object == NULL){ |
117 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 118 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
118 | delete lib; | 119 | delete lib; |
119 | return NULL; | 120 | return NULL; |
120 | } | 121 | } |
121 | 122 | ||
122 | // Store for deletion later | 123 | // Store for deletion later |
123 | libraries.insert(object, lib); | 124 | libraries.insert(object, lib); |
124 | return object; | 125 | return object; |
125 | } | 126 | } |
126 | 127 | ||
127 | /** | 128 | /** |
128 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 129 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
129 | * load the plugin and append it to the list | 130 | * load the plugin and append it to the list |
130 | */ | 131 | */ |
131 | void MainWindowImp::addClicked(){ | 132 | void MainWindowImp::addClicked(){ |
132 | QMap<Module*, QLibrary*>::Iterator it; | 133 | QMap<Module*, QLibrary*>::Iterator it; |
133 | QMap<QString, QString> list; | 134 | QMap<QString, QString> list; |
134 | QMap<QString, Module*> newInterfaceOwners; | 135 | QMap<QString, Module*> newInterfaceOwners; |
135 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); | 136 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); |
136 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); | 137 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); |
137 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 138 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
138 | if(it.key()){ | 139 | if(it.key()){ |
139 | (it.key())->possibleNewInterfaces(list); | 140 | (it.key())->possibleNewInterfaces(list); |
140 | } | 141 | } |
141 | } | 142 | } |
142 | // See if the list has anything that we can add. | 143 | // See if the list has anything that we can add. |
143 | if(list.count() == 0){ | 144 | if(list.count() == 0){ |
144 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); | 145 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); |
145 | return; | 146 | return; |
146 | } | 147 | } |
147 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 148 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
148 | addNewConnection.addConnections(list); | 149 | addNewConnection.addConnections(list); |
149 | addNewConnection.showMaximized(); | 150 | addNewConnection.showMaximized(); |
150 | if(QDialog::Accepted == addNewConnection.exec()){ | 151 | if(QDialog::Accepted == addNewConnection.exec()){ |
151 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 152 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
152 | if(!item) | 153 | if(!item) |
153 | return; | 154 | return; |
154 | 155 | ||
155 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 156 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
156 | if(it.key()){ | 157 | if(it.key()){ |
157 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 158 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
158 | if(i){ | 159 | if(i){ |
159 | interfaceNames.insert(i->getInterfaceName(), i); | 160 | interfaceNames.insert(i->getInterfaceName(), i); |
160 | updateInterface(i); | 161 | updateInterface(i); |
161 | } | 162 | } |
162 | } | 163 | } |
163 | } | 164 | } |
164 | } | 165 | } |
165 | } | 166 | } |
166 | 167 | ||
167 | /** | 168 | /** |
168 | * Prompt the user to see if they really want to do this. | 169 | * Prompt the user to see if they really want to do this. |
169 | * If they do then remove from the list and unload. | 170 | * If they do then remove from the list and unload. |
170 | */ | 171 | */ |
171 | void MainWindowImp::removeClicked(){ | 172 | void MainWindowImp::removeClicked(){ |
172 | QListViewItem *item = connectionList->currentItem(); | 173 | QListViewItem *item = connectionList->currentItem(); |
173 | if(!item) { | 174 | if(!item) { |
174 | QMessageBox::information(this, "Error","Please select an interface.", "Ok"); | 175 | QMessageBox::information(this, "Error","Please select an interface.", "Ok"); |
175 | return; | 176 | return; |
176 | } | 177 | } |
177 | 178 | ||
178 | Interface *i = interfaceItems[item]; | 179 | Interface *i = interfaceItems[item]; |
179 | if(i->getModuleOwner() == NULL){ | 180 | if(i->getModuleOwner() == NULL){ |
180 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); | 181 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); |
181 | } | 182 | } |
182 | else{ | 183 | else{ |
183 | if(!i->getModuleOwner()->remove(i)) | 184 | if(!i->getModuleOwner()->remove(i)) |
184 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); | 185 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); |
185 | else{ | 186 | else{ |
186 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); | 187 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); |
187 | // TODO memory managment.... | 188 | // TODO memory managment.... |
188 | // who deletes the interface? | 189 | // who deletes the interface? |
189 | } | 190 | } |
190 | } | 191 | } |
191 | } | 192 | } |
192 | 193 | ||
193 | /** | 194 | /** |
194 | * Pull up the configure about the currently selected interface. | 195 | * Pull up the configure about the currently selected interface. |
195 | * Report an error if no interface is selected. | 196 | * Report an error if no interface is selected. |
196 | * If the interface has a module owner then request its configure with a empty | 197 | * If the interface has a module owner then request its configure with a empty |
197 | * tab. If tab is !NULL then append the interfaces setup widget to it. | 198 | * tab. If tab is !NULL then append the interfaces setup widget to it. |
198 | */ | 199 | */ |
199 | void MainWindowImp::configureClicked(){ | 200 | void MainWindowImp::configureClicked(){ |
200 | QListViewItem *item = connectionList->currentItem(); | 201 | QListViewItem *item = connectionList->currentItem(); |
201 | if(!item){ | 202 | if(!item){ |
202 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); | 203 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); |
203 | return; | 204 | return; |
204 | } | 205 | } |
205 | 206 | ||
206 | Interface *i = interfaceItems[item]; | 207 | Interface *i = interfaceItems[item]; |
207 | if(i->getModuleOwner()){ | 208 | if(i->getModuleOwner()){ |
208 | QTabWidget *tabWidget = NULL; | 209 | QTabWidget *tabWidget = NULL; |
209 | QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); | 210 | QWidget *moduleConfigure = i->getModuleOwner()->configure(&tabWidget); |
210 | if(moduleConfigure != NULL){ | 211 | if(moduleConfigure != NULL){ |
211 | if(tabWidget != NULL){ | 212 | if(tabWidget != NULL){ |
212 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); | 213 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); |
213 | tabWidget->insertTab(configure, "TCP/IP"); | 214 | tabWidget->insertTab(configure, "TCP/IP"); |
214 | } | 215 | } |