author | harlekin <harlekin> | 2002-10-17 17:56:30 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-10-17 17:56:30 (UTC) |
commit | 08e9fcbbaf57383fd65fe4eb197d97a51abe0f26 (patch) (unidiff) | |
tree | 5d7fc6d46ae5721481e1f8f98a7872416f720993 | |
parent | eb70c5c231b80d1e925b0098ad3c951917900071 (diff) | |
download | opie-08e9fcbbaf57383fd65fe4eb197d97a51abe0f26.zip opie-08e9fcbbaf57383fd65fe4eb197d97a51abe0f26.tar.gz opie-08e9fcbbaf57383fd65fe4eb197d97a51abe0f26.tar.bz2 |
autologin if profiles io layer offers it
-rw-r--r-- | noncore/apps/opie-console/MyPty.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/MyPty.cpp b/noncore/apps/opie-console/MyPty.cpp index 565d03f..a2373bf 100644 --- a/noncore/apps/opie-console/MyPty.cpp +++ b/noncore/apps/opie-console/MyPty.cpp | |||
@@ -127,198 +127,200 @@ void MyPty::donePty() | |||
127 | // emit done(status); | 127 | // emit done(status); |
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
131 | const char* MyPty::deviceName() | 131 | const char* MyPty::deviceName() |
132 | { | 132 | { |
133 | return m_ttynam; | 133 | return m_ttynam; |
134 | } | 134 | } |
135 | 135 | ||
136 | 136 | ||
137 | void MyPty::error() | 137 | void MyPty::error() |
138 | { | 138 | { |
139 | // This is code from the Qt DumbTerminal example | 139 | // This is code from the Qt DumbTerminal example |
140 | donePty(); | 140 | donePty(); |
141 | } | 141 | } |
142 | 142 | ||
143 | void MyPty::start() { | 143 | void MyPty::start() { |
144 | char* cmd = "/bin/sh"; | 144 | char* cmd = "/bin/sh"; |
145 | QStrList lis; | 145 | QStrList lis; |
146 | int r =run(cmd, lis, 0, 0); | 146 | int r =run(cmd, lis, 0, 0); |
147 | r = r; | 147 | r = r; |
148 | } | 148 | } |
149 | /*! | 149 | /*! |
150 | start the client program. | 150 | start the client program. |
151 | */ | 151 | */ |
152 | int MyPty::run(const char* cmd, QStrList &, const char*, int) | 152 | int MyPty::run(const char* cmd, QStrList &, const char*, int) |
153 | { | 153 | { |
154 | // This is code from the Qt DumbTerminal example | 154 | // This is code from the Qt DumbTerminal example |
155 | m_cpid = fork(); | 155 | m_cpid = fork(); |
156 | 156 | ||
157 | if ( !m_cpid ) { | 157 | if ( !m_cpid ) { |
158 | // child - exec shell on tty | 158 | // child - exec shell on tty |
159 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); | 159 | for (int sig = 1; sig < NSIG; sig++) signal(sig,SIG_DFL); |
160 | int ttyfd = ::open(m_ttynam, O_RDWR); | 160 | int ttyfd = ::open(m_ttynam, O_RDWR); |
161 | dup2(ttyfd, STDIN_FILENO); | 161 | dup2(ttyfd, STDIN_FILENO); |
162 | dup2(ttyfd, STDOUT_FILENO); | 162 | dup2(ttyfd, STDOUT_FILENO); |
163 | dup2(ttyfd, STDERR_FILENO); | 163 | dup2(ttyfd, STDERR_FILENO); |
164 | // should be done with tty, so close it | 164 | // should be done with tty, so close it |
165 | ::close(ttyfd); | 165 | ::close(ttyfd); |
166 | static struct termios ttmode; | 166 | static struct termios ttmode; |
167 | if ( setsid() < 0 ) | 167 | if ( setsid() < 0 ) |
168 | perror( "failed to set process group" ); | 168 | perror( "failed to set process group" ); |
169 | #if defined (TIOCSCTTY) | 169 | #if defined (TIOCSCTTY) |
170 | // grabbed from APUE by Stevens | 170 | // grabbed from APUE by Stevens |
171 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); | 171 | ioctl(STDIN_FILENO, TIOCSCTTY, 0); |
172 | #endif | 172 | #endif |
173 | tcgetattr( STDIN_FILENO, &ttmode ); | 173 | tcgetattr( STDIN_FILENO, &ttmode ); |
174 | ttmode.c_cc[VINTR] = 3; | 174 | ttmode.c_cc[VINTR] = 3; |
175 | ttmode.c_cc[VERASE] = 8; | 175 | ttmode.c_cc[VERASE] = 8; |
176 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); | 176 | tcsetattr( STDIN_FILENO, TCSANOW, &ttmode ); |
177 | setenv("TERM","vt100",1); | 177 | setenv("TERM","vt100",1); |
178 | setenv("COLORTERM","0",1); | 178 | setenv("COLORTERM","0",1); |
179 | 179 | ||
180 | if (getuid() == 0) { | 180 | if (getuid() == 0) { |
181 | char msg[] = "WARNING: You are running this shell as root!\n"; | 181 | char msg[] = "WARNING: You are running this shell as root!\n"; |
182 | write(ttyfd, msg, sizeof(msg)); | 182 | write(ttyfd, msg, sizeof(msg)); |
183 | } | 183 | } |
184 | execl(cmd, cmd, 0); | 184 | execl(cmd, cmd, 0); |
185 | 185 | ||
186 | donePty(); | 186 | donePty(); |
187 | exit(-1); | 187 | exit(-1); |
188 | } | 188 | } |
189 | 189 | ||
190 | // parent - continue as a widget | 190 | // parent - continue as a widget |
191 | delete m_sn_r; | 191 | delete m_sn_r; |
192 | m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); | 192 | m_sn_r = new QSocketNotifier(m_fd,QSocketNotifier::Read,this); |
193 | delete m_sn_e; | 193 | delete m_sn_e; |
194 | m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); | 194 | m_sn_e = new QSocketNotifier(m_fd,QSocketNotifier::Exception,this); |
195 | connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); | 195 | connect(m_sn_r,SIGNAL(activated(int)),this,SLOT(readPty())); |
196 | connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); | 196 | connect(m_sn_e,SIGNAL(activated(int)),this,SLOT(error())); |
197 | 197 | ||
198 | return 0; | 198 | return 0; |
199 | } | 199 | } |
200 | 200 | ||
201 | int MyPty::openPty() | 201 | int MyPty::openPty() |
202 | { | 202 | { |
203 | // This is code from the Qt DumbTerminal example | 203 | // This is code from the Qt DumbTerminal example |
204 | int ptyfd = -1; | 204 | int ptyfd = -1; |
205 | 205 | ||
206 | #ifdef HAVE_OPENPTY | 206 | #ifdef HAVE_OPENPTY |
207 | int ttyfd; | 207 | int ttyfd; |
208 | if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) ) | 208 | if ( openpty(&ptyfd,&ttyfd,ttynam,0,0) ) |
209 | ptyfd = -1; | 209 | ptyfd = -1; |
210 | else | 210 | else |
211 | close(ttyfd); // we open the ttynam ourselves. | 211 | close(ttyfd); // we open the ttynam ourselves. |
212 | #else | 212 | #else |
213 | for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { | 213 | for (const char* c0 = "pqrstuvwxyzabcde"; ptyfd < 0 && *c0 != 0; c0++) { |
214 | for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { | 214 | for (const char* c1 = "0123456789abcdef"; ptyfd < 0 && *c1 != 0; c1++) { |
215 | sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); | 215 | sprintf(m_ptynam,"/dev/pty%c%c",*c0,*c1); |
216 | sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); | 216 | sprintf(m_ttynam,"/dev/tty%c%c",*c0,*c1); |
217 | if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { | 217 | if ((ptyfd = ::open(m_ptynam,O_RDWR)) >= 0) { |
218 | if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { | 218 | if (geteuid() != 0 && !access(m_ttynam,R_OK|W_OK) == 0) { |
219 | ::close(ptyfd); | 219 | ::close(ptyfd); |
220 | ptyfd = -1; | 220 | ptyfd = -1; |
221 | } | 221 | } |
222 | } | 222 | } |
223 | } | 223 | } |
224 | } | 224 | } |
225 | #endif | 225 | #endif |
226 | 226 | ||
227 | if ( ptyfd < 0 ) { | 227 | if ( ptyfd < 0 ) { |
228 | //qApp->exit(1); | 228 | //qApp->exit(1); |
229 | return -1; | 229 | return -1; |
230 | } | 230 | } |
231 | 231 | ||
232 | return ptyfd; | 232 | return ptyfd; |
233 | } | 233 | } |
234 | 234 | ||
235 | /*! | 235 | /*! |
236 | Create an instance. | 236 | Create an instance. |
237 | */ | 237 | */ |
238 | MyPty::MyPty(const Profile&) : m_cpid(0) | 238 | MyPty::MyPty(const Profile&) : m_cpid(0) |
239 | { | 239 | { |
240 | m_sn_e = 0l; | 240 | m_sn_e = 0l; |
241 | m_sn_r = 0l; | 241 | m_sn_r = 0l; |
242 | m_fd = openPty(); | 242 | m_fd = openPty(); |
243 | ProcCtl* ctl = ProcCtl::self(); | 243 | ProcCtl* ctl = ProcCtl::self(); |
244 | } | 244 | } |
245 | 245 | ||
246 | /*! | 246 | /*! |
247 | Destructor. | 247 | Destructor. |
248 | Note that the related client program is not killed | 248 | Note that the related client program is not killed |
249 | (yet) when a instance is deleted. | 249 | (yet) when a instance is deleted. |
250 | */ | 250 | */ |
251 | MyPty::~MyPty() | 251 | MyPty::~MyPty() |
252 | { | 252 | { |
253 | donePty(); | 253 | donePty(); |
254 | } | 254 | } |
255 | QString MyPty::identifier()const { | 255 | QString MyPty::identifier()const { |
256 | return QString::fromLatin1("term"); | 256 | return QString::fromLatin1("term"); |
257 | } | 257 | } |
258 | QString MyPty::name()const{ | 258 | QString MyPty::name()const{ |
259 | return identifier(); | 259 | return identifier(); |
260 | } | 260 | } |
261 | bool MyPty::open() { | 261 | bool MyPty::open() { |
262 | if (m_fd < 0) | 262 | if (m_fd < 0) |
263 | m_fd = openPty(); | 263 | m_fd = openPty(); |
264 | 264 | ||
265 | start(); | 265 | start(); |
266 | return true; | 266 | return true; |
267 | } | 267 | } |
268 | void MyPty::close() { | 268 | void MyPty::close() { |
269 | donePty(); | 269 | donePty(); |
270 | m_fd = openPty(); | 270 | m_fd = openPty(); |
271 | } | 271 | } |
272 | void MyPty::reload( const Profile& ) { | 272 | void MyPty::reload( const Profile& ) { |
273 | 273 | ||
274 | } | 274 | } |
275 | /*! sends len bytes through the line */ | 275 | /*! sends len bytes through the line */ |
276 | void MyPty::send(const QByteArray& ar) | 276 | void MyPty::send(const QByteArray& ar) |
277 | { | 277 | { |
278 | #ifdef VERBOSE_DEBUG | 278 | #ifdef VERBOSE_DEBUG |
279 | // verbose debug | 279 | // verbose debug |
280 | printf("sending bytes:\n"); | 280 | printf("sending bytes:\n"); |
281 | for (uint i = 0; i < ar.count(); i++) | 281 | for (uint i = 0; i < ar.count(); i++) |
282 | printf("%c", ar[i]); | 282 | printf("%c", ar[i]); |
283 | printf("\n"); | 283 | printf("\n"); |
284 | #endif | 284 | #endif |
285 | 285 | ||
286 | ::write(m_fd, ar.data(), ar.count()); | 286 | ::write(m_fd, ar.data(), ar.count()); |
287 | } | 287 | } |
288 | 288 | ||
289 | /*! indicates that a block of data is received */ | 289 | /*! indicates that a block of data is received */ |
290 | void MyPty::readPty() | 290 | void MyPty::readPty() |
291 | { | 291 | { |
292 | QByteArray buf(4096); | 292 | QByteArray buf(4096); |
293 | 293 | ||
294 | int len = ::read( m_fd, buf.data(), 4096 ); | 294 | int len = ::read( m_fd, buf.data(), 4096 ); |
295 | 295 | ||
296 | if (len == -1 || len == 0) { | 296 | if (len == -1 || len == 0) { |
297 | donePty(); | 297 | donePty(); |
298 | return; | 298 | return; |
299 | } | 299 | } |
300 | 300 | ||
301 | if (len < 0) | 301 | if (len < 0) |
302 | return; | 302 | return; |
303 | 303 | ||
304 | 304 | ||
305 | buf.resize(len); | 305 | buf.resize(len); |
306 | emit received(buf); | 306 | emit received(buf); |
307 | 307 | ||
308 | #ifdef VERBOSE_DEBUG | 308 | #ifdef VERBOSE_DEBUG |
309 | // verbose debug | 309 | // verbose debug |
310 | printf("read bytes:\n"); | 310 | printf("read bytes:\n"); |
311 | for (uint i = 0; i < buf.count(); i++) | 311 | for (uint i = 0; i < buf.count(); i++) |
312 | printf("%c", buf[i]); | 312 | printf("%c", buf[i]); |
313 | printf("\n"); | 313 | printf("\n"); |
314 | #endif | 314 | #endif |
315 | 315 | ||
316 | } | 316 | } |
317 | QBitArray MyPty::supports()const { | 317 | QBitArray MyPty::supports()const { |
318 | QBitArray ar(3); | 318 | QBitArray ar(3); |
319 | //autoconnect | ||
319 | ar[0] = 1; | 320 | ar[0] = 1; |
321 | // | ||
320 | ar[1] = 0; | 322 | ar[1] = 0; |
321 | ar[2] = 0; | 323 | ar[2] = 0; |
322 | 324 | ||
323 | return ar; | 325 | return ar; |
324 | } | 326 | } |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 3066b35..fdb0452 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -209,274 +209,279 @@ void MainWindow::initUI() { | |||
209 | 209 | ||
210 | /* | 210 | /* |
211 | * connect to the menu activation | 211 | * connect to the menu activation |
212 | */ | 212 | */ |
213 | connect( m_sessionsPop, SIGNAL(activated( int ) ), | 213 | connect( m_sessionsPop, SIGNAL(activated( int ) ), |
214 | this, SLOT(slotProfile( int ) ) ); | 214 | this, SLOT(slotProfile( int ) ) ); |
215 | 215 | ||
216 | m_consoleWindow = new TabWidget( this, "blah"); | 216 | m_consoleWindow = new TabWidget( this, "blah"); |
217 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), | 217 | connect(m_consoleWindow, SIGNAL(activated(Session*) ), |
218 | this, SLOT(slotSessionChanged(Session*) ) ); | 218 | this, SLOT(slotSessionChanged(Session*) ) ); |
219 | setCentralWidget( m_consoleWindow ); | 219 | setCentralWidget( m_consoleWindow ); |
220 | 220 | ||
221 | } | 221 | } |
222 | 222 | ||
223 | ProfileManager* MainWindow::manager() { | 223 | ProfileManager* MainWindow::manager() { |
224 | return m_manager; | 224 | return m_manager; |
225 | } | 225 | } |
226 | TabWidget* MainWindow::tabWidget() { | 226 | TabWidget* MainWindow::tabWidget() { |
227 | return m_consoleWindow; | 227 | return m_consoleWindow; |
228 | } | 228 | } |
229 | void MainWindow::populateProfiles() { | 229 | void MainWindow::populateProfiles() { |
230 | m_sessionsPop->clear(); | 230 | m_sessionsPop->clear(); |
231 | Profile::ValueList list = manager()->all(); | 231 | Profile::ValueList list = manager()->all(); |
232 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { | 232 | for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) { |
233 | m_sessionsPop->insertItem( (*it).name() ); | 233 | m_sessionsPop->insertItem( (*it).name() ); |
234 | } | 234 | } |
235 | 235 | ||
236 | } | 236 | } |
237 | MainWindow::~MainWindow() { | 237 | MainWindow::~MainWindow() { |
238 | delete m_factory; | 238 | delete m_factory; |
239 | manager()->save(); | 239 | manager()->save(); |
240 | } | 240 | } |
241 | 241 | ||
242 | MetaFactory* MainWindow::factory() { | 242 | MetaFactory* MainWindow::factory() { |
243 | return m_factory; | 243 | return m_factory; |
244 | } | 244 | } |
245 | 245 | ||
246 | Session* MainWindow::currentSession() { | 246 | Session* MainWindow::currentSession() { |
247 | return m_curSession; | 247 | return m_curSession; |
248 | } | 248 | } |
249 | 249 | ||
250 | QList<Session> MainWindow::sessions() { | 250 | QList<Session> MainWindow::sessions() { |
251 | return m_sessions; | 251 | return m_sessions; |
252 | } | 252 | } |
253 | 253 | ||
254 | void MainWindow::slotNew() { | 254 | void MainWindow::slotNew() { |
255 | ProfileEditorDialog dlg(factory() ); | 255 | ProfileEditorDialog dlg(factory() ); |
256 | dlg.showMaximized(); | 256 | dlg.showMaximized(); |
257 | int ret = dlg.exec(); | 257 | int ret = dlg.exec(); |
258 | 258 | ||
259 | if ( ret == QDialog::Accepted ) { | 259 | if ( ret == QDialog::Accepted ) { |
260 | create( dlg.profile() ); | 260 | create( dlg.profile() ); |
261 | } | 261 | } |
262 | } | 262 | } |
263 | 263 | ||
264 | void MainWindow::slotRecordScript() { | 264 | void MainWindow::slotRecordScript() { |
265 | /* if (currentSession()) { | 265 | /* if (currentSession()) { |
266 | currentSession()->emulationLayer()->startRecording(); | 266 | currentSession()->emulationLayer()->startRecording(); |
267 | } | 267 | } |
268 | */ | 268 | */ |
269 | } | 269 | } |
270 | 270 | ||
271 | void MainWindow::slotSaveScript() { | 271 | void MainWindow::slotSaveScript() { |
272 | /* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { | 272 | /* if (currentSession() && currentSession()->emulationLayer()->isRecording()) { |
273 | MimeTypes types; | 273 | MimeTypes types; |
274 | QStringList script; | 274 | QStringList script; |
275 | script << "text/plain"; | 275 | script << "text/plain"; |
276 | types.insert("Script", script); | 276 | types.insert("Script", script); |
277 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); | 277 | QString filename = OFileDialog::getSaveFileName(2, "/", QString::null, types); |
278 | if (!filename.isEmpty()) { | 278 | if (!filename.isEmpty()) { |
279 | currentSession()->emulationLayer()->script()->saveTo(filename); | 279 | currentSession()->emulationLayer()->script()->saveTo(filename); |
280 | currentSession()->emulationLayer()->clearScript(); | 280 | currentSession()->emulationLayer()->clearScript(); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | */ | 283 | */ |
284 | } | 284 | } |
285 | 285 | ||
286 | void MainWindow::slotRunScript() { | 286 | void MainWindow::slotRunScript() { |
287 | /* | 287 | /* |
288 | if (currentSession()) { | 288 | if (currentSession()) { |
289 | MimeTypes types; | 289 | MimeTypes types; |
290 | QStringList script; | 290 | QStringList script; |
291 | script << "text/plain"; | 291 | script << "text/plain"; |
292 | types.insert("Script", script); | 292 | types.insert("Script", script); |
293 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); | 293 | QString filename = OFileDialog::getOpenFileName(2, "/", QString::null, types); |
294 | if (!filename.isEmpty()) { | 294 | if (!filename.isEmpty()) { |
295 | Script script(DocLnk(filename).file()); | 295 | Script script(DocLnk(filename).file()); |
296 | currentSession()->emulationLayer()->runScript(&script); | 296 | currentSession()->emulationLayer()->runScript(&script); |
297 | } | 297 | } |
298 | } | 298 | } |
299 | */ | 299 | */ |
300 | } | 300 | } |
301 | 301 | ||
302 | void MainWindow::slotConnect() { | 302 | void MainWindow::slotConnect() { |
303 | if ( currentSession() ) { | 303 | if ( currentSession() ) { |
304 | bool ret = currentSession()->layer()->open(); | 304 | bool ret = currentSession()->layer()->open(); |
305 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), | 305 | if(!ret) QMessageBox::warning(currentSession()->widgetStack(), |
306 | QObject::tr("Failed"), | 306 | QObject::tr("Failed"), |
307 | QObject::tr("Connecting failed for this session.")); | 307 | QObject::tr("Connecting failed for this session.")); |
308 | else { | 308 | else { |
309 | m_connect->setEnabled( false ); | 309 | m_connect->setEnabled( false ); |
310 | m_disconnect->setEnabled( true ); | 310 | m_disconnect->setEnabled( true ); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | } | 313 | } |
314 | 314 | ||
315 | void MainWindow::slotDisconnect() { | 315 | void MainWindow::slotDisconnect() { |
316 | if ( currentSession() ) { | 316 | if ( currentSession() ) { |
317 | currentSession()->layer()->close(); | 317 | currentSession()->layer()->close(); |
318 | m_connect->setEnabled( true ); | 318 | m_connect->setEnabled( true ); |
319 | m_disconnect->setEnabled( false ); | 319 | m_disconnect->setEnabled( false ); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | 322 | ||
323 | void MainWindow::slotTerminate() { | 323 | void MainWindow::slotTerminate() { |
324 | if ( currentSession() ) | 324 | if ( currentSession() ) |
325 | currentSession()->layer()->close(); | 325 | currentSession()->layer()->close(); |
326 | 326 | ||
327 | slotClose(); | 327 | slotClose(); |
328 | /* FIXME move to the next session */ | 328 | /* FIXME move to the next session */ |
329 | } | 329 | } |
330 | 330 | ||
331 | void MainWindow::slotConfigure() { | 331 | void MainWindow::slotConfigure() { |
332 | ConfigDialog conf( manager()->all(), factory() ); | 332 | ConfigDialog conf( manager()->all(), factory() ); |
333 | conf.showMaximized(); | 333 | conf.showMaximized(); |
334 | 334 | ||
335 | int ret = conf.exec(); | 335 | int ret = conf.exec(); |
336 | 336 | ||
337 | if ( QDialog::Accepted == ret ) { | 337 | if ( QDialog::Accepted == ret ) { |
338 | manager()->setProfiles( conf.list() ); | 338 | manager()->setProfiles( conf.list() ); |
339 | manager()->save(); | 339 | manager()->save(); |
340 | populateProfiles(); | 340 | populateProfiles(); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | /* | 343 | /* |
344 | * we will remove | 344 | * we will remove |
345 | * this window from the tabwidget | 345 | * this window from the tabwidget |
346 | * remove it from the list | 346 | * remove it from the list |
347 | * delete it | 347 | * delete it |
348 | * and set the currentSession() | 348 | * and set the currentSession() |
349 | */ | 349 | */ |
350 | void MainWindow::slotClose() { | 350 | void MainWindow::slotClose() { |
351 | if (!currentSession() ) | 351 | if (!currentSession() ) |
352 | return; | 352 | return; |
353 | 353 | ||
354 | Session* ses = currentSession(); | 354 | Session* ses = currentSession(); |
355 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); | 355 | qWarning("removing! currentSession %s", currentSession()->name().latin1() ); |
356 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ | 356 | /* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */ |
357 | m_curSession = NULL; | 357 | m_curSession = NULL; |
358 | tabWidget()->remove( /*currentSession()*/ses ); | 358 | tabWidget()->remove( /*currentSession()*/ses ); |
359 | /*it's autodelete */ | 359 | /*it's autodelete */ |
360 | m_sessions.remove( ses ); | 360 | m_sessions.remove( ses ); |
361 | qWarning("after remove!!"); | 361 | qWarning("after remove!!"); |
362 | 362 | ||
363 | if (!currentSession() ) { | 363 | if (!currentSession() ) { |
364 | m_connect->setEnabled( false ); | 364 | m_connect->setEnabled( false ); |
365 | m_disconnect->setEnabled( false ); | 365 | m_disconnect->setEnabled( false ); |
366 | m_terminate->setEnabled( false ); | 366 | m_terminate->setEnabled( false ); |
367 | m_transfer->setEnabled( false ); | 367 | m_transfer->setEnabled( false ); |
368 | m_recordScript->setEnabled( false ); | 368 | m_recordScript->setEnabled( false ); |
369 | m_saveScript->setEnabled( false ); | 369 | m_saveScript->setEnabled( false ); |
370 | m_runScript->setEnabled( false ); | 370 | m_runScript->setEnabled( false ); |
371 | m_fullscreen->setEnabled( false ); | 371 | m_fullscreen->setEnabled( false ); |
372 | m_closewindow->setEnabled( false ); | 372 | m_closewindow->setEnabled( false ); |
373 | } | 373 | } |
374 | } | 374 | } |
375 | 375 | ||
376 | /* | 376 | /* |
377 | * We will get the name | 377 | * We will get the name |
378 | * Then the profile | 378 | * Then the profile |
379 | * and then we will make a profile | 379 | * and then we will make a profile |
380 | */ | 380 | */ |
381 | void MainWindow::slotProfile( int id) { | 381 | void MainWindow::slotProfile( int id) { |
382 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); | 382 | Profile prof = manager()->profile( m_sessionsPop->text( id) ); |
383 | create( prof ); | 383 | create( prof ); |
384 | } | 384 | } |
385 | void MainWindow::create( const Profile& prof ) { | 385 | void MainWindow::create( const Profile& prof ) { |
386 | Session *ses = manager()->fromProfile( prof, tabWidget() ); | 386 | Session *ses = manager()->fromProfile( prof, tabWidget() ); |
387 | 387 | ||
388 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) | 388 | if((!ses) || (!ses->layer()) || (!ses->widgetStack())) |
389 | { | 389 | { |
390 | QMessageBox::warning(this, | 390 | QMessageBox::warning(this, |
391 | QObject::tr("Session failed"), | 391 | QObject::tr("Session failed"), |
392 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); | 392 | QObject::tr("<qt>Cannot open session: Not all components were found.</qt>")); |
393 | //if(ses) delete ses; | 393 | //if(ses) delete ses; |
394 | return; | 394 | return; |
395 | } | 395 | } |
396 | 396 | ||
397 | m_sessions.append( ses ); | 397 | m_sessions.append( ses ); |
398 | tabWidget()->add( ses ); | 398 | tabWidget()->add( ses ); |
399 | m_curSession = ses; | 399 | m_curSession = ses; |
400 | 400 | ||
401 | // is io_layer wants direct connection, then autoconnect | ||
402 | if ( ( m_curSession->layer() )->supports()[0] = 1 ) { | ||
403 | slotConnect(); | ||
404 | } | ||
405 | |||
401 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it | 406 | // dicide if its a local term ( then no connction and no tranfer), maybe make a wrapper method out of it |
402 | m_connect->setEnabled( true ); | 407 | m_connect->setEnabled( true ); |
403 | m_disconnect->setEnabled( false ); | 408 | m_disconnect->setEnabled( false ); |
404 | m_terminate->setEnabled( true ); | 409 | m_terminate->setEnabled( true ); |
405 | m_transfer->setEnabled( true ); | 410 | m_transfer->setEnabled( true ); |
406 | m_recordScript->setEnabled( true ); | 411 | m_recordScript->setEnabled( true ); |
407 | m_saveScript->setEnabled( true ); | 412 | m_saveScript->setEnabled( true ); |
408 | m_runScript->setEnabled( true ); | 413 | m_runScript->setEnabled( true ); |
409 | m_fullscreen->setEnabled( true ); | 414 | m_fullscreen->setEnabled( true ); |
410 | m_closewindow->setEnabled( true ); | 415 | m_closewindow->setEnabled( true ); |
411 | } | 416 | } |
412 | 417 | ||
413 | void MainWindow::slotTransfer() | 418 | void MainWindow::slotTransfer() |
414 | { | 419 | { |
415 | if ( currentSession() ) { | 420 | if ( currentSession() ) { |
416 | TransferDialog dlg(this); | 421 | TransferDialog dlg(this); |
417 | dlg.showMaximized(); | 422 | dlg.showMaximized(); |
418 | dlg.exec(); | 423 | dlg.exec(); |
419 | } | 424 | } |
420 | } | 425 | } |
421 | 426 | ||
422 | 427 | ||
423 | void MainWindow::slotOpenKeb(bool state) { | 428 | void MainWindow::slotOpenKeb(bool state) { |
424 | 429 | ||
425 | if (state) m_keyBar->show(); | 430 | if (state) m_keyBar->show(); |
426 | else m_keyBar->hide(); | 431 | else m_keyBar->hide(); |
427 | 432 | ||
428 | } | 433 | } |
429 | void MainWindow::slotSessionChanged( Session* ses ) { | 434 | void MainWindow::slotSessionChanged( Session* ses ) { |
430 | qWarning("changed!"); | 435 | qWarning("changed!"); |
431 | if ( ses ) { | 436 | if ( ses ) { |
432 | m_curSession = ses; | 437 | m_curSession = ses; |
433 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); | 438 | qDebug(QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) ); |
434 | if ( m_curSession->layer()->isConnected() ) { | 439 | if ( m_curSession->layer()->isConnected() ) { |
435 | m_connect->setEnabled( false ); | 440 | m_connect->setEnabled( false ); |
436 | m_disconnect->setEnabled( true ); | 441 | m_disconnect->setEnabled( true ); |
437 | } else { | 442 | } else { |
438 | m_connect->setEnabled( true ); | 443 | m_connect->setEnabled( true ); |
439 | m_disconnect->setEnabled( false ); | 444 | m_disconnect->setEnabled( false ); |
440 | } | 445 | } |
441 | } | 446 | } |
442 | } | 447 | } |
443 | 448 | ||
444 | void MainWindow::slotFullscreen() { | 449 | void MainWindow::slotFullscreen() { |
445 | 450 | ||
446 | if ( m_isFullscreen ) { | 451 | if ( m_isFullscreen ) { |
447 | ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); | 452 | ( m_curSession->widgetStack() )->reparent( m_consoleWindow, 0, QPoint(0,0), false ); |
448 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 453 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
449 | setCentralWidget( m_consoleWindow ); | 454 | setCentralWidget( m_consoleWindow ); |
450 | ( m_curSession->widgetStack() )->show(); | 455 | ( m_curSession->widgetStack() )->show(); |
451 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); | 456 | ( m_curSession->emulationHandler() )->cornerButton()->hide(); |
452 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 457 | disconnect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
453 | 458 | ||
454 | } else { | 459 | } else { |
455 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); | 460 | ( m_curSession->widgetStack() )->setFrameStyle( QFrame::NoFrame ); |
456 | ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | 461 | ( m_curSession->widgetStack() )->reparent( 0,WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop |
457 | , QPoint(0,0), false ); | 462 | , QPoint(0,0), false ); |
458 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); | 463 | ( m_curSession->widgetStack() )->resize( qApp->desktop()->width(), qApp->desktop()->height() ); |
459 | ( m_curSession->widgetStack() )->setFocus(); | 464 | ( m_curSession->widgetStack() )->setFocus(); |
460 | ( m_curSession->widgetStack() )->show(); | 465 | ( m_curSession->widgetStack() )->show(); |
461 | 466 | ||
462 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); | 467 | ( ( m_curSession->emulationHandler() )->cornerButton() )->show(); |
463 | 468 | ||
464 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); | 469 | connect( ( m_curSession->emulationHandler() )->cornerButton(), SIGNAL( pressed() ), this, SLOT( slotFullscreen() ) ); |
465 | } | 470 | } |
466 | 471 | ||
467 | m_isFullscreen = !m_isFullscreen; | 472 | m_isFullscreen = !m_isFullscreen; |
468 | } | 473 | } |
469 | 474 | ||
470 | 475 | ||
471 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool, bool) { | 476 | void MainWindow::slotKeyReceived(ushort u, ushort q, bool, bool, bool) { |
472 | 477 | ||
473 | qWarning("received key event! relay to TE widget"); | 478 | qWarning("received key event! relay to TE widget"); |
474 | 479 | ||
475 | if ( m_curSession ) { | 480 | if ( m_curSession ) { |
476 | QKeyEvent ke(QEvent::KeyPress, q, u, 0); | 481 | QKeyEvent ke(QEvent::KeyPress, q, u, 0); |
477 | 482 | ||
478 | ke.ignore(); | 483 | ke.ignore(); |
479 | // where should i send this event? doesnt work sending it here | 484 | // where should i send this event? doesnt work sending it here |
480 | QApplication::sendEvent((QObject *)m_curSession->widgetStack(), &ke); | 485 | QApplication::sendEvent((QObject *)m_curSession->widgetStack(), &ke); |
481 | } | 486 | } |
482 | } | 487 | } |