[X2go-Commits] x2goclient.git - build-main (branch) updated: 3.99.2.1

X2Go dev team git-admin at x2go.org
Fri Jun 8 12:55:54 CEST 2012


The branch, build-main has been updated
       via  26aac92d6769fdb9194211108caf5ac96226a612 (commit)
       via  4ccfeaffa19e3ccc20084f3683ccd4512926b5f9 (commit)
       via  adefcb0cd27987107424e251a4d172b930390a14 (commit)
       via  f388d5f473a4939730a10ecb1e50611c45732717 (commit)
       via  1b21d75f2c10609f3586f5b5e0b4ceb7fca83fdd (commit)
       via  dd0a6376138afbaec5b5447360a32bf6bdf24d7b (commit)
       via  bad7a0bdb342649e5cad359d644bd5e33cbf7d54 (commit)
       via  367b245a575649a16fe01320f0ba412cc5fa73a5 (commit)
       via  ea3adb1cce7727a6114537ee3039e044f297d2dd (commit)
       via  82e8f77fc996de04b148ae9c6d53a78f37442ec9 (commit)
       via  4f41b1600794e06c5a9ec5e14b1621c52f867ae0 (commit)
       via  8c41c073e281b7a7d6a876381096b45458748ec1 (commit)
       via  74d212292d0e8d085032aeb59c469b8f5155e74a (commit)
       via  c736df204c427849b1a4f512fd2113ceab723fa7 (commit)
       via  868871c1c4a359f7f739037ffcc62dff853a65af (commit)
       via  1ba12c3814eb80361a03837afd0ac62b1dce6b6a (commit)
       via  a19e5dadfd929d11bcd411df7b77c3a8b063ede4 (commit)
       via  be9f453bfe1458c8c4b7e772b6b5dff0c1306bd3 (commit)
       via  60ee3404e96f23e81dfd45561405db53d3e316f5 (commit)
       via  b026eb6b729095f6907a2a6a00f1c59de2664850 (commit)
      from  7b871ac84fc2877af240ec5a4a6172d1eaec61b3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 Makefile                   |    8 +-
 VERSION                    |    2 +-
 debian/changelog           |   32 +
 desktop/x2goclient.desktop |    2 +-
 icons/128x128/unity.png    |  Bin 0 -> 17622 bytes
 icons/16x16/unity.png      |  Bin 0 -> 1410 bytes
 icons/32x32/unity.png      |  Bin 0 -> 2984 bytes
 icons/64x64/unity.png      |  Bin 0 -> 7241 bytes
 onmainwindow.cpp           | 8090 +++++++++++++++++++++++++++++++++++++++++++-
 onmainwindow.h             |    3 +
 onmainwindow_part2.cpp     | 2577 --------------
 onmainwindow_part3.cpp     | 2510 --------------
 onmainwindow_part4.cpp     | 2861 ----------------
 onmainwindow_privat.h      |    1 +
 resources.rcc              |    1 +
 sessionbutton.cpp          |   16 +
 sessionbutton.h            |    2 +-
 sessionwidget.cpp          |    6 +
 sessionwidget.h            |    2 +-
 sshmasterconnection.cpp    |   19 +-
 svg/unity.svg              |    8 +
 version.h                  |    3 +-
 x2goclient.pro             |   34 +-
 x2goclient_de.ts           |   73 +-
 x2goclient_nb_no.ts        |  741 ++--
 x2goclient_sv.ts           |   65 +-
 x2goplugin.rc              |   10 +-
 27 files changed, 8631 insertions(+), 8435 deletions(-)
 create mode 100644 icons/128x128/unity.png
 create mode 100644 icons/16x16/unity.png
 create mode 100644 icons/32x32/unity.png
 create mode 100644 icons/64x64/unity.png
 delete mode 100644 onmainwindow_part2.cpp
 delete mode 100644 onmainwindow_part3.cpp
 delete mode 100644 onmainwindow_part4.cpp
 create mode 100644 svg/unity.svg

The diff of changes is:
diff --git a/Makefile b/Makefile
index 30c12dc..19d83db 100755
--- a/Makefile
+++ b/Makefile
@@ -41,10 +41,10 @@ build_man:
 	${MAKE} -f Makefile.man2html build
 
 clean: clean_client clean_plugin clean_man
-	find . -type f -name '*.o' -exec rm -vf {} +
-	find . -type f -name 'moc_*.cpp' -exec rm -vf {} +
-	find . -type f -name 'ui_*.h' -exec rm -vf {} +
-	find . -type f -name 'qrc_*.cpp' -exec rm -vf {} +
+	find . -type f -maxdepth 2 -name '*.o' -exec rm -vf {} +
+	find . -type f -maxdepth 2 -name 'moc_*.cpp' -exec rm -vf {} +
+	find . -type f -maxdepth 2 -name 'ui_*.h' -exec rm -vf {} +
+	find . -type f -maxdepth 2 -name 'qrc_*.cpp' -exec rm -vf {} +
 	rm -f x2goclient
 	rm -f x2goclient.tag
 
diff --git a/VERSION b/VERSION
index 1296fd3..399ee7b 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.99.2.0
+3.99.2.1
diff --git a/debian/changelog b/debian/changelog
index 49f5464..baad6e2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,35 @@
+x2goclient (3.99.2.1-0~x2go1) unstable; urgency=low
+
+  [ Oleksandr Shneyder ]
+  * New upstream version (3.99.2.1):
+    - Not starting smart card daemon before users are loaded in LDAP mode.
+    - Merging onmainwindow_part*.cpp into onmainwindow.cpp
+    - Support recent pulseuadio on windows
+    - removing %USERPROFILE%\.x2go\pulse\.pulse\%COMPUTERNAME%-runtime\pid
+      if exists under windows
+    - --user=<username> set username in session mode if this field is blank
+      in session settings.
+    - --autostart=<app> launch "app" by session start in "published
+      applications" mode
+
+  [ Daniel Lindgren ]
+  * New upstream version (3.99.2.1):
+    - Swedish i18n update for published applications.
+
+  [ Terje Andersen ]
+  * New upstream version (3.99.2.1):
+    - Norwegian (Bokmal) i18n update for published applications.
+
+  [ Stefan Baur ]
+  * New upstream version (3.99.2.1):
+    - German i18n update for published applications.
+
+  [ Mike Gabriel ]
+  * New upstream version (3.99.2.1):
+    - Add Ubuntu-2d (Unity) support to X2Go Client.
+
+ -- Mike Gabriel <mike.gabriel at das-netzwerkteam.de>  Fri, 08 Jun 2012 12:52:07 +0200
+
 x2goclient (3.99.2.0-0~x2go1) unstable; urgency=low
 
   [ Oleksandr Shneyder ]
diff --git a/desktop/x2goclient.desktop b/desktop/x2goclient.desktop
index 5e806a0..16f2040 100644
--- a/desktop/x2goclient.desktop
+++ b/desktop/x2goclient.desktop
@@ -1,6 +1,6 @@
 [Desktop Entry]
 Encoding=UTF-8
-Version=3.99.2.0
+Version=3.99.2.1
 Type=Application
 Name=X2Go Client
 Exec=/usr/bin/x2goclient
diff --git a/icons/128x128/unity.png b/icons/128x128/unity.png
new file mode 100644
index 0000000..e953c76
Binary files /dev/null and b/icons/128x128/unity.png differ
diff --git a/icons/16x16/unity.png b/icons/16x16/unity.png
new file mode 100644
index 0000000..f6fc88d
Binary files /dev/null and b/icons/16x16/unity.png differ
diff --git a/icons/32x32/unity.png b/icons/32x32/unity.png
new file mode 100644
index 0000000..c13cf9a
Binary files /dev/null and b/icons/32x32/unity.png differ
diff --git a/icons/64x64/unity.png b/icons/64x64/unity.png
new file mode 100644
index 0000000..3062e96
Binary files /dev/null and b/icons/64x64/unity.png differ
diff --git a/onmainwindow.cpp b/onmainwindow.cpp
index 4ba3231..6cbd6b4 100644
--- a/onmainwindow.cpp
+++ b/onmainwindow.cpp
@@ -56,6 +56,7 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent )
     cleanAllFiles=false;
     drawMenu=true;
     usePGPCard=false;
+    PGPInited=false;
     extLogin=false;
     startMaximized=false;
     startHidden=false;
@@ -268,7 +269,7 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent )
     }
 
 
-    if ( usePGPCard )
+    if ( usePGPCard  && !useLdap)
     {
         QTimer::singleShot ( 10, this, SLOT ( slotStartPGPAuth() ) );
     }
@@ -1035,8 +1036,8 @@ void ONMainWindow::trayIconInit()
             trayIconActiveConnectionMenu->addAction(tr ("Share folder..." ),this, SLOT(slotExportDirectory()));
             trayIconActiveConnectionMenu->addAction(tr("Suspend"),this, SLOT(slotSuspendSessFromSt()));
             trayIconActiveConnectionMenu->addAction(tr("Terminate"),this, SLOT(slotTermSessFromSt()));
-            connect (trayIconActiveConnectionMenu, SIGNAL(triggered(QAction*)), this, 
-		     SLOT(slotAppMenuTriggered(QAction*)));
+            connect (trayIconActiveConnectionMenu, SIGNAL(triggered(QAction*)), this,
+                     SLOT(slotAppMenuTriggered(QAction*)));
 
 
             if (sessionStatusDlg && sessionStatusDlg->isVisible())
@@ -1081,8 +1082,8 @@ QMenu* ONMainWindow::initTrayAppMenu(QString text, QPixmap icon)
 void ONMainWindow::slotAppMenuTriggered(QAction* action)
 {
     x2goDebug<<"slotAppMenuTriggered :"<<action->data().toString()<<endl;
-    if(action->data().toString() != "")
-      runApplication(action->data().toString());
+    if (action->data().toString() != "")
+        runApplication(action->data().toString());
 }
 
 void ONMainWindow::plugAppsInTray()
@@ -1095,18 +1096,18 @@ void ONMainWindow::plugAppsInTray()
     topActions.clear();
     foreach(Application app, applications)
     {
-      QAction* act;
-      if(app.category==Application::TOP)
-      {
-	 act=new QAction(app.icon,app.name,trayIconActiveConnectionMenu);
-         trayIconActiveConnectionMenu->insertAction(appSeparator, act);
-	 topActions.append(act);
-      }
-      else
-      {
-        act=appMenu[app.category]->addAction(app.icon,app.name);
-        appMenu[app.category]->menuAction()->setVisible(true);
-      }
+        QAction* act;
+        if (app.category==Application::TOP)
+        {
+            act=new QAction(app.icon,app.name,trayIconActiveConnectionMenu);
+            trayIconActiveConnectionMenu->insertAction(appSeparator, act);
+            topActions.append(act);
+        }
+        else
+        {
+            act=appMenu[app.category]->addAction(app.icon,app.name);
+            appMenu[app.category]->menuAction()->setVisible(true);
+        }
         act->setToolTip(app.comment);
         act->setData(app.exec);
         empty=false;
@@ -1128,8 +1129,8 @@ void ONMainWindow::removeAppsFromTray()
     }
     foreach (QAction* act, topActions)
     {
-      trayIconActiveConnectionMenu->removeAction(act);
-      delete act;
+        trayIconActiveConnectionMenu->removeAction(act);
+        delete act;
     }
     topActions.clear();
     appSeparator->setVisible(false);
@@ -1555,6 +1556,12 @@ void ONMainWindow::displayUsers()
                  SLOT ( slotSnameChanged ( const QString& ) ) );
     connect ( uname,SIGNAL ( textEdited ( const QString& ) ),this,
               SLOT ( slotUnameChanged ( const QString& ) ) );
+    if ( usePGPCard  && !PGPInited)
+    {
+        PGPInited=true;
+        x2goDebug<<"Users loaded, starting smart card daemon\n";
+        QTimer::singleShot ( 10, this, SLOT ( slotStartPGPAuth() ) );
+    }
 }
 
 void ONMainWindow::showPass ( UserButton* user )
@@ -2574,6 +2581,9 @@ void ONMainWindow::slotSelectedFromList ( SessionButton* session )
         userName=st.setting()->value (
                      sid+"/user",
                      ( QVariant ) QString::null ).toString();
+        if (defaultUser && userName.length()<1)
+            userName=defaultUserName;
+
         sshPort=st.setting()->value (
                     sid+"/sshport",
                     ( QVariant ) defaultSshPort ).toString();
@@ -2788,3 +2798,8045 @@ void ONMainWindow::slotSshConnectionError ( QString message, QString lastSession
 }
 
 
+
+
+void ONMainWindow::slotSshConnectionOk()
+{
+    x2goDebug<<"ssh connection ok"<<endl;
+    passForm->setEnabled ( true );
+    if ( useLdap )
+    {
+        continueLDAPSession();
+    }
+    else
+        continueNormalSession();
+}
+
+
+SshMasterConnection*  ONMainWindow::findServerSshConnection(QString host)
+{
+    for (int i=0;i<serverSshConnections.count();++i)
+    {
+        if (serverSshConnections[i])
+        {
+            if (serverSshConnections[i]->getHost()==host)
+                return serverSshConnections[i];
+        }
+    }
+    return 0l;
+}
+
+void ONMainWindow::slotServSshConnectionOk(QString server)
+{
+    SshMasterConnection* con=findServerSshConnection(server);
+    if (!con)
+        return;
+    SshProcess* lproc;
+    lproc=new SshProcess ( con,  this );
+    connect ( lproc,SIGNAL ( sshFinished ( bool,
+                                           QString,SshProcess* ) ),
+              this,SLOT (
+                  slotListAllSessions ( bool,
+                                        QString,SshProcess* ) ) );
+    x2goDebug<<"getting sessions on "<<server<<endl;
+    lproc->startNormal ( "export HOSTNAME && x2golistsessions" );
+}
+
+void ONMainWindow::slotSshServerAuthError ( int error, QString sshMessage )
+{
+    if ( startHidden )
+    {
+        startHidden=false;
+        slotResize();
+        show();
+        activateWindow();
+        raise();
+    }
+    QString errMsg;
+    switch ( error )
+    {
+    case SSH_SERVER_KNOWN_CHANGED:
+        errMsg=tr ( "Host key for server changed.\nIt is now: " ) +sshMessage+"\n"+
+               tr ( "For security reasons, connection will be stopped" );
+        if ( sshConnection )
+        {
+            sshConnection->wait();
+            delete sshConnection;
+            sshConnection=0l;
+        }
+        slotSshUserAuthError ( errMsg );
+        return;
+
+    case SSH_SERVER_FOUND_OTHER:
+        errMsg=tr ( "The host key for this server was not found but an other"
+                    "type of key exists.An attacker might change the default server key to"
+                    "confuse your client into thinking the key does not exist" );
+        if ( sshConnection )
+        {
+            sshConnection->wait();
+            delete sshConnection;
+            sshConnection=0l;
+        }
+        slotSshUserAuthError ( errMsg );
+        return ;
+
+    case SSH_SERVER_ERROR:
+        if ( sshConnection )
+        {
+            sshConnection->wait();
+            delete sshConnection;
+            sshConnection=0l;
+        }
+        slotSshUserAuthError ( errMsg );
+        return ;
+    case SSH_SERVER_FILE_NOT_FOUND:
+        errMsg=tr ( "Could not find known host file."
+                    "If you accept the host key here, the file will be automatically created" );
+        break;
+
+    case SSH_SERVER_NOT_KNOWN:
+        errMsg=tr ( "The server is unknown. Do you trust the host key?\nPublic key hash: " ) +sshMessage;
+        break;
+    }
+
+    if ( QMessageBox::warning ( this, tr ( "Host key verification failed" ),errMsg,tr ( "Yes" ), tr ( "No" ) ) !=0 )
+    {
+        if ( sshConnection )
+        {
+            sshConnection->wait();
+            delete sshConnection;
+            sshConnection=0l;
+        }
+        slotSshUserAuthError ( tr ( "Host key verification failed" ) );
+        return;
+    }
+    sshConnection->setAcceptUnknownServers ( true );
+    sshConnection->start();
+}
+
+void ONMainWindow::slotSshUserAuthError ( QString error )
+{
+    if ( sshConnection )
+    {
+        sshConnection->wait();
+        delete sshConnection;
+        sshConnection=0l;
+    }
+
+    QMessageBox::critical ( 0l,tr ( "Authentication failed" ),error,
+                            QMessageBox::Ok,
+                            QMessageBox::NoButton );
+// 	currentKey=QString::null;
+    setEnabled ( true );
+    passForm->setEnabled ( true );
+    slotShowPassForm();
+    pass->setFocus();
+    pass->selectAll();
+
+
+
+    passForm->setEnabled ( true );
+    if ( startHidden )
+    {
+        startHidden=false;
+        slotResize();
+        show();
+        activateWindow();
+        raise();
+    }
+}
+
+void ONMainWindow::slotSessEnter()
+{
+    if ( useLdap )
+    {
+        slotPassEnter();
+        return;
+    }
+    if (brokerMode)
+    {
+        if (!config.brokerAuthenticated)
+        {
+            x2goDebug<<"starting broker request";
+            slotStartBroker();
+            return;
+        }
+    }
+
+    resumingSession.sessionId=QString::null;
+    resumingSession.server=QString::null;
+    resumingSession.display=QString::null;
+    setStatStatus ( tr ( "connecting" ) );
+
+    QString sid="";
+    if ( !embedMode )
+        sid=lastSession->id();
+    startSession ( sid );
+}
+
+void ONMainWindow::continueNormalSession()
+{
+    x2goDebug<<"continue normal x2go session"<<endl;
+    if (brokerMode)
+    {
+        slotListSessions(true,QString::null,0);
+        return;
+    }
+    SshProcess* proc=new SshProcess ( sshConnection, this );
+    connect ( proc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
+              this,SLOT ( slotListSessions ( bool, QString,
+                                             SshProcess* ) ) );
+    if ( !shadowSession )
+        proc->startNormal ( "export HOSTNAME && x2golistsessions" );
+    else
+        proc->startNormal ( "export HOSTNAME && x2golistdesktops" );
+
+}
+
+void ONMainWindow::continueLDAPSession()
+{
+
+
+    SshProcess* proc=new SshProcess ( sshConnection,this );
+    connect ( proc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
+              this,SLOT ( slotGetServers ( bool, QString,SshProcess* ) ) );
+    proc->startNormal ( "x2gogetservers" );
+}
+
+
+bool ONMainWindow::startSession ( const QString& sid )
+{
+    setEnabled ( false );
+    QString passwd;
+    QString user;
+    QString host;
+    bool autologin=false;
+    bool krblogin=false;
+    user=getCurrentUname();
+    runRemoteCommand=true;
+    shadowSession=false;
+    applications.clear();
+    removeAppsFromTray();
+
+    if ( managedMode )
+    {
+        slotListSessions ( true, QString::null,0 );
+        return true;
+    }
+
+    if ( !embedMode && !brokerMode )
+    {
+
+        X2goSettings st ( "sessions" );
+
+        passForm->setEnabled ( false );
+        host=st.setting()->value ( sid+"/host",
+                                   ( QVariant ) QString::null ).toString();
+        QString cmd=st.setting()->value ( sid+"/command",
+                                          ( QVariant ) QString::null ).toString();
+        autologin=st.setting()->value ( sid+"/autologin",
+                                        ( QVariant ) false ).toBool();
+        krblogin=st.setting()->value ( sid+"/krblogin",
+                                       ( QVariant ) false ).toBool();
+        if ( cmd=="SHADOW" )
+            shadowSession=true;
+    }
+    else
+    {
+        host=config.server;
+        sshPort=config.sshport;
+        selectedCommand=config.command;
+    }
+    if (!brokerMode)
+        passwd=getCurrentPass();
+    else
+    {
+        currentKey=config.key;
+        host=config.server;
+        X2goSettings st ( config.iniFile, QSettings::IniFormat );
+        passForm->setEnabled ( false );
+        user=st.setting()->value ( sid+"/user",
+                                   ( QVariant ) QString::null ).toString();
+        login->setText(user);
+        sshPort=config.sshport;
+        /*        sshPort=st.setting()->value ( sid+"/sshport",
+                                              ( QVariant ) "22" ).toString();*/
+    }
+    if (sshConnection)
+        sshConnection->disconnectSession();
+    sshConnection=startSshConnection ( host,sshPort,acceptRsa,user,passwd,autologin, krblogin );
+    return true;
+}
+
+
+void ONMainWindow::slotListSessions ( bool result,QString output,
+                                      SshProcess* proc )
+{
+    if ( proc )
+        delete proc;
+    if ( result==false )
+    {
+        cardReady=false;
+        cardStarted=false;
+        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
+        if ( message.indexOf ( "publickey,password" ) !=-1 )
+        {
+            message=tr ( "<b>Wrong password!</b><br><br>" ) +
+                    message;
+        }
+
+        QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                QMessageBox::Ok,
+                                QMessageBox::NoButton );
+// 		currentKey=QString::null;
+        setEnabled ( true );
+        passForm->setEnabled ( true );
+        slotShowPassForm();
+        pass->setFocus();
+        pass->selectAll();
+        return;
+    }
+
+    passForm->hide();
+    if ( !embedMode )
+    {
+        setUsersEnabled ( false );
+        uname->setEnabled ( false );
+        u->setEnabled ( false );
+    }
+    if ( managedMode || brokerMode )
+    {
+        x2goDebug<<"sess data:"<<config.sessiondata;
+        if ( config.sessiondata.indexOf ( "|S|" ) ==-1 )
+        {
+            x2goDebug<<"start new managed session";
+            startNewSession();
+        }
+        else
+        {
+            x2goSession s=getSessionFromString (
+                              config.sessiondata );
+            x2goDebug<<"resuming managed session:"<<s.sessionId;
+            resumeSession ( s );
+        }
+        return;
+    }
+
+    QStringList sessions=output.trimmed().split ( '\n',
+                         QString::SkipEmptyParts );
+    if ( shadowSession )
+    {
+        selectSession ( sessions );
+    }
+    else
+    {
+        if ( ( sessions.size() ==0 ) ||
+                ( sessions.size() ==1&&sessions[0].length() <5 ) )
+            startNewSession();
+        else if ( sessions.size() ==1 )
+        {
+            x2goSession s=getSessionFromString ( sessions[0] );
+            QDesktopWidget wd;
+            if ( s.status=="S" && isColorDepthOk ( wd.depth(),
+                                                   s.colorDepth )
+                    &&s.command == selectedCommand )
+                resumeSession ( s );
+            else
+            {
+                if ( startHidden )
+                    startNewSession();
+                else
+                    selectSession ( sessions );
+            }
+        }
+        else
+        {
+            if ( !startHidden )
+                selectSession ( sessions );
+            else
+            {
+                for ( int i=0;i<sessions.size();++i )
+                {
+                    x2goSession s=getSessionFromString (
+                                      sessions[i] );
+                    QDesktopWidget wd;
+                    if ( s.status=="S" && isColorDepthOk (
+                                wd.depth(),s.colorDepth )
+                            &&s.command == selectedCommand )
+                    {
+                        resumeSession ( s );
+                        return;
+                    }
+                }
+                startNewSession();
+            }
+        }
+    }
+}
+
+
+x2goSession ONMainWindow::getSessionFromString ( const QString& string )
+{
+    QStringList lst=string.split ( '|' );
+    x2goSession s;
+    s.agentPid=lst[0];
+    s.sessionId=lst[1];
+    s.display=lst[2];
+    s.server=lst[3];
+    s.status=lst[4];
+    s.crTime=lst[5];
+    s.cookie=lst[6];
+    s.clientIp=lst[7];
+    s.grPort=lst[8];
+    s.sndPort=lst[9];
+    if ( lst.count() >13 )
+        s.fsPort=lst[13];
+    s.colorDepth=0;
+    if ( s.sessionId.indexOf ( "_dp" ) !=-1 )
+    {
+        s.colorDepth=s.sessionId.split ( "_dp" ) [1].toInt();
+    }
+    s.sessionType=x2goSession::DESKTOP;
+    s.command=tr ( "unknown" );
+    if ( s.sessionId.indexOf ( "_st" ) !=-1 )
+    {
+        QString cmdinfo=s.sessionId.split ( "_st" ) [1];
+        cmdinfo=cmdinfo.split ( "_" ) [0];
+        QChar st=cmdinfo[0];
+        if ( st=='R' )
+            s.sessionType=x2goSession::ROOTLESS;
+        if ( st=='S' )
+            s.sessionType=x2goSession::SHADOW;
+        QString command=cmdinfo.mid ( 1 );
+        if ( command.length() >0 )
+            s.command=command;
+    }
+    return s;
+}
+
+
+void ONMainWindow::startNewSession()
+{
+    newSession=true;
+    QString passwd=getCurrentPass();
+    QString user=getCurrentUname();
+
+    QString pack;
+    bool fullscreen;
+    int height;
+    int width;
+    int quality;
+    int speed;
+    bool usekbd;
+    bool rootless=false;
+    resumingSession.published=false;
+    bool setDPI=defaultSetDPI;
+    uint dpi=defaultDPI;
+    QString layout;
+    QString type;
+    QString command;
+    QString xdmcpServer;
+    runRemoteCommand=true;
+    QString host=QString::null;
+    runStartApp=true;
+    removeAppsFromTray();
+    if ( useLdap )
+    {
+        pack=defaultPack;
+        fullscreen=defaultFullscreen;
+        height=defaultHeight;
+        width=defaultWidth;
+        quality=defaultQuality;
+        speed=defaultLink;
+        usekbd=defaultSetKbd;
+        layout=defaultLayout[0];
+        type=defaultKbdType;
+        command=defaultCmd;
+        shadowSession=false;
+        for ( int j=0;j<x2goServers.size();++j )
+        {
+            if ( x2goServers[j].connOk )
+            {
+                host=x2goServers[j].name;
+                break;
+            }
+        }
+        if ( host==QString::null )
+        {
+            QMessageBox::critical ( 0l,tr ( "Error" ),
+                                    tr ( "No server availabel" ),
+                                    QMessageBox::Ok,
+                                    QMessageBox::NoButton );
+            return;
+        }
+        sshConnection=findServerSshConnection(host);
+        if (!sshConnection)
+        {
+            QMessageBox::critical ( 0l,tr ( "Error" ),
+                                    tr ( "Server not availabel" ),
+                                    QMessageBox::Ok,
+                                    QMessageBox::NoButton );
+            return;
+        }
+    }
+    else
+    {
+        X2goSettings* st;
+
+        if (!brokerMode)
+            st=new X2goSettings( "sessions" );
+        else
+            st= new X2goSettings(config.iniFile,QSettings::IniFormat);
+
+        QString sid;
+        if ( !embedMode )
+            sid=lastSession->id();
+        else
+            sid="embedded";
+        pack=st->setting()->value ( sid+"/pack",
+                                    ( QVariant ) defaultPack ).toString();
+        fullscreen=st->setting()->value ( sid+"/fullscreen",
+                                          ( QVariant )
+                                          defaultFullscreen ).toBool();
+        height=st->setting()->value ( sid+"/height",
+                                      ( QVariant ) defaultHeight ).toInt();
+        width=st->setting()->value ( sid+"/width",
+                                     ( QVariant ) defaultWidth ).toInt();
+        setDPI=st->setting()->value ( sid+"/setdpi",
+                                      ( QVariant ) defaultSetDPI ).toBool();
+        dpi=st->setting()->value ( sid+"/dpi",
+                                   ( QVariant ) defaultDPI ).toUInt();
+        quality=st->setting()->value (
+                    sid+"/quality",
+                    ( QVariant ) defaultQuality ).toInt();
+        speed=st->setting()->value ( sid+"/speed",
+                                     ( QVariant ) defaultLink ).toInt();
+
+        usekbd=st->setting()->value ( sid+"/usekbd",
+                                      ( QVariant ) defaultSetKbd ).toBool();
+        layout=st->setting()->value ( sid+"/layout",
+                                      ( QVariant )
+                                      defaultLayout[0] ).toString();
+        type=st->setting()->value ( sid+"/type",
+                                    ( QVariant )
+                                    defaultKbdType ).toString();
+        if ( !embedMode )
+        {
+            command=st->setting()->value ( sid+"/command",
+                                           ( QVariant ) defaultCmd ).toString();
+            host=st->setting()->value (
+                     sid+"/host",
+                     ( QVariant )
+                     ( QString ) "localhost" ).toString();
+
+            rootless=st->setting()->value ( sid+"/rootless",
+                                            ( QVariant ) false ).toBool();
+            resumingSession.published=st->setting()->value ( sid+"/published",
+                                      ( QVariant ) false ).toBool();
+            xdmcpServer=st->setting()->value ( sid+"/xdmcpserver",
+                                               ( QVariant )
+                                               "localhost" ).toString();
+        }
+        else
+        {
+            command=config.command;
+            rootless= config.rootless;
+            host=config.server;
+            startEmbedded=false;
+            if ( st->setting()->value ( sid+"/startembed",
+                                        ( QVariant ) true ).toBool() )
+            {
+                startEmbedded=true;
+                fullscreen=false;
+                height=bgFrame->size().height()-stb->height();
+                width=bgFrame->size().width();
+
+                if ( height<0 ||width<0 )
+                {
+                    height=defaultHeight;
+                    width=defaultWidth;
+                }
+            }
+            if ( config.confConSpd )
+                speed=config.conSpeed;
+            if ( config.confCompMet )
+                pack=config.compMet;
+            if ( config.confImageQ )
+                quality=config.imageQ;
+            if ( config.confDPI )
+            {
+                dpi=config.dpi;
+                setDPI=true;
+            }
+            if ( config.confKbd )
+            {
+                layout=config.kbdLay;
+                type=config.kbdType;
+                usekbd=true;
+            }
+        }
+        if ( command=="RDP" )
+            rootless=true;
+        if ( command=="XDMCP" )
+        {
+            runRemoteCommand=false;
+        }
+        delete st;
+    }
+
+
+    if ( shadowSession )
+    {
+        runRemoteCommand=false;
+    }
+
+    resumingSession.server=host;
+
+    if (defaultLayout.size()>0)
+        layout=cbLayout->currentText();
+
+
+    QString geometry;
+#ifdef Q_OS_WIN
+    x2goDebug<<"fullscreen: "<<fullscreen;
+    maximizeProxyWin=false;
+    proxyWinWidth=width;
+    proxyWinHeight=height;
+//#ifdef CFGCLIENT
+    xorgMode=WIN;
+    if (fullscreen)
+        xorgMode=FS;
+    if (rootless)
+        xorgMode=SAPP;
+    xorgWidth=QString::number(width);
+    xorgHeight=QString::number(height);
+    if (! startXorgOnStart)
+        startXOrg();
+//#endif
+#endif
+    if ( fullscreen )
+    {
+        geometry="fullscreen";
+#ifdef Q_OS_WIN
+//        fullscreen=false;
+        maximizeProxyWin=true;
+        x2goDebug<<"maximizeProxyWin: "<<maximizeProxyWin;
+#endif
+    }
+    if ( ! fullscreen )
+    {
+        geometry=QString::number ( width ) +"x"+
+                 QString::number ( height );
+        if ( embedMode )
+        {
+            QPoint position=mapToGlobal ( bgFrame->pos() );
+            geometry+="+"+QString::number ( position.x() ) +"+"+
+                      QString::number ( position.y() +
+                                        stb->height() );
+        }
+
+    }
+    QString link;
+    switch ( speed )
+    {
+    case MODEM:
+        link="modem";
+        break;
+    case ISDN:
+        link="isdn";
+        break;
+    case ADSL:
+        link="adsl";
+        break;
+    case WAN:
+        link="wan";
+        break;
+    case LAN:
+        link="lan";
+        break;
+    }
+
+    QFile file ( ":/txt/packs" );
+    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+        return;
+    QTextStream in ( &file );
+    while ( !in.atEnd() )
+    {
+        QString pc=in.readLine();
+        if ( pc.indexOf ( "-%" ) !=-1 )
+        {
+            pc=pc.left ( pc.indexOf ( "-%" ) );
+            if ( pc==pack )
+            {
+                pack+="-"+QString::number ( quality );
+                break;
+            }
+        }
+    }
+    file.close();
+
+
+    if ( selectSessionDlg->isVisible() )
+    {
+        if ( !embedMode )
+            slotCloseSelectDlg();
+        else
+            selectSessionDlg->hide();
+    }
+    QDesktopWidget wd;
+    QString depth=QString::number ( wd.depth() );
+#ifdef Q_OS_DARWIN
+    usekbd=0;
+    type="query";
+#endif
+    QString sessTypeStr="D ";
+    if ( rootless )
+        sessTypeStr="R ";
+    if ( shadowSession )
+        sessTypeStr="S ";
+    if ( resumingSession.published)
+    {
+        sessTypeStr="P ";
+        command="PUBLISHED";
+    }
+    QString dpiEnv;
+    QString xdmcpEnv;
+    if ( runRemoteCommand==false && command=="XDMCP" )
+        xdmcpEnv="X2GOXDMCP="+xdmcpServer+" ";
+    if ( setDPI )
+    {
+        dpiEnv="X2GODPI="+QString::number ( dpi ) +" ";
+    }
+    QString cmd=dpiEnv+xdmcpEnv+"x2gostartagent "+
+                geometry+" "+link+" "+pack+
+                " unix-kde-depth_"+depth+" "+layout+" "+type+" ";
+    if ( usekbd )
+        cmd += "1 ";
+    else
+        cmd += "0 ";
+    QFileInfo f ( command );
+    if ( !shadowSession )
+        cmd+=sessTypeStr+f.fileName();
+    else
+    {
+        cmd+=sessTypeStr+QString::number ( shadowMode ) +"XSHAD"+
+             shadowUser+"XSHAD"+shadowDisplay;
+    }
+    resumingSession.fullscreen=fullscreen;
+    x2goDebug<<cmd<<endl;
+    if ( managedMode )
+    {
+        slotRetResumeSess ( true,config.sessiondata,0 );
+        passForm->hide();
+        return;
+    }
+
+    SshProcess* proc=0l;
+
+    proc=new SshProcess ( sshConnection, this ) ;
+
+
+    connect ( proc,SIGNAL ( sshFinished ( bool, QString,SshProcess* ) ),
+              this,SLOT ( slotRetResumeSess ( bool,
+                                              QString,SshProcess* ) ) );
+
+    proc->startNormal ( cmd );
+    passForm->hide();
+}
+
+
+
+void ONMainWindow::resumeSession ( const x2goSession& s )
+{
+    newSession=false;
+    runStartApp=false;
+    applications.clear();
+    removeAppsFromTray();
+    QString passwd=getCurrentPass();
+    QString user=getCurrentUname();
+    QString host=s.server;
+    bool rootless=false;
+
+    QString pack;
+    bool fullscreen;
+    int height;
+    int width;
+    int quality;
+    int speed;
+    bool usekbd;
+    QString layout;
+    QString type;
+    removeAppsFromTray();
+
+    if ( useLdap )
+    {
+        pack=defaultPack;
+        fullscreen=defaultFullscreen;
+        height=defaultHeight;
+        width=defaultWidth;
+        quality=defaultQuality;
+        speed=defaultLink;
+        usekbd=defaultSetKbd;
+        layout=defaultLayout[0];
+        type=defaultKbdType;
+        sshConnection=findServerSshConnection(host);
+        if (!sshConnection)
+        {
+            QMessageBox::critical ( 0l,tr ( "Error" ),
+                                    tr ( "Server not availabel" ),
+                                    QMessageBox::Ok,
+                                    QMessageBox::NoButton );
+            return;
+        }
+    }
+    else
+    {
+
+        QString sid;
+        if ( !embedMode )
+            sid=lastSession->id();
+        else
+            sid="embedded";
+        X2goSettings* st;
+        if (!brokerMode)
+            st=new X2goSettings( "sessions" );
+        else
+            st=new X2goSettings(config.iniFile,QSettings::IniFormat);
+
+        pack=st->setting()->value ( sid+"/pack",
+                                    ( QVariant ) defaultPack ).toString();
+
+        fullscreen=st->setting()->value ( sid+"/fullscreen",
+                                          ( QVariant )
+                                          defaultFullscreen ).toBool();
+        height=st->setting()->value ( sid+"/height",
+                                      ( QVariant ) defaultHeight ).toInt();
+        width=st->setting()->value ( sid+"/width",
+                                     ( QVariant ) defaultWidth ).toInt();
+        quality=st->setting()->value ( sid+"/quality",
+                                       ( QVariant )
+                                       defaultQuality ).toInt();
+        speed=st->setting()->value ( sid+"/speed",
+                                     ( QVariant ) defaultLink ).toInt();
+        usekbd=st->setting()->value ( sid+"/usekbd",
+                                      ( QVariant ) defaultSetKbd ).toBool();
+        layout=st->setting()->value ( sid+"/layout",
+                                      ( QVariant )
+                                      defaultLayout[0] ).toString();
+        type=st->setting()->value ( sid+"/type",
+                                    ( QVariant )
+                                    defaultKbdType ).toString();
+        rootless=st->setting()->value ( sid+"/rootless",
+                                        ( QVariant ) false ).toBool();
+
+        if ( !embedMode )
+        {
+            host=st->setting()->value ( sid+"/host",
+                                        ( QVariant ) s.server ).toString();
+        }
+        else
+        {
+            startEmbedded=false;
+            if ( st->setting()->value ( sid+"/startembed",
+                                        ( QVariant ) true ).toBool() )
+            {
+                fullscreen=false;
+                startEmbedded=true;
+                height=bgFrame->size().height()-stb->height();
+                width=bgFrame->size().width();
+                if ( height<0 ||width<0 )
+                {
+                    height=defaultHeight;
+                    width=defaultWidth;
+                }
+            }
+            rootless=config.rootless;
+            host=config.server;
+            if ( config.confConSpd )
+                speed=config.conSpeed;
+            if ( config.confCompMet )
+                pack=config.compMet;
+            if ( config.confImageQ )
+                quality=config.imageQ;
+            if ( config.confKbd )
+            {
+                layout=config.kbdLay;
+                type=config.kbdType;
+                usekbd=true;
+            }
+        }
+        delete st;
+    }
+
+    if (defaultLayout.size()>0)
+        layout=cbLayout->currentText();
+
+    QString geometry;
+#ifdef Q_OS_WIN
+    maximizeProxyWin=false;
+    proxyWinWidth=width;
+    proxyWinHeight=height;
+// #ifdef CFGCLIENT
+    xorgMode=WIN;
+    if (fullscreen)
+        xorgMode=FS;
+    if (rootless)
+        xorgMode=SAPP;
+    xorgWidth=QString::number(width);
+    xorgHeight=QString::number(height);
+    if (! startXorgOnStart)
+        startXOrg();
+// #endif
+
+#endif
+    if ( fullscreen )
+    {
+        geometry="fullscreen";
+#ifdef Q_OS_WIN
+//        fullscreen=false;
+        maximizeProxyWin=true;
+        x2goDebug<<"maximizeProxyWin: "<<maximizeProxyWin;
+
+#endif
+    }
+    if ( !fullscreen )
+    {
+        geometry=QString::number ( width ) +"x"+
+                 QString::number ( height );
+    }
+    resumingSession.fullscreen=fullscreen;
+    QString link;
+    switch ( speed )
+    {
+    case MODEM:
+        link="modem";
+        break;
+    case ISDN:
+        link="isdn";
+        break;
+    case ADSL:
+        link="adsl";
+        break;
+    case WAN:
+        link="wan";
+        break;
+    case LAN:
+        link="lan";
+        break;
+    }
+
+    QFile file ( ":/txt/packs" );
+    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+        return;
+    QTextStream in ( &file );
+    while ( !in.atEnd() )
+    {
+        QString pc=in.readLine();
+        if ( pc.indexOf ( "-%" ) !=-1 )
+        {
+            pc=pc.left ( pc.indexOf ( "-%" ) );
+            if ( pc==pack )
+            {
+                pack+="-"+QString::number ( quality );
+                break;
+            }
+        }
+    }
+    file.close();
+
+#ifdef Q_OS_DARWIN
+    usekbd=0;
+    type="query";
+#endif
+
+    if (s.sessionId.indexOf("RPUBLISHED")!=-1)
+    {
+        resumingSession.published=true;
+        sbApps->setDisabled(true);
+    }
+    else
+        resumingSession.published=false;
+
+
+
+    if ( selectSessionDlg->isVisible() )
+    {
+        if ( !embedMode )
+            slotCloseSelectDlg();
+        else
+            selectSessionDlg->hide();
+    }
+    QString cmd="x2goresume-session "+s.sessionId+" "+geometry+
+                " "+link+" "+pack+" "+layout+
+                " "+type+" ";
+    if ( usekbd )
+        cmd += "1";
+    else
+        cmd += "0";
+
+    SshProcess* proc=0l;
+    proc=new SshProcess ( sshConnection, this );
+
+    connect ( proc,SIGNAL ( sshFinished ( bool, QString,SshProcess* ) ),
+              this,SLOT ( slotRetResumeSess ( bool, QString,
+                                              SshProcess* ) ) );
+
+    proc->startNormal ( cmd );
+    resumingSession=s;
+    passForm->hide();
+}
+
+
+void ONMainWindow::selectSession ( QStringList& sessions )
+{
+    setEnabled ( true );
+    sessionStatusDlg->hide();
+    passForm->hide();
+// 	x2goDebug<<"check type";
+    if ( !shadowSession )
+    {
+// 		x2goDebug<<"! shadow";
+        if ( !miniMode )
+            selectSesDlgLayout->setContentsMargins ( 25,25,10,10 );
+
+        bNew->show();
+        bSusp->show();
+        bTerm->show();
+        sOk->show();
+        sCancel->show();
+// 		x2goDebug<<"standart buttons ok";
+        desktopFilter->hide();
+        desktopFilterCb->hide();
+        bShadow->hide();
+        bShadowView->hide();
+        bCancel->hide();
+// 		x2goDebug<<"shadow buttons ok";
+// 		model->clear();
+        model->removeRows ( 0,model->rowCount() );
+        selectSessionLabel->setText ( tr ( "Select session:" ) );
+        selectedSessions.clear();
+        QFontMetrics fm ( sessTv->font() );
+        for ( int row = 0; row < sessions.size(); ++row )
+        {
+
+// 			x2goDebug<<"decoding sessionstr:"<<sessions[row];
+            x2goSession s=getSessionFromString ( sessions[row] );
+// 			x2goDebug<<"listing id:"<<s.sessionId;
+            selectedSessions.append ( s );
+            QStandardItem *item;
+
+            item= new QStandardItem ( s.display );
+            model->setItem ( row,S_DISPLAY,item );
+
+            if ( s.status=="R" )
+                item= new QStandardItem ( tr ( "running" ) );
+            else
+                item= new QStandardItem ( tr ( "suspended" ) );
+            model->setItem ( row,S_STATUS,item );
+
+            item= new QStandardItem ( transAppName ( s.command ) );
+            model->setItem ( row,S_COMMAND,item );
+
+            QString type=tr ( "Desktop" );
+            if ( s.sessionType==x2goSession::ROOTLESS )
+                type=tr ( "single application" );
+            if ( s.sessionType==x2goSession::SHADOW )
+                type=tr ( "shadow session" );
+
+            item= new QStandardItem ( type );
+            model->setItem ( row,S_TYPE,item );
+
+            item= new QStandardItem ( s.crTime );
+            model->setItem ( row,S_CRTIME,item );
+            item= new QStandardItem ( s.server );
+            model->setItem ( row,S_SERVER,item );
+            item= new QStandardItem ( s.clientIp );
+            model->setItem ( row,S_IP,item );
+            item= new QStandardItem ( s.sessionId );
+            model->setItem ( row,S_ID,item );
+            for ( int j=0;j<8;++j )
+            {
+                QString txt=
+                    model->index ( row,j ).data().toString();
+                if ( sessTv->header()->sectionSize ( j ) <
+                        fm.width ( txt ) +6 )
+                {
+                    sessTv->header()->resizeSection (
+                        j,fm.width ( txt ) +6 );
+                }
+            }
+        }
+    }
+    else
+    {
+        shadowMode=SHADOW_VIEWONLY;
+        selectedDesktops.clear();
+        selectedDesktops=sessions;
+        if ( sessions.size() ==0 )
+        {
+            QMessageBox::information ( this,tr ( "Information" ),
+                                       tr ( "No accessible desktop "
+                                            "found" ) );
+            slotCloseSelectDlg();
+            return;
+        }
+        sessTv->setModel ( ( QAbstractItemModel* ) modelDesktop );
+        desktopFilter->show();
+        desktopFilterCb->show();
+        sOk->hide();
+        sCancel->hide();
+        bShadow->show();
+        bCancel->show();
+        bShadowView->show();
+        desktopFilter->setText ( tr ( "Filter" ) );
+        sessions.sort();
+        if ( !miniMode )
+            selectSesDlgLayout->setContentsMargins ( 25,25,25,25 );
+        bNew->hide();
+        bSusp->hide();
+        bTerm->hide();
+        selectSessionLabel->setText ( tr ( "Select desktop:" ) );
+        filterDesktops ( "" );
+        desktopFilter->setFocus();
+        desktopFilter->selectAll();
+    }
+    selectSessionDlg->show();
+}
+
+void ONMainWindow::slotCloseSelectDlg()
+{
+    selectSessionDlg->hide();
+    if ( !embedMode )
+    {
+        u->setEnabled ( true );
+        uname->setEnabled ( true );
+    }
+    slotShowPassForm();
+}
+
+
+
+void ONMainWindow::slotActivated ( const QModelIndex& index )
+{
+    if ( !shadowSession )
+    {
+        QString status=sessTv->model()->index (
+                           index.row(),
+                           S_STATUS ).data().toString();
+        if ( status==tr ( "running" ) )
+        {
+            bSusp->setEnabled ( true );
+            sOk->setEnabled ( false );
+        }
+        else
+        {
+            bSusp->setEnabled ( false );
+            sOk->setEnabled ( true );
+        }
+        bTerm->setEnabled ( true );
+        if ( status==QString::null )
+        {
+            sOk->setEnabled ( false );
+            bTerm->setEnabled ( false );
+        }
+    }
+    else
+    {
+        QString user=sessTv->model()->index (
+                         index.row(),
+                         D_USER ).data().toString();
+        bShadowView->setEnabled ( true );
+        bShadow->setEnabled ( user==getCurrentUname() );
+    }
+}
+
+
+void ONMainWindow::slotResumeSess()
+{
+    x2goSession s=getSelectedSession();
+    QDesktopWidget wd;
+    if ( isColorDepthOk ( wd.depth(),s.colorDepth ) )
+        resumeSession ( s );
+    else
+    {
+        QString depth=QString::number ( s.colorDepth );
+        int res;
+        if ( s.colorDepth==24 || s.colorDepth==32 )
+        {
+            res=QMessageBox::warning (
+                    0l,tr ( "Warning" ),
+                    tr (
+                        "Your current color depth is "
+                        "different to the color depth of your "
+                        "x2go-session. This may cause problems "
+                        "reconnecting to this session and in most "
+                        "cases <b>you will loose the session</b> "
+                        "and have to start a new one! It's highly "
+                        "recommended to change the color depth of "
+                        "your Display to " ) +tr ( "24 or 32" ) +
+                    tr (
+                        " bit and restart your X-server before you "
+                        "reconnect to this x2go-session.<br>Resume "
+                        "this session anyway?" ),tr ( "Yes" ),
+                    tr ( "No" ) );
+
+        }
+        else
+        {
+            res=QMessageBox::warning (
+                    0l,tr ( "Warning" ),
+                    tr (
+                        "Your current color depth is different to "
+                        "the color depth of your x2go-session. "
+                        "This may cause problems reconnecting to "
+                        "this session and in most cases <b>you "
+                        "will loose the session</b> and have to "
+                        "start a new one! It's highly recommended "
+                        "to change the color depth of your "
+                        "Display to " ) +depth+
+                    tr (
+                        " bit and restart your X-server before you "
+                        "reconnect to this x2go-session.<br>Resume "
+                        "this session anyway?" ),tr ( "Yes" ),
+                    tr ( "No" ) );
+        }
+        if ( res==0 )
+            resumeSession ( s );
+    }
+
+}
+
+
+void ONMainWindow::slotSuspendSess()
+{
+
+    QString passwd;
+    QString user=getCurrentUname();
+
+    passwd=getCurrentPass();
+
+    selectSessionDlg->setEnabled ( false );
+
+
+    QString sessId=sessTv->model()->index (
+                       sessTv->currentIndex().row(),
+                       S_ID ).data().toString();
+    QString host=sessTv->model()->index (
+                     sessTv->currentIndex().row(),
+                     S_SERVER ).data().toString();
+    if ( !useLdap )
+    {
+        if ( !embedMode )
+        {
+            X2goSettings st ( "sessions" );
+            QString sid=lastSession->id();
+            host=st.setting()->value ( sid+"/host",
+                                       ( QVariant ) host ).toString();
+        }
+        else
+        {
+            host=config.server;
+        }
+    }
+    else
+    {
+        sshConnection=findServerSshConnection(host);
+        if (!sshConnection)
+        {
+            QMessageBox::critical ( 0l,tr ( "Error" ),
+                                    tr ( "Server not availabel" ),
+                                    QMessageBox::Ok,
+                                    QMessageBox::NoButton );
+            return;
+        }
+    }
+
+
+    suspendSession ( sessId );
+}
+
+
+void ONMainWindow::slotSuspendSessFromSt()
+{
+    QString passwd;
+    QString user=getCurrentUname();
+    passwd=getCurrentPass();
+    setStatStatus ( tr ( "suspending" ) );
+
+
+    sbExp->setEnabled ( false );
+
+    if ( !shadowSession )
+        suspendSession ( resumingSession.sessionId );
+    else
+        termSession ( resumingSession.sessionId,false );
+}
+
+void ONMainWindow::slotTermSessFromSt()
+{
+
+    /*	x2goDebug <<"disconnect export"<<endl;
+    	disconnect ( sbExp,SIGNAL ( clicked() ),this,
+    	             SLOT ( slot_exportDirectory() ) );*/
+    sbExp->setEnabled ( false );
+
+    if ( !shadowSession )
+    {
+        if ( termSession ( resumingSession.sessionId ) )
+            setStatStatus ( tr ( "terminating" ) );
+    }
+    else
+        termSession ( resumingSession.sessionId,false );
+}
+
+
+void ONMainWindow::slotRetSuspSess ( bool result, QString output,
+                                     SshProcess* proc )
+{
+    if ( proc )
+        delete proc;
+    if ( result==false )
+    {
+        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
+        if ( message.indexOf ( "publickey,password" ) !=-1 )
+        {
+            message=tr (
+                        "<b>Wrong password!</b><br><br>" ) +message;
+        }
+
+        QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                QMessageBox::Ok,
+                                QMessageBox::NoButton );
+    }
+    else
+    {
+        if ( selectSessionDlg->isVisible() )
+        {
+            ( ( QStandardItemModel* )
+              ( sessTv->model() ) )->item (
+                  sessTv->currentIndex().row(),
+                  S_STATUS )->setData (
+                      QVariant ( ( QString ) tr ( "suspended" ) ),
+                      Qt::DisplayRole );
+            bSusp->setEnabled ( false );
+            sOk->setEnabled ( true );
+
+        }
+    }
+    if ( selectSessionDlg->isVisible() )
+        selectSessionDlg->setEnabled ( true );
+}
+
+
+
+void ONMainWindow::slotTermSess()
+{
+
+    selectSessionDlg->setEnabled ( false );
+
+
+    QString sessId=sessTv->model()->index ( sessTv->currentIndex().row(),
+                                            S_ID ).data().toString();
+
+    if ( !useLdap )
+    {
+        if ( !embedMode )
+        {
+            X2goSettings st ( "sessions" );
+
+            QString sid=lastSession->id();
+        }
+    }
+    else
+    {
+        QString host=sessTv->model()->index ( sessTv->currentIndex().row(),
+                                              S_SERVER ).data().toString();
+
+        sshConnection=findServerSshConnection(host);
+        if (!sshConnection)
+        {
+            QMessageBox::critical ( 0l,tr ( "Error" ),
+                                    tr ( "Server not availabel" ),
+                                    QMessageBox::Ok,
+                                    QMessageBox::NoButton );
+            return;
+        }
+    }
+
+    termSession ( sessId );
+}
+
+
+void ONMainWindow::slotNewSess()
+{
+    startNewSession();
+}
+
+
+void ONMainWindow::slotRetTermSess ( bool result,  QString output,
+                                     SshProcess* proc )
+{
+    bool nodel= ( proc==0 );
+    if ( proc )
+        delete proc;
+    if ( result==false )
+    {
+        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
+        if ( message.indexOf ( "publickey,password" ) !=-1 )
+        {
+            message=tr (
+                        "<b>Wrong password!</b><br><br>" ) +message;
+        }
+
+        QMessageBox::critical ( 0l,tr ( "Error" ),
+                                message,QMessageBox::Ok,
+                                QMessageBox::NoButton );
+    }
+    else
+    {
+        if ( selectSessionDlg->isVisible() &&!nodel )
+        {
+            sessTv->model()->removeRow (
+                sessTv->currentIndex().row() );
+            slotActivated ( sessTv->currentIndex() );
+        }
+    }
+    if ( selectSessionDlg->isVisible() )
+        selectSessionDlg->setEnabled ( true );
+}
+
+void ONMainWindow::slotRetResumeSess ( bool result,
+                                       QString output,
+                                       SshProcess* proc )
+{
+    if ( proc )
+        delete proc;
+    x2goDebug<<"Agent output:"<<output;
+    if ( result==false )
+    {
+        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
+        if ( message.indexOf ( "publickey,password" ) !=-1 )
+        {
+            message=tr (
+                        "<b>Wrong Password!</b><br><br>" ) +message;
+        }
+        if ( output.indexOf ( "LIMIT" ) !=-1 )
+        {
+            QString sessions=output.mid (
+                                 output.indexOf ( "LIMIT" ) +6 );
+
+            message="Sessions limit reached:"+sessions;
+        }
+        if ( output.indexOf ( "ACCESS DENIED" ) !=-1 )
+        {
+            message="Access denied from user";
+        }
+
+        QMessageBox::critical ( 0l,tr ( "Error" ),
+                                message,QMessageBox::Ok,
+                                QMessageBox::NoButton );
+        slotShowPassForm();
+        return;
+    }
+
+    output.replace ( " ","" );
+    QString passwd=getCurrentPass();
+    QString user=getCurrentUname();
+    QString host;
+
+    bool sound=true;
+    int sndSystem=PULSE;
+    QString sndPort;
+#ifndef Q_OS_WIN
+    sndPort="4713";
+#endif
+    bool startSoundServer=true;
+    bool sshSndTunnel=true;
+
+    if ( useLdap )
+    {
+        sound=startSound;
+        startSoundServer=LDAPSndStartServer;
+        if ( LDAPSndSys=="arts" )
+            sndSystem=ARTS;
+        if ( LDAPSndSys=="esd" )
+            sndSystem=ESD;
+        sndPort=LDAPSndPort;
+    }
+    else
+    {
+        QString sid;
+        if ( !embedMode )
+            sid=lastSession->id();
+        else
+            sid="embedded";
+        X2goSettings st ( "sessions" );
+
+        sound=st.setting()->value ( sid+"/sound",
+                                    ( QVariant ) true ).toBool();
+        QString sndsys=st.setting()->value (
+                           sid+"/soundsystem",
+                           ( QVariant ) "pulse" ).toString();
+        if ( sndsys=="arts" )
+            sndSystem=ARTS;
+        if ( sndsys=="esd" )
+            sndSystem=ESD;
+#ifndef Q_OS_WIN
+        sndPort=st.setting()->value ( sid+"/sndport" ).toString();
+#endif
+        startSoundServer=st.setting()->value (
+                             sid+"/startsoundsystem",
+                             true ).toBool();
+
+        if ( embedMode&&config.confSnd )
+        {
+            sound=config.useSnd;
+        }
+
+
+#ifndef Q_OS_WIN
+        bool defPort=st.setting()->value ( sid+
+                                           "/defsndport",true ).toBool();
+        if ( defPort )
+        {
+            switch ( sndSystem )
+            {
+            case PULSE:
+                sndPort="4713";
+                break;
+            case ESD:
+                sndPort="16001";
+                break;
+            }
+        }
+#endif
+        sshSndTunnel=st.setting()->value ( sid+"/soundtunnel",
+                                           true ).toBool();
+
+#ifdef Q_OS_WIN
+        switch ( sndSystem )
+        {
+        case PULSE:
+            sndPort=QString::number ( pulsePort );
+            break;
+        case ESD:
+            sndPort=QString::number ( esdPort );
+            break;
+        }
+#endif
+    }
+
+    //Will be used in runCommand
+    startSessSound=sound;
+    startSessSndSystem=sndSystem;
+
+    if ( newSession )
+    {
+        QString sString=output.trimmed();
+        sString.replace ( '\n','|' );
+        host=resumingSession.server;
+        resumingSession=getNewSessionFromString ( sString );
+        resumingSession.server=host;
+        resumingSession.crTime=QDateTime::currentDateTime().toString (
+                                   "dd.MM.yy HH:mm:ss" );
+        if ( managedMode )
+        {
+            //replace session data for future resuming
+            config.sessiondata=resumingSession.agentPid+"|"+
+                               resumingSession.sessionId+"|"+
+                               resumingSession.display+"|"+
+                               resumingSession.server+"|"+
+                               "S|"+
+                               resumingSession.crTime+"|"+
+                               resumingSession.cookie+"|"+
+                               resumingSession.clientIp+"|"+
+                               resumingSession.grPort+"|"+
+                               resumingSession.sndPort+"|"+
+                               resumingSession.crTime+"|"+
+                               user+"|"+
+                               "0|"+
+                               resumingSession.fsPort;
+        }
+    }
+    else
+    {
+        host=resumingSession.server;
+        QStringList outputLines=output.split("\n",QString::SkipEmptyParts);
+        foreach(QString line,outputLines)
+        {
+            if (line.indexOf("gr_port=")!=-1)
+            {
+                resumingSession.grPort=line.replace("gr_port=","");
+                x2goDebug<<"new gr_port: "<<resumingSession.grPort<<endl;
+            }
+            if (line.indexOf("sound_port=")!=-1)
+            {
+                resumingSession.sndPort=line.replace("sound_port=","");
+                x2goDebug<<"new sound_port: "<<resumingSession.sndPort<<endl;
+            }
+            if (line.indexOf("fs_port=")!=-1)
+            {
+                resumingSession.fsPort=line.replace("fs_port=","");
+                x2goDebug<<"new fs_port: "<<resumingSession.fsPort<<endl;
+            }
+        }
+        if (resumingSession.published)
+            readApplications();
+    }
+    if ( !useLdap )
+    {
+        if ( !embedMode )
+        {
+            X2goSettings st ( "sessions" );
+
+            QString sid=lastSession->id();
+            host=st.setting()->value ( sid+"/host",
+                                       ( QVariant ) host ).toString();
+        }
+        else
+            host=config.server;
+        resumingSession.server=host;
+    }
+    tunnel=new SshProcess ( sshConnection, this );
+
+    connect ( tunnel,SIGNAL ( sshFinished ( bool,  QString,SshProcess* ) ),
+              this,SLOT ( slotTunnelFailed ( bool,
+                                             QString,SshProcess* ) ) );
+    connect ( tunnel,SIGNAL ( sshTunnelOk() ),
+              this,SLOT ( slotTunnelOk() ) );
+
+    localGraphicPort=resumingSession.grPort;
+    int iport=localGraphicPort.toInt() +1000;
+    while ( iport == resumingSession.sndPort.toInt() ||
+            iport == resumingSession.fsPort.toInt() ||
+            isServerRunning ( iport ) )
+        ++iport;
+    localGraphicPort=QString::number ( iport );
+
+    tunnel->startTunnel ( "localhost",resumingSession.grPort.toInt(),"localhost",
+                          localGraphicPort.toInt() );
+    if ( shadowSession )
+        return;
+
+    sndTunnel=0l;
+    if ( sound )
+    {
+        if ( sndSystem==PULSE )
+        {
+            startSoundServer=false;
+            QString scmd;
+            if ( !sshSndTunnel )
+                scmd="echo \"default-server=`echo "
+                     "$SSH_CLIENT | awk '{print $1}'`:"+
+                     sndPort+
+                     "\"> ~/.x2go/C-"+
+                     resumingSession.sessionId+
+                     "/.pulse-client.conf"
+                     ";echo \"cookie-file=.x2go/C-"+
+                     resumingSession.sessionId+
+                     "/.pulse-cookie"+
+                     "\">> ~/.x2go/C-"+
+                     resumingSession.sessionId+
+                     "/.pulse-client.conf";
+            else
+                scmd="echo \"default-server=localhost:"+
+                     resumingSession.sndPort+
+                     "\"> ~/.x2go/C-"+
+                     resumingSession.sessionId+
+                     "/.pulse-client.conf"
+                     ";echo \"cookie-file=.x2go/C-"+
+                     resumingSession.sessionId+
+                     "/.pulse-cookie"+
+                     "\">> ~/.x2go/C-"+
+                     resumingSession.sessionId+
+                     "/.pulse-client.conf";
+            SshProcess* paProc;
+            paProc=new SshProcess ( sshConnection, this );
+            paProc->startNormal ( scmd );
+
+            bool sysPulse=false;
+#ifdef Q_OS_LINUX
+            loadPulseModuleNativeProtocol();
+            QFile file ( "/etc/default/pulseaudio" );
+            if ( file.open ( QIODevice::ReadOnly |
+                             QIODevice::Text ) )
+            {
+
+                while ( !file.atEnd() )
+                {
+                    QByteArray line = file.readLine();
+                    int pos=line.indexOf (
+                                "PULSEAUDIO_SYSTEM_START=1"
+                            );
+                    if ( pos!=-1 )
+                    {
+                        int commentPos=line.indexOf (
+                                           "#" );
+                        if ( commentPos==-1 ||
+                                commentPos>pos )
+                        {
+                            sysPulse=true;
+                            break;
+                        }
+                    }
+                }
+                file.close();
+            }
+#endif
+            if ( sysPulse )
+                paProc->start_cp (
+                    "/var/run/pulse/.pulse-cookie",
+                    "~/.x2go/C-"+
+                    resumingSession.sessionId+
+                    "/.pulse-cookie" );
+            else
+            {
+#ifndef Q_OS_WIN
+                paProc->start_cp ( homeDir+"/.pulse-cookie",
+                                   "~/.x2go/C-"+
+                                   resumingSession.sessionId+
+                                   "/.pulse-cookie" );
+#else
+                QString cooFile=
+                    wapiShortFileName ( homeDir )  +
+                    "/.x2go/pulse/.pulse-cookie";
+                QString destFile="~/.x2go/C-"+
+                                 resumingSession.sessionId+
+                                 "/.pulse-cookie";
+                paProc->start_cp ( cooFile,
+                                   destFile );
+
+                /*x2goDebug<<"cookie file: "<<cooFile
+                <<" remote:"<<
+                destFile<<endl;*/
+                connect ( paProc,
+                          SIGNAL (
+                              sshFinished ( bool,
+                                            QString,
+                                            SshProcess* ) ),
+                          this,
+                          SLOT (
+                              slotPCookieReady ( bool,
+                                                 QString,
+                                                 SshProcess* )
+                          ) );
+                parecTunnelOk=true;
+#endif
+            }
+        }
+        if ( sndSystem==ESD )
+        {
+            SshProcess* paProc;
+            paProc=new SshProcess ( sshConnection, this );
+#ifndef Q_OS_WIN
+            paProc->start_cp ( homeDir+"/.esd_auth",
+                               "~/.esd_auth" );
+#else
+            QString cooFile=
+                wapiShortFileName ( homeDir )  +
+                "/.x2go/pulse/.esd_auth";
+            QString destFile="~/.esd_auth";
+            paProc->start_cp ( cooFile,
+                               destFile );
+#endif
+        }
+#ifndef Q_OS_WIN
+        if ( startSoundServer )
+        {
+            soundServer=new QProcess ( this );
+            QString acmd="artsd",ecmd="esd";
+#ifdef Q_OS_DARWIN
+            QStringList env = soundServer->environment();
+            QDir dir ( appDir );
+            dir.cdUp();
+            dir.cd ( "esd" );
+            env.insert ( 0,"DYLD_LIBRARY_PATH="+
+                         dir.absolutePath() );
+            soundServer->setEnvironment ( env );
+            ecmd="\""+dir.absolutePath() +"\"/esd";
+#endif //Q_OS_DARWIN
+            if ( sndSystem==ESD )
+                soundServer->start (
+                    ecmd+
+                    " -tcp -nobeeps -bind localhost -port "+
+                    resumingSession.sndPort );
+            if ( sndSystem==ARTS )
+                soundServer->start ( acmd+" -u -N -p "+
+                                     resumingSession.sndPort );
+            sndPort=resumingSession.sndPort;
+        }
+#endif //Q_OS_WIN
+        if ( sshSndTunnel )
+        {
+            sndTunnel=new SshProcess ( sshConnection, this );
+
+#ifdef Q_OS_WIN
+            if ( sndSystem==PULSE )
+            {
+                parecTunnelOk=false;
+                connect ( sndTunnel,SIGNAL ( sshTunnelOk() ),
+                          this,SLOT ( slotSndTunOk() ) );
+            }
+#endif
+            connect ( sndTunnel,SIGNAL ( sshFinished ( bool,
+                                         QString,
+                                         SshProcess* ) ),
+                      this,SLOT (
+                          slotSndTunnelFailed ( bool,
+                                                QString,
+                                                SshProcess* ) ) );
+
+            sndTunnel->startTunnel (
+                "localhost",
+                resumingSession.sndPort.toInt(),"127.0.0.1",
+                sndPort.toInt(),true );
+            /*x2goDebug<<"starting tunnel, local port:"<<
+            	sndPort<<", remote: "<<
+            	resumingSession.sndPort<<
+            	endl;*/
+        }
+    }
+}
+
+
+
+x2goSession ONMainWindow::getSelectedSession()
+{
+    QString sessId=sessTv->model()->index ( sessTv->currentIndex().row(),
+                                            S_ID ).data().toString();
+    for ( int i=0;i<selectedSessions.size();++i )
+    {
+        if ( selectedSessions[i].sessionId==sessId )
+            return selectedSessions[i];
+    }
+    return selectedSessions[0]; //warning !!!!! undefined session
+}
+
+
+void ONMainWindow::slotTunnelOk()
+{
+
+#ifdef Q_OS_WIN
+    //waiting for X
+    if ( !winServersReady )
+    {
+        x2goDebug<<"waiting for win-servers";
+        QTimer::singleShot ( 100, this, SLOT ( slotTunnelOk() ) );
+        return;
+    }
+#endif
+
+    showExport=false;
+    QString nxroot=homeDir +"/.x2go";
+    QString dirpath=nxroot+"/S-"+resumingSession.sessionId;
+    QDir d ( dirpath );
+    if ( !d.exists() )
+        if ( !d.mkpath ( dirpath ) )
+        {
+            QString message=tr ( "Unable to create folder:" ) +
+                            dirpath;
+            QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                    QMessageBox::Ok,
+                                    QMessageBox::NoButton );
+            slotShowPassForm();
+            if ( tunnel )
+                delete tunnel;
+            if ( sndTunnel )
+                delete sndTunnel;
+            if ( fsTunnel )
+                delete fsTunnel;
+            if ( soundServer )
+                delete soundServer;
+            tunnel=sndTunnel=fsTunnel=0l;
+            soundServer=0l;
+            nxproxy=0l;
+            return;
+        }
+#ifdef Q_OS_WIN
+    dirpath=wapiShortFileName ( dirpath );
+    nxroot=wapiShortFileName ( nxroot );
+#endif
+    QFile file ( dirpath+"/options" );
+    if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
+    {
+        QString message=tr ( "Unable to write file:" ) +
+                        dirpath+"/options";
+        QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                QMessageBox::Ok,
+                                QMessageBox::NoButton );
+        slotShowPassForm();
+        return;
+    }
+
+    QTextStream out ( &file );
+#ifdef Q_OS_WIN
+    dirpath=cygwinPath ( dirpath );
+    nxroot=cygwinPath ( nxroot );
+#endif
+    out << "nx/nx,root="<<nxroot<<",connect=localhost,cookie="<<
+    resumingSession.cookie<<",port="
+    <<localGraphicPort/*resumingSession.grPort*/<<
+    ",errors="<<dirpath<<"/sessions:"<<
+    resumingSession.display;
+    file.close();
+    xmodExecuted=false;
+
+
+    nxproxy=new QProcess;
+    QStringList env = QProcess::systemEnvironment();
+    QString x2golibpath="/usr/lib/x2go";
+#if defined ( Q_OS_WIN ) || defined ( Q_OS_DARWIN )
+    int dispInd=-1;
+#endif
+    for ( int l=0;l<env.size();++l )
+    {
+// 		x2goDebug<<env[l]<<endl;
+        if ( env[l].indexOf ( "X2GO_LIB" ) ==0 )
+        {
+            x2golibpath=env[l].split ( "=" ) [1];
+        }
+#if defined ( Q_OS_WIN ) || defined ( Q_OS_DARWIN )
+        if ( env[l].indexOf ( "DISPLAY" ) ==0 )
+        {
+            dispInd=l;
+        }
+#endif
+    }
+    env << "LD_LIBRARY_PATH="+x2golibpath;
+    env << "NX_CLIENT="+QCoreApplication::applicationFilePath ();
+
+#if defined ( Q_OS_WIN ) || defined ( Q_OS_DARWIN )
+    // On Mac OS X, we want to make sure that DISPLAY is set to a proper value,
+    // but at the same time don't want to set the value ourselves but keep
+    // the provided one.
+    QString disp=getXDisplay();
+    if ( disp==QString::null )
+    {
+        //slotProxyerror ( QProcess::FailedToStart );
+        return;
+    }
+#endif // Q_OS_WIN || Q_OS_DARWIN
+#if defined ( Q_OS_WIN )
+    if ( dispInd==-1 )
+    {
+        env <<"DISPLAY=localhost:"+disp;
+        /*		x2goDebug<<"new env DISPLAY"<<"DISPLAY=localhost:"+disp<<endl;*/
+    }
+    else
+    {
+        env[dispInd]="DISPLAY=localhost:"+disp;
+        /*		x2goDebug<<"existing env DISPLAY("<<dispInd<<
+        		") DISPLAY=localhost:"+disp<<endl;*/
+    }
+#endif // Q_OS_WIN
+#if defined ( Q_OS_DARWIN )
+    // setting /usr/X11/bin to find xauth
+    // /usr/X11R6/bin is added for compatibility reasons with OS X 10.4.
+    env.insert (
+        0,
+        "PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/X11R6/bin" );
+    // Set the NX base dir to bundle/exe/, used for finding nxauth.
+    {
+        QDir tmpDir (appDir);
+        tmpDir.cd ("../exe");
+        env.append ("NX_SYSTEM=" + tmpDir.absolutePath ());
+    }
+    if (dispInd == -1)
+    {
+        x2goDebug << "No DISPLAY variable found in global environment, using autodetected setting.";
+        env.append ("DISPLAY=" + disp);
+    }
+#endif
+    nxproxy->setEnvironment ( env );
+    /*	x2goDebug<<"new env:"<<endl;
+    	for ( int l=0;l<env.size();++l )
+    	{
+    		x2goDebug<<env[l]<<endl;
+    	}
+    	x2goDebug<<"##########################"<<endl;*/
+    connect ( nxproxy,SIGNAL ( error ( QProcess::ProcessError ) ),this,
+              SLOT ( slotProxyError ( QProcess::ProcessError ) ) );
+    connect ( nxproxy,SIGNAL ( finished ( int,QProcess::ExitStatus ) ),this,
+              SLOT ( slotProxyFinished ( int,QProcess::ExitStatus ) ) );
+    connect ( nxproxy,SIGNAL ( readyReadStandardError() ),this,
+              SLOT ( slotProxyStderr() ) );
+    connect ( nxproxy,SIGNAL ( readyReadStandardOutput() ),this,
+              SLOT ( slotProxyStdout() ) );
+
+    QString proxyCmd="nxproxy -S nx/nx,options="+dirpath+"/options:"+
+                     resumingSession.display;
+#ifdef Q_OS_DARWIN
+    //run nxproxy from bundle
+    QDir dir ( appDir );
+    dir.cdUp();
+    dir.cd ( "exe" );
+    proxyCmd="\""+dir.absolutePath() +"/\""+proxyCmd;
+#endif //Q_OS_DARWIN
+    x2goDebug<<"starting nxproxy with: "<<proxyCmd<<endl;
+    nxproxy->start ( proxyCmd );
+//always search for proxyWin
+    proxyWinTimer->start ( 300 );
+    if ( embedMode )
+    {
+//         proxyWinTimer->start ( 300 );
+        if ( !startEmbedded )
+        {
+            act_embedContol->setText (
+                tr ( "Attach X2Go window" ) );
+        }
+    }
+#ifdef Q_OS_WIN
+    else
+    {
+// #ifdef CFGCLIENT
+//         // if using XMing, we must find proxy win for case, that we should make it fullscreen
+        //         if(useInternalX&& (internalX==XMING))
+// #endif
+//         proxyWinTimer->start ( 300 );
+    }
+#endif
+
+    showSessionStatus();
+    QTimer::singleShot ( 30000,this,SLOT ( slotRestartProxy() ) );
+
+}
+
+void ONMainWindow::slotTunnelFailed ( bool result,  QString output,
+                                      SshProcess* )
+{
+    if ( result==false )
+    {
+        if ( !managedMode )
+        {
+            QString message=tr ( "Unable to create SSL tunnel:\n" )
+                            +output;
+            QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                    QMessageBox::Ok,
+                                    QMessageBox::NoButton );
+        }
+        if ( tunnel )
+            delete tunnel;
+        if ( sndTunnel )
+            delete sndTunnel;
+        if ( fsTunnel )
+            delete fsTunnel;
+        if ( soundServer )
+            delete soundServer;
+        tunnel=sndTunnel=fsTunnel=0l;
+        soundServer=0l;
+        nxproxy=0l;
+        if ( !managedMode )
+            slotShowPassForm();
+    }
+}
+
+void ONMainWindow::slotSndTunnelFailed ( bool result,  QString output,
+        SshProcess* )
+{
+    if ( result==false )
+    {
+        if ( !managedMode )
+        {
+            QString message=tr ( "Unable to create SSL Tunnel:\n" )
+                            +output;
+            QMessageBox::warning ( 0l,tr ( "Warning" ),message,
+                                   QMessageBox::Ok,
+                                   QMessageBox::NoButton );
+        }
+        if ( sndTunnel )
+            delete sndTunnel;
+        sndTunnel=0l;
+    }
+}
+
+
+
+void ONMainWindow::slotProxyError ( QProcess::ProcessError )
+{
+    slotProxyFinished ( -1,QProcess::CrashExit );
+}
+
+
+void ONMainWindow::slotProxyFinished ( int,QProcess::ExitStatus )
+{
+    if ( embedMode )
+    {
+        if ( proxyWinEmbedded )
+        {
+#ifdef CFGPLUGIN
+            detachClient();
+#endif
+        }
+        proxyWinTimer->stop();
+        setEmbedSessionActionsEnabled ( false );
+    }
+#ifdef Q_OS_WIN
+    else
+        proxyWinTimer->stop();
+// #ifdef CFGCLIENT
+    if (! startXorgOnStart)
+    {
+        if (xorg)
+        {
+            if (xorg->state() ==QProcess::Running)
+            {
+                xorg->terminate();
+                delete xorg;
+                xorg=0;
+            }
+        }
+    }
+// #endif
+#endif
+    if ( closeEventSent )
+        return;
+    if ( tunnel )
+        delete tunnel;
+    if ( sndTunnel )
+        delete sndTunnel;
+    if ( fsTunnel )
+        delete fsTunnel;
+    if ( soundServer )
+        delete soundServer;
+    if ( spoolTimer )
+        delete spoolTimer;
+
+    x2goDebug<<"deleting proxy"<<endl;
+    disconnect ( nxproxy,SIGNAL ( error ( QProcess::ProcessError ) ),this,
+                 SLOT ( slotProxyError ( QProcess::ProcessError ) ) );
+    disconnect ( nxproxy,SIGNAL ( finished ( int,QProcess::ExitStatus ) ),this,
+                 SLOT ( slotProxyFinished ( int,QProcess::ExitStatus ) ) );
+    disconnect ( nxproxy,SIGNAL ( readyReadStandardError() ),this,
+                 SLOT ( slotProxyStderr() ) );
+    disconnect ( nxproxy,SIGNAL ( readyReadStandardOutput() ),this,
+                 SLOT ( slotProxyStdout() ) );
+#ifndef CFGPLUGIN
+    if (trayEnabled)
+    {
+        trayIconActiveConnectionMenu->setTitle(tr("Not connected"));
+        trayIconActiveConnectionMenu->setEnabled(false);
+        if (trayMaxDiscon)
+            showNormal();
+    }
+    trayAutoHidden=false;
+#endif
+
+
+#if ! (defined(Q_OS_WIN) && defined (CFGPLUGIN))
+    if ( nxproxy )
+    {
+        if ( nxproxy->state() ==QProcess::Running )
+        {
+            x2goDebug<<"waiting for proxy to exit"<<endl;
+            if ( !nxproxy->waitForFinished ( 3000 ) )
+            {
+                x2goDebug<<"Failed, try to kill"<<endl;
+                nxproxy->kill();
+            }
+        }
+        x2goDebug<<"nxproxy not running"<<endl;
+        delete nxproxy;
+    }
+#endif
+    x2goDebug<<"proxy deleted"<<endl;
+    spoolTimer=0l;
+    tunnel=sndTunnel=fsTunnel=0l;
+    soundServer=0l;
+    nxproxy=0l;
+    proxyWinId=0;
+
+    if ( !shadowSession && !usePGPCard && ! ( embedMode &&
+            ( config.checkexitstatus==false ) ) )
+        check_cmd_status();
+    else
+        sshConnection->disconnectSession();
+    if ( startHidden )
+        close();
+
+    if ( readExportsFrom!=QString::null )
+    {
+        exportTimer->stop();
+        if ( extLogin )
+        {
+            currentKey=QString::null;
+        }
+    }
+    if ( printSupport )
+        cleanPrintSpool();
+    if ( !restartResume )
+    {
+        if ( !embedMode )
+        {
+            if (!brokerMode)
+            {
+                pass->setText ( "" );
+                QTimer::singleShot ( 2000,this,
+                                     SLOT ( slotShowPassForm() ) );
+            }
+            else
+                QTimer::singleShot ( 2000,broker,
+                                     SLOT ( getUserSessions() ) );
+
+        }
+    }
+    else
+    {
+        restartResume=false;
+        sessionStatusDlg->hide();
+        resumeSession ( resumingSession );
+    }
+    setStatStatus ( tr ( "Finished" ) );
+}
+
+
+void ONMainWindow::slotProxyStderr()
+{
+    QString reserr;
+    if ( nxproxy )
+        reserr= nxproxy->readAllStandardError();
+    x2goDebug<<reserr<<endl;
+    stInfo->insertPlainText ( reserr );
+    stInfo->ensureCursorVisible();
+    if ( stInfo->toPlainText().indexOf (
+                "Connecting to remote host 'localhost:"+
+                /*resumingSession.grPort*/ localGraphicPort ) !=-1 )
+        setStatStatus ( tr ( "connecting" ) );
+
+    if ( stInfo->toPlainText().indexOf (
+                "Connection to remote proxy 'localhost:"+
+                /*resumingSession.grPort*/
+                localGraphicPort+"' established" ) !=-1 )
+    {
+        if ( newSession )
+        {
+            setStatStatus ( tr ( "starting" ) );
+        }
+        else
+        {
+            setStatStatus ( tr ( "resuming" ) );
+        }
+    }
+
+    if ( stInfo->toPlainText().indexOf (
+                "Established X server connection" ) !=-1 )
+    {
+        setStatStatus ( tr ( "running" ) );
+#ifndef CFGPLUGIN
+        if (trayEnabled)
+        {
+            if (!useLdap)
+                trayIconActiveConnectionMenu->setTitle(lastSession->name());
+            else
+                trayIconActiveConnectionMenu->setTitle(lastUser->username());
+            trayIconActiveConnectionMenu->setEnabled(true);
+            if (trayMinCon && !trayAutoHidden)
+            {
+                trayAutoHidden=true;
+                hide();
+            }
+        }
+#endif
+        if ( embedMode )
+            setEmbedSessionActionsEnabled ( true );
+        disconnect ( sbSusp,SIGNAL ( clicked() ),this,
+                     SLOT ( slotTestSessionStatus() ) );
+        disconnect ( sbSusp,SIGNAL ( clicked() ),this,
+                     SLOT ( slotSuspendSessFromSt() ) );
+        connect ( sbSusp,SIGNAL ( clicked() ),this,
+                  SLOT ( slotSuspendSessFromSt() ) );
+        if ( !showExport )
+        {
+            showExport=true;
+            /*connect ( sbExp,SIGNAL ( clicked() ),this,
+              SLOT ( slot_exportDirectory() ) );*/
+            sbExp->setEnabled ( true );
+            exportDefaultDirs();
+            if ( readExportsFrom!=QString::null )
+            {
+                exportTimer->start ( 2000 );
+            }
+        }
+        sbSusp->setToolTip ( tr ( "Suspend" ) );
+        if ( newSession )
+        {
+            runCommand();
+            newSession=false;
+        }
+#ifdef 	Q_WS_HILDON
+        else
+        {
+            if ( !xmodExecuted )
+            {
+                xmodExecuted=true;
+                QTimer::singleShot (
+                    2000, this,
+                    SLOT ( slotExecXmodmap() ) );
+            }
+        }
+#endif
+    }
+    if ( stInfo->toPlainText().indexOf (
+                tr ( "Connection timeout, aborting" ) ) !=-1 )
+        setStatStatus ( tr ( "aborting" ) );
+#if defined( Q_OS_WIN ) && defined (CFGPLUGIN)
+    if ( reserr.indexOf ( "Session terminated at" ) !=-1 )
+    {
+        x2goDebug<<"proxy finished"<<endl;
+        slotProxyFinished ( 0, QProcess::NormalExit );
+    }
+#endif
+
+
+}
+
+
+void ONMainWindow::slotProxyStdout()
+{
+    QString resout ( nxproxy->readAllStandardOutput() );
+    x2goDebug<<resout<<endl;
+
+}
+
+
+void ONMainWindow::slotShowPassForm()
+{
+    if ( !useLdap )
+    {
+        loginPrompt->show();
+        login->show();
+    }
+    else
+    {
+        loginPrompt->hide();
+        login->hide();
+    }
+    setEnabled ( true );
+    if ( !embedMode )
+    {
+        u->hide();
+        uname->hide();
+    }
+    sessionStatusDlg->hide();
+    selectSessionDlg->hide();
+    setEnabled ( true );
+    if ( isPassShown )
+    {
+        passForm->show();
+        passForm->setEnabled ( true );
+    }
+    isPassShown=true;
+    login->setEnabled ( true );
+    if ( login->text().length() >0 )
+    {
+        pass->setFocus();
+        pass->selectAll();
+    }
+    else
+        login->setFocus();
+
+
+    if ( !embedMode )
+    {
+        u->setEnabled ( true );
+    }
+    else
+    {
+        if ( config.user.length() >0 )
+            login->setEnabled ( false );
+    }
+}
+
+
+void ONMainWindow::showSessionStatus()
+{
+    setStatStatus();
+}
+
+
+void ONMainWindow::slotShowAdvancedStat()
+{
+    if ( !miniMode )
+    {
+        if ( sbAdv->isChecked() )
+        {
+            sessionStatusDlg->setFixedSize (
+                sessionStatusDlg->width(),
+                sessionStatusDlg->height() *2 );
+        }
+        else
+        {
+            sessionStatusDlg->setFixedSize (
+                sessionStatusDlg->sizeHint() );
+            stInfo->hide();
+        }
+    }
+    else
+    {
+        if ( sbAdv->isChecked() )
+        {
+            sessionStatusDlg->setFixedSize ( 310,300 );
+        }
+        else
+        {
+            stInfo->hide();
+            sessionStatusDlg->setFixedSize ( 310,200 );
+        }
+    }
+
+
+// 	username->invalidate();
+
+
+    if ( sbAdv->isChecked() )
+    {
+        stInfo->show();
+    }
+
+    X2goSettings st ( "settings" );
+    st.setting()->setValue ( "showStatus",
+                             ( QVariant ) sbAdv->isChecked() );
+    st.setting()->sync();
+}
+
+
+
+
+void ONMainWindow::slotResumeDoubleClick ( const QModelIndex& )
+{
+    if ( !shadowSession )
+        slotResumeSess();
+}
+
+
+void ONMainWindow::suspendSession ( QString sessId )
+{
+    SshProcess* proc=0l;
+    proc=new SshProcess ( sshConnection, this );
+
+    connect ( proc,SIGNAL ( sshFinished ( bool,  QString,SshProcess* ) ),
+              this,SLOT ( slotRetSuspSess ( bool,  QString,
+                                            SshProcess* ) ) );
+
+    proc->startNormal ( "x2gosuspend-session "+sessId );
+}
+
+
+bool ONMainWindow::termSession ( QString sessId, bool warn )
+{
+    if ( warn )
+    {
+        bool hide_after=false;
+        if (isHidden())
+        {
+            showNormal();
+            hide_after=true;
+        }
+        int answer=QMessageBox::warning (
+                       this,tr ( "Warning" ),
+                       tr (
+                           "Are you sure you want to terminate "
+                           "this session?\n"
+                           "Unsaved documents will be lost" ),
+                       QMessageBox::Yes,QMessageBox::No );
+        if (hide_after)
+            hide();
+
+        if ( answer !=
+                QMessageBox::Yes )
+        {
+            slotRetTermSess ( true,QString::null,0 );
+            return false;
+        }
+    }
+    if ( shadowSession )
+    {
+        nxproxy->terminate();
+        return true;
+    }
+
+    SshProcess* proc=0l;
+    proc=new SshProcess ( sshConnection,  this );
+
+    connect ( proc,SIGNAL ( sshFinished ( bool,  QString,SshProcess* ) ),
+              this,SLOT ( slotRetTermSess ( bool,
+                                            QString,SshProcess* ) ) );
+
+    proc->startNormal ( "x2goterminate-session "+sessId );
+    return true;
+}
+
+
+
+void ONMainWindow::setStatStatus ( QString status )
+{
+    setEnabled ( true );
+    passForm->hide();
+    selectSessionDlg->hide();
+    if ( status == QString::null )
+        status=statusString;
+    else
+        statusString=status;
+    QString tstr;
+    if ( statusLabel )
+        statusLabel->setText ( QString::null );
+    if ( resumingSession.sessionId!=QString::null )
+    {
+        QString f="dd.MM.yy HH:mm:ss";
+        QDateTime dt=QDateTime::fromString ( resumingSession.crTime,f );
+        dt=dt.addYears ( 100 );
+        tstr=dt.toString();
+    }
+    if ( !embedMode || !proxyWinEmbedded )
+    {
+        statusBar()->showMessage ( "");
+#if ! (defined Q_OS_WIN && defined CFGPLUGIN)
+        statusBar()->hide();
+#endif
+        QString srv;
+        if ( embedMode )
+            srv=config.server;
+        else
+            srv=resumingSession.server;
+        slVal->setText ( resumingSession.sessionId+"\n"+
+                         srv+"\n"+
+                         getCurrentUname() +"\n"+
+                         resumingSession.display+
+                         "\n"+tstr+"\n"+status );
+
+        slVal->setFixedSize ( slVal->sizeHint() );
+        sessionStatusDlg->show();
+        if (resumingSession.published)
+            sbApps->show();
+        else
+            sbApps->hide();
+    }
+    else
+    {
+
+        QString srv=config.server;
+        QString message=getCurrentUname() +"@"+
+                        srv+
+                        ", "+tr ( "Session" ) +": "+
+                        resumingSession.sessionId+", "+
+                        tr ( "Display" ) +": "+
+                        resumingSession.display+", "+
+                        tr ( "Creation time" ) +": "+tstr;
+#if ! (defined Q_OS_WIN && defined CFGPLUGIN)
+        if ( statusLabel )
+        {
+            statusLabel->setText ( "   "+message );
+        }
+        else
+#endif
+        {
+            if ( config.showstatusbar )
+            {
+                statusBar()->show();
+                statusBar()->showMessage ( message );
+            }
+        }
+        sessionStatusDlg->hide();
+    }
+}
+
+
+void ONMainWindow::slotRestartProxy()
+{
+    if ( !sessionStatusDlg->isVisible() )
+        return;
+    if ( stInfo->toPlainText().indexOf (
+                "Established X server connection" ) ==-1 )
+    {
+        stInfo->insertPlainText (
+            tr (
+                "Connection timeout, aborting" ) );
+        if ( nxproxy )
+            nxproxy->terminate();
+        restartResume=true;
+    }
+}
+
+
+void ONMainWindow::slotTestSessionStatus()
+{
+
+    if ( !sessionStatusDlg->isVisible() )
+        return;
+    if ( stInfo->toPlainText().indexOf (
+                "Established X server connection" ) ==-1 )
+    {
+        stInfo->insertPlainText (
+            tr ( "Connection timeout, aborting" ) );
+        if ( nxproxy )
+            nxproxy->terminate();
+    }
+}
+
+
+x2goSession ONMainWindow::getNewSessionFromString ( const QString& string )
+{
+    QStringList lst=string.split ( '|' );
+    x2goSession s;
+    s.display=lst[0];
+    s.cookie=lst[1];
+    s.agentPid=lst[2];
+    s.sessionId=lst[3];
+    s.grPort=lst[4];
+    s.sndPort=lst[5];
+    if ( lst.count() >6 )
+        s.fsPort=lst[6];
+    return s;
+}
+
+
+void ONMainWindow::slotAppDialog()
+{
+    AppDialog dlg(this);
+    dlg.exec();
+}
+
+void ONMainWindow::runCommand()
+{
+    QString passwd=getCurrentPass();
+    QString user=getCurrentUname();
+    QString host=resumingSession.server;
+    QString command;
+    QString sessionType="D";
+    QString rdpOpts,rdpServer;
+    bool rdpFS=false;
+    QString rdpWidth;
+    QString rdpHeight;
+    bool rootless=false;
+    resumingSession.published=false;
+    if ( !embedMode )
+    {
+        X2goSettings* st;
+        if (!brokerMode)
+            st=new X2goSettings( "sessions" );
+        else
+            st=new X2goSettings(config.iniFile, QSettings::IniFormat);
+
+
+        if ( useLdap )
+            command=sessionCmd;
+        else
+        {
+            QString sid=lastSession->id();
+            command=st->setting()->value (
+                        sid+"/command",
+                        ( QVariant ) tr ( "KDE" ) ).toString();
+            rdpOpts=st->setting()->value (
+                        sid+"/rdpoptions",
+                        ( QVariant ) "" ).toString();
+            rdpServer=st->setting()->value (
+                          sid+"/rdpserver",
+                          ( QVariant ) "" ).toString();
+            rootless=st->setting()->value ( sid+"/rootless",
+                                            ( QVariant ) false ).toBool();
+            resumingSession.published=st->setting()->value ( sid+"/published",
+                                      ( QVariant ) false ).toBool();
+
+            rdpFS=st->setting()->value (
+                      sid+"/fullscreen",
+                      ( QVariant ) defaultFullscreen ).toBool();
+            rdpHeight=st->setting()->value (
+                          sid+"/height",
+                          ( QVariant ) defaultHeight ).toString();
+            rdpWidth=st->setting()->value (
+                         sid+"/width",
+                         ( QVariant ) defaultWidth ).toString();
+
+        }
+        delete st;
+    }
+    else
+    {
+        command=config.command;
+        rootless=config.rootless;
+    }
+    if ( rootless )
+        sessionType="R";
+    if ( resumingSession.published )
+    {
+        sessionType="P";
+        command="PUBLISHED";
+    }
+
+    if ( command=="KDE" )
+    {
+        command="startkde";
+    }
+    else if ( command=="GNOME" )
+    {
+        command="gnome-session";
+    }
+    else if ( command=="UNITY" )
+    {
+        command="unity";
+    }
+    else if ( command=="LXDE" )
+    {
+        command="startlxde";
+    }
+    else if ( command=="RDP" )
+    {
+        command="rdesktop ";
+        if ( rdpFS )
+            command+=" -f ";
+        else
+            command+=" -g "+rdpWidth+"x"+rdpHeight;
+        command+=" "+rdpOpts+ " "+rdpServer;
+
+        sessionType="R";
+    }
+
+    if ( managedMode )
+        return;
+
+    SshProcess *proc=0l;
+
+    QString cmd;
+
+    command.replace ( " ","X2GO_SPACE_CHAR" );
+
+    if ( !startSessSound  || startSessSndSystem==PULSE )
+    {
+        cmd="setsid x2goruncommand "+resumingSession.display+" "+
+            resumingSession.agentPid + " " +
+            resumingSession.sessionId+" "+
+            resumingSession.sndPort+ " "+ command+" nosnd "+
+            sessionType +">& /dev/null & exit";
+        if ( startSessSndSystem ==PULSE )
+        {
+            cmd="PULSE_CLIENTCONFIG=~/.x2go/C-"+
+                resumingSession.sessionId+
+                "/.pulse-client.conf "+cmd;
+        }
+    }
+    else
+    {
+        switch ( startSessSndSystem )
+        {
+        case ESD:
+            cmd="setsid x2goruncommand "+
+                resumingSession.display+" "+
+                resumingSession.agentPid + " " +
+                resumingSession.sessionId+" "+
+                resumingSession.sndPort+ " "+
+                command+" esd "+
+                sessionType +">& /dev/null & exit";
+            break;
+        case ARTS:
+            cmd="setsid x2goruncommand "+
+                resumingSession.display+" "+
+                resumingSession.agentPid + " " +
+                resumingSession.sessionId+" "+
+                resumingSession.sndPort+ " "+
+                command+" arts "+
+                sessionType +">& /dev/null & exit";
+            break;
+
+        }
+    }
+
+    if ( runRemoteCommand )
+    {
+        proc=new SshProcess ( sshConnection, this );
+        connect ( proc,SIGNAL ( sshFinished ( bool, QString,
+                                              SshProcess* ) ),
+                  this,SLOT ( slotRetRunCommand ( bool,
+                                                  QString,
+                                                  SshProcess* ) ) );
+
+        proc->startNormal ( cmd );
+    }
+#ifdef Q_WS_HILDON
+    //wait 5 seconds and execute xkbcomp
+    QTimer::singleShot ( 5000, this, SLOT ( slotExecXmodmap() ) );
+#endif
+}
+
+
+void ONMainWindow::runApplication(QString exec)
+{
+    SshProcess* proc=new SshProcess ( sshConnection, this );
+    proc->startNormal ("PULSE_CLIENTCONFIG=~/.x2go/C-"+
+                       resumingSession.sessionId+"/.pulse-client.conf DISPLAY=:"+
+                       resumingSession.display+
+                       " setsid "+exec+">& /dev/null & exit");
+}
+
+void ONMainWindow::slotRetRunCommand ( bool result, QString output,
+                                       SshProcess* proc )
+{
+    if ( proc )
+        delete proc;
+    if ( result==false )
+    {
+        QString message=tr ( "<b>Connection failed</b>\n:\n" ) +output;
+        if ( message.indexOf ( "publickey,password" ) !=-1 )
+        {
+            message=tr ( "<b>Wrong password!</b><br><br>" ) +
+                    message;
+        }
+        QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                QMessageBox::Ok,
+                                QMessageBox::NoButton );
+    }
+    else
+    {
+        if (resumingSession.published)
+            readApplications();
+    }
+}
+
+void ONMainWindow::readApplications()
+{
+    SshProcess* proc=new SshProcess ( sshConnection, this );
+    connect ( proc,SIGNAL ( sshFinished ( bool, QString,
+                                          SshProcess* ) ),
+              this,SLOT ( slotReadApplications ( bool,
+                                                 QString,
+                                                 SshProcess* ) ) );
+    proc->startNormal ( "x2gogetapps" );
+    sbApps->setEnabled(false);
+}
+
+void ONMainWindow::slotReadApplications(bool result, QString output,
+                                        SshProcess* proc )
+{
+    if ( proc )
+        delete proc;
+    if ( result==false )
+    {
+        QString message=tr ( "<b>Connection failed</b>\n:\n" ) +output;
+        if ( message.indexOf ( "publickey,password" ) !=-1 )
+        {
+            message=tr ( "<b>Wrong password!</b><br><br>" ) +
+                    message;
+        }
+        QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                QMessageBox::Ok,
+                                QMessageBox::NoButton );
+        return;
+    }
+    sbApps->setEnabled(true);
+    applications.clear();
+    QString locallong=QLocale::system().name();
+    QString localshort=QLocale::system().name().split("_")[0];
+    bool startAppFound=false;
+
+    foreach(QString appstr, output.split("</desktop>",QString::SkipEmptyParts))
+    {
+        bool localcomment=false;
+        bool localname=false;
+        Application app;
+        app.category=Application::OTHER;
+        QStringList lines=appstr.split("\n", QString::SkipEmptyParts);
+        for (int i=0; i<lines.count(); ++i)
+        {
+            QString line=lines[i];
+            if (line.indexOf("Name["+localshort+"]=")!=-1  || line.indexOf("Name["+locallong+"]=")!=-1)
+            {
+                app.name=QString::fromUtf8(line.split("=")[1].toAscii());
+//                 x2goDebug<<"local name: "<<app.name<<endl;
+                localname=true;
+            }
+            if (line.indexOf("Comment["+localshort+"]=")!=-1 || line.indexOf("Comment["+locallong+"]=")!=-1)
+            {
+                app.comment=QString::fromUtf8(line.split("=")[1].toAscii());
+//                 x2goDebug<<"local comment: "<<app.comment<<endl;
+                localcomment=true;
+            }
+            if (line.indexOf("Name=")!=-1 && !localname)
+            {
+                app.name=line.split("=")[1];
+                if (app.name==autostartApp)
+                    startAppFound=true;
+//                 x2goDebug<<"name: "<<app.name<<endl;
+            }
+            if (line.indexOf("Comment=")!=-1 && !localcomment)
+            {
+                app.comment=line.split("=")[1];
+//                 x2goDebug<<"comment: "<<app.comment<<endl;
+            }
+            if (line.indexOf("Exec=")!=-1)
+            {
+                app.exec=line.split("=")[1];
+                app.exec.replace(" %f","",Qt::CaseInsensitive);
+                app.exec.replace(" %u","",Qt::CaseInsensitive);
+                app.exec.replace("%f","",Qt::CaseInsensitive);
+                app.exec.replace("%u","",Qt::CaseInsensitive);
+                if (app.exec==autostartApp)
+                    startAppFound=true;
+//                 x2goDebug<<"exec: "<<app.exec<<endl;
+            }
+            if (line.indexOf("Categories=")!=-1)
+            {
+                if (line.indexOf("Audio")!=-1)
+                    app.category=Application::MULTIMEDIA;
+                if (line.indexOf("Vide")!=-1)
+                    app.category=Application::MULTIMEDIA;
+                if (line.indexOf("Development")!=-1)
+                    app.category=Application::DEVELOPMENT;
+                if (line.indexOf("Education")!=-1)
+                    app.category=Application::EDUCATION;
+                if (line.indexOf("Game")!=-1)
+                    app.category=Application::GAME;
+                if (line.indexOf("Graphics")!=-1)
+                    app.category=Application::GRAPHICS;
+                if (line.indexOf("Network")!=-1)
+                    app.category=Application::NETWORK;
+                if (line.indexOf("Office")!=-1)
+                    app.category=Application::OFFICE;
+                if (line.indexOf("Settings")!=-1)
+                    app.category=Application::SETTINGS;
+                if (line.indexOf("System")!=-1)
+                    app.category=Application::SYSTEM;
+                if (line.indexOf("Utility")!=-1)
+                    app.category=Application::UTILITY;
+                if (line.indexOf("X2Go-Top",0,Qt::CaseInsensitive)!=-1)
+                    app.category=Application::TOP;
+            }
+            if (line.indexOf("<icon>")!=-1)
+            {
+                bool isSvg=false;
+                line=lines[++i];
+                QByteArray pic;
+                while (line.indexOf("</icon>")==-1)
+                {
+                    pic+=QByteArray::fromBase64(line.toAscii());
+                    line=lines[++i];
+                    if (QString(QByteArray::fromBase64(line.toAscii())).indexOf("</svg>",Qt::CaseInsensitive)!=-1)
+                    {
+                        isSvg=true;
+                    }
+                }
+                if (!isSvg)
+                    app.icon.loadFromData(pic);
+                else
+                {
+                    QPixmap pix(32,32);
+                    QSvgRenderer svgRenderer( pic );
+                    QPainter pixPainter(&pix);
+                    svgRenderer.render(&pixPainter);
+                    app.icon=pix;
+                }
+            }
+        }
+        if (app.name.length()>0)
+        {
+            if (app.comment.length()<=0)
+                app.comment=app.name;
+            applications.append(app);
+        }
+    }
+
+    qSort(applications.begin(), applications.end(),Application::lessThen);
+    plugAppsInTray();
+    if (runStartApp && autostartApp.length()>1)
+    {
+        if (!startAppFound)
+            x2goDebug<<"Autostart application "<<autostartApp<< " not found in Desktop files"<<endl;
+        else
+            runApplication(autostartApp);
+    }
+}
+
+
+bool ONMainWindow::parseParameter ( QString param )
+{
+    if ( param=="--help" )
+    {
+        showHelp();
+        return false;
+    }
+
+    if ( param=="--help-pack" )
+    {
+        showHelpPack();
+        return false;
+    }
+
+    if ( param == "--portable" )
+    {
+        ONMainWindow::portable=true;
+        return true;
+    }
+    if ( param == "--clean-all-files" )
+    {
+        cleanAllFiles=true;
+        return true;
+    }
+    if (param == "--connectivity-test")
+    {
+        connTest=true;
+        return true;
+    }
+
+    if ( param=="--no-menu" )
+    {
+        drawMenu=false;
+        return true;
+    }
+
+    if ( param=="--maximize" )
+    {
+        startMaximized=true;
+        return true;
+    }
+    if ( param=="--xinerama" )
+    {
+        defaultXinerama=true;
+        return true;
+    }
+    if (param == "--thinclient")
+    {
+        thinMode=true;
+        startMaximized=true;
+        return true;
+    }
+    if (param == "--haltbt")
+    {
+        showHaltBtn=true;
+        return true;
+    }
+    if ( param=="--hide" )
+    {
+        startHidden=true;
+        return true;
+    }
+    if ( param=="--pgp-card" )
+    {
+        usePGPCard=true;
+        return true;
+    }
+    if ( param=="--ldap-printing" )
+    {
+        LDAPPrintSupport=true;
+        return true;
+    }
+    if ( param=="--add-to-known-hosts" )
+    {
+        acceptRsa=true;
+        return true;
+    }
+    if ( param=="--no-session-edit" )
+    {
+        noSessionEdit=true;
+        return true;
+    }
+    if ( param=="--change-broker-pass")
+    {
+        changeBrokerPass=true;
+        return true;
+    }
+
+
+    QString setting,value;
+    QStringList vals=param.split ( "=" );
+    if ( vals.size() <2 )
+    {
+        printError ( param );
+        return false;
+    }
+    setting=vals[0];
+    vals.removeFirst();
+    value=vals.join ( "=" );
+    if ( setting=="--link" )
+    {
+        return linkParameter ( value );
+    }
+    if ( setting=="--sound" )
+    {
+        return soundParameter ( value );
+    }
+    if ( setting=="--geometry" )
+    {
+        return geometry_par ( value );
+    }
+    if ( setting=="--pack" )
+    {
+        return packParameter ( value );
+    }
+    if ( setting=="--kbd-layout" )
+    {
+        defaultLayout=value.split(",",QString::SkipEmptyParts);
+        if (defaultLayout.size()==0)
+            defaultLayout<<tr("us");
+        return true;
+    }
+    if ( setting=="--session" )
+    {
+        defaultSession=true;
+        defaultSessionName=value;
+        return true;
+    }
+    if ( setting=="--session-conf" )
+    {
+        ONMainWindow::sessionCfg=value;
+        return true;
+    }
+    if ( setting=="--sessionid" )
+    {
+        defaultSession=true;
+        defaultSessionId=value;
+        return true;
+    }
+    if ( setting=="--user" )
+    {
+        defaultUser=true;
+        defaultUserName=value;
+        return true;
+    }
+    if ( setting=="--kbd-type" )
+    {
+        defaultKbdType=value;
+        return true;
+    }
+    if ( setting=="--set-kbd" )
+    {
+        return setKbd_par ( value );
+    }
+    if ( setting=="--ldap" )
+    {
+        return ldapParameter ( value );
+    }
+    if ( setting=="--ldap1" )
+    {
+        return ldap1Parameter ( value );
+    }
+    if ( setting=="--ldap2" )
+    {
+        return ldap2Parameter ( value );
+    }
+    if ( setting=="--command" )
+    {
+        defaultCmd=value;
+        return true;
+    }
+    if ( setting=="--read-exports-from" )
+    {
+        readExportsFrom=value;
+        return true;
+    }
+    if ( setting=="--external-login" )
+    {
+        extLogin=true;
+        readLoginsFrom=value;
+        return true;
+    }
+    if ( setting=="--ssh-port" )
+    {
+        defaultSshPort=value;
+        return true;
+    }
+    if ( setting=="--dpi" )
+    {
+        defaultSetDPI=true;
+        defaultDPI=value.toUInt();
+        return true;
+    }
+    if ( setting=="--client-ssh-port" )
+    {
+        clientSshPort=value;
+        return true;
+    }
+    if ( setting == "--embed-into" )
+    {
+        embedMode=true;
+        embedParent=value.toLong();
+        return true;
+    }
+    if ( setting == "--broker-url")
+    {
+        brokerMode=true;
+        noSessionEdit=true;
+        config.brokerurl=value;
+        return true;
+    }
+    if ( setting == "--broker-name")
+    {
+        config.brokerName=value;
+        return true;
+    }
+    if ( setting == "--autostart")
+    {
+        autostartApp=value;
+        return true;
+    }
+    if ( setting == "--auth-id")
+    {
+        QFile file(value);
+        if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+        {
+            printError ( param + tr(" (can't open file)"));
+            return false;
+        }
+        QTextStream in(&file);
+        config.brokerUserId = in.readLine();
+        return true;
+    }
+    if (setting == "--support-menu")
+    {
+        if (! QFile::exists(value))
+        {
+            printError( param + tr(" (file not exists)"));
+            return false;
+        }
+        supportMenuFile=value;
+        return true;
+    }
+    if (setting == "--background")
+    {
+        if (! QFile::exists(value))
+        {
+            printError( param + tr(" (file not exists)"));
+            return false;
+        }
+        BGFile=value;
+        return true;
+    }
+    if (setting == "--session-icon")
+    {
+        if (! QFile::exists(value))
+        {
+            printError( param + tr(" (file not exists)"));
+            return false;
+        }
+        SPixFile=value;
+        return true;
+    }
+    if (setting == "--home")
+    {
+        QDir dr;
+
+#ifdef Q_OS_WIN
+        int find=value.indexOf("(");
+        int lind=value.indexOf(")");
+        if (find!=-1 && lind !=-1)
+        {
+            QString label=value.mid(find+1,lind-find-1);
+            x2goDebug<< "searching for drive with label: "<<label;
+            QString drive=wapiGetDriveByLabel(label);
+            value.replace("("+label+")",drive);
+            x2goDebug<<"new path: "<<value;
+        }
+#endif
+        if (! dr.exists(value))
+        {
+            printError( param + tr(" (directory not exists)"));
+            return false;
+        }
+        homeDir=value;
+        portableDataPath=value;
+        return true;
+    }
+
+    printError ( param );
+    return false;
+}
+
+
+bool ONMainWindow::linkParameter ( QString value )
+{
+    if ( value=="modem" )
+        defaultLink=MODEM;
+    else if ( value=="isdn" )
+        defaultLink=ISDN;
+    else if ( value=="adsl" )
+        defaultLink=ADSL;
+    else if ( value=="wan" )
+        defaultLink=WAN;
+    else if ( value=="lan" )
+        defaultLink=LAN;
+    else
+    {
+        qCritical (
+            "%s",tr (
+                "wrong value for argument\"--link\""
+            ).toLocal8Bit().data() );
+        return false;
+    }
+    return true;
+
+}
+
+bool ONMainWindow::soundParameter ( QString val )
+{
+    if ( val=="1" )
+        defaultUseSound=true;
+    else if ( val=="0" )
+        defaultUseSound=false;
+    else
+    {
+        qCritical (
+            "%s",tr ( "wrong value for "
+                      "argument\"--sound\"" ).toLocal8Bit().data() );
+        return false;
+    }
+    return true;
+}
+
+bool ONMainWindow::geometry_par ( QString val )
+{
+    if ( val=="fullscreen" )
+        defaultFullscreen=true;
+    else
+    {
+        QStringList res=val.split ( "x" );
+        if ( res.size() !=2 )
+        {
+            qCritical (
+                "%s",tr (
+                    "wrong value for argument\"--geometry\"" ).
+                toLocal8Bit().data() );
+            return false;
+        }
+        bool o1,o2;
+        defaultWidth=res[0].toInt ( &o1 );
+        defaultHeight=res[1].toInt ( &o2 );
+        if ( ! ( defaultWidth >0 && defaultHeight >0 && o1 && o2 ) )
+        {
+            qCritical (
+                "%s",tr (
+                    "wrong value for argument\"--geometry\"" ).
+                toLocal8Bit().data() );
+            return false;
+        }
+    }
+    return true;
+}
+
+bool ONMainWindow::setKbd_par ( QString val )
+{
+    if ( val=="1" )
+        defaultSetKbd=true;
+    else if ( val=="0" )
+        defaultSetKbd=false;
+    else
+    {
+        qCritical (
+            "%s",tr (
+                "wrong value for argument\"--set-kbd\"" ).
+            toLocal8Bit().data() );
+        return false;
+    }
+    return true;
+}
+
+bool ONMainWindow::ldapParameter ( QString val )
+{
+    QString ldapstring=val;
+    useLdap=true;
+    ldapstring.replace ( "\"","" );
+    QStringList lst=ldapstring.split ( ':',QString::SkipEmptyParts );
+    if ( lst.size() !=3 )
+    {
+        qCritical (
+            "%s",tr (
+                "wrong value for argument\"--ldap\"" ).
+            toLocal8Bit().data() );
+        return false;
+    }
+    ldapOnly=true;
+    ldapServer=lst[0];
+    ldapPort=lst[1].toInt();
+    ldapDn=lst[2];
+
+
+    return true;
+}
+
+bool ONMainWindow::ldap1Parameter ( QString val )
+{
+    QString ldapstring=val;
+    ldapstring.replace ( "\"","" );
+    QStringList lst=ldapstring.split ( ':',QString::SkipEmptyParts );
+    if ( lst.size() !=2 )
+    {
+        qCritical (
+            "%s",tr (
+                "wrong value for argument\"--ldap1\"" ).
+            toLocal8Bit().data() );
+        return false;
+    }
+    ldapServer1=lst[0];
+    ldapPort1=lst[1].toInt();
+
+    return true;
+}
+
+bool ONMainWindow::ldap2Parameter ( QString val )
+{
+    QString ldapstring=val;
+    ldapstring.replace ( "\"","" );
+    QStringList lst=ldapstring.split ( ':',QString::SkipEmptyParts );
+    if ( lst.size() !=2 )
+    {
+        qCritical ( "%s",
+                    tr (
+                        "wrong value for argument\"--ldap2\"" ).
+                    toLocal8Bit().data() );
+        return false;
+    }
+    ldapServer2=lst[0];
+    ldapPort2=lst[1].toInt();
+
+    return true;
+}
+
+
+bool ONMainWindow::packParameter ( QString val )
+{
+
+    QFile file ( ":/txt/packs" );
+    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+        return true;
+    QTextStream in ( &file );
+    while ( !in.atEnd() )
+    {
+        QString pc=in.readLine();
+        if ( pc.indexOf ( "-%" ) !=-1 )
+        {
+            pc=pc.left ( pc.indexOf ( "-%" ) );
+
+            QStringList pctails=val.split ( "-" );
+            QString pcq=pctails[pctails.size()-1];
+            pctails.removeLast();
+
+            if ( pctails.join ( "-" ) ==pc )
+            {
+                bool ok;
+                int v=pcq.toInt ( &ok );
+                if ( ok && v>=0 && v<=9 )
+                {
+                    defaultPack=pc;
+                    defaultQuality=v;
+                    return true;
+                }
+                else
+                    break;
+            }
+        }
+        else
+        {
+            if ( pc==val )
+            {
+                defaultPack=val;
+                return true;
+            }
+        }
+    }
+    file.close();
+    qCritical ( "%s",tr ( "wrong value for argument\"--pack\"" ).
+                toLocal8Bit().data() );
+    return false;
+}
+
+
+void ONMainWindow::printError ( QString param )
+{
+    qCritical ( "%s", ( tr ( "wrong parameter: " ) +param ).
+                toLocal8Bit().data() );
+#ifdef Q_OS_WIN
+    x2goDebug<<tr ( "wrong parameter: " ) +param <<endl;
+#endif
+}
+
+void ONMainWindow::showHelp()
+{
+    QString helpMsg=
+        "Usage: x2goclient [Options]\n"
+        "Options:\n"
+        "--help\t\t\t\t show this message\n"
+        "--help-pack\t\t\t show available pack methods\n"
+        "--no-menu\t\t\t hide menu bar\n"
+        "--no-session-edit\t\t not allow user to edit preconfigured\n"
+        "\t\t\t\t sessions\n"
+        "--maximize\t\t\t start maximized\n"
+        "--hide\t\t\t\t start hidden\n"
+        "--portable\t\t\t start in \"portable\" mode\n"
+        "--pgp-card\t\t\t use openPGP card authentication\n"
+        "--xinerama\t\t\t use Xinerama by default\n"
+        "--ldap-printing\t\t\t allow client side printing in LDAP mode\n"
+        "--thinclient\t\t\t run without window manager\n"
+        "--haltbt\t\t\t show shutdown button\n"
+        "--add-to-known-hosts\t\t add RSA key fingerprint to "
+        ".ssh/known_hosts\n"
+        "\t\t\t\t if authenticity of server can't be established\n\n"
+        "--ldap=<host:port:dn> \t\t start with LDAP support. Example:\n"
+        "\t\t\t\t --ldap=ldapserver:389:o=organization,c=de\n\n"
+        "--ldap1=<host:port>\t\t LDAP failover server #1 \n"
+        "--ldap2=<host:port>\t\t LDAP failover server #2 \n"
+        "--ssh-port=<port>\t\t connect to this port, default 22\n"
+        "--client-ssh-port=<port>\t local ssh port (for fs export), "
+        "default 22\n"
+        "--command=<cmd>\t\t\t Set default command, default value 'KDE'\n"
+        "--session=<session>\t\t Start session 'session'\n"
+        "--user=<username>\t\t select user 'username'\n"
+        "--geomerty=<W>x<H>|fullscreen\t set default geometry, default "
+        "value '800x600'\n"
+        "--dpi=<dpi>\t\t\t set dpi of x2goagent to dpi, default not set\n"
+        "--link=<modem|isdn|adsl|wan|lan> set default link type, "
+        "default 'adsl'\n"
+        "--pack=<packmethod>\t\t set default pack method, default "
+        "'16m-jpeg-9'\n"
+        "--kbd-layout=<layout>\t\t set default keyboard layout or layouts\n"
+        "\t\t\t\t comma separated\n"
+        "--kbd-type=<typed>\t\t set default keyboard type\n"
+        "--home=<dir>\t\t\t set users home directory\n"
+        "--set-kbd=<0|1>\t\t\t overwrite current keyboard settings\n"
+        "--autostart=<app> \t\t launch \"app\" by session start in \"published "
+        "applications\" mode\n"
+        "--session-conf=<file>\t\t path to alternative session config\n";
+    qCritical ( "%s",helpMsg.toLocal8Bit().data() );
+    QMessageBox::information ( this,tr ( "Options" ),helpMsg );
+}
+
+void ONMainWindow::showHelpPack()
+{
+    qCritical ( "%s",tr (
+                    "Available pack methodes:" ).toLocal8Bit().data() );
+    QFile file ( ":/txt/packs" );
+    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+        return;
+    QTextStream in ( &file );
+    QString msg;
+    while ( !in.atEnd() )
+    {
+        QString pc=in.readLine();
+        if ( pc.indexOf ( "-%" ) !=-1 )
+        {
+            pc=pc.left ( pc.indexOf ( "-%" ) );
+            pc+="-[0-9]";
+        }
+        msg+=pc+"\n";
+        qCritical ( "%s",pc.toLocal8Bit().data() );
+    }
+    file.close();
+#ifdef Q_OS_WIN
+
+    QMessageBox::information ( this,tr ( "Options" ),msg );
+#endif
+
+}
+
+void ONMainWindow::slotGetServers ( bool result, QString output,
+                                    SshProcess* proc )
+{
+    if ( proc )
+        delete proc;
+    proc=0;
+    if ( result==false )
+    {
+        cardReady=false;
+        cardStarted=false;
+
+        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
+        if ( message.indexOf ( "publickey,password" ) !=-1 )
+        {
+            message=tr ( "<b>Wrong password!</b><br><br>" ) +
+                    message;
+        }
+
+        QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                QMessageBox::Ok,
+                                QMessageBox::NoButton );
+// 		currentKey=QString::null;
+        setEnabled ( true );
+        passForm->setEnabled ( true );
+        pass->setFocus();
+        pass->selectAll();
+        return;
+    }
+
+    passForm->hide();
+    setUsersEnabled ( false );
+    uname->setEnabled ( false );
+    u->setEnabled ( false );
+    QStringList servers=output.trimmed().split ( '\n' );
+    for ( int i=0;i<servers.size();++i )
+    {
+        QStringList lst=servers[i].simplified().split ( ' ' );
+        if ( lst.size() >1 )
+        {
+            for ( int j=0;j<x2goServers.size();++j )
+                if ( x2goServers[j].name==lst[0] )
+                {
+                    x2goServers[j].sess=
+                        lst[1].toInt() *
+                        x2goServers[j].factor;
+                    x2goDebug<<x2goServers[j].name<<
+                    ": sessions "<<
+                    lst[1].toInt() <<
+                    ", multiplied "<<x2goServers[j].sess;
+                    break;
+                }
+        }
+    }
+
+    qSort ( x2goServers.begin(),x2goServers.end(),serv::lt );
+
+    listedSessions.clear();
+    retSessions=0;
+    if (sshConnection)
+        sshConnection->disconnectSession();
+    QString passwd;
+    QString user=getCurrentUname();
+    passwd=getCurrentPass();
+    for (int i=0; i< serverSshConnections.count();++i)
+    {
+        if (serverSshConnections[i])
+            serverSshConnections[i]->disconnectSession();
+    }
+    serverSshConnections.clear();
+    for ( int j=0;j<x2goServers.size();++j )
+    {
+        QString host=x2goServers[j].name;
+        sshPort=x2goServers[j].sshPort;
+        serverSshConnections<<startSshConnection ( host,sshPort,acceptRsa,user,passwd,true,false,true);
+    }
+}
+
+
+void ONMainWindow::slotListAllSessions ( bool result,QString output,
+        SshProcess* proc )
+{
+    bool last=false;
+
+    ++retSessions;
+    if ( retSessions == x2goServers.size() )
+        last=true;
+    if ( proc )
+        delete proc;
+    proc=0;
+
+    if ( result==false )
+    {
+        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
+        if ( message.indexOf ( "publickey,password" ) !=-1 )
+        {
+            message=tr ( "<b>Wrong password!</b><br><br>" ) +
+                    message;
+        }
+
+        QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                QMessageBox::Ok,
+                                QMessageBox::NoButton );
+        QString sv=output.split ( ":" ) [0];
+        for ( int j=0;j<x2goServers.size();++j )
+        {
+            if ( x2goServers[j].name==sv )
+            {
+                x2goServers[j].connOk=false;
+            }
+        }
+    }
+    else
+    {
+        listedSessions+=output.trimmed().split ( '\n',
+                        QString::SkipEmptyParts );
+    }
+    if ( last )
+    {
+        if ( listedSessions.size() ==0||
+                ( listedSessions.size() ==1 &&
+                  listedSessions[0].length() <5 ) )
+        {
+// 	x2goDebug<<"start New Session";
+            startNewSession();
+        }
+        else if ( listedSessions.size() ==1 )
+        {
+// 	x2goDebug<<"have one session";
+            x2goSession s=getSessionFromString (
+                              listedSessions[0] );
+// 		x2goDebug<<"will procceed one session";
+            QDesktopWidget wd;
+            if ( s.status=="S" && isColorDepthOk (
+                        wd.depth(),s.colorDepth ) )
+                resumeSession ( s );
+            else
+            {
+// 				x2goDebug<<"select one Session";
+                selectSession ( listedSessions );
+            }
+        }
+        else
+        {
+            selectSession ( listedSessions );
+        }
+    }
+}
+
+void ONMainWindow::slotResize()
+{
+    if ( startHidden )
+    {
+        hide();
+        return;
+    }
+    if ( !startMaximized && !mwMax )
+    {
+        resize ( mwSize );
+        move ( mwPos );
+        show();
+    }
+    else
+        showMaximized();
+}
+
+void ONMainWindow::slotExportDirectory()
+{
+    if ( shadowSession )
+        return;
+
+    bool hide_after=false;
+    if (isHidden())
+    {
+        showNormal();
+        hide_after=true;
+    }
+    QString path;
+    if ( !useLdap && !embedMode )
+    {
+        ExportDialog dlg ( lastSession->id(),this );
+        if ( dlg.exec() ==QDialog::Accepted )
+            path=dlg.getExport();
+    }
+    else
+
+        path= QFileDialog::getExistingDirectory (
+                  this,QString::null,
+                  homeDir );
+    if (hide_after)
+        hide();
+#ifdef Q_OS_WIN
+    if ( ONMainWindow::getPortable() &&
+            ONMainWindow::U3DevicePath().length() >0 )
+    {
+        path.replace ( "(U3)",u3Device );
+    }
+
+    path=cygwinPath ( wapiShortFileName ( path ) );
+#endif
+    if ( path!=QString::null )
+        exportDirs ( path );
+}
+
+
+void ONMainWindow::exportDirs ( QString exports,bool removable )
+{
+    if ( shadowSession )
+        return;
+    if ( embedMode )
+    {
+        if ( config.confFS  && ! ( config.useFs ) )
+        {
+            return;
+        }
+    }
+    fsExportKeyReady=false;
+    directory dr;
+
+
+    dr.dirList=exports;
+    dr.key=createRSAKey();
+    QString passwd;
+    x2goDebug<<"key created on: "<<dr.key;
+
+    passwd=getCurrentPass();
+
+    fsInTun=false;
+    if ( !useLdap )
+    {
+        if ( !embedMode )
+        {
+            X2goSettings st ( "sessions" );
+
+            QString sid=lastSession->id();
+
+            fsInTun=st.setting()->value ( sid+"/fstunnel",
+                                          ( QVariant ) true ).toBool();
+        }
+        else
+            fsInTun=true;
+    }
+    if ( fsInTun )
+    {
+        if ( fsTunnel==0l )
+            if ( startSshFsTunnel() )
+                return;
+    }
+    SshProcess* lproc;
+    QString uname=getCurrentUname();
+    lproc=new SshProcess ( sshConnection, this );
+    connect ( lproc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
+              this,SLOT ( slotCopyKey ( bool, QString,SshProcess* ) ) );
+    QString dst=dr.key;
+    QString dhdir=homeDir+"/.x2go";
+#ifdef Q_OS_WIN
+    dhdir=wapiShortFileName ( dhdir );
+#endif
+    dst.replace ( dhdir +"/ssh/gen/","" );
+    dst="~"+uname +"/.x2go/ssh/"+dst;
+    dr.dstKey=dst;
+    dr.isRemovable=removable;
+    exportDir.append ( dr );
+    QString keyFile=dr.key;
+    lproc->start_cp ( keyFile,dst );
+
+}
+
+
+void ONMainWindow::exportDefaultDirs()
+{
+    QStringList dirs;
+    bool clientPrinting= ( useLdap && LDAPPrintSupport );
+
+    if ( !useLdap )
+    {
+        if ( !embedMode )
+        {
+
+            X2goSettings st ( "sessions" );
+            clientPrinting= st.setting()->value (
+                                lastSession->id() +
+                                "/print", true ).toBool();
+
+            QString exd=st.setting()->value (
+                            lastSession->id() +"/export",
+                            ( QVariant ) QString::null ).toString();
+            QStringList lst=exd.split ( ";",
+                                        QString::SkipEmptyParts );
+            for ( int i=0;i<lst.size();++i )
+            {
+#ifndef Q_OS_WIN
+                QStringList tails=lst[i].split (
+                                      ":",
+                                      QString::SkipEmptyParts );
+#else
+
+                QStringList tails=lst[i].split (
+                                      "#",
+                                      QString::SkipEmptyParts );
+#endif
+
+                if ( tails[1]=="1" )
+                {
+#ifdef Q_OS_WIN
+                    if ( ONMainWindow::getPortable() &&
+                            ONMainWindow::U3DevicePath (
+                            ).length() >0 )
+                    {
+                        tails[0].replace (
+                            "(U3)",u3Device );
+                    }
+
+                    tails[0]=cygwinPath (
+                                 wapiShortFileName (
+                                     tails[0] ) );
+#endif
+                    dirs+=tails[0];
+                }
+            }
+        }
+        else
+        {
+            clientPrinting=true;
+            if ( config.confFS )
+            {
+                clientPrinting=config.useFs;
+            }
+        }
+    }
+
+    if ( clientPrinting )
+    {
+        QString path= homeDir +
+                      "/.x2go/S-"+
+                      resumingSession.sessionId +"/spool";
+        QDir spooldir;
+        if ( !spooldir.exists ( path ) )
+        {
+            if ( !spooldir.mkpath ( path ) )
+            {
+                QString message=
+                    tr (
+                        "Unable to create folder:" ) + path;
+                QMessageBox::critical ( 0l,tr (
+                                            "Error" ),message,
+                                        QMessageBox::Ok,
+                                        QMessageBox::NoButton );
+
+            }
+        }
+        spoolDir=path;
+#ifdef Q_OS_WIN
+        path=cygwinPath (
+                 wapiShortFileName (
+                     path ) );
+#endif
+        QFile::setPermissions (
+            path,QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner );
+
+        path+="__PRINT_SPOOL_";
+        dirs+=path;
+        printSupport=true;
+        if ( spoolTimer )
+            delete spoolTimer;
+        spoolTimer=new QTimer ( this );
+        connect ( spoolTimer,SIGNAL ( timeout() ),this,
+                  SLOT ( slotCheckPrintSpool() ) );
+        spoolTimer->start ( 2000 );
+    }
+    if ( dirs.size() <=0 )
+        return;
+    exportDirs ( dirs.join ( ":" ) );
+}
+
+QString ONMainWindow::createRSAKey()
+{
+    QDir dr;
+    QString keyPath=homeDir +"/.x2go/ssh/gen";
+    dr.mkpath ( keyPath );
+#ifdef Q_OS_WIN
+    keyPath=wapiShortFileName ( keyPath );
+#endif
+    QTemporaryFile fl ( keyPath+"/key" );
+    fl.open();
+    QString keyName=fl.fileName();
+    fl.setAutoRemove ( false );
+    fl.close();
+    fl.remove();
+
+    QStringList args;
+
+    args<<"-t"<<"rsa"<<"-b"<<"1024"<<"-N"<<""<<"-f"<<keyName;
+// 	x2goDebug <<keyName<<endl;
+
+    if ( QProcess::execute ( "ssh-keygen",args ) !=0 )
+    {
+        x2goDebug <<"ssh-keygen failed" <<endl;
+        return QString::null;
+    }
+// 	x2goDebug <<"ssh-keygen ok" <<endl;
+
+    QFile rsa ( "/etc/ssh/ssh_host_rsa_key.pub" );
+#ifdef Q_OS_WIN
+    rsa.setFileName (
+        wapiShortFileName (
+            homeDir+"\\.x2go\\etc\\ssh_host_dsa_key.pub" ) );
+#else
+    if ( userSshd )
+        rsa.setFileName ( homeDir+"/.x2go/etc/ssh_host_dsa_key.pub" );
+
+#endif
+
+#ifdef Q_OS_DARWIN
+    rsa.setFileName ( "/etc/ssh_host_rsa_key.pub" );
+#endif
+    if ( !rsa.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+    {
+#ifdef Q_OS_LINUX
+        generateHostDsaKey();
+        generateEtcFiles();
+        startSshd();
+        rsa.setFileName ( homeDir+"/.x2go/etc/ssh_host_dsa_key.pub" );
+        rsa.open ( QIODevice::ReadOnly | QIODevice::Text );
+#else
+        printSshDError();
+        return QString::null;
+#endif
+    }
+
+    QByteArray rsa_pub;
+
+    if ( !rsa.atEnd() )
+        rsa_pub = rsa.readLine();
+    else
+    {
+        x2goDebug<<"error: rsa file empty";
+        return QString::null;
+    }
+
+    QFile file ( keyName );
+    if ( !file.open (
+                QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append )
+       )
+    {
+        x2goDebug<<"error openning key:"<<keyName;
+        return keyName;
+    }
+    QTextStream out ( &file );
+    out<<"----BEGIN RSA IDENTITY----"<<rsa_pub;
+    file.close();
+    return keyName;
+}
+
+void ONMainWindow::slotCopyKey ( bool result, QString output, SshProcess* proc )
+{
+    fsExportKey=proc->getSource();
+    if ( proc )
+        delete proc;
+    proc=0;
+    x2goDebug<<"exported key "<<fsExportKey;
+    QFile::remove ( fsExportKey );
+    x2goDebug<<"key removed";
+    if ( result==false )
+    {
+        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
+        if ( message.indexOf ( "publickey,password" ) !=-1 )
+        {
+            message=tr ( "<b>Wrong password!</b><br><br>" ) +
+                    message;
+        }
+
+        QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                QMessageBox::Ok,
+                                QMessageBox::NoButton );
+        QFile::remove ( fsExportKey+".pub" );
+        return;
+    }
+    fsExportKeyReady=true;
+
+    //start reverse mounting if RSA Key and FS tunnel are ready
+    //start only once from slotFsTunnelOk() or slotCopyKey().
+    if ( !fsInTun || fsTunReady )
+        startX2goMount();
+
+}
+
+directory* ONMainWindow::getExpDir ( QString key )
+{
+    for ( int i=0;i<exportDir.size();++i )
+    {
+        if ( exportDir[i].key==key )
+            return &exportDir[i];
+    }
+    return 0l;
+}
+
+
+
+
+void ONMainWindow::slotRetExportDir ( bool result,QString output,
+                                      SshProcess* proc )
+{
+
+    QString key;
+    for ( int i=0;i<exportDir.size();++i )
+        if ( exportDir[i].proc==proc )
+        {
+            key=exportDir[i].key;
+            exportDir.removeAt ( i );
+            break;
+        }
+
+    if ( proc )
+        delete proc;
+
+    if ( result==false )
+    {
+        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
+        if ( message.indexOf ( "publickey,password" ) !=-1 )
+        {
+            message=tr ( "<b>Wrong password!</b><br><br>" ) +
+                    message;
+        }
+
+        QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                QMessageBox::Ok,
+                                QMessageBox::NoButton );
+    }
+    QFile file ( key+".pub" );
+    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+    {
+        printSshDError();
+        QFile::remove
+        ( key+".pub" );
+        return;
+    }
+
+    QByteArray line = file.readLine();
+    file.close();
+    QString authofname=homeDir;
+#ifdef Q_OS_WIN
+    QDir dir;
+    dir.mkpath ( authofname+"\\.x2go\\.ssh" );
+    x2goDebug<<"Creating "<<authofname+"\\.x2go\\.ssh"<<endl;
+    authofname=wapiShortFileName ( authofname ) +"/.x2go";
+#endif
+    authofname+="/.ssh/authorized_keys" ;
+    file.setFileName ( authofname );
+    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+    {
+        printSshDError();
+        QFile::remove
+        ( key+".pub" );
+        return;
+    }
+
+
+    QTemporaryFile tfile ( authofname );
+    tfile.open();
+    tfile.setAutoRemove ( true );
+    QTextStream out ( &tfile );
+
+    while ( !file.atEnd() )
+    {
+        QByteArray newline = file.readLine();
+        if ( newline!=line )
+            out<<newline;
+    }
+    file.close();
+    tfile.close();
+    file.remove();
+    tfile.copy ( authofname );
+    QFile::remove
+    ( key+".pub" );
+}
+
+
+
+void ONMainWindow::exportsEdit ( SessionButton* bt )
+{
+    EditConnectionDialog dlg ( bt->id(),this,3 );
+    if ( dlg.exec() ==QDialog::Accepted )
+    {
+        bt->redraw();
+        bool vis=bt->isVisible();
+        placeButtons();
+        users->ensureVisible ( bt->x(),bt->y(),50,220 );
+        bt->setVisible ( vis );
+    }
+}
+
+
+void ONMainWindow::slotExtTimer()
+{
+
+    if ( QFile::permissions ( readLoginsFrom ) !=
+            ( QFile::ReadUser|QFile::WriteUser|QFile::ExeUser|
+              QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner ) )
+    {
+        x2goDebug <<"Wrong permissions on "<<readLoginsFrom <<":"<<endl;
+        x2goDebug << ( int ) ( QFile::permissions (
+                                   readLoginsFrom+"/." ) )
+        <<"must be"<< ( int ) ( QFile::ReadUser|QFile::WriteUser
+                                |QFile::ExeUser|QFile::ReadOwner|
+                                QFile::WriteOwner|
+                                QFile::ExeOwner ) <<endl;
+        if ( extLogin )
+            extTimer->stop();
+        return;
+    }
+    QString loginDir;
+    QString logoutDir;
+    QDir dir ( readLoginsFrom );
+    QStringList list = dir.entryList ( QDir::Files );
+    for ( int i=0;i<list.size();++i )
+    {
+        QFile file ( readLoginsFrom+"/"+list[i] );
+        if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+            continue;
+        if ( !file.atEnd() )
+        {
+            QByteArray line = file.readLine();
+            QString ln ( line );
+            QStringList args=ln.split ( "=",
+                                        QString::SkipEmptyParts );
+            if ( args.size() >1 )
+            {
+                if ( args[0]=="login" )
+                {
+                    args[1].replace ( "\n","" );
+                    if ( args[1].size() )
+                        loginDir=args[1];
+                }
+                if ( args[0]=="logout" )
+                {
+                    x2goDebug <<
+                    " I HAVE external logout"<<
+                    endl;
+                    args[1].replace ( "\n","" );
+                    if ( args[1].size() )
+                        logoutDir=args[1];
+                }
+            }
+        }
+        file.close();
+        file.remove();
+    }
+    if ( exportTimer->isActive() ) //running session
+    {
+        if ( logoutDir != QString::null )
+        {
+            x2goDebug <<"external logout"<<endl;
+            externalLogout ( logoutDir );
+        }
+    }
+    else
+    {
+        if ( loginDir != QString::null )
+        {
+            x2goDebug <<"external login"<<endl;
+            externalLogin ( loginDir );
+        }
+    }
+}
+
+
+void ONMainWindow::slotExportTimer()
+{
+
+    if ( QFile::permissions ( readExportsFrom ) != ( QFile::ReadUser|
+            QFile::WriteUser|
+            QFile::ExeUser|
+            QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner ) )
+    {
+        x2goDebug <<"Wrong permissions on "<<
+        readExportsFrom <<":"<<endl;
+        x2goDebug << ( int ) ( QFile::permissions (
+                                   readExportsFrom+"/." ) )
+        <<"must be"<< ( int ) ( QFile::ReadUser|QFile::WriteUser
+                                |QFile::ExeUser|QFile::ReadOwner|
+                                QFile::WriteOwner|
+                                QFile::ExeOwner ) <<endl;
+        exportTimer->stop();
+        return;
+    }
+
+    QDir dir ( readExportsFrom );
+    QStringList list = dir.entryList ( QDir::Files );
+    QString expList;
+    QString unexpList;
+    QString loginDir;
+    QString logoutDir;
+    for ( int i=0;i<list.size();++i )
+    {
+        QFile file ( readExportsFrom+"/"+list[i] );
+        if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+            continue;
+        if ( !file.atEnd() )
+        {
+            QByteArray line = file.readLine();
+            QString ln ( line );
+            QStringList args=ln.split ( "=",
+                                        QString::SkipEmptyParts );
+            if ( args.size() >1 )
+            {
+                if ( args[0]=="export" )
+                {
+                    args[1].replace ( "\n","" );
+                    if ( args[1].size() )
+                        expList+=":"+args[1];
+                }
+                if ( args[0]=="unexport" )
+                {
+                    args[1].replace ( "\n","" );
+                    if ( args[1].size() )
+                        unexpList+=":"+args[1];
+                }
+            }
+        }
+        file.close();
+        file.remove();
+    }
+    QStringList args=expList.split ( ":",QString::SkipEmptyParts );
+    expList=args.join ( ":" );
+    if ( expList.size() >0 )
+    {
+        exportDirs ( expList,true );
+    }
+    args.clear();
+    args=unexpList.split ( ":",QString::SkipEmptyParts );
+
+    QString passwd=getCurrentPass();
+    QString user=getCurrentUname();
+    QString host=resumingSession.server;
+    QString sessionId=resumingSession.sessionId;
+
+    for ( int i=0;i<args.size();++i )
+    {
+        SshProcess* sproc=new SshProcess (
+            sshConnection, this );
+        sproc->startNormal ( "export HOSTNAME && x2goumount_session "+
+                             sessionId+" "+args[i] );
+    }
+}
+
+void ONMainWindow::slotAboutQt()
+{
+    QMessageBox::aboutQt ( this );
+}
+
+void ONMainWindow::slotSupport()
+{
+    QFile file(supportMenuFile);
+    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
+        return;
+
+    QTextStream in(&file);
+    QString sup;
+    while (!in.atEnd())
+    {
+        sup+=in.readLine();
+    }
+    QMessageBox::information (this,tr ( "Support" ),sup);
+}
+
+void ONMainWindow::slotAbout()
+{
+    QString aboutStr=tr (
+                         "</b><br> (C. 2006-2012 <b>obviously nice</b>: "
+                         "Oleksandr Shneyder, Heinz-Markus Graesing)<br>" );
+    if ( embedMode )
+        aboutStr+=tr ( "<br>x2goplugin mode was sponsored by "
+                       "<a href=\"http://www.foss-group.de/\">"
+                       "FOSS-Group GmbH(Freiburg)</a><br>" );
+    aboutStr+=
+        tr (
+            "<br>Client for use with the X2Go network based "
+            "computing environment. This Client will be able "
+            "to connect to X2Go server(s) and start, stop, "
+            "resume and terminate (running) desktop sessions. "
+            "X2Go Client stores different server connections "
+            "and may automatically request authentification "
+            "data from LDAP directories. Furthermore it can be "
+            "used as fullscreen loginscreen (replacement for "
+            "loginmanager like xdm). Please visit x2go.org for "
+            "further information." );
+    QMessageBox::about (
+        this,tr ( "About X2GO client" ),
+        tr ( "<b>X2Go client V. " ) +VERSION+
+        " </b >(Qt - "+qVersion() +")"+
+        aboutStr );
+}
+
+
+
+void ONMainWindow::slotRereadUsers()
+{
+    if ( !useLdap )
+        return;
+#ifdef USELDAP
+
+    if ( ld )
+    {
+        delete ld;
+        ld=0;
+    }
+
+
+    if ( ! initLdapSession ( false ) )
+    {
+        return;
+    }
+
+
+    list<string> attr;
+    attr.push_back ( "uidNumber" );
+    attr.push_back ( "uid" );
+
+
+    list<LDAPBinEntry> result;
+    try
+    {
+        ld->binSearch ( ldapDn.toStdString(),attr,
+                        "objectClass=posixAccount",result );
+    }
+    catch ( LDAPExeption e )
+    {
+        QString message="Exeption in: ";
+        message=message+e.err_type.c_str();
+        message=message+" : "+e.err_str.c_str();
+        QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                QMessageBox::Ok,QMessageBox::NoButton );
+        QMessageBox::critical ( 0l,tr ( "Error" ),
+                                tr ( "Please check LDAP Settings" ),
+                                QMessageBox::Ok,QMessageBox::NoButton );
+        slotConfig();
+        return;
+    }
+
+    list<LDAPBinEntry>::iterator it=result.begin();
+    list<LDAPBinEntry>::iterator end=result.end();
+
+    for ( ;it!=end;++it )
+    {
+        user u;
+        QString uin=LDAPSession::getBinAttrValues (
+                        *it,"uidNumber" ).front().getData();
+        u.uin=uin.toUInt();
+        if ( u.uin<firstUid || u.uin>lastUid )
+        {
+            continue;
+        }
+        u.uid=LDAPSession::getBinAttrValues (
+                  *it,"uid" ).front().getData();
+        if ( !findInList ( u.uid ) )
+        {
+            reloadUsers();
+            return;
+        }
+    }
+#endif
+}
+
+void ONMainWindow::reloadUsers()
+{
+    int i;
+    for ( i=0;i<names.size();++i )
+        names[i]->close();
+    for ( i=0;i<sessions.size();++i )
+        sessions[i]->close();
+
+    userList.clear();
+    sessions.clear();
+
+
+    loadSettings();
+    if ( useLdap )
+    {
+        act_new->setEnabled ( false );
+        act_edit->setEnabled ( false );
+        u->setText ( tr ( "Login:" ) );
+        QTimer::singleShot ( 1, this, SLOT ( readUsers() ) );
+    }
+    else
+    {
+        act_new->setEnabled ( true );
+        act_edit->setEnabled ( true );
+        u->setText ( tr ( "Session:" ) );
+        QTimer::singleShot ( 1, this, SLOT ( slotReadSessions() ) );
+    }
+    slotResize ( fr->size() );
+}
+
+
+bool ONMainWindow::findInList ( const QString& uid )
+{
+    for ( int i=0;i<userList.size();++i )
+    {
+        if ( userList[i].uid==uid )
+            return true;
+    }
+    return false;
+}
+
+void ONMainWindow::setUsersEnabled ( bool enable )
+{
+
+    if ( useLdap )
+    {
+        QScrollBar* bar=users->verticalScrollBar();
+        bar->setEnabled ( enable );
+        int upos=bar->value();
+        QDesktopWidget dw;
+        int height=dw.screenGeometry ( fr ).height();
+        QList<UserButton*>::iterator it;
+        QList<UserButton*>::iterator endit=names.end();
+        if ( !enable )
+        {
+            for ( it=names.begin();it!=endit;it++ )
+            {
+                QPoint pos= ( *it )->pos();
+                if ( ( pos.y() >upos-height ) &&
+                        ( pos.y() <upos+height ) )
+                    ( *it )->setEnabled ( false );
+                if ( pos.y() >upos+height )
+                    break;
+            }
+        }
+        else
+        {
+            for ( it=names.begin();it!=endit;it++ )
+            {
+                if ( ! ( *it )->isEnabled() )
+                    ( *it )->setEnabled ( true );
+            }
+        }
+    }
+    else
+        users->setEnabled ( enable );
+}
+
+
+void ONMainWindow::externalLogin ( const QString& loginDir )
+{
+    QFile file ( loginDir+"/username" );
+    QString user;
+
+    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+        return;
+    QTextStream in ( &file );
+    while ( !in.atEnd() )
+    {
+        user=in.readLine();
+        break;
+    }
+    file.close();
+
+
+    if ( passForm->isVisible() )
+        slotClosePass();
+    uname->setText ( user );
+    slotUnameEntered();
+    currentKey=loginDir+"/dsa.key";
+    extStarted=true;
+    slotPassEnter();
+}
+
+
+void ONMainWindow::externalLogout ( const QString& )
+{
+    if ( extStarted )
+    {
+        extStarted=false;
+        currentKey=QString::null;
+        if ( nxproxy )
+            if ( nxproxy->state() ==QProcess::Running )
+                nxproxy->terminate();
+    }
+}
+
+
+void ONMainWindow::slotStartPGPAuth()
+{
+    scDaemon=new QProcess ( this );
+    QStringList arguments;
+    arguments<<"--multi-server";
+    connect ( scDaemon,SIGNAL ( readyReadStandardError() ),this,
+              SLOT ( slotScDaemonError() ) );
+    connect ( scDaemon,SIGNAL ( readyReadStandardOutput() ),this,
+              SLOT ( slotScDaemonOut() ) );
+    connect ( scDaemon,SIGNAL ( finished ( int,QProcess::ExitStatus ) ),
+              this,
+              SLOT (
+                  slotScDaemonFinished ( int, QProcess::ExitStatus ) ) );
+    scDaemon->start ( "scdaemon",arguments );
+    QTimer::singleShot ( 3000, this, SLOT ( slotCheckScDaemon() ) );
+    isScDaemonOk=false;
+}
+
+void ONMainWindow::slotCheckScDaemon()
+{
+    if ( !isScDaemonOk )
+    {
+        scDaemon->kill();
+    }
+}
+
+void ONMainWindow::slotScDaemonError()
+{
+    QString stdOut ( scDaemon->readAllStandardError() );
+    stdOut=stdOut.simplified();
+    x2goDebug<<"SCDAEMON err:"<<stdOut<<endl;
+    if ( stdOut.indexOf ( "updating slot" ) !=-1 ||
+            stdOut.indexOf ( "updating status of slot" ) !=-1 )
+    {
+        isScDaemonOk=true;
+        //USABLE or PRESENT
+        if ( ( stdOut.indexOf ( "0x0002" ) !=-1 ) ||
+                ( stdOut.indexOf ( "0x0007" ) !=-1 ) )
+        {
+            scDaemon->kill();
+        }
+    }
+}
+
+void ONMainWindow::slotScDaemonOut()
+{
+    QString stdOut ( scDaemon->readAllStandardOutput() );
+    stdOut=stdOut.simplified();
+    x2goDebug<<"SCDAEMON out:"<<stdOut<<endl;
+}
+
+void ONMainWindow::slotScDaemonFinished ( int , QProcess::ExitStatus )
+{
+    scDaemon=0l;
+    if ( isScDaemonOk )
+    {
+        x2goDebug<<"scDaemon finished"<<endl;
+        gpg=new QProcess ( this );
+        QStringList arguments;
+        arguments<<"--card-status";
+        connect ( gpg,SIGNAL ( readyReadStandardError() ),
+                  this,SLOT ( slotGpgError() ) );
+        connect ( gpg,SIGNAL ( finished ( int,
+                                          QProcess::ExitStatus ) ),this,
+                  SLOT ( slotGpgFinished ( int,
+                                           QProcess::ExitStatus ) ) );
+        gpg->start ( "gpg",arguments );
+    }
+    else
+        slotStartPGPAuth();
+}
+
+
+
+void ONMainWindow::slotGpgError()
+{
+    QString stdOut ( gpg->readAllStandardError() );
+    stdOut=stdOut.simplified();
+    x2goDebug<<"GPG err:"<<stdOut<<endl;
+    if ( stdOut.indexOf ( "failed" ) !=-1 )
+    {
+        QMessageBox::critical ( 0l,tr ( "Error" ),
+                                tr ( "No valid card found" ),
+                                QMessageBox::Ok,
+                                QMessageBox::NoButton );
+        gpg->kill();
+    }
+}
+
+
+void ONMainWindow::slotGpgFinished ( int exitCode,
+                                     QProcess::ExitStatus exitStatus )
+{
+    x2goDebug<<"gpg finished, exit code:"<<exitCode<<" exit status:"<<
+    exitStatus<<endl;
+    if ( exitStatus==0 )
+    {
+        QString stdOut ( gpg->readAllStandardOutput() );
+        stdOut.chop ( 1 );
+        x2goDebug<<"GPG out:"<<stdOut<<endl;
+        QStringList lines=stdOut.split ( "\n" );
+        QString login;
+        QString appId;
+        QString authKey;
+        for ( int i=0;i<lines.count();++i )
+        {
+            if ( lines[i].indexOf ( "Application ID" ) !=-1 )
+            {
+                appId=lines[i].split ( ":" ) [1];
+            }
+            else if ( lines[i].indexOf ( "Login data" ) !=-1 )
+            {
+                login=lines[i].split ( ":" ) [1];
+            }
+            else if ( lines[i].indexOf (
+                          "Authentication key" ) !=-1 )
+            {
+                authKey=lines[i].split ( ":" ) [1];
+                break;
+            }
+        }
+        appId=appId.simplified();
+        login=login.simplified();
+        authKey=authKey.simplified();
+        x2goDebug<<"card data: "<<appId<<login<<authKey<<endl;
+        if ( login=="[not set]" || authKey == "[none]" )
+        {
+            x2goDebug<<"Card not configured\n";
+            QMessageBox::critical (
+                0l,tr ( "Error" ),
+                tr (
+                    "This card is unknown by X2Go system" ),
+                QMessageBox::Ok,
+                QMessageBox::NoButton );
+            QTimer::singleShot ( 1000, this,
+                                 SLOT ( slotStartPGPAuth() ) );
+        }
+        else
+            startGPGAgent ( login,appId );
+    }
+    else
+        QTimer::singleShot ( 1000, this, SLOT ( slotStartPGPAuth() ) );
+    gpg=0l;
+}
+
+
+
+void ONMainWindow::startGPGAgent ( const QString& login, const QString& appId )
+{
+    QString gpgPath=homeDir +"/.x2goclient/gnupg";
+    QDir d;
+    cardLogin=login;
+    d.mkpath ( gpgPath );
+    QFile file ( gpgPath+"/scd-event" );
+    if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
+    {
+        QMessageBox::critical (
+            0l,tr ( "Error" ),
+            tr (
+                "Unable to create file: " ) +
+            gpgPath+"/scd-event"
+            ,QMessageBox::Ok,
+            QMessageBox::NoButton );
+        exit ( -1 );
+    }
+    QTextStream out ( &file );
+    out << "#!/bin/bash\n\n"
+    "if [ \"$6\" != \"0x0002\" ] && [ \"$6\" != "
+    "\"0x0007\" ]\n\
+	then\n\
+	kill -9 $_assuan_pipe_connect_pid\n\
+	fi"<<endl;
+    file.close();
+    file.setPermissions ( gpgPath+"/scd-event",
+                          QFile::ReadOwner|
+                          QFile::WriteOwner|
+                          QFile::ExeOwner );
+
+    gpgAgent=new QProcess ( this );
+    QStringList arguments;
+    arguments<<"--pinentry-program"<<"/usr/bin/pinentry-x2go"<<
+    "--enable-ssh-support"<<"--daemon"<<"--no-detach";
+
+    connect ( gpgAgent,SIGNAL ( finished ( int,QProcess::ExitStatus ) ),
+              this,
+              SLOT ( slotGpgAgentFinished ( int,
+                                            QProcess::ExitStatus ) ) );
+
+    QStringList env=QProcess::systemEnvironment();
+    env<<"GNUPGHOME="+gpgPath<<"CARDAPPID="+appId;
+    gpgAgent->setEnvironment ( env );
+    gpgAgent->start ( "gpg-agent",arguments );
+}
+
+void ONMainWindow::slotGpgAgentFinished ( int , QProcess::ExitStatus )
+{
+    QString stdOut ( gpgAgent->readAllStandardOutput() );
+    stdOut=stdOut.simplified();
+    stdOut.replace ( " ","" );
+    QStringList envLst=stdOut.split ( ";" );
+    QString gpg_agent_info=envLst[0].split ( "=" ) [1];
+    QString ssh_auth_sock=envLst[2].split ( "=" ) [1];
+    agentPid=envLst[4].split ( "=" ) [1];
+    x2goDebug<<gpg_agent_info<<ssh_auth_sock<<agentPid<<endl;
+    x2goDebug<<"GPGAGENT out:"<<envLst[0]<<envLst[2]<<envLst[4]<<endl;
+
+    agentCheckTimer->start ( 1000 );
+    cardReady=true;
+
+    sshEnv.clear();
+    sshEnv<<envLst[0]<<envLst[2]<<envLst[4];
+// 	x2goDebug<<"sshenv:"<<sshEnv<<endl;
+
+    if ( !useLdap )
+    {
+        if ( passForm->isVisible() && !brokerMode)
+        {
+            if ( passForm->isEnabled() )
+            {
+                if ( login->isEnabled() )
+                {
+                    login->setText ( cardLogin );
+                    slotSessEnter();
+                    return;
+                }
+            }
+        }
+        QProcess sshadd ( this ); //using it to start scdaemon
+        sshadd.setEnvironment ( sshEnv );
+        QStringList arguments;
+        arguments<<"-l";
+        sshadd.start ( "ssh-add",arguments );
+        sshadd.waitForFinished ( -1 );
+        QString sshout ( sshadd.readAllStandardOutput() );
+        sshout=sshout.simplified();
+        x2goDebug<<"SSH-ADD out:"<<sshout<<endl;
+    }
+    else
+    {
+        if ( selectSessionDlg->isVisible() ||
+                sessionStatusDlg->isVisible() )
+        {
+            QProcess sshadd ( this ); //using it to start scdaemon
+            sshadd.setEnvironment ( sshEnv );
+            QStringList arguments;
+            arguments<<"-l";
+            sshadd.start ( "ssh-add",arguments );
+            sshadd.waitForFinished ( -1 );
+            QString sshout ( sshadd.readAllStandardOutput() );
+            sshout=sshout.simplified();
+            x2goDebug<<"SSH-ADD out:"<<sshout<<endl;
+            return;
+        }
+        if ( passForm->isVisible() )
+            slotClosePass();
+        uname->setText ( cardLogin );
+        slotUnameEntered();
+        slotPassEnter();
+    }
+}
+
+
+void ONMainWindow::slotCheckAgentProcess()
+{
+    if ( checkAgentProcess() )
+        return;
+    agentCheckTimer->stop();
+    cardReady=false;
+    if ( cardStarted )
+    {
+        cardStarted=false;
+        if ( nxproxy )
+            if ( nxproxy->state() ==QProcess::Running )
+            {
+                x2goDebug<<"Suspending session\n";
+                slotSuspendSessFromSt();
+//                 nxproxy->terminate();
+            }
+    }
+
+    x2goDebug<<"gpg-agent finished\n";
+    slotStartPGPAuth();
+}
+
+bool ONMainWindow::checkAgentProcess()
+{
+    QFile file ( "/proc/"+agentPid+"/cmdline" );
+    if ( file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+    {
+        QString line ( file.readLine() );
+        file.close();
+        if ( line.indexOf ( "gpg-agent" ) !=-1 )
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+#if defined ( Q_OS_DARWIN )
+QString ONMainWindow::getXDisplay()
+{
+    QLocalSocket unixSocket (this);
+    QString xsocket (getenv ("DISPLAY"));
+
+    if (xsocket.isEmpty ())
+    {
+        // Mac OS X 10.4 compatibility mode.
+        // There, it is possible no $DISPLAY variable is set.
+        // Start X11 manually. First, find a free display number.
+        x2goDebug << "entering 10.4 compat mode, checking for free X11 display";
+
+        int xFreeDisp = 0;
+        QDir xtmpdir ("/tmp/.X11-unix");
+
+        if (xtmpdir.exists ())
+        {
+            xtmpdir.setFilter (QDir::Files | QDir::System | QDir::NoSymLinks | QDir::NoDotAndDotDot);
+            xtmpdir.setSorting (QDir::Name);
+
+            QFileInfoList xtmpdirList = xtmpdir.entryInfoList ();
+            bool foundFreeDisp = FALSE;
+            xFreeDisp = -1;
+
+            for (int i = 0; (i < 2000) && (!foundFreeDisp); ++i)
+            {
+                QFileInfo xtmpdirFile (xtmpdir.absolutePath () + "/X" + QString::number (i));
+
+                if ((!xtmpdirFile.exists ()) && (!xtmpdirFile.isSymLink ()))
+                {
+                    xFreeDisp = i;
+                    foundFreeDisp = TRUE;
+                }
+            }
+        }
+
+        // Control flow will go to error condition if no free display port has been found.
+        if (xFreeDisp != -1)
+        {
+            xsocket = "/tmp/.X11-unix/X" + QString::number (xFreeDisp);
+            x2goDebug << "Successfully detected free socket " << xsocket << ".";
+        }
+
+        if (!(xsocket.isEmpty ()))
+        {
+            QString xname = ConfigDialog::getXDarwinDirectory () + "/Contents/MacOS/X11";
+            QString xopt = ":" + QString::number (xFreeDisp);
+            QProcessEnvironment env = QProcessEnvironment::systemEnvironment ();
+            QProcess* startx = new QProcess (this);
+
+            x2goDebug << "Starting the X server on free display port.";
+            env.insert (0, "PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin");
+
+            startx->setProcessEnvironment (env);
+            startx->start (xname + QString (" ") + xopt, QIODevice::NotOpen);
+            if (startx->waitForStarted (3000))
+            {
+                x2goDebug << "sleeping for three seconds";
+                int sleeptime = 3;
+                while ((sleeptime = sleep (sleeptime))) {};
+
+                x2goDebug << "Leaving OS X 10.4 compat mode.";
+            }
+        }
+    }
+
+    // OS X >= 10.5 starts the X11 server automatically, as soon as the
+    // launchd UNIX socket is accessed.
+    // On user login, the DISPLAY environment variable is set to this said existing
+    // socket.
+    // By now, we should have a socket, even on 10.4. Test, if connecting works.
+    // Note: common sense may tell you to change this if into an else. Don't.
+    // We do not want to skip this part, if coming from the compat section above.
+    if (!(xsocket.isEmpty ()))
+    {
+        if (xsocket[0] == ':')
+        {
+            // Be backwards compatible with 10.4.
+            // Delete the ":" character.
+            xsocket.remove (0, 1);
+            // xsocket may now contain the display value (one integer),
+            // or something like "0.0" - we're only interested in the
+            // display value, so keep the first char only.
+            if (xsocket.indexOf (".") != -1)
+            {
+                xsocket = xsocket.left (xsocket.indexOf ("."));
+            }
+            // Prepend the well-known socket path.
+            xsocket.prepend ("/tmp/.X11-unix/X");
+            x2goDebug << "xsocket in compat mode: " << xsocket;
+        }
+
+        unixSocket.connectToServer (xsocket);
+
+        if (unixSocket.waitForConnected (10000))
+        {
+            unixSocket.disconnectFromServer ();
+
+            // Mac OS X 10.4 compat: nxproxy expects
+            // a DISPLAY variable like ":0", passing
+            // an UNIX socket will just make it error out.
+            // Instead of altering the nxproxy code, which does
+            // already try to connect to "/tmp/.X11-unix/Xi" with
+            // i = display number, pass ":i" as DISPLAY.
+            if (xsocket.left (16).compare ("/tmp/.x11-unix/x", Qt::CaseInsensitive) == 0)
+            {
+                bool ok = FALSE;
+                int tmp = -1;
+
+                xsocket = xsocket.mid (16);
+                tmp = xsocket.toInt (&ok);
+
+                if (ok)
+                {
+                    x2goDebug << "Returning" << QString (":") + xsocket;
+                    return (QString (":") + xsocket);
+                }
+            }
+            else
+            {
+              return (xsocket);
+            }
+        }
+    }
+    // And if not, error out.
+    QMessageBox::critical (
+        this,tr ( "Can't connect to X server\nPlease check your settings" ),
+        tr (
+            "Can't start X server\nPlease check your settings" ) );
+    slotConfig();
+    return QString::null;
+}
+#endif
+
+#ifdef Q_OS_WIN
+QString ONMainWindow::getXDisplay()
+{
+    if ( !isServerRunning ( 6000+xDisplay ) )
+    {
+        QMessageBox::critical (
+            this,QString::null,
+            tr (
+                "Can't start X Server\nPlease check your installation" )
+        );
+        close();
+    }
+    return QString::number ( xDisplay );
+
+}
+
+QString ONMainWindow::cygwinPath ( const QString& winPath )
+{
+    QString cPath="/cygdrive/"+winPath;
+    cPath.replace ( "\\","/" );
+    cPath.replace ( ":","" );
+    return cPath;
+}
+#endif
+
+bool ONMainWindow::isColorDepthOk ( int disp, int sess )
+{
+    if ( sess==0 )
+        return true;
+    if ( disp==sess )
+        return true;
+    if ( ( disp == 24 || disp == 32 ) && ( sess == 24 || sess == 32 ) )
+        return true;
+    return false;
+}
+
+#ifndef Q_OS_LINUX
+void ONMainWindow::setWidgetStyle ( QWidget* widget )
+{
+    widget->setStyle ( widgetExtraStyle );
+}
+#else
+void ONMainWindow::setWidgetStyle ( QWidget* )
+{
+}
+#endif
+
+QString ONMainWindow::internAppName ( const QString& transAppName, bool* found )
+{
+    if ( found )
+        *found=false;
+    int ind=_transApplicationsNames.indexOf ( transAppName );
+    if ( ind!=-1 )
+    {
+        if ( found )
+            *found=true;
+        return _internApplicationsNames[ind];
+    }
+    return transAppName;
+}
+
+
+QString ONMainWindow::transAppName ( const QString& internAppName, bool* found )
+{
+    if ( found )
+        *found=false;
+    int ind=_internApplicationsNames.indexOf ( internAppName );
+    if ( ind!=-1 )
+    {
+        if ( found )
+            *found=true;
+        return _transApplicationsNames[ind];
+    }
+    return internAppName;
+}
+
+void ONMainWindow::addToAppNames ( QString intName, QString transName )
+{
+    _internApplicationsNames.append ( intName );
+    _transApplicationsNames.append ( transName );
+}
+
+
+void ONMainWindow::slotExecXmodmap()
+{
+#ifdef Q_WS_HILDON
+    QString passwd=getCurrentPass();
+    QString user=getCurrentUname();
+    QString host=resumingSession.server;
+    QString cmd;
+
+    cmd="(xmodmap -pke ;"
+        "echo keycode 73= ;"
+// 	    "echo clear shift ;"
+// 	    "echo clear lock ;"
+// 	    "echo clear control ;"
+// 	    "echo clear mod1 ;"
+// 	    "echo clear mod2 ;"
+// 	    "echo clear mod3 ;"
+// 	    "echo clear mod4 ;"
+// 	    "echo clear mod5 ;"
+//  	    "echo add shift = Shift_L ;"
+        "echo add control = Control_R "
+//  	    "echo add mod5 = ISO_Level3_Shift"
+        ")| DISPLAY=:"
+        +resumingSession.display+" xmodmap - ";
+    x2goDebug<<"cmd:"<<cmd;
+    SshProcess* xmodProc;
+    try
+    {
+        xmodProc=new SshProcess ( this,user,host,sshPort,
+                                  cmd,
+                                  passwd,currentKey,acceptRsa );
+    }
+    catch ( QString message )
+    {
+        return;
+    }
+
+    if ( cardReady /*|| useSshAgent*/ )
+    {
+        QStringList env=xmodProc->environment();
+        env+=sshEnv;
+        xmodProc->setEnvironment ( env );
+    }
+    xmodProc->setFwX ( true );
+    xmodProc->startNormal();
+#endif
+}
+
+void ONMainWindow::check_cmd_status()
+{
+    QString passwd;
+    QString user=getCurrentUname();
+    QString host=resumingSession.server;
+    passwd=getCurrentPass();
+
+    x2goDebug<<"check command message"<<endl;
+    SshProcess* proc;
+    proc=new SshProcess ( sshConnection, this );
+    connect ( proc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
+              this,SLOT ( slotCmdMessage ( bool, QString,SshProcess* ) ) );
+
+    proc->startNormal ( "x2gocmdexitmessage "+
+                        resumingSession.sessionId );
+}
+
+void ONMainWindow::slotCmdMessage ( bool result,QString output,
+                                    SshProcess* proc )
+{
+    if ( proc )
+        delete proc;
+    if ( result==false )
+    {
+        cardReady=false;
+        cardStarted=false;
+        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
+        if ( message.indexOf ( "publickey,password" ) !=-1 )
+        {
+            message=tr ( "<b>Wrong password!</b><br><br>" ) +
+                    message;
+        }
+
+        QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                QMessageBox::Ok,
+                                QMessageBox::NoButton );
+// 		currentKey=QString::null;
+        setEnabled ( true );
+        passForm->setEnabled ( true );
+        pass->setFocus();
+        pass->selectAll();
+        sshConnection->disconnectSession();
+        return;
+    }
+    if ( output.indexOf ( "X2GORUNCOMMAND ERR NOEXEC:" ) !=-1 )
+    {
+        QString cmd=output;
+        cmd.replace ( "X2GORUNCOMMAND ERR NOEXEC:","" );
+        QMessageBox::critical ( 0l,tr ( "Error" ),
+                                tr ( "Unable to execute: " ) +
+                                cmd,QMessageBox::Ok,
+                                QMessageBox::NoButton );
+    }
+    sshConnection->disconnectSession();
+}
+
+
+int ONMainWindow::startSshFsTunnel()
+{
+    fsTunReady=false;
+    x2goDebug<<"starting fs tunnel for:"<<resumingSession.sessionId<<
+    "\nfs port: "<<resumingSession.fsPort;
+
+    if ( resumingSession.fsPort.length() <=0 )
+    {
+        QString message=tr (
+                            "Remote server does not "
+                            "support file system export "
+                            "through SSH Tunnel\n"
+                            "Please update to a newer "
+                            "x2goserver package" );
+        slotFsTunnelFailed ( false,message,0 );
+        return 1;
+    }
+    QString passwd=getCurrentPass();
+    QString uname=getCurrentUname();
+
+    fsTunnel=new SshProcess ( sshConnection, this );
+
+    connect ( fsTunnel,SIGNAL ( sshFinished ( bool,
+                                QString,SshProcess* ) ),
+              this,SLOT ( slotFsTunnelFailed ( bool,
+                                               QString,SshProcess* ) ) );
+
+    connect ( fsTunnel,SIGNAL ( sshTunnelOk() ),
+              this,SLOT ( slotFsTunnelOk() ) );
+
+    fsTunnel->startTunnel ( "localhost",resumingSession.fsPort.toUInt(),"127.0.0.1",
+                            clientSshPort.toInt(), true );
+    return 0;
+}
+
+void ONMainWindow::slotFsTunnelFailed ( bool result,  QString output,
+                                        SshProcess* )
+{
+    if ( result==false )
+    {
+        if ( !managedMode )
+        {
+
+            QString message=tr ( "Unable to create SSL tunnel:\n" )
+                            +output;
+            QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                    QMessageBox::Ok,
+                                    QMessageBox::NoButton );
+        }
+        if ( fsTunnel )
+            delete fsTunnel;
+        fsTunnel=0l;
+        fsTunReady=false;
+    }
+}
+
+
+void ONMainWindow::slotFsTunnelOk()
+{
+    fsTunReady=true;
+    //start reverse mounting if RSA Key and FS tunnel are ready
+    //start only once from slotFsTunnelOk() or slotCopyKey().
+    if ( fsExportKeyReady )
+        startX2goMount();
+}
+
+
+void ONMainWindow::startX2goMount()
+{
+    QFile file ( fsExportKey+".pub" );
+    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+    {
+        QString message=tr ( "Unable to read :\n" ) +fsExportKey+".pub";
+        QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                QMessageBox::Ok,
+                                QMessageBox::NoButton );
+        QFile::remove
+        ( fsExportKey+".pub" );
+        return;
+    }
+
+    QByteArray line = file.readLine();
+    file.close();
+    QString authofname=homeDir;
+#ifdef Q_OS_WIN
+    QDir tdir;
+    tdir.mkpath ( authofname+"\\.x2go\\.ssh" );
+    x2goDebug<<"Creating "<<authofname+"\\.x2go\\.ssh"<<endl;
+    authofname=wapiShortFileName ( authofname ) +"/.x2go";
+#endif
+    authofname+= "/.ssh/authorized_keys" ;
+
+    QFile file1 ( authofname );
+
+    if ( !file1.open ( QIODevice::WriteOnly | QIODevice::Text |
+                       QIODevice::Append ) )
+    {
+        QString message=tr ( "Unable to write :\n" ) + authofname;
+        QMessageBox::critical ( 0l,tr ( "Error" ),message,
+                                QMessageBox::Ok,
+                                QMessageBox::NoButton );
+        QFile::remove
+        ( fsExportKey+".pub" );
+        return;
+
+    }
+    QTextStream out ( &file1 );
+    out<<line;
+    file1.close();
+    directory* dir=getExpDir ( fsExportKey );
+    bool rem=dir->isRemovable;
+    if ( !dir )
+        return;
+
+    QString passwd=getCurrentPass();
+    QString user=getCurrentUname();
+    QString host=resumingSession.server;
+    QString sessionId=resumingSession.sessionId;
+
+    QStringList env=QProcess::systemEnvironment();
+
+
+    QString cuser;
+#ifndef Q_WS_HILDON
+    for ( int i=0;i<env.size();++i )
+    {
+        QStringList ls=env[i].split ( "=" );
+        if ( ls[0]=="USER" )
+
+        {
+            cuser=ls[1];
+            break;
+        }
+    }
+#else
+    cuser="user";
+#endif
+#ifdef Q_OS_WIN
+    cuser="sshuser";
+#endif
+    SshProcess* proc=0l;
+    QString cmd;
+    QString dirs=dir->dirList;
+
+    if ( !fsInTun && clientSshPort!="22" )
+    {
+        dirs=dirs+"__SSH_PORT__"+clientSshPort;
+    }
+    if ( fsInTun )
+    {
+        dirs=dirs+"__REVERSESSH_PORT__"+resumingSession.fsPort;
+    }
+    if ( !rem )
+        cmd="export HOSTNAME && x2gomountdirs dir "+sessionId+" "+cuser+
+            " "+dir->dstKey+" "+dirs;
+    else
+        cmd="export HOSTNAME && x2gomountdirs rem "+sessionId+" "+cuser+
+            " "+dir->dstKey+" "+dirs;
+
+#ifdef Q_OS_WIN
+
+    cmd="chmod 600 "+dir->dstKey+"&&"+cmd;
+#endif
+
+
+
+    X2goSettings st ( "sessions" );
+
+    if ( !useLdap )
+    {
+        QString sid;
+        if ( !embedMode )
+            sid=lastSession->id();
+        else
+            sid="embedded";
+        if ( st.setting()->value (
+                    sid+"/useiconv", ( QVariant ) false ).toBool() )
+        {
+            QString toCode=st.setting()->value (
+                               sid+"/iconvto",
+                               ( QVariant ) "UTF-8" ).toString();
+
+#ifdef Q_OS_WIN
+            QString fromCode=st.setting()->value (
+                                 sid+"/iconvfrom",
+                                 ( QVariant ) tr (
+                                     "WINDOWS-1252" ) ).toString();
+#endif
+#ifdef Q_OS_DARWIN
+            QString fromCode=st.setting()->value (
+                                 sid+"/iconvfrom",
+                                 ( QVariant )
+                                 "UTF-8" ).toString();
+#endif
+#ifdef Q_OS_LINUX
+            QString fromCode=st.setting()->value (
+                                 sid+"/iconvfrom",
+                                 ( QVariant ) tr (
+                                     "ISO8859-1" ) ).toString();
+#endif
+            cmd="export X2GO_ICONV=modules=iconv,from_code="+
+                fromCode+
+                ",to_code="+toCode+"&&"+cmd;
+        }
+    }
+
+    proc=new SshProcess ( sshConnection, this );
+    dir->proc=proc;
+
+    connect ( proc,SIGNAL ( sshFinished ( bool, QString,SshProcess* ) ),
+              this,SLOT ( slotRetExportDir ( bool,
+                                             QString,SshProcess* ) ) );
+
+    proc->startNormal ( cmd );
+}
+
+void ONMainWindow::slotCheckPrintSpool()
+{
+    QDir dir ( spoolDir );
+    QStringList list = dir.entryList ( QDir::Files );
+    for ( int i=0;i<list.size();++i )
+    {
+        if ( !list[i].endsWith ( ".ready" ) )
+            continue;
+        QFile file ( spoolDir+"/"+list[i] );
+        if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+            continue;
+        bool startProc=false;
+        QString fname,title;
+        if ( !file.atEnd() )
+        {
+            QByteArray line = file.readLine();
+            QString fn ( line );
+            fn.replace ( "\n","" );
+            fname=fn;
+            if ( !file.atEnd() )
+            {
+                line = file.readLine();
+                title=line;
+                title.replace ( "\n","" );
+            }
+            startProc=true;
+        }
+        file.close();
+        file.remove();
+        if ( startProc )
+            new PrintProcess ( spoolDir+"/"+fname,title ,this );
+
+    }
+}
+
+
+void ONMainWindow::cleanPrintSpool()
+{
+    QDir dir ( spoolDir );
+    QStringList list = dir.entryList ( QDir::Files );
+    for ( int i=0;i<list.size();++i )
+    {
+        QFile::remove ( spoolDir+"/"+list[i] );
+    }
+}
+
+
+void ONMainWindow::cleanAskPass()
+{
+    QString path=homeDir +"/.x2go/ssh/";
+    QDir dir ( path );
+    QStringList list = dir.entryList ( QDir::Files );
+    for ( int i=0;i<list.size();++i )
+    {
+        if ( list[i].startsWith ( "askpass" ) )
+            QFile::remove ( path+list[i] );
+    }
+
+}
+
+
+#ifdef Q_OS_WIN
+#include <windows.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#endif
+
+
+bool ONMainWindow::isServerRunning ( int port )
+{
+#ifdef Q_OS_WIN
+    SOCKET ConnectSocket = INVALID_SOCKET;
+    struct sockaddr_in saServer;
+    hostent* localHost;
+    char* localIP;
+    int iResult;
+    WSADATA wsaData;
+
+    struct in_addr addr = { 0 };
+
+    iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
+    if (iResult != 0)
+    {
+        x2goDebug<<"WARNING: WSAStartup failed: "<< iResult<<endl;
+        return false;
+    }
+
+    addr.s_addr = inet_addr("127.0.0.1");
+    if (addr.s_addr == INADDR_NONE)
+    {
+        x2goDebug<< "WARNING:  The IPv4 address entered must be a legal address\n";
+        return false;
+    }
+
+
+    localHost = gethostbyaddr((char*)&addr,4, AF_INET);
+    if (!localHost)
+    {
+        x2goDebug<<"WARNING: gethostbyaddr failed: "<<WSAGetLastError()<<endl;
+        return false;
+    }
+    x2goDebug<<"got localhost"<<endl;
+
+    localIP = inet_ntoa (*(struct in_addr *)*localHost->h_addr_list);
+
+    saServer.sin_family = AF_INET;
+    saServer.sin_addr.s_addr = inet_addr(localIP);
+    saServer.sin_port = htons(port);
+
+    ConnectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+    if (ConnectSocket == INVALID_SOCKET)
+    {
+        x2goDebug<<"WARNING: socket failed with error: "<< WSAGetLastError()<<endl;
+        return false;
+    }
+
+    iResult = ::connect( ConnectSocket, (SOCKADDR*) &saServer, sizeof(saServer));
+    if (iResult == SOCKET_ERROR)
+    {
+        closesocket(ConnectSocket);
+        x2goDebug<<"Port is free: "<<port<<endl;
+        return false;
+    }
+    closesocket(ConnectSocket);
+    x2goDebug<<"Port already used: "<<port<<endl;
+    return true;
+#endif
+    QTcpSocket tcpSocket ( 0 );
+    tcpSocket.connectToHost ( "127.0.0.1",port );
+
+    if ( tcpSocket.waitForConnected ( 1000 ) )
+    {
+        tcpSocket.close();
+        return true;
+    }
+    return false;
+}
+#ifdef Q_OS_WIN
+void ONMainWindow::slotCheckXOrgLog()
+{
+    xorgLogMutex.lock();
+    if ( xorgLogFile.length() <=0 )
+    {
+        xorgLogMutex.unlock();
+        return;
+    }
+    QFile file ( xorgLogFile );
+    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
+    {
+        xorgLogMutex.unlock();
+        return;
+    }
+
+    QTextStream in ( &file );
+    while ( !in.atEnd() )
+    {
+        QString line = in.readLine();
+        if ( line.indexOf ( "successfully opened the display" ) !=-1 )
+        {
+            xorgLogTimer->stop();
+            slotSetWinServersReady();
+            xorgLogMutex.unlock();
+            return;
+        }
+    }
+    xorgLogMutex.unlock();
+}
+
+void ONMainWindow::startXOrg ()
+{
+    while ( isServerRunning ( 6000+xDisplay ) )
+        ++xDisplay;
+    QString dispString;
+    QTextStream ( &dispString ) <<":"<<xDisplay;
+
+    QStringList args;
+    QString exec;
+    if (internalX==XMING)
+        exec=appDir+"\\xming\\Xming.exe";
+    if (internalX==VCXSRV)
+        exec=appDir+"\\vcxsrv\\vcxsrv.exe";
+    winServersReady=false;
+    x2goDebug<<"using internal X: "<<useInternalX;
+//#ifdef CFGCLIENT
+    if (!useInternalX || internalX!=XMING)
+    {
+        if (!useInternalX)
+            exec=xorgExe;
+        QString cmdLine;
+        if (startXorgOnStart)
+            cmdLine=xorgOptions;
+        else
+        {
+            switch (xorgMode)
+            {
+            case FS:
+                cmdLine=xorgFSOptions;
+                break;
+            case SAPP:
+                cmdLine=xorgSAppOptions;
+                break;
+            case WIN:
+                cmdLine=xorgWinOptions;
+                x2goDebug<<"WxH:"<<xorgWidth<<"x"<<xorgHeight<<endl;
+                cmdLine.replace("%w",xorgWidth);
+                cmdLine.replace("%h",xorgHeight);
+                x2goDebug<<cmdLine<<endl;
+                break;
+            }
+        }
+        QStringList options=cmdLine.split(" ",QString::SkipEmptyParts);
+        QString option;
+        foreach(option,options)
+        {
+            args<< option;
+        }
+        args<<dispString;
+    }
+//#endif
+    xorg=new QProcess ( 0 );
+    if (useInternalX && (internalX==XMING))
+    {
+
+        QString workingDir=appDir+"\\xming";
+        QStringList env=QProcess::systemEnvironment();
+        env<<"GLWIN_ENABLE_DEBUG=0";
+        xorgLogMutex.lock();
+        xorgLogFile=homeDir+"/.x2go/xorg";
+        QDir dr ( homeDir );
+        dr.mkpath ( xorgLogFile );
+        xorgLogFile=wapiShortFileName ( xorgLogFile ) +"\\xorg.log."+
+                    QString::number ( xDisplay );
+        if ( QFile::exists ( xorgLogFile ) )
+            QFile::remove ( xorgLogFile );
+        xorgLogMutex.unlock();
+//run xming with clipboard support
+        args<<dispString<<"-multiwindow"<<"-notrayicon"<<"-clipboard"<<
+        "-logfile"<<xorgLogFile;
+        xorg->setEnvironment ( env );
+        xorg-> setWorkingDirectory ( workingDir);
+    }
+
+    x2goDebug<<"running"<<exec<<" "<<args.join(" ");
+    xorg->start ( exec, args );
+
+
+    if ( !xorg->waitForStarted ( 3000 ) )
+    {
+        QMessageBox::critical (
+            0,QString::null,
+            tr ( "Can't start X Server\n"
+                 "Please check your installation" ) );
+        close();
+    }
+// #ifdef CFGCLIENT
+    if ( !useInternalX || internalX!= XMING)
+    {
+        //check connection in slot and launch setWinServerReady
+        waitingForX=0;
+        QTimer::singleShot(1000, this, SLOT(slotCheckXOrgConnection()));
+    }
+// #endif
+}
+
+void ONMainWindow::slotCheckXOrgConnection()
+{
+    ++waitingForX;
+    if (isServerRunning(6000+xDisplay))
+    {
+        x2goDebug<<"X is started";
+        slotSetWinServersReady();
+    }
+    else
+    {
+        if (waitingForX > 10)
+        {
+            QMessageBox::critical (
+                0,QString::null,
+                tr ( "Can't start X Server\n"
+                     "Please check your installation" ) );
+            close();
+        }
+        else
+        {
+            x2goDebug<<"waiting for X";
+            QTimer::singleShot(1000, this, SLOT(slotCheckXOrgConnection()));
+        }
+    }
+}
+
+WinServerStarter::WinServerStarter ( daemon server, ONMainWindow * par ) :
+        QThread ( 0 )
+{
+    mode=server;
+    parent=par;
+}
+
+void WinServerStarter::run()
+{
+    switch ( mode )
+    {
+    case SSH:
+        parent->startSshd();
+        break;
+    case X:
+        parent->startXOrg();
+        break;
+    case PULSE:
+        parent->startPulsed();
+        break;
+    }
+}
+
+
+
+void ONMainWindow::startWinServers()
+{
+    x2goDebug<<"Starting win servers"<<endl;
+
+    QString etcDir=homeDir+"/.x2go/etc";
+    QDir dr ( homeDir );
+
+    pulseServer=0l;
+
+    WinServerStarter* xStarter = new WinServerStarter ( WinServerStarter::X,
+            this );
+    WinServerStarter* sshStarter = new WinServerStarter (
+        WinServerStarter::SSH, this );
+
+    WinServerStarter* pulseStarter = new WinServerStarter (
+        WinServerStarter::PULSE, this );
+
+    if ( !embedMode || !config.confFS || ( config.confFS && config.useFs ) )
+    {
+
+        dr.mkpath ( etcDir );
+        generateHostDsaKey();
+        generateEtcFiles();
+        sshStarter->start();
+    }
+    if ( !embedMode || !config.confSnd ||
+            ( config.confSnd && config.useSnd ) )
+    {
+        pulseStarter->start();
+    }
+// #ifdef CFGCLIENT
+//     x2goDebug<<"xorg settings: "<<startXorgOnStart <<" "<< useXming<<endl;
+    if ( useInternalX && (internalX== XMING))
+    {
+// #endif
+        xStarter->start();
+        xorgLogTimer=new QTimer ( this );
+        connect ( xorgLogTimer,SIGNAL ( timeout() ),this,
+                  SLOT ( slotCheckXOrgLog() ) );
+        xorgLogTimer->start ( 500 );
+// #ifdef CFGCLIENT
+    }
+    else
+    {
+        if (startXorgOnStart)
+        {
+            startXOrg();
+        }
+    }
+// #endif
+}
+
+
+bool ONMainWindow::haveCySolEntry()
+{
+    QSettings CySolSt ( "HKEY_CURRENT_USER\\Software"
+                        "\\Cygnus Solutions",
+                        QSettings::NativeFormat );
+    return ( CySolSt.childGroups().count() > 0 ||
+             CySolSt.childKeys().count() > 0 );
+}
+
+bool ONMainWindow::haveCygwinEntry()
+{
+    QSettings CygwSt ( "HKEY_CURRENT_USER\\Software"
+                       "\\Cygnus Solutions\\Cygwin",
+                       QSettings::NativeFormat );
+    return ( CygwSt.childGroups().count() >0||CygwSt.childKeys().count() );
+}
+
+
+
+void ONMainWindow::saveCygnusSettings()
+{
+    if ( ONMainWindow::portable )
+    {
+        if ( haveCySolEntry() )
+        {
+            x2goDebug<<"Cygnus Solutions entry exist";
+            cySolEntry=true;
+        }
+        else
+        {
+            cySolEntry=false;
+            x2goDebug<<"Cygnus Solutions entry not exist";
+        }
+
+        if ( haveCygwinEntry() )
+        {
+            x2goDebug<<"Cygwin entry exist";
+            cyEntry=true;
+        }
+        else
+        {
+            x2goDebug<<"Cygwin entry not exist";
+            cyEntry=false;
+        }
+    }
+
+    QSettings etcst ( "HKEY_CURRENT_USER\\Software"
+                      "\\Cygnus Solutions\\Cygwin\\mounts v2\\/etc",
+                      QSettings::NativeFormat );
+    oldEtcDir=QString::null;
+    oldEtcDir=etcst.value ( "native",oldEtcDir ).toString();
+    x2goDebug<<"old etc:"<<oldEtcDir<<endl;
+    QString newEtc=homeDir+"/.x2go/etc";
+    QDir d ( newEtc );
+    if ( !d.exists() )
+        d.mkpath ( newEtc );
+    newEtc.replace ( "/","\\" );
+
+    etcst.setValue ( "native",wapiShortFileName ( newEtc ) );
+    etcst.sync();
+    x2goDebug<<"new etc:"<<wapiShortFileName ( newEtc ) <<endl;
+
+    QSettings binst ( "HKEY_CURRENT_USER\\Software"
+                      "\\Cygnus Solutions\\Cygwin\\mounts v2\\/bin",
+                      QSettings::NativeFormat );
+    oldBinDir=QString::null;
+    oldBinDir=binst.value ( "native",oldBinDir ).toString();
+    x2goDebug<<"old bin:"<<oldBinDir<<endl;
+    QString newBin=appDir;
+    newBin.replace ( "/","\\" );
+    binst.setValue ( "native",wapiShortFileName ( newBin ) );
+    binst.sync();
+    x2goDebug<<"new bin:"<<newBin<<endl;
+
+    QSettings tmpst ( "HKEY_CURRENT_USER\\Software"
+                      "\\Cygnus Solutions\\Cygwin\\mounts v2\\/tmp",
+                      QSettings::NativeFormat );
+    oldTmpDir=QString::null;
+    oldTmpDir=tmpst.value ( "native",oldTmpDir ).toString();
+    x2goDebug<<"old tmp:"<<oldTmpDir<<endl;
+    QString newTmp=QDir::tempPath();
+    newTmp.replace ( "/","\\" );
+    tmpst.setValue ( "native",wapiShortFileName ( newTmp ) );
+    tmpst.sync();
+    x2goDebug<<"new tmp:"<<newTmp<<endl;
+}
+
+void ONMainWindow::restoreCygnusSettings()
+{
+
+    if ( oldEtcDir==QString::null )
+    {
+        QSettings st ( "HKEY_CURRENT_USER\\Software"
+                       "\\Cygnus Solutions\\Cygwin\\mounts v2\\/etc",
+                       QSettings::NativeFormat );
+        x2goDebug<<"Removing /etc from cygwin mounts\n";
+        st.remove ( "" );
+        st.sync();
+    }
+    else
+    {
+        QSettings st ( "HKEY_CURRENT_USER\\Software"
+                       "\\Cygnus Solutions\\Cygwin\\mounts v2\\/etc",
+                       QSettings::NativeFormat );
+        st.setValue ( "native",oldEtcDir );
+        st.sync();
+        x2goDebug<<"Restoring /etc in cygwin mounts\n";
+    }
+    if ( oldBinDir==QString::null )
+    {
+        QSettings st ( "HKEY_CURRENT_USER\\Software"
+                       "\\Cygnus Solutions\\Cygwin\\mounts v2\\/bin",
+                       QSettings::NativeFormat );
+        x2goDebug<<"Removing /bin from cygwin mounts\n";
+        st.remove ( "" );
+        st.sync();
+    }
+    else
+    {
+        QSettings st ( "HKEY_CURRENT_USER\\Software"
+                       "\\Cygnus Solutions\\Cygwin\\mounts v2\\/bin",
+                       QSettings::NativeFormat );
+        st.setValue ( "native",oldBinDir );
+        st.sync();
+        x2goDebug<<"Restoring /bin in cygwin mounts\n";
+    }
+    if ( oldTmpDir==QString::null )
+    {
+        QSettings st ( "HKEY_CURRENT_USER\\Software"
+                       "\\Cygnus Solutions\\Cygwin\\mounts v2\\/tmp",
+                       QSettings::NativeFormat );
+        x2goDebug<<"Removing /tmp from cygwin mounts\n";
+        st.remove ( "" );
+        st.sync();
+    }
+    else
+    {
+        QSettings st ( "HKEY_CURRENT_USER\\Software"
+                       "\\Cygnus Solutions\\Cygwin\\mounts v2\\/tmp",
+                       QSettings::NativeFormat );
+        st.setValue ( "native",oldTmpDir );
+        st.sync();
+        x2goDebug<<"Restoring /tmp in cygwin mounts\n";
+    }
+    if ( ONMainWindow::portable )
+    {
+        if ( !cyEntry )
+        {
+            removeCygwinEntry();
+        }
+        if ( !cySolEntry )
+        {
+            removeCySolEntry();
+        }
+    }
+}
+
+void ONMainWindow::removeCygwinEntry()
+{
+    QSettings st ( "HKEY_CURRENT_USER\\Software"
+                   "\\Cygnus Solutions\\Cygwin",
+                   QSettings::NativeFormat );
+    x2goDebug<<"Removing cygwin\n";
+    st.remove ( "" );
+    st.sync();
+
+}
+
+void ONMainWindow::removeCySolEntry()
+{
+    QSettings st ( "HKEY_CURRENT_USER\\Software"
+                   "\\Cygnus Solutions",
+                   QSettings::NativeFormat );
+    x2goDebug<<"Removing cygnus solutions\n";
+    st.remove ( "" );
+    st.sync();
+}
+
+void ONMainWindow::startPulsed()
+{
+    while ( isServerRunning ( pulsePort ) )
+        ++pulsePort;
+    esdPort=pulsePort+1;
+    while ( isServerRunning ( esdPort ) )
+        ++esdPort;
+
+    pulseDir=homeDir+"/.x2go/pulse";
+    QDir dr ( homeDir );
+    dr.mkpath ( pulseDir );
+    pulseDir=wapiShortFileName ( pulseDir );
+    x2goDebug<<"template: "<<pulseDir+"/tmp"<<endl;
+    QTemporaryFile* fl=new QTemporaryFile ( pulseDir+"/tmp" );
+    fl->open();
+    pulseDir=fl->fileName();
+    fl->close();
+    delete fl;
+    QFile::remove ( pulseDir );
+    dr.mkpath ( pulseDir );
+    x2goDebug<<"pulse tmp file: "<<pulseDir<<endl;
+    QStringList pEnv=QProcess::systemEnvironment();
+    for ( int i=0; i<pEnv.size();++i )
+    {
+        if ( pEnv[i].indexOf ( "USERPROFILE=" ) !=-1 )
+            pEnv[i]="USERPROFILE="+
+                    wapiShortFileName ( homeDir+"/.x2go/pulse" );
+        if ( pEnv[i].indexOf ( "TEMP=" ) !=-1 )
+            pEnv[i]="TEMP="+pulseDir;
+        if ( pEnv[i].indexOf ( "USERNAME=" ) !=-1 )
+            pEnv[i]="USERNAME=pulseuser";
+    }
+
+    QFile file ( pulseDir+"/config.pa" );
+    if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
+        return;
+    QTextStream out ( &file );
+    out << "load-module module-native-protocol-tcp port="+
+    QString::number ( pulsePort ) <<endl;
+    out << "load-module module-esound-protocol-tcp port="+
+    QString::number ( esdPort ) <<endl;
+    out << "load-module module-waveout"<<endl;
+    file.close();
+    pulseServer=new QProcess ( 0 );
+    pulseServer->setEnvironment ( pEnv );
+    QStringList args;
+#ifdef Q_OS_WIN
+    QDir drr(homeDir+"/.x2go/pulse/.pulse/"+QHostInfo::localHostName ()+"-runtime");
+    if (!drr.exists())
+        drr.mkpath(drr.path());
+    if (QFile::exists(homeDir+"/.x2go/pulse/.pulse/"+QHostInfo::localHostName ()+"-runtime/pid"))
+        QFile::remove(homeDir+"/.x2go/pulse/.pulse/"+QHostInfo::localHostName ()+"-runtime/pid");
+    pulseDir.replace("/","\\");
+    args<<"--exit-idle-time=-1"<<"-n"<<"-F"<<pulseDir+"\\config.pa";
+#else
+    args<<"--exit-idle-time=-1"<<"-n"<<"-F"<<pulseDir+"/config.pa";
+#endif
+    pulseServer->setWorkingDirectory ( wapiShortFileName (
+                                           appDir+"\\pulse" ) );
+    pulseServer->start ( "pulse\\pulseaudio.exe",args );
+    x2goDebug<<"starting pulse\\pulseaudio.exe "<<args.join ( " " ) <<
+    " working dir: "<<
+    wapiShortFileName ( appDir+"\\pulse" ) <<endl;
+}
+
+
+// #ifdef CFGCLIENT
+void ONMainWindow::xorgSettings()
+{
+    x2goDebug<<"getting xorg settings"<<endl;
+
+    X2goSettings st ( "settings" );
+
+    useInternalX=(st.setting()->value("useintx",true).toBool());
+
+    xorgExe=(st.setting()->value("xexec","C:\\program files\\vcxsrv\\vcxsrv.exe").toString());
+    xorgOptions=(st.setting()->value("options","-multiwindow -notrayicon -clipboard").toString());
+    startXorgOnStart=(st.setting()->value("onstart",true).toBool());
+    xorgWinOptions=(st.setting()->value("optionswin","-screen 0 %wx%h -notrayicon -clipboard").toString());
+    xorgFSOptions=(st.setting()->value("optionsfs","-fullscreen -notrayicon -clipboard").toString());
+    xorgSAppOptions=(st.setting()->value("optionssingle","-multiwindow -notrayicon -clipboard").toString());
+
+    if (QFile::exists(appDir+"\\vcxsrv"))
+        internalX=VCXSRV;
+    if (QFile::exists(appDir+"\\xming"))
+        internalX=XMING;
+    if (useInternalX)
+    {
+        startXorgOnStart=(internalX==XMING);
+        xorgOptions="-multiwindow -notrayicon -clipboard";
+        if (internalX==VCXSRV)
+        {
+// 	xorgWinOptions="-screen 0 %wx%h -notrayicon -clipboard";
+            xorgWinOptions="-multiwindow -notrayicon -clipboard";
+            xorgFSOptions="-fullscreen -notrayicon -clipboard";
+            xorgSAppOptions="-multiwindow -notrayicon -clipboard";
+        }
+    }
+
+}
+// #endif
+
+void ONMainWindow::slotSetWinServersReady()
+{
+    x2goDebug<<"all winservers are started\n";
+    winServersReady=true;
+    restoreCygnusSettings();
+}
+
+#include <windows.h>
+#include<sstream>
+#endif
+
+void ONMainWindow::generateEtcFiles()
+{
+    QString etcDir=homeDir+"/.x2go/etc";
+    QDir dr ( homeDir );
+    dr.mkpath ( etcDir );
+#ifdef Q_OS_WIN
+    if ( !QFile::exists ( etcDir+"/passwd" ) )
+    {
+        QString sid, sys, user, grsid, grname;
+        if ( !wapiAccountInfo ( &sid,&user,&grsid, &grname, &sys ) )
+        {
+// 			x2goDebug<<"Get account info failed\n";
+            close();
+        }
+
+// 		x2goDebug<<"sid: "<<sid <<" system:"<<
+// 		sys<< " user: "<<user<<" group sid:"<<grsid<<
+// 		"group name: "<<grname<<endl;
+
+        QStringList sidList=sid.split ( '-' );
+        QString rid=sidList[sidList.count()-1];
+        QStringList grsidList=grsid.split ( '-' );
+        QString grid=grsidList[grsidList.count()-1];
+        QFile file ( etcDir +"/passwd" );
+        if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
+            return;
+        QTextStream out ( &file );
+        out <<"sshuser::"<<rid<<":"<<grid<<":"<<sys<<"\\sshuser,"
+        <<sid<<":"<<cygwinPath ( wapiShortFileName ( homeDir ) ) <<
+        "/.x2go"<<":/bin/bash\n";
+        file.close();
+    }
+
+    if ( !QFile::exists ( etcDir+"/sshd_config" ) )
+    {
+#endif
+        QFile file ( etcDir +"/sshd_config" );
+        if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
+            return;
+        QTextStream out ( &file );
+        out<<"StrictModes no\n"<<
+        "UsePrivilegeSeparation no\n"<<
+#ifdef Q_OS_WIN
+        "Subsystem sftp /bin/sftp-server\n";
+#else
+        "Subsystem sftp "
+        <<appDir<<"/sftp-server\n";
+#endif
+        file.close();
+        x2goDebug<<etcDir +"/sshd_config created";
+#ifdef Q_OS_WIN
+    }
+#endif
+}
+
+void ONMainWindow::generateHostDsaKey()
+{
+    QString etcDir=homeDir+"/.x2go/etc";
+    QDir dr ( homeDir );
+    dr.mkpath ( etcDir );
+    if ( !QFile::exists ( etcDir+"/ssh_host_dsa_key" ) ||
+            !QFile::exists ( etcDir+"/ssh_host_dsa_key.pub" ) )
+    {
+        /*		x2goDebug<<"Generating host DSA key\n";*/
+#ifdef Q_OS_WIN
+        QString fname=cygwinPath ( wapiShortFileName ( etcDir ) ) +
+                      "/ssh_host_dsa_key";
+#else
+        QString fname=etcDir+"/ssh_host_dsa_key";
+#endif
+        QStringList args;
+        args<<"-t"<<"dsa"<<"-N"<<""<<"-C"<<
+        "x2goclient DSA host key"<<"-f"<<fname;
+        QProcess::execute ( "ssh-keygen",args );
+    }
+}
+
+void ONMainWindow::startSshd()
+{
+    if ( embedMode && config.confFS && !config.useFs )
+    {
+        return;
+    }
+#ifdef Q_OS_LINUX
+    clientSshPort="7022";
+#endif
+    QString etcDir=homeDir+"/.x2go/etc";
+    int port=clientSshPort.toInt();
+    //clientSshPort have initvalue
+    while ( isServerRunning ( port ) )
+        ++port;
+    clientSshPort=QString::number ( port );
+#ifdef Q_OS_WIN
+    std::string clientdir=wapiShortFileName ( appDir ).toStdString();
+    std::stringstream strm;
+    strm<<clientdir<<"\\sshd.exe -D -p"<<clientSshPort.toInt();
+
+    STARTUPINFOA si;
+    std::string desktopName="x2go_";
+    desktopName+=getenv ( "USERNAME" );
+    char* desktop=new char[desktopName.size() +1];
+    strcpy ( desktop,desktopName.c_str() );
+    x2goDebug<<"Creating desktop: "<<desktop<<endl;
+    if ( !CreateDesktopA (
+                desktop,
+                0,
+                0,
+                0,
+                GENERIC_ALL,
+                0
+            ) )
+    {
+        strcpy ( desktop,"" );
+        x2goDebug<<"Desktop creation failed, using default\n";
+    }
+    ZeroMemory ( &si, sizeof ( si ) );
+    ZeroMemory ( &sshd, sizeof ( sshd ) );
+    si.lpDesktop=desktop;
+    si.cb = sizeof ( si );
+    CreateProcessA ( NULL,  // No module name (use command line)
+                     ( LPSTR ) strm.str().c_str(),  // Command line
+                     NULL,           // Process handle not inheritable
+                     NULL,           // Thread handle not inheritable
+                     TRUE,          // Set handle inheritance to FALSE
+                     0/*CREATE_NO_WINDOW|CREATE_NEW_PROCESS_GROUP*/,
+                     //creation flags
+                     NULL,           // Use parent's environment block
+                     clientdir.c_str(), // Starting directory
+                     &si,            // Pointer to STARTUPINFO structure
+                     &sshd );// Pointer to PROCESS_INFORMATION structure
+    delete []desktop;
+    winSshdStarted=true;
+#else
+    userSshd=true;
+    sshd=new QProcess ( this );
+    QStringList arguments;
+    arguments<<"-f"<<etcDir +"/sshd_config"<< "-h" <<
+    etcDir+"/ssh_host_dsa_key"<<"-D"<<"-p"<<clientSshPort;
+    sshd->start ( appDir+"/sshd",arguments );
+    x2goDebug<<"Usermode sshd started";
+#endif
+}
+
+void ONMainWindow::setProxyWinTitle()
+{
+
+    QString title;
+
+    if (!useLdap)
+        title=lastSession->name();
+    else
+        title=getCurrentUname()+"@"+resumingSession.server;
+
+    QPixmap pixmap;
+
+    if (useLdap)
+        pixmap=lastUser->foto();
+    else
+        pixmap=*(lastSession->sessIcon());
+
+#ifdef Q_OS_LINUX
+
+    XStoreName(QX11Info::display(), proxyWinId, title.toLocal8Bit().data());
+
+    XWMHints* win_hints;
+
+
+    QByteArray bytes;
+    QBuffer buffer(&bytes);
+    buffer.open(QIODevice::WriteOnly);
+    pixmap.save(&buffer, "XPM");
+
+
+    int rez;
+
+    if (image)
+        XFreePixmap(QX11Info::display(),image);
+    if (shape)
+        XFreePixmap(QX11Info::display(),shape);
+
+
+    rez=XpmCreatePixmapFromBuffer(QX11Info::display(), proxyWinId, bytes.data(),
+                                  (Pixmap *) &image, (Pixmap *) &shape, NULL);
+    if (!rez)
+    {
+
+        win_hints = XAllocWMHints();
+        if (win_hints)
+        {
+            win_hints->flags = IconPixmapHint|IconMaskHint;
+            win_hints->icon_pixmap = image;
+            win_hints->icon_mask = shape;
+            XSetWMHints(QX11Info::display(), proxyWinId, win_hints);
+            XFree(win_hints);
+        }
+    }
+
+#endif
+#ifdef Q_OS_WIN
+    wapiSetWindowText((HWND)proxyWinId, title);
+//       wapiSetWindowIcon((HWND)proxyWinId, pixmap);
+#endif
+}
+
+void ONMainWindow::slotSetProxyWinFullscreen()
+{
+
+#ifdef Q_OS_LINUX
+    XSync(QX11Info::display(),false);
+    XEvent event;
+    long emask = StructureNotifyMask | ResizeRedirectMask;
+    event.xclient.type = ClientMessage;
+    event.xclient.serial = 0;
+    event.xclient.send_event = True;
+    event.xclient.display = QX11Info::display();
+    event.xclient.window = proxyWinId;
+    event.xclient.message_type = XInternAtom(QX11Info::display(),"_NET_WM_STATE",False);
+    event.xclient.format = 32;
+    event.xclient.data.l[0] = 1;
+    event.xclient.data.l[1] = XInternAtom(QX11Info::display(),"_NET_WM_STATE_FULLSCREEN",False);
+    event.xclient.data.l[2] = 0;
+    event.xclient.data.l[3] = 0;
+    event.xclient.data.l[4] = 0;
+    Status st;
+    st=XSendEvent(QX11Info::display(), DefaultRootWindow(QX11Info::display()),
+                  False, emask,&event);
+    XSync(QX11Info::display(),false);
+#endif
+#ifdef Q_OS_WIN
+    wapiSetFSWindow ( ( HWND ) proxyWinId,
+                      dispGeometry );
+
+#endif
+}
+
+
+void ONMainWindow::resizeProxyWinOnDisplay(int disp)
+{
+    QRect geom=QApplication::desktop()->screenGeometry(disp-1);
+    x2goDebug<<"resizing proxy win to fit display "<<disp<<"("<<geom<<")"<<endl;
+#ifdef Q_OS_LINUX
+    XSync(QX11Info::display(),false);
+    XMoveWindow(QX11Info::display(), proxyWinId,geom.x(),geom.y());
+#endif
+#ifdef Q_OS_WIN
+    dispGeometry=geom;
+#endif
+    QTimer::singleShot(500, this, SLOT(slotSetProxyWinFullscreen()));
+}
+
+
+QRect ONMainWindow::proxyWinGeometry()
+{
+#ifdef Q_OS_WIN
+    QRect proxyRect;
+    if (!wapiWindowRectWithoutDecoration((HWND)proxyWinId,proxyRect))
+        return QRect();
+    return proxyRect;
+#endif
+#ifdef Q_OS_LINUX
+    QRect proxyRect;
+    Window root;
+    int x,y;
+    uint w,h,border,depth;
+    if (XGetGeometry(QX11Info::display(), proxyWinId, &root,&x,&y,&w,&h,&border,&depth))
+    {
+
+        int realx,realy;
+        Window child;
+        XTranslateCoordinates(QX11Info::display(), proxyWinId, root, 0, 0, &realx, &realy, &child);
+        proxyRect.setRect(realx, realy, w,h);
+    }
+    return proxyRect;
+#endif
+    return QRect();
+}
+
+void ONMainWindow::slotConfigXinerama()
+{
+    QRect newGeometry=proxyWinGeometry();
+    if (newGeometry.isNull())
+    {
+//     x2goDebug<<"error getting window geometry (window closed?)\n";
+        xineramaTimer->stop();
+        return;
+    }
+    if (newGeometry==lastDisplayGeometry)
+        return;
+    lastDisplayGeometry=newGeometry;
+    x2goDebug<<"New proxy geometry: "<<lastDisplayGeometry<<endl;
+    QDesktopWidget* root=QApplication::desktop();
+    QList<QRect> newXineramaScreens;
+    for (int i=0; i< root->numScreens();++i)
+    {
+        QRect intersection;
+        if (resumingSession.fullscreen)
+            intersection=root->screenGeometry(i);
+        else
+            intersection=root->screenGeometry(i).intersected(lastDisplayGeometry);
+        if (!intersection.isNull())
+        {
+            x2goDebug<<"intersected with "<<i<<": "<<intersection<<endl;
+            intersection.moveLeft(intersection.x()-lastDisplayGeometry.x());
+            intersection.moveTop(intersection.y()-lastDisplayGeometry.y());
+            x2goDebug<<"xinerama screen: "<<intersection<<endl;
+            newXineramaScreens<<intersection;
+        }
+    }
+    if (xineramaScreens != newXineramaScreens)
+    {
+        xineramaScreens=newXineramaScreens;
+        x2goDebug<<"xinerama screen changed, new screens: "<<xineramaScreens<<endl;
+        SshProcess* proc=new SshProcess(sshConnection, this);
+        xineramaTimer->stop();
+        connect (proc, SIGNAL(sshFinished(bool,QString,SshProcess*)), this, SLOT(slotXineramaConfigured()));
+        QStringList screens;
+        foreach (QRect disp, xineramaScreens)
+        screens<<QString::number(disp.x())+" "+QString::number(disp.y())+" "+QString::number(disp.width())+
+        " "+QString::number(disp.height());
+        QString cmd="export DISPLAY=:"+resumingSession.display+";echo -e "+screens.join("\\\\n")+" >  ~/.x2go/C-"+
+                    resumingSession.sessionId+"/xinerama.conf";
+
+        x2goDebug<<cmd<<endl;
+        proc->startNormal(cmd);
+    }
+}
+
+void ONMainWindow::slotXineramaConfigured()
+{
+    if (resumingSession.fullscreen)
+        return;
+    if (xinSizeInc == -1)
+        xinSizeInc=1;
+    else
+        xinSizeInc=-1;
+#ifdef Q_OS_LINUX
+    lastDisplayGeometry.setWidth(lastDisplayGeometry.width()+xinSizeInc);
+    XSync(QX11Info::display(),false);
+    XResizeWindow(QX11Info::display(), proxyWinId,
+                  lastDisplayGeometry.width(),lastDisplayGeometry.height());
+    XSync(QX11Info::display(),false);
+#endif
+#ifdef Q_OS_WIN
+    QRect geom;
+    wapiWindowRect ( (HWND) proxyWinId, geom );
+    wapiMoveWindow( (HWND) proxyWinId, geom.x(), geom.y(), geom.width()+xinSizeInc, geom.height(),true);
+    lastDisplayGeometry=proxyWinGeometry();
+#endif
+    xineramaTimer->start(500);
+}
+
+void ONMainWindow::slotFindProxyWin()
+{
+#ifndef Q_OS_DARWIN
+    x2goDebug<<"search proxy win: "<<"X2GO-"+resumingSession.sessionId;
+    proxyWinId=findWindow ( "X2GO-"+resumingSession.sessionId );
+    bool xinerama=defaultXinerama;
+    if ( proxyWinId )
+    {
+        x2goDebug<<"proxy win found:"<<proxyWinId;
+        setProxyWinTitle();
+        proxyWinTimer->stop();
+        if (!useLdap)
+        {
+            X2goSettings *st;
+            QString sid;
+            if ( !embedMode )
+                sid=lastSession->id();
+            else
+                sid="embedded";
+
+            if (brokerMode)
+                st=new X2goSettings(config.iniFile,QSettings::IniFormat);
+            else
+                st= new X2goSettings( "sessions" );
+            uint displays=QApplication::desktop()->numScreens();
+            xinerama=st->setting()->value ( sid+"/xinerama",
+                                            ( QVariant ) defaultXinerama ).toBool();
+            if (st->setting()->value ( sid+"/multidisp",
+                                       ( QVariant ) false ).toBool())
+            {
+                uint disp=st->setting()->value ( sid+"/display",
+                                                 ( QVariant ) 1 ).toUInt();
+                if (disp>displays)
+                {
+                    disp=1;
+                }
+                resizeProxyWinOnDisplay(disp);
+                return;
+            }
+        }
+        if (xinerama)
+        {
+            x2goDebug<<"Starting xinerama timer\n";
+            lastDisplayGeometry=QRect();
+            xineramaScreens.clear();
+            xineramaTimer->start(500);
+        }
+
+        if ( embedMode )
+        {
+            if ( config.rootless )
+            {
+                x2goDebug<<"win is rootless";
+                act_embedContol->setEnabled ( false );
+            }
+            else
+                slotAttachProxyWindow();
+        }
+#ifdef Q_OS_WIN
+        x2goDebug<<"maximizeProxyWin: "<<maximizeProxyWin;
+        if ( !startEmbedded )
+        {
+            if ( maximizeProxyWin )
+            {
+                QDesktopWidget dw;
+                x2goDebug<<"making proxy win full screen";
+                wapiSetFSWindow ( ( HWND ) proxyWinId,
+                                  dw.screenGeometry ( this ) );
+                /*wapiShowWindow ( ( HWND ) proxyWinId,
+                   WAPI_SHOWMAXIMIZED );*/
+            }
+            else
+            {
+                wapiMoveWindow ( ( HWND ) proxyWinId,0,0,
+                                 proxyWinWidth,
+                                 proxyWinHeight,true );
+            }
+        }
+#endif
+    }
+#endif
+}
+
+
+QString ONMainWindow::getCurrentUname()
+{
+    return login->text();
+}
+
+QString ONMainWindow::getCurrentPass()
+{
+    return pass->text();
+}
+
+void ONMainWindow::slotDetachProxyWindow()
+{
+    proxyWinEmbedded=false;
+    bgFrame->show();
+    setStatStatus();
+    act_embedContol->setText ( tr ( "Attach X2Go window" ) );
+    act_embedContol->setIcon ( QIcon ( ":icons/32x32/attach.png" ) );
+#ifdef Q_OS_LINUX
+    //if QX11EmbedContainer cannot embed window, check if window exists
+    //and reconnect
+    if ( !embedControlChanged )
+    {
+        x2goDebug<<"\n";
+        slotFindProxyWin();
+        x2goDebug<<"proxy win detached, proxywin is:"<<proxyWinId<<endl;
+    }
+#endif
+    embedControlChanged=false;
+}
+
+
+void ONMainWindow::slotAttachProxyWindow()
+{
+    x2goDebug<<"slotAttachProxy";
+    if ( startEmbedded )
+    {
+        embedControlChanged=false;
+        bgFrame->hide();
+        proxyWinEmbedded=true;
+        setStatStatus();
+        act_embedContol->setText ( tr ( "Detach X2Go window" ) );
+        act_embedContol->setIcon (
+            QIcon ( ":icons/32x32/detach.png" ) );
+        QTimer::singleShot ( 100, this, SLOT ( slotEmbedWindow() ) );
+    }
+    else
+    {
+        x2goDebug<<"start embedded was false";
+        startEmbedded=true;
+    }
+
+}
+
+void ONMainWindow::slotEmbedWindow()
+{
+#ifndef Q_OS_DARWIN
+#ifdef CFGPLUGIN
+    embedWindow ( proxyWinId );
+#endif
+    QTimer::singleShot ( 1000, this,
+                         SLOT ( slotActivateWindow() ) );
+
+#endif
+}
+
+void ONMainWindow::setEmbedSessionActionsEnabled ( bool enable )
+{
+    act_shareFolder->setEnabled ( enable );
+    act_suspend->setEnabled ( enable );
+    act_terminate->setEnabled ( enable );
+    act_embedContol->setEnabled ( enable );
+    act_reconnect->setEnabled ( !enable );
+}
+
+void ONMainWindow::slotEmbedControlAction()
+{
+#ifndef Q_OS_DARWIN
+    embedControlChanged=true;
+    if ( proxyWinEmbedded )
+    {
+#ifdef CFGPLUGIN
+        detachClient();
+#endif
+    }
+    else
+        slotAttachProxyWindow();
+#endif
+}
+
+void ONMainWindow::slotEmbedIntoParentWindow()
+{
+#ifndef Q_OS_DARWIN
+// 	embedInto ( embedParent );
+#endif
+}
+
+
+void ONMainWindow::processSessionConfig()
+{
+    sshProxy.use=false;
+    bool haveKey=false;
+
+    config.command="KDE";
+    config.sshport="22";
+    config.session=tr ( "X2Go Session" );
+    config.checkexitstatus=true;
+    config.showtermbutton=true;
+    config.showexpbutton=true;
+    config.showconfig=true;
+    config.showextconfig=true;
+    config.showtoolbar=true;
+    config.showstatusbar=true;
+    config.kbdType=getDefaultKbdType();
+    config.kbdLay=getDefaultLayout()[0];
+
+
+    config.confSnd=false;
+    config.confFS=false;
+    config.confConSpd=false;
+    config.confCompMet=false;
+    config.confImageQ=false;
+    config.confDPI=false;
+    config.confKbd=false;
+
+    QStringList lines=m_x2goconfig.split ( "\n" );
+
+
+    for ( int i=0;i<lines.count();++i )
+    {
+        QString line = lines[i];
+        if ( ( line=="-----BEGIN DSA PRIVATE KEY-----" ) ||
+                ( line=="-----BEGIN RSA PRIVATE KEY-----" ) )
+        {
+            while ( i<lines.count() )
+                config.key+=lines[i++] +"\n";
+            haveKey=true;
+        }
+        else
+            processCfgLine ( line );
+    }
+    act_terminate->setVisible ( config.showtermbutton );
+    act_shareFolder->setVisible ( config.showexpbutton );
+    act_set->setVisible ( config.showconfig );
+    if (!config.showstatusbar)
+    {
+        statusBar()->hide();
+    }
+    if ( managedMode )
+    {
+        QTimer::singleShot ( 500, this, SLOT ( slotStartBroker() ) );
+        return;
+    }
+    slotSelectedFromList ( ( SessionButton* ) 0 );
+}
+
+
+void ONMainWindow::processCfgLine ( QString line )
+{
+    QStringList lst=line.split ( "=" );
+    if ( lst[0]=="command" )
+    {
+        config.command=lst[1];
+        return;
+    }
+    if ( lst[0]=="server" )
+    {
+        config.server=lst[1];
+        return;
+    }
+    if ( lst[0]=="session" )
+    {
+        config.session=lst[1];
+        return;
+    }
+    if ( lst[0]=="sshport" )
+    {
+        config.sshport=lst[1];
+        return;
+    }
+    if ( lst[0]=="user" )
+    {
+        config.user=lst[1];
+        return;
+    }
+    if ( lst[0]=="rootless" )
+    {
+        if ( lst[1]=="true" )
+            config.rootless=true;
+        else
+            config.rootless=false;
+        return;
+    }
+    if ( lst[0]=="checkexitstatus" )
+    {
+        if ( lst[1]=="true" )
+            config.checkexitstatus=true;
+        else
+            config.checkexitstatus=false;
+        return;
+    }
+    if ( lst[0]=="showtermbutton" )
+    {
+        if ( lst[1]=="true" )
+            config.showtermbutton=true;
+        else
+            config.showtermbutton=false;
+        return;
+    }
+    if ( lst[0]=="showexpbutton" )
+    {
+        if ( lst[1]=="true" )
+            config.showexpbutton=true;
+        else
+            config.showexpbutton=false;
+        return;
+    }
+    if ( lst[0]=="showconfig" )
+    {
+        if ( lst[1]=="true" )
+            config.showconfig=true;
+        else
+            config.showconfig=false;
+        return;
+    }
+    if ( lst[0]=="showextconfig" )
+    {
+        if ( lst[1]=="true" )
+            config.showextconfig=true;
+        else
+            config.showextconfig=false;
+        return;
+    }
+    if ( lst[0]=="showstatusbar" )
+    {
+        if ( lst[1]=="true" )
+            config.showstatusbar=true;
+        else
+            config.showstatusbar=false;
+        return;
+    }
+    if ( lst[0]=="showtoolbar" )
+    {
+        if ( lst[1]=="true" )
+            config.showtoolbar=true;
+        else
+            config.showtoolbar=false;
+        return;
+    }
+
+    if ( lst[0]=="sound" )
+    {
+        config.confSnd=true;
+        if ( lst[1]=="true" )
+            config.useSnd=true;
+        else
+            config.useSnd=false;
+        return;
+    }
+    if ( lst[0]=="exportfs" )
+    {
+        config.confFS=true;
+        if ( lst[1]=="true" )
+            config.useFs=true;
+        else
+            config.useFs=false;
+        return;
+    }
+
+    if ( lst[0]=="speed" )
+    {
+        config.confConSpd=true;
+        config.conSpeed=ADSL;
+
+        if ( lst[1]=="modem" )
+            config.conSpeed=MODEM;
+        else if ( lst[1]=="isdn" )
+            config.conSpeed=ISDN;
+        else if ( lst[1]=="adsl" )
+            config.conSpeed=ADSL;
+        else if ( lst[1]=="wan" )
+            config.conSpeed=WAN;
+        else if ( lst[1]=="lan" )
+            config.conSpeed=LAN;
+        else
+        {
+            qCritical (
+                "%s",tr (
+                    "wrong value for argument\"speed\""
+                ).toLocal8Bit().data() );
+        }
+        return;
+    }
+    if ( lst[0]=="compression" )
+    {
+        config.confCompMet=true;
+        config.compMet=lst[1];
+        return;
+    }
+    if ( lst[0]=="quality" )
+    {
+        config.confImageQ=true;
+        config.imageQ=lst[1].toInt();
+        return;
+    }
+    if ( lst[0]=="dpi" )
+    {
+        config.confDPI=true;
+        config.dpi=lst[1].toInt();
+        return;
+    }
+    if ( lst[0]=="kbdlayout" )
+    {
+        config.confKbd=true;
+        config.kbdLay=lst[1];
+        return;
+    }
+    if ( lst[0]=="kbdtype" )
+    {
+        config.confKbd=true;
+        config.kbdType=lst[1];
+        return;
+    }
+    if ( lst[0]=="brokerurl" )
+    {
+        config.brokerurl=lst[1];
+        managedMode=true;
+        acceptRsa=true;
+    }
+    if ( lst[0]=="proxy" )
+    {
+        config.proxy=sshProxy.host=lst[1];
+        sshProxy.use=true;
+#ifdef Q_OS_WIN
+        sshProxy.bin=cygwinPath ( wapiShortFileName ( appDir ) ) +"/ssh";
+#else
+        sshProxy.bin="ssh";
+#endif
+        return;
+    }
+    if ( lst[0]=="proxysshport" )
+    {
+        config.proxyport=sshProxy.port=lst[1];
+        return;
+    }
+    if ( lst[0]=="cookie" )
+    {
+        config.cookie=lst[1];
+        return;
+    }
+    if ( lst[0]=="x2gosession" )
+    {
+        config.sessiondata=lst[1];
+        return;
+    }
+    if ( lst[0]=="connectionts" )
+    {
+        config.connectionts=lst[1];
+        return;
+    }
+}
+
+void ONMainWindow::slotChangeKbdLayout(const QString& layout)
+{
+#ifdef Q_OS_LINUX
+    QStringList args;
+    args<<"-layout"<<layout;
+    x2goDebug<<"running setxkbmap with params: "<<args.join(" ");
+    QProcess::startDetached("setxkbmap",args);
+#endif
+}
+
+void ONMainWindow::initPassDlg()
+{
+    passForm = new SVGFrame ( ":/svg/passform.svg",
+                              false,bgFrame );
+#ifdef Q_OS_WIN
+    passForm->setMainWidget ( ( QWidget* ) this );
+#endif
+    username->addWidget ( passForm );
+    passForm->hide();
+    setWidgetStyle ( passForm );
+    if ( !miniMode )
+        passForm->setFixedSize ( passForm->sizeHint() );
+    else
+        passForm->setFixedSize ( 310,180 );
+    QPalette pal=passForm->palette();
+    pal.setBrush ( QPalette::Window, QColor ( 255,255,255,0 ) );
+    pal.setColor ( QPalette::Active, QPalette::WindowText, QPalette::Mid );
+    pal.setColor ( QPalette::Active, QPalette::ButtonText, QPalette::Mid );
+    pal.setColor ( QPalette::Active, QPalette::Text, QPalette::Mid );
+    pal.setColor ( QPalette::Inactive, QPalette::WindowText, QPalette::Mid );
+    pal.setColor ( QPalette::Inactive, QPalette::ButtonText, QPalette::Mid );
+    pal.setColor ( QPalette::Inactive, QPalette::Text, QPalette::Mid );
+    passForm->setPalette ( pal );
+
+    pal.setColor ( QPalette::Button, QColor ( 255,255,255,0 ) );
+    pal.setColor ( QPalette::Window, QColor ( 255,255,255,255 ) );
+    pal.setColor ( QPalette::Base, QColor ( 255,255,255,255 ) );
+
+
+    QFont fnt=passForm->font();
+    if ( miniMode )
+#ifdef Q_WS_HILDON
+        fnt.setPointSize ( 10 );
+#else
+        fnt.setPointSize ( 9 );
+#endif
+    passForm->setFont ( fnt );
+
+    fotoLabel=new QLabel ( passForm );
+    fotoLabel->hide();
+
+    nameLabel=new QLabel ( "",passForm );
+    nameLabel->hide();
+
+    loginPrompt=new QLabel ( tr ( "Login:" ),passForm );
+    passPrompt=new QLabel ( tr ( "Password:" ),passForm );
+    layoutPrompt=new QLabel ( tr ( "Keyboard layout:" ),passForm );
+
+    login=new ClickLineEdit ( passForm );
+    setWidgetStyle ( login );
+    login->setFrame ( false );
+    login->setEnabled ( false );
+
+    login->hide();
+    loginPrompt->hide();
+
+    pass=new ClickLineEdit ( passForm );
+    setWidgetStyle ( pass );
+    pass->setFrame ( false );
+    fnt.setBold ( true );
+    pass->setFont ( fnt );
+    pass->setEchoMode ( QLineEdit::Password );
+    pass->setFocus();
+
+#ifdef Q_OS_LINUX
+    connect ( login,SIGNAL ( clicked() ),this,
+              SLOT ( slotActivateWindow() ) );
+    connect ( pass,SIGNAL ( clicked() ),this,
+              SLOT ( slotActivateWindow() ) );
+#endif
+
+    pass->hide();
+    passPrompt->hide();
+
+
+    cbLayout=new QComboBox(passForm);
+    cbLayout->addItems(defaultLayout);
+    cbLayout->setFocusPolicy(Qt::NoFocus);
+    cbLayout->setFrame(false);
+    setWidgetStyle(cbLayout);
+    cbLayout->hide();
+    layoutPrompt->hide();
+    QHBoxLayout* cbLayoutLay=new QHBoxLayout();
+    cbLayoutLay->addWidget(cbLayout);
+    cbLayoutLay->addStretch();
+
+
+    ok=new QPushButton ( tr ( "Ok" ),passForm );
+    setWidgetStyle ( ok );
+    cancel=new QPushButton ( tr ( "Cancel" ),passForm );
+    setWidgetStyle ( cancel );
+    ok->hide();
+    cancel->hide();
+
+
+
+    cbLayout->setPalette ( pal );
+    ok->setPalette ( pal );
+    cancel->setPalette ( pal );
+
+
+
+#ifndef Q_WS_HILDON
+    ok->setFixedSize ( ok->sizeHint() );
+    cancel->setFixedSize ( cancel->sizeHint() );
+#else
+    QSize sz=cancel->sizeHint();
+    sz.setWidth ( ( int ) ( sz.width() /1.5 ) );
+    sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
+    cancel->setFixedSize ( sz );
+    sz=ok->sizeHint();
+    sz.setWidth ( ( int ) ( sz.width() /1.5 ) );
+    sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
+    ok->setFixedSize ( sz );
+#endif
+
+    QVBoxLayout *layout=new QVBoxLayout ( passForm );
+    QHBoxLayout *labelLay=new QHBoxLayout();
+    QHBoxLayout *inputLay=new QHBoxLayout();
+    QHBoxLayout *buttonLay=new QHBoxLayout();
+
+    labelLay->setSpacing ( 20 );
+    inputLay->setSpacing ( 10 );
+    layout->setContentsMargins ( 20,20,10,10 );
+    layout->addLayout ( labelLay );
+    layout->addStretch();
+    layout->addLayout ( inputLay );
+    layout->addStretch();
+    layout->addLayout ( buttonLay );
+
+    labelLay->addWidget ( fotoLabel );
+    labelLay->addWidget ( nameLabel );
+    labelLay->addStretch();
+
+    QVBoxLayout* il1=new QVBoxLayout();
+    il1->addWidget ( loginPrompt );
+    il1->addWidget ( passPrompt );
+    il1->addWidget ( layoutPrompt );
+
+    QVBoxLayout* il2=new QVBoxLayout();
+    il2->addWidget ( login );
+    il2->addWidget ( pass );
+    il2->addLayout ( cbLayoutLay );
+    inputLay->addLayout ( il1 );
+    inputLay->addLayout ( il2 );
+    inputLay->addStretch();
+
+    buttonLay->addStretch();
+    buttonLay->addWidget ( ok );
+    buttonLay->addWidget ( cancel );
+    buttonLay->addStretch();
+
+    pal.setColor ( QPalette::Base, QColor ( 239,239,239,255 ) );
+    login->setPalette ( pal );
+    pass->setPalette ( pal );
+
+    connect ( ok,SIGNAL ( clicked() ),this, SLOT ( slotSessEnter() ) );
+    connect ( cancel,SIGNAL ( clicked() ),this, SLOT ( slotClosePass() ) );
+    connect ( pass,SIGNAL ( returnPressed() ),this,
+              SLOT ( slotSessEnter() ) );
+    connect ( login,SIGNAL ( returnPressed() ),pass, SLOT ( selectAll() ) );
+    connect ( login,SIGNAL ( returnPressed() ),pass, SLOT ( setFocus() ) );
+
+    passPrompt->show();
+    pass->show();
+    ok->show();
+    cancel->show();
+    fotoLabel->show();
+    nameLabel->show();
+    if ( !useLdap )
+    {
+        login->show();
+        loginPrompt->show();
+    }
+    if ( embedMode )
+    {
+        cancel->setEnabled ( false );
+#ifdef Q_OS_WIN
+        QRect r;
+        wapiWindowRect ( ok->winId(),r );
+#endif
+    }
+    if (defaultLayout.size()>1)
+    {
+        layoutPrompt->show();
+        cbLayout->show();
+        slotChangeKbdLayout(cbLayout->currentText());
+        connect (cbLayout,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotChangeKbdLayout(QString)));
+    }
+}
+
+
+void ONMainWindow::initStatusDlg()
+{
+    sessionStatusDlg = new SVGFrame ( ":/svg/passform.svg",
+                                      false,bgFrame );
+    sessionStatusDlg->hide();
+    if ( !miniMode )
+        sessionStatusDlg->setFixedSize (
+            sessionStatusDlg->sizeHint() );
+    else
+        sessionStatusDlg->setFixedSize ( 310,200 );
+    QFont fnt=sessionStatusDlg->font();
+    if ( miniMode )
+#ifdef Q_WS_HILDON
+        fnt.setPointSize ( 10 );
+#else
+        fnt.setPointSize ( 9 );
+#endif
+    sessionStatusDlg->setFont ( fnt );
+    username->addWidget ( sessionStatusDlg );
+    QPalette pal=sessionStatusDlg->palette();
+    pal.setBrush ( QPalette::Window, QColor ( 0,0,0,0 ) );
+    pal.setColor ( QPalette::Active, QPalette::WindowText, QPalette::Mid );
+    pal.setColor ( QPalette::Active, QPalette::ButtonText, QPalette::Mid );
+    pal.setColor ( QPalette::Active, QPalette::Text, QPalette::Mid );
+    pal.setColor ( QPalette::Inactive, QPalette::WindowText, QPalette::Mid );
+    pal.setColor ( QPalette::Inactive, QPalette::ButtonText, QPalette::Mid );
+    pal.setColor ( QPalette::Inactive, QPalette::Text, QPalette::Mid );
+
+    sessionStatusDlg->setPalette ( pal );
+
+    slName=new QLabel ( sessionStatusDlg );
+    slVal=new QLabel ( sessionStatusDlg );
+
+    slName->setText (
+        tr (
+            "<b>Session ID:<br>Server:<br>Username:"
+            "<br>Display:<br>Creation time:<br>Status:</b>" ) );
+    slName->setFixedSize ( slName->sizeHint() );
+    slName->hide();
+
+    slVal->hide();
+    slVal->setFixedHeight ( slName->sizeHint().height() );
+
+    sbApps=new QToolButton (sessionStatusDlg );
+    sbApps->setToolTip(tr ( "Applications..." ));
+    sbApps->setIcon(QPixmap(":/icons/32x32/apps.png"));
+    sbApps->setAutoRaise(true);
+    sbApps->setFocusPolicy(Qt::NoFocus);
+
+    sbExp=new QToolButton (sessionStatusDlg );
+    sbExp->setIcon(QPixmap(":/icons/32x32/open_dir.png"));
+    sbExp->setToolTip (tr ("Share folder..." ));
+    sbExp->setAutoRaise(true);
+    sbExp->setFocusPolicy(Qt::NoFocus);
+
+    sbSusp=new QToolButton (sessionStatusDlg );
+    sbSusp->setIcon(QPixmap(":/icons/32x32/suspend_session.png"));
+    sbSusp->setToolTip(tr ( "Abort" ));
+    sbSusp->setAutoRaise(true);
+    sbSusp->setFocusPolicy(Qt::NoFocus);
+
+
+    sbTerm=new QToolButton (sessionStatusDlg );
+    sbTerm->setIcon(QPixmap(":/icons/32x32/stop_session.png"));
+    sbTerm->setToolTip(tr ( "Terminate" ));
+    sbTerm->setAutoRaise(true);
+    sbTerm->setFocusPolicy(Qt::NoFocus);
+
+
+    sbAdv=new QCheckBox ( tr ( "Show details" ),sessionStatusDlg );
+    setWidgetStyle ( sbTerm );
+    setWidgetStyle ( sbApps );
+    setWidgetStyle ( sbExp );
+    setWidgetStyle ( sbSusp );
+    setWidgetStyle ( sbAdv );
+
+    sbAdv->setFixedSize ( sbAdv->sizeHint() );
+    sbApps->setFixedSize ( 32,32 );
+    sbSusp->setFixedSize ( 32,32 );
+    sbTerm->setFixedSize ( 32,32 );
+    sbExp->setFixedSize ( 32,32 );
+
+    /*
+        sbApps->setFocusPolicy(Qt::NoFocus);
+        sbSusp->setFocusPolicy(Qt::NoFocus);
+        sbTerm->setFocusPolicy(Qt::NoFocus);
+        sbExp->setFocusPolicy(Qt::NoFocus);*/
+
+    sbAdv->hide();
+    sbSusp->hide();
+    sbTerm->hide();
+    sbExp->hide();
+    sbApps->hide();
+
+
+    pal.setColor ( QPalette::Button, QColor ( 255,255,255,0 ) );
+    pal.setColor ( QPalette::Window, QColor ( 255,255,255,255 ) );
+    pal.setColor ( QPalette::Base, QColor ( 255,255,255,255 ) );
+
+    sbAdv->setPalette ( pal );
+    sbApps->setPalette ( pal );
+    sbSusp->setPalette ( pal );
+    sbTerm->setPalette ( pal );
+    sbExp->setPalette ( pal );
+
+    stInfo=new QTextEdit ( sessionStatusDlg );
+    setWidgetStyle ( stInfo );
+    setWidgetStyle ( stInfo->verticalScrollBar() );
+    stInfo->setReadOnly ( true );
+    stInfo->hide();
+    stInfo->setFrameStyle ( QFrame::StyledPanel|QFrame::Plain );
+    stInfo->setPalette ( pal );
+
+    sbExp->setEnabled ( false );
+
+    connect ( sbSusp,SIGNAL ( clicked() ),this,
+              SLOT ( slotTestSessionStatus() ) );
+    connect ( sbTerm,SIGNAL ( clicked() ),this,
+              SLOT ( slotTermSessFromSt() ) );
+    connect ( sbAdv,SIGNAL ( clicked() ),this,
+              SLOT ( slotShowAdvancedStat() ) );
+    connect ( sbExp,SIGNAL ( clicked() ),this,
+              SLOT ( slotExportDirectory() ) );
+    connect ( sbApps,SIGNAL ( clicked() ),this,
+              SLOT ( slotAppDialog()) );
+
+    QVBoxLayout* layout=new QVBoxLayout ( sessionStatusDlg );
+    QHBoxLayout* ll=new QHBoxLayout();
+    ll->addWidget ( slName );
+    ll->addWidget ( slVal );
+    ll->addStretch();
+    ll->setSpacing ( 10 );
+    if ( !miniMode )
+        layout->setContentsMargins ( 25,25,10,10 );
+    else
+        layout->setContentsMargins ( 10,10,10,10 );
+
+    QHBoxLayout* bl=new QHBoxLayout();
+    bl->addStretch();
+    bl->addWidget ( sbApps );
+    bl->addWidget ( sbExp );
+    bl->addWidget ( sbSusp );
+    bl->addWidget ( sbTerm );
+//     bl->addStretch();
+    layout->addLayout ( ll );
+    layout->addStretch();
+    layout->addWidget ( stInfo );
+    layout->addWidget ( sbAdv );
+    layout->addStretch();
+    layout->addLayout ( bl );
+
+
+    slName->show();
+    slVal->show();
+    sbAdv->show();
+    if ( !embedMode )
+    {
+        sbSusp->show();
+        sbTerm->show();
+        sbExp->show();
+    }
+
+    X2goSettings st ( "settings" );
+
+
+    if ( st.setting()->value ( "showStatus", ( QVariant ) false ).toBool() )
+    {
+        sbAdv->setChecked ( true );
+        slotShowAdvancedStat();
+    }
+#ifdef Q_OS_WIN
+    if ( embedMode )
+    {
+        QRect r;
+        wapiWindowRect ( sbAdv->winId(),r );
+        wapiWindowRect ( stInfo->verticalScrollBar ()->winId(),r );
+    }
+#endif
+
+}
+
+
+void ONMainWindow::initSelectSessDlg()
+{
+    selectSessionDlg = new SVGFrame ( ":/svg/passform.svg",
+                                      false,bgFrame );
+    username->addWidget ( selectSessionDlg );
+    setWidgetStyle ( selectSessionDlg );
+    if ( !miniMode )
+        selectSessionDlg->setFixedSize ( selectSessionDlg->sizeHint() );
+    else
+        selectSessionDlg->setFixedSize ( 310,180 );
+    QPalette pal=selectSessionDlg->palette();
+    pal.setBrush ( QPalette::Window, QColor ( 255,255,255,0 ) );
+    pal.setColor ( QPalette::Active, QPalette::WindowText, QPalette::Mid );
+    pal.setColor ( QPalette::Active, QPalette::ButtonText, QPalette::Mid );
+    pal.setColor ( QPalette::Active, QPalette::Text, QPalette::Mid );
+    pal.setColor ( QPalette::Inactive, QPalette::WindowText, QPalette::Mid );
+    pal.setColor ( QPalette::Inactive, QPalette::ButtonText, QPalette::Mid );
+    pal.setColor ( QPalette::Inactive, QPalette::Text, QPalette::Mid );
+
+    selectSessionDlg->setPalette ( pal );
+
+    pal.setColor ( QPalette::Button, QColor ( 255,255,255,0 ) );
+    pal.setColor ( QPalette::Window, QColor ( 255,255,255,255 ) );
+    pal.setColor ( QPalette::Base, QColor ( 255,255,255,255 ) );
+
+    QFont fnt=selectSessionDlg->font();
+    if ( miniMode )
+#ifdef Q_WS_HILDON
+        fnt.setPointSize ( 10 );
+#else
+        fnt.setPointSize ( 9 );
+#endif
+    selectSessionDlg->setFont ( fnt );
+    selectSessionLabel=new QLabel ( tr ( "Select session:" ),
+                                    selectSessionDlg );
+    sOk=new QPushButton ( tr ( "Resume" ),selectSessionDlg );
+    setWidgetStyle ( sOk );
+    sCancel=new QPushButton ( tr ( "Cancel" ),selectSessionDlg );
+    setWidgetStyle ( sCancel );
+    bCancel=new QPushButton ( tr ( "Cancel" ),selectSessionDlg );
+    setWidgetStyle ( bCancel );
+
+    bSusp=new QPushButton ( tr ( "Suspend" ),selectSessionDlg );
+    setWidgetStyle ( bSusp );
+    bTerm=new QPushButton ( tr ( "Terminate" ),selectSessionDlg );
+    setWidgetStyle ( bTerm );
+
+    bNew=new QPushButton ( tr ( "New" ),selectSessionDlg );
+    setWidgetStyle ( bNew );
+
+    bShadow=new QPushButton ( tr ( "Full access" ),selectSessionDlg );
+    setWidgetStyle ( bShadow );
+
+    bShadowView=new QPushButton ( tr ( "View only" ),selectSessionDlg );
+    setWidgetStyle ( bShadowView );
+
+    sOk->setPalette ( pal );
+    sCancel->setPalette ( pal );
+
+    connect ( sCancel,SIGNAL ( clicked() ),this,
+              SLOT ( slotCloseSelectDlg() ) );
+    connect ( bCancel,SIGNAL ( clicked() ),this,
+              SLOT ( slotCloseSelectDlg() ) );
+
+    selectSessionDlg->show();
+#ifndef Q_WS_HILDON
+    sOk->setFixedSize ( ok->sizeHint() );
+    sCancel->setFixedSize ( cancel->sizeHint() );
+#else
+    QSize sz=sCancel->sizeHint();
+    sz.setWidth ( ( int ) ( sz.width() /1.5 ) );
+    sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
+    sCancel->setFixedSize ( sz );
+    sz=sOk->sizeHint();
+    sz.setWidth ( ( int ) ( sz.width() /1.5 ) );
+    sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
+    sOk->setFixedSize ( sz );
+    sz=bSusp->sizeHint();
+    if ( bTerm->sizeHint().width() > sz.width() )
+        sz=bTerm->sizeHint();
+    if ( bNew->sizeHint().width() > sz.width() )
+        sz=bNew->sizeHint();
+    sz.setWidth ( ( int ) ( sz.width() /1.5 ) );
+    sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
+    bSusp->setFixedSize ( sz );
+    bTerm->setFixedSize ( sz );
+    bNew->setFixedSize ( sz );
+#endif
+    int bmaxw=bNew->size().width();
+    if ( bSusp->size().width() >bmaxw )
+        bmaxw=bSusp->size().width();
+    if ( bTerm->size().width() >bmaxw )
+        bmaxw=bTerm->size().width();
+
+    bNew->setFixedWidth ( bmaxw );
+    bSusp->setFixedWidth ( bmaxw );
+    bTerm->setFixedWidth ( bmaxw );
+
+
+
+    sOk->setEnabled ( true );
+    sCancel->setEnabled ( true );
+    selectSessionDlg->setEnabled ( true );
+    setEnabled ( true );
+
+    sessTv=new QTreeView ( selectSessionDlg );
+    setWidgetStyle ( sessTv );
+    setWidgetStyle ( sessTv->horizontalScrollBar() );
+    setWidgetStyle ( sessTv->verticalScrollBar() );
+    sessTv->setItemsExpandable ( false );
+    sessTv->setRootIsDecorated ( false );
+
+    model=new QStandardItemModel ( sessions.size(), 8 );
+    model->setHeaderData ( S_DISPLAY,Qt::Horizontal,
+                           QVariant ( ( QString ) tr ( "Display" ) ) );
+    model->setHeaderData ( S_STATUS,Qt::Horizontal,
+                           QVariant ( ( QString ) tr ( "Status" ) ) );
+    model->setHeaderData ( S_COMMAND,Qt::Horizontal,
+                           QVariant ( ( QString ) tr ( "Command" ) ) );
+    model->setHeaderData ( S_TYPE,Qt::Horizontal,
+                           QVariant ( ( QString ) tr ( "Type" ) ) );
+    model->setHeaderData ( S_SERVER,Qt::Horizontal,
+                           QVariant ( ( QString ) tr ( "Server" ) ) );
+    model->setHeaderData (
+        S_CRTIME,Qt::Horizontal,
+        QVariant ( ( QString ) tr ( "Creation time" ) ) );
+    model->setHeaderData ( S_IP,Qt::Horizontal,
+                           QVariant ( ( QString ) tr ( "Client IP" ) ) );
+    model->setHeaderData ( S_ID,Qt::Horizontal,
+                           QVariant ( ( QString ) tr ( "Session ID" ) ) );
+
+    modelDesktop=new QStandardItemModel ( sessions.size(), 2 );
+    modelDesktop->setHeaderData ( D_USER,Qt::Horizontal,
+                                  QVariant ( ( QString ) tr ( "User" ) ) );
+    modelDesktop->setHeaderData (
+        D_DISPLAY,Qt::Horizontal,
+        QVariant ( ( QString ) tr ( "Display" ) ) );
+
+    sessTv->setModel ( ( QAbstractItemModel* ) model );
+
+    QFontMetrics fm ( sessTv->font() );
+    sessTv->setEditTriggers ( QAbstractItemView::NoEditTriggers );
+    sessTv->setPalette ( pal );
+
+    sessTv->setModel ( ( QAbstractItemModel* ) model );
+
+    bNew->setPalette ( pal );
+    bShadow->setPalette ( pal );
+    bShadowView->setPalette ( pal );
+    bSusp->setPalette ( pal );
+    bTerm->setPalette ( pal );
+    sessTv->setFrameStyle ( QFrame::StyledPanel|QFrame::Plain );
+    sOk->setEnabled ( false );
+    bSusp->setEnabled ( false );
+    bTerm->setEnabled ( false );
+    bShadow->setEnabled ( false );
+    selectSessionLabel->hide();
+    bCancel->setPalette ( pal );
+    bCancel->hide();
+
+    desktopFilter=new QLineEdit ( selectSessionDlg );
+    setWidgetStyle ( desktopFilter );
+// 	desktopFilter->setFrame ( false );
+
+    desktopFilterCb=new QCheckBox ( tr ( "Only my desktops" ),
+                                    selectSessionDlg );
+    desktopFilterCb->hide();
+
+    QVBoxLayout* layout=new QVBoxLayout ( selectSessionDlg );
+    QHBoxLayout* filterLay=new QHBoxLayout();
+    QHBoxLayout* blay=new QHBoxLayout();
+    QVBoxLayout* alay=new QVBoxLayout();
+    QHBoxLayout* tvlay=new QHBoxLayout();
+
+    selectSesDlgLayout=layout;
+
+    layout->addWidget ( selectSessionLabel );
+    layout->addLayout ( filterLay );
+    layout->addLayout ( tvlay );
+    layout->addLayout ( blay );
+
+    filterLay->addWidget ( desktopFilter );
+    filterLay->addWidget ( desktopFilterCb );
+
+    alay->addWidget ( bSusp );
+    alay->addWidget ( bTerm );
+    alay->addWidget ( bShadowView );
+    alay->addWidget ( bShadow );
+    alay->addStretch();
+    alay->addWidget ( bNew );
+    alay->addWidget ( bCancel );
+
+    tvlay->addWidget ( sessTv );
+    tvlay->addLayout ( alay );
+
+    blay->addStretch();
+    blay->addWidget ( sOk );
+    blay->addWidget ( sCancel );
+    blay->addStretch();
+    if ( !miniMode )
+        layout->setContentsMargins ( 25,25,10,10 );
+    else
+        layout->setContentsMargins ( 10,10,10,10 );
+
+
+
+    sOk->hide();
+    sCancel->hide();
+    bNew->hide();
+    bSusp->hide();
+    bTerm->hide();
+
+    connect ( sessTv,SIGNAL ( clicked ( const QModelIndex& ) ),
+              this,SLOT ( slotActivated ( const QModelIndex& ) ) );
+
+    connect ( sessTv,SIGNAL ( doubleClicked ( const QModelIndex& ) ),
+              this,SLOT ( slotResumeDoubleClick ( const QModelIndex& ) ) );
+
+    connect ( sOk,SIGNAL ( clicked() ),this, SLOT ( slotResumeSess() ) );
+    connect ( bSusp,SIGNAL ( clicked() ),this, SLOT ( slotSuspendSess() ) );
+    connect ( bTerm,SIGNAL ( clicked() ),this, SLOT ( slotTermSess() ) );
+    connect ( bNew,SIGNAL ( clicked() ),this, SLOT ( slotNewSess() ) );
+
+    connect ( bShadow,SIGNAL ( clicked() ),this,
+              SLOT ( slotShadowSess() ) );
+    connect ( bShadowView,SIGNAL ( clicked() ),this,
+              SLOT ( slotShadowViewSess() ) );
+
+    connect ( desktopFilter,SIGNAL ( textEdited ( const QString& ) ),this,
+              SLOT ( slotDesktopFilterChanged ( const QString& ) ) );
+    connect ( desktopFilterCb,SIGNAL ( stateChanged ( int ) ),
+              this,
+              SLOT ( slotDesktopFilterCb ( int ) ) );
+
+    selectSessionLabel->show();
+    sOk->show();
+    sCancel->show();
+    bNew->show();
+    bSusp->show();
+    bTerm->show();
+    sessTv->show();
+    selectSessionDlg->hide();
+#ifdef Q_OS_WIN
+    if ( embedMode )
+    {
+        QRect r;
+        wapiWindowRect ( sOk->winId(),r );
+        wapiWindowRect ( sessTv->verticalScrollBar ()->winId(),r );
+        wapiWindowRect ( sessTv->horizontalScrollBar ()->winId(),r );
+        wapiWindowRect ( sessTv->header ()->viewport()->winId(),r );
+    }
+#endif
+
+}
+
+
+
+void ONMainWindow::printSshDError()
+{
+    if ( closeEventSent )
+        return;
+    QMessageBox::critical ( 0l,tr ( "Error" ),
+                            tr ( "sshd not started, "
+                                 "you'll need sshd for printing "
+                                 "and file sharing\n"
+                                 "you can install sshd with\n"
+                                 "<b>sudo apt-get install "
+                                 "openssh-server</b>" ),
+                            QMessageBox::Ok,QMessageBox::NoButton );
+}
+
+void ONMainWindow::slotStartParec ()
+{
+    if ( !parecTunnelOk )
+    {
+// 		wait 1 sec and try again
+        QTimer::singleShot ( 1000, this, SLOT ( slotStartParec() ) );
+        return;
+    }
+    SshProcess* paProc;
+    QString passwd=getCurrentPass();
+    QString user=getCurrentUname();
+    QString host=resumingSession.server;
+    QString scmd="PULSE_CLIENTCONFIG=~/.x2go/C-"+
+                 resumingSession.sessionId+
+                 "/.pulse-client.conf "+
+                 "parec > /dev/null &sleep 1 && kill %1";
+
+    paProc=new SshProcess ( sshConnection, this );
+    paProc->startNormal ( scmd );
+}
+
+
+void ONMainWindow::slotSndTunOk()
+{
+    parecTunnelOk=true;
+}
+
+
+void ONMainWindow::slotPCookieReady (	bool result,
+                                      QString ,
+                                      SshProcess* )
+{
+    if ( result )
+        slotStartParec();
+}
+
+
+void ONMainWindow::loadPulseModuleNativeProtocol()
+{
+    QProcess* proc=new QProcess ( this );
+    QStringList args;
+    args<<"load-module"<<"module-native-protocol-tcp";
+    proc->start ( "pactl",args );
+    proc->waitForFinished ( 3000 );
+}
+
+void ONMainWindow::slotEmbedToolBar()
+{
+    if ( statusLabel )
+    {
+        delete statusLabel;
+        statusLabel=0;
+    }
+    if ( embedTbVisible )
+    {
+        stb->clear();
+        act_embedToolBar->setIcon (
+            QIcon ( ":icons/16x16/tbshow.png" ) );
+        stb->addAction ( act_embedToolBar );
+        stb->setToolButtonStyle ( Qt::ToolButtonIconOnly );
+        stb->widgetForAction (
+            act_embedToolBar )->setFixedHeight ( 16 );
+        act_embedToolBar->setText ( tr ( "Restore toolbar" ) );
+        statusLabel=new QLabel;
+        stb->addWidget ( statusLabel );
+#ifndef Q_OS_WIN
+        statusBar()->hide();
+#endif
+    }
+    else
+    {
+        initEmbedToolBar();
+        act_embedToolBar->setIcon (
+            QIcon ( ":icons/32x32/tbhide.png" ) );
+        act_embedToolBar->setText ( tr ( "Minimize toolbar" ) );
+    }
+    embedTbVisible=!embedTbVisible;
+    if ( proxyWinEmbedded )
+        setStatStatus();
+    X2goSettings st ( "sessions" );
+    st.setting()->setValue ( "embedded/tbvisible", embedTbVisible );
+    st.setting()->sync();
+}
+
+void ONMainWindow::initEmbedToolBar()
+{
+    stb->addAction ( act_embedToolBar );
+    stb->addSeparator();
+    stb->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon );
+    stb->addAction ( act_shareFolder );
+    stb->addAction ( act_reconnect );
+    stb->addAction ( act_suspend );
+    stb->addAction ( act_terminate );
+    stb->addSeparator();
+    stb->addAction ( act_embedContol );
+    stb->addSeparator();
+    stb->addAction ( act_set );
+    stb->addAction ( act_abclient );
+}
+
+void ONMainWindow::slotEmbedToolBarToolTip()
+{
+    if ( !showTbTooltip )
+        return;
+    QWidget* widg=stb->widgetForAction (
+                      act_embedToolBar );
+    QToolTip::showText ( this->mapToGlobal ( QPoint ( 6,6 ) ),
+                         tr ( "<br><b>   Click this "
+                              "button   <br>"
+                              "   to restore toolbar"
+                              "   </b><br>" ),
+                         widg );
+}
+
+
+void ONMainWindow::slotActivateWindow()
+{
+    if ( embedMode )
+    {
+        QApplication::setActiveWindow ( this ) ;
+        activateWindow();
+
+        /*		x2goDebug<<"focus:"<<pass->hasFocus();
+        		x2goDebug<<"activ:"<<pass->isActiveWindow();*/
+        QTimer::singleShot ( 50, this,
+                             SLOT ( slotEmbedToolBarToolTip() ) );
+    }
+}
+
+#ifndef Q_OS_WIN
+void ONMainWindow::mouseReleaseEvent ( QMouseEvent * event )
+{
+    QMainWindow::mouseReleaseEvent ( event );
+    slotActivateWindow();
+}
+#endif
+
+void ONMainWindow::slotHideEmbedToolBarToolTip()
+{
+    showTbTooltip=false;
+    QToolTip::hideText();
+}
+
+
+void ONMainWindow::slotDesktopFilterChanged ( const QString& text )
+{
+    filterDesktops ( text );
+}
+
+
+void ONMainWindow::slotDesktopFilterCb ( int state )
+{
+    if ( state==Qt::Checked )
+    {
+        filterDesktops ( getCurrentUname(),true );
+        desktopFilter->setEnabled ( false );
+    }
+    else
+    {
+        filterDesktops ( desktopFilter->text() );
+        desktopFilter->setEnabled ( true );
+    }
+}
+
+
+void ONMainWindow::filterDesktops ( const QString& filter, bool strict )
+{
+    modelDesktop->setRowCount ( 0 );
+    bShadow->setEnabled ( false );
+    bShadowView->setEnabled ( false );
+    QFontMetrics fm ( sessTv->font() );
+    uint nextRow=0;
+    for ( int row = 0; row < selectedDesktops.size(); ++row )
+    {
+        QStringList desktop=selectedDesktops[row].split ( "@" );
+        if ( filter==tr ( "Filter" ) ||filter.length() <=0||
+                ( strict && desktop[0]==filter )  ||
+                ( !strict && desktop[0].startsWith ( filter ) ) )
+        {
+            QStandardItem *item;
+            item= new QStandardItem ( desktop[0] );
+            modelDesktop->setItem ( nextRow,D_USER,item );
+            item= new QStandardItem ( desktop[1] );
+            modelDesktop->setItem ( nextRow++,D_DISPLAY,item );
+            for ( int j=0;j<2;++j )
+            {
+                QString txt=
+                    modelDesktop->index (
+                        row,j ).data().toString();
+                if ( sessTv->header()->sectionSize ( j ) <
+                        fm.width ( txt ) +6 )
+                {
+                    sessTv->header()->resizeSection (
+                        j,fm.width ( txt ) +6 );
+                }
+            }
+        }
+    }
+}
+
+
+void ONMainWindow::slotShadowSess()
+{
+    shadowMode=SHADOW_FULL;
+    slotShadowViewSess();
+}
+
+void ONMainWindow::slotShadowViewSess()
+{
+    shadowUser=sessTv->model()->index ( sessTv->currentIndex().row(),
+                                        D_USER ).data().toString();
+    shadowDisplay=sessTv->model()->index ( sessTv->currentIndex().row(),
+                                           D_DISPLAY ).data().toString();
+    startNewSession();
+}
+
+
+void ONMainWindow::slotReconnectSession()
+{
+    if ( !managedMode )
+        slotSelectedFromList ( ( SessionButton* ) 0 );
+    else
+    {
+        broker->getSInfoFromBroker();
+        setEnabled ( false );
+    }
+}
+
+
+QSize ONMainWindow::getEmbedAreaSize()
+{
+    if ( embedTbVisible && config.showstatusbar )
+        statusBar()->show();
+    QSize sz=bgFrame->size();
+//     sz.setHeight(sz.height()-statusBar()->size().height());
+    statusBar()->hide();
+    return sz;
+}
+
+
+void ONMainWindow::slotStartBroker()
+{
+    config.brokerPass=pass->text();
+    config.brokerUser=login->text();
+    setStatStatus ( tr ( "Connecting to broker" ) );
+    stInfo->insertPlainText ( "broker url: "+config.brokerurl );
+    setEnabled ( false );
+    broker->getUserSessions();
+}
+
+void ONMainWindow::slotGetBrokerSession(const QString& sinfo)
+{
+    //x2goDebug<<"broker session: "<<sinfo;
+    QStringList lst=sinfo.split("SERVER:",QString::SkipEmptyParts);
+    int keyStartPos=sinfo.indexOf("-----BEGIN DSA PRIVATE KEY-----");
+    QString endStr="-----END DSA PRIVATE KEY-----";
+    int keyEndPos=sinfo.indexOf(endStr);
+    if (! (keyEndPos == -1 || keyStartPos == -1 || lst.size()==0))
+        config.key=sinfo.mid(keyStartPos, keyEndPos+endStr.length()-keyStartPos);
+    QString serverLine=(lst[1].split("\n"))[0];
+    QStringList words=serverLine.split(":",QString::SkipEmptyParts);
+    config.server=words[0];
+    if (words.count()>1)
+        config.sshport=words[1];
+//    x2goDebug<<"server: "<<config.server<<endl<<" key: "<<config.key;
+    if (sinfo.indexOf("SESSION_INFO")!=-1)
+    {
+        QStringList lst=sinfo.split("SESSION_INFO:",QString::SkipEmptyParts);
+        config.sessiondata=(lst[1].split("\n"))[0];
+// 	x2goDebug<<"data: "<<config.sessiondata;
+    }
+    slotSessEnter();
+}
+
+void ONMainWindow::slotStartNewBrokerSession ( )
+{
+    if ( managedMode )
+    {
+        setEnabled ( true );
+        slotSelectedFromList ( ( SessionButton* ) 0 );
+    }
+}
+
+#ifdef Q_OS_WIN
+QString ONMainWindow::u3DataPath()
+{
+    QStringList env=QProcess::systemEnvironment();
+    QString dpath;
+    for ( int i=0;i<env.size();++i )
+    {
+// 		x2goDebug << env[i];
+        //check if we have U3 System
+        if ( env[i].indexOf ( "U3_APP_DATA_PATH=" ) ==0 )
+        {
+            dpath=env[i];
+        }
+        if ( env[i].indexOf ( "U3_DEVICE_PATH=" ) ==0 )
+        {
+            u3Device=env[i];
+            u3Device.replace ( "U3_DEVICE_PATH=","" );
+        }
+
+    }
+
+    if ( dpath.length() >0 )
+    {
+        dpath.replace ( "U3_APP_DATA_PATH=","" );
+        portableDataPath=dpath;
+        return dpath;
+    }
+    return QString::null;
+}
+
+#endif
+
+void ONMainWindow::cleanPortable()
+{
+    removeDir ( homeDir +"/.ssh" );
+    removeDir ( homeDir +"/ssh" );
+    removeDir ( homeDir+"/.x2go" );
+    if (cleanAllFiles)
+        removeDir(homeDir+"/.x2goclient");
+}
+
+void ONMainWindow::removeDir ( QString path )
+{
+    x2goDebug<<"entering " <<path;
+    QDir dr ( path );
+    QStringList files=dr.entryList ( QDir::Files );
+    for ( int i=0;i<files.size();++i )
+    {
+        if ( files[i]!="known_hosts" || cleanAllFiles)
+        {
+            x2goDebug<<"cleaning file:"<<path+"/"+files[i];
+            dr.remove ( path+"/"+files[i] );
+        }
+    }
+    QStringList dirs=dr.entryList ( QDir::AllDirs|QDir::NoDotAndDotDot );
+    for ( int i=0;i<dirs.size();++i )
+    {
+        removeDir ( path+"/"+dirs[i] );
+    }
+    dr.rmdir ( path );
+}
+
+#ifdef Q_OS_LINUX
+long ONMainWindow::X11FindWindow ( QString text, long rootWin )
+{
+    Window    wParent;
+    Window    wRoot;
+    Window   *child_list;
+    unsigned  nChildren;
+    long proxyId=0;
+    if ( !rootWin )
+        rootWin= XDefaultRootWindow ( QX11Info::display() );
+
+    if ( XQueryTree ( QX11Info::display(),rootWin,&wRoot,&wParent,
+                      &child_list,&nChildren ) )
+    {
+        for ( uint i=0;i<nChildren;++i )
+        {
+            char *wname;
+            if ( XFetchName ( QX11Info::display(),
+                              child_list[i],&wname ) )
+            {
+                QString title ( wname );
+                XFree ( wname );
+                if ( title==text )
+                {
+                    proxyId=child_list[i];
+                    break;
+                }
+            }
+            proxyId=X11FindWindow ( text, child_list[i] );
+            if ( proxyId )
+                break;
+        }
+        XFree ( child_list );
+    }
+    return proxyId;
+}
+#endif
+
+long ONMainWindow::findWindow ( QString text )
+{
+#ifdef Q_OS_LINUX
+    return X11FindWindow ( text );
+#endif
+#ifdef Q_OS_WIN
+    return ( long ) wapiFindWindow ( 0,text.utf16() );
+#endif
+}
+
+//////////////////////////plugin stuff//////////////
+
+#ifdef CFGPLUGIN
+void ONMainWindow::setX2goconfig ( const QString& text )
+{
+    m_x2goconfig=text;
+    x2goDebug<<"have session config";
+    initWidgetsEmbed();
+}
+
+void ONMainWindow::doPluginInit()
+{
+#ifdef Q_OS_LINUX
+    Dl_info info;
+    dladdr ( ( void* ) & ( ONMainWindow::getPortable ),&info );
+    QString fname=info.dli_fname;
+    x2goDebug<<"Application name:" <<fname;
+    QString clientDir;
+    QString pluginDir;
+    int pos=fname.lastIndexOf ( "/" );
+    pluginDir=fname.left ( pos );
+    x2goDebug<<"Plugin Dir:" <<pluginDir;
+    QDir dr ( pluginDir );
+    if ( dr.exists ( "x2goclient/x2goclient" ) )
+    {
+        clientDir=pluginDir+"/x2goclient";
+    }
+    else if ( dr.exists ( "x2goclient" ) )
+    {
+        clientDir=pluginDir;
+    }
+    else
+    {
+        dr.cdUp();
+        if ( dr.exists ( "x2goclient/x2goclient" ) )
+        {
+            clientDir=dr.absolutePath() +"/x2goclient";
+        }
+        else if ( dr.exists ( "x2goclient" ) )
+        {
+            clientDir=dr.absolutePath();
+        }
+        else
+        {
+            clientDir=pluginDir;
+        }
+    }
+    x2goDebug<<"Client Dir:"<<clientDir;
+    QString path=getenv ( "PATH" );
+    path=clientDir+":"+pluginDir+":"+path;
+    setenv ( "PATH",path.toAscii (),1 );
+
+    path=getenv ( "LD_LIBRARY_PATH" );
+    path=clientDir+":"+pluginDir+":"+path;
+    setenv ( "LD_LIBRARY_PATH",path.toAscii () ,1 );
+
+    setenv ( "X2GO_LIB",clientDir.toAscii () ,1 );
+
+    QFile::setPermissions (
+        clientDir+"/x2goclient",
+        QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner|
+        QFile::ReadGroup|QFile::WriteGroup|QFile::ExeGroup|
+        QFile::ReadOther|QFile::WriteOther|QFile::ExeOther );
+    QFile::setPermissions (
+        clientDir+"/nxproxy",
+        QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner|
+        QFile::ReadGroup|QFile::WriteGroup|QFile::ExeGroup|
+        QFile::ReadOther|QFile::WriteOther|QFile::ExeOther );
+    QFile::setPermissions (
+        clientDir+"/sshd",
+        QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner|
+        QFile::ReadGroup|QFile::WriteGroup|QFile::ExeGroup|
+        QFile::ReadOther|QFile::WriteOther|QFile::ExeOther );
+    QFile::setPermissions (
+        clientDir+"/sftp-server",
+        QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner|
+        QFile::ReadGroup|QFile::WriteGroup|QFile::ExeGroup|
+        QFile::ReadOther|QFile::WriteOther|QFile::ExeOther );
+
+#endif
+}
+
+
+#ifndef Q_OS_DARWIN
+
+
+QSize ONMainWindow::getWindowSize ( long winId )
+{
+
+#ifdef Q_OS_LINUX
+    XWindowAttributes atr;
+    if ( XGetWindowAttributes ( QX11Info::display(),winId,&atr ) )
+        return QSize ( atr.width,atr.height );
+    return QSize ( 0,0 );
+#endif
+#ifdef Q_OS_WIN
+    QRect rec;
+    if ( wapiClientRect ( ( HWND ) winId,rec ) )
+        return rec.size();
+    else
+        return QSize ( 0,0 );
+#endif
+}
+
+#ifdef Q_OS_WIN
+void ONMainWindow::slotUpdateEmbedWindow()
+{
+    if ( oldContainerSize!=embedContainer->size() ||
+            oldChildPos!= mapToGlobal (
+                QPoint ( 0,0 ) ) )
+    {
+        QRect geom=embedContainer->geometry();
+        if ( gcor==1 )
+            gcor=0;
+        else
+            gcor=1;
+        geom.setWidth ( geom.width()-gcor );
+        wapiSetFSWindow ( ( HWND ) childId,
+                          geom );
+        wapiUpdateWindow ( ( HWND ) childId );
+        oldContainerSize=embedContainer->size();
+        oldChildPos= mapToGlobal (
+                         QPoint ( 0,0 ) );
+        x2goDebug<<"updating embedded window"<<endl;
+    }
+}
+
+#endif
+
+
+
+void ONMainWindow::embedWindow ( long wndId )
+{
+    childId=wndId;
+    embedContainer->show();
+#ifdef Q_OS_LINUX
+    x2goDebug<<"embedding "<<wndId<<" in container"<<endl;
+    embedContainer->embedClient ( wndId );
+#endif
+#ifdef Q_OS_WIN
+    wapiSetParent ( ( HWND ) childId,
+                    ( HWND ) ( embedContainer->winId() ) );
+    oldContainerSize=embedContainer->size();
+    oldChildPos= ( mapToGlobal ( QPoint ( 0,0 ) ));
+    winFlags=wapiSetFSWindow ( ( HWND ) childId,
+                               embedContainer->geometry() );
+    updateTimer->start ( 500 );
+
+#endif
+}
+
+
+void ONMainWindow::detachClient()
+{
+    if ( !childId )
+        return;
+#ifdef Q_OS_LINUX
+    if ( embedContainer )
+    {
+        embedContainer->discardClient();
+    }
+#endif
+#ifdef Q_OS_WIN
+    wapiSetParent ( ( HWND ) childId, ( HWND ) 0 );
+    slotDetachProxyWindow();
+    updateTimer->stop();
+    if ( childId )
+    {
+        wapiRestoreWindow ( ( HWND ) childId, winFlags,
+                            embedContainer->geometry() );
+        wapiMoveWindow ( ( HWND ) childId,0,0,
+                         oldContainerSize.width(),
+                         oldContainerSize.height(),true );
+
+    }
+#endif
+    childId=0;
+}
+
+#endif //(Q_OS_DARWIN)
+
+
+
+
+
+QTNPFACTORY_BEGIN ( "X2GoClient Plug-in "VERSION,
+                    "Allows you to start X2Go session in a webbrowser" )
+QTNPCLASS ( ONMainWindow )
+QTNPFACTORY_END()
+
+#ifdef QAXSERVER
+#include <ActiveQt/QAxFactory>
+QAXFACTORY_BEGIN ( "{aa3216bf-7e20-482c-84c6-06167bacb616}", "{08538ca5-eb7a-4f24-a3c4-a120c6e04dc4}" )
+QAXCLASS ( ONMainWindow )
+QAXFACTORY_END()
+#endif
+#endif
diff --git a/onmainwindow.h b/onmainwindow.h
index 4a17a92..66b21e8 100644
--- a/onmainwindow.h
+++ b/onmainwindow.h
@@ -506,6 +506,7 @@ private:
     bool embedMode;
     bool thinMode;
     QString statusString;
+    QString autostartApp;
     int defaultLink;
     int defaultQuality;
     int defaultWidth;
@@ -518,6 +519,7 @@ private:
     bool showTbTooltip;
     bool noSessionEdit;
     bool cleanAllFiles;
+    bool PGPInited;
     struct SshProxy sshProxy;
     QString sshPort;
     QString clientSshPort;
@@ -663,6 +665,7 @@ private:
     bool showToolBar;
     bool showHaltBtn;
     bool newSession;
+    bool runStartApp;
     bool ldapOnly;
     bool isScDaemonOk;
     bool parecTunnelOk;
diff --git a/onmainwindow_part2.cpp b/onmainwindow_part2.cpp
deleted file mode 100644
index 9412f9d..0000000
--- a/onmainwindow_part2.cpp
+++ /dev/null
@@ -1,2577 +0,0 @@
-/***************************************************************************
-*   Copyright (C) 2005-2012 by Oleksandr Shneyder   *
-*   oleksandr.shneyder at obviously-nice.de   *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU General Public License as published by  F*
-*   the Free Software Foundation; either version 2 of the License, or     *
-*   (at your option) any later version.                                   *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU General Public License     *
-*   along with this program; if not, write to the                         *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-
-#include "onmainwindow_privat.h"
-
-
-void ONMainWindow::slotSshConnectionOk()
-{
-    x2goDebug<<"ssh connection ok"<<endl;
-    passForm->setEnabled ( true );
-    if ( useLdap )
-    {
-        continueLDAPSession();
-    }
-    else
-        continueNormalSession();
-}
-
-
-SshMasterConnection*  ONMainWindow::findServerSshConnection(QString host)
-{
-    for (int i=0;i<serverSshConnections.count();++i)
-    {
-        if (serverSshConnections[i])
-        {
-            if (serverSshConnections[i]->getHost()==host)
-                return serverSshConnections[i];
-        }
-    }
-    return 0l;
-}
-
-void ONMainWindow::slotServSshConnectionOk(QString server)
-{
-    SshMasterConnection* con=findServerSshConnection(server);
-    if (!con)
-        return;
-    SshProcess* lproc;
-    lproc=new SshProcess ( con,  this );
-    connect ( lproc,SIGNAL ( sshFinished ( bool,
-                                           QString,SshProcess* ) ),
-              this,SLOT (
-                  slotListAllSessions ( bool,
-                                        QString,SshProcess* ) ) );
-    x2goDebug<<"getting sessions on "<<server<<endl;
-    lproc->startNormal ( "export HOSTNAME && x2golistsessions" );
-}
-
-void ONMainWindow::slotSshServerAuthError ( int error, QString sshMessage )
-{
-    if ( startHidden )
-    {
-        startHidden=false;
-        slotResize();
-        show();
-        activateWindow();
-        raise();
-    }
-    QString errMsg;
-    switch ( error )
-    {
-    case SSH_SERVER_KNOWN_CHANGED:
-        errMsg=tr ( "Host key for server changed.\nIt is now: " ) +sshMessage+"\n"+
-               tr ( "For security reasons, connection will be stopped" );
-        if ( sshConnection )
-        {
-            sshConnection->wait();
-            delete sshConnection;
-            sshConnection=0l;
-        }
-        slotSshUserAuthError ( errMsg );
-        return;
-
-    case SSH_SERVER_FOUND_OTHER:
-        errMsg=tr ( "The host key for this server was not found but an other"
-                    "type of key exists.An attacker might change the default server key to"
-                    "confuse your client into thinking the key does not exist" );
-        if ( sshConnection )
-        {
-            sshConnection->wait();
-            delete sshConnection;
-            sshConnection=0l;
-        }
-        slotSshUserAuthError ( errMsg );
-        return ;
-
-    case SSH_SERVER_ERROR:
-        if ( sshConnection )
-        {
-            sshConnection->wait();
-            delete sshConnection;
-            sshConnection=0l;
-        }
-        slotSshUserAuthError ( errMsg );
-        return ;
-    case SSH_SERVER_FILE_NOT_FOUND:
-        errMsg=tr ( "Could not find known host file."
-                    "If you accept the host key here, the file will be automatically created" );
-        break;
-
-    case SSH_SERVER_NOT_KNOWN:
-        errMsg=tr ( "The server is unknown. Do you trust the host key?\nPublic key hash: " ) +sshMessage;
-        break;
-    }
-
-    if ( QMessageBox::warning ( this, tr ( "Host key verification failed" ),errMsg,tr ( "Yes" ), tr ( "No" ) ) !=0 )
-    {
-        if ( sshConnection )
-        {
-            sshConnection->wait();
-            delete sshConnection;
-            sshConnection=0l;
-        }
-        slotSshUserAuthError ( tr ( "Host key verification failed" ) );
-        return;
-    }
-    sshConnection->setAcceptUnknownServers ( true );
-    sshConnection->start();
-}
-
-void ONMainWindow::slotSshUserAuthError ( QString error )
-{
-    if ( sshConnection )
-    {
-        sshConnection->wait();
-        delete sshConnection;
-        sshConnection=0l;
-    }
-
-    QMessageBox::critical ( 0l,tr ( "Authentication failed" ),error,
-                            QMessageBox::Ok,
-                            QMessageBox::NoButton );
-// 	currentKey=QString::null;
-    setEnabled ( true );
-    passForm->setEnabled ( true );
-    slotShowPassForm();
-    pass->setFocus();
-    pass->selectAll();
-
-
-
-    passForm->setEnabled ( true );
-    if ( startHidden )
-    {
-        startHidden=false;
-        slotResize();
-        show();
-        activateWindow();
-        raise();
-    }
-}
-
-void ONMainWindow::slotSessEnter()
-{
-    if ( useLdap )
-    {
-        slotPassEnter();
-        return;
-    }
-    if (brokerMode)
-    {
-        if (!config.brokerAuthenticated)
-        {
-            x2goDebug<<"starting broker request";
-            slotStartBroker();
-            return;
-        }
-    }
-
-    resumingSession.sessionId=QString::null;
-    resumingSession.server=QString::null;
-    resumingSession.display=QString::null;
-    setStatStatus ( tr ( "connecting" ) );
-
-    QString sid="";
-    if ( !embedMode )
-        sid=lastSession->id();
-    startSession ( sid );
-}
-
-void ONMainWindow::continueNormalSession()
-{
-    x2goDebug<<"continue normal x2go session"<<endl;
-    if (brokerMode)
-    {
-        slotListSessions(true,QString::null,0);
-        return;
-    }
-    SshProcess* proc=new SshProcess ( sshConnection, this );
-    connect ( proc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
-              this,SLOT ( slotListSessions ( bool, QString,
-                                             SshProcess* ) ) );
-    if ( !shadowSession )
-        proc->startNormal ( "export HOSTNAME && x2golistsessions" );
-    else
-        proc->startNormal ( "export HOSTNAME && x2golistdesktops" );
-
-}
-
-void ONMainWindow::continueLDAPSession()
-{
-
-
-    SshProcess* proc=new SshProcess ( sshConnection,this );
-    connect ( proc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
-              this,SLOT ( slotGetServers ( bool, QString,SshProcess* ) ) );
-    proc->startNormal ( "x2gogetservers" );
-}
-
-
-bool ONMainWindow::startSession ( const QString& sid )
-{
-    setEnabled ( false );
-    QString passwd;
-    QString user;
-    QString host;
-    bool autologin=false;
-    bool krblogin=false;
-    user=getCurrentUname();
-    runRemoteCommand=true;
-    shadowSession=false;
-    applications.clear();
-    removeAppsFromTray();
-
-    if ( managedMode )
-    {
-        slotListSessions ( true, QString::null,0 );
-        return true;
-    }
-
-    if ( !embedMode && !brokerMode )
-    {
-
-        X2goSettings st ( "sessions" );
-
-        passForm->setEnabled ( false );
-        host=st.setting()->value ( sid+"/host",
-                                   ( QVariant ) QString::null ).toString();
-        QString cmd=st.setting()->value ( sid+"/command",
-                                          ( QVariant ) QString::null ).toString();
-        autologin=st.setting()->value ( sid+"/autologin",
-                                        ( QVariant ) false ).toBool();
-        krblogin=st.setting()->value ( sid+"/krblogin",
-                                       ( QVariant ) false ).toBool();
-        if ( cmd=="SHADOW" )
-            shadowSession=true;
-    }
-    else
-    {
-        host=config.server;
-        sshPort=config.sshport;
-        selectedCommand=config.command;
-    }
-    if (!brokerMode)
-        passwd=getCurrentPass();
-    else
-    {
-        currentKey=config.key;
-        host=config.server;
-        X2goSettings st ( config.iniFile, QSettings::IniFormat );
-        passForm->setEnabled ( false );
-        user=st.setting()->value ( sid+"/user",
-                                   ( QVariant ) QString::null ).toString();
-        login->setText(user);
-        sshPort=config.sshport;
-        /*        sshPort=st.setting()->value ( sid+"/sshport",
-                                              ( QVariant ) "22" ).toString();*/
-    }
-    if (sshConnection)
-        sshConnection->disconnectSession();
-    sshConnection=startSshConnection ( host,sshPort,acceptRsa,user,passwd,autologin, krblogin );
-    return true;
-}
-
-
-void ONMainWindow::slotListSessions ( bool result,QString output,
-                                      SshProcess* proc )
-{
-    if ( proc )
-        delete proc;
-    if ( result==false )
-    {
-        cardReady=false;
-        cardStarted=false;
-        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
-        if ( message.indexOf ( "publickey,password" ) !=-1 )
-        {
-            message=tr ( "<b>Wrong password!</b><br><br>" ) +
-                    message;
-        }
-
-        QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                QMessageBox::Ok,
-                                QMessageBox::NoButton );
-// 		currentKey=QString::null;
-        setEnabled ( true );
-        passForm->setEnabled ( true );
-        slotShowPassForm();
-        pass->setFocus();
-        pass->selectAll();
-        return;
-    }
-
-    passForm->hide();
-    if ( !embedMode )
-    {
-        setUsersEnabled ( false );
-        uname->setEnabled ( false );
-        u->setEnabled ( false );
-    }
-    if ( managedMode || brokerMode )
-    {
-        x2goDebug<<"sess data:"<<config.sessiondata;
-        if ( config.sessiondata.indexOf ( "|S|" ) ==-1 )
-        {
-            x2goDebug<<"start new managed session";
-            startNewSession();
-        }
-        else
-        {
-            x2goSession s=getSessionFromString (
-                              config.sessiondata );
-            x2goDebug<<"resuming managed session:"<<s.sessionId;
-            resumeSession ( s );
-        }
-        return;
-    }
-
-    QStringList sessions=output.trimmed().split ( '\n',
-                         QString::SkipEmptyParts );
-    if ( shadowSession )
-    {
-        selectSession ( sessions );
-    }
-    else
-    {
-        if ( ( sessions.size() ==0 ) ||
-                ( sessions.size() ==1&&sessions[0].length() <5 ) )
-            startNewSession();
-        else if ( sessions.size() ==1 )
-        {
-            x2goSession s=getSessionFromString ( sessions[0] );
-            QDesktopWidget wd;
-            if ( s.status=="S" && isColorDepthOk ( wd.depth(),
-                                                   s.colorDepth )
-                    &&s.command == selectedCommand )
-                resumeSession ( s );
-            else
-            {
-                if ( startHidden )
-                    startNewSession();
-                else
-                    selectSession ( sessions );
-            }
-        }
-        else
-        {
-            if ( !startHidden )
-                selectSession ( sessions );
-            else
-            {
-                for ( int i=0;i<sessions.size();++i )
-                {
-                    x2goSession s=getSessionFromString (
-                                      sessions[i] );
-                    QDesktopWidget wd;
-                    if ( s.status=="S" && isColorDepthOk (
-                                wd.depth(),s.colorDepth )
-                            &&s.command == selectedCommand )
-                    {
-                        resumeSession ( s );
-                        return;
-                    }
-                }
-                startNewSession();
-            }
-        }
-    }
-}
-
-
-x2goSession ONMainWindow::getSessionFromString ( const QString& string )
-{
-    QStringList lst=string.split ( '|' );
-    x2goSession s;
-    s.agentPid=lst[0];
-    s.sessionId=lst[1];
-    s.display=lst[2];
-    s.server=lst[3];
-    s.status=lst[4];
-    s.crTime=lst[5];
-    s.cookie=lst[6];
-    s.clientIp=lst[7];
-    s.grPort=lst[8];
-    s.sndPort=lst[9];
-    if ( lst.count() >13 )
-        s.fsPort=lst[13];
-    s.colorDepth=0;
-    if ( s.sessionId.indexOf ( "_dp" ) !=-1 )
-    {
-        s.colorDepth=s.sessionId.split ( "_dp" ) [1].toInt();
-    }
-    s.sessionType=x2goSession::DESKTOP;
-    s.command=tr ( "unknown" );
-    if ( s.sessionId.indexOf ( "_st" ) !=-1 )
-    {
-        QString cmdinfo=s.sessionId.split ( "_st" ) [1];
-        cmdinfo=cmdinfo.split ( "_" ) [0];
-        QChar st=cmdinfo[0];
-        if ( st=='R' )
-            s.sessionType=x2goSession::ROOTLESS;
-        if ( st=='S' )
-            s.sessionType=x2goSession::SHADOW;
-        QString command=cmdinfo.mid ( 1 );
-        if ( command.length() >0 )
-            s.command=command;
-    }
-    return s;
-}
-
-
-void ONMainWindow::startNewSession()
-{
-    newSession=true;
-    QString passwd=getCurrentPass();
-    QString user=getCurrentUname();
-
-    QString pack;
-    bool fullscreen;
-    int height;
-    int width;
-    int quality;
-    int speed;
-    bool usekbd;
-    bool rootless=false;
-    resumingSession.published=false;
-    bool setDPI=defaultSetDPI;
-    uint dpi=defaultDPI;
-    QString layout;
-    QString type;
-    QString command;
-    QString xdmcpServer;
-    runRemoteCommand=true;
-    QString host=QString::null;
-    removeAppsFromTray();
-    if ( useLdap )
-    {
-        pack=defaultPack;
-        fullscreen=defaultFullscreen;
-        height=defaultHeight;
-        width=defaultWidth;
-        quality=defaultQuality;
-        speed=defaultLink;
-        usekbd=defaultSetKbd;
-        layout=defaultLayout[0];
-        type=defaultKbdType;
-        command=defaultCmd;
-        shadowSession=false;
-        for ( int j=0;j<x2goServers.size();++j )
-        {
-            if ( x2goServers[j].connOk )
-            {
-                host=x2goServers[j].name;
-                break;
-            }
-        }
-        if ( host==QString::null )
-        {
-            QMessageBox::critical ( 0l,tr ( "Error" ),
-                                    tr ( "No server availabel" ),
-                                    QMessageBox::Ok,
-                                    QMessageBox::NoButton );
-            return;
-        }
-        sshConnection=findServerSshConnection(host);
-        if (!sshConnection)
-        {
-            QMessageBox::critical ( 0l,tr ( "Error" ),
-                                    tr ( "Server not availabel" ),
-                                    QMessageBox::Ok,
-                                    QMessageBox::NoButton );
-            return;
-        }
-    }
-    else
-    {
-        X2goSettings* st;
-
-        if (!brokerMode)
-            st=new X2goSettings( "sessions" );
-        else
-            st= new X2goSettings(config.iniFile,QSettings::IniFormat);
-
-        QString sid;
-        if ( !embedMode )
-            sid=lastSession->id();
-        else
-            sid="embedded";
-        pack=st->setting()->value ( sid+"/pack",
-                                    ( QVariant ) defaultPack ).toString();
-        fullscreen=st->setting()->value ( sid+"/fullscreen",
-                                          ( QVariant )
-                                          defaultFullscreen ).toBool();
-        height=st->setting()->value ( sid+"/height",
-                                      ( QVariant ) defaultHeight ).toInt();
-        width=st->setting()->value ( sid+"/width",
-                                     ( QVariant ) defaultWidth ).toInt();
-        setDPI=st->setting()->value ( sid+"/setdpi",
-                                      ( QVariant ) defaultSetDPI ).toBool();
-        dpi=st->setting()->value ( sid+"/dpi",
-                                   ( QVariant ) defaultDPI ).toUInt();
-        quality=st->setting()->value (
-                    sid+"/quality",
-                    ( QVariant ) defaultQuality ).toInt();
-        speed=st->setting()->value ( sid+"/speed",
-                                     ( QVariant ) defaultLink ).toInt();
-
-        usekbd=st->setting()->value ( sid+"/usekbd",
-                                      ( QVariant ) defaultSetKbd ).toBool();
-        layout=st->setting()->value ( sid+"/layout",
-                                      ( QVariant )
-                                      defaultLayout[0] ).toString();
-        type=st->setting()->value ( sid+"/type",
-                                    ( QVariant )
-                                    defaultKbdType ).toString();
-        if ( !embedMode )
-        {
-            command=st->setting()->value ( sid+"/command",
-                                           ( QVariant ) defaultCmd ).toString();
-            host=st->setting()->value (
-                     sid+"/host",
-                     ( QVariant )
-                     ( QString ) "localhost" ).toString();
-
-            rootless=st->setting()->value ( sid+"/rootless",
-                                            ( QVariant ) false ).toBool();
-            resumingSession.published=st->setting()->value ( sid+"/published",
-                                      ( QVariant ) false ).toBool();
-            xdmcpServer=st->setting()->value ( sid+"/xdmcpserver",
-                                               ( QVariant )
-                                               "localhost" ).toString();
-        }
-        else
-        {
-            command=config.command;
-            rootless= config.rootless;
-            host=config.server;
-            startEmbedded=false;
-            if ( st->setting()->value ( sid+"/startembed",
-                                        ( QVariant ) true ).toBool() )
-            {
-                startEmbedded=true;
-                fullscreen=false;
-                height=bgFrame->size().height()-stb->height();
-                width=bgFrame->size().width();
-
-                if ( height<0 ||width<0 )
-                {
-                    height=defaultHeight;
-                    width=defaultWidth;
-                }
-            }
-            if ( config.confConSpd )
-                speed=config.conSpeed;
-            if ( config.confCompMet )
-                pack=config.compMet;
-            if ( config.confImageQ )
-                quality=config.imageQ;
-            if ( config.confDPI )
-            {
-                dpi=config.dpi;
-                setDPI=true;
-            }
-            if ( config.confKbd )
-            {
-                layout=config.kbdLay;
-                type=config.kbdType;
-                usekbd=true;
-            }
-        }
-        if ( command=="RDP" )
-            rootless=true;
-        if ( command=="XDMCP" )
-        {
-            runRemoteCommand=false;
-        }
-        delete st;
-    }
-
-
-    if ( shadowSession )
-    {
-        runRemoteCommand=false;
-    }
-
-    resumingSession.server=host;
-
-    if (defaultLayout.size()>0)
-        layout=cbLayout->currentText();
-
-
-    QString geometry;
-#ifdef Q_OS_WIN
-    x2goDebug<<"fullscreen: "<<fullscreen;
-    maximizeProxyWin=false;
-    proxyWinWidth=width;
-    proxyWinHeight=height;
-//#ifdef CFGCLIENT
-    xorgMode=WIN;
-    if (fullscreen)
-        xorgMode=FS;
-    if (rootless)
-        xorgMode=SAPP;
-    xorgWidth=QString::number(width);
-    xorgHeight=QString::number(height);
-    if (! startXorgOnStart)
-        startXOrg();
-//#endif
-#endif
-    if ( fullscreen )
-    {
-        geometry="fullscreen";
-#ifdef Q_OS_WIN
-//        fullscreen=false;
-        maximizeProxyWin=true;
-        x2goDebug<<"maximizeProxyWin: "<<maximizeProxyWin;
-#endif
-    }
-    if ( ! fullscreen )
-    {
-        geometry=QString::number ( width ) +"x"+
-                 QString::number ( height );
-        if ( embedMode )
-        {
-            QPoint position=mapToGlobal ( bgFrame->pos() );
-            geometry+="+"+QString::number ( position.x() ) +"+"+
-                      QString::number ( position.y() +
-                                        stb->height() );
-        }
-
-    }
-    QString link;
-    switch ( speed )
-    {
-    case MODEM:
-        link="modem";
-        break;
-    case ISDN:
-        link="isdn";
-        break;
-    case ADSL:
-        link="adsl";
-        break;
-    case WAN:
-        link="wan";
-        break;
-    case LAN:
-        link="lan";
-        break;
-    }
-
-    QFile file ( ":/txt/packs" );
-    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-        return;
-    QTextStream in ( &file );
-    while ( !in.atEnd() )
-    {
-        QString pc=in.readLine();
-        if ( pc.indexOf ( "-%" ) !=-1 )
-        {
-            pc=pc.left ( pc.indexOf ( "-%" ) );
-            if ( pc==pack )
-            {
-                pack+="-"+QString::number ( quality );
-                break;
-            }
-        }
-    }
-    file.close();
-
-
-    if ( selectSessionDlg->isVisible() )
-    {
-        if ( !embedMode )
-            slotCloseSelectDlg();
-        else
-            selectSessionDlg->hide();
-    }
-    QDesktopWidget wd;
-    QString depth=QString::number ( wd.depth() );
-#ifdef Q_OS_DARWIN
-    usekbd=0;
-    type="query";
-#endif
-    QString sessTypeStr="D ";
-    if ( rootless )
-        sessTypeStr="R ";
-    if ( shadowSession )
-        sessTypeStr="S ";
-    if ( resumingSession.published)
-    {
-        sessTypeStr="P ";
-        command="PUBLISHED";
-    }
-    QString dpiEnv;
-    QString xdmcpEnv;
-    if ( runRemoteCommand==false && command=="XDMCP" )
-        xdmcpEnv="X2GOXDMCP="+xdmcpServer+" ";
-    if ( setDPI )
-    {
-        dpiEnv="X2GODPI="+QString::number ( dpi ) +" ";
-    }
-    QString cmd=dpiEnv+xdmcpEnv+"x2gostartagent "+
-                geometry+" "+link+" "+pack+
-                " unix-kde-depth_"+depth+" "+layout+" "+type+" ";
-    if ( usekbd )
-        cmd += "1 ";
-    else
-        cmd += "0 ";
-    QFileInfo f ( command );
-    if ( !shadowSession )
-        cmd+=sessTypeStr+f.fileName();
-    else
-    {
-        cmd+=sessTypeStr+QString::number ( shadowMode ) +"XSHAD"+
-             shadowUser+"XSHAD"+shadowDisplay;
-    }
-    resumingSession.fullscreen=fullscreen;
-    x2goDebug<<cmd<<endl;
-    if ( managedMode )
-    {
-        slotRetResumeSess ( true,config.sessiondata,0 );
-        passForm->hide();
-        return;
-    }
-
-    SshProcess* proc=0l;
-
-    proc=new SshProcess ( sshConnection, this ) ;
-
-
-    connect ( proc,SIGNAL ( sshFinished ( bool, QString,SshProcess* ) ),
-              this,SLOT ( slotRetResumeSess ( bool,
-                                              QString,SshProcess* ) ) );
-
-    proc->startNormal ( cmd );
-    passForm->hide();
-}
-
-
-
-void ONMainWindow::resumeSession ( const x2goSession& s )
-{
-    newSession=false;
-    applications.clear();
-    removeAppsFromTray();
-    QString passwd=getCurrentPass();
-    QString user=getCurrentUname();
-    QString host=s.server;
-    bool rootless=false;
-
-    QString pack;
-    bool fullscreen;
-    int height;
-    int width;
-    int quality;
-    int speed;
-    bool usekbd;
-    QString layout;
-    QString type;
-    removeAppsFromTray();
-
-    if ( useLdap )
-    {
-        pack=defaultPack;
-        fullscreen=defaultFullscreen;
-        height=defaultHeight;
-        width=defaultWidth;
-        quality=defaultQuality;
-        speed=defaultLink;
-        usekbd=defaultSetKbd;
-        layout=defaultLayout[0];
-        type=defaultKbdType;
-        sshConnection=findServerSshConnection(host);
-        if (!sshConnection)
-        {
-            QMessageBox::critical ( 0l,tr ( "Error" ),
-                                    tr ( "Server not availabel" ),
-                                    QMessageBox::Ok,
-                                    QMessageBox::NoButton );
-            return;
-        }
-    }
-    else
-    {
-
-        QString sid;
-        if ( !embedMode )
-            sid=lastSession->id();
-        else
-            sid="embedded";
-        X2goSettings* st;
-        if (!brokerMode)
-            st=new X2goSettings( "sessions" );
-        else
-            st=new X2goSettings(config.iniFile,QSettings::IniFormat);
-
-        pack=st->setting()->value ( sid+"/pack",
-                                    ( QVariant ) defaultPack ).toString();
-
-        fullscreen=st->setting()->value ( sid+"/fullscreen",
-                                          ( QVariant )
-                                          defaultFullscreen ).toBool();
-        height=st->setting()->value ( sid+"/height",
-                                      ( QVariant ) defaultHeight ).toInt();
-        width=st->setting()->value ( sid+"/width",
-                                     ( QVariant ) defaultWidth ).toInt();
-        quality=st->setting()->value ( sid+"/quality",
-                                       ( QVariant )
-                                       defaultQuality ).toInt();
-        speed=st->setting()->value ( sid+"/speed",
-                                     ( QVariant ) defaultLink ).toInt();
-        usekbd=st->setting()->value ( sid+"/usekbd",
-                                      ( QVariant ) defaultSetKbd ).toBool();
-        layout=st->setting()->value ( sid+"/layout",
-                                      ( QVariant )
-                                      defaultLayout[0] ).toString();
-        type=st->setting()->value ( sid+"/type",
-                                    ( QVariant )
-                                    defaultKbdType ).toString();
-        rootless=st->setting()->value ( sid+"/rootless",
-                                        ( QVariant ) false ).toBool();
-
-        if ( !embedMode )
-        {
-            host=st->setting()->value ( sid+"/host",
-                                        ( QVariant ) s.server ).toString();
-        }
-        else
-        {
-            startEmbedded=false;
-            if ( st->setting()->value ( sid+"/startembed",
-                                        ( QVariant ) true ).toBool() )
-            {
-                fullscreen=false;
-                startEmbedded=true;
-                height=bgFrame->size().height()-stb->height();
-                width=bgFrame->size().width();
-                if ( height<0 ||width<0 )
-                {
-                    height=defaultHeight;
-                    width=defaultWidth;
-                }
-            }
-            rootless=config.rootless;
-            host=config.server;
-            if ( config.confConSpd )
-                speed=config.conSpeed;
-            if ( config.confCompMet )
-                pack=config.compMet;
-            if ( config.confImageQ )
-                quality=config.imageQ;
-            if ( config.confKbd )
-            {
-                layout=config.kbdLay;
-                type=config.kbdType;
-                usekbd=true;
-            }
-        }
-        delete st;
-    }
-
-    if (defaultLayout.size()>0)
-        layout=cbLayout->currentText();
-
-    QString geometry;
-#ifdef Q_OS_WIN
-    maximizeProxyWin=false;
-    proxyWinWidth=width;
-    proxyWinHeight=height;
-// #ifdef CFGCLIENT
-    xorgMode=WIN;
-    if (fullscreen)
-        xorgMode=FS;
-    if (rootless)
-        xorgMode=SAPP;
-    xorgWidth=QString::number(width);
-    xorgHeight=QString::number(height);
-    if (! startXorgOnStart)
-        startXOrg();
-// #endif
-
-#endif
-    if ( fullscreen )
-    {
-        geometry="fullscreen";
-#ifdef Q_OS_WIN
-//        fullscreen=false;
-        maximizeProxyWin=true;
-        x2goDebug<<"maximizeProxyWin: "<<maximizeProxyWin;
-
-#endif
-    }
-    if ( !fullscreen )
-    {
-        geometry=QString::number ( width ) +"x"+
-                 QString::number ( height );
-    }
-    resumingSession.fullscreen=fullscreen;
-    QString link;
-    switch ( speed )
-    {
-    case MODEM:
-        link="modem";
-        break;
-    case ISDN:
-        link="isdn";
-        break;
-    case ADSL:
-        link="adsl";
-        break;
-    case WAN:
-        link="wan";
-        break;
-    case LAN:
-        link="lan";
-        break;
-    }
-
-    QFile file ( ":/txt/packs" );
-    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-        return;
-    QTextStream in ( &file );
-    while ( !in.atEnd() )
-    {
-        QString pc=in.readLine();
-        if ( pc.indexOf ( "-%" ) !=-1 )
-        {
-            pc=pc.left ( pc.indexOf ( "-%" ) );
-            if ( pc==pack )
-            {
-                pack+="-"+QString::number ( quality );
-                break;
-            }
-        }
-    }
-    file.close();
-
-#ifdef Q_OS_DARWIN
-    usekbd=0;
-    type="query";
-#endif
-
-    if (s.sessionId.indexOf("RPUBLISHED")!=-1)
-    {
-        resumingSession.published=true;
-        sbApps->setDisabled(true);
-    }
-    else
-        resumingSession.published=false;
-
-
-
-    if ( selectSessionDlg->isVisible() )
-    {
-        if ( !embedMode )
-            slotCloseSelectDlg();
-        else
-            selectSessionDlg->hide();
-    }
-    QString cmd="x2goresume-session "+s.sessionId+" "+geometry+
-                " "+link+" "+pack+" "+layout+
-                " "+type+" ";
-    if ( usekbd )
-        cmd += "1";
-    else
-        cmd += "0";
-
-    SshProcess* proc=0l;
-    proc=new SshProcess ( sshConnection, this );
-
-    connect ( proc,SIGNAL ( sshFinished ( bool, QString,SshProcess* ) ),
-              this,SLOT ( slotRetResumeSess ( bool, QString,
-                                              SshProcess* ) ) );
-
-    proc->startNormal ( cmd );
-    resumingSession=s;
-    passForm->hide();
-}
-
-
-void ONMainWindow::selectSession ( QStringList& sessions )
-{
-    setEnabled ( true );
-    sessionStatusDlg->hide();
-    passForm->hide();
-// 	x2goDebug<<"check type";
-    if ( !shadowSession )
-    {
-// 		x2goDebug<<"! shadow";
-        if ( !miniMode )
-            selectSesDlgLayout->setContentsMargins ( 25,25,10,10 );
-
-        bNew->show();
-        bSusp->show();
-        bTerm->show();
-        sOk->show();
-        sCancel->show();
-// 		x2goDebug<<"standart buttons ok";
-        desktopFilter->hide();
-        desktopFilterCb->hide();
-        bShadow->hide();
-        bShadowView->hide();
-        bCancel->hide();
-// 		x2goDebug<<"shadow buttons ok";
-// 		model->clear();
-        model->removeRows ( 0,model->rowCount() );
-        selectSessionLabel->setText ( tr ( "Select session:" ) );
-        selectedSessions.clear();
-        QFontMetrics fm ( sessTv->font() );
-        for ( int row = 0; row < sessions.size(); ++row )
-        {
-
-// 			x2goDebug<<"decoding sessionstr:"<<sessions[row];
-            x2goSession s=getSessionFromString ( sessions[row] );
-// 			x2goDebug<<"listing id:"<<s.sessionId;
-            selectedSessions.append ( s );
-            QStandardItem *item;
-
-            item= new QStandardItem ( s.display );
-            model->setItem ( row,S_DISPLAY,item );
-
-            if ( s.status=="R" )
-                item= new QStandardItem ( tr ( "running" ) );
-            else
-                item= new QStandardItem ( tr ( "suspended" ) );
-            model->setItem ( row,S_STATUS,item );
-
-            item= new QStandardItem ( transAppName ( s.command ) );
-            model->setItem ( row,S_COMMAND,item );
-
-            QString type=tr ( "Desktop" );
-            if ( s.sessionType==x2goSession::ROOTLESS )
-                type=tr ( "single application" );
-            if ( s.sessionType==x2goSession::SHADOW )
-                type=tr ( "shadow session" );
-
-            item= new QStandardItem ( type );
-            model->setItem ( row,S_TYPE,item );
-
-            item= new QStandardItem ( s.crTime );
-            model->setItem ( row,S_CRTIME,item );
-            item= new QStandardItem ( s.server );
-            model->setItem ( row,S_SERVER,item );
-            item= new QStandardItem ( s.clientIp );
-            model->setItem ( row,S_IP,item );
-            item= new QStandardItem ( s.sessionId );
-            model->setItem ( row,S_ID,item );
-            for ( int j=0;j<8;++j )
-            {
-                QString txt=
-                    model->index ( row,j ).data().toString();
-                if ( sessTv->header()->sectionSize ( j ) <
-                        fm.width ( txt ) +6 )
-                {
-                    sessTv->header()->resizeSection (
-                        j,fm.width ( txt ) +6 );
-                }
-            }
-        }
-    }
-    else
-    {
-        shadowMode=SHADOW_VIEWONLY;
-        selectedDesktops.clear();
-        selectedDesktops=sessions;
-        if ( sessions.size() ==0 )
-        {
-            QMessageBox::information ( this,tr ( "Information" ),
-                                       tr ( "No accessible desktop "
-                                            "found" ) );
-            slotCloseSelectDlg();
-            return;
-        }
-        sessTv->setModel ( ( QAbstractItemModel* ) modelDesktop );
-        desktopFilter->show();
-        desktopFilterCb->show();
-        sOk->hide();
-        sCancel->hide();
-        bShadow->show();
-        bCancel->show();
-        bShadowView->show();
-        desktopFilter->setText ( tr ( "Filter" ) );
-        sessions.sort();
-        if ( !miniMode )
-            selectSesDlgLayout->setContentsMargins ( 25,25,25,25 );
-        bNew->hide();
-        bSusp->hide();
-        bTerm->hide();
-        selectSessionLabel->setText ( tr ( "Select desktop:" ) );
-        filterDesktops ( "" );
-        desktopFilter->setFocus();
-        desktopFilter->selectAll();
-    }
-    selectSessionDlg->show();
-}
-
-void ONMainWindow::slotCloseSelectDlg()
-{
-    selectSessionDlg->hide();
-    if ( !embedMode )
-    {
-        u->setEnabled ( true );
-        uname->setEnabled ( true );
-    }
-    slotShowPassForm();
-}
-
-
-
-void ONMainWindow::slotActivated ( const QModelIndex& index )
-{
-    if ( !shadowSession )
-    {
-        QString status=sessTv->model()->index (
-                           index.row(),
-                           S_STATUS ).data().toString();
-        if ( status==tr ( "running" ) )
-        {
-            bSusp->setEnabled ( true );
-            sOk->setEnabled ( false );
-        }
-        else
-        {
-            bSusp->setEnabled ( false );
-            sOk->setEnabled ( true );
-        }
-        bTerm->setEnabled ( true );
-        if ( status==QString::null )
-        {
-            sOk->setEnabled ( false );
-            bTerm->setEnabled ( false );
-        }
-    }
-    else
-    {
-        QString user=sessTv->model()->index (
-                         index.row(),
-                         D_USER ).data().toString();
-        bShadowView->setEnabled ( true );
-        bShadow->setEnabled ( user==getCurrentUname() );
-    }
-}
-
-
-void ONMainWindow::slotResumeSess()
-{
-    x2goSession s=getSelectedSession();
-    QDesktopWidget wd;
-    if ( isColorDepthOk ( wd.depth(),s.colorDepth ) )
-        resumeSession ( s );
-    else
-    {
-        QString depth=QString::number ( s.colorDepth );
-        int res;
-        if ( s.colorDepth==24 || s.colorDepth==32 )
-        {
-            res=QMessageBox::warning (
-                    0l,tr ( "Warning" ),
-                    tr (
-                        "Your current color depth is "
-                        "different to the color depth of your "
-                        "x2go-session. This may cause problems "
-                        "reconnecting to this session and in most "
-                        "cases <b>you will loose the session</b> "
-                        "and have to start a new one! It's highly "
-                        "recommended to change the color depth of "
-                        "your Display to " ) +tr ( "24 or 32" ) +
-                    tr (
-                        " bit and restart your X-server before you "
-                        "reconnect to this x2go-session.<br>Resume "
-                        "this session anyway?" ),tr ( "Yes" ),
-                    tr ( "No" ) );
-
-        }
-        else
-        {
-            res=QMessageBox::warning (
-                    0l,tr ( "Warning" ),
-                    tr (
-                        "Your current color depth is different to "
-                        "the color depth of your x2go-session. "
-                        "This may cause problems reconnecting to "
-                        "this session and in most cases <b>you "
-                        "will loose the session</b> and have to "
-                        "start a new one! It's highly recommended "
-                        "to change the color depth of your "
-                        "Display to " ) +depth+
-                    tr (
-                        " bit and restart your X-server before you "
-                        "reconnect to this x2go-session.<br>Resume "
-                        "this session anyway?" ),tr ( "Yes" ),
-                    tr ( "No" ) );
-        }
-        if ( res==0 )
-            resumeSession ( s );
-    }
-
-}
-
-
-void ONMainWindow::slotSuspendSess()
-{
-
-    QString passwd;
-    QString user=getCurrentUname();
-
-    passwd=getCurrentPass();
-
-    selectSessionDlg->setEnabled ( false );
-
-
-    QString sessId=sessTv->model()->index (
-                       sessTv->currentIndex().row(),
-                       S_ID ).data().toString();
-    QString host=sessTv->model()->index (
-                     sessTv->currentIndex().row(),
-                     S_SERVER ).data().toString();
-    if ( !useLdap )
-    {
-        if ( !embedMode )
-        {
-            X2goSettings st ( "sessions" );
-            QString sid=lastSession->id();
-            host=st.setting()->value ( sid+"/host",
-                                       ( QVariant ) host ).toString();
-        }
-        else
-        {
-            host=config.server;
-        }
-    }
-    else
-    {
-        sshConnection=findServerSshConnection(host);
-        if (!sshConnection)
-        {
-            QMessageBox::critical ( 0l,tr ( "Error" ),
-                                    tr ( "Server not availabel" ),
-                                    QMessageBox::Ok,
-                                    QMessageBox::NoButton );
-            return;
-        }
-    }
-
-
-    suspendSession ( sessId );
-}
-
-
-void ONMainWindow::slotSuspendSessFromSt()
-{
-    QString passwd;
-    QString user=getCurrentUname();
-    passwd=getCurrentPass();
-    setStatStatus ( tr ( "suspending" ) );
-
-
-    sbExp->setEnabled ( false );
-
-    if ( !shadowSession )
-        suspendSession ( resumingSession.sessionId );
-    else
-        termSession ( resumingSession.sessionId,false );
-}
-
-void ONMainWindow::slotTermSessFromSt()
-{
-
-    /*	x2goDebug <<"disconnect export"<<endl;
-    	disconnect ( sbExp,SIGNAL ( clicked() ),this,
-    	             SLOT ( slot_exportDirectory() ) );*/
-    sbExp->setEnabled ( false );
-
-    if ( !shadowSession )
-    {
-        if ( termSession ( resumingSession.sessionId ) )
-            setStatStatus ( tr ( "terminating" ) );
-    }
-    else
-        termSession ( resumingSession.sessionId,false );
-}
-
-
-void ONMainWindow::slotRetSuspSess ( bool result, QString output,
-                                     SshProcess* proc )
-{
-    if ( proc )
-        delete proc;
-    if ( result==false )
-    {
-        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
-        if ( message.indexOf ( "publickey,password" ) !=-1 )
-        {
-            message=tr (
-                        "<b>Wrong password!</b><br><br>" ) +message;
-        }
-
-        QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                QMessageBox::Ok,
-                                QMessageBox::NoButton );
-    }
-    else
-    {
-        if ( selectSessionDlg->isVisible() )
-        {
-            ( ( QStandardItemModel* )
-              ( sessTv->model() ) )->item (
-                  sessTv->currentIndex().row(),
-                  S_STATUS )->setData (
-                      QVariant ( ( QString ) tr ( "suspended" ) ),
-                      Qt::DisplayRole );
-            bSusp->setEnabled ( false );
-            sOk->setEnabled ( true );
-
-        }
-    }
-    if ( selectSessionDlg->isVisible() )
-        selectSessionDlg->setEnabled ( true );
-}
-
-
-
-void ONMainWindow::slotTermSess()
-{
-
-    selectSessionDlg->setEnabled ( false );
-
-
-    QString sessId=sessTv->model()->index ( sessTv->currentIndex().row(),
-                                            S_ID ).data().toString();
-
-    if ( !useLdap )
-    {
-        if ( !embedMode )
-        {
-            X2goSettings st ( "sessions" );
-
-            QString sid=lastSession->id();
-        }
-    }
-    else
-    {
-        QString host=sessTv->model()->index ( sessTv->currentIndex().row(),
-                                              S_SERVER ).data().toString();
-
-        sshConnection=findServerSshConnection(host);
-        if (!sshConnection)
-        {
-            QMessageBox::critical ( 0l,tr ( "Error" ),
-                                    tr ( "Server not availabel" ),
-                                    QMessageBox::Ok,
-                                    QMessageBox::NoButton );
-            return;
-        }
-    }
-
-    termSession ( sessId );
-}
-
-
-void ONMainWindow::slotNewSess()
-{
-    startNewSession();
-}
-
-
-void ONMainWindow::slotRetTermSess ( bool result,  QString output,
-                                     SshProcess* proc )
-{
-    bool nodel= ( proc==0 );
-    if ( proc )
-        delete proc;
-    if ( result==false )
-    {
-        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
-        if ( message.indexOf ( "publickey,password" ) !=-1 )
-        {
-            message=tr (
-                        "<b>Wrong password!</b><br><br>" ) +message;
-        }
-
-        QMessageBox::critical ( 0l,tr ( "Error" ),
-                                message,QMessageBox::Ok,
-                                QMessageBox::NoButton );
-    }
-    else
-    {
-        if ( selectSessionDlg->isVisible() &&!nodel )
-        {
-            sessTv->model()->removeRow (
-                sessTv->currentIndex().row() );
-            slotActivated ( sessTv->currentIndex() );
-        }
-    }
-    if ( selectSessionDlg->isVisible() )
-        selectSessionDlg->setEnabled ( true );
-}
-
-void ONMainWindow::slotRetResumeSess ( bool result,
-                                       QString output,
-                                       SshProcess* proc )
-{
-    if ( proc )
-        delete proc;
-    x2goDebug<<"Agent output:"<<output;
-    if ( result==false )
-    {
-        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
-        if ( message.indexOf ( "publickey,password" ) !=-1 )
-        {
-            message=tr (
-                        "<b>Wrong Password!</b><br><br>" ) +message;
-        }
-        if ( output.indexOf ( "LIMIT" ) !=-1 )
-        {
-            QString sessions=output.mid (
-                                 output.indexOf ( "LIMIT" ) +6 );
-
-            message="Sessions limit reached:"+sessions;
-        }
-        if ( output.indexOf ( "ACCESS DENIED" ) !=-1 )
-        {
-            message="Access denied from user";
-        }
-
-        QMessageBox::critical ( 0l,tr ( "Error" ),
-                                message,QMessageBox::Ok,
-                                QMessageBox::NoButton );
-        slotShowPassForm();
-        return;
-    }
-
-    output.replace ( " ","" );
-    QString passwd=getCurrentPass();
-    QString user=getCurrentUname();
-    QString host;
-
-    bool sound=true;
-    int sndSystem=PULSE;
-    QString sndPort;
-#ifndef Q_OS_WIN
-    sndPort="4713";
-#endif
-    bool startSoundServer=true;
-    bool sshSndTunnel=true;
-
-    if ( useLdap )
-    {
-        sound=startSound;
-        startSoundServer=LDAPSndStartServer;
-        if ( LDAPSndSys=="arts" )
-            sndSystem=ARTS;
-        if ( LDAPSndSys=="esd" )
-            sndSystem=ESD;
-        sndPort=LDAPSndPort;
-    }
-    else
-    {
-        QString sid;
-        if ( !embedMode )
-            sid=lastSession->id();
-        else
-            sid="embedded";
-        X2goSettings st ( "sessions" );
-
-        sound=st.setting()->value ( sid+"/sound",
-                                    ( QVariant ) true ).toBool();
-        QString sndsys=st.setting()->value (
-                           sid+"/soundsystem",
-                           ( QVariant ) "pulse" ).toString();
-        if ( sndsys=="arts" )
-            sndSystem=ARTS;
-        if ( sndsys=="esd" )
-            sndSystem=ESD;
-#ifndef Q_OS_WIN
-        sndPort=st.setting()->value ( sid+"/sndport" ).toString();
-#endif
-        startSoundServer=st.setting()->value (
-                             sid+"/startsoundsystem",
-                             true ).toBool();
-
-        if ( embedMode&&config.confSnd )
-        {
-            sound=config.useSnd;
-        }
-
-
-#ifndef Q_OS_WIN
-        bool defPort=st.setting()->value ( sid+
-                                           "/defsndport",true ).toBool();
-        if ( defPort )
-        {
-            switch ( sndSystem )
-            {
-            case PULSE:
-                sndPort="4713";
-                break;
-            case ESD:
-                sndPort="16001";
-                break;
-            }
-        }
-#endif
-        sshSndTunnel=st.setting()->value ( sid+"/soundtunnel",
-                                           true ).toBool();
-
-#ifdef Q_OS_WIN
-        switch ( sndSystem )
-        {
-        case PULSE:
-            sndPort=QString::number ( pulsePort );
-            break;
-        case ESD:
-            sndPort=QString::number ( esdPort );
-            break;
-        }
-#endif
-    }
-
-    //Will be used in runCommand
-    startSessSound=sound;
-    startSessSndSystem=sndSystem;
-
-    if ( newSession )
-    {
-        QString sString=output.trimmed();
-        sString.replace ( '\n','|' );
-        host=resumingSession.server;
-        resumingSession=getNewSessionFromString ( sString );
-        resumingSession.server=host;
-        resumingSession.crTime=QDateTime::currentDateTime().toString (
-                                   "dd.MM.yy HH:mm:ss" );
-        if ( managedMode )
-        {
-            //replace session data for future resuming
-            config.sessiondata=resumingSession.agentPid+"|"+
-                               resumingSession.sessionId+"|"+
-                               resumingSession.display+"|"+
-                               resumingSession.server+"|"+
-                               "S|"+
-                               resumingSession.crTime+"|"+
-                               resumingSession.cookie+"|"+
-                               resumingSession.clientIp+"|"+
-                               resumingSession.grPort+"|"+
-                               resumingSession.sndPort+"|"+
-                               resumingSession.crTime+"|"+
-                               user+"|"+
-                               "0|"+
-                               resumingSession.fsPort;
-        }
-    }
-    else
-    {
-        host=resumingSession.server;
-        QStringList outputLines=output.split("\n",QString::SkipEmptyParts);
-        foreach(QString line,outputLines)
-        {
-            if (line.indexOf("gr_port=")!=-1)
-            {
-                resumingSession.grPort=line.replace("gr_port=","");
-                x2goDebug<<"new gr_port: "<<resumingSession.grPort<<endl;
-            }
-            if (line.indexOf("sound_port=")!=-1)
-            {
-                resumingSession.sndPort=line.replace("sound_port=","");
-                x2goDebug<<"new sound_port: "<<resumingSession.sndPort<<endl;
-            }
-            if (line.indexOf("fs_port=")!=-1)
-            {
-                resumingSession.fsPort=line.replace("fs_port=","");
-                x2goDebug<<"new fs_port: "<<resumingSession.fsPort<<endl;
-            }
-        }
-        if (resumingSession.published)
-            readApplications();
-    }
-    if ( !useLdap )
-    {
-        if ( !embedMode )
-        {
-            X2goSettings st ( "sessions" );
-
-            QString sid=lastSession->id();
-            host=st.setting()->value ( sid+"/host",
-                                       ( QVariant ) host ).toString();
-        }
-        else
-            host=config.server;
-        resumingSession.server=host;
-    }
-    tunnel=new SshProcess ( sshConnection, this );
-
-    connect ( tunnel,SIGNAL ( sshFinished ( bool,  QString,SshProcess* ) ),
-              this,SLOT ( slotTunnelFailed ( bool,
-                                             QString,SshProcess* ) ) );
-    connect ( tunnel,SIGNAL ( sshTunnelOk() ),
-              this,SLOT ( slotTunnelOk() ) );
-
-    localGraphicPort=resumingSession.grPort;
-    int iport=localGraphicPort.toInt() +1000;
-    while ( iport == resumingSession.sndPort.toInt() ||
-            iport == resumingSession.fsPort.toInt() ||
-            isServerRunning ( iport ) )
-        ++iport;
-    localGraphicPort=QString::number ( iport );
-
-    tunnel->startTunnel ( "localhost",resumingSession.grPort.toInt(),"localhost",
-                          localGraphicPort.toInt() );
-    if ( shadowSession )
-        return;
-
-    sndTunnel=0l;
-    if ( sound )
-    {
-        if ( sndSystem==PULSE )
-        {
-            startSoundServer=false;
-            QString scmd;
-            if ( !sshSndTunnel )
-                scmd="echo \"default-server=`echo "
-                     "$SSH_CLIENT | awk '{print $1}'`:"+
-                     sndPort+
-                     "\"> ~/.x2go/C-"+
-                     resumingSession.sessionId+
-                     "/.pulse-client.conf"
-                     ";echo \"cookie-file=.x2go/C-"+
-                     resumingSession.sessionId+
-                     "/.pulse-cookie"+
-                     "\">> ~/.x2go/C-"+
-                     resumingSession.sessionId+
-                     "/.pulse-client.conf";
-            else
-                scmd="echo \"default-server=localhost:"+
-                     resumingSession.sndPort+
-                     "\"> ~/.x2go/C-"+
-                     resumingSession.sessionId+
-                     "/.pulse-client.conf"
-                     ";echo \"cookie-file=.x2go/C-"+
-                     resumingSession.sessionId+
-                     "/.pulse-cookie"+
-                     "\">> ~/.x2go/C-"+
-                     resumingSession.sessionId+
-                     "/.pulse-client.conf";
-            SshProcess* paProc;
-            paProc=new SshProcess ( sshConnection, this );
-            paProc->startNormal ( scmd );
-
-            bool sysPulse=false;
-#ifdef Q_OS_LINUX
-            loadPulseModuleNativeProtocol();
-            QFile file ( "/etc/default/pulseaudio" );
-            if ( file.open ( QIODevice::ReadOnly |
-                             QIODevice::Text ) )
-            {
-
-                while ( !file.atEnd() )
-                {
-                    QByteArray line = file.readLine();
-                    int pos=line.indexOf (
-                                "PULSEAUDIO_SYSTEM_START=1"
-                            );
-                    if ( pos!=-1 )
-                    {
-                        int commentPos=line.indexOf (
-                                           "#" );
-                        if ( commentPos==-1 ||
-                                commentPos>pos )
-                        {
-                            sysPulse=true;
-                            break;
-                        }
-                    }
-                }
-                file.close();
-            }
-#endif
-            if ( sysPulse )
-                paProc->start_cp (
-                    "/var/run/pulse/.pulse-cookie",
-                    "~/.x2go/C-"+
-                    resumingSession.sessionId+
-                    "/.pulse-cookie" );
-            else
-            {
-#ifndef Q_OS_WIN
-                paProc->start_cp ( homeDir+"/.pulse-cookie",
-                                   "~/.x2go/C-"+
-                                   resumingSession.sessionId+
-                                   "/.pulse-cookie" );
-#else
-                QString cooFile=
-                    wapiShortFileName ( homeDir )  +
-                    "/.x2go/pulse/.pulse-cookie";
-                QString destFile="~/.x2go/C-"+
-                                 resumingSession.sessionId+
-                                 "/.pulse-cookie";
-                paProc->start_cp ( cooFile,
-                                   destFile );
-
-                /*x2goDebug<<"cookie file: "<<cooFile
-                <<" remote:"<<
-                destFile<<endl;*/
-                connect ( paProc,
-                          SIGNAL (
-                              sshFinished ( bool,
-                                            QString,
-                                            SshProcess* ) ),
-                          this,
-                          SLOT (
-                              slotPCookieReady ( bool,
-                                                 QString,
-                                                 SshProcess* )
-                          ) );
-                parecTunnelOk=true;
-#endif
-            }
-        }
-        if ( sndSystem==ESD )
-        {
-            SshProcess* paProc;
-            paProc=new SshProcess ( sshConnection, this );
-#ifndef Q_OS_WIN
-            paProc->start_cp ( homeDir+"/.esd_auth",
-                               "~/.esd_auth" );
-#else
-            QString cooFile=
-                wapiShortFileName ( homeDir )  +
-                "/.x2go/pulse/.esd_auth";
-            QString destFile="~/.esd_auth";
-            paProc->start_cp ( cooFile,
-                               destFile );
-#endif
-        }
-#ifndef Q_OS_WIN
-        if ( startSoundServer )
-        {
-            soundServer=new QProcess ( this );
-            QString acmd="artsd",ecmd="esd";
-#ifdef Q_OS_DARWIN
-            QStringList env = soundServer->environment();
-            QDir dir ( appDir );
-            dir.cdUp();
-            dir.cd ( "esd" );
-            env.insert ( 0,"DYLD_LIBRARY_PATH="+
-                         dir.absolutePath() );
-            soundServer->setEnvironment ( env );
-            ecmd="\""+dir.absolutePath() +"\"/esd";
-#endif //Q_OS_DARWIN
-            if ( sndSystem==ESD )
-                soundServer->start (
-                    ecmd+
-                    " -tcp -nobeeps -bind localhost -port "+
-                    resumingSession.sndPort );
-            if ( sndSystem==ARTS )
-                soundServer->start ( acmd+" -u -N -p "+
-                                     resumingSession.sndPort );
-            sndPort=resumingSession.sndPort;
-        }
-#endif //Q_OS_WIN
-        if ( sshSndTunnel )
-        {
-            sndTunnel=new SshProcess ( sshConnection, this );
-
-#ifdef Q_OS_WIN
-            if ( sndSystem==PULSE )
-            {
-                parecTunnelOk=false;
-                connect ( sndTunnel,SIGNAL ( sshTunnelOk() ),
-                          this,SLOT ( slotSndTunOk() ) );
-            }
-#endif
-            connect ( sndTunnel,SIGNAL ( sshFinished ( bool,
-                                         QString,
-                                         SshProcess* ) ),
-                      this,SLOT (
-                          slotSndTunnelFailed ( bool,
-                                                QString,
-                                                SshProcess* ) ) );
-
-            sndTunnel->startTunnel (
-                "localhost",
-                resumingSession.sndPort.toInt(),"127.0.0.1",
-                sndPort.toInt(),true );
-            /*x2goDebug<<"starting tunnel, local port:"<<
-            	sndPort<<", remote: "<<
-            	resumingSession.sndPort<<
-            	endl;*/
-        }
-    }
-}
-
-
-
-x2goSession ONMainWindow::getSelectedSession()
-{
-    QString sessId=sessTv->model()->index ( sessTv->currentIndex().row(),
-                                            S_ID ).data().toString();
-    for ( int i=0;i<selectedSessions.size();++i )
-    {
-        if ( selectedSessions[i].sessionId==sessId )
-            return selectedSessions[i];
-    }
-    return selectedSessions[0]; //warning !!!!! undefined session
-}
-
-
-void ONMainWindow::slotTunnelOk()
-{
-
-#ifdef Q_OS_WIN
-    //waiting for X
-    if ( !winServersReady )
-    {
-        x2goDebug<<"waiting for win-servers";
-        QTimer::singleShot ( 100, this, SLOT ( slotTunnelOk() ) );
-        return;
-    }
-#endif
-
-    showExport=false;
-    QString nxroot=homeDir +"/.x2go";
-    QString dirpath=nxroot+"/S-"+resumingSession.sessionId;
-    QDir d ( dirpath );
-    if ( !d.exists() )
-        if ( !d.mkpath ( dirpath ) )
-        {
-            QString message=tr ( "Unable to create folder:" ) +
-                            dirpath;
-            QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                    QMessageBox::Ok,
-                                    QMessageBox::NoButton );
-            slotShowPassForm();
-            if ( tunnel )
-                delete tunnel;
-            if ( sndTunnel )
-                delete sndTunnel;
-            if ( fsTunnel )
-                delete fsTunnel;
-            if ( soundServer )
-                delete soundServer;
-            tunnel=sndTunnel=fsTunnel=0l;
-            soundServer=0l;
-            nxproxy=0l;
-            return;
-        }
-#ifdef Q_OS_WIN
-    dirpath=wapiShortFileName ( dirpath );
-    nxroot=wapiShortFileName ( nxroot );
-#endif
-    QFile file ( dirpath+"/options" );
-    if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
-    {
-        QString message=tr ( "Unable to write file:" ) +
-                        dirpath+"/options";
-        QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                QMessageBox::Ok,
-                                QMessageBox::NoButton );
-        slotShowPassForm();
-        return;
-    }
-
-    QTextStream out ( &file );
-#ifdef Q_OS_WIN
-    dirpath=cygwinPath ( dirpath );
-    nxroot=cygwinPath ( nxroot );
-#endif
-    out << "nx/nx,root="<<nxroot<<",connect=localhost,cookie="<<
-    resumingSession.cookie<<",port="
-    <<localGraphicPort/*resumingSession.grPort*/<<
-    ",errors="<<dirpath<<"/sessions:"<<
-    resumingSession.display;
-    file.close();
-    xmodExecuted=false;
-
-
-    nxproxy=new QProcess;
-    QStringList env = QProcess::systemEnvironment();
-    QString x2golibpath="/usr/lib/x2go";
-#if defined ( Q_OS_WIN ) || defined ( Q_OS_DARWIN )
-    int dispInd=-1;
-#endif
-    for ( int l=0;l<env.size();++l )
-    {
-// 		x2goDebug<<env[l]<<endl;
-        if ( env[l].indexOf ( "X2GO_LIB" ) ==0 )
-        {
-            x2golibpath=env[l].split ( "=" ) [1];
-        }
-#if defined ( Q_OS_WIN ) || defined ( Q_OS_DARWIN )
-        if ( env[l].indexOf ( "DISPLAY" ) ==0 )
-        {
-            dispInd=l;
-        }
-#endif
-    }
-    env << "LD_LIBRARY_PATH="+x2golibpath;
-    env << "NX_CLIENT="+QCoreApplication::applicationFilePath ();
-
-#if defined ( Q_OS_WIN ) || defined ( Q_OS_DARWIN )
-    // On Mac OS X, we want to make sure that DISPLAY is set to a proper value,
-    // but at the same time don't want to set the value ourselves but keep
-    // the provided one.
-    QString disp=getXDisplay();
-    if ( disp==QString::null )
-    {
-        //slotProxyerror ( QProcess::FailedToStart );
-        return;
-    }
-#endif // Q_OS_WIN || Q_OS_DARWIN
-#if defined ( Q_OS_WIN )
-    if ( dispInd==-1 )
-    {
-        env <<"DISPLAY=localhost:"+disp;
-        /*		x2goDebug<<"new env DISPLAY"<<"DISPLAY=localhost:"+disp<<endl;*/
-    }
-    else
-    {
-        env[dispInd]="DISPLAY=localhost:"+disp;
-        /*		x2goDebug<<"existing env DISPLAY("<<dispInd<<
-        		") DISPLAY=localhost:"+disp<<endl;*/
-    }
-#endif // Q_OS_WIN
-#if defined ( Q_OS_DARWIN )
-    //setting /usr/X11/bin to find xauth
-    env.insert (
-        0,
-        "PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin" );
-#endif
-    nxproxy->setEnvironment ( env );
-    /*	x2goDebug<<"new env:"<<endl;
-    	for ( int l=0;l<env.size();++l )
-    	{
-    		x2goDebug<<env[l]<<endl;
-    	}
-    	x2goDebug<<"##########################"<<endl;*/
-    connect ( nxproxy,SIGNAL ( error ( QProcess::ProcessError ) ),this,
-              SLOT ( slotProxyError ( QProcess::ProcessError ) ) );
-    connect ( nxproxy,SIGNAL ( finished ( int,QProcess::ExitStatus ) ),this,
-              SLOT ( slotProxyFinished ( int,QProcess::ExitStatus ) ) );
-    connect ( nxproxy,SIGNAL ( readyReadStandardError() ),this,
-              SLOT ( slotProxyStderr() ) );
-    connect ( nxproxy,SIGNAL ( readyReadStandardOutput() ),this,
-              SLOT ( slotProxyStdout() ) );
-
-    QString proxyCmd="nxproxy -S nx/nx,options="+dirpath+"/options:"+
-                     resumingSession.display;
-#ifdef Q_OS_DARWIN
-    //run nxproxy from bundle
-    QDir dir ( appDir );
-    dir.cdUp();
-    dir.cd ( "exe" );
-    proxyCmd="\""+dir.absolutePath() +"/\""+proxyCmd;
-#endif //Q_OS_DARWIN
-    x2goDebug<<"starting nxproxy with: "<<proxyCmd<<endl;
-    nxproxy->start ( proxyCmd );
-//always search for proxyWin
-    proxyWinTimer->start ( 300 );
-    if ( embedMode )
-    {
-//         proxyWinTimer->start ( 300 );
-        if ( !startEmbedded )
-        {
-            act_embedContol->setText (
-                tr ( "Attach X2Go window" ) );
-        }
-    }
-#ifdef Q_OS_WIN
-    else
-    {
-// #ifdef CFGCLIENT
-//         // if using XMing, we must find proxy win for case, that we should make it fullscreen
-        //         if(useInternalX&& (internalX==XMING))
-// #endif
-//         proxyWinTimer->start ( 300 );
-    }
-#endif
-
-    showSessionStatus();
-    QTimer::singleShot ( 30000,this,SLOT ( slotRestartProxy() ) );
-
-}
-
-void ONMainWindow::slotTunnelFailed ( bool result,  QString output,
-                                      SshProcess* )
-{
-    if ( result==false )
-    {
-        if ( !managedMode )
-        {
-            QString message=tr ( "Unable to create SSL tunnel:\n" )
-                            +output;
-            QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                    QMessageBox::Ok,
-                                    QMessageBox::NoButton );
-        }
-        if ( tunnel )
-            delete tunnel;
-        if ( sndTunnel )
-            delete sndTunnel;
-        if ( fsTunnel )
-            delete fsTunnel;
-        if ( soundServer )
-            delete soundServer;
-        tunnel=sndTunnel=fsTunnel=0l;
-        soundServer=0l;
-        nxproxy=0l;
-        if ( !managedMode )
-            slotShowPassForm();
-    }
-}
-
-void ONMainWindow::slotSndTunnelFailed ( bool result,  QString output,
-        SshProcess* )
-{
-    if ( result==false )
-    {
-        if ( !managedMode )
-        {
-            QString message=tr ( "Unable to create SSL Tunnel:\n" )
-                            +output;
-            QMessageBox::warning ( 0l,tr ( "Warning" ),message,
-                                   QMessageBox::Ok,
-                                   QMessageBox::NoButton );
-        }
-        if ( sndTunnel )
-            delete sndTunnel;
-        sndTunnel=0l;
-    }
-}
-
-
-
-void ONMainWindow::slotProxyError ( QProcess::ProcessError )
-{
-    slotProxyFinished ( -1,QProcess::CrashExit );
-}
-
-
-void ONMainWindow::slotProxyFinished ( int,QProcess::ExitStatus )
-{
-    if ( embedMode )
-    {
-        if ( proxyWinEmbedded )
-        {
-#ifdef CFGPLUGIN
-            detachClient();
-#endif
-        }
-        proxyWinTimer->stop();
-        setEmbedSessionActionsEnabled ( false );
-    }
-#ifdef Q_OS_WIN
-    else
-        proxyWinTimer->stop();
-// #ifdef CFGCLIENT
-    if (! startXorgOnStart)
-    {
-        if (xorg)
-        {
-            if (xorg->state() ==QProcess::Running)
-            {
-                xorg->terminate();
-                delete xorg;
-                xorg=0;
-            }
-        }
-    }
-// #endif
-#endif
-    if ( closeEventSent )
-        return;
-    if ( tunnel )
-        delete tunnel;
-    if ( sndTunnel )
-        delete sndTunnel;
-    if ( fsTunnel )
-        delete fsTunnel;
-    if ( soundServer )
-        delete soundServer;
-    if ( spoolTimer )
-        delete spoolTimer;
-
-    x2goDebug<<"deleting proxy"<<endl;
-    disconnect ( nxproxy,SIGNAL ( error ( QProcess::ProcessError ) ),this,
-                 SLOT ( slotProxyError ( QProcess::ProcessError ) ) );
-    disconnect ( nxproxy,SIGNAL ( finished ( int,QProcess::ExitStatus ) ),this,
-                 SLOT ( slotProxyFinished ( int,QProcess::ExitStatus ) ) );
-    disconnect ( nxproxy,SIGNAL ( readyReadStandardError() ),this,
-                 SLOT ( slotProxyStderr() ) );
-    disconnect ( nxproxy,SIGNAL ( readyReadStandardOutput() ),this,
-                 SLOT ( slotProxyStdout() ) );
-#ifndef CFGPLUGIN
-    if (trayEnabled)
-    {
-        trayIconActiveConnectionMenu->setTitle(tr("Not connected"));
-        trayIconActiveConnectionMenu->setEnabled(false);
-        if (trayMaxDiscon)
-            showNormal();
-    }
-    trayAutoHidden=false;
-#endif
-
-
-#if ! (defined(Q_OS_WIN) && defined (CFGPLUGIN))
-    if ( nxproxy )
-    {
-        if ( nxproxy->state() ==QProcess::Running )
-        {
-            x2goDebug<<"waiting for proxy to exit"<<endl;
-            if ( !nxproxy->waitForFinished ( 3000 ) )
-            {
-                x2goDebug<<"Failed, try to kill"<<endl;
-                nxproxy->kill();
-            }
-        }
-        x2goDebug<<"nxproxy not running"<<endl;
-        delete nxproxy;
-    }
-#endif
-    x2goDebug<<"proxy deleted"<<endl;
-    spoolTimer=0l;
-    tunnel=sndTunnel=fsTunnel=0l;
-    soundServer=0l;
-    nxproxy=0l;
-    proxyWinId=0;
-
-    if ( !shadowSession && !usePGPCard && ! ( embedMode &&
-            ( config.checkexitstatus==false ) ) )
-        check_cmd_status();
-    else
-        sshConnection->disconnectSession();
-    if ( startHidden )
-        close();
-
-    if ( readExportsFrom!=QString::null )
-    {
-        exportTimer->stop();
-        if ( extLogin )
-        {
-            currentKey=QString::null;
-        }
-    }
-    if ( printSupport )
-        cleanPrintSpool();
-    if ( !restartResume )
-    {
-        if ( !embedMode )
-        {
-            if (!brokerMode)
-            {
-                pass->setText ( "" );
-                QTimer::singleShot ( 2000,this,
-                                     SLOT ( slotShowPassForm() ) );
-            }
-            else
-                QTimer::singleShot ( 2000,broker,
-                                     SLOT ( getUserSessions() ) );
-
-        }
-    }
-    else
-    {
-        restartResume=false;
-        sessionStatusDlg->hide();
-        resumeSession ( resumingSession );
-    }
-    setStatStatus ( tr ( "Finished" ) );
-}
-
-
-void ONMainWindow::slotProxyStderr()
-{
-    QString reserr;
-    if ( nxproxy )
-        reserr= nxproxy->readAllStandardError();
-    x2goDebug<<reserr<<endl;
-    stInfo->insertPlainText ( reserr );
-    stInfo->ensureCursorVisible();
-    if ( stInfo->toPlainText().indexOf (
-                "Connecting to remote host 'localhost:"+
-                /*resumingSession.grPort*/ localGraphicPort ) !=-1 )
-        setStatStatus ( tr ( "connecting" ) );
-
-    if ( stInfo->toPlainText().indexOf (
-                "Connection to remote proxy 'localhost:"+
-                /*resumingSession.grPort*/
-                localGraphicPort+"' established" ) !=-1 )
-    {
-        if ( newSession )
-            setStatStatus ( tr ( "starting" ) );
-        else
-            setStatStatus ( tr ( "resuming" ) );
-    }
-
-    if ( stInfo->toPlainText().indexOf (
-                "Established X server connection" ) !=-1 )
-    {
-        setStatStatus ( tr ( "running" ) );
-#ifndef CFGPLUGIN
-        if (trayEnabled)
-        {
-            if (!useLdap)
-                trayIconActiveConnectionMenu->setTitle(lastSession->name());
-            else
-                trayIconActiveConnectionMenu->setTitle(lastUser->username());
-            trayIconActiveConnectionMenu->setEnabled(true);
-            if (trayMinCon && !trayAutoHidden)
-            {
-                trayAutoHidden=true;
-                hide();
-            }
-        }
-#endif
-        if ( embedMode )
-            setEmbedSessionActionsEnabled ( true );
-        disconnect ( sbSusp,SIGNAL ( clicked() ),this,
-                     SLOT ( slotTestSessionStatus() ) );
-        disconnect ( sbSusp,SIGNAL ( clicked() ),this,
-                     SLOT ( slotSuspendSessFromSt() ) );
-        connect ( sbSusp,SIGNAL ( clicked() ),this,
-                  SLOT ( slotSuspendSessFromSt() ) );
-        if ( !showExport )
-        {
-            showExport=true;
-            /*connect ( sbExp,SIGNAL ( clicked() ),this,
-              SLOT ( slot_exportDirectory() ) );*/
-            sbExp->setEnabled ( true );
-            exportDefaultDirs();
-            if ( readExportsFrom!=QString::null )
-            {
-                exportTimer->start ( 2000 );
-            }
-        }
-        sbSusp->setToolTip ( tr ( "Suspend" ) );
-        if ( newSession )
-        {
-            runCommand();
-            newSession=false;
-        }
-#ifdef 	Q_WS_HILDON
-        else
-        {
-            if ( !xmodExecuted )
-            {
-                xmodExecuted=true;
-                QTimer::singleShot (
-                    2000, this,
-                    SLOT ( slotExecXmodmap() ) );
-            }
-        }
-#endif
-    }
-    if ( stInfo->toPlainText().indexOf (
-                tr ( "Connection timeout, aborting" ) ) !=-1 )
-        setStatStatus ( tr ( "aborting" ) );
-#if defined( Q_OS_WIN ) && defined (CFGPLUGIN)
-    if ( reserr.indexOf ( "Session terminated at" ) !=-1 )
-    {
-        x2goDebug<<"proxy finished"<<endl;
-        slotProxyFinished ( 0, QProcess::NormalExit );
-    }
-#endif
-
-
-}
-
-
-void ONMainWindow::slotProxyStdout()
-{
-    QString resout ( nxproxy->readAllStandardOutput() );
-    x2goDebug<<resout<<endl;
-
-}
-
-
-void ONMainWindow::slotShowPassForm()
-{
-    if ( !useLdap )
-    {
-        loginPrompt->show();
-        login->show();
-    }
-    else
-    {
-        loginPrompt->hide();
-        login->hide();
-    }
-    setEnabled ( true );
-    if ( !embedMode )
-    {
-        u->hide();
-        uname->hide();
-    }
-    sessionStatusDlg->hide();
-    selectSessionDlg->hide();
-    setEnabled ( true );
-    if ( isPassShown )
-    {
-        passForm->show();
-        passForm->setEnabled ( true );
-    }
-    isPassShown=true;
-    login->setEnabled ( true );
-    if ( login->text().length() >0 )
-    {
-        pass->setFocus();
-        pass->selectAll();
-    }
-    else
-        login->setFocus();
-
-
-    if ( !embedMode )
-    {
-        u->setEnabled ( true );
-    }
-    else
-    {
-        if ( config.user.length() >0 )
-            login->setEnabled ( false );
-    }
-}
-
-
-void ONMainWindow::showSessionStatus()
-{
-    setStatStatus();
-}
-
-
-void ONMainWindow::slotShowAdvancedStat()
-{
-    if ( !miniMode )
-    {
-        if ( sbAdv->isChecked() )
-        {
-            sessionStatusDlg->setFixedSize (
-                sessionStatusDlg->width(),
-                sessionStatusDlg->height() *2 );
-        }
-        else
-        {
-            sessionStatusDlg->setFixedSize (
-                sessionStatusDlg->sizeHint() );
-            stInfo->hide();
-        }
-    }
-    else
-    {
-        if ( sbAdv->isChecked() )
-        {
-            sessionStatusDlg->setFixedSize ( 310,300 );
-        }
-        else
-        {
-            stInfo->hide();
-            sessionStatusDlg->setFixedSize ( 310,200 );
-        }
-    }
-
-
-// 	username->invalidate();
-
-
-    if ( sbAdv->isChecked() )
-    {
-        stInfo->show();
-    }
-
-    X2goSettings st ( "settings" );
-    st.setting()->setValue ( "showStatus",
-                             ( QVariant ) sbAdv->isChecked() );
-    st.setting()->sync();
-}
-
-
-
-
-void ONMainWindow::slotResumeDoubleClick ( const QModelIndex& )
-{
-    if ( !shadowSession )
-        slotResumeSess();
-}
-
-
-void ONMainWindow::suspendSession ( QString sessId )
-{
-    SshProcess* proc=0l;
-    proc=new SshProcess ( sshConnection, this );
-
-    connect ( proc,SIGNAL ( sshFinished ( bool,  QString,SshProcess* ) ),
-              this,SLOT ( slotRetSuspSess ( bool,  QString,
-                                            SshProcess* ) ) );
-
-    proc->startNormal ( "x2gosuspend-session "+sessId );
-}
-
-
-bool ONMainWindow::termSession ( QString sessId, bool warn )
-{
-    if ( warn )
-    {
-        bool hide_after=false;
-        if (isHidden())
-        {
-            showNormal();
-            hide_after=true;
-        }
-        int answer=QMessageBox::warning (
-                       this,tr ( "Warning" ),
-                       tr (
-                           "Are you sure you want to terminate "
-                           "this session?\n"
-                           "Unsaved documents will be lost" ),
-                       QMessageBox::Yes,QMessageBox::No );
-        if (hide_after)
-            hide();
-
-        if ( answer !=
-                QMessageBox::Yes )
-        {
-            slotRetTermSess ( true,QString::null,0 );
-            return false;
-        }
-    }
-    if ( shadowSession )
-    {
-        nxproxy->terminate();
-        return true;
-    }
-
-    SshProcess* proc=0l;
-    proc=new SshProcess ( sshConnection,  this );
-
-    connect ( proc,SIGNAL ( sshFinished ( bool,  QString,SshProcess* ) ),
-              this,SLOT ( slotRetTermSess ( bool,
-                                            QString,SshProcess* ) ) );
-
-    proc->startNormal ( "x2goterminate-session "+sessId );
-    return true;
-}
-
-
-
-void ONMainWindow::setStatStatus ( QString status )
-{
-    setEnabled ( true );
-    passForm->hide();
-    selectSessionDlg->hide();
-    if ( status == QString::null )
-        status=statusString;
-    else
-        statusString=status;
-    QString tstr;
-    if ( statusLabel )
-        statusLabel->setText ( QString::null );
-    if ( resumingSession.sessionId!=QString::null )
-    {
-        QString f="dd.MM.yy HH:mm:ss";
-        QDateTime dt=QDateTime::fromString ( resumingSession.crTime,f );
-        dt=dt.addYears ( 100 );
-        tstr=dt.toString();
-    }
-    if ( !embedMode || !proxyWinEmbedded )
-    {
-        statusBar()->showMessage ( "");
-#if ! (defined Q_OS_WIN && defined CFGPLUGIN)
-        statusBar()->hide();
-#endif
-        QString srv;
-        if ( embedMode )
-            srv=config.server;
-        else
-            srv=resumingSession.server;
-        slVal->setText ( resumingSession.sessionId+"\n"+
-                         srv+"\n"+
-                         getCurrentUname() +"\n"+
-                         resumingSession.display+
-                         "\n"+tstr+"\n"+status );
-
-        slVal->setFixedSize ( slVal->sizeHint() );
-        sessionStatusDlg->show();
-        if (resumingSession.published)
-            sbApps->show();
-        else
-            sbApps->hide();
-    }
-    else
-    {
-
-        QString srv=config.server;
-        QString message=getCurrentUname() +"@"+
-                        srv+
-                        ", "+tr ( "Session" ) +": "+
-                        resumingSession.sessionId+", "+
-                        tr ( "Display" ) +": "+
-                        resumingSession.display+", "+
-                        tr ( "Creation time" ) +": "+tstr;
-#if ! (defined Q_OS_WIN && defined CFGPLUGIN)
-        if ( statusLabel )
-        {
-            statusLabel->setText ( "   "+message );
-        }
-        else
-#endif
-        {
-            if ( config.showstatusbar )
-            {
-                statusBar()->show();
-                statusBar()->showMessage ( message );
-            }
-        }
-        sessionStatusDlg->hide();
-    }
-}
-
-
-void ONMainWindow::slotRestartProxy()
-{
-    if ( !sessionStatusDlg->isVisible() )
-        return;
-    if ( stInfo->toPlainText().indexOf (
-                "Established X server connection" ) ==-1 )
-    {
-        stInfo->insertPlainText (
-            tr (
-                "Connection timeout, aborting" ) );
-        if ( nxproxy )
-            nxproxy->terminate();
-        restartResume=true;
-    }
-}
-
-
-void ONMainWindow::slotTestSessionStatus()
-{
-
-    if ( !sessionStatusDlg->isVisible() )
-        return;
-    if ( stInfo->toPlainText().indexOf (
-                "Established X server connection" ) ==-1 )
-    {
-        stInfo->insertPlainText (
-            tr ( "Connection timeout, aborting" ) );
-        if ( nxproxy )
-            nxproxy->terminate();
-    }
-}
-
diff --git a/onmainwindow_part3.cpp b/onmainwindow_part3.cpp
deleted file mode 100644
index 350a648..0000000
--- a/onmainwindow_part3.cpp
+++ /dev/null
@@ -1,2510 +0,0 @@
-/**************************************************************************
-*   Copyright (C) 2005-2012 by Oleksandr Shneyder                         *
-*   oleksandr.shneyder at obviously-nice.de                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU General Public License as published by  *
-*   the Free Software Foundation; either version 2 of the License, or     *
-*   (at your option) any later version.                                   *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU General Public License     *
-*   along with this program; if not, write to the                         *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-
-#include "onmainwindow_privat.h"
-
-x2goSession ONMainWindow::getNewSessionFromString ( const QString& string )
-{
-    QStringList lst=string.split ( '|' );
-    x2goSession s;
-    s.display=lst[0];
-    s.cookie=lst[1];
-    s.agentPid=lst[2];
-    s.sessionId=lst[3];
-    s.grPort=lst[4];
-    s.sndPort=lst[5];
-    if ( lst.count() >6 )
-        s.fsPort=lst[6];
-    return s;
-}
-
-
-void ONMainWindow::slotAppDialog()
-{
-    AppDialog dlg(this);
-    dlg.exec();
-}
-
-void ONMainWindow::runCommand()
-{
-    QString passwd=getCurrentPass();
-    QString user=getCurrentUname();
-    QString host=resumingSession.server;
-    QString command;
-    QString sessionType="D";
-    QString rdpOpts,rdpServer;
-    bool rdpFS=false;
-    QString rdpWidth;
-    QString rdpHeight;
-    bool rootless=false;
-    resumingSession.published=false;
-    if ( !embedMode )
-    {
-        X2goSettings* st;
-        if (!brokerMode)
-            st=new X2goSettings( "sessions" );
-        else
-            st=new X2goSettings(config.iniFile, QSettings::IniFormat);
-
-
-        if ( useLdap )
-            command=sessionCmd;
-        else
-        {
-            QString sid=lastSession->id();
-            command=st->setting()->value (
-                        sid+"/command",
-                        ( QVariant ) tr ( "KDE" ) ).toString();
-            rdpOpts=st->setting()->value (
-                        sid+"/rdpoptions",
-                        ( QVariant ) "" ).toString();
-            rdpServer=st->setting()->value (
-                          sid+"/rdpserver",
-                          ( QVariant ) "" ).toString();
-            rootless=st->setting()->value ( sid+"/rootless",
-                                            ( QVariant ) false ).toBool();
-            resumingSession.published=st->setting()->value ( sid+"/published",
-                                      ( QVariant ) false ).toBool();
-
-            rdpFS=st->setting()->value (
-                      sid+"/fullscreen",
-                      ( QVariant ) defaultFullscreen ).toBool();
-            rdpHeight=st->setting()->value (
-                          sid+"/height",
-                          ( QVariant ) defaultHeight ).toString();
-            rdpWidth=st->setting()->value (
-                         sid+"/width",
-                         ( QVariant ) defaultWidth ).toString();
-
-        }
-        delete st;
-    }
-    else
-    {
-        command=config.command;
-        rootless=config.rootless;
-    }
-    if ( rootless )
-        sessionType="R";
-    if ( resumingSession.published )
-    {
-        sessionType="P";
-        command="PUBLISHED";
-    }
-
-    if ( command=="KDE" )
-    {
-        command="startkde";
-    }
-    else if ( command=="GNOME" )
-    {
-        command="gnome-session";
-    }
-    else if ( command=="LXDE" )
-    {
-        command="startlxde";
-    }
-    else if ( command=="RDP" )
-    {
-        command="rdesktop ";
-        if ( rdpFS )
-            command+=" -f ";
-        else
-            command+=" -g "+rdpWidth+"x"+rdpHeight;
-        command+=" "+rdpOpts+ " "+rdpServer;
-
-        sessionType="R";
-    }
-
-    if ( managedMode )
-        return;
-
-    SshProcess *proc=0l;
-
-    QString cmd;
-
-    command.replace ( " ","X2GO_SPACE_CHAR" );
-
-    if ( !startSessSound  || startSessSndSystem==PULSE )
-    {
-        cmd="setsid x2goruncommand "+resumingSession.display+" "+
-            resumingSession.agentPid + " " +
-            resumingSession.sessionId+" "+
-            resumingSession.sndPort+ " "+ command+" nosnd "+
-            sessionType +">& /dev/null & exit";
-        if ( startSessSndSystem ==PULSE )
-        {
-            cmd="PULSE_CLIENTCONFIG=~/.x2go/C-"+
-                resumingSession.sessionId+
-                "/.pulse-client.conf "+cmd;
-        }
-    }
-    else
-    {
-        switch ( startSessSndSystem )
-        {
-        case ESD:
-            cmd="setsid x2goruncommand "+
-                resumingSession.display+" "+
-                resumingSession.agentPid + " " +
-                resumingSession.sessionId+" "+
-                resumingSession.sndPort+ " "+
-                command+" esd "+
-                sessionType +">& /dev/null & exit";
-            break;
-        case ARTS:
-            cmd="setsid x2goruncommand "+
-                resumingSession.display+" "+
-                resumingSession.agentPid + " " +
-                resumingSession.sessionId+" "+
-                resumingSession.sndPort+ " "+
-                command+" arts "+
-                sessionType +">& /dev/null & exit";
-            break;
-
-        }
-    }
-
-    if ( runRemoteCommand )
-    {
-        proc=new SshProcess ( sshConnection, this );
-        connect ( proc,SIGNAL ( sshFinished ( bool, QString,
-                                              SshProcess* ) ),
-                  this,SLOT ( slotRetRunCommand ( bool,
-                                                  QString,
-                                                  SshProcess* ) ) );
-
-        proc->startNormal ( cmd );
-    }
-#ifdef Q_WS_HILDON
-    //wait 5 seconds and execute xkbcomp
-    QTimer::singleShot ( 5000, this, SLOT ( slotExecXmodmap() ) );
-#endif
-}
-
-
-void ONMainWindow::runApplication(QString exec)
-{
-    SshProcess* proc=new SshProcess ( sshConnection, this );
-    proc->startNormal ("PULSE_CLIENTCONFIG=~/.x2go/C-"+
-                       resumingSession.sessionId+"/.pulse-client.conf DISPLAY=:"+
-                       resumingSession.display+
-                       " setsid "+exec+">& /dev/null & exit");
-}
-
-void ONMainWindow::slotRetRunCommand ( bool result, QString output,
-                                       SshProcess* proc )
-{
-    if ( proc )
-        delete proc;
-    if ( result==false )
-    {
-        QString message=tr ( "<b>Connection failed</b>\n:\n" ) +output;
-        if ( message.indexOf ( "publickey,password" ) !=-1 )
-        {
-            message=tr ( "<b>Wrong password!</b><br><br>" ) +
-                    message;
-        }
-        QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                QMessageBox::Ok,
-                                QMessageBox::NoButton );
-    }
-    else
-    {
-        if (resumingSession.published)
-            readApplications();
-    }
-}
-
-void ONMainWindow::readApplications()
-{
-    SshProcess* proc=new SshProcess ( sshConnection, this );
-    connect ( proc,SIGNAL ( sshFinished ( bool, QString,
-                                          SshProcess* ) ),
-              this,SLOT ( slotReadApplications ( bool,
-                                                 QString,
-                                                 SshProcess* ) ) );
-    proc->startNormal ( "x2gogetapps" );
-    sbApps->setEnabled(false);
-}
-
-void ONMainWindow::slotReadApplications(bool result, QString output,
-                                        SshProcess* proc )
-{
-    if ( proc )
-        delete proc;
-    if ( result==false )
-    {
-        QString message=tr ( "<b>Connection failed</b>\n:\n" ) +output;
-        if ( message.indexOf ( "publickey,password" ) !=-1 )
-        {
-            message=tr ( "<b>Wrong password!</b><br><br>" ) +
-                    message;
-        }
-        QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                QMessageBox::Ok,
-                                QMessageBox::NoButton );
-        return;
-    }
-    sbApps->setEnabled(true);
-    applications.clear();
-    QString locallong=QLocale::system().name();
-    QString localshort=QLocale::system().name().split("_")[0];
-
-    foreach(QString appstr, output.split("</desktop>",QString::SkipEmptyParts))
-    {
-        bool localcomment=false;
-        bool localname=false;
-        Application app;
-        app.category=Application::OTHER;
-        QStringList lines=appstr.split("\n", QString::SkipEmptyParts);
-        for (int i=0; i<lines.count(); ++i)
-        {
-            QString line=lines[i];
-            if (line.indexOf("Name["+localshort+"]=")!=-1  || line.indexOf("Name["+locallong+"]=")!=-1)
-            {
-                app.name=QString::fromUtf8(line.split("=")[1].toAscii());
-//                 x2goDebug<<"local name: "<<app.name<<endl;
-                localname=true;
-            }
-            if (line.indexOf("Comment["+localshort+"]=")!=-1 || line.indexOf("Comment["+locallong+"]=")!=-1)
-            {
-                app.comment=QString::fromUtf8(line.split("=")[1].toAscii());
-//                 x2goDebug<<"local comment: "<<app.comment<<endl;
-                localcomment=true;
-            }
-            if (line.indexOf("Name=")!=-1 && !localname)
-            {
-                app.name=line.split("=")[1];
-//                 x2goDebug<<"name: "<<app.name<<endl;
-            }
-            if (line.indexOf("Comment=")!=-1 && !localcomment)
-            {
-                app.comment=line.split("=")[1];
-//                 x2goDebug<<"comment: "<<app.comment<<endl;
-            }
-            if (line.indexOf("Exec=")!=-1)
-            {
-                app.exec=line.split("=")[1];
-                app.exec.replace("%f","",Qt::CaseInsensitive);
-                app.exec.replace("%u","",Qt::CaseInsensitive);
-//                 x2goDebug<<"exec: "<<app.exec<<endl;
-            }
-            if (line.indexOf("Categories=")!=-1)
-            {
-                if (line.indexOf("Audio")!=-1)
-                    app.category=Application::MULTIMEDIA;
-                if (line.indexOf("Vide")!=-1)
-                    app.category=Application::MULTIMEDIA;
-                if (line.indexOf("Development")!=-1)
-                    app.category=Application::DEVELOPMENT;
-                if (line.indexOf("Education")!=-1)
-                    app.category=Application::EDUCATION;
-                if (line.indexOf("Game")!=-1)
-                    app.category=Application::GAME;
-                if (line.indexOf("Graphics")!=-1)
-                    app.category=Application::GRAPHICS;
-                if (line.indexOf("Network")!=-1)
-                    app.category=Application::NETWORK;
-                if (line.indexOf("Office")!=-1)
-                    app.category=Application::OFFICE;
-                if (line.indexOf("Settings")!=-1)
-                    app.category=Application::SETTINGS;
-                if (line.indexOf("System")!=-1)
-                    app.category=Application::SYSTEM;
-                if (line.indexOf("Utility")!=-1)
-                    app.category=Application::UTILITY;
-                if (line.indexOf("X2Go-Top",0,Qt::CaseInsensitive)!=-1)
-                    app.category=Application::TOP;
-            }
-            if (line.indexOf("<icon>")!=-1)
-            {
-                bool isSvg=false;
-                line=lines[++i];
-                QByteArray pic;
-                while (line.indexOf("</icon>")==-1)
-                {
-                    pic+=QByteArray::fromBase64(line.toAscii());
-                    line=lines[++i];
-                    if (QString(QByteArray::fromBase64(line.toAscii())).indexOf("</svg>",Qt::CaseInsensitive)!=-1)
-                    {
-                        isSvg=true;
-                    }
-                }
-                if (!isSvg)
-                    app.icon.loadFromData(pic);
-                else
-                {
-                    QPixmap pix(32,32);
-                    QSvgRenderer svgRenderer( pic );
-                    QPainter pixPainter(&pix);
-                    svgRenderer.render(&pixPainter);
-                    app.icon=pix;
-                }
-            }
-        }
-        if (app.name.length()>0)
-        {
-            if (app.comment.length()<=0)
-                app.comment=app.name;
-            applications.append(app);
-        }
-    }
-
-    qSort(applications.begin(), applications.end(),Application::lessThen);
-    plugAppsInTray();
-}
-
-
-bool ONMainWindow::parseParameter ( QString param )
-{
-    if ( param=="--help" )
-    {
-        showHelp();
-        return false;
-    }
-
-    if ( param=="--help-pack" )
-    {
-        showHelpPack();
-        return false;
-    }
-
-    if ( param == "--portable" )
-    {
-        ONMainWindow::portable=true;
-        return true;
-    }
-    if ( param == "--clean-all-files" )
-    {
-        cleanAllFiles=true;
-        return true;
-    }
-    if (param == "--connectivity-test")
-    {
-        connTest=true;
-        return true;
-    }
-
-    if ( param=="--no-menu" )
-    {
-        drawMenu=false;
-        return true;
-    }
-
-    if ( param=="--maximize" )
-    {
-        startMaximized=true;
-        return true;
-    }
-    if ( param=="--xinerama" )
-    {
-        defaultXinerama=true;
-        return true;
-    }
-    if (param == "--thinclient")
-    {
-        thinMode=true;
-        startMaximized=true;
-        return true;
-    }
-    if (param == "--haltbt")
-    {
-        showHaltBtn=true;
-        return true;
-    }
-    if ( param=="--hide" )
-    {
-        startHidden=true;
-        return true;
-    }
-    if ( param=="--pgp-card" )
-    {
-        usePGPCard=true;
-        return true;
-    }
-    if ( param=="--ldap-printing" )
-    {
-        LDAPPrintSupport=true;
-        return true;
-    }
-    if ( param=="--add-to-known-hosts" )
-    {
-        acceptRsa=true;
-        return true;
-    }
-    if ( param=="--no-session-edit" )
-    {
-        noSessionEdit=true;
-        return true;
-    }
-    if ( param=="--change-broker-pass")
-    {
-        changeBrokerPass=true;
-        return true;
-    }
-
-
-    QString setting,value;
-    QStringList vals=param.split ( "=" );
-    if ( vals.size() <2 )
-    {
-        printError ( param );
-        return false;
-    }
-    setting=vals[0];
-    vals.removeFirst();
-    value=vals.join ( "=" );
-    if ( setting=="--link" )
-    {
-        return linkParameter ( value );
-    }
-    if ( setting=="--sound" )
-    {
-        return soundParameter ( value );
-    }
-    if ( setting=="--geometry" )
-    {
-        return geometry_par ( value );
-    }
-    if ( setting=="--pack" )
-    {
-        return packParameter ( value );
-    }
-    if ( setting=="--kbd-layout" )
-    {
-        defaultLayout=value.split(",",QString::SkipEmptyParts);
-        if (defaultLayout.size()==0)
-            defaultLayout<<tr("us");
-        return true;
-    }
-    if ( setting=="--session" )
-    {
-        defaultSession=true;
-        defaultSessionName=value;
-        return true;
-    }
-    if ( setting=="--session-conf" )
-    {
-        ONMainWindow::sessionCfg=value;
-        return true;
-    }
-    if ( setting=="--sessionid" )
-    {
-        defaultSession=true;
-        defaultSessionId=value;
-        return true;
-    }
-    if ( setting=="--user" )
-    {
-        defaultUser=true;
-        defaultUserName=value;
-        return true;
-    }
-    if ( setting=="--kbd-type" )
-    {
-        defaultKbdType=value;
-        return true;
-    }
-    if ( setting=="--set-kbd" )
-    {
-        return setKbd_par ( value );
-    }
-    if ( setting=="--ldap" )
-    {
-        return ldapParameter ( value );
-    }
-    if ( setting=="--ldap1" )
-    {
-        return ldap1Parameter ( value );
-    }
-    if ( setting=="--ldap2" )
-    {
-        return ldap2Parameter ( value );
-    }
-    if ( setting=="--command" )
-    {
-        defaultCmd=value;
-        return true;
-    }
-    if ( setting=="--read-exports-from" )
-    {
-        readExportsFrom=value;
-        return true;
-    }
-    if ( setting=="--external-login" )
-    {
-        extLogin=true;
-        readLoginsFrom=value;
-        return true;
-    }
-    if ( setting=="--ssh-port" )
-    {
-        defaultSshPort=value;
-        return true;
-    }
-    if ( setting=="--dpi" )
-    {
-        defaultSetDPI=true;
-        defaultDPI=value.toUInt();
-        return true;
-    }
-    if ( setting=="--client-ssh-port" )
-    {
-        clientSshPort=value;
-        return true;
-    }
-    if ( setting == "--embed-into" )
-    {
-        embedMode=true;
-        embedParent=value.toLong();
-        return true;
-    }
-    if ( setting == "--broker-url")
-    {
-        brokerMode=true;
-        noSessionEdit=true;
-        config.brokerurl=value;
-        return true;
-    }
-    if ( setting == "--broker-name")
-    {
-        config.brokerName=value;
-        return true;
-    }
-    if ( setting == "--auth-id")
-    {
-        QFile file(value);
-        if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
-        {
-            printError ( param + tr(" (can't open file)"));
-            return false;
-        }
-        QTextStream in(&file);
-        config.brokerUserId = in.readLine();
-        return true;
-    }
-    if (setting == "--support-menu")
-    {
-        if (! QFile::exists(value))
-        {
-            printError( param + tr(" (file not exists)"));
-            return false;
-        }
-        supportMenuFile=value;
-        return true;
-    }
-    if (setting == "--background")
-    {
-        if (! QFile::exists(value))
-        {
-            printError( param + tr(" (file not exists)"));
-            return false;
-        }
-        BGFile=value;
-        return true;
-    }
-    if (setting == "--session-icon")
-    {
-        if (! QFile::exists(value))
-        {
-            printError( param + tr(" (file not exists)"));
-            return false;
-        }
-        SPixFile=value;
-        return true;
-    }
-    if (setting == "--home")
-    {
-        QDir dr;
-
-#ifdef Q_OS_WIN
-        int find=value.indexOf("(");
-        int lind=value.indexOf(")");
-        if (find!=-1 && lind !=-1)
-        {
-            QString label=value.mid(find+1,lind-find-1);
-            x2goDebug<< "searching for drive with label: "<<label;
-            QString drive=wapiGetDriveByLabel(label);
-            value.replace("("+label+")",drive);
-            x2goDebug<<"new path: "<<value;
-        }
-#endif
-        if (! dr.exists(value))
-        {
-            printError( param + tr(" (directory not exists)"));
-            return false;
-        }
-        homeDir=value;
-        portableDataPath=value;
-        return true;
-    }
-
-    printError ( param );
-    return false;
-}
-
-
-bool ONMainWindow::linkParameter ( QString value )
-{
-    if ( value=="modem" )
-        defaultLink=MODEM;
-    else if ( value=="isdn" )
-        defaultLink=ISDN;
-    else if ( value=="adsl" )
-        defaultLink=ADSL;
-    else if ( value=="wan" )
-        defaultLink=WAN;
-    else if ( value=="lan" )
-        defaultLink=LAN;
-    else
-    {
-        qCritical (
-            "%s",tr (
-                "wrong value for argument\"--link\""
-            ).toLocal8Bit().data() );
-        return false;
-    }
-    return true;
-
-}
-
-bool ONMainWindow::soundParameter ( QString val )
-{
-    if ( val=="1" )
-        defaultUseSound=true;
-    else if ( val=="0" )
-        defaultUseSound=false;
-    else
-    {
-        qCritical (
-            "%s",tr ( "wrong value for "
-                      "argument\"--sound\"" ).toLocal8Bit().data() );
-        return false;
-    }
-    return true;
-}
-
-bool ONMainWindow::geometry_par ( QString val )
-{
-    if ( val=="fullscreen" )
-        defaultFullscreen=true;
-    else
-    {
-        QStringList res=val.split ( "x" );
-        if ( res.size() !=2 )
-        {
-            qCritical (
-                "%s",tr (
-                    "wrong value for argument\"--geometry\"" ).
-                toLocal8Bit().data() );
-            return false;
-        }
-        bool o1,o2;
-        defaultWidth=res[0].toInt ( &o1 );
-        defaultHeight=res[1].toInt ( &o2 );
-        if ( ! ( defaultWidth >0 && defaultHeight >0 && o1 && o2 ) )
-        {
-            qCritical (
-                "%s",tr (
-                    "wrong value for argument\"--geometry\"" ).
-                toLocal8Bit().data() );
-            return false;
-        }
-    }
-    return true;
-}
-
-bool ONMainWindow::setKbd_par ( QString val )
-{
-    if ( val=="1" )
-        defaultSetKbd=true;
-    else if ( val=="0" )
-        defaultSetKbd=false;
-    else
-    {
-        qCritical (
-            "%s",tr (
-                "wrong value for argument\"--set-kbd\"" ).
-            toLocal8Bit().data() );
-        return false;
-    }
-    return true;
-}
-
-bool ONMainWindow::ldapParameter ( QString val )
-{
-    QString ldapstring=val;
-    useLdap=true;
-    ldapstring.replace ( "\"","" );
-    QStringList lst=ldapstring.split ( ':',QString::SkipEmptyParts );
-    if ( lst.size() !=3 )
-    {
-        qCritical (
-            "%s",tr (
-                "wrong value for argument\"--ldap\"" ).
-            toLocal8Bit().data() );
-        return false;
-    }
-    ldapOnly=true;
-    ldapServer=lst[0];
-    ldapPort=lst[1].toInt();
-    ldapDn=lst[2];
-
-
-    return true;
-}
-
-bool ONMainWindow::ldap1Parameter ( QString val )
-{
-    QString ldapstring=val;
-    ldapstring.replace ( "\"","" );
-    QStringList lst=ldapstring.split ( ':',QString::SkipEmptyParts );
-    if ( lst.size() !=2 )
-    {
-        qCritical (
-            "%s",tr (
-                "wrong value for argument\"--ldap1\"" ).
-            toLocal8Bit().data() );
-        return false;
-    }
-    ldapServer1=lst[0];
-    ldapPort1=lst[1].toInt();
-
-    return true;
-}
-
-bool ONMainWindow::ldap2Parameter ( QString val )
-{
-    QString ldapstring=val;
-    ldapstring.replace ( "\"","" );
-    QStringList lst=ldapstring.split ( ':',QString::SkipEmptyParts );
-    if ( lst.size() !=2 )
-    {
-        qCritical ( "%s",
-                    tr (
-                        "wrong value for argument\"--ldap2\"" ).
-                    toLocal8Bit().data() );
-        return false;
-    }
-    ldapServer2=lst[0];
-    ldapPort2=lst[1].toInt();
-
-    return true;
-}
-
-
-bool ONMainWindow::packParameter ( QString val )
-{
-
-    QFile file ( ":/txt/packs" );
-    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-        return true;
-    QTextStream in ( &file );
-    while ( !in.atEnd() )
-    {
-        QString pc=in.readLine();
-        if ( pc.indexOf ( "-%" ) !=-1 )
-        {
-            pc=pc.left ( pc.indexOf ( "-%" ) );
-
-            QStringList pctails=val.split ( "-" );
-            QString pcq=pctails[pctails.size()-1];
-            pctails.removeLast();
-
-            if ( pctails.join ( "-" ) ==pc )
-            {
-                bool ok;
-                int v=pcq.toInt ( &ok );
-                if ( ok && v>=0 && v<=9 )
-                {
-                    defaultPack=pc;
-                    defaultQuality=v;
-                    return true;
-                }
-                else
-                    break;
-            }
-        }
-        else
-        {
-            if ( pc==val )
-            {
-                defaultPack=val;
-                return true;
-            }
-        }
-    }
-    file.close();
-    qCritical ( "%s",tr ( "wrong value for argument\"--pack\"" ).
-                toLocal8Bit().data() );
-    return false;
-}
-
-
-void ONMainWindow::printError ( QString param )
-{
-    qCritical ( "%s", ( tr ( "wrong parameter: " ) +param ).
-                toLocal8Bit().data() );
-#ifdef Q_OS_WIN
-    x2goDebug<<tr ( "wrong parameter: " ) +param <<endl;
-#endif
-}
-
-void ONMainWindow::showHelp()
-{
-    QString helpMsg=
-        "Usage: x2goclient [Options]\n"
-        "Options:\n"
-        "--help\t\t\t\t show this message\n"
-        "--help-pack\t\t\t show available pack methods\n"
-        "--no-menu\t\t\t hide menu bar\n"
-        "--no-session-edit\t\t not allow user to edit preconfigured\n"
-        "\t\t\t\t sessions\n"
-        "--maximize\t\t\t start maximized\n"
-        "--hide\t\t\t\t start hidden\n"
-        "--portable\t\t\t start in \"portable\" mode\n"
-        "--pgp-card\t\t\t use openPGP card authentication\n"
-        "--xinerama\t\t\t use Xinerama by default\n"
-        "--ldap-printing\t\t\t allow client side printing in LDAP mode\n"
-        "--thinclient\t\t\t run without window manager\n"
-        "--haltbt\t\t\t show shutdown button\n"
-        "--add-to-known-hosts\t\t add RSA key fingerprint to "
-        ".ssh/known_hosts\n"
-        "\t\t\t\t if authenticity of server can't be established\n\n"
-        "--ldap=<host:port:dn> \t\t start with LDAP support. Example:\n"
-        "\t\t\t\t --ldap=ldapserver:389:o=organization,c=de\n\n"
-        "--ldap1=<host:port>\t\t LDAP failover server #1 \n"
-        "--ldap2=<host:port>\t\t LDAP failover server #2 \n"
-        "--ssh-port=<port>\t\t connect to this port, default 22\n"
-        "--client-ssh-port=<port>\t local ssh port (for fs export), "
-        "default 22\n"
-        "--command=<cmd>\t\t\t Set default command, default value 'KDE'\n"
-        "--session=<session>\t\t Start session 'session'\n"
-        "--user=<username>\t\t in LDAP mode, select user 'username'\n"
-        "--geomerty=<W>x<H>|fullscreen\t set default geometry, default "
-        "value '800x600'\n"
-        "--dpi=<dpi>\t\t\t set dpi of x2goagent to dpi, default not set\n"
-        "--link=<modem|isdn|adsl|wan|lan> set default link type, "
-        "default 'adsl'\n"
-        "--pack=<packmethod>\t\t set default pack method, default "
-        "'16m-jpeg-9'\n"
-        "--kbd-layout=<layout>\t\t set default keyboard layout or layouts\n"
-        "\t\t\t\t comma separated\n"
-        "--kbd-type=<typed>\t\t set default keyboard type\n"
-        "--home=<dir>\t\t\t set users home directory\n"
-        "--set-kbd=<0|1>\t\t\t overwrite current keyboard settings\n"
-        "--session-conf=<file>\t\t\t path to alternative session config\n";
-    qCritical ( "%s",helpMsg.toLocal8Bit().data() );
-    QMessageBox::information ( this,tr ( "Options" ),helpMsg );
-}
-
-void ONMainWindow::showHelpPack()
-{
-    qCritical ( "%s",tr (
-                    "Available pack methodes:" ).toLocal8Bit().data() );
-    QFile file ( ":/txt/packs" );
-    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-        return;
-    QTextStream in ( &file );
-    QString msg;
-    while ( !in.atEnd() )
-    {
-        QString pc=in.readLine();
-        if ( pc.indexOf ( "-%" ) !=-1 )
-        {
-            pc=pc.left ( pc.indexOf ( "-%" ) );
-            pc+="-[0-9]";
-        }
-        msg+=pc+"\n";
-        qCritical ( "%s",pc.toLocal8Bit().data() );
-    }
-    file.close();
-#ifdef Q_OS_WIN
-
-    QMessageBox::information ( this,tr ( "Options" ),msg );
-#endif
-
-}
-
-void ONMainWindow::slotGetServers ( bool result, QString output,
-                                    SshProcess* proc )
-{
-    if ( proc )
-        delete proc;
-    proc=0;
-    if ( result==false )
-    {
-        cardReady=false;
-        cardStarted=false;
-
-        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
-        if ( message.indexOf ( "publickey,password" ) !=-1 )
-        {
-            message=tr ( "<b>Wrong password!</b><br><br>" ) +
-                    message;
-        }
-
-        QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                QMessageBox::Ok,
-                                QMessageBox::NoButton );
-// 		currentKey=QString::null;
-        setEnabled ( true );
-        passForm->setEnabled ( true );
-        pass->setFocus();
-        pass->selectAll();
-        return;
-    }
-
-    passForm->hide();
-    setUsersEnabled ( false );
-    uname->setEnabled ( false );
-    u->setEnabled ( false );
-    QStringList servers=output.trimmed().split ( '\n' );
-    for ( int i=0;i<servers.size();++i )
-    {
-        QStringList lst=servers[i].simplified().split ( ' ' );
-        if ( lst.size() >1 )
-        {
-            for ( int j=0;j<x2goServers.size();++j )
-                if ( x2goServers[j].name==lst[0] )
-                {
-                    x2goServers[j].sess=
-                        lst[1].toInt() *
-                        x2goServers[j].factor;
-                    x2goDebug<<x2goServers[j].name<<
-                    ": sessions "<<
-                    lst[1].toInt() <<
-                    ", multiplied "<<x2goServers[j].sess;
-                    break;
-                }
-        }
-    }
-
-    qSort ( x2goServers.begin(),x2goServers.end(),serv::lt );
-
-    listedSessions.clear();
-    retSessions=0;
-    if (sshConnection)
-        sshConnection->disconnectSession();
-    QString passwd;
-    QString user=getCurrentUname();
-    passwd=getCurrentPass();
-    for (int i=0; i< serverSshConnections.count();++i)
-    {
-        if (serverSshConnections[i])
-            serverSshConnections[i]->disconnectSession();
-    }
-    serverSshConnections.clear();
-    for ( int j=0;j<x2goServers.size();++j )
-    {
-        QString host=x2goServers[j].name;
-        sshPort=x2goServers[j].sshPort;
-        serverSshConnections<<startSshConnection ( host,sshPort,acceptRsa,user,passwd,true,false,true);
-    }
-}
-
-
-void ONMainWindow::slotListAllSessions ( bool result,QString output,
-        SshProcess* proc )
-{
-    bool last=false;
-
-    ++retSessions;
-    if ( retSessions == x2goServers.size() )
-        last=true;
-    if ( proc )
-        delete proc;
-    proc=0;
-
-    if ( result==false )
-    {
-        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
-        if ( message.indexOf ( "publickey,password" ) !=-1 )
-        {
-            message=tr ( "<b>Wrong password!</b><br><br>" ) +
-                    message;
-        }
-
-        QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                QMessageBox::Ok,
-                                QMessageBox::NoButton );
-        QString sv=output.split ( ":" ) [0];
-        for ( int j=0;j<x2goServers.size();++j )
-        {
-            if ( x2goServers[j].name==sv )
-            {
-                x2goServers[j].connOk=false;
-            }
-        }
-    }
-    else
-    {
-        listedSessions+=output.trimmed().split ( '\n',
-                        QString::SkipEmptyParts );
-    }
-    if ( last )
-    {
-        if ( listedSessions.size() ==0||
-                ( listedSessions.size() ==1 &&
-                  listedSessions[0].length() <5 ) )
-        {
-// 	x2goDebug<<"start New Session";
-            startNewSession();
-        }
-        else if ( listedSessions.size() ==1 )
-        {
-// 	x2goDebug<<"have one session";
-            x2goSession s=getSessionFromString (
-                              listedSessions[0] );
-// 		x2goDebug<<"will procceed one session";
-            QDesktopWidget wd;
-            if ( s.status=="S" && isColorDepthOk (
-                        wd.depth(),s.colorDepth ) )
-                resumeSession ( s );
-            else
-            {
-// 				x2goDebug<<"select one Session";
-                selectSession ( listedSessions );
-            }
-        }
-        else
-        {
-            selectSession ( listedSessions );
-        }
-    }
-}
-
-void ONMainWindow::slotResize()
-{
-    if ( startHidden )
-    {
-        hide();
-        return;
-    }
-    if ( !startMaximized && !mwMax )
-    {
-        resize ( mwSize );
-        move ( mwPos );
-        show();
-    }
-    else
-        showMaximized();
-}
-
-void ONMainWindow::slotExportDirectory()
-{
-    if ( shadowSession )
-        return;
-
-    bool hide_after=false;
-    if (isHidden())
-    {
-        showNormal();
-        hide_after=true;
-    }
-    QString path;
-    if ( !useLdap && !embedMode )
-    {
-        ExportDialog dlg ( lastSession->id(),this );
-        if ( dlg.exec() ==QDialog::Accepted )
-            path=dlg.getExport();
-    }
-    else
-
-        path= QFileDialog::getExistingDirectory (
-                  this,QString::null,
-                  homeDir );
-    if (hide_after)
-        hide();
-#ifdef Q_OS_WIN
-    if ( ONMainWindow::getPortable() &&
-            ONMainWindow::U3DevicePath().length() >0 )
-    {
-        path.replace ( "(U3)",u3Device );
-    }
-
-    path=cygwinPath ( wapiShortFileName ( path ) );
-#endif
-    if ( path!=QString::null )
-        exportDirs ( path );
-}
-
-
-void ONMainWindow::exportDirs ( QString exports,bool removable )
-{
-    if ( shadowSession )
-        return;
-    if ( embedMode )
-    {
-        if ( config.confFS  && ! ( config.useFs ) )
-        {
-            return;
-        }
-    }
-    fsExportKeyReady=false;
-    directory dr;
-
-
-    dr.dirList=exports;
-    dr.key=createRSAKey();
-    QString passwd;
-    x2goDebug<<"key created on: "<<dr.key;
-
-    passwd=getCurrentPass();
-
-    fsInTun=false;
-    if ( !useLdap )
-    {
-        if ( !embedMode )
-        {
-            X2goSettings st ( "sessions" );
-
-            QString sid=lastSession->id();
-
-            fsInTun=st.setting()->value ( sid+"/fstunnel",
-                                          ( QVariant ) true ).toBool();
-        }
-        else
-            fsInTun=true;
-    }
-    if ( fsInTun )
-    {
-        if ( fsTunnel==0l )
-            if ( startSshFsTunnel() )
-                return;
-    }
-    SshProcess* lproc;
-    QString uname=getCurrentUname();
-    lproc=new SshProcess ( sshConnection, this );
-    connect ( lproc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
-              this,SLOT ( slotCopyKey ( bool, QString,SshProcess* ) ) );
-    QString dst=dr.key;
-    QString dhdir=homeDir+"/.x2go";
-#ifdef Q_OS_WIN
-    dhdir=wapiShortFileName ( dhdir );
-#endif
-    dst.replace ( dhdir +"/ssh/gen/","" );
-    dst="~"+uname +"/.x2go/ssh/"+dst;
-    dr.dstKey=dst;
-    dr.isRemovable=removable;
-    exportDir.append ( dr );
-    QString keyFile=dr.key;
-    lproc->start_cp ( keyFile,dst );
-
-}
-
-
-void ONMainWindow::exportDefaultDirs()
-{
-    QStringList dirs;
-    bool clientPrinting= ( useLdap && LDAPPrintSupport );
-
-    if ( !useLdap )
-    {
-        if ( !embedMode )
-        {
-
-            X2goSettings st ( "sessions" );
-            clientPrinting= st.setting()->value (
-                                lastSession->id() +
-                                "/print", true ).toBool();
-
-            QString exd=st.setting()->value (
-                            lastSession->id() +"/export",
-                            ( QVariant ) QString::null ).toString();
-            QStringList lst=exd.split ( ";",
-                                        QString::SkipEmptyParts );
-            for ( int i=0;i<lst.size();++i )
-            {
-#ifndef Q_OS_WIN
-                QStringList tails=lst[i].split (
-                                      ":",
-                                      QString::SkipEmptyParts );
-#else
-
-                QStringList tails=lst[i].split (
-                                      "#",
-                                      QString::SkipEmptyParts );
-#endif
-
-                if ( tails[1]=="1" )
-                {
-#ifdef Q_OS_WIN
-                    if ( ONMainWindow::getPortable() &&
-                            ONMainWindow::U3DevicePath (
-                            ).length() >0 )
-                    {
-                        tails[0].replace (
-                            "(U3)",u3Device );
-                    }
-
-                    tails[0]=cygwinPath (
-                                 wapiShortFileName (
-                                     tails[0] ) );
-#endif
-                    dirs+=tails[0];
-                }
-            }
-        }
-        else
-        {
-            clientPrinting=true;
-            if ( config.confFS )
-            {
-                clientPrinting=config.useFs;
-            }
-        }
-    }
-
-    if ( clientPrinting )
-    {
-        QString path= homeDir +
-                      "/.x2go/S-"+
-                      resumingSession.sessionId +"/spool";
-        QDir spooldir;
-        if ( !spooldir.exists ( path ) )
-        {
-            if ( !spooldir.mkpath ( path ) )
-            {
-                QString message=
-                    tr (
-                        "Unable to create folder:" ) + path;
-                QMessageBox::critical ( 0l,tr (
-                                            "Error" ),message,
-                                        QMessageBox::Ok,
-                                        QMessageBox::NoButton );
-
-            }
-        }
-        spoolDir=path;
-#ifdef Q_OS_WIN
-        path=cygwinPath (
-                 wapiShortFileName (
-                     path ) );
-#endif
-        QFile::setPermissions (
-            path,QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner );
-
-        path+="__PRINT_SPOOL_";
-        dirs+=path;
-        printSupport=true;
-        if ( spoolTimer )
-            delete spoolTimer;
-        spoolTimer=new QTimer ( this );
-        connect ( spoolTimer,SIGNAL ( timeout() ),this,
-                  SLOT ( slotCheckPrintSpool() ) );
-        spoolTimer->start ( 2000 );
-    }
-    if ( dirs.size() <=0 )
-        return;
-    exportDirs ( dirs.join ( ":" ) );
-}
-
-QString ONMainWindow::createRSAKey()
-{
-    QDir dr;
-    QString keyPath=homeDir +"/.x2go/ssh/gen";
-    dr.mkpath ( keyPath );
-#ifdef Q_OS_WIN
-    keyPath=wapiShortFileName ( keyPath );
-#endif
-    QTemporaryFile fl ( keyPath+"/key" );
-    fl.open();
-    QString keyName=fl.fileName();
-    fl.setAutoRemove ( false );
-    fl.close();
-    fl.remove();
-
-    QStringList args;
-
-    args<<"-t"<<"rsa"<<"-b"<<"1024"<<"-N"<<""<<"-f"<<keyName;
-// 	x2goDebug <<keyName<<endl;
-
-    if ( QProcess::execute ( "ssh-keygen",args ) !=0 )
-    {
-        x2goDebug <<"ssh-keygen failed" <<endl;
-        return QString::null;
-    }
-// 	x2goDebug <<"ssh-keygen ok" <<endl;
-
-    QFile rsa ( "/etc/ssh/ssh_host_rsa_key.pub" );
-#ifdef Q_OS_WIN
-    rsa.setFileName (
-        wapiShortFileName (
-            homeDir+"\\.x2go\\etc\\ssh_host_dsa_key.pub" ) );
-#else
-    if ( userSshd )
-        rsa.setFileName ( homeDir+"/.x2go/etc/ssh_host_dsa_key.pub" );
-
-#endif
-
-#ifdef Q_OS_DARWIN
-    rsa.setFileName ( "/etc/ssh_host_rsa_key.pub" );
-#endif
-    if ( !rsa.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-    {
-#ifdef Q_OS_LINUX
-        generateHostDsaKey();
-        generateEtcFiles();
-        startSshd();
-        rsa.setFileName ( homeDir+"/.x2go/etc/ssh_host_dsa_key.pub" );
-        rsa.open ( QIODevice::ReadOnly | QIODevice::Text );
-#else
-        printSshDError();
-        return QString::null;
-#endif
-    }
-
-    QByteArray rsa_pub;
-
-    if ( !rsa.atEnd() )
-        rsa_pub = rsa.readLine();
-    else
-    {
-        x2goDebug<<"error: rsa file empty";
-        return QString::null;
-    }
-
-    QFile file ( keyName );
-    if ( !file.open (
-                QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append )
-       )
-    {
-        x2goDebug<<"error openning key:"<<keyName;
-        return keyName;
-    }
-    QTextStream out ( &file );
-    out<<"----BEGIN RSA IDENTITY----"<<rsa_pub;
-    file.close();
-    return keyName;
-}
-
-void ONMainWindow::slotCopyKey ( bool result, QString output, SshProcess* proc )
-{
-    fsExportKey=proc->getSource();
-    if ( proc )
-        delete proc;
-    proc=0;
-    x2goDebug<<"exported key "<<fsExportKey;
-    QFile::remove ( fsExportKey );
-    x2goDebug<<"key removed";
-    if ( result==false )
-    {
-        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
-        if ( message.indexOf ( "publickey,password" ) !=-1 )
-        {
-            message=tr ( "<b>Wrong password!</b><br><br>" ) +
-                    message;
-        }
-
-        QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                QMessageBox::Ok,
-                                QMessageBox::NoButton );
-        QFile::remove ( fsExportKey+".pub" );
-        return;
-    }
-    fsExportKeyReady=true;
-
-    //start reverse mounting if RSA Key and FS tunnel are ready
-    //start only once from slotFsTunnelOk() or slotCopyKey().
-    if ( !fsInTun || fsTunReady )
-        startX2goMount();
-
-}
-
-directory* ONMainWindow::getExpDir ( QString key )
-{
-    for ( int i=0;i<exportDir.size();++i )
-    {
-        if ( exportDir[i].key==key )
-            return &exportDir[i];
-    }
-    return 0l;
-}
-
-
-
-
-void ONMainWindow::slotRetExportDir ( bool result,QString output,
-                                      SshProcess* proc )
-{
-
-    QString key;
-    for ( int i=0;i<exportDir.size();++i )
-        if ( exportDir[i].proc==proc )
-        {
-            key=exportDir[i].key;
-            exportDir.removeAt ( i );
-            break;
-        }
-
-    if ( proc )
-        delete proc;
-
-    if ( result==false )
-    {
-        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
-        if ( message.indexOf ( "publickey,password" ) !=-1 )
-        {
-            message=tr ( "<b>Wrong password!</b><br><br>" ) +
-                    message;
-        }
-
-        QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                QMessageBox::Ok,
-                                QMessageBox::NoButton );
-    }
-    QFile file ( key+".pub" );
-    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-    {
-        printSshDError();
-        QFile::remove
-        ( key+".pub" );
-        return;
-    }
-
-    QByteArray line = file.readLine();
-    file.close();
-    QString authofname=homeDir;
-#ifdef Q_OS_WIN
-    QDir dir;
-    dir.mkpath ( authofname+"\\.x2go\\.ssh" );
-    x2goDebug<<"Creating "<<authofname+"\\.x2go\\.ssh"<<endl;
-    authofname=wapiShortFileName ( authofname ) +"/.x2go";
-#endif
-    authofname+="/.ssh/authorized_keys" ;
-    file.setFileName ( authofname );
-    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-    {
-        printSshDError();
-        QFile::remove
-        ( key+".pub" );
-        return;
-    }
-
-
-    QTemporaryFile tfile ( authofname );
-    tfile.open();
-    tfile.setAutoRemove ( true );
-    QTextStream out ( &tfile );
-
-    while ( !file.atEnd() )
-    {
-        QByteArray newline = file.readLine();
-        if ( newline!=line )
-            out<<newline;
-    }
-    file.close();
-    tfile.close();
-    file.remove();
-    tfile.copy ( authofname );
-    QFile::remove
-    ( key+".pub" );
-}
-
-
-
-void ONMainWindow::exportsEdit ( SessionButton* bt )
-{
-    EditConnectionDialog dlg ( bt->id(),this,3 );
-    if ( dlg.exec() ==QDialog::Accepted )
-    {
-        bt->redraw();
-        bool vis=bt->isVisible();
-        placeButtons();
-        users->ensureVisible ( bt->x(),bt->y(),50,220 );
-        bt->setVisible ( vis );
-    }
-}
-
-
-void ONMainWindow::slotExtTimer()
-{
-
-    if ( QFile::permissions ( readLoginsFrom ) !=
-            ( QFile::ReadUser|QFile::WriteUser|QFile::ExeUser|
-              QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner ) )
-    {
-        x2goDebug <<"Wrong permissions on "<<readLoginsFrom <<":"<<endl;
-        x2goDebug << ( int ) ( QFile::permissions (
-                                   readLoginsFrom+"/." ) )
-        <<"must be"<< ( int ) ( QFile::ReadUser|QFile::WriteUser
-                                |QFile::ExeUser|QFile::ReadOwner|
-                                QFile::WriteOwner|
-                                QFile::ExeOwner ) <<endl;
-        if ( extLogin )
-            extTimer->stop();
-        return;
-    }
-    QString loginDir;
-    QString logoutDir;
-    QDir dir ( readLoginsFrom );
-    QStringList list = dir.entryList ( QDir::Files );
-    for ( int i=0;i<list.size();++i )
-    {
-        QFile file ( readLoginsFrom+"/"+list[i] );
-        if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-            continue;
-        if ( !file.atEnd() )
-        {
-            QByteArray line = file.readLine();
-            QString ln ( line );
-            QStringList args=ln.split ( "=",
-                                        QString::SkipEmptyParts );
-            if ( args.size() >1 )
-            {
-                if ( args[0]=="login" )
-                {
-                    args[1].replace ( "\n","" );
-                    if ( args[1].size() )
-                        loginDir=args[1];
-                }
-                if ( args[0]=="logout" )
-                {
-                    x2goDebug <<
-                    " I HAVE external logout"<<
-                    endl;
-                    args[1].replace ( "\n","" );
-                    if ( args[1].size() )
-                        logoutDir=args[1];
-                }
-            }
-        }
-        file.close();
-        file.remove();
-    }
-    if ( exportTimer->isActive() ) //running session
-    {
-        if ( logoutDir != QString::null )
-        {
-            x2goDebug <<"external logout"<<endl;
-            externalLogout ( logoutDir );
-        }
-    }
-    else
-    {
-        if ( loginDir != QString::null )
-        {
-            x2goDebug <<"external login"<<endl;
-            externalLogin ( loginDir );
-        }
-    }
-}
-
-
-void ONMainWindow::slotExportTimer()
-{
-
-    if ( QFile::permissions ( readExportsFrom ) != ( QFile::ReadUser|
-            QFile::WriteUser|
-            QFile::ExeUser|
-            QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner ) )
-    {
-        x2goDebug <<"Wrong permissions on "<<
-        readExportsFrom <<":"<<endl;
-        x2goDebug << ( int ) ( QFile::permissions (
-                                   readExportsFrom+"/." ) )
-        <<"must be"<< ( int ) ( QFile::ReadUser|QFile::WriteUser
-                                |QFile::ExeUser|QFile::ReadOwner|
-                                QFile::WriteOwner|
-                                QFile::ExeOwner ) <<endl;
-        exportTimer->stop();
-        return;
-    }
-
-    QDir dir ( readExportsFrom );
-    QStringList list = dir.entryList ( QDir::Files );
-    QString expList;
-    QString unexpList;
-    QString loginDir;
-    QString logoutDir;
-    for ( int i=0;i<list.size();++i )
-    {
-        QFile file ( readExportsFrom+"/"+list[i] );
-        if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-            continue;
-        if ( !file.atEnd() )
-        {
-            QByteArray line = file.readLine();
-            QString ln ( line );
-            QStringList args=ln.split ( "=",
-                                        QString::SkipEmptyParts );
-            if ( args.size() >1 )
-            {
-                if ( args[0]=="export" )
-                {
-                    args[1].replace ( "\n","" );
-                    if ( args[1].size() )
-                        expList+=":"+args[1];
-                }
-                if ( args[0]=="unexport" )
-                {
-                    args[1].replace ( "\n","" );
-                    if ( args[1].size() )
-                        unexpList+=":"+args[1];
-                }
-            }
-        }
-        file.close();
-        file.remove();
-    }
-    QStringList args=expList.split ( ":",QString::SkipEmptyParts );
-    expList=args.join ( ":" );
-    if ( expList.size() >0 )
-    {
-        exportDirs ( expList,true );
-    }
-    args.clear();
-    args=unexpList.split ( ":",QString::SkipEmptyParts );
-
-    QString passwd=getCurrentPass();
-    QString user=getCurrentUname();
-    QString host=resumingSession.server;
-    QString sessionId=resumingSession.sessionId;
-
-    for ( int i=0;i<args.size();++i )
-    {
-        SshProcess* sproc=new SshProcess (
-            sshConnection, this );
-        sproc->startNormal ( "export HOSTNAME && x2goumount_session "+
-                             sessionId+" "+args[i] );
-    }
-}
-
-void ONMainWindow::slotAboutQt()
-{
-    QMessageBox::aboutQt ( this );
-}
-
-void ONMainWindow::slotSupport()
-{
-    QFile file(supportMenuFile);
-    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
-        return;
-
-    QTextStream in(&file);
-    QString sup;
-    while (!in.atEnd())
-    {
-        sup+=in.readLine();
-    }
-    QMessageBox::information (this,tr ( "Support" ),sup);
-}
-
-void ONMainWindow::slotAbout()
-{
-    QString aboutStr=tr (
-                         "</b><br> (C. 2006-2012 <b>obviously nice</b>: "
-                         "Oleksandr Shneyder, Heinz-Markus Graesing)<br>" );
-    if ( embedMode )
-        aboutStr+=tr ( "<br>x2goplugin mode was sponsored by "
-                       "<a href=\"http://www.foss-group.de/\">"
-                       "FOSS-Group GmbH(Freiburg)</a><br>" );
-    aboutStr+=
-        tr (
-            "<br>Client for use with the X2Go network based "
-            "computing environment. This Client will be able "
-            "to connect to X2Go server(s) and start, stop, "
-            "resume and terminate (running) desktop sessions. "
-            "X2Go Client stores different server connections "
-            "and may automatically request authentification "
-            "data from LDAP directories. Furthermore it can be "
-            "used as fullscreen loginscreen (replacement for "
-            "loginmanager like xdm). Please visit x2go.org for "
-            "further information." );
-    QMessageBox::about (
-        this,tr ( "About X2GO client" ),
-        tr ( "<b>X2Go client V. " ) +VERSION+
-        " </b >(Qt - "+qVersion() +")"+
-        aboutStr );
-}
-
-
-
-void ONMainWindow::slotRereadUsers()
-{
-    if ( !useLdap )
-        return;
-#ifdef USELDAP
-
-    if ( ld )
-    {
-        delete ld;
-        ld=0;
-    }
-
-
-    if ( ! initLdapSession ( false ) )
-    {
-        return;
-    }
-
-
-    list<string> attr;
-    attr.push_back ( "uidNumber" );
-    attr.push_back ( "uid" );
-
-
-    list<LDAPBinEntry> result;
-    try
-    {
-        ld->binSearch ( ldapDn.toStdString(),attr,
-                        "objectClass=posixAccount",result );
-    }
-    catch ( LDAPExeption e )
-    {
-        QString message="Exeption in: ";
-        message=message+e.err_type.c_str();
-        message=message+" : "+e.err_str.c_str();
-        QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                QMessageBox::Ok,QMessageBox::NoButton );
-        QMessageBox::critical ( 0l,tr ( "Error" ),
-                                tr ( "Please check LDAP Settings" ),
-                                QMessageBox::Ok,QMessageBox::NoButton );
-        slotConfig();
-        return;
-    }
-
-    list<LDAPBinEntry>::iterator it=result.begin();
-    list<LDAPBinEntry>::iterator end=result.end();
-
-    for ( ;it!=end;++it )
-    {
-        user u;
-        QString uin=LDAPSession::getBinAttrValues (
-                        *it,"uidNumber" ).front().getData();
-        u.uin=uin.toUInt();
-        if ( u.uin<firstUid || u.uin>lastUid )
-        {
-            continue;
-        }
-        u.uid=LDAPSession::getBinAttrValues (
-                  *it,"uid" ).front().getData();
-        if ( !findInList ( u.uid ) )
-        {
-            reloadUsers();
-            return;
-        }
-    }
-#endif
-}
-
-void ONMainWindow::reloadUsers()
-{
-    int i;
-    for ( i=0;i<names.size();++i )
-        names[i]->close();
-    for ( i=0;i<sessions.size();++i )
-        sessions[i]->close();
-
-    userList.clear();
-    sessions.clear();
-
-
-    loadSettings();
-    if ( useLdap )
-    {
-        act_new->setEnabled ( false );
-        act_edit->setEnabled ( false );
-        u->setText ( tr ( "Login:" ) );
-        QTimer::singleShot ( 1, this, SLOT ( readUsers() ) );
-    }
-    else
-    {
-        act_new->setEnabled ( true );
-        act_edit->setEnabled ( true );
-        u->setText ( tr ( "Session:" ) );
-        QTimer::singleShot ( 1, this, SLOT ( slotReadSessions() ) );
-    }
-    slotResize ( fr->size() );
-}
-
-
-bool ONMainWindow::findInList ( const QString& uid )
-{
-    for ( int i=0;i<userList.size();++i )
-    {
-        if ( userList[i].uid==uid )
-            return true;
-    }
-    return false;
-}
-
-void ONMainWindow::setUsersEnabled ( bool enable )
-{
-
-    if ( useLdap )
-    {
-        QScrollBar* bar=users->verticalScrollBar();
-        bar->setEnabled ( enable );
-        int upos=bar->value();
-        QDesktopWidget dw;
-        int height=dw.screenGeometry ( fr ).height();
-        QList<UserButton*>::iterator it;
-        QList<UserButton*>::iterator endit=names.end();
-        if ( !enable )
-        {
-            for ( it=names.begin();it!=endit;it++ )
-            {
-                QPoint pos= ( *it )->pos();
-                if ( ( pos.y() >upos-height ) &&
-                        ( pos.y() <upos+height ) )
-                    ( *it )->setEnabled ( false );
-                if ( pos.y() >upos+height )
-                    break;
-            }
-        }
-        else
-        {
-            for ( it=names.begin();it!=endit;it++ )
-            {
-                if ( ! ( *it )->isEnabled() )
-                    ( *it )->setEnabled ( true );
-            }
-        }
-    }
-    else
-        users->setEnabled ( enable );
-}
-
-
-void ONMainWindow::externalLogin ( const QString& loginDir )
-{
-    QFile file ( loginDir+"/username" );
-    QString user;
-
-    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-        return;
-    QTextStream in ( &file );
-    while ( !in.atEnd() )
-    {
-        user=in.readLine();
-        break;
-    }
-    file.close();
-
-
-    if ( passForm->isVisible() )
-        slotClosePass();
-    uname->setText ( user );
-    slotUnameEntered();
-    currentKey=loginDir+"/dsa.key";
-    extStarted=true;
-    slotPassEnter();
-}
-
-
-void ONMainWindow::externalLogout ( const QString& )
-{
-    if ( extStarted )
-    {
-        extStarted=false;
-        currentKey=QString::null;
-        if ( nxproxy )
-            if ( nxproxy->state() ==QProcess::Running )
-                nxproxy->terminate();
-    }
-}
-
-
-void ONMainWindow::slotStartPGPAuth()
-{
-    scDaemon=new QProcess ( this );
-    QStringList arguments;
-    arguments<<"--multi-server";
-    connect ( scDaemon,SIGNAL ( readyReadStandardError() ),this,
-              SLOT ( slotScDaemonError() ) );
-    connect ( scDaemon,SIGNAL ( readyReadStandardOutput() ),this,
-              SLOT ( slotScDaemonOut() ) );
-    connect ( scDaemon,SIGNAL ( finished ( int,QProcess::ExitStatus ) ),
-              this,
-              SLOT (
-                  slotScDaemonFinished ( int, QProcess::ExitStatus ) ) );
-    scDaemon->start ( "scdaemon",arguments );
-    QTimer::singleShot ( 3000, this, SLOT ( slotCheckScDaemon() ) );
-    isScDaemonOk=false;
-}
-
-void ONMainWindow::slotCheckScDaemon()
-{
-    if ( !isScDaemonOk )
-    {
-        scDaemon->kill();
-    }
-}
-
-void ONMainWindow::slotScDaemonError()
-{
-    QString stdOut ( scDaemon->readAllStandardError() );
-    stdOut=stdOut.simplified();
-    x2goDebug<<"SCDAEMON err:"<<stdOut<<endl;
-    if ( stdOut.indexOf ( "updating slot" ) !=-1 ||
-            stdOut.indexOf ( "updating status of slot" ) !=-1 )
-    {
-        isScDaemonOk=true;
-        //USABLE or PRESENT
-        if ( ( stdOut.indexOf ( "0x0002" ) !=-1 ) ||
-                ( stdOut.indexOf ( "0x0007" ) !=-1 ) )
-        {
-            scDaemon->kill();
-        }
-    }
-}
-
-void ONMainWindow::slotScDaemonOut()
-{
-    QString stdOut ( scDaemon->readAllStandardOutput() );
-    stdOut=stdOut.simplified();
-    x2goDebug<<"SCDAEMON out:"<<stdOut<<endl;
-}
-
-void ONMainWindow::slotScDaemonFinished ( int , QProcess::ExitStatus )
-{
-    scDaemon=0l;
-    if ( isScDaemonOk )
-    {
-        x2goDebug<<"scDaemon finished"<<endl;
-        gpg=new QProcess ( this );
-        QStringList arguments;
-        arguments<<"--card-status";
-        connect ( gpg,SIGNAL ( readyReadStandardError() ),
-                  this,SLOT ( slotGpgError() ) );
-        connect ( gpg,SIGNAL ( finished ( int,
-                                          QProcess::ExitStatus ) ),this,
-                  SLOT ( slotGpgFinished ( int,
-                                           QProcess::ExitStatus ) ) );
-        gpg->start ( "gpg",arguments );
-    }
-    else
-        slotStartPGPAuth();
-}
-
-
-
-void ONMainWindow::slotGpgError()
-{
-    QString stdOut ( gpg->readAllStandardError() );
-    stdOut=stdOut.simplified();
-    x2goDebug<<"GPG err:"<<stdOut<<endl;
-    if ( stdOut.indexOf ( "failed" ) !=-1 )
-    {
-        QMessageBox::critical ( 0l,tr ( "Error" ),
-                                tr ( "No valid card found" ),
-                                QMessageBox::Ok,
-                                QMessageBox::NoButton );
-        gpg->kill();
-    }
-}
-
-
-void ONMainWindow::slotGpgFinished ( int exitCode,
-                                     QProcess::ExitStatus exitStatus )
-{
-    x2goDebug<<"gpg finished, exit code:"<<exitCode<<" exit status:"<<
-    exitStatus<<endl;
-    if ( exitStatus==0 )
-    {
-        QString stdOut ( gpg->readAllStandardOutput() );
-        stdOut.chop ( 1 );
-        x2goDebug<<"GPG out:"<<stdOut<<endl;
-        QStringList lines=stdOut.split ( "\n" );
-        QString login;
-        QString appId;
-        QString authKey;
-        for ( int i=0;i<lines.count();++i )
-        {
-            if ( lines[i].indexOf ( "Application ID" ) !=-1 )
-            {
-                appId=lines[i].split ( ":" ) [1];
-            }
-            else if ( lines[i].indexOf ( "Login data" ) !=-1 )
-            {
-                login=lines[i].split ( ":" ) [1];
-            }
-            else if ( lines[i].indexOf (
-                          "Authentication key" ) !=-1 )
-            {
-                authKey=lines[i].split ( ":" ) [1];
-                break;
-            }
-        }
-        appId=appId.simplified();
-        login=login.simplified();
-        authKey=authKey.simplified();
-        x2goDebug<<"card data: "<<appId<<login<<authKey<<endl;
-        if ( login=="[not set]" || authKey == "[none]" )
-        {
-            x2goDebug<<"Card not configured\n";
-            QMessageBox::critical (
-                0l,tr ( "Error" ),
-                tr (
-                    "This card is unknown by X2Go system" ),
-                QMessageBox::Ok,
-                QMessageBox::NoButton );
-            QTimer::singleShot ( 1000, this,
-                                 SLOT ( slotStartPGPAuth() ) );
-        }
-        else
-            startGPGAgent ( login,appId );
-    }
-    else
-        QTimer::singleShot ( 1000, this, SLOT ( slotStartPGPAuth() ) );
-    gpg=0l;
-}
-
-
-
-void ONMainWindow::startGPGAgent ( const QString& login, const QString& appId )
-{
-    QString gpgPath=homeDir +"/.x2goclient/gnupg";
-    QDir d;
-    cardLogin=login;
-    d.mkpath ( gpgPath );
-    QFile file ( gpgPath+"/scd-event" );
-    if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
-    {
-        QMessageBox::critical (
-            0l,tr ( "Error" ),
-            tr (
-                "Unable to create file: " ) +
-            gpgPath+"/scd-event"
-            ,QMessageBox::Ok,
-            QMessageBox::NoButton );
-        exit ( -1 );
-    }
-    QTextStream out ( &file );
-    out << "#!/bin/bash\n\n"
-    "if [ \"$6\" != \"0x0002\" ] && [ \"$6\" != "
-    "\"0x0007\" ]\n\
-	then\n\
-	kill -9 $_assuan_pipe_connect_pid\n\
-	fi"<<endl;
-    file.close();
-    file.setPermissions ( gpgPath+"/scd-event",
-                          QFile::ReadOwner|
-                          QFile::WriteOwner|
-                          QFile::ExeOwner );
-
-    gpgAgent=new QProcess ( this );
-    QStringList arguments;
-    arguments<<"--pinentry-program"<<"/usr/bin/pinentry-x2go"<<
-    "--enable-ssh-support"<<"--daemon"<<"--no-detach";
-
-    connect ( gpgAgent,SIGNAL ( finished ( int,QProcess::ExitStatus ) ),
-              this,
-              SLOT ( slotGpgAgentFinished ( int,
-                                            QProcess::ExitStatus ) ) );
-
-    QStringList env=QProcess::systemEnvironment();
-    env<<"GNUPGHOME="+gpgPath<<"CARDAPPID="+appId;
-    gpgAgent->setEnvironment ( env );
-    gpgAgent->start ( "gpg-agent",arguments );
-}
-
-void ONMainWindow::slotGpgAgentFinished ( int , QProcess::ExitStatus )
-{
-    QString stdOut ( gpgAgent->readAllStandardOutput() );
-    stdOut=stdOut.simplified();
-    stdOut.replace ( " ","" );
-    QStringList envLst=stdOut.split ( ";" );
-    QString gpg_agent_info=envLst[0].split ( "=" ) [1];
-    QString ssh_auth_sock=envLst[2].split ( "=" ) [1];
-    agentPid=envLst[4].split ( "=" ) [1];
-    x2goDebug<<gpg_agent_info<<ssh_auth_sock<<agentPid<<endl;
-    x2goDebug<<"GPGAGENT out:"<<envLst[0]<<envLst[2]<<envLst[4]<<endl;
-
-    agentCheckTimer->start ( 1000 );
-    cardReady=true;
-
-    sshEnv.clear();
-    sshEnv<<envLst[0]<<envLst[2]<<envLst[4];
-// 	x2goDebug<<"sshenv:"<<sshEnv<<endl;
-
-    if ( !useLdap )
-    {
-        if ( passForm->isVisible() && !brokerMode)
-        {
-            if ( passForm->isEnabled() )
-            {
-                if ( login->isEnabled() )
-                {
-                    login->setText ( cardLogin );
-                    slotSessEnter();
-                    return;
-                }
-            }
-        }
-        QProcess sshadd ( this ); //using it to start scdaemon
-        sshadd.setEnvironment ( sshEnv );
-        QStringList arguments;
-        arguments<<"-l";
-        sshadd.start ( "ssh-add",arguments );
-        sshadd.waitForFinished ( -1 );
-        QString sshout ( sshadd.readAllStandardOutput() );
-        sshout=sshout.simplified();
-        x2goDebug<<"SSH-ADD out:"<<sshout<<endl;
-    }
-    else
-    {
-        if ( selectSessionDlg->isVisible() ||
-                sessionStatusDlg->isVisible() )
-        {
-            QProcess sshadd ( this ); //using it to start scdaemon
-            sshadd.setEnvironment ( sshEnv );
-            QStringList arguments;
-            arguments<<"-l";
-            sshadd.start ( "ssh-add",arguments );
-            sshadd.waitForFinished ( -1 );
-            QString sshout ( sshadd.readAllStandardOutput() );
-            sshout=sshout.simplified();
-            x2goDebug<<"SSH-ADD out:"<<sshout<<endl;
-            return;
-        }
-        if ( passForm->isVisible() )
-            slotClosePass();
-        uname->setText ( cardLogin );
-        slotUnameEntered();
-        slotPassEnter();
-    }
-}
-
-
-void ONMainWindow::slotCheckAgentProcess()
-{
-    if ( checkAgentProcess() )
-        return;
-    agentCheckTimer->stop();
-    cardReady=false;
-    if ( cardStarted )
-    {
-        cardStarted=false;
-        if ( nxproxy )
-            if ( nxproxy->state() ==QProcess::Running )
-            {
-                x2goDebug<<"Suspending session\n";
-                slotSuspendSessFromSt();
-//                 nxproxy->terminate();
-            }
-    }
-
-    x2goDebug<<"gpg-agent finished\n";
-    slotStartPGPAuth();
-}
-
-bool ONMainWindow::checkAgentProcess()
-{
-    QFile file ( "/proc/"+agentPid+"/cmdline" );
-    if ( file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-    {
-        QString line ( file.readLine() );
-        file.close();
-        if ( line.indexOf ( "gpg-agent" ) !=-1 )
-        {
-            return true;
-        }
-    }
-    return false;
-}
-
-#if defined ( Q_OS_DARWIN )
-QString ONMainWindow::getXDisplay()
-{
-    QLocalSocket unixSocket (this);
-    QString xsocket (getenv ("DISPLAY"));
-
-    // OS X starts the X11 server automatically, as soon as the launchd UNIX socket
-    // is accessed.
-    // On user login, the DISPLAY environment variable is set to this said existing
-    // socket.
-    // By now, we should have a socket. Test, if connecting works.
-    if ((!xsocket.isEmpty ()))
-    {
-        unixSocket.connectToServer (xsocket);
-
-        if (unixSocket.waitForConnected (10000))
-        {
-            unixSocket.disconnectFromServer ();
-            return (xsocket);
-        }
-    }
-    // And if not, error out.
-    QMessageBox::critical (
-        this,tr ( "Can't connect to X server\nPlease check your settings" ),
-        tr (
-            "Can't start X server\nPlease check your settings" ) );
-    slotConfig();
-    return QString::null;
-}
-#endif
-
-#ifdef Q_OS_WIN
-QString ONMainWindow::getXDisplay()
-{
-    if ( !isServerRunning ( 6000+xDisplay ) )
-    {
-        QMessageBox::critical (
-            this,QString::null,
-            tr (
-                "Can't start X Server\nPlease check your installation" )
-        );
-        close();
-    }
-    return QString::number ( xDisplay );
-
-}
-
-QString ONMainWindow::cygwinPath ( const QString& winPath )
-{
-    QString cPath="/cygdrive/"+winPath;
-    cPath.replace ( "\\","/" );
-    cPath.replace ( ":","" );
-    return cPath;
-}
-#endif
-
-bool ONMainWindow::isColorDepthOk ( int disp, int sess )
-{
-    if ( sess==0 )
-        return true;
-    if ( disp==sess )
-        return true;
-    if ( ( disp == 24 || disp == 32 ) && ( sess == 24 || sess == 32 ) )
-        return true;
-    return false;
-}
-
-#ifndef Q_OS_LINUX
-void ONMainWindow::setWidgetStyle ( QWidget* widget )
-{
-    widget->setStyle ( widgetExtraStyle );
-}
-#else
-void ONMainWindow::setWidgetStyle ( QWidget* )
-{
-}
-#endif
-
-QString ONMainWindow::internAppName ( const QString& transAppName, bool* found )
-{
-    if ( found )
-        *found=false;
-    int ind=_transApplicationsNames.indexOf ( transAppName );
-    if ( ind!=-1 )
-    {
-        if ( found )
-            *found=true;
-        return _internApplicationsNames[ind];
-    }
-    return transAppName;
-}
-
-
-QString ONMainWindow::transAppName ( const QString& internAppName, bool* found )
-{
-    if ( found )
-        *found=false;
-    int ind=_internApplicationsNames.indexOf ( internAppName );
-    if ( ind!=-1 )
-    {
-        if ( found )
-            *found=true;
-        return _transApplicationsNames[ind];
-    }
-    return internAppName;
-}
-
-void ONMainWindow::addToAppNames ( QString intName, QString transName )
-{
-    _internApplicationsNames.append ( intName );
-    _transApplicationsNames.append ( transName );
-}
-
-
-void ONMainWindow::slotExecXmodmap()
-{
-#ifdef Q_WS_HILDON
-    QString passwd=getCurrentPass();
-    QString user=getCurrentUname();
-    QString host=resumingSession.server;
-    QString cmd;
-
-    cmd="(xmodmap -pke ;"
-        "echo keycode 73= ;"
-// 	    "echo clear shift ;"
-// 	    "echo clear lock ;"
-// 	    "echo clear control ;"
-// 	    "echo clear mod1 ;"
-// 	    "echo clear mod2 ;"
-// 	    "echo clear mod3 ;"
-// 	    "echo clear mod4 ;"
-// 	    "echo clear mod5 ;"
-//  	    "echo add shift = Shift_L ;"
-        "echo add control = Control_R "
-//  	    "echo add mod5 = ISO_Level3_Shift"
-        ")| DISPLAY=:"
-        +resumingSession.display+" xmodmap - ";
-    x2goDebug<<"cmd:"<<cmd;
-    SshProcess* xmodProc;
-    try
-    {
-        xmodProc=new SshProcess ( this,user,host,sshPort,
-                                  cmd,
-                                  passwd,currentKey,acceptRsa );
-    }
-    catch ( QString message )
-    {
-        return;
-    }
-
-    if ( cardReady /*|| useSshAgent*/ )
-    {
-        QStringList env=xmodProc->environment();
-        env+=sshEnv;
-        xmodProc->setEnvironment ( env );
-    }
-    xmodProc->setFwX ( true );
-    xmodProc->startNormal();
-#endif
-}
-
-void ONMainWindow::check_cmd_status()
-{
-    QString passwd;
-    QString user=getCurrentUname();
-    QString host=resumingSession.server;
-    passwd=getCurrentPass();
-
-    x2goDebug<<"check command message"<<endl;
-    SshProcess* proc;
-    proc=new SshProcess ( sshConnection, this );
-    connect ( proc,SIGNAL ( sshFinished ( bool,QString,SshProcess* ) ),
-              this,SLOT ( slotCmdMessage ( bool, QString,SshProcess* ) ) );
-
-    proc->startNormal ( "x2gocmdexitmessage "+
-                        resumingSession.sessionId );
-}
-
-void ONMainWindow::slotCmdMessage ( bool result,QString output,
-                                    SshProcess* proc )
-{
-    if ( proc )
-        delete proc;
-    if ( result==false )
-    {
-        cardReady=false;
-        cardStarted=false;
-        QString message=tr ( "<b>Connection failed</b>\n" ) +output;
-        if ( message.indexOf ( "publickey,password" ) !=-1 )
-        {
-            message=tr ( "<b>Wrong password!</b><br><br>" ) +
-                    message;
-        }
-
-        QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                QMessageBox::Ok,
-                                QMessageBox::NoButton );
-// 		currentKey=QString::null;
-        setEnabled ( true );
-        passForm->setEnabled ( true );
-        pass->setFocus();
-        pass->selectAll();
-        sshConnection->disconnectSession();
-        return;
-    }
-    if ( output.indexOf ( "X2GORUNCOMMAND ERR NOEXEC:" ) !=-1 )
-    {
-        QString cmd=output;
-        cmd.replace ( "X2GORUNCOMMAND ERR NOEXEC:","" );
-        QMessageBox::critical ( 0l,tr ( "Error" ),
-                                tr ( "Unable to execute: " ) +
-                                cmd,QMessageBox::Ok,
-                                QMessageBox::NoButton );
-    }
-    sshConnection->disconnectSession();
-}
-
-
-int ONMainWindow::startSshFsTunnel()
-{
-    fsTunReady=false;
-    x2goDebug<<"starting fs tunnel for:"<<resumingSession.sessionId<<
-    "\nfs port: "<<resumingSession.fsPort;
-
-    if ( resumingSession.fsPort.length() <=0 )
-    {
-        QString message=tr (
-                            "Remote server does not "
-                            "support file system export "
-                            "through SSH Tunnel\n"
-                            "Please update to a newer "
-                            "x2goserver package" );
-        slotFsTunnelFailed ( false,message,0 );
-        return 1;
-    }
-    QString passwd=getCurrentPass();
-    QString uname=getCurrentUname();
-
-    fsTunnel=new SshProcess ( sshConnection, this );
-
-    connect ( fsTunnel,SIGNAL ( sshFinished ( bool,
-                                QString,SshProcess* ) ),
-              this,SLOT ( slotFsTunnelFailed ( bool,
-                                               QString,SshProcess* ) ) );
-
-    connect ( fsTunnel,SIGNAL ( sshTunnelOk() ),
-              this,SLOT ( slotFsTunnelOk() ) );
-
-    fsTunnel->startTunnel ( "localhost",resumingSession.fsPort.toUInt(),"127.0.0.1",
-                            clientSshPort.toInt(), true );
-    return 0;
-}
-
-void ONMainWindow::slotFsTunnelFailed ( bool result,  QString output,
-                                        SshProcess* )
-{
-    if ( result==false )
-    {
-        if ( !managedMode )
-        {
-
-            QString message=tr ( "Unable to create SSL tunnel:\n" )
-                            +output;
-            QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                    QMessageBox::Ok,
-                                    QMessageBox::NoButton );
-        }
-        if ( fsTunnel )
-            delete fsTunnel;
-        fsTunnel=0l;
-        fsTunReady=false;
-    }
-}
-
-
-void ONMainWindow::slotFsTunnelOk()
-{
-    fsTunReady=true;
-    //start reverse mounting if RSA Key and FS tunnel are ready
-    //start only once from slotFsTunnelOk() or slotCopyKey().
-    if ( fsExportKeyReady )
-        startX2goMount();
-}
-
diff --git a/onmainwindow_part4.cpp b/onmainwindow_part4.cpp
deleted file mode 100644
index 731937a..0000000
--- a/onmainwindow_part4.cpp
+++ /dev/null
@@ -1,2861 +0,0 @@
-/**************************************************************************
-*   Copyright (C) 2005-2012 by Oleksandr Shneyder                         *
-*   oleksandr.shneyder at obviously-nice.de                                  *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU General Public License as published by  *
-*   the Free Software Foundation; either version 2 of the License, or     *
-*   (at your option) any later version.                                   *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU General Public License     *
-*   along with this program; if not, write to the                         *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-
-#include "onmainwindow_privat.h"
-
-void ONMainWindow::startX2goMount()
-{
-    QFile file ( fsExportKey+".pub" );
-    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-    {
-        QString message=tr ( "Unable to read :\n" ) +fsExportKey+".pub";
-        QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                QMessageBox::Ok,
-                                QMessageBox::NoButton );
-        QFile::remove
-        ( fsExportKey+".pub" );
-        return;
-    }
-
-    QByteArray line = file.readLine();
-    file.close();
-    QString authofname=homeDir;
-#ifdef Q_OS_WIN
-    QDir tdir;
-    tdir.mkpath ( authofname+"\\.x2go\\.ssh" );
-    x2goDebug<<"Creating "<<authofname+"\\.x2go\\.ssh"<<endl;
-    authofname=wapiShortFileName ( authofname ) +"/.x2go";
-#endif
-    authofname+= "/.ssh/authorized_keys" ;
-
-    QFile file1 ( authofname );
-
-    if ( !file1.open ( QIODevice::WriteOnly | QIODevice::Text |
-                       QIODevice::Append ) )
-    {
-        QString message=tr ( "Unable to write :\n" ) + authofname;
-        QMessageBox::critical ( 0l,tr ( "Error" ),message,
-                                QMessageBox::Ok,
-                                QMessageBox::NoButton );
-        QFile::remove
-        ( fsExportKey+".pub" );
-        return;
-
-    }
-    QTextStream out ( &file1 );
-    out<<line;
-    file1.close();
-    directory* dir=getExpDir ( fsExportKey );
-    bool rem=dir->isRemovable;
-    if ( !dir )
-        return;
-
-    QString passwd=getCurrentPass();
-    QString user=getCurrentUname();
-    QString host=resumingSession.server;
-    QString sessionId=resumingSession.sessionId;
-
-    QStringList env=QProcess::systemEnvironment();
-
-
-    QString cuser;
-#ifndef Q_WS_HILDON
-    for ( int i=0;i<env.size();++i )
-    {
-        QStringList ls=env[i].split ( "=" );
-        if ( ls[0]=="USER" )
-
-        {
-            cuser=ls[1];
-            break;
-        }
-    }
-#else
-    cuser="user";
-#endif
-#ifdef Q_OS_WIN
-    cuser="sshuser";
-#endif
-    SshProcess* proc=0l;
-    QString cmd;
-    QString dirs=dir->dirList;
-
-    if ( !fsInTun && clientSshPort!="22" )
-    {
-        dirs=dirs+"__SSH_PORT__"+clientSshPort;
-    }
-    if ( fsInTun )
-    {
-        dirs=dirs+"__REVERSESSH_PORT__"+resumingSession.fsPort;
-    }
-    if ( !rem )
-        cmd="export HOSTNAME && x2gomountdirs dir "+sessionId+" "+cuser+
-            " "+dir->dstKey+" "+dirs;
-    else
-        cmd="export HOSTNAME && x2gomountdirs rem "+sessionId+" "+cuser+
-            " "+dir->dstKey+" "+dirs;
-
-#ifdef Q_OS_WIN
-
-    cmd="chmod 600 "+dir->dstKey+"&&"+cmd;
-#endif
-
-
-
-    X2goSettings st ( "sessions" );
-
-    if ( !useLdap )
-    {
-        QString sid;
-        if ( !embedMode )
-            sid=lastSession->id();
-        else
-            sid="embedded";
-        if ( st.setting()->value (
-                    sid+"/useiconv", ( QVariant ) false ).toBool() )
-        {
-            QString toCode=st.setting()->value (
-                               sid+"/iconvto",
-                               ( QVariant ) "UTF-8" ).toString();
-
-#ifdef Q_OS_WIN
-            QString fromCode=st.setting()->value (
-                                 sid+"/iconvfrom",
-                                 ( QVariant ) tr (
-                                     "WINDOWS-1252" ) ).toString();
-#endif
-#ifdef Q_OS_DARWIN
-            QString fromCode=st.setting()->value (
-                                 sid+"/iconvfrom",
-                                 ( QVariant )
-                                 "UTF-8" ).toString();
-#endif
-#ifdef Q_OS_LINUX
-            QString fromCode=st.setting()->value (
-                                 sid+"/iconvfrom",
-                                 ( QVariant ) tr (
-                                     "ISO8859-1" ) ).toString();
-#endif
-            cmd="export X2GO_ICONV=modules=iconv,from_code="+
-                fromCode+
-                ",to_code="+toCode+"&&"+cmd;
-        }
-    }
-
-    proc=new SshProcess ( sshConnection, this );
-    dir->proc=proc;
-
-    connect ( proc,SIGNAL ( sshFinished ( bool, QString,SshProcess* ) ),
-              this,SLOT ( slotRetExportDir ( bool,
-                                             QString,SshProcess* ) ) );
-
-    proc->startNormal ( cmd );
-}
-
-void ONMainWindow::slotCheckPrintSpool()
-{
-    QDir dir ( spoolDir );
-    QStringList list = dir.entryList ( QDir::Files );
-    for ( int i=0;i<list.size();++i )
-    {
-        if ( !list[i].endsWith ( ".ready" ) )
-            continue;
-        QFile file ( spoolDir+"/"+list[i] );
-        if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-            continue;
-        bool startProc=false;
-        QString fname,title;
-        if ( !file.atEnd() )
-        {
-            QByteArray line = file.readLine();
-            QString fn ( line );
-            fn.replace ( "\n","" );
-            fname=fn;
-            if ( !file.atEnd() )
-            {
-                line = file.readLine();
-                title=line;
-                title.replace ( "\n","" );
-            }
-            startProc=true;
-        }
-        file.close();
-        file.remove();
-        if ( startProc )
-            new PrintProcess ( spoolDir+"/"+fname,title ,this );
-
-    }
-}
-
-
-void ONMainWindow::cleanPrintSpool()
-{
-    QDir dir ( spoolDir );
-    QStringList list = dir.entryList ( QDir::Files );
-    for ( int i=0;i<list.size();++i )
-    {
-        QFile::remove ( spoolDir+"/"+list[i] );
-    }
-}
-
-
-void ONMainWindow::cleanAskPass()
-{
-    QString path=homeDir +"/.x2go/ssh/";
-    QDir dir ( path );
-    QStringList list = dir.entryList ( QDir::Files );
-    for ( int i=0;i<list.size();++i )
-    {
-        if ( list[i].startsWith ( "askpass" ) )
-            QFile::remove ( path+list[i] );
-    }
-
-}
-
-
-#ifdef Q_OS_WIN
-#include <windows.h>
-#include <winsock2.h>
-#include <ws2tcpip.h>
-#endif
-
-
-bool ONMainWindow::isServerRunning ( int port )
-{
-#ifdef Q_OS_WIN
-    SOCKET ConnectSocket = INVALID_SOCKET;
-    struct sockaddr_in saServer;
-    hostent* localHost;
-    char* localIP;
-    int iResult;
-    WSADATA wsaData;
-
-    struct in_addr addr = { 0 };
-
-    iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
-    if (iResult != 0)
-    {
-        x2goDebug<<"WARNING: WSAStartup failed: "<< iResult<<endl;
-        return false;
-    }
-
-    addr.s_addr = inet_addr("127.0.0.1");
-    if (addr.s_addr == INADDR_NONE)
-    {
-        x2goDebug<< "WARNING:  The IPv4 address entered must be a legal address\n";
-        return false;
-    }
-
-
-    localHost = gethostbyaddr((char*)&addr,4, AF_INET);
-    if (!localHost)
-    {
-        x2goDebug<<"WARNING: gethostbyaddr failed: "<<WSAGetLastError()<<endl;
-        return false;
-    }
-    x2goDebug<<"got localhost"<<endl;
-
-    localIP = inet_ntoa (*(struct in_addr *)*localHost->h_addr_list);
-
-    saServer.sin_family = AF_INET;
-    saServer.sin_addr.s_addr = inet_addr(localIP);
-    saServer.sin_port = htons(port);
-
-    ConnectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-    if (ConnectSocket == INVALID_SOCKET)
-    {
-        x2goDebug<<"WARNING: socket failed with error: "<< WSAGetLastError()<<endl;
-        return false;
-    }
-
-    iResult = ::connect( ConnectSocket, (SOCKADDR*) &saServer, sizeof(saServer));
-    if (iResult == SOCKET_ERROR)
-    {
-        closesocket(ConnectSocket);
-        x2goDebug<<"Port is free: "<<port<<endl;
-        return false;
-    }
-    closesocket(ConnectSocket);
-    x2goDebug<<"Port already used: "<<port<<endl;
-    return true;
-#endif
-    QTcpSocket tcpSocket ( 0 );
-    tcpSocket.connectToHost ( "127.0.0.1",port );
-
-    if ( tcpSocket.waitForConnected ( 1000 ) )
-    {
-        tcpSocket.close();
-        return true;
-    }
-    return false;
-}
-#ifdef Q_OS_WIN
-void ONMainWindow::slotCheckXOrgLog()
-{
-    xorgLogMutex.lock();
-    if ( xorgLogFile.length() <=0 )
-    {
-        xorgLogMutex.unlock();
-        return;
-    }
-    QFile file ( xorgLogFile );
-    if ( !file.open ( QIODevice::ReadOnly | QIODevice::Text ) )
-    {
-        xorgLogMutex.unlock();
-        return;
-    }
-
-    QTextStream in ( &file );
-    while ( !in.atEnd() )
-    {
-        QString line = in.readLine();
-        if ( line.indexOf ( "successfully opened the display" ) !=-1 )
-        {
-            xorgLogTimer->stop();
-            slotSetWinServersReady();
-            xorgLogMutex.unlock();
-            return;
-        }
-    }
-    xorgLogMutex.unlock();
-}
-
-void ONMainWindow::startXOrg ()
-{
-    while ( isServerRunning ( 6000+xDisplay ) )
-        ++xDisplay;
-    QString dispString;
-    QTextStream ( &dispString ) <<":"<<xDisplay;
-
-    QStringList args;
-    QString exec;
-    if (internalX==XMING)
-        exec=appDir+"\\xming\\Xming.exe";
-    if (internalX==VCXSRV)
-        exec=appDir+"\\vcxsrv\\vcxsrv.exe";
-    winServersReady=false;
-    x2goDebug<<"using internal X: "<<useInternalX;
-//#ifdef CFGCLIENT
-    if (!useInternalX || internalX!=XMING)
-    {
-        if (!useInternalX)
-            exec=xorgExe;
-        QString cmdLine;
-        if (startXorgOnStart)
-            cmdLine=xorgOptions;
-        else
-        {
-            switch (xorgMode)
-            {
-            case FS:
-                cmdLine=xorgFSOptions;
-                break;
-            case SAPP:
-                cmdLine=xorgSAppOptions;
-                break;
-            case WIN:
-                cmdLine=xorgWinOptions;
-                x2goDebug<<"WxH:"<<xorgWidth<<"x"<<xorgHeight<<endl;
-                cmdLine.replace("%w",xorgWidth);
-                cmdLine.replace("%h",xorgHeight);
-                x2goDebug<<cmdLine<<endl;
-                break;
-            }
-        }
-        QStringList options=cmdLine.split(" ",QString::SkipEmptyParts);
-        QString option;
-        foreach(option,options)
-        {
-            args<< option;
-        }
-        args<<dispString;
-    }
-//#endif
-    xorg=new QProcess ( 0 );
-    if (useInternalX && (internalX==XMING))
-    {
-
-        QString workingDir=appDir+"\\xming";
-        QStringList env=QProcess::systemEnvironment();
-        env<<"GLWIN_ENABLE_DEBUG=0";
-        xorgLogMutex.lock();
-        xorgLogFile=homeDir+"/.x2go/xorg";
-        QDir dr ( homeDir );
-        dr.mkpath ( xorgLogFile );
-        xorgLogFile=wapiShortFileName ( xorgLogFile ) +"\\xorg.log."+
-                    QString::number ( xDisplay );
-        if ( QFile::exists ( xorgLogFile ) )
-            QFile::remove ( xorgLogFile );
-        xorgLogMutex.unlock();
-//run xming with clipboard support
-        args<<dispString<<"-multiwindow"<<"-notrayicon"<<"-clipboard"<<
-        "-logfile"<<xorgLogFile;
-        xorg->setEnvironment ( env );
-        xorg-> setWorkingDirectory ( workingDir);
-    }
-
-    x2goDebug<<"running"<<exec<<" "<<args.join(" ");
-    xorg->start ( exec, args );
-
-
-    if ( !xorg->waitForStarted ( 3000 ) )
-    {
-        QMessageBox::critical (
-            0,QString::null,
-            tr ( "Can't start X Server\n"
-                 "Please check your installation" ) );
-        close();
-    }
-// #ifdef CFGCLIENT
-    if ( !useInternalX || internalX!= XMING)
-    {
-        //check connection in slot and launch setWinServerReady
-        waitingForX=0;
-        QTimer::singleShot(1000, this, SLOT(slotCheckXOrgConnection()));
-    }
-// #endif
-}
-
-void ONMainWindow::slotCheckXOrgConnection()
-{
-    ++waitingForX;
-    if (isServerRunning(6000+xDisplay))
-    {
-        x2goDebug<<"X is started";
-        slotSetWinServersReady();
-    }
-    else
-    {
-        if (waitingForX > 10)
-        {
-            QMessageBox::critical (
-                0,QString::null,
-                tr ( "Can't start X Server\n"
-                     "Please check your installation" ) );
-            close();
-        }
-        else
-        {
-            x2goDebug<<"waiting for X";
-            QTimer::singleShot(1000, this, SLOT(slotCheckXOrgConnection()));
-        }
-    }
-}
-
-WinServerStarter::WinServerStarter ( daemon server, ONMainWindow * par ) :
-        QThread ( 0 )
-{
-    mode=server;
-    parent=par;
-}
-
-void WinServerStarter::run()
-{
-    switch ( mode )
-    {
-    case SSH:
-        parent->startSshd();
-        break;
-    case X:
-        parent->startXOrg();
-        break;
-    case PULSE:
-        parent->startPulsed();
-        break;
-    }
-}
-
-
-
-void ONMainWindow::startWinServers()
-{
-    x2goDebug<<"Starting win servers"<<endl;
-
-    QString etcDir=homeDir+"/.x2go/etc";
-    QDir dr ( homeDir );
-
-    pulseServer=0l;
-
-    WinServerStarter* xStarter = new WinServerStarter ( WinServerStarter::X,
-            this );
-    WinServerStarter* sshStarter = new WinServerStarter (
-        WinServerStarter::SSH, this );
-
-    WinServerStarter* pulseStarter = new WinServerStarter (
-        WinServerStarter::PULSE, this );
-
-    if ( !embedMode || !config.confFS || ( config.confFS && config.useFs ) )
-    {
-
-        dr.mkpath ( etcDir );
-        generateHostDsaKey();
-        generateEtcFiles();
-        sshStarter->start();
-    }
-    if ( !embedMode || !config.confSnd ||
-            ( config.confSnd && config.useSnd ) )
-    {
-        pulseStarter->start();
-    }
-// #ifdef CFGCLIENT
-//     x2goDebug<<"xorg settings: "<<startXorgOnStart <<" "<< useXming<<endl;
-    if ( useInternalX && (internalX== XMING))
-    {
-// #endif
-        xStarter->start();
-        xorgLogTimer=new QTimer ( this );
-        connect ( xorgLogTimer,SIGNAL ( timeout() ),this,
-                  SLOT ( slotCheckXOrgLog() ) );
-        xorgLogTimer->start ( 500 );
-// #ifdef CFGCLIENT
-    }
-    else
-    {
-        if (startXorgOnStart)
-        {
-            startXOrg();
-        }
-    }
-// #endif
-}
-
-
-bool ONMainWindow::haveCySolEntry()
-{
-    QSettings CySolSt ( "HKEY_CURRENT_USER\\Software"
-                        "\\Cygnus Solutions",
-                        QSettings::NativeFormat );
-    return ( CySolSt.childGroups().count() > 0 ||
-             CySolSt.childKeys().count() > 0 );
-}
-
-bool ONMainWindow::haveCygwinEntry()
-{
-    QSettings CygwSt ( "HKEY_CURRENT_USER\\Software"
-                       "\\Cygnus Solutions\\Cygwin",
-                       QSettings::NativeFormat );
-    return ( CygwSt.childGroups().count() >0||CygwSt.childKeys().count() );
-}
-
-
-
-void ONMainWindow::saveCygnusSettings()
-{
-    if ( ONMainWindow::portable )
-    {
-        if ( haveCySolEntry() )
-        {
-            x2goDebug<<"Cygnus Solutions entry exist";
-            cySolEntry=true;
-        }
-        else
-        {
-            cySolEntry=false;
-            x2goDebug<<"Cygnus Solutions entry not exist";
-        }
-
-        if ( haveCygwinEntry() )
-        {
-            x2goDebug<<"Cygwin entry exist";
-            cyEntry=true;
-        }
-        else
-        {
-            x2goDebug<<"Cygwin entry not exist";
-            cyEntry=false;
-        }
-    }
-
-    QSettings etcst ( "HKEY_CURRENT_USER\\Software"
-                      "\\Cygnus Solutions\\Cygwin\\mounts v2\\/etc",
-                      QSettings::NativeFormat );
-    oldEtcDir=QString::null;
-    oldEtcDir=etcst.value ( "native",oldEtcDir ).toString();
-    x2goDebug<<"old etc:"<<oldEtcDir<<endl;
-    QString newEtc=homeDir+"/.x2go/etc";
-    QDir d ( newEtc );
-    if ( !d.exists() )
-        d.mkpath ( newEtc );
-    newEtc.replace ( "/","\\" );
-
-    etcst.setValue ( "native",wapiShortFileName ( newEtc ) );
-    etcst.sync();
-    x2goDebug<<"new etc:"<<wapiShortFileName ( newEtc ) <<endl;
-
-    QSettings binst ( "HKEY_CURRENT_USER\\Software"
-                      "\\Cygnus Solutions\\Cygwin\\mounts v2\\/bin",
-                      QSettings::NativeFormat );
-    oldBinDir=QString::null;
-    oldBinDir=binst.value ( "native",oldBinDir ).toString();
-    x2goDebug<<"old bin:"<<oldBinDir<<endl;
-    QString newBin=appDir;
-    newBin.replace ( "/","\\" );
-    binst.setValue ( "native",wapiShortFileName ( newBin ) );
-    binst.sync();
-    x2goDebug<<"new bin:"<<newBin<<endl;
-
-    QSettings tmpst ( "HKEY_CURRENT_USER\\Software"
-                      "\\Cygnus Solutions\\Cygwin\\mounts v2\\/tmp",
-                      QSettings::NativeFormat );
-    oldTmpDir=QString::null;
-    oldTmpDir=tmpst.value ( "native",oldTmpDir ).toString();
-    x2goDebug<<"old tmp:"<<oldTmpDir<<endl;
-    QString newTmp=QDir::tempPath();
-    newTmp.replace ( "/","\\" );
-    tmpst.setValue ( "native",wapiShortFileName ( newTmp ) );
-    tmpst.sync();
-    x2goDebug<<"new tmp:"<<newTmp<<endl;
-}
-
-void ONMainWindow::restoreCygnusSettings()
-{
-
-    if ( oldEtcDir==QString::null )
-    {
-        QSettings st ( "HKEY_CURRENT_USER\\Software"
-                       "\\Cygnus Solutions\\Cygwin\\mounts v2\\/etc",
-                       QSettings::NativeFormat );
-        x2goDebug<<"Removing /etc from cygwin mounts\n";
-        st.remove ( "" );
-        st.sync();
-    }
-    else
-    {
-        QSettings st ( "HKEY_CURRENT_USER\\Software"
-                       "\\Cygnus Solutions\\Cygwin\\mounts v2\\/etc",
-                       QSettings::NativeFormat );
-        st.setValue ( "native",oldEtcDir );
-        st.sync();
-        x2goDebug<<"Restoring /etc in cygwin mounts\n";
-    }
-    if ( oldBinDir==QString::null )
-    {
-        QSettings st ( "HKEY_CURRENT_USER\\Software"
-                       "\\Cygnus Solutions\\Cygwin\\mounts v2\\/bin",
-                       QSettings::NativeFormat );
-        x2goDebug<<"Removing /bin from cygwin mounts\n";
-        st.remove ( "" );
-        st.sync();
-    }
-    else
-    {
-        QSettings st ( "HKEY_CURRENT_USER\\Software"
-                       "\\Cygnus Solutions\\Cygwin\\mounts v2\\/bin",
-                       QSettings::NativeFormat );
-        st.setValue ( "native",oldBinDir );
-        st.sync();
-        x2goDebug<<"Restoring /bin in cygwin mounts\n";
-    }
-    if ( oldTmpDir==QString::null )
-    {
-        QSettings st ( "HKEY_CURRENT_USER\\Software"
-                       "\\Cygnus Solutions\\Cygwin\\mounts v2\\/tmp",
-                       QSettings::NativeFormat );
-        x2goDebug<<"Removing /tmp from cygwin mounts\n";
-        st.remove ( "" );
-        st.sync();
-    }
-    else
-    {
-        QSettings st ( "HKEY_CURRENT_USER\\Software"
-                       "\\Cygnus Solutions\\Cygwin\\mounts v2\\/tmp",
-                       QSettings::NativeFormat );
-        st.setValue ( "native",oldTmpDir );
-        st.sync();
-        x2goDebug<<"Restoring /tmp in cygwin mounts\n";
-    }
-    if ( ONMainWindow::portable )
-    {
-        if ( !cyEntry )
-        {
-            removeCygwinEntry();
-        }
-        if ( !cySolEntry )
-        {
-            removeCySolEntry();
-        }
-    }
-}
-
-void ONMainWindow::removeCygwinEntry()
-{
-    QSettings st ( "HKEY_CURRENT_USER\\Software"
-                   "\\Cygnus Solutions\\Cygwin",
-                   QSettings::NativeFormat );
-    x2goDebug<<"Removing cygwin\n";
-    st.remove ( "" );
-    st.sync();
-
-}
-
-void ONMainWindow::removeCySolEntry()
-{
-    QSettings st ( "HKEY_CURRENT_USER\\Software"
-                   "\\Cygnus Solutions",
-                   QSettings::NativeFormat );
-    x2goDebug<<"Removing cygnus solutions\n";
-    st.remove ( "" );
-    st.sync();
-}
-
-void ONMainWindow::startPulsed()
-{
-    while ( isServerRunning ( pulsePort ) )
-        ++pulsePort;
-    esdPort=pulsePort+1;
-    while ( isServerRunning ( esdPort ) )
-        ++esdPort;
-
-    pulseDir=homeDir+"/.x2go/pulse";
-    QDir dr ( homeDir );
-    dr.mkpath ( pulseDir );
-    pulseDir=wapiShortFileName ( pulseDir );
-    x2goDebug<<"template: "<<pulseDir+"/tmp"<<endl;
-    QTemporaryFile* fl=new QTemporaryFile ( pulseDir+"/tmp" );
-    fl->open();
-    pulseDir=fl->fileName();
-    fl->close();
-    delete fl;
-    QFile::remove ( pulseDir );
-    dr.mkpath ( pulseDir );
-    x2goDebug<<"pulse tmp file: "<<pulseDir<<endl;
-    QStringList pEnv=QProcess::systemEnvironment();
-    for ( int i=0; i<pEnv.size();++i )
-    {
-        if ( pEnv[i].indexOf ( "USERPROFILE=" ) !=-1 )
-            pEnv[i]="USERPROFILE="+
-                    wapiShortFileName ( homeDir+"/.x2go/pulse" );
-        if ( pEnv[i].indexOf ( "TEMP=" ) !=-1 )
-            pEnv[i]="TEMP="+pulseDir;
-        if ( pEnv[i].indexOf ( "USERNAME=" ) !=-1 )
-            pEnv[i]="USERNAME=pulseuser";
-    }
-
-    QFile file ( pulseDir+"/config.pa" );
-    if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
-        return;
-    QTextStream out ( &file );
-    out << "load-module module-native-protocol-tcp port="+
-    QString::number ( pulsePort ) <<endl;
-    out << "load-module module-esound-protocol-tcp port="+
-    QString::number ( esdPort ) <<endl;
-    out << "load-module module-waveout"<<endl;
-    file.close();
-    pulseServer=new QProcess ( 0 );
-    pulseServer->setEnvironment ( pEnv );
-    QStringList args;
-    args<<"-n"<<"-F"<<pulseDir+"/config.pa";
-    pulseServer->setWorkingDirectory ( wapiShortFileName (
-                                           appDir+"\\pulse" ) );
-    pulseServer->start ( "pulse\\pulseaudio.exe",args );
-    x2goDebug<<"starting pulse\\pulseaudio.exe "<<args.join ( " " ) <<
-    " working dir: "<<
-    wapiShortFileName ( appDir+"\\pulse" ) <<endl;
-}
-
-
-// #ifdef CFGCLIENT
-void ONMainWindow::xorgSettings()
-{
-    x2goDebug<<"getting xorg settings"<<endl;
-
-    X2goSettings st ( "settings" );
-
-    useInternalX=(st.setting()->value("useintx",true).toBool());
-
-    xorgExe=(st.setting()->value("xexec","C:\\program files\\vcxsrv\\vcxsrv.exe").toString());
-    xorgOptions=(st.setting()->value("options","-multiwindow -notrayicon -clipboard").toString());
-    startXorgOnStart=(st.setting()->value("onstart",true).toBool());
-    xorgWinOptions=(st.setting()->value("optionswin","-screen 0 %wx%h -notrayicon -clipboard").toString());
-    xorgFSOptions=(st.setting()->value("optionsfs","-fullscreen -notrayicon -clipboard").toString());
-    xorgSAppOptions=(st.setting()->value("optionssingle","-multiwindow -notrayicon -clipboard").toString());
-
-    if (QFile::exists(appDir+"\\vcxsrv"))
-        internalX=VCXSRV;
-    if (QFile::exists(appDir+"\\xming"))
-        internalX=XMING;
-    if (useInternalX)
-    {
-        startXorgOnStart=(internalX==XMING);
-        xorgOptions="-multiwindow -notrayicon -clipboard";
-        if (internalX==VCXSRV)
-        {
-// 	xorgWinOptions="-screen 0 %wx%h -notrayicon -clipboard";
-            xorgWinOptions="-multiwindow -notrayicon -clipboard";
-            xorgFSOptions="-fullscreen -notrayicon -clipboard";
-            xorgSAppOptions="-multiwindow -notrayicon -clipboard";
-        }
-    }
-
-}
-// #endif
-
-void ONMainWindow::slotSetWinServersReady()
-{
-    x2goDebug<<"all winservers are started\n";
-    winServersReady=true;
-    restoreCygnusSettings();
-}
-
-#include <windows.h>
-#include<sstream>
-#endif
-
-void ONMainWindow::generateEtcFiles()
-{
-    QString etcDir=homeDir+"/.x2go/etc";
-    QDir dr ( homeDir );
-    dr.mkpath ( etcDir );
-#ifdef Q_OS_WIN
-    if ( !QFile::exists ( etcDir+"/passwd" ) )
-    {
-        QString sid, sys, user, grsid, grname;
-        if ( !wapiAccountInfo ( &sid,&user,&grsid, &grname, &sys ) )
-        {
-// 			x2goDebug<<"Get account info failed\n";
-            close();
-        }
-
-// 		x2goDebug<<"sid: "<<sid <<" system:"<<
-// 		sys<< " user: "<<user<<" group sid:"<<grsid<<
-// 		"group name: "<<grname<<endl;
-
-        QStringList sidList=sid.split ( '-' );
-        QString rid=sidList[sidList.count()-1];
-        QStringList grsidList=grsid.split ( '-' );
-        QString grid=grsidList[grsidList.count()-1];
-        QFile file ( etcDir +"/passwd" );
-        if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
-            return;
-        QTextStream out ( &file );
-        out <<"sshuser::"<<rid<<":"<<grid<<":"<<sys<<"\\sshuser,"
-        <<sid<<":"<<cygwinPath ( wapiShortFileName ( homeDir ) ) <<
-        "/.x2go"<<":/bin/bash\n";
-        file.close();
-    }
-
-    if ( !QFile::exists ( etcDir+"/sshd_config" ) )
-    {
-#endif
-        QFile file ( etcDir +"/sshd_config" );
-        if ( !file.open ( QIODevice::WriteOnly | QIODevice::Text ) )
-            return;
-        QTextStream out ( &file );
-        out<<"StrictModes no\n"<<
-        "UsePrivilegeSeparation no\n"<<
-#ifdef Q_OS_WIN
-        "Subsystem sftp /bin/sftp-server\n";
-#else
-        "Subsystem sftp "
-        <<appDir<<"/sftp-server\n";
-#endif
-        file.close();
-        x2goDebug<<etcDir +"/sshd_config created";
-#ifdef Q_OS_WIN
-    }
-#endif
-}
-
-void ONMainWindow::generateHostDsaKey()
-{
-    QString etcDir=homeDir+"/.x2go/etc";
-    QDir dr ( homeDir );
-    dr.mkpath ( etcDir );
-    if ( !QFile::exists ( etcDir+"/ssh_host_dsa_key" ) ||
-            !QFile::exists ( etcDir+"/ssh_host_dsa_key.pub" ) )
-    {
-        /*		x2goDebug<<"Generating host DSA key\n";*/
-#ifdef Q_OS_WIN
-        QString fname=cygwinPath ( wapiShortFileName ( etcDir ) ) +
-                      "/ssh_host_dsa_key";
-#else
-        QString fname=etcDir+"/ssh_host_dsa_key";
-#endif
-        QStringList args;
-        args<<"-t"<<"dsa"<<"-N"<<""<<"-C"<<
-        "x2goclient DSA host key"<<"-f"<<fname;
-        QProcess::execute ( "ssh-keygen",args );
-    }
-}
-
-void ONMainWindow::startSshd()
-{
-    if ( embedMode && config.confFS && !config.useFs )
-    {
-        return;
-    }
-#ifdef Q_OS_LINUX
-    clientSshPort="7022";
-#endif
-    QString etcDir=homeDir+"/.x2go/etc";
-    int port=clientSshPort.toInt();
-    //clientSshPort have initvalue
-    while ( isServerRunning ( port ) )
-        ++port;
-    clientSshPort=QString::number ( port );
-#ifdef Q_OS_WIN
-    std::string clientdir=wapiShortFileName ( appDir ).toStdString();
-    std::stringstream strm;
-    strm<<clientdir<<"\\sshd.exe -D -p"<<clientSshPort.toInt();
-
-    STARTUPINFOA si;
-    std::string desktopName="x2go_";
-    desktopName+=getenv ( "USERNAME" );
-    char* desktop=new char[desktopName.size() +1];
-    strcpy ( desktop,desktopName.c_str() );
-    x2goDebug<<"Creating desktop: "<<desktop<<endl;
-    if ( !CreateDesktopA (
-                desktop,
-                0,
-                0,
-                0,
-                GENERIC_ALL,
-                0
-            ) )
-    {
-        strcpy ( desktop,"" );
-        x2goDebug<<"Desktop creation failed, using default\n";
-    }
-    ZeroMemory ( &si, sizeof ( si ) );
-    ZeroMemory ( &sshd, sizeof ( sshd ) );
-    si.lpDesktop=desktop;
-    si.cb = sizeof ( si );
-    CreateProcessA ( NULL,  // No module name (use command line)
-                     ( LPSTR ) strm.str().c_str(),  // Command line
-                     NULL,           // Process handle not inheritable
-                     NULL,           // Thread handle not inheritable
-                     TRUE,          // Set handle inheritance to FALSE
-                     0/*CREATE_NO_WINDOW|CREATE_NEW_PROCESS_GROUP*/,
-                     //creation flags
-                     NULL,           // Use parent's environment block
-                     clientdir.c_str(), // Starting directory
-                     &si,            // Pointer to STARTUPINFO structure
-                     &sshd );// Pointer to PROCESS_INFORMATION structure
-    delete []desktop;
-    winSshdStarted=true;
-#else
-    userSshd=true;
-    sshd=new QProcess ( this );
-    QStringList arguments;
-    arguments<<"-f"<<etcDir +"/sshd_config"<< "-h" <<
-    etcDir+"/ssh_host_dsa_key"<<"-D"<<"-p"<<clientSshPort;
-    sshd->start ( appDir+"/sshd",arguments );
-    x2goDebug<<"Usermode sshd started";
-#endif
-}
-
-void ONMainWindow::setProxyWinTitle()
-{
-
-    QString title;
-
-    if (!useLdap)
-        title=lastSession->name();
-    else
-        title=getCurrentUname()+"@"+resumingSession.server;
-
-    QPixmap pixmap;
-
-    if (useLdap)
-        pixmap=lastUser->foto();
-    else
-        pixmap=*(lastSession->sessIcon());
-
-#ifdef Q_OS_LINUX
-
-    XStoreName(QX11Info::display(), proxyWinId, title.toLocal8Bit().data());
-
-    XWMHints* win_hints;
-
-
-    QByteArray bytes;
-    QBuffer buffer(&bytes);
-    buffer.open(QIODevice::WriteOnly);
-    pixmap.save(&buffer, "XPM");
-
-
-    int rez;
-
-    if (image)
-        XFreePixmap(QX11Info::display(),image);
-    if (shape)
-        XFreePixmap(QX11Info::display(),shape);
-
-
-    rez=XpmCreatePixmapFromBuffer(QX11Info::display(), proxyWinId, bytes.data(),
-                                  (Pixmap *) &image, (Pixmap *) &shape, NULL);
-    if (!rez)
-    {
-
-        win_hints = XAllocWMHints();
-        if (win_hints)
-        {
-            win_hints->flags = IconPixmapHint|IconMaskHint;
-            win_hints->icon_pixmap = image;
-            win_hints->icon_mask = shape;
-            XSetWMHints(QX11Info::display(), proxyWinId, win_hints);
-            XFree(win_hints);
-        }
-    }
-
-#endif
-#ifdef Q_OS_WIN
-    wapiSetWindowText((HWND)proxyWinId, title);
-//       wapiSetWindowIcon((HWND)proxyWinId, pixmap);
-#endif
-}
-
-void ONMainWindow::slotSetProxyWinFullscreen()
-{
-
-#ifdef Q_OS_LINUX
-    XSync(QX11Info::display(),false);
-    XEvent event;
-    long emask = StructureNotifyMask | ResizeRedirectMask;
-    event.xclient.type = ClientMessage;
-    event.xclient.serial = 0;
-    event.xclient.send_event = True;
-    event.xclient.display = QX11Info::display();
-    event.xclient.window = proxyWinId;
-    event.xclient.message_type = XInternAtom(QX11Info::display(),"_NET_WM_STATE",False);
-    event.xclient.format = 32;
-    event.xclient.data.l[0] = 1;
-    event.xclient.data.l[1] = XInternAtom(QX11Info::display(),"_NET_WM_STATE_FULLSCREEN",False);
-    event.xclient.data.l[2] = 0;
-    event.xclient.data.l[3] = 0;
-    event.xclient.data.l[4] = 0;
-    Status st;
-    st=XSendEvent(QX11Info::display(), DefaultRootWindow(QX11Info::display()),
-                  False, emask,&event);
-    XSync(QX11Info::display(),false);
-#endif
-#ifdef Q_OS_WIN
-    wapiSetFSWindow ( ( HWND ) proxyWinId,
-                      dispGeometry );
-
-#endif
-}
-
-
-void ONMainWindow::resizeProxyWinOnDisplay(int disp)
-{
-    QRect geom=QApplication::desktop()->screenGeometry(disp-1);
-    x2goDebug<<"resizing proxy win to fit display "<<disp<<"("<<geom<<")"<<endl;
-#ifdef Q_OS_LINUX
-    XSync(QX11Info::display(),false);
-    XMoveWindow(QX11Info::display(), proxyWinId,geom.x(),geom.y());
-#endif
-#ifdef Q_OS_WIN
-    dispGeometry=geom;
-#endif
-    QTimer::singleShot(500, this, SLOT(slotSetProxyWinFullscreen()));
-}
-
-
-QRect ONMainWindow::proxyWinGeometry()
-{
-#ifdef Q_OS_WIN
-    QRect proxyRect;
-    if (!wapiWindowRectWithoutDecoration((HWND)proxyWinId,proxyRect))
-        return QRect();
-    return proxyRect;
-#endif
-#ifdef Q_OS_LINUX
-    QRect proxyRect;
-    Window root;
-    int x,y;
-    uint w,h,border,depth;
-    if (XGetGeometry(QX11Info::display(), proxyWinId, &root,&x,&y,&w,&h,&border,&depth))
-    {
-
-        int realx,realy;
-        Window child;
-        XTranslateCoordinates(QX11Info::display(), proxyWinId, root, 0, 0, &realx, &realy, &child);
-        proxyRect.setRect(realx, realy, w,h);
-    }
-    return proxyRect;
-#endif
-    return QRect();
-}
-
-void ONMainWindow::slotConfigXinerama()
-{
-    QRect newGeometry=proxyWinGeometry();
-    if (newGeometry.isNull())
-    {
-//     x2goDebug<<"error getting window geometry (window closed?)\n";
-        xineramaTimer->stop();
-        return;
-    }
-    if (newGeometry==lastDisplayGeometry)
-        return;
-    lastDisplayGeometry=newGeometry;
-    x2goDebug<<"New proxy geometry: "<<lastDisplayGeometry<<endl;
-    QDesktopWidget* root=QApplication::desktop();
-    QList<QRect> newXineramaScreens;
-    for (int i=0; i< root->numScreens();++i)
-    {
-        QRect intersection;
-        if (resumingSession.fullscreen)
-            intersection=root->screenGeometry(i);
-        else
-            intersection=root->screenGeometry(i).intersected(lastDisplayGeometry);
-        if (!intersection.isNull())
-        {
-            x2goDebug<<"intersected with "<<i<<": "<<intersection<<endl;
-            intersection.moveLeft(intersection.x()-lastDisplayGeometry.x());
-            intersection.moveTop(intersection.y()-lastDisplayGeometry.y());
-            x2goDebug<<"xinerama screen: "<<intersection<<endl;
-            newXineramaScreens<<intersection;
-        }
-    }
-    if (xineramaScreens != newXineramaScreens)
-    {
-        xineramaScreens=newXineramaScreens;
-        x2goDebug<<"xinerama screen changed, new screens: "<<xineramaScreens<<endl;
-        SshProcess* proc=new SshProcess(sshConnection, this);
-        xineramaTimer->stop();
-        connect (proc, SIGNAL(sshFinished(bool,QString,SshProcess*)), this, SLOT(slotXineramaConfigured()));
-        QStringList screens;
-        foreach (QRect disp, xineramaScreens)
-        screens<<QString::number(disp.x())+" "+QString::number(disp.y())+" "+QString::number(disp.width())+
-        " "+QString::number(disp.height());
-        QString cmd="export DISPLAY=:"+resumingSession.display+";echo -e "+screens.join("\\\\n")+" >  ~/.x2go/C-"+
-                    resumingSession.sessionId+"/xinerama.conf";
-
-        x2goDebug<<cmd<<endl;
-        proc->startNormal(cmd);
-    }
-}
-
-void ONMainWindow::slotXineramaConfigured()
-{
-    if (resumingSession.fullscreen)
-        return;
-    if (xinSizeInc == -1)
-        xinSizeInc=1;
-    else
-        xinSizeInc=-1;
-#ifdef Q_OS_LINUX
-    lastDisplayGeometry.setWidth(lastDisplayGeometry.width()+xinSizeInc);
-    XSync(QX11Info::display(),false);
-    XResizeWindow(QX11Info::display(), proxyWinId,
-                  lastDisplayGeometry.width(),lastDisplayGeometry.height());
-    XSync(QX11Info::display(),false);
-#endif
-#ifdef Q_OS_WIN
-    QRect geom;
-    wapiWindowRect ( (HWND) proxyWinId, geom );
-    wapiMoveWindow( (HWND) proxyWinId, geom.x(), geom.y(), geom.width()+xinSizeInc, geom.height(),true);
-    lastDisplayGeometry=proxyWinGeometry();
-#endif
-    xineramaTimer->start(500);
-}
-
-void ONMainWindow::slotFindProxyWin()
-{
-#ifndef Q_OS_DARWIN
-    x2goDebug<<"search proxy win: "<<"X2GO-"+resumingSession.sessionId;
-    proxyWinId=findWindow ( "X2GO-"+resumingSession.sessionId );
-    bool xinerama=defaultXinerama;
-    if ( proxyWinId )
-    {
-        x2goDebug<<"proxy win found:"<<proxyWinId;
-        setProxyWinTitle();
-        proxyWinTimer->stop();
-        if (!useLdap)
-        {
-            X2goSettings *st;
-            QString sid;
-            if ( !embedMode )
-                sid=lastSession->id();
-            else
-                sid="embedded";
-
-            if (brokerMode)
-                st=new X2goSettings(config.iniFile,QSettings::IniFormat);
-            else
-                st= new X2goSettings( "sessions" );
-            uint displays=QApplication::desktop()->numScreens();
-            xinerama=st->setting()->value ( sid+"/xinerama",
-                                            ( QVariant ) defaultXinerama ).toBool();
-            if (st->setting()->value ( sid+"/multidisp",
-                                       ( QVariant ) false ).toBool())
-            {
-                uint disp=st->setting()->value ( sid+"/display",
-                                                 ( QVariant ) 1 ).toUInt();
-                if (disp>displays)
-                {
-                    disp=1;
-                }
-                resizeProxyWinOnDisplay(disp);
-                return;
-            }
-        }
-        if (xinerama)
-        {
-            x2goDebug<<"Starting xinerama timer\n";
-            lastDisplayGeometry=QRect();
-            xineramaScreens.clear();
-            xineramaTimer->start(500);
-        }
-
-        if ( embedMode )
-        {
-            if ( config.rootless )
-            {
-                x2goDebug<<"win is rootless";
-                act_embedContol->setEnabled ( false );
-            }
-            else
-                slotAttachProxyWindow();
-        }
-#ifdef Q_OS_WIN
-        x2goDebug<<"maximizeProxyWin: "<<maximizeProxyWin;
-        if ( !startEmbedded )
-        {
-            if ( maximizeProxyWin )
-            {
-                QDesktopWidget dw;
-                x2goDebug<<"making proxy win full screen";
-                wapiSetFSWindow ( ( HWND ) proxyWinId,
-                                  dw.screenGeometry ( this ) );
-                /*wapiShowWindow ( ( HWND ) proxyWinId,
-                   WAPI_SHOWMAXIMIZED );*/
-            }
-            else
-            {
-                wapiMoveWindow ( ( HWND ) proxyWinId,0,0,
-                                 proxyWinWidth,
-                                 proxyWinHeight,true );
-            }
-        }
-#endif
-    }
-#endif
-}
-
-
-QString ONMainWindow::getCurrentUname()
-{
-    return login->text();
-}
-
-QString ONMainWindow::getCurrentPass()
-{
-    return pass->text();
-}
-
-void ONMainWindow::slotDetachProxyWindow()
-{
-    proxyWinEmbedded=false;
-    bgFrame->show();
-    setStatStatus();
-    act_embedContol->setText ( tr ( "Attach X2Go window" ) );
-    act_embedContol->setIcon ( QIcon ( ":icons/32x32/attach.png" ) );
-#ifdef Q_OS_LINUX
-    //if QX11EmbedContainer cannot embed window, check if window exists
-    //and reconnect
-    if ( !embedControlChanged )
-    {
-        x2goDebug<<"\n";
-        slotFindProxyWin();
-        x2goDebug<<"proxy win detached, proxywin is:"<<proxyWinId<<endl;
-    }
-#endif
-    embedControlChanged=false;
-}
-
-
-void ONMainWindow::slotAttachProxyWindow()
-{
-    x2goDebug<<"slotAttachProxy";
-    if ( startEmbedded )
-    {
-        embedControlChanged=false;
-        bgFrame->hide();
-        proxyWinEmbedded=true;
-        setStatStatus();
-        act_embedContol->setText ( tr ( "Detach X2Go window" ) );
-        act_embedContol->setIcon (
-            QIcon ( ":icons/32x32/detach.png" ) );
-        QTimer::singleShot ( 100, this, SLOT ( slotEmbedWindow() ) );
-    }
-    else
-    {
-        x2goDebug<<"start embedded was false";
-        startEmbedded=true;
-    }
-
-}
-
-void ONMainWindow::slotEmbedWindow()
-{
-#ifndef Q_OS_DARWIN
-#ifdef CFGPLUGIN
-    embedWindow ( proxyWinId );
-#endif
-    QTimer::singleShot ( 1000, this,
-                         SLOT ( slotActivateWindow() ) );
-
-#endif
-}
-
-void ONMainWindow::setEmbedSessionActionsEnabled ( bool enable )
-{
-    act_shareFolder->setEnabled ( enable );
-    act_suspend->setEnabled ( enable );
-    act_terminate->setEnabled ( enable );
-    act_embedContol->setEnabled ( enable );
-    act_reconnect->setEnabled ( !enable );
-}
-
-void ONMainWindow::slotEmbedControlAction()
-{
-#ifndef Q_OS_DARWIN
-    embedControlChanged=true;
-    if ( proxyWinEmbedded )
-    {
-#ifdef CFGPLUGIN
-        detachClient();
-#endif
-    }
-    else
-        slotAttachProxyWindow();
-#endif
-}
-
-void ONMainWindow::slotEmbedIntoParentWindow()
-{
-#ifndef Q_OS_DARWIN
-// 	embedInto ( embedParent );
-#endif
-}
-
-
-void ONMainWindow::processSessionConfig()
-{
-    sshProxy.use=false;
-    bool haveKey=false;
-
-    config.command="KDE";
-    config.sshport="22";
-    config.session=tr ( "X2Go Session" );
-    config.checkexitstatus=true;
-    config.showtermbutton=true;
-    config.showexpbutton=true;
-    config.showconfig=true;
-    config.showextconfig=true;
-    config.showtoolbar=true;
-    config.showstatusbar=true;
-    config.kbdType=getDefaultKbdType();
-    config.kbdLay=getDefaultLayout()[0];
-
-
-    config.confSnd=false;
-    config.confFS=false;
-    config.confConSpd=false;
-    config.confCompMet=false;
-    config.confImageQ=false;
-    config.confDPI=false;
-    config.confKbd=false;
-
-    QStringList lines=m_x2goconfig.split ( "\n" );
-
-
-    for ( int i=0;i<lines.count();++i )
-    {
-        QString line = lines[i];
-        if ( ( line=="-----BEGIN DSA PRIVATE KEY-----" ) ||
-                ( line=="-----BEGIN RSA PRIVATE KEY-----" ) )
-        {
-            while ( i<lines.count() )
-                config.key+=lines[i++] +"\n";
-            haveKey=true;
-        }
-        else
-            processCfgLine ( line );
-    }
-    act_terminate->setVisible ( config.showtermbutton );
-    act_shareFolder->setVisible ( config.showexpbutton );
-    act_set->setVisible ( config.showconfig );
-    if (!config.showstatusbar)
-    {
-        statusBar()->hide();
-    }
-    if ( managedMode )
-    {
-        QTimer::singleShot ( 500, this, SLOT ( slotStartBroker() ) );
-        return;
-    }
-    slotSelectedFromList ( ( SessionButton* ) 0 );
-}
-
-
-void ONMainWindow::processCfgLine ( QString line )
-{
-    QStringList lst=line.split ( "=" );
-    if ( lst[0]=="command" )
-    {
-        config.command=lst[1];
-        return;
-    }
-    if ( lst[0]=="server" )
-    {
-        config.server=lst[1];
-        return;
-    }
-    if ( lst[0]=="session" )
-    {
-        config.session=lst[1];
-        return;
-    }
-    if ( lst[0]=="sshport" )
-    {
-        config.sshport=lst[1];
-        return;
-    }
-    if ( lst[0]=="user" )
-    {
-        config.user=lst[1];
-        return;
-    }
-    if ( lst[0]=="rootless" )
-    {
-        if ( lst[1]=="true" )
-            config.rootless=true;
-        else
-            config.rootless=false;
-        return;
-    }
-    if ( lst[0]=="checkexitstatus" )
-    {
-        if ( lst[1]=="true" )
-            config.checkexitstatus=true;
-        else
-            config.checkexitstatus=false;
-        return;
-    }
-    if ( lst[0]=="showtermbutton" )
-    {
-        if ( lst[1]=="true" )
-            config.showtermbutton=true;
-        else
-            config.showtermbutton=false;
-        return;
-    }
-    if ( lst[0]=="showexpbutton" )
-    {
-        if ( lst[1]=="true" )
-            config.showexpbutton=true;
-        else
-            config.showexpbutton=false;
-        return;
-    }
-    if ( lst[0]=="showconfig" )
-    {
-        if ( lst[1]=="true" )
-            config.showconfig=true;
-        else
-            config.showconfig=false;
-        return;
-    }
-    if ( lst[0]=="showextconfig" )
-    {
-        if ( lst[1]=="true" )
-            config.showextconfig=true;
-        else
-            config.showextconfig=false;
-        return;
-    }
-    if ( lst[0]=="showstatusbar" )
-    {
-        if ( lst[1]=="true" )
-            config.showstatusbar=true;
-        else
-            config.showstatusbar=false;
-        return;
-    }
-    if ( lst[0]=="showtoolbar" )
-    {
-        if ( lst[1]=="true" )
-            config.showtoolbar=true;
-        else
-            config.showtoolbar=false;
-        return;
-    }
-
-    if ( lst[0]=="sound" )
-    {
-        config.confSnd=true;
-        if ( lst[1]=="true" )
-            config.useSnd=true;
-        else
-            config.useSnd=false;
-        return;
-    }
-    if ( lst[0]=="exportfs" )
-    {
-        config.confFS=true;
-        if ( lst[1]=="true" )
-            config.useFs=true;
-        else
-            config.useFs=false;
-        return;
-    }
-
-    if ( lst[0]=="speed" )
-    {
-        config.confConSpd=true;
-        config.conSpeed=ADSL;
-
-        if ( lst[1]=="modem" )
-            config.conSpeed=MODEM;
-        else if ( lst[1]=="isdn" )
-            config.conSpeed=ISDN;
-        else if ( lst[1]=="adsl" )
-            config.conSpeed=ADSL;
-        else if ( lst[1]=="wan" )
-            config.conSpeed=WAN;
-        else if ( lst[1]=="lan" )
-            config.conSpeed=LAN;
-        else
-        {
-            qCritical (
-                "%s",tr (
-                    "wrong value for argument\"speed\""
-                ).toLocal8Bit().data() );
-        }
-        return;
-    }
-    if ( lst[0]=="compression" )
-    {
-        config.confCompMet=true;
-        config.compMet=lst[1];
-        return;
-    }
-    if ( lst[0]=="quality" )
-    {
-        config.confImageQ=true;
-        config.imageQ=lst[1].toInt();
-        return;
-    }
-    if ( lst[0]=="dpi" )
-    {
-        config.confDPI=true;
-        config.dpi=lst[1].toInt();
-        return;
-    }
-    if ( lst[0]=="kbdlayout" )
-    {
-        config.confKbd=true;
-        config.kbdLay=lst[1];
-        return;
-    }
-    if ( lst[0]=="kbdtype" )
-    {
-        config.confKbd=true;
-        config.kbdType=lst[1];
-        return;
-    }
-    if ( lst[0]=="brokerurl" )
-    {
-        config.brokerurl=lst[1];
-        managedMode=true;
-        acceptRsa=true;
-    }
-    if ( lst[0]=="proxy" )
-    {
-        config.proxy=sshProxy.host=lst[1];
-        sshProxy.use=true;
-#ifdef Q_OS_WIN
-        sshProxy.bin=cygwinPath ( wapiShortFileName ( appDir ) ) +"/ssh";
-#else
-        sshProxy.bin="ssh";
-#endif
-        return;
-    }
-    if ( lst[0]=="proxysshport" )
-    {
-        config.proxyport=sshProxy.port=lst[1];
-        return;
-    }
-    if ( lst[0]=="cookie" )
-    {
-        config.cookie=lst[1];
-        return;
-    }
-    if ( lst[0]=="x2gosession" )
-    {
-        config.sessiondata=lst[1];
-        return;
-    }
-    if ( lst[0]=="connectionts" )
-    {
-        config.connectionts=lst[1];
-        return;
-    }
-}
-
-void ONMainWindow::slotChangeKbdLayout(const QString& layout)
-{
-#ifdef Q_OS_LINUX
-    QStringList args;
-    args<<"-layout"<<layout;
-    x2goDebug<<"running setxkbmap with params: "<<args.join(" ");
-    QProcess::startDetached("setxkbmap",args);
-#endif
-}
-
-void ONMainWindow::initPassDlg()
-{
-    passForm = new SVGFrame ( ":/svg/passform.svg",
-                              false,bgFrame );
-#ifdef Q_OS_WIN
-    passForm->setMainWidget ( ( QWidget* ) this );
-#endif
-    username->addWidget ( passForm );
-    passForm->hide();
-    setWidgetStyle ( passForm );
-    if ( !miniMode )
-        passForm->setFixedSize ( passForm->sizeHint() );
-    else
-        passForm->setFixedSize ( 310,180 );
-    QPalette pal=passForm->palette();
-    pal.setBrush ( QPalette::Window, QColor ( 255,255,255,0 ) );
-    pal.setColor ( QPalette::Active, QPalette::WindowText, QPalette::Mid );
-    pal.setColor ( QPalette::Active, QPalette::ButtonText, QPalette::Mid );
-    pal.setColor ( QPalette::Active, QPalette::Text, QPalette::Mid );
-    pal.setColor ( QPalette::Inactive, QPalette::WindowText, QPalette::Mid );
-    pal.setColor ( QPalette::Inactive, QPalette::ButtonText, QPalette::Mid );
-    pal.setColor ( QPalette::Inactive, QPalette::Text, QPalette::Mid );
-    passForm->setPalette ( pal );
-
-    pal.setColor ( QPalette::Button, QColor ( 255,255,255,0 ) );
-    pal.setColor ( QPalette::Window, QColor ( 255,255,255,255 ) );
-    pal.setColor ( QPalette::Base, QColor ( 255,255,255,255 ) );
-
-
-    QFont fnt=passForm->font();
-    if ( miniMode )
-#ifdef Q_WS_HILDON
-        fnt.setPointSize ( 10 );
-#else
-        fnt.setPointSize ( 9 );
-#endif
-    passForm->setFont ( fnt );
-
-    fotoLabel=new QLabel ( passForm );
-    fotoLabel->hide();
-
-    nameLabel=new QLabel ( "",passForm );
-    nameLabel->hide();
-
-    loginPrompt=new QLabel ( tr ( "Login:" ),passForm );
-    passPrompt=new QLabel ( tr ( "Password:" ),passForm );
-    layoutPrompt=new QLabel ( tr ( "Keyboard layout:" ),passForm );
-
-    login=new ClickLineEdit ( passForm );
-    setWidgetStyle ( login );
-    login->setFrame ( false );
-    login->setEnabled ( false );
-
-    login->hide();
-    loginPrompt->hide();
-
-    pass=new ClickLineEdit ( passForm );
-    setWidgetStyle ( pass );
-    pass->setFrame ( false );
-    fnt.setBold ( true );
-    pass->setFont ( fnt );
-    pass->setEchoMode ( QLineEdit::Password );
-    pass->setFocus();
-
-#ifdef Q_OS_LINUX
-    connect ( login,SIGNAL ( clicked() ),this,
-              SLOT ( slotActivateWindow() ) );
-    connect ( pass,SIGNAL ( clicked() ),this,
-              SLOT ( slotActivateWindow() ) );
-#endif
-
-    pass->hide();
-    passPrompt->hide();
-
-
-    cbLayout=new QComboBox(passForm);
-    cbLayout->addItems(defaultLayout);
-    cbLayout->setFocusPolicy(Qt::NoFocus);
-    cbLayout->setFrame(false);
-    setWidgetStyle(cbLayout);
-    cbLayout->hide();
-    layoutPrompt->hide();
-    QHBoxLayout* cbLayoutLay=new QHBoxLayout();
-    cbLayoutLay->addWidget(cbLayout);
-    cbLayoutLay->addStretch();
-
-
-    ok=new QPushButton ( tr ( "Ok" ),passForm );
-    setWidgetStyle ( ok );
-    cancel=new QPushButton ( tr ( "Cancel" ),passForm );
-    setWidgetStyle ( cancel );
-    ok->hide();
-    cancel->hide();
-
-
-
-    cbLayout->setPalette ( pal );
-    ok->setPalette ( pal );
-    cancel->setPalette ( pal );
-
-
-
-#ifndef Q_WS_HILDON
-    ok->setFixedSize ( ok->sizeHint() );
-    cancel->setFixedSize ( cancel->sizeHint() );
-#else
-    QSize sz=cancel->sizeHint();
-    sz.setWidth ( ( int ) ( sz.width() /1.5 ) );
-    sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
-    cancel->setFixedSize ( sz );
-    sz=ok->sizeHint();
-    sz.setWidth ( ( int ) ( sz.width() /1.5 ) );
-    sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
-    ok->setFixedSize ( sz );
-#endif
-
-    QVBoxLayout *layout=new QVBoxLayout ( passForm );
-    QHBoxLayout *labelLay=new QHBoxLayout();
-    QHBoxLayout *inputLay=new QHBoxLayout();
-    QHBoxLayout *buttonLay=new QHBoxLayout();
-
-    labelLay->setSpacing ( 20 );
-    inputLay->setSpacing ( 10 );
-    layout->setContentsMargins ( 20,20,10,10 );
-    layout->addLayout ( labelLay );
-    layout->addStretch();
-    layout->addLayout ( inputLay );
-    layout->addStretch();
-    layout->addLayout ( buttonLay );
-
-    labelLay->addWidget ( fotoLabel );
-    labelLay->addWidget ( nameLabel );
-    labelLay->addStretch();
-
-    QVBoxLayout* il1=new QVBoxLayout();
-    il1->addWidget ( loginPrompt );
-    il1->addWidget ( passPrompt );
-    il1->addWidget ( layoutPrompt );
-
-    QVBoxLayout* il2=new QVBoxLayout();
-    il2->addWidget ( login );
-    il2->addWidget ( pass );
-    il2->addLayout ( cbLayoutLay );
-    inputLay->addLayout ( il1 );
-    inputLay->addLayout ( il2 );
-    inputLay->addStretch();
-
-    buttonLay->addStretch();
-    buttonLay->addWidget ( ok );
-    buttonLay->addWidget ( cancel );
-    buttonLay->addStretch();
-
-    pal.setColor ( QPalette::Base, QColor ( 239,239,239,255 ) );
-    login->setPalette ( pal );
-    pass->setPalette ( pal );
-
-    connect ( ok,SIGNAL ( clicked() ),this, SLOT ( slotSessEnter() ) );
-    connect ( cancel,SIGNAL ( clicked() ),this, SLOT ( slotClosePass() ) );
-    connect ( pass,SIGNAL ( returnPressed() ),this,
-              SLOT ( slotSessEnter() ) );
-    connect ( login,SIGNAL ( returnPressed() ),pass, SLOT ( selectAll() ) );
-    connect ( login,SIGNAL ( returnPressed() ),pass, SLOT ( setFocus() ) );
-
-    passPrompt->show();
-    pass->show();
-    ok->show();
-    cancel->show();
-    fotoLabel->show();
-    nameLabel->show();
-    if ( !useLdap )
-    {
-        login->show();
-        loginPrompt->show();
-    }
-    if ( embedMode )
-    {
-        cancel->setEnabled ( false );
-#ifdef Q_OS_WIN
-        QRect r;
-        wapiWindowRect ( ok->winId(),r );
-#endif
-    }
-    if (defaultLayout.size()>1)
-    {
-        layoutPrompt->show();
-        cbLayout->show();
-        slotChangeKbdLayout(cbLayout->currentText());
-        connect (cbLayout,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotChangeKbdLayout(QString)));
-    }
-}
-
-
-void ONMainWindow::initStatusDlg()
-{
-    sessionStatusDlg = new SVGFrame ( ":/svg/passform.svg",
-                                      false,bgFrame );
-    sessionStatusDlg->hide();
-    if ( !miniMode )
-        sessionStatusDlg->setFixedSize (
-            sessionStatusDlg->sizeHint() );
-    else
-        sessionStatusDlg->setFixedSize ( 310,200 );
-    QFont fnt=sessionStatusDlg->font();
-    if ( miniMode )
-#ifdef Q_WS_HILDON
-        fnt.setPointSize ( 10 );
-#else
-        fnt.setPointSize ( 9 );
-#endif
-    sessionStatusDlg->setFont ( fnt );
-    username->addWidget ( sessionStatusDlg );
-    QPalette pal=sessionStatusDlg->palette();
-    pal.setBrush ( QPalette::Window, QColor ( 0,0,0,0 ) );
-    pal.setColor ( QPalette::Active, QPalette::WindowText, QPalette::Mid );
-    pal.setColor ( QPalette::Active, QPalette::ButtonText, QPalette::Mid );
-    pal.setColor ( QPalette::Active, QPalette::Text, QPalette::Mid );
-    pal.setColor ( QPalette::Inactive, QPalette::WindowText, QPalette::Mid );
-    pal.setColor ( QPalette::Inactive, QPalette::ButtonText, QPalette::Mid );
-    pal.setColor ( QPalette::Inactive, QPalette::Text, QPalette::Mid );
-
-    sessionStatusDlg->setPalette ( pal );
-
-    slName=new QLabel ( sessionStatusDlg );
-    slVal=new QLabel ( sessionStatusDlg );
-
-    slName->setText (
-        tr (
-            "<b>Session ID:<br>Server:<br>Username:"
-            "<br>Display:<br>Creation time:<br>Status:</b>" ) );
-    slName->setFixedSize ( slName->sizeHint() );
-    slName->hide();
-
-    slVal->hide();
-    slVal->setFixedHeight ( slName->sizeHint().height() );
-
-    sbApps=new QToolButton (sessionStatusDlg );
-    sbApps->setToolTip(tr ( "Applications..." ));
-    sbApps->setIcon(QPixmap(":/icons/32x32/apps.png"));
-    sbApps->setAutoRaise(true);
-    sbApps->setFocusPolicy(Qt::NoFocus);
-
-    sbExp=new QToolButton (sessionStatusDlg );
-    sbExp->setIcon(QPixmap(":/icons/32x32/open_dir.png"));
-    sbExp->setToolTip (tr ("Share folder..." ));
-    sbExp->setAutoRaise(true);
-    sbExp->setFocusPolicy(Qt::NoFocus);
-
-    sbSusp=new QToolButton (sessionStatusDlg );
-    sbSusp->setIcon(QPixmap(":/icons/32x32/suspend_session.png"));
-    sbSusp->setToolTip(tr ( "Abort" ));
-    sbSusp->setAutoRaise(true);
-    sbSusp->setFocusPolicy(Qt::NoFocus);
-
-
-    sbTerm=new QToolButton (sessionStatusDlg );
-    sbTerm->setIcon(QPixmap(":/icons/32x32/stop_session.png"));
-    sbTerm->setToolTip(tr ( "Terminate" ));
-    sbTerm->setAutoRaise(true);
-    sbTerm->setFocusPolicy(Qt::NoFocus);
-
-
-    sbAdv=new QCheckBox ( tr ( "Show details" ),sessionStatusDlg );
-    setWidgetStyle ( sbTerm );
-    setWidgetStyle ( sbApps );
-    setWidgetStyle ( sbExp );
-    setWidgetStyle ( sbSusp );
-    setWidgetStyle ( sbAdv );
-
-    sbAdv->setFixedSize ( sbAdv->sizeHint() );
-    sbApps->setFixedSize ( 32,32 );
-    sbSusp->setFixedSize ( 32,32 );
-    sbTerm->setFixedSize ( 32,32 );
-    sbExp->setFixedSize ( 32,32 );
-
-    /*
-        sbApps->setFocusPolicy(Qt::NoFocus);
-        sbSusp->setFocusPolicy(Qt::NoFocus);
-        sbTerm->setFocusPolicy(Qt::NoFocus);
-        sbExp->setFocusPolicy(Qt::NoFocus);*/
-
-    sbAdv->hide();
-    sbSusp->hide();
-    sbTerm->hide();
-    sbExp->hide();
-    sbApps->hide();
-
-
-    pal.setColor ( QPalette::Button, QColor ( 255,255,255,0 ) );
-    pal.setColor ( QPalette::Window, QColor ( 255,255,255,255 ) );
-    pal.setColor ( QPalette::Base, QColor ( 255,255,255,255 ) );
-
-    sbAdv->setPalette ( pal );
-    sbApps->setPalette ( pal );
-    sbSusp->setPalette ( pal );
-    sbTerm->setPalette ( pal );
-    sbExp->setPalette ( pal );
-
-    stInfo=new QTextEdit ( sessionStatusDlg );
-    setWidgetStyle ( stInfo );
-    setWidgetStyle ( stInfo->verticalScrollBar() );
-    stInfo->setReadOnly ( true );
-    stInfo->hide();
-    stInfo->setFrameStyle ( QFrame::StyledPanel|QFrame::Plain );
-    stInfo->setPalette ( pal );
-
-    sbExp->setEnabled ( false );
-
-    connect ( sbSusp,SIGNAL ( clicked() ),this,
-              SLOT ( slotTestSessionStatus() ) );
-    connect ( sbTerm,SIGNAL ( clicked() ),this,
-              SLOT ( slotTermSessFromSt() ) );
-    connect ( sbAdv,SIGNAL ( clicked() ),this,
-              SLOT ( slotShowAdvancedStat() ) );
-    connect ( sbExp,SIGNAL ( clicked() ),this,
-              SLOT ( slotExportDirectory() ) );
-    connect ( sbApps,SIGNAL ( clicked() ),this,
-              SLOT ( slotAppDialog()) );
-
-    QVBoxLayout* layout=new QVBoxLayout ( sessionStatusDlg );
-    QHBoxLayout* ll=new QHBoxLayout();
-    ll->addWidget ( slName );
-    ll->addWidget ( slVal );
-    ll->addStretch();
-    ll->setSpacing ( 10 );
-    if ( !miniMode )
-        layout->setContentsMargins ( 25,25,10,10 );
-    else
-        layout->setContentsMargins ( 10,10,10,10 );
-
-    QHBoxLayout* bl=new QHBoxLayout();
-    bl->addStretch();
-    bl->addWidget ( sbApps );
-    bl->addWidget ( sbExp );
-    bl->addWidget ( sbSusp );
-    bl->addWidget ( sbTerm );
-//     bl->addStretch();
-    layout->addLayout ( ll );
-    layout->addStretch();
-    layout->addWidget ( stInfo );
-    layout->addWidget ( sbAdv );
-    layout->addStretch();
-    layout->addLayout ( bl );
-
-
-    slName->show();
-    slVal->show();
-    sbAdv->show();
-    if ( !embedMode )
-    {
-        sbSusp->show();
-        sbTerm->show();
-        sbExp->show();
-    }
-
-    X2goSettings st ( "settings" );
-
-
-    if ( st.setting()->value ( "showStatus", ( QVariant ) false ).toBool() )
-    {
-        sbAdv->setChecked ( true );
-        slotShowAdvancedStat();
-    }
-#ifdef Q_OS_WIN
-    if ( embedMode )
-    {
-        QRect r;
-        wapiWindowRect ( sbAdv->winId(),r );
-        wapiWindowRect ( stInfo->verticalScrollBar ()->winId(),r );
-    }
-#endif
-
-}
-
-
-void ONMainWindow::initSelectSessDlg()
-{
-    selectSessionDlg = new SVGFrame ( ":/svg/passform.svg",
-                                      false,bgFrame );
-    username->addWidget ( selectSessionDlg );
-    setWidgetStyle ( selectSessionDlg );
-    if ( !miniMode )
-        selectSessionDlg->setFixedSize ( selectSessionDlg->sizeHint() );
-    else
-        selectSessionDlg->setFixedSize ( 310,180 );
-    QPalette pal=selectSessionDlg->palette();
-    pal.setBrush ( QPalette::Window, QColor ( 255,255,255,0 ) );
-    pal.setColor ( QPalette::Active, QPalette::WindowText, QPalette::Mid );
-    pal.setColor ( QPalette::Active, QPalette::ButtonText, QPalette::Mid );
-    pal.setColor ( QPalette::Active, QPalette::Text, QPalette::Mid );
-    pal.setColor ( QPalette::Inactive, QPalette::WindowText, QPalette::Mid );
-    pal.setColor ( QPalette::Inactive, QPalette::ButtonText, QPalette::Mid );
-    pal.setColor ( QPalette::Inactive, QPalette::Text, QPalette::Mid );
-
-    selectSessionDlg->setPalette ( pal );
-
-    pal.setColor ( QPalette::Button, QColor ( 255,255,255,0 ) );
-    pal.setColor ( QPalette::Window, QColor ( 255,255,255,255 ) );
-    pal.setColor ( QPalette::Base, QColor ( 255,255,255,255 ) );
-
-    QFont fnt=selectSessionDlg->font();
-    if ( miniMode )
-#ifdef Q_WS_HILDON
-        fnt.setPointSize ( 10 );
-#else
-        fnt.setPointSize ( 9 );
-#endif
-    selectSessionDlg->setFont ( fnt );
-    selectSessionLabel=new QLabel ( tr ( "Select session:" ),
-                                    selectSessionDlg );
-    sOk=new QPushButton ( tr ( "Resume" ),selectSessionDlg );
-    setWidgetStyle ( sOk );
-    sCancel=new QPushButton ( tr ( "Cancel" ),selectSessionDlg );
-    setWidgetStyle ( sCancel );
-    bCancel=new QPushButton ( tr ( "Cancel" ),selectSessionDlg );
-    setWidgetStyle ( bCancel );
-
-    bSusp=new QPushButton ( tr ( "Suspend" ),selectSessionDlg );
-    setWidgetStyle ( bSusp );
-    bTerm=new QPushButton ( tr ( "Terminate" ),selectSessionDlg );
-    setWidgetStyle ( bTerm );
-
-    bNew=new QPushButton ( tr ( "New" ),selectSessionDlg );
-    setWidgetStyle ( bNew );
-
-    bShadow=new QPushButton ( tr ( "Full access" ),selectSessionDlg );
-    setWidgetStyle ( bShadow );
-
-    bShadowView=new QPushButton ( tr ( "View only" ),selectSessionDlg );
-    setWidgetStyle ( bShadowView );
-
-    sOk->setPalette ( pal );
-    sCancel->setPalette ( pal );
-
-    connect ( sCancel,SIGNAL ( clicked() ),this,
-              SLOT ( slotCloseSelectDlg() ) );
-    connect ( bCancel,SIGNAL ( clicked() ),this,
-              SLOT ( slotCloseSelectDlg() ) );
-
-    selectSessionDlg->show();
-#ifndef Q_WS_HILDON
-    sOk->setFixedSize ( ok->sizeHint() );
-    sCancel->setFixedSize ( cancel->sizeHint() );
-#else
-    QSize sz=sCancel->sizeHint();
-    sz.setWidth ( ( int ) ( sz.width() /1.5 ) );
-    sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
-    sCancel->setFixedSize ( sz );
-    sz=sOk->sizeHint();
-    sz.setWidth ( ( int ) ( sz.width() /1.5 ) );
-    sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
-    sOk->setFixedSize ( sz );
-    sz=bSusp->sizeHint();
-    if ( bTerm->sizeHint().width() > sz.width() )
-        sz=bTerm->sizeHint();
-    if ( bNew->sizeHint().width() > sz.width() )
-        sz=bNew->sizeHint();
-    sz.setWidth ( ( int ) ( sz.width() /1.5 ) );
-    sz.setHeight ( ( int ) ( sz.height() /1.5 ) );
-    bSusp->setFixedSize ( sz );
-    bTerm->setFixedSize ( sz );
-    bNew->setFixedSize ( sz );
-#endif
-    int bmaxw=bNew->size().width();
-    if ( bSusp->size().width() >bmaxw )
-        bmaxw=bSusp->size().width();
-    if ( bTerm->size().width() >bmaxw )
-        bmaxw=bTerm->size().width();
-
-    bNew->setFixedWidth ( bmaxw );
-    bSusp->setFixedWidth ( bmaxw );
-    bTerm->setFixedWidth ( bmaxw );
-
-
-
-    sOk->setEnabled ( true );
-    sCancel->setEnabled ( true );
-    selectSessionDlg->setEnabled ( true );
-    setEnabled ( true );
-
-    sessTv=new QTreeView ( selectSessionDlg );
-    setWidgetStyle ( sessTv );
-    setWidgetStyle ( sessTv->horizontalScrollBar() );
-    setWidgetStyle ( sessTv->verticalScrollBar() );
-    sessTv->setItemsExpandable ( false );
-    sessTv->setRootIsDecorated ( false );
-
-    model=new QStandardItemModel ( sessions.size(), 8 );
-    model->setHeaderData ( S_DISPLAY,Qt::Horizontal,
-                           QVariant ( ( QString ) tr ( "Display" ) ) );
-    model->setHeaderData ( S_STATUS,Qt::Horizontal,
-                           QVariant ( ( QString ) tr ( "Status" ) ) );
-    model->setHeaderData ( S_COMMAND,Qt::Horizontal,
-                           QVariant ( ( QString ) tr ( "Command" ) ) );
-    model->setHeaderData ( S_TYPE,Qt::Horizontal,
-                           QVariant ( ( QString ) tr ( "Type" ) ) );
-    model->setHeaderData ( S_SERVER,Qt::Horizontal,
-                           QVariant ( ( QString ) tr ( "Server" ) ) );
-    model->setHeaderData (
-        S_CRTIME,Qt::Horizontal,
-        QVariant ( ( QString ) tr ( "Creation time" ) ) );
-    model->setHeaderData ( S_IP,Qt::Horizontal,
-                           QVariant ( ( QString ) tr ( "Client IP" ) ) );
-    model->setHeaderData ( S_ID,Qt::Horizontal,
-                           QVariant ( ( QString ) tr ( "Session ID" ) ) );
-
-    modelDesktop=new QStandardItemModel ( sessions.size(), 2 );
-    modelDesktop->setHeaderData ( D_USER,Qt::Horizontal,
-                                  QVariant ( ( QString ) tr ( "User" ) ) );
-    modelDesktop->setHeaderData (
-        D_DISPLAY,Qt::Horizontal,
-        QVariant ( ( QString ) tr ( "Display" ) ) );
-
-    sessTv->setModel ( ( QAbstractItemModel* ) model );
-
-    QFontMetrics fm ( sessTv->font() );
-    sessTv->setEditTriggers ( QAbstractItemView::NoEditTriggers );
-    sessTv->setPalette ( pal );
-
-    sessTv->setModel ( ( QAbstractItemModel* ) model );
-
-    bNew->setPalette ( pal );
-    bShadow->setPalette ( pal );
-    bShadowView->setPalette ( pal );
-    bSusp->setPalette ( pal );
-    bTerm->setPalette ( pal );
-    sessTv->setFrameStyle ( QFrame::StyledPanel|QFrame::Plain );
-    sOk->setEnabled ( false );
-    bSusp->setEnabled ( false );
-    bTerm->setEnabled ( false );
-    bShadow->setEnabled ( false );
-    selectSessionLabel->hide();
-    bCancel->setPalette ( pal );
-    bCancel->hide();
-
-    desktopFilter=new QLineEdit ( selectSessionDlg );
-    setWidgetStyle ( desktopFilter );
-// 	desktopFilter->setFrame ( false );
-
-    desktopFilterCb=new QCheckBox ( tr ( "Only my desktops" ),
-                                    selectSessionDlg );
-    desktopFilterCb->hide();
-
-    QVBoxLayout* layout=new QVBoxLayout ( selectSessionDlg );
-    QHBoxLayout* filterLay=new QHBoxLayout();
-    QHBoxLayout* blay=new QHBoxLayout();
-    QVBoxLayout* alay=new QVBoxLayout();
-    QHBoxLayout* tvlay=new QHBoxLayout();
-
-    selectSesDlgLayout=layout;
-
-    layout->addWidget ( selectSessionLabel );
-    layout->addLayout ( filterLay );
-    layout->addLayout ( tvlay );
-    layout->addLayout ( blay );
-
-    filterLay->addWidget ( desktopFilter );
-    filterLay->addWidget ( desktopFilterCb );
-
-    alay->addWidget ( bSusp );
-    alay->addWidget ( bTerm );
-    alay->addWidget ( bShadowView );
-    alay->addWidget ( bShadow );
-    alay->addStretch();
-    alay->addWidget ( bNew );
-    alay->addWidget ( bCancel );
-
-    tvlay->addWidget ( sessTv );
-    tvlay->addLayout ( alay );
-
-    blay->addStretch();
-    blay->addWidget ( sOk );
-    blay->addWidget ( sCancel );
-    blay->addStretch();
-    if ( !miniMode )
-        layout->setContentsMargins ( 25,25,10,10 );
-    else
-        layout->setContentsMargins ( 10,10,10,10 );
-
-
-
-    sOk->hide();
-    sCancel->hide();
-    bNew->hide();
-    bSusp->hide();
-    bTerm->hide();
-
-    connect ( sessTv,SIGNAL ( clicked ( const QModelIndex& ) ),
-              this,SLOT ( slotActivated ( const QModelIndex& ) ) );
-
-    connect ( sessTv,SIGNAL ( doubleClicked ( const QModelIndex& ) ),
-              this,SLOT ( slotResumeDoubleClick ( const QModelIndex& ) ) );
-
-    connect ( sOk,SIGNAL ( clicked() ),this, SLOT ( slotResumeSess() ) );
-    connect ( bSusp,SIGNAL ( clicked() ),this, SLOT ( slotSuspendSess() ) );
-    connect ( bTerm,SIGNAL ( clicked() ),this, SLOT ( slotTermSess() ) );
-    connect ( bNew,SIGNAL ( clicked() ),this, SLOT ( slotNewSess() ) );
-
-    connect ( bShadow,SIGNAL ( clicked() ),this,
-              SLOT ( slotShadowSess() ) );
-    connect ( bShadowView,SIGNAL ( clicked() ),this,
-              SLOT ( slotShadowViewSess() ) );
-
-    connect ( desktopFilter,SIGNAL ( textEdited ( const QString& ) ),this,
-              SLOT ( slotDesktopFilterChanged ( const QString& ) ) );
-    connect ( desktopFilterCb,SIGNAL ( stateChanged ( int ) ),
-              this,
-              SLOT ( slotDesktopFilterCb ( int ) ) );
-
-    selectSessionLabel->show();
-    sOk->show();
-    sCancel->show();
-    bNew->show();
-    bSusp->show();
-    bTerm->show();
-    sessTv->show();
-    selectSessionDlg->hide();
-#ifdef Q_OS_WIN
-    if ( embedMode )
-    {
-        QRect r;
-        wapiWindowRect ( sOk->winId(),r );
-        wapiWindowRect ( sessTv->verticalScrollBar ()->winId(),r );
-        wapiWindowRect ( sessTv->horizontalScrollBar ()->winId(),r );
-        wapiWindowRect ( sessTv->header ()->viewport()->winId(),r );
-    }
-#endif
-
-}
-
-
-
-void ONMainWindow::printSshDError()
-{
-    if ( closeEventSent )
-        return;
-    QMessageBox::critical ( 0l,tr ( "Error" ),
-                            tr ( "sshd not started, "
-                                 "you'll need sshd for printing "
-                                 "and file sharing\n"
-                                 "you can install sshd with\n"
-                                 "<b>sudo apt-get install "
-                                 "openssh-server</b>" ),
-                            QMessageBox::Ok,QMessageBox::NoButton );
-}
-
-void ONMainWindow::slotStartParec ()
-{
-    if ( !parecTunnelOk )
-    {
-// 		wait 1 sec and try again
-        QTimer::singleShot ( 1000, this, SLOT ( slotStartParec() ) );
-        return;
-    }
-    SshProcess* paProc;
-    QString passwd=getCurrentPass();
-    QString user=getCurrentUname();
-    QString host=resumingSession.server;
-    QString scmd="PULSE_CLIENTCONFIG=~/.x2go/C-"+
-                 resumingSession.sessionId+
-                 "/.pulse-client.conf "+
-                 "parec > /dev/null &sleep 1 && kill %1";
-
-    paProc=new SshProcess ( sshConnection, this );
-    paProc->startNormal ( scmd );
-}
-
-
-void ONMainWindow::slotSndTunOk()
-{
-    parecTunnelOk=true;
-}
-
-
-void ONMainWindow::slotPCookieReady (	bool result,
-                                      QString ,
-                                      SshProcess* )
-{
-    if ( result )
-        slotStartParec();
-}
-
-
-void ONMainWindow::loadPulseModuleNativeProtocol()
-{
-    QProcess* proc=new QProcess ( this );
-    QStringList args;
-    args<<"load-module"<<"module-native-protocol-tcp";
-    proc->start ( "pactl",args );
-    proc->waitForFinished ( 3000 );
-}
-
-void ONMainWindow::slotEmbedToolBar()
-{
-    if ( statusLabel )
-    {
-        delete statusLabel;
-        statusLabel=0;
-    }
-    if ( embedTbVisible )
-    {
-        stb->clear();
-        act_embedToolBar->setIcon (
-            QIcon ( ":icons/16x16/tbshow.png" ) );
-        stb->addAction ( act_embedToolBar );
-        stb->setToolButtonStyle ( Qt::ToolButtonIconOnly );
-        stb->widgetForAction (
-            act_embedToolBar )->setFixedHeight ( 16 );
-        act_embedToolBar->setText ( tr ( "Restore toolbar" ) );
-        statusLabel=new QLabel;
-        stb->addWidget ( statusLabel );
-#ifndef Q_OS_WIN
-        statusBar()->hide();
-#endif
-    }
-    else
-    {
-        initEmbedToolBar();
-        act_embedToolBar->setIcon (
-            QIcon ( ":icons/32x32/tbhide.png" ) );
-        act_embedToolBar->setText ( tr ( "Minimize toolbar" ) );
-    }
-    embedTbVisible=!embedTbVisible;
-    if ( proxyWinEmbedded )
-        setStatStatus();
-    X2goSettings st ( "sessions" );
-    st.setting()->setValue ( "embedded/tbvisible", embedTbVisible );
-    st.setting()->sync();
-}
-
-void ONMainWindow::initEmbedToolBar()
-{
-    stb->addAction ( act_embedToolBar );
-    stb->addSeparator();
-    stb->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon );
-    stb->addAction ( act_shareFolder );
-    stb->addAction ( act_reconnect );
-    stb->addAction ( act_suspend );
-    stb->addAction ( act_terminate );
-    stb->addSeparator();
-    stb->addAction ( act_embedContol );
-    stb->addSeparator();
-    stb->addAction ( act_set );
-    stb->addAction ( act_abclient );
-}
-
-void ONMainWindow::slotEmbedToolBarToolTip()
-{
-    if ( !showTbTooltip )
-        return;
-    QWidget* widg=stb->widgetForAction (
-                      act_embedToolBar );
-    QToolTip::showText ( this->mapToGlobal ( QPoint ( 6,6 ) ),
-                         tr ( "<br><b>   Click this "
-                              "button   <br>"
-                              "   to restore toolbar"
-                              "   </b><br>" ),
-                         widg );
-}
-
-
-void ONMainWindow::slotActivateWindow()
-{
-    if ( embedMode )
-    {
-        QApplication::setActiveWindow ( this ) ;
-        activateWindow();
-
-        /*		x2goDebug<<"focus:"<<pass->hasFocus();
-        		x2goDebug<<"activ:"<<pass->isActiveWindow();*/
-        QTimer::singleShot ( 50, this,
-                             SLOT ( slotEmbedToolBarToolTip() ) );
-    }
-}
-
-#ifndef Q_OS_WIN
-void ONMainWindow::mouseReleaseEvent ( QMouseEvent * event )
-{
-    QMainWindow::mouseReleaseEvent ( event );
-    slotActivateWindow();
-}
-#endif
-
-void ONMainWindow::slotHideEmbedToolBarToolTip()
-{
-    showTbTooltip=false;
-    QToolTip::hideText();
-}
-
-
-void ONMainWindow::slotDesktopFilterChanged ( const QString& text )
-{
-    filterDesktops ( text );
-}
-
-
-void ONMainWindow::slotDesktopFilterCb ( int state )
-{
-    if ( state==Qt::Checked )
-    {
-        filterDesktops ( getCurrentUname(),true );
-        desktopFilter->setEnabled ( false );
-    }
-    else
-    {
-        filterDesktops ( desktopFilter->text() );
-        desktopFilter->setEnabled ( true );
-    }
-}
-
-
-void ONMainWindow::filterDesktops ( const QString& filter, bool strict )
-{
-    modelDesktop->setRowCount ( 0 );
-    bShadow->setEnabled ( false );
-    bShadowView->setEnabled ( false );
-    QFontMetrics fm ( sessTv->font() );
-    uint nextRow=0;
-    for ( int row = 0; row < selectedDesktops.size(); ++row )
-    {
-        QStringList desktop=selectedDesktops[row].split ( "@" );
-        if ( filter==tr ( "Filter" ) ||filter.length() <=0||
-                ( strict && desktop[0]==filter )  ||
-                ( !strict && desktop[0].startsWith ( filter ) ) )
-        {
-            QStandardItem *item;
-            item= new QStandardItem ( desktop[0] );
-            modelDesktop->setItem ( nextRow,D_USER,item );
-            item= new QStandardItem ( desktop[1] );
-            modelDesktop->setItem ( nextRow++,D_DISPLAY,item );
-            for ( int j=0;j<2;++j )
-            {
-                QString txt=
-                    modelDesktop->index (
-                        row,j ).data().toString();
-                if ( sessTv->header()->sectionSize ( j ) <
-                        fm.width ( txt ) +6 )
-                {
-                    sessTv->header()->resizeSection (
-                        j,fm.width ( txt ) +6 );
-                }
-            }
-        }
-    }
-}
-
-
-void ONMainWindow::slotShadowSess()
-{
-    shadowMode=SHADOW_FULL;
-    slotShadowViewSess();
-}
-
-void ONMainWindow::slotShadowViewSess()
-{
-    shadowUser=sessTv->model()->index ( sessTv->currentIndex().row(),
-                                        D_USER ).data().toString();
-    shadowDisplay=sessTv->model()->index ( sessTv->currentIndex().row(),
-                                           D_DISPLAY ).data().toString();
-    startNewSession();
-}
-
-
-void ONMainWindow::slotReconnectSession()
-{
-    if ( !managedMode )
-        slotSelectedFromList ( ( SessionButton* ) 0 );
-    else
-    {
-        broker->getSInfoFromBroker();
-        setEnabled ( false );
-    }
-}
-
-
-QSize ONMainWindow::getEmbedAreaSize()
-{
-    if ( embedTbVisible && config.showstatusbar )
-        statusBar()->show();
-    QSize sz=bgFrame->size();
-//     sz.setHeight(sz.height()-statusBar()->size().height());
-    statusBar()->hide();
-    return sz;
-}
-
-
-void ONMainWindow::slotStartBroker()
-{
-    config.brokerPass=pass->text();
-    config.brokerUser=login->text();
-    setStatStatus ( tr ( "Connecting to broker" ) );
-    stInfo->insertPlainText ( "broker url: "+config.brokerurl );
-    setEnabled ( false );
-    broker->getUserSessions();
-}
-
-void ONMainWindow::slotGetBrokerSession(const QString& sinfo)
-{
-    //x2goDebug<<"broker session: "<<sinfo;
-    QStringList lst=sinfo.split("SERVER:",QString::SkipEmptyParts);
-    int keyStartPos=sinfo.indexOf("-----BEGIN DSA PRIVATE KEY-----");
-    QString endStr="-----END DSA PRIVATE KEY-----";
-    int keyEndPos=sinfo.indexOf(endStr);
-    if (! (keyEndPos == -1 || keyStartPos == -1 || lst.size()==0))
-        config.key=sinfo.mid(keyStartPos, keyEndPos+endStr.length()-keyStartPos);
-    QString serverLine=(lst[1].split("\n"))[0];
-    QStringList words=serverLine.split(":",QString::SkipEmptyParts);
-    config.server=words[0];
-    if (words.count()>1)
-        config.sshport=words[1];
-//    x2goDebug<<"server: "<<config.server<<endl<<" key: "<<config.key;
-    if (sinfo.indexOf("SESSION_INFO")!=-1)
-    {
-        QStringList lst=sinfo.split("SESSION_INFO:",QString::SkipEmptyParts);
-        config.sessiondata=(lst[1].split("\n"))[0];
-// 	x2goDebug<<"data: "<<config.sessiondata;
-    }
-    slotSessEnter();
-}
-
-void ONMainWindow::slotStartNewBrokerSession ( )
-{
-    if ( managedMode )
-    {
-        setEnabled ( true );
-        slotSelectedFromList ( ( SessionButton* ) 0 );
-    }
-}
-
-#ifdef Q_OS_WIN
-QString ONMainWindow::u3DataPath()
-{
-    QStringList env=QProcess::systemEnvironment();
-    QString dpath;
-    for ( int i=0;i<env.size();++i )
-    {
-// 		x2goDebug << env[i];
-        //check if we have U3 System
-        if ( env[i].indexOf ( "U3_APP_DATA_PATH=" ) ==0 )
-        {
-            dpath=env[i];
-        }
-        if ( env[i].indexOf ( "U3_DEVICE_PATH=" ) ==0 )
-        {
-            u3Device=env[i];
-            u3Device.replace ( "U3_DEVICE_PATH=","" );
-        }
-
-    }
-
-    if ( dpath.length() >0 )
-    {
-        dpath.replace ( "U3_APP_DATA_PATH=","" );
-        portableDataPath=dpath;
-        return dpath;
-    }
-    return QString::null;
-}
-
-#endif
-
-void ONMainWindow::cleanPortable()
-{
-    removeDir ( homeDir +"/.ssh" );
-    removeDir ( homeDir +"/ssh" );
-    removeDir ( homeDir+"/.x2go" );
-    if (cleanAllFiles)
-        removeDir(homeDir+"/.x2goclient");
-}
-
-void ONMainWindow::removeDir ( QString path )
-{
-    x2goDebug<<"entering " <<path;
-    QDir dr ( path );
-    QStringList files=dr.entryList ( QDir::Files );
-    for ( int i=0;i<files.size();++i )
-    {
-        if ( files[i]!="known_hosts" || cleanAllFiles)
-        {
-            x2goDebug<<"cleaning file:"<<path+"/"+files[i];
-            dr.remove ( path+"/"+files[i] );
-        }
-    }
-    QStringList dirs=dr.entryList ( QDir::AllDirs|QDir::NoDotAndDotDot );
-    for ( int i=0;i<dirs.size();++i )
-    {
-        removeDir ( path+"/"+dirs[i] );
-    }
-    dr.rmdir ( path );
-}
-
-#ifdef Q_OS_LINUX
-long ONMainWindow::X11FindWindow ( QString text, long rootWin )
-{
-    Window    wParent;
-    Window    wRoot;
-    Window   *child_list;
-    unsigned  nChildren;
-    long proxyId=0;
-    if ( !rootWin )
-        rootWin= XDefaultRootWindow ( QX11Info::display() );
-
-    if ( XQueryTree ( QX11Info::display(),rootWin,&wRoot,&wParent,
-                      &child_list,&nChildren ) )
-    {
-        for ( uint i=0;i<nChildren;++i )
-        {
-            char *wname;
-            if ( XFetchName ( QX11Info::display(),
-                              child_list[i],&wname ) )
-            {
-                QString title ( wname );
-                XFree ( wname );
-                if ( title==text )
-                {
-                    proxyId=child_list[i];
-                    break;
-                }
-            }
-            proxyId=X11FindWindow ( text, child_list[i] );
-            if ( proxyId )
-                break;
-        }
-        XFree ( child_list );
-    }
-    return proxyId;
-}
-#endif
-
-long ONMainWindow::findWindow ( QString text )
-{
-#ifdef Q_OS_LINUX
-    return X11FindWindow ( text );
-#endif
-#ifdef Q_OS_WIN
-    return ( long ) wapiFindWindow ( 0,text.utf16() );
-#endif
-}
-
-//////////////////////////plugin stuff//////////////
-
-#ifdef CFGPLUGIN
-void ONMainWindow::setX2goconfig ( const QString& text )
-{
-    m_x2goconfig=text;
-    x2goDebug<<"have session config";
-    initWidgetsEmbed();
-}
-
-void ONMainWindow::doPluginInit()
-{
-#ifdef Q_OS_LINUX
-    Dl_info info;
-    dladdr ( ( void* ) & ( ONMainWindow::getPortable ),&info );
-    QString fname=info.dli_fname;
-    x2goDebug<<"Application name:" <<fname;
-    QString clientDir;
-    QString pluginDir;
-    int pos=fname.lastIndexOf ( "/" );
-    pluginDir=fname.left ( pos );
-    x2goDebug<<"Plugin Dir:" <<pluginDir;
-    QDir dr ( pluginDir );
-    if ( dr.exists ( "x2goclient/x2goclient" ) )
-    {
-        clientDir=pluginDir+"/x2goclient";
-    }
-    else if ( dr.exists ( "x2goclient" ) )
-    {
-        clientDir=pluginDir;
-    }
-    else
-    {
-        dr.cdUp();
-        if ( dr.exists ( "x2goclient/x2goclient" ) )
-        {
-            clientDir=dr.absolutePath() +"/x2goclient";
-        }
-        else if ( dr.exists ( "x2goclient" ) )
-        {
-            clientDir=dr.absolutePath();
-        }
-        else
-        {
-            clientDir=pluginDir;
-        }
-    }
-    x2goDebug<<"Client Dir:"<<clientDir;
-    QString path=getenv ( "PATH" );
-    path=clientDir+":"+pluginDir+":"+path;
-    setenv ( "PATH",path.toAscii (),1 );
-
-    path=getenv ( "LD_LIBRARY_PATH" );
-    path=clientDir+":"+pluginDir+":"+path;
-    setenv ( "LD_LIBRARY_PATH",path.toAscii () ,1 );
-
-    setenv ( "X2GO_LIB",clientDir.toAscii () ,1 );
-
-    QFile::setPermissions (
-        clientDir+"/x2goclient",
-        QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner|
-        QFile::ReadGroup|QFile::WriteGroup|QFile::ExeGroup|
-        QFile::ReadOther|QFile::WriteOther|QFile::ExeOther );
-    QFile::setPermissions (
-        clientDir+"/nxproxy",
-        QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner|
-        QFile::ReadGroup|QFile::WriteGroup|QFile::ExeGroup|
-        QFile::ReadOther|QFile::WriteOther|QFile::ExeOther );
-    QFile::setPermissions (
-        clientDir+"/sshd",
-        QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner|
-        QFile::ReadGroup|QFile::WriteGroup|QFile::ExeGroup|
-        QFile::ReadOther|QFile::WriteOther|QFile::ExeOther );
-    QFile::setPermissions (
-        clientDir+"/sftp-server",
-        QFile::ReadOwner|QFile::WriteOwner|QFile::ExeOwner|
-        QFile::ReadGroup|QFile::WriteGroup|QFile::ExeGroup|
-        QFile::ReadOther|QFile::WriteOther|QFile::ExeOther );
-
-#endif
-}
-
-
-#ifndef Q_OS_DARWIN
-
-
-QSize ONMainWindow::getWindowSize ( long winId )
-{
-
-#ifdef Q_OS_LINUX
-    XWindowAttributes atr;
-    if ( XGetWindowAttributes ( QX11Info::display(),winId,&atr ) )
-        return QSize ( atr.width,atr.height );
-    return QSize ( 0,0 );
-#endif
-#ifdef Q_OS_WIN
-    QRect rec;
-    if ( wapiClientRect ( ( HWND ) winId,rec ) )
-        return rec.size();
-    else
-        return QSize ( 0,0 );
-#endif
-}
-
-#ifdef Q_OS_WIN
-void ONMainWindow::slotUpdateEmbedWindow()
-{
-    if ( oldContainerSize!=embedContainer->size() ||
-            oldChildPos!= mapToGlobal (
-                QPoint ( 0,0 ) ) )
-    {
-        QRect geom=embedContainer->geometry();
-        if ( gcor==1 )
-            gcor=0;
-        else
-            gcor=1;
-        geom.setWidth ( geom.width()-gcor );
-        wapiSetFSWindow ( ( HWND ) childId,
-                          geom );
-        wapiUpdateWindow ( ( HWND ) childId );
-        oldContainerSize=embedContainer->size();
-        oldChildPos= mapToGlobal (
-                         QPoint ( 0,0 ) );
-        x2goDebug<<"updating embedded window"<<endl;
-    }
-}
-
-#endif
-
-
-
-void ONMainWindow::embedWindow ( long wndId )
-{
-    childId=wndId;
-    embedContainer->show();
-#ifdef Q_OS_LINUX
-    x2goDebug<<"embedding "<<wndId<<" in container"<<endl;
-    embedContainer->embedClient ( wndId );
-#endif
-#ifdef Q_OS_WIN
-    wapiSetParent ( ( HWND ) childId,
-                    ( HWND ) ( embedContainer->winId() ) );
-    oldContainerSize=embedContainer->size();
-    oldChildPos= ( mapToGlobal ( QPoint ( 0,0 ) ));
-    winFlags=wapiSetFSWindow ( ( HWND ) childId,
-                               embedContainer->geometry() );
-    updateTimer->start ( 500 );
-
-#endif
-}
-
-
-void ONMainWindow::detachClient()
-{
-    if ( !childId )
-        return;
-#ifdef Q_OS_LINUX
-    if ( embedContainer )
-    {
-        embedContainer->discardClient();
-    }
-#endif
-#ifdef Q_OS_WIN
-    wapiSetParent ( ( HWND ) childId, ( HWND ) 0 );
-    slotDetachProxyWindow();
-    updateTimer->stop();
-    if ( childId )
-    {
-        wapiRestoreWindow ( ( HWND ) childId, winFlags,
-                            embedContainer->geometry() );
-        wapiMoveWindow ( ( HWND ) childId,0,0,
-                         oldContainerSize.width(),
-                         oldContainerSize.height(),true );
-
-    }
-#endif
-    childId=0;
-}
-
-#endif //(Q_OS_DARWIN)
-
-
-
-
-
-QTNPFACTORY_BEGIN ( "X2GoClient Plug-in "VERSION,
-                    "Allows you to start X2Go session in a webbrowser" )
-QTNPCLASS ( ONMainWindow )
-QTNPFACTORY_END()
-
-#ifdef QAXSERVER
-#include <ActiveQt/QAxFactory>
-QAXFACTORY_BEGIN ( "{aa3216bf-7e20-482c-84c6-06167bacb616}", "{08538ca5-eb7a-4f24-a3c4-a120c6e04dc4}" )
-QAXCLASS ( ONMainWindow )
-QAXFACTORY_END()
-#endif
-#endif
diff --git a/onmainwindow_privat.h b/onmainwindow_privat.h
index 33a8bc4..1d6266d 100644
--- a/onmainwindow_privat.h
+++ b/onmainwindow_privat.h
@@ -144,6 +144,7 @@
 
 #ifdef Q_OS_WIN
 #include "wapi.h"
+#include <QHostInfo>
 #endif
 
 #ifdef Q_OS_LINUX
diff --git a/resources.rcc b/resources.rcc
index 4263b23..3953a75 100644
--- a/resources.rcc
+++ b/resources.rcc
@@ -54,6 +54,7 @@
        <file>icons/16x16/delete.png</file>
        <file>icons/16x16/edit.png</file>
        <file>icons/16x16/gnome.png</file>
+       <file>icons/16x16/unity.png</file>
        <file>icons/16x16/kde.png</file>
        <file>icons/16x16/new_file.png</file>
        <file>icons/16x16/resolution.png</file>
diff --git a/sessionbutton.cpp b/sessionbutton.cpp
index 63be020..f53d82a 100644
--- a/sessionbutton.cpp
+++ b/sessionbutton.cpp
@@ -337,6 +337,7 @@ void SessionButton::redraw()
     cmdBox->addItem ( "KDE" );
     cmdBox->addItem ( "GNOME" );
     cmdBox->addItem ( "LXDE" );
+    cmdBox->addItem ( "UNITY" );
     cmdBox->addItem ( tr ( "RDP connection" ) );
     cmdBox->addItem ( tr ( "XDMCP" ) );
     cmdBox->addItem ( tr ( "Connection to local desktop" ) );
@@ -355,6 +356,11 @@ void SessionButton::redraw()
         cmdpix.load ( par->iconsPath ( "/16x16/gnome.png" ) );
         cmdBox->setCurrentIndex ( GNOME );
     }
+    else if ( command =="UNITY" )
+    {
+        cmdpix.load ( par->iconsPath ( "/16x16/unity.png" ) );
+        cmdBox->setCurrentIndex ( UNITY );
+    }
     else if ( command =="LXDE" )
     {
         cmdpix.load ( par->iconsPath ( "/16x16/lxde.png" ) );
@@ -631,6 +637,11 @@ void SessionButton::slot_cmd_change ( const QString& command )
         newRootless=false;
         pix.load ( par->iconsPath ( "/16x16/lxde.png" ) );
     }
+    else if ( command =="UNITY" )
+    {
+        newRootless=false;
+        pix.load ( par->iconsPath ( "/16x16/unity.png" ) );
+    }
     else if ( command ==tr ( "Connection to local desktop" ) )
     {
         newRootless=false;
@@ -669,6 +680,11 @@ void SessionButton::slot_cmd_change ( const QString& command )
         cmd="LXDE";
         newRootless=false;
     }
+    if ( command=="unity" )
+    {
+        cmd="UNITY";
+        newRootless=false;
+    }
     if (command== tr("Published applications"))
     {
         published=true;
diff --git a/sessionbutton.h b/sessionbutton.h
index a12aaf6..c5eea1e 100644
--- a/sessionbutton.h
+++ b/sessionbutton.h
@@ -26,7 +26,7 @@ class SessionButton : public SVGFrame
 {
     Q_OBJECT
 public:
-    enum {KDE,GNOME,LXDE,RDP,XDMCP,SHADOW,PUBLISHED,OTHER,APPLICATION};
+    enum {KDE,GNOME,UNITY,LXDE,RDP,XDMCP,SHADOW,PUBLISHED,OTHER,APPLICATION};
     SessionButton ( ONMainWindow* mw, QWidget* parent,QString id );
     ~SessionButton();
     QString id() {
diff --git a/sessionwidget.cpp b/sessionwidget.cpp
index 6e12843..2f66aa2 100644
--- a/sessionwidget.cpp
+++ b/sessionwidget.cpp
@@ -124,6 +124,7 @@ SessionWidget::SessionWidget ( QString id, ONMainWindow * mw,
     sessBox->addItem ( "KDE" );
     sessBox->addItem ( "GNOME" );
     sessBox->addItem ( "LXDE" );
+    sessBox->addItem ( "UNITY" );
     sessBox->addItem ( tr ( "Connect to Windows terminal server" ) );
     sessBox->addItem ( tr ( "XDMCP" ) );
     sessBox->addItem ( tr ( "Connect to local desktop" ) );
@@ -391,6 +392,11 @@ void SessionWidget::readConfig()
             sessBox->setCurrentIndex ( LXDE );
             cmd->setEnabled ( false );
         }
+        else if ( command=="UNITY" )
+        {
+            sessBox->setCurrentIndex ( UNITY );
+            cmd->setEnabled ( false );
+        }
         else if ( command=="SHADOW" )
         {
             sessBox->setCurrentIndex ( SHADOW );
diff --git a/sessionwidget.h b/sessionwidget.h
index 5dd0bd4..869d9bb 100644
--- a/sessionwidget.h
+++ b/sessionwidget.h
@@ -40,7 +40,7 @@ private slots:
     void slot_rdpOptions();
 
 private:
-    enum {KDE,GNOME,LXDE,RDP,XDMCP,SHADOW,OTHER,APPLICATION,PUBLISHED};
+    enum {KDE,GNOME,LXDE,UNITY,RDP,XDMCP,SHADOW,OTHER,APPLICATION,PUBLISHED};
     QLineEdit* sessName;
     QLineEdit* uname;
     QLineEdit* server;
diff --git a/sshmasterconnection.cpp b/sshmasterconnection.cpp
index 1f7b724..9eba130 100644
--- a/sshmasterconnection.cpp
+++ b/sshmasterconnection.cpp
@@ -1,7 +1,7 @@
 
 /***************************************************************************
- *   Copyright (C) 2005-2012 by Oleksandr Shneyder   *
- *   oleksandr.shneyder at obviously-nice.de   *
+ *   Copyright (C) 2005-2012 by Oleksandr Shneyder                         *
+ *   oleksandr.shneyder at obviously-nice.de                                  *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -46,6 +46,9 @@
 #undef DEBUG
 //#define DEBUG
 
+//#define SSH_DEBUG
+#undef SSH_DEBUG
+
 static bool isLibSshInited=false;
 
 
@@ -142,7 +145,12 @@ void SshMasterConnection::run()
     }
 #endif
 
-//     int verbosity=SSH_LOG_PROTOCOL;
+#ifdef SSH_DEBUG
+    int verbosity=SSH_LOG_PACKET;
+#else
+    int verbosity=SSH_LOG_NOLOG;
+#endif
+
     long timeout = 60;
 
     my_ssh_session = ssh_new();
@@ -159,7 +167,7 @@ void SshMasterConnection::run()
 #ifdef Q_OS_WIN
     ssh_options_set ( my_ssh_session, SSH_OPTIONS_SSH_DIR, (mainWnd->getHomeDirectory()+"/ssh").toAscii());
 #endif
-//     ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
+    ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
 
     ssh_options_set(my_ssh_session, SSH_OPTIONS_TIMEOUT, &timeout);
 
@@ -277,7 +285,8 @@ void SshMasterConnection::finalizeLibSsh()
 bool SshMasterConnection::sshConnect()
 {
     int rc;
-    ssh_options_set ( my_ssh_session, SSH_OPTIONS_HOST, host.toAscii() );
+    QByteArray tmpBA = host.toLocal8Bit();
+    ssh_options_set ( my_ssh_session, SSH_OPTIONS_HOST, tmpBA.data() );
     ssh_options_set ( my_ssh_session, SSH_OPTIONS_PORT, &port );
     rc = ssh_connect ( my_ssh_session );
     if ( rc != SSH_OK )
diff --git a/svg/unity.svg b/svg/unity.svg
new file mode 100644
index 0000000..5c1f9cf
--- /dev/null
+++ b/svg/unity.svg
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.1" width="60.513618" height="60.513618" id="svg3036" style="display:inline">
+ <g transform="translate(-1.7431908,-1.4941635)" id="layer1" style="display:inline">
+  <path d="M 30.25,0 C 13.539626,0 0,13.539626 0,30.25 0,46.960374 13.539626,60.5 30.25,60.5 46.960374,60.5 60.5,46.960374 60.5,30.25 c 0,-2.078212 -0.194675,-4.102133 -0.59375,-6.0625 -0.304345,1.200557 -0.637476,2.348209 -1,3.46875 -0.410672,1.260002 -0.836505,2.461168 -1.3125,3.5625 -0.186671,0.419999 -0.388421,0.763832 -0.59375,1.0625 -0.196003,0.307998 -0.413587,0.553998 -0.65625,0.75 -0.242669,0.195998 -0.535753,0.344164 -0.84375,0.4375 -0.298669,0.09333 -0.617335,0.156247 -1,0.15625 -0.102668,-3e-6 -0.231751,-0.01259 -0.34375,-0.03125 -0.112001,-0.0093 -0.200501,-0.0345 -0.3125,-0.0625 -0.102667,-0.01867 -0.219167,-0.0345 -0.3125,-0.0625 -0.084,-0.028 -0.150167,-0.04384 -0.1875,-0.0625 l 0.25,-1.0625 c 0.102666,0.04666 0.247583,0.08767 0.40625,0.125 0.167999,0.04666 0.310082,0.0625 0.46875,0.0625 0.513332,-2e-6 0.929415,-0.110418 1.21875,-0.34375 0.289331,-0.224001 0.547914,-0.580417 0.78125,-1.09375 -0.588003,-1.119999 -1.142919,-2.311831 -1.65625,-3.5625 -0.504001,-
 1.259995 -0.914001,-2.524494 -1.25,-3.8125 l 1.375,0 c 0.102665,0.420007 0.234998,0.858423 0.375,1.34375 0.149331,0.485339 0.322664,0.986672 0.5,1.5 0.177331,0.513337 0.357164,1.01792 0.5625,1.53125 0.20533,0.513336 0.432246,1.024002 0.65625,1.5 0.354663,-0.979998 0.644912,-1.944913 0.90625,-2.90625 0.261328,-0.961328 0.516662,-1.95141 0.75,-2.96875 l 1.125,0 C 56.82527,10.149634 44.716711,0 30.25,0 z m 29.5625,23.71875 c 0.03198,0.145258 0.06387,0.291467 0.09375,0.4375 0.03784,-0.149571 0.08807,-0.286689 0.125,-0.4375 l -0.21875,0 z M 45.78125,20.6875 c 0.233331,10e-6 0.435081,0.06009 0.59375,0.21875 0.167997,0.149343 0.249997,0.363676 0.25,0.625 -3e-6,0.261343 -0.082,0.466342 -0.25,0.625 -0.158669,0.149342 -0.360419,0.218759 -0.59375,0.21875 -0.233335,9e-6 -0.425751,-0.06941 -0.59375,-0.21875 -0.158668,-0.158658 -0.218751,-0.363657 -0.21875,-0.625 -10e-7,-0.261324 0.06008,-0.475657 0.21875,-0.625 0.167999,-0.158656 0.360415,-0.21874 0.59375,-0.21875 z m 4.1875,0.75 0,2.281
 25 2.78125,0 0,1.09375 -2.78125,0 0,3.34375 c -2e-6,0.364002 0.03775,0.663585 0.09375,0.90625 0.056,0.233335 0.137997,0.422501 0.25,0.5625 0.111997,0.130668 0.269497,0.225251 0.4375,0.28125 0.167997,0.056 0.338497,0.09375 0.5625,0.09375 0.391996,1e-6 0.704162,-0.041 0.9375,-0.125 0.242662,-0.09333 0.406662,-0.181415 0.5,-0.21875 L 53.03125,30.75 c -0.130672,0.06533 -0.360838,0.156667 -0.6875,0.25 -0.326671,0.102667 -0.705004,0.125 -1.125,0.125 -0.49467,0 -0.923336,-0.03492 -1.25,-0.15625 C 49.651415,30.838083 49.414748,30.627 49.21875,30.375 49.022749,30.123001 48.865249,29.832751 48.78125,29.46875 48.70658,29.095419 48.6875,28.672836 48.6875,28.1875 l 0,-6.5 1.28125,-0.25 z m -38.9375,1.90625 5.1875,0 0,15.25 c -9e-6,3.546677 0.56749,6.063091 1.6875,7.59375 1.119988,1.530671 3.005569,2.312504 5.65625,2.3125 0.559983,4e-6 1.152649,-0.02516 1.75,-0.0625 0.597314,-0.03733 1.164814,-0.08766 1.6875,-0.125 0.522646,-0.07466 0.964312,-0.118912 1.375,-0.15625 0.447978,-0.07466 0.78
 2061,-0.144079 0.96875,-0.21875 l 0,-24.59375 5.1875,0 0,28.28125 c -1.194693,0.298667 -2.771358,0.63275 -4.75,0.96875 -1.941354,0.336 -4.205269,0.499999 -6.78125,0.5 -2.240014,-10e-7 -4.125595,-0.334084 -5.65625,-0.96875 -1.530676,-0.671999 -2.754174,-1.586581 -3.6875,-2.78125 -0.933339,-1.194662 -1.589339,-2.613411 -2,-4.21875 -0.410671,-1.642658 -0.625004,-3.458823 -0.625,-5.4375 l 0,-16.34375 z m 28.9375,0.21875 c 0.578662,7e-6 1.054828,0.08201 1.4375,0.25 0.382661,0.158674 0.682244,0.38884 0.90625,0.6875 0.233327,0.28934 0.40666,0.620589 0.5,1.03125 0.09333,0.410672 0.124993,0.880338 0.125,1.375 l 0,4.09375 -1.3125,0 0,-3.8125 c -6e-6,-0.447996 -0.02842,-0.838912 -0.09375,-1.15625 C 41.475244,25.713922 41.389995,25.446006 41.25,25.25 c -0.140005,-0.195994 -0.329172,-0.322244 -0.5625,-0.40625 -0.233338,-0.09333 -0.529671,-0.156244 -0.875,-0.15625 -0.140004,6e-6 -0.28817,0.02192 -0.4375,0.03125 -0.149337,0.0093 -0.297503,0.01259 -0.4375,0.03125 -0.13067,0.0093 -0.231753,0
 .04384 -0.34375,0.0625 -0.102669,0.01867 -0.172086,0.02192 -0.21875,0.03125 l 0,6.15625 -1.3125,0 0,-7.09375 c 0.298665,-0.07466 0.692831,-0.134743 1.1875,-0.21875 0.494664,-0.08399 1.074747,-0.124993 1.71875,-0.125 z m 5.1875,0.15625 1.3125,0 0,7.28125 -1.3125,0 0,-7.28125 z" transform="translate(1.7431908,1.4941635)" id="path3047" style="fill:#982e6f;fill-opacity:1;stroke:none" />
+ </g>
+</svg>
diff --git a/version.h b/version.h
index bae887b..2ca866f 100644
--- a/version.h
+++ b/version.h
@@ -1 +1,2 @@
-#define VERSION "3.99.2.0"
+#define VERSION "3.99.2.1"
+
diff --git a/x2goclient.pro b/x2goclient.pro
index 8e5ea80..e831f5b 100755
--- a/x2goclient.pro
+++ b/x2goclient.pro
@@ -76,9 +76,6 @@ SOURCES += sharewidget.cpp \
            imgframe.cpp \
            LDAPSession.cpp \
            onmainwindow.cpp \
-           onmainwindow_part2.cpp \
-           onmainwindow_part3.cpp \
-           onmainwindow_part4.cpp \
            sessionbutton.cpp \
            sessionmanagedialog.cpp \
            sshmasterconnection.cpp \
@@ -108,7 +105,7 @@ LIBS += -lssh
 plugin {
 	TARGET = x2goplugin
 }
-else{
+else {
 	RC_FILE = x2goclient.rc
 	SOURCES += x2goclient.cpp
 	TARGET = x2goclient
@@ -116,6 +113,24 @@ else{
 	message(if you want to build x2goplugin you should export X2GO_CLIENT_TARGET=plugin)
 }
 
+!isEmpty(TRANSLATIONS) {
+  isEmpty(QMAKE_LRELEASE) {
+    win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\lrelease.exe
+    else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
+  }
+
+  isEmpty(TS_DIR):TS_DIR = .
+
+  TSQM.name = lrelease ${QMAKE_FILE_IN}
+  TSQM.input = TRANSLATIONS
+  TSQM.output = $$TS_DIR/${QMAKE_FILE_BASE}.qm
+  TSQM.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN}
+  TSQM.CONFIG = no_link
+  QMAKE_EXTRA_COMPILERS += TSQM
+  PRE_TARGETDEPS += compiler_TSQM_make_all
+}
+else:message(No translation files in project)
+
 TEMPLATE = app
 DEPENDPATH += .
 INCLUDEPATH += .
@@ -139,7 +154,7 @@ x2go_linux_static {
 macx {
 	message(building $$TARGET with ldap and cups)
 	LIBS += -framework LDAP -lcups -lcrypto -lssl -lz
-	CONFIG += x86 x86_64
+	CONFIG += x86 x86_64 ppc
 }
 win32-* {
 	message(building $$TARGET for windows without ldap and cups)
@@ -147,12 +162,12 @@ win32-* {
 	CONFIG += static release
 }
 QT += svg network
-ICON =icons/x2go-mac.icns
+ICON = icons/x2go-mac.icns
+QMAKE_INFO_PLIST = Info.plist
 QMAKE_MAC_SDK = /Developer/SDKs/MacOSX10.5.sdk
 QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.5
 
-plugin{
-
+plugin {
 	DEFINES += CFGPLUGIN
 	linux-g++ {
 		include(qtbrowserplugin-2.4_1-opensource/src/qtbrowserplugin.pri)
@@ -164,7 +179,6 @@ plugin{
 		DEFINES += QT_NODLL
 		CONFIG += qaxserver
 		include(qtbrowserplugin-2.4_1-opensource/src/qtbrowserplugin.pri)
-		}
+	}
 	RC_FILE = x2goplugin.rc
-
 }
diff --git a/x2goclient_de.ts b/x2goclient_de.ts
index 4fa81da..8dccd18 100644
--- a/x2goclient_de.ts
+++ b/x2goclient_de.ts
@@ -6,77 +6,77 @@
     <message>
         <location filename="appdialog.ui" line="14"/>
         <source>Published Applications</source>
-        <translation type="unfinished"></translation>
+        <translation>Veröffentlichte Anwendungen</translation>
     </message>
     <message>
         <location filename="appdialog.ui" line="60"/>
         <source>Search:</source>
-        <translation type="unfinished"></translation>
+        <translation>Suche:</translation>
     </message>
     <message>
         <location filename="appdialog.ui" line="76"/>
         <source>&Start</source>
-        <translation type="unfinished"></translation>
+        <translation>&Starten</translation>
     </message>
     <message>
         <location filename="appdialog.ui" line="96"/>
         <source>&Close</source>
-        <translation type="unfinished"></translation>
+        <translation>S&chließen</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="105"/>
         <source>Multimedia</source>
-        <translation type="unfinished"></translation>
+        <translation>Unterhaltungsmedien</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="110"/>
         <source>Development</source>
-        <translation type="unfinished"></translation>
+        <translation>Entwicklung</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="115"/>
         <source>Education</source>
-        <translation type="unfinished"></translation>
+        <translation>Bildung</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="120"/>
         <source>Game</source>
-        <translation type="unfinished"></translation>
+        <translation>Spiele</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="125"/>
         <source>Graphics</source>
-        <translation type="unfinished"></translation>
+        <translation>Grafik</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="130"/>
         <source>Network</source>
-        <translation type="unfinished"></translation>
+        <translation>Internet</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="135"/>
         <source>Office</source>
-        <translation type="unfinished"></translation>
+        <translation>Büroprogramme</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="140"/>
         <source>Settings</source>
-        <translation type="unfinished">Konfiguration</translation>
+        <translation>Einstellungen</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="145"/>
         <source>System</source>
-        <translation type="unfinished"></translation>
+        <translation>Systemwerkzeuge</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="150"/>
         <source>Utility</source>
-        <translation type="unfinished"></translation>
+        <translation>Dienstprogramme</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="155"/>
         <source>Other</source>
-        <translation type="unfinished"></translation>
+        <translation>Sonstige</translation>
     </message>
 </context>
 <context>
@@ -1011,7 +1011,7 @@ sound system connections through firewalls</source>
         <location filename="httpbrokerclient.cpp" line="467"/>
         <source>Issued to:
 </source>
-        <translation>Issued to:
+        <translation>Ausgestellt für:
 </translation>
     </message>
     <message>
@@ -1041,7 +1041,7 @@ sound system connections through firewalls</source>
         <location filename="httpbrokerclient.cpp" line="479"/>
         <source>Issued by:
 </source>
-        <translation>Issued by:
+        <translation>Ausgestellt von:
 </translation>
     </message>
     <message>
@@ -1065,7 +1065,7 @@ sound system connections through firewalls</source>
         <location filename="httpbrokerclient.cpp" line="493"/>
         <source>Fingerprints:
 </source>
-        <translation>Fingerprints:
+        <translation>Fingerabdrücke:
 </translation>
     </message>
     <message>
@@ -1681,8 +1681,8 @@ sound system connections through firewalls</source>
 Please check your settings</source>
         <oldsource>Can't connect to X-Server
 Please check your settings</oldsource>
-        <translation type="unfinished">Verbindung zu X-Server konnte nicht hergestellt werden
-Überprüfen Sie Ihre Einstellungen</translation>
+        <translation>Verbindung zu X-Server konnte nicht hergestellt werden
+Bitte überprüfen Sie Ihre Einstellungen</translation>
     </message>
     <message>
         <source>Can't start X-Server</source>
@@ -1968,7 +1968,8 @@ Public key hash: </source>
         <location filename="onmainwindow_part3.cpp" line="2232"/>
         <source>Can't start X server
 Please check your settings</source>
-        <translation type="unfinished"></translation>
+        <translation>X-Server lässt sich nicht starten. 
+Bitte überprüfen Sie Ihre Installation</translation>
     </message>
     <message>
         <location filename="onmainwindow_part3.cpp" line="2434"/>
@@ -2020,57 +2021,57 @@ Bitte installieren sie eine neuere Version von x2goserver</translation>
     <message>
         <location filename="onmainwindow.cpp" line="1005"/>
         <source>Multimedia</source>
-        <translation type="unfinished"></translation>
+        <translation>Unterhaltungsmedien</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1007"/>
         <source>Development</source>
-        <translation type="unfinished"></translation>
+        <translation>Entwicklung</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1009"/>
         <source>Education</source>
-        <translation type="unfinished"></translation>
+        <translation>Bildung</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1011"/>
         <source>Game</source>
-        <translation type="unfinished"></translation>
+        <translation>Spiele</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1013"/>
         <source>Graphics</source>
-        <translation type="unfinished"></translation>
+        <translation>Grafik</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1015"/>
         <source>Network</source>
-        <translation type="unfinished"></translation>
+        <translation>Internet</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1017"/>
         <source>Office</source>
-        <translation type="unfinished"></translation>
+        <translation>Büroprogramme</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1019"/>
         <source>Settings</source>
-        <translation type="unfinished">Konfiguration</translation>
+        <translation>Einstellungen</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1021"/>
         <source>System</source>
-        <translation type="unfinished"></translation>
+        <translation>Systemwerkzeuge</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1023"/>
         <source>Utility</source>
-        <translation type="unfinished"></translation>
+        <translation>Dienstprogramme</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1025"/>
         <source>Other</source>
-        <translation type="unfinished"></translation>
+        <translation>Sonstige</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1062"/>
@@ -2284,7 +2285,7 @@ Sie können SSHD über folgenden Befehl installieren:
     <message>
         <location filename="printdialog.cpp" line="54"/>
         <source>You've deactivated the x2go client printing dialog.</source>
-        <translation>Sie haben den clientseitigen Druckdialog deaktiviert</translation>
+        <translation>Sie haben den clientseitigen Druckdialog deaktiviert.</translation>
     </message>
     <message>
         <location filename="printdialog.cpp" line="56"/>
@@ -2513,7 +2514,7 @@ Beispiel:
         <location filename="sessionbutton.cpp" line="371"/>
         <location filename="sessionbutton.cpp" line="659"/>
         <source>Published applications</source>
-        <translation type="unfinished"></translation>
+        <translation>Veröffentlichte Anwendungen</translation>
     </message>
     <message>
         <location filename="sessionbutton.cpp" line="395"/>
@@ -2751,7 +2752,7 @@ Beispiel:
     <message>
         <location filename="sessionwidget.cpp" line="132"/>
         <source>Published applications</source>
-        <translation type="unfinished"></translation>
+        <translation>Veröffentlichte Anwendungen</translation>
     </message>
     <message>
         <location filename="sessionwidget.cpp" line="134"/>
@@ -2832,7 +2833,7 @@ Beispiel:
     <message>
         <location filename="sessionwidget.cpp" line="233"/>
         <source>x2goclient is running in portable mode. You should use a path on your usb device to be able to access your data whereever you are</source>
-        <translation>x2goclient befindet sich im portablen Ausführungsmodus. Wenn Sie einen Pfad ausserhalb des USB Geräts wählen, können sie auf die Daten nicht von überall aus zugreifen.</translation>
+        <translation>x2goclient wird gerade als portable Anwendung ausgeführt. Sie sollten einen Pfad auf dem USB-Medium wählen, um von überall aus auf Ihre Daten zugreifen zu können.</translation>
     </message>
 </context>
 <context>
diff --git a/x2goclient_nb_no.ts b/x2goclient_nb_no.ts
index 3355193..c41b517 100644
--- a/x2goclient_nb_no.ts
+++ b/x2goclient_nb_no.ts
@@ -6,77 +6,77 @@
     <message>
         <location filename="appdialog.ui" line="14"/>
         <source>Published Applications</source>
-        <translation type="unfinished"></translation>
+        <translation>Publiserte applikasjoner</translation>
     </message>
     <message>
         <location filename="appdialog.ui" line="60"/>
         <source>Search:</source>
-        <translation type="unfinished"></translation>
+        <translation>Søk:</translation>
     </message>
     <message>
         <location filename="appdialog.ui" line="76"/>
         <source>&Start</source>
-        <translation type="unfinished"></translation>
+        <translation>&Start</translation>
     </message>
     <message>
         <location filename="appdialog.ui" line="96"/>
         <source>&Close</source>
-        <translation type="unfinished"></translation>
+        <translation>&Lukk</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="105"/>
         <source>Multimedia</source>
-        <translation type="unfinished"></translation>
+        <translation>Multimedia</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="110"/>
         <source>Development</source>
-        <translation type="unfinished"></translation>
+        <translation>Utvikling</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="115"/>
         <source>Education</source>
-        <translation type="unfinished"></translation>
+        <translation>Opplæring</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="120"/>
         <source>Game</source>
-        <translation type="unfinished"></translation>
+        <translation>Spill</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="125"/>
         <source>Graphics</source>
-        <translation type="unfinished"></translation>
+        <translation>Grafikk</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="130"/>
         <source>Network</source>
-        <translation type="unfinished"></translation>
+        <translation></translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="135"/>
         <source>Office</source>
-        <translation type="unfinished"></translation>
+        <translation>Kontor</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="140"/>
         <source>Settings</source>
-        <translation type="unfinished">Innstillinger</translation>
+        <translation>Innstillinger</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="145"/>
         <source>System</source>
-        <translation type="unfinished"></translation>
+        <translation>System</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="150"/>
         <source>Utility</source>
-        <translation type="unfinished"></translation>
+        <translation>Verktøy</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="155"/>
         <source>Other</source>
-        <translation type="unfinished"></translation>
+        <translation>Andre</translation>
     </message>
 </context>
 <context>
@@ -733,42 +733,42 @@
 <context>
     <name>ONMainWindow</name>
     <message>
-        <location filename="onmainwindow.cpp" line="87"/>
-        <location filename="onmainwindow_part3.cpp" line="482"/>
+        <location filename="onmainwindow.cpp" line="90"/>
+        <location filename="onmainwindow_part3.cpp" line="495"/>
         <source>us</source>
         <translation>no</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="88"/>
+        <location filename="onmainwindow.cpp" line="91"/>
         <source>pc105/us</source>
         <translation>pc105/de</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="339"/>
+        <location filename="onmainwindow.cpp" line="345"/>
         <source>Support ...</source>
         <translatorcomment>Need to double-check this one</translatorcomment>
         <translation>Støtte ...</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="674"/>
-        <location filename="onmainwindow.cpp" line="1960"/>
-        <location filename="onmainwindow_part3.cpp" line="1815"/>
+        <location filename="onmainwindow.cpp" line="680"/>
+        <location filename="onmainwindow.cpp" line="1985"/>
+        <location filename="onmainwindow_part3.cpp" line="1834"/>
         <source>Session:</source>
         <translation>Sesjon:</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="726"/>
+        <location filename="onmainwindow.cpp" line="732"/>
         <source>&Quit</source>
         <translation>&Avslutt</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="727"/>
+        <location filename="onmainwindow.cpp" line="733"/>
         <source>Ctrl+Q</source>
         <translation>Ctrl+Q</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="728"/>
-        <location filename="onmainwindow.cpp" line="1051"/>
+        <location filename="onmainwindow.cpp" line="734"/>
+        <location filename="onmainwindow.cpp" line="1055"/>
         <source>Quit</source>
         <translation>Avslutt</translation>
     </message>
@@ -777,7 +777,7 @@
         <translation type="obsolete">&Neue Sitzung ...</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="732"/>
+        <location filename="onmainwindow.cpp" line="738"/>
         <source>Ctrl+N</source>
         <translation>Ctrl+N</translation>
     </message>
@@ -786,7 +786,7 @@
         <translation type="obsolete">Sitzungsverwaltung...</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="738"/>
+        <location filename="onmainwindow.cpp" line="744"/>
         <source>Ctrl+E</source>
         <translation>Ctrl+E</translation>
     </message>
@@ -795,7 +795,7 @@
         <translation type="obsolete">LDAP &Konfiguration ...</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2307"/>
+        <location filename="onmainwindow_part4.cpp" line="2334"/>
         <source>Restore toolbar</source>
         <translation>Gjenopprett verktøylinjen</translation>
     </message>
@@ -804,185 +804,183 @@
         <translation type="obsolete">Ãœber X2GO Client</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="781"/>
+        <location filename="onmainwindow.cpp" line="787"/>
         <source>About Qt</source>
         <translation>Om QT</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="2520"/>
+        <location filename="onmainwindow_part2.cpp" line="2522"/>
         <source>Session</source>
         <translation>Sesjon</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="798"/>
+        <location filename="onmainwindow.cpp" line="804"/>
         <source>Ctrl+Q</source>
         <comment>exit</comment>
         <translation>Ctrl+Q</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="804"/>
+        <location filename="onmainwindow.cpp" line="810"/>
         <source>&Session</source>
         <translation>&Sesjon</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="805"/>
+        <location filename="onmainwindow.cpp" line="811"/>
         <source>&Options</source>
         <translation>&Innstillinger</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="824"/>
+        <location filename="onmainwindow.cpp" line="830"/>
         <source>&Help</source>
         <translation>&Hjelp</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="1665"/>
+        <location filename="onmainwindow_part4.cpp" line="1672"/>
         <source>Password:</source>
         <translation>Passord:</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="1666"/>
+        <location filename="onmainwindow_part4.cpp" line="1673"/>
         <source>Keyboard layout:</source>
         <translation>Tastatur utseende:</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="1707"/>
+        <location filename="onmainwindow_part4.cpp" line="1714"/>
         <source>Ok</source>
         <translation>Ok</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="1709"/>
-        <location filename="onmainwindow_part4.cpp" line="2011"/>
-        <location filename="onmainwindow_part4.cpp" line="2013"/>
+        <location filename="onmainwindow_part4.cpp" line="1716"/>
+        <location filename="onmainwindow_part4.cpp" line="2038"/>
+        <location filename="onmainwindow_part4.cpp" line="2040"/>
         <source>Cancel</source>
         <translation>Avbryt</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="1850"/>
+        <location filename="onmainwindow_part4.cpp" line="1863"/>
         <source>Applications...</source>
-        <translation type="unfinished"></translation>
+        <translation>Applikasjoner...</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2507"/>
         <source>Invalid reply from broker</source>
         <translatorcomment>Need to update/create the Norwegian documentation to make clear what the "megeleren" actually is in this context.</translatorcomment>
-        <translation>Ugyldig svar fra megleren</translation>
-    </message>
-    <message>
-        <location filename="onmainwindow.cpp" line="884"/>
-        <location filename="onmainwindow.cpp" line="912"/>
-        <location filename="onmainwindow.cpp" line="1635"/>
-        <location filename="onmainwindow.cpp" line="1664"/>
-        <location filename="onmainwindow.cpp" line="1672"/>
-        <location filename="onmainwindow.cpp" line="1818"/>
-        <location filename="onmainwindow.cpp" line="1845"/>
-        <location filename="onmainwindow.cpp" line="1848"/>
-        <location filename="onmainwindow.cpp" line="2095"/>
-        <location filename="onmainwindow.cpp" line="2318"/>
-        <location filename="onmainwindow.cpp" line="2332"/>
-        <location filename="onmainwindow.cpp" line="2345"/>
-        <location filename="onmainwindow.cpp" line="2379"/>
-        <location filename="onmainwindow.cpp" line="2424"/>
-        <location filename="onmainwindow_part2.cpp" line="307"/>
-        <location filename="onmainwindow_part2.cpp" line="484"/>
-        <location filename="onmainwindow_part2.cpp" line="493"/>
-        <location filename="onmainwindow_part2.cpp" line="802"/>
-        <location filename="onmainwindow_part2.cpp" line="1263"/>
-        <location filename="onmainwindow_part2.cpp" line="1324"/>
-        <location filename="onmainwindow_part2.cpp" line="1375"/>
-        <location filename="onmainwindow_part2.cpp" line="1408"/>
-        <location filename="onmainwindow_part2.cpp" line="1452"/>
-        <location filename="onmainwindow_part2.cpp" line="1855"/>
-        <location filename="onmainwindow_part2.cpp" line="1881"/>
-        <location filename="onmainwindow_part2.cpp" line="2018"/>
-        <location filename="onmainwindow_part3.cpp" line="228"/>
-        <location filename="onmainwindow_part3.cpp" line="264"/>
-        <location filename="onmainwindow_part3.cpp" line="946"/>
-        <location filename="onmainwindow_part3.cpp" line="1027"/>
-        <location filename="onmainwindow_part3.cpp" line="1271"/>
-        <location filename="onmainwindow_part3.cpp" line="1399"/>
-        <location filename="onmainwindow_part3.cpp" line="1452"/>
-        <location filename="onmainwindow_part3.cpp" line="1758"/>
-        <location filename="onmainwindow_part3.cpp" line="1760"/>
-        <location filename="onmainwindow_part3.cpp" line="1990"/>
-        <location filename="onmainwindow_part3.cpp" line="2038"/>
-        <location filename="onmainwindow_part3.cpp" line="2066"/>
-        <location filename="onmainwindow_part3.cpp" line="2402"/>
-        <location filename="onmainwindow_part3.cpp" line="2417"/>
-        <location filename="onmainwindow_part3.cpp" line="2471"/>
+        <translation type="obsolete">Ugyldig svar fra megleren</translation>
+    </message>
+    <message>
+        <location filename="onmainwindow.cpp" line="890"/>
+        <location filename="onmainwindow.cpp" line="918"/>
+        <location filename="onmainwindow.cpp" line="1660"/>
+        <location filename="onmainwindow.cpp" line="1689"/>
+        <location filename="onmainwindow.cpp" line="1697"/>
+        <location filename="onmainwindow.cpp" line="1843"/>
+        <location filename="onmainwindow.cpp" line="1870"/>
+        <location filename="onmainwindow.cpp" line="1873"/>
+        <location filename="onmainwindow.cpp" line="2120"/>
+        <location filename="onmainwindow.cpp" line="2343"/>
+        <location filename="onmainwindow.cpp" line="2357"/>
+        <location filename="onmainwindow.cpp" line="2370"/>
+        <location filename="onmainwindow.cpp" line="2404"/>
+        <location filename="onmainwindow.cpp" line="2449"/>
+        <location filename="onmainwindow_part2.cpp" line="309"/>
+        <location filename="onmainwindow_part2.cpp" line="486"/>
+        <location filename="onmainwindow_part2.cpp" line="495"/>
+        <location filename="onmainwindow_part2.cpp" line="804"/>
+        <location filename="onmainwindow_part2.cpp" line="1265"/>
+        <location filename="onmainwindow_part2.cpp" line="1326"/>
+        <location filename="onmainwindow_part2.cpp" line="1377"/>
+        <location filename="onmainwindow_part2.cpp" line="1410"/>
+        <location filename="onmainwindow_part2.cpp" line="1454"/>
+        <location filename="onmainwindow_part2.cpp" line="1857"/>
+        <location filename="onmainwindow_part2.cpp" line="1883"/>
+        <location filename="onmainwindow_part2.cpp" line="2020"/>
+        <location filename="onmainwindow_part3.cpp" line="225"/>
+        <location filename="onmainwindow_part3.cpp" line="261"/>
+        <location filename="onmainwindow_part3.cpp" line="965"/>
+        <location filename="onmainwindow_part3.cpp" line="1046"/>
+        <location filename="onmainwindow_part3.cpp" line="1290"/>
+        <location filename="onmainwindow_part3.cpp" line="1418"/>
+        <location filename="onmainwindow_part3.cpp" line="1471"/>
+        <location filename="onmainwindow_part3.cpp" line="1777"/>
+        <location filename="onmainwindow_part3.cpp" line="1779"/>
+        <location filename="onmainwindow_part3.cpp" line="2009"/>
+        <location filename="onmainwindow_part3.cpp" line="2057"/>
+        <location filename="onmainwindow_part3.cpp" line="2085"/>
+        <location filename="onmainwindow_part3.cpp" line="2421"/>
+        <location filename="onmainwindow_part3.cpp" line="2436"/>
+        <location filename="onmainwindow_part3.cpp" line="2490"/>
         <location filename="onmainwindow_part4.cpp" line="29"/>
         <location filename="onmainwindow_part4.cpp" line="54"/>
-        <location filename="onmainwindow_part4.cpp" line="2235"/>
-        <location filename="onmainwindow_part4.cpp" line="2506"/>
+        <location filename="onmainwindow_part4.cpp" line="2262"/>
         <source>Error</source>
         <translation>Feil</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="2551"/>
-        <location filename="onmainwindow_part3.cpp" line="80"/>
+        <location filename="onmainwindow.cpp" line="2576"/>
+        <location filename="onmainwindow_part3.cpp" line="74"/>
         <source>KDE</source>
         <translation>KDE</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="2625"/>
+        <location filename="onmainwindow.cpp" line="2650"/>
         <source> on </source>
         <translation> på </translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="863"/>
-        <location filename="onmainwindow.cpp" line="1953"/>
-        <location filename="onmainwindow_part3.cpp" line="1808"/>
-        <location filename="onmainwindow_part4.cpp" line="1664"/>
+        <location filename="onmainwindow.cpp" line="869"/>
+        <location filename="onmainwindow.cpp" line="1978"/>
+        <location filename="onmainwindow_part3.cpp" line="1827"/>
+        <location filename="onmainwindow_part4.cpp" line="1671"/>
         <source>Login:</source>
         <translation>Brukernavn:</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1033"/>
-        <location filename="onmainwindow_part4.cpp" line="2007"/>
+        <location filename="onmainwindow_part2.cpp" line="1035"/>
+        <location filename="onmainwindow_part4.cpp" line="2034"/>
         <source>Select session:</source>
         <translation>Velg sesjon:</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2009"/>
+        <location filename="onmainwindow_part4.cpp" line="2036"/>
         <source>Resume</source>
         <translation>Gjenoppta</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="552"/>
-        <location filename="onmainwindow.cpp" line="1036"/>
-        <location filename="onmainwindow_part2.cpp" line="2260"/>
-        <location filename="onmainwindow_part4.cpp" line="2016"/>
+        <location filename="onmainwindow.cpp" line="558"/>
+        <location filename="onmainwindow.cpp" line="1037"/>
+        <location filename="onmainwindow_part2.cpp" line="2262"/>
+        <location filename="onmainwindow_part4.cpp" line="2043"/>
         <source>Suspend</source>
         <translatorcomment>I disagree with the word 'Suspend' here, if it was suspending then the session would be paused. As this is not the case, it's more like disconnect (and the counterpart: reconnect). I used the translation fro 'Disconnect' here, and will research the possibility of changing the Suspend word to Disconnect also in the english translation.</translatorcomment>
         <translation>Koble fra</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="555"/>
-        <location filename="onmainwindow.cpp" line="1037"/>
-        <location filename="onmainwindow_part4.cpp" line="1855"/>
-        <location filename="onmainwindow_part4.cpp" line="2018"/>
+        <location filename="onmainwindow.cpp" line="561"/>
+        <location filename="onmainwindow.cpp" line="1038"/>
+        <location filename="onmainwindow_part4.cpp" line="1883"/>
+        <location filename="onmainwindow_part4.cpp" line="2045"/>
         <source>Terminate</source>
         <translatorcomment>Need to revisit this word to see if the chosen one is *strong* enough</translatorcomment>
         <translation>Avslutte</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2021"/>
+        <location filename="onmainwindow_part4.cpp" line="2048"/>
         <source>New</source>
         <translation>Ny</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="2522"/>
-        <location filename="onmainwindow_part4.cpp" line="2088"/>
-        <location filename="onmainwindow_part4.cpp" line="2110"/>
+        <location filename="onmainwindow_part2.cpp" line="2524"/>
+        <location filename="onmainwindow_part4.cpp" line="2115"/>
+        <location filename="onmainwindow_part4.cpp" line="2137"/>
         <source>Display</source>
         <translation>Skjerm</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2090"/>
+        <location filename="onmainwindow_part4.cpp" line="2117"/>
         <source>Status</source>
         <translation>Status</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2096"/>
+        <location filename="onmainwindow_part4.cpp" line="2123"/>
         <source>Server</source>
         <translation>Server</translation>
     </message>
@@ -991,20 +989,20 @@
         <translation type="obsolete">Startzeit</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2101"/>
+        <location filename="onmainwindow_part4.cpp" line="2128"/>
         <source>Client IP</source>
         <translation>Klient IP</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1049"/>
-        <location filename="onmainwindow_part2.cpp" line="1143"/>
-        <location filename="onmainwindow_part2.cpp" line="2224"/>
+        <location filename="onmainwindow_part2.cpp" line="1051"/>
+        <location filename="onmainwindow_part2.cpp" line="1145"/>
+        <location filename="onmainwindow_part2.cpp" line="2226"/>
         <source>running</source>
         <translation>aktiv</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1051"/>
-        <location filename="onmainwindow_part2.cpp" line="1336"/>
+        <location filename="onmainwindow_part2.cpp" line="1053"/>
+        <location filename="onmainwindow_part2.cpp" line="1338"/>
         <source>suspended</source>
         <translation>Frakoblet</translation>
     </message>
@@ -1017,46 +1015,46 @@
         <translation type="obsolete">Datei kann nicht geschrieben werden:</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="2045"/>
+        <location filename="onmainwindow_part2.cpp" line="2047"/>
         <source>Unable to create SSL Tunnel:
 </source>
         <translation>Klarer ikke å opprette SSL tunnel:
 </translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1184"/>
-        <location filename="onmainwindow_part2.cpp" line="1204"/>
-        <location filename="onmainwindow_part2.cpp" line="2047"/>
-        <location filename="onmainwindow_part2.cpp" line="2436"/>
+        <location filename="onmainwindow_part2.cpp" line="1186"/>
+        <location filename="onmainwindow_part2.cpp" line="1206"/>
+        <location filename="onmainwindow_part2.cpp" line="2049"/>
+        <location filename="onmainwindow_part2.cpp" line="2438"/>
         <source>Warning</source>
         <translation>Advarsel</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="153"/>
-        <location filename="onmainwindow_part2.cpp" line="189"/>
-        <location filename="onmainwindow_part2.cpp" line="2208"/>
+        <location filename="onmainwindow.cpp" line="156"/>
+        <location filename="onmainwindow_part2.cpp" line="190"/>
+        <location filename="onmainwindow_part2.cpp" line="2210"/>
         <source>connecting</source>
         <translation>kobler til</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="2216"/>
+        <location filename="onmainwindow_part2.cpp" line="2218"/>
         <source>starting</source>
         <translation>starter</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="2218"/>
+        <location filename="onmainwindow_part2.cpp" line="2220"/>
         <source>resuming</source>
         <translation>gjenopptar</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="2280"/>
-        <location filename="onmainwindow_part2.cpp" line="2552"/>
-        <location filename="onmainwindow_part2.cpp" line="2570"/>
+        <location filename="onmainwindow_part2.cpp" line="2282"/>
+        <location filename="onmainwindow_part2.cpp" line="2554"/>
+        <location filename="onmainwindow_part2.cpp" line="2572"/>
         <source>Connection timeout, aborting</source>
         <translation>Tilkoblingen tidsavbrutt, avbryter</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="2281"/>
+        <location filename="onmainwindow_part2.cpp" line="2283"/>
         <source>aborting</source>
         <translation>Avbryter</translation>
     </message>
@@ -1065,7 +1063,7 @@
         <translation type="obsolete"><b>Sitzungs ID:<br>Server:<br>Login:<br>Display:<br>Startzeit:<br>Status:</b></translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="1854"/>
+        <location filename="onmainwindow_part4.cpp" line="1876"/>
         <source>Abort</source>
         <translation>Avbryt</translation>
     </message>
@@ -1074,78 +1072,78 @@
         <translation type="obsolete">Zeige Details</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="579"/>
+        <location filename="onmainwindow_part3.cpp" line="597"/>
         <source> (can't open file)</source>
         <translation> (kan ikke åpne filen)</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="590"/>
-        <location filename="onmainwindow_part3.cpp" line="600"/>
-        <location filename="onmainwindow_part3.cpp" line="610"/>
+        <location filename="onmainwindow_part3.cpp" line="608"/>
+        <location filename="onmainwindow_part3.cpp" line="618"/>
+        <location filename="onmainwindow_part3.cpp" line="628"/>
         <source> (file not exists)</source>
         <translation> (filen finnes ikke)</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="634"/>
+        <location filename="onmainwindow_part3.cpp" line="652"/>
         <source> (directory not exists)</source>
         <translation> (mappen finnes ikke)</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="662"/>
+        <location filename="onmainwindow_part3.cpp" line="680"/>
         <source>wrong value for argument"--link"</source>
         <translatorcomment>Chose to use 'parameteren' here, the direct translation is 'argument', but didn't fit in my opinion. The cmdline arguments, will they be translated as well?</translatorcomment>
         <translation>ugyldig verdi for parameteren "--link"</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="680"/>
+        <location filename="onmainwindow_part3.cpp" line="698"/>
         <source>wrong value for argument"--sound"</source>
         <translation>ugyldig verdi for parameteren "--sound"</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="697"/>
-        <location filename="onmainwindow_part3.cpp" line="708"/>
+        <location filename="onmainwindow_part3.cpp" line="715"/>
+        <location filename="onmainwindow_part3.cpp" line="726"/>
         <source>wrong value for argument"--geometry"</source>
         <translation>ugyldig verdi for parameteren "--geometry"</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="726"/>
+        <location filename="onmainwindow_part3.cpp" line="744"/>
         <source>wrong value for argument"--set-kbd"</source>
         <translation>ugyldig verdi for parameteren "--set-kbd"</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="743"/>
+        <location filename="onmainwindow_part3.cpp" line="761"/>
         <source>wrong value for argument"--ldap"</source>
         <translation>ugyldig verdi for parameteren "--ldap"</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="838"/>
+        <location filename="onmainwindow_part3.cpp" line="856"/>
         <source>wrong value for argument"--pack"</source>
         <translation>ugyldig verdi for parameteren "--pack"</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="846"/>
-        <location filename="onmainwindow_part3.cpp" line="849"/>
+        <location filename="onmainwindow_part3.cpp" line="864"/>
+        <location filename="onmainwindow_part3.cpp" line="867"/>
         <source>wrong parameter: </source>
         <translation>ugyldig parameter: </translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="902"/>
+        <location filename="onmainwindow_part3.cpp" line="921"/>
         <source>Available pack methodes:</source>
         <translation>Tilgjengelige pakkemetoder:</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="1690"/>
+        <location filename="onmainwindow_part3.cpp" line="1709"/>
         <source>Support</source>
         <translatorcomment>Will have to revisit this one, not sure if it fits</translatorcomment>
         <translation>Støtte</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="1695"/>
+        <location filename="onmainwindow_part3.cpp" line="1714"/>
         <source></b><br> (C. 2006-2012 <b>obviously nice</b>: Oleksandr Shneyder, Heinz-Markus Graesing)<br></source>
         <translation></b><br> (C. 2006-2012 <b>obviously nice</b>: Oleksandr Shneyder, Heinz-Markus Graesing)<br></translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="1761"/>
+        <location filename="onmainwindow_part3.cpp" line="1780"/>
         <source>Please check LDAP Settings</source>
         <translation>Vennligst sjekk LDAP innstillingene</translation>
     </message>
@@ -1158,15 +1156,15 @@
         <translation type="obsolete">Sind Sie sicher, dass Sie die Sitzung löschen wollen?</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="300"/>
-        <location filename="onmainwindow_part2.cpp" line="1317"/>
-        <location filename="onmainwindow_part2.cpp" line="1401"/>
-        <location filename="onmainwindow_part2.cpp" line="1434"/>
-        <location filename="onmainwindow_part3.cpp" line="939"/>
-        <location filename="onmainwindow_part3.cpp" line="1020"/>
-        <location filename="onmainwindow_part3.cpp" line="1392"/>
-        <location filename="onmainwindow_part3.cpp" line="1445"/>
-        <location filename="onmainwindow_part3.cpp" line="2395"/>
+        <location filename="onmainwindow_part2.cpp" line="302"/>
+        <location filename="onmainwindow_part2.cpp" line="1319"/>
+        <location filename="onmainwindow_part2.cpp" line="1403"/>
+        <location filename="onmainwindow_part2.cpp" line="1436"/>
+        <location filename="onmainwindow_part3.cpp" line="958"/>
+        <location filename="onmainwindow_part3.cpp" line="1039"/>
+        <location filename="onmainwindow_part3.cpp" line="1411"/>
+        <location filename="onmainwindow_part3.cpp" line="1464"/>
+        <location filename="onmainwindow_part3.cpp" line="2414"/>
         <source><b>Connection failed</b>
 </source>
         <translation><b>Tilkoblingen feilet</b>
@@ -1177,23 +1175,23 @@
         <translation type="obsolete">es konnte kein Server gefunden werden</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2103"/>
+        <location filename="onmainwindow_part4.cpp" line="2130"/>
         <source>Session ID</source>
         <translation>Sesjons ID</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1281"/>
+        <location filename="onmainwindow_part2.cpp" line="1283"/>
         <source>suspending</source>
         <translation>Kobler fra</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1303"/>
+        <location filename="onmainwindow_part2.cpp" line="1305"/>
         <source>terminating</source>
         <translation>Avslutter</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="222"/>
-        <location filename="onmainwindow_part3.cpp" line="258"/>
+        <location filename="onmainwindow_part3.cpp" line="219"/>
+        <location filename="onmainwindow_part3.cpp" line="255"/>
         <source><b>Connection failed</b>
 :
 </source>
@@ -1248,18 +1246,18 @@
         <translation type="obsolete"><b>X2Go Client V. 2.0.1</b><br> (C. 2006-2007 Oleksandr Shneyder, Heinz-Markus Graesing)<br><br>Ein Client für den Zugriff auf die serverbasierende Anwendungsumgebung X2Go. Mit Hilfe dieser Anwendung können Sie Sitzungen eines X2Go Servers starten, stoppen, laufende Sitzungen fortführen oder anhalten und verschiedene Sitzungskonfigurationen verwalten. Die Authentifizierung kann über LDAP erfolgen und das Programm kann im Vollbildmodus (als Ersatz für XDM) gestartet werden. Weitere Informationen erhalten SIe auf x2go.org.</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1437"/>
+        <location filename="onmainwindow_part2.cpp" line="1439"/>
         <source><b>Wrong Password!</b><br><br></source>
         <translatorcomment>Should we actually tell that it's the password that's wrong? Isn't that considered bad practice in regards to security? I propose to use "Wrong Username or Password!" instead.</translatorcomment>
         <translation><b>Feil passord!</b><br><br></translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="765"/>
+        <location filename="onmainwindow_part3.cpp" line="783"/>
         <source>wrong value for argument"--ldap1"</source>
         <translation>ugyldig verdi for parameteren "--ldap1"</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="784"/>
+        <location filename="onmainwindow_part3.cpp" line="802"/>
         <source>wrong value for argument"--ldap2"</source>
         <translation>ugyldig verdi for parameteren "--ldap2"</translation>
     </message>
@@ -1288,12 +1286,12 @@
         <translation type="obsolete">Usage: x2goclient [Options]			Options:			--help                           Print this message			--help-pack                      Print availabel pack methods			--no-menu                        Hide menu bar			--maximize                       Start maximized			--add-to-known-hosts             Add RSA key fingerprint to .ssh/known_hosts 			if authenticity of server can't be established			--ldap=<host:port:dn>            Start with LDAP Support. Example:			--ldap=ldapserver:389:o=organization,c=de			--ldap1=<host:port>              LDAP Failover Server #1 			--ldap2=<host:port>              LDAP Failover Server #2 			--command=<cmd>                  Set default command, default value 'KDE'			--sound=<0|1>                    Enable sound, default value '1'			--geomerty=<W>x<H>|fullscreen    Set default geometry, default value '800x600'			--link=<modem|isdn|adsl|wan
 |lan> Set default link type, default 'lan'			--pack=<packmethod>              Set default pack method, default '16m-jpeg-9'			--kbd-layout=<layout>            Set default keyboard layout, default 'us'			--kbd-type=<typed>               Set default keyboard type, default 'pc105/us'			--set-kbd=<0|1>                  Overwrite current keyboard settings, default '0'</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="2067"/>
+        <location filename="onmainwindow_part3.cpp" line="2086"/>
         <source>Unable to create file: </source>
         <translation>Klarer ikke å opprette filen: </translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="1991"/>
+        <location filename="onmainwindow_part3.cpp" line="2010"/>
         <source>No valid card found</source>
         <translation>Ingen gyldige kort ble funnet</translation>
     </message>
@@ -1302,14 +1300,14 @@
         <translation type="obsolete">Diese Karte ist dem X2Go System unbekannt</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="335"/>
+        <location filename="onmainwindow.cpp" line="341"/>
         <source>&Settings ...</source>
         <translatorcomment>Need to revisit the keybindings in all the Norwegian strings to check for consistency and collisions</translatorcomment>
         <translation>&Innstillinger</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="897"/>
-        <location filename="onmainwindow_part3.cpp" line="923"/>
+        <location filename="onmainwindow_part3.cpp" line="916"/>
+        <location filename="onmainwindow_part3.cpp" line="942"/>
         <source>Options</source>
         <translatorcomment>Hm.. Should we actually use different words here in Norwegian? Or could they mean the same? Need to check the UI first</translatorcomment>
         <translation>Alternativer</translation>
@@ -1323,12 +1321,12 @@
         <translation type="obsolete">Klarte ikke å koble til X-Serveren</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="2231"/>
+        <location filename="onmainwindow_part3.cpp" line="2250"/>
         <source>Can't connect to X server
 Please check your settings</source>
         <oldsource>Can't connect to X-Server
 Please check your settings</oldsource>
-        <translation type="unfinished">Klarte ikke å koble til X-Serveren
+        <translation>Klarte ikke å koble til X-Serveren
 Vennligst sjekk innstillingene dine</translation>
     </message>
     <message>
@@ -1342,33 +1340,33 @@ Please check your settings</source>
 Vennligst sjekk instillingene dine</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1185"/>
-        <location filename="onmainwindow_part2.cpp" line="1205"/>
+        <location filename="onmainwindow_part2.cpp" line="1187"/>
+        <location filename="onmainwindow_part2.cpp" line="1207"/>
         <source>Your current color depth is different to the color depth of your x2go-session. This may cause problems reconnecting to this session and in most cases <b>you will loose the session</b> and have to start a new one! It's highly recommended to change the color depth of your Display to </source>
         <translation>Din nåværende fargedybde er forskjellig fra fargedybden i din x2go sesjon. Dette kan skape problemer ved gjenoppkobling til denne sesjonen, og i de fleste tilfellene <b>vil du miste hele sesjonen</b>. og du må starte en ny en! Det er sterkt anbefalt å endre fargedybden på skjemen din til </translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1193"/>
+        <location filename="onmainwindow_part2.cpp" line="1195"/>
         <source>24 or 32</source>
         <translation>24 eller 32</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1194"/>
-        <location filename="onmainwindow_part2.cpp" line="1214"/>
+        <location filename="onmainwindow_part2.cpp" line="1196"/>
+        <location filename="onmainwindow_part2.cpp" line="1216"/>
         <source> bit and restart your X-server before you reconnect to this x2go-session.<br>Resume this session anyway?</source>
         <translation> bit og deretter restarte X-Serveren før du kobler til denne x2go sesjonen. <br>Gjenoppta denne sesjonen uansett?</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="122"/>
-        <location filename="onmainwindow_part2.cpp" line="1197"/>
-        <location filename="onmainwindow_part2.cpp" line="1217"/>
+        <location filename="onmainwindow_part2.cpp" line="123"/>
+        <location filename="onmainwindow_part2.cpp" line="1199"/>
+        <location filename="onmainwindow_part2.cpp" line="1219"/>
         <source>Yes</source>
         <translation>Ja</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="122"/>
-        <location filename="onmainwindow_part2.cpp" line="1198"/>
-        <location filename="onmainwindow_part2.cpp" line="1218"/>
+        <location filename="onmainwindow_part2.cpp" line="123"/>
+        <location filename="onmainwindow_part2.cpp" line="1200"/>
+        <location filename="onmainwindow_part2.cpp" line="1220"/>
         <source>No</source>
         <translation>Nei</translation>
     </message>
@@ -1385,42 +1383,42 @@ Vennligst sjekk instillingene dine</translation>
         <translation type="obsolete"></b><br> (C. 2006-2008 <b>obviously nice</b>: Oleksandr Shneyder, Heinz-Markus Graesing)<br><br>Ein Client für den Zugriff auf die serverbasierende Anwendungsumgebung X2Go. Mit Hilfe dieser Anwendung können Sie Sitzungen eines X2Go Servers starten, stoppen, laufende Sitzungen fortführen oder anhalten und verschiedene Sitzungskonfigurationen verwalten. Die Authentifizierung kann über LDAP erfolgen und das Programm kann im Vollbildmodus (als Ersatz für XDM) gestartet werden. Weitere Informationen erhalten SIe auf x2go.org.</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="162"/>
+        <location filename="onmainwindow.cpp" line="165"/>
         <source>OpenOffice.org</source>
         <translation>OpenOffice.org</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="163"/>
+        <location filename="onmainwindow.cpp" line="166"/>
         <source>Terminal</source>
         <translation>Terminal</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="419"/>
+        <location filename="onmainwindow_part2.cpp" line="421"/>
         <source>unknown</source>
         <translation>ukjent</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2092"/>
+        <location filename="onmainwindow_part4.cpp" line="2119"/>
         <source>Command</source>
         <translation>Kommando</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2094"/>
+        <location filename="onmainwindow_part4.cpp" line="2121"/>
         <source>Type</source>
         <translation>Type</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1057"/>
+        <location filename="onmainwindow_part2.cpp" line="1059"/>
         <source>Desktop</source>
         <translation>Skrivebord</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1059"/>
+        <location filename="onmainwindow_part2.cpp" line="1061"/>
         <source>single application</source>
         <translation>enkel applikasjon</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1061"/>
+        <location filename="onmainwindow_part2.cpp" line="1063"/>
         <source>shadow session</source>
         <translatorcomment>hm.. Need to revisit this one, not sure if I should use a better technical term in Norwegian</translatorcomment>
         <translation>skygge sesjonen</translation>
@@ -1430,315 +1428,316 @@ Vennligst sjekk instillingene dine</translation>
         <translation type="obsolete"><br>Fehler in der Sudo Konfiguration</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="2418"/>
+        <location filename="onmainwindow_part3.cpp" line="2437"/>
         <source>Unable to execute: </source>
         <translation>Klarte ikke å utføre:</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="136"/>
+        <location filename="onmainwindow.cpp" line="139"/>
         <source>X2Go client</source>
         <translation>X2Go klient</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="160"/>
+        <location filename="onmainwindow.cpp" line="163"/>
         <source>Internet browser</source>
         <translation>Nettleser</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="161"/>
+        <location filename="onmainwindow.cpp" line="164"/>
         <source>Email client</source>
         <translation>Epost program</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="731"/>
+        <location filename="onmainwindow.cpp" line="737"/>
         <source>&New session ...</source>
         <translation>&Ny sesjon ...</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="737"/>
+        <location filename="onmainwindow.cpp" line="743"/>
         <source>Session management...</source>
         <translation>Sesjonshåndtering...</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="775"/>
-        <location filename="onmainwindow.cpp" line="796"/>
+        <location filename="onmainwindow.cpp" line="781"/>
+        <location filename="onmainwindow.cpp" line="802"/>
         <source>Show toolbar</source>
         <translation>Vis verktøylinje</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="346"/>
-        <location filename="onmainwindow_part3.cpp" line="1715"/>
+        <location filename="onmainwindow.cpp" line="352"/>
+        <location filename="onmainwindow_part3.cpp" line="1734"/>
         <source>About X2GO client</source>
         <translation>Om X2GO klient</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1636"/>
-        <location filename="onmainwindow.cpp" line="1819"/>
-        <location filename="onmainwindow.cpp" line="1849"/>
+        <location filename="onmainwindow.cpp" line="1661"/>
+        <location filename="onmainwindow.cpp" line="1844"/>
+        <location filename="onmainwindow.cpp" line="1874"/>
         <source>Please check LDAP settings</source>
         <translation>Vennligst sjekk LDAP innstillingene</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1671"/>
+        <location filename="onmainwindow.cpp" line="1696"/>
         <source>no X2Go server found in LDAP </source>
         <translation>Inge X2Go server ble funnet i LDAP </translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="2243"/>
+        <location filename="onmainwindow.cpp" line="2268"/>
         <source>Are you sure you want to delete this session?</source>
         <translation>Er du sikker på at du ønsker å fjerne denne sesjonen?</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="303"/>
-        <location filename="onmainwindow_part2.cpp" line="1320"/>
-        <location filename="onmainwindow_part2.cpp" line="1404"/>
-        <location filename="onmainwindow_part3.cpp" line="225"/>
-        <location filename="onmainwindow_part3.cpp" line="261"/>
-        <location filename="onmainwindow_part3.cpp" line="942"/>
-        <location filename="onmainwindow_part3.cpp" line="1023"/>
-        <location filename="onmainwindow_part3.cpp" line="1395"/>
-        <location filename="onmainwindow_part3.cpp" line="1448"/>
-        <location filename="onmainwindow_part3.cpp" line="2398"/>
+        <location filename="onmainwindow_part2.cpp" line="305"/>
+        <location filename="onmainwindow_part2.cpp" line="1322"/>
+        <location filename="onmainwindow_part2.cpp" line="1406"/>
+        <location filename="onmainwindow_part3.cpp" line="222"/>
+        <location filename="onmainwindow_part3.cpp" line="258"/>
+        <location filename="onmainwindow_part3.cpp" line="961"/>
+        <location filename="onmainwindow_part3.cpp" line="1042"/>
+        <location filename="onmainwindow_part3.cpp" line="1414"/>
+        <location filename="onmainwindow_part3.cpp" line="1467"/>
+        <location filename="onmainwindow_part3.cpp" line="2417"/>
         <source><b>Wrong password!</b><br><br></source>
         <translation><b>Feil passord!</b><br><br></translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="485"/>
+        <location filename="onmainwindow_part2.cpp" line="487"/>
         <source>No server availabel</source>
         <translation>Ingen tilgjengelig server</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1003"/>
-        <location filename="onmainwindow_part2.cpp" line="2121"/>
+        <location filename="onmainwindow.cpp" line="1009"/>
+        <location filename="onmainwindow_part2.cpp" line="2123"/>
         <source>Not connected</source>
         <oldsource>Active connection</oldsource>
         <translation>Ikke tilkoblet</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="2524"/>
-        <location filename="onmainwindow_part4.cpp" line="2099"/>
+        <location filename="onmainwindow_part2.cpp" line="2526"/>
+        <location filename="onmainwindow_part4.cpp" line="2126"/>
         <source>Creation time</source>
         <translation>Opprettelsestidspunkt</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1853"/>
-        <location filename="onmainwindow_part3.cpp" line="1269"/>
+        <location filename="onmainwindow_part2.cpp" line="1855"/>
+        <location filename="onmainwindow_part3.cpp" line="1288"/>
         <source>Unable to create folder:</source>
         <translation>Klarer ikke å opprette katalogen:</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="79"/>
+        <location filename="onmainwindow_part2.cpp" line="80"/>
         <source>Host key for server changed.
 It is now: </source>
         <translation>Vertsnøkkel for serveren har endret seg.
 Den er nå: </translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="80"/>
+        <location filename="onmainwindow_part2.cpp" line="81"/>
         <source>For security reasons, connection will be stopped</source>
         <translation>Av hensyn til sikkerheten vil tilkoblingen bli stoppet</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="91"/>
+        <location filename="onmainwindow_part2.cpp" line="92"/>
         <source>The host key for this server was not found but an othertype of key exists.An attacker might change the default server key toconfuse your client into thinking the key does not exist</source>
         <translation>Vertsnøkkelen for denne serveren ble ikke funnet, men en annen type av nøkkel eksisterer. En angriper kan endre standard server nøkkel for å lure klienten din til å tro at nøkkelen ikke finnes</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="113"/>
+        <location filename="onmainwindow_part2.cpp" line="114"/>
         <source>Could not find known host file.If you accept the host key here, the file will be automatically created</source>
         <translation>Kan ikke finne "known host" filen. Om du aksepterer vertsnøkkelen her vil filen automatisk bli opprettet</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="118"/>
+        <location filename="onmainwindow_part2.cpp" line="119"/>
         <source>The server is unknown. Do you trust the host key?
 Public key hash: </source>
         <translation>Serveren er ukjent. Stoler du på vertsnøkkelen?
 Offentlig nøkkel: </translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="122"/>
-        <location filename="onmainwindow_part2.cpp" line="130"/>
+        <location filename="onmainwindow_part2.cpp" line="123"/>
+        <location filename="onmainwindow_part2.cpp" line="131"/>
         <source>Host key verification failed</source>
         <translation>Verifiseringen av vertsnøkkelen feilet</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="146"/>
+        <location filename="onmainwindow_part2.cpp" line="147"/>
         <source>Authentication failed</source>
         <translation>PÃ¥logging feilet</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="494"/>
-        <location filename="onmainwindow_part2.cpp" line="803"/>
-        <location filename="onmainwindow_part2.cpp" line="1264"/>
-        <location filename="onmainwindow_part2.cpp" line="1376"/>
+        <location filename="onmainwindow_part2.cpp" line="496"/>
+        <location filename="onmainwindow_part2.cpp" line="805"/>
+        <location filename="onmainwindow_part2.cpp" line="1266"/>
+        <location filename="onmainwindow_part2.cpp" line="1378"/>
         <source>Server not availabel</source>
         <translation>Serveren er ikke tilgjengelig</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1879"/>
+        <location filename="onmainwindow_part2.cpp" line="1881"/>
         <source>Unable to write file:</source>
         <translation>Klarer ikke å skrive til filen:</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="2016"/>
-        <location filename="onmainwindow_part3.cpp" line="2469"/>
+        <location filename="onmainwindow_part2.cpp" line="2018"/>
+        <location filename="onmainwindow_part3.cpp" line="2488"/>
         <source>Unable to create SSL tunnel:
 </source>
         <translation>Klarte ikke å opprette SSL tunnel:
 </translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="1842"/>
+        <location filename="onmainwindow_part4.cpp" line="1853"/>
         <source><b>Session ID:<br>Server:<br>Username:<br>Display:<br>Creation time:<br>Status:</b></source>
         <translatorcomment>Uncertain if the translation for "Creation time" is the most fitting one.</translatorcomment>
         <translation><b>Sesjons ID:<br>Server:<br>Brukernavn:<br>Skjerm:<br>Opprettet:<br>Status:</b></translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="549"/>
-        <location filename="onmainwindow.cpp" line="1035"/>
-        <location filename="onmainwindow_part4.cpp" line="1852"/>
+        <location filename="onmainwindow.cpp" line="555"/>
+        <location filename="onmainwindow.cpp" line="1036"/>
+        <location filename="onmainwindow_part4.cpp" line="1870"/>
         <source>Share folder...</source>
         <translation>Del mappe...</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="1856"/>
+        <location filename="onmainwindow_part4.cpp" line="1888"/>
         <source>Show details</source>
         <translation>Vis detailjer</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="1716"/>
+        <location filename="onmainwindow_part3.cpp" line="1735"/>
         <source><b>X2Go client V. </source>
         <translation><b>X2Go klient v. </translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="2039"/>
+        <location filename="onmainwindow_part3.cpp" line="2058"/>
         <source>This card is unknown by X2Go system</source>
         <translatorcomment>Need to double-check if the translation of "card" is suitable here</translatorcomment>
         <translation>Dette kortet er ukjent for X2Go systemet</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="2232"/>
+        <location filename="onmainwindow_part3.cpp" line="2251"/>
         <source>Can't start X server
 Please check your settings</source>
-        <translation type="unfinished"></translation>
+        <translation>Klarte ikke å starte X-Serveren
+Vennligst sjekk instillingene dine</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="2434"/>
+        <location filename="onmainwindow_part3.cpp" line="2453"/>
         <source>Remote server does not support file system export through SSH Tunnel
 Please update to a newer x2goserver package</source>
         <translation>Serveren støtter ikke eksport av filsystemet over en SSH Tunnel
 Vennligst oppdater til en nyere x2goserver pakke</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="748"/>
+        <location filename="onmainwindow.cpp" line="754"/>
         <source>&Create session icon on desktop...</source>
         <translation>&Opprett sesjonsikon på skrivebordet...</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="757"/>
+        <location filename="onmainwindow.cpp" line="763"/>
         <source>&Set broker password...</source>
         <translatorcomment>Still uncertain what to best use as a translation for "broker"</translatorcomment>
         <translation>&Sett megler passord...</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="768"/>
+        <location filename="onmainwindow.cpp" line="774"/>
         <source>&Connectivity test...</source>
         <translation>&Tilkoblings-test...</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="884"/>
+        <location filename="onmainwindow.cpp" line="890"/>
         <source>Operation failed</source>
         <translation>Handlingen feilet</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="888"/>
+        <location filename="onmainwindow.cpp" line="894"/>
         <source>Password changed</source>
         <translation>Passordet er endret</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="912"/>
+        <location filename="onmainwindow.cpp" line="918"/>
         <source>Wrong password!</source>
         <translation>Feil passord!</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="961"/>
+        <location filename="onmainwindow.cpp" line="967"/>
         <source><b>Authentication</b></source>
         <translation><b>Autentisering</b></translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1001"/>
+        <location filename="onmainwindow.cpp" line="1007"/>
         <source>Restore</source>
         <translation>Gjenopprett</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1005"/>
+        <location filename="onmainwindow.cpp" line="1011"/>
         <source>Multimedia</source>
-        <translation type="unfinished"></translation>
+        <translation>Multimedia</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1007"/>
+        <location filename="onmainwindow.cpp" line="1013"/>
         <source>Development</source>
-        <translation type="unfinished"></translation>
+        <translation>Utvikling</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1009"/>
+        <location filename="onmainwindow.cpp" line="1015"/>
         <source>Education</source>
-        <translation type="unfinished"></translation>
+        <translation>Opplæring</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1011"/>
+        <location filename="onmainwindow.cpp" line="1017"/>
         <source>Game</source>
-        <translation type="unfinished"></translation>
+        <translation>Spill</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1013"/>
+        <location filename="onmainwindow.cpp" line="1019"/>
         <source>Graphics</source>
-        <translation type="unfinished"></translation>
+        <translation>Grafikk</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1015"/>
+        <location filename="onmainwindow.cpp" line="1021"/>
         <source>Network</source>
-        <translation type="unfinished"></translation>
+        <translation>Nettverk</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1017"/>
+        <location filename="onmainwindow.cpp" line="1023"/>
         <source>Office</source>
-        <translation type="unfinished"></translation>
+        <translation>Kontor</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1019"/>
+        <location filename="onmainwindow.cpp" line="1025"/>
         <source>Settings</source>
-        <translation type="unfinished">Innstillinger</translation>
+        <translation>Innstillinger</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1021"/>
+        <location filename="onmainwindow.cpp" line="1027"/>
         <source>System</source>
-        <translation type="unfinished"></translation>
+        <translation>System</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1023"/>
+        <location filename="onmainwindow.cpp" line="1029"/>
         <source>Utility</source>
-        <translation type="unfinished"></translation>
+        <translation>Verktøy</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1025"/>
+        <location filename="onmainwindow.cpp" line="1031"/>
         <source>Other</source>
-        <translation type="unfinished"></translation>
+        <translation>Andre</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1062"/>
+        <location filename="onmainwindow.cpp" line="1066"/>
         <source>Left mouse button to hide/restore - Right mouse button to display context menu</source>
         <oldsource>Left click to open the X2GoClient window or right click to get the context menu.</oldsource>
         <translatorcomment>According to the Norwegian skolelinux translation projects discussion on the words "context menu", I've chosen to follow their guidance and used "sprettoppmeny"</translatorcomment>
         <translation>Venstre museknapp for å skjule/gjenopprette  -  Høyre museknapp viser sprettoppmeny</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1983"/>
+        <location filename="onmainwindow.cpp" line="2008"/>
         <source>Create session icon on desktop</source>
         <translation>Opprett sesjonsikon på skrivebordet</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1984"/>
+        <location filename="onmainwindow.cpp" line="2009"/>
         <source>Desktop icons can be configured not to show x2goclient (hidden mode). If you like to use this feature you'll need to configure login by a gpg key or gpg smart card.
 
 Use x2goclient hidden mode?</source>
@@ -1747,45 +1746,45 @@ Use x2goclient hidden mode?</source>
 Ønsker du å aktivere skjult modus for x2goklient?</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="1995"/>
+        <location filename="onmainwindow.cpp" line="2020"/>
         <source>New Session</source>
         <translation>Ny sesjon</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="2095"/>
+        <location filename="onmainwindow.cpp" line="2120"/>
         <source>X2Go sessions not found</source>
         <translation>X2Go sesjoner ble ikke funnet</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="2613"/>
+        <location filename="onmainwindow.cpp" line="2638"/>
         <source>RDP connection</source>
         <translation>RDP tilkobling</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="2045"/>
+        <location filename="onmainwindow.cpp" line="2070"/>
         <source>X2Go Link to session </source>
         <translatorcomment>Uncertain of the context here, need to doublecheck this.</translatorcomment>
         <translation>X2Go kobling til sesjon </translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="561"/>
+        <location filename="onmainwindow.cpp" line="567"/>
         <location filename="onmainwindow_part4.cpp" line="1296"/>
         <source>Detach X2Go window</source>
         <translation>Løsne X2Go vindu</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1990"/>
+        <location filename="onmainwindow_part2.cpp" line="1992"/>
         <location filename="onmainwindow_part4.cpp" line="1271"/>
         <source>Attach X2Go window</source>
         <translation>Feste X2Go vindu</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="2193"/>
+        <location filename="onmainwindow_part2.cpp" line="2195"/>
         <source>Finished</source>
         <translation>Ferdig</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="2437"/>
+        <location filename="onmainwindow_part2.cpp" line="2439"/>
         <source>Are you sure you want to terminate this session?
 Unsaved documents will be lost</source>
         <translation>Er du sikker på at du vil avslutte denne sesjonen?
@@ -1796,7 +1795,7 @@ Ulagrede data vil gå tapt</translation>
         <translation type="obsolete"></b><br> (C. 2006-2009 <b>obviously nice</b>: Oleksandr Shneyder, Heinz-Markus Graesing)<br><br>Ein Client für den Zugriff auf die serverbasierende Anwendungsumgebung X2Go. Mit Hilfe dieser Anwendung können Sie Sitzungen eines X2Go Servers starten, stoppen, laufende Sitzungen fortführen oder anhalten und verschiedene Sitzungskonfigurationen verwalten. Die Authentifizierung kann über LDAP erfolgen und das Programm kann im Vollbildmodus (als Ersatz für XDM) gestartet werden. Weitere Informationen erhalten SIe auf x2go.org. </translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="2246"/>
+        <location filename="onmainwindow_part3.cpp" line="2265"/>
         <location filename="onmainwindow_part4.cpp" line="422"/>
         <location filename="onmainwindow_part4.cpp" line="450"/>
         <source>Can't start X Server
@@ -1810,13 +1809,13 @@ Vennligst sjekk din installasjon</translation>
         <translation>X2Go sesjon</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="564"/>
-        <location filename="onmainwindow_part4.cpp" line="2319"/>
+        <location filename="onmainwindow.cpp" line="570"/>
+        <location filename="onmainwindow_part4.cpp" line="2346"/>
         <source>Minimize toolbar</source>
         <translation>Minimer verktøylinje</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2352"/>
+        <location filename="onmainwindow_part4.cpp" line="2379"/>
         <source><br><b>&nbsp;&nbsp;&nbsp;Click this button&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;to restore toolbar&nbsp;&nbsp;&nbsp;</b><br></source>
         <translation><br><b>&nbsp;&nbsp;&nbsp;Trykk her&nbsp;&nbsp;&nbsp;<br> &nbsp;&nbsp;&nbsp;for å gjenopprette&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;verktøylinjen&nbsp;&nbsp;&nbsp;</b><br></translation>
     </message>
@@ -1825,7 +1824,7 @@ Vennligst sjekk din installasjon</translation>
         <translation type="obsolete">Konfigurationsdatei lässt sich nicht öffnen:</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2236"/>
+        <location filename="onmainwindow_part4.cpp" line="2263"/>
         <source>sshd not started, you'll need sshd for printing and file sharing
 you can install sshd with
 <b>sudo apt-get install openssh-server</b></source>
@@ -1834,65 +1833,65 @@ Du kan installere sshd med:
 <b>sudo apt-get install openssh-server</b></translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="2621"/>
+        <location filename="onmainwindow.cpp" line="2646"/>
         <source>Connection to local desktop</source>
         <translation>Tilkobling til lokalt skrivebord</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1094"/>
+        <location filename="onmainwindow_part2.cpp" line="1096"/>
         <source>Information</source>
         <translation>Informasjon</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1108"/>
-        <location filename="onmainwindow_part4.cpp" line="2420"/>
+        <location filename="onmainwindow_part2.cpp" line="1110"/>
+        <location filename="onmainwindow_part4.cpp" line="2447"/>
         <source>Filter</source>
         <translation>Filter</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1115"/>
+        <location filename="onmainwindow_part2.cpp" line="1117"/>
         <source>Select desktop:</source>
         <translation>Velg skrivebord:</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2027"/>
+        <location filename="onmainwindow_part4.cpp" line="2054"/>
         <source>View only</source>
         <translation>Kun vis</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2107"/>
+        <location filename="onmainwindow_part4.cpp" line="2134"/>
         <source>User</source>
         <translation>Bruker</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="2617"/>
+        <location filename="onmainwindow.cpp" line="2642"/>
         <source>XDMCP</source>
         <translation>XDMCP</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part2.cpp" line="1095"/>
+        <location filename="onmainwindow_part2.cpp" line="1097"/>
         <source>No accessible desktop found</source>
         <translation>Ingen tilgjengelige skrivebord ble funnet</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2024"/>
+        <location filename="onmainwindow_part4.cpp" line="2051"/>
         <source>Full access</source>
         <translation>Full tilgang</translation>
     </message>
     <message>
-        <location filename="onmainwindow_part4.cpp" line="2138"/>
+        <location filename="onmainwindow_part4.cpp" line="2165"/>
         <source>Only my desktops</source>
         <translation>Kun mine skrivebord</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="557"/>
+        <location filename="onmainwindow.cpp" line="563"/>
         <source>Reconnect</source>
         <translation>Gjenoppkoble</translation>
     </message>
     <message>
-        <location filename="onmainwindow.cpp" line="916"/>
-        <location filename="onmainwindow.cpp" line="2533"/>
-        <location filename="onmainwindow_part4.cpp" line="2489"/>
+        <location filename="onmainwindow.cpp" line="922"/>
+        <location filename="onmainwindow.cpp" line="2558"/>
+        <location filename="onmainwindow_part4.cpp" line="2516"/>
         <source>Connecting to broker</source>
         <translation>Koble til megleren</translation>
     </message>
@@ -1901,12 +1900,12 @@ Du kan installere sshd med:
         <translation type="obsolete"></b><br> (C. 2006-2010 <b>obviously nice</b>: Oleksandr Shneyder, Heinz-Markus Graesing)<br></translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="1699"/>
+        <location filename="onmainwindow_part3.cpp" line="1718"/>
         <source><br>x2goplugin mode was sponsored by <a href="http://www.foss-group.de/">FOSS-Group GmbH(Freiburg)</a><br></source>
         <translation><br>x2goplugin modusen ble sponset av <a href="http://www.foss-group.de/">FOSS-Group GmbH(Freiburg)</a><br></translation>
     </message>
     <message>
-        <location filename="onmainwindow_part3.cpp" line="1703"/>
+        <location filename="onmainwindow_part3.cpp" line="1722"/>
         <source><br>Client for use with the X2Go network based computing environment. This Client will be able to connect to X2Go server(s) and start, stop, resume and terminate (running) desktop sessions. X2Go Client stores different server connections and may automatically request authentification data from LDAP directories. Furthermore it can be used as fullscreen loginscreen (replacement for loginmanager like xdm). Please visit x2go.org for further information.</source>
         <translation><br>Ein Client für den Zugriff auf die serverbasierende Anwendungsumgebung X2Go. Mit Hilfe dieser Anwendung können Sie Sitzungen eines X2Go Servers starten, stoppen, laufende Sitzungen fortführen oder anhalten und verschiedene Sitzungskonfigurationen verwalten. Die Authentifizierung kann über LDAP erfolgen und das Programm kann im Vollbildmodus (als Ersatz für XDM) gestartet werden. Weitere Informationen erhalten SIe auf x2go.org. </translation>
     </message>
@@ -2139,119 +2138,119 @@ Eksempel:
 <context>
     <name>SessionButton</name>
     <message>
-        <location filename="sessionbutton.cpp" line="116"/>
+        <location filename="sessionbutton.cpp" line="129"/>
         <source>Session preferences...</source>
         <translation>Sesjonsinnstillinger...</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="120"/>
+        <location filename="sessionbutton.cpp" line="133"/>
         <source>Create session icon on desktop...</source>
         <translation>Opprett sesjonsikon på skrivebordet...</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="125"/>
+        <location filename="sessionbutton.cpp" line="138"/>
         <source>Delete session</source>
         <translation>Slett sesjon</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="138"/>
+        <location filename="sessionbutton.cpp" line="151"/>
         <source>Session actions</source>
         <translation>Sesjonshandlinger</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="139"/>
+        <location filename="sessionbutton.cpp" line="152"/>
         <source>Select type</source>
         <translation>Velg type</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="141"/>
+        <location filename="sessionbutton.cpp" line="154"/>
         <source>Select resolution</source>
         <translation>Velg oppløsning</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="142"/>
+        <location filename="sessionbutton.cpp" line="155"/>
         <source>Toggle sound support</source>
         <translation>Slå av/på lydstøtte</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="272"/>
+        <location filename="sessionbutton.cpp" line="285"/>
         <source>New Session</source>
         <translation>Ny sesjon</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="277"/>
+        <location filename="sessionbutton.cpp" line="290"/>
         <source>running</source>
         <translation>aktiv</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="281"/>
+        <location filename="sessionbutton.cpp" line="294"/>
         <source>suspended</source>
         <translation>frakoblet</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="314"/>
+        <location filename="sessionbutton.cpp" line="327"/>
         <source>KDE</source>
         <translation>KDE</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="327"/>
-        <location filename="sessionbutton.cpp" line="360"/>
-        <location filename="sessionbutton.cpp" line="627"/>
+        <location filename="sessionbutton.cpp" line="340"/>
+        <location filename="sessionbutton.cpp" line="373"/>
+        <location filename="sessionbutton.cpp" line="640"/>
         <source>RDP connection</source>
         <translation>RDP tilkobling</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="328"/>
-        <location filename="sessionbutton.cpp" line="366"/>
-        <location filename="sessionbutton.cpp" line="633"/>
+        <location filename="sessionbutton.cpp" line="341"/>
+        <location filename="sessionbutton.cpp" line="379"/>
+        <location filename="sessionbutton.cpp" line="646"/>
         <source>XDMCP</source>
         <translation>XDMCP</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="329"/>
-        <location filename="sessionbutton.cpp" line="354"/>
-        <location filename="sessionbutton.cpp" line="621"/>
+        <location filename="sessionbutton.cpp" line="342"/>
+        <location filename="sessionbutton.cpp" line="367"/>
+        <location filename="sessionbutton.cpp" line="634"/>
         <source>Connection to local desktop</source>
         <translation>Tilkobling til lokalt skrivebord</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="330"/>
-        <location filename="sessionbutton.cpp" line="371"/>
-        <location filename="sessionbutton.cpp" line="659"/>
+        <location filename="sessionbutton.cpp" line="343"/>
+        <location filename="sessionbutton.cpp" line="384"/>
+        <location filename="sessionbutton.cpp" line="672"/>
         <source>Published applications</source>
-        <translation type="unfinished"></translation>
+        <translation>Publiserte applikasjoner</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="395"/>
-        <location filename="sessionbutton.cpp" line="412"/>
-        <location filename="sessionbutton.cpp" line="680"/>
+        <location filename="sessionbutton.cpp" line="408"/>
+        <location filename="sessionbutton.cpp" line="425"/>
+        <location filename="sessionbutton.cpp" line="693"/>
         <source>fullscreen</source>
         <translation>fullskjerm</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="399"/>
-        <location filename="sessionbutton.cpp" line="422"/>
-        <location filename="sessionbutton.cpp" line="426"/>
-        <location filename="sessionbutton.cpp" line="686"/>
-        <location filename="sessionbutton.cpp" line="689"/>
+        <location filename="sessionbutton.cpp" line="412"/>
+        <location filename="sessionbutton.cpp" line="435"/>
+        <location filename="sessionbutton.cpp" line="439"/>
+        <location filename="sessionbutton.cpp" line="699"/>
+        <location filename="sessionbutton.cpp" line="702"/>
         <source>Display </source>
         <translation>Skjerm </translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="407"/>
-        <location filename="sessionbutton.cpp" line="447"/>
+        <location filename="sessionbutton.cpp" line="420"/>
+        <location filename="sessionbutton.cpp" line="460"/>
         <source>window</source>
         <translation>vindu</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="455"/>
-        <location filename="sessionbutton.cpp" line="585"/>
+        <location filename="sessionbutton.cpp" line="468"/>
+        <location filename="sessionbutton.cpp" line="598"/>
         <source>Enabled</source>
         <translation>Aktivert</translation>
     </message>
     <message>
-        <location filename="sessionbutton.cpp" line="457"/>
-        <location filename="sessionbutton.cpp" line="587"/>
+        <location filename="sessionbutton.cpp" line="470"/>
+        <location filename="sessionbutton.cpp" line="600"/>
         <source>Disabled</source>
         <translation>Deaktivert</translation>
     </message>
@@ -2382,7 +2381,7 @@ Eksempel:
     <message>
         <location filename="sessionwidget.cpp" line="132"/>
         <source>Published applications</source>
-        <translation type="unfinished"></translation>
+        <translation>Publiserte applikasjoner</translation>
     </message>
     <message>
         <location filename="sessionwidget.cpp" line="134"/>
@@ -2675,85 +2674,85 @@ lydsystem forbindelser gjennom brannmurer</translation>
 <context>
     <name>SshMasterConnection</name>
     <message>
-        <location filename="sshmasterconnection.cpp" line="124"/>
+        <location filename="sshmasterconnection.cpp" line="130"/>
         <source>Can not initialize libssh</source>
         <translatorcomment>I need to revisit the word 'initiere', a better word could be 'klargjøre'</translatorcomment>
         <translation>Klarer ikke å initiere libssh</translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="145"/>
+        <location filename="sshmasterconnection.cpp" line="151"/>
         <source>Can not create ssh session</source>
         <translation>Klarer ikke å opprette ssh sesjon</translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="163"/>
+        <location filename="sshmasterconnection.cpp" line="169"/>
         <source>Can not connect to </source>
         <translation>Klarer ikke å koble til </translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="204"/>
+        <location filename="sshmasterconnection.cpp" line="210"/>
         <source>Authentication failed</source>
         <translation>Autentisering feilet</translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="220"/>
+        <location filename="sshmasterconnection.cpp" line="236"/>
         <source>channel_forward_listen failed</source>
         <translatorcomment>I'm not sure if this is a static variable which shouldn't be translated or not, but I left it as I believe it's a variable.</translatorcomment>
         <translation>channel_forward_listen feilet</translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="534"/>
+        <location filename="sshmasterconnection.cpp" line="550"/>
         <source>Can not open file </source>
         <translation>Kan ikke åpne filen </translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="546"/>
+        <location filename="sshmasterconnection.cpp" line="562"/>
         <source>Can not create remote file </source>
         <translation>Klarer ikke å opprette fil over nettverket </translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="559"/>
+        <location filename="sshmasterconnection.cpp" line="575"/>
         <source>Can not write to remote file </source>
         <translation>Klarer ikke å skrive til filen over nettverket </translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="609"/>
+        <location filename="sshmasterconnection.cpp" line="632"/>
         <source>can not connect to </source>
         <translation>Klarer ikke å koble til </translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="718"/>
+        <location filename="sshmasterconnection.cpp" line="741"/>
         <source>channel_open_forward failed</source>
         <translation>channel_open_forward feilet</translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="737"/>
+        <location filename="sshmasterconnection.cpp" line="760"/>
         <source>channel_open_session failed</source>
         <translation>channel_open_session feilet</translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="744"/>
+        <location filename="sshmasterconnection.cpp" line="767"/>
         <source>channel_request_exec failed</source>
         <translation>channel_request_exec feilet</translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="809"/>
+        <location filename="sshmasterconnection.cpp" line="832"/>
         <source>error writing to socket</source>
         <translatorcomment>Really not any great words to best translate socket into...</translatorcomment>
         <translation>feil ved skriving til sokkelen</translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="827"/>
+        <location filename="sshmasterconnection.cpp" line="850"/>
         <source>error reading channel</source>
         <translation>feil under lesing av kanalen</translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="857"/>
+        <location filename="sshmasterconnection.cpp" line="880"/>
         <source>channel_write failed</source>
         <translation>channel_write feilet</translation>
     </message>
     <message>
-        <location filename="sshmasterconnection.cpp" line="869"/>
+        <location filename="sshmasterconnection.cpp" line="892"/>
         <source>error reading tcp socket</source>
         <translation>feil ved lesing av tcp sokkelen</translation>
     </message>
diff --git a/x2goclient_sv.ts b/x2goclient_sv.ts
index 6532b01..434baed 100644
--- a/x2goclient_sv.ts
+++ b/x2goclient_sv.ts
@@ -6,77 +6,77 @@
     <message>
         <location filename="appdialog.ui" line="14"/>
         <source>Published Applications</source>
-        <translation type="unfinished"></translation>
+        <translation>Publicerade applikationer</translation>
     </message>
     <message>
         <location filename="appdialog.ui" line="60"/>
         <source>Search:</source>
-        <translation type="unfinished"></translation>
+        <translation>Sök:</translation>
     </message>
     <message>
         <location filename="appdialog.ui" line="76"/>
         <source>&Start</source>
-        <translation type="unfinished"></translation>
+        <translation>&Starta</translation>
     </message>
     <message>
         <location filename="appdialog.ui" line="96"/>
         <source>&Close</source>
-        <translation type="unfinished"></translation>
+        <translation>S&täng</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="105"/>
         <source>Multimedia</source>
-        <translation type="unfinished"></translation>
+        <translation>Ljud och video</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="110"/>
         <source>Development</source>
-        <translation type="unfinished"></translation>
+        <translation>Programmering</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="115"/>
         <source>Education</source>
-        <translation type="unfinished"></translation>
+        <translation>Utbildning</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="120"/>
         <source>Game</source>
-        <translation type="unfinished"></translation>
+        <translation>Spel</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="125"/>
         <source>Graphics</source>
-        <translation type="unfinished"></translation>
+        <translation>Grafik</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="130"/>
         <source>Network</source>
-        <translation type="unfinished"></translation>
+        <translation>Nätverk</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="135"/>
         <source>Office</source>
-        <translation type="unfinished"></translation>
+        <translation>Kontor</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="140"/>
         <source>Settings</source>
-        <translation type="unfinished">Inställningar</translation>
+        <translation>Inställningar</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="145"/>
         <source>System</source>
-        <translation type="unfinished"></translation>
+        <translation>System</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="150"/>
         <source>Utility</source>
-        <translation type="unfinished"></translation>
+        <translation>Verktyg</translation>
     </message>
     <message>
         <location filename="appdialog.cpp" line="155"/>
         <source>Other</source>
-        <translation type="unfinished"></translation>
+        <translation>Övrigt</translation>
     </message>
 </context>
 <context>
@@ -591,7 +591,7 @@
     <message>
         <location filename="exportdialog.cpp" line="73"/>
         <source>share folders</source>
-        <translation>dela mappar</translation>
+        <translation>Dela mappar</translation>
     </message>
     <message>
         <location filename="exportdialog.cpp" line="139"/>
@@ -1016,57 +1016,57 @@
     <message>
         <location filename="onmainwindow.cpp" line="1005"/>
         <source>Multimedia</source>
-        <translation type="unfinished"></translation>
+        <translation>Ljud och video</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1007"/>
         <source>Development</source>
-        <translation type="unfinished"></translation>
+        <translation>Programmering</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1009"/>
         <source>Education</source>
-        <translation type="unfinished"></translation>
+        <translation>Utbildning</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1011"/>
         <source>Game</source>
-        <translation type="unfinished"></translation>
+        <translation>Spel</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1013"/>
         <source>Graphics</source>
-        <translation type="unfinished"></translation>
+        <translation>Grafik</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1015"/>
         <source>Network</source>
-        <translation type="unfinished"></translation>
+        <translation>Nätverk</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1017"/>
         <source>Office</source>
-        <translation type="unfinished"></translation>
+        <translation>Kontor</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1019"/>
         <source>Settings</source>
-        <translation type="unfinished">Inställningar</translation>
+        <translation>Inställningar</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1021"/>
         <source>System</source>
-        <translation type="unfinished"></translation>
+        <translation>System</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1023"/>
         <source>Utility</source>
-        <translation type="unfinished"></translation>
+        <translation>Verktyg</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1025"/>
         <source>Other</source>
-        <translation type="unfinished"></translation>
+        <translation>Övrigt</translation>
     </message>
     <message>
         <location filename="onmainwindow.cpp" line="1062"/>
@@ -1559,7 +1559,8 @@ Data som ej sparats kommer att förloras</translation>
         <location filename="onmainwindow_part3.cpp" line="2232"/>
         <source>Can't start X server
 Please check your settings</source>
-        <translation type="unfinished"></translation>
+        <translation>Kan ej starta X-server
+Kontrollera dina inställningar</translation>
     </message>
     <message>
         <source>Can't connect to X-Server</source>
@@ -1571,7 +1572,7 @@ Please check your settings</source>
 Please check your settings</source>
         <oldsource>Can't connect to X-Server
 Please check your settings</oldsource>
-        <translation type="unfinished">Kan ej ansluta till X-server
+        <translation>Kan ej ansluta till X-server
 Kontrollera dina inställningar</translation>
     </message>
     <message>
@@ -1666,7 +1667,7 @@ Uppdatera till en nyare version av x2goserver</translation>
     <message>
         <location filename="onmainwindow_part4.cpp" line="1850"/>
         <source>Applications...</source>
-        <translation type="unfinished"></translation>
+        <translation>Applikationer...</translation>
     </message>
     <message>
         <location filename="onmainwindow_part4.cpp" line="1854"/>
@@ -2047,7 +2048,7 @@ Example:
         <location filename="sessionbutton.cpp" line="371"/>
         <location filename="sessionbutton.cpp" line="659"/>
         <source>Published applications</source>
-        <translation type="unfinished"></translation>
+        <translation>Publicerade applikationer</translation>
     </message>
     <message>
         <location filename="sessionbutton.cpp" line="395"/>
@@ -2210,7 +2211,7 @@ Example:
     <message>
         <location filename="sessionwidget.cpp" line="132"/>
         <source>Published applications</source>
-        <translation type="unfinished"></translation>
+        <translation>Publicerade applikationer</translation>
     </message>
     <message>
         <location filename="sessionwidget.cpp" line="134"/>
diff --git a/x2goplugin.rc b/x2goplugin.rc
index ef7a9ea..ea22b6a 100644
--- a/x2goplugin.rc
+++ b/x2goplugin.rc
@@ -1,8 +1,8 @@
 1 TYPELIB "x2goplugin.rc"
 
 1 VERSIONINFO
- FILEVERSION 3,99,2,0
- PRODUCTVERSION 3,99,2,0
+ FILEVERSION 3,99,2,1
+ PRODUCTVERSION 3,99,2,1
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -21,13 +21,13 @@ BEGIN
             VALUE "FileDescription", "Allows you to start X2Go session in a webbrowser\0"
 	    VALUE "FileExtents", "x2go\0"
 	    VALUE "FileOpenName", "Configuration File for X2Go Session (*.x2go)\0"
-            VALUE "FileVersion", "3, 99, 2 ,0\0"
+            VALUE "FileVersion", "3, 99, 2 ,1\0"
             VALUE "InternalName", "x2goplugin\0"
             VALUE "LegalCopyright", "Copyright © 2010-2012 Obviously Nice\0"
 	    VALUE "MIMEType", "application/x2go\0"
             VALUE "OriginalFilename", "npx2goplugin.dll\0"
-            VALUE "ProductName", "X2GoClient Plug-in 3.99.2.0\0"
-            VALUE "ProductVersion", "3, 99, 2, 0\0"
+            VALUE "ProductName", "X2GoClient Plug-in 3.99.2.1\0"
+            VALUE "ProductVersion", "3, 99, 2, 1\0"
         END
     END
     BLOCK "VarFileInfo"


hooks/post-receive
-- 
x2goclient.git (X2Go Client)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2goclient.git" (X2Go Client).




More information about the x2go-commits mailing list