Add status updates

This commit is contained in:
Ron Pedde 2003-11-14 04:56:20 +00:00
parent 10de50ce0b
commit d780313965
1 changed files with 19 additions and 0 deletions

View File

@ -74,6 +74,7 @@ void daap_handler(WS_CONNINFO *pwsc) {
MP3FILE *pmp3; MP3FILE *pmp3;
int file_fd; int file_fd;
int session_id=0;
close=pwsc->close; close=pwsc->close;
pwsc->close=1; /* in case we have any errors */ pwsc->close=1; /* in case we have any errors */
@ -83,24 +84,34 @@ void daap_handler(WS_CONNINFO *pwsc) {
ws_addresponseheader(pwsc,"DAAP-Server","iTunes/4.1 (Mac OS X)"); ws_addresponseheader(pwsc,"DAAP-Server","iTunes/4.1 (Mac OS X)");
ws_addresponseheader(pwsc,"Content-Type","application/x-dmap-tagged"); ws_addresponseheader(pwsc,"Content-Type","application/x-dmap-tagged");
if(ws_getvar(pwsc,"session-id")) {
session_id=atoi(ws_getvar(pwsc,"session-id"));
}
if(!strcasecmp(pwsc->uri,"/server-info")) { if(!strcasecmp(pwsc->uri,"/server-info")) {
config_set_status(pwsc,session_id,"Sending server info");
root=daap_response_server_info(); root=daap_response_server_info();
} else if (!strcasecmp(pwsc->uri,"/content-codes")) { } else if (!strcasecmp(pwsc->uri,"/content-codes")) {
config_set_status(pwsc,session_id,"Sending content codes");
root=daap_response_content_codes(); root=daap_response_content_codes();
} else if (!strcasecmp(pwsc->uri,"/login")) { } else if (!strcasecmp(pwsc->uri,"/login")) {
config_set_status(pwsc,session_id,"Logging in");
root=daap_response_login(); root=daap_response_login();
} else if (!strcasecmp(pwsc->uri,"/update")) { } else if (!strcasecmp(pwsc->uri,"/update")) {
if(!ws_getvar(pwsc,"delta")) { /* first check */ if(!ws_getvar(pwsc,"delta")) { /* first check */
clientrev=db_version() - 1; clientrev=db_version() - 1;
config_set_status(pwsc,session_id,"Sending database");
} else { } else {
clientrev=atoi(ws_getvar(pwsc,"delta")); clientrev=atoi(ws_getvar(pwsc,"delta"));
config_set_status(pwsc,session_id,"Waiting for DB updates");
} }
root=daap_response_update(clientrev); root=daap_response_update(clientrev);
} else if (!strcasecmp(pwsc->uri,"/logout")) { } else if (!strcasecmp(pwsc->uri,"/logout")) {
config_set_status(pwsc,session_id,NULL);
ws_returnerror(pwsc,204,"Logout Successful"); ws_returnerror(pwsc,204,"Logout Successful");
return; return;
} else if(strcmp(pwsc->uri,"/databases")==0) { } else if(strcmp(pwsc->uri,"/databases")==0) {
config_set_status(pwsc,session_id,"Sending database info");
root=daap_response_dbinfo(); root=daap_response_dbinfo();
} else if(strncmp(pwsc->uri,"/databases/",11) == 0) { } else if(strncmp(pwsc->uri,"/databases/",11) == 0) {
@ -141,6 +152,7 @@ void daap_handler(WS_CONNINFO *pwsc) {
/* songlist */ /* songlist */
free(uri); free(uri);
root=daap_response_songlist(); root=daap_response_songlist();
config_set_status(pwsc,session_id,"Sending songlist");
} else if (strncasecmp(last,"containers/",11)==0) { } else if (strncasecmp(last,"containers/",11)==0) {
/* playlist elements */ /* playlist elements */
first=last + 11; first=last + 11;
@ -155,16 +167,19 @@ void daap_handler(WS_CONNINFO *pwsc) {
root=daap_response_playlist_items(playlist_index); root=daap_response_playlist_items(playlist_index);
} }
free(uri); free(uri);
config_set_status(pwsc,session_id,"Sending playlist info");
} else if (strncasecmp(last,"containers",10)==0) { } else if (strncasecmp(last,"containers",10)==0) {
/* list of playlists */ /* list of playlists */
free(uri); free(uri);
root=daap_response_playlists(); root=daap_response_playlists();
config_set_status(pwsc,session_id,"Sending playlist info");
} }
} }
} }
if((!root)&&(!streaming)) { if((!root)&&(!streaming)) {
ws_returnerror(pwsc,400,"Invalid Request"); ws_returnerror(pwsc,400,"Invalid Request");
config_set_status(pwsc,session_id,NULL);
return; return;
} }
@ -199,12 +214,16 @@ void daap_handler(WS_CONNINFO *pwsc) {
DPRINTF(ERR_WARN,"Thread %d: Error opening %s: %s\n", DPRINTF(ERR_WARN,"Thread %d: Error opening %s: %s\n",
pwsc->threadno,pmp3->path,strerror(errno)); pwsc->threadno,pmp3->path,strerror(errno));
ws_returnerror(pwsc,404,"Not found"); ws_returnerror(pwsc,404,"Not found");
config_set_status(pwsc,session_id,NULL);
} else { } else {
ws_writefd(pwsc,"HTTP/1.1 200 OK\r\n"); ws_writefd(pwsc,"HTTP/1.1 200 OK\r\n");
ws_addresponseheader(pwsc,"Connection","Close"); ws_addresponseheader(pwsc,"Connection","Close");
ws_emitheaders(pwsc); ws_emitheaders(pwsc);
config_set_status(pwsc,session_id,"Streaming file '%s'",pmp3->fname);
copyfile(file_fd,pwsc->fd); copyfile(file_fd,pwsc->fd);
config_set_status(pwsc,session_id,NULL);
r_close(file_fd); r_close(file_fd);
} }
} }