diff options
author | George Hazan <george.hazan@gmail.com> | 2012-06-20 08:05:51 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-06-20 08:05:51 +0000 |
commit | 18540e71624543fd0181b764a6913aa6bf8eb75d (patch) | |
tree | 2fc7dc37339a353b53cbe878138ffd69227accfb /protocols/FacebookRM | |
parent | a00d983ecdb1d58e2bc7f7b3a6d1b3c2c169ae70 (diff) |
more avatar fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@498 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r-- | protocols/FacebookRM/avatars.cpp | 29 | ||||
-rw-r--r-- | protocols/FacebookRM/client.h | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/communication.cpp | 10 | ||||
-rw-r--r-- | protocols/FacebookRM/proto.cpp | 6 | ||||
-rw-r--r-- | protocols/FacebookRM/proto.h | 4 | ||||
-rw-r--r-- | protocols/FacebookRM/utils.cpp | 14 | ||||
-rw-r--r-- | protocols/FacebookRM/utils.h | 13 |
7 files changed, 38 insertions, 40 deletions
diff --git a/protocols/FacebookRM/avatars.cpp b/protocols/FacebookRM/avatars.cpp index 0b3bef5635..0ebfa7a558 100644 --- a/protocols/FacebookRM/avatars.cpp +++ b/protocols/FacebookRM/avatars.cpp @@ -27,12 +27,11 @@ Last change on : $Date: 2011-01-08 11:10:34 +0100 (so, 08 1 2011) $ #include "common.h"
-bool FacebookProto::GetDbAvatarInfo(PROTO_AVATAR_INFORMATIONT &ai, std::tstring *url)
+bool FacebookProto::GetDbAvatarInfo(PROTO_AVATAR_INFORMATIONT &ai, std::string *url)
{
DBVARIANT dbv;
- if (!DBGetContactSettingTString(ai.hContact, m_szModuleName, FACEBOOK_KEY_AV_URL, &dbv))
- {
- std::tstring new_url = dbv.ptszVal;
+ if (!DBGetContactSettingString(ai.hContact, m_szModuleName, FACEBOOK_KEY_AV_URL, &dbv)) {
+ std::string new_url = dbv.pszVal;
DBFreeVariant(&dbv);
if (new_url.empty())
@@ -41,10 +40,9 @@ bool FacebookProto::GetDbAvatarInfo(PROTO_AVATAR_INFORMATIONT &ai, std::tstring if (url)
*url = new_url;
- if (!DBGetContactSettingTString(ai.hContact, m_szModuleName, FACEBOOK_KEY_ID, &dbv))
- {
- std::tstring ext = new_url.substr(new_url.rfind('.'));
- std::tstring filename = GetAvatarFolder() + '\\' + dbv.ptszVal + ext;
+ if (!DBGetContactSettingTString(ai.hContact, m_szModuleName, FACEBOOK_KEY_ID, &dbv)) {
+ std::string ext = new_url.substr(new_url.rfind('.'));
+ std::tstring filename = GetAvatarFolder() + L'\\' + dbv.ptszVal + (TCHAR*)_A2T(ext.c_str());
DBFreeVariant(&dbv);
ai.hContact = ai.hContact;
@@ -58,7 +56,7 @@ bool FacebookProto::GetDbAvatarInfo(PROTO_AVATAR_INFORMATIONT &ai, std::tstring return false;
}
-void FacebookProto::CheckAvatarChange(HANDLE hContact, std::tstring image_url)
+void FacebookProto::CheckAvatarChange(HANDLE hContact, std::string image_url)
{
// Facebook contacts always have some avatar - keep avatar in database even if we have loaded empty one (e.g. for 'On Mobile' contacts)
if (image_url.empty())
@@ -80,7 +78,7 @@ void FacebookProto::CheckAvatarChange(HANDLE hContact, std::tstring image_url) }
if (update_required || !hContact)
{
- DBWriteContactSettingTString(hContact, m_szModuleName, FACEBOOK_KEY_AV_URL, image_url.c_str());
+ DBWriteContactSettingString(hContact, m_szModuleName, FACEBOOK_KEY_AV_URL, image_url.c_str());
if (hContact)
ProtoBroadcastAck(m_szModuleName, hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0);
else
@@ -100,7 +98,7 @@ void FacebookProto::UpdateAvatarWorker(void *) for (;;)
{
- std::tstring url;
+ std::string url;
PROTO_AVATAR_INFORMATIONT ai = {sizeof(ai)};
ai.hContact = avatar_queue[0];
@@ -113,7 +111,7 @@ void FacebookProto::UpdateAvatarWorker(void *) if (GetDbAvatarInfo(ai, &url))
{
LOG("***** Updating avatar: %s", url.c_str());
- bool success = facy.save_url(url, std::string(ai.filename), nlc);
+ bool success = facy.save_url(url, ai.filename, nlc);
if (ai.hContact)
ProtoBroadcastAck(m_szModuleName, ai.hContact, ACKTYPE_AVATAR, success ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, (HANDLE)&ai, 0);
@@ -129,10 +127,10 @@ void FacebookProto::UpdateAvatarWorker(void *) Netlib_CloseHandle(nlc);
}
-std::string FacebookProto::GetAvatarFolder()
+std::tstring FacebookProto::GetAvatarFolder()
{
TCHAR path[MAX_PATH];
- if ( hAvatarFolder_ && FoldersGetCustomPathT(hAvatarFolder_, path, SIZEOF(path), "") == 0 )
+ if ( hAvatarFolder_ && FoldersGetCustomPathT(hAvatarFolder_, path, SIZEOF(path), _T("")) == 0 )
return path;
else
return def_avatar_folder_;
@@ -181,10 +179,9 @@ int FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) return GAIR_NOAVATAR;
PROTO_AVATAR_INFORMATIONT* AI = (PROTO_AVATAR_INFORMATIONT*)lParam;
-
if (GetDbAvatarInfo(*AI, NULL))
{
- bool fileExist = _access(AI->filename, 0) == 0;
+ bool fileExist = _taccess(AI->filename, 0) == 0;
bool needLoad;
if (AI->hContact)
diff --git a/protocols/FacebookRM/client.h b/protocols/FacebookRM/client.h index b4874de23b..2e854c2c98 100644 --- a/protocols/FacebookRM/client.h +++ b/protocols/FacebookRM/client.h @@ -165,7 +165,7 @@ public: // HTTP communication
http::response flap( const int request_type, std::string* request_data = NULL, std::string* request_get_data = NULL );
- bool save_url(const std::string &url,const std::string &filename, HANDLE &nlc);
+ bool save_url(const std::string &url,const std::tstring &filename, HANDLE &nlc);
DWORD choose_security_level( int );
int choose_method( int );
diff --git a/protocols/FacebookRM/communication.cpp b/protocols/FacebookRM/communication.cpp index 4afb031cac..90296b18e0 100644 --- a/protocols/FacebookRM/communication.cpp +++ b/protocols/FacebookRM/communication.cpp @@ -1240,7 +1240,7 @@ bool facebook_client::set_status(const std::string &status_text) //////////////////////////////////////////////////////////////////////////////
-bool facebook_client::save_url(const std::string &url,const std::string &filename, HANDLE &nlc)
+bool facebook_client::save_url(const std::string &url,const std::tstring &filename, HANDLE &nlc)
{
NETLIBHTTPREQUEST req = {sizeof(req)};
NETLIBHTTPREQUEST *resp;
@@ -1258,12 +1258,12 @@ bool facebook_client::save_url(const std::string &url,const std::string &filenam parent->Log( "@@@@@ Saving avatar URL %s to path %s", url.c_str(), filename.c_str() );
// Create folder if necessary
- std::string dir = filename.substr(0,filename.rfind('\\'));
- if(_access(dir.c_str(),0))
- CallService(MS_UTILS_CREATEDIRTREE, 0, (LPARAM)dir.c_str());
+ std::tstring dir = filename.substr(0,filename.rfind('\\'));
+ if( _taccess(dir.c_str(),0))
+ CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)dir.c_str());
// Write to file
- FILE *f = fopen(filename.c_str(),"wb");
+ FILE *f = _tfopen(filename.c_str(), _T("wb"));
fwrite(resp->pData,1,resp->dataLength,f);
fclose(f);
diff --git a/protocols/FacebookRM/proto.cpp b/protocols/FacebookRM/proto.cpp index f53dce96db..e51a39f1dd 100644 --- a/protocols/FacebookRM/proto.cpp +++ b/protocols/FacebookRM/proto.cpp @@ -73,10 +73,10 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) SkinAddNewSoundExT( "NewsFeed", m_tszUserName, LPGENT( "News Feed" ) );
SkinAddNewSoundExT( "OtherEvent", m_tszUserName, LPGENT( "Other Event" ) );
- char *profile = Utils_ReplaceVars("%miranda_avatarcache%");
- def_avatar_folder_ = std::string(profile)+"\\"+m_szModuleName;
+ TCHAR *profile = Utils_ReplaceVarsT( _T("%miranda_avatarcache%"));
+ def_avatar_folder_ = std::tstring(profile) + _T("\\") + m_tszUserName;
mir_free(profile);
- hAvatarFolder_ = FoldersRegisterCustomPath(m_szModuleName, "Avatars", def_avatar_folder_.c_str());
+ hAvatarFolder_ = FoldersRegisterCustomPathT(m_szModuleName, "Avatars", def_avatar_folder_.c_str());
// Set all contacts offline -- in case we crashed
SetAllContactStatuses( ID_STATUS_OFFLINE );
diff --git a/protocols/FacebookRM/proto.h b/protocols/FacebookRM/proto.h index 3ce4af74a9..c08e3aaef2 100644 --- a/protocols/FacebookRM/proto.h +++ b/protocols/FacebookRM/proto.h @@ -186,7 +186,7 @@ public: facebook_client facy; // TODO: Refactor to "client" and make dynamic
// Helpers
- std::string GetAvatarFolder();
+ std::tstring GetAvatarFolder();
bool GetDbAvatarInfo(PROTO_AVATAR_INFORMATIONT &ai, std::string *url);
void CheckAvatarChange(HANDLE hContact, std::string image_url);
void ToggleStatusMenuItems( BOOL bEnable );
@@ -203,7 +203,7 @@ public: HANDLE m_hNetlibUser;
std::string last_status_msg_;
- std::string def_avatar_folder_;
+ std::tstring def_avatar_folder_;
HANDLE hAvatarFolder_;
std::vector<HANDLE> avatar_queue;
diff --git a/protocols/FacebookRM/utils.cpp b/protocols/FacebookRM/utils.cpp index 248bb432bd..e34238a372 100644 --- a/protocols/FacebookRM/utils.cpp +++ b/protocols/FacebookRM/utils.cpp @@ -423,6 +423,20 @@ void* __fastcall utils::mem::allocate(size_t size) return mir_calloc(size);
}
+struct
+{
+ char *ext;
+ int fmt;
+}
+static formats[] = {
+ { ".png", PA_FORMAT_PNG },
+ { ".jpg", PA_FORMAT_JPEG },
+ { ".jpeg", PA_FORMAT_JPEG },
+ { ".ico", PA_FORMAT_ICON },
+ { ".bmp", PA_FORMAT_BMP },
+ { ".gif", PA_FORMAT_GIF },
+};
+
int ext_to_format(const std::string &ext)
{
for(size_t i=0; i<SIZEOF(formats); i++)
diff --git a/protocols/FacebookRM/utils.h b/protocols/FacebookRM/utils.h index 25a92e4d9c..75712d6a2d 100644 --- a/protocols/FacebookRM/utils.h +++ b/protocols/FacebookRM/utils.h @@ -143,19 +143,6 @@ private: int timeout_;
};
-static const struct
-{
- char *ext;
- int fmt;
-} formats[] = {
- { ".png", PA_FORMAT_PNG },
- { ".jpg", PA_FORMAT_JPEG },
- { ".jpeg", PA_FORMAT_JPEG },
- { ".ico", PA_FORMAT_ICON },
- { ".bmp", PA_FORMAT_BMP },
- { ".gif", PA_FORMAT_GIF },
-};
-
int ext_to_format(const std::string &ext);
void MB( const char* m );
|