author | josef <josef> | 2002-10-15 21:10:29 (UTC) |
---|---|---|
committer | josef <josef> | 2002-10-15 21:10:29 (UTC) |
commit | fb99aec5215da635abfa28288d170f110114bba3 (patch) (unidiff) | |
tree | 68c1f662e126f578f467ccfc2c3164bc354a6790 /noncore/apps/opie-console | |
parent | 6b5ccd66a36280a601d09ea0295df86c4fce1a65 (diff) | |
download | opie-fb99aec5215da635abfa28288d170f110114bba3.zip opie-fb99aec5215da635abfa28288d170f110114bba3.tar.gz opie-fb99aec5215da635abfa28288d170f110114bba3.tar.bz2 |
- io_modem must keep copy of profile, otherwise it crashes (now it works -
doh!)
- try to use key/value pairs for dialing where currently possible (init string
and dial sequence)
- when editing telephone number, try to read in, including special chars
stripping (-, /, whitespace) using QRegExp
-rw-r--r-- | noncore/apps/opie-console/dialdialog.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/dialdialog.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/dialer.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_modem.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_modem.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/modemconfigwidget.cpp | 5 |
6 files changed, 21 insertions, 9 deletions
diff --git a/noncore/apps/opie-console/dialdialog.cpp b/noncore/apps/opie-console/dialdialog.cpp index 8bf32f9..0ace8f7 100644 --- a/noncore/apps/opie-console/dialdialog.cpp +++ b/noncore/apps/opie-console/dialdialog.cpp | |||
@@ -47,49 +47,57 @@ DialDialog::DialDialog( QWidget* parent, const char* name, bool modal, WFlags f | |||
47 | int x = 0, y = 0; | 47 | int x = 0, y = 0; |
48 | for ( int i = 0 ; i < 9; i++ ) { | 48 | for ( int i = 0 ; i < 9; i++ ) { |
49 | QPushButton *number = new QPushButton( this ); | 49 | QPushButton *number = new QPushButton( this ); |
50 | number->setText( QString( "%1" ).arg( i + 1 ) ); | 50 | number->setText( QString( "%1" ).arg( i + 1 ) ); |
51 | QFont number_font( number->font() ); | 51 | QFont number_font( number->font() ); |
52 | number_font.setBold( TRUE ); | 52 | number_font.setBold( TRUE ); |
53 | number->setFont( number_font ); | 53 | number->setFont( number_font ); |
54 | 54 | ||
55 | dialButtons->insert( number ); | 55 | dialButtons->insert( number ); |
56 | 56 | ||
57 | layout->addWidget( number, x, y ); | 57 | layout->addWidget( number, x, y ); |
58 | 58 | ||
59 | if ( y < 2 ) { | 59 | if ( y < 2 ) { |
60 | y++; | 60 | y++; |
61 | } else { | 61 | } else { |
62 | x++; | 62 | x++; |
63 | y = 0; | 63 | y = 0; |
64 | } | 64 | } |
65 | } | 65 | } |
66 | 66 | ||
67 | connect( dialButtons, SIGNAL( clicked( int ) ), this, SLOT( slotEnterNumber( int ) ) ); | 67 | connect( dialButtons, SIGNAL( clicked( int ) ), this, SLOT( slotEnterNumber( int ) ) ); |
68 | 68 | ||
69 | mainLayout->addStretch( 0 ); | 69 | mainLayout->addStretch( 0 ); |
70 | mainLayout->addWidget( textLabel ); | 70 | mainLayout->addWidget( textLabel ); |
71 | mainLayout->addWidget( LCD ); | 71 | mainLayout->addWidget( LCD ); |
72 | mainLayout->addStretch( 0 ); | 72 | mainLayout->addStretch( 0 ); |
73 | mainLayout->addLayout( layout ); | 73 | mainLayout->addLayout( layout ); |
74 | mainLayout->addStretch( 0 ); | 74 | mainLayout->addStretch( 0 ); |
75 | 75 | ||
76 | 76 | ||
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
80 | void DialDialog::slotEnterNumber( int number ) { | 80 | void DialDialog::slotEnterNumber( int number ) { |
81 | 81 | ||
82 | // pretty stupid, just for testing .-) | 82 | // pretty stupid, just for testing .-) |
83 | 83 | ||
84 | m_number = ( m_number * 10 ) + number; | 84 | m_number = ( m_number * 10 ) + number; |
85 | qDebug( QString("%1").arg( m_number ) ); | 85 | qDebug( QString("%1").arg( m_number ) ); |
86 | LCD->display( m_number ); | 86 | LCD->display( m_number ); |
87 | 87 | ||
88 | } | 88 | } |
89 | 89 | ||
90 | DialDialog::~DialDialog() { | 90 | DialDialog::~DialDialog() { |
91 | } | 91 | } |
92 | 92 | ||
93 | QString DialDialog::number() { | 93 | QString DialDialog::number() { |
94 | return QString( "%1").arg( m_number ); | 94 | return QString( "%1").arg( m_number ); |
95 | |||
95 | } | 96 | } |
97 | |||
98 | void DialDialog::setNumber( int number ) | ||
99 | { | ||
100 | m_number = number; | ||
101 | LCD->display( m_number ); | ||
102 | } | ||
103 | |||
diff --git a/noncore/apps/opie-console/dialdialog.h b/noncore/apps/opie-console/dialdialog.h index 5c5b948..bec7b81 100644 --- a/noncore/apps/opie-console/dialdialog.h +++ b/noncore/apps/opie-console/dialdialog.h | |||
@@ -1,29 +1,31 @@ | |||
1 | 1 | ||
2 | #ifndef DIALDIALOG_H | 2 | #ifndef DIALDIALOG_H |
3 | #define DIALDIALOG_H | 3 | #define DIALDIALOG_H |
4 | 4 | ||
5 | #include <qdialog.h> | 5 | #include <qdialog.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qlcdnumber.h> | 7 | #include <qlcdnumber.h> |
8 | 8 | ||
9 | class DialDialog : public QDialog { | 9 | class DialDialog : public QDialog { |
10 | 10 | ||
11 | Q_OBJECT | 11 | Q_OBJECT |
12 | 12 | ||
13 | public: | 13 | public: |
14 | DialDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | 14 | DialDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); |
15 | 15 | ||
16 | ~DialDialog(); | 16 | ~DialDialog(); |
17 | 17 | ||
18 | QString number(); | 18 | QString number(); |
19 | 19 | ||
20 | void setNumber( int ); | ||
21 | |||
20 | private: | 22 | private: |
21 | float m_number; | 23 | float m_number; |
22 | QLCDNumber *LCD; | 24 | QLCDNumber *LCD; |
23 | 25 | ||
24 | private slots: | 26 | private slots: |
25 | void slotEnterNumber( int ); | 27 | void slotEnterNumber( int ); |
26 | }; | 28 | }; |
27 | 29 | ||
28 | 30 | ||
29 | #endif | 31 | #endif |
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp index 90e2b6c..89a0e8d 100644 --- a/noncore/apps/opie-console/dialer.cpp +++ b/noncore/apps/opie-console/dialer.cpp | |||
@@ -80,121 +80,122 @@ void Dialer::slotCancel() | |||
80 | if(state != state_online) | 80 | if(state != state_online) |
81 | { | 81 | { |
82 | usercancel = 1; | 82 | usercancel = 1; |
83 | reset(); | 83 | reset(); |
84 | } | 84 | } |
85 | else accept(); | 85 | else accept(); |
86 | } | 86 | } |
87 | 87 | ||
88 | void Dialer::reset() | 88 | void Dialer::reset() |
89 | { | 89 | { |
90 | switchState(state_cancel); | 90 | switchState(state_cancel); |
91 | } | 91 | } |
92 | 92 | ||
93 | void Dialer::slotAutostart() | 93 | void Dialer::slotAutostart() |
94 | { | 94 | { |
95 | state = state_preinit; | 95 | state = state_preinit; |
96 | dial(m_profile.readEntry("Number")); | 96 | dial(m_profile.readEntry("Number")); |
97 | } | 97 | } |
98 | 98 | ||
99 | void Dialer::dial(const QString& number) | 99 | void Dialer::dial(const QString& number) |
100 | { | 100 | { |
101 | while(state != state_online) | 101 | while(state != state_online) |
102 | { | 102 | { |
103 | if(!usercancel) | 103 | if(!usercancel) |
104 | { | 104 | { |
105 | trydial(number); | 105 | trydial(number); |
106 | } | 106 | } |
107 | else break; | 107 | else break; |
108 | } | 108 | } |
109 | 109 | ||
110 | if(usercancel) | 110 | if(usercancel) |
111 | { | 111 | { |
112 | reject(); | 112 | reject(); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | void Dialer::trydial(const QString& number) | 116 | void Dialer::trydial(const QString& number) |
117 | { | 117 | { |
118 | if(state != state_cancel) | 118 | if(state != state_cancel) |
119 | { | 119 | { |
120 | switchState(state_preinit); | 120 | switchState(state_preinit); |
121 | // ... | 121 | // ... |
122 | QString response = receive(); | 122 | QString response = receive(); |
123 | } | 123 | } |
124 | 124 | ||
125 | if(state != state_cancel) | 125 | if(state != state_cancel) |
126 | { | 126 | { |
127 | switchState(state_init); | 127 | switchState(state_init); |
128 | send("ATZ"); | 128 | //send("ATZ"); |
129 | send(m_profile.readEntry("InitString")); | ||
129 | QString response2 = receive(); | 130 | QString response2 = receive(); |
130 | } | 131 | } |
131 | 132 | ||
132 | if(state != state_cancel) | 133 | if(state != state_cancel) |
133 | { | 134 | { |
134 | switchState(state_options); | 135 | switchState(state_options); |
135 | 136 | ||
136 | send("ATM0L0"); | 137 | send("ATM0L0"); |
137 | QString response3 = receive(); | 138 | QString response3 = receive(); |
138 | } | 139 | } |
139 | 140 | ||
140 | if(state != state_cancel) | 141 | if(state != state_cancel) |
141 | { | 142 | { |
142 | switchState(state_dialtone); | 143 | switchState(state_dialtone); |
143 | 144 | ||
144 | send("ATX1"); | 145 | send("ATX1"); |
145 | QString response4 = receive(); | 146 | QString response4 = receive(); |
146 | } | 147 | } |
147 | 148 | ||
148 | if(state != state_cancel) | 149 | if(state != state_cancel) |
149 | { | 150 | { |
150 | switchState(state_dialing); | 151 | switchState(state_dialing); |
151 | 152 | ||
152 | send(QString("ATDT %1").arg(number)); | 153 | send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number)); |
153 | QString response5 = receive(); | 154 | QString response5 = receive(); |
154 | } | 155 | } |
155 | 156 | ||
156 | if(state != state_cancel) | 157 | if(state != state_cancel) |
157 | { | 158 | { |
158 | switchState(state_online); | 159 | switchState(state_online); |
159 | } | 160 | } |
160 | } | 161 | } |
161 | 162 | ||
162 | void Dialer::send(const QString& msg) | 163 | void Dialer::send(const QString& msg) |
163 | { | 164 | { |
164 | QString m = msg; | 165 | QString m = msg; |
165 | int bytes; | 166 | int bytes; |
166 | QString termination; | 167 | QString termination; |
167 | 168 | ||
168 | termination = m_profile.readEntry("Termination"); | 169 | termination = m_profile.readEntry("Termination"); |
169 | if(termination == "\n") m = m + "\n"; | 170 | if(termination == "\n") m = m + "\n"; |
170 | else if(termination == "\r") m = m + "\r"; | 171 | else if(termination == "\r") m = m + "\r"; |
171 | else m = m + "\r\n"; | 172 | else m = m + "\r\n"; |
172 | 173 | ||
173 | bytes = write(0, m.local8Bit(), strlen(m.local8Bit())); | 174 | bytes = write(0, m.local8Bit(), strlen(m.local8Bit())); |
174 | if(bytes < 0) | 175 | if(bytes < 0) |
175 | { | 176 | { |
176 | reset(); | 177 | reset(); |
177 | } | 178 | } |
178 | } | 179 | } |
179 | 180 | ||
180 | QString Dialer::receive() | 181 | QString Dialer::receive() |
181 | { | 182 | { |
182 | for(int i = 0; i < 200000;i++) | 183 | for(int i = 0; i < 200000;i++) |
183 | qApp->processEvents(); | 184 | qApp->processEvents(); |
184 | return QString::null; | 185 | return QString::null; |
185 | } | 186 | } |
186 | 187 | ||
187 | void Dialer::switchState(int newstate) | 188 | void Dialer::switchState(int newstate) |
188 | { | 189 | { |
189 | int oldstate = state; | 190 | int oldstate = state; |
190 | state = newstate; | 191 | state = newstate; |
191 | 192 | ||
192 | switch(state) | 193 | switch(state) |
193 | { | 194 | { |
194 | case state_cancel: | 195 | case state_cancel: |
195 | status->setText(QObject::tr("Cancelling...")); | 196 | status->setText(QObject::tr("Cancelling...")); |
196 | progress->setProgress(0); | 197 | progress->setProgress(0); |
197 | break; | 198 | break; |
198 | case state_preinit: | 199 | case state_preinit: |
199 | status->setText(QObject::tr("Searching modem")); | 200 | status->setText(QObject::tr("Searching modem")); |
200 | progress->setProgress(10); | 201 | progress->setProgress(10); |
diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp index d93dc5a..22a3673 100644 --- a/noncore/apps/opie-console/io_modem.cpp +++ b/noncore/apps/opie-console/io_modem.cpp | |||
@@ -1,77 +1,75 @@ | |||
1 | 1 | ||
2 | #include "io_modem.h" | 2 | #include "io_modem.h" |
3 | 3 | ||
4 | #include "dialer.h" | 4 | #include "dialer.h" |
5 | 5 | ||
6 | IOModem::IOModem( const Profile &profile ) | 6 | IOModem::IOModem( const Profile &profile ) |
7 | : IOSerial( profile ), m_profile( profile ) { | 7 | : IOSerial( profile ) { |
8 | m_profile = profile; | ||
8 | } | 9 | } |
9 | 10 | ||
10 | 11 | ||
11 | IOModem::~IOModem() { | 12 | IOModem::~IOModem() { |
12 | 13 | ||
13 | } | 14 | } |
14 | 15 | ||
15 | 16 | ||
16 | void IOModem::close() { | 17 | void IOModem::close() { |
18 | // maybe do a hangup here just in case...? | ||
17 | 19 | ||
18 | IOSerial::close(); | 20 | IOSerial::close(); |
19 | |||
20 | } | 21 | } |
21 | 22 | ||
22 | bool IOModem::open() { | 23 | bool IOModem::open() { |
23 | bool ret = IOSerial::open(); | 24 | bool ret = IOSerial::open(); |
24 | if(!ret) return false; | 25 | if(!ret) return false; |
25 | 26 | ||
26 | qWarning("IOModem::open continues..."); | ||
27 | |||
28 | Dialer d(m_profile); | 27 | Dialer d(m_profile); |
29 | qWarning("dialer created"); | ||
30 | 28 | ||
31 | int result = d.exec(); | 29 | int result = d.exec(); |
32 | if(result == QDialog::Accepted) | 30 | if(result == QDialog::Accepted) |
33 | { | 31 | { |
34 | return true; | 32 | return true; |
35 | } | 33 | } |
36 | else return false; | 34 | else return false; |
37 | } | 35 | } |
38 | 36 | ||
39 | void IOModem::reload( const Profile &config ) { | 37 | void IOModem::reload( const Profile &config ) { |
40 | 38 | ||
41 | m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE); | 39 | m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE); |
42 | m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD); | 40 | m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD); |
43 | m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY); | 41 | m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY); |
44 | m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS); | 42 | m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS); |
45 | m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS); | 43 | m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS); |
46 | m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW); | 44 | m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW); |
47 | 45 | ||
48 | m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ); | 46 | m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ); |
49 | m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ); | 47 | m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ); |
50 | m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ); | 48 | m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ); |
51 | m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ); | 49 | m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ); |
52 | m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ); | 50 | m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ); |
53 | m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ); | 51 | m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ); |
54 | m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ); | 52 | m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ); |
55 | m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ); | 53 | m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ); |
56 | m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ); | 54 | m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ); |
57 | m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ); | 55 | m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ); |
58 | m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING ); | 56 | m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING ); |
59 | m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ); | 57 | m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ); |
60 | m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ); | 58 | m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ); |
61 | m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ); | 59 | m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ); |
62 | m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ); | 60 | m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ); |
63 | m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ); | 61 | m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ); |
64 | m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ); | 62 | m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ); |
65 | m_multiLineUntag = config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ); | 63 | m_multiLineUntag = config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ); |
66 | } | 64 | } |
67 | 65 | ||
68 | 66 | ||
69 | QString IOModem::identifier() const { | 67 | QString IOModem::identifier() const { |
70 | return "modem"; | 68 | return "modem"; |
71 | } | 69 | } |
72 | 70 | ||
73 | QString IOModem::name() const { | 71 | QString IOModem::name() const { |
74 | return "Modem IO Layer"; | 72 | return "Modem IO Layer"; |
75 | } | 73 | } |
76 | 74 | ||
77 | void IOModem::slotExited(OProcess* proc ){ | 75 | void IOModem::slotExited(OProcess* proc ){ |
diff --git a/noncore/apps/opie-console/io_modem.h b/noncore/apps/opie-console/io_modem.h index d681f66..8453b95 100644 --- a/noncore/apps/opie-console/io_modem.h +++ b/noncore/apps/opie-console/io_modem.h | |||
@@ -16,56 +16,56 @@ | |||
16 | #define MODEM_DEFAULT_INIT_STRING "~^M~ATZ^M~" | 16 | #define MODEM_DEFAULT_INIT_STRING "~^M~ATZ^M~" |
17 | #define MODEM_DEFAULT_RESET_STRING "~^M~ATZ^M~" | 17 | #define MODEM_DEFAULT_RESET_STRING "~^M~ATZ^M~" |
18 | #define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT" | 18 | #define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT" |
19 | #define MODEM_DEFAULT_DIAL_SUFFIX1 "^M" | 19 | #define MODEM_DEFAULT_DIAL_SUFFIX1 "^M" |
20 | #define MODEM_DEFAULT_DIAL_PREFIX2 "ATDP" | 20 | #define MODEM_DEFAULT_DIAL_PREFIX2 "ATDP" |
21 | #define MODEM_DEFAULT_DIAL_SUFFIX2 "^M" | 21 | #define MODEM_DEFAULT_DIAL_SUFFIX2 "^M" |
22 | #define MODEM_DEFAULT_DIAL_PREFIX3 "ATX1DT" | 22 | #define MODEM_DEFAULT_DIAL_PREFIX3 "ATX1DT" |
23 | #define MODEM_DEFAULT_DIAL_SUFFIX3 ";X4D^M" | 23 | #define MODEM_DEFAULT_DIAL_SUFFIX3 ";X4D^M" |
24 | #define MODEM_DEFAULT_CONNECT_STRING "CONNECT" | 24 | #define MODEM_DEFAULT_CONNECT_STRING "CONNECT" |
25 | #define MODEM_DEFAULT_HANGUP_STRING "~~+++~~ATH^M" | 25 | #define MODEM_DEFAULT_HANGUP_STRING "~~+++~~ATH^M" |
26 | #define MODEM_DEFAULT_CANCEL_STRING "^M" | 26 | #define MODEM_DEFAULT_CANCEL_STRING "^M" |
27 | #define MODEM_DEFAULT_DIAL_TIME 45 | 27 | #define MODEM_DEFAULT_DIAL_TIME 45 |
28 | #define MODEM_DEFAULT_DELAY_REDIAL 2 | 28 | #define MODEM_DEFAULT_DELAY_REDIAL 2 |
29 | #define MODEM_DEFAULT_NUMBER_TRIES 10 | 29 | #define MODEM_DEFAULT_NUMBER_TRIES 10 |
30 | #define MODEM_DEFAULT_DTR_DROP_TIME 1 | 30 | #define MODEM_DEFAULT_DTR_DROP_TIME 1 |
31 | #define MODEM_DEFAULT_BPS_DETECT 0 // bool | 31 | #define MODEM_DEFAULT_BPS_DETECT 0 // bool |
32 | #define MODEM_DEFAULT_DCD_LINES 1 //bool | 32 | #define MODEM_DEFAULT_DCD_LINES 1 //bool |
33 | #define MODEM_DEFAULT_MULTI_LINE_UNTAG 0 // bool | 33 | #define MODEM_DEFAULT_MULTI_LINE_UNTAG 0 // bool |
34 | 34 | ||
35 | /* IOSerial implements a RS232 IO Layer */ | 35 | /* IOSerial implements a RS232 IO Layer */ |
36 | 36 | ||
37 | class IOModem : public IOSerial { | 37 | class IOModem : public IOSerial { |
38 | 38 | ||
39 | Q_OBJECT | 39 | Q_OBJECT |
40 | 40 | ||
41 | public: | 41 | public: |
42 | 42 | ||
43 | IOModem(const Profile &); | 43 | IOModem(const Profile &); |
44 | ~IOModem(); | 44 | ~IOModem(); |
45 | 45 | ||
46 | QString identifier() const; | 46 | QString identifier() const; |
47 | QString name() const; | 47 | QString name() const; |
48 | 48 | ||
49 | signals: | 49 | signals: |
50 | void received(const QByteArray &); | 50 | void received(const QByteArray &); |
51 | void error(int, const QString &); | 51 | void error(int, const QString &); |
52 | 52 | ||
53 | public slots: | 53 | public slots: |
54 | bool open(); | 54 | bool open(); |
55 | void close(); | 55 | void close(); |
56 | void reload(const Profile &); | 56 | void reload(const Profile &); |
57 | 57 | ||
58 | private: | 58 | private: |
59 | 59 | ||
60 | QString m_initString, m_resetString, m_dialPref1, m_dialSuf1, m_dialPref2, | 60 | QString m_initString, m_resetString, m_dialPref1, m_dialSuf1, m_dialPref2, |
61 | m_dialSuf2, m_dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel; | 61 | m_dialSuf2, m_dialPref3, m_dialSuf3, m_connect, m_hangup, m_cancel; |
62 | int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime, | 62 | int m_dialTime, m_delayRedial, m_numberTries, m_dtrDropTime, |
63 | m_bpsDetect, m_dcdLines, m_multiLineUntag; | 63 | m_bpsDetect, m_dcdLines, m_multiLineUntag; |
64 | const Profile& m_profile; | 64 | Profile m_profile; |
65 | 65 | ||
66 | private slots: | 66 | private slots: |
67 | void slotExited(OProcess* proc); | 67 | void slotExited(OProcess* proc); |
68 | 68 | ||
69 | }; | 69 | }; |
70 | 70 | ||
71 | #endif | 71 | #endif |
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp index 0f0ce7c..878b0cf 100644 --- a/noncore/apps/opie-console/modemconfigwidget.cpp +++ b/noncore/apps/opie-console/modemconfigwidget.cpp | |||
@@ -1,55 +1,55 @@ | |||
1 | #include <qlabel.h> | 1 | #include <qlabel.h> |
2 | #include <qlayout.h> | 2 | #include <qlayout.h> |
3 | #include <qcombobox.h> | 3 | #include <qcombobox.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qpushbutton.h> | 5 | #include <qpushbutton.h> |
6 | #include <qhbox.h> | 6 | #include <qhbox.h> |
7 | 7 | #include <qregexp.h> | |
8 | 8 | ||
9 | #include "modemconfigwidget.h" | 9 | #include "modemconfigwidget.h" |
10 | #include "dialdialog.h" | 10 | #include "dialdialog.h" |
11 | 11 | ||
12 | namespace { | 12 | namespace { |
13 | void setCurrent( const QString& str, QComboBox* bo ) { | 13 | void setCurrent( const QString& str, QComboBox* bo ) { |
14 | uint b = bo->count(); | 14 | uint b = bo->count(); |
15 | for (uint i = 0; i < bo->count(); i++ ) { | 15 | for (uint i = 0; i < bo->count(); i++ ) { |
16 | if ( bo->text(i) == str ) { | 16 | if ( bo->text(i) == str ) { |
17 | bo->setCurrentItem( i ); | 17 | bo->setCurrentItem( i ); |
18 | return; | 18 | return; |
19 | } | 19 | } |
20 | } | 20 | } |
21 | bo->insertItem( str ); | 21 | bo->insertItem( str ); |
22 | bo->setCurrentItem( b ); | 22 | bo->setCurrentItem( b ); |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, | 26 | ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, |
27 | const char* na ) | 27 | const char* na ) |
28 | : ProfileDialogConnectionWidget( name, parent, na ) { | 28 | : ProfileDialogConnectionWidget( name, parent, na ) { |
29 | 29 | ||
30 | m_lay = new QVBoxLayout( this ); | 30 | m_lay = new QVBoxLayout( this ); |
31 | m_device = new QLabel(tr( "Modem is attached to:" ), this ); | 31 | m_device = new QLabel(tr( "Modem is attached to:" ), this ); |
32 | m_deviceCmb = new QComboBox(this ); | 32 | m_deviceCmb = new QComboBox(this ); |
33 | m_deviceCmb->setEditable( TRUE ); | 33 | m_deviceCmb->setEditable( TRUE ); |
34 | 34 | ||
35 | QLabel* telLabel = new QLabel( this ); | 35 | QLabel* telLabel = new QLabel( this ); |
36 | telLabel->setText( tr( "Enter telefon number here:" ) ); | 36 | telLabel->setText( tr( "Enter telefon number here:" ) ); |
37 | m_telNumber = new QLineEdit( this ); | 37 | m_telNumber = new QLineEdit( this ); |
38 | QHBox *buttonBox = new QHBox( this ); | 38 | QHBox *buttonBox = new QHBox( this ); |
39 | QPushButton *atButton = new QPushButton( buttonBox ); | 39 | QPushButton *atButton = new QPushButton( buttonBox ); |
40 | atButton->setText( tr( "AT commands" ) ); | 40 | atButton->setText( tr( "AT commands" ) ); |
41 | connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); | 41 | connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); |
42 | 42 | ||
43 | QPushButton *dialButton = new QPushButton( buttonBox ); | 43 | QPushButton *dialButton = new QPushButton( buttonBox ); |
44 | dialButton->setText( tr( "Enter number" ) ); | 44 | dialButton->setText( tr( "Enter number" ) ); |
45 | connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); | 45 | connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); |
46 | 46 | ||
47 | 47 | ||
48 | m_base = new IOLayerBase( this, "base" ); | 48 | m_base = new IOLayerBase( this, "base" ); |
49 | 49 | ||
50 | m_lay->addWidget( m_device ); | 50 | m_lay->addWidget( m_device ); |
51 | m_lay->addWidget( m_deviceCmb ); | 51 | m_lay->addWidget( m_deviceCmb ); |
52 | m_lay->addWidget( telLabel ); | 52 | m_lay->addWidget( telLabel ); |
53 | m_lay->addWidget( m_telNumber ); | 53 | m_lay->addWidget( m_telNumber ); |
54 | m_lay->addWidget( buttonBox ); | 54 | m_lay->addWidget( buttonBox ); |
55 | m_lay->addWidget( m_base ); | 55 | m_lay->addWidget( m_base ); |
@@ -142,53 +142,56 @@ void ModemConfigWidget::save( Profile& prof ) { | |||
142 | } | 142 | } |
143 | 143 | ||
144 | switch( m_base->parity() ) { | 144 | switch( m_base->parity() ) { |
145 | case IOLayerBase::Odd: | 145 | case IOLayerBase::Odd: |
146 | parity = 2; | 146 | parity = 2; |
147 | break; | 147 | break; |
148 | case IOLayerBase::Even: | 148 | case IOLayerBase::Even: |
149 | parity = 1; | 149 | parity = 1; |
150 | break; | 150 | break; |
151 | case IOLayerBase::NonePar: | 151 | case IOLayerBase::NonePar: |
152 | parity = 0; | 152 | parity = 0; |
153 | break; | 153 | break; |
154 | } | 154 | } |
155 | 155 | ||
156 | switch( m_base->speed() ) { | 156 | switch( m_base->speed() ) { |
157 | case IOLayerBase::Baud_115200: | 157 | case IOLayerBase::Baud_115200: |
158 | speed = 115200; | 158 | speed = 115200; |
159 | break; | 159 | break; |
160 | case IOLayerBase::Baud_57600: | 160 | case IOLayerBase::Baud_57600: |
161 | speed = 57600; | 161 | speed = 57600; |
162 | break; | 162 | break; |
163 | case IOLayerBase::Baud_38400: | 163 | case IOLayerBase::Baud_38400: |
164 | speed = 38400; | 164 | speed = 38400; |
165 | break; | 165 | break; |
166 | case IOLayerBase::Baud_19200: | 166 | case IOLayerBase::Baud_19200: |
167 | speed = 19200; | 167 | speed = 19200; |
168 | break; | 168 | break; |
169 | case IOLayerBase::Baud_9600: | 169 | case IOLayerBase::Baud_9600: |
170 | speed = 9600; | 170 | speed = 9600; |
171 | break; | 171 | break; |
172 | } | 172 | } |
173 | 173 | ||
174 | prof.writeEntry( "Flow", flow ); | 174 | prof.writeEntry( "Flow", flow ); |
175 | prof.writeEntry( "Parity", parity ); | 175 | prof.writeEntry( "Parity", parity ); |
176 | prof.writeEntry( "Speed", speed ); | 176 | prof.writeEntry( "Speed", speed ); |
177 | prof.writeEntry( "Number", m_telNumber->text() ); | 177 | prof.writeEntry( "Number", m_telNumber->text() ); |
178 | } | 178 | } |
179 | 179 | ||
180 | void ModemConfigWidget::slotAT() { | 180 | void ModemConfigWidget::slotAT() { |
181 | // ATConfigDialog conf( this, "ATConfig", true ); | 181 | // ATConfigDialog conf( this, "ATConfig", true ); |
182 | atConf->showMaximized(); | 182 | atConf->showMaximized(); |
183 | if ( atConf->exec() == QDialog::Accepted ) { | 183 | if ( atConf->exec() == QDialog::Accepted ) { |
184 | // atConf->writeConfig(); | 184 | // atConf->writeConfig(); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | void ModemConfigWidget::slotDial() { | 188 | void ModemConfigWidget::slotDial() { |
189 | DialDialog dial( this, "DialConfig", true ); | 189 | DialDialog dial( this, "DialConfig", true ); |
190 | if(!m_telNumber->text().isEmpty()) { | ||
191 | dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ ]"), "").toInt()); | ||
192 | } | ||
190 | dial.showMaximized(); | 193 | dial.showMaximized(); |
191 | if ( dial.exec() == QDialog::Accepted ) { | 194 | if ( dial.exec() == QDialog::Accepted ) { |
192 | m_telNumber->setText( dial.number() ); | 195 | m_telNumber->setText( dial.number() ); |
193 | } | 196 | } |
194 | } | 197 | } |