send files to gc peer. Fixes #7171
This commit is contained in:
parent
cfb49bb4ec
commit
ccb53c7c08
|
@ -1722,8 +1722,9 @@ class ChatControl(ChatControlBase):
|
||||||
self._video_button.set_sensitive(self.video_available)
|
self._video_button.set_sensitive(self.video_available)
|
||||||
|
|
||||||
# Send file
|
# Send file
|
||||||
if (self.contact.supports(NS_FILE) or self.contact.supports(NS_JINGLE_FILE_TRANSFER)) and (self.type_id == 'chat' or \
|
if (self.contact.supports(NS_FILE) or \
|
||||||
self.gc_contact.resource):
|
self.contact.supports(NS_JINGLE_FILE_TRANSFER)) or \
|
||||||
|
self.type_id == 'chat' or self.gc_contact.resource:
|
||||||
self._send_file_button.set_sensitive(True)
|
self._send_file_button.set_sensitive(True)
|
||||||
self._send_file_button.set_tooltip_text('')
|
self._send_file_button.set_tooltip_text('')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -28,10 +28,13 @@
|
||||||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
##
|
##
|
||||||
|
|
||||||
|
try:
|
||||||
from common import caps_cache
|
from common import caps_cache
|
||||||
from common.account import Account
|
from common.account import Account
|
||||||
import common.gajim
|
import common.gajim
|
||||||
|
except ImportError, e:
|
||||||
|
if __name__ != "__main__":
|
||||||
|
raise ImportError(e)
|
||||||
|
|
||||||
class XMPPEntity(object):
|
class XMPPEntity(object):
|
||||||
"""
|
"""
|
||||||
|
@ -411,6 +414,9 @@ class LegacyContactsAPI:
|
||||||
def get_gc_contact(self, account, room_jid, nick):
|
def get_gc_contact(self, account, room_jid, nick):
|
||||||
return self._accounts[account].gc_contacts.get_gc_contact(room_jid, nick)
|
return self._accounts[account].gc_contacts.get_gc_contact(room_jid, nick)
|
||||||
|
|
||||||
|
def is_gc_contact(self, account, jid):
|
||||||
|
return self._accounts[account].gc_contacts.is_gc_contact(jid)
|
||||||
|
|
||||||
def get_nb_role_total_gc_contacts(self, account, room_jid, role):
|
def get_nb_role_total_gc_contacts(self, account, room_jid, role):
|
||||||
return self._accounts[account].gc_contacts.get_nb_role_total_gc_contacts(room_jid, role)
|
return self._accounts[account].gc_contacts.get_nb_role_total_gc_contacts(room_jid, role)
|
||||||
|
|
||||||
|
@ -564,6 +570,21 @@ class GC_Contacts():
|
||||||
return None
|
return None
|
||||||
return self._rooms[room_jid][nick]
|
return self._rooms[room_jid][nick]
|
||||||
|
|
||||||
|
def is_gc_contact(self, jid):
|
||||||
|
"""
|
||||||
|
>>> gc = GC_Contacts()
|
||||||
|
>>> gc._rooms = {'gajim@conference.gajim.org' : {'test' : True}}
|
||||||
|
>>> gc.is_gc_contact('gajim@conference.gajim.org/test')
|
||||||
|
True
|
||||||
|
>>> gc.is_gc_contact('test@jabbim.com')
|
||||||
|
False
|
||||||
|
"""
|
||||||
|
jid = jid.split('/')
|
||||||
|
if len(jid) != 2:
|
||||||
|
return False
|
||||||
|
gcc = self.get_gc_contact(jid[0], jid[1])
|
||||||
|
return gcc != None
|
||||||
|
|
||||||
def get_nb_role_total_gc_contacts(self, room_jid, role):
|
def get_nb_role_total_gc_contacts(self, room_jid, role):
|
||||||
"""
|
"""
|
||||||
Return the number of group chat contacts for the given role and the total
|
Return the number of group chat contacts for the given role and the total
|
||||||
|
@ -827,3 +848,8 @@ class MetacontactManager():
|
||||||
"""
|
"""
|
||||||
family.sort(cmp=self._compare_metacontacts)
|
family.sort(cmp=self._compare_metacontacts)
|
||||||
return family[-1]
|
return family[-1]
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
import doctest
|
||||||
|
doctest.testmod()
|
||||||
|
|
|
@ -145,6 +145,10 @@ class ConnectionJingle(object):
|
||||||
logger.info("start file transfer with file: %s" % file_props)
|
logger.info("start file transfer with file: %s" % file_props)
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(self.name,
|
contact = gajim.contacts.get_contact_with_highest_priority(self.name,
|
||||||
gajim.get_jid_without_resource(jid))
|
gajim.get_jid_without_resource(jid))
|
||||||
|
if gajim.contacts.is_gc_contact(self.name,jid):
|
||||||
|
gcc = jid.split('/')
|
||||||
|
if len(gcc) == 2:
|
||||||
|
contact = gajim.contacts.get_gc_contact(self.name, gcc[0], gcc[1])
|
||||||
if contact is None:
|
if contact is None:
|
||||||
return
|
return
|
||||||
use_security = contact.supports(xmpp.NS_JINGLE_XTLS)
|
use_security = contact.supports(xmpp.NS_JINGLE_XTLS)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
Handles Jingle File Transfer (XEP 0234)
|
Handles Jingle File Transfer (XEP 0234)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import hashlib
|
||||||
import gajim
|
import gajim
|
||||||
import xmpp
|
import xmpp
|
||||||
from jingle_content import contents, JingleContent
|
from jingle_content import contents, JingleContent
|
||||||
|
@ -97,7 +98,13 @@ class JingleFileTransfer(JingleContent):
|
||||||
self.session = session
|
self.session = session
|
||||||
self.media = 'file'
|
self.media = 'file'
|
||||||
self.nominated_cand = {}
|
self.nominated_cand = {}
|
||||||
|
if gajim.contacts.is_gc_contact(session.connection.name,
|
||||||
|
session.peerjid):
|
||||||
|
roomjid = session.peerjid.split('/')[0]
|
||||||
|
dstaddr = hashlib.sha1('%s%s%s' % (self.file_props['sid'],
|
||||||
|
session.ourjid,
|
||||||
|
roomjid)).hexdigest()
|
||||||
|
self.file_props['dstaddr'] = dstaddr
|
||||||
self.state = STATE_NOT_STARTED
|
self.state = STATE_NOT_STARTED
|
||||||
self.states = {STATE_INITIALIZED : StateInitialized(self),
|
self.states = {STATE_INITIALIZED : StateInitialized(self),
|
||||||
STATE_CAND_SENT : StateCandSent(self),
|
STATE_CAND_SENT : StateCandSent(self),
|
||||||
|
|
|
@ -132,6 +132,8 @@ class JingleTransportSocks5(JingleTransport):
|
||||||
transport = xmpp.Node('transport')
|
transport = xmpp.Node('transport')
|
||||||
transport.setNamespace(xmpp.NS_JINGLE_BYTESTREAM)
|
transport.setNamespace(xmpp.NS_JINGLE_BYTESTREAM)
|
||||||
transport.setAttr('sid', self.sid)
|
transport.setAttr('sid', self.sid)
|
||||||
|
if 'dstaddr' in self.file_props:
|
||||||
|
transport.setAttr('dstaddr', self.file_props['dstaddr'])
|
||||||
return transport
|
return transport
|
||||||
|
|
||||||
def parse_transport_stanza(self, transport):
|
def parse_transport_stanza(self, transport):
|
||||||
|
|
Loading…
Reference in New Issue