[45157b3] | 1 | /* |
---|
| 2 | This file is part of Konsole, an X terminal. |
---|
| 3 | |
---|
| 4 | Copyright (C) 2007 by Robert Knight <robertknight@gmail.com> |
---|
| 5 | Copyright (C) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> |
---|
| 6 | |
---|
| 7 | Rewritten for QT4 by e_k <e_k at users.sourceforge.net>, Copyright (C)2008 |
---|
| 8 | |
---|
| 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. |
---|
| 13 | |
---|
| 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. |
---|
| 18 | |
---|
| 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 |
---|
| 22 | 02110-1301 USA. |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | #ifndef SESSION_H |
---|
| 26 | #define SESSION_H |
---|
| 27 | |
---|
| 28 | // Qt |
---|
| 29 | #include <QtCore/QStringList> |
---|
| 30 | #include <QtCore> |
---|
| 31 | #include <QWidget> |
---|
| 32 | |
---|
| 33 | // Konsole |
---|
| 34 | #include "History.h" |
---|
| 35 | |
---|
| 36 | class KProcess; |
---|
| 37 | |
---|
| 38 | namespace Konsole |
---|
| 39 | { |
---|
| 40 | |
---|
| 41 | class Emulation; |
---|
| 42 | class Pty; |
---|
| 43 | class TerminalDisplay; |
---|
| 44 | //class ZModemDialog; |
---|
| 45 | |
---|
| 46 | /** |
---|
| 47 | * Represents a terminal session consisting of a pseudo-teletype and a terminal emulation. |
---|
| 48 | * The pseudo-teletype (or PTY) handles I/O between the terminal process and Konsole. |
---|
| 49 | * The terminal emulation ( Emulation and subclasses ) processes the output stream from the |
---|
| 50 | * PTY and produces a character image which is then shown on views connected to the session. |
---|
| 51 | * |
---|
| 52 | * Each Session can be connected to one or more views by using the addView() method. |
---|
| 53 | * The attached views can then display output from the program running in the terminal |
---|
| 54 | * or send input to the program in the terminal in the form of keypresses and mouse |
---|
| 55 | * activity. |
---|
| 56 | */ |
---|
| 57 | class Session : public QObject |
---|
| 58 | { |
---|
| 59 | Q_OBJECT |
---|
| 60 | |
---|
| 61 | public: |
---|
| 62 | Q_PROPERTY(QString name READ nameTitle) |
---|
| 63 | Q_PROPERTY(int processId READ processId) |
---|
| 64 | Q_PROPERTY(QString keyBindings READ keyBindings WRITE setKeyBindings) |
---|
| 65 | Q_PROPERTY(QSize size READ size WRITE setSize) |
---|
| 66 | |
---|
| 67 | /** |
---|
| 68 | * Constructs a new session. |
---|
| 69 | * |
---|
| 70 | * To start the terminal process, call the run() method, |
---|
| 71 | * after specifying the program and arguments |
---|
| 72 | * using setProgram() and setArguments() |
---|
| 73 | * |
---|
| 74 | * If no program or arguments are specified explicitly, the Session |
---|
| 75 | * falls back to using the program specified in the SHELL environment |
---|
| 76 | * variable. |
---|
| 77 | */ |
---|
| 78 | Session(); |
---|
| 79 | ~Session(); |
---|
| 80 | |
---|
| 81 | /** |
---|
| 82 | * Returns true if the session is currently running. This will be true |
---|
| 83 | * after run() has been called successfully. |
---|
| 84 | */ |
---|
| 85 | bool isRunning() const; |
---|
| 86 | |
---|
| 87 | /** |
---|
| 88 | * Sets the profile associated with this session. |
---|
| 89 | * |
---|
| 90 | * @param profileKey A key which can be used to obtain the current |
---|
| 91 | * profile settings from the SessionManager |
---|
| 92 | */ |
---|
| 93 | void setProfileKey(const QString& profileKey); |
---|
| 94 | /** |
---|
| 95 | * Returns the profile key associated with this session. |
---|
| 96 | * This can be passed to the SessionManager to obtain the current |
---|
| 97 | * profile settings. |
---|
| 98 | */ |
---|
| 99 | QString profileKey() const; |
---|
| 100 | |
---|
| 101 | /** |
---|
| 102 | * Adds a new view for this session. |
---|
| 103 | * |
---|
| 104 | * The viewing widget will display the output from the terminal and |
---|
| 105 | * input from the viewing widget (key presses, mouse activity etc.) |
---|
| 106 | * will be sent to the terminal. |
---|
| 107 | * |
---|
| 108 | * Views can be removed using removeView(). The session is automatically |
---|
| 109 | * closed when the last view is removed. |
---|
| 110 | */ |
---|
| 111 | void addView(TerminalDisplay* widget); |
---|
| 112 | /** |
---|
| 113 | * Removes a view from this session. When the last view is removed, |
---|
| 114 | * the session will be closed automatically. |
---|
| 115 | * |
---|
| 116 | * @p widget will no longer display output from or send input |
---|
| 117 | * to the terminal |
---|
| 118 | */ |
---|
| 119 | void removeView(TerminalDisplay* widget); |
---|
| 120 | |
---|
| 121 | /** |
---|
| 122 | * Returns the views connected to this session |
---|
| 123 | */ |
---|
| 124 | QList<TerminalDisplay*> views() const; |
---|
| 125 | |
---|
| 126 | /** |
---|
| 127 | * Returns the terminal emulation instance being used to encode / decode |
---|
| 128 | * characters to / from the process. |
---|
| 129 | */ |
---|
| 130 | Emulation* emulation() const; |
---|
| 131 | |
---|
| 132 | /** |
---|
| 133 | * Returns the environment of this session as a list of strings like |
---|
| 134 | * VARIABLE=VALUE |
---|
| 135 | */ |
---|
| 136 | QStringList environment() const; |
---|
| 137 | /** |
---|
| 138 | * Sets the environment for this session. |
---|
| 139 | * @p environment should be a list of strings like |
---|
| 140 | * VARIABLE=VALUE |
---|
| 141 | */ |
---|
| 142 | void setEnvironment(const QStringList& environment); |
---|
| 143 | |
---|
| 144 | /** Returns the unique ID for this session. */ |
---|
| 145 | int sessionId() const; |
---|
| 146 | |
---|
| 147 | /** |
---|
| 148 | * Return the session title set by the user (ie. the program running |
---|
| 149 | * in the terminal), or an empty string if the user has not set a custom title |
---|
| 150 | */ |
---|
| 151 | QString userTitle() const; |
---|
| 152 | |
---|
| 153 | /** |
---|
| 154 | * This enum describes the contexts for which separate |
---|
| 155 | * tab title formats may be specified. |
---|
| 156 | */ |
---|
| 157 | enum TabTitleContext |
---|
| 158 | { |
---|
| 159 | /** Default tab title format */ |
---|
| 160 | LocalTabTitle, |
---|
| 161 | /** |
---|
| 162 | * Tab title format used session currently contains |
---|
| 163 | * a connection to a remote computer (via SSH) |
---|
| 164 | */ |
---|
| 165 | RemoteTabTitle |
---|
| 166 | }; |
---|
| 167 | /** |
---|
| 168 | * Sets the format used by this session for tab titles. |
---|
| 169 | * |
---|
| 170 | * @param context The context whoose format should be set. |
---|
| 171 | * @param format The tab title format. This may be a mixture |
---|
| 172 | * of plain text and dynamic elements denoted by a '%' character |
---|
| 173 | * followed by a letter. (eg. %d for directory). The dynamic |
---|
| 174 | * elements available depend on the @p context |
---|
| 175 | */ |
---|
| 176 | void setTabTitleFormat(TabTitleContext context , const QString& format); |
---|
| 177 | /** Returns the format used by this session for tab titles. */ |
---|
| 178 | QString tabTitleFormat(TabTitleContext context) const; |
---|
| 179 | |
---|
| 180 | |
---|
| 181 | /** Returns the arguments passed to the shell process when run() is called. */ |
---|
| 182 | QStringList arguments() const; |
---|
| 183 | /** Returns the program name of the shell process started when run() is called. */ |
---|
| 184 | QString program() const; |
---|
| 185 | |
---|
| 186 | /** |
---|
| 187 | * Sets the command line arguments which the session's program will be passed when |
---|
| 188 | * run() is called. |
---|
| 189 | */ |
---|
| 190 | void setArguments(const QStringList& arguments); |
---|
| 191 | /** Sets the program to be executed when run() is called. */ |
---|
| 192 | void setProgram(const QString& program); |
---|
| 193 | |
---|
| 194 | /** Returns the session's current working directory. */ |
---|
| 195 | QString initialWorkingDirectory() { return _initialWorkingDir; } |
---|
| 196 | |
---|
| 197 | /** |
---|
| 198 | * Sets the initial working directory for the session when it is run |
---|
| 199 | * This has no effect once the session has been started. |
---|
| 200 | */ |
---|
| 201 | void setInitialWorkingDirectory( const QString& dir ); |
---|
| 202 | |
---|
| 203 | /** |
---|
| 204 | * Sets the type of history store used by this session. |
---|
| 205 | * Lines of output produced by the terminal are added |
---|
| 206 | * to the history store. The type of history store |
---|
| 207 | * used affects the number of lines which can be |
---|
| 208 | * remembered before they are lost and the storage |
---|
| 209 | * (in memory, on-disk etc.) used. |
---|
| 210 | */ |
---|
| 211 | void setHistoryType(const HistoryType& type); |
---|
| 212 | /** |
---|
| 213 | * Returns the type of history store used by this session. |
---|
| 214 | */ |
---|
| 215 | const HistoryType& historyType() const; |
---|
| 216 | /** |
---|
| 217 | * Clears the history store used by this session. |
---|
| 218 | */ |
---|
| 219 | void clearHistory(); |
---|
| 220 | |
---|
| 221 | /** |
---|
| 222 | * Enables monitoring for activity in the session. |
---|
| 223 | * This will cause notifySessionState() to be emitted |
---|
| 224 | * with the NOTIFYACTIVITY state flag when output is |
---|
| 225 | * received from the terminal. |
---|
| 226 | */ |
---|
| 227 | void setMonitorActivity(bool); |
---|
| 228 | /** Returns true if monitoring for activity is enabled. */ |
---|
| 229 | bool isMonitorActivity() const; |
---|
| 230 | |
---|
| 231 | /** |
---|
| 232 | * Enables monitoring for silence in the session. |
---|
| 233 | * This will cause notifySessionState() to be emitted |
---|
| 234 | * with the NOTIFYSILENCE state flag when output is not |
---|
| 235 | * received from the terminal for a certain period of |
---|
| 236 | * time, specified with setMonitorSilenceSeconds() |
---|
| 237 | */ |
---|
| 238 | void setMonitorSilence(bool); |
---|
| 239 | /** |
---|
| 240 | * Returns true if monitoring for inactivity (silence) |
---|
| 241 | * in the session is enabled. |
---|
| 242 | */ |
---|
| 243 | bool isMonitorSilence() const; |
---|
| 244 | /** See setMonitorSilence() */ |
---|
| 245 | void setMonitorSilenceSeconds(int seconds); |
---|
| 246 | |
---|
| 247 | /** |
---|
| 248 | * Sets the key bindings used by this session. The bindings |
---|
| 249 | * specify how input key sequences are translated into |
---|
| 250 | * the character stream which is sent to the terminal. |
---|
| 251 | * |
---|
| 252 | * @param id The name of the key bindings to use. The |
---|
| 253 | * names of available key bindings can be determined using the |
---|
| 254 | * KeyboardTranslatorManager class. |
---|
| 255 | */ |
---|
| 256 | void setKeyBindings(const QString& id); |
---|
| 257 | /** Returns the name of the key bindings used by this session. */ |
---|
| 258 | QString keyBindings() const; |
---|
| 259 | |
---|
| 260 | /** |
---|
| 261 | * This enum describes the available title roles. |
---|
| 262 | */ |
---|
| 263 | enum TitleRole |
---|
| 264 | { |
---|
| 265 | /** The name of the session. */ |
---|
| 266 | NameRole, |
---|
| 267 | /** The title of the session which is displayed in tabs etc. */ |
---|
| 268 | DisplayedTitleRole |
---|
| 269 | }; |
---|
| 270 | |
---|
| 271 | /** Sets the session's title for the specified @p role to @p title. */ |
---|
| 272 | void setTitle(TitleRole role , const QString& title); |
---|
| 273 | /** Returns the session's title for the specified @p role. */ |
---|
| 274 | QString title(TitleRole role) const; |
---|
| 275 | /** Convenience method used to read the name property. Returns title(Session::NameRole). */ |
---|
| 276 | QString nameTitle() const { return title(Session::NameRole); } |
---|
| 277 | |
---|
| 278 | /** Sets the name of the icon associated with this session. */ |
---|
| 279 | void setIconName(const QString& iconName); |
---|
| 280 | /** Returns the name of the icon associated with this session. */ |
---|
| 281 | QString iconName() const; |
---|
| 282 | |
---|
| 283 | /** Sets the text of the icon associated with this session. */ |
---|
| 284 | void setIconText(const QString& iconText); |
---|
| 285 | /** Returns the text of the icon associated with this session. */ |
---|
| 286 | QString iconText() const; |
---|
| 287 | |
---|
| 288 | /** Specifies whether a utmp entry should be created for the pty used by this session. */ |
---|
| 289 | void setAddToUtmp(bool); |
---|
| 290 | |
---|
| 291 | /** Sends the specified @p signal to the terminal process. */ |
---|
| 292 | bool sendSignal(int signal); |
---|
| 293 | |
---|
| 294 | /** |
---|
| 295 | * Specifies whether to close the session automatically when the terminal |
---|
| 296 | * process terminates. |
---|
| 297 | */ |
---|
| 298 | void setAutoClose(bool b) { _autoClose = b; } |
---|
| 299 | |
---|
| 300 | /** |
---|
| 301 | * Sets whether flow control is enabled for this terminal |
---|
| 302 | * session. |
---|
| 303 | */ |
---|
| 304 | void setFlowControlEnabled(bool enabled); |
---|
| 305 | |
---|
| 306 | /** Returns whether flow control is enabled for this terminal session. */ |
---|
| 307 | bool flowControlEnabled() const; |
---|
| 308 | |
---|
| 309 | /** |
---|
| 310 | * Sends @p text to the current foreground terminal program. |
---|
| 311 | */ |
---|
| 312 | void sendText(const QString& text) const; |
---|
| 313 | |
---|
| 314 | /** |
---|
| 315 | * Returns the process id of the terminal process. |
---|
| 316 | * This is the id used by the system API to refer to the process. |
---|
| 317 | */ |
---|
| 318 | int processId() const; |
---|
| 319 | |
---|
| 320 | /** |
---|
| 321 | * Returns the process id of the terminal's foreground process. |
---|
| 322 | * This is initially the same as processId() but can change |
---|
| 323 | * as the user starts other programs inside the terminal. |
---|
| 324 | */ |
---|
| 325 | int foregroundProcessId() const; |
---|
| 326 | |
---|
| 327 | /** Returns the terminal session's window size in lines and columns. */ |
---|
| 328 | QSize size(); |
---|
| 329 | /** |
---|
| 330 | * Emits a request to resize the session to accommodate |
---|
| 331 | * the specified window size. |
---|
| 332 | * |
---|
| 333 | * @param size The size in lines and columns to request. |
---|
| 334 | */ |
---|
| 335 | void setSize(const QSize& size); |
---|
| 336 | |
---|
| 337 | /** Sets the text codec used by this session's terminal emulation. */ |
---|
| 338 | void setCodec(QTextCodec* codec); |
---|
| 339 | |
---|
| 340 | /** |
---|
| 341 | * Sets whether the session has a dark background or not. The session |
---|
| 342 | * uses this information to set the COLORFGBG variable in the process's |
---|
| 343 | * environment, which allows the programs running in the terminal to determine |
---|
| 344 | * whether the background is light or dark and use appropriate colors by default. |
---|
| 345 | * |
---|
| 346 | * This has no effect once the session is running. |
---|
| 347 | */ |
---|
| 348 | void setDarkBackground(bool darkBackground); |
---|
| 349 | /** |
---|
| 350 | * Returns true if the session has a dark background. |
---|
| 351 | * See setDarkBackground() |
---|
| 352 | */ |
---|
| 353 | bool hasDarkBackground() const; |
---|
| 354 | |
---|
| 355 | /** |
---|
| 356 | * Attempts to get the shell program to redraw the current display area. |
---|
| 357 | * This can be used after clearing the screen, for example, to get the |
---|
| 358 | * shell to redraw the prompt line. |
---|
| 359 | */ |
---|
| 360 | void refresh(); |
---|
| 361 | |
---|
| 362 | // void startZModem(const QString &rz, const QString &dir, const QStringList &list); |
---|
| 363 | // void cancelZModem(); |
---|
| 364 | // bool isZModemBusy() { return _zmodemBusy; } |
---|
| 365 | |
---|
| 366 | public slots: |
---|
| 367 | |
---|
| 368 | /** |
---|
| 369 | * Starts the terminal session. |
---|
| 370 | * |
---|
| 371 | * This creates the terminal process and connects the teletype to it. |
---|
| 372 | */ |
---|
| 373 | void run(); |
---|
| 374 | |
---|
| 375 | /** |
---|
| 376 | * Closes the terminal session. This sends a hangup signal |
---|
| 377 | * (SIGHUP) to the terminal process and causes the done(Session*) |
---|
| 378 | * signal to be emitted. |
---|
| 379 | */ |
---|
| 380 | void close(); |
---|
| 381 | |
---|
| 382 | /** |
---|
| 383 | * Changes the session title or other customizable aspects of the terminal |
---|
| 384 | * emulation display. For a list of what may be changed see the |
---|
| 385 | * Emulation::titleChanged() signal. |
---|
| 386 | */ |
---|
| 387 | void setUserTitle( int, const QString &caption ); |
---|
| 388 | |
---|
| 389 | signals: |
---|
| 390 | |
---|
| 391 | /** Emitted when the terminal process starts. */ |
---|
| 392 | void started(); |
---|
| 393 | |
---|
| 394 | /** |
---|
| 395 | * Emitted when the terminal process exits. |
---|
| 396 | */ |
---|
| 397 | void finished(); |
---|
| 398 | |
---|
| 399 | /** |
---|
| 400 | * Emitted when output is received from the terminal process. |
---|
| 401 | */ |
---|
| 402 | void receivedData( const QString& text ); |
---|
| 403 | |
---|
| 404 | /** Emitted when the session's title has changed. */ |
---|
| 405 | void titleChanged(); |
---|
| 406 | |
---|
| 407 | /** Emitted when the session's profile has changed. */ |
---|
| 408 | void profileChanged(const QString& profile); |
---|
| 409 | |
---|
| 410 | /** |
---|
| 411 | * Emitted when the activity state of this session changes. |
---|
| 412 | * |
---|
| 413 | * @param state The new state of the session. This may be one |
---|
| 414 | * of NOTIFYNORMAL, NOTIFYSILENCE or NOTIFYACTIVITY |
---|
| 415 | */ |
---|
| 416 | void stateChanged(int state); |
---|
| 417 | |
---|
| 418 | /** Emitted when a bell event occurs in the session. */ |
---|
| 419 | void bellRequest( const QString& message ); |
---|
| 420 | |
---|
| 421 | /** |
---|
| 422 | * Requests that the color the text for any tabs associated with |
---|
| 423 | * this session should be changed; |
---|
| 424 | * |
---|
| 425 | * TODO: Document what the parameter does |
---|
| 426 | */ |
---|
| 427 | void changeTabTextColorRequest(int); |
---|
| 428 | |
---|
| 429 | /** |
---|
| 430 | * Requests that the background color of views on this session |
---|
| 431 | * should be changed. |
---|
| 432 | */ |
---|
| 433 | void changeBackgroundColorRequest(const QColor&); |
---|
| 434 | |
---|
| 435 | /** TODO: Document me. */ |
---|
| 436 | void openUrlRequest(const QString& url); |
---|
| 437 | |
---|
| 438 | /** TODO: Document me. */ |
---|
| 439 | // void zmodemDetected(); |
---|
| 440 | |
---|
| 441 | /** |
---|
| 442 | * Emitted when the terminal process requests a change |
---|
| 443 | * in the size of the terminal window. |
---|
| 444 | * |
---|
| 445 | * @param size The requested window size in terms of lines and columns. |
---|
| 446 | */ |
---|
| 447 | void resizeRequest(const QSize& size); |
---|
| 448 | |
---|
| 449 | /** |
---|
| 450 | * Emitted when a profile change command is received from the terminal. |
---|
| 451 | * |
---|
| 452 | * @param text The text of the command. This is a string of the form |
---|
| 453 | * "PropertyName=Value;PropertyName=Value ..." |
---|
| 454 | */ |
---|
| 455 | void profileChangeCommandReceived(const QString& text); |
---|
| 456 | |
---|
| 457 | /** |
---|
| 458 | * Emitted when the flow control state changes. |
---|
| 459 | * |
---|
| 460 | * @param enabled True if flow control is enabled or false otherwise. |
---|
| 461 | */ |
---|
| 462 | void flowControlEnabledChanged(bool enabled); |
---|
| 463 | |
---|
| 464 | private slots: |
---|
| 465 | void done(int); |
---|
| 466 | |
---|
| 467 | // void fireZModemDetected(); |
---|
| 468 | |
---|
| 469 | void onReceiveBlock( const char* buffer, int len ); |
---|
| 470 | void monitorTimerDone(); |
---|
| 471 | |
---|
| 472 | void onViewSizeChange(int height, int width); |
---|
| 473 | void onEmulationSizeChange(int lines , int columns); |
---|
| 474 | |
---|
| 475 | void activityStateSet(int); |
---|
| 476 | |
---|
| 477 | //automatically detach views from sessions when view is destroyed |
---|
| 478 | void viewDestroyed(QObject* view); |
---|
| 479 | |
---|
| 480 | // void zmodemReadStatus(); |
---|
| 481 | // void zmodemReadAndSendBlock(); |
---|
| 482 | // void zmodemRcvBlock(const char *data, int len); |
---|
| 483 | // void zmodemFinished(); |
---|
| 484 | |
---|
| 485 | private: |
---|
| 486 | |
---|
| 487 | void updateTerminalSize(); |
---|
| 488 | WId windowId() const; |
---|
| 489 | |
---|
| 490 | int _uniqueIdentifier; |
---|
| 491 | |
---|
| 492 | Pty* _shellProcess; |
---|
| 493 | Emulation* _emulation; |
---|
| 494 | |
---|
| 495 | QList<TerminalDisplay*> _views; |
---|
| 496 | |
---|
| 497 | bool _monitorActivity; |
---|
| 498 | bool _monitorSilence; |
---|
| 499 | bool _notifiedActivity; |
---|
| 500 | bool _masterMode; |
---|
| 501 | bool _autoClose; |
---|
| 502 | bool _wantedClose; |
---|
| 503 | QTimer* _monitorTimer; |
---|
| 504 | |
---|
| 505 | int _silenceSeconds; |
---|
| 506 | |
---|
| 507 | QString _nameTitle; |
---|
| 508 | QString _displayTitle; |
---|
| 509 | QString _userTitle; |
---|
| 510 | |
---|
| 511 | QString _localTabTitleFormat; |
---|
| 512 | QString _remoteTabTitleFormat; |
---|
| 513 | |
---|
| 514 | QString _iconName; |
---|
| 515 | QString _iconText; // as set by: echo -en '\033]1;IconText\007 |
---|
| 516 | bool _addToUtmp; |
---|
| 517 | bool _flowControl; |
---|
| 518 | bool _fullScripting; |
---|
| 519 | |
---|
| 520 | QString _program; |
---|
| 521 | QStringList _arguments; |
---|
| 522 | |
---|
| 523 | QStringList _environment; |
---|
| 524 | int _sessionId; |
---|
| 525 | |
---|
| 526 | QString _initialWorkingDir; |
---|
| 527 | |
---|
| 528 | // ZModem |
---|
| 529 | // bool _zmodemBusy; |
---|
| 530 | // KProcess* _zmodemProc; |
---|
| 531 | // ZModemDialog* _zmodemProgress; |
---|
| 532 | |
---|
| 533 | // Color/Font Changes by ESC Sequences |
---|
| 534 | |
---|
| 535 | QColor _modifiedBackground; // as set by: echo -en '\033]11;Color\007 |
---|
| 536 | |
---|
| 537 | QString _profileKey; |
---|
| 538 | |
---|
| 539 | bool _hasDarkBackground; |
---|
| 540 | |
---|
| 541 | static int lastSessionId; |
---|
| 542 | |
---|
| 543 | }; |
---|
| 544 | |
---|
| 545 | /** |
---|
| 546 | * Provides a group of sessions which is divided into master and slave sessions. |
---|
| 547 | * Activity in master sessions can be propagated to all sessions within the group. |
---|
| 548 | * The type of activity which is propagated and method of propagation is controlled |
---|
| 549 | * by the masterMode() flags. |
---|
| 550 | */ |
---|
| 551 | class SessionGroup : public QObject |
---|
| 552 | { |
---|
| 553 | Q_OBJECT |
---|
| 554 | |
---|
| 555 | public: |
---|
| 556 | /** Constructs an empty session group. */ |
---|
| 557 | SessionGroup(); |
---|
| 558 | /** Destroys the session group and removes all connections between master and slave sessions. */ |
---|
| 559 | ~SessionGroup(); |
---|
| 560 | |
---|
| 561 | /** Adds a session to the group. */ |
---|
| 562 | void addSession( Session* session ); |
---|
| 563 | /** Removes a session from the group. */ |
---|
| 564 | void removeSession( Session* session ); |
---|
| 565 | |
---|
| 566 | /** Returns the list of sessions currently in the group. */ |
---|
| 567 | QList<Session*> sessions() const; |
---|
| 568 | |
---|
| 569 | /** |
---|
| 570 | * Sets whether a particular session is a master within the group. |
---|
| 571 | * Changes or activity in the group's master sessions may be propagated |
---|
| 572 | * to all the sessions in the group, depending on the current masterMode() |
---|
| 573 | * |
---|
| 574 | * @param session The session whoose master status should be changed. |
---|
| 575 | * @param master True to make this session a master or false otherwise |
---|
| 576 | */ |
---|
| 577 | void setMasterStatus( Session* session , bool master ); |
---|
| 578 | /** Returns the master status of a session. See setMasterStatus() */ |
---|
| 579 | bool masterStatus( Session* session ) const; |
---|
| 580 | |
---|
| 581 | /** |
---|
| 582 | * This enum describes the options for propagating certain activity or |
---|
| 583 | * changes in the group's master sessions to all sessions in the group. |
---|
| 584 | */ |
---|
| 585 | enum MasterMode |
---|
| 586 | { |
---|
| 587 | /** |
---|
| 588 | * Any input key presses in the master sessions are sent to all |
---|
| 589 | * sessions in the group. |
---|
| 590 | */ |
---|
| 591 | CopyInputToAll = 1 |
---|
| 592 | }; |
---|
| 593 | |
---|
| 594 | /** |
---|
| 595 | * Specifies which activity in the group's master sessions is propagated |
---|
| 596 | * to all sessions in the group. |
---|
| 597 | * |
---|
| 598 | * @param mode A bitwise OR of MasterMode flags. |
---|
| 599 | */ |
---|
| 600 | void setMasterMode( int mode ); |
---|
| 601 | /** |
---|
| 602 | * Returns a bitwise OR of the active MasterMode flags for this group. |
---|
| 603 | * See setMasterMode() |
---|
| 604 | */ |
---|
| 605 | int masterMode() const; |
---|
| 606 | |
---|
| 607 | private: |
---|
| 608 | void connectPair(Session* master , Session* other); |
---|
| 609 | void disconnectPair(Session* master , Session* other); |
---|
| 610 | void connectAll(bool connect); |
---|
| 611 | QList<Session*> masters() const; |
---|
| 612 | |
---|
| 613 | // maps sessions to their master status |
---|
| 614 | QHash<Session*,bool> _sessions; |
---|
| 615 | |
---|
| 616 | int _masterMode; |
---|
| 617 | }; |
---|
| 618 | |
---|
| 619 | } |
---|
| 620 | |
---|
| 621 | #endif |
---|