G
gliderman
Hi
I am trying to use a python version of gloox (XMPP client library
written in C++). The python binding is done using SWIG (provided by the
author of gloox). I am trying to adapt first a c++ example to python.
The code below fails with
Traceback (most recent call last):
File "tutu.py", line 54, in ?
t.run()
File "tutu.py", line 28, in run
self.f = gloox.SIProfileFT( self.c, self )
File
"/home/karim/boulot/gliders/archi/project//lib/python2.4/site-packages/gloox/gloox.py",
line 1965, in __init__
this = _gloox.new_SIProfileFT(*args)
NotImplementedError: Wrong number of arguments for overloaded function
'new_SIProfileFT'.
Possible C/C++ prototypes are:
gloox::SIProfileFT(gloox::ClientBase *,gloox::SIProfileFTHandler
*,gloox::SIManager *,gloox::SOCKS5BytestreamManager *)
gloox::SIProfileFT(gloox::ClientBase *,gloox::SIProfileFTHandler
*,gloox::SIManager *)
gloox::SIProfileFT(gloox::ClientBase *,gloox::SIProfileFTHandler *)
If I comment gloox.LogHandler.__init__( self ) (and
self.c.logInstance().registerLogHandler( gloox....), it "works".
The order to initialize the objects seems to be important. The error can
differ with the order of __init__ .
Moreover when I replace
C++ : m_s5b->registerSOCKS5BytestreamDataHandler( this );
by its python version: self.m_s5b.registerSOCKS5BytestreamDataHandler(self)
a pointer object in m_s5b is always null (it shouldnt).
There is no constructor in c++ classes
SIProfileFTHandler,LogHandler,ConnectionListener,
SOCKS5BytestreamDataHandler (almost pure virtual).
import gloox
import sys
import os
class MyClient(
gloox.SIProfileFTHandler,gloox.LogHandler,gloox.ConnectionListener,gloox.SOCKS5BytestreamDataHandler):
def __init__( self ):
gloox.ConnectionListener.__init__( self )
gloox.SOCKS5BytestreamDataHandler.__init__( self )
gloox.SIProfileFTHandler.__init__( self )
gloox.LogHandler.__init__( self )
self.j = gloox.JID( "test@localhost/yop" )
self.c = gloox.Client( self.j, 'test' )
self.f=None
def run(self):
self.c.registerConnectionListener(self )
self.c.logInstance().registerLogHandler( gloox.LogLevelDebug,
gloox.LogAreaAll,self)
m_server=gloox.SOCKS5BytestreamServer( self.c.logInstance(), 6666 )
le = m_server.listen()
if le != gloox.ConnNoError:
print( "listen returned: %d\n"% le)
print( "listening\n" )
self.f = gloox.SIProfileFT( self.c, self )
self.f.registerSOCKS5BytestreamServer( m_server )
self.f.addStreamHost( gloox.JID("jabberd"), "127.0.0.1", 7777 );
b = self.c.connect( False )
if b:
print 'successfully connected'
ce = gloox.ConnNoError
while ce == gloox.ConnNoError:
ce = self.c.recv( 1 )
return
def handleLog(self,level,area,message):
print("log: level: %d, area: %d, %s\n", level, area, message )
def onConnect(self):
print( "connected!!!\n" )
def onDisconnect(self, e ):
print( "ft_send: disconnected: %d\n"% e )
if e == gloox.ConnAuthenticationFailed :
print( "auth failed. reason: %d\n"% c.authError() )
###########################################################
t = MyClient()
t.run()
Thanks for any hint (and happy new year !)
Karim
I am trying to use a python version of gloox (XMPP client library
written in C++). The python binding is done using SWIG (provided by the
author of gloox). I am trying to adapt first a c++ example to python.
The code below fails with
Traceback (most recent call last):
File "tutu.py", line 54, in ?
t.run()
File "tutu.py", line 28, in run
self.f = gloox.SIProfileFT( self.c, self )
File
"/home/karim/boulot/gliders/archi/project//lib/python2.4/site-packages/gloox/gloox.py",
line 1965, in __init__
this = _gloox.new_SIProfileFT(*args)
NotImplementedError: Wrong number of arguments for overloaded function
'new_SIProfileFT'.
Possible C/C++ prototypes are:
gloox::SIProfileFT(gloox::ClientBase *,gloox::SIProfileFTHandler
*,gloox::SIManager *,gloox::SOCKS5BytestreamManager *)
gloox::SIProfileFT(gloox::ClientBase *,gloox::SIProfileFTHandler
*,gloox::SIManager *)
gloox::SIProfileFT(gloox::ClientBase *,gloox::SIProfileFTHandler *)
If I comment gloox.LogHandler.__init__( self ) (and
self.c.logInstance().registerLogHandler( gloox....), it "works".
The order to initialize the objects seems to be important. The error can
differ with the order of __init__ .
Moreover when I replace
C++ : m_s5b->registerSOCKS5BytestreamDataHandler( this );
by its python version: self.m_s5b.registerSOCKS5BytestreamDataHandler(self)
a pointer object in m_s5b is always null (it shouldnt).
There is no constructor in c++ classes
SIProfileFTHandler,LogHandler,ConnectionListener,
SOCKS5BytestreamDataHandler (almost pure virtual).
import gloox
import sys
import os
class MyClient(
gloox.SIProfileFTHandler,gloox.LogHandler,gloox.ConnectionListener,gloox.SOCKS5BytestreamDataHandler):
def __init__( self ):
gloox.ConnectionListener.__init__( self )
gloox.SOCKS5BytestreamDataHandler.__init__( self )
gloox.SIProfileFTHandler.__init__( self )
gloox.LogHandler.__init__( self )
self.j = gloox.JID( "test@localhost/yop" )
self.c = gloox.Client( self.j, 'test' )
self.f=None
def run(self):
self.c.registerConnectionListener(self )
self.c.logInstance().registerLogHandler( gloox.LogLevelDebug,
gloox.LogAreaAll,self)
m_server=gloox.SOCKS5BytestreamServer( self.c.logInstance(), 6666 )
le = m_server.listen()
if le != gloox.ConnNoError:
print( "listen returned: %d\n"% le)
print( "listening\n" )
self.f = gloox.SIProfileFT( self.c, self )
self.f.registerSOCKS5BytestreamServer( m_server )
self.f.addStreamHost( gloox.JID("jabberd"), "127.0.0.1", 7777 );
b = self.c.connect( False )
if b:
print 'successfully connected'
ce = gloox.ConnNoError
while ce == gloox.ConnNoError:
ce = self.c.recv( 1 )
return
def handleLog(self,level,area,message):
print("log: level: %d, area: %d, %s\n", level, area, message )
def onConnect(self):
print( "connected!!!\n" )
def onDisconnect(self, e ):
print( "ft_send: disconnected: %d\n"% e )
if e == gloox.ConnAuthenticationFailed :
print( "auth failed. reason: %d\n"% c.authError() )
###########################################################
t = MyClient()
t.run()
Thanks for any hint (and happy new year !)
Karim