Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
m-seker committed Jul 15, 2020
1 parent 76b165e commit c305578
Show file tree
Hide file tree
Showing 18 changed files with 133 additions and 173 deletions.
5 changes: 0 additions & 5 deletions assets/webconfig/js/content_grabber.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,5 @@ $(document).ready( function() {
hideEl(["pixelDecimation"]);
});

$(window.hyperion).on("cmd-scan", function(event) {
console.log(event.response);
});
requestCecScan();

removeOverlay();
});
5 changes: 0 additions & 5 deletions assets/webconfig/js/hyperion.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,6 @@ function requestAdjustment(type, value, complete)
sendToHyperion("adjustment", "", '"adjustment": {"'+type+'": '+value+'}');
}

async function requestCecScan()
{
return sendAsyncToHyperion("cec", "scan", "", Math.floor(Math.random() * 1000));
}

async function requestLedDeviceDiscovery(type)
{
let data = { ledDeviceType: type };
Expand Down
19 changes: 19 additions & 0 deletions cmake/FindCEC.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# - Try to find CEC
# Once done this will define
#
# CEC_FOUND - system has libcec
# CEC_INCLUDE_DIRS - the libcec include directory
# CEC_LIBRARIES - The libcec libraries

if(PKG_CONFIG_FOUND)
pkg_check_modules (CEC libcec>=3.0.0)
else()
find_path(CEC_INCLUDE_DIRS libcec/cec.h)
find_library(CEC_LIBRARIES cec)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CEC DEFAULT_MSG CEC_INCLUDE_DIRS CEC_LIBRARIES)

list(APPEND CEC_DEFINITIONS -DHAVE_LIBCEC=1)
mark_as_advanced(CEC_INCLUDE_DIRS CEC_LIBRARIES CEC_DEFINITIONS)
6 changes: 0 additions & 6 deletions include/api/API.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,6 @@ class API : public QObject
///
bool hasHyperionDefaultPw();

///
/// @brief Scan HDMI bus for available CEC devices
/// @return Scan results
///
QString scanCec();

///
/// @brief Logout revokes all authorizations
///
Expand Down
6 changes: 0 additions & 6 deletions include/api/JsonAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,6 @@ private slots:
///
void handleLedDeviceCommand(const QJsonObject &message, const QString &command, const int tan);

/// Handle an incoming JSON Led Device message
///
/// @param message the incoming message
///
void handleCecCommand(const QJsonObject &message, const QString &command, const int tan);

///
/// Handle an incoming JSON message of unknown type
///
Expand Down
19 changes: 5 additions & 14 deletions include/cec/CECHandler.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <QObject>
#include <QMutex>
#include <QVector>

#include <iostream>
Expand All @@ -19,35 +18,29 @@ using CECCommand = CEC::cec_command;
using CECLogicalAddress = CEC::cec_logical_address;
using CECLogicalAddresses = CEC::cec_logical_addresses;
using CECMenuState = CEC::cec_menu_state;
using CECPowerStatus = CEC::cec_power_status;
using CECVendorId = CEC::cec_vendor_id;
using CECParameter = CEC::libcec_parameter;
using CECConfig = CEC::libcec_configuration;
using CECAlert = CEC::libcec_alert;
using CECPowerStatus = CEC::cec_power_status;
using CECVendorId = CEC::cec_vendor_id;

class CECHandler : public QObject
{
Q_OBJECT
public:
CECHandler();
~CECHandler() override;

static CECHandler * getInstance()
{
static CECHandler instance;
return &instance;
}
QString scan() const;

public slots:
bool start();
void stop();
bool running() const { return _cecAdapter != nullptr; }
QString scan() const;

signals:
void cecEvent(CECEvent event);

private:
CECHandler();

/* CEC Callbacks */
static void onCecLogMessage (void * context, const CECLogMessage * message);
static void onCecKeyPress (void * context, const CECKeyPress * key);
Expand All @@ -69,6 +62,4 @@ class CECHandler : public QObject
CECAdapter * _cecAdapter {};
CECCallbacks _cecCallbacks {};
CECConfig _cecConfig {};

mutable QMutex _lock { QMutex::Recursive };
};
8 changes: 0 additions & 8 deletions libsrc/api/API.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <QTimer>

// hyperion includes
#include <cec/CECHandler.h>
#include <leddevice/LedDeviceWrapper.h>
#include <hyperion/GrabberWrapper.h>
#include <utils/jsonschema/QJsonFactory.h>
Expand Down Expand Up @@ -528,10 +527,3 @@ void API::checkTokenResponse(const bool &success, QObject *caller, const QString
void API::stopDataConnectionss()
{
}

QString API::scanCec()
{
if (!_adminAuthorized)
return {};
return CECHandler::getInstance()->scan();
}
4 changes: 0 additions & 4 deletions libsrc/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,3 @@ target_link_libraries(hyperion-api
Qt5::Gui
Qt5::Network
)

if (ENABLE_CEC)
target_link_libraries(hyperion-api cechandler)
endif ()
20 changes: 0 additions & 20 deletions libsrc/api/JSONRPC_schema/schema-cec.json

This file was deleted.

2 changes: 1 addition & 1 deletion libsrc/api/JSONRPC_schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"command": {
"type" : "string",
"required" : true,
"enum" : ["cec" , "color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "logging", "processing", "sysinfo", "videomode", "authorize", "instance", "leddevice", "transform", "correction" , "temperature"]
"enum" : ["color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "logging", "processing", "sysinfo", "videomode", "authorize", "instance", "leddevice", "transform", "correction" , "temperature"]
}
}
}
1 change: 0 additions & 1 deletion libsrc/api/JSONRPC_schemas.qrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<RCC>
<qresource prefix="/">
<file alias="schema">JSONRPC_schema/schema.json</file>
<file alias="schema-cec">JSONRPC_schema/schema-cec.json</file>
<file alias="schema-color">JSONRPC_schema/schema-color.json</file>
<file alias="schema-image">JSONRPC_schema/schema-image.json</file>
<file alias="schema-serverinfo">JSONRPC_schema/schema-serverinfo.json</file>
Expand Down
26 changes: 0 additions & 26 deletions libsrc/api/JsonAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ void JsonAPI::handleMessage(const QString &messageString, const QString &httpAut
handleInstanceCommand(message, command, tan);
else if (command == "leddevice")
handleLedDeviceCommand(message, command, tan);
else if (command == "cec")
handleCecCommand(message, command, tan);

// BEGIN | The following commands are derecated but used to ensure backward compatibility with hyperion Classic remote control
else if (command == "clearall")
Expand Down Expand Up @@ -1466,30 +1464,6 @@ void JsonAPI::handleLedDeviceCommand(const QJsonObject &message, const QString &
}
}


void JsonAPI::handleCecCommand(const QJsonObject &message, const QString &command, const int tan)
{
Debug(_log, "message: [%s]", QString(QJsonDocument(message).toJson(QJsonDocument::Compact)).toUtf8().constData());

const QString &subcommand = message["subcommand"].toString().trimmed();

QString full_command = command + "-" + subcommand;

if (subcommand == "scan")
{
QJsonObject devices;
devices.insert("devices", API::scanCec());
QJsonDocument document(devices);

Debug(_log, "response: [%s]", QString(document.toJson(QJsonDocument::Compact)).toUtf8().constData());
sendSuccessDataReply(document, full_command, tan);
}
else
{
sendErrorReply("Unknown or missing subcommand", full_command, tan);
}
}

void JsonAPI::handleNotImplemented()
{
sendErrorReply("Command not implemented");
Expand Down
Loading

0 comments on commit c305578

Please sign in to comment.