First version of server side avatar upload feature (support for external avatar server). Still hard coded, cannot be configured.

This commit is contained in:
lotodore
2009-02-21 23:33:30 +00:00
parent f78de09078
commit e7c70ad9ad
14 changed files with 560 additions and 153 deletions
+3
View File
@@ -35,6 +35,7 @@
#define MAX_AVATAR_FILE_SIZE 30720
struct AvatarFileState;
class UploaderThread;
class AvatarManager
{
@@ -77,6 +78,8 @@ private:
mutable boost::mutex m_cacheDirMutex;
std::string m_cacheDir;
boost::shared_ptr<UploaderThread> m_uploader;
};
#endif
+6
View File
@@ -20,6 +20,7 @@
#include "avatarmanager.h"
#include <net/net_helper.h>
#include <net/socket_msg.h>
#include <net/uploaderthread.h>
#include <core/loghelper.h>
#include <core/crypthelper.h>
@@ -54,10 +55,13 @@ struct AvatarFileState
AvatarManager::AvatarManager()
{
m_uploader.reset(new UploaderThread());
}
AvatarManager::~AvatarManager()
{
m_uploader->SignalTermination();
m_uploader->Join(UPLOADER_THREAD_TERMINATE_TIMEOUT);
}
bool
@@ -87,6 +91,7 @@ AvatarManager::Init(const std::string &dataDir, const std::string &cacheDir)
retVal = retVal && tmpRet;
}
m_uploader->Run();
return retVal;
}
@@ -356,6 +361,7 @@ AvatarManager::StoreAvatarInCache(const MD5Buf &md5buf, AvatarFileType avatarFil
if (!o.fail())
{
o.write((const char *)data, size);
//m_uploader->QueueUpload(fileName, size);
{
boost::mutex::scoped_lock lock(m_cachedAvatarsMutex);
m_cachedAvatars.insert(AvatarMap::value_type(md5buf, fileName));