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

0001 /****************************************************************************************
0002  * Copyright (c) 2008 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 #define DEBUG_PREFIX "MtpCollection"
0018 
0019 #include "MtpCollection.h"
0020 #include "MtpConnectionAssistant.h"
0021 #include "MtpDeviceInfo.h"
0022 #include "MediaDeviceInfo.h"
0023 
0024 #include "amarokconfig.h"
0025 #include "core/support/Debug.h"
0026 
0027 #include <QUrl>
0028 
0029 using namespace Collections;
0030 
0031 MtpCollectionFactory::MtpCollectionFactory()
0032     : MediaDeviceCollectionFactory<MtpCollection>( new MtpConnectionAssistant() )
0033 {}
0034 
0035 MtpCollectionFactory::~MtpCollectionFactory()
0036 {
0037     DEBUG_BLOCK
0038     // nothing to do
0039 }
0040 
0041 //MtpCollection
0042 
0043 MtpCollection::MtpCollection( MediaDeviceInfo* info )
0044 : MediaDeviceCollection()
0045 {
0046     DEBUG_BLOCK
0047     /** Fetch Info needed to construct MtpCollection */
0048     debug() << "Getting mtp info";
0049     MtpDeviceInfo *mtpinfo = qobject_cast<MtpDeviceInfo *>( info );
0050 
0051     debug() << "Getting udi";
0052     m_udi = mtpinfo->udi();
0053 
0054     debug() << "constructing handler";
0055 
0056     m_handler = new Meta::MtpHandler( this );
0057 
0058     //startFullScan();// parse tracks
0059 }
0060 
0061 MtpCollection::~MtpCollection()
0062 {
0063     DEBUG_BLOCK
0064     //if( m_handler )
0065     //    qobject_cast<Meta::MtpHandler*> ( m_handler )->terminate();
0066 }
0067 
0068 QString
0069 MtpCollection::collectionId() const
0070 {
0071      return m_udi;
0072 }
0073 
0074 QString
0075 MtpCollection::prettyName() const
0076 {
0077     return m_handler->prettyName();
0078 }