Detect video DVDs

pull/16/head
Timothy Pearson 11 years ago
parent cbf8c414a1
commit b181191ccc

@ -816,7 +816,7 @@ void TDEHardwareDevices::processModifiedMounts() {
emit hardwareEvent(TDEHardwareEvent::MountTableModified, TQString());
}
TDEDiskDeviceType::TDEDiskDeviceType classifyDiskType(udev_device* dev, const TQString devicebus, const TQString disktypestring, const TQString systempath, const TQString devicevendor, const TQString devicemodel, const TQString filesystemtype, const TQString devicedriver) {
TDEDiskDeviceType::TDEDiskDeviceType classifyDiskType(udev_device* dev, const TQString devicenode, const TQString devicebus, const TQString disktypestring, const TQString systempath, const TQString devicevendor, const TQString devicemodel, const TQString filesystemtype, const TQString devicedriver) {
// Classify a disk device type to the best of our ability
TDEDiskDeviceType::TDEDiskDeviceType disktype = TDEDiskDeviceType::Null;
@ -1033,6 +1033,26 @@ TDEDiskDeviceType::TDEDiskDeviceType classifyDiskType(udev_device* dev, const TQ
if ((TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_VCD")) == "1") || (TQString(udev_device_get_property_value(dev, "ID_CDROM_MEDIA_SDVD")) == "1")) {
disktype = disktype | TDEDiskDeviceType::CDVideo;
}
if ((disktype & TDEDiskDeviceType::DVDROM)
|| (disktype & TDEDiskDeviceType::DVDRAM)
|| (disktype & TDEDiskDeviceType::DVDR)
|| (disktype & TDEDiskDeviceType::DVDRW)
|| (disktype & TDEDiskDeviceType::DVDRDL)
|| (disktype & TDEDiskDeviceType::DVDRWDL)
|| (disktype & TDEDiskDeviceType::DVDPLUSR)
|| (disktype & TDEDiskDeviceType::DVDPLUSRW)
|| (disktype & TDEDiskDeviceType::DVDPLUSRDL)
|| (disktype & TDEDiskDeviceType::DVDPLUSRWDL)
) {
// Every VideoDVD must have a VIDEO_TS.IFO file
// Read this info via tdeiso_info, since udev couldn't be bothered to check DVD type on its own
int retcode = system(TQString("tdeiso_info --exists=ISO9660/VIDEO_TS/VIDEO_TS.IFO %1").arg(devicenode).ascii());
if (retcode == 0) {
disktype = disktype | TDEDiskDeviceType::DVDVideo;
}
}
}
// Detect RAM and Loop devices, since udev can't seem to...
@ -2261,7 +2281,7 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
TDEDiskDeviceType::TDEDiskDeviceType disktype = sdevice->diskType();
TDEDiskDeviceStatus::TDEDiskDeviceStatus diskstatus = TDEDiskDeviceStatus::Null;
disktype = classifyDiskType(dev, devicebus, devicetypestring, systempath, devicevendor, devicemodel, filesystemtype, devicedriver);
disktype = classifyDiskType(dev, devicenode, devicebus, devicetypestring, systempath, devicevendor, devicemodel, filesystemtype, devicedriver);
sdevice->internalSetDiskType(disktype);
device = classifyUnknownDeviceByExternalRules(dev, device, true); // Check external rules for possible subtype overrides
disktype = sdevice->diskType(); // The type can be overridden by an external rule
@ -2418,7 +2438,7 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist
if ((slavediskfstype.upper() == "CRYPTO_LUKS") || (slavediskfstype.upper() == "CRYPTO")) {
disktype = disktype | TDEDiskDeviceType::UnlockedCrypt;
// Set disk type based on parent device
disktype = disktype | classifyDiskType(slavedev, TQString(udev_device_get_property_value(dev, "ID_BUS")), TQString(udev_device_get_property_value(dev, "ID_TYPE")), (*slaveit), TQString(udev_device_get_property_value(dev, "ID_VENDOR")), TQString(udev_device_get_property_value(dev, "ID_MODEL")), TQString(udev_device_get_property_value(dev, "ID_FS_TYPE")), TQString(udev_device_get_driver(dev)));
disktype = disktype | classifyDiskType(slavedev, devicenode, TQString(udev_device_get_property_value(dev, "ID_BUS")), TQString(udev_device_get_property_value(dev, "ID_TYPE")), (*slaveit), TQString(udev_device_get_property_value(dev, "ID_VENDOR")), TQString(udev_device_get_property_value(dev, "ID_MODEL")), TQString(udev_device_get_property_value(dev, "ID_FS_TYPE")), TQString(udev_device_get_driver(dev)));
}
udev_device_unref(slavedev);
}

@ -17,6 +17,7 @@ include_directories(
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_BINARY_DIR}/tdecore
${CMAKE_SOURCE_DIR}/dcop
${CMAKE_SOURCE_DIR}/tdecore
${CMAKE_SOURCE_DIR}/tdeio
${CMAKE_SOURCE_DIR}/tdeio/tdeio
@ -49,3 +50,18 @@ tde_add_kpart( ${target} AUTOMOC
LINK isofs-static tdeio-shared
DESTINATION ${PLUGIN_INSTALL_DIR}
)
##### tdeiso_info #################################
set( target tdeiso_info )
set( ${target}_SRCS
kisodirectory.cpp kisofile.cpp qfilehack.cpp
kiso.cpp tdeiso_info.cpp
)
tde_add_executable( ${target} AUTOMOC
SOURCES ${${target}_SRCS}
LINK isofs-static tdeio-shared
DESTINATION ${BIN_INSTALL_DIR}
)

@ -0,0 +1,103 @@
/***************************************************************************
* Copyright (C) 2013 by Timothy Pearson *
* kb9vqf@pearsoncomputing.net *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <cstdlib>
#include <tdeapplication.h>
#include <tdestartupinfo.h>
#include <tdecmdlineargs.h>
#include <kuniqueapplication.h>
#include <tdeaboutdata.h>
#include "libisofs/iso_fs.h"
#include "kiso.h"
#include "kisofile.h"
#include "kisodirectory.h"
#include "iso.h"
static const char description[] =
I18N_NOOP("TDE utility for getting ISO information");
static const char version[] = "v0.0.1";
static const TDECmdLineOptions options[] =
{
{ "exists <filename>", I18N_NOOP("Returns 0 if the file exists, -1 if it does not"), 0 },
{ "!+device", I18N_NOOP("The device on which to execute the specified command. Example: /dev/sr0"), 0 },
TDECmdLineLastOption // End of options.
};
int main(int argc, char *argv[])
{
TDEAboutData aboutData( "tdeldapmanager", I18N_NOOP("Kerberos Realm Manager"),
version, description, TDEAboutData::License_GPL,
"(c) 2013, Timothy Pearson");
aboutData.addAuthor("Timothy Pearson",0, "kb9vqf@pearsoncomputing.net");
TDECmdLineArgs::init(argc, argv, &aboutData);
TDECmdLineArgs::addCmdLineOptions(options);
KUniqueApplication::addCmdLineOptions();
TDEApplication::disableAutoDcopRegistration();
TDEApplication app(false, false);
TDEStartupInfo::appStarted();
//======================================================================================================================================================
//
// Main code follows
//
//======================================================================================================================================================
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
if (args->count() > 0) {
TQString device = TQString(args->arg(0));
if (args->isSet("exists")) {
KIso isoFile( device );
if ( !isoFile.open( IO_ReadOnly ) ) {
printf("Unable to open device '%s'\n\r", device.ascii());
return -2;
}
// RAJA FIXME
TQString fileToFind = args->getOption("exists");
const KArchiveDirectory* entries = isoFile.directory();
if (!entries) {
return -1;
}
if (entries->entry(fileToFind)) {
return 0;
}
else {
return -1;
}
}
}
else {
TDECmdLineArgs::usage(i18n("No device was specified"));
return -3;
}
//======================================================================================================================================================
return 0;
}
Loading…
Cancel
Save