]> code.delx.au - pymsnt/blob - src/baseproto/glue.py
d273dfc9bf917be4154a65c34608e243f0995748
[pymsnt] / src / baseproto / glue.py
1 # Copyright 2004 James Bunton <james@delx.cjb.net>
2 # Licensed for distribution under the GPL version 2, check COPYING for details
3
4 from tlib.domish import Element
5 import groupchat
6
7 # The name of the transport
8 name = "Foo Transport"
9
10 # The transport version
11 version = "0.1"
12
13 # XDB '@' -> '%' mangling
14 mangle = True
15
16 # The transport identifier (eg, aim, icq, msn)
17 id = "foo"
18
19 # This should be set to the name space registration entries are in, in the xdb spool
20 namespace = "jabber:iq:register"
21
22
23
24 def isGroupJID(jid):
25 """ Returns True if the JID passed is a valid groupchat JID (eg, for MSN, if it does not contain '%') """
26 pass
27
28
29
30 def formRegEntry(username, password, nickname):
31 """ Returns a domish.Element representation of the data passed. This element will be written to the XDB spool file """
32 pass
33
34
35
36 def getAttributes(base):
37 """ This function should, given a spool domish.Element, pull the username, password,
38 and nickname out of it and return them """
39 pass
40 # return username, password, nickname
41
42
43
44
45 def translateAccount(legacyaccount):
46 """ Translates the legacy account into a Jabber ID, eg, user@hotmail.com --> user%hotmail.com@msn.jabber.org """
47 pass
48
49
50
51 class LegacyGroupchat(groupchat.BaseGroupchat):
52 """ A class to represent a groupchat on the legacy service. All the functions below
53 must be implemented to translate messages from Jabber to the legacy protocol.
54 Look in groupchat.py for available functions to call.
55 """
56 def __init__(self, session, resource, ID=None):
57 groupchat.BaseGroupchat.__init__(self, session, resource, ID)
58 # Initialisation stuff for the legacy protocol goes here
59
60 def removeMe(self):
61 """ Cleanly remove the the groupchat, including removing the user from the legacy room """
62 groupchat.BaseGroupchat.removeMe(self)
63
64 def sendLegacyMessage(self, message):
65 """ Send this message to the legacy room """
66
67 def sendContactInvite(self, contactJID):
68 """ Invite this user to the legacy room """
69
70
71
72
73 class LegacyConnection:
74 """ A base class that must have all functions reimplemented by legacy protocols to translate
75 from Jabber to that legacy protocol. Any incoming events from the legacy system must be
76 translated by calling the appropriate functions in the Session, JabberConnection or PyTransport classes.
77 You must also set self.session.ready = True at some point (usually when you have been connected to the
78 legacy service """
79 def __init__(self, session):
80 pass
81
82 def removeMe(self):
83 """ Called by PyTransport when the user's session is ending.
84 Must cleanly delete this object. Including sending an offline presence packet
85 for any contacts that may be on the user's list """
86 pass
87
88 def resourceOffline(self, resource):
89 """ Called whenever one of the local user's resources goes offline """
90 pass
91
92 def sendMessage(self, dest, resource, body, noerror):
93 """ Called whenever PyTransport wants to send a message to a remote user """
94 pass
95
96 def setStatus(self, show, friendly):
97 """ Called whenever PyTransport needs to change the status on the legacy service
98 'show' is a Jabber status description, and friendly is a friendly name for the contact """
99 pass
100
101 def newResourceOnline(self, resource):
102 """ Called by PyTransport when a new resource comes online. You should send them any legacy contacts' status """
103 pass
104
105 def jabberSubscriptionReceived(self, to, subtype):
106 """ Called by PyTransport whenever a Jabber subscription packet is received """
107 pass
108
109 def userTypingNotification(self, dest, composing):
110 """ Called by PyTransport whenever the Jabber user has sent typing notification to a contact """
111 pass
112
113