summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-11-23 07:09:39 (GMT)
committerTobias Markmann <tm@ayena.de>2016-11-23 11:30:02 (GMT)
commite405ff3561be3d3c0bd79d7d5173923a8828cf02 (patch)
tree9118ef838ebfaec1df90ec24761944b5d833774c /Slimber/MainController.cpp
parent8a71b91be885652f37c5aab5e1ecf25af4599fbc (diff)
downloadswift-e405ff3561be3d3c0bd79d7d5173923a8828cf02.zip
swift-e405ff3561be3d3c0bd79d7d5173923a8828cf02.tar.bz2
Migrate remaining Swiften/Base/foreach.h use to range-based for loop
Test-Information: Build on macOS 10.12.1 and all tests pass. Change-Id: Iedaa3fa7e7672c77909fd0568bf30e9393cb87e0
Diffstat (limited to 'Slimber/MainController.cpp')
-rw-r--r--Slimber/MainController.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/Slimber/MainController.cpp b/Slimber/MainController.cpp
index dcec6d5..cd36132 100644
--- a/Slimber/MainController.cpp
+++ b/Slimber/MainController.cpp
@@ -1,42 +1,41 @@
/*
* Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Slimber/MainController.h>
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
-#include <Swiften/Base/foreach.h>
#include <Swiften/LinkLocal/DNSSD/PlatformDNSSDQuerierFactory.h>
#include <Swiften/LinkLocal/LinkLocalService.h>
#include <Swiften/LinkLocal/LinkLocalServiceBrowser.h>
#include <Slimber/FileVCardCollection.h>
#include <Slimber/Menulet.h>
#include <Slimber/MenuletController.h>
#include <Slimber/Server.h>
#include <SwifTools/Application/PlatformApplicationPathProvider.h>
using namespace Swift;
MainController::MainController(Menulet* menulet, EventLoop* eventLoop) {
dnsSDQuerier = PlatformDNSSDQuerierFactory(eventLoop).createQuerier();
assert(dnsSDQuerier);
linkLocalServiceBrowser = new LinkLocalServiceBrowser(dnsSDQuerier);
linkLocalServiceBrowser->onServiceAdded.connect(
boost::bind(&MainController::handleServicesChanged, this));
linkLocalServiceBrowser->onServiceRemoved.connect(
boost::bind(&MainController::handleServicesChanged, this));
linkLocalServiceBrowser->onServiceChanged.connect(
boost::bind(&MainController::handleServicesChanged, this));
vCardCollection = new FileVCardCollection(
PlatformApplicationPathProvider("Slimber").getDataDir());
server = new Server(5222, 5562, linkLocalServiceBrowser, vCardCollection, eventLoop);
server->onStopped.connect(
@@ -61,61 +60,61 @@ 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);
}
else {
menuletController->setXMPPStatus("You are not logged in", MenuletController::Offline);
}
}
void MainController::handleServicesChanged() {
std::vector<std::string> names;
- foreach(const LinkLocalService& service, linkLocalServiceBrowser->getServices()) {
+ for (const auto& service : linkLocalServiceBrowser->getServices()) {
std::string description = service.getDescription();
if (description != service.getName()) {
description += " (" + service.getName() + ")";
}
names.push_back(description);
}
menuletController->setUserNames(names);
}
void MainController::handleServerStopped(boost::optional<ServerError> error) {
if (error) {
std::string message;
switch (error->getType()) {
case ServerError::C2SPortConflict:
message = std::string("Error: Port ") + boost::lexical_cast<std::string>(server->getClientToServerPort()) + std::string(" in use");
break;
case ServerError::C2SError:
message = std::string("Local connection server error");
break;
case ServerError::LinkLocalPortConflict:
message = std::string("Error: Port ") + boost::lexical_cast<std::string>(server->getLinkLocalPort()) + std::string(" in use");
break;
case ServerError::LinkLocalError:
message = std::string("External connection server error");
break;
}
menuletController->setXMPPStatus(message, MenuletController::Offline);
}
else {
menuletController->setXMPPStatus("XMPP Server Not Running", MenuletController::Offline);