diff options
author | Justin Maggard <jmaggard@users.sourceforge.net> | 2009-02-24 02:10:27 +0300 |
---|---|---|
committer | Justin Maggard <jmaggard@users.sourceforge.net> | 2009-02-24 02:10:27 +0300 |
commit | 0212b7ced1220936dc7c14f4358bed5dc65dea17 (patch) | |
tree | 4d16db0920e2f387ffeb8fe72ab5f5d6d40c5556 /tivo_commands.c | |
parent | 3202e6e3587e3b733d399afe2c013e25c40f08d2 (diff) |
* Add some preliminary code for the eventual possibility of TiVo support.
Diffstat (limited to 'tivo_commands.c')
-rw-r--r-- | tivo_commands.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/tivo_commands.c b/tivo_commands.c new file mode 100644 index 0000000..37ebb7c --- /dev/null +++ b/tivo_commands.c @@ -0,0 +1,95 @@ +#ifdef ENABLE_TIVO +#include <stdio.h> +#include <string.h> + +#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, "<?xml version='1.0' encoding='UTF-8' ?>\n" + "<TiVoContainer>" + "<Details>" + "<ContentType>x-container/tivo-server</ContentType>" + "<SourceFormat>x-container/folder</SourceFormat>" + "<TotalDuration>0</TotalDuration>" + "<TotalItems>2</TotalItems>" + "<Title>%s</Title>" + "</Details>" + "<ItemStart>0</ItemStart>" + "<ItemCount>2</ItemCount>" + "<Item>" + "<Details>" + "<ContentType>x-container/tivo-photos</ContentType>" + "<SourceFormat>x-container/folder</SourceFormat>" + "<Title>Pictures</Title>" + "</Details>" + "<Links>" + "<Content>" + "<Url>/TiVoConnect?Command=QueryContainer&Container=3</Url>" + "</Content>" + "</Links>" + "</Item>" + "<Item>" + "<Details>" + "<ContentType>x-container/tivo-music</ContentType>" + "<SourceFormat>x-container/folder</SourceFormat>" + "<Title>Music</Title>" + "</Details>" + "<Links>" + "<Content>" + "<Url>/TiVoConnect?Command=QueryContainer&Container=1</Url>" + "</Content>" + "</Links>" + "</Item>" + "</TiVoContainer>", 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 |