author | wazlaf <wazlaf> | 2002-10-30 20:30:08 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-10-30 20:30:08 (UTC) |
commit | 3c1824f39867bc2ada45fe32785267caa5dfb04b (patch) (unidiff) | |
tree | 08a6e7872f5d100cac7c1adb983e44f6b145af2f | |
parent | 9af1c14974a2131505b82441bfb0bf0475bb2cc9 (diff) | |
download | opie-3c1824f39867bc2ada45fe32785267caa5dfb04b.zip opie-3c1824f39867bc2ada45fe32785267caa5dfb04b.tar.gz opie-3c1824f39867bc2ada45fe32785267caa5dfb04b.tar.bz2 |
Console configuration widget done, Environment variables can now be set
-rw-r--r-- | noncore/apps/opie-console/MyPty.cpp | 27 | ||||
-rw-r--r-- | noncore/apps/opie-console/MyPty.h | 6 | ||||
-rw-r--r-- | noncore/apps/opie-console/PLANS | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/consoleconfigwidget.cpp | 95 | ||||
-rw-r--r-- | noncore/apps/opie-console/consoleconfigwidget.h | 34 | ||||
-rw-r--r-- | noncore/apps/opie-console/default.cpp | 9 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.pro | 6 |
7 files changed, 162 insertions, 17 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp index 534f79a..b0f0275 100644 --- a/noncore/apps/opie-console/MyPty.cpp +++ b/noncore/apps/opie-console/MyPty.cpp | |||
@@ -121,89 +121,86 @@ void MyPty::donePty() | |||
121 | delete m_sn_r; | 121 | delete m_sn_r; |
122 | m_sn_e = 0l; | 122 | m_sn_e = 0l; |
123 | m_sn_r = 0l; | 123 | m_sn_r = 0l; |
124 | } | 124 | } |
125 | 125 | ||
126 | m_cpid = 0; | 126 | m_cpid = 0; |
127 | m_fd = -1; | 127 | m_fd = -1; |
128 | // emit done(status); | 128 | // emit done(status); |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
132 | const char* MyPty::deviceName() | 132 | const char* MyPty::deviceName() |
133 | { | 133 | { |
134 | return m_ttynam; | 134 | return m_ttynam; |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | void MyPty::error() | 138 | void MyPty::error() |
139 | { | 139 | { |
140 | // This is code from the Qt DumbTerminal example | 140 | // This is code from the Qt DumbTerminal example |
141 | donePty(); | 141 | donePty(); |
142 | } | 142 | } |
143 | 143 | ||
144 | void MyPty::start() { | 144 | void MyPty::start() { |
145 | char* cmd = "/bin/sh"; | ||
146 | |||
147 | if ( QFile::exists( "/bin/bash" ) ) { | ||
148 | cmd = "/bin/bash"; | ||
149 | } | ||
150 | |||
151 | QStrList lis; | 145 | QStrList lis; |
152 | int r =run(cmd, lis, 0, 0); | 146 | int r =run(m_cmd.latin1(), lis, 0, 0); |
153 | r = r; | 147 | r = r; |
154 | } | 148 | } |
155 | /*! | 149 | /*! |
156 | start the client program. | 150 | start the client program. |
157 | */ | 151 | */ |
158 | int MyPty::run(const char* cmd, QStrList &, const char*, int) | 152 | int MyPty::run(const char* cmd, QStrList &, const char*, int) |
159 | { | 153 | { |
160 | // This is code from the Qt DumbTerminal example | 154 | // This is code from the Qt DumbTerminal example |
161 | m_cpid = fork(); | 155 | m_cpid = fork(); |
162 | 156 | ||
163 | if ( !m_cpid ) { | 157 | if ( !m_cpid ) { |
164 | // child - exec shell on tty | 158 | // child - exec shell on tty |
165 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); | 159 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); |
166 | int ttyfd = ::open(m_ttynam, O_RDWR); | 160 | int ttyfd = ::open(m_ttynam, O_RDWR); |
167 | dup2(ttyfd, STDIN_FILENO); | 161 | dup2(ttyfd, STDIN_FILENO); |
168 | dup2(ttyfd, STDOUT_FILENO); | 162 | dup2(ttyfd, STDOUT_FILENO); |
169 | dup2(ttyfd, STDERR_FILENO); | 163 | dup2(ttyfd, STDERR_FILENO); |
170 | // should be done with tty, so close it | 164 | // should be done with tty, so close it |
171 | ::close(ttyfd); | 165 | ::close(ttyfd); |
172 | static struct termios ttmode; | 166 | static struct termios ttmode; |
173 | if ( setsid() < 0 ) | 167 | if ( setsid() < 0 ) |
174 | perror( "failed to set process group" ); | 168 | perror( "failed to set process group" ); |
175 | #if defined (TIOCSCTTY) | 169 | #if defined (TIOCSCTTY) |
176 | // grabbed from APUE by Stevens | 170 | // grabbed from APUE by Stevens |
177 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); | 171 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); |
178 | #endif | 172 | #endif |
179 | tcgetattr( STDIN_FILENO, &ttmode ); | 173 | tcgetattr( STDIN_FILENO, &ttmode ); |
180 | ttmode.c_cc[VINTR] = 3; | 174 | ttmode.c_cc[VINTR] = 3; |
181 | ttmode.c_cc[VERASE] = 8; | 175 | ttmode.c_cc[VERASE] = 8; |
182 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); | 176 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); |
183 | setenv("TERM",m_term,1); | 177 | setenv("TERM",m_term,1); |
184 | setenv("COLORTERM","0",1); | 178 | setenv("COLORTERM","0",1); |
185 | 179 | EnvironmentMap::Iterator it; | |
180 | for (it = m_env.begin(); it != m_env.end(); it++) { | ||
181 | setenv(it.key().latin1(), it.data().latin1(), 1); | ||
182 | } | ||
186 | if (getuid() == 0) { | 183 | if (getuid() == 0) { |
187 | char msg[] = "WARNING: You are running this shell as root!\n"; | 184 | char msg[] = "WARNING: You are running this shell as root!\n"; |
188 | write(ttyfd, msg, sizeof(msg)); | 185 | write(ttyfd, msg, sizeof(msg)); |
189 | } | 186 | } |
190 | execl(cmd, cmd, 0); | 187 | execl(cmd, cmd, 0); |
191 | 188 | ||
192 | donePty(); | 189 | donePty(); |
193 | exit(-1); | 190 | exit(-1); |
194 | } | 191 | } |
195 | 192 | ||
196 | // parent - continue as a widget | 193 | // parent - continue as a widget |
197 | delete m_sn_r; | 194 | delete m_sn_r; |
198 | m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); | 195 | m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); |
199 | delete m_sn_e; | 196 | delete m_sn_e; |
200 | m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); | 197 | m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); |
201 | connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); | 198 | connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); |
202 | connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); | 199 | connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); |
203 | 200 | ||
204 | return 0; | 201 | return 0; |
205 | } | 202 | } |
206 | 203 | ||
207 | int MyPty::openPty() | 204 | int MyPty::openPty() |
208 | { | 205 | { |
209 | // This is code from the Qt DumbTerminal example | 206 | // This is code from the Qt DumbTerminal example |
@@ -242,78 +239,88 @@ int MyPty::openPty() | |||
242 | Create an instance. | 239 | Create an instance. |
243 | */ | 240 | */ |
244 | MyPty::MyPty(const Profile& prof) : m_cpid(0) | 241 | MyPty::MyPty(const Profile& prof) : m_cpid(0) |
245 | { | 242 | { |
246 | 243 | ||
247 | int term = prof.readNumEntry("Terminal", Profile::VT100 ); | 244 | int term = prof.readNumEntry("Terminal", Profile::VT100 ); |
248 | switch( term ) { | 245 | switch( term ) { |
249 | default: | 246 | default: |
250 | case Profile::VT100: | 247 | case Profile::VT100: |
251 | case Profile::VT102: | 248 | case Profile::VT102: |
252 | m_term = "vt100"; | 249 | m_term = "vt100"; |
253 | break; | 250 | break; |
254 | case Profile::Linux: | 251 | case Profile::Linux: |
255 | m_term = "linux"; | 252 | m_term = "linux"; |
256 | break; | 253 | break; |
257 | case Profile::XTerm: | 254 | case Profile::XTerm: |
258 | m_term = "xterm"; | 255 | m_term = "xterm"; |
259 | break; | 256 | break; |
260 | } | 257 | } |
261 | m_sn_e = 0l; | 258 | m_sn_e = 0l; |
262 | m_sn_r = 0l; | 259 | m_sn_r = 0l; |
263 | m_fd = openPty(); | 260 | m_fd = openPty(); |
264 | ProcCtl* ctl = ProcCtl::self(); | 261 | ProcCtl* ctl = ProcCtl::self(); |
265 | Q_UNUSED(ctl); | 262 | Q_UNUSED(ctl); |
263 | reload(prof); | ||
266 | } | 264 | } |
267 | 265 | ||
268 | /*! | 266 | /*! |
269 | Destructor. | 267 | Destructor. |
270 | Note that the related client program is not killed | 268 | Note that the related client program is not killed |
271 | (yet) when a instance is deleted. | 269 | (yet) when a instance is deleted. |
272 | */ | 270 | */ |
273 | MyPty::~MyPty() | 271 | MyPty::~MyPty() |
274 | { | 272 | { |
275 | donePty(); | 273 | donePty(); |
276 | } | 274 | } |
277 | QString MyPty::identifier()const { | 275 | QString MyPty::identifier()const { |
278 | return QString::fromLatin1("term"); | 276 | return QString::fromLatin1("term"); |
279 | } | 277 | } |
280 | QString MyPty::name()const{ | 278 | QString MyPty::name()const{ |
281 | return identifier(); | 279 | return identifier(); |
282 | } | 280 | } |
283 | bool MyPty::open() { | 281 | bool MyPty::open() { |
284 | if (m_fd < 0) | 282 | if (m_fd < 0) |
285 | m_fd = openPty(); | 283 | m_fd = openPty(); |
286 | 284 | ||
287 | start(); | 285 | start(); |
288 | return true; | 286 | return true; |
289 | } | 287 | } |
290 | void MyPty::close() { | 288 | void MyPty::close() { |
291 | donePty(); | 289 | donePty(); |
292 | m_fd = openPty(); | 290 | m_fd = openPty(); |
293 | } | 291 | } |
294 | void MyPty::reload( const Profile& ) { | 292 | void MyPty::reload( const Profile& prof) { |
295 | 293 | m_env.clear(); | |
294 | m_cmd = prof.readEntry("Command", "/bin/bash"); | ||
295 | int envcount = prof.readNumEntry("EnvVars", 0); | ||
296 | for (int i=0; i<envcount; i++) { | ||
297 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); | ||
298 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); | ||
299 | if (!(name.isEmpty() || value.isEmpty())) { | ||
300 | m_env.insert(name, value); | ||
301 | } | ||
302 | } | ||
296 | } | 303 | } |
297 | /*! sends len bytes through the line */ | 304 | /*! sends len bytes through the line */ |
298 | void MyPty::send(const QByteArray& ar) | 305 | void MyPty::send(const QByteArray& ar) |
299 | { | 306 | { |
300 | #ifdef VERBOSE_DEBUG | 307 | #ifdef VERBOSE_DEBUG |
301 | // verbose debug | 308 | // verbose debug |
302 | printf("sending bytes:\n"); | 309 | printf("sending bytes:\n"); |
303 | for (uint i = 0; i < ar.count(); i++) | 310 | for (uint i = 0; i < ar.count(); i++) |
304 | printf("%c", ar[i]); | 311 | printf("%c", ar[i]); |
305 | printf("\n"); | 312 | printf("\n"); |
306 | #endif | 313 | #endif |
307 | 314 | ||
308 | ::write(m_fd, ar.data(), ar.count()); | 315 | ::write(m_fd, ar.data(), ar.count()); |
309 | } | 316 | } |
310 | 317 | ||
311 | /*! indicates that a block of data is received */ | 318 | /*! indicates that a block of data is received */ |
312 | void MyPty::readPty() | 319 | void MyPty::readPty() |
313 | { | 320 | { |
314 | QByteArray buf(4096); | 321 | QByteArray buf(4096); |
315 | 322 | ||
316 | int len = ::read( m_fd, buf.data(), 4096 ); | 323 | int len = ::read( m_fd, buf.data(), 4096 ); |
317 | 324 | ||
318 | if (len == -1 || len == 0) { | 325 | if (len == -1 || len == 0) { |
319 | donePty(); | 326 | donePty(); |
diff --git a/noncore/apps/opie-console/MyPty.h b/noncore/apps/opie-console/MyPty.h index 7561ca3..b292ce4 100644 --- a/noncore/apps/opie-console/MyPty.h +++ b/noncore/apps/opie-console/MyPty.h | |||
@@ -2,52 +2,55 @@ | |||
2 | /* */ | 2 | /* */ |
3 | /* [MyPty.h] Pseudo Terminal Device */ | 3 | /* [MyPty.h] Pseudo Terminal Device */ |
4 | /* */ | 4 | /* */ |
5 | /* -------------------------------------------------------------------------- */ | 5 | /* -------------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole - an X terminal for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* */ | 10 | /* */ |
11 | /* -------------------------------------------------------------------------- */ | 11 | /* -------------------------------------------------------------------------- */ |
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | 18 | ||
19 | /*! \file | 19 | /*! \file |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef MY_PTY_H | 22 | #ifndef MY_PTY_H |
23 | #define MY_PTY_H | 23 | #define MY_PTY_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qlist.h> | ||
26 | #include <qstrlist.h> | 27 | #include <qstrlist.h> |
27 | 28 | ||
28 | #include "io_layer.h" | 29 | #include "io_layer.h" |
29 | 30 | ||
31 | typedef QMap<QString, QString> EnvironmentMap; | ||
32 | |||
30 | class Profile; | 33 | class Profile; |
31 | class QSocketNotifier; | 34 | class QSocketNotifier; |
32 | class MyPty : public IOLayer | 35 | class MyPty : public IOLayer |
33 | { | 36 | { |
34 | Q_OBJECT | 37 | Q_OBJECT |
35 | public: | 38 | public: |
36 | 39 | ||
37 | MyPty(const Profile&); | 40 | MyPty(const Profile&); |
38 | ~MyPty(); | 41 | ~MyPty(); |
39 | 42 | ||
40 | 43 | ||
41 | 44 | ||
42 | QString identifier()const; | 45 | QString identifier()const; |
43 | QString name()const; | 46 | QString name()const; |
44 | QBitArray supports()const; | 47 | QBitArray supports()const; |
45 | 48 | ||
46 | public slots: | 49 | public slots: |
47 | /*! | 50 | /*! |
48 | having a `run' separate from the constructor allows to make | 51 | having a `run' separate from the constructor allows to make |
49 | the necessary connections to the signals and slots of the | 52 | the necessary connections to the signals and slots of the |
50 | instance before starting the execution of the client. | 53 | instance before starting the execution of the client. |
51 | */ | 54 | */ |
52 | void start(); | 55 | void start(); |
53 | int run(const char* pgm, QStrList & args , const char* term, int addutmp); | 56 | int run(const char* pgm, QStrList & args , const char* term, int addutmp); |
@@ -74,27 +77,30 @@ public: | |||
74 | 77 | ||
75 | public slots: | 78 | public slots: |
76 | 79 | ||
77 | void send(const QByteArray& ); | 80 | void send(const QByteArray& ); |
78 | 81 | ||
79 | private: | 82 | private: |
80 | const char* deviceName(); | 83 | const char* deviceName(); |
81 | 84 | ||
82 | protected slots: | 85 | protected slots: |
83 | void readPty(); | 86 | void readPty(); |
84 | void donePty(); | 87 | void donePty(); |
85 | 88 | ||
86 | private: | 89 | private: |
87 | int openPty(); | 90 | int openPty(); |
88 | 91 | ||
89 | private: | 92 | private: |
90 | 93 | ||
91 | char m_ptynam[16]; // "/dev/ptyxx" | "/dev/ptmx" | 94 | char m_ptynam[16]; // "/dev/ptyxx" | "/dev/ptmx" |
92 | char m_ttynam[16]; // "/dev/ttyxx" | "/dev/pts/########..." | 95 | char m_ttynam[16]; // "/dev/ttyxx" | "/dev/pts/########..." |
93 | int m_fd; | 96 | int m_fd; |
94 | int m_cpid; | 97 | int m_cpid; |
95 | QSocketNotifier* m_sn_e; | 98 | QSocketNotifier* m_sn_e; |
96 | QSocketNotifier* m_sn_r; | 99 | QSocketNotifier* m_sn_r; |
97 | char* m_term; | 100 | char* m_term; |
101 | |||
102 | QString m_cmd; | ||
103 | EnvironmentMap m_env; | ||
98 | }; | 104 | }; |
99 | 105 | ||
100 | #endif | 106 | #endif |
diff --git a/noncore/apps/opie-console/PLANS b/noncore/apps/opie-console/PLANS index 8e0bee4..a7c7578 100644 --- a/noncore/apps/opie-console/PLANS +++ b/noncore/apps/opie-console/PLANS | |||
@@ -6,50 +6,50 @@ filetransfer via {x,y,z}modem, and some sort of session management. | |||
6 | Besides this requirement we would like to be able to execute 'scripts' | 6 | Besides this requirement we would like to be able to execute 'scripts' |
7 | in a session. | 7 | in a session. |
8 | A script would just write to the TEmulation and then be sent via | 8 | A script would just write to the TEmulation and then be sent via |
9 | an IOlayer. | 9 | an IOlayer. |
10 | 10 | ||
11 | We want a modular architecture which might support plugins in | 11 | We want a modular architecture which might support plugins in |
12 | the future | 12 | the future |
13 | 13 | ||
14 | should we have a general opie-console setting dialog where you configure | 14 | should we have a general opie-console setting dialog where you configure |
15 | general things like where the tabs are, the profiles, and the default | 15 | general things like where the tabs are, the profiles, and the default |
16 | keyboard? | 16 | keyboard? |
17 | 17 | ||
18 | 18 | ||
19 | (Almost) DONE: | 19 | (Almost) DONE: |
20 | Framework | 20 | Framework |
21 | Serial IOLayer | 21 | Serial IOLayer |
22 | Saving and Restoring Profiles | 22 | Saving and Restoring Profiles |
23 | ConfigDialog Framework | 23 | ConfigDialog Framework |
24 | IOLayer | 24 | IOLayer |
25 | Profile->Session and MainWidget | 25 | Profile->Session and MainWidget |
26 | FilesendingLayer ( Z/Y Modem tested X does not work at all ) | 26 | FilesendingLayer ( Z/Y Modem tested X does not work at all ) |
27 | Fullscreen | 27 | Fullscreen |
28 | Modem - Josef | 28 | Modem - Josef |
29 | Keys - hash | 29 | Keys - hash |
30 | Scripting - wazlaf | ||
30 | 31 | ||
31 | TASKS in progress: | 32 | TASKS in progress: |
32 | Keys - hash | 33 | Keys - hash |
33 | Scripting - wazlaf | ||
34 | 34 | ||
35 | Session->Profile - hash => why is this needed? you can not change any settings | 35 | Session->Profile - hash => why is this needed? you can not change any settings |
36 | after you start the session, so all you would do is | 36 | after you start the session, so all you would do is |
37 | create a duplicate of the profile used to open the | 37 | create a duplicate of the profile used to open the |
38 | current session. maybe needed later when you can change | 38 | current session. maybe needed later when you can change |
39 | settings while the session is running (colors, fonts...) | 39 | settings while the session is running (colors, fonts...) |
40 | zecke => think of that. You try to hook up with a New Device | 40 | zecke => think of that. You try to hook up with a New Device |
41 | neither know anything.... speed flow and such stuff | 41 | neither know anything.... speed flow and such stuff |
42 | you start to experiment and it starts to work | 42 | you start to experiment and it starts to work |
43 | now you want to save the session | 43 | now you want to save the session |
44 | 44 | ||
45 | hash => got it. | 45 | hash => got it. |
46 | 46 | ||
47 | OPEN tasks: | 47 | OPEN tasks: |
48 | Receiving ( copy &n paste from filetransfer.cpp ) | 48 | Receiving ( copy &n paste from filetransfer.cpp ) |
49 | 49 | ||
50 | POSTPONED UNTIL LATER: | 50 | POSTPONED UNTIL LATER: |
51 | Irda ConfigWidget | 51 | Irda ConfigWidget |
52 | BT ConfigWidget | 52 | BT ConfigWidget |
53 | IRDA-Layer | 53 | IRDA-Layer |
54 | Bluetooth-Layer | 54 | Bluetooth-Layer |
55 | 55 | ||
diff --git a/noncore/apps/opie-console/consoleconfigwidget.cpp b/noncore/apps/opie-console/consoleconfigwidget.cpp new file mode 100644 index 0000000..70e2e78 --- a/dev/null +++ b/noncore/apps/opie-console/consoleconfigwidget.cpp | |||
@@ -0,0 +1,95 @@ | |||
1 | #include <qlabel.h> | ||
2 | #include <qlayout.h> | ||
3 | #include <qcombobox.h> | ||
4 | #include <qlineedit.h> | ||
5 | #include <qpushbutton.h> | ||
6 | #include <qlistview.h> | ||
7 | #include <qhbox.h> | ||
8 | #include <qregexp.h> | ||
9 | #include <stdio.h> | ||
10 | |||
11 | #include "consoleconfigwidget.h" | ||
12 | |||
13 | ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent, | ||
14 | const char* na ) | ||
15 | : ProfileDialogConnectionWidget( name, parent, na ) { | ||
16 | m_lay = new QVBoxLayout( this ); | ||
17 | QLabel *label = new QLabel(tr("Command to execute"), this); | ||
18 | m_lay->addWidget(label); | ||
19 | m_cmd = new QLineEdit(this); | ||
20 | m_lay->addWidget(m_cmd); | ||
21 | label = new QLabel(tr("Environment Variables"), this); | ||
22 | m_lay->addWidget(label); | ||
23 | m_env = new QListView(this); | ||
24 | m_env->addColumn(tr("Name")); | ||
25 | m_env->addColumn(tr("Value")); | ||
26 | m_lay->addWidget(m_env); | ||
27 | |||
28 | QHBox *hbox = new QHBox(this); | ||
29 | label = new QLabel(tr("Name :"), hbox); | ||
30 | m_name = new QLineEdit(hbox); | ||
31 | m_lay->addWidget(hbox); | ||
32 | |||
33 | hbox = new QHBox(this); | ||
34 | label = new QLabel(tr("Value :"), hbox); | ||
35 | m_value = new QLineEdit(hbox); | ||
36 | m_lay->addWidget(hbox); | ||
37 | |||
38 | hbox = new QHBox(this); | ||
39 | hbox->setSpacing(10); | ||
40 | m_remove = new QPushButton(tr("Remove"), hbox); | ||
41 | connect(m_remove, SIGNAL(clicked()), this, SLOT(slotRemove())); | ||
42 | m_add = new QPushButton(tr("Add"), hbox); | ||
43 | connect(m_add, SIGNAL(clicked()), this, SLOT(slotAdd())); | ||
44 | m_lay->addWidget(hbox); | ||
45 | } | ||
46 | |||
47 | void ConsoleConfigWidget::slotAdd() { | ||
48 | if (!(m_name->text().isEmpty() || m_value->text().isEmpty())) { | ||
49 | QListViewItem *item = new QListViewItem(m_env); | ||
50 | item->setText(0, m_name->text()); | ||
51 | item->setText(1, m_value->text()); | ||
52 | m_env->insertItem(item); | ||
53 | } | ||
54 | } | ||
55 | |||
56 | void ConsoleConfigWidget::slotRemove() { | ||
57 | QListViewItem *item = m_env->currentItem(); | ||
58 | if (item) { | ||
59 | m_env->takeItem(item); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | ConsoleConfigWidget::~ConsoleConfigWidget() { | ||
64 | } | ||
65 | |||
66 | void ConsoleConfigWidget::load( const Profile& prof ) { | ||
67 | m_cmd->setText(prof.readEntry("Command", "/bin/bash")); | ||
68 | int envcount = prof.readNumEntry("EnvVars", 0); | ||
69 | for (int i=0; i<envcount; i++) { | ||
70 | QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); | ||
71 | QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); | ||
72 | if (!(name.isEmpty() || value.isEmpty())) { | ||
73 | QListViewItem *item = new QListViewItem(m_env); | ||
74 | item->setText(0, name); | ||
75 | item->setText(1, value); | ||
76 | m_env->insertItem(item); | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | |||
81 | void ConsoleConfigWidget::save( Profile& prof ) { | ||
82 | prof.writeEntry( "Command", m_cmd->text()); | ||
83 | QListViewItem *item = m_env->firstChild(); | ||
84 | int counter = 0; | ||
85 | while (item) { | ||
86 | QString name = item->text(0); | ||
87 | QString value = item->text(1); | ||
88 | prof.writeEntry("Env_Name_" + QString::number(counter), name); | ||
89 | prof.writeEntry("Env_Value_" + QString::number(counter), value); | ||
90 | item = item->nextSibling(); | ||
91 | counter++; | ||
92 | } | ||
93 | prof.writeEntry("EnvVars", QString::number(counter)); | ||
94 | } | ||
95 | |||
diff --git a/noncore/apps/opie-console/consoleconfigwidget.h b/noncore/apps/opie-console/consoleconfigwidget.h new file mode 100644 index 0000000..c980cb4 --- a/dev/null +++ b/noncore/apps/opie-console/consoleconfigwidget.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef OPIE_CONSOLE_CONFIG_WIDGET_H | ||
2 | #define OPIE_CONSOLE_CONFIG_WIDGET_H | ||
3 | |||
4 | #include "profiledialogwidget.h" | ||
5 | |||
6 | class QVBoxLayout; | ||
7 | class QLineEdit; | ||
8 | class QListView; | ||
9 | class QPushButton; | ||
10 | |||
11 | class ConsoleConfigWidget : public ProfileDialogConnectionWidget { | ||
12 | Q_OBJECT | ||
13 | public: | ||
14 | ConsoleConfigWidget( const QString& name, QWidget* parent, const char* name = 0l ); | ||
15 | ~ConsoleConfigWidget(); | ||
16 | |||
17 | void load( const Profile& ); | ||
18 | void save( Profile& ); | ||
19 | |||
20 | protected slots: | ||
21 | void slotAdd(); | ||
22 | void slotRemove(); | ||
23 | private: | ||
24 | QVBoxLayout *m_lay; | ||
25 | QLineEdit *m_cmd; | ||
26 | QLineEdit *m_name; | ||
27 | QLineEdit *m_value; | ||
28 | QListView *m_env; | ||
29 | QPushButton *m_add; | ||
30 | QPushButton *m_remove; | ||
31 | }; | ||
32 | |||
33 | |||
34 | #endif | ||
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp index 5d82c6a..b060139 100644 --- a/noncore/apps/opie-console/default.cpp +++ b/noncore/apps/opie-console/default.cpp | |||
@@ -1,36 +1,37 @@ | |||
1 | #include "io_serial.h" | 1 | #include "io_serial.h" |
2 | #include "io_irda.h" | 2 | #include "io_irda.h" |
3 | #include "io_bt.h" | 3 | #include "io_bt.h" |
4 | #include "io_modem.h" | 4 | #include "io_modem.h" |
5 | #include "filetransfer.h" | 5 | #include "filetransfer.h" |
6 | #include "filereceive.h" | 6 | #include "filereceive.h" |
7 | #include "serialconfigwidget.h" | 7 | #include "serialconfigwidget.h" |
8 | #include "irdaconfigwidget.h" | 8 | #include "irdaconfigwidget.h" |
9 | #include "btconfigwidget.h" | 9 | #include "btconfigwidget.h" |
10 | #include "modemconfigwidget.h" | 10 | #include "modemconfigwidget.h" |
11 | #include "terminalwidget.h" | 11 | #include "terminalwidget.h" |
12 | #include "function_keyboard.h" | 12 | #include "function_keyboard.h" |
13 | #include "consoleconfigwidget.h" | ||
13 | #include "MyPty.h" | 14 | #include "MyPty.h" |
14 | 15 | ||
15 | #include "default.h" | 16 | #include "default.h" |
16 | 17 | ||
17 | extern "C" { | 18 | extern "C" { |
18 | // FILE Transfer Stuff | 19 | // FILE Transfer Stuff |
19 | FileTransferLayer* newSZTransfer(IOLayer* lay) { | 20 | FileTransferLayer* newSZTransfer(IOLayer* lay) { |
20 | return new FileTransfer( FileTransfer::SZ, lay ); | 21 | return new FileTransfer( FileTransfer::SZ, lay ); |
21 | } | 22 | } |
22 | FileTransferLayer* newSYTransfer(IOLayer* lay) { | 23 | FileTransferLayer* newSYTransfer(IOLayer* lay) { |
23 | return new FileTransfer( FileTransfer::SY, lay ); | 24 | return new FileTransfer( FileTransfer::SY, lay ); |
24 | } | 25 | } |
25 | FileTransferLayer* newSXTransfer(IOLayer* lay) { | 26 | FileTransferLayer* newSXTransfer(IOLayer* lay) { |
26 | return new FileTransfer(FileTransfer ::SX, lay ); | 27 | return new FileTransfer(FileTransfer ::SX, lay ); |
27 | } | 28 | } |
28 | 29 | ||
29 | // FILE Transfer Receive Stuff | 30 | // FILE Transfer Receive Stuff |
30 | ReceiveLayer* newSZReceive(IOLayer* lay) { | 31 | ReceiveLayer* newSZReceive(IOLayer* lay) { |
31 | return new FileReceive( FileReceive::SZ, lay ); | 32 | return new FileReceive( FileReceive::SZ, lay ); |
32 | } | 33 | } |
33 | ReceiveLayer* newSYReceive(IOLayer* lay) { | 34 | ReceiveLayer* newSYReceive(IOLayer* lay) { |
34 | return new FileReceive( FileReceive::SY, lay ); | 35 | return new FileReceive( FileReceive::SY, lay ); |
35 | } | 36 | } |
36 | ReceiveLayer* newSXReceive(IOLayer* lay) { | 37 | ReceiveLayer* newSXReceive(IOLayer* lay) { |
@@ -46,76 +47,76 @@ extern "C" { | |||
46 | } | 47 | } |
47 | IOLayer* newIrDaLayer( const Profile& prof ) { | 48 | IOLayer* newIrDaLayer( const Profile& prof ) { |
48 | return new IOIrda( prof ); | 49 | return new IOIrda( prof ); |
49 | } | 50 | } |
50 | IOLayer* newModemLayer( const Profile& prof ) { | 51 | IOLayer* newModemLayer( const Profile& prof ) { |
51 | return new IOModem( prof ); | 52 | return new IOModem( prof ); |
52 | } | 53 | } |
53 | IOLayer* newConsole( const Profile& prof ) { | 54 | IOLayer* newConsole( const Profile& prof ) { |
54 | return new MyPty( prof ); | 55 | return new MyPty( prof ); |
55 | } | 56 | } |
56 | 57 | ||
57 | // Connection Widgets | 58 | // Connection Widgets |
58 | ProfileDialogWidget* newSerialWidget( const QString& str, QWidget* wid ) { | 59 | ProfileDialogWidget* newSerialWidget( const QString& str, QWidget* wid ) { |
59 | return new SerialConfigWidget( str, wid ); | 60 | return new SerialConfigWidget( str, wid ); |
60 | } | 61 | } |
61 | ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid ) { | 62 | ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid ) { |
62 | return new IrdaConfigWidget( str, wid ); | 63 | return new IrdaConfigWidget( str, wid ); |
63 | } | 64 | } |
64 | ProfileDialogWidget* newModemWidget( const QString& str, QWidget* wid ) { | 65 | ProfileDialogWidget* newModemWidget( const QString& str, QWidget* wid ) { |
65 | return new ModemConfigWidget(str, wid ); | 66 | return new ModemConfigWidget(str, wid ); |
66 | } | 67 | } |
67 | ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid ) { | 68 | ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid ) { |
68 | return new BTConfigWidget(str, wid ); | 69 | return new BTConfigWidget(str, wid ); |
69 | } | 70 | } |
70 | ProfileDialogWidget* newConsoleWid( const QString& , QWidget* ) { | 71 | ProfileDialogWidget* newConsoleWid( const QString& str, QWidget* wid ) { |
71 | return 0l; | 72 | return new ConsoleConfigWidget(str, wid ); |
72 | } | 73 | } |
73 | 74 | ||
74 | 75 | ||
75 | // Terminal Widget(s) | 76 | // Terminal Widget(s) |
76 | ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) { | 77 | ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) { |
77 | return new TerminalWidget(na, wid,0 ); | 78 | return new TerminalWidget(na, wid,0 ); |
78 | } | 79 | } |
79 | 80 | ||
80 | // Function Keyboard Widget | 81 | // Function Keyboard Widget |
81 | ProfileDialogWidget* newKeyboardWidget(const QString& na, QWidget *wid) { | 82 | ProfileDialogWidget* newKeyboardWidget(const QString& na, QWidget *wid) { |
82 | return new FunctionKeyboardConfig(na, wid); | 83 | return new FunctionKeyboardConfig(na, wid); |
83 | } | 84 | } |
84 | 85 | ||
85 | /* // VT Emulations | 86 | /* // VT Emulations |
86 | EmulationLayer* newVT102( WidgetLayer* wid ) { | 87 | EmulationLayer* newVT102( WidgetLayer* wid ) { |
87 | return new Vt102Emulation( wid ); | 88 | return new Vt102Emulation( wid ); |
88 | } | 89 | } |
89 | */ | 90 | */ |
90 | }; | 91 | }; |
91 | 92 | ||
92 | Default::Default( MetaFactory* fact ) { | 93 | Default::Default( MetaFactory* fact ) { |
93 | fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer ); | 94 | fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer ); |
94 | fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer ); | 95 | fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer ); |
95 | fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer ); | 96 | fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer ); |
96 | 97 | ||
97 | fact->addReceiveLayer( "SZ", QObject::tr("Z-Modem"), newSZReceive ); | 98 | fact->addReceiveLayer( "SZ", QObject::tr("Z-Modem"), newSZReceive ); |
98 | fact->addReceiveLayer( "SY", QObject::tr("Y-Modem"), newSYReceive ); | 99 | fact->addReceiveLayer( "SY", QObject::tr("Y-Modem"), newSYReceive ); |
99 | fact->addReceiveLayer( "SX", QObject::tr("X-Modem"), newSXReceive ); | 100 | fact->addReceiveLayer( "SX", QObject::tr("X-Modem"), newSXReceive ); |
100 | 101 | ||
101 | fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer ); | 102 | fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer ); |
102 | // fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer ); | 103 | // fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer ); |
103 | // fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer ); | 104 | // fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer ); |
104 | fact->addIOLayerFactory( "modem", QObject::tr("Modem"), newModemLayer ); | 105 | fact->addIOLayerFactory( "modem", QObject::tr("Modem"), newModemLayer ); |
105 | fact->addIOLayerFactory( "console", QObject::tr("local Console"), newConsole ); | 106 | fact->addIOLayerFactory( "console", QObject::tr("Local Console"), newConsole ); |
106 | 107 | ||
107 | fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget ); | 108 | fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget ); |
108 | // fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget ); | 109 | // fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget ); |
109 | fact->addConnectionWidgetFactory( "modem", QObject::tr("Modem"), newModemWidget ); | 110 | fact->addConnectionWidgetFactory( "modem", QObject::tr("Modem"), newModemWidget ); |
110 | // fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); | 111 | // fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); |
111 | fact->addConnectionWidgetFactory( "console", QObject::tr("local Console"), newConsoleWid ); | 112 | fact->addConnectionWidgetFactory( "console", QObject::tr("Local Console"), newConsoleWid ); |
112 | 113 | ||
113 | fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget ); | 114 | fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget ); |
114 | fact->addKeyboardWidgetFactory( "defaultKeys", QObject::tr("Default Keyboard"), | 115 | fact->addKeyboardWidgetFactory( "defaultKeys", QObject::tr("Default Keyboard"), |
115 | newKeyboardWidget ); | 116 | newKeyboardWidget ); |
116 | 117 | ||
117 | // fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 ); | 118 | // fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 ); |
118 | } | 119 | } |
119 | Default::~Default() { | 120 | Default::~Default() { |
120 | 121 | ||
121 | } | 122 | } |
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index f5737d4..e3f92f0 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro | |||
@@ -9,62 +9,64 @@ HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \ | |||
9 | mainwindow.h \ | 9 | mainwindow.h \ |
10 | profile.h \ | 10 | profile.h \ |
11 | profileconfig.h \ | 11 | profileconfig.h \ |
12 | profilemanager.h \ | 12 | profilemanager.h \ |
13 | configwidget.h \ | 13 | configwidget.h \ |
14 | tabwidget.h \ | 14 | tabwidget.h \ |
15 | configdialog.h \ | 15 | configdialog.h \ |
16 | keytrans.h \ | 16 | keytrans.h \ |
17 | transferdialog.h \ | 17 | transferdialog.h \ |
18 | profiledialogwidget.h \ | 18 | profiledialogwidget.h \ |
19 | profileeditordialog.h \ | 19 | profileeditordialog.h \ |
20 | default.h \ | 20 | default.h \ |
21 | iolayerbase.h \ | 21 | iolayerbase.h \ |
22 | serialconfigwidget.h irdaconfigwidget.h \ | 22 | serialconfigwidget.h irdaconfigwidget.h \ |
23 | btconfigwidget.h modemconfigwidget.h \ | 23 | btconfigwidget.h modemconfigwidget.h \ |
24 | atconfigdialog.h dialdialog.h \ | 24 | atconfigdialog.h dialdialog.h \ |
25 | procctl.h \ | 25 | procctl.h \ |
26 | function_keyboard.h \ | 26 | function_keyboard.h \ |
27 | receive_layer.h filereceive.h \ | 27 | receive_layer.h filereceive.h \ |
28 | script.h \ | 28 | script.h \ |
29 | dialer.h \ | 29 | dialer.h \ |
30 | terminalwidget.h \ | 30 | terminalwidget.h \ |
31 | emulation_handler.h TECommon.h \ | 31 | emulation_handler.h TECommon.h \ |
32 | TEHistroy.h TEScreen.h TEWidget.h \ | 32 | TEHistroy.h TEScreen.h TEWidget.h \ |
33 | TEmuVt102.h TEmulation.h MyPty.h | 33 | TEmuVt102.h TEmulation.h MyPty.h \ |
34 | consoleconfigwidget.h | ||
34 | 35 | ||
35 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ | 36 | SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \ |
36 | file_layer.cpp filetransfer.cpp \ | 37 | file_layer.cpp filetransfer.cpp \ |
37 | main.cpp \ | 38 | main.cpp \ |
38 | metafactory.cpp \ | 39 | metafactory.cpp \ |
39 | session.cpp \ | 40 | session.cpp \ |
40 | mainwindow.cpp \ | 41 | mainwindow.cpp \ |
41 | profile.cpp \ | 42 | profile.cpp \ |
42 | profileconfig.cpp \ | 43 | profileconfig.cpp \ |
43 | profilemanager.cpp \ | 44 | profilemanager.cpp \ |
44 | tabwidget.cpp \ | 45 | tabwidget.cpp \ |
45 | configdialog.cpp \ | 46 | configdialog.cpp \ |
46 | keytrans.cpp \ | 47 | keytrans.cpp \ |
47 | transferdialog.cpp \ | 48 | transferdialog.cpp \ |
48 | profiledialogwidget.cpp \ | 49 | profiledialogwidget.cpp \ |
49 | profileeditordialog.cpp \ | 50 | profileeditordialog.cpp \ |
50 | iolayerbase.cpp \ | 51 | iolayerbase.cpp \ |
51 | serialconfigwidget.cpp irdaconfigwidget.cpp \ | 52 | serialconfigwidget.cpp irdaconfigwidget.cpp \ |
52 | btconfigwidget.cpp modemconfigwidget.cpp \ | 53 | btconfigwidget.cpp modemconfigwidget.cpp \ |
53 | atconfigdialog.cpp dialdialog.cpp \ | 54 | atconfigdialog.cpp dialdialog.cpp \ |
54 | default.cpp procctl.cpp \ | 55 | default.cpp procctl.cpp \ |
55 | function_keyboard.cpp \ | 56 | function_keyboard.cpp \ |
56 | receive_layer.cpp filereceive.cpp \ | 57 | receive_layer.cpp filereceive.cpp \ |
57 | script.cpp \ | 58 | script.cpp \ |
58 | dialer.cpp \ | 59 | dialer.cpp \ |
59 | terminalwidget.cpp \ | 60 | terminalwidget.cpp \ |
60 | emulation_handler.cpp TEHistory.cpp \ | 61 | emulation_handler.cpp TEHistory.cpp \ |
61 | TEScreen.cpp TEWidget.cpp \ | 62 | TEScreen.cpp TEWidget.cpp \ |
62 | TEmuVt102.cpp TEmulation.cpp MyPty.cpp | 63 | TEmuVt102.cpp TEmulation.cpp MyPty.cpp \ |
64 | consoleconfigwidget.cpp | ||
63 | 65 | ||
64 | 66 | ||
65 | INTERFACES = configurebase.ui editbase.ui | 67 | INTERFACES = configurebase.ui editbase.ui |
66 | INCLUDEPATH += $(OPIEDIR)/include | 68 | INCLUDEPATH += $(OPIEDIR)/include |
67 | DEPENDPATH += $(OPIEDIR)/include | 69 | DEPENDPATH += $(OPIEDIR)/include |
68 | LIBS += -lqpe -lopie | 70 | LIBS += -lqpe -lopie |
69 | TARGET = opie-console | 71 | TARGET = opie-console |
70 | 72 | ||