Server now requests unknown avatar files from client and stores them in the cache dir. Error handling is still missing. Clients not yet request avatar files from the server, this is the next step.

AvatarManager is now thread safe.
Default and cached avatars are handled in different lists to prevent deleting the default avatars when clearing the cache.
This commit is contained in:
lotodore
2007-10-07 15:52:12 +00:00
parent 28f33dea76
commit 639df29bdc
14 changed files with 319 additions and 91 deletions
+11 -4
View File
@@ -26,6 +26,7 @@
#include <core/crypthelper.h>
#include <map>
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
#define MAX_AVATAR_FILE_SIZE 30720
@@ -46,19 +47,25 @@ public:
bool AvatarFileToNetPackets(const std::string &fileName, unsigned requestId, NetPacketList &packets);
bool GetHashForAvatar(const std::string &fileName, MD5Buf &md5buf);
bool GetHashForAvatar(const std::string &fileName, MD5Buf &md5buf) const;
bool GetAvatarFileName(const MD5Buf &md5buf, std::string &fileName) const;
bool HasAvatar(const MD5Buf &md5buf) const;
bool StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFileType, const unsigned char *data, unsigned size);
protected:
typedef std::map<MD5Buf, std::string> AvatarMap;
void InternalReadDirectory(const std::string &dir);
bool InternalReadDirectory(const std::string &dir, AvatarMap &avatars);
private:
AvatarMap m_avatars;
mutable boost::mutex m_avatarsMutex;
AvatarMap m_avatars;
std::string m_cacheDir;
mutable boost::mutex m_cachedAvatarsMutex;
AvatarMap m_cachedAvatars;
mutable boost::mutex m_cacheDirMutex;
std::string m_cacheDir;
};
#endif