1 /**************************************************************************************** 2 * Copyright (c) 2012 Matěj Laitl <matej@laitl.cz * 3 * * 4 * This program is free software; you can redistribute it and/or modify it under * 5 * the terms of the GNU General Public License as published by the Free Software * 6 * Foundation; either version 2 of the License, or (at your option) any later * 7 * version. * 8 * * 9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 * * 13 * You should have received a copy of the GNU General Public License along with * 14 * this program. If not, see <http://www.gnu.org/licenses/>. * 15 ****************************************************************************************/ 16 17 #ifndef IPODCOLLECTIONFACTORY_H 18 #define IPODCOLLECTIONFACTORY_H 19 20 #include "core/collections/Collection.h" 21 22 #include <QMap> 23 24 25 namespace Solid { 26 class Device; 27 } 28 29 class IpodCollection; 30 31 class IpodCollectionFactory : public Collections::CollectionFactory 32 { 33 Q_PLUGIN_METADATA(IID AmarokPluginFactory_iid FILE "amarok_collection-ipodcollection.json") 34 Q_INTERFACES(Plugins::PluginFactory) 35 Q_OBJECT 36 37 public: 38 IpodCollectionFactory(); 39 virtual ~IpodCollectionFactory(); 40 41 void init() override; 42 43 private Q_SLOTS: 44 /** 45 * Called when solid notifier detects a new device has been added 46 */ 47 void slotAddSolidDevice( const QString &udi ); 48 49 /** 50 * Called when solid StorageAccess device we are interested in is mounted or 51 * unmounted 52 */ 53 void slotAccessibilityChanged( bool accessible, const QString &udi ); 54 55 /** 56 * Called when solid notifier detects a device has been removed 57 */ 58 void slotRemoveSolidDevice( const QString &udi ); 59 60 /** 61 * Called when "tracked" collection is destroyed 62 */ 63 void slotCollectionDestroyed( QObject *collection ); 64 65 private: 66 enum DeviceType { 67 iPod, // classic wasy of accessing 68 iOS // access using libimobiledevice 69 }; 70 71 /** 72 * Checks whether a solid device is an iPod. 73 */ 74 bool identifySolidDevice( const QString &udi ) const; 75 76 /** 77 * Attempts to create appropriate collection for already identified solid device 78 * @param udi. Should Q_EMIT newCollection() if the collection was successfully 79 * created and should become visible to the user. 80 */ 81 void createCollectionForSolidDevice( const QString &udi ); 82 83 /// udi to iPod collection map 84 QMap<QString, IpodCollection *> m_collectionMap; 85 }; 86 87 #endif // IPODCOLLECTIONFACTORY_H 88