Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[addons] change binary callbacks #12596

Merged
merged 2 commits into from
Sep 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions xbmc/addons/interfaces/General.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#ifdef TARGET_POSIX
#include "linux/XMemUtils.h"
#endif
#include "settings/Settings.h"
#include "utils/CharsetConverter.h"
#include "utils/log.h"
#include "utils/LangCodeExpander.h"
Expand Down Expand Up @@ -64,6 +65,7 @@ void Interface_General::Init(AddonGlobalInterface* addonInterface)
addonInterface->toKodi->kodi->get_region = get_region;
addonInterface->toKodi->kodi->get_free_mem = get_free_mem;
addonInterface->toKodi->kodi->get_global_idle_time = get_global_idle_time;
addonInterface->toKodi->kodi->get_current_skin_id = get_current_skin_id;
addonInterface->toKodi->kodi->kodi_version = kodi_version;
}

Expand Down Expand Up @@ -144,7 +146,7 @@ bool Interface_General::open_settings_dialog(void* kodiBase)
return CGUIDialogAddonSettings::ShowForAddon(addonInfo);
}

char* Interface_General::get_localized_string(void* kodiBase, long dwCode)
char* Interface_General::get_localized_string(void* kodiBase, long label_id)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
if (!addon)
Expand All @@ -156,13 +158,10 @@ char* Interface_General::get_localized_string(void* kodiBase, long dwCode)
if (g_application.m_bStop)
return nullptr;

std::string string;
if ((dwCode >= 30000 && dwCode <= 30999) || (dwCode >= 32000 && dwCode <= 32999))
string = g_localizeStrings.GetAddonString(addon->ID(), dwCode).c_str();
else
string = g_localizeStrings.Get(dwCode).c_str();

char* buffer = strdup(string.c_str());
std::string label = g_localizeStrings.GetAddonString(addon->ID(), label_id);
if (label.empty())
label = g_localizeStrings.Get(label_id);
char* buffer = strdup(label.c_str());
return buffer;
}

Expand Down Expand Up @@ -413,6 +412,18 @@ int Interface_General::get_global_idle_time(void* kodiBase)
return g_application.GlobalIdleTime();
}

char* Interface_General::get_current_skin_id(void* kodiBase)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
if (addon == nullptr)
{
CLog::Log(LOGERROR, "Interface_General::%s - invalid data (addon='%p')", __FUNCTION__, addon);
return nullptr;
}

return strdup(CServiceBroker::GetSettings().GetString(CSettings::SETTING_LOOKANDFEEL_SKIN).c_str());

This comment was marked as spam.

This comment was marked as spam.

}

void Interface_General::kodi_version(void* kodiBase, char** compile_name, int* major, int* minor, char** revision, char** tag, char** tagversion)
{
CAddonDll* addon = static_cast<CAddonDll*>(kodiBase);
Expand Down
3 changes: 2 additions & 1 deletion xbmc/addons/interfaces/General.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace ADDON
//@{
static char* get_addon_info(void* kodiBase, const char* id);
static bool open_settings_dialog(void* kodiBase);
static char* get_localized_string(void* kodiBase, long dwCode);
static char* get_localized_string(void* kodiBase, long label_id);
static char* unknown_to_utf8(void* kodiBase, const char* source, bool* ret, bool failOnBadChar);
static char* get_language(void* kodiBase, int format, bool region);
static bool queue_notification(void* kodiBase, int type, const char* header, const char* message, const char* imageFile, unsigned int displayTime, bool withSound, unsigned int messageTime);
Expand All @@ -62,6 +62,7 @@ namespace ADDON
static char* get_region(void* kodiBase, const char* id);
static void get_free_mem(void* kodiInstance, long* free, long* total, bool as_bytes);
static int get_global_idle_time(void* kodiBase);
static char* get_current_skin_id(void* kodiBase);
static void kodi_version(void* kodiBase, char** compile_name, int* major, int* minor, char** revision, char** tag, char** tagversion);
//@}
};
Expand Down
44 changes: 43 additions & 1 deletion xbmc/addons/kodi-addon-dev-kit/include/kodi/General.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typedef struct AddonToKodiFuncTable_kodi
char* (*get_addon_info)(void* kodiBase, const char* id);
bool (*open_settings_dialog)(void* kodiBase);
char* (*unknown_to_utf8)(void* kodiBase, const char* source, bool* ret, bool failOnBadChar);
char* (*get_localized_string)(void* kodiBase, long dwCode);
char* (*get_localized_string)(void* kodiBase, long label_id);
char* (*get_language)(void* kodiBase, int format, bool region);
bool (*queue_notification)(void* kodiBase, int type, const char* header, const char* message, const char* imageFile, unsigned int displayTime, bool withSound, unsigned int messageTime);
void (*get_md5)(void* kodiBase, const char* text, char* md5);
Expand All @@ -46,6 +46,7 @@ typedef struct AddonToKodiFuncTable_kodi
void (*get_free_mem)(void* kodiBase, long* free, long* total, bool as_bytes);
int (*get_global_idle_time)(void* kodiBase);
void (*kodi_version)(void* kodiBase, char** compile_name, int* major, int* minor, char** revision, char** tag, char** tagversion);
char* (*get_current_skin_id)(void* kodiBase);
} AddonToKodiFuncTable_kodi;

//==============================================================================
Expand Down Expand Up @@ -619,6 +620,47 @@ inline int GetGlobalIdleTime()
} /* namespace kodi */
//------------------------------------------------------------------------------

//==============================================================================
namespace kodi {
///
/// \ingroup cpp_kodi
/// @brief Get the currently used skin identification name from Kodi
///-----------------------------------------------------------------------
///
/// @return The active skin id name as a string
///
///
/// @note This is not the full path like 'special://home/addons/MediaCenter',
/// but only 'MediaCenter'.
///
///
/// ------------------------------------------------------------------------
///
/// **Example:**
/// ~~~~~~~~~~~~~{.cpp}
/// #include <kodi/General.h>
/// ..
/// std::string skinid = kodi::GetCurrentSkinId();
/// ..
/// ~~~~~~~~~~~~~
///
inline std::string GetCurrentSkinId()
{
AddonToKodiFuncTable_Addon* toKodi = ::kodi::addon::CAddonBase::m_interface->toKodi;

std::string strReturn;
char* strMsg = toKodi->kodi->get_current_skin_id(toKodi->kodiBase);
if (strMsg != nullptr)
{
if (std::strlen(strMsg))
strReturn = strMsg;
toKodi->free_string(toKodi->kodiBase, strMsg);
}
return strReturn;
}
} /* namespace kodi */
//------------------------------------------------------------------------------

//==============================================================================
namespace kodi {
///
Expand Down
2 changes: 1 addition & 1 deletion xbmc/addons/kodi-addon-dev-kit/include/kodi/versions.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"libXBMC_addon.h" \
"addon-instance/"

#define ADDON_GLOBAL_VERSION_GENERAL "1.0.2"
#define ADDON_GLOBAL_VERSION_GENERAL "1.0.3"
#define ADDON_GLOBAL_VERSION_GENERAL_MIN "1.0.2"
#define ADDON_GLOBAL_VERSION_GENERAL_XML_ID "kodi.binary.global.general"
#define ADDON_GLOBAL_VERSION_GENERAL_DEPENDS "General.h"
Expand Down