~ubuntu-branches/ubuntu/wily/pianobar/wily-proposed

« back to all changes in this revision

Viewing changes to src/libpiano/piano.h

  • Committer: Package Import Robot
  • Author(s): Luke Faraone
  • Date: 2012-05-06 14:24:34 UTC
  • mfrom: (1.3.9)
  • Revision ID: package-import@ubuntu.com-20120506142434-74kwucnyp97msxdi
Tags: 2012.05.06-1
* New upstream version.
  - JSON api support (closes: #670483, LP: #988395)

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#define _PIANO_H
26
26
 
27
27
#include <stdbool.h>
 
28
#include <gcrypt.h>
28
29
 
29
30
/* this is our public API; don't expect this api to be stable as long as
30
31
 * pandora does not provide a stable api
31
32
 * all strings _must_ be utf-8 encoded. i won't care, but pandora does. so
32
33
 * be nice and check the encoding of your strings. thanks :) */
33
34
 
34
 
#define PIANO_RPC_HOST "www.pandora.com"
35
 
#define PIANO_RPC_PORT "80"
 
35
/* Pandora API documentation is available at
 
36
 * http://pan-do-ra-api.wikia.com
 
37
 */
 
38
 
 
39
#define PIANO_RPC_HOST "tuner.pandora.com"
 
40
#define PIANO_RPC_PATH "/services/json/?"
36
41
 
37
42
typedef struct PianoUserInfo {
38
 
        char *webAuthToken;
39
43
        char *listenerId;
40
44
        char *authToken;
41
45
} PianoUserInfo_t;
61
65
        PIANO_AF_UNKNOWN = 0,
62
66
        PIANO_AF_AACPLUS = 1,
63
67
        PIANO_AF_MP3 = 2,
64
 
        PIANO_AF_MP3_HI = 3
 
68
        PIANO_AF_MP3_HI = 3,
 
69
        PIANO_AF_AACPLUS_LO = 4,
65
70
} PianoAudioFormat_t;
66
71
 
67
72
typedef struct PianoSong {
68
73
        char *artist;
69
 
        char *artistMusicId;
70
74
        char *stationId;
71
75
        char *album;
72
 
        char *userSeed;
73
76
        char *audioUrl;
74
77
        char *coverArt;
75
78
        char *musicId;
105
108
        struct PianoGenreCategory *next;
106
109
} PianoGenreCategory_t;
107
110
 
 
111
typedef struct PianoPartner {
 
112
        gcry_cipher_hd_t in, out;
 
113
        char *authToken, *device, *user, *password;
 
114
        unsigned int id;
 
115
} PianoPartner_t;
 
116
 
108
117
typedef struct PianoHandle {
109
 
        char routeId[9];
110
118
        PianoUserInfo_t user;
111
119
        /* linked lists */
112
120
        PianoStation_t *stations;
113
121
        PianoGenreCategory_t *genreStations;
 
122
        PianoPartner_t partner;
114
123
        int timeOffset;
115
124
} PianoHandle_t;
116
125
 
144
153
        PIANO_REQUEST_GET_GENRE_STATIONS = 14,
145
154
        PIANO_REQUEST_TRANSFORM_STATION = 15,
146
155
        PIANO_REQUEST_EXPLAIN = 16,
147
 
        PIANO_REQUEST_GET_SEED_SUGGESTIONS = 17,
148
156
        PIANO_REQUEST_BOOKMARK_SONG = 18,
149
157
        PIANO_REQUEST_BOOKMARK_ARTIST = 19,
150
158
        PIANO_REQUEST_GET_STATION_INFO = 20,
219
227
 
220
228
typedef struct {
221
229
        PianoStation_t *station;
222
 
        char *musicId;
223
 
        unsigned short max;
224
 
        PianoSearchResult_t searchResult;
225
 
} PianoRequestDataGetSeedSuggestions_t;
226
 
 
227
 
typedef struct {
228
 
        PianoStation_t *station;
229
230
        PianoStationInfo_t info;
230
231
} PianoRequestDataGetStationInfo_t;
231
232
 
235
236
        PianoStation_t *station;
236
237
} PianoRequestDataDeleteSeed_t;
237
238
 
 
239
/* pandora error code offset */
 
240
#define PIANO_RET_OFFSET 1024
238
241
typedef enum {
239
242
        PIANO_RET_ERR = 0,
240
243
        PIANO_RET_OK = 1,
241
 
        PIANO_RET_XML_INVALID = 2,
242
 
        PIANO_RET_AUTH_TOKEN_INVALID = 3,
243
 
        PIANO_RET_AUTH_USER_PASSWORD_INVALID = 4,
244
 
        PIANO_RET_CONTINUE_REQUEST = 5,
245
 
        PIANO_RET_NOT_AUTHORIZED = 6,
246
 
        PIANO_RET_PROTOCOL_INCOMPATIBLE = 7,
247
 
        PIANO_RET_READONLY_MODE = 8,
248
 
        PIANO_RET_STATION_CODE_INVALID = 9,
249
 
        PIANO_RET_IP_REJECTED = 10,
250
 
        PIANO_RET_STATION_NONEXISTENT = 11,
251
 
        PIANO_RET_OUT_OF_MEMORY = 12,
252
 
        PIANO_RET_OUT_OF_SYNC = 13,
253
 
        PIANO_RET_PLAYLIST_END = 14,
254
 
        PIANO_RET_QUICKMIX_NOT_PLAYABLE = 15,
255
 
        PIANO_RET_REMOVING_TOO_MANY_SEEDS = 16,
 
244
        PIANO_RET_INVALID_RESPONSE = 2,
 
245
        PIANO_RET_CONTINUE_REQUEST = 3,
 
246
        PIANO_RET_OUT_OF_MEMORY = 4,
 
247
 
 
248
        PIANO_RET_P_INTERNAL = PIANO_RET_OFFSET+0,
 
249
        PIANO_RET_P_API_VERSION_NOT_SUPPORTED = PIANO_RET_OFFSET+11,
 
250
        PIANO_RET_P_BIRTH_YEAR_INVALID = PIANO_RET_OFFSET+1025,
 
251
        PIANO_RET_P_BIRTH_YEAR_TOO_YOUNG = PIANO_RET_OFFSET+1026,
 
252
        PIANO_RET_P_CALL_NOT_ALLOWED = PIANO_RET_OFFSET+1008,
 
253
        PIANO_RET_P_CERTIFICATE_REQUIRED = PIANO_RET_OFFSET+7,
 
254
        PIANO_RET_P_COMPLIMENTARY_PERIOD_ALREADY_IN_USE = PIANO_RET_OFFSET+1007,
 
255
        PIANO_RET_P_DAILY_TRIAL_LIMIT_REACHED = PIANO_RET_OFFSET+1035,
 
256
        PIANO_RET_P_DEVICE_ALREADY_ASSOCIATED_TO_ACCOUNT = PIANO_RET_OFFSET+1014,
 
257
        PIANO_RET_P_DEVICE_DISABLED = PIANO_RET_OFFSET+1034,
 
258
        PIANO_RET_P_DEVICE_MODEL_INVALID = PIANO_RET_OFFSET+1023,
 
259
        PIANO_RET_P_DEVICE_NOT_FOUND = PIANO_RET_OFFSET+1009,
 
260
        PIANO_RET_P_EXPLICIT_PIN_INCORRECT = PIANO_RET_OFFSET+1018,
 
261
        PIANO_RET_P_EXPLICIT_PIN_MALFORMED = PIANO_RET_OFFSET+1020,
 
262
        PIANO_RET_P_INSUFFICIENT_CONNECTIVITY = PIANO_RET_OFFSET+13,
 
263
        PIANO_RET_P_INVALID_AUTH_TOKEN = PIANO_RET_OFFSET+1001,
 
264
        PIANO_RET_P_INVALID_COUNTRY_CODE = PIANO_RET_OFFSET+1027,
 
265
        PIANO_RET_P_INVALID_GENDER = PIANO_RET_OFFSET+1027,
 
266
        PIANO_RET_P_INVALID_PARTNER_LOGIN = PIANO_RET_OFFSET+1002,
 
267
        PIANO_RET_P_INVALID_PASSWORD = PIANO_RET_OFFSET+1012,
 
268
        PIANO_RET_P_INVALID_SPONSOR = PIANO_RET_OFFSET+1036,
 
269
        PIANO_RET_P_INVALID_USERNAME = PIANO_RET_OFFSET+1011,
 
270
        PIANO_RET_P_LICENSING_RESTRICTIONS = PIANO_RET_OFFSET+12,
 
271
        PIANO_RET_P_MAINTENANCE_MODE = PIANO_RET_OFFSET+1,
 
272
        PIANO_RET_P_MAX_STATIONS_REACHED = PIANO_RET_OFFSET+1005,
 
273
        PIANO_RET_P_PARAMETER_MISSING = PIANO_RET_OFFSET+9,
 
274
        PIANO_RET_P_PARAMETER_TYPE_MISMATCH = PIANO_RET_OFFSET+8,
 
275
        PIANO_RET_P_PARAMETER_VALUE_INVALID = PIANO_RET_OFFSET+10,
 
276
        PIANO_RET_P_PARTNER_NOT_AUTHORIZED = PIANO_RET_OFFSET+1010,
 
277
        PIANO_RET_P_READ_ONLY_MODE = PIANO_RET_OFFSET+1000,
 
278
        PIANO_RET_P_SECURE_PROTOCOL_REQUIRED = PIANO_RET_OFFSET+6,
 
279
        PIANO_RET_P_STATION_DOES_NOT_EXIST = PIANO_RET_OFFSET+1006,
 
280
        PIANO_RET_P_UPGRADE_DEVICE_MODEL_INVALID = PIANO_RET_OFFSET+1015,
 
281
        PIANO_RET_P_URL_PARAM_MISSING_AUTH_TOKEN = PIANO_RET_OFFSET+3,
 
282
        PIANO_RET_P_URL_PARAM_MISSING_METHOD = PIANO_RET_OFFSET+2,
 
283
        PIANO_RET_P_URL_PARAM_MISSING_PARTNER_ID = PIANO_RET_OFFSET+4,
 
284
        PIANO_RET_P_URL_PARAM_MISSING_USER_ID = PIANO_RET_OFFSET+5,
 
285
        PIANO_RET_P_USERNAME_ALREADY_EXISTS = PIANO_RET_OFFSET+1013,
 
286
        PIANO_RET_P_USER_ALREADY_USED_TRIAL = PIANO_RET_OFFSET+1037,
 
287
        PIANO_RET_P_USER_NOT_ACTIVE = PIANO_RET_OFFSET+1003,
 
288
        PIANO_RET_P_USER_NOT_AUTHORIZED = PIANO_RET_OFFSET+1004,
 
289
        PIANO_RET_P_ZIP_CODE_INVALID = PIANO_RET_OFFSET+1024,
 
290
 
256
291
} PianoReturn_t;
257
292
 
258
 
void PianoInit (PianoHandle_t *);
 
293
void PianoInit (PianoHandle_t *, const char *,
 
294
                const char *, const char *, const char *,
 
295
                const char *);
259
296
void PianoDestroy (PianoHandle_t *);
260
297
void PianoDestroyPlaylist (PianoSong_t *);
261
298
void PianoDestroySearchResult (PianoSearchResult_t *);