GODT-1846: remove restart cues, implement restart-less behaviour.

Other: fixed case issue in SSL member function names.
Other: removed 'restart' mention in SMTP and IMAP SSL settings.
GODT-1846: modified gRPC server to introduce ConnectionMode settings.
GODT-1846: implemented connection mode handling in bridge-gui.
GODT-1846: implemented error reporting in bridge-gui for connection mode.
Other: gathered all IMAP/SMTP server settings.
GODT-1846: wired IMAP/SMTP port change errors.
Other: Renamed some error events and signals.
Other: Fixed crash in IMAP restart when not started.
Other: dismiss port error notifications before changing ports.
Other: misc. fixes.
This commit is contained in:
Xavier Michelon
2022-11-20 09:58:20 +01:00
committed by James Houlahan
parent 46c0463e43
commit 1f0312573a
25 changed files with 3249 additions and 4244 deletions

File diff suppressed because it is too large Load Diff

View File

@ -78,14 +78,9 @@ service Bridge {
// mail
rpc SetIsDoHEnabled(google.protobuf.BoolValue) returns (google.protobuf.Empty);
rpc IsDoHEnabled(google.protobuf.Empty) returns (google.protobuf.BoolValue);
rpc SetUseSslForSmtp(google.protobuf.BoolValue) returns (google.protobuf.Empty);
rpc UseSslForSmtp(google.protobuf.Empty) returns (google.protobuf.BoolValue);
rpc SetUseSslForImap(google.protobuf.BoolValue) returns (google.protobuf.Empty);
rpc UseSslForImap(google.protobuf.Empty) returns (google.protobuf.BoolValue);
rpc MailServerSettings(google.protobuf.Empty) returns (ImapSmtpSettings);
rpc SetMailServerSettings(ImapSmtpSettings) returns (google.protobuf.Empty);
rpc Hostname(google.protobuf.Empty) returns (google.protobuf.StringValue);
rpc ImapPort(google.protobuf.Empty) returns (google.protobuf.Int32Value);
rpc SmtpPort(google.protobuf.Empty) returns (google.protobuf.Int32Value);
rpc ChangePorts(ChangePortsRequest) returns (google.protobuf.Empty);
rpc IsPortFree(google.protobuf.Int32Value) returns (google.protobuf.BoolValue);
// keychain
@ -158,11 +153,13 @@ message LoginAbortRequest {
}
//**********************************************************
// Port related message
// IMAP/SMTP Mail Server settings
//**********************************************************
message ChangePortsRequest {
message ImapSmtpSettings {
int32 imapPort = 1;
int32 smtpPort = 2;
bool useSSLForImap = 3;
bool useSSLForSmtp = 4;
}
//**********************************************************
@ -222,7 +219,7 @@ message StreamEvent {
LoginEvent login = 2;
UpdateEvent update = 3;
DiskCacheEvent cache = 4;
MailSettingsEvent mailSettings = 5;
MailServerSettingsEvent mailServerSettings = 5;
KeychainEvent keychain = 6;
MailEvent mail = 7;
UserEvent user = 8;
@ -368,31 +365,28 @@ message DiskCachePathChangeFinishedEvent {}
//**********************************************************
// Mail settings related events
// Mail server settings related events
//**********************************************************
message MailSettingsEvent {
message MailServerSettingsEvent {
oneof event {
MailSettingsErrorEvent error = 1;
UseSslForSmtpFinishedEvent useSslForSmtpFinished = 2;
ChangePortsFinishedEvent changePortsFinished = 3;
UseSslForImapFinishedEvent useSslForImapFinished = 4;
MailServerSettingsErrorEvent error = 1;
MailServerSettingsChangedEvent mailServerSettingsChanged = 2;
ChangeMailServerSettingsFinishedEvent changeMailServerSettingsFinished = 3;
}
}
enum MailSettingsErrorType {
IMAP_PORT_ISSUE = 0;
SMTP_PORT_ISSUE = 1;
enum MailServerSettingsErrorType {
IMAP_PORT_STARTUP_ERROR = 0;
SMTP_PORT_STARTUP_ERROR = 1;
IMAP_PORT_CHANGE_ERROR = 2;
SMTP_PORT_CHANGE_ERROR = 3;
IMAP_CONNECTION_MODE_CHANGE_ERROR = 4;
SMTP_CONNECTION_MODE_CHANGE_ERROR = 5;
}
message MailSettingsErrorEvent {
MailSettingsErrorType type = 1;
}
message UseSslForSmtpFinishedEvent {}
message UseSslForImapFinishedEvent {}
message ChangePortsFinishedEvent {}
message MailServerSettingsErrorEvent { MailServerSettingsErrorType type = 1; }
message MailServerSettingsChangedEvent { ImapSmtpSettings settings = 1; }
message ChangeMailServerSettingsFinishedEvent {}
//**********************************************************
// keychain related events

View File

@ -69,14 +69,9 @@ type BridgeClient interface {
// mail
SetIsDoHEnabled(ctx context.Context, in *wrapperspb.BoolValue, opts ...grpc.CallOption) (*emptypb.Empty, error)
IsDoHEnabled(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.BoolValue, error)
SetUseSslForSmtp(ctx context.Context, in *wrapperspb.BoolValue, opts ...grpc.CallOption) (*emptypb.Empty, error)
UseSslForSmtp(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.BoolValue, error)
SetUseSslForImap(ctx context.Context, in *wrapperspb.BoolValue, opts ...grpc.CallOption) (*emptypb.Empty, error)
UseSslForImap(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.BoolValue, error)
MailServerSettings(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ImapSmtpSettings, error)
SetMailServerSettings(ctx context.Context, in *ImapSmtpSettings, opts ...grpc.CallOption) (*emptypb.Empty, error)
Hostname(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.StringValue, error)
ImapPort(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.Int32Value, error)
SmtpPort(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.Int32Value, error)
ChangePorts(ctx context.Context, in *ChangePortsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
IsPortFree(ctx context.Context, in *wrapperspb.Int32Value, opts ...grpc.CallOption) (*wrapperspb.BoolValue, error)
// keychain
AvailableKeychains(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*AvailableKeychainsResponse, error)
@ -462,36 +457,18 @@ func (c *bridgeClient) IsDoHEnabled(ctx context.Context, in *emptypb.Empty, opts
return out, nil
}
func (c *bridgeClient) SetUseSslForSmtp(ctx context.Context, in *wrapperspb.BoolValue, opts ...grpc.CallOption) (*emptypb.Empty, error) {
func (c *bridgeClient) MailServerSettings(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*ImapSmtpSettings, error) {
out := new(ImapSmtpSettings)
err := c.cc.Invoke(ctx, "/grpc.Bridge/MailServerSettings", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *bridgeClient) SetMailServerSettings(ctx context.Context, in *ImapSmtpSettings, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/grpc.Bridge/SetUseSslForSmtp", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *bridgeClient) UseSslForSmtp(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.BoolValue, error) {
out := new(wrapperspb.BoolValue)
err := c.cc.Invoke(ctx, "/grpc.Bridge/UseSslForSmtp", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *bridgeClient) SetUseSslForImap(ctx context.Context, in *wrapperspb.BoolValue, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/grpc.Bridge/SetUseSslForImap", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *bridgeClient) UseSslForImap(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.BoolValue, error) {
out := new(wrapperspb.BoolValue)
err := c.cc.Invoke(ctx, "/grpc.Bridge/UseSslForImap", in, out, opts...)
err := c.cc.Invoke(ctx, "/grpc.Bridge/SetMailServerSettings", in, out, opts...)
if err != nil {
return nil, err
}
@ -507,33 +484,6 @@ func (c *bridgeClient) Hostname(ctx context.Context, in *emptypb.Empty, opts ...
return out, nil
}
func (c *bridgeClient) ImapPort(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.Int32Value, error) {
out := new(wrapperspb.Int32Value)
err := c.cc.Invoke(ctx, "/grpc.Bridge/ImapPort", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *bridgeClient) SmtpPort(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.Int32Value, error) {
out := new(wrapperspb.Int32Value)
err := c.cc.Invoke(ctx, "/grpc.Bridge/SmtpPort", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *bridgeClient) ChangePorts(ctx context.Context, in *ChangePortsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/grpc.Bridge/ChangePorts", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *bridgeClient) IsPortFree(ctx context.Context, in *wrapperspb.Int32Value, opts ...grpc.CallOption) (*wrapperspb.BoolValue, error) {
out := new(wrapperspb.BoolValue)
err := c.cc.Invoke(ctx, "/grpc.Bridge/IsPortFree", in, out, opts...)
@ -714,14 +664,9 @@ type BridgeServer interface {
// mail
SetIsDoHEnabled(context.Context, *wrapperspb.BoolValue) (*emptypb.Empty, error)
IsDoHEnabled(context.Context, *emptypb.Empty) (*wrapperspb.BoolValue, error)
SetUseSslForSmtp(context.Context, *wrapperspb.BoolValue) (*emptypb.Empty, error)
UseSslForSmtp(context.Context, *emptypb.Empty) (*wrapperspb.BoolValue, error)
SetUseSslForImap(context.Context, *wrapperspb.BoolValue) (*emptypb.Empty, error)
UseSslForImap(context.Context, *emptypb.Empty) (*wrapperspb.BoolValue, error)
MailServerSettings(context.Context, *emptypb.Empty) (*ImapSmtpSettings, error)
SetMailServerSettings(context.Context, *ImapSmtpSettings) (*emptypb.Empty, error)
Hostname(context.Context, *emptypb.Empty) (*wrapperspb.StringValue, error)
ImapPort(context.Context, *emptypb.Empty) (*wrapperspb.Int32Value, error)
SmtpPort(context.Context, *emptypb.Empty) (*wrapperspb.Int32Value, error)
ChangePorts(context.Context, *ChangePortsRequest) (*emptypb.Empty, error)
IsPortFree(context.Context, *wrapperspb.Int32Value) (*wrapperspb.BoolValue, error)
// keychain
AvailableKeychains(context.Context, *emptypb.Empty) (*AvailableKeychainsResponse, error)
@ -864,30 +809,15 @@ func (UnimplementedBridgeServer) SetIsDoHEnabled(context.Context, *wrapperspb.Bo
func (UnimplementedBridgeServer) IsDoHEnabled(context.Context, *emptypb.Empty) (*wrapperspb.BoolValue, error) {
return nil, status.Errorf(codes.Unimplemented, "method IsDoHEnabled not implemented")
}
func (UnimplementedBridgeServer) SetUseSslForSmtp(context.Context, *wrapperspb.BoolValue) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method SetUseSslForSmtp not implemented")
func (UnimplementedBridgeServer) MailServerSettings(context.Context, *emptypb.Empty) (*ImapSmtpSettings, error) {
return nil, status.Errorf(codes.Unimplemented, "method MailServerSettings not implemented")
}
func (UnimplementedBridgeServer) UseSslForSmtp(context.Context, *emptypb.Empty) (*wrapperspb.BoolValue, error) {
return nil, status.Errorf(codes.Unimplemented, "method UseSslForSmtp not implemented")
}
func (UnimplementedBridgeServer) SetUseSslForImap(context.Context, *wrapperspb.BoolValue) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method SetUseSslForImap not implemented")
}
func (UnimplementedBridgeServer) UseSslForImap(context.Context, *emptypb.Empty) (*wrapperspb.BoolValue, error) {
return nil, status.Errorf(codes.Unimplemented, "method UseSslForImap not implemented")
func (UnimplementedBridgeServer) SetMailServerSettings(context.Context, *ImapSmtpSettings) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method SetMailServerSettings not implemented")
}
func (UnimplementedBridgeServer) Hostname(context.Context, *emptypb.Empty) (*wrapperspb.StringValue, error) {
return nil, status.Errorf(codes.Unimplemented, "method Hostname not implemented")
}
func (UnimplementedBridgeServer) ImapPort(context.Context, *emptypb.Empty) (*wrapperspb.Int32Value, error) {
return nil, status.Errorf(codes.Unimplemented, "method ImapPort not implemented")
}
func (UnimplementedBridgeServer) SmtpPort(context.Context, *emptypb.Empty) (*wrapperspb.Int32Value, error) {
return nil, status.Errorf(codes.Unimplemented, "method SmtpPort not implemented")
}
func (UnimplementedBridgeServer) ChangePorts(context.Context, *ChangePortsRequest) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method ChangePorts not implemented")
}
func (UnimplementedBridgeServer) IsPortFree(context.Context, *wrapperspb.Int32Value) (*wrapperspb.BoolValue, error) {
return nil, status.Errorf(codes.Unimplemented, "method IsPortFree not implemented")
}
@ -1657,74 +1587,38 @@ func _Bridge_IsDoHEnabled_Handler(srv interface{}, ctx context.Context, dec func
return interceptor(ctx, in, info, handler)
}
func _Bridge_SetUseSslForSmtp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(wrapperspb.BoolValue)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BridgeServer).SetUseSslForSmtp(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.Bridge/SetUseSslForSmtp",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BridgeServer).SetUseSslForSmtp(ctx, req.(*wrapperspb.BoolValue))
}
return interceptor(ctx, in, info, handler)
}
func _Bridge_UseSslForSmtp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
func _Bridge_MailServerSettings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(emptypb.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BridgeServer).UseSslForSmtp(ctx, in)
return srv.(BridgeServer).MailServerSettings(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.Bridge/UseSslForSmtp",
FullMethod: "/grpc.Bridge/MailServerSettings",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BridgeServer).UseSslForSmtp(ctx, req.(*emptypb.Empty))
return srv.(BridgeServer).MailServerSettings(ctx, req.(*emptypb.Empty))
}
return interceptor(ctx, in, info, handler)
}
func _Bridge_SetUseSslForImap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(wrapperspb.BoolValue)
func _Bridge_SetMailServerSettings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ImapSmtpSettings)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BridgeServer).SetUseSslForImap(ctx, in)
return srv.(BridgeServer).SetMailServerSettings(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.Bridge/SetUseSslForImap",
FullMethod: "/grpc.Bridge/SetMailServerSettings",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BridgeServer).SetUseSslForImap(ctx, req.(*wrapperspb.BoolValue))
}
return interceptor(ctx, in, info, handler)
}
func _Bridge_UseSslForImap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(emptypb.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BridgeServer).UseSslForImap(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.Bridge/UseSslForImap",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BridgeServer).UseSslForImap(ctx, req.(*emptypb.Empty))
return srv.(BridgeServer).SetMailServerSettings(ctx, req.(*ImapSmtpSettings))
}
return interceptor(ctx, in, info, handler)
}
@ -1747,60 +1641,6 @@ func _Bridge_Hostname_Handler(srv interface{}, ctx context.Context, dec func(int
return interceptor(ctx, in, info, handler)
}
func _Bridge_ImapPort_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(emptypb.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BridgeServer).ImapPort(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.Bridge/ImapPort",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BridgeServer).ImapPort(ctx, req.(*emptypb.Empty))
}
return interceptor(ctx, in, info, handler)
}
func _Bridge_SmtpPort_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(emptypb.Empty)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BridgeServer).SmtpPort(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.Bridge/SmtpPort",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BridgeServer).SmtpPort(ctx, req.(*emptypb.Empty))
}
return interceptor(ctx, in, info, handler)
}
func _Bridge_ChangePorts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ChangePortsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BridgeServer).ChangePorts(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.Bridge/ChangePorts",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BridgeServer).ChangePorts(ctx, req.(*ChangePortsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Bridge_IsPortFree_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(wrapperspb.Int32Value)
if err := dec(in); err != nil {
@ -2188,37 +2028,17 @@ var Bridge_ServiceDesc = grpc.ServiceDesc{
Handler: _Bridge_IsDoHEnabled_Handler,
},
{
MethodName: "SetUseSslForSmtp",
Handler: _Bridge_SetUseSslForSmtp_Handler,
MethodName: "MailServerSettings",
Handler: _Bridge_MailServerSettings_Handler,
},
{
MethodName: "UseSslForSmtp",
Handler: _Bridge_UseSslForSmtp_Handler,
},
{
MethodName: "SetUseSslForImap",
Handler: _Bridge_SetUseSslForImap_Handler,
},
{
MethodName: "UseSslForImap",
Handler: _Bridge_UseSslForImap_Handler,
MethodName: "SetMailServerSettings",
Handler: _Bridge_SetMailServerSettings_Handler,
},
{
MethodName: "Hostname",
Handler: _Bridge_Hostname_Handler,
},
{
MethodName: "ImapPort",
Handler: _Bridge_ImapPort_Handler,
},
{
MethodName: "SmtpPort",
Handler: _Bridge_SmtpPort_Handler,
},
{
MethodName: "ChangePorts",
Handler: _Bridge_ChangePorts_Handler,
},
{
MethodName: "IsPortFree",
Handler: _Bridge_IsPortFree_Handler,

View File

@ -109,20 +109,28 @@ func NewDiskCachePathChangeFinishedEvent() *StreamEvent {
return cacheEvent(&DiskCacheEvent{Event: &DiskCacheEvent_PathChangeFinished{PathChangeFinished: &DiskCachePathChangeFinishedEvent{}}})
}
func NewMailSettingsErrorEvent(err MailSettingsErrorType) *StreamEvent {
return mailSettingsEvent(&MailSettingsEvent{Event: &MailSettingsEvent_Error{Error: &MailSettingsErrorEvent{Type: err}}})
func NewMailServerSettingsErrorEvent(err MailServerSettingsErrorType) *StreamEvent {
return mailServerSettingsEvent(&MailServerSettingsEvent{
Event: &MailServerSettingsEvent_Error{
Error: &MailServerSettingsErrorEvent{Type: err},
},
})
}
func NewMailSettingsUseSslForSmtpFinishedEvent() *StreamEvent { //nolint:revive,stylecheck
return mailSettingsEvent(&MailSettingsEvent{Event: &MailSettingsEvent_UseSslForSmtpFinished{UseSslForSmtpFinished: &UseSslForSmtpFinishedEvent{}}})
func NewMailServerSettingsChangedEvent(settings *ImapSmtpSettings) *StreamEvent {
return mailServerSettingsEvent(&MailServerSettingsEvent{
Event: &MailServerSettingsEvent_MailServerSettingsChanged{
MailServerSettingsChanged: &MailServerSettingsChangedEvent{Settings: settings},
},
})
}
func NewMailSettingsUseSslForImapFinishedEvent() *StreamEvent { //nolint:revive,stylecheck
return mailSettingsEvent(&MailSettingsEvent{Event: &MailSettingsEvent_UseSslForImapFinished{UseSslForImapFinished: &UseSslForImapFinishedEvent{}}})
}
func NewMailSettingsChangePortFinishedEvent() *StreamEvent {
return mailSettingsEvent(&MailSettingsEvent{Event: &MailSettingsEvent_ChangePortsFinished{ChangePortsFinished: &ChangePortsFinishedEvent{}}})
func NewChangeMailServerSettingsFinishedEvent() *StreamEvent {
return mailServerSettingsEvent(&MailServerSettingsEvent{
Event: &MailServerSettingsEvent_ChangeMailServerSettingsFinished{
ChangeMailServerSettingsFinished: &ChangeMailServerSettingsFinishedEvent{},
},
})
}
func NewKeychainChangeKeychainFinishedEvent() *StreamEvent {
@ -183,8 +191,8 @@ func cacheEvent(event *DiskCacheEvent) *StreamEvent {
return &StreamEvent{Event: &StreamEvent_Cache{Cache: event}}
}
func mailSettingsEvent(event *MailSettingsEvent) *StreamEvent {
return &StreamEvent{Event: &StreamEvent_MailSettings{MailSettings: event}}
func mailServerSettingsEvent(event *MailServerSettingsEvent) *StreamEvent {
return &StreamEvent{Event: &StreamEvent_MailServerSettings{MailServerSettings: event}}
}
func keychainEvent(event *KeychainEvent) *StreamEvent {

View File

@ -218,10 +218,10 @@ func (s *Service) watchEvents() {
_ = s.SendEvent(NewKeychainHasNoKeychainEvent())
case errors.Is(err, bridge.ErrServeIMAP):
_ = s.SendEvent(NewMailSettingsErrorEvent(MailSettingsErrorType_IMAP_PORT_ISSUE))
_ = s.SendEvent(NewMailServerSettingsErrorEvent(MailServerSettingsErrorType_IMAP_PORT_STARTUP_ERROR))
case errors.Is(err, bridge.ErrServeSMTP):
_ = s.SendEvent(NewMailSettingsErrorEvent(MailSettingsErrorType_SMTP_PORT_ISSUE))
_ = s.SendEvent(NewMailServerSettingsErrorEvent(MailServerSettingsErrorType_SMTP_PORT_STARTUP_ERROR))
}
}

View File

@ -37,6 +37,7 @@ import (
"golang.org/x/exp/maps"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/runtime/protoimpl"
"google.golang.org/protobuf/types/known/emptypb"
"google.golang.org/protobuf/types/known/wrapperspb"
)
@ -617,46 +618,66 @@ func (s *Service) IsDoHEnabled(ctx context.Context, _ *emptypb.Empty) (*wrappers
return wrapperspb.Bool(s.bridge.GetProxyAllowed()), nil
}
func (s *Service) SetUseSslForSmtp(ctx context.Context, useSsl *wrapperspb.BoolValue) (*emptypb.Empty, error) { //nolint:revive,stylecheck
s.log.WithField("useSsl", useSsl.Value).Debug("SetUseSslForSmtp")
func (s *Service) MailServerSettings(_ context.Context, _ *emptypb.Empty) (*ImapSmtpSettings, error) {
s.log.Debug("ConnectionMode")
if s.bridge.GetSMTPSSL() == useSsl.Value {
return &emptypb.Empty{}, nil
}
if err := s.bridge.SetSMTPSSL(useSsl.Value); err != nil {
s.log.WithError(err).Error("Failed to set SMTP SSL")
return nil, status.Errorf(codes.Internal, "failed to set SMTP SSL: %v", err)
}
return &emptypb.Empty{}, s.SendEvent(NewMailSettingsUseSslForSmtpFinishedEvent())
return &ImapSmtpSettings{
state: protoimpl.MessageState{},
sizeCache: 0,
unknownFields: nil,
ImapPort: int32(s.bridge.GetIMAPPort()),
SmtpPort: int32(s.bridge.GetSMTPPort()),
UseSSLForImap: s.bridge.GetIMAPSSL(),
UseSSLForSmtp: s.bridge.GetSMTPSSL(),
}, nil
}
func (s *Service) UseSslForSmtp(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { //nolint:revive,stylecheck
s.log.Debug("UseSslForSmtp")
func (s *Service) SetMailServerSettings(_ context.Context, settings *ImapSmtpSettings) (*emptypb.Empty, error) {
s.log.
WithField("ImapPort", settings.ImapPort).
WithField("SmtpPort", settings.SmtpPort).
WithField("UseSSUseSSLForIMAP", settings.UseSSLForImap).
WithField("UseSSLForSMTP", settings.UseSSLForSmtp).
Debug("SetConnectionMode")
return wrapperspb.Bool(s.bridge.GetSMTPSSL()), nil
}
defer func() { _ = s.SendEvent(NewChangeMailServerSettingsFinishedEvent()) }()
func (s *Service) SetUseSslForImap(ctx context.Context, useSsl *wrapperspb.BoolValue) (*emptypb.Empty, error) { //nolint:revive,stylecheck
s.log.WithField("useSsl", useSsl.Value).Debug("SetUseSslForImap")
if s.bridge.GetIMAPSSL() == useSsl.Value {
return &emptypb.Empty{}, nil
if s.bridge.GetIMAPSSL() != settings.UseSSLForImap {
if err := s.bridge.SetIMAPSSL(settings.UseSSLForImap); err != nil {
s.log.WithError(err).Error("Failed to set IMAP SSL")
_ = s.SendEvent(NewMailServerSettingsErrorEvent(MailServerSettingsErrorType_IMAP_CONNECTION_MODE_CHANGE_ERROR))
}
}
if err := s.bridge.SetIMAPSSL(useSsl.Value); err != nil {
s.log.WithError(err).Error("Failed to set IMAP SSL")
return nil, status.Errorf(codes.Internal, "failed to set IMAP SSL: %v", err)
if s.bridge.GetSMTPSSL() != settings.UseSSLForSmtp {
if err := s.bridge.SetSMTPSSL(settings.UseSSLForSmtp); err != nil {
s.log.WithError(err).Error("Failed to set SMTP SSL")
_ = s.SendEvent(NewMailServerSettingsErrorEvent(MailServerSettingsErrorType_SMTP_CONNECTION_MODE_CHANGE_ERROR))
}
}
return &emptypb.Empty{}, s.SendEvent(NewMailSettingsUseSslForImapFinishedEvent())
}
if s.bridge.GetIMAPPort() != int(settings.ImapPort) {
if err := s.bridge.SetIMAPPort(int(settings.ImapPort)); err != nil {
s.log.WithError(err).Error("Failed to set IMAP port")
_ = s.SendEvent(NewMailServerSettingsErrorEvent(MailServerSettingsErrorType_IMAP_PORT_CHANGE_ERROR))
}
}
func (s *Service) UseSslForImap(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.BoolValue, error) { //nolint:revive,stylecheck
s.log.Debug("UseSslForImap")
if s.bridge.GetSMTPPort() != int(settings.SmtpPort) {
if err := s.bridge.SetSMTPPort(int(settings.SmtpPort)); err != nil {
s.log.WithError(err).Error("Failed to set SMTP port")
_ = s.SendEvent(NewMailServerSettingsErrorEvent(MailServerSettingsErrorType_SMTP_PORT_CHANGE_ERROR))
}
}
return wrapperspb.Bool(s.bridge.GetIMAPSSL()), nil
_ = s.SendEvent(NewMailServerSettingsChangedEvent(&ImapSmtpSettings{
ImapPort: int32(s.bridge.GetIMAPPort()),
SmtpPort: int32(s.bridge.GetSMTPPort()),
UseSSLForImap: s.bridge.GetIMAPSSL(),
UseSSLForSmtp: s.bridge.GetSMTPSSL(),
}))
return &emptypb.Empty{}, nil
}
func (s *Service) Hostname(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.StringValue, error) {
@ -665,34 +686,6 @@ func (s *Service) Hostname(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.S
return wrapperspb.String(constants.Host), nil
}
func (s *Service) ImapPort(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.Int32Value, error) {
s.log.Debug("ImapPort")
return wrapperspb.Int32(int32(s.bridge.GetIMAPPort())), nil
}
func (s *Service) SmtpPort(ctx context.Context, _ *emptypb.Empty) (*wrapperspb.Int32Value, error) { //nolint:revive,stylecheck
s.log.Debug("SmtpPort")
return wrapperspb.Int32(int32(s.bridge.GetSMTPPort())), nil
}
func (s *Service) ChangePorts(ctx context.Context, ports *ChangePortsRequest) (*emptypb.Empty, error) {
s.log.WithField("imapPort", ports.ImapPort).WithField("smtpPort", ports.SmtpPort).Debug("ChangePorts")
if err := s.bridge.SetIMAPPort(int(ports.ImapPort)); err != nil {
s.log.WithError(err).Error("Failed to set IMAP port")
return nil, status.Errorf(codes.Internal, "failed to set IMAP port: %v", err)
}
if err := s.bridge.SetSMTPPort(int(ports.SmtpPort)); err != nil {
s.log.WithError(err).Error("Failed to set SMTP port")
return nil, status.Errorf(codes.Internal, "failed to set SMTP port: %v", err)
}
return &emptypb.Empty{}, s.SendEvent(NewMailSettingsChangePortFinishedEvent())
}
func (s *Service) IsPortFree(ctx context.Context, port *wrapperspb.Int32Value) (*wrapperspb.BoolValue, error) {
s.log.Debug("IsPortFree")

View File

@ -145,9 +145,19 @@ func (s *Service) StartEventTest() error { //nolint:funlen
NewDiskCachePathChangeFinishedEvent(),
// mail settings
NewMailSettingsErrorEvent(MailSettingsErrorType_IMAP_PORT_ISSUE),
NewMailSettingsUseSslForSmtpFinishedEvent(),
NewMailSettingsChangePortFinishedEvent(),
NewMailServerSettingsErrorEvent(MailServerSettingsErrorType_IMAP_PORT_STARTUP_ERROR),
NewMailServerSettingsErrorEvent(MailServerSettingsErrorType_SMTP_PORT_STARTUP_ERROR),
NewMailServerSettingsErrorEvent(MailServerSettingsErrorType_IMAP_PORT_CHANGE_ERROR),
NewMailServerSettingsErrorEvent(MailServerSettingsErrorType_SMTP_PORT_CHANGE_ERROR),
NewMailServerSettingsErrorEvent(MailServerSettingsErrorType_IMAP_CONNECTION_MODE_CHANGE_ERROR),
NewMailServerSettingsErrorEvent(MailServerSettingsErrorType_SMTP_CONNECTION_MODE_CHANGE_ERROR),
NewMailServerSettingsChangedEvent(&ImapSmtpSettings{
ImapPort: 1143,
SmtpPort: 1025,
UseSSLForImap: false,
UseSSLForSmtp: false,
}),
NewChangeMailServerSettingsFinishedEvent(),
// keychain
NewKeychainChangeKeychainFinishedEvent(),