Logo Search packages:      
Sourcecode: k9copy version File versions  Download package

bool K3bDevice::Device::init ( bool  checkWritingModes = true  )  [private]

Determines the device's capabilities. This needs to be called once before using the device.

Should only be used by the DeviceManager.

Parameters:
checkWritingModes if true the CD writing modes will be checked using MMC_MODE_SELECT.

Definition at line 197 of file k3bdevice.cpp.

References blockDeviceName(), close(), determineMaximalWriteSpeed(), and open().

{
  kdDebug() << "(K3bDevice::Device) " << blockDeviceName() << ": init()" << endl;

  //
  // they all should read CD-ROM.
  //
  d->deviceType = DEVICE_CD_ROM;

  d->supportedProfiles = 0;

  if( !open() )
    return false;

  //
  // inquiry
  // use a 36 bytes buffer since not all devices return the full inquiry struct
  //
  ScsiCommand cmd( this );
  unsigned char buf[36];
  cmd.clear();
  ::memset( buf, 0, sizeof(buf) );
  struct inquiry* inq = (struct inquiry*)buf;
  cmd[0] = MMC_INQUIRY;
  cmd[4] = sizeof(buf);
  cmd[5] = 0;
  if( cmd.transport( TR_DIR_READ, buf, sizeof(buf) ) ) {
    kdError() << "(K3bDevice::Device) Unable to do inquiry." << endl;
    close();
    return false;
  }
  else {
    m_vendor = QString::fromLocal8Bit( (char*)(inq->vendor), 8 ).stripWhiteSpace();
    m_description = QString::fromLocal8Bit( (char*)(inq->product), 16 ).stripWhiteSpace();
    m_version = QString::fromLocal8Bit( (char*)(inq->revision), 4 ).stripWhiteSpace();
  }

  if( m_vendor.isEmpty() )
    m_vendor = "UNKNOWN";
  if( m_description.isEmpty() )
    m_description = "UNKNOWN";

  //
  // We probe all features of the device. Since not all devices support the GET CONFIGURATION command
  // we also query the mode page 2A and use the cdrom.h stuff to get as much information as possible
  //
  checkFeatures();

  //
  // Check the supported write modes (WRITINGMODE_TAO, WRITINGMODE_SAO, WRITINGMODE_RAW) by trying to set them
  // We do this before checking mode page 2A in case some readers allow changin
  // the write parameter page
  //
  if( bCheckWritingModes )
    checkWritingModes();

  //
  // Most current drives support the 2A mode page
  // Here we can get some more information (cdrecord -prcap does exactly this)
  //
  checkFor2AFeatures();

  m_maxWriteSpeed = determineMaximalWriteSpeed();

  //
  // Check Just-Link via Ricoh mode page 0x30
  //
  if( !d->burnfree )
    checkForJustLink();
  
  //
  // Support for some very old drives
  //
  checkForAncientWriters();

  close();

  return furtherInit();
}


Generated by  Doxygen 1.6.0   Back to index