mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-11 05:06:51 +00:00
GODT-1566: gui shows error notifications for IMAP/SMTP port errors on startup.
This commit is contained in:
@ -48,6 +48,8 @@ QtObject {
|
||||
|
||||
property var all: [
|
||||
root.noInternet,
|
||||
root.portIssueIMAP,
|
||||
root.portIssueSMTP,
|
||||
root.updateManualReady,
|
||||
root.updateManualRestartNeeded,
|
||||
root.updateManualError,
|
||||
@ -98,6 +100,38 @@ QtObject {
|
||||
}
|
||||
}
|
||||
|
||||
property Notification portIssueIMAP: Notification {
|
||||
description: qsTr("The IMAP server could not be started. Please check or change the IMAP port and restart the application.")
|
||||
brief: qsTr("IMAP port error")
|
||||
icon: "./icons/ic-alert.svg"
|
||||
type: Notification.NotificationType.Danger
|
||||
group: Notifications.Group.Connection
|
||||
|
||||
Connections {
|
||||
target: Backend
|
||||
|
||||
function onPortIssueIMAP() {
|
||||
root.portIssueIMAP.active = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property Notification portIssueSMTP: Notification {
|
||||
description: qsTr("The SMTP server could not be started. Please check or change the SMTP port and restart the application.")
|
||||
brief: qsTr("SMTP port error")
|
||||
icon: "./icons/ic-alert.svg"
|
||||
type: Notification.NotificationType.Danger
|
||||
group: Notifications.Group.Connection
|
||||
|
||||
Connections {
|
||||
target: Backend
|
||||
|
||||
function onPortIssueSMTP() {
|
||||
root.portIssueSMTP.active = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Updates
|
||||
property Notification updateManualReady: Notification {
|
||||
title: qsTr("Update to Bridge %1").arg(data ? data.version : "")
|
||||
|
||||
@ -50,6 +50,8 @@ type Service struct { // nolint:structcheck
|
||||
listener net.Listener
|
||||
eventStreamCh chan *StreamEvent
|
||||
eventStreamDoneCh chan struct{}
|
||||
eventQueue []*StreamEvent
|
||||
eventQueueMutex sync.Mutex
|
||||
|
||||
panicHandler types.PanicHandler
|
||||
eventListener listener.Listener
|
||||
|
||||
@ -20,7 +20,6 @@ package grpc
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
@ -47,6 +46,18 @@ func (s *Service) RunEventStream(request *EventStreamRequest, server Bridge_RunE
|
||||
s.eventStreamDoneCh = nil
|
||||
}()
|
||||
|
||||
// if events occurred before streaming started, they've been queued. Now that the stream channel is available
|
||||
// we can flush the queued
|
||||
go func() {
|
||||
s.eventQueueMutex.Lock()
|
||||
defer s.eventQueueMutex.Unlock()
|
||||
for _, event := range s.eventQueue {
|
||||
s.eventStreamCh <- event
|
||||
}
|
||||
|
||||
s.eventQueue = nil
|
||||
}()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-s.eventStreamDoneCh:
|
||||
@ -76,8 +87,13 @@ func (s *Service) StopEventStream(_ context.Context, _ *emptypb.Empty) (*emptypb
|
||||
|
||||
// SendEvent sends an event to the via the gRPC event stream.
|
||||
func (s *Service) SendEvent(event *StreamEvent) error {
|
||||
s.eventQueueMutex.Lock()
|
||||
defer s.eventQueueMutex.Unlock()
|
||||
|
||||
if s.eventStreamCh == nil {
|
||||
return errors.New("gRPC service is not streaming")
|
||||
// nobody is connected to the event stream, we queue events
|
||||
s.eventQueue = append(s.eventQueue, event)
|
||||
return nil
|
||||
}
|
||||
|
||||
s.eventStreamCh <- event
|
||||
|
||||
Reference in New Issue
Block a user