forked from Silverfish/proton-bridge
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: [
|
property var all: [
|
||||||
root.noInternet,
|
root.noInternet,
|
||||||
|
root.portIssueIMAP,
|
||||||
|
root.portIssueSMTP,
|
||||||
root.updateManualReady,
|
root.updateManualReady,
|
||||||
root.updateManualRestartNeeded,
|
root.updateManualRestartNeeded,
|
||||||
root.updateManualError,
|
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
|
// Updates
|
||||||
property Notification updateManualReady: Notification {
|
property Notification updateManualReady: Notification {
|
||||||
title: qsTr("Update to Bridge %1").arg(data ? data.version : "")
|
title: qsTr("Update to Bridge %1").arg(data ? data.version : "")
|
||||||
|
|||||||
@ -50,6 +50,8 @@ type Service struct { // nolint:structcheck
|
|||||||
listener net.Listener
|
listener net.Listener
|
||||||
eventStreamCh chan *StreamEvent
|
eventStreamCh chan *StreamEvent
|
||||||
eventStreamDoneCh chan struct{}
|
eventStreamDoneCh chan struct{}
|
||||||
|
eventQueue []*StreamEvent
|
||||||
|
eventQueueMutex sync.Mutex
|
||||||
|
|
||||||
panicHandler types.PanicHandler
|
panicHandler types.PanicHandler
|
||||||
eventListener listener.Listener
|
eventListener listener.Listener
|
||||||
|
|||||||
@ -20,7 +20,6 @@ package grpc
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
"google.golang.org/protobuf/types/known/emptypb"
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
@ -47,6 +46,18 @@ func (s *Service) RunEventStream(request *EventStreamRequest, server Bridge_RunE
|
|||||||
s.eventStreamDoneCh = nil
|
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 {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-s.eventStreamDoneCh:
|
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.
|
// SendEvent sends an event to the via the gRPC event stream.
|
||||||
func (s *Service) SendEvent(event *StreamEvent) error {
|
func (s *Service) SendEvent(event *StreamEvent) error {
|
||||||
|
s.eventQueueMutex.Lock()
|
||||||
|
defer s.eventQueueMutex.Unlock()
|
||||||
|
|
||||||
if s.eventStreamCh == nil {
|
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
|
s.eventStreamCh <- event
|
||||||
|
|||||||
Reference in New Issue
Block a user