--- kdebluetooth/bemused/kbemusedsrv.cpp.old	2006-10-16 11:23:57.000000000 +0100
+++ kdebluetooth/bemused/kbemusedsrv.cpp	2007-02-08 19:53:52.000000000 +0100
@@ -219,7 +219,7 @@
         
     if (cmd == "CHCK") {
         // Checks that the server is running OK
-        stream.writeBytes("Y", 1);
+        socket->writeBlock("Y", 1);
         addSendLogTxt("Y");
     }
     else if (cmd == "DINF") {
@@ -228,7 +228,7 @@
         unsigned int sampleRate;
         unsigned int channels;
         curController->commandDINF(bitrate, sampleRate, channels);
-        stream.writeBytes("DINFACK", 7);
+        socket->writeBlock("DINFACK", 7);
         stream << Q_UINT32(bitrate) << Q_UINT32(sampleRate) << Q_UINT32(channels);
 
         addSendLogTxt(QString("DINFACK: br=%1 sr=%2 ch=%3...")
--- kdebluetooth/bemused/amarokcontroller.cpp.old	2007-02-10 20:04:14.000000000 +0100
+++ kdebluetooth/bemused/amarokcontroller.cpp	2007-02-11 17:35:10.000000000 +0100
@@ -82,10 +82,13 @@
     commandSTOP();
 }
 
-// TODO: function not working
 void AmarokController::commandFFWD() {
     // Fast-forwards by five seconds
-    setPosition(getPosition()+5);
+    DCOPCall caller = createDCOPCaller();
+    caller.args() << 5;
+    if (caller.call("seekRelative(int)") != "void") {
+        kdWarning() << "Error calling amarok::amarok::seekRelative(int)" << endl;
+    }
 }
 
 Controller::SongInfo AmarokController::commandINFO() {
@@ -96,7 +99,7 @@
     info.playState = 0;
     info.repeat = false;
     info.shuffle = false;
-    info.trackName = "Pure morning";
+    info.trackName = "<unknown>";
 
     DCOPCall caller = createDCOPCaller();
     if (caller.call("trackTotalTime()") != "int") {
@@ -130,6 +133,24 @@
         info.trackName = t;
     }
 
+    if (caller.call("randomModeStatus()") != "bool") {
+        kdWarning() << "Error calling amarok::amarok::randomModesStatus()" << endl;
+    }
+    else {
+        bool u;
+        caller.ret() >> u;
+        info.shuffle = u;
+    }
+
+    if (caller.call("repeatTrackStatus()") != "bool") {
+        kdWarning() << "Error calling amarok::amarok::repeatTrackStatus()" << endl;
+    }
+    else {
+        bool v;
+        caller.ret() >> v;
+        info.repeat = v;
+    }
+
     return info;
 }
 
@@ -217,16 +238,17 @@
 
 QStringList AmarokController::commandPLST(int &curPos, bool useFilenames) {
     // Writes the current playlist to the phone
-    curPos = 0;
+    curPos = currentIndex();
     QStringList playlist;
 
     DCOPCall caller = createDCOPCaller("playlist");
     // Save Playlist
-    if (caller.call("saveCurrentPlaylist()") != "void") {
+    if (caller.call("saveCurrentPlaylist()") != "QString") {
         kdWarning() << "Error calling amarok::playlist::saveCurrentPlaylist()" << endl;
     }
     // parse Playlist
-    QString playlistFile =  locate("data", "amarok/current.xml");
+    QString playlistFile;
+    caller.ret() >> playlistFile;
     QFile f(playlistFile);
     if(f.open( IO_ReadOnly )) {
         QXmlInputSource source(&f);
@@ -259,13 +281,13 @@
     }
 }
 
-// TODO: function not working
-void AmarokController::commandREPT(bool /*repeat*/) {
+void AmarokController::commandREPT(bool repeat) {
     // Enables or disables repeat mode
-    //DCOPCall caller = createDCOPCaller();
-    //if (caller.call("loop()") != "void") {
-    //   kdWarning() << "Error calling amarok::Amarok::repeat()" << endl;
-    //}
+    DCOPCall caller = createDCOPCaller();
+    caller.args() << repeat;
+    if (caller.call("enableRepeatTrack(bool)") != "void") {
+       kdWarning() << "Error calling amarok::Amarok::enableRepeatTrack(bool)" << endl;
+    }
 }
 
 void AmarokController::commandRMAL() {
@@ -278,7 +300,11 @@
 
 void AmarokController::commandRWND() {
     // Rewinds by five seconds
-    setPosition(getPosition()-5);
+    DCOPCall caller = createDCOPCaller();
+    caller.args() << -5;
+    if (caller.call("seekRelative(int)") != "void") {
+        kdWarning() << "Error calling amarok::amarok::seekRelative(int)" << endl;
+    }
 }
 
 void AmarokController::commandSHFL(bool shuffle) {
@@ -325,7 +351,7 @@
 void AmarokController::commandVOLM(Q_UINT8 volume) {
     // Sets the volume to the value specified
     DCOPCall caller = createDCOPCaller();
-    caller.args() << volume*100/255;
+    caller.args() << int(volume/2.55 + 0.5); // 0.5: round correctly
     if (caller.call("setVolume(int)") != "void") {
         kdWarning() << "Error calling amarok::Amarok::setVolume(int)" << endl;
     }
@@ -353,7 +379,7 @@
 void AmarokController::setPosition(int pos)
 {
     DCOPCall caller = createDCOPCaller();
-    caller.args() << int(pos*1000);
+    caller.args() << pos;
     if (caller.call("seek(int)") != "void") {
         kdWarning() << "Error calling amarok::amarok::seek(int)" << endl;
     }
@@ -361,23 +387,29 @@
 
 void AmarokController::commandSEEK(Q_UINT32 seconds) {
     // Jump to specified position
-    setPosition(seconds*1000); // milliseconds
+    setPosition(seconds);
 }
 
 Q_UINT32 AmarokController::commandPLEN() {
-    return numTracks;
+    DCOPCall caller = createDCOPCaller("playlist");
+    if (caller.call("getTotalTrackCount()") != "int") {
+        kdWarning() << "Error calling amarok::playlist::getTotalTrackCount()" << endl;
+    }
+    int ret;
+    caller.ret() >> ret;
+    return Q_UINT32(ret);
 }
 
 bool AmarokController::commandGVOL(Q_UINT8 &volume) {
     // Get current volume
     DCOPCall caller = createDCOPCaller();
     if (caller.call("getVolume()") != "int") {
-        kdWarning() << "Error calling amarok::Amarok::setVolume(int)" << endl;
+        kdWarning() << "Error calling amarok::Amarok::getVolume()" << endl;
         return false;
     }
-    Q_UINT8 ret = 0;
+    int ret;
     caller.ret() >> ret;
-    volume=Q_UINT8(2.55*ret);
+    volume=Q_UINT8(int(ret*2.55 + 0.5)); //+0.5: round correctly
     return true;
 }
 
@@ -388,7 +420,7 @@
 		caller.ret() >> ret;
   		return ret;
     }
-	return 0;
+    return 0;
 }
 
 AmarokController::~AmarokController()

