summaryrefslogtreecommitdiff
authorjosef <josef>2002-10-18 09:31:09 (UTC)
committer josef <josef>2002-10-18 09:31:09 (UTC)
commit997c466fd91843699280a770cbf34e6917dcee8a (patch) (unidiff)
tree5de950d62700508673b5d79e7bf6b402a3ba49f0
parent07a1cb4baaf544e0e594040bbe8e5872ccb34c0f (diff)
downloadopie-997c466fd91843699280a770cbf34e6917dcee8a.zip
opie-997c466fd91843699280a770cbf34e6917dcee8a.tar.gz
opie-997c466fd91843699280a770cbf34e6917dcee8a.tar.bz2
- improve dialer
It works now correctly for me :) But a few details must be changed (i.e. no hardcoded values)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/dialer.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp
index 10c16ef..bd6b50f 100644
--- a/noncore/apps/opie-console/dialer.cpp
+++ b/noncore/apps/opie-console/dialer.cpp
@@ -118,21 +118,23 @@ void Dialer::dial(const QString& number)
118 } 118 }
119 119
120 if(usercancel) 120 if(usercancel)
121 { 121 {
122 // modem hangup
123 trydial(QString::null);
122 reject(); 124 reject();
123 } 125 }
124} 126}
125 127
126void Dialer::trydial(const QString& number) 128void Dialer::trydial(const QString& number)
127{ 129{
128 if(state != state_cancel) 130 //if(state != state_cancel)
129 { 131 //{
130 switchState(state_preinit); 132 if(state != state_cancel) switchState(state_preinit);
131 send("+++ATH"); 133 send("+++ATH");
132 send(""); 134 send("");
133 //QString response = receive(); 135 //QString response = receive();
134 } 136 //}
135 137
136 if(state != state_cancel) 138 if(state != state_cancel)
137 { 139 {
138 switchState(state_init); 140 switchState(state_init);
@@ -146,9 +148,9 @@ void Dialer::trydial(const QString& number)
146 if(state != state_cancel) 148 if(state != state_cancel)
147 { 149 {
148 switchState(state_options); 150 switchState(state_options);
149 151
150 send("ATM0L0"); 152 send("ATM3L3");
151 QString response3 = receive(); 153 QString response3 = receive();
152 if(!response3.contains("\nOK\r")) 154 if(!response3.contains("\nOK\r"))
153 reset(); 155 reset();
154 } 156 }
@@ -169,14 +171,19 @@ void Dialer::trydial(const QString& number)
169 171
170 send(QString("ATDT %1").arg(number)); 172 send(QString("ATDT %1").arg(number));
171 //send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number)); 173 //send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number));
172 QString response5 = receive(); 174 QString response5 = receive();
173 if(!response5.contains("\nOK\r")) 175 if(!response5.contains("\nCONNECT"))
174 { 176 {
175 QMessageBox::warning(this, 177 if(response5.contains("BUSY"))
176 QObject::tr("Failure"), 178 switchState(state_dialing);
177 QObject::tr("Dialing the number failed.")); 179 else
178 slotCancel(); 180 {
181 QMessageBox::warning(this,
182 QObject::tr("Failure"),
183 QObject::tr("Dialing the number failed."));
184 slotCancel();
185 }
179 } 186 }
180 } 187 }
181 188
182 if(state != state_cancel) 189 if(state != state_cancel)
@@ -207,11 +214,14 @@ qWarning("Sending: '%s'", m.latin1());
207} 214}
208 215
209QString Dialer::receive() 216QString Dialer::receive()
210{ 217{
218 QString buf;
211 char buffer[1024]; 219 char buffer[1024];
212 int ret; 220 int ret;
213 221
222 qApp->processEvents();
223
214 while(1) 224 while(1)
215 { 225 {
216 ret = ::read(m_fd, buffer, sizeof(buffer)); 226 ret = ::read(m_fd, buffer, sizeof(buffer));
217 227
@@ -219,19 +229,22 @@ QString Dialer::receive()
219 { 229 {
220 for(int i = 0; i < ret; i++) 230 for(int i = 0; i < ret; i++)
221 buffer[i] = buffer[i] & 0x7F; 231 buffer[i] = buffer[i] & 0x7F;
222 buffer[ret] = 0; 232 buffer[ret] = 0;
223 qWarning("Receiving: '%s'", buffer); 233qWarning("Got: '%s'", buffer);
224 return QString(buffer); 234 buf.append(QString(buffer));
235 if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY")))
236{
237qWarning("Receiving: '%s'", buf.latin1());
238 return buf;
239}
225 } 240 }
226 else if(ret < 0) 241 else if(ret < 0)
227 { 242 {
228 if(errno != EAGAIN) reset(); 243 if(errno != EAGAIN) reset();
229 } 244 }
230 } 245 }
231 246
232 //for(int i = 0; i < 200000;i++)
233 //qApp->processEvents();
234 return QString::null; 247 return QString::null;
235} 248}
236 249
237void Dialer::switchState(int newstate) 250void Dialer::switchState(int newstate)