Newer
Older
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
i->setCameraResolution(data(index, Values).toStringList().at(value.toInt()));
return true;
} else
return false;
}
case CameraFrameRate: {
if (value.userType() == QMetaType::Int) {
i->setCameraFrameRate(data(index, Values).toStringList().at(value.toInt()));
return true;
} else
return false;
}
case UseStunServer: {
if (value.userType() == QMetaType::Bool) {
i->setUseStunServer(value.toBool());
return true;
} else
return false;
}
case OnlyShareKeysWithVerifiedUsers: {
if (value.userType() == QMetaType::Bool) {
i->setOnlyShareKeysWithVerifiedUsers(value.toBool());
return true;
} else
return false;
}
case ShareKeysWithTrustedUsers: {
if (value.userType() == QMetaType::Bool) {
i->setShareKeysWithTrustedUsers(value.toBool());
return true;
} else
return false;
}
case UseOnlineKeyBackup: {
if (value.userType() == QMetaType::Bool) {
i->setUseOnlineKeyBackup(value.toBool());
return true;
} else
return false;
}
case ExposeDBusApi: {
if (value.userType() == QMetaType::Bool) {
i->setExposeDBusApi(value.toBool());
return true;
} else
return false;
}
case UpdateSpaceVias: {
if (value.userType() == QMetaType::Bool) {
i->setUpdateSpaceVias(value.toBool());
return true;
} else
return false;
}
case ExpireEvents: {
if (value.userType() == QMetaType::Bool) {
i->setExpireEvents(value.toBool());
return true;
} else
return false;
}
const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
const QString fileName = QFileDialog::getOpenFileName(
nullptr, tr("Open Sessions File"), homeFolder, QLatin1String(""));
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::warning(nullptr, tr("Error"), file.errorString());
return;
}
auto bin = file.peek(file.size());
auto payload = std::string(bin.data(), bin.size());
bool ok;
auto password = QInputDialog::getText(nullptr,
tr("File Password"),
tr("Enter the passphrase to decrypt the file:"),
QLineEdit::Password,
&ok);
if (!ok)
return;
if (password.isEmpty()) {
QMessageBox::warning(nullptr, tr("Error"), tr("The password cannot be empty"));
return;
}
try {
auto sessions = mtx::crypto::decrypt_exported_sessions(payload, password.toStdString());
cache::importSessionKeys(std::move(sessions));
} catch (const std::exception &e) {
QMessageBox::warning(nullptr, tr("Error"), e.what());
}
void
auto password = QInputDialog::getText(nullptr,
tr("File Password"),
tr("Enter passphrase to encrypt your session keys:"),
QLineEdit::Password,
&ok);
if (!ok)
return;
if (password.isEmpty()) {
QMessageBox::warning(nullptr, tr("Error"), tr("The password cannot be empty"));
return;
}
// Open file dialog to save the file.
const QString homeFolder = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
const QString fileName = QFileDialog::getSaveFileName(
nullptr, tr("File to save the exported session keys"), homeFolder);
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::warning(nullptr, tr("Error"), file.errorString());
return;
}
// Export sessions & save to file.
try {
auto encrypted_blob = mtx::crypto::encrypt_exported_sessions(cache::exportSessionKeys(),
password.toStdString());
QString b64 = QString::fromStdString(mtx::crypto::bin2base64(encrypted_blob));
QString prefix(QStringLiteral("-----BEGIN MEGOLM SESSION DATA-----"));
QString suffix(QStringLiteral("-----END MEGOLM SESSION DATA-----"));
QString newline(QStringLiteral("\n"));
QTextStream out(&file);
out << prefix << newline << b64 << newline << suffix << newline;
file.close();
} catch (const std::exception &e) {
QMessageBox::warning(nullptr, tr("Error"), e.what());
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
UserSettingsModel::requestCrossSigningSecrets()
{
olm::request_cross_signing_keys();
}
void
UserSettingsModel::downloadCrossSigningSecrets()
{
olm::download_cross_signing_keys();
}
UserSettingsModel::UserSettingsModel(QObject *p)
: QAbstractListModel(p)
{
auto s = UserSettings::instance();
connect(s.get(), &UserSettings::themeChanged, this, [this]() {
emit dataChanged(index(Theme), index(Theme), {Value});
});
connect(s.get(), &UserSettings::mobileModeChanged, this, [this]() {
emit dataChanged(index(MobileMode), index(MobileMode), {Value});
});
connect(s.get(), &UserSettings::fontChanged, this, [this]() {
emit dataChanged(index(Font), index(Font), {Value});
});
connect(s.get(), &UserSettings::fontSizeChanged, this, [this]() {
emit dataChanged(index(FontSize), index(FontSize), {Value});
});
connect(s.get(), &UserSettings::emojiFontChanged, this, [this]() {
emit dataChanged(index(EmojiFont), index(EmojiFont), {Value});
});
connect(s.get(), &UserSettings::avatarCirclesChanged, this, [this]() {
emit dataChanged(index(AvatarCircles), index(AvatarCircles), {Value});
});
connect(s.get(), &UserSettings::useIdenticonChanged, this, [this]() {
emit dataChanged(index(UseIdenticon), index(UseIdenticon), {Value});
});
connect(s.get(), &UserSettings::openImageExternalChanged, this, [this]() {
emit dataChanged(index(OpenImageExternal), index(OpenImageExternal), {Value});
});
connect(s.get(), &UserSettings::openVideoExternalChanged, this, [this]() {
emit dataChanged(index(OpenVideoExternal), index(OpenVideoExternal), {Value});
});
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
connect(s.get(), &UserSettings::privacyScreenChanged, this, [this]() {
emit dataChanged(index(PrivacyScreen), index(PrivacyScreen), {Value});
emit dataChanged(index(PrivacyScreenTimeout), index(PrivacyScreenTimeout), {Enabled});
});
connect(s.get(), &UserSettings::privacyScreenTimeoutChanged, this, [this]() {
emit dataChanged(index(PrivacyScreenTimeout), index(PrivacyScreenTimeout), {Value});
});
connect(s.get(), &UserSettings::timelineMaxWidthChanged, this, [this]() {
emit dataChanged(index(TimelineMaxWidth), index(TimelineMaxWidth), {Value});
});
connect(s.get(), &UserSettings::messageHoverHighlightChanged, this, [this]() {
emit dataChanged(index(MessageHoverHighlight), index(MessageHoverHighlight), {Value});
});
connect(s.get(), &UserSettings::enlargeEmojiOnlyMessagesChanged, this, [this]() {
emit dataChanged(index(EnlargeEmojiOnlyMessages), index(EnlargeEmojiOnlyMessages), {Value});
});
connect(s.get(), &UserSettings::animateImagesOnHoverChanged, this, [this]() {
emit dataChanged(index(AnimateImagesOnHover), index(AnimateImagesOnHover), {Value});
});
connect(s.get(), &UserSettings::typingNotificationsChanged, this, [this]() {
emit dataChanged(index(TypingNotifications), index(TypingNotifications), {Value});
});
connect(s.get(), &UserSettings::readReceiptsChanged, this, [this]() {
emit dataChanged(index(ReadReceipts), index(ReadReceipts), {Value});
});
connect(s.get(), &UserSettings::buttonInTimelineChanged, this, [this]() {
emit dataChanged(index(ButtonsInTimeline), index(ButtonsInTimeline), {Value});
});
connect(s.get(), &UserSettings::markdownChanged, this, [this]() {
emit dataChanged(index(Markdown), index(Markdown), {Value});
});
connect(s.get(), &UserSettings::invertEnterKeyChanged, this, [this]() {
emit dataChanged(index(InvertEnterKey), index(InvertEnterKey), {Value});
});
connect(s.get(), &UserSettings::bubblesChanged, this, [this]() {
emit dataChanged(index(Bubbles), index(Bubbles), {Value});
});
connect(s.get(), &UserSettings::smallAvatarsChanged, this, [this]() {
emit dataChanged(index(SmallAvatars), index(SmallAvatars), {Value});
});
connect(s.get(), &UserSettings::groupViewStateChanged, this, [this]() {
emit dataChanged(index(GroupView), index(GroupView), {Value});
});
connect(s.get(), &UserSettings::scrollbarsInRoomlistChanged, this, [this]() {
emit dataChanged(index(ScrollbarsInRoomlist), index(ScrollbarsInRoomlist), {Value});
});
connect(s.get(), &UserSettings::roomSortingChangedImportance, this, [this]() {
emit dataChanged(index(SortByImportance), index(SortByImportance), {Value});
});
connect(s.get(), &UserSettings::roomSortingChangedAlphabetical, this, [this]() {
emit dataChanged(index(SortByAlphabet), index(SortByAlphabet), {Value});
});
connect(s.get(), &UserSettings::decryptSidebarChanged, this, [this]() {
emit dataChanged(index(DecryptSidebar), index(DecryptSidebar), {Value});
});
connect(s.get(), &UserSettings::decryptNotificationsChanged, this, [this]() {
emit dataChanged(index(DecryptNotifications), index(DecryptNotifications), {Value});
});
connect(s.get(), &UserSettings::spaceNotificationsChanged, this, [this]() {
emit dataChanged(index(SpaceNotifications), index(SpaceNotifications), {Value});
});
connect(s.get(), &UserSettings::fancyEffectsChanged, this, [this]() {
emit dataChanged(index(FancyEffects), index(FancyEffects), {Value});
});
connect(s.get(), &UserSettings::reducedMotionChanged, this, [this]() {
emit dataChanged(index(ReducedMotion), index(ReducedMotion), {Value});
});
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
connect(s.get(), &UserSettings::trayChanged, this, [this]() {
emit dataChanged(index(Tray), index(Tray), {Value});
emit dataChanged(index(StartInTray), index(StartInTray), {Enabled});
});
connect(s.get(), &UserSettings::startInTrayChanged, this, [this]() {
emit dataChanged(index(StartInTray), index(StartInTray), {Value});
});
connect(s.get(), &UserSettings::desktopNotificationsChanged, this, [this]() {
emit dataChanged(index(DesktopNotifications), index(DesktopNotifications), {Value});
});
connect(s.get(), &UserSettings::alertOnNotificationChanged, this, [this]() {
emit dataChanged(index(AlertOnNotification), index(AlertOnNotification), {Value});
});
connect(s.get(), &UserSettings::useStunServerChanged, this, [this]() {
emit dataChanged(index(UseStunServer), index(UseStunServer), {Value});
});
connect(s.get(), &UserSettings::microphoneChanged, this, [this]() {
emit dataChanged(index(Microphone), index(Microphone), {Value, Values});
});
connect(s.get(), &UserSettings::cameraChanged, this, [this]() {
emit dataChanged(index(Camera), index(Camera), {Value, Values});
});
connect(s.get(), &UserSettings::cameraResolutionChanged, this, [this]() {
emit dataChanged(index(CameraResolution), index(CameraResolution), {Value, Values});
});
connect(s.get(), &UserSettings::cameraFrameRateChanged, this, [this]() {
emit dataChanged(index(CameraFrameRate), index(CameraFrameRate), {Value, Values});
});
connect(s.get(), &UserSettings::ringtoneChanged, this, [this]() {
emit dataChanged(index(Ringtone), index(Ringtone), {Values, Value});
});
connect(s.get(), &UserSettings::onlyShareKeysWithVerifiedUsersChanged, this, [this]() {
emit dataChanged(
index(OnlyShareKeysWithVerifiedUsers), index(OnlyShareKeysWithVerifiedUsers), {Value});
});
connect(s.get(), &UserSettings::shareKeysWithTrustedUsersChanged, this, [this]() {
emit dataChanged(
index(ShareKeysWithTrustedUsers), index(ShareKeysWithTrustedUsers), {Value});
});
connect(s.get(), &UserSettings::useOnlineKeyBackupChanged, this, [this]() {
emit dataChanged(index(UseOnlineKeyBackup), index(UseOnlineKeyBackup), {Value});
});
connect(MainWindow::instance(), &MainWindow::secretsChanged, this, [this]() {
emit dataChanged(index(OnlineBackupKey), index(MasterKey), {Value, Good});
});
connect(s.get(), &UserSettings::exposeDBusApiChanged, this, [this] {
emit dataChanged(index(ExposeDBusApi), index(ExposeDBusApi), {Value});
});
connect(s.get(), &UserSettings::updateSpaceViasChanged, this, [this] {
emit dataChanged(index(UpdateSpaceVias), index(UpdateSpaceVias), {Value});
});
connect(s.get(), &UserSettings::expireEventsChanged, this, [this] {
emit dataChanged(index(ExpireEvents), index(ExpireEvents), {Value});
});