Skip to content

Commit

Permalink
pvr: check version of addongui lib
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta committed Mar 1, 2013
1 parent b9a99cf commit 6a7e831
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions xbmc/addons/include/xbmc_pvr_types.h
Expand Up @@ -294,6 +294,8 @@ extern "C" {
{
const char* (__cdecl* GetPVRAPIVersion)(void);
const char* (__cdecl* GetMininumPVRAPIVersion)(void);
const char* (__cdecl* GetGUIAPIVersion)(void);
const char* (__cdecl* GetMininumGUIAPIVersion)(void);
PVR_ERROR (__cdecl* GetAddonCapabilities)(PVR_ADDON_CAPABILITIES*);
PVR_ERROR (__cdecl* GetStreamProperties)(PVR_STREAM_PROPERTIES*);
const char* (__cdecl* GetBackendName)(void);
Expand Down
19 changes: 19 additions & 0 deletions xbmc/pvr/addons/PVRClient.cpp
Expand Up @@ -257,6 +257,13 @@ bool CPVRClient::IsCompatibleAPIVersion(const ADDON::AddonVersion &minVersion, c
return (version >= myMinVersion && minVersion <= myVersion);
}

bool CPVRClient::IsCompatibleGUIAPIVersion(const ADDON::AddonVersion &minVersion, const ADDON::AddonVersion &version)
{
AddonVersion myMinVersion = AddonVersion(XBMC_GUI_MIN_API_VERSION);
AddonVersion myVersion = AddonVersion(XBMC_GUI_API_VERSION);
return (version >= myMinVersion && minVersion <= myVersion);
}

bool CPVRClient::CheckAPIVersion(void)
{
/* check the API version */
Expand All @@ -270,6 +277,18 @@ bool CPVRClient::CheckAPIVersion(void)
return false;
}

/* check the GUI API version */
AddonVersion guiVersion = AddonVersion("0.0.0");
minVersion = AddonVersion(XBMC_GUI_MIN_API_VERSION);
try { guiVersion = AddonVersion(m_pStruct->GetGUIAPIVersion()); }
catch (exception &e) { LogException(e, "GetGUIAPIVersion()"); return false; }

if (!IsCompatibleGUIAPIVersion(minVersion, guiVersion))
{
CLog::Log(LOGERROR, "PVR - Add-on '%s' is using an incompatible GUI API version. XBMC minimum GUI API version = '%s', add-on GUI API version '%s'", Name().c_str(), minVersion.c_str(), guiVersion.c_str());
return false;
}

return true;
}

Expand Down
8 changes: 8 additions & 0 deletions xbmc/pvr/addons/PVRClient.h
Expand Up @@ -511,6 +511,14 @@ namespace PVR
*/
static bool IsCompatibleAPIVersion(const ADDON::AddonVersion &minVersion, const ADDON::AddonVersion &version);

/*!
* @brief Checks whether the provided GUI API version is compatible with XBMC
* @param minVersion The add-on's XBMC_GUI_MIN_API_VERSION version
* @param version The add-on's XBMC_GUI_API_VERSION version
* @return True when compatible, false otherwise
*/
static bool IsCompatibleGUIAPIVersion(const ADDON::AddonVersion &minVersion, const ADDON::AddonVersion &version);

/*!
* @brief Request the API version from the add-on, and check if it's compatible
* @return True when compatible, false otherwise.
Expand Down

0 comments on commit 6a7e831

Please sign in to comment.