[vlc-commits] sd: add description field

Rémi Denis-Courmont git at videolan.org
Tue Nov 15 19:02:05 CET 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Nov 15 19:10:44 2016 +0200| [ce3a8f4b2242dca83e1c5bd7dc560f493d91f8ee] | committer: Rémi Denis-Courmont

sd: add description field

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ce3a8f4b2242dca83e1c5bd7dc560f493d91f8ee
---

 include/vlc_services_discovery.h       |  2 ++
 modules/access/dsm/sd.c                |  1 +
 modules/lua/services_discovery.c       |  9 +++++++++
 modules/services_discovery/avahi.c     |  2 ++
 modules/services_discovery/bonjour.m   |  2 ++
 modules/services_discovery/mediadirs.c |  6 ++++++
 modules/services_discovery/microdns.c  |  1 +
 modules/services_discovery/mtp.c       |  1 +
 modules/services_discovery/os2drive.c  |  2 ++
 modules/services_discovery/podcast.c   |  1 +
 modules/services_discovery/pulse.c     |  1 +
 modules/services_discovery/sap.c       |  1 +
 modules/services_discovery/udev.c      | 11 ++++++++---
 modules/services_discovery/upnp.cpp    |  2 ++
 modules/services_discovery/windrive.c  |  2 ++
 modules/services_discovery/xcb_apps.c  |  1 +
 src/playlist/services_discovery.c      |  1 +
 17 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/include/vlc_services_discovery.h b/include/vlc_services_discovery.h
index ffc2cd4..d581cfc 100644
--- a/include/vlc_services_discovery.h
+++ b/include/vlc_services_discovery.h
@@ -59,6 +59,8 @@ struct services_discovery_t
     char *psz_name;                           /**< Main name of the SD */
     config_chain_t *p_cfg;                    /**< Configuration for the SD */
 
+    const char *description; /**< Human-readable name */
+
     /** Control function
      * \see services_discovery_command_e
      */
diff --git a/modules/access/dsm/sd.c b/modules/access/dsm/sd.c
index 46d2542..2427ff8 100644
--- a/modules/access/dsm/sd.c
+++ b/modules/access/dsm/sd.c
@@ -135,6 +135,7 @@ int bdsm_SdOpen (vlc_object_t *p_this)
     if( p_sys == NULL )
         return VLC_ENOMEM;
 
+    p_sd->description = _("Windows networks");
     p_sd->p_sys = p_sys;
     p_sys->p_entry_item_list = vlc_array_new();
     if ( p_sys->p_entry_item_list == NULL )
diff --git a/modules/lua/services_discovery.c b/modules/lua/services_discovery.c
index 3efb09e..923f602 100644
--- a/modules/lua/services_discovery.c
+++ b/modules/lua/services_discovery.c
@@ -83,6 +83,15 @@ int Open_LuaSD( vlc_object_t *p_this )
         psz_name = strdup(p_sd->psz_name);
     }
 
+    p_sd->description = p_sd->psz_name;
+
+    for( const config_chain_t *cc = p_sd->p_cfg; cc != NULL; cc = cc->p_next )
+        if( strcmp( cc->psz_name, "longname" ) == 0 )
+        {
+            p_sd->description = cc->psz_value;
+            break;
+        }
+
     if( !( p_sys = malloc( sizeof( services_discovery_sys_t ) ) ) )
     {
         free( psz_name );
diff --git a/modules/services_discovery/avahi.c b/modules/services_discovery/avahi.c
index 94c4f0f..5b8c6fc 100644
--- a/modules/services_discovery/avahi.c
+++ b/modules/services_discovery/avahi.c
@@ -274,6 +274,8 @@ static int Open( vlc_object_t *p_this )
     if( !p_sys )
         return VLC_ENOMEM;
 
+    p_sd->description = _("Zeroconf network services");
+
     vlc_dictionary_init( &p_sys->services_name_to_input_item, 1 );
 
     p_sys->poll = avahi_threaded_poll_new();
diff --git a/modules/services_discovery/bonjour.m b/modules/services_discovery/bonjour.m
index ad4d46e..edb1b0a 100644
--- a/modules/services_discovery/bonjour.m
+++ b/modules/services_discovery/bonjour.m
@@ -226,6 +226,8 @@ static int Open(vlc_object_t *p_this)
         return VLC_ENOMEM;
     }
 
+    p_sd->description = _("Bonjour Network Discovery");
+
     VLCNetServiceDiscoveryController *discoveryController = [[VLCNetServiceDiscoveryController alloc] init];
     discoveryController.p_sd = p_sd;
 
diff --git a/modules/services_discovery/mediadirs.c b/modules/services_discovery/mediadirs.c
index 9b2bf2c..5a219ce 100644
--- a/modules/services_discovery/mediadirs.c
+++ b/modules/services_discovery/mediadirs.c
@@ -120,6 +120,7 @@ static int Open( vlc_object_t *p_this, enum type_e i_type )
 {
     services_discovery_t *p_sd = ( services_discovery_t* )p_this;
     services_discovery_sys_t *p_sys;
+    const char *desc;
 
     p_sd->p_sys = p_sys = calloc( 1, sizeof( *p_sys) );
     if( !p_sys )
@@ -129,6 +130,7 @@ static int Open( vlc_object_t *p_this, enum type_e i_type )
 
     if( p_sys->i_type == Video )
     {
+        desc = N_("My Videos");
         p_sys->psz_dir[0] = config_GetUserDir( VLC_VIDEOS_DIR );
         p_sys->psz_dir[1] = var_CreateGetString( p_sd, "input-record-path" );
 
@@ -136,6 +138,7 @@ static int Open( vlc_object_t *p_this, enum type_e i_type )
     }
     else if( p_sys->i_type == Audio )
     {
+        desc = N_("My Music");
         p_sys->psz_dir[0] = config_GetUserDir( VLC_MUSIC_DIR );
         p_sys->psz_dir[1] = var_CreateGetString( p_sd, "input-record-path" );
 
@@ -143,6 +146,7 @@ static int Open( vlc_object_t *p_this, enum type_e i_type )
     }
     else if( p_sys->i_type == Picture )
     {
+        desc = N_("My Pictures");
         p_sys->psz_dir[0] = config_GetUserDir( VLC_PICTURES_DIR );
         p_sys->psz_dir[1] = var_CreateGetString( p_sd, "snapshot-path" );
 
@@ -154,6 +158,8 @@ static int Open( vlc_object_t *p_this, enum type_e i_type )
         return VLC_EGENERIC;
     }
 
+    p_sd->description = vlc_gettext(desc);
+
     var_AddCallback( p_sd->obj.libvlc, p_sys->psz_var, onNewFileAdded, p_sd );
 
     if( vlc_clone( &p_sys->thread, Run, p_sd, VLC_THREAD_PRIORITY_LOW ) )
diff --git a/modules/services_discovery/microdns.c b/modules/services_discovery/microdns.c
index 19fec74..7727d0d 100644
--- a/modules/services_discovery/microdns.c
+++ b/modules/services_discovery/microdns.c
@@ -620,6 +620,7 @@ OpenSD( vlc_object_t *p_obj )
     if( !p_sd->p_sys )
         return VLC_ENOMEM;
 
+    p_sd->description = _("mDNS Network Discovery");
     config_ChainParse( p_sd, CFG_PREFIX, ppsz_options, p_sd->p_cfg );
 
     return OpenCommon( p_obj, &p_sd->p_sys->s, false );
diff --git a/modules/services_discovery/mtp.c b/modules/services_discovery/mtp.c
index 8a66a9e..07195ad 100644
--- a/modules/services_discovery/mtp.c
+++ b/modules/services_discovery/mtp.c
@@ -93,6 +93,7 @@ static int Open( vlc_object_t *p_this )
     if( !( p_sys = malloc( sizeof( services_discovery_sys_t ) ) ) )
         return VLC_ENOMEM;
     p_sd->p_sys = p_sys;
+    p_sd->description = _("MTP devices");
     p_sys->psz_name = NULL;
 
     vlc_mutex_lock( &mtp_lock );
diff --git a/modules/services_discovery/os2drive.c b/modules/services_discovery/os2drive.c
index 8b84be6..427f500 100644
--- a/modules/services_discovery/os2drive.c
+++ b/modules/services_discovery/os2drive.c
@@ -66,6 +66,8 @@ static int Open (vlc_object_t *obj)
     ULONG ulDataLen;
     ULONG rc;
 
+    sd->description = _("Discs");
+
     if (DosOpen ((PSZ)"CD-ROM2$", (PHFILE)&hcd2, &ulAction, 0, FILE_NORMAL,
                  OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_FAIL_IF_NEW,
                  OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, NULL))
diff --git a/modules/services_discovery/podcast.c b/modules/services_discovery/podcast.c
index 03008aa..e19f4af 100644
--- a/modules/services_discovery/podcast.c
+++ b/modules/services_discovery/podcast.c
@@ -142,6 +142,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->update_type = UPDATE_URLS;
 
     p_sd->p_sys  = p_sys;
+    p_sd->description = _("Podcasts");
 
     /* Launch the callback associated with this variable */
     vlc_object_t *pl = p_sd->obj.parent;
diff --git a/modules/services_discovery/pulse.c b/modules/services_discovery/pulse.c
index 62b6fe4..5cd6647 100644
--- a/modules/services_discovery/pulse.c
+++ b/modules/services_discovery/pulse.c
@@ -79,6 +79,7 @@ static int Open (vlc_object_t *obj)
     }
 
     sd->p_sys = sys;
+    sd->description = _("Audio capture");
     sys->context = ctx;
     sys->root = NULL;
 
diff --git a/modules/services_discovery/sap.c b/modules/services_discovery/sap.c
index 227ef36..92f04ce 100644
--- a/modules/services_discovery/sap.c
+++ b/modules/services_discovery/sap.c
@@ -301,6 +301,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_timeout = var_CreateGetInteger( p_sd, "sap-timeout" );
 
     p_sd->p_sys  = p_sys;
+    p_sd->description = _("Network streams (SAP)");
 
     p_sys->pi_fd = NULL;
     p_sys->i_fd = 0;
diff --git a/modules/services_discovery/udev.c b/modules/services_discovery/udev.c
index 1df75fd..dac9cef 100644
--- a/modules/services_discovery/udev.c
+++ b/modules/services_discovery/udev.c
@@ -119,6 +119,7 @@ struct device
 struct subsys
 {
     const char *name;
+    const char *description;
     char * (*get_mrl) (struct udev_device *dev);
     char * (*get_name) (struct udev_device *dev);
     int item_type;
@@ -233,6 +234,8 @@ static int Open (vlc_object_t *obj, const struct subsys *subsys)
 
     if (p_sys == NULL)
         return VLC_ENOMEM;
+
+    sd->description = vlc_gettext(subsys->description);
     sd->p_sys = p_sys;
     p_sys->subsys = subsys;
     p_sys->root = NULL;
@@ -441,7 +444,8 @@ static char *v4l_get_name (struct udev_device *dev)
 int OpenV4L (vlc_object_t *obj)
 {
     static const struct subsys subsys = {
-        "video4linux", v4l_get_mrl, v4l_get_name, ITEM_TYPE_CARD,
+        "video4linux", N_("Video capture"),
+        v4l_get_mrl, v4l_get_name, ITEM_TYPE_CARD,
     };
 
     return Open (obj, &subsys);
@@ -515,7 +519,8 @@ out:
 int OpenALSA (vlc_object_t *obj)
 {
     static const struct subsys subsys = {
-        "sound", alsa_get_mrl, alsa_get_name, ITEM_TYPE_CARD,
+        "sound", N_("Audio capture"),
+        alsa_get_mrl, alsa_get_name, ITEM_TYPE_CARD,
     };
 
     return Open (obj, &subsys);
@@ -619,7 +624,7 @@ static char *disc_get_name (struct udev_device *dev)
 int OpenDisc (vlc_object_t *obj)
 {
     static const struct subsys subsys = {
-        "block", disc_get_mrl, disc_get_name, ITEM_TYPE_DISC,
+        "block", N_("Discs"), disc_get_mrl, disc_get_name, ITEM_TYPE_DISC,
     };
 
     return Open (obj, &subsys);
diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp
index 75b289f..83a138e 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -230,6 +230,8 @@ static int Open( vlc_object_t *p_this )
     if( !( p_sd->p_sys = p_sys ) )
         return VLC_ENOMEM;
 
+    p_sd->description = _("Universal Plug'n'Play");
+
     p_sys->p_upnp = UpnpInstanceWrapper::get( p_this, p_sd );
     if ( !p_sys->p_upnp )
     {
diff --git a/modules/services_discovery/windrive.c b/modules/services_discovery/windrive.c
index 91956d9..fbface0 100644
--- a/modules/services_discovery/windrive.c
+++ b/modules/services_discovery/windrive.c
@@ -56,6 +56,8 @@ static int Open (vlc_object_t *obj)
 {
     services_discovery_t *sd = (services_discovery_t *)obj;
 
+    sd->description = _("Discs");
+
     LONG drives = GetLogicalDrives ();
     char mrl[12] = "file:///A:/", name[3] = "A:";
     TCHAR path[4] = TEXT("A:\\");
diff --git a/modules/services_discovery/xcb_apps.c b/modules/services_discovery/xcb_apps.c
index b3698ad..daea789 100644
--- a/modules/services_discovery/xcb_apps.c
+++ b/modules/services_discovery/xcb_apps.c
@@ -97,6 +97,7 @@ static int Open (vlc_object_t *obj)
     if (p_sys == NULL)
         return VLC_ENOMEM;
     sd->p_sys = p_sys;
+    sd->description = _("Screen capture");
 
     /* Connect to X server */
     char *display = var_InheritString (obj, "x11-display");
diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c
index 0efdabe..296ef8a 100644
--- a/src/playlist/services_discovery.c
+++ b/src/playlist/services_discovery.c
@@ -114,6 +114,7 @@ services_discovery_t *vlc_sd_Create(vlc_object_t *parent, const char *cfg,
         return NULL;
 
     free(config_ChainCreate(&sd->psz_name, &sd->p_cfg, cfg));
+    sd->description = NULL;
     sd->owner = *owner;
 
     sd->p_module = module_need(sd, "services_discovery",



More information about the vlc-commits mailing list