aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVG <vg@devys.org>2016-05-19 17:28:42 +0200
committerVG <vg@devys.org>2016-05-19 17:28:42 +0200
commit1dc11eb465ff70ea51452326935208a40c2b49bf (patch)
treea24111af8d8af3bdd0bd9e878191354d056bfaeb
parent0db947a0a43f3406819b45f7506e5a28b121a3aa (diff)
downloadcliml-1dc11eb465ff70ea51452326935208a40c2b49bf.tar.gz
climl-1dc11eb465ff70ea51452326935208a40c2b49bf.tar.bz2
climl-1dc11eb465ff70ea51452326935208a40c2b49bf.zip
Add interface: hook can do non-critical exception
-rw-r--r--climl/imap.py8
-rw-r--r--climl/interface.py19
2 files changed, 26 insertions, 1 deletions
diff --git a/climl/imap.py b/climl/imap.py
index 68a6e9b..034c77a 100644
--- a/climl/imap.py
+++ b/climl/imap.py
@@ -7,6 +7,8 @@ import backports.ssl as ssl
import socket
import time
+from . import interface
+
def conf_boolean_postprocess(src):
src = src.lower().strip()
if src == 'true' or src == 'on' or src == '1':
@@ -143,7 +145,11 @@ def main(callback=None):
response = connection.fetch([oneid], ['RFC822'])
data = response[oneid][b'RFC822']
print('calling callback...')
- callback('mail: ' + str(oneid) + ': ' + str(data))
+ try:
+ callback('mail: ' + str(oneid) + ': ' + str(data))
+ connection.add_flags([oneid], ['\Seen'])
+ except interface.HookAbortError:
+ pass
data = None
while True:
imap_waiter(connection)
diff --git a/climl/interface.py b/climl/interface.py
new file mode 100644
index 0000000..5a7f6ba
--- /dev/null
+++ b/climl/interface.py
@@ -0,0 +1,19 @@
+'''
+This file defines symbols used to make communication between
+hooks/plugins/extensions and core of climl.
+'''
+
+class HookError(Exception):
+ '''
+ Base class for hooks exception, they should not use this directly
+ '''
+
+ pass
+
+class HookAbortError(HookError):
+ '''
+ This exception is used to indicate to core of climl it should not mark
+ email \Seen for now.
+ '''
+
+ pass