Newer
Older
}
// 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());
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
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});
});
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
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::roomSortingChanged, this, [this]() {
emit dataChanged(index(SortByImportance), index(SortByImportance), {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});
});
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
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
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});
});