[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/3.5/kdemultimedia
From:       Richard Lärkäng <richard () goteborg ! utfors ! se>
Date:       2005-09-27 16:16:45
Message-ID: 1127837805.857259.2052.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 464503 by larkang:

Fix system:/ urls


 M  +1 -21     kaudiocreator/tracksimp.cpp  
 M  +23 -16    kscd/kcompactdisc.cpp  
 M  +6 -0      kscd/kcompactdisc.h  
 M  +2 -1      kscd/kscd.cpp  


--- branches/KDE/3.5/kdemultimedia/kaudiocreator/tracksimp.cpp #464502:464503
@@ -177,28 +177,8 @@
  * @param file - the new text to check.
  */
 void TracksImp::changeDevice(const QString &file ) {
-	QString newDevice = file;
+	QString newDevice = KCompactDisc::urlToDevice(file);
 
-	KURL url( newDevice );
-	if( url.isValid() && url.protocol() == "media" ) {
-		QString name = url.fileName();
-		
-		// FIXME Does the media lookup here instead of in KCompactDisc::setDevice,
-		//       so we can check if the device exist before we open it
-		DCOPRef mediamanager( "kded", "mediamanager" );
-		DCOPReply reply = mediamanager.call("properties(QString)", name);
-
-		if (!reply.isValid()) {
-			kdError() << "Invalid reply from mediamanager" << endl;
-			return;
-		} else {
-			QStringList properties = reply;
-			if (properties.count() < 6)
-			    return;
-			newDevice = properties[5];
-		}
-	}
-	
 	if( newDevice == cd->device() ) {
 		//qDebug("Device names match, returning");
 		return;
--- branches/KDE/3.5/kdemultimedia/kscd/kcompactdisc.cpp #464502:464503
@@ -231,40 +231,47 @@
     wm_cd_play(TRACK_VALID(startTrack) ? startTrack : 1, startTrackPosition / 1000, \
TRACK_VALID(endTrack) ? endTrack : WM_ENDTRACK );  }
 
-bool KCompactDisc::setDevice(
-    const QString &device,
-    unsigned volume,
-    bool digitalPlayback,
-    const QString &audioSystem,
-    const QString &audioDevice)
+QString KCompactDisc::urlToDevice(const QString& device)
 {
-    timer.stop();
     KURL deviceUrl(device);
-    if (deviceUrl.protocol() == "media")
+    if (deviceUrl.protocol() == "media" || deviceUrl.protocol() == "system")
     {
-        kdDebug() << "Asking mediamanager for " << deviceUrl.path(-1).mid(1) << \
endl; +        kdDebug() << "Asking mediamanager for " << deviceUrl.fileName() << \
endl;  DCOPRef mediamanager("kded", "mediamanager");
-        // mediamanager does not like paths with leading /
-        DCOPReply reply = mediamanager.call("properties(QString)", \
                deviceUrl.path(-1).mid(1));
-        if (!reply.isValid())
+        DCOPReply reply = mediamanager.call("properties(QString)", \
deviceUrl.fileName()); +        QStringList properties = reply;
+        if (!reply.isValid() || properties.count() < 6)
         {
             kdError() << "Invalid reply from mediamanager" << endl;
-            deviceUrl.setPath(defaultDevice);
+	    return defaultDevice;
         }
         else
         {
-            QStringList properties = reply;
-            deviceUrl.setPath(properties[5]);
             kdDebug() << "Reply from mediamanager " << properties[5] << endl;
+	    return properties[5];
         }
     }
 
+    return device;
+}
+
+bool KCompactDisc::setDevice(
+    const QString &device_,
+    unsigned volume,
+    bool digitalPlayback,
+    const QString &audioSystem,
+    const QString &audioDevice)
+{
+    timer.stop();
+
+    QString device = urlToDevice(device_);
+
 #if !defined(BUILD_CDDA)
     digitalPlayback = false;
 #endif
     int status = wm_cd_init(
                     digitalPlayback ? WM_CDDA : WM_CDIN,
-                    QFile::encodeName(deviceUrl.path(-1)),
+                    QFile::encodeName(device),
                     digitalPlayback ? audioSystem.ascii() : 0,
                     digitalPlayback ? audioDevice.ascii() : 0,
                     0);
--- branches/KDE/3.5/kdemultimedia/kscd/kcompactdisc.h #464502:464503
@@ -73,6 +73,12 @@
     void pause();
 
     /**
+     * If the url is a media:/ or system:/ URL returns
+     * the device it represents, otherwise returns device
+     */
+    static QString urlToDevice(const QString& device);
+
+    /**
      * @param device Name of CD device, e.g. /dev/cdrom.
      * @param digitalPlayback Select digial or analogue playback.
      * @param audioSystem For analogue playback, system to use, e.g. "arts".
--- branches/KDE/3.5/kdemultimedia/kscd/kscd.cpp #464502:464503
@@ -781,7 +781,8 @@
     {
         // This device did not seem usable.
         QString str = i18n("CD-ROM read or access error (or no audio disc in \
                drive).\n"\
-                            "Please make sure you have access permissions \
to:\n%1").arg(Prefs::cdDevice()); +                            "Please make sure you \
have access permissions to:\n%1").arg( +			      \
KCompactDisc::urlToDevice(Prefs::cdDevice()));  KMessageBox::error(this, str, \
i18n("Error"));  }
     else


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic