int main(void) { initialize(); getaddrinfoLocal(); tryCreateSocketReusableAndBind(); freeaddrinfo(pSession->pGetaddrinfoResultLinkList); // all done with this structure debug("ok: freeaddrinfo()."); tryListen(); prepareToHandleDeadChildProcess(); say("\nok: waiting for connections...\n"); while(1) //each loop for each connection { if ( tryAccept() == 1 ) //if ERR: accept { continue; } if (fork()==0) //success, fork() return 0 to child and return child's PID to parent. { dealWithAConnection(); } else //if in parent instead of child process { close(pSession->localSocket); debug("ok: parent: close(localSocket), parent doesn't need."); } } return 0; }//int main(void)
bool QInputDialog::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: textChanged((const QString&)static_QUType_QString.get(_o+1)); break; case 1: tryAccept(); break; default: return QDialog::qt_invoke( _id, _o ); } return TRUE; }
GraphCurveAddDialog::GraphCurveAddDialog(QWidget *parent, std::vector<GraphCurveInfo*> *curves, bool edit) : QDialog(parent),ui(new Ui::GraphCurveAddDialog), edit_widget_ui(new Ui::GraphCurveEditWidget) { ui->setupUi(this); m_edit_widget = new QWidget(this); edit_widget_ui->setupUi(m_edit_widget); ui->mainLayout->insertWidget(1, m_edit_widget); newOrEditCurve(true); setButtonColor(Qt::red); connect(ui->newRadio, SIGNAL(toggled(bool)), SLOT(newOrEditCurve(bool))); connect(ui->buttonBox, SIGNAL(accepted()), SLOT(tryAccept())); connect(edit_widget_ui->colorBtn, SIGNAL(clicked()), SLOT(selectColor())); connect(edit_widget_ui->curveBox, SIGNAL(currentIndexChanged(int)), SLOT(curveChanged(int))); static const QString dataTypes[] = { tr("unsigned 8bit"), tr("unsigned 16bit"), tr("unsigned 32bit"), tr("unsigned 64bit"), tr("signed 8bit"), tr("signed 16bit"), tr("signed 32bit"), tr("signed 64bit"), tr("float (4 bytes)"), tr("double (8 bytes)") }; for(quint8 i = 0; i < NUM_COUNT; ++i) edit_widget_ui->dataTypeBox->addItem(dataTypes[i]); m_curves = curves; ui->setRadio->setEnabled(!m_curves->empty()); if(edit) { ui->setRadio->setChecked(true); ui->setRadio->setVisible(false); ui->newRadio->setVisible(false); ui->buttonBox->addButton(QDialogButtonBox::Apply); connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), SLOT(buttonBoxClicked(QAbstractButton*))); } }
QInputDialog::QInputDialog( const QString &label, QWidget* parent, const char* name, bool modal, Type type ) : QDialog( parent, name, modal ) { d = new QInputDialogPrivate; d->lineEdit = 0; d->spinBox = 0; d->comboBox = 0; QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); d->label = new QLabel( label, this, "qt_inputdlg_lbl" ); vbox->addWidget( d->label ); d->stack = new QWidgetStack( this, "qt_inputdlg_ws" ); vbox->addWidget( d->stack ); d->lineEdit = new QLineEdit( d->stack, "qt_inputdlg_le" ); d->spinBox = new QSpinBox( d->stack, "qt_inputdlg_sb" ); d->comboBox = new QComboBox( FALSE, d->stack, "qt_inputdlg_cb" ); d->editComboBox = new QComboBox( TRUE, d->stack, "qt_inputdlg_editcb" ); QHBoxLayout *hbox = new QHBoxLayout( 6 ); vbox->addLayout( hbox, AlignRight ); d->ok = new QPushButton( tr( "OK" ), this, "qt_ok_btn" ); d->ok->setDefault( TRUE ); QPushButton *cancel = new QPushButton( tr( "Cancel" ), this, "qt_cancel_btn" ); QSize bs = d->ok->sizeHint().expandedTo( cancel->sizeHint() ); d->ok->setFixedSize( bs ); cancel->setFixedSize( bs ); hbox->addStretch(); hbox->addWidget( d->ok ); hbox->addWidget( cancel ); connect( d->lineEdit, SIGNAL( returnPressed() ), this, SLOT( tryAccept() ) ); connect( d->lineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( textChanged(const QString&) ) ); connect( d->ok, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( cancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); QSize sh = sizeHint().expandedTo( QSize(400, 10) ); setType( type ); resize( sh.width(), vbox->heightForWidth(sh.width()) ); }