1 /****************************************************************************************
2  * Copyright (c) 2008 MP3tunes, LLC <copyright@mp3tunes.com>                            *
3  *                                                                                      *
4  * This program is free software; you can redistribute it and/or modify it under        *
5  * the terms of the GNU Library General Public License as published by the Free         *
6  * Software Foundation; either version 2.1 of the License, or (at your option) any      *
7  * later version.                                                                       *
8  *                                                                                      *
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
11  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
12  *                                                                                      *
13  * You should have received a copy of the GNU Library General Public License along with *
14  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
15  ****************************************************************************************/
16 
17 /**
18  * \file locker.h
19  * \brief The \e liboboe public header.
20  */
21 
22 #ifndef __MP3TUNES_LOCKER_H__
23 #define __MP3TUNES_LOCKER_H__
24 
25 #ifndef TRUE
26 #define TRUE 1
27 #define FALSE 0
28 #endif
29 
30 #define MP3TUNES_SERVER_API_URL "ws.mp3tunes.com"
31 #define MP3TUNES_SERVER_CONTENT_URL "content.mp3tunes.com"
32 #define MP3TUNES_SERVER_LOGIN_URL "shop.mp3tunes.com"
33 
34 #define MP3TUNES_SERVER_API 0
35 #define MP3TUNES_SERVER_CONTENT 1
36 #define MP3TUNES_SERVER_LOGIN 2
37 
38 typedef struct {
39   char *username, *password, *session_id, *firstname, *lastname, *nickname;
40   char *partner_token;
41   char *server_api, *server_content, *server_login;
42   char *error_message;
43 } mp3tunes_locker_object_t;
44 
45 struct mp3tunes_locker_list_item_s {
46     int id;
47     void *value;
48     struct mp3tunes_locker_list_item_s *prev;
49     struct mp3tunes_locker_list_item_s *next;
50 };
51 
52 typedef struct mp3tunes_locker_list_item_s mp3tunes_locker_list_item_t;
53 
54 struct mp3tunes_locker_list_s {
55     int last_id;
56     mp3tunes_locker_list_item_t *first;
57     mp3tunes_locker_list_item_t *last;
58 };
59 
60 typedef struct mp3tunes_locker_list_s mp3tunes_locker_track_list_t;
61 typedef struct mp3tunes_locker_list_s mp3tunes_locker_artist_list_t;
62 typedef struct mp3tunes_locker_list_s mp3tunes_locker_album_list_t;
63 typedef struct mp3tunes_locker_list_s mp3tunes_locker_playlist_list_t;
64 
65 typedef struct {
66     int trackId;
67     char *trackTitle;
68     int trackNumber;
69     float trackLength;
70     char *trackFileName;
71     char *trackFileKey;
72     int trackFileSize;
73     char *downloadURL;
74     char *playURL;
75     int albumId;
76     char *albumTitle;
77     int albumYear;
78     char *artistName;
79     int artistId;
80 } mp3tunes_locker_track_t;
81 
82 typedef struct {
83     int artistId;
84     char* artistName;
85     int artistSize;
86     int albumCount;
87     int trackCount;
88 } mp3tunes_locker_artist_t;
89 
90 typedef struct {
91     int albumId;
92     char *albumTitle;
93     int artistId;
94     char *artistName;
95     int trackCount;
96     int albumSize;
97     int hasArt;
98 } mp3tunes_locker_album_t;
99 
100 typedef struct {
101     char* playlistId;
102     char* playlistTitle;
103     char* title;
104     char* fileName;
105     int fileCount;
106     int playlistSize;
107 } mp3tunes_locker_playlist_t;
108 
109 int mp3tunes_locker_init( mp3tunes_locker_object_t **obj, const char *partner_token );
110 int mp3tunes_locker_deinit( mp3tunes_locker_object_t **obj );
111 int mp3tunes_locker_login( mp3tunes_locker_object_t *obj, const char* username, const char* password );
112 int mp3tunes_locker_session_valid( mp3tunes_locker_object_t *obj );
113 int mp3tunes_locker_artists( mp3tunes_locker_object_t *obj, mp3tunes_locker_artist_list_t **artists_return);
114 int mp3tunes_locker_artists_search( mp3tunes_locker_object_t *obj, mp3tunes_locker_artist_list_t **artists_return, char *query);
115 int mp3tunes_locker_albums_with_artist_id( mp3tunes_locker_object_t *obj, mp3tunes_locker_album_list_t **albums_return, int artist_id);
116 int mp3tunes_locker_albums( mp3tunes_locker_object_t *obj, mp3tunes_locker_album_list_t **albums_return);
117 int mp3tunes_locker_albums_search(  mp3tunes_locker_object_t *obj, mp3tunes_locker_album_list_t **albums_return, char *query);
118 int mp3tunes_locker_playlists(mp3tunes_locker_object_t *obj, mp3tunes_locker_playlist_list_t **playlist_return);
119 int mp3tunes_locker_search(mp3tunes_locker_object_t *obj, mp3tunes_locker_artist_list_t **artists_return, mp3tunes_locker_album_list_t **albums_return, mp3tunes_locker_track_list_t **tracks_return, const char *query);
120 
121 int mp3tunes_locker_tracks( mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks_return);
122 int mp3tunes_locker_tracks_search( mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks_return, char *query);
123 int mp3tunes_locker_tracks_with_playlist_id( mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks_return, const char* playlist_id);
124 int mp3tunes_locker_tracks_with_album_id( mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks_return, int album_id);
125 int mp3tunes_locker_tracks_with_artist_id( mp3tunes_locker_object_t *obj, mp3tunes_locker_track_list_t **tracks_return, int artist_id);
126 int mp3tunes_locker_tracks_with_file_key( mp3tunes_locker_object_t *obj, const char *file_keys, mp3tunes_locker_track_list_t **tracks );
127 int mp3tunes_locker_track_with_file_key( mp3tunes_locker_object_t *obj, const char *file_key, mp3tunes_locker_track_t **track );
128 
129 int mp3tunes_locker_track_list_deinit( mp3tunes_locker_track_list_t** list );
130 int mp3tunes_locker_artist_list_deinit( mp3tunes_locker_track_list_t** list );
131 int mp3tunes_locker_album_list_deinit( mp3tunes_locker_track_list_t** list );
132 int mp3tunes_locker_playlist_list_deinit( mp3tunes_locker_track_list_t** list );
133 
134 char* mp3tunes_locker_generate_download_url_from_file_key(mp3tunes_locker_object_t *obj, char *file_key);
135 char* mp3tunes_locker_generate_download_url_from_file_key_and_bitrate(mp3tunes_locker_object_t *obj, char *file_key, char* bitrate);
136 
137 char* mp3tunes_locker_generate_filekey(const char *filename);
138 int mp3tunes_locker_upload_track(mp3tunes_locker_object_t *obj, const char *path);
139 int mp3tunes_locker_load_track(mp3tunes_locker_object_t *obj, const char *url);
140 
141 int mp3tunes_locker_sync_down(mp3tunes_locker_object_t *obj, char* type, char* bytes_local, char* files_local, char* keep_local_files, char* playlist_id);
142 #endif
143