Mercurial > libervia-backend
comparison frontends/src/jp/cmd_avatar.py @ 2123:c42aab22c2c0
plugin XEP-0054, quick frontend(app): various improvments:
- memory.cache is now used
- getAvatar and setAvatar has been renamed to avatarGet and avatarSet to follow new convention
- getAvatar now return (optionally) full path, and may request vCard or only return avatar in cache
- getAvatarFile has been removed as it is not needed anymore (avatarGet can return full path)
- getCard has been removed from bridge as it was only used to request avatar
- new internal method getBareOfFull return jid to use depending of the jid being part of a MUC or not
- cache is now set per profile in client, instead of a general one for all profiles
- thanks to the use of memory.cache, correct extension is now used in saved file, according to MIME type
- fixed and better cache handling
- a warning message is shown if given avatar hash differs from computed one
- empty hash value is now in a constant, and ignored if received
- QuickApp has been updated to follow new behaviour
- Primitivus has been fixed (it was not declaring not using avatars correclty)
- jp has been updated to follow new methods name
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 15 Jan 2017 17:51:37 +0100 |
parents | db5cda61740f |
children | 8b37a62336c3 |
comparison
equal
deleted
inserted
replaced
2122:3970ebcf8830 | 2123:c42aab22c2c0 |
---|---|
44 path = self.args.image_path | 44 path = self.args.image_path |
45 if not os.path.exists(path): | 45 if not os.path.exists(path): |
46 self.disp(_(u"file [{}] doesn't exist !").format(path), error=True) | 46 self.disp(_(u"file [{}] doesn't exist !").format(path), error=True) |
47 self.host.quit(1) | 47 self.host.quit(1) |
48 path = os.path.abspath(path) | 48 path = os.path.abspath(path) |
49 self.host.bridge.setAvatar(path, self.profile, callback=self._avatarCb, errback=self._avatarEb) | 49 self.host.bridge.avatarSet(path, self.profile, callback=self._avatarCb, errback=self._avatarEb) |
50 | 50 |
51 def _avatarCb(self): | 51 def _avatarCb(self): |
52 self.disp(_("avatar has been set"), 1) | 52 self.disp(_("avatar has been set"), 1) |
53 self.host.quit() | 53 self.host.quit() |
54 | 54 |
83 # didn't worked with commands, we try our luck with webbrowser | 83 # didn't worked with commands, we try our luck with webbrowser |
84 # in some cases, webbrowser can actually open the associated display program | 84 # in some cases, webbrowser can actually open the associated display program |
85 import webbrowser | 85 import webbrowser |
86 webbrowser.open(path) | 86 webbrowser.open(path) |
87 | 87 |
88 def _getAvatarCb(self, avatar_path): | 88 def _avatarGetCb(self, avatar_path): |
89 if not avatar_path: | 89 if not avatar_path: |
90 self.disp(_(u"No avatar found."), 1) | 90 self.disp(_(u"No avatar found."), 1) |
91 self.host.quit(C.EXIT_NOT_FOUND) | 91 self.host.quit(C.EXIT_NOT_FOUND) |
92 | 92 |
93 self.disp(avatar_path) | 93 self.disp(avatar_path) |
94 if self.args.show: | 94 if self.args.show: |
95 self.showImage(avatar_path) | 95 self.showImage(avatar_path) |
96 | 96 |
97 self.host.quit() | 97 self.host.quit() |
98 | 98 |
99 def _getAvatarEb(self, failure_): | 99 def _avatarGetEb(self, failure_): |
100 self.disp(_("error while getting avatar: {msg}").format(msg=failure_), error=True) | 100 self.disp(_("error while getting avatar: {msg}").format(msg=failure_), error=True) |
101 self.host.quit(C.EXIT_ERROR) | 101 self.host.quit(C.EXIT_ERROR) |
102 | 102 |
103 def start(self): | 103 def start(self): |
104 self.host.bridge.getAvatar(self.args.jid, self.profile, callback=self._getAvatarCb, errback=self._getAvatarEb) | 104 self.host.bridge.avatarGet(self.args.jid, False, False, self.profile, callback=self._avatarGetCb, errback=self._avatarGetEb) |
105 | 105 |
106 | 106 |
107 class Avatar(base.CommandBase): | 107 class Avatar(base.CommandBase): |
108 subcommands = (Set, Get) | 108 subcommands = (Set, Get) |
109 | 109 |