Merge branch 'master' into xirvik

This commit is contained in:
rakshasa
2014-04-21 22:34:45 +09:00
27 changed files with 461 additions and 197 deletions
+3 -7
View File
@@ -1,4 +1,4 @@
AC_INIT(rtorrent, 0.9.3, jaris@ifi.uio.no)
AC_INIT(rtorrent, 0.9.3, sundell.software@gmail.com)
AC_DEFINE(API_VERSION, 8, api version)
@@ -41,15 +41,11 @@ CFLAGS="$CFLAGS $PTHREAD_CFLAGS $CURSES_CFLAGS"
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS $CURSES_CFLAGS"
LIBS="$PTHREAD_LIBS $CURSES_LIB $LIBS"
PKG_CHECK_MODULES(sigc, sigc++-2.0,
CXXFLAGS="$CXXFLAGS $sigc_CFLAGS";
LIBS="$LIBS $sigc_LIBS")
PKG_CHECK_MODULES(libcurl, libcurl >= 7.15.4,
PKG_CHECK_MODULES([libcurl], libcurl >= 7.15.4,
CXXFLAGS="$CXXFLAGS $libcurl_CFLAGS";
LIBS="$LIBS $libcurl_LIBS")
PKG_CHECK_MODULES(libtorrent, libtorrent >= 0.13.3,
PKG_CHECK_MODULES([libtorrent], libtorrent >= 0.13.3,
CXXFLAGS="$CXXFLAGS $libtorrent_CFLAGS";
LIBS="$LIBS $libtorrent_LIBS")
+47 -63
View File
@@ -507,29 +507,6 @@ Enable/disable peer exchange for torrents that aren't marked private. Disabled b
</para></listitem>
</varlistentry>
<varlistentry>
<term>schedule = <replaceable>id</replaceable>,<replaceable>start</replaceable>,<replaceable>interval</replaceable>,<replaceable>command</replaceable></term>
<listitem><para>
Call <emphasis>command</emphasis> every <emphasis>interval</emphasis>
seconds, starting from <emphasis>start</emphasis>. An
<emphasis>interval</emphasis> of zero calls the task once, while a
<emphasis>start</emphasis> of zero calls it immediately. Currently
<emphasis>command</emphasis> is forwarded to the option handler.
<emphasis>start</emphasis> and <emphasis>interval</emphasis> may
optionally use a time format, <emphasis>dd:hh:mm:ss</emphasis>. F.ex to
start a task every day at <emphasis>18:00</emphasis>, use
<emphasis>18:00:00,24:00:00</emphasis>.
</para></listitem>
</varlistentry>
<varlistentry>
<term>schedule_remove = <replaceable>id</replaceable></term>
<listitem><para>
Delete <emphasis>id</emphasis> from the scheduler.
</para></listitem>
</varlistentry>
<varlistentry>
<term>start_tied =</term>
<listitem><para>
@@ -580,40 +557,6 @@ torrent::input_error exception on bad input.
</para></listitem>
</varlistentry>
<varlistentry>
<term>stop_on_ratio = <replaceable>min_ratio</replaceable></term>
<term>stop_on_ratio = <replaceable>min_ratio</replaceable>,<replaceable>min_upload</replaceable></term>
<term>stop_on_ratio = <replaceable>min_ratio</replaceable>,<replaceable>min_upload</replaceable>,<replaceable>max_ratio</replaceable></term>
<listitem><para>
Stop torrents when they reach the given upload ratio
<emphasis>min_ratio</emphasis> in percent. If the optional
<emphasis>min_upload</emphasis> is given, require a total
upload amount of this many bytes as well. If the optional
<emphasis>max_ratio</emphasis> is given, stop the torrent
when reaching this ratio regardless of the total upload
amount. Exclude certain torrent by pressing
<emphasis>Shift+I</emphasis> in the downlist list.
Use with the <emphasis>schedule</emphasis> option.
</para></listitem>
</varlistentry>
<varlistentry>
<term>on_insert = <replaceable>id</replaceable>,<replaceable>command</replaceable></term>
<term>on_erase = <replaceable>id</replaceable>,<replaceable>command</replaceable></term>
<term>on_open = <replaceable>id</replaceable>,<replaceable>command</replaceable></term>
<term>on_close = <replaceable>id</replaceable>,<replaceable>command</replaceable></term>
<term>on_start = <replaceable>id</replaceable>,<replaceable>command</replaceable></term>
<term>on_stop = <replaceable>id</replaceable>,<replaceable>command</replaceable></term>
<term>on_hash_queued = <replaceable>id</replaceable>,<replaceable>command</replaceable></term>
<term>on_hash_removed = <replaceable>id</replaceable>,<replaceable>command</replaceable></term>
<term>on_hash_done = <replaceable>id</replaceable>,<replaceable>command</replaceable></term>
<term>on_finished = <replaceable>id</replaceable>,<replaceable>command</replaceable></term>
<listitem><para>
Call a command on a download when its state changes. Only a subset of
commands are available.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
@@ -629,6 +572,8 @@ commands are available.
<varlistentry>
<term>upload_rate = <replaceable>KB</replaceable></term>
<term>download_rate = <replaceable>KB</replaceable></term>
<term>set_upload_rate = <replaceable>TODO</replaceable></term>
<term>set_download_rate = <replaceable>TODO</replaceable></term>
<listitem><para>
Set the maximum global uploand and download rates.
</para></listitem>
@@ -653,14 +598,19 @@ Set the minimum nad maximum number of peers to allow while seeding, or
<varlistentry>
<term>max_uploads = <replaceable>value</replaceable></term>
<term>max_downloads = <replaceable>value</replaceable></term>
<term>min_uploads = <replaceable>value</replaceable></term>
<term>min_downloads = <replaceable>value</replaceable></term>
<listitem><para>
Set the maximum number of simultaneous uploads per download.
Set the maximum/minimum number of simultaneous uploads/downloads per download/upload.
</para></listitem>
</varlistentry>
<varlistentry>
<term>max_uploads_div = <replaceable>value</replaceable></term>
<term>max_downloads_div = <replaceable>value</replaceable></term>
<term>set_max_uploads_div = <replaceable>value</replaceable></term>
<term>set_max_downloads_div = <replaceable>value</replaceable></term>
<listitem><para>
Change the divider used to calculate the max upload and download slots
to use when the throttle is changed. Disable by
@@ -671,6 +621,8 @@ setting <emphasis>0</emphasis>.
<varlistentry>
<term>max_uploads_global = <replaceable>value</replaceable></term>
<term>max_downloads_global = <replaceable>value</replaceable></term>
<term>set_max_uploads_global = <replaceable>value</replaceable></term>
<term>set_max_downloads_global = <replaceable>value</replaceable></term>
<listitem><para>
Max upload and download slots allowed. Disable by
setting <emphasis>0</emphasis>.
@@ -746,6 +698,27 @@ not allow connections to UDP trackers.
</para></listitem>
</varlistentry>
<varlistentry>
<term>http_capath = <replaceable>path</replaceable></term>
<term>http_cacert = <replaceable>filename</replaceable></term>
<listitem><para>
Set the certificates to use in http requests. See Curl's
CURLOPT_CAPATH and CURLOPT_CAINFO options for further information.
</para></listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>DHT-RELATED SETTINGS</title>
<para>
Settings related to DHT
</para>
<variablelist>
<varlistentry>
<term>dht = <replaceable>disabled|off|auto|on</replaceable></term>
<listitem><para>
@@ -779,11 +752,23 @@ The port is optional, with port 6881 being used by default.
</varlistentry>
<varlistentry>
<term>http_capath = <replaceable>path</replaceable></term>
<term>http_cacert = <replaceable>filename</replaceable></term>
<term>dht_statistics = <replaceable>TODO</replaceable></term>
<listitem><para>
Set the certificates to use in http requests. See Curl's
CURLOPT_CAPATH and CURLOPT_CAINFO options for further information.
TODO
</para></listitem>
</varlistentry>
<varlistentry>
<term>set_dht_port = <replaceable>TODO</replaceable></term>
<listitem><para>
TODO
</para></listitem>
</varlistentry>
<varlistentry>
<term>set_dht_throttle = <replaceable>TODO</replaceable></term>
<listitem><para>
TODO
</para></listitem>
</varlistentry>
@@ -791,7 +776,6 @@ CURLOPT_CAPATH and CURLOPT_CAINFO options for further information.
</refsect1>
<refsect1>
<title>USER-INTERFACE SETTINGS</title>
<para>
+49
View File
@@ -0,0 +1,49 @@
#/bin/bash
gnuplot << EOF
set terminal png size 1024,768 enhanced
set xdata time
set timefmt "%s"
set format x "%H:%M"
set y2tics
set autoscale xfix
set key autotitle columnhead
# set datafile missing '0'
set format y "%.0f"
set format y2 "%.0f"
set yrange [0:]
set y2range [0:]
set output "output_$1_transfer_requests.png"
plot \
"instrumentation_transfers.log.$1" using 1:2 title 'delegated' with lines lw 4 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:3 title 'downloading' with lines lw 4 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:4 title 'finished' with lines lw 4 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:5 title 'skipped' with lines lw 2 axis x1y2,\
"instrumentation_transfers.log.$1" using 1:6 title 'unknown' with lines lw 2 axis x1y2,\
"instrumentation_transfers.log.$1" using 1:7 title 'unordered' with lines lw 2 axis x1y2,\
"instrumentation_transfers.log.$1" using 1:19 title 'unaccounted' with lines lw 2 axis x1y2
set output "output_$1_transfer_queues.png"
plot \
"instrumentation_transfers.log.$1" using 1:8 title 'queue added' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:9 title 'queue moved' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:10 title 'queue removed' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:11 title 'queue total' with lines lw 4 axis x1y2,\
"instrumentation_transfers.log.$1" using 1:12 title 'unordered added' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:13 title 'unordered moved' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:14 title 'unordered removed' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:15 title 'unordered total' with lines lw 4 axis x1y2,\
"instrumentation_transfers.log.$1" using 1:16 title 'stalled added' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:17 title 'stalled moved' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:18 title 'stalled removed' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:19 title 'stalled total' with lines lw 4 axis x1y2,\
"instrumentation_transfers.log.$1" using 1:20 title 'choked added' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:21 title 'choked moved' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:22 title 'choked removed' with lines lw 2 axis x1y1,\
"instrumentation_transfers.log.$1" using 1:23 title 'choked total' with lines lw 4 axis x1y2
EOF
+30
View File
@@ -0,0 +1,30 @@
#/bin/bash
gnuplot << EOF
set terminal png size 1024,768 enhanced
set xdata time
set timefmt "%s"
set format x "%H:%M"
set y2tics
set autoscale xfix
set key autotitle columnhead
set format y "%.0f"
set format y2 "%.0f"
set output "output_$1_incore_sync.png"
plot \
"instrumentation_mincore.log.$1" using 1:6 title 'success' smooth sbezier with lines lw 4 axis x1y1,\
"instrumentation_mincore.log.$1" using 1:7 title 'failed' smooth sbezier with lines lw 4 axis x1y1,\
"instrumentation_mincore.log.$1" using 1:8 title 'not synced' smooth sbezier with lines lw 4 axis x1y2,\
"instrumentation_mincore.log.$1" using 1:9 title 'not deallocated' smooth sbezier with lines lw 4 axis x1y2
set format y "%.0g"
set output "output_$1_incore_alloc.png"
plot \
"instrumentation_mincore.log.$1" using 1:12 title 'allocations' smooth sbezier with lines lw 2 axis x1y1,\
"instrumentation_mincore.log.$1" using 1:13 title 'deallocations' smooth sbezier with lines lw 4 axis x1y1,\
"instrumentation_mincore.log.$1" using 1:10 title 'alloc failed' smooth sbezier with lines lw 2 axis x1y2
EOF
+51
View File
@@ -627,6 +627,57 @@ make_mem_fun(Object* o, Ret (Object::*f)(Arg1, Arg2, Arg3)) {
return mem_fun3<Object, Ret, Arg1, Arg2, Arg3>(o, f);
}
template <typename Container>
inline void
slot_list_call(const Container& slot_list) {
if (slot_list.empty())
return;
typename Container::const_iterator first = slot_list.begin();
typename Container::const_iterator next = slot_list.begin();
while (++next != slot_list.end()) {
(*first)();
first = next;
}
(*first)();
}
template <typename Container, typename Arg1>
inline void
slot_list_call(const Container& slot_list, Arg1 arg1) {
if (slot_list.empty())
return;
typename Container::const_iterator first = slot_list.begin();
typename Container::const_iterator next = slot_list.begin();
while (++next != slot_list.end()) {
(*first)(arg1);
first = next;
}
(*first)(arg1);
}
template <typename Container, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
inline void
slot_list_call(const Container& slot_list, Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4) {
if (slot_list.empty())
return;
typename Container::const_iterator first = slot_list.begin();
typename Container::const_iterator next = slot_list.begin();
while (++next != slot_list.end()) {
(*first)(arg1, arg2, arg3, arg4);
first = next;
}
(*first)(arg1, arg2, arg3, arg4);
}
}
#endif
+3
View File
@@ -49,6 +49,9 @@ class timer {
timer(int64_t usec = 0) : m_time(usec) {}
timer(timeval tv) : m_time((int64_t)(uint32_t)tv.tv_sec * 1000000 + (int64_t)(uint32_t)tv.tv_usec % 1000000) {}
bool is_zero() const { return m_time == 0; }
bool is_not_zero() const { return m_time != 0; }
int32_t seconds() const { return m_time / 1000000; }
int32_t seconds_ceiling() const { return (m_time + 1000000 - 1) / 1000000; }
int64_t usec() const { return m_time; }
+43 -14
View File
@@ -21,9 +21,9 @@ AC_DEFUN([TORRENT_CHECK_XFS], [
AC_DEFUN([TORRENT_WITHOUT_XFS], [
AC_ARG_WITH(xfs,
[ --without-xfs Do not check for XFS filesystem support],
AC_HELP_STRING([--without-xfs], [do not check for XFS filesystem support]),
[
if test "$withval" = "yes"; then
if test "$withval" = "yes"; then
TORRENT_CHECK_XFS
fi
], [
@@ -34,7 +34,7 @@ AC_DEFUN([TORRENT_WITHOUT_XFS], [
AC_DEFUN([TORRENT_WITH_XFS], [
AC_ARG_WITH(xfs,
[ --with-xfs Check for XFS filesystem support],
AC_HELP_STRING([--with-xfs], [check for XFS filesystem support]),
[
if test "$withval" = "yes"; then
TORRENT_CHECK_XFS
@@ -63,7 +63,7 @@ AC_DEFUN([TORRENT_CHECK_EPOLL], [
AC_DEFUN([TORRENT_WITHOUT_EPOLL], [
AC_ARG_WITH(epoll,
[ --without-epoll Do not check for epoll support.],
AC_HELP_STRING([--without-epoll], [do not check for epoll support]),
[
if test "$withval" = "yes"; then
TORRENT_CHECK_EPOLL
@@ -133,7 +133,7 @@ AC_DEFUN([TORRENT_CHECK_KQUEUE_SOCKET_ONLY], [
AC_DEFUN([TORRENT_WITH_KQUEUE], [
AC_ARG_WITH(kqueue,
[ --with-kqueue enable kqueue. [[default=no]]],
AC_HELP_STRING([--with-kqueue], [enable kqueue [[default=no]]]),
[
if test "$withval" = "yes"; then
TORRENT_CHECK_KQUEUE
@@ -145,7 +145,7 @@ AC_DEFUN([TORRENT_WITH_KQUEUE], [
AC_DEFUN([TORRENT_WITHOUT_KQUEUE], [
AC_ARG_WITH(kqueue,
[ --without-kqueue Do not check for kqueue support.],
AC_HELP_STRING([--without-kqueue], [do not check for kqueue support]),
[
if test "$withval" = "yes"; then
TORRENT_CHECK_KQUEUE
@@ -160,8 +160,7 @@ AC_DEFUN([TORRENT_WITHOUT_KQUEUE], [
AC_DEFUN([TORRENT_WITHOUT_VARIABLE_FDSET], [
AC_ARG_WITH(variable-fdset,
[ --without-variable-fdset do not use non-portable variable sized fd_set's.],
AC_HELP_STRING([--without-variable-fdset], [do not use non-portable variable sized fd_set's]),
[
if test "$withval" = "yes"; then
AC_DEFINE(USE_VARIABLE_FDSET, 1, defined when we allow the use of fd_set's of any size)
@@ -205,7 +204,7 @@ AC_DEFUN([TORRENT_CHECK_POSIX_FALLOCATE], [
AC_DEFUN([TORRENT_WITH_POSIX_FALLOCATE], [
AC_ARG_WITH(posix-fallocate,
[ --with-posix-fallocate Check for and use posix_fallocate to allocate files.],
AC_HELP_STRING([--with-posix-fallocate], [check for and use posix_fallocate to allocate files]),
[
if test "$withval" = "yes"; then
TORRENT_CHECK_POSIX_FALLOCATE
@@ -299,7 +298,7 @@ AC_DEFUN([TORRENT_DISABLED_STATFS], [
AC_DEFUN([TORRENT_WITHOUT_STATVFS], [
AC_ARG_WITH(statvfs,
[ --without-statvfs Don't try to use statvfs to find free diskspace.],
AC_HELP_STRING([--without-statvfs], [don't try to use statvfs to find free diskspace]),
[
if test "$withval" = "yes"; then
TORRENT_CHECK_STATVFS
@@ -314,7 +313,7 @@ AC_DEFUN([TORRENT_WITHOUT_STATVFS], [
AC_DEFUN([TORRENT_WITHOUT_STATFS], [
AC_ARG_WITH(statfs,
[ --without-statfs Don't try to use statfs to find free diskspace.],
AC_HELP_STRING([--without-statfs], [don't try to use statfs to find free diskspace]),
[
if test "$have_stat_vfs" = "no"; then
if test "$withval" = "yes"; then
@@ -336,7 +335,7 @@ AC_DEFUN([TORRENT_WITHOUT_STATFS], [
AC_DEFUN([TORRENT_WITH_ADDRESS_SPACE], [
AC_ARG_WITH(address-space,
AC_HELP_STRING([--with-address-space=MB], [Change the default address space size, default 1024 MB.]),
AC_HELP_STRING([--with-address-space=MB], [change the default address space size [[default=1024mb]]]),
[
if test ! -z $withval -a "$withval" != "yes" -a "$withval" != "no"; then
AC_DEFINE_UNQUOTED(DEFAULT_ADDRESS_SPACE_SIZE, [$withval])
@@ -402,7 +401,7 @@ AC_DEFUN([TORRENT_CHECK_CXX11], [
AC_DEFUN([TORRENT_WITH_FASTCGI], [
AC_ARG_WITH(fastcgi,
[ --with-fastcgi=PATH Enable FastCGI RPC support. (DO NOT USE)],
AC_HELP_STRING([--with-fastcgi=PATH], [enable FastCGI RPC support (DO NOT USE)]),
[
AC_MSG_CHECKING([for FastCGI (DO NOT USE)])
@@ -451,7 +450,7 @@ AC_DEFUN([TORRENT_WITH_XMLRPC_C], [
AC_MSG_CHECKING(for XMLRPC-C)
AC_ARG_WITH(xmlrpc-c,
[ --with-xmlrpc-c=PATH Enable XMLRPC-C support.],
AC_HELP_STRING([--with-xmlrpc-c=PATH], [enable XMLRPC-C support]),
[
if test "$withval" = "no"; then
AC_MSG_RESULT(no)
@@ -508,3 +507,33 @@ AC_DEFUN([TORRENT_WITH_INOTIFY], [
AC_LANG_POP(C++)
])
AC_DEFUN([TORRENT_CHECK_PTHREAD_SETNAME_NP], [
AC_CHECK_HEADERS(pthread.h)
AC_MSG_CHECKING(for pthread_setname_np type)
AC_TRY_LINK([
#include <pthread.h>
#include <sys/types.h>
],[
pthread_t t;
pthread_setname_np(t, "foo");
],[
AC_DEFINE(HAS_PTHREAD_SETNAME_NP_GENERIC, 1, The function to set pthread name has a pthread_t argumet.)
AC_MSG_RESULT(generic)
],[
AC_TRY_LINK([
#include <pthread.h>
#include <sys/types.h>
],[
pthread_t t;
pthread_setname_np("foo");
],[
AC_DEFINE(HAS_PTHREAD_SETNAME_NP_DARWIN, 1, The function to set pthread name has no pthread argument.)
AC_MSG_RESULT(darwin)
],[
AC_MSG_RESULT(no)
])
])
])
+41 -10
View File
@@ -13,7 +13,7 @@ AC_DEFUN([TORRENT_CHECK_CXXFLAGS], [
AC_DEFUN([TORRENT_ENABLE_DEBUG], [
AC_ARG_ENABLE(debug,
[ --enable-debug enable debug information [[default=yes]]],
AC_HELP_STRING([--enable-debug], [enable debug information [[default=yes]]]),
[
if test "$enableval" = "yes"; then
CXXFLAGS="$CXXFLAGS -g -DDEBUG"
@@ -28,7 +28,7 @@ AC_DEFUN([TORRENT_ENABLE_DEBUG], [
AC_DEFUN([TORRENT_ENABLE_WERROR], [
AC_ARG_ENABLE(werror,
[ --enable-werror enable the -Werror and -Wall flag [[default=no]]],
AC_HELP_STRING([--enable-werror], [enable the -Werror and -Wall flag [[default=no]]]),
[
if test "$enableval" = "yes"; then
CXXFLAGS="$CXXFLAGS -Werror -Wall"
@@ -39,7 +39,7 @@ AC_DEFUN([TORRENT_ENABLE_WERROR], [
AC_DEFUN([TORRENT_ENABLE_EXTRA_DEBUG], [
AC_ARG_ENABLE(extra-debug,
[ --enable-extra-debug enable extra debugging checks. [[default=no]]],
AC_HELP_STRING([--enable-extra-debug], [enable extra debugging checks [[default=no]]]),
[
if test "$enableval" = "yes"; then
AC_DEFINE(USE_EXTRA_DEBUG, 1, Enable extra debugging checks.)
@@ -50,7 +50,7 @@ AC_DEFUN([TORRENT_ENABLE_EXTRA_DEBUG], [
AC_DEFUN([TORRENT_WITH_SYSROOT], [
AC_ARG_WITH(sysroot,
[ --with-sysroot=PATH compile and link with a specific sysroot.],
AC_HELP_STRING([--with-sysroot=PATH], [compile and link with a specific sysroot]),
[
AC_MSG_CHECKING(for sysroot)
@@ -72,7 +72,7 @@ AC_DEFUN([TORRENT_WITH_SYSROOT], [
AC_DEFUN([TORRENT_ENABLE_ARCH], [
AC_ARG_ENABLE(arch,
[ --enable-arch=ARCH comma seprated list of architectures to compile for.],
AC_HELP_STRING([--enable-arch=ARCH], [comma seprated list of architectures to compile for]),
[
AC_MSG_CHECKING(for target architectures)
@@ -152,7 +152,7 @@ AC_DEFUN([TORRENT_MINCORE_SIGNEDNESS], [
AC_DEFUN([TORRENT_MINCORE], [
AC_ARG_ENABLE(mincore,
[ --disable-mincore disable mincore check [[default=enable]]],
AC_HELP_STRING([--disable-mincore], [disable mincore check [[default=enable]]]),
[
if test "$enableval" = "yes"; then
TORRENT_MINCORE_SIGNEDNESS()
@@ -259,7 +259,7 @@ AC_DEFUN([TORRENT_CHECK_ALIGNED], [
AC_DEFUN([TORRENT_ENABLE_ALIGNED], [
AC_ARG_ENABLE(aligned,
[ --enable-aligned enable alignment safe code [[default=check]]],
AC_HELP_STRING([--enable-aligned], [enable alignment safe code [[default=check]]]),
[
if test "$enableval" = "yes"; then
AC_DEFINE(USE_ALIGNED, 1, Require byte alignment)
@@ -270,9 +270,40 @@ AC_DEFUN([TORRENT_ENABLE_ALIGNED], [
])
AC_DEFUN([TORRENT_DISABLE_INSTRUMENTATION], [
AC_MSG_CHECKING([if instrumentation should be included])
AC_ARG_ENABLE(instrumentation,
AC_HELP_STRING([--disable-instrumentation], [disable instrumentation [[default=enabled]]]),
[
if test "$enableval" = "yes"; then
AC_DEFINE(LT_INSTRUMENTATION, 1, enable instrumentation)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
],[
AC_DEFINE(LT_INSTRUMENTATION, 1, enable instrumentation)
AC_MSG_RESULT(yes)
])
])
AC_DEFUN([TORRENT_ENABLE_INTERRUPT_SOCKET], [
AC_ARG_ENABLE(interrupt-socket,
AC_HELP_STRING([--enable-interrupt-socket], [enable interrupt socket [[default=no]]]),
[
if test "$enableval" = "yes"; then
AC_DEFINE(USE_INTERRUPT_SOCKET, 1, Use interrupt socket instead of pthread_kill)
fi
]
)
])
AC_DEFUN([TORRENT_DISABLE_IPV6], [
AC_ARG_ENABLE(ipv6,
[ --enable-ipv6 disable ipv6 [[default=no]]],
AC_HELP_STRING([--enable-ipv6], [enable ipv6 [[default=no]]]),
[
if test "$enableval" = "yes"; then
AC_DEFINE(RAK_USE_INET6, 1, enable ipv6 stuff)
@@ -282,7 +313,7 @@ AC_DEFUN([TORRENT_DISABLE_IPV6], [
AC_DEFUN([TORRENT_ENABLE_TR1], [
AC_ARG_ENABLE(std_tr1,
[ --disable-std_tr1 disable check for support for TR1 [[default=enable]]],
AC_HELP_STRING([--disable-std_tr1], [disable check for support for TR1 [[default=enable]]]),
[
if test "$enableval" = "yes"; then
TORRENT_CHECK_TR1()
@@ -297,7 +328,7 @@ AC_DEFUN([TORRENT_ENABLE_TR1], [
AC_DEFUN([TORRENT_ENABLE_CXX11], [
AC_ARG_ENABLE(std_c++11,
[ --disable-std_c++11 disable check for support for C++11 [[default=enable]]],
AC_HELP_STRING([--disable-std_c++11], [disable check for support for C++11 [[default=enable]]]),
[
if test "$enableval" = "yes"; then
TORRENT_CHECK_CXX11()
+13 -2
View File
@@ -287,6 +287,16 @@ apply_log_open_file(const torrent::Object::list_type& args) {
return torrent::Object();
}
torrent::Object
apply_log_open_gz_file(const torrent::Object::list_type& args) {
if (args.size() != 2)
throw torrent::input_error("Invalid number of arguments.");
torrent::log_open_gz_file_output(args.front().as_string().c_str(),
rak::path_expand(args.back().as_string()).c_str());
return torrent::Object();
}
torrent::Object
apply_log_add_output(const torrent::Object::list_type& args) {
if (args.size() != 2)
@@ -391,8 +401,9 @@ initialize_command_local() {
CMD2_EXECUTE ("execute.capture", rpc::ExecFile::flag_throw | rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_capture);
CMD2_EXECUTE ("execute.capture_nothrow", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_capture);
CMD2_ANY_LIST ("log.open_file", tr1::bind(&apply_log_open_file, tr1::placeholders::_2));
CMD2_ANY_LIST ("log.add_output", tr1::bind(&apply_log_add_output, tr1::placeholders::_2));
CMD2_ANY_LIST ("log.open_file", tr1::bind(&apply_log_open_file, tr1::placeholders::_2));
CMD2_ANY_LIST ("log.open_gz_file", tr1::bind(&apply_log_open_gz_file, tr1::placeholders::_2));
CMD2_ANY_LIST ("log.add_output", tr1::bind(&apply_log_add_output, tr1::placeholders::_2));
CMD2_ANY_STRING ("log.execute", tr1::bind(&apply_log, tr1::placeholders::_2, 0));
CMD2_ANY_STRING ("log.vmmap.dump", tr1::bind(&log_vmmap_dump, tr1::placeholders::_2));
+3 -1
View File
@@ -247,7 +247,9 @@ initialize_command_network() {
CMD2_VAR_BOOL ("network.port_random", true);
CMD2_VAR_STRING ("network.port_range", "6881-6999");
CMD2_ANY ("network.listen.port", tr1::bind(&torrent::ConnectionManager::listen_port, cm));
CMD2_ANY ("network.listen.port", tr1::bind(&torrent::ConnectionManager::listen_port, cm));
CMD2_ANY ("network.listen.backlog", tr1::bind(&torrent::ConnectionManager::listen_backlog, cm));
CMD2_ANY_VALUE_V ("network.listen.backlog.set", tr1::bind(&torrent::ConnectionManager::set_listen_backlog, cm, tr1::placeholders::_2));
CMD2_VAR_BOOL ("protocol.pex", true);
CMD2_ANY_LIST ("protocol.encryption.set", tr1::bind(&apply_encryption, tr1::placeholders::_2));
+40 -13
View File
@@ -86,34 +86,44 @@ CurlStack::new_socket(int fd) {
void
CurlStack::receive_action(CurlSocket* socket, int events) {
if (this <= (CurlStack*)0x100)
throw torrent::internal_error("CurlStack::receive_action(...) called with shit == NULL");
if (this >= (CurlStack*)0x00007fff00000000)
throw torrent::internal_error("CurlStack::receive_action(...) called with this == 0x00007fff00000002");
if (socket != NULL && socket <= (CurlSocket*)0x100)
throw torrent::internal_error("CurlStack::receive_action(...) called with socket == NULL");
if (socket >= (CurlSocket*)0x00007fff00000000)
throw torrent::internal_error("CurlStack::receive_action(...) called with socket == 0x00007fff00000002");
CURLMcode code;
do {
int count;
#if (LIBCURL_VERSION_NUM >= 0x071003)
code = curl_multi_socket_action((CURLM*)m_handle, socket != NULL ? socket->file_descriptor() : CURL_SOCKET_TIMEOUT, events, &count);
code = curl_multi_socket_action((CURLM*)m_handle,
socket != NULL ? socket->file_descriptor() : CURL_SOCKET_TIMEOUT,
events,
&count);
#else
code = curl_multi_socket((CURLM*)m_handle, socket != NULL ? socket->file_descriptor() : CURL_SOCKET_TIMEOUT, &count);
code = curl_multi_socket((CURLM*)m_handle,
socket != NULL ? socket->file_descriptor() : CURL_SOCKET_TIMEOUT,
&count);
#endif
if (code > 0)
throw torrent::internal_error("Error calling curl_multi_socket_action.");
// Socket might be removed when cleaning handles below, future calls should not use it.
// Socket might be removed when cleaning handles below, future
// calls should not use it.
socket = NULL;
events = 0;
if ((unsigned int)count != size()) {
// Done with some handles.
int t;
CURLMsg* msg;
while ((msg = curl_multi_info_read((CURLM*)m_handle, &t)) != NULL) {
if (msg->msg != CURLMSG_DONE)
throw torrent::internal_error("CurlStack::receive_action() msg->msg != CURLMSG_DONE.");
transfer_done(msg->easy_handle, msg->data.result == CURLE_OK ? NULL : curl_easy_strerror(msg->data.result));
}
while (process_done_handle())
; // Do nothing.
if (empty())
priority_queue_erase(&taskScheduler, &m_taskTimeout);
@@ -122,6 +132,23 @@ CurlStack::receive_action(CurlSocket* socket, int events) {
} while (code == CURLM_CALL_MULTI_PERFORM);
}
bool
CurlStack::process_done_handle() {
int remaining_msgs = 0;
CURLMsg* msg = curl_multi_info_read((CURLM*)m_handle, &remaining_msgs);
if (msg == NULL)
return false;
if (msg->msg != CURLMSG_DONE)
throw torrent::internal_error("CurlStack::receive_action() msg->msg != CURLMSG_DONE.");
transfer_done(msg->easy_handle,
msg->data.result == CURLE_OK ? NULL : curl_easy_strerror(msg->data.result));
return remaining_msgs != 0;
}
void
CurlStack::transfer_done(void* handle, const char* msg) {
iterator itr = std::find_if(begin(), end(), rak::equal(handle, std::mem_fun(&CurlGet::handle)));
+2
View File
@@ -125,6 +125,8 @@ class CurlStack : std::deque<CurlGet*> {
void receive_timeout();
bool process_done_handle();
void* m_handle;
unsigned int m_active;
+1 -3
View File
@@ -47,8 +47,6 @@
#include <rak/regex.h>
#include <rak/path.h>
#include <rak/string_manip.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/adaptors/hide.h>
#include <torrent/utils/resume.h>
#include <torrent/object.h>
#include <torrent/connection_manager.h>
@@ -115,7 +113,7 @@ Manager::set_hashing_view(View* v) {
throw torrent::internal_error("Manager::set_hashing_view(...) received NULL or is already set.");
m_hashingView = v;
v->signal_changed().connect(sigc::mem_fun(this, &Manager::receive_hashing_changed));
m_hashingView->signal_changed().push_back(std::tr1::bind(&Manager::receive_hashing_changed, this));
}
torrent::ThrottlePair
+8 -2
View File
@@ -138,12 +138,18 @@ struct view_downloads_filter : std::unary_function<Download*, bool> {
const torrent::Object& m_command;
};
inline void
void
View::emit_changed() {
priority_queue_erase(&taskScheduler, &m_delayChanged);
priority_queue_insert(&taskScheduler, &m_delayChanged, cachedTime);
}
void
View::emit_changed_now() {
for (signal_void::iterator itr = m_signal_changed.begin(), last = m_signal_changed.end(); itr != last; itr++)
(*itr)();
}
View::~View() {
if (m_name.empty())
return;
@@ -171,7 +177,7 @@ View::initialize(const std::string& name) {
m_focus = 0;
set_last_changed(rak::timer());
m_delayChanged.slot() = std::tr1::bind(&signal_type::operator(), &m_signalChanged);
m_delayChanged.slot() = std::tr1::bind(&View::emit_changed_now, this);
}
void
+9 -7
View File
@@ -52,8 +52,8 @@
#include <string>
#include <vector>
#include <rak/timer.h>
#include <sigc++/signal.h>
#include <torrent/object.h>
#include <tr1/functional>
#include "globals.h"
@@ -63,8 +63,9 @@ class Download;
class View : private std::vector<Download*> {
public:
typedef std::vector<Download*> base_type;
typedef sigc::signal0<void> signal_type;
typedef std::vector<Download*> base_type;
typedef std::tr1::function<void ()> slot_void;
typedef std::list<slot_void> signal_void;
using base_type::iterator;
using base_type::const_iterator;
@@ -101,7 +102,7 @@ public:
iterator focus() { return begin() + m_focus; }
const_iterator focus() const { return begin() + m_focus; }
void set_focus(iterator itr) { m_focus = position(itr); m_signalChanged.emit(); }
void set_focus(iterator itr) { m_focus = position(itr); emit_changed(); }
void insert(Download* download) { base_type::push_back(download); }
void erase(Download* download);
@@ -143,7 +144,7 @@ public:
// Don't connect any slots until after initialize else it get's
// triggered when adding the Download's in DownloadList.
signal_type& signal_changed() { return m_signalChanged; }
signal_void& signal_changed() { return m_signal_changed; }
private:
View(const View&);
@@ -154,7 +155,8 @@ private:
inline void insert_visible(Download* d);
inline void erase_internal(iterator itr);
inline void emit_changed();
void emit_changed();
void emit_changed_now();
size_type position(const_iterator itr) const { return itr - begin(); }
@@ -176,7 +178,7 @@ private:
rak::timer m_lastChanged;
signal_type m_signalChanged;
signal_void m_signal_changed;
rak::priority_item m_delayChanged;
};
+1 -1
View File
@@ -38,7 +38,7 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/termios.h>
#include <termios.h>
#include <torrent/exceptions.h>
#include "canvas.h"
+13 -4
View File
@@ -48,18 +48,27 @@
namespace display {
WindowDownloadList::WindowDownloadList() :
Window(new Canvas, 0, 120, 1, extent_full, extent_full),
m_view(NULL) {
}
WindowDownloadList::~WindowDownloadList() {
m_connChanged.disconnect();
if (m_view != NULL)
m_view->signal_changed().erase(m_changed_itr);
m_view = NULL;
}
void
WindowDownloadList::set_view(core::View* l) {
if (m_view != NULL)
m_view->signal_changed().erase(m_changed_itr);
m_view = l;
m_connChanged.disconnect();
if (m_view != NULL)
m_connChanged = m_view->signal_changed().connect(sigc::mem_fun(*this, &Window::mark_dirty));
m_changed_itr = m_view->signal_changed().insert(m_view->signal_changed().begin(), std::tr1::bind(&Window::mark_dirty, this));
}
void
+5 -10
View File
@@ -37,23 +37,18 @@
#ifndef RTORRENT_DISPLAY_WINDOW_DOWNLOAD_LIST_H
#define RTORRENT_DISPLAY_WINDOW_DOWNLOAD_LIST_H
#include <sigc++/connection.h>
#include "window.h"
#include "core/download_list.h"
namespace core {
class View;
}
#include "core/view.h"
namespace display {
class WindowDownloadList : public Window {
public:
WindowDownloadList() :
Window(new Canvas, 0, 120, 1, extent_full, extent_full),
m_view(NULL) {}
typedef core::View::signal_void::iterator signal_void_itr;
WindowDownloadList();
~WindowDownloadList();
virtual void redraw();
@@ -63,7 +58,7 @@ public:
private:
core::View* m_view;
sigc::connection m_connChanged;
signal_void_itr m_changed_itr;
};
}
+16 -17
View File
@@ -41,14 +41,10 @@
#include <rak/functional.h>
#include <rak/path.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#ifdef __sun__
#include <dirent.h>
#include <sys/stat.h>
#else
#include <sys/dir.h>
#endif
#include <torrent/utils/log.h>
#include "path_input.h"
@@ -67,7 +63,8 @@ PathInput::pressed(int key) {
return TextInput::pressed(key);
} else if (m_showNext) {
m_signalShowNext.emit();
for (signal_void::iterator itr = m_signal_show_next.begin(), last = m_signal_show_next.end(); itr != last; itr++)
(*itr)();
} else {
receive_do_complete();
@@ -78,17 +75,15 @@ PathInput::pressed(int key) {
struct _transform_filename {
void operator () (utils::directory_entry& entry) {
#ifdef __sun__
if (entry.d_type & S_IFDIR)
#else
if (entry.d_type == DT_DIR)
#endif
entry.d_name += '/';
}
};
void
PathInput::receive_do_complete() {
lt_log_print(torrent::LOG_UI_EVENTS, "path_input: received completion");
size_type dirEnd = find_last_delim();
utils::Directory dir(dirEnd != 0 ? str().substr(0, dirEnd) : "./");
@@ -101,7 +96,7 @@ PathInput::receive_do_complete() {
std::for_each(dir.begin(), dir.end(), _transform_filename());
Range r = find_incomplete(dir, str().substr(dirEnd, get_pos()));
range_type r = find_incomplete(dir, str().substr(dirEnd, get_pos()));
if (r.first == r.second)
return; // Show some nice colors here.
@@ -121,8 +116,12 @@ PathInput::receive_do_complete() {
// Only emit if there are more than one option.
m_showNext = ++utils::Directory::iterator(r.first) != r.second;
if (m_showNext)
m_signalShowRange.emit(r.first, r.second);
if (m_showNext) {
lt_log_print(torrent::LOG_UI_EVENTS, "path_input: show next page");
for (signal_itr_itr::iterator itr = m_signal_show_range.begin(), last = m_signal_show_range.end(); itr != last; itr++)
(*itr)(r.first, r.second);
}
}
PathInput::size_type
@@ -147,9 +146,9 @@ find_complete_not_compare(const utils::directory_entry& complete, const std::str
return !complete.d_name.compare(0, base.size(), base);
}
PathInput::Range
PathInput::range_type
PathInput::find_incomplete(utils::Directory& d, const std::string& f) {
Range r;
range_type r;
r.first = std::find_if(d.begin(), d.end(), rak::bind2nd(std::ptr_fun(&find_complete_not_compare), f));
r.second = std::find_if(r.first, d.end(), rak::bind2nd(std::ptr_fun(&find_complete_compare), f));
+14 -9
View File
@@ -37,7 +37,8 @@
#ifndef RTORRENT_INPUT_PATH_INPUT_H
#define RTORRENT_INPUT_PATH_INPUT_H
#include <sigc++/signal.h>
#include <list>
#include <tr1/functional>
#include "utils/directory.h"
#include "text_input.h"
@@ -46,15 +47,19 @@ namespace input {
class PathInput : public TextInput {
public:
typedef std::pair<utils::Directory::iterator, utils::Directory::iterator> Range;
typedef sigc::signal0<void> Signal;
typedef sigc::signal2<void, utils::Directory::iterator, utils::Directory::iterator> SignalShowRange;
typedef utils::Directory::iterator directory_itr;
typedef std::pair<directory_itr, directory_itr> range_type;
typedef std::tr1::function<void ()> slot_void;
typedef std::tr1::function<void (directory_itr, directory_itr)> slot_itr_itr;
typedef std::list<slot_void> signal_void;
typedef std::list<slot_itr_itr> signal_itr_itr;
PathInput();
virtual ~PathInput() {}
Signal& signal_show_next() { return m_signalShowNext; }
SignalShowRange& signal_show_range() { return m_signalShowRange; }
signal_void& signal_show_next() { return m_signal_show_next; }
signal_itr_itr& signal_show_range() { return m_signal_show_range; }
virtual bool pressed(int key);
@@ -62,12 +67,12 @@ private:
void receive_do_complete();
size_type find_last_delim();
Range find_incomplete(utils::Directory& d, const std::string& f);
range_type find_incomplete(utils::Directory& d, const std::string& f);
bool m_showNext;
Signal m_signalShowNext;
SignalShowRange m_signalShowRange;
signal_void m_signal_show_next;
signal_itr_itr m_signal_show_range;
};
}
+1 -1
View File
@@ -37,7 +37,7 @@
#ifndef RTORRENT_SIGNAL_HANDLER_H
#define RTORRENT_SIGNAL_HANDLER_H
#include <sys/signal.h>
#include <signal.h>
#include <tr1/functional>
class SignalHandler {
-1
View File
@@ -39,7 +39,6 @@
#include <list>
#include <torrent/peer/peer.h>
#include <sigc++/connection.h>
#include "display/manager.h"
#include "utils/list_focus.h"
+7 -6
View File
@@ -38,8 +38,6 @@
#include <rak/functional.h>
#include <rak/string_manip.h>
#include <sigc++/adaptors/bind.h>
#include <sigc++/adaptors/hide.h>
#include <torrent/exceptions.h>
#include <torrent/torrent.h>
#include <torrent/utils/log.h>
@@ -270,11 +268,14 @@ DownloadList::receive_view_input(Input type) {
ElementStringList* esl = dynamic_cast<ElementStringList*>(m_uiArray[DISPLAY_STRING_LIST]);
input->signal_show_next().connect(std::tr1::bind(&DownloadList::activate_display, this, DISPLAY_STRING_LIST));
input->signal_show_next().connect(std::tr1::bind(&ElementStringList::next_screen, *esl));
input->signal_show_next().push_back(std::tr1::bind(&DownloadList::activate_display, this, DISPLAY_STRING_LIST));
input->signal_show_next().push_back(std::tr1::bind(&ElementStringList::next_screen, esl));
input->signal_show_range().connect(sigc::hide(sigc::hide(std::tr1::bind(&DownloadList::activate_display, this, DISPLAY_STRING_LIST))));
input->signal_show_range().connect(sigc::mem_fun(*esl, &ElementStringList::set_range_dirent<utils::Directory::iterator>));
input->signal_show_range().push_back(std::tr1::bind(&DownloadList::activate_display, this, DISPLAY_STRING_LIST));
input->signal_show_range().push_back(std::tr1::bind(&ElementStringList::set_range_dirent<utils::Directory::iterator>,
esl,
std::tr1::placeholders::_1,
std::tr1::placeholders::_2));
input->bindings()['\n'] = std::tr1::bind(&DownloadList::receive_exit_input, this, type);
input->bindings()[KEY_ENTER] = std::tr1::bind(&DownloadList::receive_exit_input, this, type);
+7
View File
@@ -55,6 +55,8 @@ ElementStringList::activate(display::Frame* frame, bool focus) {
if (is_active())
throw torrent::internal_error("ui::ElementStringList::activate(...) is_active().");
lt_log_print(torrent::LOG_UI_EVENTS, "element_string_list: activate");
control->input()->push_back(&m_bindings);
m_window = new WStringList();
@@ -69,6 +71,8 @@ ElementStringList::disable() {
if (!is_active())
throw torrent::internal_error("ui::ElementStringList::disable(...) !is_active().");
lt_log_print(torrent::LOG_UI_EVENTS, "element_string_list: deactivate");
control->input()->erase(&m_bindings);
m_frame->clear();
@@ -80,6 +84,9 @@ ElementStringList::disable() {
void
ElementStringList::next_screen() {
if (m_window == NULL)
return;
if (m_window->get_draw_end() != m_list.end())
m_window->set_range(m_window->get_draw_end(), m_list.end());
else
+17 -4
View File
@@ -41,6 +41,7 @@
#include <string>
#include <algorithm>
#include <functional>
#include <torrent/utils/log.h>
#include "element_base.h"
@@ -69,8 +70,14 @@ public:
while (first != last)
m_list.push_back(*(first++));
m_window->set_range(m_list.begin(), m_list.end());
m_window->mark_dirty();
if (m_window != NULL) {
lt_log_print(torrent::LOG_UI_EVENTS, "element_string_list: set range (visible)");
m_window->set_range(m_list.begin(), m_list.end());
m_window->mark_dirty();
} else {
lt_log_print(torrent::LOG_UI_EVENTS, "element_string_list: set range (hidden)");
}
}
// A hack, clean this up.
@@ -81,8 +88,14 @@ public:
while (first != last)
m_list.push_back((first++)->d_name);
m_window->set_range(m_list.begin(), m_list.end());
m_window->mark_dirty();
if (m_window != NULL) {
lt_log_print(torrent::LOG_UI_EVENTS, "element_string_list: set dirent range (visible)");
m_window->set_range(m_list.begin(), m_list.end());
m_window->mark_dirty();
} else {
lt_log_print(torrent::LOG_UI_EVENTS, "element_string_list: set dirent range (hidden)");
}
}
void next_screen();
+2 -4
View File
@@ -38,14 +38,12 @@
#include <algorithm>
#include <functional>
#include <dirent.h>
#include <sys/stat.h>
#include <rak/path.h>
#include <torrent/exceptions.h>
#ifdef __sun__
#include <sys/stat.h>
#endif
#include "directory.h"
namespace utils {
+35 -18
View File
@@ -37,7 +37,7 @@
#ifndef RTORRENT_UTILS_LIST_FOCUS_H
#define RTORRENT_UTILS_LIST_FOCUS_H
#include <sigc++/signal.h>
#include <tr1/functional>
namespace utils {
@@ -46,15 +46,18 @@ namespace utils {
template <typename Base>
class ListFocus {
public:
typedef typename Base::iterator iterator;
typedef typename Base::const_iterator const_iterator;
typedef typename Base::reverse_iterator reverse_iterator;
typedef typename Base::const_reverse_iterator const_reverse_iterator;
typedef Base base_type;
typedef std::tr1::function<void ()> slot_void;
typedef std::list<slot_void> signal_void;
typedef typename Base::value_type value_type;
typedef sigc::signal0<void> Signal;
typedef typename base_type::iterator iterator;
typedef typename base_type::const_iterator const_iterator;
typedef typename base_type::reverse_iterator reverse_iterator;
typedef typename base_type::const_reverse_iterator const_reverse_iterator;
ListFocus(Base* b = NULL) : m_base(b) { if (b) m_focus = b->end(); }
typedef typename base_type::value_type value_type;
ListFocus(base_type* b = NULL) : m_base(b) { if (b) m_focus = b->end(); }
// Convinience functions, would have added more through using, but
// can't.
@@ -64,10 +67,10 @@ public:
reverse_iterator rend() { return m_base->rend(); }
// Don't do erase on this object without making sure focus is right.
Base& base() { return *m_base; }
base_type& base() { return *m_base; }
iterator get_focus() { return m_focus; }
void set_focus(iterator itr) { m_focus = itr; m_signalChanged.emit(); }
void set_focus(iterator itr);
// These are looping increment/decrements.
iterator inc_focus();
@@ -77,15 +80,24 @@ public:
void remove(const value_type& v);
// Be careful with copying signals.
Signal& signal_changed() { return m_signalChanged; }
signal_void& signal_changed() { return m_signal_changed; }
private:
Base* m_base;
void emit_changed();
base_type* m_base;
iterator m_focus;
Signal m_signalChanged;
signal_void m_signal_changed;
};
template <typename Base>
void
ListFocus<Base>::set_focus(iterator itr) {
m_focus = itr;
emit_changed();
}
template <typename Base>
typename ListFocus<Base>::iterator
ListFocus<Base>::inc_focus() {
@@ -94,8 +106,7 @@ ListFocus<Base>::inc_focus() {
else
m_focus = begin();
m_signalChanged.emit();
emit_changed();
return m_focus;
}
@@ -107,8 +118,7 @@ ListFocus<Base>::dec_focus() {
else
m_focus = end();
m_signalChanged.emit();
emit_changed();
return m_focus;
}
@@ -120,7 +130,7 @@ ListFocus<Base>::erase(iterator itr) {
else
return m_base->erase(itr);
m_signalChanged.emit();
emit_changed();
}
template <typename Base>
@@ -136,6 +146,13 @@ ListFocus<Base>::remove(const value_type& v) {
++first;
}
template <typename Base>
void
ListFocus<Base>::emit_changed() {
for (signal_void::iterator itr = m_signal_changed.begin(), last = m_signal_changed.end(); itr != last; itr++)
(*itr)();
}
}
#endif