void UIWizardFirstRunPage::onOpenMediumWithFileOpenDialog()
{
    /* Get opened vboxMedium id: */
    QUuid uMediumId;
    vboxGlobal().openMediumSelectorDialog(thisImp(), UIMediumDeviceType_DVD, uMediumId, "", "", "", true);
    /* Update medium-combo if necessary: */
    if (!uMediumId.isNull())
        m_pMediaSelector->setCurrentItem(uMediumId);
}
예제 #2
0
void CtcpParser::parseStandard(IrcEventRawMessage *e, Message::Type messagetype, QByteArray dequotedMessage, CtcpEvent::CtcpType ctcptype, Message::Flags flags)
{
    QByteArray ctcp;

    QList<CtcpEvent *> ctcpEvents;
    QUuid uuid; // needed to group all replies together

    // extract tagged / extended data
    int xdelimPos = -1;
    int xdelimEndPos = -1;
    int spacePos = -1;
    while ((xdelimPos = dequotedMessage.indexOf(XDELIM)) != -1) {
        if (xdelimPos > 0)
            displayMsg(e, messagetype, targetDecode(e, dequotedMessage.left(xdelimPos)), e->prefix(), e->target(), flags);

        xdelimEndPos = dequotedMessage.indexOf(XDELIM, xdelimPos + 1);
        if (xdelimEndPos == -1) {
            // no matching end delimiter found... treat rest of the message as ctcp
            xdelimEndPos = dequotedMessage.count();
        }
        ctcp = xdelimDequote(dequotedMessage.mid(xdelimPos + 1, xdelimEndPos - xdelimPos - 1));
        dequotedMessage = dequotedMessage.mid(xdelimEndPos + 1);

        //dispatch the ctcp command
        QString ctcpcmd = targetDecode(e, ctcp.left(spacePos));
        QString ctcpparam = targetDecode(e, ctcp.mid(spacePos + 1));

        spacePos = ctcp.indexOf(' ');
        if (spacePos != -1) {
            ctcpcmd = targetDecode(e, ctcp.left(spacePos));
            ctcpparam = targetDecode(e, ctcp.mid(spacePos + 1));
        }
        else {
            ctcpcmd = targetDecode(e, ctcp);
            ctcpparam = QString();
        }

        ctcpcmd = ctcpcmd.toUpper();

        // we don't want to block /me messages by the CTCP ignore list
        if (ctcpcmd == QLatin1String("ACTION") || !coreSession()->ignoreListManager()->ctcpMatch(e->prefix(), e->network()->networkName(), ctcpcmd)) {
            if (uuid.isNull())
                uuid = QUuid::createUuid();

            CtcpEvent *event = new CtcpEvent(EventManager::CtcpEvent, e->network(), e->prefix(), e->target(),
                ctcptype, ctcpcmd, ctcpparam, e->timestamp(), uuid);
            ctcpEvents << event;
        }
    }
    if (!ctcpEvents.isEmpty()) {
        _replies.insert(uuid, CtcpReply(coreNetwork(e), nickFromMask(e->prefix())));
        CtcpEvent *flushEvent = new CtcpEvent(EventManager::CtcpEventFlush, e->network(), e->prefix(), e->target(),
            ctcptype, "INVALID", QString(), e->timestamp(), uuid);
        ctcpEvents << flushEvent;
        foreach(CtcpEvent *event, ctcpEvents) {
            emit newEvent(event);
        }
예제 #3
0
파일: qaxserver.cpp 프로젝트: RSATom/Qt
static QString stripCurlyBraces(const QUuid &uuid)
{
    if (uuid.isNull())
        return QString();
    QString result = uuid.toString().toUpper();
    result.chop(1);
    result.remove(0, 1);
    return result;
}
예제 #4
0
void LimitedNodeList::fillPacketHeader(const NLPacket& packet, const QUuid& connectionSecret) {
    if (!NON_SOURCED_PACKETS.contains(packet.getType())) {
        packet.writeSourceID(getSessionUUID());
    }
    
    if (!connectionSecret.isNull()
        && !NON_SOURCED_PACKETS.contains(packet.getType())
        && !NON_VERIFIED_PACKETS.contains(packet.getType())) {
        packet.writeVerificationHashGivenSecret(connectionSecret);
    }
}
예제 #5
0
 bool fromJson(const QJsonObject& obj)
 {
     if (!obj["id"].isString() || !obj["x"].isDouble() ||
         !obj["y"].isDouble())
     {
         return false;
     }
     id = obj["id"].toString();
     pos = QPointF(obj["x"].toDouble(), obj["y"].toDouble());
     return !id.isNull();
 }
예제 #6
0
void ClientTransferManager::onCoreTransferAdded(const QUuid &uuid)
{
    if (uuid.isNull()) {
        qWarning() << Q_FUNC_INFO << "Invalid transfer uuid" << uuid.toString();
        return;
    }

    auto transfer = new ClientTransfer(uuid, this);
    connect(transfer, SIGNAL(initDone()), SLOT(onTransferInitDone())); // we only want to add initialized transfers
    Client::signalProxy()->synchronize(transfer);
}
예제 #7
0
void Node::addIgnoredNode(const QUuid& otherNodeID) {
    if (!otherNodeID.isNull() && otherNodeID != _uuid) {
        qCDebug(networking) << "Adding" << uuidStringWithoutCurlyBraces(otherNodeID) << "to ignore set for"
        << uuidStringWithoutCurlyBraces(_uuid);

        // add the session UUID to the set of ignored ones for this listening node
        _ignoredNodeIDSet.insert(otherNodeID);
    } else {
        qCWarning(networking) << "Node::addIgnoredNode called with null ID or ID of ignoring node.";
    }
}
예제 #8
0
QList<btRigidBody*> ObjectConstraintSlider::getRigidBodies() {
    QList<btRigidBody*> result;
    result += getRigidBody();
    QUuid otherEntityID;
    withReadLock([&]{
        otherEntityID = _otherID;
    });
    if (!otherEntityID.isNull()) {
        result += getOtherRigidBody(otherEntityID);
    }
    return result;
}
예제 #9
0
int populatePacketHeader(char* packet, PacketType type, const QUuid& connectionUUID) {
    int numTypeBytes = packArithmeticallyCodedValue(type, packet);
    packet[numTypeBytes] = versionForPacketType(type);
    
    QUuid packUUID = connectionUUID.isNull() ? NodeList::getInstance()->getOwnerUUID() : connectionUUID;
    
    QByteArray rfcUUID = packUUID.toRfc4122();
    memcpy(packet + numTypeBytes + sizeof(PacketVersion), rfcUUID.constData(), NUM_BYTES_RFC4122_UUID);
    
    // return the number of bytes written for pointer pushing
    return numTypeBytes + sizeof(PacketVersion) + NUM_BYTES_RFC4122_UUID;
}
예제 #10
0
btTypedConstraint* ObjectConstraintBallSocket::getConstraint() {
    btPoint2PointConstraint* constraint { nullptr };
    QUuid otherEntityID;
    glm::vec3 pivotInA;
    glm::vec3 pivotInB;

    withReadLock([&]{
        constraint = static_cast<btPoint2PointConstraint*>(_constraint);
        pivotInA = _pivotInA;
        otherEntityID = _otherID;
        pivotInB = _pivotInB;
    });
    if (constraint) {
        return constraint;
    }

    static QString repeatedBallSocketNoRigidBody = LogHandler::getInstance().addRepeatedMessageRegex(
        "ObjectConstraintBallSocket::getConstraint -- no rigidBody.*");

    btRigidBody* rigidBodyA = getRigidBody();
    if (!rigidBodyA) {
        qCDebug(physics) << "ObjectConstraintBallSocket::getConstraint -- no rigidBodyA";
        return nullptr;
    }

    if (!otherEntityID.isNull()) {
        // This constraint is between two entities... find the other rigid body.

        btRigidBody* rigidBodyB = getOtherRigidBody(otherEntityID);
        if (!rigidBodyB) {
            qCDebug(physics) << "ObjectConstraintBallSocket::getConstraint -- no rigidBodyB";
            return nullptr;
        }

        constraint = new btPoint2PointConstraint(*rigidBodyA, *rigidBodyB, glmToBullet(pivotInA), glmToBullet(pivotInB));
    } else {
        // This constraint is between an entity and the world-frame.

        constraint = new btPoint2PointConstraint(*rigidBodyA, glmToBullet(pivotInA));
    }

    withWriteLock([&]{
        _constraint = constraint;
    });

    // if we don't wake up rigidBodyA, we may not send the dynamicData property over the network
    forceBodyNonStatic();
    activateBody();

    updateBallSocket();

    return constraint;
}
void AssignmentClientMonitor::handleChildStatusPacket(QSharedPointer<ReceivedMessage> message) {
    // read out the sender ID
    QUuid senderID = QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID));

    auto nodeList = DependencyManager::get<NodeList>();

    SharedNodePointer matchingNode = nodeList->nodeWithUUID(senderID);
    const HifiSockAddr& senderSockAddr = message->getSenderSockAddr();

    AssignmentClientChildData* childData = nullptr;

    if (!matchingNode) {
        // The parent only expects to be talking with prorams running on this same machine.
        if (senderSockAddr.getAddress() == QHostAddress::LocalHost ||
                senderSockAddr.getAddress() == QHostAddress::LocalHostIPv6) {

            if (!senderID.isNull()) {
                // We don't have this node yet - we should add it
                matchingNode = DependencyManager::get<LimitedNodeList>()->addOrUpdateNode(senderID, NodeType::Unassigned,
                                                                                          senderSockAddr, senderSockAddr);

                auto childData = std::unique_ptr<AssignmentClientChildData>
                    { new AssignmentClientChildData(Assignment::Type::AllTypes) };
                matchingNode->setLinkedData(std::move(childData));
            } else {
                // tell unknown assignment-client child to exit.
                qDebug() << "Asking unknown child at" << senderSockAddr << "to exit.";

                auto diePacket = NLPacket::create(PacketType::StopNode, 0);
                nodeList->sendPacket(std::move(diePacket), senderSockAddr);

                return;
            }
        }
    } else {
        childData = dynamic_cast<AssignmentClientChildData*>(matchingNode->getLinkedData());
    }

    if (childData) {
        // update our records about how to reach this child
        matchingNode->setLocalSocket(senderSockAddr);

        // get child's assignment type out of the packet
        quint8 assignmentType;
        message->readPrimitive(&assignmentType);

        childData->setChildType(Assignment::Type(assignmentType));

        // note when this child talked
        matchingNode->setLastHeardMicrostamp(usecTimestampNow());
    }
}
예제 #12
0
 bool fromJson(const QJsonObject& obj)
 {
     if (!obj["id"].isString() || !obj["w"].isDouble() ||
         !obj["h"].isDouble() || !obj["centered"].isBool())
     {
         return false;
     }
     id = obj["id"].toString();
     size = QSizeF(obj["w"].toDouble(), obj["h"].toDouble());
     fixedPoint = obj["centered"].toBool() ? WindowPoint::CENTER
                                           : WindowPoint::TOP_LEFT;
     return !id.isNull();
 }
예제 #13
0
QUuid PlaylistWindow::getItemAfter(QUuid list, QUuid item)
{
    auto pl = PlaylistCollection::getSingleton()->playlistOf(list);
    if (!pl)
        return QUuid();
    QUuid uuid = pl->queueTakeFirst();
    if (!uuid.isNull())
        return uuid;
    QSharedPointer<Item> after = pl->itemAfter(item);
    if (!after)
        return QUuid();
    return after->uuid();
}
예제 #14
0
void Node::removeIgnoredNode(const QUuid& otherNodeID) {
    if (!otherNodeID.isNull() && otherNodeID != _uuid) {
        // insert/find are read locked concurrently. unsafe_erase is not concurrent, and needs a write lock.
        QWriteLocker lock { &_ignoredNodeIDSetLock };
        qCDebug(networking) << "Removing" << uuidStringWithoutCurlyBraces(otherNodeID) << "from ignore set for"
        << uuidStringWithoutCurlyBraces(_uuid);

        // remove the session UUID from the set of ignored ones for this listening node
        _ignoredNodeIDSet.unsafe_erase(otherNodeID);
    } else {
        qCWarning(networking) << "Node::removeIgnoredNode called with null ID or ID of ignoring node.";
    }
}
예제 #15
0
void UnplacedComponentsDock::on_lstUnplacedComponents_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
{
    Q_UNUSED(previous);

    GenCompInstance* genComp = nullptr;
    if (mBoard && current)
    {
        QUuid genCompUuid = current->data(Qt::UserRole).toUuid();
        Q_ASSERT(genCompUuid.isNull() == false);
        genComp = mProject.getCircuit().getGenCompInstanceByUuid(genCompUuid);
    }
    setSelectedGenCompInstance(genComp);
}
예제 #16
0
bool OctreePacketData::appendValue(const QUuid& uuid) {
    QByteArray bytes = uuid.toRfc4122();
    if (uuid.isNull()) {
        return appendValue((uint16_t)0); // zero length for null uuid
    } else {
        uint16_t length = bytes.size();
        bool success = appendValue(length);
        if (success) {
            success = appendRawData((const unsigned char*)bytes.constData(), bytes.size());
        }
        return success;
    }
}
예제 #17
0
/*static*/ QString XmlNoteReader::findUuid(const QUuid uuid, const QString &path)
{
    if(uuid.isNull())
        return QString();

    QDirIterator it(path, QDirIterator::Subdirectories);
    while(it.hasNext())
    {
              QString filePath = it.next();
                  if(uuid == XmlNoteReader::uuid(filePath))
                      return filePath;
    }
    return QString();
}
예제 #18
0
void Node::addIgnoredNode(const QUuid& otherNodeID) {
    if (!otherNodeID.isNull() && otherNodeID != _uuid) {
        QWriteLocker lock { &_ignoredNodeIDSetLock };
        qCDebug(networking) << "Adding" << uuidStringWithoutCurlyBraces(otherNodeID) << "to ignore set for"
            << uuidStringWithoutCurlyBraces(_uuid);

        // add the session UUID to the set of ignored ones for this listening node
        if (std::find(_ignoredNodeIDs.begin(), _ignoredNodeIDs.end(), otherNodeID) == _ignoredNodeIDs.end()) {
            _ignoredNodeIDs.push_back(otherNodeID);
        }
    } else {
        qCWarning(networking) << "Node::addIgnoredNode called with null ID or ID of ignoring node.";
    }
}
void CDTMapToolSelectTrainingSamples::setSampleID(QUuid id)
{
    if (id.isNull()) return;
    clearRubberBand();
    
    model->clear();
    model->setQuery(QString("select name,id from category where imageid = "
                            "(select imageid from segmentationlayer where id = "
                            "(select segmentationid from sample_segmentation "
                            "where id = '%1'))").arg(id),
                    QSqlDatabase::database("category"));

    sampleID = id;
    updateRubber();
}
예제 #20
0
QUuid ContextPrivate::registerExternalAsset( const QString &pFileName )
{
	QUuid		AssIdx = mAssetMap.key( pFileName );

	if( !AssIdx.isNull() )
	{
		return( AssIdx );
	}

	AssIdx = QUuid::createUuid();

	mAssetMap.insert( AssIdx, pFileName );

	return( AssIdx );
}
예제 #21
0
void Node::removeIgnoredNode(const QUuid& otherNodeID) {
    if (!otherNodeID.isNull() && otherNodeID != _uuid) {
        QWriteLocker lock { &_ignoredNodeIDSetLock };
        qCDebug(networking) << "Removing" << uuidStringWithoutCurlyBraces(otherNodeID) << "from ignore set for"
            << uuidStringWithoutCurlyBraces(_uuid);

        // remove the session UUID from the set of ignored ones for this listening node, if it exists
        auto it = std::remove(_ignoredNodeIDs.begin(), _ignoredNodeIDs.end(), otherNodeID);
        if (it != _ignoredNodeIDs.end()) {
            _ignoredNodeIDs.erase(it);
        }
    } else {
        qCWarning(networking) << "Node::removeIgnoredNode called with null ID or ID of ignoring node.";
    }
}
예제 #22
0
QString RecordBase::EncodeGuid
(
	const QUuid& uid
) 
{
	if (uid.isNull() == false)
	{
	    QString guidStr = uid.toString();
		guidStr.remove(QChar('{')).remove(QChar('}'));

		return guidStr;
	}

	return QString();
}
예제 #23
0
/*static*/ QUuid XmlNoteReader::parseUuid(QString idStr)
{
    QUuid uuid;
     // try to parse the rightmost 32 digits and four hyphens
    uuid = QUuid(idStr.rightRef(32 + 4).toString());

    if(uuid.isNull()) // if parsing fails, try more complex parsing
    {
        if(idStr.leftRef(QString("urn:uuid:").length()) == "urn:uuid:") // check if first 9 chars match "urn:uuid:"
        {
            QStringRef uuidRef = idStr.midRef(QString("urn:uuid:").length(),32+4); //32 digits and four hyphens
            uuid = QUuid(uuidRef.toString());
        }
        else // try to parse the whole string
        {
            uuid = QUuid(idStr.simplified());
        }
    }

    if(uuid.isNull())
        qDebug("XmlNoteReader::parseUuid : error parsing UUID, null UUID has been generated");

    return uuid;
}
예제 #24
0
qint64 LimitedNodeList::writePacket(const NLPacket& packet, const HifiSockAddr& destinationSockAddr,
                                    const QUuid& connectionSecret) {
    if (!NON_SOURCED_PACKETS.contains(packet.getType())) {
        const_cast<NLPacket&>(packet).writeSourceID(getSessionUUID());
    }
    
    if (!connectionSecret.isNull()
        && !NON_SOURCED_PACKETS.contains(packet.getType())
        && !NON_VERIFIED_PACKETS.contains(packet.getType())) {
        const_cast<NLPacket&>(packet).writeVerificationHash(packet.payloadHashWithConnectionUUID(connectionSecret));
    }

    emit dataSent(NodeType::Unassigned, packet.getDataSize());
    
    return writeDatagram(QByteArray::fromRawData(packet.getData(), packet.getDataSize()), destinationSockAddr);
}
예제 #25
0
파일: nodes.cpp 프로젝트: Alwnikrotikz/sire
/** Construct to hold the node that connects to the backend
    using 'frontend' */
Nodes::Nodes(Frontend frontend)
{
    QUuid uid = frontend.UID();
    
    if (uid.isNull())
        return;
        
    d.reset( new NodesPvt() );
    
    QMutexLocker lkr( &(d->datamutex) );
    
    d->frontends.insert( uid, frontend );
    d->free_frontends.append(uid);
    
    d->nodesem.reset( new QSemaphore(d->frontends.count()) );
}
예제 #26
0
Thing::Thing(const QUuid& specificUid)
: m_qp_takerOwner(0)
{
	//this is in general a bad thing, and the reason why uuids don't have operator=. HOWEVER,
	// in certain situations it's ok to do this, such as if an object will live on in a frozen state
	// (on disk, etc)
	if (specificUid.isNull())
	{
		//can never allow an invalid one
		m_uid = QUuid::createUuid();
	}
	else
	{
		m_uid = specificUid;
	}
}
예제 #27
0
void CChatSessionG2::OnCHATANS(G2Packet *pPacket)
{
	char szType[9];
	quint32 nLength = 0, nNext = 0;

	bool bAccepted = false;

	while(pPacket->ReadPacket(&szType[0], nLength))
	{
		nNext = pPacket->m_nPosition + nLength;

		if(strcmp("USERGUID", szType) == 0 && nLength >= 16)
		{
			QUuid oGUID;
			oGUID = pPacket->ReadGUID();
			if( !oGUID.isNull() )
			{
				m_oGUID = oGUID;
				emit guidChanged(oGUID);
			}
		}
		else if (strcmp("ACCEPT", szType) == 0 )
		{
			emit systemMessage("Private conversation accepted, you're now chatting with " + m_sNick);
			qDebug() << "chat accepted";
			bAccepted = true;
		}
		else if( strcmp("DENY", szType) == 0 )
		{
			emit systemMessage("Private conversation denied by remote host, sorry.");
			qDebug() << "chat denied";
			CNetworkConnection::Close();
			return;
		}
		else if( strcmp("AWAY", szType) == 0 )
		{
			emit systemMessage(m_sNick + " is away.");
			qDebug() << "he is away";
			bAccepted = true;
		}

		pPacket->m_nPosition = nNext;
	}

	if( bAccepted )
		m_nState = csActive;
}
예제 #28
0
// This method is called when the edit packet layer has determined that it has a fully formed packet destined for
// a known nodeID.
void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, unsigned char* buffer,
                                               size_t length, qint64 satoshiCost) {

    bool wantDebug = false;
    DependencyManager::get<NodeList>()->eachNode([&](const SharedNodePointer& node){
        // only send to the NodeTypes that are getMyNodeType()
        if (node->getType() == getMyNodeType()
            && ((node->getUUID() == nodeUUID) || (nodeUUID.isNull()))
            && node->getActiveSocket()) {
            
            // pack sequence number
            int numBytesPacketHeader = numBytesForPacketHeader(reinterpret_cast<char*>(buffer));
            unsigned char* sequenceAt = buffer + numBytesPacketHeader;
            quint16 sequence = _outgoingSequenceNumbers[nodeUUID]++;
            memcpy(sequenceAt, &sequence, sizeof(quint16));
            
            // send packet
            QByteArray packet(reinterpret_cast<const char*>(buffer), length);
            
            queuePacketForSending(node, packet);
            
            if (hasDestinationWalletUUID() && satoshiCost > 0) {
                // if we have a destination wallet UUID and a cost associated with this packet, signal that it
                // needs to be sent
                emit octreePaymentRequired(satoshiCost, nodeUUID, _destinationWalletUUID);
            }
            
            // add packet to history
            _sentPacketHistories[nodeUUID].packetSent(sequence, packet);
            
            // debugging output...
            if (wantDebug) {
                int numBytesPacketHeader = numBytesForPacketHeader(reinterpret_cast<const char*>(buffer));
                unsigned short int sequence = (*((unsigned short int*)(buffer + numBytesPacketHeader)));
                quint64 createdAt = (*((quint64*)(buffer + numBytesPacketHeader + sizeof(sequence))));
                quint64 queuedAt = usecTimestampNow();
                quint64 transitTime = queuedAt - createdAt;
                
                qDebug() << "OctreeEditPacketSender::queuePacketToNode() queued " << buffer[0] <<
                " - command to node bytes=" << length <<
                " satoshiCost=" << satoshiCost <<
                " sequence=" << sequence <<
                " transitTimeSoFar=" << transitTime << " usecs";
            }
        }
    });
}
예제 #29
0
SessionManager::Locker SessionManager::getDataByCookie(Cookies &cookies)
{
  QUuid id;

  // get the cookie
  if (cookies.contains("WEXUS_SESSION_UUID"))
    id = QUuid(cookies["WEXUS_SESSION_UUID"].toString());

  // make a new id if needed
  if (id.isNull()) {
    id = QUuid::createUuid();
    cookies["WEXUS_SESSION_UUID"] = id.toString();
  }

  // finally, extract the session
  return getData(id);
}
예제 #30
0
SpatiallyNestableWeakPointer InterfaceParentFinder::find(QUuid parentID, bool& success, SpatialParentTree* entityTree) const {
    SpatiallyNestableWeakPointer parent;

    if (parentID.isNull()) {
        success = true;
        return parent;
    }

    // search entities
    if (entityTree) {
        parent = entityTree->findByID(parentID);
    } else {
        auto treeRenderer = qApp->getEntities();
        EntityTreePointer tree = treeRenderer ? treeRenderer->getTree() : nullptr;
        parent = tree ? tree->findEntityByEntityItemID(parentID) : nullptr;
    }
    if (!parent.expired()) {
        success = true;
        return parent;
    }

    // search avatars
    QSharedPointer<AvatarManager> avatarManager = DependencyManager::get<AvatarManager>();
    parent = avatarManager->getAvatarBySessionID(parentID);
    if (!parent.expired()) {
        success = true;
        return parent;
    }
    if (parentID == AVATAR_SELF_ID) {
        success = true;
        return avatarManager->getMyAvatar();
    }

    // search overlays
    auto& overlays = qApp->getOverlays();
    auto overlay = overlays.getOverlay(parentID);
    parent = std::dynamic_pointer_cast<SpatiallyNestable>(overlay); // this will return nullptr for non-3d overlays
    if (!parent.expired()) {
        success = true;
        return parent;
    }

    success = false;
    return parent;
}