X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fmisc%2Fnotify%2Fmsn.c;h=67951bc692b8abe2f7cfc9731bca921a6ed43516;hb=c18658f2d162eef1135dca27adbdeae4cc5e0131;hp=6747e0a96025be27a4ad9d76dc3d621a4f2da26f;hpb=ba6501f3084682844e7ee87bad3986bced5f3652;p=vlc diff --git a/modules/misc/notify/msn.c b/modules/misc/notify/msn.c index 6747e0a960..67951bc692 100644 --- a/modules/misc/notify/msn.c +++ b/modules/misc/notify/msn.c @@ -68,18 +68,18 @@ static int SendToMSN( const char * psz_msg ); #define FORMAT_LONGTEXT N_("Format of the string to send to MSN " \ "{0} Artist, {1} Title, {2} Album. Defaults to \"Artist - Title\" ({0} - {1}).") -vlc_module_begin(); - set_category( CAT_INTERFACE ); - set_subcategory( SUBCAT_INTERFACE_CONTROL ); - set_shortname( "MSN" ); - set_description( N_("MSN Now-Playing") ); +vlc_module_begin () + set_category( CAT_INTERFACE ) + set_subcategory( SUBCAT_INTERFACE_CONTROL ) + set_shortname( "MSN" ) + set_description( N_("MSN Now-Playing") ) add_string( "msn-format", FORMAT_DEFAULT, NULL, - FORMAT_TEXT, FORMAT_LONGTEXT, false ); + FORMAT_TEXT, FORMAT_LONGTEXT, false ) - set_capability( "interface", 0 ); - set_callbacks( Open, Close ); -vlc_module_end(); + set_capability( "interface", 0 ) + set_callbacks( Open, Close ) +vlc_module_end () /***************************************************************************** * Open: initialize and create stuff @@ -89,7 +89,9 @@ static int Open( vlc_object_t *p_this ) intf_thread_t *p_intf = (intf_thread_t *)p_this; playlist_t *p_playlist; - MALLOC_ERR( p_intf->p_sys, intf_sys_t ); + p_intf->p_sys = malloc( sizeof( intf_sys_t ) ); + if( !p_intf->p_sys ) + return VLC_ENOMEM; p_intf->p_sys->psz_format = config_GetPsz( p_intf, "msn-format" ); if( !p_intf->p_sys->psz_format ) @@ -101,7 +103,7 @@ static int Open( vlc_object_t *p_this ) p_playlist = pl_Hold( p_intf ); var_AddCallback( p_playlist, "item-change", ItemChange, p_intf ); - var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf ); + var_AddCallback( p_playlist, "item-current", ItemChange, p_intf ); pl_Release( p_intf ); return VLC_SUCCESS; @@ -120,7 +122,7 @@ static void Close( vlc_object_t *p_this ) SendToMSN( "\\0Music\\01\\0\\0\\0\\0\\0\\0\\0" ); var_DelCallback( p_playlist, "item-change", ItemChange, p_intf ); - var_DelCallback( p_playlist, "playlist-current", ItemChange, p_intf ); + var_DelCallback( p_playlist, "item-current", ItemChange, p_intf ); pl_Release( p_this ); /* Destroy structure */ @@ -141,14 +143,9 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, char *psz_artist = NULL; char *psz_album = NULL; char *psz_buf = NULL; - input_thread_t *p_input; - playlist_t *p_playlist = pl_Hold( p_this ); - - p_input = p_playlist->p_input; - pl_Release( p_this ); + input_thread_t *p_input = playlist_CurrentInput( (playlist_t *) p_this ); if( !p_input ) return VLC_SUCCESS; - vlc_object_hold( p_input ); if( p_input->b_dead || !input_GetItem(p_input)->psz_name ) { @@ -163,7 +160,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, 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_album ) psz_album = strdup( "" ); if( !psz_title ) psz_title = input_item_GetName( input_GetItem( p_input ) ); @@ -197,7 +194,9 @@ static int SendToMSN( const char *psz_msg ) wchar_t buffer[MSN_MAX_LENGTH]; - mbstowcs( buffer, psz_msg, MSN_MAX_LENGTH ); + //mbstowcs( buffer, psz_msg, MSN_MAX_LENGTH ); + int nLen = MultiByteToWideChar(CP_ACP, 0, psz_msg, -1, NULL, NULL); + MultiByteToWideChar(CP_ACP, 0, psz_msg, -1, &buffer, nLen); msndata.dwData = 0x547; msndata.lpData = &buffer;