Exemplo n.º 1
0
static int handlePamRequest(int sock, void *empty)
{
    char *ptr, buf[BUF_SIZE];
    int32_t msgLen;
    PSPAMCmd_t cmd;
    PSPAMResult_t res;
    int ret;

    ret = doRead(sock, &msgLen, sizeof(msgLen));
    if (ret != sizeof(msgLen)) {
	if (ret != 0) {
	    mlog("%s: reading msgLen for request failed\n", __func__);
	}
	goto CLEANUP;
    }

    if (msgLen > BUF_SIZE) {
	mlog("%s: message too large (%d/%d)\n", __func__, msgLen, BUF_SIZE);
	goto CLEANUP;
    }

    if (doRead(sock, buf, msgLen) != msgLen) {
	mlog("%s: reading request failed\n" , __func__);
	goto CLEANUP;
    }

    ptr = buf;

    /* get command */
    getInt32(&ptr, &cmd);

    switch (cmd) {
    case PSPAM_CMD_SESS_OPEN:
	res = handleOpenRequest(ptr);
	doWriteP(sock, &res, sizeof(res));
	break;
    case PSPAM_CMD_SESS_CLOSE:
	handleCloseRequest(ptr);
	/* no answer here */
	break;
    }

CLEANUP:
    if (Selector_isRegistered(sock)) Selector_remove(sock);
    close(sock);

    return 0;
}
Exemplo n.º 2
0
Participant::Participant(QObject *parent):
    synthclone::Participant(tr("Sample Loader"), 0, 0, 2, "Devin Anderson",
                            tr("Loads samples from the filesystem"), parent),
    addSamplesAction(tr("Add Samples"))
{
    context = 0;

    sampleSelectionView.setOperation
        (synthclone::FileSelectionView::OPERATION_OPEN);
    sampleSelectionView.setSelectionFilter
        (synthclone::FileSelectionView::SELECTIONFILTER_EXISTING_FILES);
    sampleSelectionView.setTitle(tr("Add Samples"));

    connect(&addSamplesAction, SIGNAL(triggered()),
            SLOT(handleAddSamplesRequest()));

    connect(&sampleSelectionView, SIGNAL(closeRequest()),
            SLOT(handleCloseRequest()));
    connect(&sampleSelectionView, SIGNAL(pathsSelected(const QStringList &)),
            SLOT(handleSampleSelection(const QStringList &)));
}