From 23c7977d17466f2a566070851c80f4811f877195 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Fri, 27 Apr 2018 15:57:27 +0200 Subject: [PATCH] setting_helpers.h: add generic function for api keys --- src/system/setting_helpers.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/system/setting_helpers.h b/src/system/setting_helpers.h index 7150a2f2f..b1ec025b8 100644 --- a/src/system/setting_helpers.h +++ b/src/system/setting_helpers.h @@ -151,9 +151,13 @@ class CAutoModeNotifier : public CChangeObserver }; //do we need a class? -inline int check_shoutcast_dev_id() { return ((g_settings.shoutcast_dev_id != "XXXXXXXXXXXXXXXX") && !g_settings.shoutcast_dev_id.empty()); } -inline int check_youtube_dev_id() { return ((g_settings.youtube_dev_id != "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") && !g_settings.youtube_dev_id.empty()); } -inline int check_tmdb_api_key() { return ((g_settings.tmdb_api_key != "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") && !g_settings.tmdb_api_key.empty()); } -inline int check_omdb_api_key() { return ((g_settings.omdb_api_key != "XXXXXXXX") && !g_settings.omdb_api_key.empty()); } +int check_api_key(const std::string& api_key_setting, const std::string& api_key_pattern) +{ + return ((api_key_setting != api_key_pattern) && !api_key_setting.empty()); +} +inline int check_shoutcast_dev_id() { return check_api_key(g_settings.shoutcast_dev_id, "XXXXXXXXXXXXXXXX"); } +inline int check_youtube_dev_id() { return check_api_key(g_settings.youtube_dev_id, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } +inline int check_tmdb_api_key() { return check_api_key(g_settings.tmdb_api_key, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); } +inline int check_omdb_api_key() { return check_api_key(g_settings.omdb_api_key, "XXXXXXXX"); } #endif