summaryrefslogtreecommitdiff
path: root/plugins/SendScreenshotPlus
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-09-24 16:30:09 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-09-24 16:30:09 +0000
commit5cfd54b9152944f686c2ca2402e85280b3130f32 (patch)
treef0487a6e40e82743e729fa6e56b375dde334333d /plugins/SendScreenshotPlus
parentc35fd2f8545f73f5dacded24bd8124a9b575c98d (diff)
SendSS: correct version of prevoious commit
git-svn-id: http://svn.miranda-ng.org/main/trunk@15434 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SendScreenshotPlus')
-rw-r--r--plugins/SendScreenshotPlus/src/CSendDropbox.cpp27
-rw-r--r--plugins/SendScreenshotPlus/src/CSendDropbox.h5
-rw-r--r--plugins/SendScreenshotPlus/src/Utils.h13
3 files changed, 19 insertions, 26 deletions
diff --git a/plugins/SendScreenshotPlus/src/CSendDropbox.cpp b/plugins/SendScreenshotPlus/src/CSendDropbox.cpp
index 635a7f3673..30d01d22f8 100644
--- a/plugins/SendScreenshotPlus/src/CSendDropbox.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendDropbox.cpp
@@ -34,14 +34,12 @@ CSendDropbox::CSendDropbox(HWND Owner, MCONTACT hContact, bool bAsync)
: CSend(Owner, hContact, 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_EnableItem = SS_DLG_DESCRIPTION | SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND;
m_pszSendTyp = TranslateT("Dropbox transfer");
- m_hEvent = CreateEvent(NULL, 0, 0, NULL);
}
CSendDropbox::~CSendDropbox()
{
- CloseHandle(m_hEvent);
}
//---------------------------------------------------------------------------
@@ -59,7 +57,6 @@ 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
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)) == NULL)
{
@@ -67,8 +64,7 @@ void CSendDropbox::SendThread()
Exit(ACKRESULT_FAILED); return;
}
- WaitForSingleObject(m_hEvent, INFINITE);
- UnhookEvent(m_hOnAck);
+ m_hEvent.Wait();
UnhookEvent(m_hDropHook);
if (m_URL)
@@ -87,24 +83,7 @@ int CSendDropbox::OnDropSend(void *obj, WPARAM, LPARAM lParam)
{
self->m_URL = mir_strdup(info->data[0]);
}
- SetEvent(self->m_hEvent);
- }
- 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;
- }
+ self->m_hEvent.Set();
}
return 0;
}
diff --git a/plugins/SendScreenshotPlus/src/CSendDropbox.h b/plugins/SendScreenshotPlus/src/CSendDropbox.h
index 83b2db142e..66e644e537 100644
--- a/plugins/SendScreenshotPlus/src/CSendDropbox.h
+++ b/plugins/SendScreenshotPlus/src/CSendDropbox.h
@@ -29,6 +29,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef _CSEND_DROPBOX_FILE_H
#define _CSEND_DROPBOX_FILE_H
+#include "Utils.h"
+
//---------------------------------------------------------------------------
class CSendDropbox : public CSend {
public:
@@ -38,10 +40,9 @@ class CSendDropbox : public CSend {
int Send();
protected:
- HANDLE m_hEvent;
+ EventHandle m_hEvent;
HANDLE m_hDropHook;
HANDLE m_hDropSend;
- HANDLE m_hOnAck;
void SendThread();
static void SendThreadWrapper(void *Obj);
diff --git a/plugins/SendScreenshotPlus/src/Utils.h b/plugins/SendScreenshotPlus/src/Utils.h
index 0beeaabd18..94e5a73ea4 100644
--- a/plugins/SendScreenshotPlus/src/Utils.h
+++ b/plugins/SendScreenshotPlus/src/Utils.h
@@ -75,4 +75,17 @@ void SaveTIF(HBITMAP hBmp, TCHAR* szFilename);
//void ShowPopup(char *title, char *text);
*/
+
+class EventHandle
+{
+ HANDLE _hEvent;
+public:
+ inline EventHandle() { _hEvent = CreateEvent(NULL, 0, 0, NULL); }
+ inline ~EventHandle() { CloseHandle(_hEvent); }
+ inline void Set() { SetEvent(_hEvent); }
+ inline void Wait() { WaitForSingleObject(_hEvent, INFINITE); }
+ inline void Wait(DWORD dwMilliseconds) { WaitForSingleObject(_hEvent, dwMilliseconds); }
+ inline operator HANDLE() { return _hEvent; }
+};
+
#endif