| 165 | } |
| 166 | |
| 167 | void 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 |
nothing calls this directly
no test coverage detected