This commit is contained in:
Nathan Fritz 2009-09-05 07:38:29 +00:00
parent 5593848490
commit cb360c9479
3 changed files with 10 additions and 5 deletions

View file

@ -264,7 +264,7 @@ class basexmpp(object):
with self.lock:
self.event_handlers[name].pop(self.event_handlers[name].index(handler))
def makeMessage(self, mto, mbody='', msubject=None, mtype=None, mhtml=None, mfrom=None):
def makeMessage(self, mto, mbody='', msubject=None, mtype=None, mhtml=None, mfrom=None, mnick=None):
message = ET.Element('{%s}message' % self.default_ns)
if mfrom is None:
message.attrib['from'] = self.fulljid
@ -289,6 +289,11 @@ class basexmpp(object):
subject = ET.Element('subject')
subject.text = msubject
message.append(subject)
if mnick:
print("generating nick")
nick = ET.Element("{http://jabber.org/protocol/nick}nick")
nick.text = mnick
message.append(nick)
return message
def makePresence(self, pshow=None, pstatus=None, ppriority=None, pto=None, ptype=None, pfrom=None):
@ -315,8 +320,8 @@ class basexmpp(object):
presence.attrib['from'] = pfrom
return presence
def sendMessage(self, mto, mbody, msubject=None, mtype=None, mhtml=None, mfrom=None):
self.send(self.makeMessage(mto,mbody,msubject,mtype,mhtml,mfrom))
def sendMessage(self, mto, mbody, msubject=None, mtype=None, mhtml=None, mfrom=None, mnick=None):
self.send(self.makeMessage(mto,mbody,msubject,mtype,mhtml,mfrom,mnick))
def sendPresence(self, pshow=None, pstatus=None, ppriority=None, pto=None, pfrom=None):
self.send(self.makePresence(pshow,pstatus,ppriority,pto, pfrom=pfrom))

View file

@ -96,7 +96,7 @@ class ComponentXMPP(basexmpp, XMLStream):
def start_stream_handler(self, xml):
sid = xml.get('id', '')
handshake = ET.Element('{jabber:component:accept}handshake')
handshake.text = hashlib.sha1.new(b"%s%s" % (sid, self.secret)).hexdigest().lower()
handshake.text = hashlib.sha1(bytes("%s%s" % (sid, self.secret), 'utf-8')).hexdigest().lower()
self.send(handshake)
def _handleHandshake(self, xml):

View file

@ -248,8 +248,8 @@ class XMLStream(object):
def __spawnEvent(self, xmlobj):
"watching xmlOut and processes handlers"
#convert XML into Stanza
logging.debug("RECV: %s" % cElementTree.tostring(xmlobj))
xmlobj = self.incoming_filter(xmlobj)
logging.debug("PROCESSING: %s" % xmlobj.tag)
stanza = None
for stanza_class in self.__root_stanza:
if self.__root_stanza[stanza_class].match(xmlobj):