comparison frontends/src/wix/main_window.py @ 538:2c4016921403

core, frontends, bridgen plugins: fixed methods which were unproperly managing multi-profiles - added profile argument to askConfirmation, actionResult, actionResultExt, entityDataUpdated, confirmationAnswer, getProgress - core, frontends: fixed calls/signals according to new bridge API - user of proper profile namespace for progression indicators and dialogs - memory: getParam* now return bool when param type is bool - memory: added getStringParam* to return string instead of typed value - core, memory, storage, quick_frontend: getHistory now manage properly multi-profiles - plugins XEP-0047, XEP-0054, XEP-0065, XEP-0077, XEP-0096; multi-profiles proper handling
author Goffi <goffi@goffi.org>
date Sat, 10 Nov 2012 16:38:16 +0100
parents 8ee9113d307b
children 3eeb6c865e4d
comparison
equal deleted inserted replaced
537:28cddc96c4ed 538:2c4016921403
221 else: 221 else:
222 self.SetStatusText(msgOFFLINE) 222 self.SetStatusText(msgOFFLINE)
223 self.tools.Disable() 223 self.tools.Disable()
224 return 224 return
225 225
226 def askConfirmation(self, type, id, data): 226 def askConfirmation(self, confirmation_type, confirmation_id, data, profile):
227 #TODO: refactor this in QuickApp 227 #TODO: refactor this in QuickApp
228 if not self.check_profile(profile):
229 return
228 debug (_("Confirmation asked")) 230 debug (_("Confirmation asked"))
229 answer_data={} 231 answer_data={}
230 if type == "FILE_TRANSFER": 232 if confirmation_type == "FILE_TRANSFER":
231 debug (_("File transfer confirmation asked")) 233 debug (_("File transfer confirmation asked"))
232 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"]}, 234 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"]},
233 _('File Request'), 235 _('File Request'),
234 wx.YES_NO | wx.ICON_QUESTION 236 wx.YES_NO | wx.ICON_QUESTION
235 ) 237 )
236 answer=dlg.ShowModal() 238 answer=dlg.ShowModal()
237 if answer==wx.ID_YES: 239 if answer==wx.ID_YES:
238 filename = wx.FileSelector(_("Where do you want to save the file ?"), flags = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) 240 filename = wx.FileSelector(_("Where do you want to save the file ?"), flags = wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
239 if filename: 241 if filename:
240 answer_data["dest_path"] = filename 242 answer_data["dest_path"] = filename
241 self.bridge.confirmationAnswer(id, True, answer_data) 243 self.bridge.confirmationAnswer(confirmation_id, True, answer_data, profile)
242 self.waitProgress(id, _("File Transfer"), _("Copying %s") % os.path.basename(filename)) 244 self.waitProgress(confirmation_id, _("File Transfer"), _("Copying %s") % os.path.basename(filename), profile)
243 else: 245 else:
244 answer = wx.ID_NO 246 answer = wx.ID_NO
245 if answer==wx.ID_NO: 247 if answer==wx.ID_NO:
246 self.bridge.confirmationAnswer(id, False, answer_data) 248 self.bridge.confirmationAnswer(confirmation_id, False, answer_data, profile)
247 249
248 dlg.Destroy() 250 dlg.Destroy()
249 251
250 elif type == "YES/NO": 252 elif confirmation_type == "YES/NO":
251 debug (_("Yes/No confirmation asked")) 253 debug (_("Yes/No confirmation asked"))
252 dlg = wx.MessageDialog(self, data["message"], 254 dlg = wx.MessageDialog(self, data["message"],
253 _('Confirmation'), 255 _('Confirmation'),
254 wx.YES_NO | wx.ICON_QUESTION 256 wx.YES_NO | wx.ICON_QUESTION
255 ) 257 )
256 answer=dlg.ShowModal() 258 answer=dlg.ShowModal()
257 if answer==wx.ID_YES: 259 if answer==wx.ID_YES:
258 self.bridge.confirmationAnswer(id, True, {}) 260 self.bridge.confirmationAnswer(confirmation_id, True, {}, profile)
259 if answer==wx.ID_NO: 261 if answer==wx.ID_NO:
260 self.bridge.confirmationAnswer(id, False, {}) 262 self.bridge.confirmationAnswer(confirmation_id, False, {}, profile)
261 263
262 dlg.Destroy() 264 dlg.Destroy()
263 265
264 def actionResult(self, type, id, data): 266 def actionResult(self, type, id, data, profile):
267 if not self.check_profile(profile):
268 return
265 debug (_("actionResult: type = [%(type)s] id = [%(id)s] data = [%(data)s]") % {'type':type, 'id':id, 'data':data}) 269 debug (_("actionResult: type = [%(type)s] id = [%(id)s] data = [%(data)s]") % {'type':type, 'id':id, 'data':data})
266 if not id in self.current_action_ids: 270 if not id in self.current_action_ids:
267 debug (_('unknown id, ignoring')) 271 debug (_('unknown id, ignoring'))
268 return 272 return
269 if type == "SUPPRESS": 273 if type == "SUPPRESS":
311 error (_("FIXME FIXME FIXME: type [%s] not implemented") % type) 315 error (_("FIXME FIXME FIXME: type [%s] not implemented") % type)
312 raise NotImplementedError 316 raise NotImplementedError
313 317
314 318
315 319
316 def progressCB(self, id, title, message): 320 def progressCB(self, progress_id, title, message, profile):
317 data = self.bridge.getProgress(id) 321 data = self.bridge.getProgress(progress_id, profile)
318 if data: 322 if data:
319 if not self.pbar: 323 if not self.pbar:
320 #first answer, we must construct the bar 324 #first answer, we must construct the bar
321 self.pbar = wx.ProgressDialog(title, message, float(data['size']), None, 325 self.pbar = wx.ProgressDialog(title, message, float(data['size']), None,
322 wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME) 326 wx.PD_SMOOTH | wx.PD_ELAPSED_TIME | wx.PD_ESTIMATED_TIME | wx.PD_REMAINING_TIME)
325 self.pbar.Update(int(data['position'])) 329 self.pbar.Update(int(data['position']))
326 elif self.pbar: 330 elif self.pbar:
327 self.pbar.Update(self.pbar.finish_value) 331 self.pbar.Update(self.pbar.finish_value)
328 return 332 return
329 333
330 wx.CallLater(10, self.progressCB, id, title, message) 334 wx.CallLater(10, self.progressCB, progress_id, title, message, profile)
331 335
332 def waitProgress (self, id, title, message): 336 def waitProgress (self, progress_id, title, message, profile):
333 self.pbar = None 337 self.pbar = None
334 wx.CallLater(10, self.progressCB, id, title, message) 338 wx.CallLater(10, self.progressCB, progress_id, title, message, profile)
335 339
336 340
337 341
338 ### events ### 342 ### events ###
339 343