public async Task Refresh() { var repoFetch = PluginMetadataCollection.DownloadAsync(); var timeoutTask = Task.Delay(TimeSpan.FromSeconds(5)); PluginMetadataCollection collection = null; try { var completedTask = await Task.WhenAny(repoFetch, timeoutTask); if (completedTask == timeoutTask) { MessageBox.Show("Fetching plugin metadata timed-out. Only local plugins will be shown.", MessageBoxType.Warning); } else { collection = await repoFetch; } } catch (HttpRequestException) { MessageBox.Show("OTD cannot connect to Internet. Only local plugins will be shown.", MessageBoxType.Warning); } catch (Exception e) { MessageBox.Show($"Error: {e.Message}", MessageBoxType.Error); Log.Write("PluginManager", e.Message); } finally { collection ??= PluginMetadataCollection.Empty; } await Refresh(collection); }
public async Task ExpandRepositoryTarballFork() { var metadataCollection = await PluginMetadataCollection.DownloadAsync("InfinityGhost", PluginMetadataCollection.REPOSITORY_NAME); foreach (var metadata in metadataCollection) { Console.WriteLine(); Console.Out.WriteProperties(metadata); } }
public async Task Refresh(PluginMetadataCollection newRepository) { Repository = newRepository; await App.Driver.Instance.LoadPlugins(); AppInfo.PluginManager.Load(); (Application.Instance.MainForm as MainForm).Refresh(); pluginList.Refresh(); }
protected async Task <PluginMetadataCollection> GetTestRepository() { if (File.Exists(CollectionTarball)) { using (var stream = File.OpenRead(CollectionTarball)) return(PluginMetadataCollection.FromStream(stream)); } else { return(await PluginMetadataCollection.DownloadAsync()); } }
public async Task Refresh(PluginMetadataCollection newRepository) { Repository = newRepository; await App.Driver.Instance.LoadPlugins(); AppInfo.PluginManager.Load(); // Refresh settings App.Current.Settings = await App.Driver.Instance.GetSettings(); pluginList.Refresh(); }
public async void Refresh() { var index = SelectedIndex; Repository ??= await PluginMetadataCollection.DownloadAsync(); var installed = from plugin in AppInfo.PluginManager.GetLoadedPlugins() orderby plugin.FriendlyName select plugin; var installedMeta = from ctx in installed let meta = ctx.GetMetadata() where meta != null select meta; var fetched = from meta in Repository where meta.SupportedDriverVersion <= AppVersion where !installedMeta.Any(m => PluginMetadata.Match(m, meta)) select meta; var versions = from meta in installedMeta.Concat(fetched) orderby meta.PluginVersion descending group meta by(meta.Name, meta.Owner, meta.RepositoryUrl); var displayQuery = from grp in versions let meta = grp.FirstOrDefault() orderby meta.Name orderby installedMeta.Any(m => PluginMetadata.Match(m, meta)) descending select meta; this.InstalledPlugins = installed.ToList(); this.DisplayedPlugins.Clear(); foreach (var meta in displayQuery) { this.DisplayedPlugins.Add(meta); } SelectedIndex = index; }
public void SetRepository(PluginMetadataCollection repository) => Application.Instance.AsyncInvoke(() => {
public async void Refresh() { if (MetadataReference.TryGetTarget(out var metadata)) { var contexts = AppInfo.PluginManager.GetLoadedPlugins(); Repository ??= await PluginMetadataCollection.DownloadAsync(); bool isInstalled = contexts.Any(t => PluginMetadata.Match(t.GetMetadata(), metadata)); var updatableFromRepository = from meta in Repository where PluginMetadata.Match(meta, metadata) where meta.PluginVersion > metadata.PluginVersion where driverVersion >= meta.SupportedDriverVersion orderby meta.PluginVersion descending select meta; var canUpdate = updatableFromRepository.Any(); var actions = new StackLayout { Orientation = Orientation.Horizontal, Spacing = 5, Items = { new StackLayoutItem { Expand = true, Control = new Button((sender, e) => RequestPluginUninstall?.Invoke(metadata)) { Text = "Uninstall", Enabled = isInstalled } }, new StackLayoutItem { Expand = true, Control = new Button((sender, e) => RequestPluginInstall?.Invoke(canUpdate ? updatableFromRepository.First() : metadata)) { Text = canUpdate ? "Update" : "Install", Enabled = canUpdate || !isInstalled }, } } }; base.Content = new Scrollable { Content = new StackLayout { Padding = 5, Spacing = 5, HorizontalContentAlignment = HorizontalAlignment.Stretch, Items = { new AlignedGroup("Name", metadata.Name), new AlignedGroup("Owner", metadata.Owner), new AlignedGroup("Description", metadata.Description), new AlignedGroup("Driver Version", metadata.SupportedDriverVersion?.ToString()), new AlignedGroup("Plugin Version", metadata.PluginVersion?.ToString()), new LinkButtonGroup("Source Code Repository", metadata.RepositoryUrl, "Show source code"), new LinkButtonGroup("Wiki", metadata.WikiUrl, "Show plugin wiki"), new AlignedGroup("License", metadata.LicenseIdentifier), new StackLayoutItem(null, true), actions } } }; } }