annotate frontends/wix/main_window.py @ 80:9681f18d06bd

wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
author Goffi <goffi@goffi.org>
date Thu, 01 Apr 2010 18:57:57 +1100
parents 7322a41f8a8e
children 104a815bb23f
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
57
a5b5fb5fc9fd updated README and copyright note
Goffi <goffi@goffi.org>
parents: 56
diff changeset
6 Copyright (C) 2009, 2010 Jérôme Poisson (goffi@goffi.org)
0
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
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
23 from quick_frontend.quick_chat_list import QuickChatList
Goffi <goffi@goffi.org>
parents: 68
diff changeset
24 from quick_frontend.quick_app import QuickApp
Goffi <goffi@goffi.org>
parents: 68
diff changeset
25 from quick_frontend.quick_contact_management import QuickContactManagement
0
goffi@necton2
parents:
diff changeset
26 import wx
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
27 from contact_list import ContactList
0
goffi@necton2
parents:
diff changeset
28 from chat import Chat
goffi@necton2
parents:
diff changeset
29 from param import Param
35
c45deebb40a5 Wix: Registration form management (not finished yet)
Goffi <goffi@goffi.org>
parents: 33
diff changeset
30 from form import Form
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
31 from gateways import GatewaysManager
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
32 from profile import Profile
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
33 from profile_manager import ProfileManager
0
goffi@necton2
parents:
diff changeset
34 import gobject
goffi@necton2
parents:
diff changeset
35 import os.path
goffi@necton2
parents:
diff changeset
36 import pdb
goffi@necton2
parents:
diff changeset
37 from tools.jid import JID
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
38 from logging import debug, info, warning, error
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
39 import constants
0
goffi@necton2
parents:
diff changeset
40
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
41 idCONNECT,\
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
42 idDISCONNECT,\
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
43 idEXIT,\
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
44 idPARAM,\
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
45 idADD_CONTACT,\
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
46 idREMOVE_CONTACT,\
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
47 idSHOW_PROFILE,\
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
48 idJOIN_ROOM,\
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
49 idFIND_GATEWAYS = range(9)
0
goffi@necton2
parents:
diff changeset
50
goffi@necton2
parents:
diff changeset
51 class ChatList(QuickChatList):
goffi@necton2
parents:
diff changeset
52 """This class manage the list of chat windows"""
goffi@necton2
parents:
diff changeset
53
goffi@necton2
parents:
diff changeset
54 def __init__(self, host):
goffi@necton2
parents:
diff changeset
55 QuickChatList.__init__(self, host)
goffi@necton2
parents:
diff changeset
56
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
57 def createChat(self, target):
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
58 return Chat(target, self.host)
0
goffi@necton2
parents:
diff changeset
59
goffi@necton2
parents:
diff changeset
60 class MainWindow(wx.Frame, QuickApp):
goffi@necton2
parents:
diff changeset
61 """main app window"""
goffi@necton2
parents:
diff changeset
62
goffi@necton2
parents:
diff changeset
63 def __init__(self):
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
64 wx.Frame.__init__(self,None, title="SàT Wix", size=(300,500))
56
01ea5680207e removed debug comments
Goffi <goffi@goffi.org>
parents: 55
diff changeset
65 self.CM = QuickContactManagement() #FIXME: not the best place
0
goffi@necton2
parents:
diff changeset
66
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
67 #sizer
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
68 self.sizer = wx.BoxSizer(wx.VERTICAL)
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
69 self.SetSizer(self.sizer)
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
70
0
goffi@necton2
parents:
diff changeset
71 #Frame elements
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
72 self.contactList = ContactList(self, self)
0
goffi@necton2
parents:
diff changeset
73 self.contactList.registerActivatedCB(self.onContactActivated)
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
74 self.contactList.Hide()
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
75 self.sizer.Add(self.contactList, 1, flag=wx.EXPAND)
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
76
0
goffi@necton2
parents:
diff changeset
77 self.chat_wins=ChatList(self)
goffi@necton2
parents:
diff changeset
78 self.CreateStatusBar()
goffi@necton2
parents:
diff changeset
79 self.createMenus()
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
80 for i in range(self.menuBar.GetMenuCount()):
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
81 self.menuBar.EnableTop(i, False)
0
goffi@necton2
parents:
diff changeset
82
goffi@necton2
parents:
diff changeset
83 #ToolBar
goffi@necton2
parents:
diff changeset
84 self.tools=self.CreateToolBar()
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
85 self.statusBox = wx.ComboBox(self.tools, -1, "Online", choices=[status[1] for status in const_STATUS],
0
goffi@necton2
parents:
diff changeset
86 style=wx.CB_DROPDOWN | wx.CB_READONLY)
goffi@necton2
parents:
diff changeset
87 self.tools.AddControl(self.statusBox)
goffi@necton2
parents:
diff changeset
88 self.tools.AddSeparator()
goffi@necton2
parents:
diff changeset
89 self.statusTxt=wx.TextCtrl(self.tools, -1, style = wx.TE_PROCESS_ENTER)
goffi@necton2
parents:
diff changeset
90 self.tools.AddControl(self.statusTxt)
goffi@necton2
parents:
diff changeset
91 self.Bind(wx.EVT_COMBOBOX, self.onStatusChange, self.statusBox)
goffi@necton2
parents:
diff changeset
92 self.Bind(wx.EVT_TEXT_ENTER, self.onStatusChange, self.statusTxt)
goffi@necton2
parents:
diff changeset
93 self.tools.Disable()
11
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
94
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
95 #tray icon
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
96 ticon = wx.Icon(IMAGE_DIR+'/crystal/tray_icon.xpm', wx.BITMAP_TYPE_XPM)
11
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
97 self.tray_icon = wx.TaskBarIcon()
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
98 self.tray_icon.SetIcon(ticon, _("Wix jabber client"))
11
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
99 wx.EVT_TASKBAR_LEFT_UP(self.tray_icon, self.onTrayClick)
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
100
0
goffi@necton2
parents:
diff changeset
101
goffi@necton2
parents:
diff changeset
102 #events
goffi@necton2
parents:
diff changeset
103 self.Bind(wx.EVT_CLOSE, self.onClose, self)
goffi@necton2
parents:
diff changeset
104
goffi@necton2
parents:
diff changeset
105 QuickApp.__init__(self)
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
106 #self.plug_profile() #gof:
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
107
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
108 #profile panel
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
109 self.profile_pan = ProfileManager(self)
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
110 #self.profile_pan.Hide() #gof:
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
111 self.sizer.Add(self.profile_pan, 1, flag=wx.EXPAND)
52
6455fb62ff83 Connection/disconnection signals
Goffi <goffi@goffi.org>
parents: 51
diff changeset
112
0
goffi@necton2
parents:
diff changeset
113 self.Show()
goffi@necton2
parents:
diff changeset
114
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
115 def plug_profile(self, profile_key='@DEFAULT@'):
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
116 """Hide profile panel then plug profile"""
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
117 self.profile_pan.Hide()
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
118 self.contactList.Show()
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
119 self.sizer.Layout()
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
120 for i in range(self.menuBar.GetMenuCount()):
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
121 self.menuBar.EnableTop(i, True)
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
122 super(MainWindow, self).plug_profile(profile_key)
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
123 if not self.bridge.isConnected(profile_key):
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
124 self.bridge.connect(profile_key)
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
125
0
goffi@necton2
parents:
diff changeset
126 def createMenus(self):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
127 info(_("Creating menus"))
0
goffi@necton2
parents:
diff changeset
128 connectMenu = wx.Menu()
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
129 connectMenu.Append(idCONNECT, _("&Connect CTRL-c"),_(" Connect to the server"))
Goffi <goffi@goffi.org>
parents: 68
diff changeset
130 connectMenu.Append(idDISCONNECT, _("&Disconnect CTRL-d"),_(" Disconnect from the server"))
Goffi <goffi@goffi.org>
parents: 68
diff changeset
131 connectMenu.Append(idPARAM,_("&Parameters"),_(" Configure the program"))
0
goffi@necton2
parents:
diff changeset
132 connectMenu.AppendSeparator()
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
133 connectMenu.Append(idEXIT,_("E&xit"),_(" Terminate the program"))
0
goffi@necton2
parents:
diff changeset
134 contactMenu = wx.Menu()
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
135 contactMenu.Append(idADD_CONTACT, _("&Add contact"),_(" Add a contact to your list"))
Goffi <goffi@goffi.org>
parents: 68
diff changeset
136 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
137 contactMenu.AppendSeparator()
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
138 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
139 communicationMenu = wx.Menu()
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
140 communicationMenu.Append(idJOIN_ROOM, _("&Join Room"),_(" Join a Multi-User Chat room"))
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
141 communicationMenu.Append(idFIND_GATEWAYS, _("&Find Gateways"),_(" Find gateways to legacy IM"))
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
142 self.menuBar = wx.MenuBar()
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
143 self.menuBar.Append(connectMenu,_("&General"))
Goffi <goffi@goffi.org>
parents: 68
diff changeset
144 self.menuBar.Append(contactMenu,_("&Contacts"))
Goffi <goffi@goffi.org>
parents: 68
diff changeset
145 self.menuBar.Append(communicationMenu,_("&Communication"))
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
146 self.SetMenuBar(self.menuBar)
0
goffi@necton2
parents:
diff changeset
147
goffi@necton2
parents:
diff changeset
148 #events
goffi@necton2
parents:
diff changeset
149 wx.EVT_MENU(self, idCONNECT, self.onConnectRequest)
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
150 wx.EVT_MENU(self, idDISCONNECT, self.onDisconnectRequest)
0
goffi@necton2
parents:
diff changeset
151 wx.EVT_MENU(self, idPARAM, self.onParam)
goffi@necton2
parents:
diff changeset
152 wx.EVT_MENU(self, idEXIT, self.onExit)
goffi@necton2
parents:
diff changeset
153 wx.EVT_MENU(self, idADD_CONTACT, self.onAddContact)
goffi@necton2
parents:
diff changeset
154 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
155 wx.EVT_MENU(self, idSHOW_PROFILE, self.onShowProfile)
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
156 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
157 wx.EVT_MENU(self, idFIND_GATEWAYS, self.onFindGateways)
0
goffi@necton2
parents:
diff changeset
158
goffi@necton2
parents:
diff changeset
159
67
0e50dd3a234a message sending bug fixes + sortilege update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
160 def newMessage(self, from_jid, msg, type, to_jid, profile):
0e50dd3a234a message sending bug fixes + sortilege update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
161 QuickApp.newMessage(self, from_jid, msg, type, to_jid, profile)
0
goffi@necton2
parents:
diff changeset
162
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
163 def roomJoined(self, room_id, room_service, room_nicks, user_nick, profile):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
164 super(MainWindow, self).roomJoined(room_id, room_service, room_nicks, user_nick, profile)
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
165
0
goffi@necton2
parents:
diff changeset
166 def showAlert(self, message):
goffi@necton2
parents:
diff changeset
167 # TODO: place this in a separate class
goffi@necton2
parents:
diff changeset
168 popup=wx.PopupWindow(self)
goffi@necton2
parents:
diff changeset
169 ### following code come from wxpython demo
goffi@necton2
parents:
diff changeset
170 popup.SetBackgroundColour("CADET BLUE")
goffi@necton2
parents:
diff changeset
171 st = wx.StaticText(popup, -1, message, pos=(10,10))
goffi@necton2
parents:
diff changeset
172 sz = st.GetBestSize()
goffi@necton2
parents:
diff changeset
173 popup.SetSize( (sz.width+20, sz.height+20) )
goffi@necton2
parents:
diff changeset
174 x=(wx.DisplaySize()[0]-popup.GetSize()[0])/2
goffi@necton2
parents:
diff changeset
175 popup.SetPosition((x,0))
goffi@necton2
parents:
diff changeset
176 popup.Show()
goffi@necton2
parents:
diff changeset
177 wx.CallLater(5000,popup.Destroy)
goffi@necton2
parents:
diff changeset
178
goffi@necton2
parents:
diff changeset
179 def showDialog(self, message, title="", type="info"):
goffi@necton2
parents:
diff changeset
180 if type == 'info':
goffi@necton2
parents:
diff changeset
181 flags = wx.OK | wx.ICON_INFORMATION
goffi@necton2
parents:
diff changeset
182 elif type == 'error':
goffi@necton2
parents:
diff changeset
183 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
184 elif type == 'yes/no':
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
185 flags = wx.YES_NO | wx.ICON_QUESTION
0
goffi@necton2
parents:
diff changeset
186 else:
goffi@necton2
parents:
diff changeset
187 flags = wx.OK | wx.ICON_INFORMATION
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
188 error(_('unmanaged dialog type: %s'), type)
0
goffi@necton2
parents:
diff changeset
189 dlg = wx.MessageDialog(self, message, title, flags)
goffi@necton2
parents:
diff changeset
190 answer = dlg.ShowModal()
goffi@necton2
parents:
diff changeset
191 dlg.Destroy()
goffi@necton2
parents:
diff changeset
192 return True if (answer == wx.ID_YES or answer == wx.ID_OK) else False
goffi@necton2
parents:
diff changeset
193
goffi@necton2
parents:
diff changeset
194 def setStatusOnline(self, online=True):
goffi@necton2
parents:
diff changeset
195 """enable/disable controls, must be called when local user online status change"""
goffi@necton2
parents:
diff changeset
196 if online:
goffi@necton2
parents:
diff changeset
197 self.SetStatusText(msgONLINE)
goffi@necton2
parents:
diff changeset
198 self.tools.Enable()
goffi@necton2
parents:
diff changeset
199 else:
goffi@necton2
parents:
diff changeset
200 self.SetStatusText(msgOFFLINE)
goffi@necton2
parents:
diff changeset
201 self.tools.Disable()
goffi@necton2
parents:
diff changeset
202 return
goffi@necton2
parents:
diff changeset
203
goffi@necton2
parents:
diff changeset
204 def askConfirmation(self, type, id, data):
goffi@necton2
parents:
diff changeset
205 #TODO: refactor this in QuickApp
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
206 debug (_("Confirmation asked"))
0
goffi@necton2
parents:
diff changeset
207 answer_data={}
goffi@necton2
parents:
diff changeset
208 if type == "FILE_TRANSFERT":
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
209 debug (_("File transfert confirmation asked"))
Goffi <goffi@goffi.org>
parents: 68
diff changeset
210 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"]},
Goffi <goffi@goffi.org>
parents: 68
diff changeset
211 _('File Request'),
0
goffi@necton2
parents:
diff changeset
212 wx.YES_NO | wx.ICON_QUESTION
goffi@necton2
parents:
diff changeset
213 )
goffi@necton2
parents:
diff changeset
214 answer=dlg.ShowModal()
goffi@necton2
parents:
diff changeset
215 if answer==wx.ID_YES:
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
216 filename = wx.FileSelector(_("Where do you want to save the file ?"), flags = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
0
goffi@necton2
parents:
diff changeset
217 if filename:
goffi@necton2
parents:
diff changeset
218 answer_data["dest_path"] = filename
goffi@necton2
parents:
diff changeset
219 self.bridge.confirmationAnswer(id, True, answer_data)
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
220 self.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename))
0
goffi@necton2
parents:
diff changeset
221 else:
goffi@necton2
parents:
diff changeset
222 answer = wx.ID_NO
goffi@necton2
parents:
diff changeset
223 if answer==wx.ID_NO:
goffi@necton2
parents:
diff changeset
224 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
225
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
226 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
227
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
228 elif type == "YES/NO":
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
229 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
230 dlg = wx.MessageDialog(self, data["message"],
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
231 _('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
232 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
233 )
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
234 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
235 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
236 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
237 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
238 self.bridge.confirmationAnswer(id, False, {})
0
goffi@necton2
parents:
diff changeset
239
goffi@necton2
parents:
diff changeset
240 dlg.Destroy()
goffi@necton2
parents:
diff changeset
241
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
242 def actionResult(self, type, id, data):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
243 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
244 if not id in self.current_action_ids:
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
245 debug (_('unknown id, ignoring'))
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
246 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
247 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
248 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
249 elif type == "SUCCESS":
23
925ab466c5ec better presentation for register new account
Goffi <goffi@goffi.org>
parents: 22
diff changeset
250 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
251 dlg = wx.MessageDialog(self, data["message"],
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
252 _('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
253 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
254 )
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
255 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
256 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
257 elif type == "ERROR":
23
925ab466c5ec better presentation for register new account
Goffi <goffi@goffi.org>
parents: 22
diff changeset
258 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
259 dlg = wx.MessageDialog(self, data["message"],
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
260 _('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
261 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
262 )
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
263 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
264 dlg.Destroy()
33
b9bb5d8e0cc7 In-band-registration: data form 2 xml conversion
Goffi <goffi@goffi.org>
parents: 28
diff changeset
265 elif type == "FORM":
b9bb5d8e0cc7 In-band-registration: data form 2 xml conversion
Goffi <goffi@goffi.org>
parents: 28
diff changeset
266 self.current_action_ids.remove(id)
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
267 debug (_("Form received"))
Goffi <goffi@goffi.org>
parents: 68
diff changeset
268 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
269 elif type == "RESULT":
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
270 self.current_action_ids.remove(id)
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
271 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
272 callback = self.current_action_ids_cb[id]
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
273 del self.current_action_ids_cb[id]
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
274 callback(data)
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
275 elif type == "DICT_DICT":
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
276 self.current_action_ids.remove(id)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
277 if self.current_action_ids_cb.has_key(id):
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
278 callback = self.current_action_ids_cb[id]
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
279 del self.current_action_ids_cb[id]
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
280 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
281 else:
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
282 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
283 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
284
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
285
0
goffi@necton2
parents:
diff changeset
286
goffi@necton2
parents:
diff changeset
287 def progressCB(self, id, title, message):
goffi@necton2
parents:
diff changeset
288 data = self.bridge.getProgress(id)
goffi@necton2
parents:
diff changeset
289 if data:
goffi@necton2
parents:
diff changeset
290 if not data['position']:
goffi@necton2
parents:
diff changeset
291 data['position'] = '0'
goffi@necton2
parents:
diff changeset
292 if not self.pbar:
goffi@necton2
parents:
diff changeset
293 #first answer, we must construct the bar
goffi@necton2
parents:
diff changeset
294 self.pbar = wx.ProgressDialog(title, message, int(data['size']), None,
goffi@necton2
parents:
diff changeset
295 wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME)
goffi@necton2
parents:
diff changeset
296 self.pbar.finish_value = int(data['size'])
goffi@necton2
parents:
diff changeset
297
goffi@necton2
parents:
diff changeset
298 self.pbar.Update(int(data['position']))
goffi@necton2
parents:
diff changeset
299 elif self.pbar:
goffi@necton2
parents:
diff changeset
300 self.pbar.Update(self.pbar.finish_value)
goffi@necton2
parents:
diff changeset
301 return
goffi@necton2
parents:
diff changeset
302
goffi@necton2
parents:
diff changeset
303 wx.CallLater(10, self.progressCB, id, title, message)
goffi@necton2
parents:
diff changeset
304
goffi@necton2
parents:
diff changeset
305 def waitProgress (self, id, title, message):
goffi@necton2
parents:
diff changeset
306 self.pbar = None
goffi@necton2
parents:
diff changeset
307 wx.CallLater(10, self.progressCB, id, title, message)
goffi@necton2
parents:
diff changeset
308
goffi@necton2
parents:
diff changeset
309
goffi@necton2
parents:
diff changeset
310
goffi@necton2
parents:
diff changeset
311 ### events ###
goffi@necton2
parents:
diff changeset
312
goffi@necton2
parents:
diff changeset
313 def onContactActivated(self, jid):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
314 debug (_("onContactActivated: %s"), jid)
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
315 if self.chat_wins[jid.short].IsShown():
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
316 self.chat_wins[jid.short].Hide()
0
goffi@necton2
parents:
diff changeset
317 else:
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
318 self.chat_wins[jid.short].Show()
0
goffi@necton2
parents:
diff changeset
319
goffi@necton2
parents:
diff changeset
320 def onConnectRequest(self, e):
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
321 self.bridge.connect(self.profile)
0
goffi@necton2
parents:
diff changeset
322
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
323 def onDisconnectRequest(self, e):
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
324 self.bridge.disconnect(self.profile)
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
325
0
goffi@necton2
parents:
diff changeset
326 def __updateStatus(self):
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
327 show = filter(lambda x:x[1] == self.statusBox.GetValue(), const_STATUS)[0][0]
0
goffi@necton2
parents:
diff changeset
328 status = self.statusTxt.GetValue()
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
329 self.bridge.setPresence(show=show, statuses={'default':status}) #FIXME: manage multilingual statuses
0
goffi@necton2
parents:
diff changeset
330
goffi@necton2
parents:
diff changeset
331 def onStatusChange(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
332 debug(_("Status change request"))
0
goffi@necton2
parents:
diff changeset
333 self.__updateStatus()
goffi@necton2
parents:
diff changeset
334
goffi@necton2
parents:
diff changeset
335 def onParam(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
336 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
337 param=Param(self)
0
goffi@necton2
parents:
diff changeset
338
goffi@necton2
parents:
diff changeset
339 def onExit(self, e):
goffi@necton2
parents:
diff changeset
340 self.Close()
goffi@necton2
parents:
diff changeset
341
goffi@necton2
parents:
diff changeset
342 def onAddContact(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
343 debug(_("Add contact request"))
0
goffi@necton2
parents:
diff changeset
344 dlg = wx.TextEntryDialog(
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
345 self, _('Please enter new contact JID'),
Goffi <goffi@goffi.org>
parents: 68
diff changeset
346 _('Adding a contact'), _('name@server.tld'))
0
goffi@necton2
parents:
diff changeset
347
goffi@necton2
parents:
diff changeset
348 if dlg.ShowModal() == wx.ID_OK:
goffi@necton2
parents:
diff changeset
349 jid=JID(dlg.GetValue())
goffi@necton2
parents:
diff changeset
350 if jid.is_valid():
goffi@necton2
parents:
diff changeset
351 self.bridge.addContact(jid.short)
goffi@necton2
parents:
diff changeset
352 else:
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
353 error (_("'%s' is an invalid JID !"), jid)
0
goffi@necton2
parents:
diff changeset
354 #TODO: notice the user
goffi@necton2
parents:
diff changeset
355
goffi@necton2
parents:
diff changeset
356 dlg.Destroy()
goffi@necton2
parents:
diff changeset
357
goffi@necton2
parents:
diff changeset
358 def onRemoveContact(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
359 debug(_("Remove contact request"))
0
goffi@necton2
parents:
diff changeset
360 target = self.contactList.getSelection()
goffi@necton2
parents:
diff changeset
361 if not target:
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
362 dlg = wx.MessageDialog(self, _("You haven't selected any contact !"),
Goffi <goffi@goffi.org>
parents: 68
diff changeset
363 _('Error'),
0
goffi@necton2
parents:
diff changeset
364 wx.OK | wx.ICON_ERROR
goffi@necton2
parents:
diff changeset
365 )
goffi@necton2
parents:
diff changeset
366 dlg.ShowModal()
goffi@necton2
parents:
diff changeset
367 dlg.Destroy()
goffi@necton2
parents:
diff changeset
368 return
goffi@necton2
parents:
diff changeset
369
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
370 dlg = wx.MessageDialog(self, _("Are you sure you want to delete %s from your roster list ?") % target.short,
Goffi <goffi@goffi.org>
parents: 68
diff changeset
371 _('Contact suppression'),
0
goffi@necton2
parents:
diff changeset
372 wx.YES_NO | wx.ICON_QUESTION
goffi@necton2
parents:
diff changeset
373 )
goffi@necton2
parents:
diff changeset
374
goffi@necton2
parents:
diff changeset
375 if dlg.ShowModal() == wx.ID_YES:
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
376 info(_("Unsubscribing %s presence"), target.short)
0
goffi@necton2
parents:
diff changeset
377 self.bridge.delContact(target.short)
goffi@necton2
parents:
diff changeset
378
goffi@necton2
parents:
diff changeset
379 dlg.Destroy()
goffi@necton2
parents:
diff changeset
380
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
381 def onShowProfile(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
382 debug(_("Show contact's profile request"))
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
383 target = self.contactList.getSelection()
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
384 if not target:
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
385 dlg = wx.MessageDialog(self, _("You haven't selected any contact !"),
Goffi <goffi@goffi.org>
parents: 68
diff changeset
386 _('Error'),
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
387 wx.OK | wx.ICON_ERROR
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
388 )
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
389 dlg.ShowModal()
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
390 dlg.Destroy()
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
391 return
64
d46f849664aa SàT: multi-profile, plugins updated
Goffi <goffi@goffi.org>
parents: 57
diff changeset
392 id = self.bridge.getCard(target.short)
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
393 self.current_action_ids.add(id)
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
394 self.current_action_ids_cb[id] = self.onProfileReceived
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
395
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
396 def onProfileReceived(self, data):
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
397 """Called when a profile is received"""
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
398 debug (_('Profile received: [%s]') % data)
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
399 profile=Profile(self, data)
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
400
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
401 def onJoinRoom(self, e):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
402 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
403 #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
404 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
405 self, _("Please enter MUC's JID"),
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
406 _('Entering a MUC room'), _('test@conference.necton2.int'))
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
407 #_('Entering a MUC room'), _('room@muc_service.server.tld'))
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
408 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
409 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
410 if room_jid.is_valid():
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
411 self.bridge.joinMUC(room_jid.domain, room_jid.node, self.profiles[self.profile]['whoami'].node, self.profile)
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
412 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
413 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
414
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
415 def onFindGateways(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
416 debug(_("Find Gateways request"))
66
8147b4f40809 SàT: multi-profile: DBus signals and frontend adaptation (first draft)
Goffi <goffi@goffi.org>
parents: 64
diff changeset
417 id = self.bridge.findGateways(self.profiles[self.profile]['whoami'].domain)
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
418 self.current_action_ids.add(id)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
419 self.current_action_ids_cb[id] = self.onGatewaysFound
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
420
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
421 def onGatewaysFound(self, data):
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
422 """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
423 target = data['__private__']['target']
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
424 del data['__private__']
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
425 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
426
0
goffi@necton2
parents:
diff changeset
427 def onClose(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
428 info(_("Exiting..."))
0
goffi@necton2
parents:
diff changeset
429 e.Skip()
11
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
430
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
431 def onTrayClick(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
432 debug(_("Tray Click"))
11
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
433 if self.IsShown():
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
434 self.Hide()
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
435 else:
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
436 self.Show()
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
437 self.Raise()
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
438 e.Skip()
0
goffi@necton2
parents:
diff changeset
439