5

I have googled a lot but unfortunately could not come up with a working solution. I have a Python client using SleekXMPP modules and I would like to send a PNG file to a Pidgin client. AFAIK, there is no Jingle extension implemented yet but a few methods using IBB, OOB and BOB did not work for me. I have tried XEPs 0047, 0231, 0095, and 0096 for negotiating.

I set my Pidgin to auto-accept files from a certain JID.

Is there any way doing that using SleekXMPP?

p.s. The book XMPP: The definitive guide did not give me any clue too :/

Thanks.

CODE

def upload_files_tgz(self, archivename, files, removearch=True):
    # tar file name and mimetype (b for binary)
    bfilename = "{0}.tar.gz".format(archivename)
    bfilemime = "application/x-gzip";
    # create a compressed tgz archive
    tar = tarfile.open(bfilename, "w:gz" )
    if files:
        for f in files:
            tar.add(f)
    tar.close()

    with open(bfilename, "rb") as compressed_file:
        bin_output = compressed_file.read()

    cid = self.xmpp_bot['xep_0231'].set_bob(bin_output, bfilemime)
    msg = self.xmpp_bot.Message()
    msg['to'] = self.get_xmpp_server_full_jid()
    msg['bob']['cid'] = cid
    msg['bob']['type'] = bfilemime
    msg['bob']['data'] = bin_output
    msg.send()

    if removearch == True:
        os.remove(bfilename)

def upload_image(self, filename, mimetype='image/png', message=None):
    m = self.xmpp_bot.Message()
    m['to'] = self.get_xmpp_server_full_jid()
    m['type'] = 'chat'
    with open(filename, 'rb') as img_file:
        img = img_file.read()
    if img:
        cid = self.xmpp_bot['xep_0231'].set_bob(img, mimetype)
        if message:
            m['body'] = message
        m['html']['body'] = '<img src="cid:%s" />' % cid
        m.send()
The_Cute_Hedgehog
  • 1,280
  • 13
  • 22
  • Two methods are provided along the question. The former is an attempt to send a compressed file formed by a list of files and the latter is simply trying to send an image. They both use the `BOB`, I guess. The other attempts no longer exist in my scratches. Thanks for the notice BTW @User. – The_Cute_Hedgehog Mar 02 '14 at 12:58

0 Answers0