mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Modify Tomahawk's config file to be only accessible by the owner.
This commit is contained in:
@@ -47,19 +47,24 @@ TomahawkSettings::TomahawkSettings( QObject* parent )
|
|||||||
{
|
{
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
|
|
||||||
if( !contains( "configversion") )
|
#ifdef Q_OS_LINUX
|
||||||
|
QFile file( fileName() );
|
||||||
|
file.setPermissions( file.permissions() & ~(QFile::ReadGroup | QFile::WriteGroup | QFile::ExeGroup | QFile::ReadOther | QFile::WriteOther | QFile::ExeOther ) );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ( !contains( "configversion" ) )
|
||||||
{
|
{
|
||||||
setValue( "configversion", VERSION );
|
setValue( "configversion", VERSION );
|
||||||
doInitialSetup();
|
doInitialSetup();
|
||||||
}
|
}
|
||||||
else if( value( "configversion" ).toUInt() != VERSION )
|
else if ( value( "configversion" ).toUInt() != VERSION )
|
||||||
{
|
{
|
||||||
qDebug() << "Config version outdated, old:" << value( "configversion" ).toUInt()
|
qDebug() << "Config version outdated, old:" << value( "configversion" ).toUInt()
|
||||||
<< "new:" << VERSION
|
<< "new:" << VERSION
|
||||||
<< "Doing upgrade, if any...";
|
<< "Doing upgrade, if any...";
|
||||||
|
|
||||||
int current = value( "configversion" ).toUInt();
|
int current = value( "configversion" ).toUInt();
|
||||||
while( current < VERSION )
|
while ( current < VERSION )
|
||||||
{
|
{
|
||||||
doUpgrade( current, current + 1 );
|
doUpgrade( current, current + 1 );
|
||||||
|
|
||||||
@@ -68,7 +73,6 @@ TomahawkSettings::TomahawkSettings( QObject* parent )
|
|||||||
// insert upgrade code here as required
|
// insert upgrade code here as required
|
||||||
setValue( "configversion", VERSION );
|
setValue( "configversion", VERSION );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -91,22 +95,23 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
|
|||||||
{
|
{
|
||||||
Q_UNUSED( newVersion );
|
Q_UNUSED( newVersion );
|
||||||
|
|
||||||
if( oldVersion == 1 )
|
if ( oldVersion == 1 )
|
||||||
{
|
{
|
||||||
qDebug() << "Migrating config from verson 1 to 2: script resolver config name";
|
qDebug() << "Migrating config from verson 1 to 2: script resolver config name";
|
||||||
if( contains( "script/resolvers" ) ) {
|
if( contains( "script/resolvers" ) ) {
|
||||||
setValue( "script/loadedresolvers", value( "script/resolvers" ) );
|
setValue( "script/loadedresolvers", value( "script/resolvers" ) );
|
||||||
remove( "script/resolvers" );
|
remove( "script/resolvers" );
|
||||||
}
|
}
|
||||||
} else if( oldVersion == 2 )
|
}
|
||||||
|
else if ( oldVersion == 2 )
|
||||||
{
|
{
|
||||||
qDebug() << "Migrating config from version 2 to 3: Converting jabber and twitter accounts to new SIP Factory approach";
|
qDebug() << "Migrating config from version 2 to 3: Converting jabber and twitter accounts to new SIP Factory approach";
|
||||||
// migrate old accounts to new system. only jabber and twitter, and max one each. create a new plugin for each if needed
|
// migrate old accounts to new system. only jabber and twitter, and max one each. create a new plugin for each if needed
|
||||||
// not pretty as we hardcode a plugin id and assume that we know how the config layout is, but hey, this is migration after all
|
// not pretty as we hardcode a plugin id and assume that we know how the config layout is, but hey, this is migration after all
|
||||||
if( contains( "jabber/username" ) && contains( "jabber/password" ) )
|
if ( contains( "jabber/username" ) && contains( "jabber/password" ) )
|
||||||
{
|
{
|
||||||
QString sipName = "sipjabber";
|
QString sipName = "sipjabber";
|
||||||
if( value( "jabber/username" ).toString().contains( "@gmail" ) )
|
if ( value( "jabber/username" ).toString().contains( "@gmail" ) )
|
||||||
sipName = "sipgoogle";
|
sipName = "sipgoogle";
|
||||||
|
|
||||||
setValue( QString( "%1_legacy/username" ).arg( sipName ), value( "jabber/username" ) );
|
setValue( QString( "%1_legacy/username" ).arg( sipName ), value( "jabber/username" ) );
|
||||||
@@ -123,7 +128,7 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
|
|||||||
remove( "jabber/server" );
|
remove( "jabber/server" );
|
||||||
remove( "jabber/port" );
|
remove( "jabber/port" );
|
||||||
}
|
}
|
||||||
if( contains( "twitter/ScreenName" ) && contains( "twitter/OAuthToken" ) )
|
if ( contains( "twitter/ScreenName" ) && contains( "twitter/OAuthToken" ) )
|
||||||
{
|
{
|
||||||
setValue( "siptwitter_legacy/ScreenName", value( "twitter/ScreenName" ) );
|
setValue( "siptwitter_legacy/ScreenName", value( "twitter/ScreenName" ) );
|
||||||
setValue( "siptwitter_legacy/OAuthToken", value( "twitter/OAuthToken" ) );
|
setValue( "siptwitter_legacy/OAuthToken", value( "twitter/OAuthToken" ) );
|
||||||
@@ -144,7 +149,8 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
|
|||||||
}
|
}
|
||||||
// create a zeroconf plugin too
|
// create a zeroconf plugin too
|
||||||
addSipPlugin( "sipzeroconf_legacy" );
|
addSipPlugin( "sipzeroconf_legacy" );
|
||||||
} else if ( oldVersion == 3 )
|
}
|
||||||
|
else if ( oldVersion == 3 )
|
||||||
{
|
{
|
||||||
if ( contains( "script/atticaresolverstates" ) )
|
if ( contains( "script/atticaresolverstates" ) )
|
||||||
{
|
{
|
||||||
@@ -183,7 +189,8 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
|
|||||||
tDebug() << "UPGRADING AND DELETING:" << resolverDir.absolutePath();
|
tDebug() << "UPGRADING AND DELETING:" << resolverDir.absolutePath();
|
||||||
TomahawkUtils::removeDirectory( resolverDir.absolutePath() );
|
TomahawkUtils::removeDirectory( resolverDir.absolutePath() );
|
||||||
}
|
}
|
||||||
} else if ( oldVersion == 4 )
|
}
|
||||||
|
else if ( oldVersion == 4 )
|
||||||
{
|
{
|
||||||
// 0.3.0 contained a bug which prevent indexing local files. Force a reindex.
|
// 0.3.0 contained a bug which prevent indexing local files. Force a reindex.
|
||||||
QTimer::singleShot( 0, this, SLOT( updateIndex() ) );
|
QTimer::singleShot( 0, this, SLOT( updateIndex() ) );
|
||||||
@@ -935,6 +942,7 @@ TomahawkSettings::setNowPlayingEnabled( bool enable )
|
|||||||
setValue( "adium/enablenowplaying", enable );
|
setValue( "adium/enablenowplaying", enable );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TomahawkSettings::PrivateListeningMode
|
TomahawkSettings::PrivateListeningMode
|
||||||
TomahawkSettings::privateListeningMode() const
|
TomahawkSettings::privateListeningMode() const
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user