2020-11-30 17:40:38 +01:00
|
|
|
package handler
|
|
|
|
|
|
|
|
import (
|
2021-09-01 23:10:18 +02:00
|
|
|
"errors"
|
|
|
|
|
2022-07-14 00:58:22 +02:00
|
|
|
"github.com/demodesk/neko/pkg/types"
|
|
|
|
"github.com/demodesk/neko/pkg/types/message"
|
2020-11-30 17:40:38 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func (h *MessageHandlerCtx) clipboardSet(session types.Session, payload *message.ClipboardData) error {
|
2021-03-14 00:45:51 +01:00
|
|
|
if !session.Profile().CanAccessClipboard {
|
2021-09-01 23:10:18 +02:00
|
|
|
return errors.New("cannot access clipboard")
|
2020-12-06 18:55:24 +01:00
|
|
|
}
|
|
|
|
|
2020-11-30 17:40:38 +01:00
|
|
|
if !session.IsHost() {
|
2021-09-01 23:10:18 +02:00
|
|
|
return errors.New("is not the host")
|
2020-11-30 17:40:38 +01:00
|
|
|
}
|
|
|
|
|
2021-01-29 20:05:13 +01:00
|
|
|
return h.desktop.ClipboardSetText(types.ClipboardText{
|
|
|
|
Text: payload.Text,
|
|
|
|
// TODO: Send HTML?
|
|
|
|
})
|
2020-11-30 17:40:38 +01:00
|
|
|
}
|