Mercurial > octave-nkf
comparison gui/src/terminal/Session.cpp @ 13552:324adf6109e7
Isolated and eliminated class ProcessInfo.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Fri, 29 Jul 2011 18:53:35 +0200 |
parents | c70511cf64ee |
children | dfbc6a12c6fb |
comparison
equal
deleted
inserted
replaced
13551:ad905cd33563 | 13552:324adf6109e7 |
---|---|
39 #include <QtCore/QDate> | 39 #include <QtCore/QDate> |
40 | 40 |
41 #include "kprocess.h" | 41 #include "kprocess.h" |
42 #include "kptydevice.h" | 42 #include "kptydevice.h" |
43 | 43 |
44 #include "ProcessInfo.h" | 44 //#include "ProcessInfo.h" |
45 #include "Pty.h" | 45 #include "Pty.h" |
46 #include "TerminalDisplay.h" | 46 #include "TerminalDisplay.h" |
47 #include "ShellCommand.h" | 47 #include "ShellCommand.h" |
48 #include "Vt102Emulation.h" | 48 #include "Vt102Emulation.h" |
49 | 49 |
98 Session::Session (QObject * parent): | 98 Session::Session (QObject * parent): |
99 QObject (parent), _shellProcess (0), _emulation (0), _monitorActivity (false), | 99 QObject (parent), _shellProcess (0), _emulation (0), _monitorActivity (false), |
100 _monitorSilence (false), _notifiedActivity (false), _autoClose (true), | 100 _monitorSilence (false), _notifiedActivity (false), _autoClose (true), |
101 _wantedClose (false), _silenceSeconds (10), _addToUtmp (true), | 101 _wantedClose (false), _silenceSeconds (10), _addToUtmp (true), |
102 _flowControl (true), _fullScripting (false), _sessionId (0), | 102 _flowControl (true), _fullScripting (false), _sessionId (0), |
103 _sessionProcessInfo (0), _foregroundProcessInfo (0), _foregroundPid (0) | 103 /*_sessionProcessInfo (0), _foregroundProcessInfo (0),*/ _foregroundPid (0) |
104 //, _zmodemBusy(false) | 104 //, _zmodemBusy(false) |
105 //, _zmodemProc(0) | 105 //, _zmodemProc(0) |
106 //, _zmodemProgress(0) | 106 //, _zmodemProgress(0) |
107 , _hasDarkBackground (false) | 107 , _hasDarkBackground (false) |
108 { | 108 { |
161 //connect teletype to emulation backend | 161 //connect teletype to emulation backend |
162 connect (_shellProcess, SIGNAL (receivedData (const char *, int)), this, | 162 connect (_shellProcess, SIGNAL (receivedData (const char *, int)), this, |
163 SLOT (onReceiveBlock (const char *, int))); | 163 SLOT (onReceiveBlock (const char *, int))); |
164 connect (_emulation, SIGNAL (sendData (const char *, int)), _shellProcess, | 164 connect (_emulation, SIGNAL (sendData (const char *, int)), _shellProcess, |
165 SLOT (sendData (const char *, int))); | 165 SLOT (sendData (const char *, int))); |
166 connect (_emulation, SIGNAL (lockPtyRequest (bool)), _shellProcess, | |
167 SLOT (lockPty (bool))); | |
168 connect (_emulation, SIGNAL (useUtf8Request (bool)), _shellProcess, | 166 connect (_emulation, SIGNAL (useUtf8Request (bool)), _shellProcess, |
169 SLOT (setUtf8Mode (bool))); | 167 SLOT (setUtf8Mode (bool))); |
170 connect (_shellProcess, SIGNAL (finished (int, QProcess::ExitStatus)), this, | 168 connect (_shellProcess, SIGNAL (finished (int, QProcess::ExitStatus)), this, |
171 SLOT (done (int))); | 169 SLOT (done (int))); |
172 connect (_emulation, SIGNAL (imageSizeChanged (int, int)), this, | 170 connect (_emulation, SIGNAL (imageSizeChanged (int, int)), this, |
262 Session::setArguments (const QStringList & arguments) | 260 Session::setArguments (const QStringList & arguments) |
263 { | 261 { |
264 _arguments = ShellCommand::expand (arguments); | 262 _arguments = ShellCommand::expand (arguments); |
265 } | 263 } |
266 | 264 |
265 /* | |
267 QString | 266 QString |
268 Session::currentWorkingDirectory () | 267 Session::currentWorkingDirectory () |
269 { | 268 { |
270 // only returned cached value | 269 // only returned cached value |
271 if (_currentWorkingDir.isEmpty ()) | 270 //if (_currentWorkingDir.isEmpty ()) |
272 updateWorkingDirectory (); | 271 // updateWorkingDirectory (); |
273 return _currentWorkingDir; | 272 return _currentWorkingDir; |
274 } | 273 } |
275 | 274 */ |
275 /* | |
276 ProcessInfo * | 276 ProcessInfo * |
277 Session::updateWorkingDirectory () | 277 Session::updateWorkingDirectory () |
278 { | 278 { |
279 ProcessInfo *process = getProcessInfo (); | 279 ProcessInfo *process = getProcessInfo (); |
280 _currentWorkingDir = process->validCurrentDir (); | 280 _currentWorkingDir = process->validCurrentDir (); |
281 return process; | 281 return process; |
282 } | 282 }*/ |
283 | 283 |
284 QList < TerminalDisplay * >Session::views () const | 284 QList < TerminalDisplay * >Session::views () const |
285 { | 285 { |
286 return _views; | 286 return _views; |
287 } | 287 } |
816 _emulation->sendMouseEvent (buttons, column, line, eventType); | 816 _emulation->sendMouseEvent (buttons, column, line, eventType); |
817 } | 817 } |
818 | 818 |
819 Session::~Session () | 819 Session::~Session () |
820 { | 820 { |
821 if (_foregroundProcessInfo) | 821 //if (_foregroundProcessInfo) |
822 delete _foregroundProcessInfo; | 822 // delete _foregroundProcessInfo; |
823 if (_sessionProcessInfo) | 823 //if (_sessionProcessInfo) |
824 delete _sessionProcessInfo; | 824 // delete _sessionProcessInfo; |
825 delete _emulation; | 825 delete _emulation; |
826 delete _shellProcess; | 826 delete _shellProcess; |
827 //delete _zmodemProc; | 827 //delete _zmodemProc; |
828 } | 828 } |
829 | 829 |
926 return _displayTitle; | 926 return _displayTitle; |
927 else | 927 else |
928 return QString (); | 928 return QString (); |
929 } | 929 } |
930 | 930 |
931 /* | |
931 ProcessInfo * | 932 ProcessInfo * |
932 Session::getProcessInfo () | 933 Session::getProcessInfo () |
933 { | 934 { |
934 ProcessInfo *process; | 935 ProcessInfo *process; |
935 | 936 |
940 updateSessionProcessInfo (); | 941 updateSessionProcessInfo (); |
941 process = _sessionProcessInfo; | 942 process = _sessionProcessInfo; |
942 } | 943 } |
943 | 944 |
944 return process; | 945 return process; |
945 } | 946 }*/ |
947 | |
946 | 948 |
947 void | 949 void |
948 Session::updateSessionProcessInfo () | 950 Session::updateSessionProcessInfo () |
949 { | 951 { |
952 /* | |
950 Q_ASSERT (_shellProcess); | 953 Q_ASSERT (_shellProcess); |
951 if (!_sessionProcessInfo) | 954 if (!_sessionProcessInfo) |
952 { | 955 { |
953 _sessionProcessInfo = ProcessInfo::newInstance (processId ()); | 956 _sessionProcessInfo = ProcessInfo::newInstance (processId ()); |
954 _sessionProcessInfo->setUserHomeDir (); | 957 _sessionProcessInfo->setUserHomeDir (); |
955 } | 958 } |
956 _sessionProcessInfo->update (); | 959 _sessionProcessInfo->update ();*/ |
957 } | 960 } |
958 | 961 |
959 bool | 962 bool |
960 Session::updateForegroundProcessInfo () | 963 Session::updateForegroundProcessInfo () |
961 { | 964 { |
965 /* | |
962 bool valid = (_foregroundProcessInfo != 0); | 966 bool valid = (_foregroundProcessInfo != 0); |
963 | 967 |
964 // has foreground process changed? | 968 // has foreground process changed? |
965 Q_ASSERT (_shellProcess); | 969 Q_ASSERT (_shellProcess); |
966 int pid = _shellProcess->foregroundProcessGroup (); | 970 int pid = _shellProcess->foregroundProcessGroup (); |
977 { | 981 { |
978 _foregroundProcessInfo->update (); | 982 _foregroundProcessInfo->update (); |
979 valid = _foregroundProcessInfo->isValid (); | 983 valid = _foregroundProcessInfo->isValid (); |
980 } | 984 } |
981 | 985 |
982 return valid; | 986 return valid;*/ |
987 return true; | |
983 } | 988 } |
984 | 989 |
985 bool | 990 bool |
986 Session::isRemote () | 991 Session::isRemote () |
987 { | 992 {/* |
988 ProcessInfo *process = getProcessInfo (); | 993 ProcessInfo *process = getProcessInfo (); |
989 | 994 |
990 bool ok = false; | 995 bool ok = false; |
991 return (process->name (&ok) == "ssh" && ok); | 996 return (process->name (&ok) == "ssh" && ok); |
997 */ | |
998 return false; | |
992 } | 999 } |
993 | 1000 |
994 QString | 1001 QString |
995 Session::getDynamicTitle () | 1002 Session::getDynamicTitle () |
996 { | 1003 {/* |
997 // update current directory from process | 1004 // update current directory from process |
998 ProcessInfo *process = updateWorkingDirectory (); | 1005 ProcessInfo *process = updateWorkingDirectory (); |
999 | 1006 |
1000 // format tab titles using process info | 1007 // format tab titles using process info |
1001 bool ok = false; | 1008 bool ok = false; |
1006 title = sshInfo.format (tabTitleFormat (Session::RemoteTabTitle)); | 1013 title = sshInfo.format (tabTitleFormat (Session::RemoteTabTitle)); |
1007 } | 1014 } |
1008 else | 1015 else |
1009 title = process->format (tabTitleFormat (Session::LocalTabTitle)); | 1016 title = process->format (tabTitleFormat (Session::LocalTabTitle)); |
1010 | 1017 |
1011 return title; | 1018 return title;*/ |
1019 return ""; | |
1012 } | 1020 } |
1013 | 1021 |
1014 void | 1022 void |
1015 Session::setIconName (const QString & iconName) | 1023 Session::setIconName (const QString & iconName) |
1016 { | 1024 { |
1226 default: | 1234 default: |
1227 return QString (); | 1235 return QString (); |
1228 } | 1236 } |
1229 } | 1237 } |
1230 | 1238 |
1239 /* | |
1231 int | 1240 int |
1232 Session::foregroundProcessId () | 1241 Session::foregroundProcessId () |
1233 { | 1242 { |
1234 int pid; | 1243 int pid; |
1235 | 1244 |
1237 pid = getProcessInfo ()->pid (&ok); | 1246 pid = getProcessInfo ()->pid (&ok); |
1238 if (!ok) | 1247 if (!ok) |
1239 pid = -1; | 1248 pid = -1; |
1240 | 1249 |
1241 return pid; | 1250 return pid; |
1242 } | 1251 }*/ |
1243 | 1252 |
1244 bool | 1253 bool |
1245 Session::isForegroundProcessActive () | 1254 Session::isForegroundProcessActive () |
1246 { | 1255 { |
1247 // foreground process info is always updated after this | 1256 // foreground process info is always updated after this |
1248 return updateForegroundProcessInfo () && (processId () != _foregroundPid); | 1257 return updateForegroundProcessInfo () && (processId () != _foregroundPid); |
1249 } | 1258 } |
1250 | 1259 |
1260 /* | |
1251 QString | 1261 QString |
1252 Session::foregroundProcessName () | 1262 Session::foregroundProcessName () |
1253 { | 1263 { |
1254 QString name; | 1264 QString name; |
1255 | 1265 |
1260 if (!ok) | 1270 if (!ok) |
1261 name.clear (); | 1271 name.clear (); |
1262 } | 1272 } |
1263 | 1273 |
1264 return name; | 1274 return name; |
1265 } | 1275 }*/ |
1266 | 1276 |
1267 SessionGroup::SessionGroup (QObject * parent):QObject (parent), _masterMode (0) | 1277 SessionGroup::SessionGroup (QObject * parent):QObject (parent), _masterMode (0) |
1268 { | 1278 { |
1269 } | 1279 } |
1270 | 1280 |