summaryrefslogtreecommitdiff
Unidiff
Diffstat (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
@@ -31,216 +31,226 @@
31 31
32// from atconfigdialog 32// from atconfigdialog
33//initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) ); 33//initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) );
34//resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) ); 34//resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) );
35//dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 35//dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) );
36//dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 36//dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
37//dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 37//dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) );
38//dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 38//dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
39//dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 39//dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) );
40//dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 40//dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
41//connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) ); 41//connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) );
42//hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) ); 42//hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) );
43 43
44// from modemconfigwidget 44// from modemconfigwidget
45//int rad_flow = prof.readNumEntry("Flow"); 45//int rad_flow = prof.readNumEntry("Flow");
46//int rad_parity = prof.readNumEntry("Parity"); 46//int rad_parity = prof.readNumEntry("Parity");
47//int speed = prof.readNumEntry("Speed"); 47//int speed = prof.readNumEntry("Speed");
48//QString number = prof.readEntry("Number"); 48//QString number = prof.readEntry("Number");
49 49
50Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name) 50Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name)
51: QDialog(parent, name, true), m_fd(fd), m_profile(profile) 51: QDialog(parent, name, true), m_fd(fd), m_profile(profile)
52{ 52{
53 QVBoxLayout *vbox; 53 QVBoxLayout *vbox;
54 QLabel *desc; 54 QLabel *desc;
55 55
56 //m_profile.writeEntry("InitString", "ATZ"); 56 //m_profile.writeEntry("InitString", "ATZ");
57 //m_profile.writeEntry("DialPrefix1", "ATDT"); 57 //m_profile.writeEntry("DialPrefix1", "ATDT");
58 //m_profile.writeEntry("Termination", "\n"); 58 //m_profile.writeEntry("Termination", "\n");
59 59
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);
67 status = new QLabel("", this); 67 status = new QLabel("", this);
68 status->setFrameStyle(QFrame::Panel | QFrame::Sunken); 68 status->setFrameStyle(QFrame::Panel | QFrame::Sunken);
69 cancel = new QPushButton(QObject::tr("Cancel"), this); 69 cancel = new QPushButton(QObject::tr("Cancel"), this);
70 70
71 vbox = new QVBoxLayout(this, 2); 71 vbox = new QVBoxLayout(this, 2);
72 vbox->add(desc); 72 vbox->add(desc);
73 vbox->add(progress); 73 vbox->add(progress);
74 vbox->add(status); 74 vbox->add(status);
75 vbox->add(cancel); 75 vbox->add(cancel);
76 76
77 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); 77 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
78 78
79 show(); 79 show();
80 80
81 QTimer::singleShot(500, this, SLOT(slotAutostart())); 81 QTimer::singleShot(500, this, SLOT(slotAutostart()));
82} 82}
83 83
84Dialer::~Dialer() 84Dialer::~Dialer()
85{ 85{
86} 86}
87 87
88void Dialer::setHangupOnly() 88void Dialer::setHangupOnly()
89{ 89{
90 state = state_cancel; 90 state = state_cancel;
91 usercancel = 1; 91 usercancel = 1;
92} 92}
93 93
94void Dialer::slotCancel() 94void Dialer::slotCancel()
95{ 95{
96 if(state != state_online) 96 if(state != state_online)
97 { 97 {
98 usercancel = 1; 98 usercancel = 1;
99 reset(); 99 reset();
100 } 100 }
101 else accept(); 101 else accept();
102} 102}
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
109void Dialer::slotAutostart() 110void Dialer::slotAutostart()
110{ 111{
111 //state = state_preinit; 112 //state = state_preinit;
112 dial(m_profile.readEntry("Number")); 113 dial(m_profile.readEntry("Number"));
113} 114}
114 115
115void Dialer::dial(const QString& number) 116void Dialer::dial(const QString& number)
116{ 117{
117 while(state != state_online) 118 while(state != state_online)
118 { 119 {
119 if(!usercancel) 120 if(!usercancel)
120 { 121 {
121 state = state_preinit; 122 state = state_preinit;
122 trydial(number); 123 trydial(number);
123 } 124 }
124 else break; 125 else break;
125 } 126 }
126 127
127 if(usercancel) 128 if(usercancel)
128 { 129 {
129 // modem hangup 130 // modem hangup
130 trydial(QString::null); 131 trydial(QString::null);
131 reject(); 132 reject();
132 } 133 }
133} 134}
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("");
143 } 146 }
144 147
145 if(state != state_cancel) 148 if(state != state_cancel)
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();
173 } 180 }
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 {
184 if(response5.contains("BUSY")) 192 if(response5.contains("BUSY"))
185 switchState(state_dialing); 193 switchState(state_dialing);
186 else 194 else
187 { 195 {
188 QMessageBox::warning(this, 196 QMessageBox::warning(this,
189 QObject::tr("Failure"), 197 QObject::tr("Failure"),
190 QObject::tr("Dialing the number failed.")); 198 QObject::tr("Dialing the number failed."));
191 slotCancel(); 199 slotCancel();
192 } 200 }
193 } 201 }
194 } 202 }
195 203
196 if(state != state_cancel) 204 if(state != state_cancel)
197 { 205 {
198 switchState(state_online); 206 switchState(state_online);
199 } 207 }
200} 208}
201 209
202void Dialer::send(const QString& msg) 210void Dialer::send(const QString& msg)
203{ 211{
204 QString m = msg; 212 QString m = 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)
218 { 228 {
219 reset(); 229 reset();
220 } 230 }
221} 231}
222 232
223QString Dialer::receive() 233QString Dialer::receive()
224{ 234{
225 QString buf; 235 QString buf;
226 char buffer[1024]; 236 char buffer[1024];
227 int ret; 237 int ret;
228 int counter = 0; 238 int counter = 0;
229 239
230 while(1) 240 while(1)
231 { 241 {
232 ret = ::read(m_fd, buffer, sizeof(buffer)); 242 ret = ::read(m_fd, buffer, sizeof(buffer));
233 243
234 if(ret > 0) 244 if(ret > 0)
235 { 245 {
236 for(int i = 0; i < ret; i++) 246 for(int i = 0; i < ret; i++)
237 buffer[i] = buffer[i] & 0x7F; 247 buffer[i] = buffer[i] & 0x7F;
238 buffer[ret] = 0; 248 buffer[ret] = 0;
239 //qWarning("Got: '%s'", buffer); 249 //qWarning("Got: '%s'", buffer);
240 buf.append(QString(buffer)); 250 buf.append(QString(buffer));
241 if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY"))) 251 if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY")))
242 { 252 {
243 //qWarning("Receiving: '%s'", buf.latin1()); 253 //qWarning("Receiving: '%s'", buf.latin1());
244 cleanshutdown = 1; 254 cleanshutdown = 1;
245 return buf; 255 return buf;
246 } 256 }
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
@@ -1,68 +1,70 @@
1 1
2#include "io_modem.h" 2#include "io_modem.h"
3 3
4#include "dialer.h" 4#include "dialer.h"
5 5
6IOModem::IOModem( const Profile &profile ) 6IOModem::IOModem( const Profile &profile )
7 : IOSerial( profile ) { 7 : IOSerial( profile ) {
8 m_profile = profile; 8 m_profile = profile;
9} 9}
10 10
11 11
12IOModem::~IOModem() { 12IOModem::~IOModem() {
13 13
14} 14}
15 15
16 16
17void IOModem::close() { 17void IOModem::close() {
18 // Hangup, discarding result 18 // Hangup, discarding result
19 int fd = rawIO(); 19 int fd = rawIO();
20 Dialer d(m_profile, fd); 20 Dialer d(m_profile, fd);
21 d.setHangupOnly(); 21 d.setHangupOnly();
22 d.exec(); 22 d.exec();
23 closeRawIO(fd); 23 closeRawIO(fd);
24 24
25 IOSerial::close(); 25 IOSerial::close();
26} 26}
27 27
28bool IOModem::open() { 28bool 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;
40 } 42 }
41 else 43 else
42 { 44 {
43 close(); 45 close();
44 return false; 46 return false;
45 } 47 }
46} 48}
47 49
48void IOModem::reload( const Profile &config ) { 50void IOModem::reload( const Profile &config ) {
49 51
50 m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE); 52 m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE);
51 m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD); 53 m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD);
52 m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY); 54 m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY);
53 m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS); 55 m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS);
54 m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS); 56 m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS);
55 m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW); 57 m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW);
56 58
57 m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ); 59 m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING );
58 m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ); 60 m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING );
59 m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ); 61 m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 );
60 m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ); 62 m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 );
61 m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ); 63 m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 );
62 m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ); 64 m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 );
63 m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ); 65 m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 );
64 m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ); 66 m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 );
65 m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ); 67 m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING );
66 m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ); 68 m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING );
67 m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING ); 69 m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING );
68 m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ); 70 m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME );
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
@@ -175,32 +175,54 @@ QString IOSerial::identifier() const {
175QString IOSerial::name() const { 175QString IOSerial::name() const {
176 return "RS232 Serial IO Layer"; 176 return "RS232 Serial IO Layer";
177} 177}
178int IOSerial::rawIO()const { 178int IOSerial::rawIO()const {
179 if (m_read ) 179 if (m_read )
180 disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); 180 disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
181 if (m_error ) 181 if (m_error )
182 disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); 182 disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
183 183
184 int fd = ::open(m_device, O_RDWR ); 184 int fd = ::open(m_device, O_RDWR );
185 185
186 return fd; 186 return fd;
187}; 187};
188void IOSerial::closeRawIO(int fd) { 188void IOSerial::closeRawIO(int fd) {
189 if (m_read ) 189 if (m_read )
190 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); 190 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
191 if (m_error ) 191 if (m_error )
192 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); 192 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
193 193
194 ::close( fd ); 194 ::close( fd );
195} 195}
196QBitArray IOSerial::supports()const { 196QBitArray IOSerial::supports()const {
197 QBitArray ar(3); 197 QBitArray ar(3);
198 ar[0] = ar[2] = 0; 198 ar[0] = ar[2] = 0;
199 ar[1] = 1; 199 ar[1] = 1;
200 200
201 return ar; 201 return ar;
202} 202}
203 203
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
@@ -21,50 +21,52 @@ public:
21 ParityNone = 0, 21 ParityNone = 0,
22 ParityEven, 22 ParityEven,
23 ParityOdd, 23 ParityOdd,
24 ParitySpace, 24 ParitySpace,
25 ParityMark 25 ParityMark
26 }; 26 };
27 27
28 enum Flow { 28 enum Flow {
29 FlowHW = 0x01, 29 FlowHW = 0x01,
30 FlowSW = 0x02 30 FlowSW = 0x02
31 }; 31 };
32 32
33 IOSerial(const Profile &); 33 IOSerial(const Profile &);
34 ~IOSerial(); 34 ~IOSerial();
35 35
36 QString identifier() const; 36 QString identifier() const;
37 QString name() const; 37 QString name() const;
38 int rawIO()const; 38 int rawIO()const;
39 void closeRawIO(int fd ); 39 void closeRawIO(int fd );
40 QBitArray supports()const; 40 QBitArray supports()const;
41 bool isConnected(); 41 bool isConnected();
42/*signals: 42/*signals:
43 void received(const QByteArray &); 43 void received(const QByteArray &);
44 void error(int, const QString &); 44 void error(int, const QString &);
45*/ 45*/
46public slots: 46public slots:
47 void send(const QByteArray &); 47 void send(const QByteArray &);
48 bool open(); 48 bool open();
49 void close(); 49 void close();
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();
56protected: 58protected:
57 QSocketNotifier *m_read; 59 QSocketNotifier *m_read;
58 QSocketNotifier *m_error; 60 QSocketNotifier *m_error;
59 QString m_device; 61 QString m_device;
60 int m_baud; 62 int m_baud;
61 int m_parity; 63 int m_parity;
62 int m_dbits; 64 int m_dbits;
63 int m_sbits; 65 int m_sbits;
64 int m_flow; 66 int m_flow;
65 int m_fd; 67 int m_fd;
66 bool m_connected; 68 bool m_connected;
67 69
68}; 70};
69 71
70#endif /* OPIE_IO_SERIAL */ 72#endif /* OPIE_IO_SERIAL */
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
@@ -1,75 +1,77 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdio.h> 2#include <stdio.h>
3#include <fcntl.h> 3#include <fcntl.h>
4#include <sys/termios.h> 4#include <sys/termios.h>
5 5
6#include <qmultilineedit.h> 6#include <qmultilineedit.h>
7#include <qsocketnotifier.h> 7#include <qsocketnotifier.h>
8 8
9#include "../profile.h" 9#include "../profile.h"
10#include "../io_serial.h" 10#include "../io_serial.h"
11#include "../filetransfer.h" 11#include "../filetransfer.h"
12#include "../filereceive.h" 12#include "../filereceive.h"
13 13
14#include <opie/oprocess.h> 14#include <opie/oprocess.h>
15 15
16#include "senderui.h" 16#include "senderui.h"
17 17
18SenderUI::SenderUI() 18SenderUI::SenderUI()
19 : Sender() { 19 : Sender() {
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);
29 connect(ser, SIGNAL(received(const QByteArray& ) ), 29 connect(ser, SIGNAL(received(const QByteArray& ) ),
30 this, SLOT(got(const QByteArray&) ) ); 30 this, SLOT(got(const QByteArray&) ) );
31 31
32 if ( ser->open() ) 32 if ( ser->open() )
33 qWarning("opened!!!"); 33 qWarning("opened!!!");
34 else 34 else
35 qWarning("could not open"); 35 qWarning("could not open");
36 36
37 37
38} 38}
39SenderUI::~SenderUI() { 39SenderUI::~SenderUI() {
40 40
41} 41}
42void SenderUI::slotSendFile() { 42void SenderUI::slotSendFile() {
43 43
44 sz = new FileTransfer(FileTransfer::SY, ser); 44 sz = new FileTransfer(FileTransfer::SY, ser);
45 sz->sendFile("/home/ich/bootopie-v06-13.jffs2"); 45 sz->sendFile("/home/ich/bootopie-v06-13.jffs2");
46 46
47 connect (sz, SIGNAL(sent()), 47 connect (sz, SIGNAL(sent()),
48 this, SLOT(fileTransComplete())); 48 this, SLOT(fileTransComplete()));
49} 49}
50 50
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() {
64 66
65 qWarning("file transfer complete"); 67 qWarning("file transfer complete");
66} 68}
67void SenderUI::send() { 69void SenderUI::send() {
68 70
69} 71}
70void SenderUI::slotRev(){ 72void SenderUI::slotRev(){
71qWarning("Going to receive!"); 73qWarning("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}