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

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 #ifndef MEDIADEVICEHANDLER_CAPABILITY_H
0018 #define MEDIADEVICEHANDLER_CAPABILITY_H
0019 
0020 #include "core-impl/collections/mediadevicecollection/support/mediadevicecollection_export.h"
0021 
0022 #include <QObject>
0023 
0024 /**
0025  * Base class for all media device Capabilities
0026  *
0027  * Following rules apply when working with capabilities:
0028  *  * Capabilities get deleted along their media device handler. Therefore use
0029  *    QPointer everywhere to detect that.
0030  *  * the one who creates capability using create<Type>() must deleteLater() it when no
0031  *    longer used.
0032  */
0033 namespace Handler
0034 {
0035     class MEDIADEVICECOLLECTION_EXPORT Capability : public QObject
0036     {
0037         Q_OBJECT
0038 
0039         public:
0040             //add additional capabilities here
0041             enum Type { Unknown = 0
0042                         , Readable = 1 // can read from device
0043                         , Writable = 2 // can write to device
0044                         , Playlist = 3 // can read/write playlists
0045                         , Artwork = 4 // can read/write artwork
0046                         , Podcast = 5 // can read/write podcasts
0047                       };
0048             Q_ENUM( Type )
0049 
0050             /**
0051              * @param handler should be set to associated MediaDeviceHandler or Collection.
0052              *
0053              * The capability sets its parent to handler, so that it can be guaranteed that
0054              * the handler is valid for Capability's lifetime.
0055              */
0056             explicit Capability( QObject *handler );
0057             ~Capability() override;
0058 
0059         Q_SIGNALS:
0060             /**
0061              * Signals that parent of this object should be set to @param parent
0062              */
0063             void signalSetParent( QObject *parent );
0064 
0065         private Q_SLOTS:
0066             /**
0067              * Simply calls setParent( parent ); needed for cases where moveToThread() is
0068              * called in constructor - setting parent needs to be done in the new thread.
0069              */
0070             void slotSetParent( QObject *parent );
0071     };
0072 }
0073 
0074 #endif