#ifdef ENABLE_TIVO #include #include #include "tivo_utils.h" #include "upnpglobalvars.h" #include "upnphttp.h" #include "log.h" void SendRootContainer(struct upnphttp * h) { char * resp; int len; len = asprintf(&resp, "\n" "" "
" "x-container/tivo-server" "x-container/folder" "0" "2" "%s" "
" "0" "2" "" "
" "x-container/tivo-photos" "x-container/folder" "Pictures" "
" "" "" "/TiVoConnect?Command=QueryContainer&Container=3" "" "" "
" "" "
" "x-container/tivo-music" "x-container/folder" "Music" "
" "" "" "/TiVoConnect?Command=QueryContainer&Container=1" "" "" "
" "
", friendly_name); BuildResp_upnphttp(h, resp, len); SendResp_upnphttp(h); } void ProcessTiVoCommand(struct upnphttp * h, const char * orig_path) { char *path; char *key, *val; char *saveptr, *item; char *command = NULL, *container = NULL; path = decodeString(orig_path); DPRINTF(E_DEBUG, L_GENERAL, "Processing TiVo command %s\n", path); item = strtok_r( path, "&", &saveptr ); while( item != NULL ) { if( strlen( item ) == 0 ) { item = strtok_r( NULL, "&", &saveptr ); continue; } val = item; key = strsep(&val, "="); DPRINTF(E_DEBUG, L_GENERAL, "%s: %s\n", key, val); if( strcasecmp(key, "command") == 0 ) { command = val; } else if( strcasecmp(key, "container") == 0 ) { container = val; } item = strtok_r( NULL, "&", &saveptr ); } if( !container || (strcmp(container, "/") == 0) ) { SendRootContainer(h); } CloseSocket_upnphttp(h); } #endif // ENABLE_TIVO