summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_files.cpp
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2016-02-07 09:54:16 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2016-02-07 09:54:16 +0000
commit7bdabace3f6ab47b8571cdec9bfd6f5b2c360b46 (patch)
tree5d450c2098f6316df8bc3f42c7988c94eb1c2a0d /protocols/SkypeWeb/src/skype_files.cpp
parent941dca4cf7a93100c19a6e3b92e1bc6bf9e71f04 (diff)
SkypeWeb: files sending
git-svn-id: http://svn.miranda-ng.org/main/trunk@16233 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_files.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_files.cpp43
1 files changed, 31 insertions, 12 deletions
diff --git a/protocols/SkypeWeb/src/skype_files.cpp b/protocols/SkypeWeb/src/skype_files.cpp
index 38cb2f7357..451cf2d9dc 100644
--- a/protocols/SkypeWeb/src/skype_files.cpp
+++ b/protocols/SkypeWeb/src/skype_files.cpp
@@ -18,24 +18,24 @@ void CSkypeProto::SendFileThread(void *p)
//SendFileFiled(fup, VKERR_OFFLINE);
return;
}
- if (!fup->IsAccess()) {
- //SendFileFiled(fup, VKERR_FILE_NOT_EXIST);
- return;
- }
+// if (!fup->IsAccess()) {
+// //SendFileFiled(fup, VKERR_FILE_NOT_EXIST);
+// return;
+// }
- ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, (HANDLE)fup);
+ ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, (HANDLE)fup);
- SendRequest(new ASMObjectCreateRequest(li, CMStringA(FORMAT, "%d:%s", isChatRoom(fup->hContact) ? 19 : 8, ptrA(getStringA(fup->hContact, SKYPE_SETTINGS_ID)))), &CSkypeProto::OnASMObjectCreated, fup);
+ SendRequest(new ASMObjectCreateRequest(li, CMStringA(FORMAT, "%d:%s", isChatRoom(fup->hContact) ? 19 : 8, ptrA(getStringA(fup->hContact, SKYPE_SETTINGS_ID))), T2Utf(fup->tszFileName)), &CSkypeProto::OnASMObjectCreated, fup);
}
void CSkypeProto::OnASMObjectCreated(const NETLIBHTTPREQUEST *response, void *arg)
{
CFileUploadParam *fup = (CFileUploadParam*)arg;
- if (response->pData)
+ if (response && response->pData)
{
JSONNode node = JSONNode::parse((char*)response->pData);
std::string strObjectId = node["id"].as_string();
-
+ fup->uid = mir_strdup(strObjectId.c_str());
FILE *pFile = _tfopen(fup->tszFileName, _T("rb"));
if (pFile == NULL) return;
@@ -48,20 +48,39 @@ void CSkypeProto::OnASMObjectCreated(const NETLIBHTTPREQUEST *response, void *ar
}
fseek(pFile, 0, SEEK_SET);
-
- mir_ptr<BYTE> pData((PBYTE)mir_alloc(lFileLen));
+
+ mir_ptr<BYTE> pData((BYTE*)mir_alloc(lFileLen));
long lBytes = (long)fread(pData, sizeof(BYTE), lFileLen, pFile);
if (lBytes != lFileLen) {
+ fclose(pFile);
mir_free(pData);
return;
}
- SendRequest(new ASMObjectUploadRequest(li, strObjectId.c_str(), pData, lBytes));
+ fup->size = lBytes;
+ ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, (HANDLE)fup);
+ SendRequest(new ASMObjectUploadRequest(li, strObjectId.c_str(), pData, lBytes), &CSkypeProto::OnASMObjectUploaded, fup);
}
}
void CSkypeProto::OnASMObjectUploaded(const NETLIBHTTPREQUEST *response, void *arg)
{
CFileUploadParam *fup = (CFileUploadParam*)arg;
- char *szUrl = response->szUrl;
+ if (response == nullptr) return;
+ CMStringA url(response->szUrl);
+
+ HXML xml = xmlCreateNode(L"URIObject", nullptr, 0);
+ HXML xmlTitle = xmlAddChild(xml, L"Title", fup->tszFileName);
+ HXML xmlDescr = xmlAddChild(xml, L"Description", fup->tszDesc);
+ HXML xmlA = xmlAddChild(xml, L"a", CMStringW(FORMAT, L"https://login.skype.com/login/sso?go=webclient.xmm&docid=%s", _A2T(fup->uid)));
+ HXML xmlOrigName = xmlAddChild(xml, L"OriginalName", fup->tszFileName);
+ HXML xmlSize = xmlAddChild(xml, L"FileSize", CMStringW(FORMAT, L"%d", fup->size));
+
+ xmlAddAttr(xml, L"Type", L"File.1");
+ xmlAddAttr(xml, L"uri", CMStringW(FORMAT, L"https://api.asm.skype.com/v1/objects/%s", _A2T(fup->uid)));
+ xmlAddAttr(xml, L"url_thumbnail", CMStringW(FORMAT, L"https://api.asm.skype.com/v1/objects/%s/views/thumbnail", _A2T(fup->uid)));
+
+ SendRequest(new SendMessageRequest(ptrA(getStringA(fup->hContact, SKYPE_SETTINGS_ID)), time(NULL), T2Utf(xmlToString(xml, nullptr)), li, "RichText/Media_GenericFile"));
+ xmlDestroyNode(xml);
+ ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, (HANDLE)fup);
} \ No newline at end of file