Commit 8dbb3f39 authored by Rafaël Carré's avatar Rafaël Carré

Reverts [20669]

Adds a button into qt4 media information to write modified meta data to the file
parent 10b303d9
......@@ -429,6 +429,7 @@ typedef struct vlm_message_t vlm_message_t;
/* divers */
typedef struct vlc_meta_t vlc_meta_t;
typedef struct meta_export_t meta_export_t;
/* Stats */
typedef struct counter_t counter_t;
......
......@@ -227,6 +227,12 @@ enum {
ALBUM_ART_ALL
};
struct meta_export_t
{
input_item_t *p_item;
const char *psz_file;
};
#define VLC_META_ENGINE_TITLE 0x00000001
#define VLC_META_ENGINE_ARTIST 0x00000004
#define VLC_META_ENGINE_GENRE 0x00000008
......
......@@ -114,6 +114,11 @@ MetaPanel::MetaPanel( QWidget *parent, intf_thread_t *_p_intf ) :
ADD_META_B( VLC_META_ENCODED_BY, publisher_text );
ADD_META_B( VLC_META_DESCRIPTION, description_text ); // Comment Two lines?
QPushButton *write = new QPushButton( qtr( "&Write" ) );
l->addWidget( write, line, 0 );
BUTTONACT( write, saveMeta() );
/* ADD_META( TRACKID) DO NOT SHOW it */
/* ADD_URI - DO not show it, done outside */
......@@ -127,6 +132,55 @@ MetaPanel::~MetaPanel()
{
}
void MetaPanel::saveMeta()
{
playlist_t *p_playlist;
meta_export_t p_export;
p_export.p_item = p_input;
/* we can write meta data only in a file */
if( ( p_input->i_type == ITEM_TYPE_AFILE ) || \
( p_input->i_type == ITEM_TYPE_VFILE ) )
/* some audio files are detected as video files */
{
char *psz_uri = p_input->psz_uri;
if( !strncmp( psz_uri, "file://", 7 ) )
psz_uri += 7; /* strlen("file://") = 7 */
p_export.psz_file = strndup( psz_uri, PATH_MAX );
}
else
return;
/* now we read the modified meta data */
free( p_input->p_meta->psz_artist );
p_input->p_meta->psz_artist = strdup( artist_text->text().toUtf8() );
free( p_input->p_meta->psz_album );
p_input->p_meta->psz_album = strdup( collection_text->text().toUtf8() );
free( p_input->p_meta->psz_genre );
p_input->p_meta->psz_genre = strdup( genre_text->text().toUtf8() );
free( p_input->p_meta->psz_date );
p_input->p_meta->psz_date = (char*) malloc(5);
snprintf( p_input->p_meta->psz_date, 5, "%d", date_text->value() );
free( p_input->p_meta->psz_tracknum );
p_input->p_meta->psz_tracknum = (char*) malloc(5);
snprintf( p_input->p_meta->psz_tracknum, 5, "%d", seqnum_text->value() );
free( p_input->p_meta->psz_title );
p_input->p_meta->psz_title = strdup( title_text->text().toUtf8() );
p_playlist = pl_Yield( p_intf );
PL_LOCK;
p_playlist->p_private = &p_export;
module_t *p_mod = module_Need( p_playlist, "meta writer", NULL, 0 );
if( p_mod )
module_Unneed( p_playlist, p_mod );
PL_UNLOCK;
pl_Release( p_playlist );
}
void MetaPanel::update( input_item_t *p_item )
{
char *psz_meta;
......
......@@ -53,6 +53,7 @@ class MetaPanel: public QWidget
public:
MetaPanel( QWidget *, intf_thread_t * );
virtual ~MetaPanel();
input_item_t *p_input;
private:
intf_thread_t *p_intf;
QLineEdit *uri_text;
......@@ -74,6 +75,7 @@ private:
public slots:
void update( input_item_t * );
void clear();
void saveMeta();
signals:
void uriSet( QString );
};
......
......@@ -142,6 +142,7 @@ void MediaInfoDialog::update()
void MediaInfoDialog::update( input_item_t *p_item, bool update_info,
bool update_meta )
{
MP->p_input = p_item;
if( update_info )
IP->update( p_item );
if( update_meta )
......
......@@ -166,29 +166,25 @@ static int ReadMeta( vlc_object_t *p_this )
return VLC_EGENERIC;
}
#define SET(a,b) if(b) tag->set##a( b );
static int WriteMeta( vlc_object_t *p_this )
{
input_item_t *p_item = (input_item_t *)p_this;
char *psz_uri = p_item->psz_uri;
/* we can write meta data only in a file */
if( !strncmp( psz_uri, "file://", 7 ) )
psz_uri += 7;
/* if the file is specified with its path, not prefixed with file:// */
else if( strncmp( psz_uri, "/", 1 ) )
return VLC_EGENERIC;
playlist_t *p_playlist = (playlist_t *)p_this;
meta_export_t *p_export = (meta_export_t *)p_playlist->p_private;
input_item_t *p_item = p_export->p_item;
TagLib::FileRef f( psz_uri );
TagLib::FileRef f( p_export->psz_file );
if( !f.isNull() && f.tag() )
{
TagLib::Tag *tag = f.tag();
tag->setArtist( p_item->p_meta->psz_artist );
SET( Artist, p_item->p_meta->psz_artist );
if( p_item->p_meta->psz_title )
tag->setTitle( p_item->p_meta->psz_title );
else
tag->setTitle( p_item->psz_name );
tag->setAlbum( p_item->p_meta->psz_album );
tag->setGenre( p_item->p_meta->psz_genre );
SET( Album, p_item->p_meta->psz_album );
SET( Genre, p_item->p_meta->psz_genre );
if( p_item->p_meta->psz_date )
tag->setYear( atoi( p_item->p_meta->psz_date ) );
if( p_item->p_meta->psz_tracknum )
......@@ -196,6 +192,8 @@ static int WriteMeta( vlc_object_t *p_this )
f.save();
return VLC_SUCCESS;
}
msg_Err( p_this, "File %s can't be opened for tag writing\n",
p_export->psz_file );
return VLC_EGENERIC;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment