2
This file is part of Konsole
4
Copyright (C) 2006-2007 by Robert Knight <robertknight@gmail.com>
5
Copyright (C) 1997,1998 by Lars Doelle <lars.doelle@on-line.de>
7
Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008
9
This program is free software; you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation; either version 2 of the License, or
12
(at your option) any later version.
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
33
#include <QApplication>
38
#include <QStringList>
43
//#include "kptyprocess.h"
44
#include "TerminalDisplay.h"
45
#include "ShellCommand.h"
46
#include "Vt102Emulation.h"
48
using namespace Konsole;
50
int Session::lastSessionId = 0;
52
Session::Session(QObject* parent) :
56
, _monitorActivity(false)
57
, _monitorSilence(false)
58
, _notifiedActivity(false)
62
, _addToUtmp(false) // disabled by default because of a bug encountered on certain systems
63
// which caused Konsole to hang when closing a tab and then opening a new
64
// one. A 'QProcess destroyed while still running' warning was being
65
// printed to the terminal. Likely a problem in KPty::logout()
66
// or KPty::login() which uses a QProcess to start /usr/bin/utempter
68
, _fullScripting(false)
70
// , _zmodemBusy(false)
72
// , _zmodemProgress(0)
73
, _hasDarkBackground(false)
75
//prepare DBus communication
76
// new SessionAdaptor(this);
77
_sessionId = ++lastSessionId;
78
// QDBusConnection::sessionBus().registerObject(QLatin1String("/Sessions/")+QString::number(_sessionId), this);
80
//create teletype for I/O with shell process
81
_shellProcess = new Pty();
83
//create emulation backend
84
_emulation = new Vt102Emulation();
86
connect( _emulation, SIGNAL( titleChanged( int, const QString & ) ),
87
this, SLOT( setUserTitle( int, const QString & ) ) );
88
connect( _emulation, SIGNAL( stateSet(int) ),
89
this, SLOT( activityStateSet(int) ) );
90
// connect( _emulation, SIGNAL( zmodemDetected() ), this ,
91
// SLOT( fireZModemDetected() ) );
92
connect( _emulation, SIGNAL( changeTabTextColorRequest( int ) ),
93
this, SIGNAL( changeTabTextColorRequest( int ) ) );
94
connect( _emulation, SIGNAL(profileChangeCommandReceived(const QString &)),
95
this, SIGNAL( profileChangeCommandReceived(const QString &)) );
97
// connect( _emulation,SIGNAL(imageSizeChanged(int,int)) , this ,
98
// SLOT(onEmulationSizeChange(int,int)) );
100
//connect teletype to emulation backend
101
_shellProcess->setUtf8Mode(_emulation->utf8());
103
connect( _shellProcess,SIGNAL(receivedData(const char *,int)),this,
104
SLOT(onReceiveBlock(const char *,int)) );
105
connect( _emulation,SIGNAL(sendData(const char *,int)),_shellProcess,
106
SLOT(sendData(const char *,int)) );
107
connect( _emulation,SIGNAL(lockPtyRequest(bool)),_shellProcess,SLOT(lockPty(bool)) );
108
connect( _emulation,SIGNAL(useUtf8Request(bool)),_shellProcess,SLOT(setUtf8Mode(bool)) );
110
connect( _shellProcess,SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(done(int)) );
111
// not in kprocess anymore connect( _shellProcess,SIGNAL(done(int)), this, SLOT(done(int)) );
113
//setup timer for monitoring session activity
114
_monitorTimer = new QTimer(this);
115
_monitorTimer->setSingleShot(true);
116
connect(_monitorTimer, SIGNAL(timeout()), this, SLOT(monitorTimerDone()));
119
WId Session::windowId() const
121
// Returns a window ID for this session which is used
122
// to set the WINDOWID environment variable in the shell
125
// Sessions can have multiple views or no views, which means
126
// that a single ID is not always going to be accurate.
128
// If there are no views, the window ID is just 0. If
129
// there are multiple views, then the window ID for the
130
// top-level window which contains the first view is
133
if ( _views.count() == 0 ) {
136
QWidget * window = _views.first();
140
while ( window->parentWidget() != 0 ) {
141
window = window->parentWidget();
144
return window->winId();
148
void Session::setDarkBackground(bool darkBackground)
150
_hasDarkBackground = darkBackground;
152
bool Session::hasDarkBackground() const
154
return _hasDarkBackground;
156
bool Session::isRunning() const
158
return _shellProcess->state() == QProcess::Running;
161
void Session::setCodec(QTextCodec * codec)
163
emulation()->setCodec(codec);
166
void Session::setProgram(const QString & program)
168
_program = ShellCommand::expand(program);
170
void Session::setInitialWorkingDirectory(const QString & dir)
172
_initialWorkingDir = ShellCommand::expand(dir);
174
void Session::setArguments(const QStringList & arguments)
176
_arguments = ShellCommand::expand(arguments);
179
QList<TerminalDisplay *> Session::views() const
184
void Session::addView(TerminalDisplay * widget)
186
Q_ASSERT( !_views.contains(widget) );
188
_views.append(widget);
190
if ( _emulation != 0 ) {
191
// connect emulation - view signals and slots
192
connect( widget , SIGNAL(keyPressedSignal(QKeyEvent *)) , _emulation ,
193
SLOT(sendKeyEvent(QKeyEvent *)) );
194
connect( widget , SIGNAL(mouseSignal(int,int,int,int)) , _emulation ,
195
SLOT(sendMouseEvent(int,int,int,int)) );
196
connect( widget , SIGNAL(sendStringToEmu(const char *)) , _emulation ,
197
SLOT(sendString(const char *)) );
199
// allow emulation to notify view when the foreground process
200
// indicates whether or not it is interested in mouse signals
201
connect( _emulation , SIGNAL(programUsesMouseChanged(bool)) , widget ,
202
SLOT(setUsesMouse(bool)) );
204
widget->setUsesMouse( _emulation->programUsesMouse() );
206
widget->setScreenWindow(_emulation->createWindow());
209
//connect view signals and slots
210
QObject::connect( widget ,SIGNAL(changedContentSizeSignal(int,int)),this,
211
SLOT(onViewSizeChange(int,int)));
213
QObject::connect( widget ,SIGNAL(destroyed(QObject *)) , this ,
214
SLOT(viewDestroyed(QObject *)) );
216
QObject::connect(this, SIGNAL(finished()), widget, SLOT(close()));
220
void Session::viewDestroyed(QObject * view)
222
TerminalDisplay * display = (TerminalDisplay *)view;
224
Q_ASSERT( _views.contains(display) );
229
void Session::removeView(TerminalDisplay * widget)
231
_views.removeAll(widget);
233
disconnect(widget,0,this,0);
235
if ( _emulation != 0 ) {
237
// - key presses signals from widget
238
// - mouse activity signals from widget
239
// - string sending signals from widget
241
// ... and any other signals connected in addView()
242
disconnect( widget, 0, _emulation, 0);
244
// disconnect state change signals emitted by emulation
245
disconnect( _emulation , 0 , widget , 0);
248
// close the session automatically when the last view is removed
249
if ( _views.count() == 0 ) {
256
//check that everything is in place to run the session
257
if (_program.isEmpty()) {
258
qDebug() << "Session::run() - program to run not set.";
261
qDebug() << "Session::run() - program:" << _program;
264
if (_arguments.isEmpty()) {
265
qDebug() << "Session::run() - no command line arguments specified.";
268
qDebug() << "Session::run() - arguments:" << _arguments;
271
// Upon a KPty error, there is no description on what that error was...
272
// Check to see if the given program is executable.
275
/* ok iam not exactly sure where _program comes from - however it was set to /bin/bash on my system
276
* Thats bad for BSD as its /usr/local/bin/bash there - its also bad for arch as its /usr/bin/bash there too!
277
* So i added a check to see if /bin/bash exists - if no then we use $SHELL - if that does not exist either, we fall back to /bin/sh
278
* As far as i know /bin/sh exists on every unix system.. You could also just put some ifdef __FREEBSD__ here but i think these 2 filechecks are worth
279
* their computing time on any system - especially with the problem on arch linux beeing there too.
281
QString exec = QFile::encodeName(_program);
282
// if 'exec' is not specified, fall back to default shell. if that
283
// is not set then fall back to /bin/sh
285
// here we expect full path. If there is no fullpath let's expect it's
286
// a custom shell (eg. python, etc.) available in the PATH.
287
if (exec.startsWith("/"))
290
if ( exec.isEmpty() || !excheck.exists() ) {
291
exec = getenv("SHELL");
293
excheck.setFileName(exec);
295
if ( exec.isEmpty() || !excheck.exists() ) {
300
// _arguments sometimes contain ("") so isEmpty()
301
// or count() does not work as expected...
302
QString argsTmp(_arguments.join(" ").trimmed());
303
QStringList arguments;
305
if (argsTmp.length())
306
arguments << _arguments;
308
QString cwd = QDir::currentPath();
309
if (!_initialWorkingDir.isEmpty()) {
310
_shellProcess->setWorkingDirectory(_initialWorkingDir);
312
_shellProcess->setWorkingDirectory(cwd);
315
_shellProcess->setFlowControlEnabled(_flowControl);
316
_shellProcess->setErase(_emulation->eraseChar());
318
// this is not strictly accurate use of the COLORFGBG variable. This does not
319
// tell the terminal exactly which colors are being used, but instead approximates
320
// the color scheme as "black on white" or "white on black" depending on whether
321
// the background color is deemed dark or not
322
QString backgroundColorHint = _hasDarkBackground ? "COLORFGBG=15;0" : "COLORFGBG=0;15";
324
/* if we do all the checking if this shell exists then we use it ;)
325
* Dont know about the arguments though.. maybe youll need some more checking im not sure
326
* However this works on Arch and FreeBSD now.
328
int result = _shellProcess->start(exec,
330
_environment << backgroundColorHint,
335
qDebug() << "CRASHED! result: " << result;
339
_shellProcess->setWriteable(false); // We are reachable via kwrited.
340
qDebug() << "started!";
344
void Session::setUserTitle( int what, const QString & caption )
346
//set to true if anything is actually changed (eg. old _nameTitle != new _nameTitle )
347
bool modified = false;
349
// (btw: what=0 changes _userTitle and icon, what=1 only icon, what=2 only _nameTitle
350
if ((what == 0) || (what == 2)) {
351
if ( _userTitle != caption ) {
352
_userTitle = caption;
357
if ((what == 0) || (what == 1)) {
358
if ( _iconText != caption ) {
365
QString colorString = caption.section(';',0,0);
366
qDebug() << __FILE__ << __LINE__ << ": setting background colour to " << colorString;
367
QColor backColor = QColor(colorString);
368
if (backColor.isValid()) { // change color via \033]11;Color\007
369
if (backColor != _modifiedBackground) {
370
_modifiedBackground = backColor;
372
// bail out here until the code to connect the terminal display
373
// to the changeBackgroundColor() signal has been written
374
// and tested - just so we don't forget to do this.
377
emit changeBackgroundColorRequest(backColor);
383
if ( _nameTitle != caption ) {
384
setTitle(Session::NameRole,caption);
391
cwd=cwd.replace( QRegExp("^~"), QDir::homePath() );
392
emit openUrlRequest(cwd);
395
// change icon via \033]32;Icon\007
397
if ( _iconName != caption ) {
405
emit profileChangeCommandReceived(caption);
414
QString Session::userTitle() const
418
void Session::setTabTitleFormat(TabTitleContext context , const QString & format)
420
if ( context == LocalTabTitle ) {
421
_localTabTitleFormat = format;
422
} else if ( context == RemoteTabTitle ) {
423
_remoteTabTitleFormat = format;
426
QString Session::tabTitleFormat(TabTitleContext context) const
428
if ( context == LocalTabTitle ) {
429
return _localTabTitleFormat;
430
} else if ( context == RemoteTabTitle ) {
431
return _remoteTabTitleFormat;
437
void Session::monitorTimerDone()
439
//FIXME: The idea here is that the notification popup will appear to tell the user than output from
440
//the terminal has stopped and the popup will disappear when the user activates the session.
442
//This breaks with the addition of multiple views of a session. The popup should disappear
443
//when any of the views of the session becomes active
446
//FIXME: Make message text for this notification and the activity notification more descriptive.
447
if (_monitorSilence) {
449
emit stateChanged(NOTIFYSILENCE);
451
emit stateChanged(NOTIFYNORMAL);
454
_notifiedActivity=false;
457
void Session::activityStateSet(int state)
459
if (state==NOTIFYBELL) {
461
s.sprintf("Bell in session '%s'",_nameTitle.toUtf8().data());
463
emit bellRequest( s );
464
} else if (state==NOTIFYACTIVITY) {
465
if (_monitorSilence) {
466
_monitorTimer->start(_silenceSeconds*1000);
469
if ( _monitorActivity ) {
470
//FIXME: See comments in Session::monitorTimerDone()
471
if (!_notifiedActivity) {
473
_notifiedActivity=true;
478
if ( state==NOTIFYACTIVITY && !_monitorActivity ) {
479
state = NOTIFYNORMAL;
481
if ( state==NOTIFYSILENCE && !_monitorSilence ) {
482
state = NOTIFYNORMAL;
485
emit stateChanged(state);
488
void Session::onViewSizeChange(int /*height*/, int /*width*/)
490
updateTerminalSize();
492
void Session::onEmulationSizeChange(int lines , int columns)
494
setSize( QSize(lines,columns) );
497
void Session::updateTerminalSize()
499
QListIterator<TerminalDisplay *> viewIter(_views);
504
// minimum number of lines and columns that views require for
505
// their size to be taken into consideration ( to avoid problems
506
// with new view widgets which haven't yet been set to their correct size )
507
const int VIEW_LINES_THRESHOLD = 2;
508
const int VIEW_COLUMNS_THRESHOLD = 2;
510
//select largest number of lines and columns that will fit in all visible views
511
while ( viewIter.hasNext() ) {
512
TerminalDisplay * view = viewIter.next();
513
if ( view->isHidden() == false &&
514
view->lines() >= VIEW_LINES_THRESHOLD &&
515
view->columns() >= VIEW_COLUMNS_THRESHOLD ) {
516
minLines = (minLines == -1) ? view->lines() : qMin( minLines , view->lines() );
517
minColumns = (minColumns == -1) ? view->columns() : qMin( minColumns , view->columns() );
521
// backend emulation must have a _terminal of at least 1 column x 1 line in size
522
if ( minLines > 0 && minColumns > 0 ) {
523
_emulation->setImageSize( minLines , minColumns );
524
_shellProcess->setWindowSize( minLines , minColumns );
528
void Session::refresh()
530
// attempt to get the shell process to redraw the display
532
// this requires the program running in the shell
533
// to cooperate by sending an update in response to
534
// a window size change
536
// the window size is changed twice, first made slightly larger and then
537
// resized back to its normal size so that there is actually a change
538
// in the window size (some shells do nothing if the
539
// new and old sizes are the same)
541
// if there is a more 'correct' way to do this, please
542
// send an email with method or patches to konsole-devel@kde.org
544
const QSize existingSize = _shellProcess->windowSize();
545
_shellProcess->setWindowSize(existingSize.height(),existingSize.width()+1);
546
_shellProcess->setWindowSize(existingSize.height(),existingSize.width());
549
bool Session::sendSignal(int signal)
551
int result = ::kill(_shellProcess->pid(),signal);
555
_shellProcess->waitForFinished();
562
void Session::close()
566
if (!_shellProcess->isRunning() || !sendSignal(SIGHUP)) {
568
QTimer::singleShot(1, this, SIGNAL(finished()));
572
void Session::sendText(const QString & text) const
574
_emulation->sendText(text);
580
delete _shellProcess;
581
// delete _zmodemProc;
584
void Session::setProfileKey(const QString & key)
587
emit profileChanged(key);
589
QString Session::profileKey() const
594
void Session::done(int exitStatus)
597
_userTitle = ("This session is done. Finished");
603
if (!_wantedClose || exitStatus != 0) {
605
if (_shellProcess->exitStatus() == QProcess::NormalExit) {
606
message.sprintf("Session '%s' exited with status %d.",
607
_nameTitle.toUtf8().data(), exitStatus);
609
message.sprintf("Session '%s' crashed.",
610
_nameTitle.toUtf8().data());
614
if ( !_wantedClose && _shellProcess->exitStatus() != QProcess::NormalExit )
615
message.sprintf("Session '%s' exited unexpectedly.",
616
_nameTitle.toUtf8().data());
622
Emulation * Session::emulation() const
627
QString Session::keyBindings() const
629
return _emulation->keyBindings();
632
QStringList Session::environment() const
637
void Session::setEnvironment(const QStringList & environment)
639
_environment = environment;
642
int Session::sessionId() const
647
void Session::setKeyBindings(const QString & id)
649
_emulation->setKeyBindings(id);
652
void Session::setTitle(TitleRole role , const QString & newTitle)
654
if ( title(role) != newTitle ) {
655
if ( role == NameRole ) {
656
_nameTitle = newTitle;
657
} else if ( role == DisplayedTitleRole ) {
658
_displayTitle = newTitle;
665
QString Session::title(TitleRole role) const
667
if ( role == NameRole ) {
669
} else if ( role == DisplayedTitleRole ) {
670
return _displayTitle;
676
void Session::setIconName(const QString & iconName)
678
if ( iconName != _iconName ) {
679
_iconName = iconName;
684
void Session::setIconText(const QString & iconText)
686
_iconText = iconText;
687
//kDebug(1211)<<"Session setIconText " << _iconText;
690
QString Session::iconName() const
695
QString Session::iconText() const
700
void Session::setHistoryType(const HistoryType & hType)
702
_emulation->setHistory(hType);
705
const HistoryType & Session::historyType() const
707
return _emulation->history();
710
void Session::clearHistory()
712
_emulation->clearHistory();
715
QStringList Session::arguments() const
720
QString Session::program() const
726
bool Session::isMonitorActivity() const
728
return _monitorActivity;
731
bool Session::isMonitorSilence() const
733
return _monitorSilence;
736
void Session::setMonitorActivity(bool _monitor)
738
_monitorActivity=_monitor;
739
_notifiedActivity=false;
741
activityStateSet(NOTIFYNORMAL);
744
void Session::setMonitorSilence(bool _monitor)
746
if (_monitorSilence==_monitor) {
750
_monitorSilence=_monitor;
751
if (_monitorSilence) {
752
_monitorTimer->start(_silenceSeconds*1000);
754
_monitorTimer->stop();
757
activityStateSet(NOTIFYNORMAL);
760
void Session::setMonitorSilenceSeconds(int seconds)
762
_silenceSeconds=seconds;
763
if (_monitorSilence) {
764
_monitorTimer->start(_silenceSeconds*1000);
768
void Session::setAddToUtmp(bool set)
773
void Session::setFlowControlEnabled(bool enabled)
775
if (_flowControl == enabled) {
779
_flowControl = enabled;
782
_shellProcess->setFlowControlEnabled(_flowControl);
785
emit flowControlEnabledChanged(enabled);
787
bool Session::flowControlEnabled() const
791
//void Session::fireZModemDetected()
795
// QTimer::singleShot(10, this, SIGNAL(zmodemDetected()));
796
// _zmodemBusy = true;
800
//void Session::cancelZModem()
802
// _shellProcess->sendData("\030\030\030\030", 4); // Abort
803
// _zmodemBusy = false;
806
//void Session::startZModem(const QString &zmodem, const QString &dir, const QStringList &list)
808
// _zmodemBusy = true;
809
// _zmodemProc = new KProcess();
810
// _zmodemProc->setOutputChannelMode( KProcess::SeparateChannels );
812
// *_zmodemProc << zmodem << "-v" << list;
814
// if (!dir.isEmpty())
815
// _zmodemProc->setWorkingDirectory(dir);
817
// _zmodemProc->start();
819
// connect(_zmodemProc,SIGNAL (readyReadStandardOutput()),
820
// this, SLOT(zmodemReadAndSendBlock()));
821
// connect(_zmodemProc,SIGNAL (readyReadStandardError()),
822
// this, SLOT(zmodemReadStatus()));
823
// connect(_zmodemProc,SIGNAL (finished(int,QProcess::ExitStatus)),
824
// this, SLOT(zmodemFinished()));
826
// disconnect( _shellProcess,SIGNAL(block_in(const char*,int)), this, SLOT(onReceiveBlock(const char*,int)) );
827
// connect( _shellProcess,SIGNAL(block_in(const char*,int)), this, SLOT(zmodemRcvBlock(const char*,int)) );
829
// _zmodemProgress = new ZModemDialog(QApplication::activeWindow(), false,
830
// i18n("ZModem Progress"));
832
// connect(_zmodemProgress, SIGNAL(user1Clicked()),
833
// this, SLOT(zmodemDone()));
835
// _zmodemProgress->show();
838
/*void Session::zmodemReadAndSendBlock()
840
_zmodemProc->setReadChannel( QProcess::StandardOutput );
841
QByteArray data = _zmodemProc->readAll();
843
if ( data.count() == 0 )
846
_shellProcess->sendData(data.constData(),data.count());
850
void Session::zmodemReadStatus()
852
_zmodemProc->setReadChannel( QProcess::StandardError );
853
QByteArray msg = _zmodemProc->readAll();
854
while(!msg.isEmpty())
856
int i = msg.indexOf('\015');
857
int j = msg.indexOf('\012');
859
if ((i != -1) && ((j == -1) || (i < j)))
874
_zmodemProgress->addProgressText(QString::fromLocal8Bit(txt));
879
void Session::zmodemRcvBlock(const char *data, int len)
881
QByteArray ba( data, len );
883
_zmodemProc->write( ba );
887
void Session::zmodemFinished()
895
disconnect( _shellProcess,SIGNAL(block_in(const char*,int)), this ,SLOT(zmodemRcvBlock(const char*,int)) );
896
connect( _shellProcess,SIGNAL(block_in(const char*,int)), this, SLOT(onReceiveBlock(const char*,int)) );
898
_shellProcess->sendData("\030\030\030\030", 4); // Abort
899
_shellProcess->sendData("\001\013\n", 3); // Try to get prompt back
900
_zmodemProgress->transferDone();
904
void Session::onReceiveBlock( const char * buf, int len )
906
_emulation->receiveData( buf, len );
907
emit receivedData( QString::fromLatin1( buf, len ) );
910
QSize Session::size()
912
return _emulation->imageSize();
915
void Session::setSize(const QSize & size)
917
if ((size.width() <= 1) || (size.height() <= 1)) {
921
emit resizeRequest(size);
923
int Session::foregroundProcessId() const
925
return _shellProcess->foregroundProcessGroup();
927
int Session::processId() const
929
return _shellProcess->pid();
932
SessionGroup::SessionGroup()
936
SessionGroup::~SessionGroup()
941
int SessionGroup::masterMode() const
945
QList<Session *> SessionGroup::sessions() const
947
return _sessions.keys();
949
bool SessionGroup::masterStatus(Session * session) const
951
return _sessions[session];
954
void SessionGroup::addSession(Session * session)
956
_sessions.insert(session,false);
958
QListIterator<Session *> masterIter(masters());
960
while ( masterIter.hasNext() ) {
961
connectPair(masterIter.next(),session);
964
void SessionGroup::removeSession(Session * session)
966
setMasterStatus(session,false);
968
QListIterator<Session *> masterIter(masters());
970
while ( masterIter.hasNext() ) {
971
disconnectPair(masterIter.next(),session);
974
_sessions.remove(session);
976
void SessionGroup::setMasterMode(int mode)
983
QList<Session *> SessionGroup::masters() const
985
return _sessions.keys(true);
987
void SessionGroup::connectAll(bool connect)
989
QListIterator<Session *> masterIter(masters());
991
while ( masterIter.hasNext() ) {
992
Session * master = masterIter.next();
994
QListIterator<Session *> otherIter(_sessions.keys());
995
while ( otherIter.hasNext() ) {
996
Session * other = otherIter.next();
998
if ( other != master ) {
1000
connectPair(master,other);
1002
disconnectPair(master,other);
1008
void SessionGroup::setMasterStatus(Session * session, bool master)
1010
bool wasMaster = _sessions[session];
1011
_sessions[session] = master;
1013
if ((!wasMaster && !master)
1014
|| (wasMaster && master)) {
1018
QListIterator<Session *> iter(_sessions.keys());
1019
while (iter.hasNext()) {
1020
Session * other = iter.next();
1022
if (other != session) {
1024
connectPair(session, other);
1026
disconnectPair(session, other);
1032
void SessionGroup::connectPair(Session * master , Session * other)
1034
// qDebug() << k_funcinfo;
1036
if ( _masterMode & CopyInputToAll ) {
1037
qDebug() << "Connection session " << master->nameTitle() << "to" << other->nameTitle();
1039
connect( master->emulation() , SIGNAL(sendData(const char *,int)) , other->emulation() ,
1040
SLOT(sendString(const char *,int)) );
1043
void SessionGroup::disconnectPair(Session * master , Session * other)
1045
// qDebug() << k_funcinfo;
1047
if ( _masterMode & CopyInputToAll ) {
1048
qDebug() << "Disconnecting session " << master->nameTitle() << "from" << other->nameTitle();
1050
disconnect( master->emulation() , SIGNAL(sendData(const char *,int)) , other->emulation() ,
1051
SLOT(sendString(const char *,int)) );
1055
//#include "moc_Session.cpp"