summaryrefslogtreecommitdiff
authorwazlaf <wazlaf>2002-09-28 15:21:53 (UTC)
committer wazlaf <wazlaf>2002-09-28 15:21:53 (UTC)
commit18d575d0ee47a0700091de81bc3e8c54be4eae18 (patch) (unidiff)
treea4a890a3d9e823ed75ba0b5a51a67b6e47a57ab9
parentea1975bdf411de3e08e7b84d2480a522596fe143 (diff)
downloadopie-18d575d0ee47a0700091de81bc3e8c54be4eae18.zip
opie-18d575d0ee47a0700091de81bc3e8c54be4eae18.tar.gz
opie-18d575d0ee47a0700091de81bc3e8c54be4eae18.tar.bz2
indenting, comments
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/io_serial.cpp4
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp10
-rw-r--r--noncore/apps/opie-console/mainwindow.h5
-rw-r--r--noncore/apps/opie-console/metafactory.h9
4 files changed, 16 insertions, 12 deletions
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp
index 9a81de9..c9155d1 100644
--- a/noncore/apps/opie-console/io_serial.cpp
+++ b/noncore/apps/opie-console/io_serial.cpp
@@ -73,91 +73,95 @@ bool IOSerial::open() {
73 tty.c_cflag |= CLOCAL | CREAD; 73 tty.c_cflag |= CLOCAL | CREAD;
74 74
75 /* Stop bits */ 75 /* Stop bits */
76 if (m_sbits == 2) { 76 if (m_sbits == 2) {
77 tty.c_cflag |= CSTOPB; 77 tty.c_cflag |= CSTOPB;
78 } else { 78 } else {
79 tty.c_cflag &= ~CSTOPB; 79 tty.c_cflag &= ~CSTOPB;
80 } 80 }
81 81
82 tty.c_cc[VMIN] = 1; 82 tty.c_cc[VMIN] = 1;
83 tty.c_cc[VTIME] = 5; 83 tty.c_cc[VTIME] = 5;
84 84
85 /* Flow control */ 85 /* Flow control */
86 if (m_flow & FlowSW) 86 if (m_flow & FlowSW)
87 tty.c_iflag |= IXON | IXOFF; 87 tty.c_iflag |= IXON | IXOFF;
88 else 88 else
89 tty.c_iflag &= ~(IXON|IXOFF|IXANY); 89 tty.c_iflag &= ~(IXON|IXOFF|IXANY);
90 90
91 if (m_flow & FlowHW) 91 if (m_flow & FlowHW)
92 tty.c_cflag |= CRTSCTS; 92 tty.c_cflag |= CRTSCTS;
93 else 93 else
94 tty.c_cflag &= ~CRTSCTS; 94 tty.c_cflag &= ~CRTSCTS;
95 95
96 /* Parity */ 96 /* Parity */
97 tty.c_cflag &= ~(PARENB | PARODD); 97 tty.c_cflag &= ~(PARENB | PARODD);
98 if (m_parity & ParityEven) 98 if (m_parity & ParityEven)
99 tty.c_cflag |= PARENB; 99 tty.c_cflag |= PARENB;
100 else if (m_parity & ParityOdd) 100 else if (m_parity & ParityOdd)
101 tty.c_cflag |= (PARENB | PARODD); 101 tty.c_cflag |= (PARENB | PARODD);
102 102
103 /* Set the changes */ 103 /* Set the changes */
104 tcsetattr(m_fd, TCSANOW, &tty); 104 tcsetattr(m_fd, TCSANOW, &tty);
105 105
106 /* Notifications on read & errors */ 106 /* Notifications on read & errors */
107 m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); 107 m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
108 m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this); 108 m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this);
109 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); 109 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
110 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); 110 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
111 return TRUE; 111 return TRUE;
112 } else { 112 } else {
113 emit error(Refuse, tr("Device is already connected")); 113 emit error(Refuse, tr("Device is already connected"));
114 return FALSE; 114 return FALSE;
115 } 115 }
116} 116}
117 117
118void IOSerial::reload(const Config &config) { 118void IOSerial::reload(const Config &config) {
119 m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); 119 m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE);
120 m_baud = config.readNumEntry("Baud", SERIAL_DEFAULT_BAUD); 120 m_baud = config.readNumEntry("Baud", SERIAL_DEFAULT_BAUD);
121 m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY);
122 m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS);
123 m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS);
124 m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW);
121} 125}
122 126
123int IOSerial::getBaud(int baud) const { 127int IOSerial::getBaud(int baud) const {
124 switch (baud) { 128 switch (baud) {
125 case 300: return B300; break; 129 case 300: return B300; break;
126 case 600: return B600; break; 130 case 600: return B600; break;
127 case 1200: return B1200; break; 131 case 1200: return B1200; break;
128 case 2400: return B2400; break; 132 case 2400: return B2400; break;
129 case 4800: return B4800; break; 133 case 4800: return B4800; break;
130 case 9600: return B9600; break; 134 case 9600: return B9600; break;
131 case 19200: return B19200; break; 135 case 19200: return B19200; break;
132 case 38400: return B38400; break; 136 case 38400: return B38400; break;
133 case 57600: return B57600; break; 137 case 57600: return B57600; break;
134 case 115200: return B115200; break; 138 case 115200: return B115200; break;
135 } 139 }
136 return -1; 140 return -1;
137} 141}
138 142
139void IOSerial::errorOccured() { 143void IOSerial::errorOccured() {
140 emit error(ClosedUnexpected, strerror(errno)); 144 emit error(ClosedUnexpected, strerror(errno));
141 close(); 145 close();
142} 146}
143 147
144void IOSerial::dataArrived() { 148void IOSerial::dataArrived() {
145 QByteArray array; 149 QByteArray array;
146 char buf[4096]; 150 char buf[4096];
147 151
148 int len = read(m_fd, buf, 4096); 152 int len = read(m_fd, buf, 4096);
149 if (len == 0) 153 if (len == 0)
150 close(); 154 close();
151 if (len < 0) 155 if (len < 0)
152 return; 156 return;
153 array.setRawData(buf, len); 157 array.setRawData(buf, len);
154 emit received(array); 158 emit received(array);
155} 159}
156 160
157QString IOSerial::identifier() const { 161QString IOSerial::identifier() const {
158 return "serial"; 162 return "serial";
159} 163}
160 164
161QString IOSerial::name() const { 165QString IOSerial::name() const {
162 return "RS232 Serial IO Layer"; 166 return "RS232 Serial IO Layer";
163} 167}
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index b6b2a2e..e9b5eda 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,62 +1,62 @@
1 1
2#include <qaction.h> 2#include <qaction.h>
3#include <qmenubar.h> 3#include <qmenubar.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qpopupmenu.h> 5#include <qpopupmenu.h>
6#include <qtoolbar.h> 6#include <qtoolbar.h>
7 7
8#include "metafactory.h" 8#include "metafactory.h"
9#include "mainwindow.h" 9#include "mainwindow.h"
10 10
11MainWindow::MainWindow() 11MainWindow::MainWindow() {
12{
13 qWarning("c'tor");
14 m_factory = new MetaFactory(); 12 m_factory = new MetaFactory();
15 m_sessions.setAutoDelete( TRUE ); 13 m_sessions.setAutoDelete( TRUE );
16 m_curSession = 0l; 14 m_curSession = -1;
17 15
18 initUI(); 16 initUI();
19
20} 17}
21void MainWindow::initUI() { 18void MainWindow::initUI() {
22 setToolBarsMovable( FALSE ); 19 setToolBarsMovable( FALSE );
23 20
24 m_tool = new QToolBar( this ); 21 m_tool = new QToolBar( this );
25 m_tool->setHorizontalStretchable( TRUE ); 22 m_tool->setHorizontalStretchable( TRUE );
26 23
27 m_bar = new QMenuBar( m_tool ); 24 m_bar = new QMenuBar( m_tool );
28 m_console = new QPopupMenu( this ); 25 m_console = new QPopupMenu( this );
29 26
30 /* 27 /*
31 * new Action for new sessions 28 * new Action for new sessions
32 */ 29 */
33 QAction* a = new QAction(); 30 QAction* a = new QAction();
34 a->setText( tr("New Connection") ); 31 a->setText( tr("New Connection") );
35 a->addTo( m_console ); 32 a->addTo( m_console );
36 connect(a, SIGNAL(activated() ), 33 connect(a, SIGNAL(activated() ),
37 this, SLOT(slotNew() ) ); 34 this, SLOT(slotNew() ) );
38 35
39 a = new QAction(); 36 a = new QAction();
40 a->setText( tr("New from Session") ); 37 a->setText( tr("New from Session") );
41 38
42 m_connect = new QAction(); 39 m_connect = new QAction();
43 m_connect->setText( tr("Connect") ); 40 m_connect->setText( tr("Connect") );
44 m_connect->addTo( m_console ); 41 m_connect->addTo( m_console );
45 connect(m_connect, SIGNAL(activated() ), 42 connect(m_connect, SIGNAL(activated() ),
46 this, SLOT(slotConnect() ) ); 43 this, SLOT(slotConnect() ) );
47 44
48 m_bar->insertItem( tr("Connection"), m_console ); 45 m_bar->insertItem( tr("Connection"), m_console );
49 46
50} 47}
51MainWindow::~MainWindow() { 48MainWindow::~MainWindow() {
52 delete m_factory; 49 delete m_factory;
53} 50}
51
54MetaFactory* MainWindow::factory() { 52MetaFactory* MainWindow::factory() {
55 return m_factory; 53 return m_factory;
56} 54}
55
57Session* MainWindow::currentSession() { 56Session* MainWindow::currentSession() {
58 return m_curSession; 57 return m_curSession;
59} 58}
59
60QList<Session> MainWindow::sessions() { 60QList<Session> MainWindow::sessions() {
61 return m_sessions; 61 return m_sessions;
62} 62}
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h
index 3d1e1c8..db3a653 100644
--- a/noncore/apps/opie-console/mainwindow.h
+++ b/noncore/apps/opie-console/mainwindow.h
@@ -1,71 +1,74 @@
1#ifndef OPIE_MAIN_WINDOW_H 1#ifndef OPIE_MAIN_WINDOW_H
2#define OPIE_MAIN_WINDOW_H 2#define OPIE_MAIN_WINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qlist.h> 5#include <qlist.h>
6 6
7#include "session.h" 7#include "session.h"
8 8
9/** 9/**
10 * this is the MainWindow of the new opie console 10 * this is the MainWindow of the new opie console
11 * it's also the dispatcher between the different 11 * it's also the dispatcher between the different
12 * actions supported by the gui 12 * actions supported by the gui
13 */ 13 */
14class QToolBar; 14class QToolBar;
15class QMenuBar; 15class QMenuBar;
16class QAction; 16class QAction;
17class MetaFactory; 17class MetaFactory;
18
18class MainWindow : public QMainWindow { 19class MainWindow : public QMainWindow {
19 Q_OBJECT 20 Q_OBJECT
20public: 21public:
21 MainWindow( ); 22 MainWindow( );
22 ~MainWindow(); 23 ~MainWindow();
23 24
24 /** 25 /**
25 * our factory to generate IOLayer and so on 26 * our factory to generate IOLayer and so on
26 * 27 *
27 */ 28 */
28 MetaFactory* factory(); 29 MetaFactory* factory();
29 30
30 /** 31 /**
31 * A session contains a QWidget*, 32 * A session contains a QWidget*,
32 * an IOLayer* and some infos for us 33 * an IOLayer* and some infos for us
33 */ 34 */
34 Session* currentSession(); 35 Session* currentSession();
35 36
36 /** 37 /**
37 * the session list 38 * the session list
38 */ 39 */
39 QList<Session> sessions(); 40 QList<Session> sessions();
40 41protected slots:
42 void slotNew();
43 void slotConnect();
41private: 44private:
42 void initUI(); 45 void initUI();
43 /** 46 /**
44 * the current session 47 * the current session
45 */ 48 */
46 Session* m_curSession; 49 Session* m_curSession;
47 50
48 /** 51 /**
49 * the session list 52 * the session list
50 */ 53 */
51 QList<Session> m_sessions; 54 QList<Session> m_sessions;
52 55
53 /** 56 /**
54 * the metafactory 57 * the metafactory
55 */ 58 */
56 MetaFactory* m_factory; 59 MetaFactory* m_factory;
57 60
58 QToolBar* m_tool; 61 QToolBar* m_tool;
59 QMenuBar* m_bar; 62 QMenuBar* m_bar;
60 QPopupMenu* m_console; 63 QPopupMenu* m_console;
61 QPopupMenu* m_settings; 64 QPopupMenu* m_settings;
62 QPopupMenu* m_newsession; 65 QPopupMenu* m_newsession;
63 QAction* m_connect; 66 QAction* m_connect;
64 QAction* m_disconnect; 67 QAction* m_disconnect;
65 QAction* m_terminate; 68 QAction* m_terminate;
66 QAction* m_set; 69 QAction* m_set;
67 70
68}; 71};
69 72
70 73
71#endif 74#endif
diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h
index 9c0f0a1..aae9391 100644
--- a/noncore/apps/opie-console/metafactory.h
+++ b/noncore/apps/opie-console/metafactory.h
@@ -1,46 +1,43 @@
1#ifndef OPIE_META_FACTORY_H 1#ifndef OPIE_META_FACTORY_H
2#define OPIE_META_FACTORY_H 2#define OPIE_META_FACTORY_H
3 3
4/** 4/**
5 * meta factory is our factory servie 5 * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets
6 * and to instantiate these implementations on demand
6 */ 7 */
7 8
8#include <qwidget.h> 9#include <qwidget.h>
9#include <qmap.h> 10#include <qmap.h>
10 11
11#include <qpe/config.h> 12#include <qpe/config.h>
12 13
13#include "io_layer.h" 14#include "io_layer.h"
14#include "file_layer.h" 15#include "file_layer.h"
15 16
16 17
17class MetaFactory { 18class MetaFactory {
18public: 19public:
19 typedef QWidget* (*configWidget)(QWidget* parent); 20 typedef QWidget* (*configWidget)(QWidget* parent);
20 typedef IOLayer* (*iolayer)(const Config& ); 21 typedef IOLayer* (*iolayer)(const Config& );
21 typedef FileTransferLayer* (*filelayer)(IOLayer*); 22 typedef FileTransferLayer* (*filelayer)(IOLayer*);
23
22 MetaFactory(); 24 MetaFactory();
23 ~MetaFactory(); 25 ~MetaFactory();
24 26
25 void addConfigWidgetFactory( const QString&, 27 void addConfigWidgetFactory( const QString&,
26 configWidget ); 28 configWidget );
27 void addIOLayerFactory(const QString&, 29 void addIOLayerFactory(const QString&,
28 iolayer ); 30 iolayer );
29 void addFileTransferLayer( const QString&, 31 void addFileTransferLayer( const QString&,
30 filelayer ); 32 filelayer );
31 QStringList ioLayers()const; 33 QStringList ioLayers()const;
32 QStringList configWidgets()const; 34 QStringList configWidgets()const;
33 QStringList fileTransferLayers()const; 35 QStringList fileTransferLayers()const;
34
35
36private: 36private:
37 QMap<QString, configWidget> m_confFact; 37 QMap<QString, configWidget> m_confFact;
38 QMap<QString, iolayer> m_layerFact; 38 QMap<QString, iolayer> m_layerFact;
39 QMap<QString, filelayer> m_fileFact; 39 QMap<QString, filelayer> m_fileFact;
40
41
42
43}; 40};
44 41
45 42
46#endif 43#endif