summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/dialdialog.cpp8
-rw-r--r--noncore/apps/opie-console/dialdialog.h2
-rw-r--r--noncore/apps/opie-console/dialer.cpp5
-rw-r--r--noncore/apps/opie-console/io_modem.cpp8
-rw-r--r--noncore/apps/opie-console/io_modem.h2
-rw-r--r--noncore/apps/opie-console/modemconfigwidget.cpp5
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
@@ -1,95 +1,103 @@
1 1
2 2
3#include <qlayout.h> 3#include <qlayout.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qcombobox.h> 5#include <qcombobox.h>
6#include <qscrollview.h> 6#include <qscrollview.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qfont.h> 8#include <qfont.h>
9#include <qbuttongroup.h> 9#include <qbuttongroup.h>
10 10
11#include "dialdialog.h" 11#include "dialdialog.h"
12 12
13 13
14 14
15DialDialog::DialDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 15DialDialog::DialDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
16 : QDialog( parent, name, modal, fl ) { 16 : QDialog( parent, name, modal, fl ) {
17 17
18 m_number = 0; 18 m_number = 0;
19 19
20 setCaption( tr( "Enter number" ) ); 20 setCaption( tr( "Enter number" ) );
21 21
22 QVBoxLayout *mainLayout = new QVBoxLayout( this ); 22 QVBoxLayout *mainLayout = new QVBoxLayout( this );
23 23
24 QLabel *textLabel = new QLabel( this ); 24 QLabel *textLabel = new QLabel( this );
25 textLabel->setText( tr("Enter the number you want to dial. When finished, press ok") ); 25 textLabel->setText( tr("Enter the number you want to dial. When finished, press ok") );
26 26
27 LCD = new QLCDNumber( this, "LCD" ); 27 LCD = new QLCDNumber( this, "LCD" );
28 QFont LCD_font( LCD->font() ); 28 QFont LCD_font( LCD->font() );
29 LCD_font.setPointSize( 7 ); 29 LCD_font.setPointSize( 7 );
30 LCD->setFont( LCD_font ); 30 LCD->setFont( LCD_font );
31 LCD->setNumDigits( 25 ); 31 LCD->setNumDigits( 25 );
32 LCD->setSegmentStyle( QLCDNumber::Flat ); 32 LCD->setSegmentStyle( QLCDNumber::Flat );
33 LCD->setMaximumHeight( 30 ); 33 LCD->setMaximumHeight( 30 );
34 34
35 QGridLayout *layout = new QGridLayout( this , 4, 3 ); 35 QGridLayout *layout = new QGridLayout( this , 4, 3 );
36 36
37 QButtonGroup *dialButtons = new QButtonGroup( ); 37 QButtonGroup *dialButtons = new QButtonGroup( );
38 38
39 QPushButton *number0 = new QPushButton( this ); 39 QPushButton *number0 = new QPushButton( this );
40 number0->setText( QString( "0" ) ); 40 number0->setText( QString( "0" ) );
41 QFont number0_font( number0->font() ); 41 QFont number0_font( number0->font() );
42 number0_font.setBold( TRUE ); 42 number0_font.setBold( TRUE );
43 number0->setFont( number0_font ); 43 number0->setFont( number0_font );
44 layout->addWidget( number0, 4, 1 ); 44 layout->addWidget( number0, 4, 1 );
45 dialButtons->insert( number0 ); 45 dialButtons->insert( number0 );
46 46
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
80void DialDialog::slotEnterNumber( int number ) { 80void 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
90DialDialog::~DialDialog() { 90DialDialog::~DialDialog() {
91} 91}
92 92
93QString DialDialog::number() { 93QString DialDialog::number() {
94 return QString( "%1").arg( m_number ); 94 return QString( "%1").arg( m_number );
95
95} 96}
97
98void 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
9class DialDialog : public QDialog { 9class DialDialog : public QDialog {
10 10
11 Q_OBJECT 11 Q_OBJECT
12 12
13public: 13public:
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
20private: 22private:
21 float m_number; 23 float m_number;
22 QLCDNumber *LCD; 24 QLCDNumber *LCD;
23 25
24private slots: 26private 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
@@ -32,195 +32,196 @@
32//dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 32//dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) );
33//dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 33//dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
34//dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 34//dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) );
35//dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 35//dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
36//dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 36//dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) );
37//dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 37//dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
38//connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) ); 38//connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) );
39//hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) ); 39//hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) );
40 40
41// from modemconfigwidget 41// from modemconfigwidget
42//int rad_flow = prof.readNumEntry("Flow"); 42//int rad_flow = prof.readNumEntry("Flow");
43//int rad_parity = prof.readNumEntry("Parity"); 43//int rad_parity = prof.readNumEntry("Parity");
44//int speed = prof.readNumEntry("Speed"); 44//int speed = prof.readNumEntry("Speed");
45//QString number = prof.readEntry("Number"); 45//QString number = prof.readEntry("Number");
46 46
47Dialer::Dialer(const Profile& profile, QWidget *parent, const char *name) 47Dialer::Dialer(const Profile& profile, QWidget *parent, const char *name)
48: QDialog(parent, name, true), m_profile(profile) 48: QDialog(parent, name, true), m_profile(profile)
49{ 49{
50 QVBoxLayout *vbox; 50 QVBoxLayout *vbox;
51 QLabel *desc; 51 QLabel *desc;
52 52
53 usercancel = 0; 53 usercancel = 0;
54 54
55 desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this); 55 desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this);
56 progress = new QProgressBar(this); 56 progress = new QProgressBar(this);
57 status = new QLabel("", this); 57 status = new QLabel("", this);
58 status->setFrameStyle(QFrame::Panel | QFrame::Sunken); 58 status->setFrameStyle(QFrame::Panel | QFrame::Sunken);
59 cancel = new QPushButton(QObject::tr("Cancel"), this); 59 cancel = new QPushButton(QObject::tr("Cancel"), this);
60 60
61 vbox = new QVBoxLayout(this, 2); 61 vbox = new QVBoxLayout(this, 2);
62 vbox->add(desc); 62 vbox->add(desc);
63 vbox->add(progress); 63 vbox->add(progress);
64 vbox->add(status); 64 vbox->add(status);
65 vbox->add(cancel); 65 vbox->add(cancel);
66 66
67 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); 67 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
68 68
69 show(); 69 show();
70 70
71 QTimer::singleShot(500, this, SLOT(slotAutostart())); 71 QTimer::singleShot(500, this, SLOT(slotAutostart()));
72} 72}
73 73
74Dialer::~Dialer() 74Dialer::~Dialer()
75{ 75{
76} 76}
77 77
78void Dialer::slotCancel() 78void Dialer::slotCancel()
79{ 79{
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
88void Dialer::reset() 88void Dialer::reset()
89{ 89{
90 switchState(state_cancel); 90 switchState(state_cancel);
91} 91}
92 92
93void Dialer::slotAutostart() 93void 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
99void Dialer::dial(const QString& number) 99void 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
116void Dialer::trydial(const QString& number) 116void 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
162void Dialer::send(const QString& msg) 163void 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
180QString Dialer::receive() 181QString 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
187void Dialer::switchState(int newstate) 188void 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);
201 break; 202 break;
202 case state_init: 203 case state_init:
203 status->setText(QObject::tr("Initializing...")); 204 status->setText(QObject::tr("Initializing..."));
204 progress->setProgress(20); 205 progress->setProgress(20);
205 break; 206 break;
206 case state_options: 207 case state_options:
207 status->setText(QObject::tr("Reset speakers")); 208 status->setText(QObject::tr("Reset speakers"));
208 progress->setProgress(30); 209 progress->setProgress(30);
209 break; 210 break;
210 case state_dialtone: 211 case state_dialtone:
211 status->setText(QObject::tr("Turning off dialtone")); 212 status->setText(QObject::tr("Turning off dialtone"));
212 progress->setProgress(40); 213 progress->setProgress(40);
213 break; 214 break;
214 case state_dialing: 215 case state_dialing:
215 if(oldstate != state_dialing) status->setText(QObject::tr("Dial number")); 216 if(oldstate != state_dialing) status->setText(QObject::tr("Dial number"));
216 else status->setText(QObject::tr("Line busy, redialing number")); 217 else status->setText(QObject::tr("Line busy, redialing number"));
217 progress->setProgress(50); 218 progress->setProgress(50);
218 break; 219 break;
219 case state_online: 220 case state_online:
220 status->setText(QObject::tr("Connection established")); 221 status->setText(QObject::tr("Connection established"));
221 progress->setProgress(100); 222 progress->setProgress(100);
222 cancel->setText(QObject::tr("Dismiss")); 223 cancel->setText(QObject::tr("Dismiss"));
223 break; 224 break;
224 } 225 }
225} 226}
226 227
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,80 +1,78 @@
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 ), m_profile( profile ) { 7 : IOSerial( profile ) {
8 m_profile = profile;
8} 9}
9 10
10 11
11IOModem::~IOModem() { 12IOModem::~IOModem() {
12 13
13} 14}
14 15
15 16
16void IOModem::close() { 17void IOModem::close() {
18 // maybe do a hangup here just in case...?
17 19
18 IOSerial::close(); 20 IOSerial::close();
19
20} 21}
21 22
22bool IOModem::open() { 23bool 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
39void IOModem::reload( const Profile &config ) { 37void 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
69QString IOModem::identifier() const { 67QString IOModem::identifier() const {
70 return "modem"; 68 return "modem";
71} 69}
72 70
73QString IOModem::name() const { 71QString IOModem::name() const {
74 return "Modem IO Layer"; 72 return "Modem IO Layer";
75} 73}
76 74
77void IOModem::slotExited(OProcess* proc ){ 75void IOModem::slotExited(OProcess* proc ){
78 close(); 76 close();
79} 77}
80 78
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
@@ -1,71 +1,71 @@
1#ifndef OPIE_IO_MODEM 1#ifndef OPIE_IO_MODEM
2#define OPIE_IO_MODEM 2#define OPIE_IO_MODEM
3 3
4#include <opie/oprocess.h> 4#include <opie/oprocess.h>
5#include "io_serial.h" 5#include "io_serial.h"
6#include "profile.h" 6#include "profile.h"
7 7
8/* Default values to be used if the profile information is incomplete */ 8/* Default values to be used if the profile information is incomplete */
9#define MODEM_DEFAULT_DEVICE "/dev/ttyS0" 9#define MODEM_DEFAULT_DEVICE "/dev/ttyS0"
10#define MODEM_DEFAULT_BAUD 9600 10#define MODEM_DEFAULT_BAUD 9600
11#define MODEM_DEFAULT_PARITY 0 11#define MODEM_DEFAULT_PARITY 0
12#define MODEM_DEFAULT_DBITS 8 12#define MODEM_DEFAULT_DBITS 8
13#define MODEM_DEFAULT_SBITS 1 13#define MODEM_DEFAULT_SBITS 1
14#define MODEM_DEFAULT_FLOW 0 14#define MODEM_DEFAULT_FLOW 0
15 15
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
37class IOModem : public IOSerial { 37class IOModem : public IOSerial {
38 38
39 Q_OBJECT 39 Q_OBJECT
40 40
41public: 41public:
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
49signals: 49signals:
50 void received(const QByteArray &); 50 void received(const QByteArray &);
51 void error(int, const QString &); 51 void error(int, const QString &);
52 52
53public slots: 53public 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
58private: 58private:
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
66private slots: 66private 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,194 +1,197 @@
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
12namespace { 12namespace {
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
26ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, 26ModemConfigWidget::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 );
56 56
57 m_deviceCmb->insertItem( "/dev/ttyS0" ); 57 m_deviceCmb->insertItem( "/dev/ttyS0" );
58 m_deviceCmb->insertItem( "/dev/ttyS1" ); 58 m_deviceCmb->insertItem( "/dev/ttyS1" );
59 m_deviceCmb->insertItem( "/dev/ttyS2" ); 59 m_deviceCmb->insertItem( "/dev/ttyS2" );
60 60
61 atConf = new ATConfigDialog( this, "ATConfig", true ); 61 atConf = new ATConfigDialog( this, "ATConfig", true );
62} 62}
63 63
64ModemConfigWidget::~ModemConfigWidget() { 64ModemConfigWidget::~ModemConfigWidget() {
65 65
66} 66}
67void ModemConfigWidget::load( const Profile& prof ) { 67void ModemConfigWidget::load( const Profile& prof ) {
68 68
69 int rad_flow = prof.readNumEntry( "Flow" ); 69 int rad_flow = prof.readNumEntry( "Flow" );
70 int rad_parity = prof.readNumEntry( "Parity" ); 70 int rad_parity = prof.readNumEntry( "Parity" );
71 int speed = prof.readNumEntry( "Speed" ); 71 int speed = prof.readNumEntry( "Speed" );
72 QString number = prof.readEntry( "Number" ); 72 QString number = prof.readEntry( "Number" );
73 73
74 if ( !number.isEmpty() ) { 74 if ( !number.isEmpty() ) {
75 m_telNumber->setText( number ); 75 m_telNumber->setText( number );
76 } 76 }
77 77
78 if ( rad_flow == 1 ) { 78 if ( rad_flow == 1 ) {
79 m_base->setFlow( IOLayerBase::Hardware ); 79 m_base->setFlow( IOLayerBase::Hardware );
80 } else if (rad_flow == 2) { 80 } else if (rad_flow == 2) {
81 m_base->setFlow( IOLayerBase::Software ); 81 m_base->setFlow( IOLayerBase::Software );
82 } else if (rad_flow == 0) { 82 } else if (rad_flow == 0) {
83 m_base->setFlow( IOLayerBase::None ); 83 m_base->setFlow( IOLayerBase::None );
84 } 84 }
85 85
86 86
87 if ( rad_parity == 1 ) { 87 if ( rad_parity == 1 ) {
88 m_base->setParity( IOLayerBase::Even ); 88 m_base->setParity( IOLayerBase::Even );
89 } else if ( rad_parity == 2 ){ 89 } else if ( rad_parity == 2 ){
90 m_base->setParity( IOLayerBase::Odd ); 90 m_base->setParity( IOLayerBase::Odd );
91 } else { 91 } else {
92 m_base->setParity( IOLayerBase::NonePar ); 92 m_base->setParity( IOLayerBase::NonePar );
93 } 93 }
94 94
95 switch( speed ) { 95 switch( speed ) {
96 case 115200: 96 case 115200:
97 m_base->setSpeed( IOLayerBase::Baud_115200 ); 97 m_base->setSpeed( IOLayerBase::Baud_115200 );
98 break; 98 break;
99 case 57600: 99 case 57600:
100 m_base->setSpeed( IOLayerBase::Baud_57600 ); 100 m_base->setSpeed( IOLayerBase::Baud_57600 );
101 break; 101 break;
102 case 38400: 102 case 38400:
103 m_base->setSpeed( IOLayerBase::Baud_38400 ); 103 m_base->setSpeed( IOLayerBase::Baud_38400 );
104 break; 104 break;
105 case 19200: 105 case 19200:
106 m_base->setSpeed( IOLayerBase::Baud_19200 ); 106 m_base->setSpeed( IOLayerBase::Baud_19200 );
107 break; 107 break;
108 case 9600: 108 case 9600:
109 default: 109 default:
110 m_base->setSpeed( IOLayerBase::Baud_9600 ); 110 m_base->setSpeed( IOLayerBase::Baud_9600 );
111 break; 111 break;
112 } 112 }
113 113
114 if ( prof.readEntry( "Device" ).isEmpty() ) { 114 if ( prof.readEntry( "Device" ).isEmpty() ) {
115 return; 115 return;
116 } 116 }
117 setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); 117 setCurrent( prof.readEntry( "Device" ), m_deviceCmb );
118 118
119 atConf->readConfig( prof ); 119 atConf->readConfig( prof );
120} 120}
121 121
122/* 122/*
123 * save speed, 123 * save speed,
124 * flow, 124 * flow,
125 * parity 125 * parity
126 */ 126 */
127void ModemConfigWidget::save( Profile& prof ) { 127void ModemConfigWidget::save( Profile& prof ) {
128 int flow, parity, speed; 128 int flow, parity, speed;
129 prof.writeEntry( "Device", m_deviceCmb->currentText() ); 129 prof.writeEntry( "Device", m_deviceCmb->currentText() );
130 130
131 131
132 switch( m_base->flow() ) { 132 switch( m_base->flow() ) {
133 case IOLayerBase::None: 133 case IOLayerBase::None:
134 flow = 0; 134 flow = 0;
135 break; 135 break;
136 case IOLayerBase::Software: 136 case IOLayerBase::Software:
137 flow = 2; 137 flow = 2;
138 break; 138 break;
139 case IOLayerBase::Hardware: 139 case IOLayerBase::Hardware:
140 flow = 1; 140 flow = 1;
141 break; 141 break;
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
180void ModemConfigWidget::slotAT() { 180void 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
188void ModemConfigWidget::slotDial() { 188void 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}