Diffstat (limited to 'noncore/apps/opie-console/dialer.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/dialer.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp index 67ad10e..7010594 100644 --- a/noncore/apps/opie-console/dialer.cpp +++ b/noncore/apps/opie-console/dialer.cpp | |||
@@ -1,21 +1,26 @@ | |||
1 | #include "dialer.h" | 1 | #include "dialer.h" |
2 | #include "io_modem.h" | ||
3 | |||
4 | /* OPIE */ | ||
5 | #include <opie2/odebug.h> | ||
6 | using namespace Opie::Core; | ||
2 | 7 | ||
8 | /* QT */ | ||
3 | #include <qlayout.h> | 9 | #include <qlayout.h> |
4 | #include <qprogressbar.h> | 10 | #include <qprogressbar.h> |
5 | #include <qlabel.h> | 11 | #include <qlabel.h> |
6 | #include <qpushbutton.h> | 12 | #include <qpushbutton.h> |
7 | #include <qapp.h> | 13 | #include <qapp.h> |
8 | #include <qtimer.h> | 14 | #include <qtimer.h> |
9 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
10 | 16 | ||
17 | /* STD */ | ||
11 | #include <unistd.h> | 18 | #include <unistd.h> |
12 | #include <string.h> | 19 | #include <string.h> |
13 | #include <fcntl.h> | 20 | #include <fcntl.h> |
14 | #include <errno.h> | 21 | #include <errno.h> |
15 | 22 | ||
16 | #include "io_modem.h" | ||
17 | |||
18 | // State machine: | When an error occurs, we don't have to | 23 | // State machine: | When an error occurs, we don't have to |
19 | // | reset everything. | 24 | // | reset everything. |
20 | // (init) <------+ | But if the user wants to reset, | 25 | // (init) <------+ | But if the user wants to reset, |
21 | // | | | we stop dialing immediately. | 26 | // | | | we stop dialing immediately. |
@@ -103,9 +108,9 @@ void Dialer::slotCancel() | |||
103 | } | 108 | } |
104 | 109 | ||
105 | void Dialer::reset() | 110 | void Dialer::reset() |
106 | { | 111 | { |
107 | qWarning("reset"); | 112 | owarn << "reset" << oendl; |
108 | switchState(state_cancel); | 113 | switchState(state_cancel); |
109 | } | 114 | } |
110 | 115 | ||
111 | void Dialer::slotAutostart() | 116 | void Dialer::slotAutostart() |
@@ -135,20 +140,20 @@ void Dialer::dial(const QString& number) | |||
135 | } | 140 | } |
136 | 141 | ||
137 | void Dialer::trydial(const QString& number) | 142 | void Dialer::trydial(const QString& number) |
138 | { | 143 | { |
139 | qWarning("TryDial:%s", number.latin1() ); | 144 | owarn << "TryDial:" << number.latin1() << "" << oendl; |
140 | if(state != state_cancel) switchState(state_preinit); | 145 | if(state != state_cancel) switchState(state_preinit); |
141 | if(cleanshutdown) | 146 | if(cleanshutdown) |
142 | { | 147 | { |
143 | qWarning("HangupString " + m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING)); | 148 | owarn << "HangupString " << m_profile.readEntry("HangupString") << oendl; |
144 | send(m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) + "\r"); | 149 | send(m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) + "\r"); |
145 | } | 150 | } |
146 | 151 | ||
147 | if(state != state_cancel) | 152 | if(state != state_cancel) |
148 | { | 153 | { |
149 | switchState(state_init); | 154 | switchState(state_init); |
150 | // qWarning("Init String " + m_profile.readEntry("InitString") ); | 155 | // owarn << "Init String " + m_profile.readEntry("InitString") << oendl; |
151 | send(m_profile.readEntry("InitString",MODEM_DEFAULT_INIT_STRING ) + "\r"); | 156 | send(m_profile.readEntry("InitString",MODEM_DEFAULT_INIT_STRING ) + "\r"); |
152 | QString response2 = receive(); | 157 | QString response2 = receive(); |
153 | if(!response2.contains("\nOK\r")) | 158 | if(!response2.contains("\nOK\r")) |
154 | reset(); | 159 | reset(); |
@@ -157,9 +162,9 @@ void Dialer::trydial(const QString& number) | |||
157 | /*if(state != state_cancel) | 162 | /*if(state != state_cancel) |
158 | { | 163 | { |
159 | switchState(state_options); | 164 | switchState(state_options); |
160 | 165 | ||
161 | qWarning("ATM3l3"); | 166 | owarn << "ATM3l3" << oendl; |
162 | send("ATM3L3\r"); | 167 | send("ATM3L3\r"); |
163 | QString response3 = receive(); | 168 | QString response3 = receive(); |
164 | if(!response3.contains("\nOK\r")) | 169 | if(!response3.contains("\nOK\r")) |
165 | reset(); | 170 | reset(); |
@@ -177,9 +182,9 @@ void Dialer::trydial(const QString& number) | |||
177 | } | 182 | } |
178 | 183 | ||
179 | if(state != state_cancel) | 184 | if(state != state_cancel) |
180 | { | 185 | { |
181 | qWarning("progress"); | 186 | owarn << "progress" << oendl; |
182 | switchState(state_dialing); | 187 | switchState(state_dialing); |
183 | 188 | ||
184 | // send(QString("ATDT %1\r").arg(number)); | 189 | // send(QString("ATDT %1\r").arg(number)); |
185 | send(QString("%1 %2\r").arg(m_profile.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 )) | 190 | send(QString("%1 %2\r").arg(m_profile.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 )) |
@@ -213,9 +218,9 @@ void Dialer::send(const QString& msg) | |||
213 | QString m = msg; | 218 | QString m = msg; |
214 | int bytes; | 219 | int bytes; |
215 | QString termination; | 220 | QString termination; |
216 | 221 | ||
217 | qWarning("Sending: %s", m.latin1()); | 222 | owarn << "Sending: " << m.latin1() << "" << oendl; |
218 | 223 | ||
219 | /*termination = "\r"; | 224 | /*termination = "\r"; |
220 | //termination = m_profile.readEntry("Termination"); | 225 | //termination = m_profile.readEntry("Termination"); |
221 | if(termination == "\n") m = m + "\n"; | 226 | if(termination == "\n") m = m + "\n"; |
@@ -246,13 +251,13 @@ QString Dialer::receive() | |||
246 | { | 251 | { |
247 | for(int i = 0; i < ret; i++) | 252 | for(int i = 0; i < ret; i++) |
248 | buffer[i] = buffer[i] & 0x7F; | 253 | buffer[i] = buffer[i] & 0x7F; |
249 | buffer[ret] = 0; | 254 | buffer[ret] = 0; |
250 | qWarning("Got: %s", buffer); | 255 | owarn << "Got: " << buffer << "" << oendl; |
251 | buf.append(QString(buffer)); | 256 | buf.append(QString(buffer)); |
252 | if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY"))) | 257 | if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY"))) |
253 | { | 258 | { |
254 | //qWarning("Receiving: '%s'", buf.latin1()); | 259 | //owarn << "Receiving: '" << buf.latin1() << "'" << oendl; |
255 | cleanshutdown = 1; | 260 | cleanshutdown = 1; |
256 | return buf; | 261 | return buf; |
257 | }else if (buf.contains("NO CARRIER") || buf.contains("NO DIALTONE") ) { | 262 | }else if (buf.contains("NO CARRIER") || buf.contains("NO DIALTONE") ) { |
258 | cleanshutdown = 1; | 263 | cleanshutdown = 1; |