Exemple #1
0
bool CAddonInstaller::Install(const std::string &addonID, bool force, const std::string &referer, bool background)
{
  AddonPtr addon;
  bool addonInstalled = CAddonMgr::Get().GetAddon(addonID, addon, ADDON_UNKNOWN, false);
  if (addonInstalled && !force)
    return true;

  if (referer.empty())
  {
    if (!g_passwordManager.CheckMenuLock(WINDOW_ADDON_BROWSER))
      return false;
  }

  // check whether we have it available in a repository
  CAddonDatabase database;
  database.Open();
  if (database.GetAddon(addonID, addon))
  {
    std::string repo;
    database.GetRepoForAddon(addonID,repo);
    AddonPtr ptr;
    CAddonMgr::Get().GetAddon(repo,ptr);
    RepositoryPtr therepo = boost::dynamic_pointer_cast<CRepository>(ptr);
    std::string hash;
    if (therepo)
      hash = therepo->GetAddonHash(addon);
    return DoInstall(addon, hash, addonInstalled, referer, background);
  }
  return false;
}
Exemple #2
0
bool CAddonInstallJob::GetAddonWithHash(const std::string& addonID, RepositoryPtr& repo,
    ADDON::AddonPtr& addon, std::string& hash)
{
  if (!CAddonMgr::GetInstance().FindInstallableById(addonID, addon))
    return false;

  AddonPtr tmp;
  if (!CAddonMgr::GetInstance().GetAddon(addon->Origin(), tmp, ADDON_REPOSITORY))
    return false;

  repo = std::static_pointer_cast<CRepository>(tmp);
  return repo->GetAddonHash(addon, hash);
}
Exemple #3
0
void CAddonInstaller::Install(const CStdString &addonID, bool force, const CStdString &referer, bool background)
{
  AddonPtr addon;
  bool addonInstalled = CAddonMgr::Get().GetAddon(addonID, addon);
  if (addonInstalled && !force)
    return;

  // check whether we have it available in a repository
  CAddonDatabase database;
  database.Open();
  if (database.GetAddon(addonID, addon))
  {
    CStdString repo;
    database.GetRepoForAddon(addonID,repo);
    AddonPtr ptr;
    CAddonMgr::Get().GetAddon(repo,ptr);
    RepositoryPtr therepo = boost::dynamic_pointer_cast<CRepository>(ptr);
    CStdString hash;
    if (therepo)
      hash = therepo->GetAddonHash(addon);

    // check whether we already have the addon installing
    CSingleLock lock(m_critSection);
    if (m_downloadJobs.find(addonID) != m_downloadJobs.end())
      return; // already installing this addon

    if (background)
    {
      unsigned int jobID = CJobManager::GetInstance().AddJob(new CAddonInstallJob(addon, hash, addonInstalled, referer), this);
      m_downloadJobs.insert(make_pair(addon->ID(), CDownloadJob(jobID)));
    }
    else
    {
      m_downloadJobs.insert(make_pair(addon->ID(), CDownloadJob(0)));
      lock.Leave();
      CAddonInstallJob job(addon, hash, addonInstalled, referer);
      if (!job.DoWork())
      { // TODO: dump something to debug log?
      }
      lock.Enter();
      JobMap::iterator i = m_downloadJobs.find(addon->ID());
      m_downloadJobs.erase(i);
    }
  }
}
Exemple #4
0
bool CAddonInstallJob::GetAddonWithHash(const std::string& addonID, ADDON::AddonPtr& addon, std::string& hash)
{
  CAddonDatabase database;
  if (!database.Open())
    return false;

  if (!database.GetAddon(addonID, addon))
    return false;

  AddonPtr ptr = GetRepoForAddon(addon);
  if (ptr == NULL)
    return false;

  RepositoryPtr repo = std::dynamic_pointer_cast<CRepository>(ptr);
  if (repo == NULL)
    return false;

  hash = repo->GetAddonHash(addon);
  return true;
}
Exemple #5
0
bool CAddonInstaller::Install(const CStdString &addonID, bool force, const CStdString &referer, bool background)
{
  AddonPtr addon;
  bool addonInstalled = CAddonMgr::Get().GetAddon(addonID, addon, ADDON_UNKNOWN, false);
  if (addonInstalled && !force)
    return true;

  // check whether we have it available in a repository
  CAddonDatabase database;
  database.Open();
  if (database.GetAddon(addonID, addon))
  {
    CStdString repo;
    database.GetRepoForAddon(addonID,repo);
    AddonPtr ptr;
    CAddonMgr::Get().GetAddon(repo,ptr);
    RepositoryPtr therepo = boost::dynamic_pointer_cast<CRepository>(ptr);
    CStdString hash;
    if (therepo)
      hash = therepo->GetAddonHash(addon);
    return DoInstall(addon, hash, addonInstalled, referer, background);
  }
  return false;
}