static int vlclua_playlist_get( lua_State *L ) { playlist_t *p_playlist = vlclua_get_playlist_internal( L ); PL_LOCK; playlist_item_t *p_item = NULL; if( lua_isnumber( L, 1 ) ) { int i_id = lua_tointeger( L, 1 ); p_item = playlist_ItemGetById( p_playlist, i_id ); if( !p_item ) { PL_UNLOCK; return 0; /* Should we return an error instead? */ } } else if( lua_isstring( L, 1 ) ) { const char *psz_what = lua_tostring( L, 1 ); if( !strcasecmp( psz_what, "normal" ) || !strcasecmp( psz_what, "playlist" ) ) p_item = p_playlist->p_playing; else if( !strcasecmp( psz_what, "ml" ) || !strcasecmp( psz_what, "media library" ) ) p_item = p_playlist->p_media_library; else if( !strcasecmp( psz_what, "root" ) ) p_item = p_playlist->p_root; else { /* currently, psz_what must be SD module's longname! */ p_item = playlist_ChildSearchName( p_playlist->p_root, psz_what ); if( !p_item ) { PL_UNLOCK; return 0; /* Should we return an error instead? */ } } } else { p_item = p_playlist->p_root; } push_playlist_item( L, p_item ); PL_UNLOCK; return 1; }
void PLSelector::setSource( QTreeWidgetItem *item ) { if( !item ) return; bool b_ok; int i_type = item->data( 0, TYPE_ROLE ).toInt( &b_ok ); if( !b_ok || i_type == CATEGORY_TYPE ) return; bool sd_loaded; if( i_type == SD_TYPE ) { QString qs = item->data( 0, NAME_ROLE ).toString(); sd_loaded = playlist_IsServicesDiscoveryLoaded( THEPL, qtu( qs ) ); if( !sd_loaded ) playlist_ServicesDiscoveryAdd( THEPL, qtu( qs ) ); } playlist_Lock( THEPL ); playlist_item_t *pl_item = NULL; if( i_type == SD_TYPE ) { pl_item = playlist_ChildSearchName( THEPL->p_root, qtu( item->data(0, LONGNAME_ROLE ).toString() ) ); if( item->data( 0, SPECIAL_ROLE ).toInt() == IS_PODCAST ) { if( pl_item && !sd_loaded ) { podcastsParentId = pl_item->i_id; for( int i=0; i < pl_item->i_children; i++ ) addPodcastItem( pl_item->pp_children[i] ); } pl_item = NULL; //to prevent activating it } } else pl_item = item->data( 0, PL_ITEM_ROLE ).value<playlist_item_t*>(); playlist_Unlock( THEPL ); if( pl_item ) emit activated( pl_item ); }
/* A new item has been added to a certain sd */ static void playlist_sd_item_added( const vlc_event_t * p_event, void * user_data ) { input_item_t * p_input = p_event->u.services_discovery_item_added.p_new_item; const char * psz_cat = p_event->u.services_discovery_item_added.psz_category; playlist_item_t *p_new_item, * p_parent = user_data; playlist_t * p_playlist = p_parent->p_playlist; msg_Dbg( p_playlist, "Adding %s in %s", p_input->psz_name ? p_input->psz_name : "(null)", psz_cat ? psz_cat : "(null)" ); PL_LOCK; /* If p_parent is in root category (this is clearly a hack) and we have a cat */ if( !EMPTY_STR(psz_cat) && p_parent->p_parent == p_playlist->p_root_category ) { /* */ playlist_item_t * p_cat; p_cat = playlist_ChildSearchName( p_parent, psz_cat ); if( !p_cat ) { p_cat = playlist_NodeCreate( p_playlist, psz_cat, p_parent, 0, NULL ); p_cat->i_flags &= ~PLAYLIST_SKIP_FLAG; } p_parent = p_cat; } p_new_item = playlist_NodeAddInput( p_playlist, p_input, p_parent, PLAYLIST_APPEND, PLAYLIST_END, pl_Locked ); if( p_new_item ) { p_new_item->i_flags &= ~PLAYLIST_SKIP_FLAG; p_new_item->i_flags &= ~PLAYLIST_SAVE_FLAG; } PL_UNLOCK; }