File indexing completed on 2025-01-19 04:24:18

0001 /****************************************************************************************
0002  * Copyright (C) 2009 Alejandro Wainzinger <aikawarazuni@gmail.com>
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #include "AudioCdConnectionAssistant.h"
0018 #include "AudioCdDeviceInfo.h"
0019 
0020 #include "MediaDeviceCache.h" // for mountpoint
0021 
0022 #include "core/support/Debug.h"
0023 
0024 #include <QString>
0025 
0026 #include <solid/device.h>
0027 #include <solid/opticaldisc.h>
0028 
0029 AudioCdConnectionAssistant::~AudioCdConnectionAssistant()
0030 {
0031 }
0032 
0033 bool
0034 AudioCdConnectionAssistant::identify( const QString& udi )
0035 {
0036     const Solid::Device device = Solid::Device(udi);
0037     if( device.is<Solid::OpticalDisc>() )
0038     {
0039         debug() << "OpticalDisc";
0040         const Solid::OpticalDisc * opt = device.as<Solid::OpticalDisc>();
0041         if ( opt->availableContent() & Solid::OpticalDisc::Audio )
0042         {
0043             debug() << "AudioCd";
0044             return true;
0045         }
0046     }
0047     return false;
0048 }
0049 
0050 
0051 MediaDeviceInfo*
0052 AudioCdConnectionAssistant::deviceInfo( const QString& udi )
0053 {
0054     const QString device = MediaDeviceCache::instance()->device(udi);
0055     return new AudioCdDeviceInfo( device, udi );
0056 }
0057