X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fdbus%2Fskeleton%2Fservice.cpp;fp=src%2Ftype3_AndroidCloud%2Fanbox-master%2Fsrc%2Fanbox%2Fdbus%2Fskeleton%2Fservice.cpp;h=9d62d2d475b3620a505c598b16c6ac77ed894a11;hb=e26c1ec581be598521517829adba8c8dd23a768f;hp=0000000000000000000000000000000000000000;hpb=6699c1aea74eeb0eb400e6299079f0c7576f716f;p=iec.git diff --git a/src/type3_AndroidCloud/anbox-master/src/anbox/dbus/skeleton/service.cpp b/src/type3_AndroidCloud/anbox-master/src/anbox/dbus/skeleton/service.cpp new file mode 100644 index 0000000..9d62d2d --- /dev/null +++ b/src/type3_AndroidCloud/anbox-master/src/anbox/dbus/skeleton/service.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, as published + * by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranties of + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/dbus/interface.h" +#include "anbox/dbus/skeleton/service.h" +#include "anbox/dbus/skeleton/application_manager.h" +#include "anbox/logger.h" + +namespace anbox { +namespace dbus { +namespace skeleton { +std::shared_ptr Service::create_for_bus(const BusPtr& bus, const std::shared_ptr &impl) { + return std::shared_ptr(new Service(bus, impl)); +} + +Service::Service(const BusPtr& bus, const std::shared_ptr &impl) + : bus_{bus} { + if (!bus_) + throw std::invalid_argument("Missing bus object"); + + const auto r = sd_bus_request_name(bus_->raw(), + interface::Service::name(), + 0); + if (r < 0) + throw std::runtime_error("Failed to request DBus service name"); + + DEBUG("Successfully acquired DBus service name"); + + application_manager_ = std::make_shared(bus, impl); +} + +Service::~Service() {} +} // namespace skeleton +} // namespace dbus +} // namespace anbox