summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-29 19:07:22 (UTC)
committer zecke <zecke>2002-10-29 19:07:22 (UTC)
commita575fd4c862693705018902b4482c5135a8cb6a2 (patch) (unidiff)
treebcdfd7b2b8f62b2fb766b8b8808e17c96668563c
parent5ac67b8aece5aca20419f8953f88a36fd729adfc (diff)
downloadopie-a575fd4c862693705018902b4482c5135a8cb6a2.zip
opie-a575fd4c862693705018902b4482c5135a8cb6a2.tar.gz
opie-a575fd4c862693705018902b4482c5135a8cb6a2.tar.bz2
Make the Modem take custom Ats again
Supply default values set labels to richtext this way we achieve word wrap IO_Layer added a closed(IOLayer*) signal ProfileEditorDialog make Horizontal scrolling on the QScrollView possible. Once the Vertical Scrollbar is there the Modem dialog does not have enough space
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/atconfigdialog.cpp1
-rw-r--r--noncore/apps/opie-console/dialdialog.cpp1
-rw-r--r--noncore/apps/opie-console/dialer.cpp26
-rw-r--r--noncore/apps/opie-console/io_layer.h6
-rw-r--r--noncore/apps/opie-console/io_modem.h2
-rw-r--r--noncore/apps/opie-console/io_serial.cpp6
-rw-r--r--noncore/apps/opie-console/modemconfigwidget.cpp9
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp4
8 files changed, 30 insertions, 25 deletions
diff --git a/noncore/apps/opie-console/atconfigdialog.cpp b/noncore/apps/opie-console/atconfigdialog.cpp
index 5c02692..e683ab3 100644
--- a/noncore/apps/opie-console/atconfigdialog.cpp
+++ b/noncore/apps/opie-console/atconfigdialog.cpp
@@ -1,215 +1,216 @@
1 1
2#include <qlineedit.h> 2#include <qlineedit.h>
3#include <qspinbox.h> 3#include <qspinbox.h>
4#include <qlayout.h> 4#include <qlayout.h>
5#include <qcombobox.h> 5#include <qcombobox.h>
6#include <qtabwidget.h> 6#include <qtabwidget.h>
7#include <qlabel.h> 7#include <qlabel.h>
8#include <qcombobox.h> 8#include <qcombobox.h>
9#include <qscrollview.h> 9#include <qscrollview.h>
10 10
11#include "atconfigdialog.h" 11#include "atconfigdialog.h"
12#include "io_modem.h" 12#include "io_modem.h"
13 13
14 14
15ATConfigDialog::ATConfigDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 15ATConfigDialog::ATConfigDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
16 : QDialog( parent, name, modal, fl ) { 16 : QDialog( parent, name, modal, fl ) {
17 17
18 18
19 setCaption( tr( "Dialing parameter setup" ) ); 19 setCaption( tr( "Dialing parameter setup" ) );
20 20
21 QVBoxLayout *layout = new QVBoxLayout( this ); 21 QVBoxLayout *layout = new QVBoxLayout( this );
22 QTabWidget *tabWidget = new QTabWidget( this ); 22 QTabWidget *tabWidget = new QTabWidget( this );
23 23
24 tabWidget->addTab( tab0( this ), tr("Settings1") ); 24 tabWidget->addTab( tab0( this ), tr("Settings1") );
25 tabWidget->addTab( tab1( this ), tr("Settings2") ); 25 tabWidget->addTab( tab1( this ), tr("Settings2") );
26 26
27 layout->addWidget( tabWidget ); 27 layout->addWidget( tabWidget );
28 28
29} 29}
30 30
31QWidget* ATConfigDialog::tab0( QWidget* parent) { 31QWidget* ATConfigDialog::tab0( QWidget* parent) {
32 32
33 33
34 QScrollView* sv = new QScrollView( parent ); 34 QScrollView* sv = new QScrollView( parent );
35 35
36 QWidget *returnWidget = new QWidget( sv->viewport() ); 36 QWidget *returnWidget = new QWidget( sv->viewport() );
37 sv->setResizePolicy( QScrollView::AutoOneFit ); 37 sv->setResizePolicy( QScrollView::AutoOneFit );
38// sv->setHScrollBarMode( QScrollView::AlwaysOff ); 38// sv->setHScrollBarMode( QScrollView::AlwaysOff );
39// sv->setFrameShape( QFrame::NoFrame ); 39// sv->setFrameShape( QFrame::NoFrame );
40 40
41 41
42 42
43 43
44 QGridLayout *layout = new QGridLayout( returnWidget, 10, 2 ); 44 QGridLayout *layout = new QGridLayout( returnWidget, 10, 2 );
45 45
46 QLabel *initStringLabel = new QLabel( tr("Init string "), returnWidget ); 46 QLabel *initStringLabel = new QLabel( tr("Init string "), returnWidget );
47 initStringLine = new QLineEdit( returnWidget ); 47 initStringLine = new QLineEdit( returnWidget );
48 layout->addWidget( initStringLabel, 0, 0 ); 48 layout->addWidget( initStringLabel, 0, 0 );
49 layout->addWidget( initStringLine, 0, 1 ); 49 layout->addWidget( initStringLine, 0, 1 );
50 50
51 QLabel *resetStringLabel = new QLabel( tr("Reset string "), returnWidget ); 51 QLabel *resetStringLabel = new QLabel( tr("Reset string "), returnWidget );
52 resetStringLine = new QLineEdit( returnWidget ); 52 resetStringLine = new QLineEdit( returnWidget );
53 layout->addWidget( resetStringLabel, 1, 0 ); 53 layout->addWidget( resetStringLabel, 1, 0 );
54 layout->addWidget( resetStringLine, 1, 1 ); 54 layout->addWidget( resetStringLine, 1, 1 );
55 55
56 QLabel *dialPref1Label = new QLabel( tr("Dialing prefix #1 " ), returnWidget ); 56 QLabel *dialPref1Label = new QLabel( tr("Dialing prefix #1 " ), returnWidget );
57 dialPref1Line = new QLineEdit( returnWidget ); 57 dialPref1Line = new QLineEdit( returnWidget );
58 layout->addWidget( dialPref1Label, 2, 0 ); 58 layout->addWidget( dialPref1Label, 2, 0 );
59 layout->addWidget( dialPref1Line, 2, 1 ); 59 layout->addWidget( dialPref1Line, 2, 1 );
60 60
61 QLabel *dialSuf1Label = new QLabel( tr("Dialing suffix #1 " ), returnWidget ); 61 QLabel *dialSuf1Label = new QLabel( tr("Dialing suffix #1 " ), returnWidget );
62 dialSuf1Line = new QLineEdit( returnWidget ); 62 dialSuf1Line = new QLineEdit( returnWidget );
63 layout->addWidget( dialSuf1Label, 3, 0 ); 63 layout->addWidget( dialSuf1Label, 3, 0 );
64 layout->addWidget( dialSuf1Line, 3, 1 ); 64 layout->addWidget( dialSuf1Line, 3, 1 );
65 65
66 QLabel *dialPref2Label = new QLabel( tr("Dialing prefix #2 " ), returnWidget ); 66 QLabel *dialPref2Label = new QLabel( tr("Dialing prefix #2 " ), returnWidget );
67 dialPref2Line = new QLineEdit( returnWidget ); 67 dialPref2Line = new QLineEdit( returnWidget );
68 layout->addWidget( dialPref2Label, 4, 0 ); 68 layout->addWidget( dialPref2Label, 4, 0 );
69 layout->addWidget( dialPref2Line, 4, 1 ); 69 layout->addWidget( dialPref2Line, 4, 1 );
70 70
71 QLabel *dialSuf2Label = new QLabel( tr("Dialing suffix #2 " ), returnWidget ); 71 QLabel *dialSuf2Label = new QLabel( tr("Dialing suffix #2 " ), returnWidget );
72 dialSuf2Line = new QLineEdit( returnWidget ); 72 dialSuf2Line = new QLineEdit( returnWidget );
73 layout->addWidget( dialSuf2Label, 5, 0 ); 73 layout->addWidget( dialSuf2Label, 5, 0 );
74 layout->addWidget( dialSuf2Line, 5, 1 ); 74 layout->addWidget( dialSuf2Line, 5, 1 );
75 75
76 QLabel *dialPref3Label = new QLabel( tr("Dialing prefix #3 " ), returnWidget ); 76 QLabel *dialPref3Label = new QLabel( tr("Dialing prefix #3 " ), returnWidget );
77 dialPref3Line = new QLineEdit( returnWidget ); 77 dialPref3Line = new QLineEdit( returnWidget );
78 layout->addWidget( dialPref3Label, 6, 0 ); 78 layout->addWidget( dialPref3Label, 6, 0 );
79 layout->addWidget( dialPref3Line, 6, 1 ); 79 layout->addWidget( dialPref3Line, 6, 1 );
80 80
81 QLabel *dialSuf3Label = new QLabel( tr("Dialing suffix #3 " ), returnWidget ); 81 QLabel *dialSuf3Label = new QLabel( tr("Dialing suffix #3 " ), returnWidget );
82 dialSuf3Line = new QLineEdit( returnWidget ); 82 dialSuf3Line = new QLineEdit( returnWidget );
83 layout->addWidget( dialSuf3Label, 7, 0 ); 83 layout->addWidget( dialSuf3Label, 7, 0 );
84 layout->addWidget( dialSuf3Line, 7, 1 ); 84 layout->addWidget( dialSuf3Line, 7, 1 );
85 85
86 QLabel *connectLabel = new QLabel( tr("Connect string " ), returnWidget ); 86 QLabel *connectLabel = new QLabel( tr("Connect string " ), returnWidget );
87 connectLine = new QLineEdit( returnWidget ); 87 connectLine = new QLineEdit( returnWidget );
88 layout->addWidget( connectLabel, 8, 0 ); 88 layout->addWidget( connectLabel, 8, 0 );
89 layout->addWidget( connectLine, 8, 1 ); 89 layout->addWidget( connectLine, 8, 1 );
90 90
91 QLabel *hangupLabel = new QLabel( tr("Hang-up string " ), returnWidget ); 91 QLabel *hangupLabel = new QLabel( tr("Hang-up string " ), returnWidget );
92 hangupLine = new QLineEdit( returnWidget ); 92 hangupLine = new QLineEdit( returnWidget );
93 layout->addWidget( hangupLabel, 9, 0 ); 93 layout->addWidget( hangupLabel, 9, 0 );
94 layout->addWidget( hangupLine, 9, 1 ); 94 layout->addWidget( hangupLine, 9, 1 );
95 95
96 sv->addChild( returnWidget ); 96 sv->addChild( returnWidget );
97 97
98 return sv; 98 return sv;
99 99
100} 100}
101 101
102QWidget* ATConfigDialog::tab1( QWidget* parent ) { 102QWidget* ATConfigDialog::tab1( QWidget* parent ) {
103 103
104 104
105 QWidget *returnWidget = new QWidget( parent ); 105 QWidget *returnWidget = new QWidget( parent );
106 106
107 QGridLayout *layout = new QGridLayout( returnWidget, 8, 2 ); 107 QGridLayout *layout = new QGridLayout( returnWidget, 8, 2 );
108 108
109 QLabel *dialTimeLabel = new QLabel( tr("Dial time " ), returnWidget ); 109 QLabel *dialTimeLabel = new QLabel( tr("Dial time " ), returnWidget );
110 dialTimeSpin = new QSpinBox( returnWidget ); 110 dialTimeSpin = new QSpinBox( returnWidget );
111 layout->addWidget( dialTimeLabel, 0, 0 ); 111 layout->addWidget( dialTimeLabel, 0, 0 );
112 layout->addWidget( dialTimeSpin, 0, 1 ); 112 layout->addWidget( dialTimeSpin, 0, 1 );
113 113
114 QLabel *delayRedialLabel = new QLabel( tr("Delay before redial " ), returnWidget ); 114 QLabel *delayRedialLabel = new QLabel( tr("Delay before redial " ), returnWidget );
115 delayRedialSpin = new QSpinBox( returnWidget ); 115 delayRedialSpin = new QSpinBox( returnWidget );
116 layout->addWidget( delayRedialLabel, 1, 0 ); 116 layout->addWidget( delayRedialLabel, 1, 0 );
117 layout->addWidget( delayRedialSpin, 1, 1 ); 117 layout->addWidget( delayRedialSpin, 1, 1 );
118 118
119 QLabel *numberTriesLabel = new QLabel( tr("Number of tries " ), returnWidget ); 119 QLabel *numberTriesLabel = new QLabel( tr("Number of tries " ), returnWidget );
120 numberTriesSpin = new QSpinBox( returnWidget ); 120 numberTriesSpin = new QSpinBox( returnWidget );
121 layout->addWidget( numberTriesLabel, 2, 0 ); 121 layout->addWidget( numberTriesLabel, 2, 0 );
122 layout->addWidget( numberTriesSpin, 2, 1 ); 122 layout->addWidget( numberTriesSpin, 2, 1 );
123 123
124 QLabel *dtrDropTimeLabel = new QLabel( tr("DTR drop time (0=no) " ), returnWidget ); 124 QLabel *dtrDropTimeLabel = new QLabel( tr("DTR drop time (0=no) " ), returnWidget );
125 dtrDropTimeSpin = new QSpinBox( returnWidget ); 125 dtrDropTimeSpin = new QSpinBox( returnWidget );
126 layout->addWidget( dtrDropTimeLabel, 3, 0 ); 126 layout->addWidget( dtrDropTimeLabel, 3, 0 );
127 layout->addWidget( dtrDropTimeSpin, 3, 1 ); 127 layout->addWidget( dtrDropTimeSpin, 3, 1 );
128 128
129 QLabel *bpsDetectLabel = new QLabel( tr("Auto bps detect " ), returnWidget ); 129 QLabel *bpsDetectLabel = new QLabel( tr("Auto bps detect " ), returnWidget );
130 bpsDetectBox = new QComboBox( returnWidget ); 130 bpsDetectBox = new QComboBox( returnWidget );
131 layout->addWidget( bpsDetectLabel, 4, 0 ); 131 layout->addWidget( bpsDetectLabel, 4, 0 );
132 layout->addWidget( bpsDetectBox, 4, 1 ); 132 layout->addWidget( bpsDetectBox, 4, 1 );
133 bpsDetectBox->insertItem( tr("No") ); 133 bpsDetectBox->insertItem( tr("No") );
134 bpsDetectBox->insertItem( tr("Yes") ); 134 bpsDetectBox->insertItem( tr("Yes") );
135 135
136 QLabel *dcdLinesLabel = new QLabel( tr("Modem has DCD line " ), returnWidget ); 136 QLabel *dcdLinesLabel = new QLabel( tr("Modem has DCD line " ), returnWidget );
137 dcdLinesBox = new QComboBox( returnWidget ); 137 dcdLinesBox = new QComboBox( returnWidget );
138 layout->addWidget( dcdLinesLabel, 5, 0 ); 138 layout->addWidget( dcdLinesLabel, 5, 0 );
139 layout->addWidget( dcdLinesBox, 5, 1 ); 139 layout->addWidget( dcdLinesBox, 5, 1 );
140 dcdLinesBox->insertItem( tr("No") ); 140 dcdLinesBox->insertItem( tr("No") );
141 dcdLinesBox->insertItem( tr("Yes") ); 141 dcdLinesBox->insertItem( tr("Yes") );
142 142
143 QLabel *multiLineUntagLabel = new QLabel( tr("Multi-line untag " ), returnWidget ); 143 QLabel *multiLineUntagLabel = new QLabel( tr("Multi-line untag " ), returnWidget );
144 multiLineUntagBox = new QComboBox( returnWidget ); 144 multiLineUntagBox = new QComboBox( returnWidget );
145 layout->addWidget( multiLineUntagLabel, 6, 0 ); 145 layout->addWidget( multiLineUntagLabel, 6, 0 );
146 layout->addWidget( multiLineUntagBox, 6, 1 ); 146 layout->addWidget( multiLineUntagBox, 6, 1 );
147 multiLineUntagBox->insertItem( tr("No") ); 147 multiLineUntagBox->insertItem( tr("No") );
148 multiLineUntagBox->insertItem( tr("Yes") ); 148 multiLineUntagBox->insertItem( tr("Yes") );
149 149
150 return returnWidget; 150 return returnWidget;
151 151
152} 152}
153 153
154 154
155void ATConfigDialog::readConfig( const Profile& config ) { 155void ATConfigDialog::readConfig( const Profile& config ) {
156 qWarning("config in atconfigdialog");
156 157
157 initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) ); 158 initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) );
158 resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) ); 159 resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) );
159 dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 160 dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) );
160 dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 161 dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
161 dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 162 dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) );
162 dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 163 dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
163 dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 164 dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) );
164 dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 165 dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
165 connectLine->setText( config.readEntry("DefaultConnect", MODEM_DEFAULT_CONNECT_STRING ) ); 166 connectLine->setText( config.readEntry("DefaultConnect", MODEM_DEFAULT_CONNECT_STRING ) );
166 hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) ); 167 hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) );
167 dialTimeSpin->setValue( config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ) ); 168 dialTimeSpin->setValue( config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ) );
168 delayRedialSpin->setValue( config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ) ); 169 delayRedialSpin->setValue( config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ) );
169 numberTriesSpin->setValue( config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ) ); 170 numberTriesSpin->setValue( config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ) );
170 dtrDropTimeSpin->setValue( config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ) ); 171 dtrDropTimeSpin->setValue( config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ) );
171 bpsDetectBox->setCurrentItem( config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ) ); 172 bpsDetectBox->setCurrentItem( config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ) );
172 dcdLinesBox->setCurrentItem( config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ) ); 173 dcdLinesBox->setCurrentItem( config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ) );
173 multiLineUntagBox->setCurrentItem( config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ) ); 174 multiLineUntagBox->setCurrentItem( config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ) );
174 175
175 // Not implemented yet 176 // Not implemented yet
176 resetStringLine->setEnabled(false); 177 resetStringLine->setEnabled(false);
177 dialSuf1Line->setEnabled(false); 178 dialSuf1Line->setEnabled(false);
178 dialPref2Line->setEnabled(false); 179 dialPref2Line->setEnabled(false);
179 dialSuf2Line->setEnabled(false); 180 dialSuf2Line->setEnabled(false);
180 dialPref3Line->setEnabled(false); 181 dialPref3Line->setEnabled(false);
181 dialSuf3Line->setEnabled(false); 182 dialSuf3Line->setEnabled(false);
182 dialTimeSpin->setEnabled(false); 183 dialTimeSpin->setEnabled(false);
183 delayRedialSpin->setEnabled(false); 184 delayRedialSpin->setEnabled(false);
184 numberTriesSpin->setEnabled(false); 185 numberTriesSpin->setEnabled(false);
185 dtrDropTimeSpin->setEnabled(false); 186 dtrDropTimeSpin->setEnabled(false);
186 bpsDetectBox->setEnabled(false); 187 bpsDetectBox->setEnabled(false);
187 dcdLinesBox->setEnabled(false); 188 dcdLinesBox->setEnabled(false);
188 multiLineUntagBox->setEnabled(false); 189 multiLineUntagBox->setEnabled(false);
189} 190}
190 191
191void ATConfigDialog::writeConfig( Profile& config ) { 192void ATConfigDialog::writeConfig( Profile& config ) {
192 193
193 config.writeEntry( "InitString", initStringLine->text() ); 194 config.writeEntry( "InitString", initStringLine->text() );
194 config.writeEntry( "ResetString", resetStringLine->text() ); 195 config.writeEntry( "ResetString", resetStringLine->text() );
195 config.writeEntry( "DialPrefix1", dialPref1Line->text() ); 196 config.writeEntry( "DialPrefix1", dialPref1Line->text() );
196 config.writeEntry( "DialSuffix1", dialSuf1Line->text() ); 197 config.writeEntry( "DialSuffix1", dialSuf1Line->text() );
197 config.writeEntry( "DialPrefix2", dialPref2Line->text() ); 198 config.writeEntry( "DialPrefix2", dialPref2Line->text() );
198 config.writeEntry( "DialSuffix2", dialSuf2Line->text() ); 199 config.writeEntry( "DialSuffix2", dialSuf2Line->text() );
199 config.writeEntry( "DialPrefix3", dialPref3Line->text() ); 200 config.writeEntry( "DialPrefix3", dialPref3Line->text() );
200 config.writeEntry( "DialSuffix3", dialSuf3Line->text() ); 201 config.writeEntry( "DialSuffix3", dialSuf3Line->text() );
201 config.writeEntry( "DefaultConnect", connectLine->text() ); 202 config.writeEntry( "DefaultConnect", connectLine->text() );
202 config.writeEntry( "HangupString", hangupLine->text() ); 203 config.writeEntry( "HangupString", hangupLine->text() );
203 config.writeEntry( "DialTime", dialTimeSpin->value() ); 204 config.writeEntry( "DialTime", dialTimeSpin->value() );
204 config.writeEntry( "DelayRedial", delayRedialSpin->value() ); 205 config.writeEntry( "DelayRedial", delayRedialSpin->value() );
205 config.writeEntry( "NumberTries", numberTriesSpin->value() ); 206 config.writeEntry( "NumberTries", numberTriesSpin->value() );
206 config.writeEntry( "DTRDRopTime", dtrDropTimeSpin->value() ); 207 config.writeEntry( "DTRDRopTime", dtrDropTimeSpin->value() );
207 config.writeEntry( "BPSDetect", bpsDetectBox->currentItem() ); 208 config.writeEntry( "BPSDetect", bpsDetectBox->currentItem() );
208 config.writeEntry( "DCDLines", dcdLinesBox->currentItem() ); 209 config.writeEntry( "DCDLines", dcdLinesBox->currentItem() );
209 config.writeEntry( "MultiLineUntag", multiLineUntagBox->currentItem() ); 210 config.writeEntry( "MultiLineUntag", multiLineUntagBox->currentItem() );
210 211
211} 212}
212 213
213 214
214ATConfigDialog::~ATConfigDialog() { 215ATConfigDialog::~ATConfigDialog() {
215} 216}
diff --git a/noncore/apps/opie-console/dialdialog.cpp b/noncore/apps/opie-console/dialdialog.cpp
index ac1e1db..b91727b 100644
--- a/noncore/apps/opie-console/dialdialog.cpp
+++ b/noncore/apps/opie-console/dialdialog.cpp
@@ -1,100 +1,101 @@
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 setCaption( tr( "Enter number" ) ); 18 setCaption( tr( "Enter number" ) );
19 19
20 QVBoxLayout *mainLayout = new QVBoxLayout( this ); 20 QVBoxLayout *mainLayout = new QVBoxLayout( this );
21 21
22 QLabel *textLabel = new QLabel( this ); 22 QLabel *textLabel = new QLabel( this );
23 textLabel->setTextFormat( QLabel::RichText );
23 textLabel->setText( tr("Enter the number you want to dial. When finished, press ok") ); 24 textLabel->setText( tr("Enter the number you want to dial. When finished, press ok") );
24 25
25 m_dialLine = new QLineEdit( this ); 26 m_dialLine = new QLineEdit( this );
26 m_dialLine->setReadOnly( true ); 27 m_dialLine->setReadOnly( true );
27 m_dialLine->setFrame( false ); 28 m_dialLine->setFrame( false );
28 m_dialLine->setAlignment( Qt::AlignLeft ); 29 m_dialLine->setAlignment( Qt::AlignLeft );
29 QFont dialLine_font( m_dialLine->font() ); 30 QFont dialLine_font( m_dialLine->font() );
30 dialLine_font.setBold( TRUE ); 31 dialLine_font.setBold( TRUE );
31 dialLine_font.setPointSize( 18 ); 32 dialLine_font.setPointSize( 18 );
32 m_dialLine->setFont( dialLine_font ); 33 m_dialLine->setFont( dialLine_font );
33 34
34 QWidget* dialWidget = new QWidget( this ); 35 QWidget* dialWidget = new QWidget( this );
35 QGridLayout *layout = new QGridLayout( dialWidget , 4, 3 ); 36 QGridLayout *layout = new QGridLayout( dialWidget , 4, 3 );
36 37
37 QButtonGroup *dialButtons = new QButtonGroup( ); 38 QButtonGroup *dialButtons = new QButtonGroup( );
38 39
39 QPushButton *number0 = new QPushButton( dialWidget ); 40 QPushButton *number0 = new QPushButton( dialWidget );
40 number0->setText( QString( "0" ) ); 41 number0->setText( QString( "0" ) );
41 QFont number0_font( number0->font() ); 42 QFont number0_font( number0->font() );
42 number0_font.setBold( TRUE ); 43 number0_font.setBold( TRUE );
43 number0->setFont( number0_font ); 44 number0->setFont( number0_font );
44 layout->addWidget( number0, 4, 1 ); 45 layout->addWidget( number0, 4, 1 );
45 dialButtons->insert( number0 ); 46 dialButtons->insert( number0 );
46 47
47 int x = 0, y = 0; 48 int x = 0, y = 0;
48 for ( int i = 0 ; i < 9; i++ ) { 49 for ( int i = 0 ; i < 9; i++ ) {
49 QPushButton *number = new QPushButton( dialWidget ); 50 QPushButton *number = new QPushButton( dialWidget );
50 number->setText( QString( "%1" ).arg( i + 1 ) ); 51 number->setText( QString( "%1" ).arg( i + 1 ) );
51 QFont number_font( number->font() ); 52 QFont number_font( number->font() );
52 number_font.setBold( TRUE ); 53 number_font.setBold( TRUE );
53 number->setFont( number_font ); 54 number->setFont( number_font );
54 55
55 dialButtons->insert( number ); 56 dialButtons->insert( number );
56 57
57 layout->addWidget( number, x, y ); 58 layout->addWidget( number, x, y );
58 59
59 if ( y < 2 ) { 60 if ( y < 2 ) {
60 y++; 61 y++;
61 } else { 62 } else {
62 x++; 63 x++;
63 y = 0; 64 y = 0;
64 } 65 }
65 } 66 }
66 67
67 connect( dialButtons, SIGNAL( clicked( int ) ), this, SLOT( slotEnterNumber( int ) ) ); 68 connect( dialButtons, SIGNAL( clicked( int ) ), this, SLOT( slotEnterNumber( int ) ) );
68 69
69 mainLayout->addStretch( 2 ); 70 mainLayout->addStretch( 2 );
70 mainLayout->addWidget( textLabel ); 71 mainLayout->addWidget( textLabel );
71 mainLayout->addStretch( 1 ); 72 mainLayout->addStretch( 1 );
72 mainLayout->addWidget( m_dialLine ); 73 mainLayout->addWidget( m_dialLine );
73 mainLayout->addStretch( 2 ); 74 mainLayout->addStretch( 2 );
74 mainLayout->addWidget( dialWidget ); 75 mainLayout->addWidget( dialWidget );
75 mainLayout->addStretch( 4 ); 76 mainLayout->addStretch( 4 );
76} 77}
77 78
78 79
79void DialDialog::slotEnterNumber( int number ) { 80void DialDialog::slotEnterNumber( int number ) {
80 81
81 // pretty stupid, just for testing .-) 82 // pretty stupid, just for testing .-)
82 83
83 m_number.append(QString("%1").arg(number)); 84 m_number.append(QString("%1").arg(number));
84 85
85 setNumber(m_number); 86 setNumber(m_number);
86} 87}
87 88
88DialDialog::~DialDialog() { 89DialDialog::~DialDialog() {
89} 90}
90 91
91QString DialDialog::number() { 92QString DialDialog::number() {
92 return m_number; 93 return m_number;
93 94
94} 95}
95 96
96void DialDialog::setNumber( QString number ) 97void DialDialog::setNumber( QString number )
97{ 98{
98 m_dialLine->setText( QString("%1").arg( number ) ); 99 m_dialLine->setText( QString("%1").arg( number ) );
99} 100}
100 101
diff --git a/noncore/apps/opie-console/dialer.cpp b/noncore/apps/opie-console/dialer.cpp
index 8524422..67ad10e 100644
--- a/noncore/apps/opie-console/dialer.cpp
+++ b/noncore/apps/opie-console/dialer.cpp
@@ -1,319 +1,315 @@
1#include "dialer.h" 1#include "dialer.h"
2 2
3#include <qlayout.h> 3#include <qlayout.h>
4#include <qprogressbar.h> 4#include <qprogressbar.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qpushbutton.h> 6#include <qpushbutton.h>
7#include <qapp.h> 7#include <qapp.h>
8#include <qtimer.h> 8#include <qtimer.h>
9#include <qmessagebox.h> 9#include <qmessagebox.h>
10 10
11#include <unistd.h> 11#include <unistd.h>
12#include <string.h> 12#include <string.h>
13#include <fcntl.h> 13#include <fcntl.h>
14#include <errno.h> 14#include <errno.h>
15 15
16#include "io_modem.h"
17
16// State machine: | When an error occurs, we don't have to 18// State machine: | When an error occurs, we don't have to
17// | reset everything. 19// | reset everything.
18// (init) <------+ | But if the user wants to reset, 20// (init) <------+ | But if the user wants to reset,
19// | | | we stop dialing immediately. 21// | | | we stop dialing immediately.
20// v | | 22// v | |
21// (options) ----+ | Following the state machine is necessary 23// (options) ----+ | Following the state machine is necessary
22// | \ | to get determinable results. 24// | \ | to get determinable results.
23// v ^ | 25// v ^ |
24// (dial) ----+ | 26// (dial) ----+ |
25// | ^ | 27// | ^ |
26// v | | 28// v | |
27// (online) --+ | 29// (online) --+ |
28// | | 30// | |
29// v | 31// v |
30 32
31 33
32// from atconfigdialog 34// from atconfigdialog
33//initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) ); 35//initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) );
34//resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) ); 36//resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) );
35//dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 37//dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) );
36//dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 38//dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
37//dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 39//dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) );
38//dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 40//dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
39//dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) ); 41//dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) );
40//dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) ); 42//dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
41//connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) ); 43//connectLine->setText( config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ) );
42//hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) ); 44//hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) );
43 45
44// from modemconfigwidget 46// from modemconfigwidget
45//int rad_flow = prof.readNumEntry("Flow"); 47//int rad_flow = prof.readNumEntry("Flow");
46//int rad_parity = prof.readNumEntry("Parity"); 48//int rad_parity = prof.readNumEntry("Parity");
47//int speed = prof.readNumEntry("Speed"); 49//int speed = prof.readNumEntry("Speed");
48//QString number = prof.readEntry("Number"); 50//QString number = prof.readEntry("Number");
49 51
50Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name) 52Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name)
51: QDialog(parent, name, true), m_fd(fd), m_profile(profile) 53: QDialog(parent, name, true), m_fd(fd), m_profile(profile)
52{ 54{
53 QVBoxLayout *vbox; 55 QVBoxLayout *vbox;
54 QLabel *desc; 56 QLabel *desc;
55 57
56 //m_profile.writeEntry("InitString", "ATZ");
57 //m_profile.writeEntry("DialPrefix1", "ATDT");
58 //m_profile.writeEntry("Termination", "\n");
59 58
60 usercancel = 0; 59 usercancel = 0;
61 cleanshutdown = 0; 60 cleanshutdown = 0;
62 61
63 //fcntl(m_fd, F_SETFL, O_NONBLOCK);
64 62
65 desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this); 63 desc = new QLabel(QObject::tr("Dialing number: %1").arg(m_profile.readEntry("Number")), this);
66 progress = new QProgressBar(this); 64 progress = new QProgressBar(this);
67 status = new QLabel("", this); 65 status = new QLabel("", this);
68 status->setFrameStyle(QFrame::Panel | QFrame::Sunken); 66 status->setFrameStyle(QFrame::Panel | QFrame::Sunken);
69 cancel = new QPushButton(QObject::tr("Cancel"), this); 67 cancel = new QPushButton(QObject::tr("Cancel"), this);
70 68
71 vbox = new QVBoxLayout(this, 2); 69 vbox = new QVBoxLayout(this, 2);
72 vbox->add(desc); 70 vbox->add(desc);
73 vbox->add(progress); 71 vbox->add(progress);
74 vbox->add(status); 72 vbox->add(status);
75 vbox->add(cancel); 73 vbox->add(cancel);
76 74
77 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel())); 75 connect(cancel, SIGNAL(clicked()), SLOT(slotCancel()));
78 76
79 show(); 77 show();
80 78
81 QTimer::singleShot(500, this, SLOT(slotAutostart())); 79 QTimer::singleShot(500, this, SLOT(slotAutostart()));
82} 80}
83 81
84Dialer::~Dialer() 82Dialer::~Dialer()
85{ 83{
86} 84}
87 85
88void Dialer::setHangupOnly() 86void Dialer::setHangupOnly()
89{ 87{
90 state = state_cancel; 88 state = state_cancel;
91 usercancel = 1; 89 usercancel = 1;
92 send("+++ATH\r"); 90 send( m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING )+"\r" );
93} 91}
94 92
95void Dialer::slotCancel() 93void Dialer::slotCancel()
96{ 94{
97 if(state != state_online) 95 if(state != state_online)
98 { 96 {
99 usercancel = 1; 97 usercancel = 1;
100 reset(); 98 reset();
101 } 99 }
102 else { 100 else {
103 accept(); 101 accept();
104 } 102 }
105} 103}
106 104
107void Dialer::reset() 105void Dialer::reset()
108{ 106{
109 qWarning("reset"); 107 qWarning("reset");
110 switchState(state_cancel); 108 switchState(state_cancel);
111} 109}
112 110
113void Dialer::slotAutostart() 111void Dialer::slotAutostart()
114{ 112{
115 //state = state_preinit; 113 //state = state_preinit;
116 dial(m_profile.readEntry("Number")); 114 dial(m_profile.readEntry("Number"));
117} 115}
118 116
119void Dialer::dial(const QString& number) 117void Dialer::dial(const QString& number)
120{ 118{
121 while(state != state_online) 119 while(state != state_online)
122 { 120 {
123 if(!usercancel) 121 if(!usercancel)
124 { 122 {
125 state = state_preinit; 123 state = state_preinit;
126 trydial(number); 124 trydial(number);
127 } 125 }
128 else break; 126 else break;
129 } 127 }
130 128
131 if(usercancel) 129 if(usercancel)
132 { 130 {
133 // modem hangup 131 // modem hangup
134 trydial(QString::null); 132 trydial(QString::null);
135 reject(); 133 reject();
136 } 134 }
137} 135}
138 136
139void Dialer::trydial(const QString& number) 137void Dialer::trydial(const QString& number)
140{ 138{
141 qWarning("TryDial:%s", number.latin1() ); 139 qWarning("TryDial:%s", number.latin1() );
142 if(state != state_cancel) switchState(state_preinit); 140 if(state != state_cancel) switchState(state_preinit);
143 if(cleanshutdown) 141 if(cleanshutdown)
144 { 142 {
145 qWarning("HangupString " + m_profile.readEntry("HangupString")); 143 qWarning("HangupString " + m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING));
146 //send(m_profile.readEntry("HangupString")); 144 send(m_profile.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) + "\r");
147 send("+++ATH\r");
148 //send("");
149 } 145 }
150 146
151 if(state != state_cancel) 147 if(state != state_cancel)
152 { 148 {
153 switchState(state_init); 149 switchState(state_init);
154 //send("ATZ"); 150// qWarning("Init String " + m_profile.readEntry("InitString") );
155 qWarning("Init String " + m_profile.readEntry("InitString") ); 151 send(m_profile.readEntry("InitString",MODEM_DEFAULT_INIT_STRING ) + "\r");
156 // send(m_profile.readEntry("InitString", "AT"));
157 send("AT\r");
158 QString response2 = receive(); 152 QString response2 = receive();
159 if(!response2.contains("\nOK\r")) 153 if(!response2.contains("\nOK\r"))
160 reset(); 154 reset();
161 } 155 }
162 156
163 /*if(state != state_cancel) 157 /*if(state != state_cancel)
164 { 158 {
165 switchState(state_options); 159 switchState(state_options);
166 160
167 qWarning("ATM3l3"); 161 qWarning("ATM3l3");
168 send("ATM3L3\r"); 162 send("ATM3L3\r");
169 QString response3 = receive(); 163 QString response3 = receive();
170 if(!response3.contains("\nOK\r")) 164 if(!response3.contains("\nOK\r"))
171 reset(); 165 reset();
172 } 166 }
173*/ 167*/
174 168
175 if(state != state_cancel) 169 if(state != state_cancel)
176 { 170 {
177 switchState(state_dialtone); 171 switchState(state_dialtone);
178 172
179 send("ATX1\r"); 173 send("ATX1\r");
180 QString response4 = receive(); 174 QString response4 = receive();
181 if(!response4.contains("\nOK\r")) 175 if(!response4.contains("\nOK\r"))
182 reset(); 176 reset();
183 } 177 }
184 178
185 if(state != state_cancel) 179 if(state != state_cancel)
186 { 180 {
187 qWarning("progress"); 181 qWarning("progress");
188 switchState(state_dialing); 182 switchState(state_dialing);
189 183
190 send(QString("ATDT %1\r").arg(number)); 184 // send(QString("ATDT %1\r").arg(number));
191 // send(QString("%1 %2").arg(m_profile.readEntry("DialPrefix1")).arg(number)); 185 send(QString("%1 %2\r").arg(m_profile.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ))
186 .arg(number));
187
192 QString response5 = receive(); 188 QString response5 = receive();
193 if(!response5.contains("CONNECT") ) 189 if(!response5.contains("CONNECT") )
194 { 190 {
195 if(response5.contains("BUSY")) 191 if(response5.contains("BUSY"))
196 switchState(state_dialing); 192 switchState(state_dialing);
197 else 193 else
198 { 194 {
199 QMessageBox::warning(this, 195 QMessageBox::warning(this,
200 QObject::tr("Failure"), 196 QObject::tr("Failure"),
201 QObject::tr("Dialing the number failed.")); 197 QObject::tr("Dialing the number failed."));
202 slotCancel(); 198 slotCancel();
203 } 199 }
204 } 200 }
205 } 201 }
206 202
207 203
208 if(state != state_cancel) 204 if(state != state_cancel)
209 { 205 {
210 state = state_online; 206 state = state_online;
211 slotCancel(); 207 slotCancel();
212 } 208 }
213} 209}
214 210
215void Dialer::send(const QString& msg) 211void Dialer::send(const QString& msg)
216{ 212{
217 QString m = msg; 213 QString m = msg;
218 int bytes; 214 int bytes;
219 QString termination; 215 QString termination;
220 216
221 qWarning("Sending: %s", m.latin1()); 217 qWarning("Sending: %s", m.latin1());
222 218
223 /*termination = "\r"; 219 /*termination = "\r";
224 //termination = m_profile.readEntry("Termination"); 220 //termination = m_profile.readEntry("Termination");
225 if(termination == "\n") m = m + "\n"; 221 if(termination == "\n") m = m + "\n";
226 else if(termination == "\r") m = m + "\r"; 222 else if(termination == "\r") m = m + "\r";
227 else m = m + "\r\n"; 223 else m = m + "\r\n";
228*/ 224*/
229 m = m.replace(QRegExp("\n"), "\r"); 225 m = m.replace(QRegExp("\n"), "\r");
230 226
231 bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit())); 227 bytes = ::write(m_fd, m.local8Bit(), strlen(m.local8Bit()));
232 if(bytes < 0) 228 if(bytes < 0)
233 { 229 {
234 reset(); 230 reset();
235 } 231 }
236} 232}
237 233
238QString Dialer::receive() 234QString Dialer::receive()
239{ 235{
240 QString buf; 236 QString buf;
241 char buffer[1024]; 237 char buffer[1024];
242 int ret; 238 int ret;
243 int counter = 0; 239 int counter = 0;
244 240
245 while(1) 241 while(1)
246 { 242 {
247 ret = ::read(m_fd, buffer, sizeof(buffer)); 243 ret = ::read(m_fd, buffer, sizeof(buffer));
248 244
249 if(ret > 0) 245 if(ret > 0)
250 { 246 {
251 for(int i = 0; i < ret; i++) 247 for(int i = 0; i < ret; i++)
252 buffer[i] = buffer[i] & 0x7F; 248 buffer[i] = buffer[i] & 0x7F;
253 buffer[ret] = 0; 249 buffer[ret] = 0;
254 qWarning("Got: %s", buffer); 250 qWarning("Got: %s", buffer);
255 buf.append(QString(buffer)); 251 buf.append(QString(buffer));
256 if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY"))) 252 if(buf.contains("OK") || buf.contains("ERROR") || buf.contains("CONNECT") || (buf.contains("BUSY")))
257 { 253 {
258 //qWarning("Receiving: '%s'", buf.latin1()); 254 //qWarning("Receiving: '%s'", buf.latin1());
259 cleanshutdown = 1; 255 cleanshutdown = 1;
260 return buf; 256 return buf;
261 }else if (buf.contains("NO CARRIER") || buf.contains("NO DIALTONE") ) { 257 }else if (buf.contains("NO CARRIER") || buf.contains("NO DIALTONE") ) {
262 cleanshutdown = 1; 258 cleanshutdown = 1;
263 return QString::null; 259 return QString::null;
264 } 260 }
265 } 261 }
266 else if(ret < 0) 262 else if(ret < 0)
267 { 263 {
268 if(errno != EAGAIN) reset(); 264 if(errno != EAGAIN) reset();
269 else if(!(counter++ % 100)) qApp->processEvents(); 265 else if(!(counter++ % 100)) qApp->processEvents();
270 } 266 }
271 else if(!(counter++ % 100)) qApp->processEvents(); 267 else if(!(counter++ % 100)) qApp->processEvents();
272 268
273 if(usercancel) return QString::null; 269 if(usercancel) return QString::null;
274 } 270 }
275 271
276 cleanshutdown = 1; 272 cleanshutdown = 1;
277 return QString::null; 273 return QString::null;
278} 274}
279 275
280void Dialer::switchState(int newstate) 276void Dialer::switchState(int newstate)
281{ 277{
282 int oldstate = state; 278 int oldstate = state;
283 state = newstate; 279 state = newstate;
284 280
285 switch(state) 281 switch(state)
286 { 282 {
287 case state_cancel: 283 case state_cancel:
288 status->setText(QObject::tr("Cancelling...")); 284 status->setText(QObject::tr("Cancelling..."));
289 progress->setProgress(0); 285 progress->setProgress(0);
290 break; 286 break;
291 case state_preinit: 287 case state_preinit:
292 status->setText(QObject::tr("Searching modem")); 288 status->setText(QObject::tr("Searching modem"));
293 progress->setProgress(10); 289 progress->setProgress(10);
294 break; 290 break;
295 case state_init: 291 case state_init:
296 status->setText(QObject::tr("Initializing...")); 292 status->setText(QObject::tr("Initializing..."));
297 progress->setProgress(20); 293 progress->setProgress(20);
298 break; 294 break;
299 case state_options: 295 case state_options:
300 status->setText(QObject::tr("Reset speakers")); 296 status->setText(QObject::tr("Reset speakers"));
301 progress->setProgress(30); 297 progress->setProgress(30);
302 break; 298 break;
303 case state_dialtone: 299 case state_dialtone:
304 status->setText(QObject::tr("Turning off dialtone")); 300 status->setText(QObject::tr("Turning off dialtone"));
305 progress->setProgress(40); 301 progress->setProgress(40);
306 break; 302 break;
307 case state_dialing: 303 case state_dialing:
308 if(oldstate != state_dialing) status->setText(QObject::tr("Dial number")); 304 if(oldstate != state_dialing) status->setText(QObject::tr("Dial number"));
309 else status->setText(QObject::tr("Line busy, redialing number")); 305 else status->setText(QObject::tr("Line busy, redialing number"));
310 progress->setProgress(50); 306 progress->setProgress(50);
311 break; 307 break;
312 case state_online: 308 case state_online:
313 status->setText(QObject::tr("Connection established")); 309 status->setText(QObject::tr("Connection established"));
314 progress->setProgress(100); 310 progress->setProgress(100);
315 cancel->setText(QObject::tr("Dismiss")); 311 cancel->setText(QObject::tr("Dismiss"));
316 break; 312 break;
317 } 313 }
318} 314}
319 315
diff --git a/noncore/apps/opie-console/io_layer.h b/noncore/apps/opie-console/io_layer.h
index af61099..ed4478b 100644
--- a/noncore/apps/opie-console/io_layer.h
+++ b/noncore/apps/opie-console/io_layer.h
@@ -1,126 +1,132 @@
1#ifndef OPIE_IO_LAYER_H 1#ifndef OPIE_IO_LAYER_H
2#define OPIE_IO_LAYER_H 2#define OPIE_IO_LAYER_H
3 3
4#include <qbitarray.h> 4#include <qbitarray.h>
5#include <qobject.h> 5#include <qobject.h>
6 6
7 7
8#include <qpe/config.h> 8#include <qpe/config.h>
9 9
10#include "profile.h" 10#include "profile.h"
11 11
12/** 12/**
13 * This is the base class for IO Layers 13 * This is the base class for IO Layers
14 * It will used to sent and recv data( QByteArray ) 14 * It will used to sent and recv data( QByteArray )
15 * it 15 * it
16 */ 16 */
17class IOLayer : public QObject { 17class IOLayer : public QObject {
18 Q_OBJECT 18 Q_OBJECT
19public: 19public:
20 enum Error { 20 enum Error {
21 NoError = -1, 21 NoError = -1,
22 Refuse = 0, 22 Refuse = 0,
23 CouldNotOpen =1, 23 CouldNotOpen =1,
24 ClosedUnexpected =2, 24 ClosedUnexpected =2,
25 ClosedError =3, 25 ClosedError =3,
26 Terminate = 4 26 Terminate = 4
27 /* add more errors here */ 27 /* add more errors here */
28 }; 28 };
29 enum Feature { 29 enum Feature {
30 AutoConnect = 0, 30 AutoConnect = 0,
31 TransferFile = 1, 31 TransferFile = 1,
32 Close = 2 32 Close = 2
33 }; 33 };
34 /** 34 /**
35 * a small c'tor 35 * a small c'tor
36 */ 36 */
37 IOLayer(); 37 IOLayer();
38 38
39 /** 39 /**
40 * create an IOLayer instance from a config file 40 * create an IOLayer instance from a config file
41 * the currently set group stores the profile/session 41 * the currently set group stores the profile/session
42 * information 42 * information
43 */ 43 */
44 IOLayer( const Profile& ); 44 IOLayer( const Profile& );
45 45
46 /** 46 /**
47 * destructor 47 * destructor
48 */ 48 */
49 virtual ~IOLayer(); 49 virtual ~IOLayer();
50 50
51 /** 51 /**
52 * a small internal identifier 52 * a small internal identifier
53 */ 53 */
54 virtual QString identifier() const = 0; 54 virtual QString identifier() const = 0;
55 55
56 /** 56 /**
57 * a short name 57 * a short name
58 */ 58 */
59 virtual QString name() const = 0; 59 virtual QString name() const = 0;
60 60
61 /** 61 /**
62 * a file descriptor which opens 62 * a file descriptor which opens
63 * the device for io but does not 63 * the device for io but does not
64 * do any ioctling on it... 64 * do any ioctling on it...
65 * and it'll stop listening to the before opened 65 * and it'll stop listening to the before opened
66 * device 66 * device
67 */ 67 */
68 virtual int rawIO()const; 68 virtual int rawIO()const;
69 69
70 /** 70 /**
71 * will close the rawIO stuff 71 * will close the rawIO stuff
72 * and will listen to it's data again... 72 * and will listen to it's data again...
73 */ 73 */
74 virtual void closeRawIO(int); 74 virtual void closeRawIO(int);
75 75
76 /** 76 /**
77 * What does the IOLayer support? 77 * What does the IOLayer support?
78 * Bits are related to features 78 * Bits are related to features
79 */ 79 */
80 virtual QBitArray supports()const = 0; 80 virtual QBitArray supports()const = 0;
81 81
82 virtual bool isConnected() = 0; 82 virtual bool isConnected() = 0;
83 83
84signals: 84signals:
85 /** 85 /**
86 * received input as QCString 86 * received input as QCString
87 */ 87 */
88 virtual void received( const QByteArray& ); 88 virtual void received( const QByteArray& );
89 89
90 /** 90 /**
91 * an error occured 91 * an error occured
92 * int for the error number 92 * int for the error number
93 * and QString for a text 93 * and QString for a text
94 */ 94 */
95 virtual void error( int, const QString& ); 95 virtual void error( int, const QString& );
96 96
97
97 virtual void closed(); 98 virtual void closed();
99
100 /* signal emitted for closure of the IOLayer
101 * for some reasons
102 */
103 virtual void closed(IOLayer*);
98public slots: 104public slots:
99 /** 105 /**
100 * send a QCString to the device 106 * send a QCString to the device
101 */ 107 */
102 virtual void send( const QByteArray& ) = 0; 108 virtual void send( const QByteArray& ) = 0;
103 109
104 /** 110 /**
105 * bool open 111 * bool open
106 */ 112 */
107 virtual bool open() = 0; 113 virtual bool open() = 0;
108 114
109 /** 115 /**
110 * close the io 116 * close the io
111 */ 117 */
112 virtual void close() = 0; 118 virtual void close() = 0;
113 119
114 /** 120 /**
115 * closes and reloads the settings 121 * closes and reloads the settings
116 */ 122 */
117 virtual void reload( const Profile& ) = 0; 123 virtual void reload( const Profile& ) = 0;
118 124
119 /** 125 /**
120 * set the size 126 * set the size
121 * needed for pty 127 * needed for pty
122 */ 128 */
123 virtual void setSize(int lines, int cols ); 129 virtual void setSize(int lines, int cols );
124}; 130};
125 131
126#endif 132#endif
diff --git a/noncore/apps/opie-console/io_modem.h b/noncore/apps/opie-console/io_modem.h
index 1328706..17228bd 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 "ATZ" 16#define MODEM_DEFAULT_INIT_STRING "AT"
17#define MODEM_DEFAULT_RESET_STRING "ATZ~" 17#define MODEM_DEFAULT_RESET_STRING "ATZ~"
18#define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT" 18#define MODEM_DEFAULT_DIAL_PREFIX1 "ATDT"
19#define MODEM_DEFAULT_DIAL_SUFFIX1 "" 19#define MODEM_DEFAULT_DIAL_SUFFIX1 ""
20#define MODEM_DEFAULT_DIAL_PREFIX2 "" 20#define MODEM_DEFAULT_DIAL_PREFIX2 ""
21#define MODEM_DEFAULT_DIAL_SUFFIX2 "" 21#define MODEM_DEFAULT_DIAL_SUFFIX2 ""
22#define MODEM_DEFAULT_DIAL_PREFIX3 "" 22#define MODEM_DEFAULT_DIAL_PREFIX3 ""
23#define MODEM_DEFAULT_DIAL_SUFFIX3 "" 23#define MODEM_DEFAULT_DIAL_SUFFIX3 ""
24#define MODEM_DEFAULT_CONNECT_STRING "CONNECT" 24#define MODEM_DEFAULT_CONNECT_STRING "CONNECT"
25#define MODEM_DEFAULT_HANGUP_STRING "+++ATH" 25#define MODEM_DEFAULT_HANGUP_STRING "+++ATH"
26#define MODEM_DEFAULT_CANCEL_STRING "" 26#define MODEM_DEFAULT_CANCEL_STRING ""
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 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/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp
index 03e92dd..ddd4994 100644
--- a/noncore/apps/opie-console/io_serial.cpp
+++ b/noncore/apps/opie-console/io_serial.cpp
@@ -1,235 +1,231 @@
1 1
2#include <fcntl.h> 2#include <fcntl.h>
3#include <termios.h> 3#include <termios.h>
4#include <errno.h> 4#include <errno.h>
5#include <unistd.h> 5#include <unistd.h>
6#include <stdio.h> 6#include <stdio.h>
7 7
8#include "io_serial.h" 8#include "io_serial.h"
9 9
10IOSerial::IOSerial(const Profile &config) : IOLayer(config) { 10IOSerial::IOSerial(const Profile &config) : IOLayer(config) {
11 m_read = 0l; 11 m_read = 0l;
12 m_error = 0l; 12 m_error = 0l;
13 m_fd = 0; 13 m_fd = 0;
14 m_connected = false; 14 m_connected = false;
15 reload(config); 15 reload(config);
16} 16}
17 17
18 18
19IOSerial::~IOSerial() { 19IOSerial::~IOSerial() {
20 if (m_fd) { 20 if (m_fd) {
21 close(); 21 close();
22 } 22 }
23} 23}
24 24
25void IOSerial::send(const QByteArray &data) { 25void IOSerial::send(const QByteArray &data) {
26 if (m_fd) { 26 if (m_fd) {
27 write(m_fd, data.data(), data.size()); 27 write(m_fd, data.data(), data.size());
28 } else { 28 } else {
29 emit error(Refuse, tr("Not connected")); 29 emit error(Refuse, tr("Not connected"));
30 } 30 }
31} 31}
32 32
33void IOSerial::close() { 33void IOSerial::close() {
34 if (m_fd) { 34 if (m_fd) {
35 delete m_read; 35 delete m_read;
36 delete m_error; 36 delete m_error;
37 ::close(m_fd); 37 ::close(m_fd);
38 m_fd = 0; 38 m_fd = 0;
39 m_connected = false; 39 m_connected = false;
40 } else { 40 } else {
41 m_connected = false; 41 m_connected = false;
42 emit error(Refuse, tr("Not connected")); 42 emit error(Refuse, tr("Not connected"));
43 } 43 }
44} 44}
45 45
46bool IOSerial::open() { 46bool IOSerial::open() {
47 if (!m_fd) { 47 if (!m_fd) {
48 struct termios tty; 48 struct termios tty;
49 m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK); 49 m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK);
50 if (m_fd < 0) { 50 if (m_fd < 0) {
51 emit error(CouldNotOpen, strerror(errno)); 51 emit error(CouldNotOpen, strerror(errno));
52 m_fd = 0; 52 m_fd = 0;
53 return FALSE; 53 return FALSE;
54 } 54 }
55 tcgetattr(m_fd, &tty); 55 tcgetattr(m_fd, &tty);
56 56
57 /* Baud rate */ 57 /* Baud rate */
58 int speed = baud(m_baud); 58 int speed = baud(m_baud);
59 if (speed == -1) { 59 if (speed == -1) {
60 emit error(Refuse, tr("Invalid baud rate")); 60 emit error(Refuse, tr("Invalid baud rate"));
61 } 61 }
62 cfsetospeed(&tty, speed); 62 cfsetospeed(&tty, speed);
63 cfsetispeed(&tty, speed); 63 cfsetispeed(&tty, speed);
64 64
65 /* Take care of Space / Mark parity */ 65 /* Take care of Space / Mark parity */
66 if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) { 66 if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) {
67 m_dbits = 8; 67 m_dbits = 8;
68 } 68 }
69 69
70 /* Data bits */ 70 /* Data bits */
71 switch (m_dbits) { 71 switch (m_dbits) {
72 case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break; 72 case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break;
73 case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break; 73 case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break;
74 case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break; 74 case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break;
75 case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break; 75 case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break;
76 default: break; 76 default: break;
77 } 77 }
78 78
79 /* Raw, no echo mode */ 79 /* Raw, no echo mode */
80 tty.c_iflag = IGNBRK; 80 tty.c_iflag = IGNBRK;
81 tty.c_lflag = 0; 81 tty.c_lflag = 0;
82 tty.c_oflag = 0; 82 tty.c_oflag = 0;
83 tty.c_cflag |= CLOCAL | CREAD; 83 tty.c_cflag |= CLOCAL | CREAD;
84 84
85 /* Stop bits */ 85 /* Stop bits */
86 if (m_sbits == 2) { 86 if (m_sbits == 2) {
87 tty.c_cflag |= CSTOPB; 87 tty.c_cflag |= CSTOPB;
88 } else { 88 } else {
89 tty.c_cflag &= ~CSTOPB; 89 tty.c_cflag &= ~CSTOPB;
90 } 90 }
91 91
92 tty.c_cc[VMIN] = 1; 92 tty.c_cc[VMIN] = 1;
93 tty.c_cc[VTIME] = 5; 93 tty.c_cc[VTIME] = 5;
94 94
95 /* Flow control */ 95 /* Flow control */
96 if (m_flow & FlowSW) 96 if (m_flow & FlowSW)
97 tty.c_iflag |= IXON | IXOFF; 97 tty.c_iflag |= IXON | IXOFF;
98 else 98 else
99 tty.c_iflag &= ~(IXON|IXOFF|IXANY); 99 tty.c_iflag &= ~(IXON|IXOFF|IXANY);
100 100
101 if (m_flow & FlowHW) 101 if (m_flow & FlowHW)
102 tty.c_cflag |= CRTSCTS; 102 tty.c_cflag |= CRTSCTS;
103 else 103 else
104 tty.c_cflag &= ~CRTSCTS; 104 tty.c_cflag &= ~CRTSCTS;
105 105
106 /* Parity */ 106 /* Parity */
107 tty.c_cflag &= ~(PARENB | PARODD); 107 tty.c_cflag &= ~(PARENB | PARODD);
108 if (m_parity & ParityEven) 108 if (m_parity & ParityEven)
109 tty.c_cflag |= PARENB; 109 tty.c_cflag |= PARENB;
110 else if (m_parity & ParityOdd) 110 else if (m_parity & ParityOdd)
111 tty.c_cflag |= (PARENB | PARODD); 111 tty.c_cflag |= (PARENB | PARODD);
112 112
113 /* Set the changes */ 113 /* Set the changes */
114 tcsetattr(m_fd, TCSANOW, &tty); 114 tcsetattr(m_fd, TCSANOW, &tty);
115 115
116 /* Notifications on read & errors */ 116 /* Notifications on read & errors */
117 m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); 117 m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
118 m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this); 118 m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this);
119 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); 119 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
120 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); 120 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
121 m_connected = false; 121 m_connected = false;
122 return TRUE; 122 return TRUE;
123 } else { 123 } else {
124 emit error(Refuse, tr("Device is already connected")); 124 emit error(Refuse, tr("Device is already connected"));
125 m_fd = 0; 125 m_fd = 0;
126 return FALSE; 126 return FALSE;
127 } 127 }
128} 128}
129 129
130void IOSerial::reload(const Profile &config) { 130void IOSerial::reload(const Profile &config) {
131 m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); 131 m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE);
132 m_baud = config.readNumEntry("Speed", SERIAL_DEFAULT_BAUD); 132 m_baud = config.readNumEntry("Speed", SERIAL_DEFAULT_BAUD);
133 m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY); 133 m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY);
134 m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS); 134 m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS);
135 m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS); 135 m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS);
136 m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW); 136 m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW);
137 137
138} 138}
139 139
140int IOSerial::baud(int baud) const { 140int IOSerial::baud(int baud) const {
141 switch (baud) { 141 switch (baud) {
142 case 300: return B300; break; 142 case 300: return B300; break;
143 case 600: return B600; break; 143 case 600: return B600; break;
144 case 1200: return B1200; break; 144 case 1200: return B1200; break;
145 case 2400: return B2400; break; 145 case 2400: return B2400; break;
146 case 4800: return B4800; break; 146 case 4800: return B4800; break;
147 case 9600: return B9600; break; 147 case 9600: return B9600; break;
148 case 19200: return B19200; break; 148 case 19200: return B19200; break;
149 case 38400: return B38400; break; 149 case 38400: return B38400; break;
150 case 57600: return B57600; break; 150 case 57600: return B57600; break;
151 case 115200: return B115200; break; 151 case 115200: return B115200; break;
152 } 152 }
153 return -1; 153 return -1;
154} 154}
155 155
156void IOSerial::errorOccured() { 156void IOSerial::errorOccured() {
157 emit error(ClosedUnexpected, strerror(errno)); 157 emit error(ClosedUnexpected, strerror(errno));
158 close(); 158 close();
159} 159}
160 160
161void IOSerial::dataArrived() { 161void IOSerial::dataArrived() {
162 QByteArray array(4097); 162 QByteArray array(4097);
163 163
164 int len = read(m_fd, array.data(), 4096); 164 int len = read(m_fd, array.data(), 4096);
165 if (len == 0) 165 if (len == 0)
166 close(); 166 close();
167 if (len < 0) 167 if (len < 0)
168 return; 168 return;
169 qWarning("got from layer"); 169
170 for (int i = 0; i < len; i++ ) {
171 printf("%c", array[i] );
172 }
173 printf("\n");
174 array.resize( len ); 170 array.resize( len );
175 emit received(array); 171 emit received(array);
176} 172}
177 173
178QString IOSerial::identifier() const { 174QString IOSerial::identifier() const {
179 return "serial"; 175 return "serial";
180} 176}
181 177
182QString IOSerial::name() const { 178QString IOSerial::name() const {
183 return "RS232 Serial IO Layer"; 179 return "RS232 Serial IO Layer";
184} 180}
185int IOSerial::rawIO()const { 181int IOSerial::rawIO()const {
186 if (m_read ) 182 if (m_read )
187 disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); 183 disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
188 if (m_error ) 184 if (m_error )
189 disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); 185 disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
190 186
191 int fd = ::open(m_device, O_RDWR ); 187 int fd = ::open(m_device, O_RDWR );
192 188
193 return fd; 189 return fd;
194}; 190};
195void IOSerial::closeRawIO(int fd) { 191void IOSerial::closeRawIO(int fd) {
196 if (m_read ) 192 if (m_read )
197 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); 193 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
198 if (m_error ) 194 if (m_error )
199 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); 195 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
200 196
201 ::close( fd ); 197 ::close( fd );
202} 198}
203QBitArray IOSerial::supports()const { 199QBitArray IOSerial::supports()const {
204 QBitArray ar(3); 200 QBitArray ar(3);
205 ar[0] = ar[2] = 0; 201 ar[0] = ar[2] = 0;
206 ar[1] = 1; 202 ar[1] = 1;
207 203
208 return ar; 204 return ar;
209} 205}
210 206
211bool IOSerial::isConnected() { 207bool IOSerial::isConnected() {
212 return m_connected; 208 return m_connected;
213} 209}
214 210
215/* 211/*
216 * this is used to give the 212 * this is used to give the
217 * class below IOSerial 213 * class below IOSerial
218 * the possibility of 214 * the possibility of
219 * exclusive usage 215 * exclusive usage
220 */ 216 */
221void IOSerial::internDetach() { 217void IOSerial::internDetach() {
222 if (m_read ) 218 if (m_read )
223 disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); 219 disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
224 if (m_error ) 220 if (m_error )
225 disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); 221 disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
226} 222}
227/* 223/*
228 * give power back 224 * give power back
229 */ 225 */
230void IOSerial::internAttach() { 226void IOSerial::internAttach() {
231 if (m_read ) 227 if (m_read )
232 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); 228 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
233 if (m_error ) 229 if (m_error )
234 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); 230 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
235} 231}
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp
index 37eb184..f7fb6f3 100644
--- a/noncore/apps/opie-console/modemconfigwidget.cpp
+++ b/noncore/apps/opie-console/modemconfigwidget.cpp
@@ -1,252 +1,257 @@
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#include <qregexp.h> 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 (int i = 0; i < bo->count(); i++ ) { 15 for (int 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 QHBox *buttonBox = new QHBox( this ); 37 QHBox *buttonBox = new QHBox( this );
38 m_telNumber = new QLineEdit( buttonBox ); 38 m_telNumber = new QLineEdit( buttonBox );
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 m_base = new IOLayerBase( this, "base" ); 47 m_base = new IOLayerBase( this, "base" );
48 48
49 m_lay->addWidget( m_device ); 49 m_lay->addWidget( m_device );
50 m_lay->addWidget( m_deviceCmb ); 50 m_lay->addWidget( m_deviceCmb );
51 m_lay->addWidget( telLabel ); 51 m_lay->addWidget( telLabel );
52 m_lay->addWidget( buttonBox ); 52 m_lay->addWidget( buttonBox );
53 m_lay->addWidget( m_base ); 53 m_lay->addWidget( m_base );
54 m_lay->addStretch( 0 ); 54 m_lay->addStretch( 0 );
55 55
56 m_deviceCmb->insertItem( "/dev/ttyS0" ); 56 m_deviceCmb->insertItem( "/dev/ttyS0" );
57 m_deviceCmb->insertItem( "/dev/ttyS1" ); 57 m_deviceCmb->insertItem( "/dev/ttyS1" );
58 m_deviceCmb->insertItem( "/dev/ttyS2" ); 58 m_deviceCmb->insertItem( "/dev/ttyS2" );
59 59
60 atConf = new ATConfigDialog( this, "ATConfig", true ); 60 atConf = new ATConfigDialog( this, "ATConfig", true );
61} 61}
62 62
63ModemConfigWidget::~ModemConfigWidget() { 63ModemConfigWidget::~ModemConfigWidget() {
64 64
65} 65}
66void ModemConfigWidget::load( const Profile& prof ) { 66void ModemConfigWidget::load( const Profile& prof ) {
67 67
68 int rad_flow = prof.readNumEntry( "Flow" ); 68 int rad_flow = prof.readNumEntry( "Flow" );
69 int rad_parity = prof.readNumEntry( "Parity" ); 69 int rad_parity = prof.readNumEntry( "Parity" );
70 int speed = prof.readNumEntry( "Speed" ); 70 int speed = prof.readNumEntry( "Speed" );
71 int dbits = prof.readNumEntry("DataBits"); 71 int dbits = prof.readNumEntry("DataBits");
72 int sbits = prof.readNumEntry("StopBits"); 72 int sbits = prof.readNumEntry("StopBits");
73 QString number = prof.readEntry( "Number" ); 73 QString number = prof.readEntry( "Number" );
74 74
75 if ( !number.isEmpty() ) { 75 if ( !number.isEmpty() ) {
76 m_telNumber->setText( number ); 76 m_telNumber->setText( number );
77 } 77 }
78 78
79 if ( rad_flow == 1 ) { 79 if ( rad_flow == 1 ) {
80 m_base->setFlow( IOLayerBase::Hardware ); 80 m_base->setFlow( IOLayerBase::Hardware );
81 } else if (rad_flow == 2) { 81 } else if (rad_flow == 2) {
82 m_base->setFlow( IOLayerBase::Software ); 82 m_base->setFlow( IOLayerBase::Software );
83 } else if (rad_flow == 0) { 83 } else if (rad_flow == 0) {
84 m_base->setFlow( IOLayerBase::None ); 84 m_base->setFlow( IOLayerBase::None );
85 } 85 }
86 86
87 87
88 if ( rad_parity == 1 ) { 88 if ( rad_parity == 1 ) {
89 m_base->setParity( IOLayerBase::Even ); 89 m_base->setParity( IOLayerBase::Even );
90 } else if ( rad_parity == 2 ){ 90 } else if ( rad_parity == 2 ){
91 m_base->setParity( IOLayerBase::Odd ); 91 m_base->setParity( IOLayerBase::Odd );
92 } else { 92 } else {
93 m_base->setParity( IOLayerBase::NonePar ); 93 m_base->setParity( IOLayerBase::NonePar );
94 } 94 }
95 95
96 switch( speed ) { 96 switch( speed ) {
97 case 115200: 97 case 115200:
98 m_base->setSpeed( IOLayerBase::Baud_115200 ); 98 m_base->setSpeed( IOLayerBase::Baud_115200 );
99 break; 99 break;
100 case 57600: 100 case 57600:
101 m_base->setSpeed( IOLayerBase::Baud_57600 ); 101 m_base->setSpeed( IOLayerBase::Baud_57600 );
102 break; 102 break;
103 case 38400: 103 case 38400:
104 m_base->setSpeed( IOLayerBase::Baud_38400 ); 104 m_base->setSpeed( IOLayerBase::Baud_38400 );
105 break; 105 break;
106 case 19200: 106 case 19200:
107 m_base->setSpeed( IOLayerBase::Baud_19200 ); 107 m_base->setSpeed( IOLayerBase::Baud_19200 );
108 break; 108 break;
109 case 9600: 109 case 9600:
110 default: 110 default:
111 m_base->setSpeed( IOLayerBase::Baud_9600 ); 111 m_base->setSpeed( IOLayerBase::Baud_9600 );
112 break; 112 break;
113 } 113 }
114 114
115 115
116 if ( dbits == 5) { 116 if ( dbits == 5) {
117 m_base->setData( IOLayerBase::Data_Five ); 117 m_base->setData( IOLayerBase::Data_Five );
118 } else if (rad_flow == 6) { 118 } else if (rad_flow == 6) {
119 m_base->setData( IOLayerBase::Data_Six ); 119 m_base->setData( IOLayerBase::Data_Six );
120 } else if (rad_flow == 7) { 120 } else if (rad_flow == 7) {
121 m_base->setData( IOLayerBase::Data_Seven ); 121 m_base->setData( IOLayerBase::Data_Seven );
122 } else { 122 } else {
123 m_base->setData( IOLayerBase::Data_Eight ); 123 m_base->setData( IOLayerBase::Data_Eight );
124 } 124 }
125 125
126 if ( sbits == 2) { 126 if ( sbits == 2) {
127 m_base->setStop( IOLayerBase::Stop_Two ); 127 m_base->setStop( IOLayerBase::Stop_Two );
128 } else if ( sbits == 15 ) { 128 } else if ( sbits == 15 ) {
129 m_base->setStop( IOLayerBase::Stop_OnePointFive ); 129 m_base->setStop( IOLayerBase::Stop_OnePointFive );
130 } else { 130 } else {
131 m_base->setStop( IOLayerBase::Stop_One ); 131 m_base->setStop( IOLayerBase::Stop_One );
132 } 132 }
133 133
134 134
135 135 atConf->readConfig( prof );
136 if ( prof.readEntry( "Device" ).isEmpty() ) { 136 if ( prof.readEntry( "Device" ).isEmpty() ) {
137 qWarning("device empty!");
137 return; 138 return;
138 } 139 }
139 setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); 140 setCurrent( prof.readEntry( "Device" ), m_deviceCmb );
140 141
141 atConf->readConfig( prof ); 142
142} 143}
143 144
144/* 145/*
145 * save speed, 146 * save speed,
146 * flow, 147 * flow,
147 * parity 148 * parity
148 */ 149 */
149void ModemConfigWidget::save( Profile& prof ) { 150void ModemConfigWidget::save( Profile& prof ) {
150 int flow, parity, speed, data, stop; 151 int flow, parity, speed, data, stop;
151 flow = parity = speed = data = stop = 0; 152 flow = parity = speed = data = stop = 0;
152 prof.writeEntry( "Device", m_deviceCmb->currentText() ); 153 prof.writeEntry( "Device", m_deviceCmb->currentText() );
153 154
154 155
155 switch( m_base->flow() ) { 156 switch( m_base->flow() ) {
156 case IOLayerBase::None: 157 case IOLayerBase::None:
157 flow = 0; 158 flow = 0;
158 break; 159 break;
159 case IOLayerBase::Software: 160 case IOLayerBase::Software:
160 flow = 2; 161 flow = 2;
161 break; 162 break;
162 case IOLayerBase::Hardware: 163 case IOLayerBase::Hardware:
163 flow = 1; 164 flow = 1;
164 break; 165 break;
165 } 166 }
166 167
167 switch( m_base->parity() ) { 168 switch( m_base->parity() ) {
168 case IOLayerBase::Odd: 169 case IOLayerBase::Odd:
169 parity = 2; 170 parity = 2;
170 break; 171 break;
171 case IOLayerBase::Even: 172 case IOLayerBase::Even:
172 parity = 1; 173 parity = 1;
173 break; 174 break;
174 case IOLayerBase::NonePar: 175 case IOLayerBase::NonePar:
175 parity = 0; 176 parity = 0;
176 break; 177 break;
177 } 178 }
178 179
179 switch( m_base->speed() ) { 180 switch( m_base->speed() ) {
180 case IOLayerBase::Baud_115200: 181 case IOLayerBase::Baud_115200:
181 speed = 115200; 182 speed = 115200;
182 break; 183 break;
183 case IOLayerBase::Baud_57600: 184 case IOLayerBase::Baud_57600:
184 speed = 57600; 185 speed = 57600;
185 break; 186 break;
186 case IOLayerBase::Baud_38400: 187 case IOLayerBase::Baud_38400:
187 speed = 38400; 188 speed = 38400;
188 break; 189 break;
189 case IOLayerBase::Baud_19200: 190 case IOLayerBase::Baud_19200:
190 speed = 19200; 191 speed = 19200;
191 break; 192 break;
192 case IOLayerBase::Baud_9600: 193 case IOLayerBase::Baud_9600:
193 speed = 9600; 194 speed = 9600;
194 break; 195 break;
195 } 196 }
196 197
197 switch( m_base->data() ) { 198 switch( m_base->data() ) {
198 case IOLayerBase::Data_Five: 199 case IOLayerBase::Data_Five:
199 data = 5; 200 data = 5;
200 break; 201 break;
201 case IOLayerBase::Data_Six: 202 case IOLayerBase::Data_Six:
202 data = 6; 203 data = 6;
203 break; 204 break;
204 case IOLayerBase::Data_Seven: 205 case IOLayerBase::Data_Seven:
205 data = 7; 206 data = 7;
206 break; 207 break;
207 case IOLayerBase::Data_Eight: 208 case IOLayerBase::Data_Eight:
208 data = 8; 209 data = 8;
209 break; 210 break;
210 } 211 }
211 212
212 switch( m_base->stop() ) { 213 switch( m_base->stop() ) {
213 case IOLayerBase::Stop_One: 214 case IOLayerBase::Stop_One:
214 stop = 1; 215 stop = 1;
215 break; 216 break;
216 case IOLayerBase::Stop_OnePointFive: 217 case IOLayerBase::Stop_OnePointFive:
217 stop = 15; 218 stop = 15;
218 break; 219 break;
219 case IOLayerBase::Stop_Two: 220 case IOLayerBase::Stop_Two:
220 stop = 2; 221 stop = 2;
221 break; 222 break;
222 } 223 }
223 224
224 prof.writeEntry( "Flow", flow ); 225 prof.writeEntry( "Flow", flow );
225 prof.writeEntry( "Parity", parity ); 226 prof.writeEntry( "Parity", parity );
226 prof.writeEntry( "Speed", speed ); 227 prof.writeEntry( "Speed", speed );
227 prof.writeEntry("DataBits", data); 228 prof.writeEntry("DataBits", data);
228 prof.writeEntry("StopBits", stop); 229 prof.writeEntry("StopBits", stop);
229 prof.writeEntry( "Number", m_telNumber->text() ); 230 prof.writeEntry( "Number", m_telNumber->text() );
230 231
231 232
232 atConf->writeConfig(prof); 233 atConf->writeConfig(prof);
233} 234}
234 235
235void ModemConfigWidget::slotAT() { 236void ModemConfigWidget::slotAT() {
236 // ATConfigDialog conf( this, "ATConfig", true ); 237 // ATConfigDialog conf( this, "ATConfig", true );
238 // josef/Max I know why don't you create the stuff on the stack
239 // but making it a TopLevel Dialog and ignoring
240 // cancel is not fun either...
241 // what to do? FIXME!!! -zecke
237 atConf->showMaximized(); 242 atConf->showMaximized();
238 if ( atConf->exec() != QDialog::Accepted ) { 243 if ( atConf->exec() != QDialog::Accepted ) {
239 // reload old settings 244 // reload old settings
240 } 245 }
241} 246}
242 247
243void ModemConfigWidget::slotDial() { 248void ModemConfigWidget::slotDial() {
244 DialDialog dial( this, "DialConfig", true ); 249 DialDialog dial( this, "DialConfig", true );
245 if(!m_telNumber->text().isEmpty()) { 250 if(!m_telNumber->text().isEmpty()) {
246 dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ \\.\\,]"), "")); 251 dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ \\.\\,]"), ""));
247 } 252 }
248 dial.showMaximized(); 253 dial.showMaximized();
249 if ( dial.exec() == QDialog::Accepted ) { 254 if ( dial.exec() == QDialog::Accepted ) {
250 m_telNumber->setText( dial.number() ); 255 m_telNumber->setText( dial.number() );
251 } 256 }
252} 257}
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index 36daaef..fd04b6b 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -1,239 +1,239 @@
1#include <qlayout.h> 1#include <qlayout.h>
2#include <qlineedit.h> 2#include <qlineedit.h>
3#include <qlabel.h> 3#include <qlabel.h>
4#include <qmessagebox.h> 4#include <qmessagebox.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6#include <qcombobox.h> 6#include <qcombobox.h>
7#include <qcheckbox.h> 7#include <qcheckbox.h>
8#include <qscrollview.h> 8#include <qscrollview.h>
9 9
10#include "metafactory.h" 10#include "metafactory.h"
11#include "profileeditordialog.h" 11#include "profileeditordialog.h"
12 12
13namespace { 13namespace {
14 void setCurrent( const QString& str, QComboBox* bo ) { 14 void setCurrent( const QString& str, QComboBox* bo ) {
15 for (int i = 0; i < bo->count(); i++ ) { 15 for (int 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 } 18 }
19 } 19 }
20 }; 20 };
21} 21}
22 22
23ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, 23ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact,
24 const Profile& prof ) 24 const Profile& prof )
25 : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) 25 : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof )
26{ 26{
27 initUI(); 27 initUI();
28 28
29 // Apply current profile 29 // Apply current profile
30 // plugin_plugin->load(profile); 30 // plugin_plugin->load(profile);
31 // ... (reset profile name line edit etc.) 31 // ... (reset profile name line edit etc.)
32} 32}
33 33
34ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) 34ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
35 : QDialog(0, 0, TRUE), m_fact( fact ) 35 : QDialog(0, 0, TRUE), m_fact( fact )
36{ 36{
37 // Default profile 37 // Default profile
38 m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102); 38 m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102);
39 39
40 initUI(); 40 initUI();
41 41
42 // Apply current profile 42 // Apply current profile
43 // plugin_plugin->load(profile); 43 // plugin_plugin->load(profile);
44} 44}
45 45
46Profile ProfileEditorDialog::profile() const 46Profile ProfileEditorDialog::profile() const
47{ 47{
48 return m_prof; 48 return m_prof;
49} 49}
50 50
51void ProfileEditorDialog::initUI() 51void ProfileEditorDialog::initUI()
52{ 52{
53 m_con = m_term = m_key = 0l; 53 m_con = m_term = m_key = 0l;
54 54
55 55
56 QVBoxLayout *mainLayout = new QVBoxLayout( this ); 56 QVBoxLayout *mainLayout = new QVBoxLayout( this );
57 tabWidget = new OTabWidget( this ); 57 tabWidget = new OTabWidget( this );
58 tabWidget->setTabStyle(OTabWidget::TextTab); 58 tabWidget->setTabStyle(OTabWidget::TextTab);
59 mainLayout->add(tabWidget); 59 mainLayout->add(tabWidget);
60 60
61 /* base tabs */ 61 /* base tabs */
62 tabprof = new QWidget(this); 62 tabprof = new QWidget(this);
63 m_tabTerm = new QWidget(this); 63 m_tabTerm = new QWidget(this);
64 m_tabCon = new QWidget(this); 64 m_tabCon = new QWidget(this);
65 m_tabKey = new QWidget(this); 65 m_tabKey = new QWidget(this);
66 66
67 m_svCon = new QScrollView( m_tabCon ); 67 m_svCon = new QScrollView( m_tabCon );
68 m_svCon->setResizePolicy( QScrollView::AutoOneFit ); 68 m_svCon->setResizePolicy( QScrollView::AutoOneFit );
69 m_svCon->setHScrollBarMode( QScrollView::AlwaysOff ); 69 //m_svCon->setHScrollBarMode( QScrollView::AlwaysOff );
70 m_svCon->setFrameShape( QFrame::NoFrame ); 70 m_svCon->setFrameShape( QFrame::NoFrame );
71 m_svTerm = new QScrollView( m_tabTerm ); 71 m_svTerm = new QScrollView( m_tabTerm );
72 m_svTerm->setResizePolicy( QScrollView::AutoOneFit ); 72 m_svTerm->setResizePolicy( QScrollView::AutoOneFit );
73 m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff ); 73 //m_svTerm->setHScrollBarMode( QScrollView::AlwaysOff );
74 m_svTerm->setFrameShape( QFrame::NoFrame ); 74 m_svTerm->setFrameShape( QFrame::NoFrame );
75 75
76 /* base layout for tabs */ 76 /* base layout for tabs */
77 m_layCon = new QHBoxLayout( m_tabCon , 2 ); 77 m_layCon = new QHBoxLayout( m_tabCon , 2 );
78 m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); 78 m_layTerm = new QHBoxLayout( m_tabTerm, 2 );
79 m_layKey = new QHBoxLayout( m_tabKey, 2 ); 79 m_layKey = new QHBoxLayout( m_tabKey, 2 );
80 80
81 m_layCon->addWidget( m_svCon ); 81 m_layCon->addWidget( m_svCon );
82 m_layTerm->addWidget( m_svTerm ); 82 m_layTerm->addWidget( m_svTerm );
83 83
84 // profile tab 84 // profile tab
85 85
86 QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); 86 QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
87 m_name = new QLineEdit(tabprof); 87 m_name = new QLineEdit(tabprof);
88 QLabel *con = new QLabel(tr("Connection"), tabprof ); 88 QLabel *con = new QLabel(tr("Connection"), tabprof );
89 QLabel *term = new QLabel(tr("Terminal"), tabprof ); 89 QLabel *term = new QLabel(tr("Terminal"), tabprof );
90 m_conCmb = new QComboBox( tabprof ); 90 m_conCmb = new QComboBox( tabprof );
91 m_termCmb = new QComboBox( tabprof ); 91 m_termCmb = new QComboBox( tabprof );
92 m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof); 92 m_autoConnect = new QCheckBox(tr("Auto connect after load"), tabprof);
93 93
94 // layouting 94 // layouting
95 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); 95 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
96 vbox3->add(name); 96 vbox3->add(name);
97 vbox3->add(m_name); 97 vbox3->add(m_name);
98 vbox3->add(con ); 98 vbox3->add(con );
99 vbox3->add(m_conCmb ); 99 vbox3->add(m_conCmb );
100 vbox3->add(term ); 100 vbox3->add(term );
101 vbox3->add(m_termCmb ); 101 vbox3->add(m_termCmb );
102 vbox3->add(m_autoConnect); 102 vbox3->add(m_autoConnect);
103 vbox3->addStretch(1); 103 vbox3->addStretch(1);
104 104
105 m_showconntab = 0; 105 m_showconntab = 0;
106 tabWidget->addTab(tabprof, "", QObject::tr("Profile")); 106 tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
107 tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); 107 tabWidget->addTab(m_tabCon, "", QObject::tr("Connection"));
108 tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); 108 tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal"));
109 tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys")); 109 tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys"));
110 tabWidget->setCurrentTab( tabprof ); 110 tabWidget->setCurrentTab( tabprof );
111 111
112 112
113 // fill the comboboxes 113 // fill the comboboxes
114 QStringList list = m_fact->connectionWidgets(); 114 QStringList list = m_fact->connectionWidgets();
115 QStringList::Iterator it; 115 QStringList::Iterator it;
116 for (it =list.begin(); it != list.end(); ++it ) { 116 for (it =list.begin(); it != list.end(); ++it ) {
117 m_conCmb->insertItem( (*it) ); 117 m_conCmb->insertItem( (*it) );
118 } 118 }
119 list = m_fact->terminalWidgets(); 119 list = m_fact->terminalWidgets();
120 for (it =list.begin(); it != list.end(); ++it ) { 120 for (it =list.begin(); it != list.end(); ++it ) {
121 m_termCmb->insertItem( (*it) ); 121 m_termCmb->insertItem( (*it) );
122 } 122 }
123 123
124 // load profile values 124 // load profile values
125 m_name->setText(m_prof.name()); 125 m_name->setText(m_prof.name());
126 slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); 126 slotConActivated( m_fact->external(m_prof.ioLayerName() ) );
127 slotTermActivated( m_fact->external(m_prof.terminalName() ) ); 127 slotTermActivated( m_fact->external(m_prof.terminalName() ) );
128 slotKeyActivated( "Default Keyboard" ); 128 slotKeyActivated( "Default Keyboard" );
129 setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); 129 setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb );
130 setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); 130 setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb );
131 m_autoConnect->setChecked(m_prof.autoConnect()); 131 m_autoConnect->setChecked(m_prof.autoConnect());
132 132
133 133
134 // signal and slots 134 // signal and slots
135 connect(m_conCmb, SIGNAL(activated(const QString& ) ), 135 connect(m_conCmb, SIGNAL(activated(const QString& ) ),
136 this, SLOT(slotConActivated(const QString&) ) ); 136 this, SLOT(slotConActivated(const QString&) ) );
137 connect(m_termCmb, SIGNAL(activated(const QString& ) ), 137 connect(m_termCmb, SIGNAL(activated(const QString& ) ),
138 this, SLOT(slotTermActivated(const QString& ) ) ); 138 this, SLOT(slotTermActivated(const QString& ) ) );
139 139
140} 140}
141 141
142ProfileEditorDialog::~ProfileEditorDialog() { 142ProfileEditorDialog::~ProfileEditorDialog() {
143 143
144} 144}
145void ProfileEditorDialog::accept() 145void ProfileEditorDialog::accept()
146{ 146{
147 if(profName().isEmpty()) 147 if(profName().isEmpty())
148 { 148 {
149 QMessageBox::information(this, 149 QMessageBox::information(this,
150 QObject::tr("Invalid profile"), 150 QObject::tr("Invalid profile"),
151 QObject::tr("Please enter a profile name.")); 151 QObject::tr("Please enter a profile name."));
152 return; 152 return;
153 } 153 }
154 // Save profile and plugin profile 154 // Save profile and plugin profile
155 //if(plugin_plugin) plugin_plugin->save(); 155 //if(plugin_plugin) plugin_plugin->save();
156 156
157 // Save general values 157 // Save general values
158 m_prof.setName( profName() ); 158 m_prof.setName( profName() );
159 m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); 159 m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) );
160 m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); 160 m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) );
161 m_prof.setAutoConnect( m_autoConnect->isChecked() ); 161 m_prof.setAutoConnect( m_autoConnect->isChecked() );
162 162
163 if (m_con ) 163 if (m_con )
164 m_con->save( m_prof ); 164 m_con->save( m_prof );
165 if (m_term ) 165 if (m_term )
166 m_term->save( m_prof ); 166 m_term->save( m_prof );
167 if (m_key) 167 if (m_key)
168 m_key->save( m_prof ); 168 m_key->save( m_prof );
169 169
170 QDialog::accept(); 170 QDialog::accept();
171} 171}
172 172
173 173
174QString ProfileEditorDialog::profName()const 174QString ProfileEditorDialog::profName()const
175{ 175{
176 return m_name->text(); 176 return m_name->text();
177} 177}
178 178
179QCString ProfileEditorDialog::profType()const 179QCString ProfileEditorDialog::profType()const
180{ 180{
181 /*QStringList w = m_fact->configWidgets(); 181 /*QStringList w = m_fact->configWidgets();
182 for(QStringList::Iterator it = w.begin(); it != w.end(); it++) 182 for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
183 if(device_box->currentText() == m_fact->name((*it))) return (*it); 183 if(device_box->currentText() == m_fact->name((*it))) return (*it);
184 */ 184 */
185 return QCString(); 185 return QCString();
186} 186}
187/* 187/*
188 * we need to switch the widget 188 * we need to switch the widget
189 */ 189 */
190void ProfileEditorDialog::slotConActivated( const QString& str ) { 190void ProfileEditorDialog::slotConActivated( const QString& str ) {
191 191
192 delete m_con; 192 delete m_con;
193 193
194 m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() ); 194 m_con = m_fact->newConnectionPlugin( str, m_svCon->viewport() );
195 195
196 if ( !m_con ) { 196 if ( !m_con ) {
197 m_con = new NoOptions( str, m_svCon->viewport(), "name"); 197 m_con = new NoOptions( str, m_svCon->viewport(), "name");
198 } 198 }
199 199
200 // FIXME ugly hack right. Right solution would be to look into the layer and see if it 200 // FIXME ugly hack right. Right solution would be to look into the layer and see if it
201 // supports auto connect and then set it as prefered 201 // supports auto connect and then set it as prefered
202 //if ( ( )->layer()->supports()[0] == 1 ) { 202 //if ( ( )->layer()->supports()[0] == 1 ) {
203 if ( m_conCmb ->currentText() == tr("local Console") ) { 203 if ( m_conCmb ->currentText() == tr("local Console") ) {
204 m_autoConnect->setChecked( true ); 204 m_autoConnect->setChecked( true );
205 } else { 205 } else {
206 m_autoConnect->setChecked( false ); 206 m_autoConnect->setChecked( false );
207 } 207 }
208 208
209 m_con->load( m_prof ); 209 m_con->load( m_prof );
210 m_svCon->addChild( m_con ); 210 m_svCon->addChild( m_con );
211} 211}
212 212
213 213
214/* 214/*
215 * we need to switch the widget 215 * we need to switch the widget
216 */ 216 */
217void ProfileEditorDialog::slotTermActivated( const QString& str ) { 217void ProfileEditorDialog::slotTermActivated( const QString& str ) {
218 218
219 delete m_term; 219 delete m_term;
220 220
221 m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() ); 221 m_term = m_fact->newTerminalPlugin( str, m_svTerm->viewport() );
222 222
223 if (m_term) { 223 if (m_term) {
224 m_term->load( m_prof ); 224 m_term->load( m_prof );
225 m_svTerm->addChild( m_term ); 225 m_svTerm->addChild( m_term );
226 } 226 }
227} 227}
228 228
229void ProfileEditorDialog::slotKeyActivated(const QString &str) { 229void ProfileEditorDialog::slotKeyActivated(const QString &str) {
230 delete m_key; 230 delete m_key;
231 m_key = m_fact->newKeyboardPlugin( str, m_tabKey ); 231 m_key = m_fact->newKeyboardPlugin( str, m_tabKey );
232 232
233 if (m_key) { 233 if (m_key) {
234 234
235 m_key->load(m_prof); 235 m_key->load(m_prof);
236 m_layKey->addWidget(m_key); 236 m_layKey->addWidget(m_key);
237 } 237 }
238 238
239} 239}