Merge branch '2.0' of git.carlh.net:git/dcpomatic into 2.0
[dcpomatic.git] / src / lib / server_finder.cc
index bef00702f800c8ae7d503304b058d6ee746d6b43..726437ea57b3eaa14fdea90667c38a053f5963cb 100644 (file)
 #include "util.h"
 #include "config.h"
 #include "cross.h"
-#include "ui_signaller.h"
 #include "dcpomatic_socket.h"
+#include "raw_convert.h"
 #include <libcxml/cxml.h>
-#include <dcp/raw_convert.h>
 #include <boost/lambda/lambda.hpp>
 
 #include "i18n.h"
@@ -37,7 +36,6 @@ using std::cout;
 using boost::shared_ptr;
 using boost::scoped_array;
 using boost::weak_ptr;
-using dcp::raw_convert;
 
 ServerFinder* ServerFinder::_instance = 0;
 
@@ -168,13 +166,13 @@ ServerFinder::handle_accept (boost::system::error_code ec, shared_ptr<Socket> so
        xml->read_string (s);
        
        string const ip = socket->socket().remote_endpoint().address().to_string ();
-       if (!server_found (ip)) {
+       if (!server_found (ip) && xml->optional_number_child<int>("Version").get_value_or (0) == SERVER_LINK_VERSION) {
                ServerDescription sd (ip, xml->number_child<int> ("Threads"));
                {
                        boost::mutex::scoped_lock lm (_mutex);
                        _servers.push_back (sd);
                }
-               ui_signaller->emit (boost::bind (boost::ref (ServerFound), sd));
+               emit (boost::bind (boost::ref (ServerFound), sd));
        }
 
        start_accept ();
@@ -192,13 +190,9 @@ ServerFinder::server_found (string ip) const
        return i != _servers.end ();
 }
 
-void
+boost::signals2::connection
 ServerFinder::connect (boost::function<void (ServerDescription)> fn)
 {
-       if (_disabled) {
-               return;
-       }
-       
        boost::mutex::scoped_lock lm (_mutex);
 
        /* Emit the current list of servers */
@@ -206,7 +200,7 @@ ServerFinder::connect (boost::function<void (ServerDescription)> fn)
                fn (*i);
        }
 
-       ServerFound.connect (fn);
+       return ServerFound.connect (fn);
 }
 
 ServerFinder*