Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- accessibility: arrow-key navigation for message list, gallery and sticker picker #4294, #4376, #4372,
- accessibility: arrow-key navigation: handle "End" and "Home" keys to go to last / first item #4438
- add show_app_in_chat option to webxdc info message context menu #4459
- add experimental content protection option (to prevent screenshots and screenrecording the app) #4475
- app picker for webxdc apps in attachement menu #4485

## Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import useTranslationFunction from '../../hooks/useTranslationFunction'
import useDialog from '../../hooks/dialog/useDialog'
import SettingsSwitch from './SettingsSwitch'
import { runtime } from '@deltachat-desktop/runtime-interface'

type Props = {
settingsStore: SettingsStoreState
Expand Down Expand Up @@ -84,6 +85,13 @@ export function ExperimentalFeatures({ settingsStore }: Props) {
settingsKey='experimentalEnableMarkdownInMessages'
label='Render Markdown in Messages'
/>
{runtime.getRuntimeInfo().isContentProtectionSupported && (
<DesktopSettingsSwitch
settingsKey='contentProtectionEnabled'
label={tx('pref_screen_security')}
description={tx('pref_screen_security_explain')}
/>
)}
<CoreSettingsSwitch
label={tx('disable_imap_idle')}
settingsKey='disable_idle'
Expand Down
6 changes: 6 additions & 0 deletions packages/shared/shared-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export interface DesktopSettingsType {
galleryImageKeepAspectRatio: boolean
/** whether to use system ui font */
useSystemUIFont: boolean
/**
* Tell the operating system to prevent screen recoding and screenshots for delta chat
* also called screen_security
*/
contentProtectionEnabled: boolean
}

export interface RC_Config {
Expand Down Expand Up @@ -87,6 +92,7 @@ export type RuntimeInfo = {
runningUnderARM64Translation?: boolean
rpcServerPath?: string
buildInfo: BuildInfo
isContentProtectionSupported: boolean
}

export interface BuildInfo {
Expand Down
1 change: 1 addition & 0 deletions packages/shared/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ export function getDefaultState(): DesktopSettingsType {
enableRelatedChats: false,
galleryImageKeepAspectRatio: false,
useSystemUIFont: false,
contentProtectionEnabled: false,
}
}
1 change: 1 addition & 0 deletions packages/target-browser/src/backendApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ BackendApiRoute.get('/runtime_info', (_req, res) => {
isMac: false, // this has an alternative frameless design that we don't want in browser
target: 'browser',
versions: [],
isContentProtectionSupported: false,
}
res.status(200).json(runtimeInfo)
})
Expand Down
26 changes: 26 additions & 0 deletions packages/target-electron/src/content-protection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { BrowserWindow } from 'electron'
import { DesktopSettings } from './desktop_settings'
import { platform } from 'os'
import { getLogger } from '@deltachat-desktop/shared/logger'

const log = getLogger('contentProtection')

function updateContentProtection(window: BrowserWindow, enabled: boolean) {
window.setContentProtection(enabled)
if (enabled && platform() !== 'darwin' && platform() !== 'win32') {
log.warn('setContentProtection not available on your platform', platform())
}
}

export function setContentProtection(window: BrowserWindow) {
updateContentProtection(
window,
DesktopSettings.state.contentProtectionEnabled
)
}

export function updateContentProtectionOnAllActiveWindows(enabled: boolean) {
for (const win of BrowserWindow.getAllWindows()) {
updateContentProtection(win, enabled)
}
}
2 changes: 2 additions & 0 deletions packages/target-electron/src/deltachat/webxdc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
refresh as refreshTitleMenu,
} from '../menu.js'
import { T } from '@deltachat/jsonrpc-client'
import { setContentProtection } from '../content-protection.js'

const __dirname = dirname(fileURLToPath(import.meta.url))

Expand Down Expand Up @@ -271,6 +272,7 @@ export default class DCWebxdc extends SplitOut {
alwaysOnTop: main_window?.isAlwaysOnTop(),
show: false,
})
setContentProtection(webxdcWindow)
// reposition the window to last position (or default)
webxdcWindow.setBounds(lastBounds, true)
// show after repositioning to avoid blinking
Expand Down
9 changes: 8 additions & 1 deletion packages/target-electron/src/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { openHtmlEmailWindow } from './windows/html_email.js'
import { appx, mapPackagePath } from './isAppx.js'
import DeltaChatController from './deltachat/controller.js'
import { BuildInfo } from './get-build-info.js'
import { updateContentProtectionOnAllActiveWindows } from './content-protection.js'

const __dirname = dirname(fileURLToPath(import.meta.url))

Expand Down Expand Up @@ -129,6 +130,8 @@ ${error instanceof Error ? error.message : inspect(error, { depth: null })}`
runningUnderARM64Translation: app.runningUnderARM64Translation,
rpcServerPath: dcController.rpcServerPath,
buildInfo: BuildInfo,
isContentProtectionSupported:
platform() === 'darwin' || platform() === 'win32',
}
ev.returnValue = info
})
Expand Down Expand Up @@ -201,7 +204,11 @@ ${error instanceof Error ? error.message : inspect(error, { depth: null })}`
) => {
DesktopSettings.update({ [key]: value })

if (key === 'minimizeToTray') updateTrayIcon()
if (key === 'minimizeToTray') {
updateTrayIcon()
} else if (key === 'contentProtectionEnabled') {
updateContentProtectionOnAllActiveWindows(Boolean(value))
}

return true
}
Expand Down
3 changes: 3 additions & 0 deletions packages/target-electron/src/windows/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
refresh as refreshTitleMenu,
} from '../menu.js'
import { initMinWinDimensionHandling } from './helpers.js'
import { setContentProtection } from '../content-protection.js'

const log = getLogger('main/help')

Expand Down Expand Up @@ -76,6 +77,8 @@ export async function openHelpWindow(locale: string, anchor?: string) {
alwaysOnTop: main_window?.isAlwaysOnTop(),
}))

setContentProtection(help_window)

const removeScreenChangeListeners = initMinWinDimensionHandling(
help_window,
defaults.minWidth,
Expand Down
3 changes: 3 additions & 0 deletions packages/target-electron/src/windows/html_email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
refresh as refreshTitleMenu,
} from '../menu.js'
import { initMinWinDimensionHandling } from './helpers.js'
import { setContentProtection } from '../content-protection.js'

const log = getLogger('html_email')

Expand Down Expand Up @@ -92,6 +93,8 @@ export function openHtmlEmailWindow(
}))
window.webContents.setZoomFactor(DesktopSettings.state.zoomFactor)

setContentProtection(window)

const removeScreenChangeListeners = initMinWinDimensionHandling(
window,
400,
Expand Down
3 changes: 3 additions & 0 deletions packages/target-electron/src/windows/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { refreshTrayContextMenu } from '../tray.js'
import { DesktopSettings } from '../desktop_settings.js'
import { refresh as refreshTitleMenu } from '../menu.js'
import { initMinWinDimensionHandling } from './helpers.js'
import { setContentProtection } from '../content-protection.js'

const log = getLogger('/mainWindow')

Expand Down Expand Up @@ -79,6 +80,8 @@ export function init(options: { hidden: boolean }) {

initMinWinDimensionHandling(mainWindow, defaults.minWidth, defaults.minHeight)

setContentProtection(window)

// disable network request to fetch dictionary
// issue: https://github.com/electron/electron/issues/22995
// feature request for local dictionary: https://github.com/electron/electron/issues/22995
Expand Down
Loading