@@ -96,6 +96,12 @@ class MediaServer : public DLNADeviceInfo {
9696  // / Provides access to the http server
9797  HttpServer* getHttpServer () { return  p_server; }
9898
99+   // / Provides access to the system update ID
100+   int  getSystemUpdateID () { return  g_stream_updateID; }
101+   
102+   // / Increments and returns the SystemUpdateID
103+   int  incrementSystemUpdateID () { return  ++g_stream_updateID; }
104+ 
99105 protected: 
100106  static  inline  MediaServer* p_media_server = nullptr ;
101107  const  char * st = " urn:schemas-upnp-org:device:MediaServer:1" 
@@ -114,7 +120,7 @@ class MediaServer : public DLNADeviceInfo {
114120  const  char * g_search_capabiities =
115121      " dc:title,dc:creator,upnp:class,upnp:genre," 
116122      " upnp:album,upnp:artist,upnp:albumArtURI" 
117-   const  char * g_sort_capabilities = " " 
123+   const  char * g_sort_capabilities = " dc:title " 
118124
119125  void  setupServicesImpl (HttpServer* server) {
120126    DlnaLogger.log (DlnaLogLevel::Info, " MediaServer::setupServices" 
@@ -153,15 +159,20 @@ class MediaServer : public DLNADeviceInfo {
153159  bool  processAction (ActionRequest& action, HttpServer& server) {
154160    DlnaLogger.log (DlnaLogLevel::Info, " processAction" 
155161    StrView action_str (action.action );
156-     if  (StrView (action.action ).equals (" Browse" 
162+     if  (action_str.isEmpty ()){
163+       DlnaLogger.log (DlnaLogLevel::Error, " Empty action received" 
164+       server.replyNotFound ();
165+       return  false ;
166+     }
167+     if  (action_str.endsWith (" Browse" 
157168      return  processActionBrowse (action, server);
158-     } else  if  (action_str.equals (" Search" 
169+     } else  if  (action_str.endsWith (" Search" 
159170      return  processActionSearch (action, server);
160-     } else  if  (action_str.equals (" GetSearchCapabilities" 
171+     } else  if  (action_str.endsWith (" GetSearchCapabilities" 
161172      return  processActionGetSearchCapabilities (action, server);
162-     } else  if  (action_str.equals (" GetSortCapabilities" 
173+     } else  if  (action_str.endsWith (" GetSortCapabilities" 
163174      return  processActionGetSortCapabilities (action, server);
164-     } else  if  (action_str.equals (" GetSystemUpdateID" 
175+     } else  if  (action_str.endsWith (" GetSystemUpdateID" 
165176      return  processActionGetSystemUpdateID (action, server);
166177    } else  {
167178      DlnaLogger.log (DlnaLogLevel::Error, " Unsupported action: %s" 
@@ -231,36 +242,37 @@ class MediaServer : public DLNADeviceInfo {
231242
232243  bool  processActionGetSearchCapabilities (ActionRequest& action,
233244                                          HttpServer& server) {
234-     DlnaLogger.log (DlnaLogLevel::Info, " processActionGetSearchCapabilities" 
235245    Str reply_str{replyTemplate ()};
236-     reply_str.replaceAll (" %2 " " ContentDirectory " 
237-     reply_str.replaceAll (" %1 " " ActionResponse " 
246+     reply_str.replaceAll (" %1 " " GetSearchCapabilitiesResponse " 
247+     reply_str.replaceAll (" %2 " " SearchCaps " 
238248    reply_str.replaceAll (" %3" 
239249    server.reply (" text/xml" c_str ());
250+     DlnaLogger.log (DlnaLogLevel::Info, " processActionGetSearchCapabilities: %s" c_str ());
240251    return  true ;
241252  }
242253
243254  bool  processActionGetSortCapabilities (ActionRequest& action,
244255                                        HttpServer& server) {
245-     DlnaLogger.log (DlnaLogLevel::Info, " processActionGetSortCapabilities" 
246256    Str reply_str{replyTemplate ()};
247-     reply_str.replaceAll (" %2" " ContentDirectory " 
248-     reply_str.replaceAll (" %1" " ActionResponse " 
257+     reply_str.replaceAll (" %2" " SortCaps " 
258+     reply_str.replaceAll (" %1" " GetSortCapabilitiesResponse " 
249259    reply_str.replaceAll (" %3" 
250260    server.reply (" text/xml" c_str ());
261+ 
262+     DlnaLogger.log (DlnaLogLevel::Info, " processActionGetSortCapabilities: %s" c_str ());
251263    return  true ;
252264  }
253265
254266  bool  processActionGetSystemUpdateID (ActionRequest& action,
255267                                      HttpServer& server) {
256-     DlnaLogger.log (DlnaLogLevel::Info, " processActionGetSystemUpdateID" 
257268    Str reply_str{replyTemplate ()};
258269    char  update_id_str[80 ];
259270    sprintf (update_id_str, " %d" 
260-     reply_str.replaceAll (" %2" " ContentDirectory " 
261-     reply_str.replaceAll (" %1" " ActionResponse " 
271+     reply_str.replaceAll (" %2" " Id " 
272+     reply_str.replaceAll (" %1" " GetSystemUpdateIDResponse " 
262273    reply_str.replaceAll (" %3" 
263274    server.reply (" text/xml" c_str ());
275+     DlnaLogger.log (DlnaLogLevel::Info, " processActionGetSystemUpdateID: %s" c_str ());
264276    return  true ;
265277  }
266278
@@ -357,13 +369,13 @@ class MediaServer : public DLNADeviceInfo {
357369  }
358370
359371  // / generic SOAP reply template with placeholders: %1 = ActionResponse, %2 =
360-   // / ServiceName , %3 = inner payload
372+   // / payload tag , %3 = inner payload
361373  static  const  char * replyTemplate () {
362374    static  const  char * tpl =
363375        " <s:Envelope xmlns:s=\" http://schemas.xmlsoap.org/soap/envelope/\" " 
364376        "  s:encodingStyle=\" http://schemas.xmlsoap.org/soap/encoding/\" >" 
365377        " <s:Body><u:%1 " 
366-         " xmlns:u=\" urn:schemas-upnp-org:service:%2 :1\" >%3 </u:%1></s:Body></" 
378+         " xmlns:u=\" urn:schemas-upnp-org:service:ContentDirectory :1\" ><%2>%3</%2> </u:%1></s:Body></" 
367379        " s:Envelope>" 
368380    return  tpl;
369381  }
@@ -436,7 +448,6 @@ class MediaServer : public DLNADeviceInfo {
436448    xml.printNodeEnd (responseName, " u" 
437449    xml.printNodeEnd (" Body" " s" 
438450    xml.printNodeEnd (" Envelope" " s" 
439-     p_media_server->g_stream_updateID ++;
440451  }
441452
442453  //  helper: stream DIDL-Lite (escaped) for the provided items to the Print
0 commit comments