Ejemplo n.º 1
0
void ConnectionWidget::saveSettings()
{

	X2goSettings st ( "sessions" );
	st.setting()->setValue ( sessionId+"/speed", ( QVariant ) spd->value() );
	st.setting()->setValue ( sessionId+"/pack",
	              ( QVariant ) packMethode->currentText() );
	st.setting()->setValue ( sessionId+"/quality", ( QVariant ) quali->value() );
	st.setting()->sync();
}
Ejemplo n.º 2
0
void SessionButton::slot_soundClicked()
{
    bool snd=!soundIcon->isEnabled();
    soundIcon->setEnabled ( snd );
    if ( snd )
        sound->setText ( tr ( "Enabled" ) );
    else
        sound->setText ( tr ( "Disabled" ) );
    QFontMetrics fm ( sound->font() );
    sound->setFixedSize ( fm.size ( Qt::TextSingleLine,sound->text() ) +
                          QSize ( 8,4 ) );

    X2goSettings st ( "sessions" );
    st.setting()->setValue ( sid+"/sound", ( QVariant ) snd );
    st.setting()->sync();


}
Ejemplo n.º 3
0
void ConnectionWidget::readConfig()
{

	loadPackMethods();
	X2goSettings st ( "sessions" );

	spd->setValue ( st.setting()->value (
	                    sessionId+"/speed",
	                    ( QVariant ) mainWindow->getDefaultLink()
	                ).toInt() );
	QString mt=st.setting()->value (
	               sessionId+"/pack",
	               ( QVariant ) mainWindow->getDefaultPack() ).toString();


	packMethode->setCurrentIndex ( packMethode->findText ( mt ) );
	quali->setValue ( st.setting()->value ( sessionId+"/quality",
	                             mainWindow->getDefaultQuality() ).toInt() );
	slot_changePack ( mt );
}
Ejemplo n.º 4
0
ConfigDialog::ConfigDialog ( QWidget * parent,  Qt::WFlags f )
    : QDialog ( parent,f )
{

    tabWidg=new QTabWidget ( this );
    QVBoxLayout* ml=new QVBoxLayout ( this );
    ml->addWidget ( tabWidg );

    QWidget *fr=new QWidget ( this );
    QVBoxLayout* frLay=new QVBoxLayout ( fr );
    tabWidg->addTab ( fr,tr ( "General" ) );

    embedMode= ( ( ONMainWindow* ) parent )->getEmbedMode();

    X2goSettings st ( "settings" );


#ifndef CFGPLUGIN

    gbTrayIcon=new QGroupBox(tr("Display icon in system tray"),fr);
    frLay->addWidget(gbTrayIcon);
    gbTrayIcon->setCheckable(true);
    QHBoxLayout* grmainLay=new QHBoxLayout(gbTrayIcon);
    QFrame* frTray=new QFrame(gbTrayIcon);
    grmainLay->setMargin(0);
    grmainLay->addWidget(frTray);
    cbMinToTray=new QCheckBox(tr("Hide to system tray when minimized"),frTray);
    cbNoClose=new QCheckBox(tr("Hide to system tray when closed"),frTray);
    cbMinimizeTray=new QCheckBox(tr("Hide to system tray after connection is established"),frTray);
    cbMaxmizeTray=new QCheckBox(tr("Restore from system tray after session is disconnected"),frTray);
    QVBoxLayout* trLay=new QVBoxLayout(frTray);
    trLay->addWidget(cbMinToTray);
    trLay->addWidget(cbNoClose);
    trLay->addWidget(cbMinimizeTray);
    trLay->addWidget(cbMaxmizeTray);
    gbTrayIcon->setChecked ( st.setting()->value ( "trayicon/enabled", false ).toBool() );
    cbMinimizeTray->setChecked ( st.setting()->value ( "trayicon/mincon", false ).toBool() );
    cbMaxmizeTray->setChecked ( st.setting()->value ( "trayicon/maxdiscon", false ).toBool() );
    cbNoClose->setChecked ( st.setting()->value ( "trayicon/noclose", false ).toBool() );
    cbMinToTray->setChecked ( st.setting()->value ( "trayicon/mintotray", false ).toBool() );
#endif

#ifdef USELDAP
    if ( !embedMode )
    {
        ONMainWindow* par= ( ONMainWindow* ) parent;

        gbLDAP=new QGroupBox ( tr ( "Use LDAP" ),fr );
        gbLDAP->setCheckable(true);
        QHBoxLayout* grmainLay=new QHBoxLayout(gbLDAP);
        QFrame* frLdap=new QFrame(gbLDAP);
        grmainLay->setMargin(0);
        grmainLay->addWidget(frLdap);

        ldapServer=new QLineEdit ( frLdap );
        port=new QSpinBox ( frLdap );
        ldapBase=new QLineEdit ( frLdap );
        port->setMaximum ( 1000000 );

        QHBoxLayout *grLay=new QHBoxLayout ( frLdap );

        QVBoxLayout *laiLay=new QVBoxLayout();
        QVBoxLayout *setLay=new QVBoxLayout();
        setLay->setSpacing ( 6 );
        laiLay->setSpacing ( 6 );

        grLay->setSpacing ( 20 );
        grLay->addLayout ( laiLay );
        grLay->addStretch();
        grLay->addLayout ( setLay );

        laiLay->addWidget ( new QLabel ( tr ( "Server URL:" ),frLdap) );
        laiLay->addWidget ( new QLabel ( tr ( "BaseDN:" ),frLdap ) );
        laiLay->addWidget ( new QLabel (
                                tr ( "Failover server 1 URL:" ),frLdap ) );
        laiLay->addWidget ( new QLabel (
                                tr ( "Failover server 2 URL:" ),frLdap ) );

        ldapServer1=new QLineEdit ( frLdap);
        port1=new QSpinBox ( frLdap );
        ldapServer2=new QLineEdit ( frLdap );
        port2=new QSpinBox ( frLdap );
        port1->setMaximum ( 1000000 );
        port2->setMaximum ( 1000000 );


        QHBoxLayout* aLay=new QHBoxLayout();
        aLay->setSpacing ( 3 );
        aLay->addWidget ( new QLabel ( "ldap//:",frLdap ) );
        aLay->addWidget ( ldapServer );
        aLay->addWidget ( new QLabel ( ":",frLdap ) );
        aLay->addWidget ( port );

        QHBoxLayout* aLay1=new QHBoxLayout();
        aLay1->setSpacing ( 3 );
        aLay1->addWidget ( new QLabel ( "ldap//:",frLdap ) );
        aLay1->addWidget ( ldapServer1 );
        aLay1->addWidget ( new QLabel ( ":",frLdap ) );
        aLay1->addWidget ( port1 );

        QHBoxLayout* aLay2=new QHBoxLayout();
        aLay2->setSpacing ( 3 );
        aLay2->addWidget ( new QLabel ( "ldap//:",frLdap ) );
        aLay2->addWidget ( ldapServer2 );
        aLay2->addWidget ( new QLabel ( ":",frLdap ) );
        aLay2->addWidget ( port2 );


        setLay->addLayout ( aLay );
        setLay->addWidget ( ldapBase );
        setLay->addLayout ( aLay1 );
        setLay->addLayout ( aLay2 );


        gbLDAP->setChecked ( st.setting()->value ( "LDAP/useldap",
                             ( QVariant ) par->retUseLdap()
                                                 ).toBool() );
        ldapServer->setText ( st.setting()->value (
                                  "LDAP/server",
                                  ( QVariant ) par->retLdapServer()
                              ).toString() );
        port->setValue ( st.setting()->value ( "LDAP/port",
                                               ( QVariant ) par->retLdapPort()
                                             ).toInt() );
        ldapServer1->setText ( st.setting()->value (
                                   "LDAP/server1",
                                   ( QVariant ) par->retLdapServer1()
                               ).toString() );
        port1->setValue ( st.setting()->value ( "LDAP/port1",
                                                ( QVariant ) par->retLdapPort1()
                                              ).toInt() );
        ldapServer2->setText ( st.setting()->value (
                                   "LDAP/server2",
                                   ( QVariant ) par->retLdapServer2()
                               ).toString() );
        port2->setValue ( st.setting()->value ( "LDAP/port2",
                                                ( QVariant ) par->retLdapPort2()
                                              ).toInt() );
        ldapBase->setText ( st.setting()->value ( "LDAP/basedn",
                            ( QVariant ) par->retLdapDn()
                                                ).toString() );
        frLdap->setEnabled ( gbLDAP->isChecked() );
        frLay->addWidget ( gbLDAP );
        connect ( gbLDAP,SIGNAL ( toggled ( bool ) ),frLdap,
                  SLOT ( setEnabled ( bool ) ) );

        connect ( gbLDAP,SIGNAL ( toggled ( bool ) ),this,
                  SLOT ( slot_checkOkStat() ) );
        connect ( ldapBase,SIGNAL ( textChanged ( const QString& ) ),
                  this,
                  SLOT ( slot_checkOkStat() ) );
        connect ( ldapServer,SIGNAL ( textChanged ( const QString& ) ),
                  this,
                  SLOT ( slot_checkOkStat() ) );
    }
Ejemplo n.º 5
0
void SessionButton::slot_geom_change ( const QString& new_g )
{
    geom->setText ( new_g );
    X2goSettings st ( "sessions" );
    if ( new_g==tr ( "fullscreen" ) )
    {
        st.setting()->setValue ( sid+"/fullscreen", ( QVariant ) true );
        st.setting()->setValue ( sid+"/multidisp", ( QVariant ) false );
        st.setting()->setValue ( sid+"/maxdim", ( QVariant ) false );
    }
    else if ( new_g==tr ( "Maximum" ))
    {
        st.setting()->setValue ( sid+"/fullscreen", ( QVariant ) false );
        st.setting()->setValue ( sid+"/multidisp", ( QVariant ) false );
        st.setting()->setValue ( sid+"/maxdim", ( QVariant ) true );
    }
    else if (new_g.indexOf(tr("Display "))==0)
    {
        QString g= new_g;
        g.replace(tr("Display "),"");
        st.setting()->setValue ( sid+"/multidisp", ( QVariant ) true );
        st.setting()->setValue ( sid+"/display", ( QVariant ) g.toUInt());
        st.setting()->setValue ( sid+"/fullscreen", ( QVariant ) false );
        st.setting()->setValue ( sid+"/maxdim", ( QVariant ) false );
    }
    else
    {
        QString new_geom=new_g;
#ifdef Q_WS_HILDON
        new_geom="800x600";
#endif
        st.setting()->setValue ( sid+"/fullscreen", ( QVariant ) false );
        st.setting()->setValue ( sid+"/multidisp", ( QVariant ) false );
        st.setting()->setValue ( sid+"/maxdim", ( QVariant ) false );
        QStringList lst=new_geom.split ( 'x' );
        st.setting()->setValue ( sid+"/width", ( QVariant ) lst[0] );
        st.setting()->setValue ( sid+"/height", ( QVariant ) lst[1] );
    }
    st.setting()->sync();
}
Ejemplo n.º 6
0
void SessionButton::slot_cmd_change ( const QString& command )
{
    cmd->setText ( command );
    QPixmap pix;
    bool newRootless=rootless;
    published=false;
    QString cmd=command;
    if ( command=="KDE" )
    {
        newRootless=false;
        pix.load ( par->iconsPath ( "/16x16/kde.png" ) );
    }
    else if ( command =="GNOME" )
    {
        newRootless=false;
        pix.load ( par->iconsPath ( "/16x16/gnome.png" ) );
    }
    else if ( command =="LXDE" )
    {
        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 == "XFCE" )
    {
        newRootless=false;
        pix.load ( par->iconsPath ( "/16x16/xfce.png" ) );
    }
    else if ( command == "MATE" )
    {
        newRootless=false;
        pix.load ( par->iconsPath ( "/16x16/mate.png" ) );
    }
    else if ( command == "CINNAMON" )
    {
        newRootless=false;
        // As of 2014-10-01, Cinnamon does not have a logo. This icon is the
        // gear, which is the default start menu icon as of 2.2.
        pix.load ( par->iconsPath ( "/16x16/cinnamon.png" ) );
    }
    else if ( command == "TRINITY" )
    {
        newRootless=false;
        pix.load ( par->iconsPath ( "/16x16/trinity.png" ) );
    }
    else if ( command == "OPENBOX" )
    {
        newRootless=false;
        pix.load ( par->iconsPath ( "/16x16/openbox.png" ) );
    }
    else if ( command == "ICEWM" )
    {
        newRootless=false;
        pix.load ( par->iconsPath ( "/16x16/icewm.png" ) );
    }
    else if ( command ==tr ( "Connection to local desktop" ) )
    {
        newRootless=false;
        pix.load ( par->iconsPath ( "/16x16/X.png" ) );
        cmd="SHADOW";
    }
    else if ( command == tr ( "RDP connection" ) )
    {
        newRootless=false;
        pix.load ( par->iconsPath ( "/16x16/rdp.png" ) );
        cmd="RDP";
    }
    else if ( command == tr ( "XDMCP" ) )
    {
        newRootless=false;
        pix.load ( par->iconsPath ( "/16x16/X.png" ) );
        cmd="XDMCP";
    }
    else
        pix.load ( par->iconsPath ( "/16x16/X.png" ) );
    cmdIcon->setPixmap ( pix );

    X2goSettings st ( "sessions" );
    if ( command=="startkde" )
    {
        cmd="KDE";
        newRootless=false;
    }
    if ( command=="gnome-session" )
    {
        cmd="GNOME";
        newRootless=false;
    }
    if ( command=="LXDE" )
    {
        cmd="LXDE";
        newRootless=false;
    }
    if ( command=="unity" )
    {
        cmd="UNITY";
        newRootless=false;
    }
    if ( command=="xfce4-session" )
    {
        cmd="XFCE";
        newRootless=false;
    }
    if ( command=="mate-session" )
    {
        cmd="MATE";
        newRootless=false;
    }
    if ( command=="cinnamon-session" )
    {
        cmd="CINNAMON";
        newRootless=false;
    }
    if (command== tr("Published applications"))
    {
        published=true;
        cmd="PUBLISHED";
    }
    bool found=false;
    cmd=par->internAppName ( cmd,&found );
    if ( found )
        newRootless=true;
    st.setting()->setValue ( sid+"/command", ( QVariant ) cmd );
    st.setting()->setValue ( sid+"/rootless", ( QVariant ) newRootless );
    st.setting()->setValue ( sid+"/published", ( QVariant ) published );
    st.setting()->sync();

}
Ejemplo n.º 7
0
void SessionButton::redraw()
{
    bool snd;


    X2goSettings *st;

    if (par->brokerMode)
        st=new X2goSettings(par->config.iniFile,QSettings::IniFormat);
    else
        st= new X2goSettings( "sessions" );

    QString name=st->setting()->value ( sid+"/name",
                                        ( QVariant ) tr ( "New Session" ) ).toString();

    QStringList tails=name.split("/",QString::SkipEmptyParts);
    if(tails.count()>0)
    {
        name=tails.last();
        tails.pop_back();
        path=tails.join("/");
    }

    sessName->setText (name);

    QString status=st->setting()->value ( sid+"/status",
                                          ( QVariant ) QString::null ).toString();
    if (status == "R")
    {
        sessStatus->setText("("+tr("running")+")");
    }
    if (status == "S")
    {
        sessStatus->setText("("+tr("suspended")+")");
    }

    QString sessIcon = wrap_legacy_resource_URIs (st->setting()->value (sid+"/icon",
                                                                        (QVariant) ":/img/icons/128x128/x2gosession.png"
                                                                       ).toString ());
    sessIcon = expandHome(sessIcon);
    QPixmap* pix;

    x2goDebug << "Creating QPixmap with session icon: " << sessIcon.toAscii () << ".";
    if (!par->brokerMode || sessIcon == ":/img/icons/128x128/x2gosession.png")
        pix=new QPixmap( sessIcon );
    else
    {
        pix=new QPixmap;
        pix->loadFromData(QByteArray::fromBase64(sessIcon.toAscii()));
    }
    if ( !par->retMiniMode() )
        icon->setPixmap ( pix->scaled ( 64,64,Qt::IgnoreAspectRatio,
                                        Qt::SmoothTransformation ) );
    else
        icon->setPixmap ( pix->scaled ( 48,48,Qt::IgnoreAspectRatio,
                                        Qt::SmoothTransformation ) );

    delete pix;
    QString sv=st->setting()->value ( sid+"/host", ( QVariant )
                                      QString::null ).toString();
    QString uname=st->setting()->value ( sid+"/user", ( QVariant )
                                         QString::null ).toString();
    server->setText ( uname+"@"+sv );

    QString command=st->setting()->value ( sid+"/command",
                                           ( QVariant )
                                           tr (
                                                   "KDE" ) ).
                    toString();
    rootless=st->setting()->value ( sid+"/rootless",
                                    false ).toBool();
    published=st->setting()->value ( sid+"/published",
                                     false ).toBool();


    cmdBox->clear();
    cmdBox->addItem ( "KDE" );
    cmdBox->addItem ( "GNOME" );
    cmdBox->addItem ( "LXDE" );
    cmdBox->addItem ( "XFCE" );
    cmdBox->addItem ( "MATE" );
    cmdBox->addItem ( "UNITY" );
    cmdBox->addItem ( "CINNAMON" );
    cmdBox->addItem ( "TRINITY" );
    cmdBox->addItem ( "OPENBOX" );
    cmdBox->addItem ( "ICEWM" );
    cmdBox->addItem ( tr ( "RDP connection" ) );
    cmdBox->addItem ( tr ( "XDMCP" ) );
    cmdBox->addItem ( tr ( "Connection to local desktop" ) );
    cmdBox->addItem ( tr ( "Published applications" ) );

    cmdBox->addItems ( par->transApplicationsNames() );

    bool directRDP=false;
    QPixmap cmdpix;
    if ( command=="KDE" )
    {
        cmdpix.load ( par->iconsPath ( "/16x16/kde.png" ) );
        cmdBox->setCurrentIndex ( KDE );
    }
    else if ( command =="GNOME" )
    {
        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 == "XFCE" )
    {
        cmdpix.load ( par->iconsPath ( "/16x16/xfce.png" ) );
        cmdBox->setCurrentIndex ( XFCE );
    }
    else if ( command == "MATE" )
    {
        cmdpix.load ( par->iconsPath ( "/16x16/mate.png" ) );
        cmdBox->setCurrentIndex ( MATE );
    }
    else if ( command =="LXDE" )
    {
        cmdpix.load ( par->iconsPath ( "/16x16/lxde.png" ) );
        cmdBox->setCurrentIndex ( LXDE );
    }
    else if ( command == "CINNAMON" )
    {
        cmdpix.load ( par->iconsPath ( "/16x16/cinnamon.png" ) );
        cmdBox->setCurrentIndex ( CINNAMON );
    }
    else if ( command == "TRINITY" )
    {
        cmdpix.load ( par->iconsPath ( "/16x16/trinity.png" ) );
        cmdBox->setCurrentIndex ( TRINITY );
    }
    else if ( command == "OPENBOX" )
    {
        cmdpix.load ( par->iconsPath ( "/16x16/openbox.png" ) );
        cmdBox->setCurrentIndex ( OPENBOX );
    }
    else if ( command == "ICEWM" )
    {
        cmdpix.load ( par->iconsPath ( "/16x16/icewm.png" ) );
        cmdBox->setCurrentIndex ( ICEWM );
    }
    else if ( command =="SHADOW" )
    {
        cmdpix.load ( par->iconsPath ( "/16x16/X.png" ) );
        cmdBox->setCurrentIndex ( SHADOW );
        command=tr ( "Connection to local desktop" );
    }
    else if ( command =="RDP" )
    {
        if (st->setting()->value ( sid+"/directrdp",
                                   ( QVariant ) false ).toBool())
            directRDP=true;
        cmdpix.load ( par->iconsPath ( "/16x16/rdp.png" ) );
        cmdBox->setCurrentIndex ( RDP );
        command=tr ( "RDP connection" );
    }
    else if ( command =="XDMCP" )
    {
        cmdpix.load ( par->iconsPath ( "/16x16/X.png" ) );
        cmdBox->setCurrentIndex ( XDMCP );
        command=tr ( "XDMCP" );
    }
    else if (published)
    {
        cmdpix.load ( par->iconsPath ( "/16x16/X.png" ) );
        command=tr ("Published applications");
        cmdBox->setCurrentIndex (PUBLISHED);
    }
    else
    {
        cmdpix.load ( par->iconsPath ( "/16x16/X.png" ) );
        command=par->transAppName ( command );
        int id= cmdBox->findText ( command );
        if ( id ==-1 )
        {
            cmdBox->addItem ( command );
            cmdBox->setCurrentIndex ( cmdBox->count()-1 );
        }
        else
            cmdBox->setCurrentIndex ( id );
    }



    cmdIcon->setPixmap ( cmdpix );
    cmd->setText ( command );


    geomBox->clear();
    geomBox->addItem ( tr ( "fullscreen" ) );
    uint displays=QApplication::desktop()->numScreens();
    if (!directRDP)
        for (uint i=0; i<displays; ++i)
        {
            geomBox->addItem ( tr( "Display " )+QString::number(i+1));

            //add maximun available area
            geomBox->addItem( QString::number(QApplication::desktop()->availableGeometry(i).width()) + "x" + QString::number(QApplication::desktop()->availableGeometry(i).height()));


        }
#ifndef Q_WS_HILDON


    geomBox->addItem ( "1440x900" );
    geomBox->addItem ( "1280x1024" );
    geomBox->addItem ( "1024x768" );
    geomBox->addItem ( "800x600" );
#else
    geomBox->addItem ( tr ( "window" ) );
#endif
    if ( st->setting()->value ( sid+"/fullscreen",
                                ( QVariant ) false ).toBool() )
    {
        geom->setText ( tr ( "fullscreen" ) );
    }
    else if (st->setting()->value ( sid+"/multidisp",
                                    ( QVariant ) false ).toBool() && !directRDP)
    {
        uint disp=st->setting()->value ( sid+"/display",
                                         ( QVariant ) 1 ).toUInt();
        if (disp<=displays)
        {
            geom->setText( tr( "Display " )+QString::number(disp));
        }
        else
        {
            geom->setText( tr( "Display " )+QString::number(1));
        }
        for (int i=0; i<geomBox->count(); ++i)
            if (geomBox->itemText(i)==geom->text())
            {
                geomBox->setCurrentIndex(i);
                break;
            }
    }
    else
    {
#ifndef	Q_WS_HILDON
        QString g=QString::number ( st->setting()->value (
                                        sid+"/width" ).toInt() );
        g+="x"+QString::number ( st->setting()->value (
                                     sid+"/height" ).toInt() );
        geom->setText ( g );
        if ( geomBox->findText ( g ) ==-1 )
            geomBox->addItem ( g );
        geomBox->setCurrentIndex ( geomBox->findText ( g ) );
#else
        geom->setText ( tr ( "window" ) );
        geomBox->setCurrentIndex ( 1 );
#endif
    }

    if (directRDP)
    {
        geomBox->addItem ( tr("Maximum") );
        if (st->setting()->value ( sid+"/maxdim",
                                   ( QVariant ) false ).toBool())
        {
            geom->setText ( tr("Maximum") );
            geomBox->setCurrentIndex ( geomBox->findText ( tr("Maximum") ));
        }
    }


    snd=st->setting()->value ( sid+"/sound", ( QVariant ) true ).toBool();
    if ( snd )
        sound->setText ( tr ( "Enabled" ) );
    else
        sound->setText ( tr ( "Disabled" ) );
    soundIcon->setEnabled ( snd );
    QFontMetrics fm ( sound->font() );
    sound->setFixedSize ( fm.size ( Qt::TextSingleLine,sound->text() ) +
                          QSize ( 8,4 ) );

    sessName->setMinimumSize ( sessName->sizeHint() );
    geom->setMinimumSize ( geom->sizeHint() );
    cmd->setMinimumSize ( cmd->sizeHint() );
    server->setMinimumSize ( server->sizeHint() );
    delete st;
}
Ejemplo n.º 8
0
void SessionWidget::saveSettings()
{

    X2goSettings st ( "sessions" );

    QString normPath=(lPath->text()+"/"+sessName->text()).split("/",QString::SkipEmptyParts).join("/");

    st.setting()->setValue ( sessionId+"/name",
                             ( QVariant ) normPath.trimmed() );
    st.setting()->setValue ( sessionId+"/icon",
                             ( QVariant ) sessIcon );
    st.setting()->setValue ( sessionId+"/host",
                             ( QVariant ) server->text().trimmed() );
    st.setting()->setValue ( sessionId+"/user",
                             ( QVariant ) uname->text().trimmed() );

    st.setting()->setValue ( sessionId+"/key",
                             ( QVariant ) key->text().trimmed() );
#ifdef Q_OS_LINUX
    st.setting()->setValue ( sessionId+"/rdpport",
                             ( QVariant ) rdpPort->value() );
#endif
    st.setting()->setValue ( sessionId+"/sshport",
                             ( QVariant ) sshPort->value() );
    st.setting()->setValue(sessionId+"/autologin",( QVariant ) cbAutoLogin->isChecked());
    st.setting()->setValue(sessionId+"/krblogin",( QVariant ) cbKrbLogin->isChecked());
    st.setting()->setValue(sessionId+"/krbdelegation",( QVariant ) cbKrbDelegation->isChecked());
#ifdef Q_OS_LINUX
    st.setting()->setValue(sessionId+"/directrdp",( QVariant ) cbDirectRDP->isChecked());
#endif
    QString command;
    bool rootless=false;
    bool published=false;


    if ( sessBox->currentIndex() < OTHER )
        command=sessBox->currentText();
    else
        command=cmd->text().trimmed();
    if ( sessBox->currentIndex() == RDP )
    {
        command="RDP";
        rdpServer=cmd->text().trimmed();
    }
    if ( sessBox->currentIndex() == XDMCP )
    {
        command="XDMCP";
        xdmcpServer=cmd->text().trimmed();
    }
    if ( sessBox->currentIndex() == SHADOW )
    {
        command="SHADOW";
    }

    QStringList appList;
    for ( int i=-1; i<cmdCombo->count(); ++i )
    {
        QString app;
        if ( i==-1 )
            app=mainWindow->internAppName (
                    cmdCombo->lineEdit()->text () );
        else
            app=mainWindow->internAppName ( cmdCombo->itemText ( i ) );
        if ( appList.indexOf ( app ) ==-1 && app!="" &&
                app!=tr ( "Path to executable" ) )
        {
            appList.append ( app );
        }
    }
    if ( sessBox->currentIndex() ==APPLICATION )
    {
        rootless=true;
        command=mainWindow->internAppName ( cmdCombo->lineEdit()->text().trimmed() );
    }
    if ( sessBox->currentIndex() == PUBLISHED)
        published=true;

    st.setting()->setValue ( sessionId+"/rootless", ( QVariant ) rootless );
    st.setting()->setValue ( sessionId+"/published", ( QVariant ) published );
    st.setting()->setValue ( sessionId+"/applications",
                             ( QVariant ) appList );
    st.setting()->setValue ( sessionId+"/command",
                             ( QVariant ) command );
    st.setting()->setValue ( sessionId+"/rdpoptions",
                             ( QVariant ) rdpOptions );
    st.setting()->setValue ( sessionId+"/rdpserver",
                             ( QVariant ) rdpServer );
    st.setting()->setValue ( sessionId+"/xdmcpserver",
                             ( QVariant ) xdmcpServer );


    st.setting()->setValue (
        sessionId+"/usesshproxy",cbProxy->isChecked());


    if(rbHttpProxy->isChecked())
    {
        st.setting()->setValue ( sessionId+"/sshproxytype","HTTP");
    }
    else
    {
        st.setting()->setValue ( sessionId+"/sshproxytype","SSH");
    }
    st.setting()->setValue (sessionId+"/sshproxyuser",proxyLogin->text().trimmed());
    st.setting()->setValue (sessionId+"/sshproxykeyfile",proxyKey->text().trimmed());
    st.setting()->setValue (sessionId+"/sshproxyhost",proxyHost->text().trimmed());
    st.setting()->setValue (sessionId+"/sshproxyport",proxyPort->value());
    st.setting()->setValue (sessionId+"/sshproxysamepass",cbProxySamePass->isChecked());
    st.setting()->setValue (sessionId+"/sshproxysameuser",cbProxySameUser->isChecked());
    st.setting()->setValue (sessionId+"/sshproxyautologin",cbProxyAutologin->isChecked());
    st.setting()->setValue (sessionId+"/sshproxykrblogin",cbProxyKrbLogin->isChecked());

    st.setting()->sync();
}
Ejemplo n.º 9
0
void SessionWidget::readConfig()
{

    X2goSettings st ( "sessions" );
    QString name=st.setting()->value (
                     sessionId+"/name",
                     ( QVariant ) tr ( "New session" ) ).toString().trimmed();

    QStringList tails=name.split("/",QString::SkipEmptyParts);
    QString path;
    if(tails.count()>0)
    {
        name=tails.last();
        tails.pop_back();
        path=tails.join("/")+"/";
    }
    lPath->setText(path);
    if(newSession)
        lPath->setText(parent->getSessionExplorer()->getCurrentPath()+"/");

    sessName->setText (name);

    sessIcon = wrap_legacy_resource_URIs (st.setting ()->value (sessionId+"/icon",
                                                                (QVariant) ":/img/icons/128x128/x2gosession.png"
                                                               ).toString ().trimmed ());
    sessIcon = expandHome (sessIcon);
    icon->setIcon ( QIcon ( sessIcon ) );

    server->setText ( st.setting()->value (
                          sessionId+"/host",
                          ( QVariant ) QString::null ).toString().trimmed() );
    uname->setText ( st.setting()->value (
                         sessionId+"/user",
                         ( QVariant ) QString::null ).toString().trimmed() );
    key->setText ( st.setting()->value (
                       sessionId+"/key",
                       ( QVariant ) QString::null ).toString().trimmed() );
    cbAutoLogin->setChecked(st.setting()->value (
                                sessionId+"/autologin",
                                ( QVariant ) false ).toBool());
    cbKrbLogin->setChecked(st.setting()->value (
                               sessionId+"/krblogin",
                               ( QVariant ) false ).toBool());
    cbKrbDelegation->setChecked(st.setting()->value (
                                    sessionId+"/krbdelegation",
                                    ( QVariant ) false ).toBool());
    sshPort->setValue (
        st.setting()->value (
            sessionId+"/sshport",
            ( QVariant ) mainWindow->getDefaultSshPort().toInt()
        ).toInt() );
#ifdef Q_OS_LINUX
    rdpPort->setValue (
        st.setting()->value (
            sessionId+"/rdpport",3389
        ).toInt() );
#endif


    cbProxy->setChecked(st.setting()->value (
                            sessionId+"/usesshproxy",
                            false
                        ).toBool() );

    QString prtype= st.setting()->value (
                        sessionId+"/sshproxytype",
                        "SSH"
                    ).toString().trimmed() ;

    if(prtype=="HTTP")
    {
        rbHttpProxy->setChecked(true);
    }
    else
    {
        rbSshProxy->setChecked(true);
    }

    proxyLogin->setText(st.setting()->value (
                            sessionId+"/sshproxyuser",
                            QString()
                        ).toString().trimmed() );

    proxyKey->setText(st.setting()->value (
                          sessionId+"/sshproxykeyfile",
                          QString()
                      ).toString().trimmed() );

    proxyHost->setText(st.setting()->value (
                           sessionId+"/sshproxyhost",
                           QString()
                       ).toString().trimmed() );

    proxyPort->setValue(st.setting()->value (
                            sessionId+"/sshproxyport",
                            22
                        ).toInt() );

    cbProxySamePass->setChecked(st.setting()->value (
                                    sessionId+"/sshproxysamepass",
                                    false
                                ).toBool() );
    cbProxySameUser->setChecked(st.setting()->value (
                                    sessionId+"/sshproxysameuser",
                                    false
                                ).toBool() );
    cbProxyAutologin->setChecked(st.setting()->value (
                                     sessionId+"/sshproxyautologin",
                                     false
                                 ).toBool() );
    cbProxyKrbLogin->setChecked(st.setting()->value (
                                    sessionId+"/sshproxykrblogin",
                                    false
                                ).toBool() );

    if(proxyHost->text().indexOf(":")!=-1)
    {
        QStringList parts=proxyHost->text().split(":");
        proxyHost->setText(parts[0]);
        proxyPort->setValue(parts[1].toInt());
    }


    QTimer::singleShot(1, this,SLOT(slot_proxySameLogin()));
    QTimer::singleShot(2, this,SLOT(slot_proxyType()));
    QTimer::singleShot(3, this,SLOT(slot_proxyOptions()));


    QStringList appNames=st.setting()->value (
                             sessionId+"/applications" ).toStringList();
    bool rootless=st.setting()->value (
                      sessionId+"/rootless",false ).toBool();
    bool published=st.setting()->value (
                       sessionId+"/published",false ).toBool();

    QString
    command=st.setting()->value (
                sessionId+"/command",
                ( QVariant ) mainWindow->getDefaultCmd() ).toString().trimmed();

    rdpOptions=st.setting()->value ( sessionId+"/rdpoptions",
                                     ( QVariant ) "" ).toString().trimmed();
    rdpServer=st.setting()->value ( sessionId+"/rdpserver",
                                    ( QVariant ) "" ).toString().trimmed();
    xdmcpServer=st.setting()->value ( sessionId+"/xdmcpserver",
                                      ( QVariant ) "localhost" ).toString().trimmed();
#ifdef Q_OS_LINUX
    cbDirectRDP->setChecked(st.setting()->value (
                                sessionId+"/directrdp",false ).toBool());
#endif

    for ( int i=0; i<appNames.count(); ++i )
    {
        QString app=mainWindow->transAppName ( appNames[i] );
        if ( cmdCombo->findText ( app ) ==-1 )
            cmdCombo->addItem ( app );
    }
    if ( published )
    {
        sessBox->setCurrentIndex( PUBLISHED );
        cmdCombo->setDisabled(true);
        slot_changeCmd(PUBLISHED);
    }
    else if ( rootless )
    {
        sessBox->setCurrentIndex ( APPLICATION );
        QString app=mainWindow->transAppName ( command );
        cmdCombo->lineEdit()->setText ( app );
        slot_changeCmd ( APPLICATION );
    }
    else
    {
        if ( command=="KDE" )
        {
            sessBox->setCurrentIndex ( KDE );
            cmd->setEnabled ( false );
        }
        else if ( command=="GNOME" )
        {
            sessBox->setCurrentIndex ( GNOME );
            cmd->setEnabled ( false );
        }
        else if ( command=="LXDE" )
        {
            sessBox->setCurrentIndex ( LXDE );
            cmd->setEnabled ( false );
        }
        else if ( command=="UNITY" )
        {
            sessBox->setCurrentIndex ( UNITY );
            cmd->setEnabled ( false );
        }
        else if ( command=="XFCE" )
        {
            sessBox->setCurrentIndex ( XFCE );
            cmd->setEnabled ( false );
        }
        else if ( command=="SHADOW" )
        {
            sessBox->setCurrentIndex ( SHADOW );
            cmd->setEnabled ( false );
        }
        else if ( command=="RDP" )
        {
            leCmdIp->setText ( tr ( "Server:" ) );
            sessBox->setCurrentIndex ( RDP );
            cmd->setEnabled ( true );
            cmd->setText ( rdpServer );
            pbAdvanced->show();
#ifdef Q_OS_LINUX
            cbDirectRDP->show();
            slot_rdpDirectClicked();
#endif
        }
        else if ( command=="XDMCP" )
        {
            leCmdIp->setText ( tr ( "XDMCP server:" ) );
            sessBox->setCurrentIndex ( XDMCP );
            cmd->setEnabled ( true );
            cmd->setText ( xdmcpServer );
        }
        else
        {
            cmd->setText ( command );
            sessBox->setCurrentIndex ( OTHER );
            cmd->setEnabled ( true );
        }
    }
    if ( sessName->text() ==tr ( "New session" ) )
    {
        sessName->selectAll();
        sessName->setFocus();
    }
#ifdef Q_OS_LINUX
    slot_rdpDirectClicked();
#endif
    slot_krbChecked();
}