Exemplo n.º 1
0
Arquivo: mvar.c Projeto: cobr123/qtVlc
mvar_t *mvar_Duplicate( const mvar_t *v )
{
    int i;
    mvar_t *n;

    n = mvar_New( v->name, v->value );
    for( i = 0; i < v->i_field; i++ )
    {
        mvar_AppendVar( n, mvar_Duplicate( v->field[i] ) );
    }

    return n;
}
Exemplo n.º 2
0
Arquivo: mvar.c Projeto: cobr123/qtVlc
mvar_t *mvar_InfoSetNew( char *name, input_thread_t *p_input )
{
    mvar_t *s = mvar_New( name, "set" );
    int i, j;

    if( p_input == NULL || p_input->p == NULL /* workarround assert in input_GetItem */ )
    {
        return s;
    }

    vlc_mutex_lock( &input_GetItem(p_input)->lock );
    for ( i = 0; i < input_GetItem(p_input)->i_categories; i++ )
    {
        info_category_t *p_category = input_GetItem(p_input)->pp_categories[i];

        mvar_t *cat  = mvar_New( name, "set" );
        mvar_t *iset = mvar_New( "info", "set" );

        mvar_AppendNewVar( cat, "name", p_category->psz_name );
        mvar_AppendVar( cat, iset );

        for ( j = 0; j < p_category->i_infos; j++ )
        {
            info_t *p_info = p_category->pp_infos[j];
            mvar_t *info = mvar_New( "info", "" );

            /* msg_Dbg( p_input, "adding info name=%s value=%s",
                     psz_name, psz_value ); */
            mvar_AppendNewVar( info, "name",  p_info->psz_name );
            mvar_AppendNewVar( info, "value", p_info->psz_value );
            mvar_AppendVar( iset, info );
        }
        mvar_AppendVar( s, cat );
    }
    vlc_mutex_unlock( &input_GetItem(p_input)->lock );

    return s;
}
Exemplo n.º 3
0
Arquivo: mvar.c Projeto: cobr123/qtVlc
mvar_t *mvar_HttpdInfoSetNew( char *name, httpd_t *p_httpd, int i_type )
{
    mvar_t       *s = mvar_New( name, "set" );
    httpd_info_t info;
    int          i;

    if( !p_httpd->pf_control( p_httpd, i_type, &info, NULL ) )
    {
        for( i= 0; i < info.i_count; )
        {
            mvar_t *inf;

            inf = mvar_New( name, "set" );
            do
            {
                /* fprintf( stderr," mvar_HttpdInfoSetNew: append name=`%s' value=`%s'\n",
                            info.info[i].psz_name, info.info[i].psz_value ); */
                mvar_AppendNewVar( inf,
                                   info.info[i].psz_name,
                                   info.info[i].psz_value );
                i++;
            } while( i < info.i_count && strcmp( info.info[i].psz_name, "id" ) );
            mvar_AppendVar( s, inf );
        }
    }

    /* free mem */
    for( i = 0; i < info.i_count; i++ )
    {
        free( info.info[i].psz_name );
        free( info.info[i].psz_value );
    }
    if( info.i_count > 0 )
    {
        free( info.info );
    }

    return s;
}
Exemplo n.º 4
0
Arquivo: mvar.c Projeto: cobr123/qtVlc
mvar_t *mvar_ServicesSetNew( intf_thread_t *p_intf, char *psz_name )
{
    mvar_t *s = mvar_New( psz_name, "set" );
    char **longnames;
    char **names = vlc_sd_GetNames( p_intf, &longnames, NULL );
    if( names == NULL )
        goto out;

    for( size_t i = 0; names[i]; i++ )
    {
        mvar_t *sd = mvar_New( "sd", names[i] );
        mvar_AppendNewVar( sd, "name", longnames[i] );
        mvar_AppendVar( s, sd );
        free( names[i] );
        free( longnames[i] );
    }

    free( longnames );
    free( names );
out:
    return s;
}
Exemplo n.º 5
0
Arquivo: mvar.c Projeto: cobr123/qtVlc
static void mvar_VlmSetNewLoop( char *name, vlm_t *vlm, mvar_t *s,
                                vlm_message_t *el, bool b_name )
{
    /* Over name */
    mvar_t        *set;
    int k;

    /* Add a node with name and info */
    set = mvar_New( name, "set" );
    if( b_name == true )
    {
        mvar_AppendNewVar( set, "name", el->psz_name );
    }

    for( k = 0; k < el->i_child; k++ )
    {
        vlm_message_t *ch = el->child[k];
        if( ch->i_child > 0 )
        {
            mvar_VlmSetNewLoop( ch->psz_name, vlm, set, ch, false );
        }
        else
        {
            if( ch->psz_value )
            {
                mvar_AppendNewVar( set, ch->psz_name, ch->psz_value );
            }
            else
            {
                mvar_AppendNewVar( set, el->psz_name, ch->psz_name );
            }
        }
    }

    mvar_AppendVar( s, set );
}
Exemplo n.º 6
0
/*************************************************************************
 * Playlist stuff
 *************************************************************************/
void PlaylistListNode( intf_thread_t *p_intf, playlist_t *p_pl,
                           playlist_item_t *p_node, char *name, mvar_t *s,
                           int i_depth )
{
    if( !p_node || !p_node->p_input )
        return;

    if( p_node->i_children == -1 )
    {
        char value[512];
        char *psz;
        playlist_item_t * p_item = playlist_CurrentPlayingItem( p_pl );
        if( !p_item || !p_item->p_input )
            return;

        mvar_t *itm = mvar_New( name, "set" );
        if( p_item->p_input == p_node->p_input )
            mvar_AppendNewVar( itm, "current", "1" );
        else
            mvar_AppendNewVar( itm, "current", "0" );

        sprintf( value, "%d", p_node->i_id );
        mvar_AppendNewVar( itm, "index", value );

        psz = input_item_GetName( p_node->p_input );
        mvar_AppendNewVar( itm, "name", psz );
        free( psz );

        psz = input_item_GetURI( p_node->p_input );
        mvar_AppendNewVar( itm, "uri", psz );
        free( psz );

        mvar_AppendNewVar( itm, "type", "Item" );

        sprintf( value, "%d", i_depth );
        mvar_AppendNewVar( itm, "depth", value );

        if( p_node->i_flags & PLAYLIST_RO_FLAG )
            mvar_AppendNewVar( itm, "ro", "ro" );
        else
            mvar_AppendNewVar( itm, "ro", "rw" );

        sprintf( value, "%"PRId64, input_item_GetDuration( p_node->p_input ) );
        mvar_AppendNewVar( itm, "duration", value );

        //Adding extra meta-information to each playlist item

        psz = input_item_GetTitle( p_node->p_input );
        mvar_AppendNewVar( itm, "title", psz );
        free( psz );

        psz = input_item_GetArtist( p_node->p_input );
        mvar_AppendNewVar( itm, "artist", psz );
        free( psz );

        psz = input_item_GetGenre( p_node->p_input );
        mvar_AppendNewVar( itm, "genre", psz );
        free( psz );

        psz = input_item_GetCopyright( p_node->p_input );
        mvar_AppendNewVar( itm, "copyright", psz );
        free( psz );

        psz = input_item_GetAlbum( p_node->p_input );
        mvar_AppendNewVar( itm, "album", psz );
        free( psz );

        psz = input_item_GetTrackNum( p_node->p_input );
        mvar_AppendNewVar( itm, "track", psz );
        free( psz );

        psz = input_item_GetDescription( p_node->p_input );
        mvar_AppendNewVar( itm, "description", psz );
        free( psz );

        psz = input_item_GetRating( p_node->p_input );
        mvar_AppendNewVar( itm, "rating", psz );
        free( psz );

        psz = input_item_GetDate( p_node->p_input );
        mvar_AppendNewVar( itm, "date", psz );
        free( psz );

        psz = input_item_GetURL( p_node->p_input );
        mvar_AppendNewVar( itm, "url", psz );
        free( psz );

        psz = input_item_GetLanguage( p_node->p_input );
        mvar_AppendNewVar( itm, "language", psz );
        free( psz );

        psz = input_item_GetNowPlaying( p_node->p_input );
        mvar_AppendNewVar( itm, "now_playing", psz );
        free( psz );

        psz = input_item_GetPublisher( p_node->p_input );
        mvar_AppendNewVar( itm, "publisher", psz );
        free( psz );

        psz = input_item_GetEncodedBy( p_node->p_input );
        mvar_AppendNewVar( itm, "encoded_by", psz );
        free( psz );

        psz = input_item_GetArtURL( p_node->p_input );
        mvar_AppendNewVar( itm, "art_url", psz );
        free( psz );

        psz = input_item_GetTrackID( p_node->p_input );
        mvar_AppendNewVar( itm, "track_id", psz );
        free( psz );

        mvar_AppendVar( s, itm );
    }
    else
    {
        char value[512];
        int i_child;
        mvar_t *itm = mvar_New( name, "set" );

        mvar_AppendNewVar( itm, "name", p_node->p_input->psz_name );
        mvar_AppendNewVar( itm, "uri", p_node->p_input->psz_name );

        mvar_AppendNewVar( itm, "type", "Node" );

        sprintf( value, "%d", p_node->i_id );
        mvar_AppendNewVar( itm, "index", value );

        sprintf( value, "%d", p_node->i_children);
        mvar_AppendNewVar( itm, "i_children", value );

        sprintf( value, "%d", i_depth );
        mvar_AppendNewVar( itm, "depth", value );

        if( p_node->i_flags & PLAYLIST_RO_FLAG )
            mvar_AppendNewVar( itm, "ro", "ro" );
        else
            mvar_AppendNewVar( itm, "ro", "rw" );

        mvar_AppendVar( s, itm );

        for( i_child = 0 ; i_child < p_node->i_children ; i_child++ )
             PlaylistListNode( p_intf, p_pl, p_node->pp_children[i_child],
                               name, s, i_depth + 1);
    }
}
Exemplo n.º 7
0
Arquivo: mvar.c Projeto: cobr123/qtVlc
mvar_t *mvar_FileSetNew( intf_thread_t *p_intf, char *name,
                             char *psz_dir )
{
    mvar_t *s = mvar_New( name, "set" );
    char        **ppsz_dir_content;
    int           i_dir_content, i;
    psz_dir = RealPath( psz_dir );

    /* parse psz_src dir */
    if( ( i_dir_content = vlc_scandir( psz_dir, &ppsz_dir_content, Filter,
                                        InsensitiveAlphasort ) ) == -1 )
    {
        if( errno != ENOENT && errno != ENOTDIR )
            msg_Warn( p_intf, "error while scanning dir %s (%m)", psz_dir );
        free( psz_dir );
        return s;
    }

    for( i = 0; i < i_dir_content; i++ )
    {
#ifdef HAVE_SYS_STAT_H
        struct stat stat_info;
#endif
        char *psz_name = ppsz_dir_content[i], *psz_ext, *psz_dummy;
        char psz_tmp[strlen( psz_dir ) + 1 + strlen( psz_name ) + 1];
        mvar_t *f;

#if defined( WIN32 )
        if( psz_dir[0] == '\0' || (psz_dir[0] == '\\' && psz_dir[1] == '\0') )
        {
            strcpy( psz_tmp, psz_name );
        }
        else
#endif
        {
            sprintf( psz_tmp, "%s"DIR_SEP"%s", psz_dir, psz_name );

#ifdef HAVE_SYS_STAT_H
            if( vlc_stat( psz_tmp, &stat_info ) == -1 )
            {
                free( psz_name );
                continue;
            }
#endif
        }
        f = mvar_New( name, "set" );

        /* put lower-case file extension in 'ext' */
        psz_ext = strrchr( psz_name, '.' );
        psz_ext = strdup( psz_ext != NULL ? psz_ext + 1 : "" );
        for( psz_dummy = psz_ext; *psz_dummy != '\0'; psz_dummy++ )
            *psz_dummy = tolower( *psz_dummy );

        mvar_AppendNewVar( f, "ext", psz_ext );
        free( psz_ext );

#if defined( WIN32 )
        if( psz_dir[0] == '\0' || (psz_dir[0] == '\\' && psz_dir[1] == '\0') )
        {
            char psz_tmp[3];
            sprintf( psz_tmp, "%c:", psz_name[0] );
            mvar_AppendNewVar( f, "name", psz_name );
            mvar_AppendNewVar( f, "basename", psz_tmp );
            mvar_AppendNewVar( f, "type", "directory" );
            mvar_AppendNewVar( f, "size", "unknown" );
            mvar_AppendNewVar( f, "date", "unknown" );
        }
        else
#endif
        {
            char psz_buf[26];
            char psz_tmp[strlen( psz_dir ) + 1 + strlen( psz_name ) + 1];

            sprintf( psz_tmp, "%s"DIR_SEP"%s", psz_dir, psz_name );
            mvar_AppendNewVar( f, "name", psz_tmp );
            mvar_AppendNewVar( f, "basename", psz_name );

#ifdef HAVE_SYS_STAT_H
            if( S_ISDIR( stat_info.st_mode ) )
            {
                mvar_AppendNewVar( f, "type", "directory" );
            }
            else if( S_ISREG( stat_info.st_mode ) )
            {
                mvar_AppendNewVar( f, "type", "file" );
            }
            else
            {
                mvar_AppendNewVar( f, "type", "unknown" );
            }

            snprintf( psz_buf, sizeof( psz_buf ), "%"PRId64,
                      (int64_t)stat_info.st_size );
            mvar_AppendNewVar( f, "size", psz_buf );

            /* FIXME memory leak FIXME */
#   ifdef HAVE_CTIME_R
            ctime_r( &stat_info.st_mtime, psz_buf );
            mvar_AppendNewVar( f, "date", psz_buf );
#   else
            mvar_AppendNewVar( f, "date", ctime( &stat_info.st_mtime ) );
#   endif

#else
            mvar_AppendNewVar( f, "type", "unknown" );
            mvar_AppendNewVar( f, "size", "unknown" );
            mvar_AppendNewVar( f, "date", "unknown" );
#endif
        }

        mvar_AppendVar( s, f );

        free( psz_name );
    }

    free( psz_dir );
    free( ppsz_dir_content );
    return s;
}
Exemplo n.º 8
0
Arquivo: mvar.c Projeto: cobr123/qtVlc
mvar_t *mvar_InputVarSetNew( intf_thread_t *p_intf, char *name,
                                 input_thread_t *p_input,
                                 const char *psz_variable )
{
    intf_sys_t     *p_sys = p_intf->p_sys;
    mvar_t *s = mvar_New( name, "set" );
    vlc_value_t val, val_list, text_list;
    int i_type, i;

    if( p_input == NULL )
    {
        return s;
    }

    /* Check the type of the object variable */
    i_type = var_Type( p_sys->p_input, psz_variable );

    /* Make sure we want to display the variable */
    if( i_type & VLC_VAR_HASCHOICE )
    {
        var_Change( p_sys->p_input, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
        if( val.i_int == 0 ) return s;
        if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
            return s;
    }
    else
    {
        return s;
    }

    switch( i_type & VLC_VAR_TYPE )
    {
    case VLC_VAR_VOID:
    case VLC_VAR_BOOL:
    case VLC_VAR_VARIABLE:
    case VLC_VAR_STRING:
    case VLC_VAR_INTEGER:
        break;
    default:
        /* Variable doesn't exist or isn't handled */
        return s;
    }

    if( var_Get( p_sys->p_input, psz_variable, &val ) < 0 )
    {
        return s;
    }

    if( var_Change( p_sys->p_input, psz_variable, VLC_VAR_GETLIST,
                    &val_list, &text_list ) < 0 )
    {
        if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
        return s;
    }

    for( i = 0; i < val_list.p_list->i_count; i++ )
    {
        char psz_int[16];
        mvar_t *itm;

        switch( i_type & VLC_VAR_TYPE )
        {
        case VLC_VAR_STRING:
            itm = mvar_New( name, "set" );
            mvar_AppendNewVar( itm, "name", text_list.p_list->p_values[i].psz_string );
            mvar_AppendNewVar( itm, "id", val_list.p_list->p_values[i].psz_string );
            snprintf( psz_int, sizeof(psz_int), "%d",
                      ( !strcmp( val.psz_string,
                                   val_list.p_list->p_values[i].psz_string )
                           && !( i_type & VLC_VAR_ISCOMMAND ) ) );
            mvar_AppendNewVar( itm, "selected", psz_int );
            mvar_AppendVar( s, itm );
            break;

        case VLC_VAR_INTEGER:
            itm = mvar_New( name, "set" );
            mvar_AppendNewVar( itm, "name", text_list.p_list->p_values[i].psz_string );
            snprintf( psz_int, sizeof(psz_int), "%d",
                      val_list.p_list->p_values[i].i_int );
            mvar_AppendNewVar( itm, "id", psz_int );
            snprintf( psz_int, sizeof(psz_int), "%d",
                      ( val.i_int == val_list.p_list->p_values[i].i_int )
                         && !( i_type & VLC_VAR_ISCOMMAND ) );
            mvar_AppendNewVar( itm, "selected", psz_int );
            mvar_AppendVar( s, itm );
            break;

        default:
            break;
        }
    }
    /* clean up everything */
    if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
    var_FreeList( &val_list, &text_list );
    return s;
}
Exemplo n.º 9
0
Arquivo: mvar.c Projeto: cobr123/qtVlc
void mvar_AppendNewVar( mvar_t *vars, const char *name,
                            const char *value )
{
    mvar_t *f = mvar_New( name, value );
    mvar_AppendVar( vars, f );
}