diff --git a/components/spotify/cspot/bell/main/io/URLParser.cpp b/components/spotify/cspot/bell/main/io/URLParser.cpp index e26d28e8..55fd21c5 100644 --- a/components/spotify/cspot/bell/main/io/URLParser.cpp +++ b/components/spotify/cspot/bell/main/io/URLParser.cpp @@ -6,18 +6,20 @@ namespace bell { void URLParser::parse(const char* url, std::vector& match) { match[0] = url; char scratch[512]; + + /* Parsing the following (http|https://[host][/path][?query]#hash] as in regex + * below. This needs to be changed if you update that regex */ - // get schema [http(s)]:// + // get the schema if (sscanf(url, "%[^:]:/", scratch) > 0) match[1] = scratch; - // get host http(s)://[host] - if (sscanf(url, "htt%*[^:]://%512[^/#]", scratch) > 0) match[2] = scratch; + // get the host + if (sscanf(url, "htt%*[^:]://%512[^/#?]", scratch) > 0) match[2] = scratch; // get the path - url = strstr(url, match[2].c_str()); - if (!url || *url == '\0') return; - url += match[2].size(); + url = strstr(url, match[2].c_str()) + match[2].size(); if (sscanf(url, "/%512[^?]", scratch) > 0) match[3] = scratch; + else if (*url && *url != '?' && *url != '#') url++; // get the query if (match[3].size()) url += match[3].size() + 1; @@ -30,6 +32,9 @@ void URLParser::parse(const char* url, std::vector& match) { // fix the acquired items match[3] = "/" + match[3]; if (match[4].size()) match[4] = "?" + match[4]; + + // need at least schema and host + if (match[1].size() == 0 || match[2].size() == 0) match.clear(); } #else const std::regex URLParser::urlParseRegex = std::regex( diff --git a/components/spotify/cspot/bell/main/io/include/HTTPClient.h b/components/spotify/cspot/bell/main/io/include/HTTPClient.h index 31dc3a7c..7ce164d9 100644 --- a/components/spotify/cspot/bell/main/io/include/HTTPClient.h +++ b/components/spotify/cspot/bell/main/io/include/HTTPClient.h @@ -34,7 +34,7 @@ class HTTPClient { #ifndef BELL_DISABLE_FMT return ValueHeader{"Range", fmt::format("bytes={}-{}", from, to)}; #else - return ValueHeader{"Range", "bytes=" + std::to_string(from) + "-" + std::to_string(to) }; + return ValueHeader{"Range", "bytes=" + std::to_string(from) + "-" + std::to_string(to)}; #endif } diff --git a/components/spotify/cspot/protobuf/authentication.pb.c b/components/spotify/cspot/protobuf/authentication.pb.c new file mode 100644 index 00000000..3e9fd652 --- /dev/null +++ b/components/spotify/cspot/protobuf/authentication.pb.c @@ -0,0 +1,21 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.6-dev */ + +#include "protobuf/authentication.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(SystemInfo, SystemInfo, 2) + + +PB_BIND(LoginCredentials, LoginCredentials, 2) + + +PB_BIND(ClientResponseEncrypted, ClientResponseEncrypted, 2) + + + + + + diff --git a/components/spotify/cspot/protobuf/authentication.pb.h b/components/spotify/cspot/protobuf/authentication.pb.h new file mode 100644 index 00000000..e3eb8e91 --- /dev/null +++ b/components/spotify/cspot/protobuf/authentication.pb.h @@ -0,0 +1,164 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.6-dev */ + +#ifndef PB_PROTOBUF_AUTHENTICATION_PB_H_INCLUDED +#define PB_PROTOBUF_AUTHENTICATION_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Enum definitions */ +typedef enum _CpuFamily { + CpuFamily_CPU_UNKNOWN = 0, + CpuFamily_CPU_X86 = 1, + CpuFamily_CPU_X86_64 = 2, + CpuFamily_CPU_PPC = 3, + CpuFamily_CPU_PPC_64 = 4, + CpuFamily_CPU_ARM = 5, + CpuFamily_CPU_IA64 = 6, + CpuFamily_CPU_SH = 7, + CpuFamily_CPU_MIPS = 8, + CpuFamily_CPU_BLACKFIN = 9 +} CpuFamily; + +typedef enum _Os { + Os_OS_UNKNOWN = 0, + Os_OS_WINDOWS = 1, + Os_OS_OSX = 2, + Os_OS_IPHONE = 3, + Os_OS_S60 = 4, + Os_OS_LINUX = 5, + Os_OS_WINDOWS_CE = 6, + Os_OS_ANDROID = 7, + Os_OS_PALM = 8, + Os_OS_FREEBSD = 9, + Os_OS_BLACKBERRY = 10, + Os_OS_SONOS = 11, + Os_OS_LOGITECH = 12, + Os_OS_WP7 = 13, + Os_OS_ONKYO = 14, + Os_OS_PHILIPS = 15, + Os_OS_WD = 16, + Os_OS_VOLVO = 17, + Os_OS_TIVO = 18, + Os_OS_AWOX = 19, + Os_OS_MEEGO = 20, + Os_OS_QNXNTO = 21, + Os_OS_BCO = 22 +} Os; + +typedef enum _AuthenticationType { + AuthenticationType_AUTHENTICATION_USER_PASS = 0, + AuthenticationType_AUTHENTICATION_STORED_SPOTIFY_CREDENTIALS = 1, + AuthenticationType_AUTHENTICATION_STORED_FACEBOOK_CREDENTIALS = 2, + AuthenticationType_AUTHENTICATION_SPOTIFY_TOKEN = 3, + AuthenticationType_AUTHENTICATION_FACEBOOK_TOKEN = 4 +} AuthenticationType; + +/* Struct definitions */ +typedef PB_BYTES_ARRAY_T(512) LoginCredentials_auth_data_t; +typedef struct _LoginCredentials { + char username[30]; + AuthenticationType typ; + LoginCredentials_auth_data_t auth_data; +} LoginCredentials; + +typedef struct _SystemInfo { + CpuFamily cpu_family; + Os os; + char system_information_string[16]; + char device_id[50]; +} SystemInfo; + +typedef struct _ClientResponseEncrypted { + LoginCredentials login_credentials; + SystemInfo system_info; + bool has_version_string; + char version_string[32]; +} ClientResponseEncrypted; + + +/* Helper constants for enums */ +#define _CpuFamily_MIN CpuFamily_CPU_UNKNOWN +#define _CpuFamily_MAX CpuFamily_CPU_BLACKFIN +#define _CpuFamily_ARRAYSIZE ((CpuFamily)(CpuFamily_CPU_BLACKFIN+1)) + +#define _Os_MIN Os_OS_UNKNOWN +#define _Os_MAX Os_OS_BCO +#define _Os_ARRAYSIZE ((Os)(Os_OS_BCO+1)) + +#define _AuthenticationType_MIN AuthenticationType_AUTHENTICATION_USER_PASS +#define _AuthenticationType_MAX AuthenticationType_AUTHENTICATION_FACEBOOK_TOKEN +#define _AuthenticationType_ARRAYSIZE ((AuthenticationType)(AuthenticationType_AUTHENTICATION_FACEBOOK_TOKEN+1)) + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define SystemInfo_init_default {_CpuFamily_MIN, _Os_MIN, "", ""} +#define LoginCredentials_init_default {"", _AuthenticationType_MIN, {0, {0}}} +#define ClientResponseEncrypted_init_default {LoginCredentials_init_default, SystemInfo_init_default, false, ""} +#define SystemInfo_init_zero {_CpuFamily_MIN, _Os_MIN, "", ""} +#define LoginCredentials_init_zero {"", _AuthenticationType_MIN, {0, {0}}} +#define ClientResponseEncrypted_init_zero {LoginCredentials_init_zero, SystemInfo_init_zero, false, ""} + +/* Field tags (for use in manual encoding/decoding) */ +#define LoginCredentials_username_tag 10 +#define LoginCredentials_typ_tag 20 +#define LoginCredentials_auth_data_tag 30 +#define SystemInfo_cpu_family_tag 10 +#define SystemInfo_os_tag 60 +#define SystemInfo_system_information_string_tag 90 +#define SystemInfo_device_id_tag 100 +#define ClientResponseEncrypted_login_credentials_tag 10 +#define ClientResponseEncrypted_system_info_tag 50 +#define ClientResponseEncrypted_version_string_tag 70 + +/* Struct field encoding specification for nanopb */ +#define SystemInfo_FIELDLIST(X, a) \ +X(a, STATIC, REQUIRED, UENUM, cpu_family, 10) \ +X(a, STATIC, REQUIRED, UENUM, os, 60) \ +X(a, STATIC, REQUIRED, STRING, system_information_string, 90) \ +X(a, STATIC, REQUIRED, STRING, device_id, 100) +#define SystemInfo_CALLBACK NULL +#define SystemInfo_DEFAULT NULL + +#define LoginCredentials_FIELDLIST(X, a) \ +X(a, STATIC, REQUIRED, STRING, username, 10) \ +X(a, STATIC, REQUIRED, UENUM, typ, 20) \ +X(a, STATIC, REQUIRED, BYTES, auth_data, 30) +#define LoginCredentials_CALLBACK NULL +#define LoginCredentials_DEFAULT NULL + +#define ClientResponseEncrypted_FIELDLIST(X, a) \ +X(a, STATIC, REQUIRED, MESSAGE, login_credentials, 10) \ +X(a, STATIC, REQUIRED, MESSAGE, system_info, 50) \ +X(a, STATIC, OPTIONAL, STRING, version_string, 70) +#define ClientResponseEncrypted_CALLBACK NULL +#define ClientResponseEncrypted_DEFAULT NULL +#define ClientResponseEncrypted_login_credentials_MSGTYPE LoginCredentials +#define ClientResponseEncrypted_system_info_MSGTYPE SystemInfo + +extern const pb_msgdesc_t SystemInfo_msg; +extern const pb_msgdesc_t LoginCredentials_msg; +extern const pb_msgdesc_t ClientResponseEncrypted_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define SystemInfo_fields &SystemInfo_msg +#define LoginCredentials_fields &LoginCredentials_msg +#define ClientResponseEncrypted_fields &ClientResponseEncrypted_msg + +/* Maximum encoded size of messages (where known) */ +#define ClientResponseEncrypted_size 665 +#define LoginCredentials_size 550 +#define SystemInfo_size 75 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/components/spotify/cspot/protobuf/keyexchange.pb.c b/components/spotify/cspot/protobuf/keyexchange.pb.c new file mode 100644 index 00000000..2393c22f --- /dev/null +++ b/components/spotify/cspot/protobuf/keyexchange.pb.c @@ -0,0 +1,54 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.6-dev */ + +#include "protobuf/keyexchange.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(LoginCryptoDiffieHellmanChallenge, LoginCryptoDiffieHellmanChallenge, AUTO) + + +PB_BIND(LoginCryptoChallengeUnion, LoginCryptoChallengeUnion, AUTO) + + +PB_BIND(LoginCryptoDiffieHellmanHello, LoginCryptoDiffieHellmanHello, AUTO) + + +PB_BIND(LoginCryptoHelloUnion, LoginCryptoHelloUnion, AUTO) + + +PB_BIND(BuildInfo, BuildInfo, AUTO) + + +PB_BIND(FeatureSet, FeatureSet, AUTO) + + +PB_BIND(APChallenge, APChallenge, AUTO) + + +PB_BIND(APResponseMessage, APResponseMessage, AUTO) + + +PB_BIND(LoginCryptoDiffieHellmanResponse, LoginCryptoDiffieHellmanResponse, AUTO) + + +PB_BIND(LoginCryptoResponseUnion, LoginCryptoResponseUnion, AUTO) + + +PB_BIND(CryptoResponseUnion, CryptoResponseUnion, AUTO) + + +PB_BIND(PoWResponseUnion, PoWResponseUnion, AUTO) + + +PB_BIND(ClientResponsePlaintext, ClientResponsePlaintext, AUTO) + + +PB_BIND(ClientHello, ClientHello, 2) + + + + + + diff --git a/components/spotify/cspot/protobuf/keyexchange.pb.h b/components/spotify/cspot/protobuf/keyexchange.pb.h new file mode 100644 index 00000000..fb88ed76 --- /dev/null +++ b/components/spotify/cspot/protobuf/keyexchange.pb.h @@ -0,0 +1,343 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.6-dev */ + +#ifndef PB_PROTOBUF_KEYEXCHANGE_PB_H_INCLUDED +#define PB_PROTOBUF_KEYEXCHANGE_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Enum definitions */ +typedef enum _Product { + Product_PRODUCT_CLIENT = 0, + Product_PRODUCT_LIBSPOTIFY = 1, + Product_PRODUCT_MOBILE = 2, + Product_PRODUCT_PARTNER = 3, + Product_PRODUCT_LIBSPOTIFY_EMBEDDED = 5 +} Product; + +typedef enum _Platform2 { + Platform2_PLATFORM_WIN32_X86 = 0, + Platform2_PLATFORM_OSX_X86 = 1, + Platform2_PLATFORM_LINUX_X86 = 2, + Platform2_PLATFORM_IPHONE_ARM = 3, + Platform2_PLATFORM_S60_ARM = 4, + Platform2_PLATFORM_OSX_PPC = 5, + Platform2_PLATFORM_ANDROID_ARM = 6, + Platform2_PLATFORM_WINDOWS_CE_ARM = 7, + Platform2_PLATFORM_LINUX_X86_64 = 8, + Platform2_PLATFORM_OSX_X86_64 = 9, + Platform2_PLATFORM_PALM_ARM = 10, + Platform2_PLATFORM_LINUX_SH = 11, + Platform2_PLATFORM_FREEBSD_X86 = 12, + Platform2_PLATFORM_FREEBSD_X86_64 = 13, + Platform2_PLATFORM_BLACKBERRY_ARM = 14, + Platform2_PLATFORM_SONOS = 15, + Platform2_PLATFORM_LINUX_MIPS = 16, + Platform2_PLATFORM_LINUX_ARM = 17, + Platform2_PLATFORM_LOGITECH_ARM = 18, + Platform2_PLATFORM_LINUX_BLACKFIN = 19, + Platform2_PLATFORM_WP7_ARM = 20, + Platform2_PLATFORM_ONKYO_ARM = 21, + Platform2_PLATFORM_QNXNTO_ARM = 22, + Platform2_PLATFORM_BCO_ARM = 23 +} Platform2; + +typedef enum _Cryptosuite { + Cryptosuite_CRYPTO_SUITE_SHANNON = 0, + Cryptosuite_CRYPTO_SUITE_RC4_SHA1_HMAC = 1 +} Cryptosuite; + +/* Struct definitions */ +typedef struct _CryptoResponseUnion { + char dummy_field; +} CryptoResponseUnion; + +typedef struct _PoWResponseUnion { + char dummy_field; +} PoWResponseUnion; + +typedef struct _BuildInfo { + Product product; + Platform2 platform; + uint64_t version; +} BuildInfo; + +typedef struct _FeatureSet { + bool has_autoupdate2; + bool autoupdate2; +} FeatureSet; + +typedef struct _LoginCryptoDiffieHellmanChallenge { + pb_byte_t gs[96]; +} LoginCryptoDiffieHellmanChallenge; + +typedef struct _LoginCryptoDiffieHellmanHello { + pb_byte_t gc[96]; + uint32_t server_keys_known; +} LoginCryptoDiffieHellmanHello; + +typedef struct _LoginCryptoDiffieHellmanResponse { + pb_byte_t hmac[20]; +} LoginCryptoDiffieHellmanResponse; + +typedef struct _LoginCryptoChallengeUnion { + bool has_diffie_hellman; + LoginCryptoDiffieHellmanChallenge diffie_hellman; +} LoginCryptoChallengeUnion; + +typedef struct _LoginCryptoHelloUnion { + bool has_diffie_hellman; + LoginCryptoDiffieHellmanHello diffie_hellman; +} LoginCryptoHelloUnion; + +typedef struct _LoginCryptoResponseUnion { + bool has_diffie_hellman; + LoginCryptoDiffieHellmanResponse diffie_hellman; +} LoginCryptoResponseUnion; + +typedef struct _APChallenge { + LoginCryptoChallengeUnion login_crypto_challenge; +} APChallenge; + +typedef struct _ClientHello { + BuildInfo build_info; + Cryptosuite cryptosuites_supported[1]; + LoginCryptoHelloUnion login_crypto_hello; + pb_byte_t client_nonce[16]; + bool has_padding; + pb_byte_t padding[1]; + bool has_feature_set; + FeatureSet feature_set; +} ClientHello; + +typedef struct _ClientResponsePlaintext { + LoginCryptoResponseUnion login_crypto_response; + PoWResponseUnion pow_response; + CryptoResponseUnion crypto_response; +} ClientResponsePlaintext; + +typedef struct _APResponseMessage { + bool has_challenge; + APChallenge challenge; +} APResponseMessage; + + +/* Helper constants for enums */ +#define _Product_MIN Product_PRODUCT_CLIENT +#define _Product_MAX Product_PRODUCT_LIBSPOTIFY_EMBEDDED +#define _Product_ARRAYSIZE ((Product)(Product_PRODUCT_LIBSPOTIFY_EMBEDDED+1)) + +#define _Platform2_MIN Platform2_PLATFORM_WIN32_X86 +#define _Platform2_MAX Platform2_PLATFORM_BCO_ARM +#define _Platform2_ARRAYSIZE ((Platform2)(Platform2_PLATFORM_BCO_ARM+1)) + +#define _Cryptosuite_MIN Cryptosuite_CRYPTO_SUITE_SHANNON +#define _Cryptosuite_MAX Cryptosuite_CRYPTO_SUITE_RC4_SHA1_HMAC +#define _Cryptosuite_ARRAYSIZE ((Cryptosuite)(Cryptosuite_CRYPTO_SUITE_RC4_SHA1_HMAC+1)) + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define LoginCryptoDiffieHellmanChallenge_init_default {{0}} +#define LoginCryptoChallengeUnion_init_default {false, LoginCryptoDiffieHellmanChallenge_init_default} +#define LoginCryptoDiffieHellmanHello_init_default {{0}, 0} +#define LoginCryptoHelloUnion_init_default {false, LoginCryptoDiffieHellmanHello_init_default} +#define BuildInfo_init_default {_Product_MIN, _Platform2_MIN, 0} +#define FeatureSet_init_default {false, 0} +#define APChallenge_init_default {LoginCryptoChallengeUnion_init_default} +#define APResponseMessage_init_default {false, APChallenge_init_default} +#define LoginCryptoDiffieHellmanResponse_init_default {{0}} +#define LoginCryptoResponseUnion_init_default {false, LoginCryptoDiffieHellmanResponse_init_default} +#define CryptoResponseUnion_init_default {0} +#define PoWResponseUnion_init_default {0} +#define ClientResponsePlaintext_init_default {LoginCryptoResponseUnion_init_default, PoWResponseUnion_init_default, CryptoResponseUnion_init_default} +#define ClientHello_init_default {BuildInfo_init_default, {_Cryptosuite_MIN}, LoginCryptoHelloUnion_init_default, {0}, false, {0}, false, FeatureSet_init_default} +#define LoginCryptoDiffieHellmanChallenge_init_zero {{0}} +#define LoginCryptoChallengeUnion_init_zero {false, LoginCryptoDiffieHellmanChallenge_init_zero} +#define LoginCryptoDiffieHellmanHello_init_zero {{0}, 0} +#define LoginCryptoHelloUnion_init_zero {false, LoginCryptoDiffieHellmanHello_init_zero} +#define BuildInfo_init_zero {_Product_MIN, _Platform2_MIN, 0} +#define FeatureSet_init_zero {false, 0} +#define APChallenge_init_zero {LoginCryptoChallengeUnion_init_zero} +#define APResponseMessage_init_zero {false, APChallenge_init_zero} +#define LoginCryptoDiffieHellmanResponse_init_zero {{0}} +#define LoginCryptoResponseUnion_init_zero {false, LoginCryptoDiffieHellmanResponse_init_zero} +#define CryptoResponseUnion_init_zero {0} +#define PoWResponseUnion_init_zero {0} +#define ClientResponsePlaintext_init_zero {LoginCryptoResponseUnion_init_zero, PoWResponseUnion_init_zero, CryptoResponseUnion_init_zero} +#define ClientHello_init_zero {BuildInfo_init_zero, {_Cryptosuite_MIN}, LoginCryptoHelloUnion_init_zero, {0}, false, {0}, false, FeatureSet_init_zero} + +/* Field tags (for use in manual encoding/decoding) */ +#define BuildInfo_product_tag 10 +#define BuildInfo_platform_tag 30 +#define BuildInfo_version_tag 40 +#define FeatureSet_autoupdate2_tag 1 +#define LoginCryptoDiffieHellmanChallenge_gs_tag 10 +#define LoginCryptoDiffieHellmanHello_gc_tag 10 +#define LoginCryptoDiffieHellmanHello_server_keys_known_tag 20 +#define LoginCryptoDiffieHellmanResponse_hmac_tag 10 +#define LoginCryptoChallengeUnion_diffie_hellman_tag 10 +#define LoginCryptoHelloUnion_diffie_hellman_tag 10 +#define LoginCryptoResponseUnion_diffie_hellman_tag 10 +#define APChallenge_login_crypto_challenge_tag 10 +#define ClientHello_build_info_tag 10 +#define ClientHello_cryptosuites_supported_tag 30 +#define ClientHello_login_crypto_hello_tag 50 +#define ClientHello_client_nonce_tag 60 +#define ClientHello_padding_tag 70 +#define ClientHello_feature_set_tag 80 +#define ClientResponsePlaintext_login_crypto_response_tag 10 +#define ClientResponsePlaintext_pow_response_tag 20 +#define ClientResponsePlaintext_crypto_response_tag 30 +#define APResponseMessage_challenge_tag 10 + +/* Struct field encoding specification for nanopb */ +#define LoginCryptoDiffieHellmanChallenge_FIELDLIST(X, a) \ +X(a, STATIC, REQUIRED, FIXED_LENGTH_BYTES, gs, 10) +#define LoginCryptoDiffieHellmanChallenge_CALLBACK NULL +#define LoginCryptoDiffieHellmanChallenge_DEFAULT NULL + +#define LoginCryptoChallengeUnion_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, diffie_hellman, 10) +#define LoginCryptoChallengeUnion_CALLBACK NULL +#define LoginCryptoChallengeUnion_DEFAULT NULL +#define LoginCryptoChallengeUnion_diffie_hellman_MSGTYPE LoginCryptoDiffieHellmanChallenge + +#define LoginCryptoDiffieHellmanHello_FIELDLIST(X, a) \ +X(a, STATIC, REQUIRED, FIXED_LENGTH_BYTES, gc, 10) \ +X(a, STATIC, REQUIRED, UINT32, server_keys_known, 20) +#define LoginCryptoDiffieHellmanHello_CALLBACK NULL +#define LoginCryptoDiffieHellmanHello_DEFAULT NULL + +#define LoginCryptoHelloUnion_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, diffie_hellman, 10) +#define LoginCryptoHelloUnion_CALLBACK NULL +#define LoginCryptoHelloUnion_DEFAULT NULL +#define LoginCryptoHelloUnion_diffie_hellman_MSGTYPE LoginCryptoDiffieHellmanHello + +#define BuildInfo_FIELDLIST(X, a) \ +X(a, STATIC, REQUIRED, UENUM, product, 10) \ +X(a, STATIC, REQUIRED, UENUM, platform, 30) \ +X(a, STATIC, REQUIRED, UINT64, version, 40) +#define BuildInfo_CALLBACK NULL +#define BuildInfo_DEFAULT NULL + +#define FeatureSet_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, BOOL, autoupdate2, 1) +#define FeatureSet_CALLBACK NULL +#define FeatureSet_DEFAULT NULL + +#define APChallenge_FIELDLIST(X, a) \ +X(a, STATIC, REQUIRED, MESSAGE, login_crypto_challenge, 10) +#define APChallenge_CALLBACK NULL +#define APChallenge_DEFAULT NULL +#define APChallenge_login_crypto_challenge_MSGTYPE LoginCryptoChallengeUnion + +#define APResponseMessage_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, challenge, 10) +#define APResponseMessage_CALLBACK NULL +#define APResponseMessage_DEFAULT NULL +#define APResponseMessage_challenge_MSGTYPE APChallenge + +#define LoginCryptoDiffieHellmanResponse_FIELDLIST(X, a) \ +X(a, STATIC, REQUIRED, FIXED_LENGTH_BYTES, hmac, 10) +#define LoginCryptoDiffieHellmanResponse_CALLBACK NULL +#define LoginCryptoDiffieHellmanResponse_DEFAULT NULL + +#define LoginCryptoResponseUnion_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, MESSAGE, diffie_hellman, 10) +#define LoginCryptoResponseUnion_CALLBACK NULL +#define LoginCryptoResponseUnion_DEFAULT NULL +#define LoginCryptoResponseUnion_diffie_hellman_MSGTYPE LoginCryptoDiffieHellmanResponse + +#define CryptoResponseUnion_FIELDLIST(X, a) \ + +#define CryptoResponseUnion_CALLBACK NULL +#define CryptoResponseUnion_DEFAULT NULL + +#define PoWResponseUnion_FIELDLIST(X, a) \ + +#define PoWResponseUnion_CALLBACK NULL +#define PoWResponseUnion_DEFAULT NULL + +#define ClientResponsePlaintext_FIELDLIST(X, a) \ +X(a, STATIC, REQUIRED, MESSAGE, login_crypto_response, 10) \ +X(a, STATIC, REQUIRED, MESSAGE, pow_response, 20) \ +X(a, STATIC, REQUIRED, MESSAGE, crypto_response, 30) +#define ClientResponsePlaintext_CALLBACK NULL +#define ClientResponsePlaintext_DEFAULT NULL +#define ClientResponsePlaintext_login_crypto_response_MSGTYPE LoginCryptoResponseUnion +#define ClientResponsePlaintext_pow_response_MSGTYPE PoWResponseUnion +#define ClientResponsePlaintext_crypto_response_MSGTYPE CryptoResponseUnion + +#define ClientHello_FIELDLIST(X, a) \ +X(a, STATIC, REQUIRED, MESSAGE, build_info, 10) \ +X(a, STATIC, FIXARRAY, UENUM, cryptosuites_supported, 30) \ +X(a, STATIC, REQUIRED, MESSAGE, login_crypto_hello, 50) \ +X(a, STATIC, REQUIRED, FIXED_LENGTH_BYTES, client_nonce, 60) \ +X(a, STATIC, OPTIONAL, FIXED_LENGTH_BYTES, padding, 70) \ +X(a, STATIC, OPTIONAL, MESSAGE, feature_set, 80) +#define ClientHello_CALLBACK NULL +#define ClientHello_DEFAULT NULL +#define ClientHello_build_info_MSGTYPE BuildInfo +#define ClientHello_login_crypto_hello_MSGTYPE LoginCryptoHelloUnion +#define ClientHello_feature_set_MSGTYPE FeatureSet + +extern const pb_msgdesc_t LoginCryptoDiffieHellmanChallenge_msg; +extern const pb_msgdesc_t LoginCryptoChallengeUnion_msg; +extern const pb_msgdesc_t LoginCryptoDiffieHellmanHello_msg; +extern const pb_msgdesc_t LoginCryptoHelloUnion_msg; +extern const pb_msgdesc_t BuildInfo_msg; +extern const pb_msgdesc_t FeatureSet_msg; +extern const pb_msgdesc_t APChallenge_msg; +extern const pb_msgdesc_t APResponseMessage_msg; +extern const pb_msgdesc_t LoginCryptoDiffieHellmanResponse_msg; +extern const pb_msgdesc_t LoginCryptoResponseUnion_msg; +extern const pb_msgdesc_t CryptoResponseUnion_msg; +extern const pb_msgdesc_t PoWResponseUnion_msg; +extern const pb_msgdesc_t ClientResponsePlaintext_msg; +extern const pb_msgdesc_t ClientHello_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define LoginCryptoDiffieHellmanChallenge_fields &LoginCryptoDiffieHellmanChallenge_msg +#define LoginCryptoChallengeUnion_fields &LoginCryptoChallengeUnion_msg +#define LoginCryptoDiffieHellmanHello_fields &LoginCryptoDiffieHellmanHello_msg +#define LoginCryptoHelloUnion_fields &LoginCryptoHelloUnion_msg +#define BuildInfo_fields &BuildInfo_msg +#define FeatureSet_fields &FeatureSet_msg +#define APChallenge_fields &APChallenge_msg +#define APResponseMessage_fields &APResponseMessage_msg +#define LoginCryptoDiffieHellmanResponse_fields &LoginCryptoDiffieHellmanResponse_msg +#define LoginCryptoResponseUnion_fields &LoginCryptoResponseUnion_msg +#define CryptoResponseUnion_fields &CryptoResponseUnion_msg +#define PoWResponseUnion_fields &PoWResponseUnion_msg +#define ClientResponsePlaintext_fields &ClientResponsePlaintext_msg +#define ClientHello_fields &ClientHello_msg + +/* Maximum encoded size of messages (where known) */ +#define APChallenge_size 102 +#define APResponseMessage_size 104 +#define BuildInfo_size 17 +#define ClientHello_size 161 +#define ClientResponsePlaintext_size 32 +#define CryptoResponseUnion_size 0 +#define FeatureSet_size 2 +#define LoginCryptoChallengeUnion_size 100 +#define LoginCryptoDiffieHellmanChallenge_size 98 +#define LoginCryptoDiffieHellmanHello_size 105 +#define LoginCryptoDiffieHellmanResponse_size 22 +#define LoginCryptoHelloUnion_size 107 +#define LoginCryptoResponseUnion_size 24 +#define PoWResponseUnion_size 0 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/components/spotify/cspot/protobuf/mercury.pb.c b/components/spotify/cspot/protobuf/mercury.pb.c new file mode 100644 index 00000000..d8e8dc94 --- /dev/null +++ b/components/spotify/cspot/protobuf/mercury.pb.c @@ -0,0 +1,12 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.6-dev */ + +#include "protobuf/mercury.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(Header, Header, 2) + + + diff --git a/components/spotify/cspot/protobuf/mercury.pb.h b/components/spotify/cspot/protobuf/mercury.pb.h new file mode 100644 index 00000000..18767b6d --- /dev/null +++ b/components/spotify/cspot/protobuf/mercury.pb.h @@ -0,0 +1,52 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.6-dev */ + +#ifndef PB_PROTOBUF_MERCURY_PB_H_INCLUDED +#define PB_PROTOBUF_MERCURY_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Struct definitions */ +typedef struct _Header { + bool has_uri; + char uri[256]; + bool has_method; + char method[64]; +} Header; + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define Header_init_default {false, "", false, ""} +#define Header_init_zero {false, "", false, ""} + +/* Field tags (for use in manual encoding/decoding) */ +#define Header_uri_tag 1 +#define Header_method_tag 3 + +/* Struct field encoding specification for nanopb */ +#define Header_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, STRING, uri, 1) \ +X(a, STATIC, OPTIONAL, STRING, method, 3) +#define Header_CALLBACK NULL +#define Header_DEFAULT NULL + +extern const pb_msgdesc_t Header_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define Header_fields &Header_msg + +/* Maximum encoded size of messages (where known) */ +#define Header_size 323 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/components/spotify/cspot/protobuf/metadata.pb.c b/components/spotify/cspot/protobuf/metadata.pb.c new file mode 100644 index 00000000..7196e0cf --- /dev/null +++ b/components/spotify/cspot/protobuf/metadata.pb.c @@ -0,0 +1,34 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.6-dev */ + +#include "protobuf/metadata.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(AudioFile, AudioFile, AUTO) + + +PB_BIND(Restriction, Restriction, AUTO) + + +PB_BIND(Image, Image, AUTO) + + +PB_BIND(ImageGroup, ImageGroup, AUTO) + + +PB_BIND(Album, Album, AUTO) + + +PB_BIND(Artist, Artist, AUTO) + + +PB_BIND(Track, Track, AUTO) + + +PB_BIND(Episode, Episode, 2) + + + + diff --git a/components/spotify/cspot/protobuf/metadata.pb.h b/components/spotify/cspot/protobuf/metadata.pb.h new file mode 100644 index 00000000..fa196fa8 --- /dev/null +++ b/components/spotify/cspot/protobuf/metadata.pb.h @@ -0,0 +1,240 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.6-dev */ + +#ifndef PB_PROTOBUF_METADATA_PB_H_INCLUDED +#define PB_PROTOBUF_METADATA_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Enum definitions */ +typedef enum _AudioFormat { + AudioFormat_OGG_VORBIS_96 = 0, + AudioFormat_OGG_VORBIS_160 = 1, + AudioFormat_OGG_VORBIS_320 = 2, + AudioFormat_MP3_256 = 3, + AudioFormat_MP3_320 = 4, + AudioFormat_MP3_160 = 5, + AudioFormat_MP3_96 = 6, + AudioFormat_MP3_160_ENC = 7, + AudioFormat_AAC_24 = 8, + AudioFormat_AAC_48 = 9 +} AudioFormat; + +/* Struct definitions */ +typedef struct _Artist { + pb_bytes_array_t *gid; + char *name; +} Artist; + +typedef struct _Image { + pb_bytes_array_t *file_id; +} Image; + +typedef struct _ImageGroup { + pb_size_t image_count; + struct _Image *image; +} ImageGroup; + +typedef struct _Restriction { + char *countries_allowed; + char *countries_forbidden; +} Restriction; + +typedef struct _Album { + pb_callback_t gid; + char *name; + bool has_cover_group; + ImageGroup cover_group; +} Album; + +typedef struct _AudioFile { + pb_bytes_array_t *file_id; + bool has_format; + AudioFormat format; +} AudioFile; + +typedef struct _Episode { + pb_bytes_array_t *gid; + char *name; + bool has_duration; + int32_t duration; + pb_size_t audio_count; + struct _AudioFile *audio; + struct _ImageGroup *covers; +} Episode; + +typedef struct _Track { + pb_bytes_array_t *gid; + char *name; + bool has_album; + Album album; + pb_size_t artist_count; + struct _Artist *artist; + bool has_duration; + int32_t duration; + pb_size_t restriction_count; + struct _Restriction *restriction; + pb_size_t file_count; + struct _AudioFile *file; + pb_size_t alternative_count; + struct _Track *alternative; +} Track; + + +/* Helper constants for enums */ +#define _AudioFormat_MIN AudioFormat_OGG_VORBIS_96 +#define _AudioFormat_MAX AudioFormat_AAC_48 +#define _AudioFormat_ARRAYSIZE ((AudioFormat)(AudioFormat_AAC_48+1)) + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define AudioFile_init_default {NULL, false, _AudioFormat_MIN} +#define Restriction_init_default {NULL, NULL} +#define Image_init_default {NULL} +#define ImageGroup_init_default {0, NULL} +#define Album_init_default {{{NULL}, NULL}, NULL, false, ImageGroup_init_default} +#define Artist_init_default {NULL, NULL} +#define Track_init_default {NULL, NULL, false, Album_init_default, 0, NULL, false, 0, 0, NULL, 0, NULL, 0, NULL} +#define Episode_init_default {NULL, NULL, false, 0, 0, NULL, NULL} +#define AudioFile_init_zero {NULL, false, _AudioFormat_MIN} +#define Restriction_init_zero {NULL, NULL} +#define Image_init_zero {NULL} +#define ImageGroup_init_zero {0, NULL} +#define Album_init_zero {{{NULL}, NULL}, NULL, false, ImageGroup_init_zero} +#define Artist_init_zero {NULL, NULL} +#define Track_init_zero {NULL, NULL, false, Album_init_zero, 0, NULL, false, 0, 0, NULL, 0, NULL, 0, NULL} +#define Episode_init_zero {NULL, NULL, false, 0, 0, NULL, NULL} + +/* Field tags (for use in manual encoding/decoding) */ +#define Artist_gid_tag 1 +#define Artist_name_tag 2 +#define Image_file_id_tag 1 +#define ImageGroup_image_tag 1 +#define Restriction_countries_allowed_tag 2 +#define Restriction_countries_forbidden_tag 3 +#define Album_gid_tag 1 +#define Album_name_tag 2 +#define Album_cover_group_tag 17 +#define AudioFile_file_id_tag 1 +#define AudioFile_format_tag 2 +#define Episode_gid_tag 1 +#define Episode_name_tag 2 +#define Episode_duration_tag 7 +#define Episode_audio_tag 12 +#define Episode_covers_tag 68 +#define Track_gid_tag 1 +#define Track_name_tag 2 +#define Track_album_tag 3 +#define Track_artist_tag 4 +#define Track_duration_tag 7 +#define Track_restriction_tag 11 +#define Track_file_tag 12 +#define Track_alternative_tag 13 + +/* Struct field encoding specification for nanopb */ +#define AudioFile_FIELDLIST(X, a) \ +X(a, POINTER, OPTIONAL, BYTES, file_id, 1) \ +X(a, STATIC, OPTIONAL, UENUM, format, 2) +#define AudioFile_CALLBACK NULL +#define AudioFile_DEFAULT NULL + +#define Restriction_FIELDLIST(X, a) \ +X(a, POINTER, OPTIONAL, STRING, countries_allowed, 2) \ +X(a, POINTER, OPTIONAL, STRING, countries_forbidden, 3) +#define Restriction_CALLBACK NULL +#define Restriction_DEFAULT NULL + +#define Image_FIELDLIST(X, a) \ +X(a, POINTER, OPTIONAL, BYTES, file_id, 1) +#define Image_CALLBACK NULL +#define Image_DEFAULT NULL + +#define ImageGroup_FIELDLIST(X, a) \ +X(a, POINTER, REPEATED, MESSAGE, image, 1) +#define ImageGroup_CALLBACK NULL +#define ImageGroup_DEFAULT NULL +#define ImageGroup_image_MSGTYPE Image + +#define Album_FIELDLIST(X, a) \ +X(a, CALLBACK, OPTIONAL, BYTES, gid, 1) \ +X(a, POINTER, OPTIONAL, STRING, name, 2) \ +X(a, STATIC, OPTIONAL, MESSAGE, cover_group, 17) +#define Album_CALLBACK pb_default_field_callback +#define Album_DEFAULT NULL +#define Album_cover_group_MSGTYPE ImageGroup + +#define Artist_FIELDLIST(X, a) \ +X(a, POINTER, OPTIONAL, BYTES, gid, 1) \ +X(a, POINTER, OPTIONAL, STRING, name, 2) +#define Artist_CALLBACK NULL +#define Artist_DEFAULT NULL + +#define Track_FIELDLIST(X, a) \ +X(a, POINTER, OPTIONAL, BYTES, gid, 1) \ +X(a, POINTER, OPTIONAL, STRING, name, 2) \ +X(a, STATIC, OPTIONAL, MESSAGE, album, 3) \ +X(a, POINTER, REPEATED, MESSAGE, artist, 4) \ +X(a, STATIC, OPTIONAL, SINT32, duration, 7) \ +X(a, POINTER, REPEATED, MESSAGE, restriction, 11) \ +X(a, POINTER, REPEATED, MESSAGE, file, 12) \ +X(a, POINTER, REPEATED, MESSAGE, alternative, 13) +#define Track_CALLBACK NULL +#define Track_DEFAULT NULL +#define Track_album_MSGTYPE Album +#define Track_artist_MSGTYPE Artist +#define Track_restriction_MSGTYPE Restriction +#define Track_file_MSGTYPE AudioFile +#define Track_alternative_MSGTYPE Track + +#define Episode_FIELDLIST(X, a) \ +X(a, POINTER, OPTIONAL, BYTES, gid, 1) \ +X(a, POINTER, OPTIONAL, STRING, name, 2) \ +X(a, STATIC, OPTIONAL, SINT32, duration, 7) \ +X(a, POINTER, REPEATED, MESSAGE, audio, 12) \ +X(a, POINTER, OPTIONAL, MESSAGE, covers, 68) +#define Episode_CALLBACK NULL +#define Episode_DEFAULT NULL +#define Episode_audio_MSGTYPE AudioFile +#define Episode_covers_MSGTYPE ImageGroup + +extern const pb_msgdesc_t AudioFile_msg; +extern const pb_msgdesc_t Restriction_msg; +extern const pb_msgdesc_t Image_msg; +extern const pb_msgdesc_t ImageGroup_msg; +extern const pb_msgdesc_t Album_msg; +extern const pb_msgdesc_t Artist_msg; +extern const pb_msgdesc_t Track_msg; +extern const pb_msgdesc_t Episode_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define AudioFile_fields &AudioFile_msg +#define Restriction_fields &Restriction_msg +#define Image_fields &Image_msg +#define ImageGroup_fields &ImageGroup_msg +#define Album_fields &Album_msg +#define Artist_fields &Artist_msg +#define Track_fields &Track_msg +#define Episode_fields &Episode_msg + +/* Maximum encoded size of messages (where known) */ +/* AudioFile_size depends on runtime parameters */ +/* Restriction_size depends on runtime parameters */ +/* Image_size depends on runtime parameters */ +/* ImageGroup_size depends on runtime parameters */ +/* Album_size depends on runtime parameters */ +/* Artist_size depends on runtime parameters */ +/* Track_size depends on runtime parameters */ +/* Episode_size depends on runtime parameters */ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/components/spotify/cspot/protobuf/spirc.pb.c b/components/spotify/cspot/protobuf/spirc.pb.c new file mode 100644 index 00000000..fd9bffb5 --- /dev/null +++ b/components/spotify/cspot/protobuf/spirc.pb.c @@ -0,0 +1,27 @@ +/* Automatically generated nanopb constant definitions */ +/* Generated by nanopb-0.4.6-dev */ + +#include "protobuf/spirc.pb.h" +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +PB_BIND(TrackRef, TrackRef, AUTO) + + +PB_BIND(State, State, AUTO) + + +PB_BIND(Capability, Capability, 2) + + +PB_BIND(DeviceState, DeviceState, 4) + + +PB_BIND(Frame, Frame, 4) + + + + + + diff --git a/components/spotify/cspot/protobuf/spirc.pb.h b/components/spotify/cspot/protobuf/spirc.pb.h new file mode 100644 index 00000000..9b79fb63 --- /dev/null +++ b/components/spotify/cspot/protobuf/spirc.pb.h @@ -0,0 +1,294 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.4.6-dev */ + +#ifndef PB_PROTOBUF_SPIRC_PB_H_INCLUDED +#define PB_PROTOBUF_SPIRC_PB_H_INCLUDED +#include + +#if PB_PROTO_HEADER_VERSION != 40 +#error Regenerate this file with the current version of nanopb generator. +#endif + +/* Enum definitions */ +typedef enum _MessageType { + MessageType_kMessageTypeHello = 1, + MessageType_kMessageTypeGoodbye = 2, + MessageType_kMessageTypeProbe = 3, + MessageType_kMessageTypeNotify = 10, + MessageType_kMessageTypeLoad = 20, + MessageType_kMessageTypePlay = 21, + MessageType_kMessageTypePause = 22, + MessageType_kMessageTypePlayPause = 23, + MessageType_kMessageTypeSeek = 24, + MessageType_kMessageTypePrev = 25, + MessageType_kMessageTypeNext = 26, + MessageType_kMessageTypeVolume = 27, + MessageType_kMessageTypeShuffle = 28, + MessageType_kMessageTypeRepeat = 29, + MessageType_kMessageTypeVolumeDown = 31, + MessageType_kMessageTypeVolumeUp = 32, + MessageType_kMessageTypeReplace = 33, + MessageType_kMessageTypeLogout = 34, + MessageType_kMessageTypeAction = 35 +} MessageType; + +typedef enum _PlayStatus { + PlayStatus_kPlayStatusStop = 0, + PlayStatus_kPlayStatusPlay = 1, + PlayStatus_kPlayStatusPause = 2, + PlayStatus_kPlayStatusLoading = 3 +} PlayStatus; + +typedef enum _CapabilityType { + CapabilityType_kSupportedContexts = 1, + CapabilityType_kCanBePlayer = 2, + CapabilityType_kRestrictToLocal = 3, + CapabilityType_kDeviceType = 4, + CapabilityType_kGaiaEqConnectId = 5, + CapabilityType_kSupportsLogout = 6, + CapabilityType_kIsObservable = 7, + CapabilityType_kVolumeSteps = 8, + CapabilityType_kSupportedTypes = 9, + CapabilityType_kCommandAcks = 10 +} CapabilityType; + +/* Struct definitions */ +typedef struct _Capability { + bool has_typ; + CapabilityType typ; + pb_size_t intValue_count; + int64_t intValue[50]; + pb_size_t stringValue_count; + char stringValue[50][50]; +} Capability; + +typedef struct _State { + char *context_uri; + bool has_index; + uint32_t index; + bool has_position_ms; + uint32_t position_ms; + bool has_status; + PlayStatus status; + bool has_position_measured_at; + uint64_t position_measured_at; + pb_callback_t context_description; + bool has_shuffle; + bool shuffle; + bool has_repeat; + bool repeat; + bool has_playing_track_index; + uint32_t playing_track_index; + pb_size_t track_count; + struct _TrackRef *track; +} State; + +typedef struct _TrackRef { + pb_bytes_array_t *gid; + char *uri; + bool has_queued; + bool queued; + char *context; +} TrackRef; + +typedef struct _DeviceState { + char *sw_version; + bool has_is_active; + bool is_active; + bool has_can_play; + bool can_play; + bool has_volume; + uint32_t volume; + char *name; + bool has_error_code; + uint32_t error_code; + bool has_became_active_at; + int64_t became_active_at; + pb_callback_t error_message; + pb_size_t capabilities_count; + Capability capabilities[17]; + pb_callback_t local_uris; +} DeviceState; + +typedef struct _Frame { + bool has_version; + uint32_t version; + char *ident; + char *protocol_version; + bool has_seq_nr; + uint32_t seq_nr; + bool has_typ; + MessageType typ; + bool has_device_state; + DeviceState device_state; + bool has_state; + State state; + bool has_position; + uint32_t position; + bool has_volume; + uint32_t volume; + bool has_state_update_id; + int64_t state_update_id; + pb_size_t recipient_count; + char **recipient; +} Frame; + + +/* Helper constants for enums */ +#define _MessageType_MIN MessageType_kMessageTypeHello +#define _MessageType_MAX MessageType_kMessageTypeAction +#define _MessageType_ARRAYSIZE ((MessageType)(MessageType_kMessageTypeAction+1)) + +#define _PlayStatus_MIN PlayStatus_kPlayStatusStop +#define _PlayStatus_MAX PlayStatus_kPlayStatusLoading +#define _PlayStatus_ARRAYSIZE ((PlayStatus)(PlayStatus_kPlayStatusLoading+1)) + +#define _CapabilityType_MIN CapabilityType_kSupportedContexts +#define _CapabilityType_MAX CapabilityType_kCommandAcks +#define _CapabilityType_ARRAYSIZE ((CapabilityType)(CapabilityType_kCommandAcks+1)) + + +#ifdef __cplusplus +extern "C" { +#endif + +/* Initializer values for message structs */ +#define TrackRef_init_default {NULL, NULL, false, 0, NULL} +#define State_init_default {NULL, false, 0, false, 0, false, _PlayStatus_MIN, false, 0, {{NULL}, NULL}, false, 0, false, 0, false, 0, 0, NULL} +#define Capability_init_default {false, _CapabilityType_MIN, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""}} +#define DeviceState_init_default {NULL, false, 0, false, 0, false, 0, NULL, false, 0, false, 0, {{NULL}, NULL}, 0, {Capability_init_default, Capability_init_default, Capability_init_default, Capability_init_default, Capability_init_default, Capability_init_default, Capability_init_default, Capability_init_default, Capability_init_default, Capability_init_default, Capability_init_default, Capability_init_default, Capability_init_default, Capability_init_default, Capability_init_default, Capability_init_default, Capability_init_default}, {{NULL}, NULL}} +#define Frame_init_default {false, 0, NULL, NULL, false, 0, false, _MessageType_MIN, false, DeviceState_init_default, false, State_init_default, false, 0, false, 0, false, 0, 0, NULL} +#define TrackRef_init_zero {NULL, NULL, false, 0, NULL} +#define State_init_zero {NULL, false, 0, false, 0, false, _PlayStatus_MIN, false, 0, {{NULL}, NULL}, false, 0, false, 0, false, 0, 0, NULL} +#define Capability_init_zero {false, _CapabilityType_MIN, 0, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""}} +#define DeviceState_init_zero {NULL, false, 0, false, 0, false, 0, NULL, false, 0, false, 0, {{NULL}, NULL}, 0, {Capability_init_zero, Capability_init_zero, Capability_init_zero, Capability_init_zero, Capability_init_zero, Capability_init_zero, Capability_init_zero, Capability_init_zero, Capability_init_zero, Capability_init_zero, Capability_init_zero, Capability_init_zero, Capability_init_zero, Capability_init_zero, Capability_init_zero, Capability_init_zero, Capability_init_zero}, {{NULL}, NULL}} +#define Frame_init_zero {false, 0, NULL, NULL, false, 0, false, _MessageType_MIN, false, DeviceState_init_zero, false, State_init_zero, false, 0, false, 0, false, 0, 0, NULL} + +/* Field tags (for use in manual encoding/decoding) */ +#define Capability_typ_tag 1 +#define Capability_intValue_tag 2 +#define Capability_stringValue_tag 3 +#define State_context_uri_tag 2 +#define State_index_tag 3 +#define State_position_ms_tag 4 +#define State_status_tag 5 +#define State_position_measured_at_tag 7 +#define State_context_description_tag 8 +#define State_shuffle_tag 13 +#define State_repeat_tag 14 +#define State_playing_track_index_tag 26 +#define State_track_tag 27 +#define TrackRef_gid_tag 1 +#define TrackRef_uri_tag 2 +#define TrackRef_queued_tag 3 +#define TrackRef_context_tag 4 +#define DeviceState_sw_version_tag 1 +#define DeviceState_is_active_tag 10 +#define DeviceState_can_play_tag 11 +#define DeviceState_volume_tag 12 +#define DeviceState_name_tag 13 +#define DeviceState_error_code_tag 14 +#define DeviceState_became_active_at_tag 15 +#define DeviceState_error_message_tag 16 +#define DeviceState_capabilities_tag 17 +#define DeviceState_local_uris_tag 18 +#define Frame_version_tag 1 +#define Frame_ident_tag 2 +#define Frame_protocol_version_tag 3 +#define Frame_seq_nr_tag 4 +#define Frame_typ_tag 5 +#define Frame_device_state_tag 7 +#define Frame_state_tag 12 +#define Frame_position_tag 13 +#define Frame_volume_tag 14 +#define Frame_state_update_id_tag 17 +#define Frame_recipient_tag 18 + +/* Struct field encoding specification for nanopb */ +#define TrackRef_FIELDLIST(X, a) \ +X(a, POINTER, OPTIONAL, BYTES, gid, 1) \ +X(a, POINTER, OPTIONAL, STRING, uri, 2) \ +X(a, STATIC, OPTIONAL, BOOL, queued, 3) \ +X(a, POINTER, OPTIONAL, STRING, context, 4) +#define TrackRef_CALLBACK NULL +#define TrackRef_DEFAULT NULL + +#define State_FIELDLIST(X, a) \ +X(a, POINTER, OPTIONAL, STRING, context_uri, 2) \ +X(a, STATIC, OPTIONAL, UINT32, index, 3) \ +X(a, STATIC, OPTIONAL, UINT32, position_ms, 4) \ +X(a, STATIC, OPTIONAL, UENUM, status, 5) \ +X(a, STATIC, OPTIONAL, UINT64, position_measured_at, 7) \ +X(a, CALLBACK, OPTIONAL, STRING, context_description, 8) \ +X(a, STATIC, OPTIONAL, BOOL, shuffle, 13) \ +X(a, STATIC, OPTIONAL, BOOL, repeat, 14) \ +X(a, STATIC, OPTIONAL, UINT32, playing_track_index, 26) \ +X(a, POINTER, REPEATED, MESSAGE, track, 27) +#define State_CALLBACK pb_default_field_callback +#define State_DEFAULT NULL +#define State_track_MSGTYPE TrackRef + +#define Capability_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, UENUM, typ, 1) \ +X(a, STATIC, REPEATED, INT64, intValue, 2) \ +X(a, STATIC, REPEATED, STRING, stringValue, 3) +#define Capability_CALLBACK NULL +#define Capability_DEFAULT (const pb_byte_t*)"\x08\x01\x00" + +#define DeviceState_FIELDLIST(X, a) \ +X(a, POINTER, OPTIONAL, STRING, sw_version, 1) \ +X(a, STATIC, OPTIONAL, BOOL, is_active, 10) \ +X(a, STATIC, OPTIONAL, BOOL, can_play, 11) \ +X(a, STATIC, OPTIONAL, UINT32, volume, 12) \ +X(a, POINTER, OPTIONAL, STRING, name, 13) \ +X(a, STATIC, OPTIONAL, UINT32, error_code, 14) \ +X(a, STATIC, OPTIONAL, INT64, became_active_at, 15) \ +X(a, CALLBACK, OPTIONAL, STRING, error_message, 16) \ +X(a, STATIC, REPEATED, MESSAGE, capabilities, 17) \ +X(a, CALLBACK, REPEATED, STRING, local_uris, 18) +#define DeviceState_CALLBACK pb_default_field_callback +#define DeviceState_DEFAULT NULL +#define DeviceState_capabilities_MSGTYPE Capability + +#define Frame_FIELDLIST(X, a) \ +X(a, STATIC, OPTIONAL, UINT32, version, 1) \ +X(a, POINTER, OPTIONAL, STRING, ident, 2) \ +X(a, POINTER, OPTIONAL, STRING, protocol_version, 3) \ +X(a, STATIC, OPTIONAL, UINT32, seq_nr, 4) \ +X(a, STATIC, OPTIONAL, UENUM, typ, 5) \ +X(a, STATIC, OPTIONAL, MESSAGE, device_state, 7) \ +X(a, STATIC, OPTIONAL, MESSAGE, state, 12) \ +X(a, STATIC, OPTIONAL, UINT32, position, 13) \ +X(a, STATIC, OPTIONAL, UINT32, volume, 14) \ +X(a, STATIC, OPTIONAL, INT64, state_update_id, 17) \ +X(a, POINTER, REPEATED, STRING, recipient, 18) +#define Frame_CALLBACK NULL +#define Frame_DEFAULT (const pb_byte_t*)"\x28\x01\x00" +#define Frame_device_state_MSGTYPE DeviceState +#define Frame_state_MSGTYPE State + +extern const pb_msgdesc_t TrackRef_msg; +extern const pb_msgdesc_t State_msg; +extern const pb_msgdesc_t Capability_msg; +extern const pb_msgdesc_t DeviceState_msg; +extern const pb_msgdesc_t Frame_msg; + +/* Defines for backwards compatibility with code written before nanopb-0.4.0 */ +#define TrackRef_fields &TrackRef_msg +#define State_fields &State_msg +#define Capability_fields &Capability_msg +#define DeviceState_fields &DeviceState_msg +#define Frame_fields &Frame_msg + +/* Maximum encoded size of messages (where known) */ +/* TrackRef_size depends on runtime parameters */ +/* State_size depends on runtime parameters */ +/* DeviceState_size depends on runtime parameters */ +/* Frame_size depends on runtime parameters */ +#define Capability_size 3102 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif diff --git a/components/spotify/cspot/src/CDNTrackStream.cpp b/components/spotify/cspot/src/CDNTrackStream.cpp index 7b3fda7d..638a78d3 100644 --- a/components/spotify/cspot/src/CDNTrackStream.cpp +++ b/components/spotify/cspot/src/CDNTrackStream.cpp @@ -67,7 +67,7 @@ void CDNTrackStream::seek(size_t newPos) { this->position = newPos; } -void CDNTrackStream::openStream() { +void CDNTrackStream::openStream() { CSPOT_LOG(info, "Opening HTTP stream to %s", this->cdnUrl.c_str()); // Open connection, read first 128 bytes @@ -102,7 +102,7 @@ void CDNTrackStream::openStream() { this->isConnected = true; } -size_t CDNTrackStream::readBytes(uint8_t* dst, size_t bytes) { +size_t CDNTrackStream::readBytes(uint8_t* dst, size_t bytes) { size_t offsetPosition = position + SPOTIFY_OPUS_HEADER; size_t actualFileSize = this->totalFileSize + SPOTIFY_OPUS_HEADER; diff --git a/components/spotify/cspot/src/LoginBlob.cpp b/components/spotify/cspot/src/LoginBlob.cpp index 4a86ef39..411fdae6 100644 --- a/components/spotify/cspot/src/LoginBlob.cpp +++ b/components/spotify/cspot/src/LoginBlob.cpp @@ -130,12 +130,9 @@ void LoginBlob::loadUserPass(const std::string& username, void LoginBlob::loadJson(const std::string& json) { #ifdef BELL_ONLY_CJSON cJSON* root = cJSON_Parse(json.c_str()); - cJSON* item = cJSON_GetObjectItem(root, "authType"); - this->authType = item->valueint; - item = cJSON_GetObjectItem(root, "username"); - this->username = item->valuestring; - item = cJSON_GetObjectItem(root, "authData"); - std::string authDataObject = item->valuestring; + this->authType = cJSON_GetObjectItem(root, "authType")->valueint; + this->username = cJSON_GetObjectItem(root, "username")->valuestring; + std::string authDataObject = cJSON_GetObjectItem(root, "authData")->valuestring; cJSON_Delete(root); #else auto root = nlohmann::json::parse(json);