void ImageDownloaded(object state) { Gtk.Application.Invoke(delegate { if (destroyed) { return; } try { LoadImage(aentry.EndDownloadSupportFile(aresult)); } catch { // ignore } }); }
void LoadRemoteIcon(TreeIter it, string iconId, AddinRepositoryEntry arep, IAsyncResult res, AddinHeader info, object dataItem, AddinStatus status) { if (!disposed && treeStore.IterIsValid(it)) { Gdk.Pixbuf customPix = null; try { Gdk.PixbufLoader loader = new Gdk.PixbufLoader(arep.EndDownloadSupportFile(res)); customPix = loader.Pixbuf; } catch (Exception ex) { Console.WriteLine(ex); } cachedIcons [iconId] = customPix; StoreIcon(it, iconId, customPix, status); } }
public void GetSupportFile() { InitRepository(); setup.BuildRepository(monitor, repoDir); setup.Repositories.RegisterRepository(monitor, repoUrl, true); AddinRepositoryEntry arep = setup.Repositories.GetAvailableAddin("SimpleApp.Core", "0.1.0")[0]; IAsyncResult res = arep.BeginDownloadSupportFile(arep.Addin.Properties.GetPropertyValue("Prop3"), null, null); Stream s = arep.EndDownloadSupportFile(res); StreamReader sr = new StreamReader(s); Assert.AreEqual("Some support file", sr.ReadToEnd()); sr.Close(); setup.Repositories.RemoveRepository(repoUrl); }
void LoadRemoteIcon(TreeIter it, string iconId, AddinRepositoryEntry arep, IAsyncResult res, AddinHeader info, object dataItem, AddinStatus status) { if (!disposed && treeStore.IterIsValid (it)) { Gdk.Pixbuf customPix = null; try { Gdk.PixbufLoader loader = new Gdk.PixbufLoader (arep.EndDownloadSupportFile (res)); customPix = loader.Pixbuf; } catch (Exception ex) { Console.WriteLine (ex); } cachedIcons [iconId] = customPix; StoreIcon (it, iconId, customPix, status); } }
static IEnumerable <Release> ParseReleases(string addinId, AddinRepositoryEntry entry) { // Format of release notes is: // {{version1,date1}} release note text {{version2,date2}} release note text ... // Releases msyu // for example: // {{1.1,2011-01-10}} Release notes for 1.1 {{1.2,2011-03-22}} Release notes for 2.3 string releaseNotes = entry.Addin.Properties.GetPropertyValue("ReleaseNotes"); if (releaseNotes.Length == 0) { string file = entry.Addin.Properties.GetPropertyValue("ReleaseNotesFile"); if (file.Length > 0) { IAsyncResult res = entry.BeginDownloadSupportFile(file, null, null); res.AsyncWaitHandle.WaitOne(); try { using (Stream s = entry.EndDownloadSupportFile(res)) { StreamReader sr = new StreamReader(s); releaseNotes = sr.ReadToEnd(); } } catch (Exception ex) { LoggingService.LogError("Could not download release notes", ex); } } } if (releaseNotes.Length == 0) { yield break; } var addin = AddinManager.Registry.GetAddin(Addin.GetIdName(addinId)); string currentVersion = addin != null ? addin.Version : null; int i = releaseNotes.IndexOf("{{"); while (i != -1) { int j = releaseNotes.IndexOf("}}", i + 2); if (j == -1) { break; } string[] h = releaseNotes.Substring(i + 2, j - i - 2).Trim().Split(','); if (h.Length != 2) { break; } DateTime date; if (!DateTime.TryParse(h[1].Trim(), CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out date)) { break; } int k = releaseNotes.IndexOf("{{", j + 2); string version = h[0].Trim(); if (currentVersion == null || Addin.CompareVersions(currentVersion, version) > 0) { string txt = k != -1 ? releaseNotes.Substring(j + 2, k - j - 2) : releaseNotes.Substring(j + 2); yield return(new Release() { Version = version, Date = date, Notes = txt.Trim(' ', '\t', '\r', '\n') }); } i = k; } }
static IEnumerable<Release> ParseReleases (string addinId, AddinRepositoryEntry entry) { // Format of release notes is: // {{version1,date1}} release note text {{version2,date2}} release note text ... // Releases msyu // for example: // {{1.1,2011-01-10}} Release notes for 1.1 {{1.2,2011-03-22}} Release notes for 2.3 string releaseNotes = entry.Addin.Properties.GetPropertyValue ("ReleaseNotes"); if (releaseNotes.Length == 0) { string file = entry.Addin.Properties.GetPropertyValue ("ReleaseNotesFile"); if (file.Length > 0) { IAsyncResult res = entry.BeginDownloadSupportFile (file, null, null); res.AsyncWaitHandle.WaitOne (); try { using (Stream s = entry.EndDownloadSupportFile (res)) { StreamReader sr = new StreamReader (s); releaseNotes = sr.ReadToEnd (); } } catch (Exception ex) { LoggingService.LogError ("Could not download release notes", ex); } } } if (releaseNotes.Length == 0) yield break; var addin = AddinManager.Registry.GetAddin (Addin.GetIdName (addinId)); string currentVersion = addin != null ? addin.Version : null; int i = releaseNotes.IndexOf ("{{"); while (i != -1) { int j = releaseNotes.IndexOf ("}}", i + 2); if (j == -1) break; string[] h = releaseNotes.Substring (i + 2, j - i - 2).Trim ().Split (','); if (h.Length != 2) break; DateTime date; if (!DateTime.TryParse (h[1].Trim (), CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out date)) break; int k = releaseNotes.IndexOf ("{{", j + 2); string version = h[0].Trim (); if (currentVersion == null || Addin.CompareVersions (currentVersion, version) > 0) { string txt = k != -1 ? releaseNotes.Substring (j + 2, k - j - 2) : releaseNotes.Substring (j + 2); yield return new Release () { Version = version, Date = date, Notes = txt.Trim (' ','\t','\r','\n') }; } i = k; } }