From d408de1957bcf6f07fefe94a1c4bb6a55791508b Mon Sep 17 00:00:00 2001 From: MikalaiR <nikolay.romanovich@narod.ru> Date: Thu, 24 Sep 2015 11:56:40 +0000 Subject: SendSS: dropbox fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@15431 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SendScreenshotPlus/src/CSendDropbox.cpp | 29 ++++++++++++++++++------- plugins/SendScreenshotPlus/src/CSendDropbox.h | 2 ++ 2 files changed, 23 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/SendScreenshotPlus/src/CSendDropbox.cpp b/plugins/SendScreenshotPlus/src/CSendDropbox.cpp index e1d59255f3..635a7f3673 100644 --- a/plugins/SendScreenshotPlus/src/CSendDropbox.cpp +++ b/plugins/SendScreenshotPlus/src/CSendDropbox.cpp @@ -58,21 +58,17 @@ 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 - if (!ServiceExists(MS_DROPBOX_SEND_FILE)) - { - Error(LPGENT("Dropbox plugin is not installed")); - Exit(ACKRESULT_FAILED); return; - } - m_hDropHook = HookEventObj(ME_DROPBOX_SENT, OnDropSend, this); + m_hOnAck = HookEventObj(ME_PROTO_ACK, OnDropAck, this); - if (!(m_hDropSend = (HANDLE)CallService(MS_DROPBOX_SEND_FILE, (WPARAM)m_hContact, (LPARAM)m_pszFile))) + if ((m_hDropSend = (HANDLE)CallService(MS_DROPBOX_SEND_FILE, (WPARAM)m_hContact, (LPARAM)m_pszFile)) == NULL) { Error(LPGENT("%s (%i):\nCould not add a share to the Dropbox plugin."), TranslateTS(m_pszSendTyp), (INT_PTR)m_hDropSend); Exit(ACKRESULT_FAILED); return; } - WaitForSingleObject(m_hEvent, 1000 * 60 * 5); + WaitForSingleObject(m_hEvent, INFINITE); + UnhookEvent(m_hOnAck); UnhookEvent(m_hDropHook); if (m_URL) @@ -96,6 +92,23 @@ int CSendDropbox::OnDropSend(void *obj, WPARAM, LPARAM lParam) return 0; } +int CSendDropbox::OnDropAck(void *obj, WPARAM, LPARAM lParam) +{ + CSendDropbox* self = (CSendDropbox*)obj; + ACKDATA *ack = (ACKDATA*)lParam; + if (ack->hProcess == self->m_hDropSend) + { + switch (ack->result) + { + case ACKRESULT_DENIED: + case ACKRESULT_FAILED: + SetEvent(self->m_hEvent); + break; + } + } + return 0; +} + void CSendDropbox::SendThreadWrapper(void * Obj) { reinterpret_cast<CSendDropbox*>(Obj)->SendThread(); diff --git a/plugins/SendScreenshotPlus/src/CSendDropbox.h b/plugins/SendScreenshotPlus/src/CSendDropbox.h index cade8e9d8e..83b2db142e 100644 --- a/plugins/SendScreenshotPlus/src/CSendDropbox.h +++ b/plugins/SendScreenshotPlus/src/CSendDropbox.h @@ -41,10 +41,12 @@ class CSendDropbox : public CSend { HANDLE m_hEvent; HANDLE m_hDropHook; HANDLE m_hDropSend; + HANDLE m_hOnAck; void SendThread(); static void SendThreadWrapper(void *Obj); static int OnDropSend(void*, WPARAM, LPARAM); + static int OnDropAck(void*, WPARAM, LPARAM); }; //--------------------------------------------------------------------------- -- cgit v1.2.3