📄 macro.c
字号:
{ playlist_LockDelete( p_sys->p_playlist, p_items[i] ); msg_Dbg( p_intf, "requested playlist delete: %d", p_items[i] ); p_items[i] = -1; } } if( p_items ) free( p_items ); break; } case MVLC_KEEP: { int i_item, *p_items = NULL, i_nb_items = 0; char item[512], *p_parser = p_request; int i,j; /* Get the list of items to keep */ while( (p_parser = E_(ExtractURIValue)( p_parser, "item", item, 512 )) ) { if( !*item ) continue; i_item = atoi( item ); p_items = realloc( p_items, (i_nb_items + 1) * sizeof(int) ); p_items[i_nb_items] = i_item; i_nb_items++; } for( i = p_sys->p_playlist->i_size - 1 ; i >= 0; i-- ) { /* Check if the item is in the keep list */ for( j = 0 ; j < i_nb_items ; j++ ) { if( p_items[j] == p_sys->p_playlist->pp_items[i]->input.i_id ) break; } if( j == i_nb_items ) { playlist_LockDelete( p_sys->p_playlist, p_sys->p_playlist->pp_items[i]->input.i_id ); msg_Dbg( p_intf, "requested playlist delete: %d", i ); } } if( p_items ) free( p_items ); break; } case MVLC_EMPTY: { playlist_LockClear( p_sys->p_playlist ); msg_Dbg( p_intf, "requested playlist empty" ); break; } case MVLC_SORT: { char type[12]; char order[2]; char item[512]; int i_order; int i_item; E_(ExtractURIValue)( p_request, "type", type, 12 ); E_(ExtractURIValue)( p_request, "order", order, 2 ); E_(ExtractURIValue)( p_request, "item", item, 512 ); i_item = atoi( item ); if( order[0] == '0' ) i_order = ORDER_NORMAL; else i_order = ORDER_REVERSE; if( !strcmp( type , "title" ) ) { playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/ p_sys->p_playlist->pp_views[0]->p_root, SORT_TITLE_NODES_FIRST, ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE ); msg_Dbg( p_intf, "requested playlist sort by title (%d)" , i_order ); } else if( !strcmp( type , "author" ) ) { playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/ p_sys->p_playlist->pp_views[0]->p_root, SORT_AUTHOR, ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE ); msg_Dbg( p_intf, "requested playlist sort by author (%d)" , i_order ); } else if( !strcmp( type , "shuffle" ) ) { playlist_RecursiveNodeSort( p_sys->p_playlist, /*playlist_ItemGetById( p_sys->p_playlist, i_item ),*/ p_sys->p_playlist->pp_views[0]->p_root, SORT_RANDOM, ( i_order == 0 ) ? ORDER_NORMAL : ORDER_REVERSE ); msg_Dbg( p_intf, "requested playlist shuffle"); } break; } case MVLC_MOVE: { char psz_pos[6]; char psz_newpos[6]; int i_pos; int i_newpos; E_(ExtractURIValue)( p_request, "psz_pos", psz_pos, 6 ); E_(ExtractURIValue)( p_request, "psz_newpos", psz_newpos, 6 ); i_pos = atoi( psz_pos ); i_newpos = atoi( psz_newpos ); if ( i_pos < i_newpos ) { playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 ); } else { playlist_Move( p_sys->p_playlist, i_pos, i_newpos ); } msg_Dbg( p_intf, "requested move playlist item %d to %d", i_pos, i_newpos); break; } /* admin function */ case MVLC_CLOSE: { char id[512]; E_(ExtractURIValue)( p_request, "id", id, 512 ); msg_Dbg( p_intf, "requested close id=%s", id );#if 0 if( p_sys->p_httpd->pf_control( p_sys->p_httpd, HTTPD_SET_CLOSE, id, NULL ) ) { msg_Warn( p_intf, "close failed for id=%s", id ); }#endif break; } case MVLC_SHUTDOWN: { msg_Dbg( p_intf, "requested shutdown" ); p_intf->p_vlc->b_die = VLC_TRUE; break; } /* vlm */ case MVLC_VLM_NEW: case MVLC_VLM_SETUP: { static const char *vlm_properties[11] = { /* no args */ "enabled", "disabled", "loop", "unloop", /* args required */ "input", "output", "option", "date", "period", "repeat", "append", }; vlm_message_t *vlm_answer; char name[512]; char *psz = malloc( strlen( p_request ) + 1000 ); char *p = psz; char *vlm_error; int i; if( p_intf->p_sys->p_vlm == NULL ) p_intf->p_sys->p_vlm = vlm_New( p_intf ); if( p_intf->p_sys->p_vlm == NULL ) break; E_(ExtractURIValue)( p_request, "name", name, 512 ); if( E_(StrToMacroType)( control ) == MVLC_VLM_NEW ) { char type[20]; E_(ExtractURIValue)( p_request, "type", type, 20 ); p += sprintf( psz, "new %s %s", name, type ); } else { p += sprintf( psz, "setup %s", name ); } /* Parse the request */ for( i = 0; i < 11; i++ ) { char val[512]; E_(ExtractURIValue)( p_request, vlm_properties[i], val, 512 ); decode_URI( val ); if( strlen( val ) > 0 && i >= 4 ) { p += sprintf( p, " %s %s", vlm_properties[i], val ); } else if( E_(TestURIParam)( p_request, vlm_properties[i] ) && i < 4 ) { p += sprintf( p, " %s", vlm_properties[i] ); } } vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer ); if( vlm_answer->psz_value == NULL ) /* there is no error */ { vlm_error = strdup( "" ); } else { vlm_error = malloc( strlen(vlm_answer->psz_name) + strlen(vlm_answer->psz_value) + strlen( " : ") + 1 ); sprintf( vlm_error , "%s : %s" , vlm_answer->psz_name, vlm_answer->psz_value ); } E_(mvar_AppendNewVar)( p_args->vars, "vlm_error", vlm_error ); vlm_MessageDelete( vlm_answer ); free( vlm_error ); free( psz ); break; } case MVLC_VLM_DEL: { vlm_message_t *vlm_answer; char name[512]; char psz[512+10]; if( p_intf->p_sys->p_vlm == NULL ) p_intf->p_sys->p_vlm = vlm_New( p_intf ); if( p_intf->p_sys->p_vlm == NULL ) break; E_(ExtractURIValue)( p_request, "name", name, 512 ); sprintf( psz, "del %s", name ); vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer ); /* FIXME do a vlm_answer -> var stack conversion */ vlm_MessageDelete( vlm_answer ); break; } case MVLC_VLM_PLAY: case MVLC_VLM_PAUSE: case MVLC_VLM_STOP: case MVLC_VLM_SEEK: { vlm_message_t *vlm_answer; char name[512]; char psz[512+10]; if( p_intf->p_sys->p_vlm == NULL ) p_intf->p_sys->p_vlm = vlm_New( p_intf ); if( p_intf->p_sys->p_vlm == NULL ) break; E_(ExtractURIValue)( p_request, "name", name, 512 ); if( E_(StrToMacroType)( control ) == MVLC_VLM_PLAY ) sprintf( psz, "control %s play", name ); else if( E_(StrToMacroType)( control ) == MVLC_VLM_PAUSE ) sprintf( psz, "control %s pause", name ); else if( E_(StrToMacroType)( control ) == MVLC_VLM_STOP ) sprintf( psz, "control %s stop", name ); else if( E_(StrToMacroType)( control ) == MVLC_VLM_SEEK ) { char percent[20]; E_(ExtractURIValue)( p_request, "percent", percent, 512 ); sprintf( psz, "control %s seek %s", name, percent ); } vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer ); /* FIXME do a vlm_answer -> var stack conversion */ vlm_MessageDelete( vlm_answer ); break; } case MVLC_VLM_LOAD: case MVLC_VLM_SAVE: { vlm_message_t *vlm_answer; char file[512]; char psz[512]; if( p_intf->p_sys->p_vlm == NULL ) p_intf->p_sys->p_vlm = vlm_New( p_intf ); if( p_intf->p_sys->p_vlm == NULL ) break; E_(ExtractURIValue)( p_request, "file", file, 512 ); decode_URI( file ); if( E_(StrToMacroType)( control ) == MVLC_VLM_LOAD ) sprintf( psz, "load %s", file ); else sprintf( psz, "save %s", file ); vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz, &vlm_answer ); /* FIXME do a vlm_answer -> var stack conversion */ vlm_MessageDelete( vlm_answer ); break; } default: if( *control ) { PRINTS( "<!-- control param(%s) unsupported -->", control ); } break; } break; case MVLC_SET: { char value[512]; int i; float f; if( i_request <= 0 || *m->param1 == '\0' || strstr( p_request, m->param1 ) == NULL ) { break; } E_(ExtractURIValue)( p_request, m->param1, value, 512 ); decode_URI( value ); switch( E_(StrToMacroType)( m->param2 ) ) { case MVLC_INT: i = atoi( value ); config_PutInt( p_intf, m->param1, i ); break; case MVLC_FLOAT: f = atof( value ); config_PutFloat( p_intf, m->param1, f ); break; case MVLC_STRING: config_PutPsz( p_intf, m->param1, value ); break; default: PRINTS( "<!-- invalid type(%s) in set -->", m->param2 ) } break; } case MVLC_GET: { char value[512]; int i; float f; char *psz; lldiv_t div; if( *m->param1 == '\0' ) { break; } switch( E_(StrToMacroType)( m->param2 ) ) { case MVLC_INT: i = config_GetInt( p_intf, m->param1 ); sprintf( value, "%d", i ); break; case MVLC_FLOAT: f = config_GetFloat( p_intf, m->param1 ); div = lldiv( f * 1000000 , 1000000 ); sprintf( value, I64Fd".%06u", div.quot, (unsigned int)div.rem ); break; case MVLC_STRING: psz = config_GetPsz( p_intf, m->param1 ); if( psz != NULL ) { strlcpy( value, psz,sizeof( value ) ); free( psz ); } else *value = '\0'; msg_Dbg( p_intf, "%d: value = \"%s\"", __LINE__, value ); break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -