Skip to content

Commit

Permalink
Merge branch 'master' into development/METROL-689
Browse files Browse the repository at this point in the history
  • Loading branch information
HaseenaSainul authored Oct 1, 2024
2 parents a2deebe + a015de2 commit a4d4177
Show file tree
Hide file tree
Showing 32 changed files with 934 additions and 555 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/Linux build template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
sudo apt-spy2 fix --commit --launchpad --country=US
echo "deb http://archive.ubuntu.com/ubuntu/ jammy main universe restricted multiverse" | sudo tee -a /etc/apt/sources.list
echo "deb http://archive.ubuntu.com/ubuntu/ jammy-updates main universe restricted multiverse" | sudo tee -a /etc/apt/sources.list
sudo dpkg --add-architecture i386
${{matrix.architecture == '32' && 'sudo dpkg --add-architecture i386' || ':'}}
sudo apt-get update
sudo apt install python3-pip build-essential cmake ninja-build libusb-1.0-0-dev zlib1g-dev zlib1g-dev:i386 libssl-dev gcc-11-multilib g++-11-multilib
sudo apt install python3-pip build-essential cmake ninja-build libusb-1.0-0-dev ${{matrix.architecture == '32' && 'zlib1g-dev:i386 libssl-dev:i386 libsbc-dev:i386 gcc-11-multilib g++-11-multilib' || 'zlib1g-dev libssl-dev libsbc-dev'}}
sudo pip install jsonref
# ----- Checkout & DependsOn regex -----
Expand Down Expand Up @@ -85,6 +85,7 @@ jobs:
# ----- Installing generators & Options regex -----
- name: Install generators
run: |
${{matrix.architecture == '32' && 'export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig:$PKG_CONFIG_PATH' || 'PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH'}}
cmake -G Ninja -S ThunderTools -B ${{matrix.build_type}}/build/ThunderTools \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Werror -m${{matrix.architecture}}" \
-DCMAKE_C_FLAGS="-Wall -Wextra -Wpedantic -Werror -m${{matrix.architecture}}" \
Expand All @@ -103,6 +104,7 @@ jobs:
# ----- Building & uploading artifacts -----
- name: Build Thunder
run: |
${{matrix.architecture == '32' && 'export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig:$PKG_CONFIG_PATH' || 'PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH'}}
cmake -G Ninja -S Thunder -B ${{matrix.build_type}}/build/Thunder \
-DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic -Werror -m${{matrix.architecture}}" \
-DCMAKE_C_FLAGS="-Wall -Wextra -Wpedantic -Werror -m${{matrix.architecture}}" \
Expand All @@ -117,6 +119,11 @@ jobs:
-DPROXYSTUB_PATH="${PWD}/${{matrix.build_type}}/install/usr/lib/wpeframework/proxystubs" \
-DSYSTEM_PATH="${PWD}/${{matrix.build_type}}/install/usr/lib/wpeframework/plugins" \
-DVOLATILE_PATH="tmp" \
-DBLUETOOTH_SUPPORT=ON \
-DBLUETOOTH=ON \
-DDOWNLOAD_BLUEZ_UTIL_HEADERS=ON \
-DBLUETOOTH_AUDIO_SUPPORT=ON \
-DBLUETOOTH_GATT_SUPPORT=ON \
-DLOCALTRACER=ON \
-DWARNING_REPORTING=ON \
-DPROCESSCONTAINERS=ON \
Expand Down
64 changes: 3 additions & 61 deletions Source/Thunder/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,64 +114,6 @@ namespace PluginHost {
// Configuration to get a server (PluginHost server) up and running.
class JSONConfig : public Core::JSON::Container {
public:
class Environment : public Core::JSON::Container {
public:
Environment()
: Core::JSON::Container()
, Key()
, Value()
, Override(false)
{
Add(_T("key"), &Key);
Add(_T("value"), &Value);
Add(_T("override"), &Override);
}
Environment(const Environment& copy)
: Core::JSON::Container()
, Key(copy.Key)
, Value(copy.Value)
, Override(copy.Override)
{
Add(_T("key"), &Key);
Add(_T("value"), &Value);
Add(_T("override"), &Override);
}
Environment(Environment&& move) noexcept
: Core::JSON::Container()
, Key(std::move(move.Key))
, Value(std::move(move.Value))
, Override(std::move(move.Override))
{
Add(_T("key"), &Key);
Add(_T("value"), &Value);
Add(_T("override"), &Override);
}
~Environment() override = default;
Environment& operator=(const Environment& RHS)
{
Key = RHS.Key;
Value = RHS.Value;
Override = RHS.Override;

return (*this);
}
Environment& operator=(Environment&& move) noexcept
{
if (this != &move) {
Key = std::move(move.Key);
Value = std::move(move.Value);
Override = std::move(move.Override);
}

return (*this);
}

public:
Core::JSON::String Key;
Core::JSON::String Value;
Core::JSON::Boolean Override;
};

class ProcessSet : public Core::JSON::Container {
public:
ProcessSet()
Expand Down Expand Up @@ -526,7 +468,7 @@ namespace PluginHost {
Core::JSON::String Configs;
Core::JSON::String EthernetCard;
Core::JSON::ArrayType<Plugin::Config> Plugins;
Core::JSON::ArrayType<Environment> Environments;
Core::JSON::ArrayType<Plugin::Config::Environment> Environments;
Core::JSON::ArrayType<Core::JSON::EnumType<PluginHost::IShell::reason>> ExitReasons;
Core::JSON::DecSInt32 Latitude;
Core::JSON::DecSInt32 Longitude;
Expand Down Expand Up @@ -773,12 +715,12 @@ namespace PluginHost {
}

bool status = true;
Core::JSON::ArrayType<JSONConfig::Environment>::ConstIterator index(static_cast<const JSONConfig&>(config).Environments.Elements());
Core::JSON::ArrayType<Plugin::Config::Environment>::ConstIterator index(static_cast<const JSONConfig&>(config).Environments.Elements());
while (index.Next() == true) {
if ((index.Current().Key.IsSet() == true) && (index.Current().Value.IsSet() == true)) {
string value = _substituter.Substitute(index.Current().Value.Value(), nullptr);
if (value.empty() != true) {
status = Core::SystemInfo::SetEnvironment(index.Current().Key.Value(), value, index.Current().Override.Value());
status = Core::SystemInfo::SetEnvironment(index.Current().Key.Value(), value, ((index.Current().Override.Value() == RPC::Object::Environment::Scope::GLOBAL) ? true : false));
if (status != true) {
SYSLOG(Logging::Startup, (_T("Failure in setting Key:Value:[%s]:[%s]\n"), index.Current().Key.Value().c_str(), index.Current().Value.Value().c_str()));
}
Expand Down
39 changes: 16 additions & 23 deletions Source/Thunder/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,12 @@ namespace Plugin {
Core::hresult Controller::Delete(const string& path)
{
Core::hresult result = Core::ERROR_UNKNOWN_KEY;
bool valid;
string normalized_path = Core::File::Normalize(path, valid);

ASSERT(_service != nullptr);

if (valid == false) {
const string normalized_path = Core::File::Normalize(path, true /* safe paths only */);

if (normalized_path.empty() == true) {
result = Core::ERROR_PRIVILIGED_REQUEST;
}
else {
Expand Down Expand Up @@ -681,10 +681,9 @@ namespace Plugin {
remainder = index.Remainder().Text();
}

bool valid;
string normalized(Core::File::Normalize(remainder, valid));
const string normalized(Core::File::Normalize(remainder, true /* safe paths only */));

if (valid == false) {
if (normalized.empty() == true) {
result->Message = "incorrect path";
result->ErrorCode = Web::STATUS_BAD_REQUEST;
}
Expand Down Expand Up @@ -1221,31 +1220,25 @@ namespace Plugin {
{
Core::hresult result = Core::ERROR_UNKNOWN_KEY;

RPC::Administrator::Proxies collection;

// Search for the Dangling proxies
if (RPC::Administrator::Instance().Allocations(linkId, collection) == true) {

using Iterator = IMetadata::Data::IProxiesIterator;

std::list< IMetadata::Data::Proxy> elements;

for (const ProxyStub::UnknownProxy* proxy : collection) {
std::vector<IMetadata::Data::Proxy> collection;
bool proxySearch = RPC::Administrator::Instance().Allocations(linkId, [&collection](const std::vector<ProxyStub::UnknownProxy*>& proxies) {
for (const auto& proxy : proxies) {
IMetadata::Data::Proxy data;
data.Count = proxy->ReferenceCount();
data.Instance = proxy->Implementation();
data.Interface = proxy->InterfaceId();
data.Count = proxy->ReferenceCount();
data.Name = proxy->Name();

elements.emplace_back(std::move(data));
}
collection.emplace_back(std::move(data));
}
});

outProxies = Core::ServiceType<RPC::IteratorType<Iterator>>::Create<Iterator>(std::move(elements));
ASSERT(outProxies != nullptr);
if (proxySearch == true) {
using Iterator = IMetadata::Data::IProxiesIterator;

outProxies = Core::ServiceType<RPC::IteratorType<Iterator>>::Create<Iterator>(std::move(collection));
ASSERT(outProxies != nullptr);
result = Core::ERROR_NONE;
}

return (result);
}

Expand Down
4 changes: 3 additions & 1 deletion Source/Thunder/IRemoteInstantiation.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace PluginHost {
struct IRemoteInstantiation : virtual public Core::IUnknown {

enum { ID = RPC::IDS::ID_REMOTE_INSTANTIATION };
using IEnvironmentIterator = RPC::IIteratorType<RPC::Object::Environment, RPC::ID_ENVIRONMENT_ITERATOR>;

~IRemoteInstantiation() override = default;

Expand Down Expand Up @@ -56,7 +57,8 @@ namespace PluginHost {
const string& systemRootPath,
const uint8_t threads,
const int8_t priority,
const string configuration) = 0;
const string configuration,
IEnvironmentIterator* const& environments) = 0;
};
}
}
8 changes: 3 additions & 5 deletions Source/Thunder/PluginHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,15 +712,13 @@ POP_WARNING()
printf("Link: %s\n", index.Current().Remote.Value().c_str());
printf("------------------------------------------------------------\n");

RPC::Administrator::Proxies proxies;

RPC::Administrator::Instance().Allocations(index.Current().ID.Value(), proxies);

for (const ProxyStub::UnknownProxy* proxy : proxies) {
RPC::Administrator::Instance().Allocations(index.Current().ID.Value(), [](const std::vector<ProxyStub::UnknownProxy*>& proxies) {
for (const auto& proxy: proxies) {
Core::instance_id instanceId = proxy->Implementation();
printf("[%s] InstanceId: 0x%" PRIx64 ", RefCount: %d, InterfaceId %d [0x%X]\n", proxy->Name().c_str(), static_cast<uint64_t>(instanceId), proxy->ReferenceCount(), proxy->InterfaceId(), proxy->InterfaceId());
}
printf("\n");
});
}
}
break;
Expand Down
28 changes: 15 additions & 13 deletions Source/Thunder/PluginServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,26 +581,28 @@ namespace PluginHost {

Lock();

if (_jsonrpc != nullptr) {
PluginHost::IShell::IConnectionServer::INotification* sink = nullptr;
_jsonrpc->Detach(sink);
if (sink != nullptr) {
Unregister(sink);
sink->Release();
}
if (currentState != IShell::state::ACTIVATION) {
SYSLOG(Logging::Shutdown, (_T("Deactivated plugin [%s]:[%s]"), className.c_str(), callSign.c_str()));

#ifdef THUNDER_RESTFULL_API
Notify(EMPTY_STRING, string(_T("{\"state\":\"deactivated\",\"reason\":\"")) + textReason.Data() + _T("\"}"));
#endif
Notify(_T("statechange"), string(_T("{\"state\":\"deactivated\",\"reason\":\"")) + textReason.Data() + _T("\"}"));
}

if (_external.Connector().empty() == false) {
_external.Close(0);
}

if (currentState != IShell::state::ACTIVATION) {
SYSLOG(Logging::Shutdown, (_T("Deactivated plugin [%s]:[%s]"), className.c_str(), callSign.c_str()));
if (_jsonrpc != nullptr) {
PluginHost::IShell::IConnectionServer::INotification* sink = nullptr;

#ifdef THUNDER_RESTFULL_API
Notify(EMPTY_STRING, string(_T("{\"state\":\"deactivated\",\"reason\":\"")) + textReason.Data() + _T("\"}"));
#endif
Notify(_T("statechange"), string(_T("{\"state\":\"deactivated\",\"reason\":\"")) + textReason.Data() + _T("\"}"));
_jsonrpc->Detach(sink);

if (sink != nullptr) {
Unregister(sink);
sink->Release();
}
}
}

Expand Down
Loading

0 comments on commit a4d4177

Please sign in to comment.