root/trunk/RBJabber/RBJabber/component.py

Revision 457, 2.4 kB (checked in by sholloway, 6 years ago)

*** empty log message ***

Line 
1 #!/usr/bin/env python
2 ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 ##~ License
4 ##~
5 ##- The RuneBlade Foundation library is intended to ease some
6 ##- aspects of writing intricate Jabber, XML, and User Interface (wxPython, etc.)
7 ##- applications, while providing the flexibility to modularly change the
8 ##- architecture. Enjoy.
9 ##~
10 ##~ Copyright (C) 2002  TechGame Networks, LLC.
11 ##~
12 ##~ This library is free software; you can redistribute it and/or
13 ##~ modify it under the terms of the BSD style License as found in the
14 ##~ LICENSE file included with this distribution.
15 ##~
16 ##~ TechGame Networks, LLC can be reached at:
17 ##~ 3578 E. Hartsel Drive #211
18 ##~ Colorado Springs, Colorado, USA, 80920
19 ##~
20 ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21
22 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23 #~ Imports
24 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25
26 from xml.sax.saxutils import escape, quoteattr
27 from RBFoundation.XMLObjectify import BaseObjectifiedXML
28 from RBFoundation.XMLClassBuilder import ElementFactory as EF
29 from JabberConnection import JabberConnection
30 import JID
31 import sha
32
33 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34 #~ Definitions
35 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36
37 class Component(JabberConnection):
38     # NOTE: Very preliminary!
39
40     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41     #~ Constants / Variables / Etc.
42     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
43
44     ElementFactories = JabberConnection.ElementFactories.copy()
45     ElementFactories.update({
46         None: EF.Static(BaseObjectifiedXML),
47         })
48
49     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50     #~ Public Methods
51     #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52
53     def Startup(self, JabberServerURL, port, ServerJID=None, namespace='jabber:component:accept', **kw):
54         return super(Component, self).Startup(JabberServerURL, port, ServerJID, namespace, **kw)
55
56     def Handshake(self, secret, id=None):
57         data = sha.new(id or self.id)
58         data.update(secret)
59         self.SendXML('<handshake>%s</handshake>' % data.hexdigest())
60
61 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62 #~ Testing
63 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64
65 if __name__=='__main__':
66     print "Testing..."
67     import sys
68     jc = Component('cvs-holloways', 5999, 'shanetest.cvs-holloways', fileIn=sys.stdout, fileOut=sys.stdout)
69     jc.ProcessPending(1.0)
70     print "Test complete."
71
72
Note: See TracBrowser for help on using the browser.