annotate frontends/src/wix/main_window.py @ 415:3348331e0f09

primitivus: fixed screen redraw after plugin profile
author Goffi <goffi@goffi.org>
date Tue, 01 Nov 2011 22:55:58 +0100
parents 10b4f577d0c0
children cf005701624b
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
228
b1794cbb88e5 2011 copyright upgrade
Goffi <goffi@goffi.org>
parents: 227
diff changeset
6 Copyright (C) 2009, 2010, 2011 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
227
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
23 from sat_frontends.quick_frontend.quick_chat_list import QuickChatList
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
24 from sat_frontends.quick_frontend.quick_app import QuickApp
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
25 from sat_frontends.quick_frontend.quick_contact_management import QuickContactManagement
0
goffi@necton2
parents:
diff changeset
26 import wx
227
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
27 from sat_frontends.wix.contact_list import ContactList
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
28 from sat_frontends.wix.chat import Chat
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
29 from sat_frontends.wix.param import Param
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
30 from sat_frontends.wix.xmlui import XMLUI
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
31 from sat_frontends.wix.gateways import GatewaysManager
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
32 from sat_frontends.wix.profile import Profile
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
33 from sat_frontends.wix.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
225
fd9b7834d98a distutils installation script, draft
Goffi <goffi@goffi.org>
parents: 223
diff changeset
37 from sat.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
227
533507bb4e32 distutils wix installation
Goffi <goffi@goffi.org>
parents: 225
diff changeset
39 import sat_frontends.wix.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,\
191
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
44 idABOUT,\
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
45 idPARAM,\
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
46 idADD_CONTACT,\
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
47 idREMOVE_CONTACT,\
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
48 idSHOW_PROFILE,\
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
49 idJOIN_ROOM,\
191
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
50 idFIND_GATEWAYS = range(10)
0
goffi@necton2
parents:
diff changeset
51
goffi@necton2
parents:
diff changeset
52 class ChatList(QuickChatList):
goffi@necton2
parents:
diff changeset
53 """This class manage the list of chat windows"""
goffi@necton2
parents:
diff changeset
54
goffi@necton2
parents:
diff changeset
55 def __init__(self, host):
goffi@necton2
parents:
diff changeset
56 QuickChatList.__init__(self, host)
goffi@necton2
parents:
diff changeset
57
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
58 def createChat(self, target):
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
59 return Chat(target, self.host)
0
goffi@necton2
parents:
diff changeset
60
goffi@necton2
parents:
diff changeset
61 class MainWindow(wx.Frame, QuickApp):
goffi@necton2
parents:
diff changeset
62 """main app window"""
goffi@necton2
parents:
diff changeset
63
goffi@necton2
parents:
diff changeset
64 def __init__(self):
366
0806a65a5fa9 wix: updated paths to use media_dir
Goffi <goffi@goffi.org>
parents: 228
diff changeset
65 QuickApp.__init__(self)
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
66 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
67 self.CM = QuickContactManagement() #FIXME: not the best place
0
goffi@necton2
parents:
diff changeset
68
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
69 #sizer
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
70 self.sizer = wx.BoxSizer(wx.VERTICAL)
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
71 self.SetSizer(self.sizer)
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
72
0
goffi@necton2
parents:
diff changeset
73 #Frame elements
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
74 self.contactList = ContactList(self, self)
0
goffi@necton2
parents:
diff changeset
75 self.contactList.registerActivatedCB(self.onContactActivated)
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
76 self.contactList.Hide()
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
77 self.sizer.Add(self.contactList, 1, flag=wx.EXPAND)
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
78
0
goffi@necton2
parents:
diff changeset
79 self.chat_wins=ChatList(self)
goffi@necton2
parents:
diff changeset
80 self.CreateStatusBar()
goffi@necton2
parents:
diff changeset
81
goffi@necton2
parents:
diff changeset
82 #ToolBar
goffi@necton2
parents:
diff changeset
83 self.tools=self.CreateToolBar()
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
84 self.statusBox = wx.ComboBox(self.tools, -1, "Online", choices=[status[1] for status in const_STATUS],
0
goffi@necton2
parents:
diff changeset
85 style=wx.CB_DROPDOWN | wx.CB_READONLY)
goffi@necton2
parents:
diff changeset
86 self.tools.AddControl(self.statusBox)
goffi@necton2
parents:
diff changeset
87 self.tools.AddSeparator()
goffi@necton2
parents:
diff changeset
88 self.statusTxt=wx.TextCtrl(self.tools, -1, style = wx.TE_PROCESS_ENTER)
goffi@necton2
parents:
diff changeset
89 self.tools.AddControl(self.statusTxt)
goffi@necton2
parents:
diff changeset
90 self.Bind(wx.EVT_COMBOBOX, self.onStatusChange, self.statusBox)
goffi@necton2
parents:
diff changeset
91 self.Bind(wx.EVT_TEXT_ENTER, self.onStatusChange, self.statusTxt)
goffi@necton2
parents:
diff changeset
92 self.tools.Disable()
366
0806a65a5fa9 wix: updated paths to use media_dir
Goffi <goffi@goffi.org>
parents: 228
diff changeset
93
0806a65a5fa9 wix: updated paths to use media_dir
Goffi <goffi@goffi.org>
parents: 228
diff changeset
94
11
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
95
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
96 #tray icon
366
0806a65a5fa9 wix: updated paths to use media_dir
Goffi <goffi@goffi.org>
parents: 228
diff changeset
97 ticon = wx.Icon(os.path.join(self.media_dir, 'icons/crystal/tray_icon.xpm'), wx.BITMAP_TYPE_XPM)
11
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
98 self.tray_icon = wx.TaskBarIcon()
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
99 self.tray_icon.SetIcon(ticon, _("Wix jabber client"))
11
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
100 wx.EVT_TASKBAR_LEFT_UP(self.tray_icon, self.onTrayClick)
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
101
0
goffi@necton2
parents:
diff changeset
102
goffi@necton2
parents:
diff changeset
103 #events
goffi@necton2
parents:
diff changeset
104 self.Bind(wx.EVT_CLOSE, self.onClose, self)
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
105
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
106 #menus
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
107 self.createMenus()
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
108 for i in range(self.menuBar.GetMenuCount()):
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
109 self.menuBar.EnableTop(i, False)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
110
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
111 #profile panel
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
112 self.profile_pan = ProfileManager(self)
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
113 self.sizer.Add(self.profile_pan, 1, flag=wx.EXPAND)
119
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 105
diff changeset
114
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 105
diff changeset
115 self.postInit()
ded2431cea5a Primitivus: chat window / text sending.
Goffi <goffi@goffi.org>
parents: 105
diff changeset
116
0
goffi@necton2
parents:
diff changeset
117 self.Show()
goffi@necton2
parents:
diff changeset
118
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
119 def plug_profile(self, profile_key='@DEFAULT@'):
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
120 """Hide profile panel then plug profile"""
89
23caf1051099 multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents: 85
diff changeset
121 debug (_('plugin profile %s' % profile_key))
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
122 self.profile_pan.Hide()
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
123 self.contactList.Show()
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
124 self.sizer.Layout()
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
125 for i in range(self.menuBar.GetMenuCount()):
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
126 self.menuBar.EnableTop(i, True)
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
127 super(MainWindow, self).plug_profile(profile_key)
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
128
0
goffi@necton2
parents:
diff changeset
129 def createMenus(self):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
130 info(_("Creating menus"))
0
goffi@necton2
parents:
diff changeset
131 connectMenu = wx.Menu()
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
132 connectMenu.Append(idCONNECT, _("&Connect CTRL-c"),_(" Connect to the server"))
Goffi <goffi@goffi.org>
parents: 68
diff changeset
133 connectMenu.Append(idDISCONNECT, _("&Disconnect CTRL-d"),_(" Disconnect from the server"))
Goffi <goffi@goffi.org>
parents: 68
diff changeset
134 connectMenu.Append(idPARAM,_("&Parameters"),_(" Configure the program"))
0
goffi@necton2
parents:
diff changeset
135 connectMenu.AppendSeparator()
191
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
136 connectMenu.Append(idABOUT,_("A&bout"),_(" About %s") % APP_NAME)
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
137 connectMenu.Append(idEXIT,_("E&xit"),_(" Terminate the program"))
0
goffi@necton2
parents:
diff changeset
138 contactMenu = wx.Menu()
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
139 contactMenu.Append(idADD_CONTACT, _("&Add contact"),_(" Add a contact to your list"))
Goffi <goffi@goffi.org>
parents: 68
diff changeset
140 contactMenu.Append(idREMOVE_CONTACT, _("&Remove contact"),_(" Remove the selected contact from your list"))
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
141 contactMenu.AppendSeparator()
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
142 contactMenu.Append(idSHOW_PROFILE, _("&Show profile"), _(" Show contact's profile"))
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
143 communicationMenu = wx.Menu()
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
144 communicationMenu.Append(idJOIN_ROOM, _("&Join Room"),_(" Join a Multi-User Chat room"))
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
145 communicationMenu.Append(idFIND_GATEWAYS, _("&Find Gateways"),_(" Find gateways to legacy IM"))
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
146 self.menuBar = wx.MenuBar()
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
147 self.menuBar.Append(connectMenu,_("&General"))
Goffi <goffi@goffi.org>
parents: 68
diff changeset
148 self.menuBar.Append(contactMenu,_("&Contacts"))
Goffi <goffi@goffi.org>
parents: 68
diff changeset
149 self.menuBar.Append(communicationMenu,_("&Communication"))
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
150 self.SetMenuBar(self.menuBar)
0
goffi@necton2
parents:
diff changeset
151
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
152 #additionals menus
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
153 #FIXME: do this in a more generic way (in quickapp)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
154 add_menus = self.bridge.getMenus()
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
155 for menu in add_menus:
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
156 category,item,type = menu
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
157 assert(type=="NORMAL") #TODO: manage other types
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
158 menu_idx = self.menuBar.FindMenu(category)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
159 current_menu = None
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
160 if menu_idx == wx.NOT_FOUND:
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
161 #the menu is new, we create it
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
162 current_menu = wx.Menu()
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
163 self.menuBar.Append(current_menu, category)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
164 else:
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
165 current_menu = self.menuBar.GetMenu(menu_idx)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
166 assert(current_menu != None)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
167 item_id = wx.NewId()
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
168 help_string = self.bridge.getMenuHelp(category, item, type)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
169 current_menu.Append(item_id, item, help = help_string)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
170 #now we register the event
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
171 def event_answer(e):
219
782319a64ac6 primitivus, wix: added forgotten profile
Goffi <goffi@goffi.org>
parents: 204
diff changeset
172 id = self.bridge.callMenu(category, item, type, self.profile)
101
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
173 self.current_action_ids.add(id)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
174 wx.EVT_MENU(self, item_id, event_answer)
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
175
783e9d6980ec Couchsurfing plugin: first draft
Goffi <goffi@goffi.org>
parents: 91
diff changeset
176
0
goffi@necton2
parents:
diff changeset
177 #events
goffi@necton2
parents:
diff changeset
178 wx.EVT_MENU(self, idCONNECT, self.onConnectRequest)
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
179 wx.EVT_MENU(self, idDISCONNECT, self.onDisconnectRequest)
0
goffi@necton2
parents:
diff changeset
180 wx.EVT_MENU(self, idPARAM, self.onParam)
191
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
181 wx.EVT_MENU(self, idABOUT, self.onAbout)
0
goffi@necton2
parents:
diff changeset
182 wx.EVT_MENU(self, idEXIT, self.onExit)
goffi@necton2
parents:
diff changeset
183 wx.EVT_MENU(self, idADD_CONTACT, self.onAddContact)
goffi@necton2
parents:
diff changeset
184 wx.EVT_MENU(self, idREMOVE_CONTACT, self.onRemoveContact)
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
185 wx.EVT_MENU(self, idSHOW_PROFILE, self.onShowProfile)
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
186 wx.EVT_MENU(self, idJOIN_ROOM, self.onJoinRoom)
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
187 wx.EVT_MENU(self, idFIND_GATEWAYS, self.onFindGateways)
0
goffi@necton2
parents:
diff changeset
188
goffi@necton2
parents:
diff changeset
189
67
0e50dd3a234a message sending bug fixes + sortilege update
Goffi <goffi@goffi.org>
parents: 66
diff changeset
190 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
191 QuickApp.newMessage(self, from_jid, msg, type, to_jid, profile)
0
goffi@necton2
parents:
diff changeset
192
goffi@necton2
parents:
diff changeset
193 def showAlert(self, message):
goffi@necton2
parents:
diff changeset
194 # TODO: place this in a separate class
goffi@necton2
parents:
diff changeset
195 popup=wx.PopupWindow(self)
goffi@necton2
parents:
diff changeset
196 ### following code come from wxpython demo
goffi@necton2
parents:
diff changeset
197 popup.SetBackgroundColour("CADET BLUE")
goffi@necton2
parents:
diff changeset
198 st = wx.StaticText(popup, -1, message, pos=(10,10))
goffi@necton2
parents:
diff changeset
199 sz = st.GetBestSize()
goffi@necton2
parents:
diff changeset
200 popup.SetSize( (sz.width+20, sz.height+20) )
goffi@necton2
parents:
diff changeset
201 x=(wx.DisplaySize()[0]-popup.GetSize()[0])/2
goffi@necton2
parents:
diff changeset
202 popup.SetPosition((x,0))
goffi@necton2
parents:
diff changeset
203 popup.Show()
goffi@necton2
parents:
diff changeset
204 wx.CallLater(5000,popup.Destroy)
goffi@necton2
parents:
diff changeset
205
182
556c2bd7c344 Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents: 180
diff changeset
206 def showDialog(self, message, title="", type="info", answer_cb = None, answer_data = None):
0
goffi@necton2
parents:
diff changeset
207 if type == 'info':
goffi@necton2
parents:
diff changeset
208 flags = wx.OK | wx.ICON_INFORMATION
goffi@necton2
parents:
diff changeset
209 elif type == 'error':
goffi@necton2
parents:
diff changeset
210 flags = wx.OK | wx.ICON_ERROR
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
211 elif type == 'yes/no':
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
212 flags = wx.YES_NO | wx.ICON_QUESTION
0
goffi@necton2
parents:
diff changeset
213 else:
goffi@necton2
parents:
diff changeset
214 flags = wx.OK | wx.ICON_INFORMATION
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
215 error(_('unmanaged dialog type: %s'), type)
0
goffi@necton2
parents:
diff changeset
216 dlg = wx.MessageDialog(self, message, title, flags)
goffi@necton2
parents:
diff changeset
217 answer = dlg.ShowModal()
goffi@necton2
parents:
diff changeset
218 dlg.Destroy()
182
556c2bd7c344 Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents: 180
diff changeset
219 if answer_cb:
556c2bd7c344 Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents: 180
diff changeset
220 data = [answer_data] if answer_data else []
556c2bd7c344 Primitivus now implement showDialog + new "newAlert" bridge method to show a dialog from core
Goffi <goffi@goffi.org>
parents: 180
diff changeset
221 answer_cb(True if (answer == wx.ID_YES or answer == wx.ID_OK) else False, *data)
0
goffi@necton2
parents:
diff changeset
222
goffi@necton2
parents:
diff changeset
223 def setStatusOnline(self, online=True):
goffi@necton2
parents:
diff changeset
224 """enable/disable controls, must be called when local user online status change"""
goffi@necton2
parents:
diff changeset
225 if online:
goffi@necton2
parents:
diff changeset
226 self.SetStatusText(msgONLINE)
goffi@necton2
parents:
diff changeset
227 self.tools.Enable()
goffi@necton2
parents:
diff changeset
228 else:
goffi@necton2
parents:
diff changeset
229 self.SetStatusText(msgOFFLINE)
goffi@necton2
parents:
diff changeset
230 self.tools.Disable()
goffi@necton2
parents:
diff changeset
231 return
goffi@necton2
parents:
diff changeset
232
goffi@necton2
parents:
diff changeset
233 def askConfirmation(self, type, id, data):
goffi@necton2
parents:
diff changeset
234 #TODO: refactor this in QuickApp
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
235 debug (_("Confirmation asked"))
0
goffi@necton2
parents:
diff changeset
236 answer_data={}
391
c34fd9d6242e spelling
Goffi <goffi@goffi.org>
parents: 366
diff changeset
237 if type == "FILE_TRANSFER":
c34fd9d6242e spelling
Goffi <goffi@goffi.org>
parents: 366
diff changeset
238 debug (_("File transfer confirmation asked"))
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
239 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
240 _('File Request'),
0
goffi@necton2
parents:
diff changeset
241 wx.YES_NO | wx.ICON_QUESTION
goffi@necton2
parents:
diff changeset
242 )
goffi@necton2
parents:
diff changeset
243 answer=dlg.ShowModal()
goffi@necton2
parents:
diff changeset
244 if answer==wx.ID_YES:
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
245 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
246 if filename:
goffi@necton2
parents:
diff changeset
247 answer_data["dest_path"] = filename
goffi@necton2
parents:
diff changeset
248 self.bridge.confirmationAnswer(id, True, answer_data)
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
249 self.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename))
0
goffi@necton2
parents:
diff changeset
250 else:
goffi@necton2
parents:
diff changeset
251 answer = wx.ID_NO
goffi@necton2
parents:
diff changeset
252 if answer==wx.ID_NO:
goffi@necton2
parents:
diff changeset
253 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
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.Destroy()
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
256
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 == "YES/NO":
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
258 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
259 dlg = wx.MessageDialog(self, data["message"],
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
260 _('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
261 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
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 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
264 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
265 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
266 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
267 self.bridge.confirmationAnswer(id, False, {})
0
goffi@necton2
parents:
diff changeset
268
goffi@necton2
parents:
diff changeset
269 dlg.Destroy()
goffi@necton2
parents:
diff changeset
270
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
271 def actionResult(self, type, id, data):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
272 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
273 if not id in self.current_action_ids:
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
274 debug (_('unknown id, ignoring'))
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
275 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
276 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
277 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
278 elif type == "SUCCESS":
23
925ab466c5ec better presentation for register new account
Goffi <goffi@goffi.org>
parents: 22
diff changeset
279 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
280 dlg = wx.MessageDialog(self, data["message"],
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
281 _('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
282 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
283 )
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
284 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
285 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
286 elif type == "ERROR":
23
925ab466c5ec better presentation for register new account
Goffi <goffi@goffi.org>
parents: 22
diff changeset
287 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
288 dlg = wx.MessageDialog(self, data["message"],
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
289 _('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
290 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
291 )
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
292 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
293 dlg.Destroy()
103
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 102
diff changeset
294 elif type == "XMLUI":
33
b9bb5d8e0cc7 In-band-registration: data form 2 xml conversion
Goffi <goffi@goffi.org>
parents: 28
diff changeset
295 self.current_action_ids.remove(id)
103
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 102
diff changeset
296 debug (_("XML user interface received"))
91
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
297 misc = {}
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
298 #FIXME FIXME FIXME: must clean all this crap !
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
299 title = _('Form')
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
300 if data['type'] == _('registration'):
103
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 102
diff changeset
301 title = _('Registration')
91
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
302 misc['target'] = data['target']
39c672544593 Tarot: bidding phase
Goffi <goffi@goffi.org>
parents: 90
diff changeset
303 misc['action_back'] = self.bridge.gatewayRegister
103
6be927a465ed XMLUI refactoring, step 1
Goffi <goffi@goffi.org>
parents: 102
diff changeset
304 XMLUI(self, title=title, xml_data = data['xml'], misc = misc)
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
305 elif type == "RESULT":
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
306 self.current_action_ids.remove(id)
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
307 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
308 callback = self.current_action_ids_cb[id]
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
309 del self.current_action_ids_cb[id]
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
310 callback(data)
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
311 elif type == "DICT_DICT":
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
312 self.current_action_ids.remove(id)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
313 if self.current_action_ids_cb.has_key(id):
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
314 callback = self.current_action_ids_cb[id]
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
315 del self.current_action_ids_cb[id]
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
316 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
317 else:
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
318 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
319 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
320
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
321
0
goffi@necton2
parents:
diff changeset
322
goffi@necton2
parents:
diff changeset
323 def progressCB(self, id, title, message):
goffi@necton2
parents:
diff changeset
324 data = self.bridge.getProgress(id)
goffi@necton2
parents:
diff changeset
325 if data:
goffi@necton2
parents:
diff changeset
326 if not self.pbar:
goffi@necton2
parents:
diff changeset
327 #first answer, we must construct the bar
180
fdb961f27ae9 Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents: 120
diff changeset
328 self.pbar = wx.ProgressDialog(title, message, float(data['size']), None,
0
goffi@necton2
parents:
diff changeset
329 wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME)
180
fdb961f27ae9 Primitivus: file sending and progress management
Goffi <goffi@goffi.org>
parents: 120
diff changeset
330 self.pbar.finish_value = float(data['size'])
0
goffi@necton2
parents:
diff changeset
331
goffi@necton2
parents:
diff changeset
332 self.pbar.Update(int(data['position']))
goffi@necton2
parents:
diff changeset
333 elif self.pbar:
goffi@necton2
parents:
diff changeset
334 self.pbar.Update(self.pbar.finish_value)
goffi@necton2
parents:
diff changeset
335 return
goffi@necton2
parents:
diff changeset
336
goffi@necton2
parents:
diff changeset
337 wx.CallLater(10, self.progressCB, id, title, message)
goffi@necton2
parents:
diff changeset
338
goffi@necton2
parents:
diff changeset
339 def waitProgress (self, id, title, message):
goffi@necton2
parents:
diff changeset
340 self.pbar = None
goffi@necton2
parents:
diff changeset
341 wx.CallLater(10, self.progressCB, id, title, message)
goffi@necton2
parents:
diff changeset
342
goffi@necton2
parents:
diff changeset
343
goffi@necton2
parents:
diff changeset
344
goffi@necton2
parents:
diff changeset
345 ### events ###
goffi@necton2
parents:
diff changeset
346
goffi@necton2
parents:
diff changeset
347 def onContactActivated(self, jid):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
348 debug (_("onContactActivated: %s"), jid)
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
349 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
350 self.chat_wins[jid.short].Hide()
0
goffi@necton2
parents:
diff changeset
351 else:
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
352 self.chat_wins[jid.short].Show()
0
goffi@necton2
parents:
diff changeset
353
goffi@necton2
parents:
diff changeset
354 def onConnectRequest(self, e):
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
355 self.bridge.connect(self.profile)
0
goffi@necton2
parents:
diff changeset
356
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
357 def onDisconnectRequest(self, e):
68
9b842086d915 multiple profiles update
Goffi <goffi@goffi.org>
parents: 67
diff changeset
358 self.bridge.disconnect(self.profile)
1
a06a151fc31f Disconnect first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
359
0
goffi@necton2
parents:
diff changeset
360 def __updateStatus(self):
51
8c67ea98ab91 frontend improved to take into account new SàT features
Goffi <goffi@goffi.org>
parents: 42
diff changeset
361 show = filter(lambda x:x[1] == self.statusBox.GetValue(), const_STATUS)[0][0]
0
goffi@necton2
parents:
diff changeset
362 status = self.statusTxt.GetValue()
89
23caf1051099 multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents: 85
diff changeset
363 self.bridge.setPresence(show=show, statuses={'default':status}, profile_key=self.profile) #FIXME: manage multilingual statuses
0
goffi@necton2
parents:
diff changeset
364
goffi@necton2
parents:
diff changeset
365 def onStatusChange(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
366 debug(_("Status change request"))
0
goffi@necton2
parents:
diff changeset
367 self.__updateStatus()
goffi@necton2
parents:
diff changeset
368
goffi@necton2
parents:
diff changeset
369 def onParam(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
370 debug(_("Param request"))
105
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 103
diff changeset
371 #xmlui = self.bridge.getParamsUI(self.profile)
d2630fba8dfd params to XMLUI tools
Goffi <goffi@goffi.org>
parents: 103
diff changeset
372 #XMLUI(self, xml_data = xmlui)
22
bb72c29f3432 added action cb mechanism for buttons. Tested with a temporary new user registration button.
Goffi <goffi@goffi.org>
parents: 18
diff changeset
373 param=Param(self)
0
goffi@necton2
parents:
diff changeset
374
191
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
375 def onAbout(self, e):
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
376 about = wx.AboutDialogInfo()
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
377 about.SetName(APP_NAME)
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
378 about.SetVersion (unicode(self.bridge.getVersion()))
228
b1794cbb88e5 2011 copyright upgrade
Goffi <goffi@goffi.org>
parents: 227
diff changeset
379 about.SetCopyright(u"(C) 2009, 2010, 2011 Jérôme Poisson aka Goffi")
191
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
380 about.SetDescription( _(u"%(name)s is a SàT (Salut à Toi) frontend\n"+
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
381 u"%(name)s is based on WxPython, and is the standard graphic interface of SàT") % {'name':APP_NAME})
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
382 about.SetWebSite(("http://www.goffi.org", "Goffi's non-hebdo (french)"))
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
383 about.SetDevelopers([ "Goffi (Jérôme Poisson)"])
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
384 try:
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
385 with open(LICENCE_PATH,"r") as licence:
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
386 about.SetLicence(''.join(licence.readlines()))
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
387 except:
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
388 pass
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
389
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
390 wx.AboutBox(about)
1438a1337732 About added/updated for Wix & Jp
Goffi <goffi@goffi.org>
parents: 185
diff changeset
391
0
goffi@necton2
parents:
diff changeset
392 def onExit(self, e):
goffi@necton2
parents:
diff changeset
393 self.Close()
goffi@necton2
parents:
diff changeset
394
goffi@necton2
parents:
diff changeset
395 def onAddContact(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
396 debug(_("Add contact request"))
0
goffi@necton2
parents:
diff changeset
397 dlg = wx.TextEntryDialog(
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
398 self, _('Please enter new contact JID'),
Goffi <goffi@goffi.org>
parents: 68
diff changeset
399 _('Adding a contact'), _('name@server.tld'))
0
goffi@necton2
parents:
diff changeset
400
goffi@necton2
parents:
diff changeset
401 if dlg.ShowModal() == wx.ID_OK:
goffi@necton2
parents:
diff changeset
402 jid=JID(dlg.GetValue())
goffi@necton2
parents:
diff changeset
403 if jid.is_valid():
89
23caf1051099 multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents: 85
diff changeset
404 self.bridge.addContact(jid.short, profile_key=self.profile)
0
goffi@necton2
parents:
diff changeset
405 else:
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
406 error (_("'%s' is an invalid JID !"), jid)
0
goffi@necton2
parents:
diff changeset
407 #TODO: notice the user
goffi@necton2
parents:
diff changeset
408
goffi@necton2
parents:
diff changeset
409 dlg.Destroy()
goffi@necton2
parents:
diff changeset
410
goffi@necton2
parents:
diff changeset
411 def onRemoveContact(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
412 debug(_("Remove contact request"))
0
goffi@necton2
parents:
diff changeset
413 target = self.contactList.getSelection()
goffi@necton2
parents:
diff changeset
414 if not target:
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
415 dlg = wx.MessageDialog(self, _("You haven't selected any contact !"),
Goffi <goffi@goffi.org>
parents: 68
diff changeset
416 _('Error'),
0
goffi@necton2
parents:
diff changeset
417 wx.OK | wx.ICON_ERROR
goffi@necton2
parents:
diff changeset
418 )
goffi@necton2
parents:
diff changeset
419 dlg.ShowModal()
goffi@necton2
parents:
diff changeset
420 dlg.Destroy()
goffi@necton2
parents:
diff changeset
421 return
goffi@necton2
parents:
diff changeset
422
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
423 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
424 _('Contact suppression'),
0
goffi@necton2
parents:
diff changeset
425 wx.YES_NO | wx.ICON_QUESTION
goffi@necton2
parents:
diff changeset
426 )
goffi@necton2
parents:
diff changeset
427
goffi@necton2
parents:
diff changeset
428 if dlg.ShowModal() == wx.ID_YES:
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
429 info(_("Unsubscribing %s presence"), target.short)
89
23caf1051099 multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents: 85
diff changeset
430 self.bridge.delContact(target.short, profile_key=self.profile)
0
goffi@necton2
parents:
diff changeset
431
goffi@necton2
parents:
diff changeset
432 dlg.Destroy()
goffi@necton2
parents:
diff changeset
433
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
434 def onShowProfile(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
435 debug(_("Show contact's profile request"))
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
436 target = self.contactList.getSelection()
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
437 if not target:
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
438 dlg = wx.MessageDialog(self, _("You haven't selected any contact !"),
Goffi <goffi@goffi.org>
parents: 68
diff changeset
439 _('Error'),
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
440 wx.OK | wx.ICON_ERROR
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
441 )
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
442 dlg.ShowModal()
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
443 dlg.Destroy()
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
444 return
89
23caf1051099 multi-profile/subscription misc fixes
Goffi <goffi@goffi.org>
parents: 85
diff changeset
445 id = self.bridge.getCard(target.short, profile_key=self.profile)
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
446 self.current_action_ids.add(id)
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
447 self.current_action_ids_cb[id] = self.onProfileReceived
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
448
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
449 def onProfileReceived(self, data):
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
450 """Called when a profile is received"""
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
451 debug (_('Profile received: [%s]') % data)
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
452 profile=Profile(self, data)
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
453
72
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
454 def onJoinRoom(self, e):
f271fff3a713 MUC implementation: first draft
Goffi <goffi@goffi.org>
parents: 70
diff changeset
455 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
456 #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
457 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
458 self, _("Please enter MUC's JID"),
204
b2e1a13ed596 misc minors fixed before release
Goffi <goffi@goffi.org>
parents: 191
diff changeset
459 #_('Entering a MUC room'), 'test@conference.necton2.int')
b2e1a13ed596 misc minors fixed before release
Goffi <goffi@goffi.org>
parents: 191
diff changeset
460 _('Entering a MUC room'), 'room@muc_service.server.tld')
80
9681f18d06bd wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents: 75
diff changeset
461 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
462 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
463 if room_jid.is_valid():
405
10b4f577d0c0 MUC update to follow wokkel's MUC branch update
Goffi <goffi@goffi.org>
parents: 391
diff changeset
464 self.bridge.joinMUC(room_jid, self.profiles[self.profile]['whoami'].node, {}, self.profile)
80
9681f18d06bd wix: basic dialog to join MUC room, jid node is now displayed in conversations instead of full jid
Goffi <goffi@goffi.org>
parents: 75
diff changeset
465 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
466 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
467
25
53e921c8a357 new plugin: gateways plugin, and first implementation of findGateways
Goffi <goffi@goffi.org>
parents: 23
diff changeset
468 def onFindGateways(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
469 debug(_("Find Gateways request"))
102
94011f553cd0 misc bugfixes
Goffi <goffi@goffi.org>
parents: 101
diff changeset
470 id = self.bridge.findGateways(self.profiles[self.profile]['whoami'].domain, self.profile)
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
471 self.current_action_ids.add(id)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
472 self.current_action_ids_cb[id] = self.onGatewaysFound
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
473
42
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
474 def onGatewaysFound(self, data):
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents: 25
diff changeset
475 """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
476 target = data['__private__']['target']
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
477 del data['__private__']
874de3020e1c Initial VCard (XEP-0054) support + misc fixes
Goffi <goffi@goffi.org>
parents: 38
diff changeset
478 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
479
0
goffi@necton2
parents:
diff changeset
480 def onClose(self, e):
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
481 QuickApp.onExit(self)
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
482 info(_("Exiting..."))
183
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
483 for win in self.chat_wins:
9ee4a1d0d7fb Added auto(dis)connect params + misc
Goffi <goffi@goffi.org>
parents: 182
diff changeset
484 self.chat_wins[win].Destroy()
0
goffi@necton2
parents:
diff changeset
485 e.Skip()
11
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
486
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
487 def onTrayClick(self, e):
70
Goffi <goffi@goffi.org>
parents: 68
diff changeset
488 debug(_("Tray Click"))
11
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
489 if self.IsShown():
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
490 self.Hide()
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
491 else:
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
492 self.Show()
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
493 self.Raise()
37153f3a3dc1 wix: Tray Icon
Goffi <goffi@goffi.org>
parents: 1
diff changeset
494 e.Skip()
0
goffi@necton2
parents:
diff changeset
495