MCPcopy Create free account
hub / github.com/Audio4Linux/JDSP4Linux / setInternal

Method setInternal

src/utils/dbus/IpcHandler.cpp:167–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167void IpcHandler::setInternal(const QString &key, const QDBusVariant &value) const
168{
169 QMetaEnum meta = QMetaEnum::fromType<DspConfig::Key>();
170 bool valid = false;
171 auto resolvedKey = static_cast<DspConfig::Key>(meta.keyToValue(key.toLocal8Bit().constData(), &valid));
172
173 if(!valid) {
174 sendErrorReply(QDBusError::InvalidArgs, "Configuration key does not exist");
175 return;
176 }
177
178 QVariant var = value.variant();
179 int type = QtCompat::variantTypeId(var);
180 // Type validation
181 if(type == QMetaType::QString ||
182 type == QMetaType::Bool ||
183 type == QMetaType::Double ||
184 var.canConvert(QMetaType::Int)) {
185 DspConfig::instance().set(resolvedKey, var);
186 }
187 else
188 sendErrorReply(QDBusError::InvalidArgs, "Invalid variant value type. Variant must contain one of these types: String, Boolean, Integer, or Float");
189}
190

Callers

nothing calls this directly

Calls 2

variantTypeIdFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected