Implements the session portion of the dbus interface.

CCBUG: 169024

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=957189
wilder-portage
Kurt Hindenburg 17 years ago
parent 3d7eebcec8
commit b05607ee5f
  1. 48
      src/Session.cpp
  2. 194
      src/Session.h
  3. 63
      src/org.kde.konsole.Session.xml

@ -192,6 +192,21 @@ void Session::setCodec(QTextCodec* codec)
emulation()->setCodec(codec);
}
bool Session::setCodec(QByteArray name)
{
QTextCodec *codec = QTextCodec::codecForName(name);
if (codec) {
setCodec(codec);
return true;
}
return false;
}
QByteArray Session::codec()
{
return _emulation->codec()->name();
}
void Session::setProgram(const QString& program)
{
_program = ShellCommand::expand(program);
@ -527,6 +542,7 @@ void Session::monitorTimerDone()
}
void Session::updateFlowControlState(bool suspended)
{
kDebug()<<"suspend "<<suspended<<"; flowenable "<<flowControlEnabled()<<endl;
if (suspended)
{
if (flowControlEnabled())
@ -682,6 +698,11 @@ void Session::sendText(const QString &text) const
_emulation->sendText(text);
}
void Session::sendMouseEvent(int buttons, int column, int line, int eventType)
{
_emulation->sendMouseEvent(buttons, column, line, eventType);
}
Session::~Session()
{
if (_foregroundProcessInfo)
@ -976,11 +997,12 @@ void Session::setFlowControlEnabled(bool enabled)
if (_shellProcess)
_shellProcess->setFlowControlEnabled(_flowControl);
kDebug()<<"flow "<<enabled<<"; shell "<<_shellProcess<<endl;
emit flowControlEnabledChanged(enabled);
}
bool Session::flowControlEnabled() const
{
kDebug()<<"_shellProcess "<<_shellProcess->flowControlEnabled()<<"; else _flow "<<_flowControl<<endl;
if (_shellProcess)
return _shellProcess->flowControlEnabled();
else
@ -1119,6 +1141,30 @@ int Session::processId() const
return _shellProcess->pid();
}
void Session::setTitle(int role , const QString& title)
{
switch (role) {
case (0):
this->setTitle(Session::NameRole, title);
break;
case (1):
this->setTitle(Session::DisplayedTitleRole, title);
break;
}
}
QString Session::title(int role) const
{
switch (role) {
case (0):
return this->title(Session::NameRole);
case (1):
return this->title(Session::DisplayedTitleRole);
default:
return QString();
}
}
int Session::foregroundProcessId()
{
int pid;

@ -131,27 +131,9 @@ public:
*/
Emulation* emulation() const;
/**
* Returns the environment of this session as a list of strings like
* VARIABLE=VALUE
*/
QStringList environment() const;
/**
* Sets the environment for this session.
* @p environment should be a list of strings like
* VARIABLE=VALUE
*/
void setEnvironment(const QStringList& environment);
/** Returns the unique ID for this session. */
int sessionId() const;
/**
* Return the session title set by the user (ie. the program running
* in the terminal), or an empty string if the user has not set a custom title
*/
QString userTitle() const;
/**
* This enum describes the contexts for which separate
* tab title formats may be specified.
@ -225,32 +207,6 @@ public:
*/
void clearHistory();
/**
* Enables monitoring for activity in the session.
* This will cause notifySessionState() to be emitted
* with the NOTIFYACTIVITY state flag when output is
* received from the terminal.
*/
void setMonitorActivity(bool);
/** Returns true if monitoring for activity is enabled. */
bool isMonitorActivity() const;
/**
* Enables monitoring for silence in the session.
* This will cause notifySessionState() to be emitted
* with the NOTIFYSILENCE state flag when output is not
* received from the terminal for a certain period of
* time, specified with setMonitorSilenceSeconds()
*/
void setMonitorSilence(bool);
/**
* Returns true if monitoring for inactivity (silence)
* in the session is enabled.
*/
bool isMonitorSilence() const;
/** See setMonitorSilence() */
void setMonitorSilenceSeconds(int seconds);
/**
* Sets the key bindings used by this session. The bindings
* specify how input key sequences are translated into
@ -275,10 +231,12 @@ public:
DisplayedTitleRole
};
/** Sets the session's title for the specified @p role to @p title. */
void setTitle(TitleRole role , const QString& title);
/** Returns the session's title for the specified @p role. */
QString title(TitleRole role) const;
/**
* Return the session title set by the user (ie. the program running
* in the terminal), or an empty string if the user has not set a custom title
*/
QString userTitle() const;
/** Convenience method used to read the name property. Returns title(Session::NameRole). */
QString nameTitle() const { return title(Session::NameRole); }
/** Returns a title generated from tab format and process information. */
@ -297,6 +255,12 @@ public:
/** Returns the text of the icon associated with this session. */
QString iconText() const;
/** Sets the session's title for the specified @p role to @p title. */
void setTitle(TitleRole role , const QString& title);
/** Returns the session's title for the specified @p role. */
QString title(TitleRole role) const;
/**
* Specifies whether a utmp entry should be created for the pty used by this session.
* If true, KPty::login() is called when the session is started.
@ -309,31 +273,6 @@ public:
*/
void setAutoClose(bool b) { _autoClose = b; }
/**
* Sets whether flow control is enabled for this terminal
* session.
*/
void setFlowControlEnabled(bool enabled);
/** Returns whether flow control is enabled for this terminal session. */
bool flowControlEnabled() const;
/**
* Sends @p text to the current foreground terminal program.
*/
void sendText(const QString& text) const;
/**
* Returns the process id of the terminal process.
* This is the id used by the system API to refer to the process.
*/
int processId() const;
/**
* Returns the foreground PID. Returns -1 if there is none.
*/
int foregroundProcessId();
/** Returns true if the user has started a program in the session. */
bool isForegroundProcessActive();
@ -350,9 +289,6 @@ public:
*/
void setSize(const QSize& size);
/** Sets the text codec used by this session's terminal emulation. */
void setCodec(QTextCodec* codec);
/**
* Sets whether the session has a dark background or not. The session
* uses this information to set the COLORFGBG variable in the process's
@ -394,6 +330,9 @@ public:
ProfileChange = 50 // this clashes with Xterm's font change command
};
// Sets the text codec used by this sessions terminal emulation.
void setCodec(QTextCodec* codec);
// session management
void saveSession(KConfigGroup& group);
void restoreSession(KConfigGroup& group);
@ -407,6 +346,19 @@ public slots:
*/
void run();
/**
* Returns the environment of this session as a list of strings like
* VARIABLE=VALUE
*/
Q_SCRIPTABLE QStringList environment() const;
/**
* Sets the environment for this session.
* @p environment should be a list of strings like
* VARIABLE=VALUE
*/
Q_SCRIPTABLE void setEnvironment(const QStringList& environment);
/**
* Closes the terminal session. This sends a hangup signal
* (SIGHUP) to the terminal process and causes the finished()
@ -414,7 +366,7 @@ public slots:
* then the terminal connection (the pty) is closed and Konsole waits for the
* process to exit.
*/
void close();
Q_SCRIPTABLE void close();
/**
* Changes the session title or other customizable aspects of the terminal
@ -426,6 +378,94 @@ public slots:
*/
void setUserTitle( int what , const QString &caption );
/**
* Enables monitoring for activity in the session.
* This will cause notifySessionState() to be emitted
* with the NOTIFYACTIVITY state flag when output is
* received from the terminal.
*/
Q_SCRIPTABLE void setMonitorActivity(bool);
/** Returns true if monitoring for activity is enabled. */
Q_SCRIPTABLE bool isMonitorActivity() const;
/**
* Enables monitoring for silence in the session.
* This will cause notifySessionState() to be emitted
* with the NOTIFYSILENCE state flag when output is not
* received from the terminal for a certain period of
* time, specified with setMonitorSilenceSeconds()
*/
Q_SCRIPTABLE void setMonitorSilence(bool);
/**
* Returns true if monitoring for inactivity (silence)
* in the session is enabled.
*/
Q_SCRIPTABLE bool isMonitorSilence() const;
/** See setMonitorSilence() */
Q_SCRIPTABLE void setMonitorSilenceSeconds(int seconds);
/**
* Sets whether flow control is enabled for this terminal
* session.
*/
Q_SCRIPTABLE void setFlowControlEnabled(bool enabled);
/** Returns whether flow control is enabled for this terminal session. */
Q_SCRIPTABLE bool flowControlEnabled() const;
/**
* Sends @p text to the current foreground terminal program.
*/
Q_SCRIPTABLE void sendText(const QString& text) const;
/**
* Sends a mouse event of type @p eventType emitted by button
* @p buttons on @p column/@p line to the current foreground
* terminal program
*/
Q_SCRIPTABLE void sendMouseEvent(int buttons, int column, int line, int eventType);
/**
* Returns the process id of the terminal process.
* This is the id used by the system API to refer to the process.
*/
Q_SCRIPTABLE int processId() const;
/**
* Returns the process id of the terminal's foreground process.
* This is initially the same as processId() but can change
* as the user starts other programs inside the terminal.
*/
Q_SCRIPTABLE int foregroundProcessId();
/** Sets the text codec used by this sessions terminal emulation.
* Overloaded to accept a QByteArray for convenience since DBus
* does not accept QTextCodec directky.
*/
Q_SCRIPTABLE bool setCodec(QByteArray codec);
/** Returns the codec used to decode incoming characters in this
* terminal emulation
*/
Q_SCRIPTABLE QByteArray codec();
/** Sets the session's title for the specified @p role to @p title.
* This is an overloaded member function for setTitle(TitleRole, QString)
* provided for convenience since enum data types may not be
* exported directly through DBus
*/
Q_SCRIPTABLE void setTitle(int role, const QString& title);
/** Returns the session's title for the specified @p role.
* This is an overloaded member function for setTitle(TitleRole)
* provided for convenience since enum data types may not be
* exported directly through DBus
*/
Q_SCRIPTABLE QString title(int role) const;
signals:
/** Emitted when the terminal process starts. */

@ -1,6 +1,65 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.konsole.Session">
</interface>
<interface name="org.kde.konsole.Session">
<method name="environment">
<arg type="as" direction="out"/>
</method>
<method name="setEnvironment">
<arg name="environment" type="as" direction="in"/>
</method>
<method name="close">
</method>
<method name="setMonitorActivity">
<arg type="b" direction="in"/>
</method>
<method name="isMonitorActivity">
<arg type="b" direction="out"/>
</method>
<method name="setMonitorSilence">
<arg type="b" direction="in"/>
</method>
<method name="isMonitorSilence">
<arg type="b" direction="out"/>
</method>
<method name="setMonitorSilenceSeconds">
<arg name="seconds" type="i" direction="in"/>
</method>
<method name="setFlowControlEnabled">
<arg name="enabled" type="b" direction="in"/>
</method>
<method name="flowControlEnabled">
<arg type="b" direction="out"/>
</method>
<method name="sendText">
<arg name="text" type="s" direction="in"/>
</method>
<method name="sendMouseEvent">
<arg name="buttons" type="i" direction="in"/>
<arg name="column" type="i" direction="in"/>
<arg name="line" type="i" direction="in"/>
<arg name="eventType" type="i" direction="in"/>
</method>
<method name="processId">
<arg type="i" direction="out"/>
</method>
<method name="foregroundProcessId">
<arg type="i" direction="out"/>
</method>
<method name="setCodec">
<arg type="b" direction="out"/>
<arg name="codec" type="ay" direction="in"/>
</method>
<method name="codec">
<arg type="ay" direction="out"/>
</method>
<method name="setTitle">
<arg name="role" type="i" direction="in"/>
<arg name="title" type="s" direction="in"/>
</method>
<method name="title">
<arg type="s" direction="out"/>
<arg name="role" type="i" direction="in"/>
</method>
</interface>
</node>

Loading…
Cancel
Save