]> git.sesse.net Git - vlc/commitdiff
Code the playlist_TreeMove function.
authorAntoine Cellerier <dionoea@videolan.org>
Sat, 4 Mar 2006 17:00:41 +0000 (17:00 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Sat, 4 Mar 2006 17:00:41 +0000 (17:00 +0000)
zorglub: i'm not really sure about the i_serial incrementation stuff, could you give it a look ?

include/vlc_playlist.h
include/vlc_symbols.h
src/playlist/item-ext.c

index d0cca9f536377355b96ed654160710dc32e8094e..bb458706aaeb15ba657c5d11c39ca4ff1541e744 100644 (file)
@@ -364,6 +364,7 @@ VLC_EXPORT( int, playlist_ItemAddOption, (playlist_item_t *, const char *) );
 #define playlist_SortGroup(p, i) playlist_Sort( p, SORT_GROUP, i)
 VLC_EXPORT( int,  playlist_Sort, ( playlist_t *, int, int) );
 VLC_EXPORT( int,  playlist_Move, ( playlist_t *, int, int ) );
+VLC_EXPORT( int,  playlist_TreeMove, ( playlist_t *, playlist_item_t *, playlist_item_t *, int, int ) );
 VLC_EXPORT( int,  playlist_NodeGroup, ( playlist_t *, int,playlist_item_t *,playlist_item_t **,int, int, int ) );
 VLC_EXPORT( int,  playlist_NodeSort, ( playlist_t *, playlist_item_t *,int, int ) );
 VLC_EXPORT( int,  playlist_RecursiveNodeSort, ( playlist_t *, playlist_item_t *,int, int ) );
index fcb5f75aa9da4a6291a724cbf1c48824a7e8e0d7..ee4fe882abc239a4c18d0fe91acb530489b3ffb6 100644 (file)
@@ -475,6 +475,7 @@ struct module_symbols_t
     char * (*FromLocaleDup_inner) (const char *);
     int (*utf8_mkdir_inner) (const char *filename);
     vlm_media_t* (*vlm_MediaSearch_inner) (vlm_t *, const char *);
+    int (*playlist_TreeMove_inner) (playlist_t *, playlist_item_t *, playlist_item_t *, int, int);
 };
 # if defined (__PLUGIN__)
 #  define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
@@ -930,6 +931,7 @@ struct module_symbols_t
 #  define FromLocaleDup (p_symbols)->FromLocaleDup_inner
 #  define utf8_mkdir (p_symbols)->utf8_mkdir_inner
 #  define vlm_MediaSearch (p_symbols)->vlm_MediaSearch_inner
+#  define playlist_TreeMove (p_symbols)->playlist_TreeMove_inner
 # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
 /******************************************************************
  * STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
@@ -1388,6 +1390,7 @@ struct module_symbols_t
     ((p_symbols)->FromLocaleDup_inner) = FromLocaleDup; \
     ((p_symbols)->utf8_mkdir_inner) = utf8_mkdir; \
     ((p_symbols)->vlm_MediaSearch_inner) = vlm_MediaSearch; \
+    ((p_symbols)->playlist_TreeMove_inner) = playlist_TreeMove; \
     (p_symbols)->net_ConvertIPv4_deprecated = NULL; \
     (p_symbols)->__stats_CounterGet_deprecated = NULL; \
     (p_symbols)->__stats_TimerDumpAll_deprecated = NULL; \
index 835b577ee488be1640c8f733bca3a56809022d43..d35b710b1592225b4e659ad04d6174df3c64a423 100644 (file)
@@ -890,36 +890,39 @@ int playlist_TreeMove( playlist_t * p_playlist, playlist_item_t *p_item,
 {
     int i;
     playlist_item_t *p_detach = NULL;
-#if 0
-    if( i_view == ALL_VIEWS )
-    {
-        for( i = 0 ; i < p_playlist->i_views; i++ )
-        {
-            playlist_TreeMove( p_playlist, p_item, p_node, i_newpos,
-                               p_playlist->pp_views[i] );
-        }
-    }
-#endif
+    struct item_parent_t *p_parent;
 
-    /* Find the parent */
+    /* Detach from the parent */
+    printf("detaching from parent(s)\n");
     for( i = 0 ; i< p_item->i_parents; i++ )
     {
         if( p_item->pp_parents[i]->i_view == i_view )
         {
+            int j;
             p_detach = p_item->pp_parents[i]->p_parent;
-            break;
+            for( j = 0; j < p_detach->i_children; j++ )
+            {
+                if( p_detach->pp_children[j] == p_item ) break;
+            }
+            REMOVE_ELEM( p_detach->pp_children, p_detach->i_children, j );
+            p_detach->i_serial++;
+            free( p_item->pp_parents[i] );
+            REMOVE_ELEM( p_item->pp_parents, p_item->i_parents, i );
         }
     }
-    if( p_detach == NULL )
-    {
-        msg_Err( p_playlist, "item not found in view %i", i_view );
-        return VLC_EGENERIC;
-    }
-
-    /* Detach from the parent */
-//    playlist_NodeDetach( p_detach, p_item );
 
     /* Attach to new parent */
+    printf("attaching to new parent...\n");
+    INSERT_ELEM( p_node->pp_children, p_node->i_children, i_newpos, p_item );
+
+    p_parent = malloc( sizeof( struct item_parent_t ) );
+    p_parent->p_parent = p_node;
+    p_parent->i_view = i_view;
+
+    INSERT_ELEM( p_item->pp_parents, p_item->i_parents, p_item->i_parents,
+                 p_parent );
+    p_node->i_serial++;
+    p_item->i_serial++;
 
     return VLC_SUCCESS;
 }