author | ar <ar> | 2004-02-21 18:32:37 (UTC) |
---|---|---|
committer | ar <ar> | 2004-02-21 18:32:37 (UTC) |
commit | 536f271b1e6a1d1886e96a28524a3503c4c38c4e (patch) (unidiff) | |
tree | 63b3c0ce472a89a0f9731195fececc701bf4ca67 /noncore/settings/networksettings/mainwindowimp.cpp | |
parent | db2afda83e495bff9fc19fa14a30072f1cd4c67a (diff) | |
download | opie-536f271b1e6a1d1886e96a28524a3503c4c38c4e.zip opie-536f271b1e6a1d1886e96a28524a3503c4c38c4e.tar.gz opie-536f271b1e6a1d1886e96a28524a3503c4c38c4e.tar.bz2 |
improve support for BigScreen
Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 1040 |
1 files changed, 555 insertions, 485 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index d9752ce..b0a1dd9 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -1,2 +1,3 @@ | |||
1 | |||
1 | #include "mainwindowimp.h" | 2 | #include "mainwindowimp.h" |
2 | #include "addconnectionimp.h" | 3 | #include "addconnectionimp.h" |
@@ -6,4 +7,12 @@ | |||
6 | #include "module.h" | 7 | #include "module.h" |
7 | 8 | ||
9 | /* OPIE */ | ||
10 | #include <qpe/qcopenvelope_qws.h> | ||
11 | #include <qpe/qpeapplication.h> | ||
12 | #include <qpe/config.h> | ||
13 | #include <qpe/qlibrary.h> | ||
14 | #include <qpe/resource.h> | ||
15 | |||
16 | /* QT */ | ||
8 | #include <qpushbutton.h> | 17 | #include <qpushbutton.h> |
9 | #include <qlistbox.h> | 18 | #include <qlistbox.h> |
@@ -12,25 +21,7 @@ | |||
12 | #include <qheader.h> | 21 | #include <qheader.h> |
13 | #include <qlabel.h> | 22 | #include <qlabel.h> |
14 | #include <qpe/qcopenvelope_qws.h> | ||
15 | #include <qtabwidget.h> // in order to disable the profiles tab | 23 | #include <qtabwidget.h> // in order to disable the profiles tab |
16 | #include <qpe/qpeapplication.h> | ||
17 | |||
18 | #include <qmessagebox.h> | 24 | #include <qmessagebox.h> |
19 | 25 | ||
20 | #ifdef QWS | ||
21 | #include <qpe/config.h> | ||
22 | #include <qpe/qlibrary.h> | ||
23 | #include <qpe/resource.h> | ||
24 | #include <qpe/qpeapplication.h> | ||
25 | #else | ||
26 | #include <klibloader.h> | ||
27 | #define QLibrary KLibrary | ||
28 | #include <kconfig.h> | ||
29 | #define Config KConfig | ||
30 | #include <kapplication.h> | ||
31 | #include <kstandarddirs.h> | ||
32 | #include <kiconloader.h> | ||
33 | #define showMaximized show | ||
34 | #endif | ||
35 | 26 | ||
36 | #if QT_VERSION < 300 | 27 | #if QT_VERSION < 300 |
@@ -44,4 +35,5 @@ | |||
44 | #include <qregexp.h> | 35 | #include <qregexp.h> |
45 | 36 | ||
37 | /* STD */ | ||
46 | #include <net/if.h> | 38 | #include <net/if.h> |
47 | #include <sys/ioctl.h> | 39 | #include <sys/ioctl.h> |
@@ -51,84 +43,93 @@ | |||
51 | #define _PROCNETDEV "/proc/net/dev" | 43 | #define _PROCNETDEV "/proc/net/dev" |
52 | 44 | ||
53 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME){ | 45 | MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME) |
54 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); | 46 | { |
55 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); | 47 | connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); |
56 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); | 48 | connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); |
57 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | 49 | connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); |
50 | connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); | ||
58 | 51 | ||
59 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 52 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
60 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 53 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
61 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 54 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
62 | 55 | ||
63 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 56 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
64 | 57 | ||
65 | //FIXME: disable profiles for the moment: | 58 | //FIXME: disable profiles for the moment: |
66 | tabWidget->setTabEnabled( tab, false ); | 59 | tabWidget->setTabEnabled( tab, false ); |
67 | 60 | ||
68 | // Load connections. | 61 | // Load connections. |
69 | // /usr/local/kde/lib/libinterfaces.la | 62 | // /usr/local/kde/lib/libinterfaces.la |
70 | #ifdef QWS | 63 | #ifdef QWS |
71 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); | 64 | loadModules(QPEApplication::qpeDir() + "plugins/networksettings"); |
72 | #else | 65 | #else |
73 | loader = KLibLoader::self(); | 66 | loader = KLibLoader::self(); |
74 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); | 67 | loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); |
75 | #endif | 68 | #endif |
76 | getAllInterfaces(); | 69 | getAllInterfaces(); |
77 | 70 | ||
78 | Interfaces i; | 71 | Interfaces i; |
79 | QStringList list = i.getInterfaceList(); | 72 | QStringList list = i.getInterfaceList(); |
80 | QMap<QString, Interface*>::Iterator it; | 73 | QMap<QString, Interface*>::Iterator it; |
81 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 74 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) |
82 | /* | 75 | { |
83 | * we skipped it in getAllInterfaces now | 76 | /* |
84 | * we need to ignore it as well | 77 | * we skipped it in getAllInterfaces now |
85 | */ | 78 | * we need to ignore it as well |
86 | if (m_handledIfaces.contains( *ni) ) { | 79 | */ |
87 | qDebug("Not up iface handled by module"); | 80 | if (m_handledIfaces.contains( *ni) ) |
88 | continue; | 81 | { |
89 | } | 82 | qDebug("Not up iface handled by module"); |
90 | bool found = false; | 83 | continue; |
91 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 84 | } |
92 | if(it.key() == (*ni)) | 85 | bool found = false; |
93 | found = true; | 86 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ) |
94 | } | 87 | { |
95 | if(!found){ | 88 | if(it.key() == (*ni)) |
96 | if(!(*ni).contains("_")){ | 89 | found = true; |
97 | Interface *i = new Interface(this, *ni, false); | 90 | } |
98 | i->setAttached(false); | 91 | if(!found) |
99 | i->setHardwareName(tr("Disconnected")); | 92 | { |
100 | interfaceNames.insert(i->getInterfaceName(), i); | 93 | if(!(*ni).contains("_")) |
101 | updateInterface(i); | 94 | { |
102 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 95 | Interface *i = new Interface(this, *ni, false); |
103 | } | 96 | i->setAttached(false); |
104 | } | 97 | i->setHardwareName(tr("Disconnected")); |
105 | } | 98 | interfaceNames.insert(i->getInterfaceName(), i); |
106 | 99 | updateInterface(i); | |
107 | //getInterfaceList(); | 100 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
108 | connectionList->header()->hide(); | 101 | } |
109 | 102 | } | |
110 | Config cfg("NetworkSetup"); | 103 | } |
111 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 104 | |
112 | for ( QStringList::Iterator it = profiles.begin(); | 105 | //getInterfaceList(); |
113 | it != profiles.end(); ++it) | 106 | connectionList->header()->hide(); |
114 | profilesList->insertItem((*it)); | 107 | |
115 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 108 | Config cfg("NetworkSetup"); |
116 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 109 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
117 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 110 | for ( QStringList::Iterator it = profiles.begin(); |
118 | 111 | it != profiles.end(); ++it) | |
119 | QFile file(scheme); | 112 | profilesList->insertItem((*it)); |
120 | if ( file.open(IO_ReadOnly) ) { // file opened successfully | 113 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
121 | QTextStream stream( &file ); // use a text stream | 114 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
122 | while ( !stream.eof() ) { // until end of file... | 115 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
123 | QString line = stream.readLine(); // line of text excluding '\n' | 116 | |
124 | if(line.contains("SCHEME")){ | 117 | QFile file(scheme); |
125 | line = line.mid(7, line.length()); | 118 | if ( file.open(IO_ReadOnly) ) |
126 | currentProfileLabel->setText(line); | 119 | { // file opened successfully |
127 | break; | 120 | QTextStream stream( &file ); // use a text stream |
128 | } | 121 | while ( !stream.eof() ) |
129 | } | 122 | { // until end of file... |
130 | file.close(); | 123 | QString line = stream.readLine(); // line of text excluding '\n' |
131 | } | 124 | if(line.contains("SCHEME")) |
132 | makeChannel(); | 125 | { |
126 | line = line.mid(7, line.length()); | ||
127 | currentProfileLabel->setText(line); | ||
128 | break; | ||
129 | } | ||
130 | } | ||
131 | file.close(); | ||
132 | } | ||
133 | makeChannel(); | ||
133 | } | 134 | } |
134 | 135 | ||
@@ -136,28 +137,31 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWi | |||
136 | * Deconstructor. Save profiles. Delete loaded libraries. | 137 | * Deconstructor. Save profiles. Delete loaded libraries. |
137 | */ | 138 | */ |
138 | MainWindowImp::~MainWindowImp(){ | 139 | MainWindowImp::~MainWindowImp() |
139 | // Save profiles. | 140 | { |
140 | Config cfg("NetworkSetup"); | 141 | // Save profiles. |
141 | cfg.setGroup("General"); | 142 | Config cfg("NetworkSetup"); |
142 | cfg.writeEntry("Profiles", profiles.join(" ")); | 143 | cfg.setGroup("General"); |
143 | 144 | cfg.writeEntry("Profiles", profiles.join(" ")); | |
144 | // Delete all interfaces that don't have owners. | 145 | |
145 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 146 | // Delete all interfaces that don't have owners. |
146 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ | 147 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
147 | if(iIt.key()->getModuleOwner() == NULL) | 148 | for( iIt = items.begin(); iIt != items.end(); ++iIt ) |
148 | delete iIt.key(); | 149 | { |
149 | } | 150 | if(iIt.key()->getModuleOwner() == NULL) |
151 | delete iIt.key(); | ||
152 | } | ||
150 | 153 | ||
151 | #ifdef QWS | 154 | #ifdef QWS |
152 | // Delete Modules and Libraries | 155 | // Delete Modules and Libraries |
153 | QMap<Module*, QLibrary*>::Iterator it; | 156 | QMap<Module*, QLibrary*>::Iterator it; |
154 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 157 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
155 | delete it.key(); | 158 | { |
156 | // I wonder why I can't delete the libraries | 159 | delete it.key(); |
157 | // What fucking shit this is. | 160 | // I wonder why I can't delete the libraries |
158 | //delete it.data(); | 161 | // What fucking shit this is. |
159 | } | 162 | //delete it.data(); |
163 | } | ||
160 | #else | 164 | #else |
161 | // klibloader automaticly deletes the libraries for us... | 165 | // klibloader automaticly deletes the libraries for us... |
162 | #endif | 166 | #endif |
163 | } | 167 | } |
@@ -166,96 +170,108 @@ MainWindowImp::~MainWindowImp(){ | |||
166 | * Query the kernel for all of the interfaces. | 170 | * Query the kernel for all of the interfaces. |
167 | */ | 171 | */ |
168 | void MainWindowImp::getAllInterfaces(){ | 172 | void MainWindowImp::getAllInterfaces() |
169 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); | 173 | { |
170 | if(sockfd == -1) | 174 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); |
171 | return; | 175 | if(sockfd == -1) |
172 | 176 | return; | |
173 | struct ifreq ifr; | 177 | |
174 | QStringList ifaces; | 178 | struct ifreq ifr; |
175 | QFile procFile(QString(_PROCNETDEV)); | 179 | QStringList ifaces; |
176 | int result; | 180 | QFile procFile(QString(_PROCNETDEV)); |
177 | Interface *i; | 181 | int result; |
178 | 182 | Interface *i; | |
179 | if (! procFile.exists()) { | 183 | |
180 | struct ifreq ifrs[100]; | 184 | if (! procFile.exists()) |
181 | struct ifconf ifc; | 185 | { |
182 | ifc.ifc_len = sizeof(ifrs); | 186 | struct ifreq ifrs[100]; |
183 | ifc.ifc_req = ifrs; | 187 | struct ifconf ifc; |
184 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); | 188 | ifc.ifc_len = sizeof(ifrs); |
185 | 189 | ifc.ifc_req = ifrs; | |
186 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { | 190 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); |
187 | struct ifreq *pifr = &ifrs[i]; | 191 | |
188 | 192 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) | |
189 | ifaces += pifr->ifr_name; | 193 | { |
190 | } | 194 | struct ifreq *pifr = &ifrs[i]; |
191 | } else { | 195 | |
192 | procFile.open(IO_ReadOnly); | 196 | ifaces += pifr->ifr_name; |
193 | QString line; | 197 | } |
194 | QTextStream procTs(&procFile); | 198 | } |
195 | int loc = -1; | ||
196 | |||
197 | procTs.readLine(); // eat a line | ||
198 | procTs.readLine(); // eat a line | ||
199 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { | ||
200 | if((loc = line.find(":")) != -1) { | ||
201 | ifaces += line.left(loc); | ||
202 | } | ||
203 | } | ||
204 | } | ||
205 | |||
206 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { | ||
207 | int flags = 0; | ||
208 | if ( m_handledIfaces.contains( (*it) ) ) { | ||
209 | qDebug(" %s is handled by a module", (*it).latin1() ); | ||
210 | continue; | ||
211 | } | ||
212 | // int family; | ||
213 | i = NULL; | ||
214 | |||
215 | strcpy(ifr.ifr_name, (*it).latin1()); | ||
216 | |||
217 | struct ifreq ifcopy; | ||
218 | ifcopy = ifr; | ||
219 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); | ||
220 | flags = ifcopy.ifr_flags; | ||
221 | i = new Interface(this, ifr.ifr_name, false); | ||
222 | i->setAttached(true); | ||
223 | if ((flags & IFF_UP) == IFF_UP) | ||
224 | i->setStatus(true); | ||
225 | else | ||
226 | i->setStatus(false); | ||
227 | |||
228 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) | ||
229 | i->setHardwareName("Ethernet"); | ||
230 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) | ||
231 | i->setHardwareName("Point to Point"); | ||
232 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) | ||
233 | i->setHardwareName("Multicast"); | ||
234 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) | ||
235 | i->setHardwareName("Loopback"); | ||
236 | else | 199 | else |
237 | i->setHardwareName("Unknown"); | 200 | { |
238 | 201 | procFile.open(IO_ReadOnly); | |
239 | qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); | 202 | QString line; |
240 | interfaceNames.insert(i->getInterfaceName(), i); | 203 | QTextStream procTs(&procFile); |
241 | updateInterface(i); | 204 | int loc = -1; |
242 | connect(i, SIGNAL(updateInterface(Interface *)), | 205 | |
243 | this, SLOT(updateInterface(Interface *))); | 206 | procTs.readLine(); // eat a line |
244 | } | 207 | procTs.readLine(); // eat a line |
245 | // now lets ask the plugins too ;) | 208 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) |
246 | QMap<Module*, QLibrary*>::Iterator it; | 209 | { |
247 | QList<Interface> ilist; | 210 | if((loc = line.find(":")) != -1) |
248 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 211 | { |
249 | if(it.key()){ | 212 | ifaces += line.left(loc); |
250 | ilist = it.key()->getInterfaces(); | 213 | } |
251 | for( i = ilist.first(); i != 0; i = ilist.next() ){ | 214 | } |
252 | qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); | 215 | } |
253 | interfaceNames.insert(i->getInterfaceName(), i); | 216 | |
254 | updateInterface(i); | 217 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) |
255 | connect(i, SIGNAL(updateInterface(Interface *)), | 218 | { |
256 | this, SLOT(updateInterface(Interface *))); | 219 | int flags = 0; |
220 | if ( m_handledIfaces.contains( (*it) ) ) | ||
221 | { | ||
222 | qDebug(" %s is handled by a module", (*it).latin1() ); | ||
223 | continue; | ||
224 | } | ||
225 | // int family; | ||
226 | i = NULL; | ||
227 | |||
228 | strcpy(ifr.ifr_name, (*it).latin1()); | ||
229 | |||
230 | struct ifreq ifcopy; | ||
231 | ifcopy = ifr; | ||
232 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); | ||
233 | flags = ifcopy.ifr_flags; | ||
234 | i = new Interface(this, ifr.ifr_name, false); | ||
235 | i->setAttached(true); | ||
236 | if ((flags & IFF_UP) == IFF_UP) | ||
237 | i->setStatus(true); | ||
238 | else | ||
239 | i->setStatus(false); | ||
240 | |||
241 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) | ||
242 | i->setHardwareName("Ethernet"); | ||
243 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) | ||
244 | i->setHardwareName("Point to Point"); | ||
245 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) | ||
246 | i->setHardwareName("Multicast"); | ||
247 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) | ||
248 | i->setHardwareName("Loopback"); | ||
249 | else | ||
250 | i->setHardwareName("Unknown"); | ||
251 | |||
252 | qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); | ||
253 | interfaceNames.insert(i->getInterfaceName(), i); | ||
254 | updateInterface(i); | ||
255 | connect(i, SIGNAL(updateInterface(Interface *)), | ||
256 | this, SLOT(updateInterface(Interface *))); | ||
257 | } | ||
258 | // now lets ask the plugins too ;) | ||
259 | QMap<Module*, QLibrary*>::Iterator it; | ||
260 | QList<Interface> ilist; | ||
261 | for( it = libraries.begin(); it != libraries.end(); ++it ) | ||
262 | { | ||
263 | if(it.key()) | ||
264 | { | ||
265 | ilist = it.key()->getInterfaces(); | ||
266 | for( i = ilist.first(); i != 0; i = ilist.next() ) | ||
267 | { | ||
268 | qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); | ||
269 | interfaceNames.insert(i->getInterfaceName(), i); | ||
270 | updateInterface(i); | ||
271 | connect(i, SIGNAL(updateInterface(Interface *)), | ||
272 | this, SLOT(updateInterface(Interface *))); | ||
273 | } | ||
257 | } | 274 | } |
258 | } | 275 | } |
259 | } | ||
260 | } | 276 | } |
261 | 277 | ||
@@ -265,28 +281,32 @@ void MainWindowImp::getAllInterfaces(){ | |||
265 | * and attempts to load them | 281 | * and attempts to load them |
266 | */ | 282 | */ |
267 | void MainWindowImp::loadModules(const QString &path){ | 283 | void MainWindowImp::loadModules(const QString &path) |
284 | { | ||
268 | #ifdef DEBUG | 285 | #ifdef DEBUG |
269 | qDebug("MainWindowImp::loadModules: %s", path.latin1()); | 286 | qDebug("MainWindowImp::loadModules: %s", path.latin1()); |
270 | #endif | 287 | #endif |
271 | QDir d(path); | 288 | QDir d(path); |
272 | if(!d.exists()) | 289 | if(!d.exists()) |
273 | return; | 290 | return; |
274 | 291 | ||
275 | // Don't want sym links | 292 | // Don't want sym links |
276 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 293 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
277 | const QFileInfoList *list = d.entryInfoList(); | 294 | const QFileInfoList *list = d.entryInfoList(); |
278 | QFileInfoListIterator it( *list ); | 295 | QFileInfoListIterator it( *list ); |
279 | QFileInfo *fi; | 296 | QFileInfo *fi; |
280 | while ( (fi=it.current()) ) { | 297 | while ( (fi=it.current()) ) |
298 | { | ||
281 | #ifdef QWS | 299 | #ifdef QWS |
282 | if(fi->fileName().contains(".so")){ | 300 | if(fi->fileName().contains(".so")) |
301 | { | ||
283 | #else | 302 | #else |
284 | if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){ | 303 | if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")) |
304 | { | ||
285 | #endif | 305 | #endif |
286 | loadPlugin(path + "/" + fi->fileName()); | 306 | loadPlugin(path + "/" + fi->fileName()); |
287 | qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); | 307 | qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1()); |
308 | } | ||
309 | ++it; | ||
288 | } | 310 | } |
289 | ++it; | ||
290 | } | ||
291 | } | 311 | } |
292 | 312 | ||
@@ -297,53 +317,58 @@ void MainWindowImp::loadModules(const QString &path){ | |||
297 | * @return pointer to the function with name resolveString or NULL | 317 | * @return pointer to the function with name resolveString or NULL |
298 | */ | 318 | */ |
299 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ | 319 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) |
320 | { | ||
300 | #ifdef DEBUG | 321 | #ifdef DEBUG |
301 | qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); | 322 | qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1()); |
302 | #endif | 323 | #endif |
303 | #ifdef QWS | 324 | #ifdef QWS |
304 | QLibrary *lib = new QLibrary(pluginFileName); | 325 | QLibrary *lib = new QLibrary(pluginFileName); |
305 | void *functionPointer = lib->resolve(resolveString); | 326 | void *functionPointer = lib->resolve(resolveString); |
306 | if( !functionPointer ){ | 327 | if( !functionPointer ) |
328 | { | ||
307 | #ifdef DEBUG | 329 | #ifdef DEBUG |
308 | qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); | 330 | qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1()); |
309 | #endif | 331 | #endif |
310 | delete lib; | 332 | delete lib; |
311 | return NULL; | 333 | return NULL; |
312 | } | 334 | } |
313 | // Try to get an object. | 335 | // Try to get an object. |
314 | Module *object = ((Module* (*)()) functionPointer)(); | 336 | Module *object = ((Module* (*)()) functionPointer)(); |
315 | if(object == NULL){ | 337 | if(object == NULL) |
338 | { | ||
316 | #ifdef DEBUG | 339 | #ifdef DEBUG |
317 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 340 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
318 | #endif | 341 | #endif |
319 | delete lib; | 342 | delete lib; |
320 | return NULL; | 343 | return NULL; |
321 | } | 344 | } |
322 | 345 | ||
323 | m_handledIfaces += object->handledInterfaceNames(); | 346 | m_handledIfaces += object->handledInterfaceNames(); |
324 | // Store for deletion later | 347 | // Store for deletion later |
325 | libraries.insert(object, lib); | 348 | libraries.insert(object, lib); |
326 | return object; | 349 | return object; |
327 | 350 | ||
328 | #else | 351 | #else |
329 | QLibrary *lib = loader->library(pluginFileName); | 352 | QLibrary *lib = loader->library(pluginFileName); |
330 | if( !lib || !lib->hasSymbol(resolveString) ){ | 353 | if( !lib || !lib->hasSymbol(resolveString) ) |
331 | qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 354 | { |
332 | return NULL; | 355 | qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
333 | } | 356 | return NULL; |
334 | // Try to get an object. | 357 | } |
335 | Module *object = ((Module* (*)()) lib->symbol(resolveString))(); | 358 | // Try to get an object. |
336 | if(object == NULL){ | 359 | Module *object = ((Module* (*)()) lib->symbol(resolveString))(); |
360 | if(object == NULL) | ||
361 | { | ||
337 | #ifdef DEBUG | 362 | #ifdef DEBUG |
338 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 363 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
339 | #endif | 364 | #endif |
340 | return NULL; | 365 | return NULL; |
341 | } | 366 | } |
342 | #ifdef DEBUG | 367 | #ifdef DEBUG |
343 | qDebug("MainWindowImp::loadPlugin:: Found object, storing."); | 368 | qDebug("MainWindowImp::loadPlugin:: Found object, storing."); |
344 | #endif | 369 | #endif |
345 | // Store for deletion later | 370 | // Store for deletion later |
346 | libraries.insert(object, lib); | 371 | libraries.insert(object, lib); |
347 | return object; | 372 | return object; |
348 | #endif | 373 | #endif |
349 | } | 374 | } |
@@ -353,38 +378,45 @@ Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString & | |||
353 | * load the plugin and append it to the list | 378 | * load the plugin and append it to the list |
354 | */ | 379 | */ |
355 | void MainWindowImp::addClicked(){ | 380 | void MainWindowImp::addClicked() |
356 | QMap<Module*, QLibrary*>::Iterator it; | 381 | { |
357 | QMap<QString, QString> list; | 382 | QMap<Module*, QLibrary*>::Iterator it; |
358 | QMap<QString, Module*> newInterfaceOwners; | 383 | QMap<QString, QString> list; |
359 | 384 | QMap<QString, Module*> newInterfaceOwners; | |
360 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 385 | |
361 | if(it.key()){ | 386 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
362 | (it.key())->possibleNewInterfaces(list); | 387 | { |
363 | } | 388 | if(it.key()) |
364 | } | 389 | { |
365 | // See if the list has anything that we can add. | 390 | (it.key())->possibleNewInterfaces(list); |
366 | if(list.count() == 0){ | 391 | } |
367 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); | 392 | } |
368 | return; | 393 | // See if the list has anything that we can add. |
369 | } | 394 | if(list.count() == 0) |
370 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 395 | { |
371 | addNewConnection.addConnections(list); | 396 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); |
372 | addNewConnection.showMaximized(); | 397 | return; |
373 | if(QDialog::Accepted == addNewConnection.exec()){ | 398 | } |
374 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 399 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
375 | if(!item) | 400 | addNewConnection.addConnections(list); |
376 | return; | 401 | if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) ) |
377 | 402 | { | |
378 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 403 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
379 | if(it.key()){ | 404 | if(!item) |
380 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 405 | return; |
381 | if(i){ | 406 | |
382 | qDebug("iface name %s",i->getInterfaceName().latin1()); | 407 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
383 | interfaceNames.insert(i->getInterfaceName(), i); | 408 | { |
384 | updateInterface(i); | 409 | if(it.key()) |
410 | { | ||
411 | Interface *i = (it.key())->addNewInterface(item->text(0)); | ||
412 | if(i) | ||
413 | { | ||
414 | qDebug("iface name %s",i->getInterfaceName().latin1()); | ||
415 | interfaceNames.insert(i->getInterfaceName(), i); | ||
416 | updateInterface(i); | ||
417 | } | ||
418 | } | ||
385 | } | 419 | } |
386 | } | ||
387 | } | 420 | } |
388 | } | ||
389 | } | 421 | } |
390 | 422 | ||
@@ -393,23 +425,28 @@ void MainWindowImp::addClicked(){ | |||
393 | * If they do then remove from the list and unload. | 425 | * If they do then remove from the list and unload. |
394 | */ | 426 | */ |
395 | void MainWindowImp::removeClicked(){ | 427 | void MainWindowImp::removeClicked() |
396 | QListViewItem *item = connectionList->currentItem(); | 428 | { |
397 | if(!item) { | 429 | QListViewItem *item = connectionList->currentItem(); |
398 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 430 | if(!item) |
399 | return; | 431 | { |
400 | } | 432 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
401 | 433 | return; | |
402 | Interface *i = interfaceItems[item]; | 434 | } |
403 | if(i->getModuleOwner() == NULL){ | 435 | |
404 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); | 436 | Interface *i = interfaceItems[item]; |
405 | } | 437 | if(i->getModuleOwner() == NULL) |
406 | else{ | 438 | { |
407 | if(!i->getModuleOwner()->remove(i)) | 439 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); |
408 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); | 440 | } |
409 | else{ | 441 | else |
410 | delete item; | 442 | { |
411 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); | 443 | if(!i->getModuleOwner()->remove(i)) |
412 | } | 444 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); |
413 | } | 445 | else |
446 | { | ||
447 | delete item; | ||
448 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); | ||
449 | } | ||
450 | } | ||
414 | } | 451 | } |
415 | 452 | ||
@@ -419,29 +456,33 @@ void MainWindowImp::removeClicked(){ | |||
419 | * If the interface has a module owner then request its configure. | 456 | * If the interface has a module owner then request its configure. |
420 | */ | 457 | */ |
421 | void MainWindowImp::configureClicked(){ | 458 | void MainWindowImp::configureClicked() |
422 | QListViewItem *item = connectionList->currentItem(); | 459 | { |
423 | if(!item){ | 460 | QListViewItem *item = connectionList->currentItem(); |
424 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); | 461 | if(!item) |
425 | return; | 462 | { |
426 | } | 463 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); |
427 | 464 | return; | |
428 | QString currentProfileText = currentProfileLabel->text(); | 465 | } |
429 | if(currentProfileText.upper() == "ALL"); | 466 | |
467 | QString currentProfileText = currentProfileLabel->text(); | ||
468 | if(currentProfileText.upper() == "ALL"); | ||
430 | currentProfileText = ""; | 469 | currentProfileText = ""; |
431 | 470 | ||
432 | Interface *i = interfaceItems[item]; | 471 | Interface *i = interfaceItems[item]; |
433 | 472 | ||
434 | if(i->getModuleOwner()){ | 473 | if(i->getModuleOwner()) |
435 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 474 | { |
436 | if(moduleConfigure != NULL){ | 475 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
437 | i->getModuleOwner()->setProfile(currentProfileText); | 476 | if(moduleConfigure != NULL) |
438 | moduleConfigure->showMaximized(); | 477 | { |
439 | return; | 478 | i->getModuleOwner()->setProfile(currentProfileText); |
479 | QPEApplication::showWidget( moduleConfigure ); | ||
480 | return; | ||
481 | } | ||
440 | } | 482 | } |
441 | } | ||
442 | 483 | ||
443 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); | 484 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); |
444 | configure->setProfile(currentProfileText); | 485 | configure->setProfile(currentProfileText); |
445 | configure->showMaximized(); | 486 | QPEApplication::showDialog( configure ); |
446 | } | 487 | } |
447 | 488 | ||
@@ -451,29 +492,33 @@ void MainWindowImp::configureClicked(){ | |||
451 | * If the interface has a module owner then request its configure. | 492 | * If the interface has a module owner then request its configure. |
452 | */ | 493 | */ |
453 | void MainWindowImp::informationClicked(){ | 494 | void MainWindowImp::informationClicked() |
454 | QListViewItem *item = connectionList->currentItem(); | 495 | { |
455 | if(!item){ | 496 | QListViewItem *item = connectionList->currentItem(); |
456 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 497 | if(!item) |
457 | return; | 498 | { |
458 | } | 499 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
459 | 500 | return; | |
460 | Interface *i = interfaceItems[item]; | 501 | } |
461 | // if(!i->isAttached()){ | 502 | |
462 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 503 | Interface *i = interfaceItems[item]; |
463 | // return; | 504 | // if(!i->isAttached()){ |
464 | // } | 505 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
465 | 506 | // return; | |
466 | if(i->getModuleOwner()){ | 507 | // } |
467 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 508 | |
468 | if(moduleInformation != NULL){ | 509 | if(i->getModuleOwner()) |
469 | moduleInformation->showMaximized(); | 510 | { |
511 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | ||
512 | if(moduleInformation != NULL) | ||
513 | { | ||
514 | QPEApplication::showWidget( moduleInformation ); | ||
470 | #ifdef DEBUG | 515 | #ifdef DEBUG |
471 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); | 516 | qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); |
472 | #endif | 517 | #endif |
473 | return; | 518 | return; |
519 | } | ||
474 | } | 520 | } |
475 | } | 521 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); |
476 | InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); | 522 | QPEApplication::showWidget( information ); |
477 | information->showMaximized(); | ||
478 | } | 523 | } |
479 | 524 | ||
@@ -482,65 +527,70 @@ void MainWindowImp::informationClicked(){ | |||
482 | * @param Interface* pointer to the interface that needs to be updated. | 527 | * @param Interface* pointer to the interface that needs to be updated. |
483 | */ | 528 | */ |
484 | void MainWindowImp::updateInterface(Interface *i){ | 529 | void MainWindowImp::updateInterface(Interface *i) |
485 | if(!advancedUserMode){ | 530 | { |
486 | if(i->getInterfaceName() == "lo") | 531 | if(!advancedUserMode) |
487 | return; | 532 | { |
488 | } | 533 | if(i->getInterfaceName() == "lo") |
489 | 534 | return; | |
490 | QListViewItem *item = NULL; | 535 | } |
491 | 536 | ||
492 | // Find the interface, making it if needed. | 537 | QListViewItem *item = NULL; |
493 | if(items.find(i) == items.end()){ | 538 | |
494 | item = new QListViewItem(connectionList, "", "", ""); | 539 | // Find the interface, making it if needed. |
495 | // See if you can't find a module owner for this interface | 540 | if(items.find(i) == items.end()) |
496 | QMap<Module*, QLibrary*>::Iterator it; | 541 | { |
497 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 542 | item = new QListViewItem(connectionList, "", "", ""); |
498 | if(it.key()->isOwner(i)) | 543 | // See if you can't find a module owner for this interface |
499 | i->setModuleOwner(it.key()); | 544 | QMap<Module*, QLibrary*>::Iterator it; |
545 | for( it = libraries.begin(); it != libraries.end(); ++it ) | ||
546 | { | ||
547 | if(it.key()->isOwner(i)) | ||
548 | i->setModuleOwner(it.key()); | ||
549 | } | ||
550 | items.insert(i, item); | ||
551 | interfaceItems.insert(item, i); | ||
500 | } | 552 | } |
501 | items.insert(i, item); | 553 | else |
502 | interfaceItems.insert(item, i); | 554 | item = items[i]; |
503 | } | ||
504 | else | ||
505 | item = items[i]; | ||
506 | 555 | ||
507 | // Update the icons and information | 556 | // Update the icons and information |
508 | #ifdef QWS | 557 | #ifdef QWS |
509 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 558 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
510 | #else | 559 | #else |
511 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); | 560 | item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); |
512 | #endif | 561 | #endif |
513 | 562 | ||
514 | QString typeName = "lan"; | 563 | QString typeName = "lan"; |
515 | if(i->getInterfaceName() == "lo") | 564 | if(i->getInterfaceName() == "lo") |
516 | typeName = "lo"; | 565 | typeName = "lo"; |
517 | if(i->getInterfaceName().contains("irda")) | 566 | if(i->getInterfaceName().contains("irda")) |
518 | typeName = "irda"; | 567 | typeName = "irda"; |
519 | if(i->getInterfaceName().contains("wlan")) | 568 | if(i->getInterfaceName().contains("wlan")) |
520 | typeName = "wlan"; | 569 | typeName = "wlan"; |
521 | if(i->getInterfaceName().contains("usb")) | 570 | if(i->getInterfaceName().contains("usb")) |
522 | typeName = "usb"; | 571 | typeName = "usb"; |
523 | 572 | ||
524 | if(!i->isAttached()) | 573 | if(!i->isAttached()) |
525 | typeName = "connect_no"; | 574 | typeName = "connect_no"; |
526 | // Actually try to use the Module | 575 | // Actually try to use the Module |
527 | if(i->getModuleOwner() != NULL) | 576 | if(i->getModuleOwner() != NULL) |
528 | typeName = i->getModuleOwner()->getPixmapName(i); | 577 | typeName = i->getModuleOwner()->getPixmapName(i); |
529 | 578 | ||
530 | #ifdef QWS | 579 | #ifdef QWS |
531 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); | 580 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); |
532 | #else | 581 | #else |
533 | item->setPixmap(1, (SmallIcon(typeName))); | 582 | item->setPixmap(1, (SmallIcon(typeName))); |
534 | #endif | 583 | #endif |
535 | item->setText(2, i->getHardwareName()); | 584 | item->setText(2, i->getHardwareName()); |
536 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); | 585 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); |
537 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | 586 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); |
538 | } | 587 | } |
539 | 588 | ||
540 | void MainWindowImp::newProfileChanged(const QString& newText){ | 589 | void MainWindowImp::newProfileChanged(const QString& newText) |
541 | if(newText.length() > 0) | 590 | { |
542 | newProfileButton->setEnabled(true); | 591 | if(newText.length() > 0) |
543 | else | 592 | newProfileButton->setEnabled(true); |
544 | newProfileButton->setEnabled(false); | 593 | else |
594 | newProfileButton->setEnabled(false); | ||
545 | } | 595 | } |
546 | 596 | ||
@@ -550,12 +600,14 @@ void MainWindowImp::newProfileChanged(const QString& newText){ | |||
550 | * Appends to the list and QStringList | 600 | * Appends to the list and QStringList |
551 | */ | 601 | */ |
552 | void MainWindowImp::addProfile(){ | 602 | void MainWindowImp::addProfile() |
553 | QString newProfileName = newProfile->text(); | 603 | { |
554 | if(profiles.grep(newProfileName).count() > 0){ | 604 | QString newProfileName = newProfile->text(); |
555 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); | 605 | if(profiles.grep(newProfileName).count() > 0) |
556 | return; | 606 | { |
557 | } | 607 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); |
558 | profiles.append(newProfileName); | 608 | return; |
559 | profilesList->insertItem(newProfileName); | 609 | } |
610 | profiles.append(newProfileName); | ||
611 | profilesList->insertItem(newProfileName); | ||
560 | } | 612 | } |
561 | 613 | ||
@@ -564,48 +616,57 @@ void MainWindowImp::addProfile(){ | |||
564 | * Doesn't delete if there are less then 2 profiles. | 616 | * Doesn't delete if there are less then 2 profiles. |
565 | */ | 617 | */ |
566 | void MainWindowImp::removeProfile(){ | 618 | void MainWindowImp::removeProfile() |
567 | if(profilesList->count() <= 1){ | 619 | { |
568 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); | 620 | if(profilesList->count() <= 1) |
569 | return; | 621 | { |
570 | } | 622 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); |
571 | QString profileToRemove = profilesList->currentText(); | 623 | return; |
572 | if(profileToRemove == "All"){ | 624 | } |
573 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); | 625 | QString profileToRemove = profilesList->currentText(); |
574 | return; | 626 | if(profileToRemove == "All") |
575 | } | 627 | { |
576 | // Can't remove the curent profile | 628 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); |
577 | if(profileToRemove == currentProfileLabel->text()){ | 629 | return; |
578 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); | 630 | } |
579 | return; | 631 | // Can't remove the curent profile |
580 | 632 | if(profileToRemove == currentProfileLabel->text()) | |
581 | } | 633 | { |
582 | 634 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); | |
583 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ | 635 | return; |
584 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 636 | |
585 | profilesList->clear(); | 637 | } |
586 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 638 | |
587 | profilesList->insertItem((*it)); | 639 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) |
588 | 640 | { | |
589 | // Remove any interface settings and mappings. | 641 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
590 | Interfaces interfaces; | 642 | profilesList->clear(); |
591 | // Go through them one by one | 643 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
592 | QMap<Interface*, QListViewItem*>::Iterator it; | 644 | profilesList->insertItem((*it)); |
593 | for( it = items.begin(); it != items.end(); ++it ){ | 645 | |
594 | QString interfaceName = it.key()->getInterfaceName(); | 646 | // Remove any interface settings and mappings. |
595 | qDebug(interfaceName.latin1()); | 647 | Interfaces interfaces; |
596 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ | 648 | // Go through them one by one |
597 | interfaces.removeInterface(); | 649 | QMap<Interface*, QListViewItem*>::Iterator it; |
598 | if(interfaces.setMapping(interfaceName)){ | 650 | for( it = items.begin(); it != items.end(); ++it ) |
599 | if(profilesList->count() == 1) | 651 | { |
600 | interfaces.removeMapping(); | 652 | QString interfaceName = it.key()->getInterfaceName(); |
601 | else{ | 653 | qDebug(interfaceName.latin1()); |
602 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | 654 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)) |
603 | } | 655 | { |
656 | interfaces.removeInterface(); | ||
657 | if(interfaces.setMapping(interfaceName)) | ||
658 | { | ||
659 | if(profilesList->count() == 1) | ||
660 | interfaces.removeMapping(); | ||
661 | else | ||
662 | { | ||
663 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | ||
664 | } | ||
665 | } | ||
666 | interfaces.write(); | ||
667 | break; | ||
668 | } | ||
604 | } | 669 | } |
605 | interfaces.write(); | ||
606 | break; | ||
607 | } | ||
608 | } | 670 | } |
609 | } | ||
610 | } | 671 | } |
611 | 672 | ||
@@ -614,30 +675,36 @@ void MainWindowImp::removeProfile(){ | |||
614 | * @param newProfile the new profile. | 675 | * @param newProfile the new profile. |
615 | */ | 676 | */ |
616 | void MainWindowImp::changeProfile(){ | 677 | void MainWindowImp::changeProfile() |
617 | if(profilesList->currentItem() == -1){ | 678 | { |
618 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); | 679 | if(profilesList->currentItem() == -1) |
619 | return; | 680 | { |
620 | } | 681 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); |
621 | QString newProfile = profilesList->text(profilesList->currentItem()); | 682 | return; |
622 | if(newProfile != currentProfileLabel->text()){ | 683 | } |
623 | currentProfileLabel->setText(newProfile); | 684 | QString newProfile = profilesList->text(profilesList->currentItem()); |
624 | QFile::remove(scheme); | 685 | if(newProfile != currentProfileLabel->text()) |
625 | QFile file(scheme); | 686 | { |
626 | if ( file.open(IO_ReadWrite) ) { | 687 | currentProfileLabel->setText(newProfile); |
627 | QTextStream stream( &file ); | 688 | QFile::remove(scheme); |
628 | stream << QString("SCHEME=%1").arg(newProfile); | 689 | QFile file(scheme); |
629 | file.close(); | 690 | if ( file.open(IO_ReadWrite) ) |
630 | } | 691 | { |
631 | // restart all up devices? | 692 | QTextStream stream( &file ); |
632 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ | 693 | stream << QString("SCHEME=%1").arg(newProfile); |
633 | // Go through them one by one | 694 | file.close(); |
634 | QMap<Interface*, QListViewItem*>::Iterator it; | 695 | } |
635 | for( it = items.begin(); it != items.end(); ++it ){ | 696 | // restart all up devices? |
636 | if(it.key()->getStatus() == true) | 697 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok) |
637 | it.key()->restart(); | 698 | { |
638 | } | 699 | // Go through them one by one |
639 | } | 700 | QMap<Interface*, QListViewItem*>::Iterator it; |
640 | } | 701 | for( it = items.begin(); it != items.end(); ++it ) |
641 | // TODO change the profile in the modules | 702 | { |
703 | if(it.key()->getStatus() == true) | ||
704 | it.key()->restart(); | ||
705 | } | ||
706 | } | ||
707 | } | ||
708 | // TODO change the profile in the modules | ||
642 | } | 709 | } |
643 | 710 | ||
@@ -645,7 +712,7 @@ void MainWindowImp::changeProfile(){ | |||
645 | void MainWindowImp::makeChannel() | 712 | void MainWindowImp::makeChannel() |
646 | { | 713 | { |
647 | channel = new QCopChannel( "QPE/Application/networksettings", this ); | 714 | channel = new QCopChannel( "QPE/Application/networksettings", this ); |
648 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 715 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
649 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 716 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
650 | } | 717 | } |
651 | 718 | ||
@@ -654,5 +721,6 @@ void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) | |||
654 | bool found = false; | 721 | bool found = false; |
655 | qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); | 722 | qDebug("MainWindowImp::receive QCop msg >"+msg+"<"); |
656 | if (msg == "raise") { | 723 | if (msg == "raise") |
724 | { | ||
657 | raise(); | 725 | raise(); |
658 | return; | 726 | return; |
@@ -664,15 +732,17 @@ void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) | |||
664 | qDebug("dest >%s< param >"+param+"<",dest.latin1()); | 732 | qDebug("dest >%s< param >"+param+"<",dest.latin1()); |
665 | 733 | ||
666 | QMap<Module*, QLibrary*>::Iterator it; | 734 | QMap<Module*, QLibrary*>::Iterator it; |
667 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 735 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
668 | qDebug("plugin >%s<", it.key()->type().latin1() ); | 736 | { |
669 | if(it.key()->type() == dest){ | 737 | qDebug("plugin >%s<", it.key()->type().latin1() ); |
670 | it.key()->receive( param, arg ); | 738 | if(it.key()->type() == dest) |
671 | found = true; | 739 | { |
672 | } | 740 | it.key()->receive( param, arg ); |
673 | } | 741 | found = true; |
742 | } | ||
743 | } | ||
674 | 744 | ||
675 | 745 | ||
676 | if (found) QPEApplication::setKeepRunning(); | 746 | if (found) QPEApplication::setKeepRunning(); |
677 | else qDebug("Huh what do ya want"); | 747 | else qDebug("Huh what do ya want"); |
678 | } | 748 | } |