summaryrefslogtreecommitdiffstats
path: root/flounder_6.0.2.xml
blob: 1bf1806ea02e2875329f81f0fcf339a305d1c30d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remote fetch="https://gerrit.automotivelinux.org/gerrit/" name="agl" pushurl="ssh://gerrit.automotivelinux.org:29418" review="https://gerrit.automotivelinux.org/gerrit/"/>
  <remote fetch="https://github.com/" name="github"/>
  <remote fetch="git://git.openembedded.org/" name="openembedded"/>
  <remote fetch="git://code.qt.io/" name="qt.io"/>
  <remote fetch="git://git.yoctoproject.org/" name="yocto"/>
  
  <default remote="agl" revision="refs/tags/flounder/6.0.2" sync-j="4"/>
  
  <project name="01org/meta-security-isafw" path="meta-security-isafw" remote="github" revision="489abdc65cefb566d696c8b218aa0b9b99a350ae" upstream="master"/>
  <project name="AGL/meta-agl" path="meta-agl"/>
  <project name="AGL/meta-agl-demo" path="meta-agl-demo"/>
  <project name="AGL/meta-agl-devel" path="meta-agl-devel"/>
  <project name="AGL/meta-agl-extra" path="meta-agl-extra"/>
  <project name="AGL/meta-renesas-rcar-gen3" path="meta-renesas-rcar-gen3"/>
  <project name="CogentEmbedded/meta-rcar" path="meta-rcar" remote="github" revision="a0551596548ef3a4c9132161f3d9c4ae538d6fdc" upstream="v3.7.0"/>
  <project name="advancedtelematic/meta-updater" path="meta-updater" remote="github" revision="ff555e8690eb47177ade42dc6912ae17a759cc45" upstream="rocko"/>
  <project name="advancedtelematic/meta-updater-qemux86-64" path="meta-updater-qemux86-64" remote="github" revision="697632ddd98ed7ae3dbd0bd84abb04079767bc56" upstream="rocko"/>
  <project name="boundarydevices/meta-boundary" path="meta-boundary" remote="github" revision="f96f41b2e5beda2b51acb702d082568898b36a68" upstream="rocko"/>
  <project name="kraj/meta-altera" path="meta-altera" remote="github" revision="14e08a419cb9d4017f40360c14fcc3c2c1ce8e42" upstream="rocko"/>
  <project name="meta-freescale" remote="yocto" revision="a4158e3425a79720ddc4c02e76251d567bdceb51" upstream="rocko"/>
  <project name="meta-gplv2" remote="yocto" revision="f875c60ecd6f30793b80a431a2423c4b98e51548" upstream="rocko"/>
  <project name="meta-intel" remote="yocto" revision="718bb384942675437c081f6795da7f421da1fee6" upstream="rocko"/>
  <project name="meta-oic" remote="yocto" revision="6e831e4bcdfa6ab8c26eb4fca4bdc98faf028818" upstream="1.2.1"/>
  <project name="meta-openembedded" remote="openembedded" revision="eae996301d9c097bcbeb8046f08041dc82bb62f8" upstream="rocko"/>
  <project name="meta-qcom" remote="yocto" revision="955ce2625de5d8c7fe313bd4630c8a290e4b96f8" upstream="rocko"/>
  <project name="meta-qt5/meta-qt5" path="meta-qt5" remote="github" revision="682ad61c071a9710e9f9d8a32ab1b5f3c14953d1" upstream="rocko"/>
  <project name="meta-raspberrypi" remote="yocto" revision="8e4c537d84fdde8e3b4642d0dda2c0f4af76d52f" upstream="rocko"/>
  <project name="meta-security" remote="yocto" revision="8f6969a775fa6afbf553e72ba83e71197780b2d8" upstream="master"/>
  <project name="meta-ti" remote="yocto" revision="ed83a43c6a76875ee5f0388b3b60a28f2a373a10" upstream="rocko"/>
  <project name="meta-virtualization" remote="yocto" revision="bd77388f31929f38e7d4cc9c711f0f83f563007e" upstream="rocko"/>
  <project name="phongt/meta-sdl" path="meta-sdl" remote="github" revision="60c9fe8a4a9c6ca95f222685f8d6248f16236f2a" upstream="release/4.4.0"/>
  <project name="poky" remote="yocto" revision="05711ba18587aaaf4a9c465a1dd4537f27ceda93" upstream="rocko"/>
</manifest>
.sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *     http://aws.amazon.com/apache2.0/
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
#include "VshlCapabilitiesApi.h"

#include <list>
#include <json.hpp>

#include "afb/AFBApiImpl.h"
#include "afb/AFBRequestImpl.h"
#include "capabilities/CapabilitiesFactory.h"
#include "capabilities/CapabilityMessagingService.h"
#include "utilities/events/EventRouter.h"
#include "utilities/logging/Logger.h"

using namespace std;

CTLP_CAPI_REGISTER("vshlsupport-api");

static std::string TAG = "vshlcapabilities::plugins::VshlCapabilitiesApi";

static std::string EVENTS_JSON_ATTR_VA_ID = "va_id";
static std::string EVENTS_JSON_ATTR_EVENTS = "events";

static std::string CAPABILITIES_JSON_ATTR_ACTION = "action";
static std::string CAPABILITIES_JSON_ATTR_ACTIONS = "actions";
static std::string CAPABILITIES_JSON_ATTR_PAYLOAD = "payload";

static std::shared_ptr<vshlcapabilities::utilities::logging::Logger> sLogger;
static std::shared_ptr<vshlcapabilities::common::interfaces::IAFBApi> sAfbApi;
static std::unique_ptr<vshlcapabilities::capabilities::CapabilitiesFactory> sCapabilitiesFactory;
static std::unique_ptr<vshlcapabilities::capabilities::CapabilityMessagingService> sCapabilityMessagingService;
static std::unique_ptr<vshlcapabilities::utilities::events::EventRouter> sEventRouter;

using json = nlohmann::json;
using Level = vshlcapabilities::utilities::logging::Logger::Level;

CTLP_ONLOAD(plugin, ret) {
    if (plugin->api == nullptr) {
        return -1;
    }

    // Logger
    sLogger = vshlcapabilities::utilities::logging::Logger::create(plugin->api);

    // AFB Wrapper
    sAfbApi = vshlcapabilities::afb::AFBApiImpl::create(plugin->api);

    // EventRouter
    sEventRouter = vshlcapabilities::utilities::events::EventRouter::create(sLogger);
    if (!sEventRouter) {
        sLogger->log(Level::ERROR, TAG, "Failed to create EventRouter");
        return -1;
    }

    sCapabilitiesFactory = vshlcapabilities::capabilities::CapabilitiesFactory::create(sLogger);
    if (!sCapabilitiesFactory) {
        sLogger->log(Level::ERROR, TAG, "Failed to create CapabilitiesFactory");
        return -1;
    }

    sCapabilityMessagingService = vshlcapabilities::capabilities::CapabilityMessagingService::create(sLogger, sAfbApi);
    if (!sCapabilityMessagingService) {
        sLogger->log(Level::ERROR, TAG, "Failed to create CapabilityMessagingService");
        return -1;
    }

    return 0;
}


CTLP_CAPI(guiMetadataSubscribe, source, argsJ, eventJ) {
    if (sCapabilitiesFactory == nullptr || sCapabilityMessagingService == nullptr) {
        return -1;
    }

    shared_ptr<vshlcapabilities::common::interfaces::ICapability> guMetadataCapability = sCapabilitiesFactory->getGuiMetadata();
    if (!guMetadataCapability) {
        sLogger->log(
            Level::WARNING,
            TAG,
            "guimetadataSubscribe: Failed to "
            "fetch guimetadata capability "
            "object.");
        return -1;
    }

    if (eventJ == nullptr) {
        sLogger->log(Level::WARNING, TAG, "guimetadataSubscribe: No arguments supplied.");
        return -1;
    }

    json subscribeJson = json::parse(json_object_to_json_string(eventJ));
    if (subscribeJson.find(CAPABILITIES_JSON_ATTR_ACTIONS) == subscribeJson.end()) {
        sLogger->log(Level::ERROR, TAG, "guimetadataSubscribe: No events array found in subscribe json");
        return -1;
    }
    list<string> events(subscribeJson[CAPABILITIES_JSON_ATTR_ACTIONS].get<list<string>>());

    // SUbscribe this client for the guimetadata events.
    auto request = vshlcapabilities::afb::AFBRequestImpl::create(source->request);
    for (auto event : events) {
        if (!sCapabilityMessagingService->subscribe(*request, guMetadataCapability, event)) {
            sLogger->log(Level::ERROR, TAG, "guimetadataSubscribe: Failed to subscribe to event: " + event);
            return -1;
        }
    }

    afb_req_success(
        source->request, json_object_new_string("Subscription to guimetadata events successfully completed."), NULL);
    return 0;
}

CTLP_CAPI(guiMetadataPublish, source, argsJ, eventJ) {
    if (sCapabilitiesFactory == nullptr || sCapabilityMessagingService == nullptr) {
        return -1;
    }

    shared_ptr<vshlcapabilities::common::interfaces::ICapability> guMetadataCapability = sCapabilitiesFactory->getGuiMetadata();
    if (!guMetadataCapability) {
        sLogger->log(
            Level::WARNING,
            TAG,
            "guimetadataPublish: Failed to fetch "
            "guimetadata capability object.");
        return -1;
    }

    if (eventJ == nullptr) {
        sLogger->log(Level::WARNING, TAG, "guimetadataPublish: No arguments supplied.");
        return -1;
    }

    json_object* actionJ = json_object_object_get(eventJ , CAPABILITIES_JSON_ATTR_ACTION.c_str());
    if (actionJ == nullptr) {
        sLogger->log(Level::ERROR, TAG, "guimetadataPublish: No action found in publish json");
        return -1;        
    }

    std::string action = std::string(json_object_get_string(actionJ));
    if (action.empty()) {
        sLogger->log(Level::ERROR, TAG, "guimetadataPublish: Invalid action input found in publish json");
        return -1;        
    }

    json_object* payloadJ = json_object_object_get(eventJ , CAPABILITIES_JSON_ATTR_PAYLOAD.c_str());
    if (payloadJ == nullptr) {
        sLogger->log(Level::ERROR, TAG, "guimetadataPublish: No playload found in publish json");
        return -1;        
    }

    if (!sCapabilityMessagingService->publish(guMetadataCapability, action, payloadJ)) {
        sLogger->log(Level::ERROR, TAG, "guimetadataPublish: Failed to publish message: " + action);
        return -1;
    }

    afb_req_success(source->request, json_object_new_string("Successfully published guimetadata messages."), NULL);
    return 0;
}

CTLP_CAPI(phonecontrolSubscribe, source, argsJ, eventJ) {
    if (sCapabilitiesFactory == nullptr || sCapabilityMessagingService == nullptr) {
        return -1;
    }

    shared_ptr<vshlcapabilities::common::interfaces::ICapability> phoneControlCapability = sCapabilitiesFactory->getPhoneControl();
    if (!phoneControlCapability) {
        sLogger->log(Level::WARNING, TAG, "phoneControlSubscribe: Failed to fetch phone control capability object.");
        return -1;
    }

    if (eventJ == nullptr) {
        sLogger->log(Level::WARNING, TAG, "phoneControlSubscribe: No arguments supplied.");
        return -1;
    }

    json subscribeJson = json::parse(json_object_to_json_string(eventJ));
    if (subscribeJson.find(CAPABILITIES_JSON_ATTR_ACTIONS) == subscribeJson.end()) {
        sLogger->log(Level::ERROR, TAG, "phoneControlSubscribe: No events array found in subscribe json");
        return -1;
    }
    list<string> events(subscribeJson[CAPABILITIES_JSON_ATTR_ACTIONS].get<list<string>>());

    // SUbscribe this client for the phone call control events.
    auto request = vshlcapabilities::afb::AFBRequestImpl::create(source->request);
    for (auto event : events) {
        if (!sCapabilityMessagingService->subscribe(*request, phoneControlCapability, event)) {
            sLogger->log(Level::ERROR, TAG, "phoneControlSubscribe: Failed to subscribe to event: " + event);
            return -1;
        }
    }

    afb_req_success(
        source->request, json_object_new_string("Subscription to phone control events successfully completed."), NULL);
    return 0;
}

CTLP_CAPI(phonecontrolPublish, source, argsJ, eventJ) {
    if (sCapabilitiesFactory == nullptr || sCapabilityMessagingService == nullptr) {
        return -1;
    }

    shared_ptr<vshlcapabilities::common::interfaces::ICapability> phoneControlCapability = sCapabilitiesFactory->getPhoneControl();
    if (!phoneControlCapability) {
        sLogger->log(Level::WARNING, TAG, "phoneControlPublish: Failed to fetch navigation capability object.");
        return -1;
    }

    if (eventJ == nullptr) {
        sLogger->log(Level::WARNING, TAG, "phoneControlPublish: No arguments supplied.");
        return -1;
    }

    json_object* actionJ = json_object_object_get(eventJ , CAPABILITIES_JSON_ATTR_ACTION.c_str());
    if (actionJ == nullptr) {
        sLogger->log(Level::ERROR, TAG, "phoneControlPublish: No action found in publish json");
        return -1;        
    }

    std::string action = std::string(json_object_get_string(actionJ));
    if (action.empty()) {
        sLogger->log(Level::ERROR, TAG, "phoneControlPublish: Invalid action input found in publish json");
        return -1;        
    }

    json_object* payloadJ = json_object_object_get(eventJ , CAPABILITIES_JSON_ATTR_PAYLOAD.c_str());
    if (payloadJ == nullptr) {
        sLogger->log(Level::ERROR, TAG, "phoneControlPublish: No playload found in publish json");
        return -1;        
    }

    if (!sCapabilityMessagingService->publish(phoneControlCapability, action, payloadJ)) {
        sLogger->log(Level::ERROR, TAG, "phoneControlPublish: Failed to publish message: " + action);
        return -1;
    }

    afb_req_success(source->request, json_object_new_string("Successfully published phone control messages."), NULL);
    return 0;
}

CTLP_CAPI(navigationSubscribe, source, argsJ, eventJ) {
    if (sCapabilitiesFactory == nullptr || sCapabilityMessagingService == nullptr) {
        return -1;
    }

    shared_ptr<vshlcapabilities::common::interfaces::ICapability> navigationCapability = sCapabilitiesFactory->getNavigation();
    if (!navigationCapability) {
        sLogger->log(Level::WARNING, TAG, "navigationSubscribe: Failed to fetch navigation capability object.");
        return -1;
    }

    if (eventJ == nullptr) {
        sLogger->log(Level::WARNING, TAG, "navigationSubscribe: No arguments supplied.");
        return -1;
    }

    json subscribeJson = json::parse(json_object_to_json_string(eventJ));
    if (subscribeJson.find(CAPABILITIES_JSON_ATTR_ACTIONS) == subscribeJson.end()) {
        sLogger->log(Level::ERROR, TAG, "navigationSubscribe: No events array found in subscribe json");
        return -1;
    }
    list<string> events(subscribeJson[CAPABILITIES_JSON_ATTR_ACTIONS].get<list<string>>());

    // SUbscribe this client for the navigation events.
    auto request = vshlcapabilities::afb::AFBRequestImpl::create(source->request);
    for (auto event : events) {
        if (!sCapabilityMessagingService->subscribe(*request, navigationCapability, event)) {
            sLogger->log(Level::ERROR, TAG, "navigationSubscribe: Failed to subscribe to event: " + event);
            return -1;
        }
    }

    afb_req_success(
        source->request, json_object_new_string("Subscription to navigation events successfully completed."), NULL);
    return 0;
}

CTLP_CAPI(navigationPublish, source, argsJ, eventJ) {
    if (sCapabilitiesFactory == nullptr || sCapabilityMessagingService == nullptr) {
        return -1;
    }

    shared_ptr<vshlcapabilities::common::interfaces::ICapability> navigationCapability = sCapabilitiesFactory->getNavigation();
    if (!navigationCapability) {
        sLogger->log(Level::WARNING, TAG, "navigationPublish: Failed to fetch navigation capability object.");
        return -1;
    }

    if (eventJ == nullptr) {
        sLogger->log(Level::WARNING, TAG, "navigationPublish: No arguments supplied.");
        return -1;
    }

    json_object* actionJ = json_object_object_get(eventJ , CAPABILITIES_JSON_ATTR_ACTION.c_str());
    if (actionJ == nullptr) {
        sLogger->log(Level::ERROR, TAG, "navigationPublish: No action found in publish json");
        return -1;        
    }

    std::string action = std::string(json_object_get_string(actionJ));
    if (action.empty()) {
        sLogger->log(Level::ERROR, TAG, "navigationPublish: Invalid action input found in publish json");
        return -1;        
    }

    json_object* payloadJ = json_object_object_get(eventJ , CAPABILITIES_JSON_ATTR_PAYLOAD.c_str());
    if (payloadJ == nullptr) {
        sLogger->log(Level::ERROR, TAG, "navigationPublish: No playload found in publish json");
        return -1;        
    }

    if (!sCapabilityMessagingService->publish(navigationCapability, action, payloadJ)) {
        sLogger->log(Level::ERROR, TAG, "navigationPublish: Failed to publish message: " + action);
        return -1;
    }

    afb_req_success(source->request, json_object_new_string("Successfully published navigation messages."), NULL);
    return 0;
}

CTLP_CAPI(playbackControllerSubscribe, source, argsJ, eventJ) {
    if (sCapabilitiesFactory == nullptr || sCapabilityMessagingService == nullptr) {
        return -1;
    }

    shared_ptr<vshlcapabilities::common::interfaces::ICapability> playbackcontrollerCapability = sCapabilitiesFactory->getPlaybackController();
    if (!playbackcontrollerCapability) {
        sLogger->log(Level::WARNING, TAG, "playbackControllerSubscribe: Failed to fetch playbackcontroller capability object.");
        return -1;
    }

    if (eventJ == nullptr) {
        sLogger->log(Level::WARNING, TAG, "playbackControllerSubscribe: No arguments supplied.");
        return -1;
    }

    json subscribeJson = json::parse(json_object_to_json_string(eventJ));
    if (subscribeJson.find(CAPABILITIES_JSON_ATTR_ACTIONS) == subscribeJson.end()) {
        sLogger->log(Level::ERROR, TAG, "playbackControllerSubscribe: No events array found in subscribe json");
        return -1;
    }
    list<string> events(subscribeJson[CAPABILITIES_JSON_ATTR_ACTIONS].get<list<string>>());

    // SUbscribe this client for the navigation events.
    auto request = vshlcapabilities::afb::AFBRequestImpl::create(source->request);
    for (auto event : events) {
        if (!sCapabilityMessagingService->subscribe(*request, playbackcontrollerCapability, event)) {
            sLogger->log(Level::ERROR, TAG, "playbackControllerSubscribe: Failed to subscribe to event: " + event);
            return -1;
        }
    }

    afb_req_success(
        source->request, json_object_new_string("Subscription to playbackcontroller events successfully completed."), NULL);
    return 0;
}

CTLP_CAPI(playbackControllerPublish, source, argsJ, eventJ) {
    if (sCapabilitiesFactory == nullptr || sCapabilityMessagingService == nullptr) {
        return -1;
    }

    shared_ptr<vshlcapabilities::common::interfaces::ICapability> playbackcontrollerCapability = sCapabilitiesFactory->getPlaybackController();
    if (!playbackcontrollerCapability) {
        sLogger->log(Level::WARNING, TAG, "playbackControllerPublish: Failed to fetch playbackcontroller capability object.");
        return -1;
    }

    if (eventJ == nullptr) {
        sLogger->log(Level::WARNING, TAG, "playbackControllerPublish: No arguments supplied.");
        return -1;
    }

    json_object* actionJ = json_object_object_get(eventJ , CAPABILITIES_JSON_ATTR_ACTION.c_str());
    if (actionJ == nullptr) {
        sLogger->log(Level::ERROR, TAG, "playbackControllerPublish: No action found in publish json");
        return -1;        
    }

    std::string action = std::string(json_object_get_string(actionJ));
    if (action.empty()) {
        sLogger->log(Level::ERROR, TAG, "playbackControllerPublish: Invalid action input found in publish json");
        return -1;        
    }

    json_object* payloadJ = json_object_object_get(eventJ , CAPABILITIES_JSON_ATTR_PAYLOAD.c_str());
    if (payloadJ == nullptr) {
        sLogger->log(Level::ERROR, TAG, "playbackControllerPublish: No playload found in publish json");
        return -1;        
    }

    if (!sCapabilityMessagingService->publish(playbackcontrollerCapability, action, payloadJ)) {
        sLogger->log(Level::ERROR, TAG, "playbackControllerPublish: Failed to publish message: " + action);
        return -1;
    }
     
    afb_req_success(source->request, json_object_new_string("Successfully published playbackcontroller messages."), NULL);
    return 0;
}