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

List:       kde-commits
Subject:    kdemultimedia/kscd
From:       Shaheed Haque <srhaque () iee ! org>
Date:       2005-03-25 3:51:36
Message-ID: 20050325035136.A6C5148F () office ! kde ! org
[Download RAW message or body]

CVS commit by shaheed: 

1. Handle missing discs consistently, and re-enable CDDB lookups when we
   *do* have a disc.
2. Handle drive access permissions correctly.


  M +15 -10    kcompactdisc.cpp   1.4
  M +4 -1      kcompactdisc.h   1.3
  M +18 -10    kscd.cpp   1.304


--- kdemultimedia/kscd/kcompactdisc.cpp  #1.3:1.4
@@ -228,5 +228,5 @@ void KCompactDisc::play(unsigned startTr
 }
 
-void KCompactDisc::setDevice(
+bool KCompactDisc::setDevice(
     const QString &device,
     unsigned volume,
@@ -265,15 +265,24 @@ void KCompactDisc::setDevice(
                     digitalPlayback ? audioDevice.ascii() : 0,
                     0);
+    m_device = wm_drive_device();
     kdDebug() << "Device change: "
         << (digitalPlayback ? "WM_CDDA, " : "WM_CDIN, ")
-        << deviceUrl.path() << ", "
+        << m_device << ", "
         << (digitalPlayback ? audioSystem : "") << ", "
         << (digitalPlayback ? audioDevice : "") << ", status: "
         << discStatus(status) << endl;
-    m_device = wm_drive_device();
 
+    if (status < 0)
+    {
+        // Severe (OS-level) error.
+        m_device = "";
+    }
+    else
+    {
     // Init CD-ROM and display.
     setVolume(volume);
+    }
     timer.start(1000, true);
+    return !(m_device.length() == 0);
 }
 
@@ -319,10 +328,6 @@ unsigned KCompactDisc::tracks() const
 void KCompactDisc::timerExpired()
 {
-    // No device, no work to do!
-    if (m_device.length() == 0)
-        return;
-
     m_status = wm_cd_status();
-    if (WM_CDS_NO_DISC(m_status))
+    if (WM_CDS_NO_DISC(m_status) || (m_device.length() == 0))
     {
         if (m_previousStatus != m_status)

--- kdemultimedia/kscd/kcompactdisc.h  #1.2:1.3
@@ -71,6 +71,7 @@ public:
      * @param audioSystem For analogue playback, system to use, e.g. "arts".
      * @param audioDevice For analogue playback, device to use.
+     * @return true if the device seemed usable.
      */
-    void setDevice(
+    bool setDevice(
         const QString &device = defaultDevice,
         unsigned volume = 50,
@@ -93,4 +94,6 @@ public:
     /**
      * Current device.
+     *
+     * @return Empty string if no usable device set.
      */
     const QString &device() const;

--- kdemultimedia/kscd/kscd.cpp  #1.303:1.304
@@ -337,5 +337,5 @@ KSCD::setupPopups()
 void KSCD::playClicked()
 {
-    if (!m_cd->discId())
+    if (m_cd->discId() == KCompactDisc::missingDisc)
         return;
 
@@ -738,9 +738,18 @@ void KSCD::configureKeys()
 void KSCD::setDevicePaths()
 {
-    m_cd->setDevice(Prefs::cdDevice(), Prefs::volume(), Prefs::digitalPlayback());
+    if (!m_cd->setDevice(Prefs::cdDevice(), Prefs::volume(), \
Prefs::digitalPlayback())) +    {
+        // 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()); +        KMessageBox::error(this, str, \
i18n("Error")); +    }
+    else
+    {
     if (Prefs::autoplay() && !m_cd->isPlaying())
     {
         playClicked();
     }
+    }
 } // setDevicePath()
 
@@ -896,10 +905,7 @@ void KSCD::discChanged(unsigned discId)
 {
     cddbInfo.clear();
-    if (discId == 0)
+    if (discId == KCompactDisc::missingDisc)
     {
         statuslabel->setText(i18n("No disc"));
-        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(m_cd->device());
-        KMessageBox::error(this, str, i18n("Error"));
     }
     else
@@ -956,5 +962,5 @@ void KSCD::discStopped()
 {
     statuslabel->setText(i18n("Stopped"));
-    if (Prefs::ejectOnFinish() && !stoppedByUser && m_cd->discId())
+    if (Prefs::ejectOnFinish() && !stoppedByUser && (m_cd->discId() != \
KCompactDisc::missingDisc))  {
         ejectClicked();
@@ -1087,4 +1093,6 @@ void KSCD::CDDialogDone()
 void KSCD::lookupCDDB()
 {
+    if (m_cd->discId() == KCompactDisc::missingDisc)
+        return;
     kdDebug(67000) << "lookupCDDB() called" << endl;
 
@@ -1101,5 +1109,5 @@ void KSCD::lookupCDDB()
     // FIXME Should be enabled again when it doesn't go into an infinite loop
     // when no disc is found
-    //cddb->lookup(m_cd->cddbSignature());
+    cddb->lookup(m_cd->cddbSignature());
 } // lookupCDDB
 


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

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