diff options
author | Robert Pösel <robyer@seznam.cz> | 2012-12-13 09:00:44 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2012-12-13 09:00:44 +0000 |
commit | a6203909a9b4bfbae252ab5b7c616309119d84b3 (patch) | |
tree | b19afdb59ac4afd10dba681ef7c47e16b375d37d /protocols/FacebookRM/src/messages.cpp | |
parent | e23f51997817bdaa549fbed05c9eabb83824c8ed (diff) |
FacebookRM: Experimental and buggy support for custom smileys
git-svn-id: http://svn.miranda-ng.org/main/trunk@2734 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/messages.cpp')
-rw-r--r-- | protocols/FacebookRM/src/messages.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index fb86195c58..d1bd01df6f 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -54,6 +54,8 @@ void FacebookProto::SendMsgWorker(void *p) }
else if ( !DBGetContactSettingString(data->hContact,m_szModuleName,FACEBOOK_KEY_ID,&dbv))
{
+ //parseSmileys(data->msg, data->hContact);
+
int retries = 5;
std::string error_text = "";
bool result = false;
@@ -180,3 +182,53 @@ void FacebookProto::MessagingWorker(void *p) delete data;
}
+
+void FacebookProto::parseSmileys(std::string message, HANDLE hContact)
+{
+ if (!DBGetContactSettingByte(NULL,m_szModuleName,FACEBOOK_KEY_CUSTOM_SMILEYS, DEFAULT_CUSTOM_SMILEYS))
+ return;
+
+ HANDLE nlc = NULL;
+ std::string::size_type pos = 0;
+ bool anything = false;
+ while ((pos = message.find("[[", pos)) != std::string::npos) {
+ std::string::size_type pos2 = message.find("]]", pos);
+ if (pos2 == std::string::npos)
+ break;
+
+ std::string smiley = message.substr(pos, pos2+2-pos);
+ pos = pos2;
+
+ std::string url = "http://graph.facebook.com/%s/picture";
+ utils::text::replace_first(&url, "%s", smiley.substr(2, smiley.length()-4));
+
+
+ size_t slen = smiley.length();
+ size_t rlen = Netlib_GetBase64EncodedBufferSize(slen);
+ char* buf = (char*)mir_alloc(rlen);
+
+ NETLIBBASE64 nlb = { buf, (int)rlen, (PBYTE)smiley.c_str(), (int)slen };
+ CallService(MS_NETLIB_BASE64ENCODE, 0, LPARAM(&nlb));
+
+ std::string b64 = buf;
+ b64 = utils::url::encode(b64);
+
+ std::tstring filename = GetAvatarFolder() + L"\\smileys\\" + (TCHAR*)_A2T(b64.c_str()) + _T(".jpg");
+ FILE *f = _tfopen(filename.c_str(), _T("r"));
+ if (!f) {
+ facy.save_url(url, filename, nlc);
+
+ TCHAR *path = _tcsdup(filename.c_str());
+
+ SMADD_CONT cont;
+ cont.cbSize = sizeof(SMADD_CONT);
+ cont.hContact = hContact;
+ cont.type = 1;
+ cont.path = path;
+
+ CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, (LPARAM)&cont);
+ mir_free(path);
+ } else
+ fclose(f);
+ }
+}
\ No newline at end of file |