' popService - Service module
Sub Process_Globals
Dim POP As POP3
Dim Notify As Notification
Dim manager As PreferenceManager
End Sub
Sub Service_Create
Notify.Initialize
Notify.Icon = "icon"
Notify.Vibrate = False
Notify.AutoCancel = True
End Sub
Sub Service_Start
Dim tmp, interval, host, user, pass As String
Dim port As Int
Dim ssl As Boolean
Dim messages As Map
host = manager.GetString("host")
tmp = manager.GetString("port")
If IsNumber(tmp) Then port = tmp Else port = 110
user = manager.GetString("user")
pass = manager.GetString("password")
ssl = manager.GetBoolean("ssl")
interval = manager.GetString("interval")
If interval = "" Then interval = 1
If interval <= 0 Then
manager.SetString("interval","5")
interval = manager.GetString("interval")
End If
POP.Initialize(host,port,user,pass,POP)
POP.UseSSL = ssl
POP.ListMessages
StartServiceAt("", DateTime.Now + interval * DateTime.TicksPerMinute, False)
DateTime.TimeFormat = "h:mm:ss a"
manager.SetString("NextTime"," Next check: " & DateTime.Time(DateTime.now + interval * DateTime.TicksPerMinute) & " ")
If IsPaused(Main) = False Then CallSub(Main,"DisplayTitle")
End Sub
Sub pop_ListCompleted (success As Boolean, messages As Map)
If success Then
Log("Count:" & messages.Size)
For i = 0 To messages.Size - 1
POP.DownloadMessage(messages.GetKeyAt(i), True) 'Download all messages and delete them
Next
Else
Log(LastException.Message)
End If
POP.Close 'The connection will be closed after all messages are downloaded
End Sub
Sub pop_DownloadCompleted (Success As Boolean, MessageId As Int, Message As String)
Log("Download: " & Success & ", " & MessageId)
If Success Then
Log(Message)
Log(Message.Length)
Log(MessageId)
Else
Log(LastException.Message)
End If
End Sub
Sub Service_Destroy
End Sub