Guest User

Untitled

a guest
May 25th, 2018
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.78 KB | None | 0 0
  1. /*
  2. Copyright (c) 2008-2010
  3. Lars-Dominik Braun <PromyLOPh@lavabit.com>
  4.  
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11.  
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14.  
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. */
  23.  
  24. #ifndef _PIANO_H
  25. #define _PIANO_H
  26.  
  27. /* this is our public API; don't expect this api to be stable as long as
  28. * pandora does not provide a stable api
  29. * all strings _must_ be utf-8 encoded. i won't care, but pandora does. so
  30. * be nice and check the encoding of your strings. thanks :) */
  31.  
  32. #include <waitress.h>
  33.  
  34. typedef struct PianoUserInfo {
  35. char *webAuthToken;
  36. char *listenerId;
  37. char *authToken;
  38. } PianoUserInfo_t;
  39.  
  40. typedef struct PianoStation {
  41. char isCreator;
  42. char isQuickMix;
  43. char useQuickMix; /* station will be included in quickmix */
  44. char *name;
  45. char *id;
  46. struct PianoStation *next;
  47. } PianoStation_t;
  48.  
  49. typedef enum {PIANO_RATE_BAN, PIANO_RATE_LOVE, PIANO_RATE_NONE}
  50. PianoSongRating_t;
  51.  
  52. /* UNKNOWN should be 0, because memset sets audio format to 0 */
  53. typedef enum {PIANO_AF_UNKNOWN = 0, PIANO_AF_AACPLUS, PIANO_AF_MP3,
  54. PIANO_AF_MP3_HI} PianoAudioFormat_t;
  55.  
  56. typedef struct PianoSong {
  57. char *artist;
  58. char *matchingSeed;
  59. float fileGain;
  60. PianoSongRating_t rating;
  61. char *stationId;
  62. char *album;
  63. char *userSeed;
  64. char *audioUrl;
  65. char *musicId;
  66. char *title;
  67. char *focusTraitId;
  68. char *identity;
  69. PianoAudioFormat_t audioFormat;
  70. struct PianoSong *next;
  71. } PianoSong_t;
  72.  
  73. /* currently only used for search results */
  74. typedef struct PianoArtist {
  75. char *name;
  76. char *musicId;
  77. int score;
  78. struct PianoArtist *next;
  79. } PianoArtist_t;
  80.  
  81. typedef struct PianoGenreCategory {
  82. char *name;
  83. PianoStation_t *stations;
  84. struct PianoGenreCategory *next;
  85. } PianoGenreCategory_t;
  86.  
  87. typedef struct PianoHandle {
  88. WaitressHandle_t waith;
  89. char routeId[9];
  90. PianoUserInfo_t user;
  91. /* linked lists */
  92. PianoStation_t *stations;
  93. PianoGenreCategory_t *genreStations;
  94. } PianoHandle_t;
  95.  
  96. typedef struct PianoSearchResult {
  97. PianoSong_t *songs;
  98. PianoArtist_t *artists;
  99. } PianoSearchResult_t;
  100.  
  101. typedef enum {PIANO_RET_OK, PIANO_RET_ERR, PIANO_RET_XML_INVALID,
  102. PIANO_RET_AUTH_TOKEN_INVALID, PIANO_RET_AUTH_USER_PASSWORD_INVALID,
  103. PIANO_RET_NET_ERROR, PIANO_RET_NOT_AUTHORIZED,
  104. PIANO_RET_PROTOCOL_INCOMPATIBLE, PIANO_RET_READONLY_MODE,
  105. PIANO_RET_STATION_CODE_INVALID, PIANO_RET_IP_REJECTED,
  106. PIANO_RET_STATION_NONEXISTENT, PIANO_RET_OUT_OF_MEMORY,
  107. PIANO_RET_OUT_OF_SYNC, PIANO_RET_PLAYLIST_END} PianoReturn_t;
  108.  
  109. void PianoInit (PianoHandle_t *);
  110. void PianoDestroy (PianoHandle_t *);
  111. void PianoDestroyPlaylist (PianoSong_t *);
  112. void PianoDestroySearchResult (PianoSearchResult_t *);
  113. PianoReturn_t PianoConnect (PianoHandle_t *, const char *, const char *);
  114.  
  115. PianoReturn_t PianoGetStations (PianoHandle_t *);
  116. PianoReturn_t PianoGetPlaylist (PianoHandle_t *, const char *,
  117. PianoAudioFormat_t, PianoSong_t **);
  118.  
  119. PianoReturn_t PianoRateTrack (PianoHandle_t *, PianoSong_t *,
  120. PianoSongRating_t);
  121. PianoReturn_t PianoMoveSong (PianoHandle_t *, const PianoStation_t *,
  122. const PianoStation_t *, const PianoSong_t *);
  123. PianoReturn_t PianoRenameStation (PianoHandle_t *, PianoStation_t *,
  124. const char *);
  125. PianoReturn_t PianoDeleteStation (PianoHandle_t *, PianoStation_t *);
  126. PianoReturn_t PianoSearchMusic (PianoHandle_t *, const char *,
  127. PianoSearchResult_t *);
  128. PianoReturn_t PianoCreateStation (PianoHandle_t *, const char *,
  129. const char *);
  130. PianoReturn_t PianoStationAddMusic (PianoHandle_t *, PianoStation_t *,
  131. const char *);
  132. PianoReturn_t PianoSongTired (PianoHandle_t *, const PianoSong_t *);
  133. PianoReturn_t PianoSetQuickmix (PianoHandle_t *);
  134. PianoStation_t *PianoFindStationById (PianoStation_t *, const char *);
  135. PianoReturn_t PianoGetGenreStations (PianoHandle_t *);
  136. PianoReturn_t PianoTransformShared (PianoHandle_t *, PianoStation_t *);
  137. PianoReturn_t PianoExplain (PianoHandle_t *, const PianoSong_t *, char **);
  138. const char *PianoErrorToStr (PianoReturn_t);
  139. PianoReturn_t PianoSeedSuggestions (PianoHandle_t *, const char *,
  140. unsigned int, PianoSearchResult_t *);
  141.  
  142. #endif /* _PIANO_H */
Add Comment
Please, Sign In to add comment