mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-22 12:59:07 -06:00
More cleanup of Launcher
Added Infowidget
This commit is contained in:
@@ -31,12 +31,14 @@ set(application_path ${OPENSPACE_APPS_DIR}/Launcher)
|
||||
|
||||
set(SOURCE_FILES
|
||||
${application_path}/main.cpp
|
||||
${application_path}/infowidget.cpp
|
||||
${application_path}/mainwindow.cpp
|
||||
${application_path}/shortcutwidget.cpp
|
||||
${application_path}/syncwidget.cpp
|
||||
)
|
||||
|
||||
set(HEADER_FILES
|
||||
${application_path}/infowidget.h
|
||||
${application_path}/mainwindow.h
|
||||
${application_path}/shortcutwidget.h
|
||||
${application_path}/syncwidget.h
|
||||
@@ -67,35 +69,6 @@ if (APPLE)
|
||||
" COMPONENT Runtime)
|
||||
endif ()
|
||||
|
||||
# if(NOT DEFINED Boost_INCLUDE_DIR OR NOT DEFINED Boost_LIBRARIES)
|
||||
# FIND_PACKAGE( Boost COMPONENTS system thread date_time chrono)
|
||||
# endif()
|
||||
# include_directories(${Boost_INCLUDE_DIR})
|
||||
# target_link_libraries(${APPLICATION_NAME} ${Boost_LIBRARIES})
|
||||
|
||||
# Libtorrent
|
||||
add_subdirectory(${application_path}/ext/libtorrent)
|
||||
target_link_libraries(${APPLICATION_NAME} libtorrent)
|
||||
target_compile_definitions(${APPLICATION_NAME} PUBLIC BOOST_ASIO_SEPARATE_COMPILATION)
|
||||
|
||||
|
||||
# get_property(INCLUDE_DIR TARGET ${target_name} PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||
# target_link_libraries(${target_name} ${library_name})
|
||||
include_external_library(${APPLICATION_NAME} libtorrent ${application_path}/ext/libtorrent)
|
||||
target_include_directories(${APPLICATION_NAME} PUBLIC SYSTEM ${application_path}/ext/libtorrent/include)
|
||||
set_property(TARGET libtorrent PROPERTY FOLDER "External")
|
||||
if (OPENSPACE_DISABLE_EXTERNAL_WARNINGS)
|
||||
if (MSVC)
|
||||
target_compile_options(libtorrent PUBLIC "/W0" "/MP")
|
||||
else ()
|
||||
target_compile_options(libtorrent PUBLIC "-w")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# include_external_library(${APPLICATION_NAME} libtorrent ${application_path}/ext/libtorrent)
|
||||
# We have to set it manually since the libtorrent doesn't use the new system that can be queried
|
||||
# target_include_directories(${APPLICATION_NAME} PUBLIC SYSTEM ${application_path}/ext/libtorrent/include)
|
||||
|
||||
target_compile_definitions(${APPLICATION_NAME} PUBLIC BOOST_LIB_DIAGNOSTIC)
|
||||
target_compile_definitions(libtorrent PUBLIC BOOST_LIB_DIAGNOSTIC)
|
||||
|
||||
copy_files(${APPLICATION_NAME} "${CURL_ROOT_DIR}/lib/libcurl.dll")
|
||||
|
||||
@@ -4,320 +4,242 @@ set (SOVERSION "8")
|
||||
set (VERSION "1.0.5")
|
||||
|
||||
set(sources
|
||||
web_connection_base
|
||||
alert
|
||||
alert_manager
|
||||
allocator
|
||||
asio
|
||||
assert
|
||||
bandwidth_limit
|
||||
bandwidth_manager
|
||||
bandwidth_queue_entry
|
||||
bloom_filter
|
||||
chained_buffer
|
||||
connection_queue
|
||||
create_torrent
|
||||
disk_buffer_holder
|
||||
entry
|
||||
error_code
|
||||
file_storage
|
||||
lazy_bdecode
|
||||
escape_string
|
||||
string_util
|
||||
file
|
||||
gzip
|
||||
hasher
|
||||
http_connection
|
||||
http_stream
|
||||
http_parser
|
||||
i2p_stream
|
||||
identify_client
|
||||
ip_filter
|
||||
ip_voter
|
||||
peer_connection
|
||||
bt_peer_connection
|
||||
web_peer_connection
|
||||
http_seed_connection
|
||||
instantiate_connection
|
||||
natpmp
|
||||
packet_buffer
|
||||
piece_picker
|
||||
policy
|
||||
puff
|
||||
random
|
||||
rss
|
||||
session
|
||||
session_impl
|
||||
settings
|
||||
socket_io
|
||||
socket_type
|
||||
socks5_stream
|
||||
stat
|
||||
storage
|
||||
time
|
||||
timestamp_history
|
||||
torrent
|
||||
torrent_handle
|
||||
torrent_info
|
||||
tracker_manager
|
||||
http_tracker_connection
|
||||
utf8
|
||||
udp_tracker_connection
|
||||
udp_socket
|
||||
upnp
|
||||
utp_socket_manager
|
||||
utp_stream
|
||||
logger
|
||||
file_pool
|
||||
lsd
|
||||
disk_buffer_pool
|
||||
disk_io_thread
|
||||
enum_net
|
||||
broadcast_socket
|
||||
magnet_uri
|
||||
parse_url
|
||||
ConvertUTF
|
||||
thread
|
||||
xml_parse
|
||||
web_connection_base
|
||||
alert
|
||||
alert_manager
|
||||
allocator
|
||||
asio
|
||||
assert
|
||||
bandwidth_limit
|
||||
bandwidth_manager
|
||||
bandwidth_queue_entry
|
||||
bloom_filter
|
||||
chained_buffer
|
||||
connection_queue
|
||||
create_torrent
|
||||
disk_buffer_holder
|
||||
entry
|
||||
error_code
|
||||
file_storage
|
||||
lazy_bdecode
|
||||
escape_string
|
||||
string_util
|
||||
file
|
||||
gzip
|
||||
hasher
|
||||
http_connection
|
||||
http_stream
|
||||
http_parser
|
||||
i2p_stream
|
||||
identify_client
|
||||
ip_filter
|
||||
ip_voter
|
||||
peer_connection
|
||||
bt_peer_connection
|
||||
web_peer_connection
|
||||
http_seed_connection
|
||||
instantiate_connection
|
||||
natpmp
|
||||
packet_buffer
|
||||
piece_picker
|
||||
policy
|
||||
puff
|
||||
random
|
||||
rss
|
||||
session
|
||||
session_impl
|
||||
settings
|
||||
socket_io
|
||||
socket_type
|
||||
socks5_stream
|
||||
stat
|
||||
storage
|
||||
time
|
||||
timestamp_history
|
||||
torrent
|
||||
torrent_handle
|
||||
torrent_info
|
||||
tracker_manager
|
||||
http_tracker_connection
|
||||
utf8
|
||||
udp_tracker_connection
|
||||
udp_socket
|
||||
upnp
|
||||
utp_socket_manager
|
||||
utp_stream
|
||||
logger
|
||||
file_pool
|
||||
lsd
|
||||
disk_buffer_pool
|
||||
disk_io_thread
|
||||
enum_net
|
||||
broadcast_socket
|
||||
magnet_uri
|
||||
parse_url
|
||||
ConvertUTF
|
||||
thread
|
||||
xml_parse
|
||||
|
||||
# -- extensions --
|
||||
metadata_transfer
|
||||
ut_pex
|
||||
ut_metadata
|
||||
smart_ban
|
||||
lt_trackers
|
||||
metadata_transfer
|
||||
ut_pex
|
||||
ut_metadata
|
||||
smart_ban
|
||||
lt_trackers
|
||||
)
|
||||
|
||||
# -- kademlia --
|
||||
set(kademlia_sources
|
||||
dht_tracker
|
||||
node
|
||||
refresh
|
||||
rpc_manager
|
||||
find_data
|
||||
node_id
|
||||
routing_table
|
||||
traversal_algorithm
|
||||
logging
|
||||
item
|
||||
get_peers
|
||||
get_item
|
||||
dht_tracker
|
||||
node
|
||||
refresh
|
||||
rpc_manager
|
||||
find_data
|
||||
node_id
|
||||
routing_table
|
||||
traversal_algorithm
|
||||
logging
|
||||
item
|
||||
get_peers
|
||||
get_item
|
||||
)
|
||||
|
||||
# -- ed25519 --
|
||||
set(ed25519_sources
|
||||
add_scalar
|
||||
fe
|
||||
ge
|
||||
key_exchange
|
||||
keypair
|
||||
sc
|
||||
seed
|
||||
sha512
|
||||
sign
|
||||
verify
|
||||
add_scalar
|
||||
fe
|
||||
ge
|
||||
key_exchange
|
||||
keypair
|
||||
sc
|
||||
seed
|
||||
sha512
|
||||
sign
|
||||
verify
|
||||
)
|
||||
|
||||
set(includes include ed25519/src)
|
||||
|
||||
option(shared "build libtorrent as a shared library" ON)
|
||||
option(static_runtime "build libtorrent with static runtime" OFF)
|
||||
option(tcmalloc "link against google performance tools tcmalloc" OFF)
|
||||
option(pool-allocators "Uses a pool allocator for disk and piece buffers" ON)
|
||||
option(geoip "link against LGPL GeoIP code from Maxmind, to enable geoip database support" OFF)
|
||||
option(dht "enable support for Mainline DHT" ON)
|
||||
option(resolve-countries "enable support for resolving countries from peer IPs" ON)
|
||||
option(unicode "enable unicode support" ON)
|
||||
option(deprecated-functions "enable deprecated functions for backwards compatibility" ON)
|
||||
option(exceptions "build with exception support" ON)
|
||||
option(logging "build with logging" OFF)
|
||||
option(verbose-logging "build with verbose logging" OFF)
|
||||
option(LIBTORRENT_shared "build libtorrent as a shared library" ON)
|
||||
option(LIBTORRENT_pool-allocators "Uses a pool allocator for disk and piece buffers" ON)
|
||||
option(LIBTORRENT_dht "enable support for Mainline DHT" OFF)
|
||||
option(LIBTORRENT_unicode "enable unicode support" ON)
|
||||
|
||||
set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo)
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release FORCE)
|
||||
endif()
|
||||
set(CMAKE_BUILD_TYPE Release FORCE)
|
||||
endif ()
|
||||
|
||||
# add_definitions() doesn't seem to let you say wich build type to apply it to
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DTORRENT_DEBUG")
|
||||
if(UNIX)
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -g")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
||||
endif()
|
||||
if (UNIX)
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -g")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
||||
endif ()
|
||||
|
||||
include_directories(${includes})
|
||||
|
||||
add_definitions(-DTORRENT_DISABLE_ENCRYPTION)
|
||||
list(APPEND sources sha1)
|
||||
|
||||
if (logging)
|
||||
add_definitions(-DTORRENT_LOGGING)
|
||||
endif()
|
||||
if (verbose-logging)
|
||||
add_definitions(-DTORRENT_VERBOSE_LOGGING)
|
||||
endif()
|
||||
|
||||
foreach(s ${sources})
|
||||
list(APPEND sources2 src/${s})
|
||||
endforeach(s)
|
||||
list(APPEND sources2 src/${s})
|
||||
endforeach ()
|
||||
|
||||
if (dht)
|
||||
foreach(s ${kademlia_sources})
|
||||
list(APPEND sources2 src/kademlia/${s})
|
||||
endforeach(s)
|
||||
foreach(s ${ed25519_sources})
|
||||
list(APPEND sources2 ed25519/src/${s})
|
||||
endforeach(s)
|
||||
else()
|
||||
add_definitions(-DTORRENT_DISABLE_DHT)
|
||||
if (LIBTORRENT_dht)
|
||||
foreach(s ${kademlia_sources})
|
||||
list(APPEND sources2 src/kademlia/${s})
|
||||
endforeach(s)
|
||||
foreach(s ${ed25519_sources})
|
||||
list(APPEND sources2 ed25519/src/${s})
|
||||
endforeach(s)
|
||||
endif ()
|
||||
|
||||
if (LIBTORRENT_shared)
|
||||
add_definitions(-DTORRENT_BUILDING_SHARED)
|
||||
add_library(libtorrent SHARED ${sources2})
|
||||
else ()
|
||||
add_library(libtorrent STATIC ${sources2})
|
||||
endif ()
|
||||
|
||||
target_include_directories(libtorrent PUBLIC ${includes})
|
||||
target_compile_definitions(libtorrent PUBLIC
|
||||
TORRENT_DISABLE_ENCRYPTION
|
||||
TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||
TORRENT_DISABLE_GEO_IP
|
||||
BOOST_ASIO_SEPARATE_COMPILATION
|
||||
BOOST_EXCEPTION_DISABLE
|
||||
BOOST_ASIO_ENABLE_CANCELIO
|
||||
_FILE_OFFSET_BITS=64
|
||||
)
|
||||
|
||||
if (NOT LIBTORRENT_dht)
|
||||
target_compile_definitions(libtorrent PUBLIC TORRENT_DISABLE_DHT)
|
||||
endif ()
|
||||
|
||||
if (NOT LIBTORRENT_pool-allocators)
|
||||
target_compile_definitions(libtorrent PUBLIC TORRENT_DISABLE_POOL_ALLOCATOR)
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fvisibility-inlines-hidden")
|
||||
if (LIBTORRENT_unicode)
|
||||
add_definitions(-DUNICODE -D_UNICODE)
|
||||
endif()
|
||||
|
||||
if (shared)
|
||||
add_definitions(-DTORRENT_BUILDING_SHARED)
|
||||
add_library(libtorrent SHARED ${sources2})
|
||||
else (shared)
|
||||
if(static_runtime)
|
||||
# fix /MT flag:
|
||||
set(CompilerFlags
|
||||
CMAKE_CXX_FLAGS
|
||||
CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS
|
||||
CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
)
|
||||
foreach(CompilerFlag ${CompilerFlags})
|
||||
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
|
||||
endforeach()
|
||||
endif()
|
||||
add_library(libtorrent STATIC ${sources2})
|
||||
endif()
|
||||
|
||||
if (NOT MSVC)
|
||||
target_compile_options(libtorrent PUBLIC "-fvisibility=hidden" "-fvisibility-inlines-hidden")
|
||||
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fvisibility-inlines-hidden")
|
||||
endif ()
|
||||
|
||||
# Boost
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
if(NOT DEFINED Boost_INCLUDE_DIR OR NOT DEFINED Boost_LIBRARIES)
|
||||
FIND_PACKAGE( Boost COMPONENTS system thread date_time chrono)
|
||||
endif()
|
||||
include_directories(${Boost_INCLUDE_DIR})
|
||||
set(Boost_USE_STATIC_LIBS ON)
|
||||
if (NOT DEFINED Boost_INCLUDE_DIR OR NOT DEFINED Boost_LIBRARIES)
|
||||
find_package(Boost COMPONENTS system thread date_time chrono)
|
||||
endif ()
|
||||
target_include_directories(libtorrent PUBLIC ${Boost_INCLUDE_DIR})
|
||||
target_link_libraries(libtorrent ${Boost_LIBRARIES})
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(libtorrent Iphlpapi.lib)
|
||||
target_link_libraries(libtorrent wsock32 ws2_32 Iphlpapi.lib)
|
||||
target_compile_definitions(libtorrent PUBLIC "_WIN32_WINNT=0x0600")
|
||||
endif ()
|
||||
|
||||
# this works around a bug in asio in boost-1.39
|
||||
#add_definitions(-DBOOST_ASIO_HASH_MAP_BUCKETS=1021 -D__USE_W32_SOCKETS -DWIN32_LEAN_AND_MEAN )
|
||||
|
||||
# if(NOT static_runtime)
|
||||
# add_definitions(-DBOOST_ASIO_DYN_LINK -DBOOST_DATE_TIME_DYN_LINK -DBOOST_THREAD_DYN_LINK -DBOOST_SYSTEM_DYN_LINK -DBOOST_CHRONO_DYN_LINK)
|
||||
# else()
|
||||
add_definitions(-DBOOST_ASIO_SEPARATE_COMPILATION)
|
||||
# endif()
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(libtorrent wsock32 ws2_32)
|
||||
add_definitions(-D_WIN32_WINNT=0x0600)
|
||||
if (MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") # multicore compilation
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT pool-allocators)
|
||||
add_definitions(-DTORRENT_DISABLE_POOL_ALLOCATOR)
|
||||
endif()
|
||||
|
||||
if (NOT geoip)
|
||||
add_definitions(-DTORRENT_DISABLE_GEO_IP)
|
||||
endif()
|
||||
|
||||
if (NOT resolve-countries)
|
||||
add_definitions(-DTORRENT_DISABLE_RESOLVE_COUNTRIES)
|
||||
endif()
|
||||
|
||||
if (unicode)
|
||||
add_definitions(-DUNICODE -D_UNICODE)
|
||||
endif()
|
||||
|
||||
if (NOT deprecated-functions)
|
||||
add_definitions(-DTORRENT_NO_DEPRECATE)
|
||||
endif()
|
||||
|
||||
if (exceptions)
|
||||
if (MSVC)
|
||||
add_definitions(/EHsc)
|
||||
else (MSVC)
|
||||
add_definitions(-fexceptions)
|
||||
endif (MSVC)
|
||||
else()
|
||||
if (MSVC)
|
||||
add_definitions(-D_HAS_EXCEPTIONS=0)
|
||||
else (MSVC)
|
||||
add_definitions(-fno-exceptions)
|
||||
endif (MSVC)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
# disable bogus deprecation warnings on msvc8
|
||||
add_definitions(-D_SCL_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE)
|
||||
# these compiler settings just makes the compiler standard conforming
|
||||
add_definitions(/Zc:wchar_t /Zc:forScope)
|
||||
# for multi-core compilation
|
||||
add_definitions(/MP)
|
||||
target_compile_options(libtorrent PUBLIC "/EHsc" "/Zc:wchar_t" "/Zc:forScope" "/MP")
|
||||
target_compile_definitions(libtorrent PUBLIC _SCL_SECURE_NO_DEPRECATE _CRT_SECURE_NO_DEPRECATE)
|
||||
else ()
|
||||
target_compile_options(libtorrent PUBLIC "-fexceptions" "-Wno-c++11-extensions")
|
||||
endif ()
|
||||
|
||||
#$(SolutionDir)<toolset>msvc,<variant>release:<linkflags>/OPT:ICF=5
|
||||
#$(SolutionDir)<toolset>msvc,<variant>release:<linkflags>/OPT:REF
|
||||
else()
|
||||
add_definitions(-Wno-c++11-extensions)
|
||||
endif()
|
||||
|
||||
add_definitions(-D_FILE_OFFSET_BITS=64)
|
||||
add_definitions(-DBOOST_EXCEPTION_DISABLE)
|
||||
add_definitions(-DBOOST_ASIO_ENABLE_CANCELIO)
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
add_definitions(-fcolor-diagnostics)
|
||||
endif()
|
||||
|
||||
if (tcmalloc)
|
||||
target_link_libraries(libtorrent tcmalloc)
|
||||
endif()
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
target_compile_options(libtorrent PUBLIC "-fcolor-diagnostics")
|
||||
endif ()
|
||||
|
||||
set_target_properties(libtorrent PROPERTIES
|
||||
SOVERSION ${SOVERSION})
|
||||
SOVERSION ${SOVERSION})
|
||||
|
||||
get_property (COMPILETIME_OPTIONS_LIST
|
||||
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIRECTORY}
|
||||
PROPERTY COMPILE_DEFINITIONS
|
||||
)
|
||||
get_property(COMPILETIME_OPTIONS_LIST
|
||||
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIRECTORY}
|
||||
PROPERTY COMPILE_DEFINITIONS
|
||||
)
|
||||
foreach (s ${COMPILETIME_OPTIONS_LIST})
|
||||
set (COMPILETIME_OPTIONS "${COMPILETIME_OPTIONS} -D${s}")
|
||||
endforeach (s)
|
||||
set (COMPILETIME_OPTIONS "${COMPILETIME_OPTIONS} -D${s}")
|
||||
endforeach ()
|
||||
|
||||
configure_file(libtorrent-rasterbar-cmake.pc.in libtorrent-rasterbar.pc)
|
||||
|
||||
string (COMPARE EQUAL "${CMAKE_SIZEOF_VOID_P}" "8" IS64BITS)
|
||||
|
||||
if (IS64BITS AND RESPECTLIB64)
|
||||
set (LIBDIR "lib64")
|
||||
set(LIBDIR "lib64")
|
||||
else()
|
||||
set (LIBDIR "lib")
|
||||
set(LIBDIR "lib")
|
||||
endif()
|
||||
|
||||
install(TARGETS libtorrent DESTINATION ${LIBDIR})
|
||||
install(DIRECTORY include/libtorrent
|
||||
DESTINATION include
|
||||
PATTERN ".svn" EXCLUDE)
|
||||
DESTINATION include
|
||||
PATTERN ".svn" EXCLUDE)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtorrent-rasterbar.pc DESTINATION ${LIBDIR}/pkgconfig)
|
||||
|
||||
# === set up examples directory as an independent project ===
|
||||
#file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/examples)
|
||||
#configure_file(examples/run_cmake.sh.in examples/run_cmake.sh)
|
||||
# to build the examples, run examples/run_cmake.sh after building libtorrent
|
||||
|
||||
68
apps/Launcher/infowidget.cpp
Normal file
68
apps/Launcher/infowidget.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include "infowidget.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QProgressBar>
|
||||
|
||||
InfoWidget::InfoWidget(QString name, int totalBytes)
|
||||
: QWidget(nullptr)
|
||||
, _name(nullptr)
|
||||
, _bytes(nullptr)
|
||||
, _progress(nullptr)
|
||||
, _messages(nullptr)
|
||||
, _totalBytes(totalBytes)
|
||||
{
|
||||
QGridLayout* layout = new QGridLayout;
|
||||
|
||||
_name = new QLabel(name);
|
||||
layout->addWidget(_name, 0, 0);
|
||||
|
||||
_bytes = new QLabel("");
|
||||
layout->addWidget(_bytes, 0, 1);
|
||||
|
||||
_progress = new QProgressBar;
|
||||
layout->addWidget(_progress, 0, 2);
|
||||
|
||||
_messages = new QLabel("");
|
||||
layout->addWidget(_messages, 1, 0, 1, 3);
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
update(0, 0.f);
|
||||
}
|
||||
|
||||
void InfoWidget::update(int currentBytes, float progress) {
|
||||
_bytes->setText(
|
||||
QString("%1 / %2").arg(currentBytes).arg(_totalBytes)
|
||||
);
|
||||
|
||||
_progress->setValue(static_cast<int>(progress * 100));
|
||||
}
|
||||
|
||||
void InfoWidget::error(QString message) {
|
||||
_messages->setText(message);
|
||||
}
|
||||
52
apps/Launcher/infowidget.h
Normal file
52
apps/Launcher/infowidget.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __INFOWIDGET_H__
|
||||
#define __INFOWIDGET_H__
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLabel;
|
||||
class QProgressBar;
|
||||
|
||||
class InfoWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
InfoWidget(QString name, int totalBytes);
|
||||
|
||||
void update(int currentBytes, float progress);
|
||||
void error(QString message);
|
||||
|
||||
private:
|
||||
InfoWidget(const InfoWidget& rhs) = delete;
|
||||
|
||||
QLabel* _name;
|
||||
QLabel* _bytes;
|
||||
QProgressBar* _progress;
|
||||
QLabel* _messages;
|
||||
|
||||
int _totalBytes;
|
||||
};
|
||||
|
||||
#endif // __INFOWIDGET_H__
|
||||
@@ -24,9 +24,12 @@
|
||||
|
||||
#include "syncwidget.h"
|
||||
|
||||
#include "infowidget.h"
|
||||
|
||||
#include <openspace/engine/downloadmanager.h>
|
||||
|
||||
#include <ghoul/ghoul.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/filesystem/file.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/lua/ghoul_lua.h>
|
||||
@@ -38,11 +41,14 @@
|
||||
#include <QGroupBox>
|
||||
#include <QPushButton>
|
||||
#include <QString>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include <libtorrent/entry.hpp>
|
||||
#include <libtorrent/bencode.hpp>
|
||||
#include <libtorrent/session.hpp>
|
||||
#include <libtorrent/alert_types.hpp>
|
||||
|
||||
namespace {
|
||||
const int nColumns = 3;
|
||||
@@ -62,6 +68,7 @@ namespace {
|
||||
SyncWidget::SyncWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, _sceneLayout(nullptr)
|
||||
, _session(new libtorrent::session)
|
||||
{
|
||||
setFixedSize(500, 500);
|
||||
|
||||
@@ -82,15 +89,37 @@ SyncWidget::SyncWidget(QWidget* parent)
|
||||
layout->addWidget(syncButton);
|
||||
}
|
||||
|
||||
{
|
||||
QGroupBox* downloadBox = new QGroupBox;
|
||||
_downloadLayout = new QVBoxLayout;
|
||||
|
||||
downloadBox->setLayout(_downloadLayout);
|
||||
layout->addWidget(downloadBox);
|
||||
}
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
ghoul::initialize();
|
||||
openspace::DownloadManager::initialize("http://openspace.itn.liu.se/data/request", DownloadApplicationVersion);
|
||||
|
||||
libtorrent::error_code ec;
|
||||
_session->listen_on(std::make_pair(6881, 6889), ec);
|
||||
if (ec) {
|
||||
qDebug() << "Failed to open socket: " << QString::fromStdString(ec.message());
|
||||
_session = nullptr;
|
||||
return;
|
||||
}
|
||||
_session->start_upnp();
|
||||
|
||||
QTimer* timer = new QTimer(this);
|
||||
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(handleTimer()));
|
||||
timer->start(100);
|
||||
}
|
||||
|
||||
SyncWidget::~SyncWidget() {
|
||||
openspace::DownloadManager::deinitialize();
|
||||
ghoul::deinitialize();
|
||||
delete _session;
|
||||
}
|
||||
|
||||
void SyncWidget::setSceneFiles(QMap<QString, QString> sceneFiles) {
|
||||
@@ -148,28 +177,31 @@ void SyncWidget::handleFileRequest(QString module, FileRequests files) {
|
||||
void SyncWidget::handleTorrentFiles(QString module, TorrentFiles files) {
|
||||
qDebug() << "Torrent Files";
|
||||
for (const TorrentFile& f : files) {
|
||||
qDebug() << f.file;
|
||||
QString file = QString::fromStdString(absPath(fullPath(module, f.file).toStdString()));
|
||||
qDebug() << file;
|
||||
|
||||
//libtorrent::bdecode()
|
||||
|
||||
libtorrent::session s;
|
||||
libtorrent::error_code ec;
|
||||
s.listen_on(std::make_pair(6881, 6889), ec);
|
||||
libtorrent::add_torrent_params p;
|
||||
p.save_path = absPath(fullPath(module, ".").toStdString());
|
||||
qDebug() << QString::fromStdString(p.save_path);
|
||||
p.ti = new libtorrent::torrent_info(file.toStdString(), ec);
|
||||
p.name = f.file.toStdString();
|
||||
p.storage_mode = libtorrent::storage_mode_allocate;
|
||||
p.auto_managed = true;
|
||||
if (ec) {
|
||||
qDebug() << "Failed to open socket: " << QString::fromStdString(ec.message());
|
||||
return;
|
||||
qDebug() << QString::fromStdString(ec.message());
|
||||
//return;
|
||||
}
|
||||
libtorrent::torrent_handle h = _session->add_torrent(p, ec);
|
||||
if (ec) {
|
||||
qDebug() << QString::fromStdString(ec.message());
|
||||
//return;
|
||||
}
|
||||
|
||||
libtorrent::add_torrent_params p;
|
||||
p.save_path = fullPath(module, ".").toStdString();
|
||||
p.ti = new libtorrent::torrent_info(f.file.toStdString(), ec);
|
||||
if (ec) {
|
||||
qDebug() << QString::fromStdString(ec.message());
|
||||
return;
|
||||
}
|
||||
s.add_torrent(p, ec);
|
||||
if (ec) {
|
||||
qDebug() << QString::fromStdString(ec.message());
|
||||
return;
|
||||
}
|
||||
InfoWidget* w = new InfoWidget(f.file, h.status().total_done);
|
||||
_downloadLayout->addWidget(w);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,3 +312,49 @@ QStringList SyncWidget::selectedScenes() const {
|
||||
QString SyncWidget::fullPath(QString module, QString destination) const {
|
||||
return _modulesDirectory + "/" + module + "/" + destination;
|
||||
}
|
||||
|
||||
void SyncWidget::handleTimer() {
|
||||
//using namespace libtorrent;
|
||||
|
||||
//_session->post_torrent_updates();
|
||||
|
||||
//qDebug() << "Session";
|
||||
//qDebug() << "nPeers: " << _session->status().num_peers;
|
||||
//qDebug() << "===";
|
||||
|
||||
//qDebug() << "Alerts";
|
||||
//std::deque<alert*> alerts;
|
||||
//_session->pop_alerts(&alerts);
|
||||
//for (alert* a : alerts) {
|
||||
// qDebug() << QString::fromStdString(a->message());
|
||||
|
||||
// //if (a->category() == alert::status_notification) {
|
||||
// // state_update_alert* sua = static_cast<state_update_alert*>(a);
|
||||
// // for (torrent_status s )
|
||||
// //}
|
||||
//}
|
||||
//qDebug() << "===";
|
||||
|
||||
|
||||
//std::vector<torrent_handle> handles = _session->get_torrents();
|
||||
//for (torrent_handle h : handles) {
|
||||
// //qDebug() << "Name: " << QString::fromStdString(h.name());
|
||||
// //torrent_status s = h.status();
|
||||
|
||||
// //qDebug() << "Error: " << QString::fromStdString(s.error);
|
||||
|
||||
// //qDebug() << "Total Wanted: " << s.total_wanted;
|
||||
// //qDebug() << "Total Wanted Done: " << s.total_wanted_done;
|
||||
// //qDebug() << "Has Incoming: " << s.has_incoming;
|
||||
// //qDebug() << "Connect Candidates: " << s.connect_candidates;
|
||||
// //qDebug() << "Last Seen Complete: " << s.last_seen_complete;
|
||||
// //qDebug() << "List Peers: " << s.list_peers;
|
||||
// //qDebug() << "Num Pieces: " << s.num_pieces;
|
||||
// //qDebug() << "Download Rate: " << s.download_rate;
|
||||
// //qDebug() << "List Seeds: " << s.list_seeds;
|
||||
// //qDebug() << "Paused: " << s.paused;
|
||||
// //qDebug() << "Progress: " << s.progress;
|
||||
|
||||
// qDebug() << "";
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,18 @@
|
||||
|
||||
#include <QMap>
|
||||
|
||||
#include <libtorrent/torrent_handle.hpp>
|
||||
|
||||
class QBoxLayout;
|
||||
class QGridLayout;
|
||||
|
||||
class InfoWidget;
|
||||
|
||||
namespace libtorrent {
|
||||
class session;
|
||||
class torrent_handle;
|
||||
}
|
||||
|
||||
class SyncWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -42,6 +52,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void syncButtonPressed();
|
||||
void handleTimer();
|
||||
|
||||
private:
|
||||
struct DirectFile {
|
||||
@@ -74,6 +85,11 @@ private:
|
||||
QMap<QString, QString> _sceneFiles;
|
||||
QString _modulesDirectory;
|
||||
QGridLayout* _sceneLayout;
|
||||
QBoxLayout* _downloadLayout;
|
||||
|
||||
libtorrent::session* _session;
|
||||
//QMap<QString, InfoWidget*> _infoWidgetMap;
|
||||
QMap<libtorrent::torrent_handle, InfoWidget*> _infoWidgetMap;
|
||||
};
|
||||
|
||||
#endif // __SYNCWIDGET_H__
|
||||
|
||||
@@ -7,7 +7,7 @@ return {
|
||||
|
||||
-- Sets the scene that is to be loaded by OpenSpace. A scene file is a description
|
||||
-- of all entities that will be visible during an instance of OpenSpace
|
||||
Scene = "${OPENSPACE_DATA}/scene/default_nh.scene",
|
||||
Scene = "${OPENSPACE_DATA}/scene/default.scene",
|
||||
|
||||
Paths = {
|
||||
SGCT = "${BASE_PATH}/config/sgct",
|
||||
|
||||
@@ -229,6 +229,9 @@ function (handle_applications)
|
||||
|
||||
target_link_libraries(${APPLICATION_NAME} Ghoul)
|
||||
target_link_libraries(${APPLICATION_NAME} libOpenSpace)
|
||||
|
||||
copy_files(${APPLICATION_NAME} "${CURL_ROOT_DIR}/lib/libcurl.dll")
|
||||
|
||||
endif ()
|
||||
|
||||
list(APPEND applications ${APPLICATION_NAME})
|
||||
|
||||
Reference in New Issue
Block a user