@@ -2,58 +2,59 @@
|
||||
using MailKit.Net.Imap;
|
||||
using Serilog;
|
||||
|
||||
namespace Wino.Core.Integration;
|
||||
|
||||
/// <summary>
|
||||
/// Extended class for ImapClient that is used in Wino.
|
||||
/// </summary>
|
||||
internal class WinoImapClient : ImapClient
|
||||
namespace Wino.Core.Integration
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or internally sets whether the QRESYNC extension is enabled.
|
||||
/// It is set by ImapClientPool immidiately after the authentication.
|
||||
/// Extended class for ImapClient that is used in Wino.
|
||||
/// </summary>
|
||||
public bool IsQResyncEnabled { get; internal set; }
|
||||
|
||||
public WinoImapClient()
|
||||
internal class WinoImapClient : ImapClient
|
||||
{
|
||||
HookEvents();
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or internally sets whether the QRESYNC extension is enabled.
|
||||
/// It is set by ImapClientPool immidiately after the authentication.
|
||||
/// </summary>
|
||||
public bool IsQResyncEnabled { get; internal set; }
|
||||
|
||||
public WinoImapClient(IProtocolLogger protocolLogger) : base(protocolLogger)
|
||||
{
|
||||
HookEvents();
|
||||
}
|
||||
|
||||
private void HookEvents()
|
||||
{
|
||||
Disconnected += ClientDisconnected;
|
||||
}
|
||||
|
||||
private void UnhookEvents()
|
||||
{
|
||||
Disconnected -= ClientDisconnected;
|
||||
}
|
||||
|
||||
private void ClientDisconnected(object sender, DisconnectedEventArgs e)
|
||||
{
|
||||
if (e.IsRequested)
|
||||
public WinoImapClient()
|
||||
{
|
||||
Log.Debug("Imap client is disconnected on request.");
|
||||
HookEvents();
|
||||
}
|
||||
else
|
||||
|
||||
public WinoImapClient(IProtocolLogger protocolLogger) : base(protocolLogger)
|
||||
{
|
||||
Log.Debug("Imap client connection is dropped by server.");
|
||||
HookEvents();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
private void HookEvents()
|
||||
{
|
||||
UnhookEvents();
|
||||
Disconnected += ClientDisconnected;
|
||||
}
|
||||
|
||||
private void UnhookEvents()
|
||||
{
|
||||
Disconnected -= ClientDisconnected;
|
||||
}
|
||||
|
||||
private void ClientDisconnected(object sender, DisconnectedEventArgs e)
|
||||
{
|
||||
if (e.IsRequested)
|
||||
{
|
||||
Log.Debug("Imap client is disconnected on request.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Debug("Imap client connection is dropped by server.");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
UnhookEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user