1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 14:16:32 +02:00

Fix ACL saving/loading

This commit is contained in:
Jeff Mitchell
2012-06-17 22:24:49 -04:00
parent 554cb5d7a1
commit 259e4f3da9

View File

@@ -44,7 +44,7 @@ QDataStream& operator<<( QDataStream &out, const ACLRegistry::User &user )
out << knownDbid; out << knownDbid;
out << user.knownAccountIds.length(); out << user.knownAccountIds.length();
foreach( QString knownAccount, user.knownAccountIds ) foreach( QString knownAccount, user.knownAccountIds )
out << user.knownAccountIds; out << knownAccount;
out << (int)( user.acl ); out << (int)( user.acl );
return out; return out;
} }
@@ -58,12 +58,20 @@ QDataStream& operator>>( QDataStream &in, ACLRegistry::User &user )
in >> user.uuid; in >> user.uuid;
int dbidsLength; int dbidsLength;
in >> dbidsLength; in >> dbidsLength;
QString knownDbid;
for ( int i = 0; i < dbidsLength; i++ ) for ( int i = 0; i < dbidsLength; i++ )
in >> user.knownDbids; {
in >> knownDbid;
user.knownDbids << knownDbid;
}
int accountsLength; int accountsLength;
in >> accountsLength; in >> accountsLength;
QString knownAccountId;
for ( int i = 0; i < accountsLength; i++ ) for ( int i = 0; i < accountsLength; i++ )
in >> user.knownAccountIds; {
in >> knownAccountId;
user.knownAccountIds << knownAccountId;
}
int aclIn; int aclIn;
in >> aclIn; in >> aclIn;
user.acl = (ACLRegistry::ACL)( aclIn ); user.acl = (ACLRegistry::ACL)( aclIn );
@@ -253,11 +261,17 @@ ACLRegistry::load()
foreach ( QVariant entry, entryList ) foreach ( QVariant entry, entryList )
{ {
if ( !entry.isValid() || !entry.canConvert< ACLRegistry::User >() ) if ( !entry.isValid() || !entry.canConvert< ACLRegistry::User >() )
{
tLog() << Q_FUNC_INFO << "entry is invalid";
continue; continue;
}
tLog() << Q_FUNC_INFO << "loading entry"; tLog() << Q_FUNC_INFO << "loading entry";
ACLRegistry::User entryUser = entry.value< ACLRegistry::User >(); ACLRegistry::User entryUser = entry.value< ACLRegistry::User >();
if ( entryUser.knownAccountIds.empty() || entryUser.knownDbids.empty() ) if ( entryUser.knownAccountIds.empty() || entryUser.knownDbids.empty() )
{
tLog() << Q_FUNC_INFO << "user known account/dbids is empty";
continue; continue;
}
m_cache.append( entryUser ); m_cache.append( entryUser );
} }
} }