Ejemplo n.º 1
0
bool InventoryItemModel::InsertFolder(int position, const QModelIndex &parent, const QString &name)
{
    InventoryFolder *parentFolder = dynamic_cast<InventoryFolder *>(GetItem(parent));
    if (!parentFolder)
        return false;

    if (parentFolder->IsLibraryItem())
        return false;

    beginInsertRows(parent, position, position );

    RexUUID id;
    bool unique = false;
    while(!unique)
    {
        id.Random();
        AbstractInventoryItem *existing = dataModel_->GetChildFolderById(id.ToQString());
        if (!existing)
            unique = true;
        else
            InventoryModule::LogWarning("Generated an UUID that already exists! Generating a new one...");
    }

    dataModel_->GetOrCreateNewFolder(id.ToQString(), *parentFolder, name);

    endInsertRows();

    return true;
}
Ejemplo n.º 2
0
    // STATIC
    ProtocolUtilities::BuddyListPtr BuddyListParser::ExtractBuddyListFromXMLRPCReply(XmlRpcEpi &call)
    {
        XmlRpcCall *xmlrpcCall = call.GetXMLRPCCall();
        if (!xmlrpcCall)
            throw XmlRpcException("Failed to read buddy list, no XMLRPC Reply to read!");

        XMLRPC_REQUEST request = xmlrpcCall->GetReply();
        if (!request)
            throw XmlRpcException("Failed to read buddy list, no XMLRPC Reply to read!");

        XMLRPC_VALUE result = XMLRPC_RequestGetData(request);
        if (!result)
            throw XmlRpcException("Failed to read buddy list, the XMLRPC Reply did not contain any data!");

        XMLRPC_VALUE buddy_list_node = XMLRPC_VectorGetValueWithID(result, "buddy-list");

        if (!buddy_list_node || XMLRPC_GetValueType(buddy_list_node) != xmlrpc_vector)
            throw XmlRpcException("Failed to read buddy list, buddy-list in the reply was not properly formed!");

        ProtocolUtilities::BuddyListPtr buddy_list = ProtocolUtilities::BuddyListPtr(new ProtocolUtilities::BuddyList());

        XMLRPC_VALUE item = XMLRPC_VectorRewind(buddy_list_node);

        while(item)
        {
            XMLRPC_VALUE_TYPE type = XMLRPC_GetValueType(item);
            if (type == xmlrpc_vector) // xmlrpc-epi handles structs as arrays.
            {
                RexUUID id;
                int rights_given = 0;
                int rights_has = 0;

                XMLRPC_VALUE val = XMLRPC_VectorGetValueWithID(item, "buddy_id");
                if (val && XMLRPC_GetValueType(val) == xmlrpc_string)
                    id.FromString( XMLRPC_GetValueString(val) );

                val = XMLRPC_VectorGetValueWithID(item, "buddy_rights_given");
                if (val && XMLRPC_GetValueType(val) == xmlrpc_type_int)
                    rights_given = XMLRPC_GetValueInt(val);

                val = XMLRPC_VectorGetValueWithID(item, "buddy_rights_has");
                if (val && XMLRPC_GetValueType(val) == xmlrpc_type_int)
                    rights_has = XMLRPC_GetValueInt(val);

                ProtocolUtilities::Buddy *buddy = new ProtocolUtilities::Buddy(id, rights_given, rights_has);
                buddy_list->AddBuddy(buddy);
            }

            item = XMLRPC_VectorNext(buddy_list_node);
        }

        return buddy_list;
    }
Ejemplo n.º 3
0
EC_Ruler::EC_Ruler(IModule *module) :
    IComponent(module->GetFramework()),
    typeAttr_(this, "ruler type", EC_Ruler::Rotation),
    visibleAttr_(this, "visible", false),
    axisAttr_(this, "axis", EC_Ruler::X),
    localAttr_(this, "local", false),
    radiusAttr_(this, "radius", 5),
    segmentsAttr_(this, "segments", 29),
    rulerObject(0),
    gridObject(0),
    sceneNode_(0),
    type(EC_Ruler::Rotation)
{
    renderer_ = module->GetFramework()->GetServiceManager()->GetService<OgreRenderer::Renderer>(Service::ST_Renderer);
    
    RexUUID uuid = RexUUID::CreateRandom();
    rulerName = uuid.ToString() + "ruler";
    nodeName = uuid.ToString() + "node";
    rulerMovingPartName = uuid.ToString() + "mover";
    movingNodeName = uuid.ToString() + "movingNode";
    
    QObject::connect(this, SIGNAL(AttributeChanged(IAttribute*, AttributeChange::Type)), this, SLOT(UpdateRuler()));
}
Ejemplo n.º 4
0
void UDPAssetProvider::RequestTexture(boost::shared_ptr<ProtocolUtilities::ProtocolModuleInterface> net,
                                      const RexUUID& asset_id, const RequestTagVector& tags)
{
    // If request already exists, just append the new tag(s)
    std::string asset_id_str = asset_id.ToString();
    UDPAssetTransfer* transfer = GetTransfer(asset_id_str);
    if (transfer)
    {
        transfer->InsertTags(tags);
        return;
    }

    const ProtocolUtilities::ClientParameters& client = net->GetClientParameters();

    UDPAssetTransfer new_transfer;
    new_transfer.SetAssetId(asset_id.ToString());
    new_transfer.SetAssetType(RexAT_Texture);
    new_transfer.InsertTags(tags);
    texture_transfers_[asset_id] = new_transfer;

    AssetModule::LogDebug("Requesting texture " + asset_id.ToString());

    ProtocolUtilities::NetOutMessage *m = net->StartMessageBuilding(RexNetMsgRequestImage);
    assert(m);

    m->AddUUID(client.agentID);
    m->AddUUID(client.sessionID);

    m->SetVariableBlockCount(1);
    m->AddUUID(asset_id); // Image UUID
    m->AddS8(0); // Discard level
    m->AddF32(100.0); // Download priority
    m->AddU32(0); // Starting packet
    m->AddU8(RexIT_Normal); // Image type
    m->MarkReliable();
    net->FinishMessageBuilding(m);
}
Ejemplo n.º 5
0
void UDPAssetProvider::RequestOtherAsset(boost::shared_ptr<ProtocolUtilities::ProtocolModuleInterface> net,
        const RexUUID& asset_id, uint asset_type, const RequestTagVector& tags)
{
    // If request already exists, just append the new tag(s)
    std::string asset_id_str = asset_id.ToString();
    UDPAssetTransfer* transfer = GetTransfer(asset_id_str);
    if (transfer)
    {
        transfer->InsertTags(tags);
        return;
    }

    RexUUID transfer_id;
    transfer_id.Random();

    UDPAssetTransfer new_transfer;
    new_transfer.SetAssetId(asset_id_str);
    new_transfer.SetAssetType(asset_type);
    new_transfer.InsertTags(tags);
    asset_transfers_[transfer_id] = new_transfer;

    AssetModule::LogDebug("Requesting asset " + asset_id_str);

    ProtocolUtilities::NetOutMessage *m = net->StartMessageBuilding(RexNetMsgTransferRequest);
    assert(m);

    m->AddUUID(transfer_id); // Transfer ID
    m->AddS32(RexAC_Asset); // Asset channel type
    m->AddS32(RexAS_Asset); // Asset source type
    m->AddF32(100.0); // Download priority

    u8 asset_info[20]; // Asset info block with UUID and type
    memcpy(&asset_info[0], &asset_id.data, 16);
    memcpy(&asset_info[16], &asset_type, 4);
    m->AddBuffer(20, asset_info);
    m->MarkReliable();
    net->FinishMessageBuilding(m);

    return;
}