From d72780d58db86f0be2e4cfc26cd2a40ef47d5bca Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Sat, 13 Feb 2010 15:18:39 +0000 Subject: [PATCH] debut de vcard : les avatars --- README | 2 ++ data/poezio_80.png | Bin 8457 -> 6739 bytes src/client.py | 4 +-- src/common.py | 35 ++++++++++++++++++++++ src/connection.py | 2 +- src/multiuserchat.py | 67 +++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 src/common.py diff --git a/README b/README index e9d0214e..a9aeb8a5 100644 --- a/README +++ b/README @@ -70,6 +70,8 @@ the Creative Commons BY license (http://creativecommons.org/licenses/by/2.0/) = People = Erwan Briand - Handler and MultiUserChat classes Gaëtan Ribémont (http://www.bonbref.com) - Logo design += Project = + Gajim - send_vcard method ====================== The code diff --git a/data/poezio_80.png b/data/poezio_80.png index 1065593144e0397f9aff75042ba031458456ca2c..e56c6128bb5e12e649c860ed984901baf6916699 100644 GIT binary patch delta 4081 zcmVy{D6rAs2rD2XskIMF-jf z4FfeZ=zIgM000k#Nklk8CpE~W6+lMr9nrTzFFPXM!I+@P2olYm0)^Te`fF(_KWL_)ZZK}4ujtriy-rChF1ES33KZ~R|DJ`YUv^~QfmXKxKiSxao|PsRb+ zqpCkJ#_VouZPER^wo7+s2davyzVE%NiijY97$JB5vW`wn3GhHFlRJ0IU*lTgTVFEK zA#l;Ec0RO!mu&0q)Zp_6ApNAFD1tCEw?O*TxuS@~08M3bANq5dRSjBi!e?OOZ`9hG ziM{u3Jp4p2+q!={mwovn@`3DoKU=)}I@?>>*wGeM)i2x%c&nO$eZ6r6Viq#(t91;LyjK?RXehonU|FUs$A?$|G zrSuW-s3%KekknuFB<+D`jKNx4kCnlgoi73$TUP+~ClfJMoqTBDeY&-)Q;cH>hr?J4 zMyv-;L$H5<1r=15!smf!Ef~`PajC2Yn7AVp-^F|!UArgsr zAJQ~FYD1>t@z3~~Q2aZ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gA|3uu?3+~G~KuGzgxH^9JwD2Y~&}d zlP>l!f35{`Gd=+$z|$8ydCkL(-T(n6$B$u0E9K4Z$GRm%B!OCpF?YZ8YI6Y zZkXtg7tBsEZD1#V{pSY%C!6l&99C0@EctSc1YnDFTtB~QKK_}bQj~^KWAkonO52vr zdGe^ahfoX}4HT!}RQzJeXSOR_#eqcfW+;4TGruviX&KF0o(}j(%0gD8*C0KYb{~K?!wNuu3{81O@@pbE zoRB~@1_Tkj8kakO)c`&OuoXb7^n9b?%Zo-MpOoJnlTs!~5m=0Aa$^zL*AEpygZb_R z@HT)I0B+{VCkYP%e#ue4BISL|kOQ8ORy|=n!t$WSgl7P}24EwA#2oKEftf97%R(N+ zgr5TNTOKG9_>{_nXkZv3A8#Z5)XC#EhX<7Z4*(bVy~}I3O2002ovPDHLkV1ntC B{pJ7w diff --git a/src/client.py b/src/client.py index 9840d259..d3561a86 100644 --- a/src/client.py +++ b/src/client.py @@ -20,8 +20,8 @@ import sys # disable any printout (this would mess the display) stderr = sys.stderr -sys.stdout = open('/dev/null', 'w') -sys.stderr = open('/dev/null', 'w') +# sys.stdout = open('/dev/null', 'w') +# sys.stderr = open('/dev/null', 'w') from connection import Connection from multiuserchat import MultiUserChat diff --git a/src/common.py b/src/common.py new file mode 100644 index 00000000..015f1cec --- /dev/null +++ b/src/common.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- + +# Copyright 2010, Florent Le Coz + +# This program 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 of the License. + +# This program 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 this program. If not, see . + +# various useful functions + +import base64 +import os +import mimetypes +import hashlib + +def get_base64_from_file(path): + if not os.path.isfile(path): + return (None, None, "File does not exist") + size = os.path.getsize(path) + if size > 16384: + return (None, None,"File is too big") + fd = open(path, 'rb') + data = fd.read() + encoded = base64.encodestring(data) + sha1 = hashlib.sha1(data).hexdigest() + mime_type = mimetypes.guess_type(path)[0] + return (encoded, mime_type, sha1) diff --git a/src/connection.py b/src/connection.py index 8a042502..2dec8f35 100644 --- a/src/connection.py +++ b/src/connection.py @@ -52,7 +52,7 @@ class Connection(threading.Thread): if not self.authenticate(): logger.error('Could not authenticate to server') sys.exit(-1) - self.client.sendInitPresence() + self.client.sendInitPresence(requestRoster=0) self.online = 1 # 2 when confirmation of auth is received self.register_handlers() while 1: diff --git a/src/multiuserchat.py b/src/multiuserchat.py index 4f132fd4..8c948513 100644 --- a/src/multiuserchat.py +++ b/src/multiuserchat.py @@ -19,6 +19,9 @@ from xmpp import NS_MUC_ADMIN, NS_MUC from xmpp.protocol import Presence, Iq, Message, JID +import xmpp +import common +import threading from handler import Handler from config import config @@ -34,9 +37,72 @@ def is_jid(jid): if JID(jid).getNode() != '': return True +class VcardSender(threading.Thread): + """ + avatar sending is really slow (don't know why...) + use a thread to send it... + """ + def __init__(self, connection): + threading.Thread.__init__(self) + self.connection = connection + self.handler = Handler() + + def run(self): + self.send_vcard() + + def send_vcard(self): + """ + Method stolen from Gajim (thanks) + ## Copyright (C) 2006 Dimitur Kirov + ## Junglecow J + ## Copyright (C) 2006-2007 Tomasz Melcer + ## Travis Shirk + ## Nikos Kouremenos + ## Copyright (C) 2006-2008 Yann Leboulanger + ## Copyright (C) 2007 Julien Pivotto + ## Copyright (C) 2007-2008 Brendan Taylor + ## Jean-Marie Traissard + ## Stephan Erb + ## Copyright (C) 2008 Jonathan Schleifer + (one of these people coded this method, probably) + """ + if not self.connection: + return + vcard = { + "FN":"Poezio tester", + } + photo_file_path = config.get('photo', '../data/poezio_80.png') + (image, mime_type, sha1) = common.get_base64_from_file(photo_file_path) + if image: + vcard['PHOTO'] = {"TYPE":mime_type,"BINVAL":image} + iq = xmpp.Iq(typ = 'set') + iq2 = iq.setTag(xmpp.NS_VCARD + ' vCard') + for i in vcard: + if i == 'jid': + continue + if isinstance(vcard[i], dict): + iq3 = iq2.addChild(i) + for j in vcard[i]: + iq3.addChild(j).setData(vcard[i][j]) + elif isinstance(vcard[i], list): + for j in vcard[i]: + iq3 = iq2.addChild(i) + for k in j: + iq3.addChild(k).setData(j[k]) + else: + iq2.addChild(i).setData(vcard[i]) + # id_ = self.connect.getAnId() + # iq.setID(id_) + self.connection.send(iq) + iq = xmpp.Iq(typ = 'set') + iq2 = iq.setTag(xmpp.NS_VCARD_UPDATE) + iq2.addChild('PHOTO').setData(sha1) + self.connection.send(iq) + class MultiUserChat(object): def __init__(self, connection): self.connection = connection + self.vcard_sender = VcardSender(self.connection) self.rooms = [] self.rn = {} @@ -64,6 +130,7 @@ class MultiUserChat(object): else: nick = config.get('default_nick', 'poezio') self.handler.emit('join-room', room=roomname, nick=nick) + self.vcard_sender.start() def send_message(self, room, message): mes = Message(to=room)