Exemplo n.º 1
0
void diskDisappearedCallback(DADiskRef disk, void *context)
{
    const char  *BSDname = DADiskGetBSDName(disk);

    if (context)
        reinterpret_cast<MonitorThreadDarwin *>(context)->diskRemove(BSDname);
}
static void onDiskDisappear(DADiskRef disk, void *context)
{
    QString disk_name = DADiskGetBSDName(disk);
    sDevices.removeAll(disk_name); //erase?
    QDeviceWatcherPrivate *p = static_cast<QDeviceWatcherPrivate*>(context);
    p->emitDeviceRemoved(disk_name);
}
static void onDiskAppear(DADiskRef disk, void *context)
{
    QString disk_name = DADiskGetBSDName(disk);
    if (sDevices.contains(disk_name))
        return;
    sDevices.append(disk_name);
    QDeviceWatcherPrivate *p = static_cast<QDeviceWatcherPrivate*>(context);
    p->emitDeviceAdded(disk_name);
}
Exemplo n.º 4
0
static void scan_disk_appeared_cb(DADiskRef disk, void *c)
{
    struct scan_context *context = (struct scan_context *) c;
    int ix = context->count;
    if (ix < context->max_devices) {
        sprintf(context->devices[ix].path, "/dev/r%s", DADiskGetBSDName(disk));

        CFDictionaryRef info = DADiskCopyDescription(disk);
        CFNumberRef cfsize = CFDictionaryGetValue(info, kDADiskDescriptionMediaSizeKey);
        int64_t size;
        CFNumberGetValue(cfsize, kCFNumberSInt64Type, &size);
        context->devices[ix].size = size;
        CFRelease(info);

        context->count++;
    }
}
Exemplo n.º 5
0
void diskChangedCallback(DADiskRef disk, CFArrayRef keys, void *context)
{
    if (CFArrayContainsValue(keys, CFRangeMake(0, CFArrayGetCount(keys)),
                             kDADiskDescriptionVolumeNameKey))
    {
        const char     *BSDname = DADiskGetBSDName(disk);
        CFDictionaryRef details = DADiskCopyDescription(disk);
        char           *volName = getVolName(details);

        LOG(VB_MEDIA, LOG_INFO, QString("Disk %1 - changed name to '%2'.")
                          .arg(BSDname).arg(volName));

        reinterpret_cast<MonitorThreadDarwin *>(context)
            ->diskRename(BSDname, volName);
        CFRelease(details);
        free(volName);
    }
}
Exemplo n.º 6
0
void diskAppearedCallback(DADiskRef disk, void *context)
{
    const char          *BSDname = DADiskGetBSDName(disk);
    CFDictionaryRef      details;
    bool                 isCDorDVD;
    MythMediaType        mediaType;
    QString              model;
    MonitorThreadDarwin *mtd;
    QString              msg = "diskAppearedCallback() - ";
    char                *volName;


    if (!BSDname)
    {
        LOG(VB_MEDIA, LOG_INFO, msg + "Skipping non-local device");
        return;
    }

    if (!context)
    {
        LOG(VB_GENERAL, LOG_ALERT, msg + "Error. Invoked with a NULL context.");
        return;
    }

    mtd = reinterpret_cast<MonitorThreadDarwin*>(context);


    // We want to monitor CDs/DVDs and USB cameras or flash drives,
    // but probably not hard disk or network drives. For now, ignore
    // any disk or partitions that are not on removable media.
    // Seems OK for hot-plug USB/FireWire disks (i.e. they are removable)

    details = DADiskCopyDescription(disk);

    if (kCFBooleanFalse ==
        CFDictionaryGetValue(details, kDADiskDescriptionMediaRemovableKey))
    {
        LOG(VB_MEDIA, LOG_INFO, msg + QString("Skipping non-removable %1")
            .arg(BSDname));
        CFRelease(details);
        return;
    }

    // Get the volume and model name for more user-friendly interaction
    volName = getVolName(details);
    if (!volName)
    {
        LOG(VB_MEDIA, LOG_INFO, msg + QString("No volume name for dev %1")
            .arg(BSDname));
        CFRelease(details);
        return;
    }

    model     = getModel(details);
    mediaType = MediaTypeForBSDName(BSDname);
    isCDorDVD = (mediaType == MEDIATYPE_DVD) || (mediaType == MEDIATYPE_AUDIO);


    // We know it is removable, and have guessed the type.
    // Call a helper function to create appropriate objects and insert 

    LOG(VB_MEDIA, LOG_INFO, QString("Found disk %1 - volume name '%2'.")
                      .arg(BSDname).arg(volName));

    mtd->diskInsert(BSDname, volName, model, isCDorDVD);

    CFRelease(details);
    free(volName);
}