[vlc-devel] [PATCH] D-Bus controls.

Mirsal ENNAIME mirsal at gmail.com
Sun Jan 28 21:34:07 CET 2007


Here's some code to speed things up about D-Bus integration.
Implemented missing D-Bus methods GetCurrentTrack, GetLength and DelTrack.

I didn't test the code.

Mirsal ENNAIME.
-------------- next part --------------
Index: modules/control/dbus.c
===================================================================
--- modules/control/dbus.c	(r?vision 18650)
+++ modules/control/dbus.c	(copie de travail)
@@ -371,11 +371,25 @@
 }
 
 DBUS_METHOD( GetCurrentTrack )
-{ //TODO
+{ //TODO: Check the code.
     REPLY_INIT;
     OUT_ARGUMENTS;
     dbus_int32_t i_position = 0;
-    //TODO get position of playing element
+    playlist_t *p_playlist = pl_Yield( (vlc_object_t*) p_this );
+    playlist_item_t* p_tested_item = p_playlist->p_root_onelevel;
+    
+    while ( p_tested_item->i_id != p_playlist->status.p_item->i_id )
+    {
+        i_position++;
+        p_tested_item = playlist_GetNextLeaf( p_playlist, 
+                        p_playlist->p_root_onelevel, 
+                        p_tested_item,
+                        VLC_FALSE,
+                        VLC_FALSE );
+    }
+
+    pl_Release( p_playlist );
+
     ADD_INT32( &i_position );
     REPLY_SEND;
 }
@@ -407,23 +421,27 @@
 }
 
 DBUS_METHOD( GetLength )
-{ //TODO
+{ //TODO: Check the code.
     REPLY_INIT;
     OUT_ARGUMENTS;
     dbus_int32_t i_elements = 0;
-    //TODO: return number of elements in playlist
+
+    playlist_t *p_playlist = pl_Yield( (vlc_object_t*) p_this );
+    i_elements = p_playlist->i_enabled; 
+    pl_Release( p_playlist );
+     
     ADD_INT32( &i_elements );
     REPLY_SEND;
 }
 
 DBUS_METHOD( DelTrack )
-{ //TODO
+{ //TODO: Check the code.
     REPLY_INIT;
 
     DBusError error;
     dbus_error_init( &error );
 
-    dbus_int32_t i_position;
+    dbus_int32_t i_position, i_count;
 
     dbus_message_get_args( p_from, &error,
             DBUS_TYPE_INT32, &i_position,
@@ -436,8 +454,19 @@
         dbus_error_free( &error );
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
     }
+    
+    while ( i_count < i_position ) 
+    {
+        i_count++;
+        p_tested_item = playlist_GetNextLeaf( p_playlist, 
+                        p_playlist->p_root_onelevel, 
+                        p_tested_item,
+                        VLC_FALSE,
+                        VLC_FALSE );
+    }
 
-    //TODO delete the element
+    playlist_ItemDelete( p_tested_item );
+    pl_Release( p_playlist );
 
     REPLY_SEND;
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20070128/fe0b38a3/attachment.sig>


More information about the vlc-devel mailing list