mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Add call settings (#5540)
This commit is contained in:
@@ -601,6 +601,7 @@ enum {
|
||||
dbiScalePercent = 0x58,
|
||||
dbiPlaybackSpeed = 0x59,
|
||||
dbiLanguagesKey = 0x5a,
|
||||
dbiCallSettings = 0x5b,
|
||||
|
||||
dbiEncryptedWithSalt = 333,
|
||||
dbiEncrypted = 444,
|
||||
@@ -886,6 +887,43 @@ void applyReadContext(ReadSettingsContext &&context) {
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray serializeCallSettings(){
|
||||
QByteArray result=QByteArray();
|
||||
uint32 size = 3*sizeof(qint32) + Serialize::stringSize(Global::CallOutputDeviceID()) + Serialize::stringSize(Global::CallInputDeviceID());
|
||||
result.reserve(size);
|
||||
QDataStream stream(&result, QIODevice::WriteOnly);
|
||||
stream.setVersion(QDataStream::Qt_5_1);
|
||||
stream << Global::CallOutputDeviceID();
|
||||
stream << qint32(Global::CallOutputVolume());
|
||||
stream << Global::CallInputDeviceID();
|
||||
stream << qint32(Global::CallInputVolume());
|
||||
stream << qint32(Global::CallAudioDuckingEnabled() ? 1 : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
void deserializeCallSettings(QByteArray& settings){
|
||||
QDataStream stream(&settings, QIODevice::ReadOnly);
|
||||
stream.setVersion(QDataStream::Qt_5_1);
|
||||
QString outputDeviceID;
|
||||
QString inputDeviceID;
|
||||
qint32 outputVolume;
|
||||
qint32 inputVolume;
|
||||
qint32 duckingEnabled;
|
||||
|
||||
stream >> outputDeviceID;
|
||||
stream >> outputVolume;
|
||||
stream >> inputDeviceID;
|
||||
stream >> inputVolume;
|
||||
stream >> duckingEnabled;
|
||||
if(_checkStreamStatus(stream)){
|
||||
Global::SetCallOutputDeviceID(outputDeviceID);
|
||||
Global::SetCallOutputVolume(outputVolume);
|
||||
Global::SetCallInputDeviceID(inputDeviceID);
|
||||
Global::SetCallInputVolume(inputVolume);
|
||||
Global::SetCallAudioDuckingEnabled(duckingEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSettingsContext &context) {
|
||||
switch (blockId) {
|
||||
case dbiDcOptionOldOld: {
|
||||
@@ -1786,6 +1824,14 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
|
||||
Global::SetVoiceMsgPlaybackDoubled(v == 2);
|
||||
} break;
|
||||
|
||||
case dbiCallSettings: {
|
||||
QByteArray callSettings;
|
||||
stream >> callSettings;
|
||||
if(!_checkStreamStatus(stream)) return false;
|
||||
|
||||
deserializeCallSettings(callSettings);
|
||||
} break;
|
||||
|
||||
default:
|
||||
LOG(("App Error: unknown blockId in _readSetting: %1").arg(blockId));
|
||||
return false;
|
||||
@@ -2002,6 +2048,7 @@ void _writeUserSettings() {
|
||||
auto userData = userDataInstance
|
||||
? userDataInstance->serialize()
|
||||
: QByteArray();
|
||||
auto callSettings = serializeCallSettings();
|
||||
|
||||
uint32 size = 23 * (sizeof(quint32) + sizeof(qint32));
|
||||
size += sizeof(quint32) + Serialize::stringSize(Global::AskDownloadPath() ? QString() : Global::DownloadPath()) + Serialize::bytearraySize(Global::AskDownloadPath() ? QByteArray() : Global::DownloadPathBookmark());
|
||||
@@ -2024,6 +2071,7 @@ void _writeUserSettings() {
|
||||
if (!userData.isEmpty()) {
|
||||
size += sizeof(quint32) + Serialize::bytearraySize(userData);
|
||||
}
|
||||
size += sizeof(quint32) + Serialize::bytearraySize(callSettings);
|
||||
|
||||
EncryptedDescriptor data(size);
|
||||
data.stream
|
||||
@@ -2073,6 +2121,7 @@ void _writeUserSettings() {
|
||||
if (!Global::HiddenPinnedMessages().isEmpty()) {
|
||||
data.stream << quint32(dbiHiddenPinnedMessages) << Global::HiddenPinnedMessages();
|
||||
}
|
||||
data.stream << qint32(dbiCallSettings) << callSettings;
|
||||
|
||||
FileWriteDescriptor file(_userSettingsKey);
|
||||
file.writeEncrypted(data);
|
||||
|
Reference in New Issue
Block a user