Beispiel #1
0
void ControlWidget::connectCamera()
{
    if(isCameraConnected())
    {
        emit connectionRequested(0, false);
        ui->triggerwidget->setEnabled(false);
    }
    else
    {
        int index = ui->comboBoxCameraIndex->currentText().toInt();
        emit connectionRequested(index, true);
        ui->triggerwidget->setEnabled(true);
    }
}
bool ServerLobbyRoomProtocol::notifyEventAsynchronous(Event* event)
{
    assert(m_setup); // assert that the setup exists
    if (event->getType() == EVENT_TYPE_MESSAGE)
    {
        NetworkString &data = event->data();
        assert(data.size()); // message not empty
        uint8_t message_type;
        message_type = data.getUInt8();
        Log::info("ServerLobbyRoomProtocol", "Message received with type %d.",
                  message_type);
        switch(message_type)
        {
        case LE_CONNECTION_REQUESTED: connectionRequested(event); break;
        case LE_REQUEST_BEGIN: startSelection(event);             break;
        case LE_KART_SELECTION: kartSelectionRequested(event);    break;
        case LE_VOTE_MAJOR: playerMajorVote(event);               break;
        case LE_VOTE_RACE_COUNT: playerRaceCountVote(event);      break;
        case LE_VOTE_MINOR: playerMinorVote(event);               break;
        case LE_VOTE_TRACK: playerTrackVote(event);               break;
        case LE_VOTE_REVERSE: playerReversedVote(event);          break;
        case LE_VOTE_LAPS:  playerLapsVote(event);                break;
        case LE_RACE_FINISHED_ACK: playerFinishedResult(event);   break;
        }   // switch
           
    } // if (event->getType() == EVENT_TYPE_MESSAGE)
    else if (event->getType() == EVENT_TYPE_DISCONNECTED)
    {
        clientDisconnected(event);
    } // if (event->getType() == EVENT_TYPE_DISCONNECTED)
    return true;
}   // notifyEventAsynchronous
void QDBusViewer::showContextMenu(const QPoint &point)
{
    QModelIndex item = tree->indexAt(point);
    if (!item.isValid())
        return;

    const QDBusModel *model = static_cast<const QDBusModel *>(item.model());

    BusSignature sig;
    sig.mService = currentService;
    sig.mPath = model->dBusPath(item);
    sig.mInterface = model->dBusInterface(item);
    sig.mName = model->dBusMethodName(item);
    sig.mTypeSig = model->dBusTypeSignature(item);

    QMenu menu;
    menu.addAction(refreshAction);

    switch (model->itemType(item)) {
    case QDBusModel::SignalItem: {
        QAction *action = new QAction(tr("&Connect"), &menu);
        action->setData(1);
        menu.addAction(action);
        break; }
    case QDBusModel::MethodItem: {
        QAction *action = new QAction(tr("&Call"), &menu);
        action->setData(2);
        menu.addAction(action);
        break; }
    case QDBusModel::PropertyItem: {
        QAction *actionSet = new QAction(tr("&Set value"), &menu);
        actionSet->setData(3);
        QAction *actionGet = new QAction(tr("&Get value"), &menu);
        actionGet->setData(4);
        menu.addAction(actionSet);
        menu.addAction(actionGet);
        break; }
    default:
        break;
    }

    QAction *selectedAction = menu.exec(tree->viewport()->mapToGlobal(point));
    if (!selectedAction)
        return;

    switch (selectedAction->data().toInt()) {
    case 1:
        connectionRequested(sig);
        break;
    case 2:
        callMethod(sig);
        break;
    case 3:
        setProperty(sig);
        break;
    case 4:
        getProperty(sig);
        break;
    }
}
void QDBusViewer::activate(const QModelIndex &item)
{
    if (!item.isValid())
        return;

    const QDBusModel *model = static_cast<const QDBusModel *>(item.model());

    BusSignature sig;
    sig.mService = currentService;
    sig.mPath = model->dBusPath(item);
    sig.mInterface = model->dBusInterface(item);
    sig.mName = model->dBusMethodName(item);
    sig.mTypeSig = model->dBusTypeSignature(item);

    switch (model->itemType(item)) {
    case QDBusModel::SignalItem:
        connectionRequested(sig);
        break;
    case QDBusModel::MethodItem:
        callMethod(sig);
        break;
    case QDBusModel::PropertyItem:
        getProperty(sig);
        break;
    default:
        break;
    }
}
void DiagramEndPoint::messageDropped(
	BPoint point,
	BMessage *message)
{
	D_MESSAGE(("DiagramEndPoint::messageDropped()\n"));
	switch (message->what)
	{
		case M_WIRE_DRAGGED:
		{
			D_MESSAGE(("DiagramEndPoint::messageDropped(M_WIRE_DRAGGED)\n"));
			DiagramEndPoint *endPoint;
			if ((message->FindPointer("from", reinterpret_cast<void **>(&endPoint)) == B_OK)
			 && (endPoint != this))
			{
				bool success = connectionRequested(endPoint);
				BMessage dropMsg(M_WIRE_DROPPED);
				dropMsg.AddPointer("from", reinterpret_cast<void *>(endPoint));
				dropMsg.AddPointer("to", reinterpret_cast<void *>(this));
				dropMsg.AddBool("success", success);
				DiagramView* v = view();
				BMessenger(v).SendMessage(&dropMsg);
				if (isConnecting())
				{
					m_connecting = false;
					disconnected();
				}
			}
			return;
		}
		default:
		{
			DiagramItem::messageDropped(point, message);
		}
	}
}
bool ServerLobbyRoomProtocol::notifyEventAsynchronous(Event* event)
{
    assert(m_setup); // assert that the setup exists
    if (event->type == EVENT_TYPE_MESSAGE)
    {
        NetworkString data = event->data();
        assert(data.size()); // message not empty
        uint8_t message_type;
        message_type = data[0];
        event->removeFront(1);
        Log::info("ServerLobbyRoomProtocol", "Message received with type %d.", message_type);
        if (message_type == 0x01) // player requesting connection
            connectionRequested(event);
        else if (message_type == 0x02) // player requesting kart selection
            kartSelectionRequested(event);
        else if (message_type == 0xc0) // vote for major mode
            playerMajorVote(event);
        else if (message_type == 0xc1) // vote for race count
            playerRaceCountVote(event);
        else if (message_type == 0xc2) // vote for minor mode
            playerMinorVote(event);
        else if (message_type == 0xc3) // vote for track
            playerTrackVote(event);
        else if (message_type == 0xc4) // vote for reversed mode
            playerReversedVote(event);
        else if (message_type == 0xc5) // vote for laps
            playerLapsVote(event);
    } // if (event->type == EVENT_TYPE_MESSAGE)
    else if (event->type == EVENT_TYPE_CONNECTED)
    {
    } // if (event->type == EVENT_TYPE_CONNECTED)
    else if (event->type == EVENT_TYPE_DISCONNECTED)
    {
        kartDisconnected(event);
    } // if (event->type == EVENT_TYPE_DISCONNECTED)
    return true;
}
void DiagramEndPoint::messageDragged(
	BPoint point,
	uint32 transit,
	const BMessage *message)
{
	D_MOUSE(("DiagramEndPoint::messageDragged()\n"));
	switch (message->what)
	{
		case M_WIRE_DRAGGED:
		{
			D_MESSAGE(("DiagramEndPoint::messageDragged(M_WIRE_DRAGGED)\n"));
			switch (transit)
			{
				case B_INSIDE_VIEW:
				{
					//PRINT((" -> transit: B_INSIDE_VIEW\n"));
					// this is a WORK-AROUND caused by the unreliability
					// of BViews DragMessage() routine !!
					if (isConnecting())
					{
						break;
					}
					else if (isConnected())
					{
						view()->trackWire(point);
					}
					/* this should be enough in theory:
					if (!isConnecting())
					{
						view()->trackWire(point);
					}
					//break;*/
				}
				case B_ENTERED_VIEW:
				{
					//PRINT((" -> transit: B_ENTERED_VIEW\n"));
					DiagramEndPoint *endPoint;
					if ((message->FindPointer("from", reinterpret_cast<void **>(&endPoint)) == B_OK)
					 && (endPoint != this))
					{
						if (connectionRequested(endPoint))
						{
							view()->trackWire(connectionPoint());
							if (!isConnecting())
							{
								m_connecting = true;
								connected();
							}
						}
						else
						{
							view()->trackWire(point);
							if (isConnecting())
							{
								m_connecting = false;
								disconnected();
							}
						}
					}
					break;
				}
				case B_EXITED_VIEW:
				{
					//PRINT((" -> transit: B_EXITED_VIEW\n"));
					if (isConnecting())
					{
						m_connecting = false;
						disconnected();
					}
					break;
				}
			}
			break;
		}
		default:
		{
			DiagramItem::messageDragged(point, transit, message);
		}
	}
}
Beispiel #8
0
void Nuria::Internal::TcpServer::incomingConnection (qintptr handle) {
	emit connectionRequested (handle);
}