File indexing completed on 2024-05-05 04:47:58
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 CONNECTIONASSISTANT_H 0018 #define CONNECTIONASSISTANT_H 0019 0020 #include "mediadevicecollection_export.h" 0021 0022 #include <QObject> 0023 0024 class MediaDeviceInfo; 0025 0026 class QString; 0027 0028 /** 0029 @class ConnectionAssistant 0030 0031 The ConnectionAssistant (CA) serves as a way for MediaDeviceCollectionFactory to register its 0032 device type with the MediaDeviceMonitor (MDM). Once registered, the MDM can use the CA to 0033 attempt to identify a newly plugged-in device, and retrieve the MediaDeviceInfo object necessary 0034 for the Factory to connect to it. 0035 0036 */ 0037 0038 class MEDIADEVICECOLLECTION_EXPORT ConnectionAssistant : public QObject 0039 { 0040 Q_OBJECT 0041 0042 public: 0043 0044 ~ConnectionAssistant() override; 0045 0046 /** 0047 0048 identify checks if a device identified by @param udi matches the type 0049 of device described by this ConnectionAssistant 0050 0051 */ 0052 virtual bool identify( const QString& udi ); 0053 0054 /** 0055 0056 deviceInfo returns a pointer to a new MediaDeviceInfo of the type of device 0057 described by this ConnectionAssistant 0058 0059 */ 0060 0061 virtual MediaDeviceInfo* deviceInfo( const QString& udi ); 0062 0063 bool wait(); 0064 0065 // Simply Q_EMIT identified( info ) 0066 virtual void tellIdentified( const QString &udi ); 0067 virtual void tellDisconnected( const QString &udi ); 0068 0069 protected: 0070 0071 /* 0072 * Constructor 0073 * @param wait whether or not to wait to identify this device, 0074 * to give other types of devices a chance to claim this device 0075 * type during autodetection 0076 */ 0077 ConnectionAssistant( bool wait = false ); 0078 0079 Q_SIGNALS: 0080 0081 /** 0082 0083 identified is emitted when identify returns true, and the device type's Factory 0084 has a slot that then attempts to connect to the device 0085 0086 */ 0087 void identified( MediaDeviceInfo* info ); 0088 0089 /** 0090 0091 disconnected is emitted when a device with a given @param udi 0092 has been disconnected. The device type's factory should then 0093 destroy the Collection appropriately 0094 0095 */ 0096 0097 void disconnected( const QString &udi ); 0098 0099 private: 0100 bool m_wait; 0101 0102 }; 0103 0104 #endif // CONNECTIONASSISTANT_H