On 07/07/06 at 13:24 +0200, David E Freitas wrote:
> Hi,
> 
> I thought I'd suggest a config flag to disable avatar handling. Some
> servers might not want to do avatar handling. As it's unnecessary data
> transfer if not being used by the client.
> 
> I put the necessary code changes below.
> 
> Just compare the current code, and the changes are pretty logical.
> 
> James, can you please check that I've covered all the proper places?
> 
> ## comments are the added/edited parts
> 
> CONFIG.XML
> ----------
> 
> <!-- Added boolean to enable or disable avatar sending/receiving;
> Comment out to disable. -->
> <!-- <allowAvatars/> -->
> 
> 
> CONFIG.PY
> ----------
> ...
> allowAvatars = False  ## ADD THIS DEFAULT
> ...
> 
> MAIN.PY
> -------
> ...
>  if config.allowAvatars: ##ADDDED THIS CHECK
>   self.iqAvatarFactor = misciq.IqAvatarFactory(self)
> ...
> 
> MSN.PY
> -------
> # ADD: pyMSN imports
> import config ## ADD IMPORT
> ....
> 
> def handle_ILN(self, params):
> ....
> 
> if config.allowAvatars: ## ADDED this check:
>     if len(params) > 5:
>   self.handleAvatarHelper(msnContact, params[5])
>  else:
>   self.handleAvatarGoneHelper (msnContact)
> self.gotContactStatus(params[2], params[1], unquote(params[3]))
> 
> ...
> 
> def handle_NLN(self, params):
>     ...
> 
>        if config.allowAvatars: ## ADDED this check
>         if len(params) > 4:
>             self.handleAvatarHelper(msnContact, params[4])
>         else:
>             self.handleAvatarGoneHelper(msnContact)
>        self.contactStatusChanged(params[1], params[0], unquote(params[2]))
> 
> 
> SESSION.PY
> ----------
> 
> def doVCardUpdate(self):
>  def vCardReceived(el):
>   if not self.alive: return
>   LogEvent(INFO, self.jabberID)
>   vCard = None
>   for e in el.elements():
>    if e.name == "vCard" and e.uri == disco.VCARDTEMP:
>     vCard = e
>     break
>   else:
>    if config.allowAvatars: ## ADDED THIS CHECK
>     self.legacycon.updateAvatar() # Default avatar
>    return
>   avatarSet = False
>   name = ""
>   for e in vCard.elements():
>    if e.name == "NICKNAME" and e.__str__():
>     name = e.__str__()
>    if not name and e.name == "FN" and e.__str__():
>     # Give priority to nickname
>     name = e.__str__()
>    if e.name == "PHOTO" and config.allowAvatars: ## ADDED and TO THIS CHECK
>     imageData = avatar.parsePhotoEl (e)
>     if not imageData:
>      errback() # Possibly it wasn't in a supported format?
>     self.avatar = self.pytrans.avatarCache.setAvatar(imageData)
>     self.legacycon.updateAvatar(self.avatar)
>     avatarSet = True
>   if name:
>    self.updateNickname(name)
> 
>   if not avatarSet and config.allowAvatars: ## ADDED and TO THIS CHECK
>    self.legacycon.updateAvatar() # Default avatar
> 
>  def errback(args=None):
>   LogEvent(INFO, self.jabberID, "Error fetching avatar.")
> 
>   if self.alive and config.allowAvatars: ## ADDED and TO THIS CHECK
>    self.legacycon.updateAvatar()

Hi,

could you provide a patch for this, using 'svn diff' or directly 'diff' ?

Thank you,
-- 
| Lucas Nussbaum
| [EMAIL PROTECTED]   http://www.lucas-nussbaum.net/ |
| jabber: [EMAIL PROTECTED]             GPG: 1024D/023B3F4F |
From [EMAIL PROTECTED]  Sun Jul  9 01:13:54 2006
From: [EMAIL PROTECTED] (James Bunton)
Date: Sun Jul  9 01:14:05 2006
Subject: [py-transports] PyMSNt 0.11.1 released!
Message-ID: <[EMAIL PROTECTED]>

Hi all. Here are the changes since version 0.11
     * * Avatars, and other things, work better with Google Talk
     * * Adding/removing contacts is more reliable.
     * * SVN revision is checked on startup and is sent with  
jabber:iq:version results
     * * Transport doesn't 'randomly' change status on disconnection  
from MSN
     * * Reconnect automatically
     * * Groupchat timeout is configurable
     * * Compatibility with Twisted 2.2
     * * MSN file send failure message should go to both parties.  
With correct wording.
     * * More reliable avatar and file transfers.
     * * config option for service discovery name (MSN GW1, GW2, etc)
     * * Use vCard full name (FN) instead of NICKNAME if empty
     * * Fixed chunked messages
     * * Fixed error messages missing XMPP_STANZAS
     * * Fixed exception with MSNConnection.connectionFailed


I recommend all users of any version of PyMSNt upgrade to this one.
It is the most stable release so far. If you wish to disable file  
transfer, all you have to do is comment the <ftJabberPort/> option in  
config.xml

If you are running any version since 0.10.1 you can run this command  
to upgrade
svn switch svn://delx.cjb.net/pymsnt/tags/pymsnt-0.11.1


Please visit http://delx.cjb.net/pymsnt for more information, or to  
download a tarball.

Make sure you read the documentation on that page, or included with  
the tarball, for information about setting the transport up.

Have fun! :)

---

James

Reply via email to