mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-06 18:22:32 +00:00
Compare commits
211 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 327164f9d8 | |||
| 5d22fdd4b6 | |||
| 7455f2eb86 | |||
| 53767cee92 | |||
| aa9e729ca7 | |||
| e43853b782 | |||
| 81932c0b12 | |||
| 61264c4f17 | |||
| 244a84dcf5 | |||
| c9a5736d5d | |||
| 9322acb33d | |||
| a5e722b48f | |||
| ba4828d226 | |||
| dfced79186 | |||
| dd2a4cc151 | |||
| fd372b5e48 | |||
| 3ea47d7acb | |||
| b82f3614c3 | |||
| 2987ba8081 | |||
| 33f8fe804b | |||
| 1a4f6dab1a | |||
| 943b576e1f | |||
| 2ec90c6892 | |||
| 63dfe341a6 | |||
| 321147cdb8 | |||
| 2097c9ca3e | |||
| 10ce6864b8 | |||
| 226e670dec | |||
| 74bd0be5d8 | |||
| e3a5ed9c75 | |||
| c7c5a00f66 | |||
| 71a52bfac2 | |||
| 16e1961636 | |||
| 2aa130eda9 | |||
| 008561ef47 | |||
| e02c6b29fa | |||
| e2c769f459 | |||
| c3f6db0384 | |||
| 40a5b63223 | |||
| e6439a173e | |||
| 84913766d5 | |||
| 89b02f275e | |||
| ce00085107 | |||
| d7529d3b84 | |||
| 23cf6b260c | |||
| 06f1c032b0 | |||
| bdb0d99c5c | |||
| 7c5e42f4b9 | |||
| e1afe25413 | |||
| 0cba9cbf9b | |||
| 017cb1bd59 | |||
| dfdbf5e69c | |||
| 15e64bdade | |||
| 5838b8e68c | |||
| 13162f98cb | |||
| b5e4dc0342 | |||
| 41a059c999 | |||
| 55c61e9099 | |||
| e1fa392ecb | |||
| 9d7398d1da | |||
| a194da08b0 | |||
| 51c5190eb1 | |||
| 66619840d8 | |||
| 63c2b7aef5 | |||
| 2c60226bd2 | |||
| d111594d20 | |||
| a0f97e4b06 | |||
| a7079c594e | |||
| ed48d586d8 | |||
| 8be4e5bbf7 | |||
| 8140c3fe07 | |||
| 8385957b06 | |||
| 1363e50a7b | |||
| f24154e772 | |||
| 3f698b3b39 | |||
| a8c67b4aab | |||
| aac0ea48f7 | |||
| 1db32f2f63 | |||
| efc9097d62 | |||
| 5a56fbd5d1 | |||
| 7ea5729676 | |||
| c01709fa27 | |||
| 0797d636fb | |||
| b68d4c2db9 | |||
| 9abcea84c7 | |||
| cc1f7fb2cb | |||
| 944d304193 | |||
| 629e421d67 | |||
| 3e7f9d8b4f | |||
| a8cb524345 | |||
| 0510e4db9d | |||
| a975804797 | |||
| adf4a32097 | |||
| 3edeb364bc | |||
| 73a344711d | |||
| 4ba24af463 | |||
| 44f0ac3447 | |||
| a92da121d7 | |||
| 4fb036f87d | |||
| 6a8d332b4c | |||
| 911596d65e | |||
| b19cf8b4ff | |||
| 83d7dc8964 | |||
| b89fa31f37 | |||
| 30d8379391 | |||
| 605819ea6c | |||
| 1f5e4d37d5 | |||
| 33601ddc0c | |||
| e1cc736f11 | |||
| 9647749b01 | |||
| 06db5776ae | |||
| 62cb5a4605 | |||
| d4905d512a | |||
| 9ba4d1d92e | |||
| 1c47bf6162 | |||
| 50d6437792 | |||
| eb5443bbad | |||
| 1a728fc683 | |||
| 0d1dc8a331 | |||
| b5f2cfe393 | |||
| 7343e33a6a | |||
| e3cc2c601d | |||
| 3cf9cffe68 | |||
| 0ba4d7d943 | |||
| cc10161c90 | |||
| d1e807acc5 | |||
| 0df0a6650d | |||
| 6c39da6943 | |||
| 089fa765b8 | |||
| 92197d6286 | |||
| 9937ea27bc | |||
| b5bff0cb9c | |||
| 3d166de175 | |||
| 7007973c76 | |||
| 7537a3c2a9 | |||
| 81c652292a | |||
| f4c312e2c0 | |||
| 975d001ea7 | |||
| fe9a4e9714 | |||
| 52689695ff | |||
| 2a19c613c1 | |||
| dc8e786d58 | |||
| b8e24b78cd | |||
| 4244921383 | |||
| afebadcbdf | |||
| d74409c2d7 | |||
| 1fefc4720b | |||
| 09f6243c6a | |||
| 390328ec97 | |||
| bfd1a8da8c | |||
| 4ac807870e | |||
| 5acfd592f0 | |||
| e4e73aeee9 | |||
| 8e69930cc4 | |||
| 3b39f37f49 | |||
| 4f36c3e49f | |||
| ce5d67a9c0 | |||
| 904a390fba | |||
| 696c2b2b33 | |||
| 24f84214c8 | |||
| 323f0df30c | |||
| 1e4739c862 | |||
| 0329608f69 | |||
| 49d00285c8 | |||
| 2cd70f4342 | |||
| bb27adcfd3 | |||
| 7a2ec0ff86 | |||
| e95b66fc51 | |||
| 2f102f0fcd | |||
| 6d61cc09c3 | |||
| f1ece0ae12 | |||
| 75933db69b | |||
| efa3c670a5 | |||
| c46ee642fe | |||
| 27888e73bc | |||
| 097e3d9056 | |||
| 0132ce6b81 | |||
| a7b7b26d08 | |||
| 0b39455a4b | |||
| 05d16707d4 | |||
| 9c2745ecb3 | |||
| e79b38f907 | |||
| 7343c0d67c | |||
| 9aa54d2344 | |||
| 6141a5656f | |||
| 51fff1fdc5 | |||
| 07d326535d | |||
| 0514a5c0d1 | |||
| 89611a222c | |||
| cf3a1674a3 | |||
| bc993807d1 | |||
| f7403d30e9 | |||
| 6a45ca2dd6 | |||
| 2da20f984e | |||
| a0ce6c09a6 | |||
| 26581c74c1 | |||
| 0cbc11b536 | |||
| f50358b284 | |||
| 53edee3e06 | |||
| cfc4984c3a | |||
| 6a399cd927 | |||
| 79517e61aa | |||
| 3c4d21d34c | |||
| 0d648119d2 | |||
| f0da99b5c3 | |||
| c55f5611a9 | |||
| 52530d5538 | |||
| 8d4aed7dae | |||
| 7b38cc29aa | |||
| 31495b06be | |||
| 413becea38 |
@@ -32,6 +32,8 @@ libtool
|
||||
ltmain.sh
|
||||
missing
|
||||
stamp-h1
|
||||
|
||||
src/rtorrent
|
||||
scripts/libtool.m4
|
||||
scripts/lt*.m4
|
||||
|
||||
@@ -56,6 +58,7 @@ scripts/lt*.m4
|
||||
# OS generated files #
|
||||
######################
|
||||
.DS_Store?
|
||||
.dirstamp
|
||||
ehthumbs.db
|
||||
Icon?
|
||||
Thumbs.db
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
language: cpp
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- compiler: clang
|
||||
env: COMPILER=clang++ SKIP_CHECK=true
|
||||
- compiler: clang
|
||||
env: COMPILER=clang++
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libcppunit-dev
|
||||
- compiler: clang
|
||||
env: COMPILER=clang++-3.6
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.6
|
||||
packages:
|
||||
- clang-3.6
|
||||
- libcppunit-dev
|
||||
- compiler: clang
|
||||
env: COMPILER=clang++-3.7
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.7
|
||||
packages:
|
||||
- clang-3.7
|
||||
- libcppunit-dev
|
||||
- compiler: clang
|
||||
env: COMPILER=clang++-3.8
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
packages:
|
||||
- clang-3.8
|
||||
- libcppunit-dev
|
||||
- compiler: gcc
|
||||
env: COMPILER=g++-4.7 SKIP_CHECK=true
|
||||
addons:
|
||||
apt:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.7
|
||||
- compiler: gcc
|
||||
env: COMPILER=g++-4.7
|
||||
addons:
|
||||
apt:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.7
|
||||
- libcppunit-dev
|
||||
- compiler: gcc
|
||||
env: COMPILER=g++-4.8
|
||||
addons:
|
||||
apt:
|
||||
sources: ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-4.8
|
||||
- libcppunit-dev
|
||||
|
||||
# TODO: Use the same branch name if libtorrent has it.
|
||||
before_install:
|
||||
- git clone https://github.com/rakshasa/libtorrent.git
|
||||
- cd libtorrent && ./autogen.sh && CXX="$COMPILER" ./configure && make -j12 && sudo make install
|
||||
|
||||
script:
|
||||
- ./autogen.sh && CXX="$COMPILER" ./configure && make -j12
|
||||
- if [ ! $SKIP_CHECK ]; then make -j12 check; fi
|
||||
@@ -1 +1 @@
|
||||
Jari Sundell <jaris@ifi.uio.no>
|
||||
Jari Sundell <sundell.software@gmail.com>
|
||||
|
||||
@@ -32,5 +32,10 @@ DEPENDENCIES
|
||||
|
||||
CONTACT
|
||||
|
||||
Send bug reports, suggestions and patches to <jaris@ifi.uio.no> or
|
||||
to the mailinglist.
|
||||
Jari Sundell
|
||||
|
||||
Skomakerveien 33
|
||||
3185 Skoppum, NORWAY
|
||||
|
||||
Send bug reports, suggestions and patches to
|
||||
<sundell.software@gmail.com> or to the mailinglist.
|
||||
|
||||
+23
-26
@@ -1,53 +1,50 @@
|
||||
AC_INIT(rtorrent, 0.9.4, sundell.software@gmail.com)
|
||||
AC_INIT(rtorrent, 0.9.7, sundell.software@gmail.com)
|
||||
|
||||
AC_DEFINE(API_VERSION, 8, api version)
|
||||
AC_DEFINE(API_VERSION, 9, api version)
|
||||
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
AM_PATH_CPPUNIT(1.9.6)
|
||||
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_CXX
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
TORRENT_CHECK_CXXFLAGS()
|
||||
TORRENT_ENABLE_DEBUG()
|
||||
TORRENT_ENABLE_EXTRA_DEBUG()
|
||||
TORRENT_ENABLE_WERROR()
|
||||
TORRENT_ENABLE_TR1()
|
||||
TORRENT_ENABLE_CXX11()
|
||||
RAK_CHECK_CFLAGS
|
||||
RAK_CHECK_CXXFLAGS
|
||||
RAK_ENABLE_DEBUG
|
||||
RAK_ENABLE_EXTRA_DEBUG
|
||||
RAK_ENABLE_WERROR
|
||||
|
||||
RAK_CHECK_CXX11
|
||||
RAK_CHECK_TR1_LIB
|
||||
|
||||
TORRENT_DISABLE_IPV6
|
||||
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
TORRENT_CHECK_EXECINFO()
|
||||
TORRENT_OTFD()
|
||||
TORRENT_CHECK_EXECINFO
|
||||
|
||||
TORRENT_ENABLE_ARCH
|
||||
TORRENT_WITH_SYSROOT
|
||||
|
||||
TORRENT_WITHOUT_VARIABLE_FDSET()
|
||||
TORRENT_WITHOUT_STATVFS()
|
||||
TORRENT_WITHOUT_STATFS()
|
||||
TORRENT_WITHOUT_VARIABLE_FDSET
|
||||
TORRENT_WITHOUT_STATVFS
|
||||
TORRENT_WITHOUT_STATFS
|
||||
|
||||
AX_PTHREAD([], AC_MSG_ERROR([requires pthread]))
|
||||
AX_WITH_CURSES()
|
||||
AX_WITH_CURSES
|
||||
|
||||
if test "x$ax_cv_ncursesw" != xyes && test "x$ax_cv_ncurses" != xyes; then
|
||||
AC_MSG_ERROR([requires either NcursesW or Ncurses library])
|
||||
AC_MSG_ERROR([requires either NcursesW or Ncurses library])
|
||||
fi
|
||||
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS $CURSES_CFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS $CURSES_CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $CURSES_LIB $LIBS"
|
||||
PKG_CHECK_MODULES([LIBCURL], [libcurl], , [LIBCURL_CHECK_CONFIG])
|
||||
PKG_CHECK_MODULES([CPPUNIT], [cppunit],, [no_cppunit="yes"])
|
||||
PKG_CHECK_MODULES([DEPENDENCIES], [libtorrent >= 0.13.7])
|
||||
|
||||
PKG_CHECK_MODULES([libcurl], libcurl >= 7.15.4,
|
||||
CXXFLAGS="$CXXFLAGS $libcurl_CFLAGS";
|
||||
LIBS="$LIBS $libcurl_LIBS")
|
||||
|
||||
PKG_CHECK_MODULES([libtorrent], libtorrent >= 0.13.4,
|
||||
CXXFLAGS="$CXXFLAGS $libtorrent_CFLAGS";
|
||||
LIBS="$LIBS $libtorrent_LIBS")
|
||||
LIBS="$PTHREAD_LIBS $CURSES_LIB $CPPUNIT_LIBS $LIBCURL $LIBCURL_LIBS $DEPENDENCIES_LIBS $LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS $CPPUNIT_CFLAGS $LIBCURL_CPPFLAGS $LIBCURL_CFLAGS $DEPENDENCIES_CFLAGS $CURSES_CFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS $CPPUNIT_CFLAGS $LIBCURL_CPPFLAGS $LIBCURL_CFLAGS $DEPENDENCIES_CFLAGS $CURSES_CFLAGS"
|
||||
|
||||
AC_LANG_PUSH(C++)
|
||||
TORRENT_WITH_XMLRPC_C
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#/bin/bash
|
||||
gnuplot << EOF
|
||||
|
||||
set terminal png size 1024,768 enhanced
|
||||
set terminal png size 1024 * 1, 768 enhanced
|
||||
set xdata time
|
||||
set timefmt "%s"
|
||||
set format x "%H:%M"
|
||||
@@ -14,17 +14,17 @@ 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
|
||||
"instrumentation_mincore.log.$1" using 1:6 title 'success' with lines lw 4 axis x1y1,\
|
||||
"instrumentation_mincore.log.$1" using 1:7 title 'failed' with lines lw 4 axis x1y1,\
|
||||
"instrumentation_mincore.log.$1" using 1:8 title 'not synced' with lines lw 4 axis x1y2,\
|
||||
"instrumentation_mincore.log.$1" using 1:9 title 'not deallocated' 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
|
||||
"instrumentation_mincore.log.$1" using 1:12 title 'allocations' with lines lw 2 axis x1y1,\
|
||||
"instrumentation_mincore.log.$1" using 1:13 title 'deallocations' with lines lw 4 axis x1y1,\
|
||||
"instrumentation_mincore.log.$1" using 1:10 title 'alloc failed' with lines lw 2 axis x1y2
|
||||
|
||||
EOF
|
||||
+55
-27
@@ -3,61 +3,76 @@
|
||||
# uncomment the options you wish to enable.
|
||||
|
||||
# Maximum and minimum number of peers to connect to per torrent.
|
||||
#min_peers = 40
|
||||
#max_peers = 100
|
||||
#
|
||||
#throttle.min_peers.normal.set = 40
|
||||
#throttle.max_peers.normal.set = 100
|
||||
|
||||
# Same as above but for seeding completed torrents (-1 = same as downloading)
|
||||
#min_peers_seed = 10
|
||||
#max_peers_seed = 50
|
||||
#
|
||||
#throttle.min_peers.seed.set = 10
|
||||
#throttle.max_peers.seed.set = 50
|
||||
|
||||
# Maximum number of simultanious uploads per torrent.
|
||||
#max_uploads = 15
|
||||
#
|
||||
#throttle.max_uploads.set = 15
|
||||
|
||||
# Global upload and download rate in KiB. "0" for unlimited.
|
||||
#download_rate = 0
|
||||
#upload_rate = 0
|
||||
#
|
||||
#throttle.global_down.max_rate.set_kb = 0
|
||||
#throttle.global_up.max_rate.set_kb = 0
|
||||
|
||||
# Default directory to save the downloaded torrents.
|
||||
#directory = ./
|
||||
#
|
||||
#directory.default.set = ./
|
||||
|
||||
# Default session directory. Make sure you don't run multiple instance
|
||||
# of rtorrent using the same session directory. Perhaps using a
|
||||
# relative path?
|
||||
#session = ./session
|
||||
#
|
||||
#session.path.set = ./session
|
||||
|
||||
# Watch a directory for new torrents, and stop those that have been
|
||||
# deleted.
|
||||
#schedule = watch_directory,5,5,load_start=./watch/*.torrent
|
||||
#schedule = untied_directory,5,5,stop_untied=
|
||||
#
|
||||
#schedule2 = watch_directory,5,5,load.start=./watch/*.torrent
|
||||
#schedule2 = untied_directory,5,5,stop_untied=
|
||||
|
||||
# Close torrents when diskspace is low.
|
||||
#schedule = low_diskspace,5,60,close_low_diskspace=100M
|
||||
#
|
||||
#schedule2 = low_diskspace,5,60,close_low_diskspace=100M
|
||||
|
||||
# The ip address reported to the tracker.
|
||||
#ip = 127.0.0.1
|
||||
#ip = rakshasa.no
|
||||
#
|
||||
#network.local_address.set = 127.0.0.1
|
||||
#network.local_address.set = rakshasa.no
|
||||
|
||||
# The ip address the listening socket and outgoing connections is
|
||||
# bound to.
|
||||
#bind = 127.0.0.1
|
||||
#bind = rakshasa.no
|
||||
#
|
||||
#network.bind_address.set = 127.0.0.1
|
||||
#network.bind_address.set = rakshasa.no
|
||||
|
||||
# Port range to use for listening.
|
||||
#port_range = 6890-6999
|
||||
#
|
||||
#network.port_range.set = 6890-6999
|
||||
|
||||
# Start opening ports at a random position within the port range.
|
||||
#port_random = no
|
||||
#
|
||||
#network.port_random.set = no
|
||||
|
||||
# Check hash for finished torrents. Might be usefull until the bug is
|
||||
# fixed that causes lack of diskspace not to be properly reported.
|
||||
#check_hash = no
|
||||
#
|
||||
#pieces.hash.on_completion.set = no
|
||||
|
||||
# Set whether the client should try to connect to UDP trackers.
|
||||
#use_udp_trackers = yes
|
||||
#
|
||||
#trackers.use_udp.set = yes
|
||||
|
||||
# Alternative calls to bind and ip that should handle dynamic ip's.
|
||||
#schedule = ip_tick,0,1800,ip=rakshasa
|
||||
#schedule = bind_tick,0,1800,bind=rakshasa
|
||||
#
|
||||
#schedule2 = ip_tick,0,1800,ip=rakshasa
|
||||
#schedule2 = bind_tick,0,1800,bind=rakshasa
|
||||
|
||||
# Encryption options, set to none (default) or any combination of the following:
|
||||
# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
|
||||
@@ -66,19 +81,32 @@
|
||||
# outgoing connections but retries with encryption if they fail, preferring
|
||||
# plaintext to RC4 encryption after the encrypted handshake
|
||||
#
|
||||
# encryption = allow_incoming,enable_retry,prefer_plaintext
|
||||
# protocol.encryption.set = allow_incoming,enable_retry,prefer_plaintext
|
||||
|
||||
# Enable DHT support for trackerless torrents or when all trackers are down.
|
||||
# May be set to "disable" (completely disable DHT), "off" (do not start DHT),
|
||||
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
|
||||
# The default is "off". For DHT to work, a session directory must be defined.
|
||||
#
|
||||
# dht = auto
|
||||
# dht.mode.set = auto
|
||||
|
||||
# UDP port to use for DHT.
|
||||
#
|
||||
# dht_port = 6881
|
||||
#
|
||||
#dht.port.set = 6881
|
||||
|
||||
# Enable peer exchange (for torrents not marked private)
|
||||
#
|
||||
# peer_exchange = yes
|
||||
#protocol.pex.set = yes
|
||||
|
||||
# Set downlad list layout style. ("full", "compact")
|
||||
#
|
||||
#ui.torrent_list.layout.set = "full"
|
||||
|
||||
# SCGI Connectivity (for alternative rtorrent interfaces, XMLRPC)
|
||||
#
|
||||
# Use a IP socket with scgi_port, or a Unix socket with scgi_local.
|
||||
# schedule can be used to set permissions on the unix socket.
|
||||
#
|
||||
#scgi_port = 127.0.0.1:5000
|
||||
#scgi_local = /home/user/rtorrent/rpc.socket
|
||||
#schedule = scgi_permission,0,0,"execute.nothrow=chmod,\"g+w,o=\",/home/user/rtorrent/rpc.socket"
|
||||
|
||||
@@ -85,7 +85,7 @@ foreach my $f (0..$#files) {
|
||||
my $mtime = (stat "$d$files[$f]")[9];
|
||||
|
||||
# Compute number of chunks per file
|
||||
my $fsize = $t->{info}{files}[$f]{length};
|
||||
my $fsize = (exists $t->{info}{files}) ? $t->{info}{files}[$f]{length} : 1;
|
||||
my $fchunks = ($pmod ? 1 : 0);
|
||||
if ($pmod >= $fsize) { ($fsize, $pmod ) = (0, $pmod-$fsize); }
|
||||
else { ($pmod, $fsize) = (0, $fsize-$pmod); }
|
||||
@@ -101,7 +101,10 @@ foreach my $f (0..$#files) {
|
||||
$t->{libtorrent_resume}{'uncertain_pieces.timestamp'} = time;
|
||||
|
||||
# Some extra information to re-enforce the fact that this is a finished torrent
|
||||
$d .= $t->{info}{name};
|
||||
if (exists $t->{info}{files}) {
|
||||
$d .= $t->{info}{name};
|
||||
}
|
||||
|
||||
$t->{rtorrent} = {
|
||||
state => 1, # started
|
||||
state_changed => time,
|
||||
|
||||
Executable
+164
@@ -0,0 +1,164 @@
|
||||
#!/bin/bash
|
||||
#############
|
||||
###<Notes>###
|
||||
#############
|
||||
# This script depends on screen.
|
||||
# For the stop function to work, you must set an
|
||||
# explicit session directory using absolute paths (no, ~ is not absolute) in your rtorrent.rc.
|
||||
# If you typically just start rtorrent with just "rtorrent" on the
|
||||
# command line, all you need to change is the "user" option.
|
||||
# Attach to the screen session as your user with
|
||||
# "screen -dr rtorrent". Change "rtorrent" with srnname option.
|
||||
# Licensed under the GPLv2 by lostnihilist: lostnihilist _at_ gmail _dot_ com
|
||||
##############
|
||||
###</Notes>###
|
||||
##############
|
||||
|
||||
#######################
|
||||
##Start Configuration##
|
||||
#######################
|
||||
# You can specify your configuration in a different file
|
||||
# (so that it is saved with upgrades, saved in your home directory,
|
||||
# or whatever reason you want to)
|
||||
# by commenting out/deleting the configuration lines and placing them
|
||||
# in a text file (say /home/user/.rtorrent.init.conf) exactly as you would
|
||||
# have written them here (you can leave the comments if you desire
|
||||
# and then uncommenting the following line correcting the path/filename
|
||||
# for the one you used. note the space after the ".".
|
||||
# . /etc/rtorrent.init.conf
|
||||
|
||||
|
||||
#Do not put a space on either side of the equal signs e.g.
|
||||
# user = user
|
||||
# will not work
|
||||
# system user to run as (can only use one)
|
||||
user="user"
|
||||
|
||||
# system user to run as # not implemented, see d_start for beginning implementation
|
||||
# group=$(id -ng "$user")
|
||||
|
||||
# the full path to the filename where you store your rtorrent configuration
|
||||
# must keep parentheses around the entire statement, quotations around each config file
|
||||
config=("$(su -c 'echo $HOME' $user)/.rtorrent.rc")
|
||||
# Examples:
|
||||
# config=("/home/user/.rtorrent.rc")
|
||||
# config=("/home/user/.rtorrent.rc" "/mnt/some/drive/.rtorrent2.rc")
|
||||
# config=("/home/user/.rtorrent.rc"
|
||||
# "/mnt/some/drive/.rtorrent2.rc"
|
||||
# "/mnt/another/drive/.rtorrent3.rc")
|
||||
|
||||
# set of options to run with each instance, separated by a new line
|
||||
# must keep parentheses around the entire statement
|
||||
#if no special options, specify with: ""
|
||||
options=("")
|
||||
# Examples:
|
||||
# starts one instance, sourcing both .rtorrent.rc and .rtorrent2.rc
|
||||
# options=("-o import=~/.rtorrent2.rc")
|
||||
# starts two instances, ignoring .rtorrent.rc for both, and using
|
||||
# .rtorrent2.rc for the first, and .rtorrent3.rc for the second
|
||||
# we do not check for valid options
|
||||
# options=("-n -o import=~/.rtorrent2.rc" "-n -o import=~/rtorrent3.rc")
|
||||
|
||||
# default directory for screen, needs to be an absolute path
|
||||
base=$(su -c 'echo $HOME' $user)
|
||||
|
||||
# name of screen session
|
||||
srnname="rtorrent"
|
||||
|
||||
# file to log to (makes for easier debugging if something goes wrong)
|
||||
logfile="/var/log/rtorrentInit.log"
|
||||
#######################
|
||||
###END CONFIGURATION###
|
||||
#######################
|
||||
|
||||
PATH=/usr/bin:/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin
|
||||
DESC="rtorrent"
|
||||
NAME=rtorrent
|
||||
DAEMON=$NAME
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
|
||||
checkcnfg() {
|
||||
exists=0
|
||||
for i in `echo "$PATH" | tr ':' '\n'` ; do
|
||||
if [ -f $i/$NAME ] ; then
|
||||
exists=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ $exists -eq 0 ] ; then
|
||||
echo "cannot find $NAME binary in PATH: $PATH" | tee -a "$logfile" >&2
|
||||
exit 3
|
||||
fi
|
||||
for (( i=0 ; i < ${#config[@]} ; i++ )) ; do
|
||||
if ! [ -r "${config[i]}" ] ; then
|
||||
echo "cannot find readable config ${config[i]}. check that it is there and permissions are appropriate" | tee -a "$logfile" >&2
|
||||
exit 3
|
||||
fi
|
||||
session=$(getsession "${config[i]}")
|
||||
if ! [ -d "${session}" ] ; then
|
||||
echo "cannot find readable session directory ${session} from config ${config[i]}. check permissions" | tee -a "$logfile" >&2
|
||||
exit 3
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
d_start() {
|
||||
[ -d "${base}" ] && cd "${base}"
|
||||
stty stop undef && stty start undef
|
||||
su -c "screen -S "${srnname}" -X screen rtorrent ${options} 2>&1 1>/dev/null" ${user} | tee -a "$logfile" >&2
|
||||
# this works for the screen command, but starting rtorrent below adopts screen session gid
|
||||
# even if it is not the screen session we started (e.g. running under an undesirable gid
|
||||
#su -c "screen -ls | grep -sq "\.${srnname}[[:space:]]" " ${user} || su -c "sg \"$group\" -c \"screen -fn -dm -S ${srnname} 2>&1 1>/dev/null\"" ${user} | tee -a "$logfile" >&2
|
||||
for (( i=0 ; i < ${#options[@]} ; i++ )) ; do
|
||||
sleep 3
|
||||
su -c "screen -S "${srnname}" -X screen rtorrent ${options[i]} 2>&1 1>/dev/null" ${user} | tee -a "$logfile" >&2
|
||||
done
|
||||
}
|
||||
|
||||
d_stop() {
|
||||
for (( i=0 ; i < ${#config[@]} ; i++ )) ; do
|
||||
session=$(getsession "${config[i]}")
|
||||
if ! [ -s ${session}/rtorrent.lock ] ; then
|
||||
return
|
||||
fi
|
||||
pid=$(cat ${session}/rtorrent.lock | awk -F: '{print($2)}' | sed "s/[^0-9]//g")
|
||||
# make sure the pid doesn't belong to another process
|
||||
if ps -A | grep -sq ${pid}.*rtorrent ; then
|
||||
kill -s INT ${pid}
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
getsession() {
|
||||
session=$(cat "$1" | grep "^[[:space:]]*session[[:space:]]*=" | sed "s/^[[:space:]]*session[[:space:]]*=[[:space:]]*//" )
|
||||
#session=${session/#~/`getent passwd ${user}|cut -d: -f6`}
|
||||
echo $session
|
||||
}
|
||||
|
||||
checkcnfg
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting $DESC: $NAME"
|
||||
d_start
|
||||
echo "."
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping $DESC: $NAME"
|
||||
d_stop
|
||||
echo "."
|
||||
;;
|
||||
restart|force-reload)
|
||||
echo -n "Restarting $DESC: $NAME"
|
||||
d_stop
|
||||
sleep 1
|
||||
d_start
|
||||
echo "."
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
Executable
+137
@@ -0,0 +1,137 @@
|
||||
#!/bin/sh
|
||||
#############
|
||||
###<Notes>###
|
||||
#############
|
||||
# This script depends on screen.
|
||||
# For the stop function to work, you must set an
|
||||
# explicit session directory using ABSOLUTE paths (no, ~ is not absolute) in your rtorrent.rc.
|
||||
# If you typically just start rtorrent with just "rtorrent" on the
|
||||
# command line, all you need to change is the "user" option.
|
||||
# Attach to the screen session as your user with
|
||||
# "screen -dr rtorrent". Change "rtorrent" with srnname option.
|
||||
# Licensed under the GPLv2 by lostnihilist: lostnihilist _at_ gmail _dot_ com
|
||||
##############
|
||||
###</Notes>###
|
||||
##############
|
||||
|
||||
#######################
|
||||
##Start Configuration##
|
||||
#######################
|
||||
# You can specify your configuration in a different file
|
||||
# (so that it is saved with upgrades, saved in your home directory,
|
||||
# or whateve reason you want to)
|
||||
# by commenting out/deleting the configuration lines and placing them
|
||||
# in a text file (say /home/user/.rtorrent.init.conf) exactly as you would
|
||||
# have written them here (you can leave the comments if you desire
|
||||
# and then uncommenting the following line correcting the path/filename
|
||||
# for the one you used. note the space after the ".".
|
||||
# . /etc/rtorrent.init.conf
|
||||
|
||||
#Do not put a space on either side of the equal signs e.g.
|
||||
# user = user
|
||||
# will not work
|
||||
# system user to run as
|
||||
user="user"
|
||||
|
||||
# the system group to run as, not implemented, see d_start for beginning implementation
|
||||
# group=`id -ng "$user"`
|
||||
|
||||
# the full path to the filename where you store your rtorrent configuration
|
||||
config="`su -c 'echo $HOME' $user`/.rtorrent.rc"
|
||||
|
||||
# set of options to run with
|
||||
options=""
|
||||
|
||||
# default directory for screen, needs to be an absolute path
|
||||
base="`su -c 'echo $HOME' $user`"
|
||||
|
||||
# name of screen session
|
||||
srnname="rtorrent"
|
||||
|
||||
# file to log to (makes for easier debugging if something goes wrong)
|
||||
logfile="/var/log/rtorrentInit.log"
|
||||
#######################
|
||||
###END CONFIGURATION###
|
||||
#######################
|
||||
PATH=/usr/bin:/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin
|
||||
DESC="rtorrent"
|
||||
NAME=rtorrent
|
||||
DAEMON=$NAME
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
|
||||
checkcnfg() {
|
||||
exists=0
|
||||
for i in `echo "$PATH" | tr ':' '\n'` ; do
|
||||
if [ -f $i/$NAME ] ; then
|
||||
exists=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ $exists -eq 0 ] ; then
|
||||
echo "cannot find rtorrent binary in PATH $PATH" | tee -a "$logfile" >&2
|
||||
exit 3
|
||||
fi
|
||||
if ! [ -r "${config}" ] ; then
|
||||
echo "cannot find readable config ${config}. check that it is there and permissions are appropriate" | tee -a "$logfile" >&2
|
||||
exit 3
|
||||
fi
|
||||
session=`getsession "$config"`
|
||||
if ! [ -d "${session}" ] ; then
|
||||
echo "cannot find readable session directory ${session} from config ${config}. check permissions" | tee -a "$logfile" >&2
|
||||
exit 3
|
||||
fi
|
||||
}
|
||||
|
||||
d_start() {
|
||||
[ -d "${base}" ] && cd "${base}"
|
||||
stty stop undef && stty start undef
|
||||
su -c "screen -ls | grep -sq "\.${srnname}[[:space:]]" " ${user} || su -c "screen -dm -S ${srnname} 2>&1 1>/dev/null" ${user} | tee -a "$logfile" >&2
|
||||
# this works for the screen command, but starting rtorrent below adopts screen session gid
|
||||
# even if it is not the screen session we started (e.g. running under an undesirable gid
|
||||
#su -c "screen -ls | grep -sq "\.${srnname}[[:space:]]" " ${user} || su -c "sg \"$group\" -c \"screen -fn -dm -S ${srnname} 2>&1 1>/dev/null\"" ${user} | tee -a "$logfile" >&2
|
||||
su -c "screen -S "${srnname}" -X screen rtorrent ${options} 2>&1 1>/dev/null" ${user} | tee -a "$logfile" >&2
|
||||
}
|
||||
|
||||
d_stop() {
|
||||
session=`getsession "$config"`
|
||||
if ! [ -s ${session}/rtorrent.lock ] ; then
|
||||
return
|
||||
fi
|
||||
pid=`cat ${session}/rtorrent.lock | awk -F: '{print($2)}' | sed "s/[^0-9]//g"`
|
||||
if ps -A | grep -sq ${pid}.*rtorrent ; then # make sure the pid doesn't belong to another process
|
||||
kill -s INT ${pid}
|
||||
fi
|
||||
}
|
||||
|
||||
getsession() {
|
||||
session=`cat "$1" | grep "^[[:space:]]*session[[:space:]]*=" | sed "s/^[[:space:]]*session[[:space:]]*=[[:space:]]*//" `
|
||||
echo $session
|
||||
}
|
||||
|
||||
checkcnfg
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting $DESC: $NAME"
|
||||
d_start
|
||||
echo "."
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping $DESC: $NAME"
|
||||
d_stop
|
||||
echo "."
|
||||
;;
|
||||
restart|force-reload)
|
||||
echo -n "Restarting $DESC: $NAME"
|
||||
d_stop
|
||||
sleep 1
|
||||
d_start
|
||||
echo "."
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
Executable
+166
@@ -0,0 +1,166 @@
|
||||
#!/bin/bash
|
||||
### BEGIN INIT INFO
|
||||
# Provides: rtorrent_autostart
|
||||
# Required-Start: $local_fs $remote_fs $network $syslog $netdaemons
|
||||
# Required-Stop: $local_fs $remote_fs
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: rtorrent script using tmux
|
||||
# Description: rtorrent script using tmux
|
||||
### END INIT INFO
|
||||
|
||||
#############
|
||||
###<Notes>###
|
||||
#############
|
||||
# This script depends on tmux and is based on 'rtorrentInitScreen.sh' script
|
||||
# with the following enhancements:
|
||||
# - init script 'start' option can be called without breaking anything
|
||||
# - init script 'status' option can be used in scripts to determine whether rtorrent is running or not
|
||||
# - auto removes damaged/stuck 'rtorrent.lock' file if necessary
|
||||
# - saves session (just in case) before stopping with 'rtxmlrp' if it exists
|
||||
# - provides examples how to script tmux windows
|
||||
#
|
||||
# For the stop function to work, you must set an explicit session directory
|
||||
# using ABSOLUTE paths (no, ~ is not absolute) in your rtorrent.rc and with
|
||||
# "sessiondir" option.
|
||||
# If you typically just start rtorrent with just "rtorrent" on the
|
||||
# command line, all you need to change is the "user" and "sessiondir" option.
|
||||
# Attach to the tmux session as your user with
|
||||
# "tmux -2u new-session -A -s rtorrent". Change "rtorrent" with "tmuxname" option.
|
||||
# Licensed under the GPLv2 by lostnihilist: lostnihilist _at_ gmail _dot_ com
|
||||
##############
|
||||
###</Notes>###
|
||||
##############
|
||||
|
||||
#######################
|
||||
##Start Configuration##
|
||||
#######################
|
||||
# You can specify your configuration in a different file.
|
||||
# (so that it is saved with upgrades, saved in your home directory,
|
||||
# or whatever reason you want to)
|
||||
# by commenting out/deleting the configuration lines and placing them
|
||||
# in a text file (say /home/user/.rtorrent.init.conf) exactly as you would
|
||||
# have written them here (you can leave the comments if you desire
|
||||
# and then uncommenting the following line correcting the path/filename.
|
||||
# for the one you used. note the space after the ".".
|
||||
# . /etc/rtorrent.init.conf
|
||||
|
||||
# system user to run as
|
||||
user="username"
|
||||
|
||||
# default directory for tmux, needs to be an absolute path
|
||||
base=$(su -c 'echo $HOME' $user)
|
||||
|
||||
# the full path to the filename where you store your rtorrent configuration
|
||||
config="$base/.rtorrent.rc"
|
||||
|
||||
# the full path to the session directory of rtorrent
|
||||
sessiondir="/mnt/Torrents/.rtorrent/.session"
|
||||
|
||||
# options to pass to rtorrent; e.g. don't read config from $HOME but load alternate
|
||||
#options="-n -O import=$config"
|
||||
options=""
|
||||
|
||||
# name of tmux session
|
||||
tmuxname="rtorrent"
|
||||
|
||||
# name of window in tmux session
|
||||
tmuxwindowname="rT"
|
||||
#######################
|
||||
###END CONFIGURATION###
|
||||
#######################
|
||||
PATH=/usr/bin:/usr/local/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin
|
||||
NAME=rtorrent
|
||||
DAEMON=$NAME
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
RTXMLRPCBIN="$base/bin/rtxmlrpc"
|
||||
|
||||
|
||||
checkcnfg() {
|
||||
if [ -z "$(which $DAEMON)" ] ; then
|
||||
echo "Cannot find $DAEMON binary in PATH: $PATH"
|
||||
exit 3
|
||||
fi
|
||||
if ! [ -r "$config" ] ; then
|
||||
echo "Cannot find readable config $config. Check that it is there and permissions are appropriate"
|
||||
exit 3
|
||||
fi
|
||||
if ! [ -d "$sessiondir" ] ; then
|
||||
echo "Cannot find readable session directory $sessiondir from config $config. Check permissions"
|
||||
exit 3
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
status() {
|
||||
if [ -e "${sessiondir}/rtorrent.lock" ] ; then
|
||||
pid=`cat ${sessiondir}/rtorrent.lock | awk -F: '{print($2)}' | sed "s/[^0-9]//g"`
|
||||
# make sure the pid isn't empty and doesn't belong to another process : this will match lines containing rtorrent, which grep '[r]torrent' does not!
|
||||
# if there is no process as the 'pid' suggests then delete the stuck "rtorrent.lock" file (to be able to start rtorrent)
|
||||
[[ -n "$pid" ]] && ps aux | grep -sq ${pid}.*[r]torrent && echo -e ${pid} || rm -f "${sessiondir}/rtorrent.lock"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
d_start() {
|
||||
[ -d "$base" ] && cd "$base"
|
||||
# if STDIN is a terminal (we are using interactive mode)
|
||||
[ -t 0 ] && stty stop undef && stty start undef
|
||||
# start the default 2 tmux window (bash and mc) if there isn't tmux session called "tmuxname" option (rtorrent)
|
||||
if ! su -c "tmux ls | grep -sq ${tmuxname}: " $user ; then
|
||||
# 1st window (0): split it into 3 panes, display 'date' in the last one
|
||||
su -c "tmux -2u new-session -d -s ${tmuxname} -n 'shell1'" $user
|
||||
su -c "tmux -2u split-window -v -t ${tmuxname}:0 'bash'" $user
|
||||
su -c "tmux -2u split-window -h -t ${tmuxname}:0 'date; bash'" $user
|
||||
# 2nd window (1): start 'mc' if it exists
|
||||
su -c "tmux -2u new-window -t ${tmuxname}:1 -n 'mc1' 'command which mc && mc ~/; bash'" $user
|
||||
fi
|
||||
# start rtorrent always in the 3rd tmux window (2) if it's not running and leave shell behind to be able to see reason of a crash
|
||||
if [ "$(status)" == "" ]; then
|
||||
su -c "tmux -2u list-panes -t ${tmuxname}:2 &>/dev/null && tmux -2u respawn-pane -t ${tmuxname}:2 -k \"${DAEMON} ${options}; bash\" || tmux -2u new-window -t ${tmuxname}:2 -n ${tmuxwindowname} \"${DAEMON} ${options}; bash\"" $user
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
d_stop() {
|
||||
pid=$(status)
|
||||
if [ "$pid" != "" ]; then
|
||||
# save session before stopping explicitly (just in case) if rtxmlrpc util exists then wait for 5 seconds to be able to complete it
|
||||
[ -L "$RTXMLRPCBIN" ] && "$RTXMLRPCBIN" session.save &>/dev/null && sleep 5
|
||||
# INT (2, Interrupt from keyboard): normal shutdown
|
||||
kill -s INT $pid
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
checkcnfg
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting $tmuxwindowname: $NAME"
|
||||
d_start
|
||||
echo "."
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping $tmuxwindowname: $NAME"
|
||||
d_stop
|
||||
echo "."
|
||||
;;
|
||||
restart|force-reload)
|
||||
echo -n "Restarting $tmuxwindowname: $NAME"
|
||||
d_stop
|
||||
sleep 1
|
||||
d_start
|
||||
echo "."
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
PORT_NUMBER=${1:-5001}
|
||||
|
||||
echo "Option Strings"
|
||||
echo "=============="
|
||||
echo
|
||||
echo "Introduction"
|
||||
echo "------------"
|
||||
echo
|
||||
echo "Client version: " `xmlrpc2scgi.py -p scgi://127.0.0.1:${PORT_NUMBER} system.client_version`
|
||||
echo
|
||||
echo "Generated by 'rtorrent/doc/scripts/print_option_string.sh' on `date -u`."
|
||||
|
||||
for i in strings.choke_heuristics strings.choke_heuristics.upload strings.choke_heuristics.download strings.connection_type strings.encryption strings.ip_filter strings.ip_tos strings.log_group strings.tracker_event strings.tracker_mode; do
|
||||
echo
|
||||
echo $i
|
||||
echo `echo $i | tr 'a-z_.' '-'`
|
||||
echo
|
||||
echo '```'
|
||||
xmlrpc2scgi.py -p scgi://127.0.0.1:${PORT_NUMBER} $i | tr , '\n' | tr '[' ' ' | tr ']' ' '
|
||||
echo '```'
|
||||
done
|
||||
File diff suppressed because it is too large
Load Diff
+12
-12
@@ -53,8 +53,8 @@
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <tr1/functional>
|
||||
#include <tr1/memory>
|
||||
#include lt_tr1_functional
|
||||
#include lt_tr1_memory
|
||||
|
||||
namespace rak {
|
||||
|
||||
@@ -98,13 +98,13 @@ public:
|
||||
|
||||
bool is_valid() const { return m_base.get() != NULL; }
|
||||
|
||||
void set(base_type* base) { m_base = std::tr1::shared_ptr<base_type>(base); }
|
||||
void set(base_type* base) { m_base = std::shared_ptr<base_type>(base); }
|
||||
base_type* release() { return m_base.release(); }
|
||||
|
||||
Result operator () () { return (*m_base)(); }
|
||||
|
||||
private:
|
||||
std::tr1::shared_ptr<base_type> m_base;
|
||||
std::shared_ptr<base_type> m_base;
|
||||
};
|
||||
|
||||
template <typename Result, typename Arg1>
|
||||
@@ -115,13 +115,13 @@ public:
|
||||
|
||||
bool is_valid() const { return m_base.get() != NULL; }
|
||||
|
||||
void set(base_type* base) { m_base = std::tr1::shared_ptr<base_type>(base); }
|
||||
void set(base_type* base) { m_base = std::shared_ptr<base_type>(base); }
|
||||
base_type* release() { return m_base.release(); }
|
||||
|
||||
Result operator () (Arg1 arg1) { return (*m_base)(arg1); }
|
||||
|
||||
private:
|
||||
std::tr1::shared_ptr<base_type> m_base;
|
||||
std::shared_ptr<base_type> m_base;
|
||||
};
|
||||
|
||||
template <typename Result, typename Arg1, typename Arg2>
|
||||
@@ -132,13 +132,13 @@ public:
|
||||
|
||||
bool is_valid() const { return m_base.get() != NULL; }
|
||||
|
||||
void set(base_type* base) { m_base = std::tr1::shared_ptr<base_type>(base); }
|
||||
void set(base_type* base) { m_base = std::shared_ptr<base_type>(base); }
|
||||
base_type* release() { return m_base.release(); }
|
||||
|
||||
Result operator () (Arg1 arg1, Arg2 arg2) { return (*m_base)(arg1, arg2); }
|
||||
|
||||
private:
|
||||
std::tr1::shared_ptr<base_type> m_base;
|
||||
std::shared_ptr<base_type> m_base;
|
||||
};
|
||||
|
||||
template <typename Result, typename Arg2>
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
|
||||
bool is_valid() const { return m_base.get() != NULL; }
|
||||
|
||||
void set(base_type* base) { m_base = std::tr1::shared_ptr<base_type>(base); }
|
||||
void set(base_type* base) { m_base = std::shared_ptr<base_type>(base); }
|
||||
base_type* release() { return m_base.release(); }
|
||||
|
||||
Result operator () (Arg2 arg2) { return (*m_base)(arg2); }
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
Result operator () (Discard discard, Arg2 arg2) { return (*m_base)(arg2); }
|
||||
|
||||
private:
|
||||
std::tr1::shared_ptr<base_type> m_base;
|
||||
std::shared_ptr<base_type> m_base;
|
||||
};
|
||||
|
||||
template <typename Result, typename Arg1, typename Arg2, typename Arg3>
|
||||
@@ -169,13 +169,13 @@ public:
|
||||
|
||||
bool is_valid() const { return m_base.get() != NULL; }
|
||||
|
||||
void set(base_type* base) { m_base = std::tr1::shared_ptr<base_type>(base); }
|
||||
void set(base_type* base) { m_base = std::shared_ptr<base_type>(base); }
|
||||
base_type* release() { return m_base.release(); }
|
||||
|
||||
Result operator () (Arg1 arg1, Arg2 arg2, Arg3 arg3) { return (*m_base)(arg1, arg2, arg3); }
|
||||
|
||||
private:
|
||||
std::tr1::shared_ptr<base_type> m_base;
|
||||
std::shared_ptr<base_type> m_base;
|
||||
};
|
||||
|
||||
template <typename Result>
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
using base_type::end;
|
||||
using base_type::size;
|
||||
using base_type::empty;
|
||||
using base_type::clear;
|
||||
|
||||
priority_queue(Compare l = Compare(), Equal e = Equal())
|
||||
: m_compare(l), m_equal(e) {}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#ifndef RAK_PRIORITY_QUEUE_DEFAULT_H
|
||||
#define RAK_PRIORITY_QUEUE_DEFAULT_H
|
||||
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
#include <rak/allocators.h>
|
||||
#include <rak/priority_queue.h>
|
||||
#include <rak/timer.h>
|
||||
@@ -48,7 +48,7 @@ namespace rak {
|
||||
|
||||
class priority_item {
|
||||
public:
|
||||
typedef std::tr1::function<void (void)> slot_void;
|
||||
typedef std::function<void (void)> slot_void;
|
||||
|
||||
priority_item() {}
|
||||
~priority_item() {
|
||||
|
||||
+122
-43
@@ -109,13 +109,11 @@ public:
|
||||
const sockaddr* c_sockaddr() const { return &m_sockaddr; }
|
||||
const sockaddr_in* c_sockaddr_inet() const { return &m_sockaddrInet; }
|
||||
|
||||
#ifdef RAK_USE_INET6
|
||||
socket_address_inet6* sa_inet6() { return reinterpret_cast<socket_address_inet6*>(this); }
|
||||
const socket_address_inet6* sa_inet6() const { return reinterpret_cast<const socket_address_inet6*>(this); }
|
||||
|
||||
sockaddr_in6* c_sockaddr_inet6() { return &m_sockaddrInet6; }
|
||||
const sockaddr_in6* c_sockaddr_inet6() const { return &m_sockaddrInet6; }
|
||||
#endif
|
||||
|
||||
// Copy a socket address which has the length 'length. Zero out any
|
||||
// extranous bytes and ensure it does not go beyond the size of this
|
||||
@@ -139,13 +137,11 @@ private:
|
||||
union {
|
||||
sockaddr m_sockaddr;
|
||||
sockaddr_in m_sockaddrInet;
|
||||
#ifdef RAK_USE_INET6
|
||||
sockaddr_in6 m_sockaddrInet6;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
// Remeber to set the AF_INET.
|
||||
// Remember to set the AF_INET.
|
||||
|
||||
class socket_address_inet {
|
||||
public:
|
||||
@@ -184,6 +180,8 @@ public:
|
||||
|
||||
const sockaddr* c_sockaddr() const { return reinterpret_cast<const sockaddr*>(&m_sockaddr); }
|
||||
const sockaddr_in* c_sockaddr_inet() const { return &m_sockaddr; }
|
||||
|
||||
socket_address_inet6 to_mapped_address() const;
|
||||
|
||||
bool operator == (const socket_address_inet& rhs) const;
|
||||
bool operator < (const socket_address_inet& rhs) const;
|
||||
@@ -192,48 +190,47 @@ private:
|
||||
struct sockaddr_in m_sockaddr;
|
||||
};
|
||||
|
||||
// Unique key for the address, excluding port numbers etc.
|
||||
class socket_address_key {
|
||||
class socket_address_inet6 {
|
||||
public:
|
||||
// socket_address_host_key() {}
|
||||
bool is_any() const { return is_port_any() && is_address_any(); }
|
||||
bool is_valid() const { return !is_port_any() && !is_address_any(); }
|
||||
bool is_port_any() const { return port() == 0; }
|
||||
bool is_address_any() const { return std::memcmp(&m_sockaddr.sin6_addr, &in6addr_any, sizeof(in6_addr)) == 0; }
|
||||
|
||||
socket_address_key(const socket_address& sa) {
|
||||
*this = sa;
|
||||
}
|
||||
void clear() { std::memset(this, 0, sizeof(socket_address_inet6)); set_family(); }
|
||||
|
||||
socket_address_key& operator = (const socket_address& sa) {
|
||||
if (sa.family() == 0) {
|
||||
std::memset(this, 0, sizeof(socket_address_key));
|
||||
uint16_t port() const { return ntohs(m_sockaddr.sin6_port); }
|
||||
uint16_t port_n() const { return m_sockaddr.sin6_port; }
|
||||
void set_port(uint16_t p) { m_sockaddr.sin6_port = htons(p); }
|
||||
void set_port_n(uint16_t p) { m_sockaddr.sin6_port = p; }
|
||||
|
||||
} else if (sa.family() == socket_address::af_inet) {
|
||||
// Using hardware order as we use operator < to compare when
|
||||
// using inet only.
|
||||
m_addr.s_addr = sa.sa_inet()->address_h();
|
||||
in6_addr address() const { return m_sockaddr.sin6_addr; }
|
||||
const in6_addr* address_ptr() const { return &m_sockaddr.sin6_addr; }
|
||||
std::string address_str() const;
|
||||
bool address_c_str(char* buf, socklen_t size) const;
|
||||
|
||||
} else {
|
||||
// When we implement INET6 handling, embed the ipv4 address in
|
||||
// the ipv6 address.
|
||||
throw std::logic_error("socket_address_key(...) received an unsupported protocol family.");
|
||||
}
|
||||
void set_address(in6_addr a) { m_sockaddr.sin6_addr = a; }
|
||||
bool set_address_str(const std::string& a) { return set_address_c_str(a.c_str()); }
|
||||
bool set_address_c_str(const char* a);
|
||||
|
||||
return *this;
|
||||
}
|
||||
void set_address_any() { set_port(0); set_address(in6addr_any); }
|
||||
|
||||
// socket_address_key& operator = (const socket_address_key& sa) {
|
||||
// }
|
||||
sa_family_t family() const { return m_sockaddr.sin6_family; }
|
||||
void set_family() { m_sockaddr.sin6_family = AF_INET6; }
|
||||
|
||||
bool operator < (const socket_address_key& sa) const {
|
||||
// Compare the memory area instead.
|
||||
return m_addr.s_addr < sa.m_addr.s_addr;
|
||||
}
|
||||
sockaddr* c_sockaddr() { return reinterpret_cast<sockaddr*>(&m_sockaddr); }
|
||||
sockaddr_in6* c_sockaddr_inet6() { return &m_sockaddr; }
|
||||
|
||||
const sockaddr* c_sockaddr() const { return reinterpret_cast<const sockaddr*>(&m_sockaddr); }
|
||||
const sockaddr_in6* c_sockaddr_inet6() const { return &m_sockaddr; }
|
||||
|
||||
socket_address normalize_address() const;
|
||||
|
||||
bool operator == (const socket_address_inet6& rhs) const;
|
||||
bool operator < (const socket_address_inet6& rhs) const;
|
||||
|
||||
private:
|
||||
union {
|
||||
in_addr m_addr;
|
||||
// #ifdef RAK_USE_INET6
|
||||
// in_addr6 m_addr6;
|
||||
// #endif
|
||||
};
|
||||
struct sockaddr_in6 m_sockaddr;
|
||||
};
|
||||
|
||||
inline bool
|
||||
@@ -241,8 +238,8 @@ socket_address::is_valid() const {
|
||||
switch (family()) {
|
||||
case af_inet:
|
||||
return sa_inet()->is_valid();
|
||||
// case af_inet6:
|
||||
// return sa_inet6().is_valid();
|
||||
case af_inet6:
|
||||
return sa_inet6()->is_valid();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -253,6 +250,8 @@ socket_address::is_bindable() const {
|
||||
switch (family()) {
|
||||
case af_inet:
|
||||
return !sa_inet()->is_address_any();
|
||||
case af_inet6:
|
||||
return !sa_inet6()->is_address_any();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -263,6 +262,8 @@ socket_address::is_address_any() const {
|
||||
switch (family()) {
|
||||
case af_inet:
|
||||
return sa_inet()->is_address_any();
|
||||
case af_inet6:
|
||||
return sa_inet6()->is_address_any();
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
@@ -273,6 +274,8 @@ socket_address::port() const {
|
||||
switch (family()) {
|
||||
case af_inet:
|
||||
return sa_inet()->port();
|
||||
case af_inet6:
|
||||
return sa_inet6()->port();
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -283,6 +286,8 @@ socket_address::set_port(uint16_t p) {
|
||||
switch (family()) {
|
||||
case af_inet:
|
||||
return sa_inet()->set_port(p);
|
||||
case af_inet6:
|
||||
return sa_inet6()->set_port(p);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -293,6 +298,8 @@ socket_address::address_str() const {
|
||||
switch (family()) {
|
||||
case af_inet:
|
||||
return sa_inet()->address_str();
|
||||
case af_inet6:
|
||||
return sa_inet6()->address_str();
|
||||
default:
|
||||
return std::string();
|
||||
}
|
||||
@@ -303,6 +310,8 @@ socket_address::address_c_str(char* buf, socklen_t size) const {
|
||||
switch (family()) {
|
||||
case af_inet:
|
||||
return sa_inet()->address_c_str(buf, size);
|
||||
case af_inet6:
|
||||
return sa_inet6()->address_c_str(buf, size);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -314,6 +323,10 @@ socket_address::set_address_c_str(const char* a) {
|
||||
sa_inet()->set_family();
|
||||
return true;
|
||||
|
||||
} else if (sa_inet6()->set_address_c_str(a)) {
|
||||
sa_inet6()->set_family();
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -325,6 +338,8 @@ socket_address::length() const {
|
||||
switch(family()) {
|
||||
case af_inet:
|
||||
return sizeof(sockaddr_in);
|
||||
case af_inet6:
|
||||
return sizeof(sockaddr_in6);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -349,8 +364,8 @@ socket_address::operator == (const socket_address& rhs) const {
|
||||
switch (family()) {
|
||||
case af_inet:
|
||||
return *sa_inet() == *rhs.sa_inet();
|
||||
// case af_inet6:
|
||||
// return *sa_inet6() == *rhs.sa_inet6();
|
||||
case af_inet6:
|
||||
return *sa_inet6() == *rhs.sa_inet6();
|
||||
default:
|
||||
throw std::logic_error("socket_address::operator == (rhs) invalid type comparison.");
|
||||
}
|
||||
@@ -364,8 +379,8 @@ socket_address::operator < (const socket_address& rhs) const {
|
||||
switch (family()) {
|
||||
case af_inet:
|
||||
return *sa_inet() < *rhs.sa_inet();
|
||||
// case af_inet6:
|
||||
// return *sa_inet6() < *rhs.sa_inet6();
|
||||
case af_inet6:
|
||||
return *sa_inet6() < *rhs.sa_inet6();
|
||||
default:
|
||||
throw std::logic_error("socket_address::operator < (rhs) invalid type comparison.");
|
||||
}
|
||||
@@ -391,6 +406,21 @@ socket_address_inet::set_address_c_str(const char* a) {
|
||||
return inet_pton(AF_INET, a, &m_sockaddr.sin_addr);
|
||||
}
|
||||
|
||||
inline socket_address_inet6
|
||||
socket_address_inet::to_mapped_address() const {
|
||||
uint32_t addr32[4];
|
||||
addr32[0] = 0;
|
||||
addr32[1] = 0;
|
||||
addr32[2] = htonl(0xffff);
|
||||
addr32[3] = m_sockaddr.sin_addr.s_addr;
|
||||
|
||||
socket_address_inet6 sa;
|
||||
sa.clear();
|
||||
sa.set_address(*reinterpret_cast<in6_addr *>(addr32));
|
||||
sa.set_port_n(m_sockaddr.sin_port);
|
||||
return sa;
|
||||
}
|
||||
|
||||
inline bool
|
||||
socket_address_inet::operator == (const socket_address_inet& rhs) const {
|
||||
return
|
||||
@@ -406,6 +436,55 @@ socket_address_inet::operator < (const socket_address_inet& rhs) const {
|
||||
m_sockaddr.sin_port < rhs.m_sockaddr.sin_port);
|
||||
}
|
||||
|
||||
inline std::string
|
||||
socket_address_inet6::address_str() const {
|
||||
char buf[INET6_ADDRSTRLEN];
|
||||
|
||||
if (!address_c_str(buf, INET6_ADDRSTRLEN))
|
||||
return std::string();
|
||||
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
inline bool
|
||||
socket_address_inet6::address_c_str(char* buf, socklen_t size) const {
|
||||
return inet_ntop(family(), &m_sockaddr.sin6_addr, buf, size);
|
||||
}
|
||||
|
||||
inline bool
|
||||
socket_address_inet6::set_address_c_str(const char* a) {
|
||||
return inet_pton(AF_INET6, a, &m_sockaddr.sin6_addr);
|
||||
}
|
||||
|
||||
inline socket_address
|
||||
socket_address_inet6::normalize_address() const {
|
||||
const uint32_t *addr32 = reinterpret_cast<const uint32_t *>(m_sockaddr.sin6_addr.s6_addr);
|
||||
if (addr32[0] == 0 && addr32[1] == 0 && addr32[2] == htonl(0xffff)) {
|
||||
socket_address addr4;
|
||||
addr4.sa_inet()->set_family();
|
||||
addr4.sa_inet()->set_address_n(addr32[3]);
|
||||
addr4.sa_inet()->set_port_n(m_sockaddr.sin6_port);
|
||||
return addr4;
|
||||
}
|
||||
return *reinterpret_cast<const socket_address*>(this);
|
||||
}
|
||||
|
||||
inline bool
|
||||
socket_address_inet6::operator == (const socket_address_inet6& rhs) const {
|
||||
return
|
||||
memcmp(&m_sockaddr.sin6_addr, &rhs.m_sockaddr.sin6_addr, sizeof(in6_addr)) == 0 &&
|
||||
m_sockaddr.sin6_port == rhs.m_sockaddr.sin6_port;
|
||||
}
|
||||
|
||||
inline bool
|
||||
socket_address_inet6::operator < (const socket_address_inet6& rhs) const {
|
||||
int addr_comp = memcmp(&m_sockaddr.sin6_addr, &rhs.m_sockaddr.sin6_addr, sizeof(in6_addr));
|
||||
return
|
||||
addr_comp < 0 ||
|
||||
(addr_comp == 0 ||
|
||||
m_sockaddr.sin6_port < rhs.m_sockaddr.sin6_port);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_check_zlib.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_CHECK_ZLIB([action-if-found], [action-if-not-found])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# This macro searches for an installed zlib library. If nothing was
|
||||
# specified when calling configure, it searches first in /usr/local and
|
||||
# then in /usr, /opt/local and /sw. If the --with-zlib=DIR is specified,
|
||||
# it will try to find it in DIR/include/zlib.h and DIR/lib/libz.a. If
|
||||
# --without-zlib is specified, the library is not searched at all.
|
||||
#
|
||||
# If either the header file (zlib.h) or the library (libz) is not found,
|
||||
# shell commands 'action-if-not-found' is run. If 'action-if-not-found' is
|
||||
# not specified, the configuration exits on error, asking for a valid zlib
|
||||
# installation directory or --without-zlib.
|
||||
#
|
||||
# If both header file and library are found, shell commands
|
||||
# 'action-if-found' is run. If 'action-if-found' is not specified, the
|
||||
# default action appends '-I${ZLIB_HOME}/include' to CPFLAGS, appends
|
||||
# '-L$ZLIB_HOME}/lib' to LDFLAGS, prepends '-lz' to LIBS, and calls
|
||||
# AC_DEFINE(HAVE_LIBZ). You should use autoheader to include a definition
|
||||
# for this symbol in a config.h file. Sample usage in a C/C++ source is as
|
||||
# follows:
|
||||
#
|
||||
# #ifdef HAVE_LIBZ
|
||||
# #include <zlib.h>
|
||||
# #endif /* HAVE_LIBZ */
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Loic Dachary <loic@senga.org>
|
||||
# Copyright (c) 2010 Bastien Chevreux <bach@chevreux.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by the
|
||||
# Free Software Foundation; either version 2 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
||||
# Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# As a special exception, the respective Autoconf Macro's copyright owner
|
||||
# gives unlimited permission to copy, distribute and modify the configure
|
||||
# scripts that are the output of Autoconf when processing the Macro. You
|
||||
# need not follow the terms of the GNU General Public License when using
|
||||
# or distributing such scripts, even though portions of the text of the
|
||||
# Macro appear in them. The GNU General Public License (GPL) does govern
|
||||
# all other use of the material that constitutes the Autoconf Macro.
|
||||
#
|
||||
# This special exception to the GPL applies to versions of the Autoconf
|
||||
# Macro released by the Autoconf Archive. When you make and distribute a
|
||||
# modified version of the Autoconf Macro, you may extend this special
|
||||
# exception to the GPL to apply to your modified version as well.
|
||||
|
||||
#serial 14
|
||||
|
||||
AU_ALIAS([CHECK_ZLIB], [AX_CHECK_ZLIB])
|
||||
AC_DEFUN([AX_CHECK_ZLIB],
|
||||
#
|
||||
# Handle user hints
|
||||
#
|
||||
[AC_MSG_CHECKING(if zlib is wanted)
|
||||
zlib_places="/usr/local /usr /opt/local /sw"
|
||||
AC_ARG_WITH([zlib],
|
||||
[ --with-zlib=DIR root directory path of zlib installation @<:@defaults to
|
||||
/usr/local or /usr if not found in /usr/local@:>@
|
||||
--without-zlib to disable zlib usage completely],
|
||||
[if test "$withval" != no ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
if test -d "$withval"
|
||||
then
|
||||
zlib_places="$withval $zlib_places"
|
||||
else
|
||||
AC_MSG_WARN([Sorry, $withval does not exist, checking usual places])
|
||||
fi
|
||||
else
|
||||
zlib_places=
|
||||
AC_MSG_RESULT(no)
|
||||
fi],
|
||||
[AC_MSG_RESULT(yes)])
|
||||
|
||||
#
|
||||
# Locate zlib, if wanted
|
||||
#
|
||||
if test -n "${zlib_places}"
|
||||
then
|
||||
# check the user supplied or any other more or less 'standard' place:
|
||||
# Most UNIX systems : /usr/local and /usr
|
||||
# MacPorts / Fink on OSX : /opt/local respectively /sw
|
||||
for ZLIB_HOME in ${zlib_places} ; do
|
||||
if test -f "${ZLIB_HOME}/include/zlib.h"; then break; fi
|
||||
ZLIB_HOME=""
|
||||
done
|
||||
|
||||
ZLIB_OLD_LDFLAGS=$LDFLAGS
|
||||
ZLIB_OLD_CPPFLAGS=$CPPFLAGS
|
||||
if test -n "${ZLIB_HOME}"; then
|
||||
LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
|
||||
CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
|
||||
fi
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_C
|
||||
AC_CHECK_LIB([z], [inflateEnd], [zlib_cv_libz=yes], [zlib_cv_libz=no])
|
||||
AC_CHECK_HEADER([zlib.h], [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no])
|
||||
AC_LANG_RESTORE
|
||||
if test "$zlib_cv_libz" = "yes" && test "$zlib_cv_zlib_h" = "yes"
|
||||
then
|
||||
#
|
||||
# If both library and header were found, action-if-found
|
||||
#
|
||||
m4_ifblank([$1],[
|
||||
CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
|
||||
LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
|
||||
LIBS="-lz $LIBS"
|
||||
AC_DEFINE([HAVE_LIBZ], [1],
|
||||
[Define to 1 if you have `z' library (-lz)])
|
||||
],[
|
||||
# Restore variables
|
||||
LDFLAGS="$ZLIB_OLD_LDFLAGS"
|
||||
CPPFLAGS="$ZLIB_OLD_CPPFLAGS"
|
||||
$1
|
||||
])
|
||||
else
|
||||
#
|
||||
# If either header or library was not found, action-if-not-found
|
||||
#
|
||||
m4_default([$2],[
|
||||
AC_MSG_ERROR([either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib])
|
||||
])
|
||||
fi
|
||||
fi
|
||||
])
|
||||
@@ -0,0 +1,106 @@
|
||||
# ============================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_0x.html
|
||||
# ============================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_CXX_COMPILE_STDCXX_0X
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Check for baseline language coverage in the compiler for the C++0x
|
||||
# standard.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 7 (+1)
|
||||
|
||||
AU_ALIAS([AC_CXX_COMPILE_STDCXX_0X], [AX_CXX_COMPILE_STDCXX_0X])
|
||||
AC_DEFUN([AX_CXX_COMPILE_STDCXX_0X], [
|
||||
AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
|
||||
ax_cv_cxx_compile_cxx0x_native,
|
||||
[AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_TRY_COMPILE([
|
||||
template <typename T>
|
||||
struct check
|
||||
{
|
||||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||
};
|
||||
|
||||
typedef check<check<bool>> right_angle_brackets;
|
||||
|
||||
int a;
|
||||
decltype(a) b;
|
||||
|
||||
typedef check<int> check_type;
|
||||
check_type c;
|
||||
check_type&& cr = static_cast<check_type&&>(c);],,
|
||||
ax_cv_cxx_compile_cxx0x_native=yes, ax_cv_cxx_compile_cxx0x_native=no)
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
|
||||
AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
|
||||
ax_cv_cxx_compile_cxx0x_cxx,
|
||||
[AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS -std=c++0x"
|
||||
AC_TRY_COMPILE([
|
||||
template <typename T>
|
||||
struct check
|
||||
{
|
||||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||
};
|
||||
|
||||
typedef check<check<bool>> right_angle_brackets;
|
||||
|
||||
int a;
|
||||
decltype(a) b;
|
||||
|
||||
typedef check<int> check_type;
|
||||
check_type c;
|
||||
check_type&& cr = static_cast<check_type&&>(c);],,
|
||||
ax_cv_cxx_compile_cxx0x_cxx=yes, ax_cv_cxx_compile_cxx0x_cxx=no)
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
|
||||
AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
|
||||
ax_cv_cxx_compile_cxx0x_gxx,
|
||||
[AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS -std=gnu++0x"
|
||||
AC_TRY_COMPILE([
|
||||
template <typename T>
|
||||
struct check
|
||||
{
|
||||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||
};
|
||||
|
||||
typedef check<check<bool>> right_angle_brackets;
|
||||
|
||||
int a;
|
||||
decltype(a) b;
|
||||
|
||||
typedef check<int> check_type;
|
||||
check_type c;
|
||||
check_type&& cr = static_cast<check_type&&>(c);],,
|
||||
ax_cv_cxx_compile_cxx0x_gxx=yes, ax_cv_cxx_compile_cxx0x_gxx=no)
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
|
||||
if test "$ax_cv_cxx_compile_cxx0x_cxx" = yes; then
|
||||
AC_DEFINE(HAVE_STDCXX_0X,, [Define if compiler supports C++0x features.])
|
||||
CXXFLAGS="$CXXFLAGS -std=c++0x"
|
||||
fi
|
||||
])
|
||||
@@ -0,0 +1,147 @@
|
||||
# ============================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
|
||||
# ============================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Check for baseline language coverage in the compiler for the C++11
|
||||
# standard; if necessary, add switches to CXXFLAGS to enable support.
|
||||
#
|
||||
# The first argument, if specified, indicates whether you insist on an
|
||||
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
|
||||
# -std=c++11). If neither is specified, you get whatever works, with
|
||||
# preference for an extended mode.
|
||||
#
|
||||
# The second argument, if specified 'mandatory' or if left unspecified,
|
||||
# indicates that baseline C++11 support is required and that the macro
|
||||
# should error out if no mode with that support is found. If specified
|
||||
# 'optional', then configuration proceeds regardless, after defining
|
||||
# HAVE_CXX11 if and only if a supporting mode is found.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
|
||||
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
|
||||
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
|
||||
# Copyright (c) 2014 Alexey Sokolov <sokolov@google.com>
|
||||
# Copyright (c) 2014 Jari Sundell <sundell.software@gmail.com>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 5
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[
|
||||
template <typename T>
|
||||
struct check
|
||||
{
|
||||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||
};
|
||||
|
||||
struct Base {
|
||||
virtual void f() {}
|
||||
};
|
||||
struct Child : public Base {
|
||||
virtual void f() override {}
|
||||
};
|
||||
|
||||
typedef check<check<bool>> right_angle_brackets;
|
||||
|
||||
int a;
|
||||
decltype(a) b;
|
||||
|
||||
typedef check<int> check_type;
|
||||
check_type c;
|
||||
check_type&& cr = static_cast<check_type&&>(c);
|
||||
|
||||
auto d = a;
|
||||
auto l = [](){};
|
||||
|
||||
void unused() {
|
||||
l();
|
||||
}
|
||||
]])
|
||||
|
||||
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
|
||||
m4_if([$1], [], [],
|
||||
[$1], [ext], [],
|
||||
[$1], [noext], [],
|
||||
[m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
|
||||
m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
|
||||
[$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
|
||||
[$2], [optional], [ax_cxx_compile_cxx11_required=false],
|
||||
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
|
||||
AC_LANG_PUSH([C++])dnl
|
||||
ac_success=no
|
||||
AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
|
||||
ax_cv_cxx_compile_cxx11,
|
||||
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
||||
[ax_cv_cxx_compile_cxx11=yes],
|
||||
[ax_cv_cxx_compile_cxx11=no])])
|
||||
if test x$ax_cv_cxx_compile_cxx11 = xyes; then
|
||||
ac_success=yes
|
||||
fi
|
||||
|
||||
m4_if([$1], [noext], [], [dnl
|
||||
if test x$ac_success = xno; then
|
||||
for switch in -std=gnu++11 -std=gnu++0x; do
|
||||
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
|
||||
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
|
||||
$cachevar,
|
||||
[ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $switch"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
||||
[eval $cachevar=yes],
|
||||
[eval $cachevar=no])
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"])
|
||||
if eval test x\$$cachevar = xyes; then
|
||||
CXXFLAGS="$CXXFLAGS $switch"
|
||||
ac_success=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi])
|
||||
|
||||
m4_if([$1], [ext], [], [dnl
|
||||
if test x$ac_success = xno; then
|
||||
for switch in -std=c++11 -std=c++0x; do
|
||||
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
|
||||
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
|
||||
$cachevar,
|
||||
[ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $switch"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
||||
[eval $cachevar=yes],
|
||||
[eval $cachevar=no])
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"])
|
||||
if eval test x\$$cachevar = xyes; then
|
||||
CXXFLAGS="$CXXFLAGS $switch"
|
||||
ac_success=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi])
|
||||
AC_LANG_POP([C++])
|
||||
if test x$ax_cxx_compile_cxx11_required = xtrue; then
|
||||
if test x$ac_success = xno; then
|
||||
AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
|
||||
fi
|
||||
else
|
||||
if test x$ac_success = xno; then
|
||||
HAVE_CXX11=0
|
||||
AC_MSG_NOTICE([No compiler with C++11 support was found])
|
||||
else
|
||||
HAVE_CXX11=1
|
||||
AC_DEFINE(HAVE_CXX11,1,
|
||||
[define if the compiler supports basic C++11 syntax])
|
||||
fi
|
||||
|
||||
AC_SUBST(HAVE_CXX11)
|
||||
fi
|
||||
])
|
||||
@@ -354,51 +354,6 @@ AC_DEFUN([TORRENT_WITH_ADDRESS_SPACE], [
|
||||
])
|
||||
])
|
||||
|
||||
AC_DEFUN([TORRENT_CHECK_TR1], [
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_MSG_CHECKING(for TR1 support)
|
||||
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||
#include <tr1/unordered_map>
|
||||
class Foo;
|
||||
typedef std::tr1::unordered_map<Foo*, int> Bar;
|
||||
])],
|
||||
[
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_TR1, 1, Define to 1 if your C++ library supports the extensions from Technical Report 1)
|
||||
],
|
||||
[
|
||||
AC_MSG_RESULT(no)
|
||||
]
|
||||
)
|
||||
|
||||
AC_LANG_POP(C++)
|
||||
])
|
||||
|
||||
AC_DEFUN([TORRENT_CHECK_CXX11], [
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_MSG_CHECKING(for C++11 support)
|
||||
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
class Foo;
|
||||
typedef std::unordered_map<Foo*, int> Bar;
|
||||
|
||||
union test { Bar b1; };
|
||||
])],
|
||||
[
|
||||
AC_MSG_RESULT(yes)
|
||||
AC_DEFINE(HAVE_CXX11, 1, Define to 1 if your C++ compiler has support for C++11.)
|
||||
],
|
||||
[
|
||||
AC_MSG_RESULT(no)
|
||||
]
|
||||
)
|
||||
|
||||
AC_LANG_POP(C++)
|
||||
])
|
||||
|
||||
AC_DEFUN([TORRENT_WITH_FASTCGI], [
|
||||
AC_ARG_WITH(fastcgi,
|
||||
AC_HELP_STRING([--with-fastcgi=PATH], [enable FastCGI RPC support (DO NOT USE)]),
|
||||
|
||||
@@ -1,53 +1,3 @@
|
||||
AC_DEFUN([TORRENT_CHECK_CXXFLAGS], [
|
||||
|
||||
AC_MSG_CHECKING([for user-defined CXXFLAGS])
|
||||
|
||||
if test -n "$CXXFLAGS"; then
|
||||
AC_MSG_RESULT([user-defined "$CXXFLAGS"])
|
||||
else
|
||||
CXXFLAGS="-O2 -Wall"
|
||||
AC_MSG_RESULT([default "$CXXFLAGS"])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([TORRENT_ENABLE_DEBUG], [
|
||||
AC_ARG_ENABLE(debug,
|
||||
AC_HELP_STRING([--enable-debug], [enable debug information [[default=yes]]]),
|
||||
[
|
||||
if test "$enableval" = "yes"; then
|
||||
CXXFLAGS="$CXXFLAGS -g -DDEBUG"
|
||||
else
|
||||
CXXFLAGS="$CXXFLAGS -DNDEBUG"
|
||||
fi
|
||||
],[
|
||||
CXXFLAGS="$CXXFLAGS -g -DDEBUG"
|
||||
])
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([TORRENT_ENABLE_WERROR], [
|
||||
AC_ARG_ENABLE(werror,
|
||||
AC_HELP_STRING([--enable-werror], [enable the -Werror and -Wall flag [[default=no]]]),
|
||||
[
|
||||
if test "$enableval" = "yes"; then
|
||||
CXXFLAGS="$CXXFLAGS -Werror -Wall"
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([TORRENT_ENABLE_EXTRA_DEBUG], [
|
||||
AC_ARG_ENABLE(extra-debug,
|
||||
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.)
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([TORRENT_WITH_SYSROOT], [
|
||||
AC_ARG_WITH(sysroot,
|
||||
AC_HELP_STRING([--with-sysroot=PATH], [compile and link with a specific sysroot]),
|
||||
@@ -95,26 +45,6 @@ AC_DEFUN([TORRENT_ENABLE_ARCH], [
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([TORRENT_OTFD], [
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_MSG_CHECKING(for proper overloaded template function disambiguation)
|
||||
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||
template <typename T> void f(T&) {}
|
||||
template <typename T> void f(T*) {}
|
||||
int main() { int *i = 0; f(*i); f(i); }
|
||||
])],
|
||||
[
|
||||
AC_MSG_RESULT(yes)
|
||||
], [
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_ERROR([your compiler does not properly handle overloaded template function disambiguation])
|
||||
])
|
||||
|
||||
AC_LANG_POP(C++)
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([TORRENT_MINCORE_SIGNEDNESS], [
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_MSG_CHECKING(signedness of mincore parameter)
|
||||
@@ -310,34 +240,3 @@ AC_DEFUN([TORRENT_DISABLE_IPV6], [
|
||||
fi
|
||||
])
|
||||
])
|
||||
|
||||
AC_DEFUN([TORRENT_ENABLE_TR1], [
|
||||
AC_ARG_ENABLE(std_tr1,
|
||||
AC_HELP_STRING([--disable-std_tr1], [disable check for support for TR1 [[default=enable]]]),
|
||||
[
|
||||
if test "$enableval" = "yes"; then
|
||||
TORRENT_CHECK_TR1()
|
||||
else
|
||||
AC_MSG_CHECKING(for TR1 support)
|
||||
AC_MSG_RESULT(disabled)
|
||||
fi
|
||||
],[
|
||||
TORRENT_CHECK_TR1()
|
||||
])
|
||||
])
|
||||
|
||||
AC_DEFUN([TORRENT_ENABLE_CXX11], [
|
||||
AC_ARG_ENABLE(std_c++11,
|
||||
AC_HELP_STRING([--disable-std_c++11], [disable check for support for C++11 [[default=enable]]]),
|
||||
[
|
||||
if test "$enableval" = "yes"; then
|
||||
TORRENT_CHECK_CXX11()
|
||||
else
|
||||
AC_MSG_CHECKING(for C++11 support)
|
||||
AC_MSG_RESULT(disabled)
|
||||
fi
|
||||
],[
|
||||
TORRENT_CHECK_CXX11()
|
||||
]
|
||||
)
|
||||
])
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
#***************************************************************************
|
||||
# _ _ ____ _
|
||||
# Project ___| | | | _ \| |
|
||||
# / __| | | | |_) | |
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 2006, David Shaw <dshaw@jabberwocky.com>
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
# are also available at https://curl.haxx.se/docs/copyright.html.
|
||||
#
|
||||
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
# copies of the Software, and permit persons to whom the Software is
|
||||
# furnished to do so, under the terms of the COPYING file.
|
||||
#
|
||||
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
# KIND, either express or implied.
|
||||
#
|
||||
###########################################################################
|
||||
# LIBCURL_CHECK_CONFIG ([DEFAULT-ACTION], [MINIMUM-VERSION],
|
||||
# [ACTION-IF-YES], [ACTION-IF-NO])
|
||||
# ----------------------------------------------------------
|
||||
# David Shaw <dshaw@jabberwocky.com> May-09-2006
|
||||
#
|
||||
# Checks for libcurl. DEFAULT-ACTION is the string yes or no to
|
||||
# specify whether to default to --with-libcurl or --without-libcurl.
|
||||
# If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
|
||||
# minimum version of libcurl to accept. Pass the version as a regular
|
||||
# version number like 7.10.1. If not supplied, any version is
|
||||
# accepted. ACTION-IF-YES is a list of shell commands to run if
|
||||
# libcurl was successfully found and passed the various tests.
|
||||
# ACTION-IF-NO is a list of shell commands that are run otherwise.
|
||||
# Note that using --without-libcurl does run ACTION-IF-NO.
|
||||
#
|
||||
# This macro #defines HAVE_LIBCURL if a working libcurl setup is
|
||||
# found, and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary
|
||||
# values. Other useful defines are LIBCURL_FEATURE_xxx where xxx are
|
||||
# the various features supported by libcurl, and LIBCURL_PROTOCOL_yyy
|
||||
# where yyy are the various protocols supported by libcurl. Both xxx
|
||||
# and yyy are capitalized. See the list of AH_TEMPLATEs at the top of
|
||||
# the macro for the complete list of possible defines. Shell
|
||||
# variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also
|
||||
# defined to 'yes' for those features and protocols that were found.
|
||||
# Note that xxx and yyy keep the same capitalization as in the
|
||||
# curl-config list (e.g. it's "HTTP" and not "http").
|
||||
#
|
||||
# Users may override the detected values by doing something like:
|
||||
# LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure
|
||||
#
|
||||
# For the sake of sanity, this macro assumes that any libcurl that is
|
||||
# found is after version 7.7.2, the first version that included the
|
||||
# curl-config script. Note that it is very important for people
|
||||
# packaging binary versions of libcurl to include this script!
|
||||
# Without curl-config, we can only guess what protocols are available,
|
||||
# or use curl_version_info to figure it out at runtime.
|
||||
|
||||
AC_DEFUN([LIBCURL_CHECK_CONFIG],
|
||||
[
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL])
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4])
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6])
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz])
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS])
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_IDN],[Defined if libcurl supports IDN])
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_SSPI],[Defined if libcurl supports SSPI])
|
||||
AH_TEMPLATE([LIBCURL_FEATURE_NTLM],[Defined if libcurl supports NTLM])
|
||||
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_RTSP],[Defined if libcurl supports RTSP])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_POP3],[Defined if libcurl supports POP3])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_IMAP],[Defined if libcurl supports IMAP])
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_SMTP],[Defined if libcurl supports SMTP])
|
||||
|
||||
AC_ARG_WITH(libcurl,
|
||||
AS_HELP_STRING([--with-libcurl=PREFIX],[look for the curl library in PREFIX/lib and headers in PREFIX/include]),
|
||||
[_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])])
|
||||
|
||||
if test "$_libcurl_with" != "no" ; then
|
||||
|
||||
AC_PROG_AWK
|
||||
|
||||
_libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
|
||||
|
||||
_libcurl_try_link=yes
|
||||
|
||||
if test -d "$_libcurl_with" ; then
|
||||
LIBCURL_CPPFLAGS="-I$withval/include"
|
||||
_libcurl_ldflags="-L$withval/lib"
|
||||
AC_PATH_PROG([_libcurl_config],[curl-config],[],
|
||||
["$withval/bin"])
|
||||
else
|
||||
AC_PATH_PROG([_libcurl_config],[curl-config],[],[$PATH])
|
||||
fi
|
||||
|
||||
if test x$_libcurl_config != "x" ; then
|
||||
AC_CACHE_CHECK([for the version of libcurl],
|
||||
[libcurl_cv_lib_curl_version],
|
||||
[libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`])
|
||||
|
||||
_libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse`
|
||||
_libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse`
|
||||
|
||||
if test $_libcurl_wanted -gt 0 ; then
|
||||
AC_CACHE_CHECK([for libcurl >= version $2],
|
||||
[libcurl_cv_lib_version_ok],
|
||||
[
|
||||
if test $_libcurl_version -ge $_libcurl_wanted ; then
|
||||
libcurl_cv_lib_version_ok=yes
|
||||
else
|
||||
libcurl_cv_lib_version_ok=no
|
||||
fi
|
||||
])
|
||||
fi
|
||||
|
||||
if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes ; then
|
||||
if test x"$LIBCURL_CPPFLAGS" = "x" ; then
|
||||
LIBCURL_CPPFLAGS=`$_libcurl_config --cflags`
|
||||
fi
|
||||
if test x"$LIBCURL" = "x" ; then
|
||||
LIBCURL=`$_libcurl_config --libs`
|
||||
|
||||
# This is so silly, but Apple actually has a bug in their
|
||||
# curl-config script. Fixed in Tiger, but there are still
|
||||
# lots of Panther installs around.
|
||||
case "${host}" in
|
||||
powerpc-apple-darwin7*)
|
||||
LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'`
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# All curl-config scripts support --feature
|
||||
_libcurl_features=`$_libcurl_config --feature`
|
||||
|
||||
# Is it modern enough to have --protocols? (7.12.4)
|
||||
if test $_libcurl_version -ge 461828 ; then
|
||||
_libcurl_protocols=`$_libcurl_config --protocols`
|
||||
fi
|
||||
else
|
||||
_libcurl_try_link=no
|
||||
fi
|
||||
|
||||
unset _libcurl_wanted
|
||||
fi
|
||||
|
||||
if test $_libcurl_try_link = yes ; then
|
||||
|
||||
# we didn't find curl-config, so let's see if the user-supplied
|
||||
# link line (or failing that, "-lcurl") is enough.
|
||||
LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"}
|
||||
|
||||
AC_CACHE_CHECK([whether libcurl is usable],
|
||||
[libcurl_cv_lib_curl_usable],
|
||||
[
|
||||
_libcurl_save_cppflags=$CPPFLAGS
|
||||
CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS"
|
||||
_libcurl_save_libs=$LIBS
|
||||
LIBS="$LIBCURL $LIBS"
|
||||
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <curl/curl.h>]],[[
|
||||
/* Try and use a few common options to force a failure if we are
|
||||
missing symbols or can't link. */
|
||||
int x;
|
||||
curl_easy_setopt(NULL,CURLOPT_URL,NULL);
|
||||
x=CURL_ERROR_SIZE;
|
||||
x=CURLOPT_WRITEFUNCTION;
|
||||
x=CURLOPT_WRITEDATA;
|
||||
x=CURLOPT_ERRORBUFFER;
|
||||
x=CURLOPT_STDERR;
|
||||
x=CURLOPT_VERBOSE;
|
||||
if (x) {;}
|
||||
]])],libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no)
|
||||
|
||||
CPPFLAGS=$_libcurl_save_cppflags
|
||||
LIBS=$_libcurl_save_libs
|
||||
unset _libcurl_save_cppflags
|
||||
unset _libcurl_save_libs
|
||||
])
|
||||
|
||||
if test $libcurl_cv_lib_curl_usable = yes ; then
|
||||
|
||||
# Does curl_free() exist in this version of libcurl?
|
||||
# If not, fake it with free()
|
||||
|
||||
_libcurl_save_cppflags=$CPPFLAGS
|
||||
CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS"
|
||||
_libcurl_save_libs=$LIBS
|
||||
LIBS="$LIBS $LIBCURL"
|
||||
|
||||
AC_CHECK_FUNC(curl_free,,
|
||||
AC_DEFINE(curl_free,free,
|
||||
[Define curl_free() as free() if our version of curl lacks curl_free.]))
|
||||
|
||||
CPPFLAGS=$_libcurl_save_cppflags
|
||||
LIBS=$_libcurl_save_libs
|
||||
unset _libcurl_save_cppflags
|
||||
unset _libcurl_save_libs
|
||||
|
||||
AC_DEFINE(HAVE_LIBCURL,1,
|
||||
[Define to 1 if you have a functional curl library.])
|
||||
AC_SUBST(LIBCURL_CPPFLAGS)
|
||||
AC_SUBST(LIBCURL)
|
||||
|
||||
for _libcurl_feature in $_libcurl_features ; do
|
||||
AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1])
|
||||
eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes
|
||||
done
|
||||
|
||||
if test "x$_libcurl_protocols" = "x" ; then
|
||||
|
||||
# We don't have --protocols, so just assume that all
|
||||
# protocols are available
|
||||
_libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP"
|
||||
|
||||
if test x$libcurl_feature_SSL = xyes ; then
|
||||
_libcurl_protocols="$_libcurl_protocols HTTPS"
|
||||
|
||||
# FTPS wasn't standards-compliant until version
|
||||
# 7.11.0 (0x070b00 == 461568)
|
||||
if test $_libcurl_version -ge 461568; then
|
||||
_libcurl_protocols="$_libcurl_protocols FTPS"
|
||||
fi
|
||||
fi
|
||||
|
||||
# RTSP, IMAP, POP3 and SMTP were added in
|
||||
# 7.20.0 (0x071400 == 463872)
|
||||
if test $_libcurl_version -ge 463872; then
|
||||
_libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP"
|
||||
fi
|
||||
fi
|
||||
|
||||
for _libcurl_protocol in $_libcurl_protocols ; do
|
||||
AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1])
|
||||
eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes
|
||||
done
|
||||
else
|
||||
unset LIBCURL
|
||||
unset LIBCURL_CPPFLAGS
|
||||
fi
|
||||
fi
|
||||
|
||||
unset _libcurl_try_link
|
||||
unset _libcurl_version_parse
|
||||
unset _libcurl_config
|
||||
unset _libcurl_feature
|
||||
unset _libcurl_features
|
||||
unset _libcurl_protocol
|
||||
unset _libcurl_protocols
|
||||
unset _libcurl_version
|
||||
unset _libcurl_ldflags
|
||||
fi
|
||||
|
||||
if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes ; then
|
||||
# This is the IF-NO path
|
||||
ifelse([$4],,:,[$4])
|
||||
else
|
||||
# This is the IF-YES path
|
||||
ifelse([$3],,:,[$3])
|
||||
fi
|
||||
|
||||
unset _libcurl_with
|
||||
])dnl
|
||||
@@ -0,0 +1,63 @@
|
||||
AC_DEFUN([RAK_CHECK_CFLAGS], [
|
||||
|
||||
AC_MSG_CHECKING([for user-defined CFLAGS])
|
||||
|
||||
if test "$CFLAGS" = ""; then
|
||||
unset CFLAGS
|
||||
AC_MSG_RESULT([undefined])
|
||||
else
|
||||
AC_MSG_RESULT([user-defined "$CFLAGS"])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([RAK_CHECK_CXXFLAGS], [
|
||||
|
||||
AC_MSG_CHECKING([for user-defined CXXFLAGS])
|
||||
|
||||
if test "$CXXFLAGS" = ""; then
|
||||
unset CXXFLAGS
|
||||
AC_MSG_RESULT([undefined])
|
||||
else
|
||||
AC_MSG_RESULT([user-defined "$CXXFLAGS"])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([RAK_ENABLE_DEBUG], [
|
||||
AC_ARG_ENABLE(debug,
|
||||
AC_HELP_STRING([--enable-debug], [enable debug information [[default=yes]]]),
|
||||
[
|
||||
if test "$enableval" = "yes"; then
|
||||
CXXFLAGS="$CXXFLAGS -g -DDEBUG"
|
||||
else
|
||||
CXXFLAGS="$CXXFLAGS -DNDEBUG"
|
||||
fi
|
||||
],[
|
||||
CXXFLAGS="$CXXFLAGS -g -DDEBUG"
|
||||
])
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([RAK_ENABLE_WERROR], [
|
||||
AC_ARG_ENABLE(werror,
|
||||
AC_HELP_STRING([--enable-werror], [enable the -Werror and -Wall flags [[default -Wall only]]]),
|
||||
[
|
||||
if test "$enableval" = "yes"; then
|
||||
CXXFLAGS="$CXXFLAGS -Werror -Wall"
|
||||
fi
|
||||
],[
|
||||
CXXFLAGS="$CXXFLAGS -Wall"
|
||||
])
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([RAK_ENABLE_EXTRA_DEBUG], [
|
||||
AC_ARG_ENABLE(extra-debug,
|
||||
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.)
|
||||
fi
|
||||
])
|
||||
])
|
||||
@@ -0,0 +1,61 @@
|
||||
AC_DEFUN([RAK_CHECK_CXX11], [
|
||||
AC_ARG_ENABLE([c++0x],
|
||||
AC_HELP_STRING([--enable-c++0x], [compile with C++0x (unsupported)]),
|
||||
[
|
||||
if test "$enableval" = "yes"; then
|
||||
AX_CXX_COMPILE_STDCXX_0X
|
||||
else
|
||||
AX_CXX_COMPILE_STDCXX_11(noext)
|
||||
fi
|
||||
],[
|
||||
AX_CXX_COMPILE_STDCXX_11(noext)
|
||||
]
|
||||
)
|
||||
])
|
||||
|
||||
AC_DEFUN([RAK_CHECK_TR1_LIB], [
|
||||
AC_LANG_PUSH(C++)
|
||||
AC_MSG_CHECKING(should use TR1 headers)
|
||||
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||
#include <unordered_map>
|
||||
class Foo; typedef std::unordered_map<Foo*, int> Bar;
|
||||
Bar b1;
|
||||
])
|
||||
], [
|
||||
AC_MSG_RESULT(no)
|
||||
AC_DEFINE(USE_TR1_LIB, 0, Define to 1 if you need to use TR1 containers.)
|
||||
|
||||
AC_DEFINE([lt_tr1_array], [<array>], [TR1 array])
|
||||
AC_DEFINE([lt_tr1_functional], [<functional>], [TR1 functional])
|
||||
AC_DEFINE([lt_tr1_memory], [<memory>], [TR1 memory])
|
||||
AC_DEFINE([lt_tr1_unordered_map], [<unordered_map>], [TR1 unordered_map])
|
||||
|
||||
], [
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||
#include <tr1/unordered_map>
|
||||
class Foo; typedef std::tr1::unordered_map<Foo*, int> Bar;
|
||||
Bar b1;
|
||||
])
|
||||
], [
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_DEFINE(USE_TR1_LIB, 1, Define to 1 if you need to use TR1 containers.)
|
||||
|
||||
AC_DEFINE([lt_tr1_array], [<tr1/array>], [TR1 array])
|
||||
AC_DEFINE([lt_tr1_functional], [<tr1/functional>], [TR1 functional])
|
||||
AC_DEFINE([lt_tr1_memory], [<tr1/memory>], [TR1 memory])
|
||||
AC_DEFINE([lt_tr1_unordered_map], [<tr1/unordered_map>], [TR1 unordered_map])
|
||||
|
||||
], [
|
||||
AC_MSG_ERROR([No support for C++11 standard library nor TR1 extensions found.])
|
||||
])
|
||||
])
|
||||
|
||||
AH_VERBATIM(lt_tr1_zzz, [
|
||||
#if USE_TR1_LIB == 1
|
||||
namespace std { namespace tr1 {} using namespace tr1; }
|
||||
#endif
|
||||
])
|
||||
|
||||
AC_LANG_POP(C++)
|
||||
])
|
||||
@@ -18,6 +18,7 @@ libsub_root_a_SOURCES = \
|
||||
command_helpers.h \
|
||||
command_groups.cc \
|
||||
command_local.cc \
|
||||
command_logging.cc \
|
||||
command_network.cc \
|
||||
command_peer.cc \
|
||||
command_throttle.cc \
|
||||
|
||||
+131
-127
@@ -308,7 +308,10 @@ apply_d_add_peer(core::Download* download, const std::string& arg) {
|
||||
if (download->download()->info()->is_private())
|
||||
throw torrent::input_error("Download is private.");
|
||||
|
||||
ret = std::sscanf(arg.c_str(), "%1023[^:]:%i%c", host, &port, &dummy);
|
||||
ret = std::sscanf(arg.c_str(), "[%64[^]]]:%i%c", host, &port, &dummy);
|
||||
|
||||
if (ret < 1)
|
||||
ret = std::sscanf(arg.c_str(), "%1023[^:]:%i%c", host, &port, &dummy);
|
||||
|
||||
if (ret == 1)
|
||||
port = 6881;
|
||||
@@ -318,7 +321,7 @@ apply_d_add_peer(core::Download* download, const std::string& arg) {
|
||||
if (port < 1 || port > 65535)
|
||||
throw torrent::input_error("Invalid port number.");
|
||||
|
||||
torrent::connection_manager()->resolver()(host, (int)rak::socket_address::pf_inet, SOCK_STREAM, call_add_d_peer_t(download, port));
|
||||
torrent::connection_manager()->resolver()(host, (int)rak::socket_address::pf_unspec, SOCK_STREAM, call_add_d_peer_t(download, port));
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
@@ -356,7 +359,7 @@ f_multicall(core::Download* download, const torrent::Object::list_type& args) {
|
||||
if (args.front().is_list())
|
||||
std::transform(args.front().as_list().begin(), args.front().as_list().end(),
|
||||
std::back_inserter(regex_list),
|
||||
tr1::bind(&torrent::Object::as_string_c, tr1::placeholders::_1));
|
||||
std::bind(&torrent::Object::as_string_c, std::placeholders::_1));
|
||||
else if (args.front().is_string() && !args.front().as_string().empty())
|
||||
regex_list.push_back(args.front().as_string());
|
||||
else
|
||||
@@ -365,7 +368,7 @@ f_multicall(core::Download* download, const torrent::Object::list_type& args) {
|
||||
for (torrent::FileList::const_iterator itr = download->file_list()->begin(), last = download->file_list()->end(); itr != last; itr++) {
|
||||
if (use_regex &&
|
||||
std::find_if(regex_list.begin(), regex_list.end(),
|
||||
tr1::bind(&rak::regex::operator(), tr1::placeholders::_1, (*itr)->path()->as_string())) == regex_list.end())
|
||||
std::bind(&rak::regex::operator(), std::placeholders::_1, (*itr)->path()->as_string())) == regex_list.end())
|
||||
continue;
|
||||
|
||||
torrent::Object::list_type& row = result.insert(result.end(), torrent::Object::create_list())->as_list();
|
||||
@@ -581,52 +584,52 @@ d_list_remove(core::Download* download, const torrent::Object& rawArgs, const ch
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
#define CMD2_ON_INFO(func) tr1::bind(&torrent::DownloadInfo::func, tr1::bind(&core::Download::info, tr1::placeholders::_1))
|
||||
#define CMD2_ON_DATA(func) tr1::bind(&torrent::download_data::func, tr1::bind(&core::Download::data, tr1::placeholders::_1))
|
||||
#define CMD2_ON_DL(func) tr1::bind(&torrent::Download::func, tr1::bind(&core::Download::download, tr1::placeholders::_1))
|
||||
#define CMD2_ON_FL(func) tr1::bind(&torrent::FileList::func, tr1::bind(&core::Download::file_list, tr1::placeholders::_1))
|
||||
#define CMD2_ON_INFO(func) std::bind(&torrent::DownloadInfo::func, std::bind(&core::Download::info, std::placeholders::_1))
|
||||
#define CMD2_ON_DATA(func) std::bind(&torrent::download_data::func, std::bind(&core::Download::data, std::placeholders::_1))
|
||||
#define CMD2_ON_DL(func) std::bind(&torrent::Download::func, std::bind(&core::Download::download, std::placeholders::_1))
|
||||
#define CMD2_ON_FL(func) std::bind(&torrent::FileList::func, std::bind(&core::Download::file_list, std::placeholders::_1))
|
||||
|
||||
#define CMD2_BIND_DL tr1::bind(&core::Download::download, tr1::placeholders::_1)
|
||||
#define CMD2_BIND_CL tr1::bind(&core::Download::connection_list, tr1::placeholders::_1)
|
||||
#define CMD2_BIND_FL tr1::bind(&core::Download::file_list, tr1::placeholders::_1)
|
||||
#define CMD2_BIND_PL tr1::bind(&core::Download::c_peer_list, tr1::placeholders::_1)
|
||||
#define CMD2_BIND_TL tr1::bind(&core::Download::tracker_list, tr1::placeholders::_1)
|
||||
#define CMD2_BIND_TC tr1::bind(&core::Download::tracker_controller, tr1::placeholders::_1)
|
||||
#define CMD2_BIND_DL std::bind(&core::Download::download, std::placeholders::_1)
|
||||
#define CMD2_BIND_CL std::bind(&core::Download::connection_list, std::placeholders::_1)
|
||||
#define CMD2_BIND_FL std::bind(&core::Download::file_list, std::placeholders::_1)
|
||||
#define CMD2_BIND_PL std::bind(&core::Download::c_peer_list, std::placeholders::_1)
|
||||
#define CMD2_BIND_TL std::bind(&core::Download::tracker_list, std::placeholders::_1)
|
||||
#define CMD2_BIND_TC std::bind(&core::Download::tracker_controller, std::placeholders::_1)
|
||||
|
||||
#define CMD2_BIND_INFO tr1::bind(&core::Download::info, tr1::placeholders::_1)
|
||||
#define CMD2_BIND_DATA tr1::bind(&core::Download::data, tr1::placeholders::_1)
|
||||
#define CMD2_BIND_INFO std::bind(&core::Download::info, std::placeholders::_1)
|
||||
#define CMD2_BIND_DATA std::bind(&core::Download::data, std::placeholders::_1)
|
||||
|
||||
#define CMD2_DL_VAR_VALUE(key, first_key, second_key) \
|
||||
CMD2_DL(key, tr1::bind(&download_get_variable, tr1::placeholders::_1, first_key, second_key)); \
|
||||
CMD2_DL_VALUE_P(key ".set", tr1::bind(&download_set_variable_value, \
|
||||
tr1::placeholders::_1, tr1::placeholders::_2, \
|
||||
CMD2_DL(key, std::bind(&download_get_variable, std::placeholders::_1, first_key, second_key)); \
|
||||
CMD2_DL_VALUE_P(key ".set", std::bind(&download_set_variable_value, \
|
||||
std::placeholders::_1, std::placeholders::_2, \
|
||||
first_key, second_key));
|
||||
|
||||
#define CMD2_DL_VAR_VALUE_PUBLIC(key, first_key, second_key) \
|
||||
CMD2_DL(key, tr1::bind(&download_get_variable, tr1::placeholders::_1, first_key, second_key)); \
|
||||
CMD2_DL_VALUE(key ".set", tr1::bind(&download_set_variable_value, \
|
||||
tr1::placeholders::_1, tr1::placeholders::_2, \
|
||||
CMD2_DL(key, std::bind(&download_get_variable, std::placeholders::_1, first_key, second_key)); \
|
||||
CMD2_DL_VALUE(key ".set", std::bind(&download_set_variable_value, \
|
||||
std::placeholders::_1, std::placeholders::_2, \
|
||||
first_key, second_key));
|
||||
|
||||
#define CMD2_DL_TIMESTAMP(key, first_key, second_key) \
|
||||
CMD2_DL(key, tr1::bind(&download_get_variable, tr1::placeholders::_1, first_key, second_key)); \
|
||||
CMD2_DL_VALUE_P(key ".set", tr1::bind(&download_set_variable_value, \
|
||||
tr1::placeholders::_1, tr1::placeholders::_2, \
|
||||
CMD2_DL(key, std::bind(&download_get_variable, std::placeholders::_1, first_key, second_key)); \
|
||||
CMD2_DL_VALUE_P(key ".set", std::bind(&download_set_variable_value, \
|
||||
std::placeholders::_1, std::placeholders::_2, \
|
||||
first_key, second_key)); \
|
||||
CMD2_DL_VALUE_P(key ".set_if_z", tr1::bind(&download_set_variable_value_ifz, \
|
||||
tr1::placeholders::_1, tr1::placeholders::_2, \
|
||||
CMD2_DL_VALUE_P(key ".set_if_z", std::bind(&download_set_variable_value_ifz, \
|
||||
std::placeholders::_1, std::placeholders::_2, \
|
||||
first_key, second_key)); \
|
||||
|
||||
#define CMD2_DL_VAR_STRING(key, first_key, second_key) \
|
||||
CMD2_DL(key, tr1::bind(&download_get_variable, tr1::placeholders::_1, first_key, second_key)); \
|
||||
CMD2_DL_STRING_P(key ".set", tr1::bind(&download_set_variable_string, \
|
||||
tr1::placeholders::_1, tr1::placeholders::_2, \
|
||||
CMD2_DL(key, std::bind(&download_get_variable, std::placeholders::_1, first_key, second_key)); \
|
||||
CMD2_DL_STRING_P(key ".set", std::bind(&download_set_variable_string, \
|
||||
std::placeholders::_1, std::placeholders::_2, \
|
||||
first_key, second_key));
|
||||
|
||||
#define CMD2_DL_VAR_STRING_PUBLIC(key, first_key, second_key) \
|
||||
CMD2_DL(key, tr1::bind(&download_get_variable, tr1::placeholders::_1, first_key, second_key)); \
|
||||
CMD2_DL_STRING(key ".set", tr1::bind(&download_set_variable_string, \
|
||||
tr1::placeholders::_1, tr1::placeholders::_2, \
|
||||
CMD2_DL(key, std::bind(&download_get_variable, std::placeholders::_1, first_key, second_key)); \
|
||||
CMD2_DL_STRING(key ".set", std::bind(&download_set_variable_string, \
|
||||
std::placeholders::_1, std::placeholders::_2, \
|
||||
first_key, second_key));
|
||||
|
||||
int64_t cg_d_group(core::Download* download);
|
||||
@@ -635,12 +638,12 @@ void cg_d_group_set(core::Download* download, const torrent::Objec
|
||||
|
||||
void
|
||||
initialize_command_download() {
|
||||
CMD2_DL("d.hash", tr1::bind(&rak::transform_hex_str<torrent::HashString>, CMD2_ON_INFO(hash)));
|
||||
CMD2_DL("d.local_id", tr1::bind(&rak::transform_hex_str<torrent::HashString>, CMD2_ON_INFO(local_id)));
|
||||
CMD2_DL("d.local_id_html", tr1::bind(&rak::copy_escape_html_str<torrent::HashString>, CMD2_ON_INFO(local_id)));
|
||||
CMD2_DL("d.bitfield", tr1::bind(&retrieve_d_bitfield, tr1::placeholders::_1));
|
||||
CMD2_DL("d.base_path", tr1::bind(&retrieve_d_base_path, tr1::placeholders::_1));
|
||||
CMD2_DL("d.base_filename", tr1::bind(&retrieve_d_base_filename, tr1::placeholders::_1));
|
||||
CMD2_DL("d.hash", std::bind(&rak::transform_hex_str<torrent::HashString>, CMD2_ON_INFO(hash)));
|
||||
CMD2_DL("d.local_id", std::bind(&rak::transform_hex_str<torrent::HashString>, CMD2_ON_INFO(local_id)));
|
||||
CMD2_DL("d.local_id_html", std::bind(&rak::copy_escape_html_str<torrent::HashString>, CMD2_ON_INFO(local_id)));
|
||||
CMD2_DL("d.bitfield", std::bind(&retrieve_d_bitfield, std::placeholders::_1));
|
||||
CMD2_DL("d.base_path", std::bind(&retrieve_d_base_path, std::placeholders::_1));
|
||||
CMD2_DL("d.base_filename", std::bind(&retrieve_d_base_filename, std::placeholders::_1));
|
||||
|
||||
CMD2_DL("d.name", CMD2_ON_INFO(name));
|
||||
CMD2_DL("d.creation_date", CMD2_ON_INFO(creation_date));
|
||||
@@ -650,19 +653,19 @@ initialize_command_download() {
|
||||
// Network related:
|
||||
//
|
||||
|
||||
CMD2_DL ("d.up.rate", tr1::bind(&torrent::Rate::rate, CMD2_ON_INFO(up_rate)));
|
||||
CMD2_DL ("d.up.total", tr1::bind(&torrent::Rate::total, CMD2_ON_INFO(up_rate)));
|
||||
CMD2_DL ("d.down.rate", tr1::bind(&torrent::Rate::rate, CMD2_ON_INFO(down_rate)));
|
||||
CMD2_DL ("d.down.total", tr1::bind(&torrent::Rate::total, CMD2_ON_INFO(down_rate)));
|
||||
CMD2_DL ("d.skip.rate", tr1::bind(&torrent::Rate::rate, CMD2_ON_INFO(skip_rate)));
|
||||
CMD2_DL ("d.skip.total", tr1::bind(&torrent::Rate::total, CMD2_ON_INFO(skip_rate)));
|
||||
CMD2_DL ("d.up.rate", std::bind(&torrent::Rate::rate, CMD2_ON_INFO(up_rate)));
|
||||
CMD2_DL ("d.up.total", std::bind(&torrent::Rate::total, CMD2_ON_INFO(up_rate)));
|
||||
CMD2_DL ("d.down.rate", std::bind(&torrent::Rate::rate, CMD2_ON_INFO(down_rate)));
|
||||
CMD2_DL ("d.down.total", std::bind(&torrent::Rate::total, CMD2_ON_INFO(down_rate)));
|
||||
CMD2_DL ("d.skip.rate", std::bind(&torrent::Rate::rate, CMD2_ON_INFO(skip_rate)));
|
||||
CMD2_DL ("d.skip.total", std::bind(&torrent::Rate::total, CMD2_ON_INFO(skip_rate)));
|
||||
|
||||
CMD2_DL ("d.peer_exchange", CMD2_ON_INFO(is_pex_enabled));
|
||||
CMD2_DL_VALUE_V ("d.peer_exchange.set", tr1::bind(&torrent::Download::set_pex_enabled, CMD2_BIND_DL, tr1::placeholders::_2));
|
||||
CMD2_DL_VALUE_V ("d.peer_exchange.set", std::bind(&torrent::Download::set_pex_enabled, CMD2_BIND_DL, std::placeholders::_2));
|
||||
|
||||
CMD2_DL_LIST ("d.create_link", tr1::bind(&apply_d_change_link, tr1::placeholders::_1, tr1::placeholders::_2, 0));
|
||||
CMD2_DL_LIST ("d.delete_link", tr1::bind(&apply_d_change_link, tr1::placeholders::_1, tr1::placeholders::_2, 1));
|
||||
CMD2_DL ("d.delete_tied", tr1::bind(&apply_d_delete_tied, tr1::placeholders::_1));
|
||||
CMD2_DL_LIST ("d.create_link", std::bind(&apply_d_change_link, std::placeholders::_1, std::placeholders::_2, 0));
|
||||
CMD2_DL_LIST ("d.delete_link", std::bind(&apply_d_change_link, std::placeholders::_1, std::placeholders::_2, 1));
|
||||
CMD2_DL ("d.delete_tied", std::bind(&apply_d_delete_tied, std::placeholders::_1));
|
||||
|
||||
CMD2_FUNC_SINGLE("d.start", "d.hashing_failed.set=0 ;view.set_visible=started");
|
||||
CMD2_FUNC_SINGLE("d.stop", "view.set_visible=stopped");
|
||||
@@ -676,36 +679,37 @@ initialize_command_download() {
|
||||
|
||||
CMD2_DL ("d.is_open", CMD2_ON_INFO(is_open));
|
||||
CMD2_DL ("d.is_active", CMD2_ON_INFO(is_active));
|
||||
CMD2_DL ("d.is_hash_checked", tr1::bind(&torrent::Download::is_hash_checked, CMD2_BIND_DL));
|
||||
CMD2_DL ("d.is_hash_checking", tr1::bind(&torrent::Download::is_hash_checking, CMD2_BIND_DL));
|
||||
CMD2_DL ("d.is_multi_file", tr1::bind(&torrent::FileList::is_multi_file, CMD2_BIND_FL));
|
||||
CMD2_DL ("d.is_hash_checked", std::bind(&torrent::Download::is_hash_checked, CMD2_BIND_DL));
|
||||
CMD2_DL ("d.is_hash_checking", std::bind(&torrent::Download::is_hash_checking, CMD2_BIND_DL));
|
||||
CMD2_DL ("d.is_multi_file", std::bind(&torrent::FileList::is_multi_file, CMD2_BIND_FL));
|
||||
CMD2_DL ("d.is_private", CMD2_ON_INFO(is_private));
|
||||
CMD2_DL ("d.is_pex_active", CMD2_ON_INFO(is_pex_active));
|
||||
CMD2_DL ("d.is_partially_done", CMD2_ON_DATA(is_partially_done));
|
||||
CMD2_DL ("d.is_not_partially_done", CMD2_ON_DATA(is_not_partially_done));
|
||||
CMD2_DL ("d.is_meta", CMD2_ON_INFO(is_meta_download));
|
||||
|
||||
CMD2_DL_V ("d.resume", tr1::bind(&core::DownloadList::resume_default, control->core()->download_list(), tr1::placeholders::_1));
|
||||
CMD2_DL_V ("d.pause", tr1::bind(&core::DownloadList::pause_default, control->core()->download_list(), tr1::placeholders::_1));
|
||||
CMD2_DL_V ("d.open", tr1::bind(&core::DownloadList::open_throw, control->core()->download_list(), tr1::placeholders::_1));
|
||||
CMD2_DL_V ("d.close", tr1::bind(&core::DownloadList::close_throw, control->core()->download_list(), tr1::placeholders::_1));
|
||||
CMD2_DL_V ("d.close.directly", tr1::bind(&core::DownloadList::close_directly, control->core()->download_list(), tr1::placeholders::_1));
|
||||
CMD2_DL_V ("d.erase", tr1::bind(&core::DownloadList::erase_ptr, control->core()->download_list(), tr1::placeholders::_1));
|
||||
CMD2_DL_V ("d.check_hash", tr1::bind(&core::DownloadList::check_hash, control->core()->download_list(), tr1::placeholders::_1));
|
||||
CMD2_DL_V ("d.resume", std::bind(&core::DownloadList::resume_default, control->core()->download_list(), std::placeholders::_1));
|
||||
CMD2_DL_V ("d.pause", std::bind(&core::DownloadList::pause_default, control->core()->download_list(), std::placeholders::_1));
|
||||
CMD2_DL_V ("d.open", std::bind(&core::DownloadList::open_throw, control->core()->download_list(), std::placeholders::_1));
|
||||
CMD2_DL_V ("d.close", std::bind(&core::DownloadList::close_throw, control->core()->download_list(), std::placeholders::_1));
|
||||
CMD2_DL_V ("d.close.directly", std::bind(&core::DownloadList::close_directly, control->core()->download_list(), std::placeholders::_1));
|
||||
CMD2_DL_V ("d.erase", std::bind(&core::DownloadList::erase_ptr, control->core()->download_list(), std::placeholders::_1));
|
||||
CMD2_DL_V ("d.check_hash", std::bind(&core::DownloadList::check_hash, control->core()->download_list(), std::placeholders::_1));
|
||||
|
||||
CMD2_DL ("d.save_resume", tr1::bind(&core::DownloadStore::save_resume, control->core()->download_store(), tr1::placeholders::_1));
|
||||
CMD2_DL ("d.save_full_session", tr1::bind(&core::DownloadStore::save_full, control->core()->download_store(), tr1::placeholders::_1));
|
||||
CMD2_DL ("d.save_resume", std::bind(&core::DownloadStore::save_resume, control->core()->download_store(), std::placeholders::_1));
|
||||
CMD2_DL ("d.save_full_session", std::bind(&core::DownloadStore::save_full, control->core()->download_store(), std::placeholders::_1));
|
||||
|
||||
CMD2_DL_V ("d.update_priorities", CMD2_ON_DL(update_priorities));
|
||||
|
||||
CMD2_DL_STRING_V("add_peer", tr1::bind(&apply_d_add_peer, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL_STRING_V("add_peer", std::bind(&apply_d_add_peer, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
//
|
||||
// Custom settings:
|
||||
//
|
||||
|
||||
CMD2_DL_STRING("d.custom", tr1::bind(&retrieve_d_custom, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL_STRING("d.custom_throw", tr1::bind(&retrieve_d_custom_throw, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL_LIST ("d.custom.set", tr1::bind(&apply_d_custom, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL_STRING("d.custom", std::bind(&retrieve_d_custom, std::placeholders::_1, std::placeholders::_2));
|
||||
CMD2_DL_STRING("d.custom_throw", std::bind(&retrieve_d_custom_throw, std::placeholders::_1, std::placeholders::_2));
|
||||
CMD2_DL_LIST ("d.custom.set", std::bind(&apply_d_custom, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
CMD2_DL_VAR_STRING_PUBLIC("d.custom1", "rtorrent", "custom1");
|
||||
CMD2_DL_VAR_STRING_PUBLIC("d.custom2", "rtorrent", "custom2");
|
||||
@@ -750,68 +754,68 @@ initialize_command_download() {
|
||||
CMD2_DL_TIMESTAMP("d.timestamp.started", "rtorrent", "timestamp.started");
|
||||
CMD2_DL_TIMESTAMP("d.timestamp.finished", "rtorrent", "timestamp.finished");
|
||||
|
||||
CMD2_DL ("d.connection_current", tr1::bind(&torrent::option_as_string, torrent::OPTION_CONNECTION_TYPE, CMD2_ON_DL(connection_type)));
|
||||
CMD2_DL_STRING("d.connection_current.set", tr1::bind(&apply_d_connection_type, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL ("d.connection_current", std::bind(&torrent::option_as_string, torrent::OPTION_CONNECTION_TYPE, CMD2_ON_DL(connection_type)));
|
||||
CMD2_DL_STRING("d.connection_current.set", std::bind(&apply_d_connection_type, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
CMD2_DL_VAR_STRING("d.connection_leech", "rtorrent", "connection_leech");
|
||||
CMD2_DL_VAR_STRING("d.connection_seed", "rtorrent", "connection_seed");
|
||||
|
||||
CMD2_DL ("d.up.choke_heuristics", tr1::bind(&torrent::option_as_string, torrent::OPTION_CHOKE_HEURISTICS, CMD2_ON_DL(upload_choke_heuristic)));
|
||||
CMD2_DL_STRING("d.up.choke_heuristics.set", tr1::bind(&apply_d_choke_heuristics, tr1::placeholders::_1, tr1::placeholders::_2, false));
|
||||
CMD2_DL ("d.down.choke_heuristics", tr1::bind(&torrent::option_as_string, torrent::OPTION_CHOKE_HEURISTICS, CMD2_ON_DL(download_choke_heuristic)));
|
||||
CMD2_DL_STRING("d.down.choke_heuristics.set", tr1::bind(&apply_d_choke_heuristics, tr1::placeholders::_1, tr1::placeholders::_2, true));
|
||||
CMD2_DL ("d.up.choke_heuristics", std::bind(&torrent::option_as_string, torrent::OPTION_CHOKE_HEURISTICS, CMD2_ON_DL(upload_choke_heuristic)));
|
||||
CMD2_DL_STRING("d.up.choke_heuristics.set", std::bind(&apply_d_choke_heuristics, std::placeholders::_1, std::placeholders::_2, false));
|
||||
CMD2_DL ("d.down.choke_heuristics", std::bind(&torrent::option_as_string, torrent::OPTION_CHOKE_HEURISTICS, CMD2_ON_DL(download_choke_heuristic)));
|
||||
CMD2_DL_STRING("d.down.choke_heuristics.set", std::bind(&apply_d_choke_heuristics, std::placeholders::_1, std::placeholders::_2, true));
|
||||
|
||||
CMD2_DL_VAR_STRING("d.up.choke_heuristics.leech", "rtorrent", "choke_heuristics.up.leech");
|
||||
CMD2_DL_VAR_STRING("d.up.choke_heuristics.seed", "rtorrent", "choke_heuristics.up.seed");
|
||||
CMD2_DL_VAR_STRING("d.down.choke_heuristics.leech", "rtorrent", "choke_heuristics.down.leech");
|
||||
CMD2_DL_VAR_STRING("d.down.choke_heuristics.seed", "rtorrent", "choke_heuristics.down.seed");
|
||||
|
||||
CMD2_DL ("d.hashing_failed", tr1::bind(&core::Download::is_hash_failed, tr1::placeholders::_1));
|
||||
CMD2_DL_VALUE_V ("d.hashing_failed.set", tr1::bind(&core::Download::set_hash_failed, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL ("d.hashing_failed", std::bind(&core::Download::is_hash_failed, std::placeholders::_1));
|
||||
CMD2_DL_VALUE_V ("d.hashing_failed.set", std::bind(&core::Download::set_hash_failed, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
CMD2_DL ("d.views", tr1::bind(&download_get_variable, tr1::placeholders::_1, "rtorrent", "views"));
|
||||
CMD2_DL ("d.views.has", tr1::bind(&d_list_has, tr1::placeholders::_1, tr1::placeholders::_2, "rtorrent", "views"));
|
||||
CMD2_DL ("d.views.remove", tr1::bind(&d_list_remove, tr1::placeholders::_1, tr1::placeholders::_2, "rtorrent", "views"));
|
||||
CMD2_DL ("d.views.push_back", tr1::bind(&d_list_push_back, tr1::placeholders::_1, tr1::placeholders::_2, "rtorrent", "views"));
|
||||
CMD2_DL ("d.views.push_back_unique", tr1::bind(&d_list_push_back_unique, tr1::placeholders::_1, tr1::placeholders::_2, "rtorrent", "views"));
|
||||
CMD2_DL ("d.views", std::bind(&download_get_variable, std::placeholders::_1, "rtorrent", "views"));
|
||||
CMD2_DL ("d.views.has", std::bind(&d_list_has, std::placeholders::_1, std::placeholders::_2, "rtorrent", "views"));
|
||||
CMD2_DL ("d.views.remove", std::bind(&d_list_remove, std::placeholders::_1, std::placeholders::_2, "rtorrent", "views"));
|
||||
CMD2_DL ("d.views.push_back", std::bind(&d_list_push_back, std::placeholders::_1, std::placeholders::_2, "rtorrent", "views"));
|
||||
CMD2_DL ("d.views.push_back_unique", std::bind(&d_list_push_back_unique, std::placeholders::_1, std::placeholders::_2, "rtorrent", "views"));
|
||||
|
||||
// This command really needs to be improved, so we have proper
|
||||
// logging support.
|
||||
CMD2_DL ("d.message", tr1::bind(&core::Download::message, tr1::placeholders::_1));
|
||||
CMD2_DL_STRING_V("d.message.set", tr1::bind(&core::Download::set_message, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL ("d.message", std::bind(&core::Download::message, std::placeholders::_1));
|
||||
CMD2_DL_STRING_V("d.message.set", std::bind(&core::Download::set_message, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
CMD2_DL ("d.max_file_size", CMD2_ON_FL(max_file_size));
|
||||
CMD2_DL_VALUE_V ("d.max_file_size.set", tr1::bind(&torrent::FileList::set_max_file_size, CMD2_BIND_FL, tr1::placeholders::_2));
|
||||
CMD2_DL_VALUE_V ("d.max_file_size.set", std::bind(&torrent::FileList::set_max_file_size, CMD2_BIND_FL, std::placeholders::_2));
|
||||
|
||||
CMD2_DL ("d.peers_min", tr1::bind(&torrent::ConnectionList::min_size, CMD2_BIND_CL));
|
||||
CMD2_DL_VALUE_V ("d.peers_min.set", tr1::bind(&torrent::ConnectionList::set_min_size, CMD2_BIND_CL, tr1::placeholders::_2));
|
||||
CMD2_DL ("d.peers_max", tr1::bind(&torrent::ConnectionList::max_size, CMD2_BIND_CL));
|
||||
CMD2_DL_VALUE_V ("d.peers_max.set", tr1::bind(&torrent::ConnectionList::set_max_size, CMD2_BIND_CL, tr1::placeholders::_2));
|
||||
CMD2_DL ("d.uploads_max", tr1::bind(&torrent::Download::uploads_max, CMD2_BIND_DL));
|
||||
CMD2_DL_VALUE_V ("d.uploads_max.set", tr1::bind(&torrent::Download::set_uploads_max, CMD2_BIND_DL, tr1::placeholders::_2));
|
||||
CMD2_DL ("d.uploads_min", tr1::bind(&torrent::Download::uploads_min, CMD2_BIND_DL));
|
||||
CMD2_DL_VALUE_V ("d.uploads_min.set", tr1::bind(&torrent::Download::set_uploads_min, CMD2_BIND_DL, tr1::placeholders::_2));
|
||||
CMD2_DL ("d.downloads_max", tr1::bind(&torrent::Download::downloads_max, CMD2_BIND_DL));
|
||||
CMD2_DL_VALUE_V ("d.downloads_max.set", tr1::bind(&torrent::Download::set_downloads_max, CMD2_BIND_DL, tr1::placeholders::_2));
|
||||
CMD2_DL ("d.downloads_min", tr1::bind(&torrent::Download::downloads_min, CMD2_BIND_DL));
|
||||
CMD2_DL_VALUE_V ("d.downloads_min.set", tr1::bind(&torrent::Download::set_downloads_min, CMD2_BIND_DL, tr1::placeholders::_2));
|
||||
CMD2_DL ("d.peers_connected", tr1::bind(&torrent::ConnectionList::size, CMD2_BIND_CL));
|
||||
CMD2_DL ("d.peers_not_connected", tr1::bind(&torrent::PeerList::available_list_size, CMD2_BIND_PL));
|
||||
CMD2_DL ("d.peers_min", std::bind(&torrent::ConnectionList::min_size, CMD2_BIND_CL));
|
||||
CMD2_DL_VALUE_V ("d.peers_min.set", std::bind(&torrent::ConnectionList::set_min_size, CMD2_BIND_CL, std::placeholders::_2));
|
||||
CMD2_DL ("d.peers_max", std::bind(&torrent::ConnectionList::max_size, CMD2_BIND_CL));
|
||||
CMD2_DL_VALUE_V ("d.peers_max.set", std::bind(&torrent::ConnectionList::set_max_size, CMD2_BIND_CL, std::placeholders::_2));
|
||||
CMD2_DL ("d.uploads_max", std::bind(&torrent::Download::uploads_max, CMD2_BIND_DL));
|
||||
CMD2_DL_VALUE_V ("d.uploads_max.set", std::bind(&torrent::Download::set_uploads_max, CMD2_BIND_DL, std::placeholders::_2));
|
||||
CMD2_DL ("d.uploads_min", std::bind(&torrent::Download::uploads_min, CMD2_BIND_DL));
|
||||
CMD2_DL_VALUE_V ("d.uploads_min.set", std::bind(&torrent::Download::set_uploads_min, CMD2_BIND_DL, std::placeholders::_2));
|
||||
CMD2_DL ("d.downloads_max", std::bind(&torrent::Download::downloads_max, CMD2_BIND_DL));
|
||||
CMD2_DL_VALUE_V ("d.downloads_max.set", std::bind(&torrent::Download::set_downloads_max, CMD2_BIND_DL, std::placeholders::_2));
|
||||
CMD2_DL ("d.downloads_min", std::bind(&torrent::Download::downloads_min, CMD2_BIND_DL));
|
||||
CMD2_DL_VALUE_V ("d.downloads_min.set", std::bind(&torrent::Download::set_downloads_min, CMD2_BIND_DL, std::placeholders::_2));
|
||||
CMD2_DL ("d.peers_connected", std::bind(&torrent::ConnectionList::size, CMD2_BIND_CL));
|
||||
CMD2_DL ("d.peers_not_connected", std::bind(&torrent::PeerList::available_list_size, CMD2_BIND_PL));
|
||||
|
||||
CMD2_DL ("d.peers_complete", CMD2_ON_DL(peers_complete));
|
||||
CMD2_DL ("d.peers_accounted", CMD2_ON_DL(peers_accounted));
|
||||
|
||||
CMD2_DL_V ("d.disconnect.seeders", tr1::bind(&torrent::ConnectionList::erase_seeders, CMD2_BIND_CL));
|
||||
CMD2_DL_V ("d.disconnect.seeders", std::bind(&torrent::ConnectionList::erase_seeders, CMD2_BIND_CL));
|
||||
|
||||
CMD2_DL ("d.accepting_seeders", CMD2_ON_INFO(is_accepting_seeders));
|
||||
CMD2_DL_V ("d.accepting_seeders.enable", tr1::bind(&torrent::DownloadInfo::public_set_flags, CMD2_BIND_INFO, torrent::DownloadInfo::flag_accepting_seeders));
|
||||
CMD2_DL_V ("d.accepting_seeders.disable", tr1::bind(&torrent::DownloadInfo::public_unset_flags, CMD2_BIND_INFO, torrent::DownloadInfo::flag_accepting_seeders));
|
||||
CMD2_DL_V ("d.accepting_seeders.enable", std::bind(&torrent::DownloadInfo::public_set_flags, CMD2_BIND_INFO, torrent::DownloadInfo::flag_accepting_seeders));
|
||||
CMD2_DL_V ("d.accepting_seeders.disable", std::bind(&torrent::DownloadInfo::public_unset_flags, CMD2_BIND_INFO, torrent::DownloadInfo::flag_accepting_seeders));
|
||||
|
||||
CMD2_DL ("d.throttle_name", tr1::bind(&download_get_variable, tr1::placeholders::_1, "rtorrent", "throttle_name"));
|
||||
CMD2_DL_STRING_V("d.throttle_name.set", tr1::bind(&core::Download::set_throttle_name, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL ("d.throttle_name", std::bind(&download_get_variable, std::placeholders::_1, "rtorrent", "throttle_name"));
|
||||
CMD2_DL_STRING_V("d.throttle_name.set", std::bind(&core::Download::set_throttle_name, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
CMD2_DL ("d.bytes_done", CMD2_ON_DL(bytes_done));
|
||||
CMD2_DL ("d.ratio", tr1::bind(&retrieve_d_ratio, tr1::placeholders::_1));
|
||||
CMD2_DL ("d.ratio", std::bind(&retrieve_d_ratio, std::placeholders::_1));
|
||||
CMD2_DL ("d.chunks_hashed", CMD2_ON_DL(chunks_hashed));
|
||||
CMD2_DL ("d.free_diskspace", CMD2_ON_FL(free_diskspace));
|
||||
|
||||
@@ -822,7 +826,7 @@ initialize_command_download() {
|
||||
CMD2_DL ("d.size_pex", CMD2_ON_DL(size_pex));
|
||||
CMD2_DL ("d.max_size_pex", CMD2_ON_DL(max_size_pex));
|
||||
|
||||
CMD2_DL ("d.chunks_seen", tr1::bind(&d_chunks_seen, tr1::placeholders::_1));
|
||||
CMD2_DL ("d.chunks_seen", std::bind(&d_chunks_seen, std::placeholders::_1));
|
||||
|
||||
CMD2_DL ("d.completed_bytes", CMD2_ON_FL(completed_bytes));
|
||||
CMD2_DL ("d.completed_chunks", CMD2_ON_FL(completed_chunks));
|
||||
@@ -830,42 +834,42 @@ initialize_command_download() {
|
||||
|
||||
CMD2_DL ("d.wanted_chunks", CMD2_ON_DATA(wanted_chunks));
|
||||
|
||||
CMD2_DL_V ("d.tracker_announce", tr1::bind(&torrent::Download::manual_request, CMD2_BIND_DL, false));
|
||||
CMD2_DL ("d.tracker_numwant", tr1::bind(&torrent::TrackerList::numwant, CMD2_BIND_TL));
|
||||
CMD2_DL_VALUE_V ("d.tracker_numwant.set", tr1::bind(&torrent::TrackerList::set_numwant, CMD2_BIND_TL, tr1::placeholders::_2));
|
||||
CMD2_DL_V ("d.tracker_announce", std::bind(&torrent::Download::manual_request, CMD2_BIND_DL, false));
|
||||
CMD2_DL ("d.tracker_numwant", std::bind(&torrent::TrackerList::numwant, CMD2_BIND_TL));
|
||||
CMD2_DL_VALUE_V ("d.tracker_numwant.set", std::bind(&torrent::TrackerList::set_numwant, CMD2_BIND_TL, std::placeholders::_2));
|
||||
// TODO: Deprecate 'd.tracker_focus'.
|
||||
CMD2_DL ("d.tracker_focus", tr1::bind(&core::Download::tracker_list_size, tr1::placeholders::_1));
|
||||
CMD2_DL ("d.tracker_size", tr1::bind(&core::Download::tracker_list_size, tr1::placeholders::_1));
|
||||
CMD2_DL ("d.tracker_focus", std::bind(&core::Download::tracker_list_size, std::placeholders::_1));
|
||||
CMD2_DL ("d.tracker_size", std::bind(&core::Download::tracker_list_size, std::placeholders::_1));
|
||||
|
||||
CMD2_DL_LIST ("d.tracker.insert", tr1::bind(&download_tracker_insert, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL_VALUE_V ("d.tracker.send_scrape", tr1::bind(&torrent::TrackerController::scrape_request, CMD2_BIND_TC, tr1::placeholders::_2));
|
||||
CMD2_DL_LIST ("d.tracker.insert", std::bind(&download_tracker_insert, std::placeholders::_1, std::placeholders::_2));
|
||||
CMD2_DL_VALUE_V ("d.tracker.send_scrape", std::bind(&torrent::TrackerController::scrape_request, CMD2_BIND_TC, std::placeholders::_2));
|
||||
|
||||
CMD2_DL ("d.directory", CMD2_ON_FL(root_dir));
|
||||
CMD2_DL_STRING_V("d.directory.set", tr1::bind(&apply_d_directory, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL_STRING_V("d.directory.set", std::bind(&apply_d_directory, std::placeholders::_1, std::placeholders::_2));
|
||||
CMD2_DL ("d.directory_base", CMD2_ON_FL(root_dir));
|
||||
CMD2_DL_STRING_V("d.directory_base.set", tr1::bind(&core::Download::set_root_directory, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL_STRING_V("d.directory_base.set", std::bind(&core::Download::set_root_directory, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
CMD2_DL ("d.priority", tr1::bind(&core::Download::priority, tr1::placeholders::_1));
|
||||
CMD2_DL ("d.priority_str", tr1::bind(&retrieve_d_priority_str, tr1::placeholders::_1));
|
||||
CMD2_DL_VALUE_V ("d.priority.set", tr1::bind(&core::Download::set_priority, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL ("d.priority", std::bind(&core::Download::priority, std::placeholders::_1));
|
||||
CMD2_DL ("d.priority_str", std::bind(&retrieve_d_priority_str, std::placeholders::_1));
|
||||
CMD2_DL_VALUE_V ("d.priority.set", std::bind(&core::Download::set_priority, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
// CMD2_DL ("d.group", tr1::bind(&torrent::resource_manager_entry::group,
|
||||
// tr1::bind(&torrent::ResourceManager::entry_at, torrent::resource_manager(),
|
||||
// tr1::bind(&core::Download::main, tr1::placeholders::_1))));
|
||||
// CMD2_DL ("d.group", std::bind(&torrent::resource_manager_entry::group,
|
||||
// std::bind(&torrent::ResourceManager::entry_at, torrent::resource_manager(),
|
||||
// std::bind(&core::Download::main, std::placeholders::_1))));
|
||||
|
||||
// CMD2_DL_V ("d.group.set", tr1::bind(&torrent::ResourceManager::set_group,
|
||||
// CMD2_DL_V ("d.group.set", std::bind(&torrent::ResourceManager::set_group,
|
||||
// torrent::resource_manager(),
|
||||
// tr1::bind(&torrent::ResourceManager::find_throw, torrent::resource_manager(),
|
||||
// tr1::bind(&core::Download::main, tr1::placeholders::_1)),
|
||||
// std::bind(&torrent::ResourceManager::find_throw, torrent::resource_manager(),
|
||||
// std::bind(&core::Download::main, std::placeholders::_1)),
|
||||
// CG_GROUP_INDEX()));
|
||||
|
||||
CMD2_DL ("d.group", tr1::bind(&cg_d_group, tr1::placeholders::_1));
|
||||
CMD2_DL ("d.group.name", tr1::bind(&cg_d_group, tr1::placeholders::_1));
|
||||
CMD2_DL_V ("d.group.set", tr1::bind(&cg_d_group_set, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL ("d.group", std::bind(&cg_d_group, std::placeholders::_1));
|
||||
CMD2_DL ("d.group.name", std::bind(&cg_d_group, std::placeholders::_1));
|
||||
CMD2_DL_V ("d.group.set", std::bind(&cg_d_group_set, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
CMD2_DL_LIST ("f.multicall", tr1::bind(&f_multicall, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL_LIST ("p.multicall", tr1::bind(&p_multicall, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL_LIST ("t.multicall", tr1::bind(&t_multicall, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL_LIST ("f.multicall", std::bind(&f_multicall, std::placeholders::_1, std::placeholders::_2));
|
||||
CMD2_DL_LIST ("p.multicall", std::bind(&p_multicall, std::placeholders::_1, std::placeholders::_2));
|
||||
CMD2_DL_LIST ("t.multicall", std::bind(&t_multicall, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST ("p.call_target", tr1::bind(&p_call_target, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("p.call_target", std::bind(&p_call_target, std::placeholders::_2));
|
||||
}
|
||||
|
||||
+43
-28
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <torrent/utils/log.h>
|
||||
#include <torrent/utils/option_strings.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "control.h"
|
||||
@@ -158,15 +159,15 @@ system_method_insert_object(const torrent::Object::list_type& args, int flags) {
|
||||
|
||||
rpc::commands.insert_slot<rpc::command_base_is_type<rpc::command_base_call<rpc::target_type> >::type>
|
||||
(create_new_key(rawKey),
|
||||
tr1::bind(&rpc::object_storage::call_function_str, control->object_storage(),
|
||||
rawKey, tr1::placeholders::_1, tr1::placeholders::_2),
|
||||
std::bind(&rpc::object_storage::call_function_str, control->object_storage(),
|
||||
rawKey, std::placeholders::_1, std::placeholders::_2),
|
||||
&rpc::command_base_call<rpc::target_type>,
|
||||
cmd_flags, NULL, NULL);
|
||||
|
||||
} else {
|
||||
rpc::commands.insert_slot<rpc::command_base_is_type<rpc::command_base_call<rpc::target_type> >::type>
|
||||
(create_new_key(rawKey),
|
||||
tr1::bind(&rpc::object_storage::get_str, control->object_storage(), rawKey),
|
||||
std::bind(&rpc::object_storage::get_str, control->object_storage(), rawKey),
|
||||
&rpc::command_base_call<rpc::target_type>,
|
||||
cmd_flags, NULL, NULL);
|
||||
}
|
||||
@@ -175,7 +176,7 @@ system_method_insert_object(const torrent::Object::list_type& args, int flags) {
|
||||
// if (flags & rpc::object_storage::flag_rlookup) {
|
||||
// rpc::commands.insert_slot<rpc::command_base_is_type<rpc::command_base_call_string<rpc::target_type> >::type>
|
||||
// (create_new_key<9>(rawKey, ".rlookup"),
|
||||
// tr1::bind(&rpc::object_storage::rlookup_obj_list, control->object_storage(), rawKey),
|
||||
// std::bind(&rpc::object_storage::rlookup_obj_list, control->object_storage(), rawKey),
|
||||
// &rpc::command_base_call_string<rpc::target_type>,
|
||||
// cmd_flags, NULL, NULL);
|
||||
// }
|
||||
@@ -189,21 +190,21 @@ system_method_insert_object(const torrent::Object::list_type& args, int flags) {
|
||||
case rpc::object_storage::flag_bool_type:
|
||||
rpc::commands.insert_slot<rpc::command_base_is_type<rpc::command_base_call_value<rpc::target_type> >::type>
|
||||
(create_new_key<5>(rawKey, ".set"),
|
||||
tr1::bind(&rpc::object_storage::set_str_bool, control->object_storage(), rawKey, tr1::placeholders::_2),
|
||||
std::bind(&rpc::object_storage::set_str_bool, control->object_storage(), rawKey, std::placeholders::_2),
|
||||
&rpc::command_base_call_value<rpc::target_type>,
|
||||
cmd_flags, NULL, NULL);
|
||||
break;
|
||||
case rpc::object_storage::flag_value_type:
|
||||
rpc::commands.insert_slot<rpc::command_base_is_type<rpc::command_base_call_value<rpc::target_type> >::type>
|
||||
(create_new_key<5>(rawKey, ".set"),
|
||||
tr1::bind(&rpc::object_storage::set_str_value, control->object_storage(), rawKey, tr1::placeholders::_2),
|
||||
std::bind(&rpc::object_storage::set_str_value, control->object_storage(), rawKey, std::placeholders::_2),
|
||||
&rpc::command_base_call_value<rpc::target_type>,
|
||||
cmd_flags, NULL, NULL);
|
||||
break;
|
||||
case rpc::object_storage::flag_string_type:
|
||||
rpc::commands.insert_slot<rpc::command_base_is_type<rpc::command_base_call_string<rpc::target_type> >::type>
|
||||
(create_new_key<5>(rawKey, ".set"),
|
||||
tr1::bind(&rpc::object_storage::set_str_string, control->object_storage(), rawKey, tr1::placeholders::_2),
|
||||
std::bind(&rpc::object_storage::set_str_string, control->object_storage(), rawKey, std::placeholders::_2),
|
||||
&rpc::command_base_call_string<rpc::target_type>,
|
||||
cmd_flags, NULL, NULL);
|
||||
break;
|
||||
@@ -246,6 +247,10 @@ system_method_insert(const torrent::Object::list_type& args) {
|
||||
|
||||
const std::string& options = itrArgs->as_string();
|
||||
|
||||
// TODO: Replace find with a method that does '|' separated search
|
||||
// for all valid options, and then cross-checks that unmixable ones
|
||||
// aren't in there. Use a bitfield.
|
||||
|
||||
if (options.find("private") != std::string::npos)
|
||||
flags &= ~rpc::CommandMap::flag_public_xmlrpc;
|
||||
if (options.find("const") != std::string::npos)
|
||||
@@ -288,8 +293,7 @@ system_method_insert(const torrent::Object::list_type& args) {
|
||||
} else if (options.find("value") != std::string::npos ||
|
||||
options.find("bool") != std::string::npos ||
|
||||
options.find("string") != std::string::npos ||
|
||||
options.find("list") != std::string::npos ||
|
||||
options.find("simple") != std::string::npos) {
|
||||
options.find("list") != std::string::npos) {
|
||||
torrent::Object::list_type new_args;
|
||||
new_args.push_back(rawKey);
|
||||
|
||||
@@ -434,38 +438,49 @@ cmd_catch(rpc::target_type target, const torrent::Object& args) {
|
||||
}
|
||||
|
||||
#define CMD2_METHOD_INSERT(key, flags) \
|
||||
CMD2_ANY_LIST(key, tr1::bind(&system_method_insert_object, tr1::placeholders::_2, flags));
|
||||
CMD2_ANY_LIST(key, std::bind(&system_method_insert_object, std::placeholders::_2, flags));
|
||||
|
||||
void
|
||||
initialize_command_dynamic() {
|
||||
CMD2_VAR_BOOL ("method.use_deprecated", true);
|
||||
CMD2_VAR_BOOL ("method.use_deprecated", false);
|
||||
CMD2_VAR_VALUE ("method.use_intermediate", 1);
|
||||
|
||||
CMD2_ANY_LIST ("method.insert", tr1::bind(&system_method_insert, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("method.insert.value", tr1::bind(&system_method_insert_object, tr1::placeholders::_2, rpc::object_storage::flag_value_type));
|
||||
CMD2_ANY_LIST ("method.insert", std::bind(&system_method_insert, std::placeholders::_2));
|
||||
CMD2_ANY_LIST ("method.insert.value", std::bind(&system_method_insert_object, std::placeholders::_2, rpc::object_storage::flag_value_type));
|
||||
|
||||
CMD2_METHOD_INSERT("method.insert.simple", rpc::object_storage::flag_function_type);
|
||||
CMD2_METHOD_INSERT("method.insert.c_simple", rpc::object_storage::flag_constant | rpc::object_storage::flag_function_type);
|
||||
CMD2_METHOD_INSERT("method.insert.s_c_simple", rpc::object_storage::flag_static |
|
||||
rpc::object_storage::flag_constant |rpc::object_storage::flag_function_type);
|
||||
|
||||
CMD2_ANY_STRING ("method.erase", tr1::bind(&system_method_erase, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("method.redirect", tr1::bind(&system_method_redirect, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("method.get", tr1::bind(&rpc::object_storage::get_str, control->object_storage(),
|
||||
tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("method.set", tr1::bind(&system_method_set_function, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("method.erase", std::bind(&system_method_erase, std::placeholders::_2));
|
||||
CMD2_ANY_LIST ("method.redirect", std::bind(&system_method_redirect, std::placeholders::_2));
|
||||
CMD2_ANY_STRING ("method.get", std::bind(&rpc::object_storage::get_str, control->object_storage(),
|
||||
std::placeholders::_2));
|
||||
CMD2_ANY_LIST ("method.set", std::bind(&system_method_set_function, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_STRING ("method.const", tr1::bind(&rpc::object_storage::has_flag_str, control->object_storage(),
|
||||
tr1::placeholders::_2, rpc::object_storage::flag_constant));
|
||||
CMD2_ANY_STRING_V("method.const.enable", tr1::bind(&rpc::object_storage::enable_flag_str, control->object_storage(),
|
||||
tr1::placeholders::_2, rpc::object_storage::flag_constant));
|
||||
CMD2_ANY_STRING ("method.const", std::bind(&rpc::object_storage::has_flag_str, control->object_storage(),
|
||||
std::placeholders::_2, rpc::object_storage::flag_constant));
|
||||
CMD2_ANY_STRING_V("method.const.enable", std::bind(&rpc::object_storage::enable_flag_str, control->object_storage(),
|
||||
std::placeholders::_2, rpc::object_storage::flag_constant));
|
||||
|
||||
CMD2_ANY_LIST ("method.has_key", tr1::bind(&system_method_has_key, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("method.set_key", tr1::bind(&system_method_set_key, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("method.list_keys", tr1::bind(&system_method_list_keys, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("method.has_key", std::bind(&system_method_has_key, std::placeholders::_2));
|
||||
CMD2_ANY_LIST ("method.set_key", std::bind(&system_method_set_key, std::placeholders::_2));
|
||||
CMD2_ANY_STRING ("method.list_keys", std::bind(&system_method_list_keys, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_STRING ("method.rlookup", tr1::bind(&rpc::object_storage::rlookup_obj_list, control->object_storage(), tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING_V("method.rlookup.clear", tr1::bind(&rpc::object_storage::rlookup_clear, control->object_storage(), tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("method.rlookup", std::bind(&rpc::object_storage::rlookup_obj_list, control->object_storage(), std::placeholders::_2));
|
||||
CMD2_ANY_STRING_V("method.rlookup.clear", std::bind(&rpc::object_storage::rlookup_clear, control->object_storage(), std::placeholders::_2));
|
||||
|
||||
CMD2_ANY ("catch", tr1::bind(&cmd_catch, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_ANY ("catch", std::bind(&cmd_catch, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY ("strings.choke_heuristics", std::bind(&torrent::option_list_strings, torrent::OPTION_CHOKE_HEURISTICS));
|
||||
CMD2_ANY ("strings.choke_heuristics.upload", std::bind(&torrent::option_list_strings, torrent::OPTION_CHOKE_HEURISTICS_UPLOAD));
|
||||
CMD2_ANY ("strings.choke_heuristics.download", std::bind(&torrent::option_list_strings, torrent::OPTION_CHOKE_HEURISTICS_DOWNLOAD));
|
||||
CMD2_ANY ("strings.connection_type", std::bind(&torrent::option_list_strings, torrent::OPTION_CONNECTION_TYPE));
|
||||
CMD2_ANY ("strings.encryption", std::bind(&torrent::option_list_strings, torrent::OPTION_ENCRYPTION));
|
||||
CMD2_ANY ("strings.ip_filter", std::bind(&torrent::option_list_strings, torrent::OPTION_IP_FILTER));
|
||||
CMD2_ANY ("strings.ip_tos", std::bind(&torrent::option_list_strings, torrent::OPTION_IP_TOS));
|
||||
CMD2_ANY ("strings.log_group", std::bind(&torrent::option_list_strings, torrent::OPTION_LOG_GROUP));
|
||||
CMD2_ANY ("strings.tracker_event", std::bind(&torrent::option_list_strings, torrent::OPTION_TRACKER_EVENT));
|
||||
CMD2_ANY ("strings.tracker_mode", std::bind(&torrent::option_list_strings, torrent::OPTION_TRACKER_MODE));
|
||||
}
|
||||
|
||||
+46
-19
@@ -38,12 +38,14 @@
|
||||
|
||||
#include <functional>
|
||||
#include <cstdio>
|
||||
#include <rak/error_number.h>
|
||||
#include <rak/file_stat.h>
|
||||
#include <rak/path.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/hash_string.h>
|
||||
#include <torrent/utils/log.h>
|
||||
#include <torrent/utils/directory_events.h>
|
||||
|
||||
#include "core/download.h"
|
||||
#include "core/download_list.h"
|
||||
@@ -305,33 +307,58 @@ d_multicall(const torrent::Object::list_type& args) {
|
||||
return resultRaw;
|
||||
}
|
||||
|
||||
static void
|
||||
call_watch_command(const std::string& command, const std::string& path) {
|
||||
rpc::commands.call_catch(command.c_str(), rpc::make_target(), path);
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
directory_watch_added(const torrent::Object::list_type& args) {
|
||||
if (args.size() != 2)
|
||||
throw torrent::input_error("Too few arguments.");
|
||||
|
||||
const std::string& path = args.front().as_string();
|
||||
const std::string& command = args.back().as_string();
|
||||
|
||||
if (!control->directory_events()->open())
|
||||
throw torrent::input_error("Could not open inotify:" + std::string(rak::error_number::current().c_str()));
|
||||
|
||||
control->directory_events()->notify_on(path.c_str(),
|
||||
torrent::directory_events::flag_on_added | torrent::directory_events::flag_on_updated,
|
||||
std::bind(&call_watch_command, command, std::placeholders::_1));
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
void
|
||||
initialize_command_events() {
|
||||
CMD2_ANY_STRING ("on_ratio", tr1::bind(&apply_on_ratio, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("on_ratio", std::bind(&apply_on_ratio, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY ("start_tied", tr1::bind(&apply_start_tied));
|
||||
CMD2_ANY ("stop_untied", tr1::bind(&apply_stop_untied));
|
||||
CMD2_ANY ("close_untied", tr1::bind(&apply_close_untied));
|
||||
CMD2_ANY ("remove_untied", tr1::bind(&apply_remove_untied));
|
||||
CMD2_ANY ("start_tied", std::bind(&apply_start_tied));
|
||||
CMD2_ANY ("stop_untied", std::bind(&apply_stop_untied));
|
||||
CMD2_ANY ("close_untied", std::bind(&apply_close_untied));
|
||||
CMD2_ANY ("remove_untied", std::bind(&apply_remove_untied));
|
||||
|
||||
CMD2_ANY_LIST ("schedule2", tr1::bind(&apply_schedule, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING_V("schedule_remove2", tr1::bind(&rpc::CommandScheduler::erase_str, control->command_scheduler(), tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("schedule2", std::bind(&apply_schedule, std::placeholders::_2));
|
||||
CMD2_ANY_STRING_V("schedule_remove2", std::bind(&rpc::CommandScheduler::erase_str, control->command_scheduler(), std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_STRING_V("import", tr1::bind(&apply_import, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING_V("try_import", tr1::bind(&apply_try_import, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING_V("import", std::bind(&apply_import, std::placeholders::_2));
|
||||
CMD2_ANY_STRING_V("try_import", std::bind(&apply_try_import, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST ("load.normal", tr1::bind(&apply_load, tr1::placeholders::_2, core::Manager::create_quiet | core::Manager::create_tied));
|
||||
CMD2_ANY_LIST ("load.verbose", tr1::bind(&apply_load, tr1::placeholders::_2, core::Manager::create_tied));
|
||||
CMD2_ANY_LIST ("load.start", tr1::bind(&apply_load, tr1::placeholders::_2,
|
||||
CMD2_ANY_LIST ("load.normal", std::bind(&apply_load, std::placeholders::_2, core::Manager::create_quiet | core::Manager::create_tied));
|
||||
CMD2_ANY_LIST ("load.verbose", std::bind(&apply_load, std::placeholders::_2, core::Manager::create_tied));
|
||||
CMD2_ANY_LIST ("load.start", std::bind(&apply_load, std::placeholders::_2,
|
||||
core::Manager::create_quiet | core::Manager::create_tied | core::Manager::create_start));
|
||||
CMD2_ANY_LIST ("load.start_verbose", tr1::bind(&apply_load, tr1::placeholders::_2, core::Manager::create_tied | core::Manager::create_start));
|
||||
CMD2_ANY_LIST ("load.raw", tr1::bind(&apply_load, tr1::placeholders::_2, core::Manager::create_quiet | core::Manager::create_raw_data));
|
||||
CMD2_ANY_LIST ("load.raw_verbose", tr1::bind(&apply_load, tr1::placeholders::_2, core::Manager::create_raw_data));
|
||||
CMD2_ANY_LIST ("load.raw_start", tr1::bind(&apply_load, tr1::placeholders::_2,
|
||||
CMD2_ANY_LIST ("load.start_verbose", std::bind(&apply_load, std::placeholders::_2, core::Manager::create_tied | core::Manager::create_start));
|
||||
CMD2_ANY_LIST ("load.raw", std::bind(&apply_load, std::placeholders::_2, core::Manager::create_quiet | core::Manager::create_raw_data));
|
||||
CMD2_ANY_LIST ("load.raw_verbose", std::bind(&apply_load, std::placeholders::_2, core::Manager::create_raw_data));
|
||||
CMD2_ANY_LIST ("load.raw_start", std::bind(&apply_load, std::placeholders::_2,
|
||||
core::Manager::create_quiet | core::Manager::create_start | core::Manager::create_raw_data));
|
||||
CMD2_ANY_LIST ("load.raw_start_verbose", std::bind(&apply_load, std::placeholders::_2, core::Manager::create_start | core::Manager::create_raw_data));
|
||||
|
||||
CMD2_ANY_VALUE ("close_low_diskspace", tr1::bind(&apply_close_low_diskspace, tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE ("close_low_diskspace", std::bind(&apply_close_low_diskspace, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST ("download_list", tr1::bind(&apply_download_list, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("d.multicall2", tr1::bind(&d_multicall, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("download_list", std::bind(&apply_download_list, std::placeholders::_2));
|
||||
CMD2_ANY_LIST ("d.multicall2", std::bind(&d_multicall, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST ("directory.watch.added", std::bind(&directory_watch_added, std::placeholders::_2));
|
||||
}
|
||||
|
||||
+31
-31
@@ -100,45 +100,45 @@ apply_fi_filename_last(torrent::FileListIterator* itr) {
|
||||
|
||||
void
|
||||
initialize_command_file() {
|
||||
CMD2_FILE("f.is_created", tr1::bind(&torrent::File::is_created, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.is_open", tr1::bind(&torrent::File::is_open, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.is_created", std::bind(&torrent::File::is_created, std::placeholders::_1));
|
||||
CMD2_FILE("f.is_open", std::bind(&torrent::File::is_open, std::placeholders::_1));
|
||||
|
||||
CMD2_FILE("f.is_create_queued", tr1::bind(&torrent::File::is_create_queued, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.is_resize_queued", tr1::bind(&torrent::File::is_resize_queued, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.is_create_queued", std::bind(&torrent::File::is_create_queued, std::placeholders::_1));
|
||||
CMD2_FILE("f.is_resize_queued", std::bind(&torrent::File::is_resize_queued, std::placeholders::_1));
|
||||
|
||||
CMD2_FILE_VALUE_V("f.set_create_queued", tr1::bind(&torrent::File::set_flags, tr1::placeholders::_1, torrent::File::flag_create_queued));
|
||||
CMD2_FILE_VALUE_V("f.set_resize_queued", tr1::bind(&torrent::File::set_flags, tr1::placeholders::_1, torrent::File::flag_resize_queued));
|
||||
CMD2_FILE_VALUE_V("f.unset_create_queued", tr1::bind(&torrent::File::unset_flags, tr1::placeholders::_1, torrent::File::flag_create_queued));
|
||||
CMD2_FILE_VALUE_V("f.unset_resize_queued", tr1::bind(&torrent::File::unset_flags, tr1::placeholders::_1, torrent::File::flag_resize_queued));
|
||||
CMD2_FILE_VALUE_V("f.set_create_queued", std::bind(&torrent::File::set_flags, std::placeholders::_1, torrent::File::flag_create_queued));
|
||||
CMD2_FILE_VALUE_V("f.set_resize_queued", std::bind(&torrent::File::set_flags, std::placeholders::_1, torrent::File::flag_resize_queued));
|
||||
CMD2_FILE_VALUE_V("f.unset_create_queued", std::bind(&torrent::File::unset_flags, std::placeholders::_1, torrent::File::flag_create_queued));
|
||||
CMD2_FILE_VALUE_V("f.unset_resize_queued", std::bind(&torrent::File::unset_flags, std::placeholders::_1, torrent::File::flag_resize_queued));
|
||||
|
||||
CMD2_FILE ("f.prioritize_first", tr1::bind(&torrent::File::has_flags, tr1::placeholders::_1, torrent::File::flag_prioritize_first));
|
||||
CMD2_FILE_V("f.prioritize_first.enable", tr1::bind(&torrent::File::set_flags, tr1::placeholders::_1, torrent::File::flag_prioritize_first));
|
||||
CMD2_FILE_V("f.prioritize_first.disable", tr1::bind(&torrent::File::unset_flags, tr1::placeholders::_1, torrent::File::flag_prioritize_first));
|
||||
CMD2_FILE ("f.prioritize_last", tr1::bind(&torrent::File::has_flags, tr1::placeholders::_1, torrent::File::flag_prioritize_last));
|
||||
CMD2_FILE_V("f.prioritize_last.enable", tr1::bind(&torrent::File::set_flags, tr1::placeholders::_1, torrent::File::flag_prioritize_last));
|
||||
CMD2_FILE_V("f.prioritize_last.disable", tr1::bind(&torrent::File::unset_flags, tr1::placeholders::_1, torrent::File::flag_prioritize_last));
|
||||
CMD2_FILE ("f.prioritize_first", std::bind(&torrent::File::has_flags, std::placeholders::_1, torrent::File::flag_prioritize_first));
|
||||
CMD2_FILE_V("f.prioritize_first.enable", std::bind(&torrent::File::set_flags, std::placeholders::_1, torrent::File::flag_prioritize_first));
|
||||
CMD2_FILE_V("f.prioritize_first.disable", std::bind(&torrent::File::unset_flags, std::placeholders::_1, torrent::File::flag_prioritize_first));
|
||||
CMD2_FILE ("f.prioritize_last", std::bind(&torrent::File::has_flags, std::placeholders::_1, torrent::File::flag_prioritize_last));
|
||||
CMD2_FILE_V("f.prioritize_last.enable", std::bind(&torrent::File::set_flags, std::placeholders::_1, torrent::File::flag_prioritize_last));
|
||||
CMD2_FILE_V("f.prioritize_last.disable", std::bind(&torrent::File::unset_flags, std::placeholders::_1, torrent::File::flag_prioritize_last));
|
||||
|
||||
CMD2_FILE("f.size_bytes", tr1::bind(&torrent::File::size_bytes, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.size_chunks", tr1::bind(&torrent::File::size_chunks, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.completed_chunks", tr1::bind(&torrent::File::completed_chunks, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.size_bytes", std::bind(&torrent::File::size_bytes, std::placeholders::_1));
|
||||
CMD2_FILE("f.size_chunks", std::bind(&torrent::File::size_chunks, std::placeholders::_1));
|
||||
CMD2_FILE("f.completed_chunks", std::bind(&torrent::File::completed_chunks, std::placeholders::_1));
|
||||
|
||||
CMD2_FILE("f.offset", tr1::bind(&torrent::File::offset, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.range_first", tr1::bind(&torrent::File::range_first, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.range_second", tr1::bind(&torrent::File::range_second, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.offset", std::bind(&torrent::File::offset, std::placeholders::_1));
|
||||
CMD2_FILE("f.range_first", std::bind(&torrent::File::range_first, std::placeholders::_1));
|
||||
CMD2_FILE("f.range_second", std::bind(&torrent::File::range_second, std::placeholders::_1));
|
||||
|
||||
CMD2_FILE("f.priority", tr1::bind(&torrent::File::priority, tr1::placeholders::_1));
|
||||
CMD2_FILE_VALUE_V("f.priority.set", tr1::bind(&apply_f_set_priority, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_FILE("f.priority", std::bind(&torrent::File::priority, std::placeholders::_1));
|
||||
CMD2_FILE_VALUE_V("f.priority.set", std::bind(&apply_f_set_priority, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
CMD2_FILE("f.path", tr1::bind(&apply_f_path, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.path_components", tr1::bind(&apply_f_path_components, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.path_depth", tr1::bind(&apply_f_path_depth, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.frozen_path", tr1::bind(&torrent::File::frozen_path, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.path", std::bind(&apply_f_path, std::placeholders::_1));
|
||||
CMD2_FILE("f.path_components", std::bind(&apply_f_path_components, std::placeholders::_1));
|
||||
CMD2_FILE("f.path_depth", std::bind(&apply_f_path_depth, std::placeholders::_1));
|
||||
CMD2_FILE("f.frozen_path", std::bind(&torrent::File::frozen_path, std::placeholders::_1));
|
||||
|
||||
CMD2_FILE("f.match_depth_prev", tr1::bind(&torrent::File::match_depth_prev, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.match_depth_next", tr1::bind(&torrent::File::match_depth_next, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.match_depth_prev", std::bind(&torrent::File::match_depth_prev, std::placeholders::_1));
|
||||
CMD2_FILE("f.match_depth_next", std::bind(&torrent::File::match_depth_next, std::placeholders::_1));
|
||||
|
||||
CMD2_FILE("f.last_touched", tr1::bind(&torrent::File::last_touched, tr1::placeholders::_1));
|
||||
CMD2_FILE("f.last_touched", std::bind(&torrent::File::last_touched, std::placeholders::_1));
|
||||
|
||||
CMD2_FILEITR("fi.filename_last", tr1::bind(&apply_fi_filename_last, tr1::placeholders::_1));
|
||||
CMD2_FILEITR("fi.is_file", tr1::bind(&torrent::FileListIterator::is_file, tr1::placeholders::_1));
|
||||
CMD2_FILEITR("fi.filename_last", std::bind(&apply_fi_filename_last, std::placeholders::_1));
|
||||
CMD2_FILEITR("fi.is_file", std::bind(&torrent::FileListIterator::is_file, std::placeholders::_1));
|
||||
}
|
||||
|
||||
+33
-39
@@ -264,8 +264,8 @@ apply_cg_tracker_mode_set(const torrent::Object::list_type& args) {
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
#define CG_GROUP_AT() tr1::bind(&cg_get_group, tr1::placeholders::_2)
|
||||
#define CHOKE_GROUP(direction) tr1::bind(direction, CG_GROUP_AT())
|
||||
#define CG_GROUP_AT() std::bind(&cg_get_group, std::placeholders::_2)
|
||||
#define CHOKE_GROUP(direction) std::bind(direction, CG_GROUP_AT())
|
||||
|
||||
/*
|
||||
|
||||
@@ -335,55 +335,49 @@ options.
|
||||
|
||||
void
|
||||
initialize_command_groups() {
|
||||
// Move somewhere else?
|
||||
CMD2_ANY ("strings.choke_heuristics", tr1::bind(&torrent::option_list_strings, torrent::OPTION_CHOKE_HEURISTICS));
|
||||
CMD2_ANY ("strings.choke_heuristics.upload", tr1::bind(&torrent::option_list_strings, torrent::OPTION_CHOKE_HEURISTICS_UPLOAD));
|
||||
CMD2_ANY ("strings.choke_heuristics.download", tr1::bind(&torrent::option_list_strings, torrent::OPTION_CHOKE_HEURISTICS_DOWNLOAD));
|
||||
CMD2_ANY ("strings.tracker_mode", tr1::bind(&torrent::option_list_strings, torrent::OPTION_TRACKER_MODE));
|
||||
|
||||
CMD2_ANY ("choke_group.list", tr1::bind(&apply_cg_list));
|
||||
CMD2_ANY_STRING ("choke_group.insert", tr1::bind(&apply_cg_insert, tr1::placeholders::_2));
|
||||
|
||||
CMD2_ANY ("choke_group.list", std::bind(&apply_cg_list));
|
||||
CMD2_ANY_STRING ("choke_group.insert", std::bind(&apply_cg_insert, std::placeholders::_2));
|
||||
|
||||
#if USE_CHOKE_GROUP
|
||||
CMD2_ANY ("choke_group.size", tr1::bind(&torrent::ResourceManager::group_size, torrent::resource_manager()));
|
||||
CMD2_ANY_STRING ("choke_group.index_of", tr1::bind(&torrent::ResourceManager::group_index_of, torrent::resource_manager(), tr1::placeholders::_2));
|
||||
CMD2_ANY ("choke_group.size", std::bind(&torrent::ResourceManager::group_size, torrent::resource_manager()));
|
||||
CMD2_ANY_STRING ("choke_group.index_of", std::bind(&torrent::ResourceManager::group_index_of, torrent::resource_manager(), std::placeholders::_2));
|
||||
#else
|
||||
apply_cg_insert("default");
|
||||
|
||||
CMD2_ANY ("choke_group.size", tr1::bind(&std::vector<torrent::choke_group*>::size, cg_list_hack));
|
||||
CMD2_ANY_STRING ("choke_group.index_of", tr1::bind(&apply_cg_index_of, tr1::placeholders::_2));
|
||||
CMD2_ANY ("choke_group.size", std::bind(&std::vector<torrent::choke_group*>::size, cg_list_hack));
|
||||
CMD2_ANY_STRING ("choke_group.index_of", std::bind(&apply_cg_index_of, std::placeholders::_2));
|
||||
#endif
|
||||
|
||||
// Commands specific for a group. Supports as the first argument the
|
||||
// name, the index or a negative index.
|
||||
CMD2_ANY ("choke_group.general.size", tr1::bind(&torrent::choke_group::size, CG_GROUP_AT()));
|
||||
CMD2_ANY ("choke_group.general.size", std::bind(&torrent::choke_group::size, CG_GROUP_AT()));
|
||||
|
||||
CMD2_ANY ("choke_group.tracker.mode", tr1::bind(&torrent::option_as_string, torrent::OPTION_TRACKER_MODE,
|
||||
tr1::bind(&torrent::choke_group::tracker_mode, CG_GROUP_AT())));
|
||||
CMD2_ANY_LIST ("choke_group.tracker.mode.set", tr1::bind(&apply_cg_tracker_mode_set, tr1::placeholders::_2));
|
||||
CMD2_ANY ("choke_group.tracker.mode", std::bind(&torrent::option_as_string, torrent::OPTION_TRACKER_MODE,
|
||||
std::bind(&torrent::choke_group::tracker_mode, CG_GROUP_AT())));
|
||||
CMD2_ANY_LIST ("choke_group.tracker.mode.set", std::bind(&apply_cg_tracker_mode_set, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY ("choke_group.up.rate", tr1::bind(&torrent::choke_group::up_rate, CG_GROUP_AT()));
|
||||
CMD2_ANY ("choke_group.down.rate", tr1::bind(&torrent::choke_group::down_rate, CG_GROUP_AT()));
|
||||
CMD2_ANY ("choke_group.up.rate", std::bind(&torrent::choke_group::up_rate, CG_GROUP_AT()));
|
||||
CMD2_ANY ("choke_group.down.rate", std::bind(&torrent::choke_group::down_rate, CG_GROUP_AT()));
|
||||
|
||||
CMD2_ANY ("choke_group.up.max.unlimited", tr1::bind(&torrent::choke_queue::is_unlimited, CHOKE_GROUP(&torrent::choke_group::up_queue)));
|
||||
CMD2_ANY ("choke_group.up.max", tr1::bind(&torrent::choke_queue::max_unchoked_signed, CHOKE_GROUP(&torrent::choke_group::up_queue)));
|
||||
CMD2_ANY_LIST ("choke_group.up.max.set", tr1::bind(&apply_cg_max_set, tr1::placeholders::_2, true));
|
||||
CMD2_ANY ("choke_group.up.max.unlimited", std::bind(&torrent::choke_queue::is_unlimited, CHOKE_GROUP(&torrent::choke_group::up_queue)));
|
||||
CMD2_ANY ("choke_group.up.max", std::bind(&torrent::choke_queue::max_unchoked_signed, CHOKE_GROUP(&torrent::choke_group::up_queue)));
|
||||
CMD2_ANY_LIST ("choke_group.up.max.set", std::bind(&apply_cg_max_set, std::placeholders::_2, true));
|
||||
|
||||
CMD2_ANY ("choke_group.up.total", tr1::bind(&torrent::choke_queue::size_total, CHOKE_GROUP(&torrent::choke_group::up_queue)));
|
||||
CMD2_ANY ("choke_group.up.queued", tr1::bind(&torrent::choke_queue::size_queued, CHOKE_GROUP(&torrent::choke_group::up_queue)));
|
||||
CMD2_ANY ("choke_group.up.unchoked", tr1::bind(&torrent::choke_queue::size_unchoked, CHOKE_GROUP(&torrent::choke_group::up_queue)));
|
||||
CMD2_ANY ("choke_group.up.heuristics", tr1::bind(&torrent::option_as_string, torrent::OPTION_CHOKE_HEURISTICS,
|
||||
tr1::bind(&torrent::choke_queue::heuristics, CHOKE_GROUP(&torrent::choke_group::up_queue))));
|
||||
CMD2_ANY_LIST ("choke_group.up.heuristics.set", tr1::bind(&apply_cg_heuristics_set, tr1::placeholders::_2, true));
|
||||
CMD2_ANY ("choke_group.up.total", std::bind(&torrent::choke_queue::size_total, CHOKE_GROUP(&torrent::choke_group::up_queue)));
|
||||
CMD2_ANY ("choke_group.up.queued", std::bind(&torrent::choke_queue::size_queued, CHOKE_GROUP(&torrent::choke_group::up_queue)));
|
||||
CMD2_ANY ("choke_group.up.unchoked", std::bind(&torrent::choke_queue::size_unchoked, CHOKE_GROUP(&torrent::choke_group::up_queue)));
|
||||
CMD2_ANY ("choke_group.up.heuristics", std::bind(&torrent::option_as_string, torrent::OPTION_CHOKE_HEURISTICS,
|
||||
std::bind(&torrent::choke_queue::heuristics, CHOKE_GROUP(&torrent::choke_group::up_queue))));
|
||||
CMD2_ANY_LIST ("choke_group.up.heuristics.set", std::bind(&apply_cg_heuristics_set, std::placeholders::_2, true));
|
||||
|
||||
CMD2_ANY ("choke_group.down.max.unlimited", tr1::bind(&torrent::choke_queue::is_unlimited, CHOKE_GROUP(&torrent::choke_group::down_queue)));
|
||||
CMD2_ANY ("choke_group.down.max", tr1::bind(&torrent::choke_queue::max_unchoked_signed, CHOKE_GROUP(&torrent::choke_group::down_queue)));
|
||||
CMD2_ANY_LIST ("choke_group.down.max.set", tr1::bind(&apply_cg_max_set, tr1::placeholders::_2, false));
|
||||
CMD2_ANY ("choke_group.down.max.unlimited", std::bind(&torrent::choke_queue::is_unlimited, CHOKE_GROUP(&torrent::choke_group::down_queue)));
|
||||
CMD2_ANY ("choke_group.down.max", std::bind(&torrent::choke_queue::max_unchoked_signed, CHOKE_GROUP(&torrent::choke_group::down_queue)));
|
||||
CMD2_ANY_LIST ("choke_group.down.max.set", std::bind(&apply_cg_max_set, std::placeholders::_2, false));
|
||||
|
||||
CMD2_ANY ("choke_group.down.total", tr1::bind(&torrent::choke_queue::size_total, CHOKE_GROUP(&torrent::choke_group::down_queue)));
|
||||
CMD2_ANY ("choke_group.down.queued", tr1::bind(&torrent::choke_queue::size_queued, CHOKE_GROUP(&torrent::choke_group::down_queue)));
|
||||
CMD2_ANY ("choke_group.down.unchoked", tr1::bind(&torrent::choke_queue::size_unchoked, CHOKE_GROUP(&torrent::choke_group::down_queue)));
|
||||
CMD2_ANY ("choke_group.down.heuristics", tr1::bind(&torrent::option_as_string, torrent::OPTION_CHOKE_HEURISTICS,
|
||||
tr1::bind(&torrent::choke_queue::heuristics, CHOKE_GROUP(&torrent::choke_group::down_queue))));
|
||||
CMD2_ANY_LIST ("choke_group.down.heuristics.set", tr1::bind(&apply_cg_heuristics_set, tr1::placeholders::_2, false));
|
||||
CMD2_ANY ("choke_group.down.total", std::bind(&torrent::choke_queue::size_total, CHOKE_GROUP(&torrent::choke_group::down_queue)));
|
||||
CMD2_ANY ("choke_group.down.queued", std::bind(&torrent::choke_queue::size_queued, CHOKE_GROUP(&torrent::choke_group::down_queue)));
|
||||
CMD2_ANY ("choke_group.down.unchoked", std::bind(&torrent::choke_queue::size_unchoked, CHOKE_GROUP(&torrent::choke_group::down_queue)));
|
||||
CMD2_ANY ("choke_group.down.heuristics", std::bind(&torrent::option_as_string, torrent::OPTION_CHOKE_HEURISTICS,
|
||||
std::bind(&torrent::choke_queue::heuristics, CHOKE_GROUP(&torrent::choke_group::down_queue))));
|
||||
CMD2_ANY_LIST ("choke_group.down.heuristics.set", std::bind(&apply_cg_heuristics_set, std::placeholders::_2, false));
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ void initialize_command_file();
|
||||
void initialize_command_ip();
|
||||
void initialize_command_peer();
|
||||
void initialize_command_local();
|
||||
void initialize_command_logging();
|
||||
void initialize_command_network();
|
||||
void initialize_command_groups();
|
||||
void initialize_command_throttle();
|
||||
@@ -63,6 +64,7 @@ initialize_commands() {
|
||||
initialize_command_network();
|
||||
initialize_command_groups();
|
||||
initialize_command_local();
|
||||
initialize_command_logging();
|
||||
initialize_command_ui();
|
||||
initialize_command_download();
|
||||
initialize_command_file();
|
||||
|
||||
+17
-19
@@ -41,8 +41,6 @@
|
||||
#include "rpc/parse_commands.h"
|
||||
#include "rpc/object_storage.h"
|
||||
|
||||
namespace tr1 { using namespace std::tr1; }
|
||||
|
||||
void initialize_commands();
|
||||
|
||||
//
|
||||
@@ -100,43 +98,43 @@ void initialize_commands();
|
||||
|
||||
#define CMD2_VAR_BOOL(key, value) \
|
||||
control->object_storage()->insert_c_str(key, int64_t(value), rpc::object_storage::flag_bool_type); \
|
||||
CMD2_ANY(key, tr1::bind(&rpc::object_storage::get, control->object_storage(), \
|
||||
CMD2_ANY(key, std::bind(&rpc::object_storage::get, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key))); \
|
||||
CMD2_ANY_VALUE(key ".set", tr1::bind(&rpc::object_storage::set_bool, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key), tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE(key ".set", std::bind(&rpc::object_storage::set_bool, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key), std::placeholders::_2));
|
||||
|
||||
#define CMD2_VAR_VALUE(key, value) \
|
||||
control->object_storage()->insert_c_str(key, int64_t(value), rpc::object_storage::flag_value_type); \
|
||||
CMD2_ANY(key, tr1::bind(&rpc::object_storage::get, control->object_storage(), \
|
||||
CMD2_ANY(key, std::bind(&rpc::object_storage::get, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key))); \
|
||||
CMD2_ANY_VALUE(key ".set", tr1::bind(&rpc::object_storage::set_value, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key), tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE(key ".set", std::bind(&rpc::object_storage::set_value, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key), std::placeholders::_2));
|
||||
|
||||
#define CMD2_VAR_STRING(key, value) \
|
||||
control->object_storage()->insert_c_str(key, value, rpc::object_storage::flag_string_type); \
|
||||
CMD2_ANY(key, tr1::bind(&rpc::object_storage::get, control->object_storage(), \
|
||||
CMD2_ANY(key, std::bind(&rpc::object_storage::get, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key))); \
|
||||
CMD2_ANY_STRING(key ".set", tr1::bind(&rpc::object_storage::set_string, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key), tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING(key ".set", std::bind(&rpc::object_storage::set_string, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key), std::placeholders::_2));
|
||||
|
||||
|
||||
#define CMD2_VAR_C_STRING(key, value) \
|
||||
control->object_storage()->insert_c_str(key, value, rpc::object_storage::flag_string_type); \
|
||||
CMD2_ANY(key, tr1::bind(&rpc::object_storage::get, control->object_storage(), \
|
||||
CMD2_ANY(key, std::bind(&rpc::object_storage::get, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key)));
|
||||
|
||||
#define CMD2_VAR_LIST(key) \
|
||||
control->object_storage()->insert_c_str(key, torrent::Object::create_list(), rpc::object_storage::flag_list_type); \
|
||||
CMD2_ANY(key, tr1::bind(&rpc::object_storage::get, control->object_storage(), \
|
||||
CMD2_ANY(key, std::bind(&rpc::object_storage::get, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key))); \
|
||||
CMD2_ANY_LIST(key ".set", tr1::bind(&rpc::object_storage::set_list, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key), tr1::placeholders::_2)); \
|
||||
CMD2_ANY_VOID(key ".push_back", tr1::bind(&rpc::object_storage::list_push_back, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key), tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST(key ".set", std::bind(&rpc::object_storage::set_list, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key), std::placeholders::_2)); \
|
||||
CMD2_ANY_VOID(key ".push_back", std::bind(&rpc::object_storage::list_push_back, control->object_storage(), \
|
||||
torrent::raw_string::from_c_str(key), std::placeholders::_2));
|
||||
|
||||
#define CMD2_FUNC_SINGLE(key, cmds) \
|
||||
CMD2_ANY(key, tr1::bind(&rpc::command_function_call_object, torrent::Object(torrent::raw_string::from_c_str(cmds)), \
|
||||
tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_ANY(key, std::bind(&rpc::command_function_call_object, torrent::Object(torrent::raw_string::from_c_str(cmds)), \
|
||||
std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
#define CMD2_REDIRECT(from_key, to_key) \
|
||||
rpc::commands.create_redirect(from_key, to_key, rpc::CommandMap::flag_public_xmlrpc | rpc::CommandMap::flag_dont_delete);
|
||||
|
||||
+216
-102
@@ -45,42 +45,14 @@
|
||||
#include "globals.h"
|
||||
#include "command_helpers.h"
|
||||
|
||||
void
|
||||
ipv4_filter_parse(const char* address, int value) {
|
||||
uint32_t ip_values[4] = { 0, 0, 0, 0 };
|
||||
unsigned int block = rpc::ipv4_table::mask_bits;
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
char ip_dot;
|
||||
int values_read;
|
||||
|
||||
if ((values_read = sscanf(address, "%u%1[.]%u%1[.]%u%1[.]%u/%u",
|
||||
ip_values + 0, &ip_dot,
|
||||
ip_values + 1, &ip_dot,
|
||||
ip_values + 2, &ip_dot,
|
||||
ip_values + 3,
|
||||
&block)) < 2 ||
|
||||
|
||||
// Make sure the dot is included.
|
||||
(values_read < 7 && values_read % 2) ||
|
||||
|
||||
ip_values[0] >= 256 ||
|
||||
ip_values[1] >= 256 ||
|
||||
ip_values[2] >= 256 ||
|
||||
ip_values[3] >= 256 ||
|
||||
|
||||
block > rpc::ipv4_table::mask_bits)
|
||||
throw torrent::input_error("Invalid address format.");
|
||||
|
||||
// E.g. '10.10.' will be '10.10.0.0/16'.
|
||||
if (values_read < 7)
|
||||
block = 8 * (values_read / 2);
|
||||
|
||||
lt_log_print(torrent::LOG_CONNECTION_DEBUG, "Adding ip filter for %u.%u.%u.%u/%u.",
|
||||
ip_values[0], ip_values[1], ip_values[2], ip_values[3], block);
|
||||
|
||||
torrent::PeerList::ipv4_filter()->insert((ip_values[0] << 24) + (ip_values[1] << 16) + (ip_values[2] << 8) + ip_values[3],
|
||||
rpc::ipv4_table::mask_bits - block, value);
|
||||
}
|
||||
bool ipv4_range_parse(const char* address, uint32_t* address_start, uint32_t* address_end);
|
||||
|
||||
torrent::Object
|
||||
apply_ip_tables_insert_table(const std::string& args) {
|
||||
@@ -98,7 +70,8 @@ apply_ip_tables_size_data(const std::string& args) {
|
||||
if (itr != ip_tables.end())
|
||||
throw torrent::input_error("IP table does not exist.");
|
||||
|
||||
return itr->table.sizeof_data();
|
||||
uint32_t size = itr->table.sizeof_data();
|
||||
return size;
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
@@ -110,20 +83,21 @@ apply_ip_tables_get(const torrent::Object::list_type& args) {
|
||||
|
||||
const std::string& name = (args_itr++)->as_string();
|
||||
const std::string& address = (args_itr++)->as_string();
|
||||
|
||||
// Move to a helper function, add support for addresses.
|
||||
uint32_t ip_values[4];
|
||||
|
||||
if (sscanf(address.c_str(), "%u.%u.%u.%u",
|
||||
ip_values + 0, ip_values + 1, ip_values + 2, ip_values + 3) != 4)
|
||||
throw torrent::input_error("Invalid address format.");
|
||||
uint32_t address_start;
|
||||
uint32_t address_end;
|
||||
|
||||
rpc::ip_table_list::iterator table_itr = ip_tables.find(name);
|
||||
|
||||
if (table_itr == ip_tables.end())
|
||||
throw torrent::input_error("Could not find ip table.");
|
||||
|
||||
return table_itr->table.at((ip_values[0] << 24) + (ip_values[1] << 16) + (ip_values[2] << 8) + ip_values[3]);
|
||||
if (!ipv4_range_parse(address.c_str(), &address_start, &address_end))
|
||||
throw torrent::input_error("Invalid address format.");
|
||||
|
||||
if(!table_itr->table.defined(address_start, address_end))
|
||||
throw torrent::input_error("No value defined for specified IP(s).");
|
||||
|
||||
return table_itr->table.at(address_start, address_end);
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
@@ -136,15 +110,6 @@ apply_ip_tables_add_address(const torrent::Object::list_type& args) {
|
||||
const std::string& name = (args_itr++)->as_string();
|
||||
const std::string& address = (args_itr++)->as_string();
|
||||
const std::string& value_str = (args_itr++)->as_string();
|
||||
|
||||
// Move to a helper function, add support for addresses.
|
||||
uint32_t ip_values[4];
|
||||
unsigned int block = rpc::ipv4_table::mask_bits;
|
||||
|
||||
if (sscanf(address.c_str(), "%u.%u.%u.%u/%u",
|
||||
ip_values + 0, ip_values + 1, ip_values + 2, ip_values + 3, &block) < 4 ||
|
||||
block > rpc::ipv4_table::mask_bits)
|
||||
throw torrent::input_error("Invalid address format.");
|
||||
|
||||
int value;
|
||||
|
||||
@@ -158,8 +123,13 @@ apply_ip_tables_add_address(const torrent::Object::list_type& args) {
|
||||
if (table_itr == ip_tables.end())
|
||||
throw torrent::input_error("Could not find ip table.");
|
||||
|
||||
table_itr->table.insert((ip_values[0] << 24) + (ip_values[1] << 16) + (ip_values[2] << 8) + ip_values[3],
|
||||
rpc::ipv4_table::mask_bits - block, value);
|
||||
uint32_t address_start;
|
||||
uint32_t address_end;
|
||||
|
||||
if (ipv4_range_parse(address.c_str(), &address_start, &address_end))
|
||||
table_itr->table.insert(address_start, address_end, value);
|
||||
else
|
||||
throw torrent::input_error("Invalid address format.");
|
||||
|
||||
return torrent::Object();
|
||||
}
|
||||
@@ -168,6 +138,158 @@ apply_ip_tables_add_address(const torrent::Object::list_type& args) {
|
||||
// IPv4 filter functions:
|
||||
//
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// IPV4_RANGE_PARSE parses string into an ip range
|
||||
//
|
||||
// should be compatible with lines in p2p files
|
||||
// everything in address before colon is ignored
|
||||
//
|
||||
// ip range can be single ip in which case start=end
|
||||
// ip range can be cidr notation a.b.c.d/e
|
||||
// ip range can be explicit range like in p2p line a.b.c.d-w.x.y.z
|
||||
//
|
||||
// returns false if line does not contain valid ip or ip range
|
||||
// address_start and address_end will contain start and end ip
|
||||
//
|
||||
// addresses parsed are returned in host byte order
|
||||
// to get network byte order call htonl(address)
|
||||
///////////////////////////////////////////////////////////
|
||||
bool
|
||||
ipv4_range_parse(const char* address, uint32_t* address_start, uint32_t* address_end) {
|
||||
// same length as buffer used to do reads so no worries about overflow
|
||||
char address_copy[4096];
|
||||
bool valid = false;
|
||||
char address_start_str[20];
|
||||
int address_start_index=0;
|
||||
struct sockaddr_in sa_start;
|
||||
*address_start=0;
|
||||
*address_end=0;
|
||||
|
||||
// get rid of everything after '#' comments
|
||||
// copy everything up to '#' to address_copy and work from there
|
||||
while(address[address_start_index] != '#' && address[address_start_index] != '\r' &&
|
||||
address[address_start_index] != '\n' && address[address_start_index] != '\0' &&
|
||||
address_start_index < 4096 ) {
|
||||
|
||||
address_copy[address_start_index] = address[address_start_index];
|
||||
address_start_index++;
|
||||
}
|
||||
|
||||
address_copy[address_start_index] = '\0';
|
||||
address_start_index=0;
|
||||
|
||||
// skip everything up to and including last ':' character and whitespace
|
||||
const char* addr = strrchr(address_copy, ':');
|
||||
|
||||
addr = (addr == NULL) ? address_copy : addr + 1;
|
||||
|
||||
while(addr[0] == ' ' || addr[0] == '\t')
|
||||
addr++;
|
||||
|
||||
while(((addr[0] >= '0' && addr[0] <= '9') || addr[0] == '.') && address_start_index < 19) {
|
||||
address_start_str[address_start_index] = addr[0];
|
||||
address_start_index++;
|
||||
addr++;
|
||||
}
|
||||
|
||||
address_start_str[address_start_index] = '\0';
|
||||
|
||||
if(strchr(addr, '-') != NULL) {
|
||||
// explicit range
|
||||
char address_end_str[20];
|
||||
int address_end_index=0;
|
||||
struct sockaddr_in sa_end;
|
||||
|
||||
while(addr[0] == '-' || addr[0] == ' ' || addr[0] == '\t')
|
||||
addr++;
|
||||
|
||||
while(((addr[0] >= '0' && addr[0] <= '9') || addr[0] == '.') && address_end_index < 19) {
|
||||
address_end_str[address_end_index] = addr[0];
|
||||
address_end_index++;
|
||||
addr++;
|
||||
}
|
||||
|
||||
address_end_str[address_end_index] = '\0';
|
||||
|
||||
if(inet_pton(AF_INET, address_start_str, &(sa_start.sin_addr)) != 0 && inet_pton(AF_INET, address_end_str, &(sa_end.sin_addr)) != 0) {
|
||||
*address_start = ntohl(sa_start.sin_addr.s_addr);
|
||||
*address_end = ntohl(sa_end.sin_addr.s_addr);
|
||||
|
||||
if(*address_start <= *address_end)
|
||||
valid=true;
|
||||
}
|
||||
} else if(strchr(addr, '/') != NULL) {
|
||||
// cidr range
|
||||
char mask_bits_str[20];
|
||||
int mask_bits_index=0;
|
||||
uint32_t mask_bits;
|
||||
|
||||
while(addr[0] == '/' || addr[0] == ' ' || addr[0] == '\t')
|
||||
addr++;
|
||||
|
||||
while( (addr[0] >= '0' && addr[0] <= '9') && mask_bits_index < 19) {
|
||||
mask_bits_str[mask_bits_index] = addr[0];
|
||||
mask_bits_index++;
|
||||
addr++;
|
||||
}
|
||||
|
||||
mask_bits_str[mask_bits_index] = '\0';
|
||||
|
||||
if(inet_pton(AF_INET, address_start_str, &(sa_start.sin_addr)) != 0 && sscanf(mask_bits_str, "%u", &mask_bits) != 0) {
|
||||
if(mask_bits <=32) {
|
||||
uint32_t ip=ntohl(sa_start.sin_addr.s_addr);
|
||||
uint32_t mask=0;
|
||||
uint32_t end_mask=0;
|
||||
|
||||
mask = (~mask) << (32-mask_bits);
|
||||
*address_start = ip & mask;
|
||||
end_mask = (~end_mask) >> mask_bits;
|
||||
*address_end = (ip & mask) | end_mask;
|
||||
|
||||
valid=true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// single ip
|
||||
if(inet_pton(AF_INET, address_start_str, &(sa_start.sin_addr)) != 0) {
|
||||
*address_start = ntohl(sa_start.sin_addr.s_addr);
|
||||
*address_end = *address_start;
|
||||
|
||||
valid=true;
|
||||
}
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// IPV4_FILTER_PARSE
|
||||
//
|
||||
// should now be compatible with lines in p2p files
|
||||
//
|
||||
// addresses in table MUST be in host byte order
|
||||
// ntohl is called after parsing ip address(es)
|
||||
///////////////////////////////////////////////////////////
|
||||
void
|
||||
ipv4_filter_parse(const char* address, int value) {
|
||||
uint32_t address_start;
|
||||
uint32_t address_end;
|
||||
|
||||
if (ipv4_range_parse(address, &address_start, &address_end) ) {
|
||||
torrent::PeerList::ipv4_filter()->insert(address_start, address_end, value);
|
||||
|
||||
char start_str[INET_ADDRSTRLEN];
|
||||
char end_str[INET_ADDRSTRLEN];
|
||||
uint32_t net_start = htonl(address_start);
|
||||
uint32_t net_end = htonl(address_end);
|
||||
|
||||
inet_ntop(AF_INET, &net_start, start_str, INET_ADDRSTRLEN);
|
||||
inet_ntop(AF_INET, &net_end, end_str, INET_ADDRSTRLEN);
|
||||
|
||||
lt_log_print(torrent::LOG_CONNECTION_DEBUG, "Adding ip filter for %s-%s.", start_str, end_str);
|
||||
}
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
apply_ipv4_filter_size_data() {
|
||||
return torrent::PeerList::ipv4_filter()->sizeof_data();
|
||||
@@ -175,14 +297,16 @@ apply_ipv4_filter_size_data() {
|
||||
|
||||
torrent::Object
|
||||
apply_ipv4_filter_get(const std::string& args) {
|
||||
// Move to a helper function, add support for addresses.
|
||||
uint32_t ip_values[4];
|
||||
uint32_t address_start;
|
||||
uint32_t address_end;
|
||||
|
||||
if (sscanf(args.c_str(), "%u.%u.%u.%u",
|
||||
ip_values + 0, ip_values + 1, ip_values + 2, ip_values + 3) != 4)
|
||||
if (!ipv4_range_parse(args.c_str(), &address_start, &address_end))
|
||||
throw torrent::input_error("Invalid address format.");
|
||||
|
||||
return torrent::PeerList::ipv4_filter()->at((ip_values[0] << 24) + (ip_values[1] << 16) + (ip_values[2] << 8) + ip_values[3]);
|
||||
if(!torrent::PeerList::ipv4_filter()->defined(address_start, address_end))
|
||||
throw torrent::input_error("No value defined for specified IP(s).");
|
||||
|
||||
return torrent::PeerList::ipv4_filter()->at(address_start, address_end);
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
@@ -240,58 +364,48 @@ apply_ipv4_filter_load(const torrent::Object::list_type& args) {
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
static void
|
||||
append_table(torrent::ipv4_table::base_type* extent, torrent::Object::list_type& result) {
|
||||
torrent::ipv4_table::table_type::iterator first = extent->table.begin();
|
||||
torrent::ipv4_table::table_type::iterator last = extent->table.end();
|
||||
|
||||
while (first != last) {
|
||||
if (first->first != NULL) {
|
||||
// Do something more here?...
|
||||
append_table(first->first, result);
|
||||
|
||||
} else if (first->second != 0) {
|
||||
uint32_t position = extent->partition_pos(first);
|
||||
|
||||
char buffer[256];
|
||||
snprintf(buffer, 256, "%u.%u.%u.%u/%u %s",
|
||||
(position >> 24) & 0xff,
|
||||
(position >> 16) & 0xff,
|
||||
(position >> 8) & 0xff,
|
||||
(position >> 0) & 0xff,
|
||||
extent->mask_bits,
|
||||
torrent::option_as_string(torrent::OPTION_IP_FILTER, first->second));
|
||||
|
||||
result.push_back((std::string)buffer);
|
||||
}
|
||||
|
||||
first++;
|
||||
}
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
apply_ipv4_filter_dump() {
|
||||
torrent::Object raw_result = torrent::Object::create_list();
|
||||
torrent::Object::list_type& result = raw_result.as_list();
|
||||
|
||||
append_table(torrent::PeerList::ipv4_filter()->data(), result);
|
||||
torrent::ipv4_table::range_map_type range_map = torrent::PeerList::ipv4_filter()->range_map;
|
||||
torrent::ipv4_table::range_map_type::iterator iter = range_map.begin();
|
||||
|
||||
while(iter != range_map.end()) {
|
||||
char buffer[64];
|
||||
uint32_t address_start = iter->first;
|
||||
uint32_t address_end = (iter->second).first;
|
||||
int value = (iter->second).second;
|
||||
|
||||
char start_str[INET_ADDRSTRLEN];
|
||||
char end_str[INET_ADDRSTRLEN];
|
||||
uint32_t net_start = htonl(address_start);
|
||||
uint32_t net_end = htonl(address_end);
|
||||
|
||||
inet_ntop(AF_INET, &net_start, start_str, INET_ADDRSTRLEN);
|
||||
inet_ntop(AF_INET, &net_end, end_str, INET_ADDRSTRLEN);
|
||||
|
||||
snprintf(buffer, 64, "%s-%s %s", start_str, end_str, torrent::option_as_string(torrent::OPTION_IP_FILTER, value));
|
||||
|
||||
result.push_back((std::string)buffer);
|
||||
|
||||
iter++;
|
||||
}
|
||||
|
||||
return raw_result;
|
||||
}
|
||||
|
||||
void
|
||||
initialize_command_ip() {
|
||||
CMD2_ANY ("strings.ip_filter", tr1::bind(&torrent::option_list_strings, torrent::OPTION_IP_FILTER));
|
||||
CMD2_ANY ("strings.ip_tos", tr1::bind(&torrent::option_list_strings, torrent::OPTION_IP_TOS));
|
||||
CMD2_ANY_STRING ("ip_tables.insert_table", std::bind(&apply_ip_tables_insert_table, std::placeholders::_2));
|
||||
CMD2_ANY_STRING ("ip_tables.size_data", std::bind(&apply_ip_tables_size_data, std::placeholders::_2));
|
||||
CMD2_ANY_LIST ("ip_tables.get", std::bind(&apply_ip_tables_get, std::placeholders::_2));
|
||||
CMD2_ANY_LIST ("ip_tables.add_address", std::bind(&apply_ip_tables_add_address, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_STRING ("ip_tables.insert_table", tr1::bind(&apply_ip_tables_insert_table, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("ip_tables.size_data", tr1::bind(&apply_ip_tables_size_data, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("ip_tables.get", tr1::bind(&apply_ip_tables_get, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("ip_tables.add_address", tr1::bind(&apply_ip_tables_add_address, tr1::placeholders::_2));
|
||||
|
||||
CMD2_ANY ("ipv4_filter.size_data", tr1::bind(&apply_ipv4_filter_size_data));
|
||||
CMD2_ANY_STRING ("ipv4_filter.get", tr1::bind(&apply_ipv4_filter_get, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("ipv4_filter.add_address", tr1::bind(&apply_ipv4_filter_add_address, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("ipv4_filter.load", tr1::bind(&apply_ipv4_filter_load, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("ipv4_filter.dump", tr1::bind(&apply_ipv4_filter_dump));
|
||||
CMD2_ANY ("ipv4_filter.size_data", std::bind(&apply_ipv4_filter_size_data));
|
||||
CMD2_ANY_STRING ("ipv4_filter.get", std::bind(&apply_ipv4_filter_get, std::placeholders::_2));
|
||||
CMD2_ANY_LIST ("ipv4_filter.add_address", std::bind(&apply_ipv4_filter_add_address, std::placeholders::_2));
|
||||
CMD2_ANY_LIST ("ipv4_filter.load", std::bind(&apply_ipv4_filter_load, std::placeholders::_2));
|
||||
CMD2_ANY_LIST ("ipv4_filter.dump", std::bind(&apply_ipv4_filter_dump));
|
||||
}
|
||||
|
||||
+70
-149
@@ -5,12 +5,12 @@
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@@ -48,7 +48,6 @@
|
||||
#include <torrent/chunk_manager.h>
|
||||
#include <torrent/data/file_manager.h>
|
||||
#include <torrent/data/chunk_utils.h>
|
||||
#include <torrent/utils/log.h>
|
||||
#include <torrent/utils/option_strings.h>
|
||||
|
||||
#include "core/download.h"
|
||||
@@ -80,39 +79,12 @@ apply_pieces_stats_total_size() {
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
apply_log(const torrent::Object::string_type& arg, int logType) {
|
||||
if (rpc::execFile.log_fd() != -1) {
|
||||
switch (logType) {
|
||||
case 0: ::close(rpc::execFile.log_fd()); rpc::execFile.set_log_fd(-1); break;
|
||||
case 1:
|
||||
// if (control->scgi()) {
|
||||
// ::close(control->scgi()->log_fd());
|
||||
// control->scgi()->set_log_fd(-1);
|
||||
// }
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
system_env(const torrent::Object::string_type& arg) {
|
||||
if (arg.empty())
|
||||
throw torrent::input_error("system.env: Missing variable name.");
|
||||
|
||||
if (!arg.empty()) {
|
||||
int logFd = open(rak::path_expand(arg).c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
|
||||
|
||||
if (logFd < 0)
|
||||
throw torrent::input_error("Could not open execute log file.");
|
||||
|
||||
switch (logType) {
|
||||
case 0: rpc::execFile.set_log_fd(logFd); break;
|
||||
// case 1: if (control->scgi()) control->scgi()->set_log_fd(logFd); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
control->core()->push_log("Opened log file.");
|
||||
|
||||
} else {
|
||||
control->core()->push_log("Closed log file.");
|
||||
}
|
||||
|
||||
return torrent::Object();
|
||||
char* val = getenv(arg.c_str());
|
||||
return std::string(val ? val : "");
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
@@ -163,7 +135,7 @@ check_name(const std::string& str) {
|
||||
throw torrent::input_error("Non-alphanumeric characters found.");
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
group_insert(const torrent::Object::list_type& args) {
|
||||
@@ -186,7 +158,7 @@ group_insert(const torrent::Object::list_type& args) {
|
||||
|
||||
if (rpc::call_command_value("method.use_intermediate") == 1) {
|
||||
// Deprecated in 0.7.0:
|
||||
|
||||
|
||||
CMD2_REDIRECT_GENERIC_STR("group." + name + ".view", "group2." + name + ".view");
|
||||
CMD2_REDIRECT_GENERIC_STR("group." + name + ".view.set", "group2." + name + ".view.set");
|
||||
CMD2_REDIRECT_GENERIC_STR("group." + name + ".ratio.min", "group2." + name + ".ratio.min");
|
||||
@@ -198,7 +170,7 @@ group_insert(const torrent::Object::list_type& args) {
|
||||
|
||||
} if (rpc::call_command_value("method.use_intermediate") == 2) {
|
||||
// Deprecated in 0.7.0:
|
||||
|
||||
|
||||
CMD2_REDIRECT_GENERIC_STR_NO_EXPORT("group." + name + ".view", "group2." + name + ".view");
|
||||
CMD2_REDIRECT_GENERIC_STR_NO_EXPORT("group." + name + ".view.set", "group2." + name + ".view.set");
|
||||
CMD2_REDIRECT_GENERIC_STR_NO_EXPORT("group." + name + ".ratio.min", "group2." + name + ".ratio.min");
|
||||
@@ -212,27 +184,6 @@ group_insert(const torrent::Object::list_type& args) {
|
||||
return name;
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
log_vmmap_dump(const std::string& str) {
|
||||
core::DownloadList* d_list = control->core()->download_list();
|
||||
std::vector<torrent::vm_mapping> all_mappings;
|
||||
|
||||
for (core::DownloadList::iterator itr = d_list->begin(), last = d_list->end(); itr != last; itr++) {
|
||||
std::vector<torrent::vm_mapping> tmp_mappings = torrent::chunk_list_mapping((*itr)->download());
|
||||
|
||||
all_mappings.insert(all_mappings.end(), tmp_mappings.begin(), tmp_mappings.end());
|
||||
}
|
||||
|
||||
FILE* log_file = fopen(str.c_str(), "w");
|
||||
|
||||
for (std::vector<torrent::vm_mapping>::iterator itr = all_mappings.begin(), last = all_mappings.end(); itr != last; itr++) {
|
||||
fprintf(log_file, "%8p-%8p [%5llxk]\n", itr->ptr, (char*)itr->ptr + itr->length, (long long unsigned int)(itr->length / 1024));
|
||||
}
|
||||
|
||||
fclose(log_file);
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
static const int file_print_use_space = 0x1;
|
||||
static const int file_print_delim_space = 0x2;
|
||||
|
||||
@@ -264,9 +215,9 @@ torrent::Object
|
||||
cmd_file_append(const torrent::Object::list_type& args) {
|
||||
if (args.empty())
|
||||
throw torrent::input_error("Invalid number of arguments.");
|
||||
|
||||
|
||||
FILE* output = fopen(args.front().as_string().c_str(), "a");
|
||||
|
||||
|
||||
if (output == NULL)
|
||||
throw torrent::input_error("Could not append to file '" + args.front().as_string() + "': " + rak::error_number::current().c_str());
|
||||
|
||||
@@ -277,102 +228,80 @@ cmd_file_append(const torrent::Object::list_type& args) {
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
apply_log_open_file(const torrent::Object::list_type& args) {
|
||||
if (args.size() != 2)
|
||||
throw torrent::input_error("Invalid number of arguments.");
|
||||
|
||||
torrent::log_open_file_output(args.front().as_string().c_str(),
|
||||
rak::path_expand(args.back().as_string()).c_str());
|
||||
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)
|
||||
throw torrent::input_error("Invalid number of arguments.");
|
||||
|
||||
torrent::log_add_group_output(torrent::option_find_string(torrent::OPTION_LOG_GROUP, args.front().as_string().c_str()),
|
||||
args.back().as_string().c_str());
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
void
|
||||
initialize_command_local() {
|
||||
torrent::ChunkManager* chunkManager = torrent::chunk_manager();
|
||||
torrent::FileManager* fileManager = torrent::file_manager();
|
||||
core::DownloadList* dList = control->core()->download_list();
|
||||
core::DownloadStore* dStore = control->core()->download_store();
|
||||
torrent::ChunkManager* chunkManager = torrent::chunk_manager();
|
||||
torrent::FileManager* fileManager = torrent::file_manager();
|
||||
|
||||
CMD2_ANY ("system.hostname", tr1::bind(&system_hostname));
|
||||
CMD2_ANY ("system.pid", tr1::bind(&getpid));
|
||||
CMD2_ANY ("system.hostname", std::bind(&system_hostname));
|
||||
CMD2_ANY ("system.pid", std::bind(&getpid));
|
||||
|
||||
CMD2_VAR_C_STRING("system.api_version", (int64_t)API_VERSION);
|
||||
CMD2_VAR_C_STRING("system.client_version", PACKAGE_VERSION);
|
||||
CMD2_VAR_C_STRING("system.library_version", torrent::version());
|
||||
CMD2_VAR_VALUE ("system.file.allocate", 0);
|
||||
CMD2_VAR_VALUE ("system.file.max_size", (int64_t)128 << 30);
|
||||
CMD2_VAR_VALUE ("system.file.max_size", (int64_t)512 << 30);
|
||||
CMD2_VAR_VALUE ("system.file.split_size", -1);
|
||||
CMD2_VAR_STRING ("system.file.split_suffix", ".part");
|
||||
|
||||
CMD2_ANY ("system.file_status_cache.size", tr1::bind(&utils::FileStatusCache::size,
|
||||
(utils::FileStatusCache::base_type*)control->core()->file_status_cache()));
|
||||
CMD2_ANY_V ("system.file_status_cache.prune", tr1::bind(&utils::FileStatusCache::prune, control->core()->file_status_cache()));
|
||||
CMD2_ANY ("system.file_status_cache.size", std::bind(&utils::FileStatusCache::size,
|
||||
(utils::FileStatusCache::base_type*)control->core()->file_status_cache()));
|
||||
CMD2_ANY_V ("system.file_status_cache.prune", std::bind(&utils::FileStatusCache::prune, control->core()->file_status_cache()));
|
||||
|
||||
CMD2_VAR_BOOL ("file.prioritize_toc", 0);
|
||||
CMD2_VAR_LIST ("file.prioritize_toc.first");
|
||||
CMD2_VAR_LIST ("file.prioritize_toc.last");
|
||||
|
||||
CMD2_ANY ("system.files.opened_counter", tr1::bind(&FM_t::files_opened_counter, fileManager));
|
||||
CMD2_ANY ("system.files.closed_counter", tr1::bind(&FM_t::files_closed_counter, fileManager));
|
||||
CMD2_ANY ("system.files.failed_counter", tr1::bind(&FM_t::files_failed_counter, fileManager));
|
||||
CMD2_ANY ("system.files.opened_counter", std::bind(&FM_t::files_opened_counter, fileManager));
|
||||
CMD2_ANY ("system.files.closed_counter", std::bind(&FM_t::files_closed_counter, fileManager));
|
||||
CMD2_ANY ("system.files.failed_counter", std::bind(&FM_t::files_failed_counter, fileManager));
|
||||
|
||||
CMD2_ANY ("system.time", tr1::bind(&rak::timer::seconds, &cachedTime));
|
||||
CMD2_ANY ("system.time_seconds", tr1::bind(&rak::timer::current_seconds));
|
||||
CMD2_ANY ("system.time_usec", tr1::bind(&rak::timer::current_usec));
|
||||
CMD2_ANY_STRING ("system.env", std::bind(&system_env, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_VALUE_V ("system.umask.set", tr1::bind(&umask, tr1::placeholders::_2));
|
||||
CMD2_ANY ("system.time", std::bind(&rak::timer::seconds, &cachedTime));
|
||||
CMD2_ANY ("system.time_seconds", std::bind(&rak::timer::current_seconds));
|
||||
CMD2_ANY ("system.time_usec", std::bind(&rak::timer::current_usec));
|
||||
|
||||
CMD2_ANY ("system.cwd", tr1::bind(&system_get_cwd));
|
||||
CMD2_ANY_STRING ("system.cwd.set", tr1::bind(&system_set_cwd, tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE_V ("system.umask.set", std::bind(&umask, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY ("pieces.sync.always_safe", tr1::bind(&CM_t::safe_sync, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.sync.always_safe.set", tr1::bind(&CM_t::set_safe_sync, chunkManager, tr1::placeholders::_2));
|
||||
CMD2_ANY ("pieces.sync.safe_free_diskspace", tr1::bind(&CM_t::safe_free_diskspace, chunkManager));
|
||||
CMD2_ANY ("pieces.sync.timeout", tr1::bind(&CM_t::timeout_sync, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.sync.timeout.set", tr1::bind(&CM_t::set_timeout_sync, chunkManager, tr1::placeholders::_2));
|
||||
CMD2_ANY ("pieces.sync.timeout_safe", tr1::bind(&CM_t::timeout_safe_sync, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.sync.timeout_safe.set", tr1::bind(&CM_t::set_timeout_safe_sync, chunkManager, tr1::placeholders::_2));
|
||||
CMD2_ANY ("pieces.sync.queue_size", tr1::bind(&CM_t::sync_queue_size, chunkManager));
|
||||
CMD2_VAR_BOOL ("system.daemon", false);
|
||||
|
||||
CMD2_ANY ("pieces.preload.type", tr1::bind(&CM_t::preload_type, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.preload.type.set", tr1::bind(&CM_t::set_preload_type, chunkManager, tr1::placeholders::_2));
|
||||
CMD2_ANY ("pieces.preload.min_size", tr1::bind(&CM_t::preload_min_size, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.preload.min_size.set", tr1::bind(&CM_t::set_preload_min_size, chunkManager, tr1::placeholders::_2));
|
||||
CMD2_ANY ("pieces.preload.min_rate", tr1::bind(&CM_t::preload_required_rate, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.preload.min_rate.set", tr1::bind(&CM_t::set_preload_required_rate, chunkManager, tr1::placeholders::_2));
|
||||
CMD2_ANY_V ("system.shutdown.normal", std::bind(&Control::receive_normal_shutdown, control));
|
||||
CMD2_ANY_V ("system.shutdown.quick", std::bind(&Control::receive_quick_shutdown, control));
|
||||
CMD2_REDIRECT_GENERIC_NO_EXPORT("system.shutdown", "system.shutdown.normal");
|
||||
|
||||
CMD2_ANY ("pieces.memory.current", tr1::bind(&CM_t::memory_usage, chunkManager));
|
||||
CMD2_ANY ("pieces.memory.sync_queue", tr1::bind(&CM_t::sync_queue_memory_usage, chunkManager));
|
||||
CMD2_ANY ("pieces.memory.block_count", tr1::bind(&CM_t::memory_block_count, chunkManager));
|
||||
CMD2_ANY ("pieces.memory.max", tr1::bind(&CM_t::max_memory_usage, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.memory.max.set", tr1::bind(&CM_t::set_max_memory_usage, chunkManager, tr1::placeholders::_2));
|
||||
CMD2_ANY ("pieces.stats_preloaded", tr1::bind(&CM_t::stats_preloaded, chunkManager));
|
||||
CMD2_ANY ("pieces.stats_not_preloaded", tr1::bind(&CM_t::stats_not_preloaded, chunkManager));
|
||||
CMD2_ANY ("system.cwd", std::bind(&system_get_cwd));
|
||||
CMD2_ANY_STRING ("system.cwd.set", std::bind(&system_set_cwd, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY ("pieces.stats.total_size", tr1::bind(&apply_pieces_stats_total_size));
|
||||
CMD2_ANY ("pieces.sync.always_safe", std::bind(&CM_t::safe_sync, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.sync.always_safe.set", std::bind(&CM_t::set_safe_sync, chunkManager, std::placeholders::_2));
|
||||
CMD2_ANY ("pieces.sync.safe_free_diskspace", std::bind(&CM_t::safe_free_diskspace, chunkManager));
|
||||
CMD2_ANY ("pieces.sync.timeout", std::bind(&CM_t::timeout_sync, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.sync.timeout.set", std::bind(&CM_t::set_timeout_sync, chunkManager, std::placeholders::_2));
|
||||
CMD2_ANY ("pieces.sync.timeout_safe", std::bind(&CM_t::timeout_safe_sync, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.sync.timeout_safe.set", std::bind(&CM_t::set_timeout_safe_sync, chunkManager, std::placeholders::_2));
|
||||
CMD2_ANY ("pieces.sync.queue_size", std::bind(&CM_t::sync_queue_size, chunkManager));
|
||||
|
||||
CMD2_ANY ("pieces.hash.queue_size", tr1::bind(&torrent::hash_queue_size));
|
||||
CMD2_ANY ("pieces.preload.type", std::bind(&CM_t::preload_type, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.preload.type.set", std::bind(&CM_t::set_preload_type, chunkManager, std::placeholders::_2));
|
||||
CMD2_ANY ("pieces.preload.min_size", std::bind(&CM_t::preload_min_size, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.preload.min_size.set", std::bind(&CM_t::set_preload_min_size, chunkManager, std::placeholders::_2));
|
||||
CMD2_ANY ("pieces.preload.min_rate", std::bind(&CM_t::preload_required_rate, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.preload.min_rate.set", std::bind(&CM_t::set_preload_required_rate, chunkManager, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY ("pieces.memory.current", std::bind(&CM_t::memory_usage, chunkManager));
|
||||
CMD2_ANY ("pieces.memory.sync_queue", std::bind(&CM_t::sync_queue_memory_usage, chunkManager));
|
||||
CMD2_ANY ("pieces.memory.block_count", std::bind(&CM_t::memory_block_count, chunkManager));
|
||||
CMD2_ANY ("pieces.memory.max", std::bind(&CM_t::max_memory_usage, chunkManager));
|
||||
CMD2_ANY_VALUE_V ("pieces.memory.max.set", std::bind(&CM_t::set_max_memory_usage, chunkManager, std::placeholders::_2));
|
||||
CMD2_ANY ("pieces.stats_preloaded", std::bind(&CM_t::stats_preloaded, chunkManager));
|
||||
CMD2_ANY ("pieces.stats_not_preloaded", std::bind(&CM_t::stats_not_preloaded, chunkManager));
|
||||
|
||||
CMD2_ANY ("pieces.stats.total_size", std::bind(&apply_pieces_stats_total_size));
|
||||
|
||||
CMD2_ANY ("pieces.hash.queue_size", std::bind(&torrent::hash_queue_size));
|
||||
CMD2_VAR_BOOL ("pieces.hash.on_completion", true);
|
||||
|
||||
CMD2_VAR_STRING ("directory.default", "./");
|
||||
@@ -381,13 +310,13 @@ initialize_command_local() {
|
||||
CMD2_VAR_BOOL ("session.use_lock", true);
|
||||
CMD2_VAR_BOOL ("session.on_completion", true);
|
||||
|
||||
CMD2_ANY ("session.path", tr1::bind(&core::DownloadStore::path, dStore));
|
||||
CMD2_ANY_STRING_V("session.path.set", tr1::bind(&core::DownloadStore::set_path, dStore, tr1::placeholders::_2));
|
||||
CMD2_ANY ("session.path", std::bind(&core::DownloadStore::path, dStore));
|
||||
CMD2_ANY_STRING_V("session.path.set", std::bind(&core::DownloadStore::set_path, dStore, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_V ("session.save", tr1::bind(&core::DownloadList::session_save, dList));
|
||||
CMD2_ANY_V ("session.save", std::bind(&core::DownloadList::session_save, dList));
|
||||
|
||||
#define CMD2_EXECUTE(key, flags) \
|
||||
CMD2_ANY(key, tr1::bind(&rpc::ExecFile::execute_object, &rpc::execFile, tr1::placeholders::_2, flags));
|
||||
CMD2_ANY(key, std::bind(&rpc::ExecFile::execute_object, &rpc::execFile, std::placeholders::_2, flags));
|
||||
|
||||
CMD2_EXECUTE ("execute2", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_throw);
|
||||
CMD2_EXECUTE ("execute.throw", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_throw);
|
||||
@@ -401,25 +330,17 @@ 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.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));
|
||||
CMD2_ANY_STRING_V("log.xmlrpc", tr1::bind(&ThreadWorker::set_xmlrpc_log, worker_thread, tr1::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST ("file.append", tr1::bind(&cmd_file_append, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("file.append", std::bind(&cmd_file_append, std::placeholders::_2));
|
||||
|
||||
// TODO: Convert to new command types:
|
||||
*rpc::command_base::argument(0) = "placeholder.0";
|
||||
*rpc::command_base::argument(1) = "placeholder.1";
|
||||
*rpc::command_base::argument(2) = "placeholder.2";
|
||||
*rpc::command_base::argument(3) = "placeholder.3";
|
||||
CMD2_ANY_P("argument.0", tr1::bind(&rpc::command_base::argument_ref, 0));
|
||||
CMD2_ANY_P("argument.1", tr1::bind(&rpc::command_base::argument_ref, 1));
|
||||
CMD2_ANY_P("argument.2", tr1::bind(&rpc::command_base::argument_ref, 2));
|
||||
CMD2_ANY_P("argument.3", tr1::bind(&rpc::command_base::argument_ref, 3));
|
||||
CMD2_ANY_P("argument.0", std::bind(&rpc::command_base::argument_ref, 0));
|
||||
CMD2_ANY_P("argument.1", std::bind(&rpc::command_base::argument_ref, 1));
|
||||
CMD2_ANY_P("argument.2", std::bind(&rpc::command_base::argument_ref, 2));
|
||||
CMD2_ANY_P("argument.3", std::bind(&rpc::command_base::argument_ref, 3));
|
||||
|
||||
CMD2_ANY_LIST ("group.insert", tr1::bind(&group_insert, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("group.insert", std::bind(&group_insert, std::placeholders::_2));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
// rTorrent - BitTorrent client
|
||||
// Copyright (C) 2005-2011, Jari Sundell
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// In addition, as a special exception, the copyright holders give
|
||||
// permission to link the code of portions of this program with the
|
||||
// OpenSSL library under certain conditions as described in each
|
||||
// individual source file, and distribute linked combinations
|
||||
// including the two.
|
||||
//
|
||||
// You must obey the GNU General Public License in all respects for
|
||||
// all of the code used other than OpenSSL. If you modify file(s)
|
||||
// with this exception, you may extend this exception to your version
|
||||
// of the file(s), but you are not obligated to do so. If you do not
|
||||
// wish to do so, delete this exception statement from your version.
|
||||
// If you delete this exception statement from all source files in the
|
||||
// program, then also delete it here.
|
||||
//
|
||||
// Contact: Jari Sundell <jaris@ifi.uio.no>
|
||||
//
|
||||
// Skomakerveien 33
|
||||
// 3185 Skoppum, NORWAY
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <torrent/data/chunk_utils.h>
|
||||
#include <torrent/object.h>
|
||||
#include <torrent/utils/log.h>
|
||||
#include <torrent/utils/option_strings.h>
|
||||
|
||||
#include "core/download.h"
|
||||
#include "core/download_list.h"
|
||||
#include "core/manager.h"
|
||||
#include "rak/path.h"
|
||||
#include "rpc/parse_commands.h"
|
||||
|
||||
#include "globals.h"
|
||||
#include "control.h"
|
||||
#include "command_helpers.h"
|
||||
|
||||
static const int log_flag_use_gz = 0x1;
|
||||
static const int log_flag_append_pid = 0x2;
|
||||
|
||||
void
|
||||
log_add_group_output_str(const char* group_name, const char* output_id) {
|
||||
int log_group = torrent::option_find_string(torrent::OPTION_LOG_GROUP, group_name);
|
||||
torrent::log_add_group_output(log_group, output_id);
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
apply_log_open(int output_flags, const torrent::Object::list_type& args) {
|
||||
if (args.size() < 2)
|
||||
throw torrent::input_error("Invalid number of arguments.");
|
||||
|
||||
torrent::Object::list_const_iterator itr = args.begin();
|
||||
|
||||
std::string output_id = (itr++)->as_string();
|
||||
std::string file_name = rak::path_expand((itr++)->as_string());
|
||||
|
||||
if ((output_flags & log_flag_append_pid)) {
|
||||
char buffer[32];
|
||||
snprintf(buffer, 32, ".%li", (long)getpid());
|
||||
|
||||
file_name += buffer;
|
||||
}
|
||||
|
||||
if ((output_flags & log_flag_use_gz))
|
||||
torrent::log_open_gz_file_output(output_id.c_str(), file_name.c_str());
|
||||
else
|
||||
torrent::log_open_file_output(output_id.c_str(), file_name.c_str());
|
||||
|
||||
while (itr != args.end())
|
||||
log_add_group_output_str((itr++)->as_string().c_str(), output_id.c_str());
|
||||
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
apply_log_add_output(const torrent::Object::list_type& args) {
|
||||
if (args.size() != 2)
|
||||
throw torrent::input_error("Invalid number of arguments.");
|
||||
|
||||
log_add_group_output_str(args.front().as_string().c_str(),
|
||||
args.back().as_string().c_str());
|
||||
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
// TODO: Deprecated.
|
||||
torrent::Object
|
||||
apply_log(const torrent::Object::string_type& arg, int logType) {
|
||||
if (rpc::execFile.log_fd() != -1) {
|
||||
switch (logType) {
|
||||
case 0: ::close(rpc::execFile.log_fd()); rpc::execFile.set_log_fd(-1); break;
|
||||
case 1:
|
||||
// if (control->scgi()) {
|
||||
// ::close(control->scgi()->log_fd());
|
||||
// control->scgi()->set_log_fd(-1);
|
||||
// }
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!arg.empty()) {
|
||||
int logFd = open(rak::path_expand(arg).c_str(), O_WRONLY | O_APPEND | O_CREAT, 0644);
|
||||
|
||||
if (logFd < 0)
|
||||
throw torrent::input_error("Could not open execute log file.");
|
||||
|
||||
switch (logType) {
|
||||
case 0: rpc::execFile.set_log_fd(logFd); break;
|
||||
// case 1: if (control->scgi()) control->scgi()->set_log_fd(logFd); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
control->core()->push_log("Opened log file.");
|
||||
|
||||
} else {
|
||||
control->core()->push_log("Closed log file.");
|
||||
}
|
||||
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
log_vmmap_dump(const std::string& str) {
|
||||
core::DownloadList* d_list = control->core()->download_list();
|
||||
std::vector<torrent::vm_mapping> all_mappings;
|
||||
|
||||
for (core::DownloadList::iterator itr = d_list->begin(), last = d_list->end(); itr != last; itr++) {
|
||||
std::vector<torrent::vm_mapping> tmp_mappings = torrent::chunk_list_mapping((*itr)->download());
|
||||
|
||||
all_mappings.insert(all_mappings.end(), tmp_mappings.begin(), tmp_mappings.end());
|
||||
}
|
||||
|
||||
FILE* log_file = fopen(str.c_str(), "w");
|
||||
|
||||
for (std::vector<torrent::vm_mapping>::iterator itr = all_mappings.begin(), last = all_mappings.end(); itr != last; itr++) {
|
||||
fprintf(log_file, "%8p-%8p [%5llxk]\n", itr->ptr, (char*)itr->ptr + itr->length, (long long unsigned int)(itr->length / 1024));
|
||||
}
|
||||
|
||||
fclose(log_file);
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
void
|
||||
initialize_command_logging() {
|
||||
CMD2_ANY_LIST ("log.open_file", std::bind(&apply_log_open, 0, std::placeholders::_2));
|
||||
CMD2_ANY_LIST ("log.open_gz_file", std::bind(&apply_log_open, log_flag_use_gz, std::placeholders::_2));
|
||||
CMD2_ANY_LIST ("log.open_file_pid", std::bind(&apply_log_open, log_flag_append_pid, std::placeholders::_2));
|
||||
CMD2_ANY_LIST ("log.open_gz_file_pid", std::bind(&apply_log_open, log_flag_append_pid | log_flag_use_gz, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST ("log.add_output", std::bind(&apply_log_add_output, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_STRING ("log.execute", std::bind(&apply_log, std::placeholders::_2, 0));
|
||||
CMD2_ANY_STRING ("log.vmmap.dump", std::bind(&log_vmmap_dump, std::placeholders::_2));
|
||||
CMD2_ANY_STRING_V("log.xmlrpc", std::bind(&ThreadWorker::set_xmlrpc_log, worker_thread, std::placeholders::_2));
|
||||
}
|
||||
+48
-50
@@ -62,8 +62,6 @@
|
||||
#include "control.h"
|
||||
#include "command_helpers.h"
|
||||
|
||||
namespace tr1 { using namespace std::tr1; }
|
||||
|
||||
torrent::Object
|
||||
apply_encryption(const torrent::Object::list_type& args) {
|
||||
uint32_t options_mask = torrent::ConnectionManager::encryption_none;
|
||||
@@ -126,10 +124,10 @@ xmlrpc_find_peer(core::Download* download, const torrent::HashString& hash) {
|
||||
void
|
||||
initialize_xmlrpc() {
|
||||
rpc::xmlrpc.initialize();
|
||||
rpc::xmlrpc.slot_find_download() = tr1::bind(&core::DownloadList::find_hex_ptr, control->core()->download_list(), tr1::placeholders::_1);
|
||||
rpc::xmlrpc.slot_find_file() = tr1::bind(&xmlrpc_find_file, tr1::placeholders::_1, tr1::placeholders::_2);
|
||||
rpc::xmlrpc.slot_find_tracker() = tr1::bind(&xmlrpc_find_tracker, tr1::placeholders::_1, tr1::placeholders::_2);
|
||||
rpc::xmlrpc.slot_find_peer() = tr1::bind(&xmlrpc_find_peer, tr1::placeholders::_1, tr1::placeholders::_2);
|
||||
rpc::xmlrpc.slot_find_download() = std::bind(&core::DownloadList::find_hex_ptr, control->core()->download_list(), std::placeholders::_1);
|
||||
rpc::xmlrpc.slot_find_file() = std::bind(&xmlrpc_find_file, std::placeholders::_1, std::placeholders::_2);
|
||||
rpc::xmlrpc.slot_find_tracker() = std::bind(&xmlrpc_find_tracker, std::placeholders::_1, std::placeholders::_2);
|
||||
rpc::xmlrpc.slot_find_peer() = std::bind(&xmlrpc_find_peer, std::placeholders::_1, std::placeholders::_2);
|
||||
|
||||
unsigned int count = 0;
|
||||
|
||||
@@ -172,8 +170,9 @@ apply_scgi(const std::string& arg, int type) {
|
||||
lt_log_print(torrent::LOG_RPC_EVENTS,
|
||||
"The SCGI socket has not been bound to any address and likely poses a security risk.");
|
||||
|
||||
} else if (std::sscanf(arg.c_str(), "%1023[^:]:%i%c", address, &port, &dummy) == 2) {
|
||||
if ((err = rak::address_info::get_address_info(address, PF_INET, SOCK_STREAM, &ai)) != 0)
|
||||
} else if (std::sscanf(arg.c_str(), "%1023[^:]:%i%c", address, &port, &dummy) == 2 ||
|
||||
std::sscanf(arg.c_str(), "[%64[^]]]:%i%c", address, &port, &dummy) == 2) { // [xx::xx]:port format
|
||||
if ((err = rak::address_info::get_address_info(address,PF_UNSPEC, SOCK_STREAM, &ai)) != 0)
|
||||
throw torrent::input_error("Could not bind address: " + std::string(rak::address_info::strerror(err)) + ".");
|
||||
|
||||
saPtr = ai->address();
|
||||
@@ -238,23 +237,19 @@ initialize_command_network() {
|
||||
torrent::FileManager* fileManager = torrent::file_manager();
|
||||
core::CurlStack* httpStack = control->core()->http_stack();
|
||||
|
||||
CMD2_ANY ("strings.connection_type", tr1::bind(&torrent::option_list_strings, torrent::OPTION_CONNECTION_TYPE));
|
||||
CMD2_ANY ("strings.encryption", tr1::bind(&torrent::option_list_strings, torrent::OPTION_ENCRYPTION));
|
||||
|
||||
// CMD2_ANY_STRING ("encoding_list", tr1::bind(&apply_encoding_list, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("encoding.add", tr1::bind(&apply_encoding_list, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("encoding.add", std::bind(&apply_encoding_list, std::placeholders::_2));
|
||||
|
||||
// Isn't port_open used?
|
||||
CMD2_VAR_BOOL ("network.port_open", true);
|
||||
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.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_ANY ("network.listen.port", std::bind(&torrent::ConnectionManager::listen_port, cm));
|
||||
CMD2_ANY ("network.listen.backlog", std::bind(&torrent::ConnectionManager::listen_backlog, cm));
|
||||
CMD2_ANY_VALUE_V ("network.listen.backlog.set", std::bind(&torrent::ConnectionManager::set_listen_backlog, cm, std::placeholders::_2));
|
||||
|
||||
CMD2_VAR_BOOL ("protocol.pex", true);
|
||||
CMD2_ANY_LIST ("protocol.encryption.set", tr1::bind(&apply_encryption, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("protocol.encryption.set", std::bind(&apply_encryption, std::placeholders::_2));
|
||||
|
||||
CMD2_VAR_STRING ("protocol.connection.leech", "leech");
|
||||
CMD2_VAR_STRING ("protocol.connection.seed", "seed");
|
||||
@@ -264,43 +259,46 @@ initialize_command_network() {
|
||||
CMD2_VAR_STRING ("protocol.choke_heuristics.down.leech", "download_leech");
|
||||
CMD2_VAR_STRING ("protocol.choke_heuristics.down.seed", "download_leech");
|
||||
|
||||
CMD2_ANY ("network.http.capath", tr1::bind(&core::CurlStack::http_capath, httpStack));
|
||||
CMD2_ANY_STRING_V("network.http.capath.set", tr1::bind(&core::CurlStack::set_http_capath, httpStack, tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.http.cacert", tr1::bind(&core::CurlStack::http_cacert, httpStack));
|
||||
CMD2_ANY_STRING_V("network.http.cacert.set", tr1::bind(&core::CurlStack::set_http_cacert, httpStack, tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.http.proxy_address", tr1::bind(&core::CurlStack::http_proxy, httpStack));
|
||||
CMD2_ANY_STRING_V("network.http.proxy_address.set", tr1::bind(&core::CurlStack::set_http_proxy, httpStack, tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.http.max_open", tr1::bind(&core::CurlStack::max_active, httpStack));
|
||||
CMD2_ANY_VALUE_V ("network.http.max_open.set", tr1::bind(&core::CurlStack::set_max_active, httpStack, tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.http.ssl_verify_peer", tr1::bind(&core::CurlStack::ssl_verify_peer, httpStack));
|
||||
CMD2_ANY_VALUE_V ("network.http.ssl_verify_peer.set", tr1::bind(&core::CurlStack::set_ssl_verify_peer, httpStack, tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.http.dns_cache_timeout", tr1::bind(&core::CurlStack::dns_timeout, httpStack));
|
||||
CMD2_ANY_VALUE_V ("network.http.dns_cache_timeout.set", tr1::bind(&core::CurlStack::set_dns_timeout, httpStack, tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.http.cacert", std::bind(&core::CurlStack::http_cacert, httpStack));
|
||||
CMD2_ANY_STRING_V("network.http.cacert.set", std::bind(&core::CurlStack::set_http_cacert, httpStack, std::placeholders::_2));
|
||||
CMD2_ANY ("network.http.capath", std::bind(&core::CurlStack::http_capath, httpStack));
|
||||
CMD2_ANY_STRING_V("network.http.capath.set", std::bind(&core::CurlStack::set_http_capath, httpStack, std::placeholders::_2));
|
||||
CMD2_ANY ("network.http.dns_cache_timeout", std::bind(&core::CurlStack::dns_timeout, httpStack));
|
||||
CMD2_ANY_VALUE_V ("network.http.dns_cache_timeout.set", std::bind(&core::CurlStack::set_dns_timeout, httpStack, std::placeholders::_2));
|
||||
CMD2_ANY ("network.http.current_open", std::bind(&core::CurlStack::active, httpStack));
|
||||
CMD2_ANY ("network.http.max_open", std::bind(&core::CurlStack::max_active, httpStack));
|
||||
CMD2_ANY_VALUE_V ("network.http.max_open.set", std::bind(&core::CurlStack::set_max_active, httpStack, std::placeholders::_2));
|
||||
CMD2_ANY ("network.http.proxy_address", std::bind(&core::CurlStack::http_proxy, httpStack));
|
||||
CMD2_ANY_STRING_V("network.http.proxy_address.set", std::bind(&core::CurlStack::set_http_proxy, httpStack, std::placeholders::_2));
|
||||
CMD2_ANY ("network.http.ssl_verify_host", std::bind(&core::CurlStack::ssl_verify_host, httpStack));
|
||||
CMD2_ANY_VALUE_V ("network.http.ssl_verify_host.set", std::bind(&core::CurlStack::set_ssl_verify_host, httpStack, std::placeholders::_2));
|
||||
CMD2_ANY ("network.http.ssl_verify_peer", std::bind(&core::CurlStack::ssl_verify_peer, httpStack));
|
||||
CMD2_ANY_VALUE_V ("network.http.ssl_verify_peer.set", std::bind(&core::CurlStack::set_ssl_verify_peer, httpStack, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY ("network.send_buffer.size", tr1::bind(&torrent::ConnectionManager::send_buffer_size, cm));
|
||||
CMD2_ANY_VALUE_V ("network.send_buffer.size.set", tr1::bind(&torrent::ConnectionManager::set_send_buffer_size, cm, tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.receive_buffer.size", tr1::bind(&torrent::ConnectionManager::receive_buffer_size, cm));
|
||||
CMD2_ANY_VALUE_V ("network.receive_buffer.size.set", tr1::bind(&torrent::ConnectionManager::set_receive_buffer_size, cm, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("network.tos.set", tr1::bind(&apply_tos, tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.send_buffer.size", std::bind(&torrent::ConnectionManager::send_buffer_size, cm));
|
||||
CMD2_ANY_VALUE_V ("network.send_buffer.size.set", std::bind(&torrent::ConnectionManager::set_send_buffer_size, cm, std::placeholders::_2));
|
||||
CMD2_ANY ("network.receive_buffer.size", std::bind(&torrent::ConnectionManager::receive_buffer_size, cm));
|
||||
CMD2_ANY_VALUE_V ("network.receive_buffer.size.set", std::bind(&torrent::ConnectionManager::set_receive_buffer_size, cm, std::placeholders::_2));
|
||||
CMD2_ANY_STRING ("network.tos.set", std::bind(&apply_tos, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY ("network.bind_address", tr1::bind(&core::Manager::bind_address, control->core()));
|
||||
CMD2_ANY_STRING_V("network.bind_address.set", tr1::bind(&core::Manager::set_bind_address, control->core(), tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.local_address", tr1::bind(&core::Manager::local_address, control->core()));
|
||||
CMD2_ANY_STRING_V("network.local_address.set", tr1::bind(&core::Manager::set_local_address, control->core(), tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.proxy_address", tr1::bind(&core::Manager::proxy_address, control->core()));
|
||||
CMD2_ANY_STRING_V("network.proxy_address.set", tr1::bind(&core::Manager::set_proxy_address, control->core(), tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.bind_address", std::bind(&core::Manager::bind_address, control->core()));
|
||||
CMD2_ANY_STRING_V("network.bind_address.set", std::bind(&core::Manager::set_bind_address, control->core(), std::placeholders::_2));
|
||||
CMD2_ANY ("network.local_address", std::bind(&core::Manager::local_address, control->core()));
|
||||
CMD2_ANY_STRING_V("network.local_address.set", std::bind(&core::Manager::set_local_address, control->core(), std::placeholders::_2));
|
||||
CMD2_ANY ("network.proxy_address", std::bind(&core::Manager::proxy_address, control->core()));
|
||||
CMD2_ANY_STRING_V("network.proxy_address.set", std::bind(&core::Manager::set_proxy_address, control->core(), std::placeholders::_2));
|
||||
|
||||
CMD2_ANY ("network.max_open_files", tr1::bind(&torrent::FileManager::max_open_files, fileManager));
|
||||
CMD2_ANY_VALUE_V ("network.max_open_files.set", tr1::bind(&torrent::FileManager::set_max_open_files, fileManager, tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.open_sockets", tr1::bind(&torrent::ConnectionManager::size, cm));
|
||||
CMD2_ANY ("network.max_open_sockets", tr1::bind(&torrent::ConnectionManager::max_size, cm));
|
||||
CMD2_ANY_VALUE_V ("network.max_open_sockets.set", tr1::bind(&torrent::ConnectionManager::set_max_size, cm, tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.max_open_files", std::bind(&torrent::FileManager::max_open_files, fileManager));
|
||||
CMD2_ANY_VALUE_V ("network.max_open_files.set", std::bind(&torrent::FileManager::set_max_open_files, fileManager, std::placeholders::_2));
|
||||
CMD2_ANY ("network.open_sockets", std::bind(&torrent::ConnectionManager::size, cm));
|
||||
CMD2_ANY ("network.max_open_sockets", std::bind(&torrent::ConnectionManager::max_size, cm));
|
||||
CMD2_ANY_VALUE_V ("network.max_open_sockets.set", std::bind(&torrent::ConnectionManager::set_max_size, cm, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_STRING ("network.scgi.open_port", tr1::bind(&apply_scgi, tr1::placeholders::_2, 1));
|
||||
CMD2_ANY_STRING ("network.scgi.open_local", tr1::bind(&apply_scgi, tr1::placeholders::_2, 2));
|
||||
CMD2_ANY_STRING ("network.scgi.open_port", std::bind(&apply_scgi, std::placeholders::_2, 1));
|
||||
CMD2_ANY_STRING ("network.scgi.open_local", std::bind(&apply_scgi, std::placeholders::_2, 2));
|
||||
CMD2_VAR_BOOL ("network.scgi.dont_route", false);
|
||||
|
||||
CMD2_ANY_STRING ("network.xmlrpc.dialect.set", tr1::bind(&apply_xmlrpc_dialect, tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.xmlrpc.size_limit", tr1::bind(&rpc::XmlRpc::size_limit));
|
||||
CMD2_ANY_VALUE_V ("network.xmlrpc.size_limit.set", tr1::bind(&rpc::XmlRpc::set_size_limit, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("network.xmlrpc.dialect.set", std::bind(&apply_xmlrpc_dialect, std::placeholders::_2));
|
||||
CMD2_ANY ("network.xmlrpc.size_limit", std::bind(&rpc::XmlRpc::size_limit));
|
||||
CMD2_ANY_VALUE_V ("network.xmlrpc.size_limit.set", std::bind(&rpc::XmlRpc::set_size_limit, std::placeholders::_2));
|
||||
}
|
||||
|
||||
+31
-26
@@ -69,7 +69,12 @@ retrieve_p_id_html(torrent::Peer* peer) {
|
||||
|
||||
torrent::Object
|
||||
retrieve_p_address(torrent::Peer* peer) {
|
||||
return rak::socket_address::cast_from(peer->peer_info()->socket_address())->address_str();
|
||||
const rak::socket_address *addr = rak::socket_address::cast_from(peer->peer_info()->socket_address());
|
||||
|
||||
if (addr->family() == rak::socket_address::af_inet6)
|
||||
return "[" + addr->address_str() + "]";
|
||||
else
|
||||
return addr->address_str();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
@@ -97,37 +102,37 @@ retrieve_p_completed_percent(torrent::Peer* peer) {
|
||||
|
||||
void
|
||||
initialize_command_peer() {
|
||||
CMD2_PEER("p.id", tr1::bind(&retrieve_p_id, tr1::placeholders::_1));
|
||||
CMD2_PEER("p.id_html", tr1::bind(&retrieve_p_id_html, tr1::placeholders::_1));
|
||||
CMD2_PEER("p.client_version", tr1::bind(&retrieve_p_client_version, tr1::placeholders::_1));
|
||||
CMD2_PEER("p.id", std::bind(&retrieve_p_id, std::placeholders::_1));
|
||||
CMD2_PEER("p.id_html", std::bind(&retrieve_p_id_html, std::placeholders::_1));
|
||||
CMD2_PEER("p.client_version", std::bind(&retrieve_p_client_version, std::placeholders::_1));
|
||||
|
||||
CMD2_PEER("p.options_str", tr1::bind(&retrieve_p_options_str, tr1::placeholders::_1));
|
||||
CMD2_PEER("p.options_str", std::bind(&retrieve_p_options_str, std::placeholders::_1));
|
||||
|
||||
CMD2_PEER("p.is_encrypted", tr1::bind(&torrent::Peer::is_encrypted, tr1::placeholders::_1));
|
||||
CMD2_PEER("p.is_incoming", tr1::bind(&torrent::Peer::is_incoming, tr1::placeholders::_1));
|
||||
CMD2_PEER("p.is_obfuscated", tr1::bind(&torrent::Peer::is_obfuscated, tr1::placeholders::_1));
|
||||
CMD2_PEER("p.is_snubbed", tr1::bind(&torrent::Peer::is_snubbed, tr1::placeholders::_1));
|
||||
CMD2_PEER("p.is_encrypted", std::bind(&torrent::Peer::is_encrypted, std::placeholders::_1));
|
||||
CMD2_PEER("p.is_incoming", std::bind(&torrent::Peer::is_incoming, std::placeholders::_1));
|
||||
CMD2_PEER("p.is_obfuscated", std::bind(&torrent::Peer::is_obfuscated, std::placeholders::_1));
|
||||
CMD2_PEER("p.is_snubbed", std::bind(&torrent::Peer::is_snubbed, std::placeholders::_1));
|
||||
|
||||
CMD2_PEER("p.is_unwanted", tr1::bind(&torrent::PeerInfo::is_unwanted, tr1::bind(&torrent::Peer::peer_info, tr1::placeholders::_1)));
|
||||
CMD2_PEER("p.is_preferred", tr1::bind(&torrent::PeerInfo::is_preferred, tr1::bind(&torrent::Peer::peer_info, tr1::placeholders::_1)));
|
||||
CMD2_PEER("p.is_unwanted", std::bind(&torrent::PeerInfo::is_unwanted, std::bind(&torrent::Peer::peer_info, std::placeholders::_1)));
|
||||
CMD2_PEER("p.is_preferred", std::bind(&torrent::PeerInfo::is_preferred, std::bind(&torrent::Peer::peer_info, std::placeholders::_1)));
|
||||
|
||||
CMD2_PEER("p.address", tr1::bind(&retrieve_p_address, tr1::placeholders::_1));
|
||||
CMD2_PEER("p.port", tr1::bind(&retrieve_p_port, tr1::placeholders::_1));
|
||||
CMD2_PEER("p.address", std::bind(&retrieve_p_address, std::placeholders::_1));
|
||||
CMD2_PEER("p.port", std::bind(&retrieve_p_port, std::placeholders::_1));
|
||||
|
||||
CMD2_PEER("p.completed_percent", tr1::bind(&retrieve_p_completed_percent, tr1::placeholders::_1));
|
||||
CMD2_PEER("p.completed_percent", std::bind(&retrieve_p_completed_percent, std::placeholders::_1));
|
||||
|
||||
CMD2_PEER("p.up_rate", tr1::bind(&torrent::Rate::rate, tr1::bind(&torrent::Peer::up_rate, tr1::placeholders::_1)));
|
||||
CMD2_PEER("p.up_total", tr1::bind(&torrent::Rate::total, tr1::bind(&torrent::Peer::up_rate, tr1::placeholders::_1)));
|
||||
CMD2_PEER("p.down_rate", tr1::bind(&torrent::Rate::rate, tr1::bind(&torrent::Peer::down_rate, tr1::placeholders::_1)));
|
||||
CMD2_PEER("p.down_total", tr1::bind(&torrent::Rate::total, tr1::bind(&torrent::Peer::down_rate, tr1::placeholders::_1)));
|
||||
CMD2_PEER("p.peer_rate", tr1::bind(&torrent::Rate::rate, tr1::bind(&torrent::Peer::peer_rate, tr1::placeholders::_1)));
|
||||
CMD2_PEER("p.peer_total", tr1::bind(&torrent::Rate::total, tr1::bind(&torrent::Peer::peer_rate, tr1::placeholders::_1)));
|
||||
CMD2_PEER("p.up_rate", std::bind(&torrent::Rate::rate, std::bind(&torrent::Peer::up_rate, std::placeholders::_1)));
|
||||
CMD2_PEER("p.up_total", std::bind(&torrent::Rate::total, std::bind(&torrent::Peer::up_rate, std::placeholders::_1)));
|
||||
CMD2_PEER("p.down_rate", std::bind(&torrent::Rate::rate, std::bind(&torrent::Peer::down_rate, std::placeholders::_1)));
|
||||
CMD2_PEER("p.down_total", std::bind(&torrent::Rate::total, std::bind(&torrent::Peer::down_rate, std::placeholders::_1)));
|
||||
CMD2_PEER("p.peer_rate", std::bind(&torrent::Rate::rate, std::bind(&torrent::Peer::peer_rate, std::placeholders::_1)));
|
||||
CMD2_PEER("p.peer_total", std::bind(&torrent::Rate::total, std::bind(&torrent::Peer::peer_rate, std::placeholders::_1)));
|
||||
|
||||
CMD2_PEER ("p.snubbed", tr1::bind(&torrent::Peer::is_snubbed, tr1::placeholders::_1));
|
||||
CMD2_PEER_VALUE_V("p.snubbed.set", tr1::bind(&torrent::Peer::set_snubbed, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_PEER ("p.banned", tr1::bind(&torrent::Peer::is_banned, tr1::placeholders::_1));
|
||||
CMD2_PEER_VALUE_V("p.banned.set", tr1::bind(&torrent::Peer::set_banned, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_PEER ("p.snubbed", std::bind(&torrent::Peer::is_snubbed, std::placeholders::_1));
|
||||
CMD2_PEER_VALUE_V("p.snubbed.set", std::bind(&torrent::Peer::set_snubbed, std::placeholders::_1, std::placeholders::_2));
|
||||
CMD2_PEER ("p.banned", std::bind(&torrent::Peer::is_banned, std::placeholders::_1));
|
||||
CMD2_PEER_VALUE_V("p.banned.set", std::bind(&torrent::Peer::set_banned, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
CMD2_PEER_V("p.disconnect", tr1::bind(&torrent::Peer::disconnect, tr1::placeholders::_1, 0));
|
||||
CMD2_PEER_V("p.disconnect_delayed", tr1::bind(&torrent::Peer::disconnect, tr1::placeholders::_1, torrent::ConnectionList::disconnect_delayed));
|
||||
CMD2_PEER_V("p.disconnect", std::bind(&torrent::Peer::disconnect, std::placeholders::_1, 0));
|
||||
CMD2_PEER_V("p.disconnect_delayed", std::bind(&torrent::Peer::disconnect, std::placeholders::_1, torrent::ConnectionList::disconnect_delayed));
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ void
|
||||
initialize_command_scheduler() {
|
||||
CMD2_VAR_VALUE("scheduler.max_active", int64_t(-1));
|
||||
|
||||
CMD2_DL("scheduler.simple.added", tr1::bind(&cmd_scheduler_simple_added, tr1::placeholders::_1));
|
||||
CMD2_DL("scheduler.simple.removed", tr1::bind(&cmd_scheduler_simple_removed, tr1::placeholders::_1));
|
||||
CMD2_DL("scheduler.simple.update", tr1::bind(&cmd_scheduler_simple_update, tr1::placeholders::_1));
|
||||
CMD2_DL("scheduler.simple.added", std::bind(&cmd_scheduler_simple_added, std::placeholders::_1));
|
||||
CMD2_DL("scheduler.simple.removed", std::bind(&cmd_scheduler_simple_removed, std::placeholders::_1));
|
||||
CMD2_DL("scheduler.simple.update", std::bind(&cmd_scheduler_simple_update, std::placeholders::_1));
|
||||
}
|
||||
|
||||
+29
-26
@@ -96,12 +96,15 @@ torrent::Object
|
||||
apply_throttle(const torrent::Object::list_type& args, bool up) {
|
||||
torrent::Object::list_const_iterator argItr = args.begin();
|
||||
|
||||
if (argItr == args.end())
|
||||
throw torrent::input_error("Missing throttle name.");
|
||||
|
||||
const std::string& name = argItr->as_string();
|
||||
if (name.empty() || name == "NULL")
|
||||
throw torrent::input_error("Invalid throttle name.");
|
||||
throw torrent::input_error("Invalid throttle name '" + name + "'.");
|
||||
|
||||
if ((++argItr)->as_string().empty())
|
||||
return torrent::Object();
|
||||
if (++argItr == args.end() || argItr->as_string().empty())
|
||||
throw torrent::input_error("Missing throttle rate for '" + name + "'.");
|
||||
|
||||
int64_t rate;
|
||||
rpc::parse_whole_value_nothrow(argItr->as_string().c_str(), &rate);
|
||||
@@ -173,8 +176,8 @@ throttle_update(const char* variable, int64_t value) {
|
||||
|
||||
void
|
||||
initialize_command_throttle() {
|
||||
CMD2_ANY ("throttle.unchoked_uploads", tr1::bind(&torrent::ResourceManager::currently_upload_unchoked, torrent::resource_manager()));
|
||||
CMD2_ANY ("throttle.unchoked_downloads", tr1::bind(&torrent::ResourceManager::currently_download_unchoked, torrent::resource_manager()));
|
||||
CMD2_ANY ("throttle.unchoked_uploads", std::bind(&torrent::ResourceManager::currently_upload_unchoked, torrent::resource_manager()));
|
||||
CMD2_ANY ("throttle.unchoked_downloads", std::bind(&torrent::ResourceManager::currently_download_unchoked, torrent::resource_manager()));
|
||||
|
||||
CMD2_VAR_VALUE ("throttle.min_peers.normal", 100);
|
||||
CMD2_VAR_VALUE ("throttle.max_peers.normal", 200);
|
||||
@@ -196,31 +199,31 @@ initialize_command_throttle() {
|
||||
CMD2_REDIRECT_GENERIC("throttle.max_downloads.div", "throttle.max_downloads.div._val");
|
||||
CMD2_REDIRECT_GENERIC("throttle.max_downloads.global", "throttle.max_downloads.global._val");
|
||||
|
||||
CMD2_ANY_VALUE ("throttle.max_uploads.div.set", tr1::bind(&throttle_update, "throttle.max_uploads.div._val.set", tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE ("throttle.max_uploads.global.set", tr1::bind(&throttle_update, "throttle.max_uploads.global._val.set", tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE ("throttle.max_downloads.div.set", tr1::bind(&throttle_update, "throttle.max_downloads.div._val.set", tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE ("throttle.max_downloads.global.set", tr1::bind(&throttle_update, "throttle.max_downloads.global._val.set", tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE ("throttle.max_uploads.div.set", std::bind(&throttle_update, "throttle.max_uploads.div._val.set", std::placeholders::_2));
|
||||
CMD2_ANY_VALUE ("throttle.max_uploads.global.set", std::bind(&throttle_update, "throttle.max_uploads.global._val.set", std::placeholders::_2));
|
||||
CMD2_ANY_VALUE ("throttle.max_downloads.div.set", std::bind(&throttle_update, "throttle.max_downloads.div._val.set", std::placeholders::_2));
|
||||
CMD2_ANY_VALUE ("throttle.max_downloads.global.set", std::bind(&throttle_update, "throttle.max_downloads.global._val.set", std::placeholders::_2));
|
||||
|
||||
// TODO: Move the logic into some libtorrent function.
|
||||
CMD2_ANY ("throttle.global_up.rate", tr1::bind(&torrent::Rate::rate, torrent::up_rate()));
|
||||
CMD2_ANY ("throttle.global_up.total", tr1::bind(&torrent::Rate::total, torrent::up_rate()));
|
||||
CMD2_ANY ("throttle.global_up.max_rate", tr1::bind(&torrent::Throttle::max_rate, torrent::up_throttle_global()));
|
||||
CMD2_ANY_VALUE_V ("throttle.global_up.max_rate.set", tr1::bind(&ui::Root::set_up_throttle_i64, control->ui(), tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE_KB("throttle.global_up.max_rate.set_kb", tr1::bind(&ui::Root::set_up_throttle_i64, control->ui(), tr1::placeholders::_2));
|
||||
CMD2_ANY ("throttle.global_down.rate", tr1::bind(&torrent::Rate::rate, torrent::down_rate()));
|
||||
CMD2_ANY ("throttle.global_down.total", tr1::bind(&torrent::Rate::total, torrent::down_rate()));
|
||||
CMD2_ANY ("throttle.global_down.max_rate", tr1::bind(&torrent::Throttle::max_rate, torrent::down_throttle_global()));
|
||||
CMD2_ANY_VALUE_V ("throttle.global_down.max_rate.set", tr1::bind(&ui::Root::set_down_throttle_i64, control->ui(), tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE_KB("throttle.global_down.max_rate.set_kb", tr1::bind(&ui::Root::set_down_throttle_i64, control->ui(), tr1::placeholders::_2));
|
||||
CMD2_ANY ("throttle.global_up.rate", std::bind(&torrent::Rate::rate, torrent::up_rate()));
|
||||
CMD2_ANY ("throttle.global_up.total", std::bind(&torrent::Rate::total, torrent::up_rate()));
|
||||
CMD2_ANY ("throttle.global_up.max_rate", std::bind(&torrent::Throttle::max_rate, torrent::up_throttle_global()));
|
||||
CMD2_ANY_VALUE_V ("throttle.global_up.max_rate.set", std::bind(&ui::Root::set_up_throttle_i64, control->ui(), std::placeholders::_2));
|
||||
CMD2_ANY_VALUE_KB("throttle.global_up.max_rate.set_kb", std::bind(&ui::Root::set_up_throttle_i64, control->ui(), std::placeholders::_2));
|
||||
CMD2_ANY ("throttle.global_down.rate", std::bind(&torrent::Rate::rate, torrent::down_rate()));
|
||||
CMD2_ANY ("throttle.global_down.total", std::bind(&torrent::Rate::total, torrent::down_rate()));
|
||||
CMD2_ANY ("throttle.global_down.max_rate", std::bind(&torrent::Throttle::max_rate, torrent::down_throttle_global()));
|
||||
CMD2_ANY_VALUE_V ("throttle.global_down.max_rate.set", std::bind(&ui::Root::set_down_throttle_i64, control->ui(), std::placeholders::_2));
|
||||
CMD2_ANY_VALUE_KB("throttle.global_down.max_rate.set_kb", std::bind(&ui::Root::set_down_throttle_i64, control->ui(), std::placeholders::_2));
|
||||
|
||||
// Temporary names, need to change this to accept real rates rather
|
||||
// than kB.
|
||||
CMD2_ANY_LIST ("throttle.up", tr1::bind(&apply_throttle, tr1::placeholders::_2, true));
|
||||
CMD2_ANY_LIST ("throttle.down", tr1::bind(&apply_throttle, tr1::placeholders::_2, false));
|
||||
CMD2_ANY_LIST ("throttle.ip", tr1::bind(&apply_address_throttle, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("throttle.up", std::bind(&apply_throttle, std::placeholders::_2, true));
|
||||
CMD2_ANY_LIST ("throttle.down", std::bind(&apply_throttle, std::placeholders::_2, false));
|
||||
CMD2_ANY_LIST ("throttle.ip", std::bind(&apply_address_throttle, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_STRING ("throttle.up.max", tr1::bind(&retrieve_throttle_info, tr1::placeholders::_2, throttle_info_up | throttle_info_max));
|
||||
CMD2_ANY_STRING ("throttle.up.rate", tr1::bind(&retrieve_throttle_info, tr1::placeholders::_2, throttle_info_up | throttle_info_rate));
|
||||
CMD2_ANY_STRING ("throttle.down.max", tr1::bind(&retrieve_throttle_info, tr1::placeholders::_2, throttle_info_down | throttle_info_max));
|
||||
CMD2_ANY_STRING ("throttle.down.rate", tr1::bind(&retrieve_throttle_info, tr1::placeholders::_2, throttle_info_down | throttle_info_rate));
|
||||
CMD2_ANY_STRING ("throttle.up.max", std::bind(&retrieve_throttle_info, std::placeholders::_2, throttle_info_up | throttle_info_max));
|
||||
CMD2_ANY_STRING ("throttle.up.rate", std::bind(&retrieve_throttle_info, std::placeholders::_2, throttle_info_up | throttle_info_rate));
|
||||
CMD2_ANY_STRING ("throttle.down.max", std::bind(&retrieve_throttle_info, std::placeholders::_2, throttle_info_down | throttle_info_max));
|
||||
CMD2_ANY_STRING ("throttle.down.rate", std::bind(&retrieve_throttle_info, std::placeholders::_2, throttle_info_down | throttle_info_rate));
|
||||
}
|
||||
|
||||
+38
-38
@@ -111,59 +111,59 @@ apply_enable_trackers(int64_t arg) {
|
||||
|
||||
void
|
||||
initialize_command_tracker() {
|
||||
CMD2_TRACKER ("t.is_open", tr1::bind(&torrent::Tracker::is_busy, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.is_enabled", tr1::bind(&torrent::Tracker::is_enabled, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.is_usable", tr1::bind(&torrent::Tracker::is_usable, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.is_busy", tr1::bind(&torrent::Tracker::is_busy, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.is_extra_tracker", tr1::bind(&torrent::Tracker::is_extra_tracker, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.can_scrape", tr1::bind(&torrent::Tracker::can_scrape, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.is_open", std::bind(&torrent::Tracker::is_busy, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.is_enabled", std::bind(&torrent::Tracker::is_enabled, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.is_usable", std::bind(&torrent::Tracker::is_usable, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.is_busy", std::bind(&torrent::Tracker::is_busy, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.is_extra_tracker", std::bind(&torrent::Tracker::is_extra_tracker, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.can_scrape", std::bind(&torrent::Tracker::can_scrape, std::placeholders::_1));
|
||||
|
||||
CMD2_TRACKER_V ("t.enable", tr1::bind(&torrent::Tracker::enable, tr1::placeholders::_1));
|
||||
CMD2_TRACKER_V ("t.disable", tr1::bind(&torrent::Tracker::disable, tr1::placeholders::_1));
|
||||
CMD2_TRACKER_V ("t.enable", std::bind(&torrent::Tracker::enable, std::placeholders::_1));
|
||||
CMD2_TRACKER_V ("t.disable", std::bind(&torrent::Tracker::disable, std::placeholders::_1));
|
||||
|
||||
CMD2_TRACKER_VALUE_V("t.is_enabled.set", tr1::bind(&tracker_set_enabled, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_TRACKER_VALUE_V("t.is_enabled.set", std::bind(&tracker_set_enabled, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
CMD2_TRACKER ("t.url", tr1::bind(&torrent::Tracker::url, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.group", tr1::bind(&torrent::Tracker::group, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.type", tr1::bind(&torrent::Tracker::type, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.id", tr1::bind(&torrent::Tracker::tracker_id, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.url", std::bind(&torrent::Tracker::url, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.group", std::bind(&torrent::Tracker::group, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.type", std::bind(&torrent::Tracker::type, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.id", std::bind(&torrent::Tracker::tracker_id, std::placeholders::_1));
|
||||
|
||||
CMD2_TRACKER ("t.latest_event", tr1::bind(&torrent::Tracker::latest_event, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.latest_new_peers", tr1::bind(&torrent::Tracker::latest_new_peers, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.latest_sum_peers", tr1::bind(&torrent::Tracker::latest_sum_peers, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.latest_event", std::bind(&torrent::Tracker::latest_event, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.latest_new_peers", std::bind(&torrent::Tracker::latest_new_peers, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.latest_sum_peers", std::bind(&torrent::Tracker::latest_sum_peers, std::placeholders::_1));
|
||||
|
||||
// Time since last connection, connection attempt.
|
||||
|
||||
CMD2_TRACKER ("t.normal_interval", tr1::bind(&torrent::Tracker::normal_interval, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.min_interval", tr1::bind(&torrent::Tracker::min_interval, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.normal_interval", std::bind(&torrent::Tracker::normal_interval, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.min_interval", std::bind(&torrent::Tracker::min_interval, std::placeholders::_1));
|
||||
|
||||
CMD2_TRACKER ("t.activity_time_next", tr1::bind(&torrent::Tracker::activity_time_next, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.activity_time_last", tr1::bind(&torrent::Tracker::activity_time_last, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.activity_time_next", std::bind(&torrent::Tracker::activity_time_next, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.activity_time_last", std::bind(&torrent::Tracker::activity_time_last, std::placeholders::_1));
|
||||
|
||||
CMD2_TRACKER ("t.success_time_next", tr1::bind(&torrent::Tracker::success_time_next, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.success_time_last", tr1::bind(&torrent::Tracker::success_time_last, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.success_counter", tr1::bind(&torrent::Tracker::success_counter, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.success_time_next", std::bind(&torrent::Tracker::success_time_next, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.success_time_last", std::bind(&torrent::Tracker::success_time_last, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.success_counter", std::bind(&torrent::Tracker::success_counter, std::placeholders::_1));
|
||||
|
||||
CMD2_TRACKER ("t.failed_time_next", tr1::bind(&torrent::Tracker::failed_time_next, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.failed_time_last", tr1::bind(&torrent::Tracker::failed_time_last, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.failed_counter", tr1::bind(&torrent::Tracker::failed_counter, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.failed_time_next", std::bind(&torrent::Tracker::failed_time_next, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.failed_time_last", std::bind(&torrent::Tracker::failed_time_last, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.failed_counter", std::bind(&torrent::Tracker::failed_counter, std::placeholders::_1));
|
||||
|
||||
CMD2_TRACKER ("t.scrape_time_last", tr1::bind(&torrent::Tracker::scrape_time_last, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.scrape_counter", tr1::bind(&torrent::Tracker::scrape_counter, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.scrape_time_last", std::bind(&torrent::Tracker::scrape_time_last, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.scrape_counter", std::bind(&torrent::Tracker::scrape_counter, std::placeholders::_1));
|
||||
|
||||
CMD2_TRACKER ("t.scrape_complete", tr1::bind(&torrent::Tracker::scrape_complete, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.scrape_incomplete", tr1::bind(&torrent::Tracker::scrape_incomplete, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.scrape_downloaded", tr1::bind(&torrent::Tracker::scrape_downloaded, tr1::placeholders::_1));
|
||||
CMD2_TRACKER ("t.scrape_complete", std::bind(&torrent::Tracker::scrape_complete, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.scrape_incomplete", std::bind(&torrent::Tracker::scrape_incomplete, std::placeholders::_1));
|
||||
CMD2_TRACKER ("t.scrape_downloaded", std::bind(&torrent::Tracker::scrape_downloaded, std::placeholders::_1));
|
||||
|
||||
CMD2_ANY_VALUE ("trackers.enable", tr1::bind(&apply_enable_trackers, int64_t(1)));
|
||||
CMD2_ANY_VALUE ("trackers.disable", tr1::bind(&apply_enable_trackers, int64_t(0)));
|
||||
CMD2_ANY_VALUE ("trackers.enable", std::bind(&apply_enable_trackers, int64_t(1)));
|
||||
CMD2_ANY_VALUE ("trackers.disable", std::bind(&apply_enable_trackers, int64_t(0)));
|
||||
CMD2_VAR_VALUE ("trackers.numwant", -1);
|
||||
CMD2_VAR_BOOL ("trackers.use_udp", true);
|
||||
|
||||
CMD2_ANY_STRING_V ("dht.mode.set", tr1::bind(&core::DhtManager::set_mode, control->dht_manager(), tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING_V ("dht.mode.set", std::bind(&core::DhtManager::set_mode, control->dht_manager(), std::placeholders::_2));
|
||||
CMD2_VAR_VALUE ("dht.port", int64_t(6881));
|
||||
CMD2_ANY_STRING ("dht.add_node", tr1::bind(&apply_dht_add_node, tr1::placeholders::_2));
|
||||
CMD2_ANY ("dht.statistics", tr1::bind(&core::DhtManager::dht_statistics, control->dht_manager()));
|
||||
CMD2_ANY ("dht.throttle.name", tr1::bind(&core::DhtManager::throttle_name, control->dht_manager()));
|
||||
CMD2_ANY_STRING_V ("dht.throttle.name.set", tr1::bind(&core::DhtManager::set_throttle_name, control->dht_manager(), tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING ("dht.add_node", std::bind(&apply_dht_add_node, std::placeholders::_2));
|
||||
CMD2_ANY ("dht.statistics", std::bind(&core::DhtManager::dht_statistics, control->dht_manager()));
|
||||
CMD2_ANY ("dht.throttle.name", std::bind(&core::DhtManager::throttle_name, control->dht_manager()));
|
||||
CMD2_ANY_STRING_V ("dht.throttle.name.set", std::bind(&core::DhtManager::set_throttle_name, control->dht_manager(), std::placeholders::_2));
|
||||
}
|
||||
|
||||
+41
-32
@@ -466,6 +466,11 @@ cmd_ui_set_view(const torrent::Object::string_type& args) {
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
cmd_ui_current_view() {
|
||||
return control->ui()->download_list()->current_view()->name();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
cmd_ui_unfocus_download(core::Download* download) {
|
||||
control->ui()->download_list()->unfocus_download(download);
|
||||
@@ -518,41 +523,45 @@ void
|
||||
initialize_command_ui() {
|
||||
CMD2_VAR_STRING("keys.layout", "qwerty");
|
||||
|
||||
CMD2_ANY_STRING("view.add", object_convert_void(tr1::bind(&core::ViewManager::insert_throw, control->view_manager(), tr1::placeholders::_2)));
|
||||
CMD2_ANY_STRING("view.add", object_convert_void(std::bind(&core::ViewManager::insert_throw, control->view_manager(), std::placeholders::_2)));
|
||||
|
||||
CMD2_ANY_L ("view.list", tr1::bind(&apply_view_list));
|
||||
CMD2_ANY_LIST("view.set", tr1::bind(&apply_view_set, tr1::placeholders::_2));
|
||||
CMD2_ANY_L ("view.list", std::bind(&apply_view_list));
|
||||
CMD2_ANY_LIST("view.set", std::bind(&apply_view_set, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST("view.filter", tr1::bind(&apply_view_event, &core::ViewManager::set_filter, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.filter_on", tr1::bind(&apply_view_filter_on, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.filter", std::bind(&apply_view_event, &core::ViewManager::set_filter, std::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.filter_on", std::bind(&apply_view_filter_on, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST("view.sort", tr1::bind(&apply_view_sort, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.sort_new", tr1::bind(&apply_view_event, &core::ViewManager::set_sort_new, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.sort_current", tr1::bind(&apply_view_event, &core::ViewManager::set_sort_current, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.sort", std::bind(&apply_view_sort, std::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.sort_new", std::bind(&apply_view_event, &core::ViewManager::set_sort_new, std::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.sort_current", std::bind(&apply_view_event, &core::ViewManager::set_sort_current, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST("view.event_added", tr1::bind(&apply_view_event, &core::ViewManager::set_event_added, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.event_removed", tr1::bind(&apply_view_event, &core::ViewManager::set_event_removed, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.event_added", std::bind(&apply_view_event, &core::ViewManager::set_event_added, std::placeholders::_2));
|
||||
CMD2_ANY_LIST("view.event_removed", std::bind(&apply_view_event, &core::ViewManager::set_event_removed, std::placeholders::_2));
|
||||
|
||||
// Cleanup and add . to view.
|
||||
|
||||
CMD2_ANY_STRING("view.size", tr1::bind(&cmd_view_size, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING("view.size_not_visible", tr1::bind(&cmd_view_size_not_visible, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING("view.persistent", tr1::bind(&cmd_view_persistent, tr1::placeholders::_2));
|
||||
CMD2_ANY_STRING("view.size", std::bind(&cmd_view_size, std::placeholders::_2));
|
||||
CMD2_ANY_STRING("view.size_not_visible", std::bind(&cmd_view_size_not_visible, std::placeholders::_2));
|
||||
CMD2_ANY_STRING("view.persistent", std::bind(&cmd_view_persistent, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_STRING_V("view.filter_all", tr1::bind(&core::View::filter, tr1::bind(&core::ViewManager::find_ptr_throw, control->view_manager(), tr1::placeholders::_2)));
|
||||
CMD2_ANY_STRING_V("view.filter_all", std::bind(&core::View::filter, std::bind(&core::ViewManager::find_ptr_throw, control->view_manager(), std::placeholders::_2)));
|
||||
|
||||
CMD2_DL_STRING ("view.filter_download", tr1::bind(&cmd_view_filter_download, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL_STRING ("view.set_visible", tr1::bind(&cmd_view_set_visible, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL_STRING ("view.set_not_visible", tr1::bind(&cmd_view_set_not_visible, tr1::placeholders::_1, tr1::placeholders::_2));
|
||||
CMD2_DL_STRING ("view.filter_download", std::bind(&cmd_view_filter_download, std::placeholders::_1, std::placeholders::_2));
|
||||
CMD2_DL_STRING ("view.set_visible", std::bind(&cmd_view_set_visible, std::placeholders::_1, std::placeholders::_2));
|
||||
CMD2_DL_STRING ("view.set_not_visible", std::bind(&cmd_view_set_not_visible, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
// Commands that affect the default rtorrent UI.
|
||||
CMD2_DL ("ui.unfocus_download", tr1::bind(&cmd_ui_unfocus_download, tr1::placeholders::_1));
|
||||
CMD2_ANY_STRING("ui.current_view.set", tr1::bind(&cmd_ui_set_view, tr1::placeholders::_2));
|
||||
CMD2_DL ("ui.unfocus_download", std::bind(&cmd_ui_unfocus_download, std::placeholders::_1));
|
||||
CMD2_ANY ("ui.current_view", std::bind(&cmd_ui_current_view));
|
||||
CMD2_ANY_STRING("ui.current_view.set", std::bind(&cmd_ui_set_view, std::placeholders::_2));
|
||||
|
||||
// TODO: Add 'option_string' for rtorrent-specific options.
|
||||
CMD2_VAR_STRING("ui.torrent_list.layout", "full");
|
||||
|
||||
// Move.
|
||||
CMD2_ANY("print", &apply_print);
|
||||
CMD2_ANY("cat", &apply_cat);
|
||||
CMD2_ANY("if", tr1::bind(&apply_if, tr1::placeholders::_1, tr1::placeholders::_2, 0));
|
||||
CMD2_ANY("if", std::bind(&apply_if, std::placeholders::_1, std::placeholders::_2, 0));
|
||||
CMD2_ANY("not", &apply_not);
|
||||
CMD2_ANY("false", &apply_false);
|
||||
CMD2_ANY("and", &apply_and);
|
||||
@@ -560,22 +569,22 @@ initialize_command_ui() {
|
||||
|
||||
// A temporary command for handling stuff until we get proper
|
||||
// support for seperation of commands and literals.
|
||||
CMD2_ANY("branch", tr1::bind(&apply_if, tr1::placeholders::_1, tr1::placeholders::_2, 1));
|
||||
CMD2_ANY("branch", std::bind(&apply_if, std::placeholders::_1, std::placeholders::_2, 1));
|
||||
|
||||
CMD2_ANY_LIST("less", &apply_less);
|
||||
CMD2_ANY_LIST("greater", &apply_greater);
|
||||
CMD2_ANY_LIST("equal", &apply_equal);
|
||||
|
||||
CMD2_ANY_VALUE("convert.gm_time", tr1::bind(&apply_to_time, tr1::placeholders::_2, 0));
|
||||
CMD2_ANY_VALUE("convert.gm_date", tr1::bind(&apply_to_time, tr1::placeholders::_2, 0x2));
|
||||
CMD2_ANY_VALUE("convert.time", tr1::bind(&apply_to_time, tr1::placeholders::_2, 0x1));
|
||||
CMD2_ANY_VALUE("convert.date", tr1::bind(&apply_to_time, tr1::placeholders::_2, 0x1 | 0x2));
|
||||
CMD2_ANY_VALUE("convert.elapsed_time", tr1::bind(&apply_to_elapsed_time, tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE("convert.kb", tr1::bind(&apply_to_kb, tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE("convert.mb", tr1::bind(&apply_to_mb, tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE("convert.xb", tr1::bind(&apply_to_xb, tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE("convert.throttle", tr1::bind(&apply_to_throttle, tr1::placeholders::_2));
|
||||
CMD2_ANY_VALUE("convert.gm_time", std::bind(&apply_to_time, std::placeholders::_2, 0));
|
||||
CMD2_ANY_VALUE("convert.gm_date", std::bind(&apply_to_time, std::placeholders::_2, 0x2));
|
||||
CMD2_ANY_VALUE("convert.time", std::bind(&apply_to_time, std::placeholders::_2, 0x1));
|
||||
CMD2_ANY_VALUE("convert.date", std::bind(&apply_to_time, std::placeholders::_2, 0x1 | 0x2));
|
||||
CMD2_ANY_VALUE("convert.elapsed_time", std::bind(&apply_to_elapsed_time, std::placeholders::_2));
|
||||
CMD2_ANY_VALUE("convert.kb", std::bind(&apply_to_kb, std::placeholders::_2));
|
||||
CMD2_ANY_VALUE("convert.mb", std::bind(&apply_to_mb, std::placeholders::_2));
|
||||
CMD2_ANY_VALUE("convert.xb", std::bind(&apply_to_xb, std::placeholders::_2));
|
||||
CMD2_ANY_VALUE("convert.throttle", std::bind(&apply_to_throttle, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST ("elapsed.less", tr1::bind(&apply_elapsed_less, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("elapsed.greater", tr1::bind(&apply_elapsed_greater, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("elapsed.less", std::bind(&apply_elapsed_less, std::placeholders::_2));
|
||||
CMD2_ANY_LIST ("elapsed.greater", std::bind(&apply_elapsed_greater, std::placeholders::_2));
|
||||
}
|
||||
|
||||
+15
-7
@@ -5,12 +5,12 @@
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <torrent/connection_manager.h>
|
||||
#include <torrent/utils/directory_events.h>
|
||||
|
||||
#include "core/manager.h"
|
||||
#include "core/download_store.h"
|
||||
@@ -67,6 +68,7 @@ Control::Control() :
|
||||
|
||||
m_commandScheduler(new rpc::CommandScheduler()),
|
||||
m_objectStorage(new rpc::object_storage()),
|
||||
m_directory_events(new torrent::directory_events()),
|
||||
|
||||
m_tick(0),
|
||||
m_shutdownReceived(false),
|
||||
@@ -76,9 +78,9 @@ Control::Control() :
|
||||
m_viewManager = new core::ViewManager();
|
||||
m_dhtManager = new core::DhtManager();
|
||||
|
||||
m_inputStdin->slot_pressed(std::tr1::bind(&input::Manager::pressed, m_input, std::tr1::placeholders::_1));
|
||||
m_inputStdin->slot_pressed(std::bind(&input::Manager::pressed, m_input, std::placeholders::_1));
|
||||
|
||||
m_taskShutdown.slot() = std::tr1::bind(&Control::handle_shutdown, this);
|
||||
m_taskShutdown.slot() = std::bind(&Control::handle_shutdown, this);
|
||||
|
||||
m_commandScheduler->set_slot_error_message(rak::mem_fn(m_core, &core::Manager::push_log_std));
|
||||
}
|
||||
@@ -94,6 +96,7 @@ Control::~Control() {
|
||||
delete m_core;
|
||||
delete m_dhtManager;
|
||||
|
||||
delete m_directory_events;
|
||||
delete m_commandScheduler;
|
||||
delete m_objectStorage;
|
||||
}
|
||||
@@ -115,7 +118,9 @@ Control::initialize() {
|
||||
|
||||
m_ui->init(this);
|
||||
|
||||
m_inputStdin->insert(torrent::main_thread()->poll());
|
||||
if(!display::Canvas::daemon()) {
|
||||
m_inputStdin->insert(torrent::main_thread()->poll());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -125,13 +130,15 @@ Control::cleanup() {
|
||||
|
||||
priority_queue_erase(&taskScheduler, &m_taskShutdown);
|
||||
|
||||
m_inputStdin->remove(torrent::main_thread()->poll());
|
||||
if(!display::Canvas::daemon()) {
|
||||
m_inputStdin->remove(torrent::main_thread()->poll());
|
||||
}
|
||||
|
||||
m_core->download_store()->disable();
|
||||
|
||||
m_ui->cleanup();
|
||||
m_core->cleanup();
|
||||
|
||||
|
||||
display::Canvas::erase_std();
|
||||
display::Canvas::refresh_std();
|
||||
display::Canvas::do_update();
|
||||
@@ -167,6 +174,7 @@ Control::handle_shutdown() {
|
||||
worker_thread->queue_item(&ThreadBase::stop_thread);
|
||||
|
||||
torrent::connection_manager()->listen_close();
|
||||
m_directory_events->close();
|
||||
m_core->shutdown(false);
|
||||
|
||||
if (!m_taskShutdown.is_queued())
|
||||
|
||||
+9
-2
@@ -68,6 +68,10 @@ namespace rpc {
|
||||
class object_storage;
|
||||
}
|
||||
|
||||
namespace torrent {
|
||||
class directory_events;
|
||||
}
|
||||
|
||||
class Control {
|
||||
public:
|
||||
Control();
|
||||
@@ -98,6 +102,8 @@ public:
|
||||
rpc::CommandScheduler* command_scheduler() { return m_commandScheduler; }
|
||||
rpc::object_storage* object_storage() { return m_objectStorage; }
|
||||
|
||||
torrent::directory_events* directory_events() { return m_directory_events; }
|
||||
|
||||
uint64_t tick() const { return m_tick; }
|
||||
void inc_tick() { m_tick++; }
|
||||
|
||||
@@ -117,8 +123,9 @@ private:
|
||||
input::Manager* m_input;
|
||||
input::InputEvent* m_inputStdin;
|
||||
|
||||
rpc::CommandScheduler* m_commandScheduler;
|
||||
rpc::object_storage* m_objectStorage;
|
||||
rpc::CommandScheduler* m_commandScheduler;
|
||||
rpc::object_storage* m_objectStorage;
|
||||
torrent::directory_events* m_directory_events;
|
||||
|
||||
uint64_t m_tick;
|
||||
|
||||
|
||||
+17
-2
@@ -82,7 +82,7 @@ CurlGet::start() {
|
||||
|
||||
// Normally libcurl should handle the timeout. But sometimes that doesn't
|
||||
// work right so we do a fallback timeout that just aborts the transfer.
|
||||
m_taskTimeout.slot() = std::tr1::bind(&CurlGet::receive_timeout, this);
|
||||
m_taskTimeout.slot() = std::bind(&CurlGet::receive_timeout, this);
|
||||
priority_queue_erase(&taskScheduler, &m_taskTimeout);
|
||||
priority_queue_insert(&taskScheduler, &m_taskTimeout, cachedTime + rak::timer::from_seconds(m_timeout + 5));
|
||||
}
|
||||
@@ -91,9 +91,13 @@ CurlGet::start() {
|
||||
curl_easy_setopt(m_handle, CURLOPT_NOSIGNAL, (long)1);
|
||||
curl_easy_setopt(m_handle, CURLOPT_FOLLOWLOCATION, (long)1);
|
||||
curl_easy_setopt(m_handle, CURLOPT_MAXREDIRS, (long)5);
|
||||
curl_easy_setopt(m_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
|
||||
|
||||
curl_easy_setopt(m_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_WHATEVER);
|
||||
|
||||
curl_easy_setopt(m_handle, CURLOPT_ENCODING, "");
|
||||
|
||||
m_ipv6 = false;
|
||||
|
||||
m_stack->add_get(this);
|
||||
}
|
||||
|
||||
@@ -110,6 +114,17 @@ CurlGet::close() {
|
||||
m_handle = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
CurlGet::retry_ipv6() {
|
||||
CURL* nhandle = curl_easy_duphandle(m_handle);
|
||||
|
||||
curl_easy_setopt(nhandle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6);
|
||||
curl_easy_cleanup(m_handle);
|
||||
|
||||
m_handle = nhandle;
|
||||
m_ipv6 = true;
|
||||
}
|
||||
|
||||
void
|
||||
CurlGet::receive_timeout() {
|
||||
return m_stack->transfer_done(m_handle, "Timed out");
|
||||
|
||||
@@ -58,6 +58,9 @@ public:
|
||||
void start();
|
||||
void close();
|
||||
|
||||
bool is_using_ipv6() { return m_ipv6; }
|
||||
void retry_ipv6();
|
||||
|
||||
bool is_busy() const { return m_handle; }
|
||||
bool is_active() const { return m_active; }
|
||||
|
||||
@@ -75,6 +78,7 @@ private:
|
||||
void receive_timeout();
|
||||
|
||||
bool m_active;
|
||||
bool m_ipv6;
|
||||
|
||||
rak::priority_item m_taskTimeout;
|
||||
|
||||
|
||||
+21
-4
@@ -51,10 +51,11 @@ CurlStack::CurlStack() :
|
||||
m_handle((void*)curl_multi_init()),
|
||||
m_active(0),
|
||||
m_maxActive(32),
|
||||
m_ssl_verify_host(true),
|
||||
m_ssl_verify_peer(true),
|
||||
m_dns_timeout(60) {
|
||||
|
||||
m_taskTimeout.slot() = std::tr1::bind(&CurlStack::receive_timeout, this);
|
||||
m_taskTimeout.slot() = std::bind(&CurlStack::receive_timeout, this);
|
||||
|
||||
#if (LIBCURL_VERSION_NUM >= 0x071000)
|
||||
curl_multi_setopt((CURLM*)m_handle, CURLMOPT_TIMERDATA, this);
|
||||
@@ -131,8 +132,23 @@ CurlStack::process_done_handle() {
|
||||
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));
|
||||
if (msg->data.result == CURLE_COULDNT_RESOLVE_HOST) {
|
||||
iterator itr = std::find_if(begin(), end(), rak::equal(msg->easy_handle, std::mem_fun(&CurlGet::handle)));
|
||||
|
||||
if (itr == end())
|
||||
throw torrent::internal_error("Could not find CurlGet when calling CurlStack::receive_action.");
|
||||
|
||||
if (!(*itr)->is_using_ipv6()) {
|
||||
(*itr)->retry_ipv6();
|
||||
|
||||
if (curl_multi_add_handle((CURLM*)m_handle, (*itr)->handle()) > 0)
|
||||
throw torrent::internal_error("Error calling curl_multi_add_handle.");
|
||||
}
|
||||
|
||||
} else {
|
||||
transfer_done(msg->easy_handle,
|
||||
msg->data.result == CURLE_OK ? NULL : curl_easy_strerror(msg->data.result));
|
||||
}
|
||||
|
||||
return remaining_msgs != 0;
|
||||
}
|
||||
@@ -180,7 +196,8 @@ CurlStack::add_get(CurlGet* get) {
|
||||
if (!m_httpCaCert.empty())
|
||||
curl_easy_setopt(get->handle(), CURLOPT_CAINFO, m_httpCaCert.c_str());
|
||||
|
||||
curl_easy_setopt(get->handle(), CURLOPT_SSL_VERIFYPEER, (long)m_ssl_verify_peer);
|
||||
curl_easy_setopt(get->handle(), CURLOPT_SSL_VERIFYHOST, (long)(m_ssl_verify_host ? 2 : 0));
|
||||
curl_easy_setopt(get->handle(), CURLOPT_SSL_VERIFYPEER, (long)(m_ssl_verify_peer ? 1 : 0));
|
||||
curl_easy_setopt(get->handle(), CURLOPT_DNS_CACHE_TIMEOUT, m_dns_timeout);
|
||||
|
||||
base_type::push_back(get);
|
||||
|
||||
@@ -100,7 +100,9 @@ class CurlStack : std::deque<CurlGet*> {
|
||||
void set_http_capath(const std::string& s) { m_httpCaPath = s; }
|
||||
void set_http_cacert(const std::string& s) { m_httpCaCert = s; }
|
||||
|
||||
bool ssl_verify_host() const { return m_ssl_verify_host; }
|
||||
bool ssl_verify_peer() const { return m_ssl_verify_peer; }
|
||||
void set_ssl_verify_host(bool s) { m_ssl_verify_host = s; }
|
||||
void set_ssl_verify_peer(bool s) { m_ssl_verify_peer = s; }
|
||||
|
||||
long dns_timeout() const { return m_dns_timeout; }
|
||||
@@ -140,6 +142,7 @@ class CurlStack : std::deque<CurlGet*> {
|
||||
std::string m_httpCaPath;
|
||||
std::string m_httpCaCert;
|
||||
|
||||
bool m_ssl_verify_host;
|
||||
bool m_ssl_verify_peer;
|
||||
long m_dns_timeout;
|
||||
};
|
||||
|
||||
+49
-37
@@ -54,6 +54,9 @@
|
||||
#include "download_store.h"
|
||||
#include "manager.h"
|
||||
|
||||
#define LT_LOG_THIS(log_fmt, ...) \
|
||||
lt_log_print_subsystem(torrent::LOG_DHT_MANAGER, "dht_manager", log_fmt, __VA_ARGS__);
|
||||
|
||||
namespace core {
|
||||
|
||||
const char* DhtManager::dht_settings[dht_settings_num] = { "disable", "off", "auto", "on" };
|
||||
@@ -65,69 +68,77 @@ DhtManager::~DhtManager() {
|
||||
|
||||
void
|
||||
DhtManager::load_dht_cache() {
|
||||
if (m_start == dht_disable || !control->core()->download_store()->is_enabled())
|
||||
if (m_start == dht_disable || !control->core()->download_store()->is_enabled()) {
|
||||
LT_LOG_THIS("ignoring cache file", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string cache_filename = control->core()->download_store()->path() + "rtorrent.dht_cache";
|
||||
std::fstream cache_stream(cache_filename.c_str(), std::ios::in | std::ios::binary);
|
||||
|
||||
torrent::Object cache = torrent::Object::create_map();
|
||||
std::fstream cache_file((control->core()->download_store()->path() + "rtorrent.dht_cache").c_str(), std::ios::in | std::ios::binary);
|
||||
|
||||
if (cache_file.is_open()) {
|
||||
cache_file >> cache;
|
||||
if (cache_stream.is_open()) {
|
||||
cache_stream >> cache;
|
||||
|
||||
// If the cache file is corrupted we will just discard it with an
|
||||
// error message.
|
||||
if (cache_file.fail()) {
|
||||
lt_log_print(torrent::LOG_DHT_WARN, "DHT cache file corrupted, discarding.");
|
||||
if (cache_stream.fail()) {
|
||||
LT_LOG_THIS("cache file corrupted, discarding (path:%s)", cache_filename.c_str());
|
||||
cache = torrent::Object::create_map();
|
||||
} else {
|
||||
LT_LOG_THIS("cache file read (path:%s)", cache_filename.c_str());
|
||||
}
|
||||
|
||||
} else {
|
||||
LT_LOG_THIS("could not open cache file (path:%s)", cache_filename.c_str());
|
||||
}
|
||||
|
||||
try {
|
||||
torrent::dht_manager()->initialize(cache);
|
||||
torrent::dht_manager()->initialize(cache);
|
||||
|
||||
if (m_start == dht_on)
|
||||
start_dht();
|
||||
|
||||
} catch (torrent::local_error& e) {
|
||||
lt_log_print(torrent::LOG_DHT_WARN, "DHT failed: %s", e.what());
|
||||
}
|
||||
if (m_start == dht_on)
|
||||
start_dht();
|
||||
}
|
||||
|
||||
void
|
||||
DhtManager::start_dht() {
|
||||
priority_queue_erase(&taskScheduler, &m_stopTimeout);
|
||||
|
||||
if (!torrent::dht_manager()->is_valid() || torrent::dht_manager()->is_active())
|
||||
if (!torrent::dht_manager()->is_valid()) {
|
||||
LT_LOG_THIS("server start skipped, manager is uninitialized", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (torrent::dht_manager()->is_active()) {
|
||||
LT_LOG_THIS("server start skipped, already active", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
torrent::ThrottlePair throttles = control->core()->get_throttle(m_throttleName);
|
||||
torrent::dht_manager()->set_upload_throttle(throttles.first);
|
||||
torrent::dht_manager()->set_download_throttle(throttles.second);
|
||||
|
||||
int port = rpc::call_command_value("dht.port");
|
||||
|
||||
if (port <= 0)
|
||||
return;
|
||||
|
||||
lt_log_print(torrent::LOG_DHT_INFO, "Starting DHT server on port %d.", port);
|
||||
|
||||
try {
|
||||
torrent::dht_manager()->start(port);
|
||||
torrent::dht_manager()->reset_statistics();
|
||||
|
||||
m_updateTimeout.slot() = std::tr1::bind(&DhtManager::update, this);
|
||||
priority_queue_insert(&taskScheduler, &m_updateTimeout, (cachedTime + rak::timer::from_seconds(60)).round_seconds());
|
||||
|
||||
m_dhtPrevCycle = 0;
|
||||
m_dhtPrevQueriesSent = 0;
|
||||
m_dhtPrevRepliesReceived = 0;
|
||||
m_dhtPrevQueriesReceived = 0;
|
||||
m_dhtPrevBytesUp = 0;
|
||||
m_dhtPrevBytesDown = 0;
|
||||
|
||||
} catch (torrent::local_error& e) {
|
||||
lt_log_print(torrent::LOG_DHT_ERROR, "DHT start failed: %s", e.what());
|
||||
if (!torrent::dht_manager()->start(port)) {
|
||||
m_start = dht_off;
|
||||
return;
|
||||
}
|
||||
|
||||
torrent::dht_manager()->reset_statistics();
|
||||
|
||||
m_updateTimeout.slot() = std::bind(&DhtManager::update, this);
|
||||
priority_queue_insert(&taskScheduler, &m_updateTimeout, (cachedTime + rak::timer::from_seconds(60)).round_seconds());
|
||||
|
||||
m_dhtPrevCycle = 0;
|
||||
m_dhtPrevQueriesSent = 0;
|
||||
m_dhtPrevRepliesReceived = 0;
|
||||
m_dhtPrevQueriesReceived = 0;
|
||||
m_dhtPrevBytesUp = 0;
|
||||
m_dhtPrevBytesDown = 0;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -136,8 +147,9 @@ DhtManager::stop_dht() {
|
||||
priority_queue_erase(&taskScheduler, &m_stopTimeout);
|
||||
|
||||
if (torrent::dht_manager()->is_active()) {
|
||||
LT_LOG_THIS("stopping server", 0);
|
||||
|
||||
log_statistics(true);
|
||||
lt_log_print(torrent::LOG_DHT_INFO, "Stopping DHT server.");
|
||||
torrent::dht_manager()->stop();
|
||||
}
|
||||
}
|
||||
@@ -197,7 +209,7 @@ DhtManager::update() {
|
||||
break;
|
||||
|
||||
if (itr == end) {
|
||||
m_stopTimeout.slot() = std::tr1::bind(&DhtManager::stop_dht, this);
|
||||
m_stopTimeout.slot() = std::bind(&DhtManager::stop_dht, this);
|
||||
priority_queue_insert(&taskScheduler, &m_stopTimeout, (cachedTime + rak::timer::from_seconds(15 * 60)).round_seconds());
|
||||
}
|
||||
}
|
||||
@@ -219,7 +231,7 @@ DhtManager::log_statistics(bool force) {
|
||||
// We should have had clients ping us at least but have received
|
||||
// nothing, that means the UDP port is probably unreachable.
|
||||
if (torrent::dht_manager()->can_receive_queries())
|
||||
lt_log_print(torrent::LOG_DHT_WARN, "DHT port appears to be unreachable, no queries received.");
|
||||
LT_LOG_THIS("listening port appears to be unreachable, no queries received", 0);
|
||||
|
||||
torrent::dht_manager()->set_can_receive(false);
|
||||
}
|
||||
@@ -227,7 +239,7 @@ DhtManager::log_statistics(bool force) {
|
||||
if (stats.queries_sent - m_dhtPrevQueriesSent > stats.num_nodes * 2 + 20 && stats.replies_received == m_dhtPrevRepliesReceived) {
|
||||
// No replies to over 20 queries plus two per node we have. Probably firewalled.
|
||||
if (!m_warned)
|
||||
lt_log_print(torrent::LOG_DHT_WARN, "DHT port appears to be firewalled, no replies received.");
|
||||
LT_LOG_THIS("listening port appears to be firewalled, no replies received", 0);
|
||||
|
||||
m_warned = true;
|
||||
return false;
|
||||
|
||||
@@ -62,8 +62,8 @@ Download::Download(download_type d) :
|
||||
m_resumeFlags(~uint32_t()),
|
||||
m_group(0) {
|
||||
|
||||
m_download.info()->signal_tracker_success().push_back(tr1::bind(&Download::receive_tracker_msg, this, ""));
|
||||
m_download.info()->signal_tracker_failed().push_back(tr1::bind(&Download::receive_tracker_msg, this, tr1::placeholders::_1));
|
||||
m_download.info()->signal_tracker_success().push_back(std::bind(&Download::receive_tracker_msg, this, ""));
|
||||
m_download.info()->signal_tracker_failed().push_back(std::bind(&Download::receive_tracker_msg, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
Download::~Download() {
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <rak/path.h>
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
#include <torrent/utils/log.h>
|
||||
#include <torrent/utils/resume.h>
|
||||
#include <torrent/object.h>
|
||||
@@ -107,8 +107,8 @@ DownloadFactory::DownloadFactory(Manager* m) :
|
||||
m_printLog(true),
|
||||
m_isFile(false) {
|
||||
|
||||
m_taskLoad.slot() = std::tr1::bind(&DownloadFactory::receive_load, this);
|
||||
m_taskCommit.slot() = std::tr1::bind(&DownloadFactory::receive_commit, this);
|
||||
m_taskLoad.slot() = std::bind(&DownloadFactory::receive_load, this);
|
||||
m_taskCommit.slot() = std::bind(&DownloadFactory::receive_commit, this);
|
||||
|
||||
// m_variables["connection_leech"] = rpc::call_command("protocol.connection.leech");
|
||||
// m_variables["connection_seed"] = rpc::call_command("protocol.connection.seed");
|
||||
@@ -158,8 +158,8 @@ DownloadFactory::receive_load() {
|
||||
m_stream = new std::stringstream;
|
||||
HttpQueue::iterator itr = m_manager->http_queue()->insert(m_uri, m_stream);
|
||||
|
||||
(*itr)->signal_done().push_front(std::tr1::bind(&DownloadFactory::receive_loaded, this));
|
||||
(*itr)->signal_failed().push_front(std::tr1::bind(&DownloadFactory::receive_failed, this, std::tr1::placeholders::_1));
|
||||
(*itr)->signal_done().push_front(std::bind(&DownloadFactory::receive_loaded, this));
|
||||
(*itr)->signal_failed().push_front(std::bind(&DownloadFactory::receive_failed, this, std::placeholders::_1));
|
||||
|
||||
m_variables["tied_to_file"] = (int64_t)false;
|
||||
|
||||
@@ -418,6 +418,9 @@ DownloadFactory::initialize_rtorrent(Download* download, torrent::Object* rtorre
|
||||
if (rtorrent->has_key_value("total_uploaded"))
|
||||
download->info()->mutable_up_rate()->set_total(rtorrent->get_key_value("total_uploaded"));
|
||||
|
||||
if (rtorrent->has_key_value("total_downloaded"))
|
||||
download->info()->mutable_down_rate()->set_total(rtorrent->get_key_value("total_downloaded"));
|
||||
|
||||
if (rtorrent->has_key_value("chunks_done") && rtorrent->has_key_value("chunks_wanted"))
|
||||
download->download()->set_chunks_done(rtorrent->get_key_value("chunks_done"), rtorrent->get_key_value("chunks_wanted"));
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <iosfwd>
|
||||
#include <rak/priority_queue_default.h>
|
||||
#include <torrent/object.h>
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
|
||||
#include "http_queue.h"
|
||||
|
||||
@@ -54,7 +54,7 @@ class Manager;
|
||||
|
||||
class DownloadFactory {
|
||||
public:
|
||||
typedef std::tr1::function<void ()> slot_void;
|
||||
typedef std::function<void ()> slot_void;
|
||||
typedef std::vector<std::string> command_list_type;
|
||||
|
||||
// Do not destroy this object while it is in a HttpQueue.
|
||||
|
||||
@@ -180,8 +180,8 @@ DownloadList::insert(Download* download) {
|
||||
lt_log_print_info(torrent::LOG_TORRENT_INFO, download->info(), "download_list", "Inserting download.");
|
||||
|
||||
try {
|
||||
(*itr)->data()->slot_initial_hash() = tr1::bind(&DownloadList::hash_done, this, download);
|
||||
(*itr)->data()->slot_download_done() = tr1::bind(&DownloadList::received_finished, this, download);
|
||||
(*itr)->data()->slot_initial_hash() = std::bind(&DownloadList::hash_done, this, download);
|
||||
(*itr)->data()->slot_download_done() = std::bind(&DownloadList::received_finished, this, download);
|
||||
|
||||
// This needs to be separated into two different calls to ensure
|
||||
// the download remains in the view.
|
||||
|
||||
@@ -39,15 +39,15 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
|
||||
#include "download.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
class DownloadSlotMap : public std::map<std::string, std::tr1::function<void (Download*)> > {
|
||||
class DownloadSlotMap : public std::map<std::string, std::function<void (Download*)> > {
|
||||
public:
|
||||
typedef std::tr1::function<void (Download*)> slot_download;
|
||||
typedef std::function<void (Download*)> slot_download;
|
||||
typedef std::map<std::string, slot_download> Base;
|
||||
|
||||
void insert(const std::string& key, slot_download s) { Base::operator[](key) = s; }
|
||||
|
||||
@@ -140,6 +140,7 @@ DownloadStore::save(Download* d, int flags) {
|
||||
rtorrent_base->insert_key("chunks_done", d->download()->file_list()->completed_chunks());
|
||||
rtorrent_base->insert_key("chunks_wanted", d->download()->data()->wanted_chunks());
|
||||
rtorrent_base->insert_key("total_uploaded", d->info()->up_rate()->total());
|
||||
rtorrent_base->insert_key("total_downloaded", d->info()->down_rate()->total());
|
||||
|
||||
// Don't save for completed torrents when we've cleared the uncertain_pieces.
|
||||
torrent::resume_save_progress(*d->download(), *resume_base);
|
||||
|
||||
@@ -56,8 +56,8 @@ HttpQueue::insert(const std::string& url, std::iostream* s) {
|
||||
|
||||
iterator signal_itr = base_type::insert(end(), h.get());
|
||||
|
||||
h->signal_done().push_back(std::tr1::bind(&HttpQueue::erase, this, signal_itr));
|
||||
h->signal_failed().push_back(std::tr1::bind(&HttpQueue::erase, this, signal_itr));
|
||||
h->signal_done().push_back(std::bind(&HttpQueue::erase, this, signal_itr));
|
||||
h->signal_failed().push_back(std::bind(&HttpQueue::erase, this, signal_itr));
|
||||
|
||||
(*signal_itr)->start();
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
#include <list>
|
||||
#include <iosfwd>
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
|
||||
namespace core {
|
||||
|
||||
@@ -48,8 +48,8 @@ class CurlGet;
|
||||
class HttpQueue : private std::list<CurlGet*> {
|
||||
public:
|
||||
typedef std::list<CurlGet*> base_type;
|
||||
typedef std::tr1::function<CurlGet* ()> slot_factory;
|
||||
typedef std::tr1::function<void (CurlGet*)> slot_curl_get;
|
||||
typedef std::function<CurlGet* ()> slot_factory;
|
||||
typedef std::function<void (CurlGet*)> slot_curl_get;
|
||||
typedef std::list<slot_curl_get> signal_curl_get;
|
||||
|
||||
using base_type::iterator;
|
||||
|
||||
+16
-9
@@ -74,6 +74,11 @@
|
||||
|
||||
namespace core {
|
||||
|
||||
const int Manager::create_start;
|
||||
const int Manager::create_tied;
|
||||
const int Manager::create_quiet;
|
||||
const int Manager::create_raw_data;
|
||||
|
||||
void
|
||||
Manager::push_log(const char* msg) {
|
||||
m_log_important->lock_and_push_log(msg, strlen(msg), 0);
|
||||
@@ -113,7 +118,7 @@ Manager::set_hashing_view(View* v) {
|
||||
throw torrent::internal_error("Manager::set_hashing_view(...) received NULL or is already set.");
|
||||
|
||||
m_hashingView = v;
|
||||
m_hashingView->signal_changed().push_back(std::tr1::bind(&Manager::receive_hashing_changed, this));
|
||||
m_hashingView->signal_changed().push_back(std::bind(&Manager::receive_hashing_changed, this));
|
||||
}
|
||||
|
||||
torrent::ThrottlePair
|
||||
@@ -133,7 +138,7 @@ Manager::get_throttle(const std::string& name) {
|
||||
void
|
||||
Manager::set_address_throttle(uint32_t begin, uint32_t end, torrent::ThrottlePair throttles) {
|
||||
m_addressThrottles.set_merge(begin, end, throttles);
|
||||
torrent::connection_manager()->address_throttle() = tr1::bind(&core::Manager::get_address_throttle, control->core(), tr1::placeholders::_1);
|
||||
torrent::connection_manager()->address_throttle() = std::bind(&core::Manager::get_address_throttle, control->core(), std::placeholders::_1);
|
||||
}
|
||||
|
||||
torrent::ThrottlePair
|
||||
@@ -144,8 +149,8 @@ Manager::get_address_throttle(const sockaddr* addr) {
|
||||
// Most of this should be possible to move out.
|
||||
void
|
||||
Manager::initialize_second() {
|
||||
torrent::Http::slot_factory() = std::tr1::bind(&CurlStack::new_object, m_httpStack);
|
||||
m_httpQueue->set_slot_factory(std::tr1::bind(&CurlStack::new_object, m_httpStack));
|
||||
torrent::Http::slot_factory() = std::bind(&CurlStack::new_object, m_httpStack);
|
||||
m_httpQueue->set_slot_factory(std::bind(&CurlStack::new_object, m_httpStack));
|
||||
|
||||
CurlStack::global_init();
|
||||
}
|
||||
@@ -223,7 +228,8 @@ Manager::set_bind_address(const std::string& addr) {
|
||||
int err;
|
||||
rak::address_info* ai;
|
||||
|
||||
if ((err = rak::address_info::get_address_info(addr.c_str(), PF_INET, SOCK_STREAM, &ai)) != 0)
|
||||
if ((err = rak::address_info::get_address_info(addr.c_str(), PF_INET, SOCK_STREAM, &ai)) != 0 &&
|
||||
(err = rak::address_info::get_address_info(addr.c_str(), PF_INET6, SOCK_STREAM, &ai)) != 0)
|
||||
throw torrent::input_error("Could not set bind address: " + std::string(rak::address_info::strerror(err)) + ".");
|
||||
|
||||
try {
|
||||
@@ -257,7 +263,8 @@ Manager::set_local_address(const std::string& addr) {
|
||||
int err;
|
||||
rak::address_info* ai;
|
||||
|
||||
if ((err = rak::address_info::get_address_info(addr.c_str(), PF_INET, SOCK_STREAM, &ai)) != 0)
|
||||
if ((err = rak::address_info::get_address_info(addr.c_str(), PF_INET, SOCK_STREAM, &ai)) != 0 &&
|
||||
(err = rak::address_info::get_address_info(addr.c_str(), PF_INET6, SOCK_STREAM, &ai)) != 0)
|
||||
throw torrent::input_error("Could not set local address: " + std::string(rak::address_info::strerror(err)) + ".");
|
||||
|
||||
try {
|
||||
@@ -330,7 +337,7 @@ Manager::try_create_download(const std::string& uri, int flags, const command_li
|
||||
|
||||
f->set_start(flags & create_start);
|
||||
f->set_print_log(!(flags & create_quiet));
|
||||
f->slot_finished(std::tr1::bind(&rak::call_delete_func<core::DownloadFactory>, f));
|
||||
f->slot_finished(std::bind(&rak::call_delete_func<core::DownloadFactory>, f));
|
||||
|
||||
if (flags & create_raw_data)
|
||||
f->load_raw_data(uri);
|
||||
@@ -354,7 +361,7 @@ Manager::try_create_download_from_meta_download(torrent::Object* bencode, const
|
||||
|
||||
f->set_start(meta.get_key_value("start"));
|
||||
f->set_print_log(meta.get_key_value("print_log"));
|
||||
f->slot_finished(std::tr1::bind(&rak::call_delete_func<core::DownloadFactory>, f));
|
||||
f->slot_finished(std::bind(&rak::call_delete_func<core::DownloadFactory>, f));
|
||||
|
||||
// Bit of a waste to create the bencode repesentation here
|
||||
// only to have the DownloadFactory decode it.
|
||||
@@ -409,7 +416,7 @@ path_expand(std::vector<std::string>* paths, const std::string& pattern) {
|
||||
itr->update((r.pattern()[0] != '.') ? utils::Directory::update_hide_dot : 0);
|
||||
itr->erase(std::remove_if(itr->begin(), itr->end(), rak::on(rak::mem_ref(&utils::directory_entry::d_name), std::not1(r))), itr->end());
|
||||
|
||||
std::transform(itr->begin(), itr->end(), std::back_inserter(nextCache), rak::bind1st(std::ptr_fun(&path_expand_transform), itr->path() + "/"));
|
||||
std::transform(itr->begin(), itr->end(), std::back_inserter(nextCache), rak::bind1st(std::ptr_fun(&path_expand_transform), itr->path() + (itr->path() == "/" ? "" : "/")));
|
||||
}
|
||||
|
||||
currentCache.clear();
|
||||
|
||||
+2
-2
@@ -69,8 +69,8 @@ public:
|
||||
typedef DownloadList::iterator DListItr;
|
||||
typedef utils::FileStatusCache FileStatusCache;
|
||||
|
||||
// typedef std::tr1::function<void (DownloadList::iterator)> slot_ready;
|
||||
// typedef std::tr1::function<void ()> slot_void;
|
||||
// typedef std::function<void (DownloadList::iterator)> slot_ready;
|
||||
// typedef std::function<void ()> slot_void;
|
||||
|
||||
Manager();
|
||||
~Manager();
|
||||
|
||||
+7
-3
@@ -177,7 +177,7 @@ View::initialize(const std::string& name) {
|
||||
m_focus = 0;
|
||||
|
||||
set_last_changed(rak::timer());
|
||||
m_delayChanged.slot() = std::tr1::bind(&View::emit_changed_now, this);
|
||||
m_delayChanged.slot() = std::bind(&View::emit_changed_now, this);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -257,6 +257,10 @@ View::sort() {
|
||||
|
||||
void
|
||||
View::filter() {
|
||||
// Do NOT allow filter STARTED and STOPPED views: they are special
|
||||
if (m_name == "started" || m_name == "stopped")
|
||||
return;
|
||||
|
||||
// Parition the list in two steps so we know which elements changed.
|
||||
iterator splitVisible = std::stable_partition(begin_visible(), end_visible(), view_downloads_filter(m_filter));
|
||||
iterator splitFiltered = std::stable_partition(begin_filtered(), end_filtered(), view_downloads_filter(m_filter));
|
||||
@@ -282,11 +286,11 @@ View::filter() {
|
||||
// perhaps always clear them, thus not throwing anything.
|
||||
if (!m_event_removed.is_empty())
|
||||
std::for_each(changed.begin(), splitChanged,
|
||||
tr1::bind(&rpc::call_object_d_nothrow, m_event_removed, tr1::placeholders::_1));
|
||||
std::bind(&rpc::call_object_d_nothrow, m_event_removed, std::placeholders::_1));
|
||||
|
||||
if (!m_event_added.is_empty())
|
||||
std::for_each(changed.begin(), splitChanged,
|
||||
tr1::bind(&rpc::call_object_d_nothrow, m_event_added, tr1::placeholders::_1));
|
||||
std::bind(&rpc::call_object_d_nothrow, m_event_added, std::placeholders::_1));
|
||||
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@
|
||||
#include <vector>
|
||||
#include <rak/timer.h>
|
||||
#include <torrent/object.h>
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
@@ -64,7 +64,7 @@ class Download;
|
||||
class View : private std::vector<Download*> {
|
||||
public:
|
||||
typedef std::vector<Download*> base_type;
|
||||
typedef std::tr1::function<void ()> slot_void;
|
||||
typedef std::function<void ()> slot_void;
|
||||
typedef std::list<slot_void> signal_void;
|
||||
|
||||
using base_type::iterator;
|
||||
|
||||
+56
-40
@@ -5,12 +5,12 @@
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@@ -41,90 +41,106 @@
|
||||
#include <termios.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
#include "rpc/parse_commands.h"
|
||||
|
||||
#include "canvas.h"
|
||||
|
||||
namespace display {
|
||||
|
||||
bool Canvas::m_isInitialized = false;
|
||||
bool Canvas::m_isDaemon = false;
|
||||
|
||||
Canvas::Canvas(int x, int y, int width, int height) :
|
||||
m_window(newwin(height, width, y, x)) {
|
||||
Canvas::Canvas(int x, int y, int width, int height) {
|
||||
if (!m_isDaemon) {
|
||||
m_window = newwin(height, width, y, x);
|
||||
|
||||
if (m_window == NULL)
|
||||
throw torrent::internal_error("Could not allocate ncurses canvas.");
|
||||
if (m_window == NULL)
|
||||
throw torrent::internal_error("Could not allocate ncurses canvas.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Canvas::resize(int x, int y, int w, int h) {
|
||||
wresize(m_window, h, w);
|
||||
mvwin(m_window, y, x);
|
||||
if (!m_isDaemon) {
|
||||
wresize(m_window, h, w);
|
||||
mvwin(m_window, y, x);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Canvas::print_attributes(unsigned int x, unsigned int y, const char* first, const char* last, const attributes_list* attributes) {
|
||||
move(x, y);
|
||||
if (!m_isDaemon) {
|
||||
move(x, y);
|
||||
|
||||
attr_t org_attr;
|
||||
short org_pair;
|
||||
wattr_get(m_window, &org_attr, &org_pair, NULL);
|
||||
attr_t org_attr;
|
||||
short org_pair;
|
||||
wattr_get(m_window, &org_attr, &org_pair, NULL);
|
||||
|
||||
attributes_list::const_iterator attrItr = attributes->begin();
|
||||
wattr_set(m_window, Attributes::a_normal, Attributes::color_default, NULL);
|
||||
attributes_list::const_iterator attrItr = attributes->begin();
|
||||
wattr_set(m_window, Attributes::a_normal, Attributes::color_default, NULL);
|
||||
|
||||
while (first != last) {
|
||||
const char* next = last;
|
||||
while (first != last) {
|
||||
const char* next = last;
|
||||
|
||||
if (attrItr != attributes->end()) {
|
||||
next = attrItr->position();
|
||||
if (attrItr != attributes->end()) {
|
||||
next = attrItr->position();
|
||||
|
||||
if (first >= next) {
|
||||
wattr_set(m_window, attrItr->attributes(), attrItr->colors(), NULL);
|
||||
++attrItr;
|
||||
if (first >= next) {
|
||||
wattr_set(m_window, attrItr->attributes(), attrItr->colors(), NULL);
|
||||
++attrItr;
|
||||
}
|
||||
}
|
||||
|
||||
print("%.*s", next - first, first);
|
||||
first = next;
|
||||
}
|
||||
|
||||
print("%.*s", next - first, first);
|
||||
first = next;
|
||||
// Reset the color.
|
||||
wattr_set(m_window, org_attr, org_pair, NULL);
|
||||
}
|
||||
|
||||
// Reset the color.
|
||||
wattr_set(m_window, org_attr, org_pair, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
Canvas::initialize() {
|
||||
if (m_isInitialized)
|
||||
return;
|
||||
|
||||
|
||||
m_isDaemon = rpc::call_command_value("system.daemon");
|
||||
|
||||
m_isInitialized = true;
|
||||
|
||||
initscr();
|
||||
raw();
|
||||
noecho();
|
||||
nodelay(stdscr, TRUE);
|
||||
keypad(stdscr, TRUE);
|
||||
curs_set(0);
|
||||
if (!m_isDaemon) {
|
||||
initscr();
|
||||
raw();
|
||||
noecho();
|
||||
nodelay(stdscr, TRUE);
|
||||
keypad(stdscr, TRUE);
|
||||
curs_set(0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Canvas::cleanup() {
|
||||
if (!m_isInitialized)
|
||||
return;
|
||||
|
||||
|
||||
m_isInitialized = false;
|
||||
|
||||
noraw();
|
||||
endwin();
|
||||
if (!m_isDaemon) {
|
||||
noraw();
|
||||
endwin();
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<int, int>
|
||||
Canvas::term_size() {
|
||||
struct winsize ws;
|
||||
|
||||
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == 0)
|
||||
return std::pair<int, int>(ws.ws_col, ws.ws_row);
|
||||
else
|
||||
return std::pair<int, int>(80, 24);
|
||||
if (!m_isDaemon) {
|
||||
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == 0)
|
||||
return std::pair<int, int>(ws.ws_col, ws.ws_row);
|
||||
}
|
||||
return std::pair<int, int>(80, 24);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+41
-34
@@ -5,12 +5,12 @@
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
@@ -49,37 +49,37 @@ public:
|
||||
typedef std::vector<Attributes> attributes_list;
|
||||
|
||||
Canvas(int x = 0, int y = 0, int width = 0, int height = 0);
|
||||
~Canvas() { delwin(m_window); }
|
||||
~Canvas() { if (!m_isDaemon) { delwin(m_window); } }
|
||||
|
||||
void refresh() { wnoutrefresh(m_window); }
|
||||
static void refresh_std() { wnoutrefresh(stdscr); }
|
||||
void redraw() { redrawwin(m_window); }
|
||||
static void redraw_std() { redrawwin(stdscr); }
|
||||
void refresh() { if (!m_isDaemon) { wnoutrefresh(m_window); } }
|
||||
static void refresh_std() { if (!m_isDaemon) { wnoutrefresh(stdscr); } }
|
||||
void redraw() { if (!m_isDaemon) { redrawwin(m_window); } }
|
||||
static void redraw_std() { if (!m_isDaemon) { redrawwin(stdscr); } }
|
||||
|
||||
void resize(int w, int h) { wresize(m_window, h, w); }
|
||||
void resize(int w, int h) { if (!m_isDaemon) { wresize(m_window, h, w); } }
|
||||
void resize(int x, int y, int w, int h);
|
||||
|
||||
static void resize_term(int x, int y) { resizeterm(y, x); }
|
||||
static void resize_term(std::pair<int, int> dim) { resizeterm(dim.second, dim.first); }
|
||||
static void resize_term(int x, int y) { if (!m_isDaemon) { resizeterm(y, x); } }
|
||||
static void resize_term(std::pair<int, int> dim) { if (!m_isDaemon) { resizeterm(dim.second, dim.first); } }
|
||||
|
||||
unsigned int get_x() { int x, __UNUSED y; getyx(m_window, y, x); return x; }
|
||||
unsigned int get_y() { int x, y; getyx(m_window, y, x); return y; }
|
||||
unsigned int get_x() { int x, __UNUSED y; if (!m_isDaemon) { getyx(m_window, y, x); } else { x=1; } return x; }
|
||||
unsigned int get_y() { int x, y; if (!m_isDaemon) { getyx(m_window, y, x); } else { y=1; } return y; }
|
||||
|
||||
unsigned int width() { int x, __UNUSED y; getmaxyx(m_window, y, x); return x; }
|
||||
unsigned int height() { int x, y; getmaxyx(m_window, y, x); return y; }
|
||||
unsigned int width() { int x, __UNUSED y; if (!m_isDaemon) { getmaxyx(m_window, y, x); } else { x=80; } return x; }
|
||||
unsigned int height() { int x, y; if (!m_isDaemon) { getmaxyx(m_window, y, x); } else { y=24; } return y; }
|
||||
|
||||
void move(unsigned int x, unsigned int y) { wmove(m_window, y, x); }
|
||||
void move(unsigned int x, unsigned int y) { if (!m_isDaemon) { wmove(m_window, y, x); } }
|
||||
|
||||
chtype get_background() { return getbkgd(m_window); }
|
||||
void set_background(chtype c) { return wbkgdset(m_window, c); }
|
||||
chtype get_background() { chtype bg=0; if (!m_isDaemon) { bg=getbkgd(m_window); } return bg; }
|
||||
void set_background(chtype c) { if (!m_isDaemon) { return wbkgdset(m_window, c); } }
|
||||
|
||||
void erase() { werase(m_window); }
|
||||
static void erase_std() { werase(stdscr); }
|
||||
void erase() { if (!m_isDaemon) { werase(m_window); } }
|
||||
static void erase_std() { if (!m_isDaemon) { werase(stdscr); } }
|
||||
|
||||
void print_border(chtype ls, chtype rs,
|
||||
chtype ts, chtype bs,
|
||||
chtype tl, chtype tr,
|
||||
chtype bl, chtype br) { wborder(m_window, ls, rs, ts, bs, tl, tr, bl, br); }
|
||||
chtype bl, chtype br) { if (!m_isDaemon) { wborder(m_window, ls, rs, ts, bs, tl, tr, bl, br); } }
|
||||
|
||||
// The format string is non-const, but that will not be a problem
|
||||
// since the string shall always be a C string choosen at
|
||||
@@ -90,29 +90,32 @@ public:
|
||||
|
||||
void print_attributes(unsigned int x, unsigned int y, const char* first, const char* last, const attributes_list* attributes);
|
||||
|
||||
void print_char(const chtype ch) { waddch(m_window, ch); }
|
||||
void print_char(unsigned int x, unsigned int y, const chtype ch) { mvwaddch(m_window, y, x, ch); }
|
||||
void print_char(const chtype ch) { if (!m_isDaemon) { waddch(m_window, ch); } }
|
||||
void print_char(unsigned int x, unsigned int y, const chtype ch) { if (!m_isDaemon) { mvwaddch(m_window, y, x, ch); } }
|
||||
|
||||
void set_attr(unsigned int x, unsigned int y, unsigned int n, int attr, int color) { mvwchgat(m_window, y, x, n, attr, color, NULL); }
|
||||
void set_attr(unsigned int x, unsigned int y, unsigned int n, int attr, int color) { if (!m_isDaemon) { mvwchgat(m_window, y, x, n, attr, color, NULL); } }
|
||||
|
||||
void set_default_attributes(int attr) { (void)wattrset(m_window, attr); }
|
||||
void set_default_attributes(int attr) { if (!m_isDaemon) { (void)wattrset(m_window, attr); } }
|
||||
|
||||
// Initialize stdscr.
|
||||
static void initialize();
|
||||
static void cleanup();
|
||||
|
||||
static int get_screen_width() { int x, __UNUSED y; getmaxyx(stdscr, y, x); return x; }
|
||||
static int get_screen_height() { int x, y; getmaxyx(stdscr, y, x); return y; }
|
||||
static int get_screen_width() { int x, __UNUSED y; if (!m_isDaemon) { getmaxyx(stdscr, y, x); } else { x=80; } return x; }
|
||||
static int get_screen_height() { int x, y; if (!m_isDaemon) { getmaxyx(stdscr, y, x); } else { y=24;} return y; }
|
||||
|
||||
static std::pair<int, int> term_size();
|
||||
|
||||
static void do_update() { doupdate(); }
|
||||
static void do_update() { if (!m_isDaemon) { doupdate(); } }
|
||||
|
||||
static bool daemon() { return m_isDaemon; }
|
||||
|
||||
private:
|
||||
Canvas(const Canvas&);
|
||||
void operator = (const Canvas&);
|
||||
|
||||
static bool m_isInitialized;
|
||||
static bool m_isDaemon;
|
||||
|
||||
WINDOW* m_window;
|
||||
};
|
||||
@@ -121,19 +124,23 @@ inline void
|
||||
Canvas::print(const char* str, ...) {
|
||||
va_list arglist;
|
||||
|
||||
va_start(arglist, str);
|
||||
vw_printw(m_window, const_cast<char*>(str), arglist);
|
||||
va_end(arglist);
|
||||
if (!m_isDaemon) {
|
||||
va_start(arglist, str);
|
||||
vw_printw(m_window, const_cast<char*>(str), arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
Canvas::print(unsigned int x, unsigned int y, const char* str, ...) {
|
||||
va_list arglist;
|
||||
|
||||
va_start(arglist, str);
|
||||
wmove(m_window, y, x);
|
||||
vw_printw(m_window, const_cast<char*>(str), arglist);
|
||||
va_end(arglist);
|
||||
if (!m_isDaemon) {
|
||||
va_start(arglist, str);
|
||||
wmove(m_window, y, x);
|
||||
vw_printw(m_window, const_cast<char*>(str), arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
#include <rak/algorithm.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
@@ -367,9 +367,9 @@ Frame::balance_row(uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
|
||||
//
|
||||
// Else if we're short, only give each what they require.
|
||||
std::stable_sort(dynamicFrames, dynamicFrames + dynamicSize,
|
||||
std::tr1::bind(std::greater<extent_type>(),
|
||||
std::tr1::bind(&dynamic_min_height, std::tr1::placeholders::_1),
|
||||
std::tr1::bind(&dynamic_min_height, std::tr1::placeholders::_2)));
|
||||
std::bind(std::greater<extent_type>(),
|
||||
std::bind(&dynamic_min_height, std::placeholders::_1),
|
||||
std::bind(&dynamic_min_height, std::placeholders::_2)));
|
||||
|
||||
bool retry;
|
||||
|
||||
@@ -442,9 +442,9 @@ Frame::balance_column(uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
|
||||
//
|
||||
// Else if we're short, only give each what they require.
|
||||
std::stable_sort(dynamicFrames, dynamicFrames + dynamicSize,
|
||||
std::tr1::bind(std::greater<extent_type>(),
|
||||
std::tr1::bind(&dynamic_min_width, std::tr1::placeholders::_1),
|
||||
std::tr1::bind(&dynamic_min_width, std::tr1::placeholders::_2)));
|
||||
std::bind(std::greater<extent_type>(),
|
||||
std::bind(&dynamic_min_width, std::placeholders::_1),
|
||||
std::bind(&dynamic_min_width, std::placeholders::_2)));
|
||||
|
||||
bool retry;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace display {
|
||||
Manager::Manager() :
|
||||
m_forceRedraw(false) {
|
||||
|
||||
m_taskUpdate.slot() = std::tr1::bind(&Manager::receive_update, this);
|
||||
m_taskUpdate.slot() = std::bind(&Manager::receive_update, this);
|
||||
}
|
||||
|
||||
Manager::~Manager() {
|
||||
|
||||
+64
-2
@@ -133,7 +133,7 @@ print_download_title(char* first, char* last, core::Download* d) {
|
||||
}
|
||||
|
||||
char*
|
||||
print_download_info(char* first, char* last, core::Download* d) {
|
||||
print_download_info_full(char* first, char* last, core::Download* d) {
|
||||
if (!d->download()->info()->is_open())
|
||||
first = print_buffer(first, last, "[CLOSED] ");
|
||||
else if (!d->download()->info()->is_active())
|
||||
@@ -177,7 +177,7 @@ print_download_info(char* first, char* last, core::Download* d) {
|
||||
first = print_buffer(first, last , "]");
|
||||
|
||||
if (first > last)
|
||||
throw torrent::internal_error("print_download_info(...) wrote past end of the buffer.");
|
||||
throw torrent::internal_error("print_download_info_full(...) wrote past end of the buffer.");
|
||||
|
||||
return first;
|
||||
}
|
||||
@@ -218,6 +218,68 @@ print_download_status(char* first, char* last, core::Download* d) {
|
||||
return first;
|
||||
}
|
||||
|
||||
char*
|
||||
print_download_column_compact(char* first, char* last) {
|
||||
first = print_buffer(first, last, " %-64.64s", "Name");
|
||||
first = print_buffer(first, last, "| Status | Downloaded | Size | Done | Up Rate | Down Rate | Uploaded | ETA | Ratio| Misc ");
|
||||
|
||||
if (first > last)
|
||||
throw torrent::internal_error("print_download_column_compact(...) wrote past end of the buffer.");
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
char*
|
||||
print_download_info_compact(char* first, char* last, core::Download* d) {
|
||||
first = print_buffer(first, last, " %-64.64s", d->info()->name().c_str());
|
||||
first = print_buffer(first, last, "|");
|
||||
|
||||
if (!d->download()->info()->is_open())
|
||||
first = print_buffer(first, last, " CLOSED ");
|
||||
else if (!d->download()->info()->is_active())
|
||||
first = print_buffer(first, last, " OPEN ");
|
||||
else
|
||||
first = print_buffer(first, last, " ");
|
||||
|
||||
first = print_buffer(first, last, "| %7.1f MB ", (double)d->download()->bytes_done() / (double)(1 << 20));
|
||||
first = print_buffer(first, last, "| %7.1f MB ", (double)d->download()->file_list()->size_bytes() / (double)(1 << 20));
|
||||
first = print_buffer(first, last, "|");
|
||||
|
||||
if (d->is_done())
|
||||
first = print_buffer(first, last, " 100%% ");
|
||||
else if (d->is_open())
|
||||
first = print_buffer(first, last, " %2u%% ",(d->download()->file_list()->completed_chunks() * 100) / d->download()->file_list()->size_chunks());
|
||||
else
|
||||
first = print_buffer(first, last, " ");
|
||||
|
||||
first = print_buffer(first, last, "| %6.1f KB ", (double)d->info()->up_rate()->rate() / (1 << 10));
|
||||
first = print_buffer(first, last, "| %6.1f KB ", (double)d->info()->down_rate()->rate() / (1 << 10));
|
||||
first = print_buffer(first, last, "| %7.1f MB ", (double)d->info()->up_rate()->total() / (1 << 20));
|
||||
first = print_buffer(first, last, "| ");
|
||||
|
||||
if (d->download()->info()->is_active() && !d->is_done())
|
||||
first = print_download_time_left(first, last, d);
|
||||
else
|
||||
first = print_buffer(first, last, " ");
|
||||
|
||||
first = print_buffer(first, last, "| %4.2f ", (double)rpc::call_command_value("d.ratio", rpc::make_target(d)) / 1000.0);
|
||||
first = print_buffer(first, last, "| %c%c",
|
||||
rpc::call_command_string("d.tied_to_file", rpc::make_target(d)).empty() ? ' ' : 'T',
|
||||
rpc::call_command_value("d.ignore_commands", rpc::make_target(d)) == 0 ? ' ' : 'I',
|
||||
(double)rpc::call_command_value("d.ratio", rpc::make_target(d)) / 1000.0);
|
||||
|
||||
if (d->priority() != 2)
|
||||
first = print_buffer(first, last, " %s", rpc::call_command_string("d.priority_str", rpc::make_target(d)).c_str());
|
||||
|
||||
if (!d->bencode()->get_key("rtorrent").get_key_string("throttle_name").empty())
|
||||
first = print_buffer(first, last , " %s", rpc::call_command_string("d.throttle_name", rpc::make_target(d)).c_str());
|
||||
|
||||
if (first > last)
|
||||
throw torrent::internal_error("print_download_info_compact(...) wrote past end of the buffer.");
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
char*
|
||||
print_download_time_left(char* first, char* last, core::Download* d) {
|
||||
uint32_t rate = d->info()->down_rate()->rate();
|
||||
|
||||
+5
-1
@@ -66,8 +66,12 @@ char* print_ddhhmm(char* first, char* last, time_t t);
|
||||
char* print_ddmmyyyy(char* first, char* last, time_t t);
|
||||
|
||||
char* print_download_title(char* first, char* last, core::Download* d);
|
||||
char* print_download_info(char* first, char* last, core::Download* d);
|
||||
char* print_download_info_full(char* first, char* last, core::Download* d);
|
||||
char* print_download_status(char* first, char* last, core::Download* d);
|
||||
|
||||
char* print_download_column_compact(char* first, char* last);
|
||||
char* print_download_info_compact(char* first, char* last, core::Download* d);
|
||||
|
||||
char* print_download_time_left(char* first, char* last, core::Download* d);
|
||||
char* print_download_percentage_done(char* first, char* last, core::Download* d);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ Window::Window(Canvas* canvas, int flags, extent_type minWidth, extent_type minH
|
||||
m_maxWidth(maxWidth),
|
||||
m_maxHeight(maxHeight) {
|
||||
|
||||
m_taskUpdate.slot() = std::tr1::bind(&Window::redraw, this);
|
||||
m_taskUpdate.slot() = std::bind(&Window::redraw, this);
|
||||
}
|
||||
|
||||
Window::~Window() {
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
|
||||
#include "core/download.h"
|
||||
#include "core/view.h"
|
||||
#include "rpc/parse_commands.h"
|
||||
|
||||
#include "canvas.h"
|
||||
#include "globals.h"
|
||||
@@ -68,7 +69,7 @@ WindowDownloadList::set_view(core::View* l) {
|
||||
m_view = l;
|
||||
|
||||
if (m_view != NULL)
|
||||
m_changed_itr = m_view->signal_changed().insert(m_view->signal_changed().begin(), std::tr1::bind(&Window::mark_dirty, this));
|
||||
m_changed_itr = m_view->signal_changed().insert(m_view->signal_changed().begin(), std::bind(&Window::mark_dirty, this));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -85,12 +86,24 @@ WindowDownloadList::redraw() {
|
||||
if (m_view->empty_visible() || m_canvas->width() < 5 || m_canvas->height() < 2)
|
||||
return;
|
||||
|
||||
int layout_height;
|
||||
const std::string layout_name = rpc::call_command_string("ui.torrent_list.layout");
|
||||
|
||||
if (layout_name == "full") {
|
||||
layout_height = 3;
|
||||
} else if (layout_name == "compact") {
|
||||
layout_height = 1;
|
||||
} else {
|
||||
m_canvas->print(0, 0, "INVALID ui.torrent_list.layout '%s'", layout_name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
typedef std::pair<core::View::iterator, core::View::iterator> Range;
|
||||
|
||||
Range range = rak::advance_bidirectional(m_view->begin_visible(),
|
||||
m_view->focus() != m_view->end_visible() ? m_view->focus() : m_view->begin_visible(),
|
||||
m_view->end_visible(),
|
||||
m_canvas->height() / 3);
|
||||
m_canvas->height() / layout_height);
|
||||
|
||||
// Make sure we properly fill out the last lines so it looks like
|
||||
// there are more torrents, yet don't hide it if we got the last one
|
||||
@@ -99,22 +112,38 @@ WindowDownloadList::redraw() {
|
||||
++range.second;
|
||||
|
||||
int pos = 1;
|
||||
char buffer[m_canvas->width() + 1];
|
||||
char* last = buffer + m_canvas->width() - 2 + 1;
|
||||
|
||||
while (range.first != range.second) {
|
||||
char buffer[m_canvas->width() + 1];
|
||||
char* last = buffer + m_canvas->width() - 2 + 1;
|
||||
// Add a proper 'column info' method.
|
||||
if (layout_name == "compact") {
|
||||
print_download_column_compact(buffer, last);
|
||||
|
||||
print_download_title(buffer, last, *range.first);
|
||||
m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
|
||||
|
||||
print_download_info(buffer, last, *range.first);
|
||||
m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
|
||||
m_canvas->set_default_attributes(A_BOLD);
|
||||
m_canvas->print(0, pos++, " %s", buffer);
|
||||
}
|
||||
|
||||
print_download_status(buffer, last, *range.first);
|
||||
m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
|
||||
if (layout_name == "full") {
|
||||
while (range.first != range.second) {
|
||||
print_download_title(buffer, last, *range.first);
|
||||
m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
|
||||
print_download_info_full(buffer, last, *range.first);
|
||||
m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
|
||||
print_download_status(buffer, last, *range.first);
|
||||
m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
|
||||
|
||||
++range.first;
|
||||
}
|
||||
range.first++;
|
||||
}
|
||||
|
||||
} else {
|
||||
while (range.first != range.second) {
|
||||
print_download_info_compact(buffer, last, *range.first);
|
||||
m_canvas->set_default_attributes(range.first == m_view->focus() ? A_REVERSE : A_NORMAL);
|
||||
m_canvas->print(0, pos++, "%c %s", range.first == m_view->focus() ? '*' : ' ', buffer);
|
||||
|
||||
range.first++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ WindowDownloadStatusbar::redraw() {
|
||||
char buffer[m_canvas->width()];
|
||||
char* last = buffer + m_canvas->width() - 2;
|
||||
|
||||
print_download_info(buffer, last, m_download);
|
||||
print_download_info_full(buffer, last, m_download);
|
||||
m_canvas->print(0, 0, "%s", buffer);
|
||||
|
||||
snprintf(buffer, last - buffer, "Peers: %i(%i) Min/Max: %i/%i Slots: U:%i/%i D:%i/%i U/I/C/A: %i/%i/%i/%i Unchoked: %u/%u Failed: %i",
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <locale>
|
||||
#include <stdio.h>
|
||||
#include <torrent/path.h>
|
||||
#include <torrent/data/file.h>
|
||||
|
||||
@@ -53,13 +53,13 @@ WindowHttpQueue::WindowHttpQueue(core::HttpQueue* q) :
|
||||
|
||||
set_active(false);
|
||||
m_connInsert = m_queue->signal_insert().insert(m_queue->signal_insert().end(),
|
||||
std::tr1::bind(&WindowHttpQueue::receive_insert,
|
||||
std::bind(&WindowHttpQueue::receive_insert,
|
||||
this,
|
||||
std::tr1::placeholders::_1));
|
||||
std::placeholders::_1));
|
||||
m_connErase = m_queue->signal_erase().insert(m_queue->signal_insert().end(),
|
||||
std::tr1::bind(&WindowHttpQueue::receive_erase,
|
||||
std::bind(&WindowHttpQueue::receive_erase,
|
||||
this,
|
||||
std::tr1::placeholders::_1));
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#ifndef RTORRENT_DISPLAY_WINDOW_HTTP_QUEUE_H
|
||||
#define RTORRENT_DISPLAY_WINDOW_HTTP_QUEUE_H
|
||||
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
|
||||
#include "window.h"
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace display {
|
||||
|
||||
class WindowHttpQueue : public Window {
|
||||
public:
|
||||
typedef std::tr1::function<void (core::CurlGet*)> slot_curl_get;
|
||||
typedef std::function<void (core::CurlGet*)> slot_curl_get;
|
||||
typedef std::list<slot_curl_get> signal_curl_get;
|
||||
|
||||
WindowHttpQueue(core::HttpQueue* q);
|
||||
|
||||
@@ -50,11 +50,11 @@ WindowLog::WindowLog(torrent::log_buffer* l) :
|
||||
Window(new Canvas, 0, 0, 0, extent_full, extent_static),
|
||||
m_log(l) {
|
||||
|
||||
m_taskUpdate.slot() = std::tr1::bind(&WindowLog::receive_update, this);
|
||||
m_taskUpdate.slot() = std::bind(&WindowLog::receive_update, this);
|
||||
|
||||
unsigned int signal_index = torrent::main_thread()->signal_bitfield()->add_signal(std::tr1::bind(&WindowLog::receive_update, this));
|
||||
unsigned int signal_index = torrent::main_thread()->signal_bitfield()->add_signal(std::bind(&WindowLog::receive_update, this));
|
||||
|
||||
m_log->lock_and_set_update_slot(std::tr1::bind(&torrent::thread_base::send_event_signal, torrent::main_thread(), signal_index, false));
|
||||
m_log->lock_and_set_update_slot(std::bind(&torrent::thread_base::send_event_signal, torrent::main_thread(), signal_index, false));
|
||||
}
|
||||
|
||||
WindowLog::~WindowLog() {
|
||||
|
||||
@@ -68,7 +68,7 @@ WindowPeerList::redraw() {
|
||||
int x = 2;
|
||||
int y = 0;
|
||||
|
||||
m_canvas->print(x, y, "IP"); x += 16;
|
||||
m_canvas->print(x, y, "IP"); x += 25;
|
||||
m_canvas->print(x, y, "UP"); x += 7;
|
||||
m_canvas->print(x, y, "DOWN"); x += 7;
|
||||
m_canvas->print(x, y, "PEER"); x += 7;
|
||||
@@ -99,10 +99,16 @@ WindowPeerList::redraw() {
|
||||
|
||||
x = 0;
|
||||
|
||||
std::string ip_address = rak::socket_address::cast_from(p->address())->address_str();
|
||||
|
||||
if (ip_address.size() >= 24) {
|
||||
ip_address.replace(ip_address.begin() + 21, ip_address.end(), "...");
|
||||
}
|
||||
|
||||
m_canvas->print(x, y, "%c %s",
|
||||
range.first == *m_focus ? '*' : ' ',
|
||||
rak::socket_address::cast_from(p->address())->address_str().c_str());
|
||||
x += 18;
|
||||
ip_address.c_str());
|
||||
x += 27;
|
||||
|
||||
m_canvas->print(x, y, "%.1f", (double)p->up_rate()->rate() / 1024); x += 7;
|
||||
m_canvas->print(x, y, "%.1f", (double)p->down_rate()->rate() / 1024); x += 7;
|
||||
|
||||
@@ -38,15 +38,15 @@
|
||||
#define RTORRENT_INPUT_BINDINGS_H
|
||||
|
||||
#include <map>
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
|
||||
#include "display/attributes.h"
|
||||
|
||||
namespace input {
|
||||
|
||||
class Bindings : private std::map<int, std::tr1::function<void ()> > {
|
||||
class Bindings : private std::map<int, std::function<void ()> > {
|
||||
public:
|
||||
typedef std::tr1::function<void ()> slot_void;
|
||||
typedef std::function<void ()> slot_void;
|
||||
typedef std::map<int, slot_void> base_type;
|
||||
|
||||
using base_type::iterator;
|
||||
|
||||
@@ -38,8 +38,7 @@
|
||||
|
||||
#include "input_event.h"
|
||||
|
||||
//ncurses.h must be included last since sys/mman.h on Solaris munges ERR.
|
||||
#include <ncurses.h>
|
||||
#include "display/attributes.h"
|
||||
|
||||
namespace input {
|
||||
|
||||
|
||||
@@ -39,13 +39,13 @@
|
||||
|
||||
#include <torrent/event.h>
|
||||
#include <torrent/poll.h>
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
|
||||
namespace input {
|
||||
|
||||
class InputEvent : public torrent::Event {
|
||||
public:
|
||||
typedef std::tr1::function<void (int)> slot_int;
|
||||
typedef std::function<void (int)> slot_int;
|
||||
|
||||
InputEvent(int fd) { m_fileDesc = fd; }
|
||||
|
||||
|
||||
@@ -75,7 +75,11 @@ 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 += '/';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#define RTORRENT_INPUT_PATH_INPUT_H
|
||||
|
||||
#include <list>
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
|
||||
#include "utils/directory.h"
|
||||
#include "text_input.h"
|
||||
@@ -50,8 +50,8 @@ public:
|
||||
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::function<void ()> slot_void;
|
||||
typedef std::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;
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace input {
|
||||
class TextInput : private std::string {
|
||||
public:
|
||||
typedef std::string Base;
|
||||
typedef std::tr1::function<void ()> slot_void;
|
||||
typedef std::function<void ()> slot_void;
|
||||
|
||||
using Base::c_str;
|
||||
using Base::empty;
|
||||
|
||||
+76
-451
@@ -89,25 +89,25 @@ void do_nothing() {}
|
||||
void do_nothing_str(const std::string&) {}
|
||||
|
||||
int
|
||||
parse_options(Control* c, int argc, char** argv) {
|
||||
parse_options(int argc, char** argv) {
|
||||
try {
|
||||
OptionParser optionParser;
|
||||
|
||||
// Converted.
|
||||
optionParser.insert_flag('h', std::tr1::bind(&print_help));
|
||||
optionParser.insert_flag('n', std::tr1::bind(&do_nothing_str, std::tr1::placeholders::_1));
|
||||
optionParser.insert_flag('D', std::tr1::bind(&do_nothing_str, std::tr1::placeholders::_1));
|
||||
optionParser.insert_flag('I', std::tr1::bind(&do_nothing_str, std::tr1::placeholders::_1));
|
||||
optionParser.insert_flag('K', std::tr1::bind(&do_nothing_str, std::tr1::placeholders::_1));
|
||||
optionParser.insert_flag('h', std::bind(&print_help));
|
||||
optionParser.insert_flag('n', std::bind(&do_nothing_str, std::placeholders::_1));
|
||||
optionParser.insert_flag('D', std::bind(&do_nothing_str, std::placeholders::_1));
|
||||
optionParser.insert_flag('I', std::bind(&do_nothing_str, std::placeholders::_1));
|
||||
optionParser.insert_flag('K', std::bind(&do_nothing_str, std::placeholders::_1));
|
||||
|
||||
optionParser.insert_option('b', std::tr1::bind(&rpc::call_command_set_string, "network.bind_address.set", std::tr1::placeholders::_1));
|
||||
optionParser.insert_option('d', std::tr1::bind(&rpc::call_command_set_string, "directory.default.set", std::tr1::placeholders::_1));
|
||||
optionParser.insert_option('i', std::tr1::bind(&rpc::call_command_set_string, "ip", std::tr1::placeholders::_1));
|
||||
optionParser.insert_option('p', std::tr1::bind(&rpc::call_command_set_string, "network.port_range.set", std::tr1::placeholders::_1));
|
||||
optionParser.insert_option('s', std::tr1::bind(&rpc::call_command_set_string, "session", std::tr1::placeholders::_1));
|
||||
optionParser.insert_option('b', std::bind(&rpc::call_command_set_string, "network.bind_address.set", std::placeholders::_1));
|
||||
optionParser.insert_option('d', std::bind(&rpc::call_command_set_string, "directory.default.set", std::placeholders::_1));
|
||||
optionParser.insert_option('i', std::bind(&rpc::call_command_set_string, "ip", std::placeholders::_1));
|
||||
optionParser.insert_option('p', std::bind(&rpc::call_command_set_string, "network.port_range.set", std::placeholders::_1));
|
||||
optionParser.insert_option('s', std::bind(&rpc::call_command_set_string, "session", std::placeholders::_1));
|
||||
|
||||
optionParser.insert_option('O', std::tr1::bind(&rpc::parse_command_single_std, std::tr1::placeholders::_1));
|
||||
optionParser.insert_option_list('o', std::tr1::bind(&rpc::call_command_set_std_string, std::tr1::placeholders::_1, std::tr1::placeholders::_2));
|
||||
optionParser.insert_option('O', std::bind(&rpc::parse_command_single_std, std::placeholders::_1));
|
||||
optionParser.insert_option_list('o', std::bind(&rpc::call_command_set_std_string, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
return optionParser.process(argc, argv);
|
||||
|
||||
@@ -117,8 +117,8 @@ parse_options(Control* c, int argc, char** argv) {
|
||||
}
|
||||
|
||||
void
|
||||
load_session_torrents(Control* c) {
|
||||
utils::Directory entries = c->core()->download_store()->get_formated_entries();
|
||||
load_session_torrents() {
|
||||
utils::Directory entries = control->core()->download_store()->get_formated_entries();
|
||||
|
||||
for (utils::Directory::const_iterator first = entries.begin(), last = entries.end(); first != last; ++first) {
|
||||
// We don't really support session torrents that are links. These
|
||||
@@ -127,34 +127,34 @@ load_session_torrents(Control* c) {
|
||||
if (!first->is_file())
|
||||
continue;
|
||||
|
||||
core::DownloadFactory* f = new core::DownloadFactory(c->core());
|
||||
core::DownloadFactory* f = new core::DownloadFactory(control->core());
|
||||
|
||||
// Replace with session torrent flag.
|
||||
f->set_session(true);
|
||||
f->slot_finished(std::tr1::bind(&rak::call_delete_func<core::DownloadFactory>, f));
|
||||
f->slot_finished(std::bind(&rak::call_delete_func<core::DownloadFactory>, f));
|
||||
f->load(entries.path() + first->d_name);
|
||||
f->commit();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
load_arg_torrents(Control* c, char** first, char** last) {
|
||||
//std::for_each(begin, end, std::bind1st(std::mem_fun(&core::Manager::insert), &c->get_core()));
|
||||
load_arg_torrents(char** first, char** last) {
|
||||
//std::for_each(begin, end, std::bind1st(std::mem_fun(&core::Manager::insert), &control->get_core()));
|
||||
for (; first != last; ++first) {
|
||||
core::DownloadFactory* f = new core::DownloadFactory(c->core());
|
||||
core::DownloadFactory* f = new core::DownloadFactory(control->core());
|
||||
|
||||
// Replace with session torrent flag.
|
||||
f->set_start(true);
|
||||
f->slot_finished(std::tr1::bind(&rak::call_delete_func<core::DownloadFactory>, f));
|
||||
f->slot_finished(std::bind(&rak::call_delete_func<core::DownloadFactory>, f));
|
||||
f->load(*first);
|
||||
f->commit();
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
client_next_timeout(Control* c) {
|
||||
client_next_timeout() {
|
||||
if (taskScheduler.empty())
|
||||
return (c->is_shutdown_started() ? rak::timer::from_milliseconds(100) : rak::timer::from_seconds(60)).usec();
|
||||
return (control->is_shutdown_started() ? rak::timer::from_milliseconds(100) : rak::timer::from_seconds(60)).usec();
|
||||
else if (taskScheduler.top()->time() <= cachedTime)
|
||||
return 0;
|
||||
else
|
||||
@@ -190,16 +190,19 @@ main(int argc, char** argv) {
|
||||
|
||||
control = new Control;
|
||||
|
||||
srandom(cachedTime.usec() ^ (getpid() << 16) ^ getppid());
|
||||
srand48(cachedTime.usec() ^ (getpid() << 16) ^ getppid());
|
||||
unsigned int random_seed = cachedTime.seconds() ^ cachedTime.usec() ^ (getpid() << 16) ^ getppid();
|
||||
|
||||
srandom(random_seed);
|
||||
srand48(random_seed);
|
||||
|
||||
SignalHandler::set_ignore(SIGPIPE);
|
||||
SignalHandler::set_handler(SIGINT, std::tr1::bind(&Control::receive_normal_shutdown, control));
|
||||
SignalHandler::set_handler(SIGTERM, std::tr1::bind(&Control::receive_quick_shutdown, control));
|
||||
SignalHandler::set_handler(SIGWINCH, std::tr1::bind(&display::Manager::force_redraw, control->display()));
|
||||
SignalHandler::set_handler(SIGSEGV, std::tr1::bind(&do_panic, SIGSEGV));
|
||||
SignalHandler::set_handler(SIGILL, std::tr1::bind(&do_panic, SIGILL));
|
||||
SignalHandler::set_handler(SIGFPE, std::tr1::bind(&do_panic, SIGFPE));
|
||||
SignalHandler::set_handler(SIGINT, std::bind(&Control::receive_normal_shutdown, control));
|
||||
SignalHandler::set_handler(SIGHUP, std::bind(&Control::receive_normal_shutdown, control));
|
||||
SignalHandler::set_handler(SIGTERM, std::bind(&Control::receive_quick_shutdown, control));
|
||||
SignalHandler::set_handler(SIGWINCH, std::bind(&display::Manager::force_redraw, control->display()));
|
||||
SignalHandler::set_handler(SIGSEGV, std::bind(&do_panic, SIGSEGV));
|
||||
SignalHandler::set_handler(SIGILL, std::bind(&do_panic, SIGILL));
|
||||
SignalHandler::set_handler(SIGFPE, std::bind(&do_panic, SIGFPE));
|
||||
|
||||
SignalHandler::set_sigaction_handler(SIGBUS, &handle_sigbus);
|
||||
|
||||
@@ -211,16 +214,16 @@ main(int argc, char** argv) {
|
||||
// threads. Use '--enable-interrupt-socket' when configuring
|
||||
// LibTorrent to enable this workaround.
|
||||
if (torrent::thread_base::should_handle_sigusr1())
|
||||
SignalHandler::set_handler(SIGUSR1, std::tr1::bind(&do_nothing));
|
||||
SignalHandler::set_handler(SIGUSR1, std::bind(&do_nothing));
|
||||
|
||||
torrent::log_add_group_output(torrent::LOG_NOTICE, "important");
|
||||
torrent::log_add_group_output(torrent::LOG_INFO, "complete");
|
||||
|
||||
torrent::Poll::slot_create_poll() = std::tr1::bind(&core::create_poll);
|
||||
torrent::Poll::slot_create_poll() = std::bind(&core::create_poll);
|
||||
|
||||
torrent::initialize();
|
||||
torrent::main_thread()->slot_do_work() = tr1::bind(&client_perform);
|
||||
torrent::main_thread()->slot_next_timeout() = tr1::bind(&client_next_timeout, control);
|
||||
torrent::main_thread()->slot_do_work() = std::bind(&client_perform);
|
||||
torrent::main_thread()->slot_next_timeout() = std::bind(&client_next_timeout);
|
||||
|
||||
worker_thread = new ThreadWorker();
|
||||
worker_thread->init_thread();
|
||||
@@ -230,8 +233,8 @@ main(int argc, char** argv) {
|
||||
initialize_commands();
|
||||
|
||||
if (OptionParser::has_flag('D', argc, argv)) {
|
||||
rpc::call_command_set_value("method.use_deprecated.set", false);
|
||||
lt_log_print(torrent::LOG_WARN, "Disabled deprecated commands.");
|
||||
rpc::call_command_set_value("method.use_deprecated.set", true);
|
||||
lt_log_print(torrent::LOG_WARN, "Enabled deprecated commands.");
|
||||
}
|
||||
|
||||
if (OptionParser::has_flag('I', argc, argv)) {
|
||||
@@ -273,6 +276,7 @@ main(int argc, char** argv) {
|
||||
|
||||
"method.set_key = event.download.resumed, !_timestamp, ((d.timestamp.started.set_if_z, ((system.time)) ))\n"
|
||||
"method.set_key = event.download.finished, !_timestamp, ((d.timestamp.finished.set_if_z, ((system.time)) ))\n"
|
||||
"method.set_key = event.download.hash_done, !_timestamp, {(branch,((d.complete)),((d.timestamp.finished.set_if_z,(system.time))))}\n"
|
||||
|
||||
"method.insert.c_simple = group.insert_persistent_view,"
|
||||
"((view.add,((argument.0)))),((view.persistent,((argument.0)))),((group.insert,((argument.0)),((argument.0))))\n"
|
||||
@@ -394,11 +398,28 @@ main(int argc, char** argv) {
|
||||
CMD2_REDIRECT ("port_random", "network.port_random.set");
|
||||
CMD2_REDIRECT ("proxy_address", "network.proxy_address.set");
|
||||
|
||||
CMD2_REDIRECT ("scgi_port", "network.scgi.open_port");
|
||||
CMD2_REDIRECT ("scgi_local", "network.scgi.open_local");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("directory", "directory.default.set");
|
||||
CMD2_REDIRECT_GENERIC("session", "session.path.set");
|
||||
|
||||
CMD2_REDIRECT ("check_hash", "pieces.hash.on_completion.set");
|
||||
|
||||
CMD2_REDIRECT ("key_layout", "keys.layout.set");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("to_gm_time", "convert.gm_time");
|
||||
CMD2_REDIRECT_GENERIC("to_gm_date", "convert.gm_date");
|
||||
CMD2_REDIRECT_GENERIC("to_time", "convert.time");
|
||||
CMD2_REDIRECT_GENERIC("to_date", "convert.date");
|
||||
CMD2_REDIRECT_GENERIC("to_elapsed_time", "convert.elapsed_time");
|
||||
CMD2_REDIRECT_GENERIC("to_kb", "convert.kb");
|
||||
CMD2_REDIRECT_GENERIC("to_mb", "convert.mb");
|
||||
CMD2_REDIRECT_GENERIC("to_xb", "convert.xb");
|
||||
CMD2_REDIRECT_GENERIC("to_throttle", "convert.throttle");
|
||||
|
||||
CMD2_REDIRECT ("torrent_list_layout", "ui.torrent_list.layout.set");
|
||||
|
||||
// Deprecated commands. Don't use these anymore.
|
||||
|
||||
if (rpc::call_command_value("method.use_intermediate") == 1) {
|
||||
@@ -417,423 +438,25 @@ main(int argc, char** argv) {
|
||||
|
||||
#if LT_SLIM_VERSION != 1
|
||||
if (rpc::call_command_value("method.use_deprecated")) {
|
||||
// Deprecated in 0.7.0:
|
||||
|
||||
CMD2_REDIRECT_GENERIC("system.method.insert", "method.insert");
|
||||
CMD2_REDIRECT_GENERIC("system.method.erase", "method.erase");
|
||||
CMD2_REDIRECT_GENERIC("system.method.get", "method.get");
|
||||
CMD2_REDIRECT_GENERIC("system.method.set", "method.set");
|
||||
CMD2_REDIRECT_GENERIC("system.method.list_keys", "method.list_keys");
|
||||
CMD2_REDIRECT_GENERIC("system.method.has_key", "method.has_key");
|
||||
CMD2_REDIRECT_GENERIC("system.method.set_key", "method.set_key");
|
||||
|
||||
CMD2_REDIRECT ("get_directory", "directory.default");
|
||||
CMD2_REDIRECT_GENERIC("set_directory", "directory.default.set");
|
||||
|
||||
CMD2_REDIRECT ("get_session", "session.path");
|
||||
CMD2_REDIRECT_GENERIC("set_session", "session.path.set");
|
||||
|
||||
CMD2_REDIRECT ("session_save", "session.save");
|
||||
|
||||
CMD2_REDIRECT ("get_name", "session.name");
|
||||
CMD2_REDIRECT_GENERIC("set_name", "session.name.set");
|
||||
|
||||
CMD2_REDIRECT ("system.file_allocate", "system.file.allocate");
|
||||
CMD2_REDIRECT ("system.file_allocate.set", "system.file.allocate.set");
|
||||
CMD2_REDIRECT ("get_max_file_size", "system.file.max_size");
|
||||
CMD2_REDIRECT_GENERIC("set_max_file_size", "system.file.max_size.set");
|
||||
CMD2_REDIRECT ("get_split_file_size", "system.file.split_size");
|
||||
CMD2_REDIRECT_GENERIC("set_split_file_size", "system.file.split_size.set");
|
||||
CMD2_REDIRECT ("get_split_suffix", "system.file.split_suffix");
|
||||
CMD2_REDIRECT_GENERIC("set_split_suffix", "system.file.split_suffix.set");
|
||||
|
||||
CMD2_REDIRECT ("get_timeout_sync", "pieces.sync.timeout");
|
||||
CMD2_REDIRECT_GENERIC("set_timeout_sync", "pieces.sync.timeout.set");
|
||||
CMD2_REDIRECT ("get_timeout_safe_sync", "pieces.sync.timeout_safe");
|
||||
CMD2_REDIRECT_GENERIC("set_timeout_safe_sync", "pieces.sync.timeout_safe.set");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("get_preload_type", "pieces.preload.type");
|
||||
CMD2_REDIRECT_GENERIC("get_preload_min_size", "pieces.preload.min_size");
|
||||
CMD2_REDIRECT_GENERIC("get_preload_required_rate", "pieces.preload.min_rate");
|
||||
CMD2_REDIRECT_GENERIC("set_preload_type", "pieces.preload.type.set");
|
||||
CMD2_REDIRECT_GENERIC("set_preload_min_size", "pieces.preload.min_size.set");
|
||||
CMD2_REDIRECT_GENERIC("set_preload_required_rate", "pieces.preload.min_rate.set");
|
||||
CMD2_REDIRECT_GENERIC("get_stats_preloaded", "pieces.stats_preloaded");
|
||||
CMD2_REDIRECT_GENERIC("get_stats_not_preloaded", "pieces.stats_not_preloaded");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("get_safe_sync", "pieces.sync.always_safe");
|
||||
CMD2_REDIRECT_GENERIC("set_safe_sync", "pieces.sync.always_safe.set");
|
||||
|
||||
CMD2_REDIRECT ("get_memory_usage", "pieces.memory.current");
|
||||
CMD2_REDIRECT_GENERIC("get_max_memory_usage", "pieces.memory.max");
|
||||
CMD2_REDIRECT_GENERIC("set_max_memory_usage", "pieces.memory.max.set");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("load", "load.normal");
|
||||
CMD2_REDIRECT_GENERIC("load_verbose", "load.verbose");
|
||||
CMD2_REDIRECT_GENERIC("load_start", "load.start");
|
||||
CMD2_REDIRECT_GENERIC("load_start_verbose", "load.start_verbose");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("load_raw", "load.raw");
|
||||
CMD2_REDIRECT_GENERIC("load_raw_start", "load.raw_start");
|
||||
CMD2_REDIRECT_GENERIC("load_raw_verbose", "load.raw_verbose");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("get_connection_leech", "protocol.connection.leech");
|
||||
CMD2_REDIRECT_GENERIC("get_connection_seed", "protocol.connection.seed");
|
||||
CMD2_REDIRECT_GENERIC("set_connection_leech", "protocol.connection.leech.set");
|
||||
CMD2_REDIRECT_GENERIC("set_connection_seed", "protocol.connection.seed.set");
|
||||
|
||||
//
|
||||
// Throttle:
|
||||
//
|
||||
|
||||
CMD2_REDIRECT_GENERIC("throttle_up", "throttle.up");
|
||||
CMD2_REDIRECT_GENERIC("throttle_down", "throttle.down");
|
||||
CMD2_REDIRECT_GENERIC("throttle_ip", "throttle.ip");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("get_throttle_up_max", "throttle.up.max");
|
||||
CMD2_REDIRECT_GENERIC("get_throttle_up_rate", "throttle.up.rate");
|
||||
CMD2_REDIRECT_GENERIC("get_throttle_down_max", "throttle.down.max");
|
||||
CMD2_REDIRECT_GENERIC("get_throttle_down_rate", "throttle.down.rate");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("set_min_peers", "throttle.min_peers.normal.set");
|
||||
CMD2_REDIRECT_GENERIC("set_max_peers", "throttle.max_peers.normal.set");
|
||||
CMD2_REDIRECT_GENERIC("set_min_peers_seed", "throttle.min_peers.seed.set");
|
||||
CMD2_REDIRECT_GENERIC("set_max_peers_seed", "throttle.max_peers.seed.set");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("set_max_uploads", "throttle.max_uploads.set");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("set_max_uploads_div", "throttle.max_uploads.div.set");
|
||||
CMD2_REDIRECT_GENERIC("set_max_uploads_global", "throttle.max_uploads.global.set");
|
||||
CMD2_REDIRECT_GENERIC("set_max_downloads_div", "throttle.max_downloads.div.set");
|
||||
CMD2_REDIRECT_GENERIC("set_max_downloads_global", "throttle.max_downloads.global.set");
|
||||
|
||||
CMD2_REDIRECT ("get_min_peers", "throttle.min_peers.normal");
|
||||
CMD2_REDIRECT ("get_max_peers", "throttle.max_peers.normal");
|
||||
CMD2_REDIRECT ("get_min_peers_seed", "throttle.min_peers.seed");
|
||||
CMD2_REDIRECT ("get_max_peers_seed", "throttle.max_peers.seed");
|
||||
|
||||
CMD2_REDIRECT ("get_max_uploads", "throttle.max_uploads");
|
||||
|
||||
CMD2_REDIRECT ("get_max_uploads_div", "throttle.max_uploads.div");
|
||||
CMD2_REDIRECT ("get_max_uploads_global", "throttle.max_uploads.global");
|
||||
CMD2_REDIRECT ("get_max_downloads_div", "throttle.max_downloads.div");
|
||||
CMD2_REDIRECT ("get_max_downloads_global", "throttle.max_downloads.global");
|
||||
|
||||
CMD2_REDIRECT ("get_up_rate", "throttle.global_up.rate");
|
||||
CMD2_REDIRECT ("get_up_total", "throttle.global_up.total");
|
||||
CMD2_REDIRECT ("get_upload_rate", "throttle.global_up.max_rate");
|
||||
CMD2_REDIRECT_GENERIC("set_upload_rate", "throttle.global_up.max_rate.set");
|
||||
CMD2_REDIRECT ("get_down_rate", "throttle.global_down.rate");
|
||||
CMD2_REDIRECT ("get_down_total", "throttle.global_down.total");
|
||||
CMD2_REDIRECT ("get_download_rate", "throttle.global_down.max_rate");
|
||||
CMD2_REDIRECT_GENERIC("set_download_rate", "throttle.global_down.max_rate.set");
|
||||
|
||||
//
|
||||
// Network:
|
||||
//
|
||||
|
||||
CMD2_REDIRECT ("get_send_buffer_size", "network.send_buffer.size");
|
||||
CMD2_REDIRECT_GENERIC("set_send_buffer_size", "network.send_buffer.size.set");
|
||||
CMD2_REDIRECT ("get_receive_buffer_size", "network.receive_buffer.size");
|
||||
CMD2_REDIRECT_GENERIC("set_receive_buffer_size", "network.receive_buffer.size.set");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("set_bind", "network.bind_address.set");
|
||||
CMD2_REDIRECT ("get_bind", "network.bind_address");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("set_ip", "network.local_address.set");
|
||||
CMD2_REDIRECT ("get_ip", "network.local_address");
|
||||
|
||||
CMD2_REDIRECT ("get_port_range", "network.port_range");
|
||||
CMD2_REDIRECT_GENERIC("set_port_range", "network.port_range.set");
|
||||
|
||||
CMD2_REDIRECT ("get_port_random", "network.port_random");
|
||||
CMD2_REDIRECT_GENERIC("set_port_random", "network.port_random.set");
|
||||
|
||||
CMD2_REDIRECT ("port_open", "network.port_open.set");
|
||||
CMD2_REDIRECT ("get_port_open", "network.port_open");
|
||||
CMD2_REDIRECT_GENERIC("set_port_open", "network.port_open.set");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("set_proxy_address", "network.proxy_address.set");
|
||||
CMD2_REDIRECT ("get_proxy_address", "network.proxy_address");
|
||||
|
||||
CMD2_REDIRECT ("scgi_port", "network.scgi.open_port");
|
||||
CMD2_REDIRECT ("scgi_local", "network.scgi.open_local");
|
||||
|
||||
CMD2_REDIRECT ("scgi_dont_route", "network.scgi.dont_route.set");
|
||||
CMD2_REDIRECT_GENERIC("set_scgi_dont_route", "network.scgi.dont_route.set");
|
||||
CMD2_REDIRECT ("get_scgi_dont_route", "network.scgi.dont_route");
|
||||
|
||||
CMD2_REDIRECT ("get_max_open_sockets", "network.max_open_sockets");
|
||||
|
||||
CMD2_REDIRECT ("get_max_open_files", "network.max_open_files");
|
||||
CMD2_REDIRECT_GENERIC("set_max_open_files", "network.max_open_files.set");
|
||||
|
||||
//
|
||||
// XMLRPC stuff:
|
||||
//
|
||||
|
||||
CMD2_REDIRECT_GENERIC("xmlrpc_dialect", "network.xmlrpc.dialect.set");
|
||||
CMD2_REDIRECT_GENERIC("set_xmlrpc_dialect", "network.xmlrpc.dialect.set");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("xmlrpc_size_limit", "network.xmlrpc.size_limit.set");
|
||||
CMD2_REDIRECT ("get_xmlrpc_size_limit", "network.xmlrpc.size_limit");
|
||||
CMD2_REDIRECT_GENERIC("set_xmlrpc_size_limit", "network.xmlrpc.size_limit.set");
|
||||
|
||||
//
|
||||
// HTTP stuff:
|
||||
//
|
||||
|
||||
CMD2_REDIRECT_GENERIC("http_capath", "network.http.capath.set");
|
||||
CMD2_REDIRECT ("get_http_capath", "network.http.capath");
|
||||
CMD2_REDIRECT_GENERIC("set_http_capath", "network.http.capath.set");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("http_cacert", "network.http.cacert.set");
|
||||
CMD2_REDIRECT ("get_http_cacert", "network.http.cacert");
|
||||
CMD2_REDIRECT_GENERIC("set_http_cacert", "network.http.cacert.set");
|
||||
|
||||
CMD2_REDIRECT ("get_max_open_http", "network.http.max_open");
|
||||
CMD2_REDIRECT_GENERIC("set_max_open_http", "network.http.max_open.set");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("http_proxy", "network.http.proxy_address.set");
|
||||
CMD2_REDIRECT ("get_http_proxy", "network.http.proxy_address");
|
||||
CMD2_REDIRECT_GENERIC("set_http_proxy", "network.http.proxy_address.set");
|
||||
|
||||
CMD2_REDIRECT ("peer_exchange", "protocol.pex.set");
|
||||
CMD2_REDIRECT ("get_peer_exchange", "protocol.pex");
|
||||
CMD2_REDIRECT_GENERIC("set_peer_exchange", "protocol.pex.set");
|
||||
|
||||
//
|
||||
// Trackers:
|
||||
//
|
||||
|
||||
CMD2_REDIRECT ("tracker_numwant", "trackers.numwant.set");
|
||||
CMD2_REDIRECT ("get_tracker_numwant", "trackers.numwant");
|
||||
CMD2_REDIRECT_GENERIC("set_tracker_numwant", "trackers.numwant.set");
|
||||
|
||||
CMD2_REDIRECT ("use_udp_trackers", "trackers.use_udp.set");
|
||||
CMD2_REDIRECT ("get_use_udp_trackers", "trackers.use_udp");
|
||||
CMD2_REDIRECT_GENERIC("set_use_udp_trackers", "trackers.use_udp.set");
|
||||
|
||||
//
|
||||
// DHT stuff
|
||||
//
|
||||
|
||||
CMD2_REDIRECT ("dht_add_node", "dht.add_node");
|
||||
CMD2_REDIRECT ("dht_statistics", "dht.statistics");
|
||||
CMD2_REDIRECT ("get_dht_port", "dht.port");
|
||||
CMD2_REDIRECT_GENERIC("set_dht_port", "dht.port.set");
|
||||
CMD2_REDIRECT ("get_dht_throttle", "dht.throttle.name");
|
||||
CMD2_REDIRECT_GENERIC("set_dht_throttle", "dht.throttle.name.set");
|
||||
|
||||
//
|
||||
// Various system stuff:
|
||||
//
|
||||
|
||||
CMD2_REDIRECT ("get_session_lock", "session.use_lock");
|
||||
CMD2_REDIRECT_GENERIC("set_session_lock", "session.use_lock.set");
|
||||
CMD2_REDIRECT ("get_session_on_completion", "session.on_completion");
|
||||
CMD2_REDIRECT_GENERIC("set_session_on_completion", "session.on_completion.set");
|
||||
|
||||
CMD2_REDIRECT ("check_hash", "pieces.hash.on_completion.set");
|
||||
CMD2_REDIRECT ("get_check_hash", "pieces.hash.on_completion");
|
||||
CMD2_REDIRECT_GENERIC("set_check_hash", "pieces.hash.on_completion.set");
|
||||
|
||||
//
|
||||
// Download:
|
||||
//
|
||||
|
||||
CMD2_REDIRECT ("d.get_hash", "d.hash");
|
||||
CMD2_REDIRECT ("d.get_local_id", "d.local_id");
|
||||
CMD2_REDIRECT ("d.get_local_id_html", "d.local_id_html");
|
||||
CMD2_REDIRECT ("d.get_bitfield", "d.bitfield");
|
||||
CMD2_REDIRECT ("d.get_base_path", "d.base_path");
|
||||
CMD2_REDIRECT ("d.get_base_filename", "d.base_filename");
|
||||
|
||||
CMD2_REDIRECT ("d.get_name", "d.name");
|
||||
CMD2_REDIRECT ("d.get_creation_date", "d.creation_date");
|
||||
|
||||
CMD2_REDIRECT ("d.get_peer_exchange", "d.peer_exchange");
|
||||
|
||||
CMD2_REDIRECT ("d.get_up_rate", "d.up.rate");
|
||||
CMD2_REDIRECT ("d.get_up_total", "d.up.total");
|
||||
CMD2_REDIRECT ("d.get_down_rate", "d.down.rate");
|
||||
CMD2_REDIRECT ("d.get_down_total", "d.down.total");
|
||||
CMD2_REDIRECT ("d.get_skip_rate", "d.skip.rate");
|
||||
CMD2_REDIRECT ("d.get_skip_total", "d.skip.total");
|
||||
|
||||
//
|
||||
CMD2_REDIRECT ("d.get_bytes_done", "d.bytes_done");
|
||||
CMD2_REDIRECT ("d.get_chunk_size", "d.chunk_size");
|
||||
CMD2_REDIRECT ("d.get_chunks_hashed", "d.chunks_hashed");
|
||||
CMD2_REDIRECT ("d.get_complete", "d.complete");
|
||||
CMD2_REDIRECT ("d.get_completed_bytes", "d.completed_bytes");
|
||||
CMD2_REDIRECT ("d.get_completed_chunks", "d.completed_chunks");
|
||||
CMD2_REDIRECT ("d.get_connection_current", "d.connection_current");
|
||||
CMD2_REDIRECT ("d.get_connection_leech", "d.connection_leech");
|
||||
CMD2_REDIRECT ("d.get_connection_seed", "d.connection_seed");
|
||||
CMD2_REDIRECT ("d.get_custom", "d.custom");
|
||||
CMD2_REDIRECT ("d.get_custom1", "d.custom1");
|
||||
CMD2_REDIRECT ("d.get_custom2", "d.custom2");
|
||||
CMD2_REDIRECT ("d.get_custom3", "d.custom3");
|
||||
CMD2_REDIRECT ("d.get_custom4", "d.custom4");
|
||||
CMD2_REDIRECT ("d.get_custom5", "d.custom5");
|
||||
CMD2_REDIRECT ("d.get_custom_throw", "d.custom_throw");
|
||||
CMD2_REDIRECT ("d.get_directory", "d.directory");
|
||||
CMD2_REDIRECT ("d.get_directory_base", "d.directory_base");
|
||||
CMD2_REDIRECT ("d.get_free_diskspace", "d.free_diskspace");
|
||||
CMD2_REDIRECT ("d.get_hashing", "d.hashing");
|
||||
CMD2_REDIRECT ("d.get_hashing_failed", "d.hashing_failed");
|
||||
CMD2_REDIRECT ("d.get_ignore_commands", "d.ignore_commands");
|
||||
CMD2_REDIRECT ("d.get_left_bytes", "d.left_bytes");
|
||||
CMD2_REDIRECT ("d.get_loaded_file", "d.loaded_file");
|
||||
CMD2_REDIRECT ("d.get_max_file_size", "d.max_file_size");
|
||||
CMD2_REDIRECT ("d.get_max_size_pex", "d.max_size_pex");
|
||||
CMD2_REDIRECT ("d.get_message", "d.message");
|
||||
CMD2_REDIRECT ("d.get_mode", "d.mode");
|
||||
CMD2_REDIRECT ("d.get_peers_accounted", "d.peers_accounted");
|
||||
CMD2_REDIRECT ("d.get_peers_complete", "d.peers_complete");
|
||||
CMD2_REDIRECT ("d.get_peers_connected", "d.peers_connected");
|
||||
CMD2_REDIRECT ("d.get_peers_max", "d.peers_max");
|
||||
CMD2_REDIRECT ("d.get_peers_min", "d.peers_min");
|
||||
CMD2_REDIRECT ("d.get_peers_not_connected", "d.peers_not_connected");
|
||||
CMD2_REDIRECT ("d.get_priority", "d.priority");
|
||||
CMD2_REDIRECT ("d.get_priority_str", "d.priority_str");
|
||||
CMD2_REDIRECT ("d.get_ratio", "d.ratio");
|
||||
CMD2_REDIRECT ("d.get_size_bytes", "d.size_bytes");
|
||||
CMD2_REDIRECT ("d.get_size_chunks", "d.size_chunks");
|
||||
CMD2_REDIRECT ("d.get_size_files", "d.size_files");
|
||||
CMD2_REDIRECT ("d.get_size_pex", "d.size_pex");
|
||||
CMD2_REDIRECT ("d.get_state", "d.state");
|
||||
CMD2_REDIRECT ("d.get_state_changed", "d.state_changed");
|
||||
CMD2_REDIRECT ("d.get_state_counter", "d.state_counter");
|
||||
CMD2_REDIRECT ("d.get_throttle_name", "d.throttle_name");
|
||||
CMD2_REDIRECT ("d.get_tied_to_file", "d.tied_to_file");
|
||||
CMD2_REDIRECT ("d.get_tracker_focus", "d.tracker_focus");
|
||||
CMD2_REDIRECT ("d.get_tracker_numwant", "d.tracker_numwant");
|
||||
CMD2_REDIRECT ("d.get_tracker_size", "d.tracker_size");
|
||||
CMD2_REDIRECT ("d.get_uploads_max", "d.uploads_max");
|
||||
|
||||
CMD2_REDIRECT ("d.set_connection_current", "d.connection_current.set");
|
||||
CMD2_REDIRECT ("d.set_custom", "d.custom.set");
|
||||
CMD2_REDIRECT ("d.set_custom1", "d.custom1.set");
|
||||
CMD2_REDIRECT ("d.set_custom2", "d.custom2.set");
|
||||
CMD2_REDIRECT ("d.set_custom3", "d.custom3.set");
|
||||
CMD2_REDIRECT ("d.set_custom4", "d.custom4.set");
|
||||
CMD2_REDIRECT ("d.set_custom5", "d.custom5.set");
|
||||
CMD2_REDIRECT ("d.set_directory", "d.directory.set");
|
||||
CMD2_REDIRECT ("d.set_directory_base", "d.directory_base.set");
|
||||
CMD2_REDIRECT ("d.set_hashing_failed", "d.hashing_failed.set");
|
||||
CMD2_REDIRECT ("d.set_ignore_commands", "d.ignore_commands.set");
|
||||
CMD2_REDIRECT ("d.set_max_file_size", "d.max_file_size.set");
|
||||
CMD2_REDIRECT ("d.set_message", "d.message.set");
|
||||
CMD2_REDIRECT ("d.set_peers_max", "d.peers_max.set");
|
||||
CMD2_REDIRECT ("d.set_peers_min", "d.peers_min.set");
|
||||
CMD2_REDIRECT ("d.set_priority", "d.priority.set");
|
||||
CMD2_REDIRECT ("d.set_throttle_name", "d.throttle_name.set");
|
||||
CMD2_REDIRECT ("d.set_tied_to_file", "d.tied_to_file.set");
|
||||
CMD2_REDIRECT ("d.set_tracker_numwant", "d.tracker_numwant.set");
|
||||
CMD2_REDIRECT ("d.set_uploads_max", "d.uploads_max.set");
|
||||
|
||||
CMD2_REDIRECT ("create_link", "d.create_link");
|
||||
CMD2_REDIRECT ("delete_link", "d.delete_link");
|
||||
CMD2_REDIRECT ("delete_tied", "d.delete_tied");
|
||||
|
||||
//
|
||||
// Tracker:
|
||||
//
|
||||
|
||||
CMD2_REDIRECT_TRACKER("t.get_group", "t.group");
|
||||
CMD2_REDIRECT_TRACKER("t.get_id", "t.id");
|
||||
CMD2_REDIRECT_TRACKER("t.get_min_interval", "t.min_interval");
|
||||
CMD2_REDIRECT_TRACKER("t.get_normal_interval", "t.normal_interval");
|
||||
CMD2_REDIRECT_TRACKER("t.get_scrape_complete", "t.scrape_complete");
|
||||
CMD2_REDIRECT_TRACKER("t.get_scrape_downloaded", "t.scrape_downloaded");
|
||||
CMD2_REDIRECT_TRACKER("t.get_scrape_incomplete", "t.scrape_incomplete");
|
||||
CMD2_REDIRECT_TRACKER("t.get_scrape_time_last", "t.scrape_time_last");
|
||||
CMD2_REDIRECT_TRACKER("t.get_type", "t.type");
|
||||
CMD2_REDIRECT_TRACKER("t.get_url", "t.url");
|
||||
CMD2_REDIRECT_TRACKER("t.set_enabled", "t.is_enabled.set");
|
||||
|
||||
//
|
||||
// File:
|
||||
//
|
||||
|
||||
CMD2_REDIRECT_FILE ("f.get_completed_chunks", "f.completed_chunks");
|
||||
CMD2_REDIRECT_FILE ("f.get_frozen_path", "f.frozen_path");
|
||||
CMD2_REDIRECT_FILE ("f.get_last_touched", "f.last_touched");
|
||||
CMD2_REDIRECT_FILE ("f.get_match_depth_next", "f.match_depth_next");
|
||||
CMD2_REDIRECT_FILE ("f.get_match_depth_prev", "f.match_depth_prev");
|
||||
CMD2_REDIRECT_FILE ("f.get_offset", "f.offset");
|
||||
CMD2_REDIRECT_FILE ("f.get_path", "f.path");
|
||||
CMD2_REDIRECT_FILE ("f.get_path_components", "f.path_components");
|
||||
CMD2_REDIRECT_FILE ("f.get_path_depth", "f.path_depth");
|
||||
CMD2_REDIRECT_FILE ("f.get_priority", "f.priority");
|
||||
CMD2_REDIRECT_FILE ("f.get_range_first", "f.range_first");
|
||||
CMD2_REDIRECT_FILE ("f.get_range_second", "f.range_second");
|
||||
CMD2_REDIRECT_FILE ("f.get_size_bytes", "f.size_bytes");
|
||||
CMD2_REDIRECT_FILE ("f.get_size_chunks", "f.size_chunks");
|
||||
CMD2_REDIRECT_FILE ("f.set_priority", "f.priority.set");
|
||||
CMD2_REDIRECT_FILE ("fi.get_filename_last", "fi.filename_last");
|
||||
|
||||
//
|
||||
// Peer:
|
||||
//
|
||||
|
||||
CMD2_REDIRECT ("p.get_address", "p.address");
|
||||
CMD2_REDIRECT ("p.get_client_version", "p.client_version");
|
||||
CMD2_REDIRECT ("p.get_completed_percent", "p.completed_percent");
|
||||
CMD2_REDIRECT ("p.get_down_rate", "p.down_rate");
|
||||
CMD2_REDIRECT ("p.get_down_total", "p.down_total");
|
||||
CMD2_REDIRECT ("p.get_id", "p.id");
|
||||
CMD2_REDIRECT ("p.get_id_html", "p.id_html");
|
||||
CMD2_REDIRECT ("p.get_options_str", "p.options_str");
|
||||
CMD2_REDIRECT ("p.get_peer_rate", "p.peer_rate");
|
||||
CMD2_REDIRECT ("p.get_peer_total", "p.peer_total");
|
||||
CMD2_REDIRECT ("p.get_port", "p.port");
|
||||
CMD2_REDIRECT ("p.get_up_rate", "p.up_rate");
|
||||
CMD2_REDIRECT ("p.get_up_total", "p.up_total");
|
||||
|
||||
//
|
||||
// View:
|
||||
//
|
||||
|
||||
CMD2_REDIRECT_GENERIC("view_add", "view.add");
|
||||
CMD2_REDIRECT_GENERIC("view_filter", "view.filter");
|
||||
CMD2_REDIRECT_GENERIC("view_filter_on", "view.filter_on");
|
||||
CMD2_REDIRECT_GENERIC("view_list", "view.list");
|
||||
CMD2_REDIRECT_GENERIC("view_set", "view.set");
|
||||
CMD2_REDIRECT_GENERIC("view_sort", "view.sort");
|
||||
CMD2_REDIRECT_GENERIC("view_sort_current", "view.sort_current");
|
||||
CMD2_REDIRECT_GENERIC("view_sort_new", "view.sort_new");
|
||||
|
||||
// Rename these to avoid conflicts with old style.
|
||||
CMD2_REDIRECT_GENERIC("d.multicall", "d.multicall2");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("to_gm_time", "convert.gm_time");
|
||||
CMD2_REDIRECT_GENERIC("to_gm_date", "convert.gm_date");
|
||||
CMD2_REDIRECT_GENERIC("to_time", "convert.time");
|
||||
CMD2_REDIRECT_GENERIC("to_date", "convert.date");
|
||||
CMD2_REDIRECT_GENERIC("to_elapsed_time", "convert.elapsed_time");
|
||||
CMD2_REDIRECT_GENERIC("to_kb", "convert.kb");
|
||||
CMD2_REDIRECT_GENERIC("to_mb", "convert.mb");
|
||||
CMD2_REDIRECT_GENERIC("to_xb", "convert.xb");
|
||||
CMD2_REDIRECT_GENERIC("to_throttle", "convert.throttle");
|
||||
|
||||
CMD2_REDIRECT_GENERIC("execute_throw", "execute.throw");
|
||||
CMD2_REDIRECT_GENERIC("execute_nothrow", "execute.nothrow");
|
||||
CMD2_REDIRECT_GENERIC("execute_raw", "execute.raw");
|
||||
CMD2_REDIRECT_GENERIC("execute_raw_nothrow", "execute.raw_nothrow");
|
||||
CMD2_REDIRECT_GENERIC("execute_capture", "execute.capture");
|
||||
CMD2_REDIRECT_GENERIC("execute_capture_nothrow", "execute.capture_nothrow");
|
||||
}
|
||||
#endif
|
||||
|
||||
int firstArg = parse_options(control, argc, argv);
|
||||
int firstArg = parse_options(argc, argv);
|
||||
|
||||
if (OptionParser::has_flag('n', argc, argv)) {
|
||||
lt_log_print(torrent::LOG_WARN, "Ignoring ~/.rtorrent.rc.");
|
||||
lt_log_print(torrent::LOG_WARN, "Ignoring rtorrent.rc.");
|
||||
} else {
|
||||
rpc::parse_command_single(rpc::make_target(), "try_import = ~/.rtorrent.rc");
|
||||
char* config_dir = std::getenv("XDG_CONFIG_HOME");
|
||||
char* home_dir = std::getenv("HOME");
|
||||
|
||||
if (config_dir != NULL && config_dir[0] == '/' &&
|
||||
access((std::string(config_dir) + "/rtorrent/rtorrent.rc").c_str(), F_OK) != -1) {
|
||||
rpc::parse_command_single(rpc::make_target(), "try_import = " + std::string(config_dir) + "/rtorrent/rtorrent.rc");
|
||||
} else if (home_dir != NULL && access((std::string(home_dir) + "/.config/rtorrent/rtorrent.rc").c_str(), F_OK) != -1) {
|
||||
rpc::parse_command_single(rpc::make_target(), "try_import = ~/.config/rtorrent/rtorrent.rc");
|
||||
} else {
|
||||
rpc::parse_command_single(rpc::make_target(), "try_import = ~/.rtorrent.rc");
|
||||
}
|
||||
}
|
||||
|
||||
control->initialize();
|
||||
@@ -841,10 +464,10 @@ main(int argc, char** argv) {
|
||||
// Load session torrents and perform scheduled tasks to ensure
|
||||
// session torrents are loaded before arg torrents.
|
||||
control->dht_manager()->load_dht_cache();
|
||||
load_session_torrents(control);
|
||||
load_session_torrents();
|
||||
rak::priority_queue_perform(&taskScheduler, cachedTime);
|
||||
|
||||
load_arg_torrents(control, argv + firstArg, argv + argc);
|
||||
load_arg_torrents(argv + firstArg, argv + argc);
|
||||
|
||||
// Make sure we update the display before any scheduled tasks can
|
||||
// run, so that loading of torrents doesn't look like it hangs on
|
||||
@@ -1002,8 +625,9 @@ print_help() {
|
||||
std::cout << "order. Use the up/down/left/right arrow keys to move between screens." << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "Usage: rtorrent [OPTIONS]... [FILE]... [URL]..." << std::endl;
|
||||
std::cout << " -D Enable deprecated commands" << std::endl;
|
||||
std::cout << " -h Display this very helpful text" << std::endl;
|
||||
std::cout << " -n Don't try to load ~/.rtorrent.rc on startup" << std::endl;
|
||||
std::cout << " -n Don't try to load rtorrent.rc on startup" << std::endl;
|
||||
std::cout << " -b <a.b.c.d> Bind the listening socket to this IP" << std::endl;
|
||||
std::cout << " -i <a.b.c.d> Change the IP that is sent to the tracker" << std::endl;
|
||||
std::cout << " -p <int>-<int> Set port range for incoming connections" << std::endl;
|
||||
@@ -1016,6 +640,7 @@ print_help() {
|
||||
std::cout << " ^s Start torrent" << std::endl;
|
||||
std::cout << " ^d Stop torrent or delete a stopped torrent" << std::endl;
|
||||
std::cout << " ^r Manually initiate hash checking" << std::endl;
|
||||
std::cout << " ^o Change the destination directory of the download. The torrent must be closed." << std::endl;
|
||||
std::cout << " ^q Initiate shutdown or skip shutdown process" << std::endl;
|
||||
std::cout << " a,s,d,z,x,c Adjust upload throttle" << std::endl;
|
||||
std::cout << " A,S,D,Z,X,C Adjust download throttle" << std::endl;
|
||||
|
||||
@@ -60,13 +60,13 @@ OptionParser::insert_option(char c, slot_string s) {
|
||||
|
||||
void
|
||||
OptionParser::insert_option_list(char c, slot_string_pair s) {
|
||||
m_container[c].m_slot = std::tr1::bind(&OptionParser::call_option_list, s, std::tr1::placeholders::_1);
|
||||
m_container[c].m_slot = std::bind(&OptionParser::call_option_list, s, std::placeholders::_1);
|
||||
m_container[c].m_useOption = true;
|
||||
}
|
||||
|
||||
void
|
||||
OptionParser::insert_int_pair(char c, slot_int_pair s) {
|
||||
m_container[c].m_slot = std::tr1::bind(&OptionParser::call_int_pair, s, std::tr1::placeholders::_1);
|
||||
m_container[c].m_slot = std::bind(&OptionParser::call_int_pair, s, std::placeholders::_1);
|
||||
m_container[c].m_useOption = true;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -39,15 +39,15 @@
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
|
||||
// Throws std::runtime_error upon receiving bad input.
|
||||
|
||||
class OptionParser {
|
||||
public:
|
||||
typedef std::tr1::function<void (const std::string&)> slot_string;
|
||||
typedef std::tr1::function<void (const std::string&, const std::string&)> slot_string_pair;
|
||||
typedef std::tr1::function<void (int, int)> slot_int_pair;
|
||||
typedef std::function<void (const std::string&)> slot_string;
|
||||
typedef std::function<void (const std::string&, const std::string&)> slot_string_pair;
|
||||
typedef std::function<void (int, int)> slot_int_pair;
|
||||
|
||||
void insert_flag(char c, slot_string s);
|
||||
void insert_option(char c, slot_string s);
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ command_base_call_value_base(command_base* rawCommand, target_type target, const
|
||||
return command_base::_call<typename command_value_function<T>::type, T>(rawCommand, target, val);
|
||||
}
|
||||
|
||||
return command_base::_call<typename command_value_function<T>::type, T>(rawCommand, target, arg.as_value());
|
||||
return command_base::_call<typename command_value_function<T>::type, T>(rawCommand, target, unit * arg.as_value());
|
||||
}
|
||||
|
||||
template <typename T> const torrent::Object
|
||||
|
||||
+3
-5
@@ -41,14 +41,12 @@
|
||||
#include <limits>
|
||||
#include <inttypes.h>
|
||||
#include <torrent/object.h>
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
|
||||
#include <torrent/object.h>
|
||||
#include <torrent/data/file_list_iterator.h>
|
||||
|
||||
// Move into config.h or something.
|
||||
namespace tr1 { using namespace std::tr1; }
|
||||
|
||||
namespace core {
|
||||
class Download;
|
||||
}
|
||||
@@ -111,7 +109,7 @@ typedef rt_triple<int, void*, void*> target_type;
|
||||
class command_base;
|
||||
|
||||
typedef const torrent::Object (*command_base_call_type)(command_base*, target_type, const torrent::Object&);
|
||||
typedef tr1::function<torrent::Object (target_type, const torrent::Object&)> base_function;
|
||||
typedef std::function<torrent::Object (target_type, const torrent::Object&)> base_function;
|
||||
|
||||
template <typename tmpl> struct command_base_is_valid {};
|
||||
template <command_base_call_type tmpl_func> struct command_base_is_type {};
|
||||
@@ -250,7 +248,7 @@ command_base::_call(command_base* cmd, target_type target, Args args) {
|
||||
}
|
||||
|
||||
#define COMMAND_BASE_TEMPLATE_TYPE(func_type, func_parm) \
|
||||
template <typename T, int proper = target_type_id<T>::proper_type> struct func_type { typedef tr1::function<func_parm> type; }; \
|
||||
template <typename T, int proper = target_type_id<T>::proper_type> struct func_type { typedef std::function<func_parm> type; }; \
|
||||
\
|
||||
template <> struct command_base_is_valid<func_type<target_type>::type> { static const int value = 1; }; \
|
||||
template <> struct command_base_is_valid<func_type<core::Download*>::type> { static const int value = 1; }; \
|
||||
|
||||
@@ -71,7 +71,7 @@ CommandScheduler::insert(const std::string& key) {
|
||||
delete *itr;
|
||||
|
||||
*itr = new CommandSchedulerItem(key);
|
||||
(*itr)->slot() = std::tr1::bind(&CommandScheduler::call_item, this, *itr);
|
||||
(*itr)->slot() = std::bind(&CommandScheduler::call_item, this, *itr);
|
||||
|
||||
return itr;
|
||||
}
|
||||
|
||||
@@ -39,14 +39,14 @@
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
#include <torrent/object.h>
|
||||
|
||||
namespace rpc {
|
||||
|
||||
class CommandSchedulerItem {
|
||||
public:
|
||||
typedef std::tr1::function<void ()> slot_void;
|
||||
typedef std::function<void ()> slot_void;
|
||||
|
||||
CommandSchedulerItem(const std::string& key) : m_key(key), m_interval(0) {}
|
||||
~CommandSchedulerItem();
|
||||
|
||||
@@ -50,6 +50,14 @@
|
||||
|
||||
namespace rpc {
|
||||
|
||||
const unsigned int ExecFile::max_args;
|
||||
const unsigned int ExecFile::buffer_size;
|
||||
|
||||
const int ExecFile::flag_expand_tilde;
|
||||
const int ExecFile::flag_throw;
|
||||
const int ExecFile::flag_capture;
|
||||
const int ExecFile::flag_background;
|
||||
|
||||
// Close m_logFd.
|
||||
|
||||
int
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
namespace rpc {
|
||||
|
||||
typedef torrent::extents<uint32_t, int, 32, 256, 8> ipv4_table;
|
||||
typedef torrent::extents<uint32_t, int> ipv4_table;
|
||||
|
||||
struct ip_table_node {
|
||||
std::string name;
|
||||
|
||||
@@ -44,6 +44,23 @@
|
||||
|
||||
namespace rpc {
|
||||
|
||||
const unsigned int object_storage::flag_generic_type;
|
||||
const unsigned int object_storage::flag_bool_type;
|
||||
const unsigned int object_storage::flag_value_type;
|
||||
const unsigned int object_storage::flag_string_type;
|
||||
const unsigned int object_storage::flag_list_type;
|
||||
const unsigned int object_storage::flag_function_type;
|
||||
const unsigned int object_storage::flag_multi_type;
|
||||
|
||||
const unsigned int object_storage::mask_type;
|
||||
|
||||
const unsigned int object_storage::flag_constant;
|
||||
const unsigned int object_storage::flag_static;
|
||||
const unsigned int object_storage::flag_private;
|
||||
const unsigned int object_storage::flag_rlookup;
|
||||
|
||||
const size_t object_storage::key_size;
|
||||
|
||||
object_storage::local_iterator
|
||||
object_storage::find_local(const torrent::raw_string& key) {
|
||||
std::size_t n = hash_fixed_key_type::hash(key.data(), key.size()) % bucket_count();
|
||||
@@ -245,7 +262,7 @@ object_storage::rlookup_list(const std::string& cmd_key) {
|
||||
|
||||
if (r_itr != m_rlookup.end())
|
||||
std::transform(r_itr->second.begin(), r_itr->second.end(), std::back_inserter(result),
|
||||
std::tr1::bind(&key_type::c_str, std::tr1::bind(rak::mem_ptr(&value_type::first), std::tr1::placeholders::_1)));
|
||||
std::bind(&key_type::c_str, std::bind(rak::mem_ptr(&value_type::first), std::placeholders::_1)));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#define RTORRENT_RPC_OBJECT_STORAGE_H
|
||||
|
||||
#include <cstring>
|
||||
#include <tr1/unordered_map>
|
||||
#include lt_tr1_unordered_map
|
||||
#include <torrent/object.h>
|
||||
|
||||
#include "rak/unordered_vector.h"
|
||||
@@ -56,7 +56,7 @@ struct object_storage_node {
|
||||
char flags;
|
||||
};
|
||||
|
||||
typedef std::tr1::unordered_map<fixed_key_type<64>, object_storage_node, hash_fixed_key_type> object_storage_base_type;
|
||||
typedef std::unordered_map<fixed_key_type<64>, object_storage_node, hash_fixed_key_type> object_storage_base_type;
|
||||
|
||||
class object_storage : private object_storage_base_type {
|
||||
public:
|
||||
|
||||
@@ -142,7 +142,7 @@ parse_command(target_type target, const char* first, const char* last) {
|
||||
first = std::find_if(first, last, std::not1(command_map_is_space()));
|
||||
|
||||
if (first == last || *first != '=')
|
||||
throw torrent::input_error("Could not find '='.");
|
||||
throw torrent::input_error("Could not find '=' in command '" + std::string(key) + "'.");
|
||||
|
||||
torrent::Object args;
|
||||
first = parse_whole_list(first + 1, last, &args, &parse_is_delim_command);
|
||||
|
||||
+6
-6
@@ -37,7 +37,7 @@
|
||||
#ifndef RTORRENT_RPC_XMLRPC_H
|
||||
#define RTORRENT_RPC_XMLRPC_H
|
||||
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
#include <torrent/hash_string.h>
|
||||
|
||||
namespace core {
|
||||
@@ -54,11 +54,11 @@ namespace rpc {
|
||||
|
||||
class XmlRpc {
|
||||
public:
|
||||
typedef std::tr1::function<core::Download* (const char*)> slot_download;
|
||||
typedef std::tr1::function<torrent::File* (core::Download*, uint32_t)> slot_file;
|
||||
typedef std::tr1::function<torrent::Tracker* (core::Download*, uint32_t)> slot_tracker;
|
||||
typedef std::tr1::function<torrent::Peer* (core::Download*, const torrent::HashString&)> slot_peer;
|
||||
typedef std::tr1::function<bool (const char*, uint32_t)> slot_write;
|
||||
typedef std::function<core::Download* (const char*)> slot_download;
|
||||
typedef std::function<torrent::File* (core::Download*, uint32_t)> slot_file;
|
||||
typedef std::function<torrent::Tracker* (core::Download*, uint32_t)> slot_tracker;
|
||||
typedef std::function<torrent::Peer* (core::Download*, const torrent::HashString&)> slot_peer;
|
||||
typedef std::function<bool (const char*, uint32_t)> slot_write;
|
||||
|
||||
static const int dialect_generic = 0;
|
||||
static const int dialect_i8 = 1;
|
||||
|
||||
+11
-2
@@ -38,6 +38,8 @@
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "rak/error_number.h"
|
||||
#include "signal_handler.h"
|
||||
|
||||
@@ -74,8 +76,15 @@ SignalHandler::set_handler(unsigned int signum, slot_void slot) {
|
||||
if (!slot)
|
||||
throw std::logic_error("SignalHandler::set_handler(...) received an empty slot.");
|
||||
|
||||
signal(signum, &SignalHandler::caught);
|
||||
m_handlers[signum] = slot;
|
||||
struct sigaction sa;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = SA_RESTART;
|
||||
sa.sa_handler = &SignalHandler::caught;
|
||||
|
||||
if (sigaction(signum, &sa, NULL) == -1)
|
||||
throw std::logic_error("Could not set sigaction: " + std::string(rak::error_number::current().c_str()));
|
||||
else
|
||||
m_handlers[signum] = slot;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -38,11 +38,11 @@
|
||||
#define RTORRENT_SIGNAL_HANDLER_H
|
||||
|
||||
#include <signal.h>
|
||||
#include <tr1/functional>
|
||||
#include lt_tr1_functional
|
||||
|
||||
class SignalHandler {
|
||||
public:
|
||||
typedef std::tr1::function<void ()> slot_void;
|
||||
typedef std::function<void ()> slot_void;
|
||||
|
||||
// typedef void (*handler_slot)(int, siginfo_t *info, ucontext_t *uap);
|
||||
typedef void (*handler_slot)(int, siginfo_t*, void*);
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ public:
|
||||
void throw_shutdown_exception() { throw torrent::shutdown_exception(); }
|
||||
|
||||
ThreadBase::ThreadBase() {
|
||||
m_taskShutdown.slot() = std::tr1::bind(&throw_shutdown_exception);
|
||||
m_taskShutdown.slot() = std::bind(&throw_shutdown_exception);
|
||||
|
||||
m_threadQueue = new thread_queue_hack;
|
||||
}
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public:
|
||||
ThreadWorker();
|
||||
~ThreadWorker();
|
||||
|
||||
const char* name() const { return "worker_rtorrent"; }
|
||||
const char* name() const { return "rtorrent scgi"; }
|
||||
|
||||
virtual void init_thread();
|
||||
|
||||
|
||||
+52
-52
@@ -84,13 +84,13 @@ Download::Download(core::Download* d) :
|
||||
m_uiArray[DISPLAY_CHUNKS_SEEN] = new ElementChunksSeen(d);
|
||||
m_uiArray[DISPLAY_TRANSFER_LIST] = new ElementTransferList(d);
|
||||
|
||||
m_uiArray[DISPLAY_MENU]->slot_exit(std::tr1::bind(&slot_type::operator(), &m_slot_exit));
|
||||
m_uiArray[DISPLAY_PEER_LIST]->slot_exit(std::tr1::bind(&Download::activate_display_menu, this, DISPLAY_PEER_LIST));
|
||||
m_uiArray[DISPLAY_INFO]->slot_exit(std::tr1::bind(&Download::activate_display_menu, this, DISPLAY_INFO));
|
||||
m_uiArray[DISPLAY_FILE_LIST]->slot_exit(std::tr1::bind(&Download::activate_display_menu, this, DISPLAY_FILE_LIST));
|
||||
m_uiArray[DISPLAY_TRACKER_LIST]->slot_exit(std::tr1::bind(&Download::activate_display_menu, this, DISPLAY_TRACKER_LIST));
|
||||
m_uiArray[DISPLAY_CHUNKS_SEEN]->slot_exit(std::tr1::bind(&Download::activate_display_menu, this, DISPLAY_CHUNKS_SEEN));
|
||||
m_uiArray[DISPLAY_TRANSFER_LIST]->slot_exit(std::tr1::bind(&Download::activate_display_menu, this, DISPLAY_TRANSFER_LIST));
|
||||
m_uiArray[DISPLAY_MENU]->slot_exit(std::bind(&slot_type::operator(), &m_slot_exit));
|
||||
m_uiArray[DISPLAY_PEER_LIST]->slot_exit(std::bind(&Download::activate_display_menu, this, DISPLAY_PEER_LIST));
|
||||
m_uiArray[DISPLAY_INFO]->slot_exit(std::bind(&Download::activate_display_menu, this, DISPLAY_INFO));
|
||||
m_uiArray[DISPLAY_FILE_LIST]->slot_exit(std::bind(&Download::activate_display_menu, this, DISPLAY_FILE_LIST));
|
||||
m_uiArray[DISPLAY_TRACKER_LIST]->slot_exit(std::bind(&Download::activate_display_menu, this, DISPLAY_TRACKER_LIST));
|
||||
m_uiArray[DISPLAY_CHUNKS_SEEN]->slot_exit(std::bind(&Download::activate_display_menu, this, DISPLAY_CHUNKS_SEEN));
|
||||
m_uiArray[DISPLAY_TRANSFER_LIST]->slot_exit(std::bind(&Download::activate_display_menu, this, DISPLAY_TRANSFER_LIST));
|
||||
|
||||
bind_keys();
|
||||
}
|
||||
@@ -109,30 +109,30 @@ Download::create_menu() {
|
||||
ElementMenu* element = new ElementMenu;
|
||||
|
||||
element->push_back("Peer list",
|
||||
std::tr1::bind(&Download::activate_display_focus, this, DISPLAY_PEER_LIST),
|
||||
std::tr1::bind(&Download::activate_display_menu, this, DISPLAY_PEER_LIST));
|
||||
std::bind(&Download::activate_display_focus, this, DISPLAY_PEER_LIST),
|
||||
std::bind(&Download::activate_display_menu, this, DISPLAY_PEER_LIST));
|
||||
element->push_back("Info",
|
||||
std::tr1::bind(&Download::activate_display_focus, this, DISPLAY_INFO),
|
||||
std::tr1::bind(&Download::activate_display_menu, this, DISPLAY_INFO));
|
||||
std::bind(&Download::activate_display_focus, this, DISPLAY_INFO),
|
||||
std::bind(&Download::activate_display_menu, this, DISPLAY_INFO));
|
||||
element->push_back("File list",
|
||||
std::tr1::bind(&Download::activate_display_focus, this, DISPLAY_FILE_LIST),
|
||||
std::tr1::bind(&Download::activate_display_menu, this, DISPLAY_FILE_LIST));
|
||||
std::bind(&Download::activate_display_focus, this, DISPLAY_FILE_LIST),
|
||||
std::bind(&Download::activate_display_menu, this, DISPLAY_FILE_LIST));
|
||||
element->push_back("Tracker list",
|
||||
std::tr1::bind(&Download::activate_display_focus, this, DISPLAY_TRACKER_LIST),
|
||||
std::tr1::bind(&Download::activate_display_menu, this, DISPLAY_TRACKER_LIST));
|
||||
std::bind(&Download::activate_display_focus, this, DISPLAY_TRACKER_LIST),
|
||||
std::bind(&Download::activate_display_menu, this, DISPLAY_TRACKER_LIST));
|
||||
element->push_back("Chunks seen",
|
||||
std::tr1::bind(&Download::activate_display_focus, this, DISPLAY_CHUNKS_SEEN),
|
||||
std::tr1::bind(&Download::activate_display_menu, this, DISPLAY_CHUNKS_SEEN));
|
||||
std::bind(&Download::activate_display_focus, this, DISPLAY_CHUNKS_SEEN),
|
||||
std::bind(&Download::activate_display_menu, this, DISPLAY_CHUNKS_SEEN));
|
||||
element->push_back("Transfer list",
|
||||
std::tr1::bind(&Download::activate_display_focus, this, DISPLAY_TRANSFER_LIST),
|
||||
std::tr1::bind(&Download::activate_display_menu, this, DISPLAY_TRANSFER_LIST));
|
||||
std::bind(&Download::activate_display_focus, this, DISPLAY_TRANSFER_LIST),
|
||||
std::bind(&Download::activate_display_menu, this, DISPLAY_TRANSFER_LIST));
|
||||
|
||||
element->set_entry(0, false);
|
||||
|
||||
m_bindings['p'] = std::tr1::bind(&ElementMenu::set_entry_trigger, element, 0);
|
||||
m_bindings['o'] = std::tr1::bind(&ElementMenu::set_entry_trigger, element, 1);
|
||||
m_bindings['i'] = std::tr1::bind(&ElementMenu::set_entry_trigger, element, 2);
|
||||
m_bindings['u'] = std::tr1::bind(&ElementMenu::set_entry_trigger, element, 3);
|
||||
m_bindings['p'] = std::bind(&ElementMenu::set_entry_trigger, element, 0);
|
||||
m_bindings['o'] = std::bind(&ElementMenu::set_entry_trigger, element, 1);
|
||||
m_bindings['i'] = std::bind(&ElementMenu::set_entry_trigger, element, 2);
|
||||
m_bindings['u'] = std::bind(&ElementMenu::set_entry_trigger, element, 3);
|
||||
|
||||
return element;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ Download::create_info() {
|
||||
element->push_column("Upload:", te_command("cat=$convert.kb=$d.up.rate=,\" KB / \",$convert.xb=$d.up.total="));
|
||||
element->push_column("Download:", te_command("cat=$convert.kb=$d.down.rate=,\" KB / \",$convert.xb=$d.down.total="));
|
||||
element->push_column("Skipped:", te_command("cat=$convert.kb=$d.skip.rate=,\" KB / \",$convert.xb=$d.skip.total="));
|
||||
element->push_column("Preload:", te_command("cat=$pieces.preload.type=,\" / \",$pieces.stats_preloaded=,\" / \",$pieces.stats_preloaded="));
|
||||
element->push_column("Preload:", te_command("cat=$pieces.preload.type=,\" / \",$pieces.stats_preloaded=,\" / \",$pieces.stats_not_preloaded="));
|
||||
|
||||
element->set_column_width(element->column_width() + 1);
|
||||
|
||||
@@ -375,40 +375,40 @@ Download::adjust_up_throttle(int throttle) {
|
||||
|
||||
void
|
||||
Download::bind_keys() {
|
||||
m_bindings['1'] = std::tr1::bind(&Download::receive_min_uploads, this, -1);
|
||||
m_bindings['2'] = std::tr1::bind(&Download::receive_min_uploads, this, 1);
|
||||
m_bindings['3'] = std::tr1::bind(&Download::receive_max_uploads, this, -1);
|
||||
m_bindings['4'] = std::tr1::bind(&Download::receive_max_uploads, this, 1);
|
||||
m_bindings['!'] = std::tr1::bind(&Download::receive_min_downloads, this, -1);
|
||||
m_bindings['@'] = std::tr1::bind(&Download::receive_min_downloads, this, 1);
|
||||
m_bindings['#'] = std::tr1::bind(&Download::receive_max_downloads, this, -1);
|
||||
m_bindings['$'] = std::tr1::bind(&Download::receive_max_downloads, this, 1);
|
||||
m_bindings['5'] = std::tr1::bind(&Download::receive_min_peers, this, -5);
|
||||
m_bindings['6'] = std::tr1::bind(&Download::receive_min_peers, this, 5);
|
||||
m_bindings['7'] = std::tr1::bind(&Download::receive_max_peers, this, -5);
|
||||
m_bindings['8'] = std::tr1::bind(&Download::receive_max_peers, this, 5);
|
||||
m_bindings['+'] = std::tr1::bind(&Download::receive_next_priority, this);
|
||||
m_bindings['-'] = std::tr1::bind(&Download::receive_prev_priority, this);
|
||||
m_bindings['1'] = std::bind(&Download::receive_min_uploads, this, -1);
|
||||
m_bindings['2'] = std::bind(&Download::receive_min_uploads, this, 1);
|
||||
m_bindings['3'] = std::bind(&Download::receive_max_uploads, this, -1);
|
||||
m_bindings['4'] = std::bind(&Download::receive_max_uploads, this, 1);
|
||||
m_bindings['!'] = std::bind(&Download::receive_min_downloads, this, -1);
|
||||
m_bindings['@'] = std::bind(&Download::receive_min_downloads, this, 1);
|
||||
m_bindings['#'] = std::bind(&Download::receive_max_downloads, this, -1);
|
||||
m_bindings['$'] = std::bind(&Download::receive_max_downloads, this, 1);
|
||||
m_bindings['5'] = std::bind(&Download::receive_min_peers, this, -5);
|
||||
m_bindings['6'] = std::bind(&Download::receive_min_peers, this, 5);
|
||||
m_bindings['7'] = std::bind(&Download::receive_max_peers, this, -5);
|
||||
m_bindings['8'] = std::bind(&Download::receive_max_peers, this, 5);
|
||||
m_bindings['+'] = std::bind(&Download::receive_next_priority, this);
|
||||
m_bindings['-'] = std::bind(&Download::receive_prev_priority, this);
|
||||
|
||||
m_bindings['t'] = std::tr1::bind(&torrent::Download::manual_request, m_download->download(), false);
|
||||
m_bindings['T'] = std::tr1::bind(&torrent::Download::manual_request, m_download->download(), true);
|
||||
m_bindings['t'] = std::bind(&torrent::Download::manual_request, m_download->download(), false);
|
||||
m_bindings['T'] = std::bind(&torrent::Download::manual_request, m_download->download(), true);
|
||||
|
||||
const char* keys = control->ui()->get_throttle_keys();
|
||||
|
||||
m_bindings[keys[ 0]] = std::tr1::bind(&Download::adjust_up_throttle, this, 1);
|
||||
m_bindings[keys[ 1]] = std::tr1::bind(&Download::adjust_up_throttle, this, -1);
|
||||
m_bindings[keys[ 2]] = std::tr1::bind(&Download::adjust_down_throttle, this, 1);
|
||||
m_bindings[keys[ 3]] = std::tr1::bind(&Download::adjust_down_throttle, this, -1);
|
||||
m_bindings[keys[ 0]] = std::bind(&Download::adjust_up_throttle, this, 1);
|
||||
m_bindings[keys[ 1]] = std::bind(&Download::adjust_up_throttle, this, -1);
|
||||
m_bindings[keys[ 2]] = std::bind(&Download::adjust_down_throttle, this, 1);
|
||||
m_bindings[keys[ 3]] = std::bind(&Download::adjust_down_throttle, this, -1);
|
||||
|
||||
m_bindings[keys[ 4]] = std::tr1::bind(&Download::adjust_up_throttle, this, 5);
|
||||
m_bindings[keys[ 5]] = std::tr1::bind(&Download::adjust_up_throttle, this, -5);
|
||||
m_bindings[keys[ 6]] = std::tr1::bind(&Download::adjust_down_throttle, this, 5);
|
||||
m_bindings[keys[ 7]] = std::tr1::bind(&Download::adjust_down_throttle, this, -5);
|
||||
m_bindings[keys[ 4]] = std::bind(&Download::adjust_up_throttle, this, 5);
|
||||
m_bindings[keys[ 5]] = std::bind(&Download::adjust_up_throttle, this, -5);
|
||||
m_bindings[keys[ 6]] = std::bind(&Download::adjust_down_throttle, this, 5);
|
||||
m_bindings[keys[ 7]] = std::bind(&Download::adjust_down_throttle, this, -5);
|
||||
|
||||
m_bindings[keys[ 8]] = std::tr1::bind(&Download::adjust_up_throttle, this, 50);
|
||||
m_bindings[keys[ 9]] = std::tr1::bind(&Download::adjust_up_throttle, this, -50);
|
||||
m_bindings[keys[10]] = std::tr1::bind(&Download::adjust_down_throttle, this, 50);
|
||||
m_bindings[keys[11]] = std::tr1::bind(&Download::adjust_down_throttle, this, -50);
|
||||
m_bindings[keys[ 8]] = std::bind(&Download::adjust_up_throttle, this, 50);
|
||||
m_bindings[keys[ 9]] = std::bind(&Download::adjust_up_throttle, this, -50);
|
||||
m_bindings[keys[10]] = std::bind(&Download::adjust_down_throttle, this, 50);
|
||||
m_bindings[keys[11]] = std::bind(&Download::adjust_down_throttle, this, -50);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-1
@@ -89,7 +89,8 @@ public:
|
||||
void adjust_up_throttle(int throttle);
|
||||
void adjust_down_throttle(int throttle);
|
||||
|
||||
display::Window* window() { return NULL; }
|
||||
display::Window* window() { return NULL; }
|
||||
core::Download* download() { return m_download; };
|
||||
|
||||
private:
|
||||
Download(const Download&);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user