author | harlekin <harlekin> | 2002-10-13 21:10:15 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-13 21:10:15 (UTC) |
commit | 5a6ecdac2e62708b55300ca6eef8441fea0a7b05 (patch) (unidiff) | |
tree | 003577346dc8f9c73f1d86d8dd9d5038d6995662 /noncore/apps/opie-console/modemconfigwidget.cpp | |
parent | 03c81e6d55d1a837e543a00f6e0a7334e96f1eef (diff) | |
download | opie-5a6ecdac2e62708b55300ca6eef8441fea0a7b05.zip opie-5a6ecdac2e62708b55300ca6eef8441fea0a7b05.tar.gz opie-5a6ecdac2e62708b55300ca6eef8441fea0a7b05.tar.bz2 |
fixes to modem stuff
Diffstat (limited to 'noncore/apps/opie-console/modemconfigwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/modemconfigwidget.cpp | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp index 0968f62..ac62e45 100644 --- a/noncore/apps/opie-console/modemconfigwidget.cpp +++ b/noncore/apps/opie-console/modemconfigwidget.cpp | |||
@@ -1,136 +1,138 @@ | |||
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 | ||
8 | #include "iolayerbase.h" | 8 | |
9 | #include "modemconfigwidget.h" | 9 | #include "modemconfigwidget.h" |
10 | #include "atconfigdialog.h" | ||
11 | #include "dialdialog.h" | 10 | #include "dialdialog.h" |
12 | 11 | ||
13 | namespace { | 12 | namespace { |
14 | void setCurrent( const QString& str, QComboBox* bo ) { | 13 | void setCurrent( const QString& str, QComboBox* bo ) { |
15 | uint b = bo->count(); | 14 | uint b = bo->count(); |
16 | for (uint i = 0; i < bo->count(); i++ ) { | 15 | for (uint i = 0; i < bo->count(); i++ ) { |
17 | if ( bo->text(i) == str ) { | 16 | if ( bo->text(i) == str ) { |
18 | bo->setCurrentItem( i ); | 17 | bo->setCurrentItem( i ); |
19 | return; | 18 | return; |
20 | } | 19 | } |
21 | } | 20 | } |
22 | bo->insertItem( str ); | 21 | bo->insertItem( str ); |
23 | bo->setCurrentItem( b ); | 22 | bo->setCurrentItem( b ); |
24 | } | 23 | } |
25 | } | 24 | } |
26 | 25 | ||
27 | ModemConfigWidget::ModemConfigWidget( const QString& name, | 26 | ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, |
28 | QWidget* parent, | ||
29 | const char* na ) | 27 | const char* na ) |
30 | : ProfileDialogConnectionWidget( name, parent, na ) { | 28 | : ProfileDialogConnectionWidget( name, parent, na ) { |
31 | 29 | ||
32 | m_lay = new QVBoxLayout(this ); | 30 | m_lay = new QVBoxLayout( this ); |
33 | m_device = new QLabel(tr("Modem is attached to:"), this ); | 31 | m_device = new QLabel(tr( "Modem is attached to:" ), this ); |
34 | m_deviceCmb = new QComboBox(this ); | 32 | m_deviceCmb = new QComboBox(this ); |
35 | m_deviceCmb->setEditable( TRUE ); | 33 | m_deviceCmb->setEditable( TRUE ); |
36 | 34 | ||
37 | QLabel* telLabel = new QLabel( this ); | 35 | QLabel* telLabel = new QLabel( this ); |
38 | telLabel->setText( tr("Enter telefon number here:") ); | 36 | telLabel->setText( tr( "Enter telefon number here:" ) ); |
39 | m_telNumber = new QLineEdit( this ); | 37 | m_telNumber = new QLineEdit( this ); |
40 | QHBox *buttonBox = new QHBox( this ); | 38 | QHBox *buttonBox = new QHBox( this ); |
41 | QPushButton *atButton = new QPushButton( buttonBox ); | 39 | QPushButton *atButton = new QPushButton( buttonBox ); |
42 | atButton->setText( tr("AT commands") ); | 40 | atButton->setText( tr( "AT commands" ) ); |
43 | connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); | 41 | connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); |
44 | 42 | ||
45 | QPushButton *dialButton = new QPushButton( buttonBox ); | 43 | QPushButton *dialButton = new QPushButton( buttonBox ); |
46 | dialButton->setText( tr("Enter number") ); | 44 | dialButton->setText( tr( "Enter number" ) ); |
47 | connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); | 45 | connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); |
48 | 46 | ||
49 | 47 | ||
50 | m_base = new IOLayerBase(this, "base"); | 48 | m_base = new IOLayerBase( this, "base" ); |
51 | 49 | ||
52 | m_lay->addWidget( m_device ); | 50 | m_lay->addWidget( m_device ); |
53 | m_lay->addWidget( m_deviceCmb ); | 51 | m_lay->addWidget( m_deviceCmb ); |
54 | m_lay->addWidget( telLabel ); | 52 | m_lay->addWidget( telLabel ); |
55 | m_lay->addWidget( m_telNumber ); | 53 | m_lay->addWidget( m_telNumber ); |
56 | m_lay->addWidget( buttonBox ); | 54 | m_lay->addWidget( buttonBox ); |
57 | m_lay->addWidget( m_base ); | 55 | m_lay->addWidget( m_base ); |
58 | 56 | ||
59 | m_deviceCmb->insertItem( "/dev/ttyS0" ); | 57 | m_deviceCmb->insertItem( "/dev/ttyS0" ); |
60 | m_deviceCmb->insertItem( "/dev/ttyS1" ); | 58 | m_deviceCmb->insertItem( "/dev/ttyS1" ); |
61 | m_deviceCmb->insertItem( "/dev/ttyS2" ); | 59 | m_deviceCmb->insertItem( "/dev/ttyS2" ); |
62 | 60 | ||
63 | 61 | atConf = new ATConfigDialog( this, "ATConfig", true ); | |
64 | } | 62 | } |
65 | 63 | ||
66 | ModemConfigWidget::~ModemConfigWidget() { | 64 | ModemConfigWidget::~ModemConfigWidget() { |
67 | 65 | ||
68 | } | 66 | } |
69 | void ModemConfigWidget::load( const Profile& prof ) { | 67 | void ModemConfigWidget::load( const Profile& prof ) { |
70 | 68 | ||
71 | int rad_flow = prof.readNumEntry("Flow"); | 69 | int rad_flow = prof.readNumEntry( "Flow" ); |
72 | int rad_parity = prof.readNumEntry("Parity"); | 70 | int rad_parity = prof.readNumEntry( "Parity" ); |
73 | int speed = prof.readNumEntry("Speed"); | 71 | int speed = prof.readNumEntry( "Speed" ); |
74 | QString number = prof.readEntry("Number"); | 72 | QString number = prof.readEntry( "Number" ); |
75 | 73 | ||
76 | if (!number.isEmpty() ) { | 74 | if ( !number.isEmpty() ) { |
77 | m_telNumber->setText( number ); | 75 | m_telNumber->setText( number ); |
78 | } | 76 | } |
79 | 77 | ||
80 | if (rad_flow == 1) { | 78 | if ( rad_flow == 1 ) { |
81 | m_base->setFlow( IOLayerBase::Hardware ); | 79 | m_base->setFlow( IOLayerBase::Hardware ); |
82 | } else if (rad_flow == 2) { | 80 | } else if (rad_flow == 2) { |
83 | m_base->setFlow( IOLayerBase::Software ); | 81 | m_base->setFlow( IOLayerBase::Software ); |
84 | } else if (rad_flow == 0) { | 82 | } else if (rad_flow == 0) { |
85 | m_base->setFlow( IOLayerBase::None ); | 83 | m_base->setFlow( IOLayerBase::None ); |
86 | } | 84 | } |
87 | 85 | ||
88 | if (rad_parity == 1) { | 86 | if ( rad_parity == 1 ) { |
89 | m_base->setParity( IOLayerBase::Even ); | 87 | m_base->setParity( IOLayerBase::Even ); |
90 | } else { | 88 | } else { |
91 | m_base->setParity( IOLayerBase::Odd ); | 89 | m_base->setParity( IOLayerBase::Odd ); |
92 | } | 90 | } |
93 | 91 | ||
94 | switch( speed ) { | 92 | switch( speed ) { |
95 | case 115200: | 93 | case 115200: |
96 | m_base->setSpeed(IOLayerBase::Baud_115200 ); | 94 | m_base->setSpeed( IOLayerBase::Baud_115200 ); |
97 | break; | 95 | break; |
98 | case 57600: | 96 | case 57600: |
99 | m_base->setSpeed( IOLayerBase::Baud_57600 ); | 97 | m_base->setSpeed( IOLayerBase::Baud_57600 ); |
100 | break; | 98 | break; |
101 | case 38400: | 99 | case 38400: |
102 | m_base->setSpeed(IOLayerBase::Baud_38400 ); | 100 | m_base->setSpeed( IOLayerBase::Baud_38400 ); |
103 | break; | 101 | break; |
104 | case 19200: | 102 | case 19200: |
105 | m_base->setSpeed( IOLayerBase::Baud_19200 ); | 103 | m_base->setSpeed( IOLayerBase::Baud_19200 ); |
106 | break; | 104 | break; |
107 | case 9600: | 105 | case 9600: |
108 | default: | 106 | default: |
109 | m_base->setSpeed(IOLayerBase::Baud_9600 ); | 107 | m_base->setSpeed( IOLayerBase::Baud_9600 ); |
110 | break; | 108 | break; |
111 | } | 109 | } |
112 | 110 | ||
113 | if ( prof.readEntry("Device").isEmpty() ) return; | 111 | if ( prof.readEntry( "Device" ).isEmpty() ) { |
114 | setCurrent( prof.readEntry("Device"), m_deviceCmb ); | 112 | return; |
113 | } | ||
114 | setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); | ||
115 | 115 | ||
116 | atConf->readConfig( prof ); | ||
116 | } | 117 | } |
118 | |||
117 | /* | 119 | /* |
118 | * save speed, | 120 | * save speed, |
119 | * flow, | 121 | * flow, |
120 | * parity | 122 | * parity |
121 | */ | 123 | */ |
122 | void ModemConfigWidget::save( Profile& prof ) { | 124 | void ModemConfigWidget::save( Profile& prof ) { |
123 | int flow, parity, speed; | 125 | int flow, parity, speed; |
124 | prof.writeEntry("Device", m_deviceCmb->currentText() ); | 126 | prof.writeEntry( "Device", m_deviceCmb->currentText() ); |
125 | 127 | ||
126 | 128 | ||
127 | switch( m_base->flow() ) { | 129 | switch( m_base->flow() ) { |
128 | case IOLayerBase::None: | 130 | case IOLayerBase::None: |
129 | flow = 0; | 131 | flow = 0; |
130 | break; | 132 | break; |
131 | case IOLayerBase::Software: | 133 | case IOLayerBase::Software: |
132 | flow = 2; | 134 | flow = 2; |
133 | break; | 135 | break; |
134 | case IOLayerBase::Hardware: | 136 | case IOLayerBase::Hardware: |
135 | flow = 1; | 137 | flow = 1; |
136 | break; | 138 | break; |
@@ -154,34 +156,33 @@ void ModemConfigWidget::save( Profile& prof ) { | |||
154 | break; | 156 | break; |
155 | case IOLayerBase::Baud_38400: | 157 | case IOLayerBase::Baud_38400: |
156 | speed = 38400; | 158 | speed = 38400; |
157 | break; | 159 | break; |
158 | case IOLayerBase::Baud_19200: | 160 | case IOLayerBase::Baud_19200: |
159 | speed = 19200; | 161 | speed = 19200; |
160 | break; | 162 | break; |
161 | case IOLayerBase::Baud_9600: | 163 | case IOLayerBase::Baud_9600: |
162 | speed = 9600; | 164 | speed = 9600; |
163 | break; | 165 | break; |
164 | } | 166 | } |
165 | 167 | ||
166 | prof.writeEntry("Flow", flow); | 168 | prof.writeEntry( "Flow", flow ); |
167 | prof.writeEntry("Parity", parity); | 169 | prof.writeEntry( "Parity", parity ); |
168 | prof.writeEntry("Speed", speed); | 170 | prof.writeEntry( "Speed", speed ); |
169 | prof.writeEntry("Number", m_telNumber->text() ); | 171 | prof.writeEntry( "Number", m_telNumber->text() ); |
170 | } | 172 | } |
171 | 173 | ||
172 | void ModemConfigWidget::slotAT() { | 174 | void ModemConfigWidget::slotAT() { |
173 | ATConfigDialog conf( this, "ATConfig", true ); | 175 | // ATConfigDialog conf( this, "ATConfig", true ); |
174 | conf.readConfig(); | 176 | atConf->showMaximized(); |
175 | conf.showMaximized(); | 177 | if ( atConf->exec() == QDialog::Accepted ) { |
176 | if ( conf.exec() == QDialog::Accepted ) { | 178 | // atConf->writeConfig(); |
177 | conf.writeConfig(); | ||
178 | } | 179 | } |
179 | } | 180 | } |
180 | 181 | ||
181 | void ModemConfigWidget::slotDial() { | 182 | void ModemConfigWidget::slotDial() { |
182 | DialDialog dial( this, "DialConfig", true ); | 183 | DialDialog dial( this, "DialConfig", true ); |
183 | dial.showMaximized(); | 184 | dial.showMaximized(); |
184 | if ( dial.exec() == QDialog::Accepted ) { | 185 | if ( dial.exec() == QDialog::Accepted ) { |
185 | m_telNumber->setText( dial.number() ); | 186 | m_telNumber->setText( dial.number() ); |
186 | } | 187 | } |
187 | } | 188 | } |