~ubuntu-branches/debian/sid/openchange/sid

« back to all changes in this revision

Viewing changes to mapiproxy/services/client/OCSManager/ClientNotification.py

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2012-04-12 20:07:57 UTC
  • mfrom: (11 sid)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20120412200757-k933d9trljmxj1l4
Tags: 1:1.0-4
* openchangeserver: Add dependency on openchangeproxy.
* Rebuild against newer version of Samba 4.
* Use dpkg-buildflags.
* Migrate to Git, update Vcs-Git header.
* Switch to debhelper 9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import os
 
4
from lxml import etree
 
5
 
 
6
"""
 
7
OCSManager Client Notification documentation
 
8
"""
 
9
 
 
10
class ClientNotification(object):
 
11
    """Client Notification class documentation. Prepare XML request
 
12
    payloads and analyze response payloads.
 
13
    """
 
14
 
 
15
    def __init__(self):
 
16
        return None
 
17
 
 
18
    def setNewMailPayload(self, tokenLogin=None, newmail=None):
 
19
        """Prepare newmail payload.
 
20
        """
 
21
        if tokenLogin is None: return (True, 'User not authenticated')
 
22
        if newmail is None: return (True, 'Missing newmail arguments')
 
23
 
 
24
        # Sanity checks on newmail dictionary
 
25
        if not "backend" in newmail: return (True, 'Missing backend parameter')
 
26
        if not "username" in newmail: return (True, 'Missing username parameter')
 
27
        if not "folder" in newmail: return (True, 'Missing folder parameter')
 
28
        if not "msgid" in newmail: return (True, 'Missing msgid parameter')
 
29
 
 
30
        root = etree.Element('ocsmanager')
 
31
        token = etree.SubElement(root, "token")
 
32
        token.text = tokenLogin
 
33
        
 
34
        notification = etree.SubElement(root, "notification", category="newmail")
 
35
 
 
36
        backend = etree.SubElement(notification, "backend")
 
37
        backend.text = newmail['backend']
 
38
 
 
39
        username = etree.SubElement(notification, "username")
 
40
        username.text = newmail['username']
 
41
 
 
42
        folder = etree.SubElement(notification, "folder")
 
43
        folder.text = newmail['folder']
 
44
 
 
45
        messageID = etree.SubElement(notification, "messageID")
 
46
        messageID.text = newmail['msgid']
 
47
 
 
48
        return (False, etree.tostring(root, xml_declaration=True, encoding="utf-8"))