Changeset 8dbb3f39280e6c97cfee687b266e64d63d96e420

Show
Ignore:
Timestamp:
06/24/07 02:22:18 (1 year ago)
Author:
Rafaël Carré <funman@videolan.org>
git-committer:
Rafaël Carré <funman@videolan.org> 1182644538 +0000
git-parent:

[10b303d9799f411d2c185d963b4e8875e872e335]

git-author:
Rafaël Carré <funman@videolan.org> 1182644538 +0000
Message:

Reverts [20669]
Adds a button into qt4 media information to write modified meta data to the file

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_common.h

    r10b303d r8dbb3f3  
    430430/* divers */ 
    431431typedef struct vlc_meta_t    vlc_meta_t; 
     432typedef struct meta_export_t meta_export_t; 
    432433 
    433434/* Stats */ 
  • include/vlc_meta.h

    r10b303d r8dbb3f3  
    228228}; 
    229229 
     230struct meta_export_t 
     231{ 
     232    input_item_t *p_item; 
     233    const char *psz_file; 
     234}; 
     235 
    230236#define VLC_META_ENGINE_TITLE           0x00000001 
    231237#define VLC_META_ENGINE_ARTIST          0x00000004 
  • modules/gui/qt4/components/infopanels.cpp

    ref68043 r8dbb3f3  
    115115    ADD_META_B( VLC_META_DESCRIPTION, description_text ); // Comment Two lines? 
    116116 
     117    QPushButton *write = new QPushButton( qtr( "&Write" ) ); 
     118    l->addWidget( write, line, 0 ); 
     119 
     120    BUTTONACT( write, saveMeta() ); 
     121 
    117122    /*  ADD_META( TRACKID)  DO NOT SHOW it */ 
    118123    /*  ADD_URI - DO not show it, done outside */ 
     
    126131MetaPanel::~MetaPanel() 
    127132{ 
     133} 
     134 
     135void MetaPanel::saveMeta() 
     136{ 
     137    playlist_t *p_playlist; 
     138 
     139    meta_export_t p_export; 
     140    p_export.p_item = p_input; 
     141 
     142    /* we can write meta data only in a file */ 
     143    if( ( p_input->i_type == ITEM_TYPE_AFILE ) || \ 
     144        ( p_input->i_type == ITEM_TYPE_VFILE ) ) 
     145        /* some audio files are detected as video files */ 
     146    { 
     147        char *psz_uri = p_input->psz_uri; 
     148        if( !strncmp( psz_uri, "file://", 7 ) ) 
     149            psz_uri += 7; /* strlen("file://") = 7 */ 
     150 
     151        p_export.psz_file = strndup( psz_uri, PATH_MAX ); 
     152    } 
     153    else 
     154        return; 
     155 
     156    /* now we read the modified meta data */ 
     157    free( p_input->p_meta->psz_artist ); 
     158    p_input->p_meta->psz_artist = strdup( artist_text->text().toUtf8() ); 
     159    free( p_input->p_meta->psz_album ); 
     160    p_input->p_meta->psz_album = strdup( collection_text->text().toUtf8() ); 
     161    free( p_input->p_meta->psz_genre ); 
     162    p_input->p_meta->psz_genre = strdup( genre_text->text().toUtf8() ); 
     163    free( p_input->p_meta->psz_date ); 
     164    p_input->p_meta->psz_date = (char*) malloc(5); 
     165    snprintf( p_input->p_meta->psz_date, 5, "%d", date_text->value() ); 
     166    free( p_input->p_meta->psz_tracknum ); 
     167    p_input->p_meta->psz_tracknum = (char*) malloc(5); 
     168    snprintf( p_input->p_meta->psz_tracknum, 5, "%d", seqnum_text->value() ); 
     169    free( p_input->p_meta->psz_title ); 
     170    p_input->p_meta->psz_title = strdup(  title_text->text().toUtf8() ); 
     171 
     172    p_playlist = pl_Yield( p_intf ); 
     173 
     174    PL_LOCK; 
     175    p_playlist->p_private = &p_export; 
     176 
     177    module_t *p_mod = module_Need( p_playlist, "meta writer", NULL, 0 ); 
     178    if( p_mod ) 
     179        module_Unneed( p_playlist, p_mod ); 
     180    PL_UNLOCK; 
     181    pl_Release( p_playlist ); 
    128182} 
    129183 
  • modules/gui/qt4/components/infopanels.hpp

    rdabe66a r8dbb3f3  
    5454    MetaPanel( QWidget *, intf_thread_t * ); 
    5555    virtual ~MetaPanel(); 
     56    input_item_t *p_input; 
    5657private: 
    5758    intf_thread_t *p_intf; 
     
    7576    void update( input_item_t * ); 
    7677    void clear(); 
     78    void saveMeta(); 
    7779signals: 
    7880    void uriSet( QString ); 
  • modules/gui/qt4/dialogs/mediainfo.cpp

    rdabe66a r8dbb3f3  
    143143                                                    bool update_meta ) 
    144144{ 
     145    MP->p_input = p_item; 
    145146    if( update_info ) 
    146147        IP->update( p_item ); 
  • modules/meta_engine/taglib.cpp

    r10b303d r8dbb3f3  
    167167} 
    168168 
     169#define SET(a,b) if(b) tag->set##a( b ); 
     170 
    169171static int WriteMeta( vlc_object_t *p_this ) 
    170172{ 
    171     input_item_t *p_item = (input_item_t *)p_this; 
    172  
    173     char *psz_uri = p_item->psz_uri; 
    174     /* we can write meta data only in a file */ 
    175     if( !strncmp( psz_uri, "file://", 7 ) ) 
    176         psz_uri += 7; 
    177     /* if the file is specified with its path, not prefixed with file:// */ 
    178     else if( strncmp( psz_uri, "/", 1 ) ) 
    179         return VLC_EGENERIC; 
    180  
    181     TagLib::FileRef f( psz_uri ); 
     173    playlist_t *p_playlist = (playlist_t *)p_this; 
     174    meta_export_t *p_export = (meta_export_t *)p_playlist->p_private; 
     175    input_item_t *p_item = p_export->p_item; 
     176 
     177    TagLib::FileRef f( p_export->psz_file ); 
    182178    if( !f.isNull() && f.tag() ) 
    183179    { 
    184180        TagLib::Tag *tag = f.tag(); 
    185         tag->setArtist( p_item->p_meta->psz_artist ); 
     181        SET( Artist, p_item->p_meta->psz_artist ); 
    186182        if( p_item->p_meta->psz_title ) 
    187183            tag->setTitle( p_item->p_meta->psz_title ); 
    188184        else 
    189185            tag->setTitle( p_item->psz_name ); 
    190         tag->setAlbum( p_item->p_meta->psz_album ); 
    191         tag->setGenre( p_item->p_meta->psz_genre ); 
     186        SET( Album, p_item->p_meta->psz_album ); 
     187        SET( Genre, p_item->p_meta->psz_genre ); 
    192188        if( p_item->p_meta->psz_date ) 
    193189            tag->setYear( atoi( p_item->p_meta->psz_date ) ); 
     
    197193        return VLC_SUCCESS; 
    198194    } 
     195    msg_Err( p_this, "File %s can't be opened for tag writing\n", 
     196        p_export->psz_file ); 
    199197    return VLC_EGENERIC; 
    200198}