Skip to content
Snippets Groups Projects
Commit 54c5c4e3 authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

Parser: CheckmailStatus

parent 207f8fcd
Branches
No related tags found
No related merge requests found
...@@ -129,6 +129,75 @@ class ParserOsddLast: Parser ...@@ -129,6 +129,75 @@ class ParserOsddLast: Parser
} }
} }
[ParserName("checkmail_status")]
class ParserCheckmailLog: Parser
{
StatusBar bar;
public void Init(StatusBar _bar, Module _module, ConfigSection section)
{
bar = _bar;
}
public IEnumerable<Element> Parse(string data)
{
try
{
long msgTime = int.Parse(data.Split()[0]);
long countNewMails = int.Parse(data.Split()[1]);
long delay = DateTimeOffset.Now.ToUnixTimeSeconds() - msgTime;
long t = Environment.TickCount64;
bool t_parity = t/1000%2==0;
if(countNewMails > 0)
{
bar.Schedule((int)(1000-t%1000 + 10));
}
if(delay < -5 || delay > 90)
{
if(countNewMails > 0)
return new Element[]{new Element($"NO CONNECTION {TimeShow.Show(delay)} [{countNewMails}]", color: t_parity?Color.FromArgb(255, 0, 0):Color.FromArgb(0x33, 0x33, 255))};
else
return new Element[]{new Element($"NO CONNECTION {TimeShow.Show(delay)}", color: Color.Red)};
}
else
{
if(countNewMails > 0)
return new Element[]{new Element($"[{countNewMails} NEW]", color: t_parity?Color.FromArgb(255, 0x70, 0):Color.FromArgb(0x33, 0x33, 255))};
else
return new Element[]{new Element($"OK", color: Color.FromArgb(0,255,0))};
}
}
catch(Exception e)
{
Console.Error.WriteLine(e);
return new Element[]{new Element("CM PE", color: Color.Red)};
}
}
}
[ParserName("offlineimap_status")]
class ParserOfflineimapLog: Parser
{
public void Init(StatusBar _bar, Module _module, ConfigSection section)
{
}
public IEnumerable<Element> Parse(string data)
{
data = data.Trim();
if(data.StartsWith("DOING"))
return new Element[]{new Element("IMAP", color: Color.Green)};
if(data.StartsWith("WAITING"))
return new Element[]{new Element("IMAP", color: Color.Orange)};
if(int.TryParse(data, out int n))
{
if(n == 0)
return new Element[]{};
else
return new Element[]{new Element($"IMAP {n}", color: Color.Red)};
}
else
return new Element[]{new Element("IMAP PE", color: Color.Red)};
}
}
[ParserName("ICE_speed")] [ParserName("ICE_speed")]
class ParserICESpeed: Parser class ParserICESpeed: Parser
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment