File indexing completed on 2025-01-05 04:26:00
0001 /**************************************************************************************** 0002 * Copyright (c) 2012 Matěj Laitl <matej@laitl.cz * 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 #ifndef IPODCOLLECTIONFACTORY_H 0018 #define IPODCOLLECTIONFACTORY_H 0019 0020 #include "core/collections/Collection.h" 0021 0022 #include <QMap> 0023 0024 0025 namespace Solid { 0026 class Device; 0027 } 0028 0029 class IpodCollection; 0030 0031 class IpodCollectionFactory : public Collections::CollectionFactory 0032 { 0033 Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_collection-ipodcollection.json") 0034 Q_INTERFACES(Plugins::PluginFactory) 0035 Q_OBJECT 0036 0037 public: 0038 IpodCollectionFactory(); 0039 virtual ~IpodCollectionFactory(); 0040 0041 void init() override; 0042 0043 private Q_SLOTS: 0044 /** 0045 * Called when solid notifier detects a new device has been added 0046 */ 0047 void slotAddSolidDevice( const QString &udi ); 0048 0049 /** 0050 * Called when solid StorageAccess device we are interested in is mounted or 0051 * unmounted 0052 */ 0053 void slotAccessibilityChanged( bool accessible, const QString &udi ); 0054 0055 /** 0056 * Called when solid notifier detects a device has been removed 0057 */ 0058 void slotRemoveSolidDevice( const QString &udi ); 0059 0060 /** 0061 * Called when "tracked" collection is destroyed 0062 */ 0063 void slotCollectionDestroyed( QObject *collection ); 0064 0065 private: 0066 enum DeviceType { 0067 iPod, // classic wasy of accessing 0068 iOS // access using libimobiledevice 0069 }; 0070 0071 /** 0072 * Checks whether a solid device is an iPod. 0073 */ 0074 bool identifySolidDevice( const QString &udi ) const; 0075 0076 /** 0077 * Attempts to create appropriate collection for already identified solid device 0078 * @param udi. Should Q_EMIT newCollection() if the collection was successfully 0079 * created and should become visible to the user. 0080 */ 0081 void createCollectionForSolidDevice( const QString &udi ); 0082 0083 /// udi to iPod collection map 0084 QMap<QString, IpodCollection *> m_collectionMap; 0085 }; 0086 0087 #endif // IPODCOLLECTIONFACTORY_H