annotate frontends/wix/main_window.py @ 42:874de3020e1c

Initial VCard (XEP-0054) support + misc fixes - new xep-0054 plugin, avatar are cached, new getProfile bridge method - gateways plugin (XEP-0100): new __private__ key in resulting data, used to keep target jid
author Goffi <goffi@goffi.org>
date Mon, 21 Dec 2009 13:22:11 +1100
parents 3e24753b9e0b
children 8c67ea98ab91
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
goffi@necton2
parents:
diff changeset
1 #!/usr/bin/python
goffi@necton2
parents:
diff changeset
2 # -*- coding: utf-8 -*-
goffi@necton2
parents:
diff changeset
3
goffi@necton2
parents:
diff changeset
4 """
goffi@necton2
parents:
diff changeset
5 wix: a SAT frontend
goffi@necton2
parents:
diff changeset
6 Copyright (C) 2009 Jérôme Poisson (goffi@goffi.org)
goffi@necton2
parents:
diff changeset
7
goffi@necton2
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
goffi@necton2
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
goffi@necton2
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
goffi@necton2
parents:
diff changeset
11 (at your option) any later version.
goffi@necton2
parents:
diff changeset
12
goffi@necton2
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
goffi@necton2
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
goffi@necton2
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
goffi@necton2
parents:
diff changeset
16 GNU General Public License for more details.
goffi@necton2
parents:
diff changeset
17
goffi@necton2
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
goffi@necton2
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
goffi@necton2
parents:
diff changeset
20 """
goffi@necton2
parents:
diff changeset
21
goffi@necton2
parents:
diff changeset
22
goffi@necton2
parents:
diff changeset
23 import wx
goffi@necton2
parents:
diff changeset
24 from chat import Chat
goffi@necton2
parents:
diff changeset
25 from param import Param
35
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents: 33
diff changeset
26 from form import Form
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
27 from gateways import GatewaysManager
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
28 from profile import Profile
0
goffi@necton2
parents:
diff changeset
29 import gobject
goffi@necton2
parents:
diff changeset
30 import os.path
goffi@necton2
parents:
diff changeset
31 import pdb
goffi@necton2
parents:
diff changeset
32 from tools.jid import JID
goffi@necton2
parents:
diff changeset
33 from logging import debug, info, error
goffi@necton2
parents:
diff changeset
34 from quick_frontend.quick_chat_list import QuickChatList
goffi@necton2
parents:
diff changeset
35 from quick_frontend.quick_contact_list import QuickContactList
goffi@necton2
parents:
diff changeset
36 from quick_frontend.quick_app import QuickApp
goffi@necton2
parents:
diff changeset
37
goffi@necton2
parents:
diff changeset
38
goffi@necton2
parents:
diff changeset
39 msgOFFLINE = "offline"
goffi@necton2
parents:
diff changeset
40 msgONLINE = "online"
goffi@necton2
parents:
diff changeset
41 idCONNECT = 1
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
42 idDISCONNECT = 2
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
43 idEXIT = 3
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
44 idPARAM = 4
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
45 idADD_CONTACT = 5
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
46 idREMOVE_CONTACT = 6
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
47 idSHOW_PROFILE = 7
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
48 idFIND_GATEWAYS = 8
0
goffi@necton2
parents:
diff changeset
49 const_DEFAULT_GROUP = "Unclassed"
goffi@necton2
parents:
diff changeset
50 const_STATUS = {"Online":"",
goffi@necton2
parents:
diff changeset
51 "Want to discuss":"chat",
goffi@necton2
parents:
diff changeset
52 "AFK":"away",
goffi@necton2
parents:
diff changeset
53 "Do Not Disturb":"dnd",
goffi@necton2
parents:
diff changeset
54 "Away":"xa"}
goffi@necton2
parents:
diff changeset
55
goffi@necton2
parents:
diff changeset
56 class ChatList(QuickChatList):
goffi@necton2
parents:
diff changeset
57 """This class manage the list of chat windows"""
goffi@necton2
parents:
diff changeset
58
goffi@necton2
parents:
diff changeset
59 def __init__(self, host):
goffi@necton2
parents:
diff changeset
60 QuickChatList.__init__(self, host)
goffi@necton2
parents:
diff changeset
61
goffi@necton2
parents:
diff changeset
62 def createChat(self, name):
goffi@necton2
parents:
diff changeset
63 return Chat(name, self.host)
goffi@necton2
parents:
diff changeset
64
goffi@necton2
parents:
diff changeset
65
goffi@necton2
parents:
diff changeset
66
goffi@necton2
parents:
diff changeset
67 class ContactList(wx.TreeCtrl, QuickContactList):
goffi@necton2
parents:
diff changeset
68 """Customized control to manage contacts."""
goffi@necton2
parents:
diff changeset
69
goffi@necton2
parents:
diff changeset
70 def __init__(self, parent):
goffi@necton2
parents:
diff changeset
71 wx.TreeCtrl.__init__(self, parent, style = wx.TR_HIDE_ROOT | wx.TR_HAS_BUTTONS)
goffi@necton2
parents:
diff changeset
72 QuickContactList.__init__(self)
goffi@necton2
parents:
diff changeset
73 self.jid_ids={}
goffi@necton2
parents:
diff changeset
74 self.groups={}
goffi@necton2
parents:
diff changeset
75 self.root=self.AddRoot("")
goffi@necton2
parents:
diff changeset
76 self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.onActivated, self)
goffi@necton2
parents:
diff changeset
77
goffi@necton2
parents:
diff changeset
78 #icons
goffi@necton2
parents:
diff changeset
79 isz = (16,16)
goffi@necton2
parents:
diff changeset
80 il = wx.ImageList(isz[0], isz[1])
goffi@necton2
parents:
diff changeset
81 self.icon_online = il.Add(wx.ArtProvider_GetBitmap(wx.ART_TICK_MARK, wx.ART_OTHER, isz))
goffi@necton2
parents:
diff changeset
82 self.icon_unavailable = il.Add(wx.ArtProvider_GetBitmap(wx.ART_CROSS_MARK, wx.ART_OTHER, isz))
goffi@necton2
parents:
diff changeset
83 self.AssignImageList(il)
goffi@necton2
parents:
diff changeset
84
goffi@necton2
parents:
diff changeset
85 self.__addNode(const_DEFAULT_GROUP)
goffi@necton2
parents:
diff changeset
86
goffi@necton2
parents:
diff changeset
87 def __addNode(self, label):
goffi@necton2
parents:
diff changeset
88 """Add an item container"""
goffi@necton2
parents:
diff changeset
89 ret=self.AppendItem(self.root, label)
goffi@necton2
parents:
diff changeset
90 self.SetPyData(ret, "[node]")
goffi@necton2
parents:
diff changeset
91 self.SetItemBold(ret)
goffi@necton2
parents:
diff changeset
92 self.groups[label]=ret
goffi@necton2
parents:
diff changeset
93
goffi@necton2
parents:
diff changeset
94 def replace(self, jid, name="", show="", status="", group=""):
goffi@necton2
parents:
diff changeset
95 debug("status = %s show = %s",status, show)
goffi@necton2
parents:
diff changeset
96 if not self.jid_ids.has_key(jid):
goffi@necton2
parents:
diff changeset
97 self.add(jid, name, show, status, group)
goffi@necton2
parents:
diff changeset
98 else:
goffi@necton2
parents:
diff changeset
99 debug ("updating %s",jid)
goffi@necton2
parents:
diff changeset
100 self.__presentItem(jid, name, show, status, group)
goffi@necton2
parents:
diff changeset
101
goffi@necton2
parents:
diff changeset
102 def __presentItem(self, jid, name, show, status, group):
goffi@necton2
parents:
diff changeset
103 """Make a nice presentation of the contact in the list."""
goffi@necton2
parents:
diff changeset
104 id=self.jid_ids[jid]
goffi@necton2
parents:
diff changeset
105 label= "%s [%s] \n %s" % ((name or jid), (show or "online"), status)
goffi@necton2
parents:
diff changeset
106 self.SetItemText(id, label)
goffi@necton2
parents:
diff changeset
107
goffi@necton2
parents:
diff changeset
108 # icon
goffi@necton2
parents:
diff changeset
109 if not show or show=="chat":
goffi@necton2
parents:
diff changeset
110 self.SetItemImage(id, self.icon_online)
goffi@necton2
parents:
diff changeset
111 else:
goffi@necton2
parents:
diff changeset
112 self.SetItemImage(id, self.icon_unavailable)
goffi@necton2
parents:
diff changeset
113
goffi@necton2
parents:
diff changeset
114 #colour
goffi@necton2
parents:
diff changeset
115 if not show:
goffi@necton2
parents:
diff changeset
116 self.SetItemTextColour(id, wx.BLACK)
goffi@necton2
parents:
diff changeset
117 elif show=="chat":
goffi@necton2
parents:
diff changeset
118 self.SetItemTextColour(id, wx.GREEN)
goffi@necton2
parents:
diff changeset
119 elif show=="away":
goffi@necton2
parents:
diff changeset
120 self.SetItemTextColour(id, wx.BLUE)
goffi@necton2
parents:
diff changeset
121 else:
goffi@necton2
parents:
diff changeset
122 self.SetItemTextColour(id, wx.RED)
goffi@necton2
parents:
diff changeset
123
goffi@necton2
parents:
diff changeset
124 def add(self, jid, name="", show="", status="", group=""):
goffi@necton2
parents:
diff changeset
125 """add a contact to the list"""
goffi@necton2
parents:
diff changeset
126 debug ("adding %s",jid)
goffi@necton2
parents:
diff changeset
127 dest_group=group or const_DEFAULT_GROUP
goffi@necton2
parents:
diff changeset
128 if not self.groups.has_key(dest_group):
goffi@necton2
parents:
diff changeset
129 self.__addNode(dest_group)
goffi@necton2
parents:
diff changeset
130 self.jid_ids[jid]=self.AppendItem(self.groups[dest_group], "")
goffi@necton2
parents:
diff changeset
131 self.__presentItem(jid, name, show, status, group)
goffi@necton2
parents:
diff changeset
132 self.SetPyData(self.jid_ids[jid], "[contact]"+jid)
goffi@necton2
parents:
diff changeset
133 self.EnsureVisible(self.jid_ids[jid])
goffi@necton2
parents:
diff changeset
134 self.Refresh() #FIXME: Best way ?
goffi@necton2
parents:
diff changeset
135
goffi@necton2
parents:
diff changeset
136 def remove(self, jid):
goffi@necton2
parents:
diff changeset
137 """remove a contact from the list"""
goffi@necton2
parents:
diff changeset
138 debug ("removing %s",jid)
goffi@necton2
parents:
diff changeset
139 self.Delete(self.jid_ids[jid])
goffi@necton2
parents:
diff changeset
140 del self.jid_ids[jid]
goffi@necton2
parents:
diff changeset
141 self.Refresh() #FIXME: Best way ?
goffi@necton2
parents:
diff changeset
142
goffi@necton2
parents:
diff changeset
143 def onActivated(self, event):
goffi@necton2
parents:
diff changeset
144 """Called when a contact is clicked or activated with keyboard."""
goffi@necton2
parents:
diff changeset
145 if self.GetPyData(event.GetItem()).startswith("[contact]"):
goffi@necton2
parents:
diff changeset
146 self.onActivatedCB(self.GetPyData(event.GetItem())[9:])
goffi@necton2
parents:
diff changeset
147 else:
goffi@necton2
parents:
diff changeset
148 event.Skip()
goffi@necton2
parents:
diff changeset
149
goffi@necton2
parents:
diff changeset
150 def getSelection(self):
goffi@necton2
parents:
diff changeset
151 """Return the selected contact, or an empty string if there is not"""
goffi@necton2
parents:
diff changeset
152 data = self.GetPyData(self.GetSelection())
goffi@necton2
parents:
diff changeset
153 if not data or not data.startswith("[contact]"):
goffi@necton2
parents:
diff changeset
154 return ""
goffi@necton2
parents:
diff changeset
155 return JID(data[9:])
goffi@necton2
parents:
diff changeset
156
goffi@necton2
parents:
diff changeset
157 def registerActivatedCB(self, cb):
goffi@necton2
parents:
diff changeset
158 """Register a callback with manage contact activation."""
goffi@necton2
parents:
diff changeset
159 self.onActivatedCB=cb
goffi@necton2
parents:
diff changeset
160
goffi@necton2
parents:
diff changeset
161 class MainWindow(wx.Frame, QuickApp):
goffi@necton2
parents:
diff changeset
162 """main app window"""
goffi@necton2
parents:
diff changeset
163
goffi@necton2
parents:
diff changeset
164 def __init__(self):
goffi@necton2
parents:
diff changeset
165 wx.Frame.__init__(self,None, title="SAT Wix", size=(400,200))
goffi@necton2
parents:
diff changeset
166
goffi@necton2
parents:
diff changeset
167
goffi@necton2
parents:
diff changeset
168 #Frame elements
goffi@necton2
parents:
diff changeset
169 self.contactList = ContactList(self)
goffi@necton2
parents:
diff changeset
170 self.contactList.registerActivatedCB(self.onContactActivated)
goffi@necton2
parents:
diff changeset
171 self.chat_wins=ChatList(self)
goffi@necton2
parents:
diff changeset
172 self.CreateStatusBar()
goffi@necton2
parents:
diff changeset
173 self.SetStatusText(msgOFFLINE)
goffi@necton2
parents:
diff changeset
174 self.createMenus()
goffi@necton2
parents:
diff changeset
175
goffi@necton2
parents:
diff changeset
176 #ToolBar
goffi@necton2
parents:
diff changeset
177 self.tools=self.CreateToolBar()
goffi@necton2
parents:
diff changeset
178 self.statusBox = wx.ComboBox(self.tools, -1, "Online", choices=const_STATUS.keys(),
goffi@necton2
parents:
diff changeset
179 style=wx.CB_DROPDOWN | wx.CB_READONLY)
goffi@necton2
parents:
diff changeset
180 self.tools.AddControl(self.statusBox)
goffi@necton2
parents:
diff changeset
181 self.tools.AddSeparator()
goffi@necton2
parents:
diff changeset
182 self.statusTxt=wx.TextCtrl(self.tools, -1, style = wx.TE_PROCESS_ENTER)
goffi@necton2
parents:
diff changeset
183 self.tools.AddControl(self.statusTxt)
goffi@necton2
parents:
diff changeset
184 self.Bind(wx.EVT_COMBOBOX, self.onStatusChange, self.statusBox)
goffi@necton2
parents:
diff changeset
185 self.Bind(wx.EVT_TEXT_ENTER, self.onStatusChange, self.statusTxt)
goffi@necton2
parents:
diff changeset
186 self.tools.Disable()
11
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
187
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
188 #tray icon
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
189 ticon = wx.Icon("images/tray_icon.xpm", wx.BITMAP_TYPE_XPM)
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
190 self.tray_icon = wx.TaskBarIcon()
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
191 self.tray_icon.SetIcon(ticon, "Wix jabber client")
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
192 wx.EVT_TASKBAR_LEFT_UP(self.tray_icon, self.onTrayClick)
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
193
0
goffi@necton2
parents:
diff changeset
194
goffi@necton2
parents:
diff changeset
195 #events
goffi@necton2
parents:
diff changeset
196 self.Bind(wx.EVT_CLOSE, self.onClose, self)
goffi@necton2
parents:
diff changeset
197
goffi@necton2
parents:
diff changeset
198 QuickApp.__init__(self)
goffi@necton2
parents:
diff changeset
199
goffi@necton2
parents:
diff changeset
200 self.Show()
goffi@necton2
parents:
diff changeset
201
goffi@necton2
parents:
diff changeset
202 def createMenus(self):
goffi@necton2
parents:
diff changeset
203 info("Creating menus")
goffi@necton2
parents:
diff changeset
204 connectMenu = wx.Menu()
goffi@necton2
parents:
diff changeset
205 connectMenu.Append(idCONNECT, "&Connect CTRL-c"," Connect to the server")
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
206 connectMenu.Append(idDISCONNECT, "&Disconnect CTRL-d"," Disconnect from the server")
0
goffi@necton2
parents:
diff changeset
207 connectMenu.Append(idPARAM,"&Parameters"," Configure the program")
goffi@necton2
parents:
diff changeset
208 connectMenu.AppendSeparator()
goffi@necton2
parents:
diff changeset
209 connectMenu.Append(idEXIT,"E&xit"," Terminate the program")
goffi@necton2
parents:
diff changeset
210 contactMenu = wx.Menu()
goffi@necton2
parents:
diff changeset
211 contactMenu.Append(idADD_CONTACT, "&Add contact"," Add a contact to your list")
goffi@necton2
parents:
diff changeset
212 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
213 contactMenu.AppendSeparator()
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
214 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
215 communicationMenu = wx.Menu()
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
216 communicationMenu.Append(idFIND_GATEWAYS, "&Find Gateways"," Find gateways to legacy IM")
0
goffi@necton2
parents:
diff changeset
217 menuBar = wx.MenuBar()
goffi@necton2
parents:
diff changeset
218 menuBar.Append(connectMenu,"&General")
goffi@necton2
parents:
diff changeset
219 menuBar.Append(contactMenu,"&Contacts")
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
220 menuBar.Append(communicationMenu,"&Communication")
0
goffi@necton2
parents:
diff changeset
221 self.SetMenuBar(menuBar)
goffi@necton2
parents:
diff changeset
222
goffi@necton2
parents:
diff changeset
223 #events
goffi@necton2
parents:
diff changeset
224 wx.EVT_MENU(self, idCONNECT, self.onConnectRequest)
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
225 wx.EVT_MENU(self, idDISCONNECT, self.onDisconnectRequest)
0
goffi@necton2
parents:
diff changeset
226 wx.EVT_MENU(self, idPARAM, self.onParam)
goffi@necton2
parents:
diff changeset
227 wx.EVT_MENU(self, idEXIT, self.onExit)
goffi@necton2
parents:
diff changeset
228 wx.EVT_MENU(self, idADD_CONTACT, self.onAddContact)
goffi@necton2
parents:
diff changeset
229 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
230 wx.EVT_MENU(self, idSHOW_PROFILE, self.onShowProfile)
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
231 wx.EVT_MENU(self, idFIND_GATEWAYS, self.onFindGateways)
0
goffi@necton2
parents:
diff changeset
232
goffi@necton2
parents:
diff changeset
233
goffi@necton2
parents:
diff changeset
234 def newMessage(self, from_jid, msg, type, to_jid):
goffi@necton2
parents:
diff changeset
235 QuickApp.newMessage(self, from_jid, msg, type, to_jid)
goffi@necton2
parents:
diff changeset
236
goffi@necton2
parents:
diff changeset
237 def showAlert(self, message):
goffi@necton2
parents:
diff changeset
238 # TODO: place this in a separate class
goffi@necton2
parents:
diff changeset
239 popup=wx.PopupWindow(self)
goffi@necton2
parents:
diff changeset
240 ### following code come from wxpython demo
goffi@necton2
parents:
diff changeset
241 popup.SetBackgroundColour("CADET BLUE")
goffi@necton2
parents:
diff changeset
242 st = wx.StaticText(popup, -1, message, pos=(10,10))
goffi@necton2
parents:
diff changeset
243 sz = st.GetBestSize()
goffi@necton2
parents:
diff changeset
244 popup.SetSize( (sz.width+20, sz.height+20) )
goffi@necton2
parents:
diff changeset
245 x=(wx.DisplaySize()[0]-popup.GetSize()[0])/2
goffi@necton2
parents:
diff changeset
246 popup.SetPosition((x,0))
goffi@necton2
parents:
diff changeset
247 popup.Show()
goffi@necton2
parents:
diff changeset
248 wx.CallLater(5000,popup.Destroy)
goffi@necton2
parents:
diff changeset
249
goffi@necton2
parents:
diff changeset
250 def showDialog(self, message, title="", type="info"):
goffi@necton2
parents:
diff changeset
251 if type == 'info':
goffi@necton2
parents:
diff changeset
252 flags = wx.OK | wx.ICON_INFORMATION
goffi@necton2
parents:
diff changeset
253 elif type == 'error':
goffi@necton2
parents:
diff changeset
254 flags = wx.OK | wx.ICON_ERROR
goffi@necton2
parents:
diff changeset
255 elif type == 'question':
goffi@necton2
parents:
diff changeset
256 flags = wx.OK | wx.ICON_QUESTION
goffi@necton2
parents:
diff changeset
257 else:
goffi@necton2
parents:
diff changeset
258 flags = wx.OK | wx.ICON_INFORMATION
goffi@necton2
parents:
diff changeset
259 dlg = wx.MessageDialog(self, message, title, flags)
goffi@necton2
parents:
diff changeset
260 answer = dlg.ShowModal()
goffi@necton2
parents:
diff changeset
261 dlg.Destroy()
goffi@necton2
parents:
diff changeset
262 return True if (answer == wx.ID_YES or answer == wx.ID_OK) else False
goffi@necton2
parents:
diff changeset
263
goffi@necton2
parents:
diff changeset
264 def setStatusOnline(self, online=True):
goffi@necton2
parents:
diff changeset
265 """enable/disable controls, must be called when local user online status change"""
goffi@necton2
parents:
diff changeset
266 if online:
goffi@necton2
parents:
diff changeset
267 self.SetStatusText(msgONLINE)
goffi@necton2
parents:
diff changeset
268 self.tools.Enable()
goffi@necton2
parents:
diff changeset
269 else:
goffi@necton2
parents:
diff changeset
270 self.SetStatusText(msgOFFLINE)
goffi@necton2
parents:
diff changeset
271 self.tools.Disable()
goffi@necton2
parents:
diff changeset
272 return
goffi@necton2
parents:
diff changeset
273
goffi@necton2
parents:
diff changeset
274
goffi@necton2
parents:
diff changeset
275 def presenceUpdate(self, jabber_id, type, show, status, priority):
goffi@necton2
parents:
diff changeset
276 QuickApp.presenceUpdate(self, jabber_id, type, show, status, priority)
goffi@necton2
parents:
diff changeset
277
goffi@necton2
parents:
diff changeset
278 def askConfirmation(self, type, id, data):
goffi@necton2
parents:
diff changeset
279 #TODO: refactor this in QuickApp
goffi@necton2
parents:
diff changeset
280 debug ("Confirmation asked")
goffi@necton2
parents:
diff changeset
281 answer_data={}
goffi@necton2
parents:
diff changeset
282 if type == "FILE_TRANSFERT":
goffi@necton2
parents:
diff changeset
283 debug ("File transfert confirmation asked")
goffi@necton2
parents:
diff changeset
284 dlg = wx.MessageDialog(self, "The contact %s wants to send you the file %s\nDo you accept ?" % (data["from"], data["filename"]),
goffi@necton2
parents:
diff changeset
285 'File Request',
goffi@necton2
parents:
diff changeset
286 wx.YES_NO | wx.ICON_QUESTION
goffi@necton2
parents:
diff changeset
287 )
goffi@necton2
parents:
diff changeset
288 answer=dlg.ShowModal()
goffi@necton2
parents:
diff changeset
289 if answer==wx.ID_YES:
goffi@necton2
parents:
diff changeset
290 filename = wx.FileSelector("Where do you want to save the file ?", flags = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
goffi@necton2
parents:
diff changeset
291 if filename:
goffi@necton2
parents:
diff changeset
292 answer_data["dest_path"] = filename
goffi@necton2
parents:
diff changeset
293 self.bridge.confirmationAnswer(id, True, answer_data)
goffi@necton2
parents:
diff changeset
294 self.waitProgress(id, "File Transfer", "Copying %s" % os.path.basename(filename))
goffi@necton2
parents:
diff changeset
295 else:
goffi@necton2
parents:
diff changeset
296 answer = wx.ID_NO
goffi@necton2
parents:
diff changeset
297 if answer==wx.ID_NO:
goffi@necton2
parents:
diff changeset
298 self.bridge.confirmationAnswer(id, False, answer_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
299
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
300 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
301
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
302 elif type == "YES/NO":
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
303 debug ("Yes/No confirmation asked")
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
304 dlg = wx.MessageDialog(self, data["message"],
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
305 'Confirmation',
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
306 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
307 )
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
308 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
309 if answer==wx.ID_YES:
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
310 self.bridge.confirmationAnswer(id, True, {})
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
311 if answer==wx.ID_NO:
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
312 self.bridge.confirmationAnswer(id, False, {})
0
goffi@necton2
parents:
diff changeset
313
goffi@necton2
parents:
diff changeset
314 dlg.Destroy()
goffi@necton2
parents:
diff changeset
315
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
316 def actionResult(self, type, id, data):
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
317 debug ("actionResult: type = [%s] id = [%s] data = [%s]" % (type, id, 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
318 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
319 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
320 elif type == "SUCCESS":
23
925ab466c5ec better presentation for register new account
Goffi <goffi@goffi.org>
parents: 22
diff changeset
321 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
322 dlg = wx.MessageDialog(self, data["message"],
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
323 'Success',
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
324 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
325 )
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.ShowModal()
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
327 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
328 elif type == "ERROR":
23
925ab466c5ec better presentation for register new account
Goffi <goffi@goffi.org>
parents: 22
diff changeset
329 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
330 dlg = wx.MessageDialog(self, data["message"],
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
331 'Error',
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
332 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
333 )
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.ShowModal()
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
335 dlg.Destroy()
33
b9bb5d8e0cc7 In-band-registration: data form 2 xml conversion
Goffi <goffi@goffi.org>
parents: 28
diff changeset
336 elif type == "FORM":
b9bb5d8e0cc7 In-band-registration: data form 2 xml conversion
Goffi <goffi@goffi.org>
parents: 28
diff changeset
337 self.current_action_ids.remove(id)
35
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents: 33
diff changeset
338 debug ("Form received")
36
6491b7956c80 wix: Form submitting, first draft
Goffi <goffi@goffi.org>
parents: 35
diff changeset
339 form=Form(self, title='Registration', target = data['target'], type = data['type'], xml_data = data['xml'])
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
340 elif type == "RESULT":
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
341 self.current_action_ids.remove(id)
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
342 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
343 callback = self.current_action_ids_cb[id]
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
344 del self.current_action_ids_cb[id]
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
345 callback(data)
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
346 elif type == "DICT_DICT":
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
347 self.current_action_ids.remove(id)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
348 if self.current_action_ids_cb.has_key(id):
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
349 callback = self.current_action_ids_cb[id]
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
350 del self.current_action_ids_cb[id]
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
351 callback(data)
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
352 print ("Dict of dict found as result")
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
353 else:
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
354 error ("FIXME FIXME FIXME: type [%s] not implemented" % type)
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
355 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
356
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
357
0
goffi@necton2
parents:
diff changeset
358
goffi@necton2
parents:
diff changeset
359 def progressCB(self, id, title, message):
goffi@necton2
parents:
diff changeset
360 data = self.bridge.getProgress(id)
goffi@necton2
parents:
diff changeset
361 if data:
goffi@necton2
parents:
diff changeset
362 if not data['position']:
goffi@necton2
parents:
diff changeset
363 data['position'] = '0'
goffi@necton2
parents:
diff changeset
364 if not self.pbar:
goffi@necton2
parents:
diff changeset
365 #first answer, we must construct the bar
goffi@necton2
parents:
diff changeset
366 self.pbar = wx.ProgressDialog(title, message, int(data['size']), None,
goffi@necton2
parents:
diff changeset
367 wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME)
goffi@necton2
parents:
diff changeset
368 self.pbar.finish_value = int(data['size'])
goffi@necton2
parents:
diff changeset
369
goffi@necton2
parents:
diff changeset
370 self.pbar.Update(int(data['position']))
goffi@necton2
parents:
diff changeset
371 elif self.pbar:
goffi@necton2
parents:
diff changeset
372 self.pbar.Update(self.pbar.finish_value)
goffi@necton2
parents:
diff changeset
373 return
goffi@necton2
parents:
diff changeset
374
goffi@necton2
parents:
diff changeset
375 wx.CallLater(10, self.progressCB, id, title, message)
goffi@necton2
parents:
diff changeset
376
goffi@necton2
parents:
diff changeset
377 def waitProgress (self, id, title, message):
goffi@necton2
parents:
diff changeset
378 self.pbar = None
goffi@necton2
parents:
diff changeset
379 wx.CallLater(10, self.progressCB, id, title, message)
goffi@necton2
parents:
diff changeset
380
goffi@necton2
parents:
diff changeset
381
goffi@necton2
parents:
diff changeset
382
goffi@necton2
parents:
diff changeset
383 ### events ###
goffi@necton2
parents:
diff changeset
384
goffi@necton2
parents:
diff changeset
385 def onContactActivated(self, jid):
goffi@necton2
parents:
diff changeset
386 debug ("onContactActivated: %s", jid)
goffi@necton2
parents:
diff changeset
387 if self.chat_wins[jid].IsShown():
goffi@necton2
parents:
diff changeset
388 self.chat_wins[jid].Hide()
goffi@necton2
parents:
diff changeset
389 else:
goffi@necton2
parents:
diff changeset
390 self.chat_wins[jid].Show()
goffi@necton2
parents:
diff changeset
391
goffi@necton2
parents:
diff changeset
392 def onConnectRequest(self, e):
goffi@necton2
parents:
diff changeset
393 self.bridge.connect()
goffi@necton2
parents:
diff changeset
394
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
395 def onDisconnectRequest(self, e):
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
396 self.bridge.disconnect()
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
397
0
goffi@necton2
parents:
diff changeset
398 def __updateStatus(self):
goffi@necton2
parents:
diff changeset
399 show = const_STATUS[self.statusBox.GetValue()]
goffi@necton2
parents:
diff changeset
400 status = self.statusTxt.GetValue()
goffi@necton2
parents:
diff changeset
401 self.bridge.setPresence(show=show, status=status)
goffi@necton2
parents:
diff changeset
402
goffi@necton2
parents:
diff changeset
403 def onStatusChange(self, e):
goffi@necton2
parents:
diff changeset
404 debug("Status change request")
goffi@necton2
parents:
diff changeset
405 self.__updateStatus()
goffi@necton2
parents:
diff changeset
406
goffi@necton2
parents:
diff changeset
407 def onParam(self, e):
goffi@necton2
parents:
diff changeset
408 debug("Param request")
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
409 param=Param(self)
0
goffi@necton2
parents:
diff changeset
410
goffi@necton2
parents:
diff changeset
411 def onExit(self, e):
goffi@necton2
parents:
diff changeset
412 self.Close()
goffi@necton2
parents:
diff changeset
413
goffi@necton2
parents:
diff changeset
414 def onAddContact(self, e):
goffi@necton2
parents:
diff changeset
415 debug("Add contact request")
goffi@necton2
parents:
diff changeset
416 dlg = wx.TextEntryDialog(
goffi@necton2
parents:
diff changeset
417 self, 'Please enter new contact JID',
38
3e24753b9e0b Fixed parameters loading/saving
Goffi <goffi@goffi.org>
parents: 36
diff changeset
418 'Adding a contact', 'name@server.tld')
0
goffi@necton2
parents:
diff changeset
419
goffi@necton2
parents:
diff changeset
420 if dlg.ShowModal() == wx.ID_OK:
goffi@necton2
parents:
diff changeset
421 jid=JID(dlg.GetValue())
goffi@necton2
parents:
diff changeset
422 if jid.is_valid():
goffi@necton2
parents:
diff changeset
423 self.bridge.addContact(jid.short)
goffi@necton2
parents:
diff changeset
424 else:
goffi@necton2
parents:
diff changeset
425 error ("'%s' is an invalid JID !", jid)
goffi@necton2
parents:
diff changeset
426 #TODO: notice the user
goffi@necton2
parents:
diff changeset
427
goffi@necton2
parents:
diff changeset
428 dlg.Destroy()
goffi@necton2
parents:
diff changeset
429
goffi@necton2
parents:
diff changeset
430 def onRemoveContact(self, e):
goffi@necton2
parents:
diff changeset
431 debug("Remove contact request")
goffi@necton2
parents:
diff changeset
432 target = self.contactList.getSelection()
goffi@necton2
parents:
diff changeset
433 if not target:
goffi@necton2
parents:
diff changeset
434 dlg = wx.MessageDialog(self, "You haven't selected any contact !",
goffi@necton2
parents:
diff changeset
435 'Error',
goffi@necton2
parents:
diff changeset
436 wx.OK | wx.ICON_ERROR
goffi@necton2
parents:
diff changeset
437 )
goffi@necton2
parents:
diff changeset
438 dlg.ShowModal()
goffi@necton2
parents:
diff changeset
439 dlg.Destroy()
goffi@necton2
parents:
diff changeset
440 return
goffi@necton2
parents:
diff changeset
441
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
442 dlg = wx.MessageDialog(self, "Are you sure you want to delete %s from your roster list ?" % target.short,
0
goffi@necton2
parents:
diff changeset
443 'Contact suppression',
goffi@necton2
parents:
diff changeset
444 wx.YES_NO | wx.ICON_QUESTION
goffi@necton2
parents:
diff changeset
445 )
goffi@necton2
parents:
diff changeset
446
goffi@necton2
parents:
diff changeset
447 if dlg.ShowModal() == wx.ID_YES:
goffi@necton2
parents:
diff changeset
448 info("Unsubsribing %s presence", target.short)
goffi@necton2
parents:
diff changeset
449 self.bridge.delContact(target.short)
goffi@necton2
parents:
diff changeset
450
goffi@necton2
parents:
diff changeset
451 dlg.Destroy()
goffi@necton2
parents:
diff changeset
452
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
453 def onShowProfile(self, e):
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
454 debug("Show contact's profile request")
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
455 target = self.contactList.getSelection()
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
456 if not target:
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
457 dlg = wx.MessageDialog(self, "You haven't selected any contact !",
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
458 'Error',
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
459 wx.OK | wx.ICON_ERROR
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
460 )
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
461 dlg.ShowModal()
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
462 dlg.Destroy()
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
463 return
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
464 id = self.bridge.getProfile(target.short)
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
465 self.current_action_ids.add(id)
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
466 self.current_action_ids_cb[id] = self.onProfileReceived
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
467
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
468 def onProfileReceived(self, data):
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
469 """Called when a profile is received"""
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
470 debug ('Profile received: [%s]' % data)
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
471 profile=Profile(self, data)
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
472
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
473
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
474 def onFindGateways(self, e):
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
475 debug("Find Gateways request")
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
476 id = self.bridge.findGateways(self.whoami.domain)
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
477 self.current_action_ids.add(id)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
478 self.current_action_ids_cb[id] = self.onGatewaysFound
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
479 print "Find Gateways id=", id
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
480
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
481 def onGatewaysFound(self, data):
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
482 """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
483 target = data['__private__']['target']
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
484 del data['__private__']
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
485 gatewayManager = GatewaysManager(self, data, server=target)
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
486
0
goffi@necton2
parents:
diff changeset
487 def onClose(self, e):
goffi@necton2
parents:
diff changeset
488 info("Exiting...")
goffi@necton2
parents:
diff changeset
489 e.Skip()
11
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
490
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
491 def onTrayClick(self, e):
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
492 debug("Tray Click")
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
493 if self.IsShown():
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
494 self.Hide()
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
495 else:
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
496 self.Show()
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
497 self.Raise()
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
498 e.Skip()
0
goffi@necton2
parents:
diff changeset
499