# HG changeset patch # User Goffi # Date 1482187819 -3600 # Node ID 674b1fa3c945660350022af285b5f98a4f087a2e # Parent 1a324c682d8aac40852ed983d5222b90916f4373 core: use memory map on a file to indicate pause/resume status, so backend can now it diff -r 1a324c682d8a -r 674b1fa3c945 src/cagou/core/cagou_main.py --- a/src/cagou/core/cagou_main.py Sun Dec 18 21:01:04 2016 +0100 +++ b/src/cagou/core/cagou_main.py Mon Dec 19 23:50:19 2016 +0100 @@ -69,6 +69,7 @@ # sys.platform is "linux" on android by default # so we change it to allow backend to detect android sys.platform = "android" + import mmap class NotifsIcon(IconButton): @@ -226,11 +227,31 @@ """ return os.path.expanduser(path).format(*args, media=self.host.media_dir, **kwargs) + def on_start(self): + # XXX: we use memory map instead of bridge because if we try to call a bridge method + # in on_pause method, the call data is not written before the actual pause + # we create a memory map on .cagou_status file with a 1 byte status + # status is: + # R => running + # P => paused + # S => stopped + self._first_pause = True + self.cagou_status_fd = open('.cagou_status', 'wb+') + self.cagou_status_fd.write('R') + self.cagou_status_fd.flush() + self.cagou_status = mmap.mmap(self.cagou_status_fd.fileno(), 1, prot=mmap.PROT_WRITE) + def on_pause(self): + self.cagou_status[0] = 'P' return True def on_resume(self): - pass + self.cagou_status[0] = 'R' + + def on_stop(self): + self.cagou_status[0] = 'S' + self.cagou_status.flush() + self.cagou_status_fd.close() class Cagou(QuickApp):