]> git.sesse.net Git - vlc/blobdiff - modules/misc/notify/msn.c
svg module: fix memleak.
[vlc] / modules / misc / notify / msn.c
index dbb63024621cc33cc324d755e5b103e9763a6d17..5b23e54cf6a49f42fcc94c84fae173399df5a40d 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
 
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_interface.h>
 #include <vlc_meta.h>
 #include <vlc_playlist.h>
+#include <vlc_strings.h>
 
 /*****************************************************************************
  * intf_sys_t: description and status of log interface
@@ -67,10 +72,10 @@ vlc_module_begin();
     set_category( CAT_INTERFACE );
     set_subcategory( SUBCAT_INTERFACE_CONTROL );
     set_shortname( "MSN" );
-    set_description( _("MSN Now-Playing") );
+    set_description( N_("MSN Now-Playing") );
 
     add_string( "msn-format", FORMAT_DEFAULT, NULL,
-                FORMAT_TEXT, FORMAT_LONGTEXT, VLC_FALSE );
+                FORMAT_TEXT, FORMAT_LONGTEXT, false );
 
     set_capability( "interface", 0 );
     set_callbacks( Open, Close );
@@ -134,6 +139,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     char *psz_title = NULL;
     char *psz_artist = NULL;
     char *psz_album = NULL;
+    char *psz_buf = NULL;
     input_thread_t *p_input;
     playlist_t *p_playlist = pl_Yield( p_this );
 
@@ -152,23 +158,24 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
     }
 
     /* Playing something ... */
-    psz_artist = input_GetItem(p_input)->p_meta->psz_artist ?
-                  strdup( input_GetItem(p_input)->p_meta->psz_artist ) :
-                  strdup( "" );
-    psz_album = input_GetItem(p_input)->p_meta->psz_album ?
-                  strdup( input_GetItem(p_input)->p_meta->psz_album ) :
-                  strdup( "" );
-    psz_title = strdup( input_GetItem(p_input)->psz_name );
-    if( psz_title == NULL ) psz_title = strdup( N_("(no title)") );
-    if( psz_artist == NULL ) psz_artist = strdup( N_("(no artist)") );
-    if( psz_album == NULL ) psz_album = strdup( N_("(no album)") );
+    psz_artist = input_item_GetArtist( input_GetItem( p_input ) );
+    psz_album = input_item_GetAlbum( input_GetItem( p_input ) );
+    psz_title = input_item_GetTitle( input_GetItem( p_input ) );
+    if( !psz_artist ) psz_artist = strdup( "" );
+    if( !psz_album ) psz_artist = strdup( "" );
+    if( !psz_title )
+        psz_title = input_item_GetName( input_GetItem( p_input ) );
+
+    psz_buf = str_format_meta( p_this, p_intf->p_sys->psz_format );
+
     snprintf( psz_tmp,
               MSN_MAX_LENGTH,
               "\\0Music\\01\\0%s\\0%s\\0%s\\0%s\\0\\0\\0",
-              p_intf->p_sys->psz_format,
+              psz_buf,
               psz_artist,
               psz_title,
               psz_album );
+    free( psz_buf );
     free( psz_title );
     free( psz_artist );
     free( psz_album );