Mercurial > libervia-backend
annotate frontends/src/primitivus/primitivus @ 639:99eee75ec1b7
core: better handling of profile_key and don't write the param file anymore
- new error ProfileNotSetError and some methods use the default @NONE@ instead of @DEFAULT@
- do not output the .sat/param file anymore, it is not needed and created confusion
- plugin XEP-0054: remove an error message at startup
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 05 Sep 2013 21:03:52 +0200 |
parents | 6821fc06a324 |
children | 49587e170f53 |
rev | line source |
---|---|
112 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
4 # Primitivus: a SAT frontend |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org) |
112 | 6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
10 # (at your option) any later version. |
112 | 11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
15 # GNU Affero General Public License for more details. |
112 | 16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
608
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
112 | 19 |
20 | |
21 import urwid | |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
22 from urwid_satext import sat_widgets |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
23 from urwid_satext.files_management import FileDialog |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
24 from sat_frontends.quick_frontend.quick_app import QuickApp |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
25 from sat_frontends.quick_frontend.quick_chat_list import QuickChatList |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
26 from sat_frontends.quick_frontend.quick_utils import getNewPath |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
27 from sat_frontends.primitivus.profile_manager import ProfileManager |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
28 from sat_frontends.primitivus.contact_list import ContactList |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
29 from sat_frontends.primitivus.chat import Chat |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
30 from sat_frontends.primitivus.gateways import GatewaysManager |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
31 from sat_frontends.primitivus.xmlui import XMLUI |
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
32 from sat_frontends.primitivus.progress import Progress |
475
6bb9305e0b9c
frontend: Fix notify import in Primitivus.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
459
diff
changeset
|
33 from sat_frontends.primitivus.notify import Notify |
495
a726b234d3bf
primitivus: moved constants in a separate file
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
34 import sat_frontends.primitivus.constants |
112 | 35 import logging |
36 from logging import debug, info, error | |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
37 from sat.tools.jid import JID |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
38 from os.path import join |
112 | 39 |
40 | |
41 ### logging configuration FIXME: put this elsewhere ### | |
42 logging.basicConfig(level=logging.CRITICAL, #TODO: configure it to put messages in a log file | |
43 format='%(message)s') | |
44 ### | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
45 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
46 class ChatList(QuickChatList): |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
47 """This class manage the list of chat windows""" |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
48 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
49 def createChat(self, target): |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
50 return Chat(target, self.host) |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
51 |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
52 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
53 class EditBar(sat_widgets.ModalEdit): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
54 """ |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
55 The modal edit bar where you would enter messages and commands. |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
56 """ |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
57 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
58 def __init__(self, app): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
59 modes = {None: ('NORMAL', u''), |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
60 'i': ('INSERTION', u'> '), |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
61 ':': ('COMMAND', u':')} #XXX: captions *MUST* be unicode |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
62 super(EditBar, self).__init__(modes) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
63 self.app = app |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
64 self.setCompletionMethod(self._text_completion) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
65 urwid.connect_signal(self, 'click', self.onTextEntered) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
66 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
67 def _text_completion(self, text, completion_data, mode): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
68 if mode == 'INSERTION': |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
69 return self._nick_completion(text, completion_data) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
70 else: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
71 return text |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
72 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
73 def _nick_completion(self, text, completion_data): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
74 """Completion method which complete pseudo in group chat |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
75 for params, see AdvancedEdit""" |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
76 contact = self.app.contact_list.getContact() ###Based on the fact that there is currently only one contact selectable at once |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
77 if contact: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
78 chat = self.app.chat_wins[contact] |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
79 if chat.type != "group": |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
80 return text |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
81 space = text.rfind(" ") |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
82 start = text[space+1:] |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
83 nicks = list(chat.occupants) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
84 nicks.sort() |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
85 try: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
86 start_idx=nicks.index(completion_data['last_nick'])+1 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
87 if start_idx == len(nicks): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
88 start_idx = 0 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
89 except (KeyError,ValueError): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
90 start_idx = 0 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
91 for idx in range(start_idx,len(nicks)) + range(0,start_idx): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
92 if nicks[idx].lower().startswith(start.lower()): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
93 completion_data['last_nick'] = nicks[idx] |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
94 return text[:space+1] + nicks[idx] + (': ' if space < 0 else '') |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
95 return text |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
96 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
97 def onTextEntered(self, editBar): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
98 """Called when text is entered in the main edit bar""" |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
99 if self.mode == 'INSERTION': |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
100 contact = self.app.contact_list.getContact() ###Based on the fact that there is currently only one contact selectableat once |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
101 if contact: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
102 chat = self.app.chat_wins[contact] |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
103 try: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
104 self.app.sendMessage(contact, |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
105 editBar.get_edit_text(), |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
106 mess_type = "groupchat" if chat.type == 'group' else "chat", |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
107 profile_key=self.app.profile) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
108 except: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
109 self.app.notify(_("Error while sending message")) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
110 editBar.set_edit_text('') |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
111 elif self.mode == 'COMMAND': |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
112 self.commandHandler() |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
113 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
114 def commandHandler(self): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
115 #TODO: separate class with auto documentation (with introspection) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
116 # and completion method |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
117 command = self.get_edit_text() |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
118 if command == 'quit': |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
119 self.app.onExit() |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
120 raise urwid.ExitMainLoop() |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
121 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
122 def keypress(self, size, key): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
123 """Callback when a key is pressed. Send "composing" states.""" |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
124 if key != "enter": |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
125 contact = self.app.contact_list.getContact() |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
126 if contact: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
127 self.app.bridge.chatStateComposing(contact, self.app.profile) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
128 return super(EditBar, self).keypress(size, key) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
129 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
130 |
112 | 131 class PrimitivusApp(QuickApp): |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
132 |
112 | 133 def __init__(self): |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
134 QuickApp.__init__(self) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
135 |
112 | 136 ## main loop setup ## |
117 | 137 self.main_widget = ProfileManager(self) |
127
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
138 self.loop = urwid.MainLoop(self.main_widget, const_PALETTE, event_loop=urwid.GLibEventLoop(), input_filter=self.inputFilter, unhandled_input=self.keyHandler) |
112 | 139 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
140 ##misc setup## |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
141 self.chat_wins=ChatList(self) |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
142 self.notBar = sat_widgets.NotificationBar() |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
143 urwid.connect_signal(self.notBar,'change',self.onNotification) |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
144 self.progress_wid = Progress(self) |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
145 urwid.connect_signal(self.notBar.progress,'click',lambda x:self.addWindow(self.progress_wid)) |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
146 self.__saved_overlay = None |
380
ede26abf6ca1
primitivus: freedesktop notifications (if available) when somebody is talking to us and we have not focus, or our nick is pinged and we have not focus.
Goffi <goffi@goffi.org>
parents:
276
diff
changeset
|
147 |
507
f98bef71a918
frontends, core, plugin XEP-0045: leave implementation + better nick change
Goffi <goffi@goffi.org>
parents:
503
diff
changeset
|
148 self.x_notify = Notify() |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
149 |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
150 @property |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
151 def mode(self): |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
152 return self.editBar.mode |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
153 |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
154 @mode.setter |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
155 def mode(self, value): |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
156 self.editBar.mode = value |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
157 |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
158 def modeHint(self, value): |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
159 """Change mode if make sens (i.e.: if there is nothing in the editBar""" |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
160 if not self.editBar.get_edit_text(): |
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
161 self.mode = value |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
162 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
163 def debug(self): |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
164 """convenient method to reset screen and launch p(u)db""" |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
165 try: |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
166 import pudb |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
167 pudb.set_trace() |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
168 except: |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
169 import os,pdb |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
170 os.system('reset') |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
171 print 'Entered debug mode' |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
172 pdb.set_trace() |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
173 |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
174 def writeLog(self, log, file_name='/tmp/primitivus_log'): |
131 | 175 """method to write log in a temporary file, useful for debugging""" |
157
13888bdb72b6
primitivus: button are now working with XMLUI
Goffi <goffi@goffi.org>
parents:
153
diff
changeset
|
176 with open(file_name, 'a') as f: |
13888bdb72b6
primitivus: button are now working with XMLUI
Goffi <goffi@goffi.org>
parents:
153
diff
changeset
|
177 f.write(log+"\n") |
129
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
178 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
179 def redraw(self): |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
180 """redraw the screen""" |
422
5a18c5f08d9b
Primitivus: Profile Manager: fixed redraw on profile change + use of AdvandedEdit for login field
Goffi <goffi@goffi.org>
parents:
415
diff
changeset
|
181 try: |
5a18c5f08d9b
Primitivus: Profile Manager: fixed redraw on profile change + use of AdvandedEdit for login field
Goffi <goffi@goffi.org>
parents:
415
diff
changeset
|
182 self.loop.draw_screen() |
5a18c5f08d9b
Primitivus: Profile Manager: fixed redraw on profile change + use of AdvandedEdit for login field
Goffi <goffi@goffi.org>
parents:
415
diff
changeset
|
183 except AttributeError: |
5a18c5f08d9b
Primitivus: Profile Manager: fixed redraw on profile change + use of AdvandedEdit for login field
Goffi <goffi@goffi.org>
parents:
415
diff
changeset
|
184 pass |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
185 |
112 | 186 def start(self): |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
187 self.i = 0 |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
188 self.loop.set_alarm_in(0,lambda a,b: self.postInit()) |
112 | 189 self.loop.run() |
190 | |
127
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
191 def inputFilter(self, input, raw): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
192 if self.__saved_overlay and input != ['ctrl s']: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
193 return |
127
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
194 for i in input: |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
195 if isinstance(i,tuple): |
127
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
196 if i[0] == 'mouse press': |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
197 if i[1] == 4: #Mouse wheel up |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
198 input[input.index(i)] = 'up' |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
199 if i[1] == 5: #Mouse wheel down |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
200 input[input.index(i)] = 'down' |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
201 return input |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
202 |
55d3ef84f01f
Primitivus: mouse wheel changed to 'up' and 'down' key press
Goffi <goffi@goffi.org>
parents:
125
diff
changeset
|
203 def keyHandler(self, input): |
131 | 204 if input == 'meta m': |
181 | 205 """User want to (un)hide the menu roller""" |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
206 try: |
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
207 if self.main_widget.header == None: |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
208 self.main_widget.header = self.menu_roller |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
209 else: |
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
210 self.main_widget.header = None |
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
211 except AttributeError: |
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
212 pass |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
213 elif input == 'ctrl n': |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
214 """User wants to see next notification""" |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
215 self.notBar.showNext() |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
216 elif input == 'ctrl s': |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
217 """User wants to (un)hide overlay window""" |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
218 if isinstance(self.loop.widget,urwid.Overlay): |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
219 self.__saved_overlay = self.loop.widget |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
220 self.loop.widget = self.main_widget |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
221 else: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
222 if self.__saved_overlay: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
223 self.loop.widget = self.__saved_overlay |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
224 self.__saved_overlay = None |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
225 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
226 elif input == 'ctrl d' and 'D' in self.bridge.getVersion(): #Debug only for dev versions |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
227 self.debug() |
124 | 228 elif input == 'f2': #user wants to (un)hide the contact_list |
229 try: | |
608
ea9aa51234eb
Primitivus: fixed contacts list (un)hidding
Goffi <goffi@goffi.org>
parents:
607
diff
changeset
|
230 for wid, options in self.center_part.contents: |
ea9aa51234eb
Primitivus: fixed contacts list (un)hidding
Goffi <goffi@goffi.org>
parents:
607
diff
changeset
|
231 if self.contact_list is wid: |
ea9aa51234eb
Primitivus: fixed contacts list (un)hidding
Goffi <goffi@goffi.org>
parents:
607
diff
changeset
|
232 self.center_part.contents.remove((wid, options)) |
ea9aa51234eb
Primitivus: fixed contacts list (un)hidding
Goffi <goffi@goffi.org>
parents:
607
diff
changeset
|
233 break |
124 | 234 else: |
607
c123dddaea6b
primitivus: fixed urwid issues with recent urwid versions
Goffi <goffi@goffi.org>
parents:
605
diff
changeset
|
235 self.center_part.contents.insert(0, (self.contact_list, ('weight', 2, False))) |
124 | 236 except AttributeError: |
237 #The main widget is not built (probably in Profile Manager) | |
238 pass | |
129
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
239 elif input == 'window resize': |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
240 width,height = self.loop.screen_size |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
241 if height<=5 and width<=35: |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
242 if not 'save_main_widget' in dir(self): |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
243 self.save_main_widget = self.loop.widget |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
244 self.loop.widget = urwid.Filler(urwid.Text(_("Pleeeeasse, I can't even breathe !"))) |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
245 else: |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
246 if 'save_main_widget' in dir(self): |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
247 self.loop.widget = self.save_main_widget |
542682d67282
sortilege's easter egg reimplemented
Goffi <goffi@goffi.org>
parents:
128
diff
changeset
|
248 del self.save_main_widget |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
249 try: |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
250 return self.menu_roller.checkShortcuts(input) |
128
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
251 except AttributeError: |
2240f34f6452
Primitivus: misc fixes + menubar first draft
Goffi <goffi@goffi.org>
parents:
127
diff
changeset
|
252 return input |
124 | 253 |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
254 |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
255 def __buildMenuRoller(self): |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
256 menu = sat_widgets.Menu(self.loop) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
257 general = _("General") |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
258 menu.addMenu(general, _("Connect"), self.onConnectRequest) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
259 menu.addMenu(general, _("Disconnect"), self.onDisconnectRequest) |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
260 menu.addMenu(general, _("Parameters"), self.onParam) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
261 menu.addMenu(general, _("About"), self.onAboutRequest) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
262 menu.addMenu(general, _("Exit"), self.onExitRequest, 'ctrl x') |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
263 contact = _("Contact") |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
264 menu.addMenu(contact, _("Add contact"), self.onAddContactRequest) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
265 menu.addMenu(contact, _("Remove contact"), self.onRemoveContactRequest) |
131 | 266 communication = _("Communication") |
267 menu.addMenu(communication, _("Join room"), self.onJoinRoomRequest, 'meta j') | |
173 | 268 menu.addMenu(communication, _("Find Gateways"), self.onFindGatewaysRequest, 'meta g') |
633
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
269 menu.addMenu(communication, _("Search directory"), self.onSearchDirectory) |
145
c8b231abfe96
Primitivus: additionnal menus management
Goffi <goffi@goffi.org>
parents:
144
diff
changeset
|
270 #additionals menus |
c8b231abfe96
Primitivus: additionnal menus management
Goffi <goffi@goffi.org>
parents:
144
diff
changeset
|
271 #FIXME: do this in a more generic way (in quickapp) |
c8b231abfe96
Primitivus: additionnal menus management
Goffi <goffi@goffi.org>
parents:
144
diff
changeset
|
272 add_menus = self.bridge.getMenus() |
c8b231abfe96
Primitivus: additionnal menus management
Goffi <goffi@goffi.org>
parents:
144
diff
changeset
|
273 def add_menu_cb(menu): |
c8b231abfe96
Primitivus: additionnal menus management
Goffi <goffi@goffi.org>
parents:
144
diff
changeset
|
274 category, item = menu |
219
782319a64ac6
primitivus, wix: added forgotten profile
Goffi <goffi@goffi.org>
parents:
216
diff
changeset
|
275 id = self.bridge.callMenu(category, item, "NORMAL", self.profile) |
145
c8b231abfe96
Primitivus: additionnal menus management
Goffi <goffi@goffi.org>
parents:
144
diff
changeset
|
276 self.current_action_ids.add(id) |
c8b231abfe96
Primitivus: additionnal menus management
Goffi <goffi@goffi.org>
parents:
144
diff
changeset
|
277 for new_menu in add_menus: |
c8b231abfe96
Primitivus: additionnal menus management
Goffi <goffi@goffi.org>
parents:
144
diff
changeset
|
278 category,item,type = new_menu |
c8b231abfe96
Primitivus: additionnal menus management
Goffi <goffi@goffi.org>
parents:
144
diff
changeset
|
279 assert(type=="NORMAL") #TODO: manage other types |
216
783d6a61e0bd
primitivus: Q&D workaround for dbus.String issue
Goffi <goffi@goffi.org>
parents:
204
diff
changeset
|
280 menu.addMenu(unicode(category), unicode(item), add_menu_cb) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
281 |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
282 menu_roller = sat_widgets.MenuRoller([(_('Main menu'),menu)]) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
283 return menu_roller |
131 | 284 |
112 | 285 def __buildMainWidget(self): |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
495
diff
changeset
|
286 self.contact_list = ContactList(self, on_click = self.contactSelected, on_change=lambda w: self.redraw()) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
495
diff
changeset
|
287 #self.center_part = urwid.Columns([('weight',2,self.contact_list),('weight',8,Chat('',self))]) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
495
diff
changeset
|
288 self.center_part = urwid.Columns([('weight',2,self.contact_list), ('weight',8,urwid.Filler(urwid.Text('')))]) |
524
0bb595eff25b
primitivus: Primitivus is now modal (vi-like behaviour):
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
289 |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
290 self.editBar = EditBar(self) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
291 self.menu_roller = self.__buildMenuRoller() |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
292 self.main_widget = sat_widgets.FocusFrame(self.center_part, header=self.menu_roller, footer=self.editBar, focus_part='footer') |
118
76055a209ed9
primitivus: added edition zone at the bottom
Goffi <goffi@goffi.org>
parents:
117
diff
changeset
|
293 return self.main_widget |
112 | 294 |
116
7c482ecac0ff
primitivus: basic contact list, connexion now work \o/
Goffi <goffi@goffi.org>
parents:
113
diff
changeset
|
295 def plug_profile(self, profile_key='@DEFAULT@'): |
415
3348331e0f09
primitivus: fixed screen redraw after plugin profile
Goffi <goffi@goffi.org>
parents:
411
diff
changeset
|
296 self.loop.widget = self.__buildMainWidget() |
3348331e0f09
primitivus: fixed screen redraw after plugin profile
Goffi <goffi@goffi.org>
parents:
411
diff
changeset
|
297 self.redraw() |
116
7c482ecac0ff
primitivus: basic contact list, connexion now work \o/
Goffi <goffi@goffi.org>
parents:
113
diff
changeset
|
298 QuickApp.plug_profile(self, profile_key) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
299 |
120 | 300 def removePopUp(self, widget=None): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
301 "Remove current pop-up, and if there is other in queue, show it" |
117 | 302 self.loop.widget = self.main_widget |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
303 next_popup = self.notBar.getNextPopup() |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
304 if next_popup: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
305 #we still have popup to show, we display it |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
306 self.showPopUp(next_popup) |
117 | 307 |
176 | 308 def showPopUp(self, pop_up_widget, perc_width=40, perc_height=40): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
309 "Show a pop-up window if possible, else put it in queue" |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
310 if not isinstance(self.loop.widget,urwid.Overlay): |
176 | 311 display_widget = urwid.Overlay(pop_up_widget, self.main_widget, 'center', ('relative', perc_width), 'middle', ('relative', perc_height)) |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
312 self.loop.widget = display_widget |
219
782319a64ac6
primitivus, wix: added forgotten profile
Goffi <goffi@goffi.org>
parents:
216
diff
changeset
|
313 self.redraw() |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
314 else: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
315 self.notBar.addPopUp(pop_up_widget) |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
316 |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
317 def notify(self, message): |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
318 """"Notify message to user via notification bar""" |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
319 self.notBar.addMessage(message) |
112 | 320 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
321 def addWindow(self, widget): |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
322 """Display a window if possible, |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
323 else add it in the notification bar queue |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
324 @param widget: BoxWidget""" |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
325 assert(len(self.center_part.widget_list)<=2) |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
326 wid_idx = len(self.center_part.widget_list)-1 |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
327 self.center_part.widget_list[wid_idx] = widget |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
328 self.menu_roller.removeMenu(_('Chat menu')) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
495
diff
changeset
|
329 self.contact_list.unselectAll() |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
330 self.redraw() |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
331 |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
332 def removeWindow(self): |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
333 """Remove window showed on the right column""" |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
334 #TODO: to a better Window management than this crappy hack |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
335 assert(len(self.center_part.widget_list)<=2) |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
336 wid_idx = len(self.center_part.widget_list)-1 |
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
337 self.center_part.widget_list[wid_idx] = urwid.Filler(urwid.Text('')) |
168 | 338 self.center_part.set_focus(0) |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
339 self.redraw() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
340 |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
341 def addProgress (self, id, message): |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
342 """Follow a SàT progress bar |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
343 @param id: SàT id of the progression |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
344 @param message: message to show to identify the progression""" |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
345 self.progress_wid.addProgress(id, message) |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
346 |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
347 def setProgress(self, percentage): |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
348 """Set the progression shown in notification bar""" |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
349 self.notBar.setProgress(percentage) |
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
176
diff
changeset
|
350 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
351 def contactSelected(self, contact_list): |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
495
diff
changeset
|
352 contact = contact_list.getContact() |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
353 if contact: |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
354 assert(len(self.center_part.widget_list)==2) |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
355 self.center_part.widget_list[1] = self.chat_wins[contact] |
144
80661755ea8d
Primitivus: Tarot card game implementation
Goffi <goffi@goffi.org>
parents:
137
diff
changeset
|
356 self.menu_roller.addMenu(_('Chat menu'), self.chat_wins[contact].getMenu()) |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
118
diff
changeset
|
357 |
513
8ee9113d307b
core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents:
510
diff
changeset
|
358 def newMessage(self, from_jid, to_jid, msg, _type, extra, profile): |
8ee9113d307b
core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents:
510
diff
changeset
|
359 QuickApp.newMessage(self, from_jid, to_jid, msg, _type, extra, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
360 |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
361 if not from_jid in self.contact_list and from_jid.short != self.profiles[profile]['whoami'].short: |
503
10119c2a9d33
Primitivus: new entities are added to contact list if they send messages + QuickFrontend: names fixes
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
362 #XXX: needed to show entities which haven't sent any |
10119c2a9d33
Primitivus: new entities are added to contact list if they send messages + QuickFrontend: names fixes
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
363 # presence information and which are not in roster |
10119c2a9d33
Primitivus: new entities are added to contact list if they send messages + QuickFrontend: names fixes
Goffi <goffi@goffi.org>
parents:
501
diff
changeset
|
364 #TODO: put these entities in a "not in roster" list |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
365 self.contact_list.replace(from_jid) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
366 |
510
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
367 if JID(self.contact_list.selected).short != from_jid.short: |
886754295efe
quick frontend, primitivus, wix: MUC private messages management
Goffi <goffi@goffi.org>
parents:
507
diff
changeset
|
368 self.contact_list.putAlert(from_jid) |
125
8d611eb9ae48
primitivus: contact list enhancement
Goffi <goffi@goffi.org>
parents:
124
diff
changeset
|
369 |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
370 def _dialogOkCb(self, widget, data): |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
371 self.removePopUp() |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
372 answer_cb = data[0] |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
373 answer_data = [data[1]] if data[1] else [] |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
374 answer_cb(True, *answer_data) |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
375 |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
376 def _dialogCancelCb(self, widget, data): |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
377 self.removePopUp() |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
378 answer_cb = data[0] |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
379 answer_data = [data[1]] if data[1] else [] |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
380 answer_cb(False, *answer_data) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
381 |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
382 |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
383 def showDialog(self, message, title="", type="info", answer_cb = None, answer_data = None): |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
384 if type == 'info': |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
385 popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
386 elif type == 'error': |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
387 popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
388 elif type == 'yes/no': |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
389 popup = sat_widgets.ConfirmDialog(unicode(message), |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
390 yes_cb=self._dialogOkCb, yes_value = (answer_cb, answer_data), |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
391 no_cb=self._dialogCancelCb, no_value = (answer_cb, answer_data)) |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
392 else: |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
393 popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
394 error(_('unmanaged dialog type: %s'), type) |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
181
diff
changeset
|
395 self.showPopUp(popup) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
396 |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
397 def onNotification(self, notBar): |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
398 """Called when a new notification has been received""" |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
399 if not isinstance(self.main_widget, sat_widgets.FocusFrame): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
400 #if we are not in the main configuration, we ignore the notifications bar |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
401 return |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
402 if isinstance(self.main_widget.footer,sat_widgets.AdvancedEdit): |
159
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
403 if not self.notBar.canHide(): |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
404 #the notification bar is not visible and has usefull informations, we show it |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
405 pile = urwid.Pile([self.notBar, self.editBar]) |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
406 self.main_widget.footer = pile |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
407 else: |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
408 if not isinstance(self.main_widget.footer, urwid.Pile): |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
409 error(_("INTERNAL ERROR: Unexpected class for main widget's footer")) |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
410 assert(False) |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
411 if self.notBar.canHide(): |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
412 #No notification left, we can hide the bar |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
413 self.main_widget.footer = self.editBar |
2fa58703f1b7
Primitivus: notification bar, first draft
Goffi <goffi@goffi.org>
parents:
157
diff
changeset
|
414 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
415 def askConfirmation(self, confirmation_id, confirmation_type, data, profile): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
416 if not self.check_profile(profile): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
417 return |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
418 answer_data={} |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
419 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
420 def dir_selected_cb(path): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
421 dest_path = join(path, data['filename']) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
422 answer_data["dest_path"] = getNewPath(dest_path) |
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
423 self.addProgress(confirmation_id, dest_path) |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
424 accept_cb(None) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
425 |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
426 def accept_file_transfer_cb(widget): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
427 self.removePopUp() |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
428 pop_up_widget = FileDialog(dir_selected_cb, refuse_cb, title=_(u"Where do you want to save the file ?"), style=['dir']) |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
429 self.showPopUp(pop_up_widget) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
430 |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
431 def accept_cb(widget): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
432 self.removePopUp() |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
433 self.bridge.confirmationAnswer(confirmation_id, True, answer_data, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
434 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
435 def refuse_cb(widget): |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
436 self.removePopUp() |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
437 self.bridge.confirmationAnswer(confirmation_id, False, answer_data, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
438 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
439 if confirmation_type == "FILE_TRANSFER": |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
440 pop_up_widget = sat_widgets.ConfirmDialog(_("The contact %(jid)s wants to send you the file %(filename)s\nDo you accept ?") % {'jid':data["from"], 'filename':data["filename"]}, no_cb=refuse_cb, yes_cb=accept_file_transfer_cb) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
441 self.showPopUp(pop_up_widget) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
442 |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
443 elif confirmation_type == "YES/NO": |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
444 pop_up_widget = sat_widgets.ConfirmDialog(data["message"], no_cb=refuse_cb, yes_cb=accept_cb) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
445 self.showPopUp(pop_up_widget) |
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
530
diff
changeset
|
446 |
546
9dd297c513b4
primitivus: fixed actionResult call (fix gateways management)
Goffi <goffi@goffi.org>
parents:
542
diff
changeset
|
447 def actionResult(self, type, id, data, profile): |
9dd297c513b4
primitivus: fixed actionResult call (fix gateways management)
Goffi <goffi@goffi.org>
parents:
542
diff
changeset
|
448 if not self.check_profile(profile): |
9dd297c513b4
primitivus: fixed actionResult call (fix gateways management)
Goffi <goffi@goffi.org>
parents:
542
diff
changeset
|
449 return |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
450 |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
451 if not id in self.current_action_ids: |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
452 debug (_('unknown id, ignoring')) |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
453 return |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
454 if type == "SUPPRESS": |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
455 self.current_action_ids.remove(id) |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
456 elif type == "XMLUI": |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
457 self.current_action_ids.remove(id) |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
458 debug (_("XML user interface received")) |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
459 misc = {} |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
460 #FIXME FIXME FIXME: must clean all this crap ! |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
461 title = _('Form') |
173 | 462 if data['type'] == 'registration': |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
463 title = _('Registration') |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
464 misc['target'] = data['target'] |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
465 misc['action_back'] = self.bridge.gatewayRegister |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
466 ui = XMLUI(self, title=title, xml_data = data['xml'], misc = misc) |
173 | 467 if data['type'] == 'registration': |
468 ui.show('popup') | |
469 else: | |
470 ui.show('window') | |
471 elif type == "ERROR": | |
472 self.current_action_ids.remove(id) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
473 self.showPopUp(sat_widgets.Alert(_("Error"), unicode(data["message"]), ok_cb=self.removePopUp)) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore |
173 | 474 elif type == "RESULT": |
475 self.current_action_ids.remove(id) | |
476 if self.current_action_ids_cb.has_key(id): | |
477 callback = self.current_action_ids_cb[id] | |
478 del self.current_action_ids_cb[id] | |
479 callback(data) | |
480 elif type == "DICT_DICT": | |
481 self.current_action_ids.remove(id) | |
482 if self.current_action_ids_cb.has_key(id): | |
483 callback = self.current_action_ids_cb[id] | |
484 del self.current_action_ids_cb[id] | |
485 callback(data) | |
153
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
486 else: |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
487 error (_("FIXME FIXME FIXME: type [%s] not implemented") % type) |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
488 raise NotImplementedError |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
489 |
f197b52796ee
Primitivus: begining of management for actionResult
Goffi <goffi@goffi.org>
parents:
145
diff
changeset
|
490 ##DIALOGS CALLBACKS## |
120 | 491 def onJoinRoom(self, button, edit): |
492 self.removePopUp() | |
493 room_jid = JID(edit.get_edit_text()) | |
494 if room_jid.is_valid(): | |
405
10b4f577d0c0
MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents:
382
diff
changeset
|
495 self.bridge.joinMUC(room_jid, self.profiles[self.profile]['whoami'].node, {}, self.profile) |
120 | 496 else: |
497 message = _("'%s' is an invalid JID !") % room_jid | |
498 error (message) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
499 self.showPopUp(sat_widgets.Alert(_("Error"), message, ok_cb=self.removePopUp)) |
120 | 500 |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
501 def onAddContact(self, button, edit): |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
502 self.removePopUp() |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
503 jid=JID(edit.get_edit_text()) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
504 if jid.is_valid(): |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
505 self.bridge.addContact(jid.short, profile_key=self.profile) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
506 else: |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
507 message = _("'%s' is an invalid JID !") % jid |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
508 error (message) |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
509 self.showPopUp(sat_widgets.Alert(_("Error"), message, ok_cb=self.removePopUp)) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
510 |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
511 def onRemoveContact(self, button): |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
512 self.removePopUp() |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
495
diff
changeset
|
513 info(_("Unsubscribing %s presence"),self.contact_list.getContact()) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
495
diff
changeset
|
514 self.bridge.delContact(self.contact_list.getContact(), profile_key=self.profile) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
515 |
173 | 516 #MENU EVENTS# |
131 | 517 def onConnectRequest(self, menu): |
518 self.bridge.connect(self.profile) | |
519 | |
520 def onDisconnectRequest(self, menu): | |
521 self.bridge.disconnect(self.profile) | |
522 | |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
523 def onParam(self, menu): |
423
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
422
diff
changeset
|
524 def success(params): |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
422
diff
changeset
|
525 self.addWindow(XMLUI(self,xml_data=params)) |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
422
diff
changeset
|
526 def failure(error): |
6c20c76abdcc
backend: - bridge async D-Bus method now automatically manage callback and errback, we just have to return a deferred
Goffi <goffi@goffi.org>
parents:
422
diff
changeset
|
527 self.showPopUp(sat_widgets.Alert(_("Error"), _("Can't get parameters"), ok_cb=self.removePopUp)) |
634
ca2cae6b2c6d
core: security attribute added to the parameters
souliane <souliane@mailoo.org>
parents:
633
diff
changeset
|
528 security_limit = -1 |
ca2cae6b2c6d
core: security attribute added to the parameters
souliane <souliane@mailoo.org>
parents:
633
diff
changeset
|
529 self.bridge.getParamsUI(security_limit, self.profile, callback=success, errback=failure) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
530 |
166
b318d2b58887
Primitivus: parameters management via XMLUI
Goffi <goffi@goffi.org>
parents:
159
diff
changeset
|
531 |
131 | 532 def onExitRequest(self, menu): |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
533 QuickApp.onExit(self) |
131 | 534 raise urwid.ExitMainLoop() |
535 | |
536 def onJoinRoomRequest(self, menu): | |
537 """User wants to join a MUC room""" | |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
538 pop_up_widget = sat_widgets.InputDialog(_("Entering a MUC room"), _("Please enter MUC's JID"), default_txt = 'room@muc_service.server.tld', cancel_cb=self.removePopUp, ok_cb=self.onJoinRoom) |
131 | 539 self.showPopUp(pop_up_widget) |
540 | |
173 | 541 def onFindGatewaysRequest(self, e): |
633
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
542 debug(_("Find gateways request")) |
173 | 543 id = self.bridge.findGateways(self.profiles[self.profile]['whoami'].domain, self.profile) |
544 self.current_action_ids.add(id) | |
545 self.current_action_ids_cb[id] = self.onGatewaysFound | |
546 | |
633
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
547 def onSearchDirectory(self, e): |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
548 debug(_("Search directory request")) |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
549 |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
550 def requestSearchUi(button, edit): |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
551 self.removePopUp() |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
552 search_jid = edit.get_edit_text() |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
553 if search_jid: |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
554 def success(xml): |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
555 self.addWindow(XMLUI(self,xml_data=xml, misc={'callback': self._onSearchRequest, 'callback_args': [search_jid,]})) |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
556 def failure(error): |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
557 self.showPopUp(sat_widgets.Alert(_("Error"), _("Can't get search UI"), ok_cb=self.removePopUp)) |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
558 self.bridge.getSearchUI(search_jid, self.profile, callback=success, errback=failure) |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
559 |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
560 |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
561 # TODO: replace users.jabberfr.org by any XEP-0055 compatible service discovered on current server |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
562 pop_up_widget = sat_widgets.InputDialog(_("Search directory"), _("Please enter the search jid: "), default_txt="users.jabberfr.org", cancel_cb=lambda ignore: self.removePopUp(), ok_cb=requestSearchUi) |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
563 self.showPopUp(pop_up_widget) |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
564 |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
565 def onAddContactRequest(self, menu): |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
566 pop_up_widget = sat_widgets.InputDialog(_("Adding a contact"), _("Please enter new contact JID"), default_txt = 'name@server.tld', cancel_cb=self.removePopUp, ok_cb=self.onAddContact) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
567 self.showPopUp(pop_up_widget) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
568 |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
569 def onRemoveContactRequest(self, menu): |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
495
diff
changeset
|
570 contact = self.contact_list.getContact() |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
571 if not contact: |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
572 self.showPopUp(sat_widgets.Alert(_("Error"), _("You have not selected any contact to delete !"), ok_cb=self.removePopUp)) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
573 else: |
222
3198bfd66daa
primitivus: refactoring to use urwid-satext which is now a separate project
Goffi <goffi@goffi.org>
parents:
219
diff
changeset
|
574 pop_up_widget = sat_widgets.ConfirmDialog(_("Are you sure you want to delete the contact [%s] ?" % contact), yes_cb=self.onRemoveContact, no_cb=self.removePopUp) |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
575 self.showPopUp(pop_up_widget) |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
576 |
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
577 def onAboutRequest(self, menu): |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
578 self.showPopUp(sat_widgets.Alert(_("About"), const_APP_NAME + " v" + self.bridge.getVersion(), ok_cb=self.removePopUp)) |
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
579 |
173 | 580 #MISC CALLBACKS# |
581 | |
582 def onGatewaysFound(self, data): | |
583 """Called when SàT has found the server gateways""" | |
584 target = data['__private__']['target'] | |
585 del data['__private__'] | |
586 gatewayManager = GatewaysManager(self, data, server=target) | |
587 self.addWindow(gatewayManager) | |
137
227394eb080c
Primitivus: menu are now managed and fully working
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
588 |
633
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
589 def _onSearchRequest(self, data, search_jid): |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
590 def success(xml): |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
591 ui = XMLUI(self, title=_(u"Search result"), xml_data = xml) |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
592 ui.show('window') |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
593 def failure(error): |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
594 self.showPopUp(sat_widgets.Alert(_("Error"), _("Can't get search UI"), ok_cb=self.removePopUp)) |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
595 self.bridge.searchRequest(search_jid, dict(data), self.profile, callback=success, errback=failure) |
6a29a4d574bd
primitivus: menu to search directory (using XEP-0055)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
596 |
637
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
597 def chatStateReceived(self, from_jid_s, state, profile): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
598 """Signal observer to display a contact chat state |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
599 @param from_jid_s: contact who sent his new state |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
600 @state: state |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
601 @profile: current profile |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
602 """ |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
603 if not self.check_profile(profile): |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
604 return |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
605 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
606 if from_jid_s == "@ALL@": |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
607 for win in self.chat_wins: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
608 self.chat_wins[win].updateChatState(state) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
609 return |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
610 |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
611 from_bare = JID(from_jid_s).short |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
612 if from_bare in self.chat_wins: |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
613 self.chat_wins[from_bare].updateChatState(state) |
3b02554d4c8b
primitivus: chat state implementation
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
614 |
112 | 615 sat = PrimitivusApp() |
616 sat.start() |