[prev in list] [next in list] [prev in thread] [next in thread] 

List:       konsole-devel
Subject:    [Konsole-devel] [Patch] DBus Interface
From:       Arno_Töll <lists () toell ! net>
Date:       2009-01-03 17:59:56
Message-ID: 495FA79C.7080400 () toell ! net
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi there,

I've finished parts of the promised DBus interface. There may be some
more work to do, depending whether you accept the patch as it is or not.
The patch is against the KDE 4.1 branch anyway (konsole version 2.1),
not HEAD since I didn't manage to get it to work.

I don't see this patch as a final submit, but more as a request for
comments. Some notes: Both XML files available in the current
distribution are revoked and going to be replaced by my own IDL
(autogenerated by qdbus2xml - see CMakeLists.txt for a how to).


I refactored some already existing methods within the class Session to
public slots, to be usable through DBus. The majority of the other
methods are just wrappers and work arounds to do existing work within
the classes where I placed one or both interfaces.
I'm quite unhappy with the  setTitle(int role , const QString& title)
method in Session.h/cpp but there is no smart way to export enum
datatypes through DBus and even marshalling would require to port the
data type to a byte stream and therefore do assumptions on the value I
think.


Please send me feedback asap, when you have doubts or concerns with this
patch. Note: this patch also fixes bug 169024.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAklfp5kACgkQBWM6U4QI1MRl9ACgi9LwYgz8oJ8vmBKERRguOcIP
nnsAnAqTLDYIK+Lr3r9lQXyFKghOGU8m
=pmw7
-----END PGP SIGNATURE-----

["konsole-dbus-4.1.patch" (text/x-diff)]

diff -ruN konsole-4.1-BASE/src/CMakeLists.txt konsole-dbus-export/src/CMakeLists.txt
--- konsole-4.1-BASE/src/CMakeLists.txt	2008-07-07 14:04:56.000000000 +0200
+++ konsole-dbus-export/src/CMakeLists.txt	2009-01-03 18:17:51.000000000 +0100
@@ -22,11 +22,15 @@
     endif(KONSOLE_GENERATE_LINEFONT)
 
 # Konsole source files shared between embedded terminal and main application
+# qdbuscpp2xml -m  Session.h -o org.kde.konsole.Session.xml
+# qdbuscpp2xml -M -s ViewManager.h -o org.kde.konsole.Konsole.xml
 
     qt4_add_dbus_adaptor( sessionadaptors_SRCS org.kde.konsole.Session.xml Session.h \
Konsole::Session ) +    qt4_add_dbus_adaptor( konsoleadaptors_SRCS \
org.kde.konsole.Konsole.xml ViewManager.h Konsole::ViewManager )  
     set(konsole_COMMON_SRCS
         ${sessionadaptors_SRCS}
+	${konsoleadaptors_SRCS}
         BlockArray.cpp
         BookmarkHandler.cpp 
         ColorScheme.cpp
diff -ruN konsole-4.1-BASE/src/org.kde.konsole.KonsoleScripting.xml \
                konsole-dbus-export/src/org.kde.konsole.KonsoleScripting.xml
--- konsole-4.1-BASE/src/org.kde.konsole.KonsoleScripting.xml	2007-05-06 \
                01:33:05.000000000 +0200
+++ konsole-dbus-export/src/org.kde.konsole.KonsoleScripting.xml	1970-01-01 \
01:00:00.000000000 +0100 @@ -1,11 +0,0 @@
-<!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.KonsoleScripting">
-    <method name="feedAllSessions">
-      <arg name="text" type="s" direction="in"/>
-    </method>
-    <method name="sendAllSessions">
-      <arg name="text" type="s" direction="in"/>
-    </method>
-  </interface>
-</node>
diff -ruN konsole-4.1-BASE/src/org.kde.konsole.Konsole.xml \
                konsole-dbus-export/src/org.kde.konsole.Konsole.xml
--- konsole-4.1-BASE/src/org.kde.konsole.Konsole.xml	2007-05-06 01:33:05.000000000 \
                +0200
+++ konsole-dbus-export/src/org.kde.konsole.Konsole.xml	2009-01-03 17:26:22.000000000 \
+0100 @@ -1,40 +1,33 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
-"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<!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.Konsole">
     <method name="sessionCount">
       <arg type="i" direction="out"/>
     </method>
     <method name="currentSession">
-      <arg type="s" direction="out"/>
+      <arg type="i" direction="out"/>
     </method>
     <method name="newSession">
-      <arg type="s" direction="out"/>
+      <arg type="i" direction="out"/>
+      <arg name="profile" type="s" direction="in"/>
+      <arg name="directory" type="s" direction="in"/>
     </method>
-    <method name="newSession">
-      <arg name="type" type="s" direction="in"/>
-      <arg type="s" direction="out"/>
+    <method name="profileList">
+      <arg type="as" direction="out"/>
     </method>
-    <method name="sessionId">
-      <arg name="position" type="i" direction="in"/>
-      <arg type="s" direction="out"/>
+    <method name="newSession">
+      <arg type="i" direction="out"/>
     </method>
     <method name="activateSession">
-      <arg name="sessionId" type="s" direction="in"/>
+      <arg name="sessionId" type="i" direction="in"/>
+    </method>
+    <method name="nextSession">
     </method>
-    <method name="nextSession"/>
-    <method name="prevSession"/>
-    <method name="moveSessionLeft"/>
-    <method name="moveSessionRight"/>
-    <method name="fullScreen">
-      <arg type="b" direction="out"/>
+    <method name="prevSession">
     </method>
-    <method name="setFullScreen">
-      <arg name="on" type="b" direction="in"/>
+    <method name="moveSessionLeft">
     </method>
-    <method name="reparseConfiguration">
-    <annotation name="org.freedesktop.DBus.Method.NoReply" value="true"/>
+    <method name="moveSessionRight">
     </method>
-    <signal name="reloadConfig"/>
   </interface>
 </node>
diff -ruN konsole-4.1-BASE/src/org.kde.konsole.SessionScripting.xml \
                konsole-dbus-export/src/org.kde.konsole.SessionScripting.xml
--- konsole-4.1-BASE/src/org.kde.konsole.SessionScripting.xml	2007-05-06 \
                01:33:05.000000000 +0200
+++ konsole-dbus-export/src/org.kde.konsole.SessionScripting.xml	1970-01-01 \
01:00:00.000000000 +0100 @@ -1,11 +0,0 @@
-<!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.SessionScripting">
-    <method name="feedSession">
-      <arg name="text" type="s" direction="in"/>
-    </method>
-    <method name="sendSession">
-      <arg name="text" type="s" direction="in"/>
-    </method>
-  </interface>
-</node>
diff -ruN konsole-4.1-BASE/src/org.kde.konsole.Session.xml \
                konsole-dbus-export/src/org.kde.konsole.Session.xml
--- konsole-4.1-BASE/src/org.kde.konsole.Session.xml	2007-07-21 02:11:09.000000000 \
                +0200
+++ konsole-dbus-export/src/org.kde.konsole.Session.xml	2009-01-03 17:26:22.000000000 \
+0100 @@ -1,6 +1,64 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
-"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<!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">
+    <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>
diff -ruN konsole-4.1-BASE/src/Session.cpp konsole-dbus-export/src/Session.cpp
--- konsole-4.1-BASE/src/Session.cpp	2008-06-11 19:20:44.000000000 +0200
+++ konsole-dbus-export/src/Session.cpp	2009-01-03 17:26:22.000000000 +0100
@@ -37,6 +37,7 @@
 #include <QtCore/QStringList>
 #include <QtDBus/QtDBus>
 #include <QtCore/QDate>
+#include <QTextCodec>
 
 // KDE
 #include <KDebug>
@@ -186,6 +187,23 @@
     emulation()->setCodec(codec);
 }
 
+bool Session::setCodec(QByteArray name)
+{
+	QTextCodec *codec = QTextCodec::codecForName(name);
+	if (codec)
+	{
+		setCodec(codec);
+		return true;
+	}
+	else
+		return false;	
+}
+
+QByteArray Session::codec()
+{
+        return _emulation->codec()->name();
+}
+
 void Session::setProgram(const QString& program)
 {
     _program = ShellCommand::expand(program);
@@ -646,6 +664,11 @@
   _emulation->sendText(text);
 }
 
+void Session::sendMouseEvent(int buttons, int column, int line, int eventType)
+{
+  _emulation->sendMouseEvent(buttons, column, line, eventType);
+}
+
 Session::~Session()
 {
   delete _emulation;
@@ -979,6 +1002,34 @@
     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 "(undef)";
+	}
+}
+
+
 SessionGroup::SessionGroup(QObject* parent)
     : QObject(parent), _masterMode(0)
 {
@@ -1096,4 +1147,5 @@
     }
 }
 
+
 #include "Session.moc"
diff -ruN konsole-4.1-BASE/src/Session.h konsole-dbus-export/src/Session.h
--- konsole-4.1-BASE/src/Session.h	2008-06-11 19:20:44.000000000 +0200
+++ konsole-dbus-export/src/Session.h	2009-01-03 17:26:22.000000000 +0100
@@ -65,7 +65,8 @@
   Q_PROPERTY(int processId READ processId)
   Q_PROPERTY(QString keyBindings READ keyBindings WRITE setKeyBindings)
   Q_PROPERTY(QSize size READ size WRITE setSize)
-
+  Q_CLASSINFO("D-Bus Interface", "org.kde.konsole.Session")
+  
   /**
    * Constructs a new session.
    *
@@ -129,28 +130,10 @@
    */
   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.
    */
@@ -218,31 +201,6 @@
    */
   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
@@ -268,10 +226,12 @@
       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); }  
@@ -285,6 +245,12 @@
   /** 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.
@@ -297,33 +263,6 @@
    */
   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 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.
-   */
-  int foregroundProcessId() const;
-
   /** Returns the terminal session's window size in lines and columns. */
   QSize size();
   /**
@@ -334,9 +273,6 @@
    */
   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
@@ -378,6 +314,11 @@
 	ProfileChange			= 50 	// this clashes with Xterm's font change command
   };
 
+  /**
+    * Sets the text codec used by this sessions terminal emulation.
+    */
+  void setCodec(QTextCodec* codec);
+
 public slots:
 
   /**
@@ -388,11 +329,23 @@
   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 done(Session*)
    * signal to be emitted.
    */
-  void close();
+  Q_SCRIPTABLE void close();
 
   /**
    * Changes the session title or other customizable aspects of the terminal
@@ -404,6 +357,92 @@
    */
   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() const;
+
+  /** 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. */
@@ -650,4 +689,6 @@
 
 }
 
+
+
 #endif
diff -ruN konsole-4.1-BASE/src/ViewManager.cpp \
                konsole-dbus-export/src/ViewManager.cpp
--- konsole-4.1-BASE/src/ViewManager.cpp	2008-05-22 00:19:43.000000000 +0200
+++ konsole-dbus-export/src/ViewManager.cpp	2009-01-03 18:17:51.000000000 +0100
@@ -35,6 +35,7 @@
 #include <KLocale>
 #include <KToggleAction>
 #include <KXMLGUIFactory>
+#include <QStringList>
 
 // Konsole
 #include "ColorScheme.h"
@@ -45,6 +46,8 @@
 #include "SessionManager.h"
 #include "ViewContainer.h"
 #include "ViewSplitter.h"
+#include "konsoleadaptor.h"
+#include "Profile.h"
 
 using namespace Konsole;
 
@@ -85,6 +88,10 @@
             SLOT(profileChanged(Profile::Ptr)) );
     connect( SessionManager::instance() , SIGNAL(sessionUpdated(Session*)) , this,
             SLOT(updateViewsForSession(Session*)) );
+
+    //prepare DBus communication
+    new KonsoleAdaptor(this);
+    QDBusConnection::sessionBus().registerObject(QLatin1String("/Konsole"), this);
 }
 
 ViewManager::~ViewManager()
@@ -843,4 +850,102 @@
     return qHash((TerminalDisplay*)display);
 }
 
+int ViewManager::sessionCount()
+{
+	return this->_sessionMap.size();
+}
+
+int ViewManager::currentSession()
+{
+	QHash<TerminalDisplay*,Session*>::iterator i;
+    	for (i = this->_sessionMap.begin(); i != this->_sessionMap.end(); ++i)
+		if (i.key()->isVisible())
+			return i.value()->sessionId();
+	return -1;
+}
+
+int ViewManager::newSession()
+{
+	Profile::Ptr profile = profile = SessionManager::instance()->defaultProfile();
+	Session* session     = SessionManager::instance()->createSession(profile);	
+
+	this->createView(session);
+	session->run();
+	
+	return session->sessionId();
+}
+
+int ViewManager::newSession(QString profile, QString directory)
+{
+	QList<Profile::Ptr> profilelist = SessionManager::instance()->loadedProfiles();
+	QList<Profile::Ptr>::iterator i = profilelist.begin();
+
+	Profile::Ptr profileptr = SessionManager::instance()->defaultProfile();	
+
+	while (i != profilelist.end() )
+	{
+		Profile::Ptr ptr = *i;
+		if ( ptr->name().compare(profile) == 0)
+			profileptr = ptr;
+		i++;
+	}
+
+	Session* session     = SessionManager::instance()->createSession(profileptr);
+	session->setInitialWorkingDirectory(directory);
+
+	this->createView(session);
+	session->run();
+	return session->sessionId();
+}
+
+QStringList ViewManager::profileList()
+{
+	QList<Profile::Ptr> profilelist = SessionManager::instance()->loadedProfiles();
+	QList<Profile::Ptr>::iterator i = profilelist.begin();
+	QStringList list;
+	while (i != profilelist.end() )
+	{
+		Profile::Ptr ptr = *i;
+		list.push_back(ptr->name());
+		i++;
+	}
+
+	return list;
+}
+
+
+void ViewManager::activateSession(int sessionId)
+{
+	QHash<TerminalDisplay*,Session*>::iterator i;
+    	for (i = this->_sessionMap.begin(); i != this->_sessionMap.end(); ++i)
+        	if (i.value()->sessionId() == sessionId)
+		{
+			_viewSplitter->activeContainer()->setActiveView(i.key());
+			i.key()->setFocus( Qt::OtherFocusReason );
+			updateDetachViewState();
+			break;
+		}
+	return;
+}
+
+void ViewManager::nextSession()
+{
+	this->nextView();
+}
+
+void ViewManager::prevSession()
+{
+	this->previousView();
+}
+
+void ViewManager::moveSessionLeft()
+{
+	this->moveActiveViewLeft();
+}
+
+void ViewManager::moveSessionRight()
+{
+	this->moveActiveViewRight();
+}
+
 #include "ViewManager.moc"
diff -ruN konsole-4.1-BASE/src/ViewManager.h konsole-dbus-export/src/ViewManager.h
--- konsole-4.1-BASE/src/ViewManager.h	2008-05-02 02:59:47.000000000 +0200
+++ konsole-dbus-export/src/ViewManager.h	2009-01-03 17:26:22.000000000 +0100
@@ -24,6 +24,7 @@
 #include <QtCore/QHash>
 #include <QtCore/QObject>
 #include <QtCore/QPointer>
+#include <QStringList>
 
 // Konsole
 #include "Profile.h"
@@ -67,6 +68,8 @@
 class ViewManager : public QObject
 {
 Q_OBJECT
+Q_CLASSINFO("D-Bus Interface", "org.kde.konsole.Konsole")
+
 
 public:
     /** 
@@ -189,6 +192,53 @@
     /** Requests creation of a new view, with the selected profile. */
     void newViewRequest(Profile::Ptr);
 
+
+public slots:
+    /** DBus slot that returns the number of sessions in the current view. */
+    int sessionCount();
+    
+    /** DBus slot that returns the current (active) session window */
+    int currentSession();
+
+    /** DBus slot that creates a new session in the current view. 
+     * @param the name of the profile to be used
+     * @param directory is the working directory, where the session gets 
+     * started.
+     */ 
+     int newSession(QString profile, QString directory);
+	
+     // DBus slot that returns a string list of defined (known) profiles
+     QStringList profileList();
+
+    /** DBus slot that creates a new session in the current view with the associated
+      * default profile and the default working directory
+      */
+    int newSession();
+    
+    /** DBus slot that activates (focusses) given session
+     * @param sessionId is the numerical identifier for the session.
+     * The first session gets Id 1
+     */
+    void activateSession(int sessionId);
+    
+    /** DBus slot that changes the view port to the next session */
+    void nextSession();
+	
+    /** DBus slot that changes the view port to the previous session */
+    void prevSession();
+
+    /** DBus slot that switches the current session (as returned by 
+      * currentSession()) with the left (or previous) one in the 
+      * navigation tab.
+      */
+    void moveSessionLeft();
+
+    /** DBus slot that Switches the current session (as returned by 
+      * currentSession()) with the right (or next) one in the navigation 
+      * tab.
+      */
+    void moveSessionRight();
+    
 private slots:
     // called when the "Split View Left/Right" menu item is selected
     void splitLeftRight();



_______________________________________________
konsole-devel mailing list
konsole-devel@kde.org
https://mail.kde.org/mailman/listinfo/konsole-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic