summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-15 10:55:58 (UTC)
committer zecke <zecke>2002-10-15 10:55:58 (UTC)
commitf2e9de1c8b6d3b2b2e82dec23ebf502c5805f575 (patch) (unidiff)
tree108efdb1a75a78dd212a69ccad718c2e65ece0bf
parentdaae7a75b0e9ccbf1ea4c699c631ad77825e6301 (diff)
downloadopie-f2e9de1c8b6d3b2b2e82dec23ebf502c5805f575.zip
opie-f2e9de1c8b6d3b2b2e82dec23ebf502c5805f575.tar.gz
opie-f2e9de1c8b6d3b2b2e82dec23ebf502c5805f575.tar.bz2
Remove debugging output
Fix possible crashes in io_bt and io_irda
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/MyPty.cpp6
-rw-r--r--noncore/apps/opie-console/configdialog.cpp1
-rw-r--r--noncore/apps/opie-console/emulation_handler.cpp6
-rw-r--r--noncore/apps/opie-console/filereceive.cpp2
-rw-r--r--noncore/apps/opie-console/filetransfer.cpp6
-rw-r--r--noncore/apps/opie-console/io_bt.cpp1
-rw-r--r--noncore/apps/opie-console/io_irda.cpp2
-rw-r--r--noncore/apps/opie-console/io_serial.cpp8
-rw-r--r--noncore/apps/opie-console/iolayerbase.cpp3
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp5
-rw-r--r--noncore/apps/opie-console/metafactory.cpp1
-rw-r--r--noncore/apps/opie-console/procctl.cpp1
-rw-r--r--noncore/apps/opie-console/profile.cpp2
-rw-r--r--noncore/apps/opie-console/profileconfig.cpp1
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp7
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp4
-rw-r--r--noncore/apps/opie-console/session.cpp1
-rw-r--r--noncore/apps/opie-console/tabwidget.cpp1
18 files changed, 3 insertions, 55 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp
index ae01392..b6ae1d9 100644
--- a/noncore/apps/opie-console/MyPty.cpp
+++ b/noncore/apps/opie-console/MyPty.cpp
@@ -21,295 +21,289 @@
21*/ 21*/
22 22
23/*! \file 23/*! \file
24*/ 24*/
25 25
26/*! \class TEPty 26/*! \class TEPty
27 27
28 \brief Ptys provide a pseudo terminal connection to a program. 28 \brief Ptys provide a pseudo terminal connection to a program.
29 29
30 Although closely related to pipes, these pseudo terminal connections have 30 Although closely related to pipes, these pseudo terminal connections have
31 some ability, that makes it nessesary to uses them. Most importent, they 31 some ability, that makes it nessesary to uses them. Most importent, they
32 know about changing screen sizes and UNIX job control. 32 know about changing screen sizes and UNIX job control.
33 33
34 Within the terminal emulation framework, this class represents the 34 Within the terminal emulation framework, this class represents the
35 host side of the terminal together with the connecting serial line. 35 host side of the terminal together with the connecting serial line.
36 36
37 One can create many instances of this class within a program. 37 One can create many instances of this class within a program.
38 As a side effect of using this class, a signal(2) handler is 38 As a side effect of using this class, a signal(2) handler is
39 installed on SIGCHLD. 39 installed on SIGCHLD.
40 40
41 \par FIXME 41 \par FIXME
42 42
43 [NOTE: much of the technical stuff below will be replaced by forkpty.] 43 [NOTE: much of the technical stuff below will be replaced by forkpty.]
44 44
45 publish the SIGCHLD signal if not related to an instance. 45 publish the SIGCHLD signal if not related to an instance.
46 46
47 clearify TEPty::done vs. TEPty::~TEPty semantics. 47 clearify TEPty::done vs. TEPty::~TEPty semantics.
48 check if pty is restartable via run after done. 48 check if pty is restartable via run after done.
49 49
50 \par Pseudo terminals 50 \par Pseudo terminals
51 51
52 Pseudo terminals are a unique feature of UNIX, and always come in form of 52 Pseudo terminals are a unique feature of UNIX, and always come in form of
53 pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each 53 pairs of devices (/dev/ptyXX and /dev/ttyXX), which are connected to each
54 other by the operating system. One may think of them as two serial devices 54 other by the operating system. One may think of them as two serial devices
55 linked by a null-modem cable. Being based on devices the number of 55 linked by a null-modem cable. Being based on devices the number of
56 simultanous instances of this class is (globally) limited by the number of 56 simultanous instances of this class is (globally) limited by the number of
57 those device pairs, which is 256. 57 those device pairs, which is 256.
58 58
59 Another technic are UNIX 98 PTY's. These are supported also, and prefered 59 Another technic are UNIX 98 PTY's. These are supported also, and prefered
60 over the (obsolete) predecessor. 60 over the (obsolete) predecessor.
61 61
62 There's a sinister ioctl(2), signal(2) and job control stuff 62 There's a sinister ioctl(2), signal(2) and job control stuff
63 nessesary to make everything work as it should. 63 nessesary to make everything work as it should.
64*/ 64*/
65 65
66 66
67#include <qapplication.h> 67#include <qapplication.h>
68#include <qsocketnotifier.h> 68#include <qsocketnotifier.h>
69#include <qstring.h> 69#include <qstring.h>
70 70
71#include <stdlib.h> 71#include <stdlib.h>
72#include <stdio.h> 72#include <stdio.h>
73#include <signal.h> 73#include <signal.h>
74#include <fcntl.h> 74#include <fcntl.h>
75#include <unistd.h> 75#include <unistd.h>
76#include <termios.h> 76#include <termios.h>
77#include <sys/types.h> 77#include <sys/types.h>
78#include <sys/ioctl.h> 78#include <sys/ioctl.h>
79#include <sys/wait.h> 79#include <sys/wait.h>
80 80
81#ifdef HAVE_OPENPTY 81#ifdef HAVE_OPENPTY
82#include <pty.h> 82#include <pty.h>
83#endif 83#endif
84 84
85#include "procctl.h" 85#include "procctl.h"
86#include "MyPty.h" 86#include "MyPty.h"
87 87
88 88
89#undef VERBOSE_DEBUG 89#undef VERBOSE_DEBUG
90 90
91 91
92/* -------------------------------------------------------------------------- */ 92/* -------------------------------------------------------------------------- */
93 93
94/*! 94/*!
95 Informs the client program about the 95 Informs the client program about the
96 actual size of the window. 96 actual size of the window.
97*/ 97*/
98 98
99void MyPty::setSize(int lines, int columns) 99void MyPty::setSize(int lines, int columns)
100{ 100{
101 struct winsize wsize; 101 struct winsize wsize;
102 wsize.ws_row = (unsigned short)lines; 102 wsize.ws_row = (unsigned short)lines;
103 wsize.ws_col = (unsigned short)columns; 103 wsize.ws_col = (unsigned short)columns;
104 if(m_fd < 0) return; 104 if(m_fd < 0) return;
105 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize); 105 ioctl(m_fd,TIOCSWINSZ,(char *)&wsize);
106} 106}
107 107
108 108
109void MyPty::donePty() 109void MyPty::donePty()
110{ 110{
111 // This is code from the Qt DumbTerminal example 111 // This is code from the Qt DumbTerminal example
112 int status = 0; 112 int status = 0;
113 113
114 ::close(m_fd); 114 ::close(m_fd);
115 115
116 if (m_cpid) { 116 if (m_cpid) {
117 qWarning("killing!!!");
118 kill(m_cpid, SIGHUP); 117 kill(m_cpid, SIGHUP);
119 //waitpid(m_cpid, &status, 0); 118 //waitpid(m_cpid, &status, 0);
120 delete m_sn_e; 119 delete m_sn_e;
121 m_sn_e = 0l; 120 m_sn_e = 0l;
122 } 121 }
123 122
124 m_cpid = 0; 123 m_cpid = 0;
125// emit done(status); 124// emit done(status);
126} 125}
127 126
128 127
129const char* MyPty::deviceName() 128const char* MyPty::deviceName()
130{ 129{
131 return m_ttynam; 130 return m_ttynam;
132} 131}
133 132
134 133
135void MyPty::error() 134void MyPty::error()
136{ 135{
137 qWarning("error");
138 // This is code from the Qt DumbTerminal example 136 // This is code from the Qt DumbTerminal example
139 donePty(); 137 donePty();
140} 138}
141 139
142void MyPty::start() { 140void MyPty::start() {
143 char* cmd = "/bin/sh"; 141 char* cmd = "/bin/sh";
144 QStrList lis; 142 QStrList lis;
145 int r =run(cmd, lis, 0, 0); 143 int r =run(cmd, lis, 0, 0);
146 r = r; 144 r = r;
147} 145}
148/*! 146/*!
149 start the client program. 147 start the client program.
150*/ 148*/
151int MyPty::run(const char* cmd, QStrList &, const char*, int) 149int MyPty::run(const char* cmd, QStrList &, const char*, int)
152{ 150{
153 // This is code from the Qt DumbTerminal example 151 // This is code from the Qt DumbTerminal example
154 m_cpid = fork(); 152 m_cpid = fork();
155 153
156 if ( !m_cpid ) { 154 if ( !m_cpid ) {
157 // child - exec shell on tty 155 // child - exec shell on tty
158 for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); 156 for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL);
159 int ttyfd = ::open(m_ttynam, O_RDWR); 157 int ttyfd = ::open(m_ttynam, O_RDWR);
160 dup2(ttyfd, STDIN_FILENO); 158 dup2(ttyfd, STDIN_FILENO);
161 dup2(ttyfd, STDOUT_FILENO); 159 dup2(ttyfd, STDOUT_FILENO);
162 dup2(ttyfd, STDERR_FILENO); 160 dup2(ttyfd, STDERR_FILENO);
163 // should be done with tty, so close it 161 // should be done with tty, so close it
164 ::close(ttyfd); 162 ::close(ttyfd);
165 static struct termios ttmode; 163 static struct termios ttmode;
166 if ( setsid() < 0 ) 164 if ( setsid() < 0 )
167 perror( "failed to set process group" ); 165 perror( "failed to set process group" );
168#if defined (TIOCSCTTY) 166#if defined (TIOCSCTTY)
169 // grabbed from APUE by Stevens 167 // grabbed from APUE by Stevens
170 ioctl(STDIN_FILENO, TIOCSCTTY, 0); 168 ioctl(STDIN_FILENO, TIOCSCTTY, 0);
171#endif 169#endif
172 tcgetattr( STDIN_FILENO, &ttmode ); 170 tcgetattr( STDIN_FILENO, &ttmode );
173 ttmode.c_cc[VINTR] = 3; 171 ttmode.c_cc[VINTR] = 3;
174 ttmode.c_cc[VERASE] = 8; 172 ttmode.c_cc[VERASE] = 8;
175 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); 173 tcsetattr( STDIN_FILENO, TCSANOW, &ttmode );
176 setenv("TERM","vt100",1); 174 setenv("TERM","vt100",1);
177 setenv("COLORTERM","0",1); 175 setenv("COLORTERM","0",1);
178 176
179 if (getuid() == 0) { 177 if (getuid() == 0) {
180 char msg[] = "WARNING: You are running this shell as root!\n"; 178 char msg[] = "WARNING: You are running this shell as root!\n";
181 write(ttyfd, msg, sizeof(msg)); 179 write(ttyfd, msg, sizeof(msg));
182 } 180 }
183 execl(cmd, cmd, 0); 181 execl(cmd, cmd, 0);
184 182
185 donePty(); 183 donePty();
186 exit(-1); 184 exit(-1);
187 } 185 }
188 186
189 // parent - continue as a widget 187 // parent - continue as a widget
190 QSocketNotifier* sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); 188 QSocketNotifier* sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this);
191 delete m_sn_e; 189 delete m_sn_e;
192 m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); 190 m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this);
193 connect(sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); 191 connect(sn_r,SIGNAL(activated(int)),this,SLOT(readPty()));
194 connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); 192 connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error()));
195 193
196 return 0; 194 return 0;
197} 195}
198 196
199int MyPty::openPty() 197int MyPty::openPty()
200{ 198{
201 // This is code from the Qt DumbTerminal example 199 // This is code from the Qt DumbTerminal example
202 int ptyfd = -1; 200 int ptyfd = -1;
203 201
204#ifdef HAVE_OPENPTY 202#ifdef HAVE_OPENPTY
205 int ttyfd; 203 int ttyfd;
206 if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) ) 204 if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) )
207 ptyfd = -1; 205 ptyfd = -1;
208 else 206 else
209 close(ttyfd); // we open the ttynam ourselves. 207 close(ttyfd); // we open the ttynam ourselves.
210#else 208#else
211 for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { 209 for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) {
212 for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { 210 for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) {
213 sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); 211 sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1);
214 sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); 212 sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1);
215 if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { 213 if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) {
216 if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { 214 if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) {
217 ::close(ptyfd); 215 ::close(ptyfd);
218 ptyfd = -1; 216 ptyfd = -1;
219 } 217 }
220 } 218 }
221 } 219 }
222 } 220 }
223#endif 221#endif
224 222
225 if ( ptyfd < 0 ) { 223 if ( ptyfd < 0 ) {
226 qApp->exit(1); 224 qApp->exit(1);
227 return -1; 225 return -1;
228 } 226 }
229 227
230 return ptyfd; 228 return ptyfd;
231} 229}
232 230
233/*! 231/*!
234 Create an instance. 232 Create an instance.
235*/ 233*/
236MyPty::MyPty(const Profile&) : m_cpid(0) 234MyPty::MyPty(const Profile&) : m_cpid(0)
237{ 235{
238 m_sn_e = 0l; 236 m_sn_e = 0l;
239 m_fd = openPty(); 237 m_fd = openPty();
240 ProcCtl* ctl = ProcCtl::self(); 238 ProcCtl* ctl = ProcCtl::self();
241} 239}
242 240
243/*! 241/*!
244 Destructor. 242 Destructor.
245 Note that the related client program is not killed 243 Note that the related client program is not killed
246 (yet) when a instance is deleted. 244 (yet) when a instance is deleted.
247*/ 245*/
248MyPty::~MyPty() 246MyPty::~MyPty()
249{ 247{
250 donePty(); 248 donePty();
251} 249}
252QString MyPty::identifier()const { 250QString MyPty::identifier()const {
253 return QString::fromLatin1("term"); 251 return QString::fromLatin1("term");
254} 252}
255QString MyPty::name()const{ 253QString MyPty::name()const{
256 return identifier(); 254 return identifier();
257} 255}
258bool MyPty::open() { 256bool MyPty::open() {
259 start(); 257 start();
260 return true; 258 return true;
261} 259}
262void MyPty::close() { 260void MyPty::close() {
263 donePty(); 261 donePty();
264} 262}
265void MyPty::reload( const Profile& ) { 263void MyPty::reload( const Profile& ) {
266 264
267} 265}
268/*! sends len bytes through the line */ 266/*! sends len bytes through the line */
269void MyPty::send(const QByteArray& ar) 267void MyPty::send(const QByteArray& ar)
270{ 268{
271 qWarning("sending!");
272#ifdef VERBOSE_DEBUG 269#ifdef VERBOSE_DEBUG
273 // verbose debug 270 // verbose debug
274 printf("sending bytes:\n"); 271 printf("sending bytes:\n");
275 for (uint i = 0; i < ar.count(); i++) 272 for (uint i = 0; i < ar.count(); i++)
276 printf("%c", ar[i]); 273 printf("%c", ar[i]);
277 printf("\n"); 274 printf("\n");
278#endif 275#endif
279 276
280 ::write(m_fd, ar.data(), ar.count()); 277 ::write(m_fd, ar.data(), ar.count());
281} 278}
282 279
283/*! indicates that a block of data is received */ 280/*! indicates that a block of data is received */
284void MyPty::readPty() 281void MyPty::readPty()
285{ 282{
286 qWarning("read");
287 QByteArray buf(4096); 283 QByteArray buf(4096);
288 284
289 int len = ::read( m_fd, buf.data(), 4096 ); 285 int len = ::read( m_fd, buf.data(), 4096 );
290 286
291 if (len == -1 || len == 0) { 287 if (len == -1 || len == 0) {
292 qWarning("donePty!!! now!");
293 donePty(); 288 donePty();
294 qWarning("return %s", sender()->className() );
295 delete sender(); 289 delete sender();
296 return; 290 return;
297 } 291 }
298 292
299 if (len < 0) 293 if (len < 0)
300 return; 294 return;
301 295
302 296
303 buf.resize(len); 297 buf.resize(len);
304 emit received(buf); 298 emit received(buf);
305 299
306#ifdef VERBOSE_DEBUG 300#ifdef VERBOSE_DEBUG
307 // verbose debug 301 // verbose debug
308 printf("read bytes:\n"); 302 printf("read bytes:\n");
309 for (uint i = 0; i < buf.count(); i++) 303 for (uint i = 0; i < buf.count(); i++)
310 printf("%c", buf[i]); 304 printf("%c", buf[i]);
311 printf("\n"); 305 printf("\n");
312#endif 306#endif
313 307
314} 308}
315 309
diff --git a/noncore/apps/opie-console/configdialog.cpp b/noncore/apps/opie-console/configdialog.cpp
index 8745305..0bc6588 100644
--- a/noncore/apps/opie-console/configdialog.cpp
+++ b/noncore/apps/opie-console/configdialog.cpp
@@ -1,115 +1,114 @@
1#include <qdialog.h> 1#include <qdialog.h>
2#include <qlistview.h> 2#include <qlistview.h>
3 3
4 4
5#include "profile.h" 5#include "profile.h"
6#include "configdialog.h" 6#include "configdialog.h"
7#include "metafactory.h" 7#include "metafactory.h"
8#include "profileeditordialog.h" 8#include "profileeditordialog.h"
9 9
10class ConfigListItem : public QListViewItem { 10class ConfigListItem : public QListViewItem {
11public: 11public:
12 ConfigListItem( QListView* item, const Profile& ); 12 ConfigListItem( QListView* item, const Profile& );
13 ~ConfigListItem(); 13 ~ConfigListItem();
14 Profile profile()const; 14 Profile profile()const;
15 15
16private: 16private:
17 Profile m_prof; 17 Profile m_prof;
18}; 18};
19ConfigListItem::ConfigListItem( QListView* item, const Profile& prof ) 19ConfigListItem::ConfigListItem( QListView* item, const Profile& prof )
20 : QListViewItem( item ), m_prof( prof ) 20 : QListViewItem( item ), m_prof( prof )
21{ 21{
22 setText(0, prof.name() ); 22 setText(0, prof.name() );
23} 23}
24ConfigListItem::~ConfigListItem() { 24ConfigListItem::~ConfigListItem() {
25 25
26} 26}
27Profile ConfigListItem::profile()const { 27Profile ConfigListItem::profile()const {
28 return m_prof; 28 return m_prof;
29} 29}
30 30
31/* Dialog */ 31/* Dialog */
32 32
33ConfigDialog::ConfigDialog( const Profile::ValueList& lis, MetaFactory* fa, 33ConfigDialog::ConfigDialog( const Profile::ValueList& lis, MetaFactory* fa,
34 QWidget* parent ) 34 QWidget* parent )
35 : ConfigureBase( parent, 0, TRUE ), m_fact( fa ) 35 : ConfigureBase( parent, 0, TRUE ), m_fact( fa )
36{ 36{
37 //init(); 37 //init();
38 { 38 {
39 Profile::ValueList::ConstIterator it; 39 Profile::ValueList::ConstIterator it;
40 for (it = lis.begin(); it != lis.end(); ++it ) { 40 for (it = lis.begin(); it != lis.end(); ++it ) {
41 new ConfigListItem( lstView, (*it) ); 41 new ConfigListItem( lstView, (*it) );
42 } 42 }
43 } 43 }
44} 44}
45ConfigDialog::~ConfigDialog() { 45ConfigDialog::~ConfigDialog() {
46 46
47} 47}
48Profile::ValueList ConfigDialog::list()const { 48Profile::ValueList ConfigDialog::list()const {
49/* iterate over the list */ 49/* iterate over the list */
50 Profile::ValueList lst; 50 Profile::ValueList lst;
51 QListViewItemIterator it(lstView); 51 QListViewItemIterator it(lstView);
52 for ( ; it.current(); ++it ) { 52 for ( ; it.current(); ++it ) {
53 ConfigListItem* item = (ConfigListItem*)it.current(); 53 ConfigListItem* item = (ConfigListItem*)it.current();
54 lst.append( item->profile() ); 54 lst.append( item->profile() );
55 } 55 }
56 return lst; 56 return lst;
57} 57}
58/* our slots */ 58/* our slots */
59void ConfigDialog::slotRemove() { 59void ConfigDialog::slotRemove() {
60 ConfigListItem* item = (ConfigListItem*)lstView->currentItem(); 60 ConfigListItem* item = (ConfigListItem*)lstView->currentItem();
61 if (!item ) 61 if (!item )
62 return; 62 return;
63 63
64 lstView->takeItem( item ); 64 lstView->takeItem( item );
65 delete item; 65 delete item;
66} 66}
67 67
68void ConfigDialog::slotEdit() { 68void ConfigDialog::slotEdit() {
69 Profile p; 69 Profile p;
70 70
71 if(!lstView->currentItem()) return; 71 if(!lstView->currentItem()) return;
72 72
73 // Load profile 73 // Load profile
74 p = ((ConfigListItem*)lstView->currentItem())->profile(); 74 p = ((ConfigListItem*)lstView->currentItem())->profile();
75 75
76 ProfileEditorDialog dlg(m_fact, p); 76 ProfileEditorDialog dlg(m_fact, p);
77 77
78 dlg.setCaption("Edit Connection Profile"); 78 dlg.setCaption("Edit Connection Profile");
79 dlg.showMaximized(); 79 dlg.showMaximized();
80 int ret = dlg.exec(); 80 int ret = dlg.exec();
81 81
82 if(ret == QDialog::Accepted) 82 if(ret == QDialog::Accepted)
83 { 83 {
84 if(lstView->currentItem()) delete lstView->currentItem(); 84 if(lstView->currentItem()) delete lstView->currentItem();
85 85
86 // use dlg.terminal()! 86 // use dlg.terminal()!
87 Profile p = dlg.profile(); 87 Profile p = dlg.profile();
88 88
89 new ConfigListItem(lstView, p); 89 new ConfigListItem(lstView, p);
90 } 90 }
91} 91}
92 92
93 93
94void ConfigDialog::slotAdd() { 94void ConfigDialog::slotAdd() {
95 qWarning("slotAdd");
96 ProfileEditorDialog dlg(m_fact); 95 ProfileEditorDialog dlg(m_fact);
97 96
98 dlg.setCaption("New Connection"); 97 dlg.setCaption("New Connection");
99 dlg.showMaximized(); 98 dlg.showMaximized();
100 int ret = dlg.exec(); 99 int ret = dlg.exec();
101 100
102 if(ret == QDialog::Accepted) 101 if(ret == QDialog::Accepted)
103 { 102 {
104 // TODO: Move into general profile save part 103 // TODO: Move into general profile save part
105 // assignments 104 // assignments
106 //QString type = dlg.term_type(); 105 //QString type = dlg.term_type();
107 //if(type == "VT102") profile = Profile::VT102; 106 //if(type == "VT102") profile = Profile::VT102;
108 107
109 // get profile from editor 108 // get profile from editor
110 Profile p = dlg.profile(); 109 Profile p = dlg.profile();
111 110
112 new ConfigListItem(lstView, p); 111 new ConfigListItem(lstView, p);
113 } 112 }
114} 113}
115 114
diff --git a/noncore/apps/opie-console/emulation_handler.cpp b/noncore/apps/opie-console/emulation_handler.cpp
index 836a05b..b2cd348 100644
--- a/noncore/apps/opie-console/emulation_handler.cpp
+++ b/noncore/apps/opie-console/emulation_handler.cpp
@@ -1,148 +1,142 @@
1#include <qwidget.h> 1#include <qwidget.h>
2 2
3#include "TEWidget.h" 3#include "TEWidget.h"
4#include "TEmuVt102.h" 4#include "TEmuVt102.h"
5 5
6#include "profile.h" 6#include "profile.h"
7#include "emulation_handler.h" 7#include "emulation_handler.h"
8 8
9 9
10EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name ) 10EmulationHandler::EmulationHandler( const Profile& prof, QWidget* parent,const char* name )
11 : QObject(0, name ) 11 : QObject(0, name )
12{ 12{
13 m_teWid = new TEWidget( parent, "TerminalMain"); 13 m_teWid = new TEWidget( parent, "TerminalMain");
14 m_teWid->setMinimumSize(150, 70 ); 14 m_teWid->setMinimumSize(150, 70 );
15 parent->resize( m_teWid->calcSize(80, 24 ) ); 15 parent->resize( m_teWid->calcSize(80, 24 ) );
16 m_teEmu = new TEmuVt102(m_teWid ); 16 m_teEmu = new TEmuVt102(m_teWid );
17 17
18 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ), 18 connect(m_teEmu,SIGNAL(ImageSizeChanged(int, int) ),
19 this, SIGNAL(changeSize(int, int) ) ); 19 this, SIGNAL(changeSize(int, int) ) );
20 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ), 20 connect(m_teEmu, SIGNAL(sndBlock(const char*, int) ),
21 this, SLOT(recvEmulation(const char*, int) ) ); 21 this, SLOT(recvEmulation(const char*, int) ) );
22 m_teEmu->setConnect( true ); 22 m_teEmu->setConnect( true );
23 m_teEmu->setHistory( TRUE ); 23 m_teEmu->setHistory( TRUE );
24 load( prof ); 24 load( prof );
25 25
26 26
27 27
28} 28}
29EmulationHandler::~EmulationHandler() { 29EmulationHandler::~EmulationHandler() {
30 delete m_teEmu; 30 delete m_teEmu;
31 delete m_teWid; 31 delete m_teWid;
32} 32}
33void EmulationHandler::load( const Profile& prof) { 33void EmulationHandler::load( const Profile& prof) {
34 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) ); 34 m_teWid->setVTFont( font( prof.readNumEntry("Font") ) );
35 int num = prof.readNumEntry("Color"); 35 int num = prof.readNumEntry("Color");
36 setColor( foreColor(num), backColor(num) ); 36 setColor( foreColor(num), backColor(num) );
37 m_teWid->setBackgroundColor(backColor(num) ); 37 m_teWid->setBackgroundColor(backColor(num) );
38} 38}
39void EmulationHandler::recv( const QByteArray& ar) { 39void EmulationHandler::recv( const QByteArray& ar) {
40 qWarning("received in EmulationHandler!");
41 m_teEmu->onRcvBlock(ar.data(), ar.count() ); 40 m_teEmu->onRcvBlock(ar.data(), ar.count() );
42} 41}
43void EmulationHandler::recvEmulation(const char* src, int len ) { 42void EmulationHandler::recvEmulation(const char* src, int len ) {
44 qWarning("received from te ");
45 QByteArray ar(len); 43 QByteArray ar(len);
46 44
47 memcpy(ar.data(), src, sizeof(char) * len ); 45 memcpy(ar.data(), src, sizeof(char) * len );
48 46
49 emit send(ar); 47 emit send(ar);
50} 48}
51QWidget* EmulationHandler::widget() { 49QWidget* EmulationHandler::widget() {
52 return m_teWid; 50 return m_teWid;
53} 51}
54/* 52/*
55 * allocate a new table of colors 53 * allocate a new table of colors
56 */ 54 */
57void EmulationHandler::setColor( const QColor& fore, const QColor& back ) { 55void EmulationHandler::setColor( const QColor& fore, const QColor& back ) {
58 ColorEntry table[TABLE_COLORS]; 56 ColorEntry table[TABLE_COLORS];
59 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable(); 57 const ColorEntry *defaultCt = m_teWid->getdefaultColorTable();
60 58
61 for (int i = 0; i < TABLE_COLORS; i++ ) { 59 for (int i = 0; i < TABLE_COLORS; i++ ) {
62 if ( i == 0 || i == 10 ) { 60 if ( i == 0 || i == 10 ) {
63 table[i].color = fore; 61 table[i].color = fore;
64 }else if ( i == 1 || i == 11 ) { 62 }else if ( i == 1 || i == 11 ) {
65 table[i].color = back; 63 table[i].color = back;
66 table[i].transparent = 0; 64 table[i].transparent = 0;
67 }else { 65 }else {
68 table[i].color = defaultCt[i].color; 66 table[i].color = defaultCt[i].color;
69 } 67 }
70 } 68 }
71 m_teWid->setColorTable(table ); 69 m_teWid->setColorTable(table );
72 m_teWid->update(); 70 m_teWid->update();
73} 71}
74QFont EmulationHandler::font( int id ) { 72QFont EmulationHandler::font( int id ) {
75 QString name; 73 QString name;
76 int size = 0; 74 int size = 0;
77 switch(id ) { 75 switch(id ) {
78 default: // fall through 76 default: // fall through
79 case 0: 77 case 0:
80 name = QString::fromLatin1("Micro"); 78 name = QString::fromLatin1("Micro");
81 size = 4; 79 size = 4;
82 break; 80 break;
83 case 1: 81 case 1:
84 name = QString::fromLatin1("Fixed"); 82 name = QString::fromLatin1("Fixed");
85 size = 7; 83 size = 7;
86 break; 84 break;
87 case 2: 85 case 2:
88 name = QString::fromLatin1("Fixed"); 86 name = QString::fromLatin1("Fixed");
89 size = 12; 87 size = 12;
90 break; 88 break;
91 } 89 }
92 QFont font(name, size, QFont::Normal ); 90 QFont font(name, size, QFont::Normal );
93 font.setFixedPitch(TRUE ); 91 font.setFixedPitch(TRUE );
94 return font; 92 return font;
95} 93}
96QColor EmulationHandler::foreColor(int col) { 94QColor EmulationHandler::foreColor(int col) {
97 QColor co; 95 QColor co;
98 /* we need to switch it */ 96 /* we need to switch it */
99 switch( col ) { 97 switch( col ) {
100 default: 98 default:
101 case Profile::White: 99 case Profile::White:
102 qWarning("Foreground black");
103 /* color is black */ 100 /* color is black */
104 co = Qt::white; 101 co = Qt::white;
105 break; 102 break;
106 case Profile::Black: 103 case Profile::Black:
107 qWarning("Foreground white");
108 co = Qt::black; 104 co = Qt::black;
109 break; 105 break;
110 case Profile::Green: 106 case Profile::Green:
111 qWarning("Foreground green"); 107 qWarning("Foreground green");
112 co = Qt::green; 108 co = Qt::green;
113 break; 109 break;
114 case Profile::Orange: 110 case Profile::Orange:
115 qWarning("Foreground orange"); 111 qWarning("Foreground orange");
116 // FIXME needs better color here 112 // FIXME needs better color here
117 co = Qt::darkYellow; 113 co = Qt::darkYellow;
118 break; 114 break;
119 } 115 }
120 116
121 return co; 117 return co;
122} 118}
123QColor EmulationHandler::backColor(int col ) { 119QColor EmulationHandler::backColor(int col ) {
124 QColor co; 120 QColor co;
125 /* we need to switch it */ 121 /* we need to switch it */
126 switch( col ) { 122 switch( col ) {
127 default: 123 default:
128 case Profile::White: 124 case Profile::White:
129 qWarning("Background white");
130 /* color is white */ 125 /* color is white */
131 co = Qt::black; 126 co = Qt::black;
132 break; 127 break;
133 case Profile::Black: 128 case Profile::Black:
134 qWarning("Background black");
135 co = Qt::white; 129 co = Qt::white;
136 break; 130 break;
137 case Profile::Green: 131 case Profile::Green:
138 qWarning("Background black"); 132 qWarning("Background black");
139 co = Qt::black; 133 co = Qt::black;
140 break; 134 break;
141 case Profile::Orange: 135 case Profile::Orange:
142 qWarning("Background black"); 136 qWarning("Background black");
143 co = Qt::black; 137 co = Qt::black;
144 break; 138 break;
145 } 139 }
146 140
147 return co; 141 return co;
148} 142}
diff --git a/noncore/apps/opie-console/filereceive.cpp b/noncore/apps/opie-console/filereceive.cpp
index 26b3dec..e517862 100644
--- a/noncore/apps/opie-console/filereceive.cpp
+++ b/noncore/apps/opie-console/filereceive.cpp
@@ -42,118 +42,116 @@ void FileReceive::receive( const QString& dir ) {
42 setupChild(); 42 setupChild();
43 char* typus = NULL; 43 char* typus = NULL;
44 switch(m_type ) { 44 switch(m_type ) {
45 case SZ: 45 case SZ:
46 break; 46 break;
47 case SX: 47 case SX:
48 typus = "-X"; 48 typus = "-X";
49 break; 49 break;
50 case SY: 50 case SY:
51 typus = "--ymodem"; 51 typus = "--ymodem";
52 break; 52 break;
53 } 53 }
54 54
55 /* we should never return from here */ 55 /* we should never return from here */
56 execlp("rz", "rz", typus, NULL ); 56 execlp("rz", "rz", typus, NULL );
57 57
58 char resultByte = 1; 58 char resultByte = 1;
59 if (m_info[1] ) 59 if (m_info[1] )
60 ::write(m_info[1], &resultByte, 1 ); 60 ::write(m_info[1], &resultByte, 1 );
61 61
62 _exit( -1 ); 62 _exit( -1 );
63 break; 63 break;
64 } 64 }
65 default: { 65 default: {
66 if ( m_info[1] ) 66 if ( m_info[1] )
67 close( m_info[1] ); 67 close( m_info[1] );
68 68
69 if ( m_info[0] ) for (;;) { 69 if ( m_info[0] ) for (;;) {
70 char resultByte; int len; 70 char resultByte; int len;
71 len = read(m_info[0], &resultByte, 1 ); 71 len = read(m_info[0], &resultByte, 1 );
72 /* len == 1 start up failed */ 72 /* len == 1 start up failed */
73 if ( len == 1 ) { 73 if ( len == 1 ) {
74 emit error( StartError, tr("Could not start") ); 74 emit error( StartError, tr("Could not start") );
75 return; 75 return;
76 } 76 }
77 if ( len == -1 ) 77 if ( len == -1 )
78 if ( (errno == ECHILD ) || (errno == EINTR ) ) 78 if ( (errno == ECHILD ) || (errno == EINTR ) )
79 continue; 79 continue;
80 80
81 // len == 0 or something like this 81 // len == 0 or something like this
82 break; 82 break;
83 } 83 }
84 84
85 if ( m_info[0] ) 85 if ( m_info[0] )
86 close( m_info[0] ); 86 close( m_info[0] );
87 87
88 m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); 88 m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read );
89 connect(m_not, SIGNAL(activated(int) ), 89 connect(m_not, SIGNAL(activated(int) ),
90 this, SLOT(slotRead() ) ); 90 this, SLOT(slotRead() ) );
91 if ( pipe(m_term) < 0 ) 91 if ( pipe(m_term) < 0 )
92 m_term[0] = m_term[1] = 0; 92 m_term[0] = m_term[1] = 0;
93 93
94 ProcCtl::self()->add(m_pid, m_term[1] ); 94 ProcCtl::self()->add(m_pid, m_term[1] );
95 m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); 95 m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read );
96 connect(m_proc, SIGNAL(activated(int) ), 96 connect(m_proc, SIGNAL(activated(int) ),
97 this, SLOT(slotExec() ) ); 97 this, SLOT(slotExec() ) );
98 98
99 } 99 }
100 break; 100 break;
101 101
102 } 102 }
103 103
104} 104}
105void FileReceive::cancel() { 105void FileReceive::cancel() {
106 ::kill(m_pid, 9 ); 106 ::kill(m_pid, 9 );
107} 107}
108void FileReceive::setupChild() { 108void FileReceive::setupChild() {
109 changeDir( currentDir() ); 109 changeDir( currentDir() );
110 /* 110 /*
111 * we do not want to read from our 111 * we do not want to read from our
112 * information channel 112 * information channel
113 */ 113 */
114 if (m_info[0] ) 114 if (m_info[0] )
115 close(m_info[0] ); 115 close(m_info[0] );
116 /* 116 /*
117 * FD_CLOEXEC will close the 117 * FD_CLOEXEC will close the
118 * fd on successfull exec 118 * fd on successfull exec
119 */ 119 */
120 if (m_info[1] ) 120 if (m_info[1] )
121 fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); 121 fcntl(m_info[1], F_SETFD, FD_CLOEXEC );
122 122
123 if (m_comm[0] ) 123 if (m_comm[0] )
124 close( m_comm[0] ); 124 close( m_comm[0] );
125 /* 125 /*
126 * now set the communication 126 * now set the communication
127 * m_fd STDIN_FILENO 127 * m_fd STDIN_FILENO
128 * STDOUT_FILENO 128 * STDOUT_FILENO
129 * STDERR_FILENO 129 * STDERR_FILENO
130 */ 130 */
131 dup2( m_fd, STDIN_FILENO ); 131 dup2( m_fd, STDIN_FILENO );
132 dup2( m_fd, STDOUT_FILENO ); 132 dup2( m_fd, STDOUT_FILENO );
133 dup2( m_comm[1], STDERR_FILENO ); 133 dup2( m_comm[1], STDERR_FILENO );
134} 134}
135void FileReceive::slotRead() { 135void FileReceive::slotRead() {
136 QByteArray ar(4096); 136 QByteArray ar(4096);
137 int len = read(m_comm[0], ar.data(), 4096 ); 137 int len = read(m_comm[0], ar.data(), 4096 );
138 qWarning("slot read %d", len);
139 for (int i = 0; i < len; i++ ) { 138 for (int i = 0; i < len; i++ ) {
140 // printf("%c", ar[i] ); 139 // printf("%c", ar[i] );
141 } 140 }
142 ar.resize( len ); 141 ar.resize( len );
143 QString str( ar ); 142 QString str( ar );
144 qWarning(str.simplifyWhiteSpace() );
145} 143}
146void FileReceive::slotExec() { 144void FileReceive::slotExec() {
147 char buf[2]; 145 char buf[2];
148 ::read(m_term[0], buf, 1 ); 146 ::read(m_term[0], buf, 1 );
149 delete m_proc; 147 delete m_proc;
150 delete m_not; 148 delete m_not;
151 m_not = m_proc = 0l; 149 m_not = m_proc = 0l;
152 close( m_term[0] ); 150 close( m_term[0] );
153 close( m_term[1] ); 151 close( m_term[1] );
154 close( m_comm[0] ); 152 close( m_comm[0] );
155 close( m_comm[1] ); 153 close( m_comm[1] );
156 layer()->closeRawIO(m_fd); 154 layer()->closeRawIO(m_fd);
157 emit received(QString::null); 155 emit received(QString::null);
158 156
159} 157}
diff --git a/noncore/apps/opie-console/filetransfer.cpp b/noncore/apps/opie-console/filetransfer.cpp
index 8ca0df2..b81c2a2 100644
--- a/noncore/apps/opie-console/filetransfer.cpp
+++ b/noncore/apps/opie-console/filetransfer.cpp
@@ -1,256 +1,250 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3#include <errno.h> 3#include <errno.h>
4#include <fcntl.h> 4#include <fcntl.h>
5#include <unistd.h> 5#include <unistd.h>
6 6
7#include <qcstring.h> 7#include <qcstring.h>
8#include <qsocketnotifier.h> 8#include <qsocketnotifier.h>
9 9
10#include <opie/oprocess.h> 10#include <opie/oprocess.h>
11 11
12#include "procctl.h" 12#include "procctl.h"
13#include "filetransfer.h" 13#include "filetransfer.h"
14 14
15 15
16FileTransfer::FileTransfer( Type t, IOLayer* lay ) 16FileTransfer::FileTransfer( Type t, IOLayer* lay )
17 : FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) { 17 : FileTransferLayer( lay ), m_type( t ), m_pid ( 0 ) {
18 signal(SIGPIPE, SIG_IGN ); 18 signal(SIGPIPE, SIG_IGN );
19 19
20 m_pid = 0; 20 m_pid = 0;
21 m_not = 0l; 21 m_not = 0l;
22 m_proc = 0l; 22 m_proc = 0l;
23} 23}
24FileTransfer::~FileTransfer() { 24FileTransfer::~FileTransfer() {
25} 25}
26 26
27/** 27/**
28 * now we will send the file. 28 * now we will send the file.
29 * 29 *
30 * we request an fd. The IOLayer should be closed 30 * we request an fd. The IOLayer should be closed
31 * then we will setup a pipe for progress communication 31 * then we will setup a pipe for progress communication
32 * then we will dup2 the m_fd in the forked process 32 * then we will dup2 the m_fd in the forked process
33 * to do direct IO from and to the fd 33 * to do direct IO from and to the fd
34 */ 34 */
35void FileTransfer::sendFile( const QString& file ) { 35void FileTransfer::sendFile( const QString& file ) {
36 m_prog =-1; 36 m_prog =-1;
37 m_fd = layer()->rawIO(); 37 m_fd = layer()->rawIO();
38// 38//
39// m_fd = ::open("/dev/ttyS0", O_RDWR); 39// m_fd = ::open("/dev/ttyS0", O_RDWR);
40 40
41 m_file = file; 41 m_file = file;
42 if ( pipe( m_comm ) < 0 ) 42 if ( pipe( m_comm ) < 0 )
43 m_comm[0] = m_comm[1] = 0; 43 m_comm[0] = m_comm[1] = 0;
44 if ( pipe( m_info ) < 0 ) 44 if ( pipe( m_info ) < 0 )
45 m_info[0] = m_info[1] = 0; 45 m_info[0] = m_info[1] = 0;
46 46
47 47
48 m_pid = fork(); 48 m_pid = fork();
49 switch( m_pid ) { 49 switch( m_pid ) {
50 case -1: 50 case -1:
51 emit error( StartError, tr("Was not able to fork") ); 51 emit error( StartError, tr("Was not able to fork") );
52 slotExec(); 52 slotExec();
53 break; 53 break;
54 case 0:{ 54 case 0:{
55 setupChild(); 55 setupChild();
56 qWarning("output:"+file );
57 /* exec */ 56 /* exec */
58 char* verbose = "-vv"; 57 char* verbose = "-vv";
59 char* binray = "-b"; 58 char* binray = "-b";
60 59
61 60
62 char* typus; 61 char* typus;
63 switch(m_type ) { 62 switch(m_type ) {
64 case SZ: 63 case SZ:
65 typus = ""; 64 typus = "";
66 break; 65 break;
67 case SX: 66 case SX:
68 typus = "-X"; 67 typus = "-X";
69 break; 68 break;
70 case SY: 69 case SY:
71 typus = "--ymodem"; 70 typus = "--ymodem";
72 break; 71 break;
73 } 72 }
74 73
75 /* we should never return from here */ 74 /* we should never return from here */
76 execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL ); 75 execlp("sz", "sz", verbose, binray, file.latin1(), typus, NULL );
77 76
78 /* communication for error!*/ 77 /* communication for error!*/
79 char resultByte =1; 78 char resultByte =1;
80 if (m_info[1] ) 79 if (m_info[1] )
81 write(m_info[1], &resultByte, 1 ); 80 write(m_info[1], &resultByte, 1 );
82 _exit( -1 ); 81 _exit( -1 );
83 break; 82 break;
84 } 83 }
85 default:{ 84 default:{
86 if ( m_info[1] ) 85 if ( m_info[1] )
87 close( m_info[1] ); 86 close( m_info[1] );
88 if ( m_info[0] ) for (;;) { 87 if ( m_info[0] ) for (;;) {
89 char resultByte; int len; 88 char resultByte; int len;
90 len = read(m_info[0], &resultByte, 1 ); 89 len = read(m_info[0], &resultByte, 1 );
91 /* len == 1 start up failed */ 90 /* len == 1 start up failed */
92 if ( len == 1 ) { 91 if ( len == 1 ) {
93 emit error( StartError, tr("Could not start") ); 92 emit error( StartError, tr("Could not start") );
94 return; 93 return;
95 } 94 }
96 if ( len == -1 ) 95 if ( len == -1 )
97 if ( (errno == ECHILD ) || (errno == EINTR ) ) 96 if ( (errno == ECHILD ) || (errno == EINTR ) )
98 continue; 97 continue;
99 98
100 // len == 0 or something like this 99 // len == 0 or something like this
101 break; 100 break;
102 } 101 }
103 if ( m_info[0] ) 102 if ( m_info[0] )
104 close( m_info[0] ); 103 close( m_info[0] );
105 104
106 105
107 106
108 /* replace by QSocketNotifier!!! */ 107 /* replace by QSocketNotifier!!! */
109 m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read ); 108 m_not = new QSocketNotifier(m_comm[0], QSocketNotifier::Read );
110 connect(m_not, SIGNAL(activated(int) ), 109 connect(m_not, SIGNAL(activated(int) ),
111 this, SLOT(slotRead() ) ); 110 this, SLOT(slotRead() ) );
112 if ( pipe(m_term) < 0 ) 111 if ( pipe(m_term) < 0 )
113 m_term[0] = m_term[1] = 0; 112 m_term[0] = m_term[1] = 0;
114 113
115 ProcCtl::self()->add(m_pid, m_term[1] ); 114 ProcCtl::self()->add(m_pid, m_term[1] );
116 m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read ); 115 m_proc = new QSocketNotifier(m_term[0], QSocketNotifier::Read );
117 connect(m_proc, SIGNAL(activated(int) ), 116 connect(m_proc, SIGNAL(activated(int) ),
118 this, SLOT(slotExec() ) ); 117 this, SLOT(slotExec() ) );
119 118
120 } 119 }
121 break; 120 break;
122 } 121 }
123} 122}
124/* 123/*
125 * let's call the one with the filename 124 * let's call the one with the filename
126 */ 125 */
127void FileTransfer::sendFile( const QFile& file ) { 126void FileTransfer::sendFile( const QFile& file ) {
128 sendFile( file.name() ); 127 sendFile( file.name() );
129} 128}
130 129
131/* 130/*
132 * setting up communication 131 * setting up communication
133 * between parent child and ioLayer 132 * between parent child and ioLayer
134 */ 133 */
135void FileTransfer::setupChild() { 134void FileTransfer::setupChild() {
136 /* 135 /*
137 * we do not want to read from our 136 * we do not want to read from our
138 * information channel 137 * information channel
139 */ 138 */
140 if (m_info[0] ) 139 if (m_info[0] )
141 close(m_info[0] ); 140 close(m_info[0] );
142 /* 141 /*
143 * FD_CLOEXEC will close the 142 * FD_CLOEXEC will close the
144 * fd on successfull exec 143 * fd on successfull exec
145 */ 144 */
146 if (m_info[1] ) 145 if (m_info[1] )
147 fcntl(m_info[1], F_SETFD, FD_CLOEXEC ); 146 fcntl(m_info[1], F_SETFD, FD_CLOEXEC );
148 147
149 if (m_comm[0] ) 148 if (m_comm[0] )
150 close( m_comm[0] ); 149 close( m_comm[0] );
151 /* 150 /*
152 * now set the communication 151 * now set the communication
153 * m_fd STDIN_FILENO 152 * m_fd STDIN_FILENO
154 * STDOUT_FILENO 153 * STDOUT_FILENO
155 * STDERR_FILENO 154 * STDERR_FILENO
156 */ 155 */
157 dup2( m_fd, STDIN_FILENO ); 156 dup2( m_fd, STDIN_FILENO );
158 dup2( m_fd, STDOUT_FILENO ); 157 dup2( m_fd, STDOUT_FILENO );
159 dup2( m_comm[1], STDERR_FILENO ); 158 dup2( m_comm[1], STDERR_FILENO );
160} 159}
161 160
162/* 161/*
163 * read from the stderr of the child 162 * read from the stderr of the child
164 * process 163 * process
165 */ 164 */
166void FileTransfer::slotRead() { 165void FileTransfer::slotRead() {
167 QByteArray ar(4096); 166 QByteArray ar(4096);
168 int len = read(m_comm[0], ar.data(), 4096 ); 167 int len = read(m_comm[0], ar.data(), 4096 );
169 qWarning("slot read %d", len);
170 for (int i = 0; i < len; i++ ) { 168 for (int i = 0; i < len; i++ ) {
171 // printf("%c", ar[i] ); 169 // printf("%c", ar[i] );
172 } 170 }
173 ar.resize( len ); 171 ar.resize( len );
174 QString str( ar ); 172 QString str( ar );
175 qWarning(str.simplifyWhiteSpace() );
176 QStringList lis = QStringList::split(' ', str ); 173 QStringList lis = QStringList::split(' ', str );
177 /* 174 /*
178 * Transfer finished.. either complete or incomplete 175 * Transfer finished.. either complete or incomplete
179 */ 176 */
180 if ( lis[0].simplifyWhiteSpace() == "Transfer" ) { 177 if ( lis[0].simplifyWhiteSpace() == "Transfer" ) {
181 qWarning("sent!!!!");
182 return; 178 return;
183 } 179 }
184 /* 180 /*
185 * do progress reading 181 * do progress reading
186 */ 182 */
187 slotProgress( lis ); 183 slotProgress( lis );
188 184
189 185
190} 186}
191/* 187/*
192 * find the progress 188 * find the progress
193 */ 189 */
194void FileTransfer::slotProgress( const QStringList& list ) { 190void FileTransfer::slotProgress( const QStringList& list ) {
195 if ( m_type != SZ ) 191 if ( m_type != SZ )
196 return; 192 return;
197 bool complete = true; 193 bool complete = true;
198 int min, sec; 194 int min, sec;
199 int bps; 195 int bps;
200 unsigned long sent, total; 196 unsigned long sent, total;
201 197
202 min = sec = bps = -1; 198 min = sec = bps = -1;
203 sent = total = 0; 199 sent = total = 0;
204 200
205 // Data looks like this 201 // Data looks like this
206 // 0 1 2 3 4 5 202 // 0 1 2 3 4 5
207 // Bytes Sent 65536/11534336 BPS:7784 ETA 24:33 203 // Bytes Sent 65536/11534336 BPS:7784 ETA 24:33
208 QStringList progi = QStringList::split('/', list[2].simplifyWhiteSpace() ); 204 QStringList progi = QStringList::split('/', list[2].simplifyWhiteSpace() );
209 sent = progi[0].toULong(&complete ); 205 sent = progi[0].toULong(&complete );
210 if (!complete ) return; 206 if (!complete ) return;
211 207
212 total = progi[1].toULong(&complete ); 208 total = progi[1].toULong(&complete );
213 if (!complete || total == 0) { 209 if (!complete || total == 0) {
214 return; 210 return;
215 } 211 }
216 212
217 qWarning("%s, %d, %d", progi.join("/").latin1(), sent, total );
218 213
219 double pro = (double)sent/total; 214 double pro = (double)sent/total;
220 int prog = pro * 100; 215 int prog = pro * 100;
221 216
222 // speed 217 // speed
223 progi = QStringList::split(':', list[3].simplifyWhiteSpace() ); 218 progi = QStringList::split(':', list[3].simplifyWhiteSpace() );
224 bps = progi[1].toInt(); 219 bps = progi[1].toInt();
225 220
226 // time 221 // time
227 progi = QStringList::split(':', list[5].simplifyWhiteSpace() ); 222 progi = QStringList::split(':', list[5].simplifyWhiteSpace() );
228 min = progi[0].toInt(); 223 min = progi[0].toInt();
229 sec = progi[1].toInt(); 224 sec = progi[1].toInt();
230 225
231 226
232 if ( prog > m_prog ) { 227 if ( prog > m_prog ) {
233 m_prog = prog; 228 m_prog = prog;
234 emit progress(m_file, m_prog, bps, -1, min , sec ); 229 emit progress(m_file, m_prog, bps, -1, min , sec );
235 } 230 }
236 231
237} 232}
238void FileTransfer::cancel() { 233void FileTransfer::cancel() {
239 if(m_pid > 0) ::kill(m_pid,9 ); 234 if(m_pid > 0) ::kill(m_pid,9 );
240 235
241} 236}
242void FileTransfer::slotExec() { 237void FileTransfer::slotExec() {
243 qWarning("exited!");
244 char buf[2]; 238 char buf[2];
245 ::read(m_term[0], buf, 1 ); 239 ::read(m_term[0], buf, 1 );
246 delete m_proc; 240 delete m_proc;
247 delete m_not; 241 delete m_not;
248 m_proc = m_not = 0l; 242 m_proc = m_not = 0l;
249 close( m_term[0] ); 243 close( m_term[0] );
250 close( m_term[1] ); 244 close( m_term[1] );
251 close( m_comm[0] ); 245 close( m_comm[0] );
252 close( m_comm[1] ); 246 close( m_comm[1] );
253 layer()->closeRawIO( m_fd ); 247 layer()->closeRawIO( m_fd );
254 emit sent(); 248 emit sent();
255 m_pid = 0; 249 m_pid = 0;
256} 250}
diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp
index 8bff4df..0831faf 100644
--- a/noncore/apps/opie-console/io_bt.cpp
+++ b/noncore/apps/opie-console/io_bt.cpp
@@ -1,63 +1,64 @@
1 1
2#include "io_bt.h" 2#include "io_bt.h"
3 3
4IOBt::IOBt( const Profile &config ) : IOSerial( config ) { 4IOBt::IOBt( const Profile &config ) : IOSerial( config ) {
5 m_attach = 0; 5 m_attach = 0;
6} 6}
7 7
8 8
9IOBt::~IOBt() { 9IOBt::~IOBt() {
10 if ( m_attach ) { 10 if ( m_attach ) {
11 delete m_attach; 11 delete m_attach;
12 } 12 }
13} 13}
14 14
15 15
16void IOBt::close() { 16void IOBt::close() {
17 17
18 IOSerial::close(); 18 IOSerial::close();
19 // still need error handling 19 // still need error handling
20 delete m_attach; 20 delete m_attach;
21} 21}
22 22
23bool IOBt::open() { 23bool IOBt::open() {
24 24
25 // hciattach here 25 // hciattach here
26 m_attach = new OProcess(); 26 m_attach = new OProcess();
27 *m_attach << "hciattach /dev/ttyS2 any 57600"; 27 *m_attach << "hciattach /dev/ttyS2 any 57600";
28 28
29 // then start hcid, then rcfomm handling (m_mac) 29 // then start hcid, then rcfomm handling (m_mac)
30 30
31 connect( m_attach, SIGNAL( processExited( OProcess* ) ), 31 connect( m_attach, SIGNAL( processExited( OProcess* ) ),
32 this, SLOT( slotExited( OProcess* ) ) ); 32 this, SLOT( slotExited( OProcess* ) ) );
33 33
34 if ( m_attach->start() ) { 34 if ( m_attach->start() ) {
35 IOSerial::open(); 35 IOSerial::open();
36 } else { 36 } else {
37 qWarning("could not attach to device"); 37 qWarning("could not attach to device");
38 delete m_attach; 38 delete m_attach;
39 m_attach = 0;
39 } 40 }
40} 41}
41 42
42void IOBt::reload( const Profile &config ) { 43void IOBt::reload( const Profile &config ) {
43 m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); 44 m_device = config.readEntry("Device", BT_DEFAULT_DEVICE);
44 m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); 45 m_mac = config.readEntry("Mac", BT_DEFAULT_MAC);
45 m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); 46 m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD);
46 m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); 47 m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY);
47 m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); 48 m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS);
48 m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); 49 m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS);
49 m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); 50 m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW);
50} 51}
51 52
52 53
53QString IOBt::identifier() const { 54QString IOBt::identifier() const {
54 return "bluetooth"; 55 return "bluetooth";
55} 56}
56 57
57QString IOBt::name() const { 58QString IOBt::name() const {
58 return "BLuetooth IO Layer"; 59 return "BLuetooth IO Layer";
59} 60}
60 61
61void IOBt::slotExited( OProcess* proc ){ 62void IOBt::slotExited( OProcess* proc ){
62 close(); 63 close();
63} 64}
diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp
index 8e31e82..56a373c 100644
--- a/noncore/apps/opie-console/io_irda.cpp
+++ b/noncore/apps/opie-console/io_irda.cpp
@@ -1,60 +1,62 @@
1 1
2#include "io_irda.h" 2#include "io_irda.h"
3 3
4IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { 4IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) {
5 m_attach = 0; 5 m_attach = 0;
6} 6}
7 7
8 8
9IOIrda::~IOIrda() { 9IOIrda::~IOIrda() {
10 if ( m_attach ) { 10 if ( m_attach ) {
11 delete m_attach; 11 delete m_attach;
12 } 12 }
13} 13}
14 14
15 15
16void IOIrda::close() { 16void IOIrda::close() {
17 17
18 IOSerial::close(); 18 IOSerial::close();
19 // still need error handling 19 // still need error handling
20 delete m_attach; 20 delete m_attach;
21} 21}
22 22
23bool IOIrda::open() { 23bool IOIrda::open() {
24 24
25 // irdaattach here 25 // irdaattach here
26 m_attach = new OProcess(); 26 m_attach = new OProcess();
27 *m_attach << "irattach /dev/ttyS2 -s"; 27 *m_attach << "irattach /dev/ttyS2 -s";
28 28
29 connect( m_attach, SIGNAL( processExited( OProcess* ) ), 29 connect( m_attach, SIGNAL( processExited( OProcess* ) ),
30 this, SLOT( slotExited( OProcess* ) ) ); 30 this, SLOT( slotExited( OProcess* ) ) );
31 31
32 if ( m_attach->start() ) { 32 if ( m_attach->start() ) {
33 IOSerial::open(); 33 IOSerial::open();
34 } else { 34 } else {
35 // emit error!!!
35 qWarning("could not attach to device"); 36 qWarning("could not attach to device");
36 delete m_attach; 37 delete m_attach;
38 m_attach = 0l;
37 } 39 }
38} 40}
39 41
40void IOIrda::reload( const Profile &config ) { 42void IOIrda::reload( const Profile &config ) {
41 m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); 43 m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE);
42 m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD); 44 m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD);
43 m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY); 45 m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY);
44 m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS); 46 m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS);
45 m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS); 47 m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS);
46 m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW); 48 m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW);
47} 49}
48 50
49 51
50QString IOIrda::identifier() const { 52QString IOIrda::identifier() const {
51 return "irda"; 53 return "irda";
52} 54}
53 55
54QString IOIrda::name() const { 56QString IOIrda::name() const {
55 return "Irda IO Layer"; 57 return "Irda IO Layer";
56} 58}
57 59
58void IOIrda::slotExited(OProcess* proc ){ 60void IOIrda::slotExited(OProcess* proc ){
59 close(); 61 close();
60} 62}
diff --git a/noncore/apps/opie-console/io_serial.cpp b/noncore/apps/opie-console/io_serial.cpp
index 03f1b1a..a4a6f0b 100644
--- a/noncore/apps/opie-console/io_serial.cpp
+++ b/noncore/apps/opie-console/io_serial.cpp
@@ -1,197 +1,189 @@
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 reload(config); 11 reload(config);
12} 12}
13 13
14 14
15IOSerial::~IOSerial() { 15IOSerial::~IOSerial() {
16 if (m_fd) { 16 if (m_fd) {
17 close(); 17 close();
18 } 18 }
19} 19}
20 20
21void IOSerial::send(const QByteArray &data) { 21void IOSerial::send(const QByteArray &data) {
22 if (m_fd) { 22 if (m_fd) {
23 write(m_fd, data.data(), data.size()); 23 write(m_fd, data.data(), data.size());
24 } else { 24 } else {
25 emit error(Refuse, tr("Not connected")); 25 emit error(Refuse, tr("Not connected"));
26 } 26 }
27} 27}
28 28
29void IOSerial::close() { 29void IOSerial::close() {
30 qWarning("closing!");
31 if (m_fd) { 30 if (m_fd) {
32 delete m_read; 31 delete m_read;
33 delete m_error; 32 delete m_error;
34 ::close(m_fd); 33 ::close(m_fd);
35 m_fd = 0; 34 m_fd = 0;
36 } else { 35 } else {
37 emit error(Refuse, tr("Not connected")); 36 emit error(Refuse, tr("Not connected"));
38 } 37 }
39} 38}
40 39
41bool IOSerial::open() { 40bool IOSerial::open() {
42 qWarning("open");
43 if (!m_fd) { 41 if (!m_fd) {
44 qWarning("going to open %s", m_device.latin1());
45 struct termios tty; 42 struct termios tty;
46 m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK); 43 m_fd = ::open(m_device, O_RDWR | O_NOCTTY | O_NONBLOCK);
47 if (m_fd < 0) { 44 if (m_fd < 0) {
48 qWarning(" fd < 0 ");
49 emit error(CouldNotOpen, strerror(errno)); 45 emit error(CouldNotOpen, strerror(errno));
50 return FALSE; 46 return FALSE;
51 } 47 }
52 tcgetattr(m_fd, &tty); 48 tcgetattr(m_fd, &tty);
53 49
54 /* Baud rate */ 50 /* Baud rate */
55 int speed = baud(m_baud); 51 int speed = baud(m_baud);
56 if (speed == -1) { 52 if (speed == -1) {
57 qWarning("speed -1");
58 emit error(Refuse, tr("Invalid baud rate")); 53 emit error(Refuse, tr("Invalid baud rate"));
59 } 54 }
60 cfsetospeed(&tty, speed); 55 cfsetospeed(&tty, speed);
61 cfsetispeed(&tty, speed); 56 cfsetispeed(&tty, speed);
62 57
63 /* Take care of Space / Mark parity */ 58 /* Take care of Space / Mark parity */
64 if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) { 59 if (m_dbits == 7 && (m_parity == ParitySpace || m_parity == ParityMark)) {
65 m_dbits = 8; 60 m_dbits = 8;
66 } 61 }
67 62
68 /* Data bits */ 63 /* Data bits */
69 switch (m_dbits) { 64 switch (m_dbits) {
70 case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break; 65 case 5: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS5; break;
71 case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break; 66 case 6: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS6; break;
72 case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break; 67 case 7: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS7; break;
73 case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break; 68 case 8: tty.c_cflag = (tty.c_cflag & ~CSIZE) | CS8; break;
74 default: break; 69 default: break;
75 } 70 }
76 71
77 /* Raw, no echo mode */ 72 /* Raw, no echo mode */
78 tty.c_iflag = IGNBRK; 73 tty.c_iflag = IGNBRK;
79 tty.c_lflag = 0; 74 tty.c_lflag = 0;
80 tty.c_oflag = 0; 75 tty.c_oflag = 0;
81 tty.c_cflag |= CLOCAL | CREAD; 76 tty.c_cflag |= CLOCAL | CREAD;
82 77
83 /* Stop bits */ 78 /* Stop bits */
84 if (m_sbits == 2) { 79 if (m_sbits == 2) {
85 tty.c_cflag |= CSTOPB; 80 tty.c_cflag |= CSTOPB;
86 } else { 81 } else {
87 tty.c_cflag &= ~CSTOPB; 82 tty.c_cflag &= ~CSTOPB;
88 } 83 }
89 84
90 tty.c_cc[VMIN] = 1; 85 tty.c_cc[VMIN] = 1;
91 tty.c_cc[VTIME] = 5; 86 tty.c_cc[VTIME] = 5;
92 87
93 /* Flow control */ 88 /* Flow control */
94 if (m_flow & FlowSW) 89 if (m_flow & FlowSW)
95 tty.c_iflag |= IXON | IXOFF; 90 tty.c_iflag |= IXON | IXOFF;
96 else 91 else
97 tty.c_iflag &= ~(IXON|IXOFF|IXANY); 92 tty.c_iflag &= ~(IXON|IXOFF|IXANY);
98 93
99 if (m_flow & FlowHW) 94 if (m_flow & FlowHW)
100 tty.c_cflag |= CRTSCTS; 95 tty.c_cflag |= CRTSCTS;
101 else 96 else
102 tty.c_cflag &= ~CRTSCTS; 97 tty.c_cflag &= ~CRTSCTS;
103 98
104 /* Parity */ 99 /* Parity */
105 tty.c_cflag &= ~(PARENB | PARODD); 100 tty.c_cflag &= ~(PARENB | PARODD);
106 if (m_parity & ParityEven) 101 if (m_parity & ParityEven)
107 tty.c_cflag |= PARENB; 102 tty.c_cflag |= PARENB;
108 else if (m_parity & ParityOdd) 103 else if (m_parity & ParityOdd)
109 tty.c_cflag |= (PARENB | PARODD); 104 tty.c_cflag |= (PARENB | PARODD);
110 105
111 /* Set the changes */ 106 /* Set the changes */
112 tcsetattr(m_fd, TCSANOW, &tty); 107 tcsetattr(m_fd, TCSANOW, &tty);
113 108
114 /* Notifications on read & errors */ 109 /* Notifications on read & errors */
115 m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this); 110 m_read = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
116 m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this); 111 m_error = new QSocketNotifier(m_fd, QSocketNotifier::Exception, this);
117 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); 112 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
118 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); 113 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
119 return TRUE; 114 return TRUE;
120 } else { 115 } else {
121 qWarning(" already opened");
122 emit error(Refuse, tr("Device is already connected")); 116 emit error(Refuse, tr("Device is already connected"));
123 m_fd = 0; 117 m_fd = 0;
124 return FALSE; 118 return FALSE;
125 } 119 }
126} 120}
127 121
128void IOSerial::reload(const Profile &config) { 122void IOSerial::reload(const Profile &config) {
129 m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE); 123 m_device = config.readEntry("Device", SERIAL_DEFAULT_DEVICE);
130 qWarning( "Dev" +m_device );
131 qWarning( "Conf:" +config.readEntry("Device") );
132 m_baud = config.readNumEntry("Speed", SERIAL_DEFAULT_BAUD); 124 m_baud = config.readNumEntry("Speed", SERIAL_DEFAULT_BAUD);
133 m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY); 125 m_parity = config.readNumEntry("Parity", SERIAL_DEFAULT_PARITY);
134 m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS); 126 m_dbits = config.readNumEntry("DataBits", SERIAL_DEFAULT_DBITS);
135 m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS); 127 m_sbits = config.readNumEntry("StopBits", SERIAL_DEFAULT_SBITS);
136 m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW); 128 m_flow = config.readNumEntry("Flow", SERIAL_DEFAULT_FLOW);
137 129
138} 130}
139 131
140int IOSerial::baud(int baud) const { 132int IOSerial::baud(int baud) const {
141 switch (baud) { 133 switch (baud) {
142 case 300: return B300; break; 134 case 300: return B300; break;
143 case 600: return B600; break; 135 case 600: return B600; break;
144 case 1200: return B1200; break; 136 case 1200: return B1200; break;
145 case 2400: return B2400; break; 137 case 2400: return B2400; break;
146 case 4800: return B4800; break; 138 case 4800: return B4800; break;
147 case 9600: return B9600; break; 139 case 9600: return B9600; break;
148 case 19200: return B19200; break; 140 case 19200: return B19200; break;
149 case 38400: return B38400; break; 141 case 38400: return B38400; break;
150 case 57600: return B57600; break; 142 case 57600: return B57600; break;
151 case 115200: return B115200; break; 143 case 115200: return B115200; break;
152 } 144 }
153 return -1; 145 return -1;
154} 146}
155 147
156void IOSerial::errorOccured() { 148void IOSerial::errorOccured() {
157 emit error(ClosedUnexpected, strerror(errno)); 149 emit error(ClosedUnexpected, strerror(errno));
158 close(); 150 close();
159} 151}
160 152
161void IOSerial::dataArrived() { 153void IOSerial::dataArrived() {
162 QByteArray array(4097); 154 QByteArray array(4097);
163 155
164 int len = read(m_fd, array.data(), 4096); 156 int len = read(m_fd, array.data(), 4096);
165 if (len == 0) 157 if (len == 0)
166 close(); 158 close();
167 if (len < 0) 159 if (len < 0)
168 return; 160 return;
169 array.resize( len ); 161 array.resize( len );
170 emit received(array); 162 emit received(array);
171} 163}
172 164
173QString IOSerial::identifier() const { 165QString IOSerial::identifier() const {
174 return "serial"; 166 return "serial";
175} 167}
176 168
177QString IOSerial::name() const { 169QString IOSerial::name() const {
178 return "RS232 Serial IO Layer"; 170 return "RS232 Serial IO Layer";
179} 171}
180int IOSerial::rawIO()const { 172int IOSerial::rawIO()const {
181 if (m_read ) 173 if (m_read )
182 disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); 174 disconnect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
183 if (m_error ) 175 if (m_error )
184 disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); 176 disconnect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
185 177
186 int fd = ::open(m_device, O_RDWR ); 178 int fd = ::open(m_device, O_RDWR );
187 179
188 return fd; 180 return fd;
189}; 181};
190void IOSerial::closeRawIO(int fd) { 182void IOSerial::closeRawIO(int fd) {
191 if (m_read ) 183 if (m_read )
192 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived())); 184 connect(m_read, SIGNAL(activated(int)), this, SLOT(dataArrived()));
193 if (m_error ) 185 if (m_error )
194 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured())); 186 connect(m_error, SIGNAL(activated(int)), this, SLOT(errorOccured()));
195 187
196 ::close( fd ); 188 ::close( fd );
197} 189}
diff --git a/noncore/apps/opie-console/iolayerbase.cpp b/noncore/apps/opie-console/iolayerbase.cpp
index 49ed284..b0df02d 100644
--- a/noncore/apps/opie-console/iolayerbase.cpp
+++ b/noncore/apps/opie-console/iolayerbase.cpp
@@ -36,135 +36,132 @@ IOLayerBase::IOLayerBase( QWidget* par, const char* name )
36{ 36{
37 m_speedLabel = new QLabel(tr("Speed"), this ); 37 m_speedLabel = new QLabel(tr("Speed"), this );
38 m_speedBox = new QComboBox(this ); 38 m_speedBox = new QComboBox(this );
39 39
40 m_groupFlow = new QButtonGroup(tr("Flow control"),this ); 40 m_groupFlow = new QButtonGroup(tr("Flow control"),this );
41 m_flowHw = new QRadioButton(tr("Hardware"), m_groupFlow ); 41 m_flowHw = new QRadioButton(tr("Hardware"), m_groupFlow );
42 m_flowSw = new QRadioButton(tr("Software"), m_groupFlow ); 42 m_flowSw = new QRadioButton(tr("Software"), m_groupFlow );
43 m_flowNone = new QRadioButton( tr("None"), m_groupFlow ); 43 m_flowNone = new QRadioButton( tr("None"), m_groupFlow );
44 44
45 m_groupParity = new QButtonGroup(tr("Parity"), this ); 45 m_groupParity = new QButtonGroup(tr("Parity"), this );
46 m_parityNone = new QRadioButton(tr("None"), m_groupParity ); 46 m_parityNone = new QRadioButton(tr("None"), m_groupParity );
47 m_parityOdd = new QRadioButton(tr("Odd"), m_groupParity ); 47 m_parityOdd = new QRadioButton(tr("Odd"), m_groupParity );
48 m_parityEven = new QRadioButton(tr("Even"), m_groupParity ); 48 m_parityEven = new QRadioButton(tr("Even"), m_groupParity );
49 49
50 m_lroot = new QVBoxLayout( this ); 50 m_lroot = new QVBoxLayout( this );
51 m_lroot->add(m_speedLabel ); 51 m_lroot->add(m_speedLabel );
52 m_lroot->add(m_speedBox ); 52 m_lroot->add(m_speedBox );
53 m_lroot->setStretchFactor(m_speedLabel, 1); 53 m_lroot->setStretchFactor(m_speedLabel, 1);
54 m_lroot->setStretchFactor(m_speedBox, 1 ); 54 m_lroot->setStretchFactor(m_speedBox, 1 );
55 55
56 m_hbox = new QHBoxLayout(m_groupFlow, 2 ); 56 m_hbox = new QHBoxLayout(m_groupFlow, 2 );
57 m_hbox->add(m_flowHw ); 57 m_hbox->add(m_flowHw );
58 m_hbox->add(m_flowSw ); 58 m_hbox->add(m_flowSw );
59 m_hbox->add(m_flowNone ); 59 m_hbox->add(m_flowNone );
60 m_lroot->add(m_groupFlow ); 60 m_lroot->add(m_groupFlow );
61 m_lroot->setStretchFactor(m_groupFlow, 2 ); 61 m_lroot->setStretchFactor(m_groupFlow, 2 );
62 62
63 m_hboxPar = new QHBoxLayout( m_groupParity, 2 ); 63 m_hboxPar = new QHBoxLayout( m_groupParity, 2 );
64 m_hboxPar->add(m_parityOdd ); 64 m_hboxPar->add(m_parityOdd );
65 m_hboxPar->add(m_parityEven ); 65 m_hboxPar->add(m_parityEven );
66 m_hboxPar->add(m_parityNone ); 66 m_hboxPar->add(m_parityNone );
67 m_lroot->add(m_groupParity ); 67 m_lroot->add(m_groupParity );
68 m_lroot->setStretchFactor(m_groupParity, 2 ); 68 m_lroot->setStretchFactor(m_groupParity, 2 );
69 m_lroot->addStretch(2); 69 m_lroot->addStretch(2);
70 70
71 // profiles 71 // profiles
72 m_speedBox->insertItem(tr("115200 baud"), id_baud_115200 ); 72 m_speedBox->insertItem(tr("115200 baud"), id_baud_115200 );
73 m_speedBox->insertItem(tr("57600 baud"), id_baud_57600 ); 73 m_speedBox->insertItem(tr("57600 baud"), id_baud_57600 );
74 m_speedBox->insertItem(tr("38400 baud"), id_baud_38400 ); 74 m_speedBox->insertItem(tr("38400 baud"), id_baud_38400 );
75 m_speedBox->insertItem(tr("19200 baud"), id_baud_19200 ); 75 m_speedBox->insertItem(tr("19200 baud"), id_baud_19200 );
76 m_speedBox->insertItem(tr("9600 baud"), id_baud_9600 ); 76 m_speedBox->insertItem(tr("9600 baud"), id_baud_9600 );
77 77
78}; 78};
79IOLayerBase::~IOLayerBase() { 79IOLayerBase::~IOLayerBase() {
80 80
81} 81}
82void IOLayerBase::setFlow( Flow flo ) { 82void IOLayerBase::setFlow( Flow flo ) {
83 switch ( flo ) { 83 switch ( flo ) {
84 case Software: 84 case Software:
85 m_flowSw->setChecked( true ); 85 m_flowSw->setChecked( true );
86 break; 86 break;
87 case Hardware: 87 case Hardware:
88 m_flowHw->setChecked( true ); 88 m_flowHw->setChecked( true );
89 break; 89 break;
90 case None: 90 case None:
91 m_flowNone->setChecked( true ); 91 m_flowNone->setChecked( true );
92 break; 92 break;
93 } 93 }
94} 94}
95 95
96void IOLayerBase::setParity( Parity par ) { 96void IOLayerBase::setParity( Parity par ) {
97 switch( par ) { 97 switch( par ) {
98 case NonePar: 98 case NonePar:
99 m_parityNone->setChecked( true ); 99 m_parityNone->setChecked( true );
100 break; 100 break;
101 case Odd: 101 case Odd:
102 m_parityOdd->setChecked( true ); 102 m_parityOdd->setChecked( true );
103 break; 103 break;
104 case Even: 104 case Even:
105 m_parityEven->setChecked( true ); 105 m_parityEven->setChecked( true );
106 break; 106 break;
107 } 107 }
108} 108}
109void IOLayerBase::setSpeed( Speed sp ) { 109void IOLayerBase::setSpeed( Speed sp ) {
110 int index; 110 int index;
111 switch( sp ) { 111 switch( sp ) {
112 case Baud_115200: 112 case Baud_115200:
113 index = id_baud_115200; 113 index = id_baud_115200;
114 break; 114 break;
115 case Baud_57600: 115 case Baud_57600:
116 index = id_baud_57600; 116 index = id_baud_57600;
117 break; 117 break;
118 case Baud_38400: 118 case Baud_38400:
119 index = id_baud_38400; 119 index = id_baud_38400;
120 break; 120 break;
121 case Baud_19200: 121 case Baud_19200:
122 index = id_baud_19200; 122 index = id_baud_19200;
123 break; 123 break;
124 case Baud_9600: 124 case Baud_9600:
125 index = id_baud_9600; 125 index = id_baud_9600;
126 break; 126 break;
127 } 127 }
128 m_speedBox->setCurrentItem(index ); 128 m_speedBox->setCurrentItem(index );
129} 129}
130IOLayerBase::Flow IOLayerBase::flow()const { 130IOLayerBase::Flow IOLayerBase::flow()const {
131 if (m_flowHw->isChecked() ) { 131 if (m_flowHw->isChecked() ) {
132 qWarning("Hardware flow");
133 return Hardware; 132 return Hardware;
134 }else if( m_flowSw->isChecked() ) { 133 }else if( m_flowSw->isChecked() ) {
135 qWarning("Software");
136 return Software; 134 return Software;
137 } else { 135 } else {
138 qWarning("None");
139 return None; 136 return None;
140 } 137 }
141} 138}
142IOLayerBase::Parity IOLayerBase::parity()const { 139IOLayerBase::Parity IOLayerBase::parity()const {
143 if ( m_parityOdd->isChecked() ) { 140 if ( m_parityOdd->isChecked() ) {
144 return Odd; 141 return Odd;
145 } else if ( m_parityEven->isChecked() ) { 142 } else if ( m_parityEven->isChecked() ) {
146 return Even; 143 return Even;
147 } else { 144 } else {
148 return NonePar; 145 return NonePar;
149 } 146 }
150 147
151} 148}
152IOLayerBase::Speed IOLayerBase::speed()const{ 149IOLayerBase::Speed IOLayerBase::speed()const{
153 switch( m_speedBox->currentItem() ) { 150 switch( m_speedBox->currentItem() ) {
154 case id_baud_115200: 151 case id_baud_115200:
155 return Baud_115200; 152 return Baud_115200;
156 break; 153 break;
157 case id_baud_57600: 154 case id_baud_57600:
158 return Baud_57600; 155 return Baud_57600;
159 break; 156 break;
160 case id_baud_38400: 157 case id_baud_38400:
161 return Baud_38400; 158 return Baud_38400;
162 break; 159 break;
163 case id_baud_19200: 160 case id_baud_19200:
164 return Baud_19200; 161 return Baud_19200;
165 break; 162 break;
166 case id_baud_9600: 163 case id_baud_9600:
167 return Baud_9600; 164 return Baud_9600;
168 break; 165 break;
169 } 166 }
170} 167}
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index b770551..94c99bc 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -170,312 +170,307 @@ void MainWindow::initUI() {
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 208
209 209
210 210
211 m_connect->setEnabled( false ); 211 m_connect->setEnabled( false );
212 m_disconnect->setEnabled( false ); 212 m_disconnect->setEnabled( false );
213 m_terminate->setEnabled( false ); 213 m_terminate->setEnabled( false );
214 m_transfer->setEnabled( false ); 214 m_transfer->setEnabled( false );
215 m_recordScript->setEnabled( false ); 215 m_recordScript->setEnabled( false );
216 m_saveScript->setEnabled( false ); 216 m_saveScript->setEnabled( false );
217 m_runScript->setEnabled( false ); 217 m_runScript->setEnabled( false );
218 m_fullscreen->setEnabled( false ); 218 m_fullscreen->setEnabled( false );
219 m_closewindow->setEnabled( false ); 219 m_closewindow->setEnabled( false );
220 220
221 /* 221 /*
222 * connect to the menu activation 222 * connect to the menu activation
223 */ 223 */
224 connect( m_sessionsPop, SIGNAL(activated( int ) ), 224 connect( m_sessionsPop, SIGNAL(activated( int ) ),
225 this, SLOT(slotProfile( int ) ) ); 225 this, SLOT(slotProfile( int ) ) );
226 226
227 m_consoleWindow = new TabWidget( this, "blah"); 227 m_consoleWindow = new TabWidget( this, "blah");
228 connect(m_consoleWindow, SIGNAL(activated(Session*) ), 228 connect(m_consoleWindow, SIGNAL(activated(Session*) ),
229 this, SLOT(slotSessionChanged(Session*) ) ); 229 this, SLOT(slotSessionChanged(Session*) ) );
230 setCentralWidget( m_consoleWindow ); 230 setCentralWidget( m_consoleWindow );
231 231
232} 232}
233 233
234ProfileManager* MainWindow::manager() { 234ProfileManager* MainWindow::manager() {
235 return m_manager; 235 return m_manager;
236} 236}
237TabWidget* MainWindow::tabWidget() { 237TabWidget* MainWindow::tabWidget() {
238 return m_consoleWindow; 238 return m_consoleWindow;
239} 239}
240void MainWindow::populateProfiles() { 240void MainWindow::populateProfiles() {
241 m_sessionsPop->clear(); 241 m_sessionsPop->clear();
242 Profile::ValueList list = manager()->all(); 242 Profile::ValueList list = manager()->all();
243 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { 243 for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
244 m_sessionsPop->insertItem( (*it).name() ); 244 m_sessionsPop->insertItem( (*it).name() );
245 } 245 }
246 246
247} 247}
248MainWindow::~MainWindow() { 248MainWindow::~MainWindow() {
249 delete m_factory; 249 delete m_factory;
250 manager()->save(); 250 manager()->save();
251} 251}
252 252
253MetaFactory* MainWindow::factory() { 253MetaFactory* MainWindow::factory() {
254 return m_factory; 254 return m_factory;
255} 255}
256 256
257Session* MainWindow::currentSession() { 257Session* MainWindow::currentSession() {
258 return m_curSession; 258 return m_curSession;
259} 259}
260 260
261QList<Session> MainWindow::sessions() { 261QList<Session> MainWindow::sessions() {
262 return m_sessions; 262 return m_sessions;
263} 263}
264 264
265void MainWindow::slotNew() { 265void MainWindow::slotNew() {
266 qWarning("New Connection");
267 ProfileEditorDialog dlg(factory() ); 266 ProfileEditorDialog dlg(factory() );
268 dlg.showMaximized(); 267 dlg.showMaximized();
269 int ret = dlg.exec(); 268 int ret = dlg.exec();
270 269
271 if ( ret == QDialog::Accepted ) { 270 if ( ret == QDialog::Accepted ) {
272 create( dlg.profile() ); 271 create( dlg.profile() );
273 } 272 }
274} 273}
275 274
276void MainWindow::slotRecordScript() { 275void MainWindow::slotRecordScript() {
277/* if (currentSession()) { 276/* if (currentSession()) {
278 currentSession()->emulationLayer()->startRecording(); 277 currentSession()->emulationLayer()->startRecording();
279 } 278 }
280 */ 279 */
281} 280}
282 281
283void MainWindow::slotSaveScript() { 282void MainWindow::slotSaveScript() {
284/* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { 283/* if (currentSession() && currentSession()->emulationLayer()->isRecording()) {
285 MimeTypes types; 284 MimeTypes types;
286 QStringList script; 285 QStringList script;
287 script << "text/plain"; 286 script << "text/plain";
288 types.insert("Script", script); 287 types.insert("Script", script);
289 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); 288 QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types);
290 if (!filename.isEmpty()) { 289 if (!filename.isEmpty()) {
291 currentSession()->emulationLayer()->script()->saveTo(filename); 290 currentSession()->emulationLayer()->script()->saveTo(filename);
292 currentSession()->emulationLayer()->clearScript(); 291 currentSession()->emulationLayer()->clearScript();
293 } 292 }
294 } 293 }
295 */ 294 */
296} 295}
297 296
298void MainWindow::slotRunScript() { 297void MainWindow::slotRunScript() {
299/* 298/*
300 if (currentSession()) { 299 if (currentSession()) {
301 MimeTypes types; 300 MimeTypes types;
302 QStringList script; 301 QStringList script;
303 script << "text/plain"; 302 script << "text/plain";
304 types.insert("Script", script); 303 types.insert("Script", script);
305 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); 304 QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types);
306 if (!filename.isEmpty()) { 305 if (!filename.isEmpty()) {
307 Script script(DocLnk(filename).file()); 306 Script script(DocLnk(filename).file());
308 currentSession()->emulationLayer()->runScript(&script); 307 currentSession()->emulationLayer()->runScript(&script);
309 } 308 }
310 } 309 }
311 */ 310 */
312} 311}
313 312
314void MainWindow::slotConnect() { 313void MainWindow::slotConnect() {
315 if ( currentSession() ) { 314 if ( currentSession() ) {
316 bool ret = currentSession()->layer()->open(); 315 bool ret = currentSession()->layer()->open();
317 if(!ret) QMessageBox::warning(currentSession()->widgetStack(), 316 if(!ret) QMessageBox::warning(currentSession()->widgetStack(),
318 QObject::tr("Failed"), 317 QObject::tr("Failed"),
319 QObject::tr("Connecting failed for this session.")); 318 QObject::tr("Connecting failed for this session."));
320 m_connect->setEnabled( false ); 319 m_connect->setEnabled( false );
321 m_disconnect->setEnabled( true ); 320 m_disconnect->setEnabled( true );
322 } 321 }
323} 322}
324 323
325void MainWindow::slotDisconnect() { 324void MainWindow::slotDisconnect() {
326 if ( currentSession() ) { 325 if ( currentSession() ) {
327 currentSession()->layer()->close(); 326 currentSession()->layer()->close();
328 m_connect->setEnabled( true ); 327 m_connect->setEnabled( true );
329 m_disconnect->setEnabled( false ); 328 m_disconnect->setEnabled( false );
330 } 329 }
331} 330}
332 331
333void MainWindow::slotTerminate() { 332void MainWindow::slotTerminate() {
334 if ( currentSession() ) 333 if ( currentSession() )
335 currentSession()->layer()->close(); 334 currentSession()->layer()->close();
336 335
337 slotClose(); 336 slotClose();
338 /* FIXME move to the next session */ 337 /* FIXME move to the next session */
339} 338}
340 339
341void MainWindow::slotConfigure() { 340void MainWindow::slotConfigure() {
342 qWarning("configure");
343 ConfigDialog conf( manager()->all(), factory() ); 341 ConfigDialog conf( manager()->all(), factory() );
344 conf.showMaximized(); 342 conf.showMaximized();
345 343
346 int ret = conf.exec(); 344 int ret = conf.exec();
347 345
348 if ( QDialog::Accepted == ret ) { 346 if ( QDialog::Accepted == ret ) {
349 qWarning("conf %d", conf.list().count() );
350 manager()->setProfiles( conf.list() ); 347 manager()->setProfiles( conf.list() );
351 manager()->save(); 348 manager()->save();
352 populateProfiles(); 349 populateProfiles();
353 } 350 }
354} 351}
355/* 352/*
356 * we will remove 353 * we will remove
357 * this window from the tabwidget 354 * this window from the tabwidget
358 * remove it from the list 355 * remove it from the list
359 * delete it 356 * delete it
360 * and set the currentSession() 357 * and set the currentSession()
361 */ 358 */
362void MainWindow::slotClose() { 359void MainWindow::slotClose() {
363 qWarning("close");
364 if (!currentSession() ) 360 if (!currentSession() )
365 return; 361 return;
366 362
367 tabWidget()->remove( currentSession() ); 363 tabWidget()->remove( currentSession() );
368 /*it's autodelete */ 364 /*it's autodelete */
369 m_sessions.remove( m_curSession ); 365 m_sessions.remove( m_curSession );
370 m_curSession = m_sessions.first(); 366 m_curSession = m_sessions.first();
371 tabWidget()->setCurrent( m_curSession ); 367 tabWidget()->setCurrent( m_curSession );
372 368
373 if (!currentSession() ) { 369 if (!currentSession() ) {
374 m_connect->setEnabled( false ); 370 m_connect->setEnabled( false );
375 m_disconnect->setEnabled( false ); 371 m_disconnect->setEnabled( false );
376 m_terminate->setEnabled( false ); 372 m_terminate->setEnabled( false );
377 m_transfer->setEnabled( false ); 373 m_transfer->setEnabled( false );
378 m_recordScript->setEnabled( false ); 374 m_recordScript->setEnabled( false );
379 m_saveScript->setEnabled( false ); 375 m_saveScript->setEnabled( false );
380 m_runScript->setEnabled( false ); 376 m_runScript->setEnabled( false );
381 m_fullscreen->setEnabled( false ); 377 m_fullscreen->setEnabled( false );
382 m_closewindow->setEnabled( false ); 378 m_closewindow->setEnabled( false );
383 } 379 }
384} 380}
385 381
386/* 382/*
387 * We will get the name 383 * We will get the name
388 * Then the profile 384 * Then the profile
389 * and then we will make a profile 385 * and then we will make a profile
390 */ 386 */
391void MainWindow::slotProfile( int id) { 387void MainWindow::slotProfile( int id) {
392 Profile prof = manager()->profile( m_sessionsPop->text( id) ); 388 Profile prof = manager()->profile( m_sessionsPop->text( id) );
393 create( prof ); 389 create( prof );
394} 390}
395void MainWindow::create( const Profile& prof ) { 391void MainWindow::create( const Profile& prof ) {
396 Session *ses = manager()->fromProfile( prof, tabWidget() ); 392 Session *ses = manager()->fromProfile( prof, tabWidget() );
397 393
398 if((!ses) || (!ses->layer()) || (!ses->widgetStack())) 394 if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
399 { 395 {
400 QMessageBox::warning(this, 396 QMessageBox::warning(this,
401 QObject::tr("Session failed"), 397 QObject::tr("Session failed"),
402 QObject::tr("Cannot open session: Not all components were found.")); 398 QObject::tr("Cannot open session: Not all components were found."));
403 //if(ses) delete ses; 399 //if(ses) delete ses;
404 return; 400 return;
405 } 401 }
406 402
407 m_sessions.append( ses ); 403 m_sessions.append( ses );
408 tabWidget()->add( ses ); 404 tabWidget()->add( ses );
409 m_curSession = ses; 405 m_curSession = ses;
410 406
411 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it 407 // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it
412 m_connect->setEnabled( true ); 408 m_connect->setEnabled( true );
413 m_disconnect->setEnabled( false ); 409 m_disconnect->setEnabled( false );
414 m_terminate->setEnabled( true ); 410 m_terminate->setEnabled( true );
415 m_transfer->setEnabled( true ); 411 m_transfer->setEnabled( true );
416 m_recordScript->setEnabled( true ); 412 m_recordScript->setEnabled( true );
417 m_saveScript->setEnabled( true ); 413 m_saveScript->setEnabled( true );
418 m_runScript->setEnabled( true ); 414 m_runScript->setEnabled( true );
419 m_fullscreen->setEnabled( true ); 415 m_fullscreen->setEnabled( true );
420 m_closewindow->setEnabled( true ); 416 m_closewindow->setEnabled( true );
421} 417}
422 418
423void MainWindow::slotTransfer() 419void MainWindow::slotTransfer()
424{ 420{
425 if ( currentSession() ) { 421 if ( currentSession() ) {
426 TransferDialog dlg(this); 422 TransferDialog dlg(this);
427 dlg.showMaximized(); 423 dlg.showMaximized();
428 dlg.exec(); 424 dlg.exec();
429 } 425 }
430} 426}
431 427
432 428
433void MainWindow::slotOpenKeb(bool state) { 429void MainWindow::slotOpenKeb(bool state) {
434 430
435 if (state) m_keyBar->show(); 431 if (state) m_keyBar->show();
436 else m_keyBar->hide(); 432 else m_keyBar->hide();
437 433
438} 434}
439void MainWindow::slotSessionChanged( Session* ses ) { 435void MainWindow::slotSessionChanged( Session* ses ) {
440 if ( ses ) { 436 if ( ses ) {
441 qWarning("changing %s", ses->name().latin1() );
442 m_curSession = ses; 437 m_curSession = ses;
443 438
444 if ( m_curSession->isConnected() ) { 439 if ( m_curSession->isConnected() ) {
445 m_connect->setEnabled( false ); 440 m_connect->setEnabled( false );
446 m_disconnect->setEnabled( true ); 441 m_disconnect->setEnabled( true );
447 } else { 442 } else {
448 m_connect->setEnabled( true ); 443 m_connect->setEnabled( true );
449 m_disconnect->setEnabled( false ); 444 m_disconnect->setEnabled( false );
450 } 445 }
451 } 446 }
452} 447}
453 448
454void MainWindow::slotFullscreen() { 449void MainWindow::slotFullscreen() {
455 450
456 if ( m_isFullscreen ) { 451 if ( m_isFullscreen ) {
457 ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); 452 ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false );
458 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); 453 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken );
459 setCentralWidget( m_consoleWindow ); 454 setCentralWidget( m_consoleWindow );
460 ( m_curSession->widgetStack() )->show(); 455 ( m_curSession->widgetStack() )->show();
461 m_fullscreen->setText( tr("Full screen") ); 456 m_fullscreen->setText( tr("Full screen") );
462 457
463 } else { 458 } else {
464 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); 459 ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame );
465 ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop, 460 ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop,
466 QPoint(0,0), false); 461 QPoint(0,0), false);
467 ( m_curSession->widgetStack() )->resize(qApp->desktop()->width(), qApp->desktop()->height()); 462 ( m_curSession->widgetStack() )->resize(qApp->desktop()->width(), qApp->desktop()->height());
468 ( m_curSession->widgetStack() )->setFocus(); 463 ( m_curSession->widgetStack() )->setFocus();
469 ( m_curSession->widgetStack() )->show(); 464 ( m_curSession->widgetStack() )->show();
470 465
471 //QPushButton *cornerButton = new QPushButton( ); 466 //QPushButton *cornerButton = new QPushButton( );
472 //cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) ); 467 //cornerButton->setPixmap( QPixmap( (const char**)menu_xpm ) );
473 //connect( cornerButton, SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); 468 //connect( cornerButton, SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) );
474 // need teh scrollbar 469 // need teh scrollbar
475 // ( m_curSession->widgetStack() )->setCornerWidget( cornerButton ); 470 // ( m_curSession->widgetStack() )->setCornerWidget( cornerButton );
476 m_fullscreen->setText( tr("Stop full screen") ); 471 m_fullscreen->setText( tr("Stop full screen") );
477 } 472 }
478 473
479 m_isFullscreen = !m_isFullscreen; 474 m_isFullscreen = !m_isFullscreen;
480 475
481} 476}
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp
index 09ba586..04a5dfa 100644
--- a/noncore/apps/opie-console/metafactory.cpp
+++ b/noncore/apps/opie-console/metafactory.cpp
@@ -27,145 +27,144 @@ void MetaFactory::addIOLayerFactory( const QCString& name,
27void MetaFactory::addFileTransferLayer( const QCString& name, 27void MetaFactory::addFileTransferLayer( const QCString& name,
28 const QString& str, 28 const QString& str,
29 filelayer lay) { 29 filelayer lay) {
30 m_strings.insert(str, name ); 30 m_strings.insert(str, name );
31 m_fileFact.insert( str, lay ); 31 m_fileFact.insert( str, lay );
32} 32}
33void MetaFactory::addReceiveLayer( const QCString& name, 33void MetaFactory::addReceiveLayer( const QCString& name,
34 const QString& str, 34 const QString& str,
35 receivelayer lay) { 35 receivelayer lay) {
36 m_strings.insert(str, name ); 36 m_strings.insert(str, name );
37 m_receiveFact.insert( str, lay ); 37 m_receiveFact.insert( str, lay );
38} 38}
39void MetaFactory::addEmulationLayer( const QCString& name, 39void MetaFactory::addEmulationLayer( const QCString& name,
40 const QString& str, 40 const QString& str,
41 emulationLayer em) { 41 emulationLayer em) {
42 m_strings.insert(str, name ); 42 m_strings.insert(str, name );
43 m_emu.insert( str, em ); 43 m_emu.insert( str, em );
44} 44}
45QStringList MetaFactory::ioLayers()const { 45QStringList MetaFactory::ioLayers()const {
46 QStringList list; 46 QStringList list;
47 QMap<QString, iolayer>::ConstIterator it; 47 QMap<QString, iolayer>::ConstIterator it;
48 for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { 48 for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) {
49 list << it.key(); 49 list << it.key();
50 } 50 }
51 return list; 51 return list;
52} 52}
53QStringList MetaFactory::connectionWidgets()const { 53QStringList MetaFactory::connectionWidgets()const {
54 QStringList list; 54 QStringList list;
55 QMap<QString, configWidget>::ConstIterator it; 55 QMap<QString, configWidget>::ConstIterator it;
56 for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) { 56 for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) {
57 list << it.key(); 57 list << it.key();
58 } 58 }
59 return list; 59 return list;
60} 60}
61QStringList MetaFactory::terminalWidgets()const { 61QStringList MetaFactory::terminalWidgets()const {
62 QStringList list; 62 QStringList list;
63 QMap<QString, configWidget>::ConstIterator it; 63 QMap<QString, configWidget>::ConstIterator it;
64 for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) { 64 for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) {
65 list << it.key(); 65 list << it.key();
66 } 66 }
67 return list; 67 return list;
68} 68}
69QStringList MetaFactory::fileTransferLayers()const { 69QStringList MetaFactory::fileTransferLayers()const {
70 QStringList list; 70 QStringList list;
71 QMap<QString, filelayer>::ConstIterator it; 71 QMap<QString, filelayer>::ConstIterator it;
72 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { 72 for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) {
73 list << it.key(); 73 list << it.key();
74 } 74 }
75 return list; 75 return list;
76} 76}
77QStringList MetaFactory::receiveLayers()const { 77QStringList MetaFactory::receiveLayers()const {
78 QStringList list; 78 QStringList list;
79 QMap<QString, receivelayer>::ConstIterator it; 79 QMap<QString, receivelayer>::ConstIterator it;
80 for ( it = m_receiveFact.begin(); it != m_receiveFact.end(); ++it ) { 80 for ( it = m_receiveFact.begin(); it != m_receiveFact.end(); ++it ) {
81 list << it.key(); 81 list << it.key();
82 } 82 }
83 return list; 83 return list;
84} 84}
85QStringList MetaFactory::emulationLayers()const { 85QStringList MetaFactory::emulationLayers()const {
86 QStringList list; 86 QStringList list;
87 QMap<QString, emulationLayer>::ConstIterator it; 87 QMap<QString, emulationLayer>::ConstIterator it;
88 for ( it = m_emu.begin(); it != m_emu.end(); ++it ) { 88 for ( it = m_emu.begin(); it != m_emu.end(); ++it ) {
89 list << it.key(); 89 list << it.key();
90 } 90 }
91 return list; 91 return list;
92} 92}
93 93
94IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { 94IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
95 IOLayer* lay = 0l; 95 IOLayer* lay = 0l;
96 96
97 QMap<QString, iolayer>::Iterator it; 97 QMap<QString, iolayer>::Iterator it;
98 it = m_layerFact.find( str ); 98 it = m_layerFact.find( str );
99 if ( it != m_layerFact.end() ) { 99 if ( it != m_layerFact.end() ) {
100 lay = (*(it.data()))(prof); 100 lay = (*(it.data()))(prof);
101 /* 101 /*
102 iolayer laye = it.data(); 102 iolayer laye = it.data();
103 lay = (*laye )(conf);*/ 103 lay = (*laye )(conf);*/
104 } 104 }
105 105
106 return lay; 106 return lay;
107} 107}
108 108
109ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { 109ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) {
110 ProfileDialogWidget* wid = 0l; 110 ProfileDialogWidget* wid = 0l;
111 111
112 QMap<QString, configWidget>::Iterator it; 112 QMap<QString, configWidget>::Iterator it;
113 it = m_conFact.find( str ); 113 it = m_conFact.find( str );
114 if ( it != m_conFact.end() ) { 114 if ( it != m_conFact.end() ) {
115 wid = (*(it.data() ) )(str,parent); 115 wid = (*(it.data() ) )(str,parent);
116 } 116 }
117 return wid; 117 return wid;
118} 118}
119ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { 119ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) {
120 if (str.isEmpty() ) 120 if (str.isEmpty() )
121 return 0l; 121 return 0l;
122 ProfileDialogWidget* wid = 0l; 122 ProfileDialogWidget* wid = 0l;
123 qWarning("new terminalPlugin %s %l", str.latin1(), parent );
124 123
125 QMap<QString, configWidget>::Iterator it; 124 QMap<QString, configWidget>::Iterator it;
126 it = m_termFact.find( str ); 125 it = m_termFact.find( str );
127 if ( it != m_termFact.end() ) { 126 if ( it != m_termFact.end() ) {
128 wid = (*(it.data() ) )(str,parent); 127 wid = (*(it.data() ) )(str,parent);
129 } 128 }
130 return wid; 129 return wid;
131} 130}
132EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, WidgetLayer* wid) { 131EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, WidgetLayer* wid) {
133 EmulationLayer* lay = 0l; 132 EmulationLayer* lay = 0l;
134 133
135 QMap<QString, emulationLayer>::Iterator it; 134 QMap<QString, emulationLayer>::Iterator it;
136 it = m_emu.find( str ); 135 it = m_emu.find( str );
137 if ( it != m_emu.end() ) { 136 if ( it != m_emu.end() ) {
138 lay = (*(it.data() ) )(wid); 137 lay = (*(it.data() ) )(wid);
139 } 138 }
140 139
141 return lay; 140 return lay;
142} 141}
143FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) { 142FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) {
144 FileTransferLayer* file = 0l; 143 FileTransferLayer* file = 0l;
145 QMap<QString, filelayer>::Iterator it; 144 QMap<QString, filelayer>::Iterator it;
146 it = m_fileFact.find( str ); 145 it = m_fileFact.find( str );
147 if ( it != m_fileFact.end() ) { 146 if ( it != m_fileFact.end() ) {
148 file = (*(it.data() ) )(lay); 147 file = (*(it.data() ) )(lay);
149 } 148 }
150 return file; 149 return file;
151} 150}
152ReceiveLayer* MetaFactory::newReceive(const QString& str, IOLayer* lay ) { 151ReceiveLayer* MetaFactory::newReceive(const QString& str, IOLayer* lay ) {
153 ReceiveLayer* file = 0l; 152 ReceiveLayer* file = 0l;
154 QMap<QString, receivelayer>::Iterator it; 153 QMap<QString, receivelayer>::Iterator it;
155 it = m_receiveFact.find( str ); 154 it = m_receiveFact.find( str );
156 if ( it != m_receiveFact.end() ) { 155 if ( it != m_receiveFact.end() ) {
157 file = (*(it.data() ) )(lay); 156 file = (*(it.data() ) )(lay);
158 } 157 }
159 return file; 158 return file;
160} 159}
161QCString MetaFactory::internal( const QString& str )const { 160QCString MetaFactory::internal( const QString& str )const {
162 return m_strings[str]; 161 return m_strings[str];
163} 162}
164QString MetaFactory::external( const QCString& str )const { 163QString MetaFactory::external( const QCString& str )const {
165 QMap<QString, QCString>::ConstIterator it; 164 QMap<QString, QCString>::ConstIterator it;
166 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { 165 for ( it = m_strings.begin(); it != m_strings.end(); ++it ) {
167 if ( it.data() == str ) 166 if ( it.data() == str )
168 return it.key(); 167 return it.key();
169 } 168 }
170 return QString::null; 169 return QString::null;
171} 170}
diff --git a/noncore/apps/opie-console/procctl.cpp b/noncore/apps/opie-console/procctl.cpp
index d1cfaf6..ff6bea8 100644
--- a/noncore/apps/opie-console/procctl.cpp
+++ b/noncore/apps/opie-console/procctl.cpp
@@ -1,97 +1,96 @@
1#include <sys/wait.h> 1#include <sys/wait.h>
2 2
3#include <fcntl.h> 3#include <fcntl.h>
4#include <unistd.h> 4#include <unistd.h>
5 5
6#include "procctl.h" 6#include "procctl.h"
7 7
8ProcContainer *ProcCtl::m_last = 0; 8ProcContainer *ProcCtl::m_last = 0;
9ProcCtl* ProcCtl::m_self = 0; 9ProcCtl* ProcCtl::m_self = 0;
10 10
11ProcCtl::ProcCtl() { 11ProcCtl::ProcCtl() {
12 signal( SIGCHLD, signal_handler ); 12 signal( SIGCHLD, signal_handler );
13} 13}
14ProcCtl::~ProcCtl() { 14ProcCtl::~ProcCtl() {
15} 15}
16ProcCtl* ProcCtl::self() { 16ProcCtl* ProcCtl::self() {
17 if (!m_self ) { 17 if (!m_self ) {
18 m_self = new ProcCtl; 18 m_self = new ProcCtl;
19 } 19 }
20} 20}
21void ProcCtl::add(pid_t pi, int fd ) { 21void ProcCtl::add(pid_t pi, int fd ) {
22 ProcContainer * con = new ProcContainer; 22 ProcContainer * con = new ProcContainer;
23 //memset(con, 0, sizeof(con) ); 23 //memset(con, 0, sizeof(con) );
24 con->pid = pi; 24 con->pid = pi;
25 con->fd = fd; 25 con->fd = fd;
26 con->status = 0; 26 con->status = 0;
27 con->prev = m_last; 27 con->prev = m_last;
28 28
29 m_last = con; 29 m_last = con;
30 30
31} 31}
32void ProcCtl::remove( pid_t pi ) { 32void ProcCtl::remove( pid_t pi ) {
33 /* 33 /*
34 * We first check if the last item 34 * We first check if the last item
35 * is equal to pi the we 35 * is equal to pi the we
36 * 36 *
37 */ 37 */
38 ProcContainer* con; 38 ProcContainer* con;
39 if (m_last->pid == pi ) { 39 if (m_last->pid == pi ) {
40 con = m_last; 40 con = m_last;
41 m_last = con->prev; 41 m_last = con->prev;
42 delete con; 42 delete con;
43 return; 43 return;
44 } 44 }
45 45
46 con = m_last; 46 con = m_last;
47 ProcContainer* forw = 0l; 47 ProcContainer* forw = 0l;
48 while (con ) { 48 while (con ) {
49 /* remove it */ 49 /* remove it */
50 if ( pi == con->pid ) { 50 if ( pi == con->pid ) {
51 forw->prev = con->prev; 51 forw->prev = con->prev;
52 delete con; 52 delete con;
53 return; 53 return;
54 } 54 }
55 55
56 forw = con; 56 forw = con;
57 con = con->prev; 57 con = con->prev;
58 } 58 }
59 59
60} 60}
61void ProcCtl::remove( ProcContainer con ) { 61void ProcCtl::remove( ProcContainer con ) {
62 remove( con.pid ); 62 remove( con.pid );
63} 63}
64int ProcCtl::status(pid_t pid )const{ 64int ProcCtl::status(pid_t pid )const{
65 ProcContainer *con = m_last; 65 ProcContainer *con = m_last;
66 while (con) { 66 while (con) {
67 if (con->pid == pid ) 67 if (con->pid == pid )
68 return con->status; 68 return con->status;
69 con = con->prev; 69 con = con->prev;
70 } 70 }
71 return -1; 71 return -1;
72} 72}
73void ProcCtl::signal_handler(int) { 73void ProcCtl::signal_handler(int) {
74 qWarning("signal handler in ProcCtl");
75 int status; 74 int status;
76 signal( SIGCHLD, signal_handler ); 75 signal( SIGCHLD, signal_handler );
77 pid_t pi = waitpid( -1, &status, WNOHANG ); 76 pid_t pi = waitpid( -1, &status, WNOHANG );
78 77
79 /* 78 /*
80 * find the container for pid 79 * find the container for pid
81 * 80 *
82 */ 81 */
83 if ( pi < 0 ) { 82 if ( pi < 0 ) {
84 return; 83 return;
85 } 84 }
86 85
87 ProcContainer* con = m_last; 86 ProcContainer* con = m_last;
88 while (con) { 87 while (con) {
89 if ( con->pid == pi ) { 88 if ( con->pid == pi ) {
90 con->status = status; 89 con->status = status;
91 char result = 1; 90 char result = 1;
92 /* give a 'signal' */ 91 /* give a 'signal' */
93 ::write(con->fd, &result, 1 ); 92 ::write(con->fd, &result, 1 );
94 } 93 }
95 con = con->prev; 94 con = con->prev;
96 } 95 }
97} 96}
diff --git a/noncore/apps/opie-console/profile.cpp b/noncore/apps/opie-console/profile.cpp
index ffd672e..1a94619 100644
--- a/noncore/apps/opie-console/profile.cpp
+++ b/noncore/apps/opie-console/profile.cpp
@@ -1,121 +1,119 @@
1#include "profile.h" 1#include "profile.h"
2 2
3Profile::Profile() { 3Profile::Profile() {
4 4
5} 5}
6Profile::Profile( const QString& name, 6Profile::Profile( const QString& name,
7 const QCString& iolayerName, 7 const QCString& iolayerName,
8 const QCString& termName, 8 const QCString& termName,
9 int background, 9 int background,
10 int foreground, 10 int foreground,
11 int terminal ) 11 int terminal )
12 : m_name( name ), m_ioLayer( iolayerName ), m_term( termName), 12 : m_name( name ), m_ioLayer( iolayerName ), m_term( termName),
13 m_back( background ), m_fore( foreground ), m_terminal( terminal ) 13 m_back( background ), m_fore( foreground ), m_terminal( terminal )
14{} 14{}
15Profile::Profile( const Profile& prof ) 15Profile::Profile( const Profile& prof )
16{ 16{
17 (*this) = prof; 17 (*this) = prof;
18} 18}
19bool Profile::operator==( const Profile& prof ) { 19bool Profile::operator==( const Profile& prof ) {
20 if ( m_name == prof.m_name ) return true; 20 if ( m_name == prof.m_name ) return true;
21 21
22 return false; 22 return false;
23} 23}
24Profile &Profile::operator=( const Profile& prof ) { 24Profile &Profile::operator=( const Profile& prof ) {
25 m_name = prof.m_name; 25 m_name = prof.m_name;
26 m_ioLayer = prof.m_ioLayer; 26 m_ioLayer = prof.m_ioLayer;
27 m_back = prof.m_back; 27 m_back = prof.m_back;
28 m_fore = prof.m_fore; 28 m_fore = prof.m_fore;
29 m_terminal = prof.m_terminal; 29 m_terminal = prof.m_terminal;
30 m_conf = prof.m_conf; 30 m_conf = prof.m_conf;
31 m_term = prof.m_term; 31 m_term = prof.m_term;
32 32
33 return *this; 33 return *this;
34} 34}
35Profile::~Profile() { 35Profile::~Profile() {
36} 36}
37QMap<QString, QString> Profile::conf()const { 37QMap<QString, QString> Profile::conf()const {
38 return m_conf; 38 return m_conf;
39} 39}
40QString Profile::name()const { 40QString Profile::name()const {
41 return m_name; 41 return m_name;
42} 42}
43QCString Profile::ioLayerName()const { 43QCString Profile::ioLayerName()const {
44 return m_ioLayer; 44 return m_ioLayer;
45} 45}
46QCString Profile::terminalName( )const { 46QCString Profile::terminalName( )const {
47 return m_term; 47 return m_term;
48} 48}
49int Profile::foreground()const { 49int Profile::foreground()const {
50 return m_fore; 50 return m_fore;
51} 51}
52int Profile::background()const { 52int Profile::background()const {
53 return m_back; 53 return m_back;
54} 54}
55int Profile::terminal()const { 55int Profile::terminal()const {
56 return m_terminal; 56 return m_terminal;
57} 57}
58void Profile::setName( const QString& str ) { 58void Profile::setName( const QString& str ) {
59 m_name = str; 59 m_name = str;
60} 60}
61void Profile::setIOLayer( const QCString& name ) { 61void Profile::setIOLayer( const QCString& name ) {
62 m_ioLayer = name; 62 m_ioLayer = name;
63} 63}
64void Profile::setTerminalName( const QCString& str ) { 64void Profile::setTerminalName( const QCString& str ) {
65 m_term = str; 65 m_term = str;
66} 66}
67void Profile::setBackground( int back ) { 67void Profile::setBackground( int back ) {
68 m_back = back; 68 m_back = back;
69} 69}
70void Profile::setForeground( int fore ) { 70void Profile::setForeground( int fore ) {
71 m_fore = fore; 71 m_fore = fore;
72} 72}
73void Profile::setTerminal( int term ) { 73void Profile::setTerminal( int term ) {
74 m_terminal = term; 74 m_terminal = term;
75} 75}
76/* config stuff */ 76/* config stuff */
77void Profile::clearConf() { 77void Profile::clearConf() {
78 m_conf.clear(); 78 m_conf.clear();
79} 79}
80void Profile::writeEntry( const QString& key, const QString& value ) { 80void Profile::writeEntry( const QString& key, const QString& value ) {
81 qWarning("key %s value %s", key.latin1(), value.latin1() );
82 m_conf.replace( key, value ); 81 m_conf.replace( key, value );
83} 82}
84void Profile::writeEntry( const QString& key, int num ) { 83void Profile::writeEntry( const QString& key, int num ) {
85 qWarning("num");
86 writeEntry( key, QString::number( num ) ); 84 writeEntry( key, QString::number( num ) );
87} 85}
88void Profile::writeEntry( const QString& key, bool b ) { 86void Profile::writeEntry( const QString& key, bool b ) {
89 writeEntry( key, QString::number(b) ); 87 writeEntry( key, QString::number(b) );
90} 88}
91void Profile::writeEntry( const QString& key, const QStringList& lis, const QChar& sep ) { 89void Profile::writeEntry( const QString& key, const QStringList& lis, const QChar& sep ) {
92 writeEntry( key, lis.join(sep) ); 90 writeEntry( key, lis.join(sep) );
93} 91}
94QString Profile::readEntry( const QString& key, const QString& deflt )const { 92QString Profile::readEntry( const QString& key, const QString& deflt )const {
95 QMap<QString, QString>::ConstIterator it; 93 QMap<QString, QString>::ConstIterator it;
96 it = m_conf.find( key ); 94 it = m_conf.find( key );
97 95
98 if ( it != m_conf.end() ) 96 if ( it != m_conf.end() )
99 return it.data(); 97 return it.data();
100 98
101 return deflt; 99 return deflt;
102} 100}
103int Profile::readNumEntry( const QString& key, int def )const { 101int Profile::readNumEntry( const QString& key, int def )const {
104 QMap<QString, QString>::ConstIterator it; 102 QMap<QString, QString>::ConstIterator it;
105 it = m_conf.find( key ); 103 it = m_conf.find( key );
106 104
107 if ( it != m_conf.end() ) { 105 if ( it != m_conf.end() ) {
108 bool ok; 106 bool ok;
109 int val = it.data().toInt(&ok); 107 int val = it.data().toInt(&ok);
110 108
111 if (ok) 109 if (ok)
112 return val; 110 return val;
113 } 111 }
114 return def; 112 return def;
115} 113}
116bool Profile::readBoolEntry( const QString& key, bool def )const { 114bool Profile::readBoolEntry( const QString& key, bool def )const {
117 return readNumEntry( key, def ); 115 return readNumEntry( key, def );
118} 116}
119void Profile::setConf( const QMap<QString, QString>& conf ) { 117void Profile::setConf( const QMap<QString, QString>& conf ) {
120 m_conf = conf; 118 m_conf = conf;
121}; 119};
diff --git a/noncore/apps/opie-console/profileconfig.cpp b/noncore/apps/opie-console/profileconfig.cpp
index 732fae7..bd089c8 100644
--- a/noncore/apps/opie-console/profileconfig.cpp
+++ b/noncore/apps/opie-console/profileconfig.cpp
@@ -1,46 +1,45 @@
1 1
2#include "profileconfig.h" 2#include "profileconfig.h"
3 3
4ProfileConfig::ProfileConfig( const QString& prof ) 4ProfileConfig::ProfileConfig( const QString& prof )
5 : Config( prof ) 5 : Config( prof )
6{ 6{
7} 7}
8ProfileConfig::~ProfileConfig() { 8ProfileConfig::~ProfileConfig() {
9 9
10} 10}
11QStringList ProfileConfig::groups()const { 11QStringList ProfileConfig::groups()const {
12 QStringList list; 12 QStringList list;
13 QMap<QString, ConfigGroup>::ConstIterator it; 13 QMap<QString, ConfigGroup>::ConstIterator it;
14 it= Config::groups.begin(); 14 it= Config::groups.begin();
15 qWarning("config %d", Config::groups.count() );
16 15
17 for (; it != Config::groups.end(); ++it ) 16 for (; it != Config::groups.end(); ++it )
18 list << it.key(); 17 list << it.key();
19 18
20 19
21 return list; 20 return list;
22 21
23} 22}
24void ProfileConfig::clearAll() { 23void ProfileConfig::clearAll() {
25 QMap<QString, ConfigGroup>::ConstIterator it; 24 QMap<QString, ConfigGroup>::ConstIterator it;
26 it = Config::groups.begin(); 25 it = Config::groups.begin();
27 26
28 for ( ; it != Config::groups.end(); ++it ) 27 for ( ; it != Config::groups.end(); ++it )
29 clearGroup( it.key() ); 28 clearGroup( it.key() );
30} 29}
31void ProfileConfig::clearGroup( const QString& str ) { 30void ProfileConfig::clearGroup( const QString& str ) {
32 QString cur =git.key(); 31 QString cur =git.key();
33 setGroup( str ); 32 setGroup( str );
34 Config::clearGroup(); 33 Config::clearGroup();
35 setGroup( cur ); 34 setGroup( cur );
36} 35}
37QMap<QString, QString> ProfileConfig::items( const QString& group )const { 36QMap<QString, QString> ProfileConfig::items( const QString& group )const {
38 QMap<QString, QString> map; 37 QMap<QString, QString> map;
39 QMap<QString, ConfigGroup>::ConstIterator it; 38 QMap<QString, ConfigGroup>::ConstIterator it;
40 it = Config::groups.find( group ); 39 it = Config::groups.find( group );
41 40
42 if (it != Config::groups.end() ) 41 if (it != Config::groups.end() )
43 map = it.data(); 42 map = it.data();
44 43
45 return map; 44 return map;
46} 45}
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index 094c871..b709cf3 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -22,179 +22,172 @@ namespace {
22 } 22 }
23 23
24 24
25} 25}
26 26
27ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, 27ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact,
28 const Profile& prof ) 28 const Profile& prof )
29 : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) 29 : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof )
30{ 30{
31 initUI(); 31 initUI();
32 32
33 // Apply current profile 33 // Apply current profile
34 // plugin_plugin->load(profile); 34 // plugin_plugin->load(profile);
35 // ... (reset profile name line edit etc.) 35 // ... (reset profile name line edit etc.)
36} 36}
37 37
38ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) 38ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
39 : QDialog(0, 0, TRUE), m_fact( fact ) 39 : QDialog(0, 0, TRUE), m_fact( fact )
40{ 40{
41 // Default profile 41 // Default profile
42 m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102); 42 m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102);
43 43
44 initUI(); 44 initUI();
45 45
46 // Apply current profile 46 // Apply current profile
47 // plugin_plugin->load(profile); 47 // plugin_plugin->load(profile);
48} 48}
49 49
50Profile ProfileEditorDialog::profile() const 50Profile ProfileEditorDialog::profile() const
51{ 51{
52 return m_prof; 52 return m_prof;
53} 53}
54 54
55void ProfileEditorDialog::initUI() 55void ProfileEditorDialog::initUI()
56{ 56{
57 m_con = m_term = 0l; 57 m_con = m_term = 0l;
58 58
59 QVBoxLayout *mainLayout = new QVBoxLayout( this ); 59 QVBoxLayout *mainLayout = new QVBoxLayout( this );
60 OTabWidget *tabWidget = new OTabWidget( this ); 60 OTabWidget *tabWidget = new OTabWidget( this );
61 tabWidget->setTabStyle(OTabWidget::TextTab); 61 tabWidget->setTabStyle(OTabWidget::TextTab);
62 mainLayout->add(tabWidget); 62 mainLayout->add(tabWidget);
63 63
64 QWidget *tabprof; 64 QWidget *tabprof;
65 65
66 /* base tabs */ 66 /* base tabs */
67 tabprof = new QWidget(this); 67 tabprof = new QWidget(this);
68 m_tabTerm = new QWidget(this); 68 m_tabTerm = new QWidget(this);
69 m_tabCon = new QWidget(this); 69 m_tabCon = new QWidget(this);
70 70
71 /* base layout for tabs */ 71 /* base layout for tabs */
72 m_layCon = new QHBoxLayout( m_tabCon , 2 ); 72 m_layCon = new QHBoxLayout( m_tabCon , 2 );
73 m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); 73 m_layTerm = new QHBoxLayout( m_tabTerm, 2 );
74 74
75 // profile tab 75 // profile tab
76 76
77 QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); 77 QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
78 m_name = new QLineEdit(tabprof); 78 m_name = new QLineEdit(tabprof);
79 QLabel *con = new QLabel(tr("Connection"), tabprof ); 79 QLabel *con = new QLabel(tr("Connection"), tabprof );
80 QLabel *term = new QLabel(tr("Terminal"), tabprof ); 80 QLabel *term = new QLabel(tr("Terminal"), tabprof );
81 m_conCmb = new QComboBox( tabprof ); 81 m_conCmb = new QComboBox( tabprof );
82 m_termCmb = new QComboBox( tabprof ); 82 m_termCmb = new QComboBox( tabprof );
83 83
84 // layouting 84 // layouting
85 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); 85 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
86 vbox3->add(name); 86 vbox3->add(name);
87 vbox3->add(m_name); 87 vbox3->add(m_name);
88 vbox3->add(con ); 88 vbox3->add(con );
89 vbox3->add(m_conCmb ); 89 vbox3->add(m_conCmb );
90 vbox3->add(term ); 90 vbox3->add(term );
91 vbox3->add(m_termCmb ); 91 vbox3->add(m_termCmb );
92 vbox3->addStretch(1); 92 vbox3->addStretch(1);
93 93
94 tabWidget->addTab(tabprof, "", QObject::tr("Profile")); 94 tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
95 tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); 95 tabWidget->addTab(m_tabCon, "", QObject::tr("Connection"));
96 tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); 96 tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal"));
97 tabWidget->setCurrentTab( tabprof ); 97 tabWidget->setCurrentTab( tabprof );
98 98
99 99
100 // fill the comboboxes 100 // fill the comboboxes
101 QStringList list = m_fact->connectionWidgets(); 101 QStringList list = m_fact->connectionWidgets();
102 QStringList::Iterator it; 102 QStringList::Iterator it;
103 for (it =list.begin(); it != list.end(); ++it ) { 103 for (it =list.begin(); it != list.end(); ++it ) {
104 m_conCmb->insertItem( (*it) ); 104 m_conCmb->insertItem( (*it) );
105 } 105 }
106 list = m_fact->terminalWidgets(); 106 list = m_fact->terminalWidgets();
107 for (it =list.begin(); it != list.end(); ++it ) { 107 for (it =list.begin(); it != list.end(); ++it ) {
108 m_termCmb->insertItem( (*it) ); 108 m_termCmb->insertItem( (*it) );
109 } 109 }
110 110
111 // load profile values 111 // load profile values
112 m_name->setText(m_prof.name()); 112 m_name->setText(m_prof.name());
113 slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); 113 slotConActivated( m_fact->external(m_prof.ioLayerName() ) );
114 slotTermActivated( m_fact->external(m_prof.terminalName() ) ); 114 slotTermActivated( m_fact->external(m_prof.terminalName() ) );
115 setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); 115 setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb );
116 setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); 116 setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb );
117 117
118 qWarning("Layer: %s %s", m_prof.ioLayerName().data(),
119 m_fact->external(m_prof.ioLayerName() ).latin1() );
120 qWarning("Term: %s %s", m_prof.terminalName().data(),
121 m_fact->external(m_prof.terminalName() ).latin1() );
122 118
123 // signal and slots 119 // signal and slots
124 connect(m_conCmb, SIGNAL(activated(const QString& ) ), 120 connect(m_conCmb, SIGNAL(activated(const QString& ) ),
125 this, SLOT(slotConActivated(const QString&) ) ); 121 this, SLOT(slotConActivated(const QString&) ) );
126 connect(m_termCmb, SIGNAL(activated(const QString& ) ), 122 connect(m_termCmb, SIGNAL(activated(const QString& ) ),
127 this, SLOT(slotTermActivated(const QString& ) ) ); 123 this, SLOT(slotTermActivated(const QString& ) ) );
128 124
129} 125}
130 126
131ProfileEditorDialog::~ProfileEditorDialog() { 127ProfileEditorDialog::~ProfileEditorDialog() {
132 128
133} 129}
134void ProfileEditorDialog::accept() 130void ProfileEditorDialog::accept()
135{ 131{
136 if(profName().isEmpty()) 132 if(profName().isEmpty())
137 { 133 {
138 QMessageBox::information(this, 134 QMessageBox::information(this,
139 QObject::tr("Invalid profile"), 135 QObject::tr("Invalid profile"),
140 QObject::tr("Please enter a profile name.")); 136 QObject::tr("Please enter a profile name."));
141 return; 137 return;
142 } 138 }
143 // Save profile and plugin profile 139 // Save profile and plugin profile
144 //if(plugin_plugin) plugin_plugin->save(); 140 //if(plugin_plugin) plugin_plugin->save();
145 141
146 // Save general values 142 // Save general values
147 m_prof.setName(profName()); 143 m_prof.setName(profName());
148 m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); 144 m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) );
149 m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); 145 m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) );
150 qWarning("Term %s %s", m_fact->internal(m_termCmb->currentText() ).data(),
151 m_termCmb->currentText().latin1() );
152 146
153 if (m_con ) 147 if (m_con )
154 m_con->save( m_prof ); 148 m_con->save( m_prof );
155 if (m_term ) 149 if (m_term )
156 m_term->save( m_prof ); 150 m_term->save( m_prof );
157 151
158 QDialog::accept(); 152 QDialog::accept();
159} 153}
160 154
161 155
162QString ProfileEditorDialog::profName()const 156QString ProfileEditorDialog::profName()const
163{ 157{
164 return m_name->text(); 158 return m_name->text();
165} 159}
166 160
167QCString ProfileEditorDialog::profType()const 161QCString ProfileEditorDialog::profType()const
168{ 162{
169 /*QStringList w = m_fact->configWidgets(); 163 /*QStringList w = m_fact->configWidgets();
170 for(QStringList::Iterator it = w.begin(); it != w.end(); it++) 164 for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
171 if(device_box->currentText() == m_fact->name((*it))) return (*it); 165 if(device_box->currentText() == m_fact->name((*it))) return (*it);
172 */ 166 */
173 return QCString(); 167 return QCString();
174} 168}
175/* 169/*
176 * we need to switch the widget 170 * we need to switch the widget
177 */ 171 */
178void ProfileEditorDialog::slotConActivated( const QString& str ) { 172void ProfileEditorDialog::slotConActivated( const QString& str ) {
179 delete m_con; 173 delete m_con;
180 m_con = m_fact->newConnectionPlugin( str, m_tabCon ); 174 m_con = m_fact->newConnectionPlugin( str, m_tabCon );
181 175
182 if (m_con ) { 176 if (m_con ) {
183 m_con->load( m_prof ); 177 m_con->load( m_prof );
184 m_layCon->addWidget( m_con ); 178 m_layCon->addWidget( m_con );
185 } 179 }
186} 180}
187/* 181/*
188 * we need to switch the widget 182 * we need to switch the widget
189 */ 183 */
190void ProfileEditorDialog::slotTermActivated( const QString& str ) { 184void ProfileEditorDialog::slotTermActivated( const QString& str ) {
191 delete m_term; 185 delete m_term;
192 m_term = m_fact->newTerminalPlugin( str, m_tabTerm ); 186 m_term = m_fact->newTerminalPlugin( str, m_tabTerm );
193 qWarning("past");
194 187
195 if (m_term) { 188 if (m_term) {
196 m_term->load(m_prof ); 189 m_term->load(m_prof );
197 m_layTerm->addWidget( m_term ); 190 m_layTerm->addWidget( m_term );
198 } 191 }
199} 192}
200 193
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp
index 95a46f9..e5aedb6 100644
--- a/noncore/apps/opie-console/profilemanager.cpp
+++ b/noncore/apps/opie-console/profilemanager.cpp
@@ -1,146 +1,142 @@
1#include <stdio.h> 1#include <stdio.h>
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include <qfile.h> 4#include <qfile.h>
5#include <qlayout.h> 5#include <qlayout.h>
6#include <qwidgetstack.h> 6#include <qwidgetstack.h>
7 7
8#include <qpe/config.h> 8#include <qpe/config.h>
9 9
10#include "emulation_handler.h" 10#include "emulation_handler.h"
11#include "widget_layer.h" 11#include "widget_layer.h"
12#include "emulation_widget.h" 12#include "emulation_widget.h"
13#include "metafactory.h" 13#include "metafactory.h"
14#include "profileconfig.h" 14#include "profileconfig.h"
15#include "profilemanager.h" 15#include "profilemanager.h"
16 16
17ProfileManager::ProfileManager( MetaFactory* fact ) 17ProfileManager::ProfileManager( MetaFactory* fact )
18 : m_fact( fact ) 18 : m_fact( fact )
19{ 19{
20 20
21} 21}
22ProfileManager::~ProfileManager() { 22ProfileManager::~ProfileManager() {
23 23
24} 24}
25void ProfileManager::load() { 25void ProfileManager::load() {
26 m_list.clear(); 26 m_list.clear();
27 qWarning("load");
28 ProfileConfig conf("opie-console-profiles"); 27 ProfileConfig conf("opie-console-profiles");
29 QStringList groups = conf.groups(); 28 QStringList groups = conf.groups();
30 QStringList::Iterator it; 29 QStringList::Iterator it;
31 30
32 /* 31 /*
33 * for each profile 32 * for each profile
34 */ 33 */
35 for ( it = groups.begin(); it != groups.end(); ++it ) { 34 for ( it = groups.begin(); it != groups.end(); ++it ) {
36 qWarning("group " + (*it) );
37 conf.setGroup( (*it) ); 35 conf.setGroup( (*it) );
38 Profile prof; 36 Profile prof;
39 prof.setName( conf.readEntry("name") ); 37 prof.setName( conf.readEntry("name") );
40 prof.setIOLayer( conf.readEntry("iolayer").utf8() ); 38 prof.setIOLayer( conf.readEntry("iolayer").utf8() );
41 prof.setTerminalName( conf.readEntry("term").utf8() ); 39 prof.setTerminalName( conf.readEntry("term").utf8() );
42 qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() );
43 prof.setBackground( conf.readNumEntry("back") ); 40 prof.setBackground( conf.readNumEntry("back") );
44 prof.setForeground( conf.readNumEntry("fore") ); 41 prof.setForeground( conf.readNumEntry("fore") );
45 prof.setTerminal( conf.readNumEntry("terminal") ); 42 prof.setTerminal( conf.readNumEntry("terminal") );
46 43
47 // THIS is evil because all data get's reset 44 // THIS is evil because all data get's reset
48 prof.setConf( conf.items( (*it) ) ); 45 prof.setConf( conf.items( (*it) ) );
49 46
50 /* now add it */ 47 /* now add it */
51 m_list.append( prof ); 48 m_list.append( prof );
52 } 49 }
53 50
54} 51}
55void ProfileManager::clear() { 52void ProfileManager::clear() {
56 m_list.clear(); 53 m_list.clear();
57} 54}
58Profile::ValueList ProfileManager::all()const { 55Profile::ValueList ProfileManager::all()const {
59 return m_list; 56 return m_list;
60} 57}
61/* 58/*
62 * Our goal is to create a Session 59 * Our goal is to create a Session
63 * We will load the the IOLayer and EmulationLayer 60 * We will load the the IOLayer and EmulationLayer
64 * from the factory 61 * from the factory
65 * we will generate a QWidgetStack 62 * we will generate a QWidgetStack
66 * add a dummy widget with layout 63 * add a dummy widget with layout
67 * add "Widget" to the layout 64 * add "Widget" to the layout
68 * add the dummy to the stack 65 * add the dummy to the stack
69 * raise the dummy 66 * raise the dummy
70 * call session->connect(= 67 * call session->connect(=
71 * this way we only need to reparent 68 * this way we only need to reparent
72 * in TabWidget 69 * in TabWidget
73 */ 70 */
74Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { 71Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) {
75/* TEST PROFILE!!! 72/* TEST PROFILE!!!
76 Profile prof; 73 Profile prof;
77 QString str = "/dev/ttyS0"; 74 QString str = "/dev/ttyS0";
78 prof.writeEntry("Device",str ); 75 prof.writeEntry("Device",str );
79 prof.writeEntry("Baud", 115200 ); 76 prof.writeEntry("Baud", 115200 );
80 prof.setIOLayer("serial"); 77 prof.setIOLayer("serial");
81 prof.setName( "test"); 78 prof.setName( "test");
82*/ 79*/
83 Session* session = new Session(); 80 Session* session = new Session();
84 session->setName( prof.name() ); 81 session->setName( prof.name() );
85 /* translate the internal name to the external */ 82 /* translate the internal name to the external */
86 session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) , 83 session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) ,
87 prof) ); 84 prof) );
88 85
89 QWidgetStack *stack = new QWidgetStack( parent ); 86 QWidgetStack *stack = new QWidgetStack( parent );
90 session->setWidgetStack( stack ); 87 session->setWidgetStack( stack );
91 QWidget* dummy = new QWidget( stack ); 88 QWidget* dummy = new QWidget( stack );
92 QHBoxLayout* lay = new QHBoxLayout( dummy ); 89 QHBoxLayout* lay = new QHBoxLayout( dummy );
93 stack->addWidget( dummy, 0 ); 90 stack->addWidget( dummy, 0 );
94 stack->raiseWidget( 0 ); 91 stack->raiseWidget( 0 );
95 EmulationHandler* handler = new EmulationHandler(prof,dummy ); 92 EmulationHandler* handler = new EmulationHandler(prof,dummy );
96 session->setEmulationHandler( handler ); 93 session->setEmulationHandler( handler );
97 lay->addWidget( handler->widget() ); 94 lay->addWidget( handler->widget() );
98// WidgetLayer* wid = new EmulationWidget( prof, dummy ); 95// WidgetLayer* wid = new EmulationWidget( prof, dummy );
99// lay->addWidget( wid ); 96// lay->addWidget( wid );
100 97
101// session->setEmulationWidget( wid ); 98// session->setEmulationWidget( wid );
102// session->setEmulationLayer( m_fact->newEmulationLayer( m_fact->external( prof.terminalName() ), 99// session->setEmulationLayer( m_fact->newEmulationLayer( m_fact->external( prof.terminalName() ),
103// wid ) ); 100// wid ) );
104 session->connect(); 101 session->connect();
105 102
106 return session; 103 return session;
107} 104}
108void ProfileManager::save( ) { 105void ProfileManager::save( ) {
109 QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); 106 QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) );
110 ProfileConfig conf("opie-console-profiles"); 107 ProfileConfig conf("opie-console-profiles");
111 Profile::ValueList::Iterator it2; 108 Profile::ValueList::Iterator it2;
112 for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) { 109 for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) {
113 conf.setGroup( (*it2).name() ); 110 conf.setGroup( (*it2).name() );
114 111
115 /* now the config stuff */ 112 /* now the config stuff */
116 QMap<QString, QString> map = (*it2).conf(); 113 QMap<QString, QString> map = (*it2).conf();
117 QMap<QString, QString>::Iterator confIt; 114 QMap<QString, QString>::Iterator confIt;
118 for ( confIt = map.begin(); confIt != map.end(); ++confIt ) { 115 for ( confIt = map.begin(); confIt != map.end(); ++confIt ) {
119 conf.writeEntry( confIt.key(), confIt.data() ); 116 conf.writeEntry( confIt.key(), confIt.data() );
120 } 117 }
121 118
122 conf.writeEntry( "name", (*it2).name() ); 119 conf.writeEntry( "name", (*it2).name() );
123 QString str = QString::fromUtf8( (*it2).ioLayerName() ); 120 QString str = QString::fromUtf8( (*it2).ioLayerName() );
124 qWarning("IOLayerName " + str );
125 121
126 conf.writeEntry( "iolayer", str ); 122 conf.writeEntry( "iolayer", str );
127 conf.writeEntry( "term", QString::fromUtf8( (*it2).terminalName() ) ); 123 conf.writeEntry( "term", QString::fromUtf8( (*it2).terminalName() ) );
128 conf.writeEntry( "back", (*it2).background() ); 124 conf.writeEntry( "back", (*it2).background() );
129 conf.writeEntry( "fore", (*it2).foreground() ); 125 conf.writeEntry( "fore", (*it2).foreground() );
130 conf.writeEntry( "terminal", (*it2).terminal() ); 126 conf.writeEntry( "terminal", (*it2).terminal() );
131 } 127 }
132} 128}
133void ProfileManager::setProfiles( const Profile::ValueList& list ) { 129void ProfileManager::setProfiles( const Profile::ValueList& list ) {
134 m_list = list; 130 m_list = list;
135}; 131};
136Profile ProfileManager::profile( const QString& name )const { 132Profile ProfileManager::profile( const QString& name )const {
137 Profile prof; 133 Profile prof;
138 Profile::ValueList::ConstIterator it; 134 Profile::ValueList::ConstIterator it;
139 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 135 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
140 if ( name == (*it).name() ) { 136 if ( name == (*it).name() ) {
141 prof = (*it); 137 prof = (*it);
142 break; 138 break;
143 } 139 }
144 } 140 }
145 return prof; 141 return prof;
146} 142}
diff --git a/noncore/apps/opie-console/session.cpp b/noncore/apps/opie-console/session.cpp
index d0ace6c..e53dbc4 100644
--- a/noncore/apps/opie-console/session.cpp
+++ b/noncore/apps/opie-console/session.cpp
@@ -1,100 +1,99 @@
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
9Session::Session() { 9Session::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}
14Session::Session( const QString& na, QWidgetStack* widget, IOLayer* lay) 14Session::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}
21Session::~Session() { 21Session::~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}
27QString Session::name()const { 27QString Session::name()const {
28 return m_name; 28 return m_name;
29} 29}
30QWidgetStack* Session::widgetStack() { 30QWidgetStack* Session::widgetStack() {
31 return m_widget; 31 return m_widget;
32} 32}
33IOLayer* Session::layer() { 33IOLayer* Session::layer() {
34 return m_layer; 34 return m_layer;
35} 35}
36EmulationHandler* Session::emulationHandler() { 36EmulationHandler* Session::emulationHandler() {
37 return m_emu; 37 return m_emu;
38} 38}
39/* 39/*
40WidgetLayer* Session::emulationWidget() { 40WidgetLayer* Session::emulationWidget() {
41 return m_widLay; 41 return m_widLay;
42} 42}
43*/ 43*/
44void Session::connect() { 44void Session::connect() {
45 if ( !m_layer || !m_emu ) 45 if ( !m_layer || !m_emu )
46 return; 46 return;
47 47
48 m_connected = true; 48 m_connected = true;
49 49
50 qWarning("connection in session");
51 QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ), 50 QObject::connect(m_layer, SIGNAL(received(const QByteArray&) ),
52 m_emu, SLOT(recv(const QByteArray&) ) ); 51 m_emu, SLOT(recv(const QByteArray&) ) );
53 QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ), 52 QObject::connect(m_emu, SIGNAL(send(const QByteArray&) ),
54 m_layer, SLOT(send(const QByteArray&) ) ); 53 m_layer, SLOT(send(const QByteArray&) ) );
55} 54}
56 55
57void Session::disconnect() { 56void Session::disconnect() {
58 57
59 if ( !m_layer || !m_emu ) 58 if ( !m_layer || !m_emu )
60 return; 59 return;
61 60
62 m_connected = false; 61 m_connected = false;
63 62
64 QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ), 63 QObject::disconnect(m_layer, SIGNAL(received(const QByteArray&) ),
65 m_emu, SLOT(recv(const QByteArray&) ) ); 64 m_emu, SLOT(recv(const QByteArray&) ) );
66 QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ), 65 QObject::disconnect(m_emu, SIGNAL(send(const QByteArray&) ),
67 m_layer, SLOT(send(const QByteArray&) ) ); 66 m_layer, SLOT(send(const QByteArray&) ) );
68} 67}
69 68
70void Session::setName( const QString& na){ 69void Session::setName( const QString& na){
71 m_name = na; 70 m_name = na;
72} 71}
73 72
74void Session::setWidgetStack( QWidgetStack* wid ) { 73void Session::setWidgetStack( QWidgetStack* wid ) {
75 delete m_emu; 74 delete m_emu;
76 m_emu = 0l; 75 m_emu = 0l;
77 delete m_widget; 76 delete m_widget;
78 /* the EmulationLayer was destroyed... */ 77 /* the EmulationLayer was destroyed... */
79 78
80 m_widget = wid; 79 m_widget = wid;
81} 80}
82void Session::setIOLayer( IOLayer* lay ) { 81void Session::setIOLayer( IOLayer* lay ) {
83 delete m_layer; 82 delete m_layer;
84 m_layer = lay; 83 m_layer = lay;
85} 84}
86 85
87void Session::setEmulationHandler( EmulationHandler* lay ) { 86void Session::setEmulationHandler( EmulationHandler* lay ) {
88 delete m_emu; 87 delete m_emu;
89 m_emu = lay; 88 m_emu = lay;
90} 89}
91/* 90/*
92void Session::setEmulationWidget( WidgetLayer* lay ) { 91void Session::setEmulationWidget( WidgetLayer* lay ) {
93 delete m_widLay; 92 delete m_widLay;
94 m_widLay = lay; 93 m_widLay = lay;
95} 94}
96*/ 95*/
97 96
98bool Session::isConnected() { 97bool Session::isConnected() {
99 return m_connected; 98 return m_connected;
100} 99}
diff --git a/noncore/apps/opie-console/tabwidget.cpp b/noncore/apps/opie-console/tabwidget.cpp
index 466b536..8a691f9 100644
--- a/noncore/apps/opie-console/tabwidget.cpp
+++ b/noncore/apps/opie-console/tabwidget.cpp
@@ -1,44 +1,43 @@
1 1
2#include "tabwidget.h" 2#include "tabwidget.h"
3 3
4TabWidget::TabWidget( QWidget* parent, const char* name ) 4TabWidget::TabWidget( QWidget* parent, const char* name )
5 : OTabWidget( parent, name ) { 5 : OTabWidget( parent, name ) {
6 connect(this, SIGNAL( currentChanged(QWidget*) ), 6 connect(this, SIGNAL( currentChanged(QWidget*) ),
7 this, SLOT( slotCurChanged(QWidget*) ) ); 7 this, SLOT( slotCurChanged(QWidget*) ) );
8} 8}
9 9
10TabWidget::~TabWidget() { 10TabWidget::~TabWidget() {
11} 11}
12 12
13void TabWidget::add( Session* ses ) { 13void TabWidget::add( Session* ses ) {
14 if ( !ses->widgetStack() ) return; 14 if ( !ses->widgetStack() ) return;
15 qWarning("going to add it");
16 //reparent( ses->widgetStack(), QPoint() ); 15 //reparent( ses->widgetStack(), QPoint() );
17 addTab( ses->widgetStack(), "console/konsole", ses->name() ); 16 addTab( ses->widgetStack(), "console/konsole", ses->name() );
18 //addTab( ses->widgetStack(), ses->name() ); 17 //addTab( ses->widgetStack(), ses->name() );
19 m_map.insert( ses->widgetStack(), ses ); 18 m_map.insert( ses->widgetStack(), ses );
20} 19}
21 20
22void TabWidget::remove( Session* ses ) { 21void TabWidget::remove( Session* ses ) {
23 m_map.remove( ses->widgetStack() ); 22 m_map.remove( ses->widgetStack() );
24 removePage( ses->widgetStack() ); 23 removePage( ses->widgetStack() );
25} 24}
26 25
27void TabWidget::slotCurChanged( QWidget* wid ) { 26void TabWidget::slotCurChanged( QWidget* wid ) {
28 QMap<QWidget*, Session*>::Iterator it; 27 QMap<QWidget*, Session*>::Iterator it;
29 it = m_map.find( wid ); 28 it = m_map.find( wid );
30 if ( it == m_map.end() ) { 29 if ( it == m_map.end() ) {
31 return; 30 return;
32 } 31 }
33 32
34 emit activated( it.data() ); 33 emit activated( it.data() );
35} 34}
36void TabWidget::setCurrent( Session* ses ) { 35void TabWidget::setCurrent( Session* ses ) {
37 if (!ses ) 36 if (!ses )
38 return; 37 return;
39 38
40 //showPage( ses->widgetStack() ); 39 //showPage( ses->widgetStack() );
41 setCurrentTab( ses->widgetStack() ); 40 setCurrentTab( ses->widgetStack() );
42} 41}
43 42
44 43