diff options
-rw-r--r-- | protocols/SkypeWeb/src/requests/files.h | 16 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_files.cpp | 36 |
2 files changed, 46 insertions, 6 deletions
diff --git a/protocols/SkypeWeb/src/requests/files.h b/protocols/SkypeWeb/src/requests/files.h index d47b3637f3..0517385bf3 100644 --- a/protocols/SkypeWeb/src/requests/files.h +++ b/protocols/SkypeWeb/src/requests/files.h @@ -41,3 +41,19 @@ struct ASMObjectUploadRequest : public AsyncHttpRequest memcpy(m_szParam.GetBuffer(), data, size); } }; + +struct SendFileRequest : public AsyncHttpRequest +{ + SendFileRequest(const char *username, time_t timestamp, const char *message, const char *messageType, const char *asmRef) : + AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, 0, &CSkypeProto::OnMessageSent) + { + m_szUrl.AppendFormat("/users/ME/conversations/%s/messages", mir_urlEncode(username).c_str()); + + JSONNode node, ref(JSON_ARRAY); + ref.set_name("amsreferences"); ref.push_back(JSONNode("", asmRef)); + + node << INT64_PARAM("clientmessageid", timestamp) << CHAR_PARAM("messagetype", messageType) + << CHAR_PARAM("contenttype", "text") << CHAR_PARAM("content", message) << ref; + m_szParam = node.write().c_str(); + } +}; diff --git a/protocols/SkypeWeb/src/skype_files.cpp b/protocols/SkypeWeb/src/skype_files.cpp index 9eaef8b665..522e77dadd 100644 --- a/protocols/SkypeWeb/src/skype_files.cpp +++ b/protocols/SkypeWeb/src/skype_files.cpp @@ -88,19 +88,43 @@ void CSkypeProto::OnASMObjectUploaded(MHttpResponse *response, AsyncHttpRequest auto *pRoot = doc.NewElement("URIObject");
doc.InsertEndChild(pRoot);
+ pRoot->SetAttribute("doc_id", fup->uid.get());
+ pRoot->SetAttribute("uri", CMStringA(FORMAT, "https://api.asm.skype.com/v1/objects/%s", fup->uid.get()));
+
+ // is that a picture?
+ CMStringA href;
+ bool bIsPictture = false;
+ if (auto *pBitmap = FreeImage_LoadU(FreeImage_GetFIFFromFilenameU(fup->tszFileName), fup->tszFileName)) {
+ bIsPictture = true;
+ pRoot->SetAttribute("type", "File.1" /*"Picture.1"*/);
+ pRoot->SetAttribute("url_thumbnail", CMStringA(FORMAT, "https://api.asm.skype.com/v1/objects/%s/views/imgt1_anim", fup->uid.get()));
+ pRoot->SetAttribute("width", FreeImage_GetWidth(pBitmap));
+ pRoot->SetAttribute("height", FreeImage_GetHeight(pBitmap));
+ FreeImage_Unload(pBitmap);
+
+ href.Format("https://login.skype.com/login/sso?go=xmmfallback?pic=%s", fup->uid.get());
+ }
+ else {
+ pRoot->SetAttribute("type", "File.1");
+ pRoot->SetAttribute("url_thumbnail", CMStringA(FORMAT, "https://api.asm.skype.com/v1/objects/%s/views/original", fup->uid.get()));
+ href.Format("https://login.skype.com/login/sso?go=webclient.xmm&docid=%s", fup->uid.get());
+ }
+
auto *pTitle = doc.NewElement("Title"); pTitle->SetText(tszFile); pRoot->InsertEndChild(pTitle);
auto *pDescr = doc.NewElement("Description"); pDescr->SetText(fup->tszDesc.get()); pRoot->InsertEndChild(pDescr);
- auto *xmlA = doc.NewElement("a"); xmlA->SetText(CMStringA(FORMAT, "https://login.skype.com/login/sso?go=webclient.xmm&docid=%s", fup->uid.get()));
- xmlA->SetAttribute("href", CMStringA(FORMAT, "https://login.skype.com/login/sso?go=webclient.xmm&docid=%s", fup->uid.get()));
+ auto *xmlA = doc.NewElement("a"); xmlA->SetText(href);
+ xmlA->SetAttribute("href", href);
pRoot->InsertEndChild(xmlA);
auto *xmlOrigName = doc.NewElement("OriginalName"); xmlOrigName->SetAttribute("v", tszFile); pRoot->InsertEndChild(xmlOrigName);
auto *xmlSize = doc.NewElement("FileSize"); xmlSize->SetAttribute("v", (int)fup->size); pRoot->InsertEndChild(xmlSize);
- pRoot->SetAttribute("Type", "File.1");
- pRoot->SetAttribute("uri", CMStringA(FORMAT, "https://api.asm.skype.com/v1/objects/%s", fup->uid.get()));
- pRoot->SetAttribute("url_thumbnail", CMStringA(FORMAT, "https://api.asm.skype.com/v1/objects/%s/views/thumbnail", fup->uid.get()));
+ if (bIsPictture) {
+ auto xmlMeta = doc.NewElement("meta");
+ xmlMeta->SetAttribute("type", "photo"); xmlMeta->SetAttribute("originalName", tszFile);
+ pRoot->InsertEndChild(xmlMeta);
+ }
tinyxml2::XMLPrinter printer(0, true);
doc.Print(&printer);
@@ -110,7 +134,7 @@ void CSkypeProto::OnASMObjectUploaded(MHttpResponse *response, AsyncHttpRequest Utils_GetRandom(¶m->hMessage, sizeof(param->hMessage));
param->hMessage &= ~0x80000000;
- auto *pReq = new SendMessageRequest(getId(fup->hContact), time(NULL), printer.CStr(), "RichText/Media_GenericFile");
+ auto *pReq = new SendFileRequest(getId(fup->hContact), time(NULL), printer.CStr(), "RichText/Media_GenericFile", fup->uid);
pReq->pUserInfo = param;
PushRequest(pReq);
|