Esempio n. 1
0
dpySpec *fetchSessions(int flags)
{
    dpySpec *sess, *sessions = 0, tsess;

    GSet(1);
    GSendInt(G_List);
    GSendInt(flags);
next:
    while((tsess.display = GRecvStr()))
    {
        tsess.from = GRecvStr();
#ifdef HAVE_VTS
        tsess.vt = GRecvInt();
#endif
        tsess.user = GRecvStr();
        tsess.session = GRecvStr();
        tsess.flags = GRecvInt();
        if((tsess.flags & isTTY) && *tsess.from)
            for(sess = sessions; sess; sess = sess->next)
                if(sess->user && !strcmp(sess->user, tsess.user) && !strcmp(sess->from, tsess.from))
                {
                    sess->count++;
                    disposeSession(&tsess);
                    goto next;
                }
        if(!(sess = malloc(sizeof(*sess))))
            LogPanic("Out of memory\n");
        tsess.count = 1;
        tsess.next = sessions;
        *sess = tsess;
        sessions = sess;
    }
    GSet(0);
    return sessions;
}
Esempio n. 2
0
void
TDMShutdown::scheduleShutdown( TQWidget *_parent )
{
	GSet( 1 );
	GSendInt( G_QueryShutdown );
	int how = GRecvInt();
	int start = GRecvInt();
	int timeout = GRecvInt();
	int force = GRecvInt();
	int uid = GRecvInt();
	char *os = GRecvStr();
	GSet( 0 );
	if (how) {
		int ret =
			TDMCancelShutdown( how, start, timeout, force, uid, os,
			                   _parent ).exec();
		if (!ret)
			return;
		doShutdown( 0, 0 );
		uid = ret == Authed ? 0 : -1;
	} else
		uid = -1;
	if (os)
		free( os );
	TDMShutdown( uid, _parent ).exec();
}
Esempio n. 3
0
static void
doShutdown( int type, const char *os )
{
	GSet( 1 );
	GSendInt( G_Shutdown );
	GSendInt( type );
	GSendInt( 0 );
	GSendInt( 0 );
	GSendInt( SHUT_FORCE );
	GSendInt( 0 ); /* irrelevant, will timeout immediately anyway */
	GSendStr( os );
	GSet( 0 );
}
Esempio n. 4
0
void
TDMShutdown::accepted()
{
	GSet( 1 );
	GSendInt( G_Shutdown );
	GSendInt( restart_rb->isChecked() ? SHUT_REBOOT : SHUT_HALT );
	GSendInt( sch_st );
	GSendInt( sch_to );
	GSendInt( cb_force->isChecked() ? SHUT_FORCE : SHUT_CANCEL );
	GSendInt( _allowShutdown == SHUT_ROOT ? 0 : -2 );
	GSendStr( (restart_rb->isChecked() &&
	           targets && targets->currentItem() != oldTarget) ?
	          targets->currentText().local8Bit().data() : 0 );
	GSet( 0 );
	inherited::accepted();
}
Esempio n. 5
0
void
CloseGetter()
{
	if (getter.pid) {
		GSet( &cnftalk );
		(void)GClose (&getter, 0, 0);
		Debug( "getter now closed\n" );
	}
}
Esempio n. 6
0
static void
OpenGetter()
{
	GSet( &cnftalk );
	if (!getter.pid) {
		if (GOpen( &getter,
		           originalArgv, "_config", 0, strdup( "config reader" ),
		           0 ))
			LogPanic( "Cannot run config reader\n" );
		Debug( "getter now ready\n" );
	}
}
Esempio n. 7
0
static void
processDPipe( struct display *d )
{
	char *user, *pass, *args;
	int cmd;
	GTalk dpytalk;
#ifdef XDMCP
	int ct, len;
	ARRAY8 ca, ha;
#endif

	dpytalk.pipe = &d->pipe;
	if (Setjmp( dpytalk.errjmp )) {
		StopDisplay( d );
		return;
	}
	GSet( &dpytalk );
	if (!GRecvCmd( &cmd )) {
		/* process already exited */
		UnregisterInput( d->pipe.rfd );
		return;
	}
	switch (cmd) {
	case D_User:
		d->userSess = GRecvInt();
		d->userName = GRecvStr();
		d->sessName = GRecvStr();
		break;
	case D_ReLogin:
		user = GRecvStr();
		pass = GRecvStr();
		args = GRecvStr();
		setNLogin( d, user, pass, args, 1 );
		free( args );
		free( pass );
		free( user );
		break;
#ifdef XDMCP
	case D_ChooseHost:
		ca.data = (unsigned char *)GRecvArr( &len );
		ca.length = (CARD16)len;
		ct = GRecvInt();
		ha.data = (unsigned char *)GRecvArr( &len );
		ha.length = (CARD16)len;
		RegisterIndirectChoice( &ca, ct, &ha );
		XdmcpDisposeARRAY8( &ha );
		XdmcpDisposeARRAY8( &ca );
		break;
	case D_RemoteHost:
		if (d->remoteHost)
			free( d->remoteHost );
		d->remoteHost = GRecvStr();
		break;
#endif
	case D_XConnOk:
		startingServer = 0;
		break;
	default:
		LogError( "Internal error: unknown D_* command %d\n", cmd );
		StopDisplay( d );
		break;
	}
}
Esempio n. 8
0
TDMSlimShutdown::TDMSlimShutdown( TQWidget *_parent )
	: inherited( _parent )
	, targetList( 0 )
{
	setCaption(i18n("Shutdown TDE"));

	bool doUbuntuLogout = TDEConfigGroup(TDEGlobal::config(), "Shutdown").readBoolEntry("doUbuntuLogout", false);

	TQFrame* lfrm = new TQFrame( this );
	TQHBoxLayout* hbuttonbox;

	if(doUbuntuLogout)
	{
		TQVBoxLayout* vbox = new TQVBoxLayout( this );
		if (has_twin)
			lfrm->setFrameStyle( TQFrame::NoFrame );
		else
			lfrm->setFrameStyle( TQFrame::StyledPanel | TQFrame::Raised );
		lfrm->setLineWidth( style().pixelMetric( TQStyle::PM_DefaultFrameWidth, lfrm ) );
		// we need to set the minimum size for the logout box, since it
		// gets too small if there all options are not available
		lfrm->setMinimumSize(300,120);
		vbox->addWidget( lfrm );
		vbox = new TQVBoxLayout( lfrm, 2 * KDialog::marginHint(),
								2 * KDialog::spacingHint() );

		// first line of buttons
		hbuttonbox = new TQHBoxLayout( vbox, 8 * KDialog::spacingHint() );
		hbuttonbox->setAlignment( Qt::AlignHCenter );

		// Reboot
		FlatButton* btnReboot = new FlatButton( lfrm );
		btnReboot->setTextLabel( i18n("&Restart"), false );
		btnReboot->setPixmap( DesktopIcon( "reload") );
                int i = btnReboot->textLabel().find( TQRegExp("\\&"), 0 );    // i == 1
                btnReboot->setAccel( "ALT+" + btnReboot->textLabel().lower()[i+1] ) ;
		hbuttonbox->addWidget ( btnReboot);
		connect(btnReboot, TQT_SIGNAL(clicked()), TQT_SLOT(slotReboot()));
		
		// Copied completely from the standard restart/shutdown dialog
		GSet( 1 );
		GSendInt( G_ListBootOpts );
		if (GRecvInt() == BO_OK) {
			targetList = GRecvStrArr( 0 );
			/*int def =*/ GRecvInt();
			int cur = GRecvInt();
			TQPopupMenu *targets = new TQPopupMenu( this );
			btnReboot->setPopupDelay(300); // visually add dropdown
			for (int i = 0; targetList[i]; i++) {
				TQString t( TQString::fromLocal8Bit( targetList[i] ) );
				targets->insertItem( i == cur ?
									i18n("current option in boot loader",
										"%1 (current)").arg( t ) :
									t, i );
			}
			btnReboot->setPopup( targets );
			connect( targets, TQT_SIGNAL(activated(int)), TQT_SLOT(slotReboot(int)) );
		}
		GSet( 0 );
		// Copied completely from the standard restart/shutdown dialog

		// Shutdown
		FlatButton* btnHalt = new FlatButton( lfrm );
		btnHalt->setTextLabel( i18n("&Turn Off"), false );
		btnHalt->setPixmap( DesktopIcon( "system-log-out") );
                i = btnHalt->textLabel().find( TQRegExp("\\&"), 0 );    // i == 1
                btnHalt->setAccel( "ALT+" + btnHalt->textLabel().lower()[i+1] ) ;
		hbuttonbox->addWidget ( btnHalt );
		connect(btnHalt, TQT_SIGNAL(clicked()), TQT_SLOT(slotHalt()));

		// cancel buttonbox
		TQHBoxLayout* hbuttonbox2 = new TQHBoxLayout( vbox, 8 * KDialog::spacingHint()  );
		hbuttonbox2->setAlignment( Qt::AlignRight );

		// Back to tdm
		KSMPushButton* btnBack = new KSMPushButton( KStdGuiItem::cancel(), lfrm );
		hbuttonbox2->addWidget( btnBack );
		connect(btnBack, TQT_SIGNAL(clicked()), TQT_SLOT(reject()));
	}
	else
	{
		TQHBoxLayout *hbox = new TQHBoxLayout( this, KDmh, KDsh );
		if (has_twin)
			lfrm->setFrameStyle( TQFrame::NoFrame );
		else
			lfrm->setFrameStyle( TQFrame::Panel | TQFrame::Sunken );
		hbox->addWidget( lfrm, AlignCenter );
		// we need to set the minimum size for the logout box, since it
		// gets too small if there all options are not available
		TQLabel *icon = new TQLabel( lfrm );
		icon->setPixmap( TQPixmap( locate( "data", "tdm/pics/shutdown.jpg" ) ) );
		TQVBoxLayout *iconlay = new TQVBoxLayout( lfrm );
		iconlay->addWidget( icon );
	
		TQVBoxLayout *buttonlay = new TQVBoxLayout( hbox, KDsh );
	
		buttonlay->addStretch( 1 );
	
		KPushButton *btnHalt = new
			KPushButton( KGuiItem( i18n("&Turn Off Computer"), "system-log-out" ), this );
		buttonlay->addWidget( btnHalt );
		connect( btnHalt, TQT_SIGNAL(clicked()), TQT_SLOT(slotHalt()) );
	
		buttonlay->addSpacing( KDialog::spacingHint() );
	
		TDMDelayedPushButton *btnReboot = new
			TDMDelayedPushButton( KGuiItem( i18n("&Restart Computer"), "reload" ), this );
		buttonlay->addWidget( btnReboot );
		connect( btnReboot, TQT_SIGNAL(clicked()), TQT_SLOT(slotReboot()) );
	
		GSet( 1 );
		GSendInt( G_ListBootOpts );
		if (GRecvInt() == BO_OK) {
			targetList = GRecvStrArr( 0 );
			/*int def =*/ GRecvInt();
			int cur = GRecvInt();
			TQPopupMenu *targets = new TQPopupMenu( this );
			for (int i = 0; targetList[i]; i++) {
				TQString t( TQString::fromLocal8Bit( targetList[i] ) );
				targets->insertItem( i == cur ?
									i18n("current option in boot loader",
										"%1 (current)").arg( t ) :
									t, i );
			}
			btnReboot->setPopup( targets );
			connect( targets, TQT_SIGNAL(activated(int)), TQT_SLOT(slotReboot(int)) );
		}
		GSet( 0 );
	
		buttonlay->addStretch( 1 );
	
		if (_scheduledSd != SHUT_NEVER) {
			KPushButton *btnSched = new
				KPushButton( KGuiItem( i18n("&Schedule...") ), this );
			buttonlay->addWidget( btnSched );
			connect( btnSched, TQT_SIGNAL(clicked()), TQT_SLOT(slotSched()) );
	
			buttonlay->addStretch( 1 );
		}
	
		buttonlay->addWidget( new KSeparator( this ) );
	
		buttonlay->addSpacing( 0 );
	
		KPushButton *btnBack = new KPushButton( KStdGuiItem::cancel(), this );
		buttonlay->addWidget( btnBack );
		connect( btnBack, TQT_SIGNAL(clicked()), TQT_SLOT(reject()) );
	
		buttonlay->addSpacing( KDialog::spacingHint() );	
	}

}
Esempio n. 9
0
TDMShutdown::TDMShutdown( int _uid, TQWidget *_parent )
	: inherited( _uid, _parent )
{
	setCaption(i18n("Shutdown TDE"));

	TQSizePolicy fp( TQSizePolicy::Fixed, TQSizePolicy::Fixed );

	TQHBoxLayout *hlay = new TQHBoxLayout( box, KDsh );

	howGroup = new TQVButtonGroup( i18n("Shutdown Type"), this );
	hlay->addWidget( howGroup, 0, AlignTop );

	TQRadioButton *rb;
	rb = new TDMRadioButton( i18n("&Turn off computer"), howGroup );
	rb->setChecked( true );
	rb->setFocus();

	restart_rb = new TDMRadioButton( i18n("&Restart computer"), howGroup );

	connect( rb, TQT_SIGNAL(doubleClicked()), TQT_SLOT(accept()) );
	connect( restart_rb, TQT_SIGNAL(doubleClicked()), TQT_SLOT(accept()) );

	GSet( 1 );
	GSendInt( G_ListBootOpts );
	if (GRecvInt() == BO_OK) { /* XXX show dialog on failure */
		char **tlist = GRecvStrArr( 0 );
		int defaultTarget = GRecvInt();
		oldTarget = GRecvInt();
		TQWidget *hlp = new TQWidget( howGroup );
		targets = new TQComboBox( hlp );
		for (int i = 0; tlist[i]; i++)
			targets->insertItem( TQString(TQString::fromLocal8Bit( tlist[i] )) );
		freeStrArr( tlist );
		targets->setCurrentItem( oldTarget == -1 ? defaultTarget : oldTarget );
		TQHBoxLayout *hb = new TQHBoxLayout( hlp, 0, KDsh );
		int spc = kapp->style().pixelMetric( TQStyle::PM_ExclusiveIndicatorWidth )
		          + howGroup->insideSpacing();
		hb->addSpacing( spc );
		hb->addWidget( targets );
		connect( targets, TQT_SIGNAL(activated( int )), TQT_SLOT(slotTargetChanged()) );
	}
	GSet( 0 );

	howGroup->setSizePolicy( fp );

	schedGroup = new TQGroupBox( i18n("Scheduling"), this );
	hlay->addWidget( schedGroup, 0, AlignTop );

	le_start = new TQLineEdit( schedGroup );
	TQLabel *lab1 = new TQLabel( le_start, i18n("&Start:"), schedGroup );

	le_timeout = new TQLineEdit( schedGroup );
	TQLabel *lab2 = new TQLabel( le_timeout, i18n("T&imeout:"), schedGroup );

	cb_force = new TQCheckBox( i18n("&Force after timeout"), schedGroup );
	if (_allowNuke != SHUT_NONE) {
		connect( cb_force, TQT_SIGNAL(clicked()), TQT_SLOT(slotWhenChanged()) );
		mayNuke = true;
	} else
		cb_force->setEnabled( false );

	TQGridLayout *grid = new TQGridLayout( schedGroup, 0, 0, KDmh, KDsh );
	grid->addRowSpacing( 0, schedGroup->fontMetrics().height() - 5 );
	grid->addWidget( lab1, 1, 0, Qt::AlignRight );
	grid->addWidget( le_start, 1, 1 );
	grid->addWidget( lab2, 2, 0, Qt::AlignRight );
	grid->addWidget( le_timeout, 2, 1 );
	grid->addMultiCellWidget( cb_force, 3,3, 0,1 );

	schedGroup->setSizePolicy( fp );

	le_start->setText( "0" );
	if (_defSdMode == SHUT_SCHEDULE)
		le_timeout->setText( "-1" );
	else {
		le_timeout->setText( "0" );
		if (_defSdMode == SHUT_FORCENOW && cb_force->isEnabled())
			cb_force->setChecked( true );
	}

	complete( schedGroup );
}