Пример #1
0
bool SmbDeviceHandlerFactory::canHandle( const Solid::Device &device ) const
{
    const Solid::NetworkShare *share = device.as<Solid::NetworkShare>();
    if( !share )
    {
        debug() << __PRETTY_FUNCTION__ << device.udi() << "has no NetworkShare interface";
        return false;
    }
    if( share->type() != Solid::NetworkShare::Cifs )
    {
        debug() << __PRETTY_FUNCTION__ << device.udi() << "has type" << share->type()
                << "but smbfs/cifs type is" << Solid::NetworkShare::Cifs;
        return false;
    }
    const Solid::StorageAccess *access = device.as<Solid::StorageAccess>();
    if( !access )
    {
        debug() << __PRETTY_FUNCTION__ << device.udi() << "has no StorageAccess interface";
        return false;
    }
    if( !access->isAccessible() || access->filePath().isEmpty() )
    {
        debug() << __PRETTY_FUNCTION__ << device.udi() << "is not accessible"
                << "or has empty mount-point";
        return false;
    }
    return true;
}
Пример #2
0
int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);
    KComponentData data("tutorial5");

    //get a Network Device
    QList<Solid::Device> netlist = Solid::Device::listFromType(Solid::DeviceInterface::NetworkInterface, QString());

    //check to see if no network devices were found
    if(netlist.empty())
    {
        kDebug() << "No network devices found!";
        return 0;
    }

    Solid::Device device = netlist[0];
    Solid::NetworkInterface *netdev = device.as<Solid::NetworkInterface>();
    //keep the program from crashing in the event that there's a bug in solid
    if(!netdev)
    {
        kDebug() << "Device could not be converted.  There is a bug.";
        return 0;
    }

    kDebug() << "The iface of " << device.udi() << " is " << netdev->ifaceName();

    return 0;
}
QVariant SoundCardModel::data(const QModelIndex &index, int role) const
{
    // Sanity check
    if (!index.isValid())
        return QVariant();

    // Check if role is supported
    if (role != Qt::DisplayRole && role != Qt::DecorationRole)
        return QVariant();

    Solid::Device device = m_list.at(index.row());
    Solid::AudioInterface *audio = device.as<Solid::AudioInterface>();

    if (audio->deviceType() == Solid::AudioInterface::AudioOutput) {
        qDebug() << device.udi() << device.product() << device.parentUdi();
        switch (role) {
            case Qt::DisplayRole:
                return audio->name();
            case Qt::DecorationRole:
                switch (audio->soundcardType()) {
                    case Solid::AudioInterface::Headset:
                        return QIcon::fromTheme("audio-headset");
                    default:
                        return QIcon::fromTheme("audio-card");
                }
        }
    }

    return QVariant();
}
Пример #4
0
SolStorageDevice::SolStorageDevice(QTreeWidgetItem *parent, const Solid::Device &device, const storageChildren &c) :
  SolDevice(parent, device)
{
  deviceTypeHolder = Solid::DeviceInterface::StorageDrive;
  setDefaultDeviceText();
   
  if(c == CREATECHILDREN) 
  {
    createDeviceChildren<SolVolumeDevice>(this,device.udi(),Solid::DeviceInterface::StorageVolume);
  }
}
Пример #5
0
Solid::Device MenuDiskItem::opticalParent() const
{
    Solid::Device it = mDevice;
    //search for parent drive
    for ( ; !it.udi().isEmpty(); it = it.parent())
    {
        if (it.is<Solid::OpticalDrive>())
            break;
    }
    return it;
}
Пример #6
0
// Paulo: I'm not sure what this is for
static bool hasRemovableParent(Solid::Device device)
{
    // qDebug() << "acess:" << device.udi();
    for ( ; !device.udi().isEmpty(); device = device.parent())
    {
        Solid::StorageDrive* drive = device.as<Solid::StorageDrive>();
        if (drive && drive->isRemovable())
        {
            // qDebug() << "removable parent drive:" << device.udi();
            return true;
        }
    }
    return false;
}
Пример #7
0
AudioCdDevice::AudioCdDevice(MusicModel *m, Solid::Device &dev)
    : Device(m, dev, false, true)
    #ifdef CDDB_FOUND
    , cddb(0)
    #endif
    #ifdef MUSICBRAINZ5_FOUND
    , mb(0)
    #endif
    , year(0)
    , disc(0)
    , time(0xFFFFFFFF)
    , lookupInProcess(false)
    , autoPlay(false)
{
    icn=Icon("media-optical");
    drive=dev.parent().as<Solid::OpticalDrive>();
    Solid::Block *block=dev.as<Solid::Block>();
    if (block) {
        device=block->device();
    } else { // With UDisks2 we cannot get block from device :-(
        QStringList parts=dev.udi().split("/", QString::SkipEmptyParts);
        if (!parts.isEmpty()) {
            parts=parts.last().split(":");
            if (!parts.isEmpty()) {
                device="/dev/"+parts.first();
            }
        }
    }
    if (!device.isEmpty()) {
        static bool registeredTypes=false;
        if (!registeredTypes) {
            qRegisterMetaType<CdAlbum >("CdAlbum");
            qRegisterMetaType<QList<CdAlbum> >("QList<CdAlbum>");
            registeredTypes=true;
        }
        devPath=Song::constCddaProtocol+device+QChar('/');
        #if defined CDDB_FOUND && defined MUSICBRAINZ5_FOUND
        connectService(Settings::self()->useCddb());
        #else
        connectService(true);
        #endif
        detailsString=i18n("Reading disc");
        setStatusMessage(detailsString);
        lookupInProcess=true;
        connect(Covers::self(), SIGNAL(cover(const Song &, const QImage &, const QString &)),
                this, SLOT(setCover(const Song &, const QImage &, const QString &)));
        emit lookup(Settings::self()->cdAuto());
    }
}
Пример #8
0
bool deviceLessThan(const Solid::Device &a, const Solid::Device &b) {
	return a.udi() < b.udi();
}