public GetCachedRepository ( ) : Mono.Addins.Setup.Repository | ||
return | Mono.Addins.Setup.Repository |
void GetRepositoryTree(string url, ArrayList list) { RepositoryRecord rr = FindRepositoryRecord(url); if (rr == null) { return; } if (list.Contains(rr)) { return; } list.Add(rr); Repository rep = rr.GetCachedRepository(); if (rep == null) { return; } Uri absUri = new Uri(url); foreach (ReferenceRepositoryEntry re in rep.Repositories) { Uri refRepUri = new Uri(absUri, re.Url); GetRepositoryTree(refRepUri.ToString(), list); } }
/// <summary> /// Subscribes to an on-line repository /// </summary> /// <param name="monitor"> /// Progress monitor where to show progress status and log /// </param> /// <param name="url"> /// URL of the repository /// </param> /// <param name="updateNow"> /// When set to True, the repository index will be downloaded. /// </param> /// <returns> /// A repository reference /// </returns> public AddinRepository RegisterRepository(IProgressStatus monitor, string url, bool updateNow) { if (string.IsNullOrEmpty(url)) { throw new ArgumentException("Emtpy url"); } if (!url.EndsWith(".mrep")) { if (url [url.Length - 1] != '/') { url += "/"; } url = url + "main.mrep"; } RepositoryRecord rr = FindRepositoryRecord(url); if (rr != null) { return(rr); } rr = RegisterRepository(url, false); try { if (updateNow) { UpdateRepository(monitor, url); rr = FindRepositoryRecord(url); Repository rep = rr.GetCachedRepository(); if (rep != null) { rr.Name = rep.Name; } } service.SaveConfiguration(); return(rr); } catch (Exception ex) { if (monitor != null) { monitor.ReportError("The repository could not be registered", ex); } if (ContainsRepository(url)) { RemoveRepository(url); } return(null); } }
/// <summary> /// Removes an on-line repository subscription. /// </summary> /// <param name="url"> /// URL of the repository. /// </param> public void RemoveRepository(string url) { RepositoryRecord rep = FindRepositoryRecord(url); if (rep == null) { return; // Nothing to do } foreach (RepositoryRecord rr in service.Configuration.Repositories) { if (rr == rep) { continue; } Repository newRep = rr.GetCachedRepository(); if (newRep == null) { continue; } foreach (ReferenceRepositoryEntry re in newRep.Repositories) { if (re.Url == url) { // The repository can't be removed because there is another // repository depending on it. Just mark it as a reference. rep.IsReference = true; return; } } } // There are no other repositories referencing this one, so we can safely delete Repository delRep = rep.GetCachedRepository(); service.Configuration.Repositories.Remove(rep); rep.ClearCachedRepository(); if (delRep != null) { foreach (ReferenceRepositoryEntry re in delRep.Repositories) { RemoveRepository(new Uri(new Uri(url), re.Url).ToString()); } } service.SaveConfiguration(); repoList = null; }
public void RemoveRepository(string url) { RepositoryRecord rep = FindRepositoryRecord(url); if (rep == null) { throw new InstallException("The repository at url '" + url + "' is not registered"); } foreach (RepositoryRecord rr in service.Configuration.Repositories) { if (rr == rep) { continue; } Repository newRep = rr.GetCachedRepository(); if (newRep == null) { continue; } foreach (ReferenceRepositoryEntry re in newRep.Repositories) { if (re.Url == url) { rep.IsReference = true; return; } } } // There are no other repositories referencing this one, so we can safely delete Repository delRep = rep.GetCachedRepository(); service.Configuration.Repositories.Remove(rep); rep.ClearCachedRepository(); if (delRep != null) { foreach (ReferenceRepositoryEntry re in delRep.Repositories) { RemoveRepository(new Uri(new Uri(url), re.Url).ToString()); } } service.SaveConfiguration(); repoList = null; }
/// <summary> /// Enables or disables a repository /// </summary> /// <param name='url'> /// URL of the repository /// </param> /// <param name='enabled'> /// 'true' if the repository has to be enabled. /// </param> /// <remarks> /// Disabled repositories are ignored when calling UpdateAllRepositories. /// </remarks> public void SetRepositoryEnabled(string url, bool enabled) { RepositoryRecord rep = FindRepositoryRecord(url); if (rep == null) { return; // Nothing to do } rep.Enabled = enabled; Repository crep = rep.GetCachedRepository(); if (crep != null) { foreach (RepositoryEntry re in crep.Repositories) { SetRepositoryEnabled(new Uri(new Uri(url), re.Url).ToString(), enabled); } } service.SaveConfiguration(); }
public AddinRepository RegisterRepository(IProgressStatus monitor, string url, bool updateNow) { if (!url.EndsWith(".mrep")) { url = url + "/main.mrep"; } RepositoryRecord rr = FindRepositoryRecord(url); if (rr != null) { return(rr); } rr = RegisterRepository(url, false); try { if (updateNow) { UpdateRepository(monitor, url); rr = FindRepositoryRecord(url); Repository rep = rr.GetCachedRepository(); rr.Name = rep.Name; } service.SaveConfiguration(); return(rr); } catch (Exception ex) { if (monitor != null) { monitor.ReportError("The repository could not be registered", ex); } if (ContainsRepository(url)) { RemoveRepository(url); } return(null); } }