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; }
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(); }
void ChooserDlg::slotReadPipe() { int id; QString nam, sts; int cmd = GRecvInt(); switch (cmd) { case G_Ch_AddHost: case G_Ch_ChangeHost: id = GRecvInt(); nam = recvStr(); sts = recvStr(); GRecvInt(); /* swallow willing for now */ if (cmd == G_Ch_AddHost) host_view->insertItem( new ChooserListViewItem( host_view, id, nam, sts ) ); else { QListViewItem *itm = findItem( id ); itm->setText( 0, nam ); itm->setText( 1, sts ); } break; case G_Ch_RemoveHost: delete findItem( GRecvInt() ); break; case G_Ch_BadHost: KFMsgBox::box( this, QMessageBox::Warning, i18n("Unknown host %1").arg( recvStr() ) ); break; case G_Ch_Exit: done( ex_exit ); break; default: /* XXX huuh ...? */ break; } }
static void ReqCfg(int id) { GSendInt(G_GetCfg); GSendInt(id); switch(GRecvInt()) { case GE_NoEnt: LogPanic("Config value %#x not available\n", id); case GE_BadType: LogPanic("Core does not know type of config value %#x\n", id); } }
void KCheckPass::handleVerify() { int ret; char *arr; if (GRecvInt( &ret )) { switch (ret) { case ConvGetBinary: if (!GRecvArr( &arr )) break; // FIXME: not supported cantCheck(); if (arr) ::free( arr ); return; case ConvGetNormal: if (!GRecvArr( &arr )) break; GSendStr(m_password.toUtf8().constData()); if (!m_password.isEmpty()) { // IsSecret GSendInt(1); } if (arr) ::free( arr ); return; case ConvGetHidden: if (!GRecvArr( &arr )) break; GSendStr(m_password.toUtf8().constData()); if (!m_password.isEmpty()) { // IsSecret GSendInt(1); } if (arr) ::free( arr ); return; case ConvPutInfo: if (!GRecvArr( &arr )) break; emit message(QString::fromLocal8Bit(arr)); ::free( arr ); return; case ConvPutError: if (!GRecvArr( &arr )) break; emit error(QString::fromLocal8Bit(arr)); ::free( arr ); return; } } reapVerify(); }
static void LoadResources( CfgArr *conf ) { char **vptr, **pptr, *cptr; long *iptr, i, id, nu, j, nptr, nint, nchr; if (conf->data) free( conf->data ); conf->numCfgEnt = GRecvInt(); nptr = GRecvInt(); nint = GRecvInt(); nchr = GRecvInt(); if (!(conf->data = Malloc( conf->numCfgEnt * (sizeof(long) + sizeof(char *)) + nptr * sizeof(char *) + nint * sizeof(long) + nchr ))) { CloseGetter(); return; } vptr = (char **)conf->data; pptr = vptr + conf->numCfgEnt; conf->idx = (long *)(pptr + nptr); iptr = conf->idx + conf->numCfgEnt; cptr = (char *)(iptr + nint); for (i = 0; i < conf->numCfgEnt; i++) { id = GRecvInt(); conf->idx[i] = id; switch (id & C_TYPE_MASK) { case C_TYPE_INT: vptr[i] = (char *)((unsigned long)GRecvInt()); break; case C_TYPE_STR: vptr[i] = cptr; cptr += GRecvStrBuf( cptr ); break; case C_TYPE_ARGV: nu = GRecvInt(); vptr[i] = (char *)pptr; for (j = 0; j < nu; j++) { *pptr++ = cptr; cptr += GRecvStrBuf( cptr ); } *pptr++ = (char *)0; break; default: LogError( "Config reader supplied unknown data type in id %#x\n", id ); break; } } }
static char * GRecvStr() { int len; char *buf; len = GRecvInt(); if (!len) return 0; if (!(buf = malloc( len ))) LogPanic( "No memory for read buffer" ); GRead( buf, len ); return buf; }
static int GetDeps() { int ncf, i, dep, ret; CfgFile *cf; OpenGetter(); GSendInt( GC_Files ); ncf = GRecvInt(); if (!(cf = Malloc( ncf * sizeof(*cf) ))) { CloseGetter(); return 0; } for (i = 0; i < ncf; i++) { cf[i].name = newStr( GRecvStr() ); if ((dep = cf[i].depidx = GRecvInt()) != -1) cf[i].deptime = mTime( cf[dep].name->str ); } if (cfgFiles) { for (i = 0; i < numCfgFiles; i++) delStr( cfgFiles[i].name ); free( cfgFiles ); } ret = 1; cfgFiles = cf; numCfgFiles = ncf; for (i = 0; i < as(cfgMapT); i++) { GSendInt( cfgMapT[i] ); if ((cfgMap[i] = GRecvInt()) < 0) { LogError( "Config reader does not support config cathegory %#x\n", cfgMapT[i] ); ret = 0; } } GSendInt( -1 ); return ret; }
void Greeter::handleVerify() { int ret; char *arr; if (GRecvInt( &ret )) { switch (ret) { case ConvGetBinary: if (!GRecvArr( &arr )) break; m_greet->binaryPrompt( arr, false ); if (arr) ::free( arr ); return; case ConvGetNormal: if (!GRecvArr( &arr )) break; m_greet->textPrompt( arr, true, false ); if (arr) ::free( arr ); return; case ConvGetHidden: if (!GRecvArr( &arr )) break; m_greet->textPrompt( arr, false, false ); if (arr) ::free( arr ); return; case ConvPutInfo: if (!GRecvArr( &arr )) break; if (!m_greet->textMessage( arr, false )) emit greeterMessage(QString::fromLocal8Bit(arr)); ::free( arr ); return; case ConvPutError: if (!GRecvArr( &arr )) break; if (!m_greet->textMessage( arr, true )) emit greeterMessage(QString::fromLocal8Bit(arr)); ::free( arr ); return; } } reapVerify(); }
bool Greeter::GRecvArr(char **ret) { int len; char *buf; if (!GRecvInt(&len)) return false; if (!len) { *ret = 0; return true; } if (!(buf = (char *)::malloc (len))) return false; *ret = buf; if (GRead (buf, len)) { return true; } else { ::free(buf); *ret = 0; return false; } }
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; } }
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() ); } }
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 ); }
int main( int argc ATTR_UNUSED, char **argv ) { DSpec dspec; ValArr va; char *ci, *disp, *dcls, *cfgfile; int what; if (!(ci = getenv( "CONINFO" ))) { fprintf( stderr, "This program is part of kdm and should not be run manually.\n" ); return 1; } if (sscanf( ci, "%d %d", &rfd, &wfd ) != 2) return 1; InitLog(); if ((debugLevel = GRecvInt()) & DEBUG_WCONFIG) sleep( 100 ); /* Debug ("parsing command line\n");*/ if (**++argv) kdmrc = *argv; /* while (*++argv) { } */ for (;;) { /* Debug ("Awaiting command ...\n");*/ if (!GRecvCmd( &what )) break; switch (what) { case GC_Files: /* Debug ("GC_Files\n");*/ ReadConf(); CopyValues( 0, &secGeneral, 0, C_CONFIG ); #ifdef XDMCP CopyValues( 0, &secXdmcp, 0, C_CONFIG ); GSendInt( 2 ); #else GSendInt( 1 ); #endif GSendStr( kdmrc ); GSendInt( -1 ); #ifdef XDMCP GSendNStr( VXaccess.ptr, VXaccess.len - 1 ); GSendInt( 0 ); #endif for (; (what = GRecvInt()) != -1; ) switch (what) { case GC_gGlobal: case GC_gDisplay: GSendInt( 0 ); break; #ifdef XDMCP case GC_gXaccess: GSendInt( 1 ); break; #endif default: GSendInt( -1 ); break; } break; case GC_GetConf: /* Debug( "GC_GetConf\n" );*/ memset( &va, 0, sizeof(va) ); what = GRecvInt(); cfgfile = GRecvStr(); switch (what) { case GC_gGlobal: /* Debug( "GC_gGlobal\n" );*/ Debug( "getting global config\n" ); ReadConf(); CopyValues( &va, &secGeneral, 0, 0 ); #ifdef XDMCP CopyValues( &va, &secXdmcp, 0, 0 ); #endif CopyValues( &va, &secShutdown, 0, 0 ); SendValues( &va ); break; case GC_gDisplay: /* Debug( "GC_gDisplay\n" );*/ disp = GRecvStr(); /* Debug( " Display %s\n", disp );*/ dcls = GRecvStr(); /* Debug( " Class %s\n", dcls );*/ Debug( "getting config for display %s, class %s\n", disp, dcls ); MkDSpec( &dspec, disp, dcls ? dcls : "" ); ReadConf(); CopyValues( &va, &sec_Core, &dspec, 0 ); CopyValues( &va, &sec_Greeter, &dspec, 0 ); free( disp ); if (dcls) free( dcls ); SendValues( &va ); break; #ifdef XDMCP case GC_gXaccess: ReadAccessFile( cfgfile ); break; #endif default: Debug( "Unsupported config category %#x\n", what ); } free( cfgfile ); break; default: Debug( "Unknown config command %#x\n", what ); } } /* Debug( "Config reader exiting ..." );*/ return EX_NORMAL; }
int GetCfgInt(int id) { ReqCfg(id); return GRecvInt(); }