Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: jabber_groupchat.cpp
- ===================================================================
- --- jabber_groupchat.cpp (revision 13904)
- +++ jabber_groupchat.cpp (working copy)
- @@ -1033,6 +1033,7 @@
- HXML n, m;
- const TCHAR *from, *type, *p, *nick, *resource;
- JABBER_LIST_ITEM *item;
- + CMString imgLink;
- if (!xmlGetName(node) || mir_tstrcmp(xmlGetName(node), _T("message"))) return;
- if ((from = xmlGetAttrValue(node, _T("from"))) == NULL) return;
- @@ -1073,6 +1074,8 @@
- item->getTemp()->m_tszStatusMessage = mir_tstrdup(msgText);
- }
- else {
- + imgLink = ExtractImage(node);
- +
- if ((n = xmlGetChildByTag(node, "body", "xml:lang", m_tszSelectedLang)) == NULL)
- if ((n = xmlGetChild(node, "body")) == NULL)
- return;
- @@ -1112,6 +1115,7 @@
- CMString tszText(msgText);
- tszText.Replace(_T("%"), _T("%%"));
- + tszText += imgLink;
- GCEVENT gce = { sizeof(gce), &gcd };
- gce.ptszUID = resource;
- Index: jabber_misc.cpp
- ===================================================================
- --- jabber_misc.cpp (revision 13904)
- +++ jabber_misc.cpp (working copy)
- @@ -499,3 +499,60 @@
- MessageBox(NULL, szMsg, szTitle, mtype);
- }
- }
- +
- +CMString CJabberProto::ExtractImage(HXML node)
- +{
- + HXML nHtml, nBody, nImg;
- + LPCTSTR src;
- + CMString link;
- +
- + if ((nHtml = xmlGetChild(node, "html")) != NULL &&
- + (nBody = xmlGetChild(nHtml, "body")) != NULL &&
- + (nImg = xmlGetChild(nBody, "img")) != NULL &&
- + (src = xmlGetAttrValue(nImg, _T("src"))) != NULL) {
- +
- + CMString strSrc(src);
- + if (strSrc.Left(11).Compare(L"data:image/") == 0) {
- + int end = strSrc.Find(L';');
- + if (end != -1) {
- + CMString ext(strSrc.c_str() + 11, end - 11);
- + int comma = strSrc.Find(L',', end);
- + if (comma != -1) {
- + CMString image(strSrc.c_str() + comma + 1, strSrc.GetLength() - comma - 1);
- + image.Replace(L"%2B", L"+");
- + image.Replace(L"%2F", L"/");
- + image.Replace(L"%3D", L"=");
- +
- + TCHAR tmppath[MAX_PATH];
- + GetTempPath(_countof(tmppath), tmppath);
- + static DWORD fileCtr = 0;
- + char digits[8];
- + ltoa(++fileCtr, digits, 36);
- + int nDigits = (int)strlen(digits);
- + CMString filename(tmppath);
- + for (int i = nDigits - 3; i < nDigits; i++) {
- + filename += (i < 0) ? '0' : digits[i];
- + }
- + filename += '.';
- + filename += ext;
- +
- + HANDLE h = CreateFile(filename, GENERIC_READ | GENERIC_WRITE,
- + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
- + FILE_ATTRIBUTE_NORMAL, NULL);
- +
- + if (h != INVALID_HANDLE_VALUE) {
- + DWORD n;
- + unsigned int bufferLen;
- + ptrA buffer((char*)mir_base64_decode(_T2A(image), &bufferLen));
- + WriteFile(h, buffer, bufferLen, &n, NULL);
- + CloseHandle(h);
- +
- + link = L" file:///";
- + link += filename;
- + }
- + }
- + }
- + }
- + }
- + return link;
- +}
- \ No newline at end of file
- Index: jabber_proto.h
- ===================================================================
- --- jabber_proto.h (revision 13904)
- +++ jabber_proto.h (working copy)
- @@ -598,6 +598,7 @@
- void SetContactOfflineStatus(MCONTACT hContact);
- void InitPopups(void);
- void MsgPopup(MCONTACT hContact, const TCHAR *szMsg, const TCHAR *szTitle);
- + CMString ExtractImage(HXML node);
- //---- jabber_opt.cpp ----------------------------------------------------------------
- INT_PTR __cdecl OnMenuHandleRosterControl(WPARAM wParam, LPARAM lParam);
- @@ -834,7 +835,7 @@
- DWORD STDMETHODCALLTYPE GetFlags() const; // Set of JIF_* flags.
- int STDMETHODCALLTYPE GetVersion() const; // Returns version of IJabberInterface.
- DWORD STDMETHODCALLTYPE GetJabberVersion() const; // Returns Jabber plugin version.
- -
- +
- int STDMETHODCALLTYPE CompareJIDs(LPCTSTR jid1, LPCTSTR jid2); // Strips resource names from given JIDs and returns result of comparison for these JIDs.
- MCONTACT STDMETHODCALLTYPE ContactFromJID(LPCTSTR jid); // Returns contact handle for given JID.
- LPTSTR STDMETHODCALLTYPE ContactToJID(MCONTACT hContact); // Returns JID of hContact. You must free the result using mir_free().
- @@ -857,7 +858,7 @@
- int STDMETHODCALLTYPE RemoveFeatures(LPCTSTR szFeatures); // Removes features from the list of features returned by the client.
- LPTSTR STDMETHODCALLTYPE GetResourceFeatures(LPCTSTR jid); // Returns all features supported by JID in format "feature1\0feature2\0...\0featureN\0\0". You must free returned string using mir_free().
- HANDLE STDMETHODCALLTYPE GetHandle(); // Returns connection handle
- -
- +
- private:
- JabberFeatCapPairDynamic *FindFeature(LPCTSTR szFeature);
- };
- Index: jabber_thread.cpp
- ===================================================================
- --- jabber_thread.cpp (revision 13904)
- +++ jabber_thread.cpp (working copy)
- @@ -1348,6 +1348,7 @@
- return;
- CMString tmp(szMessage);
- + tmp += ExtractImage(node);
- tmp.Replace(_T("\n"), _T("\r\n"));
- ptrA buf(mir_utf8encodeW(tmp));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement