/usr/include/piano.h is in libpiano-dev 2017.08.30-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | /*
Copyright (c) 2008-2013
Lars-Dominik Braun <lars@6xq.net>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma once
#include "../config.h"
#include <stdbool.h>
#ifdef __FreeBSD__
#define _GCRYPT_IN_LIBGCRYPT
#endif
#include <gcrypt.h>
/* this is our public API; don't expect this api to be stable as long as
* pandora does not provide a stable api
* all strings _must_ be utf-8 encoded. i won't care, but pandora does. so
* be nice and check the encoding of your strings. thanks :) */
/* Pandora API documentation is available at
* http://6xq.net/playground/pandora-apidoc/
*/
#define PIANO_RPC_HOST "tuner.pandora.com"
#define PIANO_RPC_PATH "/services/json/?"
typedef struct PianoListHead {
struct PianoListHead *next;
} PianoListHead_t;
typedef struct PianoUserInfo {
char *listenerId;
char *authToken;
} PianoUserInfo_t;
typedef struct PianoStation {
PianoListHead_t head;
char isCreator;
char isQuickMix;
char useQuickMix; /* station will be included in quickmix */
char *name;
char *id;
char *seedId;
} PianoStation_t;
typedef enum {
PIANO_RATE_NONE = 0,
PIANO_RATE_LOVE = 1,
PIANO_RATE_BAN = 2
} PianoSongRating_t;
/* UNKNOWN should be 0, because memset sets audio format to 0 */
typedef enum {
PIANO_AF_UNKNOWN = 0,
PIANO_AF_AACPLUS = 1,
PIANO_AF_MP3 = 2,
} PianoAudioFormat_t;
typedef enum {
PIANO_AQ_UNKNOWN = 0,
PIANO_AQ_LOW = 1,
PIANO_AQ_MEDIUM = 2,
PIANO_AQ_HIGH = 3,
} PianoAudioQuality_t;
typedef struct PianoSong {
PianoListHead_t head;
char *artist;
char *stationId;
char *album;
char *audioUrl;
char *coverArt;
char *musicId;
char *title;
char *seedId;
char *feedbackId;
char *detailUrl;
char *trackToken;
float fileGain;
unsigned int length; /* song length in seconds */
PianoSongRating_t rating;
PianoAudioFormat_t audioFormat;
} PianoSong_t;
/* currently only used for search results */
typedef struct PianoArtist {
PianoListHead_t head;
char *name;
char *musicId;
char *seedId;
int score;
} PianoArtist_t;
typedef struct PianoGenre {
PianoListHead_t head;
char *name;
char *musicId;
} PianoGenre_t;
typedef struct PianoGenreCategory {
PianoListHead_t head;
char *name;
PianoGenre_t *genres;
} PianoGenreCategory_t;
typedef struct PianoPartner {
gcry_cipher_hd_t in, out;
char *authToken, *device, *user, *password;
unsigned int id;
} PianoPartner_t;
typedef struct PianoHandle {
PianoUserInfo_t user;
/* linked lists */
PianoStation_t *stations;
PianoGenreCategory_t *genreStations;
PianoPartner_t partner;
int timeOffset;
} PianoHandle_t;
typedef struct PianoSearchResult {
PianoSong_t *songs;
PianoArtist_t *artists;
} PianoSearchResult_t;
typedef struct {
PianoSong_t *songSeeds;
PianoArtist_t *artistSeeds;
PianoStation_t *stationSeeds;
PianoSong_t *feedback;
} PianoStationInfo_t;
typedef struct {
char *username;
bool explicitContentFilter;
} PianoSettings_t;
typedef enum {
/* 0 is reserved: memset (x, 0, sizeof (x)) */
PIANO_REQUEST_LOGIN = 1,
PIANO_REQUEST_GET_STATIONS = 2,
PIANO_REQUEST_GET_PLAYLIST = 3,
PIANO_REQUEST_RATE_SONG = 4,
PIANO_REQUEST_ADD_FEEDBACK = 5,
PIANO_REQUEST_RENAME_STATION = 7,
PIANO_REQUEST_DELETE_STATION = 8,
PIANO_REQUEST_SEARCH = 9,
PIANO_REQUEST_CREATE_STATION = 10,
PIANO_REQUEST_ADD_SEED = 11,
PIANO_REQUEST_ADD_TIRED_SONG = 12,
PIANO_REQUEST_SET_QUICKMIX = 13,
PIANO_REQUEST_GET_GENRE_STATIONS = 14,
PIANO_REQUEST_TRANSFORM_STATION = 15,
PIANO_REQUEST_EXPLAIN = 16,
PIANO_REQUEST_BOOKMARK_SONG = 18,
PIANO_REQUEST_BOOKMARK_ARTIST = 19,
PIANO_REQUEST_GET_STATION_INFO = 20,
PIANO_REQUEST_DELETE_FEEDBACK = 21,
PIANO_REQUEST_DELETE_SEED = 22,
PIANO_REQUEST_GET_SETTINGS = 23,
PIANO_REQUEST_CHANGE_SETTINGS = 24,
} PianoRequestType_t;
typedef struct PianoRequest {
PianoRequestType_t type;
bool secure;
void *data;
char urlPath[1024];
char *postData;
char *responseData;
} PianoRequest_t;
/* request data structures */
typedef struct {
char *user;
char *password;
unsigned char step;
} PianoRequestDataLogin_t;
typedef struct {
PianoStation_t *station;
PianoAudioQuality_t quality;
PianoSong_t *retPlaylist;
} PianoRequestDataGetPlaylist_t;
typedef struct {
PianoSong_t *song;
PianoSongRating_t rating;
} PianoRequestDataRateSong_t;
typedef struct {
char *stationId;
char *trackToken;
PianoSongRating_t rating;
} PianoRequestDataAddFeedback_t;
typedef struct {
PianoStation_t *station;
char *newName;
} PianoRequestDataRenameStation_t;
typedef struct {
char *searchStr;
PianoSearchResult_t searchResult;
} PianoRequestDataSearch_t;
typedef struct {
char *token;
enum {
PIANO_MUSICTYPE_INVALID = 0,
PIANO_MUSICTYPE_SONG,
PIANO_MUSICTYPE_ARTIST,
} type;
} PianoRequestDataCreateStation_t;
typedef struct {
PianoStation_t *station;
char *musicId;
} PianoRequestDataAddSeed_t;
typedef struct {
PianoSong_t *song;
char *retExplain;
} PianoRequestDataExplain_t;
typedef struct {
PianoStation_t *station;
PianoStationInfo_t info;
} PianoRequestDataGetStationInfo_t;
typedef struct {
PianoSong_t *song;
PianoArtist_t *artist;
PianoStation_t *station;
} PianoRequestDataDeleteSeed_t;
typedef enum {
PIANO_UNDEFINED = 0,
PIANO_FALSE = 1,
PIANO_TRUE = 2,
} PianoTristate_t;
typedef struct {
char *currentUsername, *newUsername;
char *currentPassword, *newPassword;
PianoTristate_t explicitContentFilter;
} PianoRequestDataChangeSettings_t;
/* pandora error code offset */
#define PIANO_RET_OFFSET 1024
typedef enum {
PIANO_RET_ERR = 0,
PIANO_RET_OK = 1,
PIANO_RET_INVALID_RESPONSE = 2,
PIANO_RET_CONTINUE_REQUEST = 3,
PIANO_RET_OUT_OF_MEMORY = 4,
PIANO_RET_INVALID_LOGIN = 5,
PIANO_RET_QUALITY_UNAVAILABLE = 6,
PIANO_RET_GCRY_ERR = 7,
/* pandora error codes */
PIANO_RET_P_INTERNAL = PIANO_RET_OFFSET+0,
PIANO_RET_P_API_VERSION_NOT_SUPPORTED = PIANO_RET_OFFSET+11,
PIANO_RET_P_BIRTH_YEAR_INVALID = PIANO_RET_OFFSET+1025,
PIANO_RET_P_BIRTH_YEAR_TOO_YOUNG = PIANO_RET_OFFSET+1026,
PIANO_RET_P_CALL_NOT_ALLOWED = PIANO_RET_OFFSET+1008,
PIANO_RET_P_CERTIFICATE_REQUIRED = PIANO_RET_OFFSET+7,
PIANO_RET_P_COMPLIMENTARY_PERIOD_ALREADY_IN_USE = PIANO_RET_OFFSET+1007,
PIANO_RET_P_DAILY_TRIAL_LIMIT_REACHED = PIANO_RET_OFFSET+1035,
PIANO_RET_P_DEVICE_ALREADY_ASSOCIATED_TO_ACCOUNT = PIANO_RET_OFFSET+1014,
PIANO_RET_P_DEVICE_DISABLED = PIANO_RET_OFFSET+1034,
PIANO_RET_P_DEVICE_MODEL_INVALID = PIANO_RET_OFFSET+1023,
PIANO_RET_P_DEVICE_NOT_FOUND = PIANO_RET_OFFSET+1009,
PIANO_RET_P_EXPLICIT_PIN_INCORRECT = PIANO_RET_OFFSET+1018,
PIANO_RET_P_EXPLICIT_PIN_MALFORMED = PIANO_RET_OFFSET+1020,
PIANO_RET_P_INSUFFICIENT_CONNECTIVITY = PIANO_RET_OFFSET+13,
PIANO_RET_P_INVALID_AUTH_TOKEN = PIANO_RET_OFFSET+1001,
PIANO_RET_P_INVALID_COUNTRY_CODE = PIANO_RET_OFFSET+1027,
PIANO_RET_P_INVALID_GENDER = PIANO_RET_OFFSET+1027,
PIANO_RET_P_INVALID_PARTNER_LOGIN = PIANO_RET_OFFSET+1002,
PIANO_RET_P_INVALID_PASSWORD = PIANO_RET_OFFSET+1012,
PIANO_RET_P_INVALID_SPONSOR = PIANO_RET_OFFSET+1036,
PIANO_RET_P_INVALID_USERNAME = PIANO_RET_OFFSET+1011,
PIANO_RET_P_LICENSING_RESTRICTIONS = PIANO_RET_OFFSET+12,
PIANO_RET_P_MAINTENANCE_MODE = PIANO_RET_OFFSET+1,
PIANO_RET_P_MAX_STATIONS_REACHED = PIANO_RET_OFFSET+1005,
PIANO_RET_P_PARAMETER_MISSING = PIANO_RET_OFFSET+9,
PIANO_RET_P_PARAMETER_TYPE_MISMATCH = PIANO_RET_OFFSET+8,
PIANO_RET_P_PARAMETER_VALUE_INVALID = PIANO_RET_OFFSET+10,
PIANO_RET_P_PARTNER_NOT_AUTHORIZED = PIANO_RET_OFFSET+1010,
PIANO_RET_P_READ_ONLY_MODE = PIANO_RET_OFFSET+1000,
PIANO_RET_P_SECURE_PROTOCOL_REQUIRED = PIANO_RET_OFFSET+6,
PIANO_RET_P_STATION_DOES_NOT_EXIST = PIANO_RET_OFFSET+1006,
PIANO_RET_P_UPGRADE_DEVICE_MODEL_INVALID = PIANO_RET_OFFSET+1015,
PIANO_RET_P_URL_PARAM_MISSING_AUTH_TOKEN = PIANO_RET_OFFSET+3,
PIANO_RET_P_URL_PARAM_MISSING_METHOD = PIANO_RET_OFFSET+2,
PIANO_RET_P_URL_PARAM_MISSING_PARTNER_ID = PIANO_RET_OFFSET+4,
PIANO_RET_P_URL_PARAM_MISSING_USER_ID = PIANO_RET_OFFSET+5,
PIANO_RET_P_USERNAME_ALREADY_EXISTS = PIANO_RET_OFFSET+1013,
PIANO_RET_P_USER_ALREADY_USED_TRIAL = PIANO_RET_OFFSET+1037,
PIANO_RET_P_LISTENER_NOT_AUTHORIZED = PIANO_RET_OFFSET+1003,
PIANO_RET_P_USER_NOT_AUTHORIZED = PIANO_RET_OFFSET+1004,
PIANO_RET_P_ZIP_CODE_INVALID = PIANO_RET_OFFSET+1024,
PIANO_RET_P_RATE_LIMIT = PIANO_RET_OFFSET+1039,
} PianoReturn_t;
/* list stuff */
#ifndef __GNUC__
# define __attribute__(x)
#endif
size_t PianoListCount (const PianoListHead_t * const l);
#define PianoListCountP(l) PianoListCount(&(l)->head)
void *PianoListAppend (PianoListHead_t * const l, PianoListHead_t * const e)
__attribute__ ((warn_unused_result));
#define PianoListAppendP(l,e) PianoListAppend(((l) == NULL) ? NULL : &(l)->head, \
&(e)->head)
void *PianoListDelete (PianoListHead_t * const l, PianoListHead_t * const e)
__attribute__ ((warn_unused_result));
#define PianoListDeleteP(l,e) PianoListDelete(((l) == NULL) ? NULL : &(l)->head, \
&(e)->head)
#define PianoListNextP(e) ((e) == NULL ? NULL : (void *) (e)->head.next)
void *PianoListPrepend (PianoListHead_t * const l, PianoListHead_t * const e)
__attribute__ ((warn_unused_result));
#define PianoListPrependP(l,e) PianoListPrepend (((l) == NULL) ? NULL : &(l)->head, \
&(e)->head)
void *PianoListGet (PianoListHead_t * const l, const size_t n);
#define PianoListGetP(l,n) PianoListGet (&(l)->head, n)
#define PianoListForeachP(l) for (; (l) != NULL; (l) = (void *) (l)->head.next)
/* memory management */
PianoReturn_t PianoInit (PianoHandle_t *, const char *,
const char *, const char *, const char *,
const char *);
void PianoDestroy (PianoHandle_t *);
void PianoDestroyPlaylist (PianoSong_t *);
void PianoDestroySearchResult (PianoSearchResult_t *);
void PianoDestroyStationInfo (PianoStationInfo_t *);
/* pandora rpc */
PianoReturn_t PianoRequest (PianoHandle_t *, PianoRequest_t *,
PianoRequestType_t);
PianoReturn_t PianoResponse (PianoHandle_t *, PianoRequest_t *);
void PianoDestroyRequest (PianoRequest_t *);
/* misc */
PianoStation_t *PianoFindStationById (PianoStation_t * const,
const char * const);
const char *PianoErrorToStr (PianoReturn_t);
|