/* * This file is part of openauto project. * Copyright (C) 2018 f1x.studio (Michal Szwaj) * * openauto is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * openauto is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY 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 openauto. If not, see . */ #include #include #include #include namespace f1x { namespace openauto { namespace autoapp { namespace service { namespace vendorextension { VendorExtensionService::VendorExtensionService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger) : strand_(ioService), timer_(ioService), channel_(std::make_shared(strand_, std::move(messenger))) { } void VendorExtensionService::start() { strand_.dispatch([this, self = this->shared_from_this()]() { OPENAUTO_LOG(info) << "[VendorExtensionService] start()"; }); } void VendorExtensionService::stop() { strand_.dispatch([this, self = this->shared_from_this()]() { OPENAUTO_LOG(info) << "[VendorExtensionService] stop()"; }); } void VendorExtensionService::pause() { strand_.dispatch([this, self = this->shared_from_this()]() { OPENAUTO_LOG(info) << "[VendorExtensionService] pause()"; }); } void VendorExtensionService::resume() { strand_.dispatch([this, self = this->shared_from_this()]() { OPENAUTO_LOG(info) << "[VendorExtensionService] resume()"; }); } void VendorExtensionService::fillFeatures( aap_protobuf::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) { OPENAUTO_LOG(info) << "[VendorExtensionService] fillFeatures()"; auto *service = response.add_channels(); service->set_id(static_cast(channel_->getId())); auto *vendorExtension = service->mutable_vendor_extension_service(); } void VendorExtensionService::onChannelError(const aasdk::error::Error &e) { OPENAUTO_LOG(error) << "[VendorExtensionService] onChannelError(): " << e.what(); } void VendorExtensionService::onChannelOpenRequest(const aap_protobuf::channel::ChannelOpenRequest &request) { OPENAUTO_LOG(info) << "[VendorExtensionService] onChannelOpenRequest()"; OPENAUTO_LOG(info) << "[VendorExtensionService] Channel Id: " << request.service_id() << ", Priority: " << request.priority(); aap_protobuf::channel::ChannelOpenResponse response; const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS; response.set_status(status); auto promise = aasdk::channel::SendPromise::defer(strand_); promise->then([]() {}, std::bind(&VendorExtensionService::onChannelError, this->shared_from_this(), std::placeholders::_1)); channel_->sendChannelOpenResponse(response, std::move(promise)); channel_->receive(this->shared_from_this()); } } } } } }