static char * get_device_name(CdIo_t * cdio, cdio_drive_read_cap_t read_cap, cdio_drive_write_cap_t write_cap, const char * device) { cdio_hwinfo_t driveid; if(cdio_get_hwinfo(cdio, &driveid) && (driveid.psz_model[0] != '\0')) { return bgav_sprintf("%s %s", driveid.psz_vendor, driveid.psz_model); } if(write_cap & CDIO_DRIVE_CAP_WRITE_DVD_R) { return bgav_sprintf("DVD Writer (%s)", device); } else if(write_cap & CDIO_DRIVE_CAP_WRITE_CD_R) { return bgav_sprintf("CD Writer (%s)", device); } else if(read_cap & CDIO_DRIVE_CAP_READ_DVD_ROM) { return bgav_sprintf("DVD Drive (%s)", device); } return bgav_sprintf("CDrom Drive (%s)", device); }
QString CddaLister::DeviceModel(const QString& id) { CdIo_t *cdio = cdio_open (id.toLocal8Bit().constData(), DRIVER_DEVICE); cdio_hwinfo_t cd_info; if (cdio_get_hwinfo(cdio, &cd_info)) { cdio_destroy(cdio); return QString(cd_info.psz_model); } cdio_destroy(cdio); return QString(); }
QString CddaLister::MakeFriendlyName(const QString& id) { CdIo_t *cdio = cdio_open (id.toLocal8Bit().constData(), DRIVER_DEVICE); cdio_hwinfo_t cd_info; if (cdio_get_hwinfo(cdio, &cd_info)) { cdio_destroy(cdio); return QString(cd_info.psz_model); } cdio_destroy(cdio); return QString("CD (") + id + ")"; }
int main(int argc, const char *argv[]) { CdIo_t *p_cdio=NULL; init(); /* Parse our arguments; every option seen by `parse_opt' will be reflected in `arguments'. */ parse_options(argc, argv); print_version(program_name, CDIO_VERSION, false, opts.version_only); if (opts.debug_level == 3) { cdio_loglevel_default = CDIO_LOG_INFO; } else if (opts.debug_level >= 4) { cdio_loglevel_default = CDIO_LOG_DEBUG; } if (NULL == source_name) { char *default_device; p_cdio = cdio_open (NULL, DRIVER_DEVICE); if (NULL == p_cdio) { printf("No loaded CD-ROM device accessible.\n"); } else { default_device = cdio_get_default_device(p_cdio); printf("The driver selected is %s\n", cdio_get_driver_name(p_cdio)); if (default_device) { printf("The default device for this driver is %s\n", default_device); } free(default_device); cdio_destroy(p_cdio); p_cdio=NULL; printf("\n"); } } /* Print out a drivers available */ { driver_id_t driver_id; printf("Drivers available...\n"); for (driver_id=CDIO_MIN_DRIVER; driver_id<=CDIO_MAX_DRIVER; driver_id++) if (cdio_have_driver(driver_id)) { printf(" %-35s\n", cdio_driver_describe(driver_id)); } printf("\n"); } if (NULL == source_name) { /* Print out a list of CD-drives */ char **ppsz_cdrives=NULL, **ppsz_cd; driver_id_t driver_id = DRIVER_DEVICE; ppsz_cdrives = cdio_get_devices_ret(&driver_id); if (NULL != ppsz_cdrives) for( ppsz_cd = ppsz_cdrives; *ppsz_cd != NULL; ppsz_cd++ ) { cdio_drive_read_cap_t i_read_cap; cdio_drive_write_cap_t i_write_cap; cdio_drive_misc_cap_t i_misc_cap; cdio_hwinfo_t hwinfo; CdIo_t *p_cdio = cdio_open(*ppsz_cd, driver_id); printf("%28s: %s\n", "Drive", *ppsz_cd); if (p_cdio) { if (cdio_get_hwinfo(p_cdio, &hwinfo)) { printf("%-28s: %s\n%-28s: %s\n%-28s: %s\n", "Vendor" , hwinfo.psz_vendor, "Model" , hwinfo.psz_model, "Revision", hwinfo.psz_revision); } print_mmc_drive_features(p_cdio); cdio_get_drive_cap(p_cdio, &i_read_cap, &i_write_cap, &i_misc_cap); print_drive_capabilities(i_read_cap, i_write_cap, i_misc_cap); } printf("\n"); if (p_cdio) cdio_destroy(p_cdio); } cdio_free_device_list(ppsz_cdrives); free(ppsz_cdrives); ppsz_cdrives = NULL; } else { /* Print CD-drive info for given source */ cdio_drive_read_cap_t i_read_cap; cdio_drive_write_cap_t i_write_cap; cdio_drive_misc_cap_t i_misc_cap; cdio_hwinfo_t hwinfo; printf("Drive %s\n", source_name); p_cdio = cdio_open (source_name, DRIVER_UNKNOWN); if (NULL != p_cdio) { if (cdio_get_hwinfo(p_cdio, &hwinfo)) { printf("%-28s: %s\n%-28s: %s\n%-28s: %s\n", "Vendor" , hwinfo.psz_vendor, "Model" , hwinfo.psz_model, "Revision", hwinfo.psz_revision); } print_mmc_drive_features(p_cdio); } cdio_get_drive_cap_dev(source_name, &i_read_cap, &i_write_cap, &i_misc_cap); print_drive_capabilities(i_read_cap, i_write_cap, i_misc_cap); printf("\n"); } myexit(p_cdio, EXIT_SUCCESS); /* Not reached:*/ return(EXIT_SUCCESS); }
void cdda_drive_info(cdda_drive_t * drive) { CdIo_t * cdio; cdio_hwinfo_t hwinfo; cdio_drive_read_cap_t read_cap; cdio_drive_write_cap_t write_cap; cdio_drive_misc_cap_t misc_cap; GtkWidget * dialog; GtkWidget * content_area; GtkWidget * label; GtkWidget * hbox; GtkWidget * vbox; GtkWidget * notebook; GtkWidget * table; char str[MAXLEN]; cdio = cdio_open(drive->device_path, DRIVER_UNKNOWN); if (!cdio_get_hwinfo(cdio, &hwinfo)) { cdio_destroy(cdio); return; } cdio_get_drive_cap(cdio, &read_cap, &write_cap, &misc_cap); cdio_destroy(cdio); snprintf(str, MAXLEN-1, "%s [%s]", _("Drive info"), cdda_displayed_device_path(drive->device_path)); dialog = gtk_dialog_new_with_buttons(str, GTK_WINDOW(browser_window), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER); content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); vbox = gtk_vbox_new(FALSE, 0); gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); gtk_box_pack_start(GTK_BOX(content_area), vbox, FALSE, FALSE, 4); table = gtk_table_new(4, 2, FALSE); gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 2); hbox = gtk_hbox_new(FALSE, 0); label = gtk_label_new(_("Device path:")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_table_attach(GTK_TABLE(table), hbox, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 4, 1); hbox = gtk_hbox_new(FALSE, 0); label = gtk_label_new(cdda_displayed_device_path(drive->device_path)); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 4, 1); hbox = gtk_hbox_new(FALSE, 0); label = gtk_label_new(_("Vendor:")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_table_attach(GTK_TABLE(table), hbox, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 4, 1); hbox = gtk_hbox_new(FALSE, 0); label = gtk_label_new(hwinfo.psz_vendor); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 1, 2, GTK_FILL, GTK_FILL, 4, 1); hbox = gtk_hbox_new(FALSE, 0); label = gtk_label_new(_("Model:")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_table_attach(GTK_TABLE(table), hbox, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 4, 1); hbox = gtk_hbox_new(FALSE, 0); label = gtk_label_new(hwinfo.psz_model); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 2, 3, GTK_FILL, GTK_FILL, 4, 1); hbox = gtk_hbox_new(FALSE, 0); label = gtk_label_new(_("Revision:")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_table_attach(GTK_TABLE(table), hbox, 0, 1, 3, 4, GTK_FILL, GTK_FILL, 4, 1); hbox = gtk_hbox_new(FALSE, 0); label = gtk_label_new(hwinfo.psz_revision); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_table_attach(GTK_TABLE(table), hbox, 1, 2, 3, 4, GTK_FILL, GTK_FILL, 4, 1); hbox = gtk_hbox_new(FALSE, 0); label = gtk_label_new(_("The information below is reported by the drive, and\n" "may not reflect the actual capabilities of the device.")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 3); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 10); if ((misc_cap == CDIO_DRIVE_CAP_ERROR) && (read_cap == CDIO_DRIVE_CAP_ERROR) && (write_cap == CDIO_DRIVE_CAP_ERROR)) { goto cdda_info_finish; } notebook = gtk_notebook_new(); gtk_box_pack_start(GTK_BOX(content_area), notebook, TRUE, TRUE, 0); if (misc_cap != CDIO_DRIVE_CAP_ERROR) { int cnt = 0; label = gtk_label_new(_("General")); table = gtk_table_new(8, 2, FALSE); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label); cdda_info_row(_("Eject"), misc_cap & CDIO_DRIVE_CAP_MISC_EJECT, table, &cnt); cdda_info_row(_("Close tray"), misc_cap & CDIO_DRIVE_CAP_MISC_CLOSE_TRAY, table, &cnt); cdda_info_row(_("Disable manual eject"), misc_cap & CDIO_DRIVE_CAP_MISC_LOCK, table, &cnt); cdda_info_row(_("Select juke-box disc"), misc_cap & CDIO_DRIVE_CAP_MISC_SELECT_DISC, table, &cnt); cdda_info_row(_("Set drive speed"), misc_cap & CDIO_DRIVE_CAP_MISC_SELECT_SPEED, table, &cnt); cdda_info_row(_("Detect media change"), misc_cap & CDIO_DRIVE_CAP_MISC_MEDIA_CHANGED, table, &cnt); cdda_info_row(_("Read multiple sessions"), misc_cap & CDIO_DRIVE_CAP_MISC_MULTI_SESSION, table, &cnt); cdda_info_row(_("Hard reset device"), misc_cap & CDIO_DRIVE_CAP_MISC_RESET, table, &cnt); } if (read_cap != CDIO_DRIVE_CAP_ERROR) { int cnt = 0; label = gtk_label_new(_("Reading")); table = gtk_table_new(16, 2, FALSE); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label); cdda_info_row(_("Play CD Audio"), read_cap & CDIO_DRIVE_CAP_READ_AUDIO, table, &cnt); cdda_info_row(_("Read CD-DA"), read_cap & CDIO_DRIVE_CAP_READ_CD_DA, table, &cnt); cdda_info_row(_("Read CD+G"), read_cap & CDIO_DRIVE_CAP_READ_CD_G, table, &cnt); cdda_info_row(_("Read CD-R"), read_cap & CDIO_DRIVE_CAP_READ_CD_R, table, &cnt); cdda_info_row(_("Read CD-RW"), read_cap & CDIO_DRIVE_CAP_READ_CD_RW, table, &cnt); cdda_info_row(_("Read DVD-R"), read_cap & CDIO_DRIVE_CAP_READ_DVD_R, table, &cnt); cdda_info_row(_("Read DVD+R"), read_cap & CDIO_DRIVE_CAP_READ_DVD_PR, table, &cnt); cdda_info_row(_("Read DVD-RW"), read_cap & CDIO_DRIVE_CAP_READ_DVD_RW, table, &cnt); cdda_info_row(_("Read DVD+RW"), read_cap & CDIO_DRIVE_CAP_READ_DVD_RPW, table, &cnt); cdda_info_row(_("Read DVD-RAM"), read_cap & CDIO_DRIVE_CAP_READ_DVD_RAM, table, &cnt); cdda_info_row(_("Read DVD-ROM"), read_cap & CDIO_DRIVE_CAP_READ_DVD_ROM, table, &cnt); cdda_info_row(_("C2 Error Correction"), read_cap & CDIO_DRIVE_CAP_READ_C2_ERRS, table, &cnt); cdda_info_row(_("Read Mode 2 Form 1"), read_cap & CDIO_DRIVE_CAP_READ_MODE2_FORM1, table, &cnt); cdda_info_row(_("Read Mode 2 Form 2"), read_cap & CDIO_DRIVE_CAP_READ_MODE2_FORM2, table, &cnt); cdda_info_row(_("Read MCN"), read_cap & CDIO_DRIVE_CAP_READ_MCN, table, &cnt); cdda_info_row(_("Read ISRC"), read_cap & CDIO_DRIVE_CAP_READ_ISRC, table, &cnt); } if (write_cap != CDIO_DRIVE_CAP_ERROR) { int cnt = 0; label = gtk_label_new(_("Writing")); table = gtk_table_new(9, 2, FALSE); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label); cdda_info_row(_("Write CD-R"), write_cap & CDIO_DRIVE_CAP_WRITE_CD_R, table, &cnt); cdda_info_row(_("Write CD-RW"), write_cap & CDIO_DRIVE_CAP_WRITE_CD_RW, table, &cnt); cdda_info_row(_("Write DVD-R"), write_cap & CDIO_DRIVE_CAP_WRITE_DVD_R, table, &cnt); cdda_info_row(_("Write DVD+R"), write_cap & CDIO_DRIVE_CAP_WRITE_DVD_PR, table, &cnt); cdda_info_row(_("Write DVD-RW"), write_cap & CDIO_DRIVE_CAP_WRITE_DVD_RW, table, &cnt); cdda_info_row(_("Write DVD+RW"), write_cap & CDIO_DRIVE_CAP_WRITE_DVD_RPW, table, &cnt); cdda_info_row(_("Write DVD-RAM"), write_cap & CDIO_DRIVE_CAP_WRITE_DVD_RAM, table, &cnt); cdda_info_row(_("Mount Rainier"), write_cap & CDIO_DRIVE_CAP_WRITE_MT_RAINIER, table, &cnt); cdda_info_row(_("Burn Proof"), write_cap & CDIO_DRIVE_CAP_WRITE_BURN_PROOF, table, &cnt); } cdda_info_finish: gtk_widget_show_all(dialog); aqualung_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); }