void LLFloaterMarketplaceListings::setPanels()
{
	if (mRootFolderId.isNull())
	{
		return;
	}

	// Consolidate Marketplace listings
	// We shouldn't have to do that but with a client/server system relying on a "well known folder" convention,
	// things get messy and conventions get broken down eventually
	gInventory.consolidateForType(mRootFolderId, LLFolderType::FT_MARKETPLACE_LISTINGS);

	// Now that we do have a non NULL root, we can build the inventory panels
	mPanelListings->buildAllPanels();

	// Create observer for marketplace listings modifications
	if (!mCategoriesObserver)
	{
		mCategoriesObserver = new LLInventoryCategoriesObserver();
		llassert(mCategoriesObserver);
		gInventory.addObserver(mCategoriesObserver);
		mCategoriesObserver->addCategory(mRootFolderId, boost::bind(&LLFloaterMarketplaceListings::onChanged, this));
	}

	// Get the content of the marketplace listings folder
	fetchContents();

	// Flag that this is done
	mPanelListingsSet = true;
}
BOOL LLFloaterMarketplaceListings::postBuild()
{
	mInventoryStatus = getChild<LLTextBox>("marketplace_status");
	mInventoryInitializationInProgress = getChild<LLView>("initialization_progress_indicator");
	mInventoryPlaceholder = getChild<LLView>("marketplace_listings_inventory_placeholder_panel");
	mInventoryText = mInventoryPlaceholder->getChild<LLTextEditor>("marketplace_listings_inventory_placeholder_text");
	mInventoryTitle = mInventoryPlaceholder->getChild<LLTextBox>("marketplace_listings_inventory_placeholder_title");

	LLFocusableElement::setFocusReceivedCallback(boost::bind(&LLFloaterMarketplaceListings::onFocusReceived, this));

	// Observe category creation to catch marketplace listings creation (moot if already existing)
	mCategoryAddedObserver = new LLMarketplaceListingsAddedObserver(this);
	gInventory.addObserver(mCategoryAddedObserver);

	// Fetch aggressively so we can interact with listings right onOpen()
	fetchContents();

	return TRUE;
}
Example #3
0
File: upnp.cpp Project: ZMacer/vlc
input_item_t* MediaServer::getNextItem()
{
    input_item_t *p_item = NULL;

    if( !xmlDocument_ )
    {
        fetchContents();
        if( !xmlDocument_ )
            return NULL;
    }

    if ( containerNodeList_ )
    {
        for ( ; !p_item && containerNodeIndex_ < ixmlNodeList_length( containerNodeList_ )
              ; containerNodeIndex_++ )
        {
            IXML_Element* containerElement = (IXML_Element*)ixmlNodeList_item( containerNodeList_,
                                                                                containerNodeIndex_ );

            const char* objectID = ixmlElement_getAttribute( containerElement,
                                                             "id" );
            if ( !objectID )
                continue;

            const char* title = xml_getChildElementValue( containerElement,
                                                          "dc:title" );
            if ( !title )
                continue;
            p_item = newItem(objectID, title);
        }
    }

    if( itemNodeList_ )
    {
        for ( ; !p_item && itemNodeIndex_ < ixmlNodeList_length( itemNodeList_ )
              ; itemNodeIndex_++ )
        {
            IXML_Element* itemElement =
                        ( IXML_Element* )ixmlNodeList_item( itemNodeList_,
                                                            itemNodeIndex_ );

            const char* objectID =
                        ixmlElement_getAttribute( itemElement, "id" );

            if ( !objectID )
                continue;

            const char* title =
                        xml_getChildElementValue( itemElement, "dc:title" );

            if ( !title )
                continue;

            const char* psz_subtitles = xml_getChildElementValue( itemElement,
                    "sec:CaptionInfo" );

            if ( !psz_subtitles )
                psz_subtitles = xml_getChildElementValue( itemElement,
                        "sec:CaptionInfoEx" );

            if ( !psz_subtitles )
                psz_subtitles = xml_getChildElementValue( itemElement,
                        "pv:subtitlefile" );

            /* Try to extract all resources in DIDL */
            IXML_NodeList* p_resource_list = ixmlDocument_getElementsByTagName( (IXML_Document*) itemElement, "res" );
            if ( p_resource_list && ixmlNodeList_length( p_resource_list ) > 0 )
            {
                mtime_t i_duration = -1;
                int i_hours, i_minutes, i_seconds;
                IXML_Element* p_resource = ( IXML_Element* ) ixmlNodeList_item( p_resource_list, 0 );
                const char* psz_resource_url = xml_getChildElementValue( p_resource, "res" );
                if( !psz_resource_url )
                    continue;
                const char* psz_duration = ixmlElement_getAttribute( p_resource, "duration" );

                if ( psz_duration )
                {
                    if( sscanf( psz_duration, "%d:%02d:%02d",
                        &i_hours, &i_minutes, &i_seconds ) )
                        i_duration = INT64_C(1000000) * ( i_hours*3600 +
                                                          i_minutes*60 +
                                                          i_seconds );
                }

                p_item = newItem( title, objectID, psz_subtitles, i_duration,
                                  psz_resource_url );
            }
            ixmlNodeList_free( p_resource_list );
        }
    }

    return p_item;
}
void LLFloaterMarketplaceListings::updateView()
{
	U32 mkt_status = LLMarketplaceData::instance().getSLMStatus();
	bool is_merchant = (mkt_status == MarketplaceStatusCodes::MARKET_PLACE_MERCHANT) || (mkt_status == MarketplaceStatusCodes::MARKET_PLACE_MIGRATED_MERCHANT);
	U32 data_fetched = LLMarketplaceData::instance().getSLMDataFetched();

	// Get or create the root folder if we are a merchant and it hasn't been done already
	if (mRootFolderId.isNull() && is_merchant)
	{
		setRootFolder();
	}

	// Update the bottom initializing status and progress dial if we are initializing or if we're a merchant and still loading
	if ((mkt_status <= MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING) || (is_merchant && (data_fetched <= MarketplaceFetchCodes::MARKET_FETCH_LOADING)) )
	{
		// Just show the loading indicator in that case and fetch the data (fetch will be skipped if it's already loading)
		mInventoryInitializationInProgress->setVisible(true);
		mPanelListings->setVisible(FALSE);
		fetchContents();
		return;
	}
	else
	{
		mInventoryInitializationInProgress->setVisible(false);
	}

	// Update the middle portion : tabs or messages
	if (getFolderCount() > 0)
	{
		if (!mPanelListingsSet)
		{
			// We need to rebuild the tabs cleanly the first time we make them visible
			setPanels();
		}
		mPanelListings->setVisible(TRUE);
		mInventoryPlaceholder->setVisible(FALSE);
	}
	else
	{
		mPanelListings->setVisible(FALSE);
		mInventoryPlaceholder->setVisible(TRUE);

		std::string text;
		std::string title;
		std::string tooltip;

		const LLSD& subs = LLMarketplaceData::instance().getMarketplaceStringSubstitutions();

		// Update the top message or flip to the tabs and folders view
		// *TODO : check those messages and create better appropriate ones in strings.xml
		if (mRootFolderId.notNull())
		{
			// "Marketplace listings is empty!" message strings
			text = LLTrans::getString("InventoryMarketplaceListingsNoItems", subs);
			title = LLTrans::getString("InventoryMarketplaceListingsNoItemsTitle");
			tooltip = LLTrans::getString("InventoryMarketplaceListingsNoItemsTooltip");
		}
		else if (mkt_status <= MarketplaceStatusCodes::MARKET_PLACE_INITIALIZING)
		{
			// "Initializing!" message strings
			text = LLTrans::getString("InventoryOutboxInitializing", subs);
			title = LLTrans::getString("InventoryOutboxInitializingTitle");
			tooltip = LLTrans::getString("InventoryOutboxInitializingTooltip");
		}
		else if (mkt_status == MarketplaceStatusCodes::MARKET_PLACE_NOT_MERCHANT)
		{
			// "Not a merchant!" message strings
			text = LLTrans::getString("InventoryOutboxNotMerchant", subs);
			title = LLTrans::getString("InventoryOutboxNotMerchantTitle");
			tooltip = LLTrans::getString("InventoryOutboxNotMerchantTooltip");
		}
		else
		{
			// "Errors!" message strings
			text = LLTrans::getString("InventoryMarketplaceError", subs);
			title = LLTrans::getString("InventoryOutboxErrorTitle");
			tooltip = LLTrans::getString("InventoryOutboxErrorTooltip");
		}

		mInventoryText->setValue(text);
		mInventoryTitle->setValue(title);
		mInventoryPlaceholder->getParent()->setToolTip(tooltip);
	}
}