Kodi Development  19.0
for Binary and Script based Add-Ons
class CAddonBase

Detailed Description

Modules

 Definitions, structures and enumerators
 General definition values
 

Enumeration Type Documentation

◆ ADDON_STATUS

Return value of functions in kodi::addon::CAddonBase and associated classes.

Enumerator
ADDON_STATUS_OK 

For everything OK and no error.

ADDON_STATUS_LOST_CONNECTION 

A needed connection was lost.

ADDON_STATUS_NEED_RESTART 

Addon needs a restart inside Kodi.

ADDON_STATUS_NEED_SETTINGS 

Necessary settings are not yet set.

ADDON_STATUS_UNKNOWN 

Unknown and incomprehensible error.

ADDON_STATUS_PERMANENT_FAILURE 

Permanent failure, like failing to resolve methods.

◆ ADDON_TYPE

enum ADDON_TYPE

The currently available instance types for Kodi add-ons

Enumerator
ADDON_INSTANCE_AUDIODECODER 

Audio decoder instance, see kodi::addon::CInstanceAudioDecoder.

ADDON_INSTANCE_AUDIOENCODER 

Audio encoder instance, see kodi::addon::CInstanceAudioEncoder.

ADDON_INSTANCE_GAME 

Game instance, see kodi::addon::CInstanceGame.

ADDON_INSTANCE_INPUTSTREAM 

Input stream instance, see kodi::addon::CInstanceInputStream.

ADDON_INSTANCE_PERIPHERAL 

Peripheral instance, see kodi::addon::CInstancePeripheral.

ADDON_INSTANCE_PVR 

Game instance, see kodi::addon::CInstancePVRClient.

ADDON_INSTANCE_SCREENSAVER 

PVR client instance, see kodi::addon::CInstanceScreensaver.

ADDON_INSTANCE_VISUALIZATION 

Music visualization instance, see kodi::addon::CInstanceVisualization.

ADDON_INSTANCE_VFS 

Virtual Filesystem (VFS) instance, see kodi::addon::CInstanceVFS.

ADDON_INSTANCE_IMAGEDECODER 

Image Decoder instance, see kodi::addon::CInstanceImageDecoder.

ADDON_INSTANCE_VIDEOCODEC 

Video Decoder instance, see kodi::addon::CInstanceVideoCodec.

Function Documentation

◆ SetSetting()

virtual ADDON_STATUS SetSetting ( const std::string &  settingName,
const kodi::CSettingValue settingValue 
)
inlinevirtual

To inform addon about changed settings values.

This becomes called for every entry defined inside his settings.xml and as last call the one where last in xml (to identify end of calls).


The following table contains values that can be set with class CSettingValue :

Name Type Get call
Settings value as string std::string GetString
Settings value as integer int GetInt
Settings value as unsigned integer unsigned int GetUInt
Settings value as boolean bool GetBoolean
Settings value as floating point float GetFloat
Settings value as enum enum GetEnum

Here is a code example how this is used:

#include <kodi/AddonBase.h>
enum myEnumValue
{
valueA,
valueB,
valueC
};
std::string m_myStringValue;
int m_myIntegerValue;
bool m_myBooleanValue;
float m_myFloatingPointValue;
myEnumValue m_myEnumValue;
ADDON_STATUS CMyAddon::SetSetting(const std::string& settingName, const kodi::CSettingValue& settingValue)
{
if (settingName == "my_string_value")
m_myStringValue = settingValue.GetString();
else if (settingName == "my_integer_value")
m_myIntegerValue = settingValue.GetInt();
else if (settingName == "my_boolean_value")
m_myBooleanValue = settingValue.GetBoolean();
else if (settingName == "my_float_value")
m_myFloatingPointValue = settingValue.GetFloat();
else if (settingName == "my_enum_value")
m_myEnumValue = settingValue.GetEnum<myEnumValue>();
}
Note
The asked type should match the type used on settings.xml.

◆ CreateInstance()

virtual ADDON_STATUS CreateInstance ( int  instanceType,
const std::string &  instanceID,
KODI_HANDLE  instance,
const std::string &  version,
KODI_HANDLE &  addonInstance 
)
inlinevirtual

Instance created.

Parameters
[in]instanceTypeThe requested type of required instance, see ADDON_TYPE.
[in]instanceIDAn individual identification key string given by Kodi.
[in]instanceThe instance handler used by Kodi must be passed to the classes created here. See in the example.
[in]versionThe from Kodi used version of instance. This can be used to allow compatibility to older versions of them. Further is this given to the parent instance that it can handle differences.
[out]addonInstanceThe pointer to instance class created in addon. Needed to be able to identify them on calls.
Returns
ADDON_STATUS_OK if correct, for possible errors see ADDON_STATUS

Here is a code example how this is used:

#include <kodi/AddonBase.h>
...
/* If you use only one instance in your add-on, can be instanceType and
* instanceID ignored *&zwj;/
ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
const std::string& instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance)
{
if (instanceType == ADDON_INSTANCE_SCREENSAVER)
{
kodi::Log(ADDON_LOG_INFO, "Creating my Screensaver");
addonInstance = new CMyScreensaver(instance);
return ADDON_STATUS_OK;
}
else if (instanceType == ADDON_INSTANCE_VISUALIZATION)
{
kodi::Log(ADDON_LOG_INFO, "Creating my Visualization");
addonInstance = new CMyVisualization(instance);
return ADDON_STATUS_OK;
}
else if (...)
{
...
}
return ADDON_STATUS_UNKNOWN;
}
...

◆ DestroyInstance()

virtual void DestroyInstance ( int  instanceType,
const std::string &  instanceID,
KODI_HANDLE  addonInstance 
)
inlinevirtual

Instance destroy.

This function is optional and intended to notify addon that the instance is terminating.

Parameters
[in]instanceTypeThe requested type of required instance, see ADDON_TYPE.
[in]instanceIDAn individual identification key string given by Kodi.
[in]addonInstanceThe pointer to instance class created in addon.
Warning
This call is only used to inform that the associated instance is terminated. The deletion is carried out in the background.
kodi::CSettingValue::GetInt
int GetInt() const
To get settings value as integer.
Definition: AddonBase.h:144
kodi::CSettingValue::GetFloat
float GetFloat() const
To get settings value as floating point.
Definition: AddonBase.h:153
kodi::CSettingValue::GetEnum
enumType GetEnum() const
To get settings value as enum.
Definition: AddonBase.h:158
kodi::CSettingValue::GetString
std::string GetString() const
To get settings value as string.
Definition: AddonBase.h:141
kodi::CSettingValue
Definition: AddonBase.h:118
kodi::CSettingValue::GetBoolean
bool GetBoolean() const
To get settings value as boolean.
Definition: AddonBase.h:150
ADDON_STATUS
ADDON_STATUS
Return value of functions in kodi::addon::CAddonBase and associated classes.
Definition: addon_base.h:80