From b3950faf9b7f354df44b7272e5380c82034ffddb Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sun, 17 Feb 2008 23:46:44 +0000 Subject: [PATCH] Expose torrent_paused and torrent_checked alerts. --- src/deluge_core.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/deluge_core.cpp b/src/deluge_core.cpp index c10298c7f..3373b3283 100644 --- a/src/deluge_core.cpp +++ b/src/deluge_core.cpp @@ -95,6 +95,8 @@ using namespace libtorrent; #define EVENT_BLOCK_FINISHED 17 #define EVENT_PEER_BLOCKED 18 #define EVENT_LISTEN_FAILED 19 +#define EVENT_FINISHED_CHECKING 20 +#define EVENT_TORRENT_PAUSED 21 #define STATE_QUEUED 0 #define STATE_CHECKING 1 @@ -1602,8 +1604,37 @@ std::cout << asctime(timeinfo) << " torrent_pop_event()" << std::endl; "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:s}", + "event_type", EVENT_FINISHED_CHECKING, + "unique_ID", M_torrents->at(index).unique_ID, + "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:s}", + "event_type", EVENT_TORRENT_PAUSED, + "unique_ID", M_torrents->at(index).unique_ID, + "message", a->msg().c_str()); + else + { Py_INCREF(Py_None); return Py_None; } + } return Py_BuildValue("{s:i,s:s}", "event_type", EVENT_OTHER, "message", a->msg().c_str() ); }