summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp27
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp272
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp80
-rw-r--r--noncore/settings/networksettings/ppp/general.cpp62
-rw-r--r--noncore/settings/networksettings/ppp/modeminfo.cpp65
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp103
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp11
7 files changed, 395 insertions, 225 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
index 37c3a91..698dfd3 100644
--- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
@@ -1,33 +1,39 @@
1
1#include "interfaceinformationimp.h" 2#include "interfaceinformationimp.h"
2#include "interfaceadvanced.h" 3#include "interfaceadvanced.h"
3 4
5/* OPIE */
6#include <qpe/config.h>
7#include <qpe/qpeapplication.h>
8
9/* QT */
4#include <qcheckbox.h> 10#include <qcheckbox.h>
5#include <qpushbutton.h> 11#include <qpushbutton.h>
6#include <qlabel.h> 12#include <qlabel.h>
7#include <qgroupbox.h> 13#include <qgroupbox.h>
8#include <qmessagebox.h> 14#include <qmessagebox.h>
9 15
10#include <qpe/config.h>
11 16
12#ifdef QWS 17#ifdef QWS
13#else 18#else
14 #define showMaximized show 19 #define showMaximized show
15#endif 20#endif
16 21
17/** 22/**
18 * Constructor for the InterfaceInformationImp class. This class pretty much 23 * Constructor for the InterfaceInformationImp class. This class pretty much
19 * just display's information about the interface that is passed to it. 24 * just display's information about the interface that is passed to it.
20 */ 25 */
21InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i){ 26InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i)
27{
22 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 28 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
23 connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &))); 29 connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &)));
24 updateInterface(interface); 30 updateInterface(interface);
25 connect(startButton, SIGNAL(clicked()), interface, SLOT(start())); 31 connect(startButton, SIGNAL(clicked()), interface, SLOT(start()));
26 connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop())); 32 connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop()));
27 connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart())); 33 connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart()));
28 connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh())); 34 connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh()));
29 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); 35 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced()));
30 Config cfg("networksettings", Config::User); 36 Config cfg("networksettings", Config::User);
31 cfg.setGroup("interface"); 37 cfg.setGroup("interface");
32 CheckBoxSilent->setChecked( cfg.readBoolEntry("silent", false) ); 38 CheckBoxSilent->setChecked( cfg.readBoolEntry("silent", false) );
33} 39}
@@ -35,59 +41,64 @@ InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *na
35InterfaceInformationImp::~InterfaceInformationImp() 41InterfaceInformationImp::~InterfaceInformationImp()
36{ 42{
37 Config cfg("networksettings", Config::User); 43 Config cfg("networksettings", Config::User);
38 cfg.setGroup("interface"); 44 cfg.setGroup("interface");
39 cfg.writeEntry("silent", CheckBoxSilent->isChecked() ); 45 cfg.writeEntry("silent", CheckBoxSilent->isChecked() );
40} 46}
41 47
42/** 48/**
43 * Update the interface information and buttons. 49 * Update the interface information and buttons.
44 * @param Intarface *i the interface to update (should be the one we already 50 * @param Intarface *i the interface to update (should be the one we already
45 * know about). 51 * know about).
46 */ 52 */
47void InterfaceInformationImp::updateInterface(Interface *){ 53void InterfaceInformationImp::updateInterface(Interface *)
48 if(interface->getStatus()){ 54{
55 if(interface->getStatus())
56 {
49 startButton->setEnabled(false); 57 startButton->setEnabled(false);
50 stopButton->setEnabled(true); 58 stopButton->setEnabled(true);
51 restartButton->setEnabled(true); 59 restartButton->setEnabled(true);
52 } 60 }
53 else{ 61 else
62 {
54 startButton->setEnabled(true); 63 startButton->setEnabled(true);
55 stopButton->setEnabled(false); 64 stopButton->setEnabled(false);
56 restartButton->setEnabled(false); 65 restartButton->setEnabled(false);
57 } 66 }
58 macAddressLabel->setText(interface->getMacAddress()); 67 macAddressLabel->setText(interface->getMacAddress());
59 ipAddressLabel->setText(interface->getIp()); 68 ipAddressLabel->setText(interface->getIp());
60 subnetMaskLabel->setText(interface->getSubnetMask()); 69 subnetMaskLabel->setText(interface->getSubnetMask());
61 broadcastLabel->setText(interface->getBroadcast()); 70 broadcastLabel->setText(interface->getBroadcast());
62} 71}
63 72
64/** 73/**
65 * Create the advanced widget. Fill it with the current interface's information. 74 * Create the advanced widget. Fill it with the current interface's information.
66 * Display it. 75 * Display it.
67 */ 76 */
68void InterfaceInformationImp::advanced(){ 77void InterfaceInformationImp::advanced()
78{
69 InterfaceAdvanced *a = new InterfaceAdvanced(this, "InterfaceAdvanced", Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); 79 InterfaceAdvanced *a = new InterfaceAdvanced(this, "InterfaceAdvanced", Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog);
70 a->interfaceName->setText(interface->getInterfaceName()); 80 a->interfaceName->setText(interface->getInterfaceName());
71 a->macAddressLabel->setText(interface->getMacAddress()); 81 a->macAddressLabel->setText(interface->getMacAddress());
72 a->ipAddressLabel->setText(interface->getIp()); 82 a->ipAddressLabel->setText(interface->getIp());
73 a->subnetMaskLabel->setText(interface->getSubnetMask()); 83 a->subnetMaskLabel->setText(interface->getSubnetMask());
74 a->broadcastLabel->setText(interface->getBroadcast()); 84 a->broadcastLabel->setText(interface->getBroadcast());
75 a->dhcpServerLabel->setText(interface->getDhcpServerIp()); 85 a->dhcpServerLabel->setText(interface->getDhcpServerIp());
76 a->leaseObtainedLabel->setText(interface->getLeaseObtained()); 86 a->leaseObtainedLabel->setText(interface->getLeaseObtained());
77 a->leaseExpiresLabel->setText(interface->getLeaseExpires()); 87 a->leaseExpiresLabel->setText(interface->getLeaseExpires());
78 a->dhcpInformation->setEnabled(interface->isDhcp()); 88 a->dhcpInformation->setEnabled(interface->isDhcp());
79 a->showMaximized(); 89 QPEApplication::showWidget( a );
80} 90}
81 91
82/** 92/**
83 * Messages from the interface if start/stop went as planned. 93 * Messages from the interface if start/stop went as planned.
84 * Purly for user feedback. 94 * Purly for user feedback.
85 * @param message the message to display. 95 * @param message the message to display.
86 */ 96 */
87void InterfaceInformationImp::showMessage(const QString &message){ 97void InterfaceInformationImp::showMessage(const QString &message)
98{
88 if (CheckBoxSilent->isChecked()) return; 99 if (CheckBoxSilent->isChecked()) return;
89 QMessageBox::information(this, "Message", message, QMessageBox::Ok); 100 QMessageBox::information(this, "Message", message, QMessageBox::Ok);
90} 101}
91 102
92// infoimp.cpp 103// infoimp.cpp
93 104
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,65 +1,58 @@
1
1#include "mainwindowimp.h" 2#include "mainwindowimp.h"
2#include "addconnectionimp.h" 3#include "addconnectionimp.h"
3#include "interfaceinformationimp.h" 4#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 5#include "interfacesetupimp.h"
5#include "interfaces.h" 6#include "interfaces.h"
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>
10#include <qlineedit.h> 19#include <qlineedit.h>
11#include <qlistview.h> 20#include <qlistview.h>
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
37#include <qlist.h> 28#include <qlist.h>
38#else 29#else
39#include <qptrlist.h> 30#include <qptrlist.h>
40#endif 31#endif
41#include <qdir.h> 32#include <qdir.h>
42#include <qfile.h> 33#include <qfile.h>
43#include <qtextstream.h> 34#include <qtextstream.h>
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>
48#include <sys/socket.h> 40#include <sys/socket.h>
49 41
50#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" 42#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
51#define _PROCNETDEV "/proc/net/dev" 43#define _PROCNETDEV "/proc/net/dev"
52 44
53MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME){ 45MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME)
46{
54 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 47 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
55 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 48 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
56 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 49 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
57 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 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:
@@ -69,152 +62,172 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWi
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 )
75 {
82 /* 76 /*
83 * we skipped it in getAllInterfaces now 77 * we skipped it in getAllInterfaces now
84 * we need to ignore it as well 78 * we need to ignore it as well
85 */ 79 */
86 if (m_handledIfaces.contains( *ni) ) { 80 if (m_handledIfaces.contains( *ni) )
81 {
87 qDebug("Not up iface handled by module"); 82 qDebug("Not up iface handled by module");
88 continue; 83 continue;
89 } 84 }
90 bool found = false; 85 bool found = false;
91 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 86 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it )
87 {
92 if(it.key() == (*ni)) 88 if(it.key() == (*ni))
93 found = true; 89 found = true;
94 } 90 }
95 if(!found){ 91 if(!found)
96 if(!(*ni).contains("_")){ 92 {
93 if(!(*ni).contains("_"))
94 {
97 Interface *i = new Interface(this, *ni, false); 95 Interface *i = new Interface(this, *ni, false);
98 i->setAttached(false); 96 i->setAttached(false);
99 i->setHardwareName(tr("Disconnected")); 97 i->setHardwareName(tr("Disconnected"));
100 interfaceNames.insert(i->getInterfaceName(), i); 98 interfaceNames.insert(i->getInterfaceName(), i);
101 updateInterface(i); 99 updateInterface(i);
102 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 100 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
103 } 101 }
104 } 102 }
105 } 103 }
106 104
107 //getInterfaceList(); 105 //getInterfaceList();
108 connectionList->header()->hide(); 106 connectionList->header()->hide();
109 107
110 Config cfg("NetworkSetup"); 108 Config cfg("NetworkSetup");
111 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 109 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
112 for ( QStringList::Iterator it = profiles.begin(); 110 for ( QStringList::Iterator it = profiles.begin();
113 it != profiles.end(); ++it) 111 it != profiles.end(); ++it)
114 profilesList->insertItem((*it)); 112 profilesList->insertItem((*it));
115 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); 113 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
116 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); 114 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
117 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); 115 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
118 116
119 QFile file(scheme); 117 QFile file(scheme);
120 if ( file.open(IO_ReadOnly) ) { // file opened successfully 118 if ( file.open(IO_ReadOnly) )
119 { // file opened successfully
121 QTextStream stream( &file ); // use a text stream 120 QTextStream stream( &file ); // use a text stream
122 while ( !stream.eof() ) { // until end of file... 121 while ( !stream.eof() )
122 { // until end of file...
123 QString line = stream.readLine(); // line of text excluding '\n' 123 QString line = stream.readLine(); // line of text excluding '\n'
124 if(line.contains("SCHEME")){ 124 if(line.contains("SCHEME"))
125 {
125 line = line.mid(7, line.length()); 126 line = line.mid(7, line.length());
126 currentProfileLabel->setText(line); 127 currentProfileLabel->setText(line);
127 break; 128 break;
128 } 129 }
129 } 130 }
130 file.close(); 131 file.close();
131 } 132 }
132 makeChannel(); 133 makeChannel();
133} 134}
134 135
135/** 136/**
136 * Deconstructor. Save profiles. Delete loaded libraries. 137 * Deconstructor. Save profiles. Delete loaded libraries.
137 */ 138 */
138MainWindowImp::~MainWindowImp(){ 139MainWindowImp::~MainWindowImp()
140{
139 // Save profiles. 141 // Save profiles.
140 Config cfg("NetworkSetup"); 142 Config cfg("NetworkSetup");
141 cfg.setGroup("General"); 143 cfg.setGroup("General");
142 cfg.writeEntry("Profiles", profiles.join(" ")); 144 cfg.writeEntry("Profiles", profiles.join(" "));
143 145
144 // Delete all interfaces that don't have owners. 146 // Delete all interfaces that don't have owners.
145 QMap<Interface*, QListViewItem*>::Iterator iIt; 147 QMap<Interface*, QListViewItem*>::Iterator iIt;
146 for( iIt = items.begin(); iIt != items.end(); ++iIt ){ 148 for( iIt = items.begin(); iIt != items.end(); ++iIt )
149 {
147 if(iIt.key()->getModuleOwner() == NULL) 150 if(iIt.key()->getModuleOwner() == NULL)
148 delete iIt.key(); 151 delete iIt.key();
149 } 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 )
158 {
155 delete it.key(); 159 delete it.key();
156 // I wonder why I can't delete the libraries 160 // I wonder why I can't delete the libraries
157 // What fucking shit this is. 161 // What fucking shit this is.
158 //delete it.data(); 162 //delete it.data();
159 } 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}
164 168
165/** 169/**
166 * Query the kernel for all of the interfaces. 170 * Query the kernel for all of the interfaces.
167 */ 171 */
168void MainWindowImp::getAllInterfaces(){ 172void MainWindowImp::getAllInterfaces()
173{
169 int sockfd = socket(PF_INET, SOCK_DGRAM, 0); 174 int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
170 if(sockfd == -1) 175 if(sockfd == -1)
171 return; 176 return;
172 177
173 struct ifreq ifr; 178 struct ifreq ifr;
174 QStringList ifaces; 179 QStringList ifaces;
175 QFile procFile(QString(_PROCNETDEV)); 180 QFile procFile(QString(_PROCNETDEV));
176 int result; 181 int result;
177 Interface *i; 182 Interface *i;
178 183
179 if (! procFile.exists()) { 184 if (! procFile.exists())
185 {
180 struct ifreq ifrs[100]; 186 struct ifreq ifrs[100];
181 struct ifconf ifc; 187 struct ifconf ifc;
182 ifc.ifc_len = sizeof(ifrs); 188 ifc.ifc_len = sizeof(ifrs);
183 ifc.ifc_req = ifrs; 189 ifc.ifc_req = ifrs;
184 result = ioctl(sockfd, SIOCGIFCONF, &ifc); 190 result = ioctl(sockfd, SIOCGIFCONF, &ifc);
185 191
186 for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { 192 for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++)
193 {
187 struct ifreq *pifr = &ifrs[i]; 194 struct ifreq *pifr = &ifrs[i];
188 195
189 ifaces += pifr->ifr_name; 196 ifaces += pifr->ifr_name;
190 } 197 }
191 } else { 198 }
199 else
200 {
192 procFile.open(IO_ReadOnly); 201 procFile.open(IO_ReadOnly);
193 QString line; 202 QString line;
194 QTextStream procTs(&procFile); 203 QTextStream procTs(&procFile);
195 int loc = -1; 204 int loc = -1;
196 205
197 procTs.readLine(); // eat a line 206 procTs.readLine(); // eat a line
198 procTs.readLine(); // eat a line 207 procTs.readLine(); // eat a line
199 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { 208 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null)
200 if((loc = line.find(":")) != -1) { 209 {
210 if((loc = line.find(":")) != -1)
211 {
201 ifaces += line.left(loc); 212 ifaces += line.left(loc);
202 } 213 }
203 } 214 }
204 } 215 }
205 216
206 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { 217 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it)
218 {
207 int flags = 0; 219 int flags = 0;
208 if ( m_handledIfaces.contains( (*it) ) ) { 220 if ( m_handledIfaces.contains( (*it) ) )
221 {
209 qDebug(" %s is handled by a module", (*it).latin1() ); 222 qDebug(" %s is handled by a module", (*it).latin1() );
210 continue; 223 continue;
211 } 224 }
212// int family; 225// int family;
213 i = NULL; 226 i = NULL;
214 227
215 strcpy(ifr.ifr_name, (*it).latin1()); 228 strcpy(ifr.ifr_name, (*it).latin1());
216 229
217 struct ifreq ifcopy; 230 struct ifreq ifcopy;
218 ifcopy = ifr; 231 ifcopy = ifr;
219 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); 232 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy);
220 flags = ifcopy.ifr_flags; 233 flags = ifcopy.ifr_flags;
@@ -236,274 +249,310 @@ void MainWindowImp::getAllInterfaces(){
236 else 249 else
237 i->setHardwareName("Unknown"); 250 i->setHardwareName("Unknown");
238 251
239 qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); 252 qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name);
240 interfaceNames.insert(i->getInterfaceName(), i); 253 interfaceNames.insert(i->getInterfaceName(), i);
241 updateInterface(i); 254 updateInterface(i);
242 connect(i, SIGNAL(updateInterface(Interface *)), 255 connect(i, SIGNAL(updateInterface(Interface *)),
243 this, SLOT(updateInterface(Interface *))); 256 this, SLOT(updateInterface(Interface *)));
244 } 257 }
245 // now lets ask the plugins too ;) 258 // now lets ask the plugins too ;)
246 QMap<Module*, QLibrary*>::Iterator it; 259 QMap<Module*, QLibrary*>::Iterator it;
247 QList<Interface> ilist; 260 QList<Interface> ilist;
248 for( it = libraries.begin(); it != libraries.end(); ++it ){ 261 for( it = libraries.begin(); it != libraries.end(); ++it )
249 if(it.key()){ 262 {
263 if(it.key())
264 {
250 ilist = it.key()->getInterfaces(); 265 ilist = it.key()->getInterfaces();
251 for( i = ilist.first(); i != 0; i = ilist.next() ){ 266 for( i = ilist.first(); i != 0; i = ilist.next() )
267 {
252 qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); 268 qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() );
253 interfaceNames.insert(i->getInterfaceName(), i); 269 interfaceNames.insert(i->getInterfaceName(), i);
254 updateInterface(i); 270 updateInterface(i);
255 connect(i, SIGNAL(updateInterface(Interface *)), 271 connect(i, SIGNAL(updateInterface(Interface *)),
256 this, SLOT(updateInterface(Interface *))); 272 this, SLOT(updateInterface(Interface *)));
257 } 273 }
258 } 274 }
259 } 275 }
260} 276}
261 277
262/** 278/**
263 * Load all modules that are found in the path 279 * Load all modules that are found in the path
264 * @param path a directory that is scaned for any plugins that can be loaded 280 * @param path a directory that is scaned for any plugins that can be loaded
265 * and attempts to load them 281 * and attempts to load them
266 */ 282 */
267void MainWindowImp::loadModules(const QString &path){ 283void 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());
288 } 308 }
289 ++it; 309 ++it;
290 } 310 }
291} 311}
292 312
293/** 313/**
294 * Attempt to load a function and resolve a function. 314 * Attempt to load a function and resolve a function.
295 * @param pluginFileName - the name of the file in which to attempt to load 315 * @param pluginFileName - the name of the file in which to attempt to load
296 * @param resolveString - function pointer to resolve 316 * @param resolveString - function pointer to resolve
297 * @return pointer to the function with name resolveString or NULL 317 * @return pointer to the function with name resolveString or NULL
298 */ 318 */
299Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ 319Module* 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) )
354 {
331 qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 355 qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
332 return NULL; 356 return NULL;
333 } 357 }
334 // Try to get an object. 358 // Try to get an object.
335 Module *object = ((Module* (*)()) lib->symbol(resolveString))(); 359 Module *object = ((Module* (*)()) lib->symbol(resolveString))();
336 if(object == NULL){ 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}
350 375
351/** 376/**
352 * The Add button was clicked. Bring up the add dialog and if OK is hit 377 * The Add button was clicked. Bring up the add dialog and if OK is hit
353 * load the plugin and append it to the list 378 * load the plugin and append it to the list
354 */ 379 */
355void MainWindowImp::addClicked(){ 380void MainWindowImp::addClicked()
381{
356 QMap<Module*, QLibrary*>::Iterator it; 382 QMap<Module*, QLibrary*>::Iterator it;
357 QMap<QString, QString> list; 383 QMap<QString, QString> list;
358 QMap<QString, Module*> newInterfaceOwners; 384 QMap<QString, Module*> newInterfaceOwners;
359 385
360 for( it = libraries.begin(); it != libraries.end(); ++it ){ 386 for( it = libraries.begin(); it != libraries.end(); ++it )
361 if(it.key()){ 387 {
388 if(it.key())
389 {
362 (it.key())->possibleNewInterfaces(list); 390 (it.key())->possibleNewInterfaces(list);
363 } 391 }
364 } 392 }
365 // See if the list has anything that we can add. 393 // See if the list has anything that we can add.
366 if(list.count() == 0){ 394 if(list.count() == 0)
395 {
367 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); 396 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
368 return; 397 return;
369 } 398 }
370 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 399 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
371 addNewConnection.addConnections(list); 400 addNewConnection.addConnections(list);
372 addNewConnection.showMaximized(); 401 if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) )
373 if(QDialog::Accepted == addNewConnection.exec()){ 402 {
374 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 403 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
375 if(!item) 404 if(!item)
376 return; 405 return;
377 406
378 for( it = libraries.begin(); it != libraries.end(); ++it ){ 407 for( it = libraries.begin(); it != libraries.end(); ++it )
379 if(it.key()){ 408 {
409 if(it.key())
410 {
380 Interface *i = (it.key())->addNewInterface(item->text(0)); 411 Interface *i = (it.key())->addNewInterface(item->text(0));
381 if(i){ 412 if(i)
413 {
382 qDebug("iface name %s",i->getInterfaceName().latin1()); 414 qDebug("iface name %s",i->getInterfaceName().latin1());
383 interfaceNames.insert(i->getInterfaceName(), i); 415 interfaceNames.insert(i->getInterfaceName(), i);
384 updateInterface(i); 416 updateInterface(i);
385 } 417 }
386 } 418 }
387 } 419 }
388 } 420 }
389} 421}
390 422
391/** 423/**
392 * Prompt the user to see if they really want to do this. 424 * Prompt the user to see if they really want to do this.
393 * If they do then remove from the list and unload. 425 * If they do then remove from the list and unload.
394 */ 426 */
395void MainWindowImp::removeClicked(){ 427void MainWindowImp::removeClicked()
428{
396 QListViewItem *item = connectionList->currentItem(); 429 QListViewItem *item = connectionList->currentItem();
397 if(!item) { 430 if(!item)
431 {
398 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 432 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
399 return; 433 return;
400 } 434 }
401 435
402 Interface *i = interfaceItems[item]; 436 Interface *i = interfaceItems[item];
403 if(i->getModuleOwner() == NULL){ 437 if(i->getModuleOwner() == NULL)
438 {
404 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); 439 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok);
405 } 440 }
406 else{ 441 else
442 {
407 if(!i->getModuleOwner()->remove(i)) 443 if(!i->getModuleOwner()->remove(i))
408 QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); 444 QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok);
409 else{ 445 else
446 {
410 delete item; 447 delete item;
411// QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); 448// QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok);
412 } 449 }
413 } 450 }
414} 451}
415 452
416/** 453/**
417 * Pull up the configure about the currently selected interface. 454 * Pull up the configure about the currently selected interface.
418 * Report an error if no interface is selected. 455 * Report an error if no interface is selected.
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 */
421void MainWindowImp::configureClicked(){ 458void MainWindowImp::configureClicked()
459{
422 QListViewItem *item = connectionList->currentItem(); 460 QListViewItem *item = connectionList->currentItem();
423 if(!item){ 461 if(!item)
462 {
424 QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); 463 QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok);
425 return; 464 return;
426 } 465 }
427 466
428 QString currentProfileText = currentProfileLabel->text(); 467 QString currentProfileText = currentProfileLabel->text();
429 if(currentProfileText.upper() == "ALL"); 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())
474 {
435 QWidget *moduleConfigure = i->getModuleOwner()->configure(i); 475 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
436 if(moduleConfigure != NULL){ 476 if(moduleConfigure != NULL)
477 {
437 i->getModuleOwner()->setProfile(currentProfileText); 478 i->getModuleOwner()->setProfile(currentProfileText);
438 moduleConfigure->showMaximized(); 479 QPEApplication::showWidget( moduleConfigure );
439 return; 480 return;
440 } 481 }
441 } 482 }
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
448/** 489/**
449 * Pull up the information about the currently selected interface. 490 * Pull up the information about the currently selected interface.
450 * Report an error if no interface is selected. 491 * Report an error if no interface is selected.
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 */
453void MainWindowImp::informationClicked(){ 494void MainWindowImp::informationClicked()
495{
454 QListViewItem *item = connectionList->currentItem(); 496 QListViewItem *item = connectionList->currentItem();
455 if(!item){ 497 if(!item)
498 {
456 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 499 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
457 return; 500 return;
458 } 501 }
459 502
460 Interface *i = interfaceItems[item]; 503 Interface *i = interfaceItems[item];
461// if(!i->isAttached()){ 504// if(!i->isAttached()){
462// QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); 505// QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok);
463// return; 506// return;
464// } 507// }
465 508
466 if(i->getModuleOwner()){ 509 if(i->getModuleOwner())
510 {
467 QWidget *moduleInformation = i->getModuleOwner()->information(i); 511 QWidget *moduleInformation = i->getModuleOwner()->information(i);
468 if(moduleInformation != NULL){ 512 if(moduleInformation != NULL)
469 moduleInformation->showMaximized(); 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;
474 } 519 }
475 } 520 }
476 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp); 521 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp);
477 information->showMaximized(); 522 QPEApplication::showWidget( information );
478} 523}
479 524
480/** 525/**
481 * Update this interface. If no QListViewItem exists create one. 526 * Update this interface. If no QListViewItem exists create one.
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 */
484void MainWindowImp::updateInterface(Interface *i){ 529void MainWindowImp::updateInterface(Interface *i)
485 if(!advancedUserMode){ 530{
531 if(!advancedUserMode)
532 {
486 if(i->getInterfaceName() == "lo") 533 if(i->getInterfaceName() == "lo")
487 return; 534 return;
488 } 535 }
489 536
490 QListViewItem *item = NULL; 537 QListViewItem *item = NULL;
491 538
492 // Find the interface, making it if needed. 539 // Find the interface, making it if needed.
493 if(items.find(i) == items.end()){ 540 if(items.find(i) == items.end())
541 {
494 item = new QListViewItem(connectionList, "", "", ""); 542 item = new QListViewItem(connectionList, "", "", "");
495 // See if you can't find a module owner for this interface 543 // See if you can't find a module owner for this interface
496 QMap<Module*, QLibrary*>::Iterator it; 544 QMap<Module*, QLibrary*>::Iterator it;
497 for( it = libraries.begin(); it != libraries.end(); ++it ){ 545 for( it = libraries.begin(); it != libraries.end(); ++it )
546 {
498 if(it.key()->isOwner(i)) 547 if(it.key()->isOwner(i))
499 i->setModuleOwner(it.key()); 548 i->setModuleOwner(it.key());
500 } 549 }
501 items.insert(i, item); 550 items.insert(i, item);
502 interfaceItems.insert(item, i); 551 interfaceItems.insert(item, i);
503 } 552 }
504 else 553 else
505 item = items[i]; 554 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")));
@@ -528,151 +577,172 @@ void MainWindowImp::updateInterface(Interface *i){
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
540void MainWindowImp::newProfileChanged(const QString& newText){ 589void MainWindowImp::newProfileChanged(const QString& newText)
590{
541 if(newText.length() > 0) 591 if(newText.length() > 0)
542 newProfileButton->setEnabled(true); 592 newProfileButton->setEnabled(true);
543 else 593 else
544 newProfileButton->setEnabled(false); 594 newProfileButton->setEnabled(false);
545} 595}
546 596
547/** 597/**
548 * Adds a new profile to the list of profiles. 598 * Adds a new profile to the list of profiles.
549 * Don't add profiles that already exists. 599 * Don't add profiles that already exists.
550 * Appends to the list and QStringList 600 * Appends to the list and QStringList
551 */ 601 */
552void MainWindowImp::addProfile(){ 602void MainWindowImp::addProfile()
603{
553 QString newProfileName = newProfile->text(); 604 QString newProfileName = newProfile->text();
554 if(profiles.grep(newProfileName).count() > 0){ 605 if(profiles.grep(newProfileName).count() > 0)
606 {
555 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); 607 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok);
556 return; 608 return;
557 } 609 }
558 profiles.append(newProfileName); 610 profiles.append(newProfileName);
559 profilesList->insertItem(newProfileName); 611 profilesList->insertItem(newProfileName);
560} 612}
561 613
562/** 614/**
563 * Removes the currently selected profile in the combo. 615 * Removes the currently selected profile in the combo.
564 * Doesn't delete if there are less then 2 profiles. 616 * Doesn't delete if there are less then 2 profiles.
565 */ 617 */
566void MainWindowImp::removeProfile(){ 618void MainWindowImp::removeProfile()
567 if(profilesList->count() <= 1){ 619{
620 if(profilesList->count() <= 1)
621 {
568 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); 622 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok);
569 return; 623 return;
570 } 624 }
571 QString profileToRemove = profilesList->currentText(); 625 QString profileToRemove = profilesList->currentText();
572 if(profileToRemove == "All"){ 626 if(profileToRemove == "All")
627 {
573 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); 628 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok);
574 return; 629 return;
575 } 630 }
576 // Can't remove the curent profile 631 // Can't remove the curent profile
577 if(profileToRemove == currentProfileLabel->text()){ 632 if(profileToRemove == currentProfileLabel->text())
633 {
578 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); 634 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok);
579 return; 635 return;
580 636
581 } 637 }
582 638
583 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ 639 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
640 {
584 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 641 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
585 profilesList->clear(); 642 profilesList->clear();
586 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 643 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
587 profilesList->insertItem((*it)); 644 profilesList->insertItem((*it));
588 645
589 // Remove any interface settings and mappings. 646 // Remove any interface settings and mappings.
590 Interfaces interfaces; 647 Interfaces interfaces;
591 // Go through them one by one 648 // Go through them one by one
592 QMap<Interface*, QListViewItem*>::Iterator it; 649 QMap<Interface*, QListViewItem*>::Iterator it;
593 for( it = items.begin(); it != items.end(); ++it ){ 650 for( it = items.begin(); it != items.end(); ++it )
651 {
594 QString interfaceName = it.key()->getInterfaceName(); 652 QString interfaceName = it.key()->getInterfaceName();
595 qDebug(interfaceName.latin1()); 653 qDebug(interfaceName.latin1());
596 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ 654 if(interfaces.setInterface(interfaceName + "_" + profileToRemove))
655 {
597 interfaces.removeInterface(); 656 interfaces.removeInterface();
598 if(interfaces.setMapping(interfaceName)){ 657 if(interfaces.setMapping(interfaceName))
658 {
599 if(profilesList->count() == 1) 659 if(profilesList->count() == 1)
600 interfaces.removeMapping(); 660 interfaces.removeMapping();
601 else{ 661 else
662 {
602 interfaces.removeMap("map", interfaceName + "_" + profileToRemove); 663 interfaces.removeMap("map", interfaceName + "_" + profileToRemove);
603 } 664 }
604 } 665 }
605 interfaces.write(); 666 interfaces.write();
606 break; 667 break;
607 } 668 }
608 } 669 }
609 } 670 }
610} 671}
611 672
612/** 673/**
613 * A new profile has been selected, change. 674 * A new profile has been selected, change.
614 * @param newProfile the new profile. 675 * @param newProfile the new profile.
615 */ 676 */
616void MainWindowImp::changeProfile(){ 677void MainWindowImp::changeProfile()
617 if(profilesList->currentItem() == -1){ 678{
679 if(profilesList->currentItem() == -1)
680 {
618 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); 681 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok);
619 return; 682 return;
620 } 683 }
621 QString newProfile = profilesList->text(profilesList->currentItem()); 684 QString newProfile = profilesList->text(profilesList->currentItem());
622 if(newProfile != currentProfileLabel->text()){ 685 if(newProfile != currentProfileLabel->text())
686 {
623 currentProfileLabel->setText(newProfile); 687 currentProfileLabel->setText(newProfile);
624 QFile::remove(scheme); 688 QFile::remove(scheme);
625 QFile file(scheme); 689 QFile file(scheme);
626 if ( file.open(IO_ReadWrite) ) { 690 if ( file.open(IO_ReadWrite) )
691 {
627 QTextStream stream( &file ); 692 QTextStream stream( &file );
628 stream << QString("SCHEME=%1").arg(newProfile); 693 stream << QString("SCHEME=%1").arg(newProfile);
629 file.close(); 694 file.close();
630 } 695 }
631 // restart all up devices? 696 // restart all up devices?
632 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ 697 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok)
698 {
633 // Go through them one by one 699 // Go through them one by one
634 QMap<Interface*, QListViewItem*>::Iterator it; 700 QMap<Interface*, QListViewItem*>::Iterator it;
635 for( it = items.begin(); it != items.end(); ++it ){ 701 for( it = items.begin(); it != items.end(); ++it )
702 {
636 if(it.key()->getStatus() == true) 703 if(it.key()->getStatus() == true)
637 it.key()->restart(); 704 it.key()->restart();
638 } 705 }
639 } 706 }
640 } 707 }
641 // TODO change the profile in the modules 708 // TODO change the profile in the modules
642} 709}
643 710
644 711
645void MainWindowImp::makeChannel() 712void 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
652void MainWindowImp::receive(const QCString &msg, const QByteArray &arg) 719void MainWindowImp::receive(const QCString &msg, const QByteArray &arg)
653{ 720{
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;
659 } 727 }
660 728
661 QString dest = msg.left(msg.find("(")); 729 QString dest = msg.left(msg.find("("));
662 QCString param = msg.right(msg.length() - msg.find("(") - 1); 730 QCString param = msg.right(msg.length() - msg.find("(") - 1);
663 param = param.left( param.length() - 1 ); 731 param = param.left( param.length() - 1 );
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 )
736 {
668 qDebug("plugin >%s<", it.key()->type().latin1() ); 737 qDebug("plugin >%s<", it.key()->type().latin1() );
669 if(it.key()->type() == dest){ 738 if(it.key()->type() == dest)
739 {
670 it.key()->receive( param, arg ); 740 it.key()->receive( param, arg );
671 found = true; 741 found = true;
672 } 742 }
673 } 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}
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index 28d8732..b8a1925a 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -15,41 +15,46 @@
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include "accounts.h"
28#include "authwidget.h"
29#include "pppdata.h"
30#include "edit.h"
31
32/* OPIE */
33#include <qpe/qpeapplication.h>
34
35/* QT */
27#include <qdir.h> 36#include <qdir.h>
28#include <stdlib.h>
29#include <qlayout.h> 37#include <qlayout.h>
30#include <qtabwidget.h> 38#include <qtabwidget.h>
31#include <qtabdialog.h> 39#include <qtabdialog.h>
32#include <qwhatsthis.h> 40#include <qwhatsthis.h>
33#include <qmessagebox.h> 41#include <qmessagebox.h>
34
35#include <qapplication.h> 42#include <qapplication.h>
36#include <qbuttongroup.h> 43#include <qbuttongroup.h>
37#include <qmessagebox.h> 44#include <qmessagebox.h>
38#include <qvgroupbox.h> 45#include <qvgroupbox.h>
39 46
40#include "accounts.h" 47/* STD */
41#include "authwidget.h" 48#include <stdlib.h>
42#include "pppdata.h"
43#include "edit.h"
44 49
45void parseargs(char* buf, char** args); 50void parseargs(char* buf, char** args);
46 51
47 52
48AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f ) 53AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f )
49 : ChooserWidget( pd, parent, name, f ) 54 : ChooserWidget( pd, parent, name, f )
50{ 55{
51 56
52 QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); 57 QWhatsThis::add(edit_b, tr("Allows you to modify the selected account"));
53 QWhatsThis::add(new_b, tr("Create a new dialup connection\n" 58 QWhatsThis::add(new_b, tr("Create a new dialup connection\n"
54 "to the Internet")); 59 "to the Internet"));
55 QWhatsThis::add(copy_b, 60 QWhatsThis::add(copy_b,
@@ -59,135 +64,150 @@ AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WF
59 "needs")); 64 "needs"));
60 QWhatsThis::add(delete_b, 65 QWhatsThis::add(delete_b,
61 tr("<p>Deletes the selected account\n\n" 66 tr("<p>Deletes the selected account\n\n"
62 "<font color=\"red\"><b>Use with care!</b></font>")); 67 "<font color=\"red\"><b>Use with care!</b></font>"));
63 68
64 69
65 70
66 copy_b->setEnabled( false ); //FIXME 71 copy_b->setEnabled( false ); //FIXME
67 // delete_b->setEnabled( false ); //FIXME 72 // delete_b->setEnabled( false ); //FIXME
68 73
69 listListbox->insertStringList(_pppdata->getAccountList()); 74 listListbox->insertStringList(_pppdata->getAccountList());
70 75
71 for (uint i = 0; i < listListbox->count(); i++){ 76 for (uint i = 0; i < listListbox->count(); i++)
77 {
72 if ( listListbox->text(i) == _pppdata->accname() ) 78 if ( listListbox->text(i) == _pppdata->accname() )
73 listListbox->setCurrentItem( i ); 79 listListbox->setCurrentItem( i );
74 } 80 }
75} 81}
76 82
77 83
78 84
79void AccountWidget::slotListBoxSelect(int idx) { 85void AccountWidget::slotListBoxSelect(int idx)
86{
80 bool ok = _pppdata->setAccount( listListbox->text(idx) ); 87 bool ok = _pppdata->setAccount( listListbox->text(idx) );
81 ok = (bool)(idx != -1); 88 ok = (bool)(idx != -1);
82 delete_b->setEnabled(ok); 89 delete_b->setEnabled(ok);
83 edit_b->setEnabled(ok); 90 edit_b->setEnabled(ok);
84//FIXME copy_b->setEnabled(ok); 91//FIXME copy_b->setEnabled(ok);
85} 92}
86 93
87void AccountWidget::edit() { 94void AccountWidget::edit()
95{
88 _pppdata->setAccount(listListbox->text(listListbox->currentItem())); 96 _pppdata->setAccount(listListbox->text(listListbox->currentItem()));
89 97
90 int result = doTab(); 98 int result = doTab();
91 99
92 if(result == QDialog::Accepted) { 100 if(result == QDialog::Accepted)
101 {
93 listListbox->changeItem(_pppdata->accname(),listListbox->currentItem()); 102 listListbox->changeItem(_pppdata->accname(),listListbox->currentItem());
94// emit resetaccounts(); 103// emit resetaccounts();
95 _pppdata->save(); 104 _pppdata->save();
96 } 105 }
97} 106}
98 107
99 108
100void AccountWidget::create() { 109void AccountWidget::create()
110{
101 111
102// if(listListbox->count() == MAX_ACCOUNTS) { 112// if(listListbox->count() == MAX_ACCOUNTS) {
103// QMessageBox::information(this, "sorry", 113// QMessageBox::information(this, "sorry",
104// tr("Maximum number of accounts reached.")); 114// tr("Maximum number of accounts reached."));
105// return; 115// return;
106// } 116// }
107 117
108 int result; 118 int result;
109 if (_pppdata->newaccount() == -1){ 119 if (_pppdata->newaccount() == -1)
120 {
110 qDebug("_pppdata->newaccount() == -1"); 121 qDebug("_pppdata->newaccount() == -1");
111 return; 122 return;
112 } 123 }
113 result = doTab(); 124 result = doTab();
114 125
115 if(result == QDialog::Accepted) { 126 if(result == QDialog::Accepted)
127 {
116 listListbox->insertItem(_pppdata->accname()); 128 listListbox->insertItem(_pppdata->accname());
117 listListbox->setSelected(listListbox->findItem(_pppdata->accname()),true); 129 listListbox->setSelected(listListbox->findItem(_pppdata->accname()),true);
118 130
119 _pppdata->save(); 131 _pppdata->save();
120 } else 132 }
133 else
121 _pppdata->deleteAccount(); 134 _pppdata->deleteAccount();
122} 135}
123 136
124 137
125void AccountWidget::copy() { 138void AccountWidget::copy()
139{
126// if(listListbox->count() == MAX_ACCOUNTS) { 140// if(listListbox->count() == MAX_ACCOUNTS) {
127// QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); 141// QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached."));
128// return; 142// return;
129// } 143// }
130 144
131 if(listListbox->currentItem()<0) { 145 if(listListbox->currentItem()<0)
146 {
132 QMessageBox::information(this, "sorry", tr("No account selected.")); 147 QMessageBox::information(this, "sorry", tr("No account selected."));
133 return; 148 return;
134 } 149 }
135 150
136 _pppdata->copyaccount(listListbox->currentText()); 151 _pppdata->copyaccount(listListbox->currentText());
137 152
138 listListbox->insertItem(_pppdata->accname()); 153 listListbox->insertItem(_pppdata->accname());
139// emit resetaccounts(); 154// emit resetaccounts();
140 _pppdata->save(); 155 _pppdata->save();
141} 156}
142 157
143 158
144void AccountWidget::remove() { 159void AccountWidget::remove()
160{
145 161
146 QString s = tr("Are you sure you want to delete\nthe account \"%1\"?") 162 QString s = tr("Are you sure you want to delete\nthe account \"%1\"?")
147 .arg(listListbox->text(listListbox->currentItem())); 163 .arg(listListbox->text(listListbox->currentItem()));
148 164
149 if(QMessageBox::warning(this,tr("Confirm"),s, 165 if(QMessageBox::warning(this,tr("Confirm"),s,
150 QMessageBox::Yes,QMessageBox::No 166 QMessageBox::Yes,QMessageBox::No
151 ) != QMessageBox::Yes) 167 ) != QMessageBox::Yes)
152 return; 168 return;
153 169
154 if(_pppdata->deleteAccount(listListbox->text(listListbox->currentItem()))) 170 if(_pppdata->deleteAccount(listListbox->text(listListbox->currentItem())))
155 listListbox->removeItem(listListbox->currentItem()); 171 listListbox->removeItem(listListbox->currentItem());
156 172
157 173
158// emit resetaccounts(); 174// emit resetaccounts();
159// _pppdata->save(); 175// _pppdata->save();
160 176
161 177
162 slotListBoxSelect(listListbox->currentItem()); 178 slotListBoxSelect(listListbox->currentItem());
163 179
164} 180}
165 181
166 182
167int AccountWidget::doTab(){ 183int AccountWidget::doTab()
184{
168 QDialog *dlg = new QDialog( 0, "newAccount", true, Qt::WStyle_ContextHelp ); 185 QDialog *dlg = new QDialog( 0, "newAccount", true, Qt::WStyle_ContextHelp );
169 QVBoxLayout *layout = new QVBoxLayout( dlg ); 186 QVBoxLayout *layout = new QVBoxLayout( dlg );
170 layout->setSpacing( 0 ); 187 layout->setSpacing( 0 );
171 layout->setMargin( 1 ); 188 layout->setMargin( 1 );
172 189
173 QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" ); 190 QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" );
174 layout->addWidget( tabWindow ); 191 layout->addWidget( tabWindow );
175 192
176 bool isnewaccount; 193 bool isnewaccount;
177 194
178 if(_pppdata->accname().isEmpty()) { 195 if(_pppdata->accname().isEmpty())
196 {
179 dlg->setCaption(tr("New Account")); 197 dlg->setCaption(tr("New Account"));
180 isnewaccount = true; 198 isnewaccount = true;
181 } else { 199 }
200 else
201 {
182 QString tit = tr("Edit Account: "); 202 QString tit = tr("Edit Account: ");
183 tit += _pppdata->accname(); 203 tit += _pppdata->accname();
184 dlg->setCaption(tit); 204 dlg->setCaption(tit);
185 isnewaccount = false; 205 isnewaccount = false;
186 } 206 }
187 207
188// // DIAL WIDGET 208// // DIAL WIDGET
189 dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); 209 dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup");
190 tabWindow->addTab( dial_w, tr("Dial") ); 210 tabWindow->addTab( dial_w, tr("Dial") );
191 211
192// // AUTH WIDGET 212// // AUTH WIDGET
193 auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script")); 213 auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script"));
@@ -203,36 +223,42 @@ int AccountWidget::doTab(){
203 223
204// // DNS WIDGET 224// // DNS WIDGET
205 dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") ); 225 dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") );
206 tabWindow->addTab( dns_w, tr("DNS") ); 226 tabWindow->addTab( dns_w, tr("DNS") );
207 227
208// // EXECUTE WIDGET 228// // EXECUTE WIDGET
209 ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs")); 229 ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs"));
210 tabWindow->addTab( exec_w, tr("Execute") ); 230 tabWindow->addTab( exec_w, tr("Execute") );
211 231
212 int result = 0; 232 int result = 0;
213 bool ok = false; 233 bool ok = false;
214 234
215 while (!ok){ 235 while (!ok)
216 dlg->showMaximized(); 236 {
217 result = dlg->exec(); 237 result = QPEApplication::execDialog( dlg );
218 ok = true; 238 ok = true;
219 239
220 if(result == QDialog::Accepted) { 240 if(result == QDialog::Accepted)
221 if (!auth_w->check()){ 241 {
242 if (!auth_w->check())
243 {
222 ok = false; 244 ok = false;
223 } else if(!dial_w->save()) { 245 }
246 else if(!dial_w->save())
247 {
224 QMessageBox::critical(this, "error", tr( "You must enter a unique account name")); 248 QMessageBox::critical(this, "error", tr( "You must enter a unique account name"));
225 ok = false; 249 ok = false;
226 }else{ 250 }
251 else
252 {
227 ip_w->save(); 253 ip_w->save();
228 dns_w->save(); 254 dns_w->save();
229 gateway_w->save(); 255 gateway_w->save();
230 auth_w->save(); 256 auth_w->save();
231 exec_w->save(); 257 exec_w->save();
232 } 258 }
233 } 259 }
234 } 260 }
235 261
236 delete dlg; 262 delete dlg;
237 263
238 return result; 264 return result;
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp
index 5540946..ff1b11b 100644
--- a/noncore/settings/networksettings/ppp/general.cpp
+++ b/noncore/settings/networksettings/ppp/general.cpp
@@ -15,49 +15,47 @@
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This program is distributed in the hope that it will be useful, 17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include <termios.h> 27#include "general.h"
28#include <string.h> 28#include "interfaceppp.h"
29#include "modeminfo.h"
30#include "modemcmds.h"
31#include "pppdata.h"
29 32
33/* OPIE */
34#include <qpe/config.h>
35#include <qpe/qpeapplication.h>
36
37/* QT */
30#include <qcheckbox.h> 38#include <qcheckbox.h>
31#include <qcombobox.h> 39#include <qcombobox.h>
32#include <qlabel.h> 40#include <qlabel.h>
33#include <qlayout.h> 41#include <qlayout.h>
34#include <qpushbutton.h> 42#include <qpushbutton.h>
35#include <qslider.h> 43#include <qslider.h>
36#include <qspinbox.h> 44#include <qspinbox.h>
37#include <qwhatsthis.h> 45#include <qwhatsthis.h>
38#include <qpe/config.h>
39// #include <qgroupbox.h>
40
41
42#include "general.h"
43#include "interfaceppp.h"
44//#include "miniterm.h"
45#include "modeminfo.h"
46#include "modemcmds.h"
47//#include "devices.h"
48#include "pppdata.h"
49//#include <klocale.h>
50
51 46
47/* STD */
48#include <termios.h>
49#include <string.h>
52 50
53 51
54ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) 52ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name )
55 : QWidget(parent, name), _pppdata(pd) 53 : QWidget(parent, name), _pppdata(pd)
56{ 54{
57 int k; 55 int k;
58 56
59 QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); 57 QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint());
60 58
61 QLabel *label1; 59 QLabel *label1;
62 60
63 label1 = new QLabel(tr("Modem &name:"), this); 61 label1 = new QLabel(tr("Modem &name:"), this);
@@ -139,67 +137,70 @@ ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name )
139 "settings here\n" 137 "settings here\n"
140 "\n" 138 "\n"
141 "<b>Default</b>: CR/LF"); 139 "<b>Default</b>: CR/LF");
142 140
143 QWhatsThis::add(labelenter,tmp); 141 QWhatsThis::add(labelenter,tmp);
144 QWhatsThis::add(enter, tmp); 142 QWhatsThis::add(enter, tmp);
145 143
146 QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this); 144 QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this);
147 tl->addWidget(baud_label, 4, 0); 145 tl->addWidget(baud_label, 4, 0);
148 baud_c = new QComboBox(this); 146 baud_c = new QComboBox(this);
149 baud_label->setBuddy(baud_c); 147 baud_label->setBuddy(baud_c);
150 148
151 static const char *baudrates[] = { 149 static const char *baudrates[] =
150 {
152 151
153#ifdef B460800 152#ifdef B460800
154 "460800", 153 "460800",
155#endif 154#endif
156 155
157#ifdef B230400 156#ifdef B230400
158 "230400", 157 "230400",
159#endif 158#endif
160 159
161#ifdef B115200 160#ifdef B115200
162 "115200", 161 "115200",
163#endif 162#endif
164 163
165#ifdef B57600 164#ifdef B57600
166 "57600", 165 "57600",
167#endif 166#endif
168 167
169 "38400", 168 "38400",
170 "19200", 169 "19200",
171 "9600", 170 "9600",
172 "2400", 171 "2400",
173 0}; 172 0
173 };
174 174
175 for(k = 0; baudrates[k]; k++) 175 for(k = 0; baudrates[k]; k++)
176 baud_c->insertItem(baudrates[k]); 176 baud_c->insertItem(baudrates[k]);
177 177
178 baud_c->setCurrentItem(3); 178 baud_c->setCurrentItem(3);
179// connect(baud_c, SIGNAL(activated(int)), 179// connect(baud_c, SIGNAL(activated(int)),
180 // this, SLOT(speed_selection(int))); 180 // this, SLOT(speed_selection(int)));
181 tl->addWidget(baud_c, 4, 1); 181 tl->addWidget(baud_c, 4, 1);
182 182
183 tmp = tr("Specifies the speed your modem and the serial\n" 183 tmp = tr("Specifies the speed your modem and the serial\n"
184 "port talk to each other. You should begin with\n" 184 "port talk to each other. You should begin with\n"
185 "the default of 38400 bits/sec. If everything\n" 185 "the default of 38400 bits/sec. If everything\n"
186 "works you can try to increase this value, but to\n" 186 "works you can try to increase this value, but to\n"
187 "no more than 115200 bits/sec (unless you know\n" 187 "no more than 115200 bits/sec (unless you know\n"
188 "that your serial port supports higher speeds)."); 188 "that your serial port supports higher speeds).");
189 189
190 QWhatsThis::add(baud_label,tmp); 190 QWhatsThis::add(baud_label,tmp);
191 QWhatsThis::add(baud_c,tmp); 191 QWhatsThis::add(baud_c,tmp);
192 192
193 for(int i=0; i <= enter->count()-1; i++) { 193 for(int i=0; i <= enter->count()-1; i++)
194 {
194 if(_pppdata->enter() == enter->text(i)) 195 if(_pppdata->enter() == enter->text(i))
195 enter->setCurrentItem(i); 196 enter->setCurrentItem(i);
196 } 197 }
197 198
198 tl->addRowSpacing(5, 10); 199 tl->addRowSpacing(5, 10);
199 200
200 //Modem Lock File 201 //Modem Lock File
201 modemlockfile = new QCheckBox(tr("&Use lock file"), this); 202 modemlockfile = new QCheckBox(tr("&Use lock file"), this);
202 203
203 modemlockfile->setChecked(_pppdata->modemLockFile()); 204 modemlockfile->setChecked(_pppdata->modemLockFile());
204// connect(modemlockfile, SIGNAL(toggled(bool)), 205// connect(modemlockfile, SIGNAL(toggled(bool)),
205// SLOT(modemlockfilechanged(bool))); 206// SLOT(modemlockfilechanged(bool)));
@@ -228,35 +229,38 @@ ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name )
228// connect(modemtimeout, SIGNAL(valueChanged(int)), 229// connect(modemtimeout, SIGNAL(valueChanged(int)),
229 // SLOT(modemtimeoutchanged(int))); 230 // SLOT(modemtimeoutchanged(int)));
230 timeoutLayout->addWidget(timeoutlabel); 231 timeoutLayout->addWidget(timeoutlabel);
231 timeoutLayout->addWidget(modemtimeout); 232 timeoutLayout->addWidget(modemtimeout);
232 tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1); 233 tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1);
233 234
234 QWhatsThis::add(modemtimeout, 235 QWhatsThis::add(modemtimeout,
235 tr("This specifies how long <i>kppp</i> waits for a\n" 236 tr("This specifies how long <i>kppp</i> waits for a\n"
236 "<i>CONNECT</i> response from your modem. The\n" 237 "<i>CONNECT</i> response from your modem. The\n"
237 "recommended value is 30 seconds.")); 238 "recommended value is 30 seconds."));
238 239
239 //set stuff from gpppdata 240 //set stuff from gpppdata
240 for(int i=0; i <= enter->count()-1; i++) { 241 for(int i=0; i <= enter->count()-1; i++)
242 {
241 if(_pppdata->enter() == enter->text(i)) 243 if(_pppdata->enter() == enter->text(i))
242 enter->setCurrentItem(i); 244 enter->setCurrentItem(i);
243 } 245 }
244 246
245 for(int i=0; i <= modemdevice->count()-1; i++) { 247 for(int i=0; i <= modemdevice->count()-1; i++)
248 {
246 if(_pppdata->modemDevice() == modemdevice->text(i)) 249 if(_pppdata->modemDevice() == modemdevice->text(i))
247 modemdevice->setCurrentItem(i); 250 modemdevice->setCurrentItem(i);
248 } 251 }
249 252
250 for(int i=0; i <= flowcontrol->count()-1; i++) { 253 for(int i=0; i <= flowcontrol->count()-1; i++)
254 {
251 if(_pppdata->flowcontrol() == flowcontrol->text(i)) 255 if(_pppdata->flowcontrol() == flowcontrol->text(i))
252 flowcontrol->setCurrentItem(i); 256 flowcontrol->setCurrentItem(i);
253 } 257 }
254 258
255 //set the modem speed 259 //set the modem speed
256 for(int i=0; i < baud_c->count(); i++) 260 for(int i=0; i < baud_c->count(); i++)
257 if(baud_c->text(i) == _pppdata->speed()) 261 if(baud_c->text(i) == _pppdata->speed())
258 baud_c->setCurrentItem(i); 262 baud_c->setCurrentItem(i);
259 263
260 tl->setRowStretch(1, 1); 264 tl->setRowStretch(1, 1);
261} 265}
262 266
@@ -264,27 +268,29 @@ ModemWidget::~ModemWidget()
264{ 268{
265 QStringList devs; 269 QStringList devs;
266 270
267 for (int i=0;i<modemdevice->count();i++) 271 for (int i=0;i<modemdevice->count();i++)
268 { 272 {
269 QString s = modemdevice->text(i); 273 QString s = modemdevice->text(i);
270 s.simplifyWhiteSpace(); 274 s.simplifyWhiteSpace();
271 if (! s.isEmpty() ) devs << s; 275 if (! s.isEmpty() ) devs << s;
272 } 276 }
273 277
274 278
275 QString edited = modemdevice->currentText(); 279 QString edited = modemdevice->currentText();
276 if ( !( edited ).isEmpty() ) { 280 if ( !( edited ).isEmpty() )
281 {
277 edited.simplifyWhiteSpace(); 282 edited.simplifyWhiteSpace();
278 if ( devs.contains( edited ) == 0 ) { 283 if ( devs.contains( edited ) == 0 )
284 {
279 devs << edited; 285 devs << edited;
280 } 286 }
281 _pppdata->setModemDevice( edited ); 287 _pppdata->setModemDevice( edited );
282 } 288 }
283 289
284 290
285 Config cfg("NetworkSetupPPP"); 291 Config cfg("NetworkSetupPPP");
286 cfg.setGroup("Devices_General"); 292 cfg.setGroup("Devices_General");
287 cfg.writeEntry("devices",devs,','); 293 cfg.writeEntry("devices",devs,',');
288 294
289} 295}
290 296
@@ -461,32 +467,34 @@ ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent,
461 hbox->addStretch(1); 467 hbox->addStretch(1);
462 l1->addStretch(1); 468 l1->addStretch(1);
463 469
464 connect(modemcmds, SIGNAL(clicked()), 470 connect(modemcmds, SIGNAL(clicked()),
465 SLOT(modemcmdsbutton())); 471 SLOT(modemcmdsbutton()));
466 connect(modeminfo_button, SIGNAL(clicked()), 472 connect(modeminfo_button, SIGNAL(clicked()),
467 SLOT(query_modem())); 473 SLOT(query_modem()));
468// connect(terminal_button, SIGNAL(clicked()), 474// connect(terminal_button, SIGNAL(clicked()),
469 // SLOT(terminal())); 475 // SLOT(terminal()));
470} 476}
471 477
472 478
473void ModemWidget2::modemcmdsbutton() { 479void ModemWidget2::modemcmdsbutton()
480{
474 ModemCommands mc(_ifaceppp->data(), this, "commands" , true, Qt::WStyle_ContextHelp); 481 ModemCommands mc(_ifaceppp->data(), this, "commands" , true, Qt::WStyle_ContextHelp);
475 mc.showMaximized(); 482
476 mc.exec(); 483 QPEApplication::execDialog( &mc );
477} 484}
478 485
479 486
480void ModemWidget2::query_modem() { 487void ModemWidget2::query_modem()
488{
481 ModemTransfer mt(_ifaceppp->modem(), this); 489 ModemTransfer mt(_ifaceppp->modem(), this);
482 mt.exec(); 490 mt.exec();
483} 491}
484 492
485 493
486// void ModemWidget2::terminal() { 494// void ModemWidget2::terminal() {
487// MiniTerm terminal(NULL,NULL); 495// MiniTerm terminal(NULL,NULL);
488// terminal.exec(); 496// terminal.exec();
489// } 497// }
490 498
491 499
492// #if 0 500// #if 0
diff --git a/noncore/settings/networksettings/ppp/modeminfo.cpp b/noncore/settings/networksettings/ppp/modeminfo.cpp
index dbb26db..df0bf9b 100644
--- a/noncore/settings/networksettings/ppp/modeminfo.cpp
+++ b/noncore/settings/networksettings/ppp/modeminfo.cpp
@@ -15,34 +15,38 @@
15 * version 2 of the License, or (at your option) any later version. 15 * version 2 of the License, or (at your option) any later version.
16 * 16 *
17 * This library is distributed in the hope that it will be useful, 17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details. 20 * Library General Public License for more details.
21 * 21 *
22 * You should have received a copy of the GNU Library General Public 22 * You should have received a copy of the GNU Library General Public
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include <unistd.h> 27#include "modeminfo.h"
28#include "modem.h"
29
30/* OPIE */
31#include <qpe/qpeapplication.h>
32
33/* QT */
28#include <qregexp.h> 34#include <qregexp.h>
29#include <qlayout.h> 35#include <qlayout.h>
30// #include <kwin.h>
31// #include <kmessagebox.h>
32// #include <kapplication.h>
33#include <qmessagebox.h> 36#include <qmessagebox.h>
34#include <qapplication.h> 37#include <qapplication.h>
35#include "modeminfo.h" 38
36#include "modem.h" 39/* STD */
40#include <unistd.h>
37 41
38ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name) 42ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name)
39 : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder), 43 : QDialog(parent, name,TRUE, WStyle_Customize|WStyle_NormalBorder),
40 _modem(mo) 44 _modem(mo)
41{ 45{
42 setCaption(QObject::tr("ATI Query")); 46 setCaption(QObject::tr("ATI Query"));
43// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); 47// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
44 48
45 QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); 49 QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
46 50
47 progressBar = new QProgressBar(this, "bar"); 51 progressBar = new QProgressBar(this, "bar");
48 progressBar->setTotalSteps(8); 52 progressBar->setTotalSteps(8);
@@ -84,101 +88,110 @@ ModemTransfer::ModemTransfer(Modem *mo, QWidget *parent, const char *name)
84 timeout_timer = new QTimer(this); 88 timeout_timer = new QTimer(this);
85 connect(timeout_timer, SIGNAL(timeout()), SLOT(time_out_slot())); 89 connect(timeout_timer, SIGNAL(timeout()), SLOT(time_out_slot()));
86 90
87 scripttimer = new QTimer(this); 91 scripttimer = new QTimer(this);
88 connect(scripttimer, SIGNAL(timeout()), SLOT(do_script())); 92 connect(scripttimer, SIGNAL(timeout()), SLOT(do_script()));
89 93
90 timeout_timer->start(15000,TRUE); // 15 secs single shot 94 timeout_timer->start(15000,TRUE); // 15 secs single shot
91 QTimer::singleShot(500, this, SLOT(init())); 95 QTimer::singleShot(500, this, SLOT(init()));
92 96
93} 97}
94 98
95 99
96void ModemTransfer::ati_done() { 100void ModemTransfer::ati_done()
101{
97 scripttimer->stop(); 102 scripttimer->stop();
98 timeout_timer->stop(); 103 timeout_timer->stop();
99 _modem->closetty(); 104 _modem->closetty();
100 _modem->unlockdevice(); 105 _modem->unlockdevice();
101 hide(); 106 hide();
102 107
103 // open the result window 108 // open the result window
104 ModemInfo *mi = new ModemInfo(this); 109 ModemInfo *mi = new ModemInfo(this);
105 for(int i = 0; i < NUM_OF_ATI; i++) 110 for(int i = 0; i < NUM_OF_ATI; i++)
106 mi->setAtiString(i, ati_query_strings[i]); 111 mi->setAtiString(i, ati_query_strings[i]);
107 mi->showMaximized(); 112
108 mi->exec(); 113 QPEApplication::execDialog( mi );
109 delete mi; 114 delete mi;
110 115
111 accept(); 116 accept();
112} 117}
113 118
114 119
115void ModemTransfer::time_out_slot() { 120void ModemTransfer::time_out_slot()
121{
116 timeout_timer->stop(); 122 timeout_timer->stop();
117 scripttimer->stop(); 123 scripttimer->stop();
118 124
119 QMessageBox::warning(this, tr("Error"), QObject::tr("Modem Query timed out.")); 125 QMessageBox::warning(this, tr("Error"), QObject::tr("Modem Query timed out."));
120 reject(); 126 reject();
121} 127}
122 128
123 129
124void ModemTransfer::init() { 130void ModemTransfer::init()
131{
125 132
126 qApp->processEvents(); 133 qApp->processEvents();
127 134
128 int lock = _modem->lockdevice(); 135 int lock = _modem->lockdevice();
129 if (lock == 1) { 136 if (lock == 1)
137 {
130 138
131 statusBar->setText(QObject::tr("Modem device is locked.")); 139 statusBar->setText(QObject::tr("Modem device is locked."));
132 return; 140 return;
133 } 141 }
134 142
135 if (lock == -1) { 143 if (lock == -1)
144 {
136 145
137 statusBar->setText(QObject::tr("Unable to create modem lock file.")); 146 statusBar->setText(QObject::tr("Unable to create modem lock file."));
138 return; 147 return;
139 } 148 }
140 149
141 150
142 if(_modem->opentty()) { 151 if(_modem->opentty())
143 if(_modem->hangup()) { 152 {
153 if(_modem->hangup())
154 {
144 usleep(100000); // wait 0.1 secs 155 usleep(100000); // wait 0.1 secs
145 _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ... 156 _modem->writeLine("ATE0Q1V1"); // E0 don't echo the commands I send ...
146 157
147 statusBar->setText(QObject::tr("Modem Ready")); 158 statusBar->setText(QObject::tr("Modem Ready"));
148 qApp->processEvents(); 159 qApp->processEvents();
149 usleep(100000); // wait 0.1 secs 160 usleep(100000); // wait 0.1 secs
150 qApp->processEvents(); 161 qApp->processEvents();
151 scripttimer->start(1000); // this one does the ati query 162 scripttimer->start(1000); // this one does the ati query
152 163
153 // clear modem buffer 164 // clear modem buffer
154 _modem->flush(); 165 _modem->flush();
155 166
156 _modem->notify(this, SLOT(readChar(unsigned char))); 167 _modem->notify(this, SLOT(readChar(unsigned char)));
157 return; 168 return;
158 } 169 }
159 } 170 }
160 171
161 // opentty() or hangup() failed 172 // opentty() or hangup() failed
162 statusBar->setText(_modem->modemMessage()); 173 statusBar->setText(_modem->modemMessage());
163 step = 99; // wait until cancel is pressed 174 step = 99; // wait until cancel is pressed
164 _modem->unlockdevice(); 175 _modem->unlockdevice();
165} 176}
166 177
167 178
168void ModemTransfer::do_script() { 179void ModemTransfer::do_script()
180{
169 QString msg; 181 QString msg;
170 QString query; 182 QString query;
171 183
172 switch(step) { 184 switch(step)
185 {
173 case 0: 186 case 0:
174 readtty(); 187 readtty();
175 statusBar->setText("ATI..."); 188 statusBar->setText("ATI...");
176 progressBar->setProgress( progressBar->progress() + 1); 189 progressBar->setProgress( progressBar->progress() + 1);
177 _modem->writeLine("ATI\n"); 190 _modem->writeLine("ATI\n");
178 break; 191 break;
179 192
180 case 1: 193 case 1:
181 case 2: 194 case 2:
182 case 3: 195 case 3:
183 case 4: 196 case 4:
184 case 5: 197 case 5:
@@ -190,80 +203,85 @@ void ModemTransfer::do_script() {
190 statusBar->setText(msg); 203 statusBar->setText(msg);
191 progressBar->setProgress( progressBar->progress() + 1); 204 progressBar->setProgress( progressBar->progress() + 1);
192 _modem->writeLine(query.local8Bit()); 205 _modem->writeLine(query.local8Bit());
193 break; 206 break;
194 207
195 default: 208 default:
196 readtty(); 209 readtty();
197 ati_done(); 210 ati_done();
198 } 211 }
199 step++; 212 step++;
200} 213}
201 214
202void ModemTransfer::readChar(unsigned char c) { 215void ModemTransfer::readChar(unsigned char c)
216{
203 if(readbuffer.length() < 255) 217 if(readbuffer.length() < 255)
204 readbuffer += c; 218 readbuffer += c;
205} 219}
206 220
207void ModemTransfer::readtty() { 221void ModemTransfer::readtty()
222{
208 223
209 if (step == 0) 224 if (step == 0)
210 return; 225 return;
211 226
212 readbuffer.replace(QRegExp("[\n\r]")," "); // remove stray \n and \r 227 readbuffer.replace(QRegExp("[\n\r]")," "); // remove stray \n and \r
213 readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white 228 readbuffer = readbuffer.stripWhiteSpace(); // strip of leading or trailing white
214 // space 229 // space
215 230
216 if(step <= NUM_OF_ATI) 231 if(step <= NUM_OF_ATI)
217 ati_query_strings[step-1] = readbuffer.copy(); 232 ati_query_strings[step-1] = readbuffer.copy();
218 233
219 readbuffer = ""; 234 readbuffer = "";
220} 235}
221 236
222 237
223void ModemTransfer::cancelbutton() { 238void ModemTransfer::cancelbutton()
239{
224 scripttimer->stop(); 240 scripttimer->stop();
225 _modem->stop(); 241 _modem->stop();
226 timeout_timer->stop(); 242 timeout_timer->stop();
227 243
228 statusBar->setText(QObject::tr("One moment please...")); 244 statusBar->setText(QObject::tr("One moment please..."));
229 qApp->processEvents(); 245 qApp->processEvents();
230 246
231 _modem->hangup(); 247 _modem->hangup();
232 248
233 _modem->closetty(); 249 _modem->closetty();
234 _modem->unlockdevice(); 250 _modem->unlockdevice();
235 reject(); 251 reject();
236} 252}
237 253
238 254
239void ModemTransfer::closeEvent( QCloseEvent *e ) { 255void ModemTransfer::closeEvent( QCloseEvent *e )
256{
240 cancelbutton(); 257 cancelbutton();
241 e->accept(); 258 e->accept();
242} 259}
243 260
244 261
245ModemInfo::ModemInfo(QWidget *parent, const char* name) 262ModemInfo::ModemInfo(QWidget *parent, const char* name)
246 : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder) 263 : QDialog(parent, name, TRUE, WStyle_Customize|WStyle_NormalBorder)
247{ 264{
248 QString label_text; 265 QString label_text;
249 266
250 setCaption(QObject::tr("Modem Query Results")); 267 setCaption(QObject::tr("Modem Query Results"));
251 // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); 268 // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
252 269
253 QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); 270 QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
254 271
255 QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5); 272 QGridLayout *l1 = new QGridLayout(NUM_OF_ATI, 2, 5);
256 tl->addLayout(l1, 1); 273 tl->addLayout(l1, 1);
257 for(int i = 0 ; i < NUM_OF_ATI ; i++) { 274 for(int i = 0 ; i < NUM_OF_ATI ; i++)
275 {
258 276
259 label_text = ""; 277 label_text = "";
260 if ( i == 0) 278 if ( i == 0)
261 label_text.sprintf("ATI :"); 279 label_text.sprintf("ATI :");
262 else 280 else
263 label_text.sprintf("ATI %d:", i ); 281 label_text.sprintf("ATI %d:", i );
264 282
265 ati_label[i] = new QLabel(label_text, this); 283 ati_label[i] = new QLabel(label_text, this);
266 l1->addWidget(ati_label[i], i, 0); 284 l1->addWidget(ati_label[i], i, 0);
267 285
268 ati_label_result[i] = new QLineEdit(this); 286 ati_label_result[i] = new QLineEdit(this);
269 ati_label_result[i]->setMinimumWidth(fontMetrics().width('H') * 24); 287 ati_label_result[i]->setMinimumWidth(fontMetrics().width('H') * 24);
@@ -277,18 +295,19 @@ ModemInfo::ModemInfo(QWidget *parent, const char* name)
277 ok->setFocus(); 295 ok->setFocus();
278 296
279 tl->addLayout(l2); 297 tl->addLayout(l2);
280 l2->addStretch(1); 298 l2->addStretch(1);
281 299
282 connect(ok, SIGNAL(clicked()), SLOT(accept())); 300 connect(ok, SIGNAL(clicked()), SLOT(accept()));
283 l2->addWidget(ok); 301 l2->addWidget(ok);
284 302
285 setMinimumSize(sizeHint()); 303 setMinimumSize(sizeHint());
286} 304}
287 305
288 306
289void ModemInfo::setAtiString(int i, QString s) { 307void ModemInfo::setAtiString(int i, QString s)
308{
290 if(i < NUM_OF_ATI) 309 if(i < NUM_OF_ATI)
291 ati_label_result[i]->setText(s); 310 ati_label_result[i]->setText(s);
292} 311}
293 312
294//#include "modeminfo.moc" 313//#include "modeminfo.moc"
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index f7dacf6..a7caffe 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -1,38 +1,46 @@
1#include <errno.h>
2#include <signal.h>
3
4
5#include <qpe/config.h>
6 1
7#include "modem.h" 2#include "modem.h"
8#include "pppconfig.h" 3#include "pppconfig.h"
9#include "pppmodule.h" 4#include "pppmodule.h"
10#include "pppdata.h" 5#include "pppdata.h"
11#include "interfaceinformationppp.h" 6#include "interfaceinformationppp.h"
12#include "interfaceppp.h" 7#include "interfaceppp.h"
13 8
9/* OPIE */
10#include <qpe/config.h>
11#include <qpe/qpeapplication.h>
12
13/* QT */
14
15/* STD */
16#include <errno.h>
17#include <signal.h>
18
14// don't polute global namespace 19// don't polute global namespace
15namespace { 20namespace
21{
16 /* 22 /*
17 * If network settings is qutting and we've ppp 23 * If network settings is qutting and we've ppp
18 * devices open we need to save the pid_t the PPData 24 * devices open we need to save the pid_t the PPData
19 * and the interface number 25 * and the interface number
20 */ 26 */
21 struct Connection { 27 struct Connection
28 {
22 pid_t pid; 29 pid_t pid;
23 QString device; 30 QString device;
24 QString name; 31 QString name;
25 }; 32 };
26 class InterfaceKeeper { 33 class InterfaceKeeper
34 {
27 public: 35 public:
28 InterfaceKeeper(); 36 InterfaceKeeper();
29 ~InterfaceKeeper(); 37 ~InterfaceKeeper();
30 38
31 void addInterface( pid_t, const QString& pppDev, const QString& name ); 39 void addInterface( pid_t, const QString& pppDev, const QString& name );
32 QMap<QString, Connection> interfaces()const; // will check if still available 40 QMap<QString, Connection> interfaces()const; // will check if still available
33 private: 41 private:
34 bool isAvailable( pid_t )const; 42 bool isAvailable( pid_t )const;
35 QMap<QString, Connection> m_interfaces; 43 QMap<QString, Connection> m_interfaces;
36 }; 44 };
37} 45}
38 46
@@ -44,207 +52,232 @@ namespace {
44 * we need to be able to shut it down... 52 * we need to be able to shut it down...
45 */ 53 */
46PPPModule::PPPModule() : Module() 54PPPModule::PPPModule() : Module()
47{ 55{
48 InterfaceKeeper inFace; 56 InterfaceKeeper inFace;
49 QMap<QString,Connection> running = inFace.interfaces(); 57 QMap<QString,Connection> running = inFace.interfaces();
50 QStringList handledInterfaceNames; 58 QStringList handledInterfaceNames;
51 59
52 QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); 60 QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces();
53 QMap<QString,QString>::Iterator it; 61 QMap<QString,QString>::Iterator it;
54 InterfacePPP *iface; 62 InterfacePPP *iface;
55 qDebug("getting interfaces"); 63 qDebug("getting interfaces");
56 for( it = ifaces.begin(); it != ifaces.end(); ++it ){ 64 for( it = ifaces.begin(); it != ifaces.end(); ++it )
65 {
57 qDebug("ifaces %s %s", it.key().latin1(), it.data().latin1() ); 66 qDebug("ifaces %s %s", it.key().latin1(), it.data().latin1() );
58 iface = new InterfacePPP( 0, it.key() ); 67 iface = new InterfacePPP( 0, it.key() );
59 iface->setHardwareName( it.data() ); 68 iface->setHardwareName( it.data() );
60 list.append( (Interface*)iface ); 69 list.append( (Interface*)iface );
61 70
62 // check if (*it) is one of the running ifaces 71 // check if (*it) is one of the running ifaces
63 if ( running.contains( it.data() ) ) { 72 if ( running.contains( it.data() ) )
73 {
64 qDebug("iface is running %s", it.key().latin1() ); 74 qDebug("iface is running %s", it.key().latin1() );
65 handledInterfaceNames << running[it.data()].device; 75 handledInterfaceNames << running[it.data()].device;
66 iface->setStatus( true ); 76 iface->setStatus( true );
67 iface->setPPPDpid( running[it.data()].pid ); 77 iface->setPPPDpid( running[it.data()].pid );
68 iface->modem()->setPPPDevice( running[it.data()].device ); 78 iface->modem()->setPPPDevice( running[it.data()].device );
69 iface->refresh(); 79 iface->refresh();
70 } 80 }
71 } 81 }
72 82
73 setHandledInterfaceNames( handledInterfaceNames ); 83 setHandledInterfaceNames( handledInterfaceNames );
74} 84}
75 85
76/** 86/**
77 * Delete any interfaces that we own. 87 * Delete any interfaces that we own.
78 */ 88 */
79PPPModule::~PPPModule(){ 89PPPModule::~PPPModule()
90{
80 qDebug("PPPModule::~PPPModule() " ); 91 qDebug("PPPModule::~PPPModule() " );
81 QMap<QString,QString> ifaces; 92 QMap<QString,QString> ifaces;
82 InterfaceKeeper keeper; 93 InterfaceKeeper keeper;
83 Interface *i; 94 Interface *i;
84 for ( i=list.first(); i != 0; i=list.next() ){ 95 for ( i=list.first(); i != 0; i=list.next() )
96 {
85 /* if online save the state */ 97 /* if online save the state */
86 if ( i->getStatus() ) { 98 if ( i->getStatus() )
99 {
87 qDebug("Iface %s is still up", i->getHardwareName().latin1() ); 100 qDebug("Iface %s is still up", i->getHardwareName().latin1() );
88 InterfacePPP* ppp = static_cast<InterfacePPP*>(i); 101 InterfacePPP* ppp = static_cast<InterfacePPP*>(i);
89 keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); 102 keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() );
90 } 103 }
91 ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); 104 ifaces.insert( i->getInterfaceName(), i->getHardwareName() );
92 delete i; 105 delete i;
93 } 106 }
94 PPPData::setConfiguredInterfaces( ifaces ); 107 PPPData::setConfiguredInterfaces( ifaces );
95} 108}
96 109
97/** 110/**
98 * Change the current profile 111 * Change the current profile
99 */ 112 */
100void PPPModule::setProfile(const QString &newProfile){ 113void PPPModule::setProfile(const QString &newProfile)
114{
101 profile = newProfile; 115 profile = newProfile;
102} 116}
103 117
104/** 118/**
105 * get the icon name for this device. 119 * get the icon name for this device.
106 * @param Interface* can be used in determining the icon. 120 * @param Interface* can be used in determining the icon.
107 * @return QString the icon name (minus .png, .gif etc) 121 * @return QString the icon name (minus .png, .gif etc)
108 */ 122 */
109QString PPPModule::getPixmapName(Interface* ){ 123QString PPPModule::getPixmapName(Interface* )
124{
110 return "ppp"; 125 return "ppp";
111} 126}
112 127
113/** 128/**
114 * Check to see if the interface i is owned by this module. 129 * Check to see if the interface i is owned by this module.
115 * @param Interface* interface to check against 130 * @param Interface* interface to check against
116 * @return bool true if i is owned by this module, false otherwise. 131 * @return bool true if i is owned by this module, false otherwise.
117 */ 132 */
118bool PPPModule::isOwner(Interface *i){ 133bool PPPModule::isOwner(Interface *i)
134{
119 return list.find( i ) != -1; 135 return list.find( i ) != -1;
120} 136}
121 137
122/** 138/**
123 * Create, and return the WLANConfigure Module 139 * Create, and return the WLANConfigure Module
124 * @return QWidget* pointer to this modules configure. 140 * @return QWidget* pointer to this modules configure.
125 */ 141 */
126QWidget *PPPModule::configure(Interface *i){ 142QWidget *PPPModule::configure(Interface *i)
143{
127 qDebug("return ModemWidget"); 144 qDebug("return ModemWidget");
128 PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i, 145 PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i,
129 0, "PPPConfig", false, 146 0, "PPPConfig", false,
130 (Qt::WDestructiveClose | Qt::WStyle_ContextHelp)); 147 (Qt::WDestructiveClose | Qt::WStyle_ContextHelp));
131 return pppconfig; 148 return pppconfig;
132} 149}
133 150
134/** 151/**
135 * Create, and return the Information Module 152 * Create, and return the Information Module
136 * @return QWidget* pointer to this modules info. 153 * @return QWidget* pointer to this modules info.
137 */ 154 */
138QWidget *PPPModule::information(Interface *i){ 155QWidget *PPPModule::information(Interface *i)
156{
139 // We don't have any advanced pppd information widget yet :-D 157 // We don't have any advanced pppd information widget yet :-D
140 // TODO ^ 158 // TODO ^
141 159
142 return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i ); 160 return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i );
143} 161}
144 162
145/** 163/**
146 * Get all active (up or down) interfaces 164 * Get all active (up or down) interfaces
147 * @return QList<Interface> A list of interfaces that exsist that havn't 165 * @return QList<Interface> A list of interfaces that exsist that havn't
148 * been called by isOwner() 166 * been called by isOwner()
149 */ 167 */
150QList<Interface> PPPModule::getInterfaces(){ 168QList<Interface> PPPModule::getInterfaces()
169{
151 // List all of the files in the peer directory 170 // List all of the files in the peer directory
152 qDebug("PPPModule::getInterfaces"); 171 qDebug("PPPModule::getInterfaces");
153 return list; 172 return list;
154} 173}
155 174
156/** 175/**
157 * Attempt to add a new interface as defined by name 176 * Attempt to add a new interface as defined by name
158 * @param name the name of the type of interface that should be created given 177 * @param name the name of the type of interface that should be created given
159 * by possibleNewInterfaces(); 178 * by possibleNewInterfaces();
160 * @return Interface* NULL if it was unable to be created. 179 * @return Interface* NULL if it was unable to be created.
161 */ 180 */
162Interface *PPPModule::addNewInterface(const QString &newInterface){ 181Interface *PPPModule::addNewInterface(const QString &newInterface)
182{
163 183
164 InterfacePPP *ifaceppp; 184 InterfacePPP *ifaceppp;
165 Interface *iface; 185 Interface *iface;
166 ifaceppp = new InterfacePPP(); 186 ifaceppp = new InterfacePPP();
167 PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true); 187 PPPConfigWidget imp(ifaceppp, 0, "PPPConfigImp", true);
168 imp.showMaximized(); 188
169 if(imp.exec() == QDialog::Accepted ){ 189 if( QPEApplication::execDialog( &imp ) == QDialog::Accepted )
190 {
170 iface = (InterfacePPP*) ifaceppp; 191 iface = (InterfacePPP*) ifaceppp;
171 iface->setModuleOwner( this ); 192 iface->setModuleOwner( this );
172 list.append( iface ); 193 list.append( iface );
173 return iface; 194 return iface;
174 }else { 195 }
196 else
197 {
175 delete ifaceppp; 198 delete ifaceppp;
176 iface = NULL; 199 iface = NULL;
177 } 200 }
178 return iface; 201 return iface;
179} 202}
180 203
181/** 204/**
182 * Attempts to remove the interface, doesn't delete i 205 * Attempts to remove the interface, doesn't delete i
183 * @return bool true if successful, false otherwise. 206 * @return bool true if successful, false otherwise.
184 */ 207 */
185bool PPPModule::remove(Interface *i){ 208bool PPPModule::remove(Interface *i)
209{
186 return list.remove(i); 210 return list.remove(i);
187} 211}
188 212
189void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces) 213void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces)
190{ 214{
191 newIfaces.insert(QObject::tr("PPP") , 215 newIfaces.insert(QObject::tr("PPP") ,
192 QObject::tr("generic ppp device")); 216 QObject::tr("generic ppp device"));
193} 217}
194 218
195 219
196 220
197namespace { 221namespace
198 InterfaceKeeper::InterfaceKeeper( ) { 222{
199 } 223 InterfaceKeeper::InterfaceKeeper( )
200 InterfaceKeeper::~InterfaceKeeper() { 224 {}
225 InterfaceKeeper::~InterfaceKeeper()
226 {
201 Config cfg("ppp_plugin_keeper"); 227 Config cfg("ppp_plugin_keeper");
202 QStringList lst = cfg.groupList(); 228 QStringList lst = cfg.groupList();
203 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { 229 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it )
230 {
204 Connection con; 231 Connection con;
205 cfg.setGroup( (*it) ); 232 cfg.setGroup( (*it) );
206 cfg.clearGroup(); 233 cfg.clearGroup();
207 } 234 }
208 235
209 for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it ) { 236 for (QMap<QString, Connection>::Iterator it = m_interfaces.begin(); it != m_interfaces.end(); ++it )
237 {
210 Connection con = it.data(); 238 Connection con = it.data();
211 cfg.setGroup( con.name ); 239 cfg.setGroup( con.name );
212 cfg.writeEntry( "pid", con.pid ); 240 cfg.writeEntry( "pid", con.pid );
213 cfg.writeEntry( "device", con.device ); 241 cfg.writeEntry( "device", con.device );
214 } 242 }
215 } 243 }
216 void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name ) { 244 void InterfaceKeeper::addInterface(pid_t pid, const QString& dev, const QString& name )
245 {
217 Connection con; 246 Connection con;
218 con.pid = pid; 247 con.pid = pid;
219 con.device = dev; 248 con.device = dev;
220 con.name = name; 249 con.name = name;
221 m_interfaces.insert( name, con ); 250 m_interfaces.insert( name, con );
222 } 251 }
223 QMap<QString, Connection> InterfaceKeeper::interfaces()const { 252 QMap<QString, Connection> InterfaceKeeper::interfaces()const
253 {
224 Config cfg("ppp_plugin_keeper"); 254 Config cfg("ppp_plugin_keeper");
225 QMap<QString, Connection> ifaces; 255 QMap<QString, Connection> ifaces;
226 QStringList lst = cfg.groupList(); 256 QStringList lst = cfg.groupList();
227 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) { 257 for (QStringList::Iterator it = lst.begin(); it != lst.end(); ++it )
258 {
228 Connection con; 259 Connection con;
229 cfg.setGroup( (*it) ); 260 cfg.setGroup( (*it) );
230 con.name = (*it); 261 con.name = (*it);
231 con.pid = cfg.readNumEntry("pid"); 262 con.pid = cfg.readNumEntry("pid");
232 con.device = cfg.readEntry("device"); 263 con.device = cfg.readEntry("device");
233 qDebug(" %s %s %d", con.name.latin1(), con.device.latin1(), con.pid ); 264 qDebug(" %s %s %d", con.name.latin1(), con.device.latin1(), con.pid );
234 265
235 if ( con.pid != -1 && isAvailable( con.pid ) ) 266 if ( con.pid != -1 && isAvailable( con.pid ) )
236 ifaces.insert( con.name, con ); 267 ifaces.insert( con.name, con );
237 } 268 }
238 return ifaces; 269 return ifaces;
239 } 270 }
240 bool InterfaceKeeper::isAvailable( pid_t p)const { 271 bool InterfaceKeeper::isAvailable( pid_t p)const
241 if (::kill(p, 0 ) == 0 || errno != ESRCH ) { 272 {
273 if (::kill(p, 0 ) == 0 || errno != ESRCH )
274 {
242 qDebug("isAvailable %d", p); 275 qDebug("isAvailable %d", p);
243 return true; 276 return true;
244 } 277 }
245 278
246 qDebug("notAvailable %d", p); 279 qDebug("notAvailable %d", p);
247 return false; 280 return false;
248 } 281 }
249 282
250} 283}
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index 07bf73f..74d7f8e 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -1,29 +1,32 @@
1
1#include "wlanmodule.h" 2#include "wlanmodule.h"
2#include "wlanimp2.h" 3#include "wlanimp2.h"
3#include "infoimp.h" 4#include "infoimp.h"
4#include "wextensions.h" 5#include "wextensions.h"
5#include "interfaceinformationimp.h" 6#include "interfaceinformationimp.h"
6 7
8/* OPIE */
9#include <qpe/qpeapplication.h>
10
11/* QT */
7#include <qcheckbox.h> 12#include <qcheckbox.h>
8#include <qcombobox.h> 13#include <qcombobox.h>
9#include <qlabel.h> 14#include <qlabel.h>
10#include <qlineedit.h> 15#include <qlineedit.h>
11#include <qprogressbar.h> 16#include <qprogressbar.h>
12#include <qspinbox.h> 17#include <qspinbox.h>
13#include <qtabwidget.h> 18#include <qtabwidget.h>
14 19
15 20
16
17
18/** 21/**
19 * Constructor, find all of the possible interfaces 22 * Constructor, find all of the possible interfaces
20 */ 23 */
21WLANModule::WLANModule() 24WLANModule::WLANModule()
22 : Module(), 25 : Module(),
23 wlanconfigWiget(0) 26 wlanconfigWiget(0)
24{ 27{
25} 28}
26 29
27/** 30/**
28 * Delete any interfaces that we own. 31 * Delete any interfaces that we own.
29 */ 32 */
@@ -163,43 +166,43 @@ void WLANModule::receive(const QCString &param, const QByteArray &arg)
163 } 166 }
164 } 167 }
165 168
166 if (ifa == 0){ 169 if (ifa == 0){
167 qDebug("WLANModule Did not find %s",interface.latin1()); 170 qDebug("WLANModule Did not find %s",interface.latin1());
168 qDebug("skipping"); 171 qDebug("skipping");
169 count = 0; 172 count = 0;
170 } 173 }
171 174
172 if (count == 2){ 175 if (count == 2){
173 // those should call the interface directly 176 // those should call the interface directly
174 QWidget *info = getInfo( ifa ); 177 QWidget *info = getInfo( ifa );
175 info->showMaximized(); 178 QPEApplication::showWidget( info );
176 179
177 if ( action.contains("start" ) ){ 180 if ( action.contains("start" ) ){
178 ifa->start(); 181 ifa->start();
179 } else if ( action.contains("restart" ) ){ 182 } else if ( action.contains("restart" ) ){
180 ifa->restart(); 183 ifa->restart();
181 } else if ( action.contains("stop" ) ){ 184 } else if ( action.contains("stop" ) ){
182 ifa->stop(); 185 ifa->stop();
183 }else if ( action.contains("refresh" ) ){ 186 }else if ( action.contains("refresh" ) ){
184 ifa->refresh(); 187 ifa->refresh();
185 } 188 }
186 }else if (count == 3){ 189 }else if (count == 3){
187 QString value; 190 QString value;
188 if (!wlanconfigWiget){ 191 if (!wlanconfigWiget){
189 //FIXME: what if it got closed meanwhile? 192 //FIXME: what if it got closed meanwhile?
190 wlanconfigWiget = (WLANImp*) configure(ifa); 193 wlanconfigWiget = (WLANImp*) configure(ifa);
191 toShow = (QDialog*) wlanconfigWiget; 194 toShow = (QDialog*) wlanconfigWiget;
192 } 195 }
193 wlanconfigWiget->showMaximized(); 196 QPEApplication::showWidget( wlanconfigWiget );
194 stream >> value; 197 stream >> value;
195 qDebug("WLANModule (build 4) is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() ); 198 qDebug("WLANModule (build 4) is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() );
196 if (value.isEmpty()){ 199 if (value.isEmpty()){
197 qDebug("value is empty!!!\nreturning"); 200 qDebug("value is empty!!!\nreturning");
198 return; 201 return;
199 } 202 }
200 if ( action.contains("ESSID") ){ 203 if ( action.contains("ESSID") ){
201 QComboBox *combo = wlanconfigWiget->essid; 204 QComboBox *combo = wlanconfigWiget->essid;
202 bool found = false; 205 bool found = false;
203 for ( int i = 0; i < combo->count(); i++) 206 for ( int i = 0; i < combo->count(); i++)
204 if ( combo->text( i ) == value ){ 207 if ( combo->text( i ) == value ){
205 combo->setCurrentItem( i ); 208 combo->setCurrentItem( i );