diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-09-19 08:54:00 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-09-19 08:54:00 +0000 |
commit | 9d19759010b01dad3f78123aff35a91891af64a4 (patch) | |
tree | 87443bd1b9bc666f1092c344e31a8c281d576de2 | |
parent | 768e066ae359cb58a4b3359da1fe46074b201fe9 (diff) |
SendSS: Dropbox sending rework
git-svn-id: http://svn.miranda-ng.org/main/trunk@15393 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/SendScreenshotPlus/src/CSendDropbox.cpp | 34 | ||||
-rw-r--r-- | plugins/SendScreenshotPlus/src/CSendDropbox.h | 5 |
2 files changed, 27 insertions, 12 deletions
diff --git a/plugins/SendScreenshotPlus/src/CSendDropbox.cpp b/plugins/SendScreenshotPlus/src/CSendDropbox.cpp index 507d61497a..400deea5fb 100644 --- a/plugins/SendScreenshotPlus/src/CSendDropbox.cpp +++ b/plugins/SendScreenshotPlus/src/CSendDropbox.cpp @@ -35,21 +35,19 @@ CSendDropbox::CSendDropbox(HWND Owner, MCONTACT hContact, bool bAsync) { /// @todo : re-enable SS_DLG_DELETEAFTERSSEND with full implemention of Dropbox upload with progress, msg and sounds m_EnableItem = SS_DLG_DESCRIPTION | SS_DLG_AUTOSEND/* | SS_DLG_DELETEAFTERSSEND*/; - m_pszSendTyp = LPGENT("Dropbox transfer"); + m_pszSendTyp = TranslateT("Dropbox transfer"); + m_hEvent = CreateEvent(NULL, 0, 0, NULL); } CSendDropbox::~CSendDropbox() { + CloseHandle(m_hEvent); } //--------------------------------------------------------------------------- int CSendDropbox::Send() { - if (!m_bAsync) { - SendThread(); - return 1; - } mir_forkthread(&CSendDropbox::SendThreadWrapper, this); return 0; } @@ -59,17 +57,29 @@ int CSendDropbox::Send() void CSendDropbox::SendThread() { /// @todo : SS_DLG_DESCRIPTION and SS_DLG_DELETEAFTERSSEND are of no use as of now since we don't track upload progress - INT_PTR ret = 0; - if (!m_hContact) - SetContact(db_find_first("Dropbox")); - if (m_hContact) - ret = CallService(MS_DROPBOX_SEND_FILE, (WPARAM)m_hContact, (LPARAM)m_pszFile); + INT_PTR ret = CallService(MS_DROPBOX_SEND_FILE, (WPARAM)m_hContact, (LPARAM)m_pszFile); if (!ret) { Error(LPGENT("%s (%i):\nCould not add a share to the Dropbox plugin."), TranslateTS(m_pszSendTyp), ret); Exit(ACKRESULT_FAILED); return; } - m_bSilent = true; - Exit(ACKRESULT_SUCCESS); + m_hDropSend = (HANDLE)ret; + //m_bSilent = true; + m_hDropHook = HookEventObj(ME_DROPBOX_SENT, OnDropSend, this); + WaitForSingleObject(m_hEvent, INFINITE); +} + +int CSendDropbox::OnDropSend(void *obj, WPARAM, LPARAM lParam) +{ + CSendDropbox *self = (CSendDropbox*)obj; + TRANSFERINFO *info = (TRANSFERINFO*)lParam; + if (info->hProcess == self->m_hDropSend && !info->status) + { + UnhookEvent(self->m_hDropHook); + self->m_URL = mir_strdup(info->data[0]); + self->svcSendMsgExit(self->m_URL); + SetEvent(self->m_hEvent); + } + return 0; } void CSendDropbox::SendThreadWrapper(void * Obj) diff --git a/plugins/SendScreenshotPlus/src/CSendDropbox.h b/plugins/SendScreenshotPlus/src/CSendDropbox.h index 0e439d57d0..cade8e9d8e 100644 --- a/plugins/SendScreenshotPlus/src/CSendDropbox.h +++ b/plugins/SendScreenshotPlus/src/CSendDropbox.h @@ -38,8 +38,13 @@ class CSendDropbox : public CSend { int Send(); protected: + HANDLE m_hEvent; + HANDLE m_hDropHook; + HANDLE m_hDropSend; + void SendThread(); static void SendThreadWrapper(void *Obj); + static int OnDropSend(void*, WPARAM, LPARAM); }; //--------------------------------------------------------------------------- |