| 219 | } |
| 220 | |
| 221 | void TopicHandlerService::unregisterTopics(const String& deviceId, const String& entityId, IPluginMaintenance* plugin, bool purge) |
| 222 | { |
| 223 | if ((false == deviceId.isEmpty()) && |
| 224 | (nullptr != plugin)) |
| 225 | { |
| 226 | const size_t JSON_DOC_SIZE = 512U; |
| 227 | DynamicJsonDocument topicsDoc(JSON_DOC_SIZE); |
| 228 | JsonArray jsonTopics = topicsDoc.createNestedArray("topics"); |
| 229 | |
| 230 | /* Get topics from plugin. */ |
| 231 | plugin->getTopics(jsonTopics); |
| 232 | |
| 233 | /* Handle each topic */ |
| 234 | if (0U < jsonTopics.size()) |
| 235 | { |
| 236 | for (JsonVariantConst jsonTopic : jsonTopics) |
| 237 | { |
| 238 | String topicName; |
| 239 | |
| 240 | /* Topic specific parameter available? */ |
| 241 | if (true == jsonTopic.is<JsonObjectConst>()) |
| 242 | { |
| 243 | JsonVariantConst jsonTopicName = jsonTopic["name"]; |
| 244 | |
| 245 | if (true == jsonTopicName.is<String>()) |
| 246 | { |
| 247 | topicName = jsonTopicName.as<const char*>(); |
| 248 | } |
| 249 | } |
| 250 | /* Only topic name is available */ |
| 251 | else if (true == jsonTopic.is<String>()) |
| 252 | { |
| 253 | topicName = jsonTopic.as<const char*>(); |
| 254 | } |
| 255 | else |
| 256 | { |
| 257 | /* Skip */ |
| 258 | ; |
| 259 | } |
| 260 | |
| 261 | if (false == topicName.isEmpty()) |
| 262 | { |
| 263 | unregisterTopic(deviceId, entityId, topicName, purge); |
| 264 | |
| 265 | removeFromTopicMetaDataList(deviceId, entityId, topicName); |
| 266 | removeFromPluginList(plugin, topicName); |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | void TopicHandlerService::registerTopic(const String& deviceId, const String& entityId, const String& topic, JsonObjectConst& jsonExtra, ITopicHandler::GetTopicFunc getTopicFunc, HasChangedFunc hasChangedFunc, ITopicHandler::SetTopicFunc setTopicFunc, ITopicHandler::UploadReqFunc uploadReqFunc) |
| 274 | { |
no test coverage detected