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
@@ -148,16 +148,17 @@ QWidget* ATConfigDialog::tab1( QWidget* parent ) {
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 ) );
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
@@ -15,16 +15,17 @@
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 );
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
@@ -8,16 +8,18 @@
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 ^ |
@@ -48,24 +50,20 @@
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);
@@ -84,17 +82,17 @@ Dialer::Dialer(const Profile& profile, int fd, QWidget *parent, const char *name
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();
@@ -137,29 +135,25 @@ void Dialer::dial(const QString& number)
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);
@@ -182,18 +176,20 @@ void Dialer::trydial(const QString& number)
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,
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
@@ -89,17 +89,23 @@ signals:
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
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
@@ -8,17 +8,17 @@
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"
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
@@ -161,21 +161,17 @@ void IOSerial::errorOccured() {
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
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
@@ -127,23 +127,24 @@ void ModemConfigWidget::load( const Profile& prof ) {
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 ) {
@@ -229,16 +230,20 @@ void ModemConfigWidget::save( Profile& prof ) {
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 );
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
@@ -61,21 +61,21 @@ void ProfileEditorDialog::initUI()
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 );