annotate frontends/wix/gateways.py @ 62:93cb45a7420f

SàT multi-profile: connection using profiles - /!\ plugins are temporarly deactivated
author Goffi <goffi@goffi.org>
date Fri, 29 Jan 2010 13:55:41 +1100
parents a5b5fb5fc9fd
children 8f2ed279784b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
3
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
4 """
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
5 wix: a SAT frontend
57
a5b5fb5fc9fd updated README and copyright note
Goffi <goffi@goffi.org>
parents: 39
diff changeset
6 Copyright (C) 2009, 2010 Jérôme Poisson (goffi@goffi.org)
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
7
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
9 it under the terms of the GNU General Public License as published by
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
11 (at your option) any later version.
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
12
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
16 GNU General Public License for more details.
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
17
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
20 """
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
21
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
22
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
23
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
24 import wx
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
25 import pdb
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from xml.dom import minidom
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from logging import debug, info, error
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from tools.jid import JID
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
29
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
30 WARNING_MSG = u"""Be careful ! Gateways allow you to use an external IM (legacy IM), so you can see your contact as jabber contacts.
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
31 But when you do this, all your messages go throught the external legacy IM server, it is a huge privacy issue (i.e.: all your messages throught the gateway can be monitored, recorded, analyzed by the external server, most of time a private company)."""
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
32
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
33 class GatewaysManager(wx.Frame):
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
34 def __init__(self, host, gateways, title="Gateways manager", server=None):
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
35 super(GatewaysManager, self).__init__(None, title=title)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
36
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
37 self.host = host
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
38 if server:
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
39 self.SetTitle(title+" (%s)" % server)
29
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
40
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
41 #Fonts
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
42 self.normal_font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
43 self.bold_font = wx.Font(8, wx.DEFAULT, wx.NORMAL, wx.BOLD)
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
44 self.italic_font = wx.Font(8, wx.DEFAULT, wx.FONTSTYLE_ITALIC, wx.NORMAL)
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
45 self.button_font = wx.Font(6, wx.DEFAULT, wx.NORMAL, wx.BOLD)
29
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
46
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
47
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
48 self.modified = {} # dict of modified data (i.e. what we have to save)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
49 self.ctl_list = {} # usefull to access ctrl, key = (name, category)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
50
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
51 self.sizer = wx.BoxSizer(wx.VERTICAL)
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
52 warning = wx.TextCtrl(self, -1, value=WARNING_MSG, style = wx.TE_MULTILINE |
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
53 wx.TE_READONLY |
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
54 wx.TE_LEFT)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
55 warning.SetFont(self.bold_font)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
56 self.sizer.Add(warning, 0, wx.EXPAND)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
57 warning.ShowPosition(0)
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
58 self.panel = wx.Panel(self)
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
59 self.panel.sizer = wx.FlexGridSizer(cols=5)
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
60 self.panel.SetSizer(self.panel.sizer)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
61 self.panel.SetAutoLayout(True)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
62 self.sizer.Add(self.panel, 1, flag=wx.EXPAND)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
63 self.SetSizer(self.sizer)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
64 self.SetAutoLayout(True)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
65
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
66 #events
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
67 self.Bind(wx.EVT_CLOSE, self.onClose, self)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
68
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
69 self.MakeModal()
29
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
70 self.panel.sizer.Add(wx.Window(self.panel, -1))
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
71 title_name = wx.StaticText(self.panel, -1, "Name")
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
72 title_name.SetFont(self.bold_font)
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
73 title_type = wx.StaticText(self.panel, -1, "Type")
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
74 title_type.SetFont(self.bold_font)
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
75 self.panel.sizer.Add(title_name)
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
76 self.panel.sizer.Add(title_type)
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
77 self.panel.sizer.Add(wx.Window(self.panel, -1))
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
78 self.panel.sizer.Add(wx.Window(self.panel, -1))
29
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
79
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
80 for gateway in gateways:
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
81 self.addGateway(gateway, gateways[gateway])
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
82
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
83 self.ext_server_panel = wx.Panel(self)
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
84 self.ext_server_panel.sizer = wx.BoxSizer(wx.HORIZONTAL)
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
85 self.ext_server_panel.SetSizer(self.ext_server_panel.sizer)
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
86 self.ext_server_panel.SetAutoLayout(True)
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
87 self.sizer.Add(self.ext_server_panel, 0, flag=wx.EXPAND)
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
88
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
89 ext_server_label = wx.StaticText(self.ext_server_panel, -1, "Use external XMPP server: ")
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
90 ext_server_label.SetFont(wx.ITALIC_FONT)
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
91 self.ext_server_text = wx.TextCtrl(self.ext_server_panel, -1)
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
92 ext_server_button = wx.Button(self.ext_server_panel, -1, "GO !")
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
93 self.ext_server_panel.Bind(wx.EVT_BUTTON, self.browseExternalServer, ext_server_button)
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
94
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
95 self.ext_server_panel.sizer.Add(ext_server_label)
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
96 self.ext_server_panel.sizer.Add(self.ext_server_text, 1, flag=wx.EXPAND)
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
97 self.ext_server_panel.sizer.Add(ext_server_button)
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
98
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
99 #self.panel.sizer.Fit(self)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
100 self.sizer.Fit(self)
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
101
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
102 self.Show()
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
103
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
104 def browseExternalServer(self, event):
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
105 """Open the gateway manager on given server"""
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
106 server = self.ext_server_text.GetValue()
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
107 debug("Opening gateways manager on [%s]" % server)
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
108 id = self.host.bridge.findGateways(server)
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
109 self.host.current_action_ids.add(id)
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
110 self.host.current_action_ids_cb[id] = self.host.onGatewaysFound
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
111 self.MakeModal(False)
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
112 self.Destroy()
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
113
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
114
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
115 def addGateway(self, gateway, param):
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
116
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
117
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
118
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
119 #First The icon
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
120 isz = (16,16)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
121 im_icon = wx.StaticBitmap(self.panel, -1, wx.ArtProvider.GetBitmap(wx.ART_GO_FORWARD, wx.ART_TOOLBAR, isz))
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
122
29
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
123 #Then the name
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
124
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
125 label=wx.StaticText(self.panel, -1, param['name'])
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
126 label.SetFont(self.normal_font)
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
127
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
128 #Then the transport type message
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
129
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
130 type_label_txt = 'Unknown IM'
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
131
29
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
132 if param['type'] == 'irc':
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
133 type_label_txt = "Internet Relay Chat"
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
134 elif param['type'] == 'xmpp':
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
135 type_label_txt = "XMPP"
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
136 elif param['type'] == 'qq':
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
137 type_label_txt = "Tencent QQ"
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
138 elif param['type'] == 'simple':
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
139 type_label_txt = "SIP/SIMPLE"
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
140 elif param['type'] == 'icq':
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
141 type_label_txt = "ICQ"
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
142 elif param['type'] == 'yahoo':
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
143 type_label_txt = "Yahoo! Messenger"
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
144 elif param['type'] == 'gadu-gadu':
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
145 type_label_txt = "Gadu-Gadu"
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
146 elif param['type'] == 'aim':
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
147 type_label_txt = "AOL Instant Messenger"
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
148 elif param['type'] == 'msn':
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
149 type_label_txt = 'Windows Live Messenger'
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
150
29
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
151 type_label_txt = type_label_txt
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
152
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
153 type_label = wx.StaticText(self.panel, -1, type_label_txt)
29
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
154 type_label.SetFont(self.italic_font)
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
155
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
156 #The buttons
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents: 29
diff changeset
157 def register_cb(event):
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents: 29
diff changeset
158 """Called when register button is clicked"""
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents: 29
diff changeset
159 gateway_jid = event.GetEventObject().gateway_jid
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents: 29
diff changeset
160 id = self.host.bridge.in_band_register(gateway_jid)
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents: 29
diff changeset
161 self.host.current_action_ids.add(id)
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents: 29
diff changeset
162 print "register id:",id
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
163 self.MakeModal(False)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
164 self.Destroy()
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents: 29
diff changeset
165
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
166 def unregister_cb(event):
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
167 """Called when unregister button is clicked"""
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
168 gateway_jid = event.GetEventObject().gateway_jid
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
169 id = self.host.bridge.gatewayRegister("CANCEL",gateway_jid, None)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
170 self.host.current_action_ids.add(id)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
171 print "unregister id:",id
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
172 self.MakeModal(False)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
173 self.Destroy()
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
174
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
175 reg_button = wx.Button(self.panel, -1, "Register", size=wx.Size(-1, 8))
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
176 reg_button.SetFont(self.button_font)
30
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents: 29
diff changeset
177 reg_button.gateway_jid = JID(gateway)
d6b613764dd7 new plugin for xep 0077 (In-Band registration): first draft
Goffi <goffi@goffi.org>
parents: 29
diff changeset
178 self.panel.Bind(wx.EVT_BUTTON, register_cb, reg_button)
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
179 unreg_button = wx.Button(self.panel, -1, "Unregister", size=wx.Size(-1, 8))
39
2e3411a6baad Wix: external server management in gateways manager, SàT: bug fixes in gateway management
Goffi <goffi@goffi.org>
parents: 37
diff changeset
180 unreg_button.SetFont(self.button_font)
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
181 unreg_button.gateway_jid = JID(gateway)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
182 self.panel.Bind(wx.EVT_BUTTON, unregister_cb, unreg_button)
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
183
29
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
184 self.panel.sizer.Add(im_icon)
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
185 self.panel.sizer.Add(label)
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
186 self.panel.sizer.Add(type_label)
df3b0b5ac49e Wix: gateways manager => better presentation
Goffi <goffi@goffi.org>
parents: 28
diff changeset
187 self.panel.sizer.Add(reg_button, 1, wx.EXPAND)
37
a61beb21d16d Gateway registration, unregistration & edition
Goffi <goffi@goffi.org>
parents: 35
diff changeset
188 self.panel.sizer.Add(unreg_button, 1, wx.EXPAND)
28
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
189
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
190
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
191 def onClose(self, event):
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
192 """Close event"""
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
193 debug("close")
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
194 self.MakeModal(False)
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
195 event.Skip()
c2b131e4e262 wix: new gateways manager
Goffi <goffi@goffi.org>
parents:
diff changeset
196