summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_files.cpp
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-11-14 18:17:50 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-11-14 18:17:50 +0000
commit63691b42d4b0e3b47869183470a2b752f3667f39 (patch)
treec5d708df6e832bceb379c057d963cb466d590ce6 /protocols/SkypeWeb/src/skype_files.cpp
parente3e2ecff1cdd34b1fd389ea61e0410c7745e2a32 (diff)
forgotten file
git-svn-id: http://svn.miranda-ng.org/main/trunk@15726 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_files.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_files.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/protocols/SkypeWeb/src/skype_files.cpp b/protocols/SkypeWeb/src/skype_files.cpp
new file mode 100644
index 0000000000..38cb2f7357
--- /dev/null
+++ b/protocols/SkypeWeb/src/skype_files.cpp
@@ -0,0 +1,67 @@
+#include "stdafx.h"
+
+HANDLE CSkypeProto::SendFile(MCONTACT hContact, const TCHAR *szDescription, TCHAR **ppszFiles)
+{
+ if (IsOnline())
+ {
+ CFileUploadParam *fup = new CFileUploadParam(hContact, szDescription, ppszFiles);
+ ForkThread(&CSkypeProto::SendFileThread, (void*)fup);
+ return (HANDLE)fup;
+ }
+ return INVALID_HANDLE_VALUE;
+}
+
+void CSkypeProto::SendFileThread(void *p)
+{
+ CFileUploadParam *fup = (CFileUploadParam *)p;
+ if (!IsOnline()) {
+ //SendFileFiled(fup, VKERR_OFFLINE);
+ return;
+ }
+ if (!fup->IsAccess()) {
+ //SendFileFiled(fup, VKERR_FILE_NOT_EXIST);
+ return;
+ }
+
+ ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, (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);
+}
+
+void CSkypeProto::OnASMObjectCreated(const NETLIBHTTPREQUEST *response, void *arg)
+{
+ CFileUploadParam *fup = (CFileUploadParam*)arg;
+ if (response->pData)
+ {
+ JSONNode node = JSONNode::parse((char*)response->pData);
+ std::string strObjectId = node["id"].as_string();
+
+ FILE *pFile = _tfopen(fup->tszFileName, _T("rb"));
+ if (pFile == NULL) return;
+
+ fseek(pFile, 0, SEEK_END);
+ long lFileLen = ftell(pFile);
+
+ if(lFileLen < 1) {
+ fclose(pFile);
+ return;
+ }
+
+ fseek(pFile, 0, SEEK_SET);
+
+ mir_ptr<BYTE> pData((PBYTE)mir_alloc(lFileLen));
+ long lBytes = (long)fread(pData, sizeof(BYTE), lFileLen, pFile);
+
+ if (lBytes != lFileLen) {
+ mir_free(pData);
+ return;
+ }
+ SendRequest(new ASMObjectUploadRequest(li, strObjectId.c_str(), pData, lBytes));
+ }
+}
+
+void CSkypeProto::OnASMObjectUploaded(const NETLIBHTTPREQUEST *response, void *arg)
+{
+ CFileUploadParam *fup = (CFileUploadParam*)arg;
+ char *szUrl = response->szUrl;
+} \ No newline at end of file