2 * Copyright (c) 2007 Jeff Mitchell <kde-dev@emailgoeshere.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include "solid/device.h"
20 #include "solid/devicenotifier.h"
25 #include "SolidHandler.h"
28 using namespace PortableDevicesNS
;
30 SolidHandler
* SolidHandler::s_instance
= 0;
33 SolidHandler::instance()
35 static SolidHandler sh
;
39 SolidHandler::SolidHandler() : QObject()
46 SolidHandler::~SolidHandler()
51 SolidHandler::Initialize()
54 connect( Solid::DeviceNotifier::instance(), SIGNAL( deviceAdded( const QString
& ) ),
55 this, SLOT( deviceAdded( const QString
& ) ) );
56 connect( Solid::DeviceNotifier::instance(), SIGNAL( deviceRemoved( const QString
& ) ),
57 this, SLOT( deviceRemoved( const QString
& ) ) );
58 QList
<Solid::Device
> deviceList
= Solid::Device::listFromQuery( "is PortableMediaPlayer" );
60 foreach( const Solid::Device
&device
, deviceList
)
62 debug() << "Found Solid::DeviceInterface::PortableMediaPlayer with udi = " << device
.udi();
63 debug() << "Device name is = " << device
.product() << " and was made by " << device
.vendor();
64 m_portableList
<< device
.udi();
69 SolidHandler::deviceAdded( const QString
&udi
)
71 if( m_portableList
.contains( udi
) )
73 debug() << "Error: duplicate UDI trying to be added from Solid.";
76 m_portableList
<< udi
;
77 emit
addDevice( udi
);
81 SolidHandler::deviceRemoved( const QString
&udi
)
83 if( m_portableList
.contains( udi
) )
85 m_portableList
.removeAll( udi
);
86 emit
removeDevice( udi
);
92 PortableDevicesNS::SolidHandler
* SolidHandler() { return PortableDevicesNS::SolidHandler::instance(); }
95 #include "SolidHandler.moc"