Mercurial > libervia-backend
diff frontends/src/jp/jp @ 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 | b7c4bb2c0668 |
children | 3eeb6c865e4d |
line wrap: on
line diff
--- a/frontends/src/jp/jp Sun Nov 04 23:53:26 2012 +0100 +++ b/frontends/src/jp/jp Sat Nov 10 16:38:16 2012 +0100 @@ -53,7 +53,6 @@ import os from os.path import abspath, basename, dirname from optparse import OptionParser -import pdb from sat.tools.jid import JID import gobject from sat_frontends.bridge.DBus import DBusBridgeFrontend,BridgeExceptionNoService @@ -79,7 +78,7 @@ print(_(u"Can't connect to SàT backend, are you sure it's launched ?")) import sys sys.exit(1) - self.transfer_id = None + self.transfer_data = None def check_options(self): """Check command line options""" @@ -242,7 +241,7 @@ for file in self.files: if not os.path.exists(file): - error (_("File [%s] doesn't exist !") % file) + error (_(u"File [%s] doesn't exist !") % file) exit(1) if not self.options.bz2 and os.path.isdir(file): error (_("[%s] is a dir ! Please send files inside or use compression") % file) @@ -265,11 +264,11 @@ bz2.close() info(_("OK !")) path = abspath(tmpfile) - self.transfer_id = self.bridge.sendFile(full_dest_jid, path, {}, profile_key=self.profile) + self.transfer_data = self.bridge.sendFile(full_dest_jid, path, {}, profile_key=self.profile) else: for file in self.files: path = abspath(file) - self.transfer_id = self.bridge.sendFile(full_dest_jid, path, {}, profile_key=self.profile) #FIXME: show progress only for last transfer_id + self.transfer_data = self.bridge.sendFile(full_dest_jid, path, {}, profile_key=self.profile) #FIXME: show progress only for last transfer_id def _getFullJid(self, param_jid): @@ -283,8 +282,11 @@ return param_jid - def askConfirmation(self, type, id, data): + def askConfirmation(self, type, confirm_id, data, profile): """CB used for file transfer, accept files depending on parameters""" + if profile != self.profile: + debug("Ask confirmation ignored: not our profile") + return answer_data={} if type == "FILE_TRANSFER": if not self.options.wait_file: @@ -295,11 +297,11 @@ answer_data["dest_path"] = os.getcwd()+'/'+data['filename'] if self.options.force or not os.path.exists(answer_data["dest_path"]): - self.bridge.confirmationAnswer(id, True, answer_data) + self.bridge.confirmationAnswer(confirm_id, True, answer_data, profile) info(_("Accepted file [%(filename)s] from %(sender)s") % {'filename':data['filename'], 'sender':data['from']}) - self.transfer_id = id + self.transfer_data = confirm_id else: - self.bridge.confirmationAnswer(id, False, answer_data) + self.bridge.confirmationAnswer(confirm_id, False, answer_data, profile) warning(_("Refused file [%(filename)s] from %(sender)s: a file with the same name already exist") % {'filename':data['filename'], 'sender':data['from']}) @@ -316,14 +318,14 @@ fifopath = os.path.join(tmp_dir,"pipe_in") answer_data["dest_path"] = fifopath os.mkfifo(fifopath) - self.bridge.confirmationAnswer(id, True, answer_data) + self.bridge.confirmationAnswer(confirm_id, True, answer_data, profile) with open(fifopath, 'r') as f: shutil.copyfileobj(f, sys.stdout) shutil.rmtree(tmp_dir) self.loop.quit() - def actionResult(self, type, id, data): + def actionResult(self, action_type, action_id, data, profile): #FIXME info (_("FIXME: actionResult not implemented")) @@ -332,8 +334,9 @@ self.bridge.register("askConfirmation", self.askConfirmation) def progressCB(self): - if self.transfer_id: - data = self.bridge.getProgress(self.transfer_id) + if self.transfer_data: + transfer_id = self.transfer_data + data = self.bridge.getProgress(transfer_id, self.profile) if data: if not data['position']: data['position'] = '0'