Beispiel #1
0
static void netbios_ns_discover_on_entry_added( void *p_opaque,
                                                netbios_ns_entry *p_entry )
{
    services_discovery_t *p_sd = (services_discovery_t *)p_opaque;

    char type = netbios_ns_entry_type( p_entry );

    if( type == NETBIOS_FILESERVER )
    {
        input_item_t *p_item;
        char *psz_mrl;
        const char *name = netbios_ns_entry_name( p_entry );

        if( asprintf(&psz_mrl, "smb://%s", name) < 0 )
            return;

        p_item = input_item_NewWithTypeExt( psz_mrl, name, 0, NULL,
                                            0, -1, ITEM_TYPE_DIRECTORY, 1 );
        msg_Dbg( p_sd, "Adding item %s", psz_mrl );
        free(psz_mrl);

        entry_item_append( p_sd, p_entry, p_item );
        vlc_gc_decref( p_item );
    }
}
Beispiel #2
0
static input_item_t *new_item( access_t *p_access, const char *psz_name,
                               int i_type )
{
    access_sys_t *p_sys = p_access->p_sys;
    input_item_t *p_item;
    char         *psz_uri, *psz_option = NULL;
    int           i_ret;

    i_ret = asprintf( &psz_uri, "smb://%s/%s", p_access->psz_location, psz_name );
    if( i_ret == -1 )
        return NULL;

    p_item = input_item_NewWithTypeExt( psz_uri, psz_name, 0, NULL, 0, -1,
                                        i_type, 1 );
    free( psz_uri );
    if( p_item == NULL )
        return NULL;

    /* Here we save on the node the credentials that allowed us to login.
     * That way the user isn't prompted more than once for credentials */
    if( p_sys->creds.login )
    {
        i_ret = asprintf( &psz_option, "smb-user=%s", p_sys->creds.login );
        if( i_ret == -1 )
            goto bailout;
        input_item_AddOption( p_item, psz_option, VLC_INPUT_OPTION_TRUSTED );
        free( psz_option );
    }

    if( p_sys->creds.password )
    {
        i_ret = asprintf( &psz_option, "smb-pwd=%s", p_sys->creds.password );
        if( i_ret == -1 )
            goto bailout;
        input_item_AddOption( p_item, psz_option, VLC_INPUT_OPTION_TRUSTED );
        free( psz_option );
    }

    if( p_sys->creds.domain )
    {
        i_ret = asprintf( &psz_option, "smb-domain=%s", p_sys->creds.domain );
        if( i_ret == -1 )
            goto bailout;
        input_item_AddOption( p_item, psz_option, VLC_INPUT_OPTION_TRUSTED );
        free( psz_option );
    }

    return p_item;
bailout:
    if( p_item )
        input_item_Release( p_item );
    free( psz_option );
    return NULL;
}
Beispiel #3
0
input_item_t* MediaServer::newItem(const char *objectID, const char *title )
{
    vlc_url_t url;
    vlc_UrlParse( &url, url_.c_str(), '?' );
    char* psz_url;

    if (asprintf( &psz_url, "upnp://%s://%s:%u%s?ObjectID=%s", url.psz_protocol,
                  url.psz_host, url.i_port ? url.i_port : 80, url.psz_path, objectID ) < 0 )
    {
        vlc_UrlClean( &url );
        return NULL;
    }
    vlc_UrlClean( &url );

    input_item_t* p_item = input_item_NewWithTypeExt( psz_url, title, 0, NULL,
                                                      0, -1, ITEM_TYPE_DIRECTORY, 1 );
    free( psz_url);
    return p_item;
}
Beispiel #4
0
static input_item_t *new_item( access_t *p_access, const char *psz_name,
                               int i_type )
{
    access_sys_t *p_sys = p_access->p_sys;
    input_item_t *p_item;
    char         *psz_uri;
    int           i_ret;

    char *psz_encoded_name = vlc_uri_encode( psz_name );
    if( psz_encoded_name == NULL )
        return NULL;
    const char *psz_sep = p_access->psz_location[0] != '\0'
        && p_access->psz_location[strlen(p_access->psz_location) -1] != '/'
        ? "/" : "";
    i_ret = asprintf( &psz_uri, "smb://%s%s%s", p_access->psz_location,
                      psz_sep, psz_encoded_name );
    free( psz_encoded_name );
    if( i_ret == -1 )
        return NULL;

    p_item = input_item_NewWithTypeExt( psz_uri, psz_name, 0, NULL, 0, -1,
                                        i_type, 1 );
    free( psz_uri );
    if( p_item == NULL )
        return NULL;

    /* Here we save on the node the credentials that allowed us to login.
     * That way the user isn't prompted more than once for credentials */
    if( p_sys->psz_user_opt != NULL )
        input_item_AddOption( p_item, p_sys->psz_user_opt,
                              VLC_INPUT_OPTION_TRUSTED );
    if( p_sys->psz_pwd_opt != NULL )
        input_item_AddOption( p_item, p_sys->psz_pwd_opt,
                              VLC_INPUT_OPTION_TRUSTED );
    if( p_sys->psz_domain_opt != NULL )
        input_item_AddOption( p_item, p_sys->psz_domain_opt,
                              VLC_INPUT_OPTION_TRUSTED );

    return p_item;
}
Beispiel #5
0
bool MediaServerList::addServer( MediaServerDesc* desc )
{
    vlc_mutex_locker lock( &lock_ );
    input_item_t* p_input_item = NULL;
    if ( getServer( desc->UDN ) )
        return false;

    msg_Dbg( p_sd_, "Adding server '%s' with uuid '%s'", desc->friendlyName.c_str(), desc->UDN.c_str() );

    char* psz_mrl;
    if( asprintf(&psz_mrl, "upnp://%s?ObjectID=0", desc->location.c_str() ) < 0 )
        return false;

    p_input_item = input_item_NewWithTypeExt( psz_mrl, desc->friendlyName.c_str(), 0,
                                              NULL, 0, -1, ITEM_TYPE_NODE, 1);
    free( psz_mrl );
    if ( !p_input_item )
        return false;
    desc->inputItem = p_input_item;
    input_item_SetDescription( p_input_item, desc->UDN.c_str() );
    services_discovery_AddItem( p_sd_, p_input_item, NULL );
    list_.push_back( desc );
    return true;
}
Beispiel #6
0
input_item_t* MediaServer::newItem(const char* title, const char*, const char*,
                                   mtime_t duration, const char* psz_url)
{
    return input_item_NewWithTypeExt( psz_url, title, 0, NULL, 0,
                                      duration, ITEM_TYPE_FILE, 1 );
}