On Wed, Jan 04, 2006 at 01:05:12PM +0100, Stian B. Barmen wrote:
> But that seems to be minor, and not critical at least. But, if I try
> from a Windows Messenger client (you remember, the very old one that
> comes preinstalled in windows xp?) the sending never starts and my
> jabber client never gets notified of an incoming file transfer. In
> debug I get: 
> 
> 2006/01/04 12:56 CET [OneSwitchboardSession,client] Traceback (most recent 
> call last):
[snip]
>           File "/usr/local/PyMSNt/src/tlib/msn/msn.py", line 823, in 
> rawDataReceived
>             self.currentMessage.readPos += len(data)
>         exceptions.AttributeError: 'NoneType' object has no attribute 
> 'readPos'
> 
> 2006/01/04 12:56 CET [OneSwitchboardSession,client] Stopping factory 
> <twisted.internet.protocol.ClientFactory instance at 0xb72852ac>

I finally got access to a version of Windows Messenger (version 4.7),
and I'm able to confirm this error. However, on the first attempt I get
this traceback:

2006/01/04 19:33 CET [OneSwitchboardSession,client] Traceback (most recent call 
last):
[snip]
          File "[...]/src/tlib/msn/msn.py", line 2093, in _checkFileInvitation
            connectivity = (info.get('Connectivity').lower() == 'y')
        exceptions.AttributeError: 'NoneType' object has no attribute 'lower'

2006/01/04 19:33 CET [OneSwitchboardSession,client] Stopping factory 
<twisted.internet.protocol.ClientFactory instance at 0xb757efac>

This exception occurs because the Connectivity header is missing (I
think the header is optional). As far as I was able to determine, this
error will eventually lead to the 'readPos' error on future file
transfer attempts. When an exception occurs the ClientFactory is stopped
(as it can be seen above), however, the OneSwitchboardSession object is
not destroyed nor removed from the switchboardSessions dictionary. So
when the next file transfer attempt is made, the OneSwitchboardSession
object is reused - and that object was in raw mode when the exception
occurred.

My initial idea to fix this problem, was to remove the corresponding
OneSwitchboardSession object from switchboardSessions, if the
ClientFactory is stopped. However, I couldn't figure out how to do that.

The current fix is to set the OneSwitchboardSession object to line mode
if it is reused. However, I don't know if the object has other states
that needs to be reset - or if it will break things to reset it to line
mode. Perhaps it will be to complex to ensure that the
OneSwitchboardSession object will be reusable after an exception has
occurred, and we just have to ensure that exceptions do not occur.

> Reproduce: send file from msn 7.5 = works, then send file from windows
> messenger = fails, then send file from msn 7.5 = fails, then log
> off-on transport, then file transfer from msn 7.5 = works. 

Windows Messenger seems to use an older protocol for file transfers
(text/x-msmsgsinvite vs. application/x-msnmsgrp2p), that is not yet
supported in PyMSNt. So even with the attached patch, you won't be able
to receive files from Windows Messenger. However, you should be able to
send a file from MSN Messenger after a failed transfer from Windows
Messenger, without having to log out. It haven't tested it though.

Best regards,
Lars
-------------- next part --------------
Index: src/tlib/msn/msn.py
===================================================================
--- src/tlib/msn/msn.py (revision 86)
+++ src/tlib/msn/msn.py (working copy)
@@ -2090,7 +2090,8 @@
             cookie = info['Invitation-Cookie']
             filename = info['Application-File']
             filesize = int(info['Application-FileSize'])
-            connectivity = (info.get('Connectivity').lower() == 'y')
+            if info.has_key('Connectivity'):
+                connectivity = (info['Connectivity'].lower() == 'y')
         except KeyError:
             log.msg('Received munged file transfer request ... ignoring.')
             return 0
Index: src/tlib/msn/msnw.py
===================================================================
--- src/tlib/msn/msnw.py        (revision 86)
+++ src/tlib/msn/msnw.py        (working copy)
@@ -422,6 +422,7 @@
                sb = self.factory.msncon.switchboardSessions.get(userHandle)
                if sb and sb.transport:
                        sb.transport.loseConnection()
+                       sb.setLineMode()
                else:
                        sb = OneSwitchboardSession(self.factory.msncon, 
userHandle)
                        self.factory.msncon.switchboardSessions[userHandle] = sb
From [EMAIL PROTECTED]  Thu Jan  5 08:01:02 2006
From: [EMAIL PROTECTED] (Stian B. Barmen)
Date: Thu Jan  5 08:01:10 2006
Subject: [py-transports] PyMSNt File transfer Windows Messenger woes :/
In-Reply-To: <[EMAIL PROTECTED]>
Message-ID: <[EMAIL PROTECTED]>

> 
> Windows Messenger seems to use an older protocol for file 
> transfers (text/x-msmsgsinvite vs. application/x-msnmsgrp2p), 
> that is not yet supported in PyMSNt. So even with the 
> attached patch, you won't be able to receive files from 
> Windows Messenger. However, you should be able to send a file 
> from MSN Messenger after a failed transfer from Windows 
> Messenger, without having to log out. It haven't tested it though.
> 

Just tested your patch, could not get the patch to apply cleanly, but I did it 
manually and it seems to work just as you say. The TB execption still happens 
when using windows messenger, but it does not cause the permanent error anymore.

Very good patch Lars, thanks :)

-stian

Reply via email to