From adcdf1d0d0ca100b319905e59e3e61394ba87117 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Fri, 10 Nov 2023 11:24:47 +0900 Subject: Rename src/config.h to src/configuration.h to avoid possible conflicts with autogenerated config.h file Signed-off-by: Michele Calgaro --- src/Makefile.am | 4 +- src/cdopener.cpp | 2 +- src/config.cpp | 1516 ----------------------------------------- src/config.h | 355 ---------- src/configbackendspage.cpp | 2 +- src/configdialog.cpp | 2 +- src/configenvironmentpage.cpp | 2 +- src/configgeneralpage.cpp | 2 +- src/configpluginspage.cpp | 2 +- src/configuration.cpp | 1516 +++++++++++++++++++++++++++++++++++++++++ src/configuration.h | 355 ++++++++++ src/convert.cpp | 2 +- src/dirdialog.cpp | 2 +- src/filelist.cpp | 2 +- src/options.cpp | 2 +- src/optionsdetailed.cpp | 2 +- src/optionseditor.cpp | 1 + src/optionsrequester.cpp | 2 +- src/optionssimple.cpp | 2 +- src/outputdirectory.cpp | 2 +- src/replaygain.cpp | 2 +- src/replaygainfilelist.cpp | 2 +- src/replaygainscanner.cpp | 2 +- src/soundkonverter.cpp | 2 +- 24 files changed, 1892 insertions(+), 1891 deletions(-) delete mode 100644 src/config.cpp delete mode 100644 src/config.h create mode 100644 src/configuration.cpp create mode 100644 src/configuration.h diff --git a/src/Makefile.am b/src/Makefile.am index 96add23..7b28f13 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,7 +3,7 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/src/metadata/ \ -I$(top_srcdir)/src/pluginloader/ $(cdda_includes) # these are the headers for your project -noinst_HEADERS = cdmanager.h cdopener.h combobutton.h config.h \ +noinst_HEADERS = cdmanager.h cdopener.h combobutton.h configuration.h \ configbackendspage.h configdialog.h configenvironmentpage.h configgeneralpage.h \ configpagebase.h configpluginspage.h conversionoptions.h convert.h cuesheeteditor.h \ dcopinterface.h dirdialog.h filelist.h logger.h logviewer.h options.h optionsdetailed.h \ @@ -29,7 +29,7 @@ bin_PROGRAMS = soundkonverter # the application source, library search path, and link libraries soundkonverter_SOURCES = cddb.cpp cdmanager.cpp cdopener.cpp combobutton.cpp \ - config.cpp configbackendspage.cpp configdialog.cpp configenvironmentpage.cpp \ + configuration.cpp configbackendspage.cpp configdialog.cpp configenvironmentpage.cpp \ configgeneralpage.cpp configpagebase.cpp configpluginspage.cpp conversionoptions.cpp \ convert.cpp cuesheeteditor.cpp dcopinterface.skel dirdialog.cpp filelist.cpp \ logger.cpp logviewer.cpp main.cpp options.cpp optionsdetailed.cpp \ diff --git a/src/cdopener.cpp b/src/cdopener.cpp index b707012..df4aa16 100644 --- a/src/cdopener.cpp +++ b/src/cdopener.cpp @@ -2,7 +2,7 @@ #include "cdopener.h" #include "cdmanager.h" #include "tagengine.h" -#include "config.h" +#include "configuration.h" #include "ripperpluginloader.h" #include "combobutton.h" diff --git a/src/config.cpp b/src/config.cpp deleted file mode 100644 index d33d975..0000000 --- a/src/config.cpp +++ /dev/null @@ -1,1516 +0,0 @@ - -#include "config.h" -#include "logger.h" -#include "convertpluginloader.h" -#include "replaygainpluginloader.h" -#include "ripperpluginloader.h" -#include "options.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -// NOTE currently only the possibilities of a file format are respected, -// the possibilities of the current encoder are ignored -// - seems to be fixed - -FormatItem::FormatItem() -{ - // reset everything - mime_types.clear(); - size = 0; - compressionType = FormatInfo::lossy; - compressionLevel = 0; - internalReplayGain = false; - encoders.clear(); - decoders.clear(); - replaygains.clear(); - //repairers.clear(); - encoder = 0; - decoder = 0; - replaygain = 0; - //repairer = 0; -} - -FormatItem::~FormatItem() -{} - - -Config::Config( Logger* _logger ) -{ - logger = _logger; - - currentRipper = 0; // this seems to be unnecessary -} - -Config::~Config() -{} - -void Config::read() -{ - loadPlugins(); - readProfiles(); - - TDEConfig *conf = kapp->config(); - TQStringList listDefaults; - int intDefault; - bool boolDefault; - TQString ripper; - TQString encoder; - TQString decoder; - TQString replaygain; - int rank; - - conf->setGroup( "General" ) ; - data.app.configVersion = conf->readNumEntry( "configVersion", 0 ); - -/* if( configVersion == 0 ) { - conf->setGroup( "Interface" ); - data.general.updateDelay = conf->readNumEntry( "pauseMS", 500 ); - data.general.startTab = conf->readNumEntry( "startTab", 0 ); - data.general.showToolBar = conf->readBoolEntry( "showToolBar", false ); - - conf->setGroup( "Backends" ); - listDefaults.clear(); - TQString datadir = locateLocal( "data", "soundkonverter/bin/" ); - datadir.remove( datadir.length() - 1, 1 ); - listDefaults.append( datadir ); - listDefaults.append( TQDir::homeDirPath() + "/bin" ); - listDefaults.append( "/usr/local/bin" ); - listDefaults.append( "/usr/bin" ); - data.environment.directories = conf->readListEntry( "directories", listDefaults ); - listDefaults.clear(); - data.environment.foundPrograms = conf->readListEntry( "programs", listDefaults ); - - conf->setGroup( "Misc" ); - //configVersion = conf->readNumEntry( "configVersion", 0 ); - data.general.askForNewOptions = conf->readBoolEntry( "askForNewOptions", true ); - - return; - }*/ - - conf->setGroup( "General" ) ; - //configVersion = conf->readNumEntry( "configVersion", 0 ); - data.general.startTab = conf->readNumEntry( "startTab", 0 ); - data.general.lastTab = conf->readNumEntry( "lastTab", 0 ); - data.general.defaultProfile = conf->readEntry( "defaultProfile", i18n("Last used") ); - data.general.defaultFormat = conf->readEntry( "defaultFormat", i18n("Last used") ); -// data.general.defaultOutputDirectory = conf->readEntry( "defaultOutputDirectory", TQDir::homeDirPath() + "/soundKonverter/%b/%d - %n - %a - %t" ); - data.general.specifyOutputDirectory = conf->readEntry( "specifyOutputDirectory", TQDir::homeDirPath() + "/soundKonverter" ); - data.general.metaDataOutputDirectory = conf->readEntry( "metaDataOutputDirectory", TQDir::homeDirPath() + "/soundKonverter/%b/%d - %n - %a - %t" ); - data.general.copyStructureOutputDirectory = conf->readEntry( "copyStructureOutputDirectory", TQDir::homeDirPath() + "/soundKonverter" ); - data.general.useVFATNames = conf->readBoolEntry( "useVFATNames", true ); - data.general.conflictHandling = conf->readNumEntry( "conflictHandling", 0 ); - data.general.priority = conf->readNumEntry( "priority", 10 ); - data.general.numFiles = conf->readNumEntry( "numFiles", 3 ); - data.general.updateDelay = conf->readNumEntry( "updateDelay", 500 ); - data.general.askForNewOptions = conf->readBoolEntry( "askForNewOptions", true ); - data.general.executeUserScript = conf->readBoolEntry( "executeUserScript", false ); - data.general.showToolBar = conf->readBoolEntry( "showToolBar", false ); - - conf->setGroup( "Plugins" ); - data.plugins.checkForUpdates = conf->readBoolEntry( "checkForUpdates", false ); - - conf->setGroup( "Environment" ); - listDefaults.clear(); - TQString datadir = locateLocal( "data", "soundkonverter/bin/" ); - datadir.remove( datadir.length() - 1, 1 ); - listDefaults.append( datadir ); - listDefaults.append( TQDir::homeDirPath() + "/bin" ); - listDefaults.append( "/usr/local/bin" ); - listDefaults.append( "/usr/bin" ); - data.environment.directories = conf->readListEntry( "directories", listDefaults ); - listDefaults.clear(); - data.environment.foundPrograms = conf->readListEntry( "foundPrograms", listDefaults ); - - conf->setGroup( "Ripper" ); - ripper = conf->readEntry( "ripper", "tdeio_audiocd" ); - - if( ripper == "tdeio_audiocd" ) rank = 10000; - else rank = 60; // tdeio_audiocd ranking - currentRipper = 0; // this is a valid ripper (tdeio_audiocd) - for( TQValueList::Iterator b = rippers.begin(); b != rippers.end(); ++b ) { - binaries[ (*b)->rip.bin ] = ""; - if( (*b)->rip.rank > rank ) { - rank = (*b)->rip.rank; - currentRipper = (*b); - } - if( (*b)->rip.bin == ripper ) { - rank = 10000; // should be high enough to overbid the other plugins - currentRipper = (*b); - } - } - - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) - { - for( TQValueList::Iterator b = (*it).encoders.begin(); b != (*it).encoders.end(); ++b ) { - binaries[ (*b)->enc.bin ] = ""; - } - - for( TQValueList::Iterator b = (*it).decoders.begin(); b != (*it).decoders.end(); ++b ) { - binaries[ (*b)->dec.bin ] = ""; - } - - for( TQValueList::Iterator b = (*it).replaygains.begin(); b != (*it).replaygains.end(); ++b ) { - binaries[ (*b)->replaygain.bin ] = ""; - } - - for( TQMap::Iterator b = binaries.begin(); b != binaries.end(); ++b ) { - for( TQStringList::Iterator c = data.environment.directories.begin(); c != data.environment.directories.end(); ++c ) - { - if( b.data() == "" && TQFile::exists((*c) + "/" + b.key()) ) { - b.data() = (*c) + "/" + b.key(); - } - } - } - TQStringList foundPrograms; - for( TQMap::Iterator b = binaries.begin(); b != binaries.end(); ++b ) { - if( b.data() != "" ) { - foundPrograms.append( b.data() ); - } - } - if( foundPrograms != data.environment.foundPrograms ) { - backendsChanged = true; - } - else { - backendsChanged = false; - } - } - - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) - { - conf->setGroup( (*it).mime_types.first() ); - encoder = conf->readEntry( "encoder" ); - decoder = conf->readEntry( "decoder" ); - replaygain = conf->readEntry( "replaygain" ); - - (*it).encoder = 0; - (*it).decoder = 0; - (*it).replaygain = 0; - - rank = 0; - for( TQValueList::Iterator b = (*it).encoders.begin(); b != (*it).encoders.end(); ++b ) { - if( (*b)->enc.rank > rank && binaries[(*b)->enc.bin] != "" ) { - rank = (*b)->enc.rank; - (*it).encoder = (*b); - } - if( (*b)->enc.bin == encoder && binaries[(*b)->enc.bin] != "" ) { - rank = 10000; // should be high enougth to overbid the other plugins - (*it).encoder = (*b); - } - } - - rank = 0; - for( TQValueList::Iterator b = (*it).decoders.begin(); b != (*it).decoders.end(); ++b ) { - if( (*b)->dec.rank > rank && binaries[(*b)->dec.bin] != "" ) { - rank = (*b)->dec.rank; - (*it).decoder = (*b); - } - if( (*b)->dec.bin == decoder && binaries[(*b)->dec.bin] != "" ) { - rank = 10000; // should be high enougth to overbid the other plugins - (*it).decoder = (*b); - } - } - - rank = 0; - for( TQValueList::Iterator b = (*it).replaygains.begin(); b != (*it).replaygains.end(); ++b ) { - if( (*b)->replaygain.rank > rank && binaries[(*b)->replaygain.bin] != "" ) { - rank = (*b)->replaygain.rank; - (*it).replaygain = (*b); - } - if( (*b)->replaygain.bin == replaygain && binaries[(*b)->replaygain.bin] != "" ) { - rank = 10000; // should be high enougth to overbid the other plugins - (*it).replaygain = (*b); - } - } - - if( (*it).encoder != 0 && (*it).encoder->enc.strength.enabled ) { - if( (*it).encoder->enc.strength.range_max >= (*it).encoder->enc.strength.range_min ) - intDefault = (*it).encoder->enc.strength.default_value / (*it).encoder->enc.strength.step; - else - intDefault = ( (*it).encoder->enc.strength.range_min - (*it).encoder->enc.strength.default_value ) / (*it).encoder->enc.strength.step; - } - else { - intDefault = 0; - } - (*it).compressionLevel = conf->readNumEntry( "compressionLevel", intDefault ); - - if( (*it).encoder != 0 && (*it).encoder->enc.replaygain.enabled ) { - if( (*it).replaygain != 0 && (*it).replaygain->replaygain.rank > (*it).encoder->enc.replaygain.rank ) { - boolDefault = false; - } - else { - boolDefault = true; - } - } - else { - boolDefault = false; - } - (*it).internalReplayGain = conf->readBoolEntry( "internalReplayGain", boolDefault ); - } -} - -void Config::write( bool sync ) -{ - TQTime time; - time.start(); - - writeProfiles(); - writeServiceMenu(); - writeAmarokScript(); - - TDEConfig *conf = kapp->config(); - - conf->setGroup( "Ripper" ); - conf->writeEntry( "ripper", (currentRipper)?currentRipper->rip.bin:"tdeio_audiocd" ); - - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) - { - conf->setGroup( (*it).mime_types.first() ); - if( (*it).encoder ) conf->writeEntry( "encoder", (*it).encoder->enc.bin ); - if( (*it).decoder ) conf->writeEntry( "decoder", (*it).decoder->dec.bin ); - if( (*it).replaygain ) conf->writeEntry( "replaygain", (*it).replaygain->replaygain.bin ); - conf->writeEntry( "compressionLevel", (*it).compressionLevel ); - conf->writeEntry( "internalReplayGain", (*it).internalReplayGain ); - } - - conf->setGroup( "General" ) ; - conf->writeEntry( "configVersion", 300 ); - conf->writeEntry( "startTab", data.general.startTab ); - conf->writeEntry( "lastTab", data.general.lastTab ); - conf->writeEntry( "defaultProfile", data.general.defaultProfile ); - conf->writeEntry( "defaultFormat", data.general.defaultFormat ); -// conf->writeEntry( "defaultOutputDirectory", data.general.defaultOutputDirectory ); - conf->writeEntry( "specifyOutputDirectory", data.general.specifyOutputDirectory ); - conf->writeEntry( "metaDataOutputDirectory", data.general.metaDataOutputDirectory ); - conf->writeEntry( "copyStructureOutputDirectory", data.general.copyStructureOutputDirectory ); - conf->writeEntry( "useVFATNames", data.general.useVFATNames ); - conf->writeEntry( "conflictHandling", data.general.conflictHandling ); - conf->writeEntry( "priority", data.general.priority ); - conf->writeEntry( "numFiles", data.general.numFiles ); - conf->writeEntry( "updateDelay", data.general.updateDelay ); - conf->writeEntry( "askForNewOptions", data.general.askForNewOptions ); - conf->writeEntry( "executeUserScript", data.general.executeUserScript ); - conf->writeEntry( "showToolBar", data.general.showToolBar ); - - conf->setGroup( "Plugins" ); - conf->writeEntry( "checkForUpdates", data.plugins.checkForUpdates ); - - conf->setGroup( "Environment" ); - conf->writeEntry( "directories", data.environment.directories ); - data.environment.foundPrograms.clear(); - for( TQMap::Iterator b = binaries.begin(); b != binaries.end(); ++b ) { - if( b.data() != "" ) { - data.environment.foundPrograms.append( b.data() ); - } - } - conf->writeEntry( "foundPrograms", data.environment.foundPrograms ); - - if( sync ) conf->sync(); - - emit configChanged(); - - logger->log( 1000, "wrote preferences: " + TQString::number(time.elapsed()) ); -} - -void Config::readProfiles() -{ - int version; - TQString name; - ConversionOptions options; - - TQDomDocument domTree; - TQFile opmlFile( locateLocal("data","soundkonverter/profiles.xml") ); - if( !opmlFile.open( IO_ReadOnly ) ) return; - if( !domTree.setContent( &opmlFile ) ) return; - opmlFile.close(); - - TQDomElement root = domTree.documentElement(); - if( root.attribute("type") != "profiles" ) return; - TQDomNode node, sub1Node, sub2Node; - node = root.firstChild(); - - while( !node.isNull() ) { - if( node.isElement() && node.nodeName() == "info" ) { - - version = node.toElement().attribute("version").toInt(); - - } - else if( node.isElement() && node.nodeName() == "profile" ) { - - name = node.toElement().attribute("name"); - - sub1Node = node.toElement().firstChild(); - while( !sub1Node.isNull() ) { - if( sub1Node.isElement() && sub1Node.nodeName() == "encodingOptions" ) { -// TODO clean up - options.encodingOptions.sFormat = sub1Node.toElement().attribute("sFormat"); - options.encodingOptions.sQualityMode = sub1Node.toElement().attribute("sQualityMode"); - options.encodingOptions.iQuality = sub1Node.toElement().attribute("iQuality").toInt(); - options.encodingOptions.sBitrateMode = sub1Node.toElement().attribute("sBitrateMode"); - options.encodingOptions.bBitrateRange = sub1Node.toElement().attribute("bBitrateRange").toInt(); - options.encodingOptions.iMinBitrate = sub1Node.toElement().attribute("iMinBitrate").toInt(); - options.encodingOptions.iMaxBitrate = sub1Node.toElement().attribute("iMaxBitrate").toInt(); - - sub2Node = sub1Node.toElement().firstChild(); - while( !sub2Node.isNull() ) { - if( sub2Node.isElement() && sub2Node.nodeName() == "samplingRate" ) { - - options.encodingOptions.samplingRate.bEnabled = sub2Node.toElement().attribute("bEnabled").toInt(); - options.encodingOptions.samplingRate.iSamplingRate = sub2Node.toElement().attribute("iSamplingRate").toInt(); - - } - else if( sub2Node.isElement() && sub2Node.nodeName() == "channels" ) { - - options.encodingOptions.channels.bEnabled = sub2Node.toElement().attribute("bEnabled").toInt(); - options.encodingOptions.channels.sChannels = sub2Node.toElement().attribute("sChannels"); - - } - else if( sub2Node.isElement() && sub2Node.nodeName() == "replaygain" ) { - - options.encodingOptions.replaygain.bEnabled = sub2Node.toElement().attribute("bEnabled").toInt(); - - } - sub2Node = sub2Node.nextSibling(); - } - - options.encodingOptions.sInOutFiles = sub1Node.toElement().attribute("sInOutFiles"); - - } - else if( sub1Node.isElement() && sub1Node.nodeName() == "outputOptions" ) { - - options.outputOptions.mode = (OutputDirectory::Mode)sub1Node.toElement().attribute("mode").toInt(); - options.outputOptions.directory = sub1Node.toElement().attribute("directory"); - - } - sub1Node = sub1Node.nextSibling(); - } - ProfileData profileData; - profileData.name = name; - profileData.options = options; - profiles += profileData; - } - node = node.nextSibling(); - } -} - -void Config::writeProfiles() -{ - TQDomDocument domTree; - TQDomElement root = domTree.createElement( "soundkonverter" ); - root.setAttribute( "type", "profiles" ); - domTree.appendChild( root ); - - TQDomElement info = domTree.createElement( "info" ); - info.setAttribute( "version", "300" ); - root.appendChild( info ); - - for( TQValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) { - TQDomElement profile = domTree.createElement( "profile" ); - profile.setAttribute( "name", (*it).name ); - - TQDomElement encodingOptions = domTree.createElement( "encodingOptions" ); - - encodingOptions.setAttribute( "sFormat", (*it).options.encodingOptions.sFormat ); - encodingOptions.setAttribute( "sQualityMode", (*it).options.encodingOptions.sQualityMode ); - encodingOptions.setAttribute( "iQuality", (*it).options.encodingOptions.iQuality ); - encodingOptions.setAttribute( "sBitrateMode", (*it).options.encodingOptions.sBitrateMode ); - encodingOptions.setAttribute( "bBitrateRange", (*it).options.encodingOptions.bBitrateRange ); - encodingOptions.setAttribute( "iMinBitrate", (*it).options.encodingOptions.iMinBitrate ); - encodingOptions.setAttribute( "iMaxBitrate", (*it).options.encodingOptions.iMaxBitrate ); - - TQDomElement samplingRate = domTree.createElement( "samplingRate" ); - - samplingRate.setAttribute( "bEnabled", (*it).options.encodingOptions.samplingRate.bEnabled ); - samplingRate.setAttribute( "iSamplingRate", (*it).options.encodingOptions.samplingRate.iSamplingRate ); - - encodingOptions.appendChild( samplingRate ); - - TQDomElement channels = domTree.createElement( "channels" ); - - channels.setAttribute( "bEnabled", (*it).options.encodingOptions.channels.bEnabled ); - channels.setAttribute( "sChannels", (*it).options.encodingOptions.channels.sChannels ); - - encodingOptions.appendChild( channels ); - - TQDomElement replaygain = domTree.createElement( "replaygain" ); - - replaygain.setAttribute( "bEnabled", (*it).options.encodingOptions.replaygain.bEnabled ); - - encodingOptions.appendChild( replaygain ); - - encodingOptions.setAttribute( "sInOutFiles", (*it).options.encodingOptions.sInOutFiles ); - - profile.appendChild( encodingOptions ); - - TQDomElement outputOptions = domTree.createElement( "outputOptions" ); - - outputOptions.setAttribute( "mode", int((*it).options.outputOptions.mode) ); - outputOptions.setAttribute( "directory", (*it).options.outputOptions.directory ); - - profile.appendChild( outputOptions ); - - root.appendChild( profile ); - } - - TQFile opmlFile( locateLocal("data","soundkonverter/profiles.xml") ); - if( !opmlFile.open( IO_WriteOnly ) ) return; - - TQTextStream ts( &opmlFile ); - ts << domTree.toString(); - - opmlFile.close(); -} - -void Config::writeServiceMenu() -{ - int num; - TQString content; - TQFile file; - - num = 0; - content = ""; - content += "[Desktop Entry]\n"; - content += "X-TDE-ServiceTypes="; - - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { -// if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) { -// if( !(*it).encoder->enc.lossy.enabled && !(*it).encoder->enc.lossless.enabled && !(*it).encoder->enc.hybrid.enabled ) continue; -// for( TQStringList::Iterator b = (*it).mime_types.begin(); b != (*it).mime_types.end(); ++b ) { -// content += (*b) + ","; -// num++; -// } -// } - if( (*it).decoder != 0 && binaries[(*it).decoder->dec.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) { - for( TQStringList::Iterator b = (*it).mime_types.begin(); b != (*it).mime_types.end(); ++b ) { - content += (*b) + ","; - num++; - } - } - } - - if( num != 0 ) - { - content += "audio/x-wav"; - - content += "\n"; - content += "Icon=soundkonverter\n"; - content += "Actions=ConvertWithSoundkonverter\n\n"; - - content += "[Desktop Action ConvertWithSoundkonverter]\n"; - content += "Name="+i18n("Convert with soundKonverter ...")+"\n"; - content += "Icon=soundkonverter\n"; - content += "Exec=soundkonverter %F\n"; - - file.setName( locateLocal("data","konqueror/servicemenus/")+"convert_with_soundkonverter.desktop" ); - if ( file.open( IO_WriteOnly ) ) { - TQTextStream stream( &file ); - stream << content; - file.close(); - } - } - - num = 0; - content = ""; - content += "[Desktop Entry]\n"; - content += "ServiceTypes="; - - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - if( (*it).replaygain != 0 && binaries[(*it).replaygain->replaygain.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) { - for( TQStringList::Iterator b = (*it).mime_types.begin(); b != (*it).mime_types.end(); ++b ) { - content += (*b) + ","; - num++; - } - } - } - - if( num != 0 ) - { - content = content.left(content.length()-1); - - content += "\n"; - content += "Icon=soundkonverter_replaygain\n"; - content += "Actions=AddReplayGainWithSoundkonverter\n\n"; - - content += "[Desktop Action AddReplayGainWithSoundkonverter]\n"; - content += "Name="+i18n("Add Replay Gain with soundKonverter ...")+"\n"; - content += "Icon=soundkonverter_replaygain\n"; - content += "Exec=soundkonverter --replaygain %F\n"; - - file.setName( locateLocal("data","konqueror/servicemenus/")+"add_replaygain_with_soundkonverter.desktop" ); - if( file.open(IO_WriteOnly) ) { - TQTextStream st( &file ); - st << content; - file.close(); - } - } -} - -void Config::writeAmarokScript() -{ - int num, num1, num2; - TQString content, content1, content2; - TQFile file; - - num = 0; - content = ""; - content += "name = soundKonverter\n"; - content += "type = transcode\n\n"; - content += "[Transcode]\n"; - content += "target_formats = "; - - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) { - if( !(*it).encoder->enc.lossy.enabled && !(*it).encoder->enc.lossless.enabled && !(*it).encoder->enc.hybrid.enabled ) continue; - for( TQStringList::Iterator b = (*it).extensions.begin(); b != (*it).extensions.end(); ++b ) { - if( content.find(" "+(*b).lower()+" ") == -1 ) content += (*b).lower() + " "; - num++; - } - } - } - - if( num != 0 ) // TODO what is, if there are only decoders? - { - content += "wav"; - content += "\n"; - - file.setName( locateLocal("data","amarok/scripts/soundKonverter/")+"soundKonverter.spec" ); - if( file.open(IO_WriteOnly) ) { - TQTextStream st( &file ); - st << content; - file.close(); - } - } - - num1 = num2 = 0; - content = content1 = content2 = ""; - - // NOTE duplicate entries won't be shown to the user at any time, so they aren't filtered - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) { - if( (*it).encoder->enc.lossless.enabled ) { - for( TQStringList::Iterator b = (*it).extensions.begin(); b != (*it).extensions.end(); ++b ) { - if( content1.find(","+(*b).lower()+",") == -1 ) content1 += (*b).lower() + ","; // NOTE the first entry will be shown twice - num1++; - } - } - if( (*it).encoder->enc.hybrid.enabled ) { - for( TQStringList::Iterator b = (*it).extensions.begin(); b != (*it).extensions.end(); ++b ) { - if( content2.find(","+(*b).lower()+",") == -1 ) content2 += (*b).lower() + ","; // NOTE the first entry will be shown twice - num2++; - } - } - } - } - - if( num1 != 0 ) - { - content1 = content1.left(content1.length()-1); - content += "Lossless"; - content += "\n"; - content += content1; - content += "\n"; - } - - if( num2 != 0 ) - { - content2 = content2.left(content2.length()-1); - content += "Hybrid"; - content += "\n"; - content += content2; - content += "\n"; - } - - if( num1 != 0 || num2 != 0 ) - { - file.setName( locateLocal("data","amarok/scripts/soundKonverter/")+"formats" ); - if( file.open(IO_WriteOnly) ) { - TQTextStream st( &file ); - st << content; - file.close(); - } - } - - TDEStandardDirs* stdDirs = new TDEStandardDirs(); - if( !TQFile::exists(locateLocal("data","amarok/scripts/soundKonverter/soundKonverter.rb")) ) { - TDEIO::NetAccess::file_copy( stdDirs->findResource("data","soundkonverter/amarokscript/soundKonverter.rb"), locateLocal("data","amarok/scripts/soundKonverter/soundKonverter.rb"), 0755, true ); - } - if( !TQFile::exists(locateLocal("data","amarok/scripts/soundKonverter/README")) ) { - TDEIO::NetAccess::file_copy( stdDirs->findResource("data","soundkonverter/amarokscript/README"), locateLocal("data","amarok/scripts/soundKonverter/README"), -1, true ); - } - delete stdDirs; -} - -void Config::loadFileInfos() -{} - -void Config::loadPlugins() -{ - // NOTE can be speeded up - - //kdDebug() << "entering: `" << "Config::loadPlugins()" << "'" << endl; - logger->log( 1000, "entering: `Config::loadPlugins()'" ); - TQStringList list; - TQDir dir; - TQString correction_file_mime_type; - - /** a map that holds the _identifier_ and the _version_ number of all plugins */ - TQMap pluginMap; - - int version; - TQString identifier; - int i; - - ConvertPluginLoader* convertPluginLoader = new ConvertPluginLoader(); - ReplayGainPluginLoader* replaygainPluginLoader = new ReplayGainPluginLoader(); - RipperPluginLoader* ripperPluginLoader = new RipperPluginLoader(); - - TDEStandardDirs stddir; - TQStringList directories = stddir.findDirs( "data", "soundkonverter/plugins/" ); - for( TQStringList::Iterator a = directories.begin(); a != directories.end(); ++a ) - { - //kdDebug() << " searching directory: `" << *a << "'" << endl; - logger->log( 1000, " searching directory: `" + *a + "'" ); - dir.setPath( *a ); - list = dir.entryList( "*", TQDir::All, TQDir::Name ); - for( TQStringList::Iterator b = list.begin(); b != list.end(); ++b ) - { - if( *b != "." && *b != ".." && (*b).right(19) == ".soundkonverter.xml" ) - { - //kdDebug() << " found file: `" << *b << "'" << endl; - logger->log( 1000, " found file: `" + *b + "'" ); - if( convertPluginLoader->verifyFile( TQString(*a).append(*b) ) != -1 ) - { - version = convertPluginLoader->verifyFile( TQString(*a).append(*b) ); - identifier = *b; - identifier.remove( identifier.length() - 19, 19 ); - i = identifier.findRev( "-" ); - identifier.remove( i, identifier.length() - i ); -// i = identifier.find( "." ); -// identifier.remove( 0, i + 1 ); - if( !pluginMap.contains(identifier) ) { - PluginMapData data; - data.version = 0; - pluginMap.insert( identifier, data ); - } - if( pluginMap[identifier].version < version ) - { - pluginMap[identifier].version = version; - pluginMap[identifier].filename = TQString(*a).append(*b); - pluginMap[identifier].type = "converter"; - logger->log( 1000, " updating version for: `" + identifier + "'" ); - } - } - else if( replaygainPluginLoader->verifyFile( TQString(*a).append(*b) ) != -1 ) - { - version = replaygainPluginLoader->verifyFile( TQString(*a).append(*b) ); - identifier = *b; - identifier.remove( identifier.length() - 19, 19 ); - i = identifier.findRev( "-" ); - identifier.remove( i, identifier.length() - i ); -// i = identifier.find( "." ); -// identifier.remove( 0, i + 1 ); - if( !pluginMap.contains(identifier) ) { - PluginMapData data; - data.version = 0; - pluginMap.insert( identifier, data ); - } - if( pluginMap[identifier].version < version ) - { - pluginMap[identifier].version = version; - pluginMap[identifier].filename = TQString(*a).append(*b); - pluginMap[identifier].type = "replaygain"; - logger->log( 1000, " updating version for: `" + identifier + "'" ); - } - } - else if( ripperPluginLoader->verifyFile( TQString(*a).append(*b) ) != -1 ) - { - version = ripperPluginLoader->verifyFile( TQString(*a).append(*b) ); - identifier = *b; - identifier.remove( identifier.length() - 19, 19 ); - i = identifier.findRev( "-" ); - identifier.remove( i, identifier.length() - i ); -// i = identifier.find( "." ); -// identifier.remove( 0, i + 1 ); - if( !pluginMap.contains(identifier) ) { - PluginMapData data; - data.version = 0; - pluginMap.insert( identifier, data ); - } - if( pluginMap[identifier].version < version ) - { - pluginMap[identifier].version = version; - pluginMap[identifier].filename = TQString(*a).append(*b); - pluginMap[identifier].type = "ripper"; - logger->log( 1000, " updating version for: `" + identifier + "'" ); - } - } - else - { - //kdDebug() << " file is invalid: `" << *b << "'" << endl; - logger->log( 1000, " file is invalid: `" + *b + "'" ); - } - } - } - } - - for( TQMap::Iterator a = pluginMap.begin(); a != pluginMap.end(); ++a ) { - if( a.data().type == "converter" ) - { - ConvertPlugin* plugin = convertPluginLoader->loadFile( a.data().filename ); - if( plugin->info.version != -1 ) - { - if( plugin->enc.hybrid.enabled ) - { - correction_file_mime_type = plugin->enc.hybrid.correction_file_mime_type; - } - if( plugin->enc.enabled ) - { - for( TQStringList::Iterator b = plugin->enc.mime_types.begin(); b != plugin->enc.mime_types.end(); ++b ) - { - //kdDebug() << " registering encoder for: `" << *b << "'" << endl; - logger->log( 1000, " registering encoder for: `" + *b + "'" ); - registerFormatFeatures( *b, plugin, 0, 0, correction_file_mime_type ); - } - } - if( plugin->dec.enabled ) - { - for( TQStringList::Iterator b = plugin->dec.mime_types.begin(); b != plugin->dec.mime_types.end(); ++b ) - { - //kdDebug() << " registering decoder for: `" << *b << "'" << endl; - logger->log( 1000, " registering decoder for: `" + *b + "'" ); - registerFormatFeatures( *b, 0, plugin, 0, correction_file_mime_type ); - } - } - converters.append( plugin ); - //kdDebug() << " plugin sucessfully loaded: `" << a.key() << "'" << endl; - logger->log( 1000, " plugin sucessfully loaded: `" + a.key() + "'" ); - } - else - { - //kdError() << " failed to load Plugin: `" << a.key() << "'" << endl; - logger->log( 1000, " failed to load Plugin: `" + a.key() + "'" ); - } - } - else if( a.data().type == "replaygain" ) - { - ReplayGainPlugin* plugin = replaygainPluginLoader->loadFile( a.data().filename ); - if( plugin->info.version != -1 ) - { - for( TQStringList::Iterator b = plugin->replaygain.mime_types.begin(); b != plugin->replaygain.mime_types.end(); ++b ) - { - //kdDebug() << " registering replaygain for: `" << *b << "'" << endl; - logger->log( 1000, " registering replaygain for: `" + *b + "'" ); - registerFormatFeatures( *b, 0, 0, plugin ); - } - replaygains.append( plugin ); - //kdDebug() << " plugin sucessfully loaded: `" << a.key() << "'" << endl; - logger->log( 1000, " plugin sucessfully loaded: `" + a.key() + "'" ); - } - else - { - //kdError() << " failed to load Plugin: `" << a.key() << "'" << endl; - logger->log( 1000, " failed to load Plugin: `" + a.key() + "'" ); - } - } - else if( a.data().type == "ripper" ) - { - RipperPlugin* plugin = ripperPluginLoader->loadFile( a.data().filename ); - if( plugin->info.version != -1 ) - { - rippers.append( plugin ); - //kdDebug() << " plugin sucessfully loaded: `" << a.key() << "'" << endl; - logger->log( 1000, " plugin sucessfully loaded: `" + a.key() + "'" ); - } - else - { - //kdError() << " failed to load Plugin: `" << a.key() << "'" << endl; - logger->log( 1000, " failed to load Plugin: `" + a.key() + "'" ); - } - } - } - - delete convertPluginLoader; - delete replaygainPluginLoader; - delete ripperPluginLoader; - - // NOTE in order to make a plugin working, there must be a format_infos file. - - // TODO remove duplicate extensions - - FormatInfoLoader* formatInfoLoader = new FormatInfoLoader(); - - //kdDebug() << " trying to open: `" << "soundkonverter/format_infos/"+language+"/" << "'" << endl; -// logger->log( 1000, " trying to open: `soundkonverter/format_infos/" + language + "/'" ); -// directories = stddir.findDirs( "data", "soundkonverter/format_infos/"+language+"/" ); -// if( directories.isEmpty() ) directories = stddir.findDirs( "data", "soundkonverter/format_infos/en/" ); - directories = stddir.findDirs( "data", "soundkonverter/format_infos/" ); - for( TQStringList::Iterator a = directories.begin(); a != directories.end(); ++a ) - { - //kdDebug() << " searching directory: `" << *a << "'" << endl; - logger->log( 1000, " searching directory: `" + *a + "'" ); - dir.setPath( *a ); - list = dir.entryList( "*", TQDir::All, TQDir::Name ); - for( TQStringList::Iterator b = list.begin(); b != list.end(); ++b ) - { - if( *b != "." && *b != ".." && (*b).right(4) == ".xml" ) - { - //kdDebug() << " found file: `" << *b << "'" << endl; - logger->log( 1000, " found file: `" + *b + "'" ); - if( formatInfoLoader->verifyFile( TQString(*a).append(*b) ) ) - { - FormatInfo* formatInfo = formatInfoLoader->loadFile( TQString(*a).append(*b) ); - - for( TQValueList::Iterator c = formats.begin(); c != formats.end(); ++c ) { - for( TQStringList::Iterator d = formatInfo->mime_types.begin(); d != formatInfo->mime_types.end(); ++d ) { - if( (*c).mime_types.findIndex(*d) != -1 ) { - (*c).description = "

" + formatInfo->description + "

"; - (*c).description.replace("\\n","

\n

"); - for( TQStringList::Iterator d = formatInfo->urls.begin(); d != formatInfo->urls.end(); ++d ) { - (*c).description += "\n

" + (*d) + "

"; - } - (*c).compressionType = formatInfo->compressionType; - (*c).size = formatInfo->size; - // add extensions for mime types - logger->log( 1000, " found mime type: `" + *d + "'" ); - TQStringList extensions = KMimeType::mimeType( *d )->patterns(); - for( TQStringList::Iterator c = extensions.begin(); c != extensions.end(); ++c ) { - (*c).remove( 0, 2 ); - logger->log( 1000, " adding extension: `" + *c + "'" ); - } - (*c).extensions += extensions; - // add extensions (from format file) HACK - extensions = formatInfo->extensions; - if( !extensions.isEmpty() ) { - logger->log( 1000, " found extensions..." ); - for( TQStringList::Iterator c = extensions.begin(); c != extensions.end(); ++c ) { - logger->log( 1000, " adding extension: `" + *c + "'" ); - } - (*c).extensions += extensions; - } - // add extensions for correction file mime types - for( TQStringList::Iterator d = (*c).correction_file_mime_types.begin(); d != (*c).correction_file_mime_types.end(); ++d ) { - logger->log( 1000, " found correction mime type: `" + *d + "'" ); - TQStringList extensions = KMimeType::mimeType( *d )->patterns(); - for( TQStringList::Iterator e = extensions.begin(); e != extensions.end(); ++e ) { - (*e).remove( 0, 2 ); - logger->log( 1000, " adding correction extension: `" + *e + "'" ); - (*c).correction_file_extensions += (*e); - } - } - } - } - } - } - } - } - } - - delete formatInfoLoader; -} - -void Config::registerFormatFeatures( const TQString &mime_type, - ConvertPlugin* encoder, ConvertPlugin* decoder, - ReplayGainPlugin* replaygain/*, RepairPlugin* repairer*/, - const TQString &correction_file_mime_type ) -{ - //kdDebug() << " entering: `" << "Config::registerFormatFeatures( ... )" << "'" << endl; - logger->log( 1000, " entering: `Config::registerFormatFeatures( ... )'" ); - - // iterate through all file formats and search for an existing one - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - if( (*it).mime_types.findIndex(mime_type) != -1 ) { // we found an existing entry for our file format - //kdDebug() << " found an existing entry: `" << mime_type << "'" << endl; - logger->log( 1000, " found an existing entry: `" + mime_type + "'" ); - - if( encoder != 0 ) (*it).encoders.append( encoder ); -// if( (*it).encoder == 0 && encoder != 0 ) (*it).encoder = encoder; -// if( (*it).encoder != 0 && binaries[(*it).encoder.enc.bin] == "" ) - if( decoder != 0 ) (*it).decoders.append( decoder ); -// if( (*it).decoder == 0 && decoder != 0 ) (*it).decoder = decoder; - if( replaygain != 0 ) (*it).replaygains.append( replaygain ); -// if( (*it).replaygain == 0 && replaygain != 0 ) (*it).replaygain = replaygain; - //if( repairer ) (*it).repairer.append( repairer );*/ - if( !correction_file_mime_type.isEmpty() ) (*it).correction_file_mime_types.append( correction_file_mime_type ); - - // everything done, we can return! - return; - } - } - //kdDebug() << " creating a new entry: `" << mime_type << "'" << endl; - logger->log( 1000, " creating a new entry: `" + mime_type + "'" ); - - // well it seems, we haven't found an entry. create a new! - TQValueList::Iterator newItem = formats.append( FormatItem() ); - (*newItem).mime_types = mime_type; - if( encoder != 0 ) (*newItem).encoders.append( encoder ); -// if( encoder != 0 ) (*newItem).encoder = encoder; - if( decoder != 0 ) (*newItem).decoders.append( decoder ); -// if( decoder != 0 ) (*newItem).decoder = decoder; - if( replaygain != 0 ) (*newItem).replaygains.append( replaygain ); -// if( replaygain != 0 ) (*newItem).replaygain = replaygain; - //if( repairer ) (*newItem).repairer.append( repairer ); - if( !correction_file_mime_type.isEmpty() ) (*newItem).correction_file_mime_types.append( correction_file_mime_type ); - -} - -/*void Config::registerFileFormat( const TQString &mime_type, const TQString &option, const TQString &value ) -{ - // iterate through all file formats and search for an existing one - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - if( (*it).mime_types.findIndex(mime_type) != -1 ) { // we found an existing entry for our file format - if( option == "mime_type" ) (*it).mime_types.append( value ); - //else if( option == "description" ) // TODO implement a qmap ?! - else if( option == "size" ) (*it).size = value.toInt(); - else if( option == "compression_type" ) { - if( value == "lossy" ) (*it).compressionType = FormatInfo::lossy; - else if( value == "lossless" ) (*it).compressionType = FormatInfo::lossless; - else (*it).compressionType = FormatInfo::hybrid; - } - - // everything done, we can return! - return; - } - } - - // well it seems, we haven't found an entry. create a new! - TQValueList::Iterator newItem = formats.append( FormatItem() ); - if( option == "mime_type" ) (*newItem).mime_types.append( value ); - //else if( option == "description" ) // TODO implement a qmap ?! - else if( option == "size" ) (*newItem).size = value.toInt(); - else if( option == "compression_type" ) { - if( value == "lossy" ) (*newItem).compressionType = FormatInfo::lossy; - else if( value == "lossless" ) (*newItem).compressionType = FormatInfo::lossless; - else (*newItem).compressionType = FormatInfo::hybrid; - } -}*/ - -ConvertPlugin* Config::encoderForFormat( const TQString &format ) -{ - // iterate through all file formats and search for our format in mime_types and extensions - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it - return (*it).encoder; - } - } - - return 0; -} - -ConvertPlugin* Config::decoderForFormat( const TQString &format ) -{ - // iterate through all file formats and search for our format in mime_types and extensions - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it - return (*it).decoder; - } - } - - return 0; -} - -ReplayGainPlugin* Config::replaygainForFormat( const TQString &format ) -{ - // iterate through all file formats and search for our format in mime_types and extensions - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it - return (*it).replaygain; - } - } - - return 0; -} - -FormatItem* Config::getFormatItem( const TQString &format ) -{ - // iterate through all file formats and search for our format in mime_types and extensions - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it - return &(*it); - } - } - - return 0; -} - -// NOTE speed up the following 3 functions (cache the data) (use the extensions variable in FormatItem) -// NOTE seems to be called too often ??? -TQStringList Config::allFormats() -{ - TQStringList list; - - //kdDebug() << "entering: `" << "Config::allFormats()" << "'" << endl; - logger->log( 1000, "entering: `Config::allFormats()'" ); - - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl; - logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" ); - if( (*it).mime_types.first() != "application/octet-stream" ) { -// TQString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower(); -// extension.remove( 0, 2 ); - TQString extension = (*it).extensions.first().lower(); - //kdDebug() << " extension: `" << extension << "'" << endl; - logger->log( 1000, " extension: `" + extension + "'" ); - if( !extension.isEmpty() && !list.contains(extension) ) { - list.append( extension ); - //kdDebug() << " (added)" << endl; - logger->log( 1000, " (added)" ); - } - } - } - - return list; -} - -TQStringList Config::allEncodableFormats() -{ - TQStringList list; - - //kdDebug() << "entering: `" << "Config::allEncodableFormats()" << "'" << endl; - logger->log( 1000, "entering: `Config::allEncodableFormats()'" ); - - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl; - logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" ); - if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) { - if( !(*it).encoder->enc.lossy.enabled && !(*it).encoder->enc.lossless.enabled && !(*it).encoder->enc.hybrid.enabled ) continue; -// TQString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower(); -// extension.remove( 0, 2 ); - TQString extension = (*it).extensions.first().lower(); - //kdDebug() << " extension: `" << extension << "'" << endl; - logger->log( 1000, " extension: `" + extension + "'" ); - if( !extension.isEmpty() && !list.contains(extension) ) { - list.append( extension ); - //kdDebug() << " (added)" << endl; - logger->log( 1000, " (added)" ); - } - } - } - - return list; -} - -TQStringList Config::allLossyEncodableFormats() -{ - TQStringList list; - - //kdDebug() << "entering: `" << "Config::allLossyEncodableFormats()" << "'" << endl; -// logger->log( 1000, "entering: `Config::allLossyEncodableFormats()'" ); - - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl; -// logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" ); - if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).encoder->enc.lossy.enabled && (*it).compressionType & FormatInfo::lossy && (*it).mime_types.first() != "application/octet-stream" ) { -// TQString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower(); -// extension.remove( 0, 2 ); - TQString extension = (*it).extensions.first().lower(); - //kdDebug() << " extension: `" << extension << "'" << endl; -// logger->log( 1000, " extension: `" + extension + "'" ); - if( !extension.isEmpty() && !list.contains(extension) ) { - list.append( extension ); - //kdDebug() << " (added)" << endl; -// logger->log( 1000, " (added)" ); - } - } - } - - return list; -} - -TQStringList Config::allLosslessEncodableFormats() -{ - TQStringList list; - - //kdDebug() << "entering: `" << "Config::allLosslessEncodableFormats()" << "'" << endl; - logger->log( 1000, "entering: `Config::allLosslessEncodableFormats()'" ); - - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl; - logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" ); - if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).encoder->enc.lossless.enabled && (*it).compressionType & FormatInfo::lossless && (*it).mime_types.first() != "application/octet-stream" ) { -// TQString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower(); -// extension.remove( 0, 2 ); - TQString extension = (*it).extensions.first().lower(); - //kdDebug() << " extension: `" << extension << "'" << endl; - logger->log( 1000, " extension: `" + extension + "'" ); - if( !extension.isEmpty() && !list.contains(extension) ) { - list.append( extension ); - //kdDebug() << " (added)" << endl; - logger->log( 1000, " (added)" ); - } - } - } - - return list; -} - -TQStringList Config::allHybridEncodableFormats() -{ - TQStringList list; - - //kdDebug() << "entering: `" << "Config::allHybridEncodableFormats()" << "'" << endl; - logger->log( 1000, "entering: `Config::allHybridEncodableFormats()'" ); - - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl; - logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" ); - if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).encoder->enc.hybrid.enabled && (*it).compressionType & FormatInfo::hybrid && (*it).mime_types.first() != "application/octet-stream" ) { -// TQString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower(); -// extension.remove( 0, 2 ); - TQString extension = (*it).extensions.first().lower(); - //kdDebug() << " extension: `" << extension << "'" << endl; - logger->log( 1000, " extension: `" + extension + "'" ); - if( !extension.isEmpty() && !list.contains(extension) ) { - list.append( extension ); - //kdDebug() << " (added)" << endl; - logger->log( 1000, " (added)" ); - } - } - } - - return list; -} - -TQString Config::getCorrectionExtension( const TQString &format ) -{ - // iterate through all file formats and search for our format - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it - return (*it).correction_file_extensions.first(); - } - } - - return ""; -} - -TQString Config::getFormatDescription( const TQString &format ) // NOTE could be removed -{ - // iterate through all file formats and search for our format - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it - return (*it).description; - } - } - - return ""; -} - -void Config::addProfile( const TQString &name, const ConversionOptions& profile ) -{ - ProfileData profileData; - profileData.name = name; - profileData.options = profile; - profiles += profileData; - if( name != i18n("Last used") && name != "Last used" ) writeProfiles(); // will only be saved at app exit, when saving everything anyway - emit configChanged(); -} - -void Config::removeProfile( const TQString &name ) -{ - for( TQValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) { - if( (*it).name == name ) { - profiles.remove( it ); - if( name != i18n("Last used") && name != "Last used" ) writeProfiles(); // will only be saved at app exit, when saving everything anyway - return; - } - } - emit configChanged(); -} - -ConversionOptions Config::getProfile( const TQString &name ) -{ - for( TQValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) { - if( /*(*it).name != i18n("Last used") &&*/ (*it).name == name ) { - return (*it).options; - } - } - - ConversionOptions options; - options.encodingOptions.sFormat = ""; - return options; -} - -TQString Config::getProfileName( const ConversionOptions& options ) -{ - if( options.encodingOptions.sQualityMode == i18n("Lossless") ) { - return i18n("Lossless"); - } - - if( options.encodingOptions.sQualityMode == i18n("Hybrid") ) { - return i18n("Hybrid"); - } - - for( TQValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) { - if( (*it).name != i18n("Last used") && (*it).options.nearlyEqual( options ) ) { - return (*it).name; - } - } - - ConvertPlugin* plugin = encoderForFormat( options.encodingOptions.sFormat ); - if( plugin != 0 ) { - if( plugin->enc.lossy.quality.enabled ) { - if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 20 && - options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 && - options.encodingOptions.channels.bEnabled == true && options.encodingOptions.channels.sChannels == i18n("Mono") && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("Very low"); - } - if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 30 && - options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 && - options.encodingOptions.channels.bEnabled == false && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("Low"); - } - if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 40 && - options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == false && - options.encodingOptions.channels.bEnabled == false && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("Medium"); - } - if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 50 && - options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == false && - options.encodingOptions.channels.bEnabled == false && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("High"); - } - if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 60 && - options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == false && - options.encodingOptions.channels.bEnabled == false && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("Very high"); - } - } - if( plugin->enc.lossy.bitrate.abr.enabled || plugin->enc.lossy.bitrate.cbr.enabled ) { - if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 64 && - options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 && - options.encodingOptions.channels.bEnabled == true && options.encodingOptions.channels.sChannels == i18n("Mono") && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("Very low"); - } - if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 96 && - options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 && - options.encodingOptions.channels.bEnabled == false && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("Low"); - } - if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 192 && - options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == false && - options.encodingOptions.channels.bEnabled == false && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("Medium"); - } - if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 240 && - options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == false && - options.encodingOptions.channels.bEnabled == false && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("High"); - } - if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 320 && - options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == false && - options.encodingOptions.channels.bEnabled == false && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("Very high"); - } - } - /*{ - if( options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 && - options.encodingOptions.channels.bEnabled == true && options.encodingOptions.channels.sChannels == i18n("Mono") && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("Very low"); - } - if( options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 && - options.encodingOptions.channels.bEnabled == false && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("Low"); - } - if( options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == false && - options.encodingOptions.channels.bEnabled == false && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("Medium"); - } - if( options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == false && - options.encodingOptions.channels.bEnabled == false && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("High"); - } - if( options.encodingOptions.bBitrateRange == false && - options.encodingOptions.samplingRate.bEnabled == false && - options.encodingOptions.channels.bEnabled == false && - options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { - return i18n("Very high"); - } - }*/ - } - return i18n("User defined"); -} - -TQStringList Config::getAllProfiles() -{ - TQStringList list; - - for( TQValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) { - /*if( (*it).name != i18n("Last used") )*/ list += (*it).name; - } - - return list; -} - -bool Config::acceptFile( const TQString& format ) -{ - if( format == "audio/x-wav" || format == "wav" ) return true; - - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it - if( (*it).decoder != 0 ) return true; - } - } - - return false; -} - -bool Config::acceptReplayGainFile( const TQString& format ) -{ - for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { - if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it - if( (*it).replaygain != 0 ) return true; - } - } - - return false; -} - -TQString Config::fileFilter( bool wav ) -{ - TQString filter1; - if( wav ) filter1 += "*.wav *.WAV *.Wav"; - TQString filter2; - if( wav ) filter2 += "\n*.wav *.WAV *.Wav|wav " + i18n("files") + " (*.wav)"; - TQString temp; - - for( TQValueList::Iterator a = formats.begin(); a != formats.end(); ++a ) { - if( (*a).decoder != 0 ) { - temp = ""; - for( TQStringList::Iterator b = (*a).extensions.begin(); b != (*a).extensions.end(); ++b ) { - filter1 += " *." + (*b); - if( !temp.contains(*b,false) ) temp += " *." + (*b).lower(); - } - //temp.stripWhiteSpace(); // NOTE doesn't work - if( temp != "" && temp.length() < 80 ) { - temp.remove( 0, 1 ); - temp = "\n" + temp + "|" + (*a).extensions.first() + " " + i18n("files") + " (" + temp + ")"; - if( !filter2.contains(temp) ) { // HACK when unsing multiple mime types, there were too much entries - filter2 += temp; - } - } - else if( temp != "" ) { - temp.remove( 0, 1 ); - temp = "\n" + temp + "|" + (*a).extensions.first() + " " + i18n("files"); - if( !filter2.contains(temp) ) { // HACK when unsing multiple mime types, there were too much entries - filter2 += temp; - } - } - } - } - - filter1.stripWhiteSpace(); - filter2.stripWhiteSpace(); - - return filter1 + "|" + i18n("all supported formats") + "\n*.*|" + i18n("all formats") + filter2; -} - -TQStringList Config::fileTypes( bool wav ) -{ - TQStringList types; - if( wav ) types.append( "wav" ); - TQString temp; - - for( TQValueList::Iterator a = formats.begin(); a != formats.end(); ++a ) { - if( (*a).decoder != 0 ) { - temp = ""; - for( TQStringList::Iterator b = (*a).extensions.begin(); b != (*a).extensions.end(); ++b ) { - if( !temp.contains(*b,false) ) temp.append( (*b).lower() + ", " ); - } - if( temp != "" ) { - temp = temp.left( temp.length() - 2 ); - if( types.findIndex(temp) == -1 ) types.append( temp ); - } - } - } - - return types; -} - -TQString Config::replayGainFilter() -{ - TQString filter1; - TQString filter2; - TQString temp; - - for( TQValueList::Iterator a = formats.begin(); a != formats.end(); ++a ) { - if( (*a).replaygain != 0 ) { - temp = ""; - for( TQStringList::Iterator b = (*a).extensions.begin(); b != (*a).extensions.end(); ++b ) { - filter1 += " *." + (*b); - if( !temp.contains(*b,false) ) temp += " *." + (*b).lower(); - } - //temp.stripWhiteSpace(); // NOTE doesn't work - if( temp != "" && temp.length() < 80 ) { - temp.remove( 0, 1 ); - filter2 += "\n" + temp + "|" + (*a).extensions.first() + " " + i18n("files") + " (" + temp + ")"; - } - else if( temp != "" ) { - temp.remove( 0, 1 ); - filter2 += "\n" + temp + "|" + (*a).extensions.first() + " " + i18n("files"); - } - } - } - - filter1.stripWhiteSpace(); - filter2.stripWhiteSpace(); - - return filter1 + "|" + i18n("all supported formats") + "\n*.*|" + i18n("all formats") + filter2; -} - -TQStringList Config::replayGainFileTypes() -{ - TQStringList types; - TQString temp; - - for( TQValueList::Iterator a = formats.begin(); a != formats.end(); ++a ) { - if( (*a).replaygain != 0 ) { - temp = ""; - for( TQStringList::Iterator b = (*a).extensions.begin(); b != (*a).extensions.end(); ++b ) { - if( !temp.contains(*b,false) ) temp.append( (*b).lower() + ", " ); - } - if( temp != "" ) { - temp = temp.left( temp.length() - 2 ); - if( types.findIndex(temp) == -1 ) types.append( temp ); - } - } - } - - return types; -} - - diff --git a/src/config.h b/src/config.h deleted file mode 100644 index c6488c1..0000000 --- a/src/config.h +++ /dev/null @@ -1,355 +0,0 @@ - - -#ifndef CONFIG_H -#define CONFIG_H - -#include "formatinfoloader.h" -#include "conversionoptions.h" - -#include -#include -#include -#include - -class Logger; -class ConvertPlugin; -//class ConvertPluginLoader; -class ReplayGainPlugin; -//class ReplayGainPluginLoader; -class RipperPlugin; -struct ProfileData; - - -/** - * @short Format items for the format list - * @author Daniel Faust - * @version 0.3 - */ -class FormatItem -{ -public: - /** - * Constructor - */ - FormatItem(); - - /** - * Destructor - */ - virtual ~FormatItem(); - - TQStringList mime_types; - TQStringList extensions; // for easy use - TQStringList correction_file_mime_types; - TQStringList correction_file_extensions; // for easy use - TQString description; - FormatInfo::CompressionType compressionType; - int compressionLevel; // the value from the config dialog - bool internalReplayGain; - int size; - TQValueList encoders; - TQValueList decoders; - TQValueList replaygains; - //TQValueList repairers; - ConvertPlugin* encoder; - ConvertPlugin* decoder; - ReplayGainPlugin* replaygain; - //RepairerPlugin* repairer; -}; - - -/** - * @short Configuration class - * @author Daniel Faust - * @version 0.3 - */ -class Config : public TQObject -{ - TQ_OBJECT - -public: - /** - * Constructor - */ - Config( Logger* ); - - /** - * Destructor - */ - virtual ~Config(); - - /** - * Read the preferences from the configuration file - */ - void read(); - - /** - * Write the preferences to the configuration file - */ - void write( bool sync = true ); - - /** - * Read the profiles from the profiles file - */ - void readProfiles(); - - /** - * Write the profiles to the profiles file - */ - void writeProfiles(); - - /** - * Get the encoder for a given file format (mime type or extension) - */ - ConvertPlugin* encoderForFormat( const TQString &format ); - - /** - * Get the decoder for a given file format (mime type or extension) - */ - ConvertPlugin* decoderForFormat( const TQString &format ); - - /** - * Get the decoder for a given file format (mime type or extension) - */ - ReplayGainPlugin* replaygainForFormat( const TQString &format ); - - /** - * Get the format information for a given file format (mime type or extension) - */ - FormatItem* getFormatItem( const TQString &format ); - - /** - * Get the current ripper - */ - RipperPlugin* getCurrentRipper() { return currentRipper; } - - /** - * Set the current ripper - */ - void setCurrentRipper( RipperPlugin* ripper ) { currentRipper = ripper; } - - /** - * Returns a list of all loaded rippers - */ - TQValueList allRippers() { return rippers; } - - /** - * Returns a list of all loaded converters - */ - TQValueList allConverters() { return converters; } - - /** - * Returns a list of all loaded replaygains - */ - TQValueList allReplayGains() { return replaygains; } - - /** - * Returns a list of all known file formats - */ - TQStringList allFormats(); - - /** - * Returns a list of all known encodeable file formats - */ - TQStringList allEncodableFormats(); - - /** - * Returns a list of all known lossy encodeable file formats - */ - TQStringList allLossyEncodableFormats(); - - /** - * Returns a list of all known lossless encodeable file formats - */ - TQStringList allLosslessEncodableFormats(); - - /** - * Returns a list of all known hybrid encodeable file formats - */ - TQStringList allHybridEncodableFormats(); - - /** - * Returns the extension of the correction file format for the given format - * If there is nor correction file format, the returned string is empty - */ - TQString getCorrectionExtension( const TQString &format ); - - /** - * Returns a localized description for the given format - */ - TQString getFormatDescription( const TQString &format ); - - /** - * Add a new profile - */ - void addProfile( const TQString &name, const ConversionOptions& profile ); - - /** - * Remove a new profile - */ - void removeProfile( const TQString &name ); - - /** - * Returns the conversion options for a profile - */ - ConversionOptions getProfile( const TQString &name ); - - /** - * Returns the name of the profile with conversion options @p options - */ - TQString getProfileName( const ConversionOptions& options ); - - /** - * Returns a list of all user defined profiles - */ - TQStringList getAllProfiles(); - - /** - * Returns true if the @p file can be added to the conversion list (can be decoded) - */ - bool acceptFile( const TQString& format ); - - /** - * Returns true if the @p file can be added to the replay gain tool - */ - bool acceptReplayGainFile( const TQString& format ); - - /** - * Returns a file filter suitable for the file open dialog - */ - TQString fileFilter( bool wav = true ); - - /** - * Returns a string list of supported file formats - */ - TQStringList fileTypes( bool wav = true ); - - /** - * Returns a file filter suitable for the file open dialog for the replay gain scanner - */ - TQString replayGainFilter(); - - /** - * Returns a string list of Replay Gain supported file formats - */ - TQStringList replayGainFileTypes(); - - struct Data { - struct General { - int startTab; - int lastTab; - TQString defaultProfile; - TQString defaultFormat; -// TQString defaultOutputDirectory; - TQString specifyOutputDirectory; - TQString metaDataOutputDirectory; - TQString copyStructureOutputDirectory; - int priority; - bool useVFATNames; - int conflictHandling; - int numFiles; - int updateDelay; - bool askForNewOptions; - bool executeUserScript; - bool showToolBar; - } general; - struct Plugins { - bool checkForUpdates; - } plugins; - struct Environment { - TQStringList directories; - TQStringList foundPrograms; - } environment; - struct App { - int configVersion; - } app; - } data; - - bool onlinePluginsChanged; - bool backendsChanged; - - TQMap binaries; - -private: - struct PluginMapData { - int version; - TQString filename; - TQString type; - }; - - Logger* logger; - - /** holds all known formats */ - TQValueList formats; - - /** holds all known rippers */ - TQValueList rippers; - RipperPlugin* currentRipper; - - /** holds all known converters */ - TQValueList converters; - /** holds all known replaygain apps */ - TQValueList replaygains; - /* holds all known file repairing apps */ -// TQValueList repairer; - - //ConvertPluginLoader* convertPluginLoader; - //ReplayGainPluginLoader* replaygainPluginLoader; - - /** holds all user defined profiles */ - TQValueList profiles; - - /** - * Load the files with the file infos (format descriptions, file size, etc.) - */ - void loadFileInfos(); - - /** - * Load all plugins that can be found - */ - void loadPlugins(); - - /** - * A plugin wants to register it's features for a file format - * @p binary The binary name of the app that wants to register it's features - * @p extension The file name extension for that is wants to register - * @p features The features of the app for that extension - */ - void registerFormatFeatures( const TQString &mime_type, - ConvertPlugin* encoder = 0, ConvertPlugin* decoder = 0, - ReplayGainPlugin* replaygain = 0/*, RepairPlugin* repairer = 0*/, - const TQString &correction_file_mime_type = TQString() ); - - /** - * Generate the service menu - */ - void writeServiceMenu(); - - /** - * Copy the amarok script - */ - void writeAmarokScript(); - - /* - * We have new inforamtion for a file format - * @p extension The file name extension for that is wants to register - * @p newSynonym Register a new synonym for this file format? - * @p newMimeType Register a new mime type for this file format? - * @p newDescription Register a new description for this file format? - * @p newSize Register a new size for this file format for calculating the progress? - */ - /*void registerFileFormat( const TQString &extension, const TQString &newSynonym = TQString(), - const TQString &newMimeType = TQString(), - const TQString &newDescription = TQString(), - int newSize = 0, FormatInfo::CompressionType newCompressionType = FormatInfo::lossy );*/ - //void registerFileFormat( const TQString &mime_type, const TQString &option, const TQString &value ); - // NOTE this function is obsolete. - // after loading all plugins and creating all neccessary file format items, - // sk will search for format info files and update the items. - -signals: - void configChanged(); - -}; - -#endif // CONFIG_H diff --git a/src/configbackendspage.cpp b/src/configbackendspage.cpp index da10d49..eba1999 100644 --- a/src/configbackendspage.cpp +++ b/src/configbackendspage.cpp @@ -3,7 +3,7 @@ #include "convertpluginloader.h" #include "replaygainpluginloader.h" #include "ripperpluginloader.h" -#include "config.h" +#include "configuration.h" #include #include diff --git a/src/configdialog.cpp b/src/configdialog.cpp index 1bc0efb..5152a9c 100644 --- a/src/configdialog.cpp +++ b/src/configdialog.cpp @@ -2,7 +2,7 @@ #include "configdialog.h" -#include "config.h" +#include "configuration.h" #include "configgeneralpage.h" #include "configpluginspage.h" #include "configenvironmentpage.h" diff --git a/src/configenvironmentpage.cpp b/src/configenvironmentpage.cpp index 3d5caf6..263f2de 100644 --- a/src/configenvironmentpage.cpp +++ b/src/configenvironmentpage.cpp @@ -1,7 +1,7 @@ #include "configenvironmentpage.h" -#include "config.h" +#include "configuration.h" #include #include diff --git a/src/configgeneralpage.cpp b/src/configgeneralpage.cpp index bef1162..1da343b 100644 --- a/src/configgeneralpage.cpp +++ b/src/configgeneralpage.cpp @@ -1,7 +1,7 @@ #include "configgeneralpage.h" -#include "config.h" +#include "configuration.h" #include #include diff --git a/src/configpluginspage.cpp b/src/configpluginspage.cpp index 0215ea7..3c9ead4 100644 --- a/src/configpluginspage.cpp +++ b/src/configpluginspage.cpp @@ -1,6 +1,6 @@ #include "configpluginspage.h" -#include "config.h" +#include "configuration.h" #include "convertpluginloader.h" #include "replaygainpluginloader.h" #include "ripperpluginloader.h" diff --git a/src/configuration.cpp b/src/configuration.cpp new file mode 100644 index 0000000..8ca153d --- /dev/null +++ b/src/configuration.cpp @@ -0,0 +1,1516 @@ + +#include "configuration.h" +#include "logger.h" +#include "convertpluginloader.h" +#include "replaygainpluginloader.h" +#include "ripperpluginloader.h" +#include "options.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +// NOTE currently only the possibilities of a file format are respected, +// the possibilities of the current encoder are ignored +// - seems to be fixed + +FormatItem::FormatItem() +{ + // reset everything + mime_types.clear(); + size = 0; + compressionType = FormatInfo::lossy; + compressionLevel = 0; + internalReplayGain = false; + encoders.clear(); + decoders.clear(); + replaygains.clear(); + //repairers.clear(); + encoder = 0; + decoder = 0; + replaygain = 0; + //repairer = 0; +} + +FormatItem::~FormatItem() +{} + + +Config::Config( Logger* _logger ) +{ + logger = _logger; + + currentRipper = 0; // this seems to be unnecessary +} + +Config::~Config() +{} + +void Config::read() +{ + loadPlugins(); + readProfiles(); + + TDEConfig *conf = kapp->config(); + TQStringList listDefaults; + int intDefault; + bool boolDefault; + TQString ripper; + TQString encoder; + TQString decoder; + TQString replaygain; + int rank; + + conf->setGroup( "General" ) ; + data.app.configVersion = conf->readNumEntry( "configVersion", 0 ); + +/* if( configVersion == 0 ) { + conf->setGroup( "Interface" ); + data.general.updateDelay = conf->readNumEntry( "pauseMS", 500 ); + data.general.startTab = conf->readNumEntry( "startTab", 0 ); + data.general.showToolBar = conf->readBoolEntry( "showToolBar", false ); + + conf->setGroup( "Backends" ); + listDefaults.clear(); + TQString datadir = locateLocal( "data", "soundkonverter/bin/" ); + datadir.remove( datadir.length() - 1, 1 ); + listDefaults.append( datadir ); + listDefaults.append( TQDir::homeDirPath() + "/bin" ); + listDefaults.append( "/usr/local/bin" ); + listDefaults.append( "/usr/bin" ); + data.environment.directories = conf->readListEntry( "directories", listDefaults ); + listDefaults.clear(); + data.environment.foundPrograms = conf->readListEntry( "programs", listDefaults ); + + conf->setGroup( "Misc" ); + //configVersion = conf->readNumEntry( "configVersion", 0 ); + data.general.askForNewOptions = conf->readBoolEntry( "askForNewOptions", true ); + + return; + }*/ + + conf->setGroup( "General" ) ; + //configVersion = conf->readNumEntry( "configVersion", 0 ); + data.general.startTab = conf->readNumEntry( "startTab", 0 ); + data.general.lastTab = conf->readNumEntry( "lastTab", 0 ); + data.general.defaultProfile = conf->readEntry( "defaultProfile", i18n("Last used") ); + data.general.defaultFormat = conf->readEntry( "defaultFormat", i18n("Last used") ); +// data.general.defaultOutputDirectory = conf->readEntry( "defaultOutputDirectory", TQDir::homeDirPath() + "/soundKonverter/%b/%d - %n - %a - %t" ); + data.general.specifyOutputDirectory = conf->readEntry( "specifyOutputDirectory", TQDir::homeDirPath() + "/soundKonverter" ); + data.general.metaDataOutputDirectory = conf->readEntry( "metaDataOutputDirectory", TQDir::homeDirPath() + "/soundKonverter/%b/%d - %n - %a - %t" ); + data.general.copyStructureOutputDirectory = conf->readEntry( "copyStructureOutputDirectory", TQDir::homeDirPath() + "/soundKonverter" ); + data.general.useVFATNames = conf->readBoolEntry( "useVFATNames", true ); + data.general.conflictHandling = conf->readNumEntry( "conflictHandling", 0 ); + data.general.priority = conf->readNumEntry( "priority", 10 ); + data.general.numFiles = conf->readNumEntry( "numFiles", 3 ); + data.general.updateDelay = conf->readNumEntry( "updateDelay", 500 ); + data.general.askForNewOptions = conf->readBoolEntry( "askForNewOptions", true ); + data.general.executeUserScript = conf->readBoolEntry( "executeUserScript", false ); + data.general.showToolBar = conf->readBoolEntry( "showToolBar", false ); + + conf->setGroup( "Plugins" ); + data.plugins.checkForUpdates = conf->readBoolEntry( "checkForUpdates", false ); + + conf->setGroup( "Environment" ); + listDefaults.clear(); + TQString datadir = locateLocal( "data", "soundkonverter/bin/" ); + datadir.remove( datadir.length() - 1, 1 ); + listDefaults.append( datadir ); + listDefaults.append( TQDir::homeDirPath() + "/bin" ); + listDefaults.append( "/usr/local/bin" ); + listDefaults.append( "/usr/bin" ); + data.environment.directories = conf->readListEntry( "directories", listDefaults ); + listDefaults.clear(); + data.environment.foundPrograms = conf->readListEntry( "foundPrograms", listDefaults ); + + conf->setGroup( "Ripper" ); + ripper = conf->readEntry( "ripper", "tdeio_audiocd" ); + + if( ripper == "tdeio_audiocd" ) rank = 10000; + else rank = 60; // tdeio_audiocd ranking + currentRipper = 0; // this is a valid ripper (tdeio_audiocd) + for( TQValueList::Iterator b = rippers.begin(); b != rippers.end(); ++b ) { + binaries[ (*b)->rip.bin ] = ""; + if( (*b)->rip.rank > rank ) { + rank = (*b)->rip.rank; + currentRipper = (*b); + } + if( (*b)->rip.bin == ripper ) { + rank = 10000; // should be high enough to overbid the other plugins + currentRipper = (*b); + } + } + + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) + { + for( TQValueList::Iterator b = (*it).encoders.begin(); b != (*it).encoders.end(); ++b ) { + binaries[ (*b)->enc.bin ] = ""; + } + + for( TQValueList::Iterator b = (*it).decoders.begin(); b != (*it).decoders.end(); ++b ) { + binaries[ (*b)->dec.bin ] = ""; + } + + for( TQValueList::Iterator b = (*it).replaygains.begin(); b != (*it).replaygains.end(); ++b ) { + binaries[ (*b)->replaygain.bin ] = ""; + } + + for( TQMap::Iterator b = binaries.begin(); b != binaries.end(); ++b ) { + for( TQStringList::Iterator c = data.environment.directories.begin(); c != data.environment.directories.end(); ++c ) + { + if( b.data() == "" && TQFile::exists((*c) + "/" + b.key()) ) { + b.data() = (*c) + "/" + b.key(); + } + } + } + TQStringList foundPrograms; + for( TQMap::Iterator b = binaries.begin(); b != binaries.end(); ++b ) { + if( b.data() != "" ) { + foundPrograms.append( b.data() ); + } + } + if( foundPrograms != data.environment.foundPrograms ) { + backendsChanged = true; + } + else { + backendsChanged = false; + } + } + + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) + { + conf->setGroup( (*it).mime_types.first() ); + encoder = conf->readEntry( "encoder" ); + decoder = conf->readEntry( "decoder" ); + replaygain = conf->readEntry( "replaygain" ); + + (*it).encoder = 0; + (*it).decoder = 0; + (*it).replaygain = 0; + + rank = 0; + for( TQValueList::Iterator b = (*it).encoders.begin(); b != (*it).encoders.end(); ++b ) { + if( (*b)->enc.rank > rank && binaries[(*b)->enc.bin] != "" ) { + rank = (*b)->enc.rank; + (*it).encoder = (*b); + } + if( (*b)->enc.bin == encoder && binaries[(*b)->enc.bin] != "" ) { + rank = 10000; // should be high enougth to overbid the other plugins + (*it).encoder = (*b); + } + } + + rank = 0; + for( TQValueList::Iterator b = (*it).decoders.begin(); b != (*it).decoders.end(); ++b ) { + if( (*b)->dec.rank > rank && binaries[(*b)->dec.bin] != "" ) { + rank = (*b)->dec.rank; + (*it).decoder = (*b); + } + if( (*b)->dec.bin == decoder && binaries[(*b)->dec.bin] != "" ) { + rank = 10000; // should be high enougth to overbid the other plugins + (*it).decoder = (*b); + } + } + + rank = 0; + for( TQValueList::Iterator b = (*it).replaygains.begin(); b != (*it).replaygains.end(); ++b ) { + if( (*b)->replaygain.rank > rank && binaries[(*b)->replaygain.bin] != "" ) { + rank = (*b)->replaygain.rank; + (*it).replaygain = (*b); + } + if( (*b)->replaygain.bin == replaygain && binaries[(*b)->replaygain.bin] != "" ) { + rank = 10000; // should be high enougth to overbid the other plugins + (*it).replaygain = (*b); + } + } + + if( (*it).encoder != 0 && (*it).encoder->enc.strength.enabled ) { + if( (*it).encoder->enc.strength.range_max >= (*it).encoder->enc.strength.range_min ) + intDefault = (*it).encoder->enc.strength.default_value / (*it).encoder->enc.strength.step; + else + intDefault = ( (*it).encoder->enc.strength.range_min - (*it).encoder->enc.strength.default_value ) / (*it).encoder->enc.strength.step; + } + else { + intDefault = 0; + } + (*it).compressionLevel = conf->readNumEntry( "compressionLevel", intDefault ); + + if( (*it).encoder != 0 && (*it).encoder->enc.replaygain.enabled ) { + if( (*it).replaygain != 0 && (*it).replaygain->replaygain.rank > (*it).encoder->enc.replaygain.rank ) { + boolDefault = false; + } + else { + boolDefault = true; + } + } + else { + boolDefault = false; + } + (*it).internalReplayGain = conf->readBoolEntry( "internalReplayGain", boolDefault ); + } +} + +void Config::write( bool sync ) +{ + TQTime time; + time.start(); + + writeProfiles(); + writeServiceMenu(); + writeAmarokScript(); + + TDEConfig *conf = kapp->config(); + + conf->setGroup( "Ripper" ); + conf->writeEntry( "ripper", (currentRipper)?currentRipper->rip.bin:"tdeio_audiocd" ); + + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) + { + conf->setGroup( (*it).mime_types.first() ); + if( (*it).encoder ) conf->writeEntry( "encoder", (*it).encoder->enc.bin ); + if( (*it).decoder ) conf->writeEntry( "decoder", (*it).decoder->dec.bin ); + if( (*it).replaygain ) conf->writeEntry( "replaygain", (*it).replaygain->replaygain.bin ); + conf->writeEntry( "compressionLevel", (*it).compressionLevel ); + conf->writeEntry( "internalReplayGain", (*it).internalReplayGain ); + } + + conf->setGroup( "General" ) ; + conf->writeEntry( "configVersion", 300 ); + conf->writeEntry( "startTab", data.general.startTab ); + conf->writeEntry( "lastTab", data.general.lastTab ); + conf->writeEntry( "defaultProfile", data.general.defaultProfile ); + conf->writeEntry( "defaultFormat", data.general.defaultFormat ); +// conf->writeEntry( "defaultOutputDirectory", data.general.defaultOutputDirectory ); + conf->writeEntry( "specifyOutputDirectory", data.general.specifyOutputDirectory ); + conf->writeEntry( "metaDataOutputDirectory", data.general.metaDataOutputDirectory ); + conf->writeEntry( "copyStructureOutputDirectory", data.general.copyStructureOutputDirectory ); + conf->writeEntry( "useVFATNames", data.general.useVFATNames ); + conf->writeEntry( "conflictHandling", data.general.conflictHandling ); + conf->writeEntry( "priority", data.general.priority ); + conf->writeEntry( "numFiles", data.general.numFiles ); + conf->writeEntry( "updateDelay", data.general.updateDelay ); + conf->writeEntry( "askForNewOptions", data.general.askForNewOptions ); + conf->writeEntry( "executeUserScript", data.general.executeUserScript ); + conf->writeEntry( "showToolBar", data.general.showToolBar ); + + conf->setGroup( "Plugins" ); + conf->writeEntry( "checkForUpdates", data.plugins.checkForUpdates ); + + conf->setGroup( "Environment" ); + conf->writeEntry( "directories", data.environment.directories ); + data.environment.foundPrograms.clear(); + for( TQMap::Iterator b = binaries.begin(); b != binaries.end(); ++b ) { + if( b.data() != "" ) { + data.environment.foundPrograms.append( b.data() ); + } + } + conf->writeEntry( "foundPrograms", data.environment.foundPrograms ); + + if( sync ) conf->sync(); + + emit configChanged(); + + logger->log( 1000, "wrote preferences: " + TQString::number(time.elapsed()) ); +} + +void Config::readProfiles() +{ + int version; + TQString name; + ConversionOptions options; + + TQDomDocument domTree; + TQFile opmlFile( locateLocal("data","soundkonverter/profiles.xml") ); + if( !opmlFile.open( IO_ReadOnly ) ) return; + if( !domTree.setContent( &opmlFile ) ) return; + opmlFile.close(); + + TQDomElement root = domTree.documentElement(); + if( root.attribute("type") != "profiles" ) return; + TQDomNode node, sub1Node, sub2Node; + node = root.firstChild(); + + while( !node.isNull() ) { + if( node.isElement() && node.nodeName() == "info" ) { + + version = node.toElement().attribute("version").toInt(); + + } + else if( node.isElement() && node.nodeName() == "profile" ) { + + name = node.toElement().attribute("name"); + + sub1Node = node.toElement().firstChild(); + while( !sub1Node.isNull() ) { + if( sub1Node.isElement() && sub1Node.nodeName() == "encodingOptions" ) { +// TODO clean up + options.encodingOptions.sFormat = sub1Node.toElement().attribute("sFormat"); + options.encodingOptions.sQualityMode = sub1Node.toElement().attribute("sQualityMode"); + options.encodingOptions.iQuality = sub1Node.toElement().attribute("iQuality").toInt(); + options.encodingOptions.sBitrateMode = sub1Node.toElement().attribute("sBitrateMode"); + options.encodingOptions.bBitrateRange = sub1Node.toElement().attribute("bBitrateRange").toInt(); + options.encodingOptions.iMinBitrate = sub1Node.toElement().attribute("iMinBitrate").toInt(); + options.encodingOptions.iMaxBitrate = sub1Node.toElement().attribute("iMaxBitrate").toInt(); + + sub2Node = sub1Node.toElement().firstChild(); + while( !sub2Node.isNull() ) { + if( sub2Node.isElement() && sub2Node.nodeName() == "samplingRate" ) { + + options.encodingOptions.samplingRate.bEnabled = sub2Node.toElement().attribute("bEnabled").toInt(); + options.encodingOptions.samplingRate.iSamplingRate = sub2Node.toElement().attribute("iSamplingRate").toInt(); + + } + else if( sub2Node.isElement() && sub2Node.nodeName() == "channels" ) { + + options.encodingOptions.channels.bEnabled = sub2Node.toElement().attribute("bEnabled").toInt(); + options.encodingOptions.channels.sChannels = sub2Node.toElement().attribute("sChannels"); + + } + else if( sub2Node.isElement() && sub2Node.nodeName() == "replaygain" ) { + + options.encodingOptions.replaygain.bEnabled = sub2Node.toElement().attribute("bEnabled").toInt(); + + } + sub2Node = sub2Node.nextSibling(); + } + + options.encodingOptions.sInOutFiles = sub1Node.toElement().attribute("sInOutFiles"); + + } + else if( sub1Node.isElement() && sub1Node.nodeName() == "outputOptions" ) { + + options.outputOptions.mode = (OutputDirectory::Mode)sub1Node.toElement().attribute("mode").toInt(); + options.outputOptions.directory = sub1Node.toElement().attribute("directory"); + + } + sub1Node = sub1Node.nextSibling(); + } + ProfileData profileData; + profileData.name = name; + profileData.options = options; + profiles += profileData; + } + node = node.nextSibling(); + } +} + +void Config::writeProfiles() +{ + TQDomDocument domTree; + TQDomElement root = domTree.createElement( "soundkonverter" ); + root.setAttribute( "type", "profiles" ); + domTree.appendChild( root ); + + TQDomElement info = domTree.createElement( "info" ); + info.setAttribute( "version", "300" ); + root.appendChild( info ); + + for( TQValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) { + TQDomElement profile = domTree.createElement( "profile" ); + profile.setAttribute( "name", (*it).name ); + + TQDomElement encodingOptions = domTree.createElement( "encodingOptions" ); + + encodingOptions.setAttribute( "sFormat", (*it).options.encodingOptions.sFormat ); + encodingOptions.setAttribute( "sQualityMode", (*it).options.encodingOptions.sQualityMode ); + encodingOptions.setAttribute( "iQuality", (*it).options.encodingOptions.iQuality ); + encodingOptions.setAttribute( "sBitrateMode", (*it).options.encodingOptions.sBitrateMode ); + encodingOptions.setAttribute( "bBitrateRange", (*it).options.encodingOptions.bBitrateRange ); + encodingOptions.setAttribute( "iMinBitrate", (*it).options.encodingOptions.iMinBitrate ); + encodingOptions.setAttribute( "iMaxBitrate", (*it).options.encodingOptions.iMaxBitrate ); + + TQDomElement samplingRate = domTree.createElement( "samplingRate" ); + + samplingRate.setAttribute( "bEnabled", (*it).options.encodingOptions.samplingRate.bEnabled ); + samplingRate.setAttribute( "iSamplingRate", (*it).options.encodingOptions.samplingRate.iSamplingRate ); + + encodingOptions.appendChild( samplingRate ); + + TQDomElement channels = domTree.createElement( "channels" ); + + channels.setAttribute( "bEnabled", (*it).options.encodingOptions.channels.bEnabled ); + channels.setAttribute( "sChannels", (*it).options.encodingOptions.channels.sChannels ); + + encodingOptions.appendChild( channels ); + + TQDomElement replaygain = domTree.createElement( "replaygain" ); + + replaygain.setAttribute( "bEnabled", (*it).options.encodingOptions.replaygain.bEnabled ); + + encodingOptions.appendChild( replaygain ); + + encodingOptions.setAttribute( "sInOutFiles", (*it).options.encodingOptions.sInOutFiles ); + + profile.appendChild( encodingOptions ); + + TQDomElement outputOptions = domTree.createElement( "outputOptions" ); + + outputOptions.setAttribute( "mode", int((*it).options.outputOptions.mode) ); + outputOptions.setAttribute( "directory", (*it).options.outputOptions.directory ); + + profile.appendChild( outputOptions ); + + root.appendChild( profile ); + } + + TQFile opmlFile( locateLocal("data","soundkonverter/profiles.xml") ); + if( !opmlFile.open( IO_WriteOnly ) ) return; + + TQTextStream ts( &opmlFile ); + ts << domTree.toString(); + + opmlFile.close(); +} + +void Config::writeServiceMenu() +{ + int num; + TQString content; + TQFile file; + + num = 0; + content = ""; + content += "[Desktop Entry]\n"; + content += "X-TDE-ServiceTypes="; + + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { +// if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) { +// if( !(*it).encoder->enc.lossy.enabled && !(*it).encoder->enc.lossless.enabled && !(*it).encoder->enc.hybrid.enabled ) continue; +// for( TQStringList::Iterator b = (*it).mime_types.begin(); b != (*it).mime_types.end(); ++b ) { +// content += (*b) + ","; +// num++; +// } +// } + if( (*it).decoder != 0 && binaries[(*it).decoder->dec.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) { + for( TQStringList::Iterator b = (*it).mime_types.begin(); b != (*it).mime_types.end(); ++b ) { + content += (*b) + ","; + num++; + } + } + } + + if( num != 0 ) + { + content += "audio/x-wav"; + + content += "\n"; + content += "Icon=soundkonverter\n"; + content += "Actions=ConvertWithSoundkonverter\n\n"; + + content += "[Desktop Action ConvertWithSoundkonverter]\n"; + content += "Name="+i18n("Convert with soundKonverter ...")+"\n"; + content += "Icon=soundkonverter\n"; + content += "Exec=soundkonverter %F\n"; + + file.setName( locateLocal("data","konqueror/servicemenus/")+"convert_with_soundkonverter.desktop" ); + if ( file.open( IO_WriteOnly ) ) { + TQTextStream stream( &file ); + stream << content; + file.close(); + } + } + + num = 0; + content = ""; + content += "[Desktop Entry]\n"; + content += "ServiceTypes="; + + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + if( (*it).replaygain != 0 && binaries[(*it).replaygain->replaygain.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) { + for( TQStringList::Iterator b = (*it).mime_types.begin(); b != (*it).mime_types.end(); ++b ) { + content += (*b) + ","; + num++; + } + } + } + + if( num != 0 ) + { + content = content.left(content.length()-1); + + content += "\n"; + content += "Icon=soundkonverter_replaygain\n"; + content += "Actions=AddReplayGainWithSoundkonverter\n\n"; + + content += "[Desktop Action AddReplayGainWithSoundkonverter]\n"; + content += "Name="+i18n("Add Replay Gain with soundKonverter ...")+"\n"; + content += "Icon=soundkonverter_replaygain\n"; + content += "Exec=soundkonverter --replaygain %F\n"; + + file.setName( locateLocal("data","konqueror/servicemenus/")+"add_replaygain_with_soundkonverter.desktop" ); + if( file.open(IO_WriteOnly) ) { + TQTextStream st( &file ); + st << content; + file.close(); + } + } +} + +void Config::writeAmarokScript() +{ + int num, num1, num2; + TQString content, content1, content2; + TQFile file; + + num = 0; + content = ""; + content += "name = soundKonverter\n"; + content += "type = transcode\n\n"; + content += "[Transcode]\n"; + content += "target_formats = "; + + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) { + if( !(*it).encoder->enc.lossy.enabled && !(*it).encoder->enc.lossless.enabled && !(*it).encoder->enc.hybrid.enabled ) continue; + for( TQStringList::Iterator b = (*it).extensions.begin(); b != (*it).extensions.end(); ++b ) { + if( content.find(" "+(*b).lower()+" ") == -1 ) content += (*b).lower() + " "; + num++; + } + } + } + + if( num != 0 ) // TODO what is, if there are only decoders? + { + content += "wav"; + content += "\n"; + + file.setName( locateLocal("data","amarok/scripts/soundKonverter/")+"soundKonverter.spec" ); + if( file.open(IO_WriteOnly) ) { + TQTextStream st( &file ); + st << content; + file.close(); + } + } + + num1 = num2 = 0; + content = content1 = content2 = ""; + + // NOTE duplicate entries won't be shown to the user at any time, so they aren't filtered + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) { + if( (*it).encoder->enc.lossless.enabled ) { + for( TQStringList::Iterator b = (*it).extensions.begin(); b != (*it).extensions.end(); ++b ) { + if( content1.find(","+(*b).lower()+",") == -1 ) content1 += (*b).lower() + ","; // NOTE the first entry will be shown twice + num1++; + } + } + if( (*it).encoder->enc.hybrid.enabled ) { + for( TQStringList::Iterator b = (*it).extensions.begin(); b != (*it).extensions.end(); ++b ) { + if( content2.find(","+(*b).lower()+",") == -1 ) content2 += (*b).lower() + ","; // NOTE the first entry will be shown twice + num2++; + } + } + } + } + + if( num1 != 0 ) + { + content1 = content1.left(content1.length()-1); + content += "Lossless"; + content += "\n"; + content += content1; + content += "\n"; + } + + if( num2 != 0 ) + { + content2 = content2.left(content2.length()-1); + content += "Hybrid"; + content += "\n"; + content += content2; + content += "\n"; + } + + if( num1 != 0 || num2 != 0 ) + { + file.setName( locateLocal("data","amarok/scripts/soundKonverter/")+"formats" ); + if( file.open(IO_WriteOnly) ) { + TQTextStream st( &file ); + st << content; + file.close(); + } + } + + TDEStandardDirs* stdDirs = new TDEStandardDirs(); + if( !TQFile::exists(locateLocal("data","amarok/scripts/soundKonverter/soundKonverter.rb")) ) { + TDEIO::NetAccess::file_copy( stdDirs->findResource("data","soundkonverter/amarokscript/soundKonverter.rb"), locateLocal("data","amarok/scripts/soundKonverter/soundKonverter.rb"), 0755, true ); + } + if( !TQFile::exists(locateLocal("data","amarok/scripts/soundKonverter/README")) ) { + TDEIO::NetAccess::file_copy( stdDirs->findResource("data","soundkonverter/amarokscript/README"), locateLocal("data","amarok/scripts/soundKonverter/README"), -1, true ); + } + delete stdDirs; +} + +void Config::loadFileInfos() +{} + +void Config::loadPlugins() +{ + // NOTE can be speeded up + + //kdDebug() << "entering: `" << "Config::loadPlugins()" << "'" << endl; + logger->log( 1000, "entering: `Config::loadPlugins()'" ); + TQStringList list; + TQDir dir; + TQString correction_file_mime_type; + + /** a map that holds the _identifier_ and the _version_ number of all plugins */ + TQMap pluginMap; + + int version; + TQString identifier; + int i; + + ConvertPluginLoader* convertPluginLoader = new ConvertPluginLoader(); + ReplayGainPluginLoader* replaygainPluginLoader = new ReplayGainPluginLoader(); + RipperPluginLoader* ripperPluginLoader = new RipperPluginLoader(); + + TDEStandardDirs stddir; + TQStringList directories = stddir.findDirs( "data", "soundkonverter/plugins/" ); + for( TQStringList::Iterator a = directories.begin(); a != directories.end(); ++a ) + { + //kdDebug() << " searching directory: `" << *a << "'" << endl; + logger->log( 1000, " searching directory: `" + *a + "'" ); + dir.setPath( *a ); + list = dir.entryList( "*", TQDir::All, TQDir::Name ); + for( TQStringList::Iterator b = list.begin(); b != list.end(); ++b ) + { + if( *b != "." && *b != ".." && (*b).right(19) == ".soundkonverter.xml" ) + { + //kdDebug() << " found file: `" << *b << "'" << endl; + logger->log( 1000, " found file: `" + *b + "'" ); + if( convertPluginLoader->verifyFile( TQString(*a).append(*b) ) != -1 ) + { + version = convertPluginLoader->verifyFile( TQString(*a).append(*b) ); + identifier = *b; + identifier.remove( identifier.length() - 19, 19 ); + i = identifier.findRev( "-" ); + identifier.remove( i, identifier.length() - i ); +// i = identifier.find( "." ); +// identifier.remove( 0, i + 1 ); + if( !pluginMap.contains(identifier) ) { + PluginMapData data; + data.version = 0; + pluginMap.insert( identifier, data ); + } + if( pluginMap[identifier].version < version ) + { + pluginMap[identifier].version = version; + pluginMap[identifier].filename = TQString(*a).append(*b); + pluginMap[identifier].type = "converter"; + logger->log( 1000, " updating version for: `" + identifier + "'" ); + } + } + else if( replaygainPluginLoader->verifyFile( TQString(*a).append(*b) ) != -1 ) + { + version = replaygainPluginLoader->verifyFile( TQString(*a).append(*b) ); + identifier = *b; + identifier.remove( identifier.length() - 19, 19 ); + i = identifier.findRev( "-" ); + identifier.remove( i, identifier.length() - i ); +// i = identifier.find( "." ); +// identifier.remove( 0, i + 1 ); + if( !pluginMap.contains(identifier) ) { + PluginMapData data; + data.version = 0; + pluginMap.insert( identifier, data ); + } + if( pluginMap[identifier].version < version ) + { + pluginMap[identifier].version = version; + pluginMap[identifier].filename = TQString(*a).append(*b); + pluginMap[identifier].type = "replaygain"; + logger->log( 1000, " updating version for: `" + identifier + "'" ); + } + } + else if( ripperPluginLoader->verifyFile( TQString(*a).append(*b) ) != -1 ) + { + version = ripperPluginLoader->verifyFile( TQString(*a).append(*b) ); + identifier = *b; + identifier.remove( identifier.length() - 19, 19 ); + i = identifier.findRev( "-" ); + identifier.remove( i, identifier.length() - i ); +// i = identifier.find( "." ); +// identifier.remove( 0, i + 1 ); + if( !pluginMap.contains(identifier) ) { + PluginMapData data; + data.version = 0; + pluginMap.insert( identifier, data ); + } + if( pluginMap[identifier].version < version ) + { + pluginMap[identifier].version = version; + pluginMap[identifier].filename = TQString(*a).append(*b); + pluginMap[identifier].type = "ripper"; + logger->log( 1000, " updating version for: `" + identifier + "'" ); + } + } + else + { + //kdDebug() << " file is invalid: `" << *b << "'" << endl; + logger->log( 1000, " file is invalid: `" + *b + "'" ); + } + } + } + } + + for( TQMap::Iterator a = pluginMap.begin(); a != pluginMap.end(); ++a ) { + if( a.data().type == "converter" ) + { + ConvertPlugin* plugin = convertPluginLoader->loadFile( a.data().filename ); + if( plugin->info.version != -1 ) + { + if( plugin->enc.hybrid.enabled ) + { + correction_file_mime_type = plugin->enc.hybrid.correction_file_mime_type; + } + if( plugin->enc.enabled ) + { + for( TQStringList::Iterator b = plugin->enc.mime_types.begin(); b != plugin->enc.mime_types.end(); ++b ) + { + //kdDebug() << " registering encoder for: `" << *b << "'" << endl; + logger->log( 1000, " registering encoder for: `" + *b + "'" ); + registerFormatFeatures( *b, plugin, 0, 0, correction_file_mime_type ); + } + } + if( plugin->dec.enabled ) + { + for( TQStringList::Iterator b = plugin->dec.mime_types.begin(); b != plugin->dec.mime_types.end(); ++b ) + { + //kdDebug() << " registering decoder for: `" << *b << "'" << endl; + logger->log( 1000, " registering decoder for: `" + *b + "'" ); + registerFormatFeatures( *b, 0, plugin, 0, correction_file_mime_type ); + } + } + converters.append( plugin ); + //kdDebug() << " plugin sucessfully loaded: `" << a.key() << "'" << endl; + logger->log( 1000, " plugin sucessfully loaded: `" + a.key() + "'" ); + } + else + { + //kdError() << " failed to load Plugin: `" << a.key() << "'" << endl; + logger->log( 1000, " failed to load Plugin: `" + a.key() + "'" ); + } + } + else if( a.data().type == "replaygain" ) + { + ReplayGainPlugin* plugin = replaygainPluginLoader->loadFile( a.data().filename ); + if( plugin->info.version != -1 ) + { + for( TQStringList::Iterator b = plugin->replaygain.mime_types.begin(); b != plugin->replaygain.mime_types.end(); ++b ) + { + //kdDebug() << " registering replaygain for: `" << *b << "'" << endl; + logger->log( 1000, " registering replaygain for: `" + *b + "'" ); + registerFormatFeatures( *b, 0, 0, plugin ); + } + replaygains.append( plugin ); + //kdDebug() << " plugin sucessfully loaded: `" << a.key() << "'" << endl; + logger->log( 1000, " plugin sucessfully loaded: `" + a.key() + "'" ); + } + else + { + //kdError() << " failed to load Plugin: `" << a.key() << "'" << endl; + logger->log( 1000, " failed to load Plugin: `" + a.key() + "'" ); + } + } + else if( a.data().type == "ripper" ) + { + RipperPlugin* plugin = ripperPluginLoader->loadFile( a.data().filename ); + if( plugin->info.version != -1 ) + { + rippers.append( plugin ); + //kdDebug() << " plugin sucessfully loaded: `" << a.key() << "'" << endl; + logger->log( 1000, " plugin sucessfully loaded: `" + a.key() + "'" ); + } + else + { + //kdError() << " failed to load Plugin: `" << a.key() << "'" << endl; + logger->log( 1000, " failed to load Plugin: `" + a.key() + "'" ); + } + } + } + + delete convertPluginLoader; + delete replaygainPluginLoader; + delete ripperPluginLoader; + + // NOTE in order to make a plugin working, there must be a format_infos file. + + // TODO remove duplicate extensions + + FormatInfoLoader* formatInfoLoader = new FormatInfoLoader(); + + //kdDebug() << " trying to open: `" << "soundkonverter/format_infos/"+language+"/" << "'" << endl; +// logger->log( 1000, " trying to open: `soundkonverter/format_infos/" + language + "/'" ); +// directories = stddir.findDirs( "data", "soundkonverter/format_infos/"+language+"/" ); +// if( directories.isEmpty() ) directories = stddir.findDirs( "data", "soundkonverter/format_infos/en/" ); + directories = stddir.findDirs( "data", "soundkonverter/format_infos/" ); + for( TQStringList::Iterator a = directories.begin(); a != directories.end(); ++a ) + { + //kdDebug() << " searching directory: `" << *a << "'" << endl; + logger->log( 1000, " searching directory: `" + *a + "'" ); + dir.setPath( *a ); + list = dir.entryList( "*", TQDir::All, TQDir::Name ); + for( TQStringList::Iterator b = list.begin(); b != list.end(); ++b ) + { + if( *b != "." && *b != ".." && (*b).right(4) == ".xml" ) + { + //kdDebug() << " found file: `" << *b << "'" << endl; + logger->log( 1000, " found file: `" + *b + "'" ); + if( formatInfoLoader->verifyFile( TQString(*a).append(*b) ) ) + { + FormatInfo* formatInfo = formatInfoLoader->loadFile( TQString(*a).append(*b) ); + + for( TQValueList::Iterator c = formats.begin(); c != formats.end(); ++c ) { + for( TQStringList::Iterator d = formatInfo->mime_types.begin(); d != formatInfo->mime_types.end(); ++d ) { + if( (*c).mime_types.findIndex(*d) != -1 ) { + (*c).description = "

" + formatInfo->description + "

"; + (*c).description.replace("\\n","

\n

"); + for( TQStringList::Iterator d = formatInfo->urls.begin(); d != formatInfo->urls.end(); ++d ) { + (*c).description += "\n

" + (*d) + "

"; + } + (*c).compressionType = formatInfo->compressionType; + (*c).size = formatInfo->size; + // add extensions for mime types + logger->log( 1000, " found mime type: `" + *d + "'" ); + TQStringList extensions = KMimeType::mimeType( *d )->patterns(); + for( TQStringList::Iterator c = extensions.begin(); c != extensions.end(); ++c ) { + (*c).remove( 0, 2 ); + logger->log( 1000, " adding extension: `" + *c + "'" ); + } + (*c).extensions += extensions; + // add extensions (from format file) HACK + extensions = formatInfo->extensions; + if( !extensions.isEmpty() ) { + logger->log( 1000, " found extensions..." ); + for( TQStringList::Iterator c = extensions.begin(); c != extensions.end(); ++c ) { + logger->log( 1000, " adding extension: `" + *c + "'" ); + } + (*c).extensions += extensions; + } + // add extensions for correction file mime types + for( TQStringList::Iterator d = (*c).correction_file_mime_types.begin(); d != (*c).correction_file_mime_types.end(); ++d ) { + logger->log( 1000, " found correction mime type: `" + *d + "'" ); + TQStringList extensions = KMimeType::mimeType( *d )->patterns(); + for( TQStringList::Iterator e = extensions.begin(); e != extensions.end(); ++e ) { + (*e).remove( 0, 2 ); + logger->log( 1000, " adding correction extension: `" + *e + "'" ); + (*c).correction_file_extensions += (*e); + } + } + } + } + } + } + } + } + } + + delete formatInfoLoader; +} + +void Config::registerFormatFeatures( const TQString &mime_type, + ConvertPlugin* encoder, ConvertPlugin* decoder, + ReplayGainPlugin* replaygain/*, RepairPlugin* repairer*/, + const TQString &correction_file_mime_type ) +{ + //kdDebug() << " entering: `" << "Config::registerFormatFeatures( ... )" << "'" << endl; + logger->log( 1000, " entering: `Config::registerFormatFeatures( ... )'" ); + + // iterate through all file formats and search for an existing one + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + if( (*it).mime_types.findIndex(mime_type) != -1 ) { // we found an existing entry for our file format + //kdDebug() << " found an existing entry: `" << mime_type << "'" << endl; + logger->log( 1000, " found an existing entry: `" + mime_type + "'" ); + + if( encoder != 0 ) (*it).encoders.append( encoder ); +// if( (*it).encoder == 0 && encoder != 0 ) (*it).encoder = encoder; +// if( (*it).encoder != 0 && binaries[(*it).encoder.enc.bin] == "" ) + if( decoder != 0 ) (*it).decoders.append( decoder ); +// if( (*it).decoder == 0 && decoder != 0 ) (*it).decoder = decoder; + if( replaygain != 0 ) (*it).replaygains.append( replaygain ); +// if( (*it).replaygain == 0 && replaygain != 0 ) (*it).replaygain = replaygain; + //if( repairer ) (*it).repairer.append( repairer );*/ + if( !correction_file_mime_type.isEmpty() ) (*it).correction_file_mime_types.append( correction_file_mime_type ); + + // everything done, we can return! + return; + } + } + //kdDebug() << " creating a new entry: `" << mime_type << "'" << endl; + logger->log( 1000, " creating a new entry: `" + mime_type + "'" ); + + // well it seems, we haven't found an entry. create a new! + TQValueList::Iterator newItem = formats.append( FormatItem() ); + (*newItem).mime_types = mime_type; + if( encoder != 0 ) (*newItem).encoders.append( encoder ); +// if( encoder != 0 ) (*newItem).encoder = encoder; + if( decoder != 0 ) (*newItem).decoders.append( decoder ); +// if( decoder != 0 ) (*newItem).decoder = decoder; + if( replaygain != 0 ) (*newItem).replaygains.append( replaygain ); +// if( replaygain != 0 ) (*newItem).replaygain = replaygain; + //if( repairer ) (*newItem).repairer.append( repairer ); + if( !correction_file_mime_type.isEmpty() ) (*newItem).correction_file_mime_types.append( correction_file_mime_type ); + +} + +/*void Config::registerFileFormat( const TQString &mime_type, const TQString &option, const TQString &value ) +{ + // iterate through all file formats and search for an existing one + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + if( (*it).mime_types.findIndex(mime_type) != -1 ) { // we found an existing entry for our file format + if( option == "mime_type" ) (*it).mime_types.append( value ); + //else if( option == "description" ) // TODO implement a qmap ?! + else if( option == "size" ) (*it).size = value.toInt(); + else if( option == "compression_type" ) { + if( value == "lossy" ) (*it).compressionType = FormatInfo::lossy; + else if( value == "lossless" ) (*it).compressionType = FormatInfo::lossless; + else (*it).compressionType = FormatInfo::hybrid; + } + + // everything done, we can return! + return; + } + } + + // well it seems, we haven't found an entry. create a new! + TQValueList::Iterator newItem = formats.append( FormatItem() ); + if( option == "mime_type" ) (*newItem).mime_types.append( value ); + //else if( option == "description" ) // TODO implement a qmap ?! + else if( option == "size" ) (*newItem).size = value.toInt(); + else if( option == "compression_type" ) { + if( value == "lossy" ) (*newItem).compressionType = FormatInfo::lossy; + else if( value == "lossless" ) (*newItem).compressionType = FormatInfo::lossless; + else (*newItem).compressionType = FormatInfo::hybrid; + } +}*/ + +ConvertPlugin* Config::encoderForFormat( const TQString &format ) +{ + // iterate through all file formats and search for our format in mime_types and extensions + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it + return (*it).encoder; + } + } + + return 0; +} + +ConvertPlugin* Config::decoderForFormat( const TQString &format ) +{ + // iterate through all file formats and search for our format in mime_types and extensions + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it + return (*it).decoder; + } + } + + return 0; +} + +ReplayGainPlugin* Config::replaygainForFormat( const TQString &format ) +{ + // iterate through all file formats and search for our format in mime_types and extensions + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it + return (*it).replaygain; + } + } + + return 0; +} + +FormatItem* Config::getFormatItem( const TQString &format ) +{ + // iterate through all file formats and search for our format in mime_types and extensions + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it + return &(*it); + } + } + + return 0; +} + +// NOTE speed up the following 3 functions (cache the data) (use the extensions variable in FormatItem) +// NOTE seems to be called too often ??? +TQStringList Config::allFormats() +{ + TQStringList list; + + //kdDebug() << "entering: `" << "Config::allFormats()" << "'" << endl; + logger->log( 1000, "entering: `Config::allFormats()'" ); + + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl; + logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" ); + if( (*it).mime_types.first() != "application/octet-stream" ) { +// TQString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower(); +// extension.remove( 0, 2 ); + TQString extension = (*it).extensions.first().lower(); + //kdDebug() << " extension: `" << extension << "'" << endl; + logger->log( 1000, " extension: `" + extension + "'" ); + if( !extension.isEmpty() && !list.contains(extension) ) { + list.append( extension ); + //kdDebug() << " (added)" << endl; + logger->log( 1000, " (added)" ); + } + } + } + + return list; +} + +TQStringList Config::allEncodableFormats() +{ + TQStringList list; + + //kdDebug() << "entering: `" << "Config::allEncodableFormats()" << "'" << endl; + logger->log( 1000, "entering: `Config::allEncodableFormats()'" ); + + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl; + logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" ); + if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).mime_types.first() != "application/octet-stream" ) { + if( !(*it).encoder->enc.lossy.enabled && !(*it).encoder->enc.lossless.enabled && !(*it).encoder->enc.hybrid.enabled ) continue; +// TQString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower(); +// extension.remove( 0, 2 ); + TQString extension = (*it).extensions.first().lower(); + //kdDebug() << " extension: `" << extension << "'" << endl; + logger->log( 1000, " extension: `" + extension + "'" ); + if( !extension.isEmpty() && !list.contains(extension) ) { + list.append( extension ); + //kdDebug() << " (added)" << endl; + logger->log( 1000, " (added)" ); + } + } + } + + return list; +} + +TQStringList Config::allLossyEncodableFormats() +{ + TQStringList list; + + //kdDebug() << "entering: `" << "Config::allLossyEncodableFormats()" << "'" << endl; +// logger->log( 1000, "entering: `Config::allLossyEncodableFormats()'" ); + + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl; +// logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" ); + if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).encoder->enc.lossy.enabled && (*it).compressionType & FormatInfo::lossy && (*it).mime_types.first() != "application/octet-stream" ) { +// TQString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower(); +// extension.remove( 0, 2 ); + TQString extension = (*it).extensions.first().lower(); + //kdDebug() << " extension: `" << extension << "'" << endl; +// logger->log( 1000, " extension: `" + extension + "'" ); + if( !extension.isEmpty() && !list.contains(extension) ) { + list.append( extension ); + //kdDebug() << " (added)" << endl; +// logger->log( 1000, " (added)" ); + } + } + } + + return list; +} + +TQStringList Config::allLosslessEncodableFormats() +{ + TQStringList list; + + //kdDebug() << "entering: `" << "Config::allLosslessEncodableFormats()" << "'" << endl; + logger->log( 1000, "entering: `Config::allLosslessEncodableFormats()'" ); + + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl; + logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" ); + if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).encoder->enc.lossless.enabled && (*it).compressionType & FormatInfo::lossless && (*it).mime_types.first() != "application/octet-stream" ) { +// TQString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower(); +// extension.remove( 0, 2 ); + TQString extension = (*it).extensions.first().lower(); + //kdDebug() << " extension: `" << extension << "'" << endl; + logger->log( 1000, " extension: `" + extension + "'" ); + if( !extension.isEmpty() && !list.contains(extension) ) { + list.append( extension ); + //kdDebug() << " (added)" << endl; + logger->log( 1000, " (added)" ); + } + } + } + + return list; +} + +TQStringList Config::allHybridEncodableFormats() +{ + TQStringList list; + + //kdDebug() << "entering: `" << "Config::allHybridEncodableFormats()" << "'" << endl; + logger->log( 1000, "entering: `Config::allHybridEncodableFormats()'" ); + + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + //kdDebug() << " mime type: `" << (*it).mime_types.first() << "'" << endl; + logger->log( 1000, " mime type: `" + (*it).mime_types.first() + "'" ); + if( (*it).encoder != 0 && binaries[(*it).encoder->enc.bin] != "" && (*it).encoder->enc.hybrid.enabled && (*it).compressionType & FormatInfo::hybrid && (*it).mime_types.first() != "application/octet-stream" ) { +// TQString extension = KMimeType::mimeType( (*it).mime_types.first() )->patterns().first().lower(); +// extension.remove( 0, 2 ); + TQString extension = (*it).extensions.first().lower(); + //kdDebug() << " extension: `" << extension << "'" << endl; + logger->log( 1000, " extension: `" + extension + "'" ); + if( !extension.isEmpty() && !list.contains(extension) ) { + list.append( extension ); + //kdDebug() << " (added)" << endl; + logger->log( 1000, " (added)" ); + } + } + } + + return list; +} + +TQString Config::getCorrectionExtension( const TQString &format ) +{ + // iterate through all file formats and search for our format + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it + return (*it).correction_file_extensions.first(); + } + } + + return ""; +} + +TQString Config::getFormatDescription( const TQString &format ) // NOTE could be removed +{ + // iterate through all file formats and search for our format + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it + return (*it).description; + } + } + + return ""; +} + +void Config::addProfile( const TQString &name, const ConversionOptions& profile ) +{ + ProfileData profileData; + profileData.name = name; + profileData.options = profile; + profiles += profileData; + if( name != i18n("Last used") && name != "Last used" ) writeProfiles(); // will only be saved at app exit, when saving everything anyway + emit configChanged(); +} + +void Config::removeProfile( const TQString &name ) +{ + for( TQValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) { + if( (*it).name == name ) { + profiles.remove( it ); + if( name != i18n("Last used") && name != "Last used" ) writeProfiles(); // will only be saved at app exit, when saving everything anyway + return; + } + } + emit configChanged(); +} + +ConversionOptions Config::getProfile( const TQString &name ) +{ + for( TQValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) { + if( /*(*it).name != i18n("Last used") &&*/ (*it).name == name ) { + return (*it).options; + } + } + + ConversionOptions options; + options.encodingOptions.sFormat = ""; + return options; +} + +TQString Config::getProfileName( const ConversionOptions& options ) +{ + if( options.encodingOptions.sQualityMode == i18n("Lossless") ) { + return i18n("Lossless"); + } + + if( options.encodingOptions.sQualityMode == i18n("Hybrid") ) { + return i18n("Hybrid"); + } + + for( TQValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) { + if( (*it).name != i18n("Last used") && (*it).options.nearlyEqual( options ) ) { + return (*it).name; + } + } + + ConvertPlugin* plugin = encoderForFormat( options.encodingOptions.sFormat ); + if( plugin != 0 ) { + if( plugin->enc.lossy.quality.enabled ) { + if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 20 && + options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 && + options.encodingOptions.channels.bEnabled == true && options.encodingOptions.channels.sChannels == i18n("Mono") && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("Very low"); + } + if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 30 && + options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 && + options.encodingOptions.channels.bEnabled == false && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("Low"); + } + if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 40 && + options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == false && + options.encodingOptions.channels.bEnabled == false && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("Medium"); + } + if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 50 && + options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == false && + options.encodingOptions.channels.bEnabled == false && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("High"); + } + if( options.encodingOptions.sQualityMode == i18n("Quality") && options.encodingOptions.iQuality == 60 && + options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == false && + options.encodingOptions.channels.bEnabled == false && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("Very high"); + } + } + if( plugin->enc.lossy.bitrate.abr.enabled || plugin->enc.lossy.bitrate.cbr.enabled ) { + if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 64 && + options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 && + options.encodingOptions.channels.bEnabled == true && options.encodingOptions.channels.sChannels == i18n("Mono") && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("Very low"); + } + if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 96 && + options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 && + options.encodingOptions.channels.bEnabled == false && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("Low"); + } + if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 192 && + options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == false && + options.encodingOptions.channels.bEnabled == false && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("Medium"); + } + if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 240 && + options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == false && + options.encodingOptions.channels.bEnabled == false && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("High"); + } + if( options.encodingOptions.sQualityMode == i18n("Bitrate") && options.encodingOptions.iQuality == 320 && + options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == false && + options.encodingOptions.channels.bEnabled == false && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("Very high"); + } + } + /*{ + if( options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 && + options.encodingOptions.channels.bEnabled == true && options.encodingOptions.channels.sChannels == i18n("Mono") && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("Very low"); + } + if( options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == true && options.encodingOptions.samplingRate.iSamplingRate == 22050 && + options.encodingOptions.channels.bEnabled == false && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("Low"); + } + if( options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == false && + options.encodingOptions.channels.bEnabled == false && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("Medium"); + } + if( options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == false && + options.encodingOptions.channels.bEnabled == false && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("High"); + } + if( options.encodingOptions.bBitrateRange == false && + options.encodingOptions.samplingRate.bEnabled == false && + options.encodingOptions.channels.bEnabled == false && + options.encodingOptions.sInOutFiles == binaries[plugin->enc.bin] + " " + plugin->enc.in_out_files ) { + return i18n("Very high"); + } + }*/ + } + return i18n("User defined"); +} + +TQStringList Config::getAllProfiles() +{ + TQStringList list; + + for( TQValueList::Iterator it = profiles.begin(); it != profiles.end(); ++it ) { + /*if( (*it).name != i18n("Last used") )*/ list += (*it).name; + } + + return list; +} + +bool Config::acceptFile( const TQString& format ) +{ + if( format == "audio/x-wav" || format == "wav" ) return true; + + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it + if( (*it).decoder != 0 ) return true; + } + } + + return false; +} + +bool Config::acceptReplayGainFile( const TQString& format ) +{ + for( TQValueList::Iterator it = formats.begin(); it != formats.end(); ++it ) { + if( (*it).mime_types.findIndex(format) != -1 || (*it).extensions.findIndex(format) != -1 ) { // we found it + if( (*it).replaygain != 0 ) return true; + } + } + + return false; +} + +TQString Config::fileFilter( bool wav ) +{ + TQString filter1; + if( wav ) filter1 += "*.wav *.WAV *.Wav"; + TQString filter2; + if( wav ) filter2 += "\n*.wav *.WAV *.Wav|wav " + i18n("files") + " (*.wav)"; + TQString temp; + + for( TQValueList::Iterator a = formats.begin(); a != formats.end(); ++a ) { + if( (*a).decoder != 0 ) { + temp = ""; + for( TQStringList::Iterator b = (*a).extensions.begin(); b != (*a).extensions.end(); ++b ) { + filter1 += " *." + (*b); + if( !temp.contains(*b,false) ) temp += " *." + (*b).lower(); + } + //temp.stripWhiteSpace(); // NOTE doesn't work + if( temp != "" && temp.length() < 80 ) { + temp.remove( 0, 1 ); + temp = "\n" + temp + "|" + (*a).extensions.first() + " " + i18n("files") + " (" + temp + ")"; + if( !filter2.contains(temp) ) { // HACK when unsing multiple mime types, there were too much entries + filter2 += temp; + } + } + else if( temp != "" ) { + temp.remove( 0, 1 ); + temp = "\n" + temp + "|" + (*a).extensions.first() + " " + i18n("files"); + if( !filter2.contains(temp) ) { // HACK when unsing multiple mime types, there were too much entries + filter2 += temp; + } + } + } + } + + filter1.stripWhiteSpace(); + filter2.stripWhiteSpace(); + + return filter1 + "|" + i18n("all supported formats") + "\n*.*|" + i18n("all formats") + filter2; +} + +TQStringList Config::fileTypes( bool wav ) +{ + TQStringList types; + if( wav ) types.append( "wav" ); + TQString temp; + + for( TQValueList::Iterator a = formats.begin(); a != formats.end(); ++a ) { + if( (*a).decoder != 0 ) { + temp = ""; + for( TQStringList::Iterator b = (*a).extensions.begin(); b != (*a).extensions.end(); ++b ) { + if( !temp.contains(*b,false) ) temp.append( (*b).lower() + ", " ); + } + if( temp != "" ) { + temp = temp.left( temp.length() - 2 ); + if( types.findIndex(temp) == -1 ) types.append( temp ); + } + } + } + + return types; +} + +TQString Config::replayGainFilter() +{ + TQString filter1; + TQString filter2; + TQString temp; + + for( TQValueList::Iterator a = formats.begin(); a != formats.end(); ++a ) { + if( (*a).replaygain != 0 ) { + temp = ""; + for( TQStringList::Iterator b = (*a).extensions.begin(); b != (*a).extensions.end(); ++b ) { + filter1 += " *." + (*b); + if( !temp.contains(*b,false) ) temp += " *." + (*b).lower(); + } + //temp.stripWhiteSpace(); // NOTE doesn't work + if( temp != "" && temp.length() < 80 ) { + temp.remove( 0, 1 ); + filter2 += "\n" + temp + "|" + (*a).extensions.first() + " " + i18n("files") + " (" + temp + ")"; + } + else if( temp != "" ) { + temp.remove( 0, 1 ); + filter2 += "\n" + temp + "|" + (*a).extensions.first() + " " + i18n("files"); + } + } + } + + filter1.stripWhiteSpace(); + filter2.stripWhiteSpace(); + + return filter1 + "|" + i18n("all supported formats") + "\n*.*|" + i18n("all formats") + filter2; +} + +TQStringList Config::replayGainFileTypes() +{ + TQStringList types; + TQString temp; + + for( TQValueList::Iterator a = formats.begin(); a != formats.end(); ++a ) { + if( (*a).replaygain != 0 ) { + temp = ""; + for( TQStringList::Iterator b = (*a).extensions.begin(); b != (*a).extensions.end(); ++b ) { + if( !temp.contains(*b,false) ) temp.append( (*b).lower() + ", " ); + } + if( temp != "" ) { + temp = temp.left( temp.length() - 2 ); + if( types.findIndex(temp) == -1 ) types.append( temp ); + } + } + } + + return types; +} + + diff --git a/src/configuration.h b/src/configuration.h new file mode 100644 index 0000000..c6488c1 --- /dev/null +++ b/src/configuration.h @@ -0,0 +1,355 @@ + + +#ifndef CONFIG_H +#define CONFIG_H + +#include "formatinfoloader.h" +#include "conversionoptions.h" + +#include +#include +#include +#include + +class Logger; +class ConvertPlugin; +//class ConvertPluginLoader; +class ReplayGainPlugin; +//class ReplayGainPluginLoader; +class RipperPlugin; +struct ProfileData; + + +/** + * @short Format items for the format list + * @author Daniel Faust + * @version 0.3 + */ +class FormatItem +{ +public: + /** + * Constructor + */ + FormatItem(); + + /** + * Destructor + */ + virtual ~FormatItem(); + + TQStringList mime_types; + TQStringList extensions; // for easy use + TQStringList correction_file_mime_types; + TQStringList correction_file_extensions; // for easy use + TQString description; + FormatInfo::CompressionType compressionType; + int compressionLevel; // the value from the config dialog + bool internalReplayGain; + int size; + TQValueList encoders; + TQValueList decoders; + TQValueList replaygains; + //TQValueList repairers; + ConvertPlugin* encoder; + ConvertPlugin* decoder; + ReplayGainPlugin* replaygain; + //RepairerPlugin* repairer; +}; + + +/** + * @short Configuration class + * @author Daniel Faust + * @version 0.3 + */ +class Config : public TQObject +{ + TQ_OBJECT + +public: + /** + * Constructor + */ + Config( Logger* ); + + /** + * Destructor + */ + virtual ~Config(); + + /** + * Read the preferences from the configuration file + */ + void read(); + + /** + * Write the preferences to the configuration file + */ + void write( bool sync = true ); + + /** + * Read the profiles from the profiles file + */ + void readProfiles(); + + /** + * Write the profiles to the profiles file + */ + void writeProfiles(); + + /** + * Get the encoder for a given file format (mime type or extension) + */ + ConvertPlugin* encoderForFormat( const TQString &format ); + + /** + * Get the decoder for a given file format (mime type or extension) + */ + ConvertPlugin* decoderForFormat( const TQString &format ); + + /** + * Get the decoder for a given file format (mime type or extension) + */ + ReplayGainPlugin* replaygainForFormat( const TQString &format ); + + /** + * Get the format information for a given file format (mime type or extension) + */ + FormatItem* getFormatItem( const TQString &format ); + + /** + * Get the current ripper + */ + RipperPlugin* getCurrentRipper() { return currentRipper; } + + /** + * Set the current ripper + */ + void setCurrentRipper( RipperPlugin* ripper ) { currentRipper = ripper; } + + /** + * Returns a list of all loaded rippers + */ + TQValueList allRippers() { return rippers; } + + /** + * Returns a list of all loaded converters + */ + TQValueList allConverters() { return converters; } + + /** + * Returns a list of all loaded replaygains + */ + TQValueList allReplayGains() { return replaygains; } + + /** + * Returns a list of all known file formats + */ + TQStringList allFormats(); + + /** + * Returns a list of all known encodeable file formats + */ + TQStringList allEncodableFormats(); + + /** + * Returns a list of all known lossy encodeable file formats + */ + TQStringList allLossyEncodableFormats(); + + /** + * Returns a list of all known lossless encodeable file formats + */ + TQStringList allLosslessEncodableFormats(); + + /** + * Returns a list of all known hybrid encodeable file formats + */ + TQStringList allHybridEncodableFormats(); + + /** + * Returns the extension of the correction file format for the given format + * If there is nor correction file format, the returned string is empty + */ + TQString getCorrectionExtension( const TQString &format ); + + /** + * Returns a localized description for the given format + */ + TQString getFormatDescription( const TQString &format ); + + /** + * Add a new profile + */ + void addProfile( const TQString &name, const ConversionOptions& profile ); + + /** + * Remove a new profile + */ + void removeProfile( const TQString &name ); + + /** + * Returns the conversion options for a profile + */ + ConversionOptions getProfile( const TQString &name ); + + /** + * Returns the name of the profile with conversion options @p options + */ + TQString getProfileName( const ConversionOptions& options ); + + /** + * Returns a list of all user defined profiles + */ + TQStringList getAllProfiles(); + + /** + * Returns true if the @p file can be added to the conversion list (can be decoded) + */ + bool acceptFile( const TQString& format ); + + /** + * Returns true if the @p file can be added to the replay gain tool + */ + bool acceptReplayGainFile( const TQString& format ); + + /** + * Returns a file filter suitable for the file open dialog + */ + TQString fileFilter( bool wav = true ); + + /** + * Returns a string list of supported file formats + */ + TQStringList fileTypes( bool wav = true ); + + /** + * Returns a file filter suitable for the file open dialog for the replay gain scanner + */ + TQString replayGainFilter(); + + /** + * Returns a string list of Replay Gain supported file formats + */ + TQStringList replayGainFileTypes(); + + struct Data { + struct General { + int startTab; + int lastTab; + TQString defaultProfile; + TQString defaultFormat; +// TQString defaultOutputDirectory; + TQString specifyOutputDirectory; + TQString metaDataOutputDirectory; + TQString copyStructureOutputDirectory; + int priority; + bool useVFATNames; + int conflictHandling; + int numFiles; + int updateDelay; + bool askForNewOptions; + bool executeUserScript; + bool showToolBar; + } general; + struct Plugins { + bool checkForUpdates; + } plugins; + struct Environment { + TQStringList directories; + TQStringList foundPrograms; + } environment; + struct App { + int configVersion; + } app; + } data; + + bool onlinePluginsChanged; + bool backendsChanged; + + TQMap binaries; + +private: + struct PluginMapData { + int version; + TQString filename; + TQString type; + }; + + Logger* logger; + + /** holds all known formats */ + TQValueList formats; + + /** holds all known rippers */ + TQValueList rippers; + RipperPlugin* currentRipper; + + /** holds all known converters */ + TQValueList converters; + /** holds all known replaygain apps */ + TQValueList replaygains; + /* holds all known file repairing apps */ +// TQValueList repairer; + + //ConvertPluginLoader* convertPluginLoader; + //ReplayGainPluginLoader* replaygainPluginLoader; + + /** holds all user defined profiles */ + TQValueList profiles; + + /** + * Load the files with the file infos (format descriptions, file size, etc.) + */ + void loadFileInfos(); + + /** + * Load all plugins that can be found + */ + void loadPlugins(); + + /** + * A plugin wants to register it's features for a file format + * @p binary The binary name of the app that wants to register it's features + * @p extension The file name extension for that is wants to register + * @p features The features of the app for that extension + */ + void registerFormatFeatures( const TQString &mime_type, + ConvertPlugin* encoder = 0, ConvertPlugin* decoder = 0, + ReplayGainPlugin* replaygain = 0/*, RepairPlugin* repairer = 0*/, + const TQString &correction_file_mime_type = TQString() ); + + /** + * Generate the service menu + */ + void writeServiceMenu(); + + /** + * Copy the amarok script + */ + void writeAmarokScript(); + + /* + * We have new inforamtion for a file format + * @p extension The file name extension for that is wants to register + * @p newSynonym Register a new synonym for this file format? + * @p newMimeType Register a new mime type for this file format? + * @p newDescription Register a new description for this file format? + * @p newSize Register a new size for this file format for calculating the progress? + */ + /*void registerFileFormat( const TQString &extension, const TQString &newSynonym = TQString(), + const TQString &newMimeType = TQString(), + const TQString &newDescription = TQString(), + int newSize = 0, FormatInfo::CompressionType newCompressionType = FormatInfo::lossy );*/ + //void registerFileFormat( const TQString &mime_type, const TQString &option, const TQString &value ); + // NOTE this function is obsolete. + // after loading all plugins and creating all neccessary file format items, + // sk will search for format info files and update the items. + +signals: + void configChanged(); + +}; + +#endif // CONFIG_H diff --git a/src/convert.cpp b/src/convert.cpp index d1a2149..204fb17 100644 --- a/src/convert.cpp +++ b/src/convert.cpp @@ -5,7 +5,7 @@ #include "replaygainpluginloader.h" #include "replaygain.h" #include "ripperpluginloader.h" -#include "config.h" +#include "configuration.h" #include "tagengine.h" #include "cdmanager.h" #include "logger.h" diff --git a/src/dirdialog.cpp b/src/dirdialog.cpp index edb3d32..627a5de 100644 --- a/src/dirdialog.cpp +++ b/src/dirdialog.cpp @@ -1,6 +1,6 @@ #include "dirdialog.h" -#include "config.h" +#include "configuration.h" #include #include diff --git a/src/filelist.cpp b/src/filelist.cpp index fa28c9b..f1f49d3 100644 --- a/src/filelist.cpp +++ b/src/filelist.cpp @@ -6,7 +6,7 @@ #include "convert.h" #include "optionseditor.h" #include "outputdirectory.h" -#include "config.h" +#include "configuration.h" #include "logger.h" #include "convertpluginloader.h" // NOTE DEBUG diff --git a/src/options.cpp b/src/options.cpp index 74a190e..be69a37 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -2,7 +2,7 @@ #include "options.h" #include "optionssimple.h" #include "optionsdetailed.h" -#include "config.h" +#include "configuration.h" #include #include diff --git a/src/optionsdetailed.cpp b/src/optionsdetailed.cpp index b050b49..7f23072 100644 --- a/src/optionsdetailed.cpp +++ b/src/optionsdetailed.cpp @@ -1,7 +1,7 @@ #include "optionsdetailed.h" #include "convertpluginloader.h" -#include "config.h" +#include "configuration.h" #include #include diff --git a/src/optionseditor.cpp b/src/optionseditor.cpp index 9e97c93..5794777 100644 --- a/src/optionseditor.cpp +++ b/src/optionseditor.cpp @@ -5,6 +5,7 @@ #include "filelist.h" #include "conversionoptions.h" #include "outputdirectory.h" +#include "configuration.h" #include #include diff --git a/src/optionsrequester.cpp b/src/optionsrequester.cpp index 854921b..29d6cd0 100644 --- a/src/optionsrequester.cpp +++ b/src/optionsrequester.cpp @@ -1,7 +1,7 @@ #include "optionsrequester.h" #include "options.h" -#include "config.h" +#include "configuration.h" #include #include diff --git a/src/optionssimple.cpp b/src/optionssimple.cpp index c5dbefe..e72ab35 100644 --- a/src/optionssimple.cpp +++ b/src/optionssimple.cpp @@ -1,6 +1,6 @@ #include "optionssimple.h" -#include "config.h" +#include "configuration.h" #include "convertpluginloader.h" #include "optionsdetailed.h" diff --git a/src/outputdirectory.cpp b/src/outputdirectory.cpp index 16a8a35..d2d0b7c 100644 --- a/src/outputdirectory.cpp +++ b/src/outputdirectory.cpp @@ -3,7 +3,7 @@ #include "filelist.h" #include "conversionoptions.h" #include "tagengine.h" -#include "config.h" +#include "configuration.h" #include #include diff --git a/src/replaygain.cpp b/src/replaygain.cpp index abf29c4..d93d57e 100644 --- a/src/replaygain.cpp +++ b/src/replaygain.cpp @@ -1,6 +1,6 @@ #include "replaygain.h" -#include "config.h" +#include "configuration.h" #include "logger.h" #include "replaygainpluginloader.h" diff --git a/src/replaygainfilelist.cpp b/src/replaygainfilelist.cpp index 7749baf..91852a2 100644 --- a/src/replaygainfilelist.cpp +++ b/src/replaygainfilelist.cpp @@ -2,7 +2,7 @@ #include "replaygainfilelist.h" #include "tagengine.h" #include "logger.h" -#include "config.h" +#include "configuration.h" #include "replaygain.h" #include "replaygainpluginloader.h" diff --git a/src/replaygainscanner.cpp b/src/replaygainscanner.cpp index b6a7e79..53808b6 100644 --- a/src/replaygainscanner.cpp +++ b/src/replaygainscanner.cpp @@ -2,7 +2,7 @@ #include "replaygainscanner.h" #include "logger.h" #include "combobutton.h" -#include "config.h" +#include "configuration.h" #include "dirdialog.h" #include diff --git a/src/soundkonverter.cpp b/src/soundkonverter.cpp index d6267a0..1914c1d 100644 --- a/src/soundkonverter.cpp +++ b/src/soundkonverter.cpp @@ -1,6 +1,6 @@ #include "soundkonverter.h" -#include "config.h" +#include "configuration.h" #include "configdialog.h" #include "logger.h" #include "logviewer.h" -- cgit v1.2.1