Mercurial > libervia-backend
annotate frontends/src/wix/main_window.py @ 771:bfabeedbf32e
core: i18n refactoring:
- _() is no more installed in __builtin__
- instead, there is a new sat.core.i18n module
- added D_() method for deferred translation
- languageSwitch method allow to dynamically change translation language
- import gettext is tested against ImportError, and dummy methods are used when not available (mainly useful for Libervia)
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 29 Dec 2013 17:06:01 +0100 |
parents | 93bd868b8fb6 |
children | eac23b1aad90 |
rev | line source |
---|---|
0 | 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:
587
diff
changeset
|
4 # wix: a SAT frontend |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
diff
changeset
|
5 # Copyright (C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson (goffi@goffi.org) |
0 | 6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
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:
587
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:
587
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:
587
diff
changeset
|
10 # (at your option) any later version. |
0 | 11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
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:
587
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:
587
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:
587
diff
changeset
|
15 # GNU Affero General Public License for more details. |
0 | 16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
587
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:
587
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
0 | 19 |
20 | |
771 | 21 from sat.core.i18n import _ |
227 | 22 from sat_frontends.quick_frontend.quick_chat_list import QuickChatList |
23 from sat_frontends.quick_frontend.quick_app import QuickApp | |
0 | 24 import wx |
227 | 25 from sat_frontends.wix.contact_list import ContactList |
26 from sat_frontends.wix.chat import Chat | |
27 from sat_frontends.wix.param import Param | |
28 from sat_frontends.wix.xmlui import XMLUI | |
29 from sat_frontends.wix.gateways import GatewaysManager | |
30 from sat_frontends.wix.profile import Profile | |
31 from sat_frontends.wix.profile_manager import ProfileManager | |
0 | 32 import os.path |
225
fd9b7834d98a
distutils installation script, draft
Goffi <goffi@goffi.org>
parents:
223
diff
changeset
|
33 from sat.tools.jid import JID |
72 | 34 from logging import debug, info, warning, error |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
35 from sat_frontends.wix.constants import Const |
0 | 36 |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
37 idCONNECT,\ |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
38 idDISCONNECT,\ |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
39 idEXIT,\ |
191 | 40 idABOUT,\ |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
41 idPARAM,\ |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
42 idADD_CONTACT,\ |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
43 idREMOVE_CONTACT,\ |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
44 idSHOW_PROFILE,\ |
72 | 45 idJOIN_ROOM,\ |
191 | 46 idFIND_GATEWAYS = range(10) |
0 | 47 |
48 class ChatList(QuickChatList): | |
49 """This class manage the list of chat windows""" | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
50 |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
51 def createChat(self, target): |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
52 return Chat(target, self.host) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
53 |
0 | 54 class MainWindow(wx.Frame, QuickApp): |
55 """main app window""" | |
56 | |
57 def __init__(self): | |
366
0806a65a5fa9
wix: updated paths to use media_dir
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
58 QuickApp.__init__(self) |
68 | 59 wx.Frame.__init__(self,None, title="SàT Wix", size=(300,500)) |
0 | 60 |
68 | 61 #sizer |
62 self.sizer = wx.BoxSizer(wx.VERTICAL) | |
63 self.SetSizer(self.sizer) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
64 |
0 | 65 #Frame elements |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
491
diff
changeset
|
66 self.contact_list = ContactList(self, self) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
491
diff
changeset
|
67 self.contact_list.registerActivatedCB(self.onContactActivated) |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
491
diff
changeset
|
68 self.contact_list.Hide() |
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
491
diff
changeset
|
69 self.sizer.Add(self.contact_list, 1, flag=wx.EXPAND) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
70 |
0 | 71 self.chat_wins=ChatList(self) |
72 self.CreateStatusBar() | |
73 | |
74 #ToolBar | |
75 self.tools=self.CreateToolBar() | |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
76 self.statusBox = wx.ComboBox(self.tools, -1, "Online", choices=[status[1] for status in Const.PRESENCE], |
0 | 77 style=wx.CB_DROPDOWN | wx.CB_READONLY) |
78 self.tools.AddControl(self.statusBox) | |
79 self.tools.AddSeparator() | |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
80 self.statusTxt = wx.TextCtrl(self.tools, -1, style=wx.TE_PROCESS_ENTER) |
0 | 81 self.tools.AddControl(self.statusTxt) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
82 self.Bind(wx.EVT_COMBOBOX, self.onStatusChange, self.statusBox) |
0 | 83 self.Bind(wx.EVT_TEXT_ENTER, self.onStatusChange, self.statusTxt) |
84 self.tools.Disable() | |
366
0806a65a5fa9
wix: updated paths to use media_dir
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
85 |
11 | 86 #tray icon |
679
59c9a7ff903d
wix, misc: use picture of dimension 32x32 for tray icon + better PEP-8 compliance
souliane <souliane@mailoo.org>
parents:
653
diff
changeset
|
87 ticon = wx.Icon(os.path.join(self.media_dir, 'icons/crystal/32/tray_icon.xpm'), wx.BITMAP_TYPE_XPM) |
11 | 88 self.tray_icon = wx.TaskBarIcon() |
70 | 89 self.tray_icon.SetIcon(ticon, _("Wix jabber client")) |
11 | 90 wx.EVT_TASKBAR_LEFT_UP(self.tray_icon, self.onTrayClick) |
91 | |
0 | 92 |
93 #events | |
94 self.Bind(wx.EVT_CLOSE, self.onClose, self) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
95 |
101 | 96 #menus |
97 self.createMenus() | |
98 for i in range(self.menuBar.GetMenuCount()): | |
99 self.menuBar.EnableTop(i, False) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
100 |
68 | 101 #profile panel |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
102 self.profile_pan = ProfileManager(self) |
68 | 103 self.sizer.Add(self.profile_pan, 1, flag=wx.EXPAND) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
104 |
119
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
105
diff
changeset
|
105 self.postInit() |
ded2431cea5a
Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents:
105
diff
changeset
|
106 |
0 | 107 self.Show() |
108 | |
68 | 109 def plug_profile(self, profile_key='@DEFAULT@'): |
110 """Hide profile panel then plug profile""" | |
89
23caf1051099
multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
111 debug (_('plugin profile %s' % profile_key)) |
68 | 112 self.profile_pan.Hide() |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
491
diff
changeset
|
113 self.contact_list.Show() |
68 | 114 self.sizer.Layout() |
115 for i in range(self.menuBar.GetMenuCount()): | |
116 self.menuBar.EnableTop(i, True) | |
117 super(MainWindow, self).plug_profile(profile_key) | |
118 | |
755
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
119 def _dynamicMenuCb(self, xmlui): |
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
120 XMLUI(self, xml_data = xmlui) |
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
121 |
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
122 def _dynamicMenuEb(self, failure): |
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
123 dlg = wx.MessageDialog(self, _(u"Error while calling menu"), |
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
124 _('Error'), |
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
125 wx.OK | wx.ICON_ERROR |
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
126 ) |
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
127 dlg.ShowModal() |
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
128 dlg.Destroy() |
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
129 |
0 | 130 def createMenus(self): |
70 | 131 info(_("Creating menus")) |
0 | 132 connectMenu = wx.Menu() |
70 | 133 connectMenu.Append(idCONNECT, _("&Connect CTRL-c"),_(" Connect to the server")) |
134 connectMenu.Append(idDISCONNECT, _("&Disconnect CTRL-d"),_(" Disconnect from the server")) | |
135 connectMenu.Append(idPARAM,_("&Parameters"),_(" Configure the program")) | |
0 | 136 connectMenu.AppendSeparator() |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
137 connectMenu.Append(idABOUT, _("A&bout"), _(" About %s") % Const.APP_NAME) |
70 | 138 connectMenu.Append(idEXIT,_("E&xit"),_(" Terminate the program")) |
0 | 139 contactMenu = wx.Menu() |
70 | 140 contactMenu.Append(idADD_CONTACT, _("&Add contact"),_(" Add a contact to your list")) |
141 contactMenu.Append(idREMOVE_CONTACT, _("&Remove contact"),_(" Remove the selected contact from your list")) | |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
142 contactMenu.AppendSeparator() |
70 | 143 contactMenu.Append(idSHOW_PROFILE, _("&Show profile"), _(" Show contact's profile")) |
25
53e921c8a357
new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
144 communicationMenu = wx.Menu() |
72 | 145 communicationMenu.Append(idJOIN_ROOM, _("&Join Room"),_(" Join a Multi-User Chat room")) |
70 | 146 communicationMenu.Append(idFIND_GATEWAYS, _("&Find Gateways"),_(" Find gateways to legacy IM")) |
68 | 147 self.menuBar = wx.MenuBar() |
70 | 148 self.menuBar.Append(connectMenu,_("&General")) |
149 self.menuBar.Append(contactMenu,_("&Contacts")) | |
150 self.menuBar.Append(communicationMenu,_("&Communication")) | |
68 | 151 self.SetMenuBar(self.menuBar) |
0 | 152 |
101 | 153 #additionals menus |
154 #FIXME: do this in a more generic way (in quickapp) | |
155 add_menus = self.bridge.getMenus() | |
156 for menu in add_menus: | |
755
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
157 type_,category,name = menu |
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
158 assert(type_=="NORMAL") #TODO: manage other types |
101 | 159 menu_idx = self.menuBar.FindMenu(category) |
160 current_menu = None | |
161 if menu_idx == wx.NOT_FOUND: | |
162 #the menu is new, we create it | |
163 current_menu = wx.Menu() | |
164 self.menuBar.Append(current_menu, category) | |
165 else: | |
166 current_menu = self.menuBar.GetMenu(menu_idx) | |
167 assert(current_menu != None) | |
168 item_id = wx.NewId() | |
755
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
169 help_string = self.bridge.getMenuHelp(category, name, type_) |
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
170 current_menu.Append(item_id, name, help = help_string) |
101 | 171 #now we register the event |
172 def event_answer(e): | |
755
e3ad48a2aab2
core, frontends: callMenu is now async and don't use callback_id anymore
Goffi <goffi@goffi.org>
parents:
737
diff
changeset
|
173 self.bridge.asyncCallMenu(category, name, Const.MENU_NORMAL, self.profile, callback=self._dynamicMenuCb, errback=self._dynamicMenuEb) |
101 | 174 wx.EVT_MENU(self, item_id, event_answer) |
175 | |
176 | |
0 | 177 #events |
178 wx.EVT_MENU(self, idCONNECT, self.onConnectRequest) | |
1 | 179 wx.EVT_MENU(self, idDISCONNECT, self.onDisconnectRequest) |
0 | 180 wx.EVT_MENU(self, idPARAM, self.onParam) |
191 | 181 wx.EVT_MENU(self, idABOUT, self.onAbout) |
0 | 182 wx.EVT_MENU(self, idEXIT, self.onExit) |
183 wx.EVT_MENU(self, idADD_CONTACT, self.onAddContact) | |
184 wx.EVT_MENU(self, idREMOVE_CONTACT, self.onRemoveContact) | |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
185 wx.EVT_MENU(self, idSHOW_PROFILE, self.onShowProfile) |
72 | 186 wx.EVT_MENU(self, idJOIN_ROOM, self.onJoinRoom) |
25
53e921c8a357
new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
187 wx.EVT_MENU(self, idFIND_GATEWAYS, self.onFindGateways) |
0 | 188 |
189 | |
513
8ee9113d307b
core, quick_frontend, primitivus, wixi, bridge: fixed delayed message timestamp:
Goffi <goffi@goffi.org>
parents:
510
diff
changeset
|
190 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
|
191 QuickApp.newMessage(self, from_jid, to_jid, msg, _type, extra, profile) |
0 | 192 |
193 def showAlert(self, message): | |
194 # TODO: place this in a separate class | |
195 popup=wx.PopupWindow(self) | |
196 ### following code come from wxpython demo | |
197 popup.SetBackgroundColour("CADET BLUE") | |
198 st = wx.StaticText(popup, -1, message, pos=(10,10)) | |
199 sz = st.GetBestSize() | |
200 popup.SetSize( (sz.width+20, sz.height+20) ) | |
201 x=(wx.DisplaySize()[0]-popup.GetSize()[0])/2 | |
202 popup.SetPosition((x,0)) | |
203 popup.Show() | |
204 wx.CallLater(5000,popup.Destroy) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
205 |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
180
diff
changeset
|
206 def showDialog(self, message, title="", type="info", answer_cb = None, answer_data = None): |
0 | 207 if type == 'info': |
208 flags = wx.OK | wx.ICON_INFORMATION | |
209 elif type == 'error': | |
210 flags = wx.OK | wx.ICON_ERROR | |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
211 elif type == 'yes/no': |
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
212 flags = wx.YES_NO | wx.ICON_QUESTION |
0 | 213 else: |
214 flags = wx.OK | wx.ICON_INFORMATION | |
70 | 215 error(_('unmanaged dialog type: %s'), type) |
0 | 216 dlg = wx.MessageDialog(self, message, title, flags) |
217 answer = dlg.ShowModal() | |
218 dlg.Destroy() | |
182
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
180
diff
changeset
|
219 if answer_cb: |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
180
diff
changeset
|
220 data = [answer_data] if answer_data else [] |
556c2bd7c344
Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents:
180
diff
changeset
|
221 answer_cb(True if (answer == wx.ID_YES or answer == wx.ID_OK) else False, *data) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
222 |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
223 def setStatusOnline(self, online=True, show="", statuses={}): |
0 | 224 """enable/disable controls, must be called when local user online status change""" |
225 if online: | |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
226 self.SetStatusText(Const.msgONLINE) |
0 | 227 self.tools.Enable() |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
228 try: |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
229 presence = [x for x in Const.PRESENCE if x[0] == show][0][1] |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
230 self.statusBox.SetValue(presence) |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
231 except (TypeError, IndexError): |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
232 pass |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
233 try: |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
234 self.statusTxt.SetValue(statuses['default']) |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
235 except (TypeError, KeyError): |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
236 pass |
0 | 237 else: |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
238 self.SetStatusText(Const.msgOFFLINE) |
0 | 239 self.tools.Disable() |
240 return | |
241 | |
759
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
242 def launchAction(self, callback_id, data=None, profile_key="@NONE@"): |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
243 """ Launch a dynamic action |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
244 @param callback_id: id of the action to launch |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
245 @param data: data needed only for certain actions |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
246 @param profile_key: %(doc_profile_key)s |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
247 |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
248 """ |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
249 if data is None: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
250 data = dict() |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
251 def action_cb(data): |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
252 if not data: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
253 # action was a one shot, nothing to do |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
254 pass |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
255 elif "xmlui" in data: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
256 debug (_("XML user interface received")) |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
257 XMLUI(self, xml_data = data['xmlui']) |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
258 else: |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
259 dlg = wx.MessageDialog(self, _(u"Unmanaged action result"), |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
260 _('Error'), |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
261 wx.OK | wx.ICON_ERROR |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
262 ) |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
263 dlg.ShowModal() |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
264 dlg.Destroy() |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
265 def action_eb(failure): |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
266 dlg = wx.MessageDialog(self, unicode(failure), |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
267 _('Error'), |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
268 wx.OK | wx.ICON_ERROR |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
269 ) |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
270 dlg.ShowModal() |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
271 dlg.Destroy() |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
272 |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
273 self.bridge.launchAction(callback_id, data, profile_key, callback=action_cb, errback=action_eb) |
93bd868b8fb6
backend, frontends: callbacks refactoring:
Goffi <goffi@goffi.org>
parents:
755
diff
changeset
|
274 |
542
3eeb6c865e4d
frontends: incoming files transfer management:
Goffi <goffi@goffi.org>
parents:
538
diff
changeset
|
275 def askConfirmation(self, confirmation_id, confirmation_type, data, profile): |
0 | 276 #TODO: refactor this in QuickApp |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
277 if not self.check_profile(profile): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
278 return |
70 | 279 debug (_("Confirmation asked")) |
0 | 280 answer_data={} |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
281 if confirmation_type == "FILE_TRANSFER": |
391 | 282 debug (_("File transfer confirmation asked")) |
70 | 283 dlg = wx.MessageDialog(self, _("The contact %(jid)s wants to send you the file %(filename)s\nDo you accept ?") % {'jid':data["from"], 'filename':data["filename"]}, |
284 _('File Request'), | |
0 | 285 wx.YES_NO | wx.ICON_QUESTION |
286 ) | |
287 answer=dlg.ShowModal() | |
288 if answer==wx.ID_YES: | |
70 | 289 filename = wx.FileSelector(_("Where do you want to save the file ?"), flags = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) |
0 | 290 if filename: |
291 answer_data["dest_path"] = filename | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
292 self.bridge.confirmationAnswer(confirmation_id, True, answer_data, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
293 self.waitProgress(confirmation_id, _("File Transfer"), _("Copying %s") % os.path.basename(filename), profile) |
0 | 294 else: |
295 answer = wx.ID_NO | |
296 if answer==wx.ID_NO: | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
297 self.bridge.confirmationAnswer(confirmation_id, False, answer_data, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
298 |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
299 dlg.Destroy() |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
300 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
301 elif confirmation_type == "YES/NO": |
70 | 302 debug (_("Yes/No confirmation asked")) |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
303 dlg = wx.MessageDialog(self, data["message"], |
70 | 304 _('Confirmation'), |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
305 wx.YES_NO | wx.ICON_QUESTION |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
306 ) |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
307 answer=dlg.ShowModal() |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
308 if answer==wx.ID_YES: |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
309 self.bridge.confirmationAnswer(confirmation_id, True, {}, profile) |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
310 if answer==wx.ID_NO: |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
311 self.bridge.confirmationAnswer(confirmation_id, False, {}, profile) |
0 | 312 |
313 dlg.Destroy() | |
314 | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
315 def actionResult(self, type, id, data, profile): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
316 if not self.check_profile(profile): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
317 return |
70 | 318 debug (_("actionResult: type = [%(type)s] id = [%(id)s] data = [%(data)s]") % {'type':type, 'id':id, 'data':data}) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
319 if not id in self.current_action_ids: |
70 | 320 debug (_('unknown id, ignoring')) |
51
8c67ea98ab91
frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents:
42
diff
changeset
|
321 return |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
322 if type == "SUPPRESS": |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
323 self.current_action_ids.remove(id) |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
324 elif type == "SUCCESS": |
23
925ab466c5ec
better presentation for register new account
Goffi <goffi@goffi.org>
parents:
22
diff
changeset
|
325 self.current_action_ids.remove(id) |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
326 dlg = wx.MessageDialog(self, data["message"], |
70 | 327 _('Success'), |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
328 wx.OK | wx.ICON_INFORMATION |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
329 ) |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
330 dlg.ShowModal() |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
331 dlg.Destroy() |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
332 elif type == "ERROR": |
23
925ab466c5ec
better presentation for register new account
Goffi <goffi@goffi.org>
parents:
22
diff
changeset
|
333 self.current_action_ids.remove(id) |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
334 dlg = wx.MessageDialog(self, data["message"], |
70 | 335 _('Error'), |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
336 wx.OK | wx.ICON_ERROR |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
337 ) |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
338 dlg.ShowModal() |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
339 dlg.Destroy() |
103 | 340 elif type == "XMLUI": |
33
b9bb5d8e0cc7
In-band-registration: data form 2 xml conversion
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
341 self.current_action_ids.remove(id) |
103 | 342 debug (_("XML user interface received")) |
91 | 343 misc = {} |
344 #FIXME FIXME FIXME: must clean all this crap ! | |
345 title = _('Form') | |
346 if data['type'] == _('registration'): | |
103 | 347 title = _('Registration') |
91 | 348 misc['target'] = data['target'] |
349 misc['action_back'] = self.bridge.gatewayRegister | |
103 | 350 XMLUI(self, title=title, xml_data = data['xml'], misc = misc) |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
351 elif type == "RESULT": |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
352 self.current_action_ids.remove(id) |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
353 if self.current_action_ids_cb.has_key(id): |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
354 callback = self.current_action_ids_cb[id] |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
355 del self.current_action_ids_cb[id] |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
356 callback(data) |
25
53e921c8a357
new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
357 elif type == "DICT_DICT": |
28 | 358 self.current_action_ids.remove(id) |
359 if self.current_action_ids_cb.has_key(id): | |
360 callback = self.current_action_ids_cb[id] | |
361 del self.current_action_ids_cb[id] | |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
362 callback(data) |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
363 else: |
70 | 364 error (_("FIXME FIXME FIXME: type [%s] not implemented") % type) |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
365 raise NotImplementedError |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
366 |
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
367 |
0 | 368 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
369 def progressCB(self, progress_id, title, message, profile): |
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
370 data = self.bridge.getProgress(progress_id, profile) |
0 | 371 if data: |
372 if not self.pbar: | |
373 #first answer, we must construct the bar | |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
374 self.pbar = wx.ProgressDialog(title, message, float(data['size']), None, |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
375 wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME) |
180
fdb961f27ae9
Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents:
120
diff
changeset
|
376 self.pbar.finish_value = float(data['size']) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
377 |
0 | 378 self.pbar.Update(int(data['position'])) |
379 elif self.pbar: | |
380 self.pbar.Update(self.pbar.finish_value) | |
381 return | |
382 | |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
383 wx.CallLater(10, self.progressCB, progress_id, title, message, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
384 |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
385 def waitProgress (self, progress_id, title, message, profile): |
0 | 386 self.pbar = None |
538
2c4016921403
core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles
Goffi <goffi@goffi.org>
parents:
513
diff
changeset
|
387 wx.CallLater(10, self.progressCB, progress_id, title, message, profile) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
388 |
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
389 |
0 | 390 |
391 ### events ### | |
392 | |
393 def onContactActivated(self, jid): | |
70 | 394 debug (_("onContactActivated: %s"), jid) |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
395 if self.chat_wins[jid.bare].IsShown(): |
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
396 self.chat_wins[jid.bare].Hide() |
0 | 397 else: |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
398 self.chat_wins[jid.bare].Show() |
0 | 399 |
400 def onConnectRequest(self, e): | |
68 | 401 self.bridge.connect(self.profile) |
0 | 402 |
1 | 403 def onDisconnectRequest(self, e): |
68 | 404 self.bridge.disconnect(self.profile) |
1 | 405 |
0 | 406 def __updateStatus(self): |
737
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
407 show = [x for x in Const.PRESENCE if x[1] == self.statusBox.GetValue()][0][0] |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
408 status = self.statusTxt.GetValue() |
378af36155c2
frontends: set and retrieve your own presence and status
souliane <souliane@mailoo.org>
parents:
736
diff
changeset
|
409 self.bridge.setPresence(show=show, statuses={'default': status}, profile_key=self.profile) #FIXME: manage multilingual statuses |
0 | 410 |
411 def onStatusChange(self, e): | |
70 | 412 debug(_("Status change request")) |
0 | 413 self.__updateStatus() |
414 | |
415 def onParam(self, e): | |
70 | 416 debug(_("Param request")) |
641
49587e170f53
core: added the security_limit to setParam
souliane <souliane@mailoo.org>
parents:
634
diff
changeset
|
417 #xmlui = self.bridge.getParamsUI(profile_key=self.profile) |
105 | 418 #XMLUI(self, xml_data = xmlui) |
22
bb72c29f3432
added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents:
18
diff
changeset
|
419 param=Param(self) |
0 | 420 |
191 | 421 def onAbout(self, e): |
422 about = wx.AboutDialogInfo() | |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
423 about.SetName(Const.APP_NAME) |
191 | 424 about.SetVersion (unicode(self.bridge.getVersion())) |
572 | 425 about.SetCopyright(u"(C) 2009, 2010, 2011, 2012, 2013 Jérôme Poisson aka Goffi") |
191 | 426 about.SetDescription( _(u"%(name)s is a SàT (Salut à Toi) frontend\n"+ |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
427 u"%(name)s is based on WxPython, and is the standard graphic interface of SàT") % {'name': Const.APP_NAME}) |
191 | 428 about.SetWebSite(("http://www.goffi.org", "Goffi's non-hebdo (french)")) |
429 about.SetDevelopers([ "Goffi (Jérôme Poisson)"]) | |
430 try: | |
736
6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
souliane <souliane@mailoo.org>
parents:
688
diff
changeset
|
431 with open(Const.LICENCE_PATH, "r") as licence: |
191 | 432 about.SetLicence(''.join(licence.readlines())) |
433 except: | |
434 pass | |
435 | |
436 wx.AboutBox(about) | |
437 | |
0 | 438 def onExit(self, e): |
439 self.Close() | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
440 |
0 | 441 def onAddContact(self, e): |
70 | 442 debug(_("Add contact request")) |
0 | 443 dlg = wx.TextEntryDialog( |
70 | 444 self, _('Please enter new contact JID'), |
445 _('Adding a contact'), _('name@server.tld')) | |
0 | 446 |
447 if dlg.ShowModal() == wx.ID_OK: | |
448 jid=JID(dlg.GetValue()) | |
449 if jid.is_valid(): | |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
450 self.bridge.addContact(jid.bare, profile_key=self.profile) |
0 | 451 else: |
70 | 452 error (_("'%s' is an invalid JID !"), jid) |
0 | 453 #TODO: notice the user |
454 | |
455 dlg.Destroy() | |
456 | |
457 def onRemoveContact(self, e): | |
70 | 458 debug(_("Remove contact request")) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
491
diff
changeset
|
459 target = self.contact_list.getSelection() |
0 | 460 if not target: |
70 | 461 dlg = wx.MessageDialog(self, _("You haven't selected any contact !"), |
462 _('Error'), | |
0 | 463 wx.OK | wx.ICON_ERROR |
464 ) | |
465 dlg.ShowModal() | |
466 dlg.Destroy() | |
467 return | |
468 | |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
469 dlg = wx.MessageDialog(self, _("Are you sure you want to delete %s from your roster list ?") % target.bare, |
70 | 470 _('Contact suppression'), |
0 | 471 wx.YES_NO | wx.ICON_QUESTION |
472 ) | |
473 | |
474 if dlg.ShowModal() == wx.ID_YES: | |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
475 info(_("Unsubscribing %s presence"), target.bare) |
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
476 self.bridge.delContact(target.bare, profile_key=self.profile) |
0 | 477 |
478 dlg.Destroy() | |
479 | |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
480 def onShowProfile(self, e): |
70 | 481 debug(_("Show contact's profile request")) |
501
e9634d2e7b38
core, quick_frontend, primitivus, wix: Contacts List refactoring phase 1:
Goffi <goffi@goffi.org>
parents:
491
diff
changeset
|
482 target = self.contact_list.getSelection() |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
483 if not target: |
70 | 484 dlg = wx.MessageDialog(self, _("You haven't selected any contact !"), |
485 _('Error'), | |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
486 wx.OK | wx.ICON_ERROR |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
487 ) |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
488 dlg.ShowModal() |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
489 dlg.Destroy() |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
490 return |
688
f7878ad3c846
tools: renamed tools.jid.JID attribute "short" to "bare"
souliane <souliane@mailoo.org>
parents:
679
diff
changeset
|
491 _id = self.bridge.getCard(target.bare, profile_key=self.profile) |
491
1e4731f1e1d7
wix: renamed id variable to avoid reserved name
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
492 self.current_action_ids.add(_id) |
1e4731f1e1d7
wix: renamed id variable to avoid reserved name
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
493 self.current_action_ids_cb[_id] = self.onProfileReceived |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
494 |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
495 def onProfileReceived(self, data): |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
496 """Called when a profile is received""" |
70 | 497 debug (_('Profile received: [%s]') % data) |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
498 profile=Profile(self, data) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
499 |
72 | 500 def onJoinRoom(self, e): |
501 warning('FIXME: temporary menu, must be improved') | |
80
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
502 #TODO: a proper MUC room joining dialog with nickname etc |
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
503 dlg = wx.TextEntryDialog( |
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
504 self, _("Please enter MUC's JID"), |
204 | 505 #_('Entering a MUC room'), 'test@conference.necton2.int') |
506 _('Entering a MUC room'), 'room@muc_service.server.tld') | |
80
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
507 if dlg.ShowModal() == wx.ID_OK: |
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
508 room_jid=JID(dlg.GetValue()) |
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
509 if room_jid.is_valid(): |
405
10b4f577d0c0
MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents:
391
diff
changeset
|
510 self.bridge.joinMUC(room_jid, self.profiles[self.profile]['whoami'].node, {}, self.profile) |
80
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
511 else: |
9681f18d06bd
wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
512 error (_("'%s' is an invalid JID !"), room_jid) |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
513 |
25
53e921c8a357
new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
514 def onFindGateways(self, e): |
70 | 515 debug(_("Find Gateways request")) |
491
1e4731f1e1d7
wix: renamed id variable to avoid reserved name
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
516 _id = self.bridge.findGateways(self.profiles[self.profile]['whoami'].domain, self.profile) |
1e4731f1e1d7
wix: renamed id variable to avoid reserved name
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
517 self.current_action_ids.add(_id) |
1e4731f1e1d7
wix: renamed id variable to avoid reserved name
Goffi <goffi@goffi.org>
parents:
480
diff
changeset
|
518 self.current_action_ids_cb[_id] = self.onGatewaysFound |
28 | 519 |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
520 def onGatewaysFound(self, data): |
28 | 521 """Called when SàT has found the server gateways""" |
42
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
522 target = data['__private__']['target'] |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
523 del data['__private__'] |
874de3020e1c
Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
524 gatewayManager = GatewaysManager(self, data, server=target) |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
525 |
0 | 526 def onClose(self, e): |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
527 QuickApp.onExit(self) |
70 | 528 info(_("Exiting...")) |
183
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
529 for win in self.chat_wins: |
9ee4a1d0d7fb
Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents:
182
diff
changeset
|
530 self.chat_wins[win].Destroy() |
628
42ee0b0b0a15
wix: fixed application quitting (fix bug 25)
Goffi <goffi@goffi.org>
parents:
609
diff
changeset
|
531 self.tray_icon.Destroy() |
0 | 532 e.Skip() |
11 | 533 |
534 def onTrayClick(self, e): | |
70 | 535 debug(_("Tray Click")) |
11 | 536 if self.IsShown(): |
537 self.Hide() | |
538 else: | |
539 self.Show() | |
540 self.Raise() | |
541 e.Skip() | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
542 |
653
e2eff3c7ad02
wix: bug fix at startup when the method chatStateReceived doesn't exist
souliane <souliane@mailoo.org>
parents:
641
diff
changeset
|
543 def chatStateReceived(self, from_jid_s, state, profile): |
e2eff3c7ad02
wix: bug fix at startup when the method chatStateReceived doesn't exist
souliane <souliane@mailoo.org>
parents:
641
diff
changeset
|
544 """Signal observer to display a contact chat state |
e2eff3c7ad02
wix: bug fix at startup when the method chatStateReceived doesn't exist
souliane <souliane@mailoo.org>
parents:
641
diff
changeset
|
545 @param from_jid_s: contact who sent his new state |
e2eff3c7ad02
wix: bug fix at startup when the method chatStateReceived doesn't exist
souliane <souliane@mailoo.org>
parents:
641
diff
changeset
|
546 @state: state |
e2eff3c7ad02
wix: bug fix at startup when the method chatStateReceived doesn't exist
souliane <souliane@mailoo.org>
parents:
641
diff
changeset
|
547 @profile: current profile |
e2eff3c7ad02
wix: bug fix at startup when the method chatStateReceived doesn't exist
souliane <souliane@mailoo.org>
parents:
641
diff
changeset
|
548 """ |
e2eff3c7ad02
wix: bug fix at startup when the method chatStateReceived doesn't exist
souliane <souliane@mailoo.org>
parents:
641
diff
changeset
|
549 print "TODO: chatStateReceived not implemented yet" |
e2eff3c7ad02
wix: bug fix at startup when the method chatStateReceived doesn't exist
souliane <souliane@mailoo.org>
parents:
641
diff
changeset
|
550 pass |