~wgrant/papyon/master

« back to all changes in this revision

Viewing changes to pymsn/service/description/Spaces/GetXmlFeed.py

  • Committer: Ali Sabil
  • Date: 2007-08-26 14:39:42 UTC
  • Revision ID: git-v1:7544026d99efb467c57a427cbc10b30201b9b011
- Merged jprieur's branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#
 
3
# Copyright (C) 2007 Youness Alaoui <kakaroto@users.sourceforge.net>
 
4
#
 
5
# This program is free software; you can redistribute it and/or modify
 
6
# it under the terms of the GNU General Public License as published by
 
7
# the Free Software Foundation; either version 2 of the License, or
 
8
# (at your option) any later version.
 
9
#
 
10
# This program is distributed in the hope that it will be useful,
 
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
# GNU General Public License for more details.
 
14
#
 
15
# You should have received a copy of the GNU General Public License
 
16
# along with this program; if not, write to the Free Software
 
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
#
 
19
 
 
20
import xml.sax.saxutils as xml
 
21
 
 
22
#from pymsn.util.ElementTree import XMLTYPE
 
23
 
 
24
def soap_header(security_token):
 
25
    """Returns the SOAP xml header"""
 
26
 
 
27
    return """
 
28
         <AuthTokenHeader xmlns="http://www.msn.com/webservices/spaces/v1/">
 
29
            <Token>%s
 
30
            </Token>
 
31
         </AuthTokenHeader>""" % (xml.escape(security_token))
 
32
 
 
33
def transport_headers():
 
34
    """Returns a dictionary, containing transport (http) headers
 
35
    to use for the request"""
 
36
 
 
37
    return {}
 
38
 
 
39
def soap_action():
 
40
    """Returns the SOAPAction value to pass to the transport
 
41
    or None if no SOAPAction needs to be specified"""
 
42
 
 
43
    return "http://www.msn.com/webservices/spaces/v1/GetXmlFeed"
 
44
 
 
45
def soap_body(cid, market = "en-US", max_elements = 2, max_chars = 200, max_images = 6):
 
46
    """Returns the SOAP xml body"""
 
47
    # , last_viewed, app_id = "Messenger Client 8.0", update_access_time = True, is_active_contact = False
 
48
    return """
 
49
       <GetXmlFeed xmlns="http://www.msn.com/webservices/spaces/v1/">
 
50
          <refreshInformation>
 
51
             <cid xmlns="http://www.msn.com/webservices/spaces/v1/">%(cid)s</cid>
 
52
             <storageAuthCache></storageAuthCache>
 
53
             <market xmlns="http://www.msn.com/webservices/spaces/v1/">%(market)s</market>
 
54
             <brand></brand>
 
55
             <maxElementCount xmlns="http://www.msn.com/webservices/spaces/v1/">%(max_element_count)d</maxElementCount>
 
56
             <maxCharacterCount xmlns="http://www.msn.com/webservices/spaces/v1/">%(max_character_count)d</maxCharacterCount>
 
57
             <maxImageCount xmlns="http://www.msn.com/webservices/spaces/v1/">%(max_image_count)d</maxImageCount>
 
58
          </refreshInformation>
 
59
       </GetXmlFeed>
 
60
       """ % {'cid' : cid,
 
61
              'market' : market,
 
62
              'max_element_count' : max_elements,
 
63
              'max_character_count' : max_chars,
 
64
              'max_image_count' : max_images}
 
65
 
 
66
#             <applicationId>%(application_id)s</applicationId>
 
67
#             <updateAccessedTime>%(update_accessed_time)s</updateAccessedTime>
 
68
#             <spaceLastViewed>%(space_last_viewed)s</spaceLastViewed>
 
69
#             <isActiveContact>%(is_active_contact)s</isActiveContact>
 
70
 
 
71
#              'appliation_id' : app_id,
 
72
#              'update_accessed_time' : XMLTYPE.boolean.encode(update_access_time),
 
73
#              'space_last_viewed' : last_viewed,
 
74
#              'is_active_contact' : XMLTYPE.boolean.encode(is_active_contact)
 
75
 
 
76
def process_response(soap_response):
 
77
    body = soap_response.body
 
78
    try:
 
79
        response = body.find("./spaces:GetXmlFeedResponse/spaces:GetXmlFeedResult")
 
80
        return response
 
81
    except AttributeError:
 
82
        return None