From 31cfba1a216fa300aaa30f9841e2336a32a8c704 Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Wed, 20 May 2009 01:31:34 +0000 Subject: [PATCH] * More changes to pass the UPnP Device Validator. --- upnpdescgen.c | 2 ++ upnphttp.c | 40 ++++++++++++++++++++++++++-------------- upnpsoap.c | 26 ++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/upnpdescgen.c b/upnpdescgen.c index 4893759..f4b438c 100644 --- a/upnpdescgen.c +++ b/upnpdescgen.c @@ -426,7 +426,9 @@ static const struct action X_MS_MediaReceiverRegistrarActions[] = { {"IsAuthorized", GetIsAuthorizedArgs}, /* R */ {"IsValidated", GetIsValidatedArgs}, /* R */ +#if 0 // Not needed? WMP12 still works. Need to check with 360 and WMP11. {"RegisterDevice", GetRegisterDeviceArgs}, /* R */ +#endif {0, 0} }; diff --git a/upnphttp.c b/upnphttp.c index 3d6defc..4d01785 100644 --- a/upnphttp.c +++ b/upnphttp.c @@ -160,14 +160,26 @@ ParseHttpHeaders(struct upnphttp * h) } else if(strncasecmp(line, "SID", 3)==0) { - p = colon + 1; - while(isspace(*p)) - p++; - n = 0; - while(!isspace(p[n])) - n++; - h->req_SID = p; - h->req_SIDLen = n; + //zqiu: fix bug for test 4.0.5 + //Skip the extra header like "SIDHEADER: xxxxxx xxx" + for(p=line+3;preq_SID = p; + h->req_SIDLen = n; + } } /* Timeout: Seconds-nnnn */ /* TIMEOUT @@ -892,12 +904,12 @@ BuildHeader_upnphttp(struct upnphttp * h, int respcode, h->res_buflen += snprintf(h->res_buf + h->res_buflen, h->res_buf_alloclen - h->res_buflen, "Date: %s\r\n", szTime); -// h->res_buflen += snprintf(h->res_buf + h->res_buflen, -// h->res_buf_alloclen - h->res_buflen, -// "contentFeatures.dlna.org: \r\n"); -// h->res_buflen += snprintf(h->res_buf + h->res_buflen, -// h->res_buf_alloclen - h->res_buflen, -// "EXT:\r\n"); + h->res_buflen += snprintf(h->res_buf + h->res_buflen, + h->res_buf_alloclen - h->res_buflen, + "contentFeatures.dlna.org: \r\n"); + h->res_buflen += snprintf(h->res_buf + h->res_buflen, + h->res_buf_alloclen - h->res_buflen, + "EXT:\r\n"); #endif h->res_buf[h->res_buflen++] = '\r'; h->res_buf[h->res_buflen++] = '\n'; diff --git a/upnpsoap.c b/upnpsoap.c index 49b39ea..b6d852a 100644 --- a/upnpsoap.c +++ b/upnpsoap.c @@ -786,8 +786,23 @@ BrowseContentDirectory(struct upnphttp * h, const char * action) char * BrowseFlag = GetValueFromNameValueList(&data, "BrowseFlag"); char * SortCriteria = GetValueFromNameValueList(&data, "SortCriteria"); char * orderBy = NULL; + if( !BrowseFlag || (strcmp(BrowseFlag, "BrowseDirectChildren") && strcmp(BrowseFlag, "BrowseMetadata")) ) + { + SoapError(h, 402, "Invalid Args"); + if( h->req_client == EXbox ) + ObjectId = malloc(1); + goto browse_error; + } if( !ObjectId ) - ObjectId = GetValueFromNameValueList(&data, "ContainerID"); + { + if( !(ObjectId = GetValueFromNameValueList(&data, "ContainerID")) ) + { + SoapError(h, 701, "No such object error"); + if( h->req_client == EXbox ) + ObjectId = malloc(1); + goto browse_error; + } + } memset(&args, 0, sizeof(args)); if( !RequestedCount ) @@ -830,7 +845,7 @@ BrowseContentDirectory(struct upnphttp * h, const char * action) ObjectId, RequestedCount, StartingIndex, BrowseFlag, Filter, SortCriteria); - if( BrowseFlag && (strcmp(BrowseFlag, "BrowseMetadata") == 0) ) + if( strcmp(BrowseFlag+6, "Metadata") == 0 ) { args.requested = 1; sql = sqlite3_mprintf( SELECT_COLUMNS @@ -941,6 +956,13 @@ SearchContentDirectory(struct upnphttp * h, const char * action) char * newSearchCriteria = NULL; char * orderBy = NULL; char groupBy[] = "group by DETAIL_ID"; + if( !ContainerID ) + { + SoapError(h, 701, "No such object error"); + if( h->req_client == EXbox ) + ContainerID = malloc(1); + goto search_error; + } memset(&args, 0, sizeof(args)); if( !RequestedCount )