merged changes from origin/hacks
This commit is contained in:
commit
d381ab320a
52
sleekxmpp/plugins/xep_0047.py
Normal file
52
sleekxmpp/plugins/xep_0047.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
'''
|
||||||
|
Created on Jul 1, 2010
|
||||||
|
|
||||||
|
@author: bbeggs
|
||||||
|
'''
|
||||||
|
from . import base
|
||||||
|
import logging
|
||||||
|
import threading
|
||||||
|
from xml.etree import cElementTree as ET
|
||||||
|
|
||||||
|
class xep_0047(base.base_plugin):
|
||||||
|
'''
|
||||||
|
In-band file transfer for xmpp.
|
||||||
|
|
||||||
|
Both message and iq transfer is supported with message being attempted first.
|
||||||
|
'''
|
||||||
|
|
||||||
|
def plugin_init(self):
|
||||||
|
self.xep = 'xep-047'
|
||||||
|
self.description = 'in-band file transfer'
|
||||||
|
self.acceptTransfers = self.config.get('acceptTransfers', True)
|
||||||
|
self.saveDirectory = self.config.get('saveDirectory', '/tmp')
|
||||||
|
self.stanzaType = self.config.get('stanzaType', 'message')
|
||||||
|
self.maxSendThreads = self.config.get('maxSendThreads', 1)
|
||||||
|
self.maxReceiveThreads = self.config.get('maxReceiveThreads', 1)
|
||||||
|
|
||||||
|
#thread setup
|
||||||
|
self.receiveThreads = {} #id:thread
|
||||||
|
self.sendThreads = {}
|
||||||
|
|
||||||
|
#add handlers to listen for incoming requests
|
||||||
|
self.xmpp.add_handler("<iq><open xmlns='http://jabber.org/protocol/ibb' /></iq>", self._handleIncomingTransferRequest)
|
||||||
|
|
||||||
|
def post_init(self):
|
||||||
|
self.post_inited = True
|
||||||
|
|
||||||
|
|
||||||
|
def sendFile(self, filePath, threaded=True):
|
||||||
|
#TODO use this method to send a file
|
||||||
|
pass
|
||||||
|
|
||||||
|
def _handleIncomingTransferRequest(self, xml):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class receiverThread(threading.Thread):
|
||||||
|
def run(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class senderThread(threading.Thread):
|
||||||
|
def run(self):
|
||||||
|
pass
|
||||||
|
|
@ -226,7 +226,6 @@ class XMLStream(object):
|
|||||||
# TODO currently this will re-send a stream header if this exception occurs.
|
# TODO currently this will re-send a stream header if this exception occurs.
|
||||||
# I don't think that's intended behavior.
|
# I don't think that's intended behavior.
|
||||||
logging.warn('socket rcv timeout')
|
logging.warn('socket rcv timeout')
|
||||||
pass
|
|
||||||
except RestartStream:
|
except RestartStream:
|
||||||
logging.debug("Restarting stream...")
|
logging.debug("Restarting stream...")
|
||||||
continue # DON'T re-initialize the stream -- this exception is sent
|
continue # DON'T re-initialize the stream -- this exception is sent
|
||||||
@ -238,12 +237,9 @@ class XMLStream(object):
|
|||||||
except:
|
except:
|
||||||
logging.exception('Unexpected error in RCV thread')
|
logging.exception('Unexpected error in RCV thread')
|
||||||
|
|
||||||
# if the RCV socket is terminated for whatever reason, our only sane choice of action is an attempt
|
# if the RCV socket is terminated for whatever reason (e.g. we reach this point of
|
||||||
# to re-establish the connection.
|
# code,) our only sane choice of action is an attempt to re-establish the connection.
|
||||||
if not self.quit.is_set():
|
if not self.quit.is_set():
|
||||||
logging.info( 'about to reconnect..........' )
|
|
||||||
logging.info( 'about to reconnect..........' )
|
|
||||||
logging.info( 'about to reconnect..........' )
|
|
||||||
logging.info( 'about to reconnect..........' )
|
logging.info( 'about to reconnect..........' )
|
||||||
try:
|
try:
|
||||||
self.disconnect(reconnect=self.should_reconnect, error=True)
|
self.disconnect(reconnect=self.should_reconnect, error=True)
|
||||||
@ -251,9 +247,6 @@ class XMLStream(object):
|
|||||||
logging.exception( "WTF disconnect!" )
|
logging.exception( "WTF disconnect!" )
|
||||||
logging.info( 'reconnect complete!' )
|
logging.info( 'reconnect complete!' )
|
||||||
logging.info( 'reconnect complete!' )
|
logging.info( 'reconnect complete!' )
|
||||||
logging.info( 'reconnect complete!' )
|
|
||||||
logging.info( 'reconnect complete!' )
|
|
||||||
logging.info( 'reconnect complete!' )
|
|
||||||
|
|
||||||
logging.debug('Quitting Process thread')
|
logging.debug('Quitting Process thread')
|
||||||
|
|
||||||
@ -322,9 +315,7 @@ class XMLStream(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def disconnect(self, reconnect=False, error=False):
|
def disconnect(self, reconnect=False, error=False):
|
||||||
logging.info('AAAAAAAAAAAAAAAAAAAAAAAA')
|
|
||||||
with self.state.transition_ctx('connected','disconnected') as locked:
|
with self.state.transition_ctx('connected','disconnected') as locked:
|
||||||
logging.info('BBBBBBBBBBBBBBBBBBBBBBBBBB')
|
|
||||||
if not locked:
|
if not locked:
|
||||||
logging.warning("Already disconnected.")
|
logging.warning("Already disconnected.")
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user