void MediaBase::SetAllowDownloads (bool allow) { const char *uri; Downloader *dl; if ((allow_downloads && allow) || (!allow_downloads && !allow)) return; if (allow && IsAttached () && source_changed) { source_changed = false; if ((uri = GetSource ()) && *uri) { if (!(dl = GetDeployment ()->CreateDownloader ())) { // we're shutting down return; } dl->Open ("GET", uri, GetDownloaderPolicy (uri)); SetSource (dl, ""); dl->unref (); } } allow_downloads = allow; }
void MediaBase::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error) { if (args->GetProperty ()->GetOwnerType() != Type::MEDIABASE) { FrameworkElement::OnPropertyChanged (args, error); return; } if (args->GetId () == MediaBase::SourceProperty) { const char *uri = args->GetNewValue() ? args->GetNewValue()->AsString () : NULL; if (IsAttached () && AllowDownloads ()) { if (uri && *uri) { Downloader *dl; if ((dl = GetDeployment ()->CreateDownloader ())) { dl->Open ("GET", uri, GetDownloaderPolicy (uri)); SetSource (dl, ""); dl->unref (); } else { // we're shutting down } } else { SetSource (NULL, NULL); } } else { source_changed = true; } InvalidateMeasure (); } NotifyListenersOfPropertyChange (args, error); }