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
This commit is contained in:
parent
49437fd9c3
commit
fa38394401
1 changed files with 570 additions and 400 deletions
|
|
@ -53,7 +53,6 @@ import sys
|
|||
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 @@ class JP():
|
|||
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 @@ class JP():
|
|||
|
||||
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 @@ class JP():
|
|||
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 @@ class JP():
|
|||
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 @@ class JP():
|
|||
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 @@ class JP():
|
|||
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 @@ class JP():
|
|||
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'
|
||||
|
|
|
|||
Loading…
Reference in a new issue