changeset 1460:68fab774c206

Automated merge with ssh://hg.atheme.org//hg/audacious-plugins
author William Pitcock <nenolod@atheme-project.org>
date Fri, 10 Aug 2007 19:36:01 -0500
parents 4afd6954159d (current diff) b2debf8c9ec8 (diff)
children 161d289f335c
files
diffstat 36 files changed, 372 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac	Fri Aug 10 19:35:53 2007 -0500
+++ b/configure.ac	Fri Aug 10 19:36:01 2007 -0500
@@ -1225,6 +1225,25 @@
     AC_MSG_RESULT([*** mms plugin disabled by request ***])
 fi
 
+
+dnl *** MTP Upload
+
+AC_ARG_ENABLE(mtp_up,
+[  --enable-mtp_up           enable mtp upload support. (default=disabled)],
+[have_mtp_up=$enableval],
+[have_mtp_up=no])
+
+if test "x$have_mtp_up" = "xyes"; then
+    have_mtp_up=yes
+    PKG_CHECK_MODULES(MTP, [libmtp >= 0.1.0], [GENERAL_PLUGINS="$GENERAL_PLUGINS mtp_up" ], [have_mtp_up="no"])
+    MTP_LIBS=`pkg-config --libs libmtp`
+    MTP_CFLAGS=`pkg-config --cflags libmtp`
+else
+    have_mtp_up=no
+fi
+AC_SUBST(MTP_LIBS)
+AC_SUBST(MTP_CFLAGS)
+
 dnl *** libparanormal checks
 
 AC_ARG_ENABLE(paranormal,
@@ -1501,6 +1520,7 @@
 echo "  Control via event device (evdev-plug):  $have_evdevplug"
 echo "  LIRC:                                   $have_lirc"
 echo "  AudioScrobbler Client:                  $scrobbler"
+echo "  Upload to MTP device:                   $have_mtp_up"
 echo
 echo "  Effect"
 echo "  ------"
--- a/mk/rules.mk.in	Fri Aug 10 19:35:53 2007 -0500
+++ b/mk/rules.mk.in	Fri Aug 10 19:36:01 2007 -0500
@@ -226,6 +226,8 @@
 MKINSTALLDIRS ?= @MKINSTALLDIRS@
 MSGFMT ?= @MSGFMT@
 MSGMERGE ?= @MSGMERGE@
+MTP_CFLAGS ?= @MTP_CFLAGS@
+MTP_LIBS ?= @MTP_LIBS@
 OBJEXT ?= @OBJEXT@
 OGG_VORBIS_CFLAGS ?= @OGG_VORBIS_CFLAGS@
 OGG_VORBIS_LIBS ?= @OGG_VORBIS_LIBS@
--- a/src/aac/src/libmp4.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/aac/src/libmp4.c	Fri Aug 10 19:36:01 2007 -0500
@@ -117,6 +117,7 @@
     buffer_playing = TRUE;
     playback->playing = 1; //XXX should acquire lock?
     decodeThread = g_thread_self();
+    playback->set_pb_ready(playback);
     mp4_decode(playback);
 }
 
--- a/src/adplug/adplug-xmms.cc	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/adplug/adplug-xmms.cc	Fri Aug 10 19:36:01 2007 -0500
@@ -989,6 +989,7 @@
   // start player func
   dbg_printf ("play");
   plr.play_thread =  g_thread_self();
+  playback->set_pb_ready(playback);
   play_loop(playback);
   dbg_printf (".\n");
 }
--- a/src/alac/plugin.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/alac/plugin.c	Fri Aug 10 19:36:01 2007 -0500
@@ -180,6 +180,7 @@
     going = 1;
     playback = data;
     playback_thread = g_thread_self();
+    playback->set_pb_ready(playback);
     decode_thread(filename);
 }
 
--- a/src/amidi-plug/amidi-plug.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/amidi-plug/amidi-plug.c	Fri Aug 10 19:36:01 2007 -0500
@@ -139,24 +139,9 @@
 
 static void amidiplug_stop( InputPlayback * playback )
 {
-  gboolean is_error = FALSE;
   DEBUGMSG( "STOP request at tick: %i\n" , midifile.playing_tick );
 
   g_mutex_lock( amidiplug_playing_mutex );
-  if ( amidiplug_playing_status == AMIDIPLUG_ERR )
-    is_error = TRUE;
-  g_mutex_unlock( amidiplug_playing_mutex );
-  
-  if ( !is_error )
-  {
-    /* if stop wasn't called due to error condition,
-       wait until the play thread reach a 'safe state'
-       (that is, when amidiplug_play_thread exists) */
-    while ( !amidiplug_play_thread )
-      g_usleep( 20000 );
-  }
-
-  g_mutex_lock( amidiplug_playing_mutex );
   amidiplug_playing_status = AMIDIPLUG_STOP;
   g_cond_signal( amidiplug_pause_cond );
   g_mutex_unlock( amidiplug_playing_mutex );
@@ -476,6 +461,7 @@
       amidiplug_playing_status = AMIDIPLUG_PLAY;
       g_mutex_unlock( amidiplug_playing_mutex );
       amidiplug_play_thread = g_thread_self();
+      playback->set_pb_ready(playback);
       amidiplug_play_loop(playback);
       break;
     }
--- a/src/cdaudio-ng/cdaudio-ng.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/cdaudio-ng/cdaudio-ng.c	Fri Aug 10 19:36:01 2007 -0500
@@ -513,6 +513,7 @@
 		pdae_params->seektime = -1;
 		pdae_params->currlsn = trackinfo[trackno].startlsn;
 		pdae_params->thread = g_thread_self();
+		pinputplayback->set_pb_ready(pinputplayback);
 		dae_play_loop(pdae_params);
 	}
 	else {
--- a/src/console/Audacious_Driver.cxx	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/console/Audacious_Driver.cxx	Fri Aug 10 19:36:01 2007 -0500
@@ -405,6 +405,7 @@
 	pending_seek = -1;
 	console_ip_is_going = 1;
 	decode_thread = g_thread_self();
+	playback->set_pb_ready(playback);
         play_loop_track( playback );
 }
 
--- a/src/cue/cuesheet.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/cue/cuesheet.c	Fri Aug 10 19:36:01 2007 -0500
@@ -218,6 +218,7 @@
 		return;
 	}
 	play_thread = g_thread_self();
+	data->set_pb_ready(data);
 	play_cue_uri(data, uri);
 }
 
--- a/src/daap/Makefile	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/daap/Makefile	Fri Aug 10 19:36:01 2007 -0500
@@ -7,7 +7,15 @@
 
 LIBDIR = $(plugindir)/$(TRANSPORT_PLUGIN_DIR)
 
-LIBADD += ./xmms2-daap/xmms2-daap.a $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) 
+#For the moment i'm hardcoding it but it will be configurable
+#MDNS_LIBS=-ldns_sd
+MDNS_LIBS=-lavahi-glib -lavahi-common -lavahi-client
+#MDNS_LIBS= 
+
+
+
+
+LIBADD += ./xmms2-daap/xmms2-daap.a $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) $(MDNS_LIBS)
 
 SOURCES = daap.c
 
--- a/src/daap/daap.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/daap/daap.c	Fri Aug 10 19:36:01 2007 -0500
@@ -20,30 +20,127 @@
 
 #include <audacious/vfs.h>
 #include <audacious/plugin.h>
+#include <audacious/discovery.h>
 /*
 #include <audacious/configdb.h>
 #include <libmowgli/mowgli.h>
 #include <curl/curl.h>
 */
 #include <glib.h>
-#include <daap/client.h>
+#include "xmms2-daap/daap_mdns_browse.h"
+#include "xmms2-daap/daap_cmd.h"
+
+gboolean daap_initialized=FALSE;
+
+GMutex * mutex_init = NULL; 
+
+GMutex * mutex_discovery = NULL; 
+
+GList * daap_servers = NULL;
+
+guint request_id=0;
+
+GList * daap_get_server_playlist(gchar * host, gint port  )
+{
+return NULL;
+
+}
 
 
+GList * daap_discovery_get_devices_impl(void)
+{   
+    discovery_device_t * current_device=NULL;
+    GList * returned_devices=NULL;
+    GSList * daap_found_devices=NULL,
+          * current_server=NULL;
+
+    if(mutex_discovery==NULL)
+        return NULL;
+
+    g_mutex_lock(mutex_discovery);
+    g_print ("caut\n");
+    daap_found_devices  = daap_mdns_get_server_list ();
+    current_server=daap_found_devices;
+    g_print ("entering for\n");
+    if(current_server!=NULL)
+        g_print("!=NULL\n");
+    else 
+        g_print("==NULL\n");
+        
+    for (; current_server; current_server = g_slist_next (current_server)) 
+    {
+     g_print ("in for\n");
+
+        current_device = g_new0(discovery_device_t,1);
+        daap_mdns_server_t *serv=current_server->data;
+        current_device->device_name = 
+            g_strdup_printf("%s(%s)",
+                    serv->server_name,
+                    serv->mdns_hostname
+                    );
+
+        current_device->device_address = 
+            g_strdup_printf(
+                    "%s:%d",
+                    serv->address,
+                    serv->port
+                    );
+        current_device->device_playlist=
+            daap_get_server_playlist(
+                    serv->mdns_hostname,
+                    serv->port
+                    );
+        returned_devices = g_list_prepend(returned_devices,current_device); 
+#if 1
+        g_print("DAAP: Found device %s at address %s\n", current_device->device_name ,current_device->device_address );
+#endif
+    }
+    g_print("am iesit\n");
+    g_slist_free(daap_found_devices);
+    g_mutex_unlock(mutex_discovery);
+    return g_list_reverse(returned_devices);
+}
 
 
 
 
-DAAP_SClientHost *libopendaap_host;
-
-
 VFSFile * daap_vfs_fopen_impl(const gchar * path, const gchar * mode)
 {
-    VFSFile *file;
+    VFSFile *file=NULL;
+    if(!mutex_init)
+        return NULL;
+
+    g_mutex_lock(mutex_init); /* locking for init */
+    if(!daap_initialized)
+    {
+        if( !daap_mdns_initialize ())
+        {
+#if 1    /*this isn't a fatal error, we can try again later*/
+            g_print("Error while initializing DAAP !!!\n");
+#endif          
+            g_mutex_unlock(mutex_init);
+            return NULL;
+        }
+        else
+        {
+#if 1   
+            g_print("DAAP was initialized succesfully\n");
+#endif  
+            daap_initialized=TRUE;
+        }
+    
+    if(daap_initialized)
+    {
+        sleep(1);
+        daap_discovery_get_devices_impl();
+    }
+    }
+    g_mutex_unlock(mutex_init);  /*init ended*/
+
     file = g_new0(VFSFile, 1);
-    /* connectiong daap*/
+//    GList * l = 
 
-
-    return file;
+        return file;
 }
 
 gint daap_vfs_fclose_impl(VFSFile * file)
@@ -120,10 +217,15 @@
 };
 
 static void init(void)
-{       
+{   
+    mutex_init = g_mutex_new();        
+    mutex_discovery = g_mutex_new();        
     vfs_register_transport(&daap_const);
 }
 static void cleanup(void)
 {
+    g_mutex_free (mutex_init);
+    g_mutex_free (mutex_discovery);
+    daap_mdns_destroy ();
 }
 DECLARE_PLUGIN(daap, init, cleanup, NULL, NULL, NULL, NULL, NULL, NULL)
--- a/src/daap/xmms2-daap/Makefile	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/daap/xmms2-daap/Makefile	Fri Aug 10 19:36:01 2007 -0500
@@ -14,11 +14,14 @@
 
 #		 daap_xform.c 
 LIBADD = $(GLIB_LIBS) 
- 
 
-CFLAGS = $(GLIB_CFLAGS)  -I/usr/include   -std=c99 -Wall # -H -v
+#For the moment i'm hardcoding it but it will be configurable
+#MDNS_IMPL=DAAP_MDNS_DNSSD
+MDNS_IMPL=DAAP_MDNS_AVAHI
+#MDNS_IMPL=DAAP_MDNS_DUMMY 
 
-#CFLAGS += $(PICFLAGS) $(ARCH_DEFINES) $(CURL_CFLAGS) -c -I../../../intl -I../../.. -I/usr/include -Wall   -std=c99 -H -v
+CFLAGS = $(GLIB_CFLAGS) $(PICFLAGS) -std=c99 -Wall -D_POSIX_SOURCE -D$(MDNS_IMPL) 
+
 OBJECTS=${SOURCES:.c=.o}
 
 include ../../../mk/objective.mk
--- a/src/daap/xmms2-daap/daap_conn.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/daap/xmms2-daap/daap_conn.c	Fri Aug 10 19:36:01 2007 -0500
@@ -121,7 +121,7 @@
         FD_SET (sockfd, &fds);
 
 		sret = select (sockfd + 1, NULL, &fds, NULL, &tmout);
-		if (sret == 0 || sret == SOCKET_ERROR) {
+		if (sret <= 0 ) {
 			g_io_channel_unref (sock_chan);
 			return NULL;
 		}
--- a/src/daap/xmms2-daap/daap_conn.h	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/daap/xmms2-daap/daap_conn.h	Fri Aug 10 19:36:01 2007 -0500
@@ -35,7 +35,7 @@
 #define CONTENT_LENGTH "Content-Length: "
 #define CONTENT_TYPE "Content-Type: "
 /* TODO does this work ok? */
-#define USER_AGENT VERSION
+#define USER_AGENT "Audacious"
 /*#define USER_AGENT "iTunes/4.6 (Windows; N)"*/
 
 GIOChannel *
--- a/src/daap/xmms2-daap/daap_mdns_avahi.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/daap/xmms2-daap/daap_mdns_avahi.c	Fri Aug 10 19:36:01 2007 -0500
@@ -13,7 +13,7 @@
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  */
-
+#ifdef DAAP_MDNS_AVAHI
 #include "daap_mdns_browse.h"
 
 #include <string.h>
@@ -264,4 +264,5 @@
 {
 	/* FIXME: deinit avahi */
 }
+#endif
 
--- a/src/daap/xmms2-daap/daap_mdns_dnssd.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/daap/xmms2-daap/daap_mdns_dnssd.c	Fri Aug 10 19:36:01 2007 -0500
@@ -12,6 +12,7 @@
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  */
+#ifdef DAAP_MDNS_DNSSD
 
 #include <glib.h>
 #include <dns_sd.h>
@@ -182,7 +183,7 @@
 		err = DNSServiceResolve (&ud2->client, 0, kDNSServiceInterfaceIndexAny,
 		                         server->mdnsname,
 		                         "_daap._tcp", "local",
-		                         resolve_reply, ud2);
+		                         (DNSServiceResolveReply)resolve_reply, ud2);
 
 		if (err != kDNSServiceErr_NoError) {
 			g_warning ("Couldn't do ServiceResolv");
@@ -332,7 +333,7 @@
 	                        service, 0, browse_reply, ud);
 
 	if (err != kDNSServiceErr_NoError) {
-		g_warning ("Couldn't setup mDNS poller");
+		g_warning ("Couldn't setup mDNS poller, error = %d",err);
 		return FALSE;
 	}
 
@@ -415,4 +416,4 @@
 	g_mdns->mutex = g_mutex_new ();
 	return g_mdns_browse (g_mdns, "_daap._tcp", NULL, NULL);
 }
-
+#endif
--- a/src/daap/xmms2-daap/daap_mdns_dummy.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/daap/xmms2-daap/daap_mdns_dummy.c	Fri Aug 10 19:36:01 2007 -0500
@@ -12,7 +12,7 @@
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  */
-
+#ifdef AVAHI_MDNS_DUMMY
 #include <glib.h>
 
 #include "daap_mdns_browse.h"
@@ -33,4 +33,4 @@
 daap_mdns_destroy ()
 {
 }
-
+#endif
--- a/src/flacng/plugin.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/flacng/plugin.c	Fri Aug 10 19:36:01 2007 -0500
@@ -578,6 +578,7 @@
     flac_ip.set_info(get_title(input->filename, main_info), l, -1, main_info->stream.samplerate, main_info->stream.channels);
 
     thread = g_thread_self();
+    input->set_pb_ready(input);
     flac_play_loop(input);
 
     _LEAVE;
--- a/src/madplug/plugin.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/madplug/plugin.c	Fri Aug 10 19:36:01 2007 -0500
@@ -469,6 +469,7 @@
     g_mutex_unlock(pb_mutex);
 
     decode_thread = g_thread_self();
+    playback->set_pb_ready(playback);
     decode_loop(&info);
 }
 
--- a/src/metronom/metronom.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/metronom/metronom.c	Fri Aug 10 19:36:01 2007 -0500
@@ -199,6 +199,7 @@
 	g_free(name);
 	playback->data = pmetronom;
 	play_thread = g_thread_self();
+	playback->set_pb_ready(playback);
 	play_loop(playback);
 }
 
--- a/src/modplug/modplugbmp.cxx	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/modplug/modplugbmp.cxx	Fri Aug 10 19:36:01 2007 -0500
@@ -312,7 +312,7 @@
 	mStopped = true;
 }
 
-void ModplugXMMS::PlayFile(const string& aFilename)
+void ModplugXMMS::PlayFile(const string& aFilename, InputPlayback *ipb)
 {
 	mStopped = true;
 	mPaused = false;
@@ -446,6 +446,7 @@
 	);
 
 	mDecodeThread = g_thread_self();
+	ipb->set_pb_ready(ipb);
 	this->PlayLoop();
 }
 
--- a/src/modplug/modplugbmp.h	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/modplug/modplugbmp.h	Fri Aug 10 19:36:01 2007 -0500
@@ -88,7 +88,7 @@
 
 	void CloseConfigureBox();
 
-	void PlayFile(const string& aFilename);// Play the file.
+	void PlayFile(const string& aFilename, InputPlayback *data);// Play the file.
 	void Stop();                       // Stop playing.
 	void Pause(bool aPaused);              // Pause or unpause.
 
--- a/src/modplug/plugin.cxx	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/modplug/plugin.cxx	Fri Aug 10 19:36:01 2007 -0500
@@ -27,7 +27,7 @@
 {
         char* aFilename = data->filename;
 	gModplugXMMS.SetOutputPlugin(*data->output);
-	gModplugXMMS.PlayFile(aFilename);
+	gModplugXMMS.PlayFile(aFilename, data);
 }
 
 static void Stop(InputPlayback *data)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mtp_up/Makefile	Fri Aug 10 19:36:01 2007 -0500
@@ -0,0 +1,19 @@
+include ../../mk/rules.mk
+include ../../mk/init.mk
+
+SUBDIRS = 
+
+OBJECTIVE_LIBS = libmtp_up$(SHARED_SUFFIX)
+
+LIBDIR = $(plugindir)/$(GENERAL_PLUGIN_DIR)
+
+LIBADD += $(MTP_LIBS) $(GTK_LIBS) $(GLIB_LIBS) $(PANGO_LIBS) 
+SOURCES = mtp.c
+
+CFLAGS += $(PICFLAGS) $(GTK_CFLAGS) $(GLIB_CFLAGS) $(PANGO_CFLAGS) $(BEEP_DEFINES) -I../../intl -I../..
+
+CFLAGS += -Wall  -pedantic -std=c99 $(GCC42_CFLAGS) -D_BSD_SOURCE
+
+OBJECTS = ${SOURCES:.c=.o}
+
+include ../../mk/objective.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mtp_up/mtp.c	Fri Aug 10 19:36:01 2007 -0500
@@ -0,0 +1,170 @@
+/*
+ * Audacious MTP upload plugin
+ *
+ * Copyright (c) 2007 Cristian Magherusan <majeru@atheme.org>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; under version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses>.
+ */
+
+#include <glib.h>
+#include <libmtp.h>
+#include <audacious/plugin.h>
+#include <audacious/playlist.h>
+#include <audacious/ui_plugin_menu.h>
+#define DEBUG 1
+
+GMutex * mutex = NULL; 
+gboolean mtp_initialised = FALSE;
+LIBMTP_mtpdevice_t *mtp_device = NULL;
+LIBMTP_progressfunc_t *callback;
+LIBMTP_file_t *filelist;
+Playlist *active_playlist;
+
+void mtp_init ( void );
+void mtp_cleanup ( void );
+void mtp_prefs ( void );
+void mtp_about ( void );
+
+GeneralPlugin mtp_gp =
+{
+    NULL,					/* handle */
+    NULL,					/* filename */
+    "MTP Upload " ,			/* description */
+    mtp_init,				/* init */
+    mtp_about,				/* about */
+    mtp_prefs,				/* configure */
+    mtp_cleanup				/* cleanup */
+};
+GtkWidget *menuitem;
+
+GeneralPlugin *mtp_gplist[] = { &mtp_gp, NULL };
+DECLARE_PLUGIN(mtp_gp, NULL, NULL, NULL, NULL, NULL, mtp_gplist, NULL, NULL)
+
+
+gpointer upload(gpointer arg)
+{
+    Playlist *current_play;
+    Tuple *tuple;
+    gchar *from_path;
+    gchar *comp;
+    char *filename;
+    uint64_t filesize;
+    struct stat sb;
+    LIBMTP_file_t *genfile;
+    int ret;
+    uint32_t parent_id = 0;
+    GList *node;
+    PlaylistEntry *entry;
+    current_play = g_new0(Playlist,1);
+    current_play = playlist_get_active();
+    node = current_play->entries;
+    PLAYLIST_LOCK(current_play->mutex); /*needed so that the user doesn't modify the selection*/
+    while (node) {
+        entry = PLAYLIST_ENTRY(node->data);
+        if (entry->selected)  
+        {
+            tuple = entry->tuple;
+            from_path = g_strdup_printf("%s/%s", tuple_get_string(tuple, "file-path"), tuple_get_string(tuple, "file-name"));
+            comp = g_strescape(from_path,NULL);
+            if ( stat(from_path, &sb) == -1 )
+            {
+#if DEBUG
+                g_print("ERROR!");
+#endif
+                return NULL;
+            }
+            filesize = (uint64_t) sb.st_size;
+            filename = basename(from_path);
+            parent_id = 0;
+            genfile = LIBMTP_new_file_t();
+            genfile->filesize = filesize;
+            genfile->filename = strdup(filename);
+#if DEBUG
+            g_print("Uploading track '%s'\n",comp);
+#endif
+            ret = LIBMTP_Send_File_From_File(mtp_device,comp , genfile, NULL , NULL, parent_id);
+#if DEBUG
+            if (ret == 0) 
+                g_print("Upload finished!\n");
+            else
+                g_print("An error has occured while uploading '%s'...\nUpload failed!!!",comp);
+#endif
+            LIBMTP_destroy_file_t(genfile);
+            g_free(from_path);
+            g_free(comp);
+            entry->selected = FALSE;
+        }
+        node = g_list_next(node);
+    }
+    PLAYLIST_UNLOCK(current_play->mutex);
+    return NULL;
+}
+
+    void
+mtp_prefs ( void )
+{
+    /*pref stub*/
+}
+
+
+    void
+mtp_about ( void )
+{
+    /*about stub*/
+}
+
+void mtp_press()
+{
+    if(!mutex) 
+        return;
+    g_mutex_lock(mutex);
+    if(!mtp_initialised)
+    {
+#if DEBUG
+        g_print("Initializing the MTP device...\n");
+#endif
+        mtp_device = LIBMTP_Get_First_Device();
+        mtp_initialised = TRUE;
+    }
+    g_mutex_unlock(mutex);
+    if(mtp_device == NULL) 
+    {
+#if DEBUG
+        g_print("No MTP devices have been found !!!");
+#endif
+        return;
+
+    }
+    g_thread_create(upload,NULL,FALSE,NULL);	
+}
+
+void mtp_init(void)
+{
+    menuitem=gtk_menu_item_new_with_label("Upload to MTP");
+    gtk_widget_show (menuitem);
+    audacious_menu_plugin_item_add(AUDACIOUS_MENU_PLAYLIST_RCLICK, menuitem);
+    g_signal_connect (G_OBJECT (menuitem), "button_press_event",G_CALLBACK (mtp_press), NULL);  
+    LIBMTP_Init();
+    mutex = g_mutex_new();
+}
+
+void mtp_cleanup(void)
+{
+#if DEBUG
+    g_print("Cleaning up MTP_upload\n");
+#endif
+    audacious_menu_plugin_item_remove(AUDACIOUS_MENU_PLAYLIST, menuitem );
+    g_mutex_free (mutex);
+    mutex = NULL;
+}
+
--- a/src/musepack/libmpc.cxx	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/musepack/libmpc.cxx	Fri Aug 10 19:36:01 2007 -0500
@@ -305,6 +305,7 @@
     mpcDecoder.isOutput = false;
     mpcDecoder.isPause  = false;
     threadHandle = g_thread_self();
+    data->set_pb_ready(data);
     decodeStream((void *) g_strdup(data->filename));
 }
 
--- a/src/sexypsf/plugin.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/sexypsf/plugin.c	Fri Aug 10 19:36:01 2007 -0500
@@ -159,6 +159,7 @@
 
         playing = 1;
         dethread = g_thread_self();
+        data->set_pb_ready(data);
         sexypsf_playloop(NULL);
     }
 }
--- a/src/sid/xmms-sid.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/sid/xmms-sid.c	Fri Aug 10 19:36:01 2007 -0500
@@ -572,6 +572,7 @@
 
 	/* Start the playing thread! */
 	xs_decode_thread = g_thread_self();
+	pb->set_pb_ready(pb);
 	xs_playthread(pb);
 
 	XSDEBUG("playback is done\n");
--- a/src/timidity/src/xmms-timidity.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/timidity/src/xmms-timidity.c	Fri Aug 10 19:36:01 2007 -0500
@@ -375,6 +375,7 @@
 	xmmstimid_seek_to = -1;
 
 	xmmstimid_decode_thread = g_thread_self();
+	playback->set_pb_ready(playback);
 	xmmstimid_play_loop(playback);
 }
 
--- a/src/tonegen/tonegen.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/tonegen/tonegen.c	Fri Aug 10 19:36:01 2007 -0500
@@ -202,6 +202,7 @@
 	g_free(name);
 	playback->data = frequencies;
 	play_thread = g_thread_self();
+	playback->set_pb_ready(playback);
 	play_loop(playback);
 }
 
--- a/src/tta/libtta.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/tta/libtta.c	Fri Aug 10 19:36:01 2007 -0500
@@ -521,6 +521,7 @@
 	read_samples = -1;
 
 	decode_thread = g_thread_self();
+	playback->set_pb_ready(playback);
 	play_loop(playback);
 }
 
--- a/src/vorbis/vorbis.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/vorbis/vorbis.c	Fri Aug 10 19:36:01 2007 -0500
@@ -571,6 +571,7 @@
     playback->error = FALSE;
 
     thread = g_thread_self();
+    playback->set_pb_ready(playback);
     vorbis_play_loop(playback);
 }
 
--- a/src/vtx/vtx.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/vtx/vtx.c	Fri Aug 10 19:36:01 2007 -0500
@@ -245,6 +245,7 @@
 
       playback->playing = TRUE;
       play_thread = g_thread_self();
+      playback->set_pb_ready(playback);
       play_loop(playback);
     }
 }
--- a/src/wav/wav.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/wav/wav.c	Fri Aug 10 19:36:01 2007 -0500
@@ -424,6 +424,7 @@
         g_free(name);
         wav_file->seek_to = -1;
         decode_thread = g_thread_self();
+        playback->set_pb_ready(playback);
         play_loop(playback);
     }
 }
--- a/src/wavpack/libwavpack.cxx	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/wavpack/libwavpack.cxx	Fri Aug 10 19:36:01 2007 -0500
@@ -352,6 +352,7 @@
     killDecodeThread = false;
     AudioError = false;
     thread_handle = g_thread_self();
+    data->set_pb_ready(data);
     DecodeThread((void *) data->filename);
     return;
 }
--- a/src/wma/wma.c	Fri Aug 10 19:35:53 2007 -0500
+++ b/src/wma/wma.c	Fri Aug 10 19:36:01 2007 -0500
@@ -433,6 +433,7 @@
     wma_decode = 1;
     playback->playing = 1;
     wma_decode_thread = g_thread_self();
+    playback->set_pb_ready(playback);
     wma_play_loop(playback);
 }