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