diff --git a/rak/string_manip.h b/rak/string_manip.h index 690bde7b..c120c014 100644 --- a/rak/string_manip.h +++ b/rak/string_manip.h @@ -265,7 +265,7 @@ transform_hex(InputIterator first1, InputIterator last1, OutputIterator first2, } template -Sequence +inline Sequence transform_hex(const Sequence& src) { Sequence dest; transform_hex(src.begin(), src.end(), std::back_inserter(dest)); @@ -273,6 +273,15 @@ transform_hex(const Sequence& src) { return dest; } +template +inline std::string +transform_hex(Iterator first, Iterator last) { + std::string dest; + transform_hex(first, last, std::back_inserter(dest)); + + return dest; +} + template Sequence generate_random(size_t length) { diff --git a/scripts/attributes.m4 b/scripts/attributes.m4 index d04449b7..183d48b9 100644 --- a/scripts/attributes.m4 +++ b/scripts/attributes.m4 @@ -58,23 +58,33 @@ AC_DEFUN([CC_ATTRIBUTE_INTERNAL], [ fi ]) -AC_DEFUN([CC_ATTRIBUTE_DEFAULT], [ +AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [ + AC_LANG_PUSH(C++) + + tmp_CXXFLAGS=$CXXFLAGS + CXXFLAGS="$CXXFLAGS -fvisibility=hidden" + AC_CACHE_CHECK([if compiler supports __attribute__((visibility("default")))], - [cc_cv_attribute_default], + [cc_cv_attribute_visibility], [AC_COMPILE_IFELSE([ - void __attribute__((visibility("default"))) default_function() { } + void __attribute__((visibility("default"))) visibility_function() { } ], - [cc_cv_attribute_default=yes], - [cc_cv_attribute_default=no]) + [cc_cv_attribute_visibility=yes], + [cc_cv_attribute_visibility=no]) ]) - if test "x$cc_cv_attribute_default" = "xyes"; then - AC_DEFINE([SUPPORT_ATTRIBUTE_DEFAULT], 1, [Define this if the compiler supports the default visibility attribute]) + CXXFLAGS=$tmp_CXXFLAGS + AC_LANG_POP(C++) + + if test "x$cc_cv_attribute_visibility" = "xyes"; then + AC_DEFINE([SUPPORT_ATTRIBUTE_VISIBILITY], 1, [Define this if the compiler supports the visibility attributes.]) + CXXFLAGS="$CXXFLAGS -fvisibility=hidden" $1 else - true + true $2 fi + ]) AC_DEFUN([CC_ATTRIBUTE_NONNULL], [ diff --git a/src/core/download.cc b/src/core/download.cc index 33ce1fd9..a4fcc7f0 100644 --- a/src/core/download.cc +++ b/src/core/download.cc @@ -92,7 +92,7 @@ Download::Download(download_type d) : m_variables.insert("directory", new utils::VariableStringSlot(rak::mem_fn(&m_fileList, &torrent::FileList::root_dir), rak::mem_fn(this, &Download::set_root_directory))); - m_variables.insert("info_hash", new utils::VariableStringSlot(rak::mem_fn(&m_download, &torrent::Download::info_hash), NULL)); +// m_variables.insert("info_hash", new utils::VariableStringSlot(rak::mem_fn(&m_download, &torrent::Download::info_hash), NULL)); m_variables.insert("min_peers", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::peers_min), rak::mem_fn(&m_download, &download_type::set_peers_min))); m_variables.insert("max_peers", new utils::VariableValueSlot(rak::mem_fn(&m_download, &download_type::peers_max), rak::mem_fn(&m_download, &download_type::set_peers_max))); diff --git a/src/core/download.h b/src/core/download.h index d26d041e..bc795dde 100644 --- a/src/core/download.h +++ b/src/core/download.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #include diff --git a/src/core/download_store.cc b/src/core/download_store.cc index 5e292df8..54d75ad7 100644 --- a/src/core/download_store.cc +++ b/src/core/download_store.cc @@ -174,7 +174,7 @@ DownloadStore::is_correct_format(std::string f) { std::string DownloadStore::create_filename(Download* d) { - return m_path + rak::transform_hex(d->download()->info_hash()) + ".torrent"; + return m_path + rak::transform_hex(d->download()->info_hash().begin(), d->download()->info_hash().end()) + ".torrent"; } } diff --git a/src/core/manager.cc b/src/core/manager.cc index e287f4e5..4f975955 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -107,7 +107,7 @@ receive_tracker_dump(const std::string& url, const char* data, size_t size) { } void -Manager::handshake_log(const sockaddr* sa, torrent::ConnectionManager::HandshakeMessage msg, int err, std::string hash) { +Manager::handshake_log(const sockaddr* sa, torrent::ConnectionManager::HandshakeMessage msg, int err, const torrent::HashString* hash) { if (!control->variable()->get_value("handshake_log")) return; @@ -115,6 +115,7 @@ Manager::handshake_log(const sockaddr* sa, torrent::ConnectionManager::Handshake std::string download; const rak::socket_address* socketAddress = rak::socket_address::cast_from(sa); + if (socketAddress->is_valid()) { char port[6]; snprintf(port, sizeof(port), "%d", socketAddress->port()); @@ -123,10 +124,11 @@ Manager::handshake_log(const sockaddr* sa, torrent::ConnectionManager::Handshake peer = "(unknown)"; } - torrent::Download d = torrent::download_find(hash); - if (d.is_valid()) - download = ": " + d.name(); - else +// torrent::Download d = torrent::download_find(hash); + +// if (d.is_valid()) +// download = ": " + d.name(); +// else download = ""; switch (msg) { diff --git a/src/core/manager.h b/src/core/manager.h index c992ca4b..f37d8364 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -98,7 +98,7 @@ public: void push_log(const std::string& msg) { m_logImportant.push_front(msg); m_logComplete.push_front(msg); } - void handshake_log(const sockaddr* sa, torrent::ConnectionManager::HandshakeMessage msg, int err, std::string hash); + void handshake_log(const sockaddr* sa, torrent::ConnectionManager::HandshakeMessage msg, int err, const torrent::HashString* hash); // Temporary, find a better place for this. void try_create_download(const std::string& uri, bool start, bool printLog = true, bool tied = false); diff --git a/src/display/client_info.h b/src/display/client_info.h index 57c7926d..35977be9 100644 --- a/src/display/client_info.h +++ b/src/display/client_info.h @@ -40,6 +40,7 @@ #include #include #include +#include namespace display { @@ -70,6 +71,7 @@ public: // Fix this... std::string str(const char* id) const; std::string str_str(const std::string& id) const { return str(id.c_str()); } + std::string hash_str(const torrent::HashString& id) const { return str(id.c_str()); } size_type sizeof_key(Type t) const { switch (t) { diff --git a/src/display/window_peer_list.cc b/src/display/window_peer_list.cc index abb7194c..1548213e 100644 --- a/src/display/window_peer_list.cc +++ b/src/display/window_peer_list.cc @@ -138,7 +138,7 @@ WindowPeerList::redraw() { x += 7; char buf[128]; - control->client_info()->print(buf, buf + 128, p.id().c_str()); + control->client_info()->print(buf, buf + 128, p.id().data()); m_canvas->print(x, y, "%s", buf); diff --git a/src/ui/element_peer_list.cc b/src/ui/element_peer_list.cc index eec39945..5cb0f178 100644 --- a/src/ui/element_peer_list.cc +++ b/src/ui/element_peer_list.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include "display/client_info.h" #include "display/frame.h" @@ -106,7 +107,7 @@ ElementPeerList::create_info() { display::text_element_value_slot(rak::on(std::mem_fun(&torrent::Peer::address), std::ptr_fun(&te_port)))); element->push_column("Id:", display::text_element_string_slot(std::mem_fun(&torrent::Peer::id), string_base::flag_escape_html)); - element->push_column("Client:", display::text_element_string_slot(rak::on(std::mem_fun(&torrent::Peer::id), rak::make_mem_fun(control->client_info(), &display::ClientInfo::str_str)))); + element->push_column("Client:", display::text_element_string_slot(rak::on(std::mem_fun(&torrent::Peer::id), rak::make_mem_fun(control->client_info(), &display::ClientInfo::hash_str)))); element->push_column("Options:", display::text_element_string_slot(std::mem_fun(&torrent::Peer::options), string_base::flag_escape_hex | string_base::flag_fixed_width, 0, 8)); element->push_column("Connected:", display::text_element_branch(std::mem_fun(&torrent::Peer::is_incoming), te_string("incoming"), te_string("outgoing"))); element->push_column("Encrypted:", display::text_element_branch3(std::mem_fun(&torrent::Peer::is_encrypted), te_string("yes"), std::mem_fun(&torrent::Peer::is_obfuscated), te_string("handshake"), te_string("no"))); @@ -249,7 +250,7 @@ ElementPeerList::receive_snub_peer() { updated_itr(); } -inline void +void ElementPeerList::updated_itr() { m_windowList->mark_dirty(); m_elementInfo->set_object(m_listItr != m_list.end() ? &*m_listItr : NULL); diff --git a/src/ui/element_peer_list.h b/src/ui/element_peer_list.h index e3b3444a..2d54d250 100644 --- a/src/ui/element_peer_list.h +++ b/src/ui/element_peer_list.h @@ -76,7 +76,7 @@ private: void receive_snub_peer(); - inline void updated_itr(); + void updated_itr(); core::Download* m_download;