summaryrefslogtreecommitdiff
authorjosef <josef>2002-10-15 22:36:10 (UTC)
committer josef <josef>2002-10-15 22:36:10 (UTC)
commit65ef0e86a879332cbf8b1575886d3c36c7d2d9bd (patch) (unidiff)
treeb0b3f192c52dc15d639977e1d592412531d826eb
parent626b45872e1774b694727792f7306a39277e413e (diff)
downloadopie-65ef0e86a879332cbf8b1575886d3c36c7d2d9bd.zip
opie-65ef0e86a879332cbf8b1575886d3c36c7d2d9bd.tar.gz
opie-65ef0e86a879332cbf8b1575886d3c36c7d2d9bd.tar.bz2
- 3 small fixes, please review:
- disable all relevant menu items when last session has been closed (but this might not be the correct bugfix, so consider it temporary) - don't set menu status to connected when connection fails - modem sessions: when user cancels connection, close serial connection first again, so we can reconnect (re-dial) later without problems
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/io_modem.cpp6
-rw-r--r--noncore/apps/opie-console/io_serial.cpp1
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp10
3 files changed, 13 insertions, 4 deletions
diff --git a/noncore/apps/opie-console/io_modem.cpp b/noncore/apps/opie-console/io_modem.cpp
index 22a3673..41f553b 100644
--- a/noncore/apps/opie-console/io_modem.cpp
+++ b/noncore/apps/opie-console/io_modem.cpp
@@ -1,78 +1,82 @@
1 1
2#include "io_modem.h" 2#include "io_modem.h"
3 3
4#include "dialer.h" 4#include "dialer.h"
5 5
6IOModem::IOModem( const Profile &profile ) 6IOModem::IOModem( const Profile &profile )
7 : IOSerial( profile ) { 7 : IOSerial( profile ) {
8 m_profile = profile; 8 m_profile = profile;
9} 9}
10 10
11 11
12IOModem::~IOModem() { 12IOModem::~IOModem() {
13 13
14} 14}
15 15
16 16
17void IOModem::close() { 17void IOModem::close() {
18 // maybe do a hangup here just in case...? 18 // maybe do a hangup here just in case...?
19 19
20 IOSerial::close(); 20 IOSerial::close();
21} 21}
22 22
23bool IOModem::open() { 23bool IOModem::open() {
24 bool ret = IOSerial::open(); 24 bool ret = IOSerial::open();
25 if(!ret) return false; 25 if(!ret) return false;
26 26
27 Dialer d(m_profile); 27 Dialer d(m_profile);
28 28
29 int result = d.exec(); 29 int result = d.exec();
30 if(result == QDialog::Accepted) 30 if(result == QDialog::Accepted)
31 { 31 {
32 return true; 32 return true;
33 } 33 }
34 else return false; 34 else
35 {
36 close();
37 return false;
38 }
35} 39}
36 40
37void IOModem::reload( const Profile &config ) { 41void IOModem::reload( const Profile &config ) {
38 42
39 m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE); 43 m_device = config.readEntry("Device", MODEM_DEFAULT_DEVICE);
40 m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD); 44 m_baud = config.readNumEntry("Baud", MODEM_DEFAULT_BAUD);
41 m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY); 45 m_parity = config.readNumEntry("Parity", MODEM_DEFAULT_PARITY);
42 m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS); 46 m_dbits = config.readNumEntry("DataBits", MODEM_DEFAULT_DBITS);
43 m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS); 47 m_sbits = config.readNumEntry("StopBits", MODEM_DEFAULT_SBITS);
44 m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW); 48 m_flow = config.readNumEntry("Flow", MODEM_DEFAULT_FLOW);
45 49
46 m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ); 50 m_initString = config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING );
47 m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ); 51 m_resetString = config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING );
48 m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ); 52 m_dialPref1 = config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 );
49 m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ); 53 m_dialSuf1 = config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 );
50 m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ); 54 m_dialPref2 = config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 );
51 m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ); 55 m_dialSuf2 = config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 );
52 m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ); 56 m_dialPref3 = config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 );
53 m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ); 57 m_dialSuf3 = config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 );
54 m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING ); 58 m_connect = config.readEntry("DefaultConnect" MODEM_DEFAULT_CONNECT_STRING );
55 m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ); 59 m_hangup = config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING );
56 m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING ); 60 m_cancel = config.readEntry("CancelString", MODEM_DEFAULT_CANCEL_STRING );
57 m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ); 61 m_dialTime = config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME );
58 m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ); 62 m_delayRedial = config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL );
59 m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ); 63 m_numberTries = config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES );
60 m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ); 64 m_dtrDropTime = config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME );
61 m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ); 65 m_bpsDetect = config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT );
62 m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ); 66 m_dcdLines = config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES );
63 m_multiLineUntag = config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ); 67 m_multiLineUntag = config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG );
64} 68}
65 69
66 70
67QString IOModem::identifier() const { 71QString IOModem::identifier() const {
68 return "modem"; 72 return "modem";
69} 73}
70 74
71QString IOModem::name() const { 75QString IOModem::name() const {
72 return "Modem IO Layer"; 76 return "Modem IO Layer";
73} 77}
74 78
75void IOModem::slotExited(OProcess* proc ){ 79void IOModem::slotExited(OProcess* proc ){
76 close(); 80 close();
77} 81}
78 82
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp
index b89a53b..cc63c58 100644
--- a/noncore/apps/opie-console/io_serial.cpp
+++ b/noncore/apps/opie-console/io_serial.cpp
@@ -1,204 +1,205 @@
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
7IOSerial::IOSerial(const Profile &config) : IOLayer(config) { 7IOSerial::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 m_connected = false;
12 reload(config); 12 reload(config);
13} 13}
14 14
15 15
16IOSerial::~IOSerial() { 16IOSerial::~IOSerial() {
17 if (m_fd) { 17 if (m_fd) {
18 close(); 18 close();
19 } 19 }
20} 20}
21 21
22void IOSerial::send(const QByteArray &data) { 22void IOSerial::send(const QByteArray &data) {
23 if (m_fd) { 23 if (m_fd) {
24 write(m_fd, data.data(), data.size()); 24 write(m_fd, data.data(), data.size());
25 } else { 25 } else {
26 emit error(Refuse, tr("Not connected")); 26 emit error(Refuse, tr("Not connected"));
27 } 27 }
28} 28}
29 29
30void IOSerial::close() { 30void IOSerial::close() {
31 if (m_fd) { 31 if (m_fd) {
32 delete m_read; 32 delete m_read;
33 delete m_error; 33 delete m_error;
34 ::close(m_fd); 34 ::close(m_fd);
35 m_fd = 0; 35 m_fd = 0;
36 m_connected = false; 36 m_connected = false;
37 } else { 37 } else {
38 m_connected = false; 38 m_connected = false;
39 emit error(Refuse, tr("Not connected")); 39 emit error(Refuse, tr("Not connected"));
40 } 40 }
41} 41}
42 42
43bool IOSerial::open() { 43bool IOSerial::open() {
44 if (!m_fd) { 44 if (!m_fd) {
45 struct termios tty; 45 struct termios tty;
46 m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK); 46 m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK);
47 if (m_fd < 0) { 47 if (m_fd < 0) {
48 emit error(CouldNotOpen, strerror(errno)); 48 emit error(CouldNotOpen, strerror(errno));
49 m_fd = 0;
49 return FALSE; 50 return FALSE;
50 } 51 }
51 tcgetattr(m_fd, &tty); 52 tcgetattr(m_fd, &tty);
52 53
53 /* Baud rate */ 54 /* Baud rate */
54 int speed = baud(m_baud); 55 int speed = baud(m_baud);
55 if (speed == -1) { 56 if (speed == -1) {
56 emit error(Refuse, tr("Invalid baud rate")); 57 emit error(Refuse, tr("Invalid baud rate"));
57 } 58 }
58 cfsetospeed(&tty, speed); 59 cfsetospeed(&tty, speed);
59 cfsetispeed(&tty, speed); 60 cfsetispeed(&tty, speed);
60 61
61 /* Take care of Space / Mark parity */ 62 /* Take care of Space / Mark parity */
62 if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) { 63 if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) {
63 m_dbits = 8; 64 m_dbits = 8;
64 } 65 }
65 66
66 /* Data bits */ 67 /* Data bits */
67 switch (m_dbits) { 68 switch (m_dbits) {
68 case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break; 69 case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break;
69 case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break; 70 case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break;
70 case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break; 71 case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break;
71 case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break; 72 case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break;
72 default: break; 73 default: break;
73 } 74 }
74 75
75 /* Raw, no echo mode */ 76 /* Raw, no echo mode */
76 tty.c_iflag = IGNBRK; 77 tty.c_iflag = IGNBRK;
77 tty.c_lflag = 0; 78 tty.c_lflag = 0;
78 tty.c_oflag = 0; 79 tty.c_oflag = 0;
79 tty.c_cflag |= CLOCAL | CREAD; 80 tty.c_cflag |= CLOCAL | CREAD;
80 81
81 /* Stop bits */ 82 /* Stop bits */
82 if (m_sbits == 2) { 83 if (m_sbits == 2) {
83 tty.c_cflag |= CSTOPB; 84 tty.c_cflag |= CSTOPB;
84 } else { 85 } else {
85 tty.c_cflag &= ~CSTOPB; 86 tty.c_cflag &= ~CSTOPB;
86 } 87 }
87 88
88 tty.c_cc[VMIN] = 1; 89 tty.c_cc[VMIN] = 1;
89 tty.c_cc[VTIME] = 5; 90 tty.c_cc[VTIME] = 5;
90 91
91 /* Flow control */ 92 /* Flow control */
92 if (m_flow & FlowSW) 93 if (m_flow & FlowSW)
93 tty.c_iflag |= IXON | IXOFF; 94 tty.c_iflag |= IXON | IXOFF;
94 else 95 else
95 tty.c_iflag &= ~(IXON|IXOFF|IXANY); 96 tty.c_iflag &= ~(IXON|IXOFF|IXANY);
96 97
97 if (m_flow & FlowHW) 98 if (m_flow & FlowHW)
98 tty.c_cflag |= CRTSCTS; 99 tty.c_cflag |= CRTSCTS;
99 else 100 else
100 tty.c_cflag &= ~CRTSCTS; 101 tty.c_cflag &= ~CRTSCTS;
101 102
102 /* Parity */ 103 /* Parity */
103 tty.c_cflag &= ~(PARENB | PARODD); 104 tty.c_cflag &= ~(PARENB | PARODD);
104 if (m_parity & ParityEven) 105 if (m_parity & ParityEven)
105 tty.c_cflag |= PARENB; 106 tty.c_cflag |= PARENB;
106 else if (m_parity & ParityOdd) 107 else if (m_parity & ParityOdd)
107 tty.c_cflag |= (PARENB | PARODD); 108 tty.c_cflag |= (PARENB | PARODD);
108 109
109 /* Set the changes */ 110 /* Set the changes */
110 tcsetattr(m_fd, TCSANOW, &tty); 111 tcsetattr(m_fd, TCSANOW, &tty);
111 112
112 /* Notifications on read & errors */ 113 /* Notifications on read & errors */
113 m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); 114 m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
114 m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this); 115 m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this);
115 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); 116 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
116 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); 117 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
117 m_connected = false; 118 m_connected = false;
118 return TRUE; 119 return TRUE;
119 } else { 120 } else {
120 emit error(Refuse, tr("Device is already connected")); 121 emit error(Refuse, tr("Device is already connected"));
121 m_fd = 0; 122 m_fd = 0;
122 return FALSE; 123 return FALSE;
123 } 124 }
124} 125}
125 126
126void IOSerial::reload(const Profile &config) { 127void IOSerial::reload(const Profile &config) {
127 m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); 128 m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE);
128 m_baud = config.readNumEntry("Speed", SERIAL_DEFAULT_BAUD); 129 m_baud = config.readNumEntry("Speed", SERIAL_DEFAULT_BAUD);
129 m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY); 130 m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY);
130 m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS); 131 m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS);
131 m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS); 132 m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS);
132 m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW); 133 m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW);
133 134
134} 135}
135 136
136int IOSerial::baud(int baud) const { 137int IOSerial::baud(int baud) const {
137 switch (baud) { 138 switch (baud) {
138 case 300: return B300; break; 139 case 300: return B300; break;
139 case 600: return B600; break; 140 case 600: return B600; break;
140 case 1200: return B1200; break; 141 case 1200: return B1200; break;
141 case 2400: return B2400; break; 142 case 2400: return B2400; break;
142 case 4800: return B4800; break; 143 case 4800: return B4800; break;
143 case 9600: return B9600; break; 144 case 9600: return B9600; break;
144 case 19200: return B19200; break; 145 case 19200: return B19200; break;
145 case 38400: return B38400; break; 146 case 38400: return B38400; break;
146 case 57600: return B57600; break; 147 case 57600: return B57600; break;
147 case 115200: return B115200; break; 148 case 115200: return B115200; break;
148 } 149 }
149 return -1; 150 return -1;
150} 151}
151 152
152void IOSerial::errorOccured() { 153void IOSerial::errorOccured() {
153 emit error(ClosedUnexpected, strerror(errno)); 154 emit error(ClosedUnexpected, strerror(errno));
154 close(); 155 close();
155} 156}
156 157
157void IOSerial::dataArrived() { 158void IOSerial::dataArrived() {
158 QByteArray array(4097); 159 QByteArray array(4097);
159 160
160 int len = read(m_fd, array.data(), 4096); 161 int len = read(m_fd, array.data(), 4096);
161 if (len == 0) 162 if (len == 0)
162 close(); 163 close();
163 if (len < 0) 164 if (len < 0)
164 return; 165 return;
165 array.resize( len ); 166 array.resize( len );
166 emit received(array); 167 emit received(array);
167} 168}
168 169
169QString IOSerial::identifier() const { 170QString IOSerial::identifier() const {
170 return "serial"; 171 return "serial";
171} 172}
172 173
173QString IOSerial::name() const { 174QString IOSerial::name() const {
174 return "RS232 Serial IO Layer"; 175 return "RS232 Serial IO Layer";
175} 176}
176int IOSerial::rawIO()const { 177int IOSerial::rawIO()const {
177 if (m_read ) 178 if (m_read )
178 disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); 179 disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
179 if (m_error ) 180 if (m_error )
180 disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); 181 disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
181 182
182 int fd = ::open(m_device, O_RDWR ); 183 int fd = ::open(m_device, O_RDWR );
183 184
184 return fd; 185 return fd;
185}; 186};
186void IOSerial::closeRawIO(int fd) { 187void IOSerial::closeRawIO(int fd) {
187 if (m_read ) 188 if (m_read )
188 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); 189 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
189 if (m_error ) 190 if (m_error )
190 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); 191 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
191 192
192 ::close( fd ); 193 ::close( fd );
193} 194}
194QBitArray IOSerial::supports()const { 195QBitArray IOSerial::supports()const {
195 QBitArray ar(3); 196 QBitArray ar(3);
196 ar[0] = ar[2] = 0; 197 ar[0] = ar[2] = 0;
197 ar[1] = 1; 198 ar[1] = 1;
198 199
199 return ar; 200 return ar;
200} 201}
201 202
202bool IOSerial::isConnected() { 203bool IOSerial::isConnected() {
203 return m_connected; 204 return m_connected;
204} 205}
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 4326609..9ccefa0 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,494 +1,498 @@
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
32static char * menu_xpm[] = { 32static 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
53MainWindow::MainWindow() { 53MainWindow::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}
69void MainWindow::initUI() { 69void 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
236ProfileManager* MainWindow::manager() { 236ProfileManager* MainWindow::manager() {
237 return m_manager; 237 return m_manager;
238} 238}
239TabWidget* MainWindow::tabWidget() { 239TabWidget* MainWindow::tabWidget() {
240 return m_consoleWindow; 240 return m_consoleWindow;
241} 241}
242void MainWindow::populateProfiles() { 242void 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}
250MainWindow::~MainWindow() { 250MainWindow::~MainWindow() {
251 delete m_factory; 251 delete m_factory;
252 manager()->save(); 252 manager()->save();
253} 253}
254 254
255MetaFactory* MainWindow::factory() { 255MetaFactory* MainWindow::factory() {
256 return m_factory; 256 return m_factory;
257} 257}
258 258
259Session* MainWindow::currentSession() { 259Session* MainWindow::currentSession() {
260 return m_curSession; 260 return m_curSession;
261} 261}
262 262
263QList<Session> MainWindow::sessions() { 263QList<Session> MainWindow::sessions() {
264 return m_sessions; 264 return m_sessions;
265} 265}
266 266
267void MainWindow::slotNew() { 267void 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
277void MainWindow::slotRecordScript() { 277void MainWindow::slotRecordScript() {
278/* if (currentSession()) { 278/* if (currentSession()) {
279 currentSession()->emulationLayer()->startRecording(); 279 currentSession()->emulationLayer()->startRecording();
280 } 280 }
281 */ 281 */
282} 282}
283 283
284void MainWindow::slotSaveScript() { 284void 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
299void MainWindow::slotRunScript() { 299void 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
315void MainWindow::slotConnect() { 315void 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 else {
322 m_disconnect->setEnabled( true ); 322 m_connect->setEnabled( false );
323 m_disconnect->setEnabled( true );
324 }
323 } 325 }
324} 326}
325 327
326void MainWindow::slotDisconnect() { 328void MainWindow::slotDisconnect() {
327 if ( currentSession() ) { 329 if ( currentSession() ) {
328 currentSession()->layer()->close(); 330 currentSession()->layer()->close();
329 m_connect->setEnabled( true ); 331 m_connect->setEnabled( true );
330 m_disconnect->setEnabled( false ); 332 m_disconnect->setEnabled( false );
331 } 333 }
332} 334}
333 335
334void MainWindow::slotTerminate() { 336void MainWindow::slotTerminate() {
335 if ( currentSession() ) 337 if ( currentSession() )
336 currentSession()->layer()->close(); 338 currentSession()->layer()->close();
337 339
338 slotClose(); 340 slotClose();
339 /* FIXME move to the next session */ 341 /* FIXME move to the next session */
340} 342}
341 343
342void MainWindow::slotConfigure() { 344void MainWindow::slotConfigure() {
343 ConfigDialog conf( manager()->all(), factory() ); 345 ConfigDialog conf( manager()->all(), factory() );
344 conf.showMaximized(); 346 conf.showMaximized();
345 347
346 int ret = conf.exec(); 348 int ret = conf.exec();
347 349
348 if ( QDialog::Accepted == ret ) { 350 if ( QDialog::Accepted == ret ) {
349 manager()->setProfiles( conf.list() ); 351 manager()->setProfiles( conf.list() );
350 manager()->save(); 352 manager()->save();
351 populateProfiles(); 353 populateProfiles();
352 } 354 }
353} 355}
354/* 356/*
355 * we will remove 357 * we will remove
356 * this window from the tabwidget 358 * this window from the tabwidget
357 * remove it from the list 359 * remove it from the list
358 * delete it 360 * delete it
359 * and set the currentSession() 361 * and set the currentSession()
360 */ 362 */
361void MainWindow::slotClose() { 363void MainWindow::slotClose() {
362 if (!currentSession() ) 364 if (!currentSession() )
363 return; 365 return;
364 366
365 Session* ses = currentSession(); 367 Session* ses = currentSession();
366 qWarning("removing! currentSession %s", currentSession()->name().latin1() ); 368 qWarning("removing! currentSession %s", currentSession()->name().latin1() );
367 tabWidget()->remove( currentSession() ); 369 /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
370 m_curSession = NULL;
371 tabWidget()->remove( /*currentSession()*/ses );
368 /*it's autodelete */ 372 /*it's autodelete */
369 m_sessions.remove( ses ); 373 m_sessions.remove( ses );
370 qWarning("after remove!!"); 374 qWarning("after remove!!");
371 375
372 if (!currentSession() ) { 376 if (!currentSession() ) {
373 m_connect->setEnabled( false ); 377 m_connect->setEnabled( false );
374 m_disconnect->setEnabled( false ); 378 m_disconnect->setEnabled( false );
375 m_terminate->setEnabled( false ); 379 m_terminate->setEnabled( false );
376 m_transfer->setEnabled( false ); 380 m_transfer->setEnabled( false );
377 m_recordScript->setEnabled( false ); 381 m_recordScript->setEnabled( false );
378 m_saveScript->setEnabled( false ); 382 m_saveScript->setEnabled( false );
379 m_runScript->setEnabled( false ); 383 m_runScript->setEnabled( false );
380 m_fullscreen->setEnabled( false ); 384 m_fullscreen->setEnabled( false );
381 m_closewindow->setEnabled( false ); 385 m_closewindow->setEnabled( false );
382 } 386 }
383} 387}
384 388
385/* 389/*
386 * We will get the name 390 * We will get the name
387 * Then the profile 391 * Then the profile
388 * and then we will make a profile 392 * and then we will make a profile
389 */ 393 */
390void MainWindow::slotProfile( int id) { 394void MainWindow::slotProfile( int id) {
391 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 395 Profile prof = manager()->profile( m_sessionsPop->text( id) );
392 create( prof ); 396 create( prof );
393} 397}
394void MainWindow::create( const Profile& prof ) { 398void MainWindow::create( const Profile& prof ) {
395 Session *ses = manager()->fromProfile( prof, tabWidget() ); 399 Session *ses = manager()->fromProfile( prof, tabWidget() );
396 400
397 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 401 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
398 { 402 {
399 QMessageBox::warning(this, 403 QMessageBox::warning(this,
400 QObject::tr("Session failed"), 404 QObject::tr("Session failed"),
401 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); 405 QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
402 //if(ses) delete ses; 406 //if(ses) delete ses;
403 return; 407 return;
404 } 408 }
405 409
406 m_sessions.append( ses ); 410 m_sessions.append( ses );
407 tabWidget()->add( ses ); 411 tabWidget()->add( ses );
408 m_curSession = ses; 412 m_curSession = ses;
409 413
410 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 414 // 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 ); 415 m_connect->setEnabled( true );
412 m_disconnect->setEnabled( false ); 416 m_disconnect->setEnabled( false );
413 m_terminate->setEnabled( true ); 417 m_terminate->setEnabled( true );
414 m_transfer->setEnabled( true ); 418 m_transfer->setEnabled( true );
415 m_recordScript->setEnabled( true ); 419 m_recordScript->setEnabled( true );
416 m_saveScript->setEnabled( true ); 420 m_saveScript->setEnabled( true );
417 m_runScript->setEnabled( true ); 421 m_runScript->setEnabled( true );
418 m_fullscreen->setEnabled( true ); 422 m_fullscreen->setEnabled( true );
419 m_closewindow->setEnabled( true ); 423 m_closewindow->setEnabled( true );
420} 424}
421 425
422void MainWindow::slotTransfer() 426void MainWindow::slotTransfer()
423{ 427{
424 if ( currentSession() ) { 428 if ( currentSession() ) {
425 TransferDialog dlg(this); 429 TransferDialog dlg(this);
426 dlg.showMaximized(); 430 dlg.showMaximized();
427 dlg.exec(); 431 dlg.exec();
428 } 432 }
429} 433}
430 434
431 435
432void MainWindow::slotOpenKeb(bool state) { 436void MainWindow::slotOpenKeb(bool state) {
433 437
434 if (state) m_keyBar->show(); 438 if (state) m_keyBar->show();
435 else m_keyBar->hide(); 439 else m_keyBar->hide();
436 440
437} 441}
438void MainWindow::slotSessionChanged( Session* ses ) { 442void MainWindow::slotSessionChanged( Session* ses ) {
439 qWarning("changed!"); 443 qWarning("changed!");
440 if ( ses ) { 444 if ( ses ) {
441 m_curSession = ses; 445 m_curSession = ses;
442 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); 446 qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) );
443 if ( m_curSession->layer()->isConnected() ) { 447 if ( m_curSession->layer()->isConnected() ) {
444 m_connect->setEnabled( false ); 448 m_connect->setEnabled( false );
445 m_disconnect->setEnabled( true ); 449 m_disconnect->setEnabled( true );
446 } else { 450 } else {
447 m_connect->setEnabled( true ); 451 m_connect->setEnabled( true );
448 m_disconnect->setEnabled( false ); 452 m_disconnect->setEnabled( false );
449 } 453 }
450 } 454 }
451} 455}
452 456
453void MainWindow::slotFullscreen() { 457void MainWindow::slotFullscreen() {
454 458
455 if ( m_isFullscreen ) { 459 if ( m_isFullscreen ) {
456 ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); 460 ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false );
457 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 461 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken );
458 setCentralWidget( m_consoleWindow ); 462 setCentralWidget( m_consoleWindow );
459 ( m_curSession->widgetStack() )->show(); 463 ( m_curSession->widgetStack() )->show();
460 m_fullscreen->setText( tr("Full screen") ); 464 m_fullscreen->setText( tr("Full screen") );
461 465
462 } else { 466 } else {
463 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 467 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
464 ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, 468 ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop,
465 QPoint(0,0), false); 469 QPoint(0,0), false);
466 ( m_curSession->widgetStack() )->resize(qApp->desktop()->width(), qApp->desktop()->height()); 470 ( m_curSession->widgetStack() )->resize(qApp->desktop()->width(), qApp->desktop()->height());
467 ( m_curSession->widgetStack() )->setFocus(); 471 ( m_curSession->widgetStack() )->setFocus();
468 ( m_curSession->widgetStack() )->show(); 472 ( m_curSession->widgetStack() )->show();
469 473
470 //QPushButton *cornerButton = new QPushButton( ); 474 //QPushButton *cornerButton = new QPushButton( );
471 //cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); 475 //cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) );
472 //connect( cornerButton, SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 476 //connect( cornerButton, SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
473 // need teh scrollbar 477 // need teh scrollbar
474 // ( m_curSession->widgetStack() )->setCornerWidget( cornerButton ); 478 // ( m_curSession->widgetStack() )->setCornerWidget( cornerButton );
475 m_fullscreen->setText( tr("Stop full screen") ); 479 m_fullscreen->setText( tr("Stop full screen") );
476 } 480 }
477 481
478 m_isFullscreen = !m_isFullscreen; 482 m_isFullscreen = !m_isFullscreen;
479 483
480} 484}
481 485
482 486
483void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool, bool) { 487void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool, bool) {
484 488
485 qWarning("received key event! relay to TE widget"); 489 qWarning("received key event! relay to TE widget");
486 490
487 if ( m_curSession ) { 491 if ( m_curSession ) {
488 QKeyEvent ke(QEvent::KeyPress, q, u, 0); 492 QKeyEvent ke(QEvent::KeyPress, q, u, 0);
489 493
490 ke.ignore(); 494 ke.ignore();
491 // where should i send this event? doesnt work sending it here 495 // where should i send this event? doesnt work sending it here
492 QApplication::sendEvent((QObject *)m_curSession->widgetStack(), &ke); 496 QApplication::sendEvent((QObject *)m_curSession->widgetStack(), &ke);
493 } 497 }
494} 498}