Diffstat (limited to 'noncore/apps/opie-console/dialer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/dialer.cpp | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp index 7010594..8883b83 100644 --- a/noncore/apps/opie-console/dialer.cpp +++ b/noncore/apps/opie-console/dialer.cpp | |||
@@ -1,15 +1,11 @@ | |||
1 | #include "dialer.h" | 1 | #include "dialer.h" |
2 | #include "io_modem.h" | 2 | #include "io_modem.h" |
3 | 3 | ||
4 | /* OPIE */ | ||
5 | #include <opie2/odebug.h> | ||
6 | using namespace Opie::Core; | ||
7 | |||
8 | /* QT */ | 4 | /* QT */ |
9 | #include <qlayout.h> | 5 | #include <qlayout.h> |
10 | #include <qprogressbar.h> | 6 | #include <qprogressbar.h> |
11 | #include <qlabel.h> | 7 | #include <qlabel.h> |
12 | #include <qpushbutton.h> | 8 | #include <qpushbutton.h> |
13 | #include <qapp.h> | 9 | #include <qapp.h> |
14 | #include <qtimer.h> | 10 | #include <qtimer.h> |
15 | #include <qmessagebox.h> | 11 | #include <qmessagebox.h> |
@@ -104,17 +100,16 @@ void Dialer::slotCancel() | |||
104 | } | 100 | } |
105 | else { | 101 | else { |
106 | accept(); | 102 | accept(); |
107 | } | 103 | } |
108 | } | 104 | } |
109 | 105 | ||
110 | void Dialer::reset() | 106 | void Dialer::reset() |
111 | { | 107 | { |
112 | owarn << "reset" << oendl; | ||
113 | switchState(state_cancel); | 108 | switchState(state_cancel); |
114 | } | 109 | } |
115 | 110 | ||
116 | void Dialer::slotAutostart() | 111 | void Dialer::slotAutostart() |
117 | { | 112 | { |
118 | //state = state_preinit; | 113 | //state = state_preinit; |
119 | dial(m_profile.readEntry("Number")); | 114 | dial(m_profile.readEntry("Number")); |
120 | } | 115 | } |
@@ -136,28 +131,25 @@ void Dialer::dial(const QString& number) | |||
136 | // modem hangup | 131 | // modem hangup |
137 | trydial(QString::null); | 132 | trydial(QString::null); |
138 | reject(); | 133 | reject(); |
139 | } | 134 | } |
140 | } | 135 | } |
141 | 136 | ||
142 | void Dialer::trydial(const QString& number) | 137 | void Dialer::trydial(const QString& number) |
143 | { | 138 | { |
144 | owarn << "TryDial:" << number.latin1() << "" << oendl; | ||
145 | if(state != state_cancel) switchState(state_preinit); | 139 | if(state != state_cancel) switchState(state_preinit); |
146 | if(cleanshutdown) | 140 | if(cleanshutdown) |
147 | { | 141 | { |
148 | owarn << "HangupString " << m_profile.readEntry("HangupString") << oendl; | ||
149 | send(m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) + "\r"); | 142 | send(m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) + "\r"); |
150 | } | 143 | } |
151 | 144 | ||
152 | if(state != state_cancel) | 145 | if(state != state_cancel) |
153 | { | 146 | { |
154 | switchState(state_init); | 147 | switchState(state_init); |
155 | // owarn << "Init String " + m_profile.readEntry("InitString") << oendl; | ||
156 | send(m_profile.readEntry("InitString",MODEM_DEFAULT_INIT_STRING ) + "\r"); | 148 | send(m_profile.readEntry("InitString",MODEM_DEFAULT_INIT_STRING ) + "\r"); |
157 | QString response2 = receive(); | 149 | QString response2 = receive(); |
158 | if(!response2.contains("\nOK\r")) | 150 | if(!response2.contains("\nOK\r")) |
159 | reset(); | 151 | reset(); |
160 | } | 152 | } |
161 | 153 | ||
162 | /*if(state != state_cancel) | 154 | /*if(state != state_cancel) |
163 | { | 155 | { |
@@ -178,33 +170,32 @@ void Dialer::trydial(const QString& number) | |||
178 | send("ATX1\r"); | 170 | send("ATX1\r"); |
179 | QString response4 = receive(); | 171 | QString response4 = receive(); |
180 | if(!response4.contains("\nOK\r")) | 172 | if(!response4.contains("\nOK\r")) |
181 | reset(); | 173 | reset(); |
182 | } | 174 | } |
183 | 175 | ||
184 | if(state != state_cancel) | 176 | if(state != state_cancel) |
185 | { | 177 | { |
186 | owarn << "progress" << oendl; | ||
187 | switchState(state_dialing); | 178 | switchState(state_dialing); |
188 | 179 | ||
189 | // send(QString("ATDT %1\r").arg(number)); | 180 | // send(QString("ATDT %1\r").arg(number)); |
190 | send(QString("%1 %2\r").arg(m_profile.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 )) | 181 | send(QString("%1 %2\r").arg(m_profile.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 )) |
191 | .arg(number)); | 182 | .arg(number)); |
192 | 183 | ||
193 | QString response5 = receive(); | 184 | QString response5 = receive(); |
194 | if(!response5.contains("CONNECT") ) | 185 | if(!response5.contains("CONNECT") ) |
195 | { | 186 | { |
196 | if(response5.contains("BUSY")) | 187 | if(response5.contains("BUSY")) |
197 | switchState(state_dialing); | 188 | switchState(state_dialing); |
198 | else | 189 | else |
199 | { | 190 | { |
200 | QMessageBox::warning(this, | 191 | QMessageBox::warning(this, |
201 | QObject::tr("Failure"), | 192 | QObject::tr("Failure"), |
202 | QObject::tr("Dialing the number failed.")); | 193 | QObject::tr("<qt>Dialing the number failed.</qt>")); |
203 | slotCancel(); | 194 | slotCancel(); |
204 | } | 195 | } |
205 | } | 196 | } |
206 | } | 197 | } |
207 | 198 | ||
208 | 199 | ||
209 | if(state != state_cancel) | 200 | if(state != state_cancel) |
210 | { | 201 | { |
@@ -214,17 +205,16 @@ void Dialer::trydial(const QString& number) | |||
214 | } | 205 | } |
215 | 206 | ||
216 | void Dialer::send(const QString& msg) | 207 | void Dialer::send(const QString& msg) |
217 | { | 208 | { |
218 | QString m = msg; | 209 | QString m = msg; |
219 | int bytes; | 210 | int bytes; |
220 | QString termination; | 211 | QString termination; |
221 | 212 | ||
222 | owarn << "Sending: " << m.latin1() << "" << oendl; | ||
223 | 213 | ||
224 | /*termination = "\r"; | 214 | /*termination = "\r"; |
225 | //termination = m_profile.readEntry("Termination"); | 215 | //termination = m_profile.readEntry("Termination"); |
226 | if(termination == "\n") m = m + "\n"; | 216 | if(termination == "\n") m = m + "\n"; |
227 | else if(termination == "\r") m = m + "\r"; | 217 | else if(termination == "\r") m = m + "\r"; |
228 | else m = m + "\r\n"; | 218 | else m = m + "\r\n"; |
229 | */ | 219 | */ |
230 | m = m.replace(QRegExp("\n"), "\r"); | 220 | m = m.replace(QRegExp("\n"), "\r"); |
@@ -247,21 +237,19 @@ QString Dialer::receive() | |||
247 | { | 237 | { |
248 | ret = ::read(m_fd, buffer, sizeof(buffer)); | 238 | ret = ::read(m_fd, buffer, sizeof(buffer)); |
249 | 239 | ||
250 | if(ret > 0) | 240 | if(ret > 0) |
251 | { | 241 | { |
252 | for(int i = 0; i < ret; i++) | 242 | for(int i = 0; i < ret; i++) |
253 | buffer[i] = buffer[i] & 0x7F; | 243 | buffer[i] = buffer[i] & 0x7F; |
254 | buffer[ret] = 0; | 244 | buffer[ret] = 0; |
255 | owarn << "Got: " << buffer << "" << oendl; | ||
256 | buf.append(QString(buffer)); | 245 | buf.append(QString(buffer)); |
257 | if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY"))) | 246 | if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY"))) |
258 | { | 247 | { |
259 | //owarn << "Receiving: '" << buf.latin1() << "'" << oendl; | ||
260 | cleanshutdown = 1; | 248 | cleanshutdown = 1; |
261 | return buf; | 249 | return buf; |
262 | }else if (buf.contains("NO CARRIER") || buf.contains("NO DIALTONE") ) { | 250 | }else if (buf.contains("NO CARRIER") || buf.contains("NO DIALTONE") ) { |
263 | cleanshutdown = 1; | 251 | cleanshutdown = 1; |
264 | return QString::null; | 252 | return QString::null; |
265 | } | 253 | } |
266 | } | 254 | } |
267 | else if(ret < 0) | 255 | else if(ret < 0) |