예제 #1
0
파일: conn.c 프로젝트: embedthis/appweb-3
/*
 *  Process a socket readable event
 */
static void readEvent(MaConn *conn)
{
    MaPacket    *packet;
    MprBuf      *content;
    int         nbytes, len;

    do {
        if ((packet = getPacket(conn, &len)) == 0) {
            break;
        }
        mprAssert(len > 0);
        content = packet->content;
        nbytes = mprReadSocket(conn->sock, mprGetBufEnd(content), len);
        showRequest(content, nbytes, len);
       
        if (nbytes > 0) {
            mprAdjustBufEnd(content, nbytes);
            maProcessReadEvent(conn, packet);
        } else {
            if (mprIsSocketEof(conn->sock)) {
                conn->dedicated = 0;
                if (conn->request) {
                    maProcessReadEvent(conn, packet);
                }
            } else if (nbytes < 0) {
                maFailConnection(conn, MPR_HTTP_CODE_COMMS_ERROR, "Communications read error");
            }
        }
    } while (!conn->disconnected && conn->dedicated);
}
예제 #2
0
void QuickContactInfo::show(QObject *object)
{
	InfoRequestFactory *factory = InfoRequestFactory::factory(object);
    SupportLevel type = factory ? factory->supportLevel(object) : InfoRequestFactory::Unavailable;
    if (type <= InfoRequestFactory::Unavailable)
        object = 0;
    
    if (m_object != object) {
        m_object = object;
        emit objectChanged(object);
    }
    if (!object) {
        m_item = DataItem("No data");
        emit itemChanged(m_item);
        delete m_request;
        m_request = 0;
        return;
    }
	bool readWrite = (type == InfoRequestFactory::ReadWrite);
    if (m_readWrite != readWrite) {
        m_readWrite = readWrite;
        emit readOnlyChanged(!readWrite);
    }
    delete m_request;
	m_request = InfoRequestFactory::dataFormRequest(object);

	if (m_request) {
		connect(m_request, SIGNAL(stateChanged(qutim_sdk_0_3::InfoRequest::State)),
				SLOT(onRequestStateChanged(qutim_sdk_0_3::InfoRequest::State)));
		m_request->requestData();
	}

	QString title;
	QString avatar;
	if (Buddy *buddy = qobject_cast<Buddy*>(m_object)) {
		title = QApplication::translate("ContactInfo", "About contact %1 <%2>")
					.arg(buddy->name())
					.arg(buddy->id());
	} else {
		if (Account *account = qobject_cast<Account*>(m_object)) {
			title = QApplication::translate("ContactInfo", "About account %1")
						.arg(account->name());
		} else {
			title = QApplication::translate("ContactInfo", "About %1 <%2>")
						.arg(m_object->property("name").toString())
						.arg(m_object->property("id").toString());
		}
	}
	if (m_request)
		onRequestStateChanged(m_request->state());
    emit showRequest();
}
예제 #3
0
파일: dialog.cpp 프로젝트: RobinWuDev/Qt
QT_USE_NAMESPACE

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , transactionCount(0)
    , serialPortLabel(new QLabel(tr("Serial port:")))
    , serialPortComboBox(new QComboBox())
    , waitRequestLabel(new QLabel(tr("Wait request, msec:")))
    , waitRequestSpinBox(new QSpinBox())
    , responseLabel(new QLabel(tr("Response:")))
    , responseLineEdit(new QLineEdit(tr("Hello, I'm Slave.")))
    , trafficLabel(new QLabel(tr("No traffic.")))
    , statusLabel(new QLabel(tr("Status: Not running.")))
    , runButton(new QPushButton(tr("Start")))
{
    waitRequestSpinBox->setRange(0, 10000);
    waitRequestSpinBox->setValue(10000);

    foreach (const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
        serialPortComboBox->addItem(info.portName());

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(serialPortLabel, 0, 0);
    mainLayout->addWidget(serialPortComboBox, 0, 1);
    mainLayout->addWidget(waitRequestLabel, 1, 0);
    mainLayout->addWidget(waitRequestSpinBox, 1, 1);
    mainLayout->addWidget(runButton, 0, 2, 2, 1);
    mainLayout->addWidget(responseLabel, 2, 0);
    mainLayout->addWidget(responseLineEdit, 2, 1, 1, 3);
    mainLayout->addWidget(trafficLabel, 3, 0, 1, 4);
    mainLayout->addWidget(statusLabel, 4, 0, 1, 5);
    setLayout(mainLayout);

    setWindowTitle(tr("Blocking Slave"));
    serialPortComboBox->setFocus();

    connect(runButton, SIGNAL(clicked()),
            this, SLOT(startSlave()));
    connect(&thread, SIGNAL(request(QString)),
            this, SLOT(showRequest(QString)));
    connect(&thread, SIGNAL(error(QString)),
            this, SLOT(processError(QString)));
    connect(&thread, SIGNAL(timeout(QString)),
            this, SLOT(processTimeout(QString)));

    connect(serialPortComboBox, SIGNAL(currentIndexChanged(QString)),
            this, SLOT(activateRunButton()));
    connect(waitRequestSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(activateRunButton()));
    connect(responseLineEdit, SIGNAL(textChanged(QString)),
            this, SLOT(activateRunButton()));
}
예제 #4
0
KWD::Decorator::Decorator () :
    KApplication (),
    mConfig (0),
    mCompositeWindow (0),
    mSwitcher (0)
{
    XSetWindowAttributes attr;
    int			 i, j;

    mSelf = this;

    mRootInfo = new NETRootInfo (QX11Info::display (), 0);

    mActiveId = 0;

    KConfigGroup cfg (KSharedConfig::openConfig ("plasmarc"),
						 QString ("Theme"));
    Plasma::Theme::defaultTheme ()->setThemeName (cfg.readEntry ("name"));

    Atoms::init ();

    new KWinAdaptor (this);

    mConfig = new KConfig ("kwinrc");

    mOptions = new KWD::Options (mConfig);
    mPlugins = new PluginManager (KSharedConfig::openConfig ("kwinrc"));

    mActiveShadowOptions.shadow_radius   = SHADOW_RADIUS;
    mActiveShadowOptions.shadow_opacity  = SHADOW_OPACITY;
    mActiveShadowOptions.shadow_offset_x = SHADOW_OFFSET_X;
    mActiveShadowOptions.shadow_offset_y = SHADOW_OFFSET_Y;
    mActiveShadowOptions.shadow_color[0] = SHADOW_COLOR_RED;
    mActiveShadowOptions.shadow_color[1] = SHADOW_COLOR_GREEN;
    mActiveShadowOptions.shadow_color[2] = SHADOW_COLOR_BLUE;

    mInactiveShadowOptions.shadow_radius   = SHADOW_RADIUS;
    mInactiveShadowOptions.shadow_opacity  = SHADOW_OPACITY;
    mInactiveShadowOptions.shadow_offset_x = SHADOW_OFFSET_X;
    mInactiveShadowOptions.shadow_offset_y = SHADOW_OFFSET_Y;
    mInactiveShadowOptions.shadow_color[0] = SHADOW_COLOR_RED;
    mInactiveShadowOptions.shadow_color[1] = SHADOW_COLOR_GREEN;
    mInactiveShadowOptions.shadow_color[2] = SHADOW_COLOR_BLUE;

    updateShadowProperties (QX11Info::appRootWindow ());

    for (i = 0; i < 3; i++)
    {
	for (j = 0; j < 3; j++)
	{
	    if (cursors[i][j].shape != XC_left_ptr)
		cursors[i][j].cursor =
		    XCreateFontCursor (QX11Info::display (),
				       cursors[i][j].shape);
	}
    }

    attr.override_redirect = True;

    mCompositeWindow = XCreateWindow (QX11Info::display (),
				      QX11Info::appRootWindow (),
				      -ROOT_OFF_X, -ROOT_OFF_Y, 1, 1, 0,
				      CopyFromParent,
				      CopyFromParent,
				      CopyFromParent,
				      CWOverrideRedirect, &attr);

    long data = 1;
    XChangeProperty (QX11Info::display(), mCompositeWindow, Atoms::enlightmentDesktop,
		      XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &data, 1);

    XCompositeRedirectSubwindows (QX11Info::display (), mCompositeWindow,
				  CompositeRedirectManual);

    XMapWindow (QX11Info::display (), mCompositeWindow);

    QDBusConnection dbus = QDBusConnection::sessionBus ();
    dbus.connect (KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, "showRequest",
		 this, SIGNAL (showRequest (qulonglong)));
    dbus.connect (KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, "menuAvailable",
		 this, SLOT (menuAvailable (qulonglong)));
    dbus.connect (KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, "clearMenus",
		 this, SLOT (clearMenus ()));
    dbus.connect (KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, "menuHidden",
		 this, SIGNAL (menuHidden ()));
}