Ejemplo n.º 1
0
    Addon::Addon(const char* cid, bool installed) throw (AddonException)
    {
      String id(cid ? cid : emptyString);

      // if the id wasn't passed then get the id from
      //   the global dictionary
      if (id.empty())
        id = getDefaultId();

      // if we still don't have an id then bail
      if (id.empty())
        throw AddonException("No valid addon id could be obtained. None was passed and the script wasn't executed in a normal xbmc manner.");

      bool success = ADDON::CAddonMgr::Get().GetAddon(id.c_str(), pAddon);
      if (!success && !installed)
      {
        CAddonDatabase addondb;
        addondb.Open();
        success = addondb.GetAddon(id, pAddon);
      }

      // if we still fail we MAY be able to recover.
      if (!success)
      {
        // we need to check the version prior to trying a bw compatibility trick
        ADDON::AddonVersion version(getAddonVersion());
        ADDON::AddonVersion allowable("1.0");

        if (version <= allowable)
        {
          // try the default ...
          id = getDefaultId();

          if (id.empty() || !ADDON::CAddonMgr::Get().GetAddon(id.c_str(), pAddon))
            throw AddonException("Could not get AddonPtr!");
          else
            CLog::Log(LOGERROR,"Use of deprecated functionality. Please to not assume that \"os.getcwd\" will return the script directory.");
        }
        else
        {
          throw AddonException("Could not get AddonPtr given a script id of %s."
                               "If you are trying to use 'os.getcwd' to set the path, you cannot do that in a version %s plugin.",
                               id.c_str(), version.asString().c_str());
        }
      }

      CAddonMgr::Get().AddToUpdateableAddons(pAddon);
    }
Ejemplo n.º 2
0
 String Addon::getAddonInfo(const char* id) throw (AddonException)
 {
   if (strcmpi(id, "author") == 0)
     return pAddon->Author();
   else if (strcmpi(id, "changelog") == 0)
     return pAddon->ChangeLog();
   else if (strcmpi(id, "description") == 0)
     return pAddon->Description();
   else if (strcmpi(id, "disclaimer") == 0)
     return pAddon->Disclaimer();
   else if (strcmpi(id, "fanart") == 0)
     return pAddon->FanArt();
   else if (strcmpi(id, "icon") == 0)
     return pAddon->Icon();
   else if (strcmpi(id, "id") == 0)
     return pAddon->ID();
   else if (strcmpi(id, "name") == 0)
     return pAddon->Name();
   else if (strcmpi(id, "path") == 0)
     return pAddon->Path();
   else if (strcmpi(id, "profile") == 0)
     return pAddon->Profile();
   else if (strcmpi(id, "stars") == 0)
   {
     return StringUtils::Format("%d", pAddon->Stars());
   }
   else if (strcmpi(id, "summary") == 0)
     return pAddon->Summary();
   else if (strcmpi(id, "type") == 0)
     return ADDON::TranslateType(pAddon->Type());
   else if (strcmpi(id, "version") == 0)
     return pAddon->Version().asString();
   else
     throw AddonException("'%s' is an invalid Id", id);
 }
Ejemplo n.º 3
0
    Addon::Addon(const char* cid) throw (AddonException)
    {
      String id(cid ? cid : emptyString);

      // if the id wasn't passed then get the id from
      //   the global dictionary
      if (id.empty())
        id = getDefaultId();

      // if we still don't have an id then bail
      if (id.empty())
        throw AddonException("No valid addon id could be obtained. None was passed and the script wasn't executed in a normal xbmc manner.");

      if (!ADDON::CAddonMgr::Get().GetAddon(id.c_str(), pAddon))
        throw AddonException("Unknown addon id '%s'.", id.c_str());

      CAddonMgr::Get().AddToUpdateableAddons(pAddon);
    }
Ejemplo n.º 4
0
 String Addon::getAddonInfo(const char* id) throw (AddonException)
 {
   if (strcmpi(id, "author") == 0)
     return pAddon->Author();
   else if (strcmpi(id, "changelog") == 0)
     return pAddon->ChangeLog();
   else if (strcmpi(id, "description") == 0)
     return pAddon->Description();
   else if (strcmpi(id, "disclaimer") == 0)
     return pAddon->Disclaimer();
   else if (strcmpi(id, "fanart") == 0)
     return pAddon->FanArt();
   else if (strcmpi(id, "icon") == 0)
     return pAddon->Icon();
   else if (strcmpi(id, "id") == 0)
     return pAddon->ID();
   else if (strcmpi(id, "name") == 0)
     return pAddon->Name();
   else if (strcmpi(id, "path") == 0)
     return pAddon->Path();
   else if (strcmpi(id, "profile") == 0)
     return pAddon->Profile();
   else if (strcmpi(id, "stars") == 0)
   {
     return StringUtils::Format("%d", pAddon->Stars());
   }
   else if (strcmpi(id, "summary") == 0)
     return pAddon->Summary();
   else if (strcmpi(id, "type") == 0)
     return ADDON::TranslateType(pAddon->Type());
   else if (strcmpi(id, "version") == 0)
     return pAddon->Version().asString();
   else if (strcmpi(id, "platforms") == 0)
   {
     InfoMap::const_iterator it;
     if ((it = pAddon->Props().extrainfo.find("platforms")) != pAddon->Props().extrainfo.end())
       return String(it->second.c_str());
     else
       return String();
   }
   else if (strcmpi(id, "extensions") == 0)
   {
     InfoMap::const_iterator it;
     if ((it = pAddon->Props().extrainfo.find("extensions")) != pAddon->Props().extrainfo.end())
       return String(it->second.c_str());
     else
       return String();
   }
   else
     throw AddonException("'%s' is an invalid Id", id);
 }