mirror of
https://github.com/markqvist/LXMF.git
synced 2025-01-12 15:39:26 -05:00
Added failed state to LXMF messages
This commit is contained in:
parent
5443040e36
commit
da0ba60b71
15
LXMF/LXMF.py
15
LXMF/LXMF.py
@ -12,7 +12,8 @@ class LXMessage:
|
||||
SENDING = 0x02
|
||||
SENT = 0x04
|
||||
DELIVERED = 0x08
|
||||
states = [DRAFT, OUTBOUND, SENDING, SENT, DELIVERED]
|
||||
FAILED = 0xFF
|
||||
states = [DRAFT, OUTBOUND, SENDING, SENT, DELIVERED, FAILED]
|
||||
|
||||
UNKNOWN = 0x00
|
||||
PACKET = 0x01
|
||||
@ -122,6 +123,7 @@ class LXMessage:
|
||||
self.resource_representation = None
|
||||
self.__delivery_destination = None
|
||||
self.__delivery_callback = None
|
||||
self.__failed_callback = None
|
||||
|
||||
def set_title_from_string(self, title_string):
|
||||
self.title = title_string.encode("utf-8")
|
||||
@ -180,6 +182,9 @@ class LXMessage:
|
||||
def register_delivery_callback(self, callback):
|
||||
self.__delivery_callback = callback
|
||||
|
||||
def register_failed_callback(self, callback):
|
||||
self.__failed_callback = callback
|
||||
|
||||
def pack(self):
|
||||
if not self.packed:
|
||||
if self.timestamp == None:
|
||||
@ -248,6 +253,7 @@ class LXMessage:
|
||||
self.state = LXMessage.SENDING
|
||||
self.resource_representation = self.__as_resource()
|
||||
elif self.method == LXMessage.PROPAGATED:
|
||||
# TODO: Implement propagation
|
||||
pass
|
||||
|
||||
def __mark_delivered(self, receipt = None):
|
||||
@ -257,6 +263,13 @@ class LXMessage:
|
||||
if self.__delivery_callback != None:
|
||||
self.__delivery_callback(self)
|
||||
|
||||
def __mark_failed(self, receipt = None):
|
||||
RNS.log(str(self)+" failed to send", RNS.LOG_DEBUG)
|
||||
self.state = LXMessage.FAILED
|
||||
|
||||
if self.__failed_callback != None:
|
||||
self.__failed_callback(self)
|
||||
|
||||
def __resource_concluded(self, resource):
|
||||
if resource.status == RNS.Resource.COMPLETE:
|
||||
self.__mark_delivered()
|
||||
|
Loading…
Reference in New Issue
Block a user