sd: split services_discovery_AddItem()
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 14 May 2017 07:36:07 +0000 (10:36 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 14 May 2017 15:44:12 +0000 (18:44 +0300)
Add a separate callback wrapper for item with category, which is long
since deprecated. Remove the category parameter from the normal
callback wrapper.

16 files changed:
include/vlc_services_discovery.h
modules/access/dsm/sd.c
modules/lua/libs/sd.c
modules/services_discovery/avahi.c
modules/services_discovery/bonjour.m
modules/services_discovery/mediadirs.c
modules/services_discovery/microdns.c
modules/services_discovery/mtp.c
modules/services_discovery/os2drive.c
modules/services_discovery/podcast.c
modules/services_discovery/pulse.c
modules/services_discovery/sap.c
modules/services_discovery/udev.c
modules/services_discovery/upnp.cpp
modules/services_discovery/windrive.c
modules/services_discovery/xcb_apps.c

index 8f8a55b..1456a89 100644 (file)
@@ -159,12 +159,23 @@ VLC_API void vlc_sd_Destroy( services_discovery_t * );
  *
  * @param sd services discoverer / services discovery module instance
  * @param item input item to add
+ */
+static inline void services_discovery_AddItem(services_discovery_t *sd,
+                                              input_item_t *item)
+{
+    return sd->owner.item_added(sd, item, NULL);
+}
+
+/**
+ * Added service backward compatibility callback.
+ *
  * @param category Optional name of a group that the item belongs in
  *                 (for backward compatibility with legacy modules)
  */
-static inline void services_discovery_AddItem(services_discovery_t *sd,
-                                              input_item_t *item,
-                                              const char *category)
+VLC_DEPRECATED
+static inline void services_discovery_AddItemCat(services_discovery_t *sd,
+                                                 input_item_t *item,
+                                                 const char *category)
 {
     return sd->owner.item_added(sd, item, category);
 }
index b6252fd..94129dc 100644 (file)
@@ -69,7 +69,7 @@ static void entry_item_append( services_discovery_t *p_sd,
     p_entry_item->p_item = p_item;
     input_item_Hold( p_item );
     vlc_array_append( &p_sys->entry_item_list, p_entry_item );
-    services_discovery_AddItem( p_sd, p_item, NULL );
+    services_discovery_AddItem( p_sd, p_item );
 }
 
 static void entry_item_remove( services_discovery_t *p_sd,
index e8561fc..455547a 100644 (file)
@@ -337,9 +337,9 @@ static int vlclua_sd_add_common( services_discovery_t *p_sd, lua_State *L,
 
     lua_getfield( L, -2, "category" );
     if( lua_isstring( L, -1 ) )
-        services_discovery_AddItem( p_sd, p_input, luaL_checkstring( L, -1 ) );
+        services_discovery_AddItemCat( p_sd, p_input, luaL_checkstring( L, -1 ) );
     else
-        services_discovery_AddItem( p_sd, p_input, NULL );
+        services_discovery_AddItem( p_sd, p_input );
     lua_pop( L, 1 );
 
     return 1;
index 3026b7a..bf19ad6 100644 (file)
@@ -205,7 +205,7 @@ static void resolve_callback(
         {
             vlc_dictionary_insert( &p_sys->services_name_to_input_item,
                 name, p_input );
-            services_discovery_AddItem( p_sd, p_input, NULL /* no category */ );
+            services_discovery_AddItem( p_sd, p_input );
             input_item_Release( p_input );
        }
     }
index 3e20382..03552ae 100644 (file)
@@ -331,7 +331,7 @@ NSString *const VLCBonjourRendererDemux         = @"VLCBonjourRendererDemux";
     NSString *uri = [NSString stringWithFormat:@"%@://%@:%ld", protocol, netService.hostName, netService.port];
     input_item_t *p_input_item = input_item_NewDirectory([uri UTF8String], [netService.name UTF8String], ITEM_NET );
     if (p_input_item != NULL) {
-        services_discovery_AddItem( p_sd, p_input_item, NULL);
+        services_discovery_AddItem(p_sd, p_input_item);
         [_inputItemsForNetServices addObject:[NSValue valueWithPointer:p_input_item]];
         [_resolvedNetServices addObject:netService];
     }
index 2dd2ab2..1a8e5fa 100644 (file)
@@ -254,7 +254,7 @@ static void input_item_subitem_added( const vlc_event_t * p_event,
     if( p_sys->i_type == Picture )
         formatSnapshotItem( p_item );
 
-    services_discovery_AddItem( p_sd, p_item, NULL );
+    services_discovery_AddItem( p_sd, p_item );
 }
 
 static int onNewFileAdded( vlc_object_t *p_this, char const *psz_var,
@@ -278,7 +278,7 @@ static int onNewFileAdded( vlc_object_t *p_this, char const *psz_var,
         if( fileType( p_sd, psz_file ) == Picture )
         {
             formatSnapshotItem( p_item );
-            services_discovery_AddItem( p_sd, p_item, NULL );
+            services_discovery_AddItem( p_sd, p_item );
 
             msg_Dbg( p_sd, "New snapshot added : %s", psz_file );
         }
@@ -287,7 +287,7 @@ static int onNewFileAdded( vlc_object_t *p_this, char const *psz_var,
     {
         if( fileType( p_sd, psz_file ) == Audio )
         {
-            services_discovery_AddItem( p_sd, p_item, NULL );
+            services_discovery_AddItem( p_sd, p_item );
 
             msg_Dbg( p_sd, "New recorded audio added : %s", psz_file );
         }
@@ -297,7 +297,7 @@ static int onNewFileAdded( vlc_object_t *p_this, char const *psz_var,
         if( fileType( p_sd, psz_file ) == Video ||
             fileType( p_sd, psz_file ) == Unknown )
         {
-            services_discovery_AddItem( p_sd, p_item, NULL );
+            services_discovery_AddItem( p_sd, p_item );
 
             msg_Dbg( p_sd, "New recorded video added : %s", psz_file );
         }
index b68df77..7fe5feb 100644 (file)
@@ -175,7 +175,7 @@ items_add_input( struct discovery_sys *p_sys, services_discovery_t *p_sd,
     p_item->p_renderer_item = NULL;
     p_item->i_last_seen = mdate();
     vlc_array_append( &p_sys->items, p_item );
-    services_discovery_AddItem( p_sd, p_input_item, NULL );
+    services_discovery_AddItem( p_sd, p_input_item );
 
     return VLC_SUCCESS;
 }
index 0beaee7..e79d04a 100644 (file)
@@ -267,7 +267,7 @@ static void AddTrack( services_discovery_t *p_sd, LIBMTP_track_t *p_track )
     }
     input_item_SetDate( p_input, p_track->date );
     input_item_SetDuration( p_input, p_track->duration * 1000 );
-    services_discovery_AddItem( p_sd, p_input, NULL );
+    services_discovery_AddItem( p_sd, p_input );
     p_sd->p_sys->pp_items[p_sd->p_sys->i_count++] = p_input;
 }
 
index e04728a..3634360 100644 (file)
@@ -95,7 +95,7 @@ static int Open (vlc_object_t *obj)
             if (item == NULL)
                 break;
 
-            services_discovery_AddItem (sd, item, NULL);
+            services_discovery_AddItem (sd, item);
         }
     }
 
index 313e92c..ba61c80 100644 (file)
@@ -327,7 +327,7 @@ static void ParseUrls( services_discovery_t *p_sd, char *psz_urls )
             input_item_AddOption( p_input, "demux=podcast", VLC_INPUT_OPTION_TRUSTED );
 
             INSERT_ELEM( pp_new_items, i_new_items, i_new_items, p_input );
-            services_discovery_AddItem( p_sd, p_input, NULL /* no cat */ );
+            services_discovery_AddItem( p_sd, p_input );
 
             INSERT_ELEM( p_sys->pp_input, p_sys->i_input, p_sys->i_input,
                          input_CreateAndStart( p_sd, p_input, NULL ) );
@@ -402,7 +402,7 @@ static void ParseRequest( services_discovery_t *p_sd )
             input_item_AddOption( p_input, "demux=podcast", VLC_INPUT_OPTION_TRUSTED );
 
             INSERT_ELEM( p_sys->pp_items, p_sys->i_items, p_sys->i_items, p_input );
-            services_discovery_AddItem( p_sd, p_input, NULL /* no cat */ );
+            services_discovery_AddItem( p_sd, p_input );
 
             INSERT_ELEM( p_sys->pp_input, p_sys->i_input, p_sys->i_input,
                          input_CreateAndStart( p_sd, p_input, NULL ) );
index 2dd1ddd..2c0771d 100644 (file)
@@ -181,8 +181,8 @@ static int AddSource (services_discovery_t *sd, const pa_source_info *info)
     }
 
     const char *card = pa_proplist_gets(info->proplist, "device.product.name");
-    services_discovery_AddItem (sd, item,
-                                (card != NULL) ? card : N_("Generic"));
+    services_discovery_AddItemCat(sd, item,
+                                  (card != NULL) ? card : N_("Generic"));
     d->sd = sd;
     return 0;
 }
index 6fc5971..48729c6 100644 (file)
@@ -900,7 +900,7 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint32_t *i_source,
         if (likely(str != NULL))
             for (char *p = strchr(str, '.'); p != NULL; p = strchr(p, '.'))
                 *(p++) = '|';
-        services_discovery_AddItem(p_sd, p_input, str ? str : psz_value);
+        services_discovery_AddItemCat(p_sd, p_input, str ? str : psz_value);
         free(str);
     }
     else
@@ -908,7 +908,7 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint32_t *i_source,
         /* backward compatibility with VLC 0.7.3-2.0.0 senders */
         psz_value = GetAttribute(p_sap->p_sdp->pp_attributes,
                                  p_sap->p_sdp->i_attributes, "x-plgroup");
-        services_discovery_AddItem(p_sd, p_input, psz_value);
+        services_discovery_AddItemCat(p_sd, p_input, psz_value);
     }
 
     TAB_APPEND( p_sys->i_announces, p_sys->pp_announces, p_sap );
index 0fd5824..f4359aa 100644 (file)
@@ -198,7 +198,7 @@ static int AddDevice (services_discovery_t *sd, struct udev_device *dev)
         *dp = d;
     }
 
-    services_discovery_AddItem (sd, item, NULL);
+    services_discovery_AddItem(sd, item);
     d->sd = sd;
     return 0;
 }
index 93aa299..ba61a75 100644 (file)
@@ -344,7 +344,7 @@ bool MediaServerList::addServer( MediaServerDesc* desc )
         input_item_SetArtworkURL( p_input_item, desc->iconUrl.c_str() );
     desc->inputItem = p_input_item;
     input_item_SetDescription( p_input_item, desc->UDN.c_str() );
-    services_discovery_AddItem( m_sd, p_input_item, NULL );
+    services_discovery_AddItem( m_sd, p_input_item );
     m_list.push_back( desc );
 
     return true;
index 8d47628..922d497 100644 (file)
@@ -81,7 +81,7 @@ static int Open (vlc_object_t *obj)
         if (item == NULL)
             break;
 
-        services_discovery_AddItem (sd, item, NULL);
+        services_discovery_AddItem(sd, item);
     }
     return VLC_SUCCESS;
 }
index fcb9caa..da13db1 100644 (file)
@@ -272,7 +272,7 @@ static struct app *AddApp (services_discovery_t *sd, xcb_window_t xid)
     app->xid = xid;
     app->item = item;
     app->owner = sd;
-    services_discovery_AddItem (sd, item, _("Applications"));
+    services_discovery_AddItemCat(sd, item, _("Applications"));
     return app;
 }
 
@@ -352,6 +352,6 @@ static void AddDesktop(services_discovery_t *sd)
     if (item == NULL)
         return;
 
-    services_discovery_AddItem (sd, item, NULL);
+    services_discovery_AddItem(sd, item);
     input_item_Release (item);
 }