From b7b31804c16a4fe9ebef1ae37b84ba96b130dd57 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Thu, 2 Aug 2007 18:31:46 +0000 Subject: [PATCH] add peer_blocked_alert --- src/deluge_core.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/deluge_core.cpp b/src/deluge_core.cpp index 03509ef5c..de8ff6cb0 100644 --- a/src/deluge_core.cpp +++ b/src/deluge_core.cpp @@ -86,6 +86,7 @@ using namespace libtorrent; #define EVENT_PIECE_FINISHED 15 #define EVENT_BLOCK_DOWNLOADING 16 #define EVENT_BLOCK_FINISHED 17 +#define EVENT_PEER_BLOCKED 18 #define STATE_QUEUED 0 #define STATE_CHECKING 1 @@ -376,7 +377,7 @@ static PyObject *torrent_init(PyObject *self, PyObject *args) M_ses->add_extension(&libtorrent::create_metadata_plugin); - M_constants = Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i}", + M_constants = Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i}", "EVENT_NULL", EVENT_NULL, "EVENT_FINISHED", EVENT_FINISHED, "EVENT_PEER_ERROR", EVENT_PEER_ERROR, @@ -394,6 +395,7 @@ static PyObject *torrent_init(PyObject *self, PyObject *args) "EVENT_PIECE_FINISHED", EVENT_PIECE_FINISHED, "EVENT_BLOCK_DOWNLOADING", EVENT_BLOCK_DOWNLOADING, "EVENT_BLOCK_FINISHED", EVENT_BLOCK_FINISHED, + "EVENT_PEER_BLOCKED", EVENT_PEER_BLOCKED, "STATE_QUEUED", STATE_QUEUED, "STATE_CHECKING", STATE_CHECKING, "STATE_CONNECTING", STATE_CONNECTING, @@ -1111,6 +1113,21 @@ static PyObject *torrent_pop_event(PyObject *self, PyObject *args) "message", a->msg().c_str()); else { Py_INCREF(Py_None); return Py_None; } + } else if (dynamic_cast(popped_alert)) + { + torrent_handle handle = (dynamic_cast(popped_alert))->handle; + long index = get_torrent_index(handle); + if (PyErr_Occurred()) + return NULL; + + if (handle_exists(handle)) + return Py_BuildValue("{s:i,s:i,s:i,s:s}", + "event_type", EVENT_PEER_BLOCKED, + "unique_ID", M_torrents->at(index).unique_ID, + "peer_ip", ip, + "message", a->msg().c_str()); + else + { Py_INCREF(Py_None); return Py_None; } } else if (dynamic_cast(popped_alert)) { torrent_handle handle = (dynamic_cast(popped_alert))->handle;