Skip to content

Commit 3d14da0

Browse files
committed
Release v0.3
2 parents a705f46 + 00507c1 commit 3d14da0

File tree

7 files changed

+171
-68
lines changed

7 files changed

+171
-68
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ build_script:
6363
- cd %BUILD_DIR%
6464
- cmake .. -DCMAKE_BUILD_TYPE=%CONFIGURATION% -G "%CMAKE_GENERATOR%" %PLATFORM_PARAM% -DCMAKE_INSTALL_PREFIX="%COMMON_INSTALL_DIR%" ^
6565
-DCMAKE_PREFIX_PATH="%COMMON_INSTALL_DIR%;%QTDIR%" -DCMAKE_CXX_STANDARD=%CPP_STD% ^
66-
-DOPT_MAJOR_QT_VERSION=%QT_MAJOR%
66+
-DOPT_QT_MAJOR_VERSION=%QT_MAJOR%
6767
- cmake --build . --config %CONFIGURATION% --target install
6868

6969

.github/workflows/actions_build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
run: |
5656
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.type}} -DCMAKE_INSTALL_PREFIX=install \
5757
-DCMAKE_PREFIX_PATH=${{runner.workspace}}/build/install -DCMAKE_CXX_STANDARD=${{matrix.cpp}} \
58-
-DCC_TOOLS_QT_MAJOR_QT_VERSION=${{matrix.qt_ver}}
58+
-DOPT_QT_MAJOR_VERSION=${{matrix.qt_ver}}
5959
env:
6060
CC: gcc-${{matrix.cc_ver}}
6161
CXX: g++-${{matrix.cc_ver}}
@@ -121,7 +121,7 @@ jobs:
121121
run: |
122122
cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.type}} -DCMAKE_INSTALL_PREFIX=install \
123123
-DCMAKE_PREFIX_PATH=${{runner.workspace}}/build/install -DCMAKE_CXX_STANDARD=${{matrix.cpp}} \
124-
-DCC_TOOLS_QT_MAJOR_QT_VERSION=${{matrix.qt_ver}}
124+
-DOPT_QT_MAJOR_VERSION=${{matrix.qt_ver}}
125125
env:
126126
CC: clang-${{matrix.cc_ver}}
127127
CXX: clang++-${{matrix.cc_ver}}

CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ option (OPT_WARN_AS_ERR "Treat warning as error" ON)
66
option (OPT_USE_CCACHE "Use ccache on UNIX systems if it's available" ON)
77

88
# Extra configuration variables
9-
# OPT_MAJOR_QT_VERSION - Major Qt version. Defaults to 5
9+
# OPT_QT_MAJOR_VERSION - Major Qt version. Defaults to 5
1010

1111
# Extra standard CMake configuration
1212
# CMAKE_CXX_STANDARD - C++ standard to use, defaults (and min required) to 17
@@ -17,16 +17,16 @@ if ("${CMAKE_CXX_STANDARD}" STREQUAL "")
1717
set (CMAKE_CXX_STANDARD 17)
1818
endif ()
1919

20-
if ("${OPT_MAJOR_QT_VERSION}" STREQUAL "")
21-
set (OPT_MAJOR_QT_VERSION 5)
20+
if ("${OPT_QT_MAJOR_VERSION}" STREQUAL "")
21+
set (OPT_QT_MAJOR_VERSION 5)
2222
endif ()
2323

2424
find_package(LibComms REQUIRED NO_MODULE)
2525
find_package(cc_tools_qt REQUIRED NO_MODULE)
2626
find_package(cc_mqtt5_client REQUIRED NO_MODULE)
27-
find_package(Qt${OPT_MAJOR_QT_VERSION} REQUIRED COMPONENTS Widgets Core)
27+
find_package(Qt${OPT_QT_MAJOR_VERSION} REQUIRED COMPONENTS Widgets Core)
2828

29-
if (Qt${OPT_MAJOR_QT_VERSION}_VERSION VERSION_LESS 5.15)
29+
if (Qt${OPT_QT_MAJOR_VERSION}_VERSION VERSION_LESS 5.15)
3030
message(FATAL_ERROR "Minimum supported Qt version is 5.15!")
3131
endif()
3232

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@ This project has the following direct and transitive external dependencies:
2121
- [Qt](https://www.qt.io/) (**direct** dependency) - Qt5/6 libraries.
2222

2323

24-
All these dependencies are expected to be built externally and installation paths to the primary dependencies are expected to be passed
25-
to the `cmake` invocation
26-
using the **CMAKE_PREFIX_PATH** configuration variable:
24+
All these dependencies are expected to be built externally and installation paths to the primary dependencies are
25+
expected to be passed to the `cmake` invocation
26+
using the **CMAKE_PREFIX_PATH** configuration variable. Also the installation directory is expected to be the same as
27+
the one used to install the [CommsChampion Tools](https://github.com/commschamp/cc_tools_qt).
2728
```
28-
cmake -DCMAKE_PREFIX_PATH=/path/to/comms/install\;/path/to/cc_tools_qt/install\;/path/to/cc.mqtt5.libs ...
29+
cmake -DCMAKE_INSTALL_PREFIX=/path/to/cc_tools_qt/install \
30+
-DCMAKE_PREFIX_PATH=/path/to/comms/install\;/path/to/cc_tools_qt/install\;/path/to/cc.mqtt5.libs ...
2931
```
3032

31-
There are [prepare_externals.sh](script/prepare_externals.sh) (for Linux) and [prepare_externals.bat](script/prepare_externals.bat) (for Windows)
33+
There are [prepare_externals.sh](script/prepare_externals.sh) (for Linux) and
34+
[prepare_externals.bat](script/prepare_externals.bat) (for Windows)
3235
scripts that can be used to pull and build all the required dependencies (excluding the [Qt](https://www.qt.io/) libraries).
3336

3437
This project requires minimal **C++17** standard as well as Qt **v5.15** or above to get properly compiled.

script/full_debug_build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ${SCRIPT_DIR}/prepare_externals.sh
2020

2121
cd ${BUILD_DIR}
2222
cmake .. -DCMAKE_INSTALL_PREFIX=${COMMON_INSTALL_DIR} \
23-
-DCMAKE_BUILD_TYPE=${COMMON_BUILD_TYPE} -DOPT_MAJOR_QT_VERSION=${COMMON_QT_VER} "$@"
23+
-DCMAKE_BUILD_TYPE=${COMMON_BUILD_TYPE} -DOPT_QT_MAJOR_VERSION=${COMMON_QT_VER} "$@"
2424

2525
procs=$(nproc)
2626
if [ -n "${procs}" ]; then

src/Mqtt5ClientFilter.cpp

Lines changed: 145 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,30 @@ const QString& aliasSubscribesProp()
195195
return Str;
196196
}
197197

198+
const QString& subscribesRemoveProp()
199+
{
200+
static const QString Str("mqtt5.subscribes_remove");
201+
return Str;
202+
}
203+
204+
const QString& aliasSubscribesRemoveProp()
205+
{
206+
static const QString Str("mqtt.subscribes_remove");
207+
return Str;
208+
}
209+
210+
const QString& subscribesClearProp()
211+
{
212+
static const QString Str("mqtt5.subscribes_clear");
213+
return Str;
214+
}
215+
216+
const QString& aliasSubscribesClearProp()
217+
{
218+
static const QString Str("mqtt.subscribes_clear");
219+
return Str;
220+
}
221+
198222
const QString& keySubProp()
199223
{
200224
static const QString Str("key");
@@ -695,7 +719,73 @@ void Mqtt5ClientFilter::applyInterPluginConfigImpl(const QVariantMap& props)
695719
updated = true;
696720
}
697721
}
698-
}
722+
}
723+
724+
{
725+
static const QString* SubscribesRemoveProps[] = {
726+
&aliasSubscribesRemoveProp(),
727+
&subscribesRemoveProp(),
728+
};
729+
730+
for (auto* p : SubscribesRemoveProps) {
731+
auto var = props.value(*p);
732+
if ((!var.isValid()) || (!var.canConvert<QVariantList>())) {
733+
continue;
734+
}
735+
736+
auto subList = var.value<QVariantList>();
737+
738+
for (auto idx = 0; idx < subList.size(); ++idx) {
739+
auto& subVar = subList[idx];
740+
if ((!subVar.isValid()) || (!subVar.canConvert<QVariantMap>())) {
741+
continue;
742+
}
743+
744+
auto subMap = subVar.value<QVariantMap>();
745+
auto topicVar = subMap.value(topicSubProp());
746+
if ((!topicVar.isValid()) || (!topicVar.canConvert<QString>())) {
747+
continue;
748+
}
749+
750+
auto topic = topicVar.value<QString>();
751+
752+
auto iter =
753+
std::find_if(
754+
m_config.m_subscribes.begin(), m_config.m_subscribes.end(),
755+
[&topic](const auto& info)
756+
{
757+
return topic == info.m_topic;
758+
});
759+
760+
if (iter != m_config.m_subscribes.end()) {
761+
m_config.m_subscribes.erase(iter);
762+
updated = true;
763+
forceCleanStart();
764+
}
765+
}
766+
}
767+
}
768+
769+
{
770+
static const QString* SubscribesClearProps[] = {
771+
&aliasSubscribesClearProp(),
772+
&subscribesClearProp(),
773+
};
774+
775+
for (auto* p : SubscribesClearProps) {
776+
auto var = props.value(*p);
777+
if ((!var.isValid()) || (!var.canConvert<bool>())) {
778+
continue;
779+
}
780+
781+
if ((!var.value<bool>()) || (m_config.m_subscribes.empty())) {
782+
continue;
783+
}
784+
785+
m_config.m_subscribes.clear();
786+
updated = true;
787+
}
788+
}
699789

700790
{
701791
static const QString* SubscribesProps[] = {
@@ -705,61 +795,63 @@ void Mqtt5ClientFilter::applyInterPluginConfigImpl(const QVariantMap& props)
705795

706796
for (auto* p : SubscribesProps) {
707797
auto var = props.value(*p);
708-
if ((var.isValid()) && (var.canConvert<QVariantList>())) {
709-
auto subList = var.value<QVariantList>();
710-
711-
for (auto idx = 0; idx < subList.size(); ++idx) {
712-
auto& subVar = subList[idx];
713-
if ((!subVar.isValid()) || (!subVar.canConvert<QVariantMap>())) {
714-
continue;
715-
}
716-
717-
auto subMap = subVar.value<QVariantMap>();
718-
auto topicVar = subMap.value(topicSubProp());
719-
if ((!topicVar.isValid()) || (!topicVar.canConvert<QString>())) {
720-
continue;
721-
}
722-
723-
auto topic = topicVar.value<QString>();
724-
725-
auto iter =
726-
std::find_if(
727-
m_config.m_subscribes.begin(), m_config.m_subscribes.end(),
728-
[&topic](const auto& info)
729-
{
730-
return topic == info.m_topic;
731-
});
732-
733-
if (iter == m_config.m_subscribes.end()) {
734-
iter = m_config.m_subscribes.insert(m_config.m_subscribes.end(), SubConfig());
735-
iter->m_topic = topic;
736-
}
737-
738-
auto& subConfig = *iter;
739-
auto qosVar = subMap.value(qosSubProp());
740-
if (qosVar.isValid() && qosVar.canConvert<int>()) {
741-
subConfig.m_maxQos = qosVar.value<int>();
742-
}
743-
744-
auto retainHandlingVar = subMap.value(retainHandlingSubProp());
745-
if (retainHandlingVar.isValid() && retainHandlingVar.canConvert<int>()) {
746-
subConfig.m_retainHandling = retainHandlingVar.value<int>();
747-
}
748-
749-
auto noLocalVar = subMap.value(noLocalSubProp());
750-
if (noLocalVar.isValid() && noLocalVar.canConvert<bool>()) {
751-
subConfig.m_noLocal = noLocalVar.value<bool>();
752-
}
753-
754-
auto retainAsPublishedVar = subMap.value(retainAsPublishedSubProp());
755-
if (retainAsPublishedVar.isValid() && retainAsPublishedVar.canConvert<bool>()) {
756-
subConfig.m_retainAsPublished = retainAsPublishedVar.value<bool>();
757-
}
798+
if ((!var.isValid()) || (!var.canConvert<QVariantList>())) {
799+
continue;
800+
}
801+
802+
auto subList = var.value<QVariantList>();
803+
804+
for (auto idx = 0; idx < subList.size(); ++idx) {
805+
auto& subVar = subList[idx];
806+
if ((!subVar.isValid()) || (!subVar.canConvert<QVariantMap>())) {
807+
continue;
758808
}
809+
810+
auto subMap = subVar.value<QVariantMap>();
811+
auto topicVar = subMap.value(topicSubProp());
812+
if ((!topicVar.isValid()) || (!topicVar.canConvert<QString>())) {
813+
continue;
814+
}
815+
816+
auto topic = topicVar.value<QString>();
817+
818+
auto iter =
819+
std::find_if(
820+
m_config.m_subscribes.begin(), m_config.m_subscribes.end(),
821+
[&topic](const auto& info)
822+
{
823+
return topic == info.m_topic;
824+
});
759825

760-
updated = true;
761-
forceCleanStart();
826+
if (iter == m_config.m_subscribes.end()) {
827+
iter = m_config.m_subscribes.insert(m_config.m_subscribes.end(), SubConfig());
828+
iter->m_topic = topic;
829+
}
830+
831+
auto& subConfig = *iter;
832+
auto qosVar = subMap.value(qosSubProp());
833+
if (qosVar.isValid() && qosVar.canConvert<int>()) {
834+
subConfig.m_maxQos = qosVar.value<int>();
835+
}
836+
837+
auto retainHandlingVar = subMap.value(retainHandlingSubProp());
838+
if (retainHandlingVar.isValid() && retainHandlingVar.canConvert<int>()) {
839+
subConfig.m_retainHandling = retainHandlingVar.value<int>();
840+
}
841+
842+
auto noLocalVar = subMap.value(noLocalSubProp());
843+
if (noLocalVar.isValid() && noLocalVar.canConvert<bool>()) {
844+
subConfig.m_noLocal = noLocalVar.value<bool>();
845+
}
846+
847+
auto retainAsPublishedVar = subMap.value(retainAsPublishedSubProp());
848+
if (retainAsPublishedVar.isValid() && retainAsPublishedVar.canConvert<bool>()) {
849+
subConfig.m_retainAsPublished = retainAsPublishedVar.value<bool>();
850+
}
762851
}
852+
853+
updated = true;
854+
forceCleanStart();
763855
}
764856
}
765857

src/cc_plugin_mqtt5_client_filter.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@
1717
" \"retain_as_published\": false, - Retain as published.\n",
1818
" \"retain_handling\": 1 - Retain handling.\n",
1919
" }, {...}",
20-
" ] } - Update subscribes\n",
20+
" ] } - Add or update subscribes\n",
21+
" { \"mqtt5.subscribes_remove\": [\n",
22+
" {\n",
23+
" \"topic\": \"some/topic\" - Subscribe topic.\n",
24+
" }, {...}",
25+
" ] } - Remove subscribes\n",
26+
" { \"mqtt5.subscribes_clear\": true } - Clear all subscribes.\n",
2127
" { \"mqtt.client\": \"client_id\" } - Alias to \"mqtt5.client\".\n",
2228
" { \"mqtt.username\": \"username\" } - Alias to \"mqtt5.username\".\n",
2329
" { \"mqtt.password\": \"password\" } - Alias to \"mqtt5.password\".\n",
2430
" { \"mqtt.pub_topic\": \"pub_topic\" } - Alias to \"mqtt5.pub_topic\".\n",
2531
" { \"mqtt.pub_qos\": 1 } - Alias to \"mqtt5.pub_qos\".\n",
2632
" { \"mqtt.resp_topic\": \"resp_topic\" } - Alias to \"mqtt5.resp_topic\".\n",
2733
" { \"mqtt.subscribes\": [...] - Alias to \"mqtt5.subscribes\". \n",
34+
" { \"mqtt.subscribes_remove\": [...] - Alias to \"mqtt5.subscribes_remove\". \n",
35+
" { \"mqtt.subscribes_clear\": true } - Alias to \"mqtt5.subscribes_clear\". \n",
2836
"\n",
2937
"Supported message overriding properties:\n",
3038
" { \"mqtt5.topic\": \"some/topic\" } - Override publish topic\n",

0 commit comments

Comments
 (0)