diff options
Diffstat (limited to 'Slimber/MainController.cpp')
-rw-r--r-- | Slimber/MainController.cpp | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/Slimber/MainController.cpp b/Slimber/MainController.cpp index d723f3f..4e238d2 100644 --- a/Slimber/MainController.cpp +++ b/Slimber/MainController.cpp @@ -16,8 +16,11 @@ using namespace Swift; MainController::MainController(Menulet* menulet) : menulet(menulet) { + menuletController = new MenuletController(menulet); + menuletController->onRestartRequested.connect(boost::bind( + &MainController::handleRestartRequested, this)); + dnsSDQuerier = boost::shared_ptr<BonjourQuerier>(new BonjourQuerier()); - dnsSDQuerier->start(); linkLocalServiceBrowser = new LinkLocalServiceBrowser(dnsSDQuerier); linkLocalServiceBrowser->onServiceAdded.connect( @@ -26,7 +29,6 @@ MainController::MainController(Menulet* menulet) : menulet(menulet) { boost::bind(&MainController::handleServicesChanged, this)); linkLocalServiceBrowser->onServiceChanged.connect( boost::bind(&MainController::handleServicesChanged, this)); - linkLocalServiceBrowser->start(); vCardCollection = new FileVCardCollection( PlatformApplication("Slimber").getSettingsDir()); @@ -37,14 +39,7 @@ MainController::MainController(Menulet* menulet) : menulet(menulet) { server->onSelfConnected.connect( boost::bind(&MainController::handleSelfConnected, this, _1)); - menuletController = new MenuletController(menulet); - menuletController->onRestartRequested.connect(boost::bind( - &MainController::handleRestartRequested, this)); - - handleSelfConnected(false); - handleServicesChanged(); - - server->start(); + start(); } MainController::~MainController() { @@ -56,6 +51,22 @@ MainController::~MainController() { dnsSDQuerier->stop(); } +void MainController::start() { + dnsSDQuerier->start(); + linkLocalServiceBrowser->start(); + + handleSelfConnected(false); + handleServicesChanged(); + + server->start(); +} + +void MainController::stop() { + server->stop(); + linkLocalServiceBrowser->stop(); + dnsSDQuerier->stop(); +} + void MainController::handleSelfConnected(bool b) { if (b) { menuletController->setXMPPStatus("You are logged in", MenuletController::Online); @@ -84,4 +95,6 @@ void MainController::handleServerStopped(boost::optional<ServerError> error) { void MainController::handleRestartRequested() { std::cout << "RESTART!" << std::endl; + stop(); + start(); } |