annotate cagou/plugins/plugin_wid_chat.py @ 180:0ddd2b20cc6b

plugins chat, contact_list, settings, widget_selector: changed icons theme
author Goffi <goffi@goffi.org>
date Tue, 01 May 2018 20:50:05 +0200
parents 826e7b17a19b
children c63922860f80
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client
126
cd99f70ea592 global file reorganisation:
Goffi <goffi@goffi.org>
parents: 122
diff changeset
5 # Copyright (C) 2016-2018 Jérôme Poisson (goffi@goffi.org)
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from sat.core import log as logging
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 log = logging.getLogger(__name__)
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from sat.core.i18n import _
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from cagou.core.constants import Const as C
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
25 from kivy.uix.boxlayout import BoxLayout
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
26 from kivy.uix.gridlayout import GridLayout
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from kivy.uix.textinput import TextInput
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
28 from kivy.metrics import dp
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from kivy import properties
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from sat_frontends.quick_frontend import quick_widgets
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from sat_frontends.quick_frontend import quick_chat
106
9909ed7a7a20 moved SimpleXHTMLWidget to a dedicated module
Goffi <goffi@goffi.org>
parents: 105
diff changeset
32 from sat_frontends.tools import jid
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 from cagou.core import cagou_widget
106
9909ed7a7a20 moved SimpleXHTMLWidget to a dedicated module
Goffi <goffi@goffi.org>
parents: 105
diff changeset
34 from cagou.core.image import Image
145
654b00fa3fdc core (common): renamed JidWidget to JidItem to avoid name conflict with XMLUI
Goffi <goffi@goffi.org>
parents: 144
diff changeset
35 from cagou.core.common import SymbolButton, JidItem
109
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
36 from kivy.uix.dropdown import DropDown
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 from cagou import G
111
c3952922ca56 chat: uploaded images are now sent with XHTML, so they are shown inline
Goffi <goffi@goffi.org>
parents: 109
diff changeset
38 import mimetypes
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
39
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
40
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 PLUGIN_INFO = {
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 "name": _(u"chat"),
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 "main": "Chat",
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 "description": _(u"instant messaging with one person or a group"),
180
0ddd2b20cc6b plugins chat, contact_list, settings, widget_selector: changed icons theme
Goffi <goffi@goffi.org>
parents: 156
diff changeset
45 "icon_symbol": u"chat",
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 }
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
47
122
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
48 # following const are here temporary, they should move to quick frontend
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
49 OTR_STATE_UNTRUSTED = 'untrusted'
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
50 OTR_STATE_TRUSTED = 'trusted'
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
51 OTR_STATE_TRUST = (OTR_STATE_UNTRUSTED, OTR_STATE_TRUSTED)
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
52 OTR_STATE_UNENCRYPTED = 'unencrypted'
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
53 OTR_STATE_ENCRYPTED = 'encrypted'
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
54 OTR_STATE_ENCRYPTION = (OTR_STATE_UNENCRYPTED, OTR_STATE_ENCRYPTED)
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
55
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
56
44
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 42
diff changeset
57 class MessAvatar(Image):
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 42
diff changeset
58 pass
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 42
diff changeset
59
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 42
diff changeset
60
138
53fb221ad084 plugin chat: layout change:
Goffi <goffi@goffi.org>
parents: 135
diff changeset
61 class MessageWidget(BoxLayout):
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 mess_data = properties.ObjectProperty()
57
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
63 mess_xhtml = properties.ObjectProperty()
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
64 mess_padding = (dp(5), dp(5))
47
abb81efef3bb chat: update avatar following quick frontend improvments
Goffi <goffi@goffi.org>
parents: 46
diff changeset
65 avatar = properties.ObjectProperty()
103
c601e3d40342 chat: display delivery receipt (with a green check mark)
Goffi <goffi@goffi.org>
parents: 102
diff changeset
66 delivery = properties.ObjectProperty()
47
abb81efef3bb chat: update avatar following quick frontend improvments
Goffi <goffi@goffi.org>
parents: 46
diff changeset
67
abb81efef3bb chat: update avatar following quick frontend improvments
Goffi <goffi@goffi.org>
parents: 46
diff changeset
68 def __init__(self, **kwargs):
105
ce6ef88f2cff chat: avatar improvments:
Goffi <goffi@goffi.org>
parents: 103
diff changeset
69 # self must be registered in widgets before kv is parsed
ce6ef88f2cff chat: avatar improvments:
Goffi <goffi@goffi.org>
parents: 103
diff changeset
70 kwargs['mess_data'].widgets.add(self)
47
abb81efef3bb chat: update avatar following quick frontend improvments
Goffi <goffi@goffi.org>
parents: 46
diff changeset
71 super(MessageWidget, self).__init__(**kwargs)
105
ce6ef88f2cff chat: avatar improvments:
Goffi <goffi@goffi.org>
parents: 103
diff changeset
72 avatar_path = self.mess_data.avatar
ce6ef88f2cff chat: avatar improvments:
Goffi <goffi@goffi.org>
parents: 103
diff changeset
73 if avatar_path is not None:
ce6ef88f2cff chat: avatar improvments:
Goffi <goffi@goffi.org>
parents: 103
diff changeset
74 self.avatar.source = avatar_path
44
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 42
diff changeset
75
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 42
diff changeset
76 @property
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 42
diff changeset
77 def chat(self):
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 42
diff changeset
78 """return parent Chat instance"""
7819e9efa250 chat: avatar and nick are now displayed, need further aesthetic improvments
Goffi <goffi@goffi.org>
parents: 42
diff changeset
79 return self.mess_data.parent
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
80
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 @property
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 def message(self):
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 """Return currently displayed message"""
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 return self.mess_data.main_message
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
85
57
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
86 @property
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
87 def message_xhtml(self):
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
88 """Return currently displayed message"""
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
89 return self.mess_data.main_message_xhtml
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
90
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
91 def widthAdjust(self):
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
92 """this widget grows up with its children"""
57
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
93 pass
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
94 # parent = self.mess_xhtml.parent
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
95 # padding_x = self.mess_padding[0]
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
96 # text_width, text_height = self.mess_xhtml.texture_size
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
97 # if text_width > parent.width:
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
98 # self.mess_xhtml.text_size = (parent.width - padding_x, None)
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
99 # self.text_max = text_width
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
100 # elif self.mess_xhtml.text_size[0] is not None and text_width < parent.width - padding_x:
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
101 # if text_width < self.text_max:
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
102 # self.mess_xhtml.text_size = (None, None)
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
103 # else:
a51ea7874e43 chat: XHTML parsing first draft:
Goffi <goffi@goffi.org>
parents: 54
diff changeset
104 # self.mess_xhtml.text_size = (parent.width - padding_x, None)
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
105
54
514c187afebc chat: changed udpate to use dict instead of single key/value
Goffi <goffi@goffi.org>
parents: 47
diff changeset
106 def update(self, update_dict):
514c187afebc chat: changed udpate to use dict instead of single key/value
Goffi <goffi@goffi.org>
parents: 47
diff changeset
107 if 'avatar' in update_dict:
514c187afebc chat: changed udpate to use dict instead of single key/value
Goffi <goffi@goffi.org>
parents: 47
diff changeset
108 self.avatar.source = update_dict['avatar']
103
c601e3d40342 chat: display delivery receipt (with a green check mark)
Goffi <goffi@goffi.org>
parents: 102
diff changeset
109 if 'status' in update_dict:
c601e3d40342 chat: display delivery receipt (with a green check mark)
Goffi <goffi@goffi.org>
parents: 102
diff changeset
110 status = update_dict['status']
c601e3d40342 chat: display delivery receipt (with a green check mark)
Goffi <goffi@goffi.org>
parents: 102
diff changeset
111 self.delivery.text = u'\u2714' if status == 'delivered' else u''
47
abb81efef3bb chat: update avatar following quick frontend improvments
Goffi <goffi@goffi.org>
parents: 46
diff changeset
112
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
113
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
114 class MessageInputBox(BoxLayout):
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
115 pass
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
116
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
117
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 class MessageInputWidget(TextInput):
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
119
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
120 def _key_down(self, key, repeat=False):
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 displayed_str, internal_str, internal_action, scale = key
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 if internal_action == 'enter':
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 self.dispatch('on_text_validate')
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 else:
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
125 super(MessageInputWidget, self)._key_down(key, repeat)
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
126
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
127
45
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
128 class MessagesWidget(GridLayout):
b0595a33465d chat: design improvments:
Goffi <goffi@goffi.org>
parents: 44
diff changeset
129 pass
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
130
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
131
135
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
132 class EncryptionButton(SymbolButton):
117
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
133
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
134 def __init__(self, chat, **kwargs):
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
135 """
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
136 @param chat(Chat): Chat instance
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
137 """
122
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
138 self.chat = chat
117
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
139 # for now we do a simple ContextMenu as we have only OTR
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
140 self.otr_menu = OtrMenu(chat)
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
141 super(EncryptionButton, self).__init__(**kwargs)
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
142 self.bind(on_release=self.otr_menu.open)
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
143
135
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
144 def getColor(self):
122
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
145 if self.chat.otr_state_encryption == OTR_STATE_UNENCRYPTED:
135
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
146 return (0.4, 0.4, 0.4, 1)
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
147 elif self.chat.otr_state_trust == OTR_STATE_TRUSTED:
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
148 return (0.29,0.87,0.0,1)
122
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
149 else:
135
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
150 return (0.4, 0.4, 0.4, 1)
122
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
151
135
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
152 def getSymbol(self):
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
153 if self.chat.otr_state_encryption == OTR_STATE_UNENCRYPTED:
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
154 return 'lock-open'
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
155 elif self.chat.otr_state_trust == OTR_STATE_TRUSTED:
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
156 return 'lock-filled'
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
157 else:
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
158 return 'lock'
122
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
159
117
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
160
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
161 class OtrMenu(DropDown):
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
162
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
163 def __init__(self, chat, **kwargs):
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
164 """
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
165 @param chat(Chat): Chat instance
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
166 """
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
167 self.chat = chat
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
168 super(OtrMenu, self).__init__(**kwargs)
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
169
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
170 def otr_start(self):
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
171 self.dismiss()
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
172 G.host.launchMenu(
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
173 C.MENU_SINGLE,
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
174 (u"otr", u"start/refresh"),
120
51e804dbf608 chat: fixed OTR calls:
Goffi <goffi@goffi.org>
parents: 117
diff changeset
175 {u'jid': unicode(self.chat.target)},
117
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
176 None,
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
177 C.NO_SECURITY_LIMIT,
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
178 self.chat.profile
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
179 )
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
180
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
181 def otr_end(self):
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
182 self.dismiss()
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
183 G.host.launchMenu(
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
184 C.MENU_SINGLE,
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
185 (u"otr", u"end session"),
120
51e804dbf608 chat: fixed OTR calls:
Goffi <goffi@goffi.org>
parents: 117
diff changeset
186 {u'jid': unicode(self.chat.target)},
117
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
187 None,
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
188 C.NO_SECURITY_LIMIT,
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
189 self.chat.profile
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
190 )
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
191
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
192 def otr_authenticate(self):
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
193 self.dismiss()
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
194 G.host.launchMenu(
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
195 C.MENU_SINGLE,
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
196 (u"otr", u"authenticate"),
120
51e804dbf608 chat: fixed OTR calls:
Goffi <goffi@goffi.org>
parents: 117
diff changeset
197 {u'jid': unicode(self.chat.target)},
117
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
198 None,
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
199 C.NO_SECURITY_LIMIT,
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
200 self.chat.profile
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
201 )
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
202
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
203
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
204 class Chat(quick_chat.QuickChat, cagou_widget.CagouWidget):
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
205 message_input = properties.ObjectProperty()
86
c711be670ecd core, chat: upload plugin system:
Goffi <goffi@goffi.org>
parents: 78
diff changeset
206 messages_widget = properties.ObjectProperty()
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
207
46
d6a63942d5ad chat: fixed MUC joining following changes in backend
Goffi <goffi@goffi.org>
parents: 45
diff changeset
208 def __init__(self, host, target, type_=C.CHAT_ONE2ONE, nick=None, occupants=None, subject=None, profiles=None):
d6a63942d5ad chat: fixed MUC joining following changes in backend
Goffi <goffi@goffi.org>
parents: 45
diff changeset
209 quick_chat.QuickChat.__init__(self, host, target, type_, nick, occupants, subject, profiles=profiles)
122
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
210 self.otr_state_encryption = OTR_STATE_UNENCRYPTED
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
211 self.otr_state_trust = OTR_STATE_UNTRUSTED
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
212 cagou_widget.CagouWidget.__init__(self)
117
f0291755b07c chat: OTR integration first draft:
Goffi <goffi@goffi.org>
parents: 111
diff changeset
213 if type_ == C.CHAT_ONE2ONE:
122
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
214 self.encryption_btn = EncryptionButton(self)
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
215 self.headerInputAddExtra(self.encryption_btn)
67
5f7f72c2635f chat: shortened chat header
Goffi <goffi@goffi.org>
parents: 59
diff changeset
216 self.header_input.hint_text = u"{}".format(target)
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
217 self.host.addListener('progressError', self.onProgressError, profiles)
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
218 self.host.addListener('progressFinished', self.onProgressFinished, profiles)
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
219 self._waiting_pids = {} # waiting progress ids
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
220 self.postInit()
109
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
221 # completion attribtues
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
222 self._hi_comp_data = None
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
223 self._hi_comp_last = None
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
224 self._hi_comp_dropdown = DropDown()
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
225 self._hi_comp_allowed = True
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
226
156
826e7b17a19b chat: added __unicode__ and __str__
Goffi <goffi@goffi.org>
parents: 145
diff changeset
227 def __unicode__(self):
826e7b17a19b chat: added __unicode__ and __str__
Goffi <goffi@goffi.org>
parents: 145
diff changeset
228 return u"Chat({})".format(self.target)
826e7b17a19b chat: added __unicode__ and __str__
Goffi <goffi@goffi.org>
parents: 145
diff changeset
229
826e7b17a19b chat: added __unicode__ and __str__
Goffi <goffi@goffi.org>
parents: 145
diff changeset
230 def __str__(self):
826e7b17a19b chat: added __unicode__ and __str__
Goffi <goffi@goffi.org>
parents: 145
diff changeset
231 return self.__unicode__().encode('utf-8')
826e7b17a19b chat: added __unicode__ and __str__
Goffi <goffi@goffi.org>
parents: 145
diff changeset
232
826e7b17a19b chat: added __unicode__ and __str__
Goffi <goffi@goffi.org>
parents: 145
diff changeset
233 def __repr__(self):
826e7b17a19b chat: added __unicode__ and __str__
Goffi <goffi@goffi.org>
parents: 145
diff changeset
234 return self.__str__()
826e7b17a19b chat: added __unicode__ and __str__
Goffi <goffi@goffi.org>
parents: 145
diff changeset
235
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
236 @classmethod
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
237 def factory(cls, plugin_info, target, profiles):
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
238 profiles = list(profiles)
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
239 if len(profiles) > 1:
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
240 raise NotImplementedError(u"Multi-profiles is not available yet for chat")
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
241 if target is None:
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
242 target = G.host.profiles[profiles[0]].whoami
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
243 return G.host.widgets.getOrCreateWidget(cls, target, on_new_widget=None, on_existing_widget=C.WIDGET_RECREATE, profiles=profiles)
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
244
109
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
245 ## header ##
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
246
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
247 def changeWidget(self, jid_):
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
248 """change current widget for a new one with given jid
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
249
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
250 @param jid_(jid.JID): jid of the widget to create
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
251 """
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
252 plugin_info = G.host.getPluginInfo(main=Chat)
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
253 factory = plugin_info['factory']
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
254 G.host.switchWidget(self, factory(plugin_info, jid_, profiles=[self.profile]))
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
255 self.header_input.text = ''
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
256
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
257 def onHeaderInput(self):
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
258 text = self.header_input.text.strip()
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
259 try:
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
260 if text.count(u'@') != 1 or text.count(u' '):
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
261 raise ValueError
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
262 jid_ = jid.JID(text)
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
263 except ValueError:
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
264 log.info(u"entered text is not a jid")
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
265 return
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
266
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
267 def discoCb(disco):
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
268 # TODO: check if plugin XEP-0045 is activated
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
269 if "conference" in [i[0] for i in disco[1]]:
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
270 G.host.bridge.mucJoin(unicode(jid_), "", "", self.profile, callback=self._mucJoinCb, errback=self._mucJoinEb)
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
271 else:
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
272 self.changeWidget(jid_)
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
273
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
274 def discoEb(failure):
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
275 log.warning(u"Disco failure, ignore this text: {}".format(failure))
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
276
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
277 G.host.bridge.discoInfos(jid_.domain, self.profile, callback=discoCb, errback=discoEb)
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
278
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
279 def onHeaderInputCompleted(self, input_wid, completed_text):
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
280 self._hi_comp_allowed = False
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
281 input_wid.text = completed_text
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
282 self._hi_comp_allowed = True
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
283 self._hi_comp_dropdown.dismiss()
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
284 self.onHeaderInput()
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
285
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
286 def onHeaderInputComplete(self, wid, text):
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
287 if not self._hi_comp_allowed:
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
288 return
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
289 text = text.lstrip()
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
290 if not text:
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
291 self._hi_comp_data = None
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
292 self._hi_comp_last = None
144
ae58f84fe4e6 plugin chat: fixed dropdown:
Goffi <goffi@goffi.org>
parents: 138
diff changeset
293 self._hi_comp_dropdown.dismiss()
109
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
294 return
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
295
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
296 profile = list(self.profiles)[0]
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
297
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
298 if self._hi_comp_data is None:
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
299 # first completion, we build the initial list
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
300 comp_data = self._hi_comp_data = []
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
301 self._hi_comp_last = ''
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
302 for jid_, jid_data in G.host.contact_lists[profile].all_iter:
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
303 comp_data.append((jid_, jid_data))
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
304 comp_data.sort(key=lambda datum: datum[0])
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
305 else:
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
306 comp_data = self._hi_comp_data
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
307
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
308 # XXX: dropdown is rebuilt each time backspace is pressed or if the text is changed,
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
309 # it works OK, but some optimisation may be done here
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
310 dropdown = self._hi_comp_dropdown
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
311
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
312 if not text.startswith(self._hi_comp_last) or not self._hi_comp_last:
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
313 # text has changed or backspace has been pressed, we restart
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
314 dropdown.clear_widgets()
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
315
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
316 for jid_, jid_data in comp_data:
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
317 nick = jid_data.get(u'nick', u'')
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
318 if text in jid_.bare or text in nick.lower():
145
654b00fa3fdc core (common): renamed JidWidget to JidItem to avoid name conflict with XMLUI
Goffi <goffi@goffi.org>
parents: 144
diff changeset
319 btn = JidItem(
109
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
320 jid = jid_.bare,
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
321 profile = profile,
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
322 size_hint = (0.5, None),
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
323 nick = nick,
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
324 on_release=lambda dummy, txt=jid_.bare: self.onHeaderInputCompleted(wid, txt)
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
325 )
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
326 dropdown.add_widget(btn)
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
327 else:
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
328 # more chars, we continue completion by removing unwanted widgets
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
329 to_remove = []
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
330 for c in dropdown.children[0].children:
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
331 if text not in c.jid and text not in (c.nick or ''):
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
332 to_remove.append(c)
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
333 for c in to_remove:
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
334 dropdown.remove_widget(c)
144
ae58f84fe4e6 plugin chat: fixed dropdown:
Goffi <goffi@goffi.org>
parents: 138
diff changeset
335 if dropdown.attach_to is None:
ae58f84fe4e6 plugin chat: fixed dropdown:
Goffi <goffi@goffi.org>
parents: 138
diff changeset
336 dropdown.open(wid)
109
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
337 self._hi_comp_last = text
7631325e11f4 chat: added completion of header's input, any entity in cache containing the entered text is shown
Goffi <goffi@goffi.org>
parents: 106
diff changeset
338
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
339 def messageDataConverter(self, idx, mess_id):
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
340 return {"mess_data": self.messages[mess_id]}
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
341
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
342 def _onHistoryPrinted(self):
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
343 """Refresh or scroll down the focus after the history is printed"""
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
344 # self.adapter.data = self.messages
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
345 for mess_data in self.messages.itervalues():
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
346 self.appendMessage(mess_data)
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
347 super(Chat, self)._onHistoryPrinted()
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
348
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
349 def createMessage(self, message):
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
350 self.appendMessage(message)
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
351
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
352 def appendMessage(self, mess_data):
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
353 self.messages_widget.add_widget(MessageWidget(mess_data=mess_data))
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
354
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
355 def onSend(self, input_widget):
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
356 G.host.messageSend(
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
357 self.target,
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
358 {'': input_widget.text}, # TODO: handle language
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
359 mess_type = C.MESS_TYPE_GROUPCHAT if self.type == C.CHAT_GROUP else C.MESS_TYPE_CHAT, # TODO: put this in QuickChat
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
360 profile_key=self.profile
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
361 )
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
362 input_widget.text = ''
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
363
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
364 def onProgressFinished(self, progress_id, metadata, profile):
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
365 try:
88
3dc526bb4a5a upload: plugin android gallery, first draft:
Goffi <goffi@goffi.org>
parents: 86
diff changeset
366 callback, cleaning_cb = self._waiting_pids.pop(progress_id)
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
367 except KeyError:
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
368 return
88
3dc526bb4a5a upload: plugin android gallery, first draft:
Goffi <goffi@goffi.org>
parents: 86
diff changeset
369 if cleaning_cb is not None:
3dc526bb4a5a upload: plugin android gallery, first draft:
Goffi <goffi@goffi.org>
parents: 86
diff changeset
370 cleaning_cb()
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
371 callback(metadata, profile)
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
372
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
373 def onProgressError(self, progress_id, err_msg, profile):
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
374 try:
88
3dc526bb4a5a upload: plugin android gallery, first draft:
Goffi <goffi@goffi.org>
parents: 86
diff changeset
375 dummy, cleaning_cb = self._waiting_pids[progress_id]
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
376 except KeyError:
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
377 return
88
3dc526bb4a5a upload: plugin android gallery, first draft:
Goffi <goffi@goffi.org>
parents: 86
diff changeset
378 else:
3dc526bb4a5a upload: plugin android gallery, first draft:
Goffi <goffi@goffi.org>
parents: 86
diff changeset
379 del self._waiting_pids[progress_id]
3dc526bb4a5a upload: plugin android gallery, first draft:
Goffi <goffi@goffi.org>
parents: 86
diff changeset
380 if cleaning_cb is not None:
3dc526bb4a5a upload: plugin android gallery, first draft:
Goffi <goffi@goffi.org>
parents: 86
diff changeset
381 cleaning_cb()
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
382 # TODO: display message to user
97
5d2289127bb7 menu (upload): better menu using dedicated widget:
Goffi <goffi@goffi.org>
parents: 90
diff changeset
383 log.warning(u"Can't transfer file: {}".format(err_msg))
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
384
97
5d2289127bb7 menu (upload): better menu using dedicated widget:
Goffi <goffi@goffi.org>
parents: 90
diff changeset
385 def fileTransferDone(self, metadata, profile):
5d2289127bb7 menu (upload): better menu using dedicated widget:
Goffi <goffi@goffi.org>
parents: 90
diff changeset
386 log.debug("file transfered: {}".format(metadata))
111
c3952922ca56 chat: uploaded images are now sent with XHTML, so they are shown inline
Goffi <goffi@goffi.org>
parents: 109
diff changeset
387 extra = {}
c3952922ca56 chat: uploaded images are now sent with XHTML, so they are shown inline
Goffi <goffi@goffi.org>
parents: 109
diff changeset
388
c3952922ca56 chat: uploaded images are now sent with XHTML, so they are shown inline
Goffi <goffi@goffi.org>
parents: 109
diff changeset
389 # FIXME: Q&D way of getting file type, upload plugins shouls give it
c3952922ca56 chat: uploaded images are now sent with XHTML, so they are shown inline
Goffi <goffi@goffi.org>
parents: 109
diff changeset
390 mime_type = mimetypes.guess_type(metadata['url'])[0]
c3952922ca56 chat: uploaded images are now sent with XHTML, so they are shown inline
Goffi <goffi@goffi.org>
parents: 109
diff changeset
391 if mime_type is not None:
c3952922ca56 chat: uploaded images are now sent with XHTML, so they are shown inline
Goffi <goffi@goffi.org>
parents: 109
diff changeset
392 if mime_type.split(u'/')[0] == 'image':
c3952922ca56 chat: uploaded images are now sent with XHTML, so they are shown inline
Goffi <goffi@goffi.org>
parents: 109
diff changeset
393 # we generate url ourselves, so this formatting is safe
c3952922ca56 chat: uploaded images are now sent with XHTML, so they are shown inline
Goffi <goffi@goffi.org>
parents: 109
diff changeset
394 extra['xhtml'] = u"<img src='{url}' />".format(**metadata)
c3952922ca56 chat: uploaded images are now sent with XHTML, so they are shown inline
Goffi <goffi@goffi.org>
parents: 109
diff changeset
395
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
396 G.host.messageSend(
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
397 self.target,
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
398 {'': metadata['url']},
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
399 mess_type = C.MESS_TYPE_GROUPCHAT if self.type == C.CHAT_GROUP else C.MESS_TYPE_CHAT,
111
c3952922ca56 chat: uploaded images are now sent with XHTML, so they are shown inline
Goffi <goffi@goffi.org>
parents: 109
diff changeset
400 extra = extra,
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
401 profile_key=profile
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
402 )
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
403
97
5d2289127bb7 menu (upload): better menu using dedicated widget:
Goffi <goffi@goffi.org>
parents: 90
diff changeset
404 def fileTransferCb(self, progress_data, cleaning_cb):
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
405 try:
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
406 progress_id = progress_data['progress']
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
407 except KeyError:
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
408 xmlui = progress_data['xmlui']
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
409 G.host.showUI(xmlui)
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
410 else:
97
5d2289127bb7 menu (upload): better menu using dedicated widget:
Goffi <goffi@goffi.org>
parents: 90
diff changeset
411 self._waiting_pids[progress_id] = (self.fileTransferDone, cleaning_cb)
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
412
98
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
413 def onTransferOK(self, file_path, cleaning_cb, transfer_type):
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
414 if transfer_type == C.TRANSFER_UPLOAD:
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
415 G.host.bridge.fileUpload(
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
416 file_path,
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
417 "",
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
418 "",
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
419 {"ignore_tls_errors": C.BOOL_TRUE}, # FIXME: should not be the default
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
420 self.profile,
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
421 callback = lambda progress_data: self.fileTransferCb(progress_data, cleaning_cb)
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
422 )
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
423 elif transfer_type == C.TRANSFER_SEND:
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
424 if self.type == C.CHAT_GROUP:
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
425 log.warning(u"P2P transfer is not possible for group chat")
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
426 # TODO: show an error dialog to user, or better hide the send button for MUC
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
427 else:
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
428 jid_ = self.target
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
429 if not jid_.resource:
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
430 jid_ = G.host.contact_lists[self.profile].getFullJid(jid_)
121
c498178d8122 chat: fixed file sending:
Goffi <goffi@goffi.org>
parents: 120
diff changeset
431 G.host.bridge.fileSend(unicode(jid_), file_path, "", "", profile=self.profile)
98
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
432 # TODO: notification of sending/failing
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
433 else:
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
434 raise log.error(u"transfer of type {} are not handled".format(transfer_type))
4d8c122b86a6 menu (upload): send transfer (i.e. P2P transfer) is now working
Goffi <goffi@goffi.org>
parents: 97
diff changeset
435
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
436
46
d6a63942d5ad chat: fixed MUC joining following changes in backend
Goffi <goffi@goffi.org>
parents: 45
diff changeset
437 def _mucJoinCb(self, joined_data):
d6a63942d5ad chat: fixed MUC joining following changes in backend
Goffi <goffi@goffi.org>
parents: 45
diff changeset
438 joined, room_jid_s, occupants, user_nick, subject, profile = joined_data
d6a63942d5ad chat: fixed MUC joining following changes in backend
Goffi <goffi@goffi.org>
parents: 45
diff changeset
439 self.host.mucRoomJoinedHandler(*joined_data[1:])
d6a63942d5ad chat: fixed MUC joining following changes in backend
Goffi <goffi@goffi.org>
parents: 45
diff changeset
440 jid_ = jid.JID(room_jid_s)
42
286865bc013a chat: joining MUC using header input is now working:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
441 self.changeWidget(jid_)
286865bc013a chat: joining MUC using header input is now working:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
442
286865bc013a chat: joining MUC using header input is now working:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
443 def _mucJoinEb(self, failure):
286865bc013a chat: joining MUC using header input is now working:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
444 log.warning(u"Can't join room: {}".format(failure))
286865bc013a chat: joining MUC using header input is now working:
Goffi <goffi@goffi.org>
parents: 41
diff changeset
445
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
446 def _onDelete(self):
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
447 self.host.removeListener('progressFinished', self.onProgressFinished)
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
448 self.host.removeListener('progressError', self.onProgressError)
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
449 return super(Chat, self).onDelete()
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
450
122
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
451 def onOTRState(self, state, dest_jid, profile):
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
452 assert profile in self.profiles
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
453 if state in OTR_STATE_ENCRYPTION:
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
454 self.otr_state_encryption = state
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
455 elif state in OTR_STATE_TRUST:
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
456 self.otr_state_trust = state
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
457 else:
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
458 log.error(_(u"Unknown OTR state received: {}".format(state)))
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
459 return
135
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
460 self.encryption_btn.symbol = self.encryption_btn.getSymbol()
091e288838e1 plugin chat: use new Symbol widget to display encryption button
Goffi <goffi@goffi.org>
parents: 126
diff changeset
461 self.encryption_btn.color = self.encryption_btn.getColor()
122
dcd6fbb3f010 chat: handle new OTR state signal and change encryption icon consequently
Goffi <goffi@goffi.org>
parents: 121
diff changeset
462
37
6cf08d0ee460 chat: forbid scrolling on X axis + don't delete widget until explicitly requested (with force attribute)
Goffi <goffi@goffi.org>
parents: 35
diff changeset
463 def onDelete(self, force=False):
6cf08d0ee460 chat: forbid scrolling on X axis + don't delete widget until explicitly requested (with force attribute)
Goffi <goffi@goffi.org>
parents: 35
diff changeset
464 if force==True:
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
465 return self._onDelete()
37
6cf08d0ee460 chat: forbid scrolling on X axis + don't delete widget until explicitly requested (with force attribute)
Goffi <goffi@goffi.org>
parents: 35
diff changeset
466 if len(list(G.host.widgets.getWidgets(self.__class__, self.target, profiles=self.profiles))) > 1:
6cf08d0ee460 chat: forbid scrolling on X axis + don't delete widget until explicitly requested (with force attribute)
Goffi <goffi@goffi.org>
parents: 35
diff changeset
467 # we don't keep duplicate widgets
78
46d962910801 chat: file upload first draft:
Goffi <goffi@goffi.org>
parents: 68
diff changeset
468 return self._onDelete()
37
6cf08d0ee460 chat: forbid scrolling on X axis + don't delete widget until explicitly requested (with force attribute)
Goffi <goffi@goffi.org>
parents: 35
diff changeset
469 return False
22
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
470
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
471
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
472 PLUGIN_INFO["factory"] = Chat.factory
74117b733bac plugin chat: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
473 quick_widgets.register(quick_chat.QuickChat, Chat)