Example #1
0
void repository::distributor::update_sources(const entry &package) {
  try {
    BUNSAN_LOG_DEBUG << "Starting \"" << package << "\" " << __func__;
    for (const std::string &src_name : cache_().read_index(package).sources()) {
      update_file(source_url(package, src_name),
                  cache_().source_path(package, src_name),
                  cache_().read_checksum(package).at(src_name));
    }
  } catch (std::exception &) {
    BOOST_THROW_EXCEPTION(distributor_update_sources_error()
                          << distributor_update_sources_error::package(package)
                          << enable_nested_current());
  }
}
/// Called when source texture has changed.
void ElementCircularBar::LoadTexture()
{
	Core::ElementDocument* document = GetOwnerDocument();
	Core::URL source_url(document == NULL ? "" : document->GetSourceURL());

	Core::String source = GetProperty< Core::String >("gauge-src");

	if (!gauge_texture.Load(source, source_url.GetPath()))
	{
		gauge_geometry.SetTexture(NULL);
		return;
	}

	gauge_geometry.SetTexture(&gauge_texture);
	actual_gauge_extent = gauge_texture.GetDimensions(GetRenderInterface());
}
Example #3
0
bool ElementImage::LoadDiskTexture()
{
	texture_dirty = false;

	// Get the source URL for the image.
	String image_source = GetAttribute< String >("src", "");
	if (image_source.Empty())
		return false;

	geometry_dirty = true;

	Rocket::Core::ElementDocument* document = GetOwnerDocument();
	URL source_url(document == NULL ? "" : document->GetSourceURL());

	if (!texture.Load(image_source, source_url.GetPath()))
	{
		geometry.SetTexture(NULL);
		return false;
	}

	// Set the texture onto our geometry object.
	geometry.SetTexture(&texture);
	return true;
}
Example #4
0
void EC_VideoSource::OnAttributeUpdated(IAttribute *attribute)
{
    if (!video_widget_ || !media_object_)
        return;

    bool update_canvas = false;
    if (attribute->GetNameString() == videoSourceUrl.GetNameString())
    {
        if (!getvideoSourceUrl().isEmpty())
        {
            QString source_string = getvideoSourceUrl();
            QUrl source_url(source_string, QUrl::TolerantMode);
            if (source_url.isValid())
            {
                if (media_object_->currentSource().url() != source_url)
                {
    ///\todo Regression. Reimplement using the new Asset API. -jj.
/*
                    Foundation::AssetServiceInterface *asset_service = GetFramework()->GetService<Foundation::AssetServiceInterface>();
                    if (asset_service)
                    {
                        Foundation::AssetInterfacePtr asset = asset_service->GetAsset(source_string.toStdString(), RexTypes::ASSETTYPENAME_VIDEO);
                        if (asset)
                        {
                            LoadVideo(asset);
                        }
                        else
                        {
                            if (expecting_resources_ == false)
                            {
                                video_request_tag_ = asset_service->RequestAsset(source_string.toStdString(), RexTypes::ASSETTYPENAME_VIDEO);
                                if (video_request_tag_)
                                {
                                    expecting_resources_ = true;
                                    LogDebug("Downloading URL source: " + source_string.toStdString());
                                }
                            }
                        }
                    }
*/
                }
            }
            else if (QFile::exists(getvideoSourceUrl()))
            {
                if (media_object_->currentSource().fileName() != getvideoSourceUrl())
                {
                    player_->load(Phonon::MediaSource(getvideoSourceUrl()));
                    LogDebug("Loading file source: " + getvideoSourceUrl().toStdString());
                }
            }
        }
        else
        {
            if (!media_object_->currentSource().fileName().isEmpty())
            {
                media_object_->clear();
                qDebug() << "-- empty source set, clearing media object";
            }
        }
    }
    else if (attribute->GetNameString() == playbackState.GetNameString())
    {
        if (!videoSourceUrl.Get().isEmpty())
        {
            // Play video if video source url has been set and if sound has been triggered or looped.
            if (getplaybackState() == PS_Play && !playing_canvas_)
            {
                Play();
            }
            else if (getplaybackState() == PS_Stop && playing_canvas_)
            {
                Stop();
                stop_canvas_ = true;
                update_canvas = true;
            }
            else if (getplaybackState() == PS_Pause && playing_canvas_)
            {
                Pause();
                stop_canvas_ = true;
                update_canvas = true;
            }
        }
    }
    else if (attribute->GetNameString() == audioPlaybackVolume.GetNameString())
    {
        qreal volume = getaudioPlaybackVolume();
        if (player_->volume() != volume)
        {
            player_->setVolume(volume);
            LogDebug("Volume set to " + QString::number(volume).toStdString());
        }
    }
    else if (attribute->GetNameString() == refreshRate.GetNameString())
    {
        EC_3DCanvas *canvas = Get3DCanvas();
        if (canvas)
        {
            if (getrefreshRate() > 0)
            {
                int ref_rate_msec = 1000 / getrefreshRate();
                if (canvas->GetRefreshRate() != ref_rate_msec)
                {
                    canvas->SetRefreshRate(getrefreshRate());
                    LogDebug("Refresh rate set");
                }
            }
            else if (canvas->GetRefreshRate() != 0)
                canvas->SetRefreshRate(0);
        }
        else
            LogError("Could not get 3D Canvas component to set refresh rate");
    }
    else if (attribute->GetNameString() == scaleDown.GetNameString())
    {
        if (getscaleDown() && player_)
        {
            original_size_ = player_->size();
            if (original_size_.width() < 1 && original_size_.height() < 1)
                original_size_ = QSize(0,0);
            else
                qDebug() << "Original size set: " << original_size_;

            if (original_size_.width() > 1 && original_size_.height() > 1)
            {
                QSize scale_down_size(320, 240);
                if (player_->size().width() > scale_down_size.width() && player_->size().height() > scale_down_size.height())
                {
                    //player_->resize(scale_down_size);
                    //LogDebug("Scaled video widget down to 320x240 for performance");
                }
            }
        }
        else if (!getscaleDown() && player_)
        {
            if (!original_size_.isNull())
            {
                if (original_size_.width() > 0 && original_size_.height() > 0)
                {
                    if (player_->size().width() > original_size_.width() && player_->size().height() > original_size_.height())
                    {
                        //player_->resize(original_size_);
                        //LogDebug("Restored original video widget size");
                    }
                }
                else
                    original_size_ = QSize(0,0);
            }
        }
    }

    if (update_canvas)
        UpdateCanvas();
}