Mercurial > libervia-backend
comparison frontends/wix/gateways.py @ 37:a61beb21d16d
Gateway registration, unregistration & edition
- default values added in form
- DBus bridge: fixed array of struct management when adding dynamically a method
- fixed doc for some methods
- ugly fix for presence status
- added dependency for XEP-0077 in XEP-0100 plugin
- Wix: added unregister button in gateways manager
- Wix: added privacy warning in gateways manager
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 15 Dec 2009 01:27:32 +1100 |
parents | c45deebb40a5 |
children | 2e3411a6baad |
comparison
equal
deleted
inserted
replaced
36:6491b7956c80 | 37:a61beb21d16d |
---|---|
25 import pdb | 25 import pdb |
26 from xml.dom import minidom | 26 from xml.dom import minidom |
27 from logging import debug, info, error | 27 from logging import debug, info, error |
28 from tools.jid import JID | 28 from tools.jid import JID |
29 | 29 |
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. | |
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).""" | |
30 | 32 |
31 class GatewaysManager(wx.Frame): | 33 class GatewaysManager(wx.Frame): |
32 def __init__(self, host, gateways, title="Gateways manager"): | 34 def __init__(self, host, gateways, title="Gateways manager"): |
33 super(GatewaysManager, self).__init__(None, title=title) | 35 super(GatewaysManager, self).__init__(None, title=title) |
34 | 36 |
42 | 44 |
43 self.modified = {} # dict of modified data (i.e. what we have to save) | 45 self.modified = {} # dict of modified data (i.e. what we have to save) |
44 self.ctl_list = {} # usefull to access ctrl, key = (name, category) | 46 self.ctl_list = {} # usefull to access ctrl, key = (name, category) |
45 | 47 |
46 self.sizer = wx.BoxSizer(wx.VERTICAL) | 48 self.sizer = wx.BoxSizer(wx.VERTICAL) |
49 warning = wx.TextCtrl(self, -1, value=WARNING_MSG, style = wx.TE_MULTILINE | | |
50 wx.TE_READONLY | | |
51 wx.TE_LEFT) | |
52 warning.SetFont(self.bold_font) | |
53 self.sizer.Add(warning, 0, wx.EXPAND) | |
54 warning.ShowPosition(0) | |
47 self.panel = wx.Panel(self) | 55 self.panel = wx.Panel(self) |
48 self.panel.sizer = wx.FlexGridSizer(cols=4) | 56 self.panel.sizer = wx.FlexGridSizer(cols=5) |
49 self.panel.SetSizer(self.panel.sizer) | 57 self.panel.SetSizer(self.panel.sizer) |
50 self.panel.SetAutoLayout(True) | 58 self.panel.SetAutoLayout(True) |
51 self.sizer.Add(self.panel, 1, flag=wx.EXPAND) | 59 self.sizer.Add(self.panel, 1, flag=wx.EXPAND) |
52 self.SetSizer(self.sizer) | 60 self.SetSizer(self.sizer) |
53 self.SetAutoLayout(True) | 61 self.SetAutoLayout(True) |
62 title_type = wx.StaticText(self.panel, -1, "Type") | 70 title_type = wx.StaticText(self.panel, -1, "Type") |
63 title_type.SetFont(self.bold_font) | 71 title_type.SetFont(self.bold_font) |
64 self.panel.sizer.Add(title_name) | 72 self.panel.sizer.Add(title_name) |
65 self.panel.sizer.Add(title_type) | 73 self.panel.sizer.Add(title_type) |
66 self.panel.sizer.Add(wx.Window(self.panel, -1)) | 74 self.panel.sizer.Add(wx.Window(self.panel, -1)) |
75 self.panel.sizer.Add(wx.Window(self.panel, -1)) | |
67 | 76 |
68 for gateway in gateways: | 77 for gateway in gateways: |
69 self.addGateway(gateway, gateways[gateway]) | 78 self.addGateway(gateway, gateways[gateway]) |
70 | 79 |
71 | 80 |
72 self.panel.sizer.Fit(self) | 81 #self.panel.sizer.Fit(self) |
82 self.sizer.Fit(self) | |
73 | 83 |
74 self.Show() | 84 self.Show() |
75 | 85 |
76 def addGateway(self, gateway, param): | 86 def addGateway(self, gateway, param): |
77 | 87 |
119 """Called when register button is clicked""" | 129 """Called when register button is clicked""" |
120 gateway_jid = event.GetEventObject().gateway_jid | 130 gateway_jid = event.GetEventObject().gateway_jid |
121 id = self.host.bridge.in_band_register(gateway_jid) | 131 id = self.host.bridge.in_band_register(gateway_jid) |
122 self.host.current_action_ids.add(id) | 132 self.host.current_action_ids.add(id) |
123 print "register id:",id | 133 print "register id:",id |
134 self.MakeModal(False) | |
135 self.Destroy() | |
124 event.Skip() | 136 event.Skip() |
125 | 137 |
138 def unregister_cb(event): | |
139 """Called when unregister button is clicked""" | |
140 gateway_jid = event.GetEventObject().gateway_jid | |
141 id = self.host.bridge.gatewayRegister("CANCEL",gateway_jid, None) | |
142 self.host.current_action_ids.add(id) | |
143 print "unregister id:",id | |
144 self.MakeModal(False) | |
145 self.Destroy() | |
146 event.Skip() | |
147 | |
126 button_font = wx.Font(6, wx.DEFAULT, wx.NORMAL, wx.BOLD) | 148 button_font = wx.Font(6, wx.DEFAULT, wx.NORMAL, wx.BOLD) |
127 reg_button = wx.Button(self.panel, -1, "Register", size=wx.Size(-1, 8)) | 149 reg_button = wx.Button(self.panel, -1, "Register", size=wx.Size(-1, 8)) |
128 reg_button.SetFont(button_font) | 150 reg_button.SetFont(button_font) |
129 reg_button.gateway_jid = JID(gateway) | 151 reg_button.gateway_jid = JID(gateway) |
130 self.panel.Bind(wx.EVT_BUTTON, register_cb, reg_button) | 152 self.panel.Bind(wx.EVT_BUTTON, register_cb, reg_button) |
131 | 153 unreg_button = wx.Button(self.panel, -1, "Unregister", size=wx.Size(-1, 8)) |
154 unreg_button.SetFont(button_font) | |
155 unreg_button.gateway_jid = JID(gateway) | |
156 self.panel.Bind(wx.EVT_BUTTON, unregister_cb, unreg_button) | |
157 | |
132 self.panel.sizer.Add(im_icon) | 158 self.panel.sizer.Add(im_icon) |
133 self.panel.sizer.Add(label) | 159 self.panel.sizer.Add(label) |
134 self.panel.sizer.Add(type_label) | 160 self.panel.sizer.Add(type_label) |
135 self.panel.sizer.Add(reg_button, 1, wx.EXPAND) | 161 self.panel.sizer.Add(reg_button, 1, wx.EXPAND) |
162 self.panel.sizer.Add(unreg_button, 1, wx.EXPAND) | |
136 | 163 |
137 | 164 |
138 def onClose(self, event): | 165 def onClose(self, event): |
139 """Close event""" | 166 """Close event""" |
140 debug("close") | 167 debug("close") |
141 #now we save the modifier params | |
142 self.MakeModal(False) | 168 self.MakeModal(False) |
143 event.Skip() | 169 event.Skip() |
144 | 170 |