-rw-r--r-- | noncore/apps/opie-console/MyPty.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/default.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_layer.h | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_serial.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/io_serial.h | 3 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-console/session.h | 2 |
8 files changed, 19 insertions, 15 deletions
diff --git a/noncore/apps/opie-console/MyPty.h b/noncore/apps/opie-console/MyPty.h index ad271df..81abad5 100644 --- a/noncore/apps/opie-console/MyPty.h +++ b/noncore/apps/opie-console/MyPty.h | |||
@@ -1,99 +1,99 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [MyPty.h] Pseudo Terminal Device */ | 3 | /* [MyPty.h] Pseudo Terminal Device */ |
4 | /* */ | 4 | /* */ |
5 | /* -------------------------------------------------------------------------- */ | 5 | /* -------------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole - an X terminal for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* */ | 10 | /* */ |
11 | /* -------------------------------------------------------------------------- */ | 11 | /* -------------------------------------------------------------------------- */ |
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | 18 | ||
19 | /*! \file | 19 | /*! \file |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef MY_PTY_H | 22 | #ifndef MY_PTY_H |
23 | #define MY_PTY_H | 23 | #define MY_PTY_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstrlist.h> | 26 | #include <qstrlist.h> |
27 | 27 | ||
28 | #include "io_layer.h" | 28 | #include "io_layer.h" |
29 | 29 | ||
30 | class Profile; | 30 | class Profile; |
31 | class QSocketNotifier; | 31 | class QSocketNotifier; |
32 | class MyPty : public IOLayer | 32 | class MyPty : public IOLayer |
33 | { | 33 | { |
34 | Q_OBJECT | 34 | Q_OBJECT |
35 | public: | 35 | public: |
36 | 36 | ||
37 | MyPty(const Profile&); | 37 | MyPty(const Profile&); |
38 | ~MyPty(); | 38 | ~MyPty(); |
39 | 39 | ||
40 | 40 | ||
41 | 41 | ||
42 | QString identifier()const; | 42 | QString identifier()const; |
43 | QString name()const; | 43 | QString name()const; |
44 | QBitArray supports()const; | 44 | QBitArray supports()const; |
45 | 45 | ||
46 | public slots: | 46 | public slots: |
47 | /*! | 47 | /*! |
48 | having a `run' separate from the constructor allows to make | 48 | having a `run' separate from the constructor allows to make |
49 | the necessary connections to the signals and slots of the | 49 | the necessary connections to the signals and slots of the |
50 | instance before starting the execution of the client. | 50 | instance before starting the execution of the client. |
51 | */ | 51 | */ |
52 | void start(); | 52 | void start(); |
53 | int run(const char* pgm, QStrList & args , const char* term, int addutmp); | 53 | int run(const char* pgm, QStrList & args , const char* term, int addutmp); |
54 | bool open(); | 54 | bool open(); |
55 | void close(); | 55 | void close(); |
56 | void reload( const Profile& ); | 56 | void reload( const Profile& ); |
57 | void setSize(int lines, int columns); | 57 | void setSize(int lines, int columns); |
58 | void error(); | 58 | void error(); |
59 | 59 | bool isConnected() { return true; }; | |
60 | signals: | 60 | signals: |
61 | 61 | ||
62 | /*! | 62 | /*! |
63 | emitted when the client program terminates. | 63 | emitted when the client program terminates. |
64 | \param status the wait(2) status code of the terminated client program. | 64 | \param status the wait(2) status code of the terminated client program. |
65 | */ | 65 | */ |
66 | void done(int status); | 66 | void done(int status); |
67 | 67 | ||
68 | /*! | 68 | /*! |
69 | emitted when a new block of data comes in. | 69 | emitted when a new block of data comes in. |
70 | \param s - the data | 70 | \param s - the data |
71 | \param len - the length of the block | 71 | \param len - the length of the block |
72 | */ | 72 | */ |
73 | void received(const QByteArray&); | 73 | void received(const QByteArray&); |
74 | 74 | ||
75 | public slots: | 75 | public slots: |
76 | 76 | ||
77 | void send(const QByteArray& ); | 77 | void send(const QByteArray& ); |
78 | 78 | ||
79 | private: | 79 | private: |
80 | const char* deviceName(); | 80 | const char* deviceName(); |
81 | 81 | ||
82 | protected slots: | 82 | protected slots: |
83 | void readPty(); | 83 | void readPty(); |
84 | void donePty(); | 84 | void donePty(); |
85 | 85 | ||
86 | private: | 86 | private: |
87 | int openPty(); | 87 | int openPty(); |
88 | 88 | ||
89 | private: | 89 | private: |
90 | 90 | ||
91 | char m_ptynam[16]; // "/dev/ptyxx" | "/dev/ptmx" | 91 | char m_ptynam[16]; // "/dev/ptyxx" | "/dev/ptmx" |
92 | char m_ttynam[16]; // "/dev/ttyxx" | "/dev/pts/########..." | 92 | char m_ttynam[16]; // "/dev/ttyxx" | "/dev/pts/########..." |
93 | int m_fd; | 93 | int m_fd; |
94 | int m_cpid; | 94 | int m_cpid; |
95 | QSocketNotifier* m_sn_e; | 95 | QSocketNotifier* m_sn_e; |
96 | QSocketNotifier* m_sn_r; | 96 | QSocketNotifier* m_sn_r; |
97 | }; | 97 | }; |
98 | 98 | ||
99 | #endif | 99 | #endif |
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp index 64c9542..8b905e1 100644 --- a/noncore/apps/opie-console/default.cpp +++ b/noncore/apps/opie-console/default.cpp | |||
@@ -1,113 +1,113 @@ | |||
1 | #include "io_serial.h" | 1 | #include "io_serial.h" |
2 | #include "io_irda.h" | 2 | #include "io_irda.h" |
3 | #include "io_bt.h" | 3 | #include "io_bt.h" |
4 | #include "io_modem.h" | 4 | #include "io_modem.h" |
5 | #include "filetransfer.h" | 5 | #include "filetransfer.h" |
6 | #include "filereceive.h" | 6 | #include "filereceive.h" |
7 | #include "serialconfigwidget.h" | 7 | #include "serialconfigwidget.h" |
8 | #include "irdaconfigwidget.h" | 8 | #include "irdaconfigwidget.h" |
9 | #include "btconfigwidget.h" | 9 | #include "btconfigwidget.h" |
10 | #include "modemconfigwidget.h" | 10 | #include "modemconfigwidget.h" |
11 | #include "terminalwidget.h" | 11 | #include "terminalwidget.h" |
12 | #include "MyPty.h" | 12 | #include "MyPty.h" |
13 | 13 | ||
14 | #include "default.h" | 14 | #include "default.h" |
15 | 15 | ||
16 | extern "C" { | 16 | extern "C" { |
17 | // FILE Transfer Stuff | 17 | // FILE Transfer Stuff |
18 | FileTransferLayer* newSZTransfer(IOLayer* lay) { | 18 | FileTransferLayer* newSZTransfer(IOLayer* lay) { |
19 | return new FileTransfer( FileTransfer::SZ, lay ); | 19 | return new FileTransfer( FileTransfer::SZ, lay ); |
20 | } | 20 | } |
21 | FileTransferLayer* newSYTransfer(IOLayer* lay) { | 21 | FileTransferLayer* newSYTransfer(IOLayer* lay) { |
22 | return new FileTransfer( FileTransfer::SY, lay ); | 22 | return new FileTransfer( FileTransfer::SY, lay ); |
23 | } | 23 | } |
24 | FileTransferLayer* newSXTransfer(IOLayer* lay) { | 24 | FileTransferLayer* newSXTransfer(IOLayer* lay) { |
25 | return new FileTransfer(FileTransfer ::SX, lay ); | 25 | return new FileTransfer(FileTransfer ::SX, lay ); |
26 | } | 26 | } |
27 | 27 | ||
28 | // FILE Transfer Receive Stuff | 28 | // FILE Transfer Receive Stuff |
29 | ReceiveLayer* newSZReceive(IOLayer* lay) { | 29 | ReceiveLayer* newSZReceive(IOLayer* lay) { |
30 | return new FileReceive( FileReceive::SZ, lay ); | 30 | return new FileReceive( FileReceive::SZ, lay ); |
31 | } | 31 | } |
32 | ReceiveLayer* newSYReceive(IOLayer* lay) { | 32 | ReceiveLayer* newSYReceive(IOLayer* lay) { |
33 | return new FileReceive( FileReceive::SY, lay ); | 33 | return new FileReceive( FileReceive::SY, lay ); |
34 | } | 34 | } |
35 | ReceiveLayer* newSXReceive(IOLayer* lay) { | 35 | ReceiveLayer* newSXReceive(IOLayer* lay) { |
36 | return new FileReceive(FileReceive::SX, lay ); | 36 | return new FileReceive(FileReceive::SX, lay ); |
37 | } | 37 | } |
38 | 38 | ||
39 | // Layer stuff | 39 | // Layer stuff |
40 | IOLayer* newSerialLayer( const Profile& prof) { | 40 | IOLayer* newSerialLayer( const Profile& prof) { |
41 | return new IOSerial( prof ); | 41 | return new IOSerial( prof ); |
42 | } | 42 | } |
43 | IOLayer* newBTLayer( const Profile& prof ) { | 43 | IOLayer* newBTLayer( const Profile& prof ) { |
44 | return new IOBt( prof ); | 44 | return new IOBt( prof ); |
45 | } | 45 | } |
46 | IOLayer* newIrDaLayer( const Profile& prof ) { | 46 | IOLayer* newIrDaLayer( const Profile& prof ) { |
47 | return new IOIrda( prof ); | 47 | return new IOIrda( prof ); |
48 | } | 48 | } |
49 | IOLayer* newModemLayer( const Profile& prof ) { | 49 | IOLayer* newModemLayer( const Profile& prof ) { |
50 | return new IOModem( prof ); | 50 | return new IOModem( prof ); |
51 | } | 51 | } |
52 | IOLayer* newConsole( const Profile& prof ) { | 52 | IOLayer* newConsole( const Profile& prof ) { |
53 | return new MyPty(prof ); | 53 | return new MyPty( prof ); |
54 | } | 54 | } |
55 | 55 | ||
56 | // Connection Widgets | 56 | // Connection Widgets |
57 | ProfileDialogWidget* newSerialWidget( const QString& str, QWidget* wid ) { | 57 | ProfileDialogWidget* newSerialWidget( const QString& str, QWidget* wid ) { |
58 | return new SerialConfigWidget( str, wid ); | 58 | return new SerialConfigWidget( str, wid ); |
59 | } | 59 | } |
60 | ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid ) { | 60 | ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid ) { |
61 | return new IrdaConfigWidget( str, wid ); | 61 | return new IrdaConfigWidget( str, wid ); |
62 | } | 62 | } |
63 | ProfileDialogWidget* newModemWidget( const QString& str, QWidget* wid ) { | 63 | ProfileDialogWidget* newModemWidget( const QString& str, QWidget* wid ) { |
64 | return new ModemConfigWidget(str, wid ); | 64 | return new ModemConfigWidget(str, wid ); |
65 | } | 65 | } |
66 | ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid ) { | 66 | ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid ) { |
67 | return new BTConfigWidget(str, wid ); | 67 | return new BTConfigWidget(str, wid ); |
68 | } | 68 | } |
69 | ProfileDialogWidget* newConsoleWid( const QString& str, QWidget* wid ) { | 69 | ProfileDialogWidget* newConsoleWid( const QString& str, QWidget* wid ) { |
70 | return 0l; | 70 | return 0l; |
71 | } | 71 | } |
72 | 72 | ||
73 | 73 | ||
74 | // Terminal Widget(s) | 74 | // Terminal Widget(s) |
75 | ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) { | 75 | ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) { |
76 | return new TerminalWidget(na, wid,0 ); | 76 | return new TerminalWidget(na, wid,0 ); |
77 | } | 77 | } |
78 | 78 | ||
79 | /* // VT Emulations | 79 | /* // VT Emulations |
80 | EmulationLayer* newVT102( WidgetLayer* wid ) { | 80 | EmulationLayer* newVT102( WidgetLayer* wid ) { |
81 | return new Vt102Emulation( wid ); | 81 | return new Vt102Emulation( wid ); |
82 | } | 82 | } |
83 | */ | 83 | */ |
84 | }; | 84 | }; |
85 | 85 | ||
86 | Default::Default( MetaFactory* fact ) { | 86 | Default::Default( MetaFactory* fact ) { |
87 | fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer ); | 87 | fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer ); |
88 | fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer ); | 88 | fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer ); |
89 | fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer ); | 89 | fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer ); |
90 | 90 | ||
91 | fact->addReceiveLayer( "SZ", QObject::tr("Z-Modem"), newSZReceive ); | 91 | fact->addReceiveLayer( "SZ", QObject::tr("Z-Modem"), newSZReceive ); |
92 | fact->addReceiveLayer( "SY", QObject::tr("Y-Modem"), newSYReceive ); | 92 | fact->addReceiveLayer( "SY", QObject::tr("Y-Modem"), newSYReceive ); |
93 | fact->addReceiveLayer( "SX", QObject::tr("X-Modem"), newSXReceive ); | 93 | fact->addReceiveLayer( "SX", QObject::tr("X-Modem"), newSXReceive ); |
94 | 94 | ||
95 | fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer ); | 95 | fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer ); |
96 | fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer ); | 96 | fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer ); |
97 | fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer ); | 97 | fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer ); |
98 | fact->addIOLayerFactory( "modem", QObject::tr("Modem"), newModemLayer ); | 98 | fact->addIOLayerFactory( "modem", QObject::tr("Modem"), newModemLayer ); |
99 | fact->addIOLayerFactory( "console", QObject::tr("Console"), newConsole ); | 99 | fact->addIOLayerFactory( "console", QObject::tr("Console"), newConsole ); |
100 | 100 | ||
101 | fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget ); | 101 | fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget ); |
102 | fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget ); | 102 | fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget ); |
103 | fact->addConnectionWidgetFactory( "modem", QObject::tr("Modem"), newModemWidget ); | 103 | fact->addConnectionWidgetFactory( "modem", QObject::tr("Modem"), newModemWidget ); |
104 | fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); | 104 | fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); |
105 | fact->addConnectionWidgetFactory( "console", QObject::tr("Console"), newConsoleWid ); | 105 | fact->addConnectionWidgetFactory( "console", QObject::tr("Console"), newConsoleWid ); |
106 | 106 | ||
107 | fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget ); | 107 | fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget ); |
108 | 108 | ||
109 | // fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 ); | 109 | // fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 ); |
110 | } | 110 | } |
111 | Default::~Default() { | 111 | Default::~Default() { |
112 | 112 | ||
113 | } | 113 | } |
diff --git a/noncore/apps/opie-console/io_layer.h b/noncore/apps/opie-console/io_layer.h index 4977e94..d5f7eab 100644 --- a/noncore/apps/opie-console/io_layer.h +++ b/noncore/apps/opie-console/io_layer.h | |||
@@ -1,124 +1,126 @@ | |||
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 | */ |
17 | class IOLayer : public QObject { | 17 | class IOLayer : public QObject { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | public: | 19 | public: |
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; | ||
83 | |||
82 | signals: | 84 | signals: |
83 | /** | 85 | /** |
84 | * received input as QCString | 86 | * received input as QCString |
85 | */ | 87 | */ |
86 | virtual void received( const QByteArray& ); | 88 | virtual void received( const QByteArray& ); |
87 | 89 | ||
88 | /** | 90 | /** |
89 | * an error occured | 91 | * an error occured |
90 | * int for the error number | 92 | * int for the error number |
91 | * and QString for a text | 93 | * and QString for a text |
92 | */ | 94 | */ |
93 | virtual void error( int, const QString& ); | 95 | virtual void error( int, const QString& ); |
94 | 96 | ||
95 | virtual void closed(); | 97 | virtual void closed(); |
96 | public slots: | 98 | public slots: |
97 | /** | 99 | /** |
98 | * send a QCString to the device | 100 | * send a QCString to the device |
99 | */ | 101 | */ |
100 | virtual void send( const QByteArray& ) = 0; | 102 | virtual void send( const QByteArray& ) = 0; |
101 | 103 | ||
102 | /** | 104 | /** |
103 | * bool open | 105 | * bool open |
104 | */ | 106 | */ |
105 | virtual bool open() = 0; | 107 | virtual bool open() = 0; |
106 | 108 | ||
107 | /** | 109 | /** |
108 | * close the io | 110 | * close the io |
109 | */ | 111 | */ |
110 | virtual void close() = 0; | 112 | virtual void close() = 0; |
111 | 113 | ||
112 | /** | 114 | /** |
113 | * closes and reloads the settings | 115 | * closes and reloads the settings |
114 | */ | 116 | */ |
115 | virtual void reload( const Profile& ) = 0; | 117 | virtual void reload( const Profile& ) = 0; |
116 | 118 | ||
117 | /** | 119 | /** |
118 | * set the size | 120 | * set the size |
119 | * needed for pty | 121 | * needed for pty |
120 | */ | 122 | */ |
121 | virtual void setSize(int rows, int cols ); | 123 | virtual void setSize(int rows, int cols ); |
122 | }; | 124 | }; |
123 | 125 | ||
124 | #endif | 126 | #endif |
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp index c10d5a8..b89a53b 100644 --- a/noncore/apps/opie-console/io_serial.cpp +++ b/noncore/apps/opie-console/io_serial.cpp | |||
@@ -1,196 +1,204 @@ | |||
1 | #include <fcntl.h> | 1 | #include <fcntl.h> |
2 | #include <termios.h> | 2 | #include <termios.h> |
3 | #include <errno.h> | 3 | #include <errno.h> |
4 | #include <unistd.h> | 4 | #include <unistd.h> |
5 | #include "io_serial.h" | 5 | #include "io_serial.h" |
6 | 6 | ||
7 | IOSerial::IOSerial(const Profile &config) : IOLayer(config) { | 7 | IOSerial::IOSerial(const Profile &config) : IOLayer(config) { |
8 | m_read = 0l; | 8 | m_read = 0l; |
9 | m_error = 0l; | 9 | m_error = 0l; |
10 | m_fd = 0; | 10 | m_fd = 0; |
11 | m_connected = false; | ||
11 | reload(config); | 12 | reload(config); |
12 | } | 13 | } |
13 | 14 | ||
14 | 15 | ||
15 | IOSerial::~IOSerial() { | 16 | IOSerial::~IOSerial() { |
16 | if (m_fd) { | 17 | if (m_fd) { |
17 | close(); | 18 | close(); |
18 | } | 19 | } |
19 | } | 20 | } |
20 | 21 | ||
21 | void IOSerial::send(const QByteArray &data) { | 22 | void IOSerial::send(const QByteArray &data) { |
22 | if (m_fd) { | 23 | if (m_fd) { |
23 | write(m_fd, data.data(), data.size()); | 24 | write(m_fd, data.data(), data.size()); |
24 | } else { | 25 | } else { |
25 | emit error(Refuse, tr("Not connected")); | 26 | emit error(Refuse, tr("Not connected")); |
26 | } | 27 | } |
27 | } | 28 | } |
28 | 29 | ||
29 | void IOSerial::close() { | 30 | void IOSerial::close() { |
30 | if (m_fd) { | 31 | if (m_fd) { |
31 | delete m_read; | 32 | delete m_read; |
32 | delete m_error; | 33 | delete m_error; |
33 | ::close(m_fd); | 34 | ::close(m_fd); |
34 | m_fd = 0; | 35 | m_fd = 0; |
36 | m_connected = false; | ||
35 | } else { | 37 | } else { |
38 | m_connected = false; | ||
36 | emit error(Refuse, tr("Not connected")); | 39 | emit error(Refuse, tr("Not connected")); |
37 | } | 40 | } |
38 | } | 41 | } |
39 | 42 | ||
40 | bool IOSerial::open() { | 43 | bool IOSerial::open() { |
41 | if (!m_fd) { | 44 | if (!m_fd) { |
42 | struct termios tty; | 45 | struct termios tty; |
43 | m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK); | 46 | m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK); |
44 | if (m_fd < 0) { | 47 | if (m_fd < 0) { |
45 | emit error(CouldNotOpen, strerror(errno)); | 48 | emit error(CouldNotOpen, strerror(errno)); |
46 | return FALSE; | 49 | return FALSE; |
47 | } | 50 | } |
48 | tcgetattr(m_fd, &tty); | 51 | tcgetattr(m_fd, &tty); |
49 | 52 | ||
50 | /* Baud rate */ | 53 | /* Baud rate */ |
51 | int speed = baud(m_baud); | 54 | int speed = baud(m_baud); |
52 | if (speed == -1) { | 55 | if (speed == -1) { |
53 | emit error(Refuse, tr("Invalid baud rate")); | 56 | emit error(Refuse, tr("Invalid baud rate")); |
54 | } | 57 | } |
55 | cfsetospeed(&tty, speed); | 58 | cfsetospeed(&tty, speed); |
56 | cfsetispeed(&tty, speed); | 59 | cfsetispeed(&tty, speed); |
57 | 60 | ||
58 | /* Take care of Space / Mark parity */ | 61 | /* Take care of Space / Mark parity */ |
59 | if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) { | 62 | if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) { |
60 | m_dbits = 8; | 63 | m_dbits = 8; |
61 | } | 64 | } |
62 | 65 | ||
63 | /* Data bits */ | 66 | /* Data bits */ |
64 | switch (m_dbits) { | 67 | switch (m_dbits) { |
65 | case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break; | 68 | case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break; |
66 | case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break; | 69 | case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break; |
67 | case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break; | 70 | case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break; |
68 | case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break; | 71 | case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break; |
69 | default: break; | 72 | default: break; |
70 | } | 73 | } |
71 | 74 | ||
72 | /* Raw, no echo mode */ | 75 | /* Raw, no echo mode */ |
73 | tty.c_iflag = IGNBRK; | 76 | tty.c_iflag = IGNBRK; |
74 | tty.c_lflag = 0; | 77 | tty.c_lflag = 0; |
75 | tty.c_oflag = 0; | 78 | tty.c_oflag = 0; |
76 | tty.c_cflag |= CLOCAL | CREAD; | 79 | tty.c_cflag |= CLOCAL | CREAD; |
77 | 80 | ||
78 | /* Stop bits */ | 81 | /* Stop bits */ |
79 | if (m_sbits == 2) { | 82 | if (m_sbits == 2) { |
80 | tty.c_cflag |= CSTOPB; | 83 | tty.c_cflag |= CSTOPB; |
81 | } else { | 84 | } else { |
82 | tty.c_cflag &= ~CSTOPB; | 85 | tty.c_cflag &= ~CSTOPB; |
83 | } | 86 | } |
84 | 87 | ||
85 | tty.c_cc[VMIN] = 1; | 88 | tty.c_cc[VMIN] = 1; |
86 | tty.c_cc[VTIME] = 5; | 89 | tty.c_cc[VTIME] = 5; |
87 | 90 | ||
88 | /* Flow control */ | 91 | /* Flow control */ |
89 | if (m_flow & FlowSW) | 92 | if (m_flow & FlowSW) |
90 | tty.c_iflag |= IXON | IXOFF; | 93 | tty.c_iflag |= IXON | IXOFF; |
91 | else | 94 | else |
92 | tty.c_iflag &= ~(IXON|IXOFF|IXANY); | 95 | tty.c_iflag &= ~(IXON|IXOFF|IXANY); |
93 | 96 | ||
94 | if (m_flow & FlowHW) | 97 | if (m_flow & FlowHW) |
95 | tty.c_cflag |= CRTSCTS; | 98 | tty.c_cflag |= CRTSCTS; |
96 | else | 99 | else |
97 | tty.c_cflag &= ~CRTSCTS; | 100 | tty.c_cflag &= ~CRTSCTS; |
98 | 101 | ||
99 | /* Parity */ | 102 | /* Parity */ |
100 | tty.c_cflag &= ~(PARENB | PARODD); | 103 | tty.c_cflag &= ~(PARENB | PARODD); |
101 | if (m_parity & ParityEven) | 104 | if (m_parity & ParityEven) |
102 | tty.c_cflag |= PARENB; | 105 | tty.c_cflag |= PARENB; |
103 | else if (m_parity & ParityOdd) | 106 | else if (m_parity & ParityOdd) |
104 | tty.c_cflag |= (PARENB | PARODD); | 107 | tty.c_cflag |= (PARENB | PARODD); |
105 | 108 | ||
106 | /* Set the changes */ | 109 | /* Set the changes */ |
107 | tcsetattr(m_fd, TCSANOW, &tty); | 110 | tcsetattr(m_fd, TCSANOW, &tty); |
108 | 111 | ||
109 | /* Notifications on read & errors */ | 112 | /* Notifications on read & errors */ |
110 | m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); | 113 | m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); |
111 | m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this); | 114 | m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this); |
112 | connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); | 115 | connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); |
113 | connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); | 116 | connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); |
117 | m_connected = false; | ||
114 | return TRUE; | 118 | return TRUE; |
115 | } else { | 119 | } else { |
116 | emit error(Refuse, tr("Device is already connected")); | 120 | emit error(Refuse, tr("Device is already connected")); |
117 | m_fd = 0; | 121 | m_fd = 0; |
118 | return FALSE; | 122 | return FALSE; |
119 | } | 123 | } |
120 | } | 124 | } |
121 | 125 | ||
122 | void IOSerial::reload(const Profile &config) { | 126 | void IOSerial::reload(const Profile &config) { |
123 | m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); | 127 | m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); |
124 | m_baud = config.readNumEntry("Speed", SERIAL_DEFAULT_BAUD); | 128 | m_baud = config.readNumEntry("Speed", SERIAL_DEFAULT_BAUD); |
125 | m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY); | 129 | m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY); |
126 | m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS); | 130 | m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS); |
127 | m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS); | 131 | m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS); |
128 | m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW); | 132 | m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW); |
129 | 133 | ||
130 | } | 134 | } |
131 | 135 | ||
132 | int IOSerial::baud(int baud) const { | 136 | int IOSerial::baud(int baud) const { |
133 | switch (baud) { | 137 | switch (baud) { |
134 | case 300: return B300; break; | 138 | case 300: return B300; break; |
135 | case 600: return B600; break; | 139 | case 600: return B600; break; |
136 | case 1200: return B1200; break; | 140 | case 1200: return B1200; break; |
137 | case 2400: return B2400; break; | 141 | case 2400: return B2400; break; |
138 | case 4800: return B4800; break; | 142 | case 4800: return B4800; break; |
139 | case 9600: return B9600; break; | 143 | case 9600: return B9600; break; |
140 | case 19200: return B19200; break; | 144 | case 19200: return B19200; break; |
141 | case 38400: return B38400; break; | 145 | case 38400: return B38400; break; |
142 | case 57600: return B57600; break; | 146 | case 57600: return B57600; break; |
143 | case 115200: return B115200; break; | 147 | case 115200: return B115200; break; |
144 | } | 148 | } |
145 | return -1; | 149 | return -1; |
146 | } | 150 | } |
147 | 151 | ||
148 | void IOSerial::errorOccured() { | 152 | void IOSerial::errorOccured() { |
149 | emit error(ClosedUnexpected, strerror(errno)); | 153 | emit error(ClosedUnexpected, strerror(errno)); |
150 | close(); | 154 | close(); |
151 | } | 155 | } |
152 | 156 | ||
153 | void IOSerial::dataArrived() { | 157 | void IOSerial::dataArrived() { |
154 | QByteArray array(4097); | 158 | QByteArray array(4097); |
155 | 159 | ||
156 | int len = read(m_fd, array.data(), 4096); | 160 | int len = read(m_fd, array.data(), 4096); |
157 | if (len == 0) | 161 | if (len == 0) |
158 | close(); | 162 | close(); |
159 | if (len < 0) | 163 | if (len < 0) |
160 | return; | 164 | return; |
161 | array.resize( len ); | 165 | array.resize( len ); |
162 | emit received(array); | 166 | emit received(array); |
163 | } | 167 | } |
164 | 168 | ||
165 | QString IOSerial::identifier() const { | 169 | QString IOSerial::identifier() const { |
166 | return "serial"; | 170 | return "serial"; |
167 | } | 171 | } |
168 | 172 | ||
169 | QString IOSerial::name() const { | 173 | QString IOSerial::name() const { |
170 | return "RS232 Serial IO Layer"; | 174 | return "RS232 Serial IO Layer"; |
171 | } | 175 | } |
172 | int IOSerial::rawIO()const { | 176 | int IOSerial::rawIO()const { |
173 | if (m_read ) | 177 | if (m_read ) |
174 | disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); | 178 | disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); |
175 | if (m_error ) | 179 | if (m_error ) |
176 | disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); | 180 | disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); |
177 | 181 | ||
178 | int fd = ::open(m_device, O_RDWR ); | 182 | int fd = ::open(m_device, O_RDWR ); |
179 | 183 | ||
180 | return fd; | 184 | return fd; |
181 | }; | 185 | }; |
182 | void IOSerial::closeRawIO(int fd) { | 186 | void IOSerial::closeRawIO(int fd) { |
183 | if (m_read ) | 187 | if (m_read ) |
184 | connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); | 188 | connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); |
185 | if (m_error ) | 189 | if (m_error ) |
186 | connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); | 190 | connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); |
187 | 191 | ||
188 | ::close( fd ); | 192 | ::close( fd ); |
189 | } | 193 | } |
190 | QBitArray IOSerial::supports()const { | 194 | QBitArray IOSerial::supports()const { |
191 | QBitArray ar(3); | 195 | QBitArray ar(3); |
192 | ar[0] = ar[2] = 0; | 196 | ar[0] = ar[2] = 0; |
193 | ar[1] = 1; | 197 | ar[1] = 1; |
194 | 198 | ||
195 | return ar; | 199 | return ar; |
196 | } | 200 | } |
201 | |||
202 | bool IOSerial::isConnected() { | ||
203 | return m_connected; | ||
204 | } | ||
diff --git a/noncore/apps/opie-console/io_serial.h b/noncore/apps/opie-console/io_serial.h index b1d1be1..7a1ea1d 100644 --- a/noncore/apps/opie-console/io_serial.h +++ b/noncore/apps/opie-console/io_serial.h | |||
@@ -1,67 +1,70 @@ | |||
1 | #ifndef OPIE_IO_SERIAL | 1 | #ifndef OPIE_IO_SERIAL |
2 | #define OPIE_IO_SERIAL | 2 | #define OPIE_IO_SERIAL |
3 | 3 | ||
4 | #include <qsocketnotifier.h> | 4 | #include <qsocketnotifier.h> |
5 | #include "io_layer.h" | 5 | #include "io_layer.h" |
6 | 6 | ||
7 | /* Default values to be used if the profile information is incomplete */ | 7 | /* Default values to be used if the profile information is incomplete */ |
8 | #define SERIAL_DEFAULT_DEVICE "/dev/ttyS0" | 8 | #define SERIAL_DEFAULT_DEVICE "/dev/ttyS0" |
9 | #define SERIAL_DEFAULT_BAUD 9600 | 9 | #define SERIAL_DEFAULT_BAUD 9600 |
10 | #define SERIAL_DEFAULT_PARITY 0 | 10 | #define SERIAL_DEFAULT_PARITY 0 |
11 | #define SERIAL_DEFAULT_DBITS 8 | 11 | #define SERIAL_DEFAULT_DBITS 8 |
12 | #define SERIAL_DEFAULT_SBITS 1 | 12 | #define SERIAL_DEFAULT_SBITS 1 |
13 | #define SERIAL_DEFAULT_FLOW 0 | 13 | #define SERIAL_DEFAULT_FLOW 0 |
14 | 14 | ||
15 | /* IOSerial implements a RS232 IO Layer */ | 15 | /* IOSerial implements a RS232 IO Layer */ |
16 | 16 | ||
17 | class IOSerial : public IOLayer { | 17 | class IOSerial : public IOLayer { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | public: | 19 | public: |
20 | enum Parity { | 20 | enum Parity { |
21 | ParityNone = 0, | 21 | ParityNone = 0, |
22 | ParityEven, | 22 | ParityEven, |
23 | ParityOdd, | 23 | ParityOdd, |
24 | ParitySpace, | 24 | ParitySpace, |
25 | ParityMark | 25 | ParityMark |
26 | }; | 26 | }; |
27 | 27 | ||
28 | enum Flow { | 28 | enum Flow { |
29 | FlowHW = 0x01, | 29 | FlowHW = 0x01, |
30 | FlowSW = 0x02 | 30 | FlowSW = 0x02 |
31 | }; | 31 | }; |
32 | 32 | ||
33 | IOSerial(const Profile &); | 33 | IOSerial(const Profile &); |
34 | ~IOSerial(); | 34 | ~IOSerial(); |
35 | 35 | ||
36 | QString identifier() const; | 36 | QString identifier() const; |
37 | QString name() const; | 37 | QString name() const; |
38 | int rawIO()const; | 38 | int rawIO()const; |
39 | void closeRawIO(int fd ); | 39 | void closeRawIO(int fd ); |
40 | QBitArray supports()const; | 40 | QBitArray supports()const; |
41 | bool isConnected(); | ||
41 | /*signals: | 42 | /*signals: |
42 | void received(const QByteArray &); | 43 | void received(const QByteArray &); |
43 | void error(int, const QString &); | 44 | void error(int, const QString &); |
44 | */ | 45 | */ |
45 | public slots: | 46 | public slots: |
46 | void send(const QByteArray &); | 47 | void send(const QByteArray &); |
47 | bool open(); | 48 | bool open(); |
48 | void close(); | 49 | void close(); |
49 | void reload(const Profile &); | 50 | void reload(const Profile &); |
50 | protected: | 51 | protected: |
51 | int baud(int baud) const; | 52 | int baud(int baud) const; |
52 | protected slots: | 53 | protected slots: |
53 | void dataArrived(); | 54 | void dataArrived(); |
54 | void errorOccured(); | 55 | void errorOccured(); |
55 | protected: | 56 | protected: |
56 | QSocketNotifier *m_read; | 57 | QSocketNotifier *m_read; |
57 | QSocketNotifier *m_error; | 58 | QSocketNotifier *m_error; |
58 | QString m_device; | 59 | QString m_device; |
59 | int m_baud; | 60 | int m_baud; |
60 | int m_parity; | 61 | int m_parity; |
61 | int m_dbits; | 62 | int m_dbits; |
62 | int m_sbits; | 63 | int m_sbits; |
63 | int m_flow; | 64 | int m_flow; |
64 | int m_fd; | 65 | int m_fd; |
66 | bool m_connected; | ||
67 | |||
65 | }; | 68 | }; |
66 | 69 | ||
67 | #endif /* OPIE_IO_SERIAL */ | 70 | #endif /* OPIE_IO_SERIAL */ |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index d3b6c8a..4326609 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,494 +1,494 @@ | |||
1 | #include <assert.h> | 1 | #include <assert.h> |
2 | 2 | ||
3 | 3 | ||
4 | 4 | ||
5 | #include <qaction.h> | 5 | #include <qaction.h> |
6 | #include <qmenubar.h> | 6 | #include <qmenubar.h> |
7 | #include <qlabel.h> | 7 | #include <qlabel.h> |
8 | #include <qpopupmenu.h> | 8 | #include <qpopupmenu.h> |
9 | #include <qtoolbar.h> | 9 | #include <qtoolbar.h> |
10 | #include <qmessagebox.h> | 10 | #include <qmessagebox.h> |
11 | #include <qpushbutton.h> | 11 | #include <qpushbutton.h> |
12 | 12 | ||
13 | #include <qpe/resource.h> | 13 | #include <qpe/resource.h> |
14 | #include <opie/ofiledialog.h> | 14 | #include <opie/ofiledialog.h> |
15 | 15 | ||
16 | 16 | ||
17 | #include "keytrans.h" | 17 | #include "keytrans.h" |
18 | #include "profileeditordialog.h" | 18 | #include "profileeditordialog.h" |
19 | #include "configdialog.h" | 19 | #include "configdialog.h" |
20 | #include "default.h" | 20 | #include "default.h" |
21 | #include "metafactory.h" | 21 | #include "metafactory.h" |
22 | #include "profile.h" | 22 | #include "profile.h" |
23 | #include "profilemanager.h" | 23 | #include "profilemanager.h" |
24 | #include "mainwindow.h" | 24 | #include "mainwindow.h" |
25 | #include "tabwidget.h" | 25 | #include "tabwidget.h" |
26 | #include "transferdialog.h" | 26 | #include "transferdialog.h" |
27 | #include "function_keyboard.h" | 27 | #include "function_keyboard.h" |
28 | #include "script.h" | 28 | #include "script.h" |
29 | 29 | ||
30 | 30 | ||
31 | 31 | ||
32 | static char * menu_xpm[] = { | 32 | static char * menu_xpm[] = { |
33 | "12 12 5 1", | 33 | "12 12 5 1", |
34 | " c None", | 34 | " c None", |
35 | ".c #000000", | 35 | ".c #000000", |
36 | "+c #FFFDAD", | 36 | "+c #FFFDAD", |
37 | "@c #FFFF00", | 37 | "@c #FFFF00", |
38 | "#c #E5E100", | 38 | "#c #E5E100", |
39 | " ", | 39 | " ", |
40 | " ", | 40 | " ", |
41 | " ......... ", | 41 | " ......... ", |
42 | " .+++++++. ", | 42 | " .+++++++. ", |
43 | " .+@@@@#. ", | 43 | " .+@@@@#. ", |
44 | " .+@@@#. ", | 44 | " .+@@@#. ", |
45 | " .+@@#. ", | 45 | " .+@@#. ", |
46 | " .+@#. ", | 46 | " .+@#. ", |
47 | " .+#. ", | 47 | " .+#. ", |
48 | " .+. ", | 48 | " .+. ", |
49 | " .. ", | 49 | " .. ", |
50 | " "}; | 50 | " "}; |
51 | 51 | ||
52 | 52 | ||
53 | MainWindow::MainWindow() { | 53 | MainWindow::MainWindow() { |
54 | KeyTrans::loadAll(); | 54 | KeyTrans::loadAll(); |
55 | for (int i = 0; i < KeyTrans::count(); i++ ) { | 55 | for (int i = 0; i < KeyTrans::count(); i++ ) { |
56 | KeyTrans* s = KeyTrans::find(i ); | 56 | KeyTrans* s = KeyTrans::find(i ); |
57 | assert( s ); | 57 | assert( s ); |
58 | } | 58 | } |
59 | m_factory = new MetaFactory(); | 59 | m_factory = new MetaFactory(); |
60 | Default def(m_factory); | 60 | Default def(m_factory); |
61 | m_sessions.setAutoDelete( TRUE ); | 61 | m_sessions.setAutoDelete( TRUE ); |
62 | m_curSession = 0; | 62 | m_curSession = 0; |
63 | m_manager = new ProfileManager( m_factory ); | 63 | m_manager = new ProfileManager( m_factory ); |
64 | m_manager->load(); | 64 | m_manager->load(); |
65 | 65 | ||
66 | initUI(); | 66 | initUI(); |
67 | populateProfiles(); | 67 | populateProfiles(); |
68 | } | 68 | } |
69 | void MainWindow::initUI() { | 69 | void MainWindow::initUI() { |
70 | setToolBarsMovable( FALSE ); | 70 | setToolBarsMovable( FALSE ); |
71 | 71 | ||
72 | /* tool bar for the menu */ | 72 | /* tool bar for the menu */ |
73 | m_tool = new QToolBar( this ); | 73 | m_tool = new QToolBar( this ); |
74 | m_tool->setHorizontalStretchable( TRUE ); | 74 | m_tool->setHorizontalStretchable( TRUE ); |
75 | 75 | ||
76 | m_bar = new QMenuBar( m_tool ); | 76 | m_bar = new QMenuBar( m_tool ); |
77 | m_console = new QPopupMenu( this ); | 77 | m_console = new QPopupMenu( this ); |
78 | m_scripts = new QPopupMenu( this ); | 78 | m_scripts = new QPopupMenu( this ); |
79 | m_sessionsPop= new QPopupMenu( this ); | 79 | m_sessionsPop= new QPopupMenu( this ); |
80 | m_settings = new QPopupMenu( this ); | 80 | m_settings = new QPopupMenu( this ); |
81 | 81 | ||
82 | /* add a toolbar for icons */ | 82 | /* add a toolbar for icons */ |
83 | m_icons = new QToolBar(this); | 83 | m_icons = new QToolBar(this); |
84 | 84 | ||
85 | /* | 85 | /* |
86 | * new Action for new sessions | 86 | * new Action for new sessions |
87 | */ | 87 | */ |
88 | QAction* a = new QAction(tr("New Connection"), | 88 | QAction* a = new QAction(tr("New Connection"), |
89 | Resource::loadPixmap( "new" ), | 89 | Resource::loadPixmap( "new" ), |
90 | QString::null, 0, this, 0); | 90 | QString::null, 0, this, 0); |
91 | a->addTo( m_console ); | 91 | a->addTo( m_console ); |
92 | a->addTo( m_icons ); | 92 | a->addTo( m_icons ); |
93 | connect(a, SIGNAL(activated() ), | 93 | connect(a, SIGNAL(activated() ), |
94 | this, SLOT(slotNew() ) ); | 94 | this, SLOT(slotNew() ) ); |
95 | 95 | ||
96 | /* | 96 | /* |
97 | * connect action | 97 | * connect action |
98 | */ | 98 | */ |
99 | m_connect = new QAction(); | 99 | m_connect = new QAction(); |
100 | m_connect->setText( tr("Connect") ); | 100 | m_connect->setText( tr("Connect") ); |
101 | m_connect->addTo( m_console ); | 101 | m_connect->addTo( m_console ); |
102 | connect(m_connect, SIGNAL(activated() ), | 102 | connect(m_connect, SIGNAL(activated() ), |
103 | this, SLOT(slotConnect() ) ); | 103 | this, SLOT(slotConnect() ) ); |
104 | 104 | ||
105 | /* | 105 | /* |
106 | * disconnect action | 106 | * disconnect action |
107 | */ | 107 | */ |
108 | m_disconnect = new QAction(); | 108 | m_disconnect = new QAction(); |
109 | m_disconnect->setText( tr("Disconnect") ); | 109 | m_disconnect->setText( tr("Disconnect") ); |
110 | m_disconnect->addTo( m_console ); | 110 | m_disconnect->addTo( m_console ); |
111 | connect(m_disconnect, SIGNAL(activated() ), | 111 | connect(m_disconnect, SIGNAL(activated() ), |
112 | this, SLOT(slotDisconnect() ) ); | 112 | this, SLOT(slotDisconnect() ) ); |
113 | 113 | ||
114 | m_transfer = new QAction(); | 114 | m_transfer = new QAction(); |
115 | m_transfer->setText( tr("Transfer file...") ); | 115 | m_transfer->setText( tr("Transfer file...") ); |
116 | m_transfer->addTo( m_console ); | 116 | m_transfer->addTo( m_console ); |
117 | connect(m_transfer, SIGNAL(activated() ), | 117 | connect(m_transfer, SIGNAL(activated() ), |
118 | this, SLOT(slotTransfer() ) ); | 118 | this, SLOT(slotTransfer() ) ); |
119 | 119 | ||
120 | 120 | ||
121 | /* | 121 | /* |
122 | * fullscreen | 122 | * fullscreen |
123 | */ | 123 | */ |
124 | m_isFullscreen = false; | 124 | m_isFullscreen = false; |
125 | 125 | ||
126 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) | 126 | m_fullscreen = new QAction( tr("Full screen"), Resource::loadPixmap( "fullscreen" ) |
127 | , QString::null, 0, this, 0); | 127 | , QString::null, 0, this, 0); |
128 | m_fullscreen->addTo( m_console ); | 128 | m_fullscreen->addTo( m_console ); |
129 | m_fullscreen->addTo( m_icons ); | 129 | m_fullscreen->addTo( m_icons ); |
130 | connect( m_fullscreen, SIGNAL( activated() ), | 130 | connect( m_fullscreen, SIGNAL( activated() ), |
131 | this, SLOT( slotFullscreen() ) ); | 131 | this, SLOT( slotFullscreen() ) ); |
132 | 132 | ||
133 | /* | 133 | /* |
134 | * terminate action | 134 | * terminate action |
135 | */ | 135 | */ |
136 | m_terminate = new QAction(); | 136 | m_terminate = new QAction(); |
137 | m_terminate->setText( tr("Terminate") ); | 137 | m_terminate->setText( tr("Terminate") ); |
138 | m_terminate->addTo( m_console ); | 138 | m_terminate->addTo( m_console ); |
139 | connect(m_terminate, SIGNAL(activated() ), | 139 | connect(m_terminate, SIGNAL(activated() ), |
140 | this, SLOT(slotTerminate() ) ); | 140 | this, SLOT(slotTerminate() ) ); |
141 | 141 | ||
142 | m_closewindow = new QAction(); | 142 | m_closewindow = new QAction(); |
143 | m_closewindow->setText( tr("Close Window") ); | 143 | m_closewindow->setText( tr("Close Window") ); |
144 | m_closewindow->addTo( m_console ); | 144 | m_closewindow->addTo( m_console ); |
145 | connect( m_closewindow, SIGNAL(activated() ), | 145 | connect( m_closewindow, SIGNAL(activated() ), |
146 | this, SLOT(slotClose() ) ); | 146 | this, SLOT(slotClose() ) ); |
147 | 147 | ||
148 | /* | 148 | /* |
149 | * the settings action | 149 | * the settings action |
150 | */ | 150 | */ |
151 | m_setProfiles = new QAction(tr("Configure Profiles"), | 151 | m_setProfiles = new QAction(tr("Configure Profiles"), |
152 | Resource::loadPixmap( "SettingsIcon" ), | 152 | Resource::loadPixmap( "SettingsIcon" ), |
153 | QString::null, 0, this, 0); | 153 | QString::null, 0, this, 0); |
154 | m_setProfiles->addTo( m_settings ); | 154 | m_setProfiles->addTo( m_settings ); |
155 | m_setProfiles->addTo( m_icons ); | 155 | m_setProfiles->addTo( m_icons ); |
156 | connect( m_setProfiles, SIGNAL(activated() ), | 156 | connect( m_setProfiles, SIGNAL(activated() ), |
157 | this, SLOT(slotConfigure() ) ); | 157 | this, SLOT(slotConfigure() ) ); |
158 | 158 | ||
159 | /* | 159 | /* |
160 | * script actions | 160 | * script actions |
161 | */ | 161 | */ |
162 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); | 162 | m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0); |
163 | m_recordScript->addTo(m_scripts); | 163 | m_recordScript->addTo(m_scripts); |
164 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); | 164 | connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript())); |
165 | 165 | ||
166 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); | 166 | m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0); |
167 | m_saveScript->addTo(m_scripts); | 167 | m_saveScript->addTo(m_scripts); |
168 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); | 168 | connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript())); |
169 | 169 | ||
170 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); | 170 | m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0); |
171 | m_runScript->addTo(m_scripts); | 171 | m_runScript->addTo(m_scripts); |
172 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); | 172 | connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript())); |
173 | 173 | ||
174 | /* | 174 | /* |
175 | * action that open/closes the keyboard | 175 | * action that open/closes the keyboard |
176 | */ | 176 | */ |
177 | m_openKeys = new QAction (tr("Open Keyboard..."), | 177 | m_openKeys = new QAction (tr("Open Keyboard..."), |
178 | Resource::loadPixmap( "down" ), | 178 | Resource::loadPixmap( "down" ), |
179 | QString::null, 0, this, 0); | 179 | QString::null, 0, this, 0); |
180 | 180 | ||
181 | m_openKeys->setToggleAction(true); | 181 | m_openKeys->setToggleAction(true); |
182 | 182 | ||
183 | connect (m_openKeys, SIGNAL(toggled(bool)), | 183 | connect (m_openKeys, SIGNAL(toggled(bool)), |
184 | this, SLOT(slotOpenKeb(bool))); | 184 | this, SLOT(slotOpenKeb(bool))); |
185 | m_openKeys->addTo(m_icons); | 185 | m_openKeys->addTo(m_icons); |
186 | 186 | ||
187 | 187 | ||
188 | /* insert the submenu */ | 188 | /* insert the submenu */ |
189 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, | 189 | m_console->insertItem(tr("New from Profile"), m_sessionsPop, |
190 | -1, 0); | 190 | -1, 0); |
191 | 191 | ||
192 | /* insert the connection menu */ | 192 | /* insert the connection menu */ |
193 | m_bar->insertItem( tr("Connection"), m_console ); | 193 | m_bar->insertItem( tr("Connection"), m_console ); |
194 | 194 | ||
195 | /* the scripts menu */ | 195 | /* the scripts menu */ |
196 | m_bar->insertItem( tr("Scripts"), m_scripts ); | 196 | m_bar->insertItem( tr("Scripts"), m_scripts ); |
197 | 197 | ||
198 | /* the settings menu */ | 198 | /* the settings menu */ |
199 | m_bar->insertItem( tr("Settings"), m_settings ); | 199 | m_bar->insertItem( tr("Settings"), m_settings ); |
200 | 200 | ||
201 | /* and the keyboard */ | 201 | /* and the keyboard */ |
202 | m_keyBar = new QToolBar(this); | 202 | m_keyBar = new QToolBar(this); |
203 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); | 203 | addToolBar( m_keyBar, "Keyboard", QMainWindow::Top, TRUE ); |
204 | m_keyBar->setHorizontalStretchable( TRUE ); | 204 | m_keyBar->setHorizontalStretchable( TRUE ); |
205 | m_keyBar->hide(); | 205 | m_keyBar->hide(); |
206 | 206 | ||
207 | m_kb = new FunctionKeyboard(m_keyBar); | 207 | m_kb = new FunctionKeyboard(m_keyBar); |
208 | connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)), | 208 | connect(m_kb, SIGNAL(keyPressed(ushort, ushort, bool, bool, bool)), |
209 | this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool))); | 209 | this, SLOT(slotKeyReceived(ushort, ushort, bool, bool, bool))); |
210 | 210 | ||
211 | 211 | ||
212 | 212 | ||
213 | m_connect->setEnabled( false ); | 213 | m_connect->setEnabled( false ); |
214 | m_disconnect->setEnabled( false ); | 214 | m_disconnect->setEnabled( false ); |
215 | m_terminate->setEnabled( false ); | 215 | m_terminate->setEnabled( false ); |
216 | m_transfer->setEnabled( false ); | 216 | m_transfer->setEnabled( false ); |
217 | m_recordScript->setEnabled( false ); | 217 | m_recordScript->setEnabled( false ); |
218 | m_saveScript->setEnabled( false ); | 218 | m_saveScript->setEnabled( false ); |
219 | m_runScript->setEnabled( false ); | 219 | m_runScript->setEnabled( false ); |
220 | m_fullscreen->setEnabled( false ); | 220 | m_fullscreen->setEnabled( false ); |
221 | m_closewindow->setEnabled( false ); | 221 | m_closewindow->setEnabled( false ); |
222 | 222 | ||
223 | /* | 223 | /* |
224 | * connect to the menu activation | 224 | * connect to the menu activation |
225 | */ | 225 | */ |
226 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 226 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
227 | this, SLOT(slotProfile( int ) ) ); | 227 | this, SLOT(slotProfile( int ) ) ); |
228 | 228 | ||
229 | m_consoleWindow = new TabWidget( this, "blah"); | 229 | m_consoleWindow = new TabWidget( this, "blah"); |
230 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 230 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
231 | this, SLOT(slotSessionChanged(Session*) ) ); | 231 | this, SLOT(slotSessionChanged(Session*) ) ); |
232 | setCentralWidget( m_consoleWindow ); | 232 | setCentralWidget( m_consoleWindow ); |
233 | 233 | ||
234 | } | 234 | } |
235 | 235 | ||
236 | ProfileManager* MainWindow::manager() { | 236 | ProfileManager* MainWindow::manager() { |
237 | return m_manager; | 237 | return m_manager; |
238 | } | 238 | } |
239 | TabWidget* MainWindow::tabWidget() { | 239 | TabWidget* MainWindow::tabWidget() { |
240 | return m_consoleWindow; | 240 | return m_consoleWindow; |
241 | } | 241 | } |
242 | void MainWindow::populateProfiles() { | 242 | void MainWindow::populateProfiles() { |
243 | m_sessionsPop->clear(); | 243 | m_sessionsPop->clear(); |
244 | Profile::ValueList list = manager()->all(); | 244 | Profile::ValueList list = manager()->all(); |
245 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 245 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
246 | m_sessionsPop->insertItem( (*it).name() ); | 246 | m_sessionsPop->insertItem( (*it).name() ); |
247 | } | 247 | } |
248 | 248 | ||
249 | } | 249 | } |
250 | MainWindow::~MainWindow() { | 250 | MainWindow::~MainWindow() { |
251 | delete m_factory; | 251 | delete m_factory; |
252 | manager()->save(); | 252 | manager()->save(); |
253 | } | 253 | } |
254 | 254 | ||
255 | MetaFactory* MainWindow::factory() { | 255 | MetaFactory* MainWindow::factory() { |
256 | return m_factory; | 256 | return m_factory; |
257 | } | 257 | } |
258 | 258 | ||
259 | Session* MainWindow::currentSession() { | 259 | Session* MainWindow::currentSession() { |
260 | return m_curSession; | 260 | return m_curSession; |
261 | } | 261 | } |
262 | 262 | ||
263 | QList<Session> MainWindow::sessions() { | 263 | QList<Session> MainWindow::sessions() { |
264 | return m_sessions; | 264 | return m_sessions; |
265 | } | 265 | } |
266 | 266 | ||
267 | void MainWindow::slotNew() { | 267 | void MainWindow::slotNew() { |
268 | ProfileEditorDialog dlg(factory() ); | 268 | ProfileEditorDialog dlg(factory() ); |
269 | dlg.showMaximized(); | 269 | dlg.showMaximized(); |
270 | int ret = dlg.exec(); | 270 | int ret = dlg.exec(); |
271 | 271 | ||
272 | if ( ret == QDialog::Accepted ) { | 272 | if ( ret == QDialog::Accepted ) { |
273 | create( dlg.profile() ); | 273 | create( dlg.profile() ); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | 276 | ||
277 | void MainWindow::slotRecordScript() { | 277 | void MainWindow::slotRecordScript() { |
278 | /* if (currentSession()) { | 278 | /* if (currentSession()) { |
279 | currentSession()->emulationLayer()->startRecording(); | 279 | currentSession()->emulationLayer()->startRecording(); |
280 | } | 280 | } |
281 | */ | 281 | */ |
282 | } | 282 | } |
283 | 283 | ||
284 | void MainWindow::slotSaveScript() { | 284 | void MainWindow::slotSaveScript() { |
285 | /* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { | 285 | /* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { |
286 | MimeTypes types; | 286 | MimeTypes types; |
287 | QStringList script; | 287 | QStringList script; |
288 | script << "text/plain"; | 288 | script << "text/plain"; |
289 | types.insert("Script", script); | 289 | types.insert("Script", script); |
290 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); | 290 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); |
291 | if (!filename.isEmpty()) { | 291 | if (!filename.isEmpty()) { |
292 | currentSession()->emulationLayer()->script()->saveTo(filename); | 292 | currentSession()->emulationLayer()->script()->saveTo(filename); |
293 | currentSession()->emulationLayer()->clearScript(); | 293 | currentSession()->emulationLayer()->clearScript(); |
294 | } | 294 | } |
295 | } | 295 | } |
296 | */ | 296 | */ |
297 | } | 297 | } |
298 | 298 | ||
299 | void MainWindow::slotRunScript() { | 299 | void MainWindow::slotRunScript() { |
300 | /* | 300 | /* |
301 | if (currentSession()) { | 301 | if (currentSession()) { |
302 | MimeTypes types; | 302 | MimeTypes types; |
303 | QStringList script; | 303 | QStringList script; |
304 | script << "text/plain"; | 304 | script << "text/plain"; |
305 | types.insert("Script", script); | 305 | types.insert("Script", script); |
306 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); | 306 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); |
307 | if (!filename.isEmpty()) { | 307 | if (!filename.isEmpty()) { |
308 | Script script(DocLnk(filename).file()); | 308 | Script script(DocLnk(filename).file()); |
309 | currentSession()->emulationLayer()->runScript(&script); | 309 | currentSession()->emulationLayer()->runScript(&script); |
310 | } | 310 | } |
311 | } | 311 | } |
312 | */ | 312 | */ |
313 | } | 313 | } |
314 | 314 | ||
315 | void MainWindow::slotConnect() { | 315 | void MainWindow::slotConnect() { |
316 | if ( currentSession() ) { | 316 | if ( currentSession() ) { |
317 | bool ret = currentSession()->layer()->open(); | 317 | bool ret = currentSession()->layer()->open(); |
318 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 318 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
319 | QObject::tr("Failed"), | 319 | QObject::tr("Failed"), |
320 | QObject::tr("Connecting failed for this session.")); | 320 | QObject::tr("Connecting failed for this session.")); |
321 | m_connect->setEnabled( false ); | 321 | m_connect->setEnabled( false ); |
322 | m_disconnect->setEnabled( true ); | 322 | m_disconnect->setEnabled( true ); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | 325 | ||
326 | void MainWindow::slotDisconnect() { | 326 | void MainWindow::slotDisconnect() { |
327 | if ( currentSession() ) { | 327 | if ( currentSession() ) { |
328 | currentSession()->layer()->close(); | 328 | currentSession()->layer()->close(); |
329 | m_connect->setEnabled( true ); | 329 | m_connect->setEnabled( true ); |
330 | m_disconnect->setEnabled( false ); | 330 | m_disconnect->setEnabled( false ); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | void MainWindow::slotTerminate() { | 334 | void MainWindow::slotTerminate() { |
335 | if ( currentSession() ) | 335 | if ( currentSession() ) |
336 | currentSession()->layer()->close(); | 336 | currentSession()->layer()->close(); |
337 | 337 | ||
338 | slotClose(); | 338 | slotClose(); |
339 | /* FIXME move to the next session */ | 339 | /* FIXME move to the next session */ |
340 | } | 340 | } |
341 | 341 | ||
342 | void MainWindow::slotConfigure() { | 342 | void MainWindow::slotConfigure() { |
343 | ConfigDialog conf( manager()->all(), factory() ); | 343 | ConfigDialog conf( manager()->all(), factory() ); |
344 | conf.showMaximized(); | 344 | conf.showMaximized(); |
345 | 345 | ||
346 | int ret = conf.exec(); | 346 | int ret = conf.exec(); |
347 | 347 | ||
348 | if ( QDialog::Accepted == ret ) { | 348 | if ( QDialog::Accepted == ret ) { |
349 | manager()->setProfiles( conf.list() ); | 349 | manager()->setProfiles( conf.list() ); |
350 | manager()->save(); | 350 | manager()->save(); |
351 | populateProfiles(); | 351 | populateProfiles(); |
352 | } | 352 | } |
353 | } | 353 | } |
354 | /* | 354 | /* |
355 | * we will remove | 355 | * we will remove |
356 | * this window from the tabwidget | 356 | * this window from the tabwidget |
357 | * remove it from the list | 357 | * remove it from the list |
358 | * delete it | 358 | * delete it |
359 | * and set the currentSession() | 359 | * and set the currentSession() |
360 | */ | 360 | */ |
361 | void MainWindow::slotClose() { | 361 | void MainWindow::slotClose() { |
362 | if (!currentSession() ) | 362 | if (!currentSession() ) |
363 | return; | 363 | return; |
364 | 364 | ||
365 | Session* ses = currentSession(); | 365 | Session* ses = currentSession(); |
366 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 366 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
367 | tabWidget()->remove( currentSession() ); | 367 | tabWidget()->remove( currentSession() ); |
368 | /*it's autodelete */ | 368 | /*it's autodelete */ |
369 | m_sessions.remove( ses ); | 369 | m_sessions.remove( ses ); |
370 | qWarning("after remove!!"); | 370 | qWarning("after remove!!"); |
371 | 371 | ||
372 | if (!currentSession() ) { | 372 | if (!currentSession() ) { |
373 | m_connect->setEnabled( false ); | 373 | m_connect->setEnabled( false ); |
374 | m_disconnect->setEnabled( false ); | 374 | m_disconnect->setEnabled( false ); |
375 | m_terminate->setEnabled( false ); | 375 | m_terminate->setEnabled( false ); |
376 | m_transfer->setEnabled( false ); | 376 | m_transfer->setEnabled( false ); |
377 | m_recordScript->setEnabled( false ); | 377 | m_recordScript->setEnabled( false ); |
378 | m_saveScript->setEnabled( false ); | 378 | m_saveScript->setEnabled( false ); |
379 | m_runScript->setEnabled( false ); | 379 | m_runScript->setEnabled( false ); |
380 | m_fullscreen->setEnabled( false ); | 380 | m_fullscreen->setEnabled( false ); |
381 | m_closewindow->setEnabled( false ); | 381 | m_closewindow->setEnabled( false ); |
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | /* | 385 | /* |
386 | * We will get the name | 386 | * We will get the name |
387 | * Then the profile | 387 | * Then the profile |
388 | * and then we will make a profile | 388 | * and then we will make a profile |
389 | */ | 389 | */ |
390 | void MainWindow::slotProfile( int id) { | 390 | void MainWindow::slotProfile( int id) { |
391 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 391 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
392 | create( prof ); | 392 | create( prof ); |
393 | } | 393 | } |
394 | void MainWindow::create( const Profile& prof ) { | 394 | void MainWindow::create( const Profile& prof ) { |
395 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 395 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
396 | 396 | ||
397 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 397 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
398 | { | 398 | { |
399 | QMessageBox::warning(this, | 399 | QMessageBox::warning(this, |
400 | QObject::tr("Session failed"), | 400 | QObject::tr("Session failed"), |
401 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 401 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
402 | //if(ses) delete ses; | 402 | //if(ses) delete ses; |
403 | return; | 403 | return; |
404 | } | 404 | } |
405 | 405 | ||
406 | m_sessions.append( ses ); | 406 | m_sessions.append( ses ); |
407 | tabWidget()->add( ses ); | 407 | tabWidget()->add( ses ); |
408 | m_curSession = ses; | 408 | m_curSession = ses; |
409 | 409 | ||
410 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 410 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
411 | m_connect->setEnabled( true ); | 411 | m_connect->setEnabled( true ); |
412 | m_disconnect->setEnabled( false ); | 412 | m_disconnect->setEnabled( false ); |
413 | m_terminate->setEnabled( true ); | 413 | m_terminate->setEnabled( true ); |
414 | m_transfer->setEnabled( true ); | 414 | m_transfer->setEnabled( true ); |
415 | m_recordScript->setEnabled( true ); | 415 | m_recordScript->setEnabled( true ); |
416 | m_saveScript->setEnabled( true ); | 416 | m_saveScript->setEnabled( true ); |
417 | m_runScript->setEnabled( true ); | 417 | m_runScript->setEnabled( true ); |
418 | m_fullscreen->setEnabled( true ); | 418 | m_fullscreen->setEnabled( true ); |
419 | m_closewindow->setEnabled( true ); | 419 | m_closewindow->setEnabled( true ); |
420 | } | 420 | } |
421 | 421 | ||
422 | void MainWindow::slotTransfer() | 422 | void MainWindow::slotTransfer() |
423 | { | 423 | { |
424 | if ( currentSession() ) { | 424 | if ( currentSession() ) { |
425 | TransferDialog dlg(this); | 425 | TransferDialog dlg(this); |
426 | dlg.showMaximized(); | 426 | dlg.showMaximized(); |
427 | dlg.exec(); | 427 | dlg.exec(); |
428 | } | 428 | } |
429 | } | 429 | } |
430 | 430 | ||
431 | 431 | ||
432 | void MainWindow::slotOpenKeb(bool state) { | 432 | void MainWindow::slotOpenKeb(bool state) { |
433 | 433 | ||
434 | if (state) m_keyBar->show(); | 434 | if (state) m_keyBar->show(); |
435 | else m_keyBar->hide(); | 435 | else m_keyBar->hide(); |
436 | 436 | ||
437 | } | 437 | } |
438 | void MainWindow::slotSessionChanged( Session* ses ) { | 438 | void MainWindow::slotSessionChanged( Session* ses ) { |
439 | qWarning("changed!"); | 439 | qWarning("changed!"); |
440 | if ( ses ) { | 440 | if ( ses ) { |
441 | m_curSession = ses; | 441 | m_curSession = ses; |
442 | 442 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | |
443 | if ( m_curSession->isConnected() ) { | 443 | if ( m_curSession->layer()->isConnected() ) { |
444 | m_connect->setEnabled( false ); | 444 | m_connect->setEnabled( false ); |
445 | m_disconnect->setEnabled( true ); | 445 | m_disconnect->setEnabled( true ); |
446 | } else { | 446 | } else { |
447 | m_connect->setEnabled( true ); | 447 | m_connect->setEnabled( true ); |
448 | m_disconnect->setEnabled( false ); | 448 | m_disconnect->setEnabled( false ); |
449 | } | 449 | } |
450 | } | 450 | } |
451 | } | 451 | } |
452 | 452 | ||
453 | void MainWindow::slotFullscreen() { | 453 | void MainWindow::slotFullscreen() { |
454 | 454 | ||
455 | if ( m_isFullscreen ) { | 455 | if ( m_isFullscreen ) { |
456 | ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); | 456 | ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); |
457 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 457 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
458 | setCentralWidget( m_consoleWindow ); | 458 | setCentralWidget( m_consoleWindow ); |
459 | ( m_curSession->widgetStack() )->show(); | 459 | ( m_curSession->widgetStack() )->show(); |
460 | m_fullscreen->setText( tr("Full screen") ); | 460 | m_fullscreen->setText( tr("Full screen") ); |
461 | 461 | ||
462 | } else { | 462 | } else { |
463 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 463 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
464 | ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, | 464 | ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, |
465 | QPoint(0,0), false); | 465 | QPoint(0,0), false); |
466 | ( m_curSession->widgetStack() )->resize(qApp->desktop()->width(), qApp->desktop()->height()); | 466 | ( m_curSession->widgetStack() )->resize(qApp->desktop()->width(), qApp->desktop()->height()); |
467 | ( m_curSession->widgetStack() )->setFocus(); | 467 | ( m_curSession->widgetStack() )->setFocus(); |
468 | ( m_curSession->widgetStack() )->show(); | 468 | ( m_curSession->widgetStack() )->show(); |
469 | 469 | ||
470 | //QPushButton *cornerButton = new QPushButton( ); | 470 | //QPushButton *cornerButton = new QPushButton( ); |
471 | //cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); | 471 | //cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); |
472 | //connect( cornerButton, SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 472 | //connect( cornerButton, SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
473 | // need teh scrollbar | 473 | // need teh scrollbar |
474 | // ( m_curSession->widgetStack() )->setCornerWidget( cornerButton ); | 474 | // ( m_curSession->widgetStack() )->setCornerWidget( cornerButton ); |
475 | m_fullscreen->setText( tr("Stop full screen") ); | 475 | m_fullscreen->setText( tr("Stop full screen") ); |
476 | } | 476 | } |
477 | 477 | ||
478 | m_isFullscreen = !m_isFullscreen; | 478 | m_isFullscreen = !m_isFullscreen; |
479 | 479 | ||
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool, bool) { | 483 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool, bool) { |
484 | 484 | ||
485 | qWarning("received key event! relay to TE widget"); | 485 | qWarning("received key event! relay to TE widget"); |
486 | 486 | ||
487 | if ( m_curSession ) { | 487 | if ( m_curSession ) { |
488 | QKeyEvent ke(QEvent::KeyPress, q, u, 0); | 488 | QKeyEvent ke(QEvent::KeyPress, q, u, 0); |
489 | 489 | ||
490 | ke.ignore(); | 490 | ke.ignore(); |
491 | // where should i send this event? doesnt work sending it here | 491 | // where should i send this event? doesnt work sending it here |
492 | QApplication::sendEvent((QObject *)m_curSession->widgetStack(), &ke); | 492 | QApplication::sendEvent((QObject *)m_curSession->widgetStack(), &ke); |
493 | } | 493 | } |
494 | } | 494 | } |
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp index aad100d..2ce6872 100644 --- a/noncore/apps/opie-console/session.cpp +++ b/noncore/apps/opie-console/session.cpp | |||
@@ -1,105 +1,98 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include "io_layer.h" | 3 | #include "io_layer.h" |
4 | #include "file_layer.h" | 4 | #include "file_layer.h" |
5 | #include "emulation_handler.h" | 5 | #include "emulation_handler.h" |
6 | #include "session.h" | 6 | #include "session.h" |
7 | 7 | ||
8 | 8 | ||
9 | Session::Session() { | 9 | Session::Session() { |
10 | m_widget = 0l; | 10 | m_widget = 0l; |
11 | m_layer = 0l; | 11 | m_layer = 0l; |
12 | m_emu = 0l; | 12 | m_emu = 0l; |
13 | } | 13 | } |
14 | Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) | 14 | Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) |
15 | : m_name( na ), m_widget( widget ), m_layer( lay ) | 15 | : m_name( na ), m_widget( widget ), m_layer( lay ) |
16 | { | 16 | { |
17 | // m_widLay = 0l; | 17 | // m_widLay = 0l; |
18 | // m_emLay = 0l; | 18 | // m_emLay = 0l; |
19 | m_emu = 0l; | 19 | m_emu = 0l; |
20 | } | 20 | } |
21 | Session::~Session() { | 21 | Session::~Session() { |
22 | delete m_layer; | 22 | delete m_layer; |
23 | delete m_emu; | 23 | delete m_emu; |
24 | delete m_widget; | 24 | delete m_widget; |
25 | /* the widget layer should be deleted by the m_widget */ | 25 | /* the widget layer should be deleted by the m_widget */ |
26 | } | 26 | } |
27 | QString Session::name()const { | 27 | QString Session::name()const { |
28 | return m_name; | 28 | return m_name; |
29 | } | 29 | } |
30 | QWidgetStack* Session::widgetStack() { | 30 | QWidgetStack* Session::widgetStack() { |
31 | return m_widget; | 31 | return m_widget; |
32 | } | 32 | } |
33 | IOLayer* Session::layer() { | 33 | IOLayer* Session::layer() { |
34 | return m_layer; | 34 | return m_layer; |
35 | } | 35 | } |
36 | EmulationHandler* Session::emulationHandler() { | 36 | EmulationHandler* Session::emulationHandler() { |
37 | return m_emu; | 37 | return m_emu; |
38 | } | 38 | } |
39 | QWidget* Session::widget() { | 39 | QWidget* Session::widget() { |
40 | if (!m_emu ) | 40 | if (!m_emu ) |
41 | return 0l; | 41 | return 0l; |
42 | 42 | ||
43 | return m_emu->widget(); | 43 | return m_emu->widget(); |
44 | } | 44 | } |
45 | /* | 45 | /* |
46 | WidgetLayer* Session::emulationWidget() { | 46 | WidgetLayer* Session::emulationWidget() { |
47 | return m_widLay; | 47 | return m_widLay; |
48 | } | 48 | } |
49 | */ | 49 | */ |
50 | void Session::connect() { | 50 | void Session::connect() { |
51 | if ( !m_layer || !m_emu ) | 51 | if ( !m_layer || !m_emu ) |
52 | return; | 52 | return; |
53 | 53 | ||
54 | m_connected = true; | ||
55 | |||
56 | QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), | 54 | QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), |
57 | m_emu, SLOT(recv(const QByteArray&) ) ); | 55 | m_emu, SLOT(recv(const QByteArray&) ) ); |
58 | QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), | 56 | QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), |
59 | m_layer, SLOT(send(const QByteArray&) ) ); | 57 | m_layer, SLOT(send(const QByteArray&) ) ); |
60 | } | 58 | } |
61 | 59 | ||
62 | void Session::disconnect() { | 60 | void Session::disconnect() { |
63 | 61 | ||
64 | if ( !m_layer || !m_emu ) | 62 | if ( !m_layer || !m_emu ) |
65 | return; | 63 | return; |
66 | 64 | ||
67 | m_connected = false; | ||
68 | |||
69 | QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), | 65 | QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), |
70 | m_emu, SLOT(recv(const QByteArray&) ) ); | 66 | m_emu, SLOT(recv(const QByteArray&) ) ); |
71 | QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), | 67 | QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), |
72 | m_layer, SLOT(send(const QByteArray&) ) ); | 68 | m_layer, SLOT(send(const QByteArray&) ) ); |
73 | } | 69 | } |
74 | 70 | ||
75 | void Session::setName( const QString& na){ | 71 | void Session::setName( const QString& na){ |
76 | m_name = na; | 72 | m_name = na; |
77 | } | 73 | } |
78 | 74 | ||
79 | void Session::setWidgetStack( QWidgetStack* wid ) { | 75 | void Session::setWidgetStack( QWidgetStack* wid ) { |
80 | delete m_emu; | 76 | delete m_emu; |
81 | m_emu = 0l; | 77 | m_emu = 0l; |
82 | delete m_widget; | 78 | delete m_widget; |
83 | /* the EmulationLayer was destroyed... */ | 79 | /* the EmulationLayer was destroyed... */ |
84 | 80 | ||
85 | m_widget = wid; | 81 | m_widget = wid; |
86 | } | 82 | } |
87 | void Session::setIOLayer( IOLayer* lay ) { | 83 | void Session::setIOLayer( IOLayer* lay ) { |
88 | delete m_layer; | 84 | delete m_layer; |
89 | m_layer = lay; | 85 | m_layer = lay; |
90 | } | 86 | } |
91 | 87 | ||
92 | void Session::setEmulationHandler( EmulationHandler* lay ) { | 88 | void Session::setEmulationHandler( EmulationHandler* lay ) { |
93 | delete m_emu; | 89 | delete m_emu; |
94 | m_emu = lay; | 90 | m_emu = lay; |
95 | } | 91 | } |
96 | /* | 92 | /* |
97 | void Session::setEmulationWidget( WidgetLayer* lay ) { | 93 | void Session::setEmulationWidget( WidgetLayer* lay ) { |
98 | delete m_widLay; | 94 | delete m_widLay; |
99 | m_widLay = lay; | 95 | m_widLay = lay; |
100 | } | 96 | } |
101 | */ | 97 | */ |
102 | 98 | ||
103 | bool Session::isConnected() { | ||
104 | return m_connected; | ||
105 | } | ||
diff --git a/noncore/apps/opie-console/session.h b/noncore/apps/opie-console/session.h index ff92df3..83b2046 100644 --- a/noncore/apps/opie-console/session.h +++ b/noncore/apps/opie-console/session.h | |||
@@ -1,74 +1,72 @@ | |||
1 | #ifndef OPIE_SESSION_H | 1 | #ifndef OPIE_SESSION_H |
2 | #define OPIE_SESSION_H | 2 | #define OPIE_SESSION_H |
3 | 3 | ||
4 | #include <qwidgetstack.h> | 4 | #include <qwidgetstack.h> |
5 | 5 | ||
6 | class IOLayer; | 6 | class IOLayer; |
7 | class EmulationHandler; | 7 | class EmulationHandler; |
8 | /** | 8 | /** |
9 | * This is a Session. A session contains | 9 | * This is a Session. A session contains |
10 | * a QWidget pointer and a IOLayer | 10 | * a QWidget pointer and a IOLayer |
11 | * Imagine a session like a collection of what | 11 | * Imagine a session like a collection of what |
12 | * is needed to show your widget in a tab ;) | 12 | * is needed to show your widget in a tab ;) |
13 | */ | 13 | */ |
14 | class Session { | 14 | class Session { |
15 | public: | 15 | public: |
16 | /** | 16 | /** |
17 | * c'tor with widget and layer | 17 | * c'tor with widget and layer |
18 | * ownership get's transfered | 18 | * ownership get's transfered |
19 | */ | 19 | */ |
20 | Session(); | 20 | Session(); |
21 | Session( const QString&, QWidgetStack* widget, IOLayer* ); | 21 | Session( const QString&, QWidgetStack* widget, IOLayer* ); |
22 | ~Session(); | 22 | ~Session(); |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * return the name of the session | 25 | * return the name of the session |
26 | */ | 26 | */ |
27 | QString name()const; | 27 | QString name()const; |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * return the widgetstack | 30 | * return the widgetstack |
31 | * this is used to be semi modal | 31 | * this is used to be semi modal |
32 | * for FileTransfer | 32 | * for FileTransfer |
33 | * | 33 | * |
34 | * semi modal == SessionModal | 34 | * semi modal == SessionModal |
35 | */ | 35 | */ |
36 | QWidgetStack* widgetStack(); | 36 | QWidgetStack* widgetStack(); |
37 | QWidget* widget(); | 37 | QWidget* widget(); |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * return the layer | 40 | * return the layer |
41 | */ | 41 | */ |
42 | IOLayer* layer(); | 42 | IOLayer* layer(); |
43 | 43 | ||
44 | EmulationHandler* emulationHandler(); | 44 | EmulationHandler* emulationHandler(); |
45 | 45 | ||
46 | /* | 46 | /* |
47 | * connects the data flow from | 47 | * connects the data flow from |
48 | * the IOLayer to the EmulationLayer | 48 | * the IOLayer to the EmulationLayer |
49 | */ | 49 | */ |
50 | void connect(); | 50 | void connect(); |
51 | 51 | ||
52 | /* | 52 | /* |
53 | * disconnect the dataflow | 53 | * disconnect the dataflow |
54 | * this will be done for ft | 54 | * this will be done for ft |
55 | */ | 55 | */ |
56 | void disconnect(); | 56 | void disconnect(); |
57 | 57 | ||
58 | void setWidgetStack( QWidgetStack* widget ); | 58 | void setWidgetStack( QWidgetStack* widget ); |
59 | void setEmulationHandler( EmulationHandler* lay ); | 59 | void setEmulationHandler( EmulationHandler* lay ); |
60 | void setIOLayer( IOLayer* ); | 60 | void setIOLayer( IOLayer* ); |
61 | void setName( const QString& ); | 61 | void setName( const QString& ); |
62 | 62 | ||
63 | bool isConnected(); | ||
64 | |||
65 | private: | 63 | private: |
66 | QString m_name; | 64 | QString m_name; |
67 | QWidgetStack* m_widget; | 65 | QWidgetStack* m_widget; |
68 | IOLayer* m_layer; | 66 | IOLayer* m_layer; |
69 | EmulationHandler* m_emu; | 67 | EmulationHandler* m_emu; |
70 | bool m_connected; | 68 | bool m_connected; |
71 | 69 | ||
72 | }; | 70 | }; |
73 | 71 | ||
74 | #endif | 72 | #endif |