Functions to manage the addon and get basic information about it
These are e.g. GetCapabilities to know supported groups at this addon or the others to get information about the source of the PVR stream.
The with "Valid implementation required." declared functions are mandatory, all others are an option.
Basic parts in interface:
Copy this to your project and extend with your parts or leave functions complete away where not used or supported.
Header parts:
Definition: General.h:116
virtual PVR_ERROR GetBackendHostname(std::string &hostname)
Get the hostname of the pvr backend server.
Definition: PVR.h:629
virtual PVR_ERROR GetBackendVersion(std::string &version)=0
Get the version string reported by the backend that will be displayed in the UI.
virtual PVR_ERROR CallSettingsMenuHook(const kodi::addon::PVRMenuhook &menuhook)
Call one of the settings related menu hooks (if supported).
Definition: PVR.h:700
virtual PVR_ERROR GetConnectionString(std::string &connection)
To get the connection string reported by the backend that will be displayed in the UI.
Definition: PVR.h:640
virtual PVR_ERROR GetDriveSpace(uint64_t &total, uint64_t &used)
Get the disk space reported by the backend (if supported).
Definition: PVR.h:667
virtual PVR_ERROR GetCapabilities(kodi::addon::PVRCapabilities &capabilities)=0
Get the list of features that this add-on provides.
virtual PVR_ERROR GetBackendName(std::string &name)=0
Get the name reported by the backend that will be displayed in the UI.
PVR_ERROR
Definition: pvr_general.h:35
Source parts:
{
}
PVR_ERROR CMyInstance::GetBackendName(std::string& name)
{
}
PVR_ERROR CMyInstance::GetBackendVersion(std::string& version)
{
}
PVR_ERROR CMyInstance::GetBackendHostname(std::string& hostname)
{
}
PVR_ERROR CMyInstance::GetConnectionString(std::string& connection)
{
}
PVR_ERROR CMyInstance::GetDriveSpace(uint64_t& total, uint64_t& used)
{
}
{
}
@ PVR_ERROR_NOT_IMPLEMENTED
-2 : The method that Kodi called is not implemented by the add-on.
Definition: pvr_general.h:43
◆ CInstancePVRClient() [1/2]
PVR client class constructor.
Used by an add-on that only supports only PVR and only in one instance.
Here's example about the use of this:
#include <kodi/addon-instance/PVR.h>
...
class ATTRIBUTE_HIDDEN CPVRExample
{
public:
CPVRExample()
{
}
~CPVRExample() override;
{
}
...
};
ADDONCREATOR(CPVRExample)
Definition: AddonBase.h:322
◆ CInstancePVRClient() [2/2]
PVR client class constructor used to support multiple instance types.
- Parameters
-
[in] | instance | The instance value given to kodi::addon::CAddonBase::CreateInstance(...) . |
[in] | kodiVersion | [opt] Version used in Kodi for this instance, to allow compatibility to older Kodi versions. |
- Note
- Recommended to set
kodiVersion
.
Here's example about the use of this:
{
public:
CMyPVRClient(KODI_HANDLE instance, const std::string& kodiVersion)
{
...
}
...
};
const std::string& instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance)
{
addonInstance = new CMyPVRClient(instance, version);
}
@ ADDON_LOG_INFO
1 : To include information messages in the log file.
Definition: addon_base.h:177
ADDON_STATUS
Definition: addon_base.h:128
@ ADDON_STATUS_OK
For everything OK and no error.
Definition: addon_base.h:130
CInstancePVRClient()
PVR client class constructor.
Definition: PVR.h:465
void ATTRIBUTE_HIDDEN Log(const AddonLog loglevel, const char *format,...)
Add a message to Kodi's log.
Definition: AddonBase.h:749
◆ ~CInstancePVRClient()
◆ GetCapabilities()
Get the list of features that this add-on provides.
Called by Kodi to query the add-on's capabilities. Used to check which options should be presented in the UI, which methods to call, etc. All capabilities that the add-on supports should be set to true.
- Parameters
-
- Returns
- PVR_ERROR_NO_ERROR if the properties were fetched successfully.
The following table contains values that can be set with class PVRCapabilities :
- Warning
- This class can not be used outside of kodi::addon::CInstancePVRClient::GetCapabilities()
Example:
{
}
@ PVR_ERROR_NO_ERROR
0 : No error occurred.
Definition: pvr_general.h:37
void SetSupportsTV(bool supportsTV)
Set true if this add-on provides TV channels.
Definition: General.h:175
void SetSupportsEPG(bool supportsEPG)
Set true if the add-on provides EPG information.
Definition: General.h:162
- Note
- Valid implementation required.
◆ GetBackendName()
virtual PVR_ERROR GetBackendName |
( |
std::string & |
name | ) |
|
|
pure virtual |
Get the name reported by the backend that will be displayed in the UI.
- Parameters
-
[out] | name | The name reported by the backend that will be displayed in the UI. |
- Returns
- PVR_ERROR_NO_ERROR if successfully done
Example:
PVR_ERROR CMyPVRClient::GetBackendName(std::string& name)
{
name = "My special PVR client";
}
- Note
- Valid implementation required.
◆ GetBackendVersion()
virtual PVR_ERROR GetBackendVersion |
( |
std::string & |
version | ) |
|
|
pure virtual |
Get the version string reported by the backend that will be displayed in the UI.
- Parameters
-
[out] | version | The version string reported by the backend that will be displayed in the UI. |
- Returns
- PVR_ERROR_NO_ERROR if successfully done
Example:
PVR_ERROR CMyPVRClient::GetBackendVersion(std::string& version)
{
version = "1.0.0";
}
- Note
- Valid implementation required.
◆ GetBackendHostname()
virtual PVR_ERROR GetBackendHostname |
( |
std::string & |
hostname | ) |
|
|
inlinevirtual |
Get the hostname of the pvr backend server.
- Parameters
-
[out] | hostname | Hostname as ip address or alias. If backend does not utilize a server, return empty string. |
- Returns
- PVR_ERROR_NO_ERROR if successfully done
◆ GetConnectionString()
virtual PVR_ERROR GetConnectionString |
( |
std::string & |
connection | ) |
|
|
inlinevirtual |
To get the connection string reported by the backend that will be displayed in the UI.
- Parameters
-
[out] | connection | The connection string reported by the backend that will be displayed in the UI. |
- Returns
- PVR_ERROR_NO_ERROR if successfully done
◆ GetDriveSpace()
virtual PVR_ERROR GetDriveSpace |
( |
uint64_t & |
total, |
|
|
uint64_t & |
used |
|
) |
| |
|
inlinevirtual |
Get the disk space reported by the backend (if supported).
- Parameters
-
[in] | total | The total disk space in KiB. |
[in] | used | The used disk space in KiB. |
- Returns
- PVR_ERROR_NO_ERROR if the drive space has been fetched successfully.
Example:
PVR_ERROR CMyPVRClient::GetDriveSpace(uint64_t& total, uint64_t& used)
{
total = 100 * 1024 * 1024;
used = 12232424;
}
◆ CallSettingsMenuHook()
Call one of the settings related menu hooks (if supported).
Supported menu hook instances have to be added in constructor()
, by calling AddMenuHook() on the callback.
- Parameters
-
[in] | menuhook | The hook to call. |
- Returns
- PVR_ERROR_NO_ERROR if the hook was called successfully.
The following table contains values that can be set with class PVRMenuhook :
Example:
{
}
@ QUEUE_INFO
Show info notification message.
Definition: general.h:45
std::string ATTRIBUTE_HIDDEN GetLocalizedString(uint32_t labelId, const std::string &defaultStr="")
Returns an addon's localized 'unicode string'.
Definition: General.h:137
void ATTRIBUTE_HIDDEN QueueNotification(QueueMsg type, const std::string &header, const std::string &message, const std::string &imageFile="", unsigned int displayTime=5000, bool withSound=true, unsigned int messageTime=1000)
Queue a notification in the GUI.
Definition: General.h:374
◆ AddMenuHook()
Callback to Kodi Function\nAdd or replace a menu hook for the context menu for this add-on
This is a callback function, called from addon to give Kodi his context menu's.
- Parameters
-
The following table contains values that can be set with class PVRMenuhook :
Here's an example of the use of it:
#include <kodi/addon-instance/PVR.h>
...
{
}
{
}
...
void AddMenuHook(const kodi::addon::PVRMenuhook &hook)
Callback to Kodi Function\nAdd or replace a menu hook for the context menu for this add-on
Definition: PVR.h:755
Here another way:
#include <kodi/addon-instance/PVR.h>
...
...
◆ ConnectionStateChange()
void ConnectionStateChange |
( |
const std::string & |
connectionString, |
|
|
PVR_CONNECTION_STATE |
newState, |
|
|
const std::string & |
message |
|
) |
| |
|
inline |
Callback to Kodi Function
Notify a state change for a PVR backend connection.
- Parameters
-
[in] | connectionString | The connection string reported by the backend that can be displayed in the UI. |
[in] | newState | The by PVR_CONNECTION_STATE defined new state. |
[in] | message | A localized addon-defined string representing the new state, that can be displayed in the UI or empty if the Kodi-defined default string for the new state shall be displayed. |
Here's an example of the use of it:
#include <kodi/addon-instance/PVR.h>
#include <kodi/General.h>
◆ UserPath()
std::string UserPath |
( |
| ) |
const |
|
inline |
Callback to Kodi Function
Get user data path of the PVR addon.
- Returns
- Path of current Kodi user
- Note
- Alternatively, kodi::GetAddonPath() can be used for this.
◆ ClientPath()
std::string ClientPath |
( |
| ) |
const |
|
inline |
Callback to Kodi Function
Get main client path of the PVR addon.
- Returns
- Path of addon client
- Note
- Alternatively, kodi::GetBaseUserPath() can be used for this.