added JingleFileTransfer for managing jingle ft content
code added to trigger jingle ft session when needed
This commit is contained in:
parent
b7048aa0da
commit
048feb5528
|
@ -38,10 +38,10 @@ import logging
|
|||
log = logging.getLogger('gajim.c.caps_cache')
|
||||
|
||||
from common.xmpp import (NS_XHTML_IM, NS_RECEIPTS, NS_ESESSION, NS_CHATSTATES,
|
||||
NS_JINGLE_ICE_UDP, NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO, NS_CAPS)
|
||||
NS_JINGLE_ICE_UDP, NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO, NS_CAPS, NS_JINGLE_FILE_TRANSFER)
|
||||
# Features where we cannot safely assume that the other side supports them
|
||||
FEATURE_BLACKLIST = [NS_CHATSTATES, NS_XHTML_IM, NS_RECEIPTS, NS_ESESSION,
|
||||
NS_JINGLE_ICE_UDP, NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO]
|
||||
NS_JINGLE_ICE_UDP, NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO, NS_JINGLE_FILE_TRANSFER]
|
||||
|
||||
# Query entry status codes
|
||||
NEW = 0
|
||||
|
|
|
@ -35,7 +35,10 @@ import helpers
|
|||
|
||||
from jingle_session import JingleSession, JingleStates
|
||||
from jingle_rtp import JingleAudio, JingleVideo
|
||||
from jingle_ft import JingleFileTransfer
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('gajim.c.jingle')
|
||||
|
||||
class ConnectionJingle(object):
|
||||
"""
|
||||
|
@ -124,6 +127,18 @@ class ConnectionJingle(object):
|
|||
jingle.start_session()
|
||||
return jingle.sid
|
||||
|
||||
def start_file_transfer(self, jid, file_props):
|
||||
logger.info("start file transfer with file: %s", str(file_props))
|
||||
jingle = self.get_jingle_session(jid, media='file')
|
||||
if jingle:
|
||||
jingle.add_content('file', JingleFileTransfer(jingle, file_props))
|
||||
else:
|
||||
jingle = JingleSession(self, weinitiate=True, jid=jid)
|
||||
self.__sessions[jingle.sid] = jingle
|
||||
jingle.add_content('file', JingleFileTransfer(jingle, file_props))
|
||||
jingle.start_session()
|
||||
return jingle.sid
|
||||
|
||||
|
||||
def iter_jingle_sessions(self, jid, sid=None, media=None):
|
||||
if sid:
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
# -*- coding:utf-8 -*-
|
||||
## This file is part of Gajim.
|
||||
##
|
||||
## Gajim is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published
|
||||
## by the Free Software Foundation; version 3 only.
|
||||
##
|
||||
## Gajim is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
|
||||
"""
|
||||
Handles Jingle File Transfer (XEP 0234)
|
||||
"""
|
||||
|
||||
import gajim
|
||||
import xmpp
|
||||
from jingle_content import contents, JingleContent
|
||||
from jingle_transport import JingleTransportICEUDP
|
||||
import logging
|
||||
|
||||
log = logging.getLogger('gajim.c.jingle_ft')
|
||||
|
||||
|
||||
class JingleFileTransfer(JingleContent):
|
||||
def __init__(self, session, file_props, transport=None):
|
||||
JingleContent.__init__(self, session, transport)
|
||||
|
||||
#events we might be interested in
|
||||
self.callbacks['session-initiate'] += [self.__on_session_initiate]
|
||||
self.callbacks['session-accept'] += [self.__on_session_accept]
|
||||
self.callbacks['session-terminate'] += [self.__on_session_terminate]
|
||||
self.callbacks['transport-accept'] += [self.__on_transport_accept]
|
||||
self.callbacks['transport-replace'] += [self.__on_transport_replace] #fallback transport method
|
||||
self.callbacks['transport-reject'] += [self.__on_transport_reject]
|
||||
self.callbacks['transport-info'] += [self.__on_transport_info]
|
||||
|
||||
self.file_props = file_props
|
||||
|
||||
if transport == None:
|
||||
self.transport = JingleTransportICEUDP()
|
||||
|
||||
def __on_session_initiate(self, stanza, content, error, action):
|
||||
log.info("__on_session_initiate")
|
||||
pass
|
||||
|
||||
def __on_session_accept(self, stanza, content, error, action):
|
||||
log.info("__on_session_accept")
|
||||
pass
|
||||
|
||||
def __on_session_terminate(self, stanza, content, error, action):
|
||||
log.info("__on_session_terminate")
|
||||
pass
|
||||
|
||||
def __on_transport_accept(self, stanza, content, error, action):
|
||||
log.info("__on_transport_accept")
|
||||
pass
|
||||
|
||||
def __on_transport_replace(self, stanza, content, error, action):
|
||||
log.info("__on_transport_replace")
|
||||
pass
|
||||
|
||||
def __on_transport_reject(self, stanza, content, error, action):
|
||||
log.info("__on_transport_reject")
|
||||
pass
|
||||
|
||||
def __on_transport_info(self, stanza, content, error, action):
|
||||
log.info("__on_transport_info")
|
||||
pass
|
||||
|
||||
def _fill_content(self, content):
|
||||
content.addChild("description", namespace = xmpp.NS_JINGLE_FILE_TRANSFER)
|
|
@ -305,9 +305,10 @@ class FileTransfersWindow:
|
|||
self.add_transfer(account, contact, file_props)
|
||||
if contact.supports(NS_JINGLE_FILE_TRANSFER):
|
||||
log.info("contact supports jingle file transfer")
|
||||
gajim.connections[account].start_file_transfer(contact.get_full_jid(), file_props)
|
||||
else:
|
||||
log.info("contact does not support jingle file transfer")
|
||||
gajim.connections[account].send_file_request(file_props)
|
||||
gajim.connections[account].send_file_request(file_props)
|
||||
return True
|
||||
|
||||
def _start_receive(self, file_path, account, contact, file_props):
|
||||
|
|
Loading…
Reference in New Issue