]> code.delx.au - pymsnt/blob - src/baseproto/glue.py
Added a discoName option
[pymsnt] / src / baseproto / glue.py
1 # Copyright 2005 James Bunton <james@delx.cjb.net>
2 # Licensed for distribution under the GPL version 2, check COPYING for details
3
4 import utils
5 from tlib import xmlw # Provides Element, parseText, parseFile
6 import avatar
7 import groupchat
8 import config
9 import debug
10 import lang
11 import config
12
13
14 # The URL of the transport's home page
15 url = "http://foo.jabberstudio.org"
16
17 # The transport version
18 version = "0.1"
19
20 # XDB '@' -> '%' mangling
21 mangle = True
22
23 # The transport identifier (eg, aim, icq, msn)
24 id = "foo"
25
26 # This should be set to the name space registration entries are in, in the xdb spool
27 namespace = "jabber:iq:register"
28
29
30 def reloadConfig():
31 """ Is called whenever settings in the config module may have changed. """
32 pass
33
34 def isGroupJID(jid):
35 """ Returns True if the JID passed is a valid groupchat JID (eg, for MSN, if it does not contain '%') """
36 pass
37
38
39
40 def formRegEntry(username, password, nickname):
41 """ Returns a domish.Element representation of the data passed. This element will be written to the XDB spool file """
42 pass
43
44
45
46 def getAttributes(base):
47 """ This function should, given a spool domish.Element, pull the username and password
48 out of it and return them """
49 pass
50 # return username, password
51
52
53
54
55 def translateAccount(legacyaccount):
56 """ Translates the legacy account into a Jabber ID, eg, user@hotmail.com --> user%hotmail.com@msn.jabber.org """
57 pass
58
59
60 def startStats(statistics):
61 """ Fills the misciq.Statistics class with the statistics fields.
62 You must put a command_OnlineUsers and command_OnlineUsers_Desc
63 attributes into the lang classes for this to work.
64 Note that OnlineUsers is a builtin stat. You don't need to
65 reimplement it yourself. """
66 #statistics.stats["OnlineUsers"] = 0
67 pass
68
69 def updateStats(statistics):
70 """ This will get called regularly. Use it to update any global
71 statistics """
72 pass
73
74 class LegacyGroupchat(groupchat.BaseGroupchat):
75 """ A class to represent a groupchat on the legacy service. All the functions below
76 must be implemented to translate messages from Jabber to the legacy protocol.
77 Look in groupchat.py for available functions to call.
78 """
79 def __init__(self, session, resource, ID=None):
80 groupchat.BaseGroupchat.__init__(self, session, resource, ID)
81 # Initialisation stuff for the legacy protocol goes here
82
83 def removeMe(self):
84 """ Cleanly remove the the groupchat, including removing the user from the legacy room """
85 groupchat.BaseGroupchat.removeMe(self)
86
87 def sendLegacyMessage(self, message):
88 """ Send this message to the legacy room """
89
90 def sendContactInvite(self, contactJID):
91 """ Invite this user to the legacy room """
92
93
94
95 class LegacyList:
96 """ A base class that must have all functions reimplemented by legacy protocol to allow
97 legacy contact list to be accessible and modifiable from Jabber """
98 def __init__(self, session):
99 self.session = session
100
101 def removeMe(self):
102 self.session = None
103
104 def addContact(self, jid):
105 """ Must add this JID to the legacy list """
106 pass
107
108 def authContact(self, jid):
109 """ Must authorise this JID on the legacy service """
110 pass
111
112 def removeContact(self, jid):
113 """ Must remove this JID from the legacy list """
114 pass
115
116 def deauthContact(self, jid):
117 """ Must deauthorise this JID on the legacy service """
118 pass
119
120
121 class LegacyConnection:
122 """ A base class that must have all functions reimplemented by legacy protocols to translate
123 from Jabber to that legacy protocol. Any incoming events from the legacy system must be
124 translated by calling the appropriate functions in the Session, JabberConnection or PyTransport classes.
125 You must also set self.session.ready = True at some point (usually when you have been connected to the
126 legacy service """
127 def __init__(self, session):
128 self.session = session
129 self.legacyList = LegacyList()
130
131 def removeMe(self):
132 """ Called by PyTransport when the user's session is ending.
133 Must cleanly end the user's legacy protocol session and delete
134 this object. """
135 self.session = None
136 self.legacyList = None
137
138 def sendShowStatus(self, jid):
139 """ Called when the transport needs to report its current presence to jid.
140 Send the status of the user on the legacy network to the given jid. """
141 pass
142
143 def resourceOffline(self, resource):
144 """ Called whenever one of the local user's resources goes offline """
145 pass
146
147 def sendMessage(self, dest, resource, body, noerror):
148 """ Called whenever PyTransport wants to send a message to a remote user """
149 pass
150
151 def sendFile(self, dest, fileSend):
152 """ Called whenever PyTransport wants to send a file to a remote user. Call accept(fileObj), or reject(). """
153
154 def setStatus(self, nickname, show, status):
155 """ Called whenever PyTransport needs to change the status on the legacy service
156 'nickname' is the Jabber nickname, 'show' is a Jabber status description, and status
157 is a personal message describing the user's current status/activities """
158 pass
159
160 def updateAvatar(self, av=None):
161 """ Called whenever a new avatar needs to be set. Instance of avatar.Avatar is passed """
162 pass
163
164 def userTypingNotification(self, dest, composing):
165 """ Called by PyTransport whenever the Jabber user has sent typing notification to a contact """
166 pass
167
168