Package twisted :: Package protocols :: Module msn

[show private | hide private]
[frames | no frames]

## Module twisted.protocols.msn

MSNP7 Protocol (client only)

Stability: unstable.

This module provides support for clients using the MSN Protocol (MSNP7). There are basically 3 servers involved in any MSN session:

1. Dispatch server

   The MSNDispatchClient class handles connections to the dispatch server, which basically delegates users to a suitable notification server.

   You will want to subclass this and handle the gotReferral method appropriately.

2. Notification Server

   The MSNNotificationClient class handles connections to the notification server, which acts as a session server (state updates, message negotiation etc...)

3. Switcboard Server

   The MSNSwitchboardClient handles connections to switchboard servers which are used to conduct conversations with other users.

There are also two classes (MSNFileSend and MSNFileReceive) used for file transfers.

Clients handle events in two ways.

- each client request requiring a response will return a Deferred, the callback for same will be fired when the server sends the required response .
- Events which are not in response to any client request have respective methods which should be overridden and handled in an adequate manner

Most client request callbacks require more than one argument, and since Deferreds can only pass the callback one result, most of the time the callback argument will be a tuple of values (documented in the respective request method). To make reading/writing code easier, callbacks can be defined in a number of ways to handle this 'cleanly'. One way would be to define methods like: def callBack(self, (arg1, arg2, arg)): ... another way would be to do something like d.addCallback(lambda result: myCallback(*result)).

If the server sends an error response to a client request, the errback of the corresponding Deferred will be called, the argument being the corresponding error code.

NOTE Due to the lack of an 'official' spec for MSNP7, extra checking than may be deemed necessary often takes place considering the server is never 'wrong'. Thus, if gotBadLine (in any of the 3 main clients) is called, or an MSNProtocolError is raised, it's probably a good idea to submit a bug report. ;)

# TODO

- check message hooks with invalid x-msgsinvite messages.
- font handling
- create factories for each respective client

Author: Sam Jordan<mailto:sam@twistedmatrix.com>

Classes
`MSNContact` | This class represents a contact (user).
`MSNContactList` | This class represents a basic MSN contact list.
`MSNDispatchClient` | This class provides support for clients connecting to the dispatch server
`MSNEventBase` | This class provides support for handling / dispatching events and is the base class of the three main client protocols (MSNDispatchClient, MSNNotificationClient, MSNSwitchboardClient)
`MSNFileReceive` | This class provides support for receiving files from contacts.
`MSNFileSend` | This class provides support for sending files to other contacts.
`MSNMessage` | I am the class used to represent an 'instant' message.
`MSNNotificationClient` | This class provides support for clients connecting to the notification server.
`MSNSwitchboardClient` | this class provides support for clients connecting to a switchboard server.

Exceptions
`MSNProtocolError` | This Exception is basically used for debugging purposes, as the official MSN server should never send anything _wrong_ and nobody in their right mind would run their ownMSN server...if it is raised by default command handlers (handle_BLAH) the error will be logged.

Function Summary
| `checkParamLen(num, expected, cmd, error)`

Variable Summary
`str` | `ALLOW_LIST`
`str` | `BLOCK_LIST`
`str` | `CR`
`dict` | `errorCodes`
`str` | `FORWARD_LIST`
`str` | `HAS_PAGER`
`str` | `HOME_PHONE`
`str` | `LF`
`str` | `MOBILE_PHONE`
`str` | `MSN_CHALLENGE_STR`
`int` | `MSN_MAX_MESSAGE`
`int` | `MSN_PORT`
`str` | `MSN_PROTOCOL_VERSION`
`_Feature` | `nested_scopes`
`instance method` | `randint`
`SelectReactor` | `reactor`
`str` | `REVERSE_LIST`
`str` | `STATUS_AWAY`
`str` | `STATUS_BRB`
`str` | `STATUS_BUSY`
`str` | `STATUS_HIDDEN`
`str` | `STATUS_IDLE`
`str` | `STATUS_LUNCH`
`str` | `STATUS_OFFLINE`
`str` | `STATUS_ONLINE`
`str` | `STATUS_PHONE`
`dict` | `statusCodes`
`str` | `WORK_PHONE`

Variable Details

### ALLOW_LIST

  Type:
    `str`
  Value:

        'al'

### BLOCK_LIST

  Type:
    `str`
  Value:

        'bl'

### CR

  Type:
    `str`
  Value:

        '\r'

### errorCodes

  Type:
    `dict`
  Value:

        {200: 'Syntax error',
         201: 'Invalid parameter',
         205: 'Invalid user',
         206: 'Domain name missing',
         207: 'Already logged in',
         208: 'Invalid username',
         209: 'Invalid screen name',
         210: 'User list full',
        ...

### FORWARD_LIST

  Type:
    `str`
  Value:

        'fl'

### HAS_PAGER

  Type:
    `str`
  Value:

        'MOB'

### HOME_PHONE

  Type:
    `str`
  Value:

        'PHH'

### LF

  Type:
    `str`
  Value:

        '''
        '''

### MOBILE_PHONE

  Type:
    `str`
  Value:

        'PHM'

### MSN_CHALLENGE_STR

  Type:
    `str`
  Value:

        'Q1P7W2E4J9R8U3S5'

### MSN_MAX_MESSAGE

  Type:
    `int`
  Value:

        1664

### MSN_PORT

  Type:
    `int`
  Value:

        1863

### MSN_PROTOCOL_VERSION

  Type:
    `str`
  Value:

        'MSNP7'

### nested_scopes

  Type:
    `_Feature`
  Value:

        _Feature((2, 1, 0, 'beta', 1), (2, 2, 0, 'alpha', 0), 16)

### randint

`randint` = `random.Random.randint`

  Type:
    `instance method`
  Value:

        <bound method Random.randint of <random.Random instance at 0x81ab22c>>

### reactor

  Type:
    `SelectReactor`
  Value:

        <twisted.internet.default.SelectReactor instance at 0x82e8c8c>

### REVERSE_LIST

  Type:
    `str`
  Value:

        'rl'

### STATUS_AWAY

  Type:
    `str`
  Value:

        'AWY'

### STATUS_BRB

  Type:
    `str`
  Value:

        'BRB'

### STATUS_BUSY

  Type:
    `str`
  Value:

        'BSY'

### STATUS_HIDDEN

  Type:
    `str`
  Value:

        'HDN'

### STATUS_IDLE

  Type:
    `str`
  Value:

        'IDL'

### STATUS_LUNCH

  Type:
    `str`
  Value:

        'LUN'

### STATUS_OFFLINE

  Type:
    `str`
  Value:

        'FLN'

### STATUS_ONLINE

  Type:
    `str`
  Value:

        'NLN'

### STATUS_PHONE

  Type:
    `str`
  Value:

        'PHN'

### statusCodes

  Type:
    `dict`
  Value:

        {'AWY': 'Away',
         'BRB': 'Be Right Back',
         'BSY': 'Busy',
         'FLN': 'Offline',
         'HDN': 'Appear Offline',
         'IDL': 'Idle',
         'LUN': 'Out to Lunch',
         'NLN': 'Online',
        ...

### WORK_PHONE

  Type:
    `str`
  Value:

        'PHW'

Generated by Epydoc 1.1 on Thu May 8 13:16:40 2003 | http://epydoc.sf.net