SVN commit 1022532 by afiestas: Adds exists methods to AvatarManager class, which will check if a given avatarName or avatarEntry exists in the config (only in the config at the moment). Reviewed at: http://reviewboard.kde.org/r/1532/ M +20 -0 kopeteavatarmanager.cpp M +12 -0 kopeteavatarmanager.h --- trunk/KDE/kdenetwork/kopete/libkopete/kopeteavatarmanager.cpp #1022531:1022532 @@ -279,6 +279,26 @@ return false; } +bool AvatarManager::exists(Kopete::AvatarManager::AvatarEntry entryToCheck) +{ + if( entryToCheck.name.isEmpty() ) + return false; + return exists(entryToCheck.name); +} + +bool AvatarManager::exists(const QString &avatarName) +{ + KUrl configUrl(d->baseDir); + configUrl.addPath( UserDir ); + configUrl.addPath( AvatarConfig ); + + KConfigGroup avatarConfig ( KSharedConfig::openConfig( configUrl.path(), KConfig::SimpleConfig ), avatarName ); + if(!avatarConfig.exists()){ + return false; + } + return true; +} + void AvatarManager::Private::createDirectory(const KUrl &directory) { if( !QFile::exists(directory.path()) ) --- trunk/KDE/kdenetwork/kopete/libkopete/kopeteavatarmanager.h #1022531:1022532 @@ -188,6 +188,18 @@ */ bool remove(Kopete::AvatarManager::AvatarEntry entryToRemove); + /** + * @brief Check if an avatar exists + * @param entryToCheck Avatar entry to check + */ + bool exists(Kopete::AvatarManager::AvatarEntry avatarToCheck); + + /** + * @brief Check if an avatar exists by his name + * @param avatarName Avatar entry to check + */ + bool exists(const QString &avatarName); + private: /** * @internal