12#include "c-api/general.h"
13#include "tools/StringUtils.h"
64 std::string& utf8StringDst,
65 bool failOnBadChar =
false)
67 using namespace kodi::addon;
70 char* retString = CPrivateBase::m_interface->toKodi->kodi->unknown_to_utf8(
71 CPrivateBase::m_interface->toKodi->kodiBase, stringSrc.c_str(), &ret, failOnBadChar);
72 if (retString !=
nullptr)
75 utf8StringDst = retString;
76 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
110 using namespace kodi::addon;
112 std::string language;
113 char* retString = CPrivateBase::m_interface->toKodi->kodi->get_language(
114 CPrivateBase::m_interface->toKodi->kodiBase, format, region);
115 if (retString !=
nullptr)
117 if (std::strlen(retString))
118 language = retString;
119 CPrivateBase::m_interface->toKodi->free_string(CPrivateBase::m_interface->toKodi->kodiBase,
204 using namespace kodi::addon;
207 va_start(args, format);
210 CPrivateBase::m_interface->toKodi->kodi->queue_notification(
211 CPrivateBase::m_interface->toKodi->kodiBase, type,
"", str.c_str(),
"", 5000,
false, 1000);
261 const std::string& header,
262 const std::string& message,
263 const std::string& imageFile =
"",
264 unsigned int displayTime = 5000,
265 bool withSound =
true,
266 unsigned int messageTime = 1000)
268 using namespace kodi::addon;
270 CPrivateBase::m_interface->toKodi->kodi->queue_notification(
271 CPrivateBase::m_interface->toKodi->kodiBase, type, header.c_str(), message.c_str(),
272 imageFile.c_str(), displayTime, withSound, messageTime);
295inline std::string ATTR_DLL_LOCAL
GetMD5(
const std::string& text)
297 using namespace kodi::addon;
299 char* md5ret =
static_cast<char*
>(malloc(40 *
sizeof(
char)));
300 CPrivateBase::m_interface->toKodi->kodi->get_md5(CPrivateBase::m_interface->toKodi->kodiBase,
301 text.c_str(), md5ret);
302 std::string md5 = md5ret;
331inline std::string ATTR_DLL_LOCAL
GetRegion(
const std::string&
id)
333 using namespace kodi::addon;
337 std::string strReturn;
338 char* strMsg = toKodi->kodi->get_region(toKodi->kodiBase,
id.c_str());
339 if (strMsg !=
nullptr)
341 if (std::strlen(strMsg))
343 toKodi->free_string(toKodi->kodiBase, strMsg);
372inline void ATTR_DLL_LOCAL
GetFreeMem(
long& free,
long& total,
bool asBytes =
false)
374 using namespace kodi::addon;
379 toKodi->kodi->get_free_mem(toKodi->kodiBase, &free, &total, asBytes);
402 using namespace kodi::addon;
405 return toKodi->kodi->get_global_idle_time(toKodi->kodiBase);
432 using namespace kodi::addon;
436 std::string strReturn;
437 char* strMsg = toKodi->kodi->get_current_skin_id(toKodi->kodiBase);
438 if (strMsg !=
nullptr)
440 if (std::strlen(strMsg))
442 toKodi->free_string(toKodi->kodiBase, strMsg);
472 std::string& version,
475 using namespace kodi::addon;
479 char* cVersion =
nullptr;
480 bool ret = toKodi->kodi->is_addon_avilable(toKodi->kodiBase,
id.c_str(), &cVersion, &enabled);
484 toKodi->free_string(toKodi->kodiBase, cVersion);
531 using namespace kodi::addon;
533 char* compile_name =
nullptr;
534 char* revision =
nullptr;
536 char* tag_revision =
nullptr;
539 toKodi->kodi->kodi_version(toKodi->kodiBase, &compile_name, &version.
major, &version.
minor,
540 &revision, &tag, &tag_revision);
541 if (compile_name !=
nullptr)
544 toKodi->free_string(toKodi->kodiBase, compile_name);
546 if (revision !=
nullptr)
549 toKodi->free_string(toKodi->kodiBase, revision);
554 toKodi->free_string(toKodi->kodiBase, tag);
556 if (tag_revision !=
nullptr)
559 toKodi->free_string(toKodi->kodiBase, tag_revision);
598 std::string& layout_name,
599 std::vector<std::vector<std::string>>& layout)
601 using namespace kodi::addon;
605 char* c_layout_name =
nullptr;
607 toKodi->kodi->get_keyboard_layout(toKodi->kodiBase, &c_layout_name, modifierKey, &c_layout);
612 layout_name = c_layout_name;
613 toKodi->free_string(toKodi->kodiBase, c_layout_name);
622 char* button = c_layout.keys[row][column];
625 layout[row][column] = button;
626 toKodi->free_string(toKodi->kodiBase, button);
671 using namespace kodi::addon;
674 char* c_layout_name =
nullptr;
675 bool ret = toKodi->kodi->change_keyboard_layout(toKodi->kodiBase, &c_layout_name);
678 layout_name = c_layout_name;
679 toKodi->free_string(toKodi->kodiBase, c_layout_name);
std::string tag_revision
The revision of tag before.
Definition General.h:34
std::string revision
The Revision contains a id and the build date, e.g. 20170706-c6b22fe217-dirty.
Definition General.h:30
int major
Major code version of Kodi.
Definition General.h:26
std::string tag
The version candidate e.g. alpha, beta or release.
Definition General.h:32
int minor
Minor code version of Kodi.
Definition General.h:28
std::string compile_name
Application name, normally 'Kodi'.
Definition General.h:24
LangFormats
Format codes to get string from them.
Definition general.h:62
QueueMsg
For kodi::QueueNotification() used message types.
Definition general.h:43
@ LANG_FMT_ENGLISH_NAME
full language name in English
Definition general.h:68
@ STD_KB_BUTTONS_PER_ROW
The quantity of buttons per row on Kodi's standard keyboard.
Definition general.h:26
@ STD_KB_BUTTONS_MAX_ROWS
The quantity of rows on Kodi's standard keyboard.
Definition general.h:28
For kodi::Version used structure.
Definition General.h:22
std::string ATTR_DLL_LOCAL GetMD5(const std::string &text)
Get the MD5 digest of the given text.
Definition General.h:295
bool ATTR_DLL_LOCAL UnknownToUTF8(const std::string &stringSrc, std::string &utf8StringDst, bool failOnBadChar=false)
Translate a string with an unknown encoding to UTF8.
Definition General.h:63
void ATTR_DLL_LOCAL KodiVersion(kodi_version_t &version)
Get current Kodi information and versions, returned data from the following kodi_version_t version; k...
Definition General.h:529
int ATTR_DLL_LOCAL GetGlobalIdleTime()
Returns the elapsed idle time in seconds as an integer.
Definition General.h:400
void ATTR_DLL_LOCAL 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:260
bool ATTR_DLL_LOCAL GetKeyboardLayout(int modifierKey, std::string &layout_name, std::vector< std::vector< std::string > > &layout)
To get keyboard layout characters.
Definition General.h:597
std::string ATTR_DLL_LOCAL GetCurrentSkinId()
Get the currently used skin identification name from Kodi.
Definition General.h:430
void ATTR_DLL_LOCAL GetFreeMem(long &free, long &total, bool asBytes=false)
Returns the amount of free memory in MByte (or as bytes) as an long integer.
Definition General.h:372
bool ATTR_DLL_LOCAL ChangeKeyboardLayout(std::string &layout_name)
To change keyboard layout characters.
Definition General.h:669
std::string ATTR_DLL_LOCAL GetRegion(const std::string &id)
Returns your regions setting as a string for the specified id.
Definition General.h:331
std::string ATTR_DLL_LOCAL GetLanguage(LangFormats format=LANG_FMT_ENGLISH_NAME, bool region=false)
Returns the active language as a string.
Definition General.h:107
bool ATTR_DLL_LOCAL IsAddonAvailable(const std::string &id, std::string &version, bool &enabled)
To check another addon is available and usable inside Kodi.
Definition General.h:471
void ATTR_DLL_LOCAL QueueFormattedNotification(QueueMsg type, const char *format,...)
Writes the C string pointed by format in the GUI. If format includes format specifiers (subsequences ...
Definition General.h:202
Callback function tables from addon to Kodi Set complete from Kodi!
Definition addon_base.h:326