Advertisement
Guest User

Untitled

a guest
May 30th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.02 KB | None | 0 0
  1. Index: jabber_groupchat.cpp
  2. ===================================================================
  3. --- jabber_groupchat.cpp    (revision 13904)
  4. +++ jabber_groupchat.cpp    (working copy)
  5. @@ -1033,6 +1033,7 @@
  6.     HXML n, m;
  7.     const TCHAR *from, *type, *p, *nick, *resource;
  8.     JABBER_LIST_ITEM *item;
  9. +   CMString imgLink;
  10.  
  11.     if (!xmlGetName(node) || mir_tstrcmp(xmlGetName(node), _T("message"))) return;
  12.     if ((from = xmlGetAttrValue(node, _T("from"))) == NULL) return;
  13. @@ -1073,6 +1074,8 @@
  14.         item->getTemp()->m_tszStatusMessage = mir_tstrdup(msgText);
  15.     }
  16.     else {
  17. +       imgLink = ExtractImage(node);
  18. +
  19.         if ((n = xmlGetChildByTag(node, "body", "xml:lang", m_tszSelectedLang)) == NULL)
  20.             if ((n = xmlGetChild(node, "body")) == NULL)
  21.                 return;
  22. @@ -1112,6 +1115,7 @@
  23.  
  24.     CMString tszText(msgText);
  25.     tszText.Replace(_T("%"), _T("%%"));
  26. +   tszText += imgLink;
  27.  
  28.     GCEVENT gce = { sizeof(gce), &gcd };
  29.     gce.ptszUID = resource;
  30. Index: jabber_misc.cpp
  31. ===================================================================
  32. --- jabber_misc.cpp (revision 13904)
  33. +++ jabber_misc.cpp (working copy)
  34. @@ -499,3 +499,60 @@
  35.         MessageBox(NULL, szMsg, szTitle, mtype);
  36.     }
  37.  }
  38. +
  39. +CMString CJabberProto::ExtractImage(HXML node)
  40. +{
  41. +   HXML nHtml, nBody, nImg;
  42. +   LPCTSTR src;
  43. +   CMString link;
  44. +
  45. +   if ((nHtml = xmlGetChild(node, "html")) != NULL &&
  46. +       (nBody = xmlGetChild(nHtml, "body")) != NULL &&
  47. +       (nImg = xmlGetChild(nBody, "img")) != NULL &&
  48. +       (src = xmlGetAttrValue(nImg, _T("src"))) != NULL) {
  49. +
  50. +       CMString strSrc(src);
  51. +       if (strSrc.Left(11).Compare(L"data:image/") == 0) {
  52. +           int end = strSrc.Find(L';');
  53. +           if (end != -1) {
  54. +               CMString ext(strSrc.c_str() + 11, end - 11);
  55. +               int comma = strSrc.Find(L',', end);
  56. +               if (comma != -1) {
  57. +                   CMString image(strSrc.c_str() + comma + 1, strSrc.GetLength() - comma - 1);
  58. +                   image.Replace(L"%2B", L"+");
  59. +                   image.Replace(L"%2F", L"/");
  60. +                   image.Replace(L"%3D", L"=");
  61. +
  62. +                   TCHAR tmppath[MAX_PATH];
  63. +                   GetTempPath(_countof(tmppath), tmppath);
  64. +                   static DWORD fileCtr = 0;
  65. +                   char digits[8];
  66. +                   ltoa(++fileCtr, digits, 36);
  67. +                   int nDigits = (int)strlen(digits);
  68. +                   CMString filename(tmppath);
  69. +                   for (int i = nDigits - 3; i < nDigits; i++) {
  70. +                       filename += (i < 0) ? '0' : digits[i];
  71. +                   }
  72. +                   filename += '.';
  73. +                   filename += ext;
  74. +
  75. +                   HANDLE h = CreateFile(filename, GENERIC_READ | GENERIC_WRITE,
  76. +                       FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
  77. +                       FILE_ATTRIBUTE_NORMAL, NULL);
  78. +
  79. +                   if (h != INVALID_HANDLE_VALUE) {
  80. +                       DWORD n;
  81. +                       unsigned int bufferLen;
  82. +                       ptrA buffer((char*)mir_base64_decode(_T2A(image), &bufferLen));
  83. +                       WriteFile(h, buffer, bufferLen, &n, NULL);
  84. +                       CloseHandle(h);
  85. +
  86. +                       link = L" file:///";
  87. +                       link += filename;
  88. +                   }
  89. +               }
  90. +           }
  91. +       }
  92. +   }
  93. +   return link;
  94. +}
  95. \ No newline at end of file
  96. Index: jabber_proto.h
  97. ===================================================================
  98. --- jabber_proto.h  (revision 13904)
  99. +++ jabber_proto.h  (working copy)
  100. @@ -598,6 +598,7 @@
  101.     void   SetContactOfflineStatus(MCONTACT hContact);
  102.     void   InitPopups(void);
  103.     void   MsgPopup(MCONTACT hContact, const TCHAR *szMsg, const TCHAR *szTitle);
  104. +   CMString ExtractImage(HXML node);
  105.  
  106.     //---- jabber_opt.cpp ----------------------------------------------------------------
  107.     INT_PTR  __cdecl OnMenuHandleRosterControl(WPARAM wParam, LPARAM lParam);
  108. @@ -834,7 +835,7 @@
  109.     DWORD     STDMETHODCALLTYPE GetFlags() const;                    // Set of JIF_* flags.
  110.     int       STDMETHODCALLTYPE GetVersion() const;                  // Returns version of IJabberInterface.
  111.     DWORD     STDMETHODCALLTYPE GetJabberVersion() const;            // Returns Jabber plugin version.
  112. -              
  113. +
  114.     int       STDMETHODCALLTYPE CompareJIDs(LPCTSTR jid1, LPCTSTR jid2); // Strips resource names from given JIDs and returns result of comparison for these JIDs.
  115.     MCONTACT  STDMETHODCALLTYPE ContactFromJID(LPCTSTR jid);             // Returns contact handle for given JID.
  116.     LPTSTR    STDMETHODCALLTYPE ContactToJID(MCONTACT hContact);           // Returns JID of hContact. You must free the result using mir_free().
  117. @@ -857,7 +858,7 @@
  118.     int       STDMETHODCALLTYPE RemoveFeatures(LPCTSTR szFeatures); // Removes features from the list of features returned by the client.
  119.     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().
  120.     HANDLE    STDMETHODCALLTYPE GetHandle();                        // Returns connection handle
  121. -              
  122. +
  123.  private:
  124.     JabberFeatCapPairDynamic *FindFeature(LPCTSTR szFeature);
  125.  };
  126. Index: jabber_thread.cpp
  127. ===================================================================
  128. --- jabber_thread.cpp   (revision 13904)
  129. +++ jabber_thread.cpp   (working copy)
  130. @@ -1348,6 +1348,7 @@
  131.         return;
  132.  
  133.     CMString tmp(szMessage);
  134. +   tmp += ExtractImage(node);
  135.     tmp.Replace(_T("\n"), _T("\r\n"));
  136.     ptrA buf(mir_utf8encodeW(tmp));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement