summaryrefslogtreecommitdiff
authorjosef <josef>2002-10-18 11:36:34 (UTC)
committer josef <josef>2002-10-18 11:36:34 (UTC)
commit24c0ae04669e94d554fe8ef49888ffb5a6a00656 (patch) (unidiff)
tree96e48d488555d789de7ac73797d016c7e8262956
parent3484cd354a54bcc20d389b123423028e09d884df (diff)
downloadopie-24c0ae04669e94d554fe8ef49888ffb5a6a00656.zip
opie-24c0ae04669e94d554fe8ef49888ffb5a6a00656.tar.gz
opie-24c0ae04669e94d554fe8ef49888ffb5a6a00656.tar.bz2
- increase dialog responsiveness
The higher the value (currently 100) is, the faster the modem dials, but lower values guarantee a smoother UI.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/dialer.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp
index 7bf9352..51d4093 100644
--- a/noncore/apps/opie-console/dialer.cpp
+++ b/noncore/apps/opie-console/dialer.cpp
@@ -131,165 +131,166 @@ void Dialer::dial(const QString& number)
131 } 131 }
132} 132}
133 133
134void Dialer::trydial(const QString& number) 134void Dialer::trydial(const QString& number)
135{ 135{
136 //if(state != state_cancel) 136 //if(state != state_cancel)
137 //{ 137 //{
138 if(state != state_cancel) switchState(state_preinit); 138 if(state != state_cancel) switchState(state_preinit);
139 send("+++ATH"); 139 send("+++ATH");
140 send(""); 140 send("");
141 //QString response = receive(); 141 //QString response = receive();
142 //} 142 //}
143 143
144 if(state != state_cancel) 144 if(state != state_cancel)
145 { 145 {
146 switchState(state_init); 146 switchState(state_init);
147 send("ATZ"); 147 send("ATZ");
148 //send(m_profile.readEntry("InitString")); 148 //send(m_profile.readEntry("InitString"));
149 QString response2 = receive(); 149 QString response2 = receive();
150 if(!response2.contains("\nOK\r")) 150 if(!response2.contains("\nOK\r"))
151 reset(); 151 reset();
152 } 152 }
153 153
154 if(state != state_cancel) 154 if(state != state_cancel)
155 { 155 {
156 switchState(state_options); 156 switchState(state_options);
157 157
158 send("ATM3L3"); 158 send("ATM3L3");
159 QString response3 = receive(); 159 QString response3 = receive();
160 if(!response3.contains("\nOK\r")) 160 if(!response3.contains("\nOK\r"))
161 reset(); 161 reset();
162 } 162 }
163 163
164 if(state != state_cancel) 164 if(state != state_cancel)
165 { 165 {
166 switchState(state_dialtone); 166 switchState(state_dialtone);
167 167
168 send("ATX1"); 168 send("ATX1");
169 QString response4 = receive(); 169 QString response4 = receive();
170 if(!response4.contains("\nOK\r")) 170 if(!response4.contains("\nOK\r"))
171 reset(); 171 reset();
172 } 172 }
173 173
174 if(state != state_cancel) 174 if(state != state_cancel)
175 { 175 {
176 switchState(state_dialing); 176 switchState(state_dialing);
177 177
178 send(QString("ATDT %1").arg(number)); 178 send(QString("ATDT %1").arg(number));
179 //send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number)); 179 //send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number));
180 QString response5 = receive(); 180 QString response5 = receive();
181 if(!response5.contains("\nCONNECT")) 181 if(!response5.contains("\nCONNECT"))
182 { 182 {
183 if(response5.contains("BUSY")) 183 if(response5.contains("BUSY"))
184 switchState(state_dialing); 184 switchState(state_dialing);
185 else 185 else
186 { 186 {
187 QMessageBox::warning(this, 187 QMessageBox::warning(this,
188 QObject::tr("Failure"), 188 QObject::tr("Failure"),
189 QObject::tr("Dialing the number failed.")); 189 QObject::tr("Dialing the number failed."));
190 slotCancel(); 190 slotCancel();
191 } 191 }
192 } 192 }
193 } 193 }
194 194
195 if(state != state_cancel) 195 if(state != state_cancel)
196 { 196 {
197 switchState(state_online); 197 switchState(state_online);
198 } 198 }
199} 199}
200 200
201void Dialer::send(const QString& msg) 201void Dialer::send(const QString& msg)
202{ 202{
203 QString m = msg; 203 QString m = msg;
204 int bytes; 204 int bytes;
205 QString termination; 205 QString termination;
206 206
207qWarning("Sending: '%s'", m.latin1()); 207qWarning("Sending: '%s'", m.latin1());
208 208
209 termination = "\r"; 209 termination = "\r";
210 //termination = m_profile.readEntry("Termination"); 210 //termination = m_profile.readEntry("Termination");
211 if(termination == "\n") m = m + "\n"; 211 if(termination == "\n") m = m + "\n";
212 else if(termination == "\r") m = m + "\r"; 212 else if(termination == "\r") m = m + "\r";
213 else m = m + "\r\n"; 213 else m = m + "\r\n";
214 214
215 bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit())); 215 bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit()));
216 if(bytes < 0) 216 if(bytes < 0)
217 { 217 {
218 reset(); 218 reset();
219 } 219 }
220} 220}
221 221
222QString Dialer::receive() 222QString Dialer::receive()
223{ 223{
224 QString buf; 224 QString buf;
225 char buffer[1024]; 225 char buffer[1024];
226 int ret; 226 int ret;
227 227 int counter;
228 qApp->processEvents();
229 228
230 while(1) 229 while(1)
231 { 230 {
232 ret = ::read(m_fd, buffer, sizeof(buffer)); 231 ret = ::read(m_fd, buffer, sizeof(buffer));
233 232
234 if(ret > 0) 233 if(ret > 0)
235 { 234 {
236 for(int i = 0; i < ret; i++) 235 for(int i = 0; i < ret; i++)
237 buffer[i] = buffer[i] & 0x7F; 236 buffer[i] = buffer[i] & 0x7F;
238 buffer[ret] = 0; 237 buffer[ret] = 0;
239qWarning("Got: '%s'", buffer); 238qWarning("Got: '%s'", buffer);
240 buf.append(QString(buffer)); 239 buf.append(QString(buffer));
241 if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY"))) 240 if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY")))
242{ 241{
243qWarning("Receiving: '%s'", buf.latin1()); 242qWarning("Receiving: '%s'", buf.latin1());
244 return buf; 243 return buf;
245} 244}
246 } 245 }
247 else if(ret < 0) 246 else if(ret < 0)
248 { 247 {
249 if(errno != EAGAIN) reset(); 248 if(errno != EAGAIN) reset();
249 else if(!(counter++ % 100)) qApp->processEvents();
250 } 250 }
251 else if(!(counter++ % 100)) qApp->processEvents();
251 } 252 }
252 253
253 return QString::null; 254 return QString::null;
254} 255}
255 256
256void Dialer::switchState(int newstate) 257void Dialer::switchState(int newstate)
257{ 258{
258 int oldstate = state; 259 int oldstate = state;
259 state = newstate; 260 state = newstate;
260 261
261 switch(state) 262 switch(state)
262 { 263 {
263 case state_cancel: 264 case state_cancel:
264 status->setText(QObject::tr("Cancelling...")); 265 status->setText(QObject::tr("Cancelling..."));
265 progress->setProgress(0); 266 progress->setProgress(0);
266 break; 267 break;
267 case state_preinit: 268 case state_preinit:
268 status->setText(QObject::tr("Searching modem")); 269 status->setText(QObject::tr("Searching modem"));
269 progress->setProgress(10); 270 progress->setProgress(10);
270 break; 271 break;
271 case state_init: 272 case state_init:
272 status->setText(QObject::tr("Initializing...")); 273 status->setText(QObject::tr("Initializing..."));
273 progress->setProgress(20); 274 progress->setProgress(20);
274 break; 275 break;
275 case state_options: 276 case state_options:
276 status->setText(QObject::tr("Reset speakers")); 277 status->setText(QObject::tr("Reset speakers"));
277 progress->setProgress(30); 278 progress->setProgress(30);
278 break; 279 break;
279 case state_dialtone: 280 case state_dialtone:
280 status->setText(QObject::tr("Turning off dialtone")); 281 status->setText(QObject::tr("Turning off dialtone"));
281 progress->setProgress(40); 282 progress->setProgress(40);
282 break; 283 break;
283 case state_dialing: 284 case state_dialing:
284 if(oldstate != state_dialing) status->setText(QObject::tr("Dial number")); 285 if(oldstate != state_dialing) status->setText(QObject::tr("Dial number"));
285 else status->setText(QObject::tr("Line busy, redialing number")); 286 else status->setText(QObject::tr("Line busy, redialing number"));
286 progress->setProgress(50); 287 progress->setProgress(50);
287 break; 288 break;
288 case state_online: 289 case state_online:
289 status->setText(QObject::tr("Connection established")); 290 status->setText(QObject::tr("Connection established"));
290 progress->setProgress(100); 291 progress->setProgress(100);
291 cancel->setText(QObject::tr("Dismiss")); 292 cancel->setText(QObject::tr("Dismiss"));
292 break; 293 break;
293 } 294 }
294} 295}
295 296