1 /****************************************************************************************
2  * Copyright (c) 2012 Matěj Laitl <matej@laitl.cz>                                      *
3  *                                                                                      *
4  * This program is free software; you can redistribute it and/or modify it under        *
5  * the terms of the GNU General Public License as published by the Free Software        *
6  * Foundation; either version 2 of the License, or (at your option) any later           *
7  * version.                                                                             *
8  *                                                                                      *
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
11  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
12  *                                                                                      *
13  * You should have received a copy of the GNU General Public License along with         *
14  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
15  ****************************************************************************************/
16 
17 #include "UmsTranscodeCapability.h"
18 
19 #include <KConfig>
20 
21 
UmsTranscodeCapability(const QString & configFilePath,const QString & groupName)22 UmsTranscodeCapability::UmsTranscodeCapability( const QString &configFilePath, const QString &groupName )
23     : TranscodeCapability()
24     , m_configFilePath( configFilePath )
25     , m_groupName( groupName )
26 {
27 }
28 
~UmsTranscodeCapability()29 UmsTranscodeCapability::~UmsTranscodeCapability()
30 {
31 }
32 
33 Transcoding::Configuration
savedConfiguration()34 UmsTranscodeCapability::savedConfiguration()
35 {
36     KConfig configFile( m_configFilePath, KConfig::SimpleConfig );
37     if( !configFile.hasGroup( m_groupName ) )
38         return Transcoding::Configuration( Transcoding::INVALID );
39     return Transcoding::Configuration::fromConfigGroup( configFile.group( m_groupName ) );
40 }
41 
42 void
setSavedConfiguration(const Transcoding::Configuration & configuration)43 UmsTranscodeCapability::setSavedConfiguration( const Transcoding::Configuration &configuration )
44 {
45     KConfig configFile( m_configFilePath, KConfig::SimpleConfig );
46     KConfigGroup group = configFile.group( m_groupName );
47     configuration.saveToConfigGroup( group );
48     configFile.sync();
49 }
50 
51