summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console
Unidiff
Diffstat (limited to 'noncore/apps/opie-console') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/dialer.cpp28
-rw-r--r--noncore/apps/opie-console/io_modem.cpp8
-rw-r--r--noncore/apps/opie-console/io_serial.cpp22
-rw-r--r--noncore/apps/opie-console/io_serial.h2
-rw-r--r--noncore/apps/opie-console/test/senderui.cpp10
5 files changed, 54 insertions, 16 deletions
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp
index 5056040..ce2b688 100644
--- a/noncore/apps/opie-console/dialer.cpp
+++ b/noncore/apps/opie-console/dialer.cpp
@@ -60,7 +60,7 @@ Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name
60 usercancel = 0; 60 usercancel = 0;
61 cleanshutdown = 0; 61 cleanshutdown = 0;
62 62
63 fcntl(m_fd, F_SETFL, O_NONBLOCK); 63 //fcntl(m_fd, F_SETFL, O_NONBLOCK);
64 64
65 desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this); 65 desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this);
66 progress = new QProgressBar(this); 66 progress = new QProgressBar(this);
@@ -103,6 +103,7 @@ void Dialer::slotCancel()
103 103
104void Dialer::reset() 104void Dialer::reset()
105{ 105{
106 qWarning("reset");
106 switchState(state_cancel); 107 switchState(state_cancel);
107} 108}
108 109
@@ -134,9 +135,11 @@ void Dialer::dial(const QString& number)
134 135
135void Dialer::trydial(const QString& number) 136void Dialer::trydial(const QString& number)
136{ 137{
138 qWarning("TryDial:%s", number.latin1() );
137 if(state != state_cancel) switchState(state_preinit); 139 if(state != state_cancel) switchState(state_preinit);
138 if(cleanshutdown) 140 if(cleanshutdown)
139 { 141 {
142 qWarning("HangupString " + m_profile.readEntry("HangupString"));
140 send(m_profile.readEntry("HangupString")); 143 send(m_profile.readEntry("HangupString"));
141 //send("+++ATH"); 144 //send("+++ATH");
142 send(""); 145 send("");
@@ -146,27 +149,31 @@ void Dialer::trydial(const QString& number)
146 { 149 {
147 switchState(state_init); 150 switchState(state_init);
148 //send("ATZ"); 151 //send("ATZ");
149 send(m_profile.readEntry("InitString")); 152 qWarning("Init String " + m_profile.readEntry("InitString") );
153 // send(m_profile.readEntry("InitString", "AT"));
154 send("AT\r");
150 QString response2 = receive(); 155 QString response2 = receive();
151 if(!response2.contains("\nOK\r")) 156 if(!response2.contains("\nOK\r"))
152 reset(); 157 reset();
153 } 158 }
154 159
155 if(state != state_cancel) 160 /*if(state != state_cancel)
156 { 161 {
157 switchState(state_options); 162 switchState(state_options);
158 163
159 send("ATM3L3"); 164 qWarning("ATM3l3");
165 send("ATM3L3\r");
160 QString response3 = receive(); 166 QString response3 = receive();
161 if(!response3.contains("\nOK\r")) 167 if(!response3.contains("\nOK\r"))
162 reset(); 168 reset();
163 } 169 }
170*/
164 171
165 if(state != state_cancel) 172 if(state != state_cancel)
166 { 173 {
167 switchState(state_dialtone); 174 switchState(state_dialtone);
168 175
169 send("ATX1"); 176 send("ATX1\r");
170 QString response4 = receive(); 177 QString response4 = receive();
171 if(!response4.contains("\nOK\r")) 178 if(!response4.contains("\nOK\r"))
172 reset(); 179 reset();
@@ -174,10 +181,11 @@ void Dialer::trydial(const QString& number)
174 181
175 if(state != state_cancel) 182 if(state != state_cancel)
176 { 183 {
184 qWarning("progress");
177 switchState(state_dialing); 185 switchState(state_dialing);
178 186
179 //send(QString("ATDT %1").arg(number)); 187 send(QString("ATDT %1\r").arg(number));
180 send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number)); 188 // send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number));
181 QString response5 = receive(); 189 QString response5 = receive();
182 if(!response5.contains("\n" + m_profile.readEntry("DefaultConnect"))) 190 if(!response5.contains("\n" + m_profile.readEntry("DefaultConnect")))
183 { 191 {
@@ -205,13 +213,15 @@ void Dialer::send(const QString& msg)
205 int bytes; 213 int bytes;
206 QString termination; 214 QString termination;
207 215
208 //qWarning("Sending: '%s'", m.latin1()); 216 qWarning("Sending: %s", m.latin1());
209 217
210 termination = "\r"; 218 /*termination = "\r";
211 //termination = m_profile.readEntry("Termination"); 219 //termination = m_profile.readEntry("Termination");
212 if(termination == "\n") m = m + "\n"; 220 if(termination == "\n") m = m + "\n";
213 else if(termination == "\r") m = m + "\r"; 221 else if(termination == "\r") m = m + "\r";
214 else m = m + "\r\n"; 222 else m = m + "\r\n";
223*/
224 m = m.replace(QRegExp("\n"), "\r");
215 225
216 bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit())); 226 bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit()));
217 if(bytes < 0) 227 if(bytes < 0)
diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp
index d4ea0b2..b7901b9 100644
--- a/noncore/apps/opie-console/io_modem.cpp
+++ b/noncore/apps/opie-console/io_modem.cpp
@@ -29,11 +29,13 @@ bool IOModem::open() {
29 bool ret = IOSerial::open(); 29 bool ret = IOSerial::open();
30 if(!ret) return false; 30 if(!ret) return false;
31 31
32 int fd = rawIO(); 32 //int fd = rawIO();
33 Dialer d(m_profile, fd); 33 internDetach();
34 Dialer d(m_profile, m_fd);
34 35
35 int result = d.exec(); 36 int result = d.exec();
36 closeRawIO(fd); 37 internAttach();
38 //closeRawIO(fd);
37 if(result == QDialog::Accepted) 39 if(result == QDialog::Accepted)
38 { 40 {
39 return true; 41 return true;
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp
index e6d1688..0540d9e 100644
--- a/noncore/apps/opie-console/io_serial.cpp
+++ b/noncore/apps/opie-console/io_serial.cpp
@@ -204,3 +204,25 @@ QBitArray IOSerial::supports()const {
204bool IOSerial::isConnected() { 204bool IOSerial::isConnected() {
205 return m_connected; 205 return m_connected;
206} 206}
207
208/*
209 * this is used to give the
210 * class below IOSerial
211 * the possibility of
212 * exclusive usage
213 */
214void IOSerial::internDetach() {
215 if (m_read )
216 disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
217 if (m_error )
218 disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
219}
220/*
221 * give power back
222 */
223void IOSerial::internAttach() {
224 if (m_read )
225 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
226 if (m_error )
227 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
228}
diff --git a/noncore/apps/opie-console/io_serial.h b/noncore/apps/opie-console/io_serial.h
index 7a1ea1d..edceac6 100644
--- a/noncore/apps/opie-console/io_serial.h
+++ b/noncore/apps/opie-console/io_serial.h
@@ -50,6 +50,8 @@ public slots:
50 void reload(const Profile &); 50 void reload(const Profile &);
51protected: 51protected:
52 int baud(int baud) const; 52 int baud(int baud) const;
53 void internDetach();
54 void internAttach();
53protected slots: 55protected slots:
54 void dataArrived(); 56 void dataArrived();
55 void errorOccured(); 57 void errorOccured();
diff --git a/noncore/apps/opie-console/test/senderui.cpp b/noncore/apps/opie-console/test/senderui.cpp
index 2ce3f6d..4026808 100644
--- a/noncore/apps/opie-console/test/senderui.cpp
+++ b/noncore/apps/opie-console/test/senderui.cpp
@@ -20,9 +20,9 @@ SenderUI::SenderUI()
20 20
21 /* we do that manually */ 21 /* we do that manually */
22 Profile prof; 22 Profile prof;
23 QString str = "/dev/ttyS0"; 23 QString str = "/dev/bty0";
24 prof.writeEntry("Device",str ); 24 prof.writeEntry("Device",str );
25 prof.writeEntry("Baud", 115200 ); 25 prof.writeEntry("Baud", 19200 );
26 26
27 qWarning("prof " + prof.readEntry("Device") + " " + str); 27 qWarning("prof " + prof.readEntry("Device") + " " + str);
28 ser = new IOSerial(prof); 28 ser = new IOSerial(prof);
@@ -51,13 +51,15 @@ void SenderUI::slotSendFile() {
51void SenderUI::slotSend() { 51void SenderUI::slotSend() {
52 QCString str = MultiLineEdit1->text().utf8(); 52 QCString str = MultiLineEdit1->text().utf8();
53 qWarning("sending: %s", str.data() ); 53 qWarning("sending: %s", str.data() );
54 str = str.replace( QRegExp("\n"), "\r");
54 ser->send( str ); 55 ser->send( str );
55} 56}
56void SenderUI::got(const QByteArray& ar) { 57void SenderUI::got(const QByteArray& ar) {
58 qWarning("got:");
57 for ( uint i = 0; i < ar.count(); i++ ) { 59 for ( uint i = 0; i < ar.count(); i++ ) {
58 printf("%c", ar[i] ); 60 printf("%c", ar[i] );
59 } 61 }
60 //printf("\n"); 62 printf("\n");
61} 63}
62 64
63void SenderUI::fileTransComplete() { 65void SenderUI::fileTransComplete() {
@@ -72,4 +74,4 @@ qWarning("Going to receive!");
72FileReceive *rev = new FileReceive( FileReceive::SZ, ser ); 74FileReceive *rev = new FileReceive( FileReceive::SZ, ser );
73rev->receive(); 75rev->receive();
74 76
75} \ No newline at end of file 77}